Re: [PATCH] usb: musb: musb_dsps: fix NULL pointer in suspend

2014-10-10 Thread Felipe Balbi
On Thu, Oct 09, 2014 at 10:25:20AM +0530, George Cherian wrote:
 
 On 10/08/2014 11:59 PM, Sebastian Andrzej Siewior wrote:
 So testing managed to configure musb in DMA mode but not load the
 matching cppi41 driver for DMA. This results in
 
 |musb-hdrc musb-hdrc.0.auto: Failed to request rx1.
 |musb-hdrc musb-hdrc.0.auto: musb_init_controller failed with status -517
 |platform musb-hdrc.0.auto: Driver musb-hdrc requests probe deferral
 
 which is okay. Once the driver is loaded we re-try probing and
 everyone is happy. Until then if you try suspend say
  echo mem  /sys/power/state
 then you go boom
 
 |Unable to handle kernel NULL pointer dereference at virtual address 03a4
 |pgd = cf50c000
 |[03a4] *pgd=8f6a3831, *pte=, *ppte=
 |Internal error: Oops: 17 [#1] ARM
 |PC is at dsps_suspend+0x18/0x9c [musb_dsps]
 |LR is at dsps_suspend+0x18/0x9c [musb_dsps]
 |pc : [bf08e268] lr : [bf08e268] psr: a013
 |sp : cbd97e00 ip : c0af4394 fp : 
 |r10: c0831d90 r9 : 0002 r8 : cf6da410
 |r7 : c03ba4dc r6 : bf08f224 r5 :  r4 : cbc5fcd0
 |r3 : bf08e250 r2 : bf08f264 r1 : cf6da410 r0 : 
 |[bf08e268] (dsps_suspend [musb_dsps]) from [c03ba508] 
 (platform_pm_suspend+0x2c/0x54)
 |Code: e1a04000 e9900041 e2800010 eb4caa8e (e59053a4)
 
 because platform_get_drvdata(glue-musb) returns a NULL pointer as long as 
 the
 device is not fully probed.
 
 Signed-off-by: Sebastian Andrzej Siewior bige...@linutronix.de
 Tested-by: George Cherian george.cher...@ti.com

Care to rebase on testing/next ? It doesn't apply:

checking file drivers/usb/musb/musb_dsps.c
Hunk #1 FAILED at 868.
Hunk #2 succeeded at 887 (offset 1 line).
1 out of 2 hunks FAILED

-- 
balbi


signature.asc
Description: Digital signature


Re: [PATCH] usb: musb: musb_dsps: fix NULL pointer in suspend

2014-10-08 Thread George Cherian


On 10/08/2014 11:59 PM, Sebastian Andrzej Siewior wrote:

So testing managed to configure musb in DMA mode but not load the
matching cppi41 driver for DMA. This results in

|musb-hdrc musb-hdrc.0.auto: Failed to request rx1.
|musb-hdrc musb-hdrc.0.auto: musb_init_controller failed with status -517
|platform musb-hdrc.0.auto: Driver musb-hdrc requests probe deferral

which is okay. Once the driver is loaded we re-try probing and
everyone is happy. Until then if you try suspend say
 echo mem  /sys/power/state
then you go boom

|Unable to handle kernel NULL pointer dereference at virtual address 03a4
|pgd = cf50c000
|[03a4] *pgd=8f6a3831, *pte=, *ppte=
|Internal error: Oops: 17 [#1] ARM
|PC is at dsps_suspend+0x18/0x9c [musb_dsps]
|LR is at dsps_suspend+0x18/0x9c [musb_dsps]
|pc : [bf08e268] lr : [bf08e268] psr: a013
|sp : cbd97e00 ip : c0af4394 fp : 
|r10: c0831d90 r9 : 0002 r8 : cf6da410
|r7 : c03ba4dc r6 : bf08f224 r5 :  r4 : cbc5fcd0
|r3 : bf08e250 r2 : bf08f264 r1 : cf6da410 r0 : 
|[bf08e268] (dsps_suspend [musb_dsps]) from [c03ba508] 
(platform_pm_suspend+0x2c/0x54)
|Code: e1a04000 e9900041 e2800010 eb4caa8e (e59053a4)

because platform_get_drvdata(glue-musb) returns a NULL pointer as long as the
device is not fully probed.

Signed-off-by: Sebastian Andrzej Siewior bige...@linutronix.de

Tested-by: George Cherian george.cher...@ti.com

---
  drivers/usb/musb/musb_dsps.c | 13 +++--
  1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/musb/musb_dsps.c b/drivers/usb/musb/musb_dsps.c
index c791ba5da91a..2f71f04ed8f7 100644
--- a/drivers/usb/musb/musb_dsps.c
+++ b/drivers/usb/musb/musb_dsps.c
@@ -868,8 +868,13 @@ static int dsps_suspend(struct device *dev)
struct dsps_glue *glue = dev_get_drvdata(dev);
const struct dsps_musb_wrapper *wrp = glue-wrp;
struct musb *musb = platform_get_drvdata(glue-musb);
-   void __iomem *mbase = musb-ctrl_base;
+   void __iomem *mbase;
  
+	if (!musb)

+   /* This can happen if the musb device is in -EPROBE_DEFER */
+   return 0;
+
+   mbase = musb-ctrl_base;
glue-context.control = dsps_readl(mbase, wrp-control);
glue-context.epintr = dsps_readl(mbase, wrp-epintr_set);
glue-context.coreintr = dsps_readl(mbase, wrp-coreintr_set);
@@ -886,8 +891,12 @@ static int dsps_resume(struct device *dev)
struct dsps_glue *glue = dev_get_drvdata(dev);
const struct dsps_musb_wrapper *wrp = glue-wrp;
struct musb *musb = platform_get_drvdata(glue-musb);
-   void __iomem *mbase = musb-ctrl_base;
+   void __iomem *mbase;
+
+   if (!musb)
+   return 0;
  
+	mbase = musb-ctrl_base;

dsps_writel(mbase, wrp-control, glue-context.control);
dsps_writel(mbase, wrp-epintr_set, glue-context.epintr);
dsps_writel(mbase, wrp-coreintr_set, glue-context.coreintr);


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