* Claude review: drm/scdc-helper: Add scdc_status debugfs entry
2026-05-20 13:35 ` [PATCH v2 1/3] drm/scdc-helper: Add scdc_status debugfs entry Nicolas Frattaroli
@ 2026-05-25 11:49 ` Claude Code Review Bot
0 siblings, 0 replies; 13+ messages in thread
From: Claude Code Review Bot @ 2026-05-25 11:49 UTC (permalink / raw)
To: dri-devel-reviews
Patch Review
This is the bulk of the series — adds `drm_scdc_read_state`, status flag structs, error counter reading, and the debugfs show function. Generally well done, but a few issues:
**1. Inappropriate comment (medium)**
```c
/* why in the fucking fuck does this return a ssize_t */
ret = drm_scdc_read(connector->ddc, SCDC_ERR_DET_0_L, buf, ARRAY_SIZE(buf));
```
This comment is not appropriate for the kernel tree. If you want to note the type mismatch, something like `/* drm_scdc_read returns ssize_t but 0 on success */` would be acceptable.
**2. Bitfield union portability on big-endian (medium)**
```c
struct drm_scdc_status_flags {
union {
struct {
bool clock_detected : 1;
bool ch0_locked : 1;
bool ch1_locked : 1;
bool ch2_locked : 1;
...
} flags __packed;
u8 data;
} status0;
```
GCC orders bitfields from LSB on little-endian targets but from MSB on big-endian targets. On a big-endian system, `clock_detected` would map to bit 7 instead of bit 0 (where `SCDC_CLOCK_DETECT` is defined). This means the bitfield-to-register mapping is wrong on big-endian. Consider using explicit bit masks (the header already defines `SCDC_CLOCK_DETECT`, `SCDC_CH0_LOCK`, etc.) and accessor functions instead, or adding an endianness guard/comment explaining why this is acceptable.
**3. Doc typo**
```c
/** @scramling_enabled: true if TMDS scrambling is on */
```
Should be `@scrambling_enabled`.
**4. Status reading clears update flag before reading the register**
In `drm_scdc_read_status0_flags`:
```c
ret = drm_scdc_writeb(connector->ddc, SCDC_UPDATE_0, SCDC_STATUS_UPDATE);
if (ret)
return ret;
return drm_scdc_readb(connector->ddc, SCDC_STATUS_FLAGS_0, &flags->status0.data);
```
The update flag is cleared (by writing 1 to it) *before* reading the status register. There's a small race window where the sink could update the status between the clear and the read, meaning the source wouldn't know to re-read later. For debugfs this is fine, but since `drm_scdc_read_status0_flags` is exported as a general-purpose API, consider documenting this behavior or swapping the order (read first, then clear). The same pattern appears in `drm_scdc_read_error_counters` with `SCDC_CED_UPDATE`, though for CED clearing before reading is the spec-mandated behavior, so that one is correct.
**5. Minor: `status1` bitfields are all reserved and unused**
The `status1` member in `drm_scdc_status_flags` has 8 reserved bool bitfields but is never read or displayed in this patch. This is fine since patch 3 replaces them, but in isolation patch 1 adds dead code.
---
Generated by Claude Code Patch Reviewer
^ permalink raw reply [flat|nested] 13+ messages in thread
* Claude review: drm/scdc-helper: Add scdc_status debugfs entry
2026-05-26 10:19 ` [PATCH v3 2/4] drm/scdc-helper: Add scdc_status debugfs entry Nicolas Frattaroli
@ 2026-05-27 5:01 ` Claude Code Review Bot
0 siblings, 0 replies; 13+ messages in thread
From: Claude Code Review Bot @ 2026-05-27 5:01 UTC (permalink / raw)
To: dri-devel-reviews
Patch Review
This is the core patch. Several observations:
**Bitfield portability (issue):** The `drm_scdc_status_flags` struct uses a union of `bool` bitfields with `u8 data`:
```c
union {
struct {
bool clock_detected : 1;
bool ch0_locked : 1;
bool ch1_locked : 1;
bool ch2_locked : 1;
...
} flags __packed;
u8 data;
} status0;
```
Bitfield ordering within a storage unit is implementation-defined. GCC allocates from LSB on little-endian targets and from MSB on big-endian targets. On a big-endian system, `clock_detected` would map to bit 7, not bit 0 as the SCDC register defines (`SCDC_CLOCK_DETECT` = `(1 << 0)`). The kernel handles this elsewhere (e.g., `struct iphdr`) using `#if defined(__LITTLE_ENDIAN_BITFIELD)` / `#elif defined(__BIG_ENDIAN_BITFIELD)` guards. The DRM subsystem doesn't currently use this pattern (no hits in `include/drm/`), but these bitfields directly overlay a hardware register byte, which is where it matters. Consider using explicit bit masks and shifts instead, or adding endianness guards.
**Conditional reads from update flags (design concern):** In `drm_scdc_read_state`, status flags and error counters are only read when the corresponding update flags are set:
```c
if (upd_flags[0] & SCDC_STATUS_UPDATE) {
ret = drm_scdc_read_status0_flags(connector, &state->stf);
...
}
if (upd_flags[0] & SCDC_CED_UPDATE) {
ret = drm_scdc_read_error_counters(connector, state->error_count);
...
}
```
Since the state persists in `scdc_debugfs_priv`, on the first debugfs read (or if no updates have occurred), the status and error fields will be zero. Subsequent reads will show stale data from the last update. For a polling-oriented debugfs interface, always reading status flags (which have no side effects besides clearing the notification bit) would produce more useful output. Error counters have clear-on-read semantics so the conditional approach is more defensible there.
**Update flag clearing order:** `drm_scdc_read_status0_flags` clears the `SCDC_STATUS_UPDATE` flag *before* reading the status register. This is fine because status registers always reflect current state (they aren't latched on the update flag), but it differs from the typical spec-described flow of read-then-clear. Not a bug, just worth noting.
**Minor: doc typo in `drm_scdc_state`:**
```c
/** @scramling_enabled: true if TMDS scrambling is on */
```
Should be `@scrambling_enabled`.
**Connector refcounting:** The `scdc_status_show` function correctly releases the connector ref after `drm_scdc_read_state` and before printing the state (which only accesses the local state copy). This is fine.
**Exported symbols:** `drm_scdc_read_status0_flags`, `drm_scdc_read_error_counters`, and `drm_scdc_read_state` are all `EXPORT_SYMBOL`. If these are only used by the debugfs show function, they could remain static to avoid expanding the kernel symbol surface. If they're intended for future driver use, the exports are reasonable.
---
Generated by Claude Code Patch Reviewer
^ permalink raw reply [flat|nested] 13+ messages in thread
* Claude review: drm/scdc-helper: Add scdc_status debugfs entry
2026-05-27 14:03 ` [PATCH v4 2/4] drm/scdc-helper: Add scdc_status debugfs entry Nicolas Frattaroli
@ 2026-05-28 2:16 ` Claude Code Review Bot
0 siblings, 0 replies; 13+ messages in thread
From: Claude Code Review Bot @ 2026-05-28 2:16 UTC (permalink / raw)
To: dri-devel-reviews
Patch Review
**Verdict: Minor issues.**
This is the bulk of the series. The overall architecture is clean: `drm_scdc_read_state` as the core state reader, separate `drm_scdc_read_status0_flags` and `drm_scdc_read_error_counters` for individual fields, and `scdc_status_show` as the debugfs presentation layer.
**1. Doc comment typo** in `drm_scdc_state`:
```c
/** @scramling_enabled: true if TMDS scrambling is on */
```
Should be `@scrambling_enabled`.
**2. Exported functions with no external callers yet**: `drm_scdc_read_status0_flags`, `drm_scdc_read_error_counters`, and `drm_scdc_read_state` are all `EXPORT_SYMBOL` and declared in the public header, but currently only used internally by `scdc_status_show`. If no driver is expected to call these directly soon, they could be `static` to reduce API surface. However, if the intent is to provide a public API for drivers that want to query SCDC state programmatically, then exporting proactively is fine -- just worth stating the intent.
**3. Status flag clear-before-read ordering**: `drm_scdc_read_status0_flags` writes `SCDC_STATUS_UPDATE` to clear the flag *before* reading the status register. The HDMI spec recommends reading the data first, then clearing the flag. For a debugfs polling interface this is fine in practice, but worth noting the deviation.
**4. Connector get/put pattern is correct**: The success path drops the ref after `drm_scdc_read_state` returns (before printing cached state), and the error path uses `err_conn_put`. Clean.
---
Generated by Claude Code Patch Reviewer
^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH v5 0/4] Add SCDC information to connector debugfs
@ 2026-06-04 15:52 Nicolas Frattaroli
2026-06-04 15:52 ` [PATCH v5 1/4] drm/scdc-helper: Don't use ssize_t return type for scdc_read/write Nicolas Frattaroli
` (4 more replies)
0 siblings, 5 replies; 13+ messages in thread
From: Nicolas Frattaroli @ 2026-06-04 15:52 UTC (permalink / raw)
To: Jani Nikula, Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann,
David Airlie, Simona Vetter, Andrzej Hajda, Neil Armstrong,
Robert Foss, Laurent Pinchart, Jonas Karlman, Jernej Skrabec,
Luca Ceresoli, Daniel Stone, Hans Verkuil
Cc: dri-devel, linux-kernel, kernel, Nicolas Frattaroli, Daniel Stone
HDMI uses the DDC I2C bus for communicating various bits of link status
out of band with the actual HDMI video signal. This information can be
useful for debugging issues like questionable cables sabotaged by feline
teeth, Enthusiast Grade cables made of cow fencing wire, and other such
problems that ruin one's media viewing plans.
Consequently, this series exposes various bits of pertinent information
from the SCDC protocol in an HDMI connector's debugfs. To continually
poll the link status, userspace can poll the debugfs file.
---
Changes in v5:
- Read all SCDC data regardless of update flags
- Dump SCDC data as hex before the human-readable output. It's separated
with "\n----------------\n\n".
- No longer write 0 to read-only registers
- Add Reed-Solomon Corrections counter parsing
- Parsing has been kept. A desire was expressed to get this data without
any external userspace tooling, and the kernel will need to parse it
eventually anyway to set the link status.
- Functions have been made static as of right now, since external users
may do another pass over the function signatures anyway.
- Link to v4: https://patch.msgid.link/20260527-scdc-link-health-v4-0-622ea40a1f59@collabora.com
Changes in v4:
- Don't use C struct bitfields for parsing status flags. Switch to
bitwise AND for boolean flags, and FIELD_GET for multi-bit values.
- Drop the superfluous !! and parens
- Drop the __pure attributes on static functions
- Initialise stack local arrays with {}, not { 0 }.
- I've kept the print macros and %-30s format. Reason being that I don't
want to repeat the format specifier and str_yes_no(foo) a bunch, and I
like the %-30s format because it means all values are aligned with the
value of the longest field, which is 30 chars long.
- Link to v3: https://patch.msgid.link/20260526-scdc-link-health-v3-0-59e4a4aaead1@collabora.com
Changes in v3:
- Add patch to change return type of drm_scdc_read/write.
- Rework error counter reading to duplicate less code.
- Also check lane 3 counter valid flag when reading its error counter.
- Use memset to clear buf for error counters, rather than doing it in
the loop.
- Make read_error_counters not accept 0 as num_lanes; fix it up in the
caller instead.
- Link to v2: https://patch.msgid.link/20260520-scdc-link-health-v2-0-511af18cd64b@collabora.com
Changes in v2:
- Add HDMI 2.1 SCDC status reporting
- Link to v1: https://patch.msgid.link/20260415-scdc-link-health-v1-0-8e731e88eaf0@collabora.com
To: Jani Nikula <jani.nikula@linux.intel.com>
To: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
To: Maxime Ripard <mripard@kernel.org>
To: Thomas Zimmermann <tzimmermann@suse.de>
To: David Airlie <airlied@gmail.com>
To: Simona Vetter <simona@ffwll.ch>
To: Andrzej Hajda <andrzej.hajda@intel.com>
To: Neil Armstrong <neil.armstrong@linaro.org>
To: Robert Foss <rfoss@kernel.org>
To: Laurent Pinchart <Laurent.pinchart@ideasonboard.com>
To: Jonas Karlman <jonas@kwiboo.se>
To: Jernej Skrabec <jernej.skrabec@gmail.com>
To: Luca Ceresoli <luca.ceresoli@bootlin.com>
To: Daniel Stone <daniel@fooishbar.org>
To: Hans Verkuil <hverkuil+cisco@kernel.org>
Cc: dri-devel@lists.freedesktop.org
Cc: linux-kernel@vger.kernel.org
Cc: kernel@collabora.com
Signed-off-by: Nicolas Frattaroli <nicolas.frattaroli@collabora.com>
---
Nicolas Frattaroli (4):
drm/scdc-helper: Don't use ssize_t return type for scdc_read/write
drm/scdc-helper: Add scdc_status debugfs entry
drm/display: bridge_connector: init scdc debugfs for HDMI
drm/scdc-helper: Implement parsing and printing HDMI 2.1 fields
drivers/gpu/drm/display/drm_bridge_connector.c | 4 +
drivers/gpu/drm/display/drm_scdc_helper.c | 285 ++++++++++++++++++++++++-
include/drm/display/drm_scdc.h | 21 +-
include/drm/display/drm_scdc_helper.h | 103 ++++++++-
4 files changed, 404 insertions(+), 9 deletions(-)
---
base-commit: 9dd27c9ba89acc30350aa57fe047b9a2fd0a5ee7
change-id: 20260413-scdc-link-health-89326013d96c
Best regards,
--
Nicolas Frattaroli <nicolas.frattaroli@collabora.com>
^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH v5 1/4] drm/scdc-helper: Don't use ssize_t return type for scdc_read/write
2026-06-04 15:52 [PATCH v5 0/4] Add SCDC information to connector debugfs Nicolas Frattaroli
@ 2026-06-04 15:52 ` Nicolas Frattaroli
2026-06-04 20:21 ` Claude review: " Claude Code Review Bot
2026-06-04 15:52 ` [PATCH v5 2/4] drm/scdc-helper: Add scdc_status debugfs entry Nicolas Frattaroli
` (3 subsequent siblings)
4 siblings, 1 reply; 13+ messages in thread
From: Nicolas Frattaroli @ 2026-06-04 15:52 UTC (permalink / raw)
To: Jani Nikula, Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann,
David Airlie, Simona Vetter, Andrzej Hajda, Neil Armstrong,
Robert Foss, Laurent Pinchart, Jonas Karlman, Jernej Skrabec,
Luca Ceresoli, Daniel Stone, Hans Verkuil
Cc: dri-devel, linux-kernel, kernel, Nicolas Frattaroli
drm_scdc_read and drm_scdc_write, both of which are only used within
drm_scdc_helper (although exported), use a ssize_t as their return type.
This would make sense if they returned the number of bytes read/written
on success, and negative errno otherwise. However, they return 0 on
success.
Demote them to "int" as their return type, in order to avoid needlessly
using 64 bits when less suffices.
No functional change.
Reviewed-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
Reviewed-by: Hans Verkuil <hverkuil+cisco@kernel.org>
Signed-off-by: Nicolas Frattaroli <nicolas.frattaroli@collabora.com>
---
drivers/gpu/drm/display/drm_scdc_helper.c | 8 ++++----
include/drm/display/drm_scdc_helper.h | 8 ++++----
2 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/drivers/gpu/drm/display/drm_scdc_helper.c b/drivers/gpu/drm/display/drm_scdc_helper.c
index df878aad4a36..8403f2390ab6 100644
--- a/drivers/gpu/drm/display/drm_scdc_helper.c
+++ b/drivers/gpu/drm/display/drm_scdc_helper.c
@@ -67,8 +67,8 @@
* Returns:
* 0 on success, negative error code on failure.
*/
-ssize_t drm_scdc_read(struct i2c_adapter *adapter, u8 offset, void *buffer,
- size_t size)
+int drm_scdc_read(struct i2c_adapter *adapter, u8 offset, void *buffer,
+ size_t size)
{
int ret;
struct i2c_msg msgs[2] = {
@@ -107,8 +107,8 @@ EXPORT_SYMBOL(drm_scdc_read);
* Returns:
* 0 on success, negative error code on failure.
*/
-ssize_t drm_scdc_write(struct i2c_adapter *adapter, u8 offset,
- const void *buffer, size_t size)
+int drm_scdc_write(struct i2c_adapter *adapter, u8 offset, const void *buffer,
+ size_t size)
{
struct i2c_msg msg = {
.addr = SCDC_I2C_SLAVE_ADDRESS,
diff --git a/include/drm/display/drm_scdc_helper.h b/include/drm/display/drm_scdc_helper.h
index 34600476a1b9..e9ccaeba56dd 100644
--- a/include/drm/display/drm_scdc_helper.h
+++ b/include/drm/display/drm_scdc_helper.h
@@ -31,10 +31,10 @@
struct drm_connector;
struct i2c_adapter;
-ssize_t drm_scdc_read(struct i2c_adapter *adapter, u8 offset, void *buffer,
- size_t size);
-ssize_t drm_scdc_write(struct i2c_adapter *adapter, u8 offset,
- const void *buffer, size_t size);
+int drm_scdc_read(struct i2c_adapter *adapter, u8 offset, void *buffer,
+ size_t size);
+int drm_scdc_write(struct i2c_adapter *adapter, u8 offset, const void *buffer,
+ size_t size);
/**
* drm_scdc_readb - read a single byte from SCDC
--
2.54.0
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH v5 2/4] drm/scdc-helper: Add scdc_status debugfs entry
2026-06-04 15:52 [PATCH v5 0/4] Add SCDC information to connector debugfs Nicolas Frattaroli
2026-06-04 15:52 ` [PATCH v5 1/4] drm/scdc-helper: Don't use ssize_t return type for scdc_read/write Nicolas Frattaroli
@ 2026-06-04 15:52 ` Nicolas Frattaroli
2026-06-04 20:21 ` Claude review: " Claude Code Review Bot
2026-06-04 15:52 ` [PATCH v5 3/4] drm/display: bridge_connector: init scdc debugfs for HDMI Nicolas Frattaroli
` (2 subsequent siblings)
4 siblings, 1 reply; 13+ messages in thread
From: Nicolas Frattaroli @ 2026-06-04 15:52 UTC (permalink / raw)
To: Jani Nikula, Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann,
David Airlie, Simona Vetter, Andrzej Hajda, Neil Armstrong,
Robert Foss, Laurent Pinchart, Jonas Karlman, Jernej Skrabec,
Luca Ceresoli, Daniel Stone, Hans Verkuil
Cc: dri-devel, linux-kernel, kernel, Nicolas Frattaroli
SCDC provides status information on the current display link. At the
very least, it may be useful to expose this info through debugfs.
Add a debugfs entry for it under the connector, which displays a few
more details parsed out of the SCDC registers. A new
drm_scdc_debugfs_init function can be called by the connector
implementation to initialise the debugfs file.
Signed-off-by: Nicolas Frattaroli <nicolas.frattaroli@collabora.com>
---
drivers/gpu/drm/display/drm_scdc_helper.c | 184 ++++++++++++++++++++++++++++++
include/drm/display/drm_scdc_helper.h | 32 ++++++
2 files changed, 216 insertions(+)
diff --git a/drivers/gpu/drm/display/drm_scdc_helper.c b/drivers/gpu/drm/display/drm_scdc_helper.c
index 8403f2390ab6..d98bcb8ce748 100644
--- a/drivers/gpu/drm/display/drm_scdc_helper.c
+++ b/drivers/gpu/drm/display/drm_scdc_helper.c
@@ -24,11 +24,14 @@
#include <linux/export.h>
#include <linux/i2c.h>
#include <linux/slab.h>
+#include <linux/debugfs.h>
#include <linux/delay.h>
+#include <linux/overflow.h>
#include <drm/display/drm_scdc_helper.h>
#include <drm/drm_connector.h>
#include <drm/drm_device.h>
+#include <drm/drm_managed.h>
#include <drm/drm_print.h>
/**
@@ -55,6 +58,11 @@
#define SCDC_I2C_SLAVE_ADDRESS 0x54
+struct scdc_debugfs_priv {
+ struct drm_connector *connector;
+ struct drm_scdc_state state;
+};
+
/**
* drm_scdc_read - read a block of data from SCDC
* @adapter: I2C controller
@@ -276,3 +284,179 @@ bool drm_scdc_set_high_tmds_clock_ratio(struct drm_connector *connector,
return true;
}
EXPORT_SYMBOL(drm_scdc_set_high_tmds_clock_ratio);
+
+static void
+drm_scdc_parse_status0_flags(u8 val, struct drm_scdc_status_flags *flags)
+{
+ flags->clock_detected = val & SCDC_CLOCK_DETECT;
+ flags->ch0_locked = val & SCDC_CH0_LOCK;
+ flags->ch1_locked = val & SCDC_CH1_LOCK;
+ flags->ch2_locked = val & SCDC_CH2_LOCK;
+}
+
+static int drm_scdc_parse_error_counters(const u8 scdc[256], u16 counter[3])
+{
+ u8 sum = 0;
+ int i;
+
+ for (i = SCDC_ERR_DET_0_L; i <= SCDC_ERR_DET_CHECKSUM ; i++)
+ sum = wrapping_add(u8, sum, scdc[i]);
+
+ if (sum)
+ return -EPROTO;
+
+ for (i = 0; i < 3; i++) {
+ if (scdc[SCDC_ERR_DET_0_H + i * 2] & SCDC_CHANNEL_VALID)
+ counter[i] = (scdc[SCDC_ERR_DET_0_H + i * 2] &
+ ~SCDC_CHANNEL_VALID) << 8 |
+ scdc[SCDC_ERR_DET_0_L + i * 2];
+ else
+ counter[i] = 0;
+ }
+
+ return 0;
+}
+
+/**
+ * drm_scdc_read_state - Update state from SCDC
+ * @connector: pointer to a &struct drm_connector on which to operate on
+ * @state: pointer to a &struct drm_scdc_state to fill
+ *
+ * Reads the entire 256 byte SCDC state and parses it.
+ *
+ * Returns: %0 on success, negative errno on failure.
+ */
+int drm_scdc_read_state(struct drm_connector *connector, struct drm_scdc_state *state)
+{
+ struct i2c_adapter *ddc;
+ struct drm_scdc *scdc;
+ u8 *buf = state->scdc;
+ int ret;
+
+ if (!state || !connector)
+ return -ENODEV;
+
+ scdc = &connector->display_info.hdmi.scdc;
+ ddc = connector->ddc;
+
+ if (!scdc->supported)
+ return -EOPNOTSUPP;
+
+ /* Read in 128-byte chunks, to work around DP<->HDMI converters with issues. */
+ ret = drm_scdc_read(ddc, 0, buf, 128);
+ if (ret)
+ return ret;
+
+ ret = drm_scdc_read(ddc, 127, &buf[127], 128);
+ if (ret)
+ return ret;
+
+ state->scrambling_enabled = buf[SCDC_TMDS_CONFIG] & SCDC_SCRAMBLING_ENABLE;
+ state->tmds_bclk_x40 = buf[SCDC_TMDS_CONFIG] & SCDC_TMDS_BIT_CLOCK_RATIO_BY_40;
+
+ state->scrambling_detected = buf[SCDC_SCRAMBLER_STATUS] & SCDC_SCRAMBLING_STATUS;
+
+ drm_scdc_parse_status0_flags(buf[SCDC_STATUS_FLAGS_0], &state->stf);
+ ret = drm_scdc_parse_error_counters(buf, state->error_count);
+ if (ret)
+ return ret;
+
+ return 0;
+}
+EXPORT_SYMBOL(drm_scdc_read_state);
+
+#define scdc_print_str(_f, key, s) \
+ (seq_printf((_f), "%-30s: %s\n", (key), (s)))
+#define scdc_print_flag(_f, key, val) \
+ (scdc_print_str((_f), (key), str_yes_no((val))))
+#define scdc_print_dec(_f, key, val) \
+ (seq_printf((_f), "%-30s: %d\n", (key), (val)))
+
+static int scdc_status_show(struct seq_file *m, void *data)
+{
+ struct scdc_debugfs_priv *priv = m->private;
+ struct drm_scdc_state *st = &priv->state;
+ struct drm_connector *connector = priv->connector;
+ struct drm_scdc *scdc = &connector->display_info.hdmi.scdc;
+ int i, ret;
+
+ drm_connector_get(connector);
+
+ if (connector->status != connector_status_connected) {
+ ret = -ENODEV;
+ goto err_conn_put;
+ }
+
+ if (scdc->supported) {
+ ret = drm_scdc_read_state(connector, st);
+ if (ret)
+ goto err_conn_put;
+
+ for (i = 0; i < ARRAY_SIZE(st->scdc); i += 16)
+ seq_printf(m, "%*ph\n", 16, &st->scdc[i]);
+
+ seq_puts(m, "\n----------------\n\n");
+ }
+
+ scdc_print_flag(m, "SCDC Supported", scdc->supported);
+ if (!scdc->supported) {
+ ret = 0;
+ goto err_conn_put;
+ }
+
+ scdc_print_flag(m, "Sink Read Request Capable", scdc->read_request);
+ scdc_print_flag(m, "Scrambling Supported", scdc->scrambling.supported);
+ scdc_print_flag(m, "Low Rate Scrambling Supported", scdc->scrambling.low_rates);
+
+ drm_connector_put(connector);
+
+ scdc_print_flag(m, "Scrambling Enabled", st->scrambling_enabled);
+ scdc_print_flag(m, "Scrambling Detected", st->scrambling_detected);
+
+ if (st->tmds_bclk_x40)
+ scdc_print_str(m, "TMDS Bit Clock Ratio", "1/40");
+ else
+ scdc_print_str(m, "TMDS Bit Clock Ratio", "1/10");
+
+ scdc_print_flag(m, "Clock Detected", st->stf.clock_detected);
+ scdc_print_flag(m, "Channel 0 Locked", st->stf.ch0_locked);
+ scdc_print_flag(m, "Channel 1 Locked", st->stf.ch1_locked);
+ scdc_print_flag(m, "Channel 2 Locked", st->stf.ch2_locked);
+
+ scdc_print_dec(m, "Channel 0 Errors", st->error_count[0]);
+ scdc_print_dec(m, "Channel 1 Errors", st->error_count[1]);
+ scdc_print_dec(m, "Channel 2 Errors", st->error_count[2]);
+
+ return 0;
+
+err_conn_put:
+ drm_connector_put(connector);
+
+ return ret;
+}
+DEFINE_SHOW_ATTRIBUTE(scdc_status);
+
+/**
+ * drm_scdc_debugfs_init - Initialize scdc files in connector debugfs
+ * @connector: pointer to &struct drm_connector to operate on
+ * @root: debugfs &struct dentry for the debugfs root of @connector
+ *
+ * Creates SCDC-related debugfs files for @connector. Must be called after
+ * @root is already created.
+ */
+void drm_scdc_debugfs_init(struct drm_connector *connector, struct dentry *root)
+{
+ struct scdc_debugfs_priv *priv;
+
+ if (!root || !connector)
+ return;
+
+ priv = drmm_kzalloc(connector->dev, sizeof(*priv), GFP_KERNEL);
+ if (!priv)
+ return;
+
+ priv->connector = connector;
+
+ debugfs_create_file("scdc_status", 0444, root, priv, &scdc_status_fops);
+}
+EXPORT_SYMBOL(drm_scdc_debugfs_init);
diff --git a/include/drm/display/drm_scdc_helper.h b/include/drm/display/drm_scdc_helper.h
index e9ccaeba56dd..e0b79d79e1ff 100644
--- a/include/drm/display/drm_scdc_helper.h
+++ b/include/drm/display/drm_scdc_helper.h
@@ -30,6 +30,34 @@
struct drm_connector;
struct i2c_adapter;
+struct dentry;
+
+struct drm_scdc_status_flags {
+ /* Status Register 0 */
+ bool clock_detected;
+ bool ch0_locked;
+ bool ch1_locked;
+ bool ch2_locked;
+};
+
+struct drm_scdc_state {
+ /** @stf: contents of the status flag registers */
+ struct drm_scdc_status_flags stf;
+ /** @scramling_enabled: true if TMDS scrambling is on */
+ bool scrambling_enabled;
+ /** @scrambling_detected: true if the sink actually detected scrambling */
+ bool scrambling_detected;
+ /**
+ * @tmds_bclk_x40: true if TMDS bit period is 1/40th of the TMDS
+ * clock period, false if it's 1/10th of the clock period.
+ */
+ bool tmds_bclk_x40;
+ /** @error_count: character error counts for each channel */
+ u16 error_count[3];
+
+ /** @scdc: raw SCDC data buffer */
+ u8 scdc[256];
+};
int drm_scdc_read(struct i2c_adapter *adapter, u8 offset, void *buffer,
size_t size);
@@ -77,4 +105,8 @@ bool drm_scdc_get_scrambling_status(struct drm_connector *connector);
bool drm_scdc_set_scrambling(struct drm_connector *connector, bool enable);
bool drm_scdc_set_high_tmds_clock_ratio(struct drm_connector *connector, bool set);
+int drm_scdc_read_state(struct drm_connector *connector,
+ struct drm_scdc_state *state);
+void drm_scdc_debugfs_init(struct drm_connector *connector, struct dentry *root);
+
#endif
--
2.54.0
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH v5 3/4] drm/display: bridge_connector: init scdc debugfs for HDMI
2026-06-04 15:52 [PATCH v5 0/4] Add SCDC information to connector debugfs Nicolas Frattaroli
2026-06-04 15:52 ` [PATCH v5 1/4] drm/scdc-helper: Don't use ssize_t return type for scdc_read/write Nicolas Frattaroli
2026-06-04 15:52 ` [PATCH v5 2/4] drm/scdc-helper: Add scdc_status debugfs entry Nicolas Frattaroli
@ 2026-06-04 15:52 ` Nicolas Frattaroli
2026-06-04 20:21 ` Claude review: " Claude Code Review Bot
2026-06-04 15:52 ` [PATCH v5 4/4] drm/scdc-helper: Implement parsing and printing HDMI 2.1 fields Nicolas Frattaroli
2026-06-04 20:21 ` Claude review: Add SCDC information to connector debugfs Claude Code Review Bot
4 siblings, 1 reply; 13+ messages in thread
From: Nicolas Frattaroli @ 2026-06-04 15:52 UTC (permalink / raw)
To: Jani Nikula, Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann,
David Airlie, Simona Vetter, Andrzej Hajda, Neil Armstrong,
Robert Foss, Laurent Pinchart, Jonas Karlman, Jernej Skrabec,
Luca Ceresoli, Daniel Stone, Hans Verkuil
Cc: dri-devel, linux-kernel, kernel, Nicolas Frattaroli, Daniel Stone
On drm_bridge_connectors that contain an HDMI bridge, initialise the
SCDC debugfs entry under the connector's debugfs root.
Reviewed-by: Daniel Stone <daniels@collabora.com>
Signed-off-by: Nicolas Frattaroli <nicolas.frattaroli@collabora.com>
---
drivers/gpu/drm/display/drm_bridge_connector.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/drivers/gpu/drm/display/drm_bridge_connector.c b/drivers/gpu/drm/display/drm_bridge_connector.c
index cafa498c3848..629d9b8aff22 100644
--- a/drivers/gpu/drm/display/drm_bridge_connector.c
+++ b/drivers/gpu/drm/display/drm_bridge_connector.c
@@ -25,6 +25,7 @@
#include <drm/display/drm_hdmi_cec_helper.h>
#include <drm/display/drm_hdmi_helper.h>
#include <drm/display/drm_hdmi_state_helper.h>
+#include <drm/display/drm_scdc_helper.h>
/**
* DOC: overview
@@ -263,6 +264,9 @@ static void drm_bridge_connector_debugfs_init(struct drm_connector *connector,
if (bridge->funcs->debugfs_init)
bridge->funcs->debugfs_init(bridge, root);
}
+
+ if (bridge_connector->bridge_hdmi)
+ drm_scdc_debugfs_init(connector, root);
}
static struct drm_connector_state *
--
2.54.0
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH v5 4/4] drm/scdc-helper: Implement parsing and printing HDMI 2.1 fields
2026-06-04 15:52 [PATCH v5 0/4] Add SCDC information to connector debugfs Nicolas Frattaroli
` (2 preceding siblings ...)
2026-06-04 15:52 ` [PATCH v5 3/4] drm/display: bridge_connector: init scdc debugfs for HDMI Nicolas Frattaroli
@ 2026-06-04 15:52 ` Nicolas Frattaroli
2026-06-04 20:21 ` Claude review: " Claude Code Review Bot
2026-06-04 20:21 ` Claude review: Add SCDC information to connector debugfs Claude Code Review Bot
4 siblings, 1 reply; 13+ messages in thread
From: Nicolas Frattaroli @ 2026-06-04 15:52 UTC (permalink / raw)
To: Jani Nikula, Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann,
David Airlie, Simona Vetter, Andrzej Hajda, Neil Armstrong,
Robert Foss, Laurent Pinchart, Jonas Karlman, Jernej Skrabec,
Luca Ceresoli, Daniel Stone, Hans Verkuil
Cc: dri-devel, linux-kernel, kernel, Nicolas Frattaroli
HDMI 2.1 redefines previously reserved fields in SCDC for various new
uses. No version check needs to be performed, as an HDMI 2.0 sink's
reserved SCDC fields are well-defined to be 0, and any zero-ness of
these fields for an HDMI 2.0 sink is not a surprise for SCDC parsers for
HDMI 2.1.
Implement reading and outputting these fields over debugfs.
Signed-off-by: Nicolas Frattaroli <nicolas.frattaroli@collabora.com>
---
drivers/gpu/drm/display/drm_scdc_helper.c | 99 ++++++++++++++++++++++++++++++-
include/drm/display/drm_scdc.h | 21 ++++++-
include/drm/display/drm_scdc_helper.h | 69 ++++++++++++++++++++-
3 files changed, 182 insertions(+), 7 deletions(-)
diff --git a/drivers/gpu/drm/display/drm_scdc_helper.c b/drivers/gpu/drm/display/drm_scdc_helper.c
index d98bcb8ce748..42c24da8abcc 100644
--- a/drivers/gpu/drm/display/drm_scdc_helper.c
+++ b/drivers/gpu/drm/display/drm_scdc_helper.c
@@ -21,6 +21,7 @@
* DEALINGS IN THE SOFTWARE.
*/
+#include <linux/bitfield.h>
#include <linux/export.h>
#include <linux/i2c.h>
#include <linux/slab.h>
@@ -63,6 +64,38 @@ struct scdc_debugfs_priv {
struct drm_scdc_state state;
};
+static const char *drm_scdc_frl_rate_str(enum drm_scdc_frl_rate rate)
+{
+ switch (rate) {
+ case SCDC_FRL_RATE_OFF:
+ return "Off";
+ case SCDC_FRL_RATE_3X3:
+ return "3 Gbit/s x 3 lanes";
+ case SCDC_FRL_RATE_6X3:
+ return "6 Gbit/s x 3 lanes";
+ case SCDC_FRL_RATE_6X4:
+ return "6 Gbit/s x 4 lanes";
+ case SCDC_FRL_RATE_8X4:
+ return "8 Gbit/s x 4 lanes";
+ case SCDC_FRL_RATE_10X4:
+ return "10 Gbit/s x 4 lanes";
+ case SCDC_FRL_RATE_12X4:
+ return "12 Gbit/s x 4 lanes";
+ case SCDC_FRL_RATE_RESV_7:
+ case SCDC_FRL_RATE_RESV_8:
+ case SCDC_FRL_RATE_RESV_9:
+ case SCDC_FRL_RATE_RESV_10:
+ case SCDC_FRL_RATE_RESV_11:
+ case SCDC_FRL_RATE_RESV_12:
+ case SCDC_FRL_RATE_RESV_13:
+ case SCDC_FRL_RATE_RESV_14:
+ case SCDC_FRL_RATE_RESV_15:
+ return "(Reserved)";
+ default:
+ return NULL;
+ }
+}
+
/**
* drm_scdc_read - read a block of data from SCDC
* @adapter: I2C controller
@@ -292,14 +325,41 @@ drm_scdc_parse_status0_flags(u8 val, struct drm_scdc_status_flags *flags)
flags->ch0_locked = val & SCDC_CH0_LOCK;
flags->ch1_locked = val & SCDC_CH1_LOCK;
flags->ch2_locked = val & SCDC_CH2_LOCK;
+ flags->ln3_locked = val & SCDC_LN3_LOCK;
+ flags->flt_ready = val & SCDC_FLT_READY;
+ flags->dsc_fail = val & SCDC_DSC_FAIL;
+}
+
+static void
+drm_scdc_parse_status1_2_flags(u8 val_flag1, u8 val_flag2,
+ struct drm_scdc_status_flags *flags)
+{
+ flags->ln0_training_pattern = FIELD_GET(SCDC_LN_EVEN_TRAIN_PTRN, val_flag1);
+ flags->ln1_training_pattern = FIELD_GET(SCDC_LN_ODD_TRAIN_PTRN, val_flag1);
+
+ flags->ln2_training_pattern = FIELD_GET(SCDC_LN_EVEN_TRAIN_PTRN, val_flag2);
+ flags->ln3_training_pattern = FIELD_GET(SCDC_LN_ODD_TRAIN_PTRN, val_flag2);
}
-static int drm_scdc_parse_error_counters(const u8 scdc[256], u16 counter[3])
+static int drm_scdc_parse_error_counters(const u8 scdc[256], u16 counter[4],
+ unsigned int num_lanes)
{
+ u8 end_reg;
u8 sum = 0;
int i;
- for (i = SCDC_ERR_DET_0_L; i <= SCDC_ERR_DET_CHECKSUM ; i++)
+ switch (num_lanes) {
+ case 3:
+ end_reg = SCDC_ERR_DET_CHECKSUM;
+ break;
+ case 4:
+ end_reg = SCDC_ERR_DET_3_H;
+ break;
+ default:
+ return -EINVAL;
+ }
+
+ for (i = SCDC_ERR_DET_0_L; i <= end_reg; i++)
sum = wrapping_add(u8, sum, scdc[i]);
if (sum)
@@ -314,6 +374,12 @@ static int drm_scdc_parse_error_counters(const u8 scdc[256], u16 counter[3])
counter[i] = 0;
}
+ if (num_lanes == 4 && scdc[SCDC_ERR_DET_3_H] & SCDC_CHANNEL_VALID)
+ counter[3] = (scdc[SCDC_ERR_DET_3_H] & ~SCDC_CHANNEL_VALID) << 8 |
+ scdc[SCDC_ERR_DET_3_L];
+ else
+ counter[3] = 0;
+
return 0;
}
@@ -331,6 +397,7 @@ int drm_scdc_read_state(struct drm_connector *connector, struct drm_scdc_state *
struct i2c_adapter *ddc;
struct drm_scdc *scdc;
u8 *buf = state->scdc;
+ int num_lanes;
int ret;
if (!state || !connector)
@@ -356,11 +423,26 @@ int drm_scdc_read_state(struct drm_connector *connector, struct drm_scdc_state *
state->scrambling_detected = buf[SCDC_SCRAMBLER_STATUS] & SCDC_SCRAMBLING_STATUS;
+ state->rate = FIELD_GET(SCDC_FRL_RATE, buf[SCDC_CONFIG_1]);
+ num_lanes = drm_scdc_num_frl_lanes(state->rate);
+ if (num_lanes < 0)
+ return num_lanes;
+ if (!num_lanes)
+ num_lanes = 3;
+
+ state->ffe_levels = FIELD_GET(SCDC_FFE_LEVELS, buf[SCDC_CONFIG_1]);
+
drm_scdc_parse_status0_flags(buf[SCDC_STATUS_FLAGS_0], &state->stf);
- ret = drm_scdc_parse_error_counters(buf, state->error_count);
+ drm_scdc_parse_status1_2_flags(buf[SCDC_STATUS_FLAGS_1],
+ buf[SCDC_STATUS_FLAGS_2], &state->stf);
+ ret = drm_scdc_parse_error_counters(buf, state->error_count, num_lanes);
if (ret)
return ret;
+ if (num_lanes == 4 && (buf[SCDC_ERR_DET_RS_H] & SCDC_CHANNEL_VALID))
+ state->rs_corrections = (buf[SCDC_ERR_DET_RS_H] & ~SCDC_CHANNEL_VALID) << 8 |
+ buf[SCDC_ERR_DET_RS_L];
+
return 0;
}
EXPORT_SYMBOL(drm_scdc_read_state);
@@ -412,6 +494,8 @@ static int scdc_status_show(struct seq_file *m, void *data)
scdc_print_flag(m, "Scrambling Enabled", st->scrambling_enabled);
scdc_print_flag(m, "Scrambling Detected", st->scrambling_detected);
+ scdc_print_str(m, "FRL Rate", drm_scdc_frl_rate_str(st->rate));
+ scdc_print_dec(m, "FFE Levels", st->ffe_levels);
if (st->tmds_bclk_x40)
scdc_print_str(m, "TMDS Bit Clock Ratio", "1/40");
@@ -422,10 +506,19 @@ static int scdc_status_show(struct seq_file *m, void *data)
scdc_print_flag(m, "Channel 0 Locked", st->stf.ch0_locked);
scdc_print_flag(m, "Channel 1 Locked", st->stf.ch1_locked);
scdc_print_flag(m, "Channel 2 Locked", st->stf.ch2_locked);
+ if (drm_scdc_num_frl_lanes(st->rate) == 4)
+ scdc_print_flag(m, "Lane 3 Locked", st->stf.ln3_locked);
+
+ scdc_print_flag(m, "Sink Ready For Link Training", st->stf.flt_ready);
+ scdc_print_flag(m, "Sink Failed To Decode DSC", st->stf.dsc_fail);
scdc_print_dec(m, "Channel 0 Errors", st->error_count[0]);
scdc_print_dec(m, "Channel 1 Errors", st->error_count[1]);
scdc_print_dec(m, "Channel 2 Errors", st->error_count[2]);
+ if (drm_scdc_num_frl_lanes(st->rate) == 4) {
+ scdc_print_dec(m, "Lane 3 Errors", st->error_count[3]);
+ scdc_print_dec(m, "Reed-Solomon Corrections", st->rs_corrections);
+ }
return 0;
diff --git a/include/drm/display/drm_scdc.h b/include/drm/display/drm_scdc.h
index 3d58f37e8ed8..7f0b05b2f280 100644
--- a/include/drm/display/drm_scdc.h
+++ b/include/drm/display/drm_scdc.h
@@ -29,6 +29,8 @@
#define SCDC_SOURCE_VERSION 0x02
#define SCDC_UPDATE_0 0x10
+#define SCDC_RSED_UPDATE (1 << 6)
+#define SCDC_FLT_UPDATE (1 << 5)
#define SCDC_READ_REQUEST_TEST (1 << 2)
#define SCDC_CED_UPDATE (1 << 1)
#define SCDC_STATUS_UPDATE (1 << 0)
@@ -46,14 +48,25 @@
#define SCDC_CONFIG_0 0x30
#define SCDC_READ_REQUEST_ENABLE (1 << 0)
+#define SCDC_CONFIG_1 0x31
+#define SCDC_FRL_RATE 0x0f
+#define SCDC_FFE_LEVELS 0xf0
+
#define SCDC_STATUS_FLAGS_0 0x40
+#define SCDC_DSC_FAIL (1 << 7)
+#define SCDC_FLT_READY (1 << 6)
+#define SCDC_LN3_LOCK (1 << 4)
#define SCDC_CH2_LOCK (1 << 3)
#define SCDC_CH1_LOCK (1 << 2)
#define SCDC_CH0_LOCK (1 << 1)
-#define SCDC_CH_LOCK_MASK (SCDC_CH2_LOCK | SCDC_CH1_LOCK | SCDC_CH0_LOCK)
+#define SCDC_CH_LOCK_MASK (SCDC_LN3_LOCK | SCDC_CH2_LOCK | SCDC_CH1_LOCK | \
+ SCDC_CH0_LOCK)
#define SCDC_CLOCK_DETECT (1 << 0)
#define SCDC_STATUS_FLAGS_1 0x41
+#define SCDC_LN_EVEN_TRAIN_PTRN 0x0f
+#define SCDC_LN_ODD_TRAIN_PTRN 0xf0
+#define SCDC_STATUS_FLAGS_2 0x42
#define SCDC_ERR_DET_0_L 0x50
#define SCDC_ERR_DET_0_H 0x51
@@ -65,6 +78,12 @@
#define SCDC_ERR_DET_CHECKSUM 0x56
+#define SCDC_ERR_DET_3_L 0x57
+#define SCDC_ERR_DET_3_H 0x58
+
+#define SCDC_ERR_DET_RS_L 0x59
+#define SCDC_ERR_DET_RS_H 0x5a
+
#define SCDC_TEST_CONFIG_0 0xc0
#define SCDC_TEST_READ_REQUEST (1 << 7)
#define SCDC_TEST_READ_REQUEST_DELAY(x) ((x) & 0x7f)
diff --git a/include/drm/display/drm_scdc_helper.h b/include/drm/display/drm_scdc_helper.h
index e0b79d79e1ff..a3b20adaac7e 100644
--- a/include/drm/display/drm_scdc_helper.h
+++ b/include/drm/display/drm_scdc_helper.h
@@ -24,6 +24,7 @@
#ifndef DRM_SCDC_HELPER_H
#define DRM_SCDC_HELPER_H
+#include <linux/errno.h>
#include <linux/types.h>
#include <drm/display/drm_scdc.h>
@@ -38,8 +39,65 @@ struct drm_scdc_status_flags {
bool ch0_locked;
bool ch1_locked;
bool ch2_locked;
+ bool ln3_locked;
+ bool flt_ready;
+ bool dsc_fail;
+
+ /* Status Register 1 */
+ u8 ln0_training_pattern : 4;
+ u8 ln1_training_pattern : 4;
+
+ /* Status Register 2 */
+ u8 ln2_training_pattern : 4;
+ u8 ln3_training_pattern : 4;
+};
+
+enum drm_scdc_frl_rate {
+ SCDC_FRL_RATE_OFF = 0,
+ SCDC_FRL_RATE_3X3 = 1,
+ SCDC_FRL_RATE_6X3 = 2,
+ SCDC_FRL_RATE_6X4 = 3,
+ SCDC_FRL_RATE_8X4 = 4,
+ SCDC_FRL_RATE_10X4 = 5,
+ SCDC_FRL_RATE_12X4 = 6,
+ SCDC_FRL_RATE_RESV_7 = 7,
+ SCDC_FRL_RATE_RESV_8 = 8,
+ SCDC_FRL_RATE_RESV_9 = 9,
+ SCDC_FRL_RATE_RESV_10 = 10,
+ SCDC_FRL_RATE_RESV_11 = 11,
+ SCDC_FRL_RATE_RESV_12 = 12,
+ SCDC_FRL_RATE_RESV_13 = 13,
+ SCDC_FRL_RATE_RESV_14 = 14,
+ SCDC_FRL_RATE_RESV_15 = 15
};
+/**
+ * drm_scdc_num_frl_lanes - get number of lanes for a given FRL rate
+ * @rate: one of &enum drm_scdc_frl_rate
+ *
+ * For a given @rate, return the number of lanes it uses.
+ *
+ * Returns: %-EINVAL if @rate is not a valid FRL rate, or the number of lanes
+ * for a given &enum drm_scdc_frl_rate on success (including %0 for "off")
+ */
+static inline __pure int drm_scdc_num_frl_lanes(enum drm_scdc_frl_rate rate)
+{
+ switch (rate) {
+ case SCDC_FRL_RATE_OFF:
+ return 0;
+ case SCDC_FRL_RATE_3X3:
+ case SCDC_FRL_RATE_6X3:
+ return 3;
+ case SCDC_FRL_RATE_6X4:
+ case SCDC_FRL_RATE_8X4:
+ case SCDC_FRL_RATE_10X4:
+ case SCDC_FRL_RATE_12X4:
+ return 4;
+ default:
+ return -EINVAL;
+ }
+}
+
struct drm_scdc_state {
/** @stf: contents of the status flag registers */
struct drm_scdc_status_flags stf;
@@ -52,9 +110,14 @@ struct drm_scdc_state {
* clock period, false if it's 1/10th of the clock period.
*/
bool tmds_bclk_x40;
- /** @error_count: character error counts for each channel */
- u16 error_count[3];
-
+ /** @rate: FRL rate set by the source */
+ enum drm_scdc_frl_rate rate : 4;
+ /** @ffe_levels: The FFE levels for @rate set by the source */
+ u8 ffe_levels : 4;
+ /** @error_count: character error counts for each channel/link */
+ u16 error_count[4];
+ /** @rs_corrections: number of Reed-Solomon Corrections */
+ u16 rs_corrections;
/** @scdc: raw SCDC data buffer */
u8 scdc[256];
};
--
2.54.0
^ permalink raw reply related [flat|nested] 13+ messages in thread
* Claude review: Add SCDC information to connector debugfs
2026-06-04 15:52 [PATCH v5 0/4] Add SCDC information to connector debugfs Nicolas Frattaroli
` (3 preceding siblings ...)
2026-06-04 15:52 ` [PATCH v5 4/4] drm/scdc-helper: Implement parsing and printing HDMI 2.1 fields Nicolas Frattaroli
@ 2026-06-04 20:21 ` Claude Code Review Bot
4 siblings, 0 replies; 13+ messages in thread
From: Claude Code Review Bot @ 2026-06-04 20:21 UTC (permalink / raw)
To: dri-devel-reviews
Overall Series Review
Subject: Add SCDC information to connector debugfs
Author: Nicolas Frattaroli <nicolas.frattaroli@collabora.com>
Patches: 5
Reviewed: 2026-06-05T06:21:28.383397
---
This v5 series adds SCDC (Status and Control Data Channel) debugfs support for HDMI connectors, exposing link health information that's useful for debugging cable/signal issues. The series is well-structured: a clean return-type fix, the core debugfs infrastructure, a bridge connector hookup, and HDMI 2.1 extensions.
The code is generally well-written and has clearly benefited from multiple review rounds. However, there are a few issues worth addressing: a **one-off error in the SCDC 256-byte read** that misses the last register, a **misplaced `drm_connector_put()` on the success path** that drops the reference before the function is done, a **missing `else` zeroing for `rs_corrections`**, and **parsed training pattern fields that are never displayed**. None are catastrophic, but the first two should be fixed before merge.
---
Generated by Claude Code Patch Reviewer
^ permalink raw reply [flat|nested] 13+ messages in thread
* Claude review: drm/scdc-helper: Don't use ssize_t return type for scdc_read/write
2026-06-04 15:52 ` [PATCH v5 1/4] drm/scdc-helper: Don't use ssize_t return type for scdc_read/write Nicolas Frattaroli
@ 2026-06-04 20:21 ` Claude Code Review Bot
0 siblings, 0 replies; 13+ messages in thread
From: Claude Code Review Bot @ 2026-06-04 20:21 UTC (permalink / raw)
To: dri-devel-reviews
Patch Review
Clean and correct. The functions return 0 on success or negative errno, so `int` is the right type. The change is consistent between the `.c` and `.h` files. Already has R-b from Luca Ceresoli and Hans Verkuil.
No issues.
---
---
Generated by Claude Code Patch Reviewer
^ permalink raw reply [flat|nested] 13+ messages in thread
* Claude review: drm/scdc-helper: Add scdc_status debugfs entry
2026-06-04 15:52 ` [PATCH v5 2/4] drm/scdc-helper: Add scdc_status debugfs entry Nicolas Frattaroli
@ 2026-06-04 20:21 ` Claude Code Review Bot
0 siblings, 0 replies; 13+ messages in thread
From: Claude Code Review Bot @ 2026-06-04 20:21 UTC (permalink / raw)
To: dri-devel-reviews
Patch Review
This is the core patch and has a few issues:
**Bug: Off-by-one in SCDC read misses register 0xFF.**
```c
ret = drm_scdc_read(ddc, 0, buf, 128);
if (ret)
return ret;
ret = drm_scdc_read(ddc, 127, &buf[127], 128);
```
The first read covers registers `0x00–0x7F`. The second reads from offset 127 (`0x7F`) for 128 bytes, covering `0x7F–0xFE`. Register `0xFF` is never read, and byte 127 is read twice (second overwrites first). The doc comment says "Reads the entire 256 byte SCDC state" but it only reads 255 registers. The hex dump then prints all 256 bytes including the unread byte 255 (which will be stale or zero).
The fix should be:
```c
ret = drm_scdc_read(ddc, 128, &buf[128], 128);
```
**Issue: `drm_connector_put()` placed mid-function on success path.**
```c
scdc_print_flag(m, "Low Rate Scrambling Supported", scdc->scrambling.low_rates);
drm_connector_put(connector); // <-- refcount dropped here
scdc_print_flag(m, "Scrambling Enabled", st->scrambling_enabled);
// ... 10 more lines accessing st-> ...
return 0;
err_conn_put:
drm_connector_put(connector);
return ret;
```
The refcount is technically balanced (one get, one put per path), and the code after the put only accesses `st` (which lives in `priv`, not the connector), so it's memory-safe. But dropping the connector ref before the function completes is an unusual pattern. If future changes access `connector` or `scdc` below this point, they'd hit a use-after-potential-free. Consider moving the `put` to just before `return 0`, or restructuring with a single exit path.
**Minor: Typo in kdoc.**
```c
/** @scramling_enabled: true if TMDS scrambling is on */
bool scrambling_enabled;
```
Should be `@scrambling_enabled` (missing 'b').
**Minor: `drm_scdc_status_flags` struct fields have no kdoc.** The `drm_scdc_state` members are documented, but the nested `drm_scdc_status_flags` fields are not. Since these structs are in a public header and `drm_scdc_read_state` is exported, adding kdoc would be good practice.
---
---
Generated by Claude Code Patch Reviewer
^ permalink raw reply [flat|nested] 13+ messages in thread
* Claude review: drm/display: bridge_connector: init scdc debugfs for HDMI
2026-06-04 15:52 ` [PATCH v5 3/4] drm/display: bridge_connector: init scdc debugfs for HDMI Nicolas Frattaroli
@ 2026-06-04 20:21 ` Claude Code Review Bot
0 siblings, 0 replies; 13+ messages in thread
From: Claude Code Review Bot @ 2026-06-04 20:21 UTC (permalink / raw)
To: dri-devel-reviews
Patch Review
Clean and minimal. Hooks into the existing `drm_bridge_connector_debugfs_init` at the right place, gated on `bridge_connector->bridge_hdmi` being set. Already has R-b from Daniel Stone.
No issues.
---
---
Generated by Claude Code Patch Reviewer
^ permalink raw reply [flat|nested] 13+ messages in thread
* Claude review: drm/scdc-helper: Implement parsing and printing HDMI 2.1 fields
2026-06-04 15:52 ` [PATCH v5 4/4] drm/scdc-helper: Implement parsing and printing HDMI 2.1 fields Nicolas Frattaroli
@ 2026-06-04 20:21 ` Claude Code Review Bot
0 siblings, 0 replies; 13+ messages in thread
From: Claude Code Review Bot @ 2026-06-04 20:21 UTC (permalink / raw)
To: dri-devel-reviews
Patch Review
**Bug: Missing `else` for `rs_corrections` zeroing.**
```c
if (num_lanes == 4 && (buf[SCDC_ERR_DET_RS_H] & SCDC_CHANNEL_VALID))
state->rs_corrections = (buf[SCDC_ERR_DET_RS_H] & ~SCDC_CHANNEL_VALID) << 8 |
buf[SCDC_ERR_DET_RS_L];
```
When the channel valid bit is not set, `rs_corrections` is left uninitialized (or carries the value from a prior read). Compare with `counter[3]` which correctly has an `else counter[3] = 0` clause. Should add:
```c
else
state->rs_corrections = 0;
```
**Issue: Training pattern fields parsed but never displayed.**
`drm_scdc_parse_status1_2_flags()` populates `ln[0-3]_training_pattern` in the state, but `scdc_status_show()` never prints them. Either add the display or defer parsing these fields until a consumer exists.
**Style: Missing parentheses in one condition but present in the equivalent one.**
```c
if (num_lanes == 4 && scdc[SCDC_ERR_DET_3_H] & SCDC_CHANNEL_VALID) // no parens
```
vs.
```c
if (num_lanes == 4 && (buf[SCDC_ERR_DET_RS_H] & SCDC_CHANNEL_VALID)) // has parens
```
Both are correct due to C precedence (`&` binds tighter than `&&`), but the inconsistency is confusing and likely to attract compiler warnings. Add parentheses to the first for clarity and consistency.
**Nit: `__pure` on `drm_scdc_num_frl_lanes`.**
```c
static inline __pure int drm_scdc_num_frl_lanes(enum drm_scdc_frl_rate rate)
```
The v4 changelog said "Drop the __pure attributes on static functions." For a static inline function that only switches on its argument, the compiler will determine purity on its own. This is harmless but unnecessary and inconsistent with the stated v4 cleanup.
**Nit: `enum drm_scdc_frl_rate rate : 4` uses an enum bitfield.** Storing an enum in a 4-bit bitfield is implementation-defined in C, though it works reliably with GCC/Clang which are the only compilers the kernel supports. Worth being aware of.
**Observation: Checksum coverage for 4 lanes.** For the 4-lane case, the checksum loop sums registers `0x50–0x58`, with the checksum byte itself at `0x56` (in the middle). This means the original 3-lane checksum byte must be recalculated by the sink to cover the two additional lane-3 registers. This is presumably correct per the HDMI 2.1 spec, but since I can't verify against the spec, flagging for the author to confirm.
---
Generated by Claude Code Patch Reviewer
^ permalink raw reply [flat|nested] 13+ messages in thread
end of thread, other threads:[~2026-06-04 20:21 UTC | newest]
Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-04 15:52 [PATCH v5 0/4] Add SCDC information to connector debugfs Nicolas Frattaroli
2026-06-04 15:52 ` [PATCH v5 1/4] drm/scdc-helper: Don't use ssize_t return type for scdc_read/write Nicolas Frattaroli
2026-06-04 20:21 ` Claude review: " Claude Code Review Bot
2026-06-04 15:52 ` [PATCH v5 2/4] drm/scdc-helper: Add scdc_status debugfs entry Nicolas Frattaroli
2026-06-04 20:21 ` Claude review: " Claude Code Review Bot
2026-06-04 15:52 ` [PATCH v5 3/4] drm/display: bridge_connector: init scdc debugfs for HDMI Nicolas Frattaroli
2026-06-04 20:21 ` Claude review: " Claude Code Review Bot
2026-06-04 15:52 ` [PATCH v5 4/4] drm/scdc-helper: Implement parsing and printing HDMI 2.1 fields Nicolas Frattaroli
2026-06-04 20:21 ` Claude review: " Claude Code Review Bot
2026-06-04 20:21 ` Claude review: Add SCDC information to connector debugfs Claude Code Review Bot
-- strict thread matches above, loose matches on Subject: below --
2026-05-27 14:03 [PATCH v4 0/4] " Nicolas Frattaroli
2026-05-27 14:03 ` [PATCH v4 2/4] drm/scdc-helper: Add scdc_status debugfs entry Nicolas Frattaroli
2026-05-28 2:16 ` Claude review: " Claude Code Review Bot
2026-05-26 10:19 [PATCH v3 0/4] Add SCDC information to connector debugfs Nicolas Frattaroli
2026-05-26 10:19 ` [PATCH v3 2/4] drm/scdc-helper: Add scdc_status debugfs entry Nicolas Frattaroli
2026-05-27 5:01 ` Claude review: " Claude Code Review Bot
2026-05-20 13:35 [PATCH v2 0/3] Add SCDC information to connector debugfs Nicolas Frattaroli
2026-05-20 13:35 ` [PATCH v2 1/3] drm/scdc-helper: Add scdc_status debugfs entry Nicolas Frattaroli
2026-05-25 11:49 ` Claude review: " Claude Code Review Bot
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox