From: Jonathan Cameron <jic23@kernel.org>
To: Jinjie Ruan <2118537295@qq.com>
Cc: anisinha@redhat.com, armbru@redhat.com, eblake@redhat.com,
imammedo@redhat.com, michael.roth@amd.com, mst@redhat.com,
pbonzini@redhat.com, peter.maydell@linaro.org,
qemu-devel@nongnu.org, qemu-arm@nongnu.org,
ruanjinjie@huawei.com
Subject: Re: [PATCH 31/37] hw/arm/mpam: Add device reset and power-on state initialisation
Date: Tue, 3 Nov 2026 03:22:53 +0000 [thread overview]
Message-ID: <20261103032253.01faabaf@jic23-hlaptop> (raw)
In-Reply-To: <tencent_A847C7182BCA69DC138B882EB70852E13308@qq.com>
On Fri, 16 Oct 2026 18:10:51 +0800
Jinjie Ruan <2118537295@qq.com> wrote:
> From: Jinjie Ruan <ruanjinjie@huawei.com>
>
> Move the power-on initialisation out of realize into
> mpam_msc_state_init() (shared with the new legacy reset callback):
> selection state and ECR/ESR cleared, per-RIS partition and monitor
> storage zeroed, the PARTID narrowing map identity-wrapped so the
> indirection is always in range before the driver programs it, and
> MBW_MAX reset to 0xffff (full bandwidth) -- an unprogrammed PARTID
> must not read as zero bandwidth.
>
> Also fix the realize error message for num-partid == 0, which
> repeated the num-ris text.
>
> Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
I'd push the refactor back to the original introduction. Reduces churn
and then is trivial to use here in the reset.
> ---
> hw/arm/mpam.c | 78 +++++++++++++++++++++++++++++++++++++++------------
> 1 file changed, 60 insertions(+), 18 deletions(-)
>
> diff --git a/hw/arm/mpam.c b/hw/arm/mpam.c
> index fe78adb..c4a7567 100644
> --- a/hw/arm/mpam.c
> +++ b/hw/arm/mpam.c
> @@ -1041,6 +1041,63 @@ static const MemoryRegionOps mpam_msc_ops = {
> },
> };
>
> +
> +/*
> + * Power-on state of the MSC, shared between realize and reset: ID narrowing
> + * map identity-wrapped, partition config at reset values, monitors off.
> + */
> +static void mpam_msc_state_init(MPAMMSCState *s)
> +{
> + int i;
> +
> + s->ris = 0;
> + s->part_sel = 0;
> + s->internal_part_sel = false;
> + s->mon_sel = 0;
> + s->ecr = 0;
> + s->esr = 0;
> +
> + for (i = 0; i < s->num_ris; i++) {
> + Mpamf *mpamf = &s->mpamf[i];
> + int p;
> +
> + mpamf->ecr = 0;
> + mpamf->esr = 0;
> + memset(mpamf->per_nrw_id, 0,
> + sizeof(MpamfPerNrwId) * s->num_int_partid);
> + memset(mpamf->cfg_intpartid, 0,
> + sizeof(uint32_t) * s->num_partid);
> + memset(mpamf->mbwu_mons, 0,
> + sizeof(MpamMbwuMon) * s->num_mbwu_mon);
> + memset(mpamf->csu_mons, 0, sizeof(MpamCsuMon) * s->num_csu_mon);
> +
> + /*
> + * Until resctrl programs the map, wrap each request PARTID onto an
> + * internal PARTID so the narrowing indirection is always in range.
> + */
> + for (p = 0; p < s->num_partid; p++) {
> + mpamf->cfg_intpartid[p] = p % s->num_int_partid;
> + }
> + /*
> + * per_nrw_id is indexed by INTERNAL PARTID: it has
> + * num_int_partid entries, not num_partid. Writing it with the
> + * request-PARTID count overflowed the allocation by 224 entries
> + * (malloc(): corrupted top size once the struct grew).
> + */
> + for (p = 0; p < s->num_int_partid; p++) {
> + /* MBW_MAX resets to full bandwidth on real hardware */
> + mpamf->per_nrw_id[p].cfg_mbw_max = 0xffff;
> + }
> + }
> +}
> +
> +static void mpam_msc_reset(DeviceState *dev)
> +{
> + MPAMMSCState *s = MPAM_MSC_DEVICE(dev);
> +
> + mpam_msc_state_init(s);
> +}
> +
> static void mpam_msc_realize(DeviceState *dev, Error **errp)
> {
> MPAMMSCState *s = MPAM_MSC_DEVICE(dev);
> @@ -1052,7 +1109,7 @@ static void mpam_msc_realize(DeviceState *dev, Error **errp)
> return;
> }
> if (s->num_partid == 0) {
> - error_setg(errp, "num-ris must be <= 16");
> + error_setg(errp, "num-partid must be nonzero");
> return;
> }
> if (s->num_int_partid == 0) {
> @@ -1061,28 +1118,12 @@ static void mpam_msc_realize(DeviceState *dev, Error **errp)
>
> s->mpamf = g_new0(Mpamf, s->num_ris);
> for (i = 0; i < s->num_ris; i++) {
> - int p;
> -
> s->mpamf[i].per_nrw_id = g_new0(MpamfPerNrwId, s->num_int_partid);
> s->mpamf[i].cfg_intpartid = g_new0(uint32_t, s->num_partid);
> s->mpamf[i].mbwu_mons = g_new0(MpamMbwuMon, s->num_mbwu_mon);
> s->mpamf[i].csu_mons = g_new0(MpamCsuMon, s->num_csu_mon);
> - /*
> - * Until resctrl programs the map, wrap each request PARTID onto an
> - * internal PARTID so the narrowing indirection is always in range.
> - */
> - for (p = 0; p < s->num_partid; p++) {
> - s->mpamf[i].cfg_intpartid[p] = p % s->num_int_partid;
> - }
> - /*
> - * per_nrw_id is indexed by INTERNAL PARTID: it has num_int_partid
> - * entries, not num_partid.
> - */
> - for (p = 0; p < s->num_int_partid; p++) {
> - /* MBW_MAX resets to full bandwidth on real hardware */
> - s->mpamf[i].per_nrw_id[p].cfg_mbw_max = 0xffff;
> - }
> }
> + mpam_msc_state_init(s);
>
> memory_region_init_io(&s->mr, OBJECT(s), &mpam_msc_ops, s, "mpam_msc",
> MPAM_SIZE);
> @@ -1301,6 +1342,7 @@ static void mpam_msc_init(ObjectClass *klass, const void *data)
> DeviceClass *dc = DEVICE_CLASS(klass);
>
> device_class_set_props(dc, mpam_msc_props);
> + device_class_set_legacy_reset(dc, mpam_msc_reset);
> }
>
> static void mpam_msc_mem_init(ObjectClass *klass, const void *data)
next prev parent reply other threads:[~2026-11-03 3:23 UTC|newest]
Thread overview: 43+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20261016101058.1900808-1-2118537295@qq.com>
2026-10-16 10:10 ` [PATCH 18/37] hw/arm/virt: Reserve the MPAM MSC MMIO window Jinjie Ruan
2026-11-03 1:54 ` Jonathan Cameron
2026-10-16 10:10 ` [PATCH 17/37] hw/arm/virt: Add mpam and mpam-min-msc machine properties Jinjie Ruan
2026-10-16 10:10 ` [PATCH 18/37] hw/arm/virt: Reserve the MPAM MSC MMIO window Jinjie Ruan
2026-10-16 10:10 ` [PATCH 19/37] hw/arm/mpam: Add node and interrupt GSIV properties Jinjie Ruan
2026-11-03 1:55 ` Jonathan Cameron
2026-10-16 10:10 ` [PATCH 20/37] hw/arm/virt: Create memory-side MPAM MSCs Jinjie Ruan
2026-11-03 2:00 ` Jonathan Cameron
2026-10-16 10:10 ` [PATCH 21/37] hw/arm/virt: Create L2/L3 cache " Jinjie Ruan
2026-11-03 2:04 ` Jonathan Cameron
2026-10-16 10:10 ` [PATCH 22/37] hw/acpi: Add MPAM table MSC node builders Jinjie Ruan
2026-11-03 2:36 ` Jonathan Cameron
2026-10-16 10:10 ` [PATCH 23/37] hw/acpi: Build the MPAM ACPI table Jinjie Ruan
2026-11-03 2:47 ` Jonathan Cameron
2026-10-16 10:10 ` [PATCH 24/37] hw/arm/mpam: Add MSMON monitor selection and window configuration Jinjie Ruan
2026-11-03 3:02 ` Jonathan Cameron
2026-10-16 10:10 ` [PATCH 25/37] hw/arm/mpam: Emulate MBWU bandwidth monitoring Jinjie Ruan
2026-11-03 3:10 ` Jonathan Cameron
2026-10-16 10:10 ` [PATCH 26/37] hw/arm/mpam: Implement CMIN/CASSOC storage Jinjie Ruan
2026-11-03 3:14 ` Jonathan Cameron
2026-10-16 10:10 ` [PATCH 27/37] hw/arm/mpam: Advertise PRI on memory-side MSCs Jinjie Ruan
2026-11-03 3:16 ` Jonathan Cameron
2026-10-16 10:10 ` [PATCH 28/37] hw/arm/mpam: Emulate CSU cache-usage monitoring Jinjie Ruan
2026-11-03 3:18 ` Jonathan Cameron
2026-10-16 10:10 ` [PATCH 29/37] hw/arm/virt: Size the cache MSC occupancy model by level Jinjie Ruan
2026-11-03 3:20 ` Jonathan Cameron
2026-10-16 10:10 ` [PATCH 30/37] hw/arm/mpam: Handle ECR/ESR as MSC-global registers Jinjie Ruan
2026-11-03 3:21 ` Jonathan Cameron
2026-10-16 10:10 ` [PATCH 31/37] hw/arm/mpam: Add device reset and power-on state initialisation Jinjie Ruan
2026-11-03 3:22 ` Jonathan Cameron [this message]
2026-10-16 10:10 ` [PATCH 32/37] hw/arm/mpam: Add error and overflow interrupt outputs Jinjie Ruan
2026-11-03 3:25 ` Jonathan Cameron
2026-10-16 10:10 ` [PATCH 33/37] hw/arm/mpam: Record errors and reject invalid configuration writes Jinjie Ruan
2026-11-03 3:27 ` Jonathan Cameron
2026-10-16 10:10 ` [PATCH 34/37] hw/arm/virt: Wire MSC error and overflow interrupts to the GIC Jinjie Ruan
2026-11-03 3:30 ` Jonathan Cameron
2026-10-16 10:10 ` [PATCH 35/37] hw/arm/virt: Default to implicit node 0 for MPAM without -numa Jinjie Ruan
2026-11-03 3:32 ` Jonathan Cameron
2026-10-16 10:10 ` [PATCH 36/37] qapi: Add MPAM cache introspection schema and stub Jinjie Ruan
2026-10-26 13:05 ` Markus Armbruster
2026-10-27 7:20 ` Jinjie Ruan
2026-10-16 10:10 ` [PATCH 37/37] hw/arm/mpam: Implement query-mpam-cache Jinjie Ruan
2026-11-06 22:39 ` Jonathan Cameron
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=20261103032253.01faabaf@jic23-hlaptop \
--to=jic23@kernel.org \
--cc=2118537295@qq.com \
--cc=anisinha@redhat.com \
--cc=armbru@redhat.com \
--cc=eblake@redhat.com \
--cc=imammedo@redhat.com \
--cc=michael.roth@amd.com \
--cc=mst@redhat.com \
--cc=pbonzini@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-arm@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=ruanjinjie@huawei.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.