From: Paolo Abeni <pabeni@redhat.com>
To: akiyano@amazon.com
Cc: davem@davemloft.net, kuba@kernel.org, netdev@vger.kernel.org,
richardcochran@gmail.com, edumazet@google.com, pabeni@redhat.com,
dwmw2@infradead.org, tglx@linutronix.de, mlichvar@redhat.com,
andrew+netdev@lunn.ch, guwen@linux.alibaba.com,
xuanzhuo@linux.alibaba.com, dwmw@amazon.com, ysarna@amazon.com,
zorik@amazon.com, matua@amazon.com, saeedb@amazon.com,
msw@amazon.com, aliguori@amazon.com, nafea@amazon.com,
evgenys@amazon.com, netanel@amazon.com, alisaidi@amazon.com,
benh@amazon.com, ndagan@amazon.com, darinzon@amazon.com,
evostrov@amazon.com, ofirt@amazon.com, amitbern@amazon.com,
linux-kselftest@vger.kernel.org, shuah@kernel.org,
vadim.fedorenko@linux.dev
Subject: Re: [PATCH v3 net-next 6/7] net: ena: Add error bound to PHC communication layer
Date: Thu, 21 May 2026 11:16:32 +0200 [thread overview]
Message-ID: <20260521091644.84928-1-pabeni@redhat.com> (raw)
In-Reply-To: <20260515164033.6403-7-akiyano@amazon.com>
From: AI Reviewer <ai@example.com>
This is an AI-generated review of your patch. The human sending this
email has considered the AI review valid, or at least plausible.
Full review at: https://netdev-ai.bots.linux.dev/sashiko/
---
net: ena: Add error bound to PHC communication layer
This commit extends the ENA PHC communication layer to retrieve an
error_bound value from the device alongside the timestamp, and adds a
phc_err_eb statistic to count error_bound retrieval failures.
> diff --git a/drivers/net/ethernet/amazon/ena/ena_com.c b/drivers/net/ethernet/amazon/ena/ena_com.c
> index 257910460bd8..832c4c1d0e5e 100644
> --- a/drivers/net/ethernet/amazon/ena/ena_com.c
> +++ b/drivers/net/ethernet/amazon/ena/ena_com.c
[ ... ]
> @@ -1882,14 +1888,15 @@ int ena_com_phc_get_timestamp(struct ena_com_dev *ena_dev, u64 *timestamp)
> }
>
> /* req_id was updated by the device which indicates that
> - * PHC timestamp and error_flags are updated too,
> - * checking errors before retrieving timestamp
> + * PHC timestamp, error_bound and error_flags are updated too,
> + * checking error flags before retrieving timestamp and
> + * error_bound values
> */
> if (unlikely(resp->error_flags & ENA_PHC_ERROR_FLAGS)) {
[High]
Once req_id is observed equal to phc->req_id, the function reads
resp->error_flags, resp->timestamp and (now) resp->error_bound from the
device-shared DMA buffer. The updated comment explicitly states that once
req_id is observed updated, "PHC timestamp, error_bound and error_flags
are updated too" — which is the producer/consumer pattern that normally
requires a read barrier between the index check and the dependent data
loads.
The buffer is declared volatile and the req_id check uses READ_ONCE(),
but on weakly-ordered architectures such as arm64 (which includes AWS
Graviton, a primary ENA deployment target) neither volatile nor
READ_ONCE() orders dependent loads against DMA writes from the device.
Without a dma_rmb() the CPU may observe the new req_id while still
returning stale or torn values for the 64-bit timestamp, the error_bound,
or the error_flags.
Could a dma_rmb() be added between the req_id check and the subsequent
reads of resp->error_flags / resp->timestamp / resp->error_bound, similar
to the pattern already used elsewhere in the same driver?
For example, ena_com_handle_admin_completion() in the same file does:
/* Do not read the rest of the completion entry before the
* phase bit was validated
*/
dma_rmb();
and ena_com_aenq_intr_handler() has:
/* Make sure the phase bit (ownership) is as expected before
* reading the rest of the descriptor.
*/
dma_rmb();
The same shape applies here: device writes data fields, then writes
req_id last; driver checks req_id, then reads data fields.
This ordering issue is not introduced by this patch — the timestamp and
error_flags reads after the req_id check existed before — but the patch
extends the same unsynchronized read pattern to a third field
(error_bound) and the new comment now documents the assumed ordering
that is not actually enforced. Would it make sense to address the missing
dma_rmb() while touching this code?
> /* Retrieved invalid PHC timestamp, PHC enters into
[ ... ]
> @@ -1897,12 +1904,15 @@ int ena_com_phc_get_timestamp(struct ena_com_dev *ena_dev, u64 *timestamp)
>
> /* PHC timestamp value is returned to the caller */
> *timestamp = resp->timestamp;
> + if (error_bound)
> + *error_bound = resp->error_bound;
>
> /* Update statistic on valid PHC timestamp retrieval */
> phc->stats.phc_cnt++;
[ ... ]
--
This is an AI-generated review.
next prev parent reply other threads:[~2026-05-21 9:17 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-15 16:40 [PATCH v3 net-next 0/7] ptp: Add PHC timestamp quality attributes Arthur Kiyanovski
2026-05-15 16:40 ` [PATCH v3 net-next 1/7] ptp: Add ioctls for PHC timestamps with " Arthur Kiyanovski
2026-05-21 13:41 ` David Woodhouse
2026-05-21 20:11 ` David Woodhouse
2026-05-22 10:10 ` David Woodhouse
2026-05-15 16:40 ` [PATCH v3 net-next 2/7] selftests/ptp: Extract print_system_timestamp helper in testptp Arthur Kiyanovski
2026-05-21 13:42 ` David Woodhouse
2026-05-15 16:40 ` [PATCH v3 net-next 3/7] selftests/ptp: Add testptp support for attributes ioctls Arthur Kiyanovski
2026-05-21 13:50 ` David Woodhouse
2026-05-15 16:40 ` [PATCH v3 net-next 4/7] ptp: ptp_vmclock: Implement " Arthur Kiyanovski
2026-05-21 14:07 ` David Woodhouse
2026-05-15 16:40 ` [PATCH v3 net-next 5/7] net: ena: Update PHC admin interface for error bound support Arthur Kiyanovski
2026-05-15 16:40 ` [PATCH v3 net-next 6/7] net: ena: Add error bound to PHC communication layer Arthur Kiyanovski
2026-05-21 9:16 ` Paolo Abeni [this message]
2026-05-21 21:43 ` Arthur Kiyanovski
2026-05-15 16:40 ` [PATCH v3 net-next 7/7] net: ena: Implement gettimexattrs64 callback for PTP attributes Arthur Kiyanovski
2026-05-19 1:26 ` [PATCH v3 net-next 0/7] ptp: Add PHC timestamp quality attributes Jakub Kicinski
2026-05-19 18:17 ` Arthur Kiyanovski
2026-05-19 23:33 ` Jakub Kicinski
2026-05-19 23:45 ` David Woodhouse
2026-05-21 9:19 ` Paolo Abeni
2026-05-21 13:09 ` David Woodhouse
2026-05-22 4:34 ` Richard Cochran
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=20260521091644.84928-1-pabeni@redhat.com \
--to=pabeni@redhat.com \
--cc=akiyano@amazon.com \
--cc=aliguori@amazon.com \
--cc=alisaidi@amazon.com \
--cc=amitbern@amazon.com \
--cc=andrew+netdev@lunn.ch \
--cc=benh@amazon.com \
--cc=darinzon@amazon.com \
--cc=davem@davemloft.net \
--cc=dwmw2@infradead.org \
--cc=dwmw@amazon.com \
--cc=edumazet@google.com \
--cc=evgenys@amazon.com \
--cc=evostrov@amazon.com \
--cc=guwen@linux.alibaba.com \
--cc=kuba@kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=matua@amazon.com \
--cc=mlichvar@redhat.com \
--cc=msw@amazon.com \
--cc=nafea@amazon.com \
--cc=ndagan@amazon.com \
--cc=netanel@amazon.com \
--cc=netdev@vger.kernel.org \
--cc=ofirt@amazon.com \
--cc=richardcochran@gmail.com \
--cc=saeedb@amazon.com \
--cc=shuah@kernel.org \
--cc=tglx@linutronix.de \
--cc=vadim.fedorenko@linux.dev \
--cc=xuanzhuo@linux.alibaba.com \
--cc=ysarna@amazon.com \
--cc=zorik@amazon.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