Skip to contentSkip to conversation

MIPS64 support

RFC PATCH In review Peter Mamonov 3 participants 22 messages May 17, 2018 – May 18, 2018

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

cover MIPS64 support

Hi,

Recently I've resolved a couple of issues that prevented 64bit Barebox from running on MIPS64 CPUs. By the way, 32bit Barebox runs on MIPS64 without any issues, since MIPS64 supports 32 bit addressing mode. Here is a relevant patch series. This is mostly for discussion, yet some patches can be applied as is. Please, give your comments.

Regards,
Peter

Peter Mamonov (15):
FIXME: add t4..t7 definitions for MIPS64
MIPS: use CKSEG1 instead of KSEG1
FIXME: mips: fix copy_to_link_location for 64 bit mode
mips: fix warnings from CPHYSADDR() macro
mips: fix dma_sync_* stuff for MIPS64
common/Kconfig: add PHYS_ADDR_T_64BIT option
mips: 64BIT selects PHYS_ADDR_T_64BIT
fixup! MIPS: import optimized string functions from Linux
MIPS: import 64-bit address conversion macros
common.h: fix IOMEM() for MIPS64
resource: fix iomem root resource for 64 bit
FIXME: commands/mem: fix /dev/mem size
FIXME: fs: fix memory access for 64bit MIPS
mtd: cfi-flash: fix write_buff() for 64BIT i2c/muxes/i2c-mux-pca954x: fix private data retrieval for 64bit mode

 arch/mips/Kconfig                   |  2 ++
 arch/mips/boot/dtb.c                |  4 ++--
 arch/mips/include/asm/addrspace.h   | 25 +++++++++++++++++++++++++
 arch/mips/include/asm/dma-mapping.h |  2 +-
 arch/mips/include/asm/io.h          |  4 ++--
 arch/mips/include/asm/pbl_macros.h  | 24 ++++++++++++++++--------
 arch/mips/include/asm/regdef.h      |  4 ++++
 arch/mips/lib/c-r4k.c               | 26 +++++++++++++-------------
 arch/mips/lib/dma-default.c         |  6 ++++--
 commands/mem.c                      |  2 +-
 common/Kconfig                      |  3 +++
 common/resource.c                   |  4 ++++
 drivers/i2c/muxes/i2c-mux-pca954x.c |  4 +++-
 drivers/mtd/nor/cfi_flash.c         |  2 +-
 fs/fs.c                             |  6 ------
 include/common.h                    |  4 ++++
 16 files changed, 85 insertions(+), 37 deletions(-)
Signature · 7 lines
2.17.0


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#1 lore raw

RFC PATCH 1/15 FIXME: add t4..t7 definitions for MIPS64

---
 arch/mips/include/asm/regdef.h | 4 ++++
 1 file changed, 4 insertions(+)
arch/mips/include/asm/regdef.h +4 -0
index 7c8ecb6b9..5a31ea022 100644
@@ -66,12 +66,16 @@
 #define a3	$7
 #define a4	$8	/* arg reg 64 bit; caller saved in 32 bit */
 #define ta0	$8
+#define t4	$8
 #define a5	$9
 #define ta1	$9
+#define t5	$9
 #define a6	$10
 #define ta2	$10
+#define t6	$10
 #define a7	$11
 #define ta3	$11
+#define t7	$11
 #define t0	$12	/* caller saved */
 #define t1	$13
 #define t2	$14
Signature · 7 lines
2.17.0


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#2 lore raw

RFC PATCH 2/15 MIPS: use CKSEG1 instead of KSEG1

In reply to Peter Mamonov
---
 arch/mips/boot/dtb.c  | 4 ++--
 arch/mips/lib/c-r4k.c | 8 ++++----
 2 files changed, 6 insertions(+), 6 deletions(-)
arch/mips/boot/dtb.c +2 -2
index e7633a5af..3f7f46641 100644
@@ -30,10 +30,10 @@ void of_add_memory_bank(struct device_node *node, bool dump, int r,
 
 	if (IS_ENABLED(CONFIG_MMU)) {
 		sprintf(str, "kseg0_ram%d", r);
-		barebox_add_memory_bank(str, KSEG0 | base, size);
+		barebox_add_memory_bank(str, CKSEG0 | base, size);
 	} else {
 		sprintf(str, "kseg1_ram%d", r);
-		barebox_add_memory_bank(str, KSEG1 | base, size);
+		barebox_add_memory_bank(str, CKSEG1 | base, size);
 	}
 
 	if (dump)
arch/mips/lib/c-r4k.c +4 -4
index 150205840..cb0544a53 100644
@@ -58,14 +58,14 @@ void flush_cache_all(void)
 
 	dcache_size = c->dcache.waysize * c->dcache.ways;
 	lsize = c->dcache.linesz;
-	aend = (KSEG0 + dcache_size - 1) & ~(lsize - 1);
-	for (addr = KSEG0; addr <= aend; addr += lsize)
+	aend = (CKSEG0 + dcache_size - 1) & ~(lsize - 1);
+	for (addr = CKSEG0; addr <= aend; addr += lsize)
 		cache_op(Index_Writeback_Inv_D, addr);
 
 	icache_size = c->icache.waysize * c->icache.ways;
 	lsize = c->icache.linesz;
-	aend = (KSEG0 + icache_size - 1) & ~(lsize - 1);
-	for (addr = KSEG0; addr <= aend; addr += lsize)
+	aend = (CKSEG0 + icache_size - 1) & ~(lsize - 1);
+	for (addr = CKSEG0; addr <= aend; addr += lsize)
 		cache_op(Index_Invalidate_I, addr);
 
 	/* secondatory cache skipped */
Signature · 7 lines
2.17.0


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#3 lore raw

RFC PATCH 3/15 FIXME: mips: fix copy_to_link_location for 64 bit mode

In reply to Peter Mamonov

A better solution: use 4 instead of LONGSIZE

---
 arch/mips/include/asm/pbl_macros.h | 24 ++++++++++++++++--------
 1 file changed, 16 insertions(+), 8 deletions(-)
arch/mips/include/asm/pbl_macros.h +16 -8
index 37b150ac2..8950b400d 100644
@@ -134,17 +134,25 @@
 	subu	t2, t1, t0	/* t2 <- size of pbl */
 	addu	a2, a0, t2	/* a2 <- source end address */
 
+#if (LONGSIZE == 4)
+#define LW	lw
+#define SW	sw
+#endif
+#if (LONGSIZE == 8)
+#define LW	ld
+#define SW	sd
+#endif
 copy_loop:
 	/* copy from source address [a0] */
-	lw	t4, LONGSIZE * 0(a0)
-	lw	t5, LONGSIZE * 1(a0)
-	lw	t6, LONGSIZE * 2(a0)
-	lw	t7, LONGSIZE * 3(a0)
+	LW	t4, LONGSIZE * 0(a0)
+	LW	t5, LONGSIZE * 1(a0)
+	LW	t6, LONGSIZE * 2(a0)
+	LW	t7, LONGSIZE * 3(a0)
 	/* copy to target address [a1] */
-	sw	t4, LONGSIZE * 0(a1)
-	sw	t5, LONGSIZE * 1(a1)
-	sw	t6, LONGSIZE * 2(a1)
-	sw	t7, LONGSIZE * 3(a1)
+	SW	t4, LONGSIZE * 0(a1)
+	SW	t5, LONGSIZE * 1(a1)
+	SW	t6, LONGSIZE * 2(a1)
+	SW	t7, LONGSIZE * 3(a1)
 	addi	a0, LONGSIZE * 4
 	subu	t3, a0, a2
 	blez	t3, copy_loop
Signature · 7 lines
2.17.0


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#4 lore raw

RFC PATCH 4/15 mips: fix warnings from CPHYSADDR() macro

In reply to Peter Mamonov
---
 arch/mips/include/asm/addrspace.h | 5 +++++
 1 file changed, 5 insertions(+)
arch/mips/include/asm/addrspace.h +5 -0
index 17d480d08..04d0f95db 100644
@@ -48,7 +48,12 @@
 /*
  * Returns the physical address of a CKSEGx / XKPHYS address
  */
+#ifdef CONFIG_ARCH_DMA_ADDR_T_64BIT
+#define CPHYSADDR(a)		((_ACAST64_(a)) & 0x1fffffff)
+#else
 #define CPHYSADDR(a)		((_ACAST32_(a)) & 0x1fffffff)
+#endif
+
 #define XPHYSADDR(a)            ((_ACAST64_(a)) &			\
 				 _CONST64_(0x000000ffffffffff))
 
Signature · 7 lines
2.17.0


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#5 lore raw

RFC PATCH 5/15 mips: fix dma_sync_* stuff for MIPS64

In reply to Peter Mamonov
---
 arch/mips/include/asm/dma-mapping.h |  2 +-
 arch/mips/include/asm/io.h          |  4 ++--
 arch/mips/lib/c-r4k.c               | 26 +++++++++++++-------------
 arch/mips/lib/dma-default.c         |  6 ++++--
 4 files changed, 20 insertions(+), 18 deletions(-)
arch/mips/include/asm/dma-mapping.h +1 -1
index c71a08703..d4cbb3cac 100644
@@ -19,7 +19,7 @@ static inline void *dma_alloc_coherent(size_t size, dma_addr_t *dma_handle)
 	if (dma_handle)
 		*dma_handle = CPHYSADDR(ret);
 
-	dma_flush_range((unsigned long)ret, (unsigned long)(ret + size));
+	dma_flush_range(ret, ret + size);
 
 	return (void *)CKSEG1ADDR(ret);
 }
arch/mips/include/asm/io.h +2 -2
index 5a4cbf564..07b337e76 100644
@@ -15,8 +15,8 @@
 #include <asm/addrspace.h>
 #include <asm/byteorder.h>
 
-void dma_flush_range(unsigned long, unsigned long);
-void dma_inv_range(unsigned long, unsigned long);
+void dma_flush_range(void *, void *);
+void dma_inv_range(void *, void *);
 
 /*
  *     virt_to_phys - map virtual addresses to physical
arch/mips/lib/c-r4k.c +13 -13
index cb0544a53..2d652be61 100644
@@ -27,12 +27,12 @@
 	: "i" (op), "R" (*(unsigned char *)(addr)))
 
 #define __BUILD_BLAST_CACHE_RANGE(pfx, desc, hitop)			\
-static inline void blast_##pfx##cache##_range(unsigned long start,	\
-					      unsigned long end)	\
+static inline void blast_##pfx##cache##_range(void *start,		\
+					      void *end)		\
 {									\
-	unsigned long lsize = current_cpu_data.desc.linesz;		\
-	unsigned long addr = start & ~(lsize - 1);			\
-	unsigned long aend = (end - 1) & ~(lsize - 1);			\
+	uintptr_t lsize = current_cpu_data.desc.linesz;			\
+	void *addr = (void *)((uintptr_t)start & ~(lsize - 1));		\
+	void *aend = (void *)(((uintptr_t)end - 1) & ~(lsize - 1));	\
 									\
 	if (current_cpu_data.desc.flags & MIPS_CACHE_NOT_PRESENT)	\
 		return;							\
@@ -52,33 +52,33 @@ void flush_cache_all(void)
 {
 	struct cpuinfo_mips *c = &current_cpu_data;
 	unsigned long lsize;
-	unsigned long addr;
-	unsigned long aend;
+	void *addr;
+	void *aend;
 	unsigned int icache_size, dcache_size;
 
 	dcache_size = c->dcache.waysize * c->dcache.ways;
 	lsize = c->dcache.linesz;
-	aend = (CKSEG0 + dcache_size - 1) & ~(lsize - 1);
-	for (addr = CKSEG0; addr <= aend; addr += lsize)
+	aend = (void *)((CKSEG0 + dcache_size - 1) & ~(lsize - 1));
+	for (addr = (void *)CKSEG0; addr <= aend; addr += lsize)
 		cache_op(Index_Writeback_Inv_D, addr);
 
 	icache_size = c->icache.waysize * c->icache.ways;
 	lsize = c->icache.linesz;
-	aend = (CKSEG0 + icache_size - 1) & ~(lsize - 1);
-	for (addr = CKSEG0; addr <= aend; addr += lsize)
+	aend = (void *)((CKSEG0 + icache_size - 1) & ~(lsize - 1));
+	for (addr = (void *)CKSEG0; addr <= aend; addr += lsize)
 		cache_op(Index_Invalidate_I, addr);
 
 	/* secondatory cache skipped */
 }
 
-void dma_flush_range(unsigned long start, unsigned long end)
+void dma_flush_range(void *start, void *end)
 {
 	blast_dcache_range(start, end);
 
 	/* secondatory cache skipped */
 }
 
-void dma_inv_range(unsigned long start, unsigned long end)
+void dma_inv_range(void *start, void *end)
 {
 	blast_inv_dcache_range(start, end);
 
arch/mips/lib/dma-default.c +4 -2
index 71c1e423b..79d61afd8 100644
@@ -17,9 +17,11 @@
 
 #if defined(CONFIG_CPU_MIPS32) || \
 	defined(CONFIG_CPU_MIPS64)
-static inline void __dma_sync_mips(unsigned long addr, size_t size,
+static inline void __dma_sync_mips(dma_addr_t _addr, size_t size,
 				   enum dma_data_direction direction)
 {
+	void *addr = (void *)CKSEG0ADDR(_addr);
+
 	switch (direction) {
 	case DMA_TO_DEVICE:
 		dma_flush_range(addr, addr + size);
@@ -38,7 +40,7 @@ static inline void __dma_sync_mips(unsigned long addr, size_t size,
 	}
 }
 #else
-static inline void __dma_sync_mips(void *addr, size_t size,
+static inline void __dma_sync_mips(dma_addr_t _addr, size_t size,
 	enum dma_data_direction direction)
 {
 }
Signature · 7 lines
2.17.0


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#6 lore raw

Re: [RFC PATCH 05/15] mips: fix dma_sync_* stuff for MIPS64

Quoted 26 lines · Peter Mamonov
---
 arch/mips/include/asm/dma-mapping.h |  2 +-
 arch/mips/include/asm/io.h          |  4 ++--
 arch/mips/lib/c-r4k.c               | 26 +++++++++++++-------------
 arch/mips/lib/dma-default.c         |  6 ++++--
 4 files changed, 20 insertions(+), 18 deletions(-)
arch/mips/include/asm/dma-mapping.h +1 -1
index c71a08703..d4cbb3cac 100644
@@ -19,7 +19,7 @@ static inline void *dma_alloc_coherent(size_t size, dma_addr_t *dma_handle)
 	if (dma_handle)
 		*dma_handle = CPHYSADDR(ret);
 
-	dma_flush_range((unsigned long)ret, (unsigned long)(ret + size));
+	dma_flush_range(ret, ret + size);
 
 	return (void *)CKSEG1ADDR(ret);
 }
arch/mips/include/asm/io.h +0 -0
index 5a4cbf564..07b337e76 100644

arch/mips/include/asm/io.h line 19

Quoted 7 lines
arch/mips/include/asm/io.h +2 -2
@@ -15,8 +15,8 @@
 #include <asm/addrspace.h>
 #include <asm/byteorder.h>
 
-void dma_flush_range(unsigned long, unsigned long);
-void dma_inv_range(unsigned long, unsigned long);
+void dma_flush_range(void *, void *);
+void dma_inv_range(void *, void *);

Why is this changed? unsigned long should normally be wide enough to hold an address.

Sascha

Signature · 9 lines
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#7 lore raw

Re: [RFC PATCH 05/15] mips: fix dma_sync_* stuff for MIPS64

Hi, Sascha,

Quoted 30 lines · Sascha Hauer
Quoted 29 lines · Peter Mamonov
---
 arch/mips/include/asm/dma-mapping.h |  2 +-
 arch/mips/include/asm/io.h          |  4 ++--
 arch/mips/lib/c-r4k.c               | 26 +++++++++++++-------------
 arch/mips/lib/dma-default.c         |  6 ++++--
 4 files changed, 20 insertions(+), 18 deletions(-)
arch/mips/include/asm/dma-mapping.h +1 -1
index c71a08703..d4cbb3cac 100644
@@ -19,7 +19,7 @@ static inline void *dma_alloc_coherent(size_t size, dma_addr_t *dma_handle)
 	if (dma_handle)
 		*dma_handle = CPHYSADDR(ret);
 
-	dma_flush_range((unsigned long)ret, (unsigned long)(ret + size));
+	dma_flush_range(ret, ret + size);
 
 	return (void *)CKSEG1ADDR(ret);
 }
arch/mips/include/asm/io.h +0 -0
index 5a4cbf564..07b337e76 100644
@@ -15,8 +15,8 @@
 #include <asm/addrspace.h>
 #include <asm/byteorder.h>
 
Quoted 7 lines

arch/mips/include/asm/io.h line 19

Quoted 4 lines
arch/mips/include/asm/io.h +2 -2
-void dma_flush_range(unsigned long, unsigned long);
-void dma_inv_range(unsigned long, unsigned long);
+void dma_flush_range(void *, void *);
+void dma_inv_range(void *, void *);

Why is this changed? unsigned long should normally be wide enough to hold an address.

You are right, it doesn't fix anything. I've made these changes after taking a look at __dma_sync_virtual in linux/arch/mips/mm/dma-default.c, which accepts void* argument. So, I decided to change call signature of __dma_sync_mips() and this decision triggered the rest of the edits :). Sorry for misleading commit message.

Regards,
Peter

Quoted 9 lines

Sascha

Signature · 4 lines
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox

#8 lore raw

RFC PATCH 6/15 common/Kconfig: add PHYS_ADDR_T_64BIT option

In reply to Peter Mamonov
---
 common/Kconfig | 3 +++
 1 file changed, 3 insertions(+)
common/Kconfig +3 -0
index b7000c4d7..a5b53b2e4 100644
@@ -95,6 +95,9 @@ config FILE_LIST
 config ARCH_DMA_ADDR_T_64BIT
 	bool
 
+config PHYS_ADDR_T_64BIT
+	bool
+
 config BAREBOX_UPDATE_IMX_NAND_FCB
 	bool
 	depends on ARCH_IMX6 || ARCH_IMX28
Signature · 7 lines
2.17.0


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#9 lore raw

RFC PATCH 7/15 mips: 64BIT selects PHYS_ADDR_T_64BIT

In reply to Peter Mamonov
---
 arch/mips/Kconfig | 1 +
 1 file changed, 1 insertion(+)
arch/mips/Kconfig +1 -0
index c2c555dc3..deeda62ea 100644
@@ -275,6 +275,7 @@ config 64BIT
 	bool "64-bit barebox"
 	depends on CPU_SUPPORTS_64BIT_KERNEL && SYS_SUPPORTS_64BIT_KERNEL
 	select ARCH_DMA_ADDR_T_64BIT
+	select PHYS_ADDR_T_64BIT
 	help
 	  Select this option if you want to build a 64-bit barebox.
 
Signature · 7 lines
2.17.0


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#10 lore raw

RFC PATCH 8/15 fixup! MIPS: import optimized string functions from Linux

In reply to Peter Mamonov
---
 arch/mips/Kconfig | 1 +
 1 file changed, 1 insertion(+)
arch/mips/Kconfig +1 -0
index deeda62ea..9e8341e9f 100644
@@ -338,6 +338,7 @@ config NMON_HELP
 
 config MIPS_OPTIMIZED_STRING_FUNCTIONS
 	bool "use assembler optimized string functions"
+	depends on !64BIT
 	default y
 	help
 	  Say yes here to use assembler optimized memcpy / memset functions.
Signature · 7 lines
2.17.0


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#11 lore raw

RFC PATCH 9/15 MIPS: import 64-bit address conversion macros

In reply to Peter Mamonov
---
 arch/mips/include/asm/addrspace.h | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)
arch/mips/include/asm/addrspace.h +20 -0
index 04d0f95db..688620472 100644
@@ -78,6 +78,26 @@
 #define CKSEG2ADDR(a)		(CPHYSADDR(a) | CKSEG2)
 #define CKSEG3ADDR(a)		(CPHYSADDR(a) | CKSEG3)
 
+/*
+ * Cache modes for XKPHYS address conversion macros
+ */
+#define K_CALG_COH_EXCL1_NOL2	0
+#define K_CALG_COH_SHRL1_NOL2	1
+#define K_CALG_UNCACHED		2
+#define K_CALG_NONCOHERENT	3
+#define K_CALG_COH_EXCL		4
+#define K_CALG_COH_SHAREABLE	5
+#define K_CALG_NOTUSED		6
+#define K_CALG_UNCACHED_ACCEL	7
+
+/*
+ * 64-bit address conversions
+ */
+#define PHYS_TO_XKSEG_UNCACHED(p)	PHYS_TO_XKPHYS(K_CALG_UNCACHED, (p))
+#define PHYS_TO_XKSEG_CACHED(p)		PHYS_TO_XKPHYS(K_CALG_COH_SHAREABLE, (p))
+#define XKPHYS_TO_PHYS(p)		((p) & TO_PHYS_MASK)
+#define PHYS_TO_XKPHYS(cm, a)		(XKPHYS | (_ACAST64_(cm) << 59) | (a))
+
 #else
 
 #define CKSEG0ADDR(a)		(CPHYSADDR(a) | KSEG0)
Signature · 7 lines
2.17.0


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#12 lore raw

RFC PATCH 10/15 common.h: fix IOMEM() for MIPS64

In reply to Peter Mamonov
---
 include/common.h | 4 ++++
 1 file changed, 4 insertions(+)
include/common.h +4 -0
index 60e5005b8..4b3bcae40 100644
@@ -142,7 +142,11 @@ void barebox_set_hostname_no_overwrite(const char *);
 #if defined(CONFIG_MIPS)
 #include <asm/addrspace.h>
 
+#ifdef CONFIG_64BIT
+#define IOMEM(addr)	((void __force __iomem *)PHYS_TO_XKSEG_UNCACHED(addr))
+#else
 #define IOMEM(addr)	((void __force __iomem *)CKSEG1ADDR(addr))
+#endif
 #else
 #define IOMEM(addr)	((void __force __iomem *)(addr))
 #endif
Signature · 7 lines
2.17.0


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#13 lore raw

RFC PATCH 11/15 resource: fix iomem root resource for 64 bit

In reply to Peter Mamonov
---
 common/resource.c | 4 ++++
 1 file changed, 4 insertions(+)
common/resource.c +4 -0
index e4bbe15fd..1cf00a927 100644
@@ -114,7 +114,11 @@ int release_region(struct resource *res)
 /* The root resource for the whole memory-mapped io space */
 struct resource iomem_resource = {
 	.start = 0,
+#ifdef CONFIG_PHYS_ADDR_T_64BIT
+	.end = -1ull,
+#else
 	.end = 0xffffffff,
+#endif
 	.name = "iomem",
 	.children = LIST_HEAD_INIT(iomem_resource.children),
 };
Signature · 7 lines
2.17.0


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#14 lore raw

Re: [RFC PATCH 11/15] resource: fix iomem root resource for 64 bit

Quoted 10 lines · Peter Mamonov
---
 common/resource.c | 4 ++++
 1 file changed, 4 insertions(+)
common/resource.c +0 -0
index e4bbe15fd..1cf00a927 100644

common/resource.c int release_region(struct resource *res) · line 121

Quoted 8 lines
common/resource.c +4 -0
@@ -114,7 +114,11 @@ int release_region(struct resource *res)
 /* The root resource for the whole memory-mapped io space */
 struct resource iomem_resource = {
        .start = 0,
+#ifdef CONFIG_PHYS_ADDR_T_64BIT
+       .end = -1ull,
+#else
        .end = 0xffffffff,
+#endif

Would ".end = ~(resource_size_t)0" work instead? This way you'd avoid using preprocessor.

Thanks,
Andrey Smironv

Quoted 11 lines
common/resource.c +0 -1
        .name = "iomem",
        .children = LIST_HEAD_INIT(iomem_resource.children),
 };
--

2.17.0

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox

#15 lore raw

Re: [RFC PATCH 11/15] resource: fix iomem root resource for 64 bit

Hi, Andrey,

Quoted 6 lines · Andrey Smirnov
Quoted 5 lines · Peter Mamonov
---
 common/resource.c | 4 ++++
 1 file changed, 4 insertions(+)
Quoted 16 lines

common/resource.c int release_region(struct resource *res) · line 121

Quoted 13 lines
common/resource.c +4 -0
index e4bbe15fd..1cf00a927 100644
@@ -114,7 +114,11 @@ int release_region(struct resource *res)
 /* The root resource for the whole memory-mapped io space */
 struct resource iomem_resource = {
        .start = 0,
+#ifdef CONFIG_PHYS_ADDR_T_64BIT
+       .end = -1ull,
+#else
        .end = 0xffffffff,
+#endif

Would ".end = ~(resource_size_t)0" work instead? This way you'd avoid using preprocessor.

Guess it should work. Thanks for the tip!

Regards,
Peter

Quoted 15 lines

Thanks,
Andrey Smironv

Quoted 11 lines
common/resource.c +0 -1
        .name = "iomem",
        .children = LIST_HEAD_INIT(iomem_resource.children),
 };
--

2.17.0

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox

#16 lore raw

RFC PATCH 12/15 FIXME: commands/mem: fix /dev/mem size

In reply to Peter Mamonov
---
 commands/mem.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
commands/mem.c +1 -1
index eb91ade05..80cf5c79d 100644
@@ -96,7 +96,7 @@ static int mem_probe(struct device_d *dev)
 	dev->priv = cdev;
 
 	cdev->name = (char*)dev->resource[0].name;
-	cdev->size = (unsigned long)resource_size(&dev->resource[0]);
+	cdev->size = (loff_t)-1;
 	cdev->ops = &memops;
 	cdev->dev = dev;
 
Signature · 7 lines
2.17.0


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#17 lore raw

RFC PATCH 13/15 FIXME: fs: fix memory access for 64bit MIPS

In reply to Peter Mamonov

Address 0xFFFFFFFFxxxxxxxx is a valid MIPS64 address.

---
 fs/fs.c | 6 ------
 1 file changed, 6 deletions(-)
fs/fs.c +0 -6
index b66cc9b17..d4965c85e 100644
@@ -962,8 +962,6 @@ loff_t lseek(int fildes, loff_t offset, int whence)
 	case SEEK_SET:
 		if (f->size != FILE_SIZE_STREAM && offset > f->size)
 			goto out;
-		if (offset < 0)
-			goto out;
 		pos = offset;
 		break;
 	case SEEK_CUR:
@@ -981,10 +979,6 @@ loff_t lseek(int fildes, loff_t offset, int whence)
 	}
 
 	pos = fsdrv->lseek(&f->fsdev->dev, f, pos);
-	if (pos < 0) {
-		errno = -pos;
-		return -1;
-	}
 
 	return pos;
 
Signature · 7 lines
2.17.0


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#18 lore raw

RFC PATCH 14/15 mtd: cfi-flash: fix write_buff() for 64BIT

In reply to Peter Mamonov
---
 drivers/mtd/nor/cfi_flash.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mtd/nor/cfi_flash.c +1 -1
index 5bdcccae1..01ab1aa27 100644
@@ -515,7 +515,7 @@ static int write_buff(struct flash_info *info, const u8 *src,
 	int buffered_size;
 #endif
 	/* get lower aligned address */
-	wp = addr & ~(info->portwidth - 1);
+	wp = addr & ~((unsigned long)info->portwidth - 1);
 
 	/* handle unaligned start */
 	aln = addr - wp;
Signature · 7 lines
2.17.0


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#19 lore raw

RFC PATCH 15/15 i2c/muxes/i2c-mux-pca954x: fix private data retrieval for 64bit mode

In reply to Peter Mamonov
---
 drivers/i2c/muxes/i2c-mux-pca954x.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/i2c/muxes/i2c-mux-pca954x.c +3 -1
index 0d5515b71..395254cdc 100644
@@ -180,6 +180,7 @@ static int pca954x_probe(struct device_d *dev)
 	struct i2c_adapter *adap = to_i2c_adapter(client->dev.parent);
 	int num, force;
 	struct pca954x *data;
+	uintptr_t tmp;
 	int ret = -ENODEV;
 	int gpio;
 
@@ -203,7 +204,8 @@ static int pca954x_probe(struct device_d *dev)
 		goto exit_free;
 	}
 
-	ret = dev_get_drvdata(dev, (const void **)&data->type);
+	ret = dev_get_drvdata(dev, (const void **)&tmp);
+	data->type = tmp;
 	if (ret)
 		goto exit_free;
 
Signature · 7 lines
2.17.0


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#20 lore raw

Re: [RFC PATCH 15/15] i2c/muxes/i2c-mux-pca954x: fix private data retrieval for 64bit mode

Quoted 18 lines · Peter Mamonov
---
 drivers/i2c/muxes/i2c-mux-pca954x.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/i2c/muxes/i2c-mux-pca954x.c +1 -0
index 0d5515b71..395254cdc 100644
@@ -180,6 +180,7 @@ static int pca954x_probe(struct device_d *dev)
        struct i2c_adapter *adap = to_i2c_adapter(client->dev.parent);
        int num, force;
        struct pca954x *data;
+       uintptr_t tmp;
        int ret = -ENODEV;
        int gpio;
 

drivers/i2c/muxes/i2c-mux-pca954x.c static int pca954x_probe(struct device_d *dev) · line 208

Quoted 6 lines
drivers/i2c/muxes/i2c-mux-pca954x.c +2 -1
@@ -203,7 +204,8 @@ static int pca954x_probe(struct device_d *dev)
                goto exit_free;
        }
 
-       ret = dev_get_drvdata(dev, (const void **)&data->type);
+       ret = dev_get_drvdata(dev, (const void **)&tmp);
+       data->type = tmp;

Upstream Linux driver doesn't store "type", but the actual pointer to "chip_desc". I think if you convert the driver to do that instead you can avoid type width problems and not need helper variable minutiae.

Thanks,
Andrey Smirnov

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox

#21 lore raw
In reply to Peter Mamonov

Hi Peter,

Quoted 7 lines · Peter Mamonov

Hi,

Recently I've resolved a couple of issues that prevented 64bit Barebox from running on MIPS64 CPUs. By the way, 32bit Barebox runs on MIPS64 without any issues, since MIPS64 supports 32 bit addressing mode. Here is a relevant patch series. This is mostly for discussion, yet some patches can be applied as is. Please, give your comments.

Please sort the patches that can be applied to the beginning of this series so that we can get this done early.

Sascha

Signature · 9 lines
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox