Skip to contentSkip to conversation

drm: core: Convert logging to drm_* functions.

PATCH In review Suraj Upadhyay 4 participants 16 messages Jul 7, 2020 – Jul 16, 2020

Subsystems (2)
lore
Share & tools
lore
#1 lore raw

PATCH 1/4 drm: mipi-dsi: Convert logging to drm_* functions.

In reply to Suraj Upadhyay

Convert logging errors from dev_err() to drm_err().

---
 drivers/gpu/drm/drm_mipi_dsi.c | 15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)
drivers/gpu/drm/drm_mipi_dsi.c +7 -8
index 07102d8da58f..5dd475e82995 100644
@@ -34,6 +34,7 @@
 #include <linux/slab.h>
 
 #include <drm/drm_dsc.h>
+#include <drm/drm_print.h>
 #include <video/mipi_display.h>
 
 /**
@@ -155,19 +156,18 @@ static int mipi_dsi_device_add(struct mipi_dsi_device *dsi)
 static struct mipi_dsi_device *
 of_mipi_dsi_device_add(struct mipi_dsi_host *host, struct device_node *node)
 {
-	struct device *dev = host->dev;
 	struct mipi_dsi_device_info info = { };
 	int ret;
 	u32 reg;
 
 	if (of_modalias_node(node, info.type, sizeof(info.type)) < 0) {
-		dev_err(dev, "modalias failure on %pOF\n", node);
+		drm_err(host, "modalias failure on %pOF\n", node);
 		return ERR_PTR(-EINVAL);
 	}
 
 	ret = of_property_read_u32(node, "reg", &reg);
 	if (ret) {
-		dev_err(dev, "device node %pOF has no valid reg property: %d\n",
+		drm_err(host, "device node %pOF has no valid reg property: %d\n",
 			node, ret);
 		return ERR_PTR(-EINVAL);
 	}
@@ -202,22 +202,21 @@ mipi_dsi_device_register_full(struct mipi_dsi_host *host,
 			      const struct mipi_dsi_device_info *info)
 {
 	struct mipi_dsi_device *dsi;
-	struct device *dev = host->dev;
 	int ret;
 
 	if (!info) {
-		dev_err(dev, "invalid mipi_dsi_device_info pointer\n");
+		drm_err(host, "invalid mipi_dsi_device_info pointer\n");
 		return ERR_PTR(-EINVAL);
 	}
 
 	if (info->channel > 3) {
-		dev_err(dev, "invalid virtual channel: %u\n", info->channel);
+		drm_err(host, "invalid virtual channel: %u\n", info->channel);
 		return ERR_PTR(-EINVAL);
 	}
 
 	dsi = mipi_dsi_device_alloc(host);
 	if (IS_ERR(dsi)) {
-		dev_err(dev, "failed to allocate DSI device %ld\n",
+		drm_err(host, "failed to allocate DSI device %ld\n",
 			PTR_ERR(dsi));
 		return dsi;
 	}
@@ -228,7 +227,7 @@ mipi_dsi_device_register_full(struct mipi_dsi_host *host,
 
 	ret = mipi_dsi_device_add(dsi);
 	if (ret) {
-		dev_err(dev, "failed to add DSI device %d\n", ret);
+		drm_err(host, "failed to add DSI device %d\n", ret);
 		kfree(dsi);
 		return ERR_PTR(ret);
 	}
Signature · 1 line
2.17.1
#0 lore raw

cover drm: core: Convert logging to drm_* functions.

This patchset converts logging to drm_* functions in drm core.

The following functions have been converted to their respective DRM alternatives :

dev_info()      --> drm_info()
dev_err()       --> drm_err()
dev_warn()      --> drm_warn()
dev_err_once()  --> drm_err_once().

Suraj Upadhyay (4):
drm: mipi-dsi: Convert logging to drm_* functions.
drm: mipi-dbi: Convert logging to drm_* functions.
drm: edid: Convert logging to drm_* functions.
drm: fb-helper: Convert logging to drm_* functions.

 drivers/gpu/drm/drm_edid.c      |  7 +++----
 drivers/gpu/drm/drm_fb_helper.c |  2 +-
 drivers/gpu/drm/drm_mipi_dbi.c  |  4 ++--
 drivers/gpu/drm/drm_mipi_dsi.c  | 15 +++++++--------
 4 files changed, 13 insertions(+), 15 deletions(-)
Signature · 1 line
2.17.1
#3 lore raw

PATCH 2/4 drm: mipi-dbi: Convert logging to drm_* functions.

Convert logging of errors once from dev_err_once() to drm_err_once().

---
 drivers/gpu/drm/drm_mipi_dbi.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/drm_mipi_dbi.c +2 -2
index 79532b9a324a..ccfb6eb1a29f 100644
@@ -225,7 +225,7 @@ int mipi_dbi_buf_copy(void *dst, struct drm_framebuffer *fb,
 		drm_fb_xrgb8888_to_rgb565(dst, src, fb, clip, swap);
 		break;
 	default:
-		dev_err_once(fb->dev->dev, "Format is not supported: %s\n",
+		drm_err_once(fb->dev, "Format is not supported: %s\n",
 			     drm_get_format_name(fb->format->format,
 						 &format_name));
 		return -EINVAL;
@@ -295,7 +295,7 @@ static void mipi_dbi_fb_dirty(struct drm_framebuffer *fb, struct drm_rect *rect)
 				   width * height * 2);
 err_msg:
 	if (ret)
-		dev_err_once(fb->dev->dev, "Failed to update display %d\n", ret);
+		drm_err_once(fb->dev, "Failed to update display %d\n", ret);
 
 	drm_dev_exit(idx);
 }
Signature · 1 line
2.17.1
#4 lore raw

PATCH 3/4 drm: edid: Convert logging to drm_* functions.

In reply to Suraj Upadhyay

Change logging of warnings to drm_warn() form dev_warn().

---
 drivers/gpu/drm/drm_edid.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
drivers/gpu/drm/drm_edid.c +3 -4
index 31496b6cfc56..ad7a1f9817ed 100644
@@ -1844,9 +1844,8 @@ static void connector_bad_edid(struct drm_connector *connector,
 	if (connector->bad_edid_counter++ && !drm_debug_enabled(DRM_UT_KMS))
 		return;
 
-	dev_warn(connector->dev->dev,
-		 "%s: EDID is invalid:\n",
-		 connector->name);
+	drm_warn(connector->dev, "%s: EDID is invalid:\n", connector->name);
+
 	for (i = 0; i < num_blocks; i++) {
 		u8 *block = edid + i * EDID_LENGTH;
 		char prefix[20];
@@ -5284,7 +5283,7 @@ int drm_add_edid_modes(struct drm_connector *connector, struct edid *edid)
 	}
 	if (!drm_edid_is_valid(edid)) {
 		clear_eld(connector);
-		dev_warn(connector->dev->dev, "%s: EDID invalid.\n",
+		drm_warn(connector->dev, "%s: EDID invalid.\n",
 			 connector->name);
 		return 0;
 	}
Signature · 1 line
2.17.1
#6 lore raw

PATCH 4/4 drm: fb-helper: Convert logging to drm_* functions.

In reply to Suraj Upadhyay

Change logging information from dev_info() to drm_info().

---
 drivers/gpu/drm/drm_fb_helper.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/drm_fb_helper.c +1 -1
index 5609e164805f..88146f7245c5 100644
@@ -1819,7 +1819,7 @@ __drm_fb_helper_initial_config_and_unlock(struct drm_fb_helper *fb_helper,
 	if (ret < 0)
 		return ret;
 
-	dev_info(dev->dev, "fb%d: %s frame buffer device\n",
+	drm_info(dev, "fb%d: %s frame buffer device\n",
 		 info->node, info->fix.id);
 
 	mutex_lock(&kernel_fb_helper_lock);
Signature · 1 line
2.17.1
maintainer Reviewed-by on v1 3/4
#5 lore raw

Re: [PATCH 3/4] drm: edid: Convert logging to drm_* functions.

In reply to Suraj Upadhyay

Thanks!

Am 07.07.20 um 18:36 schrieb Suraj Upadhyay:

Quoted 3 lines

Change logging of warnings to drm_warn() form dev_warn().

Quoted 30 lines
---
 drivers/gpu/drm/drm_edid.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
drivers/gpu/drm/drm_edid.c +3 -4
index 31496b6cfc56..ad7a1f9817ed 100644
@@ -1844,9 +1844,8 @@ static void connector_bad_edid(struct drm_connector *connector,
 	if (connector->bad_edid_counter++ && !drm_debug_enabled(DRM_UT_KMS))
 		return;
 
-	dev_warn(connector->dev->dev,
-		 "%s: EDID is invalid:\n",
-		 connector->name);
+	drm_warn(connector->dev, "%s: EDID is invalid:\n", connector->name);
+
 	for (i = 0; i < num_blocks; i++) {
 		u8 *block = edid + i * EDID_LENGTH;
 		char prefix[20];
@@ -5284,7 +5283,7 @@ int drm_add_edid_modes(struct drm_connector *connector, struct edid *edid)
 	}
 	if (!drm_edid_is_valid(edid)) {
 		clear_eld(connector);
-		dev_warn(connector->dev->dev, "%s: EDID invalid.\n",
+		drm_warn(connector->dev, "%s: EDID invalid.\n",
 			 connector->name);
 		return 0;
 	}
Signature · 6 lines
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Maxfeldstr. 5, 90409 Nürnberg, Germany
(HRB 36809, AG Nürnberg)
Geschäftsführer: Felix Imendörffer

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

maintainer Reviewed-by on v1 4/4
#7 lore raw

Re: [PATCH 4/4] drm: fb-helper: Convert logging to drm_* functions.

In reply to Suraj Upadhyay

Am 07.07.20 um 18:37 schrieb Suraj Upadhyay:

Quoted 3 lines

Change logging information from dev_info() to drm_info().

Quoted 18 lines
---
 drivers/gpu/drm/drm_fb_helper.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/drm_fb_helper.c +1 -1
index 5609e164805f..88146f7245c5 100644
@@ -1819,7 +1819,7 @@ __drm_fb_helper_initial_config_and_unlock(struct drm_fb_helper *fb_helper,
 	if (ret < 0)
 		return ret;
 
-	dev_info(dev->dev, "fb%d: %s frame buffer device\n",
+	drm_info(dev, "fb%d: %s frame buffer device\n",
 		 info->node, info->fix.id);
 
 	mutex_lock(&kernel_fb_helper_lock);
Signature · 6 lines
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Maxfeldstr. 5, 90409 Nürnberg, Germany
(HRB 36809, AG Nürnberg)
Geschäftsführer: Felix Imendörffer
#9 lore raw
In reply to Suraj Upadhyay

Hi Suraj.

Quoted 9 lines · Suraj Upadhyay

This patchset converts logging to drm_* functions in drm core.

The following functions have been converted to their respective DRM alternatives :

dev_info()      --> drm_info()
dev_err()       --> drm_err()
dev_warn()      --> drm_warn()
dev_err_once()  --> drm_err_once().

I would prefer that DRM_* logging in the same files are converted in the same patch. So we have one logging conversion patch for each file you touches and that we do not need to re-vist the files later to change another set of logging functions.
If possible WARN_* should also be converted to drm_WARN_*
If patch is too large, then split them up but again lets have all logging updated when we touch a file.

Care to take a look at this approach?

Also please consider if coccinelle can make this job easier. There is a lot of files...

Sam

Quoted 7 lines

Suraj Upadhyay (4):
drm: mipi-dsi: Convert logging to drm_* functions.
drm: mipi-dbi: Convert logging to drm_* functions.
drm: edid: Convert logging to drm_* functions.
drm: fb-helper: Convert logging to drm_* functions.

Quoted 17 lines
 drivers/gpu/drm/drm_edid.c      |  7 +++----
 drivers/gpu/drm/drm_fb_helper.c |  2 +-
 drivers/gpu/drm/drm_mipi_dbi.c  |  4 ++--
 drivers/gpu/drm/drm_mipi_dsi.c  | 15 +++++++--------
 4 files changed, 13 insertions(+), 15 deletions(-)
Signature · 10 lines
2.17.1





_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#2 lore raw

Re: [PATCH 1/4] drm: mipi-dsi: Convert logging to drm_* functions.

In reply to Suraj Upadhyay
Quoted 3 lines · Suraj Upadhyay

Convert logging errors from dev_err() to drm_err().

Thanks. Applied to drm-misc-next as there was no more logging conversion to do in this file.

Sam

Quoted 80 lines
---
 drivers/gpu/drm/drm_mipi_dsi.c | 15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)
drivers/gpu/drm/drm_mipi_dsi.c +7 -8
index 07102d8da58f..5dd475e82995 100644
@@ -34,6 +34,7 @@
 #include <linux/slab.h>
 
 #include <drm/drm_dsc.h>
+#include <drm/drm_print.h>
 #include <video/mipi_display.h>
 
 /**
@@ -155,19 +156,18 @@ static int mipi_dsi_device_add(struct mipi_dsi_device *dsi)
 static struct mipi_dsi_device *
 of_mipi_dsi_device_add(struct mipi_dsi_host *host, struct device_node *node)
 {
-	struct device *dev = host->dev;
 	struct mipi_dsi_device_info info = { };
 	int ret;
 	u32 reg;
 
 	if (of_modalias_node(node, info.type, sizeof(info.type)) < 0) {
-		dev_err(dev, "modalias failure on %pOF\n", node);
+		drm_err(host, "modalias failure on %pOF\n", node);
 		return ERR_PTR(-EINVAL);
 	}
 
 	ret = of_property_read_u32(node, "reg", &reg);
 	if (ret) {
-		dev_err(dev, "device node %pOF has no valid reg property: %d\n",
+		drm_err(host, "device node %pOF has no valid reg property: %d\n",
 			node, ret);
 		return ERR_PTR(-EINVAL);
 	}
@@ -202,22 +202,21 @@ mipi_dsi_device_register_full(struct mipi_dsi_host *host,
 			      const struct mipi_dsi_device_info *info)
 {
 	struct mipi_dsi_device *dsi;
-	struct device *dev = host->dev;
 	int ret;
 
 	if (!info) {
-		dev_err(dev, "invalid mipi_dsi_device_info pointer\n");
+		drm_err(host, "invalid mipi_dsi_device_info pointer\n");
 		return ERR_PTR(-EINVAL);
 	}
 
 	if (info->channel > 3) {
-		dev_err(dev, "invalid virtual channel: %u\n", info->channel);
+		drm_err(host, "invalid virtual channel: %u\n", info->channel);
 		return ERR_PTR(-EINVAL);
 	}
 
 	dsi = mipi_dsi_device_alloc(host);
 	if (IS_ERR(dsi)) {
-		dev_err(dev, "failed to allocate DSI device %ld\n",
+		drm_err(host, "failed to allocate DSI device %ld\n",
 			PTR_ERR(dsi));
 		return dsi;
 	}
@@ -228,7 +227,7 @@ mipi_dsi_device_register_full(struct mipi_dsi_host *host,
 
 	ret = mipi_dsi_device_add(dsi);
 	if (ret) {
-		dev_err(dev, "failed to add DSI device %d\n", ret);
+		drm_err(host, "failed to add DSI device %d\n", ret);
 		kfree(dsi);
 		return ERR_PTR(ret);
 	}
Signature · 6 lines
2.17.1

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#8 lore raw

Re: [PATCH 4/4] drm: fb-helper: Convert logging to drm_* functions.

In reply to Suraj Upadhyay
Quoted 3 lines · Suraj Upadhyay

Change logging information from dev_info() to drm_info().

Thanks. Applied to drm-misc-next.

Also, because there was no more logging functions that needed an update.

Sam

Quoted 27 lines
---
 drivers/gpu/drm/drm_fb_helper.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/drm_fb_helper.c +1 -1
index 5609e164805f..88146f7245c5 100644
@@ -1819,7 +1819,7 @@ __drm_fb_helper_initial_config_and_unlock(struct drm_fb_helper *fb_helper,
 	if (ret < 0)
 		return ret;
 
-	dev_info(dev->dev, "fb%d: %s frame buffer device\n",
+	drm_info(dev, "fb%d: %s frame buffer device\n",
 		 info->node, info->fix.id);
 
 	mutex_lock(&kernel_fb_helper_lock);
Signature · 9 lines
2.17.1




_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#10 lore raw
In reply to Sam Ravnborg
Quoted 13 lines · Sam Ravnborg

Hi Suraj.

Quoted 9 lines · Suraj Upadhyay

This patchset converts logging to drm_* functions in drm core.

The following functions have been converted to their respective DRM alternatives :

dev_info()      --> drm_info()
dev_err()       --> drm_err()
dev_warn()      --> drm_warn()
dev_err_once()  --> drm_err_once().
Quoted 4 lines

I would prefer that DRM_* logging in the same files are converted in the same patch. So we have one logging conversion patch for each file you touches and that we do not need to re-vist the files later to change another set of logging functions.

Agreed.

Quoted 6 lines

If possible WARN_* should also be converted to drm_WARN_* If patch is too large, then split them up but again lets have all logging updated when we touch a file.

Care to take a look at this approach?

Hii,
The problem with WARN_* macros is that they are used without any
drm device context. For example [this use here](https://cgit.freedesktop.org/drm/drm-misc/tree/drivers/gpu/drm/drm_edid.c#n1667) in drm_edid.c, doesn't have a drm device context and only has one argument (namely !raw_edid).
There are many more such use cases.

And also there were cases where dev_* logging functions didn't have any drm_device context.

I would be very glad, if we came up with a possible solution to this problem. I think we should develop drm_* logging APIs which could print contextless logs (which would possibly be midlyering) or give every situation a context.

Quoted 2 lines

Also please consider if coccinelle can make this job easier. There is a lot of files...

I totally agree with you. I will remember this next time.

But here, in this patchset I have tried to convert all possible cases of conversion, i.e. I have changed logging wherever there was a drm_device context.

Thanks.

Quoted 27 lines

Sam

Quoted 24 lines

Suraj Upadhyay (4):
drm: mipi-dsi: Convert logging to drm_* functions.
drm: mipi-dbi: Convert logging to drm_* functions.
drm: edid: Convert logging to drm_* functions.
drm: fb-helper: Convert logging to drm_* functions.

 drivers/gpu/drm/drm_edid.c      |  7 +++----
 drivers/gpu/drm/drm_fb_helper.c |  2 +-
 drivers/gpu/drm/drm_mipi_dbi.c  |  4 ++--
 drivers/gpu/drm/drm_mipi_dsi.c  | 15 +++++++--------
 4 files changed, 13 insertions(+), 15 deletions(-)
Signature · 10 lines
2.17.1





_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#11 lore raw
Quoted 27 lines · Suraj Upadhyay
Quoted 12 lines · Sam Ravnborg

Hi Suraj.

Quoted 8 lines · Suraj Upadhyay

This patchset converts logging to drm_* functions in drm core.

The following functions have been converted to their respective DRM alternatives :

dev_info()      --> drm_info()
dev_err()       --> drm_err()
dev_warn()      --> drm_warn()
dev_err_once()  --> drm_err_once().
Quoted 4 lines

I would prefer that DRM_* logging in the same files are converted in the same patch. So we have one logging conversion patch for each file you touches and that we do not need to re-vist the files later to change another set of logging functions.

Agreed.

Quoted 6 lines

If possible WARN_* should also be converted to drm_WARN_* If patch is too large, then split them up but again lets have all logging updated when we touch a file.

Care to take a look at this approach?

Quoted 8 lines

Hii,
The problem with WARN_* macros is that they are used without any
drm device context. For example [this use here](https://cgit.freedesktop.org/drm/drm-misc/tree/drivers/gpu/drm/drm_edid.c#n1667) in drm_edid.c, doesn't have a drm device context and only has one argument (namely !raw_edid).
There are many more such use cases.

And also there were cases where dev_* logging functions didn't have any drm_device context.

Perhaps change the __drm_printk macro to not
dereference the drm argument when NULL.

A trivial but perhaps inefficient way might be
used like:

	drm_<level>(NULL, fmt, ...)
---
 include/drm/drm_print.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
include/drm/drm_print.h +2 -2
index 1c9417430d08..9323a8f46b3c 100644
@@ -395,8 +395,8 @@ void drm_dev_dbg(const struct device *dev, enum drm_debug_category category,
 
 /* Helper for struct drm_device based logging. */
 #define __drm_printk(drm, level, type, fmt, ...)			\
-	dev_##level##type((drm)->dev, "[drm] " fmt, ##__VA_ARGS__)
-
+	dev_##level##type((drm) ? (drm)->dev : NULL, "[drm] " fmt,	\
+			  ##__VA_ARGS__)
 
 #define drm_info(drm, fmt, ...)					\
 	__drm_printk((drm), info,, fmt, ##__VA_ARGS__)

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#12 lore raw
Quoted 55 lines · Joe Perches
Quoted 27 lines · Suraj Upadhyay
Quoted 12 lines · Sam Ravnborg

Hi Suraj.

Quoted 8 lines · Suraj Upadhyay

This patchset converts logging to drm_* functions in drm core.

The following functions have been converted to their respective DRM alternatives :

dev_info()      --> drm_info()
dev_err()       --> drm_err()
dev_warn()      --> drm_warn()
dev_err_once()  --> drm_err_once().
Quoted 4 lines

I would prefer that DRM_* logging in the same files are converted in the same patch. So we have one logging conversion patch for each file you touches and that we do not need to re-vist the files later to change another set of logging functions.

Agreed.

Quoted 6 lines

If possible WARN_* should also be converted to drm_WARN_* If patch is too large, then split them up but again lets have all logging updated when we touch a file.

Care to take a look at this approach?

Quoted 8 lines

Hii,
The problem with WARN_* macros is that they are used without any
drm device context. For example [this use here](https://cgit.freedesktop.org/drm/drm-misc/tree/drivers/gpu/drm/drm_edid.c#n1667) in drm_edid.c, doesn't have a drm device context and only has one argument (namely !raw_edid).
There are many more such use cases.

And also there were cases where dev_* logging functions didn't have any drm_device context.

Perhaps change the __drm_printk macro to not
dereference the drm argument when NULL.

A trivial but perhaps inefficient way might be
used like:

	drm_<level>(NULL, fmt, ...)
---
 include/drm/drm_print.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
include/drm/drm_print.h +0 -0
index 1c9417430d08..9323a8f46b3c 100644

include/drm/drm_print.h void drm_dev_dbg(const struct device *dev, enum drm_debug_category category, · line 402

Quoted 10 lines
include/drm/drm_print.h +2 -2
@@ -395,8 +395,8 @@ void drm_dev_dbg(const struct device *dev, enum drm_debug_category category,
 
 /* Helper for struct drm_device based logging. */
 #define __drm_printk(drm, level, type, fmt, ...)			\
-	dev_##level##type((drm)->dev, "[drm] " fmt, ##__VA_ARGS__)
-
+	dev_##level##type((drm) ? (drm)->dev : NULL, "[drm] " fmt,	\
+			  ##__VA_ARGS__)
 
 #define drm_info(drm, fmt, ...)					\
 	__drm_printk((drm), info,, fmt, ##__VA_ARGS__)

Hi Joe,
Thanks for your input.
But I don't think that this change would be a good idea as we are supposed to find or make a substitute of WARN_* macros which take a condition as an argument and check for its truth. And I guess passing a NULL to dev_<level> would cause a format warning.

Also, the WARN_* macros are doing their job fine, and passing a NULL value everytime you want to warn about a certain condition at a particular line, doesn't seem good to me.

Thus, I think that WARN_* macros should be untouched.

I would like to hear what the MAINTAINERS think.

Thanks and Cheers,

Suraj Upadhyay.

#13 lore raw
Quoted 1 line · Suraj Upadhyay

On Sat, Jul 11, 2020 at 11:16:33AM -0700, Joe Perches wrote:

[]

Quoted 7 lines
Quoted 7 lines

Perhaps change the __drm_printk macro to not
dereference the drm argument when NULL.

A trivial but perhaps inefficient way might be
used like:

	drm_<level>(NULL, fmt, ...)

[]

Quoted 1 line

include/drm/drm_print.h

Quoted 1 line
include/drm/drm_print.h +0 -0

[]

Quoted 20 lines

include/drm/drm_print.h void drm_dev_dbg(const struct device *dev, enum drm_debug_category category, · line 402

Quoted 12 lines
include/drm/drm_print.h +2 -2
@@ -395,8 +395,8 @@ void drm_dev_dbg(const struct device *dev, enum drm_debug_category category,
 
 /* Helper for struct drm_device based logging. */
 #define __drm_printk(drm, level, type, fmt, ...)			\
-	dev_##level##type((drm)->dev, "[drm] " fmt, ##__VA_ARGS__)
-
+	dev_##level##type((drm) ? (drm)->dev : NULL, "[drm] " fmt,	\
+			  ##__VA_ARGS__)
 
 #define drm_info(drm, fmt, ...)					\
 	__drm_printk((drm), info,, fmt, ##__VA_ARGS__)

Hi Joe,
Thanks for your input.
But I don't think that this change would be a good idea as we are supposed to find or make a substitute of WARN_* macros which take a condition as an argument and check for its truth. And I guess passing a NULL to dev_<level> would cause a format warning.

Quoted 5 lines

Also, the WARN_* macros are doing their job fine, and passing a NULL value everytime you want to warn about a certain condition at a particular line, doesn't seem good to me.

Thus, I think that WARN_* macros should be untouched.

So do I but the suggestion was not about WARN macros only about drm_<level> macros and possibly unnecessary conversions to dev_<level> when a drm_device context is unavailable.

Also, you don't have to guess, the code is there for you to inspect.

dev_<level> when a NULL is used as the first argument emits "(NULL device *)" instead of dev_driver_string(dev) and dev_name(dev).

See: drivers/base/core.c::__dev_printk()

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#14 lore raw
Quoted 44 lines · Joe Perches
Quoted 1 line · Suraj Upadhyay

On Sat, Jul 11, 2020 at 11:16:33AM -0700, Joe Perches wrote:

[]

Quoted 7 lines
Quoted 7 lines

Perhaps change the __drm_printk macro to not
dereference the drm argument when NULL.

A trivial but perhaps inefficient way might be
used like:

	drm_<level>(NULL, fmt, ...)

[]

Quoted 1 line

include/drm/drm_print.h

Quoted 1 line
include/drm/drm_print.h +0 -0

[]

Quoted 20 lines

include/drm/drm_print.h void drm_dev_dbg(const struct device *dev, enum drm_debug_category category, · line 402

Quoted 12 lines
include/drm/drm_print.h +2 -2
@@ -395,8 +395,8 @@ void drm_dev_dbg(const struct device *dev, enum drm_debug_category category,
 
 /* Helper for struct drm_device based logging. */
 #define __drm_printk(drm, level, type, fmt, ...)			\
-	dev_##level##type((drm)->dev, "[drm] " fmt, ##__VA_ARGS__)
-
+	dev_##level##type((drm) ? (drm)->dev : NULL, "[drm] " fmt,	\
+			  ##__VA_ARGS__)
 
 #define drm_info(drm, fmt, ...)					\
 	__drm_printk((drm), info,, fmt, ##__VA_ARGS__)

Hi Joe,
Thanks for your input.
But I don't think that this change would be a good idea as we are supposed to find or make a substitute of WARN_* macros which take a condition as an argument and check for its truth. And I guess passing a NULL to dev_<level> would cause a format warning.

Quoted 5 lines

Also, the WARN_* macros are doing their job fine, and passing a NULL value everytime you want to warn about a certain condition at a particular line, doesn't seem good to me.

Thus, I think that WARN_* macros should be untouched.

So do I but the suggestion was not about WARN macros only about drm_<level> macros and possibly unnecessary conversions to dev_<level> when a drm_device context is unavailable.

Quoted 8 lines

Also, you don't have to guess, the code is there for you to inspect.

dev_<level> when a NULL is used as the first argument emits "(NULL device *)" instead of dev_driver_string(dev) and dev_name(dev).

See: drivers/base/core.c::__dev_printk()

Yes, Thanks my bad.
But the dev_<level> usages in drm/* always have a context and doesn't need NULL to be passed, i.e. some of them have only a struct device context which cannot be simply converted into drm_<level> since they take a struct pointer with a dev member and not a dev itself.
What we can convert is calls to dev_<level> with a drm_device context or with a struct pointer which has a dev member.

And, I really want the MAINTAINERS to look into it.

Thanks and Cheers,

Suraj Upadhyay.

#15 lore raw
In reply to Suraj Upadhyay

Hi Suraj.

Quoted 34 lines · Suraj Upadhyay
Quoted 13 lines · Sam Ravnborg

Hi Suraj.

Quoted 9 lines · Suraj Upadhyay

This patchset converts logging to drm_* functions in drm core.

The following functions have been converted to their respective DRM alternatives :

dev_info()      --> drm_info()
dev_err()       --> drm_err()
dev_warn()      --> drm_warn()
dev_err_once()  --> drm_err_once().
Quoted 4 lines

I would prefer that DRM_* logging in the same files are converted in the same patch. So we have one logging conversion patch for each file you touches and that we do not need to re-vist the files later to change another set of logging functions.

Agreed.

Quoted 6 lines

If possible WARN_* should also be converted to drm_WARN_* If patch is too large, then split them up but again lets have all logging updated when we touch a file.

Care to take a look at this approach?

Hii,
The problem with WARN_* macros is that they are used without any
drm device context. For example [this use here](https://cgit.freedesktop.org/drm/drm-misc/tree/drivers/gpu/drm/drm_edid.c#n1667) in drm_edid.c, doesn't have a drm device context and only has one argument (namely !raw_edid).
There are many more such use cases.

Quoted 6 lines

And also there were cases where dev_* logging functions didn't have any drm_device context.

I would be very glad, if we came up with a possible solution to this problem. I think we should develop drm_* logging APIs which could print contextless logs (which would possibly be midlyering) or give every situation a context.

This was discussed in the past.
For now the focus is migrating existing logging to the new drm_ based logging. Preferably using coccinelle.
when we are more or less covered there we can discuss if we will add more logging functions.

Quoted 9 lines
Quoted 3 lines

Also please consider if coccinelle can make this job easier. There is a lot of files...

I totally agree with you. I will remember this next time.

But here, in this patchset I have tried to convert all possible cases of conversion, i.e. I have changed logging wherever there was a drm_device context.

Please note this in the changelog when you resend.
I delete your original patches so they are gone now from my mail-box. Yeah, could dig them up somewhere, but it is easier to let you resend them and then we can have an updated changelog too.

Sam

Quoted 33 lines

Thanks.

Quoted 27 lines

Sam

Quoted 24 lines

Suraj Upadhyay (4):
drm: mipi-dsi: Convert logging to drm_* functions.
drm: mipi-dbi: Convert logging to drm_* functions.
drm: edid: Convert logging to drm_* functions.
drm: fb-helper: Convert logging to drm_* functions.

 drivers/gpu/drm/drm_edid.c      |  7 +++----
 drivers/gpu/drm/drm_fb_helper.c |  2 +-
 drivers/gpu/drm/drm_mipi_dbi.c  |  4 ++--
 drivers/gpu/drm/drm_mipi_dsi.c  | 15 +++++++--------
 4 files changed, 13 insertions(+), 15 deletions(-)
Signature · 10 lines
2.17.1





_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoted 4 lines

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel