From patchwork Mon Oct 28 02:01:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 839138 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2069.outbound.protection.outlook.com [40.107.243.69]) (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 D9DB8174EF0; Mon, 28 Oct 2024 02:02:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.243.69 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730080930; cv=fail; b=qOmCOh6fby/gUZRSwO+qmYdRDVl4FZyZoHl48F0XFJexufP55IBA6YAolzGAdp2b8Jc9V5fZ+yIRmbNw5/fVdbEhRuxXm5L3XXfff46dw7Tk+1wydt17MbTlVf1zKxNqqg72w1Bx5EMWLf2SurL2aUtGBfCJwIy/6vcfw8Zpp2o= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730080930; c=relaxed/simple; bh=UKH3Cd3FdQ6hIy3Zj8VNJUSXixyrxzUlvgD4ttF988I=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=rfhopl8xf2yBG0f+mesnMMVBWAZefKr3l4kI7EZUX+cSLFmJUTuWP+Ak5NsQaiLsGy0XCp7J54jM51R3C0XxCzw+hXZsBc2Rg2DOm/sEmA9YCnU7y7pBuae+ajZkQM2XeiTjiqgHka9J5qJiTUbKJxinQCztMRkSk05YAfR4PKU= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=PlGaKrnh; arc=fail smtp.client-ip=40.107.243.69 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="PlGaKrnh" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=arj6b7CTnxuqfByEKBExUrPp1S2r14wWgh3Bf5ugRYZJrFVuoZEkMWQ56Qjd65YfYPlxRZlBeCN7HeGloR6DRFhVRB794qBTNfpHPDVHy1UVIowsViRUbEzXFLNriKCsOGNtJDsXIlwODvboQlfVBdvg0q6lKt4lrTDBaGWWjv2uQHRMzA/sRTdHXAxhVZStKHfEj/N3v6SbpS1JOm91MiTvoHXfVpiRO2Wq6//QGLl2/Ye0A20QmGkcdi0MpygZ163KAtKSOjrlToNP67fkdeYZ6JTX3ZrXtY0U+eQVwucHoqoM+4dSdu4qX+TOwvITpScfBIigbrJMAj1xwJ5OzA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=b5TXgnY2L7xAtUurtNfnvETk/PhaZ23e7WGCm1sQZ6Q=; b=pSvVYqNxEtz7puzUrr+BCAbq6RoTq7RVTYwrXK4fFXygvZjNBbRcBH2YcU0MV8mChffR6LSwynGXScry28I9+Csh1PfE+yaU3VODE0JtariQ77jW6nJvH/mG3WKbCM1JnMuT0dAAqL3OPX1wbzWkEen4lEKg7Q/cFSJFV7dI69vVlsnOsCzRYUPW5QhPQjaQly1CEYHpBZ3iqrUKKKxVqovXS4JZKs1NRM0DXssXTYS4DxEZz6QN/yz742/OebuUgKBZfe3sPD4UEi7IOecB4Bu680l+oN/k7bH7Nq0T0Rj5SZYviYAeol64gdMUfaatqotzvpj0JycZVtL6c0IKxw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=redhat.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=b5TXgnY2L7xAtUurtNfnvETk/PhaZ23e7WGCm1sQZ6Q=; b=PlGaKrnhOyrwZHlnY2yrSm9s74AFo4qGq5EMM1LcWbNy1uLpUigcaD2A9D5qjdp0xN//ZpL3BnrofsdhSHp8hNB2o11qd8BibbughLPXppa3b9pZHkUYemRl1RjhSpJNCfjeODn3dSgo6cmOO+RSPEPvhH0XzSfdVXu7xX5N/Ug= Received: from IA1P220CA0010.NAMP220.PROD.OUTLOOK.COM (2603:10b6:208:461::7) by DM4PR12MB7671.namprd12.prod.outlook.com (2603:10b6:8:104::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.23; Mon, 28 Oct 2024 02:01:57 +0000 Received: from BL02EPF00021F68.namprd02.prod.outlook.com (2603:10b6:208:461:cafe::29) by IA1P220CA0010.outlook.office365.com (2603:10b6:208:461::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.25 via Frontend Transport; Mon, 28 Oct 2024 02:01:57 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by BL02EPF00021F68.mail.protection.outlook.com (10.167.249.4) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8093.14 via Frontend Transport; Mon, 28 Oct 2024 02:01:57 +0000 Received: from AUS-P9-MLIMONCI.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Sun, 27 Oct 2024 21:01:54 -0500 From: Mario Limonciello To: Hans de Goede , =?utf-8?q?Ilpo_J=C3=A4rvinen?= CC: "Rafael J . Wysocki" , Len Brown , Maximilian Luz , Lee Chun-Yi , "Shyam Sundar S K" , Corentin Chary , "Luke D . Jones" , Ike Panhc , Henrique de Moraes Holschuh , "Alexis Belmonte" , =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= , Ai Chao , Gergo Koteles , open list , "open list:ACPI" , "open list:MICROSOFT SURFACE PLATFORM PROFILE DRIVER" , "open list:THINKPAD ACPI EXTRAS DRIVER" , Mark Pearson , Matthew Schwartz , Mario Limonciello Subject: [PATCH v2 01/15] ACPI: platform-profile: Add a name member to handlers Date: Sun, 27 Oct 2024 21:01:17 -0500 Message-ID: <20241028020131.8031-2-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241028020131.8031-1-mario.limonciello@amd.com> References: <20241028020131.8031-1-mario.limonciello@amd.com> Precedence: bulk X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL02EPF00021F68:EE_|DM4PR12MB7671:EE_ X-MS-Office365-Filtering-Correlation-Id: 91be84c9-bbe3-4ae6-f3c6-08dcf6f480f3 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|376014|1800799024|36860700013|7416014|82310400026; X-Microsoft-Antispam-Message-Info: HHojgvmMPnzEbIm+mvSouv+IPQVSL3x/SHtb0S4hOYXWcK4qBCuzLkZIvSoYYjl4DTeMg61pvENDaMt9MbIj590EAZZuQR7RtWHY2dfV/9R+9n+uFHaToCmsx0AzHUxs1fZ3n5eijdJ6+1pWi6cT9CRyJfoI5TJBJicRFqiJHOYzez0to0agjway38hEHj/4bW2SjsxQzYFWJfgGY0rYcxPOb8qjjtqKXrJH1RJmf4fyeDQF9ihdmBiF7SOmxSkZIpl4c5WzLd4GyLLriEjHbrE9m/eiSlon1xkNJwtYuYfJR0K4BBfHXdbzykKJttFMRjoAIvFvFeF649wDI8S3ROAM0f/eNZgRLJJj2+cwQljctlTu1fm/RBOuNdSKnTVV57tnl5wnnTrbHbWaywweySI6hDGjvtOgFt4UawGvlF9OANGCMxnZ+3+pHk4imEbn3VbzzhCD58Ldazf/qu4PArtT8HV5vIP+XsRAG3gqJXB9mrwnSgGQvKEezySFupUz//kkvuJqUiws0lCqZYbuABYcOD+cdqNJxTDdBeG4gq0JJgPcDhsjbUCUf9PzqBLqtux+qFhcpVdRbf5fnL5Gm11Y+hAdeAohvlGTQFLah4vtq+KBuQubNjq4kBvlJ+9hgLC0fThzLBHWGzangiZM0I8WPquBJcxjWbXbNgYnOfypomgcn0KLk4BZ+7e4fJbtgQAGz2MDsmP1iQjRNT8u2+nmlo62ryDMoDYEEzRbnoD8gg/pj/UiFHh6BfdxH18LtyFtSel7HJG1FX+/sH62AMHb85RwxeF8fCzHxYoMm4KzFiuoXNK67dHl3jSpk2ne9ys/JFdGFPNaqqKQYkvtVY96KxscCTcVZN0wMJCnD62YW1Q6jjHEXA348nlZOptqJJon52bujzyKfL8eyOUAVM4IqqOfoNd4jydfYKe4NP+1dt9sFRbjyI/dCWUg+aPbwtGXDJupLnN9y05wDEQJuAp79kP5Xo5H9Qow+aP56rbT/zT2Hrq9JnzUHnMybrIa0jFnrn5us+P8ZseM+H/melOSJ8BmR59r/5X35vJqhY6Pp6NPz0E4IfktdsG8Pz9aIpebsloF/j5Dey/0Aplk1fDbWj7uiVAIE7WRqo+sUyIulw2w69Mqj6CyeobvRz6PIjHUi3emtv+n4FdJF0GXbIyKH8jugO56ln7Yn6hPo9Cj7dS1+hNOY+hnnpUAwFSVFFanhontPjPfMw5+awXkLqrGUCqZ6SqOI2vP3xw8YvN8uiX+UuuK7n5HCwxPM45VQByTYYMZRxQ91VKLzedc+sD3bCZbaBEVZ/84EcT3J73YMpUOqu2KAC8WYvVajko1a0OKBuVJd4Q8/HRxAniCpiaEi4N2VjvuIOWjqPEFCRyowOmC8JbUXUHR1xyjrfUei/bErJ6vzfBdxejBHH/EnQ== X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230040)(376014)(1800799024)(36860700013)(7416014)(82310400026); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Oct 2024 02:01:57.5067 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 91be84c9-bbe3-4ae6-f3c6-08dcf6f480f3 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d; Ip=[165.204.84.17]; Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BL02EPF00021F68.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB7671 In order to prepare for allowing multiple handlers, introduce a name field that can be used to distinguish between different handlers. Tested-by: Matthew Schwartz Reviewed-by: Hans de Goede Signed-off-by: Mario Limonciello --- drivers/platform/surface/surface_platform_profile.c | 1 + drivers/platform/x86/acer-wmi.c | 1 + drivers/platform/x86/amd/pmf/sps.c | 1 + drivers/platform/x86/asus-wmi.c | 1 + drivers/platform/x86/dell/dell-pc.c | 1 + drivers/platform/x86/hp/hp-wmi.c | 1 + drivers/platform/x86/ideapad-laptop.c | 1 + drivers/platform/x86/inspur_platform_profile.c | 1 + drivers/platform/x86/thinkpad_acpi.c | 1 + include/linux/platform_profile.h | 1 + 10 files changed, 10 insertions(+) diff --git a/drivers/platform/surface/surface_platform_profile.c b/drivers/platform/surface/surface_platform_profile.c index 3de864bc66108..61aa488a80eb5 100644 --- a/drivers/platform/surface/surface_platform_profile.c +++ b/drivers/platform/surface/surface_platform_profile.c @@ -211,6 +211,7 @@ static int surface_platform_profile_probe(struct ssam_device *sdev) tpd->sdev = sdev; + tpd->handler.name = "Surface Platform Profile"; tpd->handler.profile_get = ssam_platform_profile_get; tpd->handler.profile_set = ssam_platform_profile_set; diff --git a/drivers/platform/x86/acer-wmi.c b/drivers/platform/x86/acer-wmi.c index d09baa3d3d902..53fbc9b4d3df7 100644 --- a/drivers/platform/x86/acer-wmi.c +++ b/drivers/platform/x86/acer-wmi.c @@ -1878,6 +1878,7 @@ static int acer_platform_profile_setup(void) if (quirks->predator_v4) { int err; + platform_profile_handler.name = "acer-wmi"; platform_profile_handler.profile_get = acer_predator_v4_platform_profile_get; platform_profile_handler.profile_set = diff --git a/drivers/platform/x86/amd/pmf/sps.c b/drivers/platform/x86/amd/pmf/sps.c index 92f7fb22277dc..e2d0cc92c4396 100644 --- a/drivers/platform/x86/amd/pmf/sps.c +++ b/drivers/platform/x86/amd/pmf/sps.c @@ -405,6 +405,7 @@ int amd_pmf_init_sps(struct amd_pmf_dev *dev) amd_pmf_set_sps_power_limits(dev); } + dev->pprof.name = "amd-pmf"; dev->pprof.profile_get = amd_pmf_profile_get; dev->pprof.profile_set = amd_pmf_profile_set; diff --git a/drivers/platform/x86/asus-wmi.c b/drivers/platform/x86/asus-wmi.c index 2ccc23b259d3e..c7c104c65a85a 100644 --- a/drivers/platform/x86/asus-wmi.c +++ b/drivers/platform/x86/asus-wmi.c @@ -3910,6 +3910,7 @@ static int platform_profile_setup(struct asus_wmi *asus) dev_info(dev, "Using throttle_thermal_policy for platform_profile support\n"); + asus->platform_profile_handler.name = "asus-wmi"; asus->platform_profile_handler.profile_get = asus_wmi_platform_profile_get; asus->platform_profile_handler.profile_set = asus_wmi_platform_profile_set; diff --git a/drivers/platform/x86/dell/dell-pc.c b/drivers/platform/x86/dell/dell-pc.c index 972385ca1990b..3cf79e55e3129 100644 --- a/drivers/platform/x86/dell/dell-pc.c +++ b/drivers/platform/x86/dell/dell-pc.c @@ -247,6 +247,7 @@ static int thermal_init(void) thermal_handler = kzalloc(sizeof(*thermal_handler), GFP_KERNEL); if (!thermal_handler) return -ENOMEM; + thermal_handler->name = "dell-pc"; thermal_handler->profile_get = thermal_platform_profile_get; thermal_handler->profile_set = thermal_platform_profile_set; diff --git a/drivers/platform/x86/hp/hp-wmi.c b/drivers/platform/x86/hp/hp-wmi.c index 81ccc96ffe40a..26cac73caf2b9 100644 --- a/drivers/platform/x86/hp/hp-wmi.c +++ b/drivers/platform/x86/hp/hp-wmi.c @@ -1624,6 +1624,7 @@ static int thermal_profile_setup(void) set_bit(PLATFORM_PROFILE_COOL, platform_profile_handler.choices); } + platform_profile_handler.name = "hp-wmi"; set_bit(PLATFORM_PROFILE_BALANCED, platform_profile_handler.choices); set_bit(PLATFORM_PROFILE_PERFORMANCE, platform_profile_handler.choices); diff --git a/drivers/platform/x86/ideapad-laptop.c b/drivers/platform/x86/ideapad-laptop.c index 9d8c3f064050e..1f94c14c3b832 100644 --- a/drivers/platform/x86/ideapad-laptop.c +++ b/drivers/platform/x86/ideapad-laptop.c @@ -1102,6 +1102,7 @@ static int ideapad_dytc_profile_init(struct ideapad_private *priv) mutex_init(&priv->dytc->mutex); + priv->dytc->pprof.name = "ideapad-laptop"; priv->dytc->priv = priv; priv->dytc->pprof.profile_get = dytc_profile_get; priv->dytc->pprof.profile_set = dytc_profile_set; diff --git a/drivers/platform/x86/inspur_platform_profile.c b/drivers/platform/x86/inspur_platform_profile.c index 8440defa67886..03da2c8cf6789 100644 --- a/drivers/platform/x86/inspur_platform_profile.c +++ b/drivers/platform/x86/inspur_platform_profile.c @@ -177,6 +177,7 @@ static int inspur_wmi_probe(struct wmi_device *wdev, const void *context) priv->wdev = wdev; dev_set_drvdata(&wdev->dev, priv); + priv->handler.name = "inspur-wmi"; priv->handler.profile_get = inspur_platform_profile_get; priv->handler.profile_set = inspur_platform_profile_set; diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c index 4c1b0553f8720..c8c316b8507a5 100644 --- a/drivers/platform/x86/thinkpad_acpi.c +++ b/drivers/platform/x86/thinkpad_acpi.c @@ -10549,6 +10549,7 @@ static void dytc_profile_refresh(void) } static struct platform_profile_handler dytc_profile = { + .name = "thinkpad-acpi", .profile_get = dytc_profile_get, .profile_set = dytc_profile_set, }; diff --git a/include/linux/platform_profile.h b/include/linux/platform_profile.h index f5492ed413f36..6fa988e417428 100644 --- a/include/linux/platform_profile.h +++ b/include/linux/platform_profile.h @@ -27,6 +27,7 @@ enum platform_profile_option { }; struct platform_profile_handler { + const char *name; unsigned long choices[BITS_TO_LONGS(PLATFORM_PROFILE_LAST)]; int (*profile_get)(struct platform_profile_handler *pprof, enum platform_profile_option *profile); From patchwork Mon Oct 28 02:01:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 839137 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2069.outbound.protection.outlook.com [40.107.93.69]) (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 2D631187862; Mon, 28 Oct 2024 02:02:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.93.69 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730080933; cv=fail; b=TCvZKbagjdTA9HqhsIW3M3hirOOG6nHCMxM8E0HGu6/50caoJJAU+Wt2Gtij6WcUULCACdaPfSPn7r6O/CtPY3fxgqI8hahztL3ljc3u3PiUcYnx1ed87Tb8TqmbS3HDTYLxTgffPWb5/+D6/i9Jje+EQO2ZvT6nVzxIwD7hjTg= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730080933; c=relaxed/simple; bh=BemhE3FLBJt8TXb7tQ33+yfm7BmIFqxRNCRy01CsV3k=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=WgIx4mfbd6O3T6pWOmTGCZnd1oqEOCO8nc4M2H888qUA/fq/XWzRAaipYTmxzYtur/r/lYja6I0u4aMt8oRzQNISEWqEAT4/rDgV/vH33spY9uaQ4H3TexYjI4rIT/cugjSSVgj9u+mBPLKucB+YDRcBxjivkreTosMcX4+qshA= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=N57rapsk; arc=fail smtp.client-ip=40.107.93.69 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="N57rapsk" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=FGdr/3sZUK6h/9TneziCVV+ULRZPGbbvgfmFe7e47Abz6NBbj0mkKWsbvUw3A1xSzMw2TPn0y/pkZfEzV9h+7gtnNmHyy47Gl3R9HXRmQu2t947AbGmwCcpZAzkDukJeVOTgkaQTkIg+6symrnDrePbKkLLCGidL1w+5lz4RWnMToARHD5XRhW0ktE/EupGcMxz4uzGvb2dMtiTkFWXnDV1OqO/6edd40w0XZiyeyjvdDKvtgcIVjh0tnjDOCMuxIMddDZT0sDTnA4Lxwl8fS0DUsUsL7OVTvED+3nA6JpQwSJ5jkJX5IRXIXjdgtpQgS3BVCeww9FUGdtQgOoCB1A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=qpxkTbpsmel7PNy9hFdoS5mAlgzObBowHU7VZLZDO1k=; b=NYfgUVJJJkK8whGbxe+ZwK10K578WXp9mp4Q1IkJtI3ZYPom3Zc9Hl3yRFLNn0TKRslN3LmJxCtY+/DBm69M+yVONARQFBMRNh3l8byKoZseX6ZOxbmgplaW75j2/SF8CAAUpeV66ivv7HWM/NkctfLTf4935gR4x+lElsET+JhITEzL0jpK6pPqogt2ZfvMghf+YpdzAR8+aB8GtiRhPtsDOvjyLrj7UnL6lY/hTHgaN4IfhJgD21rtYcRxiLRMBucgWZA2Yk2c2Llr7i8oVji+HoSlxmgk8D1eIrenRDaVYqW8fkB5oyeAGf6pJ3IWpwfdZd/Tpq98ClIZQBwSxg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=redhat.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=qpxkTbpsmel7PNy9hFdoS5mAlgzObBowHU7VZLZDO1k=; b=N57rapskgyruY5CF4QDilAMXEVWicbUn7IOKYQxNYaY0VRCcXNfJ98mXhSKJjdspgM0ZeSIo3mZV38VH3X5NmJKUiSdbvY80BwlkqI6rYZpcNzP/qm9y7x+efNqZU00uOxxQcolJGSxETnTJpM5yYc3DkL46kMWI9y6YR5AcCyo= Received: from BLAPR03CA0074.namprd03.prod.outlook.com (2603:10b6:208:329::19) by MW4PR12MB7192.namprd12.prod.outlook.com (2603:10b6:303:22a::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.25; Mon, 28 Oct 2024 02:02:07 +0000 Received: from BL02EPF00021F69.namprd02.prod.outlook.com (2603:10b6:208:329:cafe::7f) by BLAPR03CA0074.outlook.office365.com (2603:10b6:208:329::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.23 via Frontend Transport; Mon, 28 Oct 2024 02:02:07 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by BL02EPF00021F69.mail.protection.outlook.com (10.167.249.5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8114.16 via Frontend Transport; Mon, 28 Oct 2024 02:02:07 +0000 Received: from AUS-P9-MLIMONCI.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Sun, 27 Oct 2024 21:02:01 -0500 From: Mario Limonciello To: Hans de Goede , =?utf-8?q?Ilpo_J=C3=A4rvinen?= CC: "Rafael J . Wysocki" , Len Brown , Maximilian Luz , Lee Chun-Yi , "Shyam Sundar S K" , Corentin Chary , "Luke D . Jones" , Ike Panhc , Henrique de Moraes Holschuh , "Alexis Belmonte" , =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= , Ai Chao , Gergo Koteles , open list , "open list:ACPI" , "open list:MICROSOFT SURFACE PLATFORM PROFILE DRIVER" , "open list:THINKPAD ACPI EXTRAS DRIVER" , Mark Pearson , Matthew Schwartz , Mario Limonciello Subject: [PATCH v2 04/15] ACPI: platform_profile: Add a list to platform profile handler Date: Sun, 27 Oct 2024 21:01:20 -0500 Message-ID: <20241028020131.8031-5-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241028020131.8031-1-mario.limonciello@amd.com> References: <20241028020131.8031-1-mario.limonciello@amd.com> Precedence: bulk X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL02EPF00021F69:EE_|MW4PR12MB7192:EE_ X-MS-Office365-Filtering-Correlation-Id: a83fc542-e641-46ae-0cc5-08dcf6f486e3 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|376014|7416014|82310400026|1800799024|36860700013; X-Microsoft-Antispam-Message-Info: ybfkYNvnljLWX07BoGsajzBMrNX1f62noKmr5lXaABbghGytqoZqTFBcoQVZVoHwbDh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+rrKJN9QcGDKrkypiYdG7l561yP+vU0Sajcfo5UOiBMgayzlGfDznfKD/m2XA4+hT0Rrz0DCiMWK+AjHUKjN2WYXLlVydekNfaNSs04EODZ0zppfcIMs/vy4ERfe0OqkCOeKoaKZlLBvy9jklzndnr/aurCmvmjQO5CtUafnsOc4kDC8w655Bj325nPrkn1bj8XN+yADQ9OLG7Xmy4uDHJoOvmkFn6ejTz1qkGvn8BHu2GzuxA43/lTQHmG0FkBaD/AjaVhRpcWVMm//peJEwbJHwvkhM+w== X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230040)(376014)(7416014)(82310400026)(1800799024)(36860700013); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Oct 2024 02:02:07.4622 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a83fc542-e641-46ae-0cc5-08dcf6f486e3 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d; Ip=[165.204.84.17]; Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BL02EPF00021F69.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW4PR12MB7192 In order to prepare for having support for multiple platform handlers a list will be needed to iterate over them for various platform profile handler calls. Tested-by: Matthew Schwartz Reviewed-by: Hans de Goede Signed-off-by: Mario Limonciello --- drivers/acpi/platform_profile.c | 5 ++++- include/linux/platform_profile.h | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profile.c index c24744da20916..0c60fc970b6e8 100644 --- a/drivers/acpi/platform_profile.c +++ b/drivers/acpi/platform_profile.c @@ -10,6 +10,7 @@ #include static struct platform_profile_handler *cur_profile; +static LIST_HEAD(platform_profile_handler_list); static DEFINE_MUTEX(profile_lock); static const char * const profile_names[] = { @@ -198,6 +199,7 @@ int platform_profile_register(struct platform_profile_handler *pprof) mutex_unlock(&profile_lock); return err; } + list_add_tail(&pprof->list, &platform_profile_handler_list); cur_profile = pprof; mutex_unlock(&profile_lock); @@ -207,8 +209,9 @@ EXPORT_SYMBOL_GPL(platform_profile_register); int platform_profile_remove(struct platform_profile_handler *pprof) { - sysfs_remove_group(acpi_kobj, &platform_profile_group); + list_del(&pprof->list); + sysfs_remove_group(acpi_kobj, &platform_profile_group); mutex_lock(&profile_lock); cur_profile = NULL; mutex_unlock(&profile_lock); diff --git a/include/linux/platform_profile.h b/include/linux/platform_profile.h index 58279b76d740e..9ded63a9ae6f1 100644 --- a/include/linux/platform_profile.h +++ b/include/linux/platform_profile.h @@ -29,6 +29,7 @@ enum platform_profile_option { struct platform_profile_handler { const char *name; unsigned long choices[BITS_TO_LONGS(PLATFORM_PROFILE_LAST)]; + struct list_head list; int (*profile_get)(struct platform_profile_handler *pprof, enum platform_profile_option *profile); int (*profile_set)(struct platform_profile_handler *pprof, From patchwork Mon Oct 28 02:01:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 839136 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2055.outbound.protection.outlook.com [40.107.244.55]) (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 2A2CF17BEAD; Mon, 28 Oct 2024 02:02:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.244.55 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730080940; cv=fail; b=A5GgbD1m5FCe0/2mthCojb6/sv2zbqFzz6UsAn8DKywXjQWGgmIGMGwjo0bfs7L8skNdXflc8zWtQOmSd5LqwOhj52hpFYO7Ev/m1xVMMhGDOitP367cLce7xjcSKObA1gFB33ACdTEr2HFeTWhLn2YukZumQt4T51Gb7ddvHqc= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730080940; c=relaxed/simple; bh=ZU6BROkzA7zNj0KMLGX5e4LqRYTYQfMk4VlEv6kwjzQ=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=MFTDgX0+wczk7T6thXc5cE+43GdR5PcauNPLesmqsf2DbqbnWY4FfU15zFSQCnBqfMq6EUwiNoZlBJG3CaJw98wJF5UI0ks+3c+rMUUrN/mbcobMxC7qvOEhAJNCuIasVZl5L6kLWngydz9A3czEA8oWmsugrP+3RpbEGqntzBI= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=xl2vboDX; arc=fail smtp.client-ip=40.107.244.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="xl2vboDX" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=s4Lsw7zr9Am7eZ3LypcM9dO4uyg1ibBHjSbEfq8Rw+VWZW/yeFOjaDXk02/yh21AX7dTrJCnmNjKuFHs4Lzy7+iIjrTRIbwJ8pVLbdO2CEyRgumm3z8D2RudUmJVJKje2X75Z10pEWfET3lfREuutM1yJ7C54R1TvPDfwnGox0PTNw12QOv15bgAaALWmoQ02YOrPDLuCychmbT6zfZ8rdFJEpSRwaDl/C+6rCK3hTRvEL4L9TXEd8GkJJh4SOXnXG+2mjhlW0giJMOV+D4+wzqzNfT/KKx06OBMhQPJovI0C3riTbZg/6eRhPRiJXZKGD2mVtdEUIGzxI778TSSzg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=oupYGz8RlTP+v31HqWoK+xtYXtdkCJXiniT1MB2+KEs=; b=SxDzuGOQnRihzcOxtohDiTYZ3pJPKFNVaQupd4s45Tdzy2zxHeDNGKux/ebOx3caqDgmrLYoHA5LH6hUMEWDyMnMQv0npomDcAqh/kAUdeohjStuhQTg8A7/PWzhLRq8UnYUN3dZXS2N8TFQB5P+03KGyPRoLoKOk4N8gEXetUeVgunse3Reit36+VMNaQb/0ryTh6m+epxgkSpodyEw/F8qjhyIuu8CnHnXtlvi/mYgIriuolD8YP91wIXFEmn/OrjeqjEqtkfB8S6Jp9fikaqQcq8sr4NgC//KEnjdXxNryzZWXW3i0eV2z7OA9yydrzNphfRYtSB4RAPnsSyBrw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=redhat.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=oupYGz8RlTP+v31HqWoK+xtYXtdkCJXiniT1MB2+KEs=; b=xl2vboDXN4+ADxMGgVO4koAZqzg+WfuxNUY7hggsRTPE7Q+XnKOc4dSmVgFh7EuQgC5TO+nblM7kKbUus0+s/amxls852f0Ndom7C8ZUH5BvKsBAyBk1++NZuZC3Zbs+/vo1ZuWVCA9cUUeUzXOjtAB/hFUHlbwthoGN6rt1c6k= Received: from BLAPR03CA0084.namprd03.prod.outlook.com (2603:10b6:208:329::29) by SA1PR12MB8724.namprd12.prod.outlook.com (2603:10b6:806:38b::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.20; Mon, 28 Oct 2024 02:02:14 +0000 Received: from BL02EPF00021F69.namprd02.prod.outlook.com (2603:10b6:208:329:cafe::6a) by BLAPR03CA0084.outlook.office365.com (2603:10b6:208:329::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.23 via Frontend Transport; Mon, 28 Oct 2024 02:02:14 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by BL02EPF00021F69.mail.protection.outlook.com (10.167.249.5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8114.16 via Frontend Transport; Mon, 28 Oct 2024 02:02:13 +0000 Received: from AUS-P9-MLIMONCI.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Sun, 27 Oct 2024 21:02:08 -0500 From: Mario Limonciello To: Hans de Goede , =?utf-8?q?Ilpo_J=C3=A4rvinen?= CC: "Rafael J . Wysocki" , Len Brown , Maximilian Luz , Lee Chun-Yi , "Shyam Sundar S K" , Corentin Chary , "Luke D . Jones" , Ike Panhc , Henrique de Moraes Holschuh , "Alexis Belmonte" , =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= , Ai Chao , Gergo Koteles , open list , "open list:ACPI" , "open list:MICROSOFT SURFACE PLATFORM PROFILE DRIVER" , "open list:THINKPAD ACPI EXTRAS DRIVER" , Mark Pearson , Matthew Schwartz , Mario Limonciello Subject: [PATCH v2 07/15] ACPI: platform_profile: Only remove group when no more handler registered Date: Sun, 27 Oct 2024 21:01:23 -0500 Message-ID: <20241028020131.8031-8-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241028020131.8031-1-mario.limonciello@amd.com> References: <20241028020131.8031-1-mario.limonciello@amd.com> Precedence: bulk X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL02EPF00021F69:EE_|SA1PR12MB8724:EE_ X-MS-Office365-Filtering-Correlation-Id: c176e1da-4c67-4e16-41ac-08dcf6f48ac5 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|1800799024|36860700013|376014|7416014|82310400026; X-Microsoft-Antispam-Message-Info: 3aC2GAVC/pyVbVORenrMU6p0+go0orczLiVSngAVrvDrMAejzThWiWMZvNTGGTkyaCCghVQP3m8szQJmnREZ41d8gpnQZn3494FbhQlVDEawBCZ8CpSOcZDhdnDTlqtxrglLlhE1CUx0WyGdrRtopX3QfLsp/wfovEjkawUAl86sMPBmXTQhNfvfCEmwFS4cpAyYb2UKvL9hZ6FTCRqrdm0iezNwQHTwSLy40XBmh/L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WtFbX3UjIF2gOx3NXNVUf4GYP8WLF4chqlc5Ynvj3VFPsXQzFNcda0Dh+RL2zLaBjDCBDZL+K28eOsTxEmguWEos6z094wA4pzGZw== X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230040)(1800799024)(36860700013)(376014)(7416014)(82310400026); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Oct 2024 02:02:13.9623 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c176e1da-4c67-4e16-41ac-08dcf6f48ac5 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d; Ip=[165.204.84.17]; Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BL02EPF00021F69.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR12MB8724 As multiple handlers may register for ACPI platform profile handler, only remove the sysfs group when the last one unregisters. Tested-by: Matthew Schwartz Reviewed-by: Hans de Goede Signed-off-by: Mario Limonciello --- drivers/acpi/platform_profile.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profile.c index 100d6ffb10cdb..ede1550170f1a 100644 --- a/drivers/acpi/platform_profile.c +++ b/drivers/acpi/platform_profile.c @@ -23,6 +23,16 @@ static const char * const profile_names[] = { }; static_assert(ARRAY_SIZE(profile_names) == PLATFORM_PROFILE_LAST); +static bool platform_profile_is_registered(void) +{ + struct list_head *pos; + int count = 0; + + list_for_each(pos, &platform_profile_handler_list) + count++; + return count > 0; +} + static ssize_t platform_profile_choices_show(struct device *dev, struct device_attribute *attr, char *buf) @@ -207,8 +217,10 @@ int platform_profile_remove(struct platform_profile_handler *pprof) list_del(&pprof->list); - sysfs_remove_group(acpi_kobj, &platform_profile_group); cur_profile = NULL; + if (!platform_profile_is_registered()) + sysfs_remove_group(acpi_kobj, &platform_profile_group); + return 0; } EXPORT_SYMBOL_GPL(platform_profile_remove); From patchwork Mon Oct 28 02:01:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 839135 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2054.outbound.protection.outlook.com [40.107.93.54]) (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 05F7617C7B6; Mon, 28 Oct 2024 02:02:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.93.54 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730080942; cv=fail; b=q+VgNHS3X2+W4vJ407tPuILf4McuqxmpZiJAiQyoPztxXG2FmRW75FHWmFxjZva6E+y3TmI1/VGISiZueq9s8L2p/V/qc/mVaKvz+fFy9TBs5RmJUUJoRY8lIIl2Nmdvr7A/A9mcukSqzHPGY0z29QqvTeLXt+ziHoxXozGIOjM= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730080942; c=relaxed/simple; bh=peMEyDjMFmdHm7H88Ur6wcOkl8YlUwv14hgn+PXRF+I=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=DbUzl2/qYBUIsdpj8YXQUshyPEZVktui26Z3VagJYhlilzmMHmwkwjyo5ZT1O8olY37hNFPdCNJpp0Cn2CAmJjCzy8CcIid9+Kdh54MGbuaAFSsscQ3LhBd8noyHalZ+rlXw+FC92GP9Di7Zr4OY0RSMqEJO1DKDBn67DP3CUvA= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=cIG/tNxY; arc=fail smtp.client-ip=40.107.93.54 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="cIG/tNxY" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Um30/a44E8a+qEzDMsM5sFp4mANDSUmMMK8GTpohJVh1kWwJJc3+A9ouUhqxwqRtiZfKGYdPVrBrovw3NSp27NjonkjuTzJXtS3YgwaNhLbEzFmTI7pOkqtBTdsvO3A4iLn2ETedOaS8Ejiob/FNU4l4fFYk1jL3nLA0MhVokeUA1sZHsLlFRiVQLw8uSlVuVK9VQh2XwcDWF7hHkphovDXeCd2lR4veq/o7OdMSy8ZDKTJjYb9Y0/UT94FqPnhrwNqXsN4T5IH4XEDsVfuFfdnwMmNJ/BTY+dSM+gKYUCdjtTxi6QF7UTV2RuKobuie2e3ln9iC+bhRjAlWoNrs/Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=eBZo9vCmFYLeayd4nVsafVPbyl/X4puzMIYHQcMpcF8=; b=dz0990ndHGSVAtUv+9wcQ0s7rtt/A7sPW7tRhP7Ql+hHDbqTdV4ix48tCdvWJSLFEVwUOHqVtUBehVX1g+uH8eV2gd5Mknbnu9VCfJZw9IVri3p0SJwzAMgbEQGI0oNLDktbhkJ0JodA9zOaxf/k3zUXarrH+8Xmtuv3qjKjxm8wGvZFykOzVTkBLbLtDk/kegDyF3xTEXiWTwclzBYTaFypVvtnROYbsZ/dM/7S+o+Urfr4InwGppplD68Cdbsck7Tc/a7Bp3qr2KSdm8LnJAxJKlEvOJ4DG6UzosLV3uk5hoSKKkHYmFlCZubsFNLao1Q3DY9AXxBxmTkyiFPaBA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=redhat.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=eBZo9vCmFYLeayd4nVsafVPbyl/X4puzMIYHQcMpcF8=; b=cIG/tNxYn05Bb/Toiu0oA2KxY4/lm7ITP5Hcinpo9NhwjbJHFuq2Mo+8vCnsUP31fuh89Mo+cpgCGukSawfQ/QWh9WmtdV7LiL+/rOhHlsgSrIYHA8bLWhvrBI6WU6GdqIWiAC845z1Sqn291zWKQw+GDG+Vk5A576BCXg+GGEc= Received: from BLAPR03CA0064.namprd03.prod.outlook.com (2603:10b6:208:329::9) by IA1PR12MB6089.namprd12.prod.outlook.com (2603:10b6:208:3ef::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.24; Mon, 28 Oct 2024 02:02:16 +0000 Received: from BL02EPF00021F69.namprd02.prod.outlook.com (2603:10b6:208:329:cafe::b3) by BLAPR03CA0064.outlook.office365.com (2603:10b6:208:329::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.25 via Frontend Transport; Mon, 28 Oct 2024 02:02:16 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by BL02EPF00021F69.mail.protection.outlook.com (10.167.249.5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8114.16 via Frontend Transport; Mon, 28 Oct 2024 02:02:16 +0000 Received: from AUS-P9-MLIMONCI.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Sun, 27 Oct 2024 21:02:12 -0500 From: Mario Limonciello To: Hans de Goede , =?utf-8?q?Ilpo_J=C3=A4rvinen?= CC: "Rafael J . Wysocki" , Len Brown , Maximilian Luz , Lee Chun-Yi , "Shyam Sundar S K" , Corentin Chary , "Luke D . Jones" , Ike Panhc , Henrique de Moraes Holschuh , "Alexis Belmonte" , =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= , Ai Chao , Gergo Koteles , open list , "open list:ACPI" , "open list:MICROSOFT SURFACE PLATFORM PROFILE DRIVER" , "open list:THINKPAD ACPI EXTRAS DRIVER" , Mark Pearson , Matthew Schwartz , Mario Limonciello Subject: [PATCH v2 09/15] ACPI: platform_profile: Notify change events on register and unregister Date: Sun, 27 Oct 2024 21:01:25 -0500 Message-ID: <20241028020131.8031-10-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241028020131.8031-1-mario.limonciello@amd.com> References: <20241028020131.8031-1-mario.limonciello@amd.com> Precedence: bulk X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL02EPF00021F69:EE_|IA1PR12MB6089:EE_ X-MS-Office365-Filtering-Correlation-Id: 945d3c06-6038-44ad-692b-08dcf6f48c72 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|1800799024|82310400026|36860700013|376014|7416014; X-Microsoft-Antispam-Message-Info: hzxKUqIOZUWoUYrEAabpfbatVCYBKg4zghGAtqqUjoc/n1hd815XZx/YqhY8FOPW9Q3qNtjiBFBJOa/vTj/UpJ7aUbhRplRxxYN212CL51ZHWKiwfG6jQOOXmCL3hULDSHCxgJnRyWcIb+bgRZU30T2NfnlrGWYIKG5yf/PxKfptsaXoedbs84gQI7LPnSDn2bMmU5RiAU6fYOoMhCyWyALlMnNfd//720DxmYN70rMYZuXBxfKXocqmesdDepYJzGFNAfEHbZ3IktT5sqxFc0SZp7IopvKdy3FMpo486/NNVCaIdnG1AulZ2XHzJ1Zoth/iz1DJmJGQdmRxmwrOcxV1EFxIPJ4lDwEFs0FQXu4MDzGCYG5o2gKAOSjQZd3pvPph/mI9fV9CKLqqN2iDd4cR8nVWvqDLkCKQ/1M2hBad9qZSeUmJAhRSmv66+hulgvzvJ7OcMAQ/+3b1y/jYEqKn9hbZLCoSX2DbQljg1LKHTqWwUuaSrKr1lK54ZHcAdNy73hzoa6z12/U2jEh0f8E4xrHoTtoaQt8QcpNcE6Zk1eYsqpe+b4jHqxEIWzwCjTtG2s4Xaq0KAiRSLlfonQTzY/PV+xhJULRVGJKYBQneAaFS938T36q3I/61O+eAvmCJIX+VKKq0LcXoRGm9KXqj+iJ7spVlhyRso/+JW99pDOJAHZD2P5v8sK6J7+sCt5uWC5He66LcyMTO7E1gataWiv9X4Mj9LkumWxbHuUJYGEVgPjH4hPFu+kqp7tuVn/sad/JDQmzwpGWF8wMGnpZaQQs1uFIcCHfOHq9WruD3DnO/zs6GBbvnHr2xU2uI7HP03/KB+FtDHI3g9Ou1+kr5uww9RZ/JmGYqe/2DxnCpji/VSDZfA0R8zlX9bnLAnJP22fw54zpYtJ1+M1Zod8AY40VcsUCfEp57Qx2d7qiqPZ5W9L/LT3Utxoj2dYdCgCJw8dLyN64MTlDewciWg3Dz8rhQGllysSVG1uCCoW8IZHMZN3b2qIzUeN4vHjGm5FRvODBtZ5E9rTRY+qCE2bqYqthfKEkJu4N97UKEEjx9m9q2yaaojU6S+8N8gsm8E+ZoBohZXrqpguu6UHSoDMiGwWtIhm0WJ6xXoo12huvFTEgejerNiqM7rMNj0EK74XFe/LlkMwLdCHoli/RH5skEmc4N+lDigULZJvAHqaNMOgOyE+XkmQj452EawcdShm68K62GWfv+6uke8Hh+yP448Q9/4U7ZuTuBFAFxbvwljhX8W3SChxh8GdeQyLbFZ6PaaaVkDjvRFALrebyw2m6sjWr6xsPveWwDhTypRM8LHBt2P/CTT+koOQgKMIpqPJYcAuosdEdgAkOPrTd5rfOAI6aYPcuLk8QX/27aKRgGVxRFtqedLBPrrF6q2kvJMFcmxYL9bWw8Nm+sre0mjQ== X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230040)(1800799024)(82310400026)(36860700013)(376014)(7416014); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Oct 2024 02:02:16.7747 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 945d3c06-6038-44ad-692b-08dcf6f48c72 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d; Ip=[165.204.84.17]; Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BL02EPF00021F69.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR12MB6089 As multiple platform profile handlers may come and go, send a notification to userspace each time that a platform profile handler is registered or unregistered. Tested-by: Matthew Schwartz Signed-off-by: Mario Limonciello --- drivers/acpi/platform_profile.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profile.c index c0d0775831214..5fee467614eac 100644 --- a/drivers/acpi/platform_profile.c +++ b/drivers/acpi/platform_profile.c @@ -210,6 +210,7 @@ int platform_profile_register(struct platform_profile_handler *pprof) if (err) return err; list_add_tail(&pprof->list, &platform_profile_handler_list); + sysfs_notify(acpi_kobj, NULL, "platform_profile"); cur_profile = pprof; return 0; @@ -223,6 +224,8 @@ int platform_profile_remove(struct platform_profile_handler *pprof) list_del(&pprof->list); cur_profile = NULL; + + sysfs_notify(acpi_kobj, NULL, "platform_profile"); if (!platform_profile_is_registered()) sysfs_remove_group(acpi_kobj, &platform_profile_group); From patchwork Mon Oct 28 02:01:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 839134 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2057.outbound.protection.outlook.com [40.107.237.57]) (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 8009E18B475; Mon, 28 Oct 2024 02:02:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.237.57 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730080943; cv=fail; b=V7Wx2GNe3CAFLuJkizO5zlpQlktJnmin7TpFD1qf5MtTUftTL9Nr3EK9UKBV6AEGkRbijMOGueQODAhHkWb5qUDAGY2oVXkfr6ddLEuTIKMZ02FRlZ6L0QvF7FRQGj4DD2L8ttmcIVJPqQhRkxQXfl5ro7KNsff66RocWYgjrt0= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730080943; c=relaxed/simple; bh=2QWvixAlAOe4y3rfwVCRHvrO11PnTziEQIsgrr0+79o=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=jdPDEWid8vJQhskP5nD6HFj2gAnaE2S+nddYSD0gVk0PS5NnWzFxjnn6LiscqR9DsrdWQfzFW0KX8kOjKUMqNzjhkEK1iHdz17kK/OtwqFBFqR0WpN230ja95P4qJymzRyDC+s9rQgPRMFtn/Xt4XiOW/vovfVVAjphhheBm2MI= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=x2L9dHY4; arc=fail smtp.client-ip=40.107.237.57 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="x2L9dHY4" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=pMH61BkrcHXJKGnsJ6WqkunhqbEXDo5EM9Q3+ziAOvpwJshEislzEoi0kO0Y1DXFj3JfDZpXcnWEt5wWZzY8iL9+BLMkiot4FDwpekQm7rdzVQRX2fUpvAesUp4El0TUYke32cw6DbEd0rf12or8LjlHRaYG/A2a99WsFjyK7oCJDf50FE2tJ+hCsfGXn8+6Xqb5ANo3qkAlXsDHSVkMWuLoLyNLz6pbjt612npSKygl/25WMbu4H8pVS79ymp14TXcnI61QyFCXyd/r0Hh+wng08e0UVStrqOHHQBGVZTiBD72j9P3q3T9dOmTSm25OlFvnGlGwJh9fB1QeMNL+wA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=S2vb0lbHs0eiBbQV/g463nhHMqsys4ERBQOYpqJcx6A=; b=LB3y4W2Gli3vbCR9FLYxH3y93DtZ8GHKGLy7sEEZ3L5rkWoz+l+UCkZclwFUldBC+0Rf62tcvwJPG1CRKsCtpLbcfuzeeKQDw05ghKnQDmr6kM4wYM1PJIH4lbZsnsJLOtU1gu2BCM9/G4SsfI6BaX2ghjkvqy2gw7k/yEex+hWLH4p/pHIW7eDNI8lOHlXkyiFugkEKXCz9jqgh/onVzl+H9vgCdzbUo4JLpGW9vy5rSgSI3hZm24e+pplDMunGgb+4BJhNH4dhinoYSHH/I5cerV+oDdzZJxwRnS4m0zwx8EMAbqpyuaGnTRcyWv6moE48fk65OeZyJo3giDRGqQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=redhat.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=S2vb0lbHs0eiBbQV/g463nhHMqsys4ERBQOYpqJcx6A=; b=x2L9dHY474nUjfD2p9u2kriB2MSOAopMiJvMxTFubuXrv85wlHD5LAsXlsLgf2h3thxKORf3lHiXld2TdY2H5Bt5Zzl4m5sPNDy98tzioqolhhyLj+k4sDx0sL1KR86+LEpm/sJtmeA2bwPnn5rO0KSigaFdNSLMqH3V+P5WfyQ= Received: from BLAPR03CA0068.namprd03.prod.outlook.com (2603:10b6:208:329::13) by PH0PR12MB5632.namprd12.prod.outlook.com (2603:10b6:510:14c::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.18; Mon, 28 Oct 2024 02:02:17 +0000 Received: from BL02EPF00021F69.namprd02.prod.outlook.com (2603:10b6:208:329:cafe::e2) by BLAPR03CA0068.outlook.office365.com (2603:10b6:208:329::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.25 via Frontend Transport; Mon, 28 Oct 2024 02:02:17 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by BL02EPF00021F69.mail.protection.outlook.com (10.167.249.5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8114.16 via Frontend Transport; Mon, 28 Oct 2024 02:02:17 +0000 Received: from AUS-P9-MLIMONCI.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Sun, 27 Oct 2024 21:02:15 -0500 From: Mario Limonciello To: Hans de Goede , =?utf-8?q?Ilpo_J=C3=A4rvinen?= CC: "Rafael J . Wysocki" , Len Brown , Maximilian Luz , Lee Chun-Yi , "Shyam Sundar S K" , Corentin Chary , "Luke D . Jones" , Ike Panhc , Henrique de Moraes Holschuh , "Alexis Belmonte" , =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= , Ai Chao , Gergo Koteles , open list , "open list:ACPI" , "open list:MICROSOFT SURFACE PLATFORM PROFILE DRIVER" , "open list:THINKPAD ACPI EXTRAS DRIVER" , Mark Pearson , Matthew Schwartz , Mario Limonciello Subject: [PATCH v2 10/15] ACPI: platform_profile: Only show profiles common for all handlers Date: Sun, 27 Oct 2024 21:01:26 -0500 Message-ID: <20241028020131.8031-11-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241028020131.8031-1-mario.limonciello@amd.com> References: <20241028020131.8031-1-mario.limonciello@amd.com> Precedence: bulk X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL02EPF00021F69:EE_|PH0PR12MB5632:EE_ X-MS-Office365-Filtering-Correlation-Id: c6dddaea-2375-47be-a19a-08dcf6f48cab X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|1800799024|376014|7416014|82310400026|36860700013; X-Microsoft-Antispam-Message-Info: ZOzBeZQpnBBvI2tAY8HRbAKRRg0PzC4HJMKnengqtezIkAVKGJz2erJaba6EiyctYpHCvhunKurxE+i+JHb1WYF3YvPwpTD89TcoCnTn018XxM1gPArYjXhGs7bVqYExK/OSbAUQzW2kotGs6z9Txi3xhpkFlLGMhWUmu/DWuxzqvSU+IjM7oUwjmCijLmBnB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VWYmVkl9R1YdE+RBAGSSnzSRsdi063lK6QrtGcsUr1OVtp2t4PKUWr70woWgkSpscaw/DsCOtvzMAEVNqjOQn7+PMLJAm/VAtWxhuY0XvZz6yoOwaWAVOpZ50tgfMTLQJZxjhAc6tG0bqfybGwyf22rQOpgT384MTW9g== X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230040)(1800799024)(376014)(7416014)(82310400026)(36860700013); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Oct 2024 02:02:17.1654 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c6dddaea-2375-47be-a19a-08dcf6f48cab X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d; Ip=[165.204.84.17]; Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BL02EPF00021F69.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR12MB5632 If multiple platform profile handlers have been registered, don't allow switching to profiles unique to only one handler. Tested-by: Matthew Schwartz Signed-off-by: Mario Limonciello --- drivers/acpi/platform_profile.c | 35 ++++++++++++++++++++++----------- 1 file changed, 24 insertions(+), 11 deletions(-) diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profile.c index 5fee467614eac..a83842f05022b 100644 --- a/drivers/acpi/platform_profile.c +++ b/drivers/acpi/platform_profile.c @@ -33,30 +33,43 @@ static bool platform_profile_is_registered(void) return count > 0; } +/* expected to be called under mutex */ +static unsigned long platform_profile_get_choices(void) +{ + struct platform_profile_handler *handler; + unsigned long seen = 0; + int i; + + list_for_each_entry(handler, &platform_profile_handler_list, list) { + for_each_set_bit(i, handler->choices, PLATFORM_PROFILE_LAST) { + if (seen & BIT(i)) + continue; + seen |= BIT(i); + } + } + + return seen; +} + static ssize_t platform_profile_choices_show(struct device *dev, struct device_attribute *attr, char *buf) { + unsigned long choices; int len = 0; - int err, i; - - err = mutex_lock_interruptible(&profile_lock); - if (err) - return err; + int i; - if (!cur_profile) { - mutex_unlock(&profile_lock); - return -ENODEV; - } + scoped_cond_guard(mutex_intr, return -ERESTARTSYS, &profile_lock) + choices = platform_profile_get_choices(); - for_each_set_bit(i, cur_profile->choices, PLATFORM_PROFILE_LAST) { + for_each_set_bit(i, &choices, PLATFORM_PROFILE_LAST) { if (len == 0) len += sysfs_emit_at(buf, len, "%s", profile_names[i]); else len += sysfs_emit_at(buf, len, " %s", profile_names[i]); } + len += sysfs_emit_at(buf, len, "\n"); - mutex_unlock(&profile_lock); return len; } From patchwork Mon Oct 28 02:01:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 839133 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2044.outbound.protection.outlook.com [40.107.94.44]) (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 E80AC18E751; Mon, 28 Oct 2024 02:02:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.94.44 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730080950; cv=fail; b=X0+kLxNu8Ag3VIZUyPK0yy7pcW6EgbSa0uk9PlunTKJj7fn7208vBdPy0culK7JyuEr+ThsJ7NYp7FqnhKQcIKTIkEo/uMIapUSYJUHIyjgHPAJVwQ7xn0jaa/5IjgQowS+I+FwHDBof3ulf0Tvs8JeJGxMH9Ic9bKJBgomYuRk= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730080950; c=relaxed/simple; bh=hRMdJxh2U6nRN/XXacx1ArC9M1AvzMSxjV3SY+R5fm4=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=G1XOyE0e8/ugMKM6Q0yLCVoJwyuuMiUJIOQn4g2gWX2Hwq5xstxT07WVMDGkxxXMuGP7DZTXwtpRPYgePI2nFtZNgWdFUqsClX2fqSqI5FNsd6R7CgHOj1Z3z/jVq4wSfF98HBkvMJgj2Zn+rz/DxIg16vyqYIlbWqXXHto349k= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=sVZDXmI1; arc=fail smtp.client-ip=40.107.94.44 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="sVZDXmI1" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=O9k4fXoXVmobvHM9hPuMS3lKINN1n5KEOfCNLDD3IwWpN7kLIzeGgOI+mLMo/iOfoNlTuaBQ0i2BIUDv4CDz2lBWLnCxv78cwlHe//RsMTDam+ZeaCRo5qA0IvLa6g7AVaQLUcO7AJUQkCXaD4WlxWxRnJAo8lWzwjE+K6WcmUsiccgtUhDQ2IvyWJvtd5exycDMw0u/Cpd0L6jTaL3geO8HxTJT82+7oVDCYQXPd5TcFNUZZjt045tEA/qHivIhQfiOBI7bQ/tvT+oDayTBz+6CeQdCvSAWVjd32v2EnHMCgsa0UuF+/GnCoERnO/LZ6J1vsJc89f1cj1FMS0o4xw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=jA7mkXOyFAEZsu6LCLTcVYR3EdIJJE8Ibol0D0QosHs=; b=USR5t8BpYdXg2h9ZKb7flDB8INMPoWE7xd1JW06sLipr+q3Uh58OZPpJN9abvZg1W6az4phgQkopfw8l0lkAQlO1HYDh/R5hDlQQNuAsEaBAkwwWWvIdCwFS/Cp7wrKvOdX0fModuLGLBwXTiylsbc07p6Z4XSyXyb7+O00P5F7QGWrY0EiSiF8Sy0GWopmKnLSmi4O0hy8pSD51wwM73QlTDTKHhh7BbnG0JFEcm0j4TzMl7nipi4Q8I8dBAOTCbeVatUquTed89XJZmtcIj+n4HY7eVajgregFkgmTIfNYp7noW/sGBk5qItBHzllG7ZWU1P6exOaNu6BWbHX6wA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=redhat.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=jA7mkXOyFAEZsu6LCLTcVYR3EdIJJE8Ibol0D0QosHs=; b=sVZDXmI1Mz05dywID0eJ1KELna0nbToz5HeVRx0Mu6T43q1dgc4+uCUDg3daL+T7HrD4OVCR0Iw2UOHrf0Vmzq3DPCUJlUBDo8DZ75sRvS9LSXGAkqpaHuy2kY6KDzR1K4fmJ0Nsatj3VN8tOcq8SbXzyWjoBmNgs0otPwaCDsk= Received: from BN9PR03CA0908.namprd03.prod.outlook.com (2603:10b6:408:107::13) by CH3PR12MB7690.namprd12.prod.outlook.com (2603:10b6:610:14e::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.24; Mon, 28 Oct 2024 02:02:22 +0000 Received: from BL02EPF00021F69.namprd02.prod.outlook.com (2603:10b6:408:107:cafe::73) by BN9PR03CA0908.outlook.office365.com (2603:10b6:408:107::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.22 via Frontend Transport; Mon, 28 Oct 2024 02:02:22 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by BL02EPF00021F69.mail.protection.outlook.com (10.167.249.5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8114.16 via Frontend Transport; Mon, 28 Oct 2024 02:02:22 +0000 Received: from AUS-P9-MLIMONCI.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Sun, 27 Oct 2024 21:02:16 -0500 From: Mario Limonciello To: Hans de Goede , =?utf-8?q?Ilpo_J=C3=A4rvinen?= CC: "Rafael J . Wysocki" , Len Brown , Maximilian Luz , Lee Chun-Yi , "Shyam Sundar S K" , Corentin Chary , "Luke D . Jones" , Ike Panhc , Henrique de Moraes Holschuh , "Alexis Belmonte" , =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= , Ai Chao , Gergo Koteles , open list , "open list:ACPI" , "open list:MICROSOFT SURFACE PLATFORM PROFILE DRIVER" , "open list:THINKPAD ACPI EXTRAS DRIVER" , Mark Pearson , Matthew Schwartz , Mario Limonciello Subject: [PATCH v2 11/15] ACPI: platform_profile: Set profile for all registered handlers Date: Sun, 27 Oct 2024 21:01:27 -0500 Message-ID: <20241028020131.8031-12-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241028020131.8031-1-mario.limonciello@amd.com> References: <20241028020131.8031-1-mario.limonciello@amd.com> Precedence: bulk X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL02EPF00021F69:EE_|CH3PR12MB7690:EE_ X-MS-Office365-Filtering-Correlation-Id: d4632f72-84fa-4983-55ce-08dcf6f48fca X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|1800799024|7416014|376014|36860700013|82310400026; X-Microsoft-Antispam-Message-Info: xH4HIPyIbHfiB1ZP0KqL7v9V8I19eEuT6UAZIxabX3Gi28bpdy4eseAKWc+d0nl9FqCoK4vQrNKe0zOIdRRsdxpZLzAR371Fy8CqFHDJtpt7pxZBHtpWpq23V5H1fCMHpRQyzjiMqxyofX7mTAgddmBxUhD3GD0NQ+uymIvVNSSbiRVBD/9uXmUIM1S1pQpCacaVAxDDC9j8rnGJLin0E/M/eeIYchpBnk14n4V81zrgsVwHM/thy+EYlZOh7wGR+kyum99lLSE09EnfwhnW6OwUtqLW0so9HVn+PSPPGrDyLq47O+gQIt6yj8dMUmyd4rgZY+WfhEy2aASFNYMDBy8XPx5+xQBUp0q7WSBocI55N18Rr9I4AnO6vSL8kOvsho1b9URw/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IP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230040)(1800799024)(7416014)(376014)(36860700013)(82310400026); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Oct 2024 02:02:22.3998 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: d4632f72-84fa-4983-55ce-08dcf6f48fca X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d; Ip=[165.204.84.17]; Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BL02EPF00021F69.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR12MB7690 If multiple platform profile handlers have been registered then when setting a profile verify that all profile handlers support the requested profile and set it to each handler. If this fails for any given handler, revert all profile handlers back to balanced and log an error into the kernel ring buffer. Tested-by: Matthew Schwartz Signed-off-by: Mario Limonciello --- drivers/acpi/platform_profile.c | 47 ++++++++++++++++++--------------- 1 file changed, 26 insertions(+), 21 deletions(-) diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profile.c index a83842f05022b..db2ebd0393cf7 100644 --- a/drivers/acpi/platform_profile.c +++ b/drivers/acpi/platform_profile.c @@ -105,37 +105,42 @@ static ssize_t platform_profile_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { + struct platform_profile_handler *handler; + unsigned long choices; int err, i; - err = mutex_lock_interruptible(&profile_lock); - if (err) - return err; - - if (!cur_profile) { - mutex_unlock(&profile_lock); - return -ENODEV; - } - /* Scan for a matching profile */ i = sysfs_match_string(profile_names, buf); if (i < 0) { - mutex_unlock(&profile_lock); return -EINVAL; } - /* Check that platform supports this profile choice */ - if (!test_bit(i, cur_profile->choices)) { - mutex_unlock(&profile_lock); - return -EOPNOTSUPP; - } + scoped_cond_guard(mutex_intr, return -ERESTARTSYS, &profile_lock) { + if (!platform_profile_is_registered()) + return -ENODEV; - err = cur_profile->profile_set(cur_profile, i); - if (!err) - sysfs_notify(acpi_kobj, NULL, "platform_profile"); + /* Check that all handlers support this profile choice */ + choices = platform_profile_get_choices(); + if (!test_bit(i, &choices)) + return -EOPNOTSUPP; + + list_for_each_entry(handler, &platform_profile_handler_list, list) { + err = handler->profile_set(handler, i); + if (err) { + pr_err("Failed to set profile for handler %s\n", handler->name); + break; + } + } + if (err) { + list_for_each_entry_continue_reverse(handler, &platform_profile_handler_list, list) { + if (handler->profile_set(handler, PLATFORM_PROFILE_BALANCED)) + pr_err("Failed to revert profile for handler %s\n", handler->name); + } + return err; + } + } - mutex_unlock(&profile_lock); - if (err) - return err; + sysfs_notify(acpi_kobj, NULL, "platform_profile"); return count; } From patchwork Mon Oct 28 02:01:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 839132 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2060.outbound.protection.outlook.com [40.107.244.60]) (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 18F5418E758; Mon, 28 Oct 2024 02:02:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.244.60 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730080952; cv=fail; b=fc+gVnsxwYX4JTNlQyRNBMf7hcOOrT/mJReDcdM4Kka1HM3qYEUN4A3mx/7aUrxOtYK6lGI2jWN8k3uQhLhtTZZc++iJSeEK1wKT4iWqbWMFXcgMfaC8RNO5W3Hj08gkczZirK78zFk6XB+WExiSf7CR1JJl/ledCocgSs8aQxw= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730080952; c=relaxed/simple; bh=fjLVtWLvjdxjEjtwy83jVOC5p2fUEmI3179W2pZoPGc=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=SSJYVc0l/lVJJDaEsuwILsERCnVL/hxXIIya6vMyZg3u8GiJ6Lplnzc4FiKkrugP2XDbUviSAar4W0WvEibBWkNHXciz0rR0kZCVwEijQQ/4cDSSk/l/Qt4U3itml7KRVjOGWjbetS/voEOX2E1x2vco+pzBP+pSJ/wWlUbxKZk= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=0fJo4wXb; arc=fail smtp.client-ip=40.107.244.60 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="0fJo4wXb" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=S65MwHl1nEp07l4eGKo5eD0oO40R064Ekvujb1fm8iaPB/lEa/6WnxdGp7IMYXCLPgCz2pXWtDg7V2ZdCTuE4EC5w8+l985tMVr1ZMFo/FKPfKzdr4OcsArWjsevbEiaVWxztDj8DfrOb3gQWn8gFlkkQKDDnH/C6foqqds6G61zm4IaJ/FJ/e3LL54Tw+719du9EhzGCCwjmzczEz2AAx3ShahNJ07BT2D67EPPNiMGnjYcip0kcZ2EGF/EEJ8QBGMSX//QvCIrVMEOiC3luO+uXbE2Zdt7bqeZffdbKCTw5k+Zx6Ap/PGaAtplEOAv48t+juzANqEAP5AmF8cC1A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=TfRMK+/cK1f36OYEo4S6/Q9As/pXGudvLftjTZfY9GU=; b=hqPAQMwrGJ31C1l5PwYNr9KXrQHzlAZiDAqXKIZVuLQH/ia6P6NNoMlgH6hoG0U5dkaF8AawEzEoAi+ikaPpSta6aX5D4KQIPcFcR1LP6bTQ9Ef4pEVWxzmVyPjNnIhvDsRtFrctUv7C22KQSwkZ6Iy1nUZiOQ2L+n2Kp9lkZ3z0A+OKRnJ3KmmdpR0WPDeL6X8dteH//M04AGZOSi5azBYiocuQgxsSLDDfStH5gEg8qr3D1WOjZRDWZ7DPjQ3rvcLCXHgipNmJi+NyTJdfcYFFAvrOg1KrlzBY0JkJDBbgUjBk4TKo7U2FAxZGTZrqhV+dbsK5MtuijHrdgYV+gg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=redhat.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=TfRMK+/cK1f36OYEo4S6/Q9As/pXGudvLftjTZfY9GU=; b=0fJo4wXbWLLWuMxu8cJ28kniZ/XAooyeKufId5T159qbgA7B5XFZcb59IR1gCDGEglcZjei12gazC3WxpB5gW/RffqdmqiB0m+y/CbyTexN2rCljINKUsZvRyOaGuedjAy1WuU/E8fe5mtJbj5v/H4IcJt2qNfe90fZQcGaLuH8= Received: from BL1P223CA0005.NAMP223.PROD.OUTLOOK.COM (2603:10b6:208:2c4::10) by CH3PR12MB9431.namprd12.prod.outlook.com (2603:10b6:610:1c1::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.24; Mon, 28 Oct 2024 02:02:26 +0000 Received: from BL02EPF00021F6C.namprd02.prod.outlook.com (2603:10b6:208:2c4:cafe::fe) by BL1P223CA0005.outlook.office365.com (2603:10b6:208:2c4::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.25 via Frontend Transport; Mon, 28 Oct 2024 02:02:26 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by BL02EPF00021F6C.mail.protection.outlook.com (10.167.249.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8093.14 via Frontend Transport; Mon, 28 Oct 2024 02:02:26 +0000 Received: from AUS-P9-MLIMONCI.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Sun, 27 Oct 2024 21:02:22 -0500 From: Mario Limonciello To: Hans de Goede , =?utf-8?q?Ilpo_J=C3=A4rvinen?= CC: "Rafael J . Wysocki" , Len Brown , Maximilian Luz , Lee Chun-Yi , "Shyam Sundar S K" , Corentin Chary , "Luke D . Jones" , Ike Panhc , Henrique de Moraes Holschuh , "Alexis Belmonte" , =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= , Ai Chao , Gergo Koteles , open list , "open list:ACPI" , "open list:MICROSOFT SURFACE PLATFORM PROFILE DRIVER" , "open list:THINKPAD ACPI EXTRAS DRIVER" , Mark Pearson , Matthew Schwartz , Mario Limonciello Subject: [PATCH v2 14/15] ACPI: platform_profile: Allow multiple handlers Date: Sun, 27 Oct 2024 21:01:30 -0500 Message-ID: <20241028020131.8031-15-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241028020131.8031-1-mario.limonciello@amd.com> References: <20241028020131.8031-1-mario.limonciello@amd.com> Precedence: bulk X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL02EPF00021F6C:EE_|CH3PR12MB9431:EE_ X-MS-Office365-Filtering-Correlation-Id: d77a7ae3-b86e-473e-6e48-08dcf6f491f5 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|1800799024|82310400026|36860700013|7416014|376014; X-Microsoft-Antispam-Message-Info: HiKr5eAfJE4p5AXOPEGqAluWlgMxjSRSxtA+bRWQrsf7fEmSDgU/G7Xn9UeaTh/FJOFIw03EXQ/ZUJSgRxQCiRjrbXf9vEPL9j/EqgqcilFOZbM1TX5WpeumV4tA+A/vEdJBa3WqXPe261XaBnssA93xVHHzCem4NlpMVgkMOE7uLW0tiJs6rWVqRsQupok9hLrgxARY0XyyAse75liKWc3CABXfjm7a0/2wquF8GDolICQQduDgbonMcLmlW1vNleAEFzj4a32n9I1Gt7gQn3P4cZaB7V3rWomfmTBih2l1yz7qnP5a95/zBOwrP6bVgf5dkZv14G+MXO8z9KjtXq9VszJde11ZGETJO/lWGEifDtBX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ront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230040)(1800799024)(82310400026)(36860700013)(7416014)(376014); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Oct 2024 02:02:26.0376 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: d77a7ae3-b86e-473e-6e48-08dcf6f491f5 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d; Ip=[165.204.84.17]; Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BL02EPF00021F6C.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR12MB9431 Multiple drivers may attempt to register platform profile handlers, but only one may be registered and the behavior is non-deterministic for which one wins. It's mostly controlled by probing order. This can be problematic if one driver changes CPU settings and another driver notifies the EC for changing fan curves. Modify the ACPI platform profile handler to let multiple drivers register platform profile handlers and abstract this detail from userspace. To avoid undefined behaviors only offer profiles that are commonly advertised across multiple handlers. If any problems occur when changing profiles for any driver, then revert back to the balanced profile, which is now required. Tested-by: Matthew Schwartz Signed-off-by: Mario Limonciello --- drivers/acpi/platform_profile.c | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profile.c index e6ea5b600e2af..2794a8f686200 100644 --- a/drivers/acpi/platform_profile.c +++ b/drivers/acpi/platform_profile.c @@ -9,7 +9,6 @@ #include #include -static struct platform_profile_handler *cur_profile; static LIST_HEAD(platform_profile_handler_list); static DEFINE_MUTEX(profile_lock); @@ -188,7 +187,8 @@ static const struct attribute_group platform_profile_group = { void platform_profile_notify(void) { - if (!cur_profile) + guard(mutex)(&profile_lock); + if (!platform_profile_is_registered()) return; sysfs_notify(acpi_kobj, NULL, "platform_profile"); } @@ -251,17 +251,15 @@ int platform_profile_register(struct platform_profile_handler *pprof) } guard(mutex)(&profile_lock); - /* We can only have one active profile */ - if (cur_profile) - return -EEXIST; - err = sysfs_create_group(acpi_kobj, &platform_profile_group); - if (err) - return err; + if (!platform_profile_is_registered()) { + err = sysfs_create_group(acpi_kobj, &platform_profile_group); + if (err) + return err; + } list_add_tail(&pprof->list, &platform_profile_handler_list); sysfs_notify(acpi_kobj, NULL, "platform_profile"); - cur_profile = pprof; return 0; } EXPORT_SYMBOL_GPL(platform_profile_register); @@ -272,9 +270,8 @@ int platform_profile_remove(struct platform_profile_handler *pprof) list_del(&pprof->list); - cur_profile = NULL; - sysfs_notify(acpi_kobj, NULL, "platform_profile"); + if (!platform_profile_is_registered()) sysfs_remove_group(acpi_kobj, &platform_profile_group);