Re: [Mesa-dev] [PATCH v2] loader: Add support for platform and host1x busses

2018-03-02 Thread Thierry Reding
On Fri, Mar 02, 2018 at 01:31:22PM +, Emil Velikov wrote:
> On 2 March 2018 at 11:29, Thierry Reding  wrote:
> > From: Thierry Reding 
> >
> > ARM SoCs usually have their DRM/KMS devices on the platform bus, so add
> > support for this bus in order to allow use of the DRI_PRIME environment
> > variable with those devices.
> >
> > While at it, also support the host1x bus, which is effectively the same
> > but uses an additional layer in the bus hierarchy.
> >
> > Note that it isn't enough to support the bus that has the rendering GPU
> > because the loader code will also try to construct an ID path tag for a
> > scanout-only device if it is the default that is being opened.
> >
> > The ID path tag for a device can be obtained by running udevadm info on
> > the device node, as shown in this example on NVIDIA Tegra:
> >
> > $ udevadm info /dev/dri/card0 | grep ID_PATH_TAG
> > E: ID_PATH_TAG=platform-5000_host1x
> >
> > The corresponding OF_FULLNAME property, from which the ID_PATH_TAG is
> > constructed, can be found in the sysfs "uevent" attribute for the card0
> > device's parent:
> >
> > $ grep OF_FULLNAME /sys/devices/platform/5000.host1x/drm/uevent
> > OF_FULLNAME=/host1x@5000
> >
> > Similarily, /dev/dri/card1 corresponds to the GPU:
> >
> > $ udevadm info /dev/dri/card1 | grep ID_PATH_TAG
> > E: ID_PATH_TAG=platform-5700_gpu
> >
> > and:
> >
> > $ grep OF_FULLNAME /sys/devices/platform/5700.gpu/uevent
> > OF_FULLNAME=/gpu@5700
> >
> > Changes in v2:
> > - avoid confusing pre-increment in strdup()
> > - add examples of tags to commit log
> >
> > Reviewed-by: Eric Engestrom 
> > Signed-off-by: Thierry Reding 
> Smashing, thanks for the examples Thierry.
> 
> Reviewed-by: Emil Velikov 

Thanks! Pushed to master.

Thierry


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


Re: [Mesa-dev] [PATCH v2] loader: Add support for platform and host1x busses

2018-03-02 Thread Emil Velikov
On 2 March 2018 at 11:29, Thierry Reding  wrote:
> From: Thierry Reding 
>
> ARM SoCs usually have their DRM/KMS devices on the platform bus, so add
> support for this bus in order to allow use of the DRI_PRIME environment
> variable with those devices.
>
> While at it, also support the host1x bus, which is effectively the same
> but uses an additional layer in the bus hierarchy.
>
> Note that it isn't enough to support the bus that has the rendering GPU
> because the loader code will also try to construct an ID path tag for a
> scanout-only device if it is the default that is being opened.
>
> The ID path tag for a device can be obtained by running udevadm info on
> the device node, as shown in this example on NVIDIA Tegra:
>
> $ udevadm info /dev/dri/card0 | grep ID_PATH_TAG
> E: ID_PATH_TAG=platform-5000_host1x
>
> The corresponding OF_FULLNAME property, from which the ID_PATH_TAG is
> constructed, can be found in the sysfs "uevent" attribute for the card0
> device's parent:
>
> $ grep OF_FULLNAME /sys/devices/platform/5000.host1x/drm/uevent
> OF_FULLNAME=/host1x@5000
>
> Similarily, /dev/dri/card1 corresponds to the GPU:
>
> $ udevadm info /dev/dri/card1 | grep ID_PATH_TAG
> E: ID_PATH_TAG=platform-5700_gpu
>
> and:
>
> $ grep OF_FULLNAME /sys/devices/platform/5700.gpu/uevent
> OF_FULLNAME=/gpu@5700
>
> Changes in v2:
> - avoid confusing pre-increment in strdup()
> - add examples of tags to commit log
>
> Reviewed-by: Eric Engestrom 
> Signed-off-by: Thierry Reding 
Smashing, thanks for the examples Thierry.

Reviewed-by: Emil Velikov 

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


[Mesa-dev] [PATCH v2] loader: Add support for platform and host1x busses

2018-03-02 Thread Thierry Reding
From: Thierry Reding 

ARM SoCs usually have their DRM/KMS devices on the platform bus, so add
support for this bus in order to allow use of the DRI_PRIME environment
variable with those devices.

While at it, also support the host1x bus, which is effectively the same
but uses an additional layer in the bus hierarchy.

Note that it isn't enough to support the bus that has the rendering GPU
because the loader code will also try to construct an ID path tag for a
scanout-only device if it is the default that is being opened.

The ID path tag for a device can be obtained by running udevadm info on
the device node, as shown in this example on NVIDIA Tegra:

$ udevadm info /dev/dri/card0 | grep ID_PATH_TAG
E: ID_PATH_TAG=platform-5000_host1x

The corresponding OF_FULLNAME property, from which the ID_PATH_TAG is
constructed, can be found in the sysfs "uevent" attribute for the card0
device's parent:

$ grep OF_FULLNAME /sys/devices/platform/5000.host1x/drm/uevent
OF_FULLNAME=/host1x@5000

Similarily, /dev/dri/card1 corresponds to the GPU:

$ udevadm info /dev/dri/card1 | grep ID_PATH_TAG
E: ID_PATH_TAG=platform-5700_gpu

and:

$ grep OF_FULLNAME /sys/devices/platform/5700.gpu/uevent
OF_FULLNAME=/gpu@5700

Changes in v2:
- avoid confusing pre-increment in strdup()
- add examples of tags to commit log

Reviewed-by: Eric Engestrom 
Signed-off-by: Thierry Reding 
---
 src/loader/loader.c | 27 +++
 1 file changed, 27 insertions(+)

diff --git a/src/loader/loader.c b/src/loader/loader.c
index 92b4c5204b19..43275484cc2e 100644
--- a/src/loader/loader.c
+++ b/src/loader/loader.c
@@ -120,6 +120,33 @@ static char *drm_construct_id_path_tag(drmDevicePtr device)
device->businfo.pci->func) < 0) {
  return NULL;
   }
+   } else if (device->bustype == DRM_BUS_PLATFORM ||
+  device->bustype == DRM_BUS_HOST1X) {
+  char *fullname, *name, *address;
+
+  if (device->bustype == DRM_BUS_PLATFORM)
+ fullname = device->businfo.platform->fullname;
+  else
+ fullname = device->businfo.host1x->fullname;
+
+  name = strrchr(fullname, '/');
+  if (!name)
+ name = strdup(fullname);
+  else
+ name = strdup(name + 1);
+
+  address = strchr(name, '@');
+  if (address) {
+ *address++ = '\0';
+
+ if (asprintf(, "platform-%s_%s", address, name) < 0)
+tag = NULL;
+  } else {
+ if (asprintf(, "platform-%s", name) < 0)
+tag = NULL;
+  }
+
+  free(name);
}
return tag;
 }
-- 
2.16.2

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