diff mbox series

[v2,2/3] drm: shmem: Add drm_gem_shmem_map_offset() wrapper

Message ID 20190516141447.46839-3-steven.price@arm.com (mailing list archive)
State New, archived
Headers show
Series drm/panfrost: drm_gem_map_offset() helper | expand

Commit Message

Steven Price May 16, 2019, 2:14 p.m. UTC
Provide a wrapper for drm_gem_map_offset() for clients of shmem. This
wrapper provides the correct semantics for the drm_gem_shmem_mmap()
callback.

Signed-off-by: Steven Price <steven.price@arm.com>
---
 drivers/gpu/drm/drm_gem_shmem_helper.c | 20 ++++++++++++++++++++
 include/drm/drm_gem_shmem_helper.h     |  2 ++
 2 files changed, 22 insertions(+)

Comments

Steven Price May 20, 2019, 9:21 a.m. UTC | #1
On 16/05/2019 21:26, Daniel Vetter wrote:
> On Thu, May 16, 2019 at 03:14:46PM +0100, Steven Price wrote:
>> Provide a wrapper for drm_gem_map_offset() for clients of shmem. This
>> wrapper provides the correct semantics for the drm_gem_shmem_mmap()
>> callback.
>>
>> Signed-off-by: Steven Price <steven.price@arm.com>
>> ---
>>  drivers/gpu/drm/drm_gem_shmem_helper.c | 20 ++++++++++++++++++++
>>  include/drm/drm_gem_shmem_helper.h     |  2 ++
>>  2 files changed, 22 insertions(+)
>>
>> diff --git a/drivers/gpu/drm/drm_gem_shmem_helper.c b/drivers/gpu/drm/drm_gem_shmem_helper.c
>> index 1ee208c2c85e..9dbebc4897d1 100644
>> --- a/drivers/gpu/drm/drm_gem_shmem_helper.c
>> +++ b/drivers/gpu/drm/drm_gem_shmem_helper.c
>> @@ -400,6 +400,26 @@ int drm_gem_shmem_dumb_create(struct drm_file *file, struct drm_device *dev,
>>  }
>>  EXPORT_SYMBOL_GPL(drm_gem_shmem_dumb_create);
>>  
>> +/**
>> + * drm_gem_map_offset - return the fake mmap offset for a gem object
>> + * @file: drm file-private structure containing the gem object
>> + * @dev: corresponding drm_device
>> + * @handle: gem object handle
>> + * @offset: return location for the fake mmap offset
>> + *
>> + * This provides an offset suitable for user space to return to the
>> + * drm_gem_shmem_mmap() callback via an mmap() call.
>> + *
>> + * Returns:
>> + * 0 on success or a negative error code on failure.
>> + */
>> +int drm_gem_shmem_map_offset(struct drm_file *file, struct drm_device *dev,
>> +			     u32 handle, u64 *offset)
>> +{
>> +	return drm_gem_map_offset(file, dev, handle, offset);
>> +}
>> +EXPORT_SYMBOL_GPL(drm_gem_shmem_map_offset);
> 
> Not seeing the point of this mapper, since drm_gem_shmem_map_offset isn't
> speficic at all. It works for dumb, shmem, cma and private objects all
> equally well. I'd drop this and just directly call the underlying thing,
> no need to layer helpers.
> -Daniel

Ok, I'll drop it. I may have misunderstood, but I think Chris Wilson was
asking for it because shmem is the source of the particular requirements
of what can be mmap()d. But I think a helper can be added very easily if
anything changes, so this patch is probably premature.

I'll resend the series with this patch dropped.

Thanks,
Steve
diff mbox series

Patch

diff --git a/drivers/gpu/drm/drm_gem_shmem_helper.c b/drivers/gpu/drm/drm_gem_shmem_helper.c
index 1ee208c2c85e..9dbebc4897d1 100644
--- a/drivers/gpu/drm/drm_gem_shmem_helper.c
+++ b/drivers/gpu/drm/drm_gem_shmem_helper.c
@@ -400,6 +400,26 @@  int drm_gem_shmem_dumb_create(struct drm_file *file, struct drm_device *dev,
 }
 EXPORT_SYMBOL_GPL(drm_gem_shmem_dumb_create);
 
+/**
+ * drm_gem_map_offset - return the fake mmap offset for a gem object
+ * @file: drm file-private structure containing the gem object
+ * @dev: corresponding drm_device
+ * @handle: gem object handle
+ * @offset: return location for the fake mmap offset
+ *
+ * This provides an offset suitable for user space to return to the
+ * drm_gem_shmem_mmap() callback via an mmap() call.
+ *
+ * Returns:
+ * 0 on success or a negative error code on failure.
+ */
+int drm_gem_shmem_map_offset(struct drm_file *file, struct drm_device *dev,
+			     u32 handle, u64 *offset)
+{
+	return drm_gem_map_offset(file, dev, handle, offset);
+}
+EXPORT_SYMBOL_GPL(drm_gem_shmem_map_offset);
+
 static vm_fault_t drm_gem_shmem_fault(struct vm_fault *vmf)
 {
 	struct vm_area_struct *vma = vmf->vma;
diff --git a/include/drm/drm_gem_shmem_helper.h b/include/drm/drm_gem_shmem_helper.h
index 038b6d313447..4239ddaaaa4f 100644
--- a/include/drm/drm_gem_shmem_helper.h
+++ b/include/drm/drm_gem_shmem_helper.h
@@ -128,6 +128,8 @@  drm_gem_shmem_create_with_handle(struct drm_file *file_priv,
 int drm_gem_shmem_dumb_create(struct drm_file *file, struct drm_device *dev,
 			      struct drm_mode_create_dumb *args);
 
+int drm_gem_shmem_map_offset(struct drm_file *file, struct drm_device *dev,
+			     u32 handle, u64 *offset);
 int drm_gem_shmem_mmap(struct file *filp, struct vm_area_struct *vma);
 
 extern const struct vm_operations_struct drm_gem_shmem_vm_ops;