Skip to contentSkip to conversation

iommu/rockchip: Fix PAGE_DESC_HI_MASKs for RK3568

PATCH In review Alex Bee 6 participants 6 messages Nov 24, 2021

Subsystems (2)
lore
Share & tools
lore

Alex Bee

author
#0 lore raw

PATCH 1/1 iommu/rockchip: Fix PAGE_DESC_HI_MASKs for RK3568

With the submission of iommu driver for RK3568 a subtle bug was
introduced: PAGE_DESC_HI_MASK1 and PAGE_DESC_HI_MASK2 have to be the other way arround - that leads to random errors, especially when addresses beyond 32 bit are used.

Fix it.

Fixes c55356c534aa ("iommu: rockchip: Add support for iommu v2")

---

I've found this bug, when testing the recent VOP2 submission, which is the first perpherial which uses iommu for RK356x. I could use it on my quartz64 8GB board only, when limiting the available memory to less 4GB.

This patch fixes it.

 drivers/iommu/rockchip-iommu.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/iommu/rockchip-iommu.c +2 -2
index 5cb260820eda..7f23ad61c094 100644
@@ -200,8 +200,8 @@ static inline phys_addr_t rk_dte_pt_address(u32 dte)
 #define DTE_HI_MASK2	GENMASK(7, 4)
 #define DTE_HI_SHIFT1	24 /* shift bit 8 to bit 32 */
 #define DTE_HI_SHIFT2	32 /* shift bit 4 to bit 36 */
-#define PAGE_DESC_HI_MASK1	GENMASK_ULL(39, 36)
-#define PAGE_DESC_HI_MASK2	GENMASK_ULL(35, 32)
+#define PAGE_DESC_HI_MASK1	GENMASK_ULL(35, 32)
+#define PAGE_DESC_HI_MASK2	GENMASK_ULL(39, 36)
 
 static inline phys_addr_t rk_dte_pt_address_v2(u32 dte)
 {
Signature · 1 line
2.30.2
Reviewed-by on v1 1/1
#1 lore raw

Le 24/11/2021 à 03:13, Alex Bee a écrit :

Quoted 9 lines

With the submission of iommu driver for RK3568 a subtle bug was
introduced: PAGE_DESC_HI_MASK1 and PAGE_DESC_HI_MASK2 have to be the other way arround - that leads to random errors, especially when addresses beyond 32 bit are used.

Fix it.

Fixes c55356c534aa ("iommu: rockchip: Add support for iommu v2")

Thanks for the fix.

Quoted 16 lines

---

I've found this bug, when testing the recent VOP2 submission, which is the first perpherial which uses iommu for RK356x. I could use it on my quartz64 8GB board only, when limiting the available memory to less 4GB.

This patch fixes it.

  drivers/iommu/rockchip-iommu.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
drivers/iommu/rockchip-iommu.c +0 -0
index 5cb260820eda..7f23ad61c094 100644

drivers/iommu/rockchip-iommu.c static inline phys_addr_t rk_dte_pt_address(u32 dte) · line 207

Quoted 10 lines
drivers/iommu/rockchip-iommu.c +2 -2
@@ -200,8 +200,8 @@ static inline phys_addr_t rk_dte_pt_address(u32 dte)
  #define DTE_HI_MASK2	GENMASK(7, 4)
  #define DTE_HI_SHIFT1	24 /* shift bit 8 to bit 32 */
  #define DTE_HI_SHIFT2	32 /* shift bit 4 to bit 36 */
-#define PAGE_DESC_HI_MASK1	GENMASK_ULL(39, 36)
-#define PAGE_DESC_HI_MASK2	GENMASK_ULL(35, 32)
+#define PAGE_DESC_HI_MASK1	GENMASK_ULL(35, 32)
+#define PAGE_DESC_HI_MASK2	GENMASK_ULL(39, 36)
 
  static inline phys_addr_t rk_dte_pt_address_v2(u32 dte)
  {

_______________________________________________
iommu mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/iommu

maintainer Reviewed-by on v1 1/1
#2 lore raw
In reply to Alex Bee

Am Mittwoch, 24. November 2021, 03:13:25 CET schrieb Alex Bee:

Quoted 25 lines

With the submission of iommu driver for RK3568 a subtle bug was
introduced: PAGE_DESC_HI_MASK1 and PAGE_DESC_HI_MASK2 have to be the other way arround - that leads to random errors, especially when addresses beyond 32 bit are used.

Fix it.

Fixes c55356c534aa ("iommu: rockchip: Add support for iommu v2")

---

I've found this bug, when testing the recent VOP2 submission, which is the first perpherial which uses iommu for RK356x. I could use it on my quartz64 8GB board only, when limiting the available memory to less 4GB.

This patch fixes it.

 drivers/iommu/rockchip-iommu.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/iommu/rockchip-iommu.c +0 -0
index 5cb260820eda..7f23ad61c094 100644

drivers/iommu/rockchip-iommu.c static inline phys_addr_t rk_dte_pt_address(u32 dte) · line 204

Quoted 7 lines
drivers/iommu/rockchip-iommu.c +2 -2
@@ -200,8 +200,8 @@ static inline phys_addr_t rk_dte_pt_address(u32 dte)
 #define DTE_HI_MASK2	GENMASK(7, 4)
 #define DTE_HI_SHIFT1	24 /* shift bit 8 to bit 32 */
 #define DTE_HI_SHIFT2	32 /* shift bit 4 to bit 36 */
-#define PAGE_DESC_HI_MASK1	GENMASK_ULL(39, 36)
-#define PAGE_DESC_HI_MASK2	GENMASK_ULL(35, 32)
+#define PAGE_DESC_HI_MASK1	GENMASK_ULL(35, 32)
+#define PAGE_DESC_HI_MASK2	GENMASK_ULL(39, 36)

With this change the PAGE_DESC_HI_MASK* now match the other constants above them in what bits they access, so

Tested-by
#3 lore raw
Quoted 38 lines · Heiko Stübner

Am Mittwoch, 24. November 2021, 03:13:25 CET schrieb Alex Bee:

Quoted 25 lines

With the submission of iommu driver for RK3568 a subtle bug was
introduced: PAGE_DESC_HI_MASK1 and PAGE_DESC_HI_MASK2 have to be the other way arround - that leads to random errors, especially when addresses beyond 32 bit are used.

Fix it.

Fixes c55356c534aa ("iommu: rockchip: Add support for iommu v2")

---

I've found this bug, when testing the recent VOP2 submission, which is the first perpherial which uses iommu for RK356x. I could use it on my quartz64 8GB board only, when limiting the available memory to less 4GB.

This patch fixes it.

 drivers/iommu/rockchip-iommu.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/iommu/rockchip-iommu.c +0 -0
index 5cb260820eda..7f23ad61c094 100644

drivers/iommu/rockchip-iommu.c static inline phys_addr_t rk_dte_pt_address(u32 dte) · line 204

Quoted 7 lines
drivers/iommu/rockchip-iommu.c +2 -2
@@ -200,8 +200,8 @@ static inline phys_addr_t rk_dte_pt_address(u32 dte)
 #define DTE_HI_MASK2 GENMASK(7, 4)
 #define DTE_HI_SHIFT1        24 /* shift bit 8 to bit 32 */
 #define DTE_HI_SHIFT2        32 /* shift bit 4 to bit 36 */
-#define PAGE_DESC_HI_MASK1   GENMASK_ULL(39, 36)
-#define PAGE_DESC_HI_MASK2   GENMASK_ULL(35, 32)
+#define PAGE_DESC_HI_MASK1   GENMASK_ULL(35, 32)
+#define PAGE_DESC_HI_MASK2   GENMASK_ULL(39, 36)

With this change the PAGE_DESC_HI_MASK* now match the other constants above them in what bits they access, so

Quoted 3 lines

Tested on the quartz64-a board with the experimental vop2 driver, confirmed it fixed the issue.

Quoted 7 lines

_______________________________________________
Linux-rockchip mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-rockchip

_______________________________________________
iommu mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/iommu

Tested-by
#4 lore raw

Den 24.11.2021 kl. 13.44 skrev Peter Geis:

Quoted 37 lines · Heiko Stübner
Quoted 36 lines

Am Mittwoch, 24. November 2021, 03:13:25 CET schrieb Alex Bee:

Quoted 25 lines

With the submission of iommu driver for RK3568 a subtle bug was
introduced: PAGE_DESC_HI_MASK1 and PAGE_DESC_HI_MASK2 have to be the other way arround - that leads to random errors, especially when addresses beyond 32 bit are used.

Fix it.

Fixes c55356c534aa ("iommu: rockchip: Add support for iommu v2")

---

I've found this bug, when testing the recent VOP2 submission, which is the first perpherial which uses iommu for RK356x. I could use it on my quartz64 8GB board only, when limiting the available memory to less 4GB.

This patch fixes it.

  drivers/iommu/rockchip-iommu.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
drivers/iommu/rockchip-iommu.c +0 -0
index 5cb260820eda..7f23ad61c094 100644

drivers/iommu/rockchip-iommu.c static inline phys_addr_t rk_dte_pt_address(u32 dte) · line 204

Quoted 7 lines
drivers/iommu/rockchip-iommu.c +2 -2
@@ -200,8 +200,8 @@ static inline phys_addr_t rk_dte_pt_address(u32 dte)
  #define DTE_HI_MASK2 GENMASK(7, 4)
  #define DTE_HI_SHIFT1        24 /* shift bit 8 to bit 32 */
  #define DTE_HI_SHIFT2        32 /* shift bit 4 to bit 36 */
-#define PAGE_DESC_HI_MASK1   GENMASK_ULL(39, 36)
-#define PAGE_DESC_HI_MASK2   GENMASK_ULL(35, 32)
+#define PAGE_DESC_HI_MASK1   GENMASK_ULL(35, 32)
+#define PAGE_DESC_HI_MASK2   GENMASK_ULL(39, 36)

With this change the PAGE_DESC_HI_MASK* now match the other constants above them in what bits they access, so

Quoted 5 lines
Quoted 3 lines

Tested on the quartz64-a board with the experimental vop2 driver, confirmed it fixed the issue.

Tested on my Quartz64 Model A with 8 GB with the experimental vop2 driver on 1440p monitor.

Confirmed to fix the issue, as I know how display out that works.

Quoted 13 lines
Quoted 6 lines

_______________________________________________
Linux-rockchip mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-rockchip

_______________________________________________
Linux-rockchip mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-rockchip

Signature · 7 lines
Kind regards
Dan Johansen

_______________________________________________
Linux-rockchip mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-rockchip
maintainer
#5 lore raw
In reply to Alex Bee
Quoted 9 lines · Alex Bee

With the submission of iommu driver for RK3568 a subtle bug was
introduced: PAGE_DESC_HI_MASK1 and PAGE_DESC_HI_MASK2 have to be the other way arround - that leads to random errors, especially when addresses beyond 32 bit are used.

Fix it.

Fixes c55356c534aa ("iommu: rockchip: Add support for iommu v2")

Applied for v5.16, thanks.