From: Guenter Roeck <linux@roeck-us.net>
To: Gerd Hoffmann <kraxel@redhat.com>
Cc: "Paolo Bonzini" <pbonzini@redhat.com>,
"Philippe Mathieu-Daudé" <philmd@redhat.com>,
qemu-devel@nongnu.org,
"Marc-André Lureau" <marcandre.lureau@redhat.com>
Subject: Re: [Qemu-devel] [PATCH] ehci: Ensure that device is not NULL before calling usb_ep_get
Date: Fri, 2 Aug 2019 10:28:31 -0700 [thread overview]
Message-ID: <20190802172831.GA3152@roeck-us.net> (raw)
In-Reply-To: <20190802164626.GA12934@roeck-us.net>
On Fri, Aug 02, 2019 at 09:46:26AM -0700, Guenter Roeck wrote:
> On Fri, Aug 02, 2019 at 04:11:49PM +0200, Gerd Hoffmann wrote:
> > On Wed, Jul 31, 2019 at 01:08:50PM +0200, Philippe Mathieu-Daudé wrote:
> > > On 7/30/19 7:45 PM, Guenter Roeck wrote:
> > > > The following assert is seen once in a while while resetting the
> > > > Linux kernel.
> > > >
> > > > qemu-system-x86_64: hw/usb/core.c:734: usb_ep_get:
> > > > Assertion `dev != NULL' failed.
> > > >
> > > > The call to usb_ep_get() originates from ehci_execute().
> > > > Analysis and debugging shows that p->queue->dev can indeed be NULL
> > > > in this function. Add check for this condition and return an error
> > > > if it is seen.
> > >
> > > Your patch is not wrong as it corrects your case, but I wonder why we
> > > get there. This assert seems to have catched a bug.
> >
> > https://bugzilla.redhat.com//show_bug.cgi?id=1715801 maybe.
> >
> > > Gerd, shouldn't we call usb_packet_cleanup() in ehci_reset() rather than
> > > ehci_finalize()? Then we shouldn't need this patch.
> >
> > The two ehci_queues_rip_all() calls in ehci_reset() should clean up everything
> > properly.
> >
> > Can you try the patch below to see whenever a ehci_find_device failure is the
> > root cause?
> >
> > thanks,
> > Gerd
> >
> > diff --git a/hw/usb/hcd-ehci.c b/hw/usb/hcd-ehci.c
> > index 62dab0592fa2..2b0a57772ed5 100644
> > --- a/hw/usb/hcd-ehci.c
> > +++ b/hw/usb/hcd-ehci.c
> > @@ -1644,6 +1644,10 @@ static EHCIQueue *ehci_state_fetchqh(EHCIState *ehci, int async)
> > q->dev = ehci_find_device(q->ehci,
> > get_field(q->qh.epchar, QH_EPCHAR_DEVADDR));
> > }
> > + if (q->dev == NULL) {
> > + fprintf(stderr, "%s: device %d not found\n", __func__,
> > + get_field(q->qh.epchar, QH_EPCHAR_DEVADDR));
> > + }
>
> I had tried that, but this does happen as standard behavior for some
> architectures (I didn't write down where exactly since I thought it
> must be normal). But, sure, I'll add a log message.
>
With the log message added, I see it a lot when booting riscv64 images
from usb-ehci.
ehci_state_fetchqh: device 0 not found
It looks like this happens for each usb access (a whopping 800+ times
for a simple boot test). So it is definitely a very common condition.
The relevant qemu command line is something like
-usb -device usb-ehci,id=ehci -device usb-storage,bus=ehci.0,drive=d0 \
-drive file=rootfs.ext2,if=none,id=d0,format=raw
The image works fine otherwise, so I thought that the condition is normal.
Guenter
next prev parent reply other threads:[~2019-08-02 17:29 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-07-30 17:45 [Qemu-devel] [PATCH] ehci: Ensure that device is not NULL before calling usb_ep_get Guenter Roeck
2019-07-31 11:08 ` Philippe Mathieu-Daudé
2019-07-31 21:11 ` Guenter Roeck
2019-08-02 14:11 ` Gerd Hoffmann
2019-08-02 16:46 ` Guenter Roeck
2019-08-02 17:28 ` Guenter Roeck [this message]
2019-08-06 13:23 ` Guenter Roeck
2019-08-13 11:42 ` Gerd Hoffmann
2019-08-14 14:41 ` Guenter Roeck
2019-08-20 15:38 ` Guenter Roeck
2019-08-21 8:54 ` Gerd Hoffmann
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=20190802172831.GA3152@roeck-us.net \
--to=linux@roeck-us.net \
--cc=kraxel@redhat.com \
--cc=marcandre.lureau@redhat.com \
--cc=pbonzini@redhat.com \
--cc=philmd@redhat.com \
--cc=qemu-devel@nongnu.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.