diff options
author | Ben Skeggs <bskeggs@redhat.com> | 2020-06-29 20:49:15 +1000 |
---|---|---|
committer | Ben Skeggs <bskeggs@redhat.com> | 2020-07-24 18:50:51 +1000 |
commit | 3e176fd0600439a8a1e0b3e95e2f0545660ab59c (patch) | |
tree | 09f118ba1a59e116f3f79d359e3e9da88fa506d0 /drivers/gpu/drm | |
parent | f7a7d22ad6781a34ffc718865700883d3cbf6c06 (diff) | |
download | linux-3e176fd0600439a8a1e0b3e95e2f0545660ab59c.tar.bz2 |
drm/nouveau/nvif: add support for object-level debug output
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
Reviewed-by: Lyude Paul <lyude@redhat.com>
Diffstat (limited to 'drivers/gpu/drm')
-rw-r--r-- | drivers/gpu/drm/nouveau/include/nvif/object.h | 1 | ||||
-rw-r--r-- | drivers/gpu/drm/nouveau/include/nvif/parent.h | 25 | ||||
-rw-r--r-- | drivers/gpu/drm/nouveau/include/nvif/printf.h | 20 | ||||
-rw-r--r-- | drivers/gpu/drm/nouveau/nouveau_drm.c | 39 | ||||
-rw-r--r-- | drivers/gpu/drm/nouveau/nouveau_drv.h | 2 | ||||
-rw-r--r-- | drivers/gpu/drm/nouveau/nvif/object.c | 2 |
6 files changed, 89 insertions, 0 deletions
diff --git a/drivers/gpu/drm/nouveau/include/nvif/object.h b/drivers/gpu/drm/nouveau/include/nvif/object.h index f3e20d02b2bc..a39d2bf7064b 100644 --- a/drivers/gpu/drm/nouveau/include/nvif/object.h +++ b/drivers/gpu/drm/nouveau/include/nvif/object.h @@ -10,6 +10,7 @@ struct nvif_sclass { }; struct nvif_object { + struct nvif_parent *parent; struct nvif_client *client; const char *name; u32 handle; diff --git a/drivers/gpu/drm/nouveau/include/nvif/parent.h b/drivers/gpu/drm/nouveau/include/nvif/parent.h new file mode 100644 index 000000000000..41cb1b0d90d3 --- /dev/null +++ b/drivers/gpu/drm/nouveau/include/nvif/parent.h @@ -0,0 +1,25 @@ +/* SPDX-License-Identifier: MIT */ +#ifndef __NVIF_PARENT_H__ +#define __NVIF_PARENT_H__ +#include <nvif/os.h> +struct nvif_object; + +struct nvif_parent { + const struct nvif_parent_func { + void (*debugf)(struct nvif_object *, const char *fmt, ...) __printf(2, 3); + void (*errorf)(struct nvif_object *, const char *fmt, ...) __printf(2, 3); + } *func; +}; + +static inline void +nvif_parent_dtor(struct nvif_parent *parent) +{ + parent->func = NULL; +} + +static inline void +nvif_parent_ctor(const struct nvif_parent_func *func, struct nvif_parent *parent) +{ + parent->func = func; +} +#endif diff --git a/drivers/gpu/drm/nouveau/include/nvif/printf.h b/drivers/gpu/drm/nouveau/include/nvif/printf.h new file mode 100644 index 000000000000..6c299ec6be21 --- /dev/null +++ b/drivers/gpu/drm/nouveau/include/nvif/printf.h @@ -0,0 +1,20 @@ +/* SPDX-License-Identifier: MIT */ +#ifndef __NVIF_PRINTF_H__ +#define __NVIF_PRINTF_H__ +#include <nvif/client.h> +#include <nvif/parent.h> + +#define NVIF_PRINT(l,o,f,a...) do { \ + struct nvif_object *_o = (o); \ + struct nvif_parent *_p = _o->parent; \ + _p->func->l(_o, "[%s/%08x:%s] "f"\n", _o->client->object.name, _o->handle, _o->name, ##a); \ +} while(0) + +#ifndef NVIF_DEBUG_PRINT_DISABLE +#define NVIF_DEBUG(o,f,a...) NVIF_PRINT(debugf, (o), f, ##a) +#else +#define NVIF_DEBUG(o,f,a...) +#endif + +#define NVIF_ERROR(o,f,a...) NVIF_PRINT(errorf, (o), f, ##a) +#endif diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.c b/drivers/gpu/drm/nouveau/nouveau_drm.c index 6f24a215ac74..c1b22746a710 100644 --- a/drivers/gpu/drm/nouveau/nouveau_drm.c +++ b/drivers/gpu/drm/nouveau/nouveau_drm.c @@ -496,6 +496,40 @@ nouveau_accel_init(struct nouveau_drm *drm) nouveau_bo_move_init(drm); } +static void __printf(2, 3) +nouveau_drm_errorf(struct nvif_object *object, const char *fmt, ...) +{ + struct nouveau_drm *drm = container_of(object->parent, typeof(*drm), parent); + struct va_format vaf; + va_list va; + + va_start(va, fmt); + vaf.fmt = fmt; + vaf.va = &va; + NV_ERROR(drm, "%pV", &vaf); + va_end(va); +} + +static void __printf(2, 3) +nouveau_drm_debugf(struct nvif_object *object, const char *fmt, ...) +{ + struct nouveau_drm *drm = container_of(object->parent, typeof(*drm), parent); + struct va_format vaf; + va_list va; + + va_start(va, fmt); + vaf.fmt = fmt; + vaf.va = &va; + NV_DEBUG(drm, "%pV", &vaf); + va_end(va); +} + +static const struct nvif_parent_func +nouveau_parent = { + .debugf = nouveau_drm_debugf, + .errorf = nouveau_drm_errorf, +}; + static int nouveau_drm_device_init(struct drm_device *dev) { @@ -507,6 +541,9 @@ nouveau_drm_device_init(struct drm_device *dev) dev->dev_private = drm; drm->dev = dev; + nvif_parent_ctor(&nouveau_parent, &drm->parent); + drm->master.base.object.parent = &drm->parent; + ret = nouveau_cli_init(drm, "DRM-master", &drm->master); if (ret) goto fail_alloc; @@ -583,6 +620,7 @@ fail_ttm: fail_master: nouveau_cli_fini(&drm->master); fail_alloc: + nvif_parent_dtor(&drm->parent); kfree(drm); return ret; } @@ -616,6 +654,7 @@ nouveau_drm_device_fini(struct drm_device *dev) nouveau_cli_fini(&drm->client); nouveau_cli_fini(&drm->master); + nvif_parent_dtor(&drm->parent); kfree(drm); } diff --git a/drivers/gpu/drm/nouveau/nouveau_drv.h b/drivers/gpu/drm/nouveau/nouveau_drv.h index 2a6519737800..30c0bb5b4dc9 100644 --- a/drivers/gpu/drm/nouveau/nouveau_drv.h +++ b/drivers/gpu/drm/nouveau/nouveau_drv.h @@ -132,8 +132,10 @@ nouveau_cli(struct drm_file *fpriv) } #include <nvif/object.h> +#include <nvif/parent.h> struct nouveau_drm { + struct nvif_parent parent; struct nouveau_cli master; struct nouveau_cli client; struct drm_device *dev; diff --git a/drivers/gpu/drm/nouveau/nvif/object.c b/drivers/gpu/drm/nouveau/nvif/object.c index 9f3348327244..671a5c0199e0 100644 --- a/drivers/gpu/drm/nouveau/nvif/object.c +++ b/drivers/gpu/drm/nouveau/nvif/object.c @@ -282,6 +282,8 @@ nvif_object_ctor(struct nvif_object *parent, const char *name, u32 handle, return -ENOMEM; } + object->parent = parent->parent; + args->ioctl.version = 0; args->ioctl.type = NVIF_IOCTL_V0_NEW; args->new.version = 0; |