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 B27DFC433EF for ; Fri, 1 Jul 2022 13:46:23 +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=fGGq2Q+LCJ6YcFlh5O0F80VoAI2C3IlHNbiqhV80laQ=; b=LBaJglqXRrhI/o 0cxNMupEuJFs/QJIOO92Idh5r5UYv5TtGRma826RfEwk+Bc4sM9gJCVW3kwGhtAwBgFan11ci8gLT Gsn6JX+mtXXmnzcZX6+T2UKVBAnnBegmmPRFsI525yvopVUFBHURrJUGppE7G6/P59ZERvG3SR9Mu MMIaLvzcST0gwBf0IFPMFfqYC8Ggh8hgtJLJGaOzZm2Oxl4V/ZOJu0cKs/Ry3OTD6urYotvIbjZB6 AC+bqRHep666jYngEgcrdRxgtsbV8LHtAGDxqcXnYa6+DQ7xBMqHjj3ailrY3l3R6xQfyM+zbLlsg R8H/SBGfh3a4IO12scjg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1o7GxV-0057zc-V6; Fri, 01 Jul 2022 13:45:22 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1o7GxS-0057xD-2Y for linux-arm-kernel@lists.infradead.org; Fri, 01 Jul 2022 13:45:20 +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 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-Disposition: inline In-Reply-To: <20220623124742.2492164-3-cristian.marussi@arm.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220701_064518_224446_AE92A7D6 X-CRM114-Status: GOOD ( 19.33 ) 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 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 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel