[PATCH 07/21] drm/amdkfd: Clean up KFD_MMAP_ offset handling

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, May 11, 2018 at 6:57 PM, Felix Kuehling <felix.kuehling at amd.com> wrote:
> On 2018-05-11 04:52 AM, Oded Gabbay wrote:
>>> --- a/drivers/gpu/drm/amd/amdkfd/kfd_priv.h
>>> +++ b/drivers/gpu/drm/amd/amdkfd/kfd_priv.h
>>> @@ -41,9 +41,33 @@
>>>
>>>  #define KFD_SYSFS_FILE_MODE 0444
>>>
>>> -#define KFD_MMAP_DOORBELL_MASK 0x8000000000000ull
>>> -#define KFD_MMAP_EVENTS_MASK 0x4000000000000ull
>>> -#define KFD_MMAP_RESERVED_MEM_MASK 0x2000000000000ull
>>> +/* GPU ID hash width in bits */
>>> +#define KFD_GPU_ID_HASH_WIDTH 16
>>> +
>>> +/* Use upper bits of mmap offset to store KFD driver specific information.
>>> + * BITS[63:62] - Encode MMAP type
>>> + * BITS[61:46] - Encode gpu_id. To identify to which GPU the offset belongs to
>>> + * BITS[45:0]  - MMAP offset value
>>> + *
>>> + * NOTE: struct vm_area_struct.vm_pgoff uses offset in pages. Hence, these
>>> + *  defines are w.r.t to PAGE_SIZE
>>> + */
>>> +#define KFD_MMAP_TYPE_SHIFT    (62 - PAGE_SHIFT)
>>> +#define KFD_MMAP_TYPE_MASK     (0x3ULL << KFD_MMAP_TYPE_SHIFT)
>>> +#define KFD_MMAP_TYPE_DOORBELL (0x3ULL << KFD_MMAP_TYPE_SHIFT)
>>> +#define KFD_MMAP_TYPE_EVENTS   (0x2ULL << KFD_MMAP_TYPE_SHIFT)
>>> +#define KFD_MMAP_TYPE_RESERVED_MEM     (0x1ULL << KFD_MMAP_TYPE_SHIFT)
>> Isn't this new definition breaks existing user-space library (kfd thunk) ?
>> If that is the case we have a problem here.
>
> No, this does not break user mode, because user mode isn't aware of
> these definitions at all. The mmap offset comes from kernel mode and is
> opaque to user mode. User mode just passes it back down to kernel mode
> in the offset parameter of mmap. So the kernel can change the encoding
> of the mmap offset without breaking user mode.
>
Oops, you are correct of course, I forgot. That's what happens after 4
years of not seeing that particular code :)

Oded

> Regards,
>   Felix
>
>>
>> Oded
>>
>>
>


[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux