All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [UBOOT PATCH] usb: ehci-hcd: Fix crash when rootdev not initialized
@ 2016-06-27  8:59 Siva Durga Prasad Paladugu
  2016-06-27 11:05 ` Hans de Goede
  0 siblings, 1 reply; 4+ messages in thread
From: Siva Durga Prasad Paladugu @ 2016-06-27  8:59 UTC (permalink / raw)
  To: u-boot

This patch fixes the issue on zynq USB failure with DM
when rootdev is not initialized. This variable is initalized
to zero in non driver model case but not in DM.

Signed-off-by: Siva Durga Prasad Paladugu <sivadur@xilinx.com>
---
- Tested on Zynq ZC702 board with USB DM driver model patches
  sent by Simon.
---
 drivers/usb/host/ehci-hcd.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c
index 13aa70d..8adffa6 100644
--- a/drivers/usb/host/ehci-hcd.c
+++ b/drivers/usb/host/ehci-hcd.c
@@ -1624,6 +1624,8 @@ int ehci_register(struct udevice *dev, struct ehci_hccr *hccr,
 			goto err;
 	}
 
+	ctrl->rootdev = 0;
+
 	ret = ehci_common_init(ctrl, tweaks);
 	if (ret)
 		goto err;
-- 
2.1.1

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [U-Boot] [UBOOT PATCH] usb: ehci-hcd: Fix crash when rootdev not initialized
  2016-06-27  8:59 [U-Boot] [UBOOT PATCH] usb: ehci-hcd: Fix crash when rootdev not initialized Siva Durga Prasad Paladugu
@ 2016-06-27 11:05 ` Hans de Goede
  2016-06-28  6:06   ` Siva Durga Prasad Paladugu
  0 siblings, 1 reply; 4+ messages in thread
From: Hans de Goede @ 2016-06-27 11:05 UTC (permalink / raw)
  To: u-boot

Hi,

On 27-06-16 10:59, Siva Durga Prasad Paladugu wrote:
> This patch fixes the issue on zynq USB failure with DM
> when rootdev is not initialized. This variable is initalized
> to zero in non driver model case but not in DM.
>
> Signed-off-by: Siva Durga Prasad Paladugu <sivadur@xilinx.com>
> ---
> - Tested on Zynq ZC702 board with USB DM driver model patches
>   sent by Simon.

This patch does not seem like the right fix, normally something
like the ehci_ctrl struct would be allocated by dm by setting
priv_auto_alloc_size in the driver description, and then the
data will get calloc-ed. If you're allocating the ehci_ctrl struct
differently and not memsetting it to 0 you may have other bugs
lurking, or may get new bugs when new members get added in the
future.

My advice would be to use priv_auto_alloc_size, see .e.g :
drivers/usb/host/ehci-sunxi.c

If you cannot use that for some reason, make sure to memset
struct ehci_Ctrl to 0 before calling ehci_register()

Regards,

Hans



> ---
>  drivers/usb/host/ehci-hcd.c | 2 ++
>  1 file changed, 2 insertions(+)
>
> diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c
> index 13aa70d..8adffa6 100644
> --- a/drivers/usb/host/ehci-hcd.c
> +++ b/drivers/usb/host/ehci-hcd.c
> @@ -1624,6 +1624,8 @@ int ehci_register(struct udevice *dev, struct ehci_hccr *hccr,
>  			goto err;
>  	}
>
> +	ctrl->rootdev = 0;
> +
>  	ret = ehci_common_init(ctrl, tweaks);
>  	if (ret)
>  		goto err;
>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [U-Boot] [UBOOT PATCH] usb: ehci-hcd: Fix crash when rootdev not initialized
  2016-06-27 11:05 ` Hans de Goede
@ 2016-06-28  6:06   ` Siva Durga Prasad Paladugu
  2016-06-29  3:28     ` Simon Glass
  0 siblings, 1 reply; 4+ messages in thread
From: Siva Durga Prasad Paladugu @ 2016-06-28  6:06 UTC (permalink / raw)
  To: u-boot


Hi,

> -----Original Message-----
> From: Hans de Goede [mailto:hdegoede at redhat.com]
> Sent: Monday, June 27, 2016 4:35 PM
> To: Siva Durga Prasad Paladugu <sivadur@xilinx.com>; u-boot at lists.denx.de
> Cc: marex at denx.de; Siva Durga Prasad Paladugu <sivadur@xilinx.com>
> Subject: Re: [U-Boot] [UBOOT PATCH] usb: ehci-hcd: Fix crash when rootdev not
> initialized
> 
> Hi,
> 
> On 27-06-16 10:59, Siva Durga Prasad Paladugu wrote:
> > This patch fixes the issue on zynq USB failure with DM when rootdev is
> > not initialized. This variable is initalized to zero in non driver
> > model case but not in DM.
> >
> > Signed-off-by: Siva Durga Prasad Paladugu <sivadur@xilinx.com>
> > ---
> > - Tested on Zynq ZC702 board with USB DM driver model patches
> >   sent by Simon.
> 
> This patch does not seem like the right fix, normally something like the ehci_ctrl
> struct would be allocated by dm by setting priv_auto_alloc_size in the driver
> description, and then the data will get calloc-ed. If you're allocating the ehci_ctrl
> struct differently and not memsetting it to 0 you may have other bugs lurking, or
> may get new bugs when new members get added in the future.
This is also fine for me, no Problem.
I will reply to Simon on his patch of Zynq USB DM and will ask him to do so.

Thanks,
Siva

> 
> My advice would be to use priv_auto_alloc_size, see .e.g :
> drivers/usb/host/ehci-sunxi.c
> 
> If you cannot use that for some reason, make sure to memset struct ehci_Ctrl to
> 0 before calling ehci_register()
> 
> Regards,
> 
> Hans
> 
> 
> 
> > ---
> >  drivers/usb/host/ehci-hcd.c | 2 ++
> >  1 file changed, 2 insertions(+)
> >
> > diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c
> > index 13aa70d..8adffa6 100644
> > --- a/drivers/usb/host/ehci-hcd.c
> > +++ b/drivers/usb/host/ehci-hcd.c
> > @@ -1624,6 +1624,8 @@ int ehci_register(struct udevice *dev, struct
> ehci_hccr *hccr,
> >  			goto err;
> >  	}
> >
> > +	ctrl->rootdev = 0;
> > +
> >  	ret = ehci_common_init(ctrl, tweaks);
> >  	if (ret)
> >  		goto err;
> >

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [U-Boot] [UBOOT PATCH] usb: ehci-hcd: Fix crash when rootdev not initialized
  2016-06-28  6:06   ` Siva Durga Prasad Paladugu
@ 2016-06-29  3:28     ` Simon Glass
  0 siblings, 0 replies; 4+ messages in thread
From: Simon Glass @ 2016-06-29  3:28 UTC (permalink / raw)
  To: u-boot

Hi,

On 27 June 2016 at 23:06, Siva Durga Prasad Paladugu
<siva.durga.paladugu@xilinx.com> wrote:
>
> Hi,
>
>> -----Original Message-----
>> From: Hans de Goede [mailto:hdegoede at redhat.com]
>> Sent: Monday, June 27, 2016 4:35 PM
>> To: Siva Durga Prasad Paladugu <sivadur@xilinx.com>; u-boot at lists.denx.de
>> Cc: marex at denx.de; Siva Durga Prasad Paladugu <sivadur@xilinx.com>
>> Subject: Re: [U-Boot] [UBOOT PATCH] usb: ehci-hcd: Fix crash when rootdev not
>> initialized
>>
>> Hi,
>>
>> On 27-06-16 10:59, Siva Durga Prasad Paladugu wrote:
>> > This patch fixes the issue on zynq USB failure with DM when rootdev is
>> > not initialized. This variable is initalized to zero in non driver
>> > model case but not in DM.
>> >
>> > Signed-off-by: Siva Durga Prasad Paladugu <sivadur@xilinx.com>
>> > ---
>> > - Tested on Zynq ZC702 board with USB DM driver model patches
>> >   sent by Simon.
>>
>> This patch does not seem like the right fix, normally something like the ehci_ctrl
>> struct would be allocated by dm by setting priv_auto_alloc_size in the driver
>> description, and then the data will get calloc-ed. If you're allocating the ehci_ctrl
>> struct differently and not memsetting it to 0 you may have other bugs lurking, or
>> may get new bugs when new members get added in the future.
> This is also fine for me, no Problem.
> I will reply to Simon on his patch of Zynq USB DM and will ask him to do so.
>
> Thanks,
> Siva
>
>>
>> My advice would be to use priv_auto_alloc_size, see .e.g :
>> drivers/usb/host/ehci-sunxi.c
>>
>> If you cannot use that for some reason, make sure to memset struct ehci_Ctrl to
>> 0 before calling ehci_register()

Agreed, but this is how EHCI works at present. Since EHCI is not a
uclass it cannot have its own private data. So the driver must
incorporate EHCI's private data in its own private data.

Yes this is error-prone. I'm not sure of a better solution at present,
but welcome ideas!

Reviewed-by: Simon Glass <sjg@chromium.org>

>>
>> Regards,
>>
>> Hans
>>
>>
>>
>> > ---
>> >  drivers/usb/host/ehci-hcd.c | 2 ++
>> >  1 file changed, 2 insertions(+)
>> >
>> > diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c
>> > index 13aa70d..8adffa6 100644
>> > --- a/drivers/usb/host/ehci-hcd.c
>> > +++ b/drivers/usb/host/ehci-hcd.c
>> > @@ -1624,6 +1624,8 @@ int ehci_register(struct udevice *dev, struct
>> ehci_hccr *hccr,
>> >                     goto err;
>> >     }
>> >
>> > +   ctrl->rootdev = 0;
>> > +
>> >     ret = ehci_common_init(ctrl, tweaks);
>> >     if (ret)
>> >             goto err;
>> >

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2016-06-29  3:28 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-06-27  8:59 [U-Boot] [UBOOT PATCH] usb: ehci-hcd: Fix crash when rootdev not initialized Siva Durga Prasad Paladugu
2016-06-27 11:05 ` Hans de Goede
2016-06-28  6:06   ` Siva Durga Prasad Paladugu
2016-06-29  3:28     ` Simon Glass

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.