Page MenuHomeFreeBSD

linuxkpi: handle ARI
ClosedPublic

Authored by kib on Jan 4 2021, 9:35 PM.
Tags
None
Referenced Files
Unknown Object (File)
Mar 29 2024, 2:21 AM
Unknown Object (File)
Feb 10 2024, 9:37 PM
Unknown Object (File)
Feb 3 2024, 8:15 AM
Unknown Object (File)
Dec 27 2023, 4:26 PM
Unknown Object (File)
Dec 23 2023, 12:34 AM
Unknown Object (File)
Dec 21 2023, 6:27 PM
Unknown Object (File)
Nov 26 2023, 1:48 PM
Unknown Object (File)
Nov 9 2023, 1:22 PM
Subscribers

Details

Summary

Stop trying to manually calculate RID, which cannot be done correctly by PCI_DEVFN(). Use PCI_GET_RID() method instead.

Do not use pci_find_dbsf() to go from the linux pci_dev to freebsd device_t. First, device is readily available as dev.bsddev. Second, using pci_find_dbsf() fails for ARI-enabled functions with large function numbers, because PCI_SLOT()/PCI_FUNC() are for non-ARI.

Sponsored by: Mellanox Technologies/NVidia Networking

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped

Event Timeline

kib requested review of this revision.Jan 4 2021, 9:35 PM
sys/compat/linuxkpi/common/src/linux_pci.c
271

Why do we use the parent parent here ?

sys/compat/linuxkpi/common/src/linux_pci.c
271

PCI_GET_ID() requires the first arg to be bus, and ends up as the PCIB_GET_RID() call on the parent of the bus. Hans explained to me that in drm case, dev is some pseudo-device set to be child of the normally enumerated PCI device.

If this is correct, then parent-parent there just re-aligns the things to be same for drm and non-drm. I do not think it is enough to set ivars to have GET_RID() working.

Can you test drm with this patch, please ?

sys/compat/linuxkpi/common/src/linux_pci.c
271

That will resolve to the pciN device for drm and not pcibN I think.

pcib0
  pci0
    hostb0
    vgapci0
      drmn0

I'll test today and report the result.

sys/compat/linuxkpi/common/src/linux_pci.c
271

I expect that the call needs the pair pci0/vgapci0. Then pci_get_id_method() does PCIB_GET_ID(device_get_parent(pci0) == pcib0, vgapci0).

But again, this is all from the code reading. Testing and some iterations to make it work will be much appreciated.

@kib We have a special flag for the DRM case. See pdrv->isdrm .

@kib We have a special flag for the DRM case. See pdrv->isdrm .

That's what is used here.

This revision is now accepted and ready to land.Jan 6 2021, 2:30 PM
bz added a subscriber: bz.

Looks ok to me; I don't particularly like the special cases but it seems fine.

In D27960#625635, @bz wrote:

Looks ok to me; I don't particularly like the special cases but it seems fine.

Note that the case was already there. I just handled it in my change.

This revision was automatically updated to reflect the committed changes.