* [PATCH v3 01/12] resource: fix iomem_resource.end for 64 bit systems
2018-05-22 15:33 [PATCH v3 00/12] various fixes for MIPS64 Peter Mamonov
@ 2018-05-22 15:33 ` Peter Mamonov
2018-05-22 15:33 ` [PATCH v3 02/12] fs: fix memory access via /dev/mem for MIPS64 Peter Mamonov
` (11 subsequent siblings)
12 siblings, 0 replies; 19+ messages in thread
From: Peter Mamonov @ 2018-05-22 15:33 UTC (permalink / raw)
To: barebox; +Cc: Peter Mamonov
Fix iomem_resource.end to cover the whole address space addressable by a
variable of type resource_size_t.
Signed-off-by: Peter Mamonov <pmamonov@gmail.com>
---
common/resource.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/common/resource.c b/common/resource.c
index e4bbe15fd..abc0814d2 100644
--- a/common/resource.c
+++ b/common/resource.c
@@ -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),
};
--
2.17.0
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 19+ messages in thread
* [PATCH v3 02/12] fs: fix memory access via /dev/mem for MIPS64
2018-05-22 15:33 [PATCH v3 00/12] various fixes for MIPS64 Peter Mamonov
2018-05-22 15:33 ` [PATCH v3 01/12] resource: fix iomem_resource.end for 64 bit systems Peter Mamonov
@ 2018-05-22 15:33 ` Peter Mamonov
2018-05-24 10:47 ` Sascha Hauer
2018-05-22 15:33 ` [PATCH v3 03/12] mtd: cfi-flash: fix write_buff() for 64 bit systems Peter Mamonov
` (10 subsequent siblings)
12 siblings, 1 reply; 19+ messages in thread
From: Peter Mamonov @ 2018-05-22 15:33 UTC (permalink / raw)
To: barebox; +Cc: Peter Mamonov
lseek checks for non-negative in-memory offsets (addresses), failing otherwise.
However negative address 0xffffffffXXXXXXXX is a valid MIPS64 virtual address.
Signed-off-by: Peter Mamonov <pmamonov@gmail.com>
---
fs/fs.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/fs/fs.c b/fs/fs.c
index b66cc9b17..4322d307d 100644
--- a/fs/fs.c
+++ b/fs/fs.c
@@ -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;
}
--
2.17.0
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH v3 02/12] fs: fix memory access via /dev/mem for MIPS64
2018-05-22 15:33 ` [PATCH v3 02/12] fs: fix memory access via /dev/mem for MIPS64 Peter Mamonov
@ 2018-05-24 10:47 ` Sascha Hauer
2018-05-24 14:01 ` [PATCH v4] " Peter Mamonov
0 siblings, 1 reply; 19+ messages in thread
From: Sascha Hauer @ 2018-05-24 10:47 UTC (permalink / raw)
To: Peter Mamonov; +Cc: barebox
On Tue, May 22, 2018 at 06:33:32PM +0300, Peter Mamonov wrote:
> lseek checks for non-negative in-memory offsets (addresses), failing otherwise.
> However negative address 0xffffffffXXXXXXXX is a valid MIPS64 virtual address.
>
> Signed-off-by: Peter Mamonov <pmamonov@gmail.com>
> ---
> fs/fs.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/fs/fs.c b/fs/fs.c
> index b66cc9b17..4322d307d 100644
> --- a/fs/fs.c
> +++ b/fs/fs.c
> @@ -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))
Dropped this patch. IS_ERR() takes a pointer, but offset is of type
loff_t, so gcc rightfully issues a warning.
Sascha
--
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
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 19+ messages in thread
* [PATCH v4] fs: fix memory access via /dev/mem for MIPS64
2018-05-24 10:47 ` Sascha Hauer
@ 2018-05-24 14:01 ` Peter Mamonov
2018-06-13 8:31 ` Sascha Hauer
0 siblings, 1 reply; 19+ messages in thread
From: Peter Mamonov @ 2018-05-24 14:01 UTC (permalink / raw)
To: s.hauer; +Cc: barebox, Peter Mamonov
lseek checks for non-negative in-memory offsets (addresses), failing otherwise.
However negative address 0xffffffffXXXXXXXX is a valid MIPS64 virtual address.
---
fs/fs.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/fs/fs.c b/fs/fs.c
index b66cc9b17..8a49e32b5 100644
--- a/fs/fs.c
+++ b/fs/fs.c
@@ -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_VALUE(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_VALUE(pos)) {
errno = -pos;
return -1;
}
--
2.17.0
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH v4] fs: fix memory access via /dev/mem for MIPS64
2018-05-24 14:01 ` [PATCH v4] " Peter Mamonov
@ 2018-06-13 8:31 ` Sascha Hauer
2018-06-13 16:17 ` [RESEND " Peter Mamonov
0 siblings, 1 reply; 19+ messages in thread
From: Sascha Hauer @ 2018-06-13 8:31 UTC (permalink / raw)
To: Peter Mamonov; +Cc: barebox
Hi Peter,
On Thu, May 24, 2018 at 05:01:33PM +0300, Peter Mamonov wrote:
> lseek checks for non-negative in-memory offsets (addresses), failing otherwise.
> However negative address 0xffffffffXXXXXXXX is a valid MIPS64 virtual address.
> ---
> fs/fs.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
The patch looks good now, but lacks a Signed-off-by: Could you resend
it?
Sascha
>
> diff --git a/fs/fs.c b/fs/fs.c
> index b66cc9b17..8a49e32b5 100644
> --- a/fs/fs.c
> +++ b/fs/fs.c
> @@ -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_VALUE(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_VALUE(pos)) {
> errno = -pos;
> return -1;
> }
> --
> 2.17.0
>
>
--
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
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 19+ messages in thread
* [RESEND v4] fs: fix memory access via /dev/mem for MIPS64
2018-06-13 8:31 ` Sascha Hauer
@ 2018-06-13 16:17 ` Peter Mamonov
2018-06-14 5:36 ` Sascha Hauer
0 siblings, 1 reply; 19+ messages in thread
From: Peter Mamonov @ 2018-06-13 16:17 UTC (permalink / raw)
To: s.hauer; +Cc: barebox, Peter Mamonov
lseek checks for non-negative in-memory offsets (addresses), failing otherwise.
However negative address 0xffffffffXXXXXXXX is a valid MIPS64 virtual address.
Signed-off-by: Peter Mamonov <pmamonov@gmail.com>
---
fs/fs.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/fs/fs.c b/fs/fs.c
index b66cc9b17..8a49e32b5 100644
--- a/fs/fs.c
+++ b/fs/fs.c
@@ -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_VALUE(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_VALUE(pos)) {
errno = -pos;
return -1;
}
--
2.17.0
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [RESEND v4] fs: fix memory access via /dev/mem for MIPS64
2018-06-13 16:17 ` [RESEND " Peter Mamonov
@ 2018-06-14 5:36 ` Sascha Hauer
0 siblings, 0 replies; 19+ messages in thread
From: Sascha Hauer @ 2018-06-14 5:36 UTC (permalink / raw)
To: Peter Mamonov; +Cc: barebox
On Wed, Jun 13, 2018 at 07:17:55PM +0300, Peter Mamonov wrote:
> lseek checks for non-negative in-memory offsets (addresses), failing otherwise.
> However negative address 0xffffffffXXXXXXXX is a valid MIPS64 virtual address.
>
> Signed-off-by: Peter Mamonov <pmamonov@gmail.com>
> ---
> fs/fs.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
Applied, thanks
Sascha
>
> diff --git a/fs/fs.c b/fs/fs.c
> index b66cc9b17..8a49e32b5 100644
> --- a/fs/fs.c
> +++ b/fs/fs.c
> @@ -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_VALUE(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_VALUE(pos)) {
> errno = -pos;
> return -1;
> }
> --
> 2.17.0
>
>
--
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
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 19+ messages in thread
* [PATCH v3 03/12] mtd: cfi-flash: fix write_buff() for 64 bit systems
2018-05-22 15:33 [PATCH v3 00/12] various fixes for MIPS64 Peter Mamonov
2018-05-22 15:33 ` [PATCH v3 01/12] resource: fix iomem_resource.end for 64 bit systems Peter Mamonov
2018-05-22 15:33 ` [PATCH v3 02/12] fs: fix memory access via /dev/mem for MIPS64 Peter Mamonov
@ 2018-05-22 15:33 ` Peter Mamonov
2018-05-22 15:33 ` [PATCH v3 04/12] i2c-mux-pca954x: fix out-of-bounds write " Peter Mamonov
` (9 subsequent siblings)
12 siblings, 0 replies; 19+ messages in thread
From: Peter Mamonov @ 2018-05-22 15:33 UTC (permalink / raw)
To: barebox; +Cc: Peter Mamonov
write_buff() uses ~(flash_info.portwidth - 1) to mask lower bits of addr. This
causes higher 32 bits of addr to be discarded on a 64 bit system, since
flash_info.portwidth is 32 bits long (unsigned int) and addr is 64 bits long
(unsigned long).
Signed-off-by: Peter Mamonov <pmamonov@gmail.com>
---
drivers/mtd/nor/cfi_flash.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/mtd/nor/cfi_flash.c b/drivers/mtd/nor/cfi_flash.c
index 5bdcccae1..01ab1aa27 100644
--- a/drivers/mtd/nor/cfi_flash.c
+++ b/drivers/mtd/nor/cfi_flash.c
@@ -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;
--
2.17.0
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 19+ messages in thread
* [PATCH v3 04/12] i2c-mux-pca954x: fix out-of-bounds write for 64 bit systems
2018-05-22 15:33 [PATCH v3 00/12] various fixes for MIPS64 Peter Mamonov
` (2 preceding siblings ...)
2018-05-22 15:33 ` [PATCH v3 03/12] mtd: cfi-flash: fix write_buff() for 64 bit systems Peter Mamonov
@ 2018-05-22 15:33 ` Peter Mamonov
2018-05-22 15:33 ` [PATCH v3 05/12] MIPS: import 64-bit address conversion macros Peter Mamonov
` (8 subsequent siblings)
12 siblings, 0 replies; 19+ messages in thread
From: Peter Mamonov @ 2018-05-22 15:33 UTC (permalink / raw)
To: barebox; +Cc: Peter Mamonov
get_drv_data(..., &data->type) overwrites memory beyond data->type member due
to mismatch of sizeof(enum pca_type) and sizeof(void *) on 64 bit systems.
Signed-off-by: Peter Mamonov <pmamonov@gmail.com>
---
drivers/i2c/muxes/i2c-mux-pca954x.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/i2c/muxes/i2c-mux-pca954x.c b/drivers/i2c/muxes/i2c-mux-pca954x.c
index 0d5515b71..395254cdc 100644
--- a/drivers/i2c/muxes/i2c-mux-pca954x.c
+++ b/drivers/i2c/muxes/i2c-mux-pca954x.c
@@ -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;
--
2.17.0
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 19+ messages in thread
* [PATCH v3 05/12] MIPS: import 64-bit address conversion macros
2018-05-22 15:33 [PATCH v3 00/12] various fixes for MIPS64 Peter Mamonov
` (3 preceding siblings ...)
2018-05-22 15:33 ` [PATCH v3 04/12] i2c-mux-pca954x: fix out-of-bounds write " Peter Mamonov
@ 2018-05-22 15:33 ` Peter Mamonov
2018-05-22 15:33 ` [PATCH v3 06/12] include/common.h: move IOMEM declaration for MIPS to arch/mips/include/asm/io.h Peter Mamonov
` (7 subsequent siblings)
12 siblings, 0 replies; 19+ messages in thread
From: Peter Mamonov @ 2018-05-22 15:33 UTC (permalink / raw)
To: barebox; +Cc: Peter Mamonov
Signed-off-by: Peter Mamonov <pmamonov@gmail.com>
---
arch/mips/include/asm/addrspace.h | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
diff --git a/arch/mips/include/asm/addrspace.h b/arch/mips/include/asm/addrspace.h
index 17d480d08..dc44d7f79 100644
--- a/arch/mips/include/asm/addrspace.h
+++ b/arch/mips/include/asm/addrspace.h
@@ -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)
--
2.17.0
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 19+ messages in thread
* [PATCH v3 06/12] include/common.h: move IOMEM declaration for MIPS to arch/mips/include/asm/io.h
2018-05-22 15:33 [PATCH v3 00/12] various fixes for MIPS64 Peter Mamonov
` (4 preceding siblings ...)
2018-05-22 15:33 ` [PATCH v3 05/12] MIPS: import 64-bit address conversion macros Peter Mamonov
@ 2018-05-22 15:33 ` Peter Mamonov
2018-05-22 15:33 ` [PATCH v3 07/12] MIPS: add proper IOMEM() declaration for MIPS64 Peter Mamonov
` (6 subsequent siblings)
12 siblings, 0 replies; 19+ messages in thread
From: Peter Mamonov @ 2018-05-22 15:33 UTC (permalink / raw)
To: barebox; +Cc: Peter Mamonov
Signed-off-by: Peter Mamonov <pmamonov@gmail.com>
---
arch/mips/include/asm/io.h | 2 ++
include/common.h | 7 ++-----
2 files changed, 4 insertions(+), 5 deletions(-)
diff --git a/arch/mips/include/asm/io.h b/arch/mips/include/asm/io.h
index 5a4cbf564..ee6151693 100644
--- a/arch/mips/include/asm/io.h
+++ b/arch/mips/include/asm/io.h
@@ -106,6 +106,8 @@ static inline void __raw_writel(u32 b, volatile void __iomem *addr)
#define out_be16(a, v) __raw_writew(__cpu_to_be16(v), a)
#define out_be32(a, v) __raw_writel(__cpu_to_be32(v), a)
+#define IOMEM(addr) ((void __force __iomem *)CKSEG1ADDR(addr))
+
#include <asm-generic/io.h>
#endif /* __ASM_MIPS_IO_H */
diff --git a/include/common.h b/include/common.h
index 60e5005b8..f93bd7f5d 100644
--- a/include/common.h
+++ b/include/common.h
@@ -30,6 +30,7 @@
#include <linux/kernel.h>
#include <linux/stddef.h>
#include <asm/common.h>
+#include <asm/io.h>
#include <printk.h>
/*
@@ -139,11 +140,7 @@ const char *barebox_get_hostname(void);
void barebox_set_hostname(const char *);
void barebox_set_hostname_no_overwrite(const char *);
-#if defined(CONFIG_MIPS)
-#include <asm/addrspace.h>
-
-#define IOMEM(addr) ((void __force __iomem *)CKSEG1ADDR(addr))
-#else
+#ifndef IOMEM
#define IOMEM(addr) ((void __force __iomem *)(addr))
#endif
--
2.17.0
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 19+ messages in thread
* [PATCH v3 07/12] MIPS: add proper IOMEM() declaration for MIPS64
2018-05-22 15:33 [PATCH v3 00/12] various fixes for MIPS64 Peter Mamonov
` (5 preceding siblings ...)
2018-05-22 15:33 ` [PATCH v3 06/12] include/common.h: move IOMEM declaration for MIPS to arch/mips/include/asm/io.h Peter Mamonov
@ 2018-05-22 15:33 ` Peter Mamonov
2018-05-22 15:33 ` [PATCH v3 08/12] MIPS: fix copy_to_link_location for 64 bit mode Peter Mamonov
` (5 subsequent siblings)
12 siblings, 0 replies; 19+ messages in thread
From: Peter Mamonov @ 2018-05-22 15:33 UTC (permalink / raw)
To: barebox; +Cc: Peter Mamonov
Signed-off-by: Peter Mamonov <pmamonov@gmail.com>
---
arch/mips/include/asm/io.h | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/arch/mips/include/asm/io.h b/arch/mips/include/asm/io.h
index ee6151693..c15519943 100644
--- a/arch/mips/include/asm/io.h
+++ b/arch/mips/include/asm/io.h
@@ -106,7 +106,11 @@ static inline void __raw_writel(u32 b, volatile void __iomem *addr)
#define out_be16(a, v) __raw_writew(__cpu_to_be16(v), a)
#define out_be32(a, v) __raw_writel(__cpu_to_be32(v), a)
+#ifdef CONFIG_64BIT
+#define IOMEM(addr) ((void __force __iomem *)PHYS_TO_XKSEG_UNCACHED(addr))
+#else
#define IOMEM(addr) ((void __force __iomem *)CKSEG1ADDR(addr))
+#endif
#include <asm-generic/io.h>
--
2.17.0
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 19+ messages in thread
* [PATCH v3 08/12] MIPS: fix copy_to_link_location for 64 bit mode
2018-05-22 15:33 [PATCH v3 00/12] various fixes for MIPS64 Peter Mamonov
` (6 preceding siblings ...)
2018-05-22 15:33 ` [PATCH v3 07/12] MIPS: add proper IOMEM() declaration for MIPS64 Peter Mamonov
@ 2018-05-22 15:33 ` Peter Mamonov
2018-05-22 15:33 ` [PATCH v3 09/12] MIPS: use CKSEG1 instead of KSEG1 Peter Mamonov
` (4 subsequent siblings)
12 siblings, 0 replies; 19+ messages in thread
From: Peter Mamonov @ 2018-05-22 15:33 UTC (permalink / raw)
To: barebox; +Cc: Peter Mamonov
MIPS `lw` instruction loads a 32 bit word from memory on both 32 bit and 64 bit
systems. On the other hand LONGSIZE is either 4 or 8 depending on selected code
model. This discrepancy causes copy_to_link_location failure on 64 bit systems.
Signed-off-by: Peter Mamonov <pmamonov@gmail.com>
---
arch/mips/include/asm/pbl_macros.h | 21 +++++++++++----------
1 file changed, 11 insertions(+), 10 deletions(-)
diff --git a/arch/mips/include/asm/pbl_macros.h b/arch/mips/include/asm/pbl_macros.h
index 37b150ac2..18115c848 100644
--- a/arch/mips/include/asm/pbl_macros.h
+++ b/arch/mips/include/asm/pbl_macros.h
@@ -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:
--
2.17.0
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 19+ messages in thread
* [PATCH v3 09/12] MIPS: use CKSEG1 instead of KSEG1
2018-05-22 15:33 [PATCH v3 00/12] various fixes for MIPS64 Peter Mamonov
` (7 preceding siblings ...)
2018-05-22 15:33 ` [PATCH v3 08/12] MIPS: fix copy_to_link_location for 64 bit mode Peter Mamonov
@ 2018-05-22 15:33 ` Peter Mamonov
2018-05-22 15:33 ` [PATCH v3 10/12] MIPS: add PHYS_ADDR_T_64BIT option Peter Mamonov
` (3 subsequent siblings)
12 siblings, 0 replies; 19+ messages in thread
From: Peter Mamonov @ 2018-05-22 15:33 UTC (permalink / raw)
To: barebox; +Cc: Peter Mamonov
KSEG1 constant is defined for 32 bit MIPS only. Use CKSEG1 which is defined for
both MIPS32 and MIPS64.
Signed-off-by: Peter Mamonov <pmamonov@gmail.com>
---
arch/mips/boot/dtb.c | 4 ++--
arch/mips/lib/c-r4k.c | 8 ++++----
2 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/arch/mips/boot/dtb.c b/arch/mips/boot/dtb.c
index e7633a5af..3f7f46641 100644
--- a/arch/mips/boot/dtb.c
+++ b/arch/mips/boot/dtb.c
@@ -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)
diff --git a/arch/mips/lib/c-r4k.c b/arch/mips/lib/c-r4k.c
index 150205840..cb0544a53 100644
--- a/arch/mips/lib/c-r4k.c
+++ b/arch/mips/lib/c-r4k.c
@@ -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 */
--
2.17.0
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 19+ messages in thread
* [PATCH v3 10/12] MIPS: add PHYS_ADDR_T_64BIT option
2018-05-22 15:33 [PATCH v3 00/12] various fixes for MIPS64 Peter Mamonov
` (8 preceding siblings ...)
2018-05-22 15:33 ` [PATCH v3 09/12] MIPS: use CKSEG1 instead of KSEG1 Peter Mamonov
@ 2018-05-22 15:33 ` Peter Mamonov
2018-05-22 15:33 ` [PATCH v3 11/12] MIPS: 64BIT selects PHYS_ADDR_T_64BIT Peter Mamonov
` (2 subsequent siblings)
12 siblings, 0 replies; 19+ messages in thread
From: Peter Mamonov @ 2018-05-22 15:33 UTC (permalink / raw)
To: barebox; +Cc: Peter Mamonov
Signed-off-by: Peter Mamonov <pmamonov@gmail.com>
---
arch/mips/Kconfig | 3 +++
1 file changed, 3 insertions(+)
diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig
index c2c555dc3..25c310a49 100644
--- a/arch/mips/Kconfig
+++ b/arch/mips/Kconfig
@@ -25,6 +25,9 @@ config GENERIC_LINKER_SCRIPT
config HAS_NO_BOARD_HL_CODE
bool
+config PHYS_ADDR_T_64BIT
+ bool
+
menu "Machine selection"
config BUILTIN_DTB
--
2.17.0
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 19+ messages in thread
* [PATCH v3 11/12] MIPS: 64BIT selects PHYS_ADDR_T_64BIT
2018-05-22 15:33 [PATCH v3 00/12] various fixes for MIPS64 Peter Mamonov
` (9 preceding siblings ...)
2018-05-22 15:33 ` [PATCH v3 10/12] MIPS: add PHYS_ADDR_T_64BIT option Peter Mamonov
@ 2018-05-22 15:33 ` Peter Mamonov
2018-05-22 15:33 ` [PATCH v3 12/12] MIPS: don't use optimized string functions for MIPS64 Peter Mamonov
2018-05-23 8:11 ` [PATCH v3 00/12] various fixes " Sascha Hauer
12 siblings, 0 replies; 19+ messages in thread
From: Peter Mamonov @ 2018-05-22 15:33 UTC (permalink / raw)
To: barebox; +Cc: Peter Mamonov
Signed-off-by: Peter Mamonov <pmamonov@gmail.com>
---
arch/mips/Kconfig | 1 +
1 file changed, 1 insertion(+)
diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig
index 25c310a49..da613eb39 100644
--- a/arch/mips/Kconfig
+++ b/arch/mips/Kconfig
@@ -278,6 +278,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.
--
2.17.0
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 19+ messages in thread
* [PATCH v3 12/12] MIPS: don't use optimized string functions for MIPS64
2018-05-22 15:33 [PATCH v3 00/12] various fixes for MIPS64 Peter Mamonov
` (10 preceding siblings ...)
2018-05-22 15:33 ` [PATCH v3 11/12] MIPS: 64BIT selects PHYS_ADDR_T_64BIT Peter Mamonov
@ 2018-05-22 15:33 ` Peter Mamonov
2018-05-23 8:11 ` [PATCH v3 00/12] various fixes " Sascha Hauer
12 siblings, 0 replies; 19+ messages in thread
From: Peter Mamonov @ 2018-05-22 15:33 UTC (permalink / raw)
To: barebox; +Cc: Peter Mamonov
Barebox port of optimized string functions from Linux lacks support for MIPS64.
Signed-off-by: Peter Mamonov <pmamonov@gmail.com>
---
arch/mips/Kconfig | 1 +
1 file changed, 1 insertion(+)
diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig
index da613eb39..359f67883 100644
--- a/arch/mips/Kconfig
+++ b/arch/mips/Kconfig
@@ -341,6 +341,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.
--
2.17.0
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH v3 00/12] various fixes for MIPS64
2018-05-22 15:33 [PATCH v3 00/12] various fixes for MIPS64 Peter Mamonov
` (11 preceding siblings ...)
2018-05-22 15:33 ` [PATCH v3 12/12] MIPS: don't use optimized string functions for MIPS64 Peter Mamonov
@ 2018-05-23 8:11 ` Sascha Hauer
12 siblings, 0 replies; 19+ messages in thread
From: Sascha Hauer @ 2018-05-23 8:11 UTC (permalink / raw)
To: Peter Mamonov; +Cc: barebox
On Tue, May 22, 2018 at 06:33:30PM +0300, Peter Mamonov wrote:
> Hi,
>
> This is a third revision of of the patchset which fixes various issues with 64
> bit barebox, primarily MIPS related.
>
> Differences from v2:
> - add some comments to commits
> - move MIPS' IOMEM declarations to arch/mips/include/asm/io.h
> - skip `[PATCH v2 09/12] mips: fix warnings from CPHYSADDR() macro` for now
> - Kconfig' options are disabled by default
> - don't credit Andrey for trivial suggestions :)
Thanks for the commit messages, they really give the warm feeling that
I'm doing the right thing applying these patches ;)
Applied, thanks
Sascha
--
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
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 19+ messages in thread