Received: by 2002:a05:6358:111d:b0:dc:6189:e246 with SMTP id f29csp3263980rwi; Tue, 1 Nov 2022 18:33:54 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4Xz9rPUMvJHcbxNJ2YnHvb6/1u+yWhKH3E+X1b0xXwMU//kxVHi6EzGkCCwcGaZdaAx78v X-Received: by 2002:a63:5246:0:b0:42b:e4a5:7252 with SMTP id s6-20020a635246000000b0042be4a57252mr19070026pgl.566.1667352834542; Tue, 01 Nov 2022 18:33:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667352834; cv=none; d=google.com; s=arc-20160816; b=w881uI/Za344xL0OZOwNHher+ZgWlaV0B+vLwVFALvurTcpwHh9OsyXORI8TgKJ1/y IltU6Qt7NddQ6oUn010NDBFPmJxGeT84I6kyPHZ9jSLlwhBzby4Fupb5NGBWyU5hO7xs RguqtC5Hsik/q4EnVGMnTWDLpubKYpDgvIGZwvU/jHs/vj34pgOxpO6K2WQWh1Ty/NGb CDZngJynXNAqPJmn69rxUi/9z3nmXIJXFuNMuvz/kyMJdbc/g+Sxq9AXr80uKkulwZ3X PZpU8s9dcqb41GCgCs3008YBNFKOpvE7qPCU5XuMdEfvVGpc9XMleVQekCElM7kuA7RF 8LKQ== 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:subject:user-agent:mime-version:date:message-id :dkim-signature; bh=fCDaaqwrb9HfguXm+Oa4aIFtC5jrIdk+WrH70moPni8=; b=r6aGhts6PiiAS6Pip3DjXtc7gsSBXRmGEUte+lavS5yWVGPhFKVd8rFXmxCPaDgh5J 8d56ElD+irJy5ivl00oeOEcuj8c5z63X/7psAo1R4GobfE3F7ktU+JgUFmoTbShBfbng x4boVNxPfoYfSshn6H+ux0XJs5O3Fh61IKmPaSFAzgBq5u3d5nKtHd/DxX3RshzdRlU5 NgkPhqEGIgPY0JMM+zsPIAb/5dasvtbGG8wjIuuLPO4ZgTUlMFn81eSlXvPeZUggZcxB p8n8YWfOI6R8+3xvnilkr3szW/uZAvO8bDZzksqj4OLUWOwlIkTOp8OBi2u1FaTbu0fA qL8g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=pysSL0HN; 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=quicinc.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y192-20020a638ac9000000b0046afe44ce9esi14608250pgd.131.2022.11.01.18.33.40; Tue, 01 Nov 2022 18:33:54 -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=@quicinc.com header.s=qcppdkim1 header.b=pysSL0HN; 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=quicinc.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229823AbiKBB0d (ORCPT + 97 others); Tue, 1 Nov 2022 21:26:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47828 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229756AbiKBB0b (ORCPT ); Tue, 1 Nov 2022 21:26:31 -0400 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C57651F9EB; Tue, 1 Nov 2022 18:26:29 -0700 (PDT) Received: from pps.filterd (m0279870.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 2A20SuKE017303; Wed, 2 Nov 2022 01:26:28 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=fCDaaqwrb9HfguXm+Oa4aIFtC5jrIdk+WrH70moPni8=; b=pysSL0HN4lPHSdn1OVVFJRdrjkvWOY5c8KqP9+0ZvfnkmWhp8PXmtaJOO53PHbryAwIE K3mfrzd7BW9VPerMl6ACKDgCaHKOcQUmLSEq80+kvuxz6mgogl/nA9fJLyUEoNOmzfUV +WdBuCq8T6s2M22ZdolQiI+yy2zf1RkMr6rRzXhcijeA11g12hyr/6ddT31YTRoXDpYD hapOH5Nt/oonCd8q1pMB6uTMBO2b3U1Y08VY9wvtzWvpC52G/bpXthk97DNZBPSfUgQr +PmIKokQIk9H2sVuOK5oMAopqKyqFPb+zyJpbKKQ4lbld6dYinb6nvHEVO9DT1/nyhAL mQ== Received: from nasanppmta04.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3kk7ms8uus-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 02 Nov 2022 01:26:28 +0000 Received: from nasanex01a.na.qualcomm.com ([10.52.223.231]) by NASANPPMTA04.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 2A21QRgr028877 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 2 Nov 2022 01:26:27 GMT Received: from [10.239.133.73] (10.80.80.8) by nasanex01a.na.qualcomm.com (10.52.223.231) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.29; Tue, 1 Nov 2022 18:26:25 -0700 Message-ID: <761f322c-47bb-1233-ffd2-f6c13bcd2466@quicinc.com> Date: Wed, 2 Nov 2022 09:26:22 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.3.0 Subject: Re: [PATCH] pinctrl: core: Make p->state in order in pinctrl_commit_state To: Pavan Kondeti CC: , , References: <20221027065408.36977-1-quic_aiquny@quicinc.com> <20221101043047.GA11893@hu-pkondeti-hyd.qualcomm.com> From: "Aiqun(Maria) Yu" In-Reply-To: <20221101043047.GA11893@hu-pkondeti-hyd.qualcomm.com> 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 nasanex01a.na.qualcomm.com (10.52.223.231) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-GUID: XWfkS2IBaq3kJMpahAS1CeKQbRmA-gfG X-Proofpoint-ORIG-GUID: XWfkS2IBaq3kJMpahAS1CeKQbRmA-gfG X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.895,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-11-01_12,2022-11-01_02,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 impostorscore=0 bulkscore=0 priorityscore=1501 mlxlogscore=999 malwarescore=0 adultscore=0 mlxscore=0 clxscore=1011 phishscore=0 lowpriorityscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2210170000 definitions=main-2211020006 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=ham 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: X-Mailing-List: linux-kernel@vger.kernel.org Hi Pavan, On 11/1/2022 12:30 PM, Pavan Kondeti wrote: > Hi Maria, > > On Thu, Oct 27, 2022 at 02:54:08PM +0800, Maria Yu wrote: >> We've got a dump that current cpu is in pinctrl_commit_state, the >> old_state != p->state while the stack is still in the process of >> pinmux_disable_setting. So it means even if the current p->state is >> changed in new state, the settings are not yet up-to-date enabled >> complete yet. >> >> Currently p->state in different value to synchronize the >> pinctrl_commit_state behaviors. The p->state will have transaction like >> old_state -> NULL -> new_state. When in old_state, it will try to >> disable all the all state settings. And when after new state settings >> enabled, p->state will changed to the new state after that. So use >> smp_mb to synchronize the p->state variable and the settings in order. >> --- >> drivers/pinctrl/core.c | 2 ++ >> 1 file changed, 2 insertions(+) >> >> diff --git a/drivers/pinctrl/core.c b/drivers/pinctrl/core.c >> index 9e57f4c62e60..cd917a5b1a0a 100644 >> --- a/drivers/pinctrl/core.c >> +++ b/drivers/pinctrl/core.c >> @@ -1256,6 +1256,7 @@ static int pinctrl_commit_state(struct pinctrl *p, struct pinctrl_state *state) >> } >> } >> >> + smp_mb(); >> p->state = NULL; >> >> /* Apply all the settings for the new state - pinmux first */ >> @@ -1305,6 +1306,7 @@ static int pinctrl_commit_state(struct pinctrl *p, struct pinctrl_state *state) >> pinctrl_link_add(setting->pctldev, p->dev); >> } >> >> + smp_mb(); >> p->state = state; >> > > From your commit description, are you inferring that this p->state assignment > re-ordered wrt pinmux_disable_setting()? btw, I don't see any locking that > protects concurrent access to p->state modifications. For whatever reasons, if > a client makes concurrent calls to pinctrl_select_state(), we can land up in > the situation, you are seeing. correct? correct. > > Thanks, > Pavan > -- Thx and BRs, Aiqun(Maria) Yu