From: Jani Nikula <jani.nikula@linux.intel.com>
To: Kenneth Graunke <kenneth@whitecape.org>, intel-gfx@lists.freedesktop.org
Subject: Re: [PATCH 1/3] drm/i915: Add PTE encoding function to the gtt/ppgtt vtables.
Date: Fri, 19 Apr 2013 08:56:41 +0300 [thread overview]
Message-ID: <87y5cf12sm.fsf@intel.com> (raw)
In-Reply-To: <1366316916-4164-2-git-send-email-kenneth@whitecape.org>
On Thu, 18 Apr 2013, Kenneth Graunke <kenneth@whitecape.org> wrote:
> Sandybridge/Ivybridge, Bay Trail, and Haswell all have slightly
> different page table entry formats. Rather than polluting one function
> with generation checks, simply use a function pointer and set up the
> correct PTE encoding function at startup.
>
> Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
> ---
> drivers/gpu/drm/i915/i915_drv.h | 6 ++++++
> drivers/gpu/drm/i915/i915_gem_gtt.c | 22 +++++++++++++---------
> 2 files changed, 19 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
> index bd2d7f1..8b58997 100644
> --- a/drivers/gpu/drm/i915/i915_drv.h
> +++ b/drivers/gpu/drm/i915/i915_drv.h
> @@ -430,6 +430,9 @@ struct i915_gtt {
> struct sg_table *st,
> unsigned int pg_start,
> enum i915_cache_level cache_level);
> + uint32_t (*pte_encode)(struct drm_device *dev,
> + dma_addr_t addr,
> + enum i915_cache_level level);
To keep the gen6_gtt_pte_t typedef internal to i915_gem_gtt.c, or to
have the same return type in the function pointers and the functions. I
think I'd find the latter more aesthetically pleasing, but I'm not
insisting. Either way,
Reviewed-by: Jani Nikula <jani.nikula@intel.com>
> };
> #define gtt_total_entries(gtt) ((gtt).total >> PAGE_SHIFT)
>
> @@ -451,6 +454,9 @@ struct i915_hw_ppgtt {
> struct sg_table *st,
> unsigned int pg_start,
> enum i915_cache_level cache_level);
> + uint32_t (*pte_encode)(struct drm_device *dev,
> + dma_addr_t addr,
> + enum i915_cache_level level);
> int (*enable)(struct drm_device *dev);
> void (*cleanup)(struct i915_hw_ppgtt *ppgtt);
> };
> diff --git a/drivers/gpu/drm/i915/i915_gem_gtt.c b/drivers/gpu/drm/i915/i915_gem_gtt.c
> index 50df194..9db65c1 100644
> --- a/drivers/gpu/drm/i915/i915_gem_gtt.c
> +++ b/drivers/gpu/drm/i915/i915_gem_gtt.c
> @@ -154,9 +154,9 @@ static void gen6_ppgtt_clear_range(struct i915_hw_ppgtt *ppgtt,
> unsigned first_pte = first_entry % I915_PPGTT_PT_ENTRIES;
> unsigned last_pte, i;
>
> - scratch_pte = gen6_pte_encode(ppgtt->dev,
> - ppgtt->scratch_page_dma_addr,
> - I915_CACHE_LLC);
> + scratch_pte = ppgtt->pte_encode(ppgtt->dev,
> + ppgtt->scratch_page_dma_addr,
> + I915_CACHE_LLC);
>
> while (num_entries) {
> last_pte = first_pte + num_entries;
> @@ -191,8 +191,8 @@ static void gen6_ppgtt_insert_entries(struct i915_hw_ppgtt *ppgtt,
> dma_addr_t page_addr;
>
> page_addr = sg_page_iter_dma_address(&sg_iter);
> - pt_vaddr[act_pte] = gen6_pte_encode(ppgtt->dev, page_addr,
> - cache_level);
> + pt_vaddr[act_pte] = ppgtt->pte_encode(ppgtt->dev, page_addr,
> + cache_level);
> if (++act_pte == I915_PPGTT_PT_ENTRIES) {
> kunmap_atomic(pt_vaddr);
> act_pt++;
> @@ -236,6 +236,7 @@ static int gen6_ppgtt_init(struct i915_hw_ppgtt *ppgtt)
> first_pd_entry_in_global_pt =
> gtt_total_entries(dev_priv->gtt) - I915_PPGTT_PD_ENTRIES;
>
> + ppgtt->pte_encode = gen6_pte_encode;
> ppgtt->num_pd_entries = I915_PPGTT_PD_ENTRIES;
> ppgtt->enable = gen6_ppgtt_enable;
> ppgtt->clear_range = gen6_ppgtt_clear_range;
> @@ -438,7 +439,8 @@ static void gen6_ggtt_insert_entries(struct drm_device *dev,
>
> for_each_sg_page(st->sgl, &sg_iter, st->nents, 0) {
> addr = sg_page_iter_dma_address(&sg_iter);
> - iowrite32(gen6_pte_encode(dev, addr, level), >t_entries[i]);
> + iowrite32(dev_priv->gtt.pte_encode(dev, addr, level),
> + >t_entries[i]);
> i++;
> }
>
> @@ -450,7 +452,7 @@ static void gen6_ggtt_insert_entries(struct drm_device *dev,
> */
> if (i != 0)
> WARN_ON(readl(>t_entries[i-1])
> - != gen6_pte_encode(dev, addr, level));
> + != dev_priv->gtt.pte_encode(dev, addr, level));
>
> /* This next bit makes the above posting read even more important. We
> * want to flush the TLBs only after we're certain all the PTE updates
> @@ -475,8 +477,9 @@ static void gen6_ggtt_clear_range(struct drm_device *dev,
> first_entry, num_entries, max_entries))
> num_entries = max_entries;
>
> - scratch_pte = gen6_pte_encode(dev, dev_priv->gtt.scratch_page_dma,
> - I915_CACHE_LLC);
> + scratch_pte = dev_priv->gtt.pte_encode(dev,
> + dev_priv->gtt.scratch_page_dma,
> + I915_CACHE_LLC);
> for (i = 0; i < num_entries; i++)
> iowrite32(scratch_pte, >t_base[i]);
> readl(gtt_base);
> @@ -823,6 +826,7 @@ int i915_gem_gtt_init(struct drm_device *dev)
> } else {
> dev_priv->gtt.gtt_probe = gen6_gmch_probe;
> dev_priv->gtt.gtt_remove = gen6_gmch_remove;
> + dev_priv->gtt.pte_encode = gen6_pte_encode;
> }
>
> ret = dev_priv->gtt.gtt_probe(dev, &dev_priv->gtt.total,
> --
> 1.8.2.1
>
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/intel-gfx
next prev parent reply other threads:[~2013-04-19 5:58 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-04-18 20:28 Bay Trail PTE fixes Kenneth Graunke
2013-04-18 20:28 ` [PATCH 1/3] drm/i915: Add PTE encoding function to the gtt/ppgtt vtables Kenneth Graunke
2013-04-19 5:56 ` Jani Nikula [this message]
2013-04-18 20:28 ` [PATCH 2/3] drm/i915: Fix page table entries for Bay Trail Kenneth Graunke
2013-04-19 6:08 ` Jani Nikula
2013-04-18 20:28 ` [PATCH 3/3] drm/i915: Split out Haswell code from gen6_pte_encode Kenneth Graunke
2013-04-19 6:13 ` Jani Nikula
2013-04-18 23:23 ` Bay Trail PTE fixes Ben Widawsky
-- strict thread matches above, loose matches on Subject: below --
2013-04-22 7:53 [PATCH 1/3] drm/i915: Add PTE encoding function to the gtt/ppgtt vtables Kenneth Graunke
2013-04-22 8:13 ` Jani Nikula
2013-04-22 9:44 ` 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=87y5cf12sm.fsf@intel.com \
--to=jani.nikula@linux.intel.com \
--cc=intel-gfx@lists.freedesktop.org \
--cc=kenneth@whitecape.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.