linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Michael Neuling <mikey@neuling.org>
To: mpe@ellerman.id.au, benh@kernel.crashing.org
Cc: imunsie@au.ibm.com, linuxppc-dev@ozlabs.org, mikey@neuling.org,
	Daniel Axtens <dja@axtens.net>,
	"Matthew R. Ochs" <mrochs@linux.vnet.ibm.com>,
	"Manoj N. Kumar" <manoj@linux.vnet.ibm.com>,
	brking@linux.vnet.ibm.com
Subject: [PATCH v2 05/21] powerpc/pci: Add shutdown hook to pci_controller_ops
Date: Tue, 26 May 2015 10:20:02 +1000	[thread overview]
Message-ID: <1432599618-26844-6-git-send-email-mikey@neuling.org> (raw)
In-Reply-To: <1432599618-26844-1-git-send-email-mikey@neuling.org>

Currently pnv_pci_shutdown() calls the PHB shutdown code for all PHBs in the
system.  It dereferences the private_data assuming it's a powernv PHB, which
won't be the case when we have different PHB in the systems (like when we add
vPHBs for CXL).

This moves the shutdown hook to the pci_controller_ops and fixes the call site
to use that instead.

Signed-off-by: Michael Neuling <mikey@neuling.org>
---
 arch/powerpc/include/asm/pci-bridge.h     | 2 ++
 arch/powerpc/platforms/powernv/pci-ioda.c | 8 ++++----
 arch/powerpc/platforms/powernv/pci.c      | 9 +++------
 arch/powerpc/platforms/powernv/pci.h      | 1 -
 4 files changed, 9 insertions(+), 11 deletions(-)

diff --git a/arch/powerpc/include/asm/pci-bridge.h b/arch/powerpc/include/asm/pci-bridge.h
index 4cf0caa..3947749 100644
--- a/arch/powerpc/include/asm/pci-bridge.h
+++ b/arch/powerpc/include/asm/pci-bridge.h
@@ -40,6 +40,8 @@ struct pci_controller_ops {
 #endif
 
 	int             (*dma_set_mask)(struct pci_dev *dev, u64 dma_mask);
+
+	void		(*shutdown)(struct pci_controller *);
 };
 
 /*
diff --git a/arch/powerpc/platforms/powernv/pci-ioda.c b/arch/powerpc/platforms/powernv/pci-ioda.c
index bb3c0c4..2eaf6f7 100644
--- a/arch/powerpc/platforms/powernv/pci-ioda.c
+++ b/arch/powerpc/platforms/powernv/pci-ioda.c
@@ -2645,8 +2645,10 @@ static u32 pnv_ioda_bdfn_to_pe(struct pnv_phb *phb, struct pci_bus *bus,
 	return phb->ioda.pe_rmap[(bus->number << 8) | devfn];
 }
 
-static void pnv_pci_ioda_shutdown(struct pnv_phb *phb)
+static void pnv_pci_ioda_shutdown(struct pci_controller *hose)
 {
+	struct pnv_phb *phb = hose->private_data;
+
 	opal_pci_reset(phb->opal_id, OPAL_RESET_PCI_IODA_TABLE,
 		       OPAL_ASSERT_RESET);
 }
@@ -2796,9 +2798,6 @@ static void __init pnv_pci_init_ioda_phb(struct device_node *np,
 	phb->dma_dev_setup = pnv_pci_ioda_dma_dev_setup;
 	phb->dma_get_required_mask = pnv_pci_ioda_dma_get_required_mask;
 
-	/* Setup shutdown function for kexec */
-	phb->shutdown = pnv_pci_ioda_shutdown;
-
 	/* Setup MSI support */
 	pnv_pci_init_ioda_msis(phb);
 
@@ -2879,4 +2878,5 @@ static const struct pci_controller_ops pnv_pci_ioda_controller_ops = {
        .window_alignment = pnv_pci_window_alignment,
        .reset_secondary_bus = pnv_pci_reset_secondary_bus,
        .dma_set_mask = pnv_pci_ioda_dma_set_mask,
+       .shutdown = pnv_pci_ioda_shutdown,
 };
diff --git a/arch/powerpc/platforms/powernv/pci.c b/arch/powerpc/platforms/powernv/pci.c
index acc0ced..1614d79 100644
--- a/arch/powerpc/platforms/powernv/pci.c
+++ b/arch/powerpc/platforms/powernv/pci.c
@@ -704,12 +704,9 @@ void pnv_pci_shutdown(void)
 {
 	struct pci_controller *hose;
 
-	list_for_each_entry(hose, &hose_list, list_node) {
-		struct pnv_phb *phb = hose->private_data;
-
-		if (phb && phb->shutdown)
-			phb->shutdown(phb);
-	}
+	list_for_each_entry(hose, &hose_list, list_node)
+		if (hose->controller_ops.shutdown)
+			hose->controller_ops.shutdown(hose);
 }
 
 /* Fixup wrong class code in p7ioc and p8 root complex */
diff --git a/arch/powerpc/platforms/powernv/pci.h b/arch/powerpc/platforms/powernv/pci.h
index 60bb935..7edb54f5 100644
--- a/arch/powerpc/platforms/powernv/pci.h
+++ b/arch/powerpc/platforms/powernv/pci.h
@@ -110,7 +110,6 @@ struct pnv_phb {
 				     struct pci_dev *pdev);
 	void (*fixup_phb)(struct pci_controller *hose);
 	u32 (*bdfn_to_pe)(struct pnv_phb *phb, struct pci_bus *bus, u32 devfn);
-	void (*shutdown)(struct pnv_phb *phb);
 	int (*init_m64)(struct pnv_phb *phb);
 	void (*reserve_m64_pe)(struct pnv_phb *phb);
 	int (*pick_m64_pe)(struct pnv_phb *phb, struct pci_bus *bus, int all);
-- 
2.1.0

  parent reply	other threads:[~2015-05-26  0:21 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-26  0:19 [PATCH v2 00/21] cxl: Add AFU virtual PHB and in kernel API Michael Neuling
2015-05-26  0:19 ` [PATCH v2 01/21] powerpc/copro: Fix faulting kernel segments Michael Neuling
2015-05-26  0:19 ` [PATCH v2 02/21] powerpc/pci: Export symbols for CXL Michael Neuling
2015-05-26  0:20 ` [PATCH v2 03/21] powerpc/pci: Add release_device() hook to phb ops Michael Neuling
2015-05-26  0:20 ` [PATCH v2 04/21] powerpc: Add cxl context to device archdata Michael Neuling
2015-05-26  0:20 ` Michael Neuling [this message]
2015-05-26  0:20 ` [PATCH v2 06/21] cxl: Document external user of existing API Michael Neuling
2015-05-26  0:20 ` [PATCH v2 07/21] cxl: Add shutdown hook Michael Neuling
2015-05-26  0:20 ` [PATCH v2 08/21] cxl: Re-order card init to check the VSEC earlier Michael Neuling
2015-05-26  0:20 ` [PATCH v2 09/21] cxl: Dump debug info on the AFU configuration record Michael Neuling
2015-05-26  0:20 ` [PATCH v2 10/21] cxl: Add cookie parameter to afu_release_irqs() Michael Neuling
2015-05-26  0:20 ` [PATCH v2 11/21] cxl: Rework detach context functions Michael Neuling
2015-05-26  0:20 ` [PATCH v2 12/21] cxl: cxl_afu_reset() -> __cxl_afu_reset() Michael Neuling
2015-05-26  0:20 ` [PATCH v2 13/21] cxl: Export some symbols Michael Neuling
2015-05-26  0:20 ` [PATCH v2 14/21] cxl: Only check pid for userspace contexts Michael Neuling
2015-05-26  0:20 ` [PATCH v2 15/21] cxl: Split afu_register_irqs() function Michael Neuling
2015-05-26  0:20 ` [PATCH v2 16/21] cxl: Configure PSL for kernel contexts and merge code Michael Neuling
2015-05-26  0:20 ` [PATCH v2 17/21] cxl: Rework context lifetimes Michael Neuling
2015-05-26  0:20 ` [PATCH v2 18/21] cxl: Cleanup Makefile Michael Neuling
2015-05-26  0:20 ` [PATCH v2 19/21] cxl: Move include file cxl.h -> cxl-base.h Michael Neuling
2015-05-26  0:20 ` [PATCH v2 20/21] cxl: Export file ops for use by API Michael Neuling
2015-05-26  0:20 ` [PATCH v2 21/21] cxl: Add AFU virtual PHB and kernel API Michael Neuling

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=1432599618-26844-6-git-send-email-mikey@neuling.org \
    --to=mikey@neuling.org \
    --cc=benh@kernel.crashing.org \
    --cc=brking@linux.vnet.ibm.com \
    --cc=dja@axtens.net \
    --cc=imunsie@au.ibm.com \
    --cc=linuxppc-dev@ozlabs.org \
    --cc=manoj@linux.vnet.ibm.com \
    --cc=mpe@ellerman.id.au \
    --cc=mrochs@linux.vnet.ibm.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).