Page MenuHomeFreeBSD

LinuxKPI: Support lazy BAR allocation
ClosedPublic

Authored by jrtc27 on Oct 10 2021, 7:10 PM.
Tags
None
Referenced Files
F103598955: D32447.diff
Tue, Nov 26, 11:36 PM
Unknown Object (File)
Thu, Nov 14, 12:05 PM
Unknown Object (File)
Wed, Nov 13, 12:33 PM
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

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
rS FreeBSD src repository - subversion
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 42058
Build 38946: arc lint + arc unit

Event Timeline

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

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
637

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