diff mbox

usb: gadget: s3c-hsotg: fix kernel panic

Message ID 1331904920-19685-1-git-send-email-sangwook.lee@linaro.org
State New
Headers show

Commit Message

Sangwook March 16, 2012, 1:35 p.m. UTC
Fix kernel panic from s3c_hsotg_udc_stop.
if udc_is_newstyle is true, s3c_hsotg_udc_stop should not
call disconnect, unbind.

As running rmmod g_mass_storage, kernel panic happens.

(composite_unbind+0x14/0x164 [g_mass_storage])
from [<c023e950>] (s3c_hsotg_udc_stop)

This patch is based on Lukasz Majewski's patches:
[PATCH 0/9] USB: s3c-hsotg: USB S3C-HSOTG driver fixes and code cleanu

in order to test g_mass_storage in Origen board:

Signed-off-by: Sangwook Lee <sangwook.lee@linaro.org>
---
 drivers/usb/gadget/s3c-hsotg.c |   12 ++++++------
 1 files changed, 6 insertions(+), 6 deletions(-)

Comments

Lukasz Majewski March 19, 2012, 4:52 p.m. UTC | #1
On Fri, 16 Mar 2012 13:35:20 +0000
Sangwook Lee <sangwook.lee@linaro.org> wrote:

> Fix kernel panic from s3c_hsotg_udc_stop.
> if udc_is_newstyle is true, s3c_hsotg_udc_stop should not
> call disconnect, unbind.
> 
> As running rmmod g_mass_storage, kernel panic happens.
> 
> (composite_unbind+0x14/0x164 [g_mass_storage])
> from [<c023e950>] (s3c_hsotg_udc_stop)
> 
> This patch is based on Lukasz Majewski's patches:
> [PATCH 0/9] USB: s3c-hsotg: USB S3C-HSOTG driver fixes and code cleanu
> 
> in order to test g_mass_storage in Origen board:
> 
> Signed-off-by: Sangwook Lee <sangwook.lee@linaro.org>
> ---
>  drivers/usb/gadget/s3c-hsotg.c |   12 ++++++------
>  1 files changed, 6 insertions(+), 6 deletions(-)
> 

Hi Sangwook,

Test HW: GONI S5PV210 
module: g_ether.ko

Yes, this patch works. Thanks for spotting the error.

Tested-by: Lukasz Majewski <l.majewski@samsung.com>
Felipe Balbi March 21, 2012, 9:56 a.m. UTC | #2
Hi,
On Mon, Mar 19, 2012 at 05:52:08PM +0100, Lukasz Majewski wrote:
> On Fri, 16 Mar 2012 13:35:20 +0000
> Sangwook Lee <sangwook.lee@linaro.org> wrote:
> 
> > Fix kernel panic from s3c_hsotg_udc_stop.
> > if udc_is_newstyle is true, s3c_hsotg_udc_stop should not
> > call disconnect, unbind.
> > 
> > As running rmmod g_mass_storage, kernel panic happens.
> > 
> > (composite_unbind+0x14/0x164 [g_mass_storage])
> > from [<c023e950>] (s3c_hsotg_udc_stop)
> > 
> > This patch is based on Lukasz Majewski's patches:
> > [PATCH 0/9] USB: s3c-hsotg: USB S3C-HSOTG driver fixes and code cleanu
> > 
> > in order to test g_mass_storage in Origen board:
> > 
> > Signed-off-by: Sangwook Lee <sangwook.lee@linaro.org>
> > ---
> >  drivers/usb/gadget/s3c-hsotg.c |   12 ++++++------
> >  1 files changed, 6 insertions(+), 6 deletions(-)
> > 
> 
> Hi Sangwook,
> 
> Test HW: GONI S5PV210 
> module: g_ether.ko
> 
> Yes, this patch works. Thanks for spotting the error.
> 
> Tested-by: Lukasz Majewski <l.majewski@samsung.com>

I don't seem to have the patch in my inbox, can someone re-send with
Lukasz Tested-by line already in place ?
Lukasz Majewski March 21, 2012, 10:59 a.m. UTC | #3
On Wed, 21 Mar 2012 11:56:23 +0200
Felipe Balbi <balbi@ti.com> wrote:

Hi Felipe,

> > > This patch is based on Lukasz Majewski's patches:
> > > [PATCH 0/9] USB: s3c-hsotg: USB S3C-HSOTG driver fixes and code
> > > cleanu
> > > 
This patch shall be placed on top of the above patch series.
Unfortunately those patches aren't yet applied to any of branches:

git://git.kernel.org/pub/scm/linux/kernel/git/balbi/usb

> 
> I don't seem to have the patch in my inbox, can someone re-send with
> Lukasz Tested-by line already in place ?
> 

I've already squashed this patch with one of the above patch series
with adding 
Signed-of-by: Sangwook Lee <sangwook.lee@linaro.org>

I will resend those patches asap on the linux-usb mailing list.
diff mbox

Patch

diff --git a/drivers/usb/gadget/s3c-hsotg.c b/drivers/usb/gadget/s3c-hsotg.c
index 4262df8..9925661 100644
--- a/drivers/usb/gadget/s3c-hsotg.c
+++ b/drivers/usb/gadget/s3c-hsotg.c
@@ -2883,16 +2883,12 @@  static int s3c_hsotg_udc_stop(struct usb_gadget *gadget,
 	for (ep = 0; ep < hsotg->num_of_eps; ep++)
 		s3c_hsotg_ep_disable(&hsotg->eps[ep].ep);
 
-	call_gadget(hsotg, disconnect);
-
-	driver->unbind(&hsotg->gadget);
 	s3c_hsotg_phy_disable(hsotg);
 	regulator_bulk_disable(ARRAY_SIZE(hsotg->supplies), hsotg->supplies);
 
 	hsotg->driver = NULL;
 	hsotg->gadget.speed = USB_SPEED_UNKNOWN;
-
-	device_del(&hsotg->gadget.dev);
+	hsotg->gadget.dev.driver = NULL;
 
 	dev_info(hsotg->dev, "unregistered gadget driver '%s'\n",
 		 driver->driver.name);
@@ -3526,7 +3522,10 @@  static int __devexit s3c_hsotg_remove(struct platform_device *pdev)
 
 	s3c_hsotg_delete_debug(hsotg);
 
-	usb_gadget_unregister_driver(hsotg->driver);
+	if (hsotg->driver) {
+		/* should have been done already by driver model core */
+		usb_gadget_unregister_driver(hsotg->driver);
+	}
 
 	free_irq(hsotg->irq, hsotg);
 	iounmap(hsotg->regs);
@@ -3540,6 +3539,7 @@  static int __devexit s3c_hsotg_remove(struct platform_device *pdev)
 	clk_disable(hsotg->clk);
 	clk_put(hsotg->clk);
 
+	device_unregister(&hsotg->gadget.dev);
 	kfree(hsotg);
 	return 0;
 }