* [Intel-gfx] [RFC PATCH i-g-t] lib/i915/perf: Fix non-card0 processing
@ 2021-04-30 16:18 Janusz Krzysztofik
2021-05-03 7:07 ` Lionel Landwerlin
0 siblings, 1 reply; 3+ messages in thread
From: Janusz Krzysztofik @ 2021-04-30 16:18 UTC (permalink / raw)
To: igt-dev; +Cc: intel-gfx
IGT i915/perf library functions now always operate on sysfs perf
attributes of card0 device node, no matter which DRM device fd a user
passes. The intention was to always switch to primary device node if
a user passes a render device node fd, but that breaks handling of
non-card0 devices.
Instead of forcibly using DRM device minor number 0 when opening a
device sysfs area, convert device minor number of a user passed device
fd to the minor number of respective primary (cardX) device node.
Signed-off-by: Janusz Krzysztofik <janusz.krzysztofik@linux.intel.com>
---
lib/i915/perf.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/lib/i915/perf.c b/lib/i915/perf.c
index 56d5c0b3a..336824df7 100644
--- a/lib/i915/perf.c
+++ b/lib/i915/perf.c
@@ -376,8 +376,8 @@ open_master_sysfs_dir(int drm_fd)
if (fstat(drm_fd, &st) || !S_ISCHR(st.st_mode))
return -1;
- snprintf(path, sizeof(path), "/sys/dev/char/%d:0",
- major(st.st_rdev));
+ snprintf(path, sizeof(path), "/sys/dev/char/%d:%d",
+ major(st.st_rdev), minor(st.st_rdev) & ~128);
return open(path, O_DIRECTORY);
}
--
2.25.1
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [Intel-gfx] [RFC PATCH i-g-t] lib/i915/perf: Fix non-card0 processing
2021-04-30 16:18 [Intel-gfx] [RFC PATCH i-g-t] lib/i915/perf: Fix non-card0 processing Janusz Krzysztofik
@ 2021-05-03 7:07 ` Lionel Landwerlin
2021-05-05 9:56 ` Janusz Krzysztofik
0 siblings, 1 reply; 3+ messages in thread
From: Lionel Landwerlin @ 2021-05-03 7:07 UTC (permalink / raw)
To: Janusz Krzysztofik, igt-dev; +Cc: intel-gfx
On 30/04/2021 19:18, Janusz Krzysztofik wrote:
> IGT i915/perf library functions now always operate on sysfs perf
> attributes of card0 device node, no matter which DRM device fd a user
> passes. The intention was to always switch to primary device node if
> a user passes a render device node fd, but that breaks handling of
> non-card0 devices.
>
> Instead of forcibly using DRM device minor number 0 when opening a
> device sysfs area, convert device minor number of a user passed device
> fd to the minor number of respective primary (cardX) device node.
>
> Signed-off-by: Janusz Krzysztofik <janusz.krzysztofik@linux.intel.com>
> ---
> lib/i915/perf.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/lib/i915/perf.c b/lib/i915/perf.c
> index 56d5c0b3a..336824df7 100644
> --- a/lib/i915/perf.c
> +++ b/lib/i915/perf.c
> @@ -376,8 +376,8 @@ open_master_sysfs_dir(int drm_fd)
> if (fstat(drm_fd, &st) || !S_ISCHR(st.st_mode))
> return -1;
>
> - snprintf(path, sizeof(path), "/sys/dev/char/%d:0",
> - major(st.st_rdev));
> + snprintf(path, sizeof(path), "/sys/dev/char/%d:%d",
> + major(st.st_rdev), minor(st.st_rdev) & ~128);
Isn't it minor(st.st_rdev) & 0xff ? or even 0x3f ?
Looks like /dev/dri/controlD64 can exist too.
-Lionel
>
> return open(path, O_DIRECTORY);
> }
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Intel-gfx] [RFC PATCH i-g-t] lib/i915/perf: Fix non-card0 processing
2021-05-03 7:07 ` Lionel Landwerlin
@ 2021-05-05 9:56 ` Janusz Krzysztofik
0 siblings, 0 replies; 3+ messages in thread
From: Janusz Krzysztofik @ 2021-05-05 9:56 UTC (permalink / raw)
To: igt-dev, Lionel Landwerlin; +Cc: intel-gfx
Hi Lionel,
On poniedziałek, 3 maja 2021 09:07:09 CEST Lionel Landwerlin wrote:
> On 30/04/2021 19:18, Janusz Krzysztofik wrote:
> > IGT i915/perf library functions now always operate on sysfs perf
> > attributes of card0 device node, no matter which DRM device fd a user
> > passes. The intention was to always switch to primary device node if
> > a user passes a render device node fd, but that breaks handling of
> > non-card0 devices.
> >
> > Instead of forcibly using DRM device minor number 0 when opening a
> > device sysfs area, convert device minor number of a user passed device
> > fd to the minor number of respective primary (cardX) device node.
> >
> > Signed-off-by: Janusz Krzysztofik <janusz.krzysztofik@linux.intel.com>
> > ---
> > lib/i915/perf.c | 4 ++--
> > 1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/lib/i915/perf.c b/lib/i915/perf.c
> > index 56d5c0b3a..336824df7 100644
> > --- a/lib/i915/perf.c
> > +++ b/lib/i915/perf.c
> > @@ -376,8 +376,8 @@ open_master_sysfs_dir(int drm_fd)
> > if (fstat(drm_fd, &st) || !S_ISCHR(st.st_mode))
> > return -1;
> >
> > - snprintf(path, sizeof(path), "/sys/dev/char/%d:0",
> > - major(st.st_rdev));
> > + snprintf(path, sizeof(path), "/sys/dev/char/%d:%d",
> > + major(st.st_rdev), minor(st.st_rdev) & ~128);
>
>
> Isn't it minor(st.st_rdev) & 0xff ?
Did you mean 0x7f?
> or even 0x3f ?
>
> Looks like /dev/dri/controlD64 can exist too.
Not any longer, see commit 0d49f303e8a7 ("drm: remove all control node code").
However, my approach of applying a mask is oversimplified. Minor numbers for
different node types (primary and render) are handled separately. I'm going
to propose a method similar to that implemented in igt_debugfs_path().
Thanks,
Janusz
>
>
> -Lionel
>
>
> >
> > return open(path, O_DIRECTORY);
> > }
>
>
>
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-05-05 9:57 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-04-30 16:18 [Intel-gfx] [RFC PATCH i-g-t] lib/i915/perf: Fix non-card0 processing Janusz Krzysztofik
2021-05-03 7:07 ` Lionel Landwerlin
2021-05-05 9:56 ` Janusz Krzysztofik
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox