git: de8bc3aad7f1 - stable/15 - linuxkpi: Define `PCI_POSSIBLE_ERROR()` macro
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Wed, 22 Apr 2026 21:08:03 UTC
The branch stable/15 has been updated by bz:
URL: https://cgit.FreeBSD.org/src/commit/?id=de8bc3aad7f1b8eff5258b16e67bd2cc32275e20
commit de8bc3aad7f1b8eff5258b16e67bd2cc32275e20
Author: Jean-Sébastien Pédron <dumbbell@FreeBSD.org>
AuthorDate: 2025-08-09 16:14:05 +0000
Commit: Bjoern A. Zeeb <bz@FreeBSD.org>
CommitDate: 2026-04-22 20:56:53 +0000
linuxkpi: Define `PCI_POSSIBLE_ERROR()` macro
It comes with `PCI_ERROR_RESPONSE` and `PCI_SET_ERROR_RESPONSE()` but we
don't use them so far. Therefore `PCI_POSSIBLE_ERROR()` will always
reture false.
As written in the comment, this macro is a bit weird given the Linux
`pci_read_*() functions can return an error code separately from the
read value.
The `PCI_POSSIBLE_ERROR()` macro started to be used by the amdgpu DRM
driver in Linux 6.10.
Reviewed by: emaste
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D54487
(cherry picked from commit ace666bd21a204c62807f2c899402a7dc9ab161a)
---
sys/compat/linuxkpi/common/include/linux/pci.h | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/sys/compat/linuxkpi/common/include/linux/pci.h b/sys/compat/linuxkpi/common/include/linux/pci.h
index 9b7699a5ca59..ccbd425de5da 100644
--- a/sys/compat/linuxkpi/common/include/linux/pci.h
+++ b/sys/compat/linuxkpi/common/include/linux/pci.h
@@ -235,6 +235,20 @@ extern const char *pci_power_names[6];
#define PCI_IRQ_LEGACY PCI_IRQ_INTX
#endif
+/*
+ * Linux PCI code uses `PCI_SET_ERROR_RESPONSE()` to indicate to the caller of
+ * a `pci_read_*()` function that the read failed. An example of failure is
+ * whether the device was disconnected. It is a bit weird because Linux
+ * `pci_read_*()` can return an error value, as the read value is stored in a
+ * integer passed by pointer.
+ *
+ * We don't set PCI_ERROR_RESPONSE anywhere as of this commit, but the DRM
+ * drivers started to use `PCI_POSSIBLE_ERROR()`.
+ */
+#define PCI_ERROR_RESPONSE (~0ULL)
+#define PCI_SET_ERROR_RESPONSE(val) (*(val) = ((typeof(*(val))) PCI_ERROR_RESPONSE))
+#define PCI_POSSIBLE_ERROR(val) ((val) == ((typeof(val)) PCI_ERROR_RESPONSE))
+
struct pci_dev;
struct pci_driver {