[26.04_linux-nvidia] i2c: mediatek: add ACPI/MT8901 support and gpiolib zero-debounce fix - #507
Conversation
BaseOS Kernel ReviewSummaryZero debounce now returns without disabling existing GPIO hardware debounce, while the MediaTek I2C fallback accepts malformed DT and may run the bus at half the requested rate. Findings: Critical: 0, High: 0, Medium: 2, Low: 0 Latest watcher review: open review Generated test plan: open test plan Kernel deb build: successful (download debs, 4 files) Head: This comment is maintained by nv-pr-bot. It is updated when the GitHub watcher publishes a newer review. |
|
Are these patches that you intend to send to the mailing list? If so, I'd suggest doing that first and then referencing the mailing list URL in this PR: Secondly, I suggest targeting this PR at the following branches instead of
Canonical helps ensure that the 24.04 kernel source is kept in sync with the 26.04 versions, so no need to target PRs at the 24.04+7.0 branches. |
dfa0ae4 to
a625012
Compare
PR Validation ReportPatchscan ✅ No Missing FixesAll cherry-picked commits checked — no missing upstream fixes found. PR Lint ❌ Errors foundDetailsChecking 2 commits... Cherry-pick digest: ┌──────────────┬──────────────────────────────────────────────────────────────────┬────────────┬─────────┬───────────────────────────┐ │ Local │ Referenced upstream / Patch subject │ Patch-ID │ Subject │ SoB chain │ ├──────────────┼──────────────────────────────────────────────────────────────────┼────────────┼─────────┼───────────────────────────┤ │ 22d6646cc0e9 │ [SAUCE] i2c: mediatek: add acpi/mt8901 support and firmware-mana │ N/A │ N/A │ zhang, kmaddara │ ├──────────────┼──────────────────────────────────────────────────────────────────┼────────────┼─────────┼───────────────────────────┤ │ ad27e41c28c4 │ [SAUCE] gpiolib: return early in gpio_set_debounce_timeout() for │ N/A │ N/A │ abhsahu, kmaddara │ └──────────────┴──────────────────────────────────────────────────────────────────┴────────────┴─────────┴───────────────────────────┘ Lint: all checks passed. PR metadata: E: PR targets 26.04_linux-nvidia but body has no https://bugs.launchpad.net/... link |
…or zero debounce Some GPIO controllers (e.g. MediaTek EINT used in pinctrl-paris) reject set_config(PIN_CONFIG_INPUT_DEBOUNCE, 0) with -EINVAL when the underlying interrupt is edge-triggered, even though the argument is 0 (meaning "no debounce"). ACPI _CRS GpioInt/GpioIo resources that declare DebounceTimeout=0 caused gpio_set_debounce_timeout() to call into that path, the chip returned -EINVAL, and the error propagated through gpiod_get_index() and acpi_dev_gpio_irq_get(), breaking ACPI consumers. A debounce timeout of 0 means "no debounce" - there is nothing to configure, so short-circuit the call inside gpio_set_debounce_timeout() itself and return success without touching the controller. This fixes all callers (the ACPI core call sites and any future ones) without having to add the same guard at every call site. Signed-off-by: Abhishek Sahu <abhsahu@nvidia.com> Signed-off-by: Kiran Maddaraki <kmaddaraki@nvidia.com>
…naged clocks On MT8901-based platforms the I2C controllers are described through ACPI (HID NVDA0200) rather than device tree. The upstream i2c-mt65xx driver is DT-only: no acpi_match_table, no propagation of the ACPI fwnode to the i2c_adapter device, and clock/timing properties read through of_property_read_*() helpers that don't operate on ACPI nodes. Compounding that, on these platforms firmware keeps the controller's "main" and "dma" clocks running and does not expose them via the Linux clk framework, so devm_clk_get() returns -ENOENT for both. Consequently the driver does not bind on ACPI systems: no i2c_adapter is created, HID-over-I2C never enumerates child devices, and the internal I2C keyboard stays silent. Wire up ACPI and accept firmware-managed clocks: * Add mt8901_compat (v3 register layout, default_parent_rate=124.8 MHz as a stand-in for clk_get_rate() when no clock provider is exposed) and an acpi_match_table entry NVDA0200 -> mt8901_compat. * Replace of_device_get_match_data() with device_get_match_data() in probe (with a NULL-match check), and switch mtk_i2c_parse_dt() to the fwnode-aware device_property_read_*() helpers so DT and ACPI share the same probe path. * Call device_set_node(&adap->dev, dev_fwnode(&pdev->dev)) so the ACPI fwnode reaches the i2c_adapter device; without it, has_acpi_companion() on the adapter returns 0 and i2c_acpi_register_devices() exits early, leaving HID children unenumerated. * Gate devm_clk_get() for "main"/"dma" on has_acpi_companion() - use devm_clk_get_optional() in the ACPI branch so absent clocks are accepted, and substitute i2c->dev_comp->default_parent_rate when mtk_i2c_set_speed() has no clock handle to query. Signed-off-by: Housong Zhang <housong.zhang@mediatek.com> Signed-off-by: Kiran Maddaraki <kmaddaraki@nvidia.com>
6cb82e7 to
22d6646
Compare
nirmoy
left a comment
There was a problem hiding this comment.
Codex found these two issues.
| * touching the hardware. | ||
| */ | ||
| if (!debounce) | ||
| return 0; |
There was a problem hiding this comment.
Medium: This changes the core API from “zero disables debounce” to “zero is ignored.” If firmware or an earlier request enabled debounce, returning here leaves hardware filtering and desc->debounce_period_us stale, and skips the line-state notification. Please scope the ACPI workaround to the affected call path or make the MediaTek EINT implementation handle zero by disabling debounce.
| &i2c->clk_src_div); | ||
| if (ret < 0) | ||
| return ret; | ||
| i2c->clk_src_div = 1; /* ACPI doesn't supply this */ |
There was a problem hiding this comment.
Low: This fallback also applies to DT and to malformed properties. clock-div is required by i2c-mt65xx.yaml, and the previous DT path returned the read error; silently using 1 changes DT behavior and may calculate the wrong SCL timing. Please default only for an absent ACPI property and preserve the DT/malformed-property error.
|
Got the same findings as Nirmoy. |
|
@kmaddaraki: Are these going to get sent upstream? |
Mediatek has plan to upstream these changes and it will happen around Oct 2026 |
Review: PR 507 — additional notesThe two findings already posted stand (core debounce semantics on A four-line fix already exists for the gpiolib problem
/* drivers/gpio/gpiolib-acpi-core.c */
static void acpi_gpio_set_debounce_timeout(struct gpio_desc *desc,
unsigned int acpi_debounce)
{
...
ret = gpio_set_debounce_timeout(desc, acpi_debounce);
if (ret)
gpiod_warn(desc, "Failed to set debounce-timeout %u: %d\n",
acpi_debounce, ret);
}Two consequences. The commit message is out of date. It says the error "propagated One call site still fails, ret = gpio_set_debounce_timeout(desc, info.debounce * 10);
if (ret)
return ret;Converting that single call to
The zero-only guard is incomplete
static unsigned int mtk_eint_can_en_debounce(struct mtk_eint *eint,
unsigned int eint_num)
{
...
if (eint->pins[eint_num].debounce && sens != MTK_EINT_EDGE_SENSITIVE)
return 1;
else
return 0;
}An MT8901 Nits
Two corrections to the earlier review
Both changed objects build clean on arm64 defconfig with |
Two small SAUCE patches to bring up the MediaTek MT8901 I²C host controller under ACPI on Ubuntu 24.04 nvidia-7.0.
gpiolib: return early in gpio_set_debounce_timeout() for zero debounce
Some GPIO controllers (MediaTek EINT among them) reject set_config(PIN_CONFIG_INPUT_DEBOUNCE, 0) with -EINVAL on edge-triggered lines. When an ACPI _CRS GpioInt/GpioIo declares DebounceTimeout=0, the error propagates through gpiod_get_index() / acpi_dev_gpio_irq_get() and blocks HID-over-I²C from acquiring its interrupt. A debounce timeout of 0 means "no debounce" — nothing to configure — so short-circuit inside gpio_set_debounce_timeout() itself. Fixes all call sites (present and future) without per-site guards.
i2c: mediatek: add ACPI/MT8901 support and firmware-managed clocks
Adds ACPI binding to the DT-only i2c-mt65xx driver so the MT8901 I²C controllers enumerate under NVDA0200:
DT behaviour is unchanged: both device_get_match_data() and device_property_read_*() fall through to the existing OF helpers for DT-described nodes, and the DT clock path is preserved.