Received: by 2002:a05:7412:37c9:b0:e2:908c:2ebd with SMTP id jz9csp846023rdb; Tue, 19 Sep 2023 11:54:35 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEMdZaopHHYgUDVOl9ubgSbFea/yGdeTP2JjDxd17kzaUbCvnlgiJVWVVhMZnfI4jVdzxh8 X-Received: by 2002:a05:6358:291f:b0:142:e357:e777 with SMTP id y31-20020a056358291f00b00142e357e777mr909113rwb.25.1695149675222; Tue, 19 Sep 2023 11:54:35 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1695149675; cv=pass; d=google.com; s=arc-20160816; b=XxZCabBvnD6kiYofwF8KvZMfTJM49iRLT4wDwUQc8tOjeDCxkl8MRTEcpPQz2prfZT Zc9gA3SPyfwz+OKHV6aEUY45lyl8s1rs8HvrEV5zWEhpx0N+B1MC6dkWWOCF3NCiIud5 GqJ9HD0vPxO8GqkMdmu5BKEmqhjdQbu+bH+BB/i6Wn9vJKEFLAAZbLjrvld7QaTZFspc oI1wmt6sICMdW/PDKjYENcdgFKuQh8YRPLhwr9QDUw+qSavaKzx3eOi5z6NDxf4Ca/V6 uZkF85jrThzP/2zTEGrxMMZ1K/++X1KyJzfVNQh0GjUhq3D7dkRUJ25nyGNDnSEU+s8F I4QQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :in-reply-to:from:references:cc:to:content-language:subject :user-agent:date:message-id:dkim-signature; bh=RbHVfAUsfONtzHRRpCmVRcaEGL/yaY+08R4+FLQsp0c=; fh=1XiocGn8yijQY0IycY5sKCrTdANeXAV+hlhUQXG/QS4=; b=NRiptxtkUjAH5t49fRQcyT2tI2DIREeDXdiZvqzNnxp7PiZ0Jg6BdpWpLAQJMVM5Be yCblWXNnrN7kNM+mStJTJY+CyvDgcuYhhFvFWkIp1wijB4HsPNWfsdKbMjpWHL1sJxVm qh2xLwjkcDyX1TJsgEduAKTrZ0KbgCASDbmaQRyZvk58pvEpkSGNf9Q5n4M7MgQ9AVQG 7xPta8/rSSkhpZ7lo11pxs1p7hVdIVMG7tB01UTJZ6WI3+V69pPJHc1p5kJGGB5baEx1 quG1msyomZVpyHQ0sUr2sHivpzoRPH5Q3GoTPxUQzGyAk3D+zGUDaW+sk9B3HlgZXaBX EI2g== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@os.amperecomputing.com header.s=selector2 header.b="ob/FPMuq"; arc=pass (i=1 spf=pass spfdomain=os.amperecomputing.com dkim=pass dkdomain=os.amperecomputing.com dmarc=pass fromdomain=os.amperecomputing.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amperecomputing.com Return-Path: Received: from morse.vger.email (morse.vger.email. [2620:137:e000::3:1]) by mx.google.com with ESMTPS id s21-20020a63e815000000b005775a0cd009si10145019pgh.331.2023.09.19.11.54.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Sep 2023 11:54:35 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) client-ip=2620:137:e000::3:1; Authentication-Results: mx.google.com; dkim=pass header.i=@os.amperecomputing.com header.s=selector2 header.b="ob/FPMuq"; arc=pass (i=1 spf=pass spfdomain=os.amperecomputing.com dkim=pass dkdomain=os.amperecomputing.com dmarc=pass fromdomain=os.amperecomputing.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amperecomputing.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id B08DA826EC02; Tue, 19 Sep 2023 11:54:29 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232516AbjISSya (ORCPT + 99 others); Tue, 19 Sep 2023 14:54:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40080 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232362AbjISSy2 (ORCPT ); Tue, 19 Sep 2023 14:54:28 -0400 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2125.outbound.protection.outlook.com [40.107.223.125]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BFF5E9D; Tue, 19 Sep 2023 11:54:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=K5Sukd6fdW5UKd/DxiqtrbZ5ktCGaTsUAo0OaS208BWPtcwm5TzxxMS9ic47tziSWCwcMg0DHnI8NQL5mOeKdkXhk28Gt5E0skIUSaegtb9qyvE/uux3YKwsY80PyyBcGWi1X2Q7/V+zfi6TVL5smekdepJ2BUg1DtkLviPU1bIKLdaOiWCiJLTji0qhjqx125hEQzh05F0FMJadkR5IhXNJg0yGwpsFfVxql4D+Yggg5tdzmPSd8hK+JabUuh1Cn99KHASCMvTDzcavc4embp+Ec/mTyEynwxjOMnibmnTtZlghtl1V1DKakqmcBEbrx8MXAdJDB22cIiwsO7iysA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=RbHVfAUsfONtzHRRpCmVRcaEGL/yaY+08R4+FLQsp0c=; b=bOM8oSphGd8khHWExBlFFxfqRNabXJiMOWVMGL9CwlVHqg4rYBxo5Kaba6H/ThAN+rD1pzu4bkAhHeTvAvwUGVdJjnYtUd67/E+h8P0DCSaOMmYcHg5ZweQEIQpY1VeiyIzy1HH1DEyIF/0ycxG8U5MKKmj1x4lnAiV1g2uRcwqlw3TPlqjMn3Oi3D9wnOjpfpKBewlaN59DU+2fYtRGFV5unXh+fMAjP0YekjQsK2OODcUzenbMraGe7Fz2pApfDwMIg8yllet0OT/lBoyvLNg8IXDhOQfcf68uMWkCbYUxpyndkU0wPGDnauoknYTAThJUqN0/72osHMuGw4b5Nw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=os.amperecomputing.com; dmarc=pass action=none header.from=os.amperecomputing.com; dkim=pass header.d=os.amperecomputing.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=os.amperecomputing.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=RbHVfAUsfONtzHRRpCmVRcaEGL/yaY+08R4+FLQsp0c=; b=ob/FPMuqymWzrrrfZsMs9tUQmI5WBtdWQKAl0XpLMxLJPgc4Nsi98dVIoGbi0ltnkHOOD7azm3jjZ0ybztD0X13ZByWJDhwqmKq/7RiKApvqPeO3Lm21aQPrxadvFhP95BiDxHZNLrkDXYRE4OVuM8mthMzgQXBCNDI+7OkerjE= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=os.amperecomputing.com; Received: from DM6PR01MB4044.prod.exchangelabs.com (2603:10b6:5:2c::17) by CH3PR01MB8313.prod.exchangelabs.com (2603:10b6:610:17c::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6792.27; Tue, 19 Sep 2023 18:54:15 +0000 Received: from DM6PR01MB4044.prod.exchangelabs.com ([fe80::c00b:cb2e:a349:bcbc]) by DM6PR01MB4044.prod.exchangelabs.com ([fe80::c00b:cb2e:a349:bcbc%4]) with mapi id 15.20.6792.026; Tue, 19 Sep 2023 18:54:15 +0000 Message-ID: Date: Tue, 19 Sep 2023 11:54:10 -0700 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2] i2c: designware: Fix corrupted memory seen in the ISR Content-Language: en-US To: Catalin Marinas , Yann Sionneau Cc: Wolfram Sang , Serge Semin , Yann Sionneau , Will Deacon , Jarkko Nikula , Andy Shevchenko , Mika Westerberg , Jan Dabros , Andi Shyti , Philipp Zabel , linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org References: <20230913232938.420423-1-janb@os.amperecomputing.com> <37e10c3d-b5ab-75ec-3c96-76e15eb9bef8@sionneau.net> <9de89e14-35bd-415d-97f1-4b6db1258997@os.amperecomputing.com> From: Jan Bottorff In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-ClientProxiedBy: CH2PR10CA0005.namprd10.prod.outlook.com (2603:10b6:610:4c::15) To DM6PR01MB4044.prod.exchangelabs.com (2603:10b6:5:2c::17) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6PR01MB4044:EE_|CH3PR01MB8313:EE_ X-MS-Office365-Filtering-Correlation-Id: 72e2aade-0145-40d4-8153-08dbb941d22f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: CVABCn2zA8kauetDrVtlH5YAy3MAK25vz1tdwblKrjeSuioUhv1kx+/T2kRNwfw47a4zJA0XEB62tt5b3Y3UmkZPgpxS8qUJfOr0tINRM2y4KJ0/jk7+OkdmkGGlBz8/xXyJnwcVxa/HzA/M9z114At2OrXtjyHiNJfVZb5YrHIwYWJone7Pg8XJH1STP50qhVh3RnPufbe9yByAwtkocamqIcMSELxxDVHyocmYUU9M/dw+qA5+o5cGxOLYe8SG5bFauCT3Q8buAd/ylr/e/xh3fxSkd5CEXkDZyWkiptaft6J9GRFbfbJ6yAHkurIrfjEvhJGtalkbuQ5KVvxxI/+VisHpHziytizZGQEqXTSeB8U4rhJ7FneG4HqEZLe4kS4x2kXHzVy0f/kUrkObEkNBOpxEEIgT1SlS+en4RQvy8P9o1ZyFpjrQNc5HWbv9zjGw2J//9TiOwoEbMRpEoPlI8P2Xdnshod7J9oHpQVUXfO422K2FcVmlt4Q+WiJZn/paao4dUZKnBlWFDEsS4hEMrgs55Yq0SydLo054+vI9YmBfLLDvJ1z6m/DdjzsUyheMx+4JAf0+iFxWK7kfYNdF+9x064fMi5wWaCH6OQk= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM6PR01MB4044.prod.exchangelabs.com;PTR:;CAT:NONE;SFS:(13230031)(346002)(366004)(376002)(136003)(39850400004)(396003)(1800799009)(186009)(451199024)(2906002)(5660300002)(26005)(41300700001)(7416002)(54906003)(66946007)(66476007)(66556008)(316002)(110136005)(966005)(478600001)(8936002)(4326008)(8676002)(31686004)(6486002)(6506007)(53546011)(6512007)(2616005)(38100700002)(6666004)(86362001)(31696002)(43740500002);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?NWJoYTJTNHZtREV1VGprcDVwWm9XYlVUalh6TDIvZ1JRM1QzUzNja2VzYzVj?= =?utf-8?B?V29Ib0hhc250ZHRaYmpZdFJSeTVFZ1RJYldKZndDa05OQXJXQzZxYXRTSUd4?= =?utf-8?B?anJCSVFmeUpsSy8zZWxBUUFKRmdRcVNWSys3ZW9CUWd0ZXhWUVRydjhVL2Fl?= =?utf-8?B?aXhHVDVxQmk3RlhTOFBjNU9ubmZNSHMzWEdjUnhGdGg4WExibXVYdzZDeWdX?= =?utf-8?B?VFhxZFgvN2dNNitINHVONCtlL1JVM3ZoOG52Wmg4N01sWVhpaTJ3MHZhWEo4?= =?utf-8?B?ajZiYndqSlBveGZ6ZnpRMTF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BZeU0rRDN6MXkyZk5k?= =?utf-8?B?THRpRno1dkxlQnJTMzFnMUJwT25yclJ4T2p0NmtZREpVRkJXbW9JeEJCdnc2?= =?utf-8?Q?HpCVl0ZW1piJvNGShtsHbHg=3D?= X-OriginatorOrg: os.amperecomputing.com X-MS-Exchange-CrossTenant-Network-Message-Id: 72e2aade-0145-40d4-8153-08dbb941d22f X-MS-Exchange-CrossTenant-AuthSource: DM6PR01MB4044.prod.exchangelabs.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Sep 2023 18:54:15.4419 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3bc2b170-fd94-476d-b0ce-4229bdc904a7 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: NtlMrdmDL19cHVrog7XDi2vL0O1P5XOTcvlq8GrGUUCaHgfMRzKIGJeE/gjOjP+SzZnW4HtpIM4zUhY63jGnaFUw54ixYpB25+H6IajUAhU= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR01MB8313 X-Spam-Status: No, score=-0.9 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 morse.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 (morse.vger.email [0.0.0.0]); Tue, 19 Sep 2023 11:54:30 -0700 (PDT) On 9/19/2023 7:51 AM, Catalin Marinas wrote: > > While smp_* is ok, it really depends on what the regmap_write() does. Is > it a write to a shared peripheral (if not, you may need a DSB)? Does the > regmap_write() caller know this? That's why I think having the barrier > in dw_reg_write() is better. > > If you do want to stick to a fix in i2c_dw_xfer_init(), you could go for > dma_wmb(). While this is not strictly DMA, it's sharing data with > another coherent agent (a different CPU in this instance). The smp_wmb() > is more about communication via memory not involving I/O. But this still > assumes that the caller knows regmap_write() ends up with an I/O > write*() (potentially relaxed). If we wanted maximum correctness wouldn't we need something like writel_triggers_interrupt/regmap_write_triggers_interrupt or maybe preinterrupt_wmb? The ARM docs do have a specific example case where the device write triggers an interrupt, and that example specifically says a DSB barrier is needed. If I look at the ARM GIC IPI send function gic_ipi_send_mask in https://elixir.bootlin.com/linux/v6.6-rc2/source/drivers/irqchip/irq-gic-v3.c#L1354 is says: /* * Ensure that stores to Normal memory are visible to the * other CPUs before issuing the IPI. */ dsb(ishst); I would think the IPI send code is very carefully tuned for performance, and would not use a barrier any stronger than required. I believe dma_wmb maps to DMB on ARM64. - Jan