* [PATCH] parisc: DMA API: return error instead of BUG_ON for dma ops on non dma devs
@ 2017-07-03 8:38 Thomas Bogendoerfer
2017-07-03 14:41 ` Helge Deller
0 siblings, 1 reply; 6+ messages in thread
From: Thomas Bogendoerfer @ 2017-07-03 8:38 UTC (permalink / raw)
To: jejb, deller, linux-parisc, linux-kernel
Enabling parport pc driver on a B2600 (and probably other 64bit PARISC
systems) produced following BUG:
CPU: 0 PID: 1 Comm: swapper Not tainted 4.12.0-rc5-30198-g1132d5e #156
task: 000000009e050000 task.stack: 000000009e04c000
YZrvWESTHLNXBCVMcbcbcbcbOGFRQPDI
PSW: 00001000000001101111111100001111 Not tainted
r00-03 000000ff0806ff0f 000000009e04c990 0000000040871b78 000000009e04cac0
r04-07 0000000040c14de0 ffffffffffffffff 000000009e07f098 000000009d82d200
r08-11 000000009d82d210 0000000000000378 0000000000000000 0000000040c345e0
r12-15 0000000000000005 0000000040c345e0 0000000000000000 0000000040c9d5e0
r16-19 0000000040c345e0 00000000f00001c4 00000000f00001bc 0000000000000061
r20-23 000000009e04ce28 0000000000000010 0000000000000010 0000000040b89e40
r24-27 0000000000000003 0000000000ffffff 000000009d82d210 0000000040c14de0
r28-31 0000000000000000 000000009e04ca90 000000009e04cb40 0000000000000000
sr00-03 0000000000000000 0000000000000000 0000000000000000 0000000000000000
sr04-07 0000000000000000 0000000000000000 0000000000000000 0000000000000000
IASQ: 0000000000000000 0000000000000000 IAOQ: 00000000404aece0 00000000404aece4
IIR: 03ffe01f ISR: 0000000010340000 IOR: 000001781304cac8
CPU: 0 CR30: 000000009e04c000 CR31: 00000000e2976de2
ORIG_R28: 0000000000000200
IAOQ[0]: sba_dma_supported+0x80/0xd0
IAOQ[1]: sba_dma_supported+0x84/0xd0
RP(r2): parport_pc_probe_port+0x178/0x1200
Cause is a call to dma_coerce_mask_and_coherenet in parport_pc_probe_port,
which PARISC DMA API doesn't handle very nicely. This commit gives back
DMA_ERROR_CODE for DMA API calls, if device isn't capable of DMA
transaction.
Signed-off-by: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
---
arch/parisc/include/asm/dma-mapping.h | 11 +++++++----
drivers/parisc/ccio-dma.c | 12 ++++++++++++
drivers/parisc/dino.c | 5 ++++-
drivers/parisc/lba_pci.c | 6 ++++--
drivers/parisc/sba_iommu.c | 14 ++++++++++++++
5 files changed, 41 insertions(+), 7 deletions(-)
diff --git a/arch/parisc/include/asm/dma-mapping.h b/arch/parisc/include/asm/dma-mapping.h
index 5404c6a..9a2a895 100644
--- a/arch/parisc/include/asm/dma-mapping.h
+++ b/arch/parisc/include/asm/dma-mapping.h
@@ -20,6 +20,8 @@
** flush/purge and allocate "regular" cacheable pages for everything.
*/
+#define DMA_ERROR_CODE (~(dma_addr_t)0)
+
#ifdef CONFIG_PA11
extern const struct dma_map_ops pcxl_dma_ops;
extern const struct dma_map_ops pcx_dma_ops;
@@ -54,12 +56,13 @@ parisc_walk_tree(struct device *dev)
break;
}
}
- BUG_ON(!dev->platform_data);
return dev->platform_data;
}
-
-#define GET_IOC(dev) (HBA_DATA(parisc_walk_tree(dev))->iommu)
-
+
+#define GET_IOC(dev) ({ \
+ void *__pdata = parisc_walk_tree(dev); \
+ __pdata ? HBA_DATA(__pdata)->iommu : NULL; \
+})
#ifdef CONFIG_IOMMU_CCIO
struct parisc_device;
diff --git a/drivers/parisc/ccio-dma.c b/drivers/parisc/ccio-dma.c
index e32ca2e..56c93f0 100644
--- a/drivers/parisc/ccio-dma.c
+++ b/drivers/parisc/ccio-dma.c
@@ -741,6 +741,8 @@ ccio_map_single(struct device *dev, void *addr, size_t size,
BUG_ON(!dev);
ioc = GET_IOC(dev);
+ if (!ioc)
+ return DMA_ERROR_CODE;
BUG_ON(size <= 0);
@@ -814,6 +816,10 @@ ccio_unmap_page(struct device *dev, dma_addr_t iova, size_t size,
BUG_ON(!dev);
ioc = GET_IOC(dev);
+ if (!ioc) {
+ WARN_ON(!ioc);
+ return;
+ }
DBG_RUN("%s() iovp 0x%lx/%x\n",
__func__, (long)iova, size);
@@ -918,6 +924,8 @@ ccio_map_sg(struct device *dev, struct scatterlist *sglist, int nents,
BUG_ON(!dev);
ioc = GET_IOC(dev);
+ if (!ioc)
+ return 0;
DBG_RUN_SG("%s() START %d entries\n", __func__, nents);
@@ -990,6 +998,10 @@ ccio_unmap_sg(struct device *dev, struct scatterlist *sglist, int nents,
BUG_ON(!dev);
ioc = GET_IOC(dev);
+ if (!ioc) {
+ WARN_ON(!ioc);
+ return;
+ }
DBG_RUN_SG("%s() START %d entries, %p,%x\n",
__func__, nents, sg_virt(sglist), sglist->length);
diff --git a/drivers/parisc/dino.c b/drivers/parisc/dino.c
index 1133b5c..5c63b92 100644
--- a/drivers/parisc/dino.c
+++ b/drivers/parisc/dino.c
@@ -154,7 +154,10 @@ struct dino_device
};
/* Looks nice and keeps the compiler happy */
-#define DINO_DEV(d) ((struct dino_device *) d)
+#define DINO_DEV(d) ({ \
+ void *__pdata = d; \
+ BUG_ON(!__pdata); \
+ (struct dino_device *)__pdata; })
/*
diff --git a/drivers/parisc/lba_pci.c b/drivers/parisc/lba_pci.c
index 2ec2aef..bc286cb 100644
--- a/drivers/parisc/lba_pci.c
+++ b/drivers/parisc/lba_pci.c
@@ -111,8 +111,10 @@ static u32 lba_t32;
/* Looks nice and keeps the compiler happy */
-#define LBA_DEV(d) ((struct lba_device *) (d))
-
+#define LBA_DEV(d) ({ \
+ void *__pdata = d; \
+ BUG_ON(!__pdata); \
+ (struct lba_device *)__pdata; })
/*
** Only allow 8 subsidiary busses per LBA
diff --git a/drivers/parisc/sba_iommu.c b/drivers/parisc/sba_iommu.c
index 33385e5..87ad5fd 100644
--- a/drivers/parisc/sba_iommu.c
+++ b/drivers/parisc/sba_iommu.c
@@ -691,6 +691,8 @@ static int sba_dma_supported( struct device *dev, u64 mask)
return 0;
ioc = GET_IOC(dev);
+ if (!ioc)
+ return 0;
/*
* check if mask is >= than the current max IO Virt Address
@@ -722,6 +724,8 @@ sba_map_single(struct device *dev, void *addr, size_t size,
int pide;
ioc = GET_IOC(dev);
+ if (!ioc)
+ return DMA_ERROR_CODE;
/* save offset bits */
offset = ((dma_addr_t) (long) addr) & ~IOVP_MASK;
@@ -813,6 +817,10 @@ sba_unmap_page(struct device *dev, dma_addr_t iova, size_t size,
DBG_RUN("%s() iovp 0x%lx/%x\n", __func__, (long) iova, size);
ioc = GET_IOC(dev);
+ if (!ioc) {
+ WARN_ON(!ioc);
+ return;
+ }
offset = iova & ~IOVP_MASK;
iova ^= offset; /* clear offset bits */
size += offset;
@@ -952,6 +960,8 @@ sba_map_sg(struct device *dev, struct scatterlist *sglist, int nents,
DBG_RUN_SG("%s() START %d entries\n", __func__, nents);
ioc = GET_IOC(dev);
+ if (!ioc)
+ return 0;
/* Fast path single entry scatterlists. */
if (nents == 1) {
@@ -1037,6 +1047,10 @@ sba_unmap_sg(struct device *dev, struct scatterlist *sglist, int nents,
__func__, nents, sg_virt(sglist), sglist->length);
ioc = GET_IOC(dev);
+ if (!ioc) {
+ WARN_ON(!ioc);
+ return;
+ }
#ifdef SBA_COLLECT_STATS
ioc->usg_calls++;
--
2.1.4
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] parisc: DMA API: return error instead of BUG_ON for dma ops on non dma devs
2017-07-03 8:38 [PATCH] parisc: DMA API: return error instead of BUG_ON for dma ops on non dma devs Thomas Bogendoerfer
@ 2017-07-03 14:41 ` Helge Deller
2017-07-05 18:57 ` Christoph Hellwig
0 siblings, 1 reply; 6+ messages in thread
From: Helge Deller @ 2017-07-03 14:41 UTC (permalink / raw)
To: Thomas Bogendoerfer, jejb, linux-parisc, linux-kernel
On 03.07.2017 10:38, Thomas Bogendoerfer wrote:
> Enabling parport pc driver on a B2600 (and probably other 64bit PARISC
> systems) produced following BUG:
>
> CPU: 0 PID: 1 Comm: swapper Not tainted 4.12.0-rc5-30198-g1132d5e #156
> task: 000000009e050000 task.stack: 000000009e04c000
>
> YZrvWESTHLNXBCVMcbcbcbcbOGFRQPDI
> PSW: 00001000000001101111111100001111 Not tainted
> r00-03 000000ff0806ff0f 000000009e04c990 0000000040871b78 000000009e04cac0
> r04-07 0000000040c14de0 ffffffffffffffff 000000009e07f098 000000009d82d200
> r08-11 000000009d82d210 0000000000000378 0000000000000000 0000000040c345e0
> r12-15 0000000000000005 0000000040c345e0 0000000000000000 0000000040c9d5e0
> r16-19 0000000040c345e0 00000000f00001c4 00000000f00001bc 0000000000000061
> r20-23 000000009e04ce28 0000000000000010 0000000000000010 0000000040b89e40
> r24-27 0000000000000003 0000000000ffffff 000000009d82d210 0000000040c14de0
> r28-31 0000000000000000 000000009e04ca90 000000009e04cb40 0000000000000000
> sr00-03 0000000000000000 0000000000000000 0000000000000000 0000000000000000
> sr04-07 0000000000000000 0000000000000000 0000000000000000 0000000000000000
>
> IASQ: 0000000000000000 0000000000000000 IAOQ: 00000000404aece0 00000000404aece4
> IIR: 03ffe01f ISR: 0000000010340000 IOR: 000001781304cac8
> CPU: 0 CR30: 000000009e04c000 CR31: 00000000e2976de2
> ORIG_R28: 0000000000000200
> IAOQ[0]: sba_dma_supported+0x80/0xd0
> IAOQ[1]: sba_dma_supported+0x84/0xd0
> RP(r2): parport_pc_probe_port+0x178/0x1200
>
> Cause is a call to dma_coerce_mask_and_coherenet in parport_pc_probe_port,
> which PARISC DMA API doesn't handle very nicely. This commit gives back
> DMA_ERROR_CODE for DMA API calls, if device isn't capable of DMA
> transaction.
>
> Signed-off-by: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
I didn't had parport_pc enabled on my c3000 so I never saw it crashing.
After enabling parport_pc it crashes the same way as you describe.
I tested with kernel 4.9.35.
Thanks!
Acked-by: Helge Deller <deller@gmx.de>
> ---
> arch/parisc/include/asm/dma-mapping.h | 11 +++++++----
> drivers/parisc/ccio-dma.c | 12 ++++++++++++
> drivers/parisc/dino.c | 5 ++++-
> drivers/parisc/lba_pci.c | 6 ++++--
> drivers/parisc/sba_iommu.c | 14 ++++++++++++++
> 5 files changed, 41 insertions(+), 7 deletions(-)
>
> diff --git a/arch/parisc/include/asm/dma-mapping.h b/arch/parisc/include/asm/dma-mapping.h
> index 5404c6a..9a2a895 100644
> --- a/arch/parisc/include/asm/dma-mapping.h
> +++ b/arch/parisc/include/asm/dma-mapping.h
> @@ -20,6 +20,8 @@
> ** flush/purge and allocate "regular" cacheable pages for everything.
> */
>
> +#define DMA_ERROR_CODE (~(dma_addr_t)0)
> +
> #ifdef CONFIG_PA11
> extern const struct dma_map_ops pcxl_dma_ops;
> extern const struct dma_map_ops pcx_dma_ops;
> @@ -54,12 +56,13 @@ parisc_walk_tree(struct device *dev)
> break;
> }
> }
> - BUG_ON(!dev->platform_data);
> return dev->platform_data;
> }
> -
> -#define GET_IOC(dev) (HBA_DATA(parisc_walk_tree(dev))->iommu)
> -
> +
> +#define GET_IOC(dev) ({ \
> + void *__pdata = parisc_walk_tree(dev); \
> + __pdata ? HBA_DATA(__pdata)->iommu : NULL; \
> +})
>
> #ifdef CONFIG_IOMMU_CCIO
> struct parisc_device;
> diff --git a/drivers/parisc/ccio-dma.c b/drivers/parisc/ccio-dma.c
> index e32ca2e..56c93f0 100644
> --- a/drivers/parisc/ccio-dma.c
> +++ b/drivers/parisc/ccio-dma.c
> @@ -741,6 +741,8 @@ ccio_map_single(struct device *dev, void *addr, size_t size,
>
> BUG_ON(!dev);
> ioc = GET_IOC(dev);
> + if (!ioc)
> + return DMA_ERROR_CODE;
>
> BUG_ON(size <= 0);
>
> @@ -814,6 +816,10 @@ ccio_unmap_page(struct device *dev, dma_addr_t iova, size_t size,
>
> BUG_ON(!dev);
> ioc = GET_IOC(dev);
> + if (!ioc) {
> + WARN_ON(!ioc);
> + return;
> + }
>
> DBG_RUN("%s() iovp 0x%lx/%x\n",
> __func__, (long)iova, size);
> @@ -918,6 +924,8 @@ ccio_map_sg(struct device *dev, struct scatterlist *sglist, int nents,
>
> BUG_ON(!dev);
> ioc = GET_IOC(dev);
> + if (!ioc)
> + return 0;
>
> DBG_RUN_SG("%s() START %d entries\n", __func__, nents);
>
> @@ -990,6 +998,10 @@ ccio_unmap_sg(struct device *dev, struct scatterlist *sglist, int nents,
>
> BUG_ON(!dev);
> ioc = GET_IOC(dev);
> + if (!ioc) {
> + WARN_ON(!ioc);
> + return;
> + }
>
> DBG_RUN_SG("%s() START %d entries, %p,%x\n",
> __func__, nents, sg_virt(sglist), sglist->length);
> diff --git a/drivers/parisc/dino.c b/drivers/parisc/dino.c
> index 1133b5c..5c63b92 100644
> --- a/drivers/parisc/dino.c
> +++ b/drivers/parisc/dino.c
> @@ -154,7 +154,10 @@ struct dino_device
> };
>
> /* Looks nice and keeps the compiler happy */
> -#define DINO_DEV(d) ((struct dino_device *) d)
> +#define DINO_DEV(d) ({ \
> + void *__pdata = d; \
> + BUG_ON(!__pdata); \
> + (struct dino_device *)__pdata; })
>
>
> /*
> diff --git a/drivers/parisc/lba_pci.c b/drivers/parisc/lba_pci.c
> index 2ec2aef..bc286cb 100644
> --- a/drivers/parisc/lba_pci.c
> +++ b/drivers/parisc/lba_pci.c
> @@ -111,8 +111,10 @@ static u32 lba_t32;
>
>
> /* Looks nice and keeps the compiler happy */
> -#define LBA_DEV(d) ((struct lba_device *) (d))
> -
> +#define LBA_DEV(d) ({ \
> + void *__pdata = d; \
> + BUG_ON(!__pdata); \
> + (struct lba_device *)__pdata; })
>
> /*
> ** Only allow 8 subsidiary busses per LBA
> diff --git a/drivers/parisc/sba_iommu.c b/drivers/parisc/sba_iommu.c
> index 33385e5..87ad5fd 100644
> --- a/drivers/parisc/sba_iommu.c
> +++ b/drivers/parisc/sba_iommu.c
> @@ -691,6 +691,8 @@ static int sba_dma_supported( struct device *dev, u64 mask)
> return 0;
>
> ioc = GET_IOC(dev);
> + if (!ioc)
> + return 0;
>
> /*
> * check if mask is >= than the current max IO Virt Address
> @@ -722,6 +724,8 @@ sba_map_single(struct device *dev, void *addr, size_t size,
> int pide;
>
> ioc = GET_IOC(dev);
> + if (!ioc)
> + return DMA_ERROR_CODE;
>
> /* save offset bits */
> offset = ((dma_addr_t) (long) addr) & ~IOVP_MASK;
> @@ -813,6 +817,10 @@ sba_unmap_page(struct device *dev, dma_addr_t iova, size_t size,
> DBG_RUN("%s() iovp 0x%lx/%x\n", __func__, (long) iova, size);
>
> ioc = GET_IOC(dev);
> + if (!ioc) {
> + WARN_ON(!ioc);
> + return;
> + }
> offset = iova & ~IOVP_MASK;
> iova ^= offset; /* clear offset bits */
> size += offset;
> @@ -952,6 +960,8 @@ sba_map_sg(struct device *dev, struct scatterlist *sglist, int nents,
> DBG_RUN_SG("%s() START %d entries\n", __func__, nents);
>
> ioc = GET_IOC(dev);
> + if (!ioc)
> + return 0;
>
> /* Fast path single entry scatterlists. */
> if (nents == 1) {
> @@ -1037,6 +1047,10 @@ sba_unmap_sg(struct device *dev, struct scatterlist *sglist, int nents,
> __func__, nents, sg_virt(sglist), sglist->length);
>
> ioc = GET_IOC(dev);
> + if (!ioc) {
> + WARN_ON(!ioc);
> + return;
> + }
>
> #ifdef SBA_COLLECT_STATS
> ioc->usg_calls++;
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] parisc: DMA API: return error instead of BUG_ON for dma ops on non dma devs
2017-07-03 14:41 ` Helge Deller
@ 2017-07-05 18:57 ` Christoph Hellwig
2017-07-05 19:36 ` Helge Deller
0 siblings, 1 reply; 6+ messages in thread
From: Christoph Hellwig @ 2017-07-05 18:57 UTC (permalink / raw)
To: Helge Deller; +Cc: Thomas Bogendoerfer, jejb, linux-parisc, linux-kernel
I've got a tree pending that removes DMA_ERROR_CODE, and it's been
in linux-next for a while.
While this won't compile-time conflict with this patch and will
basically revert the effect.
Can you please test the patch below and send it to Linus ASAP so that
I can send the pull request for the dma-mapping tree?
---
>From 85942d54e2f0ad5f4b4e074ce2e271be17b31274 Mon Sep 17 00:00:00 2001
From: Christoph Hellwig <hch@lst.de>
Date: Tue, 4 Jul 2017 19:55:06 -0700
Subject: parisc: ->mapping_error
DMA_ERROR_CODE already went away in linux-next, but parisc unfortunately
added a new instance of it without any review as far as I can tell.
Move the two iommu drivers to report errors through ->mapping_error.
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
arch/parisc/include/asm/dma-mapping.h | 2 --
drivers/parisc/ccio-dma.c | 10 +++++++++-
drivers/parisc/sba_iommu.c | 10 +++++++++-
3 files changed, 18 insertions(+), 4 deletions(-)
diff --git a/arch/parisc/include/asm/dma-mapping.h b/arch/parisc/include/asm/dma-mapping.h
index 9a2a8956a695..2b16282add69 100644
--- a/arch/parisc/include/asm/dma-mapping.h
+++ b/arch/parisc/include/asm/dma-mapping.h
@@ -20,8 +20,6 @@
** flush/purge and allocate "regular" cacheable pages for everything.
*/
-#define DMA_ERROR_CODE (~(dma_addr_t)0)
-
#ifdef CONFIG_PA11
extern const struct dma_map_ops pcxl_dma_ops;
extern const struct dma_map_ops pcx_dma_ops;
diff --git a/drivers/parisc/ccio-dma.c b/drivers/parisc/ccio-dma.c
index 56c93f096de9..6aa1e7f6672f 100644
--- a/drivers/parisc/ccio-dma.c
+++ b/drivers/parisc/ccio-dma.c
@@ -110,6 +110,8 @@
#define CMD_TLB_DIRECT_WRITE 35 /* IO_COMMAND for I/O TLB Writes */
#define CMD_TLB_PURGE 33 /* IO_COMMAND to Purge I/O TLB entry */
+#define CCIO_MAPPING_ERROR (~(dma_addr_t)0)
+
struct ioa_registers {
/* Runway Supervisory Set */
int32_t unused1[12];
@@ -742,7 +744,7 @@ ccio_map_single(struct device *dev, void *addr, size_t size,
BUG_ON(!dev);
ioc = GET_IOC(dev);
if (!ioc)
- return DMA_ERROR_CODE;
+ return CCIO_MAPPING_ERROR;
BUG_ON(size <= 0);
@@ -1023,6 +1025,11 @@ ccio_unmap_sg(struct device *dev, struct scatterlist *sglist, int nents,
DBG_RUN_SG("%s() DONE (nents %d)\n", __func__, nents);
}
+static int ccio_mapping_error(struct device *dev, dma_addr_t dma_addr)
+{
+ return dma_addr == CCIO_MAPPING_ERROR;
+}
+
static const struct dma_map_ops ccio_ops = {
.dma_supported = ccio_dma_supported,
.alloc = ccio_alloc,
@@ -1031,6 +1038,7 @@ static const struct dma_map_ops ccio_ops = {
.unmap_page = ccio_unmap_page,
.map_sg = ccio_map_sg,
.unmap_sg = ccio_unmap_sg,
+ .mapping_error = ccio_mapping_error,
};
#ifdef CONFIG_PROC_FS
diff --git a/drivers/parisc/sba_iommu.c b/drivers/parisc/sba_iommu.c
index 87ad5fd6a7a2..4086f79d58d5 100644
--- a/drivers/parisc/sba_iommu.c
+++ b/drivers/parisc/sba_iommu.c
@@ -93,6 +93,8 @@
#define DEFAULT_DMA_HINT_REG 0
+#define SBA_MAPPING_ERROR (~(dma_addr_t)0)
+
struct sba_device *sba_list;
EXPORT_SYMBOL_GPL(sba_list);
@@ -725,7 +727,7 @@ sba_map_single(struct device *dev, void *addr, size_t size,
ioc = GET_IOC(dev);
if (!ioc)
- return DMA_ERROR_CODE;
+ return SBA_MAPPING_ERROR;
/* save offset bits */
offset = ((dma_addr_t) (long) addr) & ~IOVP_MASK;
@@ -1083,6 +1085,11 @@ sba_unmap_sg(struct device *dev, struct scatterlist *sglist, int nents,
}
+static int sba_mapping_error(struct device *dev, dma_addr_t dma_addr)
+{
+ return dma_addr == SBA_MAPPING_ERROR;
+}
+
static const struct dma_map_ops sba_ops = {
.dma_supported = sba_dma_supported,
.alloc = sba_alloc,
@@ -1091,6 +1098,7 @@ static const struct dma_map_ops sba_ops = {
.unmap_page = sba_unmap_page,
.map_sg = sba_map_sg,
.unmap_sg = sba_unmap_sg,
+ .mapping_error = sba_mapping_error,
};
--
2.11.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] parisc: DMA API: return error instead of BUG_ON for dma ops on non dma devs
2017-07-05 18:57 ` Christoph Hellwig
@ 2017-07-05 19:36 ` Helge Deller
2017-07-05 20:33 ` Christoph Hellwig
0 siblings, 1 reply; 6+ messages in thread
From: Helge Deller @ 2017-07-05 19:36 UTC (permalink / raw)
To: Christoph Hellwig; +Cc: Thomas Bogendoerfer, jejb, linux-parisc, linux-kernel
Hi Christoph,
On 05.07.2017 20:57, Christoph Hellwig wrote:
> I've got a tree pending that removes DMA_ERROR_CODE, and it's been
> in linux-next for a while.
I had the parisc patch in for-next as well and didn't received
any warnings.
> While this won't compile-time conflict with this patch and will
> basically revert the effect.
>
> Can you please test the patch below and send it to Linus ASAP so that
> I can send the pull request for the dma-mapping tree?
I'll do that now.
> ---
> From 85942d54e2f0ad5f4b4e074ce2e271be17b31274 Mon Sep 17 00:00:00 2001
> From: Christoph Hellwig <hch@lst.de>
> Date: Tue, 4 Jul 2017 19:55:06 -0700
> Subject: parisc: ->mapping_error
>
> DMA_ERROR_CODE already went away in linux-next, but parisc unfortunately
> added a new instance of it without any review as far as I can tell.
Can we please change this to something like
"Prepare parisc to get rid of DMA_ERROR_CODE tree-wide" ?
It's somewhat more neutral.
Helge
>
> Move the two iommu drivers to report errors through ->mapping_error.
>
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---
> arch/parisc/include/asm/dma-mapping.h | 2 --
> drivers/parisc/ccio-dma.c | 10 +++++++++-
> drivers/parisc/sba_iommu.c | 10 +++++++++-
> 3 files changed, 18 insertions(+), 4 deletions(-)
>
> diff --git a/arch/parisc/include/asm/dma-mapping.h b/arch/parisc/include/asm/dma-mapping.h
> index 9a2a8956a695..2b16282add69 100644
> --- a/arch/parisc/include/asm/dma-mapping.h
> +++ b/arch/parisc/include/asm/dma-mapping.h
> @@ -20,8 +20,6 @@
> ** flush/purge and allocate "regular" cacheable pages for everything.
> */
>
> -#define DMA_ERROR_CODE (~(dma_addr_t)0)
> -
> #ifdef CONFIG_PA11
> extern const struct dma_map_ops pcxl_dma_ops;
> extern const struct dma_map_ops pcx_dma_ops;
> diff --git a/drivers/parisc/ccio-dma.c b/drivers/parisc/ccio-dma.c
> index 56c93f096de9..6aa1e7f6672f 100644
> --- a/drivers/parisc/ccio-dma.c
> +++ b/drivers/parisc/ccio-dma.c
> @@ -110,6 +110,8 @@
> #define CMD_TLB_DIRECT_WRITE 35 /* IO_COMMAND for I/O TLB Writes */
> #define CMD_TLB_PURGE 33 /* IO_COMMAND to Purge I/O TLB entry */
>
> +#define CCIO_MAPPING_ERROR (~(dma_addr_t)0)
> +
> struct ioa_registers {
> /* Runway Supervisory Set */
> int32_t unused1[12];
> @@ -742,7 +744,7 @@ ccio_map_single(struct device *dev, void *addr, size_t size,
> BUG_ON(!dev);
> ioc = GET_IOC(dev);
> if (!ioc)
> - return DMA_ERROR_CODE;
> + return CCIO_MAPPING_ERROR;
>
> BUG_ON(size <= 0);
>
> @@ -1023,6 +1025,11 @@ ccio_unmap_sg(struct device *dev, struct scatterlist *sglist, int nents,
> DBG_RUN_SG("%s() DONE (nents %d)\n", __func__, nents);
> }
>
> +static int ccio_mapping_error(struct device *dev, dma_addr_t dma_addr)
> +{
> + return dma_addr == CCIO_MAPPING_ERROR;
> +}
> +
> static const struct dma_map_ops ccio_ops = {
> .dma_supported = ccio_dma_supported,
> .alloc = ccio_alloc,
> @@ -1031,6 +1038,7 @@ static const struct dma_map_ops ccio_ops = {
> .unmap_page = ccio_unmap_page,
> .map_sg = ccio_map_sg,
> .unmap_sg = ccio_unmap_sg,
> + .mapping_error = ccio_mapping_error,
> };
>
> #ifdef CONFIG_PROC_FS
> diff --git a/drivers/parisc/sba_iommu.c b/drivers/parisc/sba_iommu.c
> index 87ad5fd6a7a2..4086f79d58d5 100644
> --- a/drivers/parisc/sba_iommu.c
> +++ b/drivers/parisc/sba_iommu.c
> @@ -93,6 +93,8 @@
>
> #define DEFAULT_DMA_HINT_REG 0
>
> +#define SBA_MAPPING_ERROR (~(dma_addr_t)0)
> +
> struct sba_device *sba_list;
> EXPORT_SYMBOL_GPL(sba_list);
>
> @@ -725,7 +727,7 @@ sba_map_single(struct device *dev, void *addr, size_t size,
>
> ioc = GET_IOC(dev);
> if (!ioc)
> - return DMA_ERROR_CODE;
> + return SBA_MAPPING_ERROR;
>
> /* save offset bits */
> offset = ((dma_addr_t) (long) addr) & ~IOVP_MASK;
> @@ -1083,6 +1085,11 @@ sba_unmap_sg(struct device *dev, struct scatterlist *sglist, int nents,
>
> }
>
> +static int sba_mapping_error(struct device *dev, dma_addr_t dma_addr)
> +{
> + return dma_addr == SBA_MAPPING_ERROR;
> +}
> +
> static const struct dma_map_ops sba_ops = {
> .dma_supported = sba_dma_supported,
> .alloc = sba_alloc,
> @@ -1091,6 +1098,7 @@ static const struct dma_map_ops sba_ops = {
> .unmap_page = sba_unmap_page,
> .map_sg = sba_map_sg,
> .unmap_sg = sba_unmap_sg,
> + .mapping_error = sba_mapping_error,
> };
>
>
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] parisc: DMA API: return error instead of BUG_ON for dma ops on non dma devs
2017-07-05 19:36 ` Helge Deller
@ 2017-07-05 20:33 ` Christoph Hellwig
2017-07-05 20:51 ` Helge Deller
0 siblings, 1 reply; 6+ messages in thread
From: Christoph Hellwig @ 2017-07-05 20:33 UTC (permalink / raw)
To: Helge Deller
Cc: Christoph Hellwig, Thomas Bogendoerfer, jejb, linux-parisc,
linux-kernel
On Wed, Jul 05, 2017 at 09:36:09PM +0200, Helge Deller wrote:
> On 05.07.2017 20:57, Christoph Hellwig wrote:
> > I've got a tree pending that removes DMA_ERROR_CODE, and it's been
> > in linux-next for a while.
>
> I had the parisc patch in for-next as well and didn't received
> any warnings.
There are no warnings, as the macro just won't be used by common code
anymore.
But the commit is from July 3rd, and the pull request to Linus for
it was merged on the same day. I can't see how it could have been
in linux-next for long. It certainly wasn't in the last linux-next
release that I looked at before the long weekend (the July 30 one)
> Can we please change this to something like
> "Prepare parisc to get rid of DMA_ERROR_CODE tree-wide" ?
> It's somewhat more neutral.
Fine with me.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] parisc: DMA API: return error instead of BUG_ON for dma ops on non dma devs
2017-07-05 20:33 ` Christoph Hellwig
@ 2017-07-05 20:51 ` Helge Deller
0 siblings, 0 replies; 6+ messages in thread
From: Helge Deller @ 2017-07-05 20:51 UTC (permalink / raw)
To: Christoph Hellwig; +Cc: Thomas Bogendoerfer, jejb, linux-parisc, linux-kernel
On 05.07.2017 22:33, Christoph Hellwig wrote:
> On Wed, Jul 05, 2017 at 09:36:09PM +0200, Helge Deller wrote:
>> On 05.07.2017 20:57, Christoph Hellwig wrote:
>>> I've got a tree pending that removes DMA_ERROR_CODE, and it's been
>>> in linux-next for a while.
>>
>> I had the parisc patch in for-next as well and didn't received
>> any warnings.
>
> There are no warnings, as the macro just won't be used by common code
> anymore.
And that's the reason why I didn't checked.
The generic DMA_ERROR_CODE has been there since 3.13 (or something
like that), so I don't think anybody would have assumed that it's
planned to vanish.
On the other side the patch fixed a real kernel crash on parisc,
and the patch applies as-is down to 3.13.
With that in mind, technically it's good that the parisc patch went in
before yours.
> But the commit is from July 3rd, and the pull request to Linus for
> it was merged on the same day. I can't see how it could have been
> in linux-next for long. It certainly wasn't in the last linux-next
> release that I looked at before the long weekend (the July 30 one)
True.
Anyway, let's get your patch in now.
>> Can we please change this to something like
>> "Prepare parisc to get rid of DMA_ERROR_CODE tree-wide" ?
>> It's somewhat more neutral.
>
> Fine with me.
I did not changed it.
Helge
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2017-07-05 20:51 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-07-03 8:38 [PATCH] parisc: DMA API: return error instead of BUG_ON for dma ops on non dma devs Thomas Bogendoerfer
2017-07-03 14:41 ` Helge Deller
2017-07-05 18:57 ` Christoph Hellwig
2017-07-05 19:36 ` Helge Deller
2017-07-05 20:33 ` Christoph Hellwig
2017-07-05 20:51 ` Helge Deller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox