From: Drew Fustini <fustini@kernel.org>
To: "Radim Krčmář" <radim.krcmar@oss.qualcomm.com>
Cc: qemu-devel@nongnu.org, qemu-riscv@nongnu.org,
"Palmer Dabbelt" <palmer@dabbelt.com>,
"Alistair Francis" <Alistair.Francis@wdc.com>,
"Weiwei Li" <liwei1518@gmail.com>,
"Daniel Henrique Barboza" <dbarboza@ventanamicro.com>,
"Liu Zhiwei" <zhiwei_liu@linux.alibaba.com>,
"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 v4 3/6] hw/riscv: implement CBQRI capacity controller
Date: Sat, 24 Jan 2026 09:55:34 -0800 [thread overview]
Message-ID: <aXUHls5y7WCo80e9@x1> (raw)
In-Reply-To: <DFQ6PDOR5QOS.6B2ASHZOJ0U7@oss.qualcomm.com>
On Fri, Jan 16, 2026 at 05:20:00PM +0000, Radim Krčmář wrote:
> Sorry, I changed emails, and this series flew under my radar, since
> qemu-riscv lore public inbox has been silent for a month and I was
> happily oblivious that it's a bug on their side.
>
> I'm addressing only the access size issue in this mail and I'll look at
> the rest next week.
>
> 2026-01-05T13:54:21-08:00, Drew Fustini <fustini@kernel.org>:
> > From: Nicolas Pitre <npitre@baylibre.com>
> >
> > Implement a capacity controller according to the Capacity and Bandwidth
> > QoS Register Interface (CBQRI) which supports these capabilities:
> >
> > - Number of access types: 2 (code and data)
> > - Usage monitoring operations: CONFIG_EVENT, READ_COUNTER
> > - Event IDs supported: None, Occupancy
> > - Capacity allocation ops: CONFIG_LIMIT, READ_LIMIT, FLUSH_RCID
> >
> > Link: https://github.com/riscv-non-isa/riscv-cbqri/releases/tag/v1.0
> > Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
> > [fustini: add fields introduced in the ratified spec: cunits, rpfx, p]
> > Signed-off-by: Drew Fustini <fustini@kernel.org>
> > ---
> > diff --git a/hw/riscv/cbqri_capacity.c b/hw/riscv/cbqri_capacity.c
> > +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,
>
> The .impl.min_access_size should be 4, since access_with_adjusted_size
> doesn't seem to do what we want.
Ok, thanks.
> > + .impl.max_access_size = 8,
>
> I think we can reuse the current 8 byte iplementation by adding
> something like the following hack for 4 byte accesses:
>
> static uint64_t riscv_cbqri_cc_read_wrapper(void *opaque, hwaddr addr,
> unsigned size)
> {
> uint64_t value = riscv_cbqri_br_read(opaque, addr & ~0x7UL, 8);
> if (size == 4) {
> if (addr & 0x7) {
> return value >> 32;
> } else {
> return value & 0xffffffff;
> }
> }
> return value;
> }
>
> read has no side-effects, so the wrapper should be conceptually correct.
Thank you very much for the suggestion. I'll try it out and get a new
revision ready.
>
>
> static uint64_t riscv_cbqri_cc_write_wrapper(void *opaque, hwaddr addr,
> uint64_t value, unsigned size)
> {
> if (size == 4) {
> uint64_t reg = riscv_cbqri_br_read(opaque, addr & ~0x7UL, 8);
> if (addr & 0x7) {
> value = value << 32 | reg & 0xffffffff;
> } else {
> value = value | reg & ~0xffffffffUL;
> }
> }
>
> riscv_cbqri_cc_write(opaque, addr & ~0x7UL, value, 8);
> }
>
> The control registers will execute an operation on a write to the upper
> half as well, which doesn't seem desirable, but it's unspecified afaik.
> The upper half of control registers has no fields that software would
> ever want to write, so I think it's not really a practical issue,
> especially since we're basically a skeleton implementation.
Thanks for the suggestion, I think that is an acceptable solution. The
main point of the Qemu implementation is to exercise the Linux kernel
code ahead of silicon that implements CBQRI.
> Another solution would be to implement just 4 byte registers, and handle
> 8 byte writes as a combination of two 4 byte -- the spec hints that this
> is an expected implementation, but with all registers being defined as 8
> byte, I think my hack would need "clarifications" to make it incorrect.
Thanks for also suggesting this. I agree that the previous suggestion is
sufficent.
-Drew
next prev parent reply other threads:[~2026-01-24 17:56 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-05 21:54 [PATCH v4 0/6] riscv: implement Ssqosid extension and CBQRI controllers Drew Fustini
2026-01-05 21:54 ` [PATCH v4 1/6] riscv: implement Ssqosid extension and srmcfg CSR Drew Fustini
2026-01-05 21:54 ` [PATCH v4 2/6] hw/riscv: define capabilities of CBQRI controllers Drew Fustini
2026-01-05 21:54 ` [PATCH v4 3/6] hw/riscv: implement CBQRI capacity controller Drew Fustini
2026-01-16 17:20 ` Radim Krčmář
2026-01-24 17:55 ` Drew Fustini [this message]
2026-01-05 21:54 ` [PATCH v4 4/6] hw/riscv: implement CBQRI bandwidth controller Drew Fustini
2026-01-05 21:54 ` [PATCH v4 5/6] hw/riscv: add CBQRI to Kconfig and build if enabled Drew Fustini
2026-01-05 21:54 ` [PATCH v4 6/6] hw/riscv: add CBQRI controllers to virt machine Drew Fustini
2026-01-07 7:38 ` [External] [PATCH v4 0/6] riscv: implement Ssqosid extension and CBQRI controllers yunhui cui
2026-01-08 7:33 ` Drew Fustini
2026-01-08 8:46 ` [External] " yunhui cui
2026-01-09 4:56 ` Drew Fustini
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=aXUHls5y7WCo80e9@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=radim.krcmar@oss.qualcomm.com \
--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 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.