![Bjorn Helgaas](/assets/img/avatar_default.png)
- move pcieport_if.h to drivers/pci/pcie/ to encapsulate it (Frederick Lawler) - merge pcieport_if.h into portdrv.h (Bjorn Helgaas) - move workaround for BIOS PME issue from portdrv to PCI core (Bjorn Helgaas) - completely disable portdrv with "pcie_ports=compat" (Bjorn Helgaas) - remove portdrv link order dependency (Bjorn Helgaas) - remove support for unused VC portdrv service (Bjorn Helgaas) - simplify portdrv feature permission checking (Bjorn Helgaas) - remove "pcie_hp=nomsi" parameter (use "pci=nomsi" instead) (Bjorn Helgaas) - remove unnecessary "pcie_ports=auto" parameter (Bjorn Helgaas) - use cached AER capability offset (Frederick Lawler) - don't enable DPC if BIOS hasn't granted AER control (Mika Westerberg) - rename pcie-dpc.c to dpc.c (Bjorn Helgaas) * pci/portdrv: PCI/DPC: Rename from pcie-dpc.c to dpc.c PCI/DPC: Do not enable DPC if AER control is not allowed by the BIOS PCI/AER: Use cached AER Capability offset PCI/portdrv: Rename and reverse sense of pcie_ports_auto PCI/portdrv: Encapsulate pcie_ports_auto inside the port driver PCI/portdrv: Remove unnecessary "pcie_ports=auto" parameter PCI/portdrv: Remove "pcie_hp=nomsi" kernel parameter PCI/portdrv: Remove unnecessary include of <linux/pci-aspm.h> PCI/portdrv: Simplify PCIe feature permission checking PCI/portdrv: Remove unused PCIE_PORT_SERVICE_VC PCI/portdrv: Remove pcie_port_bus_type link order dependency PCI/portdrv: Disable port driver in compat mode PCI/PM: Clear PCIe PME Status bit for Root Complex Event Collectors PCI/PM: Clear PCIe PME Status bit in core, not PCIe port driver PCI/PM: Move pcie_clear_root_pme_status() to core PCI/portdrv: Merge pcieport_if.h into portdrv.h PCI/portdrv: Move pcieport_if.h to drivers/pci/pcie/ Conflicts: drivers/pci/pcie/Makefile drivers/pci/pcie/portdrv.h
118 lines
2.5 KiB
C
118 lines
2.5 KiB
C
// SPDX-License-Identifier: GPL-2.0
|
|
/*
|
|
* Enable/disable PCIe ECRC checking
|
|
*
|
|
* (C) Copyright 2009 Hewlett-Packard Development Company, L.P.
|
|
* Andrew Patterson <andrew.patterson@hp.com>
|
|
*/
|
|
|
|
#include <linux/kernel.h>
|
|
#include <linux/module.h>
|
|
#include <linux/moduleparam.h>
|
|
#include <linux/pci.h>
|
|
#include <linux/pci_regs.h>
|
|
#include <linux/errno.h>
|
|
#include "../../pci.h"
|
|
|
|
#define ECRC_POLICY_DEFAULT 0 /* ECRC set by BIOS */
|
|
#define ECRC_POLICY_OFF 1 /* ECRC off for performance */
|
|
#define ECRC_POLICY_ON 2 /* ECRC on for data integrity */
|
|
|
|
static int ecrc_policy = ECRC_POLICY_DEFAULT;
|
|
|
|
static const char *ecrc_policy_str[] = {
|
|
[ECRC_POLICY_DEFAULT] = "bios",
|
|
[ECRC_POLICY_OFF] = "off",
|
|
[ECRC_POLICY_ON] = "on"
|
|
};
|
|
|
|
/**
|
|
* enable_ercr_checking - enable PCIe ECRC checking for a device
|
|
* @dev: the PCI device
|
|
*
|
|
* Returns 0 on success, or negative on failure.
|
|
*/
|
|
static int enable_ecrc_checking(struct pci_dev *dev)
|
|
{
|
|
int pos;
|
|
u32 reg32;
|
|
|
|
if (!pci_is_pcie(dev))
|
|
return -ENODEV;
|
|
|
|
pos = dev->aer_cap;
|
|
if (!pos)
|
|
return -ENODEV;
|
|
|
|
pci_read_config_dword(dev, pos + PCI_ERR_CAP, ®32);
|
|
if (reg32 & PCI_ERR_CAP_ECRC_GENC)
|
|
reg32 |= PCI_ERR_CAP_ECRC_GENE;
|
|
if (reg32 & PCI_ERR_CAP_ECRC_CHKC)
|
|
reg32 |= PCI_ERR_CAP_ECRC_CHKE;
|
|
pci_write_config_dword(dev, pos + PCI_ERR_CAP, reg32);
|
|
|
|
return 0;
|
|
}
|
|
|
|
/**
|
|
* disable_ercr_checking - disables PCIe ECRC checking for a device
|
|
* @dev: the PCI device
|
|
*
|
|
* Returns 0 on success, or negative on failure.
|
|
*/
|
|
static int disable_ecrc_checking(struct pci_dev *dev)
|
|
{
|
|
int pos;
|
|
u32 reg32;
|
|
|
|
if (!pci_is_pcie(dev))
|
|
return -ENODEV;
|
|
|
|
pos = dev->aer_cap;
|
|
if (!pos)
|
|
return -ENODEV;
|
|
|
|
pci_read_config_dword(dev, pos + PCI_ERR_CAP, ®32);
|
|
reg32 &= ~(PCI_ERR_CAP_ECRC_GENE | PCI_ERR_CAP_ECRC_CHKE);
|
|
pci_write_config_dword(dev, pos + PCI_ERR_CAP, reg32);
|
|
|
|
return 0;
|
|
}
|
|
|
|
/**
|
|
* pcie_set_ecrc_checking - set/unset PCIe ECRC checking for a device based on global policy
|
|
* @dev: the PCI device
|
|
*/
|
|
void pcie_set_ecrc_checking(struct pci_dev *dev)
|
|
{
|
|
switch (ecrc_policy) {
|
|
case ECRC_POLICY_DEFAULT:
|
|
return;
|
|
case ECRC_POLICY_OFF:
|
|
disable_ecrc_checking(dev);
|
|
break;
|
|
case ECRC_POLICY_ON:
|
|
enable_ecrc_checking(dev);
|
|
break;
|
|
default:
|
|
return;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* pcie_ecrc_get_policy - parse kernel command-line ecrc option
|
|
*/
|
|
void pcie_ecrc_get_policy(char *str)
|
|
{
|
|
int i;
|
|
|
|
for (i = 0; i < ARRAY_SIZE(ecrc_policy_str); i++)
|
|
if (!strncmp(str, ecrc_policy_str[i],
|
|
strlen(ecrc_policy_str[i])))
|
|
break;
|
|
if (i >= ARRAY_SIZE(ecrc_policy_str))
|
|
return;
|
|
|
|
ecrc_policy = i;
|
|
}
|