mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Luis Henriques <luis.henriques@canonical.com>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org,
	kernel-team@lists.ubuntu.com
Cc: Ingo Molnar <mingo@elte.hu>, Steven Rostedt <rostedt@goodmis.org>,
	Dan Williams <dan.j.williams@intel.com>,
	Ben Hutchings <ben@decadent.org.uk>,
	Luis Henriques <luis.henriques@canonical.com>
Subject: [PATCH 3.5 71/71] ioat: fix tasklet tear down
Date: Mon, 31 Mar 2014 14:23:17 +0100	[thread overview]
Message-ID: <1396272197-13394-72-git-send-email-luis.henriques@canonical.com> (raw)
In-Reply-To: <1396272197-13394-1-git-send-email-luis.henriques@canonical.com>

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

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

From: Ben Hutchings <ben@decadent.org.uk>

commit da87ca4d4ca101f177fffd84f1f0a5e4c0343557 upstream.

Since commit 77873803363c "net_dma: mark broken" we no longer pin dma
engines active for the network-receive-offload use case.  As a result
the ->free_chan_resources() that occurs after the driver self test no
longer has a NET_DMA induced ->alloc_chan_resources() to back it up.  A
late firing irq can lead to ksoftirqd spinning indefinitely due to the
tasklet_disable() performed by ->free_chan_resources().  Only
->alloc_chan_resources() can clear this condition in affected kernels.

This problem has been present since commit 3e037454bcfa "I/OAT: Add
support for MSI and MSI-X" in 2.6.24, but is now exposed. Given the
NET_DMA use case is deprecated we can revisit moving the driver to use
threaded irqs.  For now, just tear down the irq and tasklet properly by:

1/ Disable the irq from triggering the tasklet

2/ Disable the irq from re-arming

3/ Flush inflight interrupts

4/ Flush the timer

5/ Flush inflight tasklets

References:
https://lkml.org/lkml/2014/1/27/282
https://lkml.org/lkml/2014/2/19/672

Cc: Ingo Molnar <mingo@elte.hu>
Cc: Steven Rostedt <rostedt@goodmis.org>
Reported-by: Mike Galbraith <bitbucket@online.de>
Reported-by: Stanislav Fomichev <stfomichev@yandex-team.ru>
Tested-by: Mike Galbraith <bitbucket@online.de>
Tested-by: Stanislav Fomichev <stfomichev@yandex-team.ru>
Reviewed-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
[bwh: Backported to 3.2:
 - Adjust context
 - As there is no ioatdma_device::irq_mode member, check
   pci_dev::msix_enabled instead]
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
Signed-off-by: Luis Henriques <luis.henriques@canonical.com>
---
 drivers/dma/ioat/dma.c    | 46 +++++++++++++++++++++++++++++++++++++++-------
 drivers/dma/ioat/dma.h    |  1 +
 drivers/dma/ioat/dma_v2.c | 11 +++++------
 drivers/dma/ioat/dma_v3.c |  3 +++
 4 files changed, 48 insertions(+), 13 deletions(-)

diff --git a/drivers/dma/ioat/dma.c b/drivers/dma/ioat/dma.c
index 73b2b65..662bec1 100644
--- a/drivers/dma/ioat/dma.c
+++ b/drivers/dma/ioat/dma.c
@@ -77,7 +77,8 @@ static irqreturn_t ioat_dma_do_interrupt(int irq, void *data)
 	attnstatus = readl(instance->reg_base + IOAT_ATTNSTATUS_OFFSET);
 	for_each_set_bit(bit, &attnstatus, BITS_PER_LONG) {
 		chan = ioat_chan_by_index(instance, bit);
-		tasklet_schedule(&chan->cleanup_task);
+		if (test_bit(IOAT_RUN, &chan->state))
+			tasklet_schedule(&chan->cleanup_task);
 	}
 
 	writeb(intrctrl, instance->reg_base + IOAT_INTRCTRL_OFFSET);
@@ -93,7 +94,8 @@ static irqreturn_t ioat_dma_do_interrupt_msix(int irq, void *data)
 {
 	struct ioat_chan_common *chan = data;
 
-	tasklet_schedule(&chan->cleanup_task);
+	if (test_bit(IOAT_RUN, &chan->state))
+		tasklet_schedule(&chan->cleanup_task);
 
 	return IRQ_HANDLED;
 }
@@ -116,7 +118,6 @@ void ioat_init_channel(struct ioatdma_device *device, struct ioat_chan_common *c
 	chan->timer.function = device->timer_fn;
 	chan->timer.data = data;
 	tasklet_init(&chan->cleanup_task, device->cleanup_fn, data);
-	tasklet_disable(&chan->cleanup_task);
 }
 
 /**
@@ -354,13 +355,43 @@ static int ioat1_dma_alloc_chan_resources(struct dma_chan *c)
 	writel(((u64) chan->completion_dma) >> 32,
 	       chan->reg_base + IOAT_CHANCMP_OFFSET_HIGH);
 
-	tasklet_enable(&chan->cleanup_task);
+	set_bit(IOAT_RUN, &chan->state);
 	ioat1_dma_start_null_desc(ioat);  /* give chain to dma device */
 	dev_dbg(to_dev(chan), "%s: allocated %d descriptors\n",
 		__func__, ioat->desccount);
 	return ioat->desccount;
 }
 
+void ioat_stop(struct ioat_chan_common *chan)
+{
+	struct ioatdma_device *device = chan->device;
+	struct pci_dev *pdev = device->pdev;
+	int chan_id = chan_num(chan);
+
+	/* 1/ stop irq from firing tasklets
+	 * 2/ stop the tasklet from re-arming irqs
+	 */
+	clear_bit(IOAT_RUN, &chan->state);
+
+	/* flush inflight interrupts */
+#ifdef CONFIG_PCI_MSI
+	if (pdev->msix_enabled) {
+		struct msix_entry *msix = &device->msix_entries[chan_id];
+		synchronize_irq(msix->vector);
+	} else
+#endif
+		synchronize_irq(pdev->irq);
+
+	/* flush inflight timers */
+	del_timer_sync(&chan->timer);
+
+	/* flush inflight tasklet runs */
+	tasklet_kill(&chan->cleanup_task);
+
+	/* final cleanup now that everything is quiesced and can't re-arm */
+	device->cleanup_fn((unsigned long) &chan->common);
+}
+
 /**
  * ioat1_dma_free_chan_resources - release all the descriptors
  * @chan: the channel to be cleaned
@@ -379,9 +410,7 @@ static void ioat1_dma_free_chan_resources(struct dma_chan *c)
 	if (ioat->desccount == 0)
 		return;
 
-	tasklet_disable(&chan->cleanup_task);
-	del_timer_sync(&chan->timer);
-	ioat1_cleanup(ioat);
+	ioat_stop(chan);
 
 	/* Delay 100ms after reset to allow internal DMA logic to quiesce
 	 * before removing DMA descriptor resources.
@@ -526,8 +555,11 @@ ioat1_dma_prep_memcpy(struct dma_chan *c, dma_addr_t dma_dest,
 static void ioat1_cleanup_event(unsigned long data)
 {
 	struct ioat_dma_chan *ioat = to_ioat_chan((void *) data);
+	struct ioat_chan_common *chan = &ioat->base;
 
 	ioat1_cleanup(ioat);
+	if (!test_bit(IOAT_RUN, &chan->state))
+		return;
 	writew(IOAT_CHANCTRL_RUN, ioat->base.reg_base + IOAT_CHANCTRL_OFFSET);
 }
 
diff --git a/drivers/dma/ioat/dma.h b/drivers/dma/ioat/dma.h
index 5e8fe01..ee17c80 100644
--- a/drivers/dma/ioat/dma.h
+++ b/drivers/dma/ioat/dma.h
@@ -321,6 +321,7 @@ bool ioat_cleanup_preamble(struct ioat_chan_common *chan,
 			   dma_addr_t *phys_complete);
 void ioat_kobject_add(struct ioatdma_device *device, struct kobj_type *type);
 void ioat_kobject_del(struct ioatdma_device *device);
+void ioat_stop(struct ioat_chan_common *chan);
 extern const struct sysfs_ops ioat_sysfs_ops;
 extern struct ioat_sysfs_entry ioat_version_attr;
 extern struct ioat_sysfs_entry ioat_cap_attr;
diff --git a/drivers/dma/ioat/dma_v2.c b/drivers/dma/ioat/dma_v2.c
index 8689576..ae39935 100644
--- a/drivers/dma/ioat/dma_v2.c
+++ b/drivers/dma/ioat/dma_v2.c
@@ -190,8 +190,11 @@ static void ioat2_cleanup(struct ioat2_dma_chan *ioat)
 void ioat2_cleanup_event(unsigned long data)
 {
 	struct ioat2_dma_chan *ioat = to_ioat2_chan((void *) data);
+	struct ioat_chan_common *chan = &ioat->base;
 
 	ioat2_cleanup(ioat);
+	if (!test_bit(IOAT_RUN, &chan->state))
+		return;
 	writew(IOAT_CHANCTRL_RUN, ioat->base.reg_base + IOAT_CHANCTRL_OFFSET);
 }
 
@@ -539,10 +542,10 @@ int ioat2_alloc_chan_resources(struct dma_chan *c)
 	ioat->issued = 0;
 	ioat->tail = 0;
 	ioat->alloc_order = order;
+	set_bit(IOAT_RUN, &chan->state);
 	spin_unlock_bh(&ioat->prep_lock);
 	spin_unlock_bh(&chan->cleanup_lock);
 
-	tasklet_enable(&chan->cleanup_task);
 	ioat2_start_null_desc(ioat);
 
 	/* check that we got off the ground */
@@ -552,7 +555,6 @@ int ioat2_alloc_chan_resources(struct dma_chan *c)
 	} while (i++ < 20 && !is_ioat_active(status) && !is_ioat_idle(status));
 
 	if (is_ioat_active(status) || is_ioat_idle(status)) {
-		set_bit(IOAT_RUN, &chan->state);
 		return 1 << ioat->alloc_order;
 	} else {
 		u32 chanerr = readl(chan->reg_base + IOAT_CHANERR_OFFSET);
@@ -795,11 +797,8 @@ void ioat2_free_chan_resources(struct dma_chan *c)
 	if (!ioat->ring)
 		return;
 
-	tasklet_disable(&chan->cleanup_task);
-	del_timer_sync(&chan->timer);
-	device->cleanup_fn((unsigned long) c);
+	ioat_stop(chan);
 	device->reset_hw(chan);
-	clear_bit(IOAT_RUN, &chan->state);
 
 	spin_lock_bh(&chan->cleanup_lock);
 	spin_lock_bh(&ioat->prep_lock);
diff --git a/drivers/dma/ioat/dma_v3.c b/drivers/dma/ioat/dma_v3.c
index ed0e8b7..178d199 100644
--- a/drivers/dma/ioat/dma_v3.c
+++ b/drivers/dma/ioat/dma_v3.c
@@ -325,8 +325,11 @@ static void ioat3_cleanup(struct ioat2_dma_chan *ioat)
 static void ioat3_cleanup_event(unsigned long data)
 {
 	struct ioat2_dma_chan *ioat = to_ioat2_chan((void *) data);
+	struct ioat_chan_common *chan = &ioat->base;
 
 	ioat3_cleanup(ioat);
+	if (!test_bit(IOAT_RUN, &chan->state))
+		return;
 	writew(IOAT_CHANCTRL_RUN, ioat->base.reg_base + IOAT_CHANCTRL_OFFSET);
 }
 
-- 
1.9.1


  parent reply	other threads:[~2014-03-31 13:26 UTC|newest]

Thread overview: 74+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-03-31 13:22 [3.5.y.z extended stable] Linux 3.5.7.33 stable review Luis Henriques
2014-03-31 13:22 ` [PATCH 3.5 01/71] ALSA: oxygen: Xonar DG(X): capture from I2S channel 1, not 2 Luis Henriques
2014-03-31 13:22 ` [PATCH 3.5 02/71] ALSA: oxygen: Xonar DG(X): modify DAC routing Luis Henriques
2014-03-31 13:22 ` [PATCH 3.5 03/71] mac80211: fix AP powersave TX vs. wakeup race Luis Henriques
2014-03-31 13:22 ` [PATCH 3.5 04/71] iwlwifi: dvm: clear IWL_STA_UCODE_INPROGRESS when assoc fails Luis Henriques
2014-03-31 13:22 ` [PATCH 3.5 05/71] ath9k: protect tid->sched check Luis Henriques
2014-03-31 13:22 ` [PATCH 3.5 06/71] ath9k: Fix ETSI compliance for AR9462 2.0 Luis Henriques
2014-03-31 13:22 ` [PATCH 3.5 07/71] genirq: Remove racy waitqueue_active check Luis Henriques
2014-03-31 13:22 ` [PATCH 3.5 08/71] sched: Fix double normalization of vruntime Luis Henriques
2014-03-31 13:22 ` [PATCH 3.5 09/71] cpuset: fix a race condition in __cpuset_node_allowed_softwall() Luis Henriques
2014-03-31 13:22 ` [PATCH 3.5 10/71] firewire: net: fix use after free Luis Henriques
2014-03-31 13:22 ` [PATCH 3.5 11/71] mwifiex: do not advertise usb autosuspend support Luis Henriques
2014-03-31 13:22 ` [PATCH 3.5 12/71] NFS: Fix a delegation callback race Luis Henriques
2014-03-31 13:22 ` [PATCH 3.5 13/71] can: flexcan: fix shutdown: first disable chip, then all interrupts Luis Henriques
2014-03-31 13:22 ` [PATCH 3.5 14/71] can: flexcan: flexcan_open(): fix error path if flexcan_chip_start() fails Luis Henriques
2014-03-31 13:22 ` [PATCH 3.5 15/71] tracing: Do not add event files for modules that fail tracepoints Luis Henriques
2014-03-31 13:22 ` [PATCH 3.5 16/71] ocfs2: fix quota file corruption Luis Henriques
2014-03-31 13:22 ` [PATCH 3.5 17/71] rapidio/tsi721: fix tasklet termination in dma channel release Luis Henriques
2014-03-31 13:22 ` [PATCH 3.5 18/71] ALSA: usb-audio: Add quirk for Logitech Webcam C500 Luis Henriques
2014-03-31 13:22 ` [PATCH 3.5 19/71] drm/radeon: TTM must be init with cpu-visible VRAM, v2 Luis Henriques
2014-03-31 13:22 ` [PATCH 3.5 20/71] drm/radeon/atom: select the proper number of lanes in transmitter setup Luis Henriques
2014-03-31 13:22 ` [PATCH 3.5 21/71] powerpc: Align p_dyn, p_rela and p_st symbols Luis Henriques
2014-03-31 13:22 ` [PATCH 3.5 22/71] libata: add ATA_HORKAGE_BROKEN_FPDMA_AA quirk for Seagate Momentus SpinPoint M8 (2BA30001) Luis Henriques
2014-03-31 13:22 ` [PATCH 3.5 23/71] usb: Add device quirk for Logitech HD Pro Webcams C920 and C930e Luis Henriques
2014-03-31 13:22 ` [PATCH 3.5 24/71] usb: Make DELAY_INIT quirk wait 100ms between Get Configuration requests Luis Henriques
2014-03-31 13:22 ` [PATCH 3.5 25/71] ARM: 7991/1: sa1100: fix compile problem on Collie Luis Henriques
2014-03-31 13:22 ` [PATCH 3.5 26/71] firewire: don't use PREPARE_DELAYED_WORK Luis Henriques
2014-03-31 13:22 ` [PATCH 3.5 27/71] x86: Ignore NMIs that come in during early boot Luis Henriques
2014-03-31 13:22 ` [PATCH 3.5 28/71] x86: fix compile error due to X86_TRAP_NMI use in asm files Luis Henriques
2014-03-31 13:22 ` [PATCH 3.5 29/71] virtio-net: alloc big buffers also when guest can receive UFO Luis Henriques
2014-03-31 13:22 ` [PATCH 3.5 30/71] tg3: Don't check undefined error bits in RXBD Luis Henriques
2014-03-31 13:22 ` [PATCH 3.5 31/71] net: sctp: fix sctp_sf_do_5_1D_ce to verify if we/peer is AUTH capable Luis Henriques
2014-03-31 13:22 ` [PATCH 3.5 32/71] usb: dwc3: add support for Merrifield Luis Henriques
2014-03-31 13:22 ` [PATCH 3.5 33/71] mac80211: clear sequence/fragment number in QoS-null frames Luis Henriques
2014-03-31 13:22 ` [PATCH 3.5 34/71] mwifiex: copy AP's HT capability info correctly Luis Henriques
2014-03-31 13:22 ` [PATCH 3.5 35/71] net: unix socket code abuses csum_partial Luis Henriques
2014-03-31 13:22 ` [PATCH 3.5 36/71] ibmveth: Fix endian issues with MAC addresses Luis Henriques
2014-03-31 13:22 ` [PATCH 3.5 37/71] [SCSI] isci: fix reset timeout handling Luis Henriques
2014-03-31 13:22 ` [PATCH 3.5 38/71] [SCSI] isci: correct erroneous for_each_isci_host macro Luis Henriques
2014-03-31 13:22 ` [PATCH 3.5 39/71] [SCSI] qla2xxx: Poll during initialization for ISP25xx and ISP83xx Luis Henriques
2014-03-31 13:22 ` [PATCH 3.5 40/71] ocfs2 syncs the wrong range Luis Henriques
2014-03-31 13:22 ` [PATCH 3.5 41/71] fs/proc/base.c: fix GPF in /proc/$PID/map_files Luis Henriques
2014-03-31 13:22 ` [PATCH 3.5 42/71] vmxnet3: fix netpoll race condition Luis Henriques
2014-03-31 13:22 ` [PATCH 3.5 43/71] [SCSI] storvsc: NULL pointer dereference fix Luis Henriques
2014-03-31 13:22 ` [PATCH 3.5 44/71] PCI: Enable INTx in pci_reenable_device() only when MSI/MSI-X not enabled Luis Henriques
2014-03-31 13:22 ` [PATCH 3.5 45/71] KVM: SVM: fix cr8 intercept window Luis Henriques
2014-03-31 13:22 ` [PATCH 3.5 46/71] drm/ttm: don't oops if no invalidate_caches() Luis Henriques
2014-03-31 13:22 ` [PATCH 3.5 47/71] vmxnet3: fix building without CONFIG_PCI_MSI Luis Henriques
2014-03-31 13:22 ` [PATCH 3.5 48/71] x86/amd/numa: Fix northbridge quirk to assign correct NUMA node Luis Henriques
2014-03-31 13:22 ` [PATCH 3.5 49/71] Btrfs: fix data corruption when reading/updating compressed extents Luis Henriques
2014-03-31 13:22 ` [PATCH 3.5 50/71] jiffies: Avoid undefined behavior from signed overflow Luis Henriques
2014-03-31 13:22 ` [PATCH 3.5 51/71] ALSA: compress: Pass through return value of open ops callback Luis Henriques
2014-03-31 13:22 ` [PATCH 3.5 52/71] acpi-cpufreq: set current frequency based on target P-State Luis Henriques
2014-03-31 13:22 ` [PATCH 3.5 53/71] hpfs: deadlock and race in directory lseek() Luis Henriques
2014-03-31 13:23 ` [PATCH 3.5 54/71] intel_idle: Check cpu_idle_get_driver() for NULL before dereferencing it Luis Henriques
2014-03-31 13:23 ` [PATCH 3.5 55/71] ipc/msg: fix race around refcount Luis Henriques
2014-03-31 13:23 ` [PATCH 3.5 56/71] Input: synaptics - add manual min/max quirk Luis Henriques
2014-03-31 13:23 ` [PATCH 3.5 57/71] Input: synaptics - add manual min/max quirk for ThinkPad X240 Luis Henriques
2014-03-31 13:23 ` [PATCH 3.5 58/71] x86: fix boot on uniprocessor systems Luis Henriques
2014-03-31 13:23 ` [PATCH 3.5 59/71] staging: speakup: Prefix externally-visible symbols Luis Henriques
2014-03-31 13:23 ` [PATCH 3.5 60/71] ext4: atomically set inode->i_flags in ext4_set_inode_flags() Luis Henriques
2014-03-31 13:23 ` [PATCH 3.5 61/71] deb-pkg: Fix cross-building linux-headers package Luis Henriques
2014-03-31 13:23 ` [PATCH 3.5 62/71] x86: bpf_jit: support negative offsets Luis Henriques
2014-03-31 13:23 ` [PATCH 3.5 63/71] p54: clamp properly instead of just truncating Luis Henriques
2014-03-31 13:23 ` [PATCH 3.5 64/71] ALSA: hda/realtek - Avoid invalid COEFs for ALC271X Luis Henriques
2014-03-31 13:23 ` [PATCH 3.5 65/71] of: Fix address decoding on Bimini and js2x machines Luis Henriques
2014-03-31 13:23 ` [PATCH 3.5 66/71] of: fix PCI bus match for PCIe slots Luis Henriques
2014-03-31 13:23 ` [PATCH 3.5 67/71] libata: disable LPM for some WD SATA-I devices Luis Henriques
2014-03-31 13:23 ` [PATCH 3.5 68/71] mmc: sdhci: fix lockdep error in tuning routine Luis Henriques
2014-03-31 13:23 ` [PATCH 3.5 69/71] usb: ehci: add freescale imx28 special write register method Luis Henriques
2014-03-31 13:23 ` [PATCH 3.5 70/71] USB: pl2303: fix data corruption on termios updates Luis Henriques
2014-03-31 13:23 ` Luis Henriques [this message]
2014-04-04  0:13   ` [PATCH 3.5 71/71] ioat: fix tasklet tear down Ben Hutchings
2014-04-04  8:32     ` Luís Henriques

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=1396272197-13394-72-git-send-email-luis.henriques@canonical.com \
    --to=luis.henriques@canonical.com \
    --cc=ben@decadent.org.uk \
    --cc=dan.j.williams@intel.com \
    --cc=kernel-team@lists.ubuntu.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=rostedt@goodmis.org \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®