Message ID | 20230828192507.117334-4-bartosz.golaszewski@linaro.org |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a7d1:0:b0:3f2:4152:657d with SMTP id p17csp3560322vqm; Mon, 28 Aug 2023 13:20:04 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGS9XIqM3MSa1mYTUmpf/SWB6SU73sM3uEOAGieJkHKWp/8NERa3HNOUCl8mDkvgz+pdWeE X-Received: by 2002:a05:6402:f83:b0:528:9284:61c6 with SMTP id eh3-20020a0564020f8300b00528928461c6mr858811edb.0.1693254004146; Mon, 28 Aug 2023 13:20:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1693254004; cv=none; d=google.com; s=arc-20160816; b=EwRi46WqFRuGalKyeGeXkXCpMyiMnZtqIMC7UKbzN4cn+fHAObaR33+UeSHAd7sT6P Ly5DxC1ZeSW0v2982zRcLtnZ8+WN1VBSXajAjfbtv/1Mgf/00Zj0/ymZ0j57up/nRHDF 2VGbHwFRnoMIkpsAFJ6Ji9qcvtI72LnGLzZizVSTtc3M6KG7+C1Ej7i2+yZQe5RsY44b QT2Ko0g9vcN2nZDDPOs4c+K+xLIjUWRouRJT70UXzHw3PI+JIc+zKHSa2DhFLz0Ma+a/ wXG0q33V/57OixnfJw3EceEh2GjH/tC5fV3GONv2X5mmzCztxOn6h9QUUC20l/zq3YXq oXng== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=713tM2MtTN06BKtmpTKPtHYKAypTeU06f4AnOlNhYD4=; fh=aaoGrQyLgrtQ+6iazCDQb4ud5OHZi1mHDJ1RfYqBIV8=; b=WcpBhr3vniPrNKnwdHrKnb9OSDJGOiS2uPf1d4zN32HY7CZmEuO9oGj+SdZNNZ9luw evmxx2ZrN+/JKhzWiK/hiZbwYyUSsPphwqOPvfecGVmvJ4m505Nc/zGxNWx7viFvsDhC EtTOte809JzrrEdS9LHnMRq4LIIV+bhojZxi3CdALnu2uTGqjzxVLHu6myLBV763Xcy+ fgHdBJMajIcCXXuSxoQNYnq7hbDrIL3MkGrIKgdXnqoS+tXeLl9IH52SpkRfEUcNM5zH 284O1cU7nqKYuZ1GjBalb6h46BgVyqc3FvLzX0hBFXK/2DuaZsC+qSgPdGzFkKYq6Lf6 7RpA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=CSqa+pEo; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f5-20020a056402160500b0052971365560si3291945edv.413.2023.08.28.13.19.23; Mon, 28 Aug 2023 13:20:04 -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; dkim=pass header.i=@linaro.org header.s=google header.b=CSqa+pEo; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233478AbjH1T2M (ORCPT <rfc822;kiss.andras.p@gmail.com> + 99 others); Mon, 28 Aug 2023 15:28:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59978 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233269AbjH1T1b (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Mon, 28 Aug 2023 15:27:31 -0400 Received: from mail-wm1-x32b.google.com (mail-wm1-x32b.google.com [IPv6:2a00:1450:4864:20::32b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 60D9ACD8 for <linux-kernel@vger.kernel.org>; Mon, 28 Aug 2023 12:27:07 -0700 (PDT) Received: by mail-wm1-x32b.google.com with SMTP id 5b1f17b1804b1-401d2e11dacso1808535e9.0 for <linux-kernel@vger.kernel.org>; Mon, 28 Aug 2023 12:27:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1693250826; x=1693855626; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=713tM2MtTN06BKtmpTKPtHYKAypTeU06f4AnOlNhYD4=; b=CSqa+pEoDUW2H0ZlraiWwUc3xrWOrJ1YaHmkjhFa1p/azSB734HWr7cU7e+myIPnxY qDsDy9RJtc6PWOZi806K/E6XsRbqhVy78B/oFwKTyW+g05lo+dhP4G62hGqrlQ641ZRU P8VP6sbAPFh7XXebDCKtOJ70udNb6SwiNfDapAw4WM4QHiBs1L6MYTO4T/+WXxLsQzk0 zIDoQGuZovksV9kVbawJ4xMgU2RlWI4uFaqB0yceUpKqZgcbSbYm5R1v8e88gGNG0KjH a5g9KaWoA3XNQ1D9zdItbOL4waj9PwpuPKgLNZQMhF8maGHr7j0ai4dCzdIUHby5GJf2 Rccg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693250826; x=1693855626; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=713tM2MtTN06BKtmpTKPtHYKAypTeU06f4AnOlNhYD4=; b=gTf1wAF/4WGenaCzv/ptfQgVaC2Tji+LUE5kE9D8rft0U4yh7gA+JbfpNarwZrGE1a jMCzZQ/kmkqpk1oR6w+SwE3Ih5rog6b+E/VrXIgCF6A0i4yvuFhjML1hvVD9sGY92jkP z9fwWYJQLoymrLsUf8r9y7TGiENscW9G92TLxy95awG9ylGZv8zxMJgKev2OgqfBtL1J Cskr+g4cmaAy0G1KE+GSVWtE0j9G9b+dzex3BYwUlimjF4rRQBlVht4MNvIvu9P8mXfL 8MHbKPs1r/YWVvH6DD7e7e2TxTlATr4MIVSosG5r7vOdRghDuTlc/+SBxKXc3t3dJO92 np2w== X-Gm-Message-State: AOJu0YzHIuWsXMFUsuIVfCiBwsoh+KaMTqoA6xL58yDYVpdTw94S2Zr7 kCs9ILsN/fQF55lVOS+lGQz9oQ== X-Received: by 2002:adf:e682:0:b0:319:8c99:989a with SMTP id r2-20020adfe682000000b003198c99989amr369735wrm.8.1693250825898; Mon, 28 Aug 2023 12:27:05 -0700 (PDT) Received: from brgl-uxlite.home ([2a01:cb1d:334:ac00:8bd:7f16:d368:115f]) by smtp.gmail.com with ESMTPSA id i20-20020a5d5234000000b003141f96ed36sm11435319wra.0.2023.08.28.12.27.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Aug 2023 12:27:05 -0700 (PDT) From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org> To: Andy Gross <agross@kernel.org>, Bjorn Andersson <andersson@kernel.org>, Konrad Dybcio <konrad.dybcio@linaro.org>, Rob Herring <robh+dt@kernel.org>, Krzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org>, Conor Dooley <conor+dt@kernel.org>, Catalin Marinas <catalin.marinas@arm.com>, Will Deacon <will@kernel.org>, Arnd Bergmann <arnd@arndb.de>, Alex Elder <elder@linaro.org>, Srini Kandagatla <srinivas.kandagatla@linaro.org> Cc: kernel@quicinc.com, linux-arm-msm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Bartosz Golaszewski <bartosz.golaszewski@linaro.org> Subject: [PATCH 03/11] firmware: qcom-scm: atomically assign and read the global __scm pointer Date: Mon, 28 Aug 2023 21:24:59 +0200 Message-Id: <20230828192507.117334-4-bartosz.golaszewski@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230828192507.117334-1-bartosz.golaszewski@linaro.org> References: <20230828192507.117334-1-bartosz.golaszewski@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=unavailable 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1775505510428335284 X-GMAIL-MSGID: 1775505510428335284 |
Series |
[01/11] firmware: qcom-scm: drop unneeded 'extern' specifiers
|
|
Commit Message
Bartosz Golaszewski
Aug. 28, 2023, 7:24 p.m. UTC
Checking for the availability of SCM bridge can happen from any context.
It's only by chance that we haven't run into concurrency issues but with
the upcoming SHM Bridge driver that will be initiated at the same
initcall level, we need to assure the assignment and readback of the
__scm pointer is atomic.
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
---
drivers/firmware/qcom_scm.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
Comments
On 8/29/2023 12:54 AM, Bartosz Golaszewski wrote: > Checking for the availability of SCM bridge can happen from any context. > It's only by chance that we haven't run into concurrency issues but with > the upcoming SHM Bridge driver that will be initiated at the same > initcall level, we need to assure the assignment and readback of the > __scm pointer is atomic. > > Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org> > --- > drivers/firmware/qcom_scm.c | 6 +++--- > 1 file changed, 3 insertions(+), 3 deletions(-) > > diff --git a/drivers/firmware/qcom_scm.c b/drivers/firmware/qcom_scm.c > index 980fcfa20b9f..422de70faff8 100644 > --- a/drivers/firmware/qcom_scm.c > +++ b/drivers/firmware/qcom_scm.c > @@ -1331,7 +1331,7 @@ static int qcom_scm_find_dload_address(struct device *dev, u64 *addr) > */ > bool qcom_scm_is_available(void) > { > - return !!__scm; > + return !!READ_ONCE(__scm); > } > EXPORT_SYMBOL(qcom_scm_is_available); > > @@ -1477,8 +1477,8 @@ static int qcom_scm_probe(struct platform_device *pdev) > if (ret) > return ret; > > - __scm = scm; > - __scm->dev = &pdev->dev; > + scm->dev = &pdev->dev; > + WRITE_ONCE(__scm, scm); In my opinion "__scm = scm;" assignment should be done at the end of probe function success so that qcom_scm_is_available() return true only when probe is completed. Other changes may not be needed. > init_completion(&__scm->waitq_comp); >
On Tue, 17 Oct 2023 at 10:25, Om Prakash Singh <quic_omprsing@quicinc.com> wrote: > > > > On 8/29/2023 12:54 AM, Bartosz Golaszewski wrote: > > Checking for the availability of SCM bridge can happen from any context. > > It's only by chance that we haven't run into concurrency issues but with > > the upcoming SHM Bridge driver that will be initiated at the same > > initcall level, we need to assure the assignment and readback of the > > __scm pointer is atomic. > > > > Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org> > > --- > > drivers/firmware/qcom_scm.c | 6 +++--- > > 1 file changed, 3 insertions(+), 3 deletions(-) > > > > diff --git a/drivers/firmware/qcom_scm.c b/drivers/firmware/qcom_scm.c > > index 980fcfa20b9f..422de70faff8 100644 > > --- a/drivers/firmware/qcom_scm.c > > +++ b/drivers/firmware/qcom_scm.c > > @@ -1331,7 +1331,7 @@ static int qcom_scm_find_dload_address(struct device *dev, u64 *addr) > > */ > > bool qcom_scm_is_available(void) > > { > > - return !!__scm; > > + return !!READ_ONCE(__scm); > > } > > EXPORT_SYMBOL(qcom_scm_is_available); > > > > @@ -1477,8 +1477,8 @@ static int qcom_scm_probe(struct platform_device *pdev) > > if (ret) > > return ret; > > > > - __scm = scm; > > - __scm->dev = &pdev->dev; > > + scm->dev = &pdev->dev; > > + WRITE_ONCE(__scm, scm); > > In my opinion "__scm = scm;" assignment should be done at the end of > probe function success so that qcom_scm_is_available() return true only > when probe is completed. > > Other changes may not be needed. > Om, this is v1. We're at v4 (soon v5). I agree with the comment but it's outside the scope of this series. I may address it later. It has been like this for a long time. Typically this module is built-in and initialized before all other drivers so it has never caused problems. Bart > > init_completion(&__scm->waitq_comp); > >
diff --git a/drivers/firmware/qcom_scm.c b/drivers/firmware/qcom_scm.c index 980fcfa20b9f..422de70faff8 100644 --- a/drivers/firmware/qcom_scm.c +++ b/drivers/firmware/qcom_scm.c @@ -1331,7 +1331,7 @@ static int qcom_scm_find_dload_address(struct device *dev, u64 *addr) */ bool qcom_scm_is_available(void) { - return !!__scm; + return !!READ_ONCE(__scm); } EXPORT_SYMBOL(qcom_scm_is_available); @@ -1477,8 +1477,8 @@ static int qcom_scm_probe(struct platform_device *pdev) if (ret) return ret; - __scm = scm; - __scm->dev = &pdev->dev; + scm->dev = &pdev->dev; + WRITE_ONCE(__scm, scm); init_completion(&__scm->waitq_comp);