From nobody Wed Dec 17 21:27:27 2025 Received: from szxga07-in.huawei.com (szxga07-in.huawei.com [45.249.212.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D163C12E1CD for ; Sat, 7 Dec 2024 09:09:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.35 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733562567; cv=none; b=e/wEpDFb6PZPQLU45XWVXFpKj1MNYGaXUj3YRMEVo/0wU0Pl6LWylj1UKQ50H3vlYG8ifyq/XAHJkWbhwt74hagF/8dPAIBIXZo4CF7ewCIfCOVBlhdIhw0jjfqzFv8F4yrHZUzWTxRiTwNj4Ra+ySWySK+t/R2mJGaMmKtWi10= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733562567; c=relaxed/simple; bh=Dw9s7sDSOGhEg5E9v/O0gOK1xEqgry46VjEW+CN8E58=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=TdeNR++CbkYcILnM+6dGfaXFtN4U0vvjZL3Pf/NvRNFEI/GS2cNdFFCINgM5j9kblSN6BelHaCM3U9b4qIvu1yUg/xrMAf59cMakjizbpqyQ82FbSrswWW+Dbm02b4ERKPWGLD5bV7XLbiQ7anqMIX0Zxyn4vDwyQJWCwQbh2wA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; arc=none smtp.client-ip=45.249.212.35 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Received: from mail.maildlp.com (unknown [172.19.163.17]) by szxga07-in.huawei.com (SkyGuard) with ESMTP id 4Y52Ls1vKqz1T6RH; Sat, 7 Dec 2024 17:07:01 +0800 (CST) Received: from kwepemf100008.china.huawei.com (unknown [7.202.181.222]) by mail.maildlp.com (Postfix) with ESMTPS id 6F37D1A0188; Sat, 7 Dec 2024 17:09:22 +0800 (CST) Received: from huawei.com (10.175.103.91) by kwepemf100008.china.huawei.com (7.202.181.222) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Sat, 7 Dec 2024 17:09:21 +0800 From: Zeng Heng To: , CC: , , , Subject: [RFC PATCH mpam mpam/snapshot/v6.12-rc1 v3 4/5] arm_mpam: Automatically synchronize the configuration of all sub-monitoring groups Date: Sat, 7 Dec 2024 17:21:35 +0800 Message-ID: <20241207092136.2488426-5-zengheng4@huawei.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20241207092136.2488426-1-zengheng4@huawei.com> References: <20241207092136.2488426-1-zengheng4@huawei.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To kwepemf100008.china.huawei.com (7.202.181.222) Content-Type: text/plain; charset="utf-8" After the system expands the narrow-partid feature and statically assigns all (req)PARTIDs to each control group, the following scenarios require configuration synchronization operations: 1. MSCs that support narrow-partid need to establish a mapping between reqPARTID and intPARTID after creating a new monitoring group. 2. MSCs that do not support narrow-partid need to synchronize the configuration of sub-monitoring groups after users update the control group configuration. In __write_config(), we synchronize a control group's configuration to each sub-monitoring group. Signed-off-by: Zeng Heng --- drivers/platform/arm64/mpam/mpam_devices.c | 25 ++++++++++++++++++--- drivers/platform/arm64/mpam/mpam_internal.h | 3 +++ drivers/platform/arm64/mpam/mpam_resctrl.c | 10 ++++++++- 3 files changed, 34 insertions(+), 4 deletions(-) diff --git a/drivers/platform/arm64/mpam/mpam_devices.c b/drivers/platform/= arm64/mpam/mpam_devices.c index 781c9146718d..91c5849f76e3 100644 --- a/drivers/platform/arm64/mpam/mpam_devices.c +++ b/drivers/platform/arm64/mpam/mpam_devices.c @@ -1544,6 +1544,7 @@ static void mpam_reprogram_ris_partid(struct mpam_msc= _ris *ris, u16 partid, u32 pri_val =3D 0; u16 cmax =3D MPAMCFG_CMAX_CMAX; u16 bwa_fract =3D MPAMCFG_MBW_MAX_MAX; + u16 intpartid =3D req2intpartid(partid); struct mpam_msc *msc =3D ris->vmsc->msc; struct mpam_props *rprops =3D &ris->props; u16 dspri =3D GENMASK(rprops->dspri_wd, 0); @@ -1554,8 +1555,14 @@ static void mpam_reprogram_ris_partid(struct mpam_ms= c_ris *ris, u16 partid, =20 if (mpam_has_feature(mpam_feat_partid_nrw, rprops)) { mpam_write_partsel_reg(msc, INTPARTID, - MPAMCFG_INTPARTID_INTERNAL | partid); - __mpam_intpart_sel(ris->ris_idx, partid, msc); + MPAMCFG_INTPARTID_INTERNAL | + intpartid); + + /* Already finish mapping reqPARTID to intPARTID */ + if (partid !=3D intpartid) + goto out; + + __mpam_intpart_sel(ris->ris_idx, intpartid, msc); } =20 if (mpam_has_feature(mpam_feat_cpor_part, rprops)) { @@ -1615,6 +1622,7 @@ static void mpam_reprogram_ris_partid(struct mpam_msc= _ris *ris, u16 partid, =20 mpam_quirk_post_config_change(ris, partid, cfg); =20 +out: mutex_unlock(&msc->part_sel_lock); } =20 @@ -3072,9 +3080,20 @@ struct mpam_write_config_arg { =20 static int __write_config(void *arg) { + int closid_num =3D resctrl_arch_get_num_closid(NULL); struct mpam_write_config_arg *c =3D arg; + u32 reqpartid, req_idx; + + WARN_ON(c->partid >=3D closid_num); =20 - mpam_reprogram_ris_partid(c->ris, c->partid, &c->comp->cfg[c->partid]); + /* Synchronize the configuration to each sub-monitoring group. */ + for (req_idx =3D 0; req_idx < get_num_reqpartid_per_closid(); + req_idx++) { + reqpartid =3D req_idx * closid_num + c->partid; + + mpam_reprogram_ris_partid(c->ris, reqpartid, + &c->comp->cfg[c->partid]); + } =20 return 0; } diff --git a/drivers/platform/arm64/mpam/mpam_internal.h b/drivers/platform= /arm64/mpam/mpam_internal.h index 5fc9f09b6945..c02365338b21 100644 --- a/drivers/platform/arm64/mpam/mpam_internal.h +++ b/drivers/platform/arm64/mpam/mpam_internal.h @@ -773,4 +773,7 @@ static inline void mpam_resctrl_teardown_class(struct m= pam_class *class) { } */ #define MSMON_CAPT_EVNT_NOW BIT(0) =20 +u32 get_num_reqpartid_per_closid(void); +u32 req2intpartid(u32 reqpartid); + #endif /* MPAM_INTERNAL_H */ diff --git a/drivers/platform/arm64/mpam/mpam_resctrl.c b/drivers/platform/= arm64/mpam/mpam_resctrl.c index 965ff9fd45d3..47e3a51b0942 100644 --- a/drivers/platform/arm64/mpam/mpam_resctrl.c +++ b/drivers/platform/arm64/mpam/mpam_resctrl.c @@ -171,11 +171,19 @@ static u32 get_num_reqpartid(void) return mpam_partid_max + 1; } =20 -static u32 get_num_reqpartid_per_closid(void) +u32 get_num_reqpartid_per_closid(void) { return get_num_reqpartid() / resctrl_arch_get_num_closid(NULL); } =20 +u32 req2intpartid(u32 reqpartid) +{ + u8 intpartid_shift =3D fls(mpam_intpartid_max); + u32 intpartid_mask =3D ~(~0 << intpartid_shift); + + return reqpartid & intpartid_mask; +} + u32 resctrl_arch_system_num_rmid_idx(void) { u8 closid_shift =3D fls(mpam_pmg_max); --=20 2.25.1