From patchwork Tue Nov 5 15:32:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 13863080 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2063.outbound.protection.outlook.com [40.107.244.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 543DA126C03; Tue, 5 Nov 2024 15:33:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.244.63 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730820818; cv=fail; b=ueEJL53d7aYXVThGWSneNc/KoJ6JNCZTBxv/kq2fHtSFKbG0BLMakcE3bL72JqWEk56Q3qBB6kyLIhB0BcDaU0ywMEKJMBs4eBPwMYRlDsmw7bVtqy+JezFLESXE6e1+lT3oYXkoKZTvC+Wl3edQ3R8tu8T06kcIfo5a2NotdBo= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730820818; c=relaxed/simple; bh=7AooLGyysGXoohZPXELnGeYztEfM8k/ZcIos1h3C2wg=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=FwaztROY6FxIjsXCo2tvnj5GnCOfvYZEWu/EmHDEEUKqCislgxVcB0hRcx4S5e38+LJMWFueb9swYsPolY8sWiD3JsJLExhF9dP/wgtAkKNtUhvADj0u7bMPfvCjHj7yYyrgGsKvYgdeSc11SzT0CZAUU5WcJYWj8vkVolKWMgQ= 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=lCx5F5P0; arc=fail smtp.client-ip=40.107.244.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="lCx5F5P0" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=w7tTD0CG3LdBv2pVlsI5hqDLRWY1inwV30s5fsYib9hgDRSAXtch8NDbsAem/Q1ruYSrm3Q9o4v4m1E0QBF+XwUe+57wq9QEnjvWJjXO+RpTK3gIH2nhiEq6IpbNR6RygmN8ojwLPEPMvI4G2hTmAQF4gXc9deWWPUzQ2jz7CoAM2mdr8nrbf36Pan8w3m/a2lGbkyBel+XNnLnvD9jK6gvXR7W7ccV7nIr2FRtELBgq7jnBeE+s4Hog2vsu5A6E5ZdTSEd3G/2IMu7GzcqiG9Jm8olG0fMl2TLFfTZERCEX93rG/HnZbcEBz3E26wa+cllUf+M4GJ6yE0wtXOFQzA== 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=ZDdDjN4psyY/0raDk4s+w7ZhQvmNm24C4BYgq9B0YJY=; b=f5ehrSeGCvxTlKZEX2YH//oFXOymgYYztM7pJTuwqrNiSLB0HrcaIj3MDi/0eEmKHGWScnXE8Bchn5G6375NW5BQOmsLv8KKFygjPrhK2slfHBuwqX7uUM+6W71WwJRpuv6+K72OE0+1cXfs2AaH+VlIUqXbAu0uT4i3yFCgXQwO7uozIt9aLk+ZyKDxOrhj6JoHsqV+dpe91pdZaLngyNjEUpditecL72KU+xGlTkVsAg0kAoDI0StwXzps7Jy3aYZty8G9FaA/ltwg4ngFARVXVDz9Vof6jD4hyJ+SQFXQXHlencS1SMxVDca3xr5lyMzVoulisXNOM5Vh4RYBPQ== 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=ZDdDjN4psyY/0raDk4s+w7ZhQvmNm24C4BYgq9B0YJY=; b=lCx5F5P0F2+Du/c3/sTHp4CxmWuyzR+gM1BFumEToUbeGX9zQ0f2A8aLvO1mbllIMriMq/tJIaxcSjtLTOIH11x/wHvsVxaiFthupf1ncgZcvCmzKoMMSdlWXXJKH0mWY1b49I0bgROzhP3umDiVv883AZK9gEVmPEssHPDiRuw= Received: from MN0PR04CA0001.namprd04.prod.outlook.com (2603:10b6:208:52d::35) by SJ2PR12MB9189.namprd12.prod.outlook.com (2603:10b6:a03:55b::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.30; Tue, 5 Nov 2024 15:33:33 +0000 Received: from BN2PEPF000055DF.namprd21.prod.outlook.com (2603:10b6:208:52d:cafe::a1) by MN0PR04CA0001.outlook.office365.com (2603:10b6:208:52d::35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.31 via Frontend Transport; Tue, 5 Nov 2024 15:33:31 +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 BN2PEPF000055DF.mail.protection.outlook.com (10.167.245.9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8158.0 via Frontend Transport; Tue, 5 Nov 2024 15:33:31 +0000 Received: from AUS-P9-MLIMONCI.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Tue, 5 Nov 2024 09:33:29 -0600 From: Mario Limonciello To: Hans de Goede , =?utf-8?q?Ilpo_J=C3=A4rvinen?= CC: "Rafael J . Wysocki" , Len Brown , Maximilian Luz , Lee Chun-Yi , "Shyam Sundar S K" , Corentin Chary , "Luke D . Jones" , Ike Panhc , Henrique de Moraes Holschuh , "Alexis Belmonte" , =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= , Ai Chao , Gergo Koteles , open list , "open list:ACPI" , "open list:MICROSOFT SURFACE PLATFORM PROFILE DRIVER" , "open list:THINKPAD ACPI EXTRAS DRIVER" , Mark Pearson , Matthew Schwartz , Mario Limonciello Subject: [PATCH v4 01/20] ACPI: platform-profile: Add a name member to handlers Date: Tue, 5 Nov 2024 09:32:57 -0600 Message-ID: <20241105153316.378-2-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241105153316.378-1-mario.limonciello@amd.com> References: <20241105153316.378-1-mario.limonciello@amd.com> Precedence: bulk X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN2PEPF000055DF:EE_|SJ2PR12MB9189:EE_ X-MS-Office365-Filtering-Correlation-Id: 20c99e3f-bb23-45fe-d426-08dcfdaf3425 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?hO33Z0F44w4CXUH6JgOyMkbHnhYvbN0?= =?utf-8?q?cEOcxBiWsmRYtFiFOaBw1WZnal49P5JHoCTN/6eFi21DYdRHTHoMNhrwWtUj0VykW?= =?utf-8?q?lwdnH+/79KkDasCvt6yz9ug4m0r4qzmDX7Yiq7/0giE8FloaUfThbOHSxfOiPDspb?= =?utf-8?q?O65pXw6q+RwN0icDc5lqhJRsvd2FSkh9ASihLrQoqknRgyeLpOMkhw9pifj4d8x5y?= =?utf-8?q?iHkTnGMgYTdSK5L5+h0AT+Iniqc/Nhq1G8WA8+Q2tLmdhWw5xeHdTj4LeA7Tij9eP?= =?utf-8?q?MgMdjxEX+rsVdwjQyh3pu2EPUaUolVB2JHclN/9qnoJpPjbyFkudQuxCc2zhOFzNz?= =?utf-8?q?c8MrifQe2JnV53aiUnr5X+S0XQTMwtqV8XAYiKuEEKgW5XUl9T+GosL88jP7s0BVu?= =?utf-8?q?HJK0DH4r0wSJHwvSqQURh71IH2IQGc3Wybo2zJCl9gtXmme/YD4tLA+ngXdAbj56J?= =?utf-8?q?hzd/1fupOnDjTsfSy/Vwxl5GHVNTd0Y0oJ69iXH9r3ubTwxuwSBoB7MvKEYNXh71N?= =?utf-8?q?qIoFF+b3241kP+VP2gjb7mWfsuRTsgW83F3KppbSbK05YUalYar4k4ZsbEvW1TwLk?= =?utf-8?q?YyQU8qMMsiwO6f8aPULu6n8/AbwJ1hCyJEK6Haiqh6KKYeSDW1V4VpiACqGEr+pOf?= =?utf-8?q?98OtuVH0sUyX7V3cdOuznhXIoygns5hal8YB/jtCnK/d1Ieec0lBfeYndlUeRULgb?= =?utf-8?q?4me4HseaLNuzyFyBnVnNb2etJ9QleYBudNNGgibX86wHVB10Nrp2KqmwBd9ybvCJC?= =?utf-8?q?GYNCg9s/NyAraMd6YyWJxbJfRCPbWzyLhnU8ugN/0LaSC608/i4h2dPem6S8A73PA?= =?utf-8?q?WSAbrTyzTGEjfwvYsoWyAXfQGArlDN3ONNUEu1kA6jWdLWfEHOPoRGzlXWGswhRbd?= =?utf-8?q?8Lo9MOJdIcPHImwtzPQpv7TUozO5nyrYGJqi/iLCXE1vjgGYA5m8C+NijUuRHDCnf?= =?utf-8?q?4u+BM4D+LJotK6XtvwNQJ30BoACoZYSyyxMVeUzBZlKBmQnzkmsKyVWWtKCeSI7Ru?= =?utf-8?q?VMADfHBVUDHpb+hhv0nf4lJkxG3pt5yJKPk6lv4uI/wkPNlJoiN20MlGN5FP3Cq6V?= =?utf-8?q?K4GhYovDryw9HNb2NM6aSiw3vrmSRENw4EJdSiLaGwIWohnW96qfLo8sVxE7zYe7o?= =?utf-8?q?za0MaZCSTf/6GWBpupbkYy2jIRpl+sKfe8Vf1O9+tznyQ0F6WbKJKHI5pK8jsqr/r?= =?utf-8?q?T/IPTFzPfyNJX3bNF+YC9KziVtEHwOUe2PJTo8fUPhvNwq5ixd0ryeNpvEvqbLSKx?= =?utf-8?q?hv5YbQ/NDu+JGMdyTi/Ev1pU/cEMIeiBmfWmPE9BMwAbv3AGxh4TWnMnAuIsATuQB?= =?utf-8?q?72IQTECO0ovNm+YHmaisdQpRtn43OPEZjQ=3D=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)(7416014)(376014)(1800799024)(36860700013)(82310400026);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Nov 2024 15:33:31.5141 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 20c99e3f-bb23-45fe-d426-08dcfdaf3425 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: BN2PEPF000055DF.namprd21.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ2PR12MB9189 In order to prepare for allowing multiple handlers, introduce a name field that can be used to distinguish between different handlers. Tested-by: Matthew Schwartz Reviewed-by: Hans de Goede Reviewed-by: Mark Pearson Reviewed-by: Maximilian Luz Reviewed-by: Ilpo Järvinen Signed-off-by: Mario Limonciello Reviewed-by: Armin Wolf --- v4: * add alienware-wmi too --- 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(+) base-commit: d68cb6023356af3bd3193983ad4ec03954a0b3e2 diff --git a/drivers/platform/surface/surface_platform_profile.c b/drivers/platform/surface/surface_platform_profile.c index 3de864bc66108..61aa488a80eb5 100644 --- a/drivers/platform/surface/surface_platform_profile.c +++ b/drivers/platform/surface/surface_platform_profile.c @@ -211,6 +211,7 @@ static int surface_platform_profile_probe(struct ssam_device *sdev) tpd->sdev = sdev; + tpd->handler.name = "Surface Platform Profile"; tpd->handler.profile_get = ssam_platform_profile_get; tpd->handler.profile_set = ssam_platform_profile_set; diff --git a/drivers/platform/x86/acer-wmi.c b/drivers/platform/x86/acer-wmi.c index d09baa3d3d902..53fbc9b4d3df7 100644 --- a/drivers/platform/x86/acer-wmi.c +++ b/drivers/platform/x86/acer-wmi.c @@ -1878,6 +1878,7 @@ static int acer_platform_profile_setup(void) if (quirks->predator_v4) { int err; + platform_profile_handler.name = "acer-wmi"; platform_profile_handler.profile_get = acer_predator_v4_platform_profile_get; platform_profile_handler.profile_set = diff --git a/drivers/platform/x86/amd/pmf/sps.c b/drivers/platform/x86/amd/pmf/sps.c index 92f7fb22277dc..e2d0cc92c4396 100644 --- a/drivers/platform/x86/amd/pmf/sps.c +++ b/drivers/platform/x86/amd/pmf/sps.c @@ -405,6 +405,7 @@ int amd_pmf_init_sps(struct amd_pmf_dev *dev) amd_pmf_set_sps_power_limits(dev); } + dev->pprof.name = "amd-pmf"; dev->pprof.profile_get = amd_pmf_profile_get; dev->pprof.profile_set = amd_pmf_profile_set; diff --git a/drivers/platform/x86/asus-wmi.c b/drivers/platform/x86/asus-wmi.c index 2ccc23b259d3e..c7c104c65a85a 100644 --- a/drivers/platform/x86/asus-wmi.c +++ b/drivers/platform/x86/asus-wmi.c @@ -3910,6 +3910,7 @@ static int platform_profile_setup(struct asus_wmi *asus) dev_info(dev, "Using throttle_thermal_policy for platform_profile support\n"); + asus->platform_profile_handler.name = "asus-wmi"; asus->platform_profile_handler.profile_get = asus_wmi_platform_profile_get; asus->platform_profile_handler.profile_set = asus_wmi_platform_profile_set; diff --git a/drivers/platform/x86/dell/alienware-wmi.c b/drivers/platform/x86/dell/alienware-wmi.c index a800c28bb4d51..ac0038afd98fa 100644 --- a/drivers/platform/x86/dell/alienware-wmi.c +++ b/drivers/platform/x86/dell/alienware-wmi.c @@ -1056,6 +1056,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 9d8c3f064050e..1f94c14c3b832 100644 --- a/drivers/platform/x86/ideapad-laptop.c +++ b/drivers/platform/x86/ideapad-laptop.c @@ -1102,6 +1102,7 @@ static int ideapad_dytc_profile_init(struct ideapad_private *priv) mutex_init(&priv->dytc->mutex); + priv->dytc->pprof.name = "ideapad-laptop"; priv->dytc->priv = priv; priv->dytc->pprof.profile_get = dytc_profile_get; priv->dytc->pprof.profile_set = dytc_profile_set; diff --git a/drivers/platform/x86/inspur_platform_profile.c b/drivers/platform/x86/inspur_platform_profile.c index 8440defa67886..03da2c8cf6789 100644 --- a/drivers/platform/x86/inspur_platform_profile.c +++ b/drivers/platform/x86/inspur_platform_profile.c @@ -177,6 +177,7 @@ static int inspur_wmi_probe(struct wmi_device *wdev, const void *context) priv->wdev = wdev; dev_set_drvdata(&wdev->dev, priv); + priv->handler.name = "inspur-wmi"; priv->handler.profile_get = inspur_platform_profile_get; priv->handler.profile_set = inspur_platform_profile_set; diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c index 4c1b0553f8720..c8c316b8507a5 100644 --- a/drivers/platform/x86/thinkpad_acpi.c +++ b/drivers/platform/x86/thinkpad_acpi.c @@ -10549,6 +10549,7 @@ static void dytc_profile_refresh(void) } static struct platform_profile_handler dytc_profile = { + .name = "thinkpad-acpi", .profile_get = dytc_profile_get, .profile_set = dytc_profile_set, }; diff --git a/include/linux/platform_profile.h b/include/linux/platform_profile.h index f5492ed413f36..6fa988e417428 100644 --- a/include/linux/platform_profile.h +++ b/include/linux/platform_profile.h @@ -27,6 +27,7 @@ enum platform_profile_option { }; struct platform_profile_handler { + const char *name; unsigned long choices[BITS_TO_LONGS(PLATFORM_PROFILE_LAST)]; int (*profile_get)(struct platform_profile_handler *pprof, enum platform_profile_option *profile); From patchwork Tue Nov 5 15:32:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 13863082 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2050.outbound.protection.outlook.com [40.107.237.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 CD98E13D52E; Tue, 5 Nov 2024 15:33:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.237.50 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730820821; cv=fail; b=rEyV/DJnAQLGjEhJiLk7KMm+rBVfKenofMG6M8q1deA1aXK47fnxrS7ZMw47KZOR6s/evrzdQ+Hc4b6jc81z4mUv2OKW+iisTCjQBCqtM92A8KnCD2KVdRKhkvypII9MvQPOWuox+EJOJZO/sw7CaniOSjQVtssqOmOH51mIyss= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730820821; c=relaxed/simple; bh=Hf4w1lZfBgnE3Sq+P9ER52v4RFaq4g6HvEIEXOsuI1w=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=lkzRPoCxLH32ZssqVJG11BhwQyS59AA4/uyab99vDx0KnXAwRcCKuTaB1AentV56+i/qgsBopQnNgjWEmXObmlqg8mh7a94Eb/hD0YxLCwfl5iX9gfc5kcS735ThXeOblLEAXWWvh50DFcTRlxrSJ4PBAtgisBCefSJ1SdI57BU= 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=lSzG5P+A; arc=fail smtp.client-ip=40.107.237.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="lSzG5P+A" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=AnZ97z9toftLSjMzFRhRic8jbOV3xPW+D3YkRqZxplf5TRph3HvSGXrMsDK5tJupubVt7mGiUMQqOfy5bh29XeyNarF1tEdEYpNyfxuvkiuS4tgmxi8LnT2rBpHYQ4d2bi2dkQUHPIu4t9T6njJ6+pU0X1KqLjTC8amHYjXBmO0DTKdsji7of4hHYErP9qB/WxFWe9taWSXbhWshyrmC0/UcfR0c8Axc3+zIX4icy/UvzO4t+qQRYA9y1evZjYzkOgUXWQGr7FNso8KDeIndqWdA3w10kVmoM7V+uH3fBpt2v6ZX6qqkT7FX4JmWGvxmPPDhaK6hsCLXoScWGTs0Rw== 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=3oVr6vEiyIil7hu0Gy4FhGVYc4++Na2Ht5xVbuuI/U8=; b=pKXJk9+d2YYRLtZtEhd4AZPvnPOwmM9CWsBxMdR3Ti9Pchs2/PezzkaraZ24SAmrDdeMUByJOAGtnleF+PES60Cos5pfUN6VbK1Zh9UADKaUM+aX8UTQw19pDczFjp5QwCWxDZiS7kwAX9FkjPYxkmkpnYm7MUDiVTstS0kYEftilDZx71UfV8ZrsGvKofN4Y1h7qvuEEE/lUzfc+UPwvVOD0ji3cl4TFt9QtG3u9lnFBxCLh41PyQGBmR/YhvvDrxv+5432K0GBjDC7S2eIHzpDW4Iu57d4znUJV46/ag42bRjhIac7lSf7+3SOEHWJEFpaf9BmHoC7JqmRmaVWdQ== 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=3oVr6vEiyIil7hu0Gy4FhGVYc4++Na2Ht5xVbuuI/U8=; b=lSzG5P+AwfGLUsXNFvo0VeAgma+URK7QpslxSfxQni3cmMAVuyTnKK50944i770lj0P1s6/AcwkJb6x5aTEgyqpoJxnP+vMCq+OiQaJh6FTFBI1lq0FCKNxVxKLeozBxxps13uByNSsmmTst1NlRo2VMw38ZT/OmDSEtda6F3T4= Received: from MN0PR04CA0018.namprd04.prod.outlook.com (2603:10b6:208:52d::11) by SA1PR12MB8723.namprd12.prod.outlook.com (2603:10b6:806:385::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8137.18; Tue, 5 Nov 2024 15:33:34 +0000 Received: from BN2PEPF000055DF.namprd21.prod.outlook.com (2603:10b6:208:52d:cafe::1b) by MN0PR04CA0018.outlook.office365.com (2603:10b6:208:52d::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8137.18 via Frontend Transport; Tue, 5 Nov 2024 15:33: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 BN2PEPF000055DF.mail.protection.outlook.com (10.167.245.9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8158.0 via Frontend Transport; Tue, 5 Nov 2024 15:33: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; Tue, 5 Nov 2024 09:33: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 Subject: [PATCH v4 02/20] platform/x86/dell: dell-pc: Create platform device Date: Tue, 5 Nov 2024 09:32:58 -0600 Message-ID: <20241105153316.378-3-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241105153316.378-1-mario.limonciello@amd.com> References: <20241105153316.378-1-mario.limonciello@amd.com> Precedence: bulk X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN2PEPF000055DF:EE_|SA1PR12MB8723:EE_ X-MS-Office365-Filtering-Correlation-Id: dd4a8b8a-9d99-47b2-3b15-08dcfdaf3571 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700013|7416014|376014|1800799024|82310400026; X-Microsoft-Antispam-Message-Info: =?utf-8?q?CE5KkEPfZoTRfusjwOouQLpQq8roFpC?= =?utf-8?q?d09jRnQyOdn3uz0lsyDnntB7bOMx59B1SVXY306daYbfHvYeNSUH5Oq9uXA/xtb3z?= =?utf-8?q?XRrqSLq5Uh2YJ/qTSUY2/O0/K7+c9PfNlZbQwCJpgHqFqWoEsmX005xMceYmrJkLQ?= =?utf-8?q?pq3CtvSmCX8Rn+jkl893PzMyJ5+E6VvDpYuigU5dZFzsQtuyrFXoz2XMnH0fhePgP?= =?utf-8?q?ajczyIf0Md6ZjMvwYjucda+Rzyo41U4nyPIpg4+/x5V7ziyB/EluRnMJO5c/P1evP?= =?utf-8?q?V4RmB85OGXPfXkONwQ+XVtuGTbXhQtHnliq2rQ4w8PxjgFtAl8X2tJ+yvBnO6NTfP?= =?utf-8?q?zl0ARlltb3kboEGAoXT9yrD3psK5Tx3rMMJBzMt9Fhi1eySaureY1QiioriXdVfW2?= =?utf-8?q?DJ1jPGV9uctOBBfrsO6vQXOFByD0d1y+XZztEbTk99ZI4wBg2fMyX7T4xPtM/cKQM?= =?utf-8?q?L0oCIQkcwcCCr0qrgHQnFvLQdWoRPdp62q8e3GwVsGBO7kGm7zwI0jH5I1aosOEgX?= =?utf-8?q?VawgkqJm7UwF0vIIyyL/37f/ejzvCWWL0RsntYpV+e2+hE64MRGcG39n41gjyt1XP?= =?utf-8?q?FbU1SulSeyWqHJPG+ZlDGhJnlemrJA//T3sRGh7CKX34uY5WbncM68pjv83mIxN6j?= =?utf-8?q?VLr5YxbQRj1YQHvYwK4vgH5Ox3sV9jhmORRJxX70DGnllfZu3wjTojy2DB4sqOU/E?= =?utf-8?q?cioK0YVfBQtA6kfVXIPI42EYCpJSCLbkiO6g/rq2gPSxl6N1v6SNHhMUj1iV0lVI2?= =?utf-8?q?xyh0f1RZlebubOgVbCCiHBML6MrLsa9viSFp8aRmuA1h3bFN0mk50yXwiMqqFX9ju?= =?utf-8?q?74yn9MR4InifOon4TaiLI03oFfKsOYaBft614LmgZRyoZWKO20CZlR/j1gz8A1Qyk?= =?utf-8?q?JTunicbyUHRwvOQ/B2+X57FRx5QTuI1Tb9OU0rMFr7vejaNFr+B+QByHSezeg2qH0?= =?utf-8?q?iV33Vv5KPo6nEVOHkwLTmhsphYTJXHCJVbW70JERbzuxbkJq7ph8d15IVG5c1frS8?= =?utf-8?q?Y0YlgN2VC/kYI0cFRgvYF0WdeWtgn2+cBFLxbFc+gi/tixMLBddL+4fWsfAzjfUga?= =?utf-8?q?xGkA1Jx2Zf84qp0Tc1fkrmI07W5WhnQNLIMjBVmSX8u2+rOH5zt7QzwQCrd+fFmJk?= =?utf-8?q?+NC3ExPeqsoXv0x0SwdRMaeBsWbZcNWIBGztOLKIomrATXaIZHgCFICz4RNmfS2m8?= =?utf-8?q?wGcv8WRO8rD08sqd+NLJq7Q4BerHQTJHyJFOvL9CQ/FHm7OZguICfoKk39HpxcgWC?= =?utf-8?q?rgYUMydoYfuFj1FJprqS2WrDFe3qiQDs6gQpyG5kL6tbmPtF/iCnIlElzj1YHKdGE?= =?utf-8?q?cl0f+wTSgawsSPRMTIbDmFbjdI9dCfsm9g=3D=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)(36860700013)(7416014)(376014)(1800799024)(82310400026);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Nov 2024 15:33:33.6703 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: dd4a8b8a-9d99-47b2-3b15-08dcfdaf3571 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: BN2PEPF000055DF.namprd21.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR12MB8723 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: Ilpo Järvinen Signed-off-by: Mario Limonciello Reviewed-by: Armin Wolf --- drivers/platform/x86/dell/dell-pc.c | 35 +++++++++++++++++++++-------- 1 file changed, 26 insertions(+), 9 deletions(-) diff --git a/drivers/platform/x86/dell/dell-pc.c b/drivers/platform/x86/dell/dell-pc.c index 3cf79e55e3129..b145fedb6b710 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,18 @@ static int thermal_init(void) if (!supported_modes) return 0; - thermal_handler = kzalloc(sizeof(*thermal_handler), GFP_KERNEL); - if (!thermal_handler) + platform_device = platform_device_alloc("dell-pc", PLATFORM_DEVID_NONE); + if (!platform_device) return -ENOMEM; + ret = platform_device_add(platform_device); + if (ret) + goto cleanup_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 +274,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_del(platform_device); return ret; } static void thermal_cleanup(void) { - if (thermal_handler) { + if (thermal_handler) platform_profile_remove(); - kfree(thermal_handler); - } + platform_device_unregister(platform_device); } static int __init dell_init(void) From patchwork Tue Nov 5 15:32:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 13863081 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2075.outbound.protection.outlook.com [40.107.93.75]) (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 4BDE113CFA8; Tue, 5 Nov 2024 15:33:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.93.75 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730820821; cv=fail; b=qTjl38XTnLOGRaLQhcBU+9whaoFTTC4xdNMOWM9EiSG9+8qdNLUKL2BPv4DNI8Hjs69i7+WIjb2xnguPhgEvLf3ytRpATwRFiMc4WvsvOibfQUSKVg4emm2ynVJUjy1uYI9TMVyqWWKyP6u0fF5R7zDTewPNLrFXDBLfTQIlX7o= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730820821; c=relaxed/simple; bh=BmMR1Enibk1nJMvtTQUaBjCmHf+VJwF7HpJDuAA3Jlw=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=ZEPrmFwcL9BVH1PJVWCErTejLBwr/1Uo4BhB4yb5+0/4z7HlJH7fTaEG1Zpkx1XOO6QxW9sQqoB4hYQcmBx2GEq7HLMPyp34Dt/ITjk6CYycF9lVC3xLSnzgBXY4QiPyxUpp3pmzVoQyJ2HkZzeeOdA6HemSZwdf/iy9WBVroWY= 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=M5ei7LHA; arc=fail smtp.client-ip=40.107.93.75 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="M5ei7LHA" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=YqI+pM5pn1PG/rhAAFr6E/IqIfGui+kVaJMbsAzOGOETYw+LcolTOXHwSwTPOuiWomNFQk+O17zBZcrBqXnmHwUeNjPvjMYYipWOXik950k3HUrOlNLGhWs7TO2wXFZ4n3ar1Co5ec5OMRwFRu6C2lu0iG3vWCJk1nscWpfe/gQkVt7buTiyKTXZFPYc7B1aOVm6kb4VGeaJDAn9Qkh20M2q+iG1hn43cQ/g1Iw2bIJ5Z1VbVZK0Ra0g44N92zF3AXakxTH8CDM/e2K3FwN8SJ3OvQbBp3yMrAWNBoGTH2Cj1X4lHsE/m4NDN8JTEdQN3IMgQacd39JmqqW3o93piA== 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=akdffAgsWFY5qLva447baJQ/DW+tvIatLdlKwEunKCY=; b=y81DnYwytWgjirJ6RpCycPOrjp+BBvT38hRhMg0qZ8splRdcRTq4xsz3vb4i97HiKzruvTbIvb4LPpmGO0Zxo8Sr9A1xtLSjvhtTmR00TSaveII7qqNIsjFuOWNPc7+UZVJjqULRQ+PCY4yWQ1mjekHSp7kwsw4F9TJV4DTKDzrA9RbSY1Zap77vwEe7Usg/KHk6H93WHjnAiHko2IC0kWNnnC0Q6CADkLzGGORUO943ajuWiviyMYHvAOaZnwFd0+I0qhySVs06Ml8ZIcfyMWqlmOUD4LuFmY5kDvbmHwqQ2OKYIsuQdTghX6gyYoV4iZnCw0y8IaKpIEhXRxrBTQ== 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=akdffAgsWFY5qLva447baJQ/DW+tvIatLdlKwEunKCY=; b=M5ei7LHA7hvRIiAPedggKuKO8ZKaTTX7pVAaPrub78BN9n566tlDAr6tR2jaA9chWup6lrErzJG+r2uOVbFlJEx9lHCBN/bqvVsfARVyn5buKysRjr1bjZuLcK1gGggXbWFH2SCDaHUPHqO0IoWbVJ7As5L9bJGd2csOOzoFFK4= Received: from MN0PR04CA0007.namprd04.prod.outlook.com (2603:10b6:208:52d::12) by SJ2PR12MB8928.namprd12.prod.outlook.com (2603:10b6:a03:53e::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.30; Tue, 5 Nov 2024 15:33:36 +0000 Received: from BN2PEPF000055DF.namprd21.prod.outlook.com (2603:10b6:208:52d:cafe::7c) by MN0PR04CA0007.outlook.office365.com (2603:10b6:208:52d::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.31 via Frontend Transport; Tue, 5 Nov 2024 15:33: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 BN2PEPF000055DF.mail.protection.outlook.com (10.167.245.9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8158.0 via Frontend Transport; Tue, 5 Nov 2024 15:33: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; Tue, 5 Nov 2024 09:33: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 Subject: [PATCH v4 03/20] ACPI: platform_profile: Add device pointer into platform profile handler Date: Tue, 5 Nov 2024 09:32:59 -0600 Message-ID: <20241105153316.378-4-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241105153316.378-1-mario.limonciello@amd.com> References: <20241105153316.378-1-mario.limonciello@amd.com> Precedence: bulk X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN2PEPF000055DF:EE_|SJ2PR12MB8928:EE_ X-MS-Office365-Filtering-Correlation-Id: 6fc0725a-8d2b-466e-53b2-08dcfdaf36ae X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|376014|82310400026|36860700013|1800799024; X-Microsoft-Antispam-Message-Info: =?utf-8?q?/s3Fef4XRm9xc6A16vmbqsE8G2cJHQZ?= =?utf-8?q?ihsOk0ZmADIlOaIvGvUAyc+tvBXr3QOAtE4MdrGwFH6NtxM0U9rFJ+I3DEQmLUDv3?= =?utf-8?q?6oLm/PzmcPE61bEhwyLvByqCKgvu+z47Y+4r++ChOoKe3JosT+STTJuaJ4jOOYnoJ?= =?utf-8?q?wsa2TajK1TtBOUcmV4RhPjGwj+3DfR1IrBOzFlCnZWdLbgPJoMcc/rsKI0I2pzdq/?= =?utf-8?q?jhiYlIaPlJ5XUuR7oL5aRWl8bHzf9cg/hr9McnMFm3sE1tDI3/VHxFKlGLlK0Vunx?= =?utf-8?q?z8XuvGcvPJZfnAB+MUtjxdtWZCNlLlGMvQjC9DCYM1vHLqqn0H3/UCkeADDcvLR7C?= =?utf-8?q?TBN9vI9i8L9i3JNiK4FtNR5gR8dXga2UYDXi2i8/0i8Dir67zEtA1z2sHp4eVW12q?= =?utf-8?q?QBJHRP221tzurE5wEWkwe3QnCGdNDSz5ZBzv7YTmcDVRN9lppF7ZLZJwF3KC39gK1?= =?utf-8?q?QyLQSEfezvvulDFF7ZZdlAQ4ep3mLi1OrVYhcQgm4c1WgOYwan6j3tuM1UQw/Ccme?= =?utf-8?q?fS2mMkZrg4x4jb+mALC7YYRtkF053IUVTSQOeUhG0nxXZogvAo2stXy3o+Ipt7Hlu?= =?utf-8?q?s/qnpcKZNZepI6mssXvnmfFpKF9OFpz65k+CKqxXC4xqMRizP8WEPXkKmNNNlThvh?= =?utf-8?q?T2/SdU0pGyiP6Pj9Qng8dFjZVAiJ1zVORUhynewwC57pqOv7aegrKQTY3LFGQd1Wg?= =?utf-8?q?6GXQMEz98H0lrh4FW4x1w3a/tfm3EByPjPghBMPG8ja5BMXP1jsoQpBZgPKs1+AFi?= =?utf-8?q?s+UeYJDEsAYkk+otY8NkJwyC6SMsZ/cCwS8z4ACiqO3/nniE/wM6LoB++Cc3c4wb+?= =?utf-8?q?Tr8Is1zjK37E1AydFy5sVzzE7zY8JxgGj8jE1aO6W2dDmVHuj7pRtDKjjpkNfKJ9j?= =?utf-8?q?t2u7CVhbQuhOyWS6SmE3Xu/ogEhVimh+AF4T/r5lzffFme03eHoB9LU4mpmx5BUaH?= =?utf-8?q?Cw6/HM4Mxoamfuq4BIOE7TAxfj8IeivHbIMAx4ShXbrtcVeTN2yHzrvevd02V9YML?= =?utf-8?q?2QP3cTPcGg65WUrw9/EUmLf737+d5ugEi9TPnw1TRpLzGINcV4o1j0ex80EplKSpK?= =?utf-8?q?A6SrPF7X8OT8/qE3K3/K8l/mlEcV+hZnkGbfLTPQbcTTqKwMbBIZnLtMHnBNphjun?= =?utf-8?q?/Zj1JxWAl39Axpggr+Gvcw+sFvKKm1kjwqc4ekzcRGTg6m9diCSeZda/+Wy+fUBnI?= =?utf-8?q?gbjAbLOXnH8q9Nfu+X6mVgLm99no7X0WI75UbWsbSGP74ZLDBW0fTVaoglNCMNKgR?= =?utf-8?q?58/K2WCyONYufN+hjUDYGCk8blhERLgN+Le1wkE/z0A0+JqhiWcLl22qwCaHBDUVR?= =?utf-8?q?KNBlCxyGSSMvRpdAzXG7tG1rXLsLpSaKkQ=3D=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)(7416014)(376014)(82310400026)(36860700013)(1800799024);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Nov 2024 15:33:35.7641 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 6fc0725a-8d2b-466e-53b2-08dcfdaf36ae 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: BN2PEPF000055DF.namprd21.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ2PR12MB8928 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: Ilpo Järvinen Reviewed-by: Maximilian Luz Reviewed-by: Mark Pearson Signed-off-by: Mario Limonciello --- v4: * add alienware-wmi too --- drivers/acpi/platform_profile.c | 5 +++++ 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 + 12 files changed, 22 insertions(+), 6 deletions(-) diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profile.c index d2f7fd7743a13..5d9f3f7ba71c5 100644 --- a/drivers/acpi/platform_profile.c +++ b/drivers/acpi/platform_profile.c @@ -179,6 +179,11 @@ int platform_profile_register(struct platform_profile_handler *pprof) { int err; + if (!pprof->dev) { + pr_err("platform_profile: handler device is not set\n"); + return -EINVAL; + } + mutex_lock(&profile_lock); /* We can only have one active profile */ if (cur_profile) { diff --git a/drivers/platform/surface/surface_platform_profile.c b/drivers/platform/surface/surface_platform_profile.c index 61aa488a80eb5..5f45f8e8cd69b 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 c7c104c65a85a..78621b2af0ddb 100644 --- a/drivers/platform/x86/asus-wmi.c +++ b/drivers/platform/x86/asus-wmi.c @@ -3911,6 +3911,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 ac0038afd98fa..c03b1aa7dfb5f 100644 --- a/drivers/platform/x86/dell/alienware-wmi.c +++ b/drivers/platform/x86/dell/alienware-wmi.c @@ -1017,7 +1017,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; enum wmax_thermal_mode mode; @@ -1057,6 +1057,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); } @@ -1125,7 +1126,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 b145fedb6b710..730f97aab70cd 100644 --- a/drivers/platform/x86/dell/dell-pc.c +++ b/drivers/platform/x86/dell/dell-pc.c @@ -260,6 +260,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 1f94c14c3b832..24367c3590c99 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 c8c316b8507a5..222fba97d79a7 100644 --- a/drivers/platform/x86/thinkpad_acpi.c +++ b/drivers/platform/x86/thinkpad_acpi.c @@ -10616,6 +10616,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 Tue Nov 5 15:33:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 13863085 Received: from NAM04-BN8-obe.outbound.protection.outlook.com (mail-bn8nam04on2075.outbound.protection.outlook.com [40.107.100.75]) (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 5C7DA7346D; Tue, 5 Nov 2024 15:33:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.100.75 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730820824; cv=fail; b=udpt4MiDg50q9RylHAYyufo6jfW1sbNK8NSjGs8NbTs348ejwn6M22I1ZMNZdYAlJuk2JL1KtMI4vtaXaq5iQyAX2JFeyBy4YKafGzZJky0LbX0AdXyOi+jUyopUnjkGGCWfHIKSpiozBhlLaub7gBcjXWM5IfLnKo4stJFQpKk= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730820824; c=relaxed/simple; bh=xE8tgTFhgfeuOgCsUZhC1WiaGITJjtf48n9pdqNlCns=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Qb3iL9FaPXPfQ4jC8eg7XwhlVFrloXq8XXLeicc05kB/8MR36nicKflcXoT7HN97oCmR039rgDkIZbinBznHViYxyHxsjUCP/c4Iod11JRWXqrJ//S/Ave8obAOt5hElyJZpvRXPp+DaBewVJPo5cM2TqlN87ARrCC/KmZvaJS4= 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=I3BSPjCc; arc=fail smtp.client-ip=40.107.100.75 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="I3BSPjCc" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=LbJ/Oj84acB7SjgYeFKlO8rWu/DAGuxvfJ1GUdBf9A1G+xpbyWFhiFAvCrIGA3DYWglb8O3v14zLTo0jRrQEXcO4/y+CHW72I3sKCfLk0aOxtltZT93r+tsx5UXQNL2Px04R/0qkdwkDG8nbXDWqo8tA4m3wy+Eeo+TCW8ApzeSe4Unu3NiRQfDXmsVm+kjDRPsi649sGTbOnWANgbKw16sEJ8vIPUv835S20+Uz7QRA8vADhBKz8yzwVKx+M5ITW1jeiCQX6K/afk6Y2QJr9ZkRn7Bo/6Y/nQ3x1VpTafBSL4nwG5KESvVqxL1fqXmV45VJnqmcW9sUtArgOC/BSg== 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=CpP+8+J+86qUK9POCB3KSfm3Zjzt6p92edc6CL2tMVE=; b=N4c7Gu4Nfu2ReE1kIpJehcy3HMgIMRwb6ThlgLsy3YRhhUVdOqTR1Rw5eJMTlY5szf162KXq/CGC23zq3/+xDjgeQa5y1/nUhYksJ9jyZrmfXUEzZwerouhLAb2TVPtgbyMB+jie1M+nrXJysUEbs6qPdLOZA3TYWMIF6++dCQNYu3+R5cF6KhHQqKlAtkBfuzBC+scYxU9QiAHuj+bWDM2NYfRxb8mKUJ22h3bngM2Sma6OImZ1gx2XOusjaidUi0HrVySCv5VNZWEF8lU0BVOl3jkRWM8h8bxjmvUW498DlygGIiiU5N+ybJ92E5FuZJkFktVikYh8gS5Bt8zYSQ== 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=CpP+8+J+86qUK9POCB3KSfm3Zjzt6p92edc6CL2tMVE=; b=I3BSPjCcjAcZc+eSXYPJkARwTfGuFLEtIBx6QdbzzWdTc4jjZWgqfQEPrS5zyJStcPcEU2x4Ex1PMSxkNZjs6IjvDwev/dAIk/EqZjlVQrKawi3e7PkOrR4YsxQs1HJFmDO0mR8LNItiztdmq2lWMkg233akDb3TLR61393GOo0= Received: from MN0PR04CA0008.namprd04.prod.outlook.com (2603:10b6:208:52d::22) by DM4PR12MB6448.namprd12.prod.outlook.com (2603:10b6:8:8a::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.29; Tue, 5 Nov 2024 15:33:36 +0000 Received: from BN2PEPF000055DF.namprd21.prod.outlook.com (2603:10b6:208:52d:cafe::40) by MN0PR04CA0008.outlook.office365.com (2603:10b6:208:52d::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.31 via Frontend Transport; Tue, 5 Nov 2024 15:33:36 +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 BN2PEPF000055DF.mail.protection.outlook.com (10.167.245.9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8158.0 via Frontend Transport; Tue, 5 Nov 2024 15:33:36 +0000 Received: from AUS-P9-MLIMONCI.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Tue, 5 Nov 2024 09:33:32 -0600 From: Mario Limonciello To: Hans de Goede , =?utf-8?q?Ilpo_J=C3=A4rvinen?= CC: "Rafael J . Wysocki" , Len Brown , Maximilian Luz , Lee Chun-Yi , "Shyam Sundar S K" , Corentin Chary , "Luke D . Jones" , Ike Panhc , Henrique de Moraes Holschuh , "Alexis Belmonte" , =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= , Ai Chao , Gergo Koteles , open list , "open list:ACPI" , "open list:MICROSOFT SURFACE PLATFORM PROFILE DRIVER" , "open list:THINKPAD ACPI EXTRAS DRIVER" , Mark Pearson , Matthew Schwartz , Mario Limonciello Subject: [PATCH v4 04/20] ACPI: platform_profile: Add platform handler argument to platform_profile_remove() Date: Tue, 5 Nov 2024 09:33:00 -0600 Message-ID: <20241105153316.378-5-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241105153316.378-1-mario.limonciello@amd.com> References: <20241105153316.378-1-mario.limonciello@amd.com> Precedence: bulk X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN2PEPF000055DF:EE_|DM4PR12MB6448:EE_ X-MS-Office365-Filtering-Correlation-Id: cce979da-cd70-45f5-c49c-08dcfdaf3720 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|1800799024|376014|82310400026|36860700013; X-Microsoft-Antispam-Message-Info: =?utf-8?q?FxmctzE1t88Y4GdpGZg3i6iYQp0OaZ5?= =?utf-8?q?fus3+YMicAY2jhnehyCzunG0qhak9l5y4Xo8UMc1sHKXeBuGSQhD/XAA1Lar1LcOS?= =?utf-8?q?SQden2a/NRhWKp18hcnlXuyzZ6KVxjfwVOkW4kfd+BxEiXhFY1fVKWK+BbnSwmOZw?= =?utf-8?q?Z1yIInD2w07TFoUU+8cV/vfTGMn3B4OZBLaQKek8e1qO4yp+pfoB3dLGGV9rPBGf4?= =?utf-8?q?nwnsLkXuYFLPOCD0u2EcF4bDmerPfZesdNz50X2XRwlRVkTsRXpjye2LRgPCQw44T?= =?utf-8?q?SvR9n7odpJUyzm6kWDvpoHRYmo7KEnv2C7oJgy/TgdVE3ygDb54QbnJxvIy2sFQbq?= =?utf-8?q?rmeXucDyeEr0/+OQmyPBE5WHgu39UlAr/SXMGMIogoSoibxIRwB+sm6RRlPkc4PpS?= =?utf-8?q?mHbqHYB2S2Oartvz8GYTQVtitpARgBaUGxzZDaR419DjjnJxd6abduhNep6xPGQYZ?= =?utf-8?q?709r2wYFSRbho/zVFqkzwlkVnpJAWzeglZKngg9RBM3Y6DUh4niJt3Csg1kMYjIP9?= =?utf-8?q?nJCYcM64rAgT3JeWy/o7V1YwU0tRvOW7UOUqzOzLgJb+wWJRhbhsL+Z2GchxDk+7K?= =?utf-8?q?ETxkvRvFNkzIoXKBtR//sQ4yg4y3YRYL2RdTwKwewfLrVxeWTdBss/G/dlX5oEJ3g?= =?utf-8?q?z0wp0VJv4q/OffASHcS+/aj7TBAQiC4GZGWgdCpv7C01J5XSyxTTqewiUJUNentxp?= =?utf-8?q?GcH5bQqEIIYIagF28D4mu1Bfw57M7I3jJFjEWR2IPuoVTJ64hmjaFD/wthqBHAn4L?= =?utf-8?q?yJ7jdZnwKJz6Tu0P17VSdj6l8KadoxCdZqV/Bi35hArnYeWTZ2zKIDxsbrM9nnpHX?= =?utf-8?q?mVxMjGG+YxM6lyy///hijTpxwfsS2VxK+w93yj7saSxm6AwpPFSSm3FhY+H8wz+1z?= =?utf-8?q?LWvIBuerZWLIi5QoZqQVfSm4RbCChS5bT/x++z31AcA1aZo0ee92r5uGHbbkWASJH?= =?utf-8?q?tO+pjFPGOmoGFSdaK2/g7SLa58dLFF4A7pRTxS8MndlVYSKVSxGSJp+b8OxQg05KN?= =?utf-8?q?VaNsPz8ZmsrznILkMhWUKCHIXeJE3k0lMAAko3Hqgki+Vd6aQ8rRHUbq2xtfhmZaA?= =?utf-8?q?E25CrsK9+dD78yd1SUkg7KFGqvI9MIJQJIABRapzFjzT+Elj2s6YExSfIlotbUzns?= =?utf-8?q?Y2p8b0WjJqZLs18F+X7gRTsxX097F9yZIIWyENrvFSlcAxOi/zlT3nleT8Nshcx7I?= =?utf-8?q?NJzsLeJOCC5WLOAgJHz1tvAVIamkRsbpe1ZQqe24BDjYuT63Wsd05UYFpCH918QxQ?= =?utf-8?q?/biE4FaHrx3O7z8tVbL1kb30CdRa9r0E00nf6d2LF0vh4BQ3ICEWE+t0ZJ+0bQJzu?= =?utf-8?q?w48R9216lRYQl6tsYhcLd9G/+AhPrFbCmg=3D=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)(7416014)(1800799024)(376014)(82310400026)(36860700013);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Nov 2024 15:33:36.5141 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: cce979da-cd70-45f5-c49c-08dcfdaf3720 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: BN2PEPF000055DF.namprd21.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB6448 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: Matthew Schwartz Reviewed-by: Hans de Goede Reviewed-by: Mark Pearson Reviewed-by: Maximilian Luz Reviewed-by: Ilpo Järvinen Signed-off-by: Mario Limonciello Reviewed-by: Armin Wolf --- v4: * Add alienware-wmi too --- drivers/acpi/platform_profile.c | 2 +- drivers/platform/surface/surface_platform_profile.c | 6 +++++- drivers/platform/x86/acer-wmi.c | 4 ++-- drivers/platform/x86/amd/pmf/sps.c | 2 +- drivers/platform/x86/asus-wmi.c | 4 ++-- drivers/platform/x86/dell/alienware-wmi.c | 2 +- drivers/platform/x86/dell/dell-pc.c | 2 +- drivers/platform/x86/hp/hp-wmi.c | 2 +- drivers/platform/x86/ideapad-laptop.c | 2 +- drivers/platform/x86/inspur_platform_profile.c | 5 ++++- drivers/platform/x86/thinkpad_acpi.c | 2 +- include/linux/platform_profile.h | 2 +- 12 files changed, 21 insertions(+), 14 deletions(-) diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profile.c index 5d9f3f7ba71c5..c76b8e3fdcde6 100644 --- a/drivers/acpi/platform_profile.c +++ b/drivers/acpi/platform_profile.c @@ -210,7 +210,7 @@ int platform_profile_register(struct platform_profile_handler *pprof) } EXPORT_SYMBOL_GPL(platform_profile_register); -int platform_profile_remove(void) +int platform_profile_remove(struct platform_profile_handler *pprof) { sysfs_remove_group(acpi_kobj, &platform_profile_group); diff --git a/drivers/platform/surface/surface_platform_profile.c b/drivers/platform/surface/surface_platform_profile.c index 5f45f8e8cd69b..b449c4c8b883c 100644 --- a/drivers/platform/surface/surface_platform_profile.c +++ b/drivers/platform/surface/surface_platform_profile.c @@ -210,6 +210,7 @@ static int surface_platform_profile_probe(struct ssam_device *sdev) return -ENOMEM; tpd->sdev = sdev; + ssam_device_set_drvdata(sdev, tpd); tpd->handler.name = "Surface Platform Profile"; tpd->handler.dev = &sdev->dev; @@ -228,7 +229,10 @@ static int surface_platform_profile_probe(struct ssam_device *sdev) static void surface_platform_profile_remove(struct ssam_device *sdev) { - platform_profile_remove(); + struct ssam_platform_profile_device *tpd; + + tpd = ssam_device_get_drvdata(sdev); + platform_profile_remove(&tpd->handler); } static const struct ssam_device_id ssam_platform_profile_match[] = { diff --git a/drivers/platform/x86/acer-wmi.c b/drivers/platform/x86/acer-wmi.c index aca4a5746bee1..b12965d9fcdb7 100644 --- a/drivers/platform/x86/acer-wmi.c +++ b/drivers/platform/x86/acer-wmi.c @@ -2547,7 +2547,7 @@ static int acer_platform_probe(struct platform_device *device) error_hwmon: if (platform_profile_support) - platform_profile_remove(); + platform_profile_remove(&platform_profile_handler); error_platform_profile: acer_rfkill_exit(); error_rfkill: @@ -2570,7 +2570,7 @@ static void acer_platform_remove(struct platform_device *device) acer_rfkill_exit(); if (platform_profile_support) - platform_profile_remove(); + platform_profile_remove(&platform_profile_handler); } #ifdef CONFIG_PM_SLEEP diff --git a/drivers/platform/x86/amd/pmf/sps.c b/drivers/platform/x86/amd/pmf/sps.c index 1b94af7c0e0c4..bd2bd6cfc39a0 100644 --- a/drivers/platform/x86/amd/pmf/sps.c +++ b/drivers/platform/x86/amd/pmf/sps.c @@ -426,5 +426,5 @@ int amd_pmf_init_sps(struct amd_pmf_dev *dev) void amd_pmf_deinit_sps(struct amd_pmf_dev *dev) { - platform_profile_remove(); + platform_profile_remove(&dev->pprof); } diff --git a/drivers/platform/x86/asus-wmi.c b/drivers/platform/x86/asus-wmi.c index 78621b2af0ddb..0750e2fe65325 100644 --- a/drivers/platform/x86/asus-wmi.c +++ b/drivers/platform/x86/asus-wmi.c @@ -4886,7 +4886,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); @@ -4913,7 +4913,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 c03b1aa7dfb5f..3cf6c371d4220 100644 --- a/drivers/platform/x86/dell/alienware-wmi.c +++ b/drivers/platform/x86/dell/alienware-wmi.c @@ -1065,7 +1065,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 730f97aab70cd..65989af2e4196 100644 --- a/drivers/platform/x86/dell/dell-pc.c +++ b/drivers/platform/x86/dell/dell-pc.c @@ -292,7 +292,7 @@ static int thermal_init(void) static void thermal_cleanup(void) { if (thermal_handler) - platform_profile_remove(); + platform_profile_remove(thermal_handler); platform_device_unregister(platform_device); } diff --git a/drivers/platform/x86/hp/hp-wmi.c b/drivers/platform/x86/hp/hp-wmi.c index ffb09799142bc..6d6e13a0c6e2d 100644 --- a/drivers/platform/x86/hp/hp-wmi.c +++ b/drivers/platform/x86/hp/hp-wmi.c @@ -1693,7 +1693,7 @@ static void __exit hp_wmi_bios_remove(struct platform_device *device) } if (platform_profile_support) - platform_profile_remove(); + platform_profile_remove(&platform_profile_handler); } static int hp_wmi_resume_handler(struct device *device) diff --git a/drivers/platform/x86/ideapad-laptop.c b/drivers/platform/x86/ideapad-laptop.c index 24367c3590c99..80797c6ae8b0b 100644 --- a/drivers/platform/x86/ideapad-laptop.c +++ b/drivers/platform/x86/ideapad-laptop.c @@ -1136,7 +1136,7 @@ static void ideapad_dytc_profile_exit(struct ideapad_private *priv) if (!priv->dytc) return; - platform_profile_remove(); + platform_profile_remove(&priv->dytc->pprof); mutex_destroy(&priv->dytc->mutex); kfree(priv->dytc); diff --git a/drivers/platform/x86/inspur_platform_profile.c b/drivers/platform/x86/inspur_platform_profile.c index 5a53949bbbf5f..53af73a7fbf7b 100644 --- a/drivers/platform/x86/inspur_platform_profile.c +++ b/drivers/platform/x86/inspur_platform_profile.c @@ -191,7 +191,10 @@ static int inspur_wmi_probe(struct wmi_device *wdev, const void *context) static void inspur_wmi_remove(struct wmi_device *wdev) { - platform_profile_remove(); + struct inspur_wmi_priv *priv; + + priv = dev_get_drvdata(&wdev->dev); + platform_profile_remove(&priv->handler); } static const struct wmi_device_id inspur_wmi_id_table[] = { diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c index 222fba97d79a7..13798c6d5fcf3 100644 --- a/drivers/platform/x86/thinkpad_acpi.c +++ b/drivers/platform/x86/thinkpad_acpi.c @@ -10638,7 +10638,7 @@ static int tpacpi_dytc_profile_init(struct ibm_init_struct *iibm) static void dytc_profile_exit(void) { - platform_profile_remove(); + platform_profile_remove(&dytc_profile); } static struct ibm_struct dytc_profile_driver_data = { diff --git a/include/linux/platform_profile.h b/include/linux/platform_profile.h index daec6b9bad81f..bcaf3aa39160f 100644 --- a/include/linux/platform_profile.h +++ b/include/linux/platform_profile.h @@ -37,7 +37,7 @@ struct platform_profile_handler { }; int platform_profile_register(struct platform_profile_handler *pprof); -int platform_profile_remove(void); +int platform_profile_remove(struct platform_profile_handler *pprof); int platform_profile_cycle(void); void platform_profile_notify(void); From patchwork Tue Nov 5 15:33:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 13863083 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2043.outbound.protection.outlook.com [40.107.94.43]) (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 62FF0146013; Tue, 5 Nov 2024 15:33:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.94.43 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730820823; cv=fail; b=roODfQo6V/LBWMWGviPV5yIYAZcLa7x9D/4Da9Q4dRiNgM+UR4zZPejR0xrYPfmeIpnznKWTappgezQK11i5++WBEXwyN1XeKDYChlm9jxXa7S8KHDalmocK6muiyejM4XmPbyHCJdPlPAazCk16PjMpfHV8p6tDDFHDEFhFC+M= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730820823; c=relaxed/simple; bh=coqx1ADwMrtXqO17eBAIJiGtY0S3w4Hi1a9kzpKViqo=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=ZIbnnMysoFNQrP8xktuYpy58m7elMZde3iLYqnhR6YXHottRhwhxUERKgWogzZ/BrcK7zsKprb58zNIzNw89SSxy91TiGqDaBiNt7ijJbTNaDhwJrT7bMZdrZ/zYpNEkL1TGSa11nyg5XuGRMCbHyDCWZav9m7AeLIYk6UK1oIs= 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=uxuHjSst; arc=fail smtp.client-ip=40.107.94.43 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="uxuHjSst" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=tUV+yMW+v50dewUWpC6Z7HviLSDYEMVy64xTuOkqXfPM3gWbI8Eb4Hy/61hA7jbvZflYfGwEM93nK6ffUpZ3vbTxSjqWVv/AOufSqjIYynosOUzrdQsR6vcRWbknjmq3gNOuzNZO2JAXRoIzrxzCGozAzlGcl52FeXD7xdjxlg9cbhF3FN0vWfNzWmAsOLvv4i55UdzbKcX17pNBRRg2Fu97bvdl4kCoOXlJawDncFejtTJwoDoVjUaFkNlaqZo92L/SMkFQs0Qmcugs6yNOJ5DIwUqDqIS5FW8nXj0byRpbsKoaEpqNhuOd2O3VZKORxe88DPMDnT1wEw5EqjryiQ== 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=NgdRMEm5b7ecUIgJRgBzczX2TCGPfumhFWdIRNlizFc=; b=zW6zxLHRPaEowdqX1idz2imKqkiKr2lwpAT/0KjYQNy+RAFJVUv2UODqnMdNetFzURkHlJegfoafHUmUb892kgoALUTqKR4lzTUl5UKZTn4esie7ETYRcbYgnO4xD7Y1ANaBo5QGIeXklvuOHzTj65Xbyv/O9106MzF0NOs8O2lUkM4OtNV+3Ha8RwAL6+GqjMc+FLj6lMaVo+t1tXw92BiITnCcr7W+kbRmfJ3G4j3jS2su7L05UZyel/w+NVLnF9xcL3eFHPQxY4u7ix2sEmn3EsEOmp7XZNg08ZL/rBC60pqFKxwxRqIIZmkrLQKPBKUKBGlY80781aUDAL5vSg== 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=NgdRMEm5b7ecUIgJRgBzczX2TCGPfumhFWdIRNlizFc=; b=uxuHjSst+FHZRO9Y7cwG21Xjy4+2FvmHpWdeUx7zwEwH3D0RdtHVo55JpIKvtXZVhlPhBNyFND8wCXOUXHyYeXw/91z4DdP0UIfizSalySnQHeZ9gsxxG7cMhnbJPhg+aTV+HPOG92ZFhaqti+A/UiICT8MTTw1yQy7oBaitS7U= Received: from MN0PR04CA0028.namprd04.prod.outlook.com (2603:10b6:208:52d::27) by PH8PR12MB6795.namprd12.prod.outlook.com (2603:10b6:510:1c6::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.30; Tue, 5 Nov 2024 15:33:37 +0000 Received: from BN2PEPF000055DF.namprd21.prod.outlook.com (2603:10b6:208:52d:cafe::cc) by MN0PR04CA0028.outlook.office365.com (2603:10b6:208:52d::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.31 via Frontend Transport; Tue, 5 Nov 2024 15:33: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 BN2PEPF000055DF.mail.protection.outlook.com (10.167.245.9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8158.0 via Frontend Transport; Tue, 5 Nov 2024 15:33: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; Tue, 5 Nov 2024 09:33:34 -0600 From: Mario Limonciello To: Hans de Goede , =?utf-8?q?Ilpo_J=C3=A4rvinen?= CC: "Rafael J . Wysocki" , Len Brown , Maximilian Luz , Lee Chun-Yi , "Shyam Sundar S K" , Corentin Chary , "Luke D . Jones" , Ike Panhc , Henrique de Moraes Holschuh , "Alexis Belmonte" , =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= , Ai Chao , Gergo Koteles , open list , "open list:ACPI" , "open list:MICROSOFT SURFACE PLATFORM PROFILE DRIVER" , "open list:THINKPAD ACPI EXTRAS DRIVER" , Mark Pearson , Matthew Schwartz , Mario Limonciello Subject: [PATCH v4 05/20] ACPI: platform_profile: Move sanity check out of the mutex Date: Tue, 5 Nov 2024 09:33:01 -0600 Message-ID: <20241105153316.378-6-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241105153316.378-1-mario.limonciello@amd.com> References: <20241105153316.378-1-mario.limonciello@amd.com> Precedence: bulk X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN2PEPF000055DF:EE_|PH8PR12MB6795:EE_ X-MS-Office365-Filtering-Correlation-Id: c50279a0-0a90-4a09-8509-08dcfdaf3782 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700013|82310400026|376014|7416014|1800799024; X-Microsoft-Antispam-Message-Info: =?utf-8?q?Rv50o/Po2SUD/JtmUeuYZ7CAfI5a73p?= =?utf-8?q?J+6BE8di8MYzToXeYcjVlm5qfXC8ZvPDWXhRw21WOQaGbl7Xi/yDqlsNxNct/ETXw?= =?utf-8?q?P5XMj5AP/B/XwS6EY3pQ/PgydKdF68uSpR8VMtZu7BZTJgymM1Mi8i375kjYu6+cS?= =?utf-8?q?4+BHXq2979iZ1yc9R9gxlAjs3qZZBlT+2LTfUYNK50MQCOXM3iJ6DInyR4E6RmNwe?= =?utf-8?q?QN8+jUzo8BinwhKl3eUELB018RSiOrcQ1j9F7REXoO+b05XBzlcziQL4fLqOpc+rD?= =?utf-8?q?32XtifP6GmzvadEW23JfTUMSCZB2aANmA1HQxGg0dYnlL78LTh4d5O6BCaKF6FRX2?= =?utf-8?q?4FGgEK96cF0Tl69C29o4EgAmXrEHp382nU8rcxR8QgL0VXCaKlQvsv80ukohnpbM+?= =?utf-8?q?YgdTEDS4cmTPwq2nCam77V5SUzJB9V78yR7E8bVA/hXEzKzK/HrJyT1C2CzPGeJ8d?= =?utf-8?q?qM8esRxt/aahda47JKNpjyRY2ioFpbOpo0rVVmawad85mV0jcZAbJpU2OcywmGeL7?= =?utf-8?q?b8p0ukBpPnjcSr7AsT3IUa7YCbaXByCsZkgVR4TkaQXoe7f9a4fqsRYDBmKQu9Jkl?= =?utf-8?q?5KpHvrHRRJ/bP1/YKhMWsvatLAO0aDDN+N4y+UjXFEQe+itB9BXQqA/rlTTkU/1Ep?= =?utf-8?q?NjYfrF2yori8e0W/+JUJXgCXHjepzWwl+ArDJCo5gvOP0lwrtl5OZ/lnkWGh4ILPw?= =?utf-8?q?nTAcL8gssDgmhwo4QIatQM7zxsZ4i1pIFpM7f5EuIzmCREq6kCiGdXu80LAq5jDJ+?= =?utf-8?q?pVMNxBNR0V5IFohOHi7O9cGEpcc1jRAVa/2pSvXTENZVd4Mh1LQrWAKapr/Kt1m/2?= =?utf-8?q?CXzU/A0usqHmNHlu4SEoeaojLNDYc0POsS34qs0A+q2coxGbdGmNKfMdNfbDLGbwA?= =?utf-8?q?T/6IZvNZh5qcDM6EdX3XNJ2PphqW3o7xnn2TIerJsWl/1n6lTtq1wE+SbIybQviBk?= =?utf-8?q?QsPiHpMkV2afIyBRh4T8cCd7jmH1m7MPro38FlLgiz9Bo29e8fQbvN6maVk1C1uuW?= =?utf-8?q?lzXIhmAOoeFCRDG27cfioa1EFn/o0qw4X10bGat7AtOFZu02KhV0eI0goANJmXYp4?= =?utf-8?q?/mShEq4HUtY9ciSrNY0s0PcNjXyZ8VYxkqKUAHQ86oI3FyXh8C70/6Vjf+Mtkge+J?= =?utf-8?q?JG3agfggii0atl35HBnU5984F6OhEXe9qnlMz/zkp4Hq94iHMAMVMyCRgP/KplVMz?= =?utf-8?q?ILMxrU5UYua6hOayoB0fpkITeBdmNTIxPyLNVhf8HlTNp4mAhMzpR4o3m+n0nqE7X?= =?utf-8?q?n0x/ORY+8ryTBfR5AFtVbS50gi1Udhuq6JONEswNvfDG2tce//XfbuMdrnLzphl9M?= =?utf-8?q?LlkA+owNpqM3k86yCGMbSi5n6pFYjhOKrg=3D=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)(36860700013)(82310400026)(376014)(7416014)(1800799024);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Nov 2024 15:33:37.1547 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c50279a0-0a90-4a09-8509-08dcfdaf3782 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: BN2PEPF000055DF.namprd21.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH8PR12MB6795 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: Matthew Schwartz Reviewed-by: Ilpo Järvinen Reviewed-by: Mark Pearson Signed-off-by: Mario Limonciello Reviewed-by: Armin Wolf --- drivers/acpi/platform_profile.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profile.c index c76b8e3fdcde6..4e8a155589c21 100644 --- a/drivers/acpi/platform_profile.c +++ b/drivers/acpi/platform_profile.c @@ -179,6 +179,12 @@ 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; + } if (!pprof->dev) { pr_err("platform_profile: handler device is not set\n"); return -EINVAL; @@ -191,13 +197,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 Tue Nov 5 15:33:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 13863084 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2066.outbound.protection.outlook.com [40.107.93.66]) (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 1360414E2D6; Tue, 5 Nov 2024 15:33:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.93.66 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730820823; cv=fail; b=mtmHqqgc3mEb/h41C8DV4qYq0MkS1lzX9+8Ltsq83y7tGuqTF2pvtS6KulOOldNX6Fzlq4EaGuXfmhIg0VFY/VPx6FQ98RfTkmq3zABGpXRUOoXaB8I0MIVtoWw/g3WM/wN7Mk9mKNLo9xLcxN4XmlYWTEYUI1s+DD+mhG/cYDQ= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730820823; c=relaxed/simple; bh=vmH80ZPsQiWyuhHi93KG5eLUcVTYH8g9LsY0szntTDQ=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=GspamskvqSgEpbKW2bIvVxqqElwOnagDNXltboiFGqWSaVLah3ET8V4dQVT9hHOkpKEihOujF3oBH94YqGYyYZgMLRB0ew2DuGd1uUYMxi8cc5P8Sy1fmK7vp4BZRAWawE4m4xzYqpjsgDJoDObmkoSZhun/RuwCIBNG+JUANZ8= 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=P+6+0jFa; arc=fail smtp.client-ip=40.107.93.66 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="P+6+0jFa" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=f/I2I5od0xbUO9lQpo2oyy55IrvGoL6O7auBP3A4ptK1B+OEyQ1/DDEW3JHWhD5jXWJGm6coj/XRin5bCBqlDXxMk10pJyA7Ykmr0fqapI5MmHHYvag0fFysOKhHiBdTlUrEfZbJQTpTy8QX5YBVQ/DfgD1qYJ24HzSMwvXd6mqqHTIrVa3pK/cke023CrCGrIEhtrwTHfvHD2SAr5vbzXsRda32FfgU2zPc5jE5Pj8LNXW1hEW/tBRv+tRz5z7bUTmi2Ohl3lqhpTPuIQb+5hesg3E2H4X/YyJpomg50GqFLVaFxtQJep90Gsn6xvd30vbPVUmHoFSQhCBZafvLwQ== 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=BpOOny12FmSUBq/F94SaWglUWvl7NYuCERlhr18ZrG0=; b=CeDhq06BaDxq90sdH/ST6ZRB73E32ASydCT5Msg9D8OKN9Rc17YInXtKuh08w/q1TcMyAHSPAdiYW3+HbsNpJdYVNUwZ0ELejVB8tN21j7bCF0Ic3DNuWBY0CgF9Ip1tZ42aQskENIAhbEins3VZdODNL+USOXnwT+0Id/D+JIBqhkR/04srjE3svzxq+o0XBDZReFEU9zWBjrqbPwBz1OkJuU5rAHXYY/SSn0GWqI8DnAooO6m+y+pdJpRFJwoWamfJ92nNQCj0UdGEeCqPnd3plujKNqUeyO6xbrqTOxBnpHLHX3occlZtvNWrgcbE9pRb9G0EGrK0jW2S0u1/rA== 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=BpOOny12FmSUBq/F94SaWglUWvl7NYuCERlhr18ZrG0=; b=P+6+0jFaiml2Cm1kD5edUDgd1x2kzJiYA2JuwCMTwF3OU81PWc0k3TlVueJhmco+Ehkp/cqPmhlnj8M+j1VwtUSndhzRuvUsR8s66XKAdKwgU1/p+U7kjZnTdEhW7sy0/LeJuue4u/I5TO3ZdeUZ9C/QxGLcVpUtPyATU4OWvGA= Received: from MN0PR04CA0021.namprd04.prod.outlook.com (2603:10b6:208:52d::32) by PH0PR12MB7982.namprd12.prod.outlook.com (2603:10b6:510:28d::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.31; Tue, 5 Nov 2024 15:33:38 +0000 Received: from BN2PEPF000055DF.namprd21.prod.outlook.com (2603:10b6:208:52d:cafe::8f) by MN0PR04CA0021.outlook.office365.com (2603:10b6:208:52d::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.31 via Frontend Transport; Tue, 5 Nov 2024 15:33:38 +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 BN2PEPF000055DF.mail.protection.outlook.com (10.167.245.9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8158.0 via Frontend Transport; Tue, 5 Nov 2024 15:33: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; Tue, 5 Nov 2024 09:33: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 Subject: [PATCH v4 06/20] ACPI: platform_profile: Move matching string for new profile out of mutex Date: Tue, 5 Nov 2024 09:33:02 -0600 Message-ID: <20241105153316.378-7-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241105153316.378-1-mario.limonciello@amd.com> References: <20241105153316.378-1-mario.limonciello@amd.com> Precedence: bulk X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN2PEPF000055DF:EE_|PH0PR12MB7982:EE_ X-MS-Office365-Filtering-Correlation-Id: 93fdb62f-4ecc-4fbd-e19b-08dcfdaf3800 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700013|376014|7416014|82310400026|1800799024; X-Microsoft-Antispam-Message-Info: dJyRmJYGBY2BUPla5l3t5xXPk6pTXX/RaiQcLhD+aTMyzbebAdVBVuKsP+eY3X2Yn4dlZ8AE3wlqjliuQ7MM6Nz3z8n0SmX1BENPzgr0Bu4fagT9rvR+zZayaO00XrFp2f2ZCC0tufWKbu7sRTZ4HgpyJQb0hveWpmAvmJb4QTvznAsvyd6Y+mPu4zo8bry7C9Ao745nWLTQjx78VOcqrCfVik0WMnThjESQY5mc9FgZxK3QfDvO+YtFRXyd8LiJS2wukIKeEtbFvvuak7H8uGUgK+sPiBHXncW0DQnLCdOCPDsrlunjqBzo3x/zS8w2nZInC/RgkS5PWvk+9v5F6+IC5rwpSHJR03PGS86pb4X3zaw7GPM6IA0SnHfgKTwJrLdJvoaaS7dATaxC2AvTvA1Xw58bD37m+UhJu2+FYm2qD91PjFYcl1BfWH+Q0uHXSZ000o2HCnFoKjVtggSJfcFdwT+K3n88BhlbKOEolCnJvvAWVW8UWFAJ+vrtaHugO3X7REjsr2AyA3Axrwo1gDYIQC0I8AVdk7KMhfz84+WNxMoZihCW4SznAoxbjqm4fbyT/4/G15iNrzriiF4G9W75WvEnaP2tUlkTZwVYm1c3s+ZPycB1vQgSOmTDEdIQcbwzxSNzOVFlJLlcaLvbE4NA6L3Mys+dewHKOt4jMMH4XxeuOTFMW4/CUT3k0oBDXa/GCvG/TWOlaqFEhYGA1Dqifrac/ddBa+NOqHBgEwIbKZkkpAt8ITkwovh0ljy46pn2HCh25MAjCfNSJmLeRzxJfSAJ26AtWG9B5vadWFzXgGSsUfgE6q9q9d3oLrwGBut9wJsgR4VcRsz51d+02hbGObvhF5Rc30wZbuqn1tZL08P5vhUjVOYPJhsXqzaBjEOCS7IfZb+vtg8uuL7wIaaCnHjYapcs6Cn1w9EhKv6sBZZ8cXxxm0T/dExhvjeKxNil3q+IY9goefgQzkzoXI/CF8T+xTHSWj0CwAsVAlNWdLMMnOeG+sozzRwcK3c4r7L6xdGhL5hcNk3WCV4NVeDFV8KbIqmBbmGoyTAVaC/S3QNks4JuGPogQDKCnoGA9HpqsE4My0YJ4NR37hQGZcvb02SZokU29aRSOScq9oHKMURPEqHAkz2oBXCqaRtYpHih5eUlpegegWPGfjT4iufEfg1/pnasWUGLc6LrU23QCvi8TQ9Ks5eDmWxzUPzhLO5eEOllSS5Q4jStNOpWHCg7/Y4j0rh7liqwRQ5+fB6kNKNAZlke6zGzdpy+VVhaI5M2OZSI2BPSK0lbS9wEIBXX20b4R/PCI/PolzhBi1ozHWjEMOUGIsp6LpLCbJcCH6MWcWPahwBvNMB7O7GgiB6XnDE/CbYUEWX3xKZUSgB+MbxGd8poy3BUnzfJ1TXu46XM4+eqBqFCVLdoG+LotA== X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(36860700013)(376014)(7416014)(82310400026)(1800799024);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Nov 2024 15:33:37.9828 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 93fdb62f-4ecc-4fbd-e19b-08dcfdaf3800 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: BN2PEPF000055DF.namprd21.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR12MB7982 Holding the mutex is not necessary while scanning the string passed into platform_profile_store(). Signed-off-by: Mario Limonciello Reviewed-by: Ilpo Järvinen Reviewed-by: Armin Wolf --- 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 4e8a155589c21..70e7f1ba68676 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 Tue Nov 5 15:33:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 13863099 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2057.outbound.protection.outlook.com [40.107.244.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 3D6B2145B14; Tue, 5 Nov 2024 15:34:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.244.57 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730820849; cv=fail; b=Jc1K51sUmiDeHekFgn1FX5rNmkEHIdLEmY7D7l6fzyQVa/IcbyF0QCZOwY7fW7LgPqTsNzmL8U4txvF1tTAc5U0d1giCAU6hm8SK94ukwE81G5sCCNblA4Kh24iL5RBeNuYf7oi5bND4ni4UpTqsi3pCrl2mXrE51IqBNNa0Yeo= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730820849; c=relaxed/simple; bh=CC88Q+zb9x+qJyFWT0r7BsGTISAdvYfUNOCDT0p7LSI=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=QvTQ6RbyUqf883WXlDUbLhth7HSq3dLp0dLY8Amaw/PYwP8mvGTVUBYlO+oLHgjwspLtAKw61XVUDIKaIhIXjrB2gYmULMgfwWCObOm3yidgV1IEqHxYgn2YelC79ZjhSykFMZvzLNCUCn+4HAo1V+O3aMWF+eq9Rdpz6oBvdhg= 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=Ib+hAAz3; arc=fail smtp.client-ip=40.107.244.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="Ib+hAAz3" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=lI6wIUIBDQdabPZ3W3tjs/3OxPk2PQpKgUHHIY6N0LpHMnk23EIxC6j9ZDZYcnSMzLGCPbWvVOYR6txmcwq7Ta+fbn+CtietX3mFu2ZR8ms5Ew7DXyKfTnXKratcIHAHKoc5HbC3iOdGg3G2E2AjVnHjLQxybx+tV7PCy4rHmAfTd6LrDm0NBeqJLxCT2O7wcNXcrKVMn00sAhid5LHwRJwjP6onTBziYzKIGjcomIsxggMm/P/ZNiiXBqo7UY580mp3Xr2KmiuITb5r0oN0j2bmEg4xNxiJ2+1XqWhjoDphHAu/aA7oPYxGEifWIX25iE1OjtRzPTgx+KbZNF/pFw== 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=DWrFpOP8j0p7ioctz6BKIQzkCfCwrDMVuzyTi8lgzZo=; b=PoCjjbvAaX9/qAC3/pBHkxLUfVijfw0fnXpTPTLnI9frIyngru/IxHbDRGjABPJlfVkYLtV3NawPABoZE/WbuKFxrynTrI3PzE54yvJdl2+LjYMEBIOd+599IRPpgUR4A+TaUv8ecCNT5oIEYQy8ooCrveWPCGHztJM/8Tj6jbbf28pqmS+ZL4p6EpzFuHId38TuoWJrwghunruggnEVlxPdFnlKNuwV+plsfDzDEqct2aRa3RStPVcGjYBkDMeRwZGIHmoKzQxe1S1K08aeoei6kVVS/0Qi0fq8NGLF4g+Q0tNaom23Fg5WRFc0ATVtKe+ZKIu+qVOZ1lArIE8Ozg== 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=DWrFpOP8j0p7ioctz6BKIQzkCfCwrDMVuzyTi8lgzZo=; b=Ib+hAAz32cTi4es0BxJlPOqXCD6OR9HNnwkcTFr5MenQAbczsOz6Lyo5cpVz/xGHk3AOH0N3ls0fM6m/6/IXFMAlquWfd7O/Yq1vPQZ/RdUCDl92HpMcKt+Pb+n5sNbMCsjJ4ZlrsUnvyv3D7kxhKX3wFSSFpWV/aN3Z3y0dnFA= Received: from MN0PR04CA0029.namprd04.prod.outlook.com (2603:10b6:208:52d::34) by DM4PR12MB6542.namprd12.prod.outlook.com (2603:10b6:8:89::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.30; Tue, 5 Nov 2024 15:33:39 +0000 Received: from BN2PEPF000055DF.namprd21.prod.outlook.com (2603:10b6:208:52d:cafe::70) by MN0PR04CA0029.outlook.office365.com (2603:10b6:208:52d::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8137.18 via Frontend Transport; Tue, 5 Nov 2024 15:33: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 BN2PEPF000055DF.mail.protection.outlook.com (10.167.245.9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8158.0 via Frontend Transport; Tue, 5 Nov 2024 15:33: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; Tue, 5 Nov 2024 09:33: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 Subject: [PATCH v4 07/20] ACPI: platform_profile: Use guard(mutex) for register/unregister Date: Tue, 5 Nov 2024 09:33:03 -0600 Message-ID: <20241105153316.378-8-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241105153316.378-1-mario.limonciello@amd.com> References: <20241105153316.378-1-mario.limonciello@amd.com> Precedence: bulk X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN2PEPF000055DF:EE_|DM4PR12MB6542:EE_ X-MS-Office365-Filtering-Correlation-Id: 62af7fc0-497e-478f-c653-08dcfdaf38a7 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|7416014|36860700013|82310400026|1800799024; X-Microsoft-Antispam-Message-Info: =?utf-8?q?LUBNoVxvQSIs72eRkFKg2qXRYMWzBL4?= =?utf-8?q?uePslpgI6ILQirO77COjLSWftQyTWYf77SuCvRiUW4NH0QJbNt+HKFxudTb6Omck3?= =?utf-8?q?ujXWaHbylZvxXcrPFWgfBg0Igzjmgw7Hy/5hIAqY0vr1FNOlTNmzKa/0bQtqOsaHM?= =?utf-8?q?rCeOmpDaosdXYudVrivGSC2r46JADrWhJCoAi7X7qZyoBzFovdk89glv/TTXJ1bL5?= =?utf-8?q?jL/XkcXGJYSHba2R5SM57bUQ5y1tp/YeI1X3WSa4UWz8uPZuwWDcePFVDxuQi+tAH?= =?utf-8?q?33M61o7uVZJ9iVGkPbBOwDIBogJoCNrS8rANh89DwuJGHW/LKyE1io5mqWeH4A43P?= =?utf-8?q?UxfJNooMQYN0nT8Or/dJaP0+DBGpF56jn3a6/pcpKvtSmCz/4J18bQLhQUWgAlXOF?= =?utf-8?q?8pqam+yhzbw04LJybnuWbWDGep9XcghyJf9HoWCzTfG3IMBqzIg6PyfaqPxZIHcUL?= =?utf-8?q?Rg+Jc2uHj25+lpc0BrOpmFya3Esz00f+SN4s1YfFhlmLwrr+e3qa0e/67l/viCWpu?= =?utf-8?q?IsEvVtEKtZrSd/IDMS8zrS2OCNJ7MeS0LqM6iYUb5m//Ow5ftMqN7xfZELe5iHTcH?= =?utf-8?q?lEiw9TEnQHHTfFCwt6sbSBDZDM7BWHDu8KvQHSvb5yOcfl6yNphzsJtf2oBIs/lvG?= =?utf-8?q?roeu80t5BWuoVMjGUtrWeda0EmKglhqfXEr5gAe4FLfEEcDkcBJjwiYrr7E20MVdo?= =?utf-8?q?f5yLnZWZf1RRXmXFUeEGAxxVRb1QaDR86+o2QnwbaPpb8prnRIYZnafrJEXyBP7Rj?= =?utf-8?q?Khq8ExVJGB/dPG9gHb9ydqzA5OEMr88Hnzf/z3tU6xwoY9T1KSdQVUZE8EbRqm/bf?= =?utf-8?q?hk4Xy4Co0g5BHMaAEI6k+KjsJ5UmU1nIyE5/cABQ4lgOh/V4I573Yn6riU6sM+Loj?= =?utf-8?q?TKgY0vR2kvrrFlTE4Ea7N7noQwLnxtWQxXLM+ndv1nXAWgwqWNCJ0zwPCsQ9OtCaY?= =?utf-8?q?FTKqLtpmulYRbWg3xtlYc0F2A9dRi4Uhob8cdMwAVyqFzxKtIyijsBxc2ESDvnW82?= =?utf-8?q?mJ6+ZmyDnAi/sIk5vHSr630t/qPa0pDSDmAFU9dnybuVzzPk5aw0VH4LH5IIQ5omV?= =?utf-8?q?B763tZFZU949EWja5zPtZESGbeyUEFfaEyoQsJ3WU/t9Am0ycZqO9shuo115o83wu?= =?utf-8?q?4B46TRI1DR5tPUVcrB6JV3gJ6Np4IohuR+6tvPBOBsLEa4YpYT8FwkLL0mN63YF8B?= =?utf-8?q?UR2y5IFAhamrY5Vpd24N2Rj6Vo3XQUSZosJWDgZUOIaBwKhJmxZNe55WKr0Kdiifi?= =?utf-8?q?89Ut1W7FplmNlOb6RLgd+UH/QyhuZoXEmls5b9vDGqvYyA/+jGp/Qxszj+xg5oGth?= =?utf-8?q?9bIC7F/JRm7PicyS22IObT6IMX73uiE3UA=3D=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)(376014)(7416014)(36860700013)(82310400026)(1800799024);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Nov 2024 15:33:39.0766 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 62af7fc0-497e-478f-c653-08dcfdaf38a7 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: BN2PEPF000055DF.namprd21.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB6542 guard(mutex) can be used to automatically release mutexes when going out of scope. Tested-by: Matthew Schwartz Reviewed-by: Hans de Goede Reviewed-by: Mark Pearson Reviewed-by: Ilpo Järvinen Signed-off-by: Mario Limonciello Reviewed-by: Armin Wolf --- 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 70e7f1ba68676..4454c4a903c8f 100644 --- a/drivers/acpi/platform_profile.c +++ b/drivers/acpi/platform_profile.c @@ -188,32 +188,26 @@ int platform_profile_register(struct platform_profile_handler *pprof) return -EINVAL; } - mutex_lock(&profile_lock); + guard(mutex)(&profile_lock); /* We can only have one active profile */ - if (cur_profile) { - mutex_unlock(&profile_lock); + if (cur_profile) return -EEXIST; - } err = sysfs_create_group(acpi_kobj, &platform_profile_group); - if (err) { - mutex_unlock(&profile_lock); + if (err) return err; - } cur_profile = pprof; - mutex_unlock(&profile_lock); return 0; } EXPORT_SYMBOL_GPL(platform_profile_register); int platform_profile_remove(struct platform_profile_handler *pprof) { - sysfs_remove_group(acpi_kobj, &platform_profile_group); + guard(mutex)(&profile_lock); - mutex_lock(&profile_lock); + sysfs_remove_group(acpi_kobj, &platform_profile_group); cur_profile = NULL; - mutex_unlock(&profile_lock); return 0; } EXPORT_SYMBOL_GPL(platform_profile_remove); From patchwork Tue Nov 5 15:33:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 13863086 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 ABEB315573F; Tue, 5 Nov 2024 15:33:43 +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=1730820825; cv=fail; b=H25CZO07u9zLBO6WBUuTtyvzCi/clzQFHrGycxaP9xqd67H6n7GigqN3P1IG3s5Q7P8RtLgbfHe4eiGO95Q7z4QkbxHV2VR36btb0zu75rq3UyYuNaSqyyesEpvexgwDp2cLpCMhSQdt4TK1kKI5Dd2Uhg71D70g/1Pjb7YFKSU= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730820825; c=relaxed/simple; bh=w2Dm3SR0v5D689dffnqkc4HrQRF/FCuKE23LW6i3O04=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=V2q+wIAaBazRuQaheOywnIYAnKV96vM+6HNyV0rrK7BZnRWoPEZhO27KbCxW6dWhAcnye4yBKkvLUx/1tFE2RF1KI8pSYxrZNzhLXJSQRYDnRLnqRogtDJ9haiDC0MQvE/t/Ng0A8y6YsE4LMY1df7CmlvkW3Ee6n4BfH0NuqK8= 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=bDMfZBLi; 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="bDMfZBLi" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=EUeQHpR1ziwlKXfVEE3MYm1haWRzlMqONuBCrMOg09Vi439aGHGugsV8wkWy+QQxrXmK5/t6YoiMFegjN7PdDeiyLjQ76rjNjT9O+MbAsGuh8n2fPgMjKHfEKnZbIJP5ThXfzpTO1AcF+djBlDqdwWe/dhcVIZ4V2n9VJYr0wGM0LEndJfSuo5rO8Y4w8dL13Hg8SVauPyeNyF2QnCFZCFQw4cVoIIB9vQXaASdab0hMNpt5A9dVRGz71ok83haCf4yUAB7Q1bPMLdHWdgdNv/JmwaZSdmG6yyB4QNsPOMy99tADmB6TuiQhpSpTYYMXUlnkCDONdd2U4EY3FEuFQQ== 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=3Ad1/6TojCvY4jp/TB6IgLBEzjel4m/AXx+akqf9shs=; b=NOkWcD3N1pulZDRa/AqiSRkqwOVN05S7MLr687g0FNuLrX030Oj8R6adha6YicpZgwyQTJ2r5Is3lCNSfWmLqTIgPFplfzK7r7JuW96dOZK6XSuduG0n7uMe+bOUQV5ymuiFDlgYY12hqq4luxIA+mZl6MO8jM+73+ATILnLxf/5B71XBrMy6ywmLvu61clEe9vDHBunUvSmJ6U6/DOEbbfIdo5Vlv0ZvE+T+//TwT0v9szk5HZP2EXT9ce6Kq34EUUD+epB3rEhc3HpSoNuCfpli1iTEsY0st7w7OocUydkWKPLNxKT44jalP+ZeKEQLsEcL7MXRxcntsv0gyI4wA== 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=3Ad1/6TojCvY4jp/TB6IgLBEzjel4m/AXx+akqf9shs=; b=bDMfZBLiYS4CYIfQWvSYnt4+tP+21oXw+3VoHSzEvsaOCsAyKNRk+Gvy+F6mESLcpnIZgNdKI3A2naUiyy6sjvVwcBedV8fGNbVVjUzWPJYLt2d4mTjShAELbvqGzClI1KeFGP9O8UUwj3G9IS6Re28LiZ+Nwc0UTAmu9tP8VmA= Received: from MN0PR04CA0026.namprd04.prod.outlook.com (2603:10b6:208:52d::17) by BY5PR12MB4145.namprd12.prod.outlook.com (2603:10b6:a03:212::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8137.19; Tue, 5 Nov 2024 15:33:39 +0000 Received: from BN2PEPF000055DF.namprd21.prod.outlook.com (2603:10b6:208:52d:cafe::27) by MN0PR04CA0026.outlook.office365.com (2603:10b6:208:52d::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8137.18 via Frontend Transport; Tue, 5 Nov 2024 15:33: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 BN2PEPF000055DF.mail.protection.outlook.com (10.167.245.9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8158.0 via Frontend Transport; Tue, 5 Nov 2024 15:33: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; Tue, 5 Nov 2024 09:33:37 -0600 From: Mario Limonciello To: Hans de Goede , =?utf-8?q?Ilpo_J=C3=A4rvinen?= CC: "Rafael J . Wysocki" , Len Brown , Maximilian Luz , Lee Chun-Yi , "Shyam Sundar S K" , Corentin Chary , "Luke D . Jones" , Ike Panhc , Henrique de Moraes Holschuh , "Alexis Belmonte" , =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= , Ai Chao , Gergo Koteles , open list , "open list:ACPI" , "open list:MICROSOFT SURFACE PLATFORM PROFILE DRIVER" , "open list:THINKPAD ACPI EXTRAS DRIVER" , Mark Pearson , Matthew Schwartz , Mario Limonciello Subject: [PATCH v4 08/20] ACPI: platform_profile: Use `scoped_cond_guard` Date: Tue, 5 Nov 2024 09:33:04 -0600 Message-ID: <20241105153316.378-9-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241105153316.378-1-mario.limonciello@amd.com> References: <20241105153316.378-1-mario.limonciello@amd.com> Precedence: bulk X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN2PEPF000055DF:EE_|BY5PR12MB4145:EE_ X-MS-Office365-Filtering-Correlation-Id: 12232ade-a9f1-4667-d670-08dcfdaf38f8 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700013|82310400026|376014|7416014|1800799024; X-Microsoft-Antispam-Message-Info: ga8nTEjOykxLOu6UuVPBln9lt/vJJOnhuDZuxtUOHL+4Th+r6fED2GDztF2i34YrC7Dt73S+3ZweiZuSTWCUWZhKwid7x+BS1Qi5SOrAYcROrSI19Ouq8DSB2XGyB5hwvNNe/WX2FW97Zw8KROeTnnPl1O/U+864GGJA+TixNRqhccmyKjtmDTed5fTgdYdfJleQVXR1ZxHHQLdauNdIFmfS7ZWQoOadzqY4iXu32L9pmWmZFp3mljB/6CMPzlsNQwFf114snjO7vGjmTifZ1wc2TSfxb5AgXtMdijaCZWtjAQUL2JI1TjPw9QJGZt8NlcGCn0AGD7qY7ZivdEQrSEY0QifcvFNnP5ekS9qr7L+LSdELeP49xWB1S+rD/+PXh03IfOTOKqxhLEZX1y4jHRR9tbws668hC4HHun9+nsVXL5jP5ej6XfdDhNJFLxRPDREEjobIz0LwJWMhyOBEdITfHejP25U1yo7k661qrGrZQ56z5HJfMOzDvj+ACoE3QlPPGhu3/jXw9apxNo6ahZuN+Nvg2SnXI/VUJpgy4C9R80wFX+0ka9eE8ofhH1NbOjZlMP0utmQvzyms/FLDb3NHNUP9c/MeuLuboQoRvfd1nnwyHZb9NjP3R43VVlOpd0v0kRxw35ZlxaIrauzLz28tW/VkQe2E/yx6hyMMjfRiZCa63xkjTHdynAECBMzLSpVaKQKuQHE2J+jOsmTimEh5oTDD9ZZRYhV+DfX2oC8+EhGh9zlVXtjqXjwhfyb+7+iIdPs0EbjKs6HG6qUDeJctagrTB0cfbzZGLO5r7/YSC4bLzfXSLq3M7sBCXZzScHP/YHBKvC3MztwdG4U+zvw2uIb494JIMjmkPkp2NtV39qq9OVvMPARuvow9F+TofbLpRjRLVYfflBS3wVp9OBAbuIT+FC6iigMreQQEG9eMqJw7ErN8Z8hFDczvACBm9gg4WPFq8pcWe6c55AH8HxMgBiEiqF5zK7djUd4BfLJ9Y03KY/ajFMG/K4q0OTDkG+E9Qb1cBqgNTMdkOBfQCkJO0toJvbFMPuQmsgIiRejmcjOBGwKZg0th2PzHVdW7mxE23YRCIl6cUdhy/CyMAf5mYHSs2vkk8J9gLhyWmqAthbUOb0AHhxtlY4pcpcD8p4sqfxuFe8Wk1vA3Ou6DJWc7FuhzFG1nnSYoCYE6X6B5szuNlUlkzptX+fAzEkh9gt/jUROy28mRCjqJO1GpqGPZKYmEQXdRurd3H1eT8AcJPpLQ4B8AjwkoSotzXLKjgs8NKy9PPWN6JktaUMXJ6CGkRfLNk46jRoSXLvdWp3MD1qizifwjnPDtbJwUO+IExdI4EZwVOVdQjXGJEZFpoxiyI6OzCPsITUv9ALaYzjgM/YCJ4n3ysm6B5mL7FLDCxiz26qbM4rW+TRu+a0Evkw== 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)(376014)(7416014)(1800799024);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Nov 2024 15:33:39.6078 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 12232ade-a9f1-4667-d670-08dcfdaf38f8 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: BN2PEPF000055DF.namprd21.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR12MB4145 Migrate away from using an interruptible mutex to scoped_cond_guard in all functions. Reviewed-by: Mark Pearson Signed-off-by: Mario Limonciello Reviewed-by: Ilpo Järvinen --- drivers/acpi/platform_profile.c | 114 ++++++++++++-------------------- 1 file changed, 44 insertions(+), 70 deletions(-) diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profile.c index 4454c4a903c8f..fd1c4e9dccf0a 100644 --- a/drivers/acpi/platform_profile.c +++ b/drivers/acpi/platform_profile.c @@ -27,25 +27,21 @@ 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; - - 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]); + int 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) { + if (len == 0) + len += sysfs_emit_at(buf, len, "%s", profile_names[i]); + else + len += sysfs_emit_at(buf, len, " %s", profile_names[i]); + } } len += sysfs_emit_at(buf, len, "\n"); - mutex_unlock(&profile_lock); + return len; } @@ -56,20 +52,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 +79,20 @@ 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"); - - mutex_unlock(&profile_lock); - if (err) - return err; + sysfs_notify(acpi_kobj, NULL, "platform_profile"); return count; } @@ -140,36 +123,27 @@ 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"); - - return err; + sysfs_notify(acpi_kobj, NULL, "platform_profile"); + return 0; } EXPORT_SYMBOL_GPL(platform_profile_cycle); From patchwork Tue Nov 5 15:33:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 13863090 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2083.outbound.protection.outlook.com [40.107.236.83]) (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 667861714D0; Tue, 5 Nov 2024 15:33:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.236.83 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730820828; cv=fail; b=poyGSQE2hkOl64x+KxG58pjN+02/Cm0znwZ0tALC/j7WN2MfRBLOgAdZNJPAtly/s9TfL//k77VqeUamVBNT1igPo8XW7totg7g65UiycuyZ9tMFNlFE2qeCJRqiwR+kYszTL49wKGyA36loF6in2CzitLUDG8dxd5VF/uygf78= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730820828; c=relaxed/simple; bh=IKVHLpA4A5Emcm9TiMSim8CDvCbkac0/6uf5InyDifQ=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=GRQHgTGsOdhpQvl3qwgOBAtPnbvwZXnx2cKMqObThePm8jKInxudtT5AFZxxMeeQPmwleNBzEnNDyNb7zAoTWnJH+NPmzOwoWar+34sPzEKvNmjFn4gFfEdMppWeYRI7yhKhlHtbQVmEvpxKGc7e+Ls+SRERzgQFNWoPX+eCMss= 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=nYMXHmvF; arc=fail smtp.client-ip=40.107.236.83 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="nYMXHmvF" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=EKiwQecVnO0QVaUP5okXS3wGH/4rnXPE6JcXGrsdRUszAMhTgOhwn5Q26x4UUXzCx4813qMWM294W/4wFf/cw5FBLuuMeO2Rj6IRniw4Ntr4sMC38JNz7wRxvh+ECggOty8maqyznIxfI14DTziAx1BK+9bM2VjW5Mu28//tL/0RQGlnYkOHwKzRT2lJYiXraGfA8HuE0aPohTSdbWClCwfJGMvIUGiOFWuFfb+MtxsNrT1AzeUx0U0G5QDvv9Zt/8SOCRTwiRzwZJuj/hcMi1uzSh28IdO7YfzC/fxTNGdyorKz0JIpAnb44jixnguvpcJfMPCjlggdtcdJ0yJTcQ== 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=AeHUBXnx2/eWL3xINfk4aXphOjzqTzP4FAaeqbocuiQ=; b=L56VMsehWaFYidwTSswLVKE43HMErmkWw/IuZ9X6O0RrLAGW34WdISarDiA3nGQsT6OiM/P3dS3jRjJTYv979392igwgk41gfrVP5aAdYpVTrjuryOC2CFN1+KJhsdTGf4CR8L5Ln+bOuJ5GKgAsUnP2gGk7l/NNYWm7P1Avm/7+MCtpkriB11AEW8uO7tG/RXyBjaOJefrDvT/g6t615um3roTUYPzwheCkEIVAMm7yVHh3ni4ux0JuTVzLSmDNoQVc4w4UcqHcRV2GNATdPkNXp3IOdr7MbvD1zoEBfNXvG+iTg/4FLFX/9pWcVAo8UBkk4Rl+IJ8ajDTdir74dg== 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=AeHUBXnx2/eWL3xINfk4aXphOjzqTzP4FAaeqbocuiQ=; b=nYMXHmvFzXoEiEnJP+hUE1WmpygaKNDn8wuwLzza/3IlyXSfRkCcOLAsUc04FQkE7W/LxVnKnOqRt8e0TwKgXVjqkUA0qD7G3yYzpT4nECBtTVnLyxvIQowXiBi0qvA3jlzurNn8ub+U6QM2JCI3Kh8NvDycCJo2yFVX1qzJSwU= Received: from MN0PR04CA0026.namprd04.prod.outlook.com (2603:10b6:208:52d::17) by MW4PR12MB5626.namprd12.prod.outlook.com (2603:10b6:303:169::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.22; Tue, 5 Nov 2024 15:33:41 +0000 Received: from BN2PEPF000055DF.namprd21.prod.outlook.com (2603:10b6:208:52d:cafe::56) by MN0PR04CA0026.outlook.office365.com (2603:10b6:208:52d::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8137.18 via Frontend Transport; Tue, 5 Nov 2024 15:33: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 BN2PEPF000055DF.mail.protection.outlook.com (10.167.245.9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8158.0 via Frontend Transport; Tue, 5 Nov 2024 15:33: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; Tue, 5 Nov 2024 09:33: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 Subject: [PATCH v4 09/20] ACPI: platform_profile: Create class for ACPI platform profile Date: Tue, 5 Nov 2024 09:33:05 -0600 Message-ID: <20241105153316.378-10-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241105153316.378-1-mario.limonciello@amd.com> References: <20241105153316.378-1-mario.limonciello@amd.com> Precedence: bulk X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN2PEPF000055DF:EE_|MW4PR12MB5626:EE_ X-MS-Office365-Filtering-Correlation-Id: 8faca741-fcf3-442d-e51b-08dcfdaf3968 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|7416014|376014|82310400026|36860700013; X-Microsoft-Antispam-Message-Info: /rHMM46gVePch5+zbyXVVluFhFThHNYOYhpaY4nql6jfwuHJbYA355CIfM/ie0U9eEE0aOyoBpf3uV77UGO0vZCK2UCbBZ5YXdBq+2dtOJ6M+kXvuyoRppCTV3aD6U8LJ02/8b2yFNsBbO2LDhUDFaTTi0lb3QJiXoSVzBN0ITPwrAYJon9QUqkpYKKGJGeZBudtnG0CbpE9G3huY/nZ2wYJbricGXvPVsFfhoG6rB2XroKATibKCYRdnHJjts1soS4I3RQI9dFiwiEvb3VlfK/DVkLXCiiUqVM81HI5HSWcgAQ5NR0oBDyDnBdAgMKo80Oq8jYvXFzs5mM0kxMahblnctNKyhw8T6qZ4qCw1CDbuKN5/bksBkmHl67LVSNv1rRxL5boFvNv832FkGw8zkmSpOYw3pkX7j5YW1xREnCzAsYDP29PPGcSuYIbuo0caVnKJbPW+NSxbqOQi8vYrD/ASZ1UJr2gBhDH/OTxtXJwS2t5zTeLQmlD2GMOi6jS1VhGWK8R2KeUz0ixwF3OeDONsQFa3ejkbWwU3BF/wHCiZckkrtn4tvZJyrjyl8ph0jk0EeGZbed7zASfXv2gDpqyWM3lfNRRSoKon7MUdcCqLU3+tfQwOWeopctnnamnKWeK3/c/byAyjpY9HrghDF5p47X7wiuPnAFagUmscwnDVHPYEVFFe5bzHp7uwU0wUDQg6xOI8QxD8UHGJy6c5Vv/JuvNl/pHY4bwOzQ/xrH0I036IfKpF7TxdVzLMkEIqwuYPRl3MiPW+Y7mpY8bb2awaAypi0R5KecwZetBMp3S43vnZNj408mTdZMygCunt3QmNW0USZ6FyOSr5CX1M+eL1HFQR76tuYNeUpZKd3QDcWf6m3gFU8DG96HKizabnbCUvMYhPEuJrpTdioMWYo5UAVrB9/1NcGUStkToMcmbodQMRnnYyCUV/gwNus+hfbq+pBZTNBUfpSYaTokba2RW1P/h+b2ZyHy6+u7R9cXOSGWS67ZkPGwbTtaA9qbbZ+cf5oI1Fc/DuaG0qIZaCKrDkC4blLxUbJiLRjZ0BUtWZ+pGJoOacuzJLMTZl8p4AaA3b8bOsVCaeXR8oQ3QHijvPuL8rgB11gExXVsl65K3PD6M8TStv9SGDWv6iPTaf48Mh/oszBqZjQ3OfuMzVXhevjZJzjEkEubrVCeMaNQ5As05YL6nD6DCjWfY8nNgJBtI5GZj37+Iunl8Wg68FF9/c7Wle2QkAi6eu0aXU0RC9kLYlWxurEogjC4bh/zu/7x2614kpLPC0uNJdDlZGCOEDVSvf7anq3lrUB9vikCSx7omB2ppHX40bpfFjGqhg0vPKBhlI01Mgty6YUG57+9rmpd3t7mwenynNamtsxDxNRw68FtrHW9IAwh/oXNCnoWdnZxmqKlWEWrZdibofw== 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)(7416014)(376014)(82310400026)(36860700013);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Nov 2024 15:33:40.3422 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 8faca741-fcf3-442d-e51b-08dcfdaf3968 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: BN2PEPF000055DF.namprd21.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW4PR12MB5626 When registering a platform profile handler create a class device that will allow changing a single platform profile handler. Signed-off-by: Mario Limonciello --- drivers/acpi/platform_profile.c | 42 +++++++++++++++++++++++++++++--- include/linux/platform_profile.h | 2 ++ 2 files changed, 41 insertions(+), 3 deletions(-) diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profile.c index fd1c4e9dccf0a..f8e9dc9a10d54 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_IDR(platform_profile_minor_idr); + +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) @@ -113,6 +120,8 @@ void platform_profile_notify(void) { if (!cur_profile) return; + if (!class_is_registered(&platform_profile_class)) + return; sysfs_notify(acpi_kobj, NULL, "platform_profile"); } EXPORT_SYMBOL_GPL(platform_profile_notify); @@ -123,6 +132,9 @@ int platform_profile_cycle(void) enum platform_profile_option next; int err; + if (!class_is_registered(&platform_profile_class)) + return -ENODEV; + scoped_cond_guard(mutex_intr, return -ERESTARTSYS, &profile_lock) { if (!cur_profile) return -ENODEV; @@ -167,12 +179,33 @@ 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; + if (!class_is_registered(&platform_profile_class)) { + /* class for individual handlers */ + err = class_register(&platform_profile_class); + if (err) + return err; + /* legacy sysfs files */ + err = sysfs_create_group(acpi_kobj, &platform_profile_group); + if (err) + goto cleanup_class; + } + + /* create class interface for individual handler */ + pprof->minor = idr_alloc(&platform_profile_minor_idr, pprof, 0, 0, GFP_KERNEL); + pprof->class_dev = device_create(&platform_profile_class, pprof->dev, + MKDEV(0, pprof->minor), NULL, "platform-profile-%d", + pprof->minor); + if (IS_ERR(pprof->class_dev)) + return PTR_ERR(pprof->class_dev); + dev_set_drvdata(pprof->class_dev, pprof); cur_profile = pprof; return 0; + +cleanup_class: + class_unregister(&platform_profile_class); + + return err; } EXPORT_SYMBOL_GPL(platform_profile_register); @@ -181,6 +214,9 @@ int platform_profile_remove(struct platform_profile_handler *pprof) guard(mutex)(&profile_lock); sysfs_remove_group(acpi_kobj, &platform_profile_group); + + device_destroy(&platform_profile_class, MKDEV(0, pprof->minor)); + cur_profile = NULL; return 0; } diff --git a/include/linux/platform_profile.h b/include/linux/platform_profile.h index bcaf3aa39160f..f81c3afcb7575 100644 --- a/include/linux/platform_profile.h +++ b/include/linux/platform_profile.h @@ -29,6 +29,8 @@ enum platform_profile_option { struct platform_profile_handler { const char *name; struct device *dev; + struct device *class_dev; + int minor; unsigned long choices[BITS_TO_LONGS(PLATFORM_PROFILE_LAST)]; int (*profile_get)(struct platform_profile_handler *pprof, enum platform_profile_option *profile); From patchwork Tue Nov 5 15:33:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 13863088 Received: from NAM02-SN1-obe.outbound.protection.outlook.com (mail-sn1nam02on2049.outbound.protection.outlook.com [40.107.96.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 16A87178CDE; Tue, 5 Nov 2024 15:33:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.96.49 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730820827; cv=fail; b=CLLar5M2qLz0JT4LP4ScXTyzx8IixLOM9w3wlxIXQJ0w6Ix41hylYvFtIDuHe1hQ0KN89T56uf7zKZRn1nhhRIRH+9D/5mumlGT0zn09RsqlEe+p+wxJqveSrGILqdqlLAHkV46fA1ts4BBoGtmj733vEsFO9lHtt1tp0VW/J+8= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730820827; c=relaxed/simple; bh=A80apRvzFpvKnp/iSfY+2i4P14vmr3rdL7/mm8Jq4kk=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=sXEhbFtRXugT10ShEoADdUOzpoopUIDNsP9AGddVsRi9kaYziX/BBFT1MxPYjAbMz9AvWheGomYoH0Wo+GbxvehSlmwLOgXubEYcPic/O31sy6X+sKgce6pwKijZnrRTVfKDdDo7X/fXgBcO54x0tTEmWv9v3vU/+b8Dbq5/S8Y= 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=K2vZAg8i; arc=fail smtp.client-ip=40.107.96.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="K2vZAg8i" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=IKzn9IBZGrpiyrb4SB8zJOPPzooQUQBMcwZoL49nEX+flZaMTa5htMNa7io3gTomeRUKlTn69tLNJPiBhU5+9FC5EspblYlNQ9i0+hjxRAQpm4PSluK2b0YcxV2CwUCjpvXl+axca8Ug2ykDSWpgO+OCLPsm+ULxlbU8LjZz0zgeZSjXBMdyJpdgHP+yP/yZo4BaLoxfnC6IylTMwv/n5rgGuJdtQqH8ksRzOLoAfDWSNbGSPw4OKHZrnAJvGhDH7TZLH++6Pt7U1MZOrrr+VQXx1HZG8MpwkjV8bVLx7aA4q1HRx9dUiSa60ouK6PSeQ1jusnme8jKarjRgj2XIYg== 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=Z53q0LzTArxcJwMP/NfJsibGypRNuBSVtaP407naVoQ=; b=pkY2ANH+umVRrU4COLEqE4ApNsC4rWbNeiUNllRTTKULQtJRxq/apoKD6SjdvZ74h1djVjdcJwgD8I1RXewIrWczzRQ3iyHywOWn2Y2fnFPpPqDpCPj81jvEKsKPhC0QlQ2TDNDWGwXcIEHOs5IY651loFgrDccFQVB4xX3ONEzztZJKbMI7ZKkGK3k/NC6V5GnteLLzb6cuBQMt6d93RjRgX3eL7hEmYZKYbzjIb41ATi045Xv3g7XAbyD+cdVxcoqFA0oMY3S+1HHgm5hc09ugMnKMAT6szaxh7OgGyhe9Mbns9U9N+vnQo7uI/sOBryrXfYoGUmkVpcdQYD4kxA== 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=Z53q0LzTArxcJwMP/NfJsibGypRNuBSVtaP407naVoQ=; b=K2vZAg8ioOrCg7kkD2FabKnHZY1tIXfWftct5nUUG/PSTysXIcluoWALLCmrHSuQwPD3/CIOtXFNiAyvb+c2so12nkckyVzSkfR3nE/kQy5SsyucYGNsuXpNRwgvcAd5GmlcTgzQfu9R6ZRp9AAM+7qa2e6JNiSs8kbeaZrYAQg= Received: from MN0PR04CA0021.namprd04.prod.outlook.com (2603:10b6:208:52d::32) by IA1PR12MB8192.namprd12.prod.outlook.com (2603:10b6:208:3f9::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.30; Tue, 5 Nov 2024 15:33:41 +0000 Received: from BN2PEPF000055DF.namprd21.prod.outlook.com (2603:10b6:208:52d:cafe::aa) by MN0PR04CA0021.outlook.office365.com (2603:10b6:208:52d::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.31 via Frontend Transport; Tue, 5 Nov 2024 15:33:41 +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 BN2PEPF000055DF.mail.protection.outlook.com (10.167.245.9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8158.0 via Frontend Transport; Tue, 5 Nov 2024 15:33:41 +0000 Received: from AUS-P9-MLIMONCI.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Tue, 5 Nov 2024 09:33:39 -0600 From: Mario Limonciello To: Hans de Goede , =?utf-8?q?Ilpo_J=C3=A4rvinen?= CC: "Rafael J . Wysocki" , Len Brown , Maximilian Luz , Lee Chun-Yi , "Shyam Sundar S K" , Corentin Chary , "Luke D . Jones" , Ike Panhc , Henrique de Moraes Holschuh , "Alexis Belmonte" , =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= , Ai Chao , Gergo Koteles , open list , "open list:ACPI" , "open list:MICROSOFT SURFACE PLATFORM PROFILE DRIVER" , "open list:THINKPAD ACPI EXTRAS DRIVER" , Mark Pearson , Matthew Schwartz , Mario Limonciello Subject: [PATCH v4 10/20] ACPI: platform_profile: Add name attribute to class interface Date: Tue, 5 Nov 2024 09:33:06 -0600 Message-ID: <20241105153316.378-11-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241105153316.378-1-mario.limonciello@amd.com> References: <20241105153316.378-1-mario.limonciello@amd.com> Precedence: bulk X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN2PEPF000055DF:EE_|IA1PR12MB8192:EE_ X-MS-Office365-Filtering-Correlation-Id: b2eb7893-57bc-4535-2a90-08dcfdaf3a31 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700013|82310400026|376014|7416014|1800799024; X-Microsoft-Antispam-Message-Info: dUBVuAHDaGHkLeqa1ZMVDPbCaFCr15IyyBxk+eXesbPbi7S/MweDun2pjKOPp/SQJqgkCPm/WLsjyF8JRSxYSxAigoHpm0b0hHOivfXdEi3Fe8M1z0hRWRHHosCCMW9gLutHSnXwI+ia+HFsH2gq0TLrag8ENuOSczA2FIFanA2adkK27BohlepQZTZLYLH7YAz1PzkN1XW/W+PcP651AO1oodQi1SyJvqyFCzKj+MqCXXuQL1KhQX6cZe47WACMxR1ZetNITquXpfqQFF6ZK1KAK8p0vhSnezOnzqGfQYe7uPIAPBCierMAkveD23VG92zvGxoooM+L+9sYH5QfVcfzafic2fYhKxS2THjL2LDmN0iXlCZU0lFwWZerKKvQuVV+NQiT0hAvagrNmjwd5D1rP7sKOlsWoG4kOhBobzOg7HvfUwUu0sPIh4znBE2m1zmVW5vcRffmiU1YPKiALLzRIKM46OMAkFMfKLl/rsHtpkcHAA7z/s6GnzkhMDE7uiFwQ/NFy4mDTJae5VVORSlCjvLg4b9Mqu5nHncX0wgX7djLO44MCUPAh4G2c3Ey3dBAXYDVivpIaDF+uS9yY+R4CkTmCicfBuGhMDOGlBnul3oEBYU+VwBrAmHZ5X1WsepNu7ny+z3kEaAg07TXJBHJBw9CQb0Ck+qTdyJ7zB4Z87+1HYQzJCHvSQGfL6bdEtihp0TO62PKYzwDi2ABnc/mdBNyfyzaB9cqSfhiI/cxIHBZlwJqfcQx5njH17eApqA/LhqhiCkmAfj9g+oMx+3dSodiJZD0xU/qD6KGMBh156NPZkPNAXXCK3BUX3qrqfQ9Jg6vgDR2WOurZKbj03pKr7GqTzQkI65iB1Ugd5U4HPZEUbeF+Xloh06Qs36jZ62M2lMC/Tg+ckWRDlz24Xi2yDhpJcIIYs6VTUYO4Y3zcq7Nx1oYvomzTn11gYFSDjFLwt5kBnYr92DI97iWfPy0O92gOH4WIf+zoSEbzTWDNs1ooqbUarY7kaPOPrEPwO7nmlpkfCoKJqgBhvPJf9BdJQ8sKGdF/bchYWFub5Z/lwevDC+BJpFEAKIkf0aOBNmsZjqnGp3nAo4VyGBK94Dx8j/9wE6qHQ4OoA2QdMlMhr/gbT3LilLEj3EwPPv7eUH0CrcLHb7GyS+6JikIAu0n9Jh15Lv4zB/Vho9oeTuZ3gK7BdrrEJQ/Tn2FpB1v+BCbPKRrOZvqSKf54wfHQs9drBAwx+bBa+7+ANsja8NnexkU+parKwpvoAZUYvagQ1E/iFe86Aa3K1tIcAPNddUfByAVwR5rqv+rK2RTfe2+cX8sGpIaBYQpdzZBkcrTZAf1vuS9zxWLNHi3RSPwNnKPlb3qDP9dSw/b8w+L2CE8qBWWQQp+YuJbOhmLh01pEOphqf22Kjl1V3sZZTrWkg== 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)(376014)(7416014)(1800799024);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Nov 2024 15:33:41.6547 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b2eb7893-57bc-4535-2a90-08dcfdaf3a31 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: BN2PEPF000055DF.namprd21.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR12MB8192 The name attribute shows the name of the associated platform profile handler. Signed-off-by: Mario Limonciello Reviewed-by: Armin Wolf --- drivers/acpi/platform_profile.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profile.c index f8e9dc9a10d54..986bd636be226 100644 --- a/drivers/acpi/platform_profile.c +++ b/drivers/acpi/platform_profile.c @@ -25,8 +25,33 @@ static_assert(ARRAY_SIZE(profile_names) == PLATFORM_PROFILE_LAST); static DEFINE_IDR(platform_profile_minor_idr); +/** + * 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 Tue Nov 5 15:33:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 13863087 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2058.outbound.protection.outlook.com [40.107.243.58]) (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 EA12A16DC01; Tue, 5 Nov 2024 15:33:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.243.58 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730820826; cv=fail; b=i+W4YS/b1phE7U23Y1bxK7Z2EzeGkknr3/vJOC6y5WJW+gPntGtSN82I2culM9csqR5Ew2r4oyifsg69lLBWbPYNXibKtKvGMLuEKIyp0cUyPM1tN16Gl2fE5bSVCaxeflYsxXbqf5NgwApm3km+7+i8t6rofnv7J3fC15cJPdE= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730820826; c=relaxed/simple; bh=ZiSnrAZqpknDKmRTcVtO5k6/JrorA98CRKWnE2qaNnQ=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=cActgx1FIutYG1mokfajtrkdXFKp/6aRxIbY3EpbN6DPeDMuGoeY77NzOLbmNAnmV2y1d2/R1KXv596y6tCJdICGVy6OxvZm0iqKeo2P9gR8INMta1+nnZOoGlbB1IbXC9/aJLpRIm5VX33vhS4lLdGmR1H/jN3dPJ6rRPd6OU0= 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=ji/DC1ib; arc=fail smtp.client-ip=40.107.243.58 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="ji/DC1ib" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=jZyLT1bkgoff+yg7tGTBSum72kEhWbNi75wjsthMNKwasDPFCAVFnIeSH0eZKEPZzRAJ1dwRimsmbQWFWw/5j1iRt9GBf8R+bPeDnyD2oVAjJRSf5Y9nqbTpnbR4ZpU7e+6OUUz2pR+GTyG8WkobYH26PpTL/CrwvFAtbvlZ9ScFvwVRMwUB8F6OGKA7LRAqTCvEGXvk7ScNAwzLPcJ7k4E+zIAayJrrO+OTn8AjStR/c61vex4QoppINrJEmcaaouD+iDZekPLwk97RRn27tu9hVt8CoBRlOb9dZ8hVwNauCHXR1M1/CIaaCHbrULcLLR+pEAMVwqbVSQ/20MXzhQ== 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=naMIE5K+E2Bm+Lw6C/PWo8a1NL6TcZTaCbH9D8/5SRQ=; b=VPrH6UcZ8X5Vj7Fkyj+xJHOZkPBRn1TrgMj6ZQ6KWGaN21HM2XgtZeBzQMiSQMQelUl4uL6UQdmwMl1qBtD0Q7HoQLxpis3ITIdR9aGgcdO2r4G3oV3jP9SACG3tiDsXhW8T4PIv4p1cR/DfF9TWo/H8GBaRugC9GB5FYqIvga9VmenBhjteDvVNCbkWqosqEajj7fmVG2q7tSgxYhfybKxb8TcK4/98bhxFOnKjC8FnF74qJ3mmBpQSK9pceZ0Tz86STLqFPPrHSe/LiLdHMt/2u5C909yi9ZmNBnDagSxHsWopokcDa84uVrgcmu+ufCrT9cUKr4RCB0Weru1r2A== 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=naMIE5K+E2Bm+Lw6C/PWo8a1NL6TcZTaCbH9D8/5SRQ=; b=ji/DC1ibGhcNgIp/8VRnSsGsSASuwZoY4ir5xSn38ZWTPovotAaCwg7wC8q5RucCOX5uo2UgbsGgLgVIZCCiPVbycGI6pQatm29MTNyisrvOUEb34Ywkx1FdVBx7rnbYUEQ6JEjVmyU5QEZ3LAJyK5PHd1jBQRoR05kWMfljGvM= Received: from MN0PR04CA0023.namprd04.prod.outlook.com (2603:10b6:208:52d::28) by DM4PR12MB5723.namprd12.prod.outlook.com (2603:10b6:8:5e::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.31; Tue, 5 Nov 2024 15:33:42 +0000 Received: from BN2PEPF000055DF.namprd21.prod.outlook.com (2603:10b6:208:52d:cafe::a4) by MN0PR04CA0023.outlook.office365.com (2603:10b6:208:52d::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.31 via Frontend Transport; Tue, 5 Nov 2024 15:33: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 BN2PEPF000055DF.mail.protection.outlook.com (10.167.245.9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8158.0 via Frontend Transport; Tue, 5 Nov 2024 15:33: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; Tue, 5 Nov 2024 09:33: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 Subject: [PATCH v4 11/20] ACPI: platform_profile: Add choices attribute for class interface Date: Tue, 5 Nov 2024 09:33:07 -0600 Message-ID: <20241105153316.378-12-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241105153316.378-1-mario.limonciello@amd.com> References: <20241105153316.378-1-mario.limonciello@amd.com> Precedence: bulk X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN2PEPF000055DF:EE_|DM4PR12MB5723:EE_ X-MS-Office365-Filtering-Correlation-Id: 41e95df9-60b1-4209-9cc5-08dcfdaf3a84 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|82310400026|36860700013|376014|7416014|1800799024; X-Microsoft-Antispam-Message-Info: pfe6BQYxa98EN7ZFNRNWOjzMoTai5ByULv4sy9YIBnS+Z1rSf4zbQNKud5hS60qmLE9GIbViXu1KSLxLd1xjf/ATg4beOroYiaE6ondH/s57RLIAWYWayvZjwyNeX572zY4mOvaxeuvUsEdJKky8oPI3y19dbb1gKL6jC+aQMmQLbc6K2/cjvX5fZD+EkGVAaiVVeKlB9nv9+UYJ7XkC405oScb40pXQEWwNE1Lv1VnWWY6XnNytoQHH6yspkZs0wUCjrqVAAoFOCs3j7m25lA5WQ8DxLWHdr0hkMpEnWib5AUU+SIZW6/llqx8KLffZ2BZxzlcWi+jqQJVPdRUwXP0hZk1xpiNc1ZrzauM8aXkUjYVFV4MEyEy3TDJ7JtZ9HmxreBtJe4FX9ijCeD488ym5jlEijIPsJso11DU8q9urv+rO8fCT8MnKsLNqZvE6OCv5cuLx/VbIUIZY6DeGJFDe/W18daLH4lM54FceKYLKTIohvRBtGxmAJBNdcWvzEvoMzEgCkcwIVhVXKsTeA+EoEaiuo1TLaTYe1PKwPgI6ZR4vOqbsS0BWrmXM7trwNDUlwcN/w/hwa5R2ws59h510wYc/pu5ffxoBy3O6MMvl8+f8Gur/5jJBzCui5DpJDJHCl9Sgecl72qT/XdaV90VFGcoghj9p7vpxwI32n/sGhWxDEJAaiupHl7o/XQmY2Y89yUHytlThtBIxMtxl4uOIOl2RXRiqBA4NhAwZjGH/kBL6mihZ1vA+53U4Et24kPyBJYMRkE8eGEKtCdAeuhxoIC2Pi5dtlbGxpgMFIYAiYISX9F0bCd12ieB3i+svQcASSdGaicWex3cy2CCY752pVvsXmX6YYp8lNi3wZAeQ1/o8ey0K6QkOxZuCAqVTSN1COF2hDnIW4S8IkNviSII3NWlMsNOv59HTtqvcLgmDy93g0aGHmcI+d0SEZ/4n/xYDbm7JrBaPlnp2fLo4/LcHfyDfWwtMG5iILmy3P19Xah8qGU3wqu4BSf62npXlxz/1E3rbz2L8d0k3C6oHTkHmIzxQBdpEYR1YTY6IoD/fTHKevtoOZiXpolhd+HW1FfmmYhMUousbmjQ/nbHb96DyDGUZ/+hmYjsVZ5YaEvaBiodT6WvYHW7BBHIqpMUJCq3ntBga1K6R3qEAk7g4RCarKhL+6md4rVvbuaaOfOU561/eJlpr2vVc6qJUKD8YaprQVCzxM/2fGLH5TChGGnNJlR+LZFlhPd8oNxugBg9a9A2Heo0K82dIuJLq9HRPF2ydzwWIF2nGQehPBWhDTH4cf0ozmKlywzTEezGQxfHncDiiYgqF6UqT7V8MIJdtu2CpeCP8eYOGULTnZY/2tKJYzR9gpjxbGtI0BVUEy6V0f5cqWMB/FZvE+0H5Yp+xVwCb3f954HXwWz2maDurFA== 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)(82310400026)(36860700013)(376014)(7416014)(1800799024);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Nov 2024 15:33:42.2016 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 41e95df9-60b1-4209-9cc5-08dcfdaf3a84 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: BN2PEPF000055DF.namprd21.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB5723 The `choices` file will show all possible choices that a given platform profile handler can support. Signed-off-by: Mario Limonciello Reviewed-by: Armin Wolf --- drivers/acpi/platform_profile.c | 63 +++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profile.c index 986bd636be226..e1b6569c4ee70 100644 --- a/drivers/acpi/platform_profile.c +++ b/drivers/acpi/platform_profile.c @@ -25,6 +25,47 @@ static_assert(ARRAY_SIZE(profile_names) == PLATFORM_PROFILE_LAST); static DEFINE_IDR(platform_profile_minor_idr); +/** + * _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; +} + +/** + * _get_class_choices - Get the available profile choices for a class device + * @dev: The class device + * Return: The available profile choices + */ +static int _get_class_choices(struct device *dev, unsigned long *choices) +{ + struct platform_profile_handler *handler; + int i; + + scoped_cond_guard(mutex_intr, return -ERESTARTSYS, &profile_lock) { + handler = dev_get_drvdata(dev); + for_each_set_bit(i, handler->choices, PLATFORM_PROFILE_LAST) + *choices |= BIT(i); + } + + return 0; +} + + /** * name_show - Show the name of the profile handler * @dev: The device @@ -41,10 +82,32 @@ static ssize_t name_show(struct device *dev, return sysfs_emit(buf, "%s\n", handler->name); } +/** + * choices_show - Show the available profile choices + * @dev: The device + * @attr: The attribute + * @buf: The buffer to write to + */ +static ssize_t choices_show(struct device *dev, + struct device_attribute *attr, + char *buf) +{ + unsigned long choices = 0; + int err; + + err = _get_class_choices(dev, &choices); + if (err) + return err; + + return _commmon_choices_show(choices, buf); +} + static DEVICE_ATTR_RO(name); +static DEVICE_ATTR_RO(choices); static struct attribute *profile_attrs[] = { &dev_attr_name.attr, + &dev_attr_choices.attr, NULL }; ATTRIBUTE_GROUPS(profile); From patchwork Tue Nov 5 15:33:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 13863091 Received: from NAM02-DM3-obe.outbound.protection.outlook.com (mail-dm3nam02on2053.outbound.protection.outlook.com [40.107.95.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 D517917C9F8; Tue, 5 Nov 2024 15:33:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.95.53 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730820829; cv=fail; b=FmXXFPtuQshWwY+hmtrSPavtnG5M9Ru8lfMlHegM+67OyKq+6lIOL0go6AKJXY2EqPpVvzBScTE1itpKzCgQOVi+PmJG2mCek+M9LOYixrcUT/uJ1zbEX2wH4H370AOpElROc6iyTiJi4xj74MvG2p2C47lHv8halz0Nn/ZVVWA= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730820829; c=relaxed/simple; bh=TKrfIx/ehNBqFKp6HxS0kQpPp2ZLQ7nnOD0u69SIGUc=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=KWtdw11Od/Us4AWZEkWniOZ2BXL4Grm8HBmuLZTEGdwwQb09whLr9CmFjZeBdd1lcEN7t9o2fOZIQaHxdQ5SkasOvq2KcAowEc3PsJi82Ho8gzKTnG5wJEqCk6XPWO5OtNOBCwxWNWjBmLxdSZQUAEqsspfpRiqiA44mFplc4mU= 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=DAwQB/l9; arc=fail smtp.client-ip=40.107.95.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="DAwQB/l9" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=q2WVmSn6+UAkxJvj2F4MS1zSzTllDnbP/Gz8saFycGyiVFxtojU9JnA2Xu1x6Gy3wziV8nSOKDcP6G/HtzFHhKK5ABGmEbjKEh+WEQ8PROEku8gqcSt26JC2hr1sbdiRP2xXNalV1IBMNYnFWkIHLkdGqwnmA/YjcyGPv3LYD6CIGEOzFcB8SgF1wkLKN9EcV+NS0ZnK1JZS4vpA7PQ5DzHllXMpnpbYc1nhQYKzcMCcYNi5hoFjk1LxcEZNAcUL6VIvYh8e4pwFt/Ob7tl9HPnNV5oPTgi5Kkx9lN5zwbdjmdieVtK57l7fI0r+5tdXV/5V8sFo+KmIPlkSvdvXfw== 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=xJpLiFAFUIKpH4h3eLZ/owU1Hf+GXYfHSQ/QgRftZXE=; b=kgUiK5kHEfHcI9GU/+tzuk5KhEag4fv5x79azlTU9C3wP35pKg2LTUZZtRzgaRYOIH9O0MsRPvXBgcYGJE8zv6aNTY9+8iZ38GT4xQpeTc1UCef8Gdl9WaPpFjg+DjngphsbAcIdRLfqAbsbadZxj0Y4/CP8Mc1CA0ZKE5HtllUlWB0O/XitKL6Bj7hOdO/eiUBBTM7LZEuYsUk0FwhOwIJKMd7xKiwsSXhrWGUBbPmDgNiov2CwqwDn65bwqQXQDj76tyRySmz4UuPIH15IUOfCcDhOSbYmkkgKXzOIFgNurx9SFuN2bmauY7b6np2k+oz4/dItAtIKcrB5JSZfBQ== 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=xJpLiFAFUIKpH4h3eLZ/owU1Hf+GXYfHSQ/QgRftZXE=; b=DAwQB/l9JEp1zPCdt6HOP8bKUW38NwE6fiHRJUQOdpQqyLoQAeqKOzG7f1EFISLBpPCMtpzW7K94soHjOiLiImqDjyIGIyHBXdWX/f17iwAuCOmmbR24SHVfpGMpdwyabvMlR18CAcVRkP70Ubj2jI9mqXKQf4PmWJVD1k+2M0E= Received: from MN0PR04CA0007.namprd04.prod.outlook.com (2603:10b6:208:52d::12) by CH3PR12MB9455.namprd12.prod.outlook.com (2603:10b6:610:1c1::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.31; Tue, 5 Nov 2024 15:33:42 +0000 Received: from BN2PEPF000055DF.namprd21.prod.outlook.com (2603:10b6:208:52d:cafe::93) by MN0PR04CA0007.outlook.office365.com (2603:10b6:208:52d::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.31 via Frontend Transport; Tue, 5 Nov 2024 15:33: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 BN2PEPF000055DF.mail.protection.outlook.com (10.167.245.9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8158.0 via Frontend Transport; Tue, 5 Nov 2024 15:33: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; Tue, 5 Nov 2024 09:33: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 Subject: [PATCH v4 12/20] ACPI: platform_profile: Add profile attribute for class interface Date: Tue, 5 Nov 2024 09:33:08 -0600 Message-ID: <20241105153316.378-13-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241105153316.378-1-mario.limonciello@amd.com> References: <20241105153316.378-1-mario.limonciello@amd.com> Precedence: bulk X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN2PEPF000055DF:EE_|CH3PR12MB9455:EE_ X-MS-Office365-Filtering-Correlation-Id: 1b06ef5d-1755-4d4d-e812-08dcfdaf3ad0 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|1800799024|376014|36860700013|82310400026; X-Microsoft-Antispam-Message-Info: CvuLkxShw9THo/Uw3u4Jf9VNLdZXQ7RQsvIFIdoSu/ZiJ9TTKIT2hTgyuy9R6YNJmL+uRQr1AkXqAbX6pW2MWk2tgGTaxSRrWbuPqDDusrdRD0Z6esW/4q97a7/P0NrNxwoA6JqFcPgI7NGbUQyvArvSyuvvAhRjwW96Lth50AOfds8qdlpFGGvTc2SE0CRqzrxfU2xYabsmJd3heT1mZL5USmrRz702Tlj9Rc/9RwpsEV8qMm1r9hBdpUHZg/TOv3hDWa9ZFKP75CAFfJ4mpjvhh0mLaELX/zaeJ2a0NCHWyLb/gRbi3cqEprdwz9I36/ctzqQQ2SkZdPXV+5HFXFsewI51I2ckxfambir2drp7eOkrMPZ8ynoSa6GURc6eLQCRL2LaTgjO352tH6TCgvWjzlaU9KmL1kxLXPDMqhQ8WhcvEBRPw4XlqZUbOB0f233Dr5MmlaZ3JmVEICjiJqUUlWRHLbFhCXWFsputOxSqvacKIyCYQA6GZJAqRub4pd0sgbzY+Pu6bTrSi0mr8oWUcovvbpknqiuxZbAjhxUTn9Nu7VYPRXg87Voz/4Hu/JV4nBlwDOvYQs9M/nG1R0+GGD26d3+CzG5wMqNyeWvE/P4UentDTlh6d6VNpjhQV5FF4ks2Qa5rGdhOc4I/GauzrI0W39J8snkTMzPKhOknUPzqZkzXxjJuEzP+kpqUlDBMqWrED1HQjB7Rig46J17o6Zmg81C7NhzUH6ZfRa6xbftwAllAPCsD4rkDT50Ioga1tK7BneCPTl8rMtqiLb+ZBKIoJJelqioV2Oo4gSO9TfXn8UKk1CTPPppTRp2shlqjJdQT92NFWD7QbXHMW/VjoSlngzbQsTzii7we+dtuDfrkHWEAx5wOPOq3v8mm7SKU9pqJ99cmK9w0DDGks4nzL3gX4bGtwIlElkZasJQBlYE4FBwtNkdvaoERW9k9zi8KiiXYC5EwqIpgzWFB01WeSYJ9XIW4Dlk5coKBAaha9GLQTIguxQVXd1PUF9flcN5dw6ofglXW3M8lObpmCK+m1PLIBqDrHgBk9TduKZmtOHP6r6d0MEarvb0yxpYLVoUL86p4ktDhmSnYiWVChQVKyFCGnRUVDjxsmZ0r9QxP1THYbI/g/WPLpH4h/cobsbMa9OnZBI5pDIbXTHEt7Lf7GiRNfx5Oo7sKFewiKUvjMchrhFYib7OHlK8A3qypRO4CbzF1L53ellcXrBOnrl1POU8svDTJ/7HqMtJDiq5BXs2CDMX/VWsL+XCYBjzuVgS+yPk7edARvxHgAZWZfu3nLvftX8UV6Ns0OexEaWqjVDi5WqJrehkLrwgCPuGkvfunee6CovI+7Hglmy3kmh6Je5cKBWhrnINNqAqU6Gdnx8LfOyLaLOQLaBcmrctoXddV2hNGevx5o64JcViZHg== 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)(1800799024)(376014)(36860700013)(82310400026);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Nov 2024 15:33:42.7016 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 1b06ef5d-1755-4d4d-e812-08dcfdaf3ad0 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: BN2PEPF000055DF.namprd21.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR12MB9455 Reading and writing the `profile` sysfs file will use the callbacks for the platform profile handler to read or set the given profile. Signed-off-by: Mario Limonciello --- drivers/acpi/platform_profile.c | 118 ++++++++++++++++++++++++++++++++ 1 file changed, 118 insertions(+) diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profile.c index e1b6569c4ee70..79083d0bb22e3 100644 --- a/drivers/acpi/platform_profile.c +++ b/drivers/acpi/platform_profile.c @@ -65,6 +65,78 @@ static int _get_class_choices(struct device *dev, unsigned long *choices) return 0; } +/** + * _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) +{ + enum platform_profile_option profile; + unsigned long choices; + int *i = (int *)data; + int err; + + err = _get_class_choices(dev, &choices); + if (err) + return err; + + scoped_cond_guard(mutex_intr, return -ERESTARTSYS, &profile_lock) { + struct platform_profile_handler *handler; + + if (!test_bit(*i, &choices)) + return -EOPNOTSUPP; + + handler = dev_get_drvdata(dev); + err = handler->profile_get(handler, &profile); + if (err) + return err; + + err = handler->profile_set(handler, *i); + if (err) { + int recover_err; + + dev_err(dev, "Failed to set profile: %d\n", err); + recover_err = handler->profile_set(handler, profile); + if (recover_err) + dev_err(dev, "Failed to reset profile: %d\n", recover_err); + } + sysfs_notify(&handler->class_dev->kobj, NULL, "platform_profile"); + kobject_uevent(&handler->class_dev->kobj, KOBJ_CHANGE); + } + + sysfs_notify(acpi_kobj, NULL, "platform_profile"); + return err ? err : 0; +} + +/** + * 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; + + scoped_cond_guard(mutex_intr, return -ERESTARTSYS, &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 @@ -102,12 +174,58 @@ static ssize_t choices_show(struct device *dev, return _commmon_choices_show(choices, buf); } +/** + * profile_show - Show the current profile for a class device + * @dev: The device + * @attr: The attribute + * @buf: The buffer to write to + * Return: The number of bytes written + */ +static ssize_t profile_show(struct device *dev, + struct device_attribute *attr, + char *buf) +{ + enum platform_profile_option profile = PLATFORM_PROFILE_LAST; + int err; + + err = get_class_profile(dev, &profile); + if (err) + return err; + + return sysfs_emit(buf, "%s\n", profile_names[profile]); +} + +/** + * profile_store - Set the profile for a class device + * @dev: The device + * @attr: The attribute + * @buf: The buffer to read from + * @count: The number of bytes to read + * Return: The number of bytes read + */ +static ssize_t profile_store(struct device *dev, + struct device_attribute *attr, + const char *buf, size_t count) +{ + int i, ret; + + i = sysfs_match_string(profile_names, buf); + if (i < 0) + return -EINVAL; + + ret = _store_class_profile(dev, (void *)(long)&i); + + return ret ? ret : count; +} static DEVICE_ATTR_RO(name); static DEVICE_ATTR_RO(choices); +static DEVICE_ATTR_RW(profile); + static struct attribute *profile_attrs[] = { &dev_attr_name.attr, &dev_attr_choices.attr, + &dev_attr_profile.attr, NULL }; ATTRIBUTE_GROUPS(profile); From patchwork Tue Nov 5 15:33:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 13863089 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2085.outbound.protection.outlook.com [40.107.223.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 74ECC17A5A4; Tue, 5 Nov 2024 15:33:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.223.85 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730820828; cv=fail; b=diC7JnCDVYNx0dbgvY0sBIetB3E8mVKgB/9Ai96gNmq/sLWYx8mwWpNF2cBUV7TJWTlaiWHcQen/tVcHwps9RVFgzp8RV0JlxuR5tliEdciEGLOSLWpzjWPbPwo3m/hC/LFb7R19q3UxeYJLEsngpfz5Vhr8eF/xolrmugIY/Zs= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730820828; c=relaxed/simple; bh=ma6d5NxwyV3xz0uFiVwWHAoPzdOxFIKFXHz9yd0C6P4=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=A5Zk7k/HBLpUOlUY9nXZXkFh2G7k6NCnJQ6fupaR4IJey840SgFfvSosTFr0B5lzyW+xNQpCxn6DIR2mhTy830fJk5qT/sHMLlZN7q3p/XuuZJQBqnCTy4n0ZhcVpeLyTJxlWiaIOPiJbfkVaxqfIZgmF9O+rrWLyLoXbUT3WM8= 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=mOD2Edm4; arc=fail smtp.client-ip=40.107.223.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="mOD2Edm4" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Qv2nBvxEYkPKB71wMpYDe87JHVmB85c/rYW2ygm+DftL25PMk15XxDJ76KwQdWnWrJHrr10I9mO0F8/K2+6veiGdj/zqHlDEYNPk892+68q2S5l8va7VXWpu77esBRBZZ/thfN3fsOcX3bQysYTK1VijrLU8ltWXwXHXurm3TQVH74YyFPePEJiwK2uZVhFUnl3kUCM7wNS0q7oEajOhUpcvXLe1NjYtatvUxry+k1boC2ylTMTsdpXRzg5R1S9SNlAhXsyR1cjAPyVJ2hZBT6CAzUDaJH/MLSzG9KZx4ajJvyc2ZqoQv7Lzh1kJQIsg2dexzb9dmw2xL6a8WMiRVg== 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=7LMnJlDVc5gGEZL8b37BBEZ+USZkmvhj/BqsNTn8yQE=; b=g+w0CJAFm4HTXCtX22QE4lLvMRM584J7kolRTUwa7JwH5DRMOLd+732dWYxkpf6yM3s8E4QLdF+JgRNmSSsIoOvuEfiO1blyFAaNb9EKrBnMYRBVyX79tpOT5EMlBeLtk6BOp64ZOmLn+v5WnvKEplPmRrM8WoUIDnEMm+V9fCKuilrEGHofJbXoYEflcIvOACxG7khouAGyrkmg1V+if3mGzviecFxlPNg3wBrqZDL2iZ7OpYOOKkNNIxTpAbidZEt8gP2B9IfxGZKKTvieM4Mgafjl98mKHE0MYl1QFJwdHLk9wHezdSzsTPFaz3HxKbjwqdqjIdXWOvy8+4hO7w== 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=7LMnJlDVc5gGEZL8b37BBEZ+USZkmvhj/BqsNTn8yQE=; b=mOD2Edm4yWz0/WJ7Q/D/TLj4emUZK3XE0fXRIjaXGH+KkOmA+oB1HEG8SoACnA4lt2GUPaIhDfUcTwSRfRKhBchFWJfsybZ+EHpZMLWQ404axOQz03h7U3CA7F02dZZivSj4xXq7Wdm81fXp3PIl4/u4UtFrqs1taNMBLs7qBy4= Received: from MN0PR04CA0006.namprd04.prod.outlook.com (2603:10b6:208:52d::23) by CH2PR12MB4248.namprd12.prod.outlook.com (2603:10b6:610:7a::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.31; Tue, 5 Nov 2024 15:33:43 +0000 Received: from BN2PEPF000055DF.namprd21.prod.outlook.com (2603:10b6:208:52d::4) by MN0PR04CA0006.outlook.office365.com (2603:10b6:208:52d::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8137.18 via Frontend Transport; Tue, 5 Nov 2024 15:33:43 +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 BN2PEPF000055DF.mail.protection.outlook.com (10.167.245.9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8158.0 via Frontend Transport; Tue, 5 Nov 2024 15:33:43 +0000 Received: from AUS-P9-MLIMONCI.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Tue, 5 Nov 2024 09:33:41 -0600 From: Mario Limonciello To: Hans de Goede , =?utf-8?q?Ilpo_J=C3=A4rvinen?= CC: "Rafael J . Wysocki" , Len Brown , Maximilian Luz , Lee Chun-Yi , "Shyam Sundar S K" , Corentin Chary , "Luke D . Jones" , Ike Panhc , Henrique de Moraes Holschuh , "Alexis Belmonte" , =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= , Ai Chao , Gergo Koteles , open list , "open list:ACPI" , "open list:MICROSOFT SURFACE PLATFORM PROFILE DRIVER" , "open list:THINKPAD ACPI EXTRAS DRIVER" , Mark Pearson , Matthew Schwartz , Mario Limonciello Subject: [PATCH v4 13/20] ACPI: platform_profile: Notify change events on register and unregister Date: Tue, 5 Nov 2024 09:33:09 -0600 Message-ID: <20241105153316.378-14-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241105153316.378-1-mario.limonciello@amd.com> References: <20241105153316.378-1-mario.limonciello@amd.com> Precedence: bulk X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN2PEPF000055DF:EE_|CH2PR12MB4248:EE_ X-MS-Office365-Filtering-Correlation-Id: 6bb73ce3-1014-4a32-3352-08dcfdaf3b1d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|7416014|1800799024|82310400026|36860700013; X-Microsoft-Antispam-Message-Info: 8T/ysVAj+sKZB55JIzIGENyoNceC/AYqU6XDmZusZLBEFMpJFrzkxK1bOIzHJcf9Hq7If5nrUYfWUneTnQDp2s4w+/v/3IUybO/z1OWd6S/PgPu1+od6jwq9Fv5YHCimdpKV6sQfPCtbYQQkrDpTJgCQuLC+1XHxNfysCsooNwr7KVsSO0OBQrkRx1FCzz+hKfMMMBFRCiHRheQbXG2/FqRTtm9oAMYtWb4AJLQzv+w/R/8q1kAGIxoCNxqYJFKMUpRyL0NrKOg6y1xeYfzRLFHNicsorOa0GMe4S4jsIvYJK8/8Wqhr5XUvQmWMw9I/6OrjJcBXcdeeXvJsaMw12LiO/rcPYIAtubjFIzNnFMceu7Bv+SVA4nlEKOaDvH4Q11t/ORKyWIgwNrl58EhNnwBBl56L0OTq2+9LAgRWMqSBbu63ItZq9NumFaJbU86b8ybaBVbx94N6YByq84+zNG5X73AZ/p9mpfH81Hvn+vOHr+hC7NZgWrcC/6/5T81DtZvdaFhHRWYm6BkiGENvTaNu9TF1G47Q+1ALfxZMVwNty5P8v27RAOsfnDLq2a1S2NJUxgRIvwZiKKHtwUX4uLvyJlQU+Go1H4vNa6D9aHpdVZt4TliY3NR3jGPCTLtGZJMd1O4nytsfQ/7KC9GB7CDqJi8Vlw8iLsBdPdIriy+J9DZg4bjR5PVGGzHLX9E2FrTRS5WfYUWXuynoSmYdEfMZ4x7hg8fqYcSQIL0s099dNb4RRe49e2ddfEK2EZVqwR1AyId5g3AxDqsc5i23C9Tx3XlQEicqB5u6VH2QXjcOv3VV8Vhqq92rMwYjlKzgjQ4iG7dnfCrqB3QTLEhEg8CZEe/oE6KenytVeWr4vMCY0wUQzZimv7ZbCRLQriS8PHOkYk4tDBJNkmOUng/CZSwcjNcoliOhDaoJB25SloSP9V9WzAE+XrqO7lu+Tw4QREtUZRzfWK2Ak6OGjv5WuHxfL61SsZxQ1BE4lqpi8sgVyzmbjsZmcsw++bfFf541IVfHsrN5MkebJuJOp44UPyp+6692WqeucvEQ+jkzK6YWEJgD/k/pJt4L4Es8forHx9/X8MQAm2z4UuELqg1/tlszQFKA/80V+Kg56e6N+hv54N9YBwF+eaQZhT8Q1Vu44LJsqj0jPsBLLmxgKDIYRetWZ3ax7pFHLpPMS+cRLDUK2kIjM+JnjE/VUPWpeC3swXc/AEIBskXUWy8eVqeueCWDAWH3zTa/zngYKuJKMtEPjJw9EItk2QKm9mzPGKCoUrl8+I/tpnqxqu4EqohIuTM7Fcmby4aw9GHtv9O3S3UWEifUpEvQSLSUnHTLpeRqivJypDwz8DLAq7O43Jql7j9uita4rv9WmhVdlCeb1HCGOeAXwSQUptllXHQCY3rDQCEGNCaLVPVfiYJDsp3FVA== 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)(82310400026)(36860700013);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Nov 2024 15:33:43.2016 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 6bb73ce3-1014-4a32-3352-08dcfdaf3b1d 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: BN2PEPF000055DF.namprd21.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH2PR12MB4248 As multiple platform profile handlers may come and go, send a notification to userspace each time that a platform profile handler is registered or unregistered. Tested-by: Matthew Schwartz Reviewed-by: Mark Pearson Signed-off-by: Mario Limonciello --- drivers/acpi/platform_profile.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profile.c index 79083d0bb22e3..c9917daf683cb 100644 --- a/drivers/acpi/platform_profile.c +++ b/drivers/acpi/platform_profile.c @@ -404,6 +404,7 @@ int platform_profile_register(struct platform_profile_handler *pprof) if (IS_ERR(pprof->class_dev)) return PTR_ERR(pprof->class_dev); dev_set_drvdata(pprof->class_dev, pprof); + sysfs_notify(acpi_kobj, NULL, "platform_profile"); cur_profile = pprof; return 0; @@ -419,7 +420,9 @@ int platform_profile_remove(struct platform_profile_handler *pprof) { guard(mutex)(&profile_lock); - sysfs_remove_group(acpi_kobj, &platform_profile_group); + cur_profile = NULL; + + sysfs_notify(acpi_kobj, NULL, "platform_profile"); device_destroy(&platform_profile_class, MKDEV(0, pprof->minor)); From patchwork Tue Nov 5 15:33:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 13863093 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2087.outbound.protection.outlook.com [40.107.237.87]) (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 2EAF41D90A4; Tue, 5 Nov 2024 15:33:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.237.87 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730820831; cv=fail; b=V91ZQuSbBgqK+4I9nNj36b/PMyELS2NjP07ogmHM5iGm9DjTIgiilrdwUrNPkbi4+vY+UHKeG2gT/vgk2QpANblesZsruBAIaoJkopG5sMELXD81xS8ShnfH2yEM0aeYNhRXhTYHqMBeq8payTHh8kbP5S+LaKMDHfBWnJE8J5E= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730820831; c=relaxed/simple; bh=bea7+oj/yKdwscoVFM7DQQ3Vx8PXYMWZ5pqVEEdBUNY=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=YjG0lymvBtU8TJSQMxBMYTwiXNOZcBjAWkm+1BEetMwzkbELROmG7vlN70dzgX18ChPHWJ5slWCKoHnQXz95NQcCOe79xayjlRoXszryOTsbimJkYLtsz+xIFfr/TEGEsOge1jYAjOhtYYcEqTdS7xZ9wLBcPj0Xl+AKNB7z22I= 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=O5cMdkN6; arc=fail smtp.client-ip=40.107.237.87 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="O5cMdkN6" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=flMH1Acp1dYzHKW8Vdc0xZ6IbZRc9vhv8l0Qk9oPpcpYerESmhszSteAxGnsfPZ2iq7gsFLlZzmOaoVSL5T88hAM6018ISMD3xCbKffMk3Ttj5TKJn9GBlSo0FkTlKYHfOFi2wwr4zhhWLhI6A0ug3aPONUeAPKm69m6Dc33XpYOck4gWdHcSeoglWF7RG0lOj2y29WUQrGOi36G12wZHF+HkhzANe1tUDvVebfIc/Q0rjnOa8GGEPRSYPut4pHD0J7vzQFBuf/UBeIxWmwRT6lydVX+2tm+wBSFV4AO83RDFQNKxWoJdPdhnXgCIRfSlS9rxqZ+vOQF4gUBFDp9rg== 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=QC/7QRb8PV1yuawMDK+R6YepIHiT9JZOu655rTlMd5w=; b=onqXbYxhDJjIY9jrWcMru4/4z93pjpmgOjbUv+J5pYR5JdXtAsS8/G1m7DuboMuKdNn/8me9X3Hik1qAgHm9YfiMiNNnzaZxBs83+xulxZI16fOV9hCecLKliYkQvOz30rM9w8TtDz4VAOXqa5ZM7QH3boPVMFaTJTMMfh6duABaV98hNaTSEVHpffCoTrsyuQf1hOvN0bPJvFZPd+f22+ijg3yWTyjiljMawPVG6LvhTyDJ9Oo4wz3KFhOK2GmJiOuy5nUR5jYNy7asiV3t0h/nK46oOtfKqza10tQFqaZa+/T+5FgYqVaWLig5p7GV4OmVxq7aYse9L2/SQfJNLg== 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=QC/7QRb8PV1yuawMDK+R6YepIHiT9JZOu655rTlMd5w=; b=O5cMdkN6XTNsMfUybN68MfsQlJq4rM7G/7zURyDF5VgWtGVy4v02O5deXqqOthowgw6TPJWTlU0wFkEJXbrjolRn5V4SZ4xiarzhrrMAF0o0x9DsnZuGHfcPNPdvyHWkanVF2SES13z6rVaRow6Vdeu/hhQ1gZIr8C3KHLe4d0I= Received: from MN0PR04CA0014.namprd04.prod.outlook.com (2603:10b6:208:52d::20) by DM4PR12MB5724.namprd12.prod.outlook.com (2603:10b6:8:5f::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.30; Tue, 5 Nov 2024 15:33:44 +0000 Received: from BN2PEPF000055DF.namprd21.prod.outlook.com (2603:10b6:208:52d:cafe::cd) by MN0PR04CA0014.outlook.office365.com (2603:10b6:208:52d::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.31 via Frontend Transport; Tue, 5 Nov 2024 15:33:44 +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 BN2PEPF000055DF.mail.protection.outlook.com (10.167.245.9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8158.0 via Frontend Transport; Tue, 5 Nov 2024 15:33:44 +0000 Received: from AUS-P9-MLIMONCI.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Tue, 5 Nov 2024 09:33: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 Subject: [PATCH v4 14/20] ACPI: platform_profile: Only show profiles common for all handlers Date: Tue, 5 Nov 2024 09:33:10 -0600 Message-ID: <20241105153316.378-15-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241105153316.378-1-mario.limonciello@amd.com> References: <20241105153316.378-1-mario.limonciello@amd.com> Precedence: bulk X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN2PEPF000055DF:EE_|DM4PR12MB5724:EE_ X-MS-Office365-Filtering-Correlation-Id: 2d9754ca-d5e5-452b-7ba7-08dcfdaf3ba7 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700013|7416014|376014|82310400026|1800799024; X-Microsoft-Antispam-Message-Info: At4D5pdUM0KpNDuiG9tHBJK2K6wPe1hBfTi1qQf4Kc9BDQnU1e2a2VHNLOxMh6BqwgI3LMQgb85pjrjHLft8tfl+B4v+R1fHDGINqovjVpGaS02896E2NN/xCa8txDbO7Q7btIIMBbsKag7WW+zAaExT5SFPxR/JV6Nk4OX62vrrTJkNAZOVauxsWRMLaQdEYygLy6omn0fpPBx/sf8vQXmZ0tSRXCnjAtXzXfStt79FBrl1blyBajHgw7aCKssHyvHfYPOgIxHASBAqPCks738p+pcdKR7st/7BeQqbtzyPEkE5sSUb41uuH8svilsNHq0U3mYyt7vvU0+Dqm+OF4Mgy25j0VwM7E6E1bdSWZvKTMu+dVijcMtNK66UWj/WbsjFJzDdRjm6jIptZc3I+b27ejMrstUW0kqfggb5ycmYDiuEaQ+xaLfV9ORTnQHK03yryRHseGDJMtdekBh938NG3fvOP9zSJlhEclM8xgbBCmJjtNjevB+1mZeYVSVgPsHHsgaCQhpwZfQBLX1KS5blq6EYK4soe7q0+VRVcXOgOVK0FBTZ086b9MUMOheajzNytiiJQavLJjkLKBq9jRLIChJjeIQNOSktYXseJhFc39s64391kUl6NaRlDQByRQWDDj3mJPwTRBa7q/OiRUu6ipuocGtmr1GJMonr6lAi5c6vHTqhB4ZDpQHE6XD7rJGYl8k6KthlcAuQ+ICF0c4wzAdueMIARWRztBtp9xLklsUiPlTNIyh+/C33ENAc+LNWM7zpEpc1jBySUkMqX687ZmIbxIfyiSQIUbI6H2Q06+/sxZoeKDyFjm8VtO4amypuPvqb8YMUOo17JolxGmPRDGpAzF9nzq+Q19cQ8YrpJiMxWy/cHA2Rg9dn5oiOGd7TLqeqL0tl2hAofAm25We+qMrOo2nxKlhuUQM1gqBWTtbvUVRC5BL5WfcP3heqJjGcZ8UFelWtpI9V7FQM3WxmZ/5GECJsBx7cjF51bMEX6g4wAZyaFNNUY6DzSPkthAErTvUrLab5dvkHB38eGjTKlkNSXxo5AcamqoseM4BAgZQLT1Kkr32+UDJzEB+R0BhAXvDSUD3F8JH8HvdDjmi9MIWSRF3F4KRol80gpawXDx9qx+YfuHoWoeHbUFh3hav3+InOCnuxE0sfhOT0LIIYEhe9w72O94PtyJPYytotnHEaqL5zkQuY5qYqMr++spyMe60tdseLS1innR0W80EiX7mM4BKjl+ZSPyktMDvDPksi+cmeAQxjxcHlZHBg11IzMtrmdHXOjvYoNyH0lQkcdl4jqOpeAfLZg3QgmFqg7LXeeyScfjWfdM9iAsopKN1OjUZ6iksG93oPpGMJnVn14ND5P/ikURiMKgLJ6SXnPp7TsD3npVQFPY8ZTpMpjrBfmAlncjTrHRMqMUbR6Q== 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)(7416014)(376014)(82310400026)(1800799024);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Nov 2024 15:33:44.1078 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 2d9754ca-d5e5-452b-7ba7-08dcfdaf3ba7 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: BN2PEPF000055DF.namprd21.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB5724 If multiple platform profile handlers have been registered, don't allow switching to profiles unique to only one handler. Tested-by: Matthew Schwartz Signed-off-by: Mario Limonciello --- drivers/acpi/platform_profile.c | 55 +++++++++++++++++++++++---------- 1 file changed, 38 insertions(+), 17 deletions(-) diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profile.c index c9917daf683cb..8de7c8352673e 100644 --- a/drivers/acpi/platform_profile.c +++ b/drivers/acpi/platform_profile.c @@ -235,27 +235,48 @@ static const struct class platform_profile_class = { .dev_groups = profile_groups, }; -static ssize_t platform_profile_choices_show(struct device *dev, - struct device_attribute *attr, - char *buf) +/** + * _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) { - int len = 0; - int i; + unsigned long *aggregate = data; + unsigned long choices = 0; + int err; - scoped_cond_guard(mutex_intr, return -ERESTARTSYS, &profile_lock) { - if (!cur_profile) - return -ENODEV; + err = _get_class_choices(dev, &choices); + if (err) + return err; - 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]); - } - } - len += sysfs_emit_at(buf, len, "\n"); + if (!*aggregate) + *aggregate = choices; + else + *aggregate &= choices; - return len; + 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) +{ + unsigned long aggregate = 0; + int err; + + err = class_for_each_device(&platform_profile_class, NULL, + &aggregate, _aggregate_choices); + + return _commmon_choices_show(aggregate, buf); } static ssize_t platform_profile_show(struct device *dev, From patchwork Tue Nov 5 15:33:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 13863092 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2043.outbound.protection.outlook.com [40.107.243.43]) (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 2A370126C0F; Tue, 5 Nov 2024 15:33:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.243.43 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730820829; cv=fail; b=NqElhn8s+ryCpDmiY/b1A17T/Ty+GrdUb93d3BN3C8oNgQRhKuMRCfUBBdsauqKpN+/27l6C7fNiafaJdVKO92dnBnX7onNvbUyEJhFPQV1dx6d0I6M0xKzLblXGu13YZ37kTvNRLZm84bUmKRmDl1H7bmTNAFEx9U+93yTExcs= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730820829; c=relaxed/simple; bh=Cd0g23FeVtwAj5O4/KHsSeyaSM6F5ZMiE2xkf8UVSBE=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=OpTvkEvCA5Cc9o5lmYZrUwqdY/VKPUynO3JWDM+zWOvi/wqqDQIf3SYInoh9mPS5pcOUOZhn5YiatIrjRlpH6kQn4MwT60P8dyEPMWLXliv1gRRnUk+fdqUVcMWNPGoHoP7tbZaqpAQoXT7AYx6xPkurSnSG8/tu8oBDOFajqRA= 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=VdBfmK6f; arc=fail smtp.client-ip=40.107.243.43 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="VdBfmK6f" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=LpGMVVYC3XDxEfrW1vSwvh7NPyfQz5t7gsWSnTcTDI3+7o8/AQCSya28v7dGwUTqhD0MznQ2NJpjMyokCCM3uoTo11mEhBf3QCgzOL4gHMFAl7/j3wAO4RBNVVemuO9EZYme44GGr5rh0CmLd2Fydih8f1jLi1jK7c2FUMmiuEIfiT+ScgQeOZjD+QaNVJl0++glk0WYMkOoDWiHZGA7Kn/wcLteV7RF0TmR8NTopMwCK3MsQhf1wFUz+08tDuy1kRZ1rwFemCbDuYIw+kM1gdjSwDPb6yOIYkpRSSXXBHsq+9Ku5BBnBWmykTR0hvLLFCaUpOmXVX9WtkCmql0Ppg== 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=S3aTvu3Ec310NAKYMzm+n8TYQ55+AteNFEeMXomJjW4=; b=ffMWKetZYU7zJh+3lwUPHpknBsffrErqStljvswWjDNHu3DN9g37RQi7sudaHy8pXQEsMUIyBMiOrf1gYx9O4I3N86zQOnDad7ATrH8xjfCj3PJS6b/YbAPKiZCaPmzdkdNOPBkkd78Bqb4vAvCj8mi2ryRgfdAZf1UU9HB+w/2H+KNZO4wQh2anNLzdHLwwDQN5gM9qZKPmyQt+XZ/gIlku9FHp+HBxntoZJPMN0HPPdOMKkGpOqxh8iorRofMCnT/4xyIs93dOO06tHEE8xDo5Q3rpTH99Zz3mLIz1Flj5JBOkgUVQceK+16LNlNDG30ujZqwcbfaDl9cYvBJE/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=S3aTvu3Ec310NAKYMzm+n8TYQ55+AteNFEeMXomJjW4=; b=VdBfmK6fNT4WgnjPBZawflVDShzb+f2UyvWNdFaIwolXvxkH5CW0pNicfOEfKetiFPY8VuvvJ8C/U5SnDOrxNBhYy8OP6xR/vpwGJYIFmJXk6nn01W/5sHJ/3ofEv2nNKHDtkihvG3AT6MSN+EO51U+licDSP2cukhvbB+C792o= Received: from BN9PR03CA0544.namprd03.prod.outlook.com (2603:10b6:408:138::9) by BY5PR12MB4275.namprd12.prod.outlook.com (2603:10b6:a03:20a::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8137.19; Tue, 5 Nov 2024 15:33:45 +0000 Received: from BN2PEPF000055DB.namprd21.prod.outlook.com (2603:10b6:408:138:cafe::ee) by BN9PR03CA0544.outlook.office365.com (2603:10b6:408:138::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8137.18 via Frontend Transport; Tue, 5 Nov 2024 15:33: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 BN2PEPF000055DB.mail.protection.outlook.com (10.167.245.5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8158.0 via Frontend Transport; Tue, 5 Nov 2024 15:33: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; Tue, 5 Nov 2024 09:33:43 -0600 From: Mario Limonciello To: Hans de Goede , =?utf-8?q?Ilpo_J=C3=A4rvinen?= CC: "Rafael J . Wysocki" , Len Brown , Maximilian Luz , Lee Chun-Yi , "Shyam Sundar S K" , Corentin Chary , "Luke D . Jones" , Ike Panhc , Henrique de Moraes Holschuh , "Alexis Belmonte" , =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= , Ai Chao , Gergo Koteles , open list , "open list:ACPI" , "open list:MICROSOFT SURFACE PLATFORM PROFILE DRIVER" , "open list:THINKPAD ACPI EXTRAS DRIVER" , Mark Pearson , Matthew Schwartz , Mario Limonciello Subject: [PATCH v4 15/20] ACPI: platform_profile: Add concept of a "custom" profile Date: Tue, 5 Nov 2024 09:33:11 -0600 Message-ID: <20241105153316.378-16-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241105153316.378-1-mario.limonciello@amd.com> References: <20241105153316.378-1-mario.limonciello@amd.com> Precedence: bulk X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN2PEPF000055DB:EE_|BY5PR12MB4275:EE_ X-MS-Office365-Filtering-Correlation-Id: 2590f222-c1e0-4e68-4cfd-08dcfdaf3c3e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|36860700013|7416014|1800799024|82310400026; X-Microsoft-Antispam-Message-Info: qDhSwBkIGzo01cErq1GPEi4Cr6B/8wDFLiYmawQX8EZIMb6+E4TUgNFbIEvU64qlY26PhsUMZjotWT76v7x14BbydcLXF/nuABtVYRbatqqE8n7wmwLWyFAAFjYMLyW8dkAk3xgY2Sce1n0U7DgTz6yQAQ7UvsFV2XtBeotQE5nnqihZQd/u+tc7GmbV7kkyb7oRHQrldQlys+MsHuFW2EaJG3tYKWmL1SGIApinYVIEV4pwyQkEIuDQc2G5F1FMnmknDKaps760V8IKICpocqyYwHfpD1pcsYm6TUGdDOqf1ZUXjHvwpnCJ1lMlDGoKi0/O9FU4eVDBvx61TFtLe19SaoYeN9Vhh9BwoburqYpsyLKRWkjAs6Xp2WkHX5pbgLn0SPqlQVyDsDQfJ35NUEAjTz4DSDg9jGW6PhhQ88+83szojWR1fDXnwjZ8nECwIlM6kV7Rxo7CUf7C2AMYNnxj9H3WrAYFYJUpm1NyIrqOyv5I24e4NUI2clp9rkr51c09dN2fmjSB0jhk2qkxVqwIUfU/3Y5Z65vmbxccO6GkvzcXLza2AV6RpPyLGjTmfV6zllnCluhB7vC9bGrYDmBOt63rHXXEu7sarC0aHszMZLo8YJy38ESTrwd9A33szHOKBtVFfHIUhmn7mttT3ZWgqq3cVIKtexVMP/fMt6lLAUH+8fnru8e21+Z/92a7zquPG01/6/06/mEQJzluEpwEciVwVMBFV/QlcpbtsuKxSLwfKhFYeDNMxVy3UPg74Dt88NjmGpQLYZDeuXWJmYregZ0Ngcn3kj3dqsA6XRgBx/CPk3X/UpVnZe0IKOfWGh8UrWgkGW+h9ipJhEXZ5tMEXm9gwI4GdADWdsJRHO3bHvE+gkpd+f0/2N/7mYB6tXi+bXy9XBEFMy9zK7jAZ/l9RS8vCwdOTy9fQih1MDyxHGMWx6gv8sG+WaNHcC/qRae6Am3l3xxmaUXsUBS+eaf0G/YAYrATgrjCY86iQdMbAxNhXsySo+ka22lP7i/PXGVGrL36mG2NEiX3U/1GkOclFHLB4PKp8iCjhy6KBCGZVKd3qHtoCZQ4j7agUB+rJtXbVD+KyoOAAPbZqnyL629FQ0O82IXlErAACZfZSmqwLg6s0EQjxdtynKFZRnk16qSwu6Akfc+KFE/S0Ca7Fw1TcuTDZlV1PX2DqlR6r9U8I7IcIZCtiwKGFeLQ1xeseUIxssa2KtMJuTZrdLSYWkAXihbiVTWff3cQsfXnBbPvJJsq2SIRlLjiFz9WZAsT8foy18ChJQfJgj76wVxh/SbJnEv9msEt0xOC2JxONBlTtmXsdwKHjt7j0BTX45xbO2CLsUC6fz/BYfTBqOrGOIMaBZ3RqE2PtMCWXtLqMvZKuOqNWrtUt/M3MDENhwCKE7FlOZlnEdSA5fc6Hy6SFw== 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)(36860700013)(7416014)(1800799024)(82310400026);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Nov 2024 15:33:45.0962 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 2590f222-c1e0-4e68-4cfd-08dcfdaf3c3e 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: BN2PEPF000055DB.namprd21.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR12MB4275 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: Mark Pearson Signed-off-by: Mario Limonciello Reviewed-by: Armin Wolf --- 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 8de7c8352673e..d8c2d195106c2 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 f81c3afcb7575..d2a2ab4c6cee9 100644 --- a/include/linux/platform_profile.h +++ b/include/linux/platform_profile.h @@ -23,6 +23,7 @@ enum platform_profile_option { PLATFORM_PROFILE_BALANCED, PLATFORM_PROFILE_BALANCED_PERFORMANCE, PLATFORM_PROFILE_PERFORMANCE, + PLATFORM_PROFILE_CUSTOM, PLATFORM_PROFILE_LAST, /*must always be last */ }; From patchwork Tue Nov 5 15:33:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 13863094 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2041.outbound.protection.outlook.com [40.107.94.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 491931D9669; Tue, 5 Nov 2024 15:33:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.94.41 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730820831; cv=fail; b=RJugFZlVpkik+IWyyCPvVKLYi3ZHgbThH/JWqUYkkFpXP1w8DwE7rVptYzeVL5spnNepaVxzwRKsVY7dpFcWmmKJVk3Ig5AWBgOPLtHhaD0iXLB1RpX5acO2W44IzKr/nCtXb+Q2jKxAjAB+nRPl+3AbHxib/tVyL8S4ir352Lk= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730820831; c=relaxed/simple; bh=7EKQRIUFbmHdiD7bG+5mSsPZ+0rhm2SGPEQdCXLXBT0=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=hB5cQ3hVwoh490LEulHsVMcWjRMjHsXGusHmh/LT39HSAi93Ek/s2O2wt4Lf4x0KlkQdGARudzZ2/TB/hiIJ3vlPpQtUAm7mDpndY40Qaam2c7Mbj0ujKdsK8rtMDajgEzoTl1nSfzRKLSxd9POizk3ADa6b6O09I65HyBxmLVw= 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=D5K7I3H2; arc=fail smtp.client-ip=40.107.94.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="D5K7I3H2" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=ZG00jN3UAU17rdrHhLUxzjeF7/L8U/zole5GQM29CwCXbLqsZBdJqwoW/sAaFmKvO6l71relvfqNdd3j0p/vpixb7fpfNh3kWKGnZo3Nzpo3/DxpP8Xj+Dg0Mne45oziuzDaAWn+k7K6LRoIJFRM3UUA3O1jX4K3Q5UENfwoytUBbZZ+yOYWfAix4XqyZ7nycTDoRgLEuR08YA6DFJ2QBxtp76d7lEdqnvSSm9h54pWBsrjFPSpU+ggYFReeXOGEg6LlRjPZvQE37Po6kMECluyQm0M0VykCVDOeKMxvvIrx/a/PZnZ6a1TEVxPpu89gzBRdenygRflZ6FYXC8lGwQ== 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=VGwvhOXSQqEMg3VRy0cWLQm0Ref24Xtdqg/sVQL/t6s=; b=NR9/zA69+u25JM/OskPGagowcEGefXeZom782+iK1Ee3kS+y/Z/+CTePDc9qziVMThkbAEA17SHGSW7xa5jaVIw95XseMZo8wCUfoelFEKmokBrA03kYb/QA2dktrVRPK6c/0uLrFJWn0ZO800G07O2ZtRenXQYNeTSsiG8NHLXPiMCKYwqJcIlqFEgMIvXYCsyKRpsrU7iG4B3WXGpAyuRkpHeKSpq9pku45D7PQytmPPRY2EcL/ihjz6BMZZW3FNB1RX2s/iloX+prY+fi/AsCbMZmkItivdJVEuD2girbPSsiwgICTk5MEJUUwAdRRxEDcw84VjjEJqdYuLHPdQ== 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=VGwvhOXSQqEMg3VRy0cWLQm0Ref24Xtdqg/sVQL/t6s=; b=D5K7I3H2sfQNGnBPlFANtKmoHhzql504PK+HG4AhQLj2LNmcPVArWiEmfrDxbpv894wGm6NteFu1PbmYjRYetPrnjsrjd1SAgu0dDZjWYPX0IWAXTOfy4WZlyCAgs5GLG98Q59FTGYcMh2mVI79CxdDGSR0xIlIxiNJIqoUnUgw= Received: from MN0PR04CA0003.namprd04.prod.outlook.com (2603:10b6:208:52d::15) by SN7PR12MB7179.namprd12.prod.outlook.com (2603:10b6:806:2a7::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.30; Tue, 5 Nov 2024 15:33:46 +0000 Received: from BN2PEPF000055DF.namprd21.prod.outlook.com (2603:10b6:208:52d:cafe::f5) by MN0PR04CA0003.outlook.office365.com (2603:10b6:208:52d::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8137.18 via Frontend Transport; Tue, 5 Nov 2024 15:33: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 BN2PEPF000055DF.mail.protection.outlook.com (10.167.245.9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8158.0 via Frontend Transport; Tue, 5 Nov 2024 15:33: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; Tue, 5 Nov 2024 09:33: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 Subject: [PATCH v4 16/20] ACPI: platform_profile: Make sure all profile handlers agree on profile Date: Tue, 5 Nov 2024 09:33:12 -0600 Message-ID: <20241105153316.378-17-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241105153316.378-1-mario.limonciello@amd.com> References: <20241105153316.378-1-mario.limonciello@amd.com> Precedence: bulk X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN2PEPF000055DF:EE_|SN7PR12MB7179:EE_ X-MS-Office365-Filtering-Correlation-Id: 25c1324b-6a97-437f-bcf6-08dcfdaf3ccc X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|7416014|36860700013|1800799024|82310400026; X-Microsoft-Antispam-Message-Info: k1V2uhwFq2v9YDFmC9P0CI6S+hETFP0WqdjM+muYchc2XHr1FypmCkXelHp1vZacdzp6NwjFT57KT/gLE8fmBH622z/OiDsG5qEcCGIoHuiuK/OAHPIcSijyUdwncnz5nQkHIfiTOh/JaqP34SDj27KLF+Da/OJ5er52d3h3c6kFraN1+BfbotNcTVjaZ7t4pyupoGY48/4VeD3WSxbw4u+YGzrZ7dViqBEQOQvWTxFbMQzDU/KqVt0OnIkxc2f3Fp6TQxyxMMmESvrgfLsJSjGPVXGqis8qWJjVavgMtBZ+hnQBfuk2OXb63FKaZb/NPg4lN6T82dHP2d8x6tXVMJkusXDuN/Dqc2H1aBL7ft94o0rmbs3qh2iuBHiLcQcXHktZTiy/YOEZqEF4714h+ihUpSIdhTEFjoLgkhyDTYADO5A9v2u0RBOsC9R1p31M1Brvw9oQOB7I+X45U83i07k+PKe+qrbqP0SyqKHLPoAk7xokydoMwXjLL4/WawrrraXYzAXcIUliPhG9OGM1JHn1Fw1le/HR0YISWpdpYYAl2v5m2tawMPvRmquet3bM9Sfi6cm3gzGbK0yAE0zG8H/3Jf9AH7MQ70tH98afhLrcqZ3MF18ps/pNhuDdeRdsFRUp85nPUVsXyIl4RX1qVBfNorCU1jsgYIGQxkhl9Wq6654+umz4MY1mAejaF9DyDR6sRW8eYueYJ0AsYycLRSuiE4KbhyA6lfkYNEPYYv2TIOMQXMVXjQnAJeY+yYuJ1hWyo8PKI7lZOUlP6df4kAvq9ECfLwLPu1tR5ukbsT+fkxQizir9Y6xQcAAp8/fA617tqnLc7Lds+4Qxm3wD3DTAoJD5z6Yu9Pp6VlWcU/9oknXkkYkF1GDSPavkcN3q/BZEmBRgVRDUprA0bh1cLu7F5vzxoNqv0PeP5MqmjlY4hBfD+CuZwBb9CxNz27yBtxQn1ewtEZ87RkHr6WTuUrc8eNlY2CW9C9teMZ1NYSm4n97YV8SYALHYkWl5GvHOaLUxyjvk+bw9a6ANE9OI/G/8xRTTY7Y5kcHOfVamJRCYAQMGxqMOXDw1nLwU4nPWT/XUzaHKzRtJe7C5qTzD8gaaDzubuEGjdgjT5nkvjpJvi2P5xrnXDmgL7OCWsRRsJT11biPjMUDqMaYg+qYUmS6ptLw9l+uZEBByR/jnTLC3gR6aQxqZ3784yFeQlLl3+wLTSgCPo5oWcXEK/MnjD+EyU8ci0D2URl29gRZDk9GUwJYBZXNSuMygCBe1JNE5gY5aDWAKmkdYkIN9WvR72ANEeEwUqP+gr+STDeDqzaLZziH6959mYCtJn8MPHmXioQme6ZaV1g/51xiCjMK7SudqRa1WnP1FuUO3Ugf3s9chPLzkLjNJ1f+FvQfqFJSkSgb5lIej/gGjRY1Pz/9wQA== 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)(1800799024)(82310400026);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Nov 2024 15:33:46.0297 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 25c1324b-6a97-437f-bcf6-08dcfdaf3ccc 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: BN2PEPF000055DF.namprd21.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR12MB7179 If for any reason multiple profile handlers don't agree on the profile return the custom profile. Reviewed-by: Mark Pearson Signed-off-by: Mario Limonciello --- drivers/acpi/platform_profile.c | 84 +++++++++++++++++++++------------ 1 file changed, 53 insertions(+), 31 deletions(-) diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profile.c index d8c2d195106c2..7861fccc2e58c 100644 --- a/drivers/acpi/platform_profile.c +++ b/drivers/acpi/platform_profile.c @@ -280,55 +280,77 @@ static ssize_t platform_profile_choices_show(struct device *dev, return _commmon_choices_show(aggregate, buf); } -static ssize_t platform_profile_show(struct device *dev, - struct device_attribute *attr, - char *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 = PLATFORM_PROFILE_BALANCED; + enum platform_profile_option *profile = data; + enum platform_profile_option val; int err; - scoped_cond_guard(mutex_intr, return -ERESTARTSYS, &profile_lock) { - if (!cur_profile) - return -ENODEV; + err = get_class_profile(dev, &val); + if (err) + return err; - err = cur_profile->profile_get(cur_profile, &profile); - if (err) - return err; - } + if (*profile != PLATFORM_PROFILE_LAST && *profile != val) + *profile = PLATFORM_PROFILE_CUSTOM; + else + *profile = val; - /* Check that profile is valid index */ - if (WARN_ON((profile < 0) || (profile >= ARRAY_SIZE(profile_names)))) - return -EIO; + return 0; +} + +/** + * 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) +{ + enum platform_profile_option profile = PLATFORM_PROFILE_LAST; + int err; + + err = class_for_each_device(&platform_profile_class, NULL, + &profile, _aggregate_profiles); 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; + int ret; + int i; /* Scan for a matching profile */ i = sysfs_match_string(profile_names, buf); if (i < 0) return -EINVAL; - - 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)) - return -EOPNOTSUPP; - - err = cur_profile->profile_set(cur_profile, i); - if (err) - return err; + if (i == PLATFORM_PROFILE_CUSTOM) { + pr_warn("Custom profile not supported for legacy sysfs interface\n"); + return -EINVAL; } - sysfs_notify(acpi_kobj, NULL, "platform_profile"); - return count; + ret = class_for_each_device(&platform_profile_class, NULL, &i, _store_class_profile); + + return ret ? ret : count; } static DEVICE_ATTR_RO(platform_profile_choices); From patchwork Tue Nov 5 15:33:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 13863095 Received: from NAM02-BN1-obe.outbound.protection.outlook.com (mail-bn1nam02on2044.outbound.protection.outlook.com [40.107.212.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 B8BC81DF731; Tue, 5 Nov 2024 15:33:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.212.44 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730820833; cv=fail; b=KXSwkvNrVQvam/Svvl2JNn9mlLe99sEkwZuVAwf4hD69E0Y5gWVv+vrS8OGu7FiR4ii+MlrOkoPCdjDfrj/HOj47IJIeh5uhVF2FHdc0SFv44iga0usd9ux23bbSWgyXiRU10n2tV7KO5g2kdyx5kWbHLaHfMPPaP6HjbYnQwD8= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730820833; c=relaxed/simple; bh=ny3iW6DOlZU8HQaxcPXox+hKvSEiG1vFhL5CaxmL63Y=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=A3t68pFirN/MQsW2SZK65J3NWPnagbnn85y+P03v0n+RJ5exxktZWmtVK4rYNcCldvsaU/rOV2sjhuN78t6xQDZiyqivrJHwj0lh0F5xmB/aBkuYxkIkkwbMuU0xZkoJ5Jfqt88k32x0ZHN+jDdhHD6UMWapB8MeALtj8gA4jqM= 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=HUphLA1A; arc=fail smtp.client-ip=40.107.212.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="HUphLA1A" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=B7CBsAGkO0bA/5Yvamgt9AKvl2tWA+gtQq6ai5K8fHg9lrHd5fNoC0W0l0T9j0Ov/ErySck3cMmoulKIjJRACQkFPEzMnsXP0QeiE6Q2hdD0rQvCV9InLiNH8GKsQY8Qnn9rXi4AJyqUMJUrPoSdqwezruCgrZrFrHBqAA+Xuyig7TcXEPsf0btxy74rhENm11BoLWYtGcyqhNYjrWffnC+wQ0mUm7IBPb7I3Vwl0aNs7hYLLfkcpAtXXf2ZgK96v6AnGivIXSoL8vw2AJshSOCYeiXDwrmEqrZKISW2ynO2bE8HuOvX0dY60lNtPvptYQ26+3OPNhgk8HNdgxMpTQ== 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=1JP3To4xH/AA3ZnPv9aOvigXqmgNlgcBHoMsbj8A2T4=; b=QUm15SZg63Do0HkbgHzEQl0zZR1kQfE9zMC+2X+sLYVFkZJKIoIwZlmiJtIutFkIkl7N7xLZGYrsh0FWtN2Jt0HPQtKicp+7kNLsczjN7ErIQY+LhJyenaDZ9p5i8IFkLhEA2h/WzbBq8q2S+S47oq/NCbuAk7QO4jntcU9qQnaeFLHoGV7j5vznnGGSoivQ1GGAEJWOV40+EoyQ+f5oP1B9BO6oSdN7qheI0Sel9+8hyL+/xMYJ9CQ4h6XTZ1XCJ+6lnJelbNqmvIaAPAUEyvbpMaKcC6GsLvGbgDxB8draRReqWX6xo/Rl9RwXkWh2uGN0Fdmu8201EHgZkaHXgw== 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=1JP3To4xH/AA3ZnPv9aOvigXqmgNlgcBHoMsbj8A2T4=; b=HUphLA1AekvuGJlXYFpjqVdnk/nYD+Clj8p5dhq0usHPLbpwY8tZk2fujDdL8q08fEVEi2sXbn8egM5FLktR+5sBZCdmUzBSfHzj/ol070p7tU7xUOi3ektNeAiwhHrNVdnoUxXVDOJqC4cidNTk1WPGvbYxtnXM4NSypmerEGY= Received: from MN0PR04CA0011.namprd04.prod.outlook.com (2603:10b6:208:52d::7) by DM4PR12MB7717.namprd12.prod.outlook.com (2603:10b6:8:103::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.30; Tue, 5 Nov 2024 15:33:47 +0000 Received: from BN2PEPF000055DF.namprd21.prod.outlook.com (2603:10b6:208:52d:cafe::28) by MN0PR04CA0011.outlook.office365.com (2603:10b6:208:52d::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8137.18 via Frontend Transport; Tue, 5 Nov 2024 15:33:47 +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 BN2PEPF000055DF.mail.protection.outlook.com (10.167.245.9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8158.0 via Frontend Transport; Tue, 5 Nov 2024 15:33:47 +0000 Received: from AUS-P9-MLIMONCI.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Tue, 5 Nov 2024 09:33:45 -0600 From: Mario Limonciello To: Hans de Goede , =?utf-8?q?Ilpo_J=C3=A4rvinen?= CC: "Rafael J . Wysocki" , Len Brown , Maximilian Luz , Lee Chun-Yi , "Shyam Sundar S K" , Corentin Chary , "Luke D . Jones" , Ike Panhc , Henrique de Moraes Holschuh , "Alexis Belmonte" , =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= , Ai Chao , Gergo Koteles , open list , "open list:ACPI" , "open list:MICROSOFT SURFACE PLATFORM PROFILE DRIVER" , "open list:THINKPAD ACPI EXTRAS DRIVER" , Mark Pearson , Matthew Schwartz , Mario Limonciello Subject: [PATCH v4 17/20] ACPI: platform_profile: Check all profile handler to calculate next Date: Tue, 5 Nov 2024 09:33:13 -0600 Message-ID: <20241105153316.378-18-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241105153316.378-1-mario.limonciello@amd.com> References: <20241105153316.378-1-mario.limonciello@amd.com> Precedence: bulk X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN2PEPF000055DF:EE_|DM4PR12MB7717:EE_ X-MS-Office365-Filtering-Correlation-Id: 3d838e77-fb61-45c8-183d-08dcfdaf3d6a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|82310400026|7416014|1800799024|376014|36860700013; X-Microsoft-Antispam-Message-Info: afNngmcMqPrxtZGW04jW/zY9r1V/Z3xEoArP7M6BizyqWQ0QCaVo/1DbRYAD59fdd6fNCVv3eJdEtyycGeJgX6myfwpDMMuc5hsG8sEQiMmt9q7qqMWqW4PFpyDtmbY6O/Oe1rasOk53fHpGe9Nf2PcRaKBlXR5Nu/lDy8gao+17OpOqq0sbTEO/AEVGRTv36bRFDMrgAKHbpbZpGCFKbLJyLcEUROJ7FoqHXQrf+yPIOBnProb1qthXffu1IhnVGzWafj1gSsvNADSTOmrAULFUN3FO5cRLsOL8+wePQkyJnmxoP5buDJ83Q/iKBoZfgpz9IzwS8vYpeglsGJACu6Snx4dxmTnWRliF69eTaHar3XXLfson0xq5oyGYqEg3yiYwsoLEXsGnouwsSh2huo3RnCQsOTiQ4VqAmGIhnucdlOisZpg8HffmMwSL+2iGE/o1kPGs/KHlC6cw3s+WDMg9QVCq1qZ5okqy5mQeDlFNmQJD4jmrIsrFUcDQ44ddJgFo6xOWrtjHnb1qXstXY7dHKnxiSxWCPHnBxR2Y/qh/XcF2lkmtNmyy1Q4/EGXElPgCJmtwwnG9WT559iIvu3g7W9THqBotHzaYUxfiRfjdVnHVE5IdoWXksgWOL9OiH9YqNAyE4+CVaK2nqFwg5wVbTbQlOcOcr4EnyPTLEMoT2S64DzJe9b5U1XWym1yoOoYE5SxZ3Fdnq1xIyt18z84DYkP8eNVlvarl1rWYOQiJL7aaeoxhxi31g5PhltX6Hhiq20sWRpgTBpYv3+WqirfSvIVo3N5uCD6id+m6RLskk5suVBTnzbZ4v/91oY18ioZkU5LxXpl/0Ex3dTsEtlxv3VkO/b7v8n9CrF4KfOM6DcaepghfQb8FII6F5j3OzSC++dsm36E7P4GiLDXEHjxd4Ddu8fGQtx9yXaNdaDzIzcX2fCoSlGbeG7K0RLw3sR2icN/6dFD6RYTQkeVYgqOhuTXSeTGwju2QmQRH5jHgRGEjhkc2thCJ4dyVb3TtY/pJJhcpxTWNkXEtE7a/cjBtpspg8Cs0Fn/66UbE7hdd0RO8QC50GO/LCfz1MdRb5KvHxhhrIsiTeaZv7jv5IXHWTQ0OfaKh9baiMQHM9zbRim/HxurOIGe0MPguN8X8bR2IJnrfdZTjg12th+ueDHVGIw1umCspkNlQ+k5GFMQExbBmJR6TrzPiUHogHSyYou6aewT+2jsKzI3TgNv+2RG06HJL04cYDt/ZpXcreGv6aV6aGWTip06AGsK5lKVu+poCPfBfdRAwe+SauVdSBwYhK4kW5aro2toQtp22LD3mDVSWxIDBvogxDELH1IqbT/g7k36TIfY0pi8zIpxBBjNKxaLgtPOnBv0ch5qldGPR6gIg+BQmBljUshOPaCRdIg2AsNjloFFVDsAGTu31aQ== 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)(82310400026)(7416014)(1800799024)(376014)(36860700013);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Nov 2024 15:33:47.0610 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 3d838e77-fb61-45c8-183d-08dcfdaf3d6a 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: BN2PEPF000055DF.namprd21.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB7717 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. Signed-off-by: Mario Limonciello --- drivers/acpi/platform_profile.c | 35 ++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profile.c index 7861fccc2e58c..568485e285061 100644 --- a/drivers/acpi/platform_profile.c +++ b/drivers/acpi/platform_profile.c @@ -378,34 +378,37 @@ EXPORT_SYMBOL_GPL(platform_profile_notify); int platform_profile_cycle(void) { + enum platform_profile_option next = PLATFORM_PROFILE_LAST; enum platform_profile_option profile; - enum platform_profile_option next; + unsigned long choices; int err; if (!class_is_registered(&platform_profile_class)) return -ENODEV; - 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 (err) - return err; + 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, - profile + 1); + 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_class_profile); - err = cur_profile->profile_set(cur_profile, next); - if (err) - return err; - } + if (err) + return err; sysfs_notify(acpi_kobj, NULL, "platform_profile"); - return 0; + + return err; } EXPORT_SYMBOL_GPL(platform_profile_cycle); From patchwork Tue Nov 5 15:33: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: 13863096 Received: from NAM04-DM6-obe.outbound.protection.outlook.com (mail-dm6nam04on2042.outbound.protection.outlook.com [40.107.102.42]) (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 50F831E3761; Tue, 5 Nov 2024 15:33:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.102.42 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730820836; cv=fail; b=ijpVAuPHX+VJf2WjkTctqxAvcqlgylDpefLuGH9RcMKDc3RUPv13g20nViiCu9frCzw3DqjYj/1FRnMy6okoAQ4xU7h46LQOZnhOW1g/xBHvPOGGH/WZ5xUza8J8GFGhqR5ly3l7KedLoE3Be3dk674CgkEkhjsOoFLWEKtbFH8= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730820836; c=relaxed/simple; bh=8265ZWL5VAjazKoIuoLkcoqO6KX5LFi0MhGnolPFVNg=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=aDgnVz/2jMaM0raakvUcSOhzs0e96ejFsyZj6h0aAApslvgGMTPsYuTiO0rXfpO+qRuYeDTv72Uyy30yzkP8QqWREeJitpr1hUBUC0UHcWruE4F9HK8zGR2JUPrnL5qFzD6qTQbq88z1y0uK9yzpsPCPxzP4DgOrRF7c6Hx+WPA= 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=cMoYQs8Y; arc=fail smtp.client-ip=40.107.102.42 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="cMoYQs8Y" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=ohFpJbRJ7Ua+OSgIc2WtuYqHPL4c2syfKBM+cZCwj6CCw2/Vl0pVD1jXru8Tb/F/3NLjuvv52QZGWMtZsMHS0LT5inCR5wRIN7b1eb9o0O2e6N7KSePb0dBp0yT4JCiWGa7vA+0rKMrmZNN2q49ZV2DgjbKjaq90o4nIGO5M6fdBS3QTHYZqK+vXxA72IJciP0ge+OFtvZ0dKhltmvRvqIqHt0Xg7PpchZDlp2OUZCYnOSq58NyZw+w+L5SaswrwQW7psdnqYx4hGcP+jIFjLxrkxCH9FAhXdvWn3nIEE5IK9RozILRUBduzqTQ0Tx5PbSqDiYa/F+a9ElBZ0AB/ig== 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=2d2T7e6xMXa8Ho9y5c8HKcJjgMwsLu6CwC9jhZqoEl8=; b=c+F1J7WV4gf+MVMIsJCuZEa3gu9wxtE6otv6tT3CDoyrvPvWxCCytqFkq8e8wOYzihSi+Paj+ONR5eJpqqkrKtNUivtXIVww8pp07YJDdpA0Eew9LKRahqqA2pPAZKQRsajuU6HXWF5hA+TtNw/gfk5iuQbOXvFtIEc6YvZE2FY3wg4nGepu3HuC3bMQbd7AV3Eh3nM3JJsOee8b2DwleIxOSUPClpIGsq4XRXsdDCYUu3r6PrwoOHl+V8SR8oAUo/ae/qOs9IDN+nnVy9Y8guQXkTqkiJmoSFaSwOZa5YvFdNngV5xbkIYS9xhWIofiFWybKTFTSjU6aZ1pa+QzhQ== 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=2d2T7e6xMXa8Ho9y5c8HKcJjgMwsLu6CwC9jhZqoEl8=; b=cMoYQs8Y008AY7BoGlRTg++Pcn9pgWj5t2FzUZJin2QyiL9riITekcn1kc5QZNx9tOmlqkRJyp8CRyDqwOQTpS5Q/HLYrGcVskNxYq8ks/zBRvQ90HlEg8hiTIfA9U054KqStqfjA4AmMmTMqyhLMCelrCdEy4bko0em6QuEMGQ= Received: from MN0PR04CA0014.namprd04.prod.outlook.com (2603:10b6:208:52d::20) by SA1PR12MB8699.namprd12.prod.outlook.com (2603:10b6:806:389::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.32; Tue, 5 Nov 2024 15:33:48 +0000 Received: from BN2PEPF000055DF.namprd21.prod.outlook.com (2603:10b6:208:52d:cafe::c3) by MN0PR04CA0014.outlook.office365.com (2603:10b6:208:52d::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.31 via Frontend Transport; Tue, 5 Nov 2024 15:33: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 BN2PEPF000055DF.mail.protection.outlook.com (10.167.245.9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8158.0 via Frontend Transport; Tue, 5 Nov 2024 15:33: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; Tue, 5 Nov 2024 09:33: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 Subject: [PATCH v4 18/20] ACPI: platform_profile: Allow multiple handlers Date: Tue, 5 Nov 2024 09:33:14 -0600 Message-ID: <20241105153316.378-19-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241105153316.378-1-mario.limonciello@amd.com> References: <20241105153316.378-1-mario.limonciello@amd.com> Precedence: bulk X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN2PEPF000055DF:EE_|SA1PR12MB8699:EE_ X-MS-Office365-Filtering-Correlation-Id: 02e81b3e-6041-4849-9618-08dcfdaf3e6b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|376014|82310400026|36860700013|1800799024; X-Microsoft-Antispam-Message-Info: BB6OCEhVkEaAd04PrS1uDCvV6AnRZrcSq/zpzO3ips49Re7eahYEUoKVi6QuKfA8VgpGo9g/bZNhHK0LpnQwjS4+Yzn+9IEu94fk73jK9PerAe5/kzURS3ENFZuBlHW2EuyXlJ5FTtsbfjy6ilnt3xfJD/NztfxRl99XB/BSb1A7f9knzt3A0KZN8uNB++qxWdOIGkArH5K9wT9VS1uf3QiZuXYWHlWVjzTU4d13grogj3Y69mr2wx+ZDLT0A51BpT+eCcDQEvzrnfBxVUPc2GxI/+jIS6gtFxCBLmVQfzVe+wmfE588vv72mUtSrgzXpVSPchKyfeP6/EG9A4bUElJPZshH5N4Dv4HSgyhsIhgs/mzJBETakmSLKi8m0AmzZiIxsPSaxG/u2/Lg0+L5R+GylPsFEqzERS6hL5wIF9t0Bzp8K6WLWf5XEIxwOFQBMjYgiRSEghgyba1gPa7ysymgLWNbS/od1MRlu1iSKtAsghr4Y7maEDSPfm2JoOVg9BeMvMJZjspRuJ5VPntGLTno09kYH6gBe+nX25Dm+1xMFIUbMo7egw69JX7qWSqgliSDSJoGI0k0xE8dwRD8jDX6aBHMy7KiIC7CcxRWCiZzClSdj5fzyXoFtEx4HgoiI8/o01J8ba82MT6+i2Kbbxx5LhLBUT5CPYosltAM9ZkJWSfUbNdoKXdqJKlYkevSen0ZUkvPOobhDSs5AYm0qAEQXaN4jhbND4hc0Br8bPNM+sG0PI7ViYmtusFSLIDxPYG0xXNfF35dOMcG5RKjH98kFfyuvgA4VS2IHMkS/JEKA+faonyjWEsqWvTpi0XvmW8ADhoHQKriYYQ2shod2LnVR+0AvWmZ9b9KUHG044h3SDHw37x4PEUQN4g4S6MFHJhfU6Wa3uN0KOh9WhUJzG7uYbX0pa4x48pUNGMiLm1KQnYT5zqi8LdMUaPirERaqwfgm+yAehci54FmOXGATmJkRGtRxib87u2zmTB4nuax4+9M7Dwf887n6Y1naOOpU7VwuyYAIe0dkexr8gJ8HlQTG/pf1TCotCUCRhg43c7KeHH9Yb2IoG+pJfjzrpMEFZTH05D5Tviu9ePvTSAMDGLl+xMuKCvmQoglGDTBwYVXIaPVgS+H8jYxrTyluWghh8RZnnyQl6klLrboKW2raF38+ewlJA5wKCeTNbDFnRIxipH+S7fw8ZWzDHU/T8yMBpx/dKW9TCTtzgQzyUAmztDNngoiH3ZIbntpqm8QrDLSdxtFmKsvn1fHp0kz8mgnR3OwfNqtOPjBV4j3UH2y+5qRTyx9IDZsuJnUvsScr9JfMMWt+5BkM2AyJ8SyQnWHdoDor+ddnPekTvgqoiST35qdUqrs8Ar94q5CHfz4lY68Ox3D5+1rAKSB7jyS7Quzd+r12behd8nz/APXXzEhkg== 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)(36860700013)(1800799024);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Nov 2024 15:33:48.7485 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 02e81b3e-6041-4849-9618-08dcfdaf3e6b 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: BN2PEPF000055DF.namprd21.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR12MB8699 Multiple drivers may attempt to register platform profile handlers, but only one may be registered and the behavior is non-deterministic for which one wins. It's mostly controlled by probing order. This can be problematic if one driver changes CPU settings and another driver notifies the EC for changing fan curves. Modify the ACPI platform profile handler to let multiple drivers register platform profile handlers and abstract this detail from userspace. To avoid undefined behaviors only offer profiles that are commonly advertised across multiple handlers. If any problems occur when changing profiles for any driver, then revert back to the balanced profile, which is now required. Tested-by: Matthew Schwartz Reviewed-by: Mark Pearson Signed-off-by: Mario Limonciello Reviewed-by: Armin Wolf --- drivers/acpi/platform_profile.c | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profile.c index 568485e285061..b9eb25f58a2a2 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[] = { @@ -368,8 +367,7 @@ static const struct attribute_group platform_profile_group = { void platform_profile_notify(void) { - if (!cur_profile) - return; + guard(mutex)(&profile_lock); if (!class_is_registered(&platform_profile_class)) return; sysfs_notify(acpi_kobj, NULL, "platform_profile"); @@ -428,9 +426,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; if (!class_is_registered(&platform_profile_class)) { /* class for individual handlers */ @@ -451,9 +446,9 @@ int platform_profile_register(struct platform_profile_handler *pprof) if (IS_ERR(pprof->class_dev)) return PTR_ERR(pprof->class_dev); dev_set_drvdata(pprof->class_dev, pprof); + sysfs_notify(acpi_kobj, NULL, "platform_profile"); - cur_profile = pprof; return 0; cleanup_class: @@ -467,13 +462,10 @@ int platform_profile_remove(struct platform_profile_handler *pprof) { guard(mutex)(&profile_lock); - cur_profile = NULL; - sysfs_notify(acpi_kobj, NULL, "platform_profile"); device_destroy(&platform_profile_class, MKDEV(0, pprof->minor)); - cur_profile = NULL; return 0; } EXPORT_SYMBOL_GPL(platform_profile_remove); From patchwork Tue Nov 5 15:33:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 13863097 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2080.outbound.protection.outlook.com [40.107.94.80]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1CEE11E412A; Tue, 5 Nov 2024 15:33:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.94.80 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730820837; cv=fail; b=tWaxZD6kWfjdlX45qV9e3+7cULMJxREGo+nap8vEvd9yYnKgLi2yUxom4xPcbuB/iDgdNUMtV109m39HJFcUrmoqOH/Kq0MGqmhm9fhToYkF3bxmQGw2zdsPxEo8+rzwk0baGlQYubfINBnwimpl3HppXYTfWXluz7tdpAzth2M= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730820837; c=relaxed/simple; bh=Yr2DwGP3stibvV5kDEhUIRooOkkRhrchVHVPrM0URJ0=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=WDPFIwj3uPrjkbPwAYxGsofnVxJTe7Tj5jremf8iezLAHPT9OG4sc6ySYyydJqSSBbjsY4oiowE5hg6S3kaEwATOBwNVSlRBMGrPlHgJmHZHym3Rsv3BgYY5s4Kv9hkpvGIA2Mq/bDIp0mT/fZvVJyVVDF0/V29883VKd6FnNLA= 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=mD9TRaqV; arc=fail smtp.client-ip=40.107.94.80 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="mD9TRaqV" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=hqWM5SehKn9BYuhbGHfHJ9HbmJ+vhqIx4qZWM1AZYGCbnfAOY0JsrnD1JLQA8DylnIDhc7WeO6MQhtzUrQx6AM0uwUOeETeDh4g10P4Rjlz2fwG5YrO/Q0BDSoFf7uIrUQXjVInGsEnCx7yRUnSAG5r1YPFJ74WEUY8eZ28ZynhZ0posbK47/dQW9+RgY1RxhiHDW51A1b4TvpFFcnW7aQRH5r3IwZcw9cLx80NIHbAWaeKXyhggsPuwhmIrTV5ucQMYFdHH/uL4JlpzlKS6x3Lo8jO1C8Gn9y0Pgk0nko4Z7lAsHJVIDeZ0yIgzJHRFsxgmQOsj2IsdU+kE/oDYxg== 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=t/3tLlKeu+mu2+ZvcCVORU2kQj6qVksAflAgnmkPtrU=; b=p67nPGg+QEpjki7Up/ozdBk0U3WdjoYQt80Ti/0bQJTInEmj8aES8tTK7RYhETc2LS23rTjDhUsWMNoTgkpgjDK1ppH07L491x1WRotGYVMgai9Kaf3NMh134c5IV+uzQhIGDtYnMlnn80FRhCvBecI6B4cCoCbsTEvqV6rpMMTZYcHY1MAbuXxa2XqCYm6G+5maVDZBONZVQdX28ImvcruWPTkGp9qA2DOu9VgOLQPQ5JekvERONa1pvPMq8ZJSPZigsfWkkh4vNuFyEViYAaOEToTNUfYn3wj/ZogTjLedh6iiXDVOqwhi+Se9kloViHkXOdP7Xajpglzqb90SsA== 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=t/3tLlKeu+mu2+ZvcCVORU2kQj6qVksAflAgnmkPtrU=; b=mD9TRaqVdrQIUBcC5i3L5S+NzJQK/vD+TvKdfOjycYIh2MbUOiD61Kg/xWPxgPOui16H5/+9ghFzgKAj/L/N/cIItMbXI0WhY6MABSyyYlA8ktks7QVPX8hcjDi5rCb2JgtLNlDdv8PD3OmUS5BWe8vmy1532fNe7D9uFdb3AEY= Received: from MN0PR04CA0028.namprd04.prod.outlook.com (2603:10b6:208:52d::27) by DS0PR12MB7900.namprd12.prod.outlook.com (2603:10b6:8:14e::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.30; Tue, 5 Nov 2024 15:33:49 +0000 Received: from BN2PEPF000055DF.namprd21.prod.outlook.com (2603:10b6:208:52d:cafe::e2) by MN0PR04CA0028.outlook.office365.com (2603:10b6:208:52d::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.31 via Frontend Transport; Tue, 5 Nov 2024 15:33:49 +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 BN2PEPF000055DF.mail.protection.outlook.com (10.167.245.9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8158.0 via Frontend Transport; Tue, 5 Nov 2024 15:33:49 +0000 Received: from AUS-P9-MLIMONCI.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Tue, 5 Nov 2024 09:33:47 -0600 From: Mario Limonciello To: Hans de Goede , =?utf-8?q?Ilpo_J=C3=A4rvinen?= CC: "Rafael J . Wysocki" , Len Brown , Maximilian Luz , Lee Chun-Yi , "Shyam Sundar S K" , Corentin Chary , "Luke D . Jones" , Ike Panhc , Henrique de Moraes Holschuh , "Alexis Belmonte" , =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= , Ai Chao , Gergo Koteles , open list , "open list:ACPI" , "open list:MICROSOFT SURFACE PLATFORM PROFILE DRIVER" , "open list:THINKPAD ACPI EXTRAS DRIVER" , Mark Pearson , Matthew Schwartz , Mario Limonciello Subject: [PATCH v4 19/20] platform/x86/amd: pmf: Drop all quirks Date: Tue, 5 Nov 2024 09:33:15 -0600 Message-ID: <20241105153316.378-20-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241105153316.378-1-mario.limonciello@amd.com> References: <20241105153316.378-1-mario.limonciello@amd.com> Precedence: bulk X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN2PEPF000055DF:EE_|DS0PR12MB7900:EE_ X-MS-Office365-Filtering-Correlation-Id: 91a9210b-7e9a-4e52-6ad3-08dcfdaf3ec1 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|7416014|36860700013|82310400026|1800799024; X-Microsoft-Antispam-Message-Info: RmLjdV+zvhXv2OFox4hPVs7phVw34ieHAWFNfPk8Le6rI7cbu7zK/ov158k8CnCRGqxb45m2c/o/NII/EmDAkg275JJJe8tUsx+6XkUxupvt69ZDVAJZPfQjc7E4xxRRvCIMQIh2cLmEuxoTms2fE05vSFeuKjJlEsC2ts+gyNoXXPyfuJS2Xa0GBmHiiRsEfclbY+9AHhN9cUa/gpPie5a1FQng1T1lpkwwnr2OECx3W2036HUG68eh6tw4d8rJzrSrrNnMNsNOBYILcqnLWiEuSy7YJxYY4lW6/TShPre8ToS8aG5Qa6Yn3gjprD2nEhH9J5JPI/lOB9gFEhDKhTUI7BmhrgzUehhhioLXmPZaLoWjPIeMoWmEsAzhTl+GJxRdLRV62nmDtVGf6CciW9Ez5/bDLtXkFOIIpH/OZD73xirjlMigMX4z4ARPAugQzv7cB52dN915hToBEOQumYrhjuwFKVOC1YaJGwSCqWpgoWq46zi6Ni4X4psl5/j3ZzRJ+t4rm2YJhI70PMt/kaWafDkz8sWH+PLFmgBTvKup3OoAb6tX4V8BaAiRlovJ9Kv/UWuKNgPRtbn+5Yc92ybRcMuKNkysScqV8jwx4vHUjs7+H6DO/po+g5fJUwLLiSedQ1dCucJg8Rx3X/Dd2QW410PIlO3CGEpYJgcZGpBxLN52Vfqp6Oc2DgoIbOSVfByG2zG1MjD7J5dF9nkSndKchGs71oGVrgq6l9vX/RbJQjm1sdUg6c70db2tAC5G6VhGXBU6ishdIratUJ40jkHYX1IcVHLNuJcnJ29J+AZStcu3QlrFgFoshb0Z2romOFU6kfW+Pu/hzLYN7oQNh4j+V75glMr96fQbQWrIASEB4DHH8WRTesr+RSWVd0SAsLOOPwCvgpTkx+I6Ci0U6+Rr2FR8dA5rLEDd8lZExhkuMZAwUVFYSUIDynW5ySYdreUcpH6ZXVxc9VeiKMiIgTmspKcYDkvUfDvcj91kwNumpOjFpL3NzWQtkpCnaaD3Zllk+IWR3G1DBWHI/KLDZiaYCXWBUxYu3dQ2UXrYLcWelxpYiGEK6fPnZk+SOS/c1k6YSL/gtZEaZ3B/g4vO7oYbscJjzWABTH38ArLno9IMgpZROwxvXo70lBOeKVI4CzG7nPvdOptiE5RQ02tFRt8IVl9hZYbeKrJ6bMDiTg4K2nj5mcxze2aD1B3Osx1pBAzhEnh4t0iLWClTLpcnmYUB3N/ZghYFdqPn7eHeJp9BPm22t4FM6Uk0SLmFl69vaxTpW+lSO8yTFUtokb/bOJM7TT1CvtozDqWhML/zgqbY7f+aveimxCNE1JkQDmbtYiCVG8U4JIUrrQ9Tivbn5G1I4G9ClMOl2iREGJWCKAaXjMcXNh4QnYQDnYQ/twu9o23N1PW/ouzvNQHq66aMzw== 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);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Nov 2024 15:33:49.3110 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 91a9210b-7e9a-4e52-6ad3-08dcfdaf3ec1 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: BN2PEPF000055DF.namprd21.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR12MB7900 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. Tested-by: Matthew Schwartz Acked-by: Shyam Sundar S K Signed-off-by: Mario Limonciello Reviewed-by: Armin Wolf --- 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 47126abd13ca0..6ad00b3d472fe 100644 --- a/drivers/platform/x86/amd/pmf/core.c +++ b/drivers/platform/x86/amd/pmf/core.c @@ -455,7 +455,6 @@ static int amd_pmf_probe(struct platform_device *pdev) mutex_init(&dev->lock); mutex_init(&dev->update_mutex); - amd_pmf_quirks_init(dev); apmf_acpi_init(dev); platform_set_drvdata(pdev, dev); amd_pmf_dbgfs_register(dev); diff --git a/drivers/platform/x86/amd/pmf/pmf-quirks.c b/drivers/platform/x86/amd/pmf/pmf-quirks.c deleted file mode 100644 index 7cde5733b9cac..0000000000000 --- a/drivers/platform/x86/amd/pmf/pmf-quirks.c +++ /dev/null @@ -1,66 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0-or-later -/* - * AMD Platform Management Framework Driver Quirks - * - * Copyright (c) 2024, Advanced Micro Devices, Inc. - * All Rights Reserved. - * - * Author: Mario Limonciello - */ - -#include - -#include "pmf.h" - -struct quirk_entry { - u32 supported_func; -}; - -static struct quirk_entry quirk_no_sps_bug = { - .supported_func = 0x4003, -}; - -static const struct dmi_system_id fwbug_list[] = { - { - .ident = "ROG Zephyrus G14", - .matches = { - DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."), - DMI_MATCH(DMI_PRODUCT_NAME, "GA403U"), - }, - .driver_data = &quirk_no_sps_bug, - }, - { - .ident = "ROG Ally X", - .matches = { - DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."), - DMI_MATCH(DMI_PRODUCT_NAME, "RC72LA"), - }, - .driver_data = &quirk_no_sps_bug, - }, - { - .ident = "ASUS TUF Gaming A14", - .matches = { - DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."), - DMI_MATCH(DMI_PRODUCT_NAME, "FA401W"), - }, - .driver_data = &quirk_no_sps_bug, - }, - {} -}; - -void amd_pmf_quirks_init(struct amd_pmf_dev *dev) -{ - const struct dmi_system_id *dmi_id; - struct quirk_entry *quirks; - - dmi_id = dmi_first_match(fwbug_list); - if (!dmi_id) - return; - - quirks = dmi_id->driver_data; - if (quirks->supported_func) { - dev->supported_func = quirks->supported_func; - pr_info("Using supported funcs quirk to avoid %s platform firmware bug\n", - dmi_id->ident); - } -} diff --git a/drivers/platform/x86/amd/pmf/pmf.h b/drivers/platform/x86/amd/pmf/pmf.h index 8ce8816da9c16..b89aa38434faa 100644 --- a/drivers/platform/x86/amd/pmf/pmf.h +++ b/drivers/platform/x86/amd/pmf/pmf.h @@ -795,7 +795,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 Tue Nov 5 15:33:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 13863098 Received: from NAM02-SN1-obe.outbound.protection.outlook.com (mail-sn1nam02on2089.outbound.protection.outlook.com [40.107.96.89]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D439E13C80E; Tue, 5 Nov 2024 15:33:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.96.89 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730820839; cv=fail; b=cJRXgwcooCVAb+xukJaM+87ETDkIXG0MsKWy7S0mdkzQzeAD5b1aAPjNbvX+bTNvn3yhfSWK33JuKDfZf4fw+lngio/u7XIUfj9HExT1B8B7s4AZPrZAG+0bgZED20F2+A/1xAvPHTo6JI9PYH25+0YLP5qbs8KcGYo/Pm+FCco= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730820839; c=relaxed/simple; bh=h7UuvL7RUVev5uvHZ1pWhoJtMToiKFMIm87x4l/APr0=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=u9GUdiYSnZrgRuqprXMAh0xuEMEOywm8mObMy5qi/QfW6DaOVOAV2HS0jd4lFDzrR2Bs9PPHNhmv9LIdgDuGEj7g7BtXyYN/VIpWnMOLRTLnTxbD+QKKXXEBbzEXBZyvdx5xjxYM4xiVG58ekQl+Zr3V4+CI6aFCRmSvRLK7rFU= 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=SzZ8RUfy; arc=fail smtp.client-ip=40.107.96.89 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="SzZ8RUfy" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=j5ernT2hQbdDpwlairVTdve6Bk17pimXLIRzSvdXbYsJH/m1NFVlu8oNjFrTLgNuyqLsSH0IlIKJpGPO6GlYHjHrcvJK2zpPIs/iwMc7Jalo+UJKOWLgaIfacoKj0sY8IxndKROq1kbrgtCFC3qj+UIJjT8o79VlRhdv0T6ZoUgOhsG7HaOISvAtiE0nMVi8GiY227NjgKdTihqSTQC++yplYGh78Fy2WDNQ1KixZqHoweynlFducbIJ0g1WVxF2Lo1RELanHJ+ITBaV8fUl+nryJR/bhT9Nwg9Cv38Mts7Y5u2MopdFW+Ir84+SNuzDuqbCBJLkPjAnCJnEMEHbDA== 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=gBtBAl+R8h1wq1/q1GN+IGXuNYZqj8oUNSJT/F+/2mo=; b=KcCkkNbv7PJ8R1obLEZonVVoVkNDVIkBZiJDh1l9l8/jZCbq/H+VfCzon6fiNK1nvu+gyFeUJYLJDffIthgD8RJ7NXu/Dm482LjGouQzfYICxp4ZzcF/W/RF3hAY1T3CwKC66ag+k2yiBZCWr72f550/jHT5SexsxK3FnYkBGOsr2SIhqFSroRRYo3SK2h6k2PNUizUPcd40etU+YH6nE2Sa2MJ0sXBzgZyxVXMKbhawWBc0jq2qM3Sj0J3XmlNsN5h0GEId3CQC5Jo4T8OuM9m6DSqzy0c8lTDOlkt3mPErlwuXfs9KTgoXgPPIySS7t/RB4JMP3bQFokh07C0qcQ== 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=gBtBAl+R8h1wq1/q1GN+IGXuNYZqj8oUNSJT/F+/2mo=; b=SzZ8RUfyhfewU6Z7l/kehJWdTG5KbgzRZ5ziIBcAU+VxLh5tXiwbZGj5YTtP7RTDO1TdpQCYbEgYAq+4R9JCfu3HPyYhF1o5GMWflRXM01eGV+/vjGPxE4F7KtWGUb2AEWD3NGLD9MHTSEMy98Bb7HevNLyJhOfXWP/sQBEqXe0= Received: from MN0PR04CA0007.namprd04.prod.outlook.com (2603:10b6:208:52d::12) by DM4PR12MB7504.namprd12.prod.outlook.com (2603:10b6:8:110::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.31; Tue, 5 Nov 2024 15:33:50 +0000 Received: from BN2PEPF000055DF.namprd21.prod.outlook.com (2603:10b6:208:52d:cafe::a1) by MN0PR04CA0007.outlook.office365.com (2603:10b6:208:52d::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.31 via Frontend Transport; Tue, 5 Nov 2024 15:33:50 +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 BN2PEPF000055DF.mail.protection.outlook.com (10.167.245.9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8158.0 via Frontend Transport; Tue, 5 Nov 2024 15:33:50 +0000 Received: from AUS-P9-MLIMONCI.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Tue, 5 Nov 2024 09:33: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 Subject: [PATCH v4 20/20] Documentation: Add documentation about class interface for platform profiles Date: Tue, 5 Nov 2024 09:33:16 -0600 Message-ID: <20241105153316.378-21-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241105153316.378-1-mario.limonciello@amd.com> References: <20241105153316.378-1-mario.limonciello@amd.com> Precedence: bulk X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN2PEPF000055DF:EE_|DM4PR12MB7504:EE_ X-MS-Office365-Filtering-Correlation-Id: 0990ddf7-7dab-47e6-a076-08dcfdaf3f38 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700013|82310400026|1800799024|376014|7416014; X-Microsoft-Antispam-Message-Info: wagLuZn1eNsKJwQz06Tn86jKXML0XK7wQOljQiiGeP8Ix/qul8kt7oR1dGU8Nhuc8MQB6ZnskbzU0gRPn/reDzr77XDzRM3XTNTMZ1hvmmd0+e3rui/NB74xREZVTir8PLjxHIlW89l0+BPnhxWcbWtbash65mwV2GOJG7BUUGvW9nMEN06yAxZ4M5hqGrAVUbrTIZNqmJ0vd/NsiAd/mrGdaKSmEodu2aZjg8hFnwq0ReSi1bVNAsiAj1AEubdE3aO27P1jToBmQCdwx5FsZH8D9VAocZtQmeSUWjxSb8/XrHoZqXhNq7stgGyeHcvHMKe/LgSeOiNOO3TwKC56kQbpqEMP1EGwvl92ZJuuOdbuVYwLbjltZQNwsY2JQ2pQ8l6DFpol0JccBUCpeyi/ODuj9vDb+3EFZe44RaylsupCgmCAgPnaa6mOH9drX7aAFLoOZwGlnFgoW6p64NGvBELX1Z+QzNL9sOz0/sHbkucVAPQoxlm2XFtqC3fgMnNTLpv0/bWGbjzMEBKNGkWIqdzRXC4vSxPhqRP8p1ZHUpw3TQKY+soprlC4YBlYc+C3ZSgfo0wfvoTdP+SZgA+VUp20J2gBcehmxLzoBfcwJ5lNlAHI+u9MJhvBo2kRCL0M5OaA8sttiFp8E2vw+ajLHZNeMEer7r+czgQH5IJDUTrC8ogBH/gqToWXc/PYQ9GsessinydyH79/Fz4+N5awLYJepoUpmEM8917htSj921zTlc03Nq1LqeMtvAhvhpaf+d/0pcixzk8+dav0musK4NdW2TfNvt6OQ+XNH9CpahdfUaMW6DG2FfMVzxcXnYNeMB6yYmC1s6tphxVowWsIFex6MKAPb9EX40HnWUBS8r1l5nzy7gJkg4pJznwBR9X55e8aEPjG/R1gAaqDIbS4mEBtKea1dp9JLiUdNv9P7hi6WekDYKD42a2yff6Gaf2E3ZB8GT2bjYu3S6zkUA6HIs7JpDlyj85OiwbHplcrmVVbgCC7i9Z0rocfbuaWZGbqfTKH1Z4MkRVIhONFcuKkb4n7F7seViwBdtM2yHi68YRDA0/4RYn/wxsT/ManpboyMconJDMuKah0FvfncKK9clTzEqKASrBZbf330UQBbJosJ5hYkefl+ues8oOWKqlsJ0DKPLNSg6n0j2Vf1TtxwULx5Y5lG2VQW3PhHr1sDitHmInB0s9ytZSpkxunGs8LOVBce24/i6PF9dFf2fXtUb6m/QO8mRR/AcSKsRhVWF992Ep7J90TAoW/5pkuNU9Hf/2RNw4W0GMvASolP54tLJwaE5CPQiQRwoMe8kuCZDqHfh9LnecY+9ovJeT+u3hYTc89rhfoG1i90MI6wkUYI4dKtNiQVoU76SRWuQGdjPOgEM1w3PX/MXsSrbOQAiR3BDYTAegjxDvNjmiyfYQ8Iw== 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)(1800799024)(376014)(7416014);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Nov 2024 15:33:50.0922 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 0990ddf7-7dab-47e6-a076-08dcfdaf3f38 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: BN2PEPF000055DF.namprd21.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB7504 The class interface allows changing multiple platform profiles on a system to different values. The semantics of it are similar to the legacy interface. Signed-off-by: Mario Limonciello --- .../userspace-api/sysfs-platform_profile.rst | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/Documentation/userspace-api/sysfs-platform_profile.rst b/Documentation/userspace-api/sysfs-platform_profile.rst index 4fccde2e45639..418c61b096304 100644 --- a/Documentation/userspace-api/sysfs-platform_profile.rst +++ b/Documentation/userspace-api/sysfs-platform_profile.rst @@ -40,3 +40,31 @@ 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 +commong 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 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 differes 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.