Skip to contentSkip to conversation

MIPS: octeon: Fix cvmx_writeq_csr/cvmx_readq_csr on 32-bit builds

PATCH Applied Rob Herring 4 participants 12 messages Jun 14, 2023 – Jun 22, 2023

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

PATCH 1/2 MIPS: octeon: Fix cvmx_writeq_csr/cvmx_readq_csr on 32-bit builds

Test 32-bit builds have an error in cvmx_writeq_csr/cvmx_readq_csr:

arch/mips/include/asm/octeon/cvmx.h:282:24: error: cast from pointer to integer of different size [-Werror=pointer-to-int-cast]

As the default for allyesconfig/allmodconfig is 32-bit, fixing these functions for 32-bit is needed to enable Cavium Octeon drivers for COMPILE_TEST.

---
 arch/mips/include/asm/octeon/cvmx.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
arch/mips/include/asm/octeon/cvmx.h +2 -2
index 72e775bf31e6..2265a92995a8 100644
@@ -279,7 +279,7 @@ static inline void cvmx_write_csr(uint64_t csr_addr, uint64_t val)
 
 static inline void cvmx_writeq_csr(void __iomem *csr_addr, uint64_t val)
 {
-	cvmx_write_csr((__force uint64_t)csr_addr, val);
+	cvmx_write_csr((__force uintptr_t)csr_addr, val);
 }
 
 static inline void cvmx_write_io(uint64_t io_addr, uint64_t val)
@@ -296,7 +296,7 @@ static inline uint64_t cvmx_read_csr(uint64_t csr_addr)
 
 static inline uint64_t cvmx_readq_csr(void __iomem *csr_addr)
 {
-	return cvmx_read_csr((__force uint64_t) csr_addr);
+	return cvmx_read_csr((__force uintptr_t) csr_addr);
 }
 
 static inline void cvmx_send_single(uint64_t data)
Signature · 1 line
2.39.2
#1 lore raw

PATCH 2/2 ata: octeon: Add compile test support

Add COMPILE_TEST to enable building Cavium Octeon drivers in MIPS allyesconfig/allmodconfig builds. There's a dependency on MIPS headers, so other arches can't be enabled.

---
Tested on allmodconfig build. Not sure if there's other MIPS configs where this doesn't work. We'll see what 0-day says.

 drivers/ata/Kconfig          | 4 ++--
 drivers/ata/pata_octeon_cf.c | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)
drivers/ata/Kconfig +2 -2
index 42b51c9812a0..4572f837e504 100644
@@ -239,7 +239,7 @@ config AHCI_MVEBU
 
 config AHCI_OCTEON
 	tristate "Cavium Octeon Soc Serial ATA"
-	depends on SATA_AHCI_PLATFORM && CAVIUM_OCTEON_SOC
+	depends on SATA_AHCI_PLATFORM && MIPS && (CAVIUM_OCTEON_SOC || COMPILE_TEST)
 	default y
 	help
 	  This option enables support for Cavium Octeon SoC Serial ATA.
@@ -373,7 +373,7 @@ config PDC_ADMA
 
 config PATA_OCTEON_CF
 	tristate "OCTEON Boot Bus Compact Flash support"
-	depends on CAVIUM_OCTEON_SOC
+	depends on MIPS && (CAVIUM_OCTEON_SOC || COMPILE_TEST)
 	select PATA_TIMINGS
 	help
 	  This option enables a polled compact flash driver for use with
drivers/ata/pata_octeon_cf.c +2 -2
index 57b2166a6d5d..cc9e4b63ded9 100644
@@ -853,8 +853,8 @@ static int octeon_cf_probe(struct platform_device *pdev)
 					of_node_put(dma_node);
 					return -EINVAL;
 				}
-				cf_port->dma_base = (u64)devm_ioremap(&pdev->dev, res_dma->start,
-									 resource_size(res_dma));
+				cf_port->dma_base = (uintptr_t)devm_ioremap(&pdev->dev, res_dma->start,
+									    resource_size(res_dma));
 				if (!cf_port->dma_base) {
 					put_device(&dma_dev->dev);
 					of_node_put(dma_node);
Signature · 1 line
2.39.2
maintainer
#2 lore raw

Re: [PATCH 2/2] ata: octeon: Add compile test support

Quoted 3 lines · Rob Herring

Add COMPILE_TEST to enable building Cavium Octeon drivers in MIPS allyesconfig/allmodconfig builds. There's a dependency on MIPS headers, so other arches can't be enabled.

Yes, I tried... That is unfortunate.

Looks good to me though. If I get an Ack for patch 1, I can queue this up through the ata tree.

Quoted 47 lines

---
Tested on allmodconfig build. Not sure if there's other MIPS configs where this doesn't work. We'll see what 0-day says.

 drivers/ata/Kconfig          | 4 ++--
 drivers/ata/pata_octeon_cf.c | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)
drivers/ata/Kconfig +2 -2
index 42b51c9812a0..4572f837e504 100644
@@ -239,7 +239,7 @@ config AHCI_MVEBU
 
 config AHCI_OCTEON
 	tristate "Cavium Octeon Soc Serial ATA"
-	depends on SATA_AHCI_PLATFORM && CAVIUM_OCTEON_SOC
+	depends on SATA_AHCI_PLATFORM && MIPS && (CAVIUM_OCTEON_SOC || COMPILE_TEST)
 	default y
 	help
 	  This option enables support for Cavium Octeon SoC Serial ATA.
@@ -373,7 +373,7 @@ config PDC_ADMA
 
 config PATA_OCTEON_CF
 	tristate "OCTEON Boot Bus Compact Flash support"
-	depends on CAVIUM_OCTEON_SOC
+	depends on MIPS && (CAVIUM_OCTEON_SOC || COMPILE_TEST)
 	select PATA_TIMINGS
 	help
 	  This option enables a polled compact flash driver for use with
drivers/ata/pata_octeon_cf.c +2 -2
index 57b2166a6d5d..cc9e4b63ded9 100644
@@ -853,8 +853,8 @@ static int octeon_cf_probe(struct platform_device *pdev)
 					of_node_put(dma_node);
 					return -EINVAL;
 				}
-				cf_port->dma_base = (u64)devm_ioremap(&pdev->dev, res_dma->start,
-									 resource_size(res_dma));
+				cf_port->dma_base = (uintptr_t)devm_ioremap(&pdev->dev, res_dma->start,
+									    resource_size(res_dma));
 				if (!cf_port->dma_base) {
 					put_device(&dma_dev->dev);
 					of_node_put(dma_node);
Signature · 2 lines
Damien Le Moal
Western Digital Research
maintainer Acked-by on v1 1/2
#11 lore raw
In reply to Rob Herring
Quoted 37 lines · Rob Herring

Test 32-bit builds have an error in cvmx_writeq_csr/cvmx_readq_csr:

arch/mips/include/asm/octeon/cvmx.h:282:24: error: cast from pointer to integer of different size [-Werror=pointer-to-int-cast]

As the default for allyesconfig/allmodconfig is 32-bit, fixing these functions for 32-bit is needed to enable Cavium Octeon drivers for COMPILE_TEST.

---
 arch/mips/include/asm/octeon/cvmx.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
arch/mips/include/asm/octeon/cvmx.h +2 -2
index 72e775bf31e6..2265a92995a8 100644
@@ -279,7 +279,7 @@ static inline void cvmx_write_csr(uint64_t csr_addr, uint64_t val)
 
 static inline void cvmx_writeq_csr(void __iomem *csr_addr, uint64_t val)
 {
-	cvmx_write_csr((__force uint64_t)csr_addr, val);
+	cvmx_write_csr((__force uintptr_t)csr_addr, val);
 }
 
 static inline void cvmx_write_io(uint64_t io_addr, uint64_t val)
@@ -296,7 +296,7 @@ static inline uint64_t cvmx_read_csr(uint64_t csr_addr)
 
 static inline uint64_t cvmx_readq_csr(void __iomem *csr_addr)
 {
-	return cvmx_read_csr((__force uint64_t) csr_addr);
+	return cvmx_read_csr((__force uintptr_t) csr_addr);
 }
 
 static inline void cvmx_send_single(uint64_t data)
Signature · 1 line
2.39.2
Signature · 2 lines
Crap can work. Given enough thrust pigs will fly, but it's not necessarily a
good idea.                                                [ RFC1925, 2.3 ]
maintainer Applied
#3 lore raw

Re: [PATCH 2/2] ata: octeon: Add compile test support

In reply to Rob Herring
Quoted 5 lines · Rob Herring

Add COMPILE_TEST to enable building Cavium Octeon drivers in MIPS allyesconfig/allmodconfig builds. There's a dependency on MIPS headers, so other arches can't be enabled.

Applied this and 1/2 to for-6.5. Thanks !

Signature · 2 lines
Damien Le Moal
Western Digital Research
#4 lore raw

Re: [PATCH 2/2] ata: octeon: Add compile test support

In reply to Rob Herring
Quoted 8 lines · Rob Herring

Add COMPILE_TEST to enable building Cavium Octeon drivers in MIPS allyesconfig/allmodconfig builds. There's a dependency on MIPS headers, so other arches can't be enabled.

---
Tested on allmodconfig build. Not sure if there's other MIPS configs where this doesn't work. We'll see what 0-day says.

Odd, in next-20230621 I get:

Building mips:allmodconfig ... failed
--------------
Error log:
ERROR: modpost: "__udivdi3" [drivers/ata/pata_octeon_cf.ko] undefined!
ERROR: modpost: "octeon_get_io_clock_rate" [drivers/ata/pata_octeon_cf.ko] undefined!
ERROR: modpost: "__tracepoint_ata_bmdma_stop" [drivers/ata/pata_octeon_cf.ko] undefined!
ERROR: modpost: "__traceiter_ata_bmdma_stop" [drivers/ata/pata_octeon_cf.ko] undefined!
ERROR: modpost: "__divdi3" [drivers/ata/pata_octeon_cf.ko] undefined!
make[2]: [scripts/Makefile.modpost:144: Module.symvers] Error 1 (ignored)
make[2]: *** No rule to make target 'kernel/locking/locktorture.ko', needed by '__modfinal'. Stop. make[1]: [Makefile:1933: modules] Error 2 (ignored)

Guenter

maintainer
#5 lore raw

Re: [PATCH 2/2] ata: octeon: Add compile test support

Quoted 5 lines · Guenter Roeck
Quoted 4 lines · Rob Herring

Add COMPILE_TEST to enable building Cavium Octeon drivers in MIPS allyesconfig/allmodconfig builds. There's a dependency on MIPS headers, so other arches can't be enabled.

Quoted 8 lines
Quoted 4 lines

---
Tested on allmodconfig build. Not sure if there's other MIPS configs where this doesn't work. We'll see what 0-day says.

Odd, in next-20230621 I get:

Building mips:allmodconfig ... failed

Indeed odd. Given that this is an allmodconfig, I would assume that CONFIG_CAVIUM_OCTEON_SOC is set ?

Quoted 12 lines

--------------
Error log:
ERROR: modpost: "__udivdi3" [drivers/ata/pata_octeon_cf.ko] undefined!
ERROR: modpost: "octeon_get_io_clock_rate" [drivers/ata/pata_octeon_cf.ko] undefined!
ERROR: modpost: "__tracepoint_ata_bmdma_stop" [drivers/ata/pata_octeon_cf.ko] undefined!
ERROR: modpost: "__traceiter_ata_bmdma_stop" [drivers/ata/pata_octeon_cf.ko] undefined!
ERROR: modpost: "__divdi3" [drivers/ata/pata_octeon_cf.ko] undefined!
make[2]: [scripts/Makefile.modpost:144: Module.symvers] Error 1 (ignored)
make[2]: *** No rule to make target 'kernel/locking/locktorture.ko', needed by '__modfinal'. Stop. make[1]: [Makefile:1933: modules] Error 2 (ignored)

Guenter

Signature · 2 lines
Damien Le Moal
Western Digital Research
#6 lore raw

Re: [PATCH 2/2] ata: octeon: Add compile test support

Quoted 11 lines · Damien Le Moal
Quoted 10 lines · Guenter Roeck
Quoted 8 lines · Rob Herring

Add COMPILE_TEST to enable building Cavium Octeon drivers in MIPS allyesconfig/allmodconfig builds. There's a dependency on MIPS headers, so other arches can't be enabled.

---
Tested on allmodconfig build. Not sure if there's other MIPS configs where this doesn't work. We'll see what 0-day says.

Quoted 7 lines
Quoted 3 lines

Odd, in next-20230621 I get:

Building mips:allmodconfig ... failed

Indeed odd. Given that this is an allmodconfig, I would assume that CONFIG_CAVIUM_OCTEON_SOC is set ?

No, it is not. CONFIG_CAVIUM_OCTEON_SOC is a choice option, meaning only one of the choices can be set, and mips:allmodconfig selects a different choice.

Guenter

Quoted 13 lines
Quoted 12 lines

--------------
Error log:
ERROR: modpost: "__udivdi3" [drivers/ata/pata_octeon_cf.ko] undefined!
ERROR: modpost: "octeon_get_io_clock_rate" [drivers/ata/pata_octeon_cf.ko] undefined!
ERROR: modpost: "__tracepoint_ata_bmdma_stop" [drivers/ata/pata_octeon_cf.ko] undefined!
ERROR: modpost: "__traceiter_ata_bmdma_stop" [drivers/ata/pata_octeon_cf.ko] undefined!
ERROR: modpost: "__divdi3" [drivers/ata/pata_octeon_cf.ko] undefined!
make[2]: [scripts/Makefile.modpost:144: Module.symvers] Error 1 (ignored)
make[2]: *** No rule to make target 'kernel/locking/locktorture.ko', needed by '__modfinal'. Stop. make[1]: [Makefile:1933: modules] Error 2 (ignored)

Guenter

maintainer
#7 lore raw

Re: [PATCH 2/2] ata: octeon: Add compile test support

Quoted 16 lines · Guenter Roeck
Quoted 15 lines · Damien Le Moal
Quoted 13 lines · Guenter Roeck
Quoted 8 lines · Rob Herring

Add COMPILE_TEST to enable building Cavium Octeon drivers in MIPS allyesconfig/allmodconfig builds. There's a dependency on MIPS headers, so other arches can't be enabled.

---
Tested on allmodconfig build. Not sure if there's other MIPS configs where this doesn't work. We'll see what 0-day says.

Odd, in next-20230621 I get:

Building mips:allmodconfig ... failed

Quoted 7 lines
Quoted 3 lines

Indeed odd. Given that this is an allmodconfig, I would assume that CONFIG_CAVIUM_OCTEON_SOC is set ?

No, it is not. CONFIG_CAVIUM_OCTEON_SOC is a choice option, meaning only one of the choices can be set, and mips:allmodconfig selects a different choice.

OK. Then I think I need to drop this patch as I do not see how to allow COMPILE_TEST without CONFIG_CAVIUM_OCTEON_SOC being set.

Rob ?

Quoted 17 lines

Guenter

Quoted 13 lines
Quoted 12 lines

--------------
Error log:
ERROR: modpost: "__udivdi3" [drivers/ata/pata_octeon_cf.ko] undefined!
ERROR: modpost: "octeon_get_io_clock_rate" [drivers/ata/pata_octeon_cf.ko] undefined!
ERROR: modpost: "__tracepoint_ata_bmdma_stop" [drivers/ata/pata_octeon_cf.ko] undefined!
ERROR: modpost: "__traceiter_ata_bmdma_stop" [drivers/ata/pata_octeon_cf.ko] undefined!
ERROR: modpost: "__divdi3" [drivers/ata/pata_octeon_cf.ko] undefined!
make[2]: [scripts/Makefile.modpost:144: Module.symvers] Error 1 (ignored)
make[2]: *** No rule to make target 'kernel/locking/locktorture.ko', needed by '__modfinal'. Stop. make[1]: [Makefile:1933: modules] Error 2 (ignored)

Guenter

Signature · 2 lines
Damien Le Moal
Western Digital Research
#8 lore raw

Re: [PATCH 2/2] ata: octeon: Add compile test support

Quoted 21 lines · Damien Le Moal
Quoted 20 lines · Guenter Roeck
Quoted 18 lines · Damien Le Moal
Quoted 5 lines · Guenter Roeck
Quoted 4 lines · Rob Herring

Add COMPILE_TEST to enable building Cavium Octeon drivers in MIPS allyesconfig/allmodconfig builds. There's a dependency on MIPS headers, so other arches can't be enabled.

Quoted 8 lines
Quoted 4 lines

---
Tested on allmodconfig build. Not sure if there's other MIPS configs where this doesn't work. We'll see what 0-day says.

Odd, in next-20230621 I get:

Building mips:allmodconfig ... failed

Indeed odd. Given that this is an allmodconfig, I would assume that CONFIG_CAVIUM_OCTEON_SOC is set ?

Quoted 7 lines
Quoted 3 lines

No, it is not. CONFIG_CAVIUM_OCTEON_SOC is a choice option, meaning only one of the choices can be set, and mips:allmodconfig selects a different choice.

OK. Then I think I need to drop this patch as I do not see how to allow COMPILE_TEST without CONFIG_CAVIUM_OCTEON_SOC being set.

That is a contradiction anyway. COMPILE_TEST implies that the target is independent of any other compile flags. If it depends on CONFIG_CAVIUM_OCTEON_SOC, overriding that with COMPILE_TEST does not make sense.

Guenter

Quoted 20 lines

Rob ?

Quoted 17 lines

Guenter

Quoted 13 lines
Quoted 12 lines

--------------
Error log:
ERROR: modpost: "__udivdi3" [drivers/ata/pata_octeon_cf.ko] undefined!
ERROR: modpost: "octeon_get_io_clock_rate" [drivers/ata/pata_octeon_cf.ko] undefined!
ERROR: modpost: "__tracepoint_ata_bmdma_stop" [drivers/ata/pata_octeon_cf.ko] undefined!
ERROR: modpost: "__traceiter_ata_bmdma_stop" [drivers/ata/pata_octeon_cf.ko] undefined!
ERROR: modpost: "__divdi3" [drivers/ata/pata_octeon_cf.ko] undefined!
make[2]: [scripts/Makefile.modpost:144: Module.symvers] Error 1 (ignored)
make[2]: *** No rule to make target 'kernel/locking/locktorture.ko', needed by '__modfinal'. Stop. make[1]: [Makefile:1933: modules] Error 2 (ignored)

Guenter

#9 lore raw

Re: [PATCH 2/2] ata: octeon: Add compile test support

In reply to Damien Le Moal
Quoted 22 lines · Damien Le Moal
Quoted 20 lines · Guenter Roeck
Quoted 18 lines · Damien Le Moal
Quoted 5 lines · Guenter Roeck
Quoted 4 lines · Rob Herring

Add COMPILE_TEST to enable building Cavium Octeon drivers in MIPS allyesconfig/allmodconfig builds. There's a dependency on MIPS headers, so other arches can't be enabled.

Quoted 8 lines
Quoted 4 lines

---
Tested on allmodconfig build. Not sure if there's other MIPS configs where this doesn't work. We'll see what 0-day says.

Odd, in next-20230621 I get:

Building mips:allmodconfig ... failed

Indeed odd. Given that this is an allmodconfig, I would assume that CONFIG_CAVIUM_OCTEON_SOC is set ?

Quoted 8 lines
Quoted 3 lines

No, it is not. CONFIG_CAVIUM_OCTEON_SOC is a choice option, meaning only one of the choices can be set, and mips:allmodconfig selects a different choice.

OK. Then I think I need to drop this patch as I do not see how to allow COMPILE_TEST without CONFIG_CAVIUM_OCTEON_SOC being set.

Rob ?

These could be fixed, but not sure it's worth the effort.

Quoted 6 lines
Quoted 6 lines

Guenter

Quoted 3 lines
Quoted 3 lines

--------------
Error log:
ERROR: modpost: "__udivdi3" [drivers/ata/pata_octeon_cf.ko] undefined!

This is due to 64-bit divides on 32-bit build, so do_div() needs to be used.

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

ERROR: modpost: "octeon_get_io_clock_rate" [drivers/ata/pata_octeon_cf.ko] undefined!

We'd need a static inline in the header for octeon_get_io_clock_rate().

Of course the real fix is Octeon needs to move to use the clock framework.

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

ERROR: modpost: "__tracepoint_ata_bmdma_stop" [drivers/ata/pata_octeon_cf.ko] undefined!
ERROR: modpost: "__traceiter_ata_bmdma_stop" [drivers/ata/pata_octeon_cf.ko] undefined!

Probably can just drop the trace_ata_bmdma_stop() call. It was added to replace a printk.

Rob

maintainer
#10 lore raw

Re: [PATCH 2/2] ata: octeon: Add compile test support

Quoted 27 lines · Rob Herring
Quoted 26 lines · Damien Le Moal
Quoted 23 lines · Guenter Roeck
Quoted 11 lines · Damien Le Moal
Quoted 10 lines · Guenter Roeck
Quoted 8 lines · Rob Herring

Add COMPILE_TEST to enable building Cavium Octeon drivers in MIPS allyesconfig/allmodconfig builds. There's a dependency on MIPS headers, so other arches can't be enabled.

---
Tested on allmodconfig build. Not sure if there's other MIPS configs where this doesn't work. We'll see what 0-day says.

Quoted 7 lines
Quoted 3 lines

Odd, in next-20230621 I get:

Building mips:allmodconfig ... failed

Indeed odd. Given that this is an allmodconfig, I would assume that CONFIG_CAVIUM_OCTEON_SOC is set ?

No, it is not. CONFIG_CAVIUM_OCTEON_SOC is a choice option, meaning only one of the choices can be set, and mips:allmodconfig selects a different choice.

Quoted 6 lines
Quoted 4 lines

OK. Then I think I need to drop this patch as I do not see how to allow COMPILE_TEST without CONFIG_CAVIUM_OCTEON_SOC being set.

Rob ?

These could be fixed, but not sure it's worth the effort.

Agreed. And given that we are at rc7 already, this effort should not be now anyway. I will drop this patch.

Signature · 2 lines
Damien Le Moal
Western Digital Research