From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from frasgout.his.huawei.com (frasgout.his.huawei.com [185.176.79.56]) (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 3B0953451B5; Thu, 11 Sep 2025 15:07:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.176.79.56 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757603265; cv=none; b=dFTF1Kp52zAfgho0YiMAT7oc6Vspc9FnzAQ6rlwd/6qms0SIyLtgQDg31xqAZC7b9Lxkcnwt/NtXUVLBAr9pexLYIFe+HD75nM9LusToF1Dwi6Ig1PNrVFXdQc5s6NY6AzteZ4UG6te9NIGjBA93edvQuCnRiS1TVSVpxWlzmEE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757603265; c=relaxed/simple; bh=EhWfT/fftabdP9MyEall17eTwl+LK4+xGKcp9fL+0cg=; h=Date:From:To:CC:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=S/sUgK0ukBbqhQIUc49Du9445/B05qPEE9lluVHiJrOrQXOW4Hmq9gAc3JPWF2gweJcCgrjNuMLsjsLv6yNi5U8H97daDMJSbbJLDDUT9Z0sWYO/B55gBtQ8bSlamF+i+Ecn9xm8jllj8QMOKtvgxH3Im2uiOGTfXx0uqkUqTwE= 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=185.176.79.56 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.18.186.231]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4cN19D68wwz6GD8p; Thu, 11 Sep 2025 23:06:24 +0800 (CST) Received: from frapeml500008.china.huawei.com (unknown [7.182.85.71]) by mail.maildlp.com (Postfix) with ESMTPS id 6F8BD1400D9; Thu, 11 Sep 2025 23:07:40 +0800 (CST) Received: from localhost (10.203.177.15) by frapeml500008.china.huawei.com (7.182.85.71) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.39; Thu, 11 Sep 2025 17:07:39 +0200 Date: Thu, 11 Sep 2025 16:07:37 +0100 From: Jonathan Cameron To: James Morse CC: , , , D Scott Phillips OS , , , , , , Jamie Iles , Xin Hao , , , , David Hildenbrand , Dave Martin , Koba Ko , Shanker Donthineni , , , Rob Herring , Rohit Mathew , "Rafael Wysocki" , Len Brown , Lorenzo Pieralisi , Hanjun Guo , Sudeep Holla , Catalin Marinas , "Will Deacon" , Greg Kroah-Hartman , Danilo Krummrich , Lecopzer Chen Subject: Re: [PATCH v2 10/29] arm_mpam: Add cpuhp callbacks to probe MSC hardware Message-ID: <20250911160737.0000492f@huawei.com> In-Reply-To: <20250910204309.20751-11-james.morse@arm.com> References: <20250910204309.20751-1-james.morse@arm.com> <20250910204309.20751-11-james.morse@arm.com> X-Mailer: Claws Mail 4.3.0 (GTK 3.24.42; x86_64-w64-mingw32) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit X-ClientProxiedBy: lhrpeml500005.china.huawei.com (7.191.163.240) To frapeml500008.china.huawei.com (7.182.85.71) On Wed, 10 Sep 2025 20:42:50 +0000 James Morse wrote: > Because an MSC can only by accessed from the CPUs in its cpu-affinity > set we need to be running on one of those CPUs to probe the MSC > hardware. > > Do this work in the cpuhp callback. Probing the hardware will only > happen before MPAM is enabled, walk all the MSCs and probe those we can > reach that haven't already been probed as each CPU's online call is made. > > This adds the low-level MSC register accessors. > > Once all MSCs reported by the firmware have been probed from a CPU in > their respective cpu-affinity set, the probe-time cpuhp callbacks are > replaced. The replacement callbacks will ultimately need to handle > save/restore of the runtime MSC state across power transitions, but for > now there is nothing to do in them: so do nothing. > > The architecture's context switch code will be enabled by a static-key, > this can be set by mpam_enable(), but must be done from process context, > not a cpuhp callback because both take the cpuhp lock. > Whenever a new MSC has been probed, the mpam_enable() work is scheduled > to test if all the MSCs have been probed. If probing fails, mpam_disable() > is scheduled to unregister the cpuhp callbacks and free memory. > > CC: Lecopzer Chen > Signed-off-by: James Morse Trivial suggestion inline. Either way Reviewed-by: Jonathan Cameron > + > +/* Before mpam is enabled, try to probe new MSC */ > +static int mpam_discovery_cpu_online(unsigned int cpu) > +{ > + int err = 0; > + struct mpam_msc *msc; > + bool new_device_probed = false; > + > + guard(srcu)(&mpam_srcu); > + list_for_each_entry_srcu(msc, &mpam_all_msc, all_msc_list, > + srcu_read_lock_held(&mpam_srcu)) { > + if (!cpumask_test_cpu(cpu, &msc->accessibility)) > + continue; > + > + mutex_lock(&msc->probe_lock); > + if (!msc->probed) > + err = mpam_msc_hw_probe(msc); > + mutex_unlock(&msc->probe_lock); > + > + if (!err) > + new_device_probed = true; > + else > + break; Unless this going to get more complex why not if (err) break; new_device_probed = true; > + } > + > + if (new_device_probed && !err) > + schedule_work(&mpam_enable_work); > + if (err) { > + mpam_disable_reason = "error during probing"; > + schedule_work(&mpam_broken_work); > + } > + > + return err; > +} > +static void mpam_enable_once(void) > +{ > + mpam_register_cpuhp_callbacks(mpam_cpu_online, mpam_cpu_offline); > + > + pr_info("MPAM enabled\n"); Feels too noisy given it should be easy enough to tell. pr_dbg() perhaps. > +}