From: David Woodhouse <dwmw2@infradead.org>
To: "Chalios, Babis" <bchalios@amazon.es>,
"robh@kernel.org" <robh@kernel.org>,
"krzk+dt@kernel.org" <krzk+dt@kernel.org>,
"conor+dt@kernel.org" <conor+dt@kernel.org>,
"richardcochran@gmail.com" <richardcochran@gmail.com>,
"andrew+netdev@lunn.ch" <andrew+netdev@lunn.ch>,
"davem@davemloft.net" <davem@davemloft.net>,
"edumazet@google.com" <edumazet@google.com>,
"kuba@kernel.org" <kuba@kernel.org>,
"pabeni@redhat.com" <pabeni@redhat.com>
Cc: "devicetree@vger.kernel.org" <devicetree@vger.kernel.org>,
"netdev@vger.kernel.org" <netdev@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"Graf (AWS), Alexander" <graf@amazon.de>,
"mzxreary@0pointer.de" <mzxreary@0pointer.de>,
"Cali, Marco" <xmarcalx@amazon.co.uk>
Subject: Re: [PATCH v3 2/4] ptp: vmclock: support device notifications
Date: Wed, 03 Dec 2025 16:52:02 +0000 [thread overview]
Message-ID: <da92811ade53edfa1ced7995fc4344f557a4d431.camel@infradead.org> (raw)
In-Reply-To: <20251203123539.7292-3-bchalios@amazon.es>
[-- Attachment #1: Type: text/plain, Size: 2651 bytes --]
On Wed, 2025-12-03 at 12:36 +0000, Chalios, Babis wrote:
> From: "Chalios, Babis" <bchalios@amazon.es>
>
> Add optional support for device notifications in VMClock. When
> supported, the hypervisor will send a device notification every time it
> updates the seq_count to a new even value.
>
> Moreover, add support for poll() in VMClock as a means to propagate this
> notification to user space. poll() will return a POLLIN event to
> listeners every time seq_count changes to a value different than the one
> last seen (since open() or last read()/pread()). This means that when
> poll() returns a POLLIN event, listeners need to use read() to observe
> what has changed and update the reader's view of seq_count. In other
> words, after a poll() returned, all subsequent calls to poll() will
> immediately return with a POLLIN event until the listener calls read().
>
> The device advertises support for the notification mechanism by setting
> flag VMCLOCK_FLAG_NOTIFICATION_PRESENT in vmclock_abi flags field. If
> the flag is not present the driver won't setup the ACPI notification
> handler and poll() will always immediately return POLLHUP.
>
> Signed-off-by: Babis Chalios <bchalios@amazon.es>
Mostly looks good to me; thanks. However...
> +static __poll_t vmclock_miscdev_poll(struct file *fp, poll_table *wait)
> +{
> + struct vmclock_file_state *fst = fp->private_data;
> + struct vmclock_state *st = fst->st;
> + uint32_t seq;
> +
> + /*
> + * Hypervisor will not send us any notifications, so fail immediately
> + * to avoid having caller sleeping for ever.
> + */
> + if (!(st->clk->flags & VMCLOCK_FLAG_NOTIFICATION_PRESENT))
> + return POLLHUP;
Missing le64_to_cpu() there. And I guess *strictly* speaking we should
do the seq_lock dance whenever we read the dynamic fields, although
that only ever matters if a hypervisor were to bump seq_count to an odd
value, *then* set the VMCLOCK_FLAG_NOTIFICATION_PRESENT flag, then
clear the flag again before bumping seq_count to even, and blame the
*guest* for looking at the wrong time. Which is frankly insane, and I
don't think I care.
So with the le64_to_cpu() added,
Reviewed-by: David Woodhouse <dwmw@amazon.co.uk>
Don't post again for a few days though; three versions in 48 hours is
enough :)
> +static int vmclock_miscdev_release(struct inode *inode, struct file *fp)
> +{
> + kfree(fp->private_data);
> + return 0;
> +}
Still bugs me a little. I note simple_attr_release() is exported and
does the same, but I guess we'd want to move and rename that before we
try to use it from places like this.
[-- Attachment #2: smime.p7s --]
[-- Type: application/pkcs7-signature, Size: 5069 bytes --]
next prev parent reply other threads:[~2025-12-03 16:52 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-03 12:35 [PATCH v3 0/4] ptp: vmclock: Add VM generation counter and ACPI notification Chalios, Babis
2025-12-03 12:35 ` [PATCH v3 1/4] ptp: vmclock: add vm generation counter Chalios, Babis
2025-12-03 12:36 ` [PATCH v3 2/4] ptp: vmclock: support device notifications Chalios, Babis
2025-12-03 16:52 ` David Woodhouse [this message]
2025-12-03 12:36 ` [PATCH v3 3/4] dt-bindings: ptp: Add amazon,vmclock Chalios, Babis
2025-12-03 13:46 ` Krzysztof Kozlowski
2025-12-03 12:36 ` [PATCH v3 4/4] ptp: ptp_vmclock: Add device tree support Chalios, Babis
2025-12-11 19:30 ` Sai Krishna Gajula
2025-12-04 11:09 ` [PATCH v3 0/4] ptp: vmclock: Add VM generation counter and ACPI notification Paolo Abeni
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=da92811ade53edfa1ced7995fc4344f557a4d431.camel@infradead.org \
--to=dwmw2@infradead.org \
--cc=andrew+netdev@lunn.ch \
--cc=bchalios@amazon.es \
--cc=conor+dt@kernel.org \
--cc=davem@davemloft.net \
--cc=devicetree@vger.kernel.org \
--cc=edumazet@google.com \
--cc=graf@amazon.de \
--cc=krzk+dt@kernel.org \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mzxreary@0pointer.de \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=richardcochran@gmail.com \
--cc=robh@kernel.org \
--cc=xmarcalx@amazon.co.uk \
/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®