All of lore.kernel.org
 help / color / mirror / Atom feed
* libdrm/exynos: fix usage of removed ioctls
@ 2015-01-16 22:57 Tobias Jakobi
  2015-01-16 22:57 ` [PATCH 1/2] exynos: Don't use DRM_EXYNOS_GEM_{MAP_OFFSET/MMAP} ioctls Tobias Jakobi
  2015-01-16 22:57 ` [PATCH 2/2] exynos: remove " Tobias Jakobi
  0 siblings, 2 replies; 9+ messages in thread
From: Tobias Jakobi @ 2015-01-16 22:57 UTC (permalink / raw)
  To: dri-devel; +Cc: linux-samsung-soc

Hello,

these two patches are needed for the exynos component of libdrm to
properly work again. With the current stable 3.18.x the 'exynos_bo_map'
call is broken, making it impossible to get data from userspace into
a DRM buffer.

The patches were sent by Hyungwon Hwang some while ago, but the first
one was very much broken, so I fixed it up. I've put the changelog
into the commit message itself.

Please apply so that the exynos component is useable again.

With best wishes,
Tobias

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH 1/2] exynos: Don't use DRM_EXYNOS_GEM_{MAP_OFFSET/MMAP} ioctls
  2015-01-16 22:57 libdrm/exynos: fix usage of removed ioctls Tobias Jakobi
@ 2015-01-16 22:57 ` Tobias Jakobi
  2015-01-26  1:42   ` Hyungwon Hwang
  2015-01-16 22:57 ` [PATCH 2/2] exynos: remove " Tobias Jakobi
  1 sibling, 1 reply; 9+ messages in thread
From: Tobias Jakobi @ 2015-01-16 22:57 UTC (permalink / raw)
  To: dri-devel; +Cc: linux-samsung-soc, Hyungwon Hwang, Inki Dae, Tobias Jakobi

From: Hyungwon Hwang <human.hwang@samsung.com>

The ioctl DRM_EXYNOS_GEM_MAP_OFFSET and DRM_EXYNOS_GEM_MMAP are removed from
the linux kernel. This patch modifies libdrm and libkms to use drm generic
ioctls instead of the removed ioctls.

v2: The original patch was erroneous. In case the MODE_MAP_DUMB ioctl failed
    it would return the retvalue as a void-pointer. Users of libdrm would then
    happily use that ptr, eventually leading to a segfault. Change this to
    return NULL in that case and also restore the previous behaviour of logging
    to stderr.
    The other error was that 'bo->vaddr' was never filled with the mapped
    buffer address. Hence exynos_bo_map still returned NULL even if the
    buffer mapping succeeded.

Signed-off-by: Hyungwon Hwang <human.hwang@samsung.com>
Signed-off-by: Inki Dae <inki.dae@samsung.com>
Signed-off-by: Tobias Jakobi <tjakobi@math.uni-bielefeld.de>
---
 exynos/exynos_drm.c | 19 ++++++++++++-------
 libkms/exynos.c     |  7 ++++---
 2 files changed, 16 insertions(+), 10 deletions(-)

diff --git a/exynos/exynos_drm.c b/exynos/exynos_drm.c
index 4c7dd13..c5dd948 100644
--- a/exynos/exynos_drm.c
+++ b/exynos/exynos_drm.c
@@ -283,20 +283,25 @@ drm_public void *exynos_bo_map(struct exynos_bo *bo)
 {
 	if (!bo->vaddr) {
 		struct exynos_device *dev = bo->dev;
-		struct drm_exynos_gem_mmap req = {
-			.handle = bo->handle,
-			.size	= bo->size,
-		};
+		struct drm_mode_map_dumb arg;
+		void *map = NULL;
 		int ret;
 
-		ret = drmIoctl(dev->fd, DRM_IOCTL_EXYNOS_GEM_MMAP, &req);
+		memset(&arg, 0, sizeof(arg));
+		arg.handle = bo->handle;
+
+		ret = drmIoctl(dev->fd, DRM_IOCTL_MODE_MAP_DUMB, &arg);
 		if (ret) {
-			fprintf(stderr, "failed to mmap[%s].\n",
+			fprintf(stderr, "failed to map dumb buffer[%s].\n",
 				strerror(errno));
 			return NULL;
 		}
 
-		bo->vaddr = (void *)(uintptr_t)req.mapped;
+		map = drm_mmap(0, bo->size, PROT_READ | PROT_WRITE, MAP_SHARED,
+				dev->fd, arg.offset);
+
+		if (map != MAP_FAILED)
+			bo->vaddr = map;
 	}
 
 	return bo->vaddr;
diff --git a/libkms/exynos.c b/libkms/exynos.c
index 92e329c..1123482 100644
--- a/libkms/exynos.c
+++ b/libkms/exynos.c
@@ -25,6 +25,7 @@
 #include <sys/ioctl.h>
 #include "xf86drm.h"
 
+#include "libdrm.h"
 #include "exynos_drm.h"
 
 struct exynos_bo
@@ -124,7 +125,7 @@ static int
 exynos_bo_map(struct kms_bo *_bo, void **out)
 {
 	struct exynos_bo *bo = (struct exynos_bo *)_bo;
-	struct drm_exynos_gem_map_off arg;
+	struct drm_mode_map_dumb arg;
 	void *map = NULL;
 	int ret;
 
@@ -137,11 +138,11 @@ exynos_bo_map(struct kms_bo *_bo, void **out)
 	memset(&arg, 0, sizeof(arg));
 	arg.handle = bo->base.handle;
 
-	ret = drmCommandWriteRead(bo->base.kms->fd, DRM_EXYNOS_GEM_MAP_OFFSET, &arg, sizeof(arg));
+	ret = drmIoctl(bo->base.kms->fd, DRM_IOCTL_MODE_MAP_DUMB, &arg);
 	if (ret)
 		return ret;
 
-	map = mmap(0, bo->base.size, PROT_READ | PROT_WRITE, MAP_SHARED, bo->base.kms->fd, arg.offset);
+	map = drm_mmap(0, bo->base.size, PROT_READ | PROT_WRITE, MAP_SHARED, bo->base.kms->fd, arg.offset);
 	if (map == MAP_FAILED)
 		return -errno;
 
-- 
2.0.5

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH 2/2] exynos: remove DRM_EXYNOS_GEM_{MAP_OFFSET/MMAP} ioctls
  2015-01-16 22:57 libdrm/exynos: fix usage of removed ioctls Tobias Jakobi
  2015-01-16 22:57 ` [PATCH 1/2] exynos: Don't use DRM_EXYNOS_GEM_{MAP_OFFSET/MMAP} ioctls Tobias Jakobi
@ 2015-01-16 22:57 ` Tobias Jakobi
  1 sibling, 0 replies; 9+ messages in thread
From: Tobias Jakobi @ 2015-01-16 22:57 UTC (permalink / raw)
  To: dri-devel; +Cc: linux-samsung-soc, Hyungwon Hwang, Inki Dae, Tobias Jakobi

From: Hyungwon Hwang <human.hwang@samsung.com>

This patch removes the ioctls which are removed from the linux kernel.

Signed-off-by: Hyungwon Hwang <human.hwang@samsung.com>
Signed-off-by: Inki Dae <inki.dae@samsung.com>
Signed-off-by: Tobias Jakobi <tjakobi@math.uni-bielefeld.de>
---
 exynos/exynos_drm.h | 40 ----------------------------------------
 1 file changed, 40 deletions(-)

diff --git a/exynos/exynos_drm.h b/exynos/exynos_drm.h
index c3c6579..256c02f 100644
--- a/exynos/exynos_drm.h
+++ b/exynos/exynos_drm.h
@@ -47,38 +47,6 @@ struct drm_exynos_gem_create {
 };
 
 /**
- * A structure for getting buffer offset.
- *
- * @handle: a pointer to gem object created.
- * @pad: just padding to be 64-bit aligned.
- * @offset: relatived offset value of the memory region allocated.
- *	- this value should be set by user.
- */
-struct drm_exynos_gem_map_off {
-	unsigned int handle;
-	unsigned int pad;
-	uint64_t offset;
-};
-
-/**
- * A structure for mapping buffer.
- *
- * @handle: a handle to gem object created.
- * @pad: just padding to be 64-bit aligned.
- * @size: memory size to be mapped.
- * @mapped: having user virtual address mmaped.
- *	- this variable would be filled by exynos gem module
- *	of kernel side with user virtual address which is allocated
- *	by do_mmap().
- */
-struct drm_exynos_gem_mmap {
-	unsigned int handle;
-	unsigned int pad;
-	uint64_t size;
-	uint64_t mapped;
-};
-
-/**
  * A structure to gem information.
  *
  * @handle: a handle to gem object created.
@@ -164,8 +132,6 @@ struct drm_exynos_g2d_exec {
 };
 
 #define DRM_EXYNOS_GEM_CREATE		0x00
-#define DRM_EXYNOS_GEM_MAP_OFFSET	0x01
-#define DRM_EXYNOS_GEM_MMAP		0x02
 /* Reserved 0x04 ~ 0x05 for exynos specific gem ioctl */
 #define DRM_EXYNOS_GEM_GET		0x04
 #define DRM_EXYNOS_VIDI_CONNECTION	0x07
@@ -178,12 +144,6 @@ struct drm_exynos_g2d_exec {
 #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_OFFSET	DRM_IOWR(DRM_COMMAND_BASE + \
-		DRM_EXYNOS_GEM_MAP_OFFSET, struct drm_exynos_gem_map_off)
-
-#define DRM_IOCTL_EXYNOS_GEM_MMAP	DRM_IOWR(DRM_COMMAND_BASE + \
-		DRM_EXYNOS_GEM_MMAP, struct drm_exynos_gem_mmap)
-
 #define DRM_IOCTL_EXYNOS_GEM_GET	DRM_IOWR(DRM_COMMAND_BASE + \
 		DRM_EXYNOS_GEM_GET,	struct drm_exynos_gem_info)
 
-- 
2.0.5

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [PATCH 1/2] exynos: Don't use DRM_EXYNOS_GEM_{MAP_OFFSET/MMAP} ioctls
  2015-01-16 22:57 ` [PATCH 1/2] exynos: Don't use DRM_EXYNOS_GEM_{MAP_OFFSET/MMAP} ioctls Tobias Jakobi
@ 2015-01-26  1:42   ` Hyungwon Hwang
  2015-01-26 19:05     ` Emil Velikov
  0 siblings, 1 reply; 9+ messages in thread
From: Hyungwon Hwang @ 2015-01-26  1:42 UTC (permalink / raw)
  To: Tobias Jakobi; +Cc: linux-samsung-soc, dri-devel

Dear Tobias,

Thanks for fixing it.

Signed-off-by: Hyungwon Hwang <human.hwang@samsung.com>

On Fri, 16 Jan 2015 23:57:33 +0100
Tobias Jakobi <tjakobi@math.uni-bielefeld.de> wrote:

> From: Hyungwon Hwang <human.hwang@samsung.com>
> 
> The ioctl DRM_EXYNOS_GEM_MAP_OFFSET and DRM_EXYNOS_GEM_MMAP are
> removed from the linux kernel. This patch modifies libdrm and libkms
> to use drm generic ioctls instead of the removed ioctls.
> 
> v2: The original patch was erroneous. In case the MODE_MAP_DUMB ioctl
> failed it would return the retvalue as a void-pointer. Users of
> libdrm would then happily use that ptr, eventually leading to a
> segfault. Change this to return NULL in that case and also restore
> the previous behaviour of logging to stderr.
>     The other error was that 'bo->vaddr' was never filled with the
> mapped buffer address. Hence exynos_bo_map still returned NULL even
> if the buffer mapping succeeded.
> 
> Signed-off-by: Hyungwon Hwang <human.hwang@samsung.com>
> Signed-off-by: Inki Dae <inki.dae@samsung.com>
> Signed-off-by: Tobias Jakobi <tjakobi@math.uni-bielefeld.de>
> ---
>  exynos/exynos_drm.c | 19 ++++++++++++-------
>  libkms/exynos.c     |  7 ++++---
>  2 files changed, 16 insertions(+), 10 deletions(-)
> 
> diff --git a/exynos/exynos_drm.c b/exynos/exynos_drm.c
> index 4c7dd13..c5dd948 100644
> --- a/exynos/exynos_drm.c
> +++ b/exynos/exynos_drm.c
> @@ -283,20 +283,25 @@ drm_public void *exynos_bo_map(struct exynos_bo
> *bo) {
>  	if (!bo->vaddr) {
>  		struct exynos_device *dev = bo->dev;
> -		struct drm_exynos_gem_mmap req = {
> -			.handle = bo->handle,
> -			.size	= bo->size,
> -		};
> +		struct drm_mode_map_dumb arg;
> +		void *map = NULL;
>  		int ret;
>  
> -		ret = drmIoctl(dev->fd, DRM_IOCTL_EXYNOS_GEM_MMAP,
> &req);
> +		memset(&arg, 0, sizeof(arg));
> +		arg.handle = bo->handle;
> +
> +		ret = drmIoctl(dev->fd, DRM_IOCTL_MODE_MAP_DUMB,
> &arg); if (ret) {
> -			fprintf(stderr, "failed to mmap[%s].\n",
> +			fprintf(stderr, "failed to map dumb
> buffer[%s].\n", strerror(errno));
>  			return NULL;
>  		}
>  
> -		bo->vaddr = (void *)(uintptr_t)req.mapped;
> +		map = drm_mmap(0, bo->size, PROT_READ | PROT_WRITE,
> MAP_SHARED,
> +				dev->fd, arg.offset);
> +
> +		if (map != MAP_FAILED)
> +			bo->vaddr = map;
>  	}
>  
>  	return bo->vaddr;
> diff --git a/libkms/exynos.c b/libkms/exynos.c
> index 92e329c..1123482 100644
> --- a/libkms/exynos.c
> +++ b/libkms/exynos.c
> @@ -25,6 +25,7 @@
>  #include <sys/ioctl.h>
>  #include "xf86drm.h"
>  
> +#include "libdrm.h"
>  #include "exynos_drm.h"
>  
>  struct exynos_bo
> @@ -124,7 +125,7 @@ static int
>  exynos_bo_map(struct kms_bo *_bo, void **out)
>  {
>  	struct exynos_bo *bo = (struct exynos_bo *)_bo;
> -	struct drm_exynos_gem_map_off arg;
> +	struct drm_mode_map_dumb arg;
>  	void *map = NULL;
>  	int ret;
>  
> @@ -137,11 +138,11 @@ exynos_bo_map(struct kms_bo *_bo, void **out)
>  	memset(&arg, 0, sizeof(arg));
>  	arg.handle = bo->base.handle;
>  
> -	ret = drmCommandWriteRead(bo->base.kms->fd,
> DRM_EXYNOS_GEM_MAP_OFFSET, &arg, sizeof(arg));
> +	ret = drmIoctl(bo->base.kms->fd, DRM_IOCTL_MODE_MAP_DUMB,
> &arg); if (ret)
>  		return ret;
>  
> -	map = mmap(0, bo->base.size, PROT_READ | PROT_WRITE,
> MAP_SHARED, bo->base.kms->fd, arg.offset);
> +	map = drm_mmap(0, bo->base.size, PROT_READ | PROT_WRITE,
> MAP_SHARED, bo->base.kms->fd, arg.offset); if (map == MAP_FAILED)
>  		return -errno;
>  

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 1/2] exynos: Don't use DRM_EXYNOS_GEM_{MAP_OFFSET/MMAP} ioctls
  2015-01-26  1:42   ` Hyungwon Hwang
@ 2015-01-26 19:05     ` Emil Velikov
  2015-01-27  1:05       ` Hyungwon Hwang
  0 siblings, 1 reply; 9+ messages in thread
From: Emil Velikov @ 2015-01-26 19:05 UTC (permalink / raw)
  To: Hyungwon Hwang; +Cc: Tobias Jakobi, linux-samsung-soc, ML dri-devel

On 26 January 2015 at 01:42, Hyungwon Hwang <human.hwang@samsung.com> wrote:
> Dear Tobias,
>
> Thanks for fixing it.
>
> Signed-off-by: Hyungwon Hwang <human.hwang@samsung.com>
>
Hi Hyungwon Hwang

I'm a bit confused about the use of s-o-b here. I've assumed that
libdrm follows the kernel style [1] for those type of things ?
Would you have anything handy which I can read on the topic ?

Cheers,
Emil

[1] https://git.kernel.org/cgit/linux/kernel/git/stable/linux-stable.git/tree/Documentation/SubmittingPatches#n358

A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 1/2] exynos: Don't use DRM_EXYNOS_GEM_{MAP_OFFSET/MMAP} ioctls
  2015-01-26 19:05     ` Emil Velikov
@ 2015-01-27  1:05       ` Hyungwon Hwang
  2015-01-27  2:56         ` Emil Velikov
  0 siblings, 1 reply; 9+ messages in thread
From: Hyungwon Hwang @ 2015-01-27  1:05 UTC (permalink / raw)
  To: Emil Velikov; +Cc: Tobias Jakobi, linux-samsung-soc, ML dri-devel

Dear Emil,

On Mon, 26 Jan 2015 19:05:51 +0000
Emil Velikov <emil.l.velikov@gmail.com> wrote:

> On 26 January 2015 at 01:42, Hyungwon Hwang <human.hwang@samsung.com>
> wrote:
> > Dear Tobias,
> >
> > Thanks for fixing it.
> >
> > Signed-off-by: Hyungwon Hwang <human.hwang@samsung.com>
> >
> Hi Hyungwon Hwang
> 
> I'm a bit confused about the use of s-o-b here. I've assumed that
> libdrm follows the kernel style [1] for those type of things ?
> Would you have anything handy which I can read on the topic ?

I also think that DRI-devel mailing list follow the kernel rule. I used
s-o-b here by the meaning of (a) below (this text is excerpted from the
link you sent)

12) Sign your work

To improve tracking of who did what, especially with patches that can
percolate to their final resting place in the kernel through several
layers of maintainers, we've introduced a "sign-off" procedure on
patches that are being emailed around.

The sign-off is a simple line at the end of the explanation for the
patch, which certifies that you wrote it or otherwise have the right to
pass it on as an open-source patch.  The rules are pretty simple: if you
can certify the below:

        Developer's Certificate of Origin 1.1

        By making a contribution to this project, I certify that:

        (a) The contribution was created in whole or in part by me and I
            have the right to submit it under the open source license
            indicated in the file; or

Was it wrong to add s-o-b here? Should I have used "Reviewed-by" here?
I am sorry, if I broke the rule and confused you.

> 
> Cheers,
> Emil
> 
> [1]
> https://git.kernel.org/cgit/linux/kernel/git/stable/linux-stable.git/tree/Documentation/SubmittingPatches#n358
> 
> A: Because it messes up the order in which people normally read text.
> Q: Why is top-posting such a bad thing?


Best regards,
Hyungwon Hwang

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 1/2] exynos: Don't use DRM_EXYNOS_GEM_{MAP_OFFSET/MMAP} ioctls
  2015-01-27  1:05       ` Hyungwon Hwang
@ 2015-01-27  2:56         ` Emil Velikov
  0 siblings, 0 replies; 9+ messages in thread
From: Emil Velikov @ 2015-01-27  2:56 UTC (permalink / raw)
  To: Hyungwon Hwang; +Cc: Tobias Jakobi, linux-samsung-soc, ML dri-devel

On 27 January 2015 at 01:05, Hyungwon Hwang <human.hwang@samsung.com> wrote:
> Dear Emil,
>
> On Mon, 26 Jan 2015 19:05:51 +0000
> Emil Velikov <emil.l.velikov@gmail.com> wrote:
>
>> On 26 January 2015 at 01:42, Hyungwon Hwang <human.hwang@samsung.com>
>> wrote:
>> > Dear Tobias,
>> >
>> > Thanks for fixing it.
>> >
>> > Signed-off-by: Hyungwon Hwang <human.hwang@samsung.com>
>> >
>> Hi Hyungwon Hwang
>>
>> I'm a bit confused about the use of s-o-b here. I've assumed that
>> libdrm follows the kernel style [1] for those type of things ?
>> Would you have anything handy which I can read on the topic ?
>
> I also think that DRI-devel mailing list follow the kernel rule.
Sweet I'm not loosing my mind (much).

[...]
> Was it wrong to add s-o-b here? Should I have used "Reviewed-by" here?
> I am sorry, if I broke the rule and confused you.
>
Don't think any apology is due, I was just hinting that the patch has
the s-o-b already :P
Where as "what I should have used" that depends on your intent and/or
the action undertaken.

Thanks
Emil

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 1/2] exynos: Don't use DRM_EXYNOS_GEM_{MAP_OFFSET/MMAP} ioctls
  2014-10-31  1:28 [PATCH 1/2] exynos: Don't use " Hyungwon Hwang
@ 2014-11-19  2:02 ` Inki Dae
  0 siblings, 0 replies; 9+ messages in thread
From: Inki Dae @ 2014-11-19  2:02 UTC (permalink / raw)
  To: Hyungwon Hwang; +Cc: dri-devel

On 2014년 10월 31일 10:28, Hyungwon Hwang wrote:
> The ioctl DRM_EXYNOS_GEM_MAP_OFFSET and DRM_EXYNOS_GEM_MMAP are removed from
> the linux kernel. This patch modifies libdrm and libkms to use drm generic
> ioctls instead of the removed ioctls.


Signed-off-by: Inki Dae <inki.dae@samsung.com>

> 
> Signed-off-by: Hyungwon Hwang <human.hwang@samsung.com>
> ---
>  exynos/exynos_drm.c | 24 +++++++++++++-----------
>  libkms/exynos.c     |  7 ++++---
>  2 files changed, 17 insertions(+), 14 deletions(-)
> 
> diff --git a/exynos/exynos_drm.c b/exynos/exynos_drm.c
> index 4c7dd13..4cb6a6d 100644
> --- a/exynos/exynos_drm.c
> +++ b/exynos/exynos_drm.c
> @@ -283,20 +283,22 @@ drm_public void *exynos_bo_map(struct exynos_bo *bo)
>  {
>  	if (!bo->vaddr) {
>  		struct exynos_device *dev = bo->dev;
> -		struct drm_exynos_gem_mmap req = {
> -			.handle = bo->handle,
> -			.size	= bo->size,
> -		};
> +		struct drm_mode_map_dumb arg;
> +		void *map = NULL;
>  		int ret;
>  
> -		ret = drmIoctl(dev->fd, DRM_IOCTL_EXYNOS_GEM_MMAP, &req);
> -		if (ret) {
> -			fprintf(stderr, "failed to mmap[%s].\n",
> -				strerror(errno));
> -			return NULL;
> -		}
> +		memset(&arg, 0, sizeof(arg));
> +		arg.handle = bo->handle;
> +
> +		ret = drmIoctl(dev->fd, DRM_IOCTL_MODE_MAP_DUMB, &arg);
> +		if (ret)
> +			return ret;
>  
> -		bo->vaddr = (void *)(uintptr_t)req.mapped;
> +		map = drm_mmap(0, bo->size, PROT_READ | PROT_WRITE, MAP_SHARED,
> +				dev->fd, arg.offset);
> +
> +		if (map == MAP_FAILED)
> +			return NULL;
>  	}
>  
>  	return bo->vaddr;
> diff --git a/libkms/exynos.c b/libkms/exynos.c
> index 92e329c..1123482 100644
> --- a/libkms/exynos.c
> +++ b/libkms/exynos.c
> @@ -25,6 +25,7 @@
>  #include <sys/ioctl.h>
>  #include "xf86drm.h"
>  
> +#include "libdrm.h"
>  #include "exynos_drm.h"
>  
>  struct exynos_bo
> @@ -124,7 +125,7 @@ static int
>  exynos_bo_map(struct kms_bo *_bo, void **out)
>  {
>  	struct exynos_bo *bo = (struct exynos_bo *)_bo;
> -	struct drm_exynos_gem_map_off arg;
> +	struct drm_mode_map_dumb arg;
>  	void *map = NULL;
>  	int ret;
>  
> @@ -137,11 +138,11 @@ exynos_bo_map(struct kms_bo *_bo, void **out)
>  	memset(&arg, 0, sizeof(arg));
>  	arg.handle = bo->base.handle;
>  
> -	ret = drmCommandWriteRead(bo->base.kms->fd, DRM_EXYNOS_GEM_MAP_OFFSET, &arg, sizeof(arg));
> +	ret = drmIoctl(bo->base.kms->fd, DRM_IOCTL_MODE_MAP_DUMB, &arg);
>  	if (ret)
>  		return ret;
>  
> -	map = mmap(0, bo->base.size, PROT_READ | PROT_WRITE, MAP_SHARED, bo->base.kms->fd, arg.offset);
> +	map = drm_mmap(0, bo->base.size, PROT_READ | PROT_WRITE, MAP_SHARED, bo->base.kms->fd, arg.offset);
>  	if (map == MAP_FAILED)
>  		return -errno;
>  
> 

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH 1/2] exynos: Don't use DRM_EXYNOS_GEM_{MAP_OFFSET/MMAP} ioctls
@ 2014-10-31  1:28 Hyungwon Hwang
  2014-11-19  2:02 ` Inki Dae
  0 siblings, 1 reply; 9+ messages in thread
From: Hyungwon Hwang @ 2014-10-31  1:28 UTC (permalink / raw)
  To: dri-devel, inki.dae, jy0922.shim; +Cc: Hyungwon Hwang

The ioctl DRM_EXYNOS_GEM_MAP_OFFSET and DRM_EXYNOS_GEM_MMAP are removed from
the linux kernel. This patch modifies libdrm and libkms to use drm generic
ioctls instead of the removed ioctls.

Signed-off-by: Hyungwon Hwang <human.hwang@samsung.com>
---
 exynos/exynos_drm.c | 24 +++++++++++++-----------
 libkms/exynos.c     |  7 ++++---
 2 files changed, 17 insertions(+), 14 deletions(-)

diff --git a/exynos/exynos_drm.c b/exynos/exynos_drm.c
index 4c7dd13..4cb6a6d 100644
--- a/exynos/exynos_drm.c
+++ b/exynos/exynos_drm.c
@@ -283,20 +283,22 @@ drm_public void *exynos_bo_map(struct exynos_bo *bo)
 {
 	if (!bo->vaddr) {
 		struct exynos_device *dev = bo->dev;
-		struct drm_exynos_gem_mmap req = {
-			.handle = bo->handle,
-			.size	= bo->size,
-		};
+		struct drm_mode_map_dumb arg;
+		void *map = NULL;
 		int ret;
 
-		ret = drmIoctl(dev->fd, DRM_IOCTL_EXYNOS_GEM_MMAP, &req);
-		if (ret) {
-			fprintf(stderr, "failed to mmap[%s].\n",
-				strerror(errno));
-			return NULL;
-		}
+		memset(&arg, 0, sizeof(arg));
+		arg.handle = bo->handle;
+
+		ret = drmIoctl(dev->fd, DRM_IOCTL_MODE_MAP_DUMB, &arg);
+		if (ret)
+			return ret;
 
-		bo->vaddr = (void *)(uintptr_t)req.mapped;
+		map = drm_mmap(0, bo->size, PROT_READ | PROT_WRITE, MAP_SHARED,
+				dev->fd, arg.offset);
+
+		if (map == MAP_FAILED)
+			return NULL;
 	}
 
 	return bo->vaddr;
diff --git a/libkms/exynos.c b/libkms/exynos.c
index 92e329c..1123482 100644
--- a/libkms/exynos.c
+++ b/libkms/exynos.c
@@ -25,6 +25,7 @@
 #include <sys/ioctl.h>
 #include "xf86drm.h"
 
+#include "libdrm.h"
 #include "exynos_drm.h"
 
 struct exynos_bo
@@ -124,7 +125,7 @@ static int
 exynos_bo_map(struct kms_bo *_bo, void **out)
 {
 	struct exynos_bo *bo = (struct exynos_bo *)_bo;
-	struct drm_exynos_gem_map_off arg;
+	struct drm_mode_map_dumb arg;
 	void *map = NULL;
 	int ret;
 
@@ -137,11 +138,11 @@ exynos_bo_map(struct kms_bo *_bo, void **out)
 	memset(&arg, 0, sizeof(arg));
 	arg.handle = bo->base.handle;
 
-	ret = drmCommandWriteRead(bo->base.kms->fd, DRM_EXYNOS_GEM_MAP_OFFSET, &arg, sizeof(arg));
+	ret = drmIoctl(bo->base.kms->fd, DRM_IOCTL_MODE_MAP_DUMB, &arg);
 	if (ret)
 		return ret;
 
-	map = mmap(0, bo->base.size, PROT_READ | PROT_WRITE, MAP_SHARED, bo->base.kms->fd, arg.offset);
+	map = drm_mmap(0, bo->base.size, PROT_READ | PROT_WRITE, MAP_SHARED, bo->base.kms->fd, arg.offset);
 	if (map == MAP_FAILED)
 		return -errno;
 
-- 
1.8.3.2

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2015-01-27  2:56 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-01-16 22:57 libdrm/exynos: fix usage of removed ioctls Tobias Jakobi
2015-01-16 22:57 ` [PATCH 1/2] exynos: Don't use DRM_EXYNOS_GEM_{MAP_OFFSET/MMAP} ioctls Tobias Jakobi
2015-01-26  1:42   ` Hyungwon Hwang
2015-01-26 19:05     ` Emil Velikov
2015-01-27  1:05       ` Hyungwon Hwang
2015-01-27  2:56         ` Emil Velikov
2015-01-16 22:57 ` [PATCH 2/2] exynos: remove " Tobias Jakobi
  -- strict thread matches above, loose matches on Subject: below --
2014-10-31  1:28 [PATCH 1/2] exynos: Don't use " Hyungwon Hwang
2014-11-19  2:02 ` Inki Dae

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.