[PATCH] drm/amd/amdgpu: Add write() method to VRAM debugfs entry

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

 



On 29/08/17 08:46 AM, Christian König wrote:
> Am 29.08.2017 um 14:43 schrieb Tom St Denis:
>> Allows writing data to vram via debugfs.
>>
>> Signed-off-by: Tom St Denis <tom.stdenis at amd.com>
>> ---
>>   drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 41 
>> ++++++++++++++++++++++++++++++++-
>>   1 file changed, 40 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c 
>> b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
>> index c97a99427eea..cdc96d027707 100644
>> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
>> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
>> @@ -1671,10 +1671,49 @@ static ssize_t amdgpu_ttm_vram_read(struct 
>> file *f, char __user *buf,
>>       return result;
>>   }
>> +static ssize_t amdgpu_ttm_vram_write(struct file *f, const char 
>> __user *buf,
>> +                    size_t size, loff_t *pos)
>> +{
>> +    struct amdgpu_device *adev = file_inode(f)->i_private;
>> +    ssize_t result = 0;
>> +    int r;
>> +
>> +    if (size & 0x3 || *pos & 0x3)
>> +        return -EINVAL;
>> +
>> +    if (*pos >= adev->mc.mc_vram_size)
>> +        return -ENXIO;
>> +
>> +    while (size) {
>> +        unsigned long flags;
>> +        uint32_t value;
>> +
>> +        if (*pos >= adev->mc.mc_vram_size)
>> +            return result;
>> +
>> +        spin_lock_irqsave(&adev->mmio_idx_lock, flags);
>> +        WREG32(mmMM_INDEX, ((uint32_t)*pos) | 0x80000000);
>> +        WREG32(mmMM_INDEX_HI, *pos >> 31);
>> +        r = get_user(value, (uint32_t *)buf);
> 
> Don't call get_user() while holding a spin.
> 
>> +        if (r)
>> +            return r;
> 
> You forget to unlock the spin.

Yup, my bad.  I'll fix that up.

Tom


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

  Powered by Linux