Skip to contentSkip to conversation

hisi_lpc: Improve build test coverage

PATCH Superseded John Garry 2 participants 8 messages Oct 1, 2019 – Oct 3, 2019 Library code

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

John Garry

author
#0 lore raw

cover hisi_lpc: Improve build test coverage

This series aims to improve the build test cover of the driver by supporting building under COMPILE_TEST.

I also included "lib: logic_pio: Enforce LOGIC_PIO_INDIRECT region ops are set at registration" as it was never picked up for 5.4.

John Garry (3):
lib: logic_pio: Enforce LOGIC_PIO_INDIRECT region ops are set at
registration
logic_pio: Define PIO_INDIRECT_SIZE for !CONFIG_INDIRECT_PIO
bus: hisi_lpc: Expand build test coverage

 drivers/bus/Kconfig       |  4 ++--
 include/linux/logic_pio.h |  4 ++--
 lib/logic_pio.c           | 14 ++++++++------
 3 files changed, 12 insertions(+), 10 deletions(-)
Signature · 1 line
2.17.1
author
#1 lore raw

PATCH 1/3 lib: logic_pio: Enforce LOGIC_PIO_INDIRECT region ops are set at registration

Since the only LOGIC_PIO_INDIRECT host (hisi-lpc) now sets the ops prior to registration, enforce this check for accessors ops at registration instead of in the IO port accessors to simplify and marginally optimise the code.

A slight misalignment is also tidied.

Also add myself as an author.

---
 lib/logic_pio.c | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)
lib/logic_pio.c +8 -6
index 905027574e5d..f511a99bb389 100644
@@ -3,6 +3,7 @@
  * Copyright (C) 2017 HiSilicon Limited, All Rights Reserved.
  * Author: Gabriele Paoloni <[email protected]>
  * Author: Zhichang Yuan <[email protected]>
+ * Author: John Garry <[email protected]>
  */
 
 #define pr_fmt(fmt)	"LOGIC PIO: " fmt
@@ -39,7 +40,8 @@ int logic_pio_register_range(struct logic_pio_hwaddr *new_range)
 	resource_size_t iio_sz = MMIO_UPPER_LIMIT;
 	int ret = 0;
 
-	if (!new_range || !new_range->fwnode || !new_range->size)
+	if (!new_range || !new_range->fwnode || !new_range->size ||
+	    (new_range->flags == LOGIC_PIO_INDIRECT && !new_range->ops))
 		return -EINVAL;
 
 	start = new_range->hw_start;
@@ -237,7 +239,7 @@ type logic_in##bw(unsigned long addr)					\
 	} else if (addr >= MMIO_UPPER_LIMIT && addr < IO_SPACE_LIMIT) { \
 		struct logic_pio_hwaddr *entry = find_io_range(addr);	\
 									\
-		if (entry && entry->ops)				\
+		if (entry)						\
 			ret = entry->ops->in(entry->hostdata,		\
 					addr, sizeof(type));		\
 		else							\
@@ -253,7 +255,7 @@ void logic_out##bw(type value, unsigned long addr)			\
 	} else if (addr >= MMIO_UPPER_LIMIT && addr < IO_SPACE_LIMIT) {	\
 		struct logic_pio_hwaddr *entry = find_io_range(addr);	\
 									\
-		if (entry && entry->ops)				\
+		if (entry)						\
 			entry->ops->out(entry->hostdata,		\
 					addr, value, sizeof(type));	\
 		else							\
@@ -261,7 +263,7 @@ void logic_out##bw(type value, unsigned long addr)			\
 	}								\
 }									\
 									\
-void logic_ins##bw(unsigned long addr, void *buffer,		\
+void logic_ins##bw(unsigned long addr, void *buffer,			\
 		   unsigned int count)					\
 {									\
 	if (addr < MMIO_UPPER_LIMIT) {					\
@@ -269,7 +271,7 @@ void logic_ins##bw(unsigned long addr, void *buffer,		\
 	} else if (addr >= MMIO_UPPER_LIMIT && addr < IO_SPACE_LIMIT) {	\
 		struct logic_pio_hwaddr *entry = find_io_range(addr);	\
 									\
-		if (entry && entry->ops)				\
+		if (entry)						\
 			entry->ops->ins(entry->hostdata,		\
 				addr, buffer, sizeof(type), count);	\
 		else							\
@@ -286,7 +288,7 @@ void logic_outs##bw(unsigned long addr, const void *buffer,		\
 	} else if (addr >= MMIO_UPPER_LIMIT && addr < IO_SPACE_LIMIT) {	\
 		struct logic_pio_hwaddr *entry = find_io_range(addr);	\
 									\
-		if (entry && entry->ops)				\
+		if (entry)						\
 			entry->ops->outs(entry->hostdata,		\
 				addr, buffer, sizeof(type), count);	\
 		else							\
Signature · 1 line
2.17.1
author
#2 lore raw

PATCH 2/3 logic_pio: Define PIO_INDIRECT_SIZE for !CONFIG_INDIRECT_PIO

In reply to John Garry

With the goal of expanding the test coverage of the HiSi LPC driver to !ARM64, define a dummy PIO_INDIRECT_SIZE for !CONFIG_INDIRECT_PIO, which is required by the named driver.

---
 include/linux/logic_pio.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
include/linux/logic_pio.h +2 -2
index 88e1e6304a71..54945aa824b4 100644
@@ -108,10 +108,10 @@ void logic_outsl(unsigned long addr, const void *buffer, unsigned int count);
  * area by redefining the macro below.
  */
 #define PIO_INDIRECT_SIZE 0x4000
-#define MMIO_UPPER_LIMIT (IO_SPACE_LIMIT - PIO_INDIRECT_SIZE)
 #else
-#define MMIO_UPPER_LIMIT IO_SPACE_LIMIT
+#define PIO_INDIRECT_SIZE 0
 #endif /* CONFIG_INDIRECT_PIO */
+#define MMIO_UPPER_LIMIT (IO_SPACE_LIMIT - PIO_INDIRECT_SIZE)
 
 struct logic_pio_hwaddr *find_io_range_by_fwnode(struct fwnode_handle *fwnode);
 unsigned long logic_pio_trans_hwaddr(struct fwnode_handle *fwnode,
Signature · 1 line
2.17.1
author
#3 lore raw

PATCH 3/3 bus: hisi_lpc: Expand build test coverage

In reply to John Garry

Currently the driver will only ever be built for ARM64 because it selects CONFIG_INDIRECT_PIO, which itself depends on ARM64.

Expand build test coverage for the driver to other architectures by only selecting CONFIG_INDIRECT_PIO for ARM64, when we really want it.

---
 drivers/bus/Kconfig | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/bus/Kconfig +2 -2
index 6b331061d34b..44cb4b6bea18 100644
@@ -41,8 +41,8 @@ config MOXTET
 
 config HISILICON_LPC
 	bool "Support for ISA I/O space on HiSilicon Hip06/7"
-	depends on ARM64 && (ARCH_HISI || COMPILE_TEST)
-	select INDIRECT_PIO
+	depends on (ARM64 && ARCH_HISI) || COMPILE_TEST
+	select INDIRECT_PIO if ARM64
 	help
 	  Driver to enable I/O access to devices attached to the Low Pin
 	  Count bus on the HiSilicon Hip06/7 SoC.
Signature · 1 line
2.17.1
#4 lore raw

Re: [PATCH 3/3] bus: hisi_lpc: Expand build test coverage

Quoted 8 lines · John Garry

Currently the driver will only ever be built for ARM64 because it selects CONFIG_INDIRECT_PIO, which itself depends on ARM64.

Expand build test coverage for the driver to other architectures by only selecting CONFIG_INDIRECT_PIO for ARM64, when we really want it.

Good idea, but doesn't this cause a link failure against logic_pio_register_range() when INDIRECT_PIO is disabled?

Arnd

author
#5 lore raw

Re: [PATCH 3/3] bus: hisi_lpc: Expand build test coverage

Quoted 10 lines · Arnd Bergmann
Quoted 8 lines · John Garry

Currently the driver will only ever be built for ARM64 because it selects CONFIG_INDIRECT_PIO, which itself depends on ARM64.

Expand build test coverage for the driver to other architectures by only selecting CONFIG_INDIRECT_PIO for ARM64, when we really want it.

Hi Arnd,

Quoted 2 lines

Good idea, but doesn't this cause a link failure against logic_pio_register_range() when INDIRECT_PIO is disabled?

No, it shouldn't do. Function lib/logic_pio.c::logic_pio_register_range() is built always, outside any INDIRECT_PIO checking.

A some stage, for completeness we should probably change logic_pio_register_range() and friends to be under PCI_IOBASE. But then we would need stubs for !PCI_IOBASE, due to this above change and also references from the device tree code. I'd have to consider this a bit more. Let me know what you think.

Thanks,
John

Quoted 4 lines

Arnd

#6 lore raw

Re: [PATCH 3/3] bus: hisi_lpc: Expand build test coverage

Quoted 12 lines · John Garry
Quoted 10 lines · Arnd Bergmann
Quoted 8 lines · John Garry

Currently the driver will only ever be built for ARM64 because it selects CONFIG_INDIRECT_PIO, which itself depends on ARM64.

Expand build test coverage for the driver to other architectures by only selecting CONFIG_INDIRECT_PIO for ARM64, when we really want it.

Quoted 8 lines

Hi Arnd,

Quoted 2 lines

Good idea, but doesn't this cause a link failure against logic_pio_register_range() when INDIRECT_PIO is disabled?

No, it shouldn't do. Function lib/logic_pio.c::logic_pio_register_range() is built always, outside any INDIRECT_PIO checking.

Ok, I see.

Quoted 5 lines

A some stage, for completeness we should probably change logic_pio_register_range() and friends to be under PCI_IOBASE. But then we would need stubs for !PCI_IOBASE, due to this above change and also references from the device tree code. I'd have to consider this a bit more. Let me know what you think.

It's probably not to do this with the usual 'static inline' stubs in the header files. There is no rush here, but it would be nice to not build this code when it is not needed.

I wonder if this one-line change would take care of the !CONFIG_OF case already (it probably doesn't):

lib/Makefile +1 -1
@@ -107,7 +107,7 @@ obj-$(CONFIG_HAS_IOMEM) += iomap_copy.o devres.o
 obj-$(CONFIG_CHECK_SIGNATURE) += check_signature.o
 obj-$(CONFIG_DEBUG_LOCKING_API_SELFTESTS) += locking-selftest.o
 
-obj-y += logic_pio.o
+lib-y += logic_pio.o
 
 obj-$(CONFIG_GENERIC_HWEIGHT) += hweight.o
 

On a related note: At some point we may want to add an indirect method for readl()/writel(), to deal with some of the weirder 32-bit ARM platforms. We'll have to see how well this can fit into the infrastructure we already have for indirect PIO.

Arnd

author
#7 lore raw

Re: [PATCH 3/3] bus: hisi_lpc: Expand build test coverage

Quoted 30 lines · Arnd Bergmann
Quoted 12 lines · John Garry
Quoted 10 lines · Arnd Bergmann
Quoted 8 lines · John Garry

Currently the driver will only ever be built for ARM64 because it selects CONFIG_INDIRECT_PIO, which itself depends on ARM64.

Expand build test coverage for the driver to other architectures by only selecting CONFIG_INDIRECT_PIO for ARM64, when we really want it.

Quoted 8 lines

Hi Arnd,

Quoted 2 lines

Good idea, but doesn't this cause a link failure against logic_pio_register_range() when INDIRECT_PIO is disabled?

No, it shouldn't do. Function lib/logic_pio.c::logic_pio_register_range() is built always, outside any INDIRECT_PIO checking.

Ok, I see.

Quoted 5 lines

A some stage, for completeness we should probably change logic_pio_register_range() and friends to be under PCI_IOBASE. But then we would need stubs for !PCI_IOBASE, due to this above change and also references from the device tree code. I'd have to consider this a bit more. Let me know what you think.

Quoted 3 lines

It's probably not to do this with the usual 'static inline' stubs in the header files. There is no rush here, but it would be nice to not build this code when it is not needed.

Agreed, I'll add it to my todo list.

So we want to build logic_pio.c for archs which define PCI_IOBASE, but there is no specific config option for that.

lib/Makefile obj-$(CONFIG_HAS_IOMEM) += iomap_copy.o devres.o · line 110

Quoted 12 lines

I wonder if this one-line change would take care of the !CONFIG_OF case already (it probably doesn't):

lib/Makefile +1 -1
@@ -107,7 +107,7 @@ obj-$(CONFIG_HAS_IOMEM) += iomap_copy.o devres.o
 obj-$(CONFIG_CHECK_SIGNATURE) += check_signature.o
 obj-$(CONFIG_DEBUG_LOCKING_API_SELFTESTS) += locking-selftest.o
 
-obj-y += logic_pio.o
+lib-y += logic_pio.o

So that means that this obj will not be included in the vmlinux file for !CONFIG_OF (for archs with !PCI_IOBASE or !PCI).

It is an improvement, but I still would like to make the complete change and not to build at all for archs which don't define PCI_IOBASE.

Quoted 7 lines
lib/Makefile +0 -0
 obj-$(CONFIG_GENERIC_HWEIGHT) += hweight.o
 

On a related note: At some point we may want to add an indirect method for readl()/writel(), to deal with some of the weirder 32-bit ARM platforms. We'll have to see how well this can fit into the infrastructure we already have for indirect PIO.

It should be possible. We would just need to manage 2 separate logical spaces instead of one: a. mmio b. pio

I'm guessing that all the code for logical <-> hw bus address translations would be the same.

Thanks,
John

Quoted 5 lines

Arnd

.