Page MenuHomeFreeBSD

virtio_pci_legacy: Use the table BAR and PBA BAR from MSI-X cap
Needs ReviewPublic

Authored by khng300_gmail.com on Sat, Feb 20, 5:39 PM.

Details

Summary

The MSI-X resource shouldn't be assumed to be always on BAR1.
The Virtio v1.1 Spec did not specify that MSI-X table and PBA BAR has to
be BAR1 either.

Reported by: Yuan Rui <number201724@me.com>
MFC after: 2 weeks

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint OK
Unit
No Unit Test Coverage
Build Status
Buildable 37503
Build 34392: arc lint + arc unit

Event Timeline

bryanv requested changes to this revision.Tue, Feb 23, 5:03 AM
This revision now requires changes to proceed.Tue, Feb 23, 5:03 AM
sys/dev/virtio/pci/virtio_pci_legacy.c
234

This error message isn't necessarily correct, and if the MSIX allocs fail, we don't release BAR 0 (both are existing issues before this change).

Moving the MSIX stuff out of vtpci_legacy_alloc_resources() and calling vtpci_legacy_setup_msix() from this function probably fits the existing flow the best, so we can jump to fail to do the cleanup.

  • Moved virtio_legacy_setup_msix to virtio_legacy_attach
  • Moved virtio_legacy_cleanup_msix to virtio_legacy_detach
This revision is now accepted and ready to land.Tue, Feb 23, 1:55 PM

I think this looks fine. Minor nit: I think we tend to use 'teardown' or 'free' more commonly in device drivers rather than 'cleanup'.

This revision is now accepted and ready to land.Thu, Feb 25, 7:59 PM

After testing, this patch runs normally on alibabacloud

This revision now requires review to proceed.Tue, Mar 2, 4:25 PM
In D28817#647763, @jhb wrote:

I think this looks fine. Minor nit: I think we tend to use 'teardown' or 'free' more commonly in device drivers rather than 'cleanup'.

Changed to match our naming convention.