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,
	Geert Uytterhoeven <geert+renesas@glider.be>,
	Christoph Hellwig <hch@lst.de>,
	"Rafael J. Wysocki" <rafael.j.wysocki@intel.com>,
	Robin Murphy <robin.murphy@arm.com>
Subject: [PATCH 4.20 07/76] driver core: Postpone DMA tear-down until after devres release
Date: Fri,  8 Mar 2019 13:49:19 +0100	[thread overview]
Message-ID: <20190308124915.048031638@linuxfoundation.org> (raw)
In-Reply-To: <20190308124914.789210760@linuxfoundation.org>

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

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

From: Geert Uytterhoeven <geert+renesas@glider.be>

commit 376991db4b6464e906d699ef07681e2ffa8ab08c upstream.

When unbinding the (IOMMU-enabled) R-Car SATA device on Salvator-XS
(R-Car H3 ES2.0), in preparation of rebinding against vfio-platform for
device pass-through for virtualization:

    echo ee300000.sata > /sys/bus/platform/drivers/sata_rcar/unbind

the kernel crashes with:

    Unable to handle kernel paging request at virtual address ffffffbf029ffffc
    Mem abort info:
      ESR = 0x96000006
      Exception class = DABT (current EL), IL = 32 bits
      SET = 0, FnV = 0
      EA = 0, S1PTW = 0
    Data abort info:
      ISV = 0, ISS = 0x00000006
      CM = 0, WnR = 0
    swapper pgtable: 4k pages, 39-bit VAs, pgdp = 000000007e8c586c
    [ffffffbf029ffffc] pgd=000000073bfc6003, pud=000000073bfc6003, pmd=0000000000000000
    Internal error: Oops: 96000006 [#1] SMP
    Modules linked in:
    CPU: 0 PID: 1098 Comm: bash Not tainted 5.0.0-rc5-salvator-x-00452-g37596f884f4318ef #287
    Hardware name: Renesas Salvator-X 2nd version board based on r8a7795 ES2.0+ (DT)
    pstate: 60400005 (nZCv daif +PAN -UAO)
    pc : __free_pages+0x8/0x58
    lr : __dma_direct_free_pages+0x50/0x5c
    sp : ffffff801268baa0
    x29: ffffff801268baa0 x28: 0000000000000000
    x27: ffffffc6f9c60bf0 x26: ffffffc6f9c60bf0
    x25: ffffffc6f9c60810 x24: 0000000000000000
    x23: 00000000fffff000 x22: ffffff8012145000
    x21: 0000000000000800 x20: ffffffbf029fffc8
    x19: 0000000000000000 x18: ffffffc6f86c42c8
    x17: 0000000000000000 x16: 0000000000000070
    x15: 0000000000000003 x14: 0000000000000000
    x13: ffffff801103d7f8 x12: 0000000000000028
    x11: ffffff8011117604 x10: 0000000000009ad8
    x9 : ffffff80110126d0 x8 : ffffffc6f7563000
    x7 : 6b6b6b6b6b6b6b6b x6 : 0000000000000018
    x5 : ffffff8011cf3cc8 x4 : 0000000000004000
    x3 : 0000000000080000 x2 : 0000000000000001
    x1 : 0000000000000000 x0 : ffffffbf029fffc8
    Process bash (pid: 1098, stack limit = 0x00000000c38e3e32)
    Call trace:
     __free_pages+0x8/0x58
     __dma_direct_free_pages+0x50/0x5c
     arch_dma_free+0x1c/0x98
     dma_direct_free+0x14/0x24
     dma_free_attrs+0x9c/0xdc
     dmam_release+0x18/0x20
     release_nodes+0x25c/0x28c
     devres_release_all+0x48/0x4c
     device_release_driver_internal+0x184/0x1f0
     device_release_driver+0x14/0x1c
     unbind_store+0x70/0xb8
     drv_attr_store+0x24/0x34
     sysfs_kf_write+0x4c/0x64
     kernfs_fop_write+0x154/0x1c4
     __vfs_write+0x34/0x164
     vfs_write+0xb4/0x16c
     ksys_write+0x5c/0xbc
     __arm64_sys_write+0x14/0x1c
     el0_svc_common+0x98/0x114
     el0_svc_handler+0x1c/0x24
     el0_svc+0x8/0xc
    Code: d51b4234 17fffffa a9bf7bfd 910003fd (b9403404)
    ---[ end trace 8c564cdd3a1a840f ]---

While I've bisected this to commit e8e683ae9a736407 ("iommu/of: Fix
probe-deferral"), and reverting that commit on post-v5.0-rc4 kernels
does fix the problem, this turned out to be a red herring.

On arm64, arch_teardown_dma_ops() resets dev->dma_ops to NULL.
Hence if a driver has used a managed DMA allocation API, the allocated
DMA memory will be freed using the direct DMA ops, while it may have
been allocated using a custom DMA ops (iommu_dma_ops in this case).

Fix this by reversing the order of the calls to devres_release_all() and
arch_teardown_dma_ops().

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Acked-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Cc: stable <stable@vger.kernel.org>
Reviewed-by: Robin Murphy <robin.murphy@arm.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 drivers/base/dd.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--- a/drivers/base/dd.c
+++ b/drivers/base/dd.c
@@ -965,9 +965,9 @@ static void __device_release_driver(stru
 			drv->remove(dev);
 
 		device_links_driver_cleanup(dev);
-		arch_teardown_dma_ops(dev);
 
 		devres_release_all(dev);
+		arch_teardown_dma_ops(dev);
 		dev->driver = NULL;
 		dev_set_drvdata(dev, NULL);
 		if (dev->pm_domain && dev->pm_domain->dismiss)



  parent reply	other threads:[~2019-03-08 13:07 UTC|newest]

Thread overview: 82+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-08 12:49 [PATCH 4.20 00/76] 4.20.15-stable review Greg Kroah-Hartman
2019-03-08 12:49 ` [PATCH 4.20 01/76] cpufreq: Use struct kobj_attribute instead of struct global_attr Greg Kroah-Hartman
2019-03-08 12:49 ` [PATCH 4.20 02/76] staging: erofs: fix mis-acted TAIL merging behavior Greg Kroah-Hartman
2019-03-08 12:49 ` [PATCH 4.20 03/76] binder: create node flag to request senders security context Greg Kroah-Hartman
2019-03-08 12:49 ` [PATCH 4.20 04/76] USB: serial: option: add Telit ME910 ECM composition Greg Kroah-Hartman
2019-03-08 12:49 ` [PATCH 4.20 05/76] USB: serial: cp210x: add ID for Ingenico 3070 Greg Kroah-Hartman
2019-03-08 12:49 ` [PATCH 4.20 06/76] USB: serial: ftdi_sio: add ID for Hjelmslund Electronics USB485 Greg Kroah-Hartman
2019-03-08 12:49 ` Greg Kroah-Hartman [this message]
2019-03-08 12:49 ` [PATCH 4.20 08/76] staging: erofs: fix fast symlink w/o xattr when fs xattr is on Greg Kroah-Hartman
2019-03-08 12:49 ` [PATCH 4.20 09/76] staging: erofs: fix memleak of inodes shared xattr array Greg Kroah-Hartman
2019-03-08 12:49 ` [PATCH 4.20 10/76] staging: erofs: fix race of initializing xattrs of a inode at the same time Greg Kroah-Hartman
2019-03-08 12:49 ` [PATCH 4.20 11/76] staging: erofs: fix illegal address access under memory pressure Greg Kroah-Hartman
2019-03-08 12:49 ` [PATCH 4.20 12/76] staging: erofs: compressed_pages should not be accessed again after freed Greg Kroah-Hartman
2019-03-08 12:49 ` [PATCH 4.20 13/76] staging: comedi: ni_660x: fix missing break in switch statement Greg Kroah-Hartman
2019-03-08 12:49 ` [PATCH 4.20 14/76] staging: wilc1000: fix to set correct value for vif_num Greg Kroah-Hartman
2019-03-08 12:49 ` [PATCH 4.20 15/76] staging: android: ion: fix sys heap pools gfp_flags Greg Kroah-Hartman
2019-03-08 12:49 ` [PATCH 4.20 16/76] staging: android: ashmem: Dont call fallocate() with ashmem_mutex held Greg Kroah-Hartman
2019-03-08 12:49 ` [PATCH 4.20 17/76] staging: android: ashmem: Avoid range_alloc() allocation " Greg Kroah-Hartman
2019-03-08 12:49 ` [PATCH 4.20 18/76] ip6mr: Do not call __IP6_INC_STATS() from preemptible context Greg Kroah-Hartman
2019-03-08 12:49 ` [PATCH 4.20 19/76] net: dsa: mv88e6xxx: add call to mv88e6xxx_ports_cmode_init to probe for new DSA framework Greg Kroah-Hartman
2019-03-08 12:49 ` [PATCH 4.20 20/76] net: dsa: mv88e6xxx: handle unknown duplex modes gracefully in mv88e6xxx_port_set_duplex Greg Kroah-Hartman
2019-03-08 12:49 ` [PATCH 4.20 21/76] net: dsa: mv8e6xxx: fix number of internal PHYs for 88E6x90 family Greg Kroah-Hartman
2019-03-08 12:49 ` [PATCH 4.20 22/76] net: mscc: Enable all ports in QSGMII Greg Kroah-Hartman
2019-03-08 12:49 ` [PATCH 4.20 23/76] net: sched: put back q.qlen into a single location Greg Kroah-Hartman
2019-03-08 12:49 ` [PATCH 4.20 24/76] net-sysfs: Fix mem leak in netdev_register_kobject Greg Kroah-Hartman
2019-03-08 12:49 ` [PATCH 4.20 25/76] qmi_wwan: Add support for Quectel EG12/EM12 Greg Kroah-Hartman
2019-03-08 12:49 ` [PATCH 4.20 26/76] sctp: call iov_iter_revert() after sending ABORT Greg Kroah-Hartman
2019-03-08 12:49 ` [PATCH 4.20 27/76] sky2: Disable MSI on Dell Inspiron 1545 and Gateway P-79 Greg Kroah-Hartman
2019-03-08 12:49 ` [PATCH 4.20 28/76] team: Free BPF filter when unregistering netdev Greg Kroah-Hartman
2019-03-08 12:49 ` [PATCH 4.20 29/76] tipc: fix RDM/DGRAM connect() regression Greg Kroah-Hartman
2019-03-08 12:49 ` [PATCH 4.20 30/76] bnxt_en: Drop oversize TX packets to prevent errors Greg Kroah-Hartman
2019-03-08 12:49 ` [PATCH 4.20 31/76] geneve: correctly handle ipv6.disable module parameter Greg Kroah-Hartman
2019-03-08 12:49 ` [PATCH 4.20 32/76] hv_netvsc: Fix IP header checksum for coalesced packets Greg Kroah-Hartman
2019-03-08 12:49 ` [PATCH 4.20 33/76] ipv4: Add ICMPv6 support when parse route ipproto Greg Kroah-Hartman
2019-03-08 12:49 ` [PATCH 4.20 34/76] lan743x: Fix TX Stall Issue Greg Kroah-Hartman
2019-03-08 12:49 ` [PATCH 4.20 35/76] net: dsa: mv88e6xxx: Fix statistics on mv88e6161 Greg Kroah-Hartman
2019-03-08 12:49 ` [PATCH 4.20 36/76] net: dsa: mv88e6xxx: Fix u64 statistics Greg Kroah-Hartman
2019-03-08 12:49 ` [PATCH 4.20 37/76] netlabel: fix out-of-bounds memory accesses Greg Kroah-Hartman
2019-03-08 12:49 ` [PATCH 4.20 38/76] net: netem: fix skb length BUG_ON in __skb_to_sgvec Greg Kroah-Hartman
2019-03-08 12:49 ` [PATCH 4.20 39/76] net: nfc: Fix NULL dereference on nfc_llcp_build_tlv fails Greg Kroah-Hartman
2019-03-08 12:49 ` [PATCH 4.20 40/76] net: phy: Micrel KSZ8061: link failure after cable connect Greg Kroah-Hartman
2019-03-08 12:49 ` [PATCH 4.20 41/76] net: phy: phylink: fix uninitialized variable in phylink_get_mac_state Greg Kroah-Hartman
2019-03-08 12:49 ` [PATCH 4.20 42/76] net: sit: fix memory leak in sit_init_net() Greg Kroah-Hartman
2019-03-08 12:49 ` [PATCH 4.20 43/76] net: socket: set sock->sk to NULL after calling proto_ops::release() Greg Kroah-Hartman
2019-03-08 12:49 ` [PATCH 4.20 44/76] tipc: fix race condition causing hung sendto Greg Kroah-Hartman
2019-03-08 12:49 ` [PATCH 4.20 45/76] tun: fix blocking read Greg Kroah-Hartman
2019-03-08 12:49 ` [PATCH 4.20 46/76] xen-netback: dont populate the hash cache on XenBus disconnect Greg Kroah-Hartman
2019-03-08 12:49 ` [PATCH 4.20 47/76] xen-netback: fix occasional leak of grant ref mappings under memory pressure Greg Kroah-Hartman
2019-03-08 12:50 ` [PATCH 4.20 48/76] tun: remove unnecessary memory barrier Greg Kroah-Hartman
2019-03-08 12:50 ` [PATCH 4.20 49/76] net: Add __icmp_send helper Greg Kroah-Hartman
2019-03-08 12:50 ` [PATCH 4.20 50/76] net: avoid use IPCB in cipso_v4_error Greg Kroah-Hartman
2019-03-08 12:50 ` [PATCH 4.20 51/76] ipv4: Return error for RTA_VIA attribute Greg Kroah-Hartman
2019-03-08 12:50 ` [PATCH 4.20 52/76] ipv6: " Greg Kroah-Hartman
2019-03-08 12:50 ` [PATCH 4.20 53/76] mpls: Return error for RTA_GATEWAY attribute Greg Kroah-Hartman
2019-03-08 12:50 ` [PATCH 4.20 54/76] ipv4: Pass original device to ip_rcv_finish_core Greg Kroah-Hartman
2019-03-08 12:50 ` [PATCH 4.20 55/76] net: dsa: mv88e6xxx: power serdes on/off for 10G interfaces on 6390X Greg Kroah-Hartman
2019-03-08 12:50 ` [PATCH 4.20 56/76] net: dsa: mv88e6xxx: prevent interrupt storm caused by mv88e6390x_port_set_cmode Greg Kroah-Hartman
2019-03-08 12:50 ` [PATCH 4.20 57/76] net/sched: act_ipt: fix refcount leak when replace fails Greg Kroah-Hartman
2019-03-08 12:50 ` [PATCH 4.20 58/76] net/sched: act_skbedit: " Greg Kroah-Hartman
2019-03-08 12:50 ` [PATCH 4.20 59/76] net: sched: act_tunnel_key: fix NULL pointer dereference during init Greg Kroah-Hartman
2019-03-08 12:50 ` [PATCH 4.20 60/76] x86/CPU/AMD: Set the CPB bit unconditionally on F17h Greg Kroah-Hartman
2019-03-08 12:50 ` [PATCH 4.20 61/76] x86/boot/compressed/64: Do not read legacy ROM on EFI system Greg Kroah-Hartman
2019-03-08 12:50 ` [PATCH 4.20 62/76] tracing: Fix event filters and triggers to handle negative numbers Greg Kroah-Hartman
2019-03-08 12:50 ` [PATCH 4.20 63/76] xhci: tegra: Prevent error pointer dereference Greg Kroah-Hartman
2019-03-08 12:50 ` [PATCH 4.20 64/76] usb: xhci: Fix for Enabling USB ROLE SWITCH QUIRK on INTEL_SUNRISEPOINT_LP_XHCI Greg Kroah-Hartman
2019-03-08 12:50 ` [PATCH 4.20 65/76] applicom: Fix potential Spectre v1 vulnerabilities Greg Kroah-Hartman
2019-03-08 12:50 ` [PATCH 4.20 66/76] MIPS: irq: Allocate accurate order pages for irq stack Greg Kroah-Hartman
2019-03-08 12:50 ` [PATCH 4.20 67/76] aio: Fix locking in aio_poll() Greg Kroah-Hartman
2019-03-08 12:50 ` [PATCH 4.20 68/76] xtensa: fix get_wchan Greg Kroah-Hartman
2019-03-08 12:50 ` [PATCH 4.20 69/76] gnss: sirf: fix premature wakeup interrupt enable Greg Kroah-Hartman
2019-03-08 12:50 ` [PATCH 4.20 70/76] USB: serial: cp210x: fix GPIO in autosuspend Greg Kroah-Hartman
2019-03-08 12:50 ` [PATCH 4.20 71/76] selftests: firmware: fix verify_reqs() return value Greg Kroah-Hartman
2019-03-08 12:50 ` [PATCH 4.20 72/76] Bluetooth: btrtl: Restore old logic to assume firmware is already loaded Greg Kroah-Hartman
2019-03-08 12:50 ` [PATCH 4.20 73/76] Bluetooth: Fix locking in bt_accept_enqueue() for BH context Greg Kroah-Hartman
2019-03-08 12:50 ` [PATCH 4.20 74/76] exec: Fix mem leak in kernel_read_file Greg Kroah-Hartman
2019-03-08 12:50 ` [PATCH 4.20 75/76] scsi: core: reset host byte in DID_NEXUS_FAILURE case Greg Kroah-Hartman
2019-03-08 12:50 ` [PATCH 4.20 76/76] bpf: fix sanitation rewrite in case of non-pointers Greg Kroah-Hartman
2019-03-08 16:04 ` [PATCH 4.20 00/76] 4.20.15-stable review Jon Hunter
2019-03-08 16:04   ` Jon Hunter
2019-03-08 20:57 ` shuah
2019-03-09  6:44 ` Naresh Kamboju
2019-03-09 22:35 ` Guenter Roeck

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=20190308124915.048031638@linuxfoundation.org \
    --to=gregkh@linuxfoundation.org \
    --cc=geert+renesas@glider.be \
    --cc=hch@lst.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rafael.j.wysocki@intel.com \
    --cc=robin.murphy@arm.com \
    --cc=stable@vger.kernel.org \
    /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.