From: netdev-bot+sashiko@kernel.org
To: akiyano@amazon.com
Cc: davem@davemloft.net, kuba@kernel.org, richardcochran@gmail.com,
netdev@vger.kernel.org, edumazet@google.com, pabeni@redhat.com,
dwmw2@infradead.org, tglx@linutronix.de, mlichvar@redhat.com,
maciek@machnikowski.net, andrew+netdev@lunn.ch, andrew@lunn.ch,
cjubran@nvidia.com, 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, linux-doc@vger.kernel.org,
shuah@kernel.org, corbet@lwn.net, skhan@linuxfoundation.org,
horms@kernel.org, bhelgaas@google.com, vadim.fedorenko@linux.dev,
dwmw@amazon.co.uk
Subject: Re: [PATCH v7 net-next 7/7] net: ena: Implement gettimexattrs64 callback for PTP attributes
Date: Thu, 10 Sep 2026 08:31:36 +0000 [thread overview]
Message-ID: <178902909615.219967.17316162800507267391@kernel.org> (raw)
In-Reply-To: <20260909073136.12863-8-akiyano@amazon.com>
Thank you for your contribution! Sashiko AI review found 2 potential
issue(s) to consider:
Critical: 0 · High: 0 · Medium: 1 · Low: 1
- [Medium] ena_phc_gettimexattrs64()
(drivers/net/ethernet/amazon/ena/ena_phc.c:57-60) unconditionally…
- [Low] ena_phc_gettimexattrs64()
(drivers/net/ethernet/amazon/ena/ena_phc.c:28-62) is a verbatim…
--
net: ena: Implement gettimexattrs64 callback for PTP attributes
Adds ena_phc_gettimexattrs64() to the ENA PHC code and registers it in
ena_ptp_clock_info so the PTP_SYS_OFFSET_EXTENDED_ATTRS ioctl is supported.
The new callback reports the device error_bound value and sets the
corresponding valid bit; other attributes are left unreported.
A couple of questions below.
> diff --git a/drivers/net/ethernet/amazon/ena/ena_phc.c b/drivers/net/ethernet/amazon/ena/ena_phc.c
> index 2bcb5af564e2..725c36fe3f6e 100644
> --- a/drivers/net/ethernet/amazon/ena/ena_phc.c
> +++ b/drivers/net/ethernet/amazon/ena/ena_phc.c
> @@ -25,6 +25,43 @@ static int ena_phc_feature_enable(struct ptp_clock_info *clock_info,
> return -EOPNOTSUPP;
> }
>
> +static int ena_phc_gettimexattrs64(struct ptp_clock_info *clock_info,
> + struct timespec64 *ts,
> + struct ptp_system_timestamp *sts,
> + struct ptp_clock_attrs *att)
> +{
> + struct ena_phc_info *phc_info =
> + container_of(clock_info, struct ena_phc_info, clock_info);
> + u32 error_bound_nsec;
> + unsigned long flags;
> + u64 timestamp_nsec;
> + int rc;
> +
> + spin_lock_irqsave(&phc_info->lock, flags);
> +
> + ptp_read_system_prets(sts);
> +
> + rc = ena_com_phc_get_timestamp(phc_info->adapter->ena_dev,
> + ×tamp_nsec,
> + &error_bound_nsec);
> +
> + ptp_read_system_postts(sts);
> +
> + spin_unlock_irqrestore(&phc_info->lock, flags);
> +
> + if (rc)
> + return rc;
> +
> + *ts = ns_to_timespec64(timestamp_nsec);
> +
[Severity: Low]
This isn't a bug, but the body above is a verbatim copy of
ena_phc_gettimex64(): same container_of(), same
spin_lock_irqsave(&phc_info->lock, flags) / ptp_read_system_prets() /
ena_com_phc_get_timestamp() / ptp_read_system_postts() /
spin_unlock_irqrestore() sequence, same rc handling and same
*ts = ns_to_timespec64(timestamp_nsec).
Since ena_phc_gettimexattrs64() already tolerates att == NULL (and is in
fact called with sts == NULL and att == NULL from ptp_clock_gettime() in
drivers/ptp/ptp_clock.c), could ena_phc_gettimex64() simply become:
static int ena_phc_gettimex64(struct ptp_clock_info *clock_info,
struct timespec64 *ts,
struct ptp_system_timestamp *sts)
{
return ena_phc_gettimexattrs64(clock_info, ts, sts, NULL);
}
Passing a non-NULL error_bound to ena_com_phc_get_timestamp() has no side
effect beyond storing the value, since that function guards the store with
if (error_bound). Keeping two copies of the PHC doorbell/poll sequence means
a later fix can land in only one of them.
> + if (att) {
> + att->error_bound = error_bound_nsec;
> + att->valid |= PTP_ATTRS_VALID_ERROR_BOUND;
> + }
[Severity: Medium]
Is PTP_ATTRS_VALID_ERROR_BOUND being advertised here without a device
capability gate?
The only capability check in the driver is in ena_com_phc_config(), which
accepts:
/* Supporting only PHC V0 (readless mode with error bound) */
if (get_feat_resp.u.phc.version != ENA_ADMIN_PHC_FEATURE_VERSION_0) {
ENA_ADMIN_PHC_FEATURE_VERSION_0 is 0, which is the same numeric value that
pre-series firmware reports for the old name ENA_ADMIN_PHC_TYPE_READLESS.
The preceding commit only renames u8 type to u8 version and re-documents 0
as "readless with error_bound"; it also carves u32 error_bound out of the
previously reserved (must-be-zero) bytes of struct ena_admin_phc_resp.
So can a PHC-capable device whose firmware predates error_bound still pass
that version check, leave the DMA bytes at zero, and have
ena_com_phc_get_timestamp() copy that zero out:
/* PHC timestamp value is returned to the caller */
*timestamp = resp->timestamp;
if (error_bound)
*error_bound = resp->error_bound;
In that case userspace receives error_bound = 0 ns with the validity bit
asserted, i.e. it is told the timestamp is exact, rather than being told the
attribute is unavailable, which is what the valid bitmask exists to express.
The device-side error signal does not seem to help here either:
ENA_ADMIN_PHC_ERROR_FLAG_ERROR_BOUND (checked via ENA_PHC_ERROR_FLAGS) is a
new flag that error_bound-unaware firmware would never set.
Would it make sense to gate the valid bit on a distinct feature version
value or an explicitly advertised device bit? Alternatively, if every
PHC-capable ENA firmware that reports version 0 does populate error_bound
and no older firmware exists in the field, could the commit message state
that?
> +
> + return 0;
> +}
> +
> static int ena_phc_gettimex64(struct ptp_clock_info *clock_info,
> struct timespec64 *ts,
> struct ptp_system_timestamp *sts)
[ ... ]
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20260909073136.12863-1-akiyano%40amazon.com
prev parent reply other threads:[~2026-09-10 8:31 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-09 7:31 [PATCH v7 net-next 0/7] ptp: Add PHC timestamp quality attributes Arthur Kiyanovski
2026-09-09 7:31 ` [PATCH v7 net-next 1/7] ptp: Add ioctls for PHC timestamps with " Arthur Kiyanovski
2026-09-10 8:31 ` netdev-bot+sashiko
2026-09-09 7:31 ` [PATCH v7 net-next 2/7] selftests/ptp: Extract print_system_timestamp helper in testptp Arthur Kiyanovski
2026-09-09 7:31 ` [PATCH v7 net-next 3/7] selftests/ptp: Add testptp support for attributes ioctls Arthur Kiyanovski
2026-09-10 8:31 ` netdev-bot+sashiko
2026-09-09 7:31 ` [PATCH v7 net-next 4/7] ptp: ptp_vmclock: Implement " Arthur Kiyanovski
2026-09-10 8:31 ` netdev-bot+sashiko
2026-09-09 7:31 ` [PATCH v7 net-next 5/7] net: ena: Update PHC admin interface for error bound support Arthur Kiyanovski
2026-09-10 8:31 ` netdev-bot+sashiko
2026-09-09 7:31 ` [PATCH v7 net-next 6/7] net: ena: Add error bound to PHC communication layer Arthur Kiyanovski
2026-09-09 7:31 ` [PATCH v7 net-next 7/7] net: ena: Implement gettimexattrs64 callback for PTP attributes Arthur Kiyanovski
2026-09-10 8:31 ` netdev-bot+sashiko [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=178902909615.219967.17316162800507267391@kernel.org \
--to=netdev-bot+sashiko@kernel.org \
--cc=akiyano@amazon.com \
--cc=aliguori@amazon.com \
--cc=alisaidi@amazon.com \
--cc=amitbern@amazon.com \
--cc=andrew+netdev@lunn.ch \
--cc=andrew@lunn.ch \
--cc=benh@amazon.com \
--cc=bhelgaas@google.com \
--cc=cjubran@nvidia.com \
--cc=corbet@lwn.net \
--cc=darinzon@amazon.com \
--cc=davem@davemloft.net \
--cc=dwmw2@infradead.org \
--cc=dwmw@amazon.co.uk \
--cc=dwmw@amazon.com \
--cc=edumazet@google.com \
--cc=evgenys@amazon.com \
--cc=evostrov@amazon.com \
--cc=guwen@linux.alibaba.com \
--cc=horms@kernel.org \
--cc=kuba@kernel.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=maciek@machnikowski.net \
--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=pabeni@redhat.com \
--cc=richardcochran@gmail.com \
--cc=saeedb@amazon.com \
--cc=shuah@kernel.org \
--cc=skhan@linuxfoundation.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