Skip to contentSkip to conversation

various fixes for MIPS64

PATCH Superseded Peter Mamonov 5 participants 29 messages May 21, 2018 – May 22, 2018

Subsystems (4)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

v2 cover various fixes for MIPS64

Hi,

Here is a second revision of the patchset which fixes various issues with 64 bit barebox, primarily MIPS related. IMHO all of these patches are ready for application.

Regards,
Peter

Peter Mamonov (12):
resource: fix iomem root resource for 64 bit
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
MIPS: import 64-bit address conversion macros
common.h: fix IOMEM() for MIPS64
mips: fix copy_to_link_location for 64 bit mode
MIPS: use CKSEG1 instead of KSEG1
mips: fix warnings from CPHYSADDR() macro
mips: add PHYS_ADDR_T_64BIT option
mips: 64BIT selects PHYS_ADDR_T_64BIT
fixup! MIPS: import optimized string functions from Linux

 arch/mips/Kconfig                   |  6 ++++++
 arch/mips/boot/dtb.c                |  4 ++--
 arch/mips/include/asm/addrspace.h   | 25 +++++++++++++++++++++++++
 arch/mips/include/asm/pbl_macros.h  | 21 +++++++++++----------
 arch/mips/lib/c-r4k.c               |  8 ++++----
 common/resource.c                   |  2 +-
 drivers/i2c/muxes/i2c-mux-pca954x.c |  4 +++-
 drivers/mtd/nor/cfi_flash.c         |  2 +-
 fs/fs.c                             |  4 ++--
 include/common.h                    |  4 ++++
 10 files changed, 59 insertions(+), 21 deletions(-)
Signature · 7 lines
2.17.0


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

PATCH v2 1/12 resource: fix iomem root resource for 64 bit

---
 common/resource.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
common/resource.c +1 -1
index e4bbe15fd..abc0814d2 100644
@@ -114,7 +114,7 @@ int release_region(struct resource *res)
 /* The root resource for the whole memory-mapped io space */
 struct resource iomem_resource = {
 	.start = 0,
-	.end = 0xffffffff,
+	.end = ~(resource_size_t)0,
 	.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
#2 lore raw

Re: [PATCH v2 01/12] resource: fix iomem root resource for 64 bit

Quoted 2 lines · Peter Mamonov

IMHO, Signed-off-by is a bit of an overkill for this. I am perfectly fine not getting credit for trivial suggestions as was this one in general, but if we must, Suggested-by seems like a better fit.

Thanks,
Andrey Smirnov

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

#3 lore raw

PATCH v2 2/12 fs: fix memory access for 64bit MIPS

In reply to Peter Mamonov
---
 fs/fs.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
fs/fs.c +2 -2
index b66cc9b17..4322d307d 100644
@@ -962,7 +962,7 @@ 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)
+		if (IS_ERR(offset))
 			goto out;
 		pos = offset;
 		break;
@@ -981,7 +981,7 @@ loff_t lseek(int fildes, loff_t offset, int whence)
 	}
 
 	pos = fsdrv->lseek(&f->fsdev->dev, f, pos);
-	if (pos < 0) {
+	if (IS_ERR(pos)) {
 		errno = -pos;
 		return -1;
 	}
Signature · 7 lines
2.17.0


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

PATCH v2 3/12 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
#5 lore raw

PATCH v2 4/12 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
#6 lore raw

PATCH v2 5/12 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 17d480d08..dc44d7f79 100644
@@ -73,6 +73,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
#7 lore raw

PATCH v2 6/12 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
#8 lore raw

Re: [PATCH v2 06/12] common.h: fix IOMEM() for MIPS64

Quoted 11 lines · Peter Mamonov
---
 include/common.h | 4 ++++
 1 file changed, 4 insertions(+)
include/common.h +0 -0
index 60e5005b8..4b3bcae40 100644
@@ -142,7 +142,11 @@ void barebox_set_hostname_no_overwrite(const char *);
 #if defined(CONFIG_MIPS)

include/common.h void barebox_set_hostname_no_overwrite(const char *); · line 152

Quoted 10 lines
include/common.h +4 -0
 #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

Another way to handle this would be to move the definition of IOMEM to asm/common.h and then in this file define IOMEM only if not already defined.

Then we could avoid this MIPS specific stuff in the middle of a common file.

Sam

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

#9 lore raw

Re: [PATCH v2 06/12] common.h: fix IOMEM() for MIPS64

Am 21.05.2018 um 17:04 schrieb Sam Ravnborg:

Quoted 26 lines · Peter Mamonov
Quoted 11 lines
---
 include/common.h | 4 ++++
 1 file changed, 4 insertions(+)
include/common.h +0 -0
index 60e5005b8..4b3bcae40 100644
@@ -142,7 +142,11 @@ void barebox_set_hostname_no_overwrite(const char *);
 #if defined(CONFIG_MIPS)

include/common.h void barebox_set_hostname_no_overwrite(const char *); · line 152

Quoted 10 lines
include/common.h +4 -0
 #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

Another way to handle this would be to move the definition of IOMEM to asm/common.h and then in this file define IOMEM only if not already defined.

Quoted 1 line

Then we could avoid this MIPS specific stuff in the middle of a common file.

I would prefer
arch/mips/include/asm/io.h

for example in kernel we have:
arch/arm/include/asm/io.h:165:#define IOMEM(x)
arch/hexagon/include/asm/io.h:38:#define IOMEM(x)

Signature · 2 lines
Regards,
Oleksij

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

#10 lore raw

Re: [PATCH v2 06/12] common.h: fix IOMEM() for MIPS64

Quoted 27 lines · Oleksij Rempel

Am 21.05.2018 um 17:04 schrieb Sam Ravnborg:

Quoted 26 lines · Peter Mamonov
Quoted 11 lines
---
 include/common.h | 4 ++++
 1 file changed, 4 insertions(+)
include/common.h +0 -0
index 60e5005b8..4b3bcae40 100644
@@ -142,7 +142,11 @@ void barebox_set_hostname_no_overwrite(const char *);
 #if defined(CONFIG_MIPS)

include/common.h void barebox_set_hostname_no_overwrite(const char *); · line 152

Quoted 10 lines
include/common.h +4 -0
 #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

Another way to handle this would be to move the definition of IOMEM to asm/common.h and then in this file define IOMEM only if not already defined.

Quoted 4 lines
Quoted 1 line

Then we could avoid this MIPS specific stuff in the middle of a common file.

I would prefer
arch/mips/include/asm/io.h

Agreed, much better place.

Sam

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

#11 lore raw

Re: [PATCH v2 06/12] common.h: fix IOMEM() for MIPS64

Quoted 28 lines · Sam Ravnborg
Quoted 27 lines · Oleksij Rempel

Am 21.05.2018 um 17:04 schrieb Sam Ravnborg:

Quoted 26 lines · Peter Mamonov
Quoted 11 lines
---
 include/common.h | 4 ++++
 1 file changed, 4 insertions(+)
include/common.h +0 -0
index 60e5005b8..4b3bcae40 100644
@@ -142,7 +142,11 @@ void barebox_set_hostname_no_overwrite(const char *);
 #if defined(CONFIG_MIPS)

include/common.h void barebox_set_hostname_no_overwrite(const char *); · line 152

Quoted 10 lines
include/common.h +4 -0
 #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

Another way to handle this would be to move the definition of IOMEM to asm/common.h and then in this file define IOMEM only if not already defined.

Quoted 5 lines
Quoted 4 lines
Quoted 1 line

Then we could avoid this MIPS specific stuff in the middle of a common file.

I would prefer
arch/mips/include/asm/io.h

Agreed, much better place.

Got it.

Regards,
Peter

Quoted 7 lines

Sam

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

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

#12 lore raw

PATCH v2 7/12 mips: fix copy_to_link_location for 64 bit mode

In reply to Peter Mamonov
---
 arch/mips/include/asm/pbl_macros.h | 21 +++++++++++----------
 1 file changed, 11 insertions(+), 10 deletions(-)
arch/mips/include/asm/pbl_macros.h +11 -10
index 37b150ac2..18115c848 100644
@@ -134,21 +134,22 @@
 	subu	t2, t1, t0	/* t2 <- size of pbl */
 	addu	a2, a0, t2	/* a2 <- source end address */
 
+#define WSIZE	4
 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, WSIZE * 0(a0)
+	lw	t5, WSIZE * 1(a0)
+	lw	t6, WSIZE * 2(a0)
+	lw	t7, WSIZE * 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)
-	addi	a0, LONGSIZE * 4
+	sw	t4, WSIZE * 0(a1)
+	sw	t5, WSIZE * 1(a1)
+	sw	t6, WSIZE * 2(a1)
+	sw	t7, WSIZE * 3(a1)
+	addi	a0, WSIZE * 4
 	subu	t3, a0, a2
 	blez	t3, copy_loop
-	 addi	a1, LONGSIZE * 4
+	 addi	a1, WSIZE * 4
 
 copy_loop_exit:
 
Signature · 7 lines
2.17.0


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

PATCH v2 8/12 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
#14 lore raw

Re: [PATCH v2 08/12] MIPS: use CKSEG1 instead of KSEG1

Hi Peter.

Quoted 2 lines · Peter Mamonov

---

Can you elaborate a little over this change? Earlier IOMEM was fixed to use KSEG1 and not CKSEG1

And now something else moves the other way.

For readers like me that has no clue what KSEG0 and CKSEG0 is the change looks like noise.
It may be perfectly fine, but there is no backgrond info to tell why

Sam

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

#15 lore raw

Re: [PATCH v2 08/12] MIPS: use CKSEG1 instead of KSEG1

Hi, Sam,

Quoted 10 lines · Sam Ravnborg

Hi Peter.

Quoted 2 lines · Peter Mamonov

---

Can you elaborate a little over this change? Earlier IOMEM was fixed to use KSEG1 and not CKSEG1

And now something else moves the other way.

Well, before patch 6 of this patch series IOMEM for MIPS was defined using CKSEG1ADDR() macro. Patch 6 introduced a new definition for MIPS64 using PHYS_TO_XKSEG_UNCACHED macro. I can't see any use of KSEG1 in IOMEM definition for MIPS...

Quoted 3 lines
Quoted 1 line

For readers like me that has no clue what KSEG0 and CKSEG0

is the change looks like noise.
It may be perfectly fine, but there is no backgrond info to tell why

Anyway, here is the story. MIPS virtual address space is partitioned into several segments. Here is an excerpt from the "See MIPS run (Linux)" book which describes KSEG0 and KSEG1:

kseg0 0x8000.0000 – 9FFF.FFFF (512MB): These addresses are translated
into physical addresses by merely stripping off the top bit and mapping them contiguously into the low 512 MB of physical memory. [...] Addresses in this region are almost always accessed through the cache, so they may not be used until the caches are properly initialized. They will be used for most programs and data in systems not using the MMU and will be used for the OS kernel for systems that do use the MMU.

kseg1 0xA000.0000 – BFFF.FFFF (512MB): These addresses are mapped
into physical addresses by stripping off the leading 3 bits, giving a duplicate mapping of the low 512 MB of physical memory. But this time, access will not use the cache. The kseg1 region is the only chunk of the memory map that is guaranteed to behave properly from system reset; that’s why the after-reset starting point ( 0xBFC0.0000 ) lies within it.

Now, after introduction of MIPS64 these segments were preserved for compatibility reasons, and its 64bit equivalents are located at 0xffffffff80000000 and 0xffffffffa0000000 respectively.

As you can see from the arch/mips/include/asm/addrspace.h KSEG0/1 are defined for 32 bits only:

	#ifdef CONFIG_64BIT
	...
	#else
	...
	#define KSEG0                   0x80000000
	#define KSEG1                   0xa0000000
	...
	#endif

While CKSEG0/1 are defined for both 64 and 32 bits:

	#ifdef CONFIG_64BIT
	...
	#define CKSEG0                  _CONST64_(0xffffffff80000000)
	#define CKSEG1                  _CONST64_(0xffffffffa0000000)
	...
	#else
	...
	#define CKSEG0                   0x80000000
	#define CKSEG1                   0xa0000000
	...
	#endif

Linux defines these constants in the same way. I belive the "C" prefix to contants names stands for Compatible.

Anyway, if you try to compile 64 bit barebox and use KSEG1 in your code, compilation will fail.

Regards,
Peter

Quoted 2 lines

Sam

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

#16 lore raw

PATCH v2 9/12 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 dc44d7f79..688620472 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
#17 lore raw

Re: [PATCH v2 09/12] mips: fix warnings from CPHYSADDR() macro

Quoted 11 lines · Peter Mamonov
---
 arch/mips/include/asm/addrspace.h | 5 +++++
 1 file changed, 5 insertions(+)
arch/mips/include/asm/addrspace.h +0 -0
index dc44d7f79..688620472 100644
@@ -48,7 +48,12 @@
 /*

arch/mips/include/asm/addrspace.h line 58

Quoted 10 lines
arch/mips/include/asm/addrspace.h +5 -0
  * 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))

If the above cast to phys_addr_t then no ifdef is required?

Sam

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

#18 lore raw

Re: [PATCH v2 09/12] mips: fix warnings from CPHYSADDR() macro

Quoted 16 lines · Sam Ravnborg
Quoted 15 lines · Peter Mamonov
---
 arch/mips/include/asm/addrspace.h | 5 +++++
 1 file changed, 5 insertions(+)
arch/mips/include/asm/addrspace.h +2 -0
index dc44d7f79..688620472 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)
Quoted 8 lines

arch/mips/include/asm/addrspace.h line 58

Quoted 6 lines
arch/mips/include/asm/addrspace.h +3 -0
+#else
 #define CPHYSADDR(a)		((_ACAST32_(a)) & 0x1fffffff)
+#endif
+
 #define XPHYSADDR(a)            ((_ACAST64_(a)) &			\
 				 _CONST64_(0x000000ffffffffff))

If the above cast to phys_addr_t then no ifdef is required?

Probably, yet Linux uses those _ACAST*_ macros... I have to dig a little bit to find why and how. Let's skip this this patch for a while since it just fixes a warning and there are much more of them when you build for 64 bit MIPS...

Regards,
Peter

Quoted 2 lines

Sam

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

#19 lore raw

PATCH v2 10/12 mips: add PHYS_ADDR_T_64BIT option

In reply to Peter Mamonov
---
 arch/mips/Kconfig | 4 ++++
 1 file changed, 4 insertions(+)
arch/mips/Kconfig +4 -0
index c2c555dc3..433d914c2 100644
@@ -25,6 +25,10 @@ config GENERIC_LINKER_SCRIPT
 config HAS_NO_BOARD_HL_CODE
 	bool
 
+config PHYS_ADDR_T_64BIT
+	bool
+	default n
+
 menu "Machine selection"
 
 config BUILTIN_DTB
Signature · 7 lines
2.17.0


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

Re: [PATCH v2 10/12] mips: add PHYS_ADDR_T_64BIT option

Quoted 10 lines · Peter Mamonov
---
 arch/mips/Kconfig | 4 ++++
 1 file changed, 4 insertions(+)
arch/mips/Kconfig +0 -0
index c2c555dc3..433d914c2 100644

arch/mips/Kconfig config GENERIC_LINKER_SCRIPT · line 30

Quoted 6 lines
arch/mips/Kconfig +3 -0
@@ -25,6 +25,10 @@ config GENERIC_LINKER_SCRIPT
 config HAS_NO_BOARD_HL_CODE
 	bool
 
+config PHYS_ADDR_T_64BIT
+	bool
+	default n

'n' is the default already. You can skip this line.

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
#21 lore raw

PATCH v2 11/12 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 433d914c2..ef23837f4 100644
@@ -279,6 +279,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
#22 lore raw

PATCH v2 12/12 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 ef23837f4..ce63ec1ae 100644
@@ -342,6 +342,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
#23 lore raw

Re: [PATCH v2 12/12] fixup! MIPS: import optimized string functions from Linux

Please, no fixup in master log.

Am 21.05.2018 um 13:54 schrieb Peter Mamonov:

Quoted 18 lines
---
 arch/mips/Kconfig | 1 +
 1 file changed, 1 insertion(+)
arch/mips/Kconfig +1 -0
index ef23837f4..ce63ec1ae 100644
@@ -342,6 +342,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 · 2 lines
Regards,
Oleksij

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

#24 lore raw

Re: [PATCH v2 12/12] fixup! MIPS: import optimized string functions from Linux

Quoted 1 line · Oleksij Rempel

Please, no fixup in master log.

Ok, will fix it in the upcoming revision of the patch series.

Regards,
Peter

Quoted 13 lines

Am 21.05.2018 um 13:54 schrieb Peter Mamonov:

Quoted 11 lines
---
 arch/mips/Kconfig | 1 +
 1 file changed, 1 insertion(+)
arch/mips/Kconfig +0 -0
index ef23837f4..ce63ec1ae 100644
@@ -342,6 +342,7 @@ config NMON_HELP
 
Quoted 13 lines
Quoted 7 lines
arch/mips/Kconfig +1 -0
 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 · 2 lines
Regards,
Oleksij

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

#25 lore raw
In reply to Peter Mamonov
Quoted 6 lines · Peter Mamonov

Hi,

Here is a second revision of the patchset which fixes various issues with 64 bit barebox, primarily MIPS related. IMHO all of these patches are ready for application.

Don't think I've seen any comments on:
http://lists.infradead.org/pipermail/barebox/2018-May/032985.html
Right now it's not clear if that thread just slipped though the cracks or you decided to keep the code as is. Latter is fine with me, I just want to make sure it is not the former.

Thanks,
Andrey Smirnov

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

#26 lore raw

Hi, Andrey,

Quoted 8 lines · Andrey Smirnov
Quoted 6 lines · Peter Mamonov

Hi,

Here is a second revision of the patchset which fixes various issues with 64 bit barebox, primarily MIPS related. IMHO all of these patches are ready for application.

Quoted 5 lines

Don't think I've seen any comments on:
http://lists.infradead.org/pipermail/barebox/2018-May/032985.html
Right now it's not clear if that thread just slipped though the cracks or you decided to keep the code as is. Latter is fine with me, I just want to make sure it is not the former.

Sorry for lack of feedback on your proposal. Your solution is actually the proper one. Yet I've decided to keep this change trivial for two reasons:

- to make it easier for Sascha to accept it (i.e. no change in driver logic, just fix the problem)

- to make this patch self explaining, since it demonstrates the source of the
problem: get_drv_data(..., &data->type) overwrites memory beyond data->type member due to mismatch of sizeof(enum pca_type) and sizeof(void *); using argument of a proper type and size fixes the problem.

Regards,
Peter

Quoted 3 lines

Thanks,
Andrey Smirnov

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

#27 lore raw
In reply to Peter Mamonov

Hi Peter,

Quoted 5 lines · Peter Mamonov

Hi,

Here is a second revision of the patchset which fixes various issues with 64 bit barebox, primarily MIPS related. IMHO all of these patches are ready for application.

Overall the commit messages in this series could be better. At least for the non trivial changes they should answer the question why a particular change has been made. You'll be glad having added proper commit messages once a 'git blame' run points to your own code ;)

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
#28 lore raw

Hi, Sascha,

Quoted 5 lines · Sascha Hauer

Hi Peter,

Quoted 2 lines · Peter Mamonov

Hi,

Quoted 8 lines
Quoted 3 lines

Here is a second revision of the patchset which fixes various issues with 64 bit barebox, primarily MIPS related. IMHO all of these patches are ready for application.

Overall the commit messages in this series could be better. At least for the non trivial changes they should answer the question why a particular change has been made. You'll be glad having added proper commit messages once a 'git blame' run points to your own code ;)

Ok, I will work on that in the next version of the series.

Regards,
Peter

Quoted 8 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