public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot] [PATCH 1/2] usb: gadget: composite: Fix NULL pointer crash in USB compliance test
@ 2015-01-09 13:54 Stefan Roese
  2015-01-09 13:54 ` [U-Boot] [PATCH 2/2] usb: gadget: f_dfu: Add get_alt function to pass the " Stefan Roese
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Stefan Roese @ 2015-01-09 13:54 UTC (permalink / raw)
  To: u-boot

On the DXR2 board (AM335x using MUSB) the USB compliance test suite
(USB 2.0 Command Verifier) will cause the board to crash and reset
upon the "BOS Descriptor Test - Addressed state". Here the output
from the DRX2 while running this test:

GADGET DRIVER: usb_dnl_dfu
musb-hdrc: peripheral reset irq lost!
composite_setup (776)
data abort
pc : [<87f693ac>]          lr : [<87f6911c>]
sp : 86f33a58  ip : 00000000     fp : 86f3bbac
r10: 00000f00  r9 : 86f33ef4     r8 : 86f37da8
r7 : 00000005  r6 : 86f33a90     r5 : 00000000  r4 : 86f37e30
r3 : 00000000  r2 : 00000000     r1 : 87f9c888  r0 : 00000016
Flags: Nzcv  IRQs off  FIQs on  Mode SVC_32
Resetting CPU ...

resetting ...

By adding the case statement for USB_DT_BOS and therefore not running
into the default case (jump to unkown label) this crash is fixed.

Signed-off-by: Stefan Roese <sr@denx.de>
Cc: Roger Meier <r.meier@siemens.com>
Cc: Samuel Egli <samuel.egli@siemens.com>
Cc: Enrico Leto <enrico.leto@siemens.com>
Cc: Heiko Schocher <hs@denx.de>
Cc: Lukasz Majewski <l.majewski@samsung.com>
Cc: Marek Vasut <marex@denx.de>
---
 drivers/usb/gadget/composite.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c
index a4c5606..98c2da6 100644
--- a/drivers/usb/gadget/composite.c
+++ b/drivers/usb/gadget/composite.c
@@ -761,6 +761,14 @@ composite_setup(struct usb_gadget *gadget, const struct usb_ctrlrequest *ctrl)
 			if (value >= 0)
 				value = min(w_length, (u16) value);
 			break;
+		case USB_DT_BOS:
+			/*
+			 * The USB compliance test (USB 2.0 Command Verifier)
+			 * issues this request. We should not run into the
+			 * default path here. But return for now until
+			 * the superspeed support is added.
+			 */
+			break;
 		default:
 			goto unknown;
 		}
-- 
2.2.1

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

* [U-Boot] [PATCH 2/2] usb: gadget: f_dfu: Add get_alt function to pass the USB compliance test
  2015-01-09 13:54 [U-Boot] [PATCH 1/2] usb: gadget: composite: Fix NULL pointer crash in USB compliance test Stefan Roese
@ 2015-01-09 13:54 ` Stefan Roese
  2015-01-09 13:59   ` Heiko Schocher
  2015-01-09 13:59 ` [U-Boot] [PATCH 1/2] usb: gadget: composite: Fix NULL pointer crash in " Heiko Schocher
  2015-01-10  0:47 ` Marek Vasut
  2 siblings, 1 reply; 5+ messages in thread
From: Stefan Roese @ 2015-01-09 13:54 UTC (permalink / raw)
  To: u-boot

Without this function the USB compliance test (USB 2.0 Command Verifier) will
fail in the "Interface Descriptor Test" with this error message:

FAIL
(1.2.51) A successful GetInterface request must return the alternate setting
set by a prior call to SetInterface.

Lets add this function to read back the value so that the DFU device fully
passes the USB compliance test.

Signed-off-by: Stefan Roese <sr@denx.de>
Cc: Roger Meier <r.meier@siemens.com>
Cc: Samuel Egli <samuel.egli@siemens.com>
Cc: Enrico Leto <enrico.leto@siemens.com>
Cc: Heiko Schocher <hs@denx.de>
Cc: Lukasz Majewski <l.majewski@samsung.com>
Cc: Marek Vasut <marex@denx.de>
---
 drivers/usb/gadget/f_dfu.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/drivers/usb/gadget/f_dfu.c b/drivers/usb/gadget/f_dfu.c
index ead71eb..77a1567 100644
--- a/drivers/usb/gadget/f_dfu.c
+++ b/drivers/usb/gadget/f_dfu.c
@@ -780,6 +780,13 @@ static int dfu_set_alt(struct usb_function *f, unsigned intf, unsigned alt)
 	return 0;
 }
 
+static int __dfu_get_alt(struct usb_function *f, unsigned intf)
+{
+	struct f_dfu *f_dfu = func_to_dfu(f);
+
+	return f_dfu->altsetting;
+}
+
 /* TODO: is this really what we need here? */
 static void dfu_disable(struct usb_function *f)
 {
@@ -806,6 +813,7 @@ static int dfu_bind_config(struct usb_configuration *c)
 	f_dfu->usb_function.bind = dfu_bind;
 	f_dfu->usb_function.unbind = dfu_unbind;
 	f_dfu->usb_function.set_alt = dfu_set_alt;
+	f_dfu->usb_function.get_alt = __dfu_get_alt;
 	f_dfu->usb_function.disable = dfu_disable;
 	f_dfu->usb_function.strings = dfu_generic_strings;
 	f_dfu->usb_function.setup = dfu_handle;
-- 
2.2.1

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

* [U-Boot] [PATCH 1/2] usb: gadget: composite: Fix NULL pointer crash in USB compliance test
  2015-01-09 13:54 [U-Boot] [PATCH 1/2] usb: gadget: composite: Fix NULL pointer crash in USB compliance test Stefan Roese
  2015-01-09 13:54 ` [U-Boot] [PATCH 2/2] usb: gadget: f_dfu: Add get_alt function to pass the " Stefan Roese
@ 2015-01-09 13:59 ` Heiko Schocher
  2015-01-10  0:47 ` Marek Vasut
  2 siblings, 0 replies; 5+ messages in thread
From: Heiko Schocher @ 2015-01-09 13:59 UTC (permalink / raw)
  To: u-boot

Hello Stefan,

Am 09.01.2015 14:54, schrieb Stefan Roese:
> On the DXR2 board (AM335x using MUSB) the USB compliance test suite
> (USB 2.0 Command Verifier) will cause the board to crash and reset
> upon the "BOS Descriptor Test - Addressed state". Here the output
> from the DRX2 while running this test:
>
> GADGET DRIVER: usb_dnl_dfu
> musb-hdrc: peripheral reset irq lost!
> composite_setup (776)
> data abort
> pc : [<87f693ac>]          lr : [<87f6911c>]
> sp : 86f33a58  ip : 00000000     fp : 86f3bbac
> r10: 00000f00  r9 : 86f33ef4     r8 : 86f37da8
> r7 : 00000005  r6 : 86f33a90     r5 : 00000000  r4 : 86f37e30
> r3 : 00000000  r2 : 00000000     r1 : 87f9c888  r0 : 00000016
> Flags: Nzcv  IRQs off  FIQs on  Mode SVC_32
> Resetting CPU ...
>
> resetting ...
>
> By adding the case statement for USB_DT_BOS and therefore not running
> into the default case (jump to unkown label) this crash is fixed.
>
> Signed-off-by: Stefan Roese <sr@denx.de>
> Cc: Roger Meier <r.meier@siemens.com>
> Cc: Samuel Egli <samuel.egli@siemens.com>
> Cc: Enrico Leto <enrico.leto@siemens.com>
> Cc: Heiko Schocher <hs@denx.de>
> Cc: Lukasz Majewski <l.majewski@samsung.com>
> Cc: Marek Vasut <marex@denx.de>
> ---
>   drivers/usb/gadget/composite.c | 8 ++++++++
>   1 file changed, 8 insertions(+)

Thanks!

Acked-by: Heiko Schocher <hs@denx.de>

bye,
Heiko
>
> diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c
> index a4c5606..98c2da6 100644
> --- a/drivers/usb/gadget/composite.c
> +++ b/drivers/usb/gadget/composite.c
> @@ -761,6 +761,14 @@ composite_setup(struct usb_gadget *gadget, const struct usb_ctrlrequest *ctrl)
>   			if (value >= 0)
>   				value = min(w_length, (u16) value);
>   			break;
> +		case USB_DT_BOS:
> +			/*
> +			 * The USB compliance test (USB 2.0 Command Verifier)
> +			 * issues this request. We should not run into the
> +			 * default path here. But return for now until
> +			 * the superspeed support is added.
> +			 */
> +			break;
>   		default:
>   			goto unknown;
>   		}
>

-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany

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

* [U-Boot] [PATCH 2/2] usb: gadget: f_dfu: Add get_alt function to pass the USB compliance test
  2015-01-09 13:54 ` [U-Boot] [PATCH 2/2] usb: gadget: f_dfu: Add get_alt function to pass the " Stefan Roese
@ 2015-01-09 13:59   ` Heiko Schocher
  0 siblings, 0 replies; 5+ messages in thread
From: Heiko Schocher @ 2015-01-09 13:59 UTC (permalink / raw)
  To: u-boot

Hello Stefan,

Am 09.01.2015 14:54, schrieb Stefan Roese:
> Without this function the USB compliance test (USB 2.0 Command Verifier) will
> fail in the "Interface Descriptor Test" with this error message:
>
> FAIL
> (1.2.51) A successful GetInterface request must return the alternate setting
> set by a prior call to SetInterface.
>
> Lets add this function to read back the value so that the DFU device fully
> passes the USB compliance test.
>
> Signed-off-by: Stefan Roese <sr@denx.de>
> Cc: Roger Meier <r.meier@siemens.com>
> Cc: Samuel Egli <samuel.egli@siemens.com>
> Cc: Enrico Leto <enrico.leto@siemens.com>
> Cc: Heiko Schocher <hs@denx.de>
> Cc: Lukasz Majewski <l.majewski@samsung.com>
> Cc: Marek Vasut <marex@denx.de>
> ---
>   drivers/usb/gadget/f_dfu.c | 8 ++++++++
>   1 file changed, 8 insertions(+)

Thanks!

Acked-by: Heiko Schocher <hs@denx.de>

bye,
Heiko
-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany

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

* [U-Boot] [PATCH 1/2] usb: gadget: composite: Fix NULL pointer crash in USB compliance test
  2015-01-09 13:54 [U-Boot] [PATCH 1/2] usb: gadget: composite: Fix NULL pointer crash in USB compliance test Stefan Roese
  2015-01-09 13:54 ` [U-Boot] [PATCH 2/2] usb: gadget: f_dfu: Add get_alt function to pass the " Stefan Roese
  2015-01-09 13:59 ` [U-Boot] [PATCH 1/2] usb: gadget: composite: Fix NULL pointer crash in " Heiko Schocher
@ 2015-01-10  0:47 ` Marek Vasut
  2 siblings, 0 replies; 5+ messages in thread
From: Marek Vasut @ 2015-01-10  0:47 UTC (permalink / raw)
  To: u-boot

On Friday, January 09, 2015 at 02:54:55 PM, Stefan Roese wrote:
> On the DXR2 board (AM335x using MUSB) the USB compliance test suite
> (USB 2.0 Command Verifier) will cause the board to crash and reset
> upon the "BOS Descriptor Test - Addressed state". Here the output
> from the DRX2 while running this test:
> 
> GADGET DRIVER: usb_dnl_dfu
> musb-hdrc: peripheral reset irq lost!
> composite_setup (776)
> data abort
> pc : [<87f693ac>]          lr : [<87f6911c>]
> sp : 86f33a58  ip : 00000000     fp : 86f3bbac
> r10: 00000f00  r9 : 86f33ef4     r8 : 86f37da8
> r7 : 00000005  r6 : 86f33a90     r5 : 00000000  r4 : 86f37e30
> r3 : 00000000  r2 : 00000000     r1 : 87f9c888  r0 : 00000016
> Flags: Nzcv  IRQs off  FIQs on  Mode SVC_32
> Resetting CPU ...
> 
> resetting ...
> 
> By adding the case statement for USB_DT_BOS and therefore not running
> into the default case (jump to unkown label) this crash is fixed.

Applied both, thank you!

Best regards,
Marek Vasut

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

end of thread, other threads:[~2015-01-10  0:47 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-01-09 13:54 [U-Boot] [PATCH 1/2] usb: gadget: composite: Fix NULL pointer crash in USB compliance test Stefan Roese
2015-01-09 13:54 ` [U-Boot] [PATCH 2/2] usb: gadget: f_dfu: Add get_alt function to pass the " Stefan Roese
2015-01-09 13:59   ` Heiko Schocher
2015-01-09 13:59 ` [U-Boot] [PATCH 1/2] usb: gadget: composite: Fix NULL pointer crash in " Heiko Schocher
2015-01-10  0:47 ` Marek Vasut

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox