git: 33595d4ae01c - main - linuxkpi: Add `pci_map_rom()` and `pci_unmap_rom()`
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Wed, 09 Sep 2026 20:34:39 UTC
The branch main has been updated by dumbbell:
URL: https://cgit.FreeBSD.org/src/commit/?id=33595d4ae01c10c436a83e7f5afd2c07a7fbd2c5
commit 33595d4ae01c10c436a83e7f5afd2c07a7fbd2c5
Author: Jean-Sébastien Pédron <dumbbell@FreeBSD.org>
AuthorDate: 2026-06-12 10:24:02 +0000
Commit: Jean-Sébastien Pédron <dumbbell@FreeBSD.org>
CommitDate: 2026-09-09 20:01:30 +0000
linuxkpi: Add `pci_map_rom()` and `pci_unmap_rom()`
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.
Reviewed by: bz
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D57573
---
sys/compat/linuxkpi/common/include/linux/pci.h | 5 +++++
sys/compat/linuxkpi/common/src/linux_pci.c | 27 ++++++++++++++++++++++++++
2 files changed, 32 insertions(+)
diff --git a/sys/compat/linuxkpi/common/include/linux/pci.h b/sys/compat/linuxkpi/common/include/linux/pci.h
index 8cd52707a7bd..12ca790f8811 100644
--- a/sys/compat/linuxkpi/common/include/linux/pci.h
+++ b/sys/compat/linuxkpi/common/include/linux/pci.h
@@ -892,6 +892,11 @@ pci_reset_function(struct pci_dev *pdev)
#define pci_unmap_len dma_unmap_len
#define pci_unmap_len_set dma_unmap_len_set
+void *linuxkpi_pci_map_rom(struct pci_dev *pdev, size_t *size);
+void linuxkpi_pci_unmap_rom(struct pci_dev *pdev, void *rom);
+#define pci_map_rom(pdev, size) linuxkpi_pci_map_rom(pdev, size)
+#define pci_unmap_rom(pdev, rom) linuxkpi_pci_unmap_rom(pdev, rom)
+
typedef unsigned int __bitwise pci_channel_state_t;
typedef unsigned int __bitwise pci_ers_result_t;
diff --git a/sys/compat/linuxkpi/common/src/linux_pci.c b/sys/compat/linuxkpi/common/src/linux_pci.c
index 44082e6ecaa6..c1ab63b6c902 100644
--- a/sys/compat/linuxkpi/common/src/linux_pci.c
+++ b/sys/compat/linuxkpi/common/src/linux_pci.c
@@ -1663,6 +1663,33 @@ pci_device_is_present(struct pci_dev *pdev)
return (bus_child_present(dev));
}
+void *
+linuxkpi_pci_map_rom(struct pci_dev *pdev, size_t *size)
+{
+ device_t dev;
+
+ dev = pdev->dev.bsddev;
+
+ if (pci_get_class(dev) != PCIC_DISPLAY &&
+ (pci_get_class(dev) != PCIC_OLD ||
+ pci_get_subclass(dev) != PCIS_OLD_VGA)) {
+ pr_debug("%s: TODO\n", __func__);
+ return (NULL);
+ }
+
+ return (vga_pci_map_bios(device_get_parent(dev), size));
+}
+
+void
+linuxkpi_pci_unmap_rom(struct pci_dev *pdev, void *rom)
+{
+ device_t dev;
+
+ dev = pdev->dev.bsddev;
+
+ vga_pci_unmap_bios(device_get_parent(dev), rom);
+}
+
CTASSERT(sizeof(dma_addr_t) <= sizeof(uint64_t));
struct linux_dma_obj {