Re: [PATCH 1/2] staging: dwc2: when dma is disabled, clear dev->dma_mask

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Paul (& Greg),

On Thu, May 02, 2013 at 01:23:42AM +0000, Paul Zimmerman wrote:
> > From: Paul Zimmerman
> > Sent: Monday, April 29, 2013 6:27 PM
> > 
> > > From: Matthijs Kooijman [mailto:matthijs@xxxxxxxx]
> > > Sent: Monday, April 29, 2013 7:33 AM
> > >
> > >  	} else {
> > > -		dma_set_mask(hsotg->dev, 0);
> > > +		hsotg->dev->dma_mask = NULL;
> > >  		dma_set_coherent_mask(hsotg->dev, 0);
> > >  	}
> > 
> > I see a problem after applying this patch. If I insert the driver
> > modules with dwc2_module_params.dma_enable = 0, remove the modules,
> > then insert them again with dwc2_module_params.dma_enable = 1, then
> > the DMA does not get enabled. I see the message "dma_mask not set,
> > disabling DMA" from the other patch. So setting the
> > hsotg->dev->dma_mask pointer to NULL seems to be irreversible.
> > 
> > It seems like this shouldn't happen. I think hsotg->dev should get
> > deleted when the module is removed, and recreated when it is inserted
> > again. But maybe I just don't understand the device model.
> 
> Can you try the additional patch below on top of your original patch?
> This fixes the problem for me with the PCI driver, but I want to make
> sure it works for the platform device as well.

I tried your patch, but to I don't quite like it. It seems ugly to me to
have to save the dma_mask value and restore it on the module unload.

I'd say this points out that perhaps modifying the dma_mask variable
isn't the right way to tell the usb core that we don't want to be using
DMA. Instead, it seems the below alternative patch is more elegant by
simply setting hcd->self.uses_dma to 0 if we're not using dma (even
though a DMA mask is set up). If the USB core would be using the
uses_dma value during initialization already, this could create a
problem, but currently it is only used when submitting an urb, so this
should be ok.

Greg, is it ok for a HCD to modify hcd->self.uses_dma like this?

Gr.

Matthijs

diff --git a/drivers/staging/dwc2/hcd.c b/drivers/staging/dwc2/hcd.c
index d9a2055..18a91de 100644
--- a/drivers/staging/dwc2/hcd.c
+++ b/drivers/staging/dwc2/hcd.c
@@ -2766,6 +2766,9 @@ int dwc2_hcd_init(struct dwc2_hsotg *hsotg, int irq,
        if (!hcd)
                goto error1;
 
+       if (hsotg->core_params->dma_enable <= 0)
+               hcd->self.uses_dma = 0;
+
        hcd->has_tt = 1;
 
        spin_lock_init(&hsotg->lock);

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux