From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: Jisheng Zhang <jszhang@kernel.org>
Cc: Jarkko Nikula <jarkko.nikula@linux.intel.com>,
Mika Westerberg <mika.westerberg@linux.intel.com>,
Jan Dabros <jsd@semihalf.com>, Andi Shyti <andi.shyti@kernel.org>,
linux-kernel@vger.kernel.org, linux-i2c@vger.kernel.org
Subject: Re: [PATCH 2/2] i2c: designware: Implement atomic transfer suppot
Date: Wed, 20 Aug 2025 20:00:47 +0300 [thread overview]
Message-ID: <aKX_PwQWoe9S0QjP@smile.fi.intel.com> (raw)
In-Reply-To: <20250820153125.22002-3-jszhang@kernel.org>
On Wed, Aug 20, 2025 at 11:31:25PM +0800, Jisheng Zhang wrote:
> Rework the read and write code paths in the driver to support operation
> in atomic contexts. To achieve this, the driver must not rely on IRQs
> or perform any scheduling, e.g., via a sleep or schedule routine.
>
> Implement atomic, sleep-free, and IRQ-less operation. This increases
> complexity but is necessary for atomic I2C transfers required by some
> hardware configurations, e.g., to trigger reboots on an external PMIC chip.
...
> - usleep_range(25, 250);
> + if (dev->atomic)
> + udelay(25);
> + else
> + usleep_range(25, 250);
Wondering why this delay is not being properly calculated. Why in atomic case
is okay to use the shortest one?
...
> - if (!dev->acquire_lock)
> + if (dev->atomic || !dev->acquire_lock)
I think basically we should no allow atomic transfers at all when the lock is
in use. Otherwise it will be interesting case if HW (FW) wants to have an
exclusive access while OS wants to perform an atomic transfer.
...
> + if (dev->atomic)
> + return regmap_read_poll_timeout_atomic(dev->map, DW_IC_STATUS, status,
> + !(status & DW_IC_STATUS_MASTER_ACTIVITY),
> + 1100, 20000) != 0;
> + else
> + return regmap_read_poll_timeout(dev->map, DW_IC_STATUS, status,
> + !(status & DW_IC_STATUS_MASTER_ACTIVITY),
> + 1100, 20000) != 0;
Please, drop ' != 0' parts at the same time, they are redundant.
...
> +static int i2c_dw_wait_transfer_atomic(struct dw_i2c_dev *dev)
> +{
> + ktime_t timeout = ktime_add_us(ktime_get(), jiffies_to_usecs(dev->adapter.timeout));
> + unsigned int stat;
> + int ret;
> +
> + do {
> + ret = try_wait_for_completion(&dev->cmd_complete);
> + if (ret)
> + break;
> +
> + stat = i2c_dw_read_clear_intrbits(dev);
> + if (stat)
> + i2c_dw_process_transfer(dev, stat);
> + else
> + udelay(15);
No explanation about this value.
> + } while (ktime_compare(ktime_get(), timeout) < 0);
Whe have _before() and _after() APIs, use them.
> + return ret ? 0 : -ETIMEDOUT;
> +}
...
> switch (dev->flags & MODEL_MASK) {
> case MODEL_AMD_NAVI_GPU:
> + if (dev->atomic) {
> + ret = -EOPNOTSUPP;
> + goto done_nolock;
> + }
Why only AMD case?
> ret = amd_i2c_dw_xfer_quirk(adap, msgs, num);
> goto done_nolock;
> default:
> break;
> }
--
With Best Regards,
Andy Shevchenko
prev parent reply other threads:[~2025-08-20 17:00 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-20 15:31 [PATCH 0/2] i2c: designware: Implement atomic transfer suppot Jisheng Zhang
2025-08-20 15:31 ` [PATCH 1/2] i2c: designware: Avoid taking clk_prepare mutex in PM callbacks Jisheng Zhang
2025-08-20 16:05 ` Andy Shevchenko
2025-08-20 16:33 ` Jisheng Zhang
2025-08-21 12:45 ` Jarkko Nikula
2025-08-21 13:01 ` Andy Shevchenko
2025-08-21 16:32 ` Jisheng Zhang
2025-08-22 9:18 ` Andy Shevchenko
2025-08-22 9:34 ` Andy Shevchenko
2025-08-22 13:56 ` Jisheng Zhang
2025-08-22 23:51 ` Jisheng Zhang
2025-08-20 15:31 ` [PATCH 2/2] i2c: designware: Implement atomic transfer suppot Jisheng Zhang
2025-08-20 17:00 ` Andy Shevchenko [this message]
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=aKX_PwQWoe9S0QjP@smile.fi.intel.com \
--to=andriy.shevchenko@linux.intel.com \
--cc=andi.shyti@kernel.org \
--cc=jarkko.nikula@linux.intel.com \
--cc=jsd@semihalf.com \
--cc=jszhang@kernel.org \
--cc=linux-i2c@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mika.westerberg@linux.intel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.