Re: [PATCH 4/4] usb: musb: Add support for MediaTek musb controller

From: Min Guo
Date: Fri Jan 11 2019 - 00:24:56 EST


Hi Bin,

I have some questions about
musbhs_dma_controller_destroy/create_noirq().
1,Because of controller->irq=0 in noirq case, destroy_noirq can reuse
musbhs_dma_controller_destroy. Is it necessary to write a destroy_noirq
function?
2, How about creating a common function for create musb dma controller
as following:
static struct musb_dma_controller *dma_controller_alloc(struct musb
*musb, void __iomem *base)
then musbhs_dma_controller_create() and
musbhs_dma_controller_create_noirq() call it to alloc common resource.


On Tue, 2019-01-08 at 09:44 -0600, Bin Liu wrote:
> Hi,
>
> On Thu, Dec 27, 2018 at 03:34:26PM +0800, min.guo@xxxxxxxxxxxx wrote:
> > From: Min Guo <min.guo@xxxxxxxxxxxx>
> >
> > This adds support for MediaTek musb controller in
> > host, peripheral and otg mode
> >

> > diff --git a/drivers/usb/musb/musbhsdma.c b/drivers/usb/musb/musbhsdma.c
> > index 824adcb..c545475 100644
> > --- a/drivers/usb/musb/musbhsdma.c
> > +++ b/drivers/usb/musb/musbhsdma.c

> >
> > void musbhs_dma_controller_destroy(struct dma_controller *c)
> > {
> > struct musb_dma_controller *controller = container_of(c,
> > struct musb_dma_controller, controller);
> > + struct musb *musb = controller->private_data;
> >
> > dma_controller_stop(controller);
> >
> > - if (controller->irq)
> > + if (!(musb->ops->quirks & MUSB_MTK_QUIRKS) && controller->irq)
> > free_irq(controller->irq, c);
> >
> > kfree(controller);
> > @@ -398,11 +402,15 @@ struct dma_controller *musbhs_dma_controller_create(struct musb *musb,
> > struct musb_dma_controller *controller;
> > struct device *dev = musb->controller;
> > struct platform_device *pdev = to_platform_device(dev);
> > - int irq = platform_get_irq_byname(pdev, "dma");
> > + int irq = -1;
> >
> > - if (irq <= 0) {
> > - dev_err(dev, "No DMA interrupt line!\n");
> > - return NULL;
> > + if (!(musb->ops->quirks & MUSB_MTK_QUIRKS)) {
> > + irq = platform_get_irq_byname(pdev, "dma");
> > +
> > + if (irq < 0) {
> > + dev_err(dev, "No DMA interrupt line!\n");
> > + return NULL;
> > + }
> > }
>
> Please create musbhs_dma_controller_destroy_noirq() for your platform to
> not use the quirk.
>
> >
> > controller = kzalloc(sizeof(*controller), GFP_KERNEL);
> > @@ -418,15 +426,17 @@ struct dma_controller *musbhs_dma_controller_create(struct musb *musb,
> > controller->controller.channel_program = dma_channel_program;
> > controller->controller.channel_abort = dma_channel_abort;
> >
> > - if (request_irq(irq, dma_controller_irq, 0,
> > + if (!(musb->ops->quirks & MUSB_MTK_QUIRKS)) {
> > + if (request_irq(irq, dma_controller_irq, 0,
> > dev_name(musb->controller), &controller->controller)) {
> > - dev_err(dev, "request_irq %d failed!\n", irq);
> > - musb_dma_controller_destroy(&controller->controller);
> > + dev_err(dev, "request_irq %d failed!\n", irq);
> > + musb_dma_controller_destroy(&controller->controller);
> >
> > - return NULL;
> > - }
> > + return NULL;
> > + }
> >
> > - controller->irq = irq;
> > + controller->irq = irq;
> > + }
> >
> > return &controller->controller;
> > }
>
> Same here, create musbhs_dma_controller_create_noirq(). Then use both
> new API for the mtk glue driver.



> Regards,
> -Bin.