Skip to contentSkip to conversation

Fix some bugs on RV32 build fail and issue

PATCH In review Zong Li 2 participants 8 messages Oct 3, 2018 – Oct 15, 2018

Subsystems (2)
lore
Share & tools
lore

Zong Li

author
#0 lore raw

v4 cover Fix some bugs on RV32 build fail and issue

This patches contain the modificaion as follows:
1. Fix up the building fail on RV32.
2. Add umoddi3 and udivmoddi4 functions for RV32.
3. Fix ioremap problem on RV32.

Thanks all for review these code and modify the copyright description.

Changes in v4:
- Retain the complete copyright description.
- Modify commit message.
- Rebase upstream code.

Changes in v3:
- Change the copyright notices to GPLv2 from gcc 4.2.1.

Changes in v2:
- Retain the copyright notices from libgcc in umoddi3.c and udivmoddi4.c.

Vincent Chen (1):
RISC-V: Avoid corrupting the upper 32-bit of phys_addr_t in ioremap

Zong Li (4):
RISC-V: Build tishift only on 64-bit
RISC-V: Add preprocessor directive for swiotlb
lib: Add umoddi3 and udivmoddi4 of GCC library routines
RISC-V: Select GENERIC_LIB_UMODDI3 on RV32

 arch/riscv/Kconfig        |   1 +
 arch/riscv/kernel/setup.c |   3 +
 arch/riscv/lib/Makefile   |   3 +-
 arch/riscv/mm/ioremap.c   |   2 +-
 lib/Kconfig               |   3 +
 lib/Makefile              |   1 +
 lib/udivmoddi4.c          | 326 ++++++++++++++++++++++++++++++++++++++++++++++
 lib/umoddi3.c             |  48 +++++++
 8 files changed, 385 insertions(+), 2 deletions(-)
 create mode 100644 lib/udivmoddi4.c
 create mode 100644 lib/umoddi3.c
Signature · 1 line
2.7.4
author
#1 lore raw

PATCH v4 1/5 RISC-V: Build tishift only on 64-bit

Only RV64 supports 128 integer size.

---
 arch/riscv/lib/Makefile | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
arch/riscv/lib/Makefile +2 -1
index 445ec84..5739bd0 100644
@@ -2,6 +2,7 @@ lib-y	+= delay.o
 lib-y	+= memcpy.o
 lib-y	+= memset.o
 lib-y	+= uaccess.o
-lib-y	+= tishift.o
+
+lib-(CONFIG_64BIT) += tishift.o
 
 lib-$(CONFIG_32BIT) += udivdi3.o
Signature · 1 line
2.7.4
author
#2 lore raw

PATCH v4 2/5 RISC-V: Add preprocessor directive for swiotlb

In reply to Zong Li

On RV32, it doesn't select the SWIOTLB, only RV64 support swiotlb now.

---
 arch/riscv/kernel/setup.c | 3 +++
 1 file changed, 3 insertions(+)
arch/riscv/kernel/setup.c +3 -0
index aee6031..6de6584 100644
@@ -227,7 +227,10 @@ void __init setup_arch(char **cmdline_p)
 	setup_bootmem();
 	paging_init();
 	unflatten_device_tree();
+
+#ifdef CONFIG_SWIOTLB
 	swiotlb_init(1);
+#endif
 
 #ifdef CONFIG_SMP
 	setup_smp();
Signature · 1 line
2.7.4
author
#3 lore raw

PATCH v4 3/5 lib: Add umoddi3 and udivmoddi4 of GCC library routines

In reply to Zong Li

Add umoddi3 and udivmoddi4 support for 32-bit.

The RV32 need the umoddi3 to do modulo when the operands are long long type, like other libraries implementation such as ucmpdi2, lshrdi3 and so on.

I encounter the undefined reference 'umoddi3' when I use the in house dma driver, although it is in house driver, but I think that umoddi3 is a common function for RV32.

The udivmoddi4 and umoddi3 are copies from libgcc in gcc 4.2.1. There are other functions use the udivmoddi4 in libgcc, so I separate the umoddi3 and udivmoddi4 for flexible extension in the future.

---
 lib/Kconfig      |   3 +
 lib/Makefile     |   1 +
 lib/udivmoddi4.c | 326 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 lib/umoddi3.c    |  48 ++++++++
 4 files changed, 378 insertions(+)
 create mode 100644 lib/udivmoddi4.c
 create mode 100644 lib/umoddi3.c
lib/Kconfig +3 -0
index a3928d4..d82f206 100644
@@ -621,3 +621,6 @@ config GENERIC_LIB_CMPDI2
 
 config GENERIC_LIB_UCMPDI2
 	bool
+
+config GENERIC_LIB_UMODDI3
+	bool
lib/Makefile +1 -0
index ca3f7eb..51bf24d 100644
@@ -271,3 +271,4 @@ obj-$(CONFIG_GENERIC_LIB_LSHRDI3) += lshrdi3.o
 obj-$(CONFIG_GENERIC_LIB_MULDI3) += muldi3.o
 obj-$(CONFIG_GENERIC_LIB_CMPDI2) += cmpdi2.o
 obj-$(CONFIG_GENERIC_LIB_UCMPDI2) += ucmpdi2.o
+obj-$(CONFIG_GENERIC_LIB_UMODDI3) += umoddi3.o udivmoddi4.o
lib/udivmoddi4.c new file +326 -0

326 lines not on this page · raw message

lib/umoddi3.c new file +48 -0

48 lines not on this page · raw message

Signature · 1 line
2.7.4
author
#4 lore raw

PATCH v4 4/5 RISC-V: Select GENERIC_LIB_UMODDI3 on RV32

In reply to Zong Li

On RV32, it will use the __umoddi3. Select GENERIC_LIB_UMODDI3 to avoid undefined reference.

---
 arch/riscv/Kconfig | 1 +
 1 file changed, 1 insertion(+)
arch/riscv/Kconfig +1 -0
index a344980..dc262fa 100644
@@ -108,6 +108,7 @@ config ARCH_RV32I
 	select GENERIC_LIB_ASHRDI3
 	select GENERIC_LIB_LSHRDI3
 	select GENERIC_LIB_UCMPDI2
+	select GENERIC_LIB_UMODDI3
 
 config ARCH_RV64I
 	bool "RV64I"
Signature · 1 line
2.7.4
author
#5 lore raw

PATCH v4 5/5 RISC-V: Avoid corrupting the upper 32-bit of phys_addr_t in ioremap

In reply to Zong Li

From: Vincent Chen <[email protected]>

For 32bit, the upper 32-bit of phys_addr_t will be flushed to zero after AND with PAGE_MASK because the data type of PAGE_MASK is unsigned long. To fix this problem, the page alignment is done by subtracting the page offset instead of AND with PAGE_MASK.

---
 arch/riscv/mm/ioremap.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/riscv/mm/ioremap.c +1 -1
index 70ef272..bd2f2db 100644
@@ -42,7 +42,7 @@ static void __iomem *__ioremap_caller(phys_addr_t addr, size_t size,
 
 	/* Page-align mappings */
 	offset = addr & (~PAGE_MASK);
-	addr &= PAGE_MASK;
+	addr -= offset;
 	size = PAGE_ALIGN(size + offset);
 
 	area = get_vm_area_caller(size, VM_IOREMAP, caller);
Signature · 1 line
2.7.4
author
#6 lore raw
In reply to Zong Li

Zong Li <[email protected]> ? 2018?10?3? ?? ??11:12???

Quoted 40 lines

This patches contain the modificaion as follows:
1. Fix up the building fail on RV32.
2. Add umoddi3 and udivmoddi4 functions for RV32.
3. Fix ioremap problem on RV32.

Thanks all for review these code and modify the copyright description.

Changes in v4:
- Retain the complete copyright description.
- Modify commit message.
- Rebase upstream code.

Changes in v3:
- Change the copyright notices to GPLv2 from gcc 4.2.1.

Changes in v2:
- Retain the copyright notices from libgcc in umoddi3.c and udivmoddi4.c.

Vincent Chen (1):
RISC-V: Avoid corrupting the upper 32-bit of phys_addr_t in ioremap

Zong Li (4):
RISC-V: Build tishift only on 64-bit
RISC-V: Add preprocessor directive for swiotlb
lib: Add umoddi3 and udivmoddi4 of GCC library routines
RISC-V: Select GENERIC_LIB_UMODDI3 on RV32

 arch/riscv/Kconfig        |   1 +
 arch/riscv/kernel/setup.c |   3 +
 arch/riscv/lib/Makefile   |   3 +-
 arch/riscv/mm/ioremap.c   |   2 +-
 lib/Kconfig               |   3 +
 lib/Makefile              |   1 +
 lib/udivmoddi4.c          | 326 ++++++++++++++++++++++++++++++++++++++++++++++
 lib/umoddi3.c             |  48 +++++++
 8 files changed, 385 insertions(+), 2 deletions(-)
 create mode 100644 lib/udivmoddi4.c
 create mode 100644 lib/umoddi3.c
Quoted 3 lines

--
2.7.4

ping

#7 lore raw
Quoted 41 lines · zongbox at gmail.com

Zong Li <[email protected]> ? 2018?10?3? ?? ??11:12???

Quoted 40 lines

This patches contain the modificaion as follows:
1. Fix up the building fail on RV32.
2. Add umoddi3 and udivmoddi4 functions for RV32.
3. Fix ioremap problem on RV32.

Thanks all for review these code and modify the copyright description.

Changes in v4:
- Retain the complete copyright description.
- Modify commit message.
- Rebase upstream code.

Changes in v3:
- Change the copyright notices to GPLv2 from gcc 4.2.1.

Changes in v2:
- Retain the copyright notices from libgcc in umoddi3.c and udivmoddi4.c.

Vincent Chen (1):
RISC-V: Avoid corrupting the upper 32-bit of phys_addr_t in ioremap

Zong Li (4):
RISC-V: Build tishift only on 64-bit
RISC-V: Add preprocessor directive for swiotlb
lib: Add umoddi3 and udivmoddi4 of GCC library routines
RISC-V: Select GENERIC_LIB_UMODDI3 on RV32

 arch/riscv/Kconfig        |   1 +
 arch/riscv/kernel/setup.c |   3 +
 arch/riscv/lib/Makefile   |   3 +-
 arch/riscv/mm/ioremap.c   |   2 +-
 lib/Kconfig               |   3 +
 lib/Makefile              |   1 +
 lib/udivmoddi4.c          | 326 ++++++++++++++++++++++++++++++++++++++++++++++
 lib/umoddi3.c             |  48 +++++++
 8 files changed, 385 insertions(+), 2 deletions(-)
 create mode 100644 lib/udivmoddi4.c
 create mode 100644 lib/umoddi3.c
Quoted 5 lines
Quoted 3 lines

--
2.7.4

ping

Oh, sorry about that -- I took them into my local tree but they didn't make it to kernel.org. They should be in for-next now.