Received: by 2002:ac0:c50a:0:0:0:0:0 with SMTP id y10csp1336843imi; Fri, 1 Jul 2022 07:46:00 -0700 (PDT) X-Google-Smtp-Source: AGRyM1uQZW8q30/M4w3Y3xa2Wz4CnjXMACJoUbUZrZhUleAWLJTbxO8Q2V2S878Vp4hP6OJusg43 X-Received: by 2002:a17:902:c94b:b0:16a:6427:ae5d with SMTP id i11-20020a170902c94b00b0016a6427ae5dmr20540240pla.127.1656686760261; Fri, 01 Jul 2022 07:46:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656686760; cv=none; d=google.com; s=arc-20160816; b=w9LB//shpIoi1eV1fpCJ4p2oFaS1wZZB3+XFc/00kGaEhc8Os5nZGMQr7n2vLkyzW3 Hwtm9cz8K0MBG9Gyxgtbmp1S9O2k4F+2D/QA8wokqtwaEgcafwWD//nic4BGptrtbjPQ hFu97sqYUAqVASm/8acI+IAVEAMcIlu7ZLbjnv5eyJ9JjDM+soNoGVJ7Ty98WyHyye1j wiJUI26pKrdDd9ts+MTAZa6KB3AB+JorUgPT6rE4ESZAA3QGw5Etv1xuolK375VwohNP 5/9TAR5B2WGbRJc2bEoMxzl2rNPXax/IGF2YBhcg7hWx1r3S07yXlCr60fdqU3XBWrrB yy6A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=5XG0CPiVBTxig2KUAsfFRUoDNMdT6tAf4zxI1kO6fIw=; b=GUCzVF4LKFHJARaFU5uj6N4mFfYuCykLQcI4c11U/3P+4BvTyZNTX56mjpToxdB8if AImjOMGT/aK3sC9BQu86xts8dtQfCYtWY+GWlkmUHNLdJ+0iLwR4hSvvmNy+C7NqXdDN C1OtYyABbFQGIX+vQr/I+8osK4WqcGPVt10WSQvbA3EV0tQngzeieA+51ut+FRlsih5G ATmECfX2asXeZK7UmItV4tfwVcS2jl247ND9xVb9xrWo+70xoY/n6ib+RbWIZvB5Rnhr IaWvhwN5hHbgLnccfMDQmBFB6QDbZweX5+Kk1jCUk9S32dzYXTDK4AvOhSvTlQ59MraM WnIw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l184-20020a6391c1000000b003fc32f9e5fbsi28861306pge.398.2022.07.01.07.45.48; Fri, 01 Jul 2022 07:46:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231350AbiGAOgz (ORCPT + 99 others); Fri, 1 Jul 2022 10:36:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56620 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232926AbiGAOfu (ORCPT ); Fri, 1 Jul 2022 10:35:50 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id A201F39803 for ; Fri, 1 Jul 2022 07:31:29 -0700 (PDT) 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 9F5BA113E; Fri, 1 Jul 2022 07:31:29 -0700 (PDT) Received: from e120937-lin (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 8E7A93F792; Fri, 1 Jul 2022 07:31:28 -0700 (PDT) Date: Fri, 1 Jul 2022 15:31:18 +0100 From: Cristian Marussi To: Sudeep Holla Cc: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, vincent.guittot@linaro.org, f.fainelli@gmail.com Subject: Re: [PATCH 2/5] firmware: arm_scmi: Support only one single SystemPower device Message-ID: References: <20220623124742.2492164-1-cristian.marussi@arm.com> <20220623124742.2492164-3-cristian.marussi@arm.com> <20220701134509.e6wk3vwhimqre6h5@bogus> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220701134509.e6wk3vwhimqre6h5@bogus> X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jul 01, 2022 at 02:45:09PM +0100, Sudeep Holla wrote: > On Thu, Jun 23, 2022 at 01:47:39PM +0100, Cristian Marussi wrote: > > In order to minimize SCMI platform fw-side complexity, only one single SCMI > > platform should be in charge of SCMI SystemPower protocol communications > > with the OSPM: enforce the existence of one single unique device associated > > with SystemPower protocol across any possible number of SCMI platforms, and > > warn if a system tries to register different SystemPower devices from > > multiple platforms. > > > > Signed-off-by: Cristian Marussi > > --- > > drivers/firmware/arm_scmi/bus.c | 31 ++++++++++++++++++++++++++++++- > > 1 file changed, 30 insertions(+), 1 deletion(-) > > > > diff --git a/drivers/firmware/arm_scmi/bus.c b/drivers/firmware/arm_scmi/bus.c > > index a7cbf4d09081..476855d3dccb 100644 > > --- a/drivers/firmware/arm_scmi/bus.c > > +++ b/drivers/firmware/arm_scmi/bus.c > > @@ -19,6 +19,11 @@ static DEFINE_IDA(scmi_bus_id); > > static DEFINE_IDR(scmi_protocols); > > static DEFINE_SPINLOCK(protocol_lock); > > > > +/* Track globally the creation of SCMI SystemPower related devices */ > > +static bool scmi_syspower_registered; > > +/* Protect access to scmi_syspower_registered */ > > +static DEFINE_MUTEX(scmi_syspower_mtx); > > + > Hi Sudeep, thanks for the review first of all. > Since we create device from the driver, can't we do this from there > and keep the bus code free from handling all these special conditions > which are checked for each device creation. > > Yes scmi_device_create can be called outside the exiting code but since it > is not exported(yet), we can assume all users are in kernel and we can > catch that if anyone attempts to add. And probably we don't need the lock > as well if it is taken care in the single loop creating the device. > Do you mean to move the check inside driver.c common routines like in scmi_get_protocol_device() right before calling scmi_device_create() ? If this is what you meant, yes I can do that to avoid polluting the bus code...indeed it would be easier than dealing with all the internals in scmi_device_create() like it is now, BUT regarding the mutex I'm not so sure I can avoid it since the device creation is triggered at the end of main platform probe (driver:scmi_probe()) BUT potentially also whenever a new SCMI driver is (lately) loaded and asks for the device creation after (or worst concurrently to) the main probe loop. Beside that, there is the case of definitions of multiple SCMI platforms, which is not officially supported I know but that is, in my understanding, one of the most possible cause of having multiple instances of an SCMI SystemPower driver trying to register. (i.e. multiple scmi DT nodes ALL defining a SystemPower protocol with potentially multiple underlying FWs advertising SystemPower support which was the thing we wanted to avoid promoting ... AFAIU...but I could be missing something..) Thanks, Cristian