mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Amit Singh Tomar <amitsinght@marvell.com>
To: <linux-kernel@vger.kernel.org>, <linux-arm-kernel@lists.infradead.org>
Cc: <fenghua.yu@intel.com>, <reinette.chatre@intel.com>,
	<james.morse@arm.com>, <gcherian@marvell.com>, <robh@kernel.org>,
	<peternewman@google.com>, <dfustini@baylibre.com>,
	<jonathan.cameron@huawei.com>,
	Amit Singh Tomar <amitsinght@marvell.com>
Subject: [PATCH v1 13/14] arm_mpam: Handle resource instances mapped to different controls
Date: Wed, 17 Jan 2024 19:44:04 +0530	[thread overview]
Message-ID: <20240117141405.3063506-14-amitsinght@marvell.com> (raw)
In-Reply-To: <20240117141405.3063506-1-amitsinght@marvell.com>

At the moment, configuring multiple resource instances (mapped to same
control) under a resource class is not supported. For instance, on MARVELL
SoC MPAMF_IDR_NS[RIS_MAX] (under LLC MSC) is 0x2, and there are three
different resource at index 0,1,2. These are enumerated in
TAD_CMN_MPAM_RIS_E:

0: MSC
1: LTG
2: DTG

LLC MSC resource at index 0 has the Priority partitioning features.
If MPAMCFG_PART_SEL_NS[RIS] is set to 0 (MSC), then MPAMF_IDR_NS[HAS_PRI_PART]
is set to 1, leaving HAS_CPOR_PART bit to 0. CPOR and PRI_PART are
mutually exclusive resources as far configuration is concerned.

With this change, multiple resource instances that maps to different
control, say LTG for CPOR, and MSC for PRI_PART is handled properly.

Signed-off-by: Amit Singh Tomar <amitsinght@marvell.com>
---
Changes since RFC:
	* Trimmed down the commit message.
	* Tried to handle the corner case as suggested by Jonathan
	  by calling the __resource_props_mismatch even when different
	  controls are enumerated at different RIS index.
---
 drivers/platform/mpam/mpam_devices.c | 36 ++++++++++++++++++++++++----
 1 file changed, 31 insertions(+), 5 deletions(-)

diff --git a/drivers/platform/mpam/mpam_devices.c b/drivers/platform/mpam/mpam_devices.c
index 388d57281fd8..df7ac2c8bcb3 100644
--- a/drivers/platform/mpam/mpam_devices.c
+++ b/drivers/platform/mpam/mpam_devices.c
@@ -1788,11 +1788,15 @@ __resource_props_mismatch(struct mpam_msc_ris *ris, struct mpam_class *class)
 
 	lockdep_assert_held(&mpam_list_lock); /* we modify class */
 
-	/* Clear missing features */
-	cprops->features &= rprops->features;
+	/* Clear missing features, we don't want to clear features,
+	 * when different controls are implemented at different RIS
+	 * index.
+	 */
+	if (class->props.features == ris->props.features)
+		cprops->features &= rprops->features;
 
 	/* Clear incompatible features */
-	if (cprops->cpbm_wd != rprops->cpbm_wd)
+	if (cprops->cpbm_wd != rprops->cpbm_wd && rprops->cpbm_wd)
 		mpam_clear_feature(mpam_feat_cpor_part, &cprops->features);
 	if (cprops->mbw_pbm_bits != rprops->mbw_pbm_bits)
 		mpam_clear_feature(mpam_feat_mbw_part, &cprops->features);
@@ -1802,14 +1806,14 @@ __resource_props_mismatch(struct mpam_msc_ris *ris, struct mpam_class *class)
 		cprops->bwa_wd = min(cprops->bwa_wd, rprops->bwa_wd);
 
 	/* For num properties, take the minimum */
-	if (cprops->num_csu_mon != rprops->num_csu_mon)
+	if (cprops->num_csu_mon != rprops->num_csu_mon && rprops->num_csu_mon)
 		cprops->num_csu_mon = min(cprops->num_csu_mon, rprops->num_csu_mon);
 	if (cprops->num_mbwu_mon != rprops->num_mbwu_mon)
 		cprops->num_mbwu_mon = min(cprops->num_mbwu_mon, rprops->num_mbwu_mon);
 
 	if (cprops->intpri_wd != rprops->intpri_wd)
 		cprops->intpri_wd = min(cprops->intpri_wd, rprops->intpri_wd);
-	if (cprops->dspri_wd != rprops->dspri_wd)
+	if (cprops->dspri_wd != rprops->dspri_wd && rprops->dspri_wd)
 		cprops->dspri_wd = min(cprops->dspri_wd, rprops->dspri_wd);
 
 	/* {int,ds}pri may not have differing 0-low behaviour */
@@ -1845,6 +1849,20 @@ static void mpam_enable_init_class_features(struct mpam_class *class)
 	class->props = ris->props;
 }
 
+/* Club different resource properties under a class that resctrl uses,
+ * for instance, L3 cache that supports both CPOR, and DSPRI need to have
+ * knowledge of both cpbm_wd and dspri_wd. This is needed when two controls
+ * are enumerated under differnt RIS Index.
+ */
+static void mpam_enable_club_class_features(struct mpam_class *class,
+					    struct mpam_msc_ris *ris)
+{
+	class->props.features |= ris->props.features;
+	class->props.cpbm_wd |= ris->props.cpbm_wd;
+	class->props.dspri_wd |= ris->props.dspri_wd;
+	class->props.num_csu_mon |= ris->props.num_csu_mon;
+}
+
 /* Merge all the common resource features into class. */
 static void mpam_enable_merge_features(void)
 {
@@ -1860,6 +1878,14 @@ static void mpam_enable_merge_features(void)
 		list_for_each_entry(comp, &class->components, class_list) {
 			list_for_each_entry(ris, &comp->ris, comp_list) {
 				__resource_props_mismatch(ris, class);
+				/*
+				 * There can be multiple resources under a class which is
+				 * mapped to different controls, For instance L3 cache
+				 * can have both CPOR and DSPRI implemented with different
+				 * RIS.
+				 */
+				if (class->props.features != ris->props.features)
+					mpam_enable_club_class_features(class, ris);
 
 				class->nrdy_usec = max(class->nrdy_usec,
 						     ris->msc->nrdy_usec);
-- 
2.25.1


  parent reply	other threads:[~2024-01-17 14:15 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-17 14:13 [PATCH v1 00/14] ARM: MPAM: add support for priority partitioning control Amit Singh Tomar
2024-01-17 14:13 ` [PATCH v1 01/14] fs/resctrl: group the resource control types for schemata list Amit Singh Tomar
2024-01-17 19:21   ` Peter Newman
2024-01-17 14:13 ` [PATCH v1 02/14] arm_mpam: resctrl: Detect priority partitioning capability Amit Singh Tomar
2024-01-17 14:13 ` [PATCH v1 03/14] arm_mpam: resctrl: extend the schemata list to support priority partition Amit Singh Tomar
2024-01-17 14:13 ` [PATCH v1 04/14] fs/resctrl: Set-up downstream priority partition resources Amit Singh Tomar
2024-01-17 14:13 ` [PATCH v1 05/14] fs/resctrl: fetch configuration based on control type Amit Singh Tomar
2024-01-17 14:13 ` [PATCH v1 06/14] arm_mpam: resctrl: Retrieve priority values from arch code Amit Singh Tomar
2024-01-17 14:13 ` [PATCH v1 07/14] fs/resctrl: Schemata write only for intended resource Amit Singh Tomar
2024-01-17 14:13 ` [PATCH v1 08/14] fs/resctrl: Extend schemata write for priority partition control Amit Singh Tomar
2024-01-17 14:14 ` [PATCH v1 09/14] fs/resctrl: set configuration based on Control type Amit Singh Tomar
2024-01-17 14:14 ` [PATCH v1 10/14] arm_mpam: resctrl: Facilitate writing downstream priority value Amit Singh Tomar
2024-01-17 14:14 ` [PATCH v1 11/14] arm_mpam: Fix Downstream and internal priority mask Amit Singh Tomar
2024-01-17 14:14 ` [PATCH v1 12/14] arm_mpam: Program Downstream priority value Amit Singh Tomar
2024-01-17 14:14 ` Amit Singh Tomar [this message]
2024-01-17 18:03   ` [PATCH v1 13/14] arm_mpam: Handle resource instances mapped to different controls Peter Newman
2024-01-19 13:01     ` [EXT] " Amit Singh Tomar
2024-01-19 22:05       ` Peter Newman
2024-05-08 13:55         ` Amit Singh Tomar
2024-01-17 14:14 ` [PATCH v1 14/14] arm64/mpam: resctrl: export DSPRI value to info directory Amit Singh Tomar
2024-01-17 23:59 ` [PATCH v1 00/14] ARM: MPAM: add support for priority partitioning control Reinette Chatre

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=20240117141405.3063506-14-amitsinght@marvell.com \
    --to=amitsinght@marvell.com \
    --cc=dfustini@baylibre.com \
    --cc=fenghua.yu@intel.com \
    --cc=gcherian@marvell.com \
    --cc=james.morse@arm.com \
    --cc=jonathan.cameron@huawei.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=peternewman@google.com \
    --cc=reinette.chatre@intel.com \
    --cc=robh@kernel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®