git: bdd0de1a902d - stable/13 - LinuxKPI: implement pcie_capability_set_word()

From: Bjoern A. Zeeb <bz_at_FreeBSD.org>
Date: Fri, 03 Jun 2022 17:19:27 UTC
The branch stable/13 has been updated by bz:

URL: https://cgit.FreeBSD.org/src/commit/?id=bdd0de1a902d4c5b0b1690e926fefa5ce0209cb9

commit bdd0de1a902d4c5b0b1690e926fefa5ce0209cb9
Author:     Bjoern A. Zeeb <bz@FreeBSD.org>
AuthorDate: 2022-05-18 22:36:31 +0000
Commit:     Bjoern A. Zeeb <bz@FreeBSD.org>
CommitDate: 2022-06-03 16:56:49 +0000

    LinuxKPI: implement pcie_capability_set_word()
    
    Implement pcie_capability_set_word() using the already available
    read/write functions.
    Also define the completion timeout disable value to our PCI one.
    Both needed by a driver update.
    
    Sponsored by:   The FreeBSD Foundation
    Reviewed by:    manu, hselasky
    Differential Revision: https://reviews.freebsd.org/D35250
    
    (cherry picked from commit 85eb99f9a47151f90565a1fb37395b8302c2978c)
---
 sys/compat/linuxkpi/common/include/linux/pci.h | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/sys/compat/linuxkpi/common/include/linux/pci.h b/sys/compat/linuxkpi/common/include/linux/pci.h
index efe0780190b7..95187a231e1f 100644
--- a/sys/compat/linuxkpi/common/include/linux/pci.h
+++ b/sys/compat/linuxkpi/common/include/linux/pci.h
@@ -131,6 +131,7 @@ MODULE_PNP_INFO("U32:vendor;U32:device;V32:subvendor;V32:subdevice",	\
 #define	PCI_EXP_DEVCAP2		PCIER_DEVICE_CAP2		/* Device Capabilities 2 */
 #define	PCI_EXP_DEVCTL2		PCIER_DEVICE_CTL2		/* Device Control 2 */
 #define	PCI_EXP_DEVCTL2_LTR_EN	PCIEM_CTL2_LTR_ENABLE
+#define	PCI_EXP_DEVCTL2_COMP_TMOUT_DIS	PCIEM_CTL2_COMP_TIMO_DISABLE
 #define	PCI_EXP_LNKCAP2		PCIER_LINK_CAP2			/* Link Capabilities 2 */
 #define	PCI_EXP_LNKCTL2		PCIER_LINK_CTL2			/* Link Control 2 */
 #define	PCI_EXP_LNKSTA2		PCIER_LINK_STA2			/* Link Status 2 */
@@ -1165,6 +1166,22 @@ pcie_capability_write_word(struct pci_dev *dev, int pos, u16 val)
 	return pci_write_config_word(dev, pci_pcie_cap(dev) + pos, val);
 }
 
+static inline int
+pcie_capability_set_word(struct pci_dev *dev, int pos, uint16_t val)
+{
+	int error;
+	uint16_t v;
+
+	error = pcie_capability_read_word(dev, pos, &v);
+	if (error != 0)
+		return (error);
+
+	v |= val;
+
+	error = pcie_capability_write_word(dev, pos, v);
+	return (error);
+}
+
 static inline int pcie_get_minimum_link(struct pci_dev *dev,
     enum pci_bus_speed *speed, enum pcie_link_width *width)
 {