diff mbox series

[RFC,1/5] libdrm: Use mmap64 instead of __mmap2

Message ID 1555734295-31015-2-git-send-email-john.stultz@linaro.org
State Superseded
Headers show
Series libdrm: Patches from AOSP | expand

Commit Message

John Stultz April 20, 2019, 4:24 a.m. UTC
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>
to use an offset in bytes not pages, as that's what mmap64 takes.

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: Sean Paul <seanpaul@chromium.org>

Signed-off-by: John Stultz <john.stultz@linaro.org>

---
 libdrm_macros.h | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

-- 
2.7.4

Comments

Alex Deucher April 22, 2019, 3:03 p.m. UTC | #1
On Sat, Apr 20, 2019 at 12:25 AM John Stultz <john.stultz@linaro.org> wrote:
>
> 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>
> to use an offset in bytes not pages, as that's what mmap64 takes.
>
> 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: Sean Paul <seanpaul@chromium.org>
> Signed-off-by: John Stultz <john.stultz@linaro.org>

Acked-by: Alex Deucher <alexander.deucher@amd.com>

> ---
>  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
Emil Velikov April 23, 2019, 9:47 a.m. UTC | #2
On Sat, 20 Apr 2019 at 05:25, John Stultz <john.stultz@linaro.org> wrote:
>
> 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>
> to use an offset in bytes not pages, as that's what mmap64 takes.
>
> 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: Sean Paul <seanpaul@chromium.org>
> Signed-off-by: John Stultz <john.stultz@linaro.org>
> ---
>  libdrm_macros.h | 4 +---
>  1 file changed, 1 insertion(+), 3 deletions(-)
>
From a quick look mmap64 was introduced in bionic with Andoid 5 (Lollipop).
A reasonable min. version although we're lacking a check.

As a separate commit, copy the PLATFORM_VERSION hunk (or equiv.) from
Mesa's Android.mk.
Here I'd add a note "introduced with Android L which we require as of
earlier commit" and drop the bytes/pages mention.

With that this patch is:
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>

-Emil
diff mbox series

Patch

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) \