Received: by 2002:a05:6358:489b:b0:bb:da1:e618 with SMTP id x27csp7932836rwn; Wed, 14 Sep 2022 06:41:23 -0700 (PDT) X-Google-Smtp-Source: AA6agR4KF95IC+TxFIvvh655pKVeY8NYUYV3hvG5dMBqu5deSbsyg3e7PWbJMzSDJ8O4C3OSLqY/ X-Received: by 2002:a17:902:dac7:b0:178:2aab:6313 with SMTP id q7-20020a170902dac700b001782aab6313mr16028283plx.147.1663162883482; Wed, 14 Sep 2022 06:41:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663162883; cv=none; d=google.com; s=arc-20160816; b=yvz6Kjv8NNy/9NXilGt/c0jkoMS6M80iamPp0YvoGme56KROIV2iyTlUaXw0MLAD5t E6P3MC5rx83phiwlUqFQmV7aVkSDUThsy7c1KIDlbZPZEEgZtyHu0KiWh18jYJ/8gfLC em1tnI4403wUUi/xpLB0t/8fCp6mv3iCcj0sPZeOqut8K8swFr08QQ6E+LEe8UYiW89/ N6hPq+xy0bZZ8LW8zvbj03oO0vDSYEuyHLcA6D+Rg4hccAIxEeXWVVFS88daaBtv8WLB F5f3605+uFbmak9HjyEJ+QruGG4XVm0DBbqA/FAfx35o1y2cEYKhanTA8jimDox5gv2u D/YA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:subject:cc:to:from:date:references:in-reply-to :message-id:mime-version:user-agent:feedback-id:dkim-signature :dkim-signature; bh=GdgMo8oW1+2SMCLkBxj5GR3RIMNzrKHtUDN4Kx4rnvU=; b=g+H8L8CfzLSpbUYtEGsPL8Ou1X8JlnBAP3F9ZqR7y0qvk+4KyQBGBxSpwweUaTNCqZ 7+SDrJlKKMibAwm5llC1Udw3mQnfSGFKbwRZhhzNfInpBhj5tiQCICPC/MZcuV8jVP1Z OoTU8zVhNs5EkuEEqfBax31FKVao/HLk/uAXb0cSFGMzwwblHWto3dhk/bw58+6HkiFr N7LKEep1HgWPZmZ3Og2BjVQe6EToxhNAvSYAuXHuMXsB9DnF1vp4nuho7WvrRmO8ISGW 9Zc5HyL0NTg/j9gzrIy01g/y/IxjIoemMIYJbSJCPbgW7NJEt0udUeRMK5ItLGRAQf89 /KKw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@arndb.de header.s=fm1 header.b=oV2STMsF; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b=XCF+z87a; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id p17-20020a170902e75100b00178297641d4si3380047plf.287.2022.09.14.06.41.10; Wed, 14 Sep 2022 06:41:23 -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=@arndb.de header.s=fm1 header.b=oV2STMsF; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b=XCF+z87a; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229484AbiINNZy (ORCPT + 99 others); Wed, 14 Sep 2022 09:25:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38376 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229498AbiINNZw (ORCPT ); Wed, 14 Sep 2022 09:25:52 -0400 X-Greylist: delayed 489 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Wed, 14 Sep 2022 06:25:51 PDT Received: from wnew1-smtp.messagingengine.com (wnew1-smtp.messagingengine.com [64.147.123.26]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 73D4661B20; Wed, 14 Sep 2022 06:25:50 -0700 (PDT) Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailnew.west.internal (Postfix) with ESMTP id 0DDB12B05DAE; Wed, 14 Sep 2022 09:17:39 -0400 (EDT) Received: from imap51 ([10.202.2.101]) by compute3.internal (MEProxy); Wed, 14 Sep 2022 09:17:40 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=arndb.de; h=cc :cc:content-type:date:date:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:sender:subject :subject:to:to; s=fm1; t=1663161459; x=1663165059; bh=GdgMo8oW1+ 2SMCLkBxj5GR3RIMNzrKHtUDN4Kx4rnvU=; b=oV2STMsFokkBLoSvn4LZ0bRXEy PHOYPvTVkohPZ3QmjXZLv9j5XItd9ZNYiti3Wo4bAf2GM4x9AeypXkXC3LBsScan Kmy9B8+xsVZr/vnEyYBcz21o9Yw88uaUeLjkqr74E7pCILyqReQ29e45Wa5acU3J ho+vBjNlTfz6VOp/hN5SHKvU8cT2hJwBZjMD2XYx367k/jlYM/Z5veWFt3Fhg6fh rbxmdolsi8GJbQn/KwhhogeJrfd1TMEsn8JPMEKFQMUVj0WpvLIMH6d4kDZWb04U /PRpWHr6uHjcf0/3XhAOUqlKo/UfxA1K+lDQF6i1zuhT9mfv04hiddcn+cEg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:date:date:feedback-id :feedback-id:from:from:in-reply-to:in-reply-to:message-id :mime-version:references:reply-to:sender:subject:subject:to:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm2; t=1663161459; x=1663165059; bh=GdgMo8oW1+2SMCLkBxj5GR3RIMNz rKHtUDN4Kx4rnvU=; b=XCF+z87anTvBmL047FIOUpa6x9uESrqeWJ3cwS786o4z xEAaXWiyDQjSXtwPo9X/c9XThNu3ZGvo2Or/gRR2LgdEdH28HJY6Q9bHHngv6Hgf /UaaCIt+37K95+xGc58DX0sjTo3ddMtRgCXmpRjG/wZ24MvXETdwjenDrwzjLDAE ER7Om+9EtMgd20C6baZSASSXID4sKdc8eZxcsx3O31RYU9M7A94Zc3uWvQC8XqA2 nagA+oi6svFbnoiY1GDTondJ6rcDHD7wCV8roRcRoFA2DjIJxPZNR+iY/NUpk/dy tHgTNZRT7kSGcyTnz/pGCQsB2woNL2fQ10G9mfqF4Q== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedrfeduiedgieehucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepofgfggfkjghffffhvfevufgtsehttdertderredtnecuhfhrohhmpedftehr nhguuceuvghrghhmrghnnhdfuceorghrnhgusegrrhhnuggsrdguvgeqnecuggftrfgrth htvghrnhepffehueegteeihfegtefhjefgtdeugfegjeelheejueethfefgeeghfektdek teffnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomheprg hrnhgusegrrhhnuggsrdguvg X-ME-Proxy: Feedback-ID: i56a14606:Fastmail Received: by mailuser.nyi.internal (Postfix, from userid 501) id 48733B60086; Wed, 14 Sep 2022 09:17:39 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.7.0-alpha0-934-g6274855a4c-fm-20220913.002-g6274855a Mime-Version: 1.0 Message-Id: <28501fbf-3508-4afe-804d-fa5a3ccd4291@www.fastmail.com> In-Reply-To: <499f0940-3d7f-0ed5-e469-5c0979e6f761@baylibre.com> References: <20220913140303.437994-1-narmstrong@baylibre.com> <667da463-1edc-4a99-9ac1-85303d9187c6@www.fastmail.com> <499f0940-3d7f-0ed5-e469-5c0979e6f761@baylibre.com> Date: Wed, 14 Sep 2022 15:17:17 +0200 From: "Arnd Bergmann" To: "Neil Armstrong" , "Mark Brown" Cc: linux-spi@vger.kernel.org, linux-amlogic@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] spi: meson-spicc: add support for DMA Content-Type: text/plain X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,SPF_HELO_PASS, 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 On Wed, Sep 14, 2022, at 2:35 PM, Neil Armstrong wrote: > On 14/09/2022 13:19, Arnd Bergmann wrote: >> On Tue, Sep 13, 2022, at 4:03 PM, Neil Armstrong wrote: >> >>> + /* Sometimes, TC gets triggered while the RX fifo isn't fully flushed * >>> + if (spicc->using_dma) { >>> + unsigned int rxfifo_count = FIELD_GET(SPICC_RXCNT_MASK, >>> + readl_relaxed(spicc->base + SPICC_TESTREG)); >> >> Same here in the interrupt controller, I don't see anything enforcing >> the DMA to actually complete before the readl_relaxed(). > > I don't see the relathionship between a register relaxed read and the > DMA not finishing > writing the data in uncached memory, for me it's 2 unrelated things. The race is between the readl_relaxed() and a subsequent access to the data that is being transferred. On Arm processors you need a "dmb(oshld)" instruction to ensure that the CPU cannot prefetch data from the DMA buffer while it is waiting for the MMIO to complete. The __io_ar() in readl() exists specifically there for this race, and this is the reason that readl_relaxed() exists for drivers that do not do any DMA. Note that this prefetching can happen for uncached memory, but spe-meson-spicc uses cached memory. Arnd