Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp2098198imw; Tue, 5 Jul 2022 23:18:09 -0700 (PDT) X-Google-Smtp-Source: AGRyM1t2QgzV8Lpcb2oAO4cNpVxappnD2AIiPEokNv6oICRz4i/dSRqsrsg3bM5CyGaq7ytTLGCD X-Received: by 2002:a05:6402:2685:b0:43a:897f:f9e3 with SMTP id w5-20020a056402268500b0043a897ff9e3mr2193518edd.262.1657088289346; Tue, 05 Jul 2022 23:18:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657088289; cv=none; d=google.com; s=arc-20160816; b=nae8kGJlB38fhQPWUGkA97XtSalFkQANlg0lGiN0nBprMcupwr4PZUuQpAZ2YIbD1i eagKFUVovL57jwJ4Q+q/dgJIm39OxMBWFY9V4Z7iML9qIeDRNT3kA6nXZQN1sB3xeZxo rFEuryn4upD86KsGweplRd/P5lYY724VC6o4tgq8DxrDrT0+1PMGl32eui0ol0FLI9Jf D90gfSdCiUXlQYJTKGxc6c2FVlBfioLsWzq9LXXzhYDWI7hLI/dcjF13C2Ic1Q1nGjht ZrtZnK/yM1BxOlQ5/MabmZV2ZG6uChSRpTG6gLqlRRsaog7QoHLN+9O9NhhFFpljRLZ0 KbXw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=2bdejReHpno5cbtrQjXdLhWumUnQnqp1aTK4h3lAwec=; b=wi4ov3pFTNy5WYeW38rUzF+6SWzKQLG4AL6XSeKfcz0yzGycmbshA3QOTeNbdsMTyM dHIuECSehlogsY8nqflsk1NpvZfF5dYu5BzJFTxir/QPP9kx8EeWAzOptnMPlifJucBP 5Iu2UhxludgV54a0nrYpB9BvWFrDwE4RFOXnbaO6fFGiiHaWYdmWV6DNJedIcw/MOQHd dNmUcpMUBdqQKY6KOyKP7LMJUwZODunCUewzPXg30CWJhxD2rkXXI/osVRlC9mzzElFK ZU9hnqm48aqEllRu46xQNF+9ea65/cFsAwl2dSRzbyNsT7m411lue9pETk9Ggka68g+j uZOA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcdkim header.b="CPxIN/bB"; 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 qb37-20020a1709077ea500b0072aeac5f74bsi5144787ejc.119.2022.07.05.23.17.36; Tue, 05 Jul 2022 23:18:09 -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=qcdkim header.b="CPxIN/bB"; 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 S229835AbiGFGDC (ORCPT + 99 others); Wed, 6 Jul 2022 02:03:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43524 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229484AbiGFGCz (ORCPT ); Wed, 6 Jul 2022 02:02:55 -0400 Received: from alexa-out-sd-01.qualcomm.com (alexa-out-sd-01.qualcomm.com [199.106.114.38]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 26BD822295; Tue, 5 Jul 2022 23:02:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; i=@quicinc.com; q=dns/txt; s=qcdkim; t=1657087374; x=1688623374; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=2bdejReHpno5cbtrQjXdLhWumUnQnqp1aTK4h3lAwec=; b=CPxIN/bBi6CtTYd7KITPNolHfqVj9HEapBCfb0voY+B1FAjgWsBy5brP 8Bx1dzyO2DQ1zFvkrGO+vNihlP2wv9xdb/HdsEJvWyh1FzJM1jAfSTe/r mfjhYWptGPn3QPgbzCuydon0boVKnZp2oCcnpf0VenVsRk7wkDU38rJGy c=; Received: from unknown (HELO ironmsg01-sd.qualcomm.com) ([10.53.140.141]) by alexa-out-sd-01.qualcomm.com with ESMTP; 05 Jul 2022 23:02:53 -0700 X-QCInternal: smtphost Received: from nasanex01c.na.qualcomm.com ([10.47.97.222]) by ironmsg01-sd.qualcomm.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Jul 2022 23:02:53 -0700 Received: from nalasex01a.na.qualcomm.com (10.47.209.196) by nasanex01c.na.qualcomm.com (10.47.97.222) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.22; Tue, 5 Jul 2022 23:02:52 -0700 Received: from hu-clew-lv.qualcomm.com (10.49.16.6) by nalasex01a.na.qualcomm.com (10.47.209.196) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.22; Tue, 5 Jul 2022 23:02:52 -0700 From: Chris Lew To: , , CC: , , Subject: [PATCH 3/4] soc: qcom: smp2p: Add memory barrier for irq_pending Date: Tue, 5 Jul 2022 23:02:10 -0700 Message-ID: <1657087331-32455-4-git-send-email-quic_clew@quicinc.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1657087331-32455-1-git-send-email-quic_clew@quicinc.com> References: <1657087331-32455-1-git-send-email-quic_clew@quicinc.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.49.16.6] X-ClientProxiedBy: nalasex01c.na.qualcomm.com (10.47.97.35) To nalasex01a.na.qualcomm.com (10.47.209.196) X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE 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 There is a very tight race where the irq_retrigger function is run on one cpu and the actual retrigger softirq is running on a second cpu. When this happens, there may be a chance that the second cpu will not see the updated irq_pending value from first cpu. Add a memory barrier to ensure that irq_pending is read correctly. Signed-off-by: Chris Lew --- drivers/soc/qcom/smp2p.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/soc/qcom/smp2p.c b/drivers/soc/qcom/smp2p.c index a94cddcb0298..a1ea5f55c228 100644 --- a/drivers/soc/qcom/smp2p.c +++ b/drivers/soc/qcom/smp2p.c @@ -249,6 +249,9 @@ static void qcom_smp2p_notify_in(struct qcom_smp2p *smp2p) status = val ^ entry->last_value; entry->last_value = val; + + /* Ensure irq_pending is read correctly */ + mb(); status |= *entry->irq_pending; /* No changes of this entry? */ @@ -356,6 +359,11 @@ static int smp2p_retrigger_irq(struct irq_data *irqd) set_bit(irq, entry->irq_pending); + /* Ensure irq_pending is visible to all cpus that retried interrupt + * can run on + */ + mb(); + return 0; } -- 2.7.4