From: Tvrtko Ursulin <tvrtko.ursulin@linux.intel.com>
To: "Yang, Fei" <fei.yang@intel.com>,
"Intel-gfx@lists.freedesktop.org"
<Intel-gfx@lists.freedesktop.org>,
"dri-devel@lists.freedesktop.org"
<dri-devel@lists.freedesktop.org>
Cc: "Roper, Matthew D" <matthew.d.roper@intel.com>,
Chris Wilson <chris.p.wilson@linux.intel.com>
Subject: Re: [Intel-gfx] [RFC 4/8] drm/i915: Refactor PAT/object cache handling
Date: Fri, 28 Jul 2023 13:55:52 +0100 [thread overview]
Message-ID: <c4ff98f9-81e7-3f42-2e63-14782410037a@linux.intel.com> (raw)
In-Reply-To: <BYAPR11MB256702AD6B37216420298B699A06A@BYAPR11MB2567.namprd11.prod.outlook.com>
On 28/07/2023 08:14, Yang, Fei wrote:
> [snip]
>> @@ -41,14 +42,17 @@ static bool gpu_write_needs_clflush(struct drm_i915_gem_object *obj)
>> return false;
>>
>> /*
>> - * For objects created by userspace through GEM_CREATE with pat_index
>> - * set by set_pat extension, i915_gem_object_has_cache_level() will
>> - * always return true, because the coherency of such object is managed
>
> i915_gem_object_has_cache_level() always return true means this function
> always return false.
>
>> - * by userspace. Othereise the call here would fall back to checking
>> - * whether the object is un-cached or write-through.
>> + * Always flush cache for UMD objects with PAT index set.
>
> (obj->pat_set_by_user == true) indicates UMD knows how to handle the coherency,
> forcing clflush in KMD would be redundant.
For Meteorlake I made gpu_write_needs_clflush() always return false anyway.
Could you please submit a patch with kerneldoc for i915_drm.h explaining
what the set domain ioctl is expected to do when set pat extension is
used? With the focus on the use cases of how userspace is managing
coherency using it, or it isn't, or what.
>> */
>> - return !(i915_gem_object_has_cache_level(obj, I915_CACHE_NONE) ||
>> - i915_gem_object_has_cache_level(obj, I915_CACHE_WT));
>> + if (obj->pat_set_by_user)
>> + return true;
>
> return false;
Oops, thank you! I did warn in the cover letter I was getting confused
by boolean logic conversions, cross-referencing three versions, and
extracting the pat_set_by_user to call sites. :)
>> +
>> + /*
>> + * Fully coherent cached access may end up with data in the CPU cache
>> + * which hasn't hit memory yet.
>> + */
>> + return i915_gem_object_has_cache_mode(obj, I915_CACHE_MODE_WB) &&
>> + i915_gem_object_has_cache_flag(obj, I915_CACHE_FLAG_COH2W);
>
> Why checking COH2W here? The logic was, if UC or WT return false, otherwise
> return true. So, as long as cache_mode is WB, it's sufficient to say true
> here, right?
I was trying to penetrate the reason behind the check.
Original code was:
return !(obj->cache_level == I915_CACHE_NONE ||
obj->cache_level == I915_CACHE_WT);
Which is equivalent to "is it WB", right? (Since it matches on both old
LLC flavours.)
Which I thought, in the context of this function, is supposed to answer
the question of "can there be data in the shared cache written by the
GPU but not committed to RAM yet".
And then I thought that can only ever happen with 2-way coherency.
Otherwise GPU writes never end up in the CPU cache.
Did I get that wrong? Maybe I have..
Regards,
Tvrtko
next prev parent reply other threads:[~2023-07-28 12:56 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-27 14:54 [Intel-gfx] [RFC 0/8] Another take on PAT/object cache mode refactoring Tvrtko Ursulin
2023-07-27 14:54 ` [Intel-gfx] [RFC 1/8] drm/i915: Skip clflush after GPU writes on Meteorlake Tvrtko Ursulin
2023-07-27 22:19 ` Matt Roper
2023-07-28 5:50 ` Yang, Fei
2023-07-27 14:54 ` [Intel-gfx] [RFC 2/8] drm/i915: Split PTE encode between Gen12 and Meteorlake Tvrtko Ursulin
2023-07-27 22:25 ` Matt Roper
2023-07-28 8:18 ` Tvrtko Ursulin
2023-07-28 14:41 ` Matt Roper
2023-07-27 14:54 ` [Intel-gfx] [RFC 3/8] drm/i915: Cache PAT index used by the driver Tvrtko Ursulin
2023-07-27 22:44 ` Matt Roper
2023-07-28 12:03 ` Tvrtko Ursulin
2023-07-27 14:55 ` [Intel-gfx] [RFC 4/8] drm/i915: Refactor PAT/object cache handling Tvrtko Ursulin
2023-07-27 23:57 ` Matt Roper
2023-07-28 0:17 ` Matt Roper
2023-07-28 12:35 ` Tvrtko Ursulin
2023-07-28 12:23 ` Tvrtko Ursulin
2023-07-28 12:39 ` Tvrtko Ursulin
2023-07-28 14:53 ` Matt Roper
2023-07-28 7:14 ` Yang, Fei
2023-07-28 12:55 ` Tvrtko Ursulin [this message]
2023-07-27 14:55 ` [Intel-gfx] [RFC 5/8] drm/i915: Improve the vm_fault_gtt user PAT index restriction Tvrtko Ursulin
2023-07-28 0:04 ` Matt Roper
2023-07-28 12:28 ` Tvrtko Ursulin
2023-07-27 14:55 ` [Intel-gfx] [RFC 6/8] drm/i915: Lift the user PAT restriction from gpu_write_needs_clflush Tvrtko Ursulin
2023-07-28 0:05 ` Matt Roper
2023-07-27 14:55 ` [Intel-gfx] [RFC 7/8] drm/i915: Lift the user PAT restriction from use_cpu_reloc Tvrtko Ursulin
2023-07-28 0:09 ` Matt Roper
2023-07-28 12:45 ` Tvrtko Ursulin
2023-07-27 14:55 ` [Intel-gfx] [RFC 8/8] drm/i915: Refine the caching check in i915_gem_object_can_bypass_llc Tvrtko Ursulin
2023-07-27 19:43 ` [Intel-gfx] ✗ Fi.CI.CHECKPATCH: warning for Another take on PAT/object cache mode refactoring Patchwork
2023-07-27 19:43 ` [Intel-gfx] ✗ Fi.CI.SPARSE: " Patchwork
2023-07-27 20:01 ` [Intel-gfx] ✓ Fi.CI.BAT: success " Patchwork
2023-07-28 1:03 ` [Intel-gfx] ✗ Fi.CI.IGT: failure " 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=c4ff98f9-81e7-3f42-2e63-14782410037a@linux.intel.com \
--to=tvrtko.ursulin@linux.intel.com \
--cc=Intel-gfx@lists.freedesktop.org \
--cc=chris.p.wilson@linux.intel.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=fei.yang@intel.com \
--cc=matthew.d.roper@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