public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Dave Martin <Dave.Martin@arm.com>
To: linux-kernel@vger.kernel.org
Cc: linux-arm-kernel@lists.infradead.org,
	Zeng Heng <zengheng4@huawei.com>,
	Shaopeng Tan <tan.shaopeng@fujitsu.com>,
	James Morse <james.morse@arm.com>
Subject: [RFC PATCH 1/6] arm_mpam: Clean up config update checks in mpam_apply_config()
Date: Thu, 12 Dec 2024 15:39:55 +0000	[thread overview]
Message-ID: <20241212154000.330467-2-Dave.Martin@arm.com> (raw)
In-Reply-To: <20241212154000.330467-1-Dave.Martin@arm.com>

In mpam_apply_config(), a simple memcmp() test is used to check
whether the config passed by the caller is already installed or
not.

This check will never find a match except (very occasionally) by
accident, since the component's version of the struct contains
things that the caller won't pass or doesn't know (such as the
garbage collection record).  There might also be random padding.

This may result in MSCs being reprogrammed unnecessarily.

Instead, only compare fields that the caller specified.  If
anything is present in the caller's config and doesn't match the
installed config, paste it across.  If nothing was pasted across
then the MSC reprogramming step is skipped (as the previous code
attempted to do).

Signed-off-by: Dave Martin <Dave.Martin@arm.com>

---

There are comments in the code suggesting a change of this sort.
I may or may not have gone in the right direction with this, and
I have only tried to clean up the behaviour rather than optimising.

No attempt is made to skip unnecessary MSC register updates if the MSC
reprogramming goes ahead.

NOT well tested, yet.
---
 drivers/platform/arm64/mpam/mpam_devices.c | 23 ++++++++++++++++++++++
 1 file changed, 23 insertions(+)

diff --git a/drivers/platform/arm64/mpam/mpam_devices.c b/drivers/platform/arm64/mpam/mpam_devices.c
index 9463045c0011..41962dd1bb68 100644
--- a/drivers/platform/arm64/mpam/mpam_devices.c
+++ b/drivers/platform/arm64/mpam/mpam_devices.c
@@ -3120,6 +3120,29 @@ static void mpam_extend_config(struct mpam_class *class, struct mpam_config *cfg
 	}
 }
 
+#define maybe_update_config(cfg, feature, newcfg, member, changes) do { \
+	if (mpam_has_feature(feature, newcfg) &&			\
+	    (newcfg)->member != (cfg)->member) {			\
+		(cfg)->member = (newcfg)->member;			\
+		mpam_set_feature(feature, cfg);				\
+									\
+		(changes) |= (feature);					\
+	}								\
+} while (0)
+
+static mpam_features_t mpam_update_config(struct mpam_config *cfg,
+					  const struct mpam_config *newcfg)
+{
+	mpam_features_t changes = 0;
+
+	maybe_update_config(cfg, mpam_feat_cpor_part, newcfg, cpbm, changes);
+	maybe_update_config(cfg, mpam_feat_mbw_part, newcfg, mbw_pbm, changes);
+	maybe_update_config(cfg, mpam_feat_mbw_max, newcfg, mbw_max, changes);
+	maybe_update_config(cfg, mpam_feat_mbw_min, newcfg, mbw_min, changes);
+
+	return changes;
+}
+
 /* TODO: split into write_config/sync_config */
 /* TODO: add config_dirty bitmap to drive sync_config */
 int mpam_apply_config(struct mpam_component *comp, u16 partid,
-- 
2.34.1


  reply	other threads:[~2024-12-12 15:40 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-12-12 15:39 [RFC PATCH 0/6] Introduce flexible CLOSID/RMID translation Dave Martin
2024-12-12 15:39 ` Dave Martin [this message]
2024-12-12 17:06   ` [RFC PATCH 1/6] arm_mpam: Clean up config update checks in mpam_apply_config() Dave Martin
2024-12-12 15:39 ` [RFC PATCH 2/6] arm_mpam: Fix read-back of cloned resource controls under CDP emulation Dave Martin
2024-12-12 15:39 ` [RFC PATCH 3/6] arm_mpam: Delete unused function resctrl_arch_set_rmid() Dave Martin
2024-12-12 15:39 ` [RFC PATCH 4/6] arm_mpam: Introduce flexible CLOSID/RMID translation Dave Martin
2024-12-20  5:01   ` Shaopeng Tan (Fujitsu)
2025-01-02 16:14     ` Dave Martin
2025-01-08  6:45       ` Shaopeng Tan (Fujitsu)
2024-12-12 15:39 ` [RFC PATCH 5/6] arm_mpam: [NFU] Rework ID remapping to use a kernel command-line argument Dave Martin
2024-12-12 15:40 ` [RFC PATCH 6/6] arm_mpam: [NFU] Development diagnostics for MPAM ID assignments Dave Martin

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=20241212154000.330467-2-Dave.Martin@arm.com \
    --to=dave.martin@arm.com \
    --cc=james.morse@arm.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tan.shaopeng@fujitsu.com \
    --cc=zengheng4@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox