qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Drew Fustini <fustini@kernel.org>
To: Daniel Henrique Barboza <dbarboza@ventanamicro.com>
Cc: qemu-devel@nongnu.org, "Palmer Dabbelt" <palmer@dabbelt.com>,
	"Alistair Francis" <Alistair.Francis@wdc.com>,
	"Weiwei Li" <liwei1518@gmail.com>,
	"Liu Zhiwei" <zhiwei_liu@linux.alibaba.com>,
	qemu-riscv@nongnu.org, "Paolo Bonzini" <pbonzini@redhat.com>,
	"Nicolas Pitre" <npitre@baylibre.com>,
	"Kornel Dulęba" <mindal@semihalf.com>,
	"Atish Kumar Patra" <atishp@rivosinc.com>,
	"Atish Patra" <atish.patra@linux.dev>,
	"Vasudevan Srinivasan" <vasu@rivosinc.com>,
	"Radim Krčmář" <rkrcmar@ventanamicro.com>,
	"yunhui cui" <cuiyunhui@bytedance.com>,
	"Chen Pei" <cp0613@linux.alibaba.com>,
	guo.wenjia23@zte.com.cn, liu.qingtao2@zte.com.cn
Subject: Re: [PATCH 3/7] hw/riscv: implement CBQRI capacity controller
Date: Fri, 21 Nov 2025 10:57:26 -0800	[thread overview]
Message-ID: <aSC2FhUFlrKSSuwI@x1> (raw)
In-Reply-To: <ea794b78-2b7e-44eb-96e2-342f6a338090@ventanamicro.com>

On Thu, Nov 20, 2025 at 08:47:44AM -0300, Daniel Henrique Barboza wrote:
> [ ...]
> 
> > +
> > +static void riscv_cbqri_cc_write(void *opaque, hwaddr addr,
> > +                                 uint64_t value, unsigned size)
> > +{
> > +    RiscvCbqriCapacityState *cc = opaque;
> > +
> > +    assert((addr % 8) == 0);
> > +    assert(size == 8);
> 
> So here and in the read callback (riscv_cbqri_cc_read) you're doing asserts for
> size == 8, while your memoryops has:
> 
> static const MemoryRegionOps riscv_cbqri_cc_ops = {
>     .read = riscv_cbqri_cc_read,
>     .write = riscv_cbqri_cc_write,
>     .endianness = DEVICE_LITTLE_ENDIAN,
>     .valid.min_access_size = 4,  <==========
>     .valid.max_access_size = 8,
>     .impl.min_access_size = 8,
>     .impl.max_access_size = 8,
> };
> 
> 
> You can get rid of assert(size == 8) in both callbacks by setting
> min_access_size = 8.

Thanks for the review. 

I think that the assert in riscv_cbqri_cc_write maybe incorrect.

The CBQRI spec states that the registers:
 - start at an 8-byte aligned physical address. 
 - can accessed by using naturally aligned 4-byte or 8-byte accesses
 - 4-byte access to a register must be single-copy atomic
 - It is UNSPECIFIED whether 8-byte access must be single-copy atomic
 - 8-byte access can appear internally to the CBQRI implementation as
   if two separate 4-byte accesses are performed.

The spec further notes that:

"The CBQRI registers are defined so that software can perform two
individual 4 byte accesses, or hardware can perform two independent 4
byte transactions resulting from an 8 byte access, to the high and low
halves of the register as long as the register semantics, with regards
to side-effects, are respected between the two software accesses, or two
hardware transactions, respectively."

Based on the above, I believe .valid.min_access_size does need to stay
at 4 bytes. The Qemu documentation states that otherwise "accesses
outside this range will have device and bus specific behaviour (ignored,
or machine check)".

I am confused whether ".impl.min_access_size = 8" is correct. The Qemu
documentation states that "other access sizes will be emulated using the
ones available. For example a 4-byte write will be emulated using four
1-byte writes, if .impl.max_access_size = 1."

Radim asked if 32-bit (4 byte) access would be supported, but I am
confused how other access sizes are emulated.

Do I need to add code to the read and write hooks for riscv_cbqri_cc_ops
and riscv_cbqri_bc_ops?

Or is there some aspect of MemoryRegionOps that can handle the emulation
of other sizes automatically?

Thanks,
Drew


  reply	other threads:[~2025-11-22  3:25 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-20  0:42 [PATCH 0/7] riscv: implement Ssqosid extension and CBQRI controllers Drew Fustini
2025-11-20  0:42 ` [PATCH 1/7] riscv: implement Ssqosid extension and srmcfg CSR Drew Fustini
2025-11-20 11:30   ` Daniel Henrique Barboza
2025-11-20 21:34     ` Drew Fustini
2025-11-20 16:07   ` Radim Krčmář
2025-11-20 20:46     ` Drew Fustini
2025-11-20  0:42 ` [PATCH 2/7] hw/riscv: define capabilities of CBQRI controllers Drew Fustini
2025-11-20 11:59   ` Daniel Henrique Barboza
2025-11-20  0:42 ` [PATCH 3/7] hw/riscv: implement CBQRI capacity controller Drew Fustini
2025-11-20 11:47   ` Daniel Henrique Barboza
2025-11-21 18:57     ` Drew Fustini [this message]
2025-11-20 19:25   ` Radim Krčmář
2025-11-21 19:50     ` Drew Fustini
2025-11-20  0:42 ` [PATCH 4/7] hw/riscv: implement CBQRI bandwidth controller Drew Fustini
2025-11-20 11:51   ` Daniel Henrique Barboza
2025-11-20  0:42 ` [PATCH 5/7] hw/riscv: Kconfig: add CBQRI options Drew Fustini
2025-11-20  0:42 ` [PATCH 6/7] hw/riscv: meson: add CBQRI controllers to the build Drew Fustini
2025-11-20 12:01   ` Daniel Henrique Barboza
2025-11-20 20:56     ` Drew Fustini
2025-11-20  0:42 ` [PATCH 7/7] hw/riscv: add CBQRI controllers to virt machine Drew Fustini
2025-11-20 12:01   ` Daniel Henrique Barboza

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=aSC2FhUFlrKSSuwI@x1 \
    --to=fustini@kernel.org \
    --cc=Alistair.Francis@wdc.com \
    --cc=atish.patra@linux.dev \
    --cc=atishp@rivosinc.com \
    --cc=cp0613@linux.alibaba.com \
    --cc=cuiyunhui@bytedance.com \
    --cc=dbarboza@ventanamicro.com \
    --cc=guo.wenjia23@zte.com.cn \
    --cc=liu.qingtao2@zte.com.cn \
    --cc=liwei1518@gmail.com \
    --cc=mindal@semihalf.com \
    --cc=npitre@baylibre.com \
    --cc=palmer@dabbelt.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-riscv@nongnu.org \
    --cc=rkrcmar@ventanamicro.com \
    --cc=vasu@rivosinc.com \
    --cc=zhiwei_liu@linux.alibaba.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).