On Fri, Feb 06, 2026 at 02:48:17PM +0000, Shameer Kolothum wrote:
> +static void tegra241_cmdqv_event_read(void *opaque)
> +{
[...]
> + bytes = read(cmdqv->veventq->veventq_fd, &buf, sizeof(buf));
> + if (bytes <= 0) {
> + if (errno == EAGAIN || errno == EINTR) {
> + return;
> + }
> + error_report_once("Tegra241 CMDQV: vEVENTQ: read failed (%m)");
> + return;
> + }
> +
> + if (bytes == sizeof(buf.hdr) &&
> + (buf.hdr.flags & IOMMU_VEVENTQ_FLAG_LOST_EVENTS)) {
> + error_report_once("Tegra241 CMDQV: vEVENTQ has lost events");
> + return;
> + }
> +
> + if (bytes < sizeof(buf)) {
> + error_report_once("Tegra241 `CMDQV: vEVENTQ: incomplete read
> (%zd/%zd bytes)",
> + bytes, sizeof(buf));
> + cmdqv->event_start = false;
> + return;
> + }
> +
> + /* Check sequence in hdr for lost events if any */
> + if (cmdqv->event_start && (buf.hdr.sequence - last_seq != 1)) {
> + error_report_once("Tegra241 CMDQV: vEVENTQ: detected lost %u
> event(s)",
> + buf.hdr.sequence - last_seq - 1);
> + }
It shares the exact same routine with smmuv3_accel_event_read().
Can we put these into a common helper?
I also suggested in the veventq series that event_start/last_seq
could be moved into the common structure.
> veventq = g_new(IOMMUFDVeventq, 1);
> veventq->veventq_id = veventq_id;
> veventq->veventq_fd = veventq_fd;
> veventq->viommu = viommu;
> cmdqv->veventq = veventq;
>
> + /* Set up event handler for veventq fd */
> + qemu_set_fd_handler(veventq_fd, tegra241_cmdqv_event_read, NULL, s);
Should pass in "cmdqv" instead of "s".
Nicolin