Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp3008527rdg; Tue, 17 Oct 2023 01:25:40 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGtZXtZdcLPuqdSYRRpJkA2dSdw2T2C8ZchfIcwfBzyynphtjCChs6fsyueqFrJgqDtjy7u X-Received: by 2002:a17:903:6c4:b0:1c9:97b7:b3cc with SMTP id kj4-20020a17090306c400b001c997b7b3ccmr1100893plb.47.1697531140384; Tue, 17 Oct 2023 01:25:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697531140; cv=none; d=google.com; s=arc-20160816; b=g5lRK7+hvpenfOuv3wwORTbydCcI2oPw36bLS+M2YNseRsY7TFrrGJl8QaDsxweXtm 0Y/4/pLv6HcswSjsUYrMbaII2HvJWpY9DRlrY1ivab31ZYive/AvT7+PKW5sdG+lqvPp 0uetsEmjGfGjKQWL6bJ6dxWdd2GT0dI5tz3M6d2067Gh7YMjmBk+459/l+8ib5CZ+5hs FJnXhzWgERctQrHNcHYJCfeei3TZQRdUXcNYcRco2oyiKU2hNH/IZlueeT9/yPtMxjIR IuVT3J829VjoRLX69LTN9aJeSrrCbbYBLQVAaqeHQpbtb8Z6B0lEgrOMjNGsCsZXakFR Je8Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=abG+EPXB6BECKL9u/q4R7dYvCyUAXCa41Z+B12FQpWI=; fh=uQUsUEOSmhwhJcMyVYfZ2fUSnbeTC9rwYGND5isvZLY=; b=LXszU2R/Q5Z570tJ6g5KpQ4Ak2DnjcXcwBnOeQHPXEGFXzrvOszWmO8mDseHA3O2Ez +cuF2JcjhBTsnM0d61eW8E/4bFJxtvMSz2TrY+wZRSFxRmCEnxGDMwkguAr4E9SEw+Jw k7svCX6Ad3nAdBdT/axSuuHkt0836/kk/ytKqZxzcTjGs31ag8MzHvUCFrV76E+G1d/x OigGs22rgo+GbCJ1EhtitPnMaI/SV73oM0GiTtx1HJdys1L3FUtn+LqPCYW4npt/z3Vj 88WqBu/Mf27tnrkafnK6SUeS1RCP3DRm/+sDCMYsupq+ImUvjYduLBNI1aBGZRDRlBxI YOJw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=RCBaenzL; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Return-Path: Received: from groat.vger.email (groat.vger.email. [2620:137:e000::3:5]) by mx.google.com with ESMTPS id a9-20020a1709027d8900b001c9fb3b55f0si1199903plm.652.2023.10.17.01.25.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Oct 2023 01:25:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) client-ip=2620:137:e000::3:5; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=RCBaenzL; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 922048075B0A; Tue, 17 Oct 2023 01:25:28 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232134AbjJQIZT (ORCPT + 99 others); Tue, 17 Oct 2023 04:25:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44080 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232644AbjJQIZP (ORCPT ); Tue, 17 Oct 2023 04:25:15 -0400 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DC4DC93; Tue, 17 Oct 2023 01:25:13 -0700 (PDT) Received: from pps.filterd (m0279864.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 39H7nOBv026221; Tue, 17 Oct 2023 08:24:56 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h=message-id : date : mime-version : subject : to : cc : references : from : in-reply-to : content-type : content-transfer-encoding; s=qcppdkim1; bh=abG+EPXB6BECKL9u/q4R7dYvCyUAXCa41Z+B12FQpWI=; b=RCBaenzL+rR6YBrLmsSg4vxUSATLQJ/Sg5Xb7Ae5InKPVzHqOIlfngfTP+8iJ648PeQS D+nkejQy1s2aNm+dtOD3J10fTpY1IHK1cfvlBcxSznByCZAcG505MMEEyMmJaSFcYq9e 6FB9NDNf7kbHwholG4VPzd4pKmC0HKCC3THaWB6E0ZUpwMa4FNXcDOm8UbXTLC5tII9L zZYaKSeH3VBv7SmkMyY7Vwbon60uuzm8AI8veBG5B4NrOWhrZw2jc6D0Q2G7ubcOUU1a LYaBQSFO0d392/152fk5GmPBqHa6jkvbRG1Y7mCr9Q3FwKFEDwxVv+GDuzyQMJiG9liO gg== Received: from nalasppmta03.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3tryn1387n-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 17 Oct 2023 08:24:56 +0000 Received: from nalasex01b.na.qualcomm.com (nalasex01b.na.qualcomm.com [10.47.209.197]) by NALASPPMTA03.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 39H8OtIo022458 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 17 Oct 2023 08:24:55 GMT Received: from [10.216.24.217] (10.80.80.8) by nalasex01b.na.qualcomm.com (10.47.209.197) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.39; Tue, 17 Oct 2023 01:24:47 -0700 Message-ID: Date: Tue, 17 Oct 2023 13:54:43 +0530 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 03/11] firmware: qcom-scm: atomically assign and read the global __scm pointer Content-Language: en-US To: Bartosz Golaszewski , Andy Gross , Bjorn Andersson , Konrad Dybcio , Rob Herring , "Krzysztof Kozlowski" , Conor Dooley , Catalin Marinas , Will Deacon , Arnd Bergmann , Alex Elder , Srini Kandagatla CC: , , , , References: <20230828192507.117334-1-bartosz.golaszewski@linaro.org> <20230828192507.117334-4-bartosz.golaszewski@linaro.org> From: Om Prakash Singh In-Reply-To: <20230828192507.117334-4-bartosz.golaszewski@linaro.org> Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01a.na.qualcomm.com (10.52.223.231) To nalasex01b.na.qualcomm.com (10.47.209.197) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-GUID: NZoJXFrXHLjPD7Z3Hv_EfwVC3o2YEwqT X-Proofpoint-ORIG-GUID: NZoJXFrXHLjPD7Z3Hv_EfwVC3o2YEwqT X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.980,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-10-16_13,2023-10-12_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 suspectscore=0 malwarescore=0 priorityscore=1501 mlxlogscore=999 spamscore=0 bulkscore=0 phishscore=0 impostorscore=0 clxscore=1011 adultscore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2309180000 definitions=main-2310170069 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 groat.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 (groat.vger.email [0.0.0.0]); Tue, 17 Oct 2023 01:25:28 -0700 (PDT) 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. > init_completion(&__scm->waitq_comp); >