From: Sasha Levin <Alexander.Levin@microsoft.com>
To: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"stable@vger.kernel.org" <stable@vger.kernel.org>
Cc: "Chris Wilson" <chris@chris-wilson.co.uk>,
"Rob Clark" <robdclark@gmail.com>,
"Gustavo Padovan" <gustavo.padovan@collabora.co.uk>,
"Sumit Semwal" <sumit.semwal@linaro.org>,
"Christian König" <christian.koenig@amd.com>,
"Sasha Levin" <Alexander.Levin@microsoft.com>
Subject: [PATCH AUTOSEL for 4.15 004/102] dma-buf/fence: Fix lock inversion within dma-fence-array
Date: Sat, 3 Mar 2018 22:24:11 +0000 [thread overview]
Message-ID: <20180303222318.26006-4-alexander.levin@microsoft.com> (raw)
In-Reply-To: <20180303222318.26006-1-alexander.levin@microsoft.com>
From: Chris Wilson <chris@chris-wilson.co.uk>
[ Upstream commit 03e4e0a9e02cf703da331ff6cfd57d0be9bf5692 ]
Ages ago Rob Clark noted,
"Currently with fence-array, we have a potential deadlock situation. If
we fence_add_callback() on an array-fence, the array-fence's lock is
acquired first, and in it's ->enable_signaling() callback, it will install
cbs on it's array-member fences, so the array-member's lock is acquired
second.
But in the signal path, the array-member's lock is acquired first, and
the array-fence's lock acquired second."
Rob proposed either extensive changes to dma-fence to unnest the
fence-array signaling, or to defer the signaling onto a workqueue. This
is a more refined version of the later, that should keep the latency
of the fence signaling to a minimum by using an irq-work, which is
executed asap.
Reported-by: Rob Clark <robdclark@gmail.com>
Suggested-by: Rob Clark <robdclark@gmail.com>
References: 1476635975-21981-1-git-send-email-robdclark@gmail.com
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Rob Clark <robdclark@gmail.com>
Cc: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
Cc: Sumit Semwal <sumit.semwal@linaro.org>
Cc: Christian König <christian.koenig@amd.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Sumit Semwal <sumit.semwal@linaro.org>
Link: https://patchwork.freedesktop.org/patch/msgid/20171114162719.30958-1-chris@chris-wilson.co.uk
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
drivers/base/Kconfig | 1 +
drivers/dma-buf/dma-fence-array.c | 14 ++++++++++++--
include/linux/dma-fence-array.h | 3 +++
3 files changed, 16 insertions(+), 2 deletions(-)
diff --git a/drivers/base/Kconfig b/drivers/base/Kconfig
index 2415ad9f6dd4..49fd50fccd48 100644
--- a/drivers/base/Kconfig
+++ b/drivers/base/Kconfig
@@ -249,6 +249,7 @@ config DMA_SHARED_BUFFER
bool
default n
select ANON_INODES
+ select IRQ_WORK
help
This option enables the framework for buffer-sharing between
multiple drivers. A buffer is associated with a file using driver
diff --git a/drivers/dma-buf/dma-fence-array.c b/drivers/dma-buf/dma-fence-array.c
index 0350829ba62e..dd1edfb27b61 100644
--- a/drivers/dma-buf/dma-fence-array.c
+++ b/drivers/dma-buf/dma-fence-array.c
@@ -31,6 +31,14 @@ static const char *dma_fence_array_get_timeline_name(struct dma_fence *fence)
return "unbound";
}
+static void irq_dma_fence_array_work(struct irq_work *wrk)
+{
+ struct dma_fence_array *array = container_of(wrk, typeof(*array), work);
+
+ dma_fence_signal(&array->base);
+ dma_fence_put(&array->base);
+}
+
static void dma_fence_array_cb_func(struct dma_fence *f,
struct dma_fence_cb *cb)
{
@@ -39,8 +47,9 @@ static void dma_fence_array_cb_func(struct dma_fence *f,
struct dma_fence_array *array = array_cb->array;
if (atomic_dec_and_test(&array->num_pending))
- dma_fence_signal(&array->base);
- dma_fence_put(&array->base);
+ irq_work_queue(&array->work);
+ else
+ dma_fence_put(&array->base);
}
static bool dma_fence_array_enable_signaling(struct dma_fence *fence)
@@ -136,6 +145,7 @@ struct dma_fence_array *dma_fence_array_create(int num_fences,
spin_lock_init(&array->lock);
dma_fence_init(&array->base, &dma_fence_array_ops, &array->lock,
context, seqno);
+ init_irq_work(&array->work, irq_dma_fence_array_work);
array->num_fences = num_fences;
atomic_set(&array->num_pending, signal_on_any ? 1 : num_fences);
diff --git a/include/linux/dma-fence-array.h b/include/linux/dma-fence-array.h
index 332a5420243c..bc8940ca280d 100644
--- a/include/linux/dma-fence-array.h
+++ b/include/linux/dma-fence-array.h
@@ -21,6 +21,7 @@
#define __LINUX_DMA_FENCE_ARRAY_H
#include <linux/dma-fence.h>
+#include <linux/irq_work.h>
/**
* struct dma_fence_array_cb - callback helper for fence array
@@ -47,6 +48,8 @@ struct dma_fence_array {
unsigned num_fences;
atomic_t num_pending;
struct dma_fence **fences;
+
+ struct irq_work work;
};
extern const struct dma_fence_ops dma_fence_array_ops;
--
2.14.1
next prev parent reply other threads:[~2018-03-04 0:51 UTC|newest]
Thread overview: 106+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-03-03 22:24 [PATCH AUTOSEL for 4.15 001/102] drm/panel: rpi-touchscreen: propagate errors in rpi_touchscreen_i2c_read() Sasha Levin
2018-03-03 22:24 ` [PATCH AUTOSEL for 4.15 002/102] spi: imx: Fix failure path leak on GPIO request error correctly Sasha Levin
2018-03-03 22:24 ` [PATCH AUTOSEL for 4.15 003/102] drm/edid: set ELD connector type in drm_edid_to_eld() Sasha Levin
2018-03-03 22:24 ` [PATCH AUTOSEL for 4.15 005/102] video/hdmi: Allow "empty" HDMI infoframes Sasha Levin
2018-03-03 22:24 ` Sasha Levin [this message]
2018-03-03 22:24 ` [PATCH AUTOSEL for 4.15 006/102] HID: multitouch: Only look at non touch fields in first packet of a frame Sasha Levin
2018-03-03 22:24 ` [PATCH AUTOSEL for 4.15 007/102] KVM: PPC: Book3S HV: Avoid shifts by negative amounts Sasha Levin
2018-03-03 22:24 ` [PATCH AUTOSEL for 4.15 008/102] KVM: PPC: Book3S HV: Fix typo in kvmppc_hv_get_dirty_log_radix() Sasha Levin
2018-03-03 22:24 ` [PATCH AUTOSEL for 4.15 010/102] iwlwifi: mvm: rs: don't override the rate history in the search cycle Sasha Levin
2018-03-03 22:24 ` [PATCH AUTOSEL for 4.15 009/102] HID: elo: clear BTN_LEFT mapping Sasha Levin
2018-03-03 22:24 ` [PATCH AUTOSEL for 4.15 011/102] ARM: dts: koelsch: Move cec_clock to root node Sasha Levin
2018-03-03 22:24 ` [PATCH AUTOSEL for 4.15 012/102] clk: meson: gxbb: fix wrong clock for SARADC/SANA Sasha Levin
2018-03-03 22:24 ` [PATCH AUTOSEL for 4.15 013/102] ARM: dts: exynos: Correct Trats2 panel reset line Sasha Levin
2018-03-03 22:24 ` [PATCH AUTOSEL for 4.15 014/102] drm/amdgpu: fix get_max_engine_clock_in_mhz Sasha Levin
2018-03-03 22:24 ` [PATCH AUTOSEL for 4.15 015/102] staging: rtl8822be: fix missing null check on dev_alloc_skb return Sasha Levin
2018-03-03 22:24 ` [PATCH AUTOSEL for 4.15 016/102] typec: tcpm: fusb302: Resolve out of order messaging events Sasha Levin
2018-03-03 22:24 ` [PATCH AUTOSEL for 4.15 017/102] USB: ledtrig-usbport: fix of-node leak Sasha Levin
2018-03-03 22:24 ` [PATCH AUTOSEL for 4.15 018/102] dt-bindings: serial: Add common rs485 binding for RTS polarity Sasha Levin
2018-03-03 22:24 ` [PATCH AUTOSEL for 4.15 019/102] sched: Stop switched_to_rt() from sending IPIs to offline CPUs Sasha Levin
2018-03-03 22:24 ` [PATCH AUTOSEL for 4.15 020/102] sched: Stop resched_cpu() " Sasha Levin
2018-03-03 22:24 ` [PATCH AUTOSEL for 4.15 021/102] crypto: chelsio - Fix an error code in chcr_hash_dma_map() Sasha Levin
2018-03-03 22:24 ` [PATCH AUTOSEL for 4.15 023/102] crypto: keywrap - Add missing ULL suffixes for 64-bit constants Sasha Levin
2018-03-03 22:24 ` [PATCH AUTOSEL for 4.15 022/102] crypto: ecc - Fix NULL pointer deref. on no default_rng Sasha Levin
2018-03-03 22:24 ` [PATCH AUTOSEL for 4.15 025/102] test_firmware: fix setting old custom fw path back on exit Sasha Levin
2018-03-03 22:24 ` [PATCH AUTOSEL for 4.15 024/102] crypto: cavium - fix memory leak on info Sasha Levin
2018-03-03 22:24 ` [PATCH AUTOSEL for 4.15 026/102] ASoC: fsl_ssi: only enable proper channel slots in AC'97 mode Sasha Levin
2018-03-05 10:20 ` Mark Brown
2018-03-05 20:25 ` Sasha Levin
2018-03-03 22:24 ` [PATCH AUTOSEL for 4.15 027/102] drm/vblank: Fix vblank timestamp debugs Sasha Levin
2018-03-03 22:24 ` [PATCH AUTOSEL for 4.15 028/102] net: ieee802154: adf7242: Fix bug if defined DEBUG Sasha Levin
2018-03-03 22:24 ` [PATCH AUTOSEL for 4.15 029/102] rtc: brcmstb-waketimer: fix error handling in brcmstb_waketmr_probe() Sasha Levin
2018-03-03 22:24 ` [PATCH AUTOSEL for 4.15 030/102] perf report: Fix -D output for user metadata events Sasha Levin
2018-03-03 22:24 ` [PATCH AUTOSEL for 4.15 031/102] net: xfrm: allow clearing socket xfrm policies Sasha Levin
2018-03-03 22:24 ` [PATCH AUTOSEL for 4.15 032/102] gpiolib: don't allow OPEN_DRAIN & OPEN_SOURCE flags simultaneously Sasha Levin
2018-03-03 22:24 ` [PATCH AUTOSEL for 4.15 033/102] mtd: nand: fix interpretation of NAND_CMD_NONE in nand_command[_lp]() Sasha Levin
2018-03-03 22:24 ` [PATCH AUTOSEL for 4.15 035/102] ARM: dts: am335x-pepper: Fix the audio CODEC's reset pin Sasha Levin
2018-03-03 22:24 ` [PATCH AUTOSEL for 4.15 034/102] net: thunderx: Set max queue count taking XDP_TX into account Sasha Levin
2018-03-03 22:24 ` [PATCH AUTOSEL for 4.15 037/102] mtd: nand: ifc: update bufnum mask for ver >= 2.0.0 Sasha Levin
2018-03-03 22:24 ` [PATCH AUTOSEL for 4.15 036/102] ARM: dts: omap3-n900: Fix the audio CODEC's reset pin Sasha Levin
2018-03-03 22:24 ` [PATCH AUTOSEL for 4.15 038/102] userns: Don't fail follow_automount based on s_user_ns Sasha Levin
2018-03-03 22:24 ` [PATCH AUTOSEL for 4.15 040/102] leds: pm8058: Silence pointer to integer size warning Sasha Levin
2018-03-03 22:24 ` [PATCH AUTOSEL for 4.15 039/102] xfrm: Fix xfrm_replay_overflow_offload_esn Sasha Levin
2018-03-03 22:24 ` [PATCH AUTOSEL for 4.15 041/102] bpf: fix stack state printing in verifier log Sasha Levin
2018-03-03 22:24 ` [PATCH AUTOSEL for 4.15 042/102] clk: ti: clkctrl: add support for retrying failed init Sasha Levin
2018-03-03 22:24 ` [PATCH AUTOSEL for 4.15 043/102] ASoC: tlv320aic31xx: Handle inverted BCLK in non-DSP modes Sasha Levin
2018-03-05 10:21 ` Mark Brown
2018-03-05 20:25 ` Sasha Levin
2018-03-03 22:24 ` [PATCH AUTOSEL for 4.15 044/102] power: supply: sbs-message: double left shift bug in sbsm_select() Sasha Levin
2018-03-03 22:24 ` [PATCH AUTOSEL for 4.15 045/102] power: supply: ab8500_charger: Fix an error handling path Sasha Levin
2018-03-03 22:24 ` [PATCH AUTOSEL for 4.15 046/102] power: supply: ab8500_charger: Bail out in case of error in 'ab8500_charger_init_hw_registers()' Sasha Levin
2018-03-03 22:24 ` [PATCH AUTOSEL for 4.15 047/102] drm/etnaviv: make THERMAL selectable Sasha Levin
2018-03-03 22:24 ` [PATCH AUTOSEL for 4.15 049/102] iio: health: max30102: Add power enable parameter to get_temp function Sasha Levin
2018-03-03 22:24 ` [PATCH AUTOSEL for 4.15 048/102] iio: adc: ina2xx: Shift bus voltage register to mask flag bits Sasha Levin
2018-03-03 22:24 ` [PATCH AUTOSEL for 4.15 050/102] ath10k: update tdls teardown state to target Sasha Levin
2018-03-03 22:24 ` [PATCH AUTOSEL for 4.15 051/102] cpufreq: Fix governor module removal race Sasha Levin
2018-03-03 22:24 ` [PATCH AUTOSEL for 4.15 052/102] dmaengine: bcm2835-dma: Use vchan_terminate_vdesc() instead of desc_free Sasha Levin
2018-03-03 22:24 ` [PATCH AUTOSEL for 4.15 053/102] dmaengine: amba-pl08x: " Sasha Levin
2018-03-03 22:24 ` [PATCH AUTOSEL for 4.15 054/102] KVM: X86: Restart the guest when insn_len is zero and SEV is enabled Sasha Levin
2018-03-03 22:24 ` [PATCH AUTOSEL for 4.15 055/102] drm/amdgpu:fix random missing of FLR NOTIFY Sasha Levin
2018-03-03 22:24 ` [PATCH AUTOSEL for 4.15 056/102] scsi: lpfc: Fix crash during driver unload with running nvme traffic Sasha Levin
2018-03-03 22:24 ` [PATCH AUTOSEL for 4.15 057/102] scsi: ses: don't ask for diagnostic pages repeatedly during probe Sasha Levin
2018-03-03 22:24 ` [PATCH AUTOSEL for 4.15 059/102] drm/sun4i: Fix format mask in DE2 driver Sasha Levin
2018-03-03 22:24 ` [PATCH AUTOSEL for 4.15 058/102] pwm: stmpe: Fix wrong register offset for hwpwm=2 case Sasha Levin
2018-03-03 22:24 ` [PATCH AUTOSEL for 4.15 060/102] pinctrl: sh-pfc: r8a7791: Add can_clk function Sasha Levin
2018-03-03 22:24 ` [PATCH AUTOSEL for 4.15 061/102] pinctrl: sh-pfc: r8a7795-es1: Fix MOD_SEL1 bit[25:24] to 0x3 when using STP_ISEN_1_D Sasha Levin
2018-03-03 22:24 ` [PATCH AUTOSEL for 4.15 062/102] perf annotate: Fix unnecessary memory allocation for s390x Sasha Levin
2018-03-03 22:24 ` [PATCH AUTOSEL for 4.15 063/102] perf annotate: Fix objdump comment parsing for Intel mov dissassembly Sasha Levin
2018-03-03 22:24 ` [PATCH AUTOSEL for 4.15 064/102] iwlwifi: mvm: avoid dumping assert log when device is stopped Sasha Levin
2018-03-03 22:24 ` [PATCH AUTOSEL for 4.15 066/102] drm/amdgpu: fix amdgpu_sync_resv v2 Sasha Levin
2018-03-03 22:24 ` [PATCH AUTOSEL for 4.15 065/102] drm/amdgpu:fix virtual dce bug Sasha Levin
2018-03-03 22:24 ` [PATCH AUTOSEL for 4.15 067/102] bnxt_en: Uninitialized variable in bnxt_tc_parse_actions() Sasha Levin
2018-03-03 22:24 ` [PATCH AUTOSEL for 4.15 068/102] clk: qcom: msm8916: fix mnd_width for codec_digcodec Sasha Levin
2018-03-03 22:24 ` [PATCH AUTOSEL for 4.15 069/102] mwifiex: cfg80211: do not change virtual interface during scan processing Sasha Levin
2018-03-03 22:24 ` [PATCH AUTOSEL for 4.15 071/102] tools/usbip: fixes build with musl libc toolchain Sasha Levin
2018-03-03 22:24 ` [PATCH AUTOSEL for 4.15 070/102] ath10k: fix invalid STS_CAP_OFFSET_MASK Sasha Levin
2018-03-03 22:24 ` [PATCH AUTOSEL for 4.15 072/102] spi: sun6i: disable/unprepare clocks on remove Sasha Levin
2018-03-03 22:24 ` [PATCH AUTOSEL for 4.15 073/102] bnxt_en: Don't print "Link speed -1 no longer supported" messages Sasha Levin
2018-03-03 22:24 ` [PATCH AUTOSEL for 4.15 074/102] scsi: core: scsi_get_device_flags_keyed(): Always return device flags Sasha Levin
2018-03-03 22:24 ` [PATCH AUTOSEL for 4.15 075/102] scsi: devinfo: apply to HP XP the same flags as Hitachi VSP Sasha Levin
2018-03-03 22:24 ` [PATCH AUTOSEL for 4.15 076/102] scsi: dh: add new rdac devices Sasha Levin
2018-03-03 22:24 ` [PATCH AUTOSEL for 4.15 077/102] clk: renesas: r8a77970: Add LVDS clock Sasha Levin
2018-03-03 22:24 ` [PATCH AUTOSEL for 4.15 078/102] staging: fsl-dpaa2/eth: Fix access to FAS field Sasha Levin
2018-03-03 22:24 ` [PATCH AUTOSEL for 4.15 079/102] media: vsp1: Prevent suspending and resuming DRM pipelines Sasha Levin
2018-03-03 22:24 ` [PATCH AUTOSEL for 4.15 080/102] dm raid: fix raid set size revalidation Sasha Levin
2018-03-03 22:24 ` [PATCH AUTOSEL for 4.15 081/102] media: cpia2: Fix a couple off by one bugs Sasha Levin
2018-03-03 22:24 ` [PATCH AUTOSEL for 4.15 082/102] media: davinci: vpif_capture: add NULL check on devm_kzalloc return value Sasha Levin
2018-03-03 22:24 ` [PATCH AUTOSEL for 4.15 084/102] net: sched: drop qdisc_reset from dev_graft_qdisc Sasha Levin
2018-03-03 22:24 ` [PATCH AUTOSEL for 4.15 083/102] virtio_net: Disable interrupts if napi_complete_done rescheduled napi Sasha Levin
2018-03-03 22:24 ` [PATCH AUTOSEL for 4.15 086/102] drm/amdkfd: Fix memory leaks in kfd topology Sasha Levin
2018-03-03 22:24 ` [PATCH AUTOSEL for 4.15 085/102] veth: set peer GSO values Sasha Levin
2018-03-03 22:25 ` [PATCH AUTOSEL for 4.15 088/102] powerpc/64: Don't trace irqs-off at interrupt return to soft-disabled context Sasha Levin
2018-03-03 22:25 ` [PATCH AUTOSEL for 4.15 087/102] powerpc/modules: Don't try to restore r2 after a sibling call Sasha Levin
2018-03-03 22:25 ` [PATCH AUTOSEL for 4.15 090/102] agp/intel: Flush all chipset writes after updating the GGTT Sasha Levin
2018-03-03 22:25 ` [PATCH AUTOSEL for 4.15 089/102] arm64: dts: renesas: salvator-common: Add EthernetAVB PHY reset Sasha Levin
2018-03-03 22:25 ` [PATCH AUTOSEL for 4.15 091/102] mac80211_hwsim: enforce PS_MANUAL_POLL to be set after PS_ENABLED Sasha Levin
2018-03-03 22:25 ` [PATCH AUTOSEL for 4.15 093/102] crypto: caam/qi - use correct print specifier for size_t Sasha Levin
2018-03-03 22:25 ` [PATCH AUTOSEL for 4.15 092/102] mac80211: remove BUG() when interface type is invalid Sasha Levin
2018-03-03 22:25 ` [PATCH AUTOSEL for 4.15 094/102] ASoC: nuc900: Fix a loop timeout test Sasha Levin
2018-03-03 22:25 ` [PATCH AUTOSEL for 4.15 095/102] mmc: mmc_test: Ensure command queue is disabled for testing Sasha Levin
2018-03-03 22:25 ` [PATCH AUTOSEL for 4.15 096/102] Fix misannotated out-of-line _copy_to_user() Sasha Levin
2018-03-03 22:25 ` [PATCH AUTOSEL for 4.15 097/102] ipvlan: add L2 check for packets arriving via virtual devices Sasha Levin
2018-03-03 22:25 ` [PATCH AUTOSEL for 4.15 098/102] rcutorture/configinit: Fix build directory error message Sasha Levin
2018-03-03 22:25 ` [PATCH AUTOSEL for 4.15 099/102] locking/locktorture: Fix num reader/writer corner cases Sasha Levin
2018-03-03 22:25 ` [PATCH AUTOSEL for 4.15 100/102] ima: relax requiring a file signature for new files with zero length Sasha Levin
2018-03-03 22:25 ` [PATCH AUTOSEL for 4.15 102/102] dmaengine: qcom_hidma: check pending interrupts Sasha Levin
2018-03-03 22:25 ` [PATCH AUTOSEL for 4.15 101/102] IB/mlx5: revisit -Wmaybe-uninitialized warning Sasha Levin
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=20180303222318.26006-4-alexander.levin@microsoft.com \
--to=alexander.levin@microsoft.com \
--cc=chris@chris-wilson.co.uk \
--cc=christian.koenig@amd.com \
--cc=gustavo.padovan@collabora.co.uk \
--cc=linux-kernel@vger.kernel.org \
--cc=robdclark@gmail.com \
--cc=stable@vger.kernel.org \
--cc=sumit.semwal@linaro.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox