[PATCH 1/6] drm: Add helper to cast DMA-buf to GEM object v2

Felix Kuehling felix.kuehling at amd.com
Thu Jul 20 18:23:37 UTC 2017


On 17-07-19 08:35 AM, William Lewis wrote:
>
> On 07/18/2017 09:22 PM, Felix Kuehling wrote:
>> @@ -609,16 +634,14 @@ struct drm_gem_object *drm_gem_prime_import(struct drm_device *dev,
>>   	struct drm_gem_object *obj;
>>   	int ret;
>>   
>> -	if (dma_buf->ops == &drm_gem_prime_dmabuf_ops) {
>> -		obj = dma_buf->priv;
>> -		if (obj->dev == dev) {
>> -			/*
>> -			 * Importing dmabuf exported from out own gem increases
>> -			 * refcount on gem itself instead of f_count of dmabuf.
>> -			 */
>> -			drm_gem_object_reference(obj);
>> -			return obj;
>> -		}
>> +	obj = drm_gem_prime_dmabuf_to_object(dma_buf, NULL);
>> +	if (obj && obj->dev == dev) {
>> +		/*
>> +		 * Importing dmabuf exported from out own gem increases
> s/out/our/

Yeah, I can fix that while I'm here. Though I didn't write that comment.
I only changed its indentation.

Regards,
  Felix

>
>> +		 * refcount on gem itself instead of f_count of dmabuf.
>> +		 */
>> +		drm_gem_object_reference(obj);
>> +		return obj;
>>   	}
>>   
>>   	if (!dev->driver->gem_prime_import_sg_table)
>> diff --git a/include/drm/drmP.h b/include/drm/drmP.h
>> index 6105c05..79c2b23 100644
>> --- a/include/drm/drmP.h
>> +++ b/include/drm/drmP.h
>> @@ -767,6 +767,8 @@ extern struct dma_buf *drm_gem_prime_export(struct drm_device *dev,
>>   extern int drm_gem_prime_handle_to_fd(struct drm_device *dev,
>>   		struct drm_file *file_priv, uint32_t handle, uint32_t flags,
>>   		int *prime_fd);
>> +extern struct drm_gem_object *drm_gem_prime_dmabuf_to_object(
>> +		struct dma_buf *dma_buf, struct drm_driver *driver);
>>   extern struct drm_gem_object *drm_gem_prime_import(struct drm_device *dev,
>>   		struct dma_buf *dma_buf);
>>   extern int drm_gem_prime_fd_to_handle(struct drm_device *dev,
> _______________________________________________
> amd-gfx mailing list
> amd-gfx at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/amd-gfx



More information about the amd-gfx mailing list