dri-devel.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/6 v2] libdrm: Patches from AOSP
@ 2019-04-24 17:08 John Stultz
  2019-04-24 17:08 ` [PATCH 1/6 v2] libdrm: Use mmap64 instead of __mmap2 John Stultz
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: John Stultz @ 2019-04-24 17:08 UTC (permalink / raw)
  To: dri-devel; +Cc: Sean Paul, Marissa Wall, Alistair Strachan, Emil Velikov

Recently I've been trying to sync the AOSP libdrm tree with
the upstream freedesktop branch.

Thanks to input from Sean, Alistair and Marissa, we've managed
to drop a bunch of stale patches AOSP was carrying, and get
the AOSP libdrm updated to 2.4.97

I've gone through the remaining patch delta and wanted to submit
the non-Android.bp changes, which seemed like they might be
relevant for upstream, for review.

thanks
-john

Cc: Emil Velikov <emil.velikov@collabora.com>
Cc: Sean Paul <seanpaul@chromium.org>
Cc: Alistair Strachan <astrachan@google.com>
Cc: Marissa Wall <marissaw@google.com>

Adrian Salido (1):
  libdrm: reduce number of reallocations in drmModeAtomicAddProperty

Hemant Hariyani (1):
  libdrm: omap: Add DRM_RDWR flag to dmabuf export

John Stultz (2):
  libdrm: Android.mk: Add minimal Android platform check
  libdrm: amdgpu: Initialize unions with memset rather than "= {0}"

Prabhanjan Kandula (1):
  libdrm: Avoid additional drm open close

Sean Paul (1):
  libdrm: Use mmap64 instead of __mmap2

 Android.mk         | 5 +++++
 amdgpu/amdgpu_cs.c | 9 ++++++---
 libdrm_macros.h    | 4 +---
 omap/omap_drm.c    | 2 +-
 xf86drm.c          | 4 ++--
 xf86drmMode.c      | 7 ++++---
 6 files changed, 19 insertions(+), 12 deletions(-)

-- 
2.7.4

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

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

* [PATCH 1/6 v2] libdrm: Use mmap64 instead of __mmap2
  2019-04-24 17:08 [PATCH 0/6 v2] libdrm: Patches from AOSP John Stultz
@ 2019-04-24 17:08 ` John Stultz
  2019-04-24 17:08 ` [PATCH 2/6 v2] libdrm: Android.mk: Add minimal Android platform check John Stultz
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: John Stultz @ 2019-04-24 17:08 UTC (permalink / raw)
  To: dri-devel; +Cc: Marissa Wall, Sean Paul, Alistair Strachan, Emil Velikov

From: Sean Paul <seanpaul@chromium.org>

__mmap2 isn't supported on all platforms, mmap64 is the right way
to do this in android.

Also folds in a fix from Stéphane Marchesin <marcheu@chromium.org>

Cc: Emil Velikov <emil.velikov@collabora.com>
Cc: Sean Paul <seanpaul@chromium.org>
Cc: Alistair Strachan <astrachan@google.com>
Cc: Marissa Wall <marissaw@google.com>
Acked-by: Alex Deucher <alexander.deucher@amd.com>
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
Signed-off-by: Sean Paul <seanpaul@chromium.org>
[jstultz: Folded in Stéphane's fix]
Signed-off-by: John Stultz <john.stultz@linaro.org>
---
 libdrm_macros.h | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/libdrm_macros.h b/libdrm_macros.h
index 95f0ef5..0dca827 100644
--- a/libdrm_macros.h
+++ b/libdrm_macros.h
@@ -48,8 +48,6 @@
 #if defined(ANDROID) && !defined(__LP64__)
 #include <errno.h> /* for EINVAL */
 
-extern void *__mmap2(void *, size_t, int, int, int, size_t);
-
 static inline void *drm_mmap(void *addr, size_t length, int prot, int flags,
                              int fd, loff_t offset)
 {
@@ -59,7 +57,7 @@ static inline void *drm_mmap(void *addr, size_t length, int prot, int flags,
       return MAP_FAILED;
    }
 
-   return __mmap2(addr, length, prot, flags, fd, (size_t) (offset >> 12));
+   return mmap64(addr, length, prot, flags, fd, offset);
 }
 
 #  define drm_munmap(addr, length) \
-- 
2.7.4

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

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

* [PATCH 2/6 v2] libdrm: Android.mk: Add minimal Android platform check
  2019-04-24 17:08 [PATCH 0/6 v2] libdrm: Patches from AOSP John Stultz
  2019-04-24 17:08 ` [PATCH 1/6 v2] libdrm: Use mmap64 instead of __mmap2 John Stultz
@ 2019-04-24 17:08 ` John Stultz
  2019-04-24 17:08 ` [PATCH 3/6 v2] libdrm: amdgpu: Initialize unions with memset rather than "= {0}" John Stultz
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: John Stultz @ 2019-04-24 17:08 UTC (permalink / raw)
  To: dri-devel; +Cc: Sean Paul, Marissa Wall, Alistair Strachan, Emil Velikov

Add a check to error out on Android version K(4.4) or
lower.

This is due to dependency added in a previous commit on mmap64,
which was introduced with Android L.

Cc: Emil Velikov <emil.velikov@collabora.com>
Cc: Sean Paul <seanpaul@chromium.org>
Cc: Alistair Strachan <astrachan@google.com>
Cc: Marissa Wall <marissaw@google.com>
Suggested-by: Emil Velikov <emil.velikov@collabora.com>
Signed-off-by: John Stultz <john.stultz@linaro.org>
---
NOTE: This change was suggested by Emil, and I've implemented
it as suggested, but due to the fact that the Android.mk files
are no longer usable with AOSP/master, I'm not able to test
this change. Help in validating would be appreciated.
---
 Android.mk | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/Android.mk b/Android.mk
index 1b77c53..0ab6f0f 100644
--- a/Android.mk
+++ b/Android.mk
@@ -21,6 +21,11 @@
 # IN THE SOFTWARE.
 #
 
+LIBDRM_ANDROID_MAJOR_VERSION := $(word 1, $(subst ., , $(PLATFORM_VERSION)))
+ifneq ($(filter 2 4, $(LIBDRM_ANDROID_MAJOR_VERSION)),)
+$(error "Android 4.4 and earlier not supported")
+endif
+
 LIBDRM_COMMON_MK := $(call my-dir)/Android.common.mk
 
 LOCAL_PATH := $(call my-dir)
-- 
2.7.4

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

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

* [PATCH 3/6 v2] libdrm: amdgpu: Initialize unions with memset rather than "= {0}"
  2019-04-24 17:08 [PATCH 0/6 v2] libdrm: Patches from AOSP John Stultz
  2019-04-24 17:08 ` [PATCH 1/6 v2] libdrm: Use mmap64 instead of __mmap2 John Stultz
  2019-04-24 17:08 ` [PATCH 2/6 v2] libdrm: Android.mk: Add minimal Android platform check John Stultz
@ 2019-04-24 17:08 ` John Stultz
  2019-04-24 17:08 ` [PATCH 4/6 v2] libdrm: Avoid additional drm open close John Stultz
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: John Stultz @ 2019-04-24 17:08 UTC (permalink / raw)
  To: dri-devel; +Cc: Sean Paul, Marissa Wall, Alistair Strachan, Emil Velikov

Clang complains when initializing unions using "= {0}"
so instead use memset.

Cc: Emil Velikov <emil.velikov@collabora.com>
Cc: Sean Paul <seanpaul@chromium.org>
Cc: Alistair Strachan <astrachan@google.com>
Cc: Marissa Wall <marissaw@google.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
Signed-off-by: John Stultz <john.stultz@linaro.org>
---
 amdgpu/amdgpu_cs.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/amdgpu/amdgpu_cs.c b/amdgpu/amdgpu_cs.c
index 7ee844f..7c5b9d1 100644
--- a/amdgpu/amdgpu_cs.c
+++ b/amdgpu/amdgpu_cs.c
@@ -733,12 +733,13 @@ drm_public int amdgpu_cs_submit_raw(amdgpu_device_handle dev,
 				    struct drm_amdgpu_cs_chunk *chunks,
 				    uint64_t *seq_no)
 {
-	union drm_amdgpu_cs cs = {0};
+	union drm_amdgpu_cs cs;
 	uint64_t *chunk_array;
 	int i, r;
 	if (num_chunks == 0)
 		return -EINVAL;
 
+	memset(&cs, 0, sizeof(cs));
 	chunk_array = alloca(sizeof(uint64_t) * num_chunks);
 	for (i = 0; i < num_chunks; i++)
 		chunk_array[i] = (uint64_t)(uintptr_t)&chunks[i];
@@ -763,10 +764,11 @@ drm_public int amdgpu_cs_submit_raw2(amdgpu_device_handle dev,
 				     struct drm_amdgpu_cs_chunk *chunks,
 				     uint64_t *seq_no)
 {
-	union drm_amdgpu_cs cs = {0};
+	union drm_amdgpu_cs cs;
 	uint64_t *chunk_array;
 	int i, r;
 
+	memset(&cs, 0, sizeof(cs));
 	chunk_array = alloca(sizeof(uint64_t) * num_chunks);
 	for (i = 0; i < num_chunks; i++)
 		chunk_array[i] = (uint64_t)(uintptr_t)&chunks[i];
@@ -803,9 +805,10 @@ drm_public int amdgpu_cs_fence_to_handle(amdgpu_device_handle dev,
 					 uint32_t what,
 					 uint32_t *out_handle)
 {
-	union drm_amdgpu_fence_to_handle fth = {0};
+	union drm_amdgpu_fence_to_handle fth;
 	int r;
 
+	memset(&fth, 0, sizeof(fth));
 	fth.in.fence.ctx_id = fence->context->id;
 	fth.in.fence.ip_type = fence->ip_type;
 	fth.in.fence.ip_instance = fence->ip_instance;
-- 
2.7.4

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

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

* [PATCH 4/6 v2] libdrm: Avoid additional drm open close
  2019-04-24 17:08 [PATCH 0/6 v2] libdrm: Patches from AOSP John Stultz
                   ` (2 preceding siblings ...)
  2019-04-24 17:08 ` [PATCH 3/6 v2] libdrm: amdgpu: Initialize unions with memset rather than "= {0}" John Stultz
@ 2019-04-24 17:08 ` John Stultz
  2019-04-24 17:08 ` [PATCH 5/6 v2] libdrm: reduce number of reallocations in drmModeAtomicAddProperty John Stultz
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: John Stultz @ 2019-04-24 17:08 UTC (permalink / raw)
  To: dri-devel
  Cc: Alistair Strachan, Marissa Wall, Sean Paul, Prabhanjan Kandula,
	Emil Velikov

From: Prabhanjan Kandula <pkandula@codeaurora.org>

Avoid additional drm device open and close.

Cc: Emil Velikov <emil.velikov@collabora.com>
Cc: Sean Paul <seanpaul@chromium.org>
Cc: Alistair Strachan <astrachan@google.com>
Cc: Marissa Wall <marissaw@google.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: John Stultz <john.stultz@linaro.org>
---
 xf86drm.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/xf86drm.c b/xf86drm.c
index fe822ca..2c19376 100644
--- a/xf86drm.c
+++ b/xf86drm.c
@@ -750,8 +750,8 @@ drm_public int drmOpen(const char *name, const char *busid)
  */
 drm_public int drmOpenWithType(const char *name, const char *busid, int type)
 {
-    if (!drmAvailable() && name != NULL && drm_server_info &&
-        drm_server_info->load_module) {
+    if (name != NULL && drm_server_info &&
+        drm_server_info->load_module && !drmAvailable()) {
         /* try to load the kernel module */
         if (!drm_server_info->load_module(name)) {
             drmMsg("[drm] failed to load kernel module \"%s\"\n", name);
-- 
2.7.4

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

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

* [PATCH 5/6 v2] libdrm: reduce number of reallocations in drmModeAtomicAddProperty
  2019-04-24 17:08 [PATCH 0/6 v2] libdrm: Patches from AOSP John Stultz
                   ` (3 preceding siblings ...)
  2019-04-24 17:08 ` [PATCH 4/6 v2] libdrm: Avoid additional drm open close John Stultz
@ 2019-04-24 17:08 ` John Stultz
  2019-04-24 17:08 ` [PATCH 6/6 v2] libdrm: omap: Add DRM_RDWR flag to dmabuf export John Stultz
  2019-04-25 10:18 ` [PATCH 0/6 v2] libdrm: Patches from AOSP Emil Velikov
  6 siblings, 0 replies; 8+ messages in thread
From: John Stultz @ 2019-04-24 17:08 UTC (permalink / raw)
  To: dri-devel
  Cc: Adrian Salido, Alistair Strachan, Marissa Wall, Sean Paul, Emil Velikov

From: Adrian Salido <salidoa@google.com>

When calling drmModeAtomicAddProperty allocation of memory
happens as needed in increments of 16 elements. This can be very
slow if there are multiple properties to be updated in an Atomic
Commit call.

Increase this to as many as can fit in a memory PAGE to avoid
having to reallocate memory too often.

Also this patch has a small one line perf tweak in
drmModeAtomicDuplicate() to only memcpy items to the cursor
position in order avoid copying the entire item array if its
mostly empty.

Cc: Emil Velikov <emil.velikov@collabora.com>
Cc: Sean Paul <seanpaul@chromium.org>
Cc: Alistair Strachan <astrachan@google.com>
Cc: Marissa Wall <marissaw@google.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
[jstultz: Expanded commit message]
Signed-off-by: John Stultz <john.stultz@linaro.org>
---
v2: Improved commit message
---
 xf86drmMode.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/xf86drmMode.c b/xf86drmMode.c
index 8f8633e..c878d9e 100644
--- a/xf86drmMode.c
+++ b/xf86drmMode.c
@@ -1259,7 +1259,7 @@ drm_public drmModeAtomicReqPtr drmModeAtomicDuplicate(drmModeAtomicReqPtr old)
 			return NULL;
 		}
 		memcpy(new->items, old->items,
-		       old->size_items * sizeof(*new->items));
+		       old->cursor * sizeof(*new->items));
 	} else {
 		new->items = NULL;
 	}
@@ -1322,12 +1322,13 @@ drm_public int drmModeAtomicAddProperty(drmModeAtomicReqPtr req,
 		return -EINVAL;
 
 	if (req->cursor >= req->size_items) {
+		const uint32_t item_size_inc = getpagesize() / sizeof(*req->items);
 		drmModeAtomicReqItemPtr new;
 
-		req->size_items += 16;
+		req->size_items += item_size_inc;
 		new = realloc(req->items, req->size_items * sizeof(*req->items));
 		if (!new) {
-			req->size_items -= 16;
+			req->size_items -= item_size_inc;
 			return -ENOMEM;
 		}
 		req->items = new;
-- 
2.7.4

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

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

* [PATCH 6/6 v2] libdrm: omap: Add DRM_RDWR flag to dmabuf export
  2019-04-24 17:08 [PATCH 0/6 v2] libdrm: Patches from AOSP John Stultz
                   ` (4 preceding siblings ...)
  2019-04-24 17:08 ` [PATCH 5/6 v2] libdrm: reduce number of reallocations in drmModeAtomicAddProperty John Stultz
@ 2019-04-24 17:08 ` John Stultz
  2019-04-25 10:18 ` [PATCH 0/6 v2] libdrm: Patches from AOSP Emil Velikov
  6 siblings, 0 replies; 8+ messages in thread
From: John Stultz @ 2019-04-24 17:08 UTC (permalink / raw)
  To: dri-devel
  Cc: Praneeth Bajjuri, Hemant Hariyani, Alistair Strachan,
	Marissa Wall, Sean Paul, Emil Velikov

From: Hemant Hariyani <hemanthariyani@ti.com>

Allows mmap on dmabuf fd with MAP_SHARED and PROT_WRITE.

This fixes boot failures with Android (likely w/ closed source
user-space drivers) that were caused due to mmap() returning
error.

Cc: Emil Velikov <emil.velikov@collabora.com>
Cc: Sean Paul <seanpaul@chromium.org>
Cc: Alistair Strachan <astrachan@google.com>
Cc: Marissa Wall <marissaw@google.com>
Signed-off-by: Hemant Hariyani <hemanthariyani@ti.com>
[picked and updated commitmsg from http://git.ti.com/cgit/cgit.cgi/android/external-libdrm.git/]
Signed-off-by: Praneeth Bajjuri <praneeth@ti.com>
Signed-off-by: Alistair Strachan <astrachan@google.com>
[jstultz: Tweaked commit message]
Signed-off-by: John Stultz <john.stultz@linaro.org>
---
v2: Tweaked commit message
---
 omap/omap_drm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/omap/omap_drm.c b/omap/omap_drm.c
index 3aed4e0..ffacea6 100644
--- a/omap/omap_drm.c
+++ b/omap/omap_drm.c
@@ -414,7 +414,7 @@ drm_public int omap_bo_dmabuf(struct omap_bo *bo)
 	if (bo->fd < 0) {
 		struct drm_prime_handle req = {
 				.handle = bo->handle,
-				.flags = DRM_CLOEXEC,
+				.flags = DRM_CLOEXEC | DRM_RDWR,
 		};
 		int ret;
 
-- 
2.7.4

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

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

* Re: [PATCH 0/6 v2] libdrm: Patches from AOSP
  2019-04-24 17:08 [PATCH 0/6 v2] libdrm: Patches from AOSP John Stultz
                   ` (5 preceding siblings ...)
  2019-04-24 17:08 ` [PATCH 6/6 v2] libdrm: omap: Add DRM_RDWR flag to dmabuf export John Stultz
@ 2019-04-25 10:18 ` Emil Velikov
  6 siblings, 0 replies; 8+ messages in thread
From: Emil Velikov @ 2019-04-25 10:18 UTC (permalink / raw)
  To: John Stultz
  Cc: Marissa Wall, Sean Paul, Alistair Strachan, dri-devel, Emil Velikov

On Wed, 24 Apr 2019 at 18:08, John Stultz <john.stultz@linaro.org> wrote:
>
> Recently I've been trying to sync the AOSP libdrm tree with
> the upstream freedesktop branch.
>
> Thanks to input from Sean, Alistair and Marissa, we've managed
> to drop a bunch of stale patches AOSP was carrying, and get
> the AOSP libdrm updated to 2.4.97
>
> I've gone through the remaining patch delta and wanted to submit
> the non-Android.bp changes, which seemed like they might be
> relevant for upstream, for review.
>
Thanks for the follow-up John. I've swapped the order of 1/6 and 2/6
and pushed the series to master.

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

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

end of thread, other threads:[~2019-04-25 10:18 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-24 17:08 [PATCH 0/6 v2] libdrm: Patches from AOSP John Stultz
2019-04-24 17:08 ` [PATCH 1/6 v2] libdrm: Use mmap64 instead of __mmap2 John Stultz
2019-04-24 17:08 ` [PATCH 2/6 v2] libdrm: Android.mk: Add minimal Android platform check John Stultz
2019-04-24 17:08 ` [PATCH 3/6 v2] libdrm: amdgpu: Initialize unions with memset rather than "= {0}" John Stultz
2019-04-24 17:08 ` [PATCH 4/6 v2] libdrm: Avoid additional drm open close John Stultz
2019-04-24 17:08 ` [PATCH 5/6 v2] libdrm: reduce number of reallocations in drmModeAtomicAddProperty John Stultz
2019-04-24 17:08 ` [PATCH 6/6 v2] libdrm: omap: Add DRM_RDWR flag to dmabuf export John Stultz
2019-04-25 10:18 ` [PATCH 0/6 v2] libdrm: Patches from AOSP Emil Velikov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).