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)
Thu, Apr 18, 2:11 PM
Unknown Object (File)
Tue, Apr 16, 10:27 AM
Unknown Object (File)
Fri, Mar 29, 3:25 PM
Unknown Object (File)
Feb 5 2024, 5:34 PM
Unknown Object (File)
Dec 30 2023, 8:38 PM
Unknown Object (File)
Dec 27 2023, 7:27 AM
Unknown Object (File)
Dec 20 2023, 4:46 AM
Unknown Object (File)
Dec 12 2023, 2:12 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
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