From 347277313768f026ee64bc0f9d085f89baf3a194 Mon Sep 17 00:00:00 2001 From: Benjamin Herrenschmidt Date: Fri, 14 Oct 2011 14:56:15 -0500 Subject: [PATCH] --- yaml --- r: 270325 b: refs/heads/master c: a1c473aa11e61bc871be16279c9bf976acf22504 h: refs/heads/master i: 270323: fa7d50455e5f328650c163a16cde8944b031dc2e v: v3 --- [refs] | 2 +- trunk/drivers/pci/pci.c | 18 ++++++++++++++++-- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/[refs] b/[refs] index 578b28e946ee..8f65fb641255 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: 62f392ea5b5f87b641e16e61a4cedda21ef7341f +refs/heads/master: a1c473aa11e61bc871be16279c9bf976acf22504 diff --git a/trunk/drivers/pci/pci.c b/trunk/drivers/pci/pci.c index 7cd417e94058..6f45a73c6e9f 100644 --- a/trunk/drivers/pci/pci.c +++ b/trunk/drivers/pci/pci.c @@ -3202,8 +3202,6 @@ int pcie_set_readrq(struct pci_dev *dev, int rq) if (rq < 128 || rq > 4096 || !is_power_of_2(rq)) goto out; - v = (ffs(rq) - 8) << 12; - cap = pci_pcie_cap(dev); if (!cap) goto out; @@ -3211,6 +3209,22 @@ int pcie_set_readrq(struct pci_dev *dev, int rq) err = pci_read_config_word(dev, cap + PCI_EXP_DEVCTL, &ctl); if (err) goto out; + /* + * If using the "performance" PCIe config, we clamp the + * read rq size to the max packet size to prevent the + * host bridge generating requests larger than we can + * cope with + */ + if (pcie_bus_config == PCIE_BUS_PERFORMANCE) { + int mps = pcie_get_mps(dev); + + if (mps < 0) + return mps; + if (mps < rq) + rq = mps; + } + + v = (ffs(rq) - 8) << 12; if ((ctl & PCI_EXP_DEVCTL_READRQ) != v) { ctl &= ~PCI_EXP_DEVCTL_READRQ;