From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id AE5ADC4345F for ; Wed, 17 Apr 2024 12:43:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=zpiV83JAT0IbDpJXha/ZVq1zVwt22FUMHm1NWS/T13w=; b=2M54w5Tp8v6/Me 5Btr29bngBBqRY4z//TBtZ+T5M5UJhfnAhs1pvBr6zsmJX+dbjdckrTgyYtDZDsaArJ8Ij0IiXYOG CUYWMD3MjUMyIL91MzP9VUdK/nIb+ari4xjqQn85kW4b4aODIHe5kIF4WojOdGbaJS/pQtrRskGq9 dZvm0bgiORYll/eQHYMGGis2wycsnDYzh0RQQpD2KgIHSZOzUxKJ4GdCnqqVo99H+h/9/7cSkSKch O2yg6kYFeFLVWYNASW4KM5PQm03xwE61sgcS9oeHowGJDuNT9kDY9apdBC6v8EWiaBLFLORsgz7sG 0y0MrkOaGv/OCUJ0gQCQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rx4cw-0000000Fy3a-2qut; Wed, 17 Apr 2024 12:43:02 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rx4ct-0000000Fy2n-3GNI for linux-arm-kernel@lists.infradead.org; Wed, 17 Apr 2024 12:43:01 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id A77FF339; Wed, 17 Apr 2024 05:43:26 -0700 (PDT) Received: from pluto (usa-sjc-mx-foss1.foss.arm.com [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id D89AE3F738; Wed, 17 Apr 2024 05:42:54 -0700 (PDT) Date: Wed, 17 Apr 2024 13:42:50 +0100 From: Cristian Marussi To: Sudeep Holla Cc: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, james.quinlan@broadcom.com, f.fainelli@gmail.com, vincent.guittot@linaro.org, peng.fan@oss.nxp.com, michal.simek@amd.com, quic_sibis@quicinc.com, konrad.dybcio@linaro.org, souvik.chakravarty@arm.com Subject: Re: [PATCH v2 1/2] firmware: arm_scmi: Add support for multiple vendors custom protocols Message-ID: References: <20240408093052.3801576-1-cristian.marussi@arm.com> <20240408093052.3801576-2-cristian.marussi@arm.com> <20240417123208.criylj2kvdngoswe@bogus> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20240417123208.criylj2kvdngoswe@bogus> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240417_054259_942415_D5B61D27 X-CRM114-Status: GOOD ( 29.40 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Wed, Apr 17, 2024 at 01:32:08PM +0100, Sudeep Holla wrote: > On Mon, Apr 08, 2024 at 10:30:51AM +0100, Cristian Marussi wrote: > > Add a mechanism to be able to tag vendor protocol modules at compile-time > > with a vendor/sub_vendor string and an implementation version and then to > > choose to load, at run-time, only those vendor protocol modules matching > > as close as possible the vendor/subvendor identification advertised by > > the SCMI platform server. > > > > In this way, any in-tree existent vendor protocol module can be build and > > shipped by default in a single kernel image, even when using the same > > clashing protocol identification numbers, since the SCMI core will take > > care at run-time to load only the ones pertinent to the running system. > > > > Signed-off-by: Cristian Marussi > > --- > > drivers/firmware/arm_scmi/driver.c | 165 ++++++++++++++++++++++---- > > drivers/firmware/arm_scmi/protocols.h | 15 +++ > > 2 files changed, 158 insertions(+), 22 deletions(-) > > > > diff --git a/drivers/firmware/arm_scmi/driver.c b/drivers/firmware/arm_scmi/driver.c > > index d0091459a276..aa18202054a5 100644 > > --- a/drivers/firmware/arm_scmi/driver.c > > +++ b/drivers/firmware/arm_scmi/driver.c > > [...] > > > +static const struct scmi_protocol * > > +scmi_vendor_protocol_lookup(int protocol_id, char *vendor_id, > > + char *sub_vendor_id, u32 impl_ver) > > +{ > > + unsigned long key; > > + struct scmi_protocol *proto = NULL; > > + > > + /* Searching for closest match ...*/ > > + key = scmi_protocol_key_calculate(protocol_id, vendor_id, > > + sub_vendor_id, impl_ver); > > + if (key) > > + proto = xa_load(&scmi_protocols, key); > > + > > + if (proto) > > + return proto; > > + > > + /* Any match on vendor/sub_vendor ? */ > > + if (impl_ver) { > > + key = scmi_protocol_key_calculate(protocol_id, vendor_id, > > + sub_vendor_id, 0); > > + if (key) > > + proto = xa_load(&scmi_protocols, key); > > + > > + if (proto) > > + return proto; > > + } > > + > > + /* Any match on just the vendor ? */ > > + if (sub_vendor_id) { > > + key = scmi_protocol_key_calculate(protocol_id, vendor_id, > > + NULL, 0); > > + if (key) > > + proto = xa_load(&scmi_protocols, key); > > + } > > > > I see a pattern here, can be simplify/compress by something like below ? > > static const struct scmi_protocol * > __scmi_vendor_protocol_lookup(int protocol_id, char *vendor_id, > char *sub_vendor_id, u32 impl_ver) > { > unsigned long key; > struct scmi_protocol *proto = NULL; > > key = scmi_protocol_key_calculate(protocol_id, vendor_id, > sub_vendor_id, impl_ver); > if (key) > proto = xa_load(&scmi_protocols, key); > > return proto; > } Sure...was not completely sure to proceed that way because only 2 lines were saved for a each block....bit indeed is more clear...I'll d in V3 > > [...] > > > diff --git a/drivers/firmware/arm_scmi/protocols.h b/drivers/firmware/arm_scmi/protocols.h > > index 317d3fb32676..45ee8b35f56d 100644 > > --- a/drivers/firmware/arm_scmi/protocols.h > > +++ b/drivers/firmware/arm_scmi/protocols.h > > @@ -29,6 +29,8 @@ > > #define PROTOCOL_REV_MAJOR(x) ((u16)(FIELD_GET(PROTOCOL_REV_MAJOR_MASK, (x)))) > > #define PROTOCOL_REV_MINOR(x) ((u16)(FIELD_GET(PROTOCOL_REV_MINOR_MASK, (x)))) > > > > +#define SCMI_PROTOCOL_VENDOR 0x80 > > + > > s/SCMI_PROTOCOL_VENDOR/SCMI_PROTOCOL_VENDOR_BASE/ > > as I expect 0x80 to be used by most vendors. > I'll do. Thanks for the review. Cristian _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel