Received: by 2002:ab2:6a05:0:b0:1f8:1780:a4ed with SMTP id w5csp1252909lqo; Sat, 11 May 2024 14:52:44 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWRT/xmYVygXDBzDhYDkxyai7H+SSCN3gECRFFNGN/frQLFTtiXO0bLzrOBO7zD+NnaLRPr+Mzu7IzkSgUz/hKrMvm3XHUhtcmSoUpUTA== X-Google-Smtp-Source: AGHT+IGDHYhum5SAdjV2M9jASsSBBgooDAWIWBXyspuR07+wuFi6KZKgUxEieohxmKH3NeEi9hTa X-Received: by 2002:a05:6808:2026:b0:3c8:6238:8c38 with SMTP id 5614622812f47-3c997023d5cmr7423565b6e.11.1715464363798; Sat, 11 May 2024 14:52:43 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715464363; cv=pass; d=google.com; s=arc-20160816; b=TIkoJtSptMTLgB2aPLwb9C3KRWvkqG7X5gSRerTsOdtuINFluPMO1S42CD6HbgOJOj wDfWhZI9HPIwPdnUf9QBOozEXkuDducUk5OsMTNEofBKf1wqGElghBDSdff2kAB5TEFg huDLPFMlAggpWHi9JskXGQ33oM6vyAQrAAHvfSIZ1ETYub05WPCEp8u1JksbJKd8Jaxg QRyCS90O2ld0zHystr1LPpdYXBZDqbDg5bR0l8lseO1OJmdYMPz0fE+4QAZke0V64LTG aW0Q8TgBHV5it3xm6hf4izEfkjmmhlDHqE0w1zx5MNqBntF8iMDoa38oc58B5Adx867C 7pHA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :dkim-signature; bh=3wjcDK8yOGJQ1DL5gQpu62cFA/q24UQrr/Gt9NCzNO4=; fh=zRUTQ5+oQ5srYM7Rk65BuIf2Wa+dV1pGnC44y8hpvkA=; b=uNZSKoGFsikcrZECQOHLYbbTPEAAEAE22hKs2symoL7/KqMHcBty/poU6TQl5nXdlO QXC51jAyO/7IzxGrcJNKk1JkCs6YqMnp49yfy+51eYibw3xd3BC3rjjINr+x2uhmMDUj 6CQw+BqzP43nJZJlJzIa35dtq3irbkwtScH1lCsyXCt57Oao68BDUY9S25NhdcfsMJqM o4sBZ6fr++1Qi1UAwLbH4G14f3g4+owMZpjw9DPdQ9RnbYA+ezMz5BTwg2wwzvAiGtsI buKWJF2t+an50jVTXQgyNWXG5NK2bmLWrabInUJCJNl+0chxCDIBEQUzm7zGaOPoDDME UESA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=QZQg8ESO; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-kernel+bounces-176739-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-176739-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id d75a77b69052e-43dfa596f8bsi53677341cf.516.2024.05.11.14.52.43 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 11 May 2024 14:52:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-176739-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=QZQg8ESO; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-kernel+bounces-176739-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-176739-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 3BD2E1C20EF2 for ; Sat, 11 May 2024 21:52:43 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6C74E28DC3; Sat, 11 May 2024 21:52:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="QZQg8ESO" Received: from mail-yb1-f169.google.com (mail-yb1-f169.google.com [209.85.219.169]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 07F47200C7 for ; Sat, 11 May 2024 21:52:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.169 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715464356; cv=none; b=D9RH5F6KT8v56DMVj80qf0LPEJN1iTrsCx9iLRSATIALbGDULIlb2L2Z4w7Z4CrCnzcGTNPli3CIaTlMy3uPgRcZUk6gNkRAhqmb7vaHsymhzdqxPhJVxHQd+duZUROPoCABucyQ8dd7FXBqQTW4Gvm6inh6MclBmG/Tnlxi2K0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715464356; c=relaxed/simple; bh=pf2wv3ydNosYB79zDqNVaK/3uio46So1rqMJdd2CbYs=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=jjBuOUjaWt3jzNatHoY+Xc6sNcawRf61zMqqnXudxM1Ll31heeG1L1t3ok96osQDBGuRfmXxh8jzTkxJ/pPXGjwpKwXAZU+6VveUqGDSvZ+S5QayjYPoWwHPqUKbak4QcpQtAmjaQ70H7wYKY2I2AzUhtX89HB5r9tVvKZTmhHI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=QZQg8ESO; arc=none smtp.client-ip=209.85.219.169 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Received: by mail-yb1-f169.google.com with SMTP id 3f1490d57ef6-de603e3072dso3592876276.1 for ; Sat, 11 May 2024 14:52:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1715464354; x=1716069154; 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=3wjcDK8yOGJQ1DL5gQpu62cFA/q24UQrr/Gt9NCzNO4=; b=QZQg8ESOWSVHHYo4whpb7togbVaxNZW44I8prsjZkSHzoboiF0wKNZHaZCxKF8yNaA gPJ8baF3RvhPuDhLr2IEyPS2mg77sYVTSI5PnAd3hUhyJUsmWMeYMhivhh2c8d+bjetz F8MSGhvhxSesHVi9SOnmJvhEHptQQSyRH6lUjoujMRS7it6cCU+qiqX1QaEMSB9gNM1m 90EiLyOTRvGIkQSEtsKRg/mzARoh0DkAdYiTpK8zkpaYA5Q8knXB1yhSp5b0/FbjNDuW HFp2gp1wEkpnSDCNlRFGpN1/JWYBjBsnyLKx8D7njMnMzOEGjx48f3GV1Nq/bx9xRvVX TugA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715464354; x=1716069154; 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=3wjcDK8yOGJQ1DL5gQpu62cFA/q24UQrr/Gt9NCzNO4=; b=RjIHw6unKlK2pbs4jc+I+1mfVPfr6szfIWNDLU43+uV/3UnSPj8uu6acQAlCo0kgb9 ZYfBYDSN/2mmUUCidHM3oWZMfPRbwJX2qk8TFILfjtBnX4lpVhFwANkQ6E6X7IsUAdQ2 +cfZlQcgMbcW8TaZGfHfVoG34Q/enR3B+k59chYFFkynZrUL+CJB7WOoxxfjdFVYmFGh nowT31ycmiXoBIGZsHzQbRBlClVDLBchwJYi6e7JI4+q0URSNtargsm/gEfede/ZGuDO vSB4mxGyWuo0pCmEiclt69UnLD3cq+jQDWp97l3rly98b4UXUslWcQsjVItTi2MM2PNU MVqw== X-Forwarded-Encrypted: i=1; AJvYcCUTZA1DoNe+vEhNzJ649J+vgCGLeYbQHqE3LrWZoxJ9FCFpdWztX0/Kj4NEgvsar8TxHrYHM5cd2pYarinqsst6lJIaFThldD+QByhR X-Gm-Message-State: AOJu0YzQoMZpTA0AD7bCoo7dvd1B9/wS2Pa6ZLkuEgXPoXcP8Yp1vEQo aqzzu/mUeuLbaUEfj3vFY+d8lH0scmtof7//sIs26chDV2nahKWU5t9UdAIKZk17ywOzj2759ev 9Te3IGD1C8uUzgh4/ISLjREFbFTKxPmcxzSCPmg== X-Received: by 2002:a05:6902:28b:b0:de0:f74b:25f3 with SMTP id 3f1490d57ef6-dee4f3961dcmr5392619276.60.1715464354013; Sat, 11 May 2024 14:52:34 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240424-qcom-pd-mapper-v7-0-05f7fc646e0f@linaro.org> <20240424-qcom-pd-mapper-v7-1-05f7fc646e0f@linaro.org> In-Reply-To: From: Dmitry Baryshkov Date: Sun, 12 May 2024 00:52:23 +0300 Message-ID: Subject: Re: [PATCH v7 1/6] soc: qcom: pdr: protect locator_addr with the main mutex To: Chris Lew Cc: Bjorn Andersson , Konrad Dybcio , Sibi Sankar , Mathieu Poirier , linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-remoteproc@vger.kernel.org, Johan Hovold , Xilin Wu , "Bryan O'Donoghue" , Neil Armstrong Content-Type: text/plain; charset="UTF-8" On Thu, 25 Apr 2024 at 22:30, Chris Lew wrote: > > > On 4/24/2024 2:27 AM, Dmitry Baryshkov wrote: > > If the service locator server is restarted fast enough, the PDR can > > rewrite locator_addr fields concurrently. Protect them by placing > > modification of those fields under the main pdr->lock. > > > > Fixes: fbe639b44a82 ("soc: qcom: Introduce Protection Domain Restart helpers") > > Tested-by: Neil Armstrong # on SM8550-QRD > > Signed-off-by: Dmitry Baryshkov > > --- > > drivers/soc/qcom/pdr_interface.c | 4 ++-- > > 1 file changed, 2 insertions(+), 2 deletions(-) > > > > diff --git a/drivers/soc/qcom/pdr_interface.c b/drivers/soc/qcom/pdr_interface.c > > index a1b6a4081dea..19cfe4b41235 100644 > > --- a/drivers/soc/qcom/pdr_interface.c > > +++ b/drivers/soc/qcom/pdr_interface.c > > @@ -76,12 +76,12 @@ static int pdr_locator_new_server(struct qmi_handle *qmi, > > locator_hdl); > > struct pdr_service *pds; > > > > + mutex_lock(&pdr->lock); > > /* Create a local client port for QMI communication */ > > pdr->locator_addr.sq_family = AF_QIPCRTR; > > pdr->locator_addr.sq_node = svc->node; > > pdr->locator_addr.sq_port = svc->port; > > > > - mutex_lock(&pdr->lock); > > pdr->locator_init_complete = true; > > mutex_unlock(&pdr->lock); > > > > @@ -104,10 +104,10 @@ static void pdr_locator_del_server(struct qmi_handle *qmi, > > > > mutex_lock(&pdr->lock); > > pdr->locator_init_complete = false; > > - mutex_unlock(&pdr->lock); > > > > pdr->locator_addr.sq_node = 0; > > pdr->locator_addr.sq_port = 0; > > + mutex_unlock(&pdr->lock); > > } > > > > static const struct qmi_ops pdr_locator_ops = { > > > > These two functions are provided as qmi_ops handlers in pdr_locator_ops. > Aren't they serialized in the qmi handle's workqueue since it as an > ordered_workqueue? Even in a fast pdr scenario I don't think we would > see a race condition between these two functions. > > The other access these two functions do race against is in the > pdr_notifier_work. I think you would need to protect locator_addr in > pdr_get_domain_list since the qmi_send_request there uses > 'pdr->locator_addr'. Thanks, I missed it initially. I think I'd keep the rest of the changes and expand the lock to cover pdr_get_domain_list(). > > Thanks! > Chris -- With best wishes Dmitry