From: "Luis Claudio R. Goncalves" <lgoncalv@redhat.com>
To: Jillian Donahue <jilliandonahue58@gmail.com>
Cc: "Sebastian Andrzej Siewior" <bigeasy@linutronix.de>,
"Petr Tesařík" <petesarik@suse.de>,
linux-rt-users@vger.kernel.org
Subject: Re: Spinlock in f_midi_transmit causing kernel crash
Date: Mon, 3 Feb 2025 09:45:24 -0300 [thread overview]
Message-ID: <Z6C6ZHQh3jc_iJLk@uudg.org> (raw)
In-Reply-To: <CAArt=LgTQHaHmBQZkY3APwuRAH=f-4ABW-8f0joQs3JLocZarA@mail.gmail.com>
On Fri, Jan 31, 2025 at 12:08:01PM -0700, Jillian Donahue wrote:
> Thanks again for your time. Here is the request patch:
Sebastian, do you envision this as a patch to be carried by v5.10-rt or a
patch to stable v5.10?
In any case, Jillian, would you mind adding a description to your patch? No
matter who will take the patch (Greg or myself), a description is required.
One or two paragraphs summarizing the problem and/or the solution.
Thanks in advance!
Luis
> From 1577bf36766218a1902ac92377dbc51798f2e4a0 Mon Sep 17 00:00:00 2001
> From: Jill Donahue <jilliandonahue58@gmail.com>
> Date: Fri, 31 Jan 2025 11:39:57 -0700
> Subject: [PATCH] f_midi_complete to call tasklet_hi_schedule
>
> ---
> drivers/usb/gadget/function/f_midi.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/usb/gadget/function/f_midi.c
> b/drivers/usb/gadget/function/f_midi.c
> index 837fcdfa3..37d438e5d 100644
> --- a/drivers/usb/gadget/function/f_midi.c
> +++ b/drivers/usb/gadget/function/f_midi.c
> @@ -283,7 +283,7 @@ f_midi_complete(struct usb_ep *ep, struct usb_request *req)
> /* Our transmit completed. See if there's more to go.
> * f_midi_transmit eats req, don't queue it again. */
> req->length = 0;
> - f_midi_transmit(midi);
> + tasklet_hi_schedule(&midi->tasklet);
> return;
> }
> break;
> --
> 2.25.1
>
> Jill
>
> On Thu, Jan 30, 2025 at 12:50 AM Sebastian Andrzej Siewior
> <bigeasy@linutronix.de> wrote:
> >
> > On 2025-01-29 14:59:19 [-0700], Jillian Donahue wrote:
> > > > So a simple "tasklet_hi_schedule(&midi->tasklet);" instead of "f_midi_transmit(midi)" in f_midi_complete() might do the trick.
> > >
> > > This fixes the problem - do you have any insight to how this worked in
> > > the first place? Trying to understand the change.
> >
> > There are possibilities. The problem is that you send a packet and it
> > completes the same moment and the completion callback is invoked which
> > deadlocks.
> >
> > Now:
> > - PREEMPT_RT may have moved the timing a bit (makes it behave a bit
> > different or simply make a UP device behave like a SMP one) to the
> > point that it sees the completion of the request where it did not
> > before. So does it occur without PREEMPT_RT?
> >
> > - It never did work in this combination even without PREEMPT_RT. The
> > driver (f_midi) was never tested with the USB device controller you
> > have and the one it was tested with behaves differently so the
> > recursion never occurred.
> >
> > - It is an old driver (f_midi). It was never tested on SMP or with
> > enabled lock testing. On UP spinlocks end up almost as NOPs so a
> > deadlock (as in this case) will not be observed.
> >
> > Either way I would blame f_midi here.
> > Once you have the pieces together, mind sending a patch?
> >
> > Sebastian
>
---end quoted text---
next prev parent reply other threads:[~2025-02-03 12:45 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-15 4:05 Spinlock in f_midi_transmit causing kernel crash Jillian Donahue
2025-01-23 13:23 ` Petr Tesařík
2025-01-24 22:21 ` Jillian Donahue
2025-01-29 10:39 ` Sebastian Andrzej Siewior
2025-01-29 21:59 ` Jillian Donahue
2025-01-30 7:50 ` Sebastian Andrzej Siewior
2025-01-31 19:08 ` Jillian Donahue
2025-02-03 12:45 ` Luis Claudio R. Goncalves [this message]
2025-02-03 13:22 ` Sebastian Andrzej Siewior
2025-02-03 17:50 ` Jillian Donahue
2025-02-06 12:05 ` Sebastian Andrzej Siewior
2025-02-06 18:13 ` Jillian Donahue
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=Z6C6ZHQh3jc_iJLk@uudg.org \
--to=lgoncalv@redhat.com \
--cc=bigeasy@linutronix.de \
--cc=jilliandonahue58@gmail.com \
--cc=linux-rt-users@vger.kernel.org \
--cc=petesarik@suse.de \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox