* [PATCH v3 0/5] drm: Add decoding for DRM/KMS and i915 ioctls
@ 2015-07-01 12:52 Patrik Jakobsson
[not found] ` <1435755168-16207-1-git-send-email-patrik.jakobsson-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
` (2 more replies)
0 siblings, 3 replies; 22+ messages in thread
From: Patrik Jakobsson @ 2015-07-01 12:52 UTC (permalink / raw)
To: strace-devel, ldv, gabriel; +Cc: intel-gfx
This set of patches adds a dispatcher for handling DRM ioctls. The
kernel headers for DRM might not be available on all distributions
so we depend on libdrm for those. If libdrm is not available we fall
back on the kernel headers. Since DRM drivers share the same range of
private ioctl numbers I've added a function for detecting the driver
based on it's name.
Changes in v2:
* Rebased to master
* Added Changelog to commits
* Keep strace_SOURCES list sorted
* Removed unneeded includes
* Reduced number of driver name checks by adding tcb private data
* Use tprints() for regular strings
* Reworked entering() / exiting() handling for all ioctls
* Use printstr() to print strings in properly quoted form
Changes in v3:
* Moved all umove() into state checks for single state ioctls
* Removed extra curly bracket
* Moved param argument into entering() state in i915_setparam()
* Don't return before private data is freed in drm_ioctl()
Patrik Jakobsson (5):
drm: Add config for detecting libdrm
drm: Add private data field to trace control block
drm: Add dispatcher and driver identification for DRM
drm: Add decoding of i915 ioctls
drm: Add decoding of DRM and KMS ioctls
Makefile.am | 2 +
configure.ac | 4 +
defs.h | 11 +-
drm.c | 668 +++++++++++++++++++++++++++++++++++++++++++++
drm_i915.c | 332 ++++++++++++++++++++++
io.c | 2 +-
ioctl.c | 6 +-
xlat/drm_i915_getparams.in | 28 ++
xlat/drm_i915_ioctls.in | 51 ++++
xlat/drm_i915_setparams.in | 4 +
10 files changed, 1105 insertions(+), 3 deletions(-)
create mode 100644 drm.c
create mode 100644 drm_i915.c
create mode 100644 xlat/drm_i915_getparams.in
create mode 100644 xlat/drm_i915_ioctls.in
create mode 100644 xlat/drm_i915_setparams.in
--
2.1.4
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
^ permalink raw reply [flat|nested] 22+ messages in thread[parent not found: <1435755168-16207-1-git-send-email-patrik.jakobsson-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>]
* [PATCH v3 1/5] drm: Add config for detecting libdrm [not found] ` <1435755168-16207-1-git-send-email-patrik.jakobsson-VuQAYsv1563Yd54FQh9/CA@public.gmane.org> @ 2015-07-01 12:52 ` Patrik Jakobsson [not found] ` <1435755168-16207-2-git-send-email-patrik.jakobsson-VuQAYsv1563Yd54FQh9/CA@public.gmane.org> 2015-07-01 12:52 ` [PATCH v3 2/5] drm: Add private data field to trace control block Patrik Jakobsson 2015-07-01 12:52 ` [PATCH v3 3/5] drm: Add dispatcher and driver identification for DRM Patrik Jakobsson 2 siblings, 1 reply; 22+ messages in thread From: Patrik Jakobsson @ 2015-07-01 12:52 UTC (permalink / raw) To: strace-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f, ldv-u2l5PoMzF/Vg9hUCZPvPmw, gabriel-tU7rkvAWjlwhT4uAktR2oQ Cc: intel-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW Use pkg-config to try to find libdrm. If that fails use the standard include directory for kernel drm headers in /usr/include/drm. * configure.ac: Use pkg-config to find libdrm Signed-off-by: Patrik Jakobsson <patrik.jakobsson-VuQAYsv1563Yd54FQh9/CA@public.gmane.org> --- configure.ac | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/configure.ac b/configure.ac index bb8bf46..aa63af7 100644 --- a/configure.ac +++ b/configure.ac @@ -844,6 +844,10 @@ fi AM_CONDITIONAL([USE_LIBUNWIND], [test "x$use_libunwind" = xyes]) AC_MSG_RESULT([$use_libunwind]) +PKG_CHECK_MODULES([libdrm], [libdrm], + [CPPFLAGS="$CPPFLAGS $libdrm_CFLAGS"], + [CPPFLAGS="$CPPFLAGS -I/usr/include/drm"]) + if test "$arch" = mips && test "$no_create" != yes; then mkdir -p linux/mips if $srcdir/linux/mips/genstub.sh linux/mips; then -- 2.1.4 ------------------------------------------------------------------------------ Don't Limit Your Business. Reach for the Cloud. GigeNET's Cloud Solutions provide you with the tools and support that you need to offload your IT needs and focus on growing your business. Configured For All Businesses. Start Your Cloud Today. https://www.gigenetcloud.com/ ^ permalink raw reply related [flat|nested] 22+ messages in thread
[parent not found: <1435755168-16207-2-git-send-email-patrik.jakobsson-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>]
* Re: [PATCH v3 1/5] drm: Add config for detecting libdrm [not found] ` <1435755168-16207-2-git-send-email-patrik.jakobsson-VuQAYsv1563Yd54FQh9/CA@public.gmane.org> @ 2015-07-23 9:48 ` Mike Frysinger 2015-07-23 10:44 ` Dmitry V. Levin 2015-07-30 13:30 ` Patrik Jakobsson 0 siblings, 2 replies; 22+ messages in thread From: Mike Frysinger @ 2015-07-23 9:48 UTC (permalink / raw) To: strace development list Cc: intel-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW, ldv-u2l5PoMzF/Vg9hUCZPvPmw [-- Attachment #1.1: Type: text/plain, Size: 957 bytes --] On 01 Jul 2015 14:52, Patrik Jakobsson wrote: > Use pkg-config to try to find libdrm. If that fails use the standard > include directory for kernel drm headers in /usr/include/drm. > > * configure.ac: Use pkg-config to find libdrm > > Signed-off-by: Patrik Jakobsson <patrik.jakobsson-VuQAYsv1563Yd54FQh9/CA@public.gmane.org> > --- > configure.ac | 4 ++++ > 1 file changed, 4 insertions(+) > > diff --git a/configure.ac b/configure.ac > index bb8bf46..aa63af7 100644 > --- a/configure.ac > +++ b/configure.ac > @@ -844,6 +844,10 @@ fi > AM_CONDITIONAL([USE_LIBUNWIND], [test "x$use_libunwind" = xyes]) > AC_MSG_RESULT([$use_libunwind]) > > +PKG_CHECK_MODULES([libdrm], [libdrm], > + [CPPFLAGS="$CPPFLAGS $libdrm_CFLAGS"], > + [CPPFLAGS="$CPPFLAGS -I/usr/include/drm"]) yikes, no, this is a really really bad idea. it should read: PKG_CHECK_MODULES([LIBDRM], [libdrm], [CPPFLAGS="$CPPFLAGS $LIBDRM_CFLAGS"], [:]) -mike [-- Attachment #1.2: Digital signature --] [-- Type: application/pgp-signature, Size: 819 bytes --] [-- Attachment #2: Type: text/plain, Size: 79 bytes --] ------------------------------------------------------------------------------ [-- Attachment #3: Type: text/plain, Size: 195 bytes --] _______________________________________________ Strace-devel mailing list Strace-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org https://lists.sourceforge.net/lists/listinfo/strace-devel ^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [PATCH v3 1/5] drm: Add config for detecting libdrm 2015-07-23 9:48 ` Mike Frysinger @ 2015-07-23 10:44 ` Dmitry V. Levin [not found] ` <20150723104417.GA21575-u2l5PoMzF/Vg9hUCZPvPmw@public.gmane.org> 2015-07-30 13:30 ` Patrik Jakobsson 1 sibling, 1 reply; 22+ messages in thread From: Dmitry V. Levin @ 2015-07-23 10:44 UTC (permalink / raw) To: strace development list, gabriel, intel-gfx [-- Attachment #1.1: Type: text/plain, Size: 1092 bytes --] On Thu, Jul 23, 2015 at 05:48:21AM -0400, Mike Frysinger wrote: > On 01 Jul 2015 14:52, Patrik Jakobsson wrote: > > Use pkg-config to try to find libdrm. If that fails use the standard > > include directory for kernel drm headers in /usr/include/drm. > > > > * configure.ac: Use pkg-config to find libdrm > > > > Signed-off-by: Patrik Jakobsson <patrik.jakobsson@linux.intel.com> > > --- > > configure.ac | 4 ++++ > > 1 file changed, 4 insertions(+) > > > > diff --git a/configure.ac b/configure.ac > > index bb8bf46..aa63af7 100644 > > --- a/configure.ac > > +++ b/configure.ac > > @@ -844,6 +844,10 @@ fi > > AM_CONDITIONAL([USE_LIBUNWIND], [test "x$use_libunwind" = xyes]) > > AC_MSG_RESULT([$use_libunwind]) > > > > +PKG_CHECK_MODULES([libdrm], [libdrm], > > + [CPPFLAGS="$CPPFLAGS $libdrm_CFLAGS"], > > + [CPPFLAGS="$CPPFLAGS -I/usr/include/drm"]) > > yikes, no, this is a really really bad idea. it should read: > PKG_CHECK_MODULES([LIBDRM], [libdrm], > [CPPFLAGS="$CPPFLAGS $LIBDRM_CFLAGS"], [:]) Why [:] ? Wouldn't [] suffice? -- ldv [-- Attachment #1.2: Type: application/pgp-signature, Size: 181 bytes --] [-- Attachment #2: Type: text/plain, Size: 159 bytes --] _______________________________________________ Intel-gfx mailing list Intel-gfx@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/intel-gfx ^ permalink raw reply [flat|nested] 22+ messages in thread
[parent not found: <20150723104417.GA21575-u2l5PoMzF/Vg9hUCZPvPmw@public.gmane.org>]
* Re: [PATCH v3 1/5] drm: Add config for detecting libdrm [not found] ` <20150723104417.GA21575-u2l5PoMzF/Vg9hUCZPvPmw@public.gmane.org> @ 2015-07-23 11:02 ` Mike Frysinger 0 siblings, 0 replies; 22+ messages in thread From: Mike Frysinger @ 2015-07-23 11:02 UTC (permalink / raw) To: strace development list, gabriel-tU7rkvAWjlwhT4uAktR2oQ, intel-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW [-- Attachment #1.1: Type: text/plain, Size: 1558 bytes --] On 23 Jul 2015 13:44, Dmitry V. Levin wrote: > On Thu, Jul 23, 2015 at 05:48:21AM -0400, Mike Frysinger wrote: > > On 01 Jul 2015 14:52, Patrik Jakobsson wrote: > > > Use pkg-config to try to find libdrm. If that fails use the standard > > > include directory for kernel drm headers in /usr/include/drm. > > > > > > * configure.ac: Use pkg-config to find libdrm > > > > > > Signed-off-by: Patrik Jakobsson <patrik.jakobsson-VuQAYsv1563Yd54FQh9/CA@public.gmane.org> > > > --- > > > configure.ac | 4 ++++ > > > 1 file changed, 4 insertions(+) > > > > > > diff --git a/configure.ac b/configure.ac > > > index bb8bf46..aa63af7 100644 > > > --- a/configure.ac > > > +++ b/configure.ac > > > @@ -844,6 +844,10 @@ fi > > > AM_CONDITIONAL([USE_LIBUNWIND], [test "x$use_libunwind" = xyes]) > > > AC_MSG_RESULT([$use_libunwind]) > > > > > > +PKG_CHECK_MODULES([libdrm], [libdrm], > > > + [CPPFLAGS="$CPPFLAGS $libdrm_CFLAGS"], > > > + [CPPFLAGS="$CPPFLAGS -I/usr/include/drm"]) > > > > yikes, no, this is a really really bad idea. it should read: > > PKG_CHECK_MODULES([LIBDRM], [libdrm], > > [CPPFLAGS="$CPPFLAGS $LIBDRM_CFLAGS"], [:]) > > Why [:] ? Wouldn't [] suffice? probably ... force of habit after being bitten by m4 macros that did not expect to expand empty code and thus lead to shell errors (include macros by autotools projects). i.e. if the m4 looked something like: if ...check if pkg is available...; then $3 else $4 fi then the generated configure script would have syntax errors. -mike [-- Attachment #1.2: Digital signature --] [-- Type: application/pgp-signature, Size: 819 bytes --] [-- Attachment #2: Type: text/plain, Size: 79 bytes --] ------------------------------------------------------------------------------ [-- Attachment #3: Type: text/plain, Size: 195 bytes --] _______________________________________________ Strace-devel mailing list Strace-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org https://lists.sourceforge.net/lists/listinfo/strace-devel ^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [PATCH v3 1/5] drm: Add config for detecting libdrm 2015-07-23 9:48 ` Mike Frysinger 2015-07-23 10:44 ` Dmitry V. Levin @ 2015-07-30 13:30 ` Patrik Jakobsson 2015-07-30 14:04 ` Mike Frysinger 1 sibling, 1 reply; 22+ messages in thread From: Patrik Jakobsson @ 2015-07-30 13:30 UTC (permalink / raw) To: strace development list, ldv, gabriel, intel-gfx On Thu, Jul 23, 2015 at 05:48:21AM -0400, Mike Frysinger wrote: > On 01 Jul 2015 14:52, Patrik Jakobsson wrote: > > Use pkg-config to try to find libdrm. If that fails use the standard > > include directory for kernel drm headers in /usr/include/drm. > > > > * configure.ac: Use pkg-config to find libdrm > > > > Signed-off-by: Patrik Jakobsson <patrik.jakobsson@linux.intel.com> > > --- > > configure.ac | 4 ++++ > > 1 file changed, 4 insertions(+) > > > > diff --git a/configure.ac b/configure.ac > > index bb8bf46..aa63af7 100644 > > --- a/configure.ac > > +++ b/configure.ac > > @@ -844,6 +844,10 @@ fi > > AM_CONDITIONAL([USE_LIBUNWIND], [test "x$use_libunwind" = xyes]) > > AC_MSG_RESULT([$use_libunwind]) > > > > +PKG_CHECK_MODULES([libdrm], [libdrm], > > + [CPPFLAGS="$CPPFLAGS $libdrm_CFLAGS"], > > + [CPPFLAGS="$CPPFLAGS -I/usr/include/drm"]) > > yikes, no, this is a really really bad idea. it should read: > PKG_CHECK_MODULES([LIBDRM], [libdrm], > [CPPFLAGS="$CPPFLAGS $LIBDRM_CFLAGS"], [:]) > -mike Hi Mike Please include me in CC. I take it you don't want me to fallback on kernel headers and skip compiling with drm support if libdrm is not available? Cheers Patrik _______________________________________________ Intel-gfx mailing list Intel-gfx@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/intel-gfx ^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [PATCH v3 1/5] drm: Add config for detecting libdrm 2015-07-30 13:30 ` Patrik Jakobsson @ 2015-07-30 14:04 ` Mike Frysinger 2015-07-31 9:09 ` Patrik Jakobsson 0 siblings, 1 reply; 22+ messages in thread From: Mike Frysinger @ 2015-07-30 14:04 UTC (permalink / raw) To: strace development list, ldv, gabriel, intel-gfx [-- Attachment #1.1: Type: text/plain, Size: 1456 bytes --] On 30 Jul 2015 15:30, Patrik Jakobsson wrote: > On Thu, Jul 23, 2015 at 05:48:21AM -0400, Mike Frysinger wrote: > > On 01 Jul 2015 14:52, Patrik Jakobsson wrote: > > > Use pkg-config to try to find libdrm. If that fails use the standard > > > include directory for kernel drm headers in /usr/include/drm. > > > > > > * configure.ac: Use pkg-config to find libdrm > > > > > > Signed-off-by: Patrik Jakobsson <patrik.jakobsson@linux.intel.com> > > > --- > > > configure.ac | 4 ++++ > > > 1 file changed, 4 insertions(+) > > > > > > diff --git a/configure.ac b/configure.ac > > > index bb8bf46..aa63af7 100644 > > > --- a/configure.ac > > > +++ b/configure.ac > > > @@ -844,6 +844,10 @@ fi > > > AM_CONDITIONAL([USE_LIBUNWIND], [test "x$use_libunwind" = xyes]) > > > AC_MSG_RESULT([$use_libunwind]) > > > > > > +PKG_CHECK_MODULES([libdrm], [libdrm], > > > + [CPPFLAGS="$CPPFLAGS $libdrm_CFLAGS"], > > > + [CPPFLAGS="$CPPFLAGS -I/usr/include/drm"]) > > > > yikes, no, this is a really really bad idea. it should read: > > PKG_CHECK_MODULES([LIBDRM], [libdrm], > > [CPPFLAGS="$CPPFLAGS $LIBDRM_CFLAGS"], [:]) > > I take it you don't want me to fallback on kernel headers and skip > compiling with drm support if libdrm is not available? you cannot hardcode any path at all. if the kernel headers provide all of the defines/structs that you need, then just include them directly via #include <drm/xxx.h>. -mike [-- Attachment #1.2: Digital signature --] [-- Type: application/pgp-signature, Size: 819 bytes --] [-- Attachment #2: Type: text/plain, Size: 159 bytes --] _______________________________________________ Intel-gfx mailing list Intel-gfx@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/intel-gfx ^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [PATCH v3 1/5] drm: Add config for detecting libdrm 2015-07-30 14:04 ` Mike Frysinger @ 2015-07-31 9:09 ` Patrik Jakobsson 2015-08-01 18:22 ` Dmitry V. Levin 0 siblings, 1 reply; 22+ messages in thread From: Patrik Jakobsson @ 2015-07-31 9:09 UTC (permalink / raw) To: strace development list, ldv, gabriel, intel-gfx, vapier On Thu, Jul 30, 2015 at 10:04:49AM -0400, Mike Frysinger wrote: > On 30 Jul 2015 15:30, Patrik Jakobsson wrote: > > On Thu, Jul 23, 2015 at 05:48:21AM -0400, Mike Frysinger wrote: > > > On 01 Jul 2015 14:52, Patrik Jakobsson wrote: > > > > Use pkg-config to try to find libdrm. If that fails use the standard > > > > include directory for kernel drm headers in /usr/include/drm. > > > > > > > > * configure.ac: Use pkg-config to find libdrm > > > > > > > > Signed-off-by: Patrik Jakobsson <patrik.jakobsson@linux.intel.com> > > > > --- > > > > configure.ac | 4 ++++ > > > > 1 file changed, 4 insertions(+) > > > > > > > > diff --git a/configure.ac b/configure.ac > > > > index bb8bf46..aa63af7 100644 > > > > --- a/configure.ac > > > > +++ b/configure.ac > > > > @@ -844,6 +844,10 @@ fi > > > > AM_CONDITIONAL([USE_LIBUNWIND], [test "x$use_libunwind" = xyes]) > > > > AC_MSG_RESULT([$use_libunwind]) > > > > > > > > +PKG_CHECK_MODULES([libdrm], [libdrm], > > > > + [CPPFLAGS="$CPPFLAGS $libdrm_CFLAGS"], > > > > + [CPPFLAGS="$CPPFLAGS -I/usr/include/drm"]) > > > > > > yikes, no, this is a really really bad idea. it should read: > > > PKG_CHECK_MODULES([LIBDRM], [libdrm], > > > [CPPFLAGS="$CPPFLAGS $LIBDRM_CFLAGS"], [:]) > > > > I take it you don't want me to fallback on kernel headers and skip > > compiling with drm support if libdrm is not available? > > you cannot hardcode any path at all. if the kernel headers provide all > of the defines/structs that you need, then just include them directly > via #include <drm/xxx.h>. > -mike The prefered "drm way" is to always use the libdrm headers and never the kernel headers. I know this is breaking the rules but it's what we got to work with. Some distros give you the kernel version and others the libdrm version. The kernel version is wrong and libdrm patches this up since we're not allowed to break the userspace interface. I think the safest way would be to only compile drm support for strace if libdrm is present and ignore the kernel headers. What do you think? Cheers Patrik _______________________________________________ Intel-gfx mailing list Intel-gfx@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/intel-gfx ^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [PATCH v3 1/5] drm: Add config for detecting libdrm 2015-07-31 9:09 ` Patrik Jakobsson @ 2015-08-01 18:22 ` Dmitry V. Levin 2015-08-02 14:03 ` Patrik Jakobsson 0 siblings, 1 reply; 22+ messages in thread From: Dmitry V. Levin @ 2015-08-01 18:22 UTC (permalink / raw) To: Patrik Jakobsson; +Cc: intel-gfx, strace-devel [-- Attachment #1.1: Type: text/plain, Size: 2965 bytes --] On Fri, Jul 31, 2015 at 11:09:11AM +0200, Patrik Jakobsson wrote: > On Thu, Jul 30, 2015 at 10:04:49AM -0400, Mike Frysinger wrote: > > On 30 Jul 2015 15:30, Patrik Jakobsson wrote: > > > On Thu, Jul 23, 2015 at 05:48:21AM -0400, Mike Frysinger wrote: > > > > On 01 Jul 2015 14:52, Patrik Jakobsson wrote: > > > > > Use pkg-config to try to find libdrm. If that fails use the standard > > > > > include directory for kernel drm headers in /usr/include/drm. > > > > > > > > > > * configure.ac: Use pkg-config to find libdrm > > > > > > > > > > Signed-off-by: Patrik Jakobsson <patrik.jakobsson@linux.intel.com> > > > > > --- > > > > > configure.ac | 4 ++++ > > > > > 1 file changed, 4 insertions(+) > > > > > > > > > > diff --git a/configure.ac b/configure.ac > > > > > index bb8bf46..aa63af7 100644 > > > > > --- a/configure.ac > > > > > +++ b/configure.ac > > > > > @@ -844,6 +844,10 @@ fi > > > > > AM_CONDITIONAL([USE_LIBUNWIND], [test "x$use_libunwind" = xyes]) > > > > > AC_MSG_RESULT([$use_libunwind]) > > > > > > > > > > +PKG_CHECK_MODULES([libdrm], [libdrm], > > > > > + [CPPFLAGS="$CPPFLAGS $libdrm_CFLAGS"], > > > > > + [CPPFLAGS="$CPPFLAGS -I/usr/include/drm"]) > > > > > > > > yikes, no, this is a really really bad idea. it should read: > > > > PKG_CHECK_MODULES([LIBDRM], [libdrm], > > > > [CPPFLAGS="$CPPFLAGS $LIBDRM_CFLAGS"], [:]) > > > > > > I take it you don't want me to fallback on kernel headers and skip > > > compiling with drm support if libdrm is not available? > > > > you cannot hardcode any path at all. if the kernel headers provide all > > of the defines/structs that you need, then just include them directly > > via #include <drm/xxx.h>. > > -mike > > The prefered "drm way" is to always use the libdrm headers and never the kernel > headers. I know this is breaking the rules but it's what we got to work with. > Some distros give you the kernel version and others the libdrm version. The > kernel version is wrong and libdrm patches this up since we're not allowed to > break the userspace interface. I think the safest way would be to only compile > drm support for strace if libdrm is present and ignore the kernel headers. Unlike most of userspace, strace attempts to show the picture as it's seen from the kernel perspective. Sometimes it forces us to use kernel headers instead of headers provided by libc and other libraries. If kernel itself uses uapi/drm, it should be safe for strace to use it as well. I suppose the check could be written this way: PKG_CHECK_MODULES([LIBDRM], [libdrm], [CPPFLAGS="$CPPFLAGS $LIBDRM_CFLAGS" AC_CHECK_HEADERS([drm.h i915_drm.h])], [AC_CHECK_HEADERS([drm/drm.h drm/i915_drm.h])]) ... #if defined HAVE_DRM_H || defined HAVE_DRM_DRM_H # ifdef HAVE_DRM_H # include <drm.h> # else # include <drm/drm.h> # endif [rest of drm.c] #endif /* HAVE_DRM_H || HAVE_DRM_DRM_H */ -- ldv [-- Attachment #1.2: Type: application/pgp-signature, Size: 181 bytes --] [-- Attachment #2: Type: text/plain, Size: 159 bytes --] _______________________________________________ Intel-gfx mailing list Intel-gfx@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/intel-gfx ^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [PATCH v3 1/5] drm: Add config for detecting libdrm 2015-08-01 18:22 ` Dmitry V. Levin @ 2015-08-02 14:03 ` Patrik Jakobsson 0 siblings, 0 replies; 22+ messages in thread From: Patrik Jakobsson @ 2015-08-02 14:03 UTC (permalink / raw) To: Patrik Jakobsson, gabriel, strace-devel, Intel Graphics Development On Sat, Aug 1, 2015 at 8:22 PM, Dmitry V. Levin <ldv@altlinux.org> wrote: > On Fri, Jul 31, 2015 at 11:09:11AM +0200, Patrik Jakobsson wrote: >> On Thu, Jul 30, 2015 at 10:04:49AM -0400, Mike Frysinger wrote: >> > On 30 Jul 2015 15:30, Patrik Jakobsson wrote: >> > > On Thu, Jul 23, 2015 at 05:48:21AM -0400, Mike Frysinger wrote: >> > > > On 01 Jul 2015 14:52, Patrik Jakobsson wrote: >> > > > > Use pkg-config to try to find libdrm. If that fails use the standard >> > > > > include directory for kernel drm headers in /usr/include/drm. >> > > > > >> > > > > * configure.ac: Use pkg-config to find libdrm >> > > > > >> > > > > Signed-off-by: Patrik Jakobsson <patrik.jakobsson@linux.intel.com> >> > > > > --- >> > > > > configure.ac | 4 ++++ >> > > > > 1 file changed, 4 insertions(+) >> > > > > >> > > > > diff --git a/configure.ac b/configure.ac >> > > > > index bb8bf46..aa63af7 100644 >> > > > > --- a/configure.ac >> > > > > +++ b/configure.ac >> > > > > @@ -844,6 +844,10 @@ fi >> > > > > AM_CONDITIONAL([USE_LIBUNWIND], [test "x$use_libunwind" = xyes]) >> > > > > AC_MSG_RESULT([$use_libunwind]) >> > > > > >> > > > > +PKG_CHECK_MODULES([libdrm], [libdrm], >> > > > > + [CPPFLAGS="$CPPFLAGS $libdrm_CFLAGS"], >> > > > > + [CPPFLAGS="$CPPFLAGS -I/usr/include/drm"]) >> > > > >> > > > yikes, no, this is a really really bad idea. it should read: >> > > > PKG_CHECK_MODULES([LIBDRM], [libdrm], >> > > > [CPPFLAGS="$CPPFLAGS $LIBDRM_CFLAGS"], [:]) >> > > >> > > I take it you don't want me to fallback on kernel headers and skip >> > > compiling with drm support if libdrm is not available? >> > >> > you cannot hardcode any path at all. if the kernel headers provide all >> > of the defines/structs that you need, then just include them directly >> > via #include <drm/xxx.h>. >> > -mike >> >> The prefered "drm way" is to always use the libdrm headers and never the kernel >> headers. I know this is breaking the rules but it's what we got to work with. >> Some distros give you the kernel version and others the libdrm version. The >> kernel version is wrong and libdrm patches this up since we're not allowed to >> break the userspace interface. I think the safest way would be to only compile >> drm support for strace if libdrm is present and ignore the kernel headers. > > Unlike most of userspace, strace attempts to show the picture as it's seen > from the kernel perspective. Sometimes it forces us to use kernel headers > instead of headers provided by libc and other libraries. > > If kernel itself uses uapi/drm, it should be safe for strace to use it > as well. I suppose the check could be written this way: > > PKG_CHECK_MODULES([LIBDRM], [libdrm], > [CPPFLAGS="$CPPFLAGS $LIBDRM_CFLAGS" > AC_CHECK_HEADERS([drm.h i915_drm.h])], > [AC_CHECK_HEADERS([drm/drm.h drm/i915_drm.h])]) > ... > > #if defined HAVE_DRM_H || defined HAVE_DRM_DRM_H > > # ifdef HAVE_DRM_H > # include <drm.h> > # else > # include <drm/drm.h> > # endif > > [rest of drm.c] > > #endif /* HAVE_DRM_H || HAVE_DRM_DRM_H */ That would be even better. We'll get some warnings when including the kernel version of drm.h but I guess we can live with that. Will soon send out a new version of the patches. Thanks Patrik > > > -- > ldv > > _______________________________________________ > Intel-gfx mailing list > Intel-gfx@lists.freedesktop.org > http://lists.freedesktop.org/mailman/listinfo/intel-gfx > _______________________________________________ Intel-gfx mailing list Intel-gfx@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/intel-gfx ^ permalink raw reply [flat|nested] 22+ messages in thread
* [PATCH v3 2/5] drm: Add private data field to trace control block [not found] ` <1435755168-16207-1-git-send-email-patrik.jakobsson-VuQAYsv1563Yd54FQh9/CA@public.gmane.org> 2015-07-01 12:52 ` [PATCH v3 1/5] drm: Add config for detecting libdrm Patrik Jakobsson @ 2015-07-01 12:52 ` Patrik Jakobsson 2015-07-03 0:33 ` Dmitry V. Levin 2015-07-01 12:52 ` [PATCH v3 3/5] drm: Add dispatcher and driver identification for DRM Patrik Jakobsson 2 siblings, 1 reply; 22+ messages in thread From: Patrik Jakobsson @ 2015-07-01 12:52 UTC (permalink / raw) To: strace-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f, ldv-u2l5PoMzF/Vg9hUCZPvPmw, gabriel-tU7rkvAWjlwhT4uAktR2oQ Cc: intel-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW This field can be used by the decode functions of a syscall. The main usecase for now is to allow storing the driver name for drm devices across the lifetime of a trace control block. This allows us to do the driver identification once and reuse the information in all the decode stages of the ioctl. * defs.h: Add private data field in struct tcb Signed-off-by: Patrik Jakobsson <patrik.jakobsson-VuQAYsv1563Yd54FQh9/CA@public.gmane.org> --- defs.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/defs.h b/defs.h index c02f810..5b0670e 100644 --- a/defs.h +++ b/defs.h @@ -266,6 +266,13 @@ struct tcb { int u_error; /* Error code */ long scno; /* System call number */ long u_arg[MAX_ARGS]; /* System call arguments */ + + /* + * Private data for the decoding functions of the syscall. TCB core does + * _not_ handle allocation / deallocation of this data. + */ + void *priv_data; + #if defined(LINUX_MIPSN32) || defined(X32) long long ext_arg[MAX_ARGS]; long long u_lrval; /* long long return value */ -- 2.1.4 ------------------------------------------------------------------------------ Don't Limit Your Business. Reach for the Cloud. GigeNET's Cloud Solutions provide you with the tools and support that you need to offload your IT needs and focus on growing your business. Configured For All Businesses. Start Your Cloud Today. https://www.gigenetcloud.com/ ^ permalink raw reply related [flat|nested] 22+ messages in thread
* Re: [PATCH v3 2/5] drm: Add private data field to trace control block 2015-07-01 12:52 ` [PATCH v3 2/5] drm: Add private data field to trace control block Patrik Jakobsson @ 2015-07-03 0:33 ` Dmitry V. Levin 2015-07-06 8:09 ` Patrik Jakobsson 0 siblings, 1 reply; 22+ messages in thread From: Dmitry V. Levin @ 2015-07-03 0:33 UTC (permalink / raw) To: Patrik Jakobsson; +Cc: intel-gfx, strace-devel [-- Attachment #1.1: Type: text/plain, Size: 5062 bytes --] On Wed, Jul 01, 2015 at 02:52:45PM +0200, Patrik Jakobsson wrote: [...] > --- a/defs.h > +++ b/defs.h > @@ -266,6 +266,13 @@ struct tcb { > int u_error; /* Error code */ > long scno; /* System call number */ > long u_arg[MAX_ARGS]; /* System call arguments */ > + > + /* > + * Private data for the decoding functions of the syscall. TCB core does > + * _not_ handle allocation / deallocation of this data. > + */ > + void *priv_data; > + This will result to memory leaks if droptcb() is called before the syscall parser that allocated memory had a chance to deallocate it. As this data is no longer relevant after leaving trace_syscall_exiting(), I suggest to perform deallocation directly from trace_syscall_exiting. This API could be made more flexible by adding another pointer - the function to be called to deallocate memory, e.g. struct tcb { ... void *priv_data; void (*free_priv_data)(void *); ... }; ... void free_priv_data(struct tcb *tcp) { if (tcp->priv_data) { if (tcp->free_priv_data) { tcp->free_priv_data(tcp->priv_data); tcp->free_priv_data = NULL; } tcp->priv_data = NULL; } } ... droptcb(struct tcb *tcp) { ... free_priv_data(tcp); ... } ... trace_syscall_exiting(struct tcb *tcp) { ... ret: free_priv_data(tcp); ... } [...] On Wed, Jul 01, 2015 at 02:52:46PM +0200, Patrik Jakobsson wrote: > * Makefile.am: Add compilation of drm.c > * defs.h: Declarations of drm functions > * drm.c: Utility functions for drm driver detection > * io.c: Dispatch drm ioctls > * ioctl.c: Distpatch generic and driver specific ioctls This is not quite a GNU style changelog entry. Please have a look at http://www.gnu.org/prep/standards/html_node/Style-of-Change-Logs.html and examples in strace.git history. [...] > +#include "defs.h" > + > +#include <drm.h> > +#include <linux/limits.h> Please include <sys/param.h> instead of <linux/limits.h>. > +#define DRM_MAX_NAME_LEN 128 > + > +struct drm_ioctl_priv { > + char name[DRM_MAX_NAME_LEN]; > +}; > + > +inline int drm_is_priv(const unsigned int num) > +{ > + return (_IOC_NR(num) >= DRM_COMMAND_BASE && > + _IOC_NR(num) < DRM_COMMAND_END); > +} > + > +static int drm_get_driver_name(struct tcb *tcp, char *name, size_t bufsize) > +{ > + char path[PATH_MAX]; > + char link[PATH_MAX]; > + int ret; > + > + ret = getfdpath(tcp, tcp->u_arg[0], path, PATH_MAX - 1); > + if (ret < 0) > + return ret; > + > + snprintf(link, PATH_MAX, "/sys/class/drm/%s/device/driver", > + basename(path)); > + > + ret = readlink(link, path, PATH_MAX - 1); > + if (ret < 0) > + return ret; > + > + path[ret] = '\0'; > + strncpy(name, basename(path), bufsize); > + > + return 0; > +} I think this is getting too complicated. This function could just return strdup(basename(path)) or NULL in case of any error: static char * drm_get_driver_name(struct tcb *tcp, const char *name) { char path[PATH_MAX]; char link[PATH_MAX]; int ret; if (getfdpath(tcp, tcp->u_arg[0], path, PATH_MAX - 1) < 0) return NULL; if (snprintf(link, PATH_MAX, "/sys/class/drm/%s/device/driver", basename(path)) >= PATH_MAX) return NULL; ret = readlink(link, path, PATH_MAX - 1); if (ret < 0) return NULL; path[ret] = '\0'; return strdup(basename(path)); } > + > +int drm_is_driver(struct tcb *tcp, const char *name) > +{ > + struct drm_ioctl_priv *priv; > + int ret; > + > + /* > + * If no private data is allocated we are detecting the driver name for > + * the first time and must resolve it. > + */ > + if (tcp->priv_data == NULL) { > + tcp->priv_data = xcalloc(1, sizeof(struct drm_ioctl_priv)); xcalloc shouldn't be used if a potential memory allocation error is not fatal. In a parser that performs verbose syscall decoding no memory allocation error is fatal. > + priv = tcp->priv_data; > + > + ret = drm_get_driver_name(tcp, priv->name, DRM_MAX_NAME_LEN); > + if (ret) > + return 0; > + } > + > + priv = tcp->priv_data; > + > + return strncmp(name, priv->name, DRM_MAX_NAME_LEN) == 0; Then with priv_data+free_priv_data interface this would looks smth like ... if (!tcp->priv_data) { tcp->priv_data = drm_get_driver_name(tcp, name); if (tcp->priv_data) { tcp->free_priv_data = free; } else { tcp->priv_data = (void *) ""; tcp->free_priv_data = NULL; } } return !strcmp(name, (char *) tcp->priv_data); > +} > + > +int drm_decode_number(struct tcb *tcp, unsigned int arg) This is an ioctl request code, let's consistently call it "code" to distinguish from its argument. [...] > --- a/ioctl.c > +++ b/ioctl.c > @@ -182,7 +182,7 @@ hiddev_decode_number(unsigned int arg) > } > > int > -ioctl_decode_command_number(unsigned int arg) > +ioctl_decode_command_number(struct tcb *tcp, unsigned int arg) I've already changed ioctl_decode_command_number's signature: struct tcb * is already there and "arg" is now called "code". -- ldv [-- Attachment #1.2: Type: application/pgp-signature, Size: 181 bytes --] [-- Attachment #2: Type: text/plain, Size: 159 bytes --] _______________________________________________ Intel-gfx mailing list Intel-gfx@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/intel-gfx ^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [PATCH v3 2/5] drm: Add private data field to trace control block 2015-07-03 0:33 ` Dmitry V. Levin @ 2015-07-06 8:09 ` Patrik Jakobsson 0 siblings, 0 replies; 22+ messages in thread From: Patrik Jakobsson @ 2015-07-06 8:09 UTC (permalink / raw) To: strace-devel, gabriel, intel-gfx, ldv On Fri, Jul 03, 2015 at 03:33:31AM +0300, Dmitry V. Levin wrote: > On Wed, Jul 01, 2015 at 02:52:45PM +0200, Patrik Jakobsson wrote: > [...] > > --- a/defs.h > > +++ b/defs.h > > @@ -266,6 +266,13 @@ struct tcb { > > int u_error; /* Error code */ > > long scno; /* System call number */ > > long u_arg[MAX_ARGS]; /* System call arguments */ > > + > > + /* > > + * Private data for the decoding functions of the syscall. TCB core does > > + * _not_ handle allocation / deallocation of this data. > > + */ > > + void *priv_data; > > + > > This will result to memory leaks if droptcb() is called before the > syscall parser that allocated memory had a chance to deallocate it. > As this data is no longer relevant after leaving trace_syscall_exiting(), > I suggest to perform deallocation directly from trace_syscall_exiting. > > This API could be made more flexible by adding another pointer - > the function to be called to deallocate memory, e.g. > struct tcb { > ... > void *priv_data; > void (*free_priv_data)(void *); > ... > }; > ... > void > free_priv_data(struct tcb *tcp) > { > if (tcp->priv_data) { > if (tcp->free_priv_data) { > tcp->free_priv_data(tcp->priv_data); > tcp->free_priv_data = NULL; > } > tcp->priv_data = NULL; > } > } > ... > droptcb(struct tcb *tcp) > { > ... > free_priv_data(tcp); > ... > } > ... > trace_syscall_exiting(struct tcb *tcp) > { > ... > ret: > free_priv_data(tcp); > ... > } > > [...] > On Wed, Jul 01, 2015 at 02:52:46PM +0200, Patrik Jakobsson wrote: Yes, that's more robust. I was afraid it would be too intrusive. > > * Makefile.am: Add compilation of drm.c > > * defs.h: Declarations of drm functions > > * drm.c: Utility functions for drm driver detection > > * io.c: Dispatch drm ioctls > > * ioctl.c: Distpatch generic and driver specific ioctls > > This is not quite a GNU style changelog entry. Please have a look at > http://www.gnu.org/prep/standards/html_node/Style-of-Change-Logs.html > and examples in strace.git history. > > [...] I'll get that sorted out. > > +#include "defs.h" > > + > > +#include <drm.h> > > +#include <linux/limits.h> > > Please include <sys/param.h> instead of <linux/limits.h>. Yup > > +#define DRM_MAX_NAME_LEN 128 > > + > > +struct drm_ioctl_priv { > > + char name[DRM_MAX_NAME_LEN]; > > +}; > > + > > +inline int drm_is_priv(const unsigned int num) > > +{ > > + return (_IOC_NR(num) >= DRM_COMMAND_BASE && > > + _IOC_NR(num) < DRM_COMMAND_END); > > +} > > + > > +static int drm_get_driver_name(struct tcb *tcp, char *name, size_t bufsize) > > +{ > > + char path[PATH_MAX]; > > + char link[PATH_MAX]; > > + int ret; > > + > > + ret = getfdpath(tcp, tcp->u_arg[0], path, PATH_MAX - 1); > > + if (ret < 0) > > + return ret; > > + > > + snprintf(link, PATH_MAX, "/sys/class/drm/%s/device/driver", > > + basename(path)); > > + > > + ret = readlink(link, path, PATH_MAX - 1); > > + if (ret < 0) > > + return ret; > > + > > + path[ret] = '\0'; > > + strncpy(name, basename(path), bufsize); > > + > > + return 0; > > +} > > I think this is getting too complicated. This function could just return > strdup(basename(path)) or NULL in case of any error: > > static char * > drm_get_driver_name(struct tcb *tcp, const char *name) > { > char path[PATH_MAX]; > char link[PATH_MAX]; > int ret; > > if (getfdpath(tcp, tcp->u_arg[0], path, PATH_MAX - 1) < 0) > return NULL; > > if (snprintf(link, PATH_MAX, "/sys/class/drm/%s/device/driver", > basename(path)) >= PATH_MAX) > return NULL; > > ret = readlink(link, path, PATH_MAX - 1); > if (ret < 0) > return NULL; > > path[ret] = '\0'; > return strdup(basename(path)); > } > That's nicer > > + > > +int drm_is_driver(struct tcb *tcp, const char *name) > > +{ > > + struct drm_ioctl_priv *priv; > > + int ret; > > + > > + /* > > + * If no private data is allocated we are detecting the driver name for > > + * the first time and must resolve it. > > + */ > > + if (tcp->priv_data == NULL) { > > + tcp->priv_data = xcalloc(1, sizeof(struct drm_ioctl_priv)); > > xcalloc shouldn't be used if a potential memory allocation error is not > fatal. In a parser that performs verbose syscall decoding no memory > allocation error is fatal. Ok > > + priv = tcp->priv_data; > > + > > + ret = drm_get_driver_name(tcp, priv->name, DRM_MAX_NAME_LEN); > > + if (ret) > > + return 0; > > + } > > + > > + priv = tcp->priv_data; > > + > > + return strncmp(name, priv->name, DRM_MAX_NAME_LEN) == 0; > > Then with priv_data+free_priv_data interface this would looks smth like > ... > if (!tcp->priv_data) { > tcp->priv_data = drm_get_driver_name(tcp, name); > if (tcp->priv_data) { > tcp->free_priv_data = free; > } else { > tcp->priv_data = (void *) ""; > tcp->free_priv_data = NULL; > } > } > return !strcmp(name, (char *) tcp->priv_data); > > > +} > > + > > +int drm_decode_number(struct tcb *tcp, unsigned int arg) > > This is an ioctl request code, let's consistently call it "code" to > distinguish from its argument. > > [...] > > --- a/ioctl.c > > +++ b/ioctl.c > > @@ -182,7 +182,7 @@ hiddev_decode_number(unsigned int arg) > > } > > > > int > > -ioctl_decode_command_number(unsigned int arg) > > +ioctl_decode_command_number(struct tcb *tcp, unsigned int arg) > > I've already changed ioctl_decode_command_number's signature: > struct tcb * is already there and "arg" is now called "code". > > > -- > ldv _______________________________________________ Intel-gfx mailing list Intel-gfx@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/intel-gfx ^ permalink raw reply [flat|nested] 22+ messages in thread
* [PATCH v3 3/5] drm: Add dispatcher and driver identification for DRM [not found] ` <1435755168-16207-1-git-send-email-patrik.jakobsson-VuQAYsv1563Yd54FQh9/CA@public.gmane.org> 2015-07-01 12:52 ` [PATCH v3 1/5] drm: Add config for detecting libdrm Patrik Jakobsson 2015-07-01 12:52 ` [PATCH v3 2/5] drm: Add private data field to trace control block Patrik Jakobsson @ 2015-07-01 12:52 ` Patrik Jakobsson 2 siblings, 0 replies; 22+ messages in thread From: Patrik Jakobsson @ 2015-07-01 12:52 UTC (permalink / raw) To: strace-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f, ldv-u2l5PoMzF/Vg9hUCZPvPmw, gabriel-tU7rkvAWjlwhT4uAktR2oQ Cc: intel-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW * Makefile.am: Add compilation of drm.c * defs.h: Declarations of drm functions * drm.c: Utility functions for drm driver detection * io.c: Dispatch drm ioctls * ioctl.c: Distpatch generic and driver specific ioctls Signed-off-by: Patrik Jakobsson <patrik.jakobsson-VuQAYsv1563Yd54FQh9/CA@public.gmane.org> --- Makefile.am | 1 + defs.h | 4 ++- drm.c | 108 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ io.c | 2 +- ioctl.c | 6 +++- 5 files changed, 118 insertions(+), 3 deletions(-) create mode 100644 drm.c diff --git a/Makefile.am b/Makefile.am index e2a0f74..99382bd 100644 --- a/Makefile.am +++ b/Makefile.am @@ -41,6 +41,7 @@ strace_SOURCES = \ count.c \ desc.c \ dirent.c \ + drm.c \ evdev.c \ execve.c \ exit.c \ diff --git a/defs.h b/defs.h index 5b0670e..63e4585 100644 --- a/defs.h +++ b/defs.h @@ -573,8 +573,10 @@ extern const struct_ioctlent *ioctl_lookup(const unsigned int); extern const struct_ioctlent *ioctl_next_match(const struct_ioctlent *); extern void ioctl_print_code(const unsigned int); extern int ioctl_decode(struct tcb *, const unsigned int, long); -extern int ioctl_decode_command_number(const unsigned int); +extern int ioctl_decode_command_number(struct tcb *, const unsigned int); extern int block_ioctl(struct tcb *, const unsigned int, long); +extern int drm_decode_number(struct tcb *tcp, unsigned int arg); +extern int drm_ioctl(struct tcb *, const unsigned int, long); extern int evdev_ioctl(struct tcb *, const unsigned int, long); extern int loop_ioctl(struct tcb *, const unsigned int, long); extern int mtd_ioctl(struct tcb *, const unsigned int, long); diff --git a/drm.c b/drm.c new file mode 100644 index 0000000..61df09f --- /dev/null +++ b/drm.c @@ -0,0 +1,108 @@ +/* + * Copyright (c) 2015 Intel Corporation + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * Authors: + * Patrik Jakobsson <patrik.jakobsson-VuQAYsv1563Yd54FQh9/CA@public.gmane.org> + */ + +#include "defs.h" + +#include <drm.h> +#include <linux/limits.h> + +#define DRM_MAX_NAME_LEN 128 + +struct drm_ioctl_priv { + char name[DRM_MAX_NAME_LEN]; +}; + +inline int drm_is_priv(const unsigned int num) +{ + return (_IOC_NR(num) >= DRM_COMMAND_BASE && + _IOC_NR(num) < DRM_COMMAND_END); +} + +static int drm_get_driver_name(struct tcb *tcp, char *name, size_t bufsize) +{ + char path[PATH_MAX]; + char link[PATH_MAX]; + int ret; + + ret = getfdpath(tcp, tcp->u_arg[0], path, PATH_MAX - 1); + if (ret < 0) + return ret; + + snprintf(link, PATH_MAX, "/sys/class/drm/%s/device/driver", + basename(path)); + + ret = readlink(link, path, PATH_MAX - 1); + if (ret < 0) + return ret; + + path[ret] = '\0'; + strncpy(name, basename(path), bufsize); + + return 0; +} + +int drm_is_driver(struct tcb *tcp, const char *name) +{ + struct drm_ioctl_priv *priv; + int ret; + + /* + * If no private data is allocated we are detecting the driver name for + * the first time and must resolve it. + */ + if (tcp->priv_data == NULL) { + tcp->priv_data = xcalloc(1, sizeof(struct drm_ioctl_priv)); + priv = tcp->priv_data; + + ret = drm_get_driver_name(tcp, priv->name, DRM_MAX_NAME_LEN); + if (ret) + return 0; + } + + priv = tcp->priv_data; + + return strncmp(name, priv->name, DRM_MAX_NAME_LEN) == 0; +} + +int drm_decode_number(struct tcb *tcp, unsigned int arg) +{ + return 0; +} + +int drm_ioctl(struct tcb *tcp, const unsigned int code, long arg) +{ + /* Free any allocated private data */ + if (exiting(tcp) && tcp->priv_data != NULL) { + free(tcp->priv_data); + tcp->priv_data = NULL; + } + + return 0; +} diff --git a/io.c b/io.c index 30ed578..6810a45 100644 --- a/io.c +++ b/io.c @@ -391,7 +391,7 @@ SYS_FUNC(ioctl) if (entering(tcp)) { printfd(tcp, tcp->u_arg[0]); tprints(", "); - if (!ioctl_decode_command_number(tcp->u_arg[1])) { + if (!ioctl_decode_command_number(tcp, tcp->u_arg[1])) { iop = ioctl_lookup(tcp->u_arg[1]); if (iop) { tprints(iop->symbol); diff --git a/ioctl.c b/ioctl.c index c67d048..0b3dd3f 100644 --- a/ioctl.c +++ b/ioctl.c @@ -182,7 +182,7 @@ hiddev_decode_number(unsigned int arg) } int -ioctl_decode_command_number(unsigned int arg) +ioctl_decode_command_number(struct tcb *tcp, unsigned int arg) { switch (_IOC_TYPE(arg)) { case 'E': @@ -204,6 +204,8 @@ ioctl_decode_command_number(unsigned int arg) return 1; } return 0; + case 'd': + return drm_decode_number(tcp, arg); case 'j': if (_IOC_DIR(arg) == _IOC_READ && _IOC_NR(arg) == 0x13) { tprintf("JSIOCGNAME(%u)", _IOC_SIZE(arg)); @@ -243,6 +245,8 @@ ioctl_decode(struct tcb *tcp, unsigned int code, long arg) case 0x22: return scsi_ioctl(tcp, code, arg); #endif + case 'd': + return drm_ioctl(tcp, code, arg); case 'L': return loop_ioctl(tcp, code, arg); case 'M': -- 2.1.4 ------------------------------------------------------------------------------ Don't Limit Your Business. Reach for the Cloud. GigeNET's Cloud Solutions provide you with the tools and support that you need to offload your IT needs and focus on growing your business. Configured For All Businesses. Start Your Cloud Today. https://www.gigenetcloud.com/ ^ permalink raw reply related [flat|nested] 22+ messages in thread
* [PATCH v3 4/5] drm: Add decoding of i915 ioctls 2015-07-01 12:52 [PATCH v3 0/5] drm: Add decoding for DRM/KMS and i915 ioctls Patrik Jakobsson [not found] ` <1435755168-16207-1-git-send-email-patrik.jakobsson-VuQAYsv1563Yd54FQh9/CA@public.gmane.org> @ 2015-07-01 12:52 ` Patrik Jakobsson 2015-07-03 0:36 ` Dmitry V. Levin 2015-07-01 12:52 ` [PATCH v3 5/5] drm: Add decoding of DRM and KMS ioctls Patrik Jakobsson 2 siblings, 1 reply; 22+ messages in thread From: Patrik Jakobsson @ 2015-07-01 12:52 UTC (permalink / raw) To: strace-devel, ldv, gabriel; +Cc: intel-gfx There are more ioctls to add but the ones in this patch are most commonly used. * Makefile.am: Add compilation of drm_i915.c * drm.c: Dispatch i915 ioctls * drm_i915.c: Decode DRM_IOCTL_I915_GETPARAM * drm_i915.c: Decode DRM_IOCTL_I915_SETPARAM * drm_i915.c: Decode DRM_IOCTL_I915_GEM_EXECBUFFER2 * drm_i915.c: Decode DRM_IOCTL_I915_GEM_BUSY * drm_i915.c: Decode DRM_IOCTL_I915_GEM_CREATE * drm_i915.c: Decode DRM_IOCTL_I915_GEM_PREAD * drm_i915.c: Decode DRM_IOCTL_I915_GEM_PWRITE * drm_i915.c: Decode DRM_IOCTL_I915_GEM_MMAP * drm_i915.c: Decode DRM_IOCTL_I915_GEM_MMAP_GTT * drm_i915.c: Decode DRM_IOCTL_I915_SET_DOMAIN * drm_i915.c: Decode DRM_IOCTL_I915_MADVISE * drm_i915.c: Decode DRM_IOCTL_I915_GET_TILING * drm_i915.c: Decode DRM_IOCTL_I915_SET_TILING * drm_i915.c: Decode DRM_IOCTL_I915_USERPTR * xlat/drm_i915_getparams.in: List GETPARAM parameters * xlat/drm_i915_setparams.in: List SETPARAM parameters * xlat/drm_i915_ioctls.in: List i915 ioctls Signed-off-by: Patrik Jakobsson <patrik.jakobsson@linux.intel.com> --- Makefile.am | 1 + drm.c | 18 ++- drm_i915.c | 332 +++++++++++++++++++++++++++++++++++++++++++++ xlat/drm_i915_getparams.in | 28 ++++ xlat/drm_i915_ioctls.in | 51 +++++++ xlat/drm_i915_setparams.in | 4 + 6 files changed, 433 insertions(+), 1 deletion(-) create mode 100644 drm_i915.c create mode 100644 xlat/drm_i915_getparams.in create mode 100644 xlat/drm_i915_ioctls.in create mode 100644 xlat/drm_i915_setparams.in diff --git a/Makefile.am b/Makefile.am index 99382bd..aa27e0c 100644 --- a/Makefile.am +++ b/Makefile.am @@ -42,6 +42,7 @@ strace_SOURCES = \ desc.c \ dirent.c \ drm.c \ + drm_i915.c \ evdev.c \ execve.c \ exit.c \ diff --git a/drm.c b/drm.c index 61df09f..846ea4d 100644 --- a/drm.c +++ b/drm.c @@ -35,6 +35,9 @@ #define DRM_MAX_NAME_LEN 128 +extern int drm_i915_decode_number(struct tcb *tcp, unsigned int arg); +extern int drm_i915_ioctl(struct tcb *tcp, const unsigned int code, long arg); + struct drm_ioctl_priv { char name[DRM_MAX_NAME_LEN]; }; @@ -93,16 +96,29 @@ int drm_is_driver(struct tcb *tcp, const char *name) int drm_decode_number(struct tcb *tcp, unsigned int arg) { + if (drm_is_priv(tcp->u_arg[1])) { + if (verbose(tcp) && drm_is_driver(tcp, "i915")) + return drm_i915_decode_number(tcp, arg); + } + return 0; } int drm_ioctl(struct tcb *tcp, const unsigned int code, long arg) { + int ret = 0; + + /* Check for device specific ioctls */ + if (drm_is_priv(tcp->u_arg[1])) { + if (verbose(tcp) && drm_is_driver(tcp, "i915")) + ret = drm_i915_ioctl(tcp, code, arg); + } + /* Free any allocated private data */ if (exiting(tcp) && tcp->priv_data != NULL) { free(tcp->priv_data); tcp->priv_data = NULL; } - return 0; + return ret; } diff --git a/drm_i915.c b/drm_i915.c new file mode 100644 index 0000000..e4705b6 --- /dev/null +++ b/drm_i915.c @@ -0,0 +1,332 @@ +/* + * Copyright (c) 2015 Intel Corporation + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * Authors: + * Patrik Jakobsson <patrik.jakobsson@linux.intel.com> + */ + +#include "defs.h" + +#include <drm.h> +#include <i915_drm.h> +#include "xlat/drm_i915_ioctls.h" +#include "xlat/drm_i915_getparams.h" +#include "xlat/drm_i915_setparams.h" + +static int i915_getparam(struct tcb *tcp, const unsigned int code, long arg) +{ + struct drm_i915_getparam param; + int value; + + if (umove(tcp, arg, ¶m)) + return 0; + + if (entering(tcp)) { + tprints(", {param="); + printxval(drm_i915_getparams, param.param, "I915_PARAM_???"); + } else if (exiting(tcp)) { + if (umove(tcp, (long)param.value, &value)) + return 0; + + tprints(", value="); + switch (param.param) { + case I915_PARAM_CHIPSET_ID: + tprintf("0x%04x", value); + break; + default: + tprintf("%d", value); + } + tprints("}"); + } + + return 1; +} + +static int i915_setparam(struct tcb *tcp, const unsigned int code, long arg) +{ + struct drm_i915_setparam param; + + if (entering(tcp)) { + if (umove(tcp, arg, ¶m)) + return 0; + + tprints(", {param="); + printxval(drm_i915_setparams, param.param, "I915_PARAM_???"); + tprintf(", value=%d}", param.value); + } + + return 1; +} + +static int i915_gem_execbuffer2(struct tcb *tcp, const unsigned int code, + long arg) +{ + struct drm_i915_gem_execbuffer2 eb; + + if (entering(tcp)) { + if (umove(tcp, arg, &eb)) + return 0; + + tprintf(", {buffers_ptr=%p, buffer_count=%u, " + "batch_start_offset=%x, batch_len=%u, DR1=%u, DR4=%u, " + "num_cliprects=%u, cliprects_ptr=%p, flags=0x%Lx}", + (void *)eb.buffers_ptr, eb.buffer_count, + eb.batch_start_offset, eb.batch_len, eb.DR1, eb.DR4, + eb.num_cliprects, (void *)eb.cliprects_ptr, eb.flags); + } + + return 1; +} + +static int i915_gem_busy(struct tcb *tcp, const unsigned int code, long arg) +{ + struct drm_i915_gem_busy busy; + + if (umove(tcp, arg, &busy)) + return 0; + + if (entering(tcp)) { + tprintf(", {handle=%u", busy.handle); + } else if (exiting(tcp)) { + tprintf(", busy=%c, ring=%u}", + (busy.busy & 0x1) ? 'Y' : 'N', (busy.busy >> 16)); + } + + return 1; +} + +static int i915_gem_create(struct tcb *tcp, const unsigned int code, long arg) +{ + struct drm_i915_gem_create create; + + if (umove(tcp, arg, &create)) + return 0; + + if (entering(tcp)) { + tprintf(", {size=%Lu", create.size); + } else if (exiting(tcp)) { + tprintf(", handle=%u}", create.handle); + } + + return 1; +} + +static int i915_gem_pread(struct tcb *tcp, const unsigned int code, long arg) +{ + struct drm_i915_gem_pread pr; + + + if (entering(tcp)) { + if (umove(tcp, arg, &pr)) + return 0; + + tprintf(", {handle=%u, offset=%Lu, size=%Lu, data_ptr=%p}", + pr.handle, pr.offset, pr.size, (void *)pr.data_ptr); + } + + return 1; +} + +static int i915_gem_pwrite(struct tcb *tcp, const unsigned int code, long arg) +{ + struct drm_i915_gem_pwrite pw; + + if (entering(tcp)) { + if (umove(tcp, arg, &pw)) + return 0; + + tprintf(", {handle=%u, offset=%Lu, size=%Lu, data_ptr=%p}", + pw.handle, pw.offset, pw.size, (void *)pw.data_ptr); + } + + return 1; +} + +static int i915_gem_mmap(struct tcb *tcp, const unsigned int code, long arg) +{ + struct drm_i915_gem_mmap mmap; + + if (umove(tcp, arg, &mmap)) + return 0; + + if (entering(tcp)) { + tprintf(", {handle=%u, size=%Lu", mmap.handle, mmap.size); + } else if (exiting(tcp)) { + tprintf(", offset=%Lu, addr_ptr=%p}", + mmap.offset, (void *)mmap.addr_ptr); + } + + return 1; +} + +static int i915_gem_mmap_gtt(struct tcb *tcp, const unsigned int code, long arg) +{ + struct drm_i915_gem_mmap_gtt mmap; + + if (umove(tcp, arg, &mmap)) + return 0; + + if (entering(tcp)) { + tprintf(", {handle=%u", mmap.handle); + } else if (exiting(tcp)) { + tprintf(", offset=%Lu}", mmap.offset); + } + + return 1; +} + +static int i915_gem_set_domain(struct tcb *tcp, const unsigned int code, + long arg) +{ + struct drm_i915_gem_set_domain dom; + + if (entering(tcp)) { + if (umove(tcp, arg, &dom)) + return 0; + + tprintf(", {handle=%u, read_domains=%x, write_domain=%x}", + dom.handle, dom.read_domains, dom.write_domain); + } + + return 1; +} + +static int i915_gem_madvise(struct tcb *tcp, const unsigned int code, long arg) +{ + struct drm_i915_gem_madvise madv; + + if (umove(tcp, arg, &madv)) + return 0; + + if (entering(tcp)) { + tprintf(", {handle=%u, madv=%u", madv.handle, madv.madv); + } else if (exiting(tcp)) { + tprintf(", retained=%u}", madv.retained); + } + + return 1; +} + +static int i915_gem_get_tiling(struct tcb *tcp, const unsigned int code, + long arg) +{ + struct drm_i915_gem_get_tiling tiling; + + if (umove(tcp, arg, &tiling)) + return 0; + + if (entering(tcp)) { + tprintf(", {handle=%u", tiling.handle); + } else if (exiting(tcp)) { + tprintf(", tiling_mode=%u, swizzle_mode=%u}", tiling.tiling_mode, + tiling.swizzle_mode); + } + + return 1; +} + +static int i915_gem_set_tiling(struct tcb *tcp, const unsigned int code, + long arg) +{ + struct drm_i915_gem_set_tiling tiling; + + if (umove(tcp, arg, &tiling)) + return 0; + + if (entering(tcp)) { + tprintf(", {handle=%u, tiling_mode=%u, stride=%u", + tiling.handle, tiling.tiling_mode, tiling.stride); + } else if (exiting(tcp)) { + tprintf(", swizzle_mode=%u}", tiling.swizzle_mode); + } + + return 1; +} + +static int i915_gem_userptr(struct tcb *tcp, const unsigned int code, long arg) +{ + struct drm_i915_gem_userptr uptr; + + if (umove(tcp, arg, &uptr)) + return 0; + + if (entering(tcp)) { + tprintf(", {user_ptr=%p, user_size=%Lu", (void *)uptr.user_ptr, + uptr.user_size); + } else if (exiting(tcp)) { + tprintf(", flags=0x%x, handle=%u}", uptr.flags, uptr.handle); + } + + return 1; +} + +int drm_i915_decode_number(struct tcb *tcp, unsigned int arg) +{ + const char *str = xlookup(drm_i915_ioctls, arg); + + if (str) { + tprintf("%s", str); + return 1; + } + + return 0; +} + +int drm_i915_ioctl(struct tcb *tcp, const unsigned int code, long arg) +{ + switch (code) { + case DRM_IOCTL_I915_GETPARAM: + return i915_getparam(tcp, code, arg); + case DRM_IOCTL_I915_SETPARAM: + return i915_setparam(tcp, code, arg); + case DRM_IOCTL_I915_GEM_EXECBUFFER2: + return i915_gem_execbuffer2(tcp, code, arg); + case DRM_IOCTL_I915_GEM_BUSY: + return i915_gem_busy(tcp, code, arg); + case DRM_IOCTL_I915_GEM_CREATE: + return i915_gem_create(tcp, code, arg); + case DRM_IOCTL_I915_GEM_PREAD: + return i915_gem_pread(tcp, code, arg); + case DRM_IOCTL_I915_GEM_PWRITE: + return i915_gem_pwrite(tcp, code, arg); + case DRM_IOCTL_I915_GEM_MMAP: + return i915_gem_mmap(tcp, code, arg); + case DRM_IOCTL_I915_GEM_MMAP_GTT: + return i915_gem_mmap_gtt(tcp, code, arg); + case DRM_IOCTL_I915_GEM_SET_DOMAIN: + return i915_gem_set_domain(tcp, code, arg); + case DRM_IOCTL_I915_GEM_MADVISE: + return i915_gem_madvise(tcp, code, arg); + case DRM_IOCTL_I915_GEM_GET_TILING: + return i915_gem_get_tiling(tcp, code, arg); + case DRM_IOCTL_I915_GEM_SET_TILING: + return i915_gem_set_tiling(tcp, code, arg); + case DRM_IOCTL_I915_GEM_USERPTR: + return i915_gem_userptr(tcp, code, arg); + } + + return 0; +} diff --git a/xlat/drm_i915_getparams.in b/xlat/drm_i915_getparams.in new file mode 100644 index 0000000..15275cb --- /dev/null +++ b/xlat/drm_i915_getparams.in @@ -0,0 +1,28 @@ +I915_PARAM_IRQ_ACTIVE +I915_PARAM_ALLOW_BATCHBUFFER +I915_PARAM_LAST_DISPATCH +I915_PARAM_CHIPSET_ID +I915_PARAM_HAS_GEM +I915_PARAM_NUM_FENCES_AVAIL +I915_PARAM_HAS_OVERLAY +I915_PARAM_HAS_PAGEFLIPPING +I915_PARAM_HAS_EXECBUF2 +I915_PARAM_HAS_BSD +I915_PARAM_HAS_BLT +I915_PARAM_HAS_RELAXED_FENCING +I915_PARAM_HAS_COHERENT_RINGS +I915_PARAM_HAS_EXEC_CONSTANTS +I915_PARAM_HAS_RELAXED_DELTA +I915_PARAM_HAS_GEN7_SOL_RESET +I915_PARAM_HAS_LLC +I915_PARAM_HAS_ALIASING_PPGTT +I915_PARAM_HAS_WAIT_TIMEOUT +I915_PARAM_HAS_SEMAPHORES +I915_PARAM_HAS_PRIME_VMAP_FLUSH +I915_PARAM_HAS_VEBOX +I915_PARAM_HAS_SECURE_BATCHES +I915_PARAM_HAS_PINNED_BATCHES +I915_PARAM_HAS_EXEC_NO_RELOC +I915_PARAM_HAS_EXEC_HANDLE_LUT +I915_PARAM_HAS_WT +I915_PARAM_CMD_PARSER_VERSION diff --git a/xlat/drm_i915_ioctls.in b/xlat/drm_i915_ioctls.in new file mode 100644 index 0000000..21c3397 --- /dev/null +++ b/xlat/drm_i915_ioctls.in @@ -0,0 +1,51 @@ +/* Unfortunately i915 collides with other DRM drivers so we must specify these */ +DRM_IOCTL_I915_INIT +DRM_IOCTL_I915_FLUSH +DRM_IOCTL_I915_FLIP +DRM_IOCTL_I915_BATCHBUFFER +DRM_IOCTL_I915_IRQ_EMIT +DRM_IOCTL_I915_IRQ_WAIT +DRM_IOCTL_I915_GETPARAM +DRM_IOCTL_I915_SETPARAM +DRM_IOCTL_I915_ALLOC +DRM_IOCTL_I915_FREE +DRM_IOCTL_I915_INIT_HEAP +DRM_IOCTL_I915_CMDBUFFER +DRM_IOCTL_I915_DESTROY_HEAP +DRM_IOCTL_I915_SET_VBLANK_PIPE +DRM_IOCTL_I915_GET_VBLANK_PIPE +DRM_IOCTL_I915_VBLANK_SWAP +DRM_IOCTL_I915_HWS_ADDR +DRM_IOCTL_I915_GEM_INIT +DRM_IOCTL_I915_GEM_EXECBUFFER +DRM_IOCTL_I915_GEM_EXECBUFFER2 +DRM_IOCTL_I915_GEM_PIN +DRM_IOCTL_I915_GEM_UNPIN +DRM_IOCTL_I915_GEM_BUSY +DRM_IOCTL_I915_GEM_SET_CACHING +DRM_IOCTL_I915_GEM_GET_CACHING +DRM_IOCTL_I915_GEM_THROTTLE +DRM_IOCTL_I915_GEM_ENTERVT +DRM_IOCTL_I915_GEM_LEAVEVT +DRM_IOCTL_I915_GEM_CREATE +DRM_IOCTL_I915_GEM_PREAD +DRM_IOCTL_I915_GEM_PWRITE +DRM_IOCTL_I915_GEM_MMAP +DRM_IOCTL_I915_GEM_MMAP_GTT +DRM_IOCTL_I915_GEM_SET_DOMAIN +DRM_IOCTL_I915_GEM_SW_FINISH +DRM_IOCTL_I915_GEM_SET_TILING +DRM_IOCTL_I915_GEM_GET_TILING +DRM_IOCTL_I915_GEM_GET_APERTURE +DRM_IOCTL_I915_GET_PIPE_FROM_CRTC_ID +DRM_IOCTL_I915_GEM_MADVISE +DRM_IOCTL_I915_OVERLAY_PUT_IMAGE +DRM_IOCTL_I915_OVERLAY_ATTRS +DRM_IOCTL_I915_SET_SPRITE_COLORKEY +DRM_IOCTL_I915_GET_SPRITE_COLORKEY +DRM_IOCTL_I915_GEM_WAIT +DRM_IOCTL_I915_GEM_CONTEXT_CREATE +DRM_IOCTL_I915_GEM_CONTEXT_DESTROY +DRM_IOCTL_I915_REG_READ +DRM_IOCTL_I915_GET_RESET_STATS +DRM_IOCTL_I915_GEM_USERPTR diff --git a/xlat/drm_i915_setparams.in b/xlat/drm_i915_setparams.in new file mode 100644 index 0000000..d93d2ea --- /dev/null +++ b/xlat/drm_i915_setparams.in @@ -0,0 +1,4 @@ +I915_SETPARAM_USE_MI_BATCHBUFFER_START +I915_SETPARAM_TEX_LRU_LOG_GRANULARITY +I915_SETPARAM_ALLOW_BATCHBUFFER +I915_SETPARAM_NUM_USED_FENCES -- 2.1.4 _______________________________________________ Intel-gfx mailing list Intel-gfx@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/intel-gfx ^ permalink raw reply related [flat|nested] 22+ messages in thread
* Re: [PATCH v3 4/5] drm: Add decoding of i915 ioctls 2015-07-01 12:52 ` [PATCH v3 4/5] drm: Add decoding of i915 ioctls Patrik Jakobsson @ 2015-07-03 0:36 ` Dmitry V. Levin [not found] ` <20150703003609.GB29080-u2l5PoMzF/Vg9hUCZPvPmw@public.gmane.org> 0 siblings, 1 reply; 22+ messages in thread From: Dmitry V. Levin @ 2015-07-03 0:36 UTC (permalink / raw) To: Patrik Jakobsson; +Cc: intel-gfx, strace-devel [-- Attachment #1.1: Type: text/plain, Size: 1194 bytes --] On Wed, Jul 01, 2015 at 02:52:47PM +0200, Patrik Jakobsson wrote: [...] > --- a/drm.c > +++ b/drm.c > @@ -35,6 +35,9 @@ > > #define DRM_MAX_NAME_LEN 128 > > +extern int drm_i915_decode_number(struct tcb *tcp, unsigned int arg); Please rename "arg" to "code", and ... > +extern int drm_i915_ioctl(struct tcb *tcp, const unsigned int code, long arg); ... move both declarations to defs.h to make them visible also in the file where these functions are defined. [...] > +static int i915_setparam(struct tcb *tcp, const unsigned int code, long arg) > +{ > + struct drm_i915_setparam param; > + > + if (entering(tcp)) { > + if (umove(tcp, arg, ¶m)) > + return 0; > + > + tprints(", {param="); > + printxval(drm_i915_setparams, param.param, "I915_PARAM_???"); > + tprintf(", value=%d}", param.value); > + } > + > + return 1; > +} In this and most of other parsers of _IOC_WRITE ioctls added by this and the next patches, any error in parser that leads to "return 0" will result to disabled "arg" decoding, including the fallback decoding performed by sys_ioctl. Maybe it's time to deal with this issue in a more generic way. -- ldv [-- Attachment #1.2: Type: application/pgp-signature, Size: 181 bytes --] [-- Attachment #2: Type: text/plain, Size: 159 bytes --] _______________________________________________ Intel-gfx mailing list Intel-gfx@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/intel-gfx ^ permalink raw reply [flat|nested] 22+ messages in thread
[parent not found: <20150703003609.GB29080-u2l5PoMzF/Vg9hUCZPvPmw@public.gmane.org>]
* Re: [PATCH v3 4/5] drm: Add decoding of i915 ioctls [not found] ` <20150703003609.GB29080-u2l5PoMzF/Vg9hUCZPvPmw@public.gmane.org> @ 2015-07-06 10:35 ` Patrik Jakobsson 2015-07-06 14:40 ` Gabriel Laskar 0 siblings, 1 reply; 22+ messages in thread From: Patrik Jakobsson @ 2015-07-06 10:35 UTC (permalink / raw) To: strace-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f, gabriel-tU7rkvAWjlwhT4uAktR2oQ, intel-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW, ldv-u2l5PoMzF/Vg9hUCZPvPmw On Fri, Jul 03, 2015 at 03:36:09AM +0300, Dmitry V. Levin wrote: > On Wed, Jul 01, 2015 at 02:52:47PM +0200, Patrik Jakobsson wrote: > [...] > > --- a/drm.c > > +++ b/drm.c > > @@ -35,6 +35,9 @@ > > > > #define DRM_MAX_NAME_LEN 128 > > > > +extern int drm_i915_decode_number(struct tcb *tcp, unsigned int arg); > > Please rename "arg" to "code", and ... > > > +extern int drm_i915_ioctl(struct tcb *tcp, const unsigned int code, long arg); > > ... move both declarations to defs.h to make them visible also > in the file where these functions are defined. > > [...] > > +static int i915_setparam(struct tcb *tcp, const unsigned int code, long arg) > > +{ > > + struct drm_i915_setparam param; > > + > > + if (entering(tcp)) { > > + if (umove(tcp, arg, ¶m)) > > + return 0; > > + > > + tprints(", {param="); > > + printxval(drm_i915_setparams, param.param, "I915_PARAM_???"); > > + tprintf(", value=%d}", param.value); > > + } > > + > > + return 1; > > +} > > In this and most of other parsers of _IOC_WRITE ioctls added by this and > the next patches, any error in parser that leads to "return 0" will result > to disabled "arg" decoding, including the fallback decoding performed by > sys_ioctl. > > Maybe it's time to deal with this issue in a more generic way. > Yes, I'm thinking SYS_FUNC(ioctl) could be improved. But on the other hand how likely is it that we fail in umove and what chance do we have to recover from that anyway? All I can think of is OOM. > > -- > ldv ------------------------------------------------------------------------------ Don't Limit Your Business. Reach for the Cloud. GigeNET's Cloud Solutions provide you with the tools and support that you need to offload your IT needs and focus on growing your business. Configured For All Businesses. Start Your Cloud Today. https://www.gigenetcloud.com/ ^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [PATCH v3 4/5] drm: Add decoding of i915 ioctls 2015-07-06 10:35 ` Patrik Jakobsson @ 2015-07-06 14:40 ` Gabriel Laskar 2015-07-08 0:11 ` Dmitry V. Levin 0 siblings, 1 reply; 22+ messages in thread From: Gabriel Laskar @ 2015-07-06 14:40 UTC (permalink / raw) To: Patrik Jakobsson; +Cc: intel-gfx, ldv, strace-devel On Mon, 6 Jul 2015 12:35:52 +0200 Patrik Jakobsson <patrik.jakobsson@linux.intel.com> wrote: > On Fri, Jul 03, 2015 at 03:36:09AM +0300, Dmitry V. Levin wrote: > > On Wed, Jul 01, 2015 at 02:52:47PM +0200, Patrik Jakobsson wrote: > > [...] > > > --- a/drm.c > > > +++ b/drm.c > > > @@ -35,6 +35,9 @@ > > > > > > #define DRM_MAX_NAME_LEN 128 > > > > > > +extern int drm_i915_decode_number(struct tcb *tcp, unsigned int arg); > > > > Please rename "arg" to "code", and ... > > > > > +extern int drm_i915_ioctl(struct tcb *tcp, const unsigned int code, long arg); > > > > ... move both declarations to defs.h to make them visible also > > in the file where these functions are defined. > > > > [...] > > > +static int i915_setparam(struct tcb *tcp, const unsigned int code, long arg) > > > +{ > > > + struct drm_i915_setparam param; > > > + > > > + if (entering(tcp)) { > > > + if (umove(tcp, arg, ¶m)) > > > + return 0; > > > + > > > + tprints(", {param="); > > > + printxval(drm_i915_setparams, param.param, "I915_PARAM_???"); > > > + tprintf(", value=%d}", param.value); > > > + } > > > + > > > + return 1; > > > +} > > > > In this and most of other parsers of _IOC_WRITE ioctls added by this and > > the next patches, any error in parser that leads to "return 0" will result > > to disabled "arg" decoding, including the fallback decoding performed by > > sys_ioctl. > > > > Maybe it's time to deal with this issue in a more generic way. > > > > Yes, I'm thinking SYS_FUNC(ioctl) could be improved. But on the other hand how > likely is it that we fail in umove and what chance do we have to recover from > that anyway? All I can think of is OOM. umove() can fail in multiple ways. For example, if the memory is not valid in the tracee, umove() will fail. Anyway, SYS_FUNC(ioctl) is a bit complicated, and the handling of the fallbacks on failure should be more generic. -- Gabriel Laskar _______________________________________________ Intel-gfx mailing list Intel-gfx@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/intel-gfx ^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [PATCH v3 4/5] drm: Add decoding of i915 ioctls 2015-07-06 14:40 ` Gabriel Laskar @ 2015-07-08 0:11 ` Dmitry V. Levin 2015-07-10 12:36 ` Patrik Jakobsson 0 siblings, 1 reply; 22+ messages in thread From: Dmitry V. Levin @ 2015-07-08 0:11 UTC (permalink / raw) To: Gabriel Laskar; +Cc: intel-gfx, strace-devel [-- Attachment #1.1: Type: text/plain, Size: 2734 bytes --] On Mon, Jul 06, 2015 at 04:40:24PM +0200, Gabriel Laskar wrote: > On Mon, 6 Jul 2015 12:35:52 +0200, Patrik Jakobsson wrote: > > On Fri, Jul 03, 2015 at 03:36:09AM +0300, Dmitry V. Levin wrote: > > > On Wed, Jul 01, 2015 at 02:52:47PM +0200, Patrik Jakobsson wrote: > > > [...] > > > > --- a/drm.c > > > > +++ b/drm.c > > > > @@ -35,6 +35,9 @@ > > > > > > > > #define DRM_MAX_NAME_LEN 128 > > > > > > > > +extern int drm_i915_decode_number(struct tcb *tcp, unsigned int arg); > > > > > > Please rename "arg" to "code", and ... > > > > > > > +extern int drm_i915_ioctl(struct tcb *tcp, const unsigned int code, long arg); > > > > > > ... move both declarations to defs.h to make them visible also > > > in the file where these functions are defined. > > > > > > [...] > > > > +static int i915_setparam(struct tcb *tcp, const unsigned int code, long arg) > > > > +{ > > > > + struct drm_i915_setparam param; > > > > + > > > > + if (entering(tcp)) { > > > > + if (umove(tcp, arg, ¶m)) > > > > + return 0; > > > > + > > > > + tprints(", {param="); > > > > + printxval(drm_i915_setparams, param.param, "I915_PARAM_???"); > > > > + tprintf(", value=%d}", param.value); > > > > + } > > > > + > > > > + return 1; > > > > +} > > > > > > In this and most of other parsers of _IOC_WRITE ioctls added by this and > > > the next patches, any error in parser that leads to "return 0" will result > > > to disabled "arg" decoding, including the fallback decoding performed by > > > sys_ioctl. > > > > > > Maybe it's time to deal with this issue in a more generic way. > > > > > > > Yes, I'm thinking SYS_FUNC(ioctl) could be improved. But on the other hand how > > likely is it that we fail in umove and what chance do we have to recover from > > that anyway? All I can think of is OOM. > > umove() can fail in multiple ways. For example, if the memory is not > valid in the tracee, umove() will fail. Yes, this is the most likely cause for umove() to fail, and the most easily reproducible one, e.g. ioctl(-1, DRM_IOCTL_VERSION, 42); > Anyway, SYS_FUNC(ioctl) is a bit complicated, and the handling of the > fallbacks on failure should be more generic. What would be useful is a way for "on entering" parsers to return "done with decoding" information to their callers. This could be implemented by or'ing return value in the current semantics with a flag with "done with decoding" meaning, e.g. RVAL_DONE. If an ioctl parser returned RVAL_DONE, this would tell SYS_FUNC(ioctl) that the decoding is finished but fallback decoding is needed, while RVAL_DONE+1 would mean that the decoding is finished and no fallback decoding is needed. -- ldv [-- Attachment #1.2: Type: application/pgp-signature, Size: 181 bytes --] [-- Attachment #2: Type: text/plain, Size: 159 bytes --] _______________________________________________ Intel-gfx mailing list Intel-gfx@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/intel-gfx ^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [PATCH v3 4/5] drm: Add decoding of i915 ioctls 2015-07-08 0:11 ` Dmitry V. Levin @ 2015-07-10 12:36 ` Patrik Jakobsson 2015-07-10 12:57 ` Dmitry V. Levin 0 siblings, 1 reply; 22+ messages in thread From: Patrik Jakobsson @ 2015-07-10 12:36 UTC (permalink / raw) To: Gabriel Laskar, intel-gfx, strace-devel On Wed, Jul 08, 2015 at 03:11:36AM +0300, Dmitry V. Levin wrote: > On Mon, Jul 06, 2015 at 04:40:24PM +0200, Gabriel Laskar wrote: > > On Mon, 6 Jul 2015 12:35:52 +0200, Patrik Jakobsson wrote: > > > On Fri, Jul 03, 2015 at 03:36:09AM +0300, Dmitry V. Levin wrote: > > > > On Wed, Jul 01, 2015 at 02:52:47PM +0200, Patrik Jakobsson wrote: > > > > [...] > > > > > --- a/drm.c > > > > > +++ b/drm.c > > > > > @@ -35,6 +35,9 @@ > > > > > > > > > > #define DRM_MAX_NAME_LEN 128 > > > > > > > > > > +extern int drm_i915_decode_number(struct tcb *tcp, unsigned int arg); > > > > > > > > Please rename "arg" to "code", and ... > > > > > > > > > +extern int drm_i915_ioctl(struct tcb *tcp, const unsigned int code, long arg); > > > > > > > > ... move both declarations to defs.h to make them visible also > > > > in the file where these functions are defined. > > > > > > > > [...] > > > > > +static int i915_setparam(struct tcb *tcp, const unsigned int code, long arg) > > > > > +{ > > > > > + struct drm_i915_setparam param; > > > > > + > > > > > + if (entering(tcp)) { > > > > > + if (umove(tcp, arg, ¶m)) > > > > > + return 0; > > > > > + > > > > > + tprints(", {param="); > > > > > + printxval(drm_i915_setparams, param.param, "I915_PARAM_???"); > > > > > + tprintf(", value=%d}", param.value); > > > > > + } > > > > > + > > > > > + return 1; > > > > > +} > > > > > > > > In this and most of other parsers of _IOC_WRITE ioctls added by this and > > > > the next patches, any error in parser that leads to "return 0" will result > > > > to disabled "arg" decoding, including the fallback decoding performed by > > > > sys_ioctl. > > > > > > > > Maybe it's time to deal with this issue in a more generic way. > > > > > > > > > > Yes, I'm thinking SYS_FUNC(ioctl) could be improved. But on the other hand how > > > likely is it that we fail in umove and what chance do we have to recover from > > > that anyway? All I can think of is OOM. > > > > umove() can fail in multiple ways. For example, if the memory is not > > valid in the tracee, umove() will fail. > > Yes, this is the most likely cause for umove() to fail, > and the most easily reproducible one, e.g. > ioctl(-1, DRM_IOCTL_VERSION, 42); Yes, then we definitely need to handle those fails better > > > Anyway, SYS_FUNC(ioctl) is a bit complicated, and the handling of the > > fallbacks on failure should be more generic. > > What would be useful is a way for "on entering" parsers to return > "done with decoding" information to their callers. > > This could be implemented by or'ing return value in the current semantics > with a flag with "done with decoding" meaning, e.g. RVAL_DONE. > > If an ioctl parser returned RVAL_DONE, this would tell SYS_FUNC(ioctl) > that the decoding is finished but fallback decoding is needed, while > RVAL_DONE+1 would mean that the decoding is finished and no fallback > decoding is needed. I like that idea but isn't the current return semantics already good enough for that? The problem right now is that we ignore the return value from ioctl_decode() "on entering". What we could do is: 1. Call ioctl_decode_number() 2. Call ioctl_decode() if above didn't fail 3. If any of 1 and/or 2 failed we do fallback > > > -- > ldv _______________________________________________ Intel-gfx mailing list Intel-gfx@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/intel-gfx ^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [PATCH v3 4/5] drm: Add decoding of i915 ioctls 2015-07-10 12:36 ` Patrik Jakobsson @ 2015-07-10 12:57 ` Dmitry V. Levin 0 siblings, 0 replies; 22+ messages in thread From: Dmitry V. Levin @ 2015-07-10 12:57 UTC (permalink / raw) To: Patrik Jakobsson; +Cc: intel-gfx, strace-devel [-- Attachment #1.1: Type: text/plain, Size: 1194 bytes --] On Fri, Jul 10, 2015 at 02:36:38PM +0200, Patrik Jakobsson wrote: > On Wed, Jul 08, 2015 at 03:11:36AM +0300, Dmitry V. Levin wrote: > > On Mon, Jul 06, 2015 at 04:40:24PM +0200, Gabriel Laskar wrote: [...] > > > Anyway, SYS_FUNC(ioctl) is a bit complicated, and the handling of the > > > fallbacks on failure should be more generic. > > > > What would be useful is a way for "on entering" parsers to return > > "done with decoding" information to their callers. > > > > This could be implemented by or'ing return value in the current semantics > > with a flag with "done with decoding" meaning, e.g. RVAL_DONE. > > > > If an ioctl parser returned RVAL_DONE, this would tell SYS_FUNC(ioctl) > > that the decoding is finished but fallback decoding is needed, while > > RVAL_DONE+1 would mean that the decoding is finished and no fallback > > decoding is needed. > > I like that idea but isn't the current return semantics already good enough > for that? The problem right now is that we ignore the return value from > ioctl_decode() "on entering". After commit v4.10-104-g204c2bc we no longer ignore the return value from ioctl_decode() "on entering". -- ldv [-- Attachment #1.2: Type: application/pgp-signature, Size: 181 bytes --] [-- Attachment #2: Type: text/plain, Size: 159 bytes --] _______________________________________________ Intel-gfx mailing list Intel-gfx@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/intel-gfx ^ permalink raw reply [flat|nested] 22+ messages in thread
* [PATCH v3 5/5] drm: Add decoding of DRM and KMS ioctls 2015-07-01 12:52 [PATCH v3 0/5] drm: Add decoding for DRM/KMS and i915 ioctls Patrik Jakobsson [not found] ` <1435755168-16207-1-git-send-email-patrik.jakobsson-VuQAYsv1563Yd54FQh9/CA@public.gmane.org> 2015-07-01 12:52 ` [PATCH v3 4/5] drm: Add decoding of i915 ioctls Patrik Jakobsson @ 2015-07-01 12:52 ` Patrik Jakobsson 2 siblings, 0 replies; 22+ messages in thread From: Patrik Jakobsson @ 2015-07-01 12:52 UTC (permalink / raw) To: strace-devel, ldv, gabriel; +Cc: intel-gfx This patch adds many of the DRM and KMS ioctls. The rest can be added as needed. * drm.c: Decode DRM_IOCTL_VERSION * drm.c: Decode DRM_IOCTL_GET_UNIQUE * drm.c: Decode DRM_IOCTL_GET_MAGIC * drm.c: Decode DRM_IOCTL_WAIT_VBLANK * drm.c: Decode DRM_IOCTL_MODE_GETRESOURCES * drm.c: Decode DRM_IOCTL_MODE_GETCRTC * drm.c: Decode DRM_IOCTL_MODE_SETCRTC * drm.c: Decode DRM_IOCTL_MODE_CURSOR * drm.c: Decode DRM_IOCTL_MODE_CURSOR2 * drm.c: Decode DRM_IOCTL_MODE_GETGAMMA * drm.c: Decode DRM_IOCTL_MODE_SETGAMMA * drm.c: Decode DRM_IOCTL_MODE_GETENCODER * drm.c: Decode DRM_IOCTL_MODE_GETCONNECTOR * drm.c: Decode DRM_IOCTL_MODE_GETPROPERTY * drm.c: Decode DRM_IOCTL_MODE_SETPROPERTY * drm.c: Decode DRM_IOCTL_MODE_GETPROPBLOB * drm.c: Decode DRM_IOCTL_MODE_GETFB * drm.c: Decode DRM_IOCTL_MODE_ADDFB * drm.c: Decode DRM_IOCTL_MODE_RMFB * drm.c: Decode DRM_IOCTL_MODE_PAGE_FLIP * drm.c: Decode DRM_IOCTL_DIRTYFB * drm.c: Decode DRM_IOCTL_CREATE_DUMB * drm.c: Decode DRM_IOCTL_MAP_DUMB * drm.c: Decode DRM_IOCTL_DESTROY_DUMB * drm.c: Decode DRM_IOCTL_GEM_CLOSE Signed-off-by: Patrik Jakobsson <patrik.jakobsson@linux.intel.com> --- drm.c | 544 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 544 insertions(+) diff --git a/drm.c b/drm.c index 846ea4d..c1d54f4 100644 --- a/drm.c +++ b/drm.c @@ -104,6 +104,472 @@ int drm_decode_number(struct tcb *tcp, unsigned int arg) return 0; } +static int drm_version(struct tcb *tcp, const unsigned int code, long arg) +{ + struct drm_version ver; + + if (exiting(tcp)) { + if (umove(tcp, arg, &ver)) + return 0; + + tprintf(", {version_major=%d, version_minor=%d, version_patchlevel=%d, " + "name_len=%lu, name=", ver.version_major, + ver.version_minor, ver.version_patchlevel, + ver.name_len); + printstr(tcp, (long)ver.name, ver.name_len); + tprintf(", date_len=%lu, date=", ver.date_len); + printstr(tcp, (long)ver.date, ver.date_len); + tprintf(", desc_len=%lu, desc=", ver.desc_len); + printstr(tcp, (long)ver.desc, ver.desc_len); + tprints("}"); + } + + return 1; +} + +static int drm_get_unique(struct tcb *tcp, const unsigned int code, long arg) +{ + struct drm_unique unique; + + if (exiting(tcp)) { + if (umove(tcp, arg, &unique)) + return 0; + + tprintf(", {unique_len=%lu, unique=", unique.unique_len); + printstr(tcp, (long)unique.unique, unique.unique_len); + tprints("}"); + } + + return 1; +} + +static int drm_get_magic(struct tcb *tcp, const unsigned int code, long arg) +{ + struct drm_auth auth; + + if (exiting(tcp)) { + if (umove(tcp, arg, &auth)) + return 0; + + tprintf(", {magic=%u}", auth.magic); + } + + return 1; +} + +static int drm_wait_vblank(struct tcb *tcp, const unsigned int code, long arg) +{ + union drm_wait_vblank vblank; + + if (umove(tcp, arg, &vblank)) + return 0; + + if (entering(tcp)) { + tprintf(", {request={type=%u, sequence=%u, signal=%lu}", + vblank.request.type, vblank.request.sequence, + vblank.request.signal); + } else if (exiting(tcp)) { + tprintf(", reply={type=%u, sequence=%u, tval_sec=%ld, tval_usec=%ld}}", + vblank.reply.type, vblank.reply.sequence, + vblank.reply.tval_sec, vblank.reply.tval_usec); + } + + return 1; +} + +static int drm_mode_get_resources(struct tcb *tcp, const unsigned int code, long arg) +{ + struct drm_mode_card_res res; + + + if (exiting(tcp)) { + if (umove(tcp, arg, &res)) + return 0; + + tprintf(", {fb_id_ptr=%p, crtc_id_ptr=%p, connector_id_ptr=%p, " + "encoder_id_ptr=%p, count_fbs=%u, count_crtcs=%u, " + "count_connectors=%u, count_encoders=%u, min_width=%u, " + "max_width=%u, min_height=%u, max_height=%u}", + (void *)res.fb_id_ptr, (void *)res.crtc_id_ptr, + (void *)res.connector_id_ptr, (void *)res.encoder_id_ptr, + res.count_fbs, res.count_crtcs, res.count_connectors, + res.count_encoders, res.min_width, res.max_width, + res.min_height, res.max_height); + } + + return 1; +} + +static void drm_mode_print_modeinfo(struct drm_mode_modeinfo *info) +{ + tprintf("clock=%u, hdisplay=%hu, hsync_start=%hu, hsync_end=%hu, " + "htotal=%hu, hskew=%hu, vdisplay=%hu, vsync_start=%hu, " + "vsync_end=%hu, vtotal=%hu, vscan=%hu, vrefresh=%u, " + "flags=0x%x, type=%u, name=%s", info->clock, info->hdisplay, + info->hsync_start, info->hsync_end, info->htotal, info->hskew, + info->vdisplay, info->vsync_start, info->vsync_end, + info->vtotal, info->vscan, info->vrefresh, info->flags, + info->type, info->name); +} + +static int drm_mode_get_crtc(struct tcb *tcp, const unsigned int code, long arg) +{ + struct drm_mode_crtc crtc; + + if (umove(tcp, arg, &crtc)) + return 0; + + if (entering(tcp)) { + tprintf(", {crtc_id=%u", crtc.crtc_id); + } else if (exiting(tcp)) { + tprintf(", set_connectors_ptr=%p, count_connectors=%u, " + "fb_id=%u, x=%u, y=%u, gamma_size=%u, mode_valid=%u, " + "mode={", (void *)crtc.set_connectors_ptr, + crtc.count_connectors, crtc.fb_id, crtc.x, crtc.y, + crtc.gamma_size, crtc.mode_valid); + + drm_mode_print_modeinfo(&crtc.mode); + tprintf("}}"); + } + + return 1; +} + +static int drm_mode_set_crtc(struct tcb *tcp, const unsigned int code, long arg) +{ + struct drm_mode_crtc crtc; + + if (entering(tcp)) { + if (umove(tcp, arg, &crtc)) + return 0; + + tprintf(", {set_connectors_ptr=%p, count_connectors=%u, " + "crtc_id=%u, fb_id=%u, x=%u, y=%u, gamma_size=%u, " + "mode_valid=%u, mode={", (void *)crtc.set_connectors_ptr, + crtc.count_connectors, crtc.crtc_id, crtc.fb_id, crtc.x, + crtc.y, crtc.gamma_size, crtc.mode_valid); + + drm_mode_print_modeinfo(&crtc.mode); + tprintf("}}"); + } + + return 1; +} + +static int drm_mode_cursor(struct tcb *tcp, const unsigned int code, long arg) +{ + struct drm_mode_cursor cursor; + + + if (entering(tcp)) { + if (umove(tcp, arg, &cursor)) + return 0; + + tprintf(", {flags=0x%x, crtc_id=%u, x=%d, y=%d, width=%u, " + "height=%u, handle=%u}", cursor.flags, cursor.crtc_id, + cursor.x, cursor.y, cursor.width, cursor.height, + cursor.handle); + } + + return 1; +} + +static int drm_mode_cursor2(struct tcb *tcp, const unsigned int code, long arg) +{ + struct drm_mode_cursor2 cursor; + + if (entering(tcp)) { + if (umove(tcp, arg, &cursor)) + return 0; + + tprintf(", {flags=0x%x, crtc_id=%u, x=%d, y=%d, width=%u, " + "height=%u, handle=%u, hot_x=%d, hot_y=%d}", + cursor.flags, cursor.crtc_id, cursor.x, cursor.y, + cursor.width, cursor.height, cursor.handle, + cursor.hot_x, cursor.hot_y); + } + + return 1; +} + +static int drm_mode_get_gamma(struct tcb *tcp, const unsigned int code, long arg) +{ + struct drm_mode_crtc_lut lut; + + + if (entering(tcp)) { + if (umove(tcp, arg, &lut)) + return 0; + + /* We don't print the entire table, just the pointers */ + tprintf(", {crtc_id=%u, gamma_size=%u, red=%p, green=%p, " + "blue=%p}", lut.crtc_id, lut.gamma_size, + (void *)lut.red, (void *)lut.green, (void *)lut.blue); + } + + return 1; +} + +static int drm_mode_set_gamma(struct tcb *tcp, const unsigned int code, long arg) +{ + struct drm_mode_crtc_lut lut; + + if (entering(tcp)) { + if (umove(tcp, arg, &lut)) + return 0; + + /* We don't print the entire table, just the rgb pointers */ + tprintf(", {crtc_id=%u, gamma_size=%u, red=%p, green=%p, " + "blue=%p}", lut.crtc_id, lut.gamma_size, + (void *)lut.red, (void *)lut.green, (void *)lut.blue); + } + + return 1; +} + +static int drm_mode_get_encoder(struct tcb *tcp, const unsigned int code, long arg) +{ + struct drm_mode_get_encoder enc; + + if (umove(tcp, arg, &enc)) + return 0; + + if (entering(tcp)) { + tprintf(", {encoder_id=%u", enc.encoder_id); + } else if (exiting(tcp)) { + /* TODO: Print name of encoder type */ + tprintf(", encoder_type=%u, crtc_id=%u, possible_crtcs=0x%x, " + "possible_clones=0x%x}", enc.encoder_type, + enc.crtc_id, enc.possible_crtcs, enc.possible_clones); + } + + return 1; +} + +static int drm_mode_get_connector(struct tcb *tcp, const unsigned int code, long arg) +{ + struct drm_mode_get_connector con; + + if (umove(tcp, arg, &con)) + return 0; + + /* We could be very verbose here but keep is simple for now */ + if (entering(tcp)) { + tprintf(", {connector_id=%u", con.connector_id); + } else if (exiting(tcp)) { + tprintf(", encoders_ptr=%p, modes_ptr=%p, props_ptr=%p, " + "prop_values_ptr=%p, count_modes=%u, count_props=%u, " + "count_encoders=%u, encoder_id=%u, connector_type=%u, " + "connector_type_id=%u, connection=%u, mm_width=%u, " + "mm_height=%u, subpixel=%u}", (void *)con.encoders_ptr, + (void *)con.modes_ptr, (void *)con.props_ptr, + (void *)con.prop_values_ptr, con.count_modes, + con.count_props, con.count_encoders, con.encoder_id, + con.connector_type, con.connector_type_id, + con.connection, con.mm_width, con.mm_height, + con.subpixel); + } + + return 1; +} + +static int drm_mode_get_property(struct tcb *tcp, const unsigned int code, long arg) +{ + struct drm_mode_get_property prop; + + if (umove(tcp, arg, &prop)) + return 0; + + if (entering(tcp)) { + tprintf(", {prop_id=%u", prop.prop_id); + } else if (exiting(tcp)) { + tprintf(", values_ptr=%p, enum_blob_ptr=%p, flags=0x%x, " + "name=%s, count_values=%u, count_enum_blobs=%u}", + (void *)prop.values_ptr, (void *)prop.enum_blob_ptr, + prop.flags, prop.name, prop.count_values, + prop.count_enum_blobs); + } + + return 1; +} + +static int drm_mode_set_property(struct tcb *tcp, const unsigned int code, long arg) +{ + struct drm_mode_connector_set_property prop; + + if (entering(tcp)) { + if (umove(tcp, arg, &prop)) + return 0; + + tprintf(", {value=%Lu, prop_id=%u, connector_id=%u}", + prop.value, prop.prop_id, prop.connector_id); + } + + return 1; +} + +static int drm_mode_get_prop_blob(struct tcb *tcp, const unsigned int code, long arg) +{ + struct drm_mode_get_blob blob; + + if (umove(tcp, arg, &blob)) + return 0; + + if (entering(tcp)) { + tprintf(", {blob_id=%u", blob.blob_id); + } else if (exiting(tcp)) { + tprintf(", length=%u, data=%p}", blob.length, + (void *)blob.data); + } + + return 1; +} + +static int drm_mode_add_fb(struct tcb *tcp, const unsigned int code, long arg) +{ + struct drm_mode_fb_cmd cmd; + + if (umove(tcp, arg, &cmd)) + return 0; + + if (entering(tcp)) { + tprintf(", {width=%u, height=%u, pitch=%u, bpp=%u, depth=%u, " + "handle=%u", cmd.width, cmd.height, cmd.pitch, + cmd.bpp, cmd.depth, cmd.handle); + } else if (exiting(tcp)) { + tprintf(", fb_id=%u}", cmd.fb_id); + } + + return 1; +} + +static int drm_mode_get_fb(struct tcb *tcp, const unsigned int code, long arg) +{ + struct drm_mode_fb_cmd cmd; + + if (umove(tcp, arg, &cmd)) + return 0; + + if (entering(tcp)) { + tprintf(", {fb_id=%u", cmd.fb_id); + } else { + tprintf(", width=%u, height=%u, pitch=%u, bpp=%u, depth=%u, " + "handle=%u}", cmd.width, cmd.height, cmd.pitch, + cmd.bpp, cmd.depth, cmd.handle); + } + + return 1; +} + +static int drm_mode_rm_fb(struct tcb *tcp, const unsigned int code, long arg) +{ + unsigned int handle; + + + if (entering(tcp)) { + if (umove(tcp, arg, &handle)) + return 0; + + tprintf(", %u", handle); + } + + return 1; +} + +static int drm_mode_page_flip(struct tcb *tcp, const unsigned int code, long arg) +{ + struct drm_mode_crtc_page_flip flip; + + if (entering(tcp)) { + if (umove(tcp, arg, &flip)) + return 0; + + tprintf(", {crtc_id=%u, fb_id=%u, flags=0x%x, user_data=0x%Lx}", + flip.crtc_id, flip.fb_id, flip.flags, flip.user_data); + } + + return 1; +} + +static int drm_mode_dirty_fb(struct tcb *tcp, const unsigned int code, long arg) +{ + struct drm_mode_fb_dirty_cmd cmd; + + + if (entering(tcp)) { + if (umove(tcp, arg, &cmd)) + return 0; + + tprintf(", {fb_id=%u, flags=0x%x, color=0x%x, num_clips=%u, " + "clips_ptr=%p}", cmd.fb_id, cmd.flags, cmd.color, + cmd.num_clips, (void *)cmd.clips_ptr); + } + + return 1; +} + +static int drm_mode_create_dumb(struct tcb *tcp, const unsigned int code, long arg) +{ + struct drm_mode_create_dumb dumb; + + if (umove(tcp, arg, &dumb)) + return 0; + + if (entering(tcp)) { + tprintf(", {width=%u, height=%u, bpp=%u, flags=0x%x", + dumb.width, dumb.height, dumb.bpp, dumb.flags); + } else if (exiting(tcp)) { + tprintf(", handle=%u, pitch=%u, size=%Lu}", dumb.handle, + dumb.pitch, dumb.size); + } + + return 1; +} + +static int drm_mode_map_dumb(struct tcb *tcp, const unsigned int code, long arg) +{ + struct drm_mode_map_dumb dumb; + + if (umove(tcp, arg, &dumb)) + return 0; + + if (entering(tcp)) { + tprintf(", {handle=%u", dumb.handle); + } else if (exiting(tcp)) { + tprintf(", offset=%Lu}", dumb.offset); + } + + return 1; +} + +static int drm_mode_destroy_dumb(struct tcb *tcp, const unsigned int code, long arg) +{ + struct drm_mode_destroy_dumb dumb; + + if (entering(tcp)) { + if (umove(tcp, arg, &dumb)) + return 0; + + tprintf(", {handle=%u}", dumb.handle); + } + + return 1; +} + +static int drm_gem_close(struct tcb *tcp, const unsigned int code, long arg) +{ + struct drm_gem_close close; + + if (entering(tcp)) { + if (umove(tcp, arg, &close)) + return 0; + + tprintf(", {handle=%u}", close.handle); + } + + return 1; +} + int drm_ioctl(struct tcb *tcp, const unsigned int code, long arg) { int ret = 0; @@ -112,6 +578,84 @@ int drm_ioctl(struct tcb *tcp, const unsigned int code, long arg) if (drm_is_priv(tcp->u_arg[1])) { if (verbose(tcp) && drm_is_driver(tcp, "i915")) ret = drm_i915_ioctl(tcp, code, arg); + } else { + switch (code) { + case DRM_IOCTL_VERSION: + ret = drm_version(tcp, code, arg); + break; + case DRM_IOCTL_GET_UNIQUE: + ret = drm_get_unique(tcp, code, arg); + break; + case DRM_IOCTL_GET_MAGIC: + ret = drm_get_magic(tcp, code, arg); + break; + case DRM_IOCTL_WAIT_VBLANK: + ret = drm_wait_vblank(tcp, code, arg); + break; + case DRM_IOCTL_MODE_GETRESOURCES: + ret = drm_mode_get_resources(tcp, code, arg); + break; + case DRM_IOCTL_MODE_GETCRTC: + ret = drm_mode_get_crtc(tcp, code, arg); + break; + case DRM_IOCTL_MODE_SETCRTC: + ret = drm_mode_set_crtc(tcp, code, arg); + break; + case DRM_IOCTL_MODE_CURSOR: + ret = drm_mode_cursor(tcp, code, arg); + break; + case DRM_IOCTL_MODE_CURSOR2: + ret = drm_mode_cursor2(tcp, code, arg); + break; + case DRM_IOCTL_MODE_GETGAMMA: + ret = drm_mode_get_gamma(tcp, code, arg); + break; + case DRM_IOCTL_MODE_SETGAMMA: + ret = drm_mode_set_gamma(tcp, code, arg); + break; + case DRM_IOCTL_MODE_GETENCODER: + ret = drm_mode_get_encoder(tcp, code, arg); + break; + case DRM_IOCTL_MODE_GETCONNECTOR: + ret = drm_mode_get_connector(tcp, code, arg); + break; + case DRM_IOCTL_MODE_GETPROPERTY: + ret = drm_mode_get_property(tcp, code, arg); + break; + case DRM_IOCTL_MODE_SETPROPERTY: + ret = drm_mode_set_property(tcp, code, arg); + break; + case DRM_IOCTL_MODE_GETPROPBLOB: + ret = drm_mode_get_prop_blob(tcp, code, arg); + break; + case DRM_IOCTL_MODE_GETFB: + ret = drm_mode_get_fb(tcp, code, arg); + break; + case DRM_IOCTL_MODE_ADDFB: + ret = drm_mode_add_fb(tcp, code, arg); + break; + case DRM_IOCTL_MODE_RMFB: + ret = drm_mode_rm_fb(tcp, code, arg); + break; + case DRM_IOCTL_MODE_PAGE_FLIP: + ret = drm_mode_page_flip(tcp, code, arg); + break; + case DRM_IOCTL_MODE_DIRTYFB: + ret = drm_mode_dirty_fb(tcp, code, arg); + break; + case DRM_IOCTL_MODE_CREATE_DUMB: + ret = drm_mode_create_dumb(tcp, code, arg); + break; + case DRM_IOCTL_MODE_MAP_DUMB: + ret = drm_mode_map_dumb(tcp, code, arg); + break; + case DRM_IOCTL_MODE_DESTROY_DUMB: + ret = drm_mode_destroy_dumb(tcp, code, arg); + break; + case DRM_IOCTL_GEM_CLOSE: + ret = drm_gem_close(tcp, code, arg); + break; + } } /* Free any allocated private data */ -- 2.1.4 _______________________________________________ Intel-gfx mailing list Intel-gfx@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/intel-gfx ^ permalink raw reply related [flat|nested] 22+ messages in thread
end of thread, other threads:[~2015-08-02 14:03 UTC | newest]
Thread overview: 22+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-07-01 12:52 [PATCH v3 0/5] drm: Add decoding for DRM/KMS and i915 ioctls Patrik Jakobsson
[not found] ` <1435755168-16207-1-git-send-email-patrik.jakobsson-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
2015-07-01 12:52 ` [PATCH v3 1/5] drm: Add config for detecting libdrm Patrik Jakobsson
[not found] ` <1435755168-16207-2-git-send-email-patrik.jakobsson-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
2015-07-23 9:48 ` Mike Frysinger
2015-07-23 10:44 ` Dmitry V. Levin
[not found] ` <20150723104417.GA21575-u2l5PoMzF/Vg9hUCZPvPmw@public.gmane.org>
2015-07-23 11:02 ` Mike Frysinger
2015-07-30 13:30 ` Patrik Jakobsson
2015-07-30 14:04 ` Mike Frysinger
2015-07-31 9:09 ` Patrik Jakobsson
2015-08-01 18:22 ` Dmitry V. Levin
2015-08-02 14:03 ` Patrik Jakobsson
2015-07-01 12:52 ` [PATCH v3 2/5] drm: Add private data field to trace control block Patrik Jakobsson
2015-07-03 0:33 ` Dmitry V. Levin
2015-07-06 8:09 ` Patrik Jakobsson
2015-07-01 12:52 ` [PATCH v3 3/5] drm: Add dispatcher and driver identification for DRM Patrik Jakobsson
2015-07-01 12:52 ` [PATCH v3 4/5] drm: Add decoding of i915 ioctls Patrik Jakobsson
2015-07-03 0:36 ` Dmitry V. Levin
[not found] ` <20150703003609.GB29080-u2l5PoMzF/Vg9hUCZPvPmw@public.gmane.org>
2015-07-06 10:35 ` Patrik Jakobsson
2015-07-06 14:40 ` Gabriel Laskar
2015-07-08 0:11 ` Dmitry V. Levin
2015-07-10 12:36 ` Patrik Jakobsson
2015-07-10 12:57 ` Dmitry V. Levin
2015-07-01 12:52 ` [PATCH v3 5/5] drm: Add decoding of DRM and KMS ioctls Patrik Jakobsson
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox