Re: [Mesa-dev] [PATCH] egl/android: rework device probing

2018-08-29 Thread Emil Velikov
On 29 August 2018 at 07:55, Tomasz Figa  wrote:
> Hi Emil,
>
> On Fri, Aug 24, 2018 at 9:25 PM Emil Velikov  wrote:
>>
>> From: Emil Velikov 
>>
>> Unlike the other platforms, here we aim do guess if the device that we
>> somewhat arbitrarily picked, is supported or not.
>>
>> In particular: when a vendor is _not_ requested we loop through all
>> devices, picking the first one which can create a DRI screen.
>>
>> When a vendor is requested - we use that and do _not_ fall-back to any
>> other device.
>>
>> The former seems a bit fiddly, but considering EGL_EXT_explicit_device and
>> EGL_MESA_query_renderer are MIA, this is the best we can do for the
>> moment.
>>
>> With those (proposed) extensions userspace will be able to create a
>> separate EGL display for each device, query device details and make the
>> conscious decision which one to use.
>>
>> Cc: Robert Foss 
>> Cc: Tomasz Figa 
>> Signed-off-by: Emil Velikov 
>> ---
>> Thanks for the clarification Tomasz. The original code was using a
>> fall-back even a vendor was explicitly requested, confusing me a bit ;-)
>
> Yeah, it was surprisingly difficult to get it right and I missed that
> in the review. Thanks for figuring this out.
>
>> ---
>>  src/egl/drivers/dri2/platform_android.c | 71 +++--
>>  1 file changed, 43 insertions(+), 28 deletions(-)
>>
>> diff --git a/src/egl/drivers/dri2/platform_android.c 
>> b/src/egl/drivers/dri2/platform_android.c
>> index 1f9fe27ab85..5bf627dec7d 100644
>> --- a/src/egl/drivers/dri2/platform_android.c
>> +++ b/src/egl/drivers/dri2/platform_android.c
>> @@ -1420,13 +1420,32 @@ droid_filter_device(_EGLDisplay *disp, int fd, const 
>> char *vendor)
>> return 0;
>>  }
>>
>> +static int
>> +droid_probe_device(_EGLDisplay *disp)
>> +{
>> +  /* Check that the device is supported, by attempting to:
>> +   * - load the dri module
>> +   * - and, create a screen
>> +   */
>> +   if (!droid_load_driver(disp)) {
>> +  _eglLog(_EGL_WARNING, "DRI2: failed to load driver");
>
> Failing to create a screen is probably critical enough to be worth a
> message, even if just probing, but failing to load a driver would like
> mean that there is no driver for the device, so perhaps we don't need
> to clutter the log in such case?
>
I'm fine either way - merely copying what everyone else does ;-)

>> +  return -1;
>> +   }
>> +
>> +   if (!dri2_create_screen(disp)) {
>> +  _eglLog(_EGL_WARNING, "DRI2: failed to create screen");
>
> I don't remember if I got an answer to this question, sorry if I did:
>
> Is there really nothing to clean up after droid_load_driver()? Not
> leaking anything here, when probing though the subsequent devices?
>
No other driver does such handling so there's no separate helper.
I'll pull out the bits from dri2_display_destroy (a dlclose + free)
and into a preparatory patch, when sending the next revision.

>> + close(fd);
>> + fd = -1;
>>   continue;
>>}
>> -  /* Found a device */
>>break;
>
> A break at the end of a loop is really confusing to read. Could we
> rewrite the last block to avoid it? E.g.
>
>if (!droid_probe_device(disp)) {
>   /* Found a device */
>   break;
>}
>/* No explicit request - attempt the next device. */
>close(fd);
>fd = -1;
> }
>
Sure thing.

Will try to send out next revision tomorrow.

Thanks
Emil
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH] egl/android: rework device probing

2018-08-28 Thread Tomasz Figa
Hi Emil,

On Fri, Aug 24, 2018 at 9:25 PM Emil Velikov  wrote:
>
> From: Emil Velikov 
>
> Unlike the other platforms, here we aim do guess if the device that we
> somewhat arbitrarily picked, is supported or not.
>
> In particular: when a vendor is _not_ requested we loop through all
> devices, picking the first one which can create a DRI screen.
>
> When a vendor is requested - we use that and do _not_ fall-back to any
> other device.
>
> The former seems a bit fiddly, but considering EGL_EXT_explicit_device and
> EGL_MESA_query_renderer are MIA, this is the best we can do for the
> moment.
>
> With those (proposed) extensions userspace will be able to create a
> separate EGL display for each device, query device details and make the
> conscious decision which one to use.
>
> Cc: Robert Foss 
> Cc: Tomasz Figa 
> Signed-off-by: Emil Velikov 
> ---
> Thanks for the clarification Tomasz. The original code was using a
> fall-back even a vendor was explicitly requested, confusing me a bit ;-)

Yeah, it was surprisingly difficult to get it right and I missed that
in the review. Thanks for figuring this out.

> ---
>  src/egl/drivers/dri2/platform_android.c | 71 +++--
>  1 file changed, 43 insertions(+), 28 deletions(-)
>
> diff --git a/src/egl/drivers/dri2/platform_android.c 
> b/src/egl/drivers/dri2/platform_android.c
> index 1f9fe27ab85..5bf627dec7d 100644
> --- a/src/egl/drivers/dri2/platform_android.c
> +++ b/src/egl/drivers/dri2/platform_android.c
> @@ -1420,13 +1420,32 @@ droid_filter_device(_EGLDisplay *disp, int fd, const 
> char *vendor)
> return 0;
>  }
>
> +static int
> +droid_probe_device(_EGLDisplay *disp)
> +{
> +  /* Check that the device is supported, by attempting to:
> +   * - load the dri module
> +   * - and, create a screen
> +   */
> +   if (!droid_load_driver(disp)) {
> +  _eglLog(_EGL_WARNING, "DRI2: failed to load driver");

Failing to create a screen is probably critical enough to be worth a
message, even if just probing, but failing to load a driver would like
mean that there is no driver for the device, so perhaps we don't need
to clutter the log in such case?

> +  return -1;
> +   }
> +
> +   if (!dri2_create_screen(disp)) {
> +  _eglLog(_EGL_WARNING, "DRI2: failed to create screen");

I don't remember if I got an answer to this question, sorry if I did:

Is there really nothing to clean up after droid_load_driver()? Not
leaking anything here, when probing though the subsequent devices?

> +  return -1;
> +   }
> +   return 0;
> +}
> +
>  static int
>  droid_open_device(_EGLDisplay *disp)
>  {
>  #define MAX_DRM_DEVICES 32
> drmDevicePtr device, devices[MAX_DRM_DEVICES] = { NULL };
> int prop_set, num_devices;
> -   int fd = -1, fallback_fd = -1;
> +   int fd = -1;
>
> char *vendor_name = NULL;
> char vendor_buf[PROPERTY_VALUE_MAX];
> @@ -1451,33 +1470,39 @@ droid_open_device(_EGLDisplay *disp)
>   continue;
>}
>
> -  if (vendor_name && droid_filter_device(disp, fd, vendor_name)) {
> - /* Match requested, but not found - set as fallback */
> - if (fallback_fd == -1) {
> -fallback_fd = fd;
> - } else {
> +  /* If a vendor is explicitly provided, we use only that.
> +   * Otherwise we fall-back the first device that is supported.
> +   */
> +  if (vendor_name) {
> + if (droid_filter_device(disp, fd, vendor_name)) {
> +/* Device does not match - try next device */
>  close(fd);
>  fd = -1;
> +continue;
>   }
> -
> + /* If the requested device matches use it, regardless if
> +  * init fails. Do not fall-back to any other device.
> +  */
> + if (droid_probbe_device(disp)) {

typo: droid_probe_device

> +close(fd);
> +fd = -1;
> + }
> + break;
> +  }
> +  /* No explicit request - attempt the next device */
> +  if (droid_probbe_device(disp)) {

typo: droid_probe_device

> + close(fd);
> + fd = -1;
>   continue;
>}
> -  /* Found a device */
>break;

A break at the end of a loop is really confusing to read. Could we
rewrite the last block to avoid it? E.g.

   if (!droid_probe_device(disp)) {
  /* Found a device */
  break;
   }
   /* No explicit request - attempt the next device. */
   close(fd);
   fd = -1;
}

Best regards,
Tomasz
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH] egl/android: rework device probing

2018-08-27 Thread Robert Foss

Hey,

On 27/08/2018 11.47, Emil Velikov wrote:

On 24 August 2018 at 18:55, Robert Foss  wrote:

Hey Emil,


On 24/08/2018 14.21, Emil Velikov wrote:


From: Emil Velikov 

Unlike the other platforms, here we aim do guess if the device that we
somewhat arbitrarily picked, is supported or not.

In particular: when a vendor is _not_ requested we loop through all
devices, picking the first one which can create a DRI screen.

When a vendor is requested - we use that and do _not_ fall-back to any
other device.

The former seems a bit fiddly, but considering EGL_EXT_explicit_device and
EGL_MESA_query_renderer are MIA, this is the best we can do for the
moment.

With those (proposed) extensions userspace will be able to create a
separate EGL display for each device, query device details and make the
conscious decision which one to use.

Cc: Robert Foss 
Cc: Tomasz Figa 
Signed-off-by: Emil Velikov 
---
Thanks for the clarification Tomasz. The original code was using a
fall-back even a vendor was explicitly requested, confusing me a bit ;-)
---
   src/egl/drivers/dri2/platform_android.c | 71 +++--
   1 file changed, 43 insertions(+), 28 deletions(-)

diff --git a/src/egl/drivers/dri2/platform_android.c
b/src/egl/drivers/dri2/platform_android.c
index 1f9fe27ab85..5bf627dec7d 100644
--- a/src/egl/drivers/dri2/platform_android.c
+++ b/src/egl/drivers/dri2/platform_android.c
@@ -1420,13 +1420,32 @@ droid_filter_device(_EGLDisplay *disp, int fd,
const char *vendor)
  return 0;
   }
   +static int
+droid_probe_device(_EGLDisplay *disp)
+{
+  /* Check that the device is supported, by attempting to:
+   * - load the dri module
+   * - and, create a screen
+   */
+   if (!droid_load_driver(disp)) {
+  _eglLog(_EGL_WARNING, "DRI2: failed to load driver");
+  return -1;
+   }
+
+   if (!dri2_create_screen(disp)) {
+  _eglLog(_EGL_WARNING, "DRI2: failed to create screen");
+  return -1;
+   }
+   return 0;
+}
+
   static int
   droid_open_device(_EGLDisplay *disp)
   {
   #define MAX_DRM_DEVICES 32
  drmDevicePtr device, devices[MAX_DRM_DEVICES] = { NULL };
  int prop_set, num_devices;
-   int fd = -1, fallback_fd = -1;
+   int fd = -1;
char *vendor_name = NULL;
  char vendor_buf[PROPERTY_VALUE_MAX];
@@ -1451,33 +1470,39 @@ droid_open_device(_EGLDisplay *disp)
continue;
 }
   -  if (vendor_name && droid_filter_device(disp, fd, vendor_name)) {
- /* Match requested, but not found - set as fallback */
- if (fallback_fd == -1) {
-fallback_fd = fd;
- } else {
+  /* If a vendor is explicitly provided, we use only that.
+   * Otherwise we fall-back the first device that is supported.
+   */
+  if (vendor_name) {
+ if (droid_filter_device(disp, fd, vendor_name)) {
+/* Device does not match - try next device */
   close(fd);
   fd = -1;
+continue;
}
-
+ /* If the requested device matches use it, regardless if
+  * init fails. Do not fall-back to any other device.
+  */
+ if (droid_probbe_device(disp)) {



Typo in function name.


Thanks for having a look Rob. Will fix (plus second instance below).


+close(fd);
+fd = -1;
+ }



Isn't the above comment saying that the if statement just below it shouldn't
be there? Or am I misparsing something?


I think it matches with the comment - note the function returns an int
0 on success.

We could change that esp. since others - droid_load_driver return an EGLBoolean.
Alternatively we could use if (droid_probbe_device(disp) != 0)

I'm fine either way.


Upon re-reading this, I'm happy with the way it is.

Feel free to add my r-b with the above typo fixed.



-Emil


___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH] egl/android: rework device probing

2018-08-27 Thread Emil Velikov
On 24 August 2018 at 18:55, Robert Foss  wrote:
> Hey Emil,
>
>
> On 24/08/2018 14.21, Emil Velikov wrote:
>>
>> From: Emil Velikov 
>>
>> Unlike the other platforms, here we aim do guess if the device that we
>> somewhat arbitrarily picked, is supported or not.
>>
>> In particular: when a vendor is _not_ requested we loop through all
>> devices, picking the first one which can create a DRI screen.
>>
>> When a vendor is requested - we use that and do _not_ fall-back to any
>> other device.
>>
>> The former seems a bit fiddly, but considering EGL_EXT_explicit_device and
>> EGL_MESA_query_renderer are MIA, this is the best we can do for the
>> moment.
>>
>> With those (proposed) extensions userspace will be able to create a
>> separate EGL display for each device, query device details and make the
>> conscious decision which one to use.
>>
>> Cc: Robert Foss 
>> Cc: Tomasz Figa 
>> Signed-off-by: Emil Velikov 
>> ---
>> Thanks for the clarification Tomasz. The original code was using a
>> fall-back even a vendor was explicitly requested, confusing me a bit ;-)
>> ---
>>   src/egl/drivers/dri2/platform_android.c | 71 +++--
>>   1 file changed, 43 insertions(+), 28 deletions(-)
>>
>> diff --git a/src/egl/drivers/dri2/platform_android.c
>> b/src/egl/drivers/dri2/platform_android.c
>> index 1f9fe27ab85..5bf627dec7d 100644
>> --- a/src/egl/drivers/dri2/platform_android.c
>> +++ b/src/egl/drivers/dri2/platform_android.c
>> @@ -1420,13 +1420,32 @@ droid_filter_device(_EGLDisplay *disp, int fd,
>> const char *vendor)
>>  return 0;
>>   }
>>   +static int
>> +droid_probe_device(_EGLDisplay *disp)
>> +{
>> +  /* Check that the device is supported, by attempting to:
>> +   * - load the dri module
>> +   * - and, create a screen
>> +   */
>> +   if (!droid_load_driver(disp)) {
>> +  _eglLog(_EGL_WARNING, "DRI2: failed to load driver");
>> +  return -1;
>> +   }
>> +
>> +   if (!dri2_create_screen(disp)) {
>> +  _eglLog(_EGL_WARNING, "DRI2: failed to create screen");
>> +  return -1;
>> +   }
>> +   return 0;
>> +}
>> +
>>   static int
>>   droid_open_device(_EGLDisplay *disp)
>>   {
>>   #define MAX_DRM_DEVICES 32
>>  drmDevicePtr device, devices[MAX_DRM_DEVICES] = { NULL };
>>  int prop_set, num_devices;
>> -   int fd = -1, fallback_fd = -1;
>> +   int fd = -1;
>>char *vendor_name = NULL;
>>  char vendor_buf[PROPERTY_VALUE_MAX];
>> @@ -1451,33 +1470,39 @@ droid_open_device(_EGLDisplay *disp)
>>continue;
>> }
>>   -  if (vendor_name && droid_filter_device(disp, fd, vendor_name)) {
>> - /* Match requested, but not found - set as fallback */
>> - if (fallback_fd == -1) {
>> -fallback_fd = fd;
>> - } else {
>> +  /* If a vendor is explicitly provided, we use only that.
>> +   * Otherwise we fall-back the first device that is supported.
>> +   */
>> +  if (vendor_name) {
>> + if (droid_filter_device(disp, fd, vendor_name)) {
>> +/* Device does not match - try next device */
>>   close(fd);
>>   fd = -1;
>> +continue;
>>}
>> -
>> + /* If the requested device matches use it, regardless if
>> +  * init fails. Do not fall-back to any other device.
>> +  */
>> + if (droid_probbe_device(disp)) {
>
>
> Typo in function name.
>
Thanks for having a look Rob. Will fix (plus second instance below).

>> +close(fd);
>> +fd = -1;
>> + }
>
>
> Isn't the above comment saying that the if statement just below it shouldn't
> be there? Or am I misparsing something?
>
I think it matches with the comment - note the function returns an int
0 on success.

We could change that esp. since others - droid_load_driver return an EGLBoolean.
Alternatively we could use if (droid_probbe_device(disp) != 0)

I'm fine either way.

-Emil
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH] egl/android: rework device probing

2018-08-24 Thread Robert Foss

Hey Emil,

On 24/08/2018 14.21, Emil Velikov wrote:

From: Emil Velikov 

Unlike the other platforms, here we aim do guess if the device that we
somewhat arbitrarily picked, is supported or not.

In particular: when a vendor is _not_ requested we loop through all
devices, picking the first one which can create a DRI screen.

When a vendor is requested - we use that and do _not_ fall-back to any
other device.

The former seems a bit fiddly, but considering EGL_EXT_explicit_device and
EGL_MESA_query_renderer are MIA, this is the best we can do for the
moment.

With those (proposed) extensions userspace will be able to create a
separate EGL display for each device, query device details and make the
conscious decision which one to use.

Cc: Robert Foss 
Cc: Tomasz Figa 
Signed-off-by: Emil Velikov 
---
Thanks for the clarification Tomasz. The original code was using a
fall-back even a vendor was explicitly requested, confusing me a bit ;-)
---
  src/egl/drivers/dri2/platform_android.c | 71 +++--
  1 file changed, 43 insertions(+), 28 deletions(-)

diff --git a/src/egl/drivers/dri2/platform_android.c 
b/src/egl/drivers/dri2/platform_android.c
index 1f9fe27ab85..5bf627dec7d 100644
--- a/src/egl/drivers/dri2/platform_android.c
+++ b/src/egl/drivers/dri2/platform_android.c
@@ -1420,13 +1420,32 @@ droid_filter_device(_EGLDisplay *disp, int fd, const 
char *vendor)
 return 0;
  }
  
+static int

+droid_probe_device(_EGLDisplay *disp)
+{
+  /* Check that the device is supported, by attempting to:
+   * - load the dri module
+   * - and, create a screen
+   */
+   if (!droid_load_driver(disp)) {
+  _eglLog(_EGL_WARNING, "DRI2: failed to load driver");
+  return -1;
+   }
+
+   if (!dri2_create_screen(disp)) {
+  _eglLog(_EGL_WARNING, "DRI2: failed to create screen");
+  return -1;
+   }
+   return 0;
+}
+
  static int
  droid_open_device(_EGLDisplay *disp)
  {
  #define MAX_DRM_DEVICES 32
 drmDevicePtr device, devices[MAX_DRM_DEVICES] = { NULL };
 int prop_set, num_devices;
-   int fd = -1, fallback_fd = -1;
+   int fd = -1;
  
 char *vendor_name = NULL;

 char vendor_buf[PROPERTY_VALUE_MAX];
@@ -1451,33 +1470,39 @@ droid_open_device(_EGLDisplay *disp)
   continue;
}
  
-  if (vendor_name && droid_filter_device(disp, fd, vendor_name)) {

- /* Match requested, but not found - set as fallback */
- if (fallback_fd == -1) {
-fallback_fd = fd;
- } else {
+  /* If a vendor is explicitly provided, we use only that.
+   * Otherwise we fall-back the first device that is supported.
+   */
+  if (vendor_name) {
+ if (droid_filter_device(disp, fd, vendor_name)) {
+/* Device does not match - try next device */
  close(fd);
  fd = -1;
+continue;
   }
-
+ /* If the requested device matches use it, regardless if
+  * init fails. Do not fall-back to any other device.
+  */
+ if (droid_probbe_device(disp)) {


Typo in function name.


+close(fd);
+fd = -1;
+ }


Isn't the above comment saying that the if statement just below it shouldn't
be there? Or am I misparsing something?


+ break;
+  }
+  /* No explicit request - attempt the next device */
+  if (droid_probbe_device(disp)) {


Typo in function name.


+ close(fd);
+ fd = -1;
   continue;
}
-  /* Found a device */
break;
 }
 drmFreeDevices(devices, num_devices);
  
-   if (fallback_fd < 0 && fd < 0) {

-  _eglLog(_EGL_WARNING, "Failed to open any DRM device");
-  return -1;
-   }
-
-   if (fd < 0) {
-  _eglLog(_EGL_WARNING, "Failed to open desired DRM device, using 
fallback");
-  return fallback_fd;
-   }
+   if (fd < 0)
+  _eglLog(_EGL_WARNING, "Failed to open %s DRM device",
+vendor_name ? "desired": "any");
  
-   close(fallback_fd);

 return fd;
  #undef MAX_DRM_DEVICES
  }
@@ -1519,16 +1544,6 @@ dri2_initialize_android(_EGLDriver *drv, _EGLDisplay 
*disp)
goto cleanup;
 }
  
-   if (!droid_load_driver(disp)) {

-  err = "DRI2: failed to load driver";
-  goto cleanup;
-   }
-
-   if (!dri2_create_screen(disp)) {
-  err = "DRI2: failed to create screen";
-  goto cleanup;
-   }
-
 if (!dri2_setup_extensions(disp)) {
err = "DRI2: failed to setup extensions";
goto cleanup;


___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH] egl/android: rework device probing

2018-08-24 Thread Emil Velikov
From: Emil Velikov 

Unlike the other platforms, here we aim do guess if the device that we
somewhat arbitrarily picked, is supported or not.

In particular: when a vendor is _not_ requested we loop through all
devices, picking the first one which can create a DRI screen.

When a vendor is requested - we use that and do _not_ fall-back to any
other device.

The former seems a bit fiddly, but considering EGL_EXT_explicit_device and
EGL_MESA_query_renderer are MIA, this is the best we can do for the
moment.

With those (proposed) extensions userspace will be able to create a
separate EGL display for each device, query device details and make the
conscious decision which one to use.

Cc: Robert Foss 
Cc: Tomasz Figa 
Signed-off-by: Emil Velikov 
---
Thanks for the clarification Tomasz. The original code was using a
fall-back even a vendor was explicitly requested, confusing me a bit ;-)
---
 src/egl/drivers/dri2/platform_android.c | 71 +++--
 1 file changed, 43 insertions(+), 28 deletions(-)

diff --git a/src/egl/drivers/dri2/platform_android.c 
b/src/egl/drivers/dri2/platform_android.c
index 1f9fe27ab85..5bf627dec7d 100644
--- a/src/egl/drivers/dri2/platform_android.c
+++ b/src/egl/drivers/dri2/platform_android.c
@@ -1420,13 +1420,32 @@ droid_filter_device(_EGLDisplay *disp, int fd, const 
char *vendor)
return 0;
 }
 
+static int
+droid_probe_device(_EGLDisplay *disp)
+{
+  /* Check that the device is supported, by attempting to:
+   * - load the dri module
+   * - and, create a screen
+   */
+   if (!droid_load_driver(disp)) {
+  _eglLog(_EGL_WARNING, "DRI2: failed to load driver");
+  return -1;
+   }
+
+   if (!dri2_create_screen(disp)) {
+  _eglLog(_EGL_WARNING, "DRI2: failed to create screen");
+  return -1;
+   }
+   return 0;
+}
+
 static int
 droid_open_device(_EGLDisplay *disp)
 {
 #define MAX_DRM_DEVICES 32
drmDevicePtr device, devices[MAX_DRM_DEVICES] = { NULL };
int prop_set, num_devices;
-   int fd = -1, fallback_fd = -1;
+   int fd = -1;
 
char *vendor_name = NULL;
char vendor_buf[PROPERTY_VALUE_MAX];
@@ -1451,33 +1470,39 @@ droid_open_device(_EGLDisplay *disp)
  continue;
   }
 
-  if (vendor_name && droid_filter_device(disp, fd, vendor_name)) {
- /* Match requested, but not found - set as fallback */
- if (fallback_fd == -1) {
-fallback_fd = fd;
- } else {
+  /* If a vendor is explicitly provided, we use only that.
+   * Otherwise we fall-back the first device that is supported.
+   */
+  if (vendor_name) {
+ if (droid_filter_device(disp, fd, vendor_name)) {
+/* Device does not match - try next device */
 close(fd);
 fd = -1;
+continue;
  }
-
+ /* If the requested device matches use it, regardless if
+  * init fails. Do not fall-back to any other device.
+  */
+ if (droid_probbe_device(disp)) {
+close(fd);
+fd = -1;
+ }
+ break;
+  }
+  /* No explicit request - attempt the next device */
+  if (droid_probbe_device(disp)) {
+ close(fd);
+ fd = -1;
  continue;
   }
-  /* Found a device */
   break;
}
drmFreeDevices(devices, num_devices);
 
-   if (fallback_fd < 0 && fd < 0) {
-  _eglLog(_EGL_WARNING, "Failed to open any DRM device");
-  return -1;
-   }
-
-   if (fd < 0) {
-  _eglLog(_EGL_WARNING, "Failed to open desired DRM device, using 
fallback");
-  return fallback_fd;
-   }
+   if (fd < 0)
+  _eglLog(_EGL_WARNING, "Failed to open %s DRM device",
+vendor_name ? "desired": "any");
 
-   close(fallback_fd);
return fd;
 #undef MAX_DRM_DEVICES
 }
@@ -1519,16 +1544,6 @@ dri2_initialize_android(_EGLDriver *drv, _EGLDisplay 
*disp)
   goto cleanup;
}
 
-   if (!droid_load_driver(disp)) {
-  err = "DRI2: failed to load driver";
-  goto cleanup;
-   }
-
-   if (!dri2_create_screen(disp)) {
-  err = "DRI2: failed to create screen";
-  goto cleanup;
-   }
-
if (!dri2_setup_extensions(disp)) {
   err = "DRI2: failed to setup extensions";
   goto cleanup;
-- 
2.18.0

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev