u-boot.lists.denx.de archive mirror
 help / color / mirror / Atom feed
* [PATCH] usb: gadget: fastboot: detach usb just before rebooting
@ 2023-01-04 16:16 Dario Binacchi
  2023-01-04 16:27 ` Marek Vasut
  0 siblings, 1 reply; 3+ messages in thread
From: Dario Binacchi @ 2023-01-04 16:16 UTC (permalink / raw)
  To: u-boot
  Cc: Dario Binacchi, Mattijs Korpershoek, 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")
Signed-off-by: Dario Binacchi <dario.binacchi@amarulasolutions.com>
---

 drivers/usb/gadget/f_fastboot.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/usb/gadget/f_fastboot.c b/drivers/usb/gadget/f_fastboot.c
index 07b1681c8a9a..0b3fae564d0a 100644
--- a/drivers/usb/gadget/f_fastboot.c
+++ b/drivers/usb/gadget/f_fastboot.c
@@ -419,11 +419,6 @@ static int fastboot_tx_write_str(const char *buffer)
 	return fastboot_tx_write(buffer, strlen(buffer));
 }
 
-static void compl_do_reset(struct usb_ep *ep, struct usb_request *req)
-{
-	do_reset(NULL, 0, 0, NULL);
-}
-
 static unsigned int rx_bytes_expected(struct usb_ep *ep)
 {
 	int rx_remain = fastboot_data_remaining();
@@ -495,6 +490,12 @@ static void do_bootm_on_complete(struct usb_ep *ep, struct usb_request *req)
 	do_exit_on_complete(ep, req);
 }
 
+static void compl_do_reset(struct usb_ep *ep, struct usb_request *req)
+{
+	do_exit_on_complete(ep, req);
+	do_reset(NULL, 0, 0, NULL);
+}
+
 #if CONFIG_IS_ENABLED(FASTBOOT_UUU_SUPPORT)
 static void do_acmd_complete(struct usb_ep *ep, struct usb_request *req)
 {
@@ -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] 3+ messages in thread

* Re: [PATCH] usb: gadget: fastboot: detach usb just before rebooting
  2023-01-04 16:16 [PATCH] usb: gadget: fastboot: detach usb just before rebooting Dario Binacchi
@ 2023-01-04 16:27 ` Marek Vasut
  2023-01-05  9:07   ` Mattijs Korpershoek
  0 siblings, 1 reply; 3+ messages in thread
From: Marek Vasut @ 2023-01-04 16:27 UTC (permalink / raw)
  To: Dario Binacchi, u-boot
  Cc: Mattijs Korpershoek, Lukasz Majewski, linux-amarula

On 1/4/23 17:16, Dario Binacchi 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")
> Signed-off-by: Dario Binacchi <dario.binacchi@amarulasolutions.com>
> ---
> 
>   drivers/usb/gadget/f_fastboot.c | 12 ++++++------
>   1 file changed, 6 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/usb/gadget/f_fastboot.c b/drivers/usb/gadget/f_fastboot.c
> index 07b1681c8a9a..0b3fae564d0a 100644
> --- a/drivers/usb/gadget/f_fastboot.c
> +++ b/drivers/usb/gadget/f_fastboot.c
> @@ -419,11 +419,6 @@ static int fastboot_tx_write_str(const char *buffer)
>   	return fastboot_tx_write(buffer, strlen(buffer));
>   }
>   
> -static void compl_do_reset(struct usb_ep *ep, struct usb_request *req)
> -{
> -	do_reset(NULL, 0, 0, NULL);
> -}
> -
>   static unsigned int rx_bytes_expected(struct usb_ep *ep)
>   {
>   	int rx_remain = fastboot_data_remaining();
> @@ -495,6 +490,12 @@ static void do_bootm_on_complete(struct usb_ep *ep, struct usb_request *req)
>   	do_exit_on_complete(ep, req);
>   }
>   
> +static void compl_do_reset(struct usb_ep *ep, struct usb_request *req)
> +{
> +	do_exit_on_complete(ep, req);
> +	do_reset(NULL, 0, 0, NULL);
> +}
> +
>   #if CONFIG_IS_ENABLED(FASTBOOT_UUU_SUPPORT)
>   static void do_acmd_complete(struct usb_ep *ep, struct usb_request *req)
>   {
> @@ -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:

If Mattijs could have a look, that would be real nice.

If there is no activity in say a week or two, please let me know and 
I'll pick it up via USB tree.

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

* Re: [PATCH] usb: gadget: fastboot: detach usb just before rebooting
  2023-01-04 16:27 ` Marek Vasut
@ 2023-01-05  9:07   ` Mattijs Korpershoek
  0 siblings, 0 replies; 3+ messages in thread
From: Mattijs Korpershoek @ 2023-01-05  9:07 UTC (permalink / raw)
  To: Marek Vasut, Dario Binacchi, u-boot; +Cc: Lukasz Majewski, linux-amarula

On Wed, Jan 04, 2023 at 17:27, Marek Vasut <marex@denx.de> wrote:

> On 1/4/23 17:16, Dario Binacchi 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")
>> Signed-off-by: Dario Binacchi <dario.binacchi@amarulasolutions.com>
>> ---
>> 
>>   drivers/usb/gadget/f_fastboot.c | 12 ++++++------
>>   1 file changed, 6 insertions(+), 6 deletions(-)
>> 
>> diff --git a/drivers/usb/gadget/f_fastboot.c b/drivers/usb/gadget/f_fastboot.c
>> index 07b1681c8a9a..0b3fae564d0a 100644
>> --- a/drivers/usb/gadget/f_fastboot.c
>> +++ b/drivers/usb/gadget/f_fastboot.c
>> @@ -419,11 +419,6 @@ static int fastboot_tx_write_str(const char *buffer)
>>   	return fastboot_tx_write(buffer, strlen(buffer));
>>   }
>>   
>> -static void compl_do_reset(struct usb_ep *ep, struct usb_request *req)
>> -{
>> -	do_reset(NULL, 0, 0, NULL);
>> -}
>> -
>>   static unsigned int rx_bytes_expected(struct usb_ep *ep)
>>   {
>>   	int rx_remain = fastboot_data_remaining();
>> @@ -495,6 +490,12 @@ static void do_bootm_on_complete(struct usb_ep *ep, struct usb_request *req)
>>   	do_exit_on_complete(ep, req);
>>   }
>>   
>> +static void compl_do_reset(struct usb_ep *ep, struct usb_request *req)
>> +{
>> +	do_exit_on_complete(ep, req);
>> +	do_reset(NULL, 0, 0, NULL);
>> +}
>> +
>>   #if CONFIG_IS_ENABLED(FASTBOOT_UUU_SUPPORT)
>>   static void do_acmd_complete(struct usb_ep *ep, struct usb_request *req)
>>   {
>> @@ -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:
>
> If Mattijs could have a look, that would be real nice.

I've answered on v2. Let's continue the discussion there.

>
> If there is no activity in say a week or two, please let me know and 
> I'll pick it up via USB tree.

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

end of thread, other threads:[~2023-01-05  9:07 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-04 16:16 [PATCH] usb: gadget: fastboot: detach usb just before rebooting Dario Binacchi
2023-01-04 16:27 ` Marek Vasut
2023-01-05  9:07   ` Mattijs Korpershoek

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).