mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Christian König" <christian.koenig@amd.com>
To: Pierre-Eric Pelloux-Prayer <pierre-eric@damsy.net>,
	Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>,
	Alex Deucher <alexander.deucher@amd.com>,
	David Airlie <airlied@gmail.com>, Simona Vetter <simona@ffwll.ch>,
	Sumit Semwal <sumit.semwal@linaro.org>
Cc: amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org,
	linux-kernel@vger.kernel.org, linux-media@vger.kernel.org,
	linaro-mm-sig@lists.linaro.org
Subject: Re: [PATCH v1 1/2] drm/amdgpu: make non-NULL out fence mandatory
Date: Tue, 16 Sep 2025 14:51:50 +0200	[thread overview]
Message-ID: <388ddaf9-2a43-4c70-aed6-370b9f38887b@amd.com> (raw)
In-Reply-To: <3b4f8837-e0a8-4e8c-9d33-5f107e41c55d@damsy.net>

On 16.09.25 13:58, Pierre-Eric Pelloux-Prayer wrote:
> 
> 
> Le 16/09/2025 à 12:52, Christian König a écrit :
>> On 16.09.25 11:46, Pierre-Eric Pelloux-Prayer wrote:
>>>
>>>
>>> Le 16/09/2025 à 11:25, Christian König a écrit :
>>>> On 16.09.25 09:08, Pierre-Eric Pelloux-Prayer wrote:
>>>>> amdgpu_ttm_copy_mem_to_mem has a single caller, make sure the out
>>>>> fence is non-NULL to simplify the code.
>>>>> Since none of the pointers should be NULL, we can enable
>>>>> __attribute__((nonnull))__.
>>>>>
>>>>> While at it make the function static since it's only used from
>>>>> amdgpuu_ttm.c.
>>>>>
>>>>> Signed-off-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
>>>>> ---
>>>>>    drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 17 ++++++++---------
>>>>>    drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h |  6 ------
>>>>>    2 files changed, 8 insertions(+), 15 deletions(-)
>>>>>
>>>>> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
>>>>> index 27ab4e754b2a..70b817b5578d 100644
>>>>> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
>>>>> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
>>>>> @@ -284,12 +284,13 @@ static int amdgpu_ttm_map_buffer(struct ttm_buffer_object *bo,
>>>>>     * move and different for a BO to BO copy.
>>>>>     *
>>>>>     */
>>>>> -int amdgpu_ttm_copy_mem_to_mem(struct amdgpu_device *adev,
>>>>> -                   const struct amdgpu_copy_mem *src,
>>>>> -                   const struct amdgpu_copy_mem *dst,
>>>>> -                   uint64_t size, bool tmz,
>>>>> -                   struct dma_resv *resv,
>>>>> -                   struct dma_fence **f)
>>>>> +__attribute__((nonnull))
>>>>
>>>> That looks fishy.
>>>>
>>>>> +static int amdgpu_ttm_copy_mem_to_mem(struct amdgpu_device *adev,
>>>>> +                      const struct amdgpu_copy_mem *src,
>>>>> +                      const struct amdgpu_copy_mem *dst,
>>>>> +                      uint64_t size, bool tmz,
>>>>> +                      struct dma_resv *resv,
>>>>> +                      struct dma_fence **f)
>>>>
>>>> I'm not an expert for those, but looking at other examples that should be here and look something like:
>>>>
>>>> __attribute__((nonnull(7)))
>>>
>>> Both syntax are valid. The GCC docs says:
>>>
>>>     If no arg-index is given to the nonnull attribute, all pointer arguments are marked as non-null
>>
>> Never seen that before. Is that gcc specifc or standardized?
> 
> clang supports it:
> 
> https://clang.llvm.org/docs/AttributeReference.html#id10
> 
> And both syntaxes are already used in the drm subtree by i915.

Ok in that case Reviewed-by: Christian König <christian.koenig@amd.com>.

Regards,
Christian.

> 
> Pierre-Eric
> 
>>
>>>
>>>
>>>>
>>>> But I think for this case here it is also not a must have to have that.
>>>
>>> I can remove it if you prefer, but it doesn't hurt to have the compiler validate usage of the functions.
>>
>> Yeah it's clearly useful, but I'm worried that clang won't like it.
>>
>> Christian.
>>
>>>
>>> Pierre-Eric
>>>
>>>
>>>>
>>>> Regards,
>>>> Christian.
>>>>
>>>>>    {
>>>>>        struct amdgpu_ring *ring = adev->mman.buffer_funcs_ring;
>>>>>        struct amdgpu_res_cursor src_mm, dst_mm;
>>>>> @@ -363,9 +364,7 @@ int amdgpu_ttm_copy_mem_to_mem(struct amdgpu_device *adev,
>>>>>        }
>>>>>    error:
>>>>>        mutex_unlock(&adev->mman.gtt_window_lock);
>>>>> -    if (f)
>>>>> -        *f = dma_fence_get(fence);
>>>>> -    dma_fence_put(fence);
>>>>> +    *f = fence;
>>>>>        return r;
>>>>>    }
>>>>>    diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h
>>>>> index bb17987f0447..07ae2853c77c 100644
>>>>> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h
>>>>> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h
>>>>> @@ -170,12 +170,6 @@ int amdgpu_copy_buffer(struct amdgpu_ring *ring, uint64_t src_offset,
>>>>>                   struct dma_resv *resv,
>>>>>                   struct dma_fence **fence, bool direct_submit,
>>>>>                   bool vm_needs_flush, uint32_t copy_flags);
>>>>> -int amdgpu_ttm_copy_mem_to_mem(struct amdgpu_device *adev,
>>>>> -                   const struct amdgpu_copy_mem *src,
>>>>> -                   const struct amdgpu_copy_mem *dst,
>>>>> -                   uint64_t size, bool tmz,
>>>>> -                   struct dma_resv *resv,
>>>>> -                   struct dma_fence **f);
>>>>>    int amdgpu_ttm_clear_buffer(struct amdgpu_bo *bo,
>>>>>                    struct dma_resv *resv,
>>>>>                    struct dma_fence **fence);
>>


      reply	other threads:[~2025-09-16 12:51 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-09-16  7:08 Pierre-Eric Pelloux-Prayer
2025-09-16  7:08 ` [PATCH v1 2/2] drm/amdgpu: remove gart_window_lock usage from gmc v12 Pierre-Eric Pelloux-Prayer
2025-09-16  9:25   ` Christian König
2025-09-16  9:25 ` [PATCH v1 1/2] drm/amdgpu: make non-NULL out fence mandatory Christian König
2025-09-16  9:46   ` Pierre-Eric Pelloux-Prayer
2025-09-16 10:52     ` Christian König
2025-09-16 11:58       ` Pierre-Eric Pelloux-Prayer
2025-09-16 12:51         ` Christian König [this message]

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=388ddaf9-2a43-4c70-aed6-370b9f38887b@amd.com \
    --to=christian.koenig@amd.com \
    --cc=airlied@gmail.com \
    --cc=alexander.deucher@amd.com \
    --cc=amd-gfx@lists.freedesktop.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=linaro-mm-sig@lists.linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=pierre-eric.pelloux-prayer@amd.com \
    --cc=pierre-eric@damsy.net \
    --cc=simona@ffwll.ch \
    --cc=sumit.semwal@linaro.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

all inboxes | Powered by JetHome®