From: Jani Nikula <jani.nikula@linux.intel.com>
To: ville.syrjala@linux.intel.com, intel-gfx@lists.freedesktop.org
Subject: Re: [PATCH v2 5/6] drm/i915: Don't clobber the GTT when it's within stolen memory
Date: Mon, 30 Jun 2014 13:25:29 +0300 [thread overview]
Message-ID: <87bntaitie.fsf@intel.com> (raw)
In-Reply-To: <1401987779-6372-1-git-send-email-ville.syrjala@linux.intel.com>
On Thu, 05 Jun 2014, ville.syrjala@linux.intel.com wrote:
> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
>
> On most gen2-4 platforms the GTT can be (or maybe always is?)
> inside the stolen memory region. If that's the case, reduce the
> size of the stolen memory appropriately to make make sure we
> don't clobber the GTT.
>
> v2: Deal with gen4 36 bit physical address
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=80151
> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> ---
> drivers/gpu/drm/i915/i915_gem_stolen.c | 44 ++++++++++++++++++++++++++++++++++
> drivers/gpu/drm/i915/i915_reg.h | 3 +++
> 2 files changed, 47 insertions(+)
>
> diff --git a/drivers/gpu/drm/i915/i915_gem_stolen.c b/drivers/gpu/drm/i915/i915_gem_stolen.c
> index 62ef55b..7465ab0 100644
> --- a/drivers/gpu/drm/i915/i915_gem_stolen.c
> +++ b/drivers/gpu/drm/i915/i915_gem_stolen.c
> @@ -74,6 +74,50 @@ static unsigned long i915_stolen_to_physical(struct drm_device *dev)
> if (base == 0)
> return 0;
>
> + /* make sure we don't clobber the GTT if it's within stolen memory */
> + if (INTEL_INFO(dev)->gen <= 4 && !IS_G33(dev) && !IS_G4X(dev)) {
> + struct {
> + u32 start, end;
> + } stolen[2] = {
> + { .start = base, .end = base + dev_priv->gtt.stolen_size, },
> + { .start = base, .end = base + dev_priv->gtt.stolen_size, },
> + };
> + u64 gtt_start, gtt_end;
> +
> + gtt_start = I915_READ(PGTBL_CTL);
> + if (IS_GEN4(dev))
> + gtt_start = (gtt_start & PGTBL_ADDRESS_LO_MASK) |
> + (gtt_start & PGTBL_ADDRESS_HI_MASK) << 28;
> + else
> + gtt_start &= PGTBL_ADDRESS_LO_MASK;
> + gtt_end = gtt_start + gtt_total_entries(dev_priv->gtt) * 4;
> +
> + if (gtt_start >= stolen[0].start && gtt_start < stolen[0].end)
> + stolen[0].end = gtt_start;
> + if (gtt_end > stolen[1].start && gtt_end <= stolen[1].end)
> + stolen[1].start = gtt_end;
> +
> + /* pick the larger of the two chunks */
> + if (stolen[0].end - stolen[0].start >
> + stolen[1].end - stolen[1].start) {
> + base = stolen[0].start;
> + dev_priv->gtt.stolen_size = stolen[0].end - stolen[0].start;
> + } else {
> + base = stolen[1].start;
> + dev_priv->gtt.stolen_size = stolen[1].end - stolen[1].start;
> + }
> +
> + if (stolen[0].start != stolen[1].start ||
> + stolen[0].end != stolen[1].end) {
> + DRM_DEBUG_KMS("GTT within stolen memory at 0x%llx-0x%llx\n",
> + (unsigned long long) gtt_start,
> + (unsigned long long) gtt_end - 1);
> + DRM_DEBUG_KMS("Stolen memory adjusted to 0x%x-0x%x\n",
> + base, base + (u32) dev_priv->gtt.stolen_size - 1);
> + }
> + }
> +
> +
> /* Verify that nothing else uses this physical address. Stolen
> * memory should be reserved by the BIOS and hidden from the
> * kernel. So if the region is already marked as busy, something
> diff --git a/drivers/gpu/drm/i915/i915_reg.h b/drivers/gpu/drm/i915/i915_reg.h
> index 247be2a..619924b 100644
> --- a/drivers/gpu/drm/i915/i915_reg.h
> +++ b/drivers/gpu/drm/i915/i915_reg.h
> @@ -978,6 +978,9 @@ enum punit_power_well {
> /*
> * Instruction and interrupt control regs
> */
> +#define PGTBL_CTL 0x02020
> +#define PGTBL_ADDRESS_LO_MASK 0xfffff000 /* bits [31:12] */
> +#define PGTBL_ADDRESS_HI_MASK 0x000000f0 /* bits [35:32] (gen4) */
> #define PGTBL_ER 0x02024
> #define RENDER_RING_BASE 0x02000
> #define BSD_RING_BASE 0x04000
> --
> 1.8.5.5
>
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/intel-gfx
--
Jani Nikula, Intel Open Source Technology Center
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
next prev parent reply other threads:[~2014-06-30 10:25 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-12-03 15:49 [PATCH 0/6] drm/i915: Gen2 stolen/local memory support (v2) ville.syrjala
2013-12-03 15:49 ` [PATCH 1/6] x86: Add vfunc for Intel graphics stolen memory base address ville.syrjala
2013-12-03 15:49 ` ville.syrjala
2013-12-03 15:49 ` [PATCH v2 2/6] x86: Add Intel graphics stolen memory quirk for gen2 platforms ville.syrjala
2013-12-03 15:49 ` ville.syrjala
2013-12-04 9:08 ` Ingo Molnar
2013-12-04 9:08 ` Ingo Molnar
2013-12-04 15:12 ` Ville Syrjälä
2013-12-04 15:12 ` Ville Syrjälä
2013-12-04 15:15 ` Ingo Molnar
2014-01-07 15:28 ` [PATCH v3 " ville.syrjala
2014-01-07 15:28 ` ville.syrjala
2014-02-04 12:47 ` Ville Syrjälä
2014-02-04 12:47 ` Ville Syrjälä
2014-02-04 13:02 ` [Intel-gfx] " Daniel Vetter
2014-02-05 5:41 ` Ingo Molnar
2014-02-05 5:41 ` [Intel-gfx] " Ingo Molnar
2013-12-03 15:49 ` [PATCH 3/6] x86: Print the Intel graphcis stolen memory range ville.syrjala
2013-12-03 15:49 ` ville.syrjala
2013-12-03 15:49 ` [PATCH 4/6] intel-gtt: Report stolen_size as 0 when local memory is present ville.syrjala
2013-12-03 15:49 ` [PATCH 5/6] drm/i915: Don't clobber the GTT when it's within stolen memory ville.syrjala
2014-06-05 17:02 ` [PATCH v2 " ville.syrjala
2014-06-30 10:25 ` Jani Nikula [this message]
2014-07-07 9:02 ` Daniel Vetter
2013-12-03 15:49 ` [PATCH v2 6/6] drm/i915: Determine the stolen memory base address on gen2 ville.syrjala
2014-01-07 15:28 ` [PATCH v3 " ville.syrjala
2014-01-10 13:31 ` [PATCH v4 " ville.syrjala
2014-01-10 15:11 ` Jani Nikula
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=87bntaitie.fsf@intel.com \
--to=jani.nikula@linux.intel.com \
--cc=intel-gfx@lists.freedesktop.org \
--cc=ville.syrjala@linux.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 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.