kernel hang when initializing usb

2013-07-11 Thread Rao, Ravi

Hi Tony/Greg/Liu,
I'am Ravi working on a P2040 based custom board which has a compact flash 
connected to USB port via CYPRESS USB to IDE bridge. I am able to see the USB 
mass storage device from uboot but when I boot to kernel it hangs.
Below is the dump that shows the part where it hangs. I have added some debug 
prints and narrowed down that the hang happens when it is trying to write to 
port status(portsc) register.

>>>>>
ehci_hcd: USB 2.0 'Enhanced' Host Controller (EHCI) Driver
ohci_hcd: USB 1.1 'Open' Host Controller (OHCI) Driver
fsl-ehci fsl-ehci.0: Freescale On-Chip EHCI Host Controller
fsl-ehci fsl-ehci.0: new USB bus registered, assigned bus number 1
fsl-ehci fsl-ehci.0: Before invoking reset
ehci_fsl_setup got invoked..
Before invoking ehci_readl
Before invoking ehci_halt
ehci_writel invoked with val=0x0, reg=0xf125e148
Before invoking ehci_init
Before invoking ehci_reset
ehci_writel invoked with val=0x80002, reg=0xf125e140
ehci_writel invoked with val=0x3, reg=0xf125e1a8
Before invoking ehci_fsl_reinit
Entering ehci_fsl_usb_setup with op_mode=0x1 have_sysif_regs=0x1
Completed SNOOPing of 4GB space
Before invoking ehci_fsl_setup_phy with phy_mode=0x2
Entering ehci_fsl_setup_phy, portsc=0x0 port_offset=0x0 
port_status_addr=0xf125e184
Before invoking mdelay, cntrlr_ver=0x1
Before invoking ehci_writel, portsc=0x0 port_offset=0x0 
port_status_addr=0xf125e184
ehci_writel invoked with val=0x0, reg=0xf125e184
>>>>>>


Kernel I am using is Linux version 3.0.51-rt75 and it looks like it has all the 
required patches described in the 
thread(http://thread.gmane.org/gmane.linux.usb.general/58763/focus=58795) but I 
still see the hang.
Can one you give some pointers to troubleshoot what may be causing this hang
Below is the email in which Tony had mentioned that he is also seeing the hang 
even after applying all the prescribed patches.
Tony were you able to find the cause for the hang ? If so can you please share 
what was the fix that you made.

>>>>
Re: [ 011/108] powerpc/usb: fix bug of kernel hang when initializing usb Remove 
Highlighting [In reply to]
Greg KH  writes:

> 3.0-stable review patch. If anyone has any objections, please let me know.
>
> --
>
> From: Shengzhou Liu 
>
> commit 28c56ea1431421dec51b7b229369e991481453df upstream.
>
> If USB UTMI PHY is not enable, writing to portsc register will lead to
> kernel hang during boot up.

I apologize for the late response, but I was encountering this same
hang (on an 8315) and applied this patch. (For what it's worth, I'm
only seeing it after many warm boots; a cold boot / hard power cycle
solves the issue, but since this is eventually going to be locked up
in a box without a console...)

I encountered the hang again this evening, so this fix (plus the snoop
fix) is not sufficientl

Reading through the original thread, it seems that an additional delay
might be required:

http://article.gmane.org/gmane.linux.usb.general/58795

> First, the SDK kernel had a delay after setting that bit, I added
> that back in. This is not what fixed it but it looks like the
> right thing to do, though please, use msleep rather than udelay
> here if possible (not in atomic context).

However, I never saw a patch to that effect. I'm assuming (hoping!)
it's something as simple as:


diff --git a/drivers/usb/host/ehci-fsl.c b/drivers/usb/host/ehci-fsl.c
index 09fd214..d58c1c6 100644
--- a/drivers/usb/host/ehci-fsl.c
+++ b/drivers/usb/host/ehci-fsl.c
@@ -236,6 +236,7 @@ static void ehci_fsl_setup_phy(struct ehci_hcd *ehci,
case FSL_USB2_PHY_UTMI:
/* enable UTMI PHY */
setbits32(non_ehci + FSL_SOC_USB_CTRL, CTRL_UTMI_PHY_EN);
+ msleep(5);
portsc |= PORT_PTS_UTMI;
break;
case FSL_USB2_PHY_NONE:


But confirmation would be nice. Also, which SDK kernel was this
compared against? I just downloaded the 8315ERDB BSP, and the kernel
there doesn't seem to have any of this in it.

There was also the follow-on patch that enabled snooping (to deal with
cache coherency?):

http://article.gmane.org/gmane.linux.usb.general/58798

(If there was a formal patch there, it looks like it got scrambled on
gmane, and I can't find another list archive.)

Is that also needed for consistent results here? (Or are we wandering
astray from "-stable" material?)

Thanks,
Tony.
>>>>

Thanks & Regards,
Ravi..
___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

Re: [PATCH] powerpc/usb: fix bug of kernel hang when initializing usb

2012-02-18 Thread Sergei Shtylyov

Hello.

On 16-02-2012 14:02, Shengzhou Liu wrote:


If USB UTMI PHY is not enable, writing to portsc register will lead to
kernel hang during boot up.



Signed-off-by: Shengzhou Liu

[...]


diff --git a/drivers/usb/host/ehci-fsl.h b/drivers/usb/host/ehci-fsl.h
index bdf43e2..0e400c2 100644
--- a/drivers/usb/host/ehci-fsl.h
+++ b/drivers/usb/host/ehci-fsl.h
@@ -45,6 +45,7 @@
  #define FSL_SOC_USB_PRICTRL   0x40c   /* NOTE: big-endian */
  #define FSL_SOC_USB_SICTRL0x410   /* NOTE: big-endian */
  #define FSL_SOC_USB_CTRL  0x500   /* NOTE: big-endian */
+#define CTRL_UTMI_PHY_EN   (1<<9)


   Please put spaces around << like below.


  #define CTRL_PHY_CLK_VALID(1<<  17)
  #define SNOOP_SIZE_2GB0x1e
  #endif/* _EHCI_FSL_H */


WBR, Sergei
___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev


RE: [PATCH] powerpc/usb: fix bug of kernel hang when initializing usb

2012-02-16 Thread Pan Jiafei-B37022
> -Original Message-
> From: Benjamin Herrenschmidt [mailto:b...@kernel.crashing.org]
> Sent: Friday, February 17, 2012 11:43 AM
> To: Pan Jiafei-B37022
> Cc: Liu Shengzhou-B36685; linux-...@vger.kernel.org; linuxppc-
> d...@lists.ozlabs.org
> Subject: RE: [PATCH] powerpc/usb: fix bug of kernel hang when
> initializing usb
> 
> On Fri, 2012-02-17 at 03:20 +, Pan Jiafei-B37022 wrote:
> > FYI, I once fixed this issue when backport P5020 BSP for WR Linux, The
> > following is the patch which I have submitted to linuxbj-internal.
> 
> Should I just apply this to upstream ?
> 
> Cheers,
> Ben.
> 
[Pan Jiafei-B37022] 
Ok, thanks, I will resend the patch formally!

Best Regards.
Jiafei.

> > From: linuxbj-internal-boun...@linux.freescale.net
> > [mailto:linuxbj-internal-boun...@linux.freescale.net] On Behalf Of Pan
> > Jiafei-B37022
> > Sent: Friday, December 16, 2011 12:49 PM
> > To: linuxbj-inter...@linux.freescale.net
> > Cc: Pan Jiafei-B37022
> > Subject: [Linuxbj-internal] [PATCH] USB: ehci-fsl: Turn on cache
> > snooping on MPC8xxx
> >
> > If a MPC8xxx was being used, 'have_sysif_regs' should be set and it
> > should setup cache snooping for all the 4GB space on both PPC32 and
> > PPC64.
> >
> > Signed-off-by: Pan Jiafei 
> > ---
> > drivers/usb/host/ehci-fsl.c |   23 ++-
> > 1 files changed, 10 insertions(+), 13 deletions(-)
> >
> > diff --git a/drivers/usb/host/ehci-fsl.c b/drivers/usb/host/ehci-fsl.c
> > index 90534cc..ee14fa7 100644
> > --- a/drivers/usb/host/ehci-fsl.c
> > +++ b/drivers/usb/host/ehci-fsl.c
> > @@ -260,21 +260,18 @@ static void ehci_fsl_usb_setup(struct ehci_hcd
> *ehci)
> > if (pdata->have_sysif_regs) {
> >   temp = in_be32(non_ehci + FSL_SOC_USB_CTRL);
> >   out_be32(non_ehci + FSL_SOC_USB_CTRL, temp | 0x0004);
> > -  out_be32(non_ehci + FSL_SOC_USB_SNOOP1, 0x001b);
> > -}
> >
> > -#if defined(CONFIG_PPC32) && !defined(CONFIG_NOT_COHERENT_CACHE)
> > -/*
> > -* Turn on cache snooping hardware, since some PowerPC platforms
> > -* wholly rely on hardware to deal with cache coherent
> > -*/
> > +  /*
> > +  * Turn on cache snooping hardware, since some PowerPC
> platforms
> > +  * wholly rely on hardware to deal with cache coherent
> > +  */
> >
> > -/* Setup Snooping for all the 4GB space */
> > -/* SNOOP1 starts from 0x0, size 2G */
> > -out_be32(non_ehci + FSL_SOC_USB_SNOOP1, 0x0 | SNOOP_SIZE_2GB);
> > -/* SNOOP2 starts from 0x8000, size 2G */
> > -out_be32(non_ehci + FSL_SOC_USB_SNOOP2, 0x8000 |
> SNOOP_SIZE_2GB);
> > -#endif
> > +  /* Setup Snooping for all the 4GB space */
> > +  /* SNOOP1 starts from 0x0, size 2G */
> > +  out_be32(non_ehci + FSL_SOC_USB_SNOOP1, 0x0 |
> SNOOP_SIZE_2GB);
> > +  /* SNOOP2 starts from 0x8000, size 2G */
> > +  out_be32(non_ehci + FSL_SOC_USB_SNOOP2, 0x8000 |
> SNOOP_SIZE_2GB);
> > +}
> >
> >  if ((pdata->operating_mode == FSL_USB2_DR_HOST) ||
> >(pdata->operating_mode == FSL_USB2_DR_OTG))
> 
> 

___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev


RE: [PATCH] powerpc/usb: fix bug of kernel hang when initializing usb

2012-02-16 Thread Pan Jiafei-B37022


> -Original Message-
> From: Benjamin Herrenschmidt [mailto:b...@kernel.crashing.org]
> Sent: Friday, February 17, 2012 11:43 AM
> To: Pan Jiafei-B37022
> Cc: Liu Shengzhou-B36685; linux-...@vger.kernel.org; linuxppc-
> d...@lists.ozlabs.org
> Subject: RE: [PATCH] powerpc/usb: fix bug of kernel hang when
> initializing usb
> 
> On Fri, 2012-02-17 at 03:20 +, Pan Jiafei-B37022 wrote:
> > FYI, I once fixed this issue when backport P5020 BSP for WR Linux, The
> > following is the patch which I have submitted to linuxbj-internal.
> 
> Should I just apply this to upstream ?
> 
> Cheers,
> Ben.
> 
[Pan Jiafei-B37022] 
Feel free to apply this to upstream, thanks

Best Regards.
Jiafei

> > From: linuxbj-internal-boun...@linux.freescale.net
> > [mailto:linuxbj-internal-boun...@linux.freescale.net] On Behalf Of Pan
> > Jiafei-B37022
> > Sent: Friday, December 16, 2011 12:49 PM
> > To: linuxbj-inter...@linux.freescale.net
> > Cc: Pan Jiafei-B37022
> > Subject: [Linuxbj-internal] [PATCH] USB: ehci-fsl: Turn on cache
> > snooping on MPC8xxx
> >
> > If a MPC8xxx was being used, 'have_sysif_regs' should be set and it
> > should setup cache snooping for all the 4GB space on both PPC32 and
> > PPC64.
> >
> > Signed-off-by: Pan Jiafei 
> > ---
> > drivers/usb/host/ehci-fsl.c |   23 ++-
> > 1 files changed, 10 insertions(+), 13 deletions(-)
> >
> > diff --git a/drivers/usb/host/ehci-fsl.c b/drivers/usb/host/ehci-fsl.c
> > index 90534cc..ee14fa7 100644
> > --- a/drivers/usb/host/ehci-fsl.c
> > +++ b/drivers/usb/host/ehci-fsl.c
> > @@ -260,21 +260,18 @@ static void ehci_fsl_usb_setup(struct ehci_hcd
> *ehci)
> > if (pdata->have_sysif_regs) {
> >   temp = in_be32(non_ehci + FSL_SOC_USB_CTRL);
> >   out_be32(non_ehci + FSL_SOC_USB_CTRL, temp | 0x0004);
> > -  out_be32(non_ehci + FSL_SOC_USB_SNOOP1, 0x001b);
> > -}
> >
> > -#if defined(CONFIG_PPC32) && !defined(CONFIG_NOT_COHERENT_CACHE)
> > -/*
> > -* Turn on cache snooping hardware, since some PowerPC platforms
> > -* wholly rely on hardware to deal with cache coherent
> > -*/
> > +  /*
> > +  * Turn on cache snooping hardware, since some PowerPC
> platforms
> > +  * wholly rely on hardware to deal with cache coherent
> > +  */
> >
> > -/* Setup Snooping for all the 4GB space */
> > -/* SNOOP1 starts from 0x0, size 2G */
> > -out_be32(non_ehci + FSL_SOC_USB_SNOOP1, 0x0 | SNOOP_SIZE_2GB);
> > -/* SNOOP2 starts from 0x8000, size 2G */
> > -out_be32(non_ehci + FSL_SOC_USB_SNOOP2, 0x8000 |
> SNOOP_SIZE_2GB);
> > -#endif
> > +  /* Setup Snooping for all the 4GB space */
> > +  /* SNOOP1 starts from 0x0, size 2G */
> > +  out_be32(non_ehci + FSL_SOC_USB_SNOOP1, 0x0 |
> SNOOP_SIZE_2GB);
> > +  /* SNOOP2 starts from 0x8000, size 2G */
> > +  out_be32(non_ehci + FSL_SOC_USB_SNOOP2, 0x8000 |
> SNOOP_SIZE_2GB);
> > +}
> >
> >  if ((pdata->operating_mode == FSL_USB2_DR_HOST) ||
> >(pdata->operating_mode == FSL_USB2_DR_OTG))
> 
> 

___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev


RE: [PATCH] powerpc/usb: fix bug of kernel hang when initializing usb

2012-02-16 Thread Pan Jiafei-B37022
FYI, I once fixed this issue when backport P5020 BSP for WR Linux, The 
following is the patch which I have submitted to linuxbj-internal.


From: linuxbj-internal-boun...@linux.freescale.net 
[mailto:linuxbj-internal-boun...@linux.freescale.net] On Behalf Of Pan 
Jiafei-B37022
Sent: Friday, December 16, 2011 12:49 PM
To: linuxbj-inter...@linux.freescale.net
Cc: Pan Jiafei-B37022
Subject: [Linuxbj-internal] [PATCH] USB: ehci-fsl: Turn on cache snooping on 
MPC8xxx

If a MPC8xxx was being used, 'have_sysif_regs' should be set and
it should setup cache snooping for all the 4GB space on both PPC32
and PPC64.

Signed-off-by: Pan Jiafei 
---
drivers/usb/host/ehci-fsl.c |   23 ++-
1 files changed, 10 insertions(+), 13 deletions(-)

diff --git a/drivers/usb/host/ehci-fsl.c b/drivers/usb/host/ehci-fsl.c
index 90534cc..ee14fa7 100644
--- a/drivers/usb/host/ehci-fsl.c
+++ b/drivers/usb/host/ehci-fsl.c
@@ -260,21 +260,18 @@ static void ehci_fsl_usb_setup(struct ehci_hcd *ehci)
if (pdata->have_sysif_regs) {
  temp = in_be32(non_ehci + FSL_SOC_USB_CTRL);
  out_be32(non_ehci + FSL_SOC_USB_CTRL, temp | 0x0004);
-  out_be32(non_ehci + FSL_SOC_USB_SNOOP1, 0x001b);
-}

-#if defined(CONFIG_PPC32) && !defined(CONFIG_NOT_COHERENT_CACHE)
-/*
-* Turn on cache snooping hardware, since some PowerPC platforms
-* wholly rely on hardware to deal with cache coherent
-*/
+  /*
+  * Turn on cache snooping hardware, since some PowerPC platforms
+  * wholly rely on hardware to deal with cache coherent
+  */

-/* Setup Snooping for all the 4GB space */
-/* SNOOP1 starts from 0x0, size 2G */
-out_be32(non_ehci + FSL_SOC_USB_SNOOP1, 0x0 | SNOOP_SIZE_2GB);
-/* SNOOP2 starts from 0x8000, size 2G */
-out_be32(non_ehci + FSL_SOC_USB_SNOOP2, 0x8000 | SNOOP_SIZE_2GB);
-#endif
+  /* Setup Snooping for all the 4GB space */
+  /* SNOOP1 starts from 0x0, size 2G */
+  out_be32(non_ehci + FSL_SOC_USB_SNOOP1, 0x0 | SNOOP_SIZE_2GB);
+  /* SNOOP2 starts from 0x8000, size 2G */
+  out_be32(non_ehci + FSL_SOC_USB_SNOOP2, 0x8000 | SNOOP_SIZE_2GB);
+}

 if ((pdata->operating_mode == FSL_USB2_DR_HOST) ||
   (pdata->operating_mode == FSL_USB2_DR_OTG))
-- 
1.7.5.1

> -Original Message-
> From: linuxppc-dev-bounces+jiafei.pan=freescale@lists.ozlabs.org
> [mailto:linuxppc-dev-bounces+jiafei.pan=freescale@lists.ozlabs.org]
> On Behalf Of Liu Shengzhou-B36685
> Sent: Friday, February 17, 2012 10:33 AM
> To: Benjamin Herrenschmidt
> Cc: linux-...@vger.kernel.org; linuxppc-dev@lists.ozlabs.org
> Subject: RE: [PATCH] powerpc/usb: fix bug of kernel hang when
> initializing usb
> 
> 
> > -Original Message-
> > From: Benjamin Herrenschmidt [mailto:b...@kernel.crashing.org]
> > Sent: Friday, February 17, 2012 8:03 AM
> > To: Liu Shengzhou-B36685
> > Cc: linux-...@vger.kernel.org; linuxppc-dev@lists.ozlabs.org
> > Subject: Re: [PATCH] powerpc/usb: fix bug of kernel hang when
> > initializing usb
> >
> > On Fri, 2012-02-17 at 09:58 +1100, Benjamin Herrenschmidt wrote:
> > > On Thu, 2012-02-16 at 18:02 +0800, Shengzhou Liu wrote:
> > > > If USB UTMI PHY is not enable, writing to portsc register will
> > > > lead to kernel hang during boot up.
> > > >
> > > > Signed-off-by: Shengzhou Liu 
> > > > ---
> > > > Apply for master branch of
> > > > git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-
> > 2.6.git
> > > > Tested on P5020DS, the issue was reported by Benjamin Herrenschmidt.
> > >
> > > This fixes the hang, but sadly doesn't make USB work. I now get:
> >
> >  .../...
> >
> > Ok, found the problem.
> >
> > First, the SDK kernel had a delay after setting that bit, I added that
> > back in. This is not what fixed it but it looks like the right thing
> > to do, though please, use msleep rather than udelay here if possible
> > (not in atomic context).
> >
> > Then, the real culprit is (CC'ing Kumar and Scott to figure out why)
> > this statement:
> >
> > #if defined(CONFIG_PPC32) && !defined(CONFIG_NOT_COHERENT_CACHE)
> > /*
> >  * Turn on cache snooping hardware, since some PowerPC platforms
> >  * wholly rely on hardware to deal with cache coherent
> >  */
> >
> > /* Setup Snooping for all the 4GB space */
> > /* SNOOP1 starts from 0x0, size 2G */
> > out_be32(non_ehci + FSL_SOC_USB_SNOOP1, 0x0 | SNOOP_SIZE_2GB);
> > /* SNOOP2 starts from 0x8000, size 2G */
> > out_be32(non_ehci + FSL_SOC_USB_SNOOP2, 0x

RE: [PATCH] powerpc/usb: fix bug of kernel hang when initializing usb

2012-02-16 Thread Benjamin Herrenschmidt
On Fri, 2012-02-17 at 03:20 +, Pan Jiafei-B37022 wrote:
> FYI, I once fixed this issue when backport P5020 BSP for WR Linux, The
> following is the patch which I have submitted to linuxbj-internal.

Should I just apply this to upstream ?

Cheers,
Ben.

> From: linuxbj-internal-boun...@linux.freescale.net 
> [mailto:linuxbj-internal-boun...@linux.freescale.net] On Behalf Of Pan 
> Jiafei-B37022
> Sent: Friday, December 16, 2011 12:49 PM
> To: linuxbj-inter...@linux.freescale.net
> Cc: Pan Jiafei-B37022
> Subject: [Linuxbj-internal] [PATCH] USB: ehci-fsl: Turn on cache snooping on 
> MPC8xxx
> 
> If a MPC8xxx was being used, 'have_sysif_regs' should be set and
> it should setup cache snooping for all the 4GB space on both PPC32
> and PPC64.
> 
> Signed-off-by: Pan Jiafei 
> ---
> drivers/usb/host/ehci-fsl.c |   23 ++-
> 1 files changed, 10 insertions(+), 13 deletions(-)
> 
> diff --git a/drivers/usb/host/ehci-fsl.c b/drivers/usb/host/ehci-fsl.c
> index 90534cc..ee14fa7 100644
> --- a/drivers/usb/host/ehci-fsl.c
> +++ b/drivers/usb/host/ehci-fsl.c
> @@ -260,21 +260,18 @@ static void ehci_fsl_usb_setup(struct ehci_hcd *ehci)
> if (pdata->have_sysif_regs) {
>   temp = in_be32(non_ehci + FSL_SOC_USB_CTRL);
>   out_be32(non_ehci + FSL_SOC_USB_CTRL, temp | 0x0004);
> -  out_be32(non_ehci + FSL_SOC_USB_SNOOP1, 0x001b);
> -}
> 
> -#if defined(CONFIG_PPC32) && !defined(CONFIG_NOT_COHERENT_CACHE)
> -/*
> -* Turn on cache snooping hardware, since some PowerPC platforms
> -* wholly rely on hardware to deal with cache coherent
> -*/
> +  /*
> +  * Turn on cache snooping hardware, since some PowerPC platforms
> +  * wholly rely on hardware to deal with cache coherent
> +  */
> 
> -/* Setup Snooping for all the 4GB space */
> -/* SNOOP1 starts from 0x0, size 2G */
> -out_be32(non_ehci + FSL_SOC_USB_SNOOP1, 0x0 | SNOOP_SIZE_2GB);
> -/* SNOOP2 starts from 0x8000, size 2G */
> -out_be32(non_ehci + FSL_SOC_USB_SNOOP2, 0x8000 | SNOOP_SIZE_2GB);
> -#endif
> +  /* Setup Snooping for all the 4GB space */
> +  /* SNOOP1 starts from 0x0, size 2G */
> +  out_be32(non_ehci + FSL_SOC_USB_SNOOP1, 0x0 | SNOOP_SIZE_2GB);
> +  /* SNOOP2 starts from 0x8000, size 2G */
> +  out_be32(non_ehci + FSL_SOC_USB_SNOOP2, 0x8000 | 
> SNOOP_SIZE_2GB);
> +}
> 
>  if ((pdata->operating_mode == FSL_USB2_DR_HOST) ||
>(pdata->operating_mode == FSL_USB2_DR_OTG))


___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev


RE: [PATCH] powerpc/usb: fix bug of kernel hang when initializing usb

2012-02-16 Thread Liu Shengzhou-B36685

> -Original Message-
> From: Benjamin Herrenschmidt [mailto:b...@kernel.crashing.org]
> Sent: Friday, February 17, 2012 8:03 AM
> To: Liu Shengzhou-B36685
> Cc: linux-...@vger.kernel.org; linuxppc-dev@lists.ozlabs.org
> Subject: Re: [PATCH] powerpc/usb: fix bug of kernel hang when
> initializing usb
> 
> On Fri, 2012-02-17 at 09:58 +1100, Benjamin Herrenschmidt wrote:
> > On Thu, 2012-02-16 at 18:02 +0800, Shengzhou Liu wrote:
> > > If USB UTMI PHY is not enable, writing to portsc register will lead
> > > to kernel hang during boot up.
> > >
> > > Signed-off-by: Shengzhou Liu 
> > > ---
> > > Apply for master branch of
> > > git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-
> 2.6.git
> > > Tested on P5020DS, the issue was reported by Benjamin Herrenschmidt.
> >
> > This fixes the hang, but sadly doesn't make USB work. I now get:
> 
>  .../...
> 
> Ok, found the problem.
> 
> First, the SDK kernel had a delay after setting that bit, I added that
> back in. This is not what fixed it but it looks like the right thing to
> do, though please, use msleep rather than udelay here if possible (not
> in atomic context).
> 
> Then, the real culprit is (CC'ing Kumar and Scott to figure out why)
> this statement:
> 
> #if defined(CONFIG_PPC32) && !defined(CONFIG_NOT_COHERENT_CACHE)
>   /*
>* Turn on cache snooping hardware, since some PowerPC platforms
>* wholly rely on hardware to deal with cache coherent
>*/
> 
>   /* Setup Snooping for all the 4GB space */
>   /* SNOOP1 starts from 0x0, size 2G */
>   out_be32(non_ehci + FSL_SOC_USB_SNOOP1, 0x0 | SNOOP_SIZE_2GB);
>   /* SNOOP2 starts from 0x8000, size 2G */
>   out_be32(non_ehci + FSL_SOC_USB_SNOOP2, 0x8000 |
> SNOOP_SIZE_2GB); #endif
> 
> I'm building a 64-bit kernel so this isn't compiled and it looks like
> the EHCI is thus not snooping.
> 
> By removing the defined(CONFIG_PPC32) part of the statement, my problem
> goes away.
> 
> Cheers,
> Ben.
> 
> 

[Shengzhou] I tested the patch with 32bit P5020DS, USB worked well. Not tested 
with 64-bit kernel.
Glad to you had found the problem in case of 64-bit, thanks!
___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev


Re: [PATCH] powerpc/usb: fix bug of kernel hang when initializing usb

2012-02-16 Thread Benjamin Herrenschmidt
On Fri, 2012-02-17 at 09:58 +1100, Benjamin Herrenschmidt wrote:
> On Thu, 2012-02-16 at 18:02 +0800, Shengzhou Liu wrote:
> > If USB UTMI PHY is not enable, writing to portsc register will lead to
> > kernel hang during boot up.
> > 
> > Signed-off-by: Shengzhou Liu 
> > ---
> > Apply for master branch of 
> > git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6.git 
> > Tested on P5020DS, the issue was reported by Benjamin Herrenschmidt. 
> 
> This fixes the hang, but sadly doesn't make USB work. I now get:

 .../...

Ok, found the problem.

First, the SDK kernel had a delay after setting that bit, I added that
back in. This is not what fixed it but it looks like the right thing to
do, though please, use msleep rather than udelay here if possible (not
in atomic context).

Then, the real culprit is (CC'ing Kumar and Scott to figure out why)
this statement:

#if defined(CONFIG_PPC32) && !defined(CONFIG_NOT_COHERENT_CACHE)
/*
 * Turn on cache snooping hardware, since some PowerPC platforms
 * wholly rely on hardware to deal with cache coherent
 */

/* Setup Snooping for all the 4GB space */
/* SNOOP1 starts from 0x0, size 2G */
out_be32(non_ehci + FSL_SOC_USB_SNOOP1, 0x0 | SNOOP_SIZE_2GB);
/* SNOOP2 starts from 0x8000, size 2G */
out_be32(non_ehci + FSL_SOC_USB_SNOOP2, 0x8000 | SNOOP_SIZE_2GB);
#endif

I'm building a 64-bit kernel so this isn't compiled and it looks like
the EHCI is thus not snooping.

By removing the defined(CONFIG_PPC32) part of the statement, my problem
goes away.

Cheers,
Ben.


___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev


Re: [PATCH] powerpc/usb: fix bug of kernel hang when initializing usb

2012-02-16 Thread Benjamin Herrenschmidt
On Thu, 2012-02-16 at 18:02 +0800, Shengzhou Liu wrote:
> If USB UTMI PHY is not enable, writing to portsc register will lead to
> kernel hang during boot up.
> 
> Signed-off-by: Shengzhou Liu 
> ---
> Apply for master branch of 
> git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6.git 
> Tested on P5020DS, the issue was reported by Benjamin Herrenschmidt. 

This fixes the hang, but sadly doesn't make USB work. I now get:

ehci_hcd: USB 2.0 'Enhanced' Host Controller (EHCI) Driver
ohci_hcd: USB 1.1 'Open' Host Controller (OHCI) Driver
/soc@ffe00/usb@21: Invalid 'dr_mode' property, fallback to host mode
fsl-ehci fsl-ehci.0: Freescale On-Chip EHCI Host Controller
fsl-ehci fsl-ehci.0: new USB bus registered, assigned bus number 1
fsl-ehci fsl-ehci.0: irq 44, io mem 0xffe21
fsl-ehci fsl-ehci.0: USB 2.0 started, EHCI 1.00
hub 1-0:1.0: USB hub found
hub 1-0:1.0: 1 port detected
fsl-ehci fsl-ehci.1: Freescale On-Chip EHCI Host Controller
fsl-ehci fsl-ehci.1: new USB bus registered, assigned bus number 2
fsl-ehci fsl-ehci.1: irq 45, io mem 0xffe211000
fsl-ehci fsl-ehci.1: USB 2.0 started, EHCI 1.00

 .../...

usb 1-1: device descriptor read/64, error -110
usb 1-1: device descriptor read/64, error -110



usb 1-1: new full-speed USB device number 3 using fsl-ehci
hub 1-0:1.0: unable to enumerate USB device on port 1



usb 1-1: new full-speed USB device number 4 using fsl-ehci
usb 1-1: device descriptor read/64, error -110

The blurb about "invalid dr_mode property" makes me think there's some
kind of disagreement between the device-tree coming with the machine and
what upstream expects. Basically the DT doesn't contain a dr_mode
property at all (which should be fine, host mode is what I want, but I
suspect some stuff aren't being configured properly by u-boot either...)

Cheers,
Ben.


___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev


Re: [PATCH] powerpc/usb: fix bug of kernel hang when initializing usb

2012-02-16 Thread Greg KH
On Thu, Feb 16, 2012 at 09:39:15PM +1100, Benjamin Herrenschmidt wrote:
> On Thu, 2012-02-16 at 18:02 +0800, Shengzhou Liu wrote:
> > If USB UTMI PHY is not enable, writing to portsc register will lead to
> > kernel hang during boot up.
> 
> Thanks, I'll try that tomorrow.
> 
> Greg, you're picking that up or should I ?

I can, if you let me know that this fixes your problem :)

thanks,

greg k-h
___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev


Re: [PATCH] powerpc/usb: fix bug of kernel hang when initializing usb

2012-02-16 Thread Benjamin Herrenschmidt
On Thu, 2012-02-16 at 18:02 +0800, Shengzhou Liu wrote:
> If USB UTMI PHY is not enable, writing to portsc register will lead to
> kernel hang during boot up.

Thanks, I'll try that tomorrow.

Greg, you're picking that up or should I ?

Cheers,
Ben.

> Signed-off-by: Shengzhou Liu 
> ---
> Apply for master branch of 
> git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6.git 
> Tested on P5020DS, the issue was reported by Benjamin Herrenschmidt. 
> 
>  drivers/usb/host/ehci-fsl.c |4 
>  drivers/usb/host/ehci-fsl.h |1 +
>  2 files changed, 5 insertions(+), 0 deletions(-)
> 
> diff --git a/drivers/usb/host/ehci-fsl.c b/drivers/usb/host/ehci-fsl.c
> index c26a82e..0090ed2 100644
> --- a/drivers/usb/host/ehci-fsl.c
> +++ b/drivers/usb/host/ehci-fsl.c
> @@ -216,6 +216,8 @@ static void ehci_fsl_setup_phy(struct ehci_hcd *ehci,
>  unsigned int port_offset)
>  {
>   u32 portsc;
> + struct usb_hcd *hcd = ehci_to_hcd(ehci);
> + void __iomem *non_ehci = hcd->regs;
>  
>   portsc = ehci_readl(ehci, &ehci->regs->port_status[port_offset]);
>   portsc &= ~(PORT_PTS_MSK | PORT_PTS_PTW);
> @@ -231,6 +233,8 @@ static void ehci_fsl_setup_phy(struct ehci_hcd *ehci,
>   portsc |= PORT_PTS_PTW;
>   /* fall through */
>   case FSL_USB2_PHY_UTMI:
> + /* enable UTMI PHY */
> + setbits32(non_ehci + FSL_SOC_USB_CTRL, CTRL_UTMI_PHY_EN);
>   portsc |= PORT_PTS_UTMI;
>   break;
>   case FSL_USB2_PHY_NONE:
> diff --git a/drivers/usb/host/ehci-fsl.h b/drivers/usb/host/ehci-fsl.h
> index bdf43e2..0e400c2 100644
> --- a/drivers/usb/host/ehci-fsl.h
> +++ b/drivers/usb/host/ehci-fsl.h
> @@ -45,6 +45,7 @@
>  #define FSL_SOC_USB_PRICTRL  0x40c   /* NOTE: big-endian */
>  #define FSL_SOC_USB_SICTRL   0x410   /* NOTE: big-endian */
>  #define FSL_SOC_USB_CTRL 0x500   /* NOTE: big-endian */
> +#define CTRL_UTMI_PHY_EN (1<<9)
>  #define CTRL_PHY_CLK_VALID   (1 << 17)
>  #define SNOOP_SIZE_2GB   0x1e
>  #endif   /* _EHCI_FSL_H */


___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev


[PATCH] powerpc/usb: fix bug of kernel hang when initializing usb

2012-02-16 Thread Shengzhou Liu
If USB UTMI PHY is not enable, writing to portsc register will lead to
kernel hang during boot up.

Signed-off-by: Shengzhou Liu 
---
Apply for master branch of 
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6.git 
Tested on P5020DS, the issue was reported by Benjamin Herrenschmidt. 

 drivers/usb/host/ehci-fsl.c |4 
 drivers/usb/host/ehci-fsl.h |1 +
 2 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/drivers/usb/host/ehci-fsl.c b/drivers/usb/host/ehci-fsl.c
index c26a82e..0090ed2 100644
--- a/drivers/usb/host/ehci-fsl.c
+++ b/drivers/usb/host/ehci-fsl.c
@@ -216,6 +216,8 @@ static void ehci_fsl_setup_phy(struct ehci_hcd *ehci,
   unsigned int port_offset)
 {
u32 portsc;
+   struct usb_hcd *hcd = ehci_to_hcd(ehci);
+   void __iomem *non_ehci = hcd->regs;
 
portsc = ehci_readl(ehci, &ehci->regs->port_status[port_offset]);
portsc &= ~(PORT_PTS_MSK | PORT_PTS_PTW);
@@ -231,6 +233,8 @@ static void ehci_fsl_setup_phy(struct ehci_hcd *ehci,
portsc |= PORT_PTS_PTW;
/* fall through */
case FSL_USB2_PHY_UTMI:
+   /* enable UTMI PHY */
+   setbits32(non_ehci + FSL_SOC_USB_CTRL, CTRL_UTMI_PHY_EN);
portsc |= PORT_PTS_UTMI;
break;
case FSL_USB2_PHY_NONE:
diff --git a/drivers/usb/host/ehci-fsl.h b/drivers/usb/host/ehci-fsl.h
index bdf43e2..0e400c2 100644
--- a/drivers/usb/host/ehci-fsl.h
+++ b/drivers/usb/host/ehci-fsl.h
@@ -45,6 +45,7 @@
 #define FSL_SOC_USB_PRICTRL0x40c   /* NOTE: big-endian */
 #define FSL_SOC_USB_SICTRL 0x410   /* NOTE: big-endian */
 #define FSL_SOC_USB_CTRL   0x500   /* NOTE: big-endian */
+#define CTRL_UTMI_PHY_EN   (1<<9)
 #define CTRL_PHY_CLK_VALID (1 << 17)
 #define SNOOP_SIZE_2GB 0x1e
 #endif /* _EHCI_FSL_H */
-- 
1.6.4


___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev