From patchwork Thu Jun 19 15:14:54 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jie Zhan X-Patchwork-Id: 898220 Received: from szxga05-in.huawei.com (szxga05-in.huawei.com [45.249.212.191]) (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 1429640C03 for ; Thu, 19 Jun 2025 15:22:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.191 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750346536; cv=none; b=dr4prBAcx5ssgA0a8oRBcOtWSVyQuLUxx7AUMATO/H/sKf0JxWxxdofu+J3Kqdln56NCHURfv1tixibdbhZWov2/NYflj/rkxDbhcgf4NapW97Lea0LrERm6KTclrkAXDZdVNJG2boPMEk3IRiI8m4VvkYltUF4UOhwh5RLWKzM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750346536; c=relaxed/simple; bh=dln/PaKdaAxwAHQKpxhJXACcd4dREDbhyP9b5kHyPwM=; h=From:To:CC:Subject:Date:Message-ID:MIME-Version:Content-Type; b=ZaE6+XGCs2lk6V3wwE5of2OTf/KkCG2CkMrHKkkS8OFhck83TBClpVcwrWYAz/ZGP4KRkJAZq0XHQEKb1BQo7KGQGJIToEMBlYxq3nbll9KIYp2gsaA3l6/HBO9J8q6X5h2s+p+wGwN/Rvzj+b7OIy5EbMCDUfjTWqNt1CVQOnY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=hisilicon.com; spf=pass smtp.mailfrom=hisilicon.com; arc=none smtp.client-ip=45.249.212.191 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=hisilicon.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=hisilicon.com Received: from mail.maildlp.com (unknown [172.19.163.44]) by szxga05-in.huawei.com (SkyGuard) with ESMTP id 4bNPRP0hmLz28fRJ; Thu, 19 Jun 2025 23:19:45 +0800 (CST) Received: from kwepemo100006.china.huawei.com (unknown [7.202.195.47]) by mail.maildlp.com (Postfix) with ESMTPS id 5D9D81402CE; Thu, 19 Jun 2025 23:22:10 +0800 (CST) Received: from localhost.localdomain (10.90.31.46) by kwepemo100006.china.huawei.com (7.202.195.47) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Thu, 19 Jun 2025 23:22:09 +0800 From: Jie Zhan To: , , , CC: , , , , , , , , , Subject: [PATCH v5 0/2] PM / devfreq: Add HiSilicon uncore frequency scaling driver Date: Thu, 19 Jun 2025 23:14:54 +0800 Message-ID: <20250619151456.3328624-1-zhanjie9@hisilicon.com> X-Mailer: git-send-email 2.30.0 Precedence: bulk X-Mailing-List: linux-pm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: kwepems200001.china.huawei.com (7.221.188.67) To kwepemo100006.china.huawei.com (7.202.195.47) Add the HiSilicon uncore frequency scaling driver for Kunpeng SoCs based on the devfreq framework. The uncore domain contains shared computing resources, including system interconnects and L3 cache. The uncore frequency significantly impacts the system-wide performance as well as power consumption. This driver adds support for runtime management of uncore frequency from kernel and userspace. The main function includes setting and getting frequencies, changing frequency scaling policies, and querying the list of CPUs whose performance is significantly related to this uncore frequency domain, etc. The driver communicates with a platform controller through an ACPI PCC mailbox to take the actual actions of frequency scaling. Changelog: v5: - Comment more on error code related stuff about hisi_uncore_mark_related_cpus(), and return failure early on errors except for -EINVAL, which indicates possibly broken firmware. - Separate error prints apart for two cases in hisi_platform_gov_handler() - Make the 'related_cpus' sysfs ABI description more generic - Some coding style cleanups and typo fixes v4: https://lore.kernel.org/linux-pm/20250530081722.280776-1-zhanjie9@hisilicon.com/ - Allow devfreq core to accept device-specific sysfs ABIs - Replace custom sysfs attrs with dev_groups and let the devfreq core manage it - Update 'related_cpus' description in the devfreq ABI doc - Remove COMPILE_TEST in Kconfig as the mailbox_client.h doesn't support this yet - Replace dev_err() with dev_err_probe() during drv->probe() - Replace mutex_init() with devm_mutex_init() to warn on UAF - Replace uncore->dev with dev in some places to make code a bit shorter - Remove redundant uncore->pchan check in hisi_uncore_free_pcc_chan() - Use __free() to let compiler release temporary memory - Clean up the error handling and redundant 'status = 0' in hisi_uncore_send_cmd() - Some coding style cleanup v3: https://lore.kernel.org/linux-pm/20250522031701.1912458-1-zhanjie9@hisilicon.com/ - Remove redundant resource freeing processes when drv->probe() fails as they're already handled by devm v2: https://lore.kernel.org/linux-pm/20250520074120.4187096-1-zhanjie9@hisilicon.com/ - Make devm manage the release sequence, remove drv->remove() - Warn on !uncore or !uncore->pchan as they're no longer expected - Remove ioremap of pcc shared memory because it's done by the pcc driver - Fix compiler warning of discarding 'const' - Minor trivial coding style changes v1: https://lore.kernel.org/linux-pm/20250506021434.944386-1-zhanjie9@hisilicon.com/ Jie Zhan (2): PM / devfreq: Allow devfreq driver to add custom sysfs ABIs PM / devfreq: Add HiSilicon uncore frequency scaling driver Documentation/ABI/testing/sysfs-class-devfreq | 9 + drivers/devfreq/Kconfig | 11 + drivers/devfreq/Makefile | 1 + drivers/devfreq/devfreq.c | 1 + drivers/devfreq/hisi_uncore_freq.c | 664 ++++++++++++++++++ include/linux/devfreq.h | 4 + 6 files changed, 690 insertions(+) create mode 100644 drivers/devfreq/hisi_uncore_freq.c