linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Gavin Shan <shangw@linux.vnet.ibm.com>
To: linuxppc-dev@ozlabs.org
Cc: Gavin Shan <shangw@linux.vnet.ibm.com>
Subject: [PATCH 4/9] powerpc/eeh: Introduce eeh_pe_free()
Date: Tue, 25 Feb 2014 13:37:45 +0800	[thread overview]
Message-ID: <1393306670-17435-5-git-send-email-shangw@linux.vnet.ibm.com> (raw)
In-Reply-To: <1393306670-17435-1-git-send-email-shangw@linux.vnet.ibm.com>

The patch introduces eeh_pe_free() to replace original kfree(pe)
so that we could have more checks there and calls to platform
interface supplied by eeh_ops in future.

Signed-off-by: Gavin Shan <shangw@linux.vnet.ibm.com>
---
 arch/powerpc/kernel/eeh_pe.c |   25 +++++++++++++++++++++++--
 1 file changed, 23 insertions(+), 2 deletions(-)

diff --git a/arch/powerpc/kernel/eeh_pe.c b/arch/powerpc/kernel/eeh_pe.c
index f0c353f..2add834 100644
--- a/arch/powerpc/kernel/eeh_pe.c
+++ b/arch/powerpc/kernel/eeh_pe.c
@@ -60,6 +60,27 @@ static struct eeh_pe *eeh_pe_alloc(struct pci_controller *phb, int type)
 }
 
 /**
+ * eeh_pe_free - Free PE
+ * @pe: EEH PE
+ *
+ * Free PE instance dynamically
+ */
+static void eeh_pe_free(struct eeh_pe *pe)
+{
+	if (!pe)
+		return;
+
+	if (!list_empty(&pe->child_list) ||
+	    !list_empty(&pe->edevs)) {
+		pr_warn("%s: PHB#%x-PE#%x has child PE or EEH dev\n",
+			__func__, pe->phb->global_number, pe->addr);
+		return;
+	}
+
+	kfree(pe);
+}
+
+/**
  * eeh_phb_pe_create - Create PHB PE
  * @phb: PCI controller
  *
@@ -374,7 +395,7 @@ int eeh_add_to_parent_pe(struct eeh_dev *edev)
 			pr_err("%s: No PHB PE is found (PHB Domain=%d)\n",
 				__func__, edev->phb->global_number);
 			edev->pe = NULL;
-			kfree(pe);
+			eeh_pe_free(pe);
 			return -EEXIST;
 		}
 	}
@@ -433,7 +454,7 @@ int eeh_rmv_from_parent_pe(struct eeh_dev *edev)
 			if (list_empty(&pe->edevs) &&
 			    list_empty(&pe->child_list)) {
 				list_del(&pe->child);
-				kfree(pe);
+				eeh_pe_free(pe);
 			} else {
 				break;
 			}
-- 
1.7.10.4

  parent reply	other threads:[~2014-02-25  5:38 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-02-25  5:37 [PATCH v2 0/9] EEH improvement Gavin Shan
2014-02-25  5:37 ` [PATCH 1/9] powerpc/eeh: Remove EEH_PE_PHB_DEAD Gavin Shan
2014-02-25  5:37 ` [PATCH 2/9] powerpc/powernv: Remove PNV_EEH_STATE_REMOVED Gavin Shan
2014-02-25  5:37 ` [PATCH 3/9] powerpc/powernv: Move PNV_EEH_STATE_ENABLED around Gavin Shan
2014-02-25  5:37 ` Gavin Shan [this message]
2014-02-25  5:37 ` [PATCH 5/9] powerpc/eeh: Introduce eeh_ops->event() Gavin Shan
2014-02-25  5:37 ` [PATCH 6/9] powerpc/powernv: Support eeh_ops->event() Gavin Shan
2014-02-25  5:37 ` [PATCH 7/9] powerpc/powernv: Cache PHB diag-data Gavin Shan
2014-02-25  5:37 ` [PATCH 8/9] powerpc/powernv: Add /proc/powerpc/eeh_inf_err Gavin Shan
2014-02-25  5:37 ` [PATCH 9/9] powerpc/powernv: Refactor PHB diag-data dump Gavin Shan
2014-02-25  7:26 ` [PATCH v2 0/9] EEH improvement Gavin Shan

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=1393306670-17435-5-git-send-email-shangw@linux.vnet.ibm.com \
    --to=shangw@linux.vnet.ibm.com \
    --cc=linuxppc-dev@ozlabs.org \
    /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).