Devicetree
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Aleksandrs Vinarskis" <alex@vinarskis.com>
Cc: devicetree@vger.kernel.org, robh@kernel.org, conor+dt@kernel.org
Subject: Re: [PATCH v8 2/3] platform: arm64: dell-xps-ec: new driver
Date: Mon, 26 Oct 2026 01:06:51 +0000	[thread overview]
Message-ID: <sashiko-outbox-184570@kernel.org> (raw)
In-Reply-To: <20261026-dell-xps-9345-ec-v8-2-251c2cbfbc6c@vinarskis.com>

Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:
- [High] platform: dell-xps-ec: unacknowledged level IRQ in dell_xps_ec_irq_handler()
- [Medium] platform: arm64: dell-xps-ec: stopped temp_work on dell_xps_ec_resume() error
- [Low] platform: arm64: dell-xps-ec: mismatched ID and positional init in dell_xps_ec_i2c_id
--

commit 89371344f2f860e258af233ab4a65e60a8d3f321
Author: Aleksandrs Vinarskis <alex@vinarskis.com>

platform: arm64: dell-xps-ec: new driver

This commit introduces an I2C driver for the Embedded Controller in the
Qualcomm Snapdragon-based Dell XPS 13 9345. It configures the thermistor
profile, periodically reports thermistor temperatures read via IIO channels to
the EC, and notifies the EC across system suspend and resume.

> diff --git a/drivers/platform/arm64/dell-xps-ec.c b/drivers/platform/arm64/dell-xps-ec.c
> new file mode 100644
> index 0000000000000..20cb2a1b7bbd4
> --- /dev/null
> +++ b/drivers/platform/arm64/dell-xps-ec.c
> @@ -0,0 +1,308 @@

[ ... ]

> +static irqreturn_t dell_xps_ec_irq_handler(int irq, void *data)
> +{
> +	struct dell_xps_ec *ec = data;
> +
> +	/*
> +	 * TODO: IRQ is fired on lid-close. Follow Windows example to read out
> +	 *       the thermistor thresholds and potentially fan speeds.
> +	 */
> +	dev_dbg(ec->dev, "IRQ triggered (irq=%d)\n", irq);
> +
> +	return IRQ_HANDLED;
> +}
> +
> +static int dell_xps_ec_probe(struct i2c_client *client)
> +{
> +	const struct dell_xps_ec_data *data;
> +	struct device *dev = &client->dev;
> +	struct dell_xps_ec *ec;
> +	unsigned int i;
> +	int ret;
> +
> +	data = i2c_get_match_data(client);
> +	if (!data)
> +		return dev_err_probe(dev, -ENODEV, "No match data\n");

[ ... ]

> +	/* Request IRQ for EC events */
> +	ret = devm_request_threaded_irq(dev, client->irq, NULL,
> +					dell_xps_ec_irq_handler,
> +					IRQF_ONESHOT, dev_name(dev), ec);
> +	if (ret)
> +		return dev_err_probe(dev, ret, "Failed to request IRQ\n");
> +
> +	return 0;
> +}

[Severity: High]
Can requesting this interrupt before event readout is implemented cause an
interrupt storm when the EC asserts the line (for example, on lid close)?

Both the devicetree binding
(Documentation/devicetree/bindings/embedded-controller/dell,xps13-9345-ec.yaml)
and the board devicetree configure the EC interrupt as level-triggered
active-low:

    interrupts-extended = <&tlmm 66 IRQ_TYPE_LEVEL_LOW>;

In dell_xps_ec_probe(), devm_request_threaded_irq() enables this interrupt
with IRQF_ONESHOT, but dell_xps_ec_irq_handler() only logs a debug message
and returns IRQ_HANDLED without performing an I2C transfer to read or clear
the pending event on the EC.

When the EC asserts the level-low interrupt line, irq_thread_fn() runs
dell_xps_ec_irq_handler() and irq_finalize_oneshot() immediately unmasks the
line while it is still asserted low, causing the interrupt to re-fire in a
tight loop. Because dell_xps_ec_irq_handler() unconditionally returns
IRQ_HANDLED, note_interrupt() treats every firing as handled and spurious IRQ
detection will not disable the line.

Should the driver hold off on requesting the IRQ until the EC event readout is
implemented?

> +
> +/*
> + * Notify EC of suspend
> + *
> + * This will:
> + * - Cut power to display/trackpad/keyboard/touchrow, wake-up source still works.
> + */
> +static int dell_xps_ec_suspend(struct device *dev)
> +{
> +	struct dell_xps_ec *ec = dev_get_drvdata(dev);
> +
> +	int ret;
> +
> +	cancel_delayed_work_sync(&ec->temp_work);
> +
> +	ret = dell_xps_ec_suspend_cmd(ec, true);
> +	if (ret) {
> +		schedule_delayed_work(&ec->temp_work,
> +				      DELL_XPS_EC_TEMP_POLL_JIFFIES);
> +		return ret;
> +	}
> +
> +	return 0;
> +}
> +
> +/*
> + * Notify EC of resume
> + *
> + * This will undo the suspend actions. Without the resume signal, device would
> + * wake up but be forced back into suspend by EC within seconds.
> + */
> +static int dell_xps_ec_resume(struct device *dev)
> +{
> +	struct dell_xps_ec *ec = dev_get_drvdata(dev);
> +	int ret;
> +
> +	ret = dell_xps_ec_suspend_cmd(ec, false);
> +	if (ret)
> +		return ret;
> +
> +	schedule_delayed_work(&ec->temp_work, DELL_XPS_EC_TEMP_POLL_JIFFIES);
> +
> +	return 0;
> +}

[Severity: Medium]
If dell_xps_ec_suspend_cmd(ec, false) fails in dell_xps_ec_resume(), does this
leave ec->temp_work permanently stopped after the system resumes?

During suspend, dell_xps_ec_suspend() cancels ec->temp_work via
cancel_delayed_work_sync(). On resume, the PM core continues resuming the
system even if a device resume callback returns an error, so returning early
before schedule_delayed_work(&ec->temp_work, DELL_XPS_EC_TEMP_POLL_JIFFIES)
leaves periodic temperature reporting disabled while the system is running.

> +
> +static const struct of_device_id dell_xps_ec_of_match[] = {
> +	{ .compatible = "dell,xps13-9345-ec", .data = &dell_xps13_9345_data },
> +	{}
> +};
> +MODULE_DEVICE_TABLE(of, dell_xps_ec_of_match);
> +
> +static const struct i2c_device_id dell_xps_ec_i2c_id[] = {
> +	{ "dell-xps-ec", (kernel_ulong_t)&dell_xps13_9345_data },
> +	{}
> +};
> +MODULE_DEVICE_TABLE(i2c, dell_xps_ec_i2c_id);

[Severity: Low]
Should dell_xps_ec_i2c_id use the vendor-stripped compatible string
"xps13-9345-ec" and named initializers (.name and .driver_data)?

When an i2c_client without an fwnode (such as via sysfs instantiation using
the OF compatible name "xps13-9345-ec") is matched via
i2c_device_match() -> i2c_of_match_device() -> i2c_of_match_device_sysfs(),
dell_xps_ec_probe() calls i2c_get_match_data(client). Because
device_get_match_data(&client->dev) returns NULL when no fwnode is attached,
i2c_get_match_data() falls back to i2c_match_id(driver->id_table, client),
which fails to match "xps13-9345-ec" against "dell-xps-ec" and causes
dell_xps_ec_probe() to fail with -ENODEV. Using named initializers also
matches the I2C subsystem convention for new struct i2c_device_id entries.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261026-dell-xps-9345-ec-v8-0-251c2cbfbc6c@vinarskis.com?part=2

  reply	other threads:[~2026-10-26  1:06 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-26  0:29 [PATCH v8 0/3] Introduce EC driver for Snapdragon X1E based Dell XPS 13 9345 Aleksandrs Vinarskis
2026-10-26  0:29 ` [PATCH v8 1/3] dt-bindings: platform: introduce EC for " Aleksandrs Vinarskis
2026-10-26  0:29 ` [PATCH v8 2/3] platform: arm64: dell-xps-ec: new driver Aleksandrs Vinarskis
2026-10-26  1:06   ` sashiko-bot [this message]
2026-10-26  0:29 ` [PATCH v8 3/3] arm64: dts: qcom: x1e80100-dell-xps13-9345: introduce EC Aleksandrs Vinarskis

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=sashiko-outbox-184570@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=alex@vinarskis.com \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=robh@kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox