All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jim MacArthur <jim.macarthur@linaro.org>
To: Gustavo Romero <gromero@redhat.com>
Cc: qemu-devel@nongnu.org, Eric Auger <eric.auger@redhat.com>,
	Peter Maydell <peter.maydell@linaro.org>,
	qemu-arm@nongnu.org,
	Leif Lindholm <leif.lindholm@oss.qualcomm.com>,
	Pierrick Bouvier <pierrick.bouvier@oss.qualcomm.com>
Subject: Re: [PATCH 1/2] hw/arm/smmuv3: define Root registers
Date: Tue, 10 Nov 2026 16:21:03 +0000	[thread overview]
Message-ID: <avNEb_ScXZ-A6uDF@linaro.org> (raw)
In-Reply-To: <isr4ew27ud6xmfrk444mdme2rqdtd5wgpbgjblgaavmzhpyppt@hhmxurpxh766>

On Fri, Nov 06, 2026 at 11:20:56PM +0100, Gustavo Romero wrote:
> > +/*
> > + * Check we are from the Root PA space to read from or write to the
> > + * SMMU Root register area.
> > + */
> > +static bool smmu_check_root_access(SMMUv3State *s, MemTxAttrs attrs,
> > +                                     hwaddr offset, bool is_read)
> 
> Indentation is off ---------------------^
> 
> I think it makes sense also to call this function smmu_root_access(), but no
> strong preference here.

Noted indentation fault. I would prefer to have a verb in the function name,
but similarly have no strong preferences on it.

> 
> 
> > +{
> > +    /* Check if the access is from Root PA */
> > +    if (!(attrs.space == ARMSS_Root)) {
> 
> Could we use the comparison operator (!=) instead of the logical one here? I
> think it's clearer than a negation.
> 
Good point, that is clearer.

> > +    case A_ROOT_GPT_BASE2:
> > +        *data = s->root.gpt_base2;
> > +        return MEMTX_OK;
> > +    case A_ROOT_GPCBW:
> > +        /* Optional, not implemented. Present if ROOT_IDR0.GPTS == 0 */
> 
>                                          GPTS == 1 here? -----^
Correct, thank you.

> > @@ -411,6 +411,28 @@ REG32(EVENTQ_IRQ_CFG2,     0xbc)
> >  
> >  #define A_IDREGS           0xfd0
> >  
> > +#define SMMU_ROOT_REG_START 0x20000
> 
> The base address for the Root Control Page is implementation defined, hence
> 0x20000 is not always true and depends on the machine/platform. We could add
> property to set it externaly but it would also complicate unnecessarily the
> offset math. So I think it's ok to follow what FVP is doing. Please just add a
> note saying it's impl. defined so it might require a tweak in the
> future.
> 
> I think we can follow TF-A code here and rename this macro. So how about
> renaming it to:
> 
> SMMUV3_ROOT_REG_OFFSET ?
> 
I'll add another comment and yes, that name change makes sense.

...

> > +typedef struct SMMUv3RootRegBank {
> 
> How about naming this struct simply SMMUv3Root?

I don't mind renaming it to something other than 'Bank' to avoid conflicts
with another meaning of register bank (e.g. the actually banked registers),
for example SMMUv3RootControlPage would be fine. If it's just to save space
on punch cards, I'm less keen, but will happily follow code conventions.

> 
> 
> > +    uint32_t idr0;
> > +    uint32_t iidr;
> > +    uint32_t cr0;
> > +    uint32_t cr0ack;
> > +    uint64_t gpt_base;
> > +    uint64_t gpt_base_cfg;
> > +    uint64_t gpf_far;
> > +    uint64_t gpt_cfg_far;
> > +    uint64_t gpt_base2;
> 
> Looking at ARM IHI 0070 H.a Non-confidential spec I don't see
> 
> 0x0068 SMMU_ROOT_GPT_BASE_UPDATE 32-bit, R/W and
> 0x0070 SMMU_ROOT_GPCBW 64-bit, R/W
> 
> as Optional like I see SMMU_ROOT_TLBI and SMMU_ROOT_TLBI_CTRL.
> 
> Should they be declared as well?

GPT_BASE_UPDATE is an unusual case; it has side effects when writing hence
I was reluctant to include it as a normal config register, however, it
shouldn't do any harm to add it - users will just see the 'update' bit stick
as 1 forever if they write it.

SMMU_ROOT_GPCBW is RES0 unless ROOT_IDR0.GPTS == 1 as noted above, and we
don't define that bit at the moment, so making storage for it seemed
unnecessary.

> 
> 
> > +} SMMUv3RootRegBank;
> > +
> >  struct SMMUv3State {
> >      SMMUState     smmu_state;
> >  
> > @@ -80,6 +92,7 @@ struct SMMUv3State {
> >      OnOffAuto cmdqv;
> >  
> >      Notifier machine_done;
> > +    SMMUv3RootRegBank root;
> >  };
> >  
> >  typedef enum {
> > 
> > -- 
> > 2.43.0
> > 
> > 
> 
> General comments:
> 
> smmu_read_mmio_root
> smmu_write_mmio_root 
> 
> I think we can drop the "mmio_" for both functions. It's ok to have "mmio_" in
> the "trace_smmuv3_write_mmio" trace function because afaics it has a generic use,
> so its use is not tied to any bank.
Yep, fine by me.

> 
> 
> I think we're missing to reset some registers in smmuv3_reset()? Like:
> 
> s->root.cr0 = 0;
> s->root.cr0ack = 0;
> s->root.gpf_far = 0;
> s->root.gpt_cfg_far = 0;

Good point, we are missing those, thanks.

Thanks for the review!

Jim


  reply	other threads:[~2026-11-10 16:22 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-16  9:40 [PATCH 0/2] Add SMMUv3 Root registers Jim MacArthur
2026-10-16  9:40 ` [PATCH 1/2] hw/arm/smmuv3: define " Jim MacArthur
2026-11-06 22:20   ` Gustavo Romero
2026-11-10 16:21     ` Jim MacArthur [this message]
2026-10-16  9:40 ` [PATCH 2/2] hw/arm/sbsa-ref.c: Increase SMMU space for " Jim MacArthur
2026-10-16 11:02   ` Leif Lindholm
2026-11-06 22:21   ` Gustavo Romero
2026-11-11 16:31     ` Jim MacArthur
2026-11-11 18:10       ` Pierrick Bouvier
2026-11-12 18:59         ` Gustavo Romero

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=avNEb_ScXZ-A6uDF@linaro.org \
    --to=jim.macarthur@linaro.org \
    --cc=eric.auger@redhat.com \
    --cc=gromero@redhat.com \
    --cc=leif.lindholm@oss.qualcomm.com \
    --cc=peter.maydell@linaro.org \
    --cc=pierrick.bouvier@oss.qualcomm.com \
    --cc=qemu-arm@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    /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.