drm/exynos: add DRM_EXYNOS_GEM_MAP ioctl
diff mbox

Message ID 1444014266-14598-1-git-send-email-jy0922.shim@samsung.com
State New
Headers show

Commit Message

Joonyoung Shim Oct. 5, 2015, 3:04 a.m. UTC
The commit d931589c01a2 ("drm/exynos: remove DRM_EXYNOS_GEM_MAP_OFFSET
ioctl") removed it same with the ioctl that this patch adds. The reason
that removed DRM_EXYNOS_GEM_MAP_OFFSET was we could use
DRM_IOCTL_MODE_MAP_DUMB. Both did exactly same thing.

Now we again will revive it as DRM_EXYNOS_GEM_MAP because of render
node. DRM_IOCTL_MODE_MAP_DUMB isn't permitted in render node.

Signed-off-by: Joonyoung Shim <jy0922.shim@samsung.com>
---
 drivers/gpu/drm/exynos/exynos_drm_drv.c |  2 ++
 drivers/gpu/drm/exynos/exynos_drm_gem.c |  9 +++++++++
 drivers/gpu/drm/exynos/exynos_drm_gem.h |  4 ++++
 include/uapi/drm/exynos_drm.h           | 17 ++++++++++++++++-
 4 files changed, 31 insertions(+), 1 deletion(-)

Comments

Inki Dae Oct. 13, 2015, 5:11 a.m. UTC | #1
Merged.

Thanks,
Inki Dae

2015? 10? 05? 12:04? Joonyoung Shim ?(?) ? ?:
> The commit d931589c01a2 ("drm/exynos: remove DRM_EXYNOS_GEM_MAP_OFFSET
> ioctl") removed it same with the ioctl that this patch adds. The reason
> that removed DRM_EXYNOS_GEM_MAP_OFFSET was we could use
> DRM_IOCTL_MODE_MAP_DUMB. Both did exactly same thing.
>
> Now we again will revive it as DRM_EXYNOS_GEM_MAP because of render
> node. DRM_IOCTL_MODE_MAP_DUMB isn't permitted in render node.
>
> Signed-off-by: Joonyoung Shim <jy0922.shim@samsung.com>
> ---
>   drivers/gpu/drm/exynos/exynos_drm_drv.c |  2 ++
>   drivers/gpu/drm/exynos/exynos_drm_gem.c |  9 +++++++++
>   drivers/gpu/drm/exynos/exynos_drm_gem.h |  4 ++++
>   include/uapi/drm/exynos_drm.h           | 17 ++++++++++++++++-
>   4 files changed, 31 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/exynos/exynos_drm_drv.c b/drivers/gpu/drm/exynos/exynos_drm_drv.c
> index f0a5839..8fd7201 100644
> --- a/drivers/gpu/drm/exynos/exynos_drm_drv.c
> +++ b/drivers/gpu/drm/exynos/exynos_drm_drv.c
> @@ -404,6 +404,8 @@ static const struct vm_operations_struct exynos_drm_gem_vm_ops = {
>   static const struct drm_ioctl_desc exynos_ioctls[] = {
>   	DRM_IOCTL_DEF_DRV(EXYNOS_GEM_CREATE, exynos_drm_gem_create_ioctl,
>   			DRM_UNLOCKED | DRM_AUTH | DRM_RENDER_ALLOW),
> +	DRM_IOCTL_DEF_DRV(EXYNOS_GEM_MAP, exynos_drm_gem_map_ioctl,
> +			DRM_UNLOCKED | DRM_AUTH | DRM_RENDER_ALLOW),
>   	DRM_IOCTL_DEF_DRV(EXYNOS_GEM_GET, exynos_drm_gem_get_ioctl,
>   			DRM_UNLOCKED | DRM_RENDER_ALLOW),
>   	DRM_IOCTL_DEF_DRV(EXYNOS_VIDI_CONNECTION, vidi_connection_ioctl,
> diff --git a/drivers/gpu/drm/exynos/exynos_drm_gem.c b/drivers/gpu/drm/exynos/exynos_drm_gem.c
> index f1dcdd0..29f4875 100644
> --- a/drivers/gpu/drm/exynos/exynos_drm_gem.c
> +++ b/drivers/gpu/drm/exynos/exynos_drm_gem.c
> @@ -271,6 +271,15 @@ int exynos_drm_gem_create_ioctl(struct drm_device *dev, void *data,
>   	return 0;
>   }
>
> +int exynos_drm_gem_map_ioctl(struct drm_device *dev, void *data,
> +			     struct drm_file *file_priv)
> +{
> +	struct drm_exynos_gem_map *args = data;
> +
> +	return exynos_drm_gem_dumb_map_offset(file_priv, dev, args->handle,
> +					      &args->offset);
> +}
> +
>   dma_addr_t *exynos_drm_gem_get_dma_addr(struct drm_device *dev,
>   					unsigned int gem_handle,
>   					struct drm_file *filp)
> diff --git a/drivers/gpu/drm/exynos/exynos_drm_gem.h b/drivers/gpu/drm/exynos/exynos_drm_gem.h
> index 37ab8b2..0d0ab27 100644
> --- a/drivers/gpu/drm/exynos/exynos_drm_gem.h
> +++ b/drivers/gpu/drm/exynos/exynos_drm_gem.h
> @@ -73,6 +73,10 @@ struct exynos_drm_gem *exynos_drm_gem_create(struct drm_device *dev,
>   int exynos_drm_gem_create_ioctl(struct drm_device *dev, void *data,
>   				struct drm_file *file_priv);
>
> +/* get fake-offset of gem object that can be used with mmap. */
> +int exynos_drm_gem_map_ioctl(struct drm_device *dev, void *data,
> +			     struct drm_file *file_priv);
> +
>   /*
>    * get dma address from gem handle and this function could be used for
>    * other drivers such as 2d/3d acceleration drivers.
> diff --git a/include/uapi/drm/exynos_drm.h b/include/uapi/drm/exynos_drm.h
> index 5575ed1..18f0601 100644
> --- a/include/uapi/drm/exynos_drm.h
> +++ b/include/uapi/drm/exynos_drm.h
> @@ -33,6 +33,19 @@ struct drm_exynos_gem_create {
>   };
>
>   /**
> + * A structure for getting a fake-offset that can be used with mmap.
> + *
> + * @handle: handle of gem object.
> + * @reserved: just padding to be 64-bit aligned.
> + * @offset: a fake-offset of gem object.
> + */
> +struct drm_exynos_gem_map {
> +	__u32 handle;
> +	__u32 reserved;
> +	__u64 offset;
> +};
> +
> +/**
>    * A structure to gem information.
>    *
>    * @handle: a handle to gem object created.
> @@ -284,6 +297,7 @@ struct drm_exynos_ipp_cmd_ctrl {
>   };
>
>   #define DRM_EXYNOS_GEM_CREATE		0x00
> +#define DRM_EXYNOS_GEM_MAP		0x01
>   /* Reserved 0x03 ~ 0x05 for exynos specific gem ioctl */
>   #define DRM_EXYNOS_GEM_GET		0x04
>   #define DRM_EXYNOS_VIDI_CONNECTION	0x07
> @@ -301,7 +315,8 @@ struct drm_exynos_ipp_cmd_ctrl {
>
>   #define DRM_IOCTL_EXYNOS_GEM_CREATE		DRM_IOWR(DRM_COMMAND_BASE + \
>   		DRM_EXYNOS_GEM_CREATE, struct drm_exynos_gem_create)
> -
> +#define DRM_IOCTL_EXYNOS_GEM_MAP		DRM_IOWR(DRM_COMMAND_BASE + \
> +		DRM_EXYNOS_GEM_MAP, struct drm_exynos_gem_map)
>   #define DRM_IOCTL_EXYNOS_GEM_GET	DRM_IOWR(DRM_COMMAND_BASE + \
>   		DRM_EXYNOS_GEM_GET,	struct drm_exynos_gem_info)
>
>
Joonyoung Shim Oct. 13, 2015, 5:23 a.m. UTC | #2
On 10/13/2015 02:11 PM, Inki Dae wrote:
> 
> Merged.
> 

Thanks for merge but this will be conflicted with the patch of Daniel,
http://patchwork.freedesktop.org/patch/60565/

I found it on next-20151012, do you want v2 patch that DRM_UNLOCKED flag
is dropped?

Thanks.

> Thanks,
> Inki Dae
> 
> 2015? 10? 05? 12:04? Joonyoung Shim ?(?) ? ?:
>> The commit d931589c01a2 ("drm/exynos: remove DRM_EXYNOS_GEM_MAP_OFFSET
>> ioctl") removed it same with the ioctl that this patch adds. The reason
>> that removed DRM_EXYNOS_GEM_MAP_OFFSET was we could use
>> DRM_IOCTL_MODE_MAP_DUMB. Both did exactly same thing.
>>
>> Now we again will revive it as DRM_EXYNOS_GEM_MAP because of render
>> node. DRM_IOCTL_MODE_MAP_DUMB isn't permitted in render node.
>>
>> Signed-off-by: Joonyoung Shim <jy0922.shim@samsung.com>
>> ---
>>   drivers/gpu/drm/exynos/exynos_drm_drv.c |  2 ++
>>   drivers/gpu/drm/exynos/exynos_drm_gem.c |  9 +++++++++
>>   drivers/gpu/drm/exynos/exynos_drm_gem.h |  4 ++++
>>   include/uapi/drm/exynos_drm.h           | 17 ++++++++++++++++-
>>   4 files changed, 31 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/gpu/drm/exynos/exynos_drm_drv.c b/drivers/gpu/drm/exynos/exynos_drm_drv.c
>> index f0a5839..8fd7201 100644
>> --- a/drivers/gpu/drm/exynos/exynos_drm_drv.c
>> +++ b/drivers/gpu/drm/exynos/exynos_drm_drv.c
>> @@ -404,6 +404,8 @@ static const struct vm_operations_struct exynos_drm_gem_vm_ops = {
>>   static const struct drm_ioctl_desc exynos_ioctls[] = {
>>       DRM_IOCTL_DEF_DRV(EXYNOS_GEM_CREATE, exynos_drm_gem_create_ioctl,
>>               DRM_UNLOCKED | DRM_AUTH | DRM_RENDER_ALLOW),
>> +    DRM_IOCTL_DEF_DRV(EXYNOS_GEM_MAP, exynos_drm_gem_map_ioctl,
>> +            DRM_UNLOCKED | DRM_AUTH | DRM_RENDER_ALLOW),
>>       DRM_IOCTL_DEF_DRV(EXYNOS_GEM_GET, exynos_drm_gem_get_ioctl,
>>               DRM_UNLOCKED | DRM_RENDER_ALLOW),
>>       DRM_IOCTL_DEF_DRV(EXYNOS_VIDI_CONNECTION, vidi_connection_ioctl,
>> diff --git a/drivers/gpu/drm/exynos/exynos_drm_gem.c b/drivers/gpu/drm/exynos/exynos_drm_gem.c
>> index f1dcdd0..29f4875 100644
>> --- a/drivers/gpu/drm/exynos/exynos_drm_gem.c
>> +++ b/drivers/gpu/drm/exynos/exynos_drm_gem.c
>> @@ -271,6 +271,15 @@ int exynos_drm_gem_create_ioctl(struct drm_device *dev, void *data,
>>       return 0;
>>   }
>>
>> +int exynos_drm_gem_map_ioctl(struct drm_device *dev, void *data,
>> +                 struct drm_file *file_priv)
>> +{
>> +    struct drm_exynos_gem_map *args = data;
>> +
>> +    return exynos_drm_gem_dumb_map_offset(file_priv, dev, args->handle,
>> +                          &args->offset);
>> +}
>> +
>>   dma_addr_t *exynos_drm_gem_get_dma_addr(struct drm_device *dev,
>>                       unsigned int gem_handle,
>>                       struct drm_file *filp)
>> diff --git a/drivers/gpu/drm/exynos/exynos_drm_gem.h b/drivers/gpu/drm/exynos/exynos_drm_gem.h
>> index 37ab8b2..0d0ab27 100644
>> --- a/drivers/gpu/drm/exynos/exynos_drm_gem.h
>> +++ b/drivers/gpu/drm/exynos/exynos_drm_gem.h
>> @@ -73,6 +73,10 @@ struct exynos_drm_gem *exynos_drm_gem_create(struct drm_device *dev,
>>   int exynos_drm_gem_create_ioctl(struct drm_device *dev, void *data,
>>                   struct drm_file *file_priv);
>>
>> +/* get fake-offset of gem object that can be used with mmap. */
>> +int exynos_drm_gem_map_ioctl(struct drm_device *dev, void *data,
>> +                 struct drm_file *file_priv);
>> +
>>   /*
>>    * get dma address from gem handle and this function could be used for
>>    * other drivers such as 2d/3d acceleration drivers.
>> diff --git a/include/uapi/drm/exynos_drm.h b/include/uapi/drm/exynos_drm.h
>> index 5575ed1..18f0601 100644
>> --- a/include/uapi/drm/exynos_drm.h
>> +++ b/include/uapi/drm/exynos_drm.h
>> @@ -33,6 +33,19 @@ struct drm_exynos_gem_create {
>>   };
>>
>>   /**
>> + * A structure for getting a fake-offset that can be used with mmap.
>> + *
>> + * @handle: handle of gem object.
>> + * @reserved: just padding to be 64-bit aligned.
>> + * @offset: a fake-offset of gem object.
>> + */
>> +struct drm_exynos_gem_map {
>> +    __u32 handle;
>> +    __u32 reserved;
>> +    __u64 offset;
>> +};
>> +
>> +/**
>>    * A structure to gem information.
>>    *
>>    * @handle: a handle to gem object created.
>> @@ -284,6 +297,7 @@ struct drm_exynos_ipp_cmd_ctrl {
>>   };
>>
>>   #define DRM_EXYNOS_GEM_CREATE        0x00
>> +#define DRM_EXYNOS_GEM_MAP        0x01
>>   /* Reserved 0x03 ~ 0x05 for exynos specific gem ioctl */
>>   #define DRM_EXYNOS_GEM_GET        0x04
>>   #define DRM_EXYNOS_VIDI_CONNECTION    0x07
>> @@ -301,7 +315,8 @@ struct drm_exynos_ipp_cmd_ctrl {
>>
>>   #define DRM_IOCTL_EXYNOS_GEM_CREATE        DRM_IOWR(DRM_COMMAND_BASE + \
>>           DRM_EXYNOS_GEM_CREATE, struct drm_exynos_gem_create)
>> -
>> +#define DRM_IOCTL_EXYNOS_GEM_MAP        DRM_IOWR(DRM_COMMAND_BASE + \
>> +        DRM_EXYNOS_GEM_MAP, struct drm_exynos_gem_map)
>>   #define DRM_IOCTL_EXYNOS_GEM_GET    DRM_IOWR(DRM_COMMAND_BASE + \
>>           DRM_EXYNOS_GEM_GET,    struct drm_exynos_gem_info)
>>
>>
>
Joonyoung Shim Oct. 13, 2015, 5:32 a.m. UTC | #3
On 10/13/2015 02:23 PM, Joonyoung Shim wrote:
> On 10/13/2015 02:11 PM, Inki Dae wrote:
>>
>> Merged.
>>
> 
> Thanks for merge but this will be conflicted with the patch of Daniel,
> http://patchwork.freedesktop.org/patch/60565/
> 

Oops, wrong link,

http://lists.freedesktop.org/archives/intel-gfx/2015-September/075368.html

Thanks.

> I found it on next-20151012, do you want v2 patch that DRM_UNLOCKED flag
> is dropped?
> 
> Thanks.
> 
>> Thanks,
>> Inki Dae
>>
>> 2015? 10? 05? 12:04? Joonyoung Shim ?(?) ? ?:
>>> The commit d931589c01a2 ("drm/exynos: remove DRM_EXYNOS_GEM_MAP_OFFSET
>>> ioctl") removed it same with the ioctl that this patch adds. The reason
>>> that removed DRM_EXYNOS_GEM_MAP_OFFSET was we could use
>>> DRM_IOCTL_MODE_MAP_DUMB. Both did exactly same thing.
>>>
>>> Now we again will revive it as DRM_EXYNOS_GEM_MAP because of render
>>> node. DRM_IOCTL_MODE_MAP_DUMB isn't permitted in render node.
>>>
>>> Signed-off-by: Joonyoung Shim <jy0922.shim@samsung.com>
>>> ---
>>>   drivers/gpu/drm/exynos/exynos_drm_drv.c |  2 ++
>>>   drivers/gpu/drm/exynos/exynos_drm_gem.c |  9 +++++++++
>>>   drivers/gpu/drm/exynos/exynos_drm_gem.h |  4 ++++
>>>   include/uapi/drm/exynos_drm.h           | 17 ++++++++++++++++-
>>>   4 files changed, 31 insertions(+), 1 deletion(-)
>>>
>>> diff --git a/drivers/gpu/drm/exynos/exynos_drm_drv.c b/drivers/gpu/drm/exynos/exynos_drm_drv.c
>>> index f0a5839..8fd7201 100644
>>> --- a/drivers/gpu/drm/exynos/exynos_drm_drv.c
>>> +++ b/drivers/gpu/drm/exynos/exynos_drm_drv.c
>>> @@ -404,6 +404,8 @@ static const struct vm_operations_struct exynos_drm_gem_vm_ops = {
>>>   static const struct drm_ioctl_desc exynos_ioctls[] = {
>>>       DRM_IOCTL_DEF_DRV(EXYNOS_GEM_CREATE, exynos_drm_gem_create_ioctl,
>>>               DRM_UNLOCKED | DRM_AUTH | DRM_RENDER_ALLOW),
>>> +    DRM_IOCTL_DEF_DRV(EXYNOS_GEM_MAP, exynos_drm_gem_map_ioctl,
>>> +            DRM_UNLOCKED | DRM_AUTH | DRM_RENDER_ALLOW),
>>>       DRM_IOCTL_DEF_DRV(EXYNOS_GEM_GET, exynos_drm_gem_get_ioctl,
>>>               DRM_UNLOCKED | DRM_RENDER_ALLOW),
>>>       DRM_IOCTL_DEF_DRV(EXYNOS_VIDI_CONNECTION, vidi_connection_ioctl,
>>> diff --git a/drivers/gpu/drm/exynos/exynos_drm_gem.c b/drivers/gpu/drm/exynos/exynos_drm_gem.c
>>> index f1dcdd0..29f4875 100644
>>> --- a/drivers/gpu/drm/exynos/exynos_drm_gem.c
>>> +++ b/drivers/gpu/drm/exynos/exynos_drm_gem.c
>>> @@ -271,6 +271,15 @@ int exynos_drm_gem_create_ioctl(struct drm_device *dev, void *data,
>>>       return 0;
>>>   }
>>>
>>> +int exynos_drm_gem_map_ioctl(struct drm_device *dev, void *data,
>>> +                 struct drm_file *file_priv)
>>> +{
>>> +    struct drm_exynos_gem_map *args = data;
>>> +
>>> +    return exynos_drm_gem_dumb_map_offset(file_priv, dev, args->handle,
>>> +                          &args->offset);
>>> +}
>>> +
>>>   dma_addr_t *exynos_drm_gem_get_dma_addr(struct drm_device *dev,
>>>                       unsigned int gem_handle,
>>>                       struct drm_file *filp)
>>> diff --git a/drivers/gpu/drm/exynos/exynos_drm_gem.h b/drivers/gpu/drm/exynos/exynos_drm_gem.h
>>> index 37ab8b2..0d0ab27 100644
>>> --- a/drivers/gpu/drm/exynos/exynos_drm_gem.h
>>> +++ b/drivers/gpu/drm/exynos/exynos_drm_gem.h
>>> @@ -73,6 +73,10 @@ struct exynos_drm_gem *exynos_drm_gem_create(struct drm_device *dev,
>>>   int exynos_drm_gem_create_ioctl(struct drm_device *dev, void *data,
>>>                   struct drm_file *file_priv);
>>>
>>> +/* get fake-offset of gem object that can be used with mmap. */
>>> +int exynos_drm_gem_map_ioctl(struct drm_device *dev, void *data,
>>> +                 struct drm_file *file_priv);
>>> +
>>>   /*
>>>    * get dma address from gem handle and this function could be used for
>>>    * other drivers such as 2d/3d acceleration drivers.
>>> diff --git a/include/uapi/drm/exynos_drm.h b/include/uapi/drm/exynos_drm.h
>>> index 5575ed1..18f0601 100644
>>> --- a/include/uapi/drm/exynos_drm.h
>>> +++ b/include/uapi/drm/exynos_drm.h
>>> @@ -33,6 +33,19 @@ struct drm_exynos_gem_create {
>>>   };
>>>
>>>   /**
>>> + * A structure for getting a fake-offset that can be used with mmap.
>>> + *
>>> + * @handle: handle of gem object.
>>> + * @reserved: just padding to be 64-bit aligned.
>>> + * @offset: a fake-offset of gem object.
>>> + */
>>> +struct drm_exynos_gem_map {
>>> +    __u32 handle;
>>> +    __u32 reserved;
>>> +    __u64 offset;
>>> +};
>>> +
>>> +/**
>>>    * A structure to gem information.
>>>    *
>>>    * @handle: a handle to gem object created.
>>> @@ -284,6 +297,7 @@ struct drm_exynos_ipp_cmd_ctrl {
>>>   };
>>>
>>>   #define DRM_EXYNOS_GEM_CREATE        0x00
>>> +#define DRM_EXYNOS_GEM_MAP        0x01
>>>   /* Reserved 0x03 ~ 0x05 for exynos specific gem ioctl */
>>>   #define DRM_EXYNOS_GEM_GET        0x04
>>>   #define DRM_EXYNOS_VIDI_CONNECTION    0x07
>>> @@ -301,7 +315,8 @@ struct drm_exynos_ipp_cmd_ctrl {
>>>
>>>   #define DRM_IOCTL_EXYNOS_GEM_CREATE        DRM_IOWR(DRM_COMMAND_BASE + \
>>>           DRM_EXYNOS_GEM_CREATE, struct drm_exynos_gem_create)
>>> -
>>> +#define DRM_IOCTL_EXYNOS_GEM_MAP        DRM_IOWR(DRM_COMMAND_BASE + \
>>> +        DRM_EXYNOS_GEM_MAP, struct drm_exynos_gem_map)
>>>   #define DRM_IOCTL_EXYNOS_GEM_GET    DRM_IOWR(DRM_COMMAND_BASE + \
>>>           DRM_EXYNOS_GEM_GET,    struct drm_exynos_gem_info)
>>>
>>>
>>
>
Inki Dae Oct. 13, 2015, 5:50 a.m. UTC | #4
2015? 10? 13? 14:23? Joonyoung Shim ?(?) ? ?:
> On 10/13/2015 02:11 PM, Inki Dae wrote:
>>
>> Merged.
>>
>
> Thanks for merge but this will be conflicted with the patch of Daniel,
> http://patchwork.freedesktop.org/patch/60565/

Right. With Daniel patch, DRM_UNLOCKED flag isn't needed anymore for 
driver specific ioctls.

>
> I found it on next-20151012, do you want v2 patch that DRM_UNLOCKED flag
> is dropped?

It'd be better to drop the flag for cleanup. Anyway, I can do it.

Thanks,
Inki Dae

>
> Thanks.
>
>> Thanks,
>> Inki Dae
>>
>> 2015? 10? 05? 12:04? Joonyoung Shim ?(?) ? ?:
>>> The commit d931589c01a2 ("drm/exynos: remove DRM_EXYNOS_GEM_MAP_OFFSET
>>> ioctl") removed it same with the ioctl that this patch adds. The reason
>>> that removed DRM_EXYNOS_GEM_MAP_OFFSET was we could use
>>> DRM_IOCTL_MODE_MAP_DUMB. Both did exactly same thing.
>>>
>>> Now we again will revive it as DRM_EXYNOS_GEM_MAP because of render
>>> node. DRM_IOCTL_MODE_MAP_DUMB isn't permitted in render node.
>>>
>>> Signed-off-by: Joonyoung Shim <jy0922.shim@samsung.com>
>>> ---
>>>    drivers/gpu/drm/exynos/exynos_drm_drv.c |  2 ++
>>>    drivers/gpu/drm/exynos/exynos_drm_gem.c |  9 +++++++++
>>>    drivers/gpu/drm/exynos/exynos_drm_gem.h |  4 ++++
>>>    include/uapi/drm/exynos_drm.h           | 17 ++++++++++++++++-
>>>    4 files changed, 31 insertions(+), 1 deletion(-)
>>>
>>> diff --git a/drivers/gpu/drm/exynos/exynos_drm_drv.c b/drivers/gpu/drm/exynos/exynos_drm_drv.c
>>> index f0a5839..8fd7201 100644
>>> --- a/drivers/gpu/drm/exynos/exynos_drm_drv.c
>>> +++ b/drivers/gpu/drm/exynos/exynos_drm_drv.c
>>> @@ -404,6 +404,8 @@ static const struct vm_operations_struct exynos_drm_gem_vm_ops = {
>>>    static const struct drm_ioctl_desc exynos_ioctls[] = {
>>>        DRM_IOCTL_DEF_DRV(EXYNOS_GEM_CREATE, exynos_drm_gem_create_ioctl,
>>>                DRM_UNLOCKED | DRM_AUTH | DRM_RENDER_ALLOW),
>>> +    DRM_IOCTL_DEF_DRV(EXYNOS_GEM_MAP, exynos_drm_gem_map_ioctl,
>>> +            DRM_UNLOCKED | DRM_AUTH | DRM_RENDER_ALLOW),
>>>        DRM_IOCTL_DEF_DRV(EXYNOS_GEM_GET, exynos_drm_gem_get_ioctl,
>>>                DRM_UNLOCKED | DRM_RENDER_ALLOW),
>>>        DRM_IOCTL_DEF_DRV(EXYNOS_VIDI_CONNECTION, vidi_connection_ioctl,
>>> diff --git a/drivers/gpu/drm/exynos/exynos_drm_gem.c b/drivers/gpu/drm/exynos/exynos_drm_gem.c
>>> index f1dcdd0..29f4875 100644
>>> --- a/drivers/gpu/drm/exynos/exynos_drm_gem.c
>>> +++ b/drivers/gpu/drm/exynos/exynos_drm_gem.c
>>> @@ -271,6 +271,15 @@ int exynos_drm_gem_create_ioctl(struct drm_device *dev, void *data,
>>>        return 0;
>>>    }
>>>
>>> +int exynos_drm_gem_map_ioctl(struct drm_device *dev, void *data,
>>> +                 struct drm_file *file_priv)
>>> +{
>>> +    struct drm_exynos_gem_map *args = data;
>>> +
>>> +    return exynos_drm_gem_dumb_map_offset(file_priv, dev, args->handle,
>>> +                          &args->offset);
>>> +}
>>> +
>>>    dma_addr_t *exynos_drm_gem_get_dma_addr(struct drm_device *dev,
>>>                        unsigned int gem_handle,
>>>                        struct drm_file *filp)
>>> diff --git a/drivers/gpu/drm/exynos/exynos_drm_gem.h b/drivers/gpu/drm/exynos/exynos_drm_gem.h
>>> index 37ab8b2..0d0ab27 100644
>>> --- a/drivers/gpu/drm/exynos/exynos_drm_gem.h
>>> +++ b/drivers/gpu/drm/exynos/exynos_drm_gem.h
>>> @@ -73,6 +73,10 @@ struct exynos_drm_gem *exynos_drm_gem_create(struct drm_device *dev,
>>>    int exynos_drm_gem_create_ioctl(struct drm_device *dev, void *data,
>>>                    struct drm_file *file_priv);
>>>
>>> +/* get fake-offset of gem object that can be used with mmap. */
>>> +int exynos_drm_gem_map_ioctl(struct drm_device *dev, void *data,
>>> +                 struct drm_file *file_priv);
>>> +
>>>    /*
>>>     * get dma address from gem handle and this function could be used for
>>>     * other drivers such as 2d/3d acceleration drivers.
>>> diff --git a/include/uapi/drm/exynos_drm.h b/include/uapi/drm/exynos_drm.h
>>> index 5575ed1..18f0601 100644
>>> --- a/include/uapi/drm/exynos_drm.h
>>> +++ b/include/uapi/drm/exynos_drm.h
>>> @@ -33,6 +33,19 @@ struct drm_exynos_gem_create {
>>>    };
>>>
>>>    /**
>>> + * A structure for getting a fake-offset that can be used with mmap.
>>> + *
>>> + * @handle: handle of gem object.
>>> + * @reserved: just padding to be 64-bit aligned.
>>> + * @offset: a fake-offset of gem object.
>>> + */
>>> +struct drm_exynos_gem_map {
>>> +    __u32 handle;
>>> +    __u32 reserved;
>>> +    __u64 offset;
>>> +};
>>> +
>>> +/**
>>>     * A structure to gem information.
>>>     *
>>>     * @handle: a handle to gem object created.
>>> @@ -284,6 +297,7 @@ struct drm_exynos_ipp_cmd_ctrl {
>>>    };
>>>
>>>    #define DRM_EXYNOS_GEM_CREATE        0x00
>>> +#define DRM_EXYNOS_GEM_MAP        0x01
>>>    /* Reserved 0x03 ~ 0x05 for exynos specific gem ioctl */
>>>    #define DRM_EXYNOS_GEM_GET        0x04
>>>    #define DRM_EXYNOS_VIDI_CONNECTION    0x07
>>> @@ -301,7 +315,8 @@ struct drm_exynos_ipp_cmd_ctrl {
>>>
>>>    #define DRM_IOCTL_EXYNOS_GEM_CREATE        DRM_IOWR(DRM_COMMAND_BASE + \
>>>            DRM_EXYNOS_GEM_CREATE, struct drm_exynos_gem_create)
>>> -
>>> +#define DRM_IOCTL_EXYNOS_GEM_MAP        DRM_IOWR(DRM_COMMAND_BASE + \
>>> +        DRM_EXYNOS_GEM_MAP, struct drm_exynos_gem_map)
>>>    #define DRM_IOCTL_EXYNOS_GEM_GET    DRM_IOWR(DRM_COMMAND_BASE + \
>>>            DRM_EXYNOS_GEM_GET,    struct drm_exynos_gem_info)
>>>
>>>
>>
>
>

Patch
diff mbox

diff --git a/drivers/gpu/drm/exynos/exynos_drm_drv.c b/drivers/gpu/drm/exynos/exynos_drm_drv.c
index f0a5839..8fd7201 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_drv.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_drv.c
@@ -404,6 +404,8 @@  static const struct vm_operations_struct exynos_drm_gem_vm_ops = {
 static const struct drm_ioctl_desc exynos_ioctls[] = {
 	DRM_IOCTL_DEF_DRV(EXYNOS_GEM_CREATE, exynos_drm_gem_create_ioctl,
 			DRM_UNLOCKED | DRM_AUTH | DRM_RENDER_ALLOW),
+	DRM_IOCTL_DEF_DRV(EXYNOS_GEM_MAP, exynos_drm_gem_map_ioctl,
+			DRM_UNLOCKED | DRM_AUTH | DRM_RENDER_ALLOW),
 	DRM_IOCTL_DEF_DRV(EXYNOS_GEM_GET, exynos_drm_gem_get_ioctl,
 			DRM_UNLOCKED | DRM_RENDER_ALLOW),
 	DRM_IOCTL_DEF_DRV(EXYNOS_VIDI_CONNECTION, vidi_connection_ioctl,
diff --git a/drivers/gpu/drm/exynos/exynos_drm_gem.c b/drivers/gpu/drm/exynos/exynos_drm_gem.c
index f1dcdd0..29f4875 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_gem.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_gem.c
@@ -271,6 +271,15 @@  int exynos_drm_gem_create_ioctl(struct drm_device *dev, void *data,
 	return 0;
 }
 
+int exynos_drm_gem_map_ioctl(struct drm_device *dev, void *data,
+			     struct drm_file *file_priv)
+{
+	struct drm_exynos_gem_map *args = data;
+
+	return exynos_drm_gem_dumb_map_offset(file_priv, dev, args->handle,
+					      &args->offset);
+}
+
 dma_addr_t *exynos_drm_gem_get_dma_addr(struct drm_device *dev,
 					unsigned int gem_handle,
 					struct drm_file *filp)
diff --git a/drivers/gpu/drm/exynos/exynos_drm_gem.h b/drivers/gpu/drm/exynos/exynos_drm_gem.h
index 37ab8b2..0d0ab27 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_gem.h
+++ b/drivers/gpu/drm/exynos/exynos_drm_gem.h
@@ -73,6 +73,10 @@  struct exynos_drm_gem *exynos_drm_gem_create(struct drm_device *dev,
 int exynos_drm_gem_create_ioctl(struct drm_device *dev, void *data,
 				struct drm_file *file_priv);
 
+/* get fake-offset of gem object that can be used with mmap. */
+int exynos_drm_gem_map_ioctl(struct drm_device *dev, void *data,
+			     struct drm_file *file_priv);
+
 /*
  * get dma address from gem handle and this function could be used for
  * other drivers such as 2d/3d acceleration drivers.
diff --git a/include/uapi/drm/exynos_drm.h b/include/uapi/drm/exynos_drm.h
index 5575ed1..18f0601 100644
--- a/include/uapi/drm/exynos_drm.h
+++ b/include/uapi/drm/exynos_drm.h
@@ -33,6 +33,19 @@  struct drm_exynos_gem_create {
 };
 
 /**
+ * A structure for getting a fake-offset that can be used with mmap.
+ *
+ * @handle: handle of gem object.
+ * @reserved: just padding to be 64-bit aligned.
+ * @offset: a fake-offset of gem object.
+ */
+struct drm_exynos_gem_map {
+	__u32 handle;
+	__u32 reserved;
+	__u64 offset;
+};
+
+/**
  * A structure to gem information.
  *
  * @handle: a handle to gem object created.
@@ -284,6 +297,7 @@  struct drm_exynos_ipp_cmd_ctrl {
 };
 
 #define DRM_EXYNOS_GEM_CREATE		0x00
+#define DRM_EXYNOS_GEM_MAP		0x01
 /* Reserved 0x03 ~ 0x05 for exynos specific gem ioctl */
 #define DRM_EXYNOS_GEM_GET		0x04
 #define DRM_EXYNOS_VIDI_CONNECTION	0x07
@@ -301,7 +315,8 @@  struct drm_exynos_ipp_cmd_ctrl {
 
 #define DRM_IOCTL_EXYNOS_GEM_CREATE		DRM_IOWR(DRM_COMMAND_BASE + \
 		DRM_EXYNOS_GEM_CREATE, struct drm_exynos_gem_create)
-
+#define DRM_IOCTL_EXYNOS_GEM_MAP		DRM_IOWR(DRM_COMMAND_BASE + \
+		DRM_EXYNOS_GEM_MAP, struct drm_exynos_gem_map)
 #define DRM_IOCTL_EXYNOS_GEM_GET	DRM_IOWR(DRM_COMMAND_BASE + \
 		DRM_EXYNOS_GEM_GET,	struct drm_exynos_gem_info)