From patchwork Tue Nov 19 17:17:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 844295 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2044.outbound.protection.outlook.com [40.107.243.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 CEA7C1D1E79; Tue, 19 Nov 2024 17:21:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.243.44 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732036870; cv=fail; b=RCF4FGeFQxwgj+wUM0j0vPLxbZpDoH+2qhllsl3fhEILY8O4v58PwJ8wTyHBqUOUriiS0AuC4/1kzC4ppor/+mdClBsMFGcsZ1wrAgWwDNHnRK2VFmXUSrtfQdbOzJFq2fMvk1KcbxyyHDKe+u+Q8RQ4oKdfyRz0A1UkvNLGWAc= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732036870; c=relaxed/simple; bh=gVOFZQ1NkY8btPf86/D8ZFqsha0+GCMWANbhEBwFGl4=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=fL3RYe3DJUVxoC2fSDUtyWru39jqZgVc+RS4XGXY8bsrQrArPTLNigCEnNqcbcHhiFdMeZ6WRvHUyFmfm3pI5zbJt6GkjRucy3vCm7JXFYUxN96NLIC8w/N4h/tC5l7V8lS7jzM3vrWbFTc3WeodsZ7DRV+qSoOsZZxL+ObIDXo= 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=E59xm3d6; arc=fail smtp.client-ip=40.107.243.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="E59xm3d6" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=fRaE5fEaI5G8Uf4IOPcJP33HFq6+6Mtt1RkK5UWLfiOA3nNO80SAYKjEdwBqu71IQjF9tqc1gjE9TekpcE1Jb12Ybz6Gbq3W9bVM4AeqBg18hty3XAPhK9ElGqNjyMWgNg70i92CXmqLK+TjHBfCBkcXRusnbacWFIZ0fNVg8qGNQcu+OUowfNSkBAInwH1uiQ294LmuKy9FJp4pSCluNJbfVIKi+mZ1L366u7dX+r0vXG18o5nCsncBD77qW7BBZ8uTE54sXwkkFs4wVMNo9v8dmDXi9OJjEDgvtM7iM6N13lwCJ2IeAOP7ev8DBQjIBLUOJ+0je5u96e+mtsRcHw== 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=Rcake+aW7InzlrriCA9veWw0Iv9E+pdMZvM9w0hzudg=; b=kkqipRyXGiCgLdcAQTvutvs2K5Wb52weCnsGqsOektUs6B7d4DWyhfohQHTZUppz0uQnppd890gJzdJP6eWTmq1/3UU264BeLZROhO8wI5OjIgsFxyXps8VZLA4zcyvnGOClKjLYIwCAreLcuuvz0E8TnIHJAu4EB/QOPZGTeWIhcBdTOq3N5xLPqu9QOF/iKie98Q7ACgdHZRDNj00O/+OmjwXPPEsPGi2+B556hINgZQPWUZw5F+btomsuOvFc99qukIsgGbmjEvki+bvt/KXfT1kI2tK84aGRfo+qnycPcDgB/TpRCAVgJQl492bPkfcA9vmB026607een5oIcA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.12) 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=Rcake+aW7InzlrriCA9veWw0Iv9E+pdMZvM9w0hzudg=; b=E59xm3d6xDoyojZQCFMUfz8/heJvf1H26odjeB4IwT6zq4LQy5uzQuVNGm7ul9AA+ujDjDdUW5LvbkRBoj9j6sv1749yV+nhRKC2i8h9ZqlyRHy5UasIuKt4cTlO7cKTt8d4RrbeakUHN8iOnnCK12YqNGkmS7XzdD/j6GIS/Kg= Received: from SJ2PR07CA0008.namprd07.prod.outlook.com (2603:10b6:a03:505::8) by DS7PR12MB6239.namprd12.prod.outlook.com (2603:10b6:8:95::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.22; Tue, 19 Nov 2024 17:21:02 +0000 Received: from CY4PEPF0000EDD4.namprd03.prod.outlook.com (2603:10b6:a03:505:cafe::69) by SJ2PR07CA0008.outlook.office365.com (2603:10b6:a03:505::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.25 via Frontend Transport; Tue, 19 Nov 2024 17:21:02 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.12) 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.12 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.12; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.12) by CY4PEPF0000EDD4.mail.protection.outlook.com (10.167.241.200) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8158.14 via Frontend Transport; Tue, 19 Nov 2024 17:21:02 +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; Tue, 19 Nov 2024 11:20:59 -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 v7 02/22] platform/x86/dell: dell-pc: Create platform device Date: Tue, 19 Nov 2024 11:17:19 -0600 Message-ID: <20241119171739.77028-3-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241119171739.77028-1-mario.limonciello@amd.com> References: <20241119171739.77028-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: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000EDD4:EE_|DS7PR12MB6239:EE_ X-MS-Office365-Filtering-Correlation-Id: fafd6b68-d250-4506-3513-08dd08be8af9 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|82310400026|376014|7416014|36860700013|1800799024; X-Microsoft-Antispam-Message-Info: =?utf-8?q?bhPbb0eSubmlGNMyn4v+7ZQP0zyXJ3Y?= =?utf-8?q?mUNJ6EMTZHVx7WTEFZ27tBSA4w2e4EWYXGpZE4yJjExq9/NwV5AoPk7LRgjmddfM6?= =?utf-8?q?IBqvk6uJznc8MUPySg6MhDXaWbKUCh0ptJ3x0wDJvkUgvKkwWLn8didZp9n10mQDt?= =?utf-8?q?6QK2VbDaq74NCIf+gzXMOTWJ5MlyPRjQbVdo6fdZsNvneLR455ebEgXmwNYiogCFy?= =?utf-8?q?ZwrPAwZEycJ2Z6PUXcIkYhOiT0XssRp2cZTzT39ipS9XVE8y0bhdzVhlPODJzwpxb?= =?utf-8?q?bX3+UYpvztmXegcWhLtYODiDxhw/Jj+xdIgfwXUfbLf2k87RgDpYp7XTQKqBGB8Ty?= =?utf-8?q?zled3aBqqPRy9s0xU9EnvQ069v0p9r6R1NYoa4Un/tCN04AwMv54TQrHbFbCrdotq?= =?utf-8?q?BcCVaFF670FwaYvsk8aLzZUu9xy3qA8jXUmpvpIpB9Erev0I0MvTD+SpcVS1iktf3?= =?utf-8?q?vKagmuly8tcFJyahMUk4KohXRR7v5Em+HOTk1+a7R9RbruTyaV72Dzd/82lgYL1me?= =?utf-8?q?g2XMfclXIQ6PPXiGQ0ipQ7KZFt0SlYuqE1xVw0Zdc97OCC//+DRHpm0x8VIC7L6Zw?= =?utf-8?q?mBgpDJtoXyiP6AvP/D7VuLM47+cpoQ7eld5vra+ZAGKt1bwEtXeyzaeEW8dHr/pjq?= =?utf-8?q?6owyzh95e8PJu6teov9fLz0RVX3a23vb2jWMzM18g2b6k72DRCbYVh8l1r6+ZDOkg?= =?utf-8?q?f2EEdTCO6IY0xlHZl2ne+g7w1zhXipsC44sH4VgagbOEJRjzBOJqpsnUSWVnuMy5O?= =?utf-8?q?nEP0m0aqiDvoQv/olYGE18k9Hn9cna+c9bWdWl4AuuF1rT+BQRoh8gYAQBJZTuFfs?= =?utf-8?q?xuOW3Og1r/ZydI92/9L7+G0PwQ/xGiOYGq6v4o1EoU4EwBXpC4aGsOZ5APApDu3d5?= =?utf-8?q?Z8YW35Zi5Egk6BJh0P/EzbVFmzUOTqZtzwf8S6bqXu6YTx+fvHeaISiI0PWuEoqXX?= =?utf-8?q?fSiLMfJZIayOPNhSW9IG2RZAZv66NCOa3TU/c9kglrL+cEL6V6gGVVANx9TIyHlwt?= =?utf-8?q?ueEUVIL23crNulMLnhF5l5BOnYqvB7KDIeqNV9Dy2SkuOeSVat6PQbF3a/YuUxf74?= =?utf-8?q?C9iQv8tY8CTigtLx9rkyRxUpzWV8JtxA6eUYeHJN3Y9Mu/5vQasrDEA5adoPDisPA?= =?utf-8?q?IYtD1xLC8GVtFi0I6rrl3M3uoaGxCXYIyK8nGKiOJSV1zNQIMzxE6zCK4qFWZ3edq?= =?utf-8?q?0ly456tSDH9QIkmtK8omUVTQFD56tPaQETfu9AbZ7SPg8Jo1i3tGp6Okl1GK0J4xP?= =?utf-8?q?rLvFwfXTIAX7X8QIZS0skIVvt1KTjoy/BvIciMWNMpLiZPCFymGdR06qBwzJiy3WT?= =?utf-8?q?6o0xCVTMvHqyszBWWzLVCvAhmYyuFY3v/w=3D=3D?= X-Forefront-Antispam-Report: CIP:165.204.84.12; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:atlvpn-bp.amd.com; CAT:NONE; SFS:(13230040)(82310400026)(376014)(7416014)(36860700013)(1800799024); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Nov 2024 17:21:02.3156 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: fafd6b68-d250-4506-3513-08dd08be8af9 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.12]; Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CY4PEPF0000EDD4.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS7PR12MB6239 In order to have a device for the platform profile core to reference create a platform device for dell-pc. While doing this change the memory allocation for the thermal handler to be device managed to follow the lifecycle of that device. Reviewed-by: Armin Wolf Tested-by: Mark Pearson Reviewed-by: Ilpo Järvinen Signed-off-by: Mario Limonciello --- v6: * Use PLATFORM_DEVID_NONE (Armin) v5: * use platform_device_register_simple() --- drivers/platform/x86/dell/dell-pc.c | 32 +++++++++++++++++++++-------- 1 file changed, 23 insertions(+), 9 deletions(-) diff --git a/drivers/platform/x86/dell/dell-pc.c b/drivers/platform/x86/dell/dell-pc.c index 3cf79e55e3129..805497e44b3a5 100644 --- a/drivers/platform/x86/dell/dell-pc.c +++ b/drivers/platform/x86/dell/dell-pc.c @@ -18,10 +18,13 @@ #include #include #include +#include #include #include "dell-smbios.h" +static struct platform_device *platform_device; + static const struct dmi_system_id dell_device_table[] __initconst = { { .ident = "Dell Inc.", @@ -244,9 +247,15 @@ static int thermal_init(void) if (!supported_modes) return 0; - thermal_handler = kzalloc(sizeof(*thermal_handler), GFP_KERNEL); - if (!thermal_handler) + platform_device = platform_device_register_simple("dell-pc", PLATFORM_DEVID_NONE, NULL, 0); + if (!platform_device) return -ENOMEM; + + thermal_handler = devm_kzalloc(&platform_device->dev, sizeof(*thermal_handler), GFP_KERNEL); + if (!thermal_handler) { + ret = -ENOMEM; + goto cleanup_platform_device; + } thermal_handler->name = "dell-pc"; thermal_handler->profile_get = thermal_platform_profile_get; thermal_handler->profile_set = thermal_platform_profile_set; @@ -262,20 +271,25 @@ static int thermal_init(void) /* Clean up if failed */ ret = platform_profile_register(thermal_handler); - if (ret) { - kfree(thermal_handler); - thermal_handler = NULL; - } + if (ret) + goto cleanup_thermal_handler; + + return 0; + +cleanup_thermal_handler: + thermal_handler = NULL; + +cleanup_platform_device: + platform_device_unregister(platform_device); return ret; } static void thermal_cleanup(void) { - if (thermal_handler) { + if (thermal_handler) platform_profile_remove(); - kfree(thermal_handler); - } + platform_device_unregister(platform_device); } static int __init dell_init(void) From patchwork Tue Nov 19 17:17:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 844293 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2055.outbound.protection.outlook.com [40.107.93.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 203941CF7C1; Tue, 19 Nov 2024 17:21:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.93.55 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732036877; cv=fail; b=p57k7rWzxMjSURn5PRcCLTBwma3g0dNqYb/+OZVpXXWmvMVZM815KxNFKolLSwaJ1P4AO1HY4qgfILsFliONXP6miWh4QWdILThdHTVadYWhFflGgKLTIdgEaC3EAzfQFe4ut3nWwah11RzP7poCslhgsoQXNUUcv5ncnH5+He0= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732036877; c=relaxed/simple; bh=vwvkuCF6TUIm5sAd8pAAU03EmVf6teWL+lnPU/6KHg4=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=K+uiwIyuYzDaNMaWGDos1xTEQ2isuP10/pKo9+1JjQQXx2fuoEkqTFYCodalFW0+P75/n336ADnsXxZjsHq+Ch9k1do92iJOpHlacjB5IeD2pOdkUnuhWdeENeHA6kwNtdecizyNVkEe0yViUOOdOAaKV1oRv4VVYZ2qljZXgc0= 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=nkpUuvU3; arc=fail smtp.client-ip=40.107.93.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="nkpUuvU3" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=srrFMrOqPaeVWp5glqZ8kBNr+VFg2UhF/XvvxacZlERVySrJuUSzegr439rREJbUOy0bqtznGb3qBc8e/DUdScarEjqQ+NHvAp+jCu30foPNUHa2Muccuf4PXnWMd8hPXVHl4xUihsLxetQQTnk3UokF4ajy+G1QDSccn0cxOWOpC/pO5Tuq0Rksodcv5QMWNEWz7qaHGMO+AdSi09Jmm4+NfEU/yATN1wLLAiyPleiRdLAVkgPmO4KrrzyiMPcWSObym0lfZk1bZ8v02r8rXpKVhQOuExkzM4DyViC7mhwU4QKx5Pfl3yMy/7G3QLijQIR5cC//sUmyNOEGGggnWA== 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=OehAyRoZjLR3a5hc5eWpv7UNPEKV6B1j4xI56uoKf0c=; b=X5zHp3W7IpzCuse6CP165r99P81n9YtFn60+3oQ5WNDg3E/Taoq9jT25FrpluXPN31fLt1Xa/8uefHdabzpxdpccaStSKbEogOxEVS3BSj03T0jzu//Fu1dPrBMHpuuji/OkjnZ+s+FEZuDvt+tlQGivowJg24Ilz8l/9Hbh++ZEySlitLZr54hOaApVDM5gCVZiT6j+fAbothLprSWV7SztvBH6lcei7NK1kjvh/5X3tXDK5h6tF0JaLkL1TC5sGZrqgOIbkhRtT6TFKAJ9AVX+PkJJ1Juy+cRDv33FqO0z+MIYjH2fKAU2dpCBwskCgKlMqk8MpJSdEJFYZratzw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.12) 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=OehAyRoZjLR3a5hc5eWpv7UNPEKV6B1j4xI56uoKf0c=; b=nkpUuvU3seWwlgItY85QqU7dZrwI8yixAUI5flcm4zLKYUOP8//nacz7Xgv8R6z/GNGJ530OOn7IRv0EE9vKEGVhorYRkbOIh6LeGIk7V8J7/eZu71aaFN4JGt1j4Xoidq8VJ1pgj0I7sqfQhkmw2B9CxxfUWQa1em0lRoXFTi4= Received: from SJ2PR07CA0022.namprd07.prod.outlook.com (2603:10b6:a03:505::24) by DS7PR12MB5719.namprd12.prod.outlook.com (2603:10b6:8:72::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.22; Tue, 19 Nov 2024 17:21:08 +0000 Received: from CY4PEPF0000EDD4.namprd03.prod.outlook.com (2603:10b6:a03:505:cafe::40) by SJ2PR07CA0022.outlook.office365.com (2603:10b6:a03:505::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.24 via Frontend Transport; Tue, 19 Nov 2024 17:21:07 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.12) 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.12 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.12; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.12) by CY4PEPF0000EDD4.mail.protection.outlook.com (10.167.241.200) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8158.14 via Frontend Transport; Tue, 19 Nov 2024 17:21: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; Tue, 19 Nov 2024 11:21:03 -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 v7 04/22] ACPI: platform_profile: Add platform handler argument to platform_profile_remove() Date: Tue, 19 Nov 2024 11:17:21 -0600 Message-ID: <20241119171739.77028-5-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241119171739.77028-1-mario.limonciello@amd.com> References: <20241119171739.77028-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: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000EDD4:EE_|DS7PR12MB5719:EE_ X-MS-Office365-Filtering-Correlation-Id: 8c2ba382-6e14-4de4-2329-08dd08be8e32 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|1800799024|7416014|376014|82310400026|36860700013; X-Microsoft-Antispam-Message-Info: =?utf-8?q?4dAqlA0A4SmP9oHnFyWOmjDDoR/qRGH?= =?utf-8?q?Nffr2KUMkkI/l02/T/eDNdnsMdOJ2Nyibe9FjNhurGJgZjrwyJJIZkIfFLr5vZsz1?= =?utf-8?q?gR0VVuvg6x9LYWk2VksJUHPrF0G7//siWStrnJSdr4bgtoOLOuZ1/aXRrr4Dz1fFI?= =?utf-8?q?Z8QxlA3WpBc8xaE4/ZEmtBzDRi8oL+xcln4Ysp6vs9+JA+ahCKKDEyGcmdFw1IU3L?= =?utf-8?q?GyV7rgM5b8VZidlkTBX7h+86rEDqtWkmeOv3dIR7SJRCGO955Gr1KHGE2xLLfJi1r?= =?utf-8?q?mbIpJNjh+hkEeCO7ewfiDwIOlsdfEaiG5k1WKhurC2b/t6Jbh0CrtAKrqg40h9qnk?= =?utf-8?q?qSoDNSaeXxYGXi8qFaIvaW9GIbprNFHSLpKX89FFyaicRC18b7LZASO9UanOXn1+b?= =?utf-8?q?maOs2uaA69v+VsHi6YY6wZPrFsSYCf2Wjm7llsNqC4814JYLw4ECcT5SdGvN5MboX?= =?utf-8?q?EVMz6c8qj/Twj9XdHK/jdaBUlyVoeSZRTaVZlzYXe7Ad94RTsR6fiCn35Sa8KJA6q?= =?utf-8?q?f29M3wwz9EJfrFTe1FldaFQNo5kD9ibzRPik/qApbX4s+xwRPMfcFZBSNJDQDYOin?= =?utf-8?q?ZMUlP+du922swFCvI+5Cn34tFGwrOxsxeApnjzQnicbKXhm8TO+BUMTRnZ99Z9FnW?= =?utf-8?q?zDgH6W/zugLK7VK+4eRDkCamzv2uKzPjBO7q3v/NaJU8VOdGh4JUfV1M2kptYQ8U1?= =?utf-8?q?kHLN/cSyzbAW3T6CXVIPfrsiqZ+uBS/AuFTGKAM5IboOJ2oCfxGev7iKOxW932ziK?= =?utf-8?q?svxxKD70yay3/znD+X8lHbzztuYMfFD5tULJIEXwJ103AdjjtOkHJbiUiefDl9gDZ?= =?utf-8?q?OM1dPvAvsvhALQRhLH/3SqUw52cMkWXeyS5S4JugOCTxtaO3ItIfw7INvJ7Fndz0Y?= =?utf-8?q?e0btYLzB7ApLjVYK5wykjaVEZ2uTM+N9wPAnxYl8Fg2GbVogtELzKO8FTU607rFyX?= =?utf-8?q?TVOgO8fAlqxthyaUO+21Orb9V+SCK9LSzTB9LfFVHcq/1m8w25oB0l1T1hDGc/vUK?= =?utf-8?q?yCgr5YZOrSpCHFBswxO/UoIvn7akK85TelSuDrbwoitL9lvvDhNHhyeZqy68wvBBJ?= =?utf-8?q?4YU0PmkHtg3VE8lQWuOXpRtIemCnPIi/gdCRa4yP/u1kzycfQ19A64zs02YVQU5hP?= =?utf-8?q?ieLJUQcvDzdw8pfSPFvDHQrYx1yu+gWkytqugPllsI7Wz8nnd3sSQ1WpL8dmpgSOD?= =?utf-8?q?p59YFnVfRuZMJsV+8vL2QNPsfgZbEbjlt9nm7EAVPNZx3S8eubZLrnjxXoN2unl5F?= =?utf-8?q?pStpfl/iaelEMcObkslkkSQtL3WisOVutcYDHcKoJ1rIHFM0bdiR2IXuPSp75UaUk?= =?utf-8?q?m2vOsL4qCvhcDThd3xZte/77yWDNDbP0tw=3D=3D?= X-Forefront-Antispam-Report: CIP:165.204.84.12; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:atlvpn-bp.amd.com; CAT:NONE; SFS:(13230040)(1800799024)(7416014)(376014)(82310400026)(36860700013); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Nov 2024 17:21:07.7062 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 8c2ba382-6e14-4de4-2329-08dd08be8e32 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.12]; Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CY4PEPF0000EDD4.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS7PR12MB5719 To allow registering and unregistering multiple platform handlers calls to platform_profile_remove() will need to know which handler is to be removed. Add an argument for this. Tested-by: Mark Pearson Tested-by: Matthew Schwartz Reviewed-by: Hans de Goede Reviewed-by: Mark Pearson Reviewed-by: Maximilian Luz Reviewed-by: Ilpo Järvinen Reviewed-by: Armin Wolf Signed-off-by: Mario Limonciello --- v5: * Add tag v4: * Add alienware-wmi too --- drivers/acpi/platform_profile.c | 2 +- drivers/platform/surface/surface_platform_profile.c | 6 +++++- drivers/platform/x86/acer-wmi.c | 4 ++-- drivers/platform/x86/amd/pmf/sps.c | 2 +- drivers/platform/x86/asus-wmi.c | 4 ++-- drivers/platform/x86/dell/alienware-wmi.c | 2 +- drivers/platform/x86/dell/dell-pc.c | 2 +- drivers/platform/x86/hp/hp-wmi.c | 2 +- drivers/platform/x86/ideapad-laptop.c | 2 +- drivers/platform/x86/inspur_platform_profile.c | 5 ++++- drivers/platform/x86/thinkpad_acpi.c | 2 +- include/linux/platform_profile.h | 2 +- 12 files changed, 21 insertions(+), 14 deletions(-) diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profile.c index d2f7fd7743a13..c24744da20916 100644 --- a/drivers/acpi/platform_profile.c +++ b/drivers/acpi/platform_profile.c @@ -205,7 +205,7 @@ int platform_profile_register(struct platform_profile_handler *pprof) } EXPORT_SYMBOL_GPL(platform_profile_register); -int platform_profile_remove(void) +int platform_profile_remove(struct platform_profile_handler *pprof) { sysfs_remove_group(acpi_kobj, &platform_profile_group); diff --git a/drivers/platform/surface/surface_platform_profile.c b/drivers/platform/surface/surface_platform_profile.c index 5f45f8e8cd69b..b449c4c8b883c 100644 --- a/drivers/platform/surface/surface_platform_profile.c +++ b/drivers/platform/surface/surface_platform_profile.c @@ -210,6 +210,7 @@ static int surface_platform_profile_probe(struct ssam_device *sdev) return -ENOMEM; tpd->sdev = sdev; + ssam_device_set_drvdata(sdev, tpd); tpd->handler.name = "Surface Platform Profile"; tpd->handler.dev = &sdev->dev; @@ -228,7 +229,10 @@ static int surface_platform_profile_probe(struct ssam_device *sdev) static void surface_platform_profile_remove(struct ssam_device *sdev) { - platform_profile_remove(); + struct ssam_platform_profile_device *tpd; + + tpd = ssam_device_get_drvdata(sdev); + platform_profile_remove(&tpd->handler); } static const struct ssam_device_id ssam_platform_profile_match[] = { diff --git a/drivers/platform/x86/acer-wmi.c b/drivers/platform/x86/acer-wmi.c index aca4a5746bee1..b12965d9fcdb7 100644 --- a/drivers/platform/x86/acer-wmi.c +++ b/drivers/platform/x86/acer-wmi.c @@ -2547,7 +2547,7 @@ static int acer_platform_probe(struct platform_device *device) error_hwmon: if (platform_profile_support) - platform_profile_remove(); + platform_profile_remove(&platform_profile_handler); error_platform_profile: acer_rfkill_exit(); error_rfkill: @@ -2570,7 +2570,7 @@ static void acer_platform_remove(struct platform_device *device) acer_rfkill_exit(); if (platform_profile_support) - platform_profile_remove(); + platform_profile_remove(&platform_profile_handler); } #ifdef CONFIG_PM_SLEEP diff --git a/drivers/platform/x86/amd/pmf/sps.c b/drivers/platform/x86/amd/pmf/sps.c index 1b94af7c0e0c4..bd2bd6cfc39a0 100644 --- a/drivers/platform/x86/amd/pmf/sps.c +++ b/drivers/platform/x86/amd/pmf/sps.c @@ -426,5 +426,5 @@ int amd_pmf_init_sps(struct amd_pmf_dev *dev) void amd_pmf_deinit_sps(struct amd_pmf_dev *dev) { - platform_profile_remove(); + platform_profile_remove(&dev->pprof); } diff --git a/drivers/platform/x86/asus-wmi.c b/drivers/platform/x86/asus-wmi.c index c15fccf5131af..9105b456eab1f 100644 --- a/drivers/platform/x86/asus-wmi.c +++ b/drivers/platform/x86/asus-wmi.c @@ -4842,7 +4842,7 @@ static int asus_wmi_add(struct platform_device *pdev) fail_custom_fan_curve: fail_platform_profile_setup: if (asus->platform_profile_support) - platform_profile_remove(); + platform_profile_remove(&asus->platform_profile_handler); fail_fan_boost_mode: fail_platform: kfree(asus); @@ -4869,7 +4869,7 @@ static void asus_wmi_remove(struct platform_device *device) asus_wmi_battery_exit(asus); if (asus->platform_profile_support) - platform_profile_remove(); + platform_profile_remove(&asus->platform_profile_handler); kfree(asus); } diff --git a/drivers/platform/x86/dell/alienware-wmi.c b/drivers/platform/x86/dell/alienware-wmi.c index 78aac76132788..e95d22c7b60cd 100644 --- a/drivers/platform/x86/dell/alienware-wmi.c +++ b/drivers/platform/x86/dell/alienware-wmi.c @@ -1165,7 +1165,7 @@ static int create_thermal_profile(struct platform_device *platform_device) static void remove_thermal_profile(void) { if (quirks->thermal) - platform_profile_remove(); + platform_profile_remove(&pp_handler); } static int __init alienware_wmi_init(void) diff --git a/drivers/platform/x86/dell/dell-pc.c b/drivers/platform/x86/dell/dell-pc.c index e5724e76a2082..5c4d48e4b667a 100644 --- a/drivers/platform/x86/dell/dell-pc.c +++ b/drivers/platform/x86/dell/dell-pc.c @@ -289,7 +289,7 @@ static int thermal_init(void) static void thermal_cleanup(void) { if (thermal_handler) - platform_profile_remove(); + platform_profile_remove(thermal_handler); platform_device_unregister(platform_device); } diff --git a/drivers/platform/x86/hp/hp-wmi.c b/drivers/platform/x86/hp/hp-wmi.c index ffb09799142bc..6d6e13a0c6e2d 100644 --- a/drivers/platform/x86/hp/hp-wmi.c +++ b/drivers/platform/x86/hp/hp-wmi.c @@ -1693,7 +1693,7 @@ static void __exit hp_wmi_bios_remove(struct platform_device *device) } if (platform_profile_support) - platform_profile_remove(); + platform_profile_remove(&platform_profile_handler); } static int hp_wmi_resume_handler(struct device *device) diff --git a/drivers/platform/x86/ideapad-laptop.c b/drivers/platform/x86/ideapad-laptop.c index 24367c3590c99..80797c6ae8b0b 100644 --- a/drivers/platform/x86/ideapad-laptop.c +++ b/drivers/platform/x86/ideapad-laptop.c @@ -1136,7 +1136,7 @@ static void ideapad_dytc_profile_exit(struct ideapad_private *priv) if (!priv->dytc) return; - platform_profile_remove(); + platform_profile_remove(&priv->dytc->pprof); mutex_destroy(&priv->dytc->mutex); kfree(priv->dytc); diff --git a/drivers/platform/x86/inspur_platform_profile.c b/drivers/platform/x86/inspur_platform_profile.c index 5a53949bbbf5f..53af73a7fbf7b 100644 --- a/drivers/platform/x86/inspur_platform_profile.c +++ b/drivers/platform/x86/inspur_platform_profile.c @@ -191,7 +191,10 @@ static int inspur_wmi_probe(struct wmi_device *wdev, const void *context) static void inspur_wmi_remove(struct wmi_device *wdev) { - platform_profile_remove(); + struct inspur_wmi_priv *priv; + + priv = dev_get_drvdata(&wdev->dev); + platform_profile_remove(&priv->handler); } static const struct wmi_device_id inspur_wmi_id_table[] = { diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c index 222fba97d79a7..13798c6d5fcf3 100644 --- a/drivers/platform/x86/thinkpad_acpi.c +++ b/drivers/platform/x86/thinkpad_acpi.c @@ -10638,7 +10638,7 @@ static int tpacpi_dytc_profile_init(struct ibm_init_struct *iibm) static void dytc_profile_exit(void) { - platform_profile_remove(); + platform_profile_remove(&dytc_profile); } static struct ibm_struct dytc_profile_driver_data = { diff --git a/include/linux/platform_profile.h b/include/linux/platform_profile.h index daec6b9bad81f..bcaf3aa39160f 100644 --- a/include/linux/platform_profile.h +++ b/include/linux/platform_profile.h @@ -37,7 +37,7 @@ struct platform_profile_handler { }; int platform_profile_register(struct platform_profile_handler *pprof); -int platform_profile_remove(void); +int platform_profile_remove(struct platform_profile_handler *pprof); int platform_profile_cycle(void); void platform_profile_notify(void); From patchwork Tue Nov 19 17:17:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 844294 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2067.outbound.protection.outlook.com [40.107.92.67]) (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 350BC1CF295; Tue, 19 Nov 2024 17:21:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.92.67 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732036875; cv=fail; b=opOtR5tAjI3bL5t88Rg3y47Tq2ivLPNITctEFTIhX49BusppU7E7Atbrd5PmMuJgUvPpYTkur5Nva5+ZTB+XL56kwkLzOPy6MJVDMDGi9nETVgDYOfIph2jLhr8lW52rhLEXD5ko2lR6fvtEXuyHX/CDxVueTGUYg5ixw9MzpT8= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732036875; c=relaxed/simple; bh=JPe2DJsTvwK+BxZZsMEmNji+XZXD4uKA1ctPwvtUOf0=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Ya/winkQa577nSVTeMhGlLEoy32xi2nrXkLBYZw4o6aEyX5355c6qSd8UviXml88aJPXaLYGFbG4q0JtLnu7spvtI9PbS9nzL/tkdV2scfQTJzduWqt4w2yiFcxrQ0TVF6stKvx2EmRNqR1NE1BCUsxd+1nOyBZF/Ihp5NYx614= 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=khN3K3JO; arc=fail smtp.client-ip=40.107.92.67 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="khN3K3JO" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=ocUyvG9b/mDzGCwEU1WnX5OnEO0UgknzSXw9QEKpkLV+MpagNytxa6C9QaxYKqm5GQpwCi4v0MEpm2xl5dS1hRkKtJZo6k9qcpq/P7KSlHDoBKGMasuUchxboaD5zNOHIGsHqaIJEMd+R67kA3DRcDzeZYtmCgDJ/0XryP2JcvMyyWVt6TW3WqS63MAWHaiwGsecCKosXS8cOqyYkjcfSyBfQ+xPTren64EyWvSjsVRzHTG74BYPS8IKQrB542aKXo4F9Z+0VxLfK8zYuz2MKR7jHeHIGzgRq4KwFSivfefxrQ5reeB7jV904hMm1lT9sz/VtszVC+9gwVTxlhhhwA== 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=zzCFVbPZgYxPcQ1+GhB7cobM6gVHm22OUaAGLwiiReU=; b=BkDAYvRiBY7JyUaIx60tIpmvv73epvM17nESHdmN57kjOqzV8itPO61ssRsCj+8Fiuqa1U6yfPrR64BcoZWpBFSIjL0i1DTdFmJuuHsJPsserp+0iexMIgUMoOzbQjo5k8eROL1QFLs470KX8mPRxPLJ2q4ipI+ima5JqaSFeFuXLQw7b17ZBZjMzju79Ww6HQp3Xap64+T3BEg5EBWVcSDAMXLLr38xkcvDBQ9zBdExxA7dCjAVDgdkcb1ktSLCvj/Jc9yOf8Bwd60OMtmPCR7o4Kshuf/thm+tHhy4T5yIHhrCCurXGveJTAZON1nw+pCScWRy4IoO06VmDer2fQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.12) 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=zzCFVbPZgYxPcQ1+GhB7cobM6gVHm22OUaAGLwiiReU=; b=khN3K3JOkcDQMw58erNZm0NgzHVxfbIvtfp/q/3cRnPG4n5umGgUBf1BTMOrxZbmdpqaEBjv0ep8fhF6Ggkdu+oABGU3RzmW5QYwW1Ha0JgdKXUd0Q3OafckV6/Xzevf+PHmNZXCqk4do3qLPD/f/SUxQxYRDXJ1QigpY6UPIjQ= Received: from PH7PR17CA0047.namprd17.prod.outlook.com (2603:10b6:510:323::29) by PH8PR12MB7374.namprd12.prod.outlook.com (2603:10b6:510:216::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.23; Tue, 19 Nov 2024 17:21:10 +0000 Received: from CY4PEPF0000EDD6.namprd03.prod.outlook.com (2603:10b6:510:323:cafe::27) by PH7PR17CA0047.outlook.office365.com (2603:10b6:510:323::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.24 via Frontend Transport; Tue, 19 Nov 2024 17:21:09 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.12) 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.12 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.12; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.12) by CY4PEPF0000EDD6.mail.protection.outlook.com (10.167.241.202) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8158.14 via Frontend Transport; Tue, 19 Nov 2024 17:21:09 +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; Tue, 19 Nov 2024 11:21:04 -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 v7 05/22] ACPI: platform_profile: Pass the profile handler into platform_profile_notify() Date: Tue, 19 Nov 2024 11:17:22 -0600 Message-ID: <20241119171739.77028-6-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241119171739.77028-1-mario.limonciello@amd.com> References: <20241119171739.77028-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: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000EDD6:EE_|PH8PR12MB7374:EE_ X-MS-Office365-Filtering-Correlation-Id: a5410d8f-e214-4d78-ea3f-08dd08be8f47 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|1800799024|376014|7416014|36860700013|82310400026; X-Microsoft-Antispam-Message-Info: K1psSYPGuzdJ4PrkKJ70Ax5O5+o0HYtVVv7F1kuIsdm6C+vBAY/8FaVV/U0c0wRGeAMNINJvuVSLIhHU/wDmrdktUa1TlN8a7Ij367tl0XIg9R/oBUPbH1HDf9iVp2GOFxH2CqKzo/QvfkwbkyPMBDBPGA/hbvdQWWHamrSwQq1QXzLuX1qBa/WxlZNBEHcsQn7jhiiW6UqJuoGP4LPDXh6dZPgBKKS99WsVXzvVts0m/NFN3WMjFHFVidkpdYtu7qqnwIov//dCpSjHZD27IbjcTwMb59EpKcrWg2QyNf3DNLMwIXDP/9mRLZC/CkgQ+mQ4hPF8gJHHPuPpz8fv2tD65XswujFLyRqOiACjRT7gDR8JllO0nONKJV2mBPmJj4f5VlDHkb1W5R0oGJwXLFlmv5eGMAAC82IqrkmqbtRUVAxUHalJiX3oi8A4Fq7t/jBGm23uSYTKXOEdOPxaBl1/v2NT4kdrmRPUqpgs3ahbdhL5Vx2LwuPGs+Cg757EYHSNoMtdJGJyhmxTQQ2lFyYoRggdblBipjHly+XqxxpGXnLn0keMrTiWuuvyyAbGjbUwao1/kdqJyp25jucp08GSE0glF5fhiWzZAprlrOyB3LEYHb4ZY7gEf3ItKBJbfEmKPhVVOCaBW4sFWAUh9pZjMiORuLj+r6iuzF0njfW7qrfbw/PzWa8jXBwuHUyN4g2/HlKmgFSO2+PGl5RgQgeFVtbqIJ6yYseSXSH+8jbg6NnYiAr0HOjSXBGhjJBUK/braxZ7IC9jGRha4TYIklAhwLOviCe1+iEkY3dxXSxlyNnvBuW5nWkznRuZWCfmi6/5mfQdXRNPGz2KeLCxQpOO5qshaub8kPdXttTw5WKgBBKcsqoI0n9jLR5VlejZ3L2cmFFHXhFF0d2pYp93tj/LcY9IcOCssrM+fcgkSSRC4+S8tbPe+DnnP+95MNK6gzOqHOs2irtLomvlr+9SMBxNyIBozfwPV1tXoXCnbv7S7K8NilDt1GT/VGUbxW3OuHcm49U/dK9YXjsiATPoBXTLjuBtoJddsBHkOfnQN8a9/aNkFlVyDfJKppX25Eva8mLxNqvlFFCnUiFk/5KT0JkhLB+OycKjhDO3gaFSXOTHysYX61O87q9tXSiPc7KHvuJ5u6/p+rgrab6nANhA8muFC5xhAQjuYCZFV43Ea0FklEfV4ZOSIBwZt3nsd5ASZeyIpTjQep0mGQO9UjvGF0fjXOI8dOwCQF1pQDPWCt1QeffkN9faoxwNeSiEJR+JeLguWbXa3BncPC6bEhwo09xrcs1ksvqIxo2Nk+SHsS94SENw+aC763etxnvAxBz2G+p+DNcNKho45DhGyuZ9hf4HVI0J2SU9gnwJ2YKFwT8Q4nWoi23cC/Q3KNWhnvBYUZY+hL0xwYdUyS5kyAn33A== X-Forefront-Antispam-Report: CIP:165.204.84.12; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:atlvpn-bp.amd.com; CAT:NONE; SFS:(13230040)(1800799024)(376014)(7416014)(36860700013)(82310400026); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Nov 2024 17:21:09.3548 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a5410d8f-e214-4d78-ea3f-08dd08be8f47 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.12]; Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CY4PEPF0000EDD6.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH8PR12MB7374 The profile handler will be used to notify the appropriate class devices. Reviewed-by: Armin Wolf Signed-off-by: Mario Limonciello --- v7: * Rebase on pdx86/for-next for asus-wmi change * Add Armin's tag --- drivers/acpi/platform_profile.c | 2 +- drivers/platform/x86/acer-wmi.c | 2 +- drivers/platform/x86/asus-wmi.c | 2 +- drivers/platform/x86/ideapad-laptop.c | 2 +- drivers/platform/x86/thinkpad_acpi.c | 14 +++++++------- include/linux/platform_profile.h | 2 +- 6 files changed, 12 insertions(+), 12 deletions(-) diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profile.c index c24744da20916..927a2f7456c9a 100644 --- a/drivers/acpi/platform_profile.c +++ b/drivers/acpi/platform_profile.c @@ -128,7 +128,7 @@ static const struct attribute_group platform_profile_group = { .attrs = platform_profile_attrs }; -void platform_profile_notify(void) +void platform_profile_notify(struct platform_profile_handler *pprof) { if (!cur_profile) return; diff --git a/drivers/platform/x86/acer-wmi.c b/drivers/platform/x86/acer-wmi.c index b12965d9fcdb7..0018818258070 100644 --- a/drivers/platform/x86/acer-wmi.c +++ b/drivers/platform/x86/acer-wmi.c @@ -1988,7 +1988,7 @@ static int acer_thermal_profile_change(void) if (tp != ACER_PREDATOR_V4_THERMAL_PROFILE_TURBO_WMI) last_non_turbo_profile = tp; - platform_profile_notify(); + platform_profile_notify(&platform_profile_handler); } return 0; diff --git a/drivers/platform/x86/asus-wmi.c b/drivers/platform/x86/asus-wmi.c index 9105b456eab1f..dcda7420ca26c 100644 --- a/drivers/platform/x86/asus-wmi.c +++ b/drivers/platform/x86/asus-wmi.c @@ -3789,7 +3789,7 @@ static ssize_t throttle_thermal_policy_store(struct device *dev, * Ensure that platform_profile updates userspace with the change to ensure * that platform_profile and throttle_thermal_policy_mode are in sync. */ - platform_profile_notify(); + platform_profile_notify(&asus->platform_profile_handler); return count; } diff --git a/drivers/platform/x86/ideapad-laptop.c b/drivers/platform/x86/ideapad-laptop.c index 80797c6ae8b0b..79c65c24b433a 100644 --- a/drivers/platform/x86/ideapad-laptop.c +++ b/drivers/platform/x86/ideapad-laptop.c @@ -1041,7 +1041,7 @@ static void dytc_profile_refresh(struct ideapad_private *priv) if (profile != priv->dytc->current_profile) { priv->dytc->current_profile = profile; - platform_profile_notify(); + platform_profile_notify(&priv->dytc->pprof); } } diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c index 13798c6d5fcf3..8539cac042be8 100644 --- a/drivers/platform/x86/thinkpad_acpi.c +++ b/drivers/platform/x86/thinkpad_acpi.c @@ -10516,6 +10516,12 @@ static int dytc_profile_set(struct platform_profile_handler *pprof, return err; } +static struct platform_profile_handler dytc_profile = { + .name = "thinkpad-acpi", + .profile_get = dytc_profile_get, + .profile_set = dytc_profile_set, +}; + static void dytc_profile_refresh(void) { enum platform_profile_option profile; @@ -10544,16 +10550,10 @@ static void dytc_profile_refresh(void) err = convert_dytc_to_profile(funcmode, perfmode, &profile); if (!err && profile != dytc_current_profile) { dytc_current_profile = profile; - platform_profile_notify(); + platform_profile_notify(&dytc_profile); } } -static struct platform_profile_handler dytc_profile = { - .name = "thinkpad-acpi", - .profile_get = dytc_profile_get, - .profile_set = dytc_profile_set, -}; - static int tpacpi_dytc_profile_init(struct ibm_init_struct *iibm) { int err, output; diff --git a/include/linux/platform_profile.h b/include/linux/platform_profile.h index bcaf3aa39160f..8ec0b8da56db5 100644 --- a/include/linux/platform_profile.h +++ b/include/linux/platform_profile.h @@ -39,6 +39,6 @@ struct platform_profile_handler { int platform_profile_register(struct platform_profile_handler *pprof); int platform_profile_remove(struct platform_profile_handler *pprof); int platform_profile_cycle(void); -void platform_profile_notify(void); +void platform_profile_notify(struct platform_profile_handler *pprof); #endif /*_PLATFORM_PROFILE_H_*/ From patchwork Tue Nov 19 17:17:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 844292 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2062.outbound.protection.outlook.com [40.107.92.62]) (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 7DCEE1D27B4; Tue, 19 Nov 2024 17:21:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.92.62 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732036879; cv=fail; b=ZZcJpsHRh8cGXhg0GjsrVFst9q1W8uxU3lizVBkFtNY4rjAg4AD81ux3FfQAte6D2slIVXKN/EwTx9KLJs97tK6oKPfaRTPDDHl4GPuqfx2JK14z18ZpdjJm5gitMb65wuGx1gct1fCSdF0KV/XiG554viUzJqW/Vvx0IH2dHH8= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732036879; c=relaxed/simple; bh=JewyXTxhFRqy6h34+YKrMpsgMeLgKwlZqckAx0I+7ck=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=tDb6+Xi9ci6KFLohI+lYejQJH7VeZnAhjpuHrkzx8Sdeg04z1QVPf35IwjAq4/x1DnSgXhcp8KLsONaHkdLNsjCW/CfiR1TY8swwQeWh/W29d5BzShC3vBAV5Hs7Ph5LVroj6ve7m3lIWLeasw8tzn9o1fr9uvzLvT5Rc7NmBbU= 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=edfjn6gy; arc=fail smtp.client-ip=40.107.92.62 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="edfjn6gy" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=hUikfqQSy70sVX+2YpY4GE8ND3kaigEJ0BeUz+SCeY3zLGxy2CyhoIjEnzNrazNYoBsor4Yxmg9/fNV5frWpTmSOnG5wIXbW+E7G7mJsSST2Lh6YgTofO906SCl1GZrUGsqnzJu2uLuadLsqmbvWmW8qGKikY3PLA2xfTf2nSYPRlUOVSQkEksUJPF2+67b5FFkTryESzkdtKJqOmBWYsLEp6hpRY5l7fqn8p7TJLs++Hl7RYjeKXTFCfKXRU06cpSnc6/1G5OZah/Dyv4xuNocOUXwTzuenuUs5o7tEHoeDoehXaEGINF3FFbA3gAzzvRxuW9n3JhcamBQIWiQwhw== 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=se/DRSG0jq4mSe3JIlni8+u15VBvik79rcxTvY6iGeE=; b=qh4oE13lfHnjG5ST/HYAaapJDcq5n8FwrbiUJmSXToddL5a7BhrNPRQMmEA+wDcnpSaURV3XEb/JWtPr04+BLDX0u6pwF1HY7phH3MqNGV+7jzL1igE+Q83DinTiN6nhTKgtGppRnThlB7FandwBYBG5msyyPaFvX13VtKn3BVuV0ygWPJKmi0ftyGajwpr9m7e2jRf4rzki47oppMBXhrK6R9mkl+43Cc9dxpKJSoQxYGoQLRpAgrtiV7PUAxIEX5oc3fVLROpvYnCLUdwxSaRnZJYp0fvmW9NlPLFP8xBLu9g9HOF288inFOFLxinZq0Oazixg2gvFf507xoEHAA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.12) 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=se/DRSG0jq4mSe3JIlni8+u15VBvik79rcxTvY6iGeE=; b=edfjn6gy6/zYuhhLkGa1y+/NRlN79wzmD1ZoBvyOryd7MbwLTRAy8HSo7slqCIZeXU/rR+4pvO0ERK7P9HTyF4TSo6FlBkhNkKJkrkxM91i1plbElgQMCsjTC6E04UAvCeHM6Gix5jMKOVUWQ9DJxkUmikyig+cvehTq2MA3ceA= Received: from PH7PR17CA0041.namprd17.prod.outlook.com (2603:10b6:510:323::24) by DM6PR12MB4219.namprd12.prod.outlook.com (2603:10b6:5:217::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.24; Tue, 19 Nov 2024 17:21:12 +0000 Received: from CY4PEPF0000EDD6.namprd03.prod.outlook.com (2603:10b6:510:323:cafe::32) by PH7PR17CA0041.outlook.office365.com (2603:10b6:510:323::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.23 via Frontend Transport; Tue, 19 Nov 2024 17:21:12 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.12) 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.12 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.12; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.12) by CY4PEPF0000EDD6.mail.protection.outlook.com (10.167.241.202) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8158.14 via Frontend Transport; Tue, 19 Nov 2024 17:21:11 +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; Tue, 19 Nov 2024 11:21:09 -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 v7 08/22] ACPI: platform_profile: Use guard(mutex) for register/unregister Date: Tue, 19 Nov 2024 11:17:25 -0600 Message-ID: <20241119171739.77028-9-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241119171739.77028-1-mario.limonciello@amd.com> References: <20241119171739.77028-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: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000EDD6:EE_|DM6PR12MB4219:EE_ X-MS-Office365-Filtering-Correlation-Id: 976cc9e1-d22b-4d36-4ffd-08dd08be90b2 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|376014|7416014|1800799024|36860700013|82310400026; X-Microsoft-Antispam-Message-Info: =?utf-8?q?THUgSlGfXQLaydNARwUSfYXWnr/WJjC?= =?utf-8?q?1OM427arTHqTj1k03ZJDUlvm7bOiiQq9/4VZgAHsD5PlQUdFkZJFf0xIdQWk0dYsa?= =?utf-8?q?1EyhstFRHI6PUVAPr7sH7riYUqdGR/Q2Re2I/GkYGFhfll9GtmcvuV+wOQOsOUX/W?= =?utf-8?q?dAJt62bF5EbiGifsI1sIciIMfYQeecI1uSpbptZkrP6gsqpRzgPkmjAhmYUxRKc+z?= =?utf-8?q?y35sZG0Vr/vHcVQAAzY9g9Vu3PstUpbJuQwrjDUsIZkC3qHJ0OgUb1wzVqrCq8srZ?= =?utf-8?q?I/OyzMQOnwyhax++ybbyouEprxBAv2Hp03I3eQWdDDG6VMzRith49u38Yffh0XFIx?= =?utf-8?q?pClXsKw+mEpghDxXRdlKHKAQzW+q8euI7QjcN4/7DtXrdcYlvtrngxsD6I3C1XF2y?= =?utf-8?q?BQWHeT9hB7WZUxNmP7KiihFtvdQmPN8U5XtUqKS8r+b+wAhud30J6duVf5XeAmUoU?= =?utf-8?q?DNpNvK42Ge+iW8yTBlBg7EgRkwf1luWfYePicsl6a3zTNfDX6HCAWykf1eYTzdoYl?= =?utf-8?q?Km5uHSj/JS54ZY7nDxMmC6q+z+Vf1K8jC+Px5yD6hZAbe8Av3HrybcyHbPX5iK34Q?= =?utf-8?q?PTjyrzpmA1cJxYDNdgrRo52JIpkCQW42j5GswPFvsH/QkxANynXaGq7MtlHEh0bNr?= =?utf-8?q?3vmGaYmH2tFTGUQz4KDei82zZvLDZkdKM+H/viGe7CkAYUFalc76LUR6MjmkFRbzh?= =?utf-8?q?yRmKMvxaWuPO7PUpEm+9e3xsYt7AMCBiBK6Arpzv7Dv19pC2UsfBP5IU9oUtXjcBI?= =?utf-8?q?F6BCvD8zLnhxLZBrlJG7gLELNHVlwiY5WBrDky/GNiI+dPlLLePk1122AIN/kyqg3?= =?utf-8?q?DZr6a3KpdtM0wHTokvKzHpg+s3/jeQntcnPvayrFaBTpJMmHedtffm2xI9pMrc9jW?= =?utf-8?q?td+mqSa1h92wnLd9Y1antt24ID8JcNCBOdkzFDoFKsoFr2T0xNODZPSdt9xkADDJj?= =?utf-8?q?JdQkB3/QjhKmeusos8QQjEJBrYfplUdom7CXbzF3EAMK7ThpPGs1m9c66o/A9DWjV?= =?utf-8?q?OZ1caU8IXqL3uFsmFa7uP1IPa8JrXMophK1tbq+1RAMqWWs/34MWIhvhoY5eq4iJd?= =?utf-8?q?A/RdX0ke2CA9ZbrTt5cNOo+/C+hxx8eyFRM/7p7DiABKJZTpcMQOuu2ZNIHsiwqgs?= =?utf-8?q?B68Wa4thWhAqfoWpgmgXnS2I2faYML59+HSFQ3BIZNLfv3+ZxNoiwNheD907PW7xq?= =?utf-8?q?JwoO2Niqr6cqfXl8SGdEid2vtHT3admu382aYnMMDEW8iEqolwbQDUdgbtt1puhmi?= =?utf-8?q?6+YsOBNUbeu3IU3PPqcdJdR9YXRtWwqwGBBSj6eRQjF0rqMbzEEni8PnLR1ncNSlD?= =?utf-8?q?Vncaft90bFMQmoLs+Bj8bZblLtC+U6AAQQ=3D=3D?= X-Forefront-Antispam-Report: CIP:165.204.84.12; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:atlvpn-bp.amd.com; CAT:NONE; SFS:(13230040)(376014)(7416014)(1800799024)(36860700013)(82310400026); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Nov 2024 17:21:11.9173 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 976cc9e1-d22b-4d36-4ffd-08dd08be90b2 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.12]; Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CY4PEPF0000EDD6.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB4219 guard(mutex) can be used to automatically release mutexes when going out of scope. Tested-by: Mark Pearson Tested-by: Matthew Schwartz Reviewed-by: Hans de Goede Reviewed-by: Mark Pearson Reviewed-by: Ilpo Järvinen Reviewed-by: Armin Wolf Signed-off-by: Mario Limonciello --- drivers/acpi/platform_profile.c | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profile.c index 45ffd85a71dd5..9729543df6333 100644 --- a/drivers/acpi/platform_profile.c +++ b/drivers/acpi/platform_profile.c @@ -184,32 +184,26 @@ int platform_profile_register(struct platform_profile_handler *pprof) return -EINVAL; } - mutex_lock(&profile_lock); + guard(mutex)(&profile_lock); /* We can only have one active profile */ - if (cur_profile) { - mutex_unlock(&profile_lock); + if (cur_profile) return -EEXIST; - } err = sysfs_create_group(acpi_kobj, &platform_profile_group); - if (err) { - mutex_unlock(&profile_lock); + if (err) return err; - } cur_profile = pprof; - mutex_unlock(&profile_lock); return 0; } EXPORT_SYMBOL_GPL(platform_profile_register); int platform_profile_remove(struct platform_profile_handler *pprof) { - sysfs_remove_group(acpi_kobj, &platform_profile_group); + guard(mutex)(&profile_lock); - mutex_lock(&profile_lock); + sysfs_remove_group(acpi_kobj, &platform_profile_group); cur_profile = NULL; - mutex_unlock(&profile_lock); return 0; } EXPORT_SYMBOL_GPL(platform_profile_remove); From patchwork Tue Nov 19 17:17: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: 844291 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2047.outbound.protection.outlook.com [40.107.244.47]) (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 1A77D1D4333; Tue, 19 Nov 2024 17:21:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.244.47 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732036884; cv=fail; b=b9UgT1LZAmDa8grCv/FW7NnDkFr9Gt7uupKQOE1EpK4QXa1NeOpltd/r89wfEWD/rkc3i2dBObjaFJKsZlndcB/OK1TX45aCCkdnEiYlqQ9iHG277ml0jjDmDP7XkFTceBFh1JVLmtfa597HUTCDBxwpW1j1aUZAw48BeQ89TwU= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732036884; c=relaxed/simple; bh=wBQDnDbMvL1S6Enbnu3r7J+KMcdaAx15fZAfucZABb4=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=umuDAJkoDNPRwDhVRdJO2o8PhrMezLzkzP2IlwKJlNOqAoXN/oXJBgG6JvecDU1epKMFqdfvtWr/1oPHGvnR7I1L8PzRnzwnA+NvhFTJxo1YxIUuBeE730hOoR4PSJjF+WKhP6NRPSAMpEv1Rahd6GwPNvqjrBEByxTozlMGQoM= 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=KqVVD9xL; arc=fail smtp.client-ip=40.107.244.47 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="KqVVD9xL" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=bnrcqd9EkW5EWBjMweGi7Byig0ANUSrToCtmYZmMax6xfLx8QcJZJo1RPTk+xJft4+cO0cDWrUnxGYfdS5SFgZhqz1eYNmewQHCpfJZ8EC+nUzwaWPVkOOlygjOqyJr8c2rrzeTyTl9lWyYeHWSFfg/mNOHbm4Y0mcG6xBWLDWBbWXmXnMlidvvdDgtq1R1Ao0r/BH095/+E7jbBbCVrPopStodQ0FSiXoqeWDI78jZnOKQckj4gDjJxSROyyvK629zvUAREA+OZmn79QbXBZswybhoy1eH5haAtETHyrgw1nnlX9/IWY17zWF/JrXHPRmYxfaFfIAKh2Wwf4Mk2yw== 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=K8DYtwULlzPhvvL2ryCL3gCt0hyAcSnLlGYhblzyqNY=; b=Zfk22G2iKsrA/y38+U1j9V8TDGY5ihLXdz/9RTfBgjdQtKxAwLmq38BOAuzIjtjEXI0hhChJs279qOP8ZfQkQSKuZgRohRdgY9qwsf7eWiNrrTe6BDC9HW/uhbSz8v0lcwbG4QEIknQBPfg9OsygoqPQvqSh1a++ynjzYcIdFROBZydf8fxYPNoa7LHGaZEzaMFbmhzQufg2aCUumqO9Nqinpbg+QNy8oVldHMIqTJY86Uj/n/5yiQ0JI68/sKdpCvDlaqjz3Jl1IWOer+w9b8F6aggk1e3Loq9q8GZVhOrOxealF5q5DTs5YqWPx68g+gj99VRLex7V62osv6NHrQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.12) 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=K8DYtwULlzPhvvL2ryCL3gCt0hyAcSnLlGYhblzyqNY=; b=KqVVD9xLQUjWcypc3wAKeu7XLZijtkDj66chsuEM4Iz5gE51kCnr2hF7hXWt0gA6MFpLL5QtvGqVch3QgM8dT1AyYsSSxlwwL9lkKX0QeqzzcHQwEO3GiF3JbmNl/x9vRSbc7HHXijVpYeNngXiPmJEcUoh1s+clvCjxzTAEYtk= Received: from PH7P220CA0051.NAMP220.PROD.OUTLOOK.COM (2603:10b6:510:32b::13) by MW6PR12MB9019.namprd12.prod.outlook.com (2603:10b6:303:23f::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.22; Tue, 19 Nov 2024 17:21:18 +0000 Received: from CY4PEPF0000EDD0.namprd03.prod.outlook.com (2603:10b6:510:32b:cafe::8a) by PH7P220CA0051.outlook.office365.com (2603:10b6:510:32b::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.23 via Frontend Transport; Tue, 19 Nov 2024 17:21:15 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.12) 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.12 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.12; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.12) by CY4PEPF0000EDD0.mail.protection.outlook.com (10.167.241.196) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8158.14 via Frontend Transport; Tue, 19 Nov 2024 17:21:15 +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; Tue, 19 Nov 2024 11:21:13 -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 v7 10/22] ACPI: platform_profile: Create class for ACPI platform profile Date: Tue, 19 Nov 2024 11:17:27 -0600 Message-ID: <20241119171739.77028-11-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241119171739.77028-1-mario.limonciello@amd.com> References: <20241119171739.77028-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: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000EDD0:EE_|MW6PR12MB9019:EE_ X-MS-Office365-Filtering-Correlation-Id: ed8b494f-42ef-47ee-a6cc-08dd08be92ef X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|7416014|376014|82310400026|1800799024|36860700013; X-Microsoft-Antispam-Message-Info: wlgWGg6OeOf3IA7LIOZ6Q+FzSj1hPmCenMoP1ZpKu3PtGOQGhvGyPDgxuYFnsk4T57+G0MKRfGmrOx6q+NkbaaREjbxNKYTdadF+hapNm3Po8Woe/dOZlTPinWpmenVXVURo9/kjXv7vrUw/U9zwRwnBEk5lRpMS8tUQXDdvF5rlC9p/tlmgulogdCpiGR7nW5qg6O8eR0eMrwALhL3YVkjjAylJWG9o5OOWzVVbcK3Y0Q26dOZZ6iH6RaDQbG5Sn9CA0x5Idp1JS4UPxsJCiaA9jFdsnJ0Br3CYRX9F1iD57iRcRznhOnltmNwyCMHQNps6Yrg1++qk34X87/uNV0XZaCAmsj0R/rs9FWJvc0miCuX0DLGVCtcXv3FhMC+12cT0kPWdiXtGLFjvftk0QrZLzqMZrELTVXn8DuqwjQ43a2JDakiIBjKCtJuQwCCWoN6TH6TExC0Z96f1g7Msd71JcuXd6Pc4+96ZhUGZ38Tu5BIB6XBzbHfs3tkzjoD8DUrIK1dRNlP3jm3cbDoe+Mz/ahwaZingbmIrRPs8lh8OBzsKUjtRSh6c/mkBte657PRMgFFJHh6UZRcl8aUXydBllMB4k40bDpjWmGwbiepxMJGT2H8cp9Ihrc1KGIKd8TesztkyTWKqMQgsB8QGYc/5t10GFfINt/YZunoCFN0r0MDTZ42eIZ1/UqP75VdmD/c/y3jEwNH17lLdEimNPHTNU6kCPn1PaUmVvsn5lz/ldrrP/0Eb07tx+XT1VJBHrpQtIMm4Rz6qgHBSrQ6IFaOe8vtUBrIyA2/nDQ5lHwuQ0G3G8TLA7Kqx5K8t08erPgvpgRUlIBCj8TRC+CDz0zSEJFdQmcACBUON4YHGbD4EKBUoSr+QqLJEc8VQcaC/1+unTXHMvbT+JMFrb5pUFZLvmXh959W3vbLUNZCBUaFitV47lO4Wy2BlH6HPKThVhkzptK2y8EUsPZ5udllL6ubXAe1HaHCCYe45mvlNibURdzeg00U+eJ2ogfXmkQwvFAYJs6tzHWp9QIC2xumm16/27Z/Bx1whXn/MsNmc2OIjwWjzhEaZOYkARu1TLaER7S9kOVcw9fVTOpP85gDVQuK8EMu3RXvDCXN3T68Q1TnDtCWudHut0uaR4tZlW+qg0UTZkG25aTIPifFH6QQH1vB98rWT6s+xkRpG09fmFdtGPUV3D7txMNujYY0/Met6/jN8YOot0SpGQbvUKDwsinJyvD7SkYE3IjE9AQBUQoAphPcUQ1F9K5MeLU7fMbRGdd609zXY5VqvxgxoRwvNAe5SJCc0mq4lHCB4bvYvYidOwrujKKoQ07ukNmDKGObpQtZpLOYq4RTOOq45qGpzOonzrOEfRL82AKEBIiFjeXTDW+Jj7SXggeKZxNedji9indnrQuyqZ+HC2BhkX2cKzw== X-Forefront-Antispam-Report: CIP:165.204.84.12; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:atlvpn-bp.amd.com; CAT:NONE; SFS:(13230040)(7416014)(376014)(82310400026)(1800799024)(36860700013); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Nov 2024 17:21:15.6435 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ed8b494f-42ef-47ee-a6cc-08dd08be92ef 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.12]; Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CY4PEPF0000EDD0.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW6PR12MB9019 When registering a platform profile handler create a class device that will allow changing a single platform profile handler. The class and sysfs group are no longer needed when the platform profile core is a module and unloaded, so remove them at that time as well. Reviewed-by: Armin Wolf Tested-by: Mark Pearson Signed-off-by: Mario Limonciello --- v7: * Whitespace * Add tag * Drop class_is_registered() check * Remove legacy sysfs before class v6: * Catch failures in ida_alloc * Use 4th argument of device_create instead of dev_set_drvdata() * Squash unregister patch * Add module init callback * Move class creation to module init * Update visibility based on group presence * Add back parent device v5: * Use ida instead of idr * Use device_unregister instead of device_destroy() * MKDEV (0, 0) --- drivers/acpi/platform_profile.c | 86 ++++++++++++++++++++++++++++++-- include/linux/platform_profile.h | 2 + 2 files changed, 83 insertions(+), 5 deletions(-) diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profile.c index 32affb75e782d..3524a2b4618ed 100644 --- a/drivers/acpi/platform_profile.c +++ b/drivers/acpi/platform_profile.c @@ -5,6 +5,7 @@ #include #include #include +#include #include #include #include @@ -22,6 +23,12 @@ static const char * const profile_names[] = { }; static_assert(ARRAY_SIZE(profile_names) == PLATFORM_PROFILE_LAST); +static DEFINE_IDA(platform_profile_ida); + +static const struct class platform_profile_class = { + .name = "platform-profile", +}; + static ssize_t platform_profile_choices_show(struct device *dev, struct device_attribute *attr, char *buf) @@ -105,8 +112,25 @@ static struct attribute *platform_profile_attrs[] = { NULL }; +static int profile_class_registered(struct device *dev, const void *data) +{ + return 1; +} + +static umode_t profile_class_is_visible(struct kobject *kobj, struct attribute *attr, int idx) +{ + if (!class_find_device(&platform_profile_class, NULL, NULL, profile_class_registered)) + return 0; + if (attr == &dev_attr_platform_profile_choices.attr) + return 0444; + if (attr == &dev_attr_platform_profile.attr) + return 0644; + return 0; +} + static const struct attribute_group platform_profile_group = { - .attrs = platform_profile_attrs + .attrs = platform_profile_attrs, + .is_visible = profile_class_is_visible, }; void platform_profile_notify(struct platform_profile_handler *pprof) @@ -164,25 +188,77 @@ int platform_profile_register(struct platform_profile_handler *pprof) if (cur_profile) return -EEXIST; - err = sysfs_create_group(acpi_kobj, &platform_profile_group); - if (err) - return err; + /* create class interface for individual handler */ + pprof->minor = ida_alloc(&platform_profile_ida, GFP_KERNEL); + if (pprof->minor < 0) + return pprof->minor; + pprof->class_dev = device_create(&platform_profile_class, pprof->dev, + MKDEV(0, 0), pprof, "platform-profile-%d", + pprof->minor); + if (IS_ERR(pprof->class_dev)) { + err = PTR_ERR(pprof->class_dev); + goto cleanup_ida; + } cur_profile = pprof; + + err = sysfs_update_group(acpi_kobj, &platform_profile_group); + if (err) + goto cleanup_cur; + return 0; + +cleanup_cur: + cur_profile = NULL; + device_unregister(pprof->class_dev); + +cleanup_ida: + ida_free(&platform_profile_ida, pprof->minor); + + return err; } EXPORT_SYMBOL_GPL(platform_profile_register); int platform_profile_remove(struct platform_profile_handler *pprof) { + int id; guard(mutex)(&profile_lock); - sysfs_remove_group(acpi_kobj, &platform_profile_group); cur_profile = NULL; + + id = pprof->minor; + device_unregister(pprof->class_dev); + ida_free(&platform_profile_ida, id); + + sysfs_update_group(acpi_kobj, &platform_profile_group); + return 0; } EXPORT_SYMBOL_GPL(platform_profile_remove); +static int __init platform_profile_init(void) +{ + int err; + + err = class_register(&platform_profile_class); + if (err) + return err; + + err = sysfs_create_group(acpi_kobj, &platform_profile_group); + if (err) + class_unregister(&platform_profile_class); + + return err; +} + +static void __exit platform_profile_exit(void) +{ + sysfs_remove_group(acpi_kobj, &platform_profile_group); + class_unregister(&platform_profile_class); +} +module_init(platform_profile_init); +module_exit(platform_profile_exit); + MODULE_AUTHOR("Mark Pearson "); MODULE_DESCRIPTION("ACPI platform profile sysfs interface"); MODULE_LICENSE("GPL"); diff --git a/include/linux/platform_profile.h b/include/linux/platform_profile.h index 8ec0b8da56db5..a888fd085c513 100644 --- a/include/linux/platform_profile.h +++ b/include/linux/platform_profile.h @@ -29,6 +29,8 @@ enum platform_profile_option { struct platform_profile_handler { const char *name; struct device *dev; + struct device *class_dev; + int minor; unsigned long choices[BITS_TO_LONGS(PLATFORM_PROFILE_LAST)]; int (*profile_get)(struct platform_profile_handler *pprof, enum platform_profile_option *profile); From patchwork Tue Nov 19 17:17: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: 844290 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2088.outbound.protection.outlook.com [40.107.244.88]) (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 BC2751D5171; Tue, 19 Nov 2024 17:21:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.244.88 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732036885; cv=fail; b=PpEcYveasg9/eRpZxZtt/jo5LTVUunfW7mihMiZlg4MbSAfrjcYfnQxDnuzvld7s1dE0JL04aViPxh6Agg4I15sDhFycqbj2S+v1X9wPNeKKcHpz+MH9HjrRg49aSflwukj42V/K7p+jVusGEjbOXHE2cg7wD5icSF3eAnRMwDM= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732036885; c=relaxed/simple; bh=snLFbEnXBKQVGlUks73lyegCvX770SSCXi1gKbSURZI=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=pSiMGVkc+BKS6C+WObsErWhNzyGdC6zE+7QZMBDbezd+VShYleZPsyP9vrrcMC5rHQsLPv2n3enz3WqjRH42++jOSDys5VIuQjSLydbk7DOzCn1ZRBac62RmfMMEOqD3A5Si2uirEEfDzqv6XFeASm5N3rnVyNCogbMewo9FWVI= 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=2QP6FQ2J; arc=fail smtp.client-ip=40.107.244.88 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="2QP6FQ2J" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=FT1ND2OwNEh8HOPE8dyCM70ZUmqb7OimJCkQM6eWB9cOVxWsw5WwjzjaUjRcchc/0VqN0biuO0U4JTeWcTwitOuej3g0GiWJkaX8EPzG6X7gVooC8+s0bZCwwpECZ5vfCgNk+BCWMdw1964lyYhgUkE6DLCWP9vI5jK5efp0wQBKb7CRnfyZWgoHtUMHUdTQFGARP6/uE0F80lrcYPn6kpQTyPGQLSnQGlHTUdQJqeYC5SEsx44PAWnMOWjWd2qJL2jACvaZ5u0HH+Yoku/pxWlWl/3dpskaH9fMocwcP38rFg7mDu8olRAWOEXbvWw3dosut+vHic4jnx7+nVg7EA== 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=mFeIu1OOy7NmI9v4XrT9b1Rd6G/IHgfIrbo7n8grD+A=; b=UjzmNPl4hgdWmVp+X6PYrS6zCHf7+yhPkKoOcFwmnpd4dhIwkhnDeQBcW7GLxYZ67N3ejyk+qtsHYVBUpf+KsPLRctrvrP1w0K4feFNqqkfwnQ0bHQHBp148sk2drq7WqcBW0CMUL4umWE+OL0Wwce36mkxd8Q6Ef7TK+bdOqwCoJXdSmN2XuEjIo9a279eAhJFtCf7GvaSUmZKkR+ryJ60ZaD8Z0vJA9B+HGYRxm6jHMnhHlEmcB2KC9BADvN0GdyMYNSLJGAkwkBJhgr1Ap7DpF5Uqkuuz3HeegaCQWlWbHVhiX8Rw9Ixu4zzQzyOQ3m/j8jCG8H2odjhty8xldA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.12) 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=mFeIu1OOy7NmI9v4XrT9b1Rd6G/IHgfIrbo7n8grD+A=; b=2QP6FQ2JWXZVeQR/eUaL9qUENyMi4P0lyXDD6/rgrycdaz2nm0WgjFFX8wpH5si/TH7E+v8wFu6EUP42lr/Jd03EOPIEMj9W+Z2QA39LeSJl2oDU4fpatKxk20x9UNFO/UiukQXD/Xc+lhnrJTq9A2lrAum/ME9S+qn/VYb53k4= Received: from PH7P220CA0040.NAMP220.PROD.OUTLOOK.COM (2603:10b6:510:32b::24) by SN7PR12MB7450.namprd12.prod.outlook.com (2603:10b6:806:29a::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.22; Tue, 19 Nov 2024 17:21:20 +0000 Received: from CY4PEPF0000EDD0.namprd03.prod.outlook.com (2603:10b6:510:32b:cafe::be) by PH7P220CA0040.outlook.office365.com (2603:10b6:510:32b::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.23 via Frontend Transport; Tue, 19 Nov 2024 17:21:20 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.12) 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.12 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.12; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.12) by CY4PEPF0000EDD0.mail.protection.outlook.com (10.167.241.196) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8158.14 via Frontend Transport; Tue, 19 Nov 2024 17:21:20 +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; Tue, 19 Nov 2024 11:21:18 -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 Subject: [PATCH v7 13/22] ACPI: platform_profile: Add profile attribute for class interface Date: Tue, 19 Nov 2024 11:17:30 -0600 Message-ID: <20241119171739.77028-14-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241119171739.77028-1-mario.limonciello@amd.com> References: <20241119171739.77028-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: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000EDD0:EE_|SN7PR12MB7450:EE_ X-MS-Office365-Filtering-Correlation-Id: fca57492-3cdb-42e0-155d-08dd08be95a3 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: 1F8i2RiYQdZkgKUe4hlTAKekSF4azYoMAH7PgjH2D44YAFHm1OK5zADlDRSkwxn3TADopUH5gEpCVzTqPoE9hOOToGjC6dRyKFI1NpqJi+8Jk37B9SUsUlx4HGeZ0L0bfLFSG/Rrg9bK1BUrC0HHAf4h9Ktu8ICriK/9+tYAN/B4SKHuK6PjIxQCKOVgZ2e2IjLmTT2DmeDKae+6AmNkp/orYysqrKuOh5RDE6mZ4xyGrJieEpFMSR2eZgUQmOG4+aGNMsLsFRfn9HVD4ZnJ/5w4RVgd2HomVlbbxOoxrhQcb/iOo5+weT39eLhe2W/X2VBN4FXHYhOf2LGi7xov8i1Dr2GxEvwCeXwiAql+CXmfeSXbxdpi+IHz8jJw/rhdNIJyV6zWyUOM6TZop2U84OR8gxZMRLdtbFvhsxV9SwaqreNqB7N9zIojirsuTBeYMai52XXRqjCncAvwCJZxgODDhZBAYTwsZnfQaaRGcKbjc9oB00Q6pv+9KuPZnuznyxtvAPWqHAftC8rTulSwPUtQqqXJ9xuSVzZ1tVKNBe8Ts8I0Rpt3q/Sk2T+g8pbyJhny7beGTVbNQUErV0Ggwbb6enF+8Z0EVTKpIUFuNFR7epApk0S7fzM66TDt/JCHrZQTMWs5c3TC73bg/n3uNPCt17xY9w6DK2T0Y1zH/nxL7YOFtKdgvXrqgRNSobzMFFxOXNpKrwI1rFp28nj717cnpQVfV/awNScJgaUmDlVegei0XbQws3ZP+PjX4tvWTTx4iUIbczc8lWGzjFgptuwNzmTjHVDZlgk4PkvYTGqowm2A7MfwACtCwRIXZ9I8JAJyqeAptkMx7PPUDlgzMwMNtQtF1e8BMkLZZmiYCCPg5n8oGKvYX0P2bbhnDyUCE8XnJYcqDr6At5X+HmBqv50/FM0xps/zNnQKbn2h85sFuKZ6Mq0QDeCPuxMVX5zz0GQJ22L/+RCFgrYNMd4NiiZzcf2EKDDWSakOkpQ75FXY7EwSaime4suLsnwH7uO+nENgsw3YqmtpqRFjTVwaRbJlQ0ocXkuKvti5JqG0bze7stCY73CMn1bQnTd5aidrylzPJIznTJSXOzWcTlpdijOX9FcjveBClvOzDbxnf42JVLTftU1SEkETxz9Mpv4LBsNubccDOnu0dUOb24q3ZPxfO19/8HjaWasJQrwNacYDOU6OZiNZczSCCVPEb/S1u80lI5TLxF7G0RB7vsX0DX9by4QcFukwa7/aUUu30M2UBSmmCiEHt2NYHtquv0EndFzmnn5CjJHW82YNJuPM3ZWeK2CvTr5BjEAvnKsJheAyDMLk+SSCouiwmNMgub3dH3HvnU1KtJB9aahekw4Ujn6PDa9Cx0j8ixVIth9Dind+U09Xbdpddgghyk6ym5GZ40PsbcYtkNtG89h8iuylIg== X-Forefront-Antispam-Report: CIP:165.204.84.12; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:atlvpn-bp.amd.com; CAT:NONE; SFS:(13230040)(376014)(7416014)(82310400026)(1800799024)(36860700013); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Nov 2024 17:21:20.1903 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: fca57492-3cdb-42e0-155d-08dd08be95a3 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.12]; Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CY4PEPF0000EDD0.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR12MB7450 Reading and writing the `profile` sysfs file will use the callbacks for the platform profile handler to read or set the given profile. Tested-by: Mark Pearson Signed-off-by: Mario Limonciello --- v7: * Remove extra handler set * Remove err variable v6: * Fix return v5: * Drop recovery flow * Don't get profile before setting (not needed) * Simplify casting for call to _store_class_profile() * Only notify legacy interface of changes * Adjust mutex use --- drivers/acpi/platform_profile.c | 100 ++++++++++++++++++++++++++++++++ 1 file changed, 100 insertions(+) diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profile.c index 9d6ead043994c..1530e6096cd39 100644 --- a/drivers/acpi/platform_profile.c +++ b/drivers/acpi/platform_profile.c @@ -46,6 +46,52 @@ static ssize_t _commmon_choices_show(unsigned long *choices, char *buf) return len; } +/** + * _store_class_profile - Set the profile for a class device + * @dev: The class device + * @data: The profile to set + */ +static int _store_class_profile(struct device *dev, void *data) +{ + struct platform_profile_handler *handler; + int *i = (int *)data; + + lockdep_assert_held(&profile_lock); + handler = dev_get_drvdata(dev); + if (!test_bit(*i, handler->choices)) + return -EOPNOTSUPP; + + return handler->profile_set(handler, *i); +} + +/** + * get_class_profile - Show the current profile for a class device + * @dev: The class device + * @profile: The profile to return + * Return: 0 on success, -errno on failure + */ +static int get_class_profile(struct device *dev, + enum platform_profile_option *profile) +{ + struct platform_profile_handler *handler; + enum platform_profile_option val; + int err; + + lockdep_assert_held(&profile_lock); + handler = dev_get_drvdata(dev); + err = handler->profile_get(handler, &val); + if (err) { + pr_err("Failed to get profile for handler %s\n", handler->name); + return err; + } + + if (WARN_ON(val >= PLATFORM_PROFILE_LAST)) + return -EINVAL; + *profile = val; + + return 0; +} + /** * name_show - Show the name of the profile handler * @dev: The device @@ -77,12 +123,66 @@ static ssize_t choices_show(struct device *dev, return _commmon_choices_show(handler->choices, buf); } +/** + * profile_show - Show the current profile for a class device + * @dev: The device + * @attr: The attribute + * @buf: The buffer to write to + * Return: The number of bytes written + */ +static ssize_t profile_show(struct device *dev, + struct device_attribute *attr, + char *buf) +{ + enum platform_profile_option profile = PLATFORM_PROFILE_LAST; + int err; + + scoped_cond_guard(mutex_intr, return -ERESTARTSYS, &profile_lock) { + err = get_class_profile(dev, &profile); + if (err) + return err; + } + + return sysfs_emit(buf, "%s\n", profile_names[profile]); +} + +/** + * profile_store - Set the profile for a class device + * @dev: The device + * @attr: The attribute + * @buf: The buffer to read from + * @count: The number of bytes to read + * Return: The number of bytes read + */ +static ssize_t profile_store(struct device *dev, + struct device_attribute *attr, + const char *buf, size_t count) +{ + int i, ret; + + i = sysfs_match_string(profile_names, buf); + if (i < 0) + return -EINVAL; + + scoped_cond_guard(mutex_intr, return -ERESTARTSYS, &profile_lock) { + ret = _store_class_profile(dev, &i); + if (ret) + return ret; + } + + sysfs_notify(acpi_kobj, NULL, "platform_profile"); + + return count; +} + static DEVICE_ATTR_RO(name); static DEVICE_ATTR_RO(choices); +static DEVICE_ATTR_RW(profile); static struct attribute *profile_attrs[] = { &dev_attr_name.attr, &dev_attr_choices.attr, + &dev_attr_profile.attr, NULL }; ATTRIBUTE_GROUPS(profile); From patchwork Tue Nov 19 17:17:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 844289 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2050.outbound.protection.outlook.com [40.107.93.50]) (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 4720A1D63EC; Tue, 19 Nov 2024 17:21:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.93.50 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732036887; cv=fail; b=P7KlMuPbRej0bpJkxnUYqZMJRSFtZGr/GnDzkyjc8J61LL2nVU5dCoGRLKdFlw4Tz/3livyDOj0nku382QGindcL8q99xgB5M5crdkozBi0wKIUArxe4JlgMMWd7rdThaQIg/duIBZXFXLvgAbZs/bII287vHdW/LOj2DFZw54Q= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732036887; c=relaxed/simple; bh=31AW3D7L+1fTsGrX8PR1c6Lzz+tYtEk1o1RenZxATmM=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=M3rItJOlE7XDWjHYfoHPl2a0s4RGEOGTBx++VKD/Lqe7BjR7FmiG6Q6id4Cjc8GllWldy3vbQipGCHpzo5KnZgnT9UdR49jDcb3nOFbBnCrScqHpnz6JEhDKLY/7PQ7Pi0ZI8N9irTsAwh36EihuvkC4XRAbksgX6XKfWpiWxwI= 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=ZvM2T3RL; arc=fail smtp.client-ip=40.107.93.50 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="ZvM2T3RL" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=pT1JQqNYKf0s9/nMqtWZZV4zlAuTeVsKE8V01VctW9T0XKAUcUcUmyMyPkoAEmxP9FciqPsbTi3No6dbMZXqx6nKT9Sp67LT6X7R+xN2KFQB/1f/SfsAD8MwleSa77jTUsMDnBi62fxK5l2Zu+f+7lAJoQhU7UJXxL24av53J8voAIkU9/mZIfPbG6mITiMB5a4apttgPpnsXd5cNxtDHrL6clDOTvGV30ZOZd7LKp0GwHGCCoc5W+eCFQHWLL6QR9/iLpC5hHQPLMam4JF7ONm7mkS5IHv6nqKD1ddEWw4+S495D5GrbgGu7+BE9F8UiJWYLzUx+cZLblfoxWRqnw== 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=gCLCYYN6yRq3E/e6+tiqhvpUaO+kwcSxOCVD3v5ilIY=; b=Qqin2O4eLCd45Lc3ZhB5IiFFnLkTRm4Ep5uX41kSkubRN+9JnOqAAfAy9RE7j0K+O+pNgmZNW2dXUJXgiNwA7nUdW0CEjt4rQmTu9873thwX3Q1FNwXMTStkJLYANAXJllUvAENtYqTLj/J66vbD1Hgvsb4ZROM5wDaZ0UoKCiWd0EmqMC776VaJbuD2yW/B+SNKOpPVZsJY4ripM7/T9uPUZS32Vfs5puIcAbXJ0ww0N0eEelpea4vU5xjM39h3aL+iVXan+DtW1tA2MCJ/z/mY3fLVe54IdF38qJTCiLL/C57w014F4NO6rV1FuYwkUCkVnwLqqEwR/VDVkGPKBg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.12) 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=gCLCYYN6yRq3E/e6+tiqhvpUaO+kwcSxOCVD3v5ilIY=; b=ZvM2T3RLV5khqQuXDTgL/G9La0mrU/kB2Tuqv1CfR6XPiVgtQLti6wlXrgDvYjw+RgInQHRGFcyOhe5rN5qgW/7EGB88TmTYAeIUm51romHqPbzthqs5WQUqqYIrlJq0ZkfSeTo6jNOpiQ+N6Bq+30IRPp+FQ9VxXqa0Y8cVwPA= Received: from PH7PR02CA0009.namprd02.prod.outlook.com (2603:10b6:510:33d::11) by CH3PR12MB8994.namprd12.prod.outlook.com (2603:10b6:610:171::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.24; Tue, 19 Nov 2024 17:21:22 +0000 Received: from CY4PEPF0000EDD2.namprd03.prod.outlook.com (2603:10b6:510:33d:cafe::e3) by PH7PR02CA0009.outlook.office365.com (2603:10b6:510:33d::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.24 via Frontend Transport; Tue, 19 Nov 2024 17:21:22 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.12) 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.12 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.12; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.12) by CY4PEPF0000EDD2.mail.protection.outlook.com (10.167.241.198) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8158.14 via Frontend Transport; Tue, 19 Nov 2024 17:21: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; Tue, 19 Nov 2024 11:21:19 -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 v7 14/22] ACPI: platform_profile: Notify change events on register and unregister Date: Tue, 19 Nov 2024 11:17:31 -0600 Message-ID: <20241119171739.77028-15-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241119171739.77028-1-mario.limonciello@amd.com> References: <20241119171739.77028-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: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000EDD2:EE_|CH3PR12MB8994:EE_ X-MS-Office365-Filtering-Correlation-Id: 69bef7e0-8f32-4fa3-846d-08dd08be96e3 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|1800799024|7416014|376014|82310400026|36860700013; X-Microsoft-Antispam-Message-Info: /7i3wFtMUUJH+4lYzO3EOCK0jmgwfrzn2UQtyRQO7qBbRw497R/11O++lIwM1vqalbXj8U10S0lT2Hpz65gclY3ipEFoH2LQjDIZ5dZUFEJRkLDXVYBMKFK8xKXjKuNRckqifBlDXntQPCiGp8dEdS6clsiIkwPKOtr0KCZDK82ah90bI0IE8Z5Y8IRHOMMKlj2UI5egZKQWfYbY7xEsDFWp6ML8Rm71HPhH1w3IDXG53y7zG7pZSA72uY0XLtmBviIFOUAt2aFsnPE8hEEzJ68rjFwCNXwxkZOtqevn1Gm1Xtm9dIzf2Os4qgloq/Mg16PTRDgxtdqpcoMQXvK3Rrv1BML6f+8CcxQeK2ruCmfdpSKNjJ0TL73cGNarl47bNEGVdTmxNL8gn0A5Zu4sowbucpXrkW1Y90PjFmGzBRIl8HYd0edP61waESWNyIFBd1Y1zTSywnyjRithj3VJrogbK4EH+ysJ0quwMkDSE1oRPyIGtylzrlw0Ev07+vYoAh2RNiFyCAmDimu2K6vGmfSi9ZBtKg2cWgT4PyvqfuW6OK448425nvxIHhlp8L+dXXg3z2wMfQ1tv43Au4IrvKy0nORvFNWCRqxqk9/cFuUi681uzS6p9GYcgXuQA3LmqlgPxpRU8+GahqS71RstqK54/ojdBhkzDrxrBU6h+KGaSBZolpFk/z+j1qxF62VJe8ISJso740XV7A2/yhnb+84z/scxY7KGkuSutn62wUGfsQT0x6wKL67iLU7MBS1ODwODa0QJ3Vabc0J2h4Puupx/61vDXNUaBjNDyEuN4YY13CQwW4CJPsekkTEuXO7XHgkQ3AzmpNjzy93pAVJNQOl0Q9G3mlTAYDV/C3x2n5iuzA14hh3Vq5TFYglPKI0QXPQMb1c7ZeXHGWIoqbJW01e6Cg9eoADVi4OtNIdJNSdE/25hPQ53HML4R/rv9YxyyB6gdBsrIbRqXY8mv1N4JPMo5H9MlmiovibTMJu5fBO30AmNtfuKMVGzaNV5e7NqBcmUibRGmYasXpX+FpfGxEMNVB03BYKbQ0ZCA4Gk7kka789B5baTviN54w5Y125aGsAIaqc/SrpijYCPLQIQaDdApXwLq/DJd4AztVcsBoQRN2DcPafuO61fk1BXcdykCE6B7mQSlQP77ajoe6k5h3jojXltJJQtJHK+wMctqBjsH6mR6LgdXNYqHsgbewHQnVWb5I56Ona6eMETsqAS6wfnsFEifleNIqNtq47QWps1CSPreT75HCF825rIYhOq2Tk0uu27ZudkCjGVTFBW6RWzvpk21E/i9RK6eDeh+31pVU0HyF68Re5PrOeZUxcjCE4u3eawLDuBemxkQ/rip9IZc2L3Or/s1ab6madxJAAKsk1qg5SN7R4+AKMpx0xb+VhMw4+ZODnL4ZNCxtWDLA== X-Forefront-Antispam-Report: CIP:165.204.84.12; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:atlvpn-bp.amd.com; CAT:NONE; SFS:(13230040)(1800799024)(7416014)(376014)(82310400026)(36860700013); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Nov 2024 17:21:22.3217 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 69bef7e0-8f32-4fa3-846d-08dd08be96e3 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.12]; Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CY4PEPF0000EDD2.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR12MB8994 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. Reviewed-by: Armin Wolf Tested-by: Mark Pearson Tested-by: Matthew Schwartz Reviewed-by: Mark Pearson Signed-off-by: Mario Limonciello --- v7: * Add Armin's tag --- drivers/acpi/platform_profile.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profile.c index 1530e6096cd39..de0804305b02c 100644 --- a/drivers/acpi/platform_profile.c +++ b/drivers/acpi/platform_profile.c @@ -363,6 +363,8 @@ int platform_profile_register(struct platform_profile_handler *pprof) goto cleanup_ida; } + sysfs_notify(acpi_kobj, NULL, "platform_profile"); + cur_profile = pprof; err = sysfs_update_group(acpi_kobj, &platform_profile_group); @@ -393,6 +395,8 @@ int platform_profile_remove(struct platform_profile_handler *pprof) device_unregister(pprof->class_dev); ida_free(&platform_profile_ida, id); + sysfs_notify(acpi_kobj, NULL, "platform_profile"); + sysfs_update_group(acpi_kobj, &platform_profile_group); return 0; From patchwork Tue Nov 19 17:17:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 844288 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2089.outbound.protection.outlook.com [40.107.92.89]) (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 BD14E1D9592; Tue, 19 Nov 2024 17:21:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.92.89 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732036893; cv=fail; b=MiBLBTG2bB66x+KoEkn+9sY/ha1UBu5LMgbwFhQSlbdii4Ooy17zuhgsT9epTGi0YMgJWbdyqTK1fVTyi3UQaq9WikSNf8CyBNTNc6MibJNoN9DKx8ylrfScleAjWRRZUbLwHOKQZ4W8vXlZI6VF7QPrfqb3Qcm22IR2gUS46aM= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732036893; c=relaxed/simple; bh=R4FOJvOdpurkjZ6rAItGPYx1C5vNDKL/Ck1Ok8rE8LM=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=kgVrXtSpyP2GHNRdICpIJVHPJuYEgnXiDSYim3Uqe0R+VhgIUJ/sjgRnQCxKf2nzR4KlUe609lZsbBtRi1YOhLfbAglLGEfT7EyHzM+xsCHlMa3X8PVq3MxyfZVp0elDr8ixbVxQv8UMZtpdyyifXoIucWI6kQ0mHR/nAvhUEWE= 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=CJ5vaEqq; arc=fail smtp.client-ip=40.107.92.89 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="CJ5vaEqq" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=OsqFqK7sU/FtG0ZZhPZ5zqAhj1EtSwzdSxBZNHpNgGFZsAKJ2S87ggtlhUTWcmH8ezsZZSta/gSwFRxIOUb+8zxtyCYmA34xdfKzMB5UWkS1/gtNNIYMOS+dyFQTsh1/0Jk+sjv6PApwIYNFNpgad+do8ffKvYtCGELyeYs+/tA6XM9No+gJa1TqIqF83LatuLS52qfh09rPrmMGrEzqmcCsaxmXitbYDp5+O26a5GpXEqNmkL9x7ZslXzHKfr27C8ZneTtIqi4tWPW0DoN0VtsgtbBrqLMm2grg5M+yh+6lYZIv5uwgnauOwxfRZkIrpcosrLy25S6idxVn6FUeXg== 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=gdz8VhuJ822zb+HDdL0/A5HVsWK/jSuxunFPEBpnYJA=; b=Kx+NOY2aQI0m2+kCeUYkQBE6tvnOuH6WO/sLtjcI2k0vXzoXohtshf16Scqf+wAq7dP3LnpMRnBT7QCrz6aexU5gb/Hxuxx9JhjAyypcYKV3tdjGRtCxMA8nrkJK6QbM3Ggfgoss+3kPivMbu6v9fpNtnbxXh0T1uNoJYneVjivGY6HCNHrOuKgtZgrPXRRccFVSzpA1+/L6FCUtheQD64Zyx1maZE7/Ucg0MgWBRGxWG3Ta4azs0a0Pir026HBn3x5162bby9dkkc5g7YWyAHDuGk/QKpAgBtGioRj3tGg1VNG4MumrDNuW1MehhuCVpCHmdFSUOOjS81es9b0GNQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.12) 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=gdz8VhuJ822zb+HDdL0/A5HVsWK/jSuxunFPEBpnYJA=; b=CJ5vaEqqcm+JXTQ99mmFiIUTnqr3uNqaP1rNQ/ANuzt9x/HpduRA98c0obm7Tnk0i0IqT+WHi27jtmuJ7fkZ3dwL9FMGQTMFXevh3CjflilwbJEX7eXRWMOTd3dvn9XEHuPEXtpNP9lLT+fwmTge+6AidQb5pxrMxUkenKaaICM= Received: from PH7PR17CA0046.namprd17.prod.outlook.com (2603:10b6:510:323::6) by SA0PR12MB4368.namprd12.prod.outlook.com (2603:10b6:806:9f::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.17; Tue, 19 Nov 2024 17:21:26 +0000 Received: from CY4PEPF0000EDD6.namprd03.prod.outlook.com (2603:10b6:510:323:cafe::b) by PH7PR17CA0046.outlook.office365.com (2603:10b6:510:323::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.24 via Frontend Transport; Tue, 19 Nov 2024 17:21:25 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.12) 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.12 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.12; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.12) by CY4PEPF0000EDD6.mail.protection.outlook.com (10.167.241.202) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8158.14 via Frontend Transport; Tue, 19 Nov 2024 17:21:25 +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; Tue, 19 Nov 2024 11:21: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 v7 16/22] ACPI: platform_profile: Add concept of a "custom" profile Date: Tue, 19 Nov 2024 11:17:33 -0600 Message-ID: <20241119171739.77028-17-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241119171739.77028-1-mario.limonciello@amd.com> References: <20241119171739.77028-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: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000EDD6:EE_|SA0PR12MB4368:EE_ X-MS-Office365-Filtering-Correlation-Id: b1d8a5a7-d0b1-4503-caa6-08dd08be98e6 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|82310400026|7416014|1800799024|376014|36860700013; X-Microsoft-Antispam-Message-Info: V8VVbOdcfUinJD86ja1k6NIgmwlbLMiZ0+0knu9KFuLnuthzBRzxS+6wSiuInBMAl7J4FY6zjh5bu6rC5B4UtkLqRbLQ0qBu9t5a45nHgk/awBESyi1mQHX4Oa5lJkb+tjxG4IanV7RcWqekeZ16th3KeoTGGr9Q+CI5U/0ojU9p40FJgwG+7zC7UugfxTyNdxp14ZgGQU+VaROuLkAhy/ocasCwl52qdbj0yrJljzbF9zvMWib3tSE68QOGNLaZt6CTf0c/tGWfl8CYz28D3cjHowHaimsHwvtaYEF6BgGM6Hi4BztwTwbGGWt0pHuwE/WiYyBBGKsn3QVhwhgh1vxelmFW3Uoa+RTiLqYvyHAVmZkZ7h9DV0foInX779jm87EMSGqw+FOiujNYuCoJHlZ3y1tu578i/ejMG+jb9xeduZl/kDtK1V4RUyvITkJ+/GTg60vuXWkCzY9Zrs0Oez4Yvt5o4Le+jtydOU3IGaNCYk8vwxn+0xAtOrmwLntczOkJzAxHf0KhsY3AFp5/JzpX2/QrIP22CqQAKKxg4e3x4Q/eCyyaVFurxej9LZhsB0NNeGQ9MjPBznoQ08JSPbfFvkUUJdIVvoFQosOfMPEg+P1hzAOaC5TJTf+Beap3vVxmLOqw4TegUmKIK3yKFKrsS/i4Cb3Qr8ZPUDLQViU6m1aV31qTpxhO2UnvRSl9/PFLyKOY2Y7xKDzVpL/tIK5D/DU/84g2FyFIO7X89LFj4ljR7NkorWlSeF3uvVEZvHFFEH2SqnSui2AjfQpfvY+/df+bw47xdtjwxLdK0MqP6PQ6+jMIjdrqGz5z7JIP5sY6vX17dMrZREiTYyW28uS2tdtUECRKHHy5fYo7t8aLVM47BJZ3oxhdgQzF6smMlt0spwOALO+KDQkNfuG33XMHu23tVhg1yRLFN7GjnL+t/+8xZv3Ztpu2tirgN34MUPOjx0fdRxB21ZNFHtQueJMSvCZhVbiZO4h9vBKhdnlWqNzmMsbsU5n9VYmpUidbq9p0MaKyhDlNLgp+nigGF9x3MOeGOwVpK12dVLBhamWu9I3Zb/2hHFp3307Q0FuzQyQGP4qImlsrJc9L3RmkXDpyWPswwyJyAzcxCwla94MdUMMJuzl4Wua6i6X0Tsq4PjWdHDL25B42NqHfepko/er2kwvFuiABOMh6hNrtxZ0hhEnd+lyMyJCBvNVGnJf2py/zAly8Ge7DqGpuir90zlqpnaRu68xmV6rOw1z6TywF00dPLwCVWuDKH71EQ7H1NdHWcM7pnqiOdnkIQJ8Q2GECoDUmk6Zf+1N9Ikt2TTTscpA6gtXsMibuLiYbMx5TK3IxchyxAJZ7BuLsNYgK6DCNLSezxblC+SQNFs4FZEN7nb9yC+95aGbWX+bcdHYh30AuE/JXsOXLPbOFSZgyjQ== X-Forefront-Antispam-Report: CIP:165.204.84.12; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:atlvpn-bp.amd.com; CAT:NONE; SFS:(13230040)(82310400026)(7416014)(1800799024)(376014)(36860700013); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Nov 2024 17:21:25.6830 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b1d8a5a7-d0b1-4503-caa6-08dd08be98e6 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.12]; Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CY4PEPF0000EDD6.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA0PR12MB4368 When two profile handlers don't agree on the current profile it's ambiguous what to show to the legacy sysfs interface. Add a "custom" profile string that userspace will be able to distinguish this situation when using the legacy sysfs interface. Reviewed-by: Armin Wolf Tested-by: Mark Pearson Reviewed-by: Mark Pearson Signed-off-by: Mario Limonciello --- drivers/acpi/platform_profile.c | 1 + include/linux/platform_profile.h | 1 + 2 files changed, 2 insertions(+) diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profile.c index db2daab5b2a44..d579de1b31be7 100644 --- a/drivers/acpi/platform_profile.c +++ b/drivers/acpi/platform_profile.c @@ -20,6 +20,7 @@ static const char * const profile_names[] = { [PLATFORM_PROFILE_BALANCED] = "balanced", [PLATFORM_PROFILE_BALANCED_PERFORMANCE] = "balanced-performance", [PLATFORM_PROFILE_PERFORMANCE] = "performance", + [PLATFORM_PROFILE_CUSTOM] = "custom", }; static_assert(ARRAY_SIZE(profile_names) == PLATFORM_PROFILE_LAST); diff --git a/include/linux/platform_profile.h b/include/linux/platform_profile.h index a888fd085c513..0682bb4c57e5d 100644 --- a/include/linux/platform_profile.h +++ b/include/linux/platform_profile.h @@ -23,6 +23,7 @@ enum platform_profile_option { PLATFORM_PROFILE_BALANCED, PLATFORM_PROFILE_BALANCED_PERFORMANCE, PLATFORM_PROFILE_PERFORMANCE, + PLATFORM_PROFILE_CUSTOM, PLATFORM_PROFILE_LAST, /*must always be last */ }; From patchwork Tue Nov 19 17:17:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 844287 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2086.outbound.protection.outlook.com [40.107.93.86]) (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 074481DA116; Tue, 19 Nov 2024 17:21:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.93.86 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732036897; cv=fail; b=pk0Z6Ad3aA/7Y5kiXXHgDoL/uxjjgVbbt+ADjb2G/82eCnyX8yeLsX1iHrrPKukakCmWmFPwjWNPDX3EeETMPMmqjA8Ph91hinJQOwr7Nu0tPxHEaZYnSYJQLdy4jw2rSLZcdhyG+lPGCquI1JnvNZgtIlZV0iOVPYyRZKsmmAI= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732036897; c=relaxed/simple; bh=Ef7oQOGf2sOKgbZOMtFN/mM0DbbDnF1zOUyMqKgCTHg=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=HUbYlCUn5ciPv7PHGs7JjyllBuE7K6B7uopmeJgpG9kJrAbXg8EiZOzMHrroxkXwB//On7gJlU4BGBMSQe8OBuGvcEZQDa1XM0hmZ+MJ8EievkZ/0mVHRgD8kZNHFI343CmQzAXboubI8fh+GNjSDH5X/hcgzRI6oEzDUbGbrEo= 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=hHQALUwZ; arc=fail smtp.client-ip=40.107.93.86 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="hHQALUwZ" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=EIBDB850AgkTtmftts7wzgjnMvEQ+9i6/5nZwCrVEW1cn6gmzHi3v7Y5LhFRckIUV0kJBcFXVCMMocDgXie4kFPx16m8BLvxr7CSOUjMEgvR3+ew8Q3AuHNj4yQFMJv77wNMTifHSTqgwefQgF/qfIRmzJm6ADcn91Mnl7Ju07YqHfeJsG1N61XC2A2UI8NJpAyHd7SPI+kEVQPHcu4nSfdQIodETlqs09g7MMlKJsg/albOOO+aKOxSl9CPZyAtu2GATAZpUbv352FuZrvfMNEuXv8x8G8mMq9ufrrpZIP4wCQ1m/C+OeQHjsSecJDHZE19dXjyOS1IaF7B1e5y6A== 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=cvogErjJOwcVk46qfAaJGl6aKvOdsby22Z+cYER8yMQ=; b=fGLDQRw7LKwLi+rFapkKVOSZLk56VX8OVK1OaM+dE3faBrkNon3iLyyFew0STzxF84Gzl3MqnZsUa2yg7DueToQGjHIh9AqAxV87AT1GJYhujEg4gvBNGiazLvxFbwWI/tNrVOZb00kcdhcfDountls/LDBH5wHpZMs1N1msWKt4GiD01CEJ3FuGfsY8xWo0qMVK326d/L6NFVLnIRtXG6PxiFOzjrqXedXAGh7gUkzLa83C1gTPGlRAybRjExUca8ziu3xMKfnE+eLPKKGq50vguzl3APEv/lKwW+C3/G0oZlQgKvHO12WOH5SAUcmbzGv6rSXxSRVvYNN9DuwviQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.12) 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=cvogErjJOwcVk46qfAaJGl6aKvOdsby22Z+cYER8yMQ=; b=hHQALUwZfgpEBnhSyvfXAYlCspPqhvSHM0doWSPsEAXyYsEC2bQBFTvn2OzY9Q84Ux65HidN+Fr/tW3Vaf5WodNN/38HfvCcyfb1w6N+neuo2t59Qonk1ObGrkRYkpw2oPkFf9UdOPua9p/fuBBIPl7xltV/rpmfvmQVjauyZ4Y= Received: from PH7PR17CA0042.namprd17.prod.outlook.com (2603:10b6:510:323::21) by PH0PR12MB7790.namprd12.prod.outlook.com (2603:10b6:510:289::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.21; Tue, 19 Nov 2024 17:21:30 +0000 Received: from CY4PEPF0000EDD6.namprd03.prod.outlook.com (2603:10b6:510:323:cafe::8c) by PH7PR17CA0042.outlook.office365.com (2603:10b6:510:323::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.24 via Frontend Transport; Tue, 19 Nov 2024 17:21:29 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.12) 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.12 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.12; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.12) by CY4PEPF0000EDD6.mail.protection.outlook.com (10.167.241.202) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8158.14 via Frontend Transport; Tue, 19 Nov 2024 17:21:29 +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; Tue, 19 Nov 2024 11:21:26 -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 v7 18/22] ACPI: platform_profile: Check all profile handler to calculate next Date: Tue, 19 Nov 2024 11:17:35 -0600 Message-ID: <20241119171739.77028-19-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241119171739.77028-1-mario.limonciello@amd.com> References: <20241119171739.77028-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: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000EDD6:EE_|PH0PR12MB7790:EE_ X-MS-Office365-Filtering-Correlation-Id: 7f8c3051-13c3-43f7-9c59-08dd08be9b3f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|7416014|376014|82310400026|1800799024|36860700013; X-Microsoft-Antispam-Message-Info: 7TzWH9uXUfksOny6Q1afVG/MtUTkiRZaQ60NipLZX/PZRJkgGTiDd08eZ1UedK8dL2KVNpDqwLiANXm/aGtn3ypg337qgYJp6tnGjilW/KoYoBBjoEwjYVrkoQywNfSIK7zuaJBGYtO1p7wtdDGgJRonOX5mBetawBaV7O66Gg7j15Mx+qUj9xwack4dg+rHjXJm0emVnla8gV/E4jQtSLvVIrtKWtXEpHB1OOox7TgtaMHbvNI1zm1ZJH5MnuH7X/5qS87At8msHmcUxa/FrXSywGNBLsJOf0MQ/F7KV2Ljkg+xwhcG80k/pgKj2xq493SHYXD2roz3DtnvTXo+iHavC1Sz+I91aSPqAe3SEgyKyjiq3g9Sk9v8P85xGi9v2KQrornw8XQdXw0SrYzJsDDblDwHBar+1+tr6m1JAhXQxI7nLeacpHIzbDX1ryi4bYFux/4HYeEK8Eb/P6LdpwP07ypPIuCfd3tusAmmDdzVPoA1Ylz/wJ+nkesobUed3QULCUi0Qk9nkqiutz0C9qNPqGHL8+PKlGnDTJWN8hH3QPFZ+fWGXXt+SdU7rwsngBo3KWNKK8ZnG8SOlUW3tIhglX8YqFyLeqMLOkFEueXf4d2bgvA7K+ZmhGwFYwy5FWTE6tD+yxwcMMzDERKdseDrZD2gyXee/6XPrJYvVQW+JN21Lx9SjclWYb0zIYEPbIulCnVdBotj7TrNMP27rdEz7Xk5S+8A6foaUjezH5LcbSYwqrvS8fEreSiSpxtWrOuy+gXKvZa7KFna2tHpldAeox6JrI2k5qibbQlHgdBBx5xtQE7aUsgDCmKD4MV62betGVJCqUGzU9nqnCxoHxuzTFsON1hlW9Eu8r8LNq5UzDA8XUISai8+4rAEc0fFouT1oL/3mvUQNE7bQ++LQkM4xfF+U/6yAh1zPZMma1zTOeX92CSbP017fMPaRT2e6/ZghPPjrWd1m0bmhM12jw4r65mxXJ7JTPX/002vFf3JDFy559zJmGUaP/uOaIws24FaVMMxd1lpi6myFri08BZu+EubkJPgYnfRI/fersAWqVrxIY9mAyVTNH9KlXhJevihPbfl++9JLAcQAUMlueZLXLPSbIQCURm72Vg1z6TLwWtlcDOx5iPb1gQS71olR40P1AwJ83ImpLhxf+F6juUjqXbF48xd56aJj6jSifD2OTgRrlIWfhxwLsC2sD5b0xDwhtJAsoBLKkJUd/31hrElrkfIZqAsmrEcu3LvdSpiI+Gzrfvm+Bny4xdM06ix09e119yLH9c5DGqQQq7kF1Mj5D78BtYQFWC//QvZv7eq4s+oAKSYX/nzrcuwkw50sEJ0euYjrh+z6DtpzUehmKWJzIJF6R7UgcLBpdfdbOUSv1GNjgee9U+n+6ZTKdP1rTMqGjGDM5Vd1bt/wzlByQ== X-Forefront-Antispam-Report: CIP:165.204.84.12; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:atlvpn-bp.amd.com; CAT:NONE; SFS:(13230040)(7416014)(376014)(82310400026)(1800799024)(36860700013); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Nov 2024 17:21:29.6049 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 7f8c3051-13c3-43f7-9c59-08dd08be9b3f 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.12]; Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CY4PEPF0000EDD6.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR12MB7790 As multiple platform profile handlers might not all support the same profile, cycling to the next profile could have a different result depending on what handler are registered. Check what is active and supported by all handlers to decide what to do. Reviewed-by: Armin Wolf Tested-by: Mark Pearson Signed-off-by: Mario Limonciello --- v7: * Add Armin's tag * Use _store_and_notify() instead of _store_class_profile() v6: * Handle cases of inconsistent profiles or all profile handlers supporting custom. v5: * Adjust mutex use --- drivers/acpi/platform_profile.c | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profile.c index a258f2481246f..ca997f4e9a5cb 100644 --- a/drivers/acpi/platform_profile.c +++ b/drivers/acpi/platform_profile.c @@ -408,25 +408,37 @@ EXPORT_SYMBOL_GPL(platform_profile_notify); int platform_profile_cycle(void) { - enum platform_profile_option profile; - enum platform_profile_option next; + enum platform_profile_option next = PLATFORM_PROFILE_LAST; + enum platform_profile_option profile = PLATFORM_PROFILE_LAST; + unsigned long choices[BITS_TO_LONGS(PLATFORM_PROFILE_LAST)]; int err; + set_bit(PLATFORM_PROFILE_LAST, choices); scoped_cond_guard(mutex_intr, return -ERESTARTSYS, &profile_lock) { - if (!cur_profile) - return -ENODEV; + err = class_for_each_device(&platform_profile_class, NULL, + &profile, _aggregate_profiles); + if (err) + return err; - err = cur_profile->profile_get(cur_profile, &profile); + if (profile == PLATFORM_PROFILE_CUSTOM || + profile == PLATFORM_PROFILE_LAST) + return -EINVAL; + + err = class_for_each_device(&platform_profile_class, NULL, + choices, _aggregate_choices); if (err) return err; - next = find_next_bit_wrap(cur_profile->choices, PLATFORM_PROFILE_LAST, + /* never iterate into a custom if all drivers supported it */ + clear_bit(PLATFORM_PROFILE_CUSTOM, choices); + + next = find_next_bit_wrap(choices, + PLATFORM_PROFILE_LAST, profile + 1); - if (WARN_ON(next == PLATFORM_PROFILE_LAST)) - return -EINVAL; + err = class_for_each_device(&platform_profile_class, NULL, &next, + _store_and_notify); - err = cur_profile->profile_set(cur_profile, next); if (err) return err; } From patchwork Tue Nov 19 17:17:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 844286 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2079.outbound.protection.outlook.com [40.107.93.79]) (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 495AF1DA2F1; Tue, 19 Nov 2024 17:21:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.93.79 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732036897; cv=fail; b=JIYZP1grE+jedfFiW/ZRtSW/JBV13NdUXuHgF9bHnK0xpKnXzDpCVNssHZuJk9z5ULlJnjD4nWQGsPtMFE5b2C8PxQMCLk/cvzeaEuP5pUDMKVnbORxGDsQoPeZ5GhXrYEI9zpK0Mgvm5fFFG62oFDNt1xicLxvYio61Goc0/ug= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732036897; c=relaxed/simple; bh=tPk8iBelMkozwVP4JFH/dleWnueKOlHY6NqDmg11oOs=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=sWSGv8b7Xue6JIbr0E1PA2mVreqpAAmD2LsSuIC22jqEeTyr8GczayQwVmp+JofOEDEGRTRbg+/2siPRDPbGffOFgDUajtw8wMy7aX28KYGI1KrRq3dA/O7GrYKlYid1l8T/NXBcYxceG/yLdmqLRnItksN4t7B82zhZVva1k6g= 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=0+a4u+3O; arc=fail smtp.client-ip=40.107.93.79 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="0+a4u+3O" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=sMIxtv5F4lBCpVRzUuD7cMEjYmNPc33gESPv8p52DfkZFPh8tPdIePCL0C+ksbT4/Si1qPNSvEEeekxBP6+O3O7RXRRi6OIUGor4FPjWl7bwPsLtsRuFtsUo9vE84FIGyHhgiS4GU2qcM0byeSdYGegVg9IKR1yeAWt/7D7FtK/6Z6K5mvsR2xPUQuDsEEgCBEOeODEFeE2mU0MXuS/nZ8wR6e3/RbyyiBoXP/79951GcRg9T8hAHYfW4SfLVlcKIujq/XiKrleVKyO5ufDXJ3RCpx7RaKE80ItYWS9C5J2afmGwI751Gf27ZzPZWH2RmzCCmRAYTPrIsFtMjjAKXg== 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=Gdw4LcMjSmWQqzwh5N3XehtHblWWjBa8rpF+/nMuPGw=; b=PVI9GEukSHWDD1AUOAhdzF/Y9JGZH5YcJLpbb3HY+g1O0HeCTndA21vvrWb+/rNC6dzNNsw7opPjQuoIPPHlU/UjzfuwITI7E3bmLZzBODhQN45qRZxzFRmEG9arfwA6M0pwVlj6dgG/NW/D3EFh7Zsj5jx1tM7d0LKgS6CTI68VR1iwRv4RBRiLF2xZBZ6dIA1QgzCKZFxdUJNP+rPpUuiAPQ3NU8hxeSdixoLJobw8UEtEiZp7tgbCTJwLf1gEwIcc2M7+y8dw1FVzidZ3wb70bafIUSovLlu+fIF4vAdoNYfmkbNcwyZ95OysWeRcrGuvCi4/gIUYZLFJkCbZOg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.12) 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=Gdw4LcMjSmWQqzwh5N3XehtHblWWjBa8rpF+/nMuPGw=; b=0+a4u+3OnOgOiBRVFpA41Vd20k1OL6bIsKcIbi5UjpjuaZ1q3nMA2PJi9Xi233wgvdVGcLuEUY3EHuAsNs4UAWx7vK8CZY7kLy9NKwrQY9GBDVf0W+MbW3uXDIFs1zUhk0tzIkQOaFh5ktxFrfbwpgGTovd2ph7TqG15vtU7hRk= Received: from PH7PR02CA0003.namprd02.prod.outlook.com (2603:10b6:510:33d::31) by SA1PR12MB6800.namprd12.prod.outlook.com (2603:10b6:806:25c::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.21; Tue, 19 Nov 2024 17:21:33 +0000 Received: from CY4PEPF0000EDD2.namprd03.prod.outlook.com (2603:10b6:510:33d:cafe::37) by PH7PR02CA0003.outlook.office365.com (2603:10b6:510:33d::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.24 via Frontend Transport; Tue, 19 Nov 2024 17:21:32 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.12) 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.12 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.12; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.12) by CY4PEPF0000EDD2.mail.protection.outlook.com (10.167.241.198) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8158.14 via Frontend Transport; Tue, 19 Nov 2024 17:21:32 +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; Tue, 19 Nov 2024 11:21:30 -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 v7 20/22] ACPI: platform_profile: Allow multiple handlers Date: Tue, 19 Nov 2024 11:17:37 -0600 Message-ID: <20241119171739.77028-21-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241119171739.77028-1-mario.limonciello@amd.com> References: <20241119171739.77028-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: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000EDD2:EE_|SA1PR12MB6800:EE_ X-MS-Office365-Filtering-Correlation-Id: f7072b11-5d1b-4295-8829-08dd08be9cff X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|7416014|376014|82310400026|1800799024|36860700013; X-Microsoft-Antispam-Message-Info: mAeT9dXHfaSZ9oBHtIGsi473jTnBGCSLDgqIbRPc3CKj/gpKNcuw/ropT06fhKywW85CG5UWXfpIy9cb0w+kaTy8Z4m0xWaDQrIJBKA1oc2MJaPtWy+8gOvk31EAF5p0U7+ezOYyuX9DYXGtX1OKWH1gJO7XIapbaTGa85GDBz3qQh0jA7BeOMErGD/xk0D1iOdLx9LPoPSCfOF44gw8G5gXYw6s5AS4qNlte4+sLKRhLfJm5iRlCUN7Yr6spX1JjemdMEoU4AcyMK14NRQkjvn/rO7ojapyI/BNjpH5D9WrvTSnq+ZcKhvsgPEsMR+59pnA5OvmqQJhHun0l2XYRjYScYSMRDJebGSZHAvNhPOch6L5pLzBBaKt8E1eixjtW7dcntcQgMWxsYN5Qx7hbWM6hRe+ceNlhsA40ze9tLRqr0FU+MLKC83QM+NquVxJHmMo78RNsmVQ8NBLIiS8ADHZhAb2yhOG6LiMkPeo7BAwQ/Ol67tCdyGQcnklkeM0E6yG6wSceaOmucZ0QdVO15QHCLxEC0RzTtkeFcKOn4X5ZpuNeeHinQWVofNbvgB6euZHaZpa2jY0W7vjFgtj+48V2E+SdkzU1ISefeX1Uw4rQLTcdruwog72GqJ3jpoVWUvTJiu6ThGg7plnI11T8kt6r5kd03XcmrFdpb6IB1ENL/DQ0eagVHsTfkmS+4YHSYWTw8pHQHATy9XQ2VWj8ar+Cm0AJ3k/KojyUA0mQf1YhOifm6GuVWhWX870mHSwqSeMkbO9wHCTC4jAp4Ny+kQAXFa3ozBzWBW6sKec2JMQIn5NDLNCpJaymPorQTAY8c5O4xm5C4OpqThYHeMtO0HLjIC87B0XgaTJJkV4pLZ82k606M5cQ1xKXa0xfTwAaXGWmVNFGxflDWXgKSZYtrNnkFy2tU78ujrVNXf1fEafT4sLSTKYEUhRm6bAMQX8OhYMLhu4x6Pnb9rXpUNEfCupPH0KvXKGTd30u0ND7w7q/kvhFyltwglabDge6sz9Gae0DU/T3xH6vLK0uhLKLP+1saIFppfibPeep2IaIUUnzDT1f8eC11fVAZm+E1VlnR4PicEaIWo4+DSq1aKxqH+J64Gt+SGueklgTMCcwWev5cSGfQcryTjTGhn9K+DshiLUZJnDsCaqFjWImmTkaqJssb+8rVnzoaLJxlxlAqQ3hNc4O/ox46ZkamKShkHF7jpN3IpmomqlRtLWqJm8cWn0f35406WICuBOds+w0083/bxUmy+wQvNYuh5fEvjmkXOLQ09HPuJFbC1t7IaGdIyCxIOKBo3q+ozNv2I6HriXrScRPcblCtwhb5u1ZcIk7fHosL78g7VgnaYIzQ1w4iAs2RvFBLf4RTnBrl8jqjgxU0eTD3b4YOHJiXHirbJCygsw58/+/4adogcIPHM0UQ== X-Forefront-Antispam-Report: CIP:165.204.84.12; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:atlvpn-bp.amd.com; CAT:NONE; SFS:(13230040)(7416014)(376014)(82310400026)(1800799024)(36860700013); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Nov 2024 17:21:32.5716 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f7072b11-5d1b-4295-8829-08dd08be9cff 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.12]; Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CY4PEPF0000EDD2.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR12MB6800 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 Signed-off-by: Mario Limonciello --- v7: * rebase v6: * rebase v5: * reword commit message --- 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 e88b355a72112..7d774c43f4fa7 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[] = { @@ -400,8 +399,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) { class_for_each_device(&platform_profile_class, NULL, NULL, _notify_class_profile); @@ -465,9 +462,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); @@ -483,8 +477,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; @@ -492,7 +484,6 @@ int platform_profile_register(struct platform_profile_handler *pprof) return 0; cleanup_cur: - cur_profile = NULL; device_unregister(pprof->class_dev); cleanup_ida: @@ -507,8 +498,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); From patchwork Tue Nov 19 17:17:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 844285 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2081.outbound.protection.outlook.com [40.107.223.81]) (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 C25F31DD88B; Tue, 19 Nov 2024 17:21:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.223.81 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732036901; cv=fail; b=qzB96egYEfCxLn3UM1EqnS3hVYiB5gux0obooEd0ZddEQl5cJJguI4uQoZS1XcXO2nkWJUMb+Hdc5po85aWYvfBrn2XPwdxVllTl/qS6DVK8j/1r8tQqEyQn7l/NWCE9rHo1qJsqbh/A+sxsdXNUNBEoZTiyd83shD2aL4Osqio= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732036901; c=relaxed/simple; bh=+bdiJ1Eyfn9MTcWLW4JH4T1uWT0phudmlVUuiFZMgKQ=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=MoLgyFPP6mHiOKm9OAqBvN2bEKYBSeqakdEJ5rpX7LMZAMGAevmVbwrKVjgRpLKU0ZuGMVXHgO56w8K5C389ADAEScWaTk79+fjOD//qCLxffnqWQjIg2TlRCQISY+57CpAjrrrwLJqnUMtFljN+ZYEl8Gs7gnhyy3pCcN5InLY= 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=1/69Iamr; arc=fail smtp.client-ip=40.107.223.81 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="1/69Iamr" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=pdq5/xnYLbfbQaI7k+12aoRogOn719rY3OqWAlAxObP5dORDVWF3mY+xK0sqagoyl31DJ6k25MObw5BYutPlcvGA8/3KpIq3zwuGWOlJ3mnshDz6W41E4tmJd/wcOPxeJHJxseN9WgdBksLMUQPTz3iQogUCd3FPMJJRJLyEZo9gUsipQ4EHVY+FpphQkgdf/q7ydQjjbLQFKKK3DLHQ231B4z79tQR0yVDHK0LOUxa5wCkqpAn9eVtSIprErI6DXkqWRLE1wFcU/D8V/gFSkpfKBLW3ZDBbKrzVoN6GeGi8LwsTvCoi9z0w1s42K0s32grC6WNs1KHtYdiHkAWb6w== 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=mE5xib2maNaIrlY03QYSAc2xN6cAxJyeeTXImIzPjlg=; b=quLt7Flxk6aoHRLkqVSSq5oGUL7Q566d6cV6eCwxC84ftcpBSfD8ymodn67J7HglUEhGNuqRc5Hkgs29/bNitWLha+BcmrGH3RK4iQb+oVelJPy7AQS9ACjrTDUKra7bwjwnf3lxWJGl66p1Nx3Itd5ihHLWO9VSRmYu6eO4SnXfsL5WLoVFwqDALNuHmccs7MNb4uGwntSo5h7ODzKxrEfOK+R/rYbmeQwslo9fPDMYd2Us/GjwtMGuV4JR4sDRUBiLjdzu+kCC/RUXnFmR2KEKB0fk2F349ER9xMhoaIHKGMxHUrrTvyBS7Hl/7eLNW64csZFvWbGc4vvxlWluVg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.12) 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=mE5xib2maNaIrlY03QYSAc2xN6cAxJyeeTXImIzPjlg=; b=1/69Iamr5wxi8wf7I7e9tw24EldmH6hHFZ7QWY9y+yEr5YtX+Xlh8ZOJ9v1X0Vp7f2LEGtYUr8I2+12NXizF842eDFCRuCzlia+v2STbkWyrek8dwj/F+Rbe/7arGZsmqkEtR4OIZPen7PpN7zN1Ll/NKrvcTFkZ4ou4E5Xi7tA= Received: from SJ2PR07CA0010.namprd07.prod.outlook.com (2603:10b6:a03:505::27) by SJ2PR12MB8035.namprd12.prod.outlook.com (2603:10b6:a03:4d3::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.21; Tue, 19 Nov 2024 17:21:34 +0000 Received: from CY4PEPF0000EDD4.namprd03.prod.outlook.com (2603:10b6:a03:505:cafe::20) by SJ2PR07CA0010.outlook.office365.com (2603:10b6:a03:505::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.23 via Frontend Transport; Tue, 19 Nov 2024 17:21:34 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.12) 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.12 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.12; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.12) by CY4PEPF0000EDD4.mail.protection.outlook.com (10.167.241.200) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8158.14 via Frontend Transport; Tue, 19 Nov 2024 17:21:34 +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; Tue, 19 Nov 2024 11:21:31 -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 v7 21/22] platform/x86/amd: pmf: Drop all quirks Date: Tue, 19 Nov 2024 11:17:38 -0600 Message-ID: <20241119171739.77028-22-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241119171739.77028-1-mario.limonciello@amd.com> References: <20241119171739.77028-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: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000EDD4:EE_|SJ2PR12MB8035:EE_ X-MS-Office365-Filtering-Correlation-Id: dec3c9b0-0bac-4afc-0781-08dd08be9e0c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|82310400026|376014|7416014|1800799024|36860700013; X-Microsoft-Antispam-Message-Info: efuexn/vu9BtnldNg8eCRyNn4GMhv8vMjy/6FqgscQn4/nJ5Xgq6/5QNm2COQtfqOrnqAGPnyZRHWazMkI3Qimo8AlYIXZduW/DFOI2NQaDkPdloqACd1eYSFYxtWp4ZMUiyN3P5mBQatJnHxVSZoNrIDl9dWc0O2rpJbOhEHDn3t67966TKqIDCHx1JVuNcccJeh03bJLKcofKP3M0sJG/pAWGxgU9SK+jP9bEGQEGQPu8J0uQCQTd4x/jdIEG4umGR/unb+buUt2P69jQtQ3O4s90BfDxNYzSpSfxCPYqaeTyANja1R/opDGhEMsV+eP2EzGw3cTjvuNs+KuOw/VRz6ciUWWdUHKSNxULOFQMVpYwHisxWW2kaqhbx17SRfkJJLrGmtLa7tv2Tn9BwMe/aAtuxb1TnBe3lze2kHr3uXKUJeT2iyo8WngFh4CWthQDFxrzNPIv7hPPleG2PuXWs2GgtKRfHSB5Dq7iG5YDw1W54DwV25wxlWWcgrRTT+2+62EnRF2kH4fXv7eqWmqeF+8ZPCqb0v5YmrgY81sB997lQNeg4dEQzy/uXnvtZVD7QvjvzuQ9ZsKkwcLOMwUBGXVk5K78N5mJjy85ONAzpZ++rr9x8CjkebmukzJYqFbEaWYX3ChKH6ZCZFkLia533UeiAkW0DXvTnT5GS2TJfK8ljKVhY50iNom29Ehm7PM4Oj+FgOCticzUB0G7Hfewi6uYlb7kkxVndXPAKILfrZ5/f0VXeNKWN7Lh+hhj4+nueQV+V65vnypwFF8jWe7ICqsLJPxsjMYpl4ZooDpw3RecGACcPjl1YprxGL2FalbAI9rEKNImyJJcqEYAqMj7dnd6rBQN5H5pakgVsSb1lI0uKFyLIC3Dya36lysMvLvXeLjzOh6NfcF2yL8lUdgo5Wyni/XpKbO6RUoM8mdQLEWIuf11IPPouwfPXZpkY5kVFyE80YBfFA3zQEll+n+X7X97I13Xs8BqqMH4tn/3SzQ/wgLBqLS6JdwsAEtj/wbF6KM9Di/efRfJqGDq1tBZ4zMNthPiI9erdMUZbK3MWnLjZzEF16zewpqTmhNHk+04hiBJoHwXe9AHuEfdsWGlkdCYb+6kLIHM4KmbnHK8fhNJHah1d80mO+DmehvnC3nx9phS9bz5CsV0LTcskVmvZ7fnffF/+1sprrAiXyoADAtuHSu5JTDWCv4CH5kEXZ7h+NAuisy8f8m3I487XFVWW/kHpVs9xvGzn343byKdXDKiRv6eHwiIjMq77KmPoryCzY4nvNWVdRQveDCHOdRHDdxDnSSzumbKP6V+eiE/qpMiVxXm+o1We4SyzhMPdfA6lZuJGiJqnnT0ixEqO0nJePSEHUMlcnz50VJjBMrUTWS5DPVa4eO0+aGUscHGXha2bC3VhIyDtrEURGLEL+Q== X-Forefront-Antispam-Report: CIP:165.204.84.12; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:atlvpn-bp.amd.com; CAT:NONE; SFS:(13230040)(82310400026)(376014)(7416014)(1800799024)(36860700013); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Nov 2024 17:21:34.3000 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: dec3c9b0-0bac-4afc-0781-08dd08be9e0c 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.12]; Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CY4PEPF0000EDD4.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ2PR12MB8035 As multiple platform profile handlers can now be registered, the quirks to avoid registering amd-pmf as a handler are no longer necessary. Drop them. Reviewed-by: Armin Wolf Tested-by: Mark Pearson Tested-by: Matthew Schwartz Acked-by: Shyam Sundar S K Signed-off-by: Mario Limonciello --- drivers/platform/x86/amd/pmf/Makefile | 2 +- drivers/platform/x86/amd/pmf/core.c | 1 - drivers/platform/x86/amd/pmf/pmf-quirks.c | 66 ----------------------- drivers/platform/x86/amd/pmf/pmf.h | 3 -- 4 files changed, 1 insertion(+), 71 deletions(-) delete mode 100644 drivers/platform/x86/amd/pmf/pmf-quirks.c diff --git a/drivers/platform/x86/amd/pmf/Makefile b/drivers/platform/x86/amd/pmf/Makefile index 7d6079b02589c..6b26e48ce8ad2 100644 --- a/drivers/platform/x86/amd/pmf/Makefile +++ b/drivers/platform/x86/amd/pmf/Makefile @@ -7,4 +7,4 @@ obj-$(CONFIG_AMD_PMF) += amd-pmf.o amd-pmf-objs := core.o acpi.o sps.o \ auto-mode.o cnqf.o \ - tee-if.o spc.o pmf-quirks.o + tee-if.o spc.o diff --git a/drivers/platform/x86/amd/pmf/core.c b/drivers/platform/x86/amd/pmf/core.c index 745d0e013a330..44461f2f35e82 100644 --- a/drivers/platform/x86/amd/pmf/core.c +++ b/drivers/platform/x86/amd/pmf/core.c @@ -455,7 +455,6 @@ static int amd_pmf_probe(struct platform_device *pdev) mutex_init(&dev->lock); mutex_init(&dev->update_mutex); - amd_pmf_quirks_init(dev); apmf_acpi_init(dev); platform_set_drvdata(pdev, dev); amd_pmf_dbgfs_register(dev); diff --git a/drivers/platform/x86/amd/pmf/pmf-quirks.c b/drivers/platform/x86/amd/pmf/pmf-quirks.c deleted file mode 100644 index 7cde5733b9cac..0000000000000 --- a/drivers/platform/x86/amd/pmf/pmf-quirks.c +++ /dev/null @@ -1,66 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0-or-later -/* - * AMD Platform Management Framework Driver Quirks - * - * Copyright (c) 2024, Advanced Micro Devices, Inc. - * All Rights Reserved. - * - * Author: Mario Limonciello - */ - -#include - -#include "pmf.h" - -struct quirk_entry { - u32 supported_func; -}; - -static struct quirk_entry quirk_no_sps_bug = { - .supported_func = 0x4003, -}; - -static const struct dmi_system_id fwbug_list[] = { - { - .ident = "ROG Zephyrus G14", - .matches = { - DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."), - DMI_MATCH(DMI_PRODUCT_NAME, "GA403U"), - }, - .driver_data = &quirk_no_sps_bug, - }, - { - .ident = "ROG Ally X", - .matches = { - DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."), - DMI_MATCH(DMI_PRODUCT_NAME, "RC72LA"), - }, - .driver_data = &quirk_no_sps_bug, - }, - { - .ident = "ASUS TUF Gaming A14", - .matches = { - DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."), - DMI_MATCH(DMI_PRODUCT_NAME, "FA401W"), - }, - .driver_data = &quirk_no_sps_bug, - }, - {} -}; - -void amd_pmf_quirks_init(struct amd_pmf_dev *dev) -{ - const struct dmi_system_id *dmi_id; - struct quirk_entry *quirks; - - dmi_id = dmi_first_match(fwbug_list); - if (!dmi_id) - return; - - quirks = dmi_id->driver_data; - if (quirks->supported_func) { - dev->supported_func = quirks->supported_func; - pr_info("Using supported funcs quirk to avoid %s platform firmware bug\n", - dmi_id->ident); - } -} diff --git a/drivers/platform/x86/amd/pmf/pmf.h b/drivers/platform/x86/amd/pmf/pmf.h index a79808fda1d89..64ab532550ac3 100644 --- a/drivers/platform/x86/amd/pmf/pmf.h +++ b/drivers/platform/x86/amd/pmf/pmf.h @@ -797,7 +797,4 @@ int amd_pmf_smartpc_apply_bios_output(struct amd_pmf_dev *dev, u32 val, u32 preq void amd_pmf_populate_ta_inputs(struct amd_pmf_dev *dev, struct ta_pmf_enact_table *in); void amd_pmf_dump_ta_inputs(struct amd_pmf_dev *dev, struct ta_pmf_enact_table *in); -/* Quirk infrastructure */ -void amd_pmf_quirks_init(struct amd_pmf_dev *dev); - #endif /* PMF_H */