* [PATCH] iommu: rockchip: Fix physical address decoding
@ 2021-06-18 11:46 Benjamin Gaignard
2021-06-18 12:45 ` Robin Murphy
0 siblings, 1 reply; 2+ messages in thread
From: Benjamin Gaignard @ 2021-06-18 11:46 UTC (permalink / raw)
To: will, robh+dt, heiko, xxm, robin.murphy, joro, dan.carpenter
Cc: devicetree, iommu, kernel, Benjamin Gaignard, linux-arm-kernel
Restore bits 39 to 32 at correct position.
It reverses the operation done in rk_dma_addr_dte_v2().
Fixes: c55356c534aa ("iommu: rockchip: Add support for iommu v2")
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Benjamin Gaignard <benjamin.gaignard@collabora.com>
---
drivers/iommu/rockchip-iommu.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/iommu/rockchip-iommu.c b/drivers/iommu/rockchip-iommu.c
index 94b9d8e5b9a40..e55482a477080 100644
--- a/drivers/iommu/rockchip-iommu.c
+++ b/drivers/iommu/rockchip-iommu.c
@@ -544,12 +544,13 @@ static inline u32 rk_dma_addr_dte(dma_addr_t dt_dma)
}
#define DT_HI_MASK GENMASK_ULL(39, 32)
+#define DTE_BASE_HI_MASK GENMASK(11, 4)
#define DT_SHIFT 28
static inline phys_addr_t rk_dte_addr_phys_v2(u32 addr)
{
return (phys_addr_t)(addr & RK_DTE_PT_ADDRESS_MASK) |
- ((addr & DT_HI_MASK) << DT_SHIFT);
+ ((addr & DTE_BASE_HI_MASK) << DT_SHIFT);
}
static inline u32 rk_dma_addr_dte_v2(dma_addr_t dt_dma)
--
2.25.1
_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] iommu: rockchip: Fix physical address decoding
2021-06-18 11:46 [PATCH] iommu: rockchip: Fix physical address decoding Benjamin Gaignard
@ 2021-06-18 12:45 ` Robin Murphy
0 siblings, 0 replies; 2+ messages in thread
From: Robin Murphy @ 2021-06-18 12:45 UTC (permalink / raw)
To: Benjamin Gaignard, will, robh+dt, heiko, xxm, joro, dan.carpenter
Cc: devicetree, iommu, kernel, linux-arm-kernel
On 2021-06-18 12:46, Benjamin Gaignard wrote:
> Restore bits 39 to 32 at correct position.
> It reverses the operation done in rk_dma_addr_dte_v2().
>
> Fixes: c55356c534aa ("iommu: rockchip: Add support for iommu v2")
>
> Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
> Signed-off-by: Benjamin Gaignard <benjamin.gaignard@collabora.com>
> ---
> drivers/iommu/rockchip-iommu.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/iommu/rockchip-iommu.c b/drivers/iommu/rockchip-iommu.c
> index 94b9d8e5b9a40..e55482a477080 100644
> --- a/drivers/iommu/rockchip-iommu.c
> +++ b/drivers/iommu/rockchip-iommu.c
> @@ -544,12 +544,13 @@ static inline u32 rk_dma_addr_dte(dma_addr_t dt_dma)
> }
>
> #define DT_HI_MASK GENMASK_ULL(39, 32)
> +#define DTE_BASE_HI_MASK GENMASK(11, 4)
> #define DT_SHIFT 28
>
> static inline phys_addr_t rk_dte_addr_phys_v2(u32 addr)
> {
> return (phys_addr_t)(addr & RK_DTE_PT_ADDRESS_MASK) |
> - ((addr & DT_HI_MASK) << DT_SHIFT);
> + ((addr & DTE_BASE_HI_MASK) << DT_SHIFT);
I think this still has the problem that you're shifting off the top of
addr *before* the cast takes effect.
Robin.
> }
>
> static inline u32 rk_dma_addr_dte_v2(dma_addr_t dt_dma)
>
_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-06-18 12:46 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-18 11:46 [PATCH] iommu: rockchip: Fix physical address decoding Benjamin Gaignard
2021-06-18 12:45 ` Robin Murphy
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).