> -----Original Message-----
> From: Nicolin Chen <[email protected]>
> Sent: 01 June 2026 23:06
> To: Shameer Kolothum Thodi <[email protected]>
> Cc: [email protected]; [email protected];
> [email protected]; [email protected]; [email protected];
> [email protected]; Nathan Chen <[email protected]>; Matt Ochs
> <[email protected]>; Jiandi An <[email protected]>; Jason Gunthorpe
> <[email protected]>; [email protected]; Krishnakant Jaju
> <[email protected]>; [email protected]
> Subject: Re: [PATCH v6 19/31] hw/arm/tegra241-cmdqv: Use mmap'd VINTF
> page0 as VCMDQ backing
>
> On Mon, Jun 01, 2026 at 12:42:09PM +0100, Shameer Kolothum wrote:
> > +/*
> > + * Return a pointer into the mmap'd VINTF page0 for the VCMDQ Page 0
> > + * register at @offset0 in VCMDQ slot @index, or NULL when the VCMDQ
> > + * has no hw_queue allocated or the VINTF page0 is not mmap'd.
> > + */
> > +static inline uint32_t *tegra241_cmdqv_vintf_ptr(Tegra241CMDQV
> *cmdqv,
> > + int index, hwaddr
> > +offset0)
>
> I'd do:
> tegra241_cmdqv_vintf_lvcmdq_ptr()
> or just:
> tegra241_vintf_lvcmdq_ptr()
Ok. I will go with tegra241_cmdqv_vintf_lvcmdq_ptr()
> > static void tegra241_cmdqv_write_vcmdq_page0(Tegra241CMDQV
> *cmdqv,
> > hwaddr offset0, int index,
> > uint32_t value, bool
> > direct) {
> > + uint32_t *ptr = tegra241_cmdqv_vintf_ptr(cmdqv, index, offset0);
> > +
> > + if (ptr) {
> > + switch (offset0) {
> > + case A_VCMDQ0_CONS_INDX:
> > + case A_VCMDQ0_PROD_INDX:
> > + case A_VCMDQ0_CONFIG:
> > + case A_VCMDQ0_GERRORN:
> > + *ptr = value;
> > + goto out;
> > + default:
> > + break;
> > + }
> > + }
>
> Could stuff this into the helper? Return a valid ptr only when the
> offset0 is one of these four registers; otherwise, return NULL.
>
> Then, here if would be:
> if (ptr) {
> *ptr = value;
> goto out;
> }
The helper is shared with _read_vcmdq_page0(), where STATUS/
GERROR reads also need to route to the mmap when allocated. Folding
the above would require a separate handling for "write" inside the
helper. Could do. But I think this is more readable...
Thanks,
Shameer