From: Ivan Vecera <ivecera@redhat.com>
To: Jakub Kicinski <kuba@kernel.org>
Cc: mschmidt@redhat.com, linux-kernel@vger.kernel.org,
Prathosh.Satish@microchip.com, horms@kernel.org,
vadim.fedorenko@linux.dev, arkadiusz.kubalewski@intel.com,
jiri@resnulli.us, poros@redhat.com, netdev@vger.kernel.org
Subject: Re: [net-next,5/6] dpll: zl3073x: add reference priority to zl3073x_chan
Date: Sun, 15 Mar 2026 18:38:25 +0100 [thread overview]
Message-ID: <a4ffd3b0-e5a0-4c2c-9f2a-117034a0e4b7@redhat.com> (raw)
In-Reply-To: <20260314195358.2710968-2-kuba@kernel.org>
On 3/14/26 8:53 PM, Jakub Kicinski wrote:
> This is an AI-generated review of your patch. The human sending this
> email says "Is this legit? Quite hard to follow the logic of this change :/"
>
> For local reproduction steps see https://netdev-ai.bots.linux.dev/ai-local.html
> ---
> dpll: zl3073x: add reference priority to zl3073x_chan
>
> This commit caches the ZL_REG_DPLL_REF_PRIO registers in the zl3073x_chan
> cfg group, adding a ref_prio[] array and inline helpers for accessing
> priority values. It extends state_fetch and state_set with DPLL mailbox
> operations to read and write these priority registers.
>
>> diff --git a/drivers/dpll/zl3073x/chan.c b/drivers/dpll/zl3073x/chan.c
>> index 10189c8a5ded..74d00cee624e 100644
>> --- a/drivers/dpll/zl3073x/chan.c
>> +++ b/drivers/dpll/zl3073x/chan.c
>
> [ ... ]
>
>> @@ -85,7 +102,9 @@ const struct zl3073x_chan *zl3073x_chan_state_get(struct zl3073x_dev *zldev,
>> * @chan: desired channel state
>> *
>> * Skips the HW write if the configuration is unchanged, and otherwise
>> - * writes the mode_refsel register to hardware.
>> + * writes only the changed registers to hardware. The mode_refsel register
>> + * is written directly, while the reference priority registers are written
>> + * via the DPLL mailbox interface.
>> *
>> * Return: 0 on success, <0 on HW error
>> */
>> @@ -93,14 +112,48 @@ int zl3073x_chan_state_set(struct zl3073x_dev *zldev, u8 index,
>> const struct zl3073x_chan *chan)
>> {
>> struct zl3073x_chan *dchan = &zldev->chan[index];
>> - int rc;
>> + int rc, i;
>>
>> /* Skip HW write if configuration hasn't changed */
>> if (!memcmp(&dchan->cfg, &chan->cfg, sizeof(chan->cfg)))
>> return 0;
>>
>> - rc = zl3073x_write_u8(zldev, ZL_REG_DPLL_MODE_REFSEL(index),
>> - chan->mode_refsel);
>> + /* Direct register write for mode_refsel */
>> + if (dchan->mode_refsel != chan->mode_refsel) {
>> + rc = zl3073x_write_u8(zldev, ZL_REG_DPLL_MODE_REFSEL(index),
>> + chan->mode_refsel);
>> + if (rc)
>> + return rc;
>> + }
>> +
>> + /* Mailbox write for ref_prio if changed */
>> + if (!memcmp(dchan->ref_prio, chan->ref_prio, sizeof(chan->ref_prio))) {
>> + dchan->cfg = chan->cfg;
>> + return 0;
>> + }
>> +
>> + guard(mutex)(&zldev->multiop_lock);
>> +
>> + /* Read DPLL configuration into mailbox */
>> + rc = zl3073x_mb_op(zldev, ZL_REG_DPLL_MB_SEM, ZL_DPLL_MB_SEM_RD,
>> + ZL_REG_DPLL_MB_MASK, BIT(index));
>> + if (rc)
>> + return rc;
>> +
>> + /* Update changed ref_prio registers */
>> + for (i = 0; i < ARRAY_SIZE(chan->ref_prio); i++) {
>> + if (dchan->ref_prio[i] != chan->ref_prio[i]) {
>> + rc = zl3073x_write_u8(zldev,
>> + ZL_REG_DPLL_REF_PRIO(i),
>> + chan->ref_prio[i]);
>> + if (rc)
>> + return rc;
>> + }
>> + }
>> +
>> + /* Commit DPLL configuration */
>> + rc = zl3073x_mb_op(zldev, ZL_REG_DPLL_MB_SEM, ZL_DPLL_MB_SEM_WR,
>> + ZL_REG_DPLL_MB_MASK, BIT(index));
>> if (rc)
>> return rc;
>>
>
> Could this function leave the cache and hardware out of sync?
>
> When both mode_refsel and ref_prio have changed, the function writes
> mode_refsel to hardware first. If the subsequent mailbox operation fails
> (during the mailbox read, a ref_prio write, or the mailbox commit), the
> function returns an error without executing 'dchan->cfg = chan->cfg'.
This potential situation is very unusual (mode_refsel updated and
mailbox access erroneous) but yes, after successful write of mode_refsel
dchan->mon_refsel should be updated to avoid this issue.
Will fix in v2.
Ivan
next prev parent reply other threads:[~2026-03-15 17:38 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-11 19:00 [PATCH net-next 0/6] dpll: zl3073x: refactor state management Ivan Vecera
2026-03-11 19:00 ` [PATCH net-next 1/6] dpll: zl3073x: use struct_group to partition states Ivan Vecera
2026-03-11 19:00 ` [PATCH net-next 2/6] dpll: zl3073x: add zl3073x_ref_state_update helper Ivan Vecera
2026-03-11 19:00 ` [PATCH net-next 3/6] dpll: zl3073x: introduce zl3073x_chan for DPLL channel state Ivan Vecera
2026-03-11 19:00 ` [PATCH net-next 4/6] dpll: zl3073x: add DPLL channel status fields to zl3073x_chan Ivan Vecera
2026-03-11 19:00 ` [PATCH net-next 5/6] dpll: zl3073x: add reference priority " Ivan Vecera
2026-03-14 19:53 ` [net-next,5/6] " Jakub Kicinski
2026-03-15 17:38 ` Ivan Vecera [this message]
2026-03-11 19:00 ` [PATCH net-next 6/6] dpll: zl3073x: drop selected and simplify connected ref getter Ivan Vecera
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=a4ffd3b0-e5a0-4c2c-9f2a-117034a0e4b7@redhat.com \
--to=ivecera@redhat.com \
--cc=Prathosh.Satish@microchip.com \
--cc=arkadiusz.kubalewski@intel.com \
--cc=horms@kernel.org \
--cc=jiri@resnulli.us \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mschmidt@redhat.com \
--cc=netdev@vger.kernel.org \
--cc=poros@redhat.com \
--cc=vadim.fedorenko@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