From: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
To: Chris Wilson <chris@chris-wilson.co.uk>, intel-gfx@lists.freedesktop.org
Subject: Re: [PATCH 03/10] drm/i915: Move fence tracking from object to vma
Date: Mon, 15 Aug 2016 12:18:20 +0300 [thread overview]
Message-ID: <1471252700.3839.26.camel@linux.intel.com> (raw)
In-Reply-To: <1470997701-988-4-git-send-email-chris@chris-wilson.co.uk>
On pe, 2016-08-12 at 11:28 +0100, Chris Wilson wrote:
> @@ -455,15 +455,21 @@ struct intel_opregion {
> struct intel_overlay;
> struct intel_overlay_error_state;
>
> -#define I915_FENCE_REG_NONE -1
> -#define I915_MAX_NUM_FENCES 32
> -/* 32 fences + sign bit for FENCE_REG_NONE */
> -#define I915_MAX_NUM_FENCE_BITS 6
> -
> struct drm_i915_fence_reg {
> struct list_head lru_list;
Could be converted to lru_link while at it.
> @@ -1131,15 +1131,11 @@ i915_gem_gtt_pwrite_fast(struct drm_i915_private *i915,
> } else {
> node.start = i915_ggtt_offset(vma);
> node.allocated = false;
> - ret = i915_gem_object_put_fence(obj);
> + ret = i915_vma_put_fence(vma);
> if (ret)
> goto out_unpin;
> }
>
> - ret = i915_gem_object_set_to_gtt_domain(obj, true);
> - if (ret)
> - goto out_unpin;
> -
This is a somewhat an unexpected change in here. Care to explain?
> +static void i965_write_fence_reg(struct drm_i915_fence_reg *fence,
> + struct i915_vma *vma)
> {
> - struct drm_i915_private *dev_priv = to_i915(dev);
> i915_reg_t fence_reg_lo, fence_reg_hi;
> int fence_pitch_shift;
> + u64 val;
>
> - if (INTEL_INFO(dev)->gen >= 6) {
> - fence_reg_lo = FENCE_REG_GEN6_LO(reg);
> - fence_reg_hi = FENCE_REG_GEN6_HI(reg);
> + if (INTEL_INFO(fence->i915)->gen >= 6) {
> + fence_reg_lo = FENCE_REG_GEN6_LO(fence->id);
> + fence_reg_hi = FENCE_REG_GEN6_HI(fence->id);
> fence_pitch_shift = GEN6_FENCE_PITCH_SHIFT;
> +
> } else {
> - fence_reg_lo = FENCE_REG_965_LO(reg);
> - fence_reg_hi = FENCE_REG_965_HI(reg);
> + fence_reg_lo = FENCE_REG_965_LO(fence->id);
> + fence_reg_hi = FENCE_REG_965_HI(fence->id);
> fence_pitch_shift = I965_FENCE_PITCH_SHIFT;
> }
>
> - /* To w/a incoherency with non-atomic 64-bit register updates,
> - * we split the 64-bit update into two 32-bit writes. In order
> - * for a partial fence not to be evaluated between writes, we
> - * precede the update with write to turn off the fence register,
> - * and only enable the fence as the last step.
> - *
> - * For extra levels of paranoia, we make sure each step lands
> - * before applying the next step.
> - */
> - I915_WRITE(fence_reg_lo, 0);
> - POSTING_READ(fence_reg_lo);
> -
> - if (obj) {
> - struct i915_vma *vma = i915_gem_object_to_ggtt(obj, NULL);
> - unsigned int tiling = i915_gem_object_get_tiling(obj);
> - unsigned int stride = i915_gem_object_get_stride(obj);
> - u64 size = vma->node.size;
> - u32 row_size = stride * (tiling == I915_TILING_Y ? 32 : 8);
> - u64 val;
> -
> - /* Adjust fence size to match tiled area */
> - size = rounddown(size, row_size);
> + if (vma) {
> + unsigned int tiling = i915_gem_object_get_tiling(vma->obj);
> + unsigned int tiling_y = tiling == I915_TILING_Y;
bool and maybe 'y_tiled'?
> + unsigned int stride = i915_gem_object_get_stride(vma->obj);
> + u32 row_size = stride * (tiling_y ? 32 : 8);
> + u32 size = rounddown(vma->node.size, row_size);
>
> val = ((vma->node.start + size - 4096) & 0xfffff000) << 32;
> val |= vma->node.start & 0xfffff000;
> val |= (u64)((stride / 128) - 1) << fence_pitch_shift;
> - if (tiling == I915_TILING_Y)
> + if (tiling_y)
> val |= 1 << I965_FENCE_TILING_Y_SHIFT;
While around, BIT()
> val |= I965_FENCE_REG_VALID;
> + } else
> + val = 0;
> +
> + if (1) {
Umm? At least ought to have TODO: / FIXME: or some explanation. And
if (!1)
return;
Would make the code more readable too, as you do not have any else
branch.
> @@ -152,20 +148,23 @@ static void i915_write_fence_reg(struct drm_device *dev, int reg,
> } else
> val = 0;
>
> - I915_WRITE(FENCE_REG(reg), val);
> - POSTING_READ(FENCE_REG(reg));
> + if (1) {
Ditto.
> @@ -186,96 +185,95 @@ static void i830_write_fence_reg(struct drm_device *dev, int reg,
> } else
> val = 0;
>
> - I915_WRITE(FENCE_REG(reg), val);
> - POSTING_READ(FENCE_REG(reg));
> -}
> + if (1) {
Ditto.
> -static struct drm_i915_fence_reg *
> -i915_find_fence_reg(struct drm_device *dev)
> +static struct drm_i915_fence_reg *fence_find(struct drm_i915_private *dev_priv)
> {
> - struct drm_i915_private *dev_priv = to_i915(dev);
> - struct drm_i915_fence_reg *reg, *avail;
> - int i;
> -
> - /* First try to find a free reg */
> - avail = NULL;
> - for (i = 0; i < dev_priv->num_fence_regs; i++) {
> - reg = &dev_priv->fence_regs[i];
> - if (!reg->obj)
> - return reg;
> -
> - if (!reg->pin_count)
> - avail = reg;
> - }
> -
> - if (avail == NULL)
> - goto deadlock;
> + struct drm_i915_fence_reg *fence;
>
> - /* None available, try to steal one or wait for a user to finish */
> - list_for_each_entry(reg, &dev_priv->mm.fence_list, lru_list) {
> - if (reg->pin_count)
> + list_for_each_entry(fence, &dev_priv->mm.fence_list, lru_list) {
> + if (fence->pin_count)
> continue;
>
> - return reg;
> + return fence;
Umm, one could check for !fence->pin_count and then return fence and
drop the braces.
> }
>
> -deadlock:
> /* Wait for completion of pending flips which consume fences */
> - if (intel_has_pending_fb_unpin(dev))
> + if (intel_has_pending_fb_unpin(&dev_priv->drm))
> return ERR_PTR(-EAGAIN);
>
> return ERR_PTR(-EDEADLK);
> }
>
> /**
> - * i915_gem_object_get_fence - set up fencing for an object
> - * @obj: object to map through a fence reg
> + * i915_vma_get_fence - set up fencing for a vma
> + * @vma: vma to map through a fence reg
I think we should use uppercase VMA in the documentation sections?
> +static bool i915_vma_fence_prepare(struct i915_vma *vma, int tiling_mode)
> +{
> + struct drm_i915_private *dev_priv = to_i915(vma->vm->dev);
> + u32 size;
> +
> + if (!i915_vma_is_map_and_fenceable(vma))
> + return true;
> +
> + if (INTEL_GEN(dev_priv) == 3) {
Up there IS_GEN2 and IS_GEN3 is still used, just noting.
> +++ b/drivers/gpu/drm/i915/intel_fbc.c
> @@ -244,7 +244,6 @@ static void ilk_fbc_activate(struct drm_i915_private *dev_priv)
> dpfc_ctl |= DPFC_CTL_LIMIT_1X;
> break;
> }
> - dpfc_ctl |= DPFC_CTL_FENCE_EN;
This bit is not set elsewhere, forgot to reinsert elsewhere?
Regards, Joonas
--
Joonas Lahtinen
Open Source Technology Center
Intel Corporation
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
next prev parent reply other threads:[~2016-08-15 9:18 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-08-12 10:28 Partial VMA fixes Chris Wilson
2016-08-12 10:28 ` [PATCH 01/10] drm/i915: Move map-and-fenceable tracking to the VMA Chris Wilson
2016-08-15 8:03 ` Joonas Lahtinen
2016-08-15 8:14 ` Chris Wilson
2016-08-12 10:28 ` [PATCH 02/10] drm/i915/userptr: Make gup errors stickier Chris Wilson
2016-08-15 11:16 ` Joonas Lahtinen
2016-08-15 15:08 ` Mika Kuoppala
2016-08-15 15:28 ` Chris Wilson
2016-08-16 7:40 ` Mika Kuoppala
2016-08-12 10:28 ` [PATCH 03/10] drm/i915: Move fence tracking from object to vma Chris Wilson
2016-08-15 9:18 ` Joonas Lahtinen [this message]
2016-08-15 9:25 ` Chris Wilson
2016-08-15 10:16 ` Joonas Lahtinen
2016-08-15 9:52 ` Chris Wilson
2016-08-12 10:28 ` [PATCH 04/10] drm/i915: Choose partial chunksize based on tile row size Chris Wilson
2016-08-12 10:38 ` Joonas Lahtinen
2016-08-12 10:28 ` [PATCH 05/10] drm/i915: Fix partial GGTT faulting Chris Wilson
2016-08-15 9:29 ` Joonas Lahtinen
2016-08-12 10:28 ` [PATCH 06/10] drm/i915: Choose not to evict faultable objects from the GGTT Chris Wilson
2016-08-12 10:50 ` Joonas Lahtinen
2016-08-12 11:13 ` Chris Wilson
2016-08-15 10:20 ` Joonas Lahtinen
2016-08-12 10:28 ` [PATCH 07/10] drm/i915: Fallback to using unmappable memory for scanout Chris Wilson
2016-08-15 9:33 ` Joonas Lahtinen
2016-08-12 10:28 ` [PATCH 08/10] drm/i915: Track display alignment on VMA Chris Wilson
2016-08-15 9:38 ` Joonas Lahtinen
2016-08-16 8:40 ` Chris Wilson
2016-08-12 10:28 ` [PATCH 09/10] drm/i915: Bump the inactive MRU tracking for all VMA accessed Chris Wilson
2016-08-15 9:59 ` Joonas Lahtinen
2016-08-15 10:12 ` Chris Wilson
2016-08-15 11:10 ` Joonas Lahtinen
2016-08-12 10:28 ` [PATCH 10/10] drm/i915: Stop discarding GTT cache-domain on unbind vma Chris Wilson
2016-08-15 10:03 ` Joonas Lahtinen
2016-08-12 10:33 ` ✗ Ro.CI.BAT: failure for series starting with [01/10] drm/i915: Move map-and-fenceable tracking to the VMA Patchwork
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=1471252700.3839.26.camel@linux.intel.com \
--to=joonas.lahtinen@linux.intel.com \
--cc=chris@chris-wilson.co.uk \
--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 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.