summaryrefslogtreecommitdiffstats
path: root/kernel/include/nvidia-vgpu-vfio.h
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/include/nvidia-vgpu-vfio.h')
-rw-r--r--kernel/include/nvidia-vgpu-vfio.h40
1 files changed, 29 insertions, 11 deletions
diff --git a/kernel/include/nvidia-vgpu-vfio.h b/kernel/include/nvidia-vgpu-vfio.h
index 3ca5cf6..02c2c13 100644
--- a/kernel/include/nvidia-vgpu-vfio.h
+++ b/kernel/include/nvidia-vgpu-vfio.h
@@ -191,16 +191,34 @@ static inline struct nv_vgpu_device *mdev_to_vgpu(struct mdev_device *mdev)
return dev_get_drvdata(&mdev->dev);
}
-#define nv_vgpu_dbg(vgpu, fmt, ...) \
- dev_dbg(&(vgpu)->dev, "%s: " fmt, __func__, ##__VA_ARGS__)
-
-#define nv_vgpu_info(vgpu, fmt, ...) \
- dev_info(&(vgpu)->dev, "%s: " fmt, __func__, ##__VA_ARGS__)
-
-#define nv_vgpu_warn(vgpu, fmt, ...) \
- dev_warn(&(vgpu)->dev, "%s: " fmt, __func__, ##__VA_ARGS__)
-
-#define nv_vgpu_err(vgpu, fmt, ...) \
- dev_err(&(vgpu)->dev, "%s: " fmt, __func__, ##__VA_ARGS__)
+/* NULL-tolerant logging: emulation paths may run with a NULL vgpu
+ * (e.g. unit tests, early init) - fall back to plain pr_*. */
+#define nv_vgpu_dbg(vgpu, fmt, ...) do { \
+ if (vgpu) \
+ dev_dbg(&(vgpu)->dev, "%s: " fmt, __func__, ##__VA_ARGS__); \
+ else \
+ pr_debug("%s: " fmt, __func__, ##__VA_ARGS__); \
+} while (0)
+
+#define nv_vgpu_info(vgpu, fmt, ...) do { \
+ if (vgpu) \
+ dev_info(&(vgpu)->dev, "%s: " fmt, __func__, ##__VA_ARGS__); \
+ else \
+ pr_info("%s: " fmt, __func__, ##__VA_ARGS__); \
+} while (0)
+
+#define nv_vgpu_warn(vgpu, fmt, ...) do { \
+ if (vgpu) \
+ dev_warn(&(vgpu)->dev, "%s: " fmt, __func__, ##__VA_ARGS__); \
+ else \
+ pr_warn("%s: " fmt, __func__, ##__VA_ARGS__); \
+} while (0)
+
+#define nv_vgpu_err(vgpu, fmt, ...) do { \
+ if (vgpu) \
+ dev_err(&(vgpu)->dev, "%s: " fmt, __func__, ##__VA_ARGS__); \
+ else \
+ pr_err("%s: " fmt, __func__, ##__VA_ARGS__); \
+} while (0)
#endif \ No newline at end of file