From: Ben Hutchings <ben@decadent.org.uk>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: torvalds@linux-foundation.org, akpm@linux-foundation.org,
alan@lxorguk.ukuu.org.uk, Daniel Vetter <daniel.vetter@ffwll.ch>,
Chris Wilson <chris@chris-wilson.co.uk>
Subject: [ 16/37] drm/i915: fixup seqno allocation logic for lazy_request
Date: Fri, 17 Aug 2012 04:02:59 +0100 [thread overview]
Message-ID: <20120817030246.259786839@decadent.org.uk> (raw)
In-Reply-To: <20120817030243.807605523@decadent.org.uk>
3.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Daniel Vetter <daniel.vetter@ffwll.ch>
commit 53d227f282eb9fa4c7cdbfd691fa372b7ca8c4c3 upstream.
Currently we reserve seqnos only when we emit the request to the ring
(by bumping dev_priv->next_seqno), but start using it much earlier for
ring->oustanding_lazy_request. When 2 threads compete for the gpu and
run on two different rings (e.g. ddx on blitter vs. compositor)
hilarity ensued, especially when we get constantly interrupted while
reserving buffers.
Breakage seems to have been introduced in
commit 6f392d548658a17600da7faaf8a5df25ee5f01f6
Author: Chris Wilson <chris@chris-wilson.co.uk>
Date: Sat Aug 7 11:01:22 2010 +0100
drm/i915: Use a common seqno for all rings.
This patch fixes up the seqno reservation logic by moving it into
i915_gem_next_request_seqno. The ring->add_request functions now
superflously still return the new seqno through a pointer, that will
be refactored in the next patch.
Note that with this change we now unconditionally allocate a seqno,
even when ->add_request might fail because the rings are full and the
gpu died. But this does not open up a new can of worms because we can
already leave behind an outstanding_request_seqno if e.g. the caller
gets interrupted with a signal while stalling for the gpu in the
eviciton paths. And with the bugfix we only ever have one seqno
allocated per ring (and only that ring), so there are no ordering
issues with multiple outstanding seqnos on the same ring.
v2: Keep i915_gem_get_seqno (but move it to i915_gem.c) to make it
clear that we only have one seqno counter for all rings. Suggested by
Chris Wilson.
v3: As suggested by Chris Wilson use i915_gem_next_request_seqno
instead of ring->oustanding_lazy_request to make the follow-up
refactoring more clearly correct. Also improve the commit message
with issues discussed on irc.
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=45181
Tested-by: Nicolas Kalkhof nkalkhof()at()web.de
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
Signed-Off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
---
drivers/gpu/drm/i915/i915_drv.h | 7 +------
drivers/gpu/drm/i915/i915_gem.c | 23 +++++++++++++++++++++++
drivers/gpu/drm/i915/intel_ringbuffer.c | 24 ++++--------------------
3 files changed, 28 insertions(+), 26 deletions(-)
diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
index 000a9ad..563d24e 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -1177,12 +1177,7 @@ i915_seqno_passed(uint32_t seq1, uint32_t seq2)
return (int32_t)(seq1 - seq2) >= 0;
}
-static inline u32
-i915_gem_next_request_seqno(struct intel_ring_buffer *ring)
-{
- drm_i915_private_t *dev_priv = ring->dev->dev_private;
- return ring->outstanding_lazy_request = dev_priv->next_seqno;
-}
+u32 i915_gem_next_request_seqno(struct intel_ring_buffer *ring);
int __must_check i915_gem_object_get_fence(struct drm_i915_gem_object *obj,
struct intel_ring_buffer *pipelined);
diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
index 2b51e9c..2031cc7 100644
--- a/drivers/gpu/drm/i915/i915_gem.c
+++ b/drivers/gpu/drm/i915/i915_gem.c
@@ -1576,6 +1576,28 @@ i915_gem_process_flushing_list(struct intel_ring_buffer *ring,
}
}
+static u32
+i915_gem_get_seqno(struct drm_device *dev)
+{
+ drm_i915_private_t *dev_priv = dev->dev_private;
+ u32 seqno = dev_priv->next_seqno;
+
+ /* reserve 0 for non-seqno */
+ if (++dev_priv->next_seqno == 0)
+ dev_priv->next_seqno = 1;
+
+ return seqno;
+}
+
+u32
+i915_gem_next_request_seqno(struct intel_ring_buffer *ring)
+{
+ if (ring->outstanding_lazy_request == 0)
+ ring->outstanding_lazy_request = i915_gem_get_seqno(ring->dev);
+
+ return ring->outstanding_lazy_request;
+}
+
int
i915_add_request(struct intel_ring_buffer *ring,
struct drm_file *file,
@@ -1587,6 +1609,7 @@ i915_add_request(struct intel_ring_buffer *ring,
int ret;
BUG_ON(request == NULL);
+ seqno = i915_gem_next_request_seqno(ring);
ret = ring->add_request(ring, &seqno);
if (ret)
diff --git a/drivers/gpu/drm/i915/intel_ringbuffer.c b/drivers/gpu/drm/i915/intel_ringbuffer.c
index 4956f1b..8a983b5 100644
--- a/drivers/gpu/drm/i915/intel_ringbuffer.c
+++ b/drivers/gpu/drm/i915/intel_ringbuffer.c
@@ -52,20 +52,6 @@ static inline int ring_space(struct intel_ring_buffer *ring)
return space;
}
-static u32 i915_gem_get_seqno(struct drm_device *dev)
-{
- drm_i915_private_t *dev_priv = dev->dev_private;
- u32 seqno;
-
- seqno = dev_priv->next_seqno;
-
- /* reserve 0 for non-seqno */
- if (++dev_priv->next_seqno == 0)
- dev_priv->next_seqno = 1;
-
- return seqno;
-}
-
static int
render_ring_flush(struct intel_ring_buffer *ring,
u32 invalidate_domains,
@@ -465,7 +451,7 @@ gen6_add_request(struct intel_ring_buffer *ring,
mbox1_reg = ring->signal_mbox[0];
mbox2_reg = ring->signal_mbox[1];
- *seqno = i915_gem_get_seqno(ring->dev);
+ *seqno = i915_gem_next_request_seqno(ring);
update_mboxes(ring, *seqno, mbox1_reg);
update_mboxes(ring, *seqno, mbox2_reg);
@@ -563,8 +549,7 @@ static int
pc_render_add_request(struct intel_ring_buffer *ring,
u32 *result)
{
- struct drm_device *dev = ring->dev;
- u32 seqno = i915_gem_get_seqno(dev);
+ u32 seqno = i915_gem_next_request_seqno(ring);
struct pipe_control *pc = ring->private;
u32 scratch_addr = pc->gtt_offset + 128;
int ret;
@@ -615,8 +600,7 @@ static int
render_ring_add_request(struct intel_ring_buffer *ring,
u32 *result)
{
- struct drm_device *dev = ring->dev;
- u32 seqno = i915_gem_get_seqno(dev);
+ u32 seqno = i915_gem_next_request_seqno(ring);
int ret;
ret = intel_ring_begin(ring, 4);
@@ -790,7 +774,7 @@ ring_add_request(struct intel_ring_buffer *ring,
if (ret)
return ret;
- seqno = i915_gem_get_seqno(ring->dev);
+ seqno = i915_gem_next_request_seqno(ring);
intel_ring_emit(ring, MI_STORE_DWORD_INDEX);
intel_ring_emit(ring, I915_GEM_HWS_INDEX << MI_STORE_DWORD_INDEX_SHIFT);
next prev parent reply other threads:[~2012-08-17 3:34 UTC|newest]
Thread overview: 43+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-08-17 3:02 [ 00/37] 3.2.28-stable review Ben Hutchings
2012-08-17 3:02 ` [ 01/37] bnx2: Fix bug in bnx2_free_tx_skbs() Ben Hutchings
2012-08-17 3:02 ` [ 02/37] sch_sfb: Fix missing NULL check Ben Hutchings
2012-08-17 3:02 ` [ 03/37] sctp: Fix list corruption resulting from freeing an association on a list Ben Hutchings
2012-08-17 3:02 ` [ 04/37] caif: Fix access to freed pernet memory Ben Hutchings
2012-08-17 3:02 ` [ 05/37] cipso: dont follow a NULL pointer when setsockopt() is called Ben Hutchings
2012-08-17 3:02 ` [ 06/37] caif: fix NULL pointer check Ben Hutchings
2012-08-17 3:02 ` [ 07/37] wanmain: comparing array with NULL Ben Hutchings
2012-08-17 3:02 ` [ 08/37] tcp: Add TCP_USER_TIMEOUT negative value check Ben Hutchings
2012-08-17 3:02 ` [ 09/37] USB: kaweth.c: use GFP_ATOMIC under spin_lock Ben Hutchings
2012-08-17 3:02 ` [ 10/37] net: fix rtnetlink IFF_PROMISC and IFF_ALLMULTI handling Ben Hutchings
2012-08-17 3:02 ` [ 11/37] tcp: perform DMA to userspace only if there is a task waiting for it Ben Hutchings
2012-08-17 3:02 ` [ 12/37] net/tun: fix ioctl() based info leaks Ben Hutchings
2012-08-17 3:02 ` [ 13/37] e1000: add dropped DMA receive enable back in for WoL Ben Hutchings
2012-08-17 3:02 ` [ 14/37] rtlwifi: rtl8192cu: Change buffer allocation for synchronous reads Ben Hutchings
2012-08-17 3:02 ` [ 15/37] hfsplus: fix overflow in sector calculations in hfsplus_submit_bio Ben Hutchings
2012-08-17 3:02 ` Ben Hutchings [this message]
2012-08-17 3:03 ` [ 17/37] KVM: VMX: Advertise CPU_BASED_RDPMC_EXITING for nested guests Ben Hutchings
2012-08-17 3:03 ` [ 18/37] mac80211: cancel mesh path timer Ben Hutchings
2012-08-17 3:03 ` [ 19/37] ath9k: Add PID/VID support for AR1111 Ben Hutchings
2012-08-17 3:03 ` [ 20/37] ARM: mxs: Remove MMAP_MIN_ADDR setting from mxs_defconfig Ben Hutchings
2012-08-17 3:03 ` [ 21/37] ALSA: hda - add dock support for Thinkpad T430s Ben Hutchings
2012-08-17 3:03 ` [ 22/37] cfg80211: process pending events when unregistering net device Ben Hutchings
2012-08-17 3:03 ` [ 23/37] rt61pci: fix NULL pointer dereference in config_lna_gain Ben Hutchings
2012-08-17 3:03 ` [ 24/37] iwlwifi: disable greenfield transmissions as a workaround Ben Hutchings
2012-08-17 3:03 ` [ 25/37] ALSA: hda - add dock support for Thinkpad X230 Ben Hutchings
2012-08-17 3:03 ` [ 26/37] e1000e: NIC goes up and immediately goes down Ben Hutchings
2012-08-17 3:03 ` [ 27/37] ALSA: hda - remove quirk for Dell Vostro 1015 Ben Hutchings
2012-08-17 3:03 ` [ 28/37] ALSA: hda - Fix double quirk for Quanta FL1 / Lenovo Ideapad Ben Hutchings
2012-08-17 3:03 ` [ 29/37] ARM: pxa: remove irq_to_gpio from ezx-pcap driver Ben Hutchings
2012-08-17 3:03 ` [ 30/37] Input: eeti_ts: pass gpio value instead of IRQ Ben Hutchings
2012-08-17 3:03 ` [ 31/37] tun: dont zeroize sock->file on detach Ben Hutchings
2012-08-19 17:13 ` Ben Hutchings
2012-08-17 3:03 ` [ 32/37] drm/i915: correctly order the ring init sequence Ben Hutchings
2012-08-17 23:29 ` Herton Ronaldo Krzesinski
2012-08-18 10:04 ` Daniel Vetter
2012-08-19 14:54 ` Ben Hutchings
2012-08-19 19:00 ` Herton Ronaldo Krzesinski
2012-08-17 3:03 ` [ 33/37] s390/compat: fix compat wrappers for process_vm system calls Ben Hutchings
2012-08-17 3:03 ` [ 34/37] s390/compat: fix mmap compat " Ben Hutchings
2012-08-17 3:03 ` [ 35/37] drm/radeon: fix bank tiling parameters on evergreen Ben Hutchings
2012-08-17 3:03 ` [ 36/37] drm/radeon: fix bank tiling parameters on cayman Ben Hutchings
2012-08-17 3:03 ` [ 37/37] drm/radeon: do not reenable crtc after moving vram start address Ben Hutchings
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=20120817030246.259786839@decadent.org.uk \
--to=ben@decadent.org.uk \
--cc=akpm@linux-foundation.org \
--cc=alan@lxorguk.ukuu.org.uk \
--cc=chris@chris-wilson.co.uk \
--cc=daniel.vetter@ffwll.ch \
--cc=linux-kernel@vger.kernel.org \
--cc=stable@vger.kernel.org \
--cc=torvalds@linux-foundation.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.