All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mattijs Korpershoek <mkorpershoek@kernel.org>
To: Patrice Chotard <patrice.chotard@foss.st.com>,
	u-boot@lists.u-boot-project.org
Cc: Lukasz Majewski <lukma@denx.de>,
	Marek Vasut <marek.vasut+usb@mailbox.org>,
	Tom Rini <trini@konsulko.com>,
	Patrice Chotard <patrice.chotard@foss.st.com>
Subject: Re: [PATCH 2/2] usb: gadget: f_mass_storage: Optimize schedule() call
Date: Mon, 07 Sep 2026 11:07:04 +0200	[thread overview]
Message-ID: <87fqzltop3.fsf@kernel.org> (raw)
In-Reply-To: <20260817-move_schedule_inside_sleep_thread-v1-2-0023194e8c47@foss.st.com>

Hi Patrice,

Thank you for the patch and sorry for the review delays.

On Mon, Aug 17, 2026 at 17:41, Patrice Chotard <patrice.chotard@foss.st.com> wrote:

> schedule was added in sleep_thread() by commit 4b6a3e860878
> ("usb: gadget: f_mass_storage: Add schedule() in sleep_thread()").
> to ensure that watchdog is still reset periodically even on platform
> that doesn't implement g_dnl_board_usb_cable_connected() and in case USB
> cable is not connected.
>
> Instead of calling schedule() for each for() loop iteration, call
> schedule() only in case g_dnl_board_usb_cable_connected() is not
> overloaded, in this particular case, g_dnl_board_usb_cable_connected()'s
> return value is -EOPNOTSUPP.
>
> Signed-off-by: Patrice Chotard <patrice.chotard@foss.st.com>
> ---
>  drivers/usb/gadget/f_mass_storage.c | 7 +++++--
>  1 file changed, 5 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/usb/gadget/f_mass_storage.c b/drivers/usb/gadget/f_mass_storage.c
> index 621852080e2..f467693d2cb 100644
> --- a/drivers/usb/gadget/f_mass_storage.c
> +++ b/drivers/usb/gadget/f_mass_storage.c
> @@ -651,6 +651,7 @@ static void busy_indicator(void)
>  static int sleep_thread(struct fsg_common *common)
>  {
>  	int i = 0, k = 0;
> +	int ret;
>  
>  	/* Wait until a signal arrives or we are woken up */
>  	for (;;) {
> @@ -673,13 +674,15 @@ static int sleep_thread(struct fsg_common *common)
>  				return -EPIPE;
>  
>  			/* Check cable connection */
> -			if (!g_dnl_board_usb_cable_connected())
> +			ret = g_dnl_board_usb_cable_connected();
> +			if (!ret)
>  				return -EIO;
> +			if (ret == -EOPNOTSUPP)
> +				schedule();

What happens on boards that override g_dnl_board_usb_cable_connected()
that return a positive value?

Per my understanding, schedule() will never be called, and the watchdog
will be triggered at some point, no?

>  
>  			k = 0;
>  		}
>  
> -		schedule();
>  		dm_usb_gadget_handle_interrupts(udcdev);
>  	}
>  	common->thread_wakeup_needed = 0;
>
> -- 
> 2.43.0

  reply	other threads:[~2026-09-07  9:07 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-17 15:41 [PATCH 0/2] usb: gdaget: f_mass_storage: various fixes Patrice Chotard
2026-08-17 15:41 ` [PATCH 1/2] usb: gadget: f_mass_storage: Remove useless rc variable Patrice Chotard
2026-08-17 15:43   ` Heinrich Schuchardt
2026-08-17 22:45   ` Marek Vasut
2026-09-07  8:53   ` Mattijs Korpershoek
2026-08-17 15:41 ` [PATCH 2/2] usb: gadget: f_mass_storage: Optimize schedule() call Patrice Chotard
2026-09-07  9:07   ` Mattijs Korpershoek [this message]
2026-09-11 12:38     ` Patrice CHOTARD

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87fqzltop3.fsf@kernel.org \
    --to=mkorpershoek@kernel.org \
    --cc=lukma@denx.de \
    --cc=marek.vasut+usb@mailbox.org \
    --cc=patrice.chotard@foss.st.com \
    --cc=trini@konsulko.com \
    --cc=u-boot@lists.u-boot-project.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.