summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--drm/nouveau/include/nvkm/core/client.h12
-rw-r--r--drm/nouveau/include/nvkm/core/device.h15
-rw-r--r--drm/nouveau/include/nvkm/core/enum.h1
-rw-r--r--drm/nouveau/include/nvkm/core/subdev.h19
-rw-r--r--drm/nouveau/nvkm/core/enum.c17
-rw-r--r--drm/nouveau/nvkm/core/subdev.c1
-rw-r--r--lib/include/nvif/os.h10
-rw-r--r--lib/main.c17
-rw-r--r--lib/null.c3
-rw-r--r--lib/priv.h1
10 files changed, 75 insertions, 21 deletions
diff --git a/drm/nouveau/include/nvkm/core/client.h b/drm/nouveau/include/nvkm/core/client.h
index a35b38244..bcd2a3583 100644
--- a/drm/nouveau/include/nvkm/core/client.h
+++ b/drm/nouveau/include/nvkm/core/client.h
@@ -52,4 +52,16 @@ int nvkm_client_notify_new(struct nvkm_object *, struct nvkm_event *,
int nvkm_client_notify_del(struct nvkm_client *, int index);
int nvkm_client_notify_get(struct nvkm_client *, int index);
int nvkm_client_notify_put(struct nvkm_client *, int index);
+
+/* logging for client-facing objects */
+#define nvif_printk(o,l,p,f,a...) do { \
+ struct nvkm_object *_object = (o); \
+ struct nvkm_client *_client = nvkm_client(_object); \
+ if (_client->debug >= NV_DBG_##l) \
+ printk(KERN_##p "nouveau: %s: "f, _client->name, ##a); \
+} while(0)
+#define nvif_error(o,f,a...) nvif_printk((o), ERROR, ERR, f, ##a)
+#define nvif_debug(o,f,a...) nvif_printk((o), DEBUG, INFO, f, ##a)
+#define nvif_trace(o,f,a...) nvif_printk((o), TRACE, INFO, f, ##a)
+#define nvif_ioctl(o,f,a...) nvif_trace((o), "ioctl: "f, ##a)
#endif
diff --git a/drm/nouveau/include/nvkm/core/device.h b/drm/nouveau/include/nvkm/core/device.h
index 14f7d197e..ffff6fd5a 100644
--- a/drm/nouveau/include/nvkm/core/device.h
+++ b/drm/nouveau/include/nvkm/core/device.h
@@ -214,4 +214,19 @@ enum nv_bus_type {
int nvkm_device_create_(void *, enum nv_bus_type type, u64 name,
const char *sname, const char *cfg, const char *dbg,
int, void **);
+
+/* device logging */
+#define nvdev_printk_(d,l,p,f,a...) do { \
+ struct nvkm_device *_device = (d); \
+ if (_device->engine.subdev.debug >= (l)) \
+ dev_##p(_device->dev, f, ##a); \
+} while(0)
+#define nvdev_printk(d,l,p,f,a...) nvdev_printk_((d), NV_DBG_##l, p, f, ##a)
+#define nvdev_fatal(d,f,a...) nvdev_printk((d), FATAL, crit, f, ##a)
+#define nvdev_error(d,f,a...) nvdev_printk((d), ERROR, err, f, ##a)
+#define nvdev_warn(d,f,a...) nvdev_printk((d), WARN, notice, f, ##a)
+#define nvdev_info(d,f,a...) nvdev_printk((d), INFO, info, f, ##a)
+#define nvdev_debug(d,f,a...) nvdev_printk((d), DEBUG, info, f, ##a)
+#define nvdev_trace(d,f,a...) nvdev_printk((d), TRACE, info, f, ##a)
+#define nvdev_spam(d,f,a...) nvdev_printk((d), SPAM, dbg, f, ##a)
#endif
diff --git a/drm/nouveau/include/nvkm/core/enum.h b/drm/nouveau/include/nvkm/core/enum.h
index e76f76f11..573b1eef4 100644
--- a/drm/nouveau/include/nvkm/core/enum.h
+++ b/drm/nouveau/include/nvkm/core/enum.h
@@ -18,4 +18,5 @@ struct nvkm_bitfield {
};
void nvkm_bitfield_print(const struct nvkm_bitfield *, u32 value);
+void nvkm_snprintbf(char *, int, const struct nvkm_bitfield *, u32 value);
#endif
diff --git a/drm/nouveau/include/nvkm/core/subdev.h b/drm/nouveau/include/nvkm/core/subdev.h
index ad516cf24..e146f2758 100644
--- a/drm/nouveau/include/nvkm/core/subdev.h
+++ b/drm/nouveau/include/nvkm/core/subdev.h
@@ -11,7 +11,7 @@ struct nvkm_subdev {
struct nvkm_device *device;
struct mutex mutex;
- const char *name;
+ const char *name, *sname;
u32 debug;
u32 unit;
@@ -53,11 +53,20 @@ void _nvkm_subdev_dtor(struct nvkm_object *);
int _nvkm_subdev_init(struct nvkm_object *);
int _nvkm_subdev_fini(struct nvkm_object *, bool suspend);
-#define s_printk(s,l,f,a...) do { \
- if ((s)->debug >= OS_DBG_##l) { \
- nv_printk((s)->base.parent, (s)->name, l, f, ##a); \
- } \
+/* subdev logging */
+#define nvkm_printk_(s,l,p,f,a...) do { \
+ struct nvkm_subdev *_subdev = (s); \
+ if (_subdev->debug >= (l)) \
+ dev_##p(_subdev->device->dev, "%s: "f, _subdev->sname, ##a); \
} while(0)
+#define nvkm_printk(s,l,p,f,a...) nvkm_printk_((s), NV_DBG_##l, p, f, ##a)
+#define nvkm_fatal(s,f,a...) nvkm_printk((s), FATAL, crit, f, ##a)
+#define nvkm_error(s,f,a...) nvkm_printk((s), ERROR, err, f, ##a)
+#define nvkm_warn(s,f,a...) nvkm_printk((s), WARN, notice, f, ##a)
+#define nvkm_info(s,f,a...) nvkm_printk((s), INFO, info, f, ##a)
+#define nvkm_debug(s,f,a...) nvkm_printk((s), DEBUG, info, f, ##a)
+#define nvkm_trace(s,f,a...) nvkm_printk((s), TRACE, info, f, ##a)
+#define nvkm_spam(s,f,a...) nvkm_printk((s), SPAM, dbg, f, ##a)
#include <core/engine.h>
#endif
diff --git a/drm/nouveau/nvkm/core/enum.c b/drm/nouveau/nvkm/core/enum.c
index 4f92bfc13..2cfaec406 100644
--- a/drm/nouveau/nvkm/core/enum.c
+++ b/drm/nouveau/nvkm/core/enum.c
@@ -64,3 +64,20 @@ nvkm_bitfield_print(const struct nvkm_bitfield *bf, u32 value)
if (value)
pr_cont(" (unknown bits 0x%08x)", value);
}
+
+void
+nvkm_snprintbf(char *data, int size, const struct nvkm_bitfield *bf, u32 value)
+{
+ bool space = false;
+ while (size >= 1 && bf->name) {
+ if (value & bf->mask) {
+ int this = snprintf(data, size, "%s%s",
+ space ? " " : "", bf->name);
+ size -= this;
+ data += this;
+ space = true;
+ }
+ bf++;
+ }
+ data[0] = '\0';
+}
diff --git a/drm/nouveau/nvkm/core/subdev.c b/drm/nouveau/nvkm/core/subdev.c
index dd2cf44bd..476add5a4 100644
--- a/drm/nouveau/nvkm/core/subdev.c
+++ b/drm/nouveau/nvkm/core/subdev.c
@@ -111,6 +111,7 @@ nvkm_subdev_create_(struct nvkm_object *parent, struct nvkm_object *engine,
__mutex_init(&subdev->mutex, subname, &oclass->lock_class_key);
subdev->name = subname;
+ subdev->sname = sysname;
if (parent) {
struct nvkm_device *device = nv_device(parent);
diff --git a/lib/include/nvif/os.h b/lib/include/nvif/os.h
index 3ed79cc12..84817babc 100644
--- a/lib/include/nvif/os.h
+++ b/lib/include/nvif/os.h
@@ -634,12 +634,14 @@ struct device_driver {
struct device {
struct device_driver *driver;
+ char name[64];
};
-#define dev_crit(d,f,a...) printf("nouveau: "f, ##a)
-#define dev_err(d,f,a...) dev_crit((d), f, ##a)
-#define dev_warn(d,f,a...) dev_crit((d), f, ##a)
-#define dev_info(d,f,a...) dev_crit((d), f, ##a)
+#define dev_crit(d,f,a...) printf("nouveau %s: "f, (d)->name, ##a)
+#define dev_err(d,f,a...) dev_crit((d), f, ##a)
+#define dev_warn(d,f,a...) dev_crit((d), f, ##a)
+#define dev_notice(d,f,a...) dev_crit((d), f, ##a)
+#define dev_info(d,f,a...) dev_crit((d), f, ##a)
/******************************************************************************
* PM runtime
diff --git a/lib/main.c b/lib/main.c
index 6201c3ca3..d1a57a85e 100644
--- a/lib/main.c
+++ b/lib/main.c
@@ -139,7 +139,6 @@ os_init_device(struct pci_device *pdev, u64 handle, const char *cfg, const char
{
struct os_device *odev;
struct pci_dev *ldev;
- char *name, _name[64];
int ret;
ret = pci_device_probe(pdev);
@@ -148,31 +147,28 @@ os_init_device(struct pci_device *pdev, u64 handle, const char *cfg, const char
return ret;
}
- snprintf(_name, sizeof(_name), "%04x:%02x:%02x.%1x",
- pdev->domain, pdev->bus, pdev->dev, pdev->func);
-
list_for_each_entry(odev, &os_device_list, head) {
if (odev->base.handle == handle)
return -EEXIST;
}
- ldev = calloc(1, sizeof(*ldev));
+ ldev = malloc(sizeof(*ldev));
+ snprintf(ldev->dev.name, sizeof(ldev->dev.name), "%04x:%02x:%02x.%1x",
+ pdev->domain, pdev->bus, pdev->dev, pdev->func);
ldev->pdev = pdev;
ldev->device = pdev->dev;
ldev->subsystem_vendor = pdev->subvendor_id;
ldev->subsystem_device = pdev->subdevice_id;
- name = strdup(_name);
- ret = nvkm_device_create(ldev, NVKM_BUS_PCI, handle, name,
+ ret = nvkm_device_create(ldev, NVKM_BUS_PCI, handle, ldev->dev.name,
cfg, dbg, &odev);
if (ret) {
fprintf(stderr, "failed to create device, %d\n", ret);
- free(name);
+ free(ldev);
return ret;
}
list_add_tail(&odev->head, &os_device_list);
- odev->name = name;
return 0;
}
@@ -221,10 +217,9 @@ os_fini(void)
list_for_each_entry_safe(odev, temp, &os_device_list, head) {
struct pci_dev *ldev = odev->base.pdev;
- char *name = odev->name;
list_del(&odev->head);
nvkm_object_ref(NULL, (struct nvkm_object **)&odev);
- free(name); free(ldev);
+ free(ldev);
}
nvkm_object_debug();
diff --git a/lib/null.c b/lib/null.c
index 8f35b944b..910f95d2c 100644
--- a/lib/null.c
+++ b/lib/null.c
@@ -38,6 +38,9 @@ static int null_client_nr = 0;
static struct nvkm_device *null_device;
static struct pci_dev
null_pci_dev = {
+ .dev = {
+ .name = "0000:00:00.0",
+ },
.pdev = &(struct pci_device) {
},
};
diff --git a/lib/priv.h b/lib/priv.h
index 00e304680..cae0acd75 100644
--- a/lib/priv.h
+++ b/lib/priv.h
@@ -9,7 +9,6 @@
struct os_device {
struct nvkm_device base;
struct list_head head;
- char *name;
char *cfg;
char *dbg;
};