Page MenuHomeFreeBSD

linuxkpi: Add `pci_map_rom()` and `pci_unmap_rom()`
AcceptedPublic

Authored by dumbbell on Jun 14 2026, 9:13 AM.
Referenced Files
F171191201: D57573.diff
Wed, Sep 9, 9:44 AM
Unknown Object (File)
Sat, Sep 5, 12:18 PM
Unknown Object (File)
Sat, Sep 5, 7:41 AM
Unknown Object (File)
Sat, Sep 5, 6:43 AM
Unknown Object (File)
Fri, Sep 4, 7:01 PM
Unknown Object (File)
Thu, Sep 3, 5:33 AM
Unknown Object (File)
Wed, Sep 2, 10:32 AM
Unknown Object (File)
Wed, Sep 2, 10:18 AM
Subscribers

Details

Reviewers
bz
Group Reviewers
linuxkpi
Summary

They were already defined as macros in various places in DRM drivers, aliasing the vga_pci_map_bios() and vga_pci_unmap_bios() functions. Let's move them to linuxkpi and avoid copies everywhere.

Because they use the vga_pci code internally, pci_map_rom() checks whether the given device is a video card. If it is not, it logs a "TODO" and returns NULL.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped

Event Timeline

bz added inline comments.
sys/compat/linuxkpi/common/include/linux/pci.h
897

What's the deal with this LINUXKPI_VERSION check? pci_map_rom() is ancient.

If you wnat to guard against older drm versions (I do not know how it was defined there), would a #ifndef pci_map_rom ... work?

Indeed, perhaps we don’t neet it.

I already changed my WIP drm-kmod branch to do this:

#if defined(__FreeBSD__) && !defined(pci_map_rom)

(before, it was just checking defined(__FreeBSD__)).

So backporting this check to all supported drm-kmod branches should be enough.

Indeed, perhaps we don’t neet it.

I already changed my WIP drm-kmod branch to do this:

#if defined(__FreeBSD__) && !defined(pci_map_rom)

(before, it was just checking defined(__FreeBSD__)).

So backporting this check to all supported drm-kmod branches should be enough.

Do we need the !defined(FreeBSD) check?
We are always FreeBSD in LinuxKPI. In drivers I do that check too to mark FreeBSD specifics.

Can you update the patch?

Remove the #if LINUXKPI_VERSION ... check as suggested by @bz.

Aehm, I was still ecxpecting an #ifdef !defined(pci_map_rom) check (just no FreeBSD or LINUXKPI_VERSION)

In drm-kmod, pci_map_rom() was defined as a macro inside C files, after all #include, so such a check won’t prevent a build failure in this specific case. I guess there are no other consumers of this API. Do you think it’s still useful to add it?

In drm-kmod, pci_map_rom() was defined as a macro inside C files, after all #include, so such a check won’t prevent a build failure in this specific case. I guess there are no other consumers of this API. Do you think it’s still useful to add it?

Oh doh! And that three times. Now I understand why you had these complicated guards. But even with those we'd have to touch drm-kmod then?

So would the proper solution be to touch all drm-kmod branches and edit all the various instances with an #ifdef check first for both of them, then add the one here, and then at least in master remove the FreeBSD-specific code?

Would certainly cleanup drm-kmod that way; will we ever need this anywhere else? I don't know. There don't seem to be hundreds of consumers in Linux of it. If you think reducing diff to upstream in drm is worth it I am still game.

That was fast in drm-kmod :)

This revision is now accepted and ready to land.Mon, Sep 7, 10:37 PM