aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/staging/dwc2
diff options
context:
space:
mode:
authorMatthijs Kooijman <matthijs@stdin.nl>2013-07-19 11:34:22 +0200
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2013-07-23 14:59:38 -0700
commita0112f487180bd243aec86b5a8c4b5e2d45e8404 (patch)
treea6265483f271bf098ba6b589692bcf80a82c8fdc /drivers/staging/dwc2
parentstaging: dwc2: add driver parameter to set AHB config register value (diff)
downloadlinux-dev-a0112f487180bd243aec86b5a8c4b5e2d45e8404.tar.xz
linux-dev-a0112f487180bd243aec86b5a8c4b5e2d45e8404.zip
staging: dwc2: disable dma when no dma_mask was setup
If the platform or bus driver failed to setup a dma_mask, but the hardware advertises support for DMA, before DMA would be enabled in dwc2, but disabled in the usb core, making all connectivity break. With this commit, the dwc2 driver will emit a warning and fall back to slave mode in this case. Note that since commit 642f2ec (staging: dwc2: Fix dma-enabled platform devices using a default dma_mask) the platform bindings make sure a DMA mask is always present, but having this check here anyway is probably a good from a defensive programming standpoint (in case of changes to platform.c or addition of new glue layers). Signed-off-by: Matthijs Kooijman <matthijs@stdin.nl> Acked-by: Paul Zimmerman <Paul.Zimmerman@synopsys.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/staging/dwc2')
-rw-r--r--drivers/staging/dwc2/hcd.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/drivers/staging/dwc2/hcd.c b/drivers/staging/dwc2/hcd.c
index d4ef5f34c2a0..f77e66333ac7 100644
--- a/drivers/staging/dwc2/hcd.c
+++ b/drivers/staging/dwc2/hcd.c
@@ -2830,6 +2830,15 @@ int dwc2_hcd_init(struct dwc2_hsotg *hsotg, int irq,
/* Validate parameter values */
dwc2_set_parameters(hsotg, params);
+ /* Check if the bus driver or platform code has setup a dma_mask */
+ if (hsotg->core_params->dma_enable > 0 &&
+ hsotg->dev->dma_mask == NULL) {
+ dev_warn(hsotg->dev,
+ "dma_mask not set, disabling DMA\n");
+ hsotg->core_params->dma_enable = 0;
+ hsotg->core_params->dma_desc_enable = 0;
+ }
+
/* Set device flags indicating whether the HCD supports DMA */
if (hsotg->core_params->dma_enable > 0) {
if (dma_set_mask(hsotg->dev, DMA_BIT_MASK(32)) < 0)