riscv: mm: update T-Head memory type definitions
PATCH 1/1 riscv: mm: update T-Head memory type definitions
Update T-Head memory type definitions according to C910 doc [1] For NC and IO, SH property isn't configurable, hardcoded as SH, so set SH for NOCACHE and IO.
And also set bit[61](Bufferable) for NOCACHE according to the table 6.1 in the doc [1].
--- arch/riscv/include/asm/pgtable-64.h | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-)
arch/riscv/include/asm/pgtable-64.h +9 -5
@@ -126,14 +126,18 @@ enum napot_cont_order {/* * [63:59] T-Head Memory Type definitions: -* -* 00000 - NC Weakly-ordered, Non-cacheable, Non-bufferable, Non-shareable, Non-trustable +* bit[63] SO - Strong Order +* bit[62] C - Cacheable +* bit[61] B - Bufferable +* bit[60] SH - Shareable +* bit[59] Sec - Trustable +* 00110 - NC Weakly-ordered, Non-cacheable, Bufferable, Shareable, Non-trustable * 01110 - PMA Weakly-ordered, Cacheable, Bufferable, Shareable, Non-trustable -* 10000 - IO Strongly-ordered, Non-cacheable, Non-bufferable, Non-shareable, Non-trustable +* 10010 - IO Strongly-ordered, Non-cacheable, Non-bufferable, Shareable, Non-trustable */ #define _PAGE_PMA_THEAD ((1UL << 62) | (1UL << 61) | (1UL << 60)) -#define _PAGE_NOCACHE_THEAD 0UL -#define _PAGE_IO_THEAD (1UL << 63) +#define _PAGE_NOCACHE_THEAD ((1UL < 61) | (1UL << 60)) +#define _PAGE_IO_THEAD ((1UL << 63) | (1UL << 60))#define _PAGE_MTMASK_THEAD (_PAGE_PMA_THEAD | _PAGE_IO_THEAD | (1UL << 59))static inline u64 riscv_page_mtmask (void )
Signature · 7 lines
2.40.1 _______________________________________________ linux-riscv mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-riscv
Quoted 29 lines · Jisheng Zhang
Update T-Head memory type definitions according to C910 doc [1] For NC and IO, SH property isn't configurable, hardcoded as SH, so set SH for NOCACHE and IO.
And also set bit[61](Bufferable) for NOCACHE according to the table 6.1 in the doc [1].
Signed-off-by Jisheng Zhang <[email protected]>--- arch/riscv/include/asm/pgtable-64.h | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-)arch/riscv/include/asm/pgtable-64.h +5
-2@@ -126,14 +126,18 @@ enum napot_cont_order {/* * [63:59] T-Head Memory Type definitions: -* -* 00000 - NC Weakly-ordered, Non-cacheable, Non-bufferable, Non-shareable, Non-trustable +* bit[63] SO - Strong Order +* bit[62] C - Cacheable +* bit[61] B - Bufferable +* bit[60] SH - Shareable +* bit[59] Sec - Trustable
arch/riscv/include/asm/pgtable-64.h enum napot_cont_order { · line 140
Quoted 10 lines
arch/riscv/include/asm/pgtable-64.h +4
-3+* 00110 - NC Weakly-ordered, Non-cacheable, Bufferable, Shareable, Non-trustable * 01110 - PMA Weakly-ordered, Cacheable, Bufferable, Shareable, Non-trustable -* 10000 - IO Strongly-ordered, Non-cacheable, Non-bufferable, Non-shareable, Non-trustable +* 10010 - IO Strongly-ordered, Non-cacheable, Non-bufferable, Shareable, Non-trustable */ #define _PAGE_PMA_THEAD ((1UL << 62) | (1UL << 61) | (1UL << 60)) -#define _PAGE_NOCACHE_THEAD 0UL -#define _PAGE_IO_THEAD (1UL << 63) +#define _PAGE_NOCACHE_THEAD ((1UL < 61) | (1UL << 60)) +#define _PAGE_IO_THEAD ((1UL << 63) | (1UL << 60))
Yes, SH does not affect D1, but let's keep th1520 & d1 & sg2042 with the same definitions.
Quoted 6 lines
arch/riscv/include/asm/pgtable-64.h +0
-1#define _PAGE_MTMASK_THEAD (_PAGE_PMA_THEAD | _PAGE_IO_THEAD | (1UL << 59))static inline u64 riscv_page_mtmask (void ) --2.40.1
Signature · 7 lines
Best Regards Guo Ren _______________________________________________ linux-riscv mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-riscv
Quoted 44 lines · Jisheng Zhang
Update T-Head memory type definitions according to C910 doc [1] For NC and IO, SH property isn't configurable, hardcoded as SH, so set SH for NOCACHE and IO.
And also set bit[61](Bufferable) for NOCACHE according to the table 6.1 in the doc [1].
Signed-off-by Jisheng Zhang <[email protected]>--- arch/riscv/include/asm/pgtable-64.h | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-)arch/riscv/include/asm/pgtable-64.h +9
-5@@ -126,14 +126,18 @@ enum napot_cont_order {/* * [63:59] T-Head Memory Type definitions: -* -* 00000 - NC Weakly-ordered, Non-cacheable, Non-bufferable, Non-shareable, Non-trustable +* bit[63] SO - Strong Order +* bit[62] C - Cacheable +* bit[61] B - Bufferable +* bit[60] SH - Shareable +* bit[59] Sec - Trustable +* 00110 - NC Weakly-ordered, Non-cacheable, Bufferable, Shareable, Non-trustable * 01110 - PMA Weakly-ordered, Cacheable, Bufferable, Shareable, Non-trustable -* 10000 - IO Strongly-ordered, Non-cacheable, Non-bufferable, Non-shareable, Non-trustable +* 10010 - IO Strongly-ordered, Non-cacheable, Non-bufferable, Shareable, Non-trustable */ #define _PAGE_PMA_THEAD ((1UL << 62) | (1UL << 61) | (1UL << 60)) -#define _PAGE_NOCACHE_THEAD 0UL -#define _PAGE_IO_THEAD (1UL << 63) +#define _PAGE_NOCACHE_THEAD ((1UL < 61) | (1UL << 60)) +#define _PAGE_IO_THEAD ((1UL << 63) | (1UL << 60))#define _PAGE_MTMASK_THEAD (_PAGE_PMA_THEAD | _PAGE_IO_THEAD | (1UL << 59))static inline u64 riscv_page_mtmask (void )Signature · 1 line
2.40.1
I applied this on top of:
[1] riscv: errata: improve T-Head CMO
[2] riscv: dts: thead: set dma-noncoherent to soc bus
[3] RISC-V: Add basic eMMC support for BeagleV Ahead
The BeagleV Ahead eMMC continues to function okay in ADMA mode after this patch was applied.
Thanks,
Drew
[1] https://lore.kernel.org/linux-riscv/[email protected]/
[2] https://lore.kernel.org/linux-riscv/ZOIBQI3L4kP7c%2FT1@xhacker/
[3] https://lore.kernel.org/linux-riscv/[email protected]/