From patchwork Tue Feb 25 05:37:45 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gavin Shan X-Patchwork-Id: 323827 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from ozlabs.org (localhost [IPv6:::1]) by ozlabs.org (Postfix) with ESMTP id 260532C03E9 for ; Tue, 25 Feb 2014 16:38:41 +1100 (EST) Received: by ozlabs.org (Postfix) id 857372C0256; Tue, 25 Feb 2014 16:38:11 +1100 (EST) Delivered-To: linuxppc-dev@ozlabs.org Received: from e7.ny.us.ibm.com (e7.ny.us.ibm.com [32.97.182.137]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id C9D9C2C00B9 for ; Tue, 25 Feb 2014 16:38:10 +1100 (EST) Received: from /spool/local by e7.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 25 Feb 2014 00:38:07 -0500 Received: from d01dlp03.pok.ibm.com (9.56.250.168) by e7.ny.us.ibm.com (192.168.1.107) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Tue, 25 Feb 2014 00:38:05 -0500 Received: from b01cxnp22033.gho.pok.ibm.com (b01cxnp22033.gho.pok.ibm.com [9.57.198.23]) by d01dlp03.pok.ibm.com (Postfix) with ESMTP id E4F3AC90040 for ; Tue, 25 Feb 2014 00:38:01 -0500 (EST) Received: from d01av03.pok.ibm.com (d01av03.pok.ibm.com [9.56.224.217]) by b01cxnp22033.gho.pok.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id s1P5c5Hd1507828 for ; Tue, 25 Feb 2014 05:38:05 GMT Received: from d01av03.pok.ibm.com (localhost [127.0.0.1]) by d01av03.pok.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id s1P5c4Y3018322 for ; Tue, 25 Feb 2014 00:38:04 -0500 Received: from shangw (shangw.cn.ibm.com [9.125.213.121]) by d01av03.pok.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with SMTP id s1P5c2Bv018229; Tue, 25 Feb 2014 00:38:03 -0500 Received: by shangw (Postfix, from userid 1000) id 9F1A03026DD; Tue, 25 Feb 2014 13:37:53 +0800 (CST) From: Gavin Shan To: linuxppc-dev@ozlabs.org Subject: [PATCH 4/9] powerpc/eeh: Introduce eeh_pe_free() Date: Tue, 25 Feb 2014 13:37:45 +0800 Message-Id: <1393306670-17435-5-git-send-email-shangw@linux.vnet.ibm.com> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1393306670-17435-1-git-send-email-shangw@linux.vnet.ibm.com> References: <1393306670-17435-1-git-send-email-shangw@linux.vnet.ibm.com> X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 14022505-5806-0000-0000-00002435EB8D Cc: Gavin Shan X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" 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 --- 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; }