From: Alyssa Rosenzweig <alyssa@rosenzweig.io>
To: sven@svenpeter.dev
Cc: Janne Grunau <j@jannau.net>,
Madhavan Srinivasan <maddy@linux.ibm.com>,
Michael Ellerman <mpe@ellerman.id.au>,
Nicholas Piggin <npiggin@gmail.com>,
Christophe Leroy <christophe.leroy@csgroup.eu>,
Naveen N Rao <naveen@kernel.org>,
Andi Shyti <andi.shyti@kernel.org>, Neal Gompa <neal@gompa.dev>,
Hector Martin <marcan@marcan.st>,
linuxppc-dev@lists.ozlabs.org, asahi@lists.linux.dev,
linux-arm-kernel@lists.infradead.org, linux-i2c@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 3/6] i2c: pasemi: Improve timeout handling
Date: Tue, 15 Apr 2025 13:11:51 -0400 [thread overview]
Message-ID: <Z_6TV-tPU2wRdfFf@blossom> (raw)
In-Reply-To: <20250415-pasemi-fixes-v2-3-c543bf53151a@svenpeter.dev>
Reviewed-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Le Tue , Apr 15, 2025 at 03:36:57PM +0000, Sven Peter via B4 Relay a écrit :
> From: Sven Peter <sven@svenpeter.dev>
>
> Add proper timeout handling for the interrupt path.
> Previously, this was only correctly done for the polling path.
> Note that we drop reg_write(smbus, REG_SMSTA, status) here which
> will be done anyway whenever the next transaction starts via
> pasemi_smb_clear.
>
> Signed-off-by: Sven Peter <sven@svenpeter.dev>
> ---
> drivers/i2c/busses/i2c-pasemi-core.c | 24 +++++++++++++++++-------
> 1 file changed, 17 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/i2c/busses/i2c-pasemi-core.c b/drivers/i2c/busses/i2c-pasemi-core.c
> index df1b0087dcacb0a3b94196368137d5e20b0e6d7e..9b611dbdfef23e78a4ea75ac0311938d52b6ba96 100644
> --- a/drivers/i2c/busses/i2c-pasemi-core.c
> +++ b/drivers/i2c/busses/i2c-pasemi-core.c
> @@ -91,32 +91,42 @@ static void pasemi_smb_clear(struct pasemi_smbus *smbus)
> static int pasemi_smb_waitready(struct pasemi_smbus *smbus)
> {
> int timeout = 100;
> + int ret;
> unsigned int status;
>
> if (smbus->use_irq) {
> reinit_completion(&smbus->irq_completion);
> reg_write(smbus, REG_IMASK, SMSTA_XEN | SMSTA_MTN);
> - wait_for_completion_timeout(&smbus->irq_completion, msecs_to_jiffies(100));
> + ret = wait_for_completion_timeout(&smbus->irq_completion, msecs_to_jiffies(100));
> reg_write(smbus, REG_IMASK, 0);
> status = reg_read(smbus, REG_SMSTA);
> +
> + if (ret < 0) {
> + dev_err(smbus->dev,
> + "Completion wait failed with %d, status 0x%08x\n",
> + ret, status);
> + return ret;
> + } else if (ret == 0) {
> + dev_warn(smbus->dev, "Timeout, status 0x%08x\n", status);
> + return -ETIME;
> + }
> } else {
> status = reg_read(smbus, REG_SMSTA);
> while (!(status & SMSTA_XEN) && timeout--) {
> msleep(1);
> status = reg_read(smbus, REG_SMSTA);
> }
> +
> + if (timeout < 0) {
> + dev_warn(smbus->dev, "Timeout, status 0x%08x\n", status);
> + return -ETIME;
> + }
> }
>
> /* Got NACK? */
> if (status & SMSTA_MTN)
> return -ENXIO;
>
> - if (timeout < 0) {
> - dev_warn(smbus->dev, "Timeout, status 0x%08x\n", status);
> - reg_write(smbus, REG_SMSTA, status);
> - return -ETIME;
> - }
> -
> /* Clear XEN */
> reg_write(smbus, REG_SMSTA, SMSTA_XEN);
>
>
> --
> 2.34.1
>
>
next prev parent reply other threads:[~2025-04-15 17:34 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-15 15:36 [PATCH v2 0/6] Apple/PASemi i2c error recovery fixes Sven Peter via B4 Relay
2025-04-15 15:36 ` [PATCH v2 1/6] i2c: pasemi: Use correct bits.h include Sven Peter via B4 Relay
2025-04-15 17:10 ` Alyssa Rosenzweig
2025-04-15 15:36 ` [PATCH v2 2/6] i2c: pasemi: Sort includes alphabetically Sven Peter via B4 Relay
2025-04-15 17:11 ` Alyssa Rosenzweig
2025-04-15 15:36 ` [PATCH v2 3/6] i2c: pasemi: Improve timeout handling Sven Peter via B4 Relay
2025-04-15 17:11 ` Alyssa Rosenzweig [this message]
2025-04-17 12:57 ` Andi Shyti
2025-04-15 15:36 ` [PATCH v2 4/6] i2c: pasemi: Improve error recovery Sven Peter via B4 Relay
2025-04-15 17:12 ` Alyssa Rosenzweig
2025-04-17 13:07 ` Andi Shyti
2025-04-27 11:29 ` Sven Peter
2025-04-15 15:36 ` [PATCH v2 5/6] i2c: pasemi: Enable the unjam machine Sven Peter via B4 Relay
2025-04-15 15:37 ` [PATCH v2 6/6] i2c: pasemi: Log bus reset causes Sven Peter via B4 Relay
2025-04-17 13:10 ` Andi Shyti
2025-04-16 1:38 ` [PATCH v2 0/6] Apple/PASemi i2c error recovery fixes Neal Gompa
2025-04-17 13:16 ` 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=Z_6TV-tPU2wRdfFf@blossom \
--to=alyssa@rosenzweig.io \
--cc=andi.shyti@kernel.org \
--cc=asahi@lists.linux.dev \
--cc=christophe.leroy@csgroup.eu \
--cc=j@jannau.net \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-i2c@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=maddy@linux.ibm.com \
--cc=marcan@marcan.st \
--cc=mpe@ellerman.id.au \
--cc=naveen@kernel.org \
--cc=neal@gompa.dev \
--cc=npiggin@gmail.com \
--cc=sven@svenpeter.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;
as well as URLs for NNTP newsgroup(s).