* Re: [PATCH 6.18 regression fix] dma-mapping: Fix DMA_BIT_MASK() macro being broken
2025-12-07 18:47 ` [PATCH 6.18 regression fix] dma-mapping: Fix DMA_BIT_MASK() macro being broken Hans de Goede
@ 2025-12-07 18:50 ` kernel test robot
2025-12-08 3:25 ` Nathan Chancellor
2025-12-08 8:42 ` Marek Szyprowski
2 siblings, 0 replies; 4+ messages in thread
From: kernel test robot @ 2025-12-07 18:50 UTC (permalink / raw)
To: Hans de Goede; +Cc: stable, oe-kbuild-all
Hi,
Thanks for your patch.
FYI: kernel test robot notices the stable kernel rule is not satisfied.
The check is based on https://www.kernel.org/doc/html/latest/process/stable-kernel-rules.html#option-3
Rule: The upstream commit ID must be specified with a separate line above the commit text.
Subject: [PATCH 6.18 regression fix] dma-mapping: Fix DMA_BIT_MASK() macro being broken
Link: https://lore.kernel.org/stable/20251207184756.97904-1-johannes.goede%40oss.qualcomm.com
Please ignore this mail if the patch is not relevant for upstream.
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 6.18 regression fix] dma-mapping: Fix DMA_BIT_MASK() macro being broken
2025-12-07 18:47 ` [PATCH 6.18 regression fix] dma-mapping: Fix DMA_BIT_MASK() macro being broken Hans de Goede
2025-12-07 18:50 ` kernel test robot
@ 2025-12-08 3:25 ` Nathan Chancellor
2025-12-08 8:42 ` Marek Szyprowski
2 siblings, 0 replies; 4+ messages in thread
From: Nathan Chancellor @ 2025-12-08 3:25 UTC (permalink / raw)
To: Hans de Goede
Cc: Marek Szyprowski, Robin Murphy, iommu, linux-kernel, Sakari Ailus,
James Clark, stable
On Sun, Dec 07, 2025 at 07:47:56PM +0100, Hans de Goede wrote:
> After commit a50f7456f853 ("dma-mapping: Allow use of DMA_BIT_MASK(64) in
> global scope"), the DMA_BIT_MASK() macro is broken when passed non trivial
> statements for the value of 'n'. This is caused by the new version missing
> parenthesis around 'n' when evaluating 'n'.
>
> One example of this breakage is the IPU6 driver now crashing due to
> it getting DMA-addresses with address bit 32 set even though it has
> tried to set a 32 bit DMA mask.
>
> The IPU6 CSI2 engine has a DMA mask of either 31 or 32 bits depending
> on if it is in secure mode or not and it sets this masks like this:
>
> mmu_info->aperture_end =
> (dma_addr_t)DMA_BIT_MASK(isp->secure_mode ?
> IPU6_MMU_ADDR_BITS :
> IPU6_MMU_ADDR_BITS_NON_SECURE);
>
> So the 'n' argument here is "isp->secure_mode ? IPU6_MMU_ADDR_BITS :
> IPU6_MMU_ADDR_BITS_NON_SECURE" which gets expanded into:
>
> isp->secure_mode ? IPU6_MMU_ADDR_BITS : IPU6_MMU_ADDR_BITS_NON_SECURE - 1
>
> With the -1 only being applied in the non secure case, causing
> the secure mode mask to be one 1 bit too large.
>
> Fixes: a50f7456f853 ("dma-mapping: Allow use of DMA_BIT_MASK(64) in global scope")
> Cc: Sakari Ailus <sakari.ailus@linux.intel.com>
> Cc: James Clark <james.clark@linaro.org>
> Cc: Nathan Chancellor <nathan@kernel.org>
> Cc: stable@vger.kernel.org
> Signed-off-by: Hans de Goede <johannes.goede@oss.qualcomm.com>
Yeah, the parentheses definitely should have been kept.
Reviewed-by: Nathan Chancellor <nathan@kernel.org>
> ---
> include/linux/dma-mapping.h | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/include/linux/dma-mapping.h b/include/linux/dma-mapping.h
> index 2ceda49c609f..aa36a0d1d9df 100644
> --- a/include/linux/dma-mapping.h
> +++ b/include/linux/dma-mapping.h
> @@ -90,7 +90,7 @@
> */
> #define DMA_MAPPING_ERROR (~(dma_addr_t)0)
>
> -#define DMA_BIT_MASK(n) GENMASK_ULL(n - 1, 0)
> +#define DMA_BIT_MASK(n) GENMASK_ULL((n) - 1, 0)
>
> struct dma_iova_state {
> dma_addr_t addr;
> --
> 2.52.0
>
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH 6.18 regression fix] dma-mapping: Fix DMA_BIT_MASK() macro being broken
2025-12-07 18:47 ` [PATCH 6.18 regression fix] dma-mapping: Fix DMA_BIT_MASK() macro being broken Hans de Goede
2025-12-07 18:50 ` kernel test robot
2025-12-08 3:25 ` Nathan Chancellor
@ 2025-12-08 8:42 ` Marek Szyprowski
2 siblings, 0 replies; 4+ messages in thread
From: Marek Szyprowski @ 2025-12-08 8:42 UTC (permalink / raw)
To: Hans de Goede, Robin Murphy
Cc: iommu, linux-kernel, Sakari Ailus, James Clark, Nathan Chancellor,
stable
On 07.12.2025 19:47, Hans de Goede wrote:
> After commit a50f7456f853 ("dma-mapping: Allow use of DMA_BIT_MASK(64) in
> global scope"), the DMA_BIT_MASK() macro is broken when passed non trivial
> statements for the value of 'n'. This is caused by the new version missing
> parenthesis around 'n' when evaluating 'n'.
>
> One example of this breakage is the IPU6 driver now crashing due to
> it getting DMA-addresses with address bit 32 set even though it has
> tried to set a 32 bit DMA mask.
>
> The IPU6 CSI2 engine has a DMA mask of either 31 or 32 bits depending
> on if it is in secure mode or not and it sets this masks like this:
>
> mmu_info->aperture_end =
> (dma_addr_t)DMA_BIT_MASK(isp->secure_mode ?
> IPU6_MMU_ADDR_BITS :
> IPU6_MMU_ADDR_BITS_NON_SECURE);
>
> So the 'n' argument here is "isp->secure_mode ? IPU6_MMU_ADDR_BITS :
> IPU6_MMU_ADDR_BITS_NON_SECURE" which gets expanded into:
>
> isp->secure_mode ? IPU6_MMU_ADDR_BITS : IPU6_MMU_ADDR_BITS_NON_SECURE - 1
>
> With the -1 only being applied in the non secure case, causing
> the secure mode mask to be one 1 bit too large.
>
> Fixes: a50f7456f853 ("dma-mapping: Allow use of DMA_BIT_MASK(64) in global scope")
> Cc: Sakari Ailus <sakari.ailus@linux.intel.com>
> Cc: James Clark <james.clark@linaro.org>
> Cc: Nathan Chancellor <nathan@kernel.org>
> Cc: stable@vger.kernel.org
> Signed-off-by: Hans de Goede <johannes.goede@oss.qualcomm.com>
Applied to dma-mapping-fixes branch. Thanks!
> ---
> include/linux/dma-mapping.h | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/include/linux/dma-mapping.h b/include/linux/dma-mapping.h
> index 2ceda49c609f..aa36a0d1d9df 100644
> --- a/include/linux/dma-mapping.h
> +++ b/include/linux/dma-mapping.h
> @@ -90,7 +90,7 @@
> */
> #define DMA_MAPPING_ERROR (~(dma_addr_t)0)
>
> -#define DMA_BIT_MASK(n) GENMASK_ULL(n - 1, 0)
> +#define DMA_BIT_MASK(n) GENMASK_ULL((n) - 1, 0)
>
> struct dma_iova_state {
> dma_addr_t addr;
Best regards
--
Marek Szyprowski, PhD
Samsung R&D Institute Poland
^ permalink raw reply [flat|nested] 4+ messages in thread