All of lore.kernel.org
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: linux-kernel@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	stable@vger.kernel.org,
	Thomas Bogendoerfer <tsbogend@alpha.franken.de>,
	Helge Deller <deller@gmx.de>
Subject: [PATCH 4.11 47/88] parisc: DMA API: return error instead of BUG_ON for dma ops on non dma devs
Date: Wed, 19 Jul 2017 12:08:09 +0200	[thread overview]
Message-ID: <20170719100828.017416098@linuxfoundation.org> (raw)
In-Reply-To: <20170719100820.364094938@linuxfoundation.org>

4.11-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Thomas Bogendoerfer <tsbogend@alpha.franken.de>

commit 33f9e02495d15a061f0c94ef46f5103a2d0c20f3 upstream.

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>
Signed-off-by: Helge Deller <deller@gmx.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 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(-)

--- 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;
--- a/drivers/parisc/ccio-dma.c
+++ b/drivers/parisc/ccio-dma.c
@@ -741,6 +741,8 @@ ccio_map_single(struct device *dev, void
 
 	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_
 	
 	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 s
 	
 	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
 
 	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);
--- 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; })
 
 
 /*
--- 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
--- a/drivers/parisc/sba_iommu.c
+++ b/drivers/parisc/sba_iommu.c
@@ -691,6 +691,8 @@ static int sba_dma_supported( struct dev
 		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
 	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_a
 	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 sc
 	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
 		__func__, nents, sg_virt(sglist), sglist->length);
 
 	ioc = GET_IOC(dev);
+	if (!ioc) {
+		WARN_ON(!ioc);
+		return;
+	}
 
 #ifdef SBA_COLLECT_STATS
 	ioc->usg_calls++;

  parent reply	other threads:[~2017-07-19 10:21 UTC|newest]

Thread overview: 81+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-07-19 10:07 [PATCH 4.11 00/88] 4.11.12-stable review Greg Kroah-Hartman
2017-07-19 10:07 ` [PATCH 4.11 01/88] net/phy: micrel: configure intterupts after autoneg workaround Greg Kroah-Hartman
2017-07-19 10:07 ` [PATCH 4.11 02/88] ipv6: avoid unregistering inet6_dev for loopback Greg Kroah-Hartman
2017-07-19 10:07 ` [PATCH 4.11 03/88] netvsc: dont access netdev->num_rx_queues directly Greg Kroah-Hartman
2017-07-19 10:07 ` [PATCH 4.11 04/88] sfc: Fix MCDI command size for filter operations Greg Kroah-Hartman
2017-07-19 10:07 ` [PATCH 4.11 06/88] net: dp83640: Avoid NULL pointer dereference Greg Kroah-Hartman
2017-07-19 10:07 ` [PATCH 4.11 07/88] tcp: reset sk_rx_dst in tcp_disconnect() Greg Kroah-Hartman
2017-07-19 10:07 ` [PATCH 4.11 08/88] net: prevent sign extension in dev_get_stats() Greg Kroah-Hartman
2017-07-19 10:07 ` [PATCH 4.11 09/88] virtio-net: serialize tx routine during reset Greg Kroah-Hartman
2017-07-19 10:07 ` [PATCH 4.11 10/88] net: sched: Fix one possible panic when no destroy callback Greg Kroah-Hartman
2017-07-19 10:07 ` [PATCH 4.11 11/88] mlxsw: spectrum_router: Fix NULL pointer dereference Greg Kroah-Hartman
2017-07-19 10:07 ` [PATCH 4.11 12/88] rocker: move dereference before free Greg Kroah-Hartman
2017-07-19 10:07 ` [PATCH 4.11 13/88] bpf: prevent leaking pointer via xadd on unpriviledged Greg Kroah-Hartman
2017-07-19 10:07 ` [PATCH 4.11 15/88] net/mlx5: Cancel delayed recovery work when unloading the driver Greg Kroah-Hartman
2017-07-19 10:07 ` [PATCH 4.11 16/88] net/mlx5e: Fix TX carrier errors report in get stats ndo Greg Kroah-Hartman
2017-07-19 10:07 ` [PATCH 4.11 17/88] ipv6: dad: dont remove dynamic addresses if link is down Greg Kroah-Hartman
2017-07-19 10:07 ` [PATCH 4.11 18/88] vxlan: fix hlist corruption Greg Kroah-Hartman
2017-07-19 10:07 ` [PATCH 4.11 19/88] geneve: " Greg Kroah-Hartman
2017-07-19 10:07 ` [PATCH 4.11 20/88] net: core: Fix slab-out-of-bounds in netdev_stats_to_stats64 Greg Kroah-Hartman
2017-07-19 10:07 ` [PATCH 4.11 21/88] liquidio: fix bug in soft reset failure detection Greg Kroah-Hartman
2017-07-19 10:07 ` [PATCH 4.11 23/88] vrf: fix bug_on triggered by rx when destroying a vrf Greg Kroah-Hartman
2017-07-19 10:07 ` [PATCH 4.11 24/88] rds: tcp: use sock_create_lite() to create the accept socket Greg Kroah-Hartman
2017-07-19 10:07 ` [PATCH 4.11 25/88] net/mlx5e: Initialize CEEs getpermhwaddr address buffer to 0xff Greg Kroah-Hartman
2017-07-19 10:07 ` [PATCH 4.11 26/88] cxgb4: fix BUG() on interrupt deallocating path of ULD Greg Kroah-Hartman
2017-07-19 10:07 ` [PATCH 4.11 27/88] tap: convert a mutex to a spinlock Greg Kroah-Hartman
2017-07-19 10:07 ` [PATCH 4.11 28/88] bridge: mdb: fix leak on complete_info ptr on fail path Greg Kroah-Hartman
2017-07-19 10:07 ` [PATCH 4.11 30/88] sfc: dont read beyond unicast address list Greg Kroah-Hartman
2017-07-19 10:07 ` [PATCH 4.11 31/88] Adding asm-prototypes.h for genksyms to generate crc Greg Kroah-Hartman
2017-07-19 10:07 ` [PATCH 4.11 32/88] sed regex in Makefile.build requires line break between exported symbols Greg Kroah-Hartman
2017-07-19 10:07 ` [PATCH 4.11 33/88] Adding the type of " Greg Kroah-Hartman
2017-07-19 10:07 ` [PATCH 4.11 34/88] sparc64: Fix gup_huge_pmd Greg Kroah-Hartman
2017-07-19 10:07 ` [PATCH 4.11 35/88] block: Fix a blk_exit_rl() regression Greg Kroah-Hartman
2017-07-19 10:07 ` [PATCH 4.11 36/88] brcmfmac: Fix a memory leak in error handling path in brcmf_cfg80211_attach Greg Kroah-Hartman
2017-07-19 10:07 ` [PATCH 4.11 37/88] brcmfmac: Fix glom_skb leak in brcmf_sdiod_recv_chain Greg Kroah-Hartman
2017-07-19 10:08 ` [PATCH 4.11 38/88] efi: Process the MEMATTR table only if EFI_MEMMAP is enabled Greg Kroah-Hartman
2017-07-19 10:08 ` Greg Kroah-Hartman
2017-07-19 10:08 ` [PATCH 4.11 39/88] cfg80211: Define nla_policy for NL80211_ATTR_LOCAL_MESH_POWER_MODE Greg Kroah-Hartman
2017-07-19 10:08 ` [PATCH 4.11 40/88] cfg80211: Validate frequencies nested in NL80211_ATTR_SCAN_FREQUENCIES Greg Kroah-Hartman
2017-07-19 10:08 ` [PATCH 4.11 41/88] cfg80211: Check if PMKID attribute is of expected size Greg Kroah-Hartman
2017-07-19 10:08 ` [PATCH 4.11 42/88] cfg80211: Check if NAN service ID " Greg Kroah-Hartman
2017-07-19 10:08 ` [PATCH 4.11 43/88] drm/amdgpu/gfx6: properly cache mc_arb_ramcfg Greg Kroah-Hartman
2017-07-19 10:08 ` [PATCH 4.11 44/88] irqchip/gic-v3: Fix out-of-bound access in gic_set_affinity Greg Kroah-Hartman
2017-07-19 10:08 ` [PATCH 4.11 45/88] parisc: Report SIGSEGV instead of SIGBUS when running out of stack Greg Kroah-Hartman
2017-07-19 10:08 ` [PATCH 4.11 46/88] parisc: use compat_sys_keyctl() Greg Kroah-Hartman
2017-07-19 10:08 ` Greg Kroah-Hartman [this message]
2017-07-19 10:08 ` [PATCH 4.11 48/88] parisc/mm: Ensure IRQs are off in switch_mm() Greg Kroah-Hartman
2017-07-19 10:08 ` [PATCH 4.11 49/88] tools/lib/lockdep: Reduce MAX_LOCK_DEPTH to avoid overflowing lock_chain/: Depth Greg Kroah-Hartman
2017-07-19 10:08 ` [PATCH 4.11 50/88] thp, mm: fix crash due race in MADV_FREE handling Greg Kroah-Hartman
2017-07-19 10:08 ` [PATCH 4.11 51/88] kernel/extable.c: mark core_kernel_text notrace Greg Kroah-Hartman
2017-07-19 10:08 ` [PATCH 4.11 52/88] mm/list_lru.c: fix list_lru_count_node() to be race free Greg Kroah-Hartman
2017-07-19 10:08 ` [PATCH 4.11 53/88] fs/dcache.c: fix spin lockup issue on nlru->lock Greg Kroah-Hartman
2017-07-19 10:08 ` [PATCH 4.11 54/88] checkpatch: silence perl 5.26.0 unescaped left brace warnings Greg Kroah-Hartman
2017-07-19 10:08 ` [PATCH 4.11 55/88] binfmt_elf: use ELF_ET_DYN_BASE only for PIE Greg Kroah-Hartman
2017-07-19 10:08 ` [PATCH 4.11 56/88] arm: move ELF_ET_DYN_BASE to 4MB Greg Kroah-Hartman
2017-07-19 10:08 ` [PATCH 4.11 57/88] arm64: move ELF_ET_DYN_BASE to 4GB / 4MB Greg Kroah-Hartman
2017-07-19 10:08 ` [PATCH 4.11 58/88] powerpc: " Greg Kroah-Hartman
2017-07-19 10:08 ` [PATCH 4.11 59/88] s390: reduce ELF_ET_DYN_BASE Greg Kroah-Hartman
2017-07-19 10:08 ` [PATCH 4.11 60/88] exec: Limit arg stack to at most 75% of _STK_LIM Greg Kroah-Hartman
2017-07-19 10:08 ` [PATCH 4.11 61/88] powerpc/kexec: Fix radix to hash kexec due to IAMR/AMOR Greg Kroah-Hartman
2017-07-19 10:08 ` [PATCH 4.11 62/88] ARM64: dts: marvell: armada37xx: Fix timer interrupt specifiers Greg Kroah-Hartman
2017-07-19 10:08 ` [PATCH 4.11 63/88] arm64: Preventing READ_IMPLIES_EXEC propagation Greg Kroah-Hartman
2017-07-19 10:08 ` [PATCH 4.11 64/88] vt: fix unchecked __put_user() in tioclinux ioctls Greg Kroah-Hartman
2017-07-19 10:08 ` [PATCH 4.11 65/88] rcu: Add memory barriers for NOCB leader wakeup Greg Kroah-Hartman
2017-07-19 10:08 ` [PATCH 4.11 66/88] nvmem: core: fix leaks on registration errors Greg Kroah-Hartman
2017-07-19 10:08 ` [PATCH 4.11 67/88] Drivers: hv: vmbus: Close timing hole that can corrupt per-cpu page Greg Kroah-Hartman
2017-07-19 10:08 ` [PATCH 4.11 68/88] mnt: In umount propagation reparent in a separate pass Greg Kroah-Hartman
2017-07-19 10:08 ` [PATCH 4.11 69/88] mnt: In propgate_umount handle visiting mounts in any order Greg Kroah-Hartman
2017-07-19 10:08 ` [PATCH 4.11 70/88] mnt: Make propagate_umount less slow for overlapping mount propagation trees Greg Kroah-Hartman
2017-07-19 10:08 ` [PATCH 4.11 71/88] selftests/capabilities: Fix the test_execve test Greg Kroah-Hartman
2017-07-19 10:08 ` [PATCH 4.11 74/88] crypto: atmel - only treat EBUSY as transient if backlog Greg Kroah-Hartman
2017-07-19 10:08 ` [PATCH 4.11 75/88] crypto: sha1-ssse3 - Disable avx2 Greg Kroah-Hartman
2017-07-19 10:08 ` [PATCH 4.11 78/88] sched/fair, cpumask: Export for_each_cpu_wrap() Greg Kroah-Hartman
2017-07-19 10:08 ` [PATCH 4.11 79/88] sched/topology: Fix building of overlapping sched-groups Greg Kroah-Hartman
2017-07-19 10:08 ` [PATCH 4.11 80/88] sched/topology: Optimize build_group_mask() Greg Kroah-Hartman
2017-07-19 10:08 ` [PATCH 4.11 81/88] sched/topology: Fix overlapping sched_group_mask Greg Kroah-Hartman
2017-07-19 10:08 ` [PATCH 4.11 82/88] PM / wakeirq: Convert to SRCU Greg Kroah-Hartman
2017-07-19 10:08 ` [PATCH 4.11 84/88] PM / QoS: return -EINVAL for bogus strings Greg Kroah-Hartman
2017-07-19 10:08 ` [PATCH 4.11 88/88] kvm: vmx: allow host to access guest MSR_IA32_BNDCFGS Greg Kroah-Hartman
2017-07-19 10:27 ` [PATCH 4.11 00/88] 4.11.12-stable review Greg Kroah-Hartman
2017-07-19 20:34 ` Guenter Roeck
2017-07-19 23:38 ` Shuah Khan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170719100828.017416098@linuxfoundation.org \
    --to=gregkh@linuxfoundation.org \
    --cc=deller@gmx.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=stable@vger.kernel.org \
    --cc=tsbogend@alpha.franken.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.