Re: linux-next and usb gadget composite BUG

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

 



Hi,

On Sun, Feb 24, 2013 at 12:06:35AM +0100, Robert Jarzmik wrote:
> Hi Felipe,
> 
> I tried today's version of linux-next tree (commit id
> b1714a88bee1ae, "Add linux-next specific files for 20130222").
> 
> My PXA based platform bugs on bootup. I have no console available on my
> platform, just a JTAG, so this is the info I have :
>  - I'm using a Mitac MIO A701 board (arch/arm/mach-pxa/mioa701.c)
>  - on gadget side, I'm using g_ether + pxa27x_udc
> 
> So far, I didn't have any composite driver enabled (as the PXA suffer from a
> severe hardware defect, see comment in header of pxa27x_udc.c).
> 
> Now, what I gathered from the JTAG is in [1].
> You can see that in sysfs_create_file(), the first argument has :
> &dev->kobj->sd == NULL.
> 
> And of course in fs/sysfs/file.c :
> 	BUG_ON(!kobj || !kobj->sd || !attr);
> 
> Therefore, I hit a BUG.
> 
> Could you tell me what changed recently that triggers this ? I saw in my .config
> CONFIG_USB_LIBCOMPOSITE=y which looks a bit suspect to me, but I'm sure you'll
> tell me what recent change prevents my platform from booting.

this is not caused by current pull request. Well, you could argue that
commit 70189a63d408d4ea0cddbf0ff0afe6020844e813 (usb: gadget:
pxa27x_udc: convert to udc_start/udc_stop) is the culprit, but the fact
is that what pxa27x is doing is pretty wrong.

The bug is that pxa27x_udc tries to register gadget->dev at udc_start()
time and that's only called after gadget driver has already been bound
to the controller. Since commit above converted pxa27x to
udc_start()/udc_stop() calls, it exposed the issue.

Anyway, this patch should fix it (I didn't even compile test it, since
pxa27x still depends on its architecture, which needs to be fixed).

commit de7dedf26d906e3a2d6bf60385f8a55b9938ae16
Author: Felipe Balbi <balbi@xxxxxx>
Date:   Mon Feb 25 08:49:05 2013 +0200

    usb: gadget: pxa27x: fix gadget->dev registration
    
    Whenever ->udc_start() gets called, gadet driver
    has already being bound to the udc controller, which
    means that gadget->dev had to be already initialized
    and added to driver model.
    
    This patch fixes pxa27x mistake.
    
    Signed-off-by: Felipe Balbi <balbi@xxxxxx>

diff --git a/drivers/usb/gadget/pxa27x_udc.c b/drivers/usb/gadget/pxa27x_udc.c
index 2b3b01d..8f39db2 100644
--- a/drivers/usb/gadget/pxa27x_udc.c
+++ b/drivers/usb/gadget/pxa27x_udc.c
@@ -1821,11 +1821,6 @@ static int pxa27x_udc_start(struct usb_gadget_driver *driver,
 	udc->gadget.dev.driver = &driver->driver;
 	dplus_pullup(udc, 1);
 
-	retval = device_add(&udc->gadget.dev);
-	if (retval) {
-		dev_err(udc->dev, "device_add error %d\n", retval);
-		goto add_fail;
-	}
 	retval = bind(&udc->gadget, driver);
 	if (retval) {
 		dev_err(udc->dev, "bind to driver %s --> error %d\n",
@@ -1852,8 +1847,6 @@ transceiver_fail:
 	if (driver->unbind)
 		driver->unbind(&udc->gadget);
 bind_fail:
-	device_del(&udc->gadget.dev);
-add_fail:
 	udc->driver = NULL;
 	udc->gadget.dev.driver = NULL;
 	return retval;
@@ -1905,7 +1898,6 @@ static int pxa27x_udc_stop(struct usb_gadget_driver *driver)
 	driver->unbind(&udc->gadget);
 	udc->driver = NULL;
 
-	device_del(&udc->gadget.dev);
 	dev_info(udc->dev, "unregistered gadget driver '%s'\n",
 		 driver->driver.name);
 
@@ -2511,13 +2503,24 @@ static int __init pxa_udc_probe(struct platform_device *pdev)
 			driver_name, udc->irq, retval);
 		goto err_irq;
 	}
+
+	retval = device_add(&udc->gadget.dev);
+	if (retval) {
+		dev_err(udc->dev, "device_add error %d\n", retval);
+		goto err_dev_add;
+	}
+
 	retval = usb_add_gadget_udc(&pdev->dev, &udc->gadget);
 	if (retval)
 		goto err_add_udc;
 
 	pxa_init_debugfs(udc);
+
 	return 0;
+
 err_add_udc:
+	device_unregister(&udc->gadget.dev);
+err_dev_add:
 	free_irq(udc->irq, udc);
 err_irq:
 	iounmap(udc->regs);
@@ -2538,6 +2541,7 @@ static int __exit pxa_udc_remove(struct platform_device *_dev)
 	int gpio = udc->mach->gpio_pullup;
 
 	usb_del_gadget_udc(&udc->gadget);
+	device_del(&udc->gadget.dev);
 	usb_gadget_unregister_driver(udc->driver);
 	free_irq(udc->irq, udc);
 	pxa_cleanup_debugfs(udc);

-- 
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