linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Alexey Kardashevskiy <aik@ozlabs.ru>
To: linuxppc-dev@lists.ozlabs.org
Cc: Alexey Kardashevskiy <aik@ozlabs.ru>,
	David Gibson <david@gibson.dropbear.id.au>,
	Benjamin Herrenschmidt <benh@kernel.crashing.org>,
	Alistair Popple <alistair@popple.id.au>,
	Russell Currey <ruscur@russell.cc>
Subject: [PATCH kernel 5/5] powerpc/eeh: Remove unnecessary node from pci_dn
Date: Wed, 23 Aug 2017 20:19:01 +1000	[thread overview]
Message-ID: <20170823101901.33961-6-aik@ozlabs.ru> (raw)
In-Reply-To: <20170823101901.33961-1-aik@ozlabs.ru>

The pci_dn struct caches a OF device node pointer in order to access
the "ibm,loc-code" property when EEH is recovering.

However, when this happens in eeh_dev_check_failure(), we also have
a pci_dev pointer which should have a valid pointer to the device node
when pci_dn has one (both pointers are not NULL for physical functions
and are NULL for virtual functions).

This removes the node pointer from the pci_dn struct and used pdev
in eeh_dev_check_failure() instead.

This changes pci_remove_device_node_info() to look for a parent of
the node being removed, just like pci_add_device_node_info() does when it
references the parent node.

Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
---
 arch/powerpc/include/asm/pci-bridge.h | 1 -
 arch/powerpc/kernel/eeh.c             | 9 +++++----
 arch/powerpc/kernel/pci_dn.c          | 8 +++++---
 3 files changed, 10 insertions(+), 8 deletions(-)

diff --git a/arch/powerpc/include/asm/pci-bridge.h b/arch/powerpc/include/asm/pci-bridge.h
index 56c67d3f0108..0b8aa1fe2d5f 100644
--- a/arch/powerpc/include/asm/pci-bridge.h
+++ b/arch/powerpc/include/asm/pci-bridge.h
@@ -195,7 +195,6 @@ struct pci_dn {
 	struct  pci_dn *parent;
 	struct  pci_controller *phb;	/* for pci devices */
 	struct	iommu_table_group *table_group;	/* for phb's or bridges */
-	struct	device_node *node;	/* back-pointer to the device_node */
 
 	int	pci_ext_config_space;	/* for pci devices */
 
diff --git a/arch/powerpc/kernel/eeh.c b/arch/powerpc/kernel/eeh.c
index c877014d11ce..2c926029adbe 100644
--- a/arch/powerpc/kernel/eeh.c
+++ b/arch/powerpc/kernel/eeh.c
@@ -435,7 +435,7 @@ int eeh_dev_check_failure(struct eeh_dev *edev)
 	int ret;
 	int active_flags = (EEH_STATE_MMIO_ACTIVE | EEH_STATE_DMA_ACTIVE);
 	unsigned long flags;
-	struct pci_dn *pdn;
+	struct device_node *dn;
 	struct pci_dev *dev;
 	struct eeh_pe *pe, *parent_pe, *phb_pe;
 	int rc = 0;
@@ -493,9 +493,10 @@ int eeh_dev_check_failure(struct eeh_dev *edev)
 	if (pe->state & EEH_PE_ISOLATED) {
 		pe->check_count++;
 		if (pe->check_count % EEH_MAX_FAILS == 0) {
-			pdn = eeh_dev_to_pdn(edev);
-			if (pdn->node)
-				location = of_get_property(pdn->node, "ibm,loc-code", NULL);
+			dn = pci_device_to_OF_node(dev);
+			if (dn)
+				location = of_get_property(dn, "ibm,loc-code",
+						NULL);
 			printk(KERN_ERR "EEH: %d reads ignored for recovering device at "
 				"location=%s driver=%s pci addr=%s\n",
 				pe->check_count,
diff --git a/arch/powerpc/kernel/pci_dn.c b/arch/powerpc/kernel/pci_dn.c
index 0256372b72de..0e395afbf0f4 100644
--- a/arch/powerpc/kernel/pci_dn.c
+++ b/arch/powerpc/kernel/pci_dn.c
@@ -293,7 +293,6 @@ struct pci_dn *pci_add_device_node_info(struct pci_controller *hose,
 	if (pdn == NULL)
 		return NULL;
 	dn->data = pdn;
-	pdn->node = dn;
 	pdn->phb = hose;
 #ifdef CONFIG_PPC_POWERNV
 	pdn->pe_number = IODA_INVALID_PE;
@@ -342,6 +341,7 @@ EXPORT_SYMBOL_GPL(pci_add_device_node_info);
 void pci_remove_device_node_info(struct device_node *dn)
 {
 	struct pci_dn *pdn = dn ? PCI_DN(dn) : NULL;
+	struct device_node *parent;
 #ifdef CONFIG_EEH
 	struct eeh_dev *edev = pdn_to_eeh_dev(pdn);
 
@@ -354,8 +354,10 @@ void pci_remove_device_node_info(struct device_node *dn)
 
 	WARN_ON(!list_empty(&pdn->child_list));
 	list_del(&pdn->list);
-	if (pdn->parent)
-		of_node_put(pdn->parent->node);
+
+	parent = of_get_parent(dn);
+	if (parent)
+		of_node_put(parent);
 
 	dn->data = NULL;
 	kfree(pdn);
-- 
2.11.0

  parent reply	other threads:[~2017-08-23 10:19 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-23 10:18 [PATCH kernel 0/5] powerpc/eeh: Some cleanups Alexey Kardashevskiy
2017-08-23 10:18 ` [PATCH kernel 1/5] powerpc/pci: Remove unused parameter from add_one_dev_pci_data() Alexey Kardashevskiy
2017-08-23 10:18 ` [PATCH kernel 2/5] powerpc/eeh: Reduce to one the number of places where edev is allocated Alexey Kardashevskiy
2017-08-23 10:18 ` [PATCH kernel 3/5] powerpc/eeh: Remove unnecessary pointer to phb from eeh_dev Alexey Kardashevskiy
2017-08-24  4:45   ` Andrew Donnellan
2017-08-28  6:25   ` Michael Ellerman
2017-08-23 10:19 ` [PATCH kernel 4/5] powerpc/eeh: Remove unnecessary config_addr " Alexey Kardashevskiy
2017-08-28  6:27   ` Michael Ellerman
2017-08-23 10:19 ` Alexey Kardashevskiy [this message]
2017-08-28  6:27   ` [PATCH kernel 5/5] powerpc/eeh: Remove unnecessary node from pci_dn Michael Ellerman
2017-08-24  1:13 ` [PATCH kernel 0/5] powerpc/eeh: Some cleanups Russell Currey
2017-08-24  2:19   ` Alexey Kardashevskiy
2017-08-24  5:29     ` Andrew Donnellan
     [not found] ` <20170823102823.7F12CC603E@b03ledav006.gho.boulder.ibm.com>
2017-08-24  4:21   ` [PATCH kernel 1/5] powerpc/pci: Remove unused parameter from add_one_dev_pci_data() Andrew Donnellan
     [not found] ` <20170823101926.03970124035@b01ledav002.gho.pok.ibm.com>
2017-08-24  4:34   ` [PATCH kernel 2/5] powerpc/eeh: Reduce to one the number of places where edev is allocated Andrew Donnellan
     [not found] ` <20170823102546.29A77AE034@b01ledav005.gho.pok.ibm.com>
2017-08-24  4:55   ` [PATCH kernel 4/5] powerpc/eeh: Remove unnecessary config_addr from eeh_dev Andrew Donnellan
     [not found] ` <20170823102629.539BD2803A@b01ledav001.gho.pok.ibm.com>
2017-08-24  5:19   ` [PATCH kernel 5/5] powerpc/eeh: Remove unnecessary node from pci_dn Andrew Donnellan

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=20170823101901.33961-6-aik@ozlabs.ru \
    --to=aik@ozlabs.ru \
    --cc=alistair@popple.id.au \
    --cc=benh@kernel.crashing.org \
    --cc=david@gibson.dropbear.id.au \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=ruscur@russell.cc \
    /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).