From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id CF1B5C77B73 for ; Sat, 3 Jun 2023 13:53:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=JDBP5b3KU9foF4sCAxXMf673vifz520t5RtAp6IKC3I=; b=ky9EJZ4f7kyQAi w/r0P3kjCkcFOKqgGMEdNzK1clHUfMuu9jPt+XKK05MwpaCGZt/7mNEKBnhA9R46ZmxW6jXT+b38y IBa7BI5usBdtvJttx+aFhk/IK8nEafWw3Zz2SZQyTZWjpG4HHg9Aul0YeGnsB8jtqJ6BuA3Biz+GM V9CHlj4Nat0ufScqXe5t+uFr4ZVtkXQONqkt8GhZIvaX8yLHZQRG6Ctd1uY6S5IgQr0Nlxb6M8KSz Flbk6Sx/3DwRIonS9RX9dNXb4t7a52m7cu5aMlA+qdbaGJR6rz5a3vxMwoy8UaODIfYzn9y/sOK0B nz/um41emFCYi2N8kLYw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1q5RgV-009rlF-2o; Sat, 03 Jun 2023 13:52:47 +0000 Received: from pandora.armlinux.org.uk ([2001:4d48:ad52:32c8:5054:ff:fe00:142]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1q5RgS-009rkc-1H for linux-arm-kernel@lists.infradead.org; Sat, 03 Jun 2023 13:52:45 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=armlinux.org.uk; s=pandora-2019; h=Sender:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=Lnq90pYck3Rwp/VxV7iuqkJXkSUat3Ke2tJakohUHF8=; b=h9NkTQxyy8LkiQzo8U99ijt1Dv 1bdoVFCN36uldfqsOo4jS4KIRsxDKEaZ0InciTpnffGLU8aXFZTDUpTDO/lbb3caNCnVKxfltvvOe bbkw4/6PBddexxpgYs7leivlIXyvDywky9iSoNHe702qae6Ztb5RoyX338z87DmRNhxlBfwEBfYEG 8Q9c95o4MdRrNdtsmgQQCd4KuluP8gRnXmY7XhbR8c8BYCNquQTWpoGtHuauH/bDdhUK+BhfSot3t ATbe4f/uz+nDtgTVG9nY6y0M7fS85lqm4q6JYStVbBAtYREE1RFt+T2kNkMexViTglgRue8Jqk6Hb 6l+Y5FzA==; Received: from shell.armlinux.org.uk ([fd8f:7570:feb6:1:5054:ff:fe00:4ec]:33956) by pandora.armlinux.org.uk with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1q5RgJ-0001LJ-3H; Sat, 03 Jun 2023 14:52:35 +0100 Received: from linux by shell.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1q5RgF-00044u-72; Sat, 03 Jun 2023 14:52:31 +0100 Date: Sat, 3 Jun 2023 14:52:31 +0100 From: "Russell King (Oracle)" To: Arnd Bergmann Cc: Stefan Wahren , Florian Fainelli , Robin Murphy , Christoph Hellwig , Nicolas Saenz Julienne , linux-arm-kernel@lists.infradead.org, Lukas Wunner Subject: Re: [PATCH] ARM: mm: Fix ARCH_LOW_ADDRESS_LIMIT when CONFIG_ZONE_DMA Message-ID: References: <20230603090643.6799-1-stefan.wahren@i2se.com> <121092e9-a718-45f7-938d-a2cff7e92214@app.fastmail.com> <728053e0-5cc5-4449-a6ea-b224c7ff2af2@app.fastmail.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <728053e0-5cc5-4449-a6ea-b224c7ff2af2@app.fastmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230603_065244_453067_FFE27BBF X-CRM114-Status: GOOD ( 27.67 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Sat, Jun 03, 2023 at 02:59:53PM +0200, Arnd Bergmann wrote: > On Sat, Jun 3, 2023, at 14:38, Russell King (Oracle) wrote: > > On Sat, Jun 03, 2023 at 02:33:49PM +0200, Arnd Bergmann wrote: > >> Changing the low address limit by itself makes the swiotlb work > >> correctly, but for performance we also want to avoid having to > >> use the swiotlb at all when dealing with the zero page. > > > > How often is the zero page used for DMA _to_ a device (it should never > > be used for DMA _from_ a device.) ? It doesn't sound that useful to me, > > since it can only be used for writing zeros. > > It's possible that this doesn't happen all that much at all, the > bcm2835-dma driver is the only one that has a specific optimization > for this case, introduced in commit bf75703d0912d ("dmaengine: > bcm2835: Avoid accessing memory when copying zeroes"). > > If the ZERO page can only be mapped through swiotlb, that > optimization is clearly counterproductive because it requires > making a copy of the zero page but doesn't actually skip > any transfers. > > I don't really understand what the spi driver is doing here, > but I can see that it still contains the code that originally > started the discussion about the change to the DMA driver, > so I assume it's still used that way. With many SPI interfaces, if you want to read something, you need to have an active "write" stream (because when you clock the bus, bits need to be clocked out while bits are clocked in.) A common way to do that is to clock out zeros, and to DMA them from somewhere. Note that in the commit you pointed to: + /* non-lite channels can write zeroes w/o accessing memory */ + if (buf_addr == od->zero_page && !c->is_lite_channel) + info |= BCM2835_DMA_S_IGNORE; So, if it's not a "lite" channel, then even mapping the zero page is a waste, because according to the comment, it won't even access memory. Note also that the driver is also relying on dma_map_*() of zero-page _always_ producing the same result, which afaik the DMA API has never guaranteed. Also note that the buffer passed into bcm2835_dma_prep_dma_cyclic() must also have been dma-mapped (since it takes a dma_addr_t, not the virtual address of the buffer.) So this all looks rather dodgy to me. -- RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last! _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel