Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 22 Apr 2026 21:08:03 +0000
From:      Bjoern A. Zeeb <bz@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org
Cc:        Jean-=?utf-8?Q?S=C3=A9bast?==?utf-8?Q?ien P=C3=A9?=dron <dumbbell@FreeBSD.org>
Subject:   git: de8bc3aad7f1 - stable/15 - linuxkpi: Define `PCI_POSSIBLE_ERROR()` macro
Message-ID:  <69e938b3.27ca4.3aec0a0b@gitrepo.freebsd.org>

index | next in thread | raw e-mail

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 {


home | help

Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?69e938b3.27ca4.3aec0a0b>