Blame SOURCES/9004-add-pci_aer_clear_nonfatal_status.patch

2eb987
Index: src/drivers/net/ethernet/intel/ice/ice_backport_compat.h
2eb987
===================================================================
2eb987
--- src.orig/drivers/net/ethernet/intel/ice/ice_backport_compat.h	2020-08-27 23:41:54.067426597 +0200
2eb987
+++ src/drivers/net/ethernet/intel/ice/ice_backport_compat.h	2020-08-27 23:44:20.729496531 +0200
2eb987
@@ -37,4 +37,47 @@
2eb987
 }
2eb987
 
2eb987
 
2eb987
+static inline struct pci_bus *find_pci_root_bus_dup(struct pci_bus *bus)
2eb987
+{
2eb987
+	while (bus->parent)
2eb987
+		bus = bus->parent;
2eb987
+
2eb987
+	return bus;
2eb987
+}
2eb987
+
2eb987
+static inline struct pci_host_bridge *pci_find_host_bridge_dup(struct pci_bus *bus)
2eb987
+{
2eb987
+	struct pci_bus *root_bus = find_pci_root_bus_dup(bus);
2eb987
+
2eb987
+	return to_pci_host_bridge(root_bus->bridge);
2eb987
+}
2eb987
+
2eb987
+static inline int pcie_aer_is_native(struct pci_dev *dev)
2eb987
+{
2eb987
+	struct pci_host_bridge *host = pci_find_host_bridge_dup(dev->bus);
2eb987
+
2eb987
+	if (!dev->aer_cap)
2eb987
+		return 0;
2eb987
+
2eb987
+	return /* pcie_ports_native || */ host->native_aer;
2eb987
+}
2eb987
+
2eb987
+static inline int pci_aer_clear_nonfatal_status(struct pci_dev *dev)
2eb987
+{
2eb987
+	int aer = dev->aer_cap;
2eb987
+	u32 status, sev;
2eb987
+
2eb987
+	if (!pcie_aer_is_native(dev))
2eb987
+		return -EIO;
2eb987
+
2eb987
+	/* Clear status bits for ERR_NONFATAL errors only */
2eb987
+	pci_read_config_dword(dev, aer + PCI_ERR_UNCOR_STATUS, &status);
2eb987
+	pci_read_config_dword(dev, aer + PCI_ERR_UNCOR_SEVER, &sev;;
2eb987
+	status &= ~sev;
2eb987
+	if (status)
2eb987
+		pci_write_config_dword(dev, aer + PCI_ERR_UNCOR_STATUS, status);
2eb987
+
2eb987
+	return 0;
2eb987
+}
2eb987
+
2eb987
 #endif /* ICE_BACKPORT_COMPAT_H */