Re: [PATCH] drm/msm: UAPI error reporting

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




On 22/11/2024 15:51, Rob Clark wrote:
On Fri, Nov 22, 2024 at 4:21 AM Konrad Dybcio
<konrad.dybcio@xxxxxxxxxxxxxxxx> wrote:

On 21.11.2024 5:48 PM, Rob Clark wrote:
From: Rob Clark <robdclark@xxxxxxxxxxxx>

Debugging incorrect UAPI usage tends to be a bit painful, so add a
helper macro to make it easier to add debug logging which can be enabled
at runtime via drm.debug.

Signed-off-by: Rob Clark <robdclark@xxxxxxxxxxxx>
---

[...]

+/* Helper for returning a UABI error with optional logging which can make
+ * it easier for userspace to understand what it is doing wrong.
+ */
+#define UERR(err, drm, fmt, ...) \
+     ({ DRM_DEV_DEBUG_DRIVER((drm)->dev, fmt, ##__VA_ARGS__); -(err); })
+
  #define DBG(fmt, ...) DRM_DEBUG_DRIVER(fmt"\n", ##__VA_ARGS__)
  #define VERB(fmt, ...) if (0) DRM_DEBUG_DRIVER(fmt"\n", ##__VA_ARGS__)

I'm generally not a fan of adding driver-specific debug prints..

Maybe that's something that could be pushed to the drm-common layer
or even deeper down the stack?

Even if we had something like DRM_DBG_UABI_ERROR() I'd probably still
just #define UERR() to be a wrapper for it, since line length/wrapping
tends to be a bit of a challenge.  And I have a fairly substantial
patch stack on top of this adding sparse/vm_bind support.  (Debugging
that was actually the motivation for this patch.)

I noticed that xe has something similar, but slightly different shape,
in the form of XE_IOCTL_DBG().. but that kinda just moves the line
length problem into the if() conditional.  (And doesn't provide the
benefit of being able to display the incorrect param.)

FWIW there is also a debug only builds hack in i915:

/* Catch emission of unexpected errors for CI! */
#if IS_ENABLED(CONFIG_DRM_I915_DEBUG_GEM)
#undef EINVAL
#define EINVAL ({ \
	DRM_DEBUG_DRIVER("EINVAL at %s:%d\n", __func__, __LINE__); \
	22; \
})
#endif

UERR functionality wise looks quite good to me. Better than the other two. The name is not scoped but I appreciate the readability line length challenges.

Regards,

Tvrtko



[Index of Archives]     [Linux DRI Users]     [Linux Intel Graphics]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux