lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <5af0aeaf-c713-406d-9eed-ee24ce129b03@intel.com>
Date: Fri, 10 May 2024 09:12:46 +0200
From: Przemek Kitszel <przemyslaw.kitszel@...el.com>
To: Alexander Lobakin <aleksander.lobakin@...el.com>, Christoph Hellwig
	<hch@....de>
CC: Eric Dumazet <edumazet@...gle.com>, Jakub Kicinski <kuba@...nel.org>,
	Marek Szyprowski <m.szyprowski@...sung.com>, Steven Price
	<steven.price@....com>, Robin Murphy <robin.murphy@....com>, Joerg Roedel
	<joro@...tes.org>, Will Deacon <will@...nel.org>, "Rafael J. Wysocki"
	<rafael@...nel.org>, Magnus Karlsson <magnus.karlsson@...el.com>,
	<nex.sw.ncis.osdt.itp.upstreaming@...el.com>, <bpf@...r.kernel.org>,
	<netdev@...r.kernel.org>, <iommu@...ts.linux.dev>,
	<linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] dma: fix DMA sync for drivers not calling dma_set_mask*()

On 5/9/24 16:46, Alexander Lobakin wrote:
> There are several reports that the DMA sync shortcut broke non-coherent
> devices.
> dev->dma_need_sync is false after the &device allocation and if a driver
> didn't call dma_set_mask*(), it will still be false even if the device
> is not DMA-coherent and thus needs synchronizing. Due to historical
> reasons, there's still a lot of drivers not calling it.
> Invert the boolean, so that the sync will be performed by default and
> the shortcut will be enabled only when calling dma_set_mask*().
> 
> Reported-by: Marek Szyprowski <m.szyprowski@...sung.com>
> Closes: https://lore.kernel.org/lkml/46160534-5003-4809-a408-6b3a3f4921e9@samsung.com
> Reported-by: Steven Price <steven.price@....com>
> Closes: https://lore.kernel.org/lkml/010686f5-3049-46a1-8230-7752a1b433ff@arm.com
> Fixes: 32ba8b823252 ("dma: avoid redundant calls for sync operations")
> Signed-off-by: Alexander Lobakin <aleksander.lobakin@...el.com>
> ---
>   include/linux/device.h      |  4 ++--
>   include/linux/dma-map-ops.h |  4 ++--
>   include/linux/dma-mapping.h |  2 +-
>   kernel/dma/mapping.c        | 10 +++++-----
>   kernel/dma/swiotlb.c        |  2 +-
>   5 files changed, 11 insertions(+), 11 deletions(-)
> 
> diff --git a/include/linux/device.h b/include/linux/device.h
> index ed95b829f05b..d4b50accff26 100644
> --- a/include/linux/device.h
> +++ b/include/linux/device.h
> @@ -691,7 +691,7 @@ struct device_physical_location {
>    *		and optionall (if the coherent mask is large enough) also
>    *		for dma allocations.  This flag is managed by the dma ops
>    *		instance from ->dma_supported.
> - * @dma_need_sync: The device needs performing DMA sync operations.
> + * @dma_skip_sync: DMA sync operations can be skipped for coherent buffers.
>    *
>    * At the lowest level, every device in a Linux system is represented by an
>    * instance of struct device. The device structure contains the information
> @@ -805,7 +805,7 @@ struct device {
>   	bool			dma_ops_bypass : 1;
>   #endif
>   #ifdef CONFIG_DMA_NEED_SYNC
> -	bool			dma_need_sync:1;
> +	bool			dma_skip_sync:1;
>   #endif
>   };
>   

very good solution with inverting the flag,
Reviewed-by: Przemek Kitszel <przemyslaw.kitszel@...el.com>

// ...

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ