Skip to contentSkip to conversation

PCI: Add support for turning PCIe ECRC on or off

PATCH Superseded Andrew Patterson 2 participants 3 messages Apr 3, 2009 – Apr 6, 2009

Subsystems (2)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 PCI: Add support for turning PCIe ECRC on or off

This is version two of my patch to add PCIe ECRC support

Changelog:

Fixed copyright year typo.
Removed unneeded EXPORT_SYMBOL_GPL.
Use pci=ecrc=<option> instead of pcie_ecrc=<option>.
Use "bios" instead of "default" to indicate ECRC should be set by firmware. Use CONFIG_PCIE_ECRC instead of CONFIG_PCIEECRC.

 Documentation/kernel-parameters.txt |    6 ++
 drivers/pci/pci.c                   |    2 +
 drivers/pci/pcie/Kconfig            |   12 +++++
 drivers/pci/pcie/Makefile           |    2 +
 drivers/pci/pcie/ecrc.c             |   91 +++++++++++++++++++++++++++++++++++
 drivers/pci/probe.c                 |    3 +
 include/linux/pci.h                 |   11 ++++
 7 files changed, 127 insertions(+), 0 deletions(-)
 create mode 100644 drivers/pci/pcie/ecrc.c
Signature · 1 line
Andrew Patterson
#1 lore raw

PATCH v2 1/1 PCI: Add support for turning PCIe ECRC on or off

PCI: Add support for turning PCIe ECRC on or off

Adds support for PCI Express transaction layer end-to-end CRC checking (ECRC). This patch will enable/disable ECRC checking by setting/clearing the ECRC Check Enable and/or ECRC Generation Enable bits for devices that support ECRC.

The ECRC setting is controlled by the "pci=ecrc=<policy>" command-line option. If this option is not set or is set to 'bios", the enable and generation bits are left in whatever state that firmware/BIOS set them to. The "off" setting turns them off, and the "on" option turns them on (if the device supports it).

Turning ECRC on or off can be a data integrity versus performance tradeoff. In theory, turning it on will catch more data errors, turning it off means possibly better performance since CRC does not need to be calculated by the PCIe hardware and packet sizes are reduced.

---

Documentation/kernel-parameters.txt +6 -0
index 1754fed..56cdd5f 100644
@@ -1769,6 +1769,12 @@ and is between 256 and 4096 characters. It is defined in the file
 				PAGE_SIZE is used as alignment.
 				PCI-PCI bridge can be specified, if resource
 				windows need to be expanded.
+		ecrc=		Enable/disable PCIe ECRC (transaction layer
+				end-to-end CRC checking).
+				bios: Use BIOS/firmware settings. This is the
+				the default.
+				off: Turn ECRC off
+				on: Turn ECRC on.
 
 	pcie_aspm=	[PCIE] Forcibly enable or disable PCIe Active State Power
 			Management.
drivers/pci/pci.c +2 -0
index 59569b8..65e8a53 100644
@@ -2555,6 +2555,8 @@ static int __init pci_setup(char *str)
 			} else if (!strncmp(str, "resource_alignment=", 19)) {
 				pci_set_resource_alignment_param(str + 19,
 							strlen(str + 19));
+			} else if (!strncmp(str, "ecrc=", 5)) {
+				pcie_ecrc_get_policy(str + 5);
 			} else {
 				printk(KERN_ERR "PCI: Unknown option `%s'\n",
 						str);
drivers/pci/pcie/Kconfig +12 -0
index 5a0c6ad..a79e52b 100644
@@ -46,3 +46,15 @@ config PCIEASPM_DEBUG
 	help
 	  This enables PCI Express ASPM debug support. It will add per-device
 	  interface to control ASPM.
+
+#
+# PCI Express ECRC
+#
+config PCIE_ECRC
+	bool "PCI Express ECRC support"
+	depends on PCI
+	help
+	  Enables PCI Express ECRC (transaction layer end-to-end CRC
+	  checking)
+
+	  When in doubt, say N.
drivers/pci/pcie/Makefile +2 -0
index 11f6bb1..2f8ce01 100644
@@ -5,6 +5,8 @@
 # Build PCI Express ASPM if needed
 obj-$(CONFIG_PCIEASPM)		+= aspm.o
 
+obj-$(CONFIG_PCIE_ECRC)		+= ecrc.o
+
 pcieportdrv-y			:= portdrv_core.o portdrv_pci.o portdrv_bus.o
 
 obj-$(CONFIG_PCIEPORTBUS)	+= pcieportdrv.o
drivers/pci/pcie/ecrc.c new file +91 -0

91 lines not on this page · raw message

drivers/pci/probe.c +3 -0
index e2f3dd0..df8f909 100644
@@ -984,6 +984,9 @@ static void pci_init_capabilities(struct pci_dev *dev)
 
 	/* Single Root I/O Virtualization */
 	pci_iov_init(dev);
+
+	/* PCIe end-to-end CRC checking */
+	pcie_set_ecrc_checking(dev);
 }
 
 void pci_device_add(struct pci_dev *dev, struct pci_bus *bus)
include/linux/pci.h +11 -0
index 6fb335b..4275e2f 100644
@@ -874,6 +874,17 @@ static inline int pcie_aspm_enabled(void)
 extern int pcie_aspm_enabled(void);
 #endif
 
+#ifndef CONFIG_PCIE_ECRC
+static inline int pcie_set_ecrc_checking(struct pci_dev *dev)
+{
+	return 0;
+}
+static inline void pcie_ecrc_get_policy(char *str) {};
+#else
+extern int pcie_set_ecrc_checking(struct pci_dev *dev);
+extern void pcie_ecrc_get_policy(char *str);
+#endif
+
 #define pci_enable_msi(pdev)	pci_enable_msi_block(pdev, 1)
 
 #ifdef CONFIG_HT_IRQ
Applied
#2 lore raw
Quoted 13 lines · On Fri, 03 Apr 2009 16:01:36 -0600 Andrew Patterson <[email protected]>…

PCI: Add support for turning PCIe ECRC on or off

Adds support for PCI Express transaction layer end-to-end CRC checking (ECRC). This patch will enable/disable ECRC checking by setting/clearing the ECRC Check Enable and/or ECRC Generation Enable bits for devices that support ECRC.

The ECRC setting is controlled by the "pci=ecrc=<policy>" command-line option. If this option is not set or is set to 'bios", the enable and generation bits are left in whatever state that firmware/BIOS set them to. The "off" setting turns them off, and the "on" option turns them on (if the device supports it).

Quoted 7 lines

Turning ECRC on or off can be a data integrity versus performance tradeoff. In theory, turning it on will catch more data errors, turning it off means possibly better performance since CRC does not need to be calculated by the PCIe hardware and packet sizes are reduced.

Applied to my for-linus branch, thanks Andrew.

Signature · 1 line
Jesse Barnes, Intel Open Source Technology Center