[Intel-gfx] [PATCH 1/3] drm/i915: Use readl/writel for ring buffer access

Chris Wilson chris at chris-wilson.co.uk
Thu Apr 14 11:30:42 UTC 2016


On Thu, Apr 14, 2016 at 12:24:20PM +0100, Tvrtko Ursulin wrote:
> 
> On 14/04/16 12:16, Chris Wilson wrote:
> >On Thu, Apr 14, 2016 at 11:59:29AM +0100, Tvrtko Ursulin wrote:
> >>From: Tvrtko Ursulin <tvrtko.ursulin at intel.com>
> >>
> >>We know ringbuffers are memory and not ports so if we use readl
> >>and writel instead of ioread32 and iowrite32 (which dispatch to
> >>the very same functions after checking the address range) we
> >>avoid generating functions calls and branching on every access.
> >
> >We don't need to use readl/write at all, since they are normal memory
> >on llc, and on x86 we can pretend that iomaps (!llc/stolen) are as well.
> 
> It is fine to use readl/writel since it translates to a single mov
> instruction anyway on x86.
> 
> >This patch is in the queue along with killing the incorrect spare iomem
> >annotation.
> 
> Ok did not spot them. Don't mind either way, thought this is quick,
> easy and obvious improvement when I spotted the ugly code generated
> for ring buffer writing.
> 
> Mind you it is still not completely pretty with this patch since it
> is full of reloads and adds for ringbuf->virtual_start and tail
> which I can't figure how to help GCC optimize. Unless we make being,
> emit and advance functions return the current tail pointer and also
> accept it. In that case it all shrinks by half.

We figured out how to help gcc with that in userspace using:

out = ring_begin(num_dwords);
out[0] = cmd;
out[N] = dwN

GCC will then do

mov $imm0, 0x0($eax)
mov $imm1, 0x4($eax)
mov $edx, 0x8($eax)
etc

Forgive the clumsy rebasing:

https://cgit.freedesktop.org/~ickle/linux-2.6/commit/?h=tasklet&id=a5c7b28441af0cb0e640f4ba86facba69e8f6c37
 drivers/gpu/drm/i915/i915_gem.c            |   4 -
 drivers/gpu/drm/i915/i915_gem_context.c    |  76 +--
 drivers/gpu/drm/i915/i915_gem_execbuffer.c |  37 +-
 drivers/gpu/drm/i915/i915_gem_gtt.c        |  61 +-
 drivers/gpu/drm/i915/i915_gem_request.c    | 121 +++-
 drivers/gpu/drm/i915/i915_gem_request.h    |   3 +
 drivers/gpu/drm/i915/i915_guc_submission.c |   2 +-
 drivers/gpu/drm/i915/intel_display.c       | 134 ++---
 drivers/gpu/drm/i915/intel_lrc.c           | 239 ++++----
 drivers/gpu/drm/i915/intel_mocs.c          |  50 +-
 drivers/gpu/drm/i915/intel_overlay.c       |  77 +--
 drivers/gpu/drm/i915/intel_ringbuffer.c    | 922 ++++++++++++-----------------
 drivers/gpu/drm/i915/intel_ringbuffer.h    |  28 +-
 13 files changed, 793 insertions(+), 961 deletions(-)
-Chris

-- 
Chris Wilson, Intel Open Source Technology Centre


More information about the Intel-gfx mailing list