Intel-XE Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Matthew Auld <matthew.auld@intel.com>
To: "Thomas Hellström" <thomas.hellstrom@linux.intel.com>,
	intel-xe@lists.freedesktop.org
Cc: Matthew Brost <matthew.brost@intel.com>,
	Jani Nikula <jani.nikula@intel.com>
Subject: Re: [PATCH] drm/xe/display: fix ttm_bo_access() usage
Date: Mon, 2 Dec 2024 16:28:45 +0000	[thread overview]
Message-ID: <602c7ab7-cab9-4790-a67c-306b23a75f23@intel.com> (raw)
In-Reply-To: <a758f27d283bc3aff6aeca05c6002d2d5233ec78.camel@linux.intel.com>

On 02/12/2024 15:56, Thomas Hellström wrote:
> On Mon, 2024-12-02 at 15:41 +0000, Matthew Auld wrote:
>> ttm_bo_access() returns the size on success. Account for that
>> otherwise
>> the caller incorrectly thinks this is an error in
>> intel_atomic_prepare_plane_clear_colors().
>>
>> Fixes: b6308aaa24a7 ("drm/xe/display: Update intel_bo_read_from_page
>> to use ttm_bo_access")
>> Link: https://gitlab.freedesktop.org/drm/xe/kernel/-/issues/3661
>> Signed-off-by: Matthew Auld <matthew.auld@intel.com>
>> Cc: Thomas Hellström <thomas.hellstrom@linux.intel.com>
>> Cc: Matthew Brost <matthew.brost@intel.com>
>> Cc: Jani Nikula <jani.nikula@intel.com>
>> ---
>>   drivers/gpu/drm/xe/display/intel_bo.c | 7 ++++++-
>>   1 file changed, 6 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/gpu/drm/xe/display/intel_bo.c
>> b/drivers/gpu/drm/xe/display/intel_bo.c
>> index 43141964f6f2..b2a8d06cc78a 100644
>> --- a/drivers/gpu/drm/xe/display/intel_bo.c
>> +++ b/drivers/gpu/drm/xe/display/intel_bo.c
>> @@ -40,8 +40,13 @@ int intel_bo_fb_mmap(struct drm_gem_object *obj,
>> struct vm_area_struct *vma)
>>   int intel_bo_read_from_page(struct drm_gem_object *obj, u64 offset,
>> void *dst, int size)
>>   {
>>   	struct xe_bo *bo = gem_to_xe_bo(obj);
>> +	int ret;
>>   
>> -	return ttm_bo_access(&bo->ttm, offset, dst, size, 0);
>> +	ret = ttm_bo_access(&bo->ttm, offset, dst, size, 0);
>> +	if (ret == size)
>> +		ret = 0;
>> +
>> +	return ret;
>>   }
>>   
> 
> Looking at how callers are using struct vm_operations_struct::access()
> it looks possible that 0 <= ret < size, indicating the number of bytes
> actually processed.
> 
> Now since ttm_bo_access() is actually a helper to implement the above,
> we strictly don't have to follow that for its interface, but I think it
> makes sense to assert that ret is either == size or something negative.
> Ideas?

hmm, what about if we add something like:

+int xe_bo_read(struct xe_bo *bo, u64 offset, void *dst, int size)
+{
+       int ret;
+
+       ret = ttm_bo_access(&bo->ttm, offset, dst, size, 0);
+       if (!(ret < 0) && ret != size)
+               ret = -EIO;
+       else if (!(ret < 0))
+               ret = 0;
+
+       return ret;
+}

And then both callers use that?

> 
> /Thomas
> 
> 
> 
>>   struct intel_frontbuffer *intel_bo_get_frontbuffer(struct
>> drm_gem_object *obj)
> 


  reply	other threads:[~2024-12-02 16:28 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-12-02 15:41 [PATCH] drm/xe/display: fix ttm_bo_access() usage Matthew Auld
2024-12-02 15:47 ` ✓ CI.Patch_applied: success for " Patchwork
2024-12-02 15:47 ` ✓ CI.checkpatch: " Patchwork
2024-12-02 15:48 ` ✓ CI.KUnit: " Patchwork
2024-12-02 15:56 ` [PATCH] " Thomas Hellström
2024-12-02 16:28   ` Matthew Auld [this message]
2024-12-02 16:33     ` Thomas Hellström
2024-12-02 16:38       ` Matthew Auld
2024-12-02 16:14 ` ✓ CI.Build: success for " Patchwork
2024-12-02 16:18 ` ✓ CI.Hooks: " Patchwork
2024-12-02 16:20 ` ✓ CI.checksparse: " Patchwork
2024-12-02 16:41 ` ✓ Xe.CI.BAT: " Patchwork
2024-12-02 17:47 ` ✗ Xe.CI.Full: 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=602c7ab7-cab9-4790-a67c-306b23a75f23@intel.com \
    --to=matthew.auld@intel.com \
    --cc=intel-xe@lists.freedesktop.org \
    --cc=jani.nikula@intel.com \
    --cc=matthew.brost@intel.com \
    --cc=thomas.hellstrom@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox