Merge tag 'pci-v3.13-changes' of git://git.kernel.org/pub/scm/linux/kernel/git/helgaas/pci
Pull PCI changes from Bjorn Helgaas: "Resource management - Fix host bridge window coalescing (Alexey Neyman) - Pass type, width, and prefetchability for window alignment (Wei Yang) PCI device hotplug - Convert acpiphp, acpiphp_ibm to dynamic debug (Lan Tianyu) Power management - Remove pci_pm_complete() (Liu Chuansheng) MSI - Fail initialization if device is not in PCI_D0 (Yijing Wang) MPS (Max Payload Size) - Use pcie_get_mps() and pcie_set_mps() to simplify code (Yijing Wang) - Use pcie_set_readrq() to simplify code (Yijing Wang) - Use cached pci_dev->pcie_mpss to simplify code (Yijing Wang) SR-IOV - Enable upstream bridges even for VFs on virtual buses (Bjorn Helgaas) - Use pci_is_root_bus() to avoid catching virtual buses (Wei Yang) Virtualization - Add x86 MSI masking ops (Konrad Rzeszutek Wilk) Freescale i.MX6 - Support i.MX6 PCIe controller (Sean Cross) - Increase link startup timeout (Marek Vasut) - Probe PCIe in fs_initcall() (Marek Vasut) - Fix imprecise abort handler (Tim Harvey) - Remove redundant of_match_ptr (Sachin Kamat) Renesas R-Car - Support Gen2 internal PCIe controller (Valentine Barshak) Samsung Exynos - Add MSI support (Jingoo Han) - Turn off power when link fails (Jingoo Han) - Add Jingoo Han as maintainer (Jingoo Han) - Add clk_disable_unprepare() on error path (Wei Yongjun) - Remove redundant of_match_ptr (Sachin Kamat) Synopsys DesignWare - Add irq_create_mapping() (Pratyush Anand) - Add header guards (Seungwon Jeon) Miscellaneous - Enable native PCIe services by default on non-ACPI (Andrew Murray) - Cleanup _OSC usage and messages (Bjorn Helgaas) - Remove pcibios_last_bus boot option on non-x86 (Bjorn Helgaas) - Convert bus code to use bus_, drv_, and dev_groups (Greg Kroah-Hartman) - Remove unused pci_mem_start (Myron Stowe) - Make sysfs functions static (Sachin Kamat) - Warn on invalid return from driver probe (Stephen M. Cameron) - Remove Intel Haswell D3 delays (Todd E Brandt) - Call pci_set_master() in core if driver doesn't do it (Yinghai Lu) - Use pci_is_pcie() to simplify code (Yijing Wang) - Use PCIe capability accessors to simplify code (Yijing Wang) - Use cached pci_dev->pcie_cap to simplify code (Yijing Wang) - Removed unused "is_pcie" from struct pci_dev (Yijing Wang) - Simplify sysfs CPU affinity implementation (Yijing Wang)" * tag 'pci-v3.13-changes' of git://git.kernel.org/pub/scm/linux/kernel/git/helgaas/pci: (79 commits) PCI: Enable upstream bridges even for VFs on virtual buses PCI: Add pci_upstream_bridge() PCI: Add x86_msi.msi_mask_irq() and msix_mask_irq() PCI: Warn on driver probe return value greater than zero PCI: Drop warning about drivers that don't use pci_set_master() PCI: Workaround missing pci_set_master in pci drivers powerpc/pci: Use pci_is_pcie() to simplify code [fix] PCI: Update pcie_ports 'auto' behavior for non-ACPI platforms PCI: imx6: Probe the PCIe in fs_initcall() PCI: Add R-Car Gen2 internal PCI support PCI: imx6: Remove redundant of_match_ptr PCI: Report pci_pme_active() kmalloc failure mn10300/PCI: Remove useless pcibios_last_bus frv/PCI: Remove pcibios_last_bus PCI: imx6: Increase link startup timeout PCI: exynos: Remove redundant of_match_ptr PCI: imx6: Fix imprecise abort handler PCI: Fail MSI/MSI-X initialization if device is not in PCI_D0 PCI: imx6: Remove redundant dev_err() in imx6_pcie_probe() x86/PCI: Coalesce multiple overlapping host bridge windows ...
This commit is contained in:
@@ -51,8 +51,8 @@
|
||||
* file calls, even though this violates some
|
||||
* expectations of harmlessness.
|
||||
*/
|
||||
static int qib_tune_pcie_caps(struct qib_devdata *);
|
||||
static int qib_tune_pcie_coalesce(struct qib_devdata *);
|
||||
static void qib_tune_pcie_caps(struct qib_devdata *);
|
||||
static void qib_tune_pcie_coalesce(struct qib_devdata *);
|
||||
|
||||
/*
|
||||
* Do all the common PCIe setup and initialization.
|
||||
@@ -476,30 +476,6 @@ void qib_pcie_reenable(struct qib_devdata *dd, u16 cmd, u8 iline, u8 cline)
|
||||
"pci_enable_device failed after reset: %d\n", r);
|
||||
}
|
||||
|
||||
/* code to adjust PCIe capabilities. */
|
||||
|
||||
static int fld2val(int wd, int mask)
|
||||
{
|
||||
int lsbmask;
|
||||
|
||||
if (!mask)
|
||||
return 0;
|
||||
wd &= mask;
|
||||
lsbmask = mask ^ (mask & (mask - 1));
|
||||
wd /= lsbmask;
|
||||
return wd;
|
||||
}
|
||||
|
||||
static int val2fld(int wd, int mask)
|
||||
{
|
||||
int lsbmask;
|
||||
|
||||
if (!mask)
|
||||
return 0;
|
||||
lsbmask = mask ^ (mask & (mask - 1));
|
||||
wd *= lsbmask;
|
||||
return wd;
|
||||
}
|
||||
|
||||
static int qib_pcie_coalesce;
|
||||
module_param_named(pcie_coalesce, qib_pcie_coalesce, int, S_IRUGO);
|
||||
@@ -511,7 +487,7 @@ MODULE_PARM_DESC(pcie_coalesce, "tune PCIe colescing on some Intel chipsets");
|
||||
* of these chipsets, with some BIOS settings, and enabling it on those
|
||||
* systems may result in the system crashing, and/or data corruption.
|
||||
*/
|
||||
static int qib_tune_pcie_coalesce(struct qib_devdata *dd)
|
||||
static void qib_tune_pcie_coalesce(struct qib_devdata *dd)
|
||||
{
|
||||
int r;
|
||||
struct pci_dev *parent;
|
||||
@@ -519,18 +495,18 @@ static int qib_tune_pcie_coalesce(struct qib_devdata *dd)
|
||||
u32 mask, bits, val;
|
||||
|
||||
if (!qib_pcie_coalesce)
|
||||
return 0;
|
||||
return;
|
||||
|
||||
/* Find out supported and configured values for parent (root) */
|
||||
parent = dd->pcidev->bus->self;
|
||||
if (parent->bus->parent) {
|
||||
qib_devinfo(dd->pcidev, "Parent not root\n");
|
||||
return 1;
|
||||
return;
|
||||
}
|
||||
if (!pci_is_pcie(parent))
|
||||
return 1;
|
||||
return;
|
||||
if (parent->vendor != 0x8086)
|
||||
return 1;
|
||||
return;
|
||||
|
||||
/*
|
||||
* - bit 12: Max_rdcmp_Imt_EN: need to set to 1
|
||||
@@ -563,13 +539,12 @@ static int qib_tune_pcie_coalesce(struct qib_devdata *dd)
|
||||
mask = (3U << 24) | (7U << 10);
|
||||
} else {
|
||||
/* not one of the chipsets that we know about */
|
||||
return 1;
|
||||
return;
|
||||
}
|
||||
pci_read_config_dword(parent, 0x48, &val);
|
||||
val &= ~mask;
|
||||
val |= bits;
|
||||
r = pci_write_config_dword(parent, 0x48, val);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -580,55 +555,44 @@ static int qib_pcie_caps;
|
||||
module_param_named(pcie_caps, qib_pcie_caps, int, S_IRUGO);
|
||||
MODULE_PARM_DESC(pcie_caps, "Max PCIe tuning: Payload (0..3), ReadReq (4..7)");
|
||||
|
||||
static int qib_tune_pcie_caps(struct qib_devdata *dd)
|
||||
static void qib_tune_pcie_caps(struct qib_devdata *dd)
|
||||
{
|
||||
int ret = 1; /* Assume the worst */
|
||||
struct pci_dev *parent;
|
||||
u16 pcaps, pctl, ecaps, ectl;
|
||||
int rc_sup, ep_sup;
|
||||
int rc_cur, ep_cur;
|
||||
u16 rc_mpss, rc_mps, ep_mpss, ep_mps;
|
||||
u16 rc_mrrs, ep_mrrs, max_mrrs;
|
||||
|
||||
/* Find out supported and configured values for parent (root) */
|
||||
parent = dd->pcidev->bus->self;
|
||||
if (parent->bus->parent) {
|
||||
if (!pci_is_root_bus(parent->bus)) {
|
||||
qib_devinfo(dd->pcidev, "Parent not root\n");
|
||||
goto bail;
|
||||
return;
|
||||
}
|
||||
|
||||
if (!pci_is_pcie(parent) || !pci_is_pcie(dd->pcidev))
|
||||
goto bail;
|
||||
pcie_capability_read_word(parent, PCI_EXP_DEVCAP, &pcaps);
|
||||
pcie_capability_read_word(parent, PCI_EXP_DEVCTL, &pctl);
|
||||
return;
|
||||
|
||||
rc_mpss = parent->pcie_mpss;
|
||||
rc_mps = ffs(pcie_get_mps(parent)) - 8;
|
||||
/* Find out supported and configured values for endpoint (us) */
|
||||
pcie_capability_read_word(dd->pcidev, PCI_EXP_DEVCAP, &ecaps);
|
||||
pcie_capability_read_word(dd->pcidev, PCI_EXP_DEVCTL, &ectl);
|
||||
ep_mpss = dd->pcidev->pcie_mpss;
|
||||
ep_mps = ffs(pcie_get_mps(dd->pcidev)) - 8;
|
||||
|
||||
ret = 0;
|
||||
/* Find max payload supported by root, endpoint */
|
||||
rc_sup = fld2val(pcaps, PCI_EXP_DEVCAP_PAYLOAD);
|
||||
ep_sup = fld2val(ecaps, PCI_EXP_DEVCAP_PAYLOAD);
|
||||
if (rc_sup > ep_sup)
|
||||
rc_sup = ep_sup;
|
||||
|
||||
rc_cur = fld2val(pctl, PCI_EXP_DEVCTL_PAYLOAD);
|
||||
ep_cur = fld2val(ectl, PCI_EXP_DEVCTL_PAYLOAD);
|
||||
if (rc_mpss > ep_mpss)
|
||||
rc_mpss = ep_mpss;
|
||||
|
||||
/* If Supported greater than limit in module param, limit it */
|
||||
if (rc_sup > (qib_pcie_caps & 7))
|
||||
rc_sup = qib_pcie_caps & 7;
|
||||
if (rc_mpss > (qib_pcie_caps & 7))
|
||||
rc_mpss = qib_pcie_caps & 7;
|
||||
/* If less than (allowed, supported), bump root payload */
|
||||
if (rc_sup > rc_cur) {
|
||||
rc_cur = rc_sup;
|
||||
pctl = (pctl & ~PCI_EXP_DEVCTL_PAYLOAD) |
|
||||
val2fld(rc_cur, PCI_EXP_DEVCTL_PAYLOAD);
|
||||
pcie_capability_write_word(parent, PCI_EXP_DEVCTL, pctl);
|
||||
if (rc_mpss > rc_mps) {
|
||||
rc_mps = rc_mpss;
|
||||
pcie_set_mps(parent, 128 << rc_mps);
|
||||
}
|
||||
/* If less than (allowed, supported), bump endpoint payload */
|
||||
if (rc_sup > ep_cur) {
|
||||
ep_cur = rc_sup;
|
||||
ectl = (ectl & ~PCI_EXP_DEVCTL_PAYLOAD) |
|
||||
val2fld(ep_cur, PCI_EXP_DEVCTL_PAYLOAD);
|
||||
pcie_capability_write_word(dd->pcidev, PCI_EXP_DEVCTL, ectl);
|
||||
if (rc_mpss > ep_mps) {
|
||||
ep_mps = rc_mpss;
|
||||
pcie_set_mps(dd->pcidev, 128 << ep_mps);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -636,26 +600,22 @@ static int qib_tune_pcie_caps(struct qib_devdata *dd)
|
||||
* No field for max supported, but PCIe spec limits it to 4096,
|
||||
* which is code '5' (log2(4096) - 7)
|
||||
*/
|
||||
rc_sup = 5;
|
||||
if (rc_sup > ((qib_pcie_caps >> 4) & 7))
|
||||
rc_sup = (qib_pcie_caps >> 4) & 7;
|
||||
rc_cur = fld2val(pctl, PCI_EXP_DEVCTL_READRQ);
|
||||
ep_cur = fld2val(ectl, PCI_EXP_DEVCTL_READRQ);
|
||||
max_mrrs = 5;
|
||||
if (max_mrrs > ((qib_pcie_caps >> 4) & 7))
|
||||
max_mrrs = (qib_pcie_caps >> 4) & 7;
|
||||
|
||||
if (rc_sup > rc_cur) {
|
||||
rc_cur = rc_sup;
|
||||
pctl = (pctl & ~PCI_EXP_DEVCTL_READRQ) |
|
||||
val2fld(rc_cur, PCI_EXP_DEVCTL_READRQ);
|
||||
pcie_capability_write_word(parent, PCI_EXP_DEVCTL, pctl);
|
||||
max_mrrs = 128 << max_mrrs;
|
||||
rc_mrrs = pcie_get_readrq(parent);
|
||||
ep_mrrs = pcie_get_readrq(dd->pcidev);
|
||||
|
||||
if (max_mrrs > rc_mrrs) {
|
||||
rc_mrrs = max_mrrs;
|
||||
pcie_set_readrq(parent, rc_mrrs);
|
||||
}
|
||||
if (rc_sup > ep_cur) {
|
||||
ep_cur = rc_sup;
|
||||
ectl = (ectl & ~PCI_EXP_DEVCTL_READRQ) |
|
||||
val2fld(ep_cur, PCI_EXP_DEVCTL_READRQ);
|
||||
pcie_capability_write_word(dd->pcidev, PCI_EXP_DEVCTL, ectl);
|
||||
if (max_mrrs > ep_mrrs) {
|
||||
ep_mrrs = max_mrrs;
|
||||
pcie_set_readrq(dd->pcidev, ep_mrrs);
|
||||
}
|
||||
bail:
|
||||
return ret;
|
||||
}
|
||||
/* End of PCIe capability tuning */
|
||||
|
||||
|
Reference in New Issue
Block a user