From patchwork Fri Dec 6 03:19:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 13896373 Received: from NAM02-DM3-obe.outbound.protection.outlook.com (mail-dm3nam02on2080.outbound.protection.outlook.com [40.107.95.80]) (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 A2937194C83; Fri, 6 Dec 2024 03:26:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.95.80 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733455596; cv=fail; b=XFcDOq0W+o7gLE0tca2WLQFyC8adDn+mrwVNG0g7w+bfeP35XtDAbNq22sGBLoD6nLkLFAV4TdySKm94DRFZJTNzJngn8AYM4pHMZG4gl9JJv0ijvzvG6fESujiGP/s3FO8uwcz5I2uYXRU+jPnFLb2N9BJIftbT7nJ+uZrLLhI= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733455596; c=relaxed/simple; bh=Pby3tslwiaWul1jpe7jDQmaOMHbh0fenYAG674vWqvE=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=R3eYEMh9M4TWiTlDOY990qUFfg3DA1+s2n9OCelCKjQruO9CQx1uy1ED6Emsk/YtpjcX8XAVnbx5uACzFvhkRr27vEeBoHokQSo6HijM9KtB9ggyfgMFEVtTr0tXczbdr0MJm4ARotrrjtxaTxiToTlSPex8H7t5fcQTN8wBJV0= 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=InkH2ACW; arc=fail smtp.client-ip=40.107.95.80 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="InkH2ACW" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=yS3llCSAyUsyVqQWYmdzq+PGGxgW4xBFq4150AH1Y2hCeZ1DGLYeM8aTnGymPowzlARD+sb/UKHOiUiNKboI7EmZopD+Z581nLUX/jAYFiwHMPVwfAQy+ACPgG6e7fBiUhMhUyLftOLimRHJmJqQ7ri+ht/OMlI6dcLbgHByiT3eQy6qpyCs3yN8IB2YRFC5rcQznFQjt6s2SN0tc9H1/6a1PDzzd7ZKPwsAlxCgYDdMyN2B9PNac71HlHhkmqtm+Fc+Ad2eVsbacKo/zC7MsOESwMNU2myoL7bNFzVBLZyngd49PR5PMsU9UqwR9h3dtnt7bNDKRRtgi0l9BhNRpQ== 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=hyJY5aPn73/DA7rBV+lEr27Aq5GpXoB16YU2Ca577/k=; b=YtZVMZ5++VwZu0SUeIzgc29g6lT2O76SXGEyOp9IO5lJIRvFeegmHuPkj+dGfCRtzjKdPLXo4mmtK9QFrZUtqbcgG9Io2ptcxm1SSmrUFYr67NvvbKO9OiXBqgZZ3Gh4ddcgle9lSBX//mjgFypyduym12f8bSBizlN54EhiGV1/Fx4N2ww3byDHrWLShqTXMyU8DH/vewlZjQsNlnhb87QgDSNSYYE2bq1yK7MTy6Ql+hhocHHmBEFUiCFKFiN3fnu3cMyJHoVzT/lxrr6guRr5yFCjijTb1aYJ0FTrMnZ/cYueXvGEs3gqLvp6AqLKHqdrXstvY36Q+iFvXE+YPQ== 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=hyJY5aPn73/DA7rBV+lEr27Aq5GpXoB16YU2Ca577/k=; b=InkH2ACW0AQVmFFeR1sA8zJvC3fAFBQmRwhR7VVrjEg5TDt5Aw8s7jt7Qu8tPy96dQ0sCR5AJ6RAieDj5n8Iz221ocQJkJNaS/KyDM5vPyMFJRuokBl5Ke8hFkrs/yBaCoXvcTOIRLTfA9wNb0SkdpKROy8cyTh2uppxuTL40hU= Received: from BLAPR03CA0007.namprd03.prod.outlook.com (2603:10b6:208:32b::12) by PH8PR12MB7135.namprd12.prod.outlook.com (2603:10b6:510:22c::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8207.23; Fri, 6 Dec 2024 03:26:26 +0000 Received: from BN1PEPF00004686.namprd03.prod.outlook.com (2603:10b6:208:32b:cafe::7c) by BLAPR03CA0007.outlook.office365.com (2603:10b6:208:32b::12) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8207.19 via Frontend Transport; Fri, 6 Dec 2024 03:26: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 BN1PEPF00004686.mail.protection.outlook.com (10.167.243.91) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8230.7 via Frontend Transport; Fri, 6 Dec 2024 03:26: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; Thu, 5 Dec 2024 21:26:23 -0600 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 , Armin Wolf Subject: [PATCH v10 20/22] ACPI: platform_profile: Allow multiple handlers Date: Thu, 5 Dec 2024 21:19:16 -0600 Message-ID: <20241206031918.1537-21-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241206031918.1537-1-mario.limonciello@amd.com> References: <20241206031918.1537-1-mario.limonciello@amd.com> Precedence: bulk X-Mailing-List: platform-driver-x86@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: BN1PEPF00004686:EE_|PH8PR12MB7135:EE_ X-MS-Office365-Filtering-Correlation-Id: 34b174a3-f5bf-4216-7a7b-08dd15a5c438 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700013|376014|1800799024|7416014|82310400026; X-Microsoft-Antispam-Message-Info: =?utf-8?q?izxPp/oLQq46Mbhozp1uRn4VsqrcEFW?= =?utf-8?q?wNVKNSP+F7409GUjt9VkUUT1njvBwMLgpEAvaMOwIRhCHnZaFylm0h85rYvXHGmCe?= =?utf-8?q?orJfo5cLNLHyaPP6V3eQxofHRbEnlhWhTrb1cuLQ+WbWtrqedhseK5OucKQAJD8mz?= =?utf-8?q?JcEls0XwDuI5zFxhWkS/q+S0om67kKAf0G1JMYKuvIvxfjjyKPNiVAoigmTev3BVi?= =?utf-8?q?7vZvREzs0MyamxBF1gkkp6RaDRIfC0AsxEOBoW0Qg2F9u1Qtb7073oWyB4kgBSD6L?= =?utf-8?q?obuL4hSWP7vIHhbr29LEJ8xsC+Hnsunv7ruNYHV+gYxA9/kl42qgybKVFSO+DAKMw?= =?utf-8?q?ySimt0Il6BfjsVlC+n/Qnill7eGZRDkMx2MiIkanlNPleYylwy9Y/QOz9eoPv/Akb?= =?utf-8?q?Pq5GiXDOK7Mok6nEQ7WbfhoghQI0rPpW6LMMw+k7X2w3FdNnMvjliCz9eU056p0+y?= =?utf-8?q?7BOy70DFr5YElA/NgrdWwvqeHjbIWOnyabVUUtDeuXhuznyKZXqa8hgrqQgiotEA0?= =?utf-8?q?389O+vHKul/ll2A/OOqItWbBlDSCAWXjtPPbbuC/UCXj0s8UrfosU6LtHaBUZOobP?= =?utf-8?q?nd1mxURCHnhgd4Vj/v4dHQ6RDe1tQuHHC6JIuMpd0YPnRMA35m4Fy0wQcFuluDIvm?= =?utf-8?q?UjhwUOLaOFvYXjqv57rLhm9NlVTkLRLNKV6OaBcTlRa7ZVxjjpA13xhsP0Xnj1LIy?= =?utf-8?q?wT/dgeiTkT6Acph0Fy7nap0s8UO2TjKh5H/l7eG0d039oruJ7GtgM54YbxyUsV8Rc?= =?utf-8?q?zTmv3K/9Bjo+TfqKzVS/TucQ6gwHvPjVV9TC/7/T0Bl+C/aRhJmfC4iwvB77FoG+g?= =?utf-8?q?hXrwbb2aYpRdKdmC3EGMmuanpdWzojwPry46WgQt7b94/el2WKlz0OEvb0cuQcf7d?= =?utf-8?q?h4zFOBjmw2WsCC+QehhC82udZcbvjoCCXY5vDIIF44DamGegTc+n71osKPn+eeMRd?= =?utf-8?q?lQbY/hw2eO60+wbPzOletSwk+vdCaha64wsatDzSiwi/DvqWeJ+VF9vJCA8cpmGOj?= =?utf-8?q?tkO3UI2+5G+yHPR/c9VcT4M670FwJiXut+htokmNzw4aGIILQWlLZJqFmrBGdMfdw?= =?utf-8?q?rbY/nCUAebqvMA7M5QG0Pghk1Dpi2DNM8RJaTvk2UtN/47t2ZRAgsBZ6K6SGl12g5?= =?utf-8?q?N9Cs/PjAvDsJ6Va4pT4JPEh0h2C7GhgRFsz2UXa+2l7b83C+hbvNlB2p3Pgy2EaR8?= =?utf-8?q?UL0+murnAS+321DwiwZEAALsWuuTAlrMztlCrjq5bn5SQOo6yQa0Dv2tVJaiCdDtC?= =?utf-8?q?+SrkrIZMCKiOfPCvNSrWHAhMIHAxBL+w5GabJZ/KBFvyNPTUaVUvHp6AnFGqDdMhp?= =?utf-8?q?VcBJos50+Eq5/ewDXrSurqZg8w9vUENR8qYw1Tph5NIEB6C8LVfdg3FasPpPKc0Zk?= =?utf-8?q?1Yd6zQ3ewJv?= 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)(36860700013)(376014)(1800799024)(7416014)(82310400026);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Dec 2024 03:26:26.1520 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 34b174a3-f5bf-4216-7a7b-08dd15a5c438 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: BN1PEPF00004686.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH8PR12MB7135 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 the drivers that were already changed remain changed and the legacy sysfs handler will report 'custom'. Tested-by: Mark Pearson Tested-by: Matthew Schwartz Reviewed-by: Mark Pearson Reviewed-by: Armin Wolf Reviewed-by: Ilpo Järvinen Signed-off-by: Mario Limonciello --- drivers/acpi/platform_profile.c | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profile.c index e105ef48409ec..75a1415190ace 100644 --- a/drivers/acpi/platform_profile.c +++ b/drivers/acpi/platform_profile.c @@ -10,7 +10,6 @@ #include #include -static struct platform_profile_handler *cur_profile; static DEFINE_MUTEX(profile_lock); static const char * const profile_names[] = { @@ -410,8 +409,6 @@ static const struct attribute_group platform_profile_group = { void platform_profile_notify(struct platform_profile_handler *pprof) { - if (!cur_profile) - return; scoped_cond_guard(mutex_intr, return, &profile_lock) { _notify_class_profile(pprof->class_dev, NULL); } @@ -474,9 +471,6 @@ 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; /* create class interface for individual handler */ pprof->minor = ida_alloc(&platform_profile_ida, GFP_KERNEL); @@ -492,8 +486,6 @@ int platform_profile_register(struct platform_profile_handler *pprof) sysfs_notify(acpi_kobj, NULL, "platform_profile"); - cur_profile = pprof; - err = sysfs_update_group(acpi_kobj, &platform_profile_group); if (err) goto cleanup_cur; @@ -501,7 +493,6 @@ int platform_profile_register(struct platform_profile_handler *pprof) return 0; cleanup_cur: - cur_profile = NULL; device_unregister(pprof->class_dev); cleanup_ida: @@ -516,8 +507,6 @@ int platform_profile_remove(struct platform_profile_handler *pprof) int id; guard(mutex)(&profile_lock); - cur_profile = NULL; - id = pprof->minor; device_unregister(pprof->class_dev); ida_free(&platform_profile_ida, id);