All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3] usb: gadget: fastboot: detach usb just before rebooting
@ 2023-01-07 16:48 Dario Binacchi
  2023-01-10  8:33 ` Mattijs Korpershoek
  0 siblings, 1 reply; 4+ messages in thread
From: Dario Binacchi @ 2023-01-07 16:48 UTC (permalink / raw)
  To: u-boot
  Cc: Dario Binacchi, Mattijs Korpershoek, Michael Trimarchi,
	Lukasz Majewski, Marek Vasut, linux-amarula

The patch fixes the following error when updating a BSH SMM S2 board:
3:72>Start Cmd:FB[-t 8000]: ucmd nand write ${loadaddr} nanddtb ${filesize}
3:72>Okay (0.023s)
3:72>Start Cmd:FB: reboot
3:72>Fail Bulk(R):LIBUSB_ERROR_IO(0s)

The "fastboot reboot" command detaches the USB when it still needs to be
used. So let's detach the USB just before the reset.

CC: Mattijs Korpershoek <mkorpershoek@baylibre.com>
Fixes: 5f7e01e9d5d800 ("usb: gadget: fastboot: detach usb on reboot commands")
Suggested-by: Michael Trimarchi <michael@amarulasolutions.com>
Co-developed-by: Mattijs Korpershoek <mkorpershoek@baylibre.com>
Signed-off-by: Mattijs Korpershoek <mkorpershoek@baylibre.com>
Signed-off-by: Dario Binacchi <dario.binacchi@amarulasolutions.com>

---

Changes in v3:
- Replace do_exit_on_complete() with g_dnl_unregister().
- Add 'Co-developed-by' tag.

Changes in v2:
- Add 'Suggested-by' tag.

 drivers/usb/gadget/f_fastboot.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/gadget/f_fastboot.c b/drivers/usb/gadget/f_fastboot.c
index 07b1681c8a9a..f4311328a2da 100644
--- a/drivers/usb/gadget/f_fastboot.c
+++ b/drivers/usb/gadget/f_fastboot.c
@@ -421,6 +421,7 @@ static int fastboot_tx_write_str(const char *buffer)
 
 static void compl_do_reset(struct usb_ep *ep, struct usb_request *req)
 {
+	g_dnl_unregister();
 	do_reset(NULL, 0, 0, NULL);
 }
 
@@ -544,7 +545,6 @@ static void rx_handler_command(struct usb_ep *ep, struct usb_request *req)
 		case FASTBOOT_COMMAND_REBOOT_FASTBOOTD:
 		case FASTBOOT_COMMAND_REBOOT_RECOVERY:
 			fastboot_func->in_req->complete = compl_do_reset;
-			g_dnl_trigger_detach();
 			break;
 #if CONFIG_IS_ENABLED(FASTBOOT_UUU_SUPPORT)
 		case FASTBOOT_COMMAND_ACMD:
-- 
2.32.0


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

* Re: [PATCH v3] usb: gadget: fastboot: detach usb just before rebooting
  2023-01-07 16:48 [PATCH v3] usb: gadget: fastboot: detach usb just before rebooting Dario Binacchi
@ 2023-01-10  8:33 ` Mattijs Korpershoek
  2023-01-10  9:14   ` Mattijs Korpershoek
  2023-01-10 10:37   ` Marek Vasut
  0 siblings, 2 replies; 4+ messages in thread
From: Mattijs Korpershoek @ 2023-01-10  8:33 UTC (permalink / raw)
  To: Dario Binacchi, u-boot
  Cc: Dario Binacchi, Michael Trimarchi, Lukasz Majewski, Marek Vasut,
	linux-amarula

Hi Dario,

Thank you for your patch.

On Sat, Jan 07, 2023 at 17:48, Dario Binacchi <dario.binacchi@amarulasolutions.com> wrote:

> The patch fixes the following error when updating a BSH SMM S2 board:
> 3:72>Start Cmd:FB[-t 8000]: ucmd nand write ${loadaddr} nanddtb ${filesize}
> 3:72>Okay (0.023s)
> 3:72>Start Cmd:FB: reboot
> 3:72>Fail Bulk(R):LIBUSB_ERROR_IO(0s)
>
> The "fastboot reboot" command detaches the USB when it still needs to be
> used. So let's detach the USB just before the reset.
>
> CC: Mattijs Korpershoek <mkorpershoek@baylibre.com>
> Fixes: 5f7e01e9d5d800 ("usb: gadget: fastboot: detach usb on reboot commands")
> Suggested-by: Michael Trimarchi <michael@amarulasolutions.com>
> Co-developed-by: Mattijs Korpershoek <mkorpershoek@baylibre.com>
> Signed-off-by: Mattijs Korpershoek <mkorpershoek@baylibre.com>
> Signed-off-by: Dario Binacchi <dario.binacchi@amarulasolutions.com>

I've re-ran this on my vim3l. This patch, alongside with an
implementation of usb_gadget_ops.pullup() in
drivers/usb/gadget/dwc2_udc_otg.c also fixes the issue described in
commit 5f7e01e9d5d800 ("usb: gadget: fastboot: detach usb on reboot commands")

Tested-by Mattijs Korpershoek <mkorpershoek@baylibre.com>

I will submit the pullup() implementation on my end, indepently from
this change.

Marek, is it possible to pick this up to resolve Dario's flashing problems?

>
> ---
>
> Changes in v3:
> - Replace do_exit_on_complete() with g_dnl_unregister().
> - Add 'Co-developed-by' tag.
>
> Changes in v2:
> - Add 'Suggested-by' tag.
>
>  drivers/usb/gadget/f_fastboot.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/usb/gadget/f_fastboot.c b/drivers/usb/gadget/f_fastboot.c
> index 07b1681c8a9a..f4311328a2da 100644
> --- a/drivers/usb/gadget/f_fastboot.c
> +++ b/drivers/usb/gadget/f_fastboot.c
> @@ -421,6 +421,7 @@ static int fastboot_tx_write_str(const char *buffer)
>  
>  static void compl_do_reset(struct usb_ep *ep, struct usb_request *req)
>  {
> +	g_dnl_unregister();
>  	do_reset(NULL, 0, 0, NULL);
>  }
>  
> @@ -544,7 +545,6 @@ static void rx_handler_command(struct usb_ep *ep, struct usb_request *req)
>  		case FASTBOOT_COMMAND_REBOOT_FASTBOOTD:
>  		case FASTBOOT_COMMAND_REBOOT_RECOVERY:
>  			fastboot_func->in_req->complete = compl_do_reset;
> -			g_dnl_trigger_detach();
>  			break;
>  #if CONFIG_IS_ENABLED(FASTBOOT_UUU_SUPPORT)
>  		case FASTBOOT_COMMAND_ACMD:
> -- 
> 2.32.0

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

* Re: [PATCH v3] usb: gadget: fastboot: detach usb just before rebooting
  2023-01-10  8:33 ` Mattijs Korpershoek
@ 2023-01-10  9:14   ` Mattijs Korpershoek
  2023-01-10 10:37   ` Marek Vasut
  1 sibling, 0 replies; 4+ messages in thread
From: Mattijs Korpershoek @ 2023-01-10  9:14 UTC (permalink / raw)
  To: u-boot
  Cc: Dario Binacchi, Michael Trimarchi, Lukasz Majewski, Marek Vasut,
	linux-amarula

On Tue, Jan 10, 2023 at 09:33, Mattijs Korpershoek <mkorpershoek@baylibre.com> wrote:

> Hi Dario,
>
> Thank you for your patch.
>
> On Sat, Jan 07, 2023 at 17:48, Dario Binacchi <dario.binacchi@amarulasolutions.com> wrote:
>
>> The patch fixes the following error when updating a BSH SMM S2 board:
>> 3:72>Start Cmd:FB[-t 8000]: ucmd nand write ${loadaddr} nanddtb ${filesize}
>> 3:72>Okay (0.023s)
>> 3:72>Start Cmd:FB: reboot
>> 3:72>Fail Bulk(R):LIBUSB_ERROR_IO(0s)
>>
>> The "fastboot reboot" command detaches the USB when it still needs to be
>> used. So let's detach the USB just before the reset.
>>
>> CC: Mattijs Korpershoek <mkorpershoek@baylibre.com>
>> Fixes: 5f7e01e9d5d800 ("usb: gadget: fastboot: detach usb on reboot commands")
>> Suggested-by: Michael Trimarchi <michael@amarulasolutions.com>
>> Co-developed-by: Mattijs Korpershoek <mkorpershoek@baylibre.com>
>> Signed-off-by: Mattijs Korpershoek <mkorpershoek@baylibre.com>
>> Signed-off-by: Dario Binacchi <dario.binacchi@amarulasolutions.com>
>
> I've re-ran this on my vim3l. This patch, alongside with an
> implementation of usb_gadget_ops.pullup() in
> drivers/usb/gadget/dwc2_udc_otg.c also fixes the issue described in
> commit 5f7e01e9d5d800 ("usb: gadget: fastboot: detach usb on reboot commands")
>
> Tested-by Mattijs Korpershoek <mkorpershoek@baylibre.com>
>
> I will submit the pullup() implementation on my end, indepently from
> this change.

For those interested, pullup() change is submitted here:
https://lore.kernel.org/all/20230110-dwc2-pullup-v1-1-2bf9743e59e5@baylibre.com/

>
> Marek, is it possible to pick this up to resolve Dario's flashing problems?
>
>>
>> ---
>>
>> Changes in v3:
>> - Replace do_exit_on_complete() with g_dnl_unregister().
>> - Add 'Co-developed-by' tag.
>>
>> Changes in v2:
>> - Add 'Suggested-by' tag.
>>
>>  drivers/usb/gadget/f_fastboot.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/usb/gadget/f_fastboot.c b/drivers/usb/gadget/f_fastboot.c
>> index 07b1681c8a9a..f4311328a2da 100644
>> --- a/drivers/usb/gadget/f_fastboot.c
>> +++ b/drivers/usb/gadget/f_fastboot.c
>> @@ -421,6 +421,7 @@ static int fastboot_tx_write_str(const char *buffer)
>>  
>>  static void compl_do_reset(struct usb_ep *ep, struct usb_request *req)
>>  {
>> +	g_dnl_unregister();
>>  	do_reset(NULL, 0, 0, NULL);
>>  }
>>  
>> @@ -544,7 +545,6 @@ static void rx_handler_command(struct usb_ep *ep, struct usb_request *req)
>>  		case FASTBOOT_COMMAND_REBOOT_FASTBOOTD:
>>  		case FASTBOOT_COMMAND_REBOOT_RECOVERY:
>>  			fastboot_func->in_req->complete = compl_do_reset;
>> -			g_dnl_trigger_detach();
>>  			break;
>>  #if CONFIG_IS_ENABLED(FASTBOOT_UUU_SUPPORT)
>>  		case FASTBOOT_COMMAND_ACMD:
>> -- 
>> 2.32.0

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

* Re: [PATCH v3] usb: gadget: fastboot: detach usb just before rebooting
  2023-01-10  8:33 ` Mattijs Korpershoek
  2023-01-10  9:14   ` Mattijs Korpershoek
@ 2023-01-10 10:37   ` Marek Vasut
  1 sibling, 0 replies; 4+ messages in thread
From: Marek Vasut @ 2023-01-10 10:37 UTC (permalink / raw)
  To: Mattijs Korpershoek, Dario Binacchi, u-boot
  Cc: Michael Trimarchi, Lukasz Majewski, linux-amarula

On 1/10/23 09:33, Mattijs Korpershoek wrote:
> Hi Dario,

Hello everyone,

> Thank you for your patch.
> 
> On Sat, Jan 07, 2023 at 17:48, Dario Binacchi <dario.binacchi@amarulasolutions.com> wrote:
> 
>> The patch fixes the following error when updating a BSH SMM S2 board:
>> 3:72>Start Cmd:FB[-t 8000]: ucmd nand write ${loadaddr} nanddtb ${filesize}
>> 3:72>Okay (0.023s)
>> 3:72>Start Cmd:FB: reboot
>> 3:72>Fail Bulk(R):LIBUSB_ERROR_IO(0s)
>>
>> The "fastboot reboot" command detaches the USB when it still needs to be
>> used. So let's detach the USB just before the reset.
>>
>> CC: Mattijs Korpershoek <mkorpershoek@baylibre.com>
>> Fixes: 5f7e01e9d5d800 ("usb: gadget: fastboot: detach usb on reboot commands")
>> Suggested-by: Michael Trimarchi <michael@amarulasolutions.com>
>> Co-developed-by: Mattijs Korpershoek <mkorpershoek@baylibre.com>
>> Signed-off-by: Mattijs Korpershoek <mkorpershoek@baylibre.com>
>> Signed-off-by: Dario Binacchi <dario.binacchi@amarulasolutions.com>
> 
> I've re-ran this on my vim3l. This patch, alongside with an
> implementation of usb_gadget_ops.pullup() in
> drivers/usb/gadget/dwc2_udc_otg.c also fixes the issue described in
> commit 5f7e01e9d5d800 ("usb: gadget: fastboot: detach usb on reboot commands")
> 
> Tested-by Mattijs Korpershoek <mkorpershoek@baylibre.com>
> 
> I will submit the pullup() implementation on my end, indepently from
> this change.
> 
> Marek, is it possible to pick this up to resolve Dario's flashing problems?

Applied both to usb/master.

Thanks to both of you for figuring it all out, much appreciated!

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

end of thread, other threads:[~2023-01-10 10:37 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-07 16:48 [PATCH v3] usb: gadget: fastboot: detach usb just before rebooting Dario Binacchi
2023-01-10  8:33 ` Mattijs Korpershoek
2023-01-10  9:14   ` Mattijs Korpershoek
2023-01-10 10:37   ` Marek Vasut

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.