Page MenuHomeFreeBSD

LinuxKPI: Support lazy BAR allocation
ClosedPublic

Authored by jrtc27 on Oct 10 2021, 7:10 PM.
Tags
None
Referenced Files
Unknown Object (File)
Oct 4 2024, 10:43 AM
Unknown Object (File)
Oct 4 2024, 6:30 AM
Unknown Object (File)
Oct 1 2024, 4:59 AM
Unknown Object (File)
Sep 29 2024, 6:50 PM
Unknown Object (File)
Sep 27 2024, 11:21 PM
Unknown Object (File)
Sep 27 2024, 3:51 AM
Unknown Object (File)
Sep 26 2024, 5:22 AM
Unknown Object (File)
Sep 21 2024, 8:44 AM

Details

Summary

Linux KPIs like pci_resource_start/len assume that BARs have been
allocated, but FreeBSD lazily allocates BARs if it cannot allocate the
firmware-allocated BARs. Thus using the Linux KPIs must force allocation
of the BARs rather than returning 0 for the start and length, which can
crash drm-kmod drivers that assume the BARs are valid. This is needed
for the AMDGPU driver to be able to attach on SiFive's HiFive Unmatched.

MFC after: 1 week

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

hselasky added inline comments.
sys/compat/linuxkpi/common/src/linux_pci.c
678

Maybe put ()'s around "pdev->pdrv != NULL && pdev->pdrv->isdrm".

This revision is now accepted and ready to land.Oct 11 2021, 9:27 AM

You also should bump the __FreeBSD_version in sys/sys/param.h alongside this commit.

sys/compat/linuxkpi/common/include/linux/pci.h
318

With regards to MFC-ing it would be better to make two different inline functions for getting the "rle". One as-is, and one with reserve_bar always set true. Then you don't change any existing APIs!

This revision now requires changes to proceed.Oct 11 2021, 9:34 AM
hselasky added inline comments.
sys/compat/linuxkpi/common/include/linux/pci.h
318

Nevermind. This is apparently all inline functions.

This revision is now accepted and ready to land.Oct 11 2021, 9:35 AM
This revision was automatically updated to reflect the committed changes.
sys/compat/linuxkpi/common/src/linux_pci.c
678

Realise I didn't reply to this, but this is the exact style used elsewhere when checking isdrm