amd-gfx.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
From: Felix Kuehling <felix.kuehling@amd.com>
To: "Christian König" <christian.koenig@amd.com>,
	"Thomas Zimmermann" <tzimmermann@suse.de>,
	alexander.deucher@amd.com, airlied@linux.ie, daniel@ffwll.ch,
	bskeggs@redhat.com, ray.huang@amd.com,
	linux-graphics-maintainer@vmware.com, sroland@vmware.com,
	zackr@vmware.com, shashank.sharma@amd.com, sam@ravnborg.org,
	emil.velikov@collabora.com, nirmoy.das@amd.com
Cc: nouveau@lists.freedesktop.org, amd-gfx@lists.freedesktop.org,
	dri-devel@lists.freedesktop.org
Subject: Re: [PATCH 3/8] drm/amdgpu: Implement mmap as GEM object function
Date: Tue, 6 Apr 2021 11:22:44 -0400	[thread overview]
Message-ID: <e00ad6ad-ea3e-a8d3-c888-cb9e587c510a@amd.com> (raw)
In-Reply-To: <4d859bdf-a0c8-34f6-2f84-c7b0f0a226b5@amd.com>

Am 2021-04-06 um 9:04 a.m. schrieb Christian König:
> Am 06.04.21 um 14:52 schrieb Thomas Zimmermann:
>> Hi
>>
>> Am 06.04.21 um 14:42 schrieb Christian König:
>>> Hi Thomas,
>>>
>>> Am 06.04.21 um 13:55 schrieb Thomas Zimmermann:
>>>> Hi
>>>>
>>>> Am 06.04.21 um 12:56 schrieb Christian König:
>>>>>>
>>>>>> In the end I went with the semantics I found in amdgpu_mmap() and
>>>>>> handled KFD specially. Let me know if this requires to be changed.
>>>>>
>>>>> Well the question is where is the call to
>>>>> drm_vma_node_verify_access() now? Cause that needs to be skipped
>>>>> for KFD BOs.
>>>>
>>>> I see. It's now drm_vma_node_is_allowed(); called by
>>>> drm_gem_mmap(). [1] So drm_gem_mmap() cannot be used by amdgpu.
>>>>
>>>> If I understand the code at [2] correctly, KFD objects don't use
>>>> the GEM ioctl interfaces, but they still use the internal GEM
>>>> object that is part of the TTM BO. In this case, amdgpu could have
>>>> its own version of drm_gem_mmap(), which calls drm_gem_mmap_obj(),
>>>> [3] which in turn handles the mmap details via GEM object functions.
>>>
>>> Correct, well we could cleanup the KFD to use the GEM functions as
>>> well.
>>
>> The KFD code already calls amdgpu_gem_object_create(). It should have
>> the object-functions pointer set for use with mmap. Not sure what the
>> use of drm_vma_node_is_allowed() would involve.
>
> The KFD allows BOs to be mmaped with different offsets than what's
> used in the DRM node.
>
> So drm_vma_node_is_allowed() would return false as far as I know.

We used to mmap KFD BOs through the /dev/kfd file descriptor. We moved
that to using the /dev/dri/renderD* file descriptors a long time ago. If
there is some KFD special casing left in the code for BO mmap, it's
probably an oversight and we should be able to remove it.

We still have a few special mmaps in /dev/kfd, but they are for things
that don't involve GEM BOs that could be mmapped through the render
node: doorbells, MMIO pages and CWSR trap-handler mappings for APUs.

Regards,
  Felix


>
> Regards,
> Christian.
>
>>
>> Best regards
>> Thomas
>>
>>>
>>> Felix what exactly was your objections to using this?
>>>
>>> Regards,
>>> Christian.
>>>
>>>>
>>>> drm_gem_prime_mmap() doesn't do any additional verification.
>>>>
>>>> Best regards
>>>> Thomas
>>>>
>>>> [1]
>>>> https://elixir.bootlin.com/linux/v5.11.11/source/drivers/gpu/drm/drm_gem.c#L1156
>>>>
>>>> [2]
>>>> https://elixir.bootlin.com/linux/v5.11.11/source/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c#L1224
>>>>
>>>> [3]
>>>> https://elixir.bootlin.com/linux/v5.12-rc6/source/drivers/gpu/drm/drm_gem.c#L1053
>>>>
>>>>
>>>>
>>>>>
>>>>> Regards,
>>>>> Christian.
>>>>>
>>>>>>
>>>>>> Best regards
>>>>>> Thomas
>>>>>>
>>>>>>>> -
>>>>>>>>   int amdgpu_copy_buffer(struct amdgpu_ring *ring, uint64_t
>>>>>>>> src_offset,
>>>>>>>>                  uint64_t dst_offset, uint32_t byte_count,
>>>>>>>>                  struct dma_resv *resv,
>>>>>>>> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h
>>>>>>>> b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h
>>>>>>>> index dec0db8b0b13..6e51faad7371 100644
>>>>>>>> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h
>>>>>>>> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h
>>>>>>>> @@ -146,7 +146,6 @@ int amdgpu_fill_buffer(struct amdgpu_bo *bo,
>>>>>>>>               struct dma_resv *resv,
>>>>>>>>               struct dma_fence **fence);
>>>>>>>> -int amdgpu_mmap(struct file *filp, struct vm_area_struct *vma);
>>>>>>>>   int amdgpu_ttm_alloc_gart(struct ttm_buffer_object *bo);
>>>>>>>>   int amdgpu_ttm_recover_gart(struct ttm_buffer_object *tbo);
>>>>>>>>   uint64_t amdgpu_ttm_domain_start(struct amdgpu_device *adev,
>>>>>>>> uint32_t type);
>>>>>>>
>>>>>>> _______________________________________________
>>>>>>> dri-devel mailing list
>>>>>>> dri-devel@lists.freedesktop.org
>>>>>>> https://lists.freedesktop.org/mailman/listinfo/dri-devel
>>>>>>
>>>>>
>>>>> _______________________________________________
>>>>> dri-devel mailing list
>>>>> dri-devel@lists.freedesktop.org
>>>>> https://lists.freedesktop.org/mailman/listinfo/dri-devel
>>>>
>>>
>>> _______________________________________________
>>> dri-devel mailing list
>>> dri-devel@lists.freedesktop.org
>>> https://lists.freedesktop.org/mailman/listinfo/dri-devel
>>
>
_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

  reply	other threads:[~2021-04-06 15:23 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-06  9:08 [PATCH 0/8] drm: Clean up mmap for TTM-based GEM drivers Thomas Zimmermann
2021-04-06  9:08 ` [PATCH 1/8] drm/ttm: Don't override vm_ops callbacks, if set Thomas Zimmermann
2021-04-06  9:08 ` [PATCH 2/8] drm/amdgpu: Remove unused function amdgpu_bo_fbdev_mmap() Thomas Zimmermann
2021-04-06  9:43   ` Christian König
2021-04-06 10:21     ` Thomas Zimmermann
2021-04-06  9:08 ` [PATCH 3/8] drm/amdgpu: Implement mmap as GEM object function Thomas Zimmermann
2021-04-06  9:35   ` Christian König
2021-04-06 10:38     ` Thomas Zimmermann
2021-04-06 10:56       ` Christian König
2021-04-06 11:55         ` Thomas Zimmermann
2021-04-06 12:42           ` Christian König
2021-04-06 12:52             ` Thomas Zimmermann
2021-04-06 13:04               ` Christian König
2021-04-06 15:22                 ` Felix Kuehling [this message]
2021-04-06 15:27       ` Felix Kuehling
2021-04-07 11:25         ` Christian König
2021-04-07 19:34           ` Felix Kuehling
2021-04-07 19:49             ` Felix Kuehling
2021-04-08  4:45               ` Thomas Zimmermann
2021-04-14  7:44               ` Thomas Zimmermann
2021-04-14  8:37                 ` Felix Kuehling
2021-04-06  9:08 ` [PATCH 4/8] drm/radeon: " Thomas Zimmermann
2021-04-06  9:38   ` Christian König
2021-04-06 14:18   ` Alex Deucher
2021-04-06  9:09 ` [PATCH 5/8] drm/nouveau: " Thomas Zimmermann
2021-04-06  9:09 ` [PATCH 6/8] drm/vmwgfx: Inline ttm_bo_mmap() into vmwgfx driver Thomas Zimmermann
2021-04-07 16:52   ` Zack Rusin
2021-04-06  9:09 ` [PATCH 7/8] drm/vmwgfx: Inline vmw_verify_access() Thomas Zimmermann
2021-04-07 16:52   ` Zack Rusin
2021-04-06  9:09 ` [PATCH 8/8] drm/ttm: Remove ttm_bo_mmap() and friends Thomas Zimmermann
2021-04-06  9:40   ` Christian König
2021-04-08 11:19 ` [PATCH 0/8] drm: Clean up mmap for TTM-based GEM drivers Daniel Vetter
2021-04-08 11:38   ` Thomas Zimmermann
2021-04-08 11:42     ` 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=e00ad6ad-ea3e-a8d3-c888-cb9e587c510a@amd.com \
    --to=felix.kuehling@amd.com \
    --cc=airlied@linux.ie \
    --cc=alexander.deucher@amd.com \
    --cc=amd-gfx@lists.freedesktop.org \
    --cc=bskeggs@redhat.com \
    --cc=christian.koenig@amd.com \
    --cc=daniel@ffwll.ch \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=emil.velikov@collabora.com \
    --cc=linux-graphics-maintainer@vmware.com \
    --cc=nirmoy.das@amd.com \
    --cc=nouveau@lists.freedesktop.org \
    --cc=ray.huang@amd.com \
    --cc=sam@ravnborg.org \
    --cc=shashank.sharma@amd.com \
    --cc=sroland@vmware.com \
    --cc=tzimmermann@suse.de \
    --cc=zackr@vmware.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;
as well as URLs for NNTP newsgroup(s).