Page MenuHomeFreeBSD

LinuxKPI: Support lazy BAR allocation
ClosedPublic

Authored by jrtc27 on Oct 10 2021, 7:10 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
R10 FreeBSD src repository
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

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

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
677

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