Re: [PATCH] usb: renesas_usbhs: bugfix: use irqnum = -1 for usb_add_hcd()

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

 



Hi,

On Mon, Feb 27, 2012 at 07:03:49PM -0800, Kuninori Morimoto wrote:
> current renesas_usbhs host driver will get below WARNING when host was removed
> 
> WARNING: at /opt/usr/src/WORK/morimoto/gitlinux/linux-2.6/kernel/irq/manage.c:1)
> Trying to free already-free IRQ 0
> Modules linked in:
> [<c000e25c>] (unwind_backtrace+0x0/0xe4) from [<c001695c>] (warn_slowpath_commo)
> [<c001695c>] (warn_slowpath_common+0x4c/0x64) from [<c00169f4>] (warn_slowpath_)
> [<c00169f4>] (warn_slowpath_fmt+0x2c/0x3c) from [<c004978c>] (__free_irq+0x88/0)
> [<c004978c>] (__free_irq+0x88/0x148) from [<c00498a0>] (free_irq+0x54/0x78)
> [<c00498a0>] (free_irq+0x54/0x78) from [<c01b023c>] (usb_remove_hcd+0x13c/0x170)
> [<c01b023c>] (usb_remove_hcd+0x13c/0x170) from [<c01c7b1c>] (usbhsh_stop+0x44/0)
> ...
> 
> renesas_usbhs host hcd->irq should be -1 since
> this driver doesn't have hcd->driver->irq.
> 
> But, from 68d07f64b8a11a852d48d1b05b724c3e20c0d94b,
> (USB: Don't fail USB3 probe on missing legacy PCI IRQ.)
> current renesas_usbhs didn't call usb_hcd_request_irqs()

renesas is not supposed to call that. usb_add_hcd() is calling that,
which makes me wonder if this patch is really needed.

> which will set hcd->irq on usb_add_hcd().
> Because the "irqnum" was 0.
> 
> This patch use irqnum = -1 for usb_add_hcd().
> 
> Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@xxxxxxxxxxx>
> ---
> 
> >> Felipe
> 
> This patch is for linus/master
> 
> 
>  drivers/usb/renesas_usbhs/mod_host.c |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
> 
> diff --git a/drivers/usb/renesas_usbhs/mod_host.c b/drivers/usb/renesas_usbhs/mod_host.c
> index 1834cf5..f9c668b 100644
> --- a/drivers/usb/renesas_usbhs/mod_host.c
> +++ b/drivers/usb/renesas_usbhs/mod_host.c
> @@ -1441,7 +1441,7 @@ static int usbhsh_start(struct usbhs_priv *priv)
>  	int ret;
>  
>  	/* add hcd */
> -	ret = usb_add_hcd(hcd, 0, 0);
> +	ret = usb_add_hcd(hcd, -1, 0);

what will happen here is that usb_add_hcd() will call
usb_hcd_request_irqs() which will fall into the else branch:

2325 static int usb_hcd_request_irqs(struct usb_hcd *hcd,
2326                 unsigned int irqnum, unsigned long irqflags)
2327 {
2328         int retval;
2329 
2330         if (hcd->driver->irq) {
2331 
2332                 /* IRQF_DISABLED doesn't work as advertised when used together
2333                  * with IRQF_SHARED. As usb_hcd_irq() will always disable
2334                  * interrupts we can remove it here.
2335                  */
2336                 if (irqflags & IRQF_SHARED)
2337                         irqflags &= ~IRQF_DISABLED;
2338 
2339                 snprintf(hcd->irq_descr, sizeof(hcd->irq_descr), "%s:usb%d",
2340                                 hcd->driver->description, hcd->self.busnum);
2341                 retval = request_irq(irqnum, &usb_hcd_irq, irqflags,
2342                                 hcd->irq_descr, hcd);
2343                 if (retval != 0) {
2344                         dev_err(hcd->self.controller,
2345                                         "request interrupt %d failed\n",
2346                                         irqnum);
2347                         return retval;
2348                 }
2349                 hcd->irq = irqnum;
2350                 dev_info(hcd->self.controller, "irq %d, %s 0x%08llx\n", irqnum,
2351                                 (hcd->driver->flags & HCD_MEMORY) ?
2352                                         "io mem" : "io base",
2353                                         (unsigned long long)hcd->rsrc_start);
2354         } else {
2355                 hcd->irq = -1;
2356                 if (hcd->rsrc_start)
2357                         dev_info(hcd->self.controller, "%s 0x%08llx\n",
2358                                         (hcd->driver->flags & HCD_MEMORY) ?
2359                                         "io mem" : "io base",
2360                                         (unsigned long long)hcd->rsrc_start);
2361         }
2362         return 0;
2363 }

Are you sure you never initialize driver->irq by mistake ??

-- 
balbi

Attachment: signature.asc
Description: Digital signature


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

  Powered by Linux