From patchwork Tue Feb 25 05:37:47 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gavin Shan X-Patchwork-Id: 323831 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 D277B2C02FB for ; Tue, 25 Feb 2014 16:41:45 +1100 (EST) Received: by ozlabs.org (Postfix) id AFC8F2C0327; Tue, 25 Feb 2014 16:38:13 +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 D37C02C0310 for ; Tue, 25 Feb 2014 16:38:12 +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:10 -0500 Received: from d01dlp02.pok.ibm.com (9.56.250.167) 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:09 -0500 Received: from b01cxnp22035.gho.pok.ibm.com (b01cxnp22035.gho.pok.ibm.com [9.57.198.25]) by d01dlp02.pok.ibm.com (Postfix) with ESMTP id 8ED276E803C for ; Tue, 25 Feb 2014 00:38:03 -0500 (EST) Received: from d01av01.pok.ibm.com (d01av01.pok.ibm.com [9.56.224.215]) by b01cxnp22035.gho.pok.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id s1P5c8g33801460 for ; Tue, 25 Feb 2014 05:38:08 GMT Received: from d01av01.pok.ibm.com (localhost [127.0.0.1]) by d01av01.pok.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id s1P5c8mH020686 for ; Tue, 25 Feb 2014 00:38:08 -0500 Received: from shangw (shangw.cn.ibm.com [9.125.213.121]) by d01av01.pok.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with SMTP id s1P5c65f020625; Tue, 25 Feb 2014 00:38:06 -0500 Received: by shangw (Postfix, from userid 1000) id 81328302756; Tue, 25 Feb 2014 13:37:54 +0800 (CST) From: Gavin Shan To: linuxppc-dev@ozlabs.org Subject: [PATCH 6/9] powerpc/powernv: Support eeh_ops->event() Date: Tue, 25 Feb 2014 13:37:47 +0800 Message-Id: <1393306670-17435-7-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-00002435EB95 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 implements the backend for eeh_ops->event() on PowerNV platform so that we can allocate or destroy PHB diag-data buffer, which is attached to eeh_pe::data. Signed-off-by: Gavin Shan --- arch/powerpc/platforms/powernv/eeh-powernv.c | 42 +++++++++++++++++++++++++- arch/powerpc/platforms/pseries/eeh_pseries.c | 3 +- 2 files changed, 43 insertions(+), 2 deletions(-) diff --git a/arch/powerpc/platforms/powernv/eeh-powernv.c b/arch/powerpc/platforms/powernv/eeh-powernv.c index a59788e..cfba40a 100644 --- a/arch/powerpc/platforms/powernv/eeh-powernv.c +++ b/arch/powerpc/platforms/powernv/eeh-powernv.c @@ -365,6 +365,45 @@ static int powernv_eeh_restore_config(struct device_node *dn) return 0; } +static int powernv_eeh_event(int event, void *data) +{ + struct eeh_pe *pe = data; + struct pnv_phb *phb; + int ret = 0; + + switch (event) { + case EEH_EVENT_PE_ALLOC: + if (!pe) { + ret = -EINVAL; + break; + } else if (pe->data) { + ret = -EEXIST; + break; + } + + phb = pe->phb->private_data; + if (phb->model == PNV_PHB_MODEL_P7IOC || + phb->model == PNV_PHB_MODEL_PHB3) { + pe->data = kzalloc(PNV_PCI_DIAG_BUF_SIZE, GFP_KERNEL); + if (!pe->data) + ret = -ENOMEM; + } + + break; + case EEH_EVENT_PE_FREE: + if (pe->data) { + kfree(pe->data); + pe->data = NULL; + } + + break; + default: + return 0; + } + + return ret; +} + static struct eeh_ops powernv_eeh_ops = { .name = "powernv", .init = powernv_eeh_init, @@ -381,7 +420,8 @@ static struct eeh_ops powernv_eeh_ops = { .read_config = pnv_pci_cfg_read, .write_config = pnv_pci_cfg_write, .next_error = powernv_eeh_next_error, - .restore_config = powernv_eeh_restore_config + .restore_config = powernv_eeh_restore_config, + .event = powernv_eeh_event }; /** diff --git a/arch/powerpc/platforms/pseries/eeh_pseries.c b/arch/powerpc/platforms/pseries/eeh_pseries.c index 8a8f047..b9a4ddb 100644 --- a/arch/powerpc/platforms/pseries/eeh_pseries.c +++ b/arch/powerpc/platforms/pseries/eeh_pseries.c @@ -691,7 +691,8 @@ static struct eeh_ops pseries_eeh_ops = { .read_config = pseries_eeh_read_config, .write_config = pseries_eeh_write_config, .next_error = NULL, - .restore_config = NULL + .restore_config = NULL, + .event = NULL }; /**