Skip to contentSkip to conversation

drm/bridge: ite-it66121: use bulk read, improve probe logging

PATCH New Luca Ceresoli 2 participants 7 messages Nov 27

Subsystems (4)
lore
Share & tools
lore

Luca Ceresoli

author reviewer
#0 lore raw

v2 cover drm/bridge: ite-it66121: use bulk read, improve probe logging

This small series improves it66121_probe() in various ways:

* use a bulk read for reading the vendor and device ID registers
* log errors in ID reading and matching instead of failing silently
* on successful probe be quiet on !DEBUG, more informative on DEBUG

Note there is a separate series fixing probing on the BeagleBone Black rev.D [0]. That is orthogonal and they overall improve probing of this chip.

[0] https://lore.kernel.org/lkml/[email protected]/

---
Changes in v2:
- Split patch 1 in two parts
- Use just a u8[4] array for the bulk read
- Link to v1: https://patch.msgid.link/20261015-drm-ite-it66121-log-probe-errors-v1-0-7fd6994e0be0@bootlin.com

---
Luca Ceresoli (4):
drm/bridge: ite-it66121: check for read errors reading IDs drm/bridge: ite-it66121: simplify getting the chip IDs drm/bridge: ite-it66121: log an error if the IDs do not match drm/bridge: ite-it66121: make successful probe quiet

 drivers/gpu/drm/bridge/ite-it66121.c | 30 +++++++++++++++++++-----------
 1 file changed, 19 insertions(+), 11 deletions(-)

---
base-commit: f210da5b4aace6919f2723586d22126b73c0e31a
change-id: 20261015-drm-ite-it66121-log-probe-errors-9c8cfef8a7f7

Best regards,

Signature · 3 lines
Luca Ceresoli, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
author reviewer
#1 lore raw

PATCH v2 1/4 drm/bridge: ite-it66121: check for read errors reading IDs

it66121_probe() calls regmap_read() four times to read the vendor and device ID registers, without error checking. This leads to silently continuing using invalid ID values when any of the reads fail (which has happened and is being fixed [0]).

Adding error checking on all 4 regmap_read()s would be annoying, so switch to regmap_bulk_read().

[0] https://lore.kernel.org/lkml/[email protected]/

---

Changes in v2:
- Use just a u8 array (Javier)
- Split v1 patch 1 in two parts (Javier)

---
 drivers/gpu/drm/bridge/ite-it66121.c | 19 ++++++++++---------
 1 file changed, 10 insertions(+), 9 deletions(-)
drivers/gpu/drm/bridge/ite-it66121.c +10 -9
index 34302db25a8e..8bc96ef006f8 100644
@@ -1572,7 +1572,8 @@ static const struct it66121_chip_info it66xx_chip_info[] = {
 
 static int it66121_probe(struct i2c_client *client)
 {
-	u32 revision_id, vendor_ids[2] = { 0 }, device_ids[2] = { 0 };
+	__u8 chip_id_regs[4];
+	u32 revision_id;
 	struct device_node *ep;
 	int ret, i;
 	struct it66121_ctx *ctx;
@@ -1636,19 +1637,19 @@ static int it66121_probe(struct i2c_client *client)
 	if (IS_ERR(ctx->regmap))
 		return PTR_ERR(ctx->regmap);
 
-	regmap_read(ctx->regmap, IT66121_VENDOR_ID0_REG, &vendor_ids[0]);
-	regmap_read(ctx->regmap, IT66121_VENDOR_ID1_REG, &vendor_ids[1]);
-	regmap_read(ctx->regmap, IT66121_DEVICE_ID0_REG, &device_ids[0]);
-	regmap_read(ctx->regmap, IT66121_DEVICE_ID1_REG, &device_ids[1]);
+	ret = regmap_bulk_read(ctx->regmap, IT66121_VENDOR_ID0_REG,
+			       &chip_id_regs, sizeof(chip_id_regs));
+	if (ret)
+		return dev_err_probe(dev, ret, "Error reading device IDs\n");
 
 	/* Revision is shared with DEVICE_ID1 */
-	revision_id = FIELD_GET(IT66121_REVISION_MASK, device_ids[1]);
-	device_ids[1] &= IT66121_DEVICE_ID1_MASK;
+	revision_id = FIELD_GET(IT66121_REVISION_MASK, chip_id_regs[3]);
+	chip_id_regs[3] &= IT66121_DEVICE_ID1_MASK;
 
 	for (i = 0; i < ARRAY_SIZE(it66xx_chip_info); i++) {
 		chip_info = &it66xx_chip_info[i];
-		if ((vendor_ids[1] << 8 | vendor_ids[0]) == chip_info->vid &&
-		    (device_ids[1] << 8 | device_ids[0]) == chip_info->pid) {
+		if ((chip_id_regs[1] << 8 | chip_id_regs[0]) == chip_info->vid &&
+		    (chip_id_regs[3] << 8 | chip_id_regs[2]) == chip_info->pid) {
 			ctx->id = chip_info->id;
 			break;
 		}
Signature · 1 line
2.56.1
author reviewer
#2 lore raw

PATCH v2 2/4 drm/bridge: ite-it66121: simplify getting the chip IDs

In reply to Luca Ceresoli

Simplify how the vendor and device ID are computed by using get_unaligned_le16 instead of open-coded bit operations.

While there, also store the IDs into variables and log them for debugging.

---

Changes in v2:
- new patch, split out of v1 patch 1 (Javier)

---
 drivers/gpu/drm/bridge/ite-it66121.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
drivers/gpu/drm/bridge/ite-it66121.c +7 -2
index 8bc96ef006f8..4642a32f1bd0 100644
@@ -1573,6 +1573,7 @@ static const struct it66121_chip_info it66xx_chip_info[] = {
 static int it66121_probe(struct i2c_client *client)
 {
 	__u8 chip_id_regs[4];
+	u16 vendor_id, device_id;
 	u32 revision_id;
 	struct device_node *ep;
 	int ret, i;
@@ -1646,10 +1647,14 @@ static int it66121_probe(struct i2c_client *client)
 	revision_id = FIELD_GET(IT66121_REVISION_MASK, chip_id_regs[3]);
 	chip_id_regs[3] &= IT66121_DEVICE_ID1_MASK;
 
+	vendor_id = get_unaligned_le16(&chip_id_regs[0]);
+	device_id = get_unaligned_le16(&chip_id_regs[2]);
+	dev_dbg(dev, "vendor %04x device %04x (rev %01x)\n", vendor_id, device_id, revision_id);
+
 	for (i = 0; i < ARRAY_SIZE(it66xx_chip_info); i++) {
 		chip_info = &it66xx_chip_info[i];
-		if ((chip_id_regs[1] << 8 | chip_id_regs[0]) == chip_info->vid &&
-		    (chip_id_regs[3] << 8 | chip_id_regs[2]) == chip_info->pid) {
+		if (vendor_id == chip_info->vid &&
+		    device_id == chip_info->pid) {
 			ctx->id = chip_info->id;
 			break;
 		}
Signature · 1 line
2.56.1
#3 lore raw

Re: [PATCH v2 2/4] drm/bridge: ite-it66121: simplify getting the chip IDs

Thank you for your contribution! Sashiko AI review found 1 potential issue to consider: - [High] drm/bridge: ite-it66121: missing linux/unaligned.h include in it66121_probe() --

Thank you for your contribution! Sashiko AI review found 1 potential issue to consider:
- [High] drm/bridge: ite-it66121: missing linux/unaligned.h include in it66121_probe()
--

commit 86dd14ece48e024d13ff3916942d669c127f8cf0
Author: Luca Ceresoli <[email protected]>

drm/bridge: ite-it66121: simplify getting the chip IDs

This commit replaces open-coded bit shifts with get_unaligned_le16() to compute the vendor and device IDs in it66121_probe() and logs them with dev_dbg().

Quoted 13 lines
drivers/gpu/drm/bridge/ite-it66121.c +1 -0
index fe3c48df85388..909a21fac8c02 100644
@@ -1570,6 +1570,7 @@ static const struct it66121_chip_info it66xx_chip_info[] = {
 static int it66121_probe(struct i2c_client *client)
 {
 	__u8 chip_id_regs[4];
+	u16 vendor_id, device_id;
 	u32 revision_id;
 	struct device_node *ep;
 	int ret, i;

drivers/gpu/drm/bridge/ite-it66121.c static int it66121_probe(struct i2c_client *client) · line 1648

Quoted 5 lines
drivers/gpu/drm/bridge/ite-it66121.c +2 -0
@@ -1643,10 +1644,14 @@ static int it66121_probe(struct i2c_client *client)
 	revision_id = FIELD_GET(IT66121_REVISION_MASK, chip_id_regs[3]);
 	chip_id_regs[3] &= IT66121_DEVICE_ID1_MASK;
 
+	vendor_id = get_unaligned_le16(&chip_id_regs[0]);
+	device_id = get_unaligned_le16(&chip_id_regs[2]);

[Severity: High]
Does drivers/gpu/drm/bridge/ite-it66121.c need to include <linux/unaligned.h> for get_unaligned_le16()? Without it, the build fails with an implicit declaration of get_unaligned_le16() on architectures such as arm64 and x86_64 that do not pull in linux/unaligned.h transitively.

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/20261127-drm-ite-it66121-log-probe-errors-v2-0-dbe9b5a3c5df@bootlin.com?part=2
author reviewer
#4 lore raw

PATCH v2 3/4 drm/bridge: ite-it66121: log an error if the IDs do not match

In reply to Luca Ceresoli

If the IDs read from the chip do not match any of the known models, it66121_probe() fails silently, making troubleshooting unnecessarily difficult. Log an error to clarify the failure reason, showing the IDs read from the hardware.

---
 drivers/gpu/drm/bridge/ite-it66121.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/bridge/ite-it66121.c +2 -1
index 4642a32f1bd0..596c31f3d5a9 100644
@@ -1661,7 +1661,8 @@ static int it66121_probe(struct i2c_client *client)
 	}
 
 	if (i == ARRAY_SIZE(it66xx_chip_info))
-		return -ENODEV;
+		return dev_err_probe(dev, -ENODEV, "Unknown vendor %04x device %04x (rev %01x)\n",
+				     vendor_id, device_id, revision_id);
 
 	ctx->bridge.of_node = dev->of_node;
 	ctx->bridge.type = DRM_MODE_CONNECTOR_HDMIA;
Signature · 1 line
2.56.1
author reviewer
#5 lore raw

PATCH v2 4/4 drm/bridge: ite-it66121: make successful probe quiet

In reply to Luca Ceresoli

When drivers are working properly they should be quiet. Turn the dev_info() into a dev_dbg(). While there, also make it more informative.

---
 drivers/gpu/drm/bridge/ite-it66121.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/bridge/ite-it66121.c +2 -1
index 596c31f3d5a9..d11f947e33b2 100644
@@ -1698,7 +1698,8 @@ static int it66121_probe(struct i2c_client *client)
 
 	drm_bridge_add(&ctx->bridge);
 
-	dev_info(ctx->dev, "IT66121 revision %d probed\n", revision_id);
+	dev_dbg(ctx->dev, "IT66121 vendor %04x device %04x revision %d probed\n",
+		vendor_id, device_id, revision_id);
 
 	return 0;
 }
Signature · 1 line
2.56.1
#6 lore raw

Re: [PATCH v2 4/4] drm/bridge: ite-it66121: make successful probe quiet

Thank you for your contribution! Sashiko AI review found 2 potential issues to consider: - [High] drm/bridge: ite-it66121: missing linux/unaligned.h include in it66121_probe() - [Low] drm/bridge…

Thank you for your contribution! Sashiko AI review found 2 potential issues to consider:
- [High] drm/bridge: ite-it66121: missing linux/unaligned.h include in it66121_probe()
- [Low] drm/bridge: ite-it66121: duplicate chip ID dev_dbg() in it66121_probe()
--

commit 46732f4e982566f4573478b485add2d91b24ff1a
Author: Luca Ceresoli <[email protected]>

drm/bridge: ite-it66121: make successful probe quiet

This commit converts the final probe message in it66121_probe() from dev_info() to dev_dbg() and includes vendor_id and device_id in the log string.

Quoted 5 lines
drivers/gpu/drm/bridge/ite-it66121.c +0 -0
index 48f320df8fe77..04e84def2d1b3 100644

drivers/gpu/drm/bridge/ite-it66121.c static int it66121_probe(struct i2c_client *client) · line 1702

Quoted 9 lines
drivers/gpu/drm/bridge/ite-it66121.c +2 -1
@@ -1695,7 +1695,8 @@ static int it66121_probe(struct i2c_client *client)
 
 	drm_bridge_add(&ctx->bridge);
 
-	dev_info(ctx->dev, "IT66121 revision %d probed\n", revision_id);
+	dev_dbg(ctx->dev, "IT66121 vendor %04x device %04x revision %d probed\n",
+		vendor_id, device_id, revision_id);
 
 	return 0;
 }

[Severity: High]
Does drivers/gpu/drm/bridge/ite-it66121.c need to include linux/unaligned.h for the get_unaligned_le16() calls computing vendor_id and device_id (added earlier in the series by commit "drm/bridge: ite-it66121: simplify getting the chip IDs")?

On architectures such as x86_64 and arm64 where asm/uaccess.h does not pull in linux/unaligned.h transitively, building this driver fails with an implicit declaration of get_unaligned_le16().

[Severity: Low]
Does this dev_dbg() duplicate the chip ID debug message added earlier in it66121_probe() by commit "drm/bridge: ite-it66121: simplify getting the chip IDs"?

drivers/gpu/drm/bridge/ite-it66121.c:it66121_probe() {
    ...
	vendor_id = get_unaligned_le16(&chip_id_regs[0]);
	device_id = get_unaligned_le16(&chip_id_regs[2]);
	dev_dbg(dev, "vendor %04x device %04x (rev %01x)\n", vendor_id, device_id, revision_id);
    ...
}

When dynamic debug is enabled, every successful probe prints both messages with the same IDs, formatting revision_id in hex (%01x) in the first and in decimal (%d) in the second.

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/20261127-drm-ite-it66121-log-probe-errors-v2-0-dbe9b5a3c5df@bootlin.com?part=4