From patchwork Mon Dec 2 05:50:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 13889992 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2062.outbound.protection.outlook.com [40.107.223.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 CB94A23741; Mon, 2 Dec 2024 05:51:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.223.62 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733118695; cv=fail; b=tl75YXXg+OVlKs/PR2aYZzSVp9WLYUDm7mciipng94j50UfgPwqmSduuK2Bl83Y7goaMzEx89pfCoSf4wTbV4o458NmCFtNc5f+dfhVxfSrGalSZPedesNO1p+19ws9fNmqTCKB/Dg8ar22qQsmw1wVB4YIZqTAETdhPJ6J6P7Q= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733118695; c=relaxed/simple; bh=2GfJ/SjUIoNaiwHOnGXTGKoy8oQY1NZVgcne1nh591o=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=AK3F/zZafiSq7gs4J0oJRVFNI3fiH3vC6vzUA7v0igTxWADkGPeDpyMieukq6+xfJlBhQmzQc+m5dZhXXT9+NBRamV190YdEYJwQHxCLQSj2xSV+BZCDNYk0ubT+Hq/R64RHDxCHtX8dtMQQQ6Gss8z7YvFowoko0kP3AaGU+RY= 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=3iU0iHt8; arc=fail smtp.client-ip=40.107.223.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="3iU0iHt8" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=sdOm/KiNAGNDaK7QSyb0OeQJVdnMpT8n+FY1pat1KicpYXYNa4qq+qFZHDXU/a3CpfpPDp8PG6bGrN3yBXpyK1A9JX6lkXF3caKPGpRxGDUMp2X7z1K+/TtPVzaO+dQ+A1MFCDqkgq52E9JRhp/0y4Y+dAQa2T2Y+qX3Vf4RfQ7NvTwNA5wyxHMcU89lhV91TbGsq+1gcosdpJkmCIHJ5hnSGgstaufikeXvDpvDdJecZWjbijZmUJj173JVHrcdhnDHEcuRF6aHyGjEf1+A8PHQT1Vioct6+qc/5Nb0wKzoV4BJ9W/U+Pkd3KDbUj5d6Fwzr8S3ANFAfpDDNbnqKA== 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=DoQnBgUUl7eonCm8N3+8uE69DCAavYY1OE4Xsjy+5YI=; b=Lj6BYfryWZHAN4hin1mzJpcrBACDVce5jrI/V46SR81+CAgK4SQ+ev/4LtwrnzEvEKuKocHoAGG4AnTjEMMfMNEnOiT0eTJh6XpLtw+C0gpvdIkDspPJksqPxNSglrXjQh9njiifl2EFEiO2X+GIr/SjLY09QpneJEvzzFlz5dcx+fUqxgStBQ+07Em8NBpAYm3Xg1P92+goTC4BTMnF13x3sAR28xnoxDRVE6ZcvqkEUryCDhoKAwTBg6YYRb1pNV8HvIYKEcWxyrtIrfDv6xlMPhQ+wMiR4JFLvry4+83EsXg251gOEC/KZwjOysQQYdTNKv1G7bfoQ9NjPXQuBg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=redhat.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=DoQnBgUUl7eonCm8N3+8uE69DCAavYY1OE4Xsjy+5YI=; b=3iU0iHt8D8HZC1Lz3T8NG5rPLjl255r9FM1M84dD4tJLT7z9fRNWqdp/eCoWQC7Lcwd0XXRrWH7feXhjqNiAktSGarsaI5PsLSnabxVhWIYmTOBehEr2VZx6fwhjpAGBsZMIabz9+Om9bW5/q6zrabd6Cz1rF3UPF099RAai7wM= Received: from CH2PR16CA0006.namprd16.prod.outlook.com (2603:10b6:610:50::16) by IA1PR12MB9468.namprd12.prod.outlook.com (2603:10b6:208:596::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8207.18; Mon, 2 Dec 2024 05:51:30 +0000 Received: from CH1PEPF0000AD78.namprd04.prod.outlook.com (2603:10b6:610:50:cafe::1e) by CH2PR16CA0006.outlook.office365.com (2603:10b6:610:50::16) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8207.17 via Frontend Transport; Mon, 2 Dec 2024 05:51:29 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by CH1PEPF0000AD78.mail.protection.outlook.com (10.167.244.56) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8230.7 via Frontend Transport; Mon, 2 Dec 2024 05:51: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; Sun, 1 Dec 2024 23:50: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 v9 01/22] ACPI: platform-profile: Add a name member to handlers Date: Sun, 1 Dec 2024 23:50:10 -0600 Message-ID: <20241202055031.8038-2-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241202055031.8038-1-mario.limonciello@amd.com> References: <20241202055031.8038-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: CH1PEPF0000AD78:EE_|IA1PR12MB9468:EE_ X-MS-Office365-Filtering-Correlation-Id: 377c3ce1-a50b-49f4-59ba-08dd12955e5c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|7416014|36860700013|82310400026|1800799024|7053199007; X-Microsoft-Antispam-Message-Info: =?utf-8?q?0nVF17KSOsT6W+gmDzarff1Ua4LpB6C?= =?utf-8?q?8XcxqcdC4RatSLQ0oB9cI8zdC6HBAB1D8BTWA8fzKr55pf1oP4TWaakdabY5eaIrk?= =?utf-8?q?2jWpVp480XbgW6oRswNYHdVH0Co73ohSZ93WWFY/3H96SHYeg4HIFxSRr8W57xTmn?= =?utf-8?q?dwl/yy/8DL0bsFHdvJSZ5dybj4mbJAgFK2zMgd7tO7trjjgpknCicWOemUuLrrGRb?= =?utf-8?q?77vB4r6WhU+OEIpakJe/FZG9IeWUUY8gvJDAz7EFRLoknSoiq1cv1N+RNKNYUyBC2?= =?utf-8?q?cFBqqf3SJ/28nCXIuEhT3GF+bpE5HZrf7opCMU0SWP4FTtM+GSnHcMbp3JPNRN0ls?= =?utf-8?q?BaKHHq/Q8KOYDJyiVtKu5NosZ9BobQucx64upuNMRIfwq1t6sOj7wK1yfYbIizh7y?= =?utf-8?q?BnKT9EWdP4swEJKwAKzO97qPGa+Tc2ijXeVa3XBgpq5xG0dtoABDZQXLp2RJap3Yr?= =?utf-8?q?eu6WIt2KZ7AVpmhK9s3hbyNzMgizL2/T+3vHyiUZHrxFZi0LdOIEFcbgq3hNgIp7t?= =?utf-8?q?Y4EFaGai/7+LcpLjaxG+km0uaxnzH5GQfsbHUFPRfCUqzhEVI8NlSRId1x3jA5CJs?= =?utf-8?q?ltZ0FcB80n09lfWey3Ja/p/YYTJhVzR3sd5TZS9KVxJOG0NvhpFITLwWjEiFYiNrO?= =?utf-8?q?REUf2nYUoWag+9NDaNRZ5zT6z+v320bnvXR3c/NLOzWqshUeCBv5VBtJ6Zwncmq/7?= =?utf-8?q?Cc7V0Gj4e4HQgTrNGxHlwykZ3vOPHxk1iX9iQqBhlfvzU1hmWuWV3oujRTq6vVJ9H?= =?utf-8?q?E1fQdGL7HvzazGjDnty5/pWmA04WiOqZL71YjlPIc3FSUP9hHMsfpj7LI59/0B9XS?= =?utf-8?q?TBfVV5siHfp2C8xvSPDbYKDJEm332v4h4j6Nyn3sWBJlkITsX1IQMNyacoYJo2FZQ?= =?utf-8?q?cKI3Y3Fuza9qFQSaXr0b0Wp9FrC8KwDZvwgXDsHl0i2u6TYtqLrPLSwwShlwp1J8u?= =?utf-8?q?OBbS3KlQRZDHHsjrcTZs6FcJmuNJtTnHZCDmNmWYPT2agbSdpyEIM2ARG0k0UZqmI?= =?utf-8?q?2gCDp3AB3AUj6pLV0JuOAsAgnjBp6+lO13Nh3SFPKcDsHwv8d6jYWPbh8GibMBD8R?= =?utf-8?q?V0KkLRBYOeDmxuRi5X9daV3rOBIaUlbLiiY0Pt1V9GhtHIt/yUPdELtgGnzk5PWR1?= =?utf-8?q?sCV2AIOso1jXMqhQ38axlA4zCkHVsRFE6F6XhpELUFFWGW1JYEVnzgIgkTnvIavmP?= =?utf-8?q?sKTDSjJTk2tTrr8X9EnBDOr3FIgFGTdy3IBf3dFtY8v/bCC1i7Wt+7lkCNC+4YTri?= =?utf-8?q?gfE5kKidGYpS2FY5SJYaKmu8KoCqVo1zHkREUjGTv/ruRx+hhkjUQEPYLext1PXUW?= =?utf-8?q?1c1AE2bpCC6YMEMMFsCzDQXZboatDsapKEFxuInRA/jYty2tXAodUqaK3VevPlXGV?= =?utf-8?q?VLxKV5r2meA?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(376014)(7416014)(36860700013)(82310400026)(1800799024)(7053199007);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Dec 2024 05:51:29.8234 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 377c3ce1-a50b-49f4-59ba-08dd12955e5c X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CH1PEPF0000AD78.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR12MB9468 In order to prepare for allowing multiple handlers, introduce a name field that can be used to distinguish between different handlers. 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 --- drivers/platform/surface/surface_platform_profile.c | 1 + drivers/platform/x86/acer-wmi.c | 1 + drivers/platform/x86/amd/pmf/sps.c | 1 + drivers/platform/x86/asus-wmi.c | 1 + drivers/platform/x86/dell/alienware-wmi.c | 1 + drivers/platform/x86/dell/dell-pc.c | 1 + drivers/platform/x86/hp/hp-wmi.c | 1 + drivers/platform/x86/ideapad-laptop.c | 1 + drivers/platform/x86/inspur_platform_profile.c | 1 + drivers/platform/x86/thinkpad_acpi.c | 1 + include/linux/platform_profile.h | 1 + 11 files changed, 11 insertions(+) diff --git a/drivers/platform/surface/surface_platform_profile.c b/drivers/platform/surface/surface_platform_profile.c index 08db878f1d7d4..9d3e3f9458186 100644 --- a/drivers/platform/surface/surface_platform_profile.c +++ b/drivers/platform/surface/surface_platform_profile.c @@ -211,6 +211,7 @@ static int surface_platform_profile_probe(struct ssam_device *sdev) tpd->sdev = sdev; + tpd->handler.name = "Surface Platform Profile"; tpd->handler.profile_get = ssam_platform_profile_get; tpd->handler.profile_set = ssam_platform_profile_set; diff --git a/drivers/platform/x86/acer-wmi.c b/drivers/platform/x86/acer-wmi.c index d09baa3d3d902..53fbc9b4d3df7 100644 --- a/drivers/platform/x86/acer-wmi.c +++ b/drivers/platform/x86/acer-wmi.c @@ -1878,6 +1878,7 @@ static int acer_platform_profile_setup(void) if (quirks->predator_v4) { int err; + platform_profile_handler.name = "acer-wmi"; platform_profile_handler.profile_get = acer_predator_v4_platform_profile_get; platform_profile_handler.profile_set = diff --git a/drivers/platform/x86/amd/pmf/sps.c b/drivers/platform/x86/amd/pmf/sps.c index 92f7fb22277dc..e2d0cc92c4396 100644 --- a/drivers/platform/x86/amd/pmf/sps.c +++ b/drivers/platform/x86/amd/pmf/sps.c @@ -405,6 +405,7 @@ int amd_pmf_init_sps(struct amd_pmf_dev *dev) amd_pmf_set_sps_power_limits(dev); } + dev->pprof.name = "amd-pmf"; dev->pprof.profile_get = amd_pmf_profile_get; dev->pprof.profile_set = amd_pmf_profile_set; diff --git a/drivers/platform/x86/asus-wmi.c b/drivers/platform/x86/asus-wmi.c index ba8b6d028f9fe..a08dc936276b9 100644 --- a/drivers/platform/x86/asus-wmi.c +++ b/drivers/platform/x86/asus-wmi.c @@ -3876,6 +3876,7 @@ static int platform_profile_setup(struct asus_wmi *asus) dev_info(dev, "Using throttle_thermal_policy for platform_profile support\n"); + asus->platform_profile_handler.name = "asus-wmi"; asus->platform_profile_handler.profile_get = asus_wmi_platform_profile_get; asus->platform_profile_handler.profile_set = asus_wmi_platform_profile_set; diff --git a/drivers/platform/x86/dell/alienware-wmi.c b/drivers/platform/x86/dell/alienware-wmi.c index 77465ed9b449b..f88d898447511 100644 --- a/drivers/platform/x86/dell/alienware-wmi.c +++ b/drivers/platform/x86/dell/alienware-wmi.c @@ -1156,6 +1156,7 @@ static int create_thermal_profile(void) pp_handler.profile_get = thermal_profile_get; pp_handler.profile_set = thermal_profile_set; + pp_handler.name = "alienware-wmi"; return platform_profile_register(&pp_handler); } diff --git a/drivers/platform/x86/dell/dell-pc.c b/drivers/platform/x86/dell/dell-pc.c index 972385ca1990b..3cf79e55e3129 100644 --- a/drivers/platform/x86/dell/dell-pc.c +++ b/drivers/platform/x86/dell/dell-pc.c @@ -247,6 +247,7 @@ static int thermal_init(void) thermal_handler = kzalloc(sizeof(*thermal_handler), GFP_KERNEL); if (!thermal_handler) return -ENOMEM; + thermal_handler->name = "dell-pc"; thermal_handler->profile_get = thermal_platform_profile_get; thermal_handler->profile_set = thermal_platform_profile_set; diff --git a/drivers/platform/x86/hp/hp-wmi.c b/drivers/platform/x86/hp/hp-wmi.c index 81ccc96ffe40a..26cac73caf2b9 100644 --- a/drivers/platform/x86/hp/hp-wmi.c +++ b/drivers/platform/x86/hp/hp-wmi.c @@ -1624,6 +1624,7 @@ static int thermal_profile_setup(void) set_bit(PLATFORM_PROFILE_COOL, platform_profile_handler.choices); } + platform_profile_handler.name = "hp-wmi"; set_bit(PLATFORM_PROFILE_BALANCED, platform_profile_handler.choices); set_bit(PLATFORM_PROFILE_PERFORMANCE, platform_profile_handler.choices); diff --git a/drivers/platform/x86/ideapad-laptop.c b/drivers/platform/x86/ideapad-laptop.c index 5d2c1f0d1e9fb..cbdc965eeb248 100644 --- a/drivers/platform/x86/ideapad-laptop.c +++ b/drivers/platform/x86/ideapad-laptop.c @@ -1102,6 +1102,7 @@ static int ideapad_dytc_profile_init(struct ideapad_private *priv) mutex_init(&priv->dytc->mutex); + priv->dytc->pprof.name = "ideapad-laptop"; priv->dytc->priv = priv; priv->dytc->pprof.profile_get = dytc_profile_get; priv->dytc->pprof.profile_set = dytc_profile_set; diff --git a/drivers/platform/x86/inspur_platform_profile.c b/drivers/platform/x86/inspur_platform_profile.c index 8440defa67886..03da2c8cf6789 100644 --- a/drivers/platform/x86/inspur_platform_profile.c +++ b/drivers/platform/x86/inspur_platform_profile.c @@ -177,6 +177,7 @@ static int inspur_wmi_probe(struct wmi_device *wdev, const void *context) priv->wdev = wdev; dev_set_drvdata(&wdev->dev, priv); + priv->handler.name = "inspur-wmi"; priv->handler.profile_get = inspur_platform_profile_get; priv->handler.profile_set = inspur_platform_profile_set; diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c index 6371a9f765c13..0e03c41e028d4 100644 --- a/drivers/platform/x86/thinkpad_acpi.c +++ b/drivers/platform/x86/thinkpad_acpi.c @@ -10571,6 +10571,7 @@ static void dytc_profile_refresh(void) } static struct platform_profile_handler dytc_profile = { + .name = "thinkpad-acpi", .profile_get = dytc_profile_get, .profile_set = dytc_profile_set, }; diff --git a/include/linux/platform_profile.h b/include/linux/platform_profile.h index f5492ed413f36..6fa988e417428 100644 --- a/include/linux/platform_profile.h +++ b/include/linux/platform_profile.h @@ -27,6 +27,7 @@ enum platform_profile_option { }; struct platform_profile_handler { + const char *name; unsigned long choices[BITS_TO_LONGS(PLATFORM_PROFILE_LAST)]; int (*profile_get)(struct platform_profile_handler *pprof, enum platform_profile_option *profile); From patchwork Mon Dec 2 05:50:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 13889993 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2051.outbound.protection.outlook.com [40.107.237.51]) (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 47BA01F8AEA; Mon, 2 Dec 2024 05:51:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.237.51 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733118697; cv=fail; b=CJp8P/BIvKQZJJVAIbZdQ9DXEzo5Fcu/L9IaW39ak8Ry/vwrafu48MkHU84we1PilJlcyRQ10qtIqLL7jLGlqoJzR/I52WpQm8vdkHmaLPTB7ZA3y9pRFIoby02/jHJM5aHJPMb11iZq//QLkohL20NaSE+SxJCGyYVIHCQ/VR0= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733118697; c=relaxed/simple; bh=7FR0mS053av9fSakTvKuY8cLkqdOo6I54zrt7+qryVw=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=ZDS9M4sOfNxDITexWFd61uNsWB/9V0zzkQkEAwT30xBU970cCMEQXyfh1lhfAf2nhJ7I+4sr0bqwIP2fEkuHc6UzjmQ25AwxD+USeVndyPeseeq19zOJCzR+u7s7BngI+oTv0qEiC7txkOFrU89IiaL/bef4AzLrDu4EbLoroZs= 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=OYe77kvQ; arc=fail smtp.client-ip=40.107.237.51 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="OYe77kvQ" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=UVZtTWwmSVd/KWP3e9OFfSds5CT3Nlyfo080P20t181k8e6mVwzhz5O7V94v+HS7CX/CtLnmYfAWy7k9ek4r24wraDyxq5IAc1K5y2upS42rstc0KJecS4XmaCwqMgjjfYNNnKbhpSbpvobOshRsFQuJDdwVW1I2Z+FUZwZfB6zMiAyDUMnQ5ahMGl0hClWMh2U6h6QjDCHsbFWzAAWxL1mXGzt/CFnPEdPXVjI0MnmiNcSedgC2feF9h21QXLhxwuNe8fS9VpWqA4qBLAl4KKUB9V/p3wQLRCV88AVs5BYgTcdphCcGYfot7GK+ZikgG29wJT40OdJkyMkWylTkMw== 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=HO5D+drA4qa07bYVA6TrUgo8LFJF1qHTIg2teKV8f8U=; b=G1R0UOwTAfWI7xukgS5jYInJymQlzco/5HbffCPy4Gtg9bDhKrdFNQWdbmmqpH3qt/4k107G0saqzP9JPnTAro9m003d5Rl/gwSpzhpXgsX4TlVigXfdtrBGjFpAvW0Aqe1Utm95QolAwH7e6OFC1ho/7M2xv6J7O3rdwBykbmB7oEpMoJiIh+/7IBWSuOJulOKsC3tbpvaKrf8+tX/XHotMlaKfO2QnYXOFpe42topN+hUseTEfkykf78qPKZrC5qcam4xSrfqb/Ss/x1Yjhicz9bfzeKECtnsIUGDvhI8i30pyyqOFLo9JgPgRh76/Kls8zYQ+PTNoUIVsn3GtuQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=redhat.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=HO5D+drA4qa07bYVA6TrUgo8LFJF1qHTIg2teKV8f8U=; b=OYe77kvQiE9Ne+ds0SsPTilxy3d7sqNsRsO8DgsOlfVxx+MIgt/DKaHr29LTOuE7cJJ7ajWpijJ6w0WTQToFeBXoVGjCc1PEBX4AMWNRLZTokzERqTPBub2QXGEDm3nkrKdF8oZn6aublfqjtiGRkENIrrnvnLs4t3MaBUohTEw= Received: from CH2PR16CA0006.namprd16.prod.outlook.com (2603:10b6:610:50::16) by SA3PR12MB8811.namprd12.prod.outlook.com (2603:10b6:806:312::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8207.19; Mon, 2 Dec 2024 05:51:30 +0000 Received: from CH1PEPF0000AD78.namprd04.prod.outlook.com (2603:10b6:610:50:cafe::53) by CH2PR16CA0006.outlook.office365.com (2603:10b6:610:50::16) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8207.17 via Frontend Transport; Mon, 2 Dec 2024 05:51:30 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by CH1PEPF0000AD78.mail.protection.outlook.com (10.167.244.56) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8230.7 via Frontend Transport; Mon, 2 Dec 2024 05:51:30 +0000 Received: from AUS-P9-MLIMONCI.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Sun, 1 Dec 2024 23:51:28 -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 v9 02/22] platform/x86/dell: dell-pc: Create platform device Date: Sun, 1 Dec 2024 23:50:11 -0600 Message-ID: <20241202055031.8038-3-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241202055031.8038-1-mario.limonciello@amd.com> References: <20241202055031.8038-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: CH1PEPF0000AD78:EE_|SA3PR12MB8811:EE_ X-MS-Office365-Filtering-Correlation-Id: e4bf76ba-b86b-422a-2eb0-08dd12955eb2 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|36860700013|7416014|82310400026|376014; X-Microsoft-Antispam-Message-Info: =?utf-8?q?/GKDvrtx97V98DjgUuh8l1PRG96EjH9?= =?utf-8?q?aAQJc6c3Nm4eCVy8WTmKbYrXp1U07CGqOchLOuRJX8g0UHSLxa3FIbpZc+w/PBwdg?= =?utf-8?q?WyQ+DIRc8x4S4PfmPdfjU+J7JLP4I0dSxa2OXoaiSW4FN1JAID25zcj0EcFwEeHX4?= =?utf-8?q?ThHvn7dfYZFi6QJcDiD1cHXT18lT4ZKWCALSzTrNE3LtFWThFxCjF12lSvZxcWxD5?= =?utf-8?q?idoNZHSqKLovwOh3Z8ZOWnHymNO5drHrh6uBi0UB+WUGTF4+kLPHkdgvYHa53hm+c?= =?utf-8?q?+8vvgaQi8hVmveolFRRRBWUmt+irMJ08+wG+KzcJnJA0PzFigfBAuU20W5NSolDqV?= =?utf-8?q?zYDeulEmw40CZEjXaNI/2bvceb6O1i+kOMLQOVG4n1ZzCHkpa5pjcq2Rdt+4WsAlP?= =?utf-8?q?8lN/epEnI9VtTj6KA3aAhfEqMbBfaJvAal7xxSafGZr9f/BtmiuIq90ow27eA6V6k?= =?utf-8?q?tiNnPVBt2YJ6WHvsLx1DRtmBdsKcdTEQtnsUWGwpt44d8t03evF1FnZ/zVttxmt6k?= =?utf-8?q?bhZJ7YlpXV7gbzPzob913pPaij3riFmqSgrsuW3KJFVSEEbJJaT6v4nkOdAxzk6tO?= =?utf-8?q?erqVl3cqgaTs432tcDdxctzAvDdtnTXvYMKle6bsaY4Q9OBYqOQ2QZxUywHD8wC5l?= =?utf-8?q?uJuw6DGtMoWhQGDF8kxCURvobTF6ITs15cA2kC4mTZrqThFF9eKrEB0ITMU0KzXE9?= =?utf-8?q?xyLPWfkNnLAyPB7UFxUbsFrb8gMjETJr++uu9PrOcsD/kIVFoFOCJ8OSKNGT96j7B?= =?utf-8?q?joKpK7EYYWLxOrvH0Tv9GZen1/Ebcfg+Ns4yaXNbWH3GQRnEidBbLku2pzs4QjwfQ?= =?utf-8?q?W6GhVs+AEKRRyO5vrjnA8T9Co5qp60zFG+AEWcr8oY8JO01+OBEnhlY0gyVUYiZ/3?= =?utf-8?q?jANGXFUdiUvGr8xUbqoZk0pJRt9jwTpf6ynIr+3VnUc+ZUY/P9E8+JANJQmfMv2mz?= =?utf-8?q?uS1anUENrs5Q/O4QINhrNElF62kzFGUGcJVzyW6fs8iJ3CMay21FcPuu8Jr52sgFk?= =?utf-8?q?0ZmrFEMDWDMXXZmxKUwMBlZVkKqj9CNOUOpsbAhE7pyrA555Aue+TGvENr0SFAbBy?= =?utf-8?q?bh4kQuGkkirbFUHzOwyI9j+wI3FowWLBwdFknG4eu5w3BGG5CSG4jEeabBz6ZG4w9?= =?utf-8?q?5auTGDaBk0hrXBqi8qV2dzk0lNGwEb2lyIbFuW/Y3gsMN047qAmWNEYQn6vQq/DuO?= =?utf-8?q?4jL3/88oXEnWTzi+iyCSstLpEZONfTpCdpL0ugx00MZCZZeJHB+CRtwPAfYWnSpg6?= =?utf-8?q?jfrm9O5/2HqDm3UbkUvm2dBoMnBz8zA7thBtXmVLWP69vc3mBlVvhVYPNTWk8yfL6?= =?utf-8?q?YVkp/xc4oH3Nrs9/5rWqQpC/BoBMep2kp6hn2zocBygMVxmKB9wb37tJmiFemDw77?= =?utf-8?q?QNaQtlZnfIL?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(1800799024)(36860700013)(7416014)(82310400026)(376014);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Dec 2024 05:51:30.3859 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e4bf76ba-b86b-422a-2eb0-08dd12955eb2 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CH1PEPF0000AD78.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA3PR12MB8811 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 Reviewed-by: Mark Pearson Signed-off-by: Mario Limonciello --- v9: * ERR_PTR() -> PTR_ERR() v8: * Use IS_ERR()/ERR_PTR() --- drivers/platform/x86/dell/dell-pc.c | 34 ++++++++++++++++++++--------- 1 file changed, 24 insertions(+), 10 deletions(-) diff --git a/drivers/platform/x86/dell/dell-pc.c b/drivers/platform/x86/dell/dell-pc.c index 3cf79e55e3129..c0dbbd3b23065 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) - return -ENOMEM; + platform_device = platform_device_register_simple("dell-pc", PLATFORM_DEVID_NONE, NULL, 0); + if (IS_ERR(platform_device)) + return PTR_ERR(platform_device); + + 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 Mon Dec 2 05:50:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 13889994 Received: from NAM02-DM3-obe.outbound.protection.outlook.com (mail-dm3nam02on2088.outbound.protection.outlook.com [40.107.95.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 880B51F940F; Mon, 2 Dec 2024 05:51:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.95.88 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733118701; cv=fail; b=P1wOFNFyCXo0IlW8vF0IIslJLjtxPkcB2mwtwO9+m4qMWy/ohxGl1WRsCEZZrxe4rz2ktWwI8DKOOM9mNeXieyiSs8O1WE4jZK6AgWVBmRB23iqI/0y9FxErrAqFxUQUK0bazy1bKWuKVNSa28lHS2l58TKikhtpFkcNtHZgZzA= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733118701; c=relaxed/simple; bh=AhcQq/qoPABsrY8CsoC/m8lNX7jnLQEA1NZQjsy9xjY=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=cJ5SkSiJ47D6KVSwxw//D+eoC33xQLdc1wH+9gWA56ex4Zz9eJdPtP+r2ili9/CpLIxPziTraQPmV6Yb/aqchl0/8u938zxD0PFNiNqy45D3PKr/KxRHf8HKlRncoFEfgqBI2Px9f9/mMJCgmJlGauZyBEdwu0/3bQU4JC7ddOo= 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=5QiFK9Aj; arc=fail smtp.client-ip=40.107.95.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="5QiFK9Aj" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=cbXZHh7muk/jSfIvFNc3NMDqW+66p9mMdxujZM4y0i9sASOivZmWR+1kOFge3JRueB96hXKuKAipMHXEgB7LW1paJgWmPaYMXxOc+MKN7tWvpAI4ujARtSZHE2e3FC4L1gzL10e3mFWARQpdFkx9xNknTwviusgmfCMOCzSiE5+as34EncxkRqHtsHhFPnnZc6KXzIAlBs/AW2n2biBO55bHeY+jhkPnadH/tS13FWBWWWCmaHSPEAlu1y2NR3v3zAfqd0aNypbdqpbUO5mTY2V0bUNZboJ+2Zvd1H/3YpH+Vc411uHJunc/QcJlp3DCf/nI+trSjS6wrVmLtB0DyQ== 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=lnx4s0xfHI8MWMTVeFUsyesOxs3tBhsZmpwtkndEF7o=; b=I5+y/Y8GOMPsRSumD1djhb5uIo+9lGUOo5l5TiG6yFSuB1OEdMkCbdSXxODFd3rVotoqLrhcboHidlXmHATUbPHcRzceVymqjuK36qmBAI2kxdWsT0QOdzIj0rPRpMOsLrj1b8/5qoxnJIc/115tgLysqYuVDDjTCMqPGxlqwOQaozrzJknOs4OtyFzKTcm90m+k0qG4PBKrxhpYdQ7/5btr5+SLNIGr8rvDJNeJ2D+5ezarZ2nFVhqvF1KrQBCIM3P3J8nSLnDULZANsZilfaf2i6cwpqLnCVFuj7YLrVGC0Dv/xLhPFYxJ1B6Ik0kkQVjDURj1E2DgK/i9f9pDEw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=redhat.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=lnx4s0xfHI8MWMTVeFUsyesOxs3tBhsZmpwtkndEF7o=; b=5QiFK9Ajbj1kfF2oTBp2Mtp05iYKFi2ywN4FsgnY2rBuQ4ePcW9DqHFUtmCnvI1qJSab1P1ZFQyx1qqtz23BwuGoQFA2fxNnGVGGXh6KkMbQnsbBNiqNdQWB7oi8hLDWcxxGcXldZj1zPBfX12n6pq75H0eIgifTyZd4fC9t4pI= Received: from CH5P220CA0022.NAMP220.PROD.OUTLOOK.COM (2603:10b6:610:1ef::28) by SA0PR12MB4495.namprd12.prod.outlook.com (2603:10b6:806:70::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8207.18; Mon, 2 Dec 2024 05:51:32 +0000 Received: from CH1PEPF0000AD7A.namprd04.prod.outlook.com (2603:10b6:610:1ef:cafe::c7) by CH5P220CA0022.outlook.office365.com (2603:10b6:610:1ef::28) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8207.15 via Frontend Transport; Mon, 2 Dec 2024 05:51:32 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by CH1PEPF0000AD7A.mail.protection.outlook.com (10.167.244.59) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8230.7 via Frontend Transport; Mon, 2 Dec 2024 05:51: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; Sun, 1 Dec 2024 23:51: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 v9 03/22] ACPI: platform_profile: Add device pointer into platform profile handler Date: Sun, 1 Dec 2024 23:50:12 -0600 Message-ID: <20241202055031.8038-4-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241202055031.8038-1-mario.limonciello@amd.com> References: <20241202055031.8038-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: CH1PEPF0000AD7A:EE_|SA0PR12MB4495:EE_ X-MS-Office365-Filtering-Correlation-Id: f8cd0e09-77e9-4c5e-4d57-08dd12955fb2 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|376014|1800799024|82310400026|36860700013; X-Microsoft-Antispam-Message-Info: =?utf-8?q?ul3+80mmXoroDCw2CCLO/vuQt7wnGhw?= =?utf-8?q?mUM1teaG1IxmbzBvGXi4X5diTpnCZST40YuqMBx3ynyKzlRzE8g0pld5hzizNro6P?= =?utf-8?q?f08CnXSCg5SwmSj+/qOZzwVl1u+lB3L5+3U6TaTEztN6STWANofhWLjpk7WpQKtdd?= =?utf-8?q?jW0MQacvlgpHKyvv02vZFPgLjF4ccZXpzMuKD9Z5SFz4X0dc4dJEfGvOslN4ohKcz?= =?utf-8?q?5EjAm8qBIxU6UznAdGM+WjgXG2p0SWqxnIq5SBwcysC8ihborU20uL1FmloyMyyte?= =?utf-8?q?89F8Rh2/ausktQukimV9UyjLJqgtB6riSBA5FJNmHiGNwt0X250l0nvlTIQ3aer2D?= =?utf-8?q?wvvmzNMi691nCueevNAZRyQgqg6dRKlOPiuQlGMv3wg+AqFnawl6YfY+Y3FzUsMRq?= =?utf-8?q?GOTZ7x+soIY5zlfm1gc8MYPiIpzIo9QLZ/heBycx4fV94u75q21LrxEP9NhB50gNl?= =?utf-8?q?UNiqlZxaaaKi54XBJJtLm3xXrVk/0mr11QK5D8dodlkH2KZM42tHk2q2QZ1TBKeif?= =?utf-8?q?cVQEA2BteLqxi3FdNpn5FA0HqX5Y95nnauSHV3uqhhZI4VMpGR1SR0sZ4eX0INqda?= =?utf-8?q?zL1b9pufn4GUGQl/VEcrvAafEOVapgc47cR/76/61tA9YFlnEuBuSLj1TJPec0qfD?= =?utf-8?q?JZ0iCDB46lYzOMOL8QTBv6zlWm1PG2eUXbaFH+6ZPRb4aITUAP+1OseoZQw9nq23I?= =?utf-8?q?1BxCV6cGWWVPci8jQk8rKesqI6NbNExruIDW3urjXSnPV3eFzH7AmKRF9VZQtsbFO?= =?utf-8?q?UW7Ccp+qxr1H4BnQX7pFNLLddmU5XYb/FYzNGqm2DkjjyIFQdZHYesvyLAPYrl+cb?= =?utf-8?q?NzYsox3VBg2QRJ9bjn7wohEgA7YEngLqCnh5gxvT+s7AvF852id62Mu7Sl/OiXUVX?= =?utf-8?q?WHdod6BtiJ8mV+9Tf5wWq04Og2e4pplxH7/XpCvQTj6C32io3lqESKZEiAQLi2kEI?= =?utf-8?q?EWqP2tFymGUmUVoC8sWLg2y2S7BlThnuGexaNnieL8maN6VEh4aNj8CbRZpWtgfpN?= =?utf-8?q?NU5nDqKhkQJPnL3e0N8aS/nmEiuIS+2ncW6+yoDyCalGJ3N4LFIheQSklK6m//JbG?= =?utf-8?q?jYcJE2CJG8CU6qozYC2B4tz7zUrOZwYZRlbl9rbJMtT+nnKnRLDluX8in86tzgKez?= =?utf-8?q?bv9DQifPktx5qWF+lffBqsNhUEvm6tCm5PdTRZI8Tx2CmNRkjag95zG+HWuxV8tjG?= =?utf-8?q?jOv5xXpiHAR6uiSXC17SS9WsbmeUamc9qifbU7TUjYaI9iS+9voh6yRKixfiJTNRs?= =?utf-8?q?aHij/cLdVz7DwBhPyV8y5fjIUDtBMilpv7pyj14OGEPx7XLh2atiH1qV8hm2Op2AE?= =?utf-8?q?UqbH895uDvr1Y9BFoXteQOfWDryFTzXzZkrffPp+cg7Pd+gwsECdyNZbvDHdofVq0?= =?utf-8?q?oUZeZGNwOEg?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(7416014)(376014)(1800799024)(82310400026)(36860700013);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Dec 2024 05:51:32.0645 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f8cd0e09-77e9-4c5e-4d57-08dd12955fb2 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CH1PEPF0000AD7A.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA0PR12MB4495 In order to let platform profile handlers manage platform profile for their driver the core code will need a pointer to the device. Add this to the structure and use it in the trivial driver cases. Reviewed-by: Armin Wolf Reviewed-by: Ilpo Järvinen Reviewed-by: Maximilian Luz Reviewed-by: Mark Pearson Signed-off-by: Mario Limonciello --- drivers/platform/surface/surface_platform_profile.c | 1 + drivers/platform/x86/acer-wmi.c | 5 +++-- drivers/platform/x86/amd/pmf/sps.c | 1 + drivers/platform/x86/asus-wmi.c | 1 + drivers/platform/x86/dell/alienware-wmi.c | 5 +++-- drivers/platform/x86/dell/dell-pc.c | 1 + drivers/platform/x86/hp/hp-wmi.c | 5 +++-- drivers/platform/x86/ideapad-laptop.c | 1 + drivers/platform/x86/inspur_platform_profile.c | 1 + drivers/platform/x86/thinkpad_acpi.c | 1 + include/linux/platform_profile.h | 1 + 11 files changed, 17 insertions(+), 6 deletions(-) diff --git a/drivers/platform/surface/surface_platform_profile.c b/drivers/platform/surface/surface_platform_profile.c index 9d3e3f9458186..b73cfdd920c66 100644 --- a/drivers/platform/surface/surface_platform_profile.c +++ b/drivers/platform/surface/surface_platform_profile.c @@ -212,6 +212,7 @@ static int surface_platform_profile_probe(struct ssam_device *sdev) tpd->sdev = sdev; tpd->handler.name = "Surface Platform Profile"; + tpd->handler.dev = &sdev->dev; tpd->handler.profile_get = ssam_platform_profile_get; tpd->handler.profile_set = ssam_platform_profile_set; diff --git a/drivers/platform/x86/acer-wmi.c b/drivers/platform/x86/acer-wmi.c index 53fbc9b4d3df7..aca4a5746bee1 100644 --- a/drivers/platform/x86/acer-wmi.c +++ b/drivers/platform/x86/acer-wmi.c @@ -1873,12 +1873,13 @@ acer_predator_v4_platform_profile_set(struct platform_profile_handler *pprof, return 0; } -static int acer_platform_profile_setup(void) +static int acer_platform_profile_setup(struct platform_device *device) { if (quirks->predator_v4) { int err; platform_profile_handler.name = "acer-wmi"; + platform_profile_handler.dev = &device->dev; platform_profile_handler.profile_get = acer_predator_v4_platform_profile_get; platform_profile_handler.profile_set = @@ -2531,7 +2532,7 @@ static int acer_platform_probe(struct platform_device *device) goto error_rfkill; if (has_cap(ACER_CAP_PLATFORM_PROFILE)) { - err = acer_platform_profile_setup(); + err = acer_platform_profile_setup(device); if (err) goto error_platform_profile; } diff --git a/drivers/platform/x86/amd/pmf/sps.c b/drivers/platform/x86/amd/pmf/sps.c index e2d0cc92c4396..1b94af7c0e0c4 100644 --- a/drivers/platform/x86/amd/pmf/sps.c +++ b/drivers/platform/x86/amd/pmf/sps.c @@ -406,6 +406,7 @@ int amd_pmf_init_sps(struct amd_pmf_dev *dev) } dev->pprof.name = "amd-pmf"; + dev->pprof.dev = dev->dev; dev->pprof.profile_get = amd_pmf_profile_get; dev->pprof.profile_set = amd_pmf_profile_set; diff --git a/drivers/platform/x86/asus-wmi.c b/drivers/platform/x86/asus-wmi.c index a08dc936276b9..14d84cad01b49 100644 --- a/drivers/platform/x86/asus-wmi.c +++ b/drivers/platform/x86/asus-wmi.c @@ -3877,6 +3877,7 @@ static int platform_profile_setup(struct asus_wmi *asus) dev_info(dev, "Using throttle_thermal_policy for platform_profile support\n"); asus->platform_profile_handler.name = "asus-wmi"; + asus->platform_profile_handler.dev = dev; asus->platform_profile_handler.profile_get = asus_wmi_platform_profile_get; asus->platform_profile_handler.profile_set = asus_wmi_platform_profile_set; diff --git a/drivers/platform/x86/dell/alienware-wmi.c b/drivers/platform/x86/dell/alienware-wmi.c index f88d898447511..78aac76132788 100644 --- a/drivers/platform/x86/dell/alienware-wmi.c +++ b/drivers/platform/x86/dell/alienware-wmi.c @@ -1108,7 +1108,7 @@ static int thermal_profile_set(struct platform_profile_handler *pprof, return wmax_thermal_control(supported_thermal_profiles[profile]); } -static int create_thermal_profile(void) +static int create_thermal_profile(struct platform_device *platform_device) { u32 out_data; u8 sys_desc[4]; @@ -1157,6 +1157,7 @@ static int create_thermal_profile(void) pp_handler.profile_get = thermal_profile_get; pp_handler.profile_set = thermal_profile_set; pp_handler.name = "alienware-wmi"; + pp_handler.dev = &platform_device->dev; return platform_profile_register(&pp_handler); } @@ -1225,7 +1226,7 @@ static int __init alienware_wmi_init(void) } if (quirks->thermal) { - ret = create_thermal_profile(); + ret = create_thermal_profile(platform_device); if (ret) goto fail_prep_thermal_profile; } diff --git a/drivers/platform/x86/dell/dell-pc.c b/drivers/platform/x86/dell/dell-pc.c index c0dbbd3b23065..b9a6dd7b321d9 100644 --- a/drivers/platform/x86/dell/dell-pc.c +++ b/drivers/platform/x86/dell/dell-pc.c @@ -257,6 +257,7 @@ static int thermal_init(void) goto cleanup_platform_device; } thermal_handler->name = "dell-pc"; + thermal_handler->dev = &platform_device->dev; thermal_handler->profile_get = thermal_platform_profile_get; thermal_handler->profile_set = thermal_platform_profile_set; diff --git a/drivers/platform/x86/hp/hp-wmi.c b/drivers/platform/x86/hp/hp-wmi.c index 26cac73caf2b9..ffb09799142bc 100644 --- a/drivers/platform/x86/hp/hp-wmi.c +++ b/drivers/platform/x86/hp/hp-wmi.c @@ -1565,7 +1565,7 @@ static inline void omen_unregister_powersource_event_handler(void) unregister_acpi_notifier(&platform_power_source_nb); } -static int thermal_profile_setup(void) +static int thermal_profile_setup(struct platform_device *device) { int err, tp; @@ -1625,6 +1625,7 @@ static int thermal_profile_setup(void) } platform_profile_handler.name = "hp-wmi"; + platform_profile_handler.dev = &device->dev; set_bit(PLATFORM_PROFILE_BALANCED, platform_profile_handler.choices); set_bit(PLATFORM_PROFILE_PERFORMANCE, platform_profile_handler.choices); @@ -1664,7 +1665,7 @@ static int __init hp_wmi_bios_setup(struct platform_device *device) if (err < 0) return err; - thermal_profile_setup(); + thermal_profile_setup(device); return 0; } diff --git a/drivers/platform/x86/ideapad-laptop.c b/drivers/platform/x86/ideapad-laptop.c index cbdc965eeb248..b6586c473ba91 100644 --- a/drivers/platform/x86/ideapad-laptop.c +++ b/drivers/platform/x86/ideapad-laptop.c @@ -1103,6 +1103,7 @@ static int ideapad_dytc_profile_init(struct ideapad_private *priv) mutex_init(&priv->dytc->mutex); priv->dytc->pprof.name = "ideapad-laptop"; + priv->dytc->pprof.dev = &priv->platform_device->dev; priv->dytc->priv = priv; priv->dytc->pprof.profile_get = dytc_profile_get; priv->dytc->pprof.profile_set = dytc_profile_set; diff --git a/drivers/platform/x86/inspur_platform_profile.c b/drivers/platform/x86/inspur_platform_profile.c index 03da2c8cf6789..5a53949bbbf5f 100644 --- a/drivers/platform/x86/inspur_platform_profile.c +++ b/drivers/platform/x86/inspur_platform_profile.c @@ -178,6 +178,7 @@ static int inspur_wmi_probe(struct wmi_device *wdev, const void *context) dev_set_drvdata(&wdev->dev, priv); priv->handler.name = "inspur-wmi"; + priv->handler.dev = &wdev->dev; priv->handler.profile_get = inspur_platform_profile_get; priv->handler.profile_set = inspur_platform_profile_set; diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c index 0e03c41e028d4..58af9020382c1 100644 --- a/drivers/platform/x86/thinkpad_acpi.c +++ b/drivers/platform/x86/thinkpad_acpi.c @@ -10638,6 +10638,7 @@ static int tpacpi_dytc_profile_init(struct ibm_init_struct *iibm) dbg_printk(TPACPI_DBG_INIT, "DYTC version %d: thermal mode available\n", dytc_version); + dytc_profile.dev = &tpacpi_pdev->dev; /* Create platform_profile structure and register */ err = platform_profile_register(&dytc_profile); /* diff --git a/include/linux/platform_profile.h b/include/linux/platform_profile.h index 6fa988e417428..daec6b9bad81f 100644 --- a/include/linux/platform_profile.h +++ b/include/linux/platform_profile.h @@ -28,6 +28,7 @@ enum platform_profile_option { struct platform_profile_handler { const char *name; + struct device *dev; unsigned long choices[BITS_TO_LONGS(PLATFORM_PROFILE_LAST)]; int (*profile_get)(struct platform_profile_handler *pprof, enum platform_profile_option *profile); From patchwork Mon Dec 2 05:50:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 13889995 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2085.outbound.protection.outlook.com [40.107.92.85]) (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 2700C1F9416; Mon, 2 Dec 2024 05:51:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.92.85 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733118702; cv=fail; b=tIpXzvcrwBTbF0Q1M1/OeA5YcwN3O2PJxYZnVEWuEjQ3xEjLYnTpTW0rt1n+dLr3o54zUcuIhoGJtFRUfb7k+ixg4vMLqjP/dMqq1JrFoK/Yu4hahlj1p1kGj/S28X2nmAxwxp1u4ffzrtgELw7eWhHgcNoRnGuyKraoULPKdCg= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733118702; c=relaxed/simple; bh=ADHAYEGQIN8PMTT+q5E6Wnjocrm/ZEi+CMd0CtE3+mk=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=kxrQMDyOh/y5/Hk4hgmcZmqiOSjgN8YfB34tOqN4dqwOSJgTkbrh6oYsHANAF475wlXyiYzNyBu2bY9vjJ9jJN5eyETDrWhEs5l0TxjZhsR0cXQXIHOjLO6BShq5b4Epj9iV56npXTZt38qWjSTxGXlovubjhuUb7q1OzGlG/6k= 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=0zk1b12o; arc=fail smtp.client-ip=40.107.92.85 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="0zk1b12o" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=KWvk92Q+4bZlbNBe8DDWir8qFGPTvI9Nke3I2TMJRDtXnMXXnCGd/chStnIft7kDqRlo28RCHU/XsOKq+wC1js446bFeFf/GhYrfZDDvN0EqtLeBLnu1opU70+O6SGYxFMar5YKkBQRhoR8Jf2sEFIvVao1WmXgBTbgBCbuWC9eQbQaFLz19areYoiEjrwblZewKa0X6JH0H4//reNMF20XCEORLaG9qe3kpmHZeeIXc0Wl7Y4rX5TaeABRf7IbWlkt78Yc5WTBm5WnGRDkr8YUsPJIRUFom81CMko0ClBTH6o9AIovm+gffTr8FVX1ErOrTiCcxXDcMtPJv4Qh6FQ== 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=Vqpumrmwwskxuax8IdkPneF/w2aPuFMAKFy2VR8gjso=; b=nq5K7/8ZCKJLX64edc6+q5qgM4Cap1qFpU/s5w/k1VKE34LAkdGPaleYZhF02DJ9RfzW74vcj9bycilS+faLTGnFbY4bWDaj1uP1fYyIPiv6T/y9I0QN/iqdQfTEgLwSjg2b9vxVWN9GiRQbUefs3LudaM7kaCQx1+vti+xOETZrN35lZlPq/7Zwy1bBJxQVwicu8FXEciUwqGNKeKFZ8pnxlH8U3f1amg/CJ6LPRonRoDlCul6IilSRWHgpRM/UFqcGVG3jThXEcv/Eof73c0h4I5gZwkbbq+S09bKuafH6JSulJuyHXVXk8Bb0jMkUxNneYE2FSnjKhgC9hpgKUQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=redhat.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Vqpumrmwwskxuax8IdkPneF/w2aPuFMAKFy2VR8gjso=; b=0zk1b12oJ+j0pkeFvVeOwBiveupkR6GA/7fnbMvarrXqOOZXP2936ZL424xAfTvLjJKZheRoAeHIvRMNuHQHLpAONp/lC+PmyHrqvtfJ5lvrjjdXWmx40s0hFd9hkHVCOxXqST1F4egigRwdhg0VR/Jz+VzuMDBJEBhtPrZGohM= Received: from CH2PR16CA0008.namprd16.prod.outlook.com (2603:10b6:610:50::18) by IA1PR12MB8496.namprd12.prod.outlook.com (2603:10b6:208:446::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8207.18; Mon, 2 Dec 2024 05:51:34 +0000 Received: from CH1PEPF0000AD78.namprd04.prod.outlook.com (2603:10b6:610:50:cafe::a8) by CH2PR16CA0008.outlook.office365.com (2603:10b6:610:50::18) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8207.16 via Frontend Transport; Mon, 2 Dec 2024 05:51:33 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by CH1PEPF0000AD78.mail.protection.outlook.com (10.167.244.56) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8230.7 via Frontend Transport; Mon, 2 Dec 2024 05:51:33 +0000 Received: from AUS-P9-MLIMONCI.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Sun, 1 Dec 2024 23:51: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 v9 04/22] ACPI: platform_profile: Add platform handler argument to platform_profile_remove() Date: Sun, 1 Dec 2024 23:50:13 -0600 Message-ID: <20241202055031.8038-5-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241202055031.8038-1-mario.limonciello@amd.com> References: <20241202055031.8038-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: CH1PEPF0000AD78:EE_|IA1PR12MB8496:EE_ X-MS-Office365-Filtering-Correlation-Id: e41e1bb2-2486-46f4-04e3-08dd129560ae X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|376014|1800799024|36860700013|82310400026|7053199007; X-Microsoft-Antispam-Message-Info: =?utf-8?q?HbOMP2qWAmIg+RfnRSkQk+PZLa7FFiz?= =?utf-8?q?eDBjcfbPczugb+uxvG0kqEZmX2ihw6L0HltMb2p0WDMnqnGbmo0zwjTIGh/pFPY0W?= =?utf-8?q?VEBVhobmANa8qlOBo+S6a8U6wnligtotRmrPHoP4B3CE9D3YedjQbNLeQlN12T5un?= =?utf-8?q?JNzWPZYTDhcEL4MsI2W2vgYk1o/bbqYjE7izb/TOmnGlTYaWXROJ/eg8BVbmzFFqa?= =?utf-8?q?U8AskQuL2+FEMyxM1aLClSCTQXZ0S3GvKLbcsMl7bKCyTe1pC6/sqYcZAgVphF8tG?= =?utf-8?q?QwhksF1cMIz+5bYTFaxYLO4e2RZ4xku3h9eWAhnfS5DJ8YXIBMUdHIe6WZ9iYG6Hu?= =?utf-8?q?qS66usHd7wHcv9fIUfwhx4zrKUznbaBieruAH6bgmf5GNfM27XJfDuiRAOJXvjpHS?= =?utf-8?q?vfTXzIFIwhuwdX/NjN+ZazfHEyUQJQwNTIHKpou0UxwSiXf/06rbP+pixsWog3XfJ?= =?utf-8?q?ffnXo5Nfky3eDrJfZ3PJqRvAGtZTYLSZpTm/5ca6eI9qB65Hrf2e1+vLYCJcxozxM?= =?utf-8?q?pk4Uaob6KJAttWyHLDADZqLqOnlpDf0/zYM4hR6D1ivy8/NGsZMARE2DfyGjTpi1t?= =?utf-8?q?OecbxzEfSEX9xprMDhzSzKKoAfNUuAfIrzghyp6yLW39A5ok0IQ0RLA0dyEnUcMOE?= =?utf-8?q?jtrKOwH0psBSdCkN7YEMfKZZ9CuLecgBFrfqyd+9h3QyYnKbC8SSh3TGBuOvw1+p8?= =?utf-8?q?AslnsB5ofjCzB5k7oJW3LY5DsTPGakJk+Xdlx5aJouD4Mc6G1K57mV2EYJM60Ag+Z?= =?utf-8?q?Jua/GKPeth2AYYvxVC1+SZgMe7stHNR3wTLTU41Awn78NJocl4t++pCmzzBHlN0X7?= =?utf-8?q?gNFdLN14ErmVIz3gOoCJfsg3KLdPEd14+v1bpXKR9GW3bL4ZCx7zCwVXMRVaQp+ld?= =?utf-8?q?TyLVI6/8WdWtEaQGjJY6R//+itCXlLk9E0lrVhVobkTQuvZ0dkX4xl6ymX+7C0tPK?= =?utf-8?q?zB42I++YGGVebv/Z3W9Zsmgs4W4A0aiaf2NjRkyTzMrYL+xTvpSLPLx5IQeB/s0hU?= =?utf-8?q?wAEW/yyMgtg14QU63Vn7/EtpOu772mM6dILinXF9FCemJgv5+2nCt4uOIfLwgzUtO?= =?utf-8?q?aEkedyOenludZIJs4P0NZsSDhf/WtqpTejDMgdgZ2f1qLt4X+xLOfw7YLTL91qIla?= =?utf-8?q?ZWexCyWtFewAhtelY7r6eTqgJ5CmS7JFJ4HfuwwHC6XG9icTSg2fVIPX5gS7+WZws?= =?utf-8?q?g+WC6cDfB+N49jw0bOEIf3Iy0i3cpLNkrq6e/kmi6GasLa24LY2hf9h77yCijcl3k?= =?utf-8?q?oRWOmVf1akavHXRE9IamDVV4IezH0GhDyUHYFvj3nJbsM1I9p9ZqxUcVQmczh05mM?= =?utf-8?q?0xI1V9gFMoceJf3i827aZuPrNvXuU2q1Ob8vYkNaTKvFhn1DV5wYoTXfRTYEIfTDl?= =?utf-8?q?/7+8eAJnLsD?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(7416014)(376014)(1800799024)(36860700013)(82310400026)(7053199007);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Dec 2024 05:51:33.7141 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e41e1bb2-2486-46f4-04e3-08dd129560ae X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CH1PEPF0000AD78.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR12MB8496 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 --- 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 b73cfdd920c66..6c87e982bfc8f 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 14d84cad01b49..805bce80beef2 100644 --- a/drivers/platform/x86/asus-wmi.c +++ b/drivers/platform/x86/asus-wmi.c @@ -4852,7 +4852,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); @@ -4879,7 +4879,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 b9a6dd7b321d9..3797a5721dbde 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 b6586c473ba91..95b66ac3ea1d6 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 58af9020382c1..298100d5c535c 100644 --- a/drivers/platform/x86/thinkpad_acpi.c +++ b/drivers/platform/x86/thinkpad_acpi.c @@ -10660,7 +10660,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 Mon Dec 2 05:50:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 13889996 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2046.outbound.protection.outlook.com [40.107.223.46]) (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 D11BE1F941C; Mon, 2 Dec 2024 05:51:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.223.46 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733118702; cv=fail; b=mf2nLxy5SXbakmZimNiQUWK+3QgN50kVlHWPjLqeF/aXmFrid4f/QEZjqO4HPeZTQjEeoYOTtZIfhk0s+2W77OR0w45F9ZwkMcwuuoC384tiTCmzur35NzdKgIVddRAeY83nMHm4t2Uw4OXzIxENj8WyOdEJJVTo74OF5mH8ohI= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733118702; c=relaxed/simple; bh=2sGp8nsceMSqqbGFXAGu40PROo274ncRCGZ1RbgNNlw=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=t4sWLmcvk3EXuor0ZEw2y7b5GnLsUAlu+DRlZjeCdZywYP4VBl8dvlGWFfYY2T1SUOFaWwKbI1V/etf3eyjqM2sZ2hf1ryE97CbEEtwnagxEsuViK2JrFqkpQJCeBM8+i9ISlm/aIplzcaZqi2Kdo3u2oXjbREOjQqQsX/Foj0Q= 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=r9tq7M6E; arc=fail smtp.client-ip=40.107.223.46 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="r9tq7M6E" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=a1cOKteqJnGzTkvgiw75orWMkDcmZRZJbxI4E0jxxVXnNELIbLt7O5I08KM/dr4xfu0U8NbkADfAnJ1d/vDOiqyaAUbS7WWH80RBnkkkq0vpGoa68r2binkzvze/IagbCXPfBDOlWYV3RSYcM32Ej27eGP0Wh/UXcMza8abTc1HYOyYJhXizkZ5Vc2BBlbAHp6mJJf9l359Qbmtl0v5zfKV94IQhqHNiG5XFO8x4EeDf8srIs6xn/DEGb0zdMiZO8OFyNYwsGFQ1AjisLf4HeiseArymVv+UCMubA9okktSI1tQP3DO9AATFPU0TQ0GmBXZExeNU4o8FQPyuEll7RA== 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=PtJpblUh8MBOEucV5B3TNCycXxWvmJz0+rzIT5JUVPU=; b=C9gHq9hTouKJXXBfHlk0trxQRfQEhc1uOXC4fnZFEh2Y7xKFz2lc9Y8X3wsWFYujO6HIbpBjeEnr0pccvxk9F6azYSXBNdtfTcxkDjHnVhEFSwgGMGnpCA/Fj+pDiL17nY5Qji+lVcW3CDMaWnAnypFG9jz4VppcF+UslpA1c16BaAB20yRd6deKG8NkMlqzUUGfuAOyUDFQMBf1rpHdmgtHP9W9RISfffmFjJ49gZ/h2oIzEcKE2gCUvMjED2VSkj6RXDh+roMkNn+x0a6XR5DsVXvOB+IVVJeJgOXyByXsrlKMO2EPiucNX+zp+IzDmCwi3eJnPrDv1NoR9dtiJQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=redhat.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=PtJpblUh8MBOEucV5B3TNCycXxWvmJz0+rzIT5JUVPU=; b=r9tq7M6Exfz4KRUxDsZyw8Y4P3eolhrWcusd0tsuGM8XIIwQRp5b7uZHrpl4r4pPsicHkuCT95fKFzHi+OydIG+hz+4Yi8ZSJYmRVPBktlclF8W5y1J2sdssyI+8+1Hb6wy8scFUfKhi1EbcBPdQX6Y15zA7HU317o3LU8JwSZk= Received: from CH5P220CA0020.NAMP220.PROD.OUTLOOK.COM (2603:10b6:610:1ef::18) by SJ2PR12MB8830.namprd12.prod.outlook.com (2603:10b6:a03:4d0::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8207.17; Mon, 2 Dec 2024 05:51:36 +0000 Received: from CH1PEPF0000AD7A.namprd04.prod.outlook.com (2603:10b6:610:1ef:cafe::27) by CH5P220CA0020.outlook.office365.com (2603:10b6:610:1ef::18) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8207.16 via Frontend Transport; Mon, 2 Dec 2024 05:51:35 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by CH1PEPF0000AD7A.mail.protection.outlook.com (10.167.244.59) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8230.7 via Frontend Transport; Mon, 2 Dec 2024 05:51:35 +0000 Received: from AUS-P9-MLIMONCI.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Sun, 1 Dec 2024 23:51:33 -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 v9 05/22] ACPI: platform_profile: Pass the profile handler into platform_profile_notify() Date: Sun, 1 Dec 2024 23:50:14 -0600 Message-ID: <20241202055031.8038-6-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241202055031.8038-1-mario.limonciello@amd.com> References: <20241202055031.8038-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: CH1PEPF0000AD7A:EE_|SJ2PR12MB8830:EE_ X-MS-Office365-Filtering-Correlation-Id: 1745921c-4dc3-423a-0cbc-08dd129561ba X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700013|1800799024|82310400026|7416014|376014; X-Microsoft-Antispam-Message-Info: GsAQucWpkXDk52kISSgOLFeTyYZ6PZDojdMgmRG72XHsz+CeaGbCn3GRjwUmXeNqsXbBUKz7nmh3dUWpR/fEzvaAmJ4UGfI5niXwSrEutxe3tfxubj4W+vbyqdpvcxBPdkyXlxpMjZ9eLuka6Scuaa/oNXRo3u6L4vMWnspVZYR70yJ1v329GUrmeFAPR+GznRFJ7xz81qXhXUyIk4aWpZBhrgesV/Gao/r37/ijUNDAQ7vGYlsPR4LLj7ynG45iSxM2wHYAGsT88ssFR5XxdpKIM48DO3d/bmbypUNxmtz9WzE5TIfKa5ArYZ3vZkkA/KMorS+2sGy3IG0QUMyEFHcXVCot9eyXiEGxBJ7uzOY/M8na48X3vTy4qv9rK4MPZ7VNsYIfHjVKbfdOgeqHPHY0bYtDBlbVz84XZmw2aPcStcDRmeFZz3YzkF+d7DZF92k0KBcGjF4Ih4sIvlk7Z+ejg3FFBaADNRM9yGOlzeyreWuph9sPl3S6LOwf2oYf9tpXFXVfub7NRTillLGHdW1uSW39LD+EAqfxD5Ozc1V9xAB2owvfGHay0vUTmiAgfNJPNEVEFWU8lCfAx16IG1ZDn4nA3/flxxjPtj6su/c4KC1f5t4IvYoEfO8ewJg6IW9xphNOOwL6VzBxe/OsMVmMenYgQA/lFb5F8NpiNgmZjHe0Mp6oyKS4d2MR9ANJR7TYn0trC/NWJkYS9sAStzKkZlPjL6i1HeZvJGCDibrNIHxmo1TGz/udlJhEpu2uJc7+jjiJCSApGD86yoJw8TRpwTTrsUy56K/h9LyUk+YyRFxt0UE9Mc1o5bYrrJ3HEUEuAycu4UKzydPcEbTS2Fcq58bC17+RPXh8JQPHyRZjxhUip7j6ydeV+C+eCkzVYNc8dZMXDhnSaS94dp+hSpYvnm0yQVF/kpq5thTP3GVA+P9IhT6V0OFwYUQkR56IbFLxu+zmv4p4NKjP2N6O2x3XkmEMj9eJd4iSh0xrADOkBcaOzQzrtKXdP0DwDOCp7PzqiipACeef+vCCLAkvp7pMGpp9EoYp1LriIrAl9qeKenPscN8NgrAkPofIMgBJTEC+wKsjc/jsl2DaXUoQx6f5IYIhLHGb6f4vOKuBJ1XDi2D63Ms7kqYyJku+VC9/TVabMNMon+Fw90VrKgc326e68rWqeS++SBEjSCOHDaysrwm9S2fWAppU2JzhaiVWjM1+hM2dAiGZk8Vc5UZrZ4OGL02PEcbMSs8oO9As8KBJFPvEWJ8LKozcKqjf/Bpd6JyUx70VT1BsHzAdf8qGOuNLYbqiEiyR+wQ1d3dhsWVTRbN9ddFPo6qow+huUlEyPkrgRserMsV7g6axzfB2WRx/kAPytA+7RkzdMwAFKj0fKakcjTQjqZus9vwrsbuHz+N38+S1sUGL8vCnIX/ISCexcLxJXB12Kms1I3ho7/BvliS66bFTUv5DHDdVo96n X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(36860700013)(1800799024)(82310400026)(7416014)(376014);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Dec 2024 05:51:35.4550 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 1745921c-4dc3-423a-0cbc-08dd129561ba X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CH1PEPF0000AD7A.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ2PR12MB8830 The profile handler will be used to notify the appropriate class devices. Reviewed-by: Armin Wolf Reviewed-by: Mark Pearson Signed-off-by: Mario Limonciello --- 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 805bce80beef2..fdeebab96fc00 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 95b66ac3ea1d6..00b9c0c32239c 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 298100d5c535c..f516628617384 100644 --- a/drivers/platform/x86/thinkpad_acpi.c +++ b/drivers/platform/x86/thinkpad_acpi.c @@ -10538,6 +10538,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; @@ -10566,16 +10572,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 Mon Dec 2 05:50:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 13889997 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2048.outbound.protection.outlook.com [40.107.243.48]) (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 5735F1F9423; Mon, 2 Dec 2024 05:51:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.243.48 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733118703; cv=fail; b=D9yx6XA57im6fJatO9SiqAqK4gXI0nljMri2Ex8pnDmd3AuZlgmsU8KCl/BZxG8ilOASSpbh/XcEEMo1uawBFF92d9yQSiPh82QyE+nwUB8SQYu3xkFarjaFNxqEoPGZikAbqWxdbhM+jahPByOwx2AxjjkVWASQRBFB0j1gMQI= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733118703; c=relaxed/simple; bh=z0GlcC9vwRUmxS0LWl2nrqiX/2qAQj38IxksQe1F4C8=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=LX1cQdxzVN6uotNOQn7jjTV5ZhPEoQzISM4y+dzO15rdzIhnydWVXUoz+TS2aF/qhkMTphVO8MMP34kUk/xlu4ptjgvmHSVBwogrFSRnv8zJn1Xz5M3yBdtDmuzV+vWOkmYmZP4EaFgpHnkbXy3+1BHLQsfkyyr2q9JNvvJL5rE= 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=Cacak7Pu; arc=fail smtp.client-ip=40.107.243.48 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="Cacak7Pu" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=A6n8Zh+5FZFiAipwpcGfg2WF15n7rJWJjcZ9raBbB9rddYcfMSf81epGSx8lTL+JzM0YXPe2CberYM0I77KflNIeKnxwE5/JtKJACs9ffQVWLfq/Y7bl7nnm7yrA3h74nL2/+okXJDGhmnmYbeGD3MQuoRR3FHiyMwG+Jm461oqSE+mDpEC32cTHFWsPj9v59GtP1HrykphD8A3FY8YtM4bqbPaoimUASCjT0HX0fOMi676h+aOfVXAB/CSPbwP1huSIDn7dZ8VoGh49SabhEFr25b4+EcnMpe7qyF2tnS4tJ72rkFx3Zty1iwFso3JInZDd0fyRZJtLf1Um6SdiTQ== 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=Fbrw9w+y1t+fOwFGCAec/Yj7kmTgUhQgGzFW3WCgW90=; b=ZVvYqXN/nvdvSGEDkfTJRviEEL1RUwxkdqeZ9A/kgzBqUGYiqBG1SlrL/oph1n3IRYRBh7nLINKglY8BMgKTmnYSndXZyUg5CJ22NERupSjLWhEjGRW4cvuo2N5amnIvd6gijpRKQ0YFFzxjMpBoeyO3dQ+yRPrOT2CTBMYBhIdA25sWSbPaQsuiovP5V8S3yxB91o+e+cfQQQKwKNWZhQFFS/Gs0WYAsBqCOpkeoj1FpbMRZo5/nXX65+Nx93OfqLqQrY5UxMgZ2tdr6Kdz0X5M9kdnnnT0adBVvxuTSkaAu1STsNODwPBlHzLKmOuthtzPLieCXpiLupcspJMEtg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=redhat.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Fbrw9w+y1t+fOwFGCAec/Yj7kmTgUhQgGzFW3WCgW90=; b=Cacak7Puvxq0zPdNUFrIrukzqoCHOQ6HTfAKyeWVgnJ5HpHIFGsect1PA36Kevu87Tr2xKoBrqMYhL2zHmRErzlBrwCZ4xcG1hVhOz8SrVvB2KrUmjzAF3UUxQzDnYU0ndFMxfZASU/uFI9waZ2HbCew5LlGkfToN5OsHOjDQIM= Received: from CH2PR08CA0011.namprd08.prod.outlook.com (2603:10b6:610:5a::21) by CH3PR12MB7546.namprd12.prod.outlook.com (2603:10b6:610:149::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8207.17; Mon, 2 Dec 2024 05:51:37 +0000 Received: from CH1PEPF0000AD77.namprd04.prod.outlook.com (2603:10b6:610:5a:cafe::3b) by CH2PR08CA0011.outlook.office365.com (2603:10b6:610:5a::21) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8207.17 via Frontend Transport; Mon, 2 Dec 2024 05:51:37 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by CH1PEPF0000AD77.mail.protection.outlook.com (10.167.244.55) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8230.7 via Frontend Transport; Mon, 2 Dec 2024 05:51:37 +0000 Received: from AUS-P9-MLIMONCI.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Sun, 1 Dec 2024 23:51:35 -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 v9 06/22] ACPI: platform_profile: Move sanity check out of the mutex Date: Sun, 1 Dec 2024 23:50:15 -0600 Message-ID: <20241202055031.8038-7-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241202055031.8038-1-mario.limonciello@amd.com> References: <20241202055031.8038-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: CH1PEPF0000AD77:EE_|CH3PR12MB7546:EE_ X-MS-Office365-Filtering-Correlation-Id: 1a2daeb5-5d57-469c-74df-08dd129562b2 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|376014|1800799024|36860700013|82310400026; X-Microsoft-Antispam-Message-Info: =?utf-8?q?Ob0waUBxCwFRErlnGSXqRWS7xw8ooxj?= =?utf-8?q?5JKWdrLPNj0Yr/ENRQyzw39fBSaI1zw2o2vtxAchNFZkb4tAoGAbLX2GkkPMpRXOX?= =?utf-8?q?pacfuT63i/yakK6FyWZrxN2s4YoQwH51mpMbuxQOpzjRjBUK2lZUKBOWUq+PemFCO?= =?utf-8?q?E+ZDTd9a879kM33kcYLtyzZVTHLaioNo66ZSW2G2Rzof54BWHkw7LjhFP6KPDqGDt?= =?utf-8?q?cx+jKcUI1xF4SBqGwd1sxPvApYdj0GbRDPUmByG+5DAho5Bjfk44f1bDKSJnCQtr1?= =?utf-8?q?xNVpfOylsZIjaRMfZHmvtOau+LAuLfaVARFMvaOvTdcIYvcYevUUnRbBuVoGomdpC?= =?utf-8?q?0hVgYgbvWbJi3udx8pjKv3qiwZIheKXL6OXMfdGMZATbC4Qz8MtnUHuQ92HnD9dsu?= =?utf-8?q?1nJ/Lja/IGXeUBL1csvbqUfYLQJMbUIa1jyRCLq9wuPIwBweowgcq2UQGBVtPLmPv?= =?utf-8?q?yNM1DK2A+sfUxIMNAkFkl/o/4MimmM8s3GNzp3UrOSHy8VI4ZMs1J/DG/yxkwqdfQ?= =?utf-8?q?oseBsxMXwv4MtIxhP4700MOHHrX6Sk615IlpTAvACEmECt6eCLZMI3cXui4zy6q9D?= =?utf-8?q?3+4BgxlQA63rBrJ4pOSqOu9v6C49ANA34xhYNYiUinpAEZde3y5qn7ma2scrtBTbe?= =?utf-8?q?ce1IvCsF4k/CNJLLMgxn0PI8MJKDAtmZrn4AL8LB47zgAFGZAftMYr2DlWQKll4jr?= =?utf-8?q?F7WiPaBbjP8eDXzfMGm070iQGvDh5K/G+epjQYj9pk/mTQyoLjFzsyzDk1eqxy8ij?= =?utf-8?q?UyFIIhiVMGPpaTskDfsvyOtbsB2PDEr1Kb2sgWTx7sTkVa1NU1/JLhP1YtEIIhgzb?= =?utf-8?q?FUvfL8D0y7cD8XP31u5jRMLTes/5SRb+rHADcCmS+zFhthmX2t7VLEL8mFgxWWwSH?= =?utf-8?q?l/Hx90hihHkjYDrgKOPUduGIYw1/GlCDsWkyn4euL++eiXeNyT8NGRa4618BSTOsL?= =?utf-8?q?XjjTcPMs5orpCyQxUKd6S4xwzfQIMfkwBlFWFoeQaVagbSHIZrP1zW3FOPokbpjyv?= =?utf-8?q?1GZWbBgrSIW8oxwd7bNl0rP6zdQridUKmzNlpC/fF0fVA3ReqYMYVR/ydJMwlpfxV?= =?utf-8?q?wZJCevxk2AS8ox99sOGsto7lfkN8uAL0za5SQGvN4D4JyDF+kZTuETiSR+r4dH5hr?= =?utf-8?q?FMyNnNEL8+WBupydlXlipC+HwIpdpVzvLHBGZsJJ/wM4b5NpXwGPVnd2y9AMFfL61?= =?utf-8?q?7sphM+umzx3rFECOI4/jQ7AwCik9uKcHYxE96k/e8+/8W2bJMtp6pKDVPqO1ZsJGK?= =?utf-8?q?sE1GGnVtGhYUQabKqm+rTekYE8Purd/DOcPUfeli5PTbK7f3UvbnlV5P/Q4yaaTLK?= =?utf-8?q?Zc1kid+7MubzjlJAHcNkT5/jLH16eeQOfnaEl6HdGhzPEYAPy5OoCFFFE1D/fhBuD?= =?utf-8?q?DHQnvsH4Q6z?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(7416014)(376014)(1800799024)(36860700013)(82310400026);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Dec 2024 05:51:37.0986 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 1a2daeb5-5d57-469c-74df-08dd129562b2 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CH1PEPF0000AD77.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR12MB7546 The sanity check that the platform handler had choices set doesn't need the mutex taken. Move it to earlier in the registration. Tested-by: Mark Pearson Tested-by: Matthew Schwartz Reviewed-by: Ilpo Järvinen Reviewed-by: Mark Pearson Reviewed-by: Armin Wolf Signed-off-by: Mario Limonciello --- drivers/acpi/platform_profile.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profile.c index 927a2f7456c9a..4f5623fc27c09 100644 --- a/drivers/acpi/platform_profile.c +++ b/drivers/acpi/platform_profile.c @@ -179,6 +179,13 @@ int platform_profile_register(struct platform_profile_handler *pprof) { int err; + /* Sanity check the profile handler */ + if (!pprof || bitmap_empty(pprof->choices, PLATFORM_PROFILE_LAST) || + !pprof->profile_set || !pprof->profile_get) { + pr_err("platform_profile: handler is invalid\n"); + return -EINVAL; + } + mutex_lock(&profile_lock); /* We can only have one active profile */ if (cur_profile) { @@ -186,13 +193,6 @@ int platform_profile_register(struct platform_profile_handler *pprof) return -EEXIST; } - /* Sanity check the profile handler field are set */ - if (!pprof || bitmap_empty(pprof->choices, PLATFORM_PROFILE_LAST) || - !pprof->profile_set || !pprof->profile_get) { - mutex_unlock(&profile_lock); - return -EINVAL; - } - err = sysfs_create_group(acpi_kobj, &platform_profile_group); if (err) { mutex_unlock(&profile_lock); From patchwork Mon Dec 2 05:50:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 13889998 Received: from NAM02-DM3-obe.outbound.protection.outlook.com (mail-dm3nam02on2070.outbound.protection.outlook.com [40.107.95.70]) (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 AB48A1F943A; Mon, 2 Dec 2024 05:51:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.95.70 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733118704; cv=fail; b=FVWno2bo6Ry7sSQDhbEltzrea35bqq2LtzIKMrSq3olVzEH/dmsFOwaNkCe6ySgLVGtiHmjpgw6Uwd9MDggsRYqpafEFAriZx2NTz+I15O8ddy8he6d2x0yg+FBrYSxq5mdYhvyP7td9L4MVGJjPWZw5mTdubAs6P7PiOShf9KE= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733118704; c=relaxed/simple; bh=+xN18sNC5Ocgap1+ttPhDXae8uq0m/TFsmTPn/lgO0w=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=q5La+X2qRBKtg1UPYBhqlBB0+74enrmQ2obofmt+47ADtixmexz98NMz4XGMKftoHSb3zvkTabJk6Lm40DPKU4z+nLqbWHQphftW9T4fLB1EncOx1S1wK58d6lbdCGQBG55fAh5kbxLl5TwBETwtYOGN3h5puUGmJYsfr7gNPhQ= 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=pX/LnXVb; arc=fail smtp.client-ip=40.107.95.70 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="pX/LnXVb" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=NkmRMpUYDjdpTpUT0Rm0kTENKTrskdYRQ+whALPaKvqeQSqTgXDWSVWQD1WEh2url/kOKM0OugqaQIIVH3ZWnqTdSLQZYcjeQI2ixmjT+gQvzlEP8gVm0XjlGv9eH19uyIS48FBzo4Ckw+rEh4wrFwv4RKWH3yDMzJuosFY/tL7t4K2DlNOyVuiaTMzGeG9AZtGHUuPV3E6j9wryP4C3wXuE6NYcUYuGL/MKa80/AU3ZHQbNbkKni8W7e+5SbgD+QYKxKuIs2lQLny2WQbXwqf7xhvfpylDaYqsbx1laCULxFnrWEWrm2XZH8qE2e2q8cA8CUBjNyR2N0uFCzWad4w== 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=N+XaE8yyWjGIn19TzASAZzj0sYETWpxRAyipXeNBClA=; b=OM+lKST2hXsDoGhqsSsfXyyP+jmTFgUZjGUvfQg3f0Mdq6CWwMtiCwAxvaKl+gg0bBTfsiFCmhdv06GvAw61+eQpHJc0OjBPiD0jW4gXQ4CnrvonmHnpT2lDlHzmd/JDmXJHLymoP5pw9F2IRGrstrJHy5WSNJwlnvCbkurxeGoib2vzw9oTVOdV9VF9Ig3gYHzuhuOuzcURAwh8F1CA3+yuFDXIA1BBiHjQvVtKxGBAmC68eQwsRLTNmteHIixo9n7Dgzw9gEMkrbmW018Gj1PikfcGgq8ViKIApVL3Ap4O6FmpJSIv4/UTSxaaydpHDWsgk46Eg0ZMa1jrjC6Clw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=redhat.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=N+XaE8yyWjGIn19TzASAZzj0sYETWpxRAyipXeNBClA=; b=pX/LnXVbEN9MQkjuTzFun+HgQkJk+3osYrtioiZpDPLVFsSTZtne1Wnqh29xI8aqiLWtl8z+JfAGQe8/8YeFJvjRrUfJB2DV8VU8YEqnRfgEEl4mWjGEk4Glw4UHMNHQ3uWnK/2y/pv2qdbNeRijUkMMf1MO8kZhCkgJxOXEhmY= Received: from CH5PR05CA0019.namprd05.prod.outlook.com (2603:10b6:610:1f0::27) by DS7PR12MB5768.namprd12.prod.outlook.com (2603:10b6:8:77::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8207.17; Mon, 2 Dec 2024 05:51:39 +0000 Received: from CH1PEPF0000AD75.namprd04.prod.outlook.com (2603:10b6:610:1f0:cafe::a) by CH5PR05CA0019.outlook.office365.com (2603:10b6:610:1f0::27) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8230.7 via Frontend Transport; Mon, 2 Dec 2024 05:51:39 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by CH1PEPF0000AD75.mail.protection.outlook.com (10.167.244.54) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8230.7 via Frontend Transport; Mon, 2 Dec 2024 05:51:39 +0000 Received: from AUS-P9-MLIMONCI.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Sun, 1 Dec 2024 23:51:36 -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 v9 07/22] ACPI: platform_profile: Move matching string for new profile out of mutex Date: Sun, 1 Dec 2024 23:50:16 -0600 Message-ID: <20241202055031.8038-8-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241202055031.8038-1-mario.limonciello@amd.com> References: <20241202055031.8038-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: CH1PEPF0000AD75:EE_|DS7PR12MB5768:EE_ X-MS-Office365-Filtering-Correlation-Id: b7a27436-31ed-486f-96af-08dd129563ea X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|36860700013|376014|7416014|82310400026; X-Microsoft-Antispam-Message-Info: =?utf-8?q?Vq8rzQdosqePLPHfjnBwnrTOXPY7tIX?= =?utf-8?q?xazjdOsDaGJDHVg1d60QcCoGWzJNFr4K0TsHY4p2cguDMEHjZyF2duQcWEaMC3ciC?= =?utf-8?q?eVRY8oXDrhE1RJ+/Y8Z8KwY8RfE3aKo2IBPyjWXy5h4jnTm75QI/Ydsz6IYudBYe9?= =?utf-8?q?Y94OGW1fAN+1YAktf4jYhT67GcWXhasZy/+upPNyBWgUa0nCbWkBDmQyj+2wg83iV?= =?utf-8?q?YfJByskYMQFn0cdooamaIpXNl+nxfDZ5CnD36+NrL+ZwD/S7PjztRjB5PqLyP35ug?= =?utf-8?q?URhYD+GoI+P9esTJyu5GTYuY3nU8XcwIm3MAHdt1hzHp/h9BTQ3AVZl85BnWBS6bq?= =?utf-8?q?hnAj22tulv/wmu5Cr1FMESTveB8UYt32yhfbAaY3xUpqOPrdALKkquvT6PFpDreJ/?= =?utf-8?q?hj9mGAO8uFix+h3j153K7YEPwAdvUri60wb19/lsKaoQ5+UE2GzWfOM5tnUhBOPQj?= =?utf-8?q?Po/jup5YApUVu+jEL4r8JUpYOSI3Y0CmzBfBlPK60eRaAKfLXR294QPTXcgS5jggD?= =?utf-8?q?ohSYmms49/4d0UYEG8zz7132q5ym0oHIz7Fvhf1SbEx+yn7nD/kQiqNePpFZwe+dM?= =?utf-8?q?nN8Q8e9FUMy7TjfaSZNTY/21lSMERmaaPXnxX8i8eJE6S7m3tF6wOKkj9m2wkmNUl?= =?utf-8?q?NpxzO1cKT0AO7gu74RV8eCxhhgKn+SYYW2K545OIpvy+KOwESYVUfltNII509a7fy?= =?utf-8?q?4tIrqc6AocEPYWNvxRt3yKTWne4vj+1eMGr8ZzUiMosz/VOaYZtCqfKEugYjPxF18?= =?utf-8?q?X/1wp/AKGnBpM07AUebkAXBhSWOvneReK6quzEvK5sGBoAA0nE2xYUug5SJP4eI09?= =?utf-8?q?U7P0c7CPqp/vw4UY+EXcJSgvw62Ssgehsul/kFGVIJB6+9sshF2/WZBfOJEDuYM2z?= =?utf-8?q?U3v6Avh5BRhrGH9WKzQXwSXQfQlyDkcipmzhVuKpIXI1R8XXK8C0HwCXqd86SOyqQ?= =?utf-8?q?HKhjQ/WctEdoywGsGBgYD9O9E6KLjNKWfweKyyqPW70uBy+33R7J7gyXw9iurloCT?= =?utf-8?q?y/Zevb12ljgLrOdUqJQBqw25I8BtWBQ1VQl5uf1xcXQdp9uZ/24Vd6Sr6JupHkY6T?= =?utf-8?q?3meirnGeyUbB9R2fFWxJoOSTFBB8RLhRFn+R29e3Z3psorbmbD4DLwNjYzqbo3ULA?= =?utf-8?q?yYywsblWH08ZU4PGAznCvS553KjIr1yRntBXAYmp0Mr/gVeiqIFTO6YHRetaVaymR?= =?utf-8?q?InaMbb8ueDhG3BYqc8CDghcJ+N+Vfn3fSVcrKSkiwsX/oxHaIRrpO/p2El1oJo1TB?= =?utf-8?q?wOqJu0kJo50qGo5wKGrx4Ds3LpmXZe9skaZy3P/xZsrHbhGpOZgczK9k1kWuE1FUv?= =?utf-8?q?NPb07to7DvsSzMQnzNckKZhXfALF88YbT197tTEki0GZGh1VVctuCVVZ3I+eOfSCk?= =?utf-8?q?bwq9umEXb3W?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(1800799024)(36860700013)(376014)(7416014)(82310400026);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Dec 2024 05:51:39.1286 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b7a27436-31ed-486f-96af-08dd129563ea X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CH1PEPF0000AD75.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS7PR12MB5768 Holding the mutex is not necessary while scanning the string passed into platform_profile_store(). Tested-by: Mark Pearson Reviewed-by: Ilpo Järvinen Reviewed-by: Armin Wolf Reviewed-by: Mark Pearson Signed-off-by: Mario Limonciello --- drivers/acpi/platform_profile.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profile.c index 4f5623fc27c09..45ffd85a71dd5 100644 --- a/drivers/acpi/platform_profile.c +++ b/drivers/acpi/platform_profile.c @@ -83,6 +83,11 @@ static ssize_t platform_profile_store(struct device *dev, { int err, i; + /* Scan for a matching profile */ + i = sysfs_match_string(profile_names, buf); + if (i < 0) + return -EINVAL; + err = mutex_lock_interruptible(&profile_lock); if (err) return err; @@ -92,13 +97,6 @@ static ssize_t platform_profile_store(struct device *dev, return -ENODEV; } - /* Scan for a matching profile */ - i = sysfs_match_string(profile_names, buf); - if (i < 0) { - mutex_unlock(&profile_lock); - return -EINVAL; - } - /* Check that platform supports this profile choice */ if (!test_bit(i, cur_profile->choices)) { mutex_unlock(&profile_lock); From patchwork Mon Dec 2 05:50:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 13889999 Received: from NAM02-BN1-obe.outbound.protection.outlook.com (mail-bn1nam02on2065.outbound.protection.outlook.com [40.107.212.65]) (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 79F381F9EBA; Mon, 2 Dec 2024 05:51:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.212.65 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733118707; cv=fail; b=PDuMMk4MZN2vFZiSGqa+lbX5gKEkqLjMTLdw/OzVx9vjEx4LcZ8mL7bVM6Z3h4lwlRy/ff1TyRkPn/f3QIZscFaPgFSkjM/yNne7lbHqckY6Tkl9wHe7gGklryMPg09ywYxu15TUwCwLBS9wbtGd/KCCnCewD+7twalk3vRHoSE= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733118707; c=relaxed/simple; bh=JewyXTxhFRqy6h34+YKrMpsgMeLgKwlZqckAx0I+7ck=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Trd1aTkXs3gjPmycx5uvs85/rvWJSPaQx8yqY1WzNdh4weX9sXBU/1ttL5T6jQHa4aqQM3vZX3nfn47AQzTggPpSFYgU8DDOfDxMOizOYQCkppYA3VwoQ7gqK1NhXMBTtLhWwD7r5OfipY4BPSU+cnAzZKKRY+G3CdJNknqYgr4= 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=v08x+nmk; arc=fail smtp.client-ip=40.107.212.65 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="v08x+nmk" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=i8H2KS75srIrOUhqa8mUH3jdnJZizWLiKGmfofcaAcWH2X6NIGVPPi2axNhtewjWtaZefpLXHQld8PmHRH81k5UlIYhPDcre4sO4PnUj8gFjl9kunnfxXEfeE2ttMIaMT5WK+C+twrC7cKmo1iB1kH7Ue2SA+zIo7Ia5M1pN8qAcRGhQbZ2CypKHi4jVA5DwY2n+Log4sg1ujKtVeFqS7ARsOhJUhiQvKkK4GaBrYxEE+S6KKT3XKBFLHo3oV4Fgzie8RVoU4u60E7T/NC60smyhgjasuY4lMvECU6ZWbc+drh9950qUUffmaLcBrtaOCoQNjDaJkLewBUX502FTkA== 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=GzTOEsPUivWb/QIFaI+QJ9Zx4kO+zDSGKOXAZO2RfIUSRFpCQu51hptkT8AEs4ZONXEMSiz++ZfsLCpaNy6bKiBDPYDZvnaMziqnPBQESio4QoVX53DvTPC3Q4FxQaXtS1shwVrHfKkZ77BZfeiCXoQuggsWHW/oyk2T56bJ5SyH5yM+ZbVxwfio/T+JaB3aU/0+OzK6jjYlbuj55VmtBQRpaqMqpBZME3G9xNxtdxBOuLnUxRTJ6YB2gRnJoJ3MXeVv87ih6IcL9D/Xfh/7YEBJ7n+LtNitOVMlBpZgXJjEmw3A/+soR7Udcmj8kB+Irvh5YePUyjBsKZke7rG4Fw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=redhat.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=se/DRSG0jq4mSe3JIlni8+u15VBvik79rcxTvY6iGeE=; b=v08x+nmkvA05H6jmTVirxUqJJ0FegBHxtRInY7uF21UQNoPP9IdTXmgR7yBgQNrZMr7QN7OhX9TpBYV22zXmX/1FfxMWA+ZFkWLtV0wRA+EKnCKvf75Fzj2AeINwujDT+mMyCFs0Vo5QsC4os92jTRHzhJbX6HPDcZBRH+dov08= Received: from CH2PR16CA0018.namprd16.prod.outlook.com (2603:10b6:610:50::28) by LV8PR12MB9154.namprd12.prod.outlook.com (2603:10b6:408:190::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8207.18; Mon, 2 Dec 2024 05:51:41 +0000 Received: from CH1PEPF0000AD78.namprd04.prod.outlook.com (2603:10b6:610:50:cafe::93) by CH2PR16CA0018.outlook.office365.com (2603:10b6:610:50::28) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8207.17 via Frontend Transport; Mon, 2 Dec 2024 05:51:40 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by CH1PEPF0000AD78.mail.protection.outlook.com (10.167.244.56) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8230.7 via Frontend Transport; Mon, 2 Dec 2024 05:51:40 +0000 Received: from AUS-P9-MLIMONCI.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Sun, 1 Dec 2024 23:51:38 -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 v9 08/22] ACPI: platform_profile: Use guard(mutex) for register/unregister Date: Sun, 1 Dec 2024 23:50:17 -0600 Message-ID: <20241202055031.8038-9-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241202055031.8038-1-mario.limonciello@amd.com> References: <20241202055031.8038-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: CH1PEPF0000AD78:EE_|LV8PR12MB9154:EE_ X-MS-Office365-Filtering-Correlation-Id: 40cd4ee9-ce26-410e-ae6b-08dd129564e3 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|376014|1800799024|36860700013|82310400026|7053199007; X-Microsoft-Antispam-Message-Info: =?utf-8?q?GUwgzJM4pXHdozq4VL9UzsdI2HDnGro?= =?utf-8?q?BxopqKOwINQQxdjz4x2IZvlC9n5CrI+T3q+y4A2istXt1JPMG9jJB6x9l0eEzamYg?= =?utf-8?q?Lxhz94hzos3toRrSK+be5Slz45Z0EZ2GvA1O5C7kAlaSgPzcrzgRq40xnAaP7AFaU?= =?utf-8?q?ufRb2yg9nwEsvq4A/j8GliOnX96/riMAC/bczGMb+hIKEUU5Ro15zECwK/VCLQ71O?= =?utf-8?q?8Hl4dQsY5psen59CzLjt2XCwfmRIHQYblOXBSib+tAo0FxF2nYJyyBRaYH2BPiBBS?= =?utf-8?q?6VZzwkvNIKls6FiaW5a0AFX/86SScpG2/V9LSV+Hue/TWz2y85wl25GGrka0QEE9J?= =?utf-8?q?cLRmrQpEsenWucgDNjqfus5XFhbU2a/1o1DUbrbjPYOLbL2JVfywuKDKaS7aJHrBj?= =?utf-8?q?FclGBog3d4/S/h36AuQjkIeNwmouzEoC4hIfcoT0aG8ldpvMtm5ELGu1/X/n+BxlV?= =?utf-8?q?Rf8hqH9bRW7zPhoFPtXiEgsDjjezp05AoR9+5XcEWla2UfAx8SukG53z2FNACWvJ7?= =?utf-8?q?hQMkYjDfizS3Y1pDMAvqedvlBFKcwClVTgaOhxVhpcKUpXSIEQeBS58bN9pzTPDRS?= =?utf-8?q?bxQ99U4ySi6nRZdNSmoL/SqwjJe22LWyUXnB4rkzJNFe7poO239w2sl8Yj6SiEwah?= =?utf-8?q?I8TOXDKTb0jMfChzaQ73AMBtlNzC+P7agt/QHZM4VFlqBHDLUr9fx/Q+5izTNya1I?= =?utf-8?q?BPJLzz0WKiK1zTRFxU8yDoA9PogATfWya6oRFOWFCXEv+bC6+2sDzxFSgNP1RVY5j?= =?utf-8?q?uKosW3xBK8512r4sycuhFZEjtqvFqfViz8Duw+ocxtMQ3TtjcZbOwtS0w+xMQMl61?= =?utf-8?q?tVp9aXYoguWWCgxXMMNpM6OIXJhucaS8dfjKtCDHiz/IYFocr3a8A3bVoO1fvyarm?= =?utf-8?q?OZfYupml67SGCFbIRHyNhzdLuftXoOzPMjTY3eOFluPg7qICY0BvqMeLnWi8S62Fk?= =?utf-8?q?c1uuZNLhhn3S3C58t9gOqMafhvyLMK9mdK8nXxCOKjiYQMnzuR6UGQrlCgU7yN4qN?= =?utf-8?q?eX8LZdsiPwmdX/XdBgT+mIjuaacfRcK9D2lpL+cbTBRFh7tsBogZcjO3wcSVMOD3c?= =?utf-8?q?C2+kgIlv5lWDqb2yp3fu9yLnm3gy7pTfDyGGpAJejjYaOjVW2at4JKsSatSDN33Ma?= =?utf-8?q?+se7VHkLbDowKStIZw8dQXVu5TeQcu5H2ismeNKjKaUN1uQMy7cPXgPiCtr8Y6Ka1?= =?utf-8?q?DmrpPUYDYJUXX1VnECkhe2FPYndhVOclTAMBsA3G4jc76GCTxK7NFbDksOw/iX/p5?= =?utf-8?q?coCq4tyWdMFopL8EkXrcgzeaov0KW2Fq75w+ad5DhSHvrTwBP6L1Uu/0sT8KxYcEh?= =?utf-8?q?v0KitrbV3GyDQmD2x612DK4l2tTYDpWAi8rb13ZEaozDQFPXT4ZsOaCqCaj13Ufrl?= =?utf-8?q?rMM3T7PNEOV?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(7416014)(376014)(1800799024)(36860700013)(82310400026)(7053199007);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Dec 2024 05:51:40.7767 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 40cd4ee9-ce26-410e-ae6b-08dd129564e3 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CH1PEPF0000AD78.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: LV8PR12MB9154 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 Mon Dec 2 05:50:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 13890000 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2053.outbound.protection.outlook.com [40.107.220.53]) (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 91FF51F8F0C; Mon, 2 Dec 2024 05:51:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.220.53 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733118708; cv=fail; b=A+GQfiitKFFLqOHsIi5g8OFJt2ec5lvnrAncB11olslCyrkwWvWE88Px7oiNKVAQ3qgclsiXJPaOm88avq6Smv0aRTcl20eB85O2BRT4vKB8io6a53VE3dnoe78vW+EVkWuHZUNSPhLFbW3WbGfdkTzsktmth7nsM8u6v55IE+E= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733118708; c=relaxed/simple; bh=+SmEl9EtJQuPngttNL52qZ4Ot6LKWQLRIQrfYzO93/s=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=f82NAlbw8JSIy00jyvcGlVgFJJ6v9VXmmkskrWIZQj1txRkxLdGauCXyTeoPbCg326vJz0mdAfrZsoR3hvixjYdB3bzQYj+SL+9fgqc1SogPI1uBjQOFMxm5LzDya46PmLZjIRcpghUra1sEE9R1Capnydq6WxUXjOedXlPwpkY= 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=1HzgFpkC; arc=fail smtp.client-ip=40.107.220.53 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="1HzgFpkC" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=pXlMSLFMaESb6/UoTWJsm3gLheS9DqUzBHyGLcg61sFNa6GJMXfrqT9xkx8ieVZCkFZ1sPizx9d/61zAgx75/OHA4A/8zVs6jnnNsQTD5IsJo1uJxHWzMWDs20t1yNtY6XsIHq4Mm5g0fG8pc//nCwrB6CaCe3HuuWNbhZCvwaHcaPVhTjmaRuxsSGFENBRgIbU6X3DtsKrLvEFCgwiJyuLoOu2Hp+HREF8mwEL+WwGplt9yx7dGch8y2FnbQKzEw0/2v727nK3M04ZEeiYGmDToweBkfmAXMJqwa6TpUndT1J3swYEIe0/DsRXcXNHMV7MPEA45yR/96gFNvaMSGA== 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=7ThrWq9BcObnUtyryd2sft6WajqDMk+OpNUD+dK4UC4=; b=BqjcppN+eJPoqPGJtlt8RptvnSZz/VL5CA+N6CvbbZOvUC0pI1flJVcH8jaSFb6cDeOsVjxbnJiewYgROjTeL9SbMyLsHAORciZ6SYks1RPe8BMUF8T+5/uBc5/hdxv4d0ssIQ0H3U2wodgsoYqhovtg7nrBL3RjXgj5dVkkN4AE1okwZkSFP1tAns4cyE+ZB/PIbuwE2pVchwV7CUw0W9u61WFlxqBtAaMcQ2VIqtSVjDyF2sYUOX74EV01WyoTuO0k+D/oZ+DuGds2pq4sKANJt0cXPhgTaUf3tpcGM7k6y3e6MrEOKMCAfe+KgCq/GxPJguS5X890tXwN0elYxw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=redhat.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=7ThrWq9BcObnUtyryd2sft6WajqDMk+OpNUD+dK4UC4=; b=1HzgFpkCFvM9375cOMDd04LuaTzrLVn9psUBB6GMuRmr9UGjxYX+ghXYpJ47vDgHTyNvuF8VlV+cxTSiqdiBkPimSLk+JJNYS+EmXwbMWPCeWrf7aNgx0CwHms8DK6wcp4SXuTUwc2QdgnvJAJtGohSKhUni7DechymEPP4ZfT8= Received: from CH5PR05CA0022.namprd05.prod.outlook.com (2603:10b6:610:1f0::14) by LV3PR12MB9404.namprd12.prod.outlook.com (2603:10b6:408:219::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8207.17; Mon, 2 Dec 2024 05:51:42 +0000 Received: from CH1PEPF0000AD75.namprd04.prod.outlook.com (2603:10b6:610:1f0:cafe::1c) by CH5PR05CA0022.outlook.office365.com (2603:10b6:610:1f0::14) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8230.7 via Frontend Transport; Mon, 2 Dec 2024 05:51:42 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by CH1PEPF0000AD75.mail.protection.outlook.com (10.167.244.54) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8230.7 via Frontend Transport; Mon, 2 Dec 2024 05:51:42 +0000 Received: from AUS-P9-MLIMONCI.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Sun, 1 Dec 2024 23:51:40 -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 v9 09/22] ACPI: platform_profile: Use `scoped_cond_guard` Date: Sun, 1 Dec 2024 23:50:18 -0600 Message-ID: <20241202055031.8038-10-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241202055031.8038-1-mario.limonciello@amd.com> References: <20241202055031.8038-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: CH1PEPF0000AD75:EE_|LV3PR12MB9404:EE_ X-MS-Office365-Filtering-Correlation-Id: ea0f1eb2-96a5-41cb-9109-08dd1295660c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|82310400026|36860700013|7416014|376014; X-Microsoft-Antispam-Message-Info: =?utf-8?q?UambZL34gMZM3Rd+qhhqDkcde/0Vdn3?= =?utf-8?q?4hwY5FDIyQQ8rGzXRFystpdqLev9wWTkGUHxeECIPKFcXddFHWCc8EhWpN2MHq/ZY?= =?utf-8?q?IZR5cAM6x4EI/svUOg1o5sZFd6EPMbVBUxf+CgZxJZCKtkvsrj3fmFuZQbQkjK8Uy?= =?utf-8?q?058UhgAwbOeZuubGO8Sl5itxdeF0xzOuMKzvMt4CRF4JrHnERGD55qMEYhFWXiv6t?= =?utf-8?q?Vk85nSzPIrYIaXWV6m8TUrDDRqdWdnTfkLQhgVQ1xj+DSz5AXJuS6uv08CLu9gsCq?= =?utf-8?q?r3eufF4B841IdyifHrTmrevW263Qib42fHH0WSs7IeAa8yLp3LzhYr6BRG8tg3fdn?= =?utf-8?q?spH5OscwWDRgHJdOiqkhsFviQ5wKP+WlxNfHbUOKg+Z4YXoQ7WrhWlMf6GsYhvoWZ?= =?utf-8?q?oFh+gE69mooGVHINMshLy0VJWVbzQjuBu5RDxRlRR9M/rpTfnTRBWTKyFD/0pCYUQ?= =?utf-8?q?16xW4ciK+rSizW2umhfl9eq1WUG5cGEPUzDUYqoGJPRyukaxjmOAWiiWvQyxEw/iK?= =?utf-8?q?iCj2xPSRqVzdGszesvSiA3lsr1bhfVs1wqODzj7X6w9PpJtxZRvMU/U7H0rL+mXVE?= =?utf-8?q?JWsfxAjNE2y5fwEMAr9dU2YcMzl4J7LPod9l4v9GnTDjT1jcuzdpJAsL/Dvb99Cyu?= =?utf-8?q?aLC+FhNbHyUUjS2ouHKcZitYgikOckA51tYXfADGmQpPe6yPMuAGpLuVKnVU1qWMU?= =?utf-8?q?jMo+j6zJi4ijWvrbPi060rsWT7nHPqcrLRKP52Xhq0533FgiVGPLxufJndPZw2z0X?= =?utf-8?q?B6djcpWJiwwHhqjKkNGd6y8KcbB60gtxM/iSd7tvZX7sTNKEBTXdACsHq1i+lHtjs?= =?utf-8?q?T58nVOKHD+h1Z4kkZdbCNVbc2SJ28dT5mSxgts0oJLosHaYqmMkmpp5qPL2fm1wYT?= =?utf-8?q?58QS5elUdsQN85uIWcDKPb7yWxr9sy/mIsDL8sdd0/Sh7N4Jg2bmG0c0C84TdkgSr?= =?utf-8?q?Porj5ZvBHbilNzKmTgOwVATQVib6XW93UKoCWNtwWgkNoMWbWDpuXTiLyZI249rNS?= =?utf-8?q?z/WiDN1QGYwP32+GRjqa2WvWJhB6xL6+8WY90st3zThiP1R3fs+xy9/Dhu9EEebVF?= =?utf-8?q?9ySsFqPhKFpbvm3deaaxCFRhPZNAzPfMrHsOMRLgN5lGWKcYW+W9mDeZmZpRKrdb3?= =?utf-8?q?Zbf+0r5YfZQe9w7oYxbq6bibnDRY/kN5SwA9fHdPINxE+Ql9uK9d3XgZJQL99YRy0?= =?utf-8?q?920WdWNm3VD87URpxyfoLLaeZEGx4f7foBqsRCn53nXuRGU77gb+Y0nOPzv5Mku4v?= =?utf-8?q?62lWoPlCIj4Htcc5mEHqbdxS9xM9gV/+E9LPW/xSV7jn3M0jy60vsCuw6blCZ6p4h?= =?utf-8?q?z2VCSVuHT9QXhk6Qgbuqrl+qOif0IjmciOZaltqy0yLXqotmGEe64TVkRINAgGXML?= =?utf-8?q?zfelhqQMtIP?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(1800799024)(82310400026)(36860700013)(7416014)(376014);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Dec 2024 05:51:42.7223 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ea0f1eb2-96a5-41cb-9109-08dd1295660c X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CH1PEPF0000AD75.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: LV3PR12MB9404 Migrate away from using an interruptible mutex to scoped_cond_guard in all functions. While changing, move the sysfs notification used in platform_profile_store() outside of mutex scope. Reviewed-by: Armin Wolf Tested-by: Mark Pearson Reviewed-by: Mark Pearson Reviewed-by: Ilpo Järvinen Signed-off-by: Mario Limonciello --- v9: * Simplify platform_profile_choices_show() --- drivers/acpi/platform_profile.c | 105 ++++++++++++-------------------- 1 file changed, 38 insertions(+), 67 deletions(-) diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profile.c index 9729543df6333..a1f0378f15e62 100644 --- a/drivers/acpi/platform_profile.c +++ b/drivers/acpi/platform_profile.c @@ -27,25 +27,16 @@ static ssize_t platform_profile_choices_show(struct device *dev, char *buf) { int len = 0; - int err, i; - - err = mutex_lock_interruptible(&profile_lock); - if (err) - return err; + int i; - if (!cur_profile) { - mutex_unlock(&profile_lock); - return -ENODEV; - } - - for_each_set_bit(i, cur_profile->choices, PLATFORM_PROFILE_LAST) { - if (len == 0) - len += sysfs_emit_at(buf, len, "%s", profile_names[i]); - else - len += sysfs_emit_at(buf, len, " %s", profile_names[i]); + scoped_cond_guard(mutex_intr, return -ERESTARTSYS, &profile_lock) { + if (!cur_profile) + return -ENODEV; + for_each_set_bit(i, cur_profile->choices, PLATFORM_PROFILE_LAST) + len += sysfs_emit_at(buf, len, len ? " %s": "%s", profile_names[i]); } len += sysfs_emit_at(buf, len, "\n"); - mutex_unlock(&profile_lock); + return len; } @@ -56,20 +47,15 @@ static ssize_t platform_profile_show(struct device *dev, enum platform_profile_option profile = PLATFORM_PROFILE_BALANCED; int err; - err = mutex_lock_interruptible(&profile_lock); - if (err) - return err; + scoped_cond_guard(mutex_intr, return -ERESTARTSYS, &profile_lock) { + if (!cur_profile) + return -ENODEV; - if (!cur_profile) { - mutex_unlock(&profile_lock); - return -ENODEV; + err = cur_profile->profile_get(cur_profile, &profile); + if (err) + return err; } - err = cur_profile->profile_get(cur_profile, &profile); - mutex_unlock(&profile_lock); - if (err) - return err; - /* Check that profile is valid index */ if (WARN_ON((profile < 0) || (profile >= ARRAY_SIZE(profile_names)))) return -EIO; @@ -88,28 +74,21 @@ static ssize_t platform_profile_store(struct device *dev, if (i < 0) return -EINVAL; - err = mutex_lock_interruptible(&profile_lock); - if (err) - return err; + scoped_cond_guard(mutex_intr, return -ERESTARTSYS, &profile_lock) { + if (!cur_profile) + return -ENODEV; - if (!cur_profile) { - mutex_unlock(&profile_lock); - return -ENODEV; - } + /* Check that platform supports this profile choice */ + if (!test_bit(i, cur_profile->choices)) + return -EOPNOTSUPP; - /* Check that platform supports this profile choice */ - if (!test_bit(i, cur_profile->choices)) { - mutex_unlock(&profile_lock); - return -EOPNOTSUPP; + err = cur_profile->profile_set(cur_profile, i); + if (err) + return err; } - err = cur_profile->profile_set(cur_profile, i); - if (!err) - sysfs_notify(acpi_kobj, NULL, "platform_profile"); + sysfs_notify(acpi_kobj, NULL, "platform_profile"); - mutex_unlock(&profile_lock); - if (err) - return err; return count; } @@ -140,36 +119,28 @@ int platform_profile_cycle(void) enum platform_profile_option next; int err; - err = mutex_lock_interruptible(&profile_lock); - if (err) - return err; + scoped_cond_guard(mutex_intr, return -ERESTARTSYS, &profile_lock) { + if (!cur_profile) + return -ENODEV; - if (!cur_profile) { - mutex_unlock(&profile_lock); - return -ENODEV; - } + err = cur_profile->profile_get(cur_profile, &profile); + if (err) + return err; - err = cur_profile->profile_get(cur_profile, &profile); - if (err) { - mutex_unlock(&profile_lock); - return err; - } + next = find_next_bit_wrap(cur_profile->choices, PLATFORM_PROFILE_LAST, + profile + 1); - next = find_next_bit_wrap(cur_profile->choices, PLATFORM_PROFILE_LAST, - profile + 1); + if (WARN_ON(next == PLATFORM_PROFILE_LAST)) + return -EINVAL; - if (WARN_ON(next == PLATFORM_PROFILE_LAST)) { - mutex_unlock(&profile_lock); - return -EINVAL; + err = cur_profile->profile_set(cur_profile, next); + if (err) + return err; } - err = cur_profile->profile_set(cur_profile, next); - mutex_unlock(&profile_lock); - - if (!err) - sysfs_notify(acpi_kobj, NULL, "platform_profile"); + sysfs_notify(acpi_kobj, NULL, "platform_profile"); - return err; + return 0; } EXPORT_SYMBOL_GPL(platform_profile_cycle); From patchwork Mon Dec 2 05:50: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: 13890002 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2047.outbound.protection.outlook.com [40.107.92.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 C5A391FA15D; Mon, 2 Dec 2024 05:51:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.92.47 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733118713; cv=fail; b=Id7EqOJRvO14cWV7mOjRVQ9dExxHEvbNcISZv7hD8JHAw7xv3Y77ItgI5XadUDQpN9ZqPKxhPbhPH1G88WHPw7Va92xJTQwk+YBWes/ZbjE8RH+7xwTG3RCh+jmsxUQ3VO7cD8rgBMzmuzreX+TWADj4nks6zjUgjk7GT7GLq7o= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733118713; c=relaxed/simple; bh=tnlb1jYrZFRhofbi7UJYTXe3VMdHpMv8C+ata/uZWwU=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=bthMr4GSonvIVm4UJFD/OAGxRGqKTJtNeqh7PKqFHr04u2Q0Gf5lJ26s2BqRXtqjeU8cA6t1HYKkb5g7WKEpzDLVD5StkpqOaQZzB4qf0WbgmGpAN907FSBrOKpUxNjmS8YX0wPIu2KPE2XTgdEwtNbIUpKV1Av34/a35CpFHL0= 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=Coh9bAJP; arc=fail smtp.client-ip=40.107.92.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="Coh9bAJP" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=VmbiXsyMRjtLTh/h1UzL4u+YbCa1QhG9M8ieor1/7HZhVkkVG63Or9zVyVpogQjgeE3eanEaBJJEyxYSF02408p0s7hmbyhVq7sQzeBr0i9SQKIWSST8GNTaFvuA6KrbGi+R6Pq7P6ZCNRS9SLNg5k1Ip+jFwrnJtvlJeIiEwcm4mxKwDZK6KYmRzq2+Ey6+ACkmtXOkpCgoWxL5LvVEC4uwIUuozpnSeH6Oko+xzqGriR0pH772gOJuK5uZ/7F8mp4DC6h6gyIKgg2VE533fV1PgQdvs4vM2xnZsuzTDC8G/Ej+u+SDqhfKUws3IEmu40Y7z69k+YgEYstprOQVKg== 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=SoW0ZqmQ9VFosdHm3pny8yHfT4BkNi2/J+aCF6hRzy8=; b=vt31cn6gdbVgKj7KlNsilb5NP+zoZ1ML7JVF2onYN2hFJTaFS76jAhKYfQtOy8OdySrPaV+qlIu/sPc+arbl1B8EFj5qGgNrmrfEJgZUHXEMFVm8dDZYZsIXGA2vUKyzxiH/gL1NGnOS53JoR+yMlJ0emzb5cMPTGvokzdlvrmYdseBJAFIRwQJbCk4tS5o2L2jas8WvCMTJrp9N1bPfNoFyZAjXaReh1VNH2wxbeV3h0yyjCBYOrZhUWbV2ZesDaj0VLGV7efOVPzO7VWlwI2kp2ZurBF4tGvr8aH5TLi1TWE58p/FILfAlKLysVa6mUWTbJHzJ9lo0vC8KXesDpA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=redhat.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=SoW0ZqmQ9VFosdHm3pny8yHfT4BkNi2/J+aCF6hRzy8=; b=Coh9bAJPWa21HqBHUCnR57DP/bIOHOHUdGc0yvSoWMWHL/CW9ms2dAqqM6L3wPoidB+yeOp1pV5ZD08/8SDgY97pZiZ2vcFXQ2q9AFdCK+TLhyxTmbj66dSEU+DOvKM+FDQbx6dt3FttQtnfJ6v65auxP6IzssnxhFifYAexU2g= Received: from CH5P220CA0019.NAMP220.PROD.OUTLOOK.COM (2603:10b6:610:1ef::17) by SJ2PR12MB8110.namprd12.prod.outlook.com (2603:10b6:a03:4fc::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8207.19; Mon, 2 Dec 2024 05:51:45 +0000 Received: from CH1PEPF0000AD7A.namprd04.prod.outlook.com (2603:10b6:610:1ef:cafe::80) by CH5P220CA0019.outlook.office365.com (2603:10b6:610:1ef::17) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8207.13 via Frontend Transport; Mon, 2 Dec 2024 05:51:45 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by CH1PEPF0000AD7A.mail.protection.outlook.com (10.167.244.59) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8230.7 via Frontend Transport; Mon, 2 Dec 2024 05:51:45 +0000 Received: from AUS-P9-MLIMONCI.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Sun, 1 Dec 2024 23:51:42 -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 v9 10/22] ACPI: platform_profile: Create class for ACPI platform profile Date: Sun, 1 Dec 2024 23:50:19 -0600 Message-ID: <20241202055031.8038-11-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241202055031.8038-1-mario.limonciello@amd.com> References: <20241202055031.8038-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: CH1PEPF0000AD7A:EE_|SJ2PR12MB8110:EE_ X-MS-Office365-Filtering-Correlation-Id: f2279424-58bf-4d6d-2863-08dd1295676d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|82310400026|36860700013|376014|7416014; X-Microsoft-Antispam-Message-Info: HNo6ydGB575g2YeRT16JY/XDgrYy1YZnY8NFY7CEjBfSaaXB5NmSoiuws0zpRNkCBkaZehadY1t87D3cu06zrv5bfR9KQlvlR6WlkOlGlWtXtgUz7ydXT2nbqREgzVeWZZoOXWUFV/oELHlvKb3zzAOpLO1MhtPzIsrujxmKMthLyBN7dRo3TzusghHhI2RiRDMr/kTT7Vr5BIGy0+L0zZH+gX4VeQn5EO/+kPojVb6JFi11M6VnHpgBTD9YZqHafee3eTPEUPCbKma2FjnZPJX93FH8o2JC4PZ9ulnv7HCSut2ZtDCqXYglhrfbX2TVt8rxMoxr6IX+GNdKkWJ9YUP72atyYZxPkZKghMhU84LikuUSZWuJReMguR9W9EdhAyP4jLgtA3FWXp4rGcaJSHDvzQyMViNHBD0zLnQXsyVXxMD+vkx+axlZK+yHAOJbCFidL6PBaoIHBSVoXEe9Ox5fv+qY1yxN7JdZ1KOo8GHDxwrXHJ0PjcefwIN63orDZWI5Q+3iQSW4ptLMDN5MCZAMVXPYTEme2XeKUAvtCoqtMbNoQZ/rBH2apADojaM3Iiblg/o80CAdLPalut1msdeSt/P2vrhYMIPCm2h9otjhUXpbGpyXfVl2hFgu/yjT84E37vfK01R94bEjXDegsW2es+wcLWuYXBJJx15mHssLKsBPXELHWg04j2VNnKlq+DJQkNlt4gH7wJt+sROWgU89BKYxgFRFUSlRScLoEebsYyEOM3tYOUyx1iemkqLhqmL5/eR5n2u8ZYIkcD0suvSGyPIrY7yu8bMBJxyS9/aBE97ZMGbMXrbSkN5sGx7GGscqfjgYvC7ApFY4h2ULdnW7ehT6+F+SRXHfJASCa+xfzVgvmBgleQjPFk7ywiFdbEBGHKtjXz2PVpmUqGiNfbidYtzVNWvQWRWZiJ4CCyyOdTenzdbGqOkY/JVVbguLtMORzietqGwyoRoRyjpJnJciedvAu2cadMkxL045RTwvXU3TmOrNIWE7Tmw0brLwCX1C42jhhk99cHnITA73iZJIMTFblD1cDObwxHr1LJMEY/OhDrq3+pm6D8EdGeDSWsBUaAsIywv1WpJnFYAf5nJTkLXkTvTSNZHKxqhYcIF7AY5R16yeKv9djYLteQty/71Yi3sFwPoMB4ieKfbkLW8u9SdNCZvfHXZJw1b1/kb/Rg61ipMCVI97eDhDLcWhUIOUwH/nbRz0FziNIZqID6sxyqKATfc7XSYceoZ6aoO9LmesEQCZIpDQPZvswe/n8my8X28IUTCP27mMkBqp3N0j7MIGpX28u4CgQIDeVkLvNYYSUVNWGJlE2/GykcDCTwlsqA2974cF78xghfMsYmQwFUnfp6y4LAeq6DBlJOGCjw8ZwKR+5CPwTV+WJCab2eA7IRy6sieLqtwSOw52vTK3S8FA/Xoqt7vtiJBmHohIaHpZ9cKl0TlR6rC3gkxt X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(1800799024)(82310400026)(36860700013)(376014)(7416014);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Dec 2024 05:51:45.0331 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f2279424-58bf-4d6d-2863-08dd1295676d X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CH1PEPF0000AD7A.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ2PR12MB8110 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 Reviewed-by: Mark Pearson Signed-off-by: Mario Limonciello Reviewed-by: Ilpo Järvinen --- v8: * Use attr->mode --- drivers/acpi/platform_profile.c | 82 ++++++++++++++++++++++++++++++-- include/linux/platform_profile.h | 2 + 2 files changed, 79 insertions(+), 5 deletions(-) diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profile.c index a1f0378f15e62..11eb60b09bac4 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) @@ -101,8 +108,21 @@ 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; + return attr->mode; +} + 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) @@ -160,25 +180,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 Mon Dec 2 05:50:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 13890001 Received: from NAM04-MW2-obe.outbound.protection.outlook.com (mail-mw2nam04on2082.outbound.protection.outlook.com [40.107.101.82]) (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 3E3CF1F9F73; Mon, 2 Dec 2024 05:51:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.101.82 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733118711; cv=fail; b=lEz7VLqxdahjQ4Yxyf+Hy2Y0hr3+m44HIlIi8I8sgezD0Hyl/vAz+JEUO3oN4QQKSqMMsO5BhK1f9qUKXZxWHELj6iAPRtDWURBuSQhL2i0I0XvOMHCKXeok0gQHDNtIARutRnd3tEXECiLfNDUzmGRNsAbwvQCoN1ePFxI+2/o= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733118711; c=relaxed/simple; bh=J6vY6Ly1mybX4QtNPFGmVNYhGmUsJ/VMfVVpXRSd+hM=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=RNG6DugZfz5aqElXoy/ZGGrrJ6zII3WJ5kXrp8gpKIQ1rFLyOs1TtN1p5ZA9W9UpwlXCNz77EcyFchH/kBMwv9sbHdQhVHrShkR9eB3GykMxVZ0Vcnk7SXZEigaSjSK9XESW6wAt0j1XBhGVnj5tfFFz6CcvBerhoGj/VX7J9sQ= 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=Cn6kqbd/; arc=fail smtp.client-ip=40.107.101.82 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="Cn6kqbd/" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=fgBWPw1aMo4pw0dmKGdGKLjv8ZPDw6lca49JyNkMpXv7GhvpskRhLwZhrXB5N6sll0lduzSOs7+SQ0fAo/OnAGMuxRJSi/GrgbUOX3AlSkmNEyzGPqe+UB/Zcj8UOoHIfO7w2CL+5/wN1UACQRk3kQkn1UwIKli0YpWvdV3XazRTeGAojNlLkdMm83uM58ps6f46jTDeYuf/xMb3iFvP8GjubMBVc+xAHQhGENzaDQBXINmuSpn/yno7F0Ij71pKvImJozkXgAwph1siuuXC/x5jJ6MchEbJtp8tu9ODJFGWwa+tswFiHrqR1SV6DQIez8MEn7meeWhCrYZFleBfSw== 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=figZ5FDaBxhpEPwjr9xklx6iqQpxEbgqRxOEyEEz6K4=; b=W040RTAvrIptZghv089pYIEWQOD/NOAeRyEqUK65tqfQFPLq19Czx1dQcd5emmKd1MJSEKPZD+xcwDP1g3m5Ta3UJ6Y8EhDw87lNNLxFGwSjc4CHpEwRkTdvE7QgO72sSYNkzt4eWPVk8KLrzn3YBPresUnL8rXSIxrB4Z7hhnW1mso1sYstiOisqc0wJIptGD4S6clGRBDCatPkGi67EL1VK+mz1RebuoO/xQdor6Ka7dn9JGshGMgG0PRGjQYXh5FqMyBmI6JSk9628Xql0oRzF0PLVJ6ii8BnK5mMPPzEGRDsCuXBRl3NUlx+KNZcTvh5wlpZnVtF4UztLY3OXg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=redhat.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=figZ5FDaBxhpEPwjr9xklx6iqQpxEbgqRxOEyEEz6K4=; b=Cn6kqbd/U4AJeR4tCetyPX4WuvIDFv4B2/vla1XOS0MbqpdztPBZIDbGuKSTVdWxxY6C4PsJaXa+KW3B+ftZt7oGEaK2tYF04ThN6FXGXpdqc9sKPcz3rHCHHNxvaRJe4kZDC962ATdVQzc3/6gUmGV13Wxl6U5OFlcTQixIe6Y= Received: from CH5P220CA0022.NAMP220.PROD.OUTLOOK.COM (2603:10b6:610:1ef::28) by SA1PR12MB8742.namprd12.prod.outlook.com (2603:10b6:806:373::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8207.14; Mon, 2 Dec 2024 05:51:46 +0000 Received: from CH1PEPF0000AD7A.namprd04.prod.outlook.com (2603:10b6:610:1ef:cafe::d) by CH5P220CA0022.outlook.office365.com (2603:10b6:610:1ef::28) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8207.15 via Frontend Transport; Mon, 2 Dec 2024 05:51:46 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by CH1PEPF0000AD7A.mail.protection.outlook.com (10.167.244.59) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8230.7 via Frontend Transport; Mon, 2 Dec 2024 05:51:46 +0000 Received: from AUS-P9-MLIMONCI.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Sun, 1 Dec 2024 23:51:44 -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 v9 11/22] ACPI: platform_profile: Add name attribute to class interface Date: Sun, 1 Dec 2024 23:50:20 -0600 Message-ID: <20241202055031.8038-12-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241202055031.8038-1-mario.limonciello@amd.com> References: <20241202055031.8038-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: CH1PEPF0000AD7A:EE_|SA1PR12MB8742:EE_ X-MS-Office365-Filtering-Correlation-Id: 52e8f1b9-d8a7-4fbb-f579-08dd1295685d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700013|82310400026|7416014|376014|1800799024; X-Microsoft-Antispam-Message-Info: =?utf-8?q?kBftEdda05zSGBqFXsU+1McDnSyt48X?= =?utf-8?q?g10eE4iGiS5LNGz35IYBwWQndJVEhp82C63QwNkmPi3p1Lf7Uv8QKnRXYSXaUz/7N?= =?utf-8?q?p/4V09Q4nEV71rn+0es96349rQTyAygfaFwYN6XH8LUJPPbwhGW/e4piVHGwKw2aj?= =?utf-8?q?EOcyy3gSFHYDwoho8XTtyS4vlpm0Mm2bZR6Dbz4RCZG2EUphqMAgG4CyM8o6bA6wD?= =?utf-8?q?5dGs4j0Dzx2QiVRzu33GWfYs9BgmAYMv4PFWb9RwdoOvfpoKq28p9ndPowlxGcPwe?= =?utf-8?q?706vF0MNlKNLmehdRQYBsO4EACZT2veLs0dXlHJ2hufunRfIWFDMbyCThlzD4I1Jg?= =?utf-8?q?XdH8mT4wVkdcSXOW+8PI2PAKUs/ubVej4QXZKWL2NDmj/fqAyh9T+o41ANTQVrjuI?= =?utf-8?q?TkI/hnkuRaMwqMn7rbzdbTZYMd7NvJ4zbTHIcF6oL1j4XIIy6e/lA0BJbBF1PADeG?= =?utf-8?q?nFA0VS05fcpbxu0eHmdqnXhiDtTCxVdaV0QiEWOSVDR4kf8hZNOttyer9ES6JbLic?= =?utf-8?q?c4ZGxkD7MKl+U7bHjvX3l1neWmSfdgNH0KTwd5j9UvFdrBo9BcGCOoBlpNpNI8dVh?= =?utf-8?q?YlUkAnBvbexOtUsgMem6kM/0TwjygmBxbtISfrJaqTQf5kglPumeXOtDx5L64NAZF?= =?utf-8?q?DUyQ/dzlea9/LJD2Zk1P51q4XH1+i+RWfnYgurgrzyYRTbo+0MKnBLXzLIeisEKO0?= =?utf-8?q?heN72evQPmsNtJnbRsev89U5HO+b3fUv+fjf0G8FhG84uafPpa6A1HE+XHNoXsIJP?= =?utf-8?q?GhfQWxI3c+mCyD5NDIXhnnoMd8A0H2NHD+vTEKa9g9raf4Mcrb4h6nqO+Iw7vW/of?= =?utf-8?q?VARvxcnIg9m4seR12pwnspqKn2wpqrjFIpQCidD415tgVYl3AMDAtIsXEREovBesj?= =?utf-8?q?SnhsdgPf9IVumvE7nTM8tgY2MC3NBYxIgd54/KKq7u6d8gUj8RCF1rh8rYn6o1gOK?= =?utf-8?q?o0yH6AHNUxjJBZb9rmwMNjww4Iux/UC+RWp+rapBmRlNXKLPJ2NzKqw4haapi+SMq?= =?utf-8?q?liJ5Rr8byY3V0iWmmW1Yj0qoPwuuUq3shRNr7WckUUE39Q1JLXs/SM6/w9TkKgFgt?= =?utf-8?q?WPwIFOWmXCGwjnvyH04LUYVZcFZoiTE4lvrUhHIorz+MrCMerxpus8eC9af7BZ0rg?= =?utf-8?q?xB/k4ZF99m3N/HbImTaf/fWPIhQB7F1FWL/YC3wYB6mMt0/YokFgK8B84ca9+656d?= =?utf-8?q?B5QKPGYFB/K/QDjOSLBj8rL6LnTpdbSDfqg6EYr5iu6p71wZV/1Beb9lmXUForIWY?= =?utf-8?q?o5ZycwqPm/a8E/4YTiTZ0I2uvbEP/CqyNU9AbkqKvrH6zhM/e2Pob3uMQ7B81WsFS?= =?utf-8?q?C2nVkLdSafYXKLkOvwfPsEZky1q7aU31FbbbV/pcJ2S0X2yMNbkMBO0g5TLOtQlBW?= =?utf-8?q?J7JQJgaCqrX?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(36860700013)(82310400026)(7416014)(376014)(1800799024);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Dec 2024 05:51:46.5956 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 52e8f1b9-d8a7-4fbb-f579-08dd1295685d X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CH1PEPF0000AD7A.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR12MB8742 The name attribute shows the name of the associated platform profile handler. Tested-by: Mark Pearson Reviewed-by: Ilpo Järvinen Reviewed-by: Armin Wolf Reviewed-by: Mark Pearson Signed-off-by: Mario Limonciello --- v8: * Whitespace --- drivers/acpi/platform_profile.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profile.c index 11eb60b09bac4..49a8bd6e97ece 100644 --- a/drivers/acpi/platform_profile.c +++ b/drivers/acpi/platform_profile.c @@ -25,8 +25,31 @@ static_assert(ARRAY_SIZE(profile_names) == PLATFORM_PROFILE_LAST); static DEFINE_IDA(platform_profile_ida); +/** + * name_show - Show the name of the profile handler + * @dev: The device + * @attr: The attribute + * @buf: The buffer to write to + * + * Return: The number of bytes written + */ +static ssize_t name_show(struct device *dev, struct device_attribute *attr, char *buf) +{ + struct platform_profile_handler *handler = dev_get_drvdata(dev); + + return sysfs_emit(buf, "%s\n", handler->name); +} +static DEVICE_ATTR_RO(name); + +static struct attribute *profile_attrs[] = { + &dev_attr_name.attr, + NULL +}; +ATTRIBUTE_GROUPS(profile); + static const struct class platform_profile_class = { .name = "platform-profile", + .dev_groups = profile_groups, }; static ssize_t platform_profile_choices_show(struct device *dev, From patchwork Mon Dec 2 05:50: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: 13890003 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2055.outbound.protection.outlook.com [40.107.236.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 70DE11F9406; Mon, 2 Dec 2024 05:51:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.236.55 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733118716; cv=fail; b=fh3leaMqv9+E1r4vgwNV3J5hc0GNNMl4y0uKcx5v3aTKn6nBQgYgz8PwCu6uBzldhZ6Gq5e3FS+1bJ+H4dYTBHfE3bgApdsb3z2XCfobRJKJy9iPs4Ak5hUkvfBu/JCYMIAevU8XqQqiGLHz+cra7BwMgAeo14kI9JwAvgTTUPY= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733118716; c=relaxed/simple; bh=unPzCMnUJFAJaoAgr6uPiA30SduoOCKrGWgNsfy25no=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=FPPsTkgAMO3uwlUlJgMxFSoOoBgx0w964yj4Kq2upVH9NqRF2xEA+zTaLBkbOF3MsseUyB65eSNMXH+8EXtesBK4WZBWG0avsbfzBsraVO45/o+pfwPXFZUjZBnDNY4FzGUm4JPtyz5DtyLyvS9C+Teen30lRZhmeEDxp3+KCN8= 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=wDCP2xs1; arc=fail smtp.client-ip=40.107.236.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="wDCP2xs1" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=b6OiV5qUscdZ+hzm8UolSag9Lr9x+XUSd4+drD41Pdl8rql/r8eGN/Wk1s7WvaF5KYS/me/gpJcxbj0PhJgvsyA3T++/d+DMF9vT64bLTI5NzxU+1y0MuosAWdfordG37E5Jaa2B0+2kJJ+iRUV+XuctVurbNG+nY1amLTmmKDDpFfAC3gn2yH1Ybv6IgYImwbwveTSofjFvzmJodKKXYgytM2c2Ummw6MwyMT6qE3ruKn/iZYyNJ0Z59WnsJkDgj762HfrcAIbd+5EwN8DK3EroQB7njJUOoEvZ5RQwR8aG0pZICFIS1qRUaeGXB/Ez1w2TycmmHxRBB646VhGCwA== 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=mEMpx0Xko02t5+VOBOvFQ5yzKaAUqCfVq+KGuAIPsrs=; b=iVoIjPVJuDt4zL6gL2srV+2mTycRop6cQgVSmViESwz63TlIKYfdHzel9QdDGgaJuc5MXEcDzlOqkp9ILODXJKLesUtMRCacqKkBFd2ADFl4Ig8myF1IqAB66GByI6q7b4g5XXoH+kY8YXfktuQmp8RwESEKj3MpJsjmU/rtQPoP0BtJzw3L7o/hZCoTbM+ocbkniKjxQNOgwoWX2ySy96hi0pszriRDAxSX7tdjd70JLXCdzhXfJFWdeXISY3YEuNiK6aUAUIpDwd2VZOfDWX09ztnJ5u3W6AoqPIJc2WPKBkG+/V71e8XS4bXVJ2k3XHW4QY+Q945uLaqN9L9NQA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=redhat.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=mEMpx0Xko02t5+VOBOvFQ5yzKaAUqCfVq+KGuAIPsrs=; b=wDCP2xs14HbaQujntIVKITmB09Z8XGeTxDNvkne5jF65Rvk0sIOeLRQYzHWweBmIB+/3ArZPknUrsxp1HSYhKAv6PDHQoNjw7trFUE/cE5r1sICrEGHCR6jRK8Q3d/KULht5Nx8aeGebht31JL8spXN391S61QePypfIaN8WIN8= Received: from CH2PR03CA0014.namprd03.prod.outlook.com (2603:10b6:610:59::24) by MW3PR12MB4460.namprd12.prod.outlook.com (2603:10b6:303:2f::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8207.18; Mon, 2 Dec 2024 05:51:49 +0000 Received: from CH1PEPF0000AD79.namprd04.prod.outlook.com (2603:10b6:610:59:cafe::17) by CH2PR03CA0014.outlook.office365.com (2603:10b6:610:59::24) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8207.17 via Frontend Transport; Mon, 2 Dec 2024 05:51:48 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by CH1PEPF0000AD79.mail.protection.outlook.com (10.167.244.57) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8230.7 via Frontend Transport; Mon, 2 Dec 2024 05:51:48 +0000 Received: from AUS-P9-MLIMONCI.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Sun, 1 Dec 2024 23:51:46 -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 v9 12/22] ACPI: platform_profile: Add choices attribute for class interface Date: Sun, 1 Dec 2024 23:50:21 -0600 Message-ID: <20241202055031.8038-13-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241202055031.8038-1-mario.limonciello@amd.com> References: <20241202055031.8038-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: CH1PEPF0000AD79:EE_|MW3PR12MB4460:EE_ X-MS-Office365-Filtering-Correlation-Id: 8c8db48d-e11a-4351-0a6a-08dd129569ae X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|36860700013|376014|82310400026|7416014; X-Microsoft-Antispam-Message-Info: =?utf-8?q?izXsKLghAtoWIoKW1MPpeD3oMPsmsEI?= =?utf-8?q?InA+ZRRKTeB81czM1nONsJuEby8VcRmR6ZC+RQfBscc33y3SZ5ji1voc8/mk0z59u?= =?utf-8?q?yAXHtBpQuAkkBjuFwz33WhlGeUje+NqKWfcDCWjI+J+e13yKTRxmWikZWlXadRS5X?= =?utf-8?q?xR5ZnrF7kIYnv5AqT/h6tUeLk/adZK5D7UygaxBAos1TQfCLupi2Ip2xVNjjH2pVZ?= =?utf-8?q?qTqIAiT9pLgXgeO0cxnGxjdny7Ow2GGqh9UUlgUU1r6CaMRCI4icnFs0SDwKdDVWs?= =?utf-8?q?aHHb9PG0eBnZbSFniGvTWrSon5+kaBk6NT6H0Vz9AQ3FlgNCvW0vaSvRxdLnnEI5J?= =?utf-8?q?4yQH8d+v8TvisXfKbEJwQxcU2jzQeoVgtj3qL3URdZU15cZi9lWonMNefVn546yfH?= =?utf-8?q?0ChHGw4Ecxpppk6TPcDu3mjjgH8mOdx7ZG1zg18gl3CCt4x+CzhDuiE/+9DBnbsla?= =?utf-8?q?V6WG7GcEwFJDdxZOqqEjxMrzyhOvgw1f6yIWZI69ZImLiaTJjwTQG7M/AYupSrTb8?= =?utf-8?q?KwayiZ7ISLKR6Zc2H9oOcu1OfRu8oEhkrDncsqJq1ZkqCxBmCd5n1Zb8OXtyy/pMY?= =?utf-8?q?9Z89EoPsEd7+Ox6tCGQVvCIw5CVvjHjGAW5OH+25N408NGI0XzuJN8K+bp+MXkM/k?= =?utf-8?q?GNcLGO0avxQBCwjmR8y1V7QOzz3DS4Wnrc1tznlHUU4xXEDaRlaCM9t0wnfs7Qd1e?= =?utf-8?q?/Ue1UGlIMTrMhs7e9oQWGLVgJsJvnEuwPrdH3q23GKGwrrGdg3l/mymu99BId3/Bi?= =?utf-8?q?5qcfesubuaY+CPr4S0BS1LkHHrcPJkhitRlivaCrbMKSR50Od/GsGgNofCfHpvfqW?= =?utf-8?q?tBDwZ6a1XHDvMEz5AWRzkgRjMa8kKzJX58UoEje+Y1b2V8zMZB10bHJO4DiUZ/50D?= =?utf-8?q?nctUVUgYOIVHbShAuQ/1dQ8sU2HwhcMvCCH686XEBtMuv/7vNzezT6hVZBSmBRvOS?= =?utf-8?q?cPt7XMEStJRo4vwN0rV1W/UTpeWj3WNoctYL4TgX5Q5PxQz4dhyjXKAOksaXA3B3z?= =?utf-8?q?/uhGdkoHdL5t1aocIEltyHynNhAGHHQzDaHGgexI+AYFGxl22/SCcQOSLCo++HB9U?= =?utf-8?q?uccyNbuZlIT6Gdq5KSnm6s4PBMqb0LtDK4eiZlFKOISBm3qmKARFOPom5uPK5NjkH?= =?utf-8?q?pmCP4zO9qxnO8wd9cNjPR7evqto1YiwxFdQk4FllWZi/lSuOlrtezvAvqU6XTOUj1?= =?utf-8?q?dtij94HssMhqc3ixgiWWcrYLSfmGoXb9GF/bYbXTV7NF3rEp9mUxYnJfCrAGR8qpf?= =?utf-8?q?ojivsW2gdjodmTlUmR3IcS2Hs/o+0/cVPtyj+0L7FqeOg7H9HR+VUfwMLjoJB2HgS?= =?utf-8?q?cSe4XJ0BKvnWP3vfOTScdVkg4TH9Sj+NxVwJc5hhsqK37p++BDZOu9c=3D?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(1800799024)(36860700013)(376014)(82310400026)(7416014);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Dec 2024 05:51:48.8137 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 8c8db48d-e11a-4351-0a6a-08dd129569ae X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CH1PEPF0000AD79.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW3PR12MB4460 The `choices` file will show all possible choices that a given platform profile handler can support. Tested-by: Mark Pearson Reviewed-by: Ilpo Järvinen Reviewed-by: Armin Wolf Reviewed-by: Mark Pearson Signed-off-by: Mario Limonciello --- v8: whitespace --- drivers/acpi/platform_profile.c | 41 +++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profile.c index 49a8bd6e97ece..885f41bca6c25 100644 --- a/drivers/acpi/platform_profile.c +++ b/drivers/acpi/platform_profile.c @@ -25,6 +25,28 @@ static_assert(ARRAY_SIZE(profile_names) == PLATFORM_PROFILE_LAST); static DEFINE_IDA(platform_profile_ida); +/** + * _commmon_choices_show - Show the available profile choices + * @choices: The available profile choices + * @buf: The buffer to write to + * + * Return: The number of bytes written + */ +static ssize_t _commmon_choices_show(unsigned long *choices, char *buf) +{ + int i, len = 0; + + for_each_set_bit(i, choices, PLATFORM_PROFILE_LAST) { + if (len == 0) + len += sysfs_emit_at(buf, len, "%s", profile_names[i]); + else + len += sysfs_emit_at(buf, len, " %s", profile_names[i]); + } + len += sysfs_emit_at(buf, len, "\n"); + + return len; +} + /** * name_show - Show the name of the profile handler * @dev: The device @@ -41,8 +63,27 @@ static ssize_t name_show(struct device *dev, struct device_attribute *attr, char } static DEVICE_ATTR_RO(name); +/** + * choices_show - Show the available profile choices + * @dev: The device + * @attr: The attribute + * @buf: The buffer to write to + * + * Return: The number of bytes written + */ +static ssize_t choices_show(struct device *dev, + struct device_attribute *attr, + char *buf) +{ + struct platform_profile_handler *handler = dev_get_drvdata(dev); + + return _commmon_choices_show(handler->choices, buf); +} +static DEVICE_ATTR_RO(choices); + static struct attribute *profile_attrs[] = { &dev_attr_name.attr, + &dev_attr_choices.attr, NULL }; ATTRIBUTE_GROUPS(profile); From patchwork Mon Dec 2 05:50: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: 13890004 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2041.outbound.protection.outlook.com [40.107.223.41]) (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 0B75F1FA25D; Mon, 2 Dec 2024 05:51:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.223.41 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733118716; cv=fail; b=GlWwN7x/3ZpWN0o8zhitO/DyADcTMusTdVahitcUFHjKPJPmPms+kfUl7y0dwDikR+2Ns3JIS/fcCCOyD9g2IL29vEymndEQIM3rCZebV2GHP2FsLKlv1kwh39v32OATmgDrh+a4aCq1DA9Czxp2HVNe/KikU+h8jTVSsE16kbM= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733118716; c=relaxed/simple; bh=hiCWV5Ciccc7IZdNV8FshBAGXHQO12fWiThiZON8daM=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=NXHl9aYssdATNjoYrmlAlnkE16tJHCccGBeR5FW9z8kDlXYqwm8kV1B1J5prVL58O8ytBl0dKGC52eRtFMNemSBj/CvwLC/2utcK6c789FMVelEII4gq4BXY3HQwvai0VrYn1y2RI2XSs//XEj35hCFX/dYCS1Wu/wIZ2XenZlk= 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=o3nwSrVi; arc=fail smtp.client-ip=40.107.223.41 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="o3nwSrVi" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=jIckD3PXNWRR3GXeBIJb6azy/Ovtwlvet17WY3ohdAYK0+PBzPoSGyh90oCZfxeHsUYN8P9hbrhW920m04HvqVB7AsQqhx0xeAts3Trh9EHf9Sc7UN539lvfc71FU8Ypwt0abhYjNxz7W1M3+aWPVFthrWGcjnx3I2vAAm5PqHyCEQZzzfM3EHuQc5KaFruxyithLKh4zqQ9Bx3ZnzJqIr+aQ83MUPT5QL2FXWhBLFRh4tvGf9VNDhWp5Mnci1z52ROtpg7KHzLs40AFTBN/FiwSFUT7J7c6Znn/a0FdoawoYQ6rvRv0Ml7rYtf+cdoPP8dmpqvGewolFALzfO4peQ== 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=qZ1+jIvN/hKauFl7u3gq7oiXHB4v+3oh9XKPoOpjc64=; b=AHTD9psSqXm1dPNOnx0EMgO0moxxyz9sdPEnH4Oxayn3h7dXlChdJY8/CV0Z3iKUE/3oa6cTvGInW+PRymOzCcxNkT2x9Om9kXedXy3wz7xZThc8adOHOPRTZENtrnP72jX5aVl3pDuB6vMegAFFyzcEdAvoY33MNGJ1cyDxeb9iIl3pzbVa+mfCGya5rIig4zAr0U6Cu2MzubUSIePhPAsySiP29TaHtTtiRPYu0xwkPKlAnOAZH9BNt+IqG+M4t0wFGFYtdG1us8IFRq8G3VzFe3yrVQCz8gMxVSoqRa51eDWgFNEBvGBJcZbBHVoo7+jAcld8UA65GrWFA7F1VA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=redhat.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=qZ1+jIvN/hKauFl7u3gq7oiXHB4v+3oh9XKPoOpjc64=; b=o3nwSrViDJ1pGmGpbJtbzWNCH7dVTMgxDaNmUHCxeUHQ/iaOoxLy0cPkXkaPsXo6nzGuoQRIqfTHUHqClM7knBCrgb7ROqtT0AJFAiwgb61SgEM3ZAv0uesYLAZqEXW0Bv8s+S1oSVeHRvoBoVlsbemSzjf9/KAOzyoKbMnQpn0= Received: from CH5PR05CA0006.namprd05.prod.outlook.com (2603:10b6:610:1f0::11) by DS0PR12MB7928.namprd12.prod.outlook.com (2603:10b6:8:14c::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8207.17; Mon, 2 Dec 2024 05:51:51 +0000 Received: from CH1PEPF0000AD75.namprd04.prod.outlook.com (2603:10b6:610:1f0:cafe::27) by CH5PR05CA0006.outlook.office365.com (2603:10b6:610:1f0::11) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8230.7 via Frontend Transport; Mon, 2 Dec 2024 05:51:51 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by CH1PEPF0000AD75.mail.protection.outlook.com (10.167.244.54) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8230.7 via Frontend Transport; Mon, 2 Dec 2024 05:51:51 +0000 Received: from AUS-P9-MLIMONCI.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Sun, 1 Dec 2024 23:51:48 -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 v9 13/22] ACPI: platform_profile: Add profile attribute for class interface Date: Sun, 1 Dec 2024 23:50:22 -0600 Message-ID: <20241202055031.8038-14-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241202055031.8038-1-mario.limonciello@amd.com> References: <20241202055031.8038-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: CH1PEPF0000AD75:EE_|DS0PR12MB7928:EE_ X-MS-Office365-Filtering-Correlation-Id: 6a2911ac-45de-4a4c-688c-08dd12956b16 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: 7pYMB3JNJjYzVOnTYz9AeXLFT/fKwZBF4AXFT7G9Dl6cZ4xtPPiZTuldF6g4RU6C/dp84dC7vCpBRvdJgIjv1lloIwy1qnSnUN5Srx5y0vp8eTWP9wmGlWZ81Mith0TDQf/m+4QlsEmfhCYQL8Gf9iLQW6OkZbhU8jS9c9XNveGs0NWvQKypRi9IHgJlQ6quR/kwxqujzhHIhfDcuhNTyDS+r2Stpw42l4gXb4Da2Bq3c9iRPznPLCDdZlVKLdP01TnekFdDrMJ/CJR+LgpFquk+lBiNzDvkArwcAih2mIs77e1Gke08ZyAjW5TOFacL/bFeypnZdIdEdpHCNVW+ySfAOFH32aaoqeTkg/yyFOuZ3+EfAy2YAzjRG8kJkMM9jz6MyQWiKTXctPiRPo/h/tPCI27ya6JL1tqU7MzMzGOgEX6+FIrZwSXjb+D1YRYnlamjPNDGBp+SvevcARlFteevEY7S3wIrTirM9p+5LzjQvInZBPNpseoVmm5Dk9NHBWr2kPbTTptF+Z8sQn+qN9hcsQERKaBHjJVQ099EUcvpgLr+1Vwrnxw4XhTOaKxxneuyAWhuHR4HMWJ16KPSQJ2twuMTYKP0JW4llFcxFl7xjLvOwSEadAxkoMaZJ1NoexLrHLBl6bHoPgV5aQGcW4z64K+oKFzqmGjl+f/xze9tWqIQrF0O+bNbW6M2+kBBs2DADhV7ql7bBF8hrFob1eZaDCy6LD8gzVUeaqXq25CkFFY1QmJYcRnpKyDPF1d19hQr8fg7QYKX67pEyyFyOZLIFZZWEeH0ba90CEchy8YO0YfmCN2WcrwR9/WM8oSygS4+UniccFsG6QafUyD/ThdmVmHOxwKvTeCAxbYUXPhunJLR4aslmiA2Cz16thTirZwJ51w0P3PcVCcCDKQu6qnYfRH6+c+d7hjAUtq2pH3MrJZsq4ZkF8eQZ9gf7v97XSBLEWhBUof8eMxlIX3puWSRXzubggi/9bPyyADH+xBZWM3qUXpGHMNbIvyIxvuSGZIUC7+/+TB9L686870Gs60QlrfDV2W2Nu7GArusYJ+ay6av9alzWsC5nHKlfUe5i7KRKV7/F50PvYZTdcLbspBgVrK0G9EtZKJ3ADfc3GE8hj1qRH+lLbScSEiFbX6a9PxYxSnJYldBkGtLIHe3IQdKZcTb4C27PBwdSSDdImQLHoBLc80o8LEr8XzfNM6fIxjq87n2BoiqJyEZdiq8BsSzl/tbdjO8oWtFdaNwl+7B8VFOVWEq4EmRs9TIaZnlkUi3Dj4lHL6Plg4dCdoCYPfWmiX6BVFugawcImryz9aNnWa4WoWoTUigdU7XVLQjeNScQ2apkBK2ng6d3d4Hs7eL0DLc8w9bq71srIpaZ0cdJPEbGMv/dQ3e8vftxHzgyvJ2OXiWk0YR85lYUsWK1T8QZeNqdbtT7uHUBkTJAEI8lgUu1rTgbBJJ8bE1uL0A X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(7416014)(376014)(82310400026)(1800799024)(36860700013);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Dec 2024 05:51:51.1754 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 6a2911ac-45de-4a4c-688c-08dd12956b16 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CH1PEPF0000AD75.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR12MB7928 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 Reviewed-by: Mark Pearson Reviewed-by: Armin Wolf Signed-off-by: Mario Limonciello --- v8: * whitespace * rename variables --- drivers/acpi/platform_profile.c | 102 ++++++++++++++++++++++++++++++++ 1 file changed, 102 insertions(+) diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profile.c index 885f41bca6c25..fdff374aab128 100644 --- a/drivers/acpi/platform_profile.c +++ b/drivers/acpi/platform_profile.c @@ -47,6 +47,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 *bit = (int *)data; + + lockdep_assert_held(&profile_lock); + handler = dev_get_drvdata(dev); + if (!test_bit(*bit, handler->choices)) + return -EOPNOTSUPP; + + return handler->profile_set(handler, *bit); +} + +/** + * 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 @@ -81,9 +127,65 @@ static ssize_t choices_show(struct device *dev, } static DEVICE_ATTR_RO(choices); +/** + * 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 index, ret; + + index = sysfs_match_string(profile_names, buf); + if (index < 0) + return -EINVAL; + + scoped_cond_guard(mutex_intr, return -ERESTARTSYS, &profile_lock) { + ret = _store_class_profile(dev, &index); + if (ret) + return ret; + } + + sysfs_notify(acpi_kobj, NULL, "platform_profile"); + + return count; +} +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 Mon Dec 2 05:50:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 13890005 Received: from NAM04-BN8-obe.outbound.protection.outlook.com (mail-bn8nam04on2062.outbound.protection.outlook.com [40.107.100.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 4D7D81FA17F; Mon, 2 Dec 2024 05:51:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.100.62 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733118719; cv=fail; b=RoumLJJPWQfr53ru5JtDL1sM5ZAn+yHz5mOQKnxTS3ObwwLMXLn3bbx/0avlK/UkKUteqmJ1O8AU7Wd8s0P6VbJPr3Olrm2oI7lIXyHn1NGlG3Kl0Z1NQslLRFfaHFxbsSFG8oC+Dmzn6FukGPySqorJa5rpZN5pO50DG6XJv0E= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733118719; c=relaxed/simple; bh=NQ4pJmqJ6qZZWa5lH+fhCRqJlKpGTIYwJ1ZjJRKXJeU=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=fuuzdsOB4ub31oSWFyPdmxSPSreTWOdNr1dMuwx5In2xM7u9bpVfL1RZm8eFx71ZWiqFJSi8XGOQQV8k4XnhN0KeFVLYOyOlnZxjbm8GQu5v20DOFLXwCodQ+kHVQbWRRpPtqI7FQpCJVQra9DqgCZyplKdCLzNKtxz8/VR0M+Q= 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=uvlVn1M0; arc=fail smtp.client-ip=40.107.100.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="uvlVn1M0" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=S0x2ymeqLEKEcXY0ly4RTKMn7CUnxkWV4wKPTBBfIkCUxpnD1wRYWaQ54ygf1Y8aqrn9ZaAOfbbk4kMK4dayHQ4nHzN/pYdkFIBoPOLdWhhxlMBdicdB4iocITbgCF5mzWLLs3zeN7ymTYqYVqUD6CQKbqtQXG2g8/xsJLZ6mk3+bQuwG7iVQ2JweXlOw2OJTExdYqXcOkq8v1TCvvPANOMQ9NocNADBfprkTq2KtZRyfaXS2jqz66DZWZ2TF/jc3ST8tIMbN/43mmiYZaBdd8m874egxapbucwTzcAtYzGo2tr5xXxpWogg4vht2I18rAw7z4T26pIQKWj0pTn/qw== 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=slJil58DB8gn2VuJwq6MCs6bH8SWzRC3d/Cv9r+sBAM=; b=l9+2ia5j0sswngaNnYOsayXpjnJuANrJP8PunIyO3fRkSgA43JdsTatZE6QJCY3NH3JycS+/zbTICc/iDwXxmiSz5hD6TVfwPTCrksFKbKHfmCetnoKycEiL36PS2WO5ympR2Aos+l75lebryEkNj6uhA3PQchbi5NwYo5MKlTtn7VTsBBvdH4Eyux9MkbEKU6w35v/vbrttRmc6oDEQ/J+NTs/m0RmarmLH7XkT2elzN+h87gOxnZc0p4zI8t04/Xvr2zjGCCg+vmz3lEvSBHdb9XlkqjBd+O2jfPI9pf87s2aB5SXNWtl65TVQNUyPDHrEdwjZI50gkOmcT3RB/A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=redhat.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=slJil58DB8gn2VuJwq6MCs6bH8SWzRC3d/Cv9r+sBAM=; b=uvlVn1M0rGR+y8bLr4iNfk4wKKQWCB+JuHKviFPRReyR0T+MG6onYxT9NxtQxfhUHPGyh2KuoxNJE4GmHy4fU8hucKK4VisOUiwcDdTgiSWaAw/71Hi4zXtEaCO3pLefC9RCj0753cTiOwn/kx0dswN5qwS1fD+cXoz+2XoxOH8= Received: from CH0PR03CA0277.namprd03.prod.outlook.com (2603:10b6:610:e6::12) by DM4PR12MB5794.namprd12.prod.outlook.com (2603:10b6:8:61::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8207.17; Mon, 2 Dec 2024 05:51:53 +0000 Received: from CH1PEPF0000AD74.namprd04.prod.outlook.com (2603:10b6:610:e6:cafe::a6) by CH0PR03CA0277.outlook.office365.com (2603:10b6:610:e6::12) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8207.17 via Frontend Transport; Mon, 2 Dec 2024 05:51:52 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by CH1PEPF0000AD74.mail.protection.outlook.com (10.167.244.52) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8230.7 via Frontend Transport; Mon, 2 Dec 2024 05:51:52 +0000 Received: from AUS-P9-MLIMONCI.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Sun, 1 Dec 2024 23:51:50 -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 v9 14/22] ACPI: platform_profile: Notify change events on register and unregister Date: Sun, 1 Dec 2024 23:50:23 -0600 Message-ID: <20241202055031.8038-15-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241202055031.8038-1-mario.limonciello@amd.com> References: <20241202055031.8038-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: CH1PEPF0000AD74:EE_|DM4PR12MB5794:EE_ X-MS-Office365-Filtering-Correlation-Id: 1c7547a0-a4f0-455f-3742-08dd12956c1a 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: eqcknQRE6ubQ1KstDGPnidC2YKhJTtXBrKfjo5H3HVVbH5O5QiB1GjoyfZ8usBj1XJbGnBMnAz2HVIgxqs3UKIRkZbYp+oFFF0zZnznLyX9Xr7S9JjOirkv4ZYEKsHc1/rA60eiLKakH5NtXE03b3mogJm9ysFVzwZkjsQ7CoQJvT9GrVuy3XGYjKK3QiKD7r6cQQR15k+hmoT3vshiUf7kcBhgi+JFSRJt5mObMqMFuPzhtQWBRgu546rrZHMDPW19fqUM1ONYTvCEqEnyKauSC9foc4dYCIZbldCSUOdz8Xir+66MAGqQR+zbwFfiAPrNNGcm+sAJIAK5kRkGnOAg/WmS6rLvP9uJswJy6NeJ/QT2pFFBQizR3s1H7gXbYD7zBA7nibzlXnCQi08SC+/CoP8e8kDAFTiqoNPmHPjeY/BSy0Tm+v24sd8zIpqzkwhCRoQdPa5Hzi3DMG8qpMTcxWEj8VnuyjVzv7JAwZwuzeE0Tm57GOzxAbCGhnHuFWIdkLqDQG2cYUCCC9dT/lWkS1f62qDDXRXtGPMkUW5op1XUqyIE03Akz5dkUGwBwxGwJOLozOL1WX9VJlvQkW1buBhahlJFg6VSIP4dIYSI94s/Gq7lOKGVHanSwLr4CS0avIK06BW5GXMWmdsWcMeeYK49kgeWdm6HPRy+GqthezAMMF9wA9pCy7P8QyBzxgwB4frhjYou+5Uhii/52GiQmJJRPZVc0T6qwbgsw1SQgDRJa1fb5CxSmZcWqX1ydNSfkr0KaOgrXhe5gaTrVX9/ROl46W6ksbrBZSpbYsGVW/PchXlOy7IQ0WCIKAo8nktMuNNrb8Y+JQKYiJRdwJIhlt+OnUuc0zBZ6dZhFRmWbMyn8dSRPbAA8BdRuTTiXT+hvQUwg4tZL2ZhupZ4hxhF1NI71usDSAlNzWwj/1bgIbXq5x3HU6iN6RMGzv8I6Z0TZfTrZ7EwATynuBmlc50Z+UHXILLVXHlaMiXYxg0qbnj8SnYnQGZnPyFSJC8IntSgOnQbKiyCzpBo971QI9y6LutyM07LmWu+McMMAuRlXAVlOmiagHCcclKIrRbnjG/gmGhdbCxWYOdEkIvcof9S9k+h+tpS/VaPv7u52ySDN5/fJGGgoP6s/y1DptKlaY5IFDdT6PPi1nMQe64sj8rhEkS0Vd2m88+coXaBCZWYEgUC95FQhaNjW6yrTk2WsIQriv2CCIAjzLl0hOs6kLrQO3FgkYlzUZkEp2rrmHGqzKapsIfWeXVCfl19LAOQXU9KpymVvJNaH/TCs+XMSYQ15oVEsz58U6WcpVyv4wXw3qvbyYT2eqx/LL+dDu0ha2khnqju9sRbzMxTcfXSJ/OCEQzN4atjuh5tvy4PfomhbhJJSrjJmXpLck7GYFH42811+BaLMeMrsBk/QmwddptIlg9NrR8ab7+LvpEnuF6xrsX4XfAWxJTZ6rNrfVJSZ X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(376014)(7416014)(1800799024)(36860700013)(82310400026);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Dec 2024 05:51:52.8781 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 1c7547a0-a4f0-455f-3742-08dd12956c1a X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CH1PEPF0000AD74.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB5794 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 --- 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 fdff374aab128..bb0178e52ff6b 100644 --- a/drivers/acpi/platform_profile.c +++ b/drivers/acpi/platform_profile.c @@ -358,6 +358,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); @@ -388,6 +390,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 Mon Dec 2 05:50:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 13890006 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2063.outbound.protection.outlook.com [40.107.94.63]) (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 7FB321FA27F; Mon, 2 Dec 2024 05:51:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.94.63 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733118720; cv=fail; b=T+pBUWn5HPQP2RWAUG8A6XBO/HbxqR4A0VwMtYbKHloC4y8cRyXl/bXj5CxmSgKO1jJC+S1ocITtQdFod1tHeW1EfOcV6feYyPP2mebST8vPN/qNl/FXaeDNmZi+8qEVm0v8jirbS+7eFemPtTSM9Cw3XdkSHub1zHADWXtYOrA= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733118720; c=relaxed/simple; bh=Wf8Mf/SMm663C4HQysPYkEoNMVeUDOKQh0hZMgeYm0Y=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=bw5geilhiPMgky4ihq60Emfvs/bzpugKX+e0G3JAmgqFR8PadyS34SaYZcdNTS0S4Zd39ZXkzA4ASbHVzpqQ9P7Td/G031YO4U8dsG1gH2u6G2vZdg8edu/HJUxYhp6TdpLeyY9bfcLbANyfeQfz1pN95ahFLsrf8v+/zOey2Ks= 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=qnlpI3m/; arc=fail smtp.client-ip=40.107.94.63 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="qnlpI3m/" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=YYilkmQmrja4FYGhcYwOSix6Q0XoTOuxQRA5WTp80K6g3CLxC1eTSwQe5LBeO/Y8q/JuzyNZiIdZhQ+M9hOUwNX0eVvk5BTkf1PlR1nBlDGyztY4wduvEdeeITTWqSD/vtcYHKRIid9i9LlKGGxolFXnOWGmGBXsT4mfBBP6vSIlzsV3c6T3OthYbXq1DGuUwaK4s3uH231EsKFVCwgREQyFx6Y14Vq+etHCN0st5ClVICdEQR9m06PLe7teHY+AKe+pmgJDH+v26Xe5JVAvsUxclFloTerdDkGT4oSB6kEO8cJm3cOEOdZe5SeusEnHZv+bsyE68COH8XRaVJOWHA== 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=CNIfQJHGvNvzIfH9h40KQ9ngDElZj/c7E6vhFm+/W3M=; b=X+tD/UoxC5jNTYG9gFj2xAb2306Jzk987gZKiAcCkJPJg9RkyzBPzN1VW2Yfxwwc7YeRGufF5H04QyEh1BDa2nyT8rRge7hn7Sk6rLXp8O3iIChN2ZjNe3kRfh+u3ZsqOcTpHSvoppTFq78yo+iulUngZBdzRBUVdCddMmhCY1A6GibpfHiEaqCCVxR0PNnv83jlXvDhw8mrGL73y1GCLoRyilIHwhAEEt+5RGAwBEOLAuDmYsMVrKI+4yEqsmbhcAa38x6zhgsee3sQWz4JuHH7cD5dyI2yy1cOn3Nooch6wQwVcIAmdgebsrzuk31KHF6HqZBLhE7fAXWL3OGJ6Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=redhat.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=CNIfQJHGvNvzIfH9h40KQ9ngDElZj/c7E6vhFm+/W3M=; b=qnlpI3m/8E3aYZaRIlJkUTjwXHe6i8BVS6reJzi587oWTeVQKyoCDY2zOVzjom2beR9clyZTdTKI0BOfGw/mKWFVs/jTaIHdjYKReJXZofPj9HissXHqjc5kfwcI6gAs9w2Sr80wdD0Z3BJJjfflUeRKTZgIJWoZtWEToDserdU= Received: from CH5PR05CA0020.namprd05.prod.outlook.com (2603:10b6:610:1f0::13) by CY5PR12MB6624.namprd12.prod.outlook.com (2603:10b6:930:40::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8207.17; Mon, 2 Dec 2024 05:51:55 +0000 Received: from CH1PEPF0000AD75.namprd04.prod.outlook.com (2603:10b6:610:1f0:cafe::8) by CH5PR05CA0020.outlook.office365.com (2603:10b6:610:1f0::13) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8230.7 via Frontend Transport; Mon, 2 Dec 2024 05:51:55 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by CH1PEPF0000AD75.mail.protection.outlook.com (10.167.244.54) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8230.7 via Frontend Transport; Mon, 2 Dec 2024 05:51:54 +0000 Received: from AUS-P9-MLIMONCI.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Sun, 1 Dec 2024 23:51:52 -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 v9 15/22] ACPI: platform_profile: Only show profiles common for all handlers Date: Sun, 1 Dec 2024 23:50:24 -0600 Message-ID: <20241202055031.8038-16-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241202055031.8038-1-mario.limonciello@amd.com> References: <20241202055031.8038-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: CH1PEPF0000AD75:EE_|CY5PR12MB6624:EE_ X-MS-Office365-Filtering-Correlation-Id: 6d27e4eb-5934-4e28-2629-08dd12956d5c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|376014|1800799024|36860700013|82310400026; X-Microsoft-Antispam-Message-Info: XIcHvAS5bFoRBsEW+yjEUpueUzsdDaFPWBT2CfgTAw6I2KJBLLAkAPM87ehMylC6UJDpMyycdBBj/k8Rg2WeGN063Do6wwK78gP2C9evt+K/4hf8pDki4ajcKwg1iIIeHwIe1VqylhlCcRGvG3Ok4O3cr427XOOeIoi+zD3dgC4HF5dX7Dpk0H5BHHX3ep2hpPhgY+r21FyeSF8XH9lSgv/kBoN+l0OmRE2zvwlxpPjecSWljfixIYJ4TAOOfuGFKaIz1wb0DWLucnBIZ2iS2MvGl2KhBbkf2by46qmTUDWL9+5eyxI3DAXhC+bZ3JiFjNOTUS3ceKrDaS/+/DgKpHpRabqVRkY3zsQaYaIA4IBrgMOFeSrNpa2JwfdhgNLIuMGEnHLgrPiu6LikUQqRyFQJCti8PuyawNkM/0sGJETGBfyoJMMuzH0VKPmBA3sEgjqGLDsTlQGXVRfUl352GqcfJMaSgoNydmIvSwOFRy/L0EQa7OPH0c/EPx+2dpikdybXO4nDCAgHBg+JvIoi5WcHfklTeZ6g2HiPhLSxq10W8MHwgOKIiiFCjc4peNmQmnozp+W4VcSaj/qVy3qFQCSW8kENy0JTxsJCI8YmOBago8GcZGRwMsgZ+pyAAy23AzBRUCS/XDjtaF1OVLs8fsiww3TpkeeHIY0qmg8fgaBSScTYdA85bsGjX70UOwEct5pRgz/RbCyxFTOsVWmj86FZAM3T1ku1bbkvoHKBABHdbGb7QOdHV4qfnbdxzPqV2lb36Sil4XzP76XP55aJJ+VAyqRUx50txPUBYG41u/u+IJjxuNi5EHsEjtLdkB4GetUdj+Bb7YsiKesbDbHJn9chqPsClHA6+ucpBNuktDTJEW+qPl8kZXI3LRtn/MU7a6lpm8/taC/s7agM1No+2Thl6KXApuuVc4Bsx5cql4dzNDZog2L+XJjvMKrcD6nFp1SYz7d+vl8FMhlKDIfOtiTjgaZ0AtGGOHTUdpTeAMHG9EVB9PWx1SWqxea439mu2Uu6jnloTNq9+wKPZ8rOZgdzqMkAyPgt5D7UKPdA8TVh0Ptn0bFNgpTozFEGbGm4jHUChF15L+1pqIMyRodQ0qKb9U4DTme1+ZElZ+53lgjMSiuh43F7kR4qKn6HCH4MuLqFakj5slaLlcIJo2dhaQ83uoTG7p7wX2rEcuTIH/0aP/sDl0nuXSCCCVIrC7fMgHtlSNfCOTKB/niyF4kewqWJekQtgbSnSpUFS067IB7mt4Y1IO1CAlI28IvVSxumuqBfwQyPRr+AQQTO6LLgPrmBYLXtlyLXmMH5dIyAsjsjjr0AHglHeBW4l3nptXGmCt4QLs1ipMRG7zYia/Vr2cd7I3xvg7oVTu4J3Z/s8rOtQJmS45Mz0pzhkAJiQNRxngS8mUq64Gd1cJ8uHYt13Z0NKbN0DfXzBRDpLrKYCJM8RBFI9esBGL57z/HP93LD X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(7416014)(376014)(1800799024)(36860700013)(82310400026);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Dec 2024 05:51:54.9723 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 6d27e4eb-5934-4e28-2629-08dd12956d5c X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CH1PEPF0000AD75.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY5PR12MB6624 If multiple platform profile handlers have been registered, don't allow switching to profiles unique to only one handler. Reviewed-by: Armin Wolf Tested-by: Mark Pearson Tested-by: Matthew Schwartz Reviewed-by: Mark Pearson Signed-off-by: Mario Limonciello --- drivers/acpi/platform_profile.c | 52 ++++++++++++++++++++++++++------- 1 file changed, 42 insertions(+), 10 deletions(-) diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profile.c index bb0178e52ff6b..40826876006b5 100644 --- a/drivers/acpi/platform_profile.c +++ b/drivers/acpi/platform_profile.c @@ -195,22 +195,54 @@ static const struct class platform_profile_class = { .dev_groups = profile_groups, }; +/** + * _aggregate_choices - Aggregate the available profile choices + * @dev: The device + * @data: The available profile choices + * Return: 0 on success, -errno on failure + */ +static int _aggregate_choices(struct device *dev, void *data) +{ + struct platform_profile_handler *handler; + unsigned long *aggregate = data; + + lockdep_assert_held(&profile_lock); + handler = dev_get_drvdata(dev); + if (test_bit(PLATFORM_PROFILE_LAST, aggregate)) + bitmap_copy(aggregate, handler->choices, PLATFORM_PROFILE_LAST); + else + bitmap_and(aggregate, handler->choices, aggregate, PLATFORM_PROFILE_LAST); + + return 0; +} + +/** + * platform_profile_choices_show - Show the available profile choices for legacy sysfs interface + * @dev: The device + * @attr: The attribute + * @buf: The buffer to write to + * Return: The number of bytes written + */ static ssize_t platform_profile_choices_show(struct device *dev, - struct device_attribute *attr, - char *buf) + struct device_attribute *attr, + char *buf) { - int len = 0; - int i; + unsigned long aggregate[BITS_TO_LONGS(PLATFORM_PROFILE_LAST)]; + int err; + set_bit(PLATFORM_PROFILE_LAST, aggregate); scoped_cond_guard(mutex_intr, return -ERESTARTSYS, &profile_lock) { - if (!cur_profile) - return -ENODEV; - for_each_set_bit(i, cur_profile->choices, PLATFORM_PROFILE_LAST) - len += sysfs_emit_at(buf, len, len ? " %s": "%s", profile_names[i]); + err = class_for_each_device(&platform_profile_class, NULL, + aggregate, _aggregate_choices); + if (err) + return err; } - len += sysfs_emit_at(buf, len, "\n"); - return len; + /* no profile handler registered any more */ + if (bitmap_empty(aggregate, PLATFORM_PROFILE_LAST)) + return -EINVAL; + + return _commmon_choices_show(aggregate, buf); } static ssize_t platform_profile_show(struct device *dev, From patchwork Mon Dec 2 05:50:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 13890007 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2073.outbound.protection.outlook.com [40.107.243.73]) (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 5579A1FA15D; Mon, 2 Dec 2024 05:52:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.243.73 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733118722; cv=fail; b=hWrYRJLX9OsQTVBf89lsHbvkVexWl/aX3EUd9UGBx5UrARNjn7lStACtZ0gyfeikGoQ5iV3XO8im2kIZqoNYHU568fZ8qcuUQJe/dGuVYGzdZz9Rc2dBB2qmCaE9B6HqAbJ7Rc8MUz1LEOoy2+jjMmM3YenGMrJnMYepKN+sCiA= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733118722; c=relaxed/simple; bh=f+GAxf2ilYPGunufrK0qKluIJjjPc6FBvYYjc4HgZf4=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Un9ee916qF0fekRyKBK4ht62LGTIgog3hsZZLaP6ElSfCfZ8W6kmaQiARurVfQYZ6hsp0FqZGGWril1Lu5myAAVAJrv32GpHmDghfxSmAJA+LMMcuzkeLxV5mMpP72i1I+tvsW4Z6I0rZ/N0tQLLj5pWtX244qYN0uf50bePlws= 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=YwI8svyN; arc=fail smtp.client-ip=40.107.243.73 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="YwI8svyN" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=AUHVSxMF+jCb/TeuDJxGMmfwDLCbMyZo0VX1z15RI5WsAJ2Rt9aGtwxjUEkAL0tWNNCVpGOwKbTm/4BzuI4Sj+eqTrFjhI9VuHK5A8fqEP+iQbI6RgyzCjJSpFf+opixm6MJP60++W8Yytb99ATNp5yvr3uga9vqqzaVlitMDlmqBBUEWW49STUVU9AbtZokLYGdPwbhxwhwUA97en+DQ0cKrhFzFNH/wt2CePt2VJD0WvGtZAmPC7Z+ekZ/fwpIhbOhRDsXo/B6eSGgugXPaA8r60eVBtCo2UXP0BAcsLHgSjKONk7zdTXDaIFI6i8u7SYwbz8ozf8uCwprrCvXmw== 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=gJM86/5fT/kTWIaWTa20k/1Hba2Jgn8oT1io5vhyWVs=; b=ldsYRu1gtMuyfBZpuB1ckVzl6blXEcAP12semlurAO1HHgRz6+AyH3kj0++/QYbkuHhSliG38cGV5fwAUcq4Cv4qFy1J0FQgjqM42SBVdccmX62GYyF78aeqhYRTEHIz/td0lD6EreDNyG+DQ96xqPnUAy7xyNcMz9A/rNgA50wnoehMV4Xnzcx0rmr5/WWGo6BUL/PamVZf1As1zgLsrkrRdnKTL5rmExhAhYFzw2AsSUhmCIHRjfvUKHoLHzTShNA2fpMBPoFSDDjwg9l4MF5wXzT/kknW61jblEMP/AjZx58adA7ZlrY5NymOtIK696bON36MXxl32tE98DQ4Ag== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=redhat.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=gJM86/5fT/kTWIaWTa20k/1Hba2Jgn8oT1io5vhyWVs=; b=YwI8svyNkld8aEqgcG4Gob4jAAa/0LcmBPcG3phL3F+2y1xqGYxwga/BKbSrdQWMN+dYxKBAhMdTSosRsEmy2IFEq7kDASfE4JfumH1aQru5A8H9AcHYTWFL4OACzGSmvzyJFrt6Xw2AeqwMHjgzy0XVQ+N0lLBPvU3S0w/IQOw= Received: from CH2PR17CA0004.namprd17.prod.outlook.com (2603:10b6:610:53::14) by PH8PR12MB8606.namprd12.prod.outlook.com (2603:10b6:510:1ce::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8207.18; Mon, 2 Dec 2024 05:51:57 +0000 Received: from CH1PEPF0000AD7B.namprd04.prod.outlook.com (2603:10b6:610:53:cafe::7b) by CH2PR17CA0004.outlook.office365.com (2603:10b6:610:53::14) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8207.17 via Frontend Transport; Mon, 2 Dec 2024 05:51:57 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by CH1PEPF0000AD7B.mail.protection.outlook.com (10.167.244.58) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8230.7 via Frontend Transport; Mon, 2 Dec 2024 05:51:57 +0000 Received: from AUS-P9-MLIMONCI.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Sun, 1 Dec 2024 23:51:54 -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 v9 16/22] ACPI: platform_profile: Add concept of a "custom" profile Date: Sun, 1 Dec 2024 23:50:25 -0600 Message-ID: <20241202055031.8038-17-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241202055031.8038-1-mario.limonciello@amd.com> References: <20241202055031.8038-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: CH1PEPF0000AD7B:EE_|PH8PR12MB8606:EE_ X-MS-Office365-Filtering-Correlation-Id: db90c848-16bf-4013-0bb8-08dd12956ea9 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|376014|1800799024|36860700013|82310400026; X-Microsoft-Antispam-Message-Info: 7bihjDCb5+0XAmbm/JDiEUCdW5sdCPSap7R4lfwLTPzPYQWCHHoxLaxKuSrorS11zrR2dhj0QDZT0GTrtMd3I3pPKTg6U/SLlXHr7suM1G77bKTdqErp0+WUOu0/YfXAQplO6AUwX6fVMQJ7+tYt1Zz8vh7BFN+IhX4vQcwa9UCi3f3Q8b2yqJlHD4KD5jyU1sQfvaUX69AN8vME1sQbNKole5Pl/rISpv3UltPBVKxRjJ+ayGNm12SJaQdIWqnOMOJENFPCIU+uYg2zQKmd+Xhf+nObkVVKE0qsnWMLiyfRdkrh2OdPC4YVoracWyvvaWJlvHL5K8qxLisQYnE5iX3bGG1x783Pp88+zh3eUYnKbs05ewwzY0c5pRQUy6X8br0wfrZWgcY7+wxqCJzt+UBrIz4InbmVHjUTDH/C7t8TSgVAxF/L7VNku+oF7qsOU1fjfVQ/ruanGnIKX+P0miosbQNcxpmG0Z+9n5d/EbEABzNlSHqzMuOtiMZsabq0SctgzOAFbpc0q/2GYkmUSgZB33C+pPXy0Kty59gFN0cZjaTSvra8uFOW3674f0ldHZvu22d6rwCOS68Tr+/e7AbMdk4CSiNjIWkt7Dmzau7ERlFCFhiRNKiDIwRn61bVY+OmmFkGzS9uB7n2Fh59PPWfDxEmZanBmMp2TzBDR4RkgXwG1o3NAJBHCpl7758oTk3LTCcPHusJAcuiw1s/WVVyMLIsXMNAyfOnA3/SEH1ndnJLseX+LBbO74IewMH6ECr7BQ3i0TJHyKHiF6ThblPQdbfvmYaoXoenoY+mzdh7gSWBlbIqLDiLsS6SP1gw+XVwLcRTunJNAdIt8jBUM91WuspuI8isjRpDBgttMuxZ0Ov4dd8387q7rZGpcRKvbTsz6hN+3dcyHzc2I+3lUsF3xmBtS1Y6Qpuhy7Qv7c1iqgD+s5GsoVPHywNMQEFEEv+Rfs1yXuZ1GU/fAytkSCc81tILhV9UK2jjI0+V5g3ZcxDP05ymzPbrlDaRlxyA3DFOt7QR75KCwPFUEb6zfB9aSCwf7HoVs39RFyfcH73kPBz+fcaTjbAED8iyEheP2EWZcqoO5DeN+UwVbVwVsN1enSZyH89bJYXtH9OA8nn/Frod8vSehgQLcDLNMIzg4j/DcRAKvOruCgVW+y7SePOKT689BD19SiuF//FpQKcqnZNRbJUG92doO+w66KyGhCkMEOHrGyf6IUSK+i3nx0ZkBaVMpxOiaxa736nvnCKiSin0SaRzcQmhFwEKkLmpn7norrS8cWIJGNurcqSrbgZ9bNaQjFkB6B87x3tc0B0TlM6yw3rzHGlVO3nvKA0/d00Kuti9vdAEe43IfsLxn0jD3idBJ78y29PSxxB8RG9EkVsbxr/xeLnOYMPRsCwrF28XUE99H5QAx8ku0PuWwK1GJHUytQS781qo17g//QIEm1RKfOLRTf6YDpncrcoP X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(7416014)(376014)(1800799024)(36860700013)(82310400026);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Dec 2024 05:51:57.1540 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: db90c848-16bf-4013-0bb8-08dd12956ea9 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CH1PEPF0000AD7B.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH8PR12MB8606 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 40826876006b5..a9cd13c5fd39b 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 Mon Dec 2 05:50:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 13890008 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2049.outbound.protection.outlook.com [40.107.94.49]) (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 69E0F1FBEA1; Mon, 2 Dec 2024 05:52:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.94.49 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733118726; cv=fail; b=iIbsPMmWLer9m3Wqq8t2Wa7UX45egIYMwvEpBQI0v1qC3K4DFJ1aXoYz4m5zAi3C1uAPQfwGJx4DawMmiJEwhKC7/HklCbg+0T9fHIOwQj61GDEZKKwZ3ZnLI54ZdUNceAcxoMivLc0EntBOK58E46HapcPnhsr/WUPYt8GlKeM= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733118726; c=relaxed/simple; bh=xJ+M4Lg2cIRGE7DzFAzUz3QMC2iv+n5Ah8qSAwPX1zs=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=SElvbCgm675nCdz6sVTwU2YindceQkR/3JM9tLoXNY0rsQzVMmW1CGlkxUOTTOjW/J/oPlRQRc4ozsq6bfP5aBLto++OYSwNRDiJIUzWyF8A/204hjWalo14jXkAjq1PnlXtVyRIWpA7S09jgunHE49in4sKBogtPliqZvsaxlM= 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=Dcu7vSbq; arc=fail smtp.client-ip=40.107.94.49 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="Dcu7vSbq" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=J7mobltIc//42CQXyj5In+eJmbZjyF6qqWb9M+NfLwEaY8mjdL7bsJQ+a7waM3N58++Y7rzpD5EnK+5W3xMweCIOqd+Z0Qwjh6EdL00jR1f3hfc6+mUXCr4Cg5pNYesNGvmIvg/io/zde8jvNzAIqLlhKy9KX0Nm2UJOTk8DUzqMoEuWJAWL3dKIGtvGFTkkY4LkRKRc2CumFlzyhEDMy9N7En1p8UiKlXbXfYD9ot6vE0MVUvNNn+uJjeqDvd8IEk8K5ZAg78wHOyJxNyiK41isWukHN6z+o8tUCnKAO8ZkmhXR7/Z0FFiKT45sJnWG5FrVEhA43vlT/zyjiIDb8w== 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=hKN4rAzipi4gAsFai9pIibJf+kkEH1x3D/3vlXFg0D8=; b=KzCihDnTUfMFsi254F7Zp0aNh+VGToyIwLqdbhYn88JwrmEvsS4u7ypgYNW33Bow86PBUzqBlQHklLV1IwixzaT9V7HBVBvYHX/jgWKwEJN25t57+C/caX1WygHZIfBw/2h18JUsInYvsgExpKKvpQUvJKv/KI0JE3FkOwgw/lmzEguk7im/Y3LpxcSXYgPT+ET9M3jnFOZAfjeMhcnSYhy5bLF4XUP3I0tOOAYwiXleX1j2aEvlWv7IadLEftELLv/i7aG2j9AD1IfX/dbZOVgL4KRlEeVSAXjqOfz++RRAQ+j30kykeLewO4gyzOpizgd/15oENECOmLXuFaINEA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=redhat.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=hKN4rAzipi4gAsFai9pIibJf+kkEH1x3D/3vlXFg0D8=; b=Dcu7vSbqpAcX9Oh0M1DdDWwTZ//0h9mmwSov/oGQvi9jE9jZ8/DHimeORHQ1disl4N9zT/ZNywIPGESJxIn0NYFAbzZQmqDmRDHFGOou7IKQy9Csv5cHyqsyS40pstbz/lCWlgli4byKZBFKKiZIlp+vIzJwFH/Tr4TE65Q71bM= Received: from CH0PR03CA0275.namprd03.prod.outlook.com (2603:10b6:610:e6::10) by IA0PR12MB8085.namprd12.prod.outlook.com (2603:10b6:208:400::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8207.18; Mon, 2 Dec 2024 05:51:59 +0000 Received: from CH1PEPF0000AD74.namprd04.prod.outlook.com (2603:10b6:610:e6:cafe::30) by CH0PR03CA0275.outlook.office365.com (2603:10b6:610:e6::10) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8207.17 via Frontend Transport; Mon, 2 Dec 2024 05:51:59 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by CH1PEPF0000AD74.mail.protection.outlook.com (10.167.244.52) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8230.7 via Frontend Transport; Mon, 2 Dec 2024 05:51:59 +0000 Received: from AUS-P9-MLIMONCI.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Sun, 1 Dec 2024 23:51:56 -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 v9 17/22] ACPI: platform_profile: Make sure all profile handlers agree on profile Date: Sun, 1 Dec 2024 23:50:26 -0600 Message-ID: <20241202055031.8038-18-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241202055031.8038-1-mario.limonciello@amd.com> References: <20241202055031.8038-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: CH1PEPF0000AD74:EE_|IA0PR12MB8085:EE_ X-MS-Office365-Filtering-Correlation-Id: 8a079ef1-bcda-4592-462f-08dd12956ff5 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700013|1800799024|82310400026|7416014|376014; X-Microsoft-Antispam-Message-Info: PnHoeDM2jEAnidWxJ+z9xf1zGfTZ5FO2m0H9S8AamfpIFnagkequ10VlZppSUIzqGSrl5NwkU7EWu0OjyBoEF4afilNBIgD4XwZLUxyB+0pf9nCFGi3JcJB5zXi+9zB8k1VodlfN8OfnzZgw+d25I1CFVIruJonFlgVIr3A/SP7H3NS+g0msyPtDZTtTK/H15owdb0wgyaB2DnzIFiWIA5HmOqVx55xTXLv8WXYq6brdcAwE9GUf+UBO8GA4X1aZusqfOPLVeG99dT9utxHCEs7vf+ZxDY051Pad5JHcO6g6Q5KYuVzMOU6E+L5hRXEc4x4HVS/7E4naGYMmqw08A4UBwAoqPqk46SWf5aVDVyCB5pFUcfTI8I57/awtxoTkLd8njTQPlaf4DRScluBU5ncqqerX4zoiqqer9sIHqQlOL8R+zOoDM0AQpLOlOVH0ehuBily2yzV/Aawv+4bxeLEIw00LL2CULn3sZIMRG3COVCv16NaPKNOOBM3okhTaV97hRdVR3H5bPYjDIeIuP1v7VdPGx63ppAW5KnJuKwGL80HGpzdrp/Y05ubeWWQw7xu0W8vdSCvuGkSurcYPCjywy2dtZyW98rSpm6nvfnr6gbCLIkDyPM+F/VuR2PvUHYNIAIFxBB3rHZsQ8E2CqBWkvAKK1nOV0Mrh5Q+quZPF7oW6ckaW0onPkrfbIHi3KklY3OjJSu/5Wv9VlOJyKd77eNPmz8g74tDB8H2Y7a7exN7RyXCcFN58JMKPOylgJMB0NFogvbxjP0xEZQ0nzfnxrGySk1gaJvMvRunRnLIcy1H0Q31t3gF3zN3ZqvF+LfJXzlx2k2Ya1b45PbIj1ORMM/KnXcLjP69nY/hNT/+GQiPrsSMWDclCctXuEL3kQ8coSLkqi4sOQNudtx60P6QLwpyp1wf9op65ROJxArk6vxf0SwMTurg7ILXx1EyWRW3QoAIpiGWqzNfhtiBysbr9qZtpaZ9b9UNi7J2OpVs/PpKxOA9adwfJpZ2Yo5r7/1En+luX7ScIqHnLNUzqpHib358P0f3E9IhsfAMf6UrcetRFLJzyNc2qAiz97DTffqaon8OCkktjdlr8nM8dQovKcyX+Lc07L/3WaOA4tO0gbh/QbIAgOMKftEhHdDXXNYg5SIl0vg/3bg6tcuC1Ftmet75XIYiP1sORjj4wUWB0XAWhRcTrXDn0g78dfEgcjEpNgd8UmLuGRT28vHQlG5i1UHzkl9fyInE/T9PvYHrejEQ36fDi+BL+Cn+tLquREcKIFafHI1/+Iz69EpM7Z6r0h8oQQBq9Ey6PEQITxS+9WHLjqGi3T2Zx8b4d5NXSe0N365LZCHsSXtVYxkEBRGN20o24sGYX89NIwHbb985YKme90cm/fqinWTmc2ICyWRkVaY34CwRo987ExwBly222fDwJN0Bxr+PILFKZ0Eal+225Y7Cp1p4j/U0BcRQo X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(36860700013)(1800799024)(82310400026)(7416014)(376014);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Dec 2024 05:51:59.3313 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 8a079ef1-bcda-4592-462f-08dd12956ff5 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CH1PEPF0000AD74.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA0PR12MB8085 If for any reason multiple profile handlers don't agree on the profile return the custom profile. Reviewed-by: Armin Wolf Tested-by: Mark Pearson Reviewed-by: Mark Pearson Signed-off-by: Mario Limonciello --- drivers/acpi/platform_profile.c | 119 ++++++++++++++++++++++++++------ 1 file changed, 96 insertions(+), 23 deletions(-) diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profile.c index a9cd13c5fd39b..d5f0679d59d50 100644 --- a/drivers/acpi/platform_profile.c +++ b/drivers/acpi/platform_profile.c @@ -66,6 +66,22 @@ static int _store_class_profile(struct device *dev, void *data) return handler->profile_set(handler, *bit); } +/** + * _notify_class_profile - Notify the class device of a profile change + * @dev: The class device + * @data: Unused + */ +static int _notify_class_profile(struct device *dev, void *data) +{ + struct platform_profile_handler *handler = dev_get_drvdata(dev); + + lockdep_assert_held(&profile_lock); + sysfs_notify(&handler->class_dev->kobj, NULL, "profile"); + kobject_uevent(&handler->class_dev->kobj, KOBJ_CHANGE); + + return 0; +} + /** * get_class_profile - Show the current profile for a class device * @dev: The class device @@ -246,51 +262,108 @@ static ssize_t platform_profile_choices_show(struct device *dev, return _commmon_choices_show(aggregate, buf); } +/** + * _aggregate_profiles - Aggregate the profiles for legacy sysfs interface + * @dev: The device + * @data: The profile to return + * Return: 0 on success, -errno on failure + */ +static int _aggregate_profiles(struct device *dev, void *data) +{ + enum platform_profile_option *profile = data; + enum platform_profile_option val; + int err; + + err = get_class_profile(dev, &val); + if (err) + return err; + + if (*profile != PLATFORM_PROFILE_LAST && *profile != val) + *profile = PLATFORM_PROFILE_CUSTOM; + else + *profile = val; + + return 0; +} + +/** + * _store_and_notify - Atomically store and notify a class from legacy sysfs interface + * @dev: The device + * @data: The profile to return + * Return: 0 on success, -errno on failure + */ +static int _store_and_notify(struct device *dev, void *data) +{ + enum platform_profile_option *profile = data; + int err; + + err = _store_class_profile(dev, profile); + if (err) + return err; + return _notify_class_profile(dev, NULL); +} + +/** + * platform_profile_show - Show the current profile for legacy sysfs interface + * @dev: The device + * @attr: The attribute + * @buf: The buffer to write to + * Return: The number of bytes written + */ static ssize_t platform_profile_show(struct device *dev, - struct device_attribute *attr, - char *buf) + struct device_attribute *attr, + char *buf) { - enum platform_profile_option profile = PLATFORM_PROFILE_BALANCED; + enum platform_profile_option profile = PLATFORM_PROFILE_LAST; int err; scoped_cond_guard(mutex_intr, return -ERESTARTSYS, &profile_lock) { - if (!cur_profile) - return -ENODEV; - - err = cur_profile->profile_get(cur_profile, &profile); + err = class_for_each_device(&platform_profile_class, NULL, + &profile, _aggregate_profiles); if (err) return err; } - /* Check that profile is valid index */ - if (WARN_ON((profile < 0) || (profile >= ARRAY_SIZE(profile_names)))) - return -EIO; + /* no profile handler registered any more */ + if (profile == PLATFORM_PROFILE_LAST) + return -EINVAL; return sysfs_emit(buf, "%s\n", profile_names[profile]); } +/** + * platform_profile_store - Set the profile for legacy sysfs interface + * @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 platform_profile_store(struct device *dev, - struct device_attribute *attr, - const char *buf, size_t count) + struct device_attribute *attr, + const char *buf, size_t count) { - int err, i; + unsigned long choices[BITS_TO_LONGS(PLATFORM_PROFILE_LAST)]; + int ret; + int i; /* Scan for a matching profile */ i = sysfs_match_string(profile_names, buf); - if (i < 0) + if (i < 0 || i == PLATFORM_PROFILE_CUSTOM) return -EINVAL; - + set_bit(PLATFORM_PROFILE_LAST, choices); scoped_cond_guard(mutex_intr, return -ERESTARTSYS, &profile_lock) { - if (!cur_profile) - return -ENODEV; - - /* Check that platform supports this profile choice */ - if (!test_bit(i, cur_profile->choices)) + ret = class_for_each_device(&platform_profile_class, NULL, + choices, _aggregate_choices); + if (ret) + return ret; + if (!test_bit(i, choices)) return -EOPNOTSUPP; - err = cur_profile->profile_set(cur_profile, i); - if (err) - return err; + ret = class_for_each_device(&platform_profile_class, NULL, &i, + _store_and_notify); + if (ret) + return ret; } sysfs_notify(acpi_kobj, NULL, "platform_profile"); From patchwork Mon Dec 2 05:50: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: 13890009 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2067.outbound.protection.outlook.com [40.107.223.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 27D691F8AEA; Mon, 2 Dec 2024 05:52:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.223.67 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733118728; cv=fail; b=la1s/gKcDB641xZWieg0fxOcLMZbc0Y1dHuXDfbzmThuh53sRWuMmtI9KbC48PNwJAX+lyN7qsYabPmOQTEm9Fn/zGHWL/9TL2ppWRJTK8H0tjd7WfE5KCeRrWVqHuUNjdkvFQFswn+pAb2zm0r1+P3rFFvvNpH1lF3qLef/wHY= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733118728; c=relaxed/simple; bh=KM+dPq6fppV/EB4F1B1uEv7wI59aTtfxB2Knml06lVw=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=dxE1cUHmB3/T6IF6gZPe4QvpZiIOeDG62SrVmXxiu9GdLvFLFqHoDa1V5W0kYx570wqezVIr6GqkGvXFsJD0ZlRrgGDyxaMGXgR8j+YljDFKPVxPUKOLF8VChE1xFtRz6IwvrzxDQQnBoOrw6coXX5NAOopxtJ8SHhQc3HRSah4= 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=FEj94E9m; arc=fail smtp.client-ip=40.107.223.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="FEj94E9m" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=CycQl8cVaue9an7U0rfYd8QKIyt6z5XrsO4XI5VHlb1G+ACR8/SOz4mxxuCYSsJ1UVVWtF/rc/39i8K0D2Otzp1m3gZn0FyaynMhKotk8X0PS77sq1ZzsQpc7yTKyM50TrKPo/RLINUfqQ58Eqvr/fKSLIilQ+VHPCT/E8UlPCpknqHLr7aC76usCoeKOdWdyBnu+aqQp8AGkk58OgPHqXIKJoIOAQQDi3X0DOo4IpO/3F8/0UB5f0AWtd1dbEVyC9u+/5feoBaUHZGqy6D4UGmCp/s/XHuFfZHMNyuEt8PFo2cx/U7ktonP0rH5ga9z7OhJ8F9FG5mr9LGkqXY5qw== 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=smturJnl38zpoH+XcVv6chpREJCbKkNG0Dg6yMqE52A=; b=JsR+MxMrnue89oUZGdn5iCz6JsPulrhM2pmh/LJkjSwoFsZx8jXfyIoUjnlmzCqQV/q7rj3btORHrJLjfEcsgpEMS217q0uoy5O5yyZTriis5OCUM+QuNBRU/BDhFop6bvZELYI4b5ojSNHSw+gMH14B5Ik3Ip7VvixkQPwWKrs/z4yGvBLU+nx1HCcCM6aRW23E3mwAUbqvmLITQ4p5DGXa4o1GFgMuf6/5n+QVdAL3RK1LnCp/GNNcm/OaeSjJyz/NybIWSHMxmU8shwp18nLNynlLwWSuFI8fD3onkIud5XQM6lnp1+ccMFEgXjZwCWWVrXjDO66Z/0hVsURaOQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=redhat.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=smturJnl38zpoH+XcVv6chpREJCbKkNG0Dg6yMqE52A=; b=FEj94E9mf4v3iGBvZ5Z9e/2S3OWLGaneJGltXf2F9cTJ4IZA7uBdBYK1/o3Ug1icfKcKeAzEFV8PuPbsq/pdNoNAeBzG4mL5vJrcyUqVqBheC/ftuasCjv+MlzXaCeVNBK1dTQLi598U4T5BdNsL+h2EPQtOia36FZSdjVvXK5I= Received: from CH2PR17CA0002.namprd17.prod.outlook.com (2603:10b6:610:53::12) by MW6PR12MB8900.namprd12.prod.outlook.com (2603:10b6:303:244::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8207.18; Mon, 2 Dec 2024 05:52:02 +0000 Received: from CH1PEPF0000AD7B.namprd04.prod.outlook.com (2603:10b6:610:53:cafe::3c) by CH2PR17CA0002.outlook.office365.com (2603:10b6:610:53::12) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8207.16 via Frontend Transport; Mon, 2 Dec 2024 05:52:02 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by CH1PEPF0000AD7B.mail.protection.outlook.com (10.167.244.58) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8230.7 via Frontend Transport; Mon, 2 Dec 2024 05:52: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; Sun, 1 Dec 2024 23:51: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 v9 18/22] ACPI: platform_profile: Check all profile handler to calculate next Date: Sun, 1 Dec 2024 23:50:27 -0600 Message-ID: <20241202055031.8038-19-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241202055031.8038-1-mario.limonciello@amd.com> References: <20241202055031.8038-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: CH1PEPF0000AD7B:EE_|MW6PR12MB8900:EE_ X-MS-Office365-Filtering-Correlation-Id: faf1e545-ef0d-43ff-4908-08dd129571d1 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|376014|1800799024|36860700013|82310400026; X-Microsoft-Antispam-Message-Info: jMCqLqlW7zbEoroEkYXDFdwO4s1emsc2kJYTpLLgkbwH48x8kEqg0uMTU7mvOjeMyr2EXzQyFLxS2Yq/VekhzQ6Yq+DuBLZgU8GyEVzcMAqLvjNKNwmPtC37m4zDVDkfuLrImMIW0OzpngcNf4rE5iHmg6J2vQFBVI3CxEh6nZ+0pfgg2wBFpDoGZHAYraEP4mscYXUGLUaXTGYANaYQCBCyr6teU31132kNVOjssW1x/pfmVdzbvtgn6KsJcNjFl+UEs41NDunQNblSC7/cOAlQieeGRk/Nabmvc/ztwH11phCWvt7OsBK35piHg5CL8/mC9WF1N4GMINta+iDzOWCYuCbq3gAFgadIpRUiAWfjJxNsIJsxBy4eF1UcKrOcHSZZymzvvNRrIBdpXB999L9ghFxoPr3pHUtutcLgqgKin+O17d95dSMjLH30Eg5hPtj+u082vyae+8i0nfsXjHpNba9SxA77FlRyaekGSFl5oHWOQcvPvSPyn81LxahO0smCCmmqt+W/7Kue3OjbD7g6RpkGp6gonCLsGdbJXuc9sZyNgjTtXu2U12TkJ1BP7kPaFjihXpShgWacE0mSUtoa8IvtOUopBvBL0ieHw51S2v2PErrjyRtgMcgRnZJ4CeAc8pkmN1t6AJFsp7lqrnfEcFs8aD6wC552LqPMdQWNMHN3M+LpbAMjk4XxlqNuZq4ZDtEKiRr5adGJOj9eewTu8Q3wvqk/Vm2DiqkQJBPcpfauCmYHIYqadFRXUb9qfM0Jx73hV18RGjKKTeJ9qyWYJhdTjAvN07xKTHO5iA+Lo49x0DGRgSkoWLCjtb2GE1H6VqaBO0ET44Mnw1R7bFMobbeqq3TS1BQuMxFrQvVG2Xp3tgqy8JA115YBp5wlgnH4ue42lrGwA44zvK1185Xs81H/yFI6foy+VEC+GndFiILL+ZhmirlRH6ASRmQYsTsnuo8vVUaZ6R1i3JQqT9/7jSpCNZpN3itFuwwDcasYN89IaKHJ0/BihoovNyONXaLfR4E1kSvqwlT04Io6OUEM7E5PJ2sXcbaErI9YQ/Pu3Z0qT2N9CGPOjyOOTQzjWop7elB1ZIzIqrGcqVrQy69DcN/KQ6Nd4PUzvazlI7cbbhia0jDeidSKT6Sr/jNEKowV1L8gF5gpcMotX4bKm05Na6LJ5QXlXumGOW4yx22jQNNBDehWer++HVknRvKeuf61U/9heRAY86QKWf+uSJsogqHLU1jQEsQ6+YKJgPYBVlKMpa1mAYUTueid6mhamVjCCTqSzr4E3oTNL6C+Gv57aBFovUpNjFMlqN9uBQS1UDGLIOt7tf/RrMGB8YZvLRcdgfxhuimk7xfcbGltxpfdctuRtB8i1vDS1eUhE93iA6xFgMMqAzNopLkXPgEZOcifDRg6kZA8MM63APW8LzYGQjMUbbKHO7co8N4Vdpw6pEK44siX0nthStGOc0Qt X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(7416014)(376014)(1800799024)(36860700013)(82310400026);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Dec 2024 05:52:02.4509 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: faf1e545-ef0d-43ff-4908-08dd129571d1 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CH1PEPF0000AD7B.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW6PR12MB8900 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 Reviewed-by: Mark Pearson Signed-off-by: Mario Limonciello --- 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 d5f0679d59d50..16746d9b9aa7c 100644 --- a/drivers/acpi/platform_profile.c +++ b/drivers/acpi/platform_profile.c @@ -407,25 +407,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 Mon Dec 2 05:50:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 13890010 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2044.outbound.protection.outlook.com [40.107.94.44]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 299DF1F9432; Mon, 2 Dec 2024 05:52:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.94.44 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733118730; cv=fail; b=LJevqeavXZ7mhDS2h8800E1qrD6UHCeMiXsQx/f+A+7H/A5vfYCBMfQ9u+WXLykvY41zNVQfJ2qp/cGM3wipWTgGPmzcI8Pi+gQvS/uQ+V/uZHWhMJ+HbN3+97NyJzllysfspx6ZgOfu0IH75eusU7ashUxDnXwwHMX5mueGyqA= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733118730; c=relaxed/simple; bh=Q9avaHbOthdc41LgOEuzAOMf3jR41UX86Qe6lJzXjYc=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=CcyfCnAVXoMC98CQPbrAvj5OuW5jq0gwSZAAvRM9kPFa+/Y9ii9KMTgKQe1jakNKN4WuCBWf7AFsNqjNFbnr+kdd0iTFNAz+dviPAyeFnX1m3HnERebzKqw444FpgghHu1EzG3mwQpwpABP5iZjkCQbfjbYU5rtr1obRCA+5LWw= 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=OcNwqa4x; arc=fail smtp.client-ip=40.107.94.44 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="OcNwqa4x" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=zSymC3m2ozuQLxcRh0qpiHBQYw5vTp4qbvV+k1zVELGymzoQUEfcZ+y7Yq74E8qBbv4m2+/UbDkwttuicnqSoi64hIq8ENAWHSy1ftBm8IxZLBYg+76QNsWbGC0Lc0K+kjIgF49imtFfPAre9eqMUPi4EbfzYz6iAfdNfOH4QpfzO6eW3bOspcYzd66fZEU87/FZeMqJBZki8zACXBzHeey49ZnsskE7PyQFQ2UCJO0c7vXPpZFOY/9IZT4P/AaVuB/RKR8f7CagJ9F6eZhJnJyYNRG5gSkn72DucAFh3cx9BGW245QPDn1BfyYJRAogc51Y5a9wF9JhTHxi1TPtBw== 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=FhPbuhl5p8r1g6n/pTVVP/pO7JKpLp1XJelDnHFGo9k=; b=byxSge8amZNidXpeNQgI/1nm/oiKBzSNQBvTsNyJk49ThAwxTNMiFbOYhDeNFnYaeL3uBqz/aZllnCiKdqBDq/CNfnuIHk1BCsNhYW6kqvEAJEOh97opbKRANPeSAcnCxeSlZ6OF+NP3HactgPDfeo8Wf786FNCmOVLHsMGfEro8nkIrwW5WJyER5zSaxSRp7r7qKKCzPn/jbvvP8IHNc2iLvx9oORhoI1fBNgCp6GPV5bXWcKO6lyZzYjv2Z5/1pfO49oLROb76mfMWxPfVO2ZSdhtXteqbcNEjbe6wKZ8P8qfse8EuU9eNG2jWN7RstyfxKN8lMi6UiKFu9gJBmQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=redhat.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=FhPbuhl5p8r1g6n/pTVVP/pO7JKpLp1XJelDnHFGo9k=; b=OcNwqa4xYDLU4NNeUyG8w+gS456VoAxO/4+LokDWjXwaai5NssvQinWv81Bt1mywGsENUJ1yCugM4+HTrF+GDGvBj+5171v94OXcFEsdq9BMMat/6rMQxqixi21flNRknOGB87+6CfNi3nHQJcqKCj1ZsO7SN6CAtbzVrcjNXbY= Received: from CH5PR05CA0015.namprd05.prod.outlook.com (2603:10b6:610:1f0::20) by SA3PR12MB7807.namprd12.prod.outlook.com (2603:10b6:806:304::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8207.17; Mon, 2 Dec 2024 05:52:04 +0000 Received: from CH1PEPF0000AD75.namprd04.prod.outlook.com (2603:10b6:610:1f0:cafe::e3) by CH5PR05CA0015.outlook.office365.com (2603:10b6:610:1f0::20) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8230.7 via Frontend Transport; Mon, 2 Dec 2024 05:52:04 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by CH1PEPF0000AD75.mail.protection.outlook.com (10.167.244.54) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8230.7 via Frontend Transport; Mon, 2 Dec 2024 05:52:03 +0000 Received: from AUS-P9-MLIMONCI.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Sun, 1 Dec 2024 23:52:01 -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 v9 19/22] ACPI: platform_profile: Notify class device from platform_profile_notify() Date: Sun, 1 Dec 2024 23:50:28 -0600 Message-ID: <20241202055031.8038-20-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241202055031.8038-1-mario.limonciello@amd.com> References: <20241202055031.8038-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: CH1PEPF0000AD75:EE_|SA3PR12MB7807:EE_ X-MS-Office365-Filtering-Correlation-Id: 816dea74-65e7-4790-7056-08dd129572b9 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: +VAYRfaJA4L6OniAokknEPiamWLpFwV9rJhwfAXFRQhejJxfNZnQjRYSYLbGINsyfnPMmG/ucBT4P8oGKqf07mZUQS7FxyS0L9iRd4C8raOcdARdQkLVoiOEjiw+kF+3jhwtR1s+TkMpGJ8MVz0SN2hGbTG2PieCojyKrmnVQisfgWhgb0IKQBum1IpSFIYTSOQvPwZONJFyvlHZhbQl/o+7lFs8CGKVW9ZqmFZyhRA8Gy5XxMKE3DofiG2uvFu3Z6iEb4wHuUm8XmqLKEisfs0rECfJOrzQFuTP7gJLUka5Esl5zCKpaFPfVQlOHPGmCuZJmQaGIA3ZZUTHgsv8xRSfuZmZqDld3G8dLKnrMxlZWlgDp3VrwJtGmoKQbd6TNf2RMngeh5lDpAf9V4LYZkZGHxnbCAqfyijeGXBc6kIMvH+VFPfoyZDJuFTQs6wWgX4w9a2vnnftWeBjSyxvvPwwJLwsXEYA2YtunnFmfm4ybMqq9hVhXsle5LXZ916fjfCM9D8+akS5uQzuWy4U5kgbYLNxBeLjDlALvvy/hJ/IJT2eVXgwNNITdrtcGFahuuzwdVr+zQU1A3PgVG5SiQuSFmt3kkBkzuiNhlQdsAdI2paz56uFZp7+UQ9xoH0vckcYM6yFpTPJgFkFsr6OyUntnLmImfYpWqtf4jgFmc1h4v3IhbqBD8ULD27mWuWvJvfQKT1o5TlziWb+gS3VFTwPki2vC22wFboouvoGnVFC05j9ReCwfwF6/BRQYYSLCqUV9zr+WfVgbt9foqewmAuawXlRbARRdoyipYQZIhtW/HXJ+Uakr3YF8gSaQbuJqrz9Ow5FnL8U/+O4eVeWBx0ZIriXrseoCmhCGFl3nbO4uMEhnHnSay1R6btviJrZ4DDGQqV1bRR2IVSi007ktS80gg5mQH3vwUMROj+7i8sLI20Bf+bNS/ahdAkVzo+0/vXyRBkyTRIu4BwPTtIaS/VrhGux0eG55SiTpSi2M5WxVnjJb7GuJl1V164rRo86OQnduKKaXcf3CP5FD1qSwgi6qaqWDDsVXHBZ2aiiLwCZwnNWc+Jv7x7wvFK6qU6yqsuIKLCN08hg5VdM5CqWnyL3fRFb0sc7VbVEIKp5df7ok1T4gt1V21zfrNMlU9QLZa0Kqll6wEM4a5n7HYPYI1ubUGLJ17TFLazi9LXYdyrfGXFisjQd+vnE2FJLOf5BbqyLsv17C8XsVl+1BTQPNG2s/9R91C/vNIPMP9oeu0zNOC9RMDjsKKZSI60uhtfXOAtz6RJWBDhbFxe3e1ylkeMrM/xsqX2p6T8QrciVb55h7QivmVgQlgmtKvvExbAtQhiYm984eRQkKlV1832fIj9aR9r0ZI14LZCkAEvB3B00RN35XFVi0OeGTBGC0QAzuDiXWYQhFTRBRbMMNPnrAI1PskoNGH125MBWD55dqpQxLH1v1teTG3tMhkS8XiLs X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(7416014)(376014)(82310400026)(1800799024)(36860700013);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Dec 2024 05:52:03.9879 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 816dea74-65e7-4790-7056-08dd129572b9 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CH1PEPF0000AD75.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA3PR12MB7807 When a driver has called platform_profile_notify() both the legacy sysfs interface and the class device should be notified as userspace may listen to either. Reviewed-by: Armin Wolf Reviewed-by: Mark Pearson Signed-off-by: Mario Limonciello --- v8: * notify only one dev --- drivers/acpi/platform_profile.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profile.c index 16746d9b9aa7c..289b5d43638ae 100644 --- a/drivers/acpi/platform_profile.c +++ b/drivers/acpi/platform_profile.c @@ -401,6 +401,9 @@ void platform_profile_notify(struct platform_profile_handler *pprof) { if (!cur_profile) return; + scoped_cond_guard(mutex_intr, return, &profile_lock) { + _notify_class_profile(pprof->class_dev, NULL); + } sysfs_notify(acpi_kobj, NULL, "platform_profile"); } EXPORT_SYMBOL_GPL(platform_profile_notify); From patchwork Mon Dec 2 05:50:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 13890011 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2059.outbound.protection.outlook.com [40.107.93.59]) (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 65CD11FC0FC; Mon, 2 Dec 2024 05:52:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.93.59 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733118732; cv=fail; b=dI7/XD/12y+aR87mrPWCTODuRItpmDvE0f8CpsQX/ugcLDKGDBKpy28/+ouTqUyXPlYSUUEJq9IapzG+Q1QZCj7C7VEDopNtJIzi5YKJFCdYmY5W0B0tATdXzG8Hp7aB6wzmBjbu9CpFKGelwcV0/GJyfHIvSZbXm7DyRP5e+4c= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733118732; c=relaxed/simple; bh=Ic1kSez1p5RhlfYjfiCieTuIGQgUojglIYTT9+//idM=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=skuo9zPGdYCS1NYmQnJd8EB9cZrRfsYEfxUFWcnJxRBV2ormG17jVJekFqef5oHL/PLB3Ba1xPrDamfB3YFBzof9y9FZwtwzUoP1J9V4Rp2daN+PMi+NvVjWBJ/5v/4QoP46/hxG7G2tT0iKDrWf2U/eLWCfLMIuzcBwYcPCx4A= 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=TrZ0An3U; arc=fail smtp.client-ip=40.107.93.59 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="TrZ0An3U" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=iRjPPivATxZTlQlv/GQ1RdScJ3M0WTmXhsGjS6TAT50VfGqzdCMOQaKPFKpRBEC2/Q2UvOvn0QrL9CbdQj072Dp3zCyUQ2M0wBD/K5iwhXccRfdmYt8CiOGaLEYB1RMcZRYpogL3Yb8UXeVQlk9NzRR4/7chASS2QrGmaHIB+vLhkT2LS/BFpjjnSmpCvdEZtUA7yGtIrJ+lW/m3Fk9Uh5xDOBipTI53sW2Kmghzn59gbyiSQUoHHYHvyl3CY/g2kAT8FoCGwlyM+kWCWhHhJIx0exmMGU5ByrBVVmdc2LMrzu1o9DUKgiHJrgbrGIrprsmBtugsvrpvAAjO5BhBdQ== 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=ZygNqvmrqxLlOcz7KlrmxmajDRP0uJQIhejUlstLa6Q=; b=wvI6K/0NCmNtG0MYczf3hWG6YWeuuhXr+22RZcdFA76cxWXfC7QfXc8bwH4Pyw8RUpGdb3LqraDQ+JzqlmvekIxS+XA/ERKA2NY6QxvWPSUBJjbtH/jJS5p8DG5SFXSdzmCVqabHjLl/j8cAYoeGiHeBPX3KDqdfzqOsmX1ew3xyGMYM+bxUPvNJL5ItVl9llZkCtTiaMlFypMkosM4DWsHpA77ferLYI5Ms/gZgYVvfrRzMT72afHiwhslme3X78fdwbAZMehOBJs4TTPataba/IX1g9I9Cdjmf2YVxKXzeu5cjzKsFcLfuMCNkzYktqZKaGMLmvEylFkDMbCca0w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=redhat.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ZygNqvmrqxLlOcz7KlrmxmajDRP0uJQIhejUlstLa6Q=; b=TrZ0An3UN7w6I3wBedGZGhh7/tjMA2vc/81b/DEN9A80DCGt9j6DUGFiarIhYYdSF69gSRgthGmsojkplI5QDpIGG6t5vYRUfv8QNjBxiqtLThIhxXpkWur3oCsAGfE4ThZeTN06ho9ehAfpprgEBE/UQYAn/XFCKl5JZySKy/A= Received: from CH2PR17CA0007.namprd17.prod.outlook.com (2603:10b6:610:53::17) by MN6PR12MB8542.namprd12.prod.outlook.com (2603:10b6:208:477::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8207.17; Mon, 2 Dec 2024 05:52:06 +0000 Received: from CH1PEPF0000AD7B.namprd04.prod.outlook.com (2603:10b6:610:53:cafe::75) by CH2PR17CA0007.outlook.office365.com (2603:10b6:610:53::17) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8207.17 via Frontend Transport; Mon, 2 Dec 2024 05:52:05 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by CH1PEPF0000AD7B.mail.protection.outlook.com (10.167.244.58) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8230.7 via Frontend Transport; Mon, 2 Dec 2024 05:52:05 +0000 Received: from AUS-P9-MLIMONCI.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Sun, 1 Dec 2024 23:52: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 v9 20/22] ACPI: platform_profile: Allow multiple handlers Date: Sun, 1 Dec 2024 23:50:29 -0600 Message-ID: <20241202055031.8038-21-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241202055031.8038-1-mario.limonciello@amd.com> References: <20241202055031.8038-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: CH1PEPF0000AD7B:EE_|MN6PR12MB8542:EE_ X-MS-Office365-Filtering-Correlation-Id: 4a0d80f8-4799-43f3-09ae-08dd129573d9 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700013|1800799024|82310400026|7416014|376014; X-Microsoft-Antispam-Message-Info: dTXJGJ0QkUll72ZrlLNjoqxHiW3Wq0BUTn2ADfiBx7l0NyB3o02DIPnXiF6oYHANMAYwBGgC5snvEHlfApyw+8F+JAy3Lvx6Fu0iO11olWjYcwH1Nq35n/YVnSoM3+WDC1j64ByNCbF7lNCc5/BYFVRqWFrCjFE+8IMtjxbtnjR8c0/0wtP7RH93uilx/zDIbSTBBKjH67JIL3e6dsWI8XOCnUcvhYh+Wo2xAoPeNFBXaMvJiDSKhJrYN6S9b8Nzp/GL2ij1H+E0SV9JkTFIySubvCW7uaCKMk5ib3DzaDURhYXApbhX4GApG/8UE7FDCeenSL0AjhApTpaY3uAUag7lW1jHKC/n0ihYqIUhdBjdagvBAaQWu1+kxkVqPkHGVlzpj8EeP8CNsPtWXOWayFh4oBXlzTJ66afBpxOZineMMUVfekNaIaIK8qwcUbBhTh3Lc+zU0tQtLgj5BCtBoRHBFigcWyk1es6OUX6BOc+iZl/0Hc8mwCgghZ/Iux3BR5N+oIGUR7WEC1ktTYAVDzyv5+UJ0LuRLMKMWePQsNCYIxDmyFUpDS7XVfjHpTlBzbnWI64KWTkfY6oye1Il09wGPqsEDYVp99jAVhtUZwSe/+VCgZz1DKcJAUzgv+NdCqwYoO16N4z83JByvvqosCialKl3cB1FVrFJJg8TczGj2QsbIVXd3u3I+AF9WTr4PrHYIELHAqkkUwmmltndavsaw6Dhb/3ZG8PlZrkraYWs/1jibFFk6hdw0FGDLwslAp0QaWsh6Y7L7kp/Emd2Nad4pWsDG/C6NFIngJK7cFjWMt6onCx7ZpVNK0EE7J+vjLgzlON1jSLZOaCewDjMxYS823ElbsWQgohIyJ8u4uSYlXvpuH/3dHPws8Q5GX2/Ymlf2TP1XMtKpxoYOUjBW+G1OYuBUinOomUw8AunV5HAtatQmKdmKpEFoQplHZL1wyrq09nOoRBr6FkCAvetcz1HXNfKZYnAX0VQS0y4bqXT1F8APYJc3gOO7iimYjXmvtodsQoKlZJGZDpwtk29KWeIedzmpERmBQ9EK+3sqZHUe8+H51yhLpj1KeAXY5veiJhrnUbJTQ6eH2Q26G/wmNYaf/yMLjmJwIQKbxec3A+J4OtF3jiMFfbJGheCb9yHGVGMzYYfytevw38LgMhT55+ItjxTT9FwHWKIhm7eY6unXG9u7fKMxUQVC9R+ScJ6EyIcnaz5WondTAe8jSCr7TAFQPv4OUwkLGnaeVXoYbv9h1A8+FFWa75ff4uE+aUHYkVu1V9MzOsS6cPwrAd4RjAGUiY4uYASxwr4uulIVVOkFHf2v0FAJfgjqaYG6+GzrFYcjvBKXZ/tmdLOXWT7BAZsr77f+Hr9+Mxs+EyTagjaC/SpTBOXCSNWlJWXFgLnoTRrPpG2lNk8VXLy/VK4SQbJEgBe3uurmMGP5yFPqcDxF4EEZV2QvBMdyjPI+Ov+ X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(36860700013)(1800799024)(82310400026)(7416014)(376014);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Dec 2024 05:52:05.8727 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 4a0d80f8-4799-43f3-09ae-08dd129573d9 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CH1PEPF0000AD7B.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN6PR12MB8542 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 --- 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 289b5d43638ae..2e38aa410b3ad 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[] = { @@ -399,8 +398,6 @@ static const struct attribute_group platform_profile_group = { void platform_profile_notify(struct platform_profile_handler *pprof) { - if (!cur_profile) - return; scoped_cond_guard(mutex_intr, return, &profile_lock) { _notify_class_profile(pprof->class_dev, NULL); } @@ -463,9 +460,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); @@ -481,8 +475,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; @@ -490,7 +482,6 @@ int platform_profile_register(struct platform_profile_handler *pprof) return 0; cleanup_cur: - cur_profile = NULL; device_unregister(pprof->class_dev); cleanup_ida: @@ -505,8 +496,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 Mon Dec 2 05:50: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: 13890012 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2057.outbound.protection.outlook.com [40.107.237.57]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9F0F51F943E; Mon, 2 Dec 2024 05:52:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.237.57 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733118734; cv=fail; b=M6s34OI5F3exhqlFWj5P+B8wNT9Ffg/EiGJTs9NdE3T0OW6tkB2WYPg3FVjZ1MMzn/HpD/jCCgMvCI4s4mstR0NwS8Oc+0+50wl3ZlNKMrvHEZe97774qSAeAt1z8cSGEv2N19ycUO90+jBltupM7snmJ1WfUx7W0OB1LY9IdLY= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733118734; c=relaxed/simple; bh=gnBSoFNrP8JY9HMIGKwmf6pitl5xXDFNXwZjpg8UPDk=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=LUuTByN3quMUi9rW44DiHwC2YpRWfY+nNnnTDoE61mrQ4prrOKjmh7Xf6uIDoNh27zHSAnw28Cq6ViRh0wyABGoisLqAG5H1m2bgcHcRKrkS+5n+GKLsCMqOrl6VcKbJeQ79IrutTp+mGj+pg7iZ+akqdFmG9Le4Gd5KMgmDGdk= 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=qjW/wtUI; arc=fail smtp.client-ip=40.107.237.57 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="qjW/wtUI" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=PChU1GdA+vTc5+XXUQxoA/WYp7Kg+fLOfhxinqja3Ird8RyT9S1ofGVUQyQ9hXBzaGMIiqPezGjGkqvznvRKHBbZ/E9um8OdA55b3JcgpAmcHnJbc/gSxm9Vdb/4Z0k6fNcxGUPhPBsM7fkR2DbPrMeX6ptJRWItslk4B2Jv9grjoPyWOs+2opSyMiEVa03LJ5Kw7BSUAruhoZTOn3GvoiHGvIPAsGKhsekGrHsomWw0OBjLPfZjEfUGhfRZEelu71cbwfActQgMoIkDNg5FR5ednmuBdbYzEv8mLzARcpAvYn7URZ/BVYD0evhBTv1t3tY+3bufKimijeakcEmGzQ== 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=uvGa/ULj0+7xI0tTFN6XDMWS1c3ltWrpsoEcLfQvXj8=; b=vVlTO6JO/uatGTdkJOwhCFbQGFiRrc1NrIpn+vd/W3bL6jnS3yhE461AJMs39wjHe7ev6X3akkLADygfqdGyLP1fw/ZyoG/KaKQ06HuGwWuu2jIWjXQZsERTOeiHilwZ0HJat68cK88TXl6wGC4PxPc90XPi7n6e2bLkXHwvX6QfrG7TLH9VWm/UDHiUicgIbousrSBI24Y9cLMJX6/RB6ZzI/uJrFjDAAJai9uHBjmfjef03maQEy4FcbtpUIsHpkLsunQFcj4kp4tLQob4gNvegXQu/XV/wrX+rBt7PsRv9tK8JZ7Q8vqXf7yHs1MXjN5Nd1dgqpXc8Z+NbKnDKA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=redhat.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=uvGa/ULj0+7xI0tTFN6XDMWS1c3ltWrpsoEcLfQvXj8=; b=qjW/wtUIH0mOYSgfkz4n+jdCdw3r9Uczl9MaD+kqZ/Shn1drY236ivUXZX9CJYfCanSynINqYAQY3TF9x1pqXZoPCgRz9oP1ahAdX8jor/hK5Og3mnIUrTruGPhjMXLk26LDORktyrVXaPOuUOPWDqhsSqZ5fBsFAFRwPZUmgwQ= Received: from CH2PR17CA0009.namprd17.prod.outlook.com (2603:10b6:610:53::19) by PH7PR12MB6659.namprd12.prod.outlook.com (2603:10b6:510:210::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8207.17; Mon, 2 Dec 2024 05:52:08 +0000 Received: from CH1PEPF0000AD7B.namprd04.prod.outlook.com (2603:10b6:610:53:cafe::38) by CH2PR17CA0009.outlook.office365.com (2603:10b6:610:53::19) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8207.17 via Frontend Transport; Mon, 2 Dec 2024 05:52:08 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by CH1PEPF0000AD7B.mail.protection.outlook.com (10.167.244.58) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8230.7 via Frontend Transport; Mon, 2 Dec 2024 05:52:07 +0000 Received: from AUS-P9-MLIMONCI.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Sun, 1 Dec 2024 23:52:05 -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 v9 21/22] platform/x86/amd: pmf: Drop all quirks Date: Sun, 1 Dec 2024 23:50:30 -0600 Message-ID: <20241202055031.8038-22-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241202055031.8038-1-mario.limonciello@amd.com> References: <20241202055031.8038-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: CH1PEPF0000AD7B:EE_|PH7PR12MB6659:EE_ X-MS-Office365-Filtering-Correlation-Id: 91294c0f-f2ca-42ee-4958-08dd1295751d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700013|1800799024|82310400026|7416014|376014; X-Microsoft-Antispam-Message-Info: Z9MWRT6LmYb3wLKvLwWnUIiEFoHEVTgkq2ETcf/L1pSO8vFx6htO7plqAqA6iETFDHU0Wu3rFysmYBECHDvqYfYs62xTYzcdc0CI/WXl2J/eooWLMcRWgO+pZzgGtzghfigu3wmdDbEArVL7Q4B1SskVqsCtl8pDb/vEGYKsTnqjJKVb1bAN8gVLNmeTh+0SXpvtwgHzcZvlz7lpqEEr1QSfg7OBk8UbufJOrzqaGPMV1yTXbQ6Rlnk14XU5Cdz8M9F+QSEGE9tuTGAOJp9O6jQkSKfx6L0miKqsEGEdvLuv5GSu5k0BXcbPUD9jE9okQX6GrdM9Ozd9wYdT+1RJsog10OsqfKk/7HaZ8KF+YfioNh//iYM6mpepIevcsmWInt/SUHFzMEY9rokvB3UYpoAYj9OT/S8O8dgoZKdPBv51poo/rnzOYzG5i/QGq22OLlLcjcVQxI69Dp8RkN5qXAy667QG/vlA/lDEeh/Fj2MRg025taOGPXYK/q/ohAv8M/NmwY2tVckbUdZokvOvpBNhDuAjK9o8bwR9Y07K8uFcdPIS/hgE1qLLJ56GaY9VzGTMYBaOgGSMxiVfvIaKBghAjNqkcln5paMhb9Ke3x5MZV3apWFJAGmikuC88IAmgndInhg8vKjj3Xv/8A7VVqyGz/RYJY4ujBlwz0aYrLPsD5O6JsQAuJo1tS6qyfmWF4h89xFUF/uJEpQDiAII0TDR8VV5J19FmlD/l+Xv3MeqJUXxmdbHkr1Bt6IYXxbB/GleO468b6NtixdsLH5rDoCZSiUm8yNr6Kv5p8Rau/cIlYNlP7NM/FXifGNkPWlDimel+DpWoPnW+j2Gh7KSY2VKhe9/Tx9lvt+WhKFkbQc4b9Yhngvj9D1KRsEc1bOUDie0zW0tBVwBQJmDadxppNWhKehyHlji5/cGyU7YDjPkxng3N7byeMyTG+3h6qLljfvdmoFD9V7jdlatSShdh6droCweLoi2qvcKsOmPRle3TgEeZ9ZDMzRCpXYglYjyJJprbcTJ55Ha36Lgc76Y2SA0PW6dPyrvhgHDR7rJmbM/Mhf1U0F+fC5+BaPDEkT3KhJmk5c6ZGZnpJFa8XjFj0nalZCr/jtvSJ9E6ElvHhUu5/fOr8zAbSwQ7igNxqHaBNuyNNJWe5QXxIMtgN9g62rcAtmx8vDpXwrL886SSzSilZSJ3mZ/7XOEX5kd+bLbARpC0et0cSzAXlrySp5Dwh82HWeiCCKuHULXmH0Rm4fv+Q7RZCzg8uTloPoN2c+WLNRIz8nvwQSlud9P5D7qmJRtdw4CxxwJ82XvafGzaF1s8HhVvqSdoMV+aSVaHUH7pq+7AKRPqsK3mXd9YqfO/CaH9ZNsrJ37ugcB5ke3cddFDpn1oVqHRTyo9llcZWxHpMyuOph678o8HfGpY5gg7FtzBbCMjEK4lHLwW7rZcIsY9J2NXaT/ruhT501rjtkF X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(36860700013)(1800799024)(82310400026)(7416014)(376014);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Dec 2024 05:52:07.9977 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 91294c0f-f2ca-42ee-4958-08dd1295751d X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CH1PEPF0000AD7B.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB6659 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 Reviewed-by: Mark Pearson 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 06a97c533cb85..01eb9ee1eccd9 100644 --- a/drivers/platform/x86/amd/pmf/core.c +++ b/drivers/platform/x86/amd/pmf/core.c @@ -456,7 +456,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 */ From patchwork Mon Dec 2 05:50: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: 13890013 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2050.outbound.protection.outlook.com [40.107.94.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 2D32B1FC7FF; Mon, 2 Dec 2024 05:52:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.94.50 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733118736; cv=fail; b=i7SW4ORqejgPebpOe+yTtJ8/Wan2nfsXCzoxkMYeAgV0ZxapUscKz4JiLifowRZlwJKWfhVSUr4PXvL+4yv05y0toQw3XClP4umRixpNtqNehW+c963Oi+1V5EpW6W/QBvHirno7jzj3MQU40MFjmqmhuyUbi4ZWWabdspTltOA= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733118736; c=relaxed/simple; bh=wf5rKNmIsnUUNoTwfFtQuOKmfayAw2AHgYGdmMq1vBQ=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=f04NNqWJO8+W2UpVNLnUCly84baHtQmlUPLhjTpcLYmMdaVoXv1WraqAuAsrIrXI6Fv42ZMlySqzKwfqlRuu+Nd0NGqoBMZ5Ve7pFyM1tYkjdz3lL8XMuVy9JxBjxUu2Sw8dtdNVW//IOxYeeMPJbQwUyMB4LjoB1gsVUK5EscU= 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=g2NnIKfM; arc=fail smtp.client-ip=40.107.94.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="g2NnIKfM" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=TgMyCtM035mUk5MD3qSOujVM0FyhZhsCbwn7kIGkfXHDwPn91EvThXWEkhRCizinokvYn9piMWFJBKixfRme5D8flCrNbBnUuJ4sqM97qMhqcYz6bFXYBJrev8CWjx4/AnaATUkzChe8bFQGGK+rzCu+FPNfymIhPpMnx2DrlZFPN8JM+rBAJ9i+9tjeV9+b0r8kYKgQ+xzQmF9KLynmD3ouHBI9DEbU6IWsu+F5b3pv7S5+dqiBFhqhbQ7XOVs3K6C5S+9/M+GJ9AuudL0YmAHZRfaxsPo+hp1HFV6LxcXpGF4z+/tjv9uBrvn/R5ZRQpcG8uBYgmx/2xDzwNPjxg== 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=Y7AsA2wn+UuDjCVQLXzWcZ19ajtJVFU0lsgjVGz13nQ=; b=EZEEcR1T+VRMhhVyArlTFvchsnkTdOuG9efdpr6XDZjMZwdYW2Bphp3qSm9AcIP7q1qFp4Ipf4ULQIEXXUbs7aaT8QmiJ9IuZhS/5+tI4he6GZ8KZjJk4FHgJs/M3qoMqpzYiSK3giyumGGaEGQYPOTUXsNXZmnoQd0Wadc7UQe0yOVv4zr+qnV70CqWUnQlgHfB+lnJMrid4hgGnYLupPXySu1s+8SUbP2KFqzyRybPktxlsxctn/BZO8jpZpGB6xgBqo8lAXkw31d+jTSJj8r6nctNjRDnOC1+F70pYLB9xX96xtpAnE+tmCN0L5qixbtcIEWXxF5GBUUS8krrjA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=redhat.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Y7AsA2wn+UuDjCVQLXzWcZ19ajtJVFU0lsgjVGz13nQ=; b=g2NnIKfMuN6JD9AjbJpdVglnD5kKsgHDwIV0jn9EEX8+Q/4eMS5jizuXkdH0oRlFuP2kLzuebbX1jwQBxJ8+wgzgxZr28KGd6m2BBLRmEycwbwc1bU/batAfM09C86/AcQImMV8gINFQT0h4nEkQ5t7yCevuGLEp+m/8mb085E0= Received: from CH2PR16CA0002.namprd16.prod.outlook.com (2603:10b6:610:50::12) by BL1PR12MB5945.namprd12.prod.outlook.com (2603:10b6:208:398::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8207.17; Mon, 2 Dec 2024 05:52:10 +0000 Received: from CH1PEPF0000AD78.namprd04.prod.outlook.com (2603:10b6:610:50:cafe::26) by CH2PR16CA0002.outlook.office365.com (2603:10b6:610:50::12) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8207.18 via Frontend Transport; Mon, 2 Dec 2024 05:52:10 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by CH1PEPF0000AD78.mail.protection.outlook.com (10.167.244.56) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8230.7 via Frontend Transport; Mon, 2 Dec 2024 05:52:10 +0000 Received: from AUS-P9-MLIMONCI.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Sun, 1 Dec 2024 23:52:07 -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 v9 22/22] Documentation: Add documentation about class interface for platform profiles Date: Sun, 1 Dec 2024 23:50:31 -0600 Message-ID: <20241202055031.8038-23-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241202055031.8038-1-mario.limonciello@amd.com> References: <20241202055031.8038-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: CH1PEPF0000AD78:EE_|BL1PR12MB5945:EE_ X-MS-Office365-Filtering-Correlation-Id: 2688015f-fb79-4489-fb9a-08dd129576a3 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: X2EFd16EQYTgGDqcT4QNzfxkPqgb1LiWEhplhWM7cJcvLhvQKqgiod50ex5NBjpcv0C06Qt2AD7uvIb0Z/uq0Bl8fdSWwxcg5k9mDhBNYPuzMoMkzCSpb9fUcWXhcmE0X5y+S6FD+9lC7KxBfbwaCZNFm8Tyc6u6z/L/+1KkBU2QZNaAmrtRTYzDvmzwOucQWTzOfgojPGh9t/JO5hmIn1gShBY/XsS1OKsh0g+rqmpMVpjGA5t4U3NwnZU94Q+fAICYCcgG0C2FkUZxeh5ec/D8kk+x0BSZUpFglBO6N2TAUEKv8MHGKOzl4sSrM1oAYbzu5E6hxQNRYoMJZXMNfRLkrdI8vW69dy5oe30h4jg2SB+TMRNbB1wU+kxm/xDSAGRHRzVy37EGmC9PvpZuAZmmKsUpT/e7nWKVOJt8QEYrcKDPGS8d+2SnIuOQMiCuwh6Le74HqTpLH4oLJrvNgRo8/wgItguQfNZYwyUjziOWTi9izTTnnlwhK5QVl+jadEo9IqjA9DG0qLr2shKLzjHoEaa02O+LHysfqDbmp/UEwADHDymvHg0Pke5Yq7zd3UHucwBZ9BTD2Q4IR9Lbo2q4Dch7Nome8ycVG7PVuEjCoZh2DXHZAc2BDB9simMv09I+FC0OmitxyNFHYl5OdaaTdcScTw9QfpTuTlc7YSkIRKvZ+AuQkgj9LZTVuKIcWMZ9CNobwWGqCr7TkHv7LsOBQafxPlHcNaoKdHm165M8tKatOS54LWqAvbF8c1iykVatbKFhCCALY3K2v6MCqodbcgB188l8USoj3hwXOwz80UtRYiz8bI5cRCCvtxn4mcmFhQQGJ1R9TPuQ7aVuFIvRK3NKocsGWKDRrIdQ9iARxMmIjCIJh21wgm7/iPvHYq2vAC1peOWZH5ci3nQ4VMp0t014hQYK7sZhtIrZVCztEjea+SmOVq1wqyrN/GsMK2OapNkjnnuMpN/7iQj7Gazpn9FDHSM/VdsPT6hIqdrNSqZbr4y3E2rfIl0CM66LrRtPzxlQ+MYB4OgV+cyE23wZIV8IDn9BvyfzorKSPaXeqSRhmSvOACUamoCQ64P5yETPjTEiDk3Xstg7kQzn6Ra9qF3pRqkSsWC9l9dTZt1K/ecsxnZUnBZA0gig7S+cBMhZWxEv0rTQdguEX+JjpXVBo0bJEyjjHIvOGlCmbyuPxngXzNhSPKhLtUCvgddtOHJ2gUP6jn9TTdjpgx9qGhkvyQMQXGZuV9APAI/p5LlU9fDQgxtbZcXX7hdgv8n+x6IWcwmMIm2k2rxnoxsHDU2qi4Du1uNtntC2P+th2FWPwfz40VWEAYF6L/o6F4IKF64NpWYkr7nMIJehDE7Kbyv+82wH9iUVd0DorpNLqntBRr/UP1bux6RINNND4NBPpDhIpLb9uGe+PnKFwlkvtzivuOYfCaKNiLeoebVT7a0aRPbHCJbgFdNKsQfogFRy X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(376014)(7416014)(82310400026)(1800799024)(36860700013);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Dec 2024 05:52:10.5426 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 2688015f-fb79-4489-fb9a-08dd129576a3 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CH1PEPF0000AD78.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL1PR12MB5945 The class interface allows changing multiple platform profiles on a system to different values. The semantics of it are similar to the legacy interface. Reviewed-by: Armin Wolf Tested-by: Mark Pearson Reviewed-by: Mark Pearson Signed-off-by: Mario Limonciello --- .../ABI/testing/sysfs-platform_profile | 5 +++ .../userspace-api/sysfs-platform_profile.rst | 31 +++++++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/Documentation/ABI/testing/sysfs-platform_profile b/Documentation/ABI/testing/sysfs-platform_profile index baf1d125f9f83..125324ab53a96 100644 --- a/Documentation/ABI/testing/sysfs-platform_profile +++ b/Documentation/ABI/testing/sysfs-platform_profile @@ -33,3 +33,8 @@ Description: Reading this file gives the current selected profile for this source such as e.g. a hotkey triggered profile change handled either directly by the embedded-controller or fully handled inside the kernel. + + This file may also emit the string 'custom' to indicate + that multiple platform profiles drivers are in use but + have different values. This string can not be written to + this interface and is solely for informational purposes. diff --git a/Documentation/userspace-api/sysfs-platform_profile.rst b/Documentation/userspace-api/sysfs-platform_profile.rst index 4fccde2e45639..0aa384c75095a 100644 --- a/Documentation/userspace-api/sysfs-platform_profile.rst +++ b/Documentation/userspace-api/sysfs-platform_profile.rst @@ -40,3 +40,34 @@ added. Drivers which wish to introduce new profile names must: 1. Explain why the existing profile names cannot be used. 2. Add the new profile name, along with a clear description of the expected behaviour, to the sysfs-platform_profile ABI documentation. + +Multiple driver support +======================= +When multiple drivers on a system advertise a platform profile handler, the +platform profile handler core will only advertise the profiles that are +common between all drivers to the ``/sys/firmware/acpi`` interfaces. + +This is to ensure there is no ambiguity on what the profile names mean when +all handlers don't support a profile. + +Individual drivers will register a 'platform_profile' class device that has +similar semantics as the ``/sys/firmware/acpi/platform_profile`` interface. + +To discover which driver is associated with a platform profile handler the +user can read the ``name`` attribute of the class device. + +To discover available profiles from the class interface the user can read the +``choices`` attribute. + +If a user wants to select a profile for a specific driver, they can do so +by writing to the ``profile`` attribute of the driver's class device. + +This will allow users to set different profiles for different drivers on the +same system. If the selected profile by individual drivers differs the +platform profile handler core will display the profile 'custom' to indicate +that the profiles are not the same. + +While the ``platform_profile`` attribute has the value ``custom``, writing a +common profile from ``platform_profile_choices`` to the platform_profile +attribute of the platform profile handler core will set the profile for all +drivers.