Received: by 2002:ac0:c50a:0:0:0:0:0 with SMTP id y10csp1296024imi; Fri, 1 Jul 2022 07:00:51 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tFeS0dDJDbzsp+JmjQy/Lqw87d5k2dZLZRQunHKUR2pusr/k+g//YQ3fpMbW9mRoikMinl X-Received: by 2002:a17:907:76b2:b0:726:d02f:dee with SMTP id jw18-20020a17090776b200b00726d02f0deemr14074534ejc.249.1656684050831; Fri, 01 Jul 2022 07:00:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656684050; cv=none; d=google.com; s=arc-20160816; b=iVCQpDNS43pkeOnwtddzKQ4qcbIb3SUyGEAT4i4ru7mcuP4CwA9rMpIyOxltpe/pO2 d99tGVEAgEViS8QZVrHik1VEc5ByXDWUN4hdCLejp3nk/k+ufrH57BPBjcutycbSVP7X V+TAFougD0PxVPFd9oZHWqnGeEz6BWsEP+Qj9jAWi8WoUWLMgv2rn4FoQXS3YV+zOYWD XtEROhCICGHlle8jLOakiv11D1svcgzjuTu+I1yP0ekQh20zIihqIKUvfHoFpEX0qbTY vL/lkepn5FxSg5jHetCvqnncAy2oljo7dVYLuxbSVKQLClxu0zwp+1A0T7EHas2WJJlc 2XPw== 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=uQ/pB9fkZCeAlHmYi3U5cb3pRq+7Wmpz5S6+phjwAO4=; b=ahvZ/yXhSBG+C2pYGyJFumwkumscQ+bkW4SzSWXFBBaNDxupNP5nFyAiJp0VE6GdXp CIZq/xmhRZiiw3lX+6jEiuzIWpEpA6pk+gaYlETtLaxV4qqgqdh4nmWujl0ZrNB/4Q9M cDYuMsljK31YmqksQVXc5eDX9x6M97IOvV+/HcJHobjEDEk6Q7gqWG59v9ciSI02mo5C mPwYpzs3mgr1Q9rRy3Sagf82u9UoKF+hhUg/egcLHUn7Jufl9uOSGN7nHZuvZ9L/zbbX BFhh2Oxjf0hj7mNbx1xIIympM4lT0vrJLFE4nUxCzh4Wvjf7D2f4FnVls4xmktVWZJQu jgPQ== 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 hc39-20020a17090716a700b0072a5c090821si284727ejc.130.2022.07.01.07.00.21; Fri, 01 Jul 2022 07:00:50 -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 S231421AbiGANpd (ORCPT + 99 others); Fri, 1 Jul 2022 09:45:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38156 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231555AbiGANpT (ORCPT ); Fri, 1 Jul 2022 09:45:19 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 0CD1C24958 for ; Fri, 1 Jul 2022 06:45:14 -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 F0490113E; Fri, 1 Jul 2022 06:45:13 -0700 (PDT) Received: from bogus (e103737-lin.cambridge.arm.com [10.1.197.49]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 8F2B53F800; Fri, 1 Jul 2022 06:45:12 -0700 (PDT) Date: Fri, 1 Jul 2022 14:45:09 +0100 From: Sudeep Holla To: Cristian Marussi Cc: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, vincent.guittot@linaro.org, f.fainelli@gmail.com, Sudeep Holla Subject: Re: [PATCH 2/5] firmware: arm_scmi: Support only one single SystemPower device Message-ID: <20220701134509.e6wk3vwhimqre6h5@bogus> References: <20220623124742.2492164-1-cristian.marussi@arm.com> <20220623124742.2492164-3-cristian.marussi@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220623124742.2492164-3-cristian.marussi@arm.com> 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 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); > + 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. -- Regards, Sudeep