From: Stefan Wahren <wahrenst@gmx.net>
To: Nathan Chancellor <nathan@kernel.org>,
Andrew Lunn <andrew+netdev@lunn.ch>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@kernel.org>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>
Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
llvm@lists.linux.dev, stable@vger.kernel.org
Subject: Re: [PATCH net] qca_spi: Avoid unsequenced accesses to jiffies in qcaspi_netdev_tx_timeout()
Date: Sun, 15 Nov 2026 15:08:23 +0100 [thread overview]
Message-ID: <490e6ccf-0cc0-4db6-b076-5d4ac5f5b8a4@gmx.net> (raw)
In-Reply-To: <20261114-qca_spi-wunsequenced-v1-1-6b219b906db7@kernel.org>
Hi Nathan,
Am 15.11.26 um 05:39 schrieb Nathan Chancellor:
> After a recent improvement in clang to warn on unsequenced accesses to
> volatile variables [1], an instance appears in
> qcaspi_netdev_tx_timeout(), which can break the build with
> CONFIG_WERROR=y / W=e:
>
> drivers/net/ethernet/qualcomm/qca_spi.c:805:16: error: unsequenced accesses to volatile qualified 'jiffies' [-Werror,-Wunsequenced]
> 805 | jiffies, jiffies - dev_trans_start(dev));
> | ~~~~~~~ ^
>
> Per C11 5.1.2.3.2, accessing a volatile object is a side effect. Per C11
> 6.5.2, unsequenced side effects on the same scalar object are undefined
> behavior. Per C11 6.5.2.2.10/12, the evaluation of arguments in a
> function call is indeterminately sequenced, meaning any side effects in
> the arguments are unsequenced.
>
> Add a local variable to hold the value of jiffies before the function
> call so that there are no unsequenced side effects, clearing up the
> warning.
>
> Cc: stable@vger.kernel.org
> Fixes: 291ab06ecf67 ("net: qualcomm: new Ethernet over SPI driver for QCA7000")
> Closes: https://github.com/ClangBuiltLinux/linux/issues/2197
> Link: https://github.com/llvm/llvm-project/commit/955715460eaf9188c241c74750637fc82dfcc423 [1]
> Signed-off-by: Nathan Chancellor <nathan@kernel.org>
> ---
> drivers/net/ethernet/qualcomm/qca_spi.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/net/ethernet/qualcomm/qca_spi.c b/drivers/net/ethernet/qualcomm/qca_spi.c
> index 38a779f4b866..3ea745d4aef7 100644
> --- a/drivers/net/ethernet/qualcomm/qca_spi.c
> +++ b/drivers/net/ethernet/qualcomm/qca_spi.c
> @@ -800,9 +800,10 @@ static void
> qcaspi_netdev_tx_timeout(struct net_device *dev, unsigned int txqueue)
> {
> struct qcaspi *qca = netdev_priv(dev);
> + unsigned long j = jiffies;
>
> netdev_info(qca->net_dev, "Transmit timeout at %ld, latency %ld\n",
> - jiffies, jiffies - dev_trans_start(dev));
> + j, j - dev_trans_start(dev));
In general agree, but imo the jiffies itself were not helpful to debug a
transmit timeout in the first place, so I hope we can avoid adding a
local variable here.
How about this:
netdev_info(qca->net_dev, "Transmit timeout, latency %ld\n",
jiffies - dev_trans_start(dev));
The timestamp from netdev_info() is much more helpful.
Thanks
> qca->net_dev->stats.tx_errors++;
> /* Trigger tx queue flush and QCA7000 reset */
> set_bit(SPI_RESET, &qca->flags);
>
> ---
> base-commit: aa40afa831ebfe45e40a23721711059f2ac584d4
> change-id: 20261114-qca_spi-wunsequenced-a81e54616844
>
> Best regards,
> --
> Cheers,
> Nathan
prev parent reply other threads:[~2026-11-15 14:08 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-15 4:39 Nathan Chancellor
2026-11-15 14:08 ` Stefan Wahren [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=490e6ccf-0cc0-4db6-b076-5d4ac5f5b8a4@gmx.net \
--to=wahrenst@gmx.net \
--cc=andrew+netdev@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@kernel.org \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=llvm@lists.linux.dev \
--cc=nathan@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=stable@vger.kernel.org \
/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
all inboxes | Powered by JetHome®