[Beignet] [PATCH] runtime: fix bug in cl_enqueue_read_buffer.

Zhigang Gong zhigang.gong at gmail.com
Thu Nov 13 23:29:32 PST 2014


Right, forgot to check the writing path. As userptr is disabled
currently, it will not cause real problem.
Will fix it soon. Thanks.

On Fri, Nov 14, 2014 at 11:30 AM, Zhenyu Wang <zhenyuw at linux.intel.com> wrote:
>
> yeah, also need for enqueue write for userptr buffer.
>
> On 2014.11.13 06:52:39 +0000, Guo, Yejun wrote:
>> LGTM, thanks.
>>
>> -----Original Message-----
>> From: Beignet [mailto:beignet-bounces at lists.freedesktop.org] On Behalf Of Zhigang Gong
>> Sent: Thursday, November 13, 2014 1:43 PM
>> To: beignet at lists.freedesktop.org
>> Cc: Gong, Zhigang
>> Subject: [Beignet] [PATCH] runtime: fix bug in cl_enqueue_read_buffer.
>>
>> If the buffer is a userptr buffer, we should copy it directly.
>> Otherwise, it fails in libdrm. As drm_intel_gem_bo_subdata() refuses
>> to read a userptr buffer object.
>>
>> Signed-off-by: Zhigang Gong <zhigang.gong at intel.com>
>> ---
>>  src/cl_enqueue.c | 11 ++++++++---
>>  1 file changed, 8 insertions(+), 3 deletions(-)
>>
>> diff --git a/src/cl_enqueue.c b/src/cl_enqueue.c
>> index fcffd05..5798e20 100644
>> --- a/src/cl_enqueue.c
>> +++ b/src/cl_enqueue.c
>> @@ -31,13 +31,18 @@
>>
>>  cl_int cl_enqueue_read_buffer(enqueue_data* data)
>>  {
>> +  cl_int err = CL_SUCCESS;
>>    cl_mem mem = data->mem_obj;
>>    assert(mem->type == CL_MEM_BUFFER_TYPE ||
>>           mem->type == CL_MEM_SUBBUFFER_TYPE);
>>    struct _cl_mem_buffer* buffer = (struct _cl_mem_buffer*)mem;
>> -
>> -  return cl_buffer_get_subdata(mem->bo, data->offset + buffer->sub_offset,
>> -                            data->size, data->ptr);
>> +  if (!mem->is_userptr) {
>> +    if (cl_buffer_get_subdata(mem->bo, data->offset + buffer->sub_offset,
>> +                            data->size, data->ptr) != 0)
>> +      err = CL_MAP_FAILURE;
>> +  } else
>> +    memcpy(data->ptr, (char*)mem->host_ptr + data->offset + buffer->sub_offset, data->size);
>> +  return err;
>>  }
>>
>>  cl_int cl_enqueue_read_buffer_rect(enqueue_data* data)
>> --
>> 1.8.3.2
>>
>> _______________________________________________
>> Beignet mailing list
>> Beignet at lists.freedesktop.org
>> http://lists.freedesktop.org/mailman/listinfo/beignet
>> _______________________________________________
>> Beignet mailing list
>> Beignet at lists.freedesktop.org
>> http://lists.freedesktop.org/mailman/listinfo/beignet
>
> --
> Open Source Technology Center, Intel ltd.
>
> $gpg --keyserver wwwkeys.pgp.net --recv-keys 4D781827
>
> _______________________________________________
> Beignet mailing list
> Beignet at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/beignet
>


More information about the Beignet mailing list