Linux-parisc archive on lore.kernel.org
 help / Atom feed
* DMA-related cleanups for parisc
@ 2019-01-14 11:23 Christoph Hellwig
  2019-01-14 11:23 ` [PATCH 1/8] parisc: don't include <asm/cacheflush.h> in <asm/dma-mapping.h> Christoph Hellwig
                   ` (8 more replies)
  0 siblings, 9 replies; 15+ messages in thread
From: Christoph Hellwig @ 2019-01-14 11:23 UTC (permalink / raw)
  To: James E.J. Bottomley, Helge Deller; +Cc: linux-parisc, linux-kernel

Hi James and Helge,

this series has a couple DMA-related cleanups for parisc.  The main aim
is to move anything not required by drivers out of <asm/dma-mapping.h>,
but I noticed a few related bits and cleaned them up as well.

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [PATCH 1/8] parisc: don't include <asm/cacheflush.h> in <asm/dma-mapping.h>
  2019-01-14 11:23 DMA-related cleanups for parisc Christoph Hellwig
@ 2019-01-14 11:23 ` Christoph Hellwig
  2019-01-14 11:23 ` [PATCH 2/8] parisc: move internal implementation details out of <asm/dma-mapping.h> Christoph Hellwig
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 15+ messages in thread
From: Christoph Hellwig @ 2019-01-14 11:23 UTC (permalink / raw)
  To: James E.J. Bottomley, Helge Deller; +Cc: linux-parisc, linux-kernel

No need for any of the definitions here, all there real work now
happens out of line.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 arch/parisc/include/asm/dma-mapping.h | 2 --
 arch/parisc/kernel/setup.c            | 1 +
 2 files changed, 1 insertion(+), 2 deletions(-)

diff --git a/arch/parisc/include/asm/dma-mapping.h b/arch/parisc/include/asm/dma-mapping.h
index 44a9f97194aa..f1bf5e297f1c 100644
--- a/arch/parisc/include/asm/dma-mapping.h
+++ b/arch/parisc/include/asm/dma-mapping.h
@@ -2,8 +2,6 @@
 #ifndef _PARISC_DMA_MAPPING_H
 #define _PARISC_DMA_MAPPING_H
 
-#include <asm/cacheflush.h>
-
 /*
 ** We need to support 4 different coherent dma models with one binary:
 **
diff --git a/arch/parisc/kernel/setup.c b/arch/parisc/kernel/setup.c
index f2cf86ac279b..15dd9e21be7e 100644
--- a/arch/parisc/kernel/setup.c
+++ b/arch/parisc/kernel/setup.c
@@ -40,6 +40,7 @@
 #include <linux/sched/clock.h>
 #include <linux/start_kernel.h>
 
+#include <asm/cacheflush.h>
 #include <asm/processor.h>
 #include <asm/sections.h>
 #include <asm/pdc.h>
-- 
2.20.1


^ permalink raw reply	[flat|nested] 15+ messages in thread

* [PATCH 2/8] parisc: move internal implementation details out of <asm/dma-mapping.h>
  2019-01-14 11:23 DMA-related cleanups for parisc Christoph Hellwig
  2019-01-14 11:23 ` [PATCH 1/8] parisc: don't include <asm/cacheflush.h> in <asm/dma-mapping.h> Christoph Hellwig
@ 2019-01-14 11:23 ` Christoph Hellwig
  2019-01-14 11:23 ` [PATCH 3/8] parisc: turn GET_IOC into an inline function Christoph Hellwig
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 15+ messages in thread
From: Christoph Hellwig @ 2019-01-14 11:23 UTC (permalink / raw)
  To: James E.J. Bottomley, Helge Deller; +Cc: linux-parisc, linux-kernel

Move everything that is not required for the public facing DMA API out
of <asm/dma-mapping.h> and into a new drivers/parisc/iommu.h header.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 arch/parisc/include/asm/dma-mapping.h | 44 ------------------------
 drivers/parisc/ccio-dma.c             |  2 ++
 drivers/parisc/dino.c                 |  1 +
 drivers/parisc/eisa.c                 |  2 ++
 drivers/parisc/hppb.c                 |  2 ++
 drivers/parisc/iommu.h                | 49 +++++++++++++++++++++++++++
 drivers/parisc/lba_pci.c              |  2 ++
 drivers/parisc/sba_iommu.c            |  2 ++
 8 files changed, 60 insertions(+), 44 deletions(-)
 create mode 100644 drivers/parisc/iommu.h

diff --git a/arch/parisc/include/asm/dma-mapping.h b/arch/parisc/include/asm/dma-mapping.h
index f1bf5e297f1c..d5bd94247371 100644
--- a/arch/parisc/include/asm/dma-mapping.h
+++ b/arch/parisc/include/asm/dma-mapping.h
@@ -26,48 +26,4 @@ static inline const struct dma_map_ops *get_arch_dma_ops(struct bus_type *bus)
 	return hppa_dma_ops;
 }
 
-static inline void *
-parisc_walk_tree(struct device *dev)
-{
-	struct device *otherdev;
-	if(likely(dev->platform_data != NULL))
-		return dev->platform_data;
-	/* OK, just traverse the bus to find it */
-	for(otherdev = dev->parent; otherdev;
-	    otherdev = otherdev->parent) {
-		if(otherdev->platform_data) {
-			dev->platform_data = otherdev->platform_data;
-			break;
-		}
-	}
-	return dev->platform_data;
-}
-
-#define GET_IOC(dev) ({					\
-	void *__pdata = parisc_walk_tree(dev);		\
-	__pdata ? HBA_DATA(__pdata)->iommu : NULL;	\
-})
-
-#ifdef CONFIG_IOMMU_CCIO
-struct parisc_device;
-struct ioc;
-void * ccio_get_iommu(const struct parisc_device *dev);
-int ccio_request_resource(const struct parisc_device *dev,
-		struct resource *res);
-int ccio_allocate_resource(const struct parisc_device *dev,
-		struct resource *res, unsigned long size,
-		unsigned long min, unsigned long max, unsigned long align);
-#else /* !CONFIG_IOMMU_CCIO */
-#define ccio_get_iommu(dev) NULL
-#define ccio_request_resource(dev, res) insert_resource(&iomem_resource, res)
-#define ccio_allocate_resource(dev, res, size, min, max, align) \
-		allocate_resource(&iomem_resource, res, size, min, max, \
-				align, NULL, NULL)
-#endif /* !CONFIG_IOMMU_CCIO */
-
-#ifdef CONFIG_IOMMU_SBA
-struct parisc_device;
-void * sba_get_iommu(struct parisc_device *dev);
-#endif
-
 #endif
diff --git a/drivers/parisc/ccio-dma.c b/drivers/parisc/ccio-dma.c
index 8d2fc84119c6..b17e81cf77d5 100644
--- a/drivers/parisc/ccio-dma.c
+++ b/drivers/parisc/ccio-dma.c
@@ -55,6 +55,8 @@
 #include <asm/hardware.h>       /* for register_module() */
 #include <asm/parisc-device.h>
 
+#include "iommu.h"
+
 /* 
 ** Choose "ccio" since that's what HP-UX calls it.
 ** Make it easier for folks to migrate from one to the other :^)
diff --git a/drivers/parisc/dino.c b/drivers/parisc/dino.c
index dfeea458a789..6f348c75687c 100644
--- a/drivers/parisc/dino.c
+++ b/drivers/parisc/dino.c
@@ -59,6 +59,7 @@
 #include <asm/hardware.h>
 
 #include "gsc.h"
+#include "iommu.h"
 
 #undef DINO_DEBUG
 
diff --git a/drivers/parisc/eisa.c b/drivers/parisc/eisa.c
index 9ff434f354bd..5657a1d3eb2b 100644
--- a/drivers/parisc/eisa.c
+++ b/drivers/parisc/eisa.c
@@ -45,6 +45,8 @@
 #include <asm/eisa_bus.h>
 #include <asm/eisa_eeprom.h>
 
+#include "iommu.h"
+
 #if 0
 #define EISA_DBG(msg, arg...) printk(KERN_DEBUG "eisa: " msg, ## arg)
 #else
diff --git a/drivers/parisc/hppb.c b/drivers/parisc/hppb.c
index ebc7b617e5d0..3b3481c0d81d 100644
--- a/drivers/parisc/hppb.c
+++ b/drivers/parisc/hppb.c
@@ -23,6 +23,8 @@
 #include <asm/hardware.h>
 #include <asm/parisc-device.h>
 
+#include "iommu.h"
+
 struct hppb_card {
 	unsigned long hpa;
 	struct resource mmio_region;
diff --git a/drivers/parisc/iommu.h b/drivers/parisc/iommu.h
new file mode 100644
index 000000000000..c72c4fe51a3a
--- /dev/null
+++ b/drivers/parisc/iommu.h
@@ -0,0 +1,49 @@
+#ifndef _IOMMU_H
+#define _IOMMU_H 1
+
+struct parisc_device;
+struct ioc;
+
+static inline void *parisc_walk_tree(struct device *dev)
+{
+	struct device *otherdev;
+
+	if (likely(dev->platform_data))
+		return dev->platform_data;
+
+	/* OK, just traverse the bus to find it */
+	for (otherdev = dev->parent;
+	     otherdev;
+	     otherdev = otherdev->parent) {
+		if (otherdev->platform_data) {
+			dev->platform_data = otherdev->platform_data;
+			break;
+		}
+	}
+
+	return dev->platform_data;
+}
+
+#define GET_IOC(dev) ({					\
+	void *__pdata = parisc_walk_tree(dev);		\
+	__pdata ? HBA_DATA(__pdata)->iommu : NULL;	\
+})
+
+#ifdef CONFIG_IOMMU_CCIO
+void *ccio_get_iommu(const struct parisc_device *dev);
+int ccio_request_resource(const struct parisc_device *dev,
+		struct resource *res);
+int ccio_allocate_resource(const struct parisc_device *dev,
+		struct resource *res, unsigned long size,
+		unsigned long min, unsigned long max, unsigned long align);
+#else /* !CONFIG_IOMMU_CCIO */
+#define ccio_get_iommu(dev) NULL
+#define ccio_request_resource(dev, res) insert_resource(&iomem_resource, res)
+#define ccio_allocate_resource(dev, res, size, min, max, align) \
+		allocate_resource(&iomem_resource, res, size, min, max, \
+				align, NULL, NULL)
+#endif /* !CONFIG_IOMMU_CCIO */
+
+void *sba_get_iommu(struct parisc_device *dev);
+
+#endif /* _IOMMU_H */
diff --git a/drivers/parisc/lba_pci.c b/drivers/parisc/lba_pci.c
index 69bd98421eb1..63e9bc6d18de 100644
--- a/drivers/parisc/lba_pci.c
+++ b/drivers/parisc/lba_pci.c
@@ -49,6 +49,8 @@
 #include <asm/parisc-device.h>
 #include <asm/io.h>		/* read/write stuff */
 
+#include "iommu.h"
+
 #undef DEBUG_LBA	/* general stuff */
 #undef DEBUG_LBA_PORT	/* debug I/O Port access */
 #undef DEBUG_LBA_CFG	/* debug Config Space Access (ie PCI Bus walk) */
diff --git a/drivers/parisc/sba_iommu.c b/drivers/parisc/sba_iommu.c
index 42172eb32235..afaf8e6aefe6 100644
--- a/drivers/parisc/sba_iommu.c
+++ b/drivers/parisc/sba_iommu.c
@@ -49,6 +49,8 @@
 #include <asm/pdcpat.h>		/* for is_pdc_pat() */
 #include <asm/parisc-device.h>
 
+#include "iommu.h"
+
 #define MODULE_NAME "SBA"
 
 /*
-- 
2.20.1


^ permalink raw reply	[flat|nested] 15+ messages in thread

* [PATCH 3/8] parisc: turn GET_IOC into an inline function
  2019-01-14 11:23 DMA-related cleanups for parisc Christoph Hellwig
  2019-01-14 11:23 ` [PATCH 1/8] parisc: don't include <asm/cacheflush.h> in <asm/dma-mapping.h> Christoph Hellwig
  2019-01-14 11:23 ` [PATCH 2/8] parisc: move internal implementation details out of <asm/dma-mapping.h> Christoph Hellwig
@ 2019-01-14 11:23 ` Christoph Hellwig
  2019-01-14 23:32   ` kbuild test robot
  2019-01-14 11:23 ` [PATCH 4/8] parisc: properly type the iommu field in struct pci_hba_data Christoph Hellwig
                   ` (5 subsequent siblings)
  8 siblings, 1 reply; 15+ messages in thread
From: Christoph Hellwig @ 2019-01-14 11:23 UTC (permalink / raw)
  To: James E.J. Bottomley, Helge Deller; +Cc: linux-parisc, linux-kernel

This makes the function both more readable and more typesafe.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 drivers/parisc/iommu.h | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/drivers/parisc/iommu.h b/drivers/parisc/iommu.h
index c72c4fe51a3a..94d5eae98bf6 100644
--- a/drivers/parisc/iommu.h
+++ b/drivers/parisc/iommu.h
@@ -24,10 +24,14 @@ static inline void *parisc_walk_tree(struct device *dev)
 	return dev->platform_data;
 }
 
-#define GET_IOC(dev) ({					\
-	void *__pdata = parisc_walk_tree(dev);		\
-	__pdata ? HBA_DATA(__pdata)->iommu : NULL;	\
-})
+static inline struct ioc *GET_IOC(struct device *dev)
+{
+	struct pci_hba_data *pdata = parisc_walk_tree(dev);
+
+	if (!pdata)
+		return NULL;
+	return pdata->iommu;
+}
 
 #ifdef CONFIG_IOMMU_CCIO
 void *ccio_get_iommu(const struct parisc_device *dev);
-- 
2.20.1


^ permalink raw reply	[flat|nested] 15+ messages in thread

* [PATCH 4/8] parisc: properly type the iommu field in struct pci_hba_data
  2019-01-14 11:23 DMA-related cleanups for parisc Christoph Hellwig
                   ` (2 preceding siblings ...)
  2019-01-14 11:23 ` [PATCH 3/8] parisc: turn GET_IOC into an inline function Christoph Hellwig
@ 2019-01-14 11:23 ` Christoph Hellwig
  2019-01-14 11:23 ` [PATCH 5/8] parisc: properly type the return value of parisc_walk_tree Christoph Hellwig
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 15+ messages in thread
From: Christoph Hellwig @ 2019-01-14 11:23 UTC (permalink / raw)
  To: James E.J. Bottomley, Helge Deller; +Cc: linux-parisc, linux-kernel

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 arch/parisc/include/asm/pci.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/parisc/include/asm/pci.h b/arch/parisc/include/asm/pci.h
index 3328fd17c19d..00f763688401 100644
--- a/arch/parisc/include/asm/pci.h
+++ b/arch/parisc/include/asm/pci.h
@@ -56,7 +56,7 @@ struct pci_hba_data {
 	#define DINO_MAX_LMMIO_RESOURCES	3
 
 	unsigned long   lmmio_space_offset;  /* CPU view - PCI view */
-	void *          iommu;          /* IOMMU this device is under */
+	struct ioc	*iommu;		/* IOMMU this device is under */
 	/* REVISIT - spinlock to protect resources? */
 
 	#define HBA_NAME_SIZE 16
-- 
2.20.1


^ permalink raw reply	[flat|nested] 15+ messages in thread

* [PATCH 5/8] parisc: properly type the return value of parisc_walk_tree
  2019-01-14 11:23 DMA-related cleanups for parisc Christoph Hellwig
                   ` (3 preceding siblings ...)
  2019-01-14 11:23 ` [PATCH 4/8] parisc: properly type the iommu field in struct pci_hba_data Christoph Hellwig
@ 2019-01-14 11:23 ` Christoph Hellwig
  2019-01-14 11:23 ` [PATCH 6/8] parisc/dino: use container_of in DINO_DEV Christoph Hellwig
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 15+ messages in thread
From: Christoph Hellwig @ 2019-01-14 11:23 UTC (permalink / raw)
  To: James E.J. Bottomley, Helge Deller; +Cc: linux-parisc, linux-kernel

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 drivers/parisc/iommu.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/parisc/iommu.h b/drivers/parisc/iommu.h
index 94d5eae98bf6..010539fc4643 100644
--- a/drivers/parisc/iommu.h
+++ b/drivers/parisc/iommu.h
@@ -4,7 +4,7 @@
 struct parisc_device;
 struct ioc;
 
-static inline void *parisc_walk_tree(struct device *dev)
+static inline struct pci_hba_data *parisc_walk_tree(struct device *dev)
 {
 	struct device *otherdev;
 
-- 
2.20.1


^ permalink raw reply	[flat|nested] 15+ messages in thread

* [PATCH 6/8] parisc/dino: use container_of in DINO_DEV
  2019-01-14 11:23 DMA-related cleanups for parisc Christoph Hellwig
                   ` (4 preceding siblings ...)
  2019-01-14 11:23 ` [PATCH 5/8] parisc: properly type the return value of parisc_walk_tree Christoph Hellwig
@ 2019-01-14 11:23 ` Christoph Hellwig
  2019-01-14 11:23 ` [PATCH 7/8] parisc/lba_pci: use container_of in LBA_DEV Christoph Hellwig
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 15+ messages in thread
From: Christoph Hellwig @ 2019-01-14 11:23 UTC (permalink / raw)
  To: James E.J. Bottomley, Helge Deller; +Cc: linux-parisc, linux-kernel

Use the type safe container_of macros instead of a blind cast in
DINO_DEV, and turn the macro into an inline function.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 drivers/parisc/dino.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/drivers/parisc/dino.c b/drivers/parisc/dino.c
index 6f348c75687c..846b59d15999 100644
--- a/drivers/parisc/dino.c
+++ b/drivers/parisc/dino.c
@@ -154,12 +154,10 @@ struct dino_device
 #endif
 };
 
-/* Looks nice and keeps the compiler happy */
-#define DINO_DEV(d) ({				\
-	void *__pdata = d;			\
-	BUG_ON(!__pdata);			\
-	(struct dino_device *)__pdata; })
-
+static inline struct dino_device *DINO_DEV(struct pci_hba_data *hba)
+{
+	return container_of(hba, struct dino_device, hba);
+}
 
 /*
  * Dino Configuration Space Accessor Functions
-- 
2.20.1


^ permalink raw reply	[flat|nested] 15+ messages in thread

* [PATCH 7/8] parisc/lba_pci: use container_of in LBA_DEV
  2019-01-14 11:23 DMA-related cleanups for parisc Christoph Hellwig
                   ` (5 preceding siblings ...)
  2019-01-14 11:23 ` [PATCH 6/8] parisc/dino: use container_of in DINO_DEV Christoph Hellwig
@ 2019-01-14 11:23 ` Christoph Hellwig
  2019-01-14 11:23 ` [PATCH 8/8] parisc: remove the HBA_DATA macro Christoph Hellwig
  2019-01-26 17:11 ` DMA-related cleanups for parisc Helge Deller
  8 siblings, 0 replies; 15+ messages in thread
From: Christoph Hellwig @ 2019-01-14 11:23 UTC (permalink / raw)
  To: James E.J. Bottomley, Helge Deller; +Cc: linux-parisc, linux-kernel

Use the type safe container_of macros instead of a blind cast in
LBA_DEV, and turn the macro into an inline function.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 drivers/parisc/lba_pci.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/drivers/parisc/lba_pci.c b/drivers/parisc/lba_pci.c
index 63e9bc6d18de..065d88868402 100644
--- a/drivers/parisc/lba_pci.c
+++ b/drivers/parisc/lba_pci.c
@@ -111,12 +111,10 @@ static u32 lba_t32;
 
 #define LBA_SKIP_PROBE(d) ((d)->flags & LBA_FLAG_SKIP_PROBE)
 
-
-/* Looks nice and keeps the compiler happy */
-#define LBA_DEV(d) ({				\
-	void *__pdata = d;			\
-	BUG_ON(!__pdata);			\
-	(struct lba_device *)__pdata; })
+static inline struct lba_device *LBA_DEV(struct pci_hba_data *hba)
+{
+	return container_of(hba, struct lba_device, hba);
+}
 
 /*
 ** Only allow 8 subsidiary busses per LBA
-- 
2.20.1


^ permalink raw reply	[flat|nested] 15+ messages in thread

* [PATCH 8/8] parisc: remove the HBA_DATA macro
  2019-01-14 11:23 DMA-related cleanups for parisc Christoph Hellwig
                   ` (6 preceding siblings ...)
  2019-01-14 11:23 ` [PATCH 7/8] parisc/lba_pci: use container_of in LBA_DEV Christoph Hellwig
@ 2019-01-14 11:23 ` Christoph Hellwig
  2019-01-26 17:11 ` DMA-related cleanups for parisc Helge Deller
  8 siblings, 0 replies; 15+ messages in thread
From: Christoph Hellwig @ 2019-01-14 11:23 UTC (permalink / raw)
  To: James E.J. Bottomley, Helge Deller; +Cc: linux-parisc, linux-kernel

No need to hide a cast in a macro, especially as all users have
cleaner ways to archive the result than blind casting.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 arch/parisc/include/asm/pci.h | 2 --
 drivers/parisc/ccio-dma.c     | 9 ++++++---
 drivers/parisc/lba_pci.c      | 6 +++---
 3 files changed, 9 insertions(+), 8 deletions(-)

diff --git a/arch/parisc/include/asm/pci.h b/arch/parisc/include/asm/pci.h
index 00f763688401..f14465b84de4 100644
--- a/arch/parisc/include/asm/pci.h
+++ b/arch/parisc/include/asm/pci.h
@@ -66,8 +66,6 @@ struct pci_hba_data {
 	char gmmio_name[HBA_NAME_SIZE];
 };
 
-#define HBA_DATA(d)		((struct pci_hba_data *) (d))
-
 /* 
 ** We support 2^16 I/O ports per HBA.  These are set up in the form
 ** 0xbbxxxx, where bb is the bus number and xxxx is the I/O port
diff --git a/drivers/parisc/ccio-dma.c b/drivers/parisc/ccio-dma.c
index b17e81cf77d5..097b0d43d13c 100644
--- a/drivers/parisc/ccio-dma.c
+++ b/drivers/parisc/ccio-dma.c
@@ -1519,6 +1519,7 @@ static int __init ccio_probe(struct parisc_device *dev)
 {
 	int i;
 	struct ioc *ioc, **ioc_p = &ioc_list;
+	struct pci_hba_data *hba;
 
 	ioc = kzalloc(sizeof(struct ioc), GFP_KERNEL);
 	if (ioc == NULL) {
@@ -1545,11 +1546,13 @@ static int __init ccio_probe(struct parisc_device *dev)
 	ccio_ioc_init(ioc);
 	ccio_init_resources(ioc);
 	hppa_dma_ops = &ccio_ops;
-	dev->dev.platform_data = kzalloc(sizeof(struct pci_hba_data), GFP_KERNEL);
 
+	hba = kzalloc(sizeof(*hba), GFP_KERNEL);
 	/* if this fails, no I/O cards will work, so may as well bug */
-	BUG_ON(dev->dev.platform_data == NULL);
-	HBA_DATA(dev->dev.platform_data)->iommu = ioc;
+	BUG_ON(hba == NULL);
+
+	hba->iommu = ioc;
+	dev->dev.platform_data = hba;
 
 #ifdef CONFIG_PROC_FS
 	if (ioc_count == 0) {
diff --git a/drivers/parisc/lba_pci.c b/drivers/parisc/lba_pci.c
index 065d88868402..9047cc22c155 100644
--- a/drivers/parisc/lba_pci.c
+++ b/drivers/parisc/lba_pci.c
@@ -1275,7 +1275,7 @@ lba_legacy_resources(struct parisc_device *pa_dev, struct lba_device *lba_dev)
 		r->flags = IORESOURCE_MEM;
 		/* mmio_mask also clears Enable bit */
 		r->start &= mmio_mask;
-		r->start = PCI_HOST_ADDR(HBA_DATA(lba_dev), r->start);
+		r->start = PCI_HOST_ADDR(&lba_dev->hba, r->start);
 		rsize = ~ READ_REG32(lba_dev->hba.base_addr + LBA_LMMIO_MASK);
 
 		/*
@@ -1321,7 +1321,7 @@ lba_legacy_resources(struct parisc_device *pa_dev, struct lba_device *lba_dev)
 		r->flags = IORESOURCE_MEM;
 		/* mmio_mask also clears Enable bit */
 		r->start &= mmio_mask;
-		r->start = PCI_HOST_ADDR(HBA_DATA(lba_dev), r->start);
+		r->start = PCI_HOST_ADDR(&lba_dev->hba, r->start);
 		rsize = READ_REG32(lba_dev->hba.base_addr + LBA_ELMMIO_MASK);
 		r->end = r->start + ~rsize;
 	}
@@ -1562,7 +1562,7 @@ lba_driver_probe(struct parisc_device *dev)
 
 	/* ------------ Second : initialize common stuff ---------- */
 	pci_bios = &lba_bios_ops;
-	pcibios_register_hba(HBA_DATA(lba_dev));
+	pcibios_register_hba(&lba_dev->hba);
 	spin_lock_init(&lba_dev->lba_lock);
 
 	if (lba_hw_init(lba_dev))
-- 
2.20.1


^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH 3/8] parisc: turn GET_IOC into an inline function
  2019-01-14 11:23 ` [PATCH 3/8] parisc: turn GET_IOC into an inline function Christoph Hellwig
@ 2019-01-14 23:32   ` kbuild test robot
  0 siblings, 0 replies; 15+ messages in thread
From: kbuild test robot @ 2019-01-14 23:32 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: kbuild-all, James E.J. Bottomley, Helge Deller, linux-parisc,
	linux-kernel

[-- Attachment #1: Type: text/plain, Size: 1570 bytes --]

Hi Christoph,

I love your patch! Yet something to improve:

[auto build test ERROR on hp-parisc/for-next]
[also build test ERROR on v5.0-rc2 next-20190114]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Christoph-Hellwig/parisc-don-t-include-asm-cacheflush-h-in-asm-dma-mapping-h/20190115-034634
base:   https://git.kernel.org/pub/scm/linux/kernel/git/deller/parisc-linux.git for-next
config: parisc-b180_defconfig (attached as .config)
compiler: hppa-linux-gnu-gcc (Debian 7.2.0-11) 7.2.0
reproduce:
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # save the attached .config to linux build tree
        GCC_VERSION=7.2.0 make.cross ARCH=parisc 

All errors (new ones prefixed by >>):

   In file included from drivers/parisc/hppb.c:26:0:
   drivers/parisc/iommu.h: In function 'GET_IOC':
>> drivers/parisc/iommu.h:33:14: error: dereferencing pointer to incomplete type 'struct pci_hba_data'
     return pdata->iommu;
                 ^~

vim +33 drivers/parisc/iommu.h

    26	
    27	static inline struct ioc *GET_IOC(struct device *dev)
    28	{
    29		struct pci_hba_data *pdata = parisc_walk_tree(dev);
    30	
    31		if (!pdata)
    32			return NULL;
  > 33		return pdata->iommu;
    34	}
    35	

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 13297 bytes --]

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: DMA-related cleanups for parisc
  2019-01-14 11:23 DMA-related cleanups for parisc Christoph Hellwig
                   ` (7 preceding siblings ...)
  2019-01-14 11:23 ` [PATCH 8/8] parisc: remove the HBA_DATA macro Christoph Hellwig
@ 2019-01-26 17:11 ` Helge Deller
  2019-01-28  7:34   ` Christoph Hellwig
  8 siblings, 1 reply; 15+ messages in thread
From: Helge Deller @ 2019-01-26 17:11 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: James Bottomley, Helge Deller, linux-parisc, linux-kernel

* Christoph Hellwig <hch@lst.de>:
> Hi James and Helge,

Hi Christoph, 

> this series has a couple DMA-related cleanups for parisc.  The main aim
> is to move anything not required by drivers out of <asm/dma-mapping.h>,
> but I noticed a few related bits and cleaned them up as well.

Thanks for doing that!
I tested it. Your patches work, but you need the fixup below (0-day
testing complained as well).

With the one below, you may add
Tested-by: Helge Deller <deller@gmx.de>

Thanks!
Helge


diff --git a/drivers/parisc/hppb.c b/drivers/parisc/hppb.c
index 3b3481c..65a8148 100644
--- a/drivers/parisc/hppb.c
+++ b/drivers/parisc/hppb.c
@@ -20,6 +20,7 @@
 #include <linux/ioport.h>
 
 #include <asm/io.h>
+#include <asm/pci.h>
 #include <asm/hardware.h>
 #include <asm/parisc-device.h>
 

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: DMA-related cleanups for parisc
  2019-01-26 17:11 ` DMA-related cleanups for parisc Helge Deller
@ 2019-01-28  7:34   ` Christoph Hellwig
  2019-01-29 18:06     ` Helge Deller
  0 siblings, 1 reply; 15+ messages in thread
From: Christoph Hellwig @ 2019-01-28  7:34 UTC (permalink / raw)
  To: Helge Deller
  Cc: Christoph Hellwig, James Bottomley, linux-parisc, linux-kernel

On Sat, Jan 26, 2019 at 06:11:24PM +0100, Helge Deller wrote:
> Thanks for doing that!
> I tested it. Your patches work, but you need the fixup below (0-day
> testing complained as well).

I actually sent a v2 series since then which makes sure the new iommu.h
includes <linux/pci.h>, so that we don't rely on header ordering.

> 
> With the one below, you may add
> Tested-by: Helge Deller <deller@gmx.de>

While this series prepares for DMA layerer work it isn't urgent, so
if you want to pick it up through the parisc tree that is perfectly
fine with me.

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: DMA-related cleanups for parisc
  2019-01-28  7:34   ` Christoph Hellwig
@ 2019-01-29 18:06     ` Helge Deller
  2019-01-29 18:12       ` Christoph Hellwig
  0 siblings, 1 reply; 15+ messages in thread
From: Helge Deller @ 2019-01-29 18:06 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: James Bottomley, linux-parisc, linux-kernel

On 28.01.19 08:34, Christoph Hellwig wrote:
> On Sat, Jan 26, 2019 at 06:11:24PM +0100, Helge Deller wrote:
>> Thanks for doing that!
>> I tested it. Your patches work, but you need the fixup below (0-day
>> testing complained as well).
> 
> I actually sent a v2 series since then which makes sure the new iommu.h
> includes <linux/pci.h>, so that we don't rely on header ordering.

I don't see a v2 series. At least it wasn't sent to the parisc mailing list.
Can you point me to this series?
 
>> With the one below, you may add
>> Tested-by: Helge Deller <deller@gmx.de>
> 
> While this series prepares for DMA layerer work it isn't urgent, so
> if you want to pick it up through the parisc tree that is perfectly
> fine with me.

Yes, I can take it through the parisc tree then.

Helge

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: DMA-related cleanups for parisc
  2019-01-29 18:06     ` Helge Deller
@ 2019-01-29 18:12       ` Christoph Hellwig
  0 siblings, 0 replies; 15+ messages in thread
From: Christoph Hellwig @ 2019-01-29 18:12 UTC (permalink / raw)
  To: Helge Deller
  Cc: Christoph Hellwig, James Bottomley, linux-parisc, linux-kernel

On Tue, Jan 29, 2019 at 07:06:17PM +0100, Helge Deller wrote:
> On 28.01.19 08:34, Christoph Hellwig wrote:
> > On Sat, Jan 26, 2019 at 06:11:24PM +0100, Helge Deller wrote:
> >> Thanks for doing that!
> >> I tested it. Your patches work, but you need the fixup below (0-day
> >> testing complained as well).
> > 
> > I actually sent a v2 series since then which makes sure the new iommu.h
> > includes <linux/pci.h>, so that we don't rely on header ordering.
> 
> I don't see a v2 series. At least it wasn't sent to the parisc mailing list.
> Can you point me to this series?

Hmm, looks like I prepared it but didn't actually end up sending it,
as I can't find it either.  I'll send it now.

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [PATCH 2/8] parisc: move internal implementation details out of <asm/dma-mapping.h>
  2019-01-29 18:13 DMA-related cleanups for parisc v2 Christoph Hellwig
@ 2019-01-29 18:13 ` Christoph Hellwig
  0 siblings, 0 replies; 15+ messages in thread
From: Christoph Hellwig @ 2019-01-29 18:13 UTC (permalink / raw)
  To: James E.J. Bottomley, Helge Deller; +Cc: linux-parisc, linux-kernel

Move everything that is not required for the public facing DMA API out
of <asm/dma-mapping.h> and into a new drivers/parisc/iommu.h header.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 arch/parisc/include/asm/dma-mapping.h | 44 -----------------------
 drivers/parisc/ccio-dma.c             |  2 ++
 drivers/parisc/dino.c                 |  1 +
 drivers/parisc/eisa.c                 |  2 ++
 drivers/parisc/hppb.c                 |  2 ++
 drivers/parisc/iommu.h                | 51 +++++++++++++++++++++++++++
 drivers/parisc/lba_pci.c              |  2 ++
 drivers/parisc/sba_iommu.c            |  2 ++
 8 files changed, 62 insertions(+), 44 deletions(-)
 create mode 100644 drivers/parisc/iommu.h

diff --git a/arch/parisc/include/asm/dma-mapping.h b/arch/parisc/include/asm/dma-mapping.h
index f1bf5e297f1c..d5bd94247371 100644
--- a/arch/parisc/include/asm/dma-mapping.h
+++ b/arch/parisc/include/asm/dma-mapping.h
@@ -26,48 +26,4 @@ static inline const struct dma_map_ops *get_arch_dma_ops(struct bus_type *bus)
 	return hppa_dma_ops;
 }
 
-static inline void *
-parisc_walk_tree(struct device *dev)
-{
-	struct device *otherdev;
-	if(likely(dev->platform_data != NULL))
-		return dev->platform_data;
-	/* OK, just traverse the bus to find it */
-	for(otherdev = dev->parent; otherdev;
-	    otherdev = otherdev->parent) {
-		if(otherdev->platform_data) {
-			dev->platform_data = otherdev->platform_data;
-			break;
-		}
-	}
-	return dev->platform_data;
-}
-
-#define GET_IOC(dev) ({					\
-	void *__pdata = parisc_walk_tree(dev);		\
-	__pdata ? HBA_DATA(__pdata)->iommu : NULL;	\
-})
-
-#ifdef CONFIG_IOMMU_CCIO
-struct parisc_device;
-struct ioc;
-void * ccio_get_iommu(const struct parisc_device *dev);
-int ccio_request_resource(const struct parisc_device *dev,
-		struct resource *res);
-int ccio_allocate_resource(const struct parisc_device *dev,
-		struct resource *res, unsigned long size,
-		unsigned long min, unsigned long max, unsigned long align);
-#else /* !CONFIG_IOMMU_CCIO */
-#define ccio_get_iommu(dev) NULL
-#define ccio_request_resource(dev, res) insert_resource(&iomem_resource, res)
-#define ccio_allocate_resource(dev, res, size, min, max, align) \
-		allocate_resource(&iomem_resource, res, size, min, max, \
-				align, NULL, NULL)
-#endif /* !CONFIG_IOMMU_CCIO */
-
-#ifdef CONFIG_IOMMU_SBA
-struct parisc_device;
-void * sba_get_iommu(struct parisc_device *dev);
-#endif
-
 #endif
diff --git a/drivers/parisc/ccio-dma.c b/drivers/parisc/ccio-dma.c
index 8d2fc84119c6..b17e81cf77d5 100644
--- a/drivers/parisc/ccio-dma.c
+++ b/drivers/parisc/ccio-dma.c
@@ -55,6 +55,8 @@
 #include <asm/hardware.h>       /* for register_module() */
 #include <asm/parisc-device.h>
 
+#include "iommu.h"
+
 /* 
 ** Choose "ccio" since that's what HP-UX calls it.
 ** Make it easier for folks to migrate from one to the other :^)
diff --git a/drivers/parisc/dino.c b/drivers/parisc/dino.c
index dfeea458a789..6f348c75687c 100644
--- a/drivers/parisc/dino.c
+++ b/drivers/parisc/dino.c
@@ -59,6 +59,7 @@
 #include <asm/hardware.h>
 
 #include "gsc.h"
+#include "iommu.h"
 
 #undef DINO_DEBUG
 
diff --git a/drivers/parisc/eisa.c b/drivers/parisc/eisa.c
index 9ff434f354bd..5657a1d3eb2b 100644
--- a/drivers/parisc/eisa.c
+++ b/drivers/parisc/eisa.c
@@ -45,6 +45,8 @@
 #include <asm/eisa_bus.h>
 #include <asm/eisa_eeprom.h>
 
+#include "iommu.h"
+
 #if 0
 #define EISA_DBG(msg, arg...) printk(KERN_DEBUG "eisa: " msg, ## arg)
 #else
diff --git a/drivers/parisc/hppb.c b/drivers/parisc/hppb.c
index ebc7b617e5d0..3b3481c0d81d 100644
--- a/drivers/parisc/hppb.c
+++ b/drivers/parisc/hppb.c
@@ -23,6 +23,8 @@
 #include <asm/hardware.h>
 #include <asm/parisc-device.h>
 
+#include "iommu.h"
+
 struct hppb_card {
 	unsigned long hpa;
 	struct resource mmio_region;
diff --git a/drivers/parisc/iommu.h b/drivers/parisc/iommu.h
new file mode 100644
index 000000000000..5a38b635e963
--- /dev/null
+++ b/drivers/parisc/iommu.h
@@ -0,0 +1,51 @@
+#ifndef _IOMMU_H
+#define _IOMMU_H 1
+
+#include <linux/pci.h>
+
+struct parisc_device;
+struct ioc;
+
+static inline void *parisc_walk_tree(struct device *dev)
+{
+	struct device *otherdev;
+
+	if (likely(dev->platform_data))
+		return dev->platform_data;
+
+	/* OK, just traverse the bus to find it */
+	for (otherdev = dev->parent;
+	     otherdev;
+	     otherdev = otherdev->parent) {
+		if (otherdev->platform_data) {
+			dev->platform_data = otherdev->platform_data;
+			break;
+		}
+	}
+
+	return dev->platform_data;
+}
+
+#define GET_IOC(dev) ({					\
+	void *__pdata = parisc_walk_tree(dev);		\
+	__pdata ? HBA_DATA(__pdata)->iommu : NULL;	\
+})
+
+#ifdef CONFIG_IOMMU_CCIO
+void *ccio_get_iommu(const struct parisc_device *dev);
+int ccio_request_resource(const struct parisc_device *dev,
+		struct resource *res);
+int ccio_allocate_resource(const struct parisc_device *dev,
+		struct resource *res, unsigned long size,
+		unsigned long min, unsigned long max, unsigned long align);
+#else /* !CONFIG_IOMMU_CCIO */
+#define ccio_get_iommu(dev) NULL
+#define ccio_request_resource(dev, res) insert_resource(&iomem_resource, res)
+#define ccio_allocate_resource(dev, res, size, min, max, align) \
+		allocate_resource(&iomem_resource, res, size, min, max, \
+				align, NULL, NULL)
+#endif /* !CONFIG_IOMMU_CCIO */
+
+void *sba_get_iommu(struct parisc_device *dev);
+
+#endif /* _IOMMU_H */
diff --git a/drivers/parisc/lba_pci.c b/drivers/parisc/lba_pci.c
index 69bd98421eb1..63e9bc6d18de 100644
--- a/drivers/parisc/lba_pci.c
+++ b/drivers/parisc/lba_pci.c
@@ -49,6 +49,8 @@
 #include <asm/parisc-device.h>
 #include <asm/io.h>		/* read/write stuff */
 
+#include "iommu.h"
+
 #undef DEBUG_LBA	/* general stuff */
 #undef DEBUG_LBA_PORT	/* debug I/O Port access */
 #undef DEBUG_LBA_CFG	/* debug Config Space Access (ie PCI Bus walk) */
diff --git a/drivers/parisc/sba_iommu.c b/drivers/parisc/sba_iommu.c
index 42172eb32235..afaf8e6aefe6 100644
--- a/drivers/parisc/sba_iommu.c
+++ b/drivers/parisc/sba_iommu.c
@@ -49,6 +49,8 @@
 #include <asm/pdcpat.h>		/* for is_pdc_pat() */
 #include <asm/parisc-device.h>
 
+#include "iommu.h"
+
 #define MODULE_NAME "SBA"
 
 /*
-- 
2.20.1


^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, back to index

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-01-14 11:23 DMA-related cleanups for parisc Christoph Hellwig
2019-01-14 11:23 ` [PATCH 1/8] parisc: don't include <asm/cacheflush.h> in <asm/dma-mapping.h> Christoph Hellwig
2019-01-14 11:23 ` [PATCH 2/8] parisc: move internal implementation details out of <asm/dma-mapping.h> Christoph Hellwig
2019-01-14 11:23 ` [PATCH 3/8] parisc: turn GET_IOC into an inline function Christoph Hellwig
2019-01-14 23:32   ` kbuild test robot
2019-01-14 11:23 ` [PATCH 4/8] parisc: properly type the iommu field in struct pci_hba_data Christoph Hellwig
2019-01-14 11:23 ` [PATCH 5/8] parisc: properly type the return value of parisc_walk_tree Christoph Hellwig
2019-01-14 11:23 ` [PATCH 6/8] parisc/dino: use container_of in DINO_DEV Christoph Hellwig
2019-01-14 11:23 ` [PATCH 7/8] parisc/lba_pci: use container_of in LBA_DEV Christoph Hellwig
2019-01-14 11:23 ` [PATCH 8/8] parisc: remove the HBA_DATA macro Christoph Hellwig
2019-01-26 17:11 ` DMA-related cleanups for parisc Helge Deller
2019-01-28  7:34   ` Christoph Hellwig
2019-01-29 18:06     ` Helge Deller
2019-01-29 18:12       ` Christoph Hellwig
2019-01-29 18:13 DMA-related cleanups for parisc v2 Christoph Hellwig
2019-01-29 18:13 ` [PATCH 2/8] parisc: move internal implementation details out of <asm/dma-mapping.h> Christoph Hellwig

Linux-parisc archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-parisc/0 linux-parisc/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-parisc linux-parisc/ https://lore.kernel.org/linux-parisc \
		linux-parisc@vger.kernel.org linux-parisc@archiver.kernel.org
	public-inbox-index linux-parisc


Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-parisc


AGPL code for this site: git clone https://public-inbox.org/ public-inbox