All of lore.kernel.org
 help / color / mirror / Atom feed
From: Nicolin Chen <nicolinc@nvidia.com>
To: Shameer Kolothum Thodi <skolothumtho@nvidia.com>
Cc: "eric.auger@redhat.com" <eric.auger@redhat.com>,
	"qemu-arm@nongnu.org" <qemu-arm@nongnu.org>,
	"qemu-devel@nongnu.org" <qemu-devel@nongnu.org>,
	"peter.maydell@linaro.org" <peter.maydell@linaro.org>,
	"clg@redhat.com" <clg@redhat.com>,
	"alex@shazbot.org" <alex@shazbot.org>,
	Nathan Chen <nathanc@nvidia.com>, Matt Ochs <mochs@nvidia.com>,
	Jiandi An <jan@nvidia.com>, Jason Gunthorpe <jgg@nvidia.com>,
	"zhenzhong.duan@intel.com" <zhenzhong.duan@intel.com>,
	Krishnakant Jaju <kjaju@nvidia.com>,
	"phrdina@redhat.com" <phrdina@redhat.com>
Subject: Re: [PATCH v4 20/31] hw/arm/tegra241-cmdqv: Use mmap'd VINTF page0 as VCMDQ backing
Date: Wed, 6 May 2026 13:55:26 -0700	[thread overview]
Message-ID: <afuqvoODHtr2KoSk@nvidia.com> (raw)
In-Reply-To: <CH3PR12MB7548FA36B3EB6386EDF09B3CAB3F2@CH3PR12MB7548.namprd12.prod.outlook.com>

On Wed, May 06, 2026 at 01:13:53PM -0700, Shameer Kolothum Thodi wrote:
> > -----Original Message-----
> > On Wed, May 06, 2026 at 06:16:00AM -0700, Shameer Kolothum Thodi wrote:
> > > > From: Nicolin Chen <nicolinc@nvidia.com>
> > > > Could this be a case:
> > > >  - Write the PROD_INDX/ CONS_INDX with a consistent value (0xf)
> > > >  - Program the VIRT_CMDQ_BASE
> > > >  - Read the PROD_INDX/CONS_INDX, expecting 0xf
> > > >  - Write the PROD_INDX/ CONS_INDX with 0x0
> > > >  - Program the VIRT_CMDQ_CONFIG to enable the CMDQ
> > >
> > > Yes, if Guest is not spec compliant then this can be any order.
> > >
> > > However,
> > >
> > > >  - Program the VIRT_CMDQ_BASE -- suppose we call setup_vcmdq()
> > 
> > > then kernel will reset PROD/CONS, right?
> > 
> > But I don't have an impression that QEMU only supports Guest to run
> > Linux...
> 
> Oh no, I was referring to host kernel behaviour on IOMMU_HW_QUEUE_ALLOC
> IOCTL. It seems to reset PROD/CONS to zero in that path and I thought
> it was following spec in that case.

Ah, it was fixing a kernel bug, where the VCMDQ registers never got
cleared even after a host reset (IIRC). And the solution is to clear
them before handing over to the guest.

Once QEMU allocates the hw_queue that ALLOC_MAPs it to the VINTF, it
should probably sync what the register caches were programmed by the
guest.

> This scenario writes PROD_INDX before BASE, which is explicitly
> non-spec-compliant — TRM p.175 "Enabling the Virtual CMDQ"
> mandates BASE as the first step, with PROD_INDX/CONS_INDX
> initialization following. For a spec-compliant guest, PROD_INDX
> is only written after BASE, at which point vintf_ptr() is
> valid and writes go directly to hardware with no discard
> involved.

I think the goal of VMM is that a guest VM cannot distinguish
between real HW and emulated HW. If we just follow the minimal
"spec compliant" flow, it fails to do so. So, "spec compliant"
itself doesn't make a lot of sense to me.

With that being said, if QEMU is okay with the minimal support
for "spec compliant" flow only, I certainly won't be against
submitting it (for the initial version maybe?).

> 2) But then after some prompt it says:
> 
> Looking at SMMUv3's register write handlers, QEMU doesn't enforce
> any programming order there either —   registers are written to cache
> unconditionally. CMDQV should follow the same convention. Will fix by
> replaying cached PROD_INDX/CONS_INDX values to hardware after
> alloc_hw_queue succeeds, making the pre-to-post-alloc transition
> transparent to the guest.

Yes. We are indeed missing a few details in the implementation.

> 3) But it changes position again if you ask in a different way:
> 
> SMMUv3 has no equivalent transition point where hardware takes over.
> In CMDQV, the BASE write is a fundamental transition — before it,
> there is no hardware queue; after it, hardware owns the registers.
> The BASE write is a fundamental transition point — before it, no
> hardware queue exists; after it, hardware owns the Page0 registers.
> Pre-alloc writes to PROD_INDX/CONS_INDX are undefined behavior by
> spec, and "discard" at transition is the   correct consequence.
> There's nothing to "preserve across" in the SMMUv3 case.

Ask it to do a deeper research before answer any question, or
to pinpoint where spec declares that "undefined behaviour" for
example.

> I think the spec is vague and doesn’t demand a strict order.
> So may be better to sync the registers after the alloc.

Agreed.

Nicolin


  reply	other threads:[~2026-05-06 20:56 UTC|newest]

Thread overview: 102+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-15 10:55 [PATCH v4 00/31] hw/arm/virt: Introduce Tegra241 CMDQV support for accelerated SMMUv3 Shameer Kolothum
2026-04-15 10:55 ` [PATCH v4 01/31] backends/iommufd: Update iommufd_backend_get_device_info Shameer Kolothum
2026-04-15 10:55 ` [PATCH v4 02/31] backends/iommufd: Update iommufd_backend_alloc_viommu to allow user ptr Shameer Kolothum
2026-04-15 10:55 ` [PATCH v4 03/31] backends/iommufd: Introduce iommufd_backend_alloc_hw_queue Shameer Kolothum
2026-04-15 10:55 ` [PATCH v4 04/31] backends/iommufd: Introduce iommufd_backend_viommu_mmap Shameer Kolothum
2026-04-15 10:55 ` [PATCH v4 05/31] system/iommufd: Remove unused viommu pointer from IOMMUFDVeventq Shameer Kolothum
2026-05-04 15:00   ` Eric Auger
2026-05-04 18:16   ` Nicolin Chen
2026-04-15 10:55 ` [PATCH v4 06/31] hw/arm/smmuv3-accel: Introduce CMDQV ops interface Shameer Kolothum
2026-05-04 15:19   ` Eric Auger
2026-05-04 18:28   ` Nicolin Chen
2026-04-15 10:55 ` [PATCH v4 07/31] hw/arm/tegra241-cmdqv: Add Tegra241 CMDQV ops backend stub Shameer Kolothum
2026-05-04 15:19   ` Eric Auger
2026-05-04 18:23   ` Nicolin Chen
2026-04-15 10:55 ` [PATCH v4 08/31] hw/arm/smmuv3-accel: Wire CMDQV ops into accel lifecycle Shameer Kolothum
2026-05-04 15:33   ` Eric Auger
2026-05-05  7:47     ` Shameer Kolothum Thodi
2026-05-04 18:38   ` Nicolin Chen
2026-04-15 10:55 ` [PATCH v4 09/31] hw/arm/virt: Use stored SMMUv3 device list for IORT build Shameer Kolothum
2026-05-04 18:46   ` Nicolin Chen
2026-04-15 10:55 ` [PATCH v4 10/31] hw/arm/tegra241-cmdqv: Probe host Tegra241 CMDQV support Shameer Kolothum
2026-05-04 18:49   ` Nicolin Chen
2026-04-15 10:55 ` [PATCH v4 11/31] hw/arm/tegra241-cmdqv: Implement CMDQV init Shameer Kolothum
2026-04-15 10:55 ` [PATCH v4 12/31] hw/arm/virt: Link SMMUv3 CMDQV resources to platform bus Shameer Kolothum
2026-05-04 18:57   ` Nicolin Chen
2026-04-15 10:55 ` [PATCH v4 13/31] hw/arm/tegra241-cmdqv: Implement CMDQV vIOMMU alloc/free Shameer Kolothum
2026-05-04 16:01   ` Eric Auger
2026-05-04 19:54   ` Nicolin Chen
2026-04-15 10:55 ` [PATCH v4 14/31] hw/arm/tegra241-cmdqv: Emulate CMDQ-V Config region Shameer Kolothum
2026-05-05  0:09   ` Nicolin Chen
2026-05-05  7:26   ` Eric Auger
2026-05-05 10:28     ` Shameer Kolothum Thodi
2026-04-15 10:55 ` [PATCH v4 15/31] hw/arm/tegra241-cmdqv: Emulate VCMDQ register reads Shameer Kolothum
2026-05-05 10:12   ` Eric Auger
2026-05-05 13:27     ` Shameer Kolothum Thodi
2026-05-06 11:14       ` Eric Auger
2026-04-15 10:55 ` [PATCH v4 16/31] hw/arm/tegra241-cmdqv: Emulate VCMDQ register writes Shameer Kolothum
2026-05-05 10:42   ` Eric Auger
2026-05-05 13:49     ` Shameer Kolothum Thodi
2026-04-15 10:55 ` [PATCH v4 17/31] hw/arm/tegra241-cmdqv: mmap VINTF Page0 for CMDQV Shameer Kolothum
2026-04-15 10:55 ` [PATCH v4 18/31] system/physmem: Add address_space_is_ram() helper Shameer Kolothum
2026-05-05  0:24   ` Nicolin Chen
2026-04-15 10:55 ` [PATCH v4 19/31] hw/arm/tegra241-cmdqv: Allocate HW VCMDQs on base register programming Shameer Kolothum
2026-05-05  0:40   ` Nicolin Chen
2026-05-05  9:59     ` Shameer Kolothum Thodi
2026-05-05 19:38       ` Nicolin Chen
2026-05-06  8:18         ` Shameer Kolothum Thodi
2026-05-06 18:18           ` Nicolin Chen
2026-05-05 13:25   ` Eric Auger
2026-05-05 14:26     ` Shameer Kolothum Thodi
2026-05-06 17:49       ` Nicolin Chen
2026-05-08 14:50       ` Eric Auger
2026-05-06 16:51   ` Eric Auger
2026-05-06 18:21     ` Nicolin Chen via
2026-05-06 18:21       ` Nicolin Chen via qemu development
2026-04-15 10:55 ` [PATCH v4 20/31] hw/arm/tegra241-cmdqv: Use mmap'd VINTF page0 as VCMDQ backing Shameer Kolothum
2026-05-05  0:50   ` Nicolin Chen
2026-05-05 15:13     ` Shameer Kolothum Thodi
2026-05-05 19:52       ` Nicolin Chen
2026-05-06 13:16         ` Shameer Kolothum Thodi
2026-05-06 18:34           ` Nicolin Chen
2026-05-06 20:13             ` Shameer Kolothum Thodi
2026-05-06 20:55               ` Nicolin Chen [this message]
2026-05-06 12:27   ` Eric Auger
2026-04-15 10:55 ` [PATCH v4 21/31] memory: Allow RAM device regions to skip IOMMU mapping Shameer Kolothum
2026-05-06 12:39   ` Eric Auger
2026-04-15 10:55 ` [PATCH v4 22/31] hw/arm/tegra241-cmdqv: Map VINTF page0 into guest MMIO space Shameer Kolothum
2026-05-06 12:44   ` Eric Auger
2026-05-06 14:24     ` Shameer Kolothum Thodi
2026-05-07 16:24       ` Eric Auger
2026-05-08  9:03         ` Shameer Kolothum Thodi
2026-05-08 14:35           ` Eric Auger
2026-05-08 14:37             ` Shameer Kolothum Thodi
2026-04-15 10:55 ` [PATCH v4 23/31] hw/arm/smmuv3-accel: Introduce common helper for veventq read Shameer Kolothum
2026-05-05  1:07   ` Nicolin Chen
2026-05-06 12:49   ` Eric Auger
2026-04-15 10:55 ` [PATCH v4 24/31] hw/arm/tegra241-cmdqv: Read and propagate Tegra241 CMDQV errors Shameer Kolothum
2026-05-05  1:13   ` Nicolin Chen
2026-05-07 16:40   ` Eric Auger
2026-05-08 10:52     ` Shameer Kolothum Thodi
2026-04-15 10:55 ` [PATCH v4 25/31] hw/arm/tegra241-cmdqv: Add reset handler Shameer Kolothum
2026-05-07 16:51   ` Eric Auger
2026-05-08 11:19     ` Shameer Kolothum Thodi
2026-05-08 14:39       ` Eric Auger
2026-05-07 17:03   ` Eric Auger
2026-04-15 10:55 ` [PATCH v4 26/31] hw/arm/tegra241-cmdqv: Limit queue size based on backend page size Shameer Kolothum
2026-05-05  1:26   ` Nicolin Chen
2026-05-07 17:23   ` Eric Auger
2026-05-08 13:38     ` Shameer Kolothum Thodi
2026-05-08 14:41       ` Eric Auger
2026-04-15 10:55 ` [PATCH v4 27/31] hw/arm/smmuv3: Add per-device identifier property Shameer Kolothum
2026-05-05  1:30   ` Nicolin Chen
2026-04-15 10:55 ` [PATCH v4 28/31] hw/arm/smmuv3-accel: Introduce helper to query CMDQV type Shameer Kolothum
2026-05-05  1:32   ` Nicolin Chen
2026-04-15 10:55 ` [PATCH v4 29/31] hw/arm/virt-acpi: Advertise Tegra241 CMDQV nodes in DSDT Shameer Kolothum
2026-05-07 17:32   ` Eric Auger
2026-04-15 10:55 ` [PATCH v4 30/31] hw/arm/smmuv3-accel: Enforce viommu association when CMDQV is active Shameer Kolothum
2026-05-05  1:35   ` Nicolin Chen
2026-05-07 17:36   ` Eric Auger
2026-05-08 14:36     ` Shameer Kolothum Thodi
2026-04-15 10:55 ` [PATCH v4 31/31] hw/arm/smmuv3: Add cmdqv property for SMMUv3 device Shameer Kolothum
2026-05-07 17:28   ` Eric Auger

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=afuqvoODHtr2KoSk@nvidia.com \
    --to=nicolinc@nvidia.com \
    --cc=alex@shazbot.org \
    --cc=clg@redhat.com \
    --cc=eric.auger@redhat.com \
    --cc=jan@nvidia.com \
    --cc=jgg@nvidia.com \
    --cc=kjaju@nvidia.com \
    --cc=mochs@nvidia.com \
    --cc=nathanc@nvidia.com \
    --cc=peter.maydell@linaro.org \
    --cc=phrdina@redhat.com \
    --cc=qemu-arm@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=skolothumtho@nvidia.com \
    --cc=zhenzhong.duan@intel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.