[PATCH 08/11] powerpc/powernv: Replace open coded pnv_ioda_get_pe()s
Reza Arbab
arbab at linux.ibm.com
Thu Oct 31 03:59:57 AEDT 2019
Collapse several open coded instances of pnv_ioda_get_pe().
Signed-off-by: Reza Arbab <arbab at linux.ibm.com>
---
arch/powerpc/platforms/powernv/npu-dma.c | 22 +++++-----------------
arch/powerpc/platforms/powernv/pci-ioda.c | 10 +++-------
2 files changed, 8 insertions(+), 24 deletions(-)
diff --git a/arch/powerpc/platforms/powernv/npu-dma.c b/arch/powerpc/platforms/powernv/npu-dma.c
index a77ce7d71634..0010b21d45b8 100644
--- a/arch/powerpc/platforms/powernv/npu-dma.c
+++ b/arch/powerpc/platforms/powernv/npu-dma.c
@@ -97,24 +97,17 @@ struct pci_dev *pnv_pci_get_npu_dev(struct pci_dev *gpdev, int index)
static struct pnv_ioda_pe *get_gpu_pci_dev_and_pe(struct pnv_ioda_pe *npe,
struct pci_dev **gpdev)
{
- struct pnv_phb *phb;
- struct pci_controller *hose;
struct pci_dev *pdev;
struct pnv_ioda_pe *pe;
- struct pci_dn *pdn;
pdev = pnv_pci_get_gpu_dev(npe->pdev);
if (!pdev)
return NULL;
- pdn = pci_get_pdn(pdev);
- if (WARN_ON(!pdn || pdn->pe_number == IODA_INVALID_PE))
+ pe = pnv_ioda_get_pe(pdev);
+ if (WARN_ON(!pe))
return NULL;
- hose = pci_bus_to_host(pdev->bus);
- phb = hose->private_data;
- pe = &phb->ioda.pe_array[pdn->pe_number];
-
if (gpdev)
*gpdev = pdev;
@@ -261,9 +254,6 @@ static int pnv_npu_dma_set_bypass(struct pnv_ioda_pe *npe)
void pnv_npu_try_dma_set_bypass(struct pci_dev *gpdev, u64 mask)
{
struct pnv_ioda_pe *gpe = pnv_ioda_get_pe(gpdev);
- struct pnv_phb *phb;
- struct pci_dn *pdn;
- struct pnv_ioda_pe *npe;
struct pci_dev *npdev;
bool bypass;
int i = 0;
@@ -275,12 +265,10 @@ void pnv_npu_try_dma_set_bypass(struct pci_dev *gpdev, u64 mask)
bypass = pnv_ioda_pe_iommu_bypass_supported(gpe, mask);
while ((npdev = pnv_pci_get_npu_dev(gpdev, i++))) {
- pdn = pci_get_pdn(npdev);
- if (WARN_ON(!pdn || pdn->pe_number == IODA_INVALID_PE))
- return;
+ struct pnv_ioda_pe *npe = pnv_ioda_get_pe(npdev);
- phb = pci_bus_to_host(npdev->bus)->private_data;
- npe = &phb->ioda.pe_array[pdn->pe_number];
+ if (WARN_ON(!npe))
+ return;
if (bypass) {
dev_info(&npdev->dev,
diff --git a/arch/powerpc/platforms/powernv/pci-ioda.c b/arch/powerpc/platforms/powernv/pci-ioda.c
index 319152d30bc3..6b932cfc0deb 100644
--- a/arch/powerpc/platforms/powernv/pci-ioda.c
+++ b/arch/powerpc/platforms/powernv/pci-ioda.c
@@ -1829,16 +1829,12 @@ static int pnv_pci_ioda_dma_64bit_bypass(struct pnv_ioda_pe *pe)
static bool pnv_pci_ioda_iommu_bypass_supported(struct pci_dev *pdev,
u64 dma_mask)
{
- struct pci_controller *hose = pci_bus_to_host(pdev->bus);
- struct pnv_phb *phb = hose->private_data;
- struct pci_dn *pdn = pci_get_pdn(pdev);
- struct pnv_ioda_pe *pe;
+ struct pnv_ioda_pe *pe = pnv_ioda_get_pe(pdev);
bool bypass;
- if (WARN_ON(!pdn || pdn->pe_number == IODA_INVALID_PE))
+ if (WARN_ON(!pe))
return false;
- pe = &phb->ioda.pe_array[pdn->pe_number];
bypass = pnv_ioda_pe_iommu_bypass_supported(pe, dma_mask);
/*
@@ -1852,7 +1848,7 @@ static bool pnv_pci_ioda_iommu_bypass_supported(struct pci_dev *pdev,
dma_mask > (memory_hotplug_max() + (1ULL << 32)) &&
/* pe->pdev should be set if it's a single device, pe->pbus if not */
(pe->device_count == 1 || !pe->pbus) &&
- phb->model == PNV_PHB_MODEL_PHB3) {
+ pe->phb->model == PNV_PHB_MODEL_PHB3) {
/* Configure the bypass mode */
if (pnv_pci_ioda_dma_64bit_bypass(pe))
return false;
--
1.8.3.1
More information about the Linuxppc-dev
mailing list