Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp3010474rdg; Tue, 17 Oct 2023 01:31:03 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHkH6oDFtrIqmvzc9QXazC6T2zeE4bnvPxwTfrqrzgFYDH9eLTxQ5UQE8jG1TRysEvqCnp5 X-Received: by 2002:a05:6a00:22d1:b0:6be:62e:d5bc with SMTP id f17-20020a056a0022d100b006be062ed5bcmr1996294pfj.3.1697531463513; Tue, 17 Oct 2023 01:31:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697531463; cv=none; d=google.com; s=arc-20160816; b=rClHoN03YPZybO4FsQhbopJsFhgAPOBJmKDiMNQWo9M3MtWhPxJz3x+ccEDceksbOF 7urrRTiWQa9I5VtlUa2NgASRECLO3OEhy7FQlUUIgEI0rVVOLAIKBeSPQU6gyHWnhpi6 9lWbBWTVTTqcl80R9C7pTXlRg/hpUbrx0ACgR5WFg0bAJroBrVpr+Q7TpDT+LXAU7Gd+ zdve/Cz0vsYUhgvNjPz5Rr65ATwkeGCUUgD8Fx28wpPBV6GOGmFmSg/nzbjqGZtMKja6 se/oACTHQDQzU6zo6+9VSD7jrxB8CCvenLf6u1qH5YRVbAcZl3IL+YRxxWxqoTYq/uQc dY0A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=pxbU8VQAzmkVOhUJ/7DgKFkqpOThGFGr8nSN0CTJbY4=; fh=R9s3qQsl3TPlsAXHHObEohsF/8Xm5NaKAroZEGbKQII=; b=Sk6ZDSMB4AKLo5hFxGJsZPZfJQVlzko71vsxZfJgfGwygpozHfyJsMi03f0ALnceut 5ZrkSCa5dLPGIg1l4Dw1+KrOoLjCeqA75ZQ9juHCw4TX+6W5+ZbdsKLB1sfZytbqHYX5 pxNzrhiA2W18T3adXUSOBiVuiuE0zj9QClaLr7dCRfKpcqSkCubBGZ3XvTlqZJKy/stB 0bwAJeCnMjn0LW4eUGMFdGERDz2i7q+H9SU/kFzf/DaULnb2XxK5Hg82jjsUeoczs9EP ox7LanvN1c4yJ6xRzzNPA+dZt9XwxU4k8xbYxC9PNg28dNRrWJMDeVT7isbf2uKlJeQt gvzA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=TNyr1Hx+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id fb21-20020a056a002d9500b006be198b9332si1236448pfb.143.2023.10.17.01.31.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Oct 2023 01:31:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) client-ip=23.128.96.38; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=TNyr1Hx+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 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 (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id 2A937809FA7A; Tue, 17 Oct 2023 01:30:23 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234729AbjJQIaN (ORCPT + 99 others); Tue, 17 Oct 2023 04:30:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38550 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234716AbjJQIaL (ORCPT ); Tue, 17 Oct 2023 04:30:11 -0400 Received: from mail-yb1-xb31.google.com (mail-yb1-xb31.google.com [IPv6:2607:f8b0:4864:20::b31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D3328F2 for ; Tue, 17 Oct 2023 01:30:09 -0700 (PDT) Received: by mail-yb1-xb31.google.com with SMTP id 3f1490d57ef6-d84c24a810dso6344014276.2 for ; Tue, 17 Oct 2023 01:30:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1697531409; x=1698136209; darn=vger.kernel.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=pxbU8VQAzmkVOhUJ/7DgKFkqpOThGFGr8nSN0CTJbY4=; b=TNyr1Hx+F5j9cLPaG6bn+3DVVhVq/UEiFAQqjxVCPzBz4bf+Dn1se1pjvP+t7tj+2S Nt1vcupJfwKDJublCzpgplvBTviw8z+se1acuBgyoDX0Od0RQd+MvBl+DobffGY/wDS8 GT5WxCMYuFFpnrvZTQ6c7l0UlvaY1Ft8jvOb2KXzdnslXjd7S4JiYKvEsPkNOhnBrJIQ cY9ZXbI46Pb3dh+XICjsta8L7l7HqM/EJnxlJagC2CJSc3AL54pJirgOHp4f8uB8CkAD l+TF8wtMFQndWlKSiShGzZDkE8hzvbpn3KW/B3lKV3vAOiSFfxTw/RNng5/J6mG1HSxt SOQw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697531409; x=1698136209; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=pxbU8VQAzmkVOhUJ/7DgKFkqpOThGFGr8nSN0CTJbY4=; b=DU0uEL74oDvQEMhV48HvVvLbcy2B2mrQbryIdSGJJs9wmxRdtP/II8BCGXnirkGrVS xngkDsddfcApQytrLwyDQdR2eUAx1lp7BfW6/oBUQF1UBw+Ytxcbznim5Ht/W7in+gGZ 2kgTKUG74QCdEpEg7FLN6sqkSus1DuPbwAtQIqJW6OKajhuQZfWR88O+1Vnu/i2wjExd 1C1v035ygmpabg1/5RD8Y5TUY3ZuvKZQXF050TmY389dLQpiUYIPsVlIS7Jq94djCV6M dygdeMTVPmE3gDij7GjApsOPWQjP3P4x+0PIaf8FCmeBByQFtEfPbUkd03EyCFUmaBe2 SbCw== X-Gm-Message-State: AOJu0YyY/0B2bRPB8/y7mHbdUHSPBbIfozdBXNeeFMq8Y5vUNbaZenWx /VrDAcoP26nnqX/97/cElYs4y21mFoBGfoo9KgfcqQ== X-Received: by 2002:a25:8a92:0:b0:d9a:bbe1:1b7a with SMTP id h18-20020a258a92000000b00d9abbe11b7amr1291030ybl.50.1697531409028; Tue, 17 Oct 2023 01:30:09 -0700 (PDT) MIME-Version: 1.0 References: <20230828192507.117334-1-bartosz.golaszewski@linaro.org> <20230828192507.117334-4-bartosz.golaszewski@linaro.org> In-Reply-To: From: Bartosz Golaszewski Date: Tue, 17 Oct 2023 10:29:58 +0200 Message-ID: Subject: Re: [PATCH 03/11] firmware: qcom-scm: atomically assign and read the global __scm pointer To: Om Prakash Singh Cc: Andy Gross , Bjorn Andersson , Konrad Dybcio , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Catalin Marinas , Will Deacon , Arnd Bergmann , Alex Elder , Srini Kandagatla , kernel@quicinc.com, linux-arm-msm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, 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 fry.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Tue, 17 Oct 2023 01:30:23 -0700 (PDT) On Tue, 17 Oct 2023 at 10:25, Om Prakash Singh 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 > > --- > > 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); > >