Linux I2C development
 help / color / mirror / Atom feed
From: Alex Elder <elder@riscstar.com>
To: Linmao Li <lilinmao@kylinos.cn>,
	Troy Mitchell <troy.mitchell@linux.spacemit.com>,
	Andi Shyti <andi.shyti@kernel.org>
Cc: Yixun Lan <dlan@kernel.org>,
	linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-riscv@lists.infradead.org, spacemit@lists.linux.dev
Subject: Re: [PATCH] i2c: spacemit: request IRQ after controller initialization
Date: Wed, 22 Jul 2026 07:20:01 -0500	[thread overview]
Message-ID: <7d7938cd-80bb-448b-89d0-6ac6d2717e98@riscstar.com> (raw)
In-Reply-To: <20260722094302.2284191-1-lilinmao@kylinos.cn>

On 7/22/26 4:43 AM, Linmao Li wrote:
> spacemit_i2c_probe() requests the IRQ before it enables the clocks, resets
> the controller and runs init_completion(). If an interrupt is already
> pending, the handler runs too early: it reads registers while the clocks
> are still off and calls complete() on an uninitialized completion. Request
> the IRQ after the controller and completion are initialized, but still
> before the adapter is registered.
> 
> Fixes: 5ea558473fa3 ("i2c: spacemit: add support for SpacemiT K1 SoC")
> Signed-off-by: Linmao Li <lilinmao@kylinos.cn>

This looks correct.

Reviewed-by: Alex Elder <elder@riscstar.com>

> ---
>   drivers/i2c/busses/i2c-k1.c | 10 +++++-----
>   1 file changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/i2c/busses/i2c-k1.c b/drivers/i2c/busses/i2c-k1.c
> index 51a0c3d80fc9..3fe716cc153d 100644
> --- a/drivers/i2c/busses/i2c-k1.c
> +++ b/drivers/i2c/busses/i2c-k1.c
> @@ -723,11 +723,6 @@ static int spacemit_i2c_probe(struct platform_device *pdev)
>   	if (i2c->irq < 0)
>   		return dev_err_probe(dev, i2c->irq, "failed to get irq resource");
>   
> -	ret = devm_request_irq(i2c->dev, i2c->irq, spacemit_i2c_irq_handler,
> -			       IRQF_NO_SUSPEND, dev_name(i2c->dev), i2c);
> -	if (ret)
> -		return dev_err_probe(dev, ret, "failed to request irq");
> -
>   	clk = devm_clk_get_enabled(dev, "func");
>   	if (IS_ERR(clk))
>   		return dev_err_probe(dev, PTR_ERR(clk), "failed to enable func clock");
> @@ -755,6 +750,11 @@ static int spacemit_i2c_probe(struct platform_device *pdev)
>   
>   	init_completion(&i2c->complete);
>   
> +	ret = devm_request_irq(i2c->dev, i2c->irq, spacemit_i2c_irq_handler,
> +			       IRQF_NO_SUSPEND, dev_name(i2c->dev), i2c);
> +	if (ret)
> +		return dev_err_probe(dev, ret, "failed to request irq");
> +
>   	platform_set_drvdata(pdev, i2c);
>   
>   	ret = i2c_add_numbered_adapter(&i2c->adapt);


  parent reply	other threads:[~2026-07-22 12:20 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-22  9:43 [PATCH] i2c: spacemit: request IRQ after controller initialization Linmao Li
2026-07-22 12:15 ` Troy Mitchell
2026-07-22 12:20 ` Alex Elder [this message]
2026-07-23  2:11 ` [PATCH v2] " Linmao Li
2026-07-24 22:52   ` Andi Shyti

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=7d7938cd-80bb-448b-89d0-6ac6d2717e98@riscstar.com \
    --to=elder@riscstar.com \
    --cc=andi.shyti@kernel.org \
    --cc=dlan@kernel.org \
    --cc=lilinmao@kylinos.cn \
    --cc=linux-i2c@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-riscv@lists.infradead.org \
    --cc=spacemit@lists.linux.dev \
    --cc=troy.mitchell@linux.spacemit.com \
    /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