[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAMuHMdW5bXeE=nr7+hHxL+xhm2q05udkJpMBM-BG7g9S7Nt7Zg@mail.gmail.com>
Date: Mon, 3 Jul 2023 09:54:46 +0200
From: Geert Uytterhoeven <geert@...ux-m68k.org>
To: Arnd Bergmann <arnd@...nel.org>
Cc: linux-kernel@...r.kernel.org, Arnd Bergmann <arnd@...db.de>,
Vineet Gupta <vgupta@...nel.org>,
Russell King <linux@...linux.org.uk>,
Neil Armstrong <neil.armstrong@...aro.org>,
Linus Walleij <linus.walleij@...aro.org>,
Catalin Marinas <catalin.marinas@....com>,
Will Deacon <will@...nel.org>, Guo Ren <guoren@...nel.org>,
Brian Cain <bcain@...cinc.com>,
Michal Simek <monstr@...str.eu>,
Thomas Bogendoerfer <tsbogend@...ha.franken.de>,
Dinh Nguyen <dinguyen@...nel.org>,
Stafford Horne <shorne@...il.com>,
Helge Deller <deller@....de>,
Michael Ellerman <mpe@...erman.id.au>,
Christophe Leroy <christophe.leroy@...roup.eu>,
Paul Walmsley <paul.walmsley@...ive.com>,
Palmer Dabbelt <palmer@...belt.com>,
Rich Felker <dalias@...c.org>,
John Paul Adrian Glaubitz <glaubitz@...sik.fu-berlin.de>,
"David S. Miller" <davem@...emloft.net>,
Max Filippov <jcmvbkbc@...il.com>,
Christoph Hellwig <hch@....de>,
Robin Murphy <robin.murphy@....com>,
Lad Prabhakar <prabhakar.mahadev-lad.rj@...renesas.com>,
Conor Dooley <conor.dooley@...rochip.com>,
linux-snps-arc@...ts.infradead.org,
linux-arm-kernel@...ts.infradead.org, linux-oxnas@...ups.io,
linux-csky@...r.kernel.org, linux-hexagon@...r.kernel.org,
linux-m68k@...ts.linux-m68k.org, linux-mips@...r.kernel.org,
linux-openrisc@...r.kernel.org, linux-parisc@...r.kernel.org,
linuxppc-dev@...ts.ozlabs.org, linux-riscv@...ts.infradead.org,
linux-sh@...r.kernel.org, sparclinux@...r.kernel.org,
linux-xtensa@...ux-xtensa.org,
Emil Renner Berthing <emil.renner.berthing@...onical.com>
Subject: Re: [PATCH 20/21] ARM: dma-mapping: split out arch_dma_mark_clean() helper
Hi Arnd,
On Mon, Mar 27, 2023 at 2:16 PM Arnd Bergmann <arnd@...nel.org> wrote:
> From: Arnd Bergmann <arnd@...db.de>
>
> The arm version of the arch_sync_dma_for_cpu() function annotates pages as
> PG_dcache_clean after a DMA, but no other architecture does this here. On
> ia64, the same thing is done in arch_sync_dma_for_cpu(), so it makes sense
> to use the same hook in order to have identical arch_sync_dma_for_cpu()
> semantics as all other architectures.
>
> Splitting this out has multiple effects:
>
> - for dma-direct, this now gets called after arch_sync_dma_for_cpu()
> for DMA_FROM_DEVICE mappings, but not for DMA_BIDIRECTIONAL. While
> it would not be harmful to keep doing it for bidirectional mappings,
> those are apparently not used in any callers that care about the flag.
>
> - Since arm has its own dma-iommu abstraction, this now also needs to
> call the same function, so the calls are added there to mirror the
> dma-direct version.
>
> - Like dma-direct, the dma-iommu version now marks the dcache clean
> for both coherent and noncoherent devices after a DMA, but it only
> does this for DMA_FROM_DEVICE, not DMA_BIDIRECTIONAL.
>
> [ HELP NEEDED: can anyone confirm that it is a correct assumption
> on arm that a cache-coherent device writing to a page always results
> in it being in a PG_dcache_clean state like on ia64, or can a device
> write directly into the dcache?]
>
> Signed-off-by: Arnd Bergmann <arnd@...db.de>
Thanks for your patch, which is now commit 322dbe898f82fd8a
("ARM: dma-mapping: split out arch_dma_mark_clean() helper") in
esmil/jh7100-dmapool.
If CONFIG_ARM_DMA_USE_IOMMU=y, the build fails.
> --- a/arch/arm/mm/dma-mapping.c
> +++ b/arch/arm/mm/dma-mapping.c
> @@ -1294,6 +1298,17 @@ static int arm_iommu_map_sg(struct device *dev, struct scatterlist *sg,
> return -EINVAL;
> }
>
> +static void arm_iommu_sync_dma_for_cpu(phys_addr_t phys, size_t len,
> + enum dma_data_direction dir,
> + bool dma_coherent)
> +{
> + if (!dma_coherent)
> + arch_sync_dma_for_cpu(phys, s->length, dir);
s/s->length/len/
> +
> + if (dir == DMA_FROM_DEVICE)
> + arch_dma_mark_clean(phys, s->length);
Likewise.
> +}
> +
> /**
> * arm_iommu_unmap_sg - unmap a set of SG buffers mapped by dma_map_sg
> * @dev: valid struct device pointer
> @@ -1425,9 +1438,9 @@ static void arm_iommu_unmap_page(struct device *dev, dma_addr_t handle,
> if (!iova)
> return;
>
> - if (!dev->dma_coherent && !(attrs & DMA_ATTR_SKIP_CPU_SYNC)) {
> + if (!(attrs & DMA_ATTR_SKIP_CPU_SYNC))
Missing opening curly brace.
> phys = iommu_iova_to_phys(mapping->domain, handle);
> - arch_sync_dma_for_cpu(phys, size, dir);
> + arm_iommu_sync_dma_for_cpu(phys, size, dir, dev->dma_coherent);
> }
>
> iommu_unmap(mapping->domain, iova, len);
With the above fixed, it builds and boots fine (on R-Car M2-W).
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@...ux-m68k.org
In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
Powered by blists - more mailing lists