[PATCH v4 00/22] usb/xhci and usb/msd improvements and tests

Nicholas Piggin posted 22 patches 6 months, 2 weeks ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20250502033047.102465-1-npiggin@gmail.com
Maintainers: Paolo Bonzini <pbonzini@redhat.com>, "Michael S. Tsirkin" <mst@redhat.com>, Marcel Apfelbaum <marcel.apfelbaum@gmail.com>, Fabiano Rosas <farosas@suse.de>, Laurent Vivier <lvivier@redhat.com>
hw/usb/hcd-xhci-pci.h           |    9 +
hw/usb/hcd-xhci.h               |  237 +++++++
include/hw/pci/pci_ids.h        |    1 +
include/hw/usb/msd.h            |   21 +-
include/hw/usb/xhci.h           |    1 +
hw/usb/dev-storage.c            |  532 +++++++++++-----
hw/usb/hcd-xhci-pci.c           |  118 +++-
hw/usb/hcd-xhci-ti.c            |   77 +++
hw/usb/hcd-xhci.c               |  527 ++++++---------
tests/qtest/usb-hcd-xhci-test.c | 1056 ++++++++++++++++++++++++++++++-
hw/usb/Kconfig                  |    5 +
hw/usb/meson.build              |    1 +
hw/usb/trace-events             |   11 +-
13 files changed, 2043 insertions(+), 553 deletions(-)
create mode 100644 hw/usb/hcd-xhci-ti.c
[PATCH v4 00/22] usb/xhci and usb/msd improvements and tests
Posted by Nicholas Piggin 6 months, 2 weeks ago
This is merged from two series now because code especially the test
cases have started to depend on one another.

The series are "usb/xhci: TR NOOP, TI HCD device, more qtests" from:
https://lore.kernel.org/qemu-devel/20250411080431.207579-1-npiggin@gmail.com/

And "usb/msd: Permit relaxed ordering of IN packets" from:
https://lore.kernel.org/qemu-devel/20250411080431.207579-1-npiggin@gmail.com/

The qtests also depends on the qtest fixes:
https://lore.kernel.org/qemu-devel/20250502030446.88310-1-npiggin@gmail.com/

This series adds better support qtests support for the xhci controller,
adds support for the "TR NOOP" command used by AIX, and adds a new USB
controller model from TI that PowerVM and AIX use.

It also permits relaxed ordering of USB mass-storage
packets from the host, as allowed by the usbmassbulk 1.0 spec, but
not usually seen in drivers. AIX drivers do require this ordering.

Since previous posting the usb/msd series had some changes that Phil
noted. But otherwise the qemu code is mostly unchanged. The qtest code
has had some big changes, cleaned up a lot and started adding some USB
Mass Storage Device tests including one which verifies the relaxed
ordering change. It would be nice if we could plug these into more
comprehensive SCSI tests, but so far it mainly just tests the USB MSD
protocol.

Nicholas Piggin (22):
  hw/usb/xhci: Move HCD constants to a header and add register constants
  hw/usb/xhci: Rename and move HCD register region constants to header
  tests/qtest/xhci: test the qemu-xhci device
  tests/qtest/xhci: Add controller and device setup and ring tests
  tests/qtest/xhci: Add basic USB Mass Storage tests
  hw/usb/xhci: Support TR NOOP commands
  tests/qtest/xhci: add a test for TR NOOP commands
  tests/qtest/usb-hcd-xhci: Deliver msix interrupts
  hw/usb/hcd-xhci-pci: Make PCI device more configurable
  hw/usb/hcd-xhci-pci: Add TI TUSB73X0 XHCI controller model
  usb/msd: Split in and out packet handling
  usb/msd: Ensure packet structure layout is correct
  usb/msd: Improved handling of mass storage reset
  usb/msd: Improve packet validation error logging
  usb/msd: Allow CBW packet size greater than 31
  usb/msd: Split async packet tracking into data and csw
  usb/msd: Add some additional assertions
  usb/msd: Rename mode to cbw_state, and tweak names
  usb/msd: Add NODATA CBW state
  usb/msd: Permit a DATA-IN or CSW packet before CBW packet
  tests/qtest/xhci: Test USB Mass Storage relaxed CSW order
  usb/msd: Add more tracing

 hw/usb/hcd-xhci-pci.h           |    9 +
 hw/usb/hcd-xhci.h               |  237 +++++++
 include/hw/pci/pci_ids.h        |    1 +
 include/hw/usb/msd.h            |   21 +-
 include/hw/usb/xhci.h           |    1 +
 hw/usb/dev-storage.c            |  532 +++++++++++-----
 hw/usb/hcd-xhci-pci.c           |  118 +++-
 hw/usb/hcd-xhci-ti.c            |   77 +++
 hw/usb/hcd-xhci.c               |  527 ++++++---------
 tests/qtest/usb-hcd-xhci-test.c | 1056 ++++++++++++++++++++++++++++++-
 hw/usb/Kconfig                  |    5 +
 hw/usb/meson.build              |    1 +
 hw/usb/trace-events             |   11 +-
 13 files changed, 2043 insertions(+), 553 deletions(-)
 create mode 100644 hw/usb/hcd-xhci-ti.c

-- 
2.47.1
Re: [PATCH v4 00/22] usb/xhci and usb/msd improvements and tests
Posted by Nicholas Piggin 6 months, 2 weeks ago
On Fri May 2, 2025 at 1:30 PM AEST, Nicholas Piggin wrote:
> This is merged from two series now because code especially the test
> cases have started to depend on one another.

Question for the list, hw/usb/* is marked orphan. I don't have the
bandwidth to take it on. There's one or two other little things that
need to be taken, e.g.,

https://lore.kernel.org/qemu-devel/20250405140002.3537411-1-linux@roeck-us.net/

Bernhard and Phil Dennis-Jordan have been doing some good work and
reviews on host controllers and Kevin on usb-storage. Any interest
to maintain it or do odd fixes? I suppose most are in the same boat
as me.

I would like to get this series merged, but I realize the mass storage
change to relax packet ordering of a command particularly is quite
complicated and under-reviewed.

Would there be objection if I made a pull request for Guenter's
patches, the hcd stuff, the qtests, and some of the easier / reviewed
bits of msd?

Thanks,
Nick
Re: [PATCH v4 00/22] usb/xhci and usb/msd improvements and tests
Posted by Kevin Wolf 6 months, 2 weeks ago
Am 05.05.2025 um 04:03 hat Nicholas Piggin geschrieben:
> On Fri May 2, 2025 at 1:30 PM AEST, Nicholas Piggin wrote:
> > This is merged from two series now because code especially the test
> > cases have started to depend on one another.
> 
> Question for the list, hw/usb/* is marked orphan. I don't have the
> bandwidth to take it on. There's one or two other little things that
> need to be taken, e.g.,
> 
> https://lore.kernel.org/qemu-devel/20250405140002.3537411-1-linux@roeck-us.net/
> 
> Bernhard and Phil Dennis-Jordan have been doing some good work and
> reviews on host controllers and Kevin on usb-storage. Any interest
> to maintain it or do odd fixes? I suppose most are in the same boat
> as me.

The changes I made (or merged) were mostly for the external interfaces
of the device. Initialising the qdev device, setting properties, passing
them to the SCSI device etc. It's been a while since I last looked at
some actual USB stuff (and not in the context of QEMU), so I'm not
necessarily the natural reviewer/maintainer for this part of it. (On the
other hand, who is if Gerd doesn't have the time for it any more?)

> I would like to get this series merged, but I realize the mass storage
> change to relax packet ordering of a command particularly is quite
> complicated and under-reviewed.

I can try to find the time to have a look at the series, but given that
I'll have to familiarise myself with the specs again, it might take a
while.

> Would there be objection if I made a pull request for Guenter's
> patches, the hcd stuff, the qtests, and some of the easier / reviewed
> bits of msd?

That makes sense to me. I suppose I can also give a quick review for the
initial part of the msd patches, at lot of which seems to be more or
less just refactoring.

Kevin
Re: [PATCH v4 00/22] usb/xhci and usb/msd improvements and tests
Posted by Peter Maydell 6 months, 1 week ago
On Mon, 5 May 2025 at 10:03, Kevin Wolf <kwolf@redhat.com> wrote:
>
> Am 05.05.2025 um 04:03 hat Nicholas Piggin geschrieben:
> > I would like to get this series merged, but I realize the mass storage
> > change to relax packet ordering of a command particularly is quite
> > complicated and under-reviewed.
>
> I can try to find the time to have a look at the series, but given that
> I'll have to familiarise myself with the specs again, it might take a
> while.
>
> > Would there be objection if I made a pull request for Guenter's
> > patches, the hcd stuff, the qtests, and some of the easier / reviewed
> > bits of msd?
>
> That makes sense to me. I suppose I can also give a quick review for the
> initial part of the msd patches, at lot of which seems to be more or
> less just refactoring.

I've now reviewed the hw/usb/xhci patches, so I think you
now have reviews for everything here except the tests/qtest/
patches (3, 4, 5, 7, 8, 21).

-- PMM
Re: [PATCH v4 00/22] usb/xhci and usb/msd improvements and tests
Posted by Fabiano Rosas 6 months, 1 week ago
Peter Maydell <peter.maydell@linaro.org> writes:

> On Mon, 5 May 2025 at 10:03, Kevin Wolf <kwolf@redhat.com> wrote:
>>
>> Am 05.05.2025 um 04:03 hat Nicholas Piggin geschrieben:
>> > I would like to get this series merged, but I realize the mass storage
>> > change to relax packet ordering of a command particularly is quite
>> > complicated and under-reviewed.
>>
>> I can try to find the time to have a look at the series, but given that
>> I'll have to familiarise myself with the specs again, it might take a
>> while.
>>
>> > Would there be objection if I made a pull request for Guenter's
>> > patches, the hcd stuff, the qtests, and some of the easier / reviewed
>> > bits of msd?
>>
>> That makes sense to me. I suppose I can also give a quick review for the
>> initial part of the msd patches, at lot of which seems to be more or
>> less just refactoring.
>
> I've now reviewed the hw/usb/xhci patches, so I think you
> now have reviews for everything here except the tests/qtest/
> patches (3, 4, 5, 7, 8, 21).
>

I'll get to them this week. It'd be nice to see the new version of the
pending dependency series that's mentioned in the cover letter. For
these subsystems I'm not familiar with, most of my qtest review will
rely on putting the series through asan and tests on a loaded
machine. If there's latent bugs in qtest, it gets super confusing.