diff mbox

[libdrm,1/2] intel: Do not use libpciaccess on Android

Message ID 20180320173652.5917-1-emil.l.velikov@gmail.com (mailing list archive)
State New, archived
Headers show

Commit Message

Emil Velikov March 20, 2018, 5:36 p.m. UTC
From: Tomasz Figa <tfiga@google.com>

This patch makes the code not rely anymore on libpciaccess when compiled
for Android to eliminate ioperm() and iopl() syscalls required by that
library. As a side effect, the mappable aperture size is hardcoded to 64
MiB on Android, however nothing seems to rely on this value anyway, as
checked be grepping relevant code in drm_gralloc and Mesa.

Cc: John Stultz <john.stultz@linaro.org>
Cc: Rob Herring <rob.herring@linaro.org>
Cc: John Stultz <john.stultz@linaro.org>
Cc: Tomasz Figa <tfiga@google.com>
Signed-off-by: Tomasz Figa <tfiga@google.com>
[Emil Velikov: rebase against master]
Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
---
Tomasz, I've taken the liberty of pulling the patch from the Android
tree. Hope you don't mind.
---
 intel/Android.mk     |  3 +--
 intel/intel_bufmgr.c | 12 ++++++++++++
 2 files changed, 13 insertions(+), 2 deletions(-)

Comments

Eric Engestrom March 20, 2018, 6:47 p.m. UTC | #1
On Tuesday, 2018-03-20 17:36:51 +0000, Emil Velikov wrote:
> From: Tomasz Figa <tfiga@google.com>
> 
> This patch makes the code not rely anymore on libpciaccess when compiled
> for Android to eliminate ioperm() and iopl() syscalls required by that
> library. As a side effect, the mappable aperture size is hardcoded to 64
> MiB on Android, however nothing seems to rely on this value anyway, as
> checked be grepping relevant code in drm_gralloc and Mesa.
> 
> Cc: John Stultz <john.stultz@linaro.org>
> Cc: Rob Herring <rob.herring@linaro.org>
> Cc: John Stultz <john.stultz@linaro.org>
> Cc: Tomasz Figa <tfiga@google.com>
> Signed-off-by: Tomasz Figa <tfiga@google.com>
> [Emil Velikov: rebase against master]
> Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
> ---
> Tomasz, I've taken the liberty of pulling the patch from the Android
> tree. Hope you don't mind.
> ---
>  intel/Android.mk     |  3 +--
>  intel/intel_bufmgr.c | 12 ++++++++++++
>  2 files changed, 13 insertions(+), 2 deletions(-)
> 
> diff --git a/intel/Android.mk b/intel/Android.mk
> index 3f9db785..dd881688 100644
> --- a/intel/Android.mk
> +++ b/intel/Android.mk
> @@ -33,8 +33,7 @@ LOCAL_MODULE := libdrm_intel
>  LOCAL_SRC_FILES := $(LIBDRM_INTEL_FILES)
>  
>  LOCAL_SHARED_LIBRARIES := \
> -	libdrm \
> -	libpciaccess
> +	libdrm
>  
>  include $(LIBDRM_COMMON_MK)
>  include $(BUILD_SHARED_LIBRARY)
> diff --git a/intel/intel_bufmgr.c b/intel/intel_bufmgr.c
> index a2853400..42f5f62c 100644
> --- a/intel/intel_bufmgr.c
> +++ b/intel/intel_bufmgr.c
> @@ -36,7 +36,9 @@
>  #include <errno.h>
>  #include <drm.h>
>  #include <i915_drm.h>
> +#ifndef __ANDROID__
>  #include <pciaccess.h>
> +#endif
>  #include "libdrm_macros.h"
>  #include "intel_bufmgr.h"
>  #include "intel_bufmgr_priv.h"
> @@ -326,6 +328,7 @@ drm_intel_get_pipe_from_crtc_id(drm_intel_bufmgr *bufmgr, int crtc_id)
>  	return -1;
>  }
>  
> +#ifndef __ANDROID__
>  static size_t
>  drm_intel_probe_agp_aperture_size(int fd)
>  {
> @@ -351,6 +354,15 @@ err:
>  	pci_system_cleanup ();
>  	return size;
>  }
> +#else
> +static size_t
> +drm_intel_probe_agp_aperture_size(int fd)
> +{
> +	/* Nothing seems to rely on this value on Android anyway... */
> +	fprintf(stderr, "%s: Mappable aperture size hardcoded to 64MiB\n");

Guessing there's a __func__ missing at the end there ^

> +	return 64 * 1024 * 1024;
> +}
> +#endif
>  
>  int
>  drm_intel_get_aperture_sizes(int fd, size_t *mappable, size_t *total)
> -- 
> 2.16.0
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
Emil Velikov March 21, 2018, 3:16 p.m. UTC | #2
On 20 March 2018 at 18:47, Eric Engestrom <eric.engestrom@imgtec.com> wrote:
> On Tuesday, 2018-03-20 17:36:51 +0000, Emil Velikov wrote:
>> From: Tomasz Figa <tfiga@google.com>
>>
>> This patch makes the code not rely anymore on libpciaccess when compiled
>> for Android to eliminate ioperm() and iopl() syscalls required by that
>> library. As a side effect, the mappable aperture size is hardcoded to 64
>> MiB on Android, however nothing seems to rely on this value anyway, as
>> checked be grepping relevant code in drm_gralloc and Mesa.
>>
>> Cc: John Stultz <john.stultz@linaro.org>
>> Cc: Rob Herring <rob.herring@linaro.org>
>> Cc: John Stultz <john.stultz@linaro.org>
>> Cc: Tomasz Figa <tfiga@google.com>
>> Signed-off-by: Tomasz Figa <tfiga@google.com>
>> [Emil Velikov: rebase against master]
>> Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
>> ---
>> Tomasz, I've taken the liberty of pulling the patch from the Android
>> tree. Hope you don't mind.
>> ---
>>  intel/Android.mk     |  3 +--
>>  intel/intel_bufmgr.c | 12 ++++++++++++
>>  2 files changed, 13 insertions(+), 2 deletions(-)
>>
>> diff --git a/intel/Android.mk b/intel/Android.mk
>> index 3f9db785..dd881688 100644
>> --- a/intel/Android.mk
>> +++ b/intel/Android.mk
>> @@ -33,8 +33,7 @@ LOCAL_MODULE := libdrm_intel
>>  LOCAL_SRC_FILES := $(LIBDRM_INTEL_FILES)
>>
>>  LOCAL_SHARED_LIBRARIES := \
>> -     libdrm \
>> -     libpciaccess
>> +     libdrm
>>
>>  include $(LIBDRM_COMMON_MK)
>>  include $(BUILD_SHARED_LIBRARY)
>> diff --git a/intel/intel_bufmgr.c b/intel/intel_bufmgr.c
>> index a2853400..42f5f62c 100644
>> --- a/intel/intel_bufmgr.c
>> +++ b/intel/intel_bufmgr.c
>> @@ -36,7 +36,9 @@
>>  #include <errno.h>
>>  #include <drm.h>
>>  #include <i915_drm.h>
>> +#ifndef __ANDROID__
>>  #include <pciaccess.h>
>> +#endif
>>  #include "libdrm_macros.h"
>>  #include "intel_bufmgr.h"
>>  #include "intel_bufmgr_priv.h"
>> @@ -326,6 +328,7 @@ drm_intel_get_pipe_from_crtc_id(drm_intel_bufmgr *bufmgr, int crtc_id)
>>       return -1;
>>  }
>>
>> +#ifndef __ANDROID__
>>  static size_t
>>  drm_intel_probe_agp_aperture_size(int fd)
>>  {
>> @@ -351,6 +354,15 @@ err:
>>       pci_system_cleanup ();
>>       return size;
>>  }
>> +#else
>> +static size_t
>> +drm_intel_probe_agp_aperture_size(int fd)
>> +{
>> +     /* Nothing seems to rely on this value on Android anyway... */
>> +     fprintf(stderr, "%s: Mappable aperture size hardcoded to 64MiB\n");
>
> Guessing there's a __func__ missing at the end there ^
>
Indeed - fixed locally. Can resent if the Android related people are
keen on the overall idea.

-Emil
John Stultz March 26, 2018, 11:27 p.m. UTC | #3
On Tue, Mar 20, 2018 at 10:36 AM, Emil Velikov <emil.l.velikov@gmail.com> wrote:
> From: Tomasz Figa <tfiga@google.com>
>
> This patch makes the code not rely anymore on libpciaccess when compiled
> for Android to eliminate ioperm() and iopl() syscalls required by that
> library. As a side effect, the mappable aperture size is hardcoded to 64
> MiB on Android, however nothing seems to rely on this value anyway, as
> checked be grepping relevant code in drm_gralloc and Mesa.
>
> Cc: John Stultz <john.stultz@linaro.org>
> Cc: Rob Herring <rob.herring@linaro.org>
> Cc: John Stultz <john.stultz@linaro.org>
> Cc: Tomasz Figa <tfiga@google.com>
> Signed-off-by: Tomasz Figa <tfiga@google.com>
> [Emil Velikov: rebase against master]
> Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
> ---
> Tomasz, I've taken the liberty of pulling the patch from the Android
> tree. Hope you don't mind.
> ---

Sorry, being abroad for a conference last week slowed me down and I
didn't get to validate this.

Many thanks for sending this out, I do agree its cleaner then my filtering fix.

I've got this patch (along with the __func__ fix EricE noticed) built
and tested for the HiKey boards and it works ok for me.

Feel free to add my:
Acked-by: John Stultz <john.stultz@linaro.org>

Emil: Do you mind respinning with the fix so Rob or someone can apply?

thanks
-john
Tomasz Figa March 27, 2018, 2:50 a.m. UTC | #4
On Wed, Mar 21, 2018 at 2:36 AM, Emil Velikov <emil.l.velikov@gmail.com> wrote:
> From: Tomasz Figa <tfiga@google.com>
>
> This patch makes the code not rely anymore on libpciaccess when compiled
> for Android to eliminate ioperm() and iopl() syscalls required by that
> library. As a side effect, the mappable aperture size is hardcoded to 64
> MiB on Android, however nothing seems to rely on this value anyway, as
> checked be grepping relevant code in drm_gralloc and Mesa.
>
> Cc: John Stultz <john.stultz@linaro.org>
> Cc: Rob Herring <rob.herring@linaro.org>
> Cc: John Stultz <john.stultz@linaro.org>
> Cc: Tomasz Figa <tfiga@google.com>
> Signed-off-by: Tomasz Figa <tfiga@google.com>
> [Emil Velikov: rebase against master]
> Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
> ---
> Tomasz, I've taken the liberty of pulling the patch from the Android
> tree. Hope you don't mind.

Thanks Emil for digging it up. I have no objections.

For reference, we used this as a quick hack before moving build of
graphics components to Chrome OS side. After that, for short time, we
had libpciaccess being built with autotools (and some small patch
disabling port IO related stuff). Eventually we got rid of it
completely, as Mesa stopped using libdrm_intel for i965 (and we don't
use i915).

Best regards,
Tomasz
Emil Velikov March 28, 2018, 4:16 p.m. UTC | #5
On 27 March 2018 at 00:27, John Stultz <john.stultz@linaro.org> wrote:
> On Tue, Mar 20, 2018 at 10:36 AM, Emil Velikov <emil.l.velikov@gmail.com> wrote:
>> From: Tomasz Figa <tfiga@google.com>
>>
>> This patch makes the code not rely anymore on libpciaccess when compiled
>> for Android to eliminate ioperm() and iopl() syscalls required by that
>> library. As a side effect, the mappable aperture size is hardcoded to 64
>> MiB on Android, however nothing seems to rely on this value anyway, as
>> checked be grepping relevant code in drm_gralloc and Mesa.
>>
>> Cc: John Stultz <john.stultz@linaro.org>
>> Cc: Rob Herring <rob.herring@linaro.org>
>> Cc: John Stultz <john.stultz@linaro.org>
>> Cc: Tomasz Figa <tfiga@google.com>
>> Signed-off-by: Tomasz Figa <tfiga@google.com>
>> [Emil Velikov: rebase against master]
>> Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
>> ---
>> Tomasz, I've taken the liberty of pulling the patch from the Android
>> tree. Hope you don't mind.
>> ---
>
> Sorry, being abroad for a conference last week slowed me down and I
> didn't get to validate this.
>
> Many thanks for sending this out, I do agree its cleaner then my filtering fix.
>
> I've got this patch (along with the __func__ fix EricE noticed) built
> and tested for the HiKey boards and it works ok for me.
>
> Feel free to add my:
> Acked-by: John Stultz <john.stultz@linaro.org>
>
> Emil: Do you mind respinning with the fix so Rob or someone can apply?
>
Added the __func__ piece and pushed the series.

Thanks guys!
Emil
diff mbox

Patch

diff --git a/intel/Android.mk b/intel/Android.mk
index 3f9db785..dd881688 100644
--- a/intel/Android.mk
+++ b/intel/Android.mk
@@ -33,8 +33,7 @@  LOCAL_MODULE := libdrm_intel
 LOCAL_SRC_FILES := $(LIBDRM_INTEL_FILES)
 
 LOCAL_SHARED_LIBRARIES := \
-	libdrm \
-	libpciaccess
+	libdrm
 
 include $(LIBDRM_COMMON_MK)
 include $(BUILD_SHARED_LIBRARY)
diff --git a/intel/intel_bufmgr.c b/intel/intel_bufmgr.c
index a2853400..42f5f62c 100644
--- a/intel/intel_bufmgr.c
+++ b/intel/intel_bufmgr.c
@@ -36,7 +36,9 @@ 
 #include <errno.h>
 #include <drm.h>
 #include <i915_drm.h>
+#ifndef __ANDROID__
 #include <pciaccess.h>
+#endif
 #include "libdrm_macros.h"
 #include "intel_bufmgr.h"
 #include "intel_bufmgr_priv.h"
@@ -326,6 +328,7 @@  drm_intel_get_pipe_from_crtc_id(drm_intel_bufmgr *bufmgr, int crtc_id)
 	return -1;
 }
 
+#ifndef __ANDROID__
 static size_t
 drm_intel_probe_agp_aperture_size(int fd)
 {
@@ -351,6 +354,15 @@  err:
 	pci_system_cleanup ();
 	return size;
 }
+#else
+static size_t
+drm_intel_probe_agp_aperture_size(int fd)
+{
+	/* Nothing seems to rely on this value on Android anyway... */
+	fprintf(stderr, "%s: Mappable aperture size hardcoded to 64MiB\n");
+	return 64 * 1024 * 1024;
+}
+#endif
 
 int
 drm_intel_get_aperture_sizes(int fd, size_t *mappable, size_t *total)