From: Keith Packard <keithp@keithp.com>
To: Daniel Vetter <daniel@ffwll.ch>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>,
intel-gfx <intel-gfx@lists.freedesktop.org>
Subject: Re: [PATCH 06/43] drm/i915: protect force_wake_(get|put) with the gt_lock
Date: Wed, 04 Jan 2012 18:22:41 -0800 [thread overview]
Message-ID: <86fwfulwge.fsf@sumi.keithp.com> (raw)
In-Reply-To: <20120104181257.GI8004@phenom.ffwll.local>
[-- Attachment #1.1: Type: text/plain, Size: 2683 bytes --]
On Wed, 4 Jan 2012 19:12:57 +0100, Daniel Vetter <daniel@ffwll.ch> wrote:
> The "Correct?" was just to check my understanding of your concern, I still
> think its invalid. You've cut away the second part of my mail where I
> explain why and I don't see you responding to that here. Also
> micro-optimizing the gpu reset code sounds a bit strange.
Sorry, I didn't explain things very well.
Right now, our register access looks like:
get(struct_mutex);
if (++forcewake_count == 1)
force_wake_get()
value = read32(reg) or write32(reg, val)
if (--forcewake_count == 0)
force_wake_put();
/* more register accesses may follow ... */
put(struct_mutex);
All very sensible, the whole register sequence is covered by
struct_mutex, which ensures that the forcewake is set across the
register access.
The patch does:
get(spin_lock)
if (++forcewake_count == 1)
force_wake_get()
put(spin_lock)
value = read32(reg) or write32(reg, val)
get(spin_lock)
if (--forcewake_count == 0)
force_wake_put()
put(spin_lock)
I realize that all current users hold the struct_mutex across this whole
sequence, aside from the reset path, but we're removing that requirement
explicitly (the patch removes the WARN_ON calls).
Without a lock held across the whole sequence, it's easy to see how a
race could occur. We're also dropping and re-acquiring a spinlock with a
single instruction between, which seems wasteful. Instead, we should be
doing:
get(spin_lock)
force_wake_get();
value = read32(reg) or write32(reg,val)
force_wake_put();
put(spin_lock);
No need here to deal with the wake lock at reset time; the whole
operation is atomic wrt interrupts. It's more efficient *and* correct,
without depending on the old struct_mutex locking.
If you want to continue to expose the user-mode wake lock stuff, you
could add:
get(spin_lock);
if (!forcewake_count)
force_wake_get();
value = read32(reg) or write32(reg,val)
if (!forcewake_count)
force_wake_put();
put(spin_lock);
This would require that the reset code also deal with the
forcewake_count to restore the user-mode force wake.
A further optimization would hold the force_wake active for 'a while' to
avoid the extra bus cycles required, but we'd want to see a performance
problem from this before doing that.
--
keith.packard@intel.com
[-- Attachment #1.2: Type: application/pgp-signature, Size: 827 bytes --]
[-- Attachment #2: Type: text/plain, Size: 159 bytes --]
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
next prev parent reply other threads:[~2012-01-05 2:22 UTC|newest]
Thread overview: 115+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-12-14 12:56 [PATCH 01/43] drm/i915: kicking rings stuck on semaphores considered harmful Daniel Vetter
2011-12-14 12:56 ` [PATCH 02/43] drm/i915: don't bail out of intel_wait_ring_buffer too early Daniel Vetter
2011-12-14 18:39 ` Eugeni Dodonov
2011-12-14 12:57 ` [PATCH 03/43] drm/i915: switch ring->id to be a real id Daniel Vetter
2011-12-14 18:42 ` Eugeni Dodonov
2012-01-29 16:40 ` Daniel Vetter
2011-12-14 12:57 ` [PATCH 04/43] drm/i915: refactor ring error state capture to use arrays Daniel Vetter
2011-12-14 18:43 ` Eugeni Dodonov
2012-01-29 16:44 ` Daniel Vetter
2011-12-14 12:57 ` [PATCH 05/43] drm/i915: collect more per ring error state Daniel Vetter
2011-12-14 18:43 ` Eugeni Dodonov
2012-01-29 16:48 ` Daniel Vetter
2011-12-14 12:57 ` [PATCH 06/43] drm/i915: protect force_wake_(get|put) with the gt_lock Daniel Vetter
2012-01-03 18:51 ` Keith Packard
2012-01-03 19:12 ` Daniel Vetter
2012-01-03 21:13 ` Keith Packard
2012-01-03 21:49 ` Ben Widawsky
2012-01-03 22:23 ` Chris Wilson
2012-01-03 21:49 ` Daniel Vetter
2012-01-03 23:33 ` Keith Packard
2012-01-04 17:11 ` Daniel Vetter
2012-01-04 17:54 ` Keith Packard
2012-01-04 18:12 ` Daniel Vetter
2012-01-05 2:22 ` Keith Packard [this message]
2012-01-05 11:29 ` Daniel Vetter
2012-01-05 15:49 ` Keith Packard
2012-01-05 16:59 ` Daniel Vetter
2012-01-06 0:29 ` Keith Packard
2012-01-06 5:41 ` Keith Packard
2012-01-06 20:43 ` Keith Packard
2011-12-14 12:57 ` [PATCH 07/43] drm/i915: convert force_wake_get to func pointer in the gpu reset code Daniel Vetter
2011-12-14 12:57 ` [PATCH 08/43] drm/i915: drop register special-casing in forcewake Daniel Vetter
2011-12-14 15:05 ` Chris Wilson
2011-12-15 10:21 ` Daniel Vetter
2011-12-15 10:44 ` Chris Wilson
2011-12-22 0:28 ` [PATCH] drm/i915: clear up I915_(READ|WRITE)_NOTRACE confusion Daniel Vetter
2011-12-22 17:54 ` Keith Packard
2011-12-22 18:16 ` Daniel Vetter
2011-12-14 12:57 ` [PATCH 09/43] drm/i915: introduce a vtable for gpu core functions Daniel Vetter
2011-12-14 15:06 ` Chris Wilson
2011-12-21 20:38 ` Daniel Vetter
2011-12-14 18:58 ` Kenneth Graunke
2011-12-14 12:57 ` [PATCH 10/43] drm/i915/ringbuffer: kill snb blt workaround Daniel Vetter
2012-01-29 16:52 ` Daniel Vetter
2011-12-14 12:57 ` [PATCH 11/43] drm/i915: Separate fence pin counting from normal bind pin counting Daniel Vetter
2012-01-29 16:56 ` Daniel Vetter
2011-12-14 12:57 ` [PATCH 12/43] drm/i915: don't trash the gtt when running out of fences Daniel Vetter
2011-12-14 15:09 ` Chris Wilson
2012-01-29 16:57 ` Daniel Vetter
2011-12-14 12:57 ` [PATCH 13/43] drm/i915: refactor debugfs open function Daniel Vetter
2011-12-14 15:10 ` Chris Wilson
2011-12-14 18:36 ` Eugeni Dodonov
2012-01-29 17:28 ` Daniel Vetter
2011-12-14 12:57 ` [PATCH 14/43] drm/i915: refactor debugfs create functions Daniel Vetter
2011-12-14 18:44 ` Eugeni Dodonov
2011-12-14 12:57 ` [PATCH 15/43] drm/i915: add interface to simulate gpu hangs Daniel Vetter
2011-12-14 19:00 ` Eugeni Dodonov
2011-12-14 12:57 ` [PATCH 16/43] drm/i915: rework dev->first_error locking Daniel Vetter
2011-12-14 15:13 ` Chris Wilson
2011-12-14 18:37 ` Eugeni Dodonov
2011-12-14 12:57 ` [PATCH 17/43] drm/i915: destroy existing error_state when simulating a gpu hang Daniel Vetter
2011-12-14 18:45 ` Eugeni Dodonov
2011-12-14 12:57 ` [PATCH 18/43] drm/i915: fix swizzle detection for gen3 Daniel Vetter
2012-01-29 17:36 ` Chris Wilson
2012-01-30 20:20 ` Daniel Vetter
2011-12-14 12:57 ` [PATCH 19/43] drm/i915: add debugfs file for swizzling information Daniel Vetter
2012-01-29 17:37 ` Chris Wilson
2012-01-30 20:22 ` Daniel Vetter
2011-12-14 12:57 ` [PATCH 20/43] drm/i915: swizzling support for snb/ivb Daniel Vetter
2012-01-29 18:34 ` Chris Wilson
2012-01-31 7:44 ` Ben Widawsky
2012-01-31 8:42 ` Daniel Vetter
2011-12-14 12:57 ` [PATCH 21/43] drm/i915: add gen6+ registers to i915_swizzle_info Daniel Vetter
2011-12-14 12:57 ` [PATCH 22/43] drm/i915: prevent division by zero when asking for chipset power Daniel Vetter
2011-12-14 19:05 ` Kenneth Graunke
2011-12-14 12:57 ` [PATCH 23/43] drm/i915: multithreaded forcewake is an ivb+ feature Daniel Vetter
2011-12-14 21:07 ` Eric Anholt
2011-12-14 12:57 ` [PATCH 24/43] drm/i915: capture error_state also for stuck rings Daniel Vetter
2012-01-29 17:36 ` Daniel Vetter
2011-12-14 12:57 ` [PATCH 25/43] drm/i915: properly flush the wc buffer in pwrites to phys objects Daniel Vetter
2011-12-14 15:23 ` Chris Wilson
2011-12-14 12:57 ` [PATCH 26/43] drm/i915: Only clear the GPU domains upon a successful finish Daniel Vetter
2011-12-16 20:07 ` Eric Anholt
2012-03-01 20:40 ` Daniel Vetter
2011-12-14 12:57 ` [PATCH 27/43] drm/i915: flush overlay regfile writes Daniel Vetter
2011-12-14 15:24 ` Chris Wilson
2011-12-21 20:41 ` Daniel Vetter
2011-12-14 12:57 ` [PATCH 28/43] drm/i915: Handle unmappable buffers during error state capture Daniel Vetter
2011-12-14 18:46 ` Eugeni Dodonov
2012-01-31 19:32 ` Daniel Vetter
2011-12-14 12:57 ` [PATCH 29/43] drm/i915: remove the i915_batchbuffer_info debugfs file Daniel Vetter
2012-01-29 17:35 ` Daniel Vetter
2011-12-14 12:57 ` [PATCH 30/43] drm/i915: reject GTT domain in relocations Daniel Vetter
2012-01-29 17:38 ` Daniel Vetter
2011-12-14 12:57 ` [PATCH 31/43] drm/i915: Use kcalloc instead of kzalloc to allocate array Daniel Vetter
2011-12-14 18:48 ` Eugeni Dodonov
2011-12-14 12:57 ` [PATCH 32/43] drm/i915: Avoid using mappable space for relocation processing through the CPU Daniel Vetter
2011-12-14 12:57 ` [PATCH 33/43] drm/i915: fall through pwrite_gtt_slow to the shmem slow path Daniel Vetter
2011-12-14 12:57 ` [PATCH 34/43] drm/i915: rewrite shmem_pwrite_slow to use copy_from_user Daniel Vetter
2011-12-14 12:57 ` [PATCH 35/43] drm/i915: rewrite shmem_pread_slow to use copy_to_user Daniel Vetter
2012-01-30 22:37 ` Daniel Vetter
2011-12-14 12:57 ` [PATCH 36/43] agp/intel-gtt: export the scratch page dma address Daniel Vetter
2011-12-14 12:57 ` [PATCH 37/43] agp/intel-gtt: export the gtt pagetable iomapping Daniel Vetter
2011-12-14 12:57 ` [PATCH 38/43] drm/i915: initialization/teardown for the aliasing ppgtt Daniel Vetter
2011-12-14 12:57 ` [PATCH 39/43] drm/i915: ppgtt binding/unbinding support Daniel Vetter
2011-12-14 12:57 ` [PATCH 40/43] drm/i915: ppgtt register definitions Daniel Vetter
2011-12-14 18:58 ` Eugeni Dodonov
2011-12-14 19:01 ` Eugeni Dodonov
2011-12-14 12:57 ` [PATCH 41/43] drm/i915: ppgtt debugfs info Daniel Vetter
2011-12-14 12:57 ` [PATCH 42/43] drm/i915: per-ring fault reg Daniel Vetter
2011-12-14 19:00 ` Eugeni Dodonov
2012-01-29 22:20 ` Daniel Vetter
2011-12-14 12:57 ` [PATCH 43/43] drm/i915: enable ppgtt Daniel Vetter
2011-12-14 15:34 ` Chris Wilson
2011-12-21 20:46 ` Daniel Vetter
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=86fwfulwge.fsf@sumi.keithp.com \
--to=keithp@keithp.com \
--cc=daniel.vetter@ffwll.ch \
--cc=daniel@ffwll.ch \
--cc=intel-gfx@lists.freedesktop.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