From: "Michał Winiarski" <michal.winiarski@intel.com>
To: intel-gfx@lists.freedesktop.org
Cc: Mika Kuoppala <mika.kuoppala@intel.com>
Subject: [PATCH 3/8] drm/i915/gtt: Extract unwind to separate function for gen6_alloc_va_range
Date: Mon, 12 Dec 2016 12:44:12 +0100 [thread overview]
Message-ID: <1481543057-333-4-git-send-email-michal.winiarski@intel.com> (raw)
In-Reply-To: <1481543057-333-1-git-send-email-michal.winiarski@intel.com>
In case of error during allocation we should free the entries allocated
during the current "transaction".
We can't simply reuse the clear_range, since for gen6 we're not
shrinking ppgtt. We can extract unwind to a function though, and use
range rather than bitmaps.
Cc: Arkadiusz Hiler <arkadiusz.hiler@intel.com>
Cc: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Cc: Michel Thierry <michel.thierry@intel.com>
Cc: Mika Kuoppala <mika.kuoppala@intel.com>
Signed-off-by: Michał Winiarski <michal.winiarski@intel.com>
---
drivers/gpu/drm/i915/i915_gem_gtt.c | 33 +++++++++++++++++++++------------
1 file changed, 21 insertions(+), 12 deletions(-)
diff --git a/drivers/gpu/drm/i915/i915_gem_gtt.c b/drivers/gpu/drm/i915/i915_gem_gtt.c
index 49e1006..f760c3e 100644
--- a/drivers/gpu/drm/i915/i915_gem_gtt.c
+++ b/drivers/gpu/drm/i915/i915_gem_gtt.c
@@ -1917,6 +1917,23 @@ static void gen6_ppgtt_insert_entries(struct i915_address_space *vm,
kunmap_px(ppgtt, pt_vaddr);
}
+static void gen6_ppgtt_unwind_pd(struct i915_address_space *vm,
+ struct i915_page_directory *pd,
+ uint64_t start, uint64_t length) {
+
+ struct i915_page_table *pt;
+ uint64_t pde;
+
+ /* We're only using this for cleanup on PT allocation failure,
+ * and since in this case scratch_pt is already encoded in pde there's
+ * no need to call gen6_write_pde.
+ */
+ gen6_for_each_pde(pt, pd, start, length, pde) {
+ pd->page_table[pde] = vm->scratch_pt;
+ free_pt(vm->i915, pt);
+ }
+}
+
static int gen6_alloc_va_range(struct i915_address_space *vm,
uint64_t start, uint64_t length)
{
@@ -1954,7 +1971,10 @@ static int gen6_alloc_va_range(struct i915_address_space *vm,
pt = alloc_pt(dev_priv);
if (IS_ERR(pt)) {
ret = PTR_ERR(pt);
- goto unwind_out;
+ gen6_ppgtt_unwind_pd(vm, &ppgtt->pd,
+ start_save, start - start_save);
+ mark_tlbs_dirty(ppgtt);
+ return ret;
}
gen6_initialize_pt(vm, pt);
@@ -1993,17 +2013,6 @@ static int gen6_alloc_va_range(struct i915_address_space *vm,
mark_tlbs_dirty(ppgtt);
return 0;
-
-unwind_out:
- for_each_set_bit(pde, new_page_tables, I915_PDES) {
- struct i915_page_table *pt = ppgtt->pd.page_table[pde];
-
- ppgtt->pd.page_table[pde] = vm->scratch_pt;
- free_pt(dev_priv, pt);
- }
-
- mark_tlbs_dirty(ppgtt);
- return ret;
}
static int gen6_init_scratch(struct i915_address_space *vm)
--
2.7.4
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
next prev parent reply other threads:[~2016-12-12 11:45 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-12-12 11:44 [PATCH 0/8] GTT bitmaps purge Michał Winiarski
2016-12-12 11:44 ` [PATCH 1/8] drm/i915/gtt: Don't pass ppgtt to ppgtt_cleanup_4lvl Michał Winiarski
2016-12-12 11:56 ` Chris Wilson
2016-12-12 11:44 ` [PATCH 2/8] drm/i915/gtt: Rename orig_start/orig_length Michał Winiarski
2016-12-12 11:44 ` Michał Winiarski [this message]
2016-12-12 11:44 ` [PATCH 4/8] drm/i915/gtt: Don't use temp bitmaps to unwind gen8_alloc_va_range Michał Winiarski
2016-12-12 11:46 ` [PATCH 5/8] drm/i915/gtt: Purge temp bitmaps Michał Winiarski
2016-12-12 11:46 ` [PATCH 6/8] drm/i915: Prepare i915_page_table_entry_map tracepoint for bitmap purge Michał Winiarski
2016-12-12 11:48 ` [PATCH 7/8] drm/i915/gtt: Purge page tracking bitmaps Michał Winiarski
2016-12-12 11:48 ` [PATCH 8/8] drm/i915: Clear range when unbinding closed vma Michał Winiarski
2016-12-12 12:00 ` Chris Wilson
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=1481543057-333-4-git-send-email-michal.winiarski@intel.com \
--to=michal.winiarski@intel.com \
--cc=intel-gfx@lists.freedesktop.org \
--cc=mika.kuoppala@intel.com \
/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;
as well as URLs for NNTP newsgroup(s).