From: Oliver O'Halloran <oohall@gmail.com>
To: linuxppc-dev@lists.ozlabs.org
Cc: alistair@popple.id.au, Oliver O'Halloran <oohall@gmail.com>,
s.miroshnichenko@yadro.com
Subject: [Very RFC 15/46] powernv/eeh: Use pnv_eeh_*_config() for internal config ops
Date: Wed, 20 Nov 2019 12:28:28 +1100 [thread overview]
Message-ID: <20191120012859.23300-16-oohall@gmail.com> (raw)
In-Reply-To: <20191120012859.23300-1-oohall@gmail.com>
Use the pnv_eeh_{read|write}_config() functions that take an edev rather
than a pci_dn. This allows us to remove most of the explict uses of pci_dn
in the PowerNV EEH backend and localises them into a few functions which we
can fix later.
Signed-off-by: Oliver O'Halloran <oohall@gmail.com>
---
arch/powerpc/platforms/powernv/eeh-powernv.c | 153 +++++++++----------
1 file changed, 70 insertions(+), 83 deletions(-)
diff --git a/arch/powerpc/platforms/powernv/eeh-powernv.c b/arch/powerpc/platforms/powernv/eeh-powernv.c
index aa2935a08464..aaccb3768393 100644
--- a/arch/powerpc/platforms/powernv/eeh-powernv.c
+++ b/arch/powerpc/platforms/powernv/eeh-powernv.c
@@ -278,27 +278,73 @@ int pnv_eeh_post_init(void)
return ret;
}
-static int pnv_eeh_find_cap(struct pci_dn *pdn, int cap)
+static inline bool pnv_eeh_cfg_blocked(struct eeh_dev *edev)
+{
+ if (!edev || !edev->pe)
+ return false;
+
+ /*
+ * We will issue FLR or AF FLR to all VFs, which are contained
+ * in VF PE. It relies on the EEH PCI config accessors. So we
+ * can't block them during the window.
+ */
+ if (edev->physfn && (edev->pe->state & EEH_PE_RESET))
+ return false;
+
+ if (edev->pe->state & EEH_PE_CFG_BLOCKED)
+ return true;
+
+ return false;
+}
+
+static int pnv_eeh_read_config(struct eeh_dev *edev,
+ int where, int size, u32 *val)
+{
+ struct pci_dn *pdn = eeh_dev_to_pdn(edev);
+
+ if (!pdn)
+ return PCIBIOS_DEVICE_NOT_FOUND;
+
+ if (pnv_eeh_cfg_blocked(edev)) {
+ *val = 0xFFFFFFFF;
+ return PCIBIOS_SET_FAILED;
+ }
+
+ return pnv_pci_cfg_read(pdn, where, size, val);
+}
+
+static int pnv_eeh_write_config(struct eeh_dev *edev,
+ int where, int size, u32 val)
+{
+ struct pci_dn *pdn = eeh_dev_to_pdn(edev);
+
+ if (!pdn)
+ return PCIBIOS_DEVICE_NOT_FOUND;
+
+ if (pnv_eeh_cfg_blocked(edev))
+ return PCIBIOS_SET_FAILED;
+
+ return pnv_pci_cfg_write(pdn, where, size, val);
+}
+
+static int pnv_eeh_find_cap(struct eeh_dev *edev, int cap)
{
int pos = PCI_CAPABILITY_LIST;
int cnt = 48; /* Maximal number of capabilities */
u32 status, id;
- if (!pdn)
- return 0;
-
/* Check if the device supports capabilities */
- pnv_pci_cfg_read(pdn, PCI_STATUS, 2, &status);
+ pnv_eeh_read_config(edev, PCI_STATUS, 2, &status);
if (!(status & PCI_STATUS_CAP_LIST))
return 0;
while (cnt--) {
- pnv_pci_cfg_read(pdn, pos, 1, &pos);
+ pnv_eeh_read_config(edev, pos, 1, &pos);
if (pos < 0x40)
break;
pos &= ~3;
- pnv_pci_cfg_read(pdn, pos + PCI_CAP_LIST_ID, 1, &id);
+ pnv_eeh_read_config(edev, pos + PCI_CAP_LIST_ID, 1, &id);
if (id == 0xff)
break;
@@ -313,15 +359,14 @@ static int pnv_eeh_find_cap(struct pci_dn *pdn, int cap)
return 0;
}
-static int pnv_eeh_find_ecap(struct pci_dn *pdn, int cap)
+static int pnv_eeh_find_ecap(struct eeh_dev *edev, int cap)
{
- struct eeh_dev *edev = pdn_to_eeh_dev(pdn);
u32 header;
int pos = 256, ttl = (4096 - 256) / 8;
if (!edev || !edev->pcie_cap)
return 0;
- if (pnv_pci_cfg_read(pdn, pos, 4, &header) != PCIBIOS_SUCCESSFUL)
+ if (pnv_eeh_read_config(edev, pos, 4, &header) != PCIBIOS_SUCCESSFUL)
return 0;
else if (!header)
return 0;
@@ -334,7 +379,7 @@ static int pnv_eeh_find_ecap(struct pci_dn *pdn, int cap)
if (pos < 256)
break;
- if (pnv_pci_cfg_read(pdn, pos, 4, &header) != PCIBIOS_SUCCESSFUL)
+ if (pnv_eeh_read_config(edev, pos, 4, &header) != PCIBIOS_SUCCESSFUL)
break;
}
@@ -382,15 +427,14 @@ static struct eeh_dev *pnv_eeh_probe_pdev(struct pci_dev *pdev)
/* Initialize eeh device */
edev->class_code = pdn->class_code;
- edev->mode &= 0xFFFFFF00;
- edev->pcix_cap = pnv_eeh_find_cap(pdn, PCI_CAP_ID_PCIX);
- edev->pcie_cap = pnv_eeh_find_cap(pdn, PCI_CAP_ID_EXP);
- edev->af_cap = pnv_eeh_find_cap(pdn, PCI_CAP_ID_AF);
- edev->aer_cap = pnv_eeh_find_ecap(pdn, PCI_EXT_CAP_ID_ERR);
+ edev->pcix_cap = pnv_eeh_find_cap(edev, PCI_CAP_ID_PCIX);
+ edev->pcie_cap = pnv_eeh_find_cap(edev, PCI_CAP_ID_EXP);
+ edev->af_cap = pnv_eeh_find_cap(edev, PCI_CAP_ID_AF);
+ edev->aer_cap = pnv_eeh_find_ecap(edev, PCI_EXT_CAP_ID_ERR);
if ((edev->class_code >> 8) == PCI_CLASS_BRIDGE_PCI) {
edev->mode |= EEH_DEV_BRIDGE;
if (edev->pcie_cap) {
- pnv_pci_cfg_read(pdn, edev->pcie_cap + PCI_EXP_FLAGS,
+ pnv_eeh_read_config(edev, edev->pcie_cap + PCI_EXP_FLAGS,
2, &pcie_flags);
pcie_flags = (pcie_flags & PCI_EXP_FLAGS_TYPE) >> 4;
if (pcie_flags == PCI_EXP_TYPE_ROOT_PORT)
@@ -839,8 +883,7 @@ static int pnv_eeh_root_reset(struct pci_controller *hose, int option)
static int __pnv_eeh_bridge_reset(struct pci_dev *dev, int option)
{
- struct pci_dn *pdn = pci_get_pdn_by_devfn(dev->bus, dev->devfn);
- struct eeh_dev *edev = pdn_to_eeh_dev(pdn);
+ struct eeh_dev *edev = pci_dev_to_eeh_dev(dev);
int aer = edev ? edev->aer_cap : 0;
u32 ctrl;
@@ -944,10 +987,9 @@ void pnv_pci_reset_secondary_bus(struct pci_dev *dev)
}
}
-static void pnv_eeh_wait_for_pending(struct pci_dn *pdn, const char *type,
+static void pnv_eeh_wait_for_pending(struct eeh_dev *edev, const char *type,
int pos, u16 mask)
{
- struct eeh_dev *edev = pdn->edev;
int i, status = 0;
/* Wait for Transaction Pending bit to be cleared */
@@ -965,9 +1007,8 @@ static void pnv_eeh_wait_for_pending(struct pci_dn *pdn, const char *type,
PCI_SLOT(pdn->devfn), PCI_FUNC(pdn->devfn));
}
-static int pnv_eeh_do_flr(struct pci_dn *pdn, int option)
+static int pnv_eeh_do_flr(struct eeh_dev *edev, int option)
{
- struct eeh_dev *edev = pdn_to_eeh_dev(pdn);
u32 reg = 0;
if (WARN_ON(!edev->pcie_cap))
@@ -980,7 +1021,7 @@ static int pnv_eeh_do_flr(struct pci_dn *pdn, int option)
switch (option) {
case EEH_RESET_HOT:
case EEH_RESET_FUNDAMENTAL:
- pnv_eeh_wait_for_pending(pdn, "",
+ pnv_eeh_wait_for_pending(edev, "",
edev->pcie_cap + PCI_EXP_DEVSTA,
PCI_EXP_DEVSTA_TRPND);
eeh_ops->read_config(edev, edev->pcie_cap + PCI_EXP_DEVCTL,
@@ -1003,9 +1044,8 @@ static int pnv_eeh_do_flr(struct pci_dn *pdn, int option)
return 0;
}
-static int pnv_eeh_do_af_flr(struct pci_dn *pdn, int option)
+static int pnv_eeh_do_af_flr(struct eeh_dev *edev, int option)
{
- struct eeh_dev *edev = pdn_to_eeh_dev(pdn);
u32 cap = 0;
if (WARN_ON(!edev->af_cap))
@@ -1023,7 +1063,7 @@ static int pnv_eeh_do_af_flr(struct pci_dn *pdn, int option)
* test is used, so we use the conrol offset rather than status
* and shift the test bit to match.
*/
- pnv_eeh_wait_for_pending(pdn, "AF",
+ pnv_eeh_wait_for_pending(edev, "AF",
edev->af_cap + PCI_AF_CTRL,
PCI_AF_STATUS_TP << 8);
eeh_ops->write_config(edev, edev->af_cap + PCI_AF_CTRL,
@@ -1042,20 +1082,18 @@ static int pnv_eeh_do_af_flr(struct pci_dn *pdn, int option)
static int pnv_eeh_reset_vf_pe(struct eeh_pe *pe, int option)
{
struct eeh_dev *edev;
- struct pci_dn *pdn;
int ret;
/* The VF PE should have only one child device */
edev = list_first_entry_or_null(&pe->edevs, struct eeh_dev, entry);
- pdn = eeh_dev_to_pdn(edev);
- if (!pdn)
+ if (!edev)
return -ENXIO;
- ret = pnv_eeh_do_flr(pdn, option);
+ ret = pnv_eeh_do_flr(edev, option);
if (!ret)
return ret;
- return pnv_eeh_do_af_flr(pdn, option);
+ return pnv_eeh_do_af_flr(edev, option);
}
/**
@@ -1244,57 +1282,6 @@ static int pnv_eeh_err_inject(struct eeh_pe *pe, int type, int func,
return 0;
}
-static inline bool pnv_eeh_cfg_blocked(struct pci_dn *pdn)
-{
- struct eeh_dev *edev = pdn_to_eeh_dev(pdn);
-
- if (!edev || !edev->pe)
- return false;
-
- /*
- * We will issue FLR or AF FLR to all VFs, which are contained
- * in VF PE. It relies on the EEH PCI config accessors. So we
- * can't block them during the window.
- */
- if (edev->physfn && (edev->pe->state & EEH_PE_RESET))
- return false;
-
- if (edev->pe->state & EEH_PE_CFG_BLOCKED)
- return true;
-
- return false;
-}
-
-static int pnv_eeh_read_config(struct eeh_dev *edev,
- int where, int size, u32 *val)
-{
- struct pci_dn *pdn = eeh_dev_to_pdn(edev);
-
- if (!pdn)
- return PCIBIOS_DEVICE_NOT_FOUND;
-
- if (pnv_eeh_cfg_blocked(pdn)) {
- *val = 0xFFFFFFFF;
- return PCIBIOS_SET_FAILED;
- }
-
- return pnv_pci_cfg_read(pdn, where, size, val);
-}
-
-static int pnv_eeh_write_config(struct eeh_dev *edev,
- int where, int size, u32 val)
-{
- struct pci_dn *pdn = eeh_dev_to_pdn(edev);
-
- if (!pdn)
- return PCIBIOS_DEVICE_NOT_FOUND;
-
- if (pnv_eeh_cfg_blocked(pdn))
- return PCIBIOS_SET_FAILED;
-
- return pnv_pci_cfg_write(pdn, where, size, val);
-}
-
static void pnv_eeh_dump_hub_diag_common(struct OpalIoP7IOCErrorData *data)
{
/* GEM */
--
2.21.0
next prev parent reply other threads:[~2019-11-20 2:00 UTC|newest]
Thread overview: 107+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-11-20 1:28 PCIPOCALYPSE Oliver O'Halloran
2019-11-20 1:28 ` [Very RFC 01/46] powerpc/eeh: Don't attempt to restore VF config space after reset Oliver O'Halloran
2019-11-21 3:38 ` Alexey Kardashevskiy
2019-11-21 4:34 ` Oliver O'Halloran
2019-11-20 1:28 ` [Very RFC 02/46] powernv/pci: Add helper to find ioda_pe from BDFN Oliver O'Halloran
2019-11-20 1:28 ` [Very RFC 03/46] powernv/pci: Remove dma_dev_setup() for NPU PHBs Oliver O'Halloran
2019-11-21 3:57 ` Alexey Kardashevskiy
2019-11-20 1:28 ` [Very RFC 04/46] powernv/pci: Move dma_{dev|bus}_setup into pci-ioda.c Oliver O'Halloran
2019-11-21 4:02 ` Alexey Kardashevskiy
2019-11-21 4:33 ` Oliver O'Halloran
2019-11-21 7:46 ` Christoph Hellwig
2019-11-20 1:28 ` [Very RFC 05/46] powernv/pci: Remove the pnv_phb dma_dev_setup callback Oliver O'Halloran
2019-11-21 4:03 ` Alexey Kardashevskiy
2019-11-20 1:28 ` [Very RFC 06/46] powerpc/iov: Move VF pdev fixup into pcibios_fixup_iov() Oliver O'Halloran
2019-11-21 4:34 ` Alexey Kardashevskiy
2019-11-25 4:41 ` Oliver O'Halloran
2019-11-21 7:48 ` Christoph Hellwig
2019-11-25 4:39 ` Oliver O'Halloran
2019-11-20 1:28 ` [Very RFC 07/46] powernv/pci: Rework IODA PE device accounting Oliver O'Halloran
2019-11-21 5:48 ` Alexey Kardashevskiy
2019-11-20 1:28 ` [Very RFC 08/46] powerpc/eeh: Calculate VF index rather than looking it up in pci_dn Oliver O'Halloran
2019-11-22 4:43 ` Alexey Kardashevskiy
2019-11-20 1:28 ` [Very RFC 09/46] powerpc/eeh: Pass eeh_dev to eeh_ops->{read|write}_config() Oliver O'Halloran
2019-11-22 4:52 ` Alexey Kardashevskiy
2019-11-20 1:28 ` [Very RFC 10/46] powerpc/eeh: Pass eeh_dev to eeh_ops->restore_config() Oliver O'Halloran
2019-11-20 1:28 ` [Very RFC 11/46] powerpc/eeh: Convert various printfs to use edev, not pci_dn Oliver O'Halloran
2019-11-22 4:55 ` Alexey Kardashevskiy
2019-11-20 1:28 ` [Very RFC 12/46] powerpc/eeh: Split eeh_probe into probe_pdn and probe_pdev Oliver O'Halloran
2019-11-22 5:45 ` Alexey Kardashevskiy
2019-11-20 1:28 ` [Very RFC 13/46] powerpc/eeh: Rework how pdev_probe() is used Oliver O'Halloran
2019-11-20 1:28 ` [Very RFC 14/46] powernv/eeh: Remove un-necessary call to eeh_add_device_early() Oliver O'Halloran
2019-11-22 6:01 ` Alexey Kardashevskiy
2019-11-20 1:28 ` Oliver O'Halloran [this message]
2019-11-22 6:15 ` [Very RFC 15/46] powernv/eeh: Use pnv_eeh_*_config() for internal config ops Alexey Kardashevskiy
2019-11-20 1:28 ` [Very RFC 16/46] powernv/eeh: Use eeh_edev_warn() rather than open-coding a BDFN print Oliver O'Halloran
2019-11-22 6:17 ` Alexey Kardashevskiy
2019-11-20 1:28 ` [Very RFC 17/46] powernv/eeh: add pnv_eeh_find_edev() Oliver O'Halloran
2019-11-25 0:30 ` Alexey Kardashevskiy
2019-11-20 1:28 ` [Very RFC 18/46] powernv/pci: Add pci_bus_to_pnvhb() helper Oliver O'Halloran
2019-11-25 0:42 ` Alexey Kardashevskiy
2019-11-20 1:28 ` [Very RFC 19/46] powernv/eeh: Use standard PCI capability lookup functions Oliver O'Halloran
2019-11-25 1:02 ` Alexey Kardashevskiy
2019-11-20 1:28 ` [Very RFC 20/46] powernv/eeh: Look up device info from pci_dev Oliver O'Halloran
2019-11-25 1:26 ` Alexey Kardashevskiy
2019-11-20 1:28 ` [Very RFC 21/46] powernv/eeh: Rework finding an existing edev in probe_pdev() Oliver O'Halloran
2019-11-25 3:20 ` Alexey Kardashevskiy
2019-11-25 4:17 ` Oliver O'Halloran
2019-11-20 1:28 ` [Very RFC 22/46] powernv/eeh: Allocate eeh_dev's when needed Oliver O'Halloran
2019-11-25 3:27 ` Alexey Kardashevskiy
2019-11-25 4:26 ` Oliver O'Halloran
2019-11-27 1:50 ` Alexey Kardashevskiy
2019-11-20 1:28 ` [Very RFC 23/46] powerpc/eeh: Moving finding the parent PE into the platform Oliver O'Halloran
2019-11-25 5:00 ` Alexey Kardashevskiy
2019-11-20 1:28 ` [Very RFC 24/46] powernv/pci: Make the pre-cfg EEH freeze check use eeh_dev rather than pci_dn Oliver O'Halloran
2019-11-27 0:21 ` Alexey Kardashevskiy
2019-11-20 1:28 ` [Very RFC 25/46] powernv/pci: Remove pdn from pnv_pci_config_check_eeh() Oliver O'Halloran
2019-11-27 1:05 ` Alexey Kardashevskiy
2019-11-20 1:28 ` [Very RFC 26/46] powernv/pci: Remove pdn from pnv_pci_cfg_{read|write} Oliver O'Halloran
2019-11-27 2:16 ` Alexey Kardashevskiy
2019-11-20 1:28 ` [Very RFC 27/46] powernv/pci: Clear reserved PE freezes Oliver O'Halloran
2019-11-27 3:00 ` Alexey Kardashevskiy
2019-11-20 1:28 ` [Very RFC 28/46] powernv/iov: Move SR-IOV PF state out of pci_dn Oliver O'Halloran
2019-11-27 4:09 ` Alexey Kardashevskiy
2019-11-20 1:28 ` [Very RFC 29/46] powernv/pci: Remove open-coded PE lookup in PELT-V setup Oliver O'Halloran
2019-11-27 4:26 ` Alexey Kardashevskiy
2019-11-20 1:28 ` [Very RFC 30/46] powernv/pci: Remove open-coded PE lookup in PELT-V teardown Oliver O'Halloran
2019-11-27 4:50 ` Alexey Kardashevskiy
2019-11-20 1:28 ` [Very RFC 31/46] powernv/pci: Remove open-coded PE lookup in pnv_pci_ioda_dma_dev_setup() Oliver O'Halloran
2019-11-21 7:52 ` Christoph Hellwig
2019-11-27 4:53 ` Alexey Kardashevskiy
2019-11-20 1:28 ` [Very RFC 32/46] powernv/pci: Remove open-coded PE lookup in iommu_bypass_supported() Oliver O'Halloran
2019-11-27 5:09 ` Alexey Kardashevskiy
2019-11-20 1:28 ` [Very RFC 33/46] powernv/pci: Remove open-coded PE lookup in iommu notifier Oliver O'Halloran
2019-11-27 5:09 ` Alexey Kardashevskiy
2019-11-20 1:28 ` [Very RFC 34/46] powernv/pci: Remove open-coded PE lookup in pnv_pci_enable_device_hook() Oliver O'Halloran
2019-11-27 5:14 ` Alexey Kardashevskiy
2019-11-20 1:28 ` [Very RFC 35/46] powernv/pci: Remove open-coded PE lookup in pnv_pci_release_device Oliver O'Halloran
2019-11-27 5:24 ` Alexey Kardashevskiy
2019-11-27 9:51 ` Oliver O'Halloran
2019-11-20 1:28 ` [Very RFC 36/46] powernv/npu: Remove open-coded PE lookup for GPU device Oliver O'Halloran
2019-11-27 5:45 ` Alexey Kardashevskiy
2019-11-20 1:28 ` [Very RFC 37/46] powernv/pci: Use the PHB's rmap for pnv_ioda_to_pe() Oliver O'Halloran
2019-11-21 3:50 ` Alexey Kardashevskiy
2019-11-20 1:28 ` [Very RFC 38/46] powerpc/pci-hotplug: Scan the whole bus when using PCI_PROBE_NORMAL Oliver O'Halloran
2019-11-27 6:27 ` Alexey Kardashevskiy
2019-11-20 1:28 ` [Very RFC 39/46] powernv/npu: Avoid pci_dn when mapping device_node to a pci_dev Oliver O'Halloran
2019-11-27 6:58 ` Alexey Kardashevskiy
2019-11-20 1:28 ` [Very RFC 40/46] powernv/npu: Don't drop refcount when looking up GPU pci_devs Oliver O'Halloran
2019-11-27 7:09 ` Alexey Kardashevskiy
2019-11-27 8:24 ` Greg Kurz
2019-11-27 9:10 ` Frederic Barrat
2019-11-27 9:33 ` Greg Kurz
2019-11-27 9:40 ` Oliver O'Halloran
2019-11-27 12:00 ` Greg Kurz
2019-11-27 9:47 ` Frederic Barrat
2019-11-27 12:03 ` Greg Kurz
2019-11-20 1:28 ` [Very RFC 41/46] powernv/eeh: Remove pdn setup for SR-IOV VFs Oliver O'Halloran
2019-11-27 7:14 ` Alexey Kardashevskiy
2019-11-20 1:28 ` [Very RFC 42/46] powernv/pci: Don't clear pdn->pe_number in pnv_pci_release_device Oliver O'Halloran
2019-11-27 7:30 ` Alexey Kardashevskiy
2019-11-20 1:28 ` [Very RFC 43/46] powernv/pci: Do not set pdn->pe_number for NPU/CAPI devices Oliver O'Halloran
2019-11-27 22:49 ` Alexey Kardashevskiy
2019-11-20 1:28 ` [Very RFC 44/46] powerpc/pci: Don't set pdn->pe_number when applying the weird P8 NVLink PE hack Oliver O'Halloran
2019-11-27 22:54 ` Alexey Kardashevskiy
2019-11-20 1:28 ` [Very RFC 45/46] powernv/pci: Remove requirement for a pdn in config accessors Oliver O'Halloran
2019-11-27 23:00 ` Alexey Kardashevskiy
2019-11-20 1:28 ` [Very RFC 46/46] HACK: prevent pdn's from being created Oliver O'Halloran
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20191120012859.23300-16-oohall@gmail.com \
--to=oohall@gmail.com \
--cc=alistair@popple.id.au \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=s.miroshnichenko@yadro.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).