[PATCH 22/24] drm/amdkfd: Adding new IOCTL for scratch memory v2

Oded Gabbay oded.gabbay at gmail.com
Tue Aug 22 06:21:39 UTC 2017


On Mon, Aug 21, 2017 at 11:11 PM, Felix Kuehling <felix.kuehling at amd.com> wrote:
> On 2017-08-21 04:01 PM, Jerome Glisse wrote:
>>> From this explanation, I think that the user's supplied VA should be
>>> tested that its a valid writable area of the user.
>>> How do you test for that ? could you point me to such a code in the kernel ?
>>> From looking at other drivers that pin host memory, like mellanox nic,
>>> they don't do any special testing for the address they receive from
>>> the user.
>> GUP (get_user_page()) will perform proper check on your behalf.
>> I am assuming those driver use GUP.
>
Ah, ok. I thought you refer to some other check that needs to be done
*before* calling get_user_page().
As Felix said, for APU the GPU doesn't need the memory to be pinned
and it uses the ATS to access it directly so we don't call
get_user_page() or some other function that calls it eventually.

On dGPU I guess it would be similar to what is done in most drivers
that need to pin user memory, by calling to get_user_page().

Oded

> On APUs, the GPU can address memory directly through ATS. So it doesn't
> use GUP. The GPU uses the same page tables as the CPU, so uses the same
> access bits to check permissions on the fly.
>
> On dGPU, when we use VRAM for scratch backing, that doesn't use GUP. In
> theory it should be possible to use GUP (using our userptr mechanism).
> In that case GUP would check the access permissions of the underlying
> mapping.
>
> Regards,
>   Felix
>
>>
>> Jérôme
>


More information about the amd-gfx mailing list