From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2F21B41CB3B for ; Fri, 10 Jul 2026 11:56:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783684579; cv=none; b=ENK8dwGRnpPw1uaTeAu5QxXjT55SAC6U7khIgs7hUUFcSjYHpo1qdiO7QgwNZpgU5k92Z5dWNmQmZ6xoQxJvjO5TP8pSOqrMOkO0Nql/+46TMyPPqMI5FSEktTo2xGpxYfu6FyxbenS7eZlFHdzKy7yPCdbSI+wYSVlW3hakyjE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783684579; c=relaxed/simple; bh=8TVx75ha39M0Z5Dj+uNRxEhIdCRJjUHu/0cTQP+NjGI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Y77mjWk6yk9gbNqSQYTyfjJ8W74pfjxWIq6gsqpMoFvLu9928rCOU17G4p8HLqNfb5dg3ikOJ4OjtGsoE3+uNeML0ozv4hUIqqP4pe2nVznXgQ7PKZn1IEDZ2X+2YCliH9iuH0smAD+NFce8cLmMrJTvCcCcx/Qt9B72podSQbE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.b=Z2GZVF0D; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.b="Z2GZVF0D" Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id BBBFC1F60; Fri, 10 Jul 2026 04:56:07 -0700 (PDT) Received: from e134344.cambridge.arm.com (e134344.arm.com [10.2.212.8]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id C94B23F85F; Fri, 10 Jul 2026 04:56:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=arm.com; s=foss; t=1783684572; bh=8TVx75ha39M0Z5Dj+uNRxEhIdCRJjUHu/0cTQP+NjGI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Z2GZVF0DtmISB+PC2UM+RHAzQQwDqcbUsx6qrdNfe/rhQ1VYG3a7CJRKY+tV1AD1h FM3zBVDTXOpz/NrZVoT4Zm2PIaGIlAWTzCThdhIT7kpf6cXJ1vJoKE3aAonjicbYwr iTY/v1lcvQkPpSvFWKnI5qKUbwClbp64NB3ESmsM= From: Ben Horgan To: ben.horgan@arm.com Cc: james.morse@arm.com, reinette.chatre@intel.com, fenghuay@nvidia.com, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, dave.martin@arm.com, andre.przywara@arm.com Subject: [PATCH v1 10/11] arm_mpam: Don't loop forever if there is the maximum possible amount of PARTIDs Date: Fri, 10 Jul 2026 12:55:44 +0100 Message-ID: <20260710115546.29644-11-ben.horgan@arm.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260710115546.29644-1-ben.horgan@arm.com> References: <20260710115546.29644-1-ben.horgan@arm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit On a theoretical platform with the maximum possible number of usable PARTIDs, 0XFFFF, the loops iterating over PARTID in mpam_reset_ris() and mpam_reprogram_ris() will never reach their termination condition leading to a system hang when register the cpu hotplug handlers when MPAM is enabling. Fix these loops. Fixes: f188a36ca241 ("arm_mpam: Reset MSC controls from cpuhp callbacks") Fixes: 09b89d2a72f3 ("arm_mpam: Allow configuration to be applied and restored during cpu online") Signed-off-by: Ben Horgan --- drivers/resctrl/mpam_devices.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/resctrl/mpam_devices.c b/drivers/resctrl/mpam_devices.c index c9adc450f087..9412ffde1cf1 100644 --- a/drivers/resctrl/mpam_devices.c +++ b/drivers/resctrl/mpam_devices.c @@ -1735,7 +1735,7 @@ static int mpam_save_mbwu_state(void *arg) */ static int mpam_reset_ris(void *arg) { - u16 partid, partid_max; + u16 partid_max; struct mpam_config reset_cfg = {}; struct mpam_msc_ris *ris = arg; @@ -1745,7 +1745,7 @@ static int mpam_reset_ris(void *arg) spin_lock(&partid_max_lock); partid_max = mpam_partid_max; spin_unlock(&partid_max_lock); - for (partid = 0; partid <= partid_max; partid++) + for (u32 partid = 0; partid <= partid_max; partid++) mpam_reprogram_ris_partid(ris, partid, &reset_cfg); return 0; @@ -1792,7 +1792,6 @@ static int __write_config(void *arg) static void mpam_reprogram_msc(struct mpam_msc *msc) { - u16 partid; bool reset; struct mpam_config *cfg; struct mpam_msc_ris *ris; @@ -1816,7 +1815,7 @@ static void mpam_reprogram_msc(struct mpam_msc *msc) arg.comp = ris->vmsc->comp; arg.ris = ris; reset = true; - for (partid = 0; partid <= mpam_partid_max; partid++) { + for (u32 partid = 0; partid <= mpam_partid_max; partid++) { cfg = &ris->vmsc->comp->cfg[partid]; if (!bitmap_empty(cfg->features, MPAM_FEATURE_LAST)) reset = false; -- 2.43.0