Intel-GFX Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Tvrtko Ursulin <tvrtko.ursulin@linux.intel.com>
To: "Yang, Fei" <fei.yang@intel.com>,
	"Sripada, Radhakrishna" <radhakrishna.sripada@intel.com>,
	"intel-gfx@lists.freedesktop.org"
	<intel-gfx@lists.freedesktop.org>
Cc: "Wilson, Chris P" <chris.p.wilson@intel.com>,
	"stable@vger.kernel.org" <stable@vger.kernel.org>
Subject: Re: [Intel-gfx] [PATCH v2] drm/i915/dpt: Use shmem for dpt objects
Date: Thu, 20 Jul 2023 10:16:51 +0100	[thread overview]
Message-ID: <46e2c9cc-bc9d-69cb-c40d-53a4012cf80c@linux.intel.com> (raw)
In-Reply-To: <SN6PR11MB2574001C852621E0AFF4CF7F9A39A@SN6PR11MB2574.namprd11.prod.outlook.com>


On 19/07/2023 21:53, Yang, Fei wrote:
>> On 18/07/2023 23:51, Radhakrishna Sripada wrote:
>>> Dpt objects that are created from internal get evicted when there is
>>> memory pressure and do not get restored when pinned during scanout.
>>> The pinned page table entries look corrupted and programming the
>>> display engine with the incorrect pte's result in DE throwing pipe faults.
>>>
>>> Create DPT objects from shmem and mark the object as dirty when
>>> pinning so that the object is restored when shrinker evicts an unpinned buffer object.
>>>
>>> v2: Unconditionally mark the dpt objects dirty during pinning(Chris).
>>>
>>> Fixes: 0dc987b699ce ("drm/i915/display: Add smem fallback allocation
>>> for dpt")
>>> Cc: <stable@vger.kernel.org> # v6.0+
>>> Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
>>> Cc: Tvrtko Ursulin <tvrtko.ursulin@linux.intel.com>
>>> Suggested-by: Chris Wilson <chris.p.wilson@intel.com>
>>> Signed-off-by: Fei Yang <fei.yang@intel.com>
>>> Signed-off-by: Radhakrishna Sripada <radhakrishna.sripada@intel.com>
>>> ---
>>>    drivers/gpu/drm/i915/display/intel_dpt.c | 4 +++-
>>>    1 file changed, 3 insertions(+), 1 deletion(-)
>>>
>>> diff --git a/drivers/gpu/drm/i915/display/intel_dpt.c
>>> b/drivers/gpu/drm/i915/display/intel_dpt.c
>>> index 7c5fddb203ba..fbfd8f959f17 100644
>>> --- a/drivers/gpu/drm/i915/display/intel_dpt.c
>>> +++ b/drivers/gpu/drm/i915/display/intel_dpt.c
>>> @@ -166,6 +166,8 @@ struct i915_vma *intel_dpt_pin(struct i915_address_space *vm)
>>>               i915_vma_get(vma);
>>>       }
>>>
>>> +    dpt->obj->mm.dirty = true;
>>> +
>>>       atomic_dec(&i915->gpu_error.pending_fb_pin);
>>>       intel_runtime_pm_put(&i915->runtime_pm, wakeref);
>>>
>>> @@ -261,7 +263,7 @@ intel_dpt_create(struct intel_framebuffer *fb)
>>>               dpt_obj = i915_gem_object_create_stolen(i915, size);
>>>       if (IS_ERR(dpt_obj) && !HAS_LMEM(i915)) {
>>>               drm_dbg_kms(&i915->drm, "Allocating dpt from smem\n");
>>> -            dpt_obj = i915_gem_object_create_internal(i915, size);
>>> +            dpt_obj = i915_gem_object_create_shmem(i915, size);
>>>       }
>>>       if (IS_ERR(dpt_obj))
>>>               return ERR_CAST(dpt_obj);
>>
>> Okay I think I get it after some more looking at the DPT code paths.
>> Problem seems pretty clear - page tables are stored in dpt_obj and so
>> are lost when backing store is discarded.
>>
>> Changing to shmem object indeed looks the easiest option.
>>
>> Some related thoughts:
>>
>> 1)
>> I wonder if intel_dpt_suspend/resume remain needed after this patch.
>> Could you investigate please? On a glance their job was to restore the
>> PTEs which would be lost from internal objects backing storage. With
>> shmem objects that content should be preserved.
> 
> intel_dpt_suspend is "suspending" the whole VM where, not only the dpt
> objects are mapped into, but also the framebuffer objects. I don't have
> much knowledge on how the framebuffer objects are managed, but the suspend
> resume path still look necessary to me, unless the content of these
> framebuffer objects are also preserved.

I don't think it has anything to do with fb content, but you are correct 
it is still needed. Because 9755f055f512 ("drm/i915: Restore memory 
mapping for DPT FBs across system suspend/resume") reminds me backing 
store for DPT PTEs can be either lmem, stolen or internal (now shmem). 
Even though with this patch internal is out of the picture, stolen 
remains and so the issue of losing the page table content remains. 
Perhaps resume could be optimised to only restore PTEs when VM page 
tables are backed by stolen which may win some suspend/resume speed on 
some platforms.

Regards,

Tvrtko

> 
>> 2)
>> I wonder if i915_vma_flush_writes should be used (as a companion of
>> i915_vma_pin_iomap) from DPT dpt_bind_vma, dpt_insert_entries, etc. But
>> then I am also not sure if it does the right thing for the
>> i915_gem_object_pin_map path of i915_vma_pin_iomap. Perhaps it should
>> call __i915_gem_object_flush_map itself for that mapping flavour and
>> not do the ggtt flushing in that case.
>>
>> In summary I think the fix is safe and correct but at least point 1) I
>> think needs looking into. It can be a follow up work too.
>>
>> Regards,
>>
>> Tvrtko
>>

  reply	other threads:[~2023-07-20  9:16 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-18 22:51 [Intel-gfx] [PATCH v2] drm/i915/dpt: Use shmem for dpt objects Radhakrishna Sripada
2023-07-19  0:27 ` [Intel-gfx] ✓ Fi.CI.BAT: success for drm/i915/dpt: Use shmem for dpt objects (rev2) Patchwork
2023-07-19  2:50 ` [Intel-gfx] ✗ Fi.CI.IGT: failure " Patchwork
2023-07-21  4:50   ` Sripada, Radhakrishna
2023-07-19 13:36 ` [Intel-gfx] [PATCH v2] drm/i915/dpt: Use shmem for dpt objects Tvrtko Ursulin
2023-07-19 20:53   ` Yang, Fei
2023-07-20  9:16     ` Tvrtko Ursulin [this message]
2023-07-20 17:02       ` Sripada, Radhakrishna
2023-07-21  8:17         ` Tvrtko Ursulin
2023-07-21 23:54           ` Sripada, Radhakrishna
2023-07-24 13:01             ` Tvrtko Ursulin

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=46e2c9cc-bc9d-69cb-c40d-53a4012cf80c@linux.intel.com \
    --to=tvrtko.ursulin@linux.intel.com \
    --cc=chris.p.wilson@intel.com \
    --cc=fei.yang@intel.com \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=radhakrishna.sripada@intel.com \
    --cc=stable@vger.kernel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox