From patchwork Thu Feb 15 21:55:24 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Bringmann X-Patchwork-Id: 874155 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3zj9DJ6q8Fz9t2c for ; Fri, 16 Feb 2018 08:59:44 +1100 (AEDT) Received: from bilbo.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 3zj9DJ5lQjzF1Ml for ; Fri, 16 Feb 2018 08:59:44 +1100 (AEDT) X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=linux.vnet.ibm.com (client-ip=148.163.156.1; helo=mx0a-001b2d01.pphosted.com; envelope-from=mwb@linux.vnet.ibm.com; receiver=) Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 3zj98K30RWzF1MG for ; Fri, 16 Feb 2018 08:56:17 +1100 (AEDT) Received: from pps.filterd (m0098399.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w1FLsZYG129525 for ; Thu, 15 Feb 2018 16:56:15 -0500 Received: from e31.co.us.ibm.com (e31.co.us.ibm.com [32.97.110.149]) by mx0a-001b2d01.pphosted.com with ESMTP id 2g5cvn60cn-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Thu, 15 Feb 2018 16:56:11 -0500 Received: from localhost by e31.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 15 Feb 2018 14:56:11 -0700 Received: from b03cxnp07028.gho.boulder.ibm.com (9.17.130.15) by e31.co.us.ibm.com (192.168.1.131) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Thu, 15 Feb 2018 14:56:09 -0700 Received: from b03ledav004.gho.boulder.ibm.com (b03ledav004.gho.boulder.ibm.com [9.17.130.235]) by b03cxnp07028.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w1FLu76l8520044; Thu, 15 Feb 2018 14:56:07 -0700 Received: from b03ledav004.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 5627378041; Thu, 15 Feb 2018 14:56:07 -0700 (MST) Received: from oc5000245537.ibm.com (unknown [9.53.92.192]) by b03ledav004.gho.boulder.ibm.com (Postfix) with ESMTP id AC5607803F; Thu, 15 Feb 2018 14:56:06 -0700 (MST) From: Michael Bringmann Organization: IBM Linux Technology Center To: linuxppc-dev@lists.ozlabs.org Subject: [RFC 2/4] powerpc/hotplug/drcinfo: Provide common parser for ibm,drc-info In-Reply-To: <531f98fb-a29b-53e2-e7d5-870a531b76fd@linux.vnet.ibm.com> Date: Thu, 15 Feb 2018 15:55:24 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 MIME-Version: 1.0 Content-Language: en-US X-TM-AS-GCONF: 00 x-cbid: 18021521-8235-0000-0000-00000D06B463 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00008539; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000253; SDB=6.00990257; UDB=6.00502892; IPR=6.00769605; MB=3.00019576; MTD=3.00000008; XFM=3.00000015; UTC=2018-02-15 21:56:10 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18021521-8236-0000-0000-00003FB29231 Message-Id: <5301d563-fdd8-1ec5-7f9b-2ed74af09199@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2018-02-15_10:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 impostorscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1709140000 definitions=main-1802150263 X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Nathan Fontenot , Michael Bringmann , Thomas Falcon , Tyrel Datwyler , John Allen Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" This patch provides a common parse function for the ibm,drc-info property that can be modified by a callback function. The caller provides a pointer to the function and a pointer to their unique data, and the parser provides the current lmb set from the struct. The callback function may return codes indicating that the parsing is complete, or should continue, along with an error code that may be returned to the caller. Signed-off-by: Michael Bringmann Fixes: 3f38000eda48 ("powerpc/firmware: Add definitions for new drc-info firmwar e feature" -- end of patch series applied to powerpc next) --- arch/powerpc/include/asm/prom.h | 7 +++ arch/powerpc/platforms/pseries/Makefile | 2 - arch/powerpc/platforms/pseries/drchelpers.c | 66 +++++++++++++++++++++++++++ 3 files changed, 74 insertions(+), 1 deletion(-) create mode 100644 arch/powerpc/platforms/pseries/drchelpers.c diff --git a/arch/powerpc/include/asm/prom.h b/arch/powerpc/include/asm/prom.h index 7db7958..e75963e 100644 --- a/arch/powerpc/include/asm/prom.h +++ b/arch/powerpc/include/asm/prom.h @@ -94,6 +94,13 @@ struct of_drc_info { extern int of_read_drc_info_cell(struct property **prop, const __be32 **curval, struct of_drc_info *data); +extern int drc_info_parser(struct device_node *dn, + int (*usercb)(struct of_drc_info *drc, + void *data, + void *optional_data, + int *ret_code), + char *opt_drc_type, + void *data); /* * There are two methods for telling firmware what our capabilities are. diff --git a/arch/powerpc/platforms/pseries/Makefile b/arch/powerpc/platforms/pseries/Makefile index 13eede6..38c8547 100644 --- a/arch/powerpc/platforms/pseries/Makefile +++ b/arch/powerpc/platforms/pseries/Makefile @@ -3,7 +3,7 @@ ccflags-$(CONFIG_PPC64) := $(NO_MINIMAL_TOC) ccflags-$(CONFIG_PPC_PSERIES_DEBUG) += -DDEBUG obj-y := lpar.o hvCall.o nvram.o reconfig.o \ - of_helpers.o \ + of_helpers.o drchelpers.o \ setup.o iommu.o event_sources.o ras.o \ firmware.o power.o dlpar.o mobility.o rng.o \ pci.o pci_dlpar.o eeh_pseries.o msi.o diff --git a/arch/powerpc/platforms/pseries/drchelpers.c b/arch/powerpc/platforms/pseries/drchelpers.c new file mode 100644 index 0000000..556e05d --- /dev/null +++ b/arch/powerpc/platforms/pseries/drchelpers.c @@ -0,0 +1,66 @@ +/* + * Copyright (C) 2018 Michael Bringmann , IBM + * + * pSeries specific routines for device-tree properties. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include +#include +#include +#include +#include + +#include +#include "pseries.h" + +#define MAX_DRC_NAME_LEN 64 + +int drc_info_parser(struct device_node *dn, + int (*usercb)(struct of_drc_info *drc, + void *data, + void *optional_data, + int *ret_code), + char *opt_drc_type, + void *data) +{ + struct property *info; + unsigned int entries; + struct of_drc_info drc; + const __be32 *value; + int j, done = 0, ret_code = -EINVAL; + + info = of_find_property(dn, "ibm,drc-info", NULL); + if (info == NULL) + return -EINVAL; + + value = of_prop_next_u32(info, NULL, &entries); + if (!value) + return -EINVAL; + value++; + + for (j = 0, done = 0; (j < entries) && (!done); j++) { + of_read_drc_info_cell(&info, &value, &drc); + + if (opt_drc_type && strcmp(opt_drc_type, drc.drc_type)) + continue; + + done = usercb(&drc, data, NULL, &ret_code); + } + + return ret_code; +} +EXPORT_SYMBOL(drc_info_parser);