From nobody Sun Nov 24 03:28:03 2024 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2080.outbound.protection.outlook.com [40.107.236.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 D937E192D8F; Thu, 7 Nov 2024 06:03:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.236.80 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730959414; cv=fail; b=iN6xYYw6jhmwmTc8gylRlV0z5TKCsntMVIE7+wi90ebxVfukiIUCyuAQ5e3bnBFE3xkEjTqtE0xThK+EUPrBkspm/w99q4FyT3tiVzc29l67jqJNw2LeIF5M/C78DI3+ONndCWPQJ6JL16Ki5CYzbkhPsY24W0xpnbczkcDLbWI= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730959414; c=relaxed/simple; bh=tgk8RY+Xh2BX2mN66fKFdmqhl/F4m7qqrrEeV1tpv8Q=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Goh1SFBilukoTWHrAfUUVLlwB/NMS2FU9tnmKMsHjjJ+iuZ4I0XJSTgzlFWlKZ6GGYlr3pE/6jVxt2FyJWKjP7dVX5PbZSL8eW1GCBv+lczzv9iUWyvp3eypxk8wrFNLhOrUb3O6rsIR58EEcVrnLDBs6Jv875hkDMdTSYrl07k= 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=eO0i+Qqg; arc=fail smtp.client-ip=40.107.236.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="eO0i+Qqg" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=aGgFRa/yO62l1j11ZvtSA977fsurE+67qPAG7zGCpx3PKAQQPu2vH9MDhUz5dMB7wfdQh6bw3x1VJOpmVIpvLGHPdGBVJkEm6EbGIzZTGE+x+vJ+axQTNypECEculAwQSJ08AVBltzR+2xcUJ7OnVwIT55zZrYf3l5SCL1yolymIMNGsCsIVVYUMIwzUloCXKyE8t8J6CUw1egWMRq3U4Ca4i8zAqZB8Bsw2/7gUsVvFFagCiflzJ6GYDzX3BCdUn8KP7DmdMM+A/CvvlEcQJWqKJv2ygKFykzPu1d3sNFVCt/Uwoz/acZ4A8rRYvl1KpcHHL+SgM3ZYRRxtWApsWA== 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=YZpVGhxUqKsw5ae2nfZGIdmBElV9ZiVBff5oYJnU5X4=; b=O3woC8eNmTq252fDx7SMeeIKSuSY/XHlsacNWspbxkRAzpY5AIZ+LtKkV80k01z8Wtn4kmN4ikvv9XmBkhFy9ajIxPWGpMCWb660kBe3BNKfvJnSaulUs8cFBgT3yXf3U+3NoRbWjFeRMrHcvRIT4d0363014Zg17iBV6yKdTOYn48mRfkzqeRdlY3EEvAgqRSrsA9Hsni6oRas0JLJ9wdX6/ElObZEEZDCSIBmoflOvjMZ/Z7vZpHV3HpPJFMG1lqRyU4zmwL7U8n69Xzn8LtUG/0fB6MsT1CopSDrV3CE1XxidyJh+nB4bojjImSHsSYHTKr+20N5uKMMYd9POIA== 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=YZpVGhxUqKsw5ae2nfZGIdmBElV9ZiVBff5oYJnU5X4=; b=eO0i+Qqgx7MjeI6KkslYeImdvhfqRORanMfBfuvsGEnGDr5xiWPMmiVEp0IHq9++clcEooZUH/DH2qBqOOE35/2im2j1CCgXx9I2JwxObpWHgxImxRevNbJ+MPjrNKzGClbM87LH7LWFB1luGBDeTWpRfukKRUbHwh0AX6f1jUk= Received: from CH0PR03CA0292.namprd03.prod.outlook.com (2603:10b6:610:e6::27) by LV2PR12MB5776.namprd12.prod.outlook.com (2603:10b6:408:178::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.29; Thu, 7 Nov 2024 06:03:27 +0000 Received: from CH2PEPF00000147.namprd02.prod.outlook.com (2603:10b6:610:e6:cafe::d3) by CH0PR03CA0292.outlook.office365.com (2603:10b6:610:e6::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8137.19 via Frontend Transport; Thu, 7 Nov 2024 06:03:27 +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 CH2PEPF00000147.mail.protection.outlook.com (10.167.244.104) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8137.17 via Frontend Transport; Thu, 7 Nov 2024 06:03:27 +0000 Received: from AUS-P9-MLIMONCI.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Thu, 7 Nov 2024 00:03:25 -0600 From: Mario Limonciello To: Hans de Goede , =?UTF-8?q?Ilpo=20J=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=20Kleine-K=C3=B6nig?= , Ai Chao , Gergo Koteles , open list , "open list:ACPI" , "open list:MICROSOFT SURFACE PLATFORM PROFILE DRIVER" , "open list:THINKPAD ACPI EXTRAS DRIVER" , Mark Pearson , Matthew Schwartz , Mario Limonciello , Armin Wolf Subject: [PATCH v5 01/20] ACPI: platform-profile: Add a name member to handlers Date: Thu, 7 Nov 2024 00:02:35 -0600 Message-ID: <20241107060254.17615-2-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241107060254.17615-1-mario.limonciello@amd.com> References: <20241107060254.17615-1-mario.limonciello@amd.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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: CH2PEPF00000147:EE_|LV2PR12MB5776:EE_ X-MS-Office365-Filtering-Correlation-Id: a431c8ed-32b5-4e98-7495-08dcfef1e5c4 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|82310400026|7416014|36860700013|376014; X-Microsoft-Antispam-Message-Info: =?utf-8?B?eFpTczlISy9LUXV3Y0NkR3lxdy8yODZmKzVJb3hoaHFnSjRQZVJhQXFKdldY?= =?utf-8?B?YTRUbWt3Q1MrU08vVE9vbFhDZGFKd2F2b2F5Y214alZaNVF3VDVuL2tzbzVx?= =?utf-8?B?c3NNanV3dVZPSDJ3bVZpeDRxWGZBTlAvSjR4NVprOUdOUWVIOU10c3pNZU5z?= =?utf-8?B?TXZBR0RVdHBLU1B5aHVLNzVpY21pc1k1anpuT3B0ZHVPYlNBSUdPNnROc2Q1?= =?utf-8?B?Z1NtdFZ0VUhKZnZGbnBBRXZleGJueGx0N3hGZUh3a2hHbnd0R0pIblBkcVpx?= =?utf-8?B?bjlvdEY0S2pqaDdMOTloZnFPVjdYMzBXczJ0NzQ1Z0JyeXRwdzl0RFRESmQv?= =?utf-8?B?Y3dlM1MvcmFVeStRWVRlNnhYZElxTE4wUVFySTJrbE54MkdZY0JvNHZxUFBV?= =?utf-8?B?Y2xhb29MZE1UblF2SDNHK1FlUmZrZHQwZUtNUGVZRHpGeGgxN2YrY2ZLbEdr?= =?utf-8?B?YkJjZlZzSUdCSU9QZU85aW5QR0hBbXcrY0dlZG4vc0UzM1h0RE9OdllPNm9w?= =?utf-8?B?cmJBZ2ZhME9ScDdBQkNDR00rbWNtVGs1N2JHZUxFR2x3dGVnL2dOUktPc2lL?= =?utf-8?B?QVc3WDZ4MDFwcVZOcGkrK2VkSDlmbVA1aFBYMEJiOWlBT2FYVFlCb1lOVGp6?= =?utf-8?B?Ynp5NVBIZmdoQXdJR1JwTFM3TUtQZS9FdEQ3RlU1eDFSZU5GNFpPT0prVFFn?= =?utf-8?B?MXNzRVdXZmkzTlNWN0FCc0tIa1NEckYzeGU3UWxmcnVxOHRESmVqcDJWTm4y?= =?utf-8?B?Ri8wNVV6dkZpR25SRldYcW52OUJiU3lRZjVEeTFERGZpcmJ1dDNKdG9MaHVr?= =?utf-8?B?cUtEQU56dWU3SzFyQ3dUeFQzTGcrMzgyMERWUjVhVUJGRkpvaHVzeGdtSWts?= =?utf-8?B?Z2MvbGg1c1VNNDVHK3U2a1R5bVZQWGJmc0RPeWZzdzljM1Z2bSt5QTdUZ2x4?= =?utf-8?B?K21meVBxeHRoVnhVQjBQT2NZRHY4dlNqOTk0V3RzRFo4ZDRoRFBLaW9ob3p0?= =?utf-8?B?bHBvOTg1NXhpVUQ0d1hDdHJMUHRuZkhqRDhUR3FHWEdvQVlHU010YTZzVExI?= =?utf-8?B?RUFja3hYNnRWOTR1ZEFTTzFESWF1R3FVMkpNUGl4U1UvKzlHQlkzM3U4Mjha?= =?utf-8?B?alVaQ09JNVFKczBBRkF5aGUwd1d0UmtxTyt0YlVMZWZrdkdtTjVENnBxRE9z?= =?utf-8?B?V24rcHZKQUtQY3dsMkRWY3VtR3ViSFJNbmFpVitmek9McjZLSzJoTlIzNkM1?= =?utf-8?B?NlBFbGhGdDQzNXJkdGQ3c01lZWZwZW9yelQ4QU9pNFJCUXJxMHlIcFdjVjBh?= =?utf-8?B?T2ZsT3FKQW4zWHJWemgvTWpjL1VNY0J5Q1gvSXFBTmFEQ1lZaEEvdU53Wjlk?= =?utf-8?B?ZlhSY05WbFEyQktNenhVVXdObWp4d2l2ZE1jYWM5b3dVNG1ITEhmTUZQTlJN?= =?utf-8?B?bjkwWkxjM3p2elIvVkN0UGpzckVOc01mSWsza0RCZVhWMURqVUdCSDhyalI3?= =?utf-8?B?Rm1LRm5iRkd1U1JKUWdaZWZjOHpQZGNoOVp4ZFUrUlVIMEduNStKSFN3T3NY?= =?utf-8?B?TVdIL3RpOHU3eG9NMWsxV2dNbVZNSkdqVXNBOHErWnl2NkZmUFhxYUhmcHYx?= =?utf-8?B?TnBBd09oK3BESlNHWG9sM0VqcVFsRDRsYjJsRlFaOHd0ZGM0a3NyRHlNQjUz?= =?utf-8?B?S0Vsa2E0Sk9BaGUyZ09hNDhUSGo1MUJqWWxEcG1Rckxka0kvSldUU2xxeVFU?= =?utf-8?B?eGhHUEp3OVNNVnNNeTZadjlNKzIrYVZGdUhsOEdvNDNQLzVIY3RleDU4eDBW?= =?utf-8?B?anJkdkkxVDJFb01weE4za3UvNW1TNmZ4S25hZm9DVlJ1L0h0bHJ6Mm5JaFQ2?= =?utf-8?B?WTJMMXN4UHpoUW4rejh0dVpWQnJTU1hWK0RZWWRlUDlkYmc9PQ==?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(1800799024)(82310400026)(7416014)(36860700013)(376014);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Nov 2024 06:03:27.4417 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a431c8ed-32b5-4e98-7495-08dcfef1e5c4 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: CH2PEPF00000147.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: LV2PR12MB5776 In order to prepare for allowing multiple handlers, introduce a name field that can be used to distinguish between different handlers. Tested-by: Mark Pearson Tested-by: Matthew Schwartz Reviewed-by: Hans de Goede Reviewed-by: Mark Pearson Reviewed-by: Maximilian Luz Reviewed-by: Ilpo J=C3=A4rvinen Reviewed-by: Armin Wolf Signed-off-by: Mario Limonciello --- v5: * pick up tag --- drivers/platform/surface/surface_platform_profile.c | 1 + drivers/platform/x86/acer-wmi.c | 1 + drivers/platform/x86/amd/pmf/sps.c | 1 + drivers/platform/x86/asus-wmi.c | 1 + drivers/platform/x86/dell/alienware-wmi.c | 1 + drivers/platform/x86/dell/dell-pc.c | 1 + drivers/platform/x86/hp/hp-wmi.c | 1 + drivers/platform/x86/ideapad-laptop.c | 1 + drivers/platform/x86/inspur_platform_profile.c | 1 + drivers/platform/x86/thinkpad_acpi.c | 1 + include/linux/platform_profile.h | 1 + 11 files changed, 11 insertions(+) diff --git a/drivers/platform/surface/surface_platform_profile.c b/drivers/= platform/surface/surface_platform_profile.c index 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_d= evice *sdev) =20 tpd->sdev =3D sdev; =20 + tpd->handler.name =3D "Surface Platform Profile"; tpd->handler.profile_get =3D ssam_platform_profile_get; tpd->handler.profile_set =3D ssam_platform_profile_set; =20 diff --git a/drivers/platform/x86/acer-wmi.c b/drivers/platform/x86/acer-wm= i.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; =20 + platform_profile_handler.name =3D "acer-wmi"; platform_profile_handler.profile_get =3D acer_predator_v4_platform_profile_get; platform_profile_handler.profile_set =3D 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); } =20 + dev->pprof.name =3D "amd-pmf"; dev->pprof.profile_get =3D amd_pmf_profile_get; dev->pprof.profile_set =3D amd_pmf_profile_set; =20 diff --git a/drivers/platform/x86/asus-wmi.c b/drivers/platform/x86/asus-wm= i.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 *as= us) =20 dev_info(dev, "Using throttle_thermal_policy for platform_profile support= \n"); =20 + asus->platform_profile_handler.name =3D "asus-wmi"; asus->platform_profile_handler.profile_get =3D asus_wmi_platform_profile_= get; asus->platform_profile_handler.profile_set =3D asus_wmi_platform_profile_= set; =20 diff --git a/drivers/platform/x86/dell/alienware-wmi.c b/drivers/platform/x= 86/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) =20 pp_handler.profile_get =3D thermal_profile_get; pp_handler.profile_set =3D thermal_profile_set; + pp_handler.name =3D "alienware-wmi"; =20 return platform_profile_register(&pp_handler); } diff --git a/drivers/platform/x86/dell/dell-pc.c b/drivers/platform/x86/del= l/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 =3D kzalloc(sizeof(*thermal_handler), GFP_KERNEL); if (!thermal_handler) return -ENOMEM; + thermal_handler->name =3D "dell-pc"; thermal_handler->profile_get =3D thermal_platform_profile_get; thermal_handler->profile_set =3D thermal_platform_profile_set; =20 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); } =20 + platform_profile_handler.name =3D "hp-wmi"; set_bit(PLATFORM_PROFILE_BALANCED, platform_profile_handler.choices); set_bit(PLATFORM_PROFILE_PERFORMANCE, platform_profile_handler.choices); =20 diff --git a/drivers/platform/x86/ideapad-laptop.c b/drivers/platform/x86/i= deapad-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_p= rivate *priv) =20 mutex_init(&priv->dytc->mutex); =20 + priv->dytc->pprof.name =3D "ideapad-laptop"; priv->dytc->priv =3D priv; priv->dytc->pprof.profile_get =3D dytc_profile_get; priv->dytc->pprof.profile_set =3D dytc_profile_set; diff --git a/drivers/platform/x86/inspur_platform_profile.c b/drivers/platf= orm/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, co= nst void *context) priv->wdev =3D wdev; dev_set_drvdata(&wdev->dev, priv); =20 + priv->handler.name =3D "inspur-wmi"; priv->handler.profile_get =3D inspur_platform_profile_get; priv->handler.profile_set =3D inspur_platform_profile_set; =20 diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/th= inkpad_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) } =20 static struct platform_profile_handler dytc_profile =3D { + .name =3D "thinkpad-acpi", .profile_get =3D dytc_profile_get, .profile_set =3D dytc_profile_set, }; diff --git a/include/linux/platform_profile.h b/include/linux/platform_prof= ile.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 { }; =20 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); --=20 2.43.0 From nobody Sun Nov 24 03:28:03 2024 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2076.outbound.protection.outlook.com [40.107.93.76]) (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 B1170192D7E; Thu, 7 Nov 2024 06:03:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.93.76 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730959414; cv=fail; b=cUfGM3KdpL2efT2AhRh36I23YH/1WcHy8C/c8ERcGONy5IVKrh+CkQQZtV6bUR9A4jSGEYHGjr2zwcn+UC3Z9TsJ3bhenzZV2s3MpG8VIkVZaNqJFrTmLMzJDqguftiF1BpkXLyjxRHgDnhuFHhUk3gkG5nYngSOvQVg/Mf7whI= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730959414; c=relaxed/simple; bh=YrvhKUBrmKASOjRrsD4+2FutuCJZ/+C9KrTb2y2zj1E=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=okvfKpP0lgY/RtalaGXMNPjMb99wYywAJ1OWPLF9EwTnnYr7l5T0/xpsKnL152ljIbvfaSK1msu2xp/vEDVjEL2r+vE/ZWrqWgWD3xMcWg2NP0LDt9yevto9YY0Ehi13SoID8HVNmOqjqbPgx2bEYX2IEWeEYH8WQShm6XlAwxA= 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=uwAepv1V; arc=fail smtp.client-ip=40.107.93.76 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="uwAepv1V" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=kVnaV0d72dPj5RqWaJapTngmFB9LRPPDAaqePNNNIYGK6PbS/YZs+dtwWGF4zQv6Rw5RwIR3Sfe9Cnma9iNeJvblOpb7RMkkuJadm8T3TN1koO7m1Qi+oWv/JrSGKeNhNSFonpP6wDxLK8CAhnLVBFBaFbtJd0nSC8XbzW44y71MKZdIhnfzOIb73ZQ50NVo0pFNDBf3HM4+3K54lumu2ilP5z9sOrG0mjALKfXVAKynP9d1c9yOqzj2+etCXIdRhbsv18+XggjteDiGruye4P1LngrAU6rCTkOhC0ipYDWYcBq7i1tmE56uEQ91QkGLff6dlIxpQA6hcarVLplxJw== 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=4JnTbbFF5wE4ooCniMJuEfRSre9huJa0rS/D8f+fLP0=; b=CRXNEEBhuTZFyWtOcvYVdXbPpZ1BrzKCKufJWxexwB4PEaREyTDVf+cx6V9V8TZf4WFZ4GAxSofotWDCsRDVCg1tGN/FCAVuo9dy/Z0ozCCANwPlkREPrX3r76CI4v23n+yTPVHgZbBPTv3E4gSOa0uwTt/ACb/zWgDzVWtkmFNLMZGIOukrcL3MgMSAD4KXSVSYMVMwCREj7nTd3vNupm67DhL9JdVrYScCJV4GpBgTGkq/clFFBkzgqHtu6InWC9bWRXZmr38hvvrmuvp3OWTDY0OxP/6cfy4ofkOZhgW2+tqIl7zmEuu2PMpt/A6GEKW00fKpXVIX/Cj3M6bdSQ== 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=4JnTbbFF5wE4ooCniMJuEfRSre9huJa0rS/D8f+fLP0=; b=uwAepv1VceZcCqqZ/Cfufy8RHoU/8dDuk7PVEAjoBLTh/tKHQ9Jt57AORFTIqjGGLLu8gQlZh949Al7QLZJlf64VXfnCNnSPFXVXR9hCtxNLEObcJKVr/D8IJ8dpmnI8XF968owDHALIGHMl1QwN34VmuHcklwFPTWDPWtXLxx8= Received: from CH2PR07CA0007.namprd07.prod.outlook.com (2603:10b6:610:20::20) by PH7PR12MB7331.namprd12.prod.outlook.com (2603:10b6:510:20e::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.29; Thu, 7 Nov 2024 06:03:29 +0000 Received: from CH2PEPF00000148.namprd02.prod.outlook.com (2603:10b6:610:20:cafe::8) by CH2PR07CA0007.outlook.office365.com (2603:10b6:610:20::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8137.19 via Frontend Transport; Thu, 7 Nov 2024 06:03:29 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by CH2PEPF00000148.mail.protection.outlook.com (10.167.244.105) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8137.17 via Frontend Transport; Thu, 7 Nov 2024 06:03:29 +0000 Received: from AUS-P9-MLIMONCI.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Thu, 7 Nov 2024 00:03:27 -0600 From: Mario Limonciello To: Hans de Goede , =?UTF-8?q?Ilpo=20J=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=20Kleine-K=C3=B6nig?= , Ai Chao , Gergo Koteles , open list , "open list:ACPI" , "open list:MICROSOFT SURFACE PLATFORM PROFILE DRIVER" , "open list:THINKPAD ACPI EXTRAS DRIVER" , Mark Pearson , Matthew Schwartz , Mario Limonciello , Armin Wolf Subject: [PATCH v5 02/20] platform/x86/dell: dell-pc: Create platform device Date: Thu, 7 Nov 2024 00:02:36 -0600 Message-ID: <20241107060254.17615-3-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241107060254.17615-1-mario.limonciello@amd.com> References: <20241107060254.17615-1-mario.limonciello@amd.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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: CH2PEPF00000148:EE_|PH7PR12MB7331:EE_ X-MS-Office365-Filtering-Correlation-Id: 5805d461-7537-4b58-ee5c-08dcfef1e70a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700013|7416014|1800799024|82310400026|376014; X-Microsoft-Antispam-Message-Info: =?utf-8?B?SE92UkxwWmFXdUtaK2VIWEh0NklXSEhuWDNKeG1Vcjdlc3hMZ0hCMWdpRFF6?= =?utf-8?B?OEIzbjF6ZWJXUW5xNFkvdlc5dlNzaFdueUl5cWRtR0xWMW5JNWpYYXNsdnBD?= =?utf-8?B?S2F6dnFDR3llR3hFaTdiWVQ2a3hjejRjMGdlWGFJaWlFd2cyaWl0azhQZnVP?= =?utf-8?B?SnRkM3M4M3gyb3djUExlREFLOWdob3orZ0QxWUJlSDJKamRFaVkzMzFSdzNP?= =?utf-8?B?TnBnWXk1NnZ6SmZ4NWJLY3ZWcWh2aU1qY0JRUTY3L095eFQyN1g4a0xjVDJH?= =?utf-8?B?VXN5NG9qLzJQK2M1M21HUWJZZVpZbkp1RDZ6bXdHOXJKUTNycmtQMlNFSFdE?= =?utf-8?B?SUxXOWNLSVdJaGpuQVp2ZFN4V3Z1ejIwK28yMUFsSFBVYmNudnRncE83T0Yx?= =?utf-8?B?SXEvd2l4cUxnL2Q0S05tKzYzb2tjemFwaStmK0JHa3U0VUxXN0h1ZWs4ZzZO?= =?utf-8?B?Rm15dFIxdTJlVHE0TlAxVW1zWEJQTzNVaXROSm9zU2RjNW41TnRMVWVYSm5W?= =?utf-8?B?TEh4YldsSmxmOXE0NlQrOW0wS05QM0ZJS3hNcyt4OE0wRWxoQU5uVmVuYnpq?= =?utf-8?B?MlRUVHJrZTZzdkVoR0xkQUs1aUliNVZNYmxnczBtV3lzL0pJZFcybTF0WDEr?= =?utf-8?B?UEZ4RXduN0NuMmJzaXZuaUw0MFdHWDBvckd1Ylh1N2tsWWx2d3U3UllOZHR2?= =?utf-8?B?a3ljTkl2NkVwTTBOWm5RZElQSUNPV25EVTI3UkdCd0d3alJFOTBJVzBuTFR6?= =?utf-8?B?aUxHc2huazAvTVNCRkZDazhmVEhvOXJNc3MyaWNDbmZBYm0xbEZqMFhybm82?= =?utf-8?B?MjN3KzJjNjdtQmpFTit0ZXBXL21Sb25zMlcyWm15dkhkNmxQOHpXak9xZ09Z?= =?utf-8?B?UW5XRmlPT1ZnTmQxbjk2NGFTdkFHRnpFQjJkKzJYNi9ONjhuLzlHa2J3elVn?= =?utf-8?B?M25Nb1hpWm5WTmppcGtEVEVPK3Z1b3dDYklwNWJ1MUEyWEMyeDNvMEJtZS9i?= =?utf-8?B?K1pxaEdkRGp4Ykd5cEhwdmRSN3Nmdi9BKy8xdnRUV1p0UTR2ZWNEWmx2ZGtw?= =?utf-8?B?a083bXE2ajVyckVwWm0ybmlXTzF5MUtXL2gzK21JVGlpZzE2dzd3elZNRCtq?= =?utf-8?B?MFp0LzdoVENFWFJ1WG95MlVhY2ZtTGxtTDRQTjF1ZTNJb1lEeHIwWnQ2SzZT?= =?utf-8?B?MmNBS0Z5amE5VFczNmVPeVNqSG1BZTVPY3RsNkJnaEZUU2Nia280MjdTcERq?= =?utf-8?B?QXFkanVPbDlOcDkvVzNVWklJdTU4ZDlzazNLY1EvSmRSL3BBK3QrRWxHVFFk?= =?utf-8?B?SGhxdytYZm4vS1BXZllJNE1MK2pSZURFMDRsZGlLdnAwTzhCV3JjaGZ1dmRT?= =?utf-8?B?dlozMmtnL1I2eVZpMmhQa0h0a292ZHMvUDhSNjZDQWNLeUZOTXU0NS8vaWd4?= =?utf-8?B?MHNmTUx0ZjBsUDNSUUZtZURlNHh6Q0g0N3psRlVUYWIzWWw4alkwU0MxMThW?= =?utf-8?B?aWFDWThvOTdsUk9SUURoVnpGdmFuWjlWN1FyWmdhQnl2UmUyL0I4MlBrZWxL?= =?utf-8?B?dDNxcHJxU0Vuajg4TXAwZ0dzbjlmRmpCRk1UT0VOaERIMVdlaHNMUTNVV1Ey?= =?utf-8?B?RTBqNDdqUi9UcythVVpkT2xDNU9vWXBBbllqdmQxZ0ZUVGx1cTZ4cFptWU85?= =?utf-8?B?c21TdE5KcDFBMFIwU3VjQko0VjlaVXBrMkROendRTkZnUG4xL1pnd29LWXJj?= =?utf-8?B?bzVLSEFLZDR1cVd1RnA3UWppUGk1bnRqbnBPOThsWERySGR6Sm5yK0QyQ0xR?= =?utf-8?B?eEMzSWVsdFVVd2YzU0tQS2ZtS0hCREJVM3FxSEZBNytHQ2g2dUt5dUxBckdH?= =?utf-8?B?OUhrUEtyaTIwRGFDbzR6Q1YvUklLbGYySXRweTNHRHRBMXc9PQ==?= 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)(1800799024)(82310400026)(376014);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Nov 2024 06:03:29.4563 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 5805d461-7537-4b58-ee5c-08dcfef1e70a 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: CH2PEPF00000148.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB7331 In order to have a device for the platform profile core to reference create a platform device for dell-pc. While doing this change the memory allocation for the thermal handler to be device managed to follow the lifecycle of that device. Reviewed-by: Armin Wolf Tested-by: Mark Pearson Reviewed-by: Ilpo J=C3=A4rvinen Signed-off-by: Mario Limonciello --- v5: * use platform_device_register_simple() --- drivers/platform/x86/dell/dell-pc.c | 32 +++++++++++++++++++++-------- 1 file changed, 23 insertions(+), 9 deletions(-) diff --git a/drivers/platform/x86/dell/dell-pc.c b/drivers/platform/x86/del= l/dell-pc.c index 3cf79e55e3129..0cd9b26572b61 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 =20 #include "dell-smbios.h" =20 +static struct platform_device *platform_device; + static const struct dmi_system_id dell_device_table[] __initconst =3D { { .ident =3D "Dell Inc.", @@ -244,9 +247,15 @@ static int thermal_init(void) if (!supported_modes) return 0; =20 - thermal_handler =3D kzalloc(sizeof(*thermal_handler), GFP_KERNEL); - if (!thermal_handler) + platform_device =3D platform_device_register_simple("dell-pc", -1, NULL, = 0); + if (!platform_device) return -ENOMEM; + + thermal_handler =3D devm_kzalloc(&platform_device->dev, sizeof(*thermal_h= andler), GFP_KERNEL); + if (!thermal_handler) { + ret =3D -ENOMEM; + goto cleanup_platform_device; + } thermal_handler->name =3D "dell-pc"; thermal_handler->profile_get =3D thermal_platform_profile_get; thermal_handler->profile_set =3D thermal_platform_profile_set; @@ -262,20 +271,25 @@ static int thermal_init(void) =20 /* Clean up if failed */ ret =3D platform_profile_register(thermal_handler); - if (ret) { - kfree(thermal_handler); - thermal_handler =3D NULL; - } + if (ret) + goto cleanup_thermal_handler; + + return 0; + +cleanup_thermal_handler: + thermal_handler =3D NULL; + +cleanup_platform_device: + platform_device_unregister(platform_device); =20 return ret; } =20 static void thermal_cleanup(void) { - if (thermal_handler) { + if (thermal_handler) platform_profile_remove(); - kfree(thermal_handler); - } + platform_device_unregister(platform_device); } =20 static int __init dell_init(void) --=20 2.43.0 From nobody Sun Nov 24 03:28:03 2024 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2047.outbound.protection.outlook.com [40.107.236.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 86E39194C6E; Thu, 7 Nov 2024 06:03:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.236.47 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730959418; cv=fail; b=JVgRQsTzWcWdJaKMeu0MkOBP+RCur9uyhIJh0AAlUBSt7ZkZSQhj5FICT4KDhQ2Ok5lOBclLk5G2m8TROmuzuc8QgrIHVOQmSjAwT0i8W32V2SWXcuKIfv7CfOFE7EInSRo2KTHKIYeu4ayXzX33URaNGNQaOw9fBLHH6zSFmII= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730959418; c=relaxed/simple; bh=IZ1HlMQ/Xt3xeFZFd0KcV+Z8RNZRAWxNsipJcv2/foM=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=mzqUU+wZ1zGXoKEINSvT4Ba4aQV+lS3Z2xzXZ1/x9MMh8J3Zxfw4xezjtJ3P8UXChlZfUChcxXb7jG/hKzpfDLa03X/E/hztk2mMaxQQw2gVYcTwQvqAVBZz8Z+cxsrD4ZDMGXFfT5oojvihvueazZcJ94TsWObs57NVYFrdXAo= 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=DJYKoq05; arc=fail smtp.client-ip=40.107.236.47 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="DJYKoq05" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=gWM1g+kWSAbRsaDnOI6XJu4IlLZJF1hv4xUeooTJGK+4+i+c/LOklyeHyjwbu53ZXf3RGlhqv7sXmmmmdOOHBWmalWK6G9XWzsJlWp5fCtdFqDSIIqGGOW1yO9LcaYEr+5BEio5vU36c8SZpDquOonYnApWV8HPoZS1tk6LGs4BAeCB7XsAr8p7glt6/HQU8BWSHpxwPPsH+6ZquJaSCo0Ki921QM8O6WmxZhZ6D8FC9fn6KkmFbj3liX0sPbAUAZoklGWHQlbU+GSghGlKlSuF54mZ0jBWrxpezUc7OogVI7VMxrjt9JaclnVXSNDVaWcgEgHyaN+Q/RRLpQ5nYQg== 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=9rcEA9VFt43X5+VIMws0c2U3e7AuxufNdvwsPe43s08=; b=JHFCffAFUJ+NT2nwUCs31+yLCc2fVV+dje6TTM2phPkcg5Ao9IZTikIjlfwWfTEx32v7e/XIPJbeIOiW9pJU8YVrubnKk5OjtArNw2IJbzD63u4QGD5TnCPwe/R1t+cy/Dy6ATJdfs37Lp+ukBqTHuz0dardXrxQpnyNRpYAL6vmvk5C71xV4VSUfrR1aonnXU3duZbbZ5F7nASNS4oaVzGc304TqjbL37LAJt3LnA8FaiHZKubvZfm9VRKQdZe9OqQ9ghn4oIjLDkyJI1sgpr1vxmh/tpir33Wz9sVXsHnoCFek1fp7jQOb6yK4ZxnkP8oPsvgnh+iVmz2zojqVWw== 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=9rcEA9VFt43X5+VIMws0c2U3e7AuxufNdvwsPe43s08=; b=DJYKoq0560kHVNJzThHFhIFqVuR8PWxLZfWDLGUAa/XZ5jTZUSktqkiDA52r96mnHw1FLGoGJCWtzAPyvYBuOo/KBRAMrqo9E+VolfQpG66sLVyMDbVuicTriQpqh27NtWF4qBpivj2k6SRawAmH9/nGRrF+Z88rW0MlO+d0Owk= Received: from CH5P222CA0019.NAMP222.PROD.OUTLOOK.COM (2603:10b6:610:1ee::20) by SJ0PR12MB6686.namprd12.prod.outlook.com (2603:10b6:a03:479::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8137.20; Thu, 7 Nov 2024 06:03:31 +0000 Received: from CH2PEPF0000014A.namprd02.prod.outlook.com (2603:10b6:610:1ee:cafe::e6) by CH5P222CA0019.outlook.office365.com (2603:10b6:610:1ee::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8137.20 via Frontend Transport; Thu, 7 Nov 2024 06:03: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 CH2PEPF0000014A.mail.protection.outlook.com (10.167.244.107) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8137.17 via Frontend Transport; Thu, 7 Nov 2024 06:03: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; Thu, 7 Nov 2024 00:03:28 -0600 From: Mario Limonciello To: Hans de Goede , =?UTF-8?q?Ilpo=20J=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=20Kleine-K=C3=B6nig?= , Ai Chao , Gergo Koteles , open list , "open list:ACPI" , "open list:MICROSOFT SURFACE PLATFORM PROFILE DRIVER" , "open list:THINKPAD ACPI EXTRAS DRIVER" , Mark Pearson , Matthew Schwartz , Mario Limonciello , Armin Wolf Subject: [PATCH v5 03/20] ACPI: platform_profile: Add platform handler argument to platform_profile_remove() Date: Thu, 7 Nov 2024 00:02:37 -0600 Message-ID: <20241107060254.17615-4-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241107060254.17615-1-mario.limonciello@amd.com> References: <20241107060254.17615-1-mario.limonciello@amd.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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: CH2PEPF0000014A:EE_|SJ0PR12MB6686:EE_ X-MS-Office365-Filtering-Correlation-Id: d619c148-b22b-43df-8481-08dcfef1e823 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700013|82310400026|7416014|376014|1800799024; X-Microsoft-Antispam-Message-Info: =?utf-8?B?Y1BiTEtudDRhSkRzbmlwZGJwKzFVUlVJZjlpaHZidkY1Um1MS3IrUVlKVUhM?= =?utf-8?B?SFg1R2ZJVTE3TDRDaGE2SGs5RlBZVG1SdDIrNklORFlYQUUxM28zbFNBcFMz?= =?utf-8?B?ZU80T1c1V2o5MXlGamphdHBJK3FuN1lQbm0yaXZCc1RYamQ0MEg1Vi9ndDEw?= =?utf-8?B?V3ZFd1l5MTA2SmdpcVNralVDOWpmNWNlaHhobHZhZm9mTlFEaVhERHNYZzZV?= =?utf-8?B?VDNCM1ZWVlZsbzRna05KWU82cEJJS0t3S3ArN3ltUmgwZWpRWVdXczFCMTRF?= =?utf-8?B?Skp0SFRUT2Y1aDlHV0FyS3JlYmpHZlc1bUt2VFR2Q0dWNHZMYTN5eUgyQVNX?= =?utf-8?B?bm43cWIrZllwQWZkYTVYeVpxMWFCZWdvUzNWcFdaeUI2T3BJeGhaTTVTbXgx?= =?utf-8?B?L0d3R2txUHE2UlVSY2o2aDF3djZBaXZvNG5CRVFQOFBidGxLelhnd282UEpk?= =?utf-8?B?TEg5aXZhMjBLTGhqcVhWMU15NkxaVE9vVmE3eldOeEtERjNIRC9zczNodzg1?= =?utf-8?B?NklmTG4vMVhMNkRIVTg5SCt0aHBSRFhTWTlFVXVHR3JFMnFjZDRwNERsQURH?= =?utf-8?B?QTBpOVJqd1BvSGVwSkhQdzJ6Nyt5WGxaUlFoVW0rUC9aRnFyZFZFWHFkRWt6?= =?utf-8?B?bEltUGJObjdjMGU1cXcyYUc3TERaNlAveU5JdDdtOFFaL0tOZzVOeWNiNkpW?= =?utf-8?B?Nk0zeFZTdk85ak1VQjQ1cmVFR3R0cG1HRU5BNTNCY3ZaOGh6VmRtdTVJb253?= =?utf-8?B?NklFa2I4Wm9ZUG9qUHl1eU9nK29kdWVON3M5a3BjVDJxcUpnVEZnelRqdS90?= =?utf-8?B?TWlJSTJwdTdsOVJtTTQ3RENwMjcyWW9Vd0xROUtxVFNoczNLUVJLUVVrcytW?= =?utf-8?B?STBRMGNnV0dBZFhyV0tsSXJpUDFwUk1TL0I2cnY4dUd6ejRlVmRDbUc5blRJ?= =?utf-8?B?UXM4cmh4U3JwcWhTR3MrMVU1dHltTWZWSzhLZlA3ZnRWc3JUUDk1TTVhTElh?= =?utf-8?B?MjFHVWFrNWRiTzVUK1ZsR2RTb0Q1NVFBb0lmUHRGRFA1TnpRUzhSUm5Xd2ZM?= =?utf-8?B?bzV0eitFRG5LYW5hK2NkL2RwWTM2dUhHZDlFNjNoR24za2RaN203eGNYai96?= =?utf-8?B?SG13ZndyVkE2bXRLTXZJd2ZpN0xvc3BSZ1pMeEhJa2hFcVlaY3hpaGdvVlpv?= =?utf-8?B?aUoweVJ1VUc1ek00cGtlaVZ6djl5RmZueHJTMXdYYm1zbXJSSWRyMGEvS2s2?= =?utf-8?B?SWZQZVdsdFFTV0JYQmszWHNkWDdrdDdBVWRLZVNyMmxmSldEU3hNaUE3SmJC?= =?utf-8?B?WjUyK28zUWo2bVhqVEtmRVFMYzgrZUErcGdKTllzZkVUQnMxVnhMVFdqQ1dt?= =?utf-8?B?ZzkwckErbmMvVmhGVlpYa2FDTXdWazh2NEJ0cGczQkMrK2JJSGx6ZXU1MVMr?= =?utf-8?B?USt2R0FXOXZHbkZmdCtpQjllcC9nOE9XRjFGWk9SK1MvU1FpLytzNk92Z1lB?= =?utf-8?B?czlXV2NGOWlnVFEwSjN2bFRySkJUdnY1OEV0Y1RYTDR2U0ZlTlJKTWJqRXBK?= =?utf-8?B?Ymg1ZW1nYVUxcWk4THFjNytKRnhIZVhVVUJTdTFnRjlIWUNBc1UzU0pGVXA5?= =?utf-8?B?Q3RYMmtZaENLNWw4dllrYW9EaXdWMTdtcmxZeGdNQTU3RHJnWG5NdTN3WGIw?= =?utf-8?B?cW93cEg2SEFjM1Bxd0Ura1hKVmQvVDdQbjF6Tm94b3c0ejYzcE9mQWZaSS9B?= =?utf-8?B?a3N4WEQwTGJ6OGdVQ2JVVzlvY2FPZzUrREppVjRrMmRyYjByM1Q5R3Zjd0pi?= =?utf-8?B?ZkdNd3pncnNJTHF4dUVGM3dnajRRVnBYUXRydDRIUDc1SVExQzBvN2dlRXgv?= =?utf-8?B?S0k0T0JJTDVubWxUdHI4eGlUTUUwMnJWenZXQzFUVTVoeXc9PQ==?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(36860700013)(82310400026)(7416014)(376014)(1800799024);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Nov 2024 06:03:31.3108 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: d619c148-b22b-43df-8481-08dcfef1e823 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: CH2PEPF0000014A.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR12MB6686 To allow registering and unregistering multiple platform handlers calls to platform_profile_remove() will need to know which handler is to be removed. Add an argument for this. Tested-by: Mark Pearson Tested-by: Matthew Schwartz Reviewed-by: Hans de Goede Reviewed-by: Mark Pearson Reviewed-by: Maximilian Luz Reviewed-by: Ilpo J=C3=A4rvinen Reviewed-by: Armin Wolf Signed-off-by: Mario Limonciello --- v5: * Add tag v4: * Add alienware-wmi too --- drivers/acpi/platform_profile.c | 2 +- drivers/platform/surface/surface_platform_profile.c | 6 +++++- drivers/platform/x86/acer-wmi.c | 4 ++-- drivers/platform/x86/amd/pmf/sps.c | 2 +- drivers/platform/x86/asus-wmi.c | 4 ++-- drivers/platform/x86/dell/alienware-wmi.c | 2 +- drivers/platform/x86/dell/dell-pc.c | 2 +- drivers/platform/x86/hp/hp-wmi.c | 2 +- drivers/platform/x86/ideapad-laptop.c | 2 +- drivers/platform/x86/inspur_platform_profile.c | 5 ++++- drivers/platform/x86/thinkpad_acpi.c | 2 +- include/linux/platform_profile.h | 2 +- 12 files changed, 21 insertions(+), 14 deletions(-) diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profil= e.c index d2f7fd7743a13..c24744da20916 100644 --- a/drivers/acpi/platform_profile.c +++ b/drivers/acpi/platform_profile.c @@ -205,7 +205,7 @@ int platform_profile_register(struct platform_profile_h= andler *pprof) } EXPORT_SYMBOL_GPL(platform_profile_register); =20 -int platform_profile_remove(void) +int platform_profile_remove(struct platform_profile_handler *pprof) { sysfs_remove_group(acpi_kobj, &platform_profile_group); =20 diff --git a/drivers/platform/surface/surface_platform_profile.c b/drivers/= platform/surface/surface_platform_profile.c index 61aa488a80eb5..1c9e37b1f4761 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_d= evice *sdev) return -ENOMEM; =20 tpd->sdev =3D sdev; + ssam_device_set_drvdata(sdev, tpd); =20 tpd->handler.name =3D "Surface Platform Profile"; tpd->handler.profile_get =3D ssam_platform_profile_get; @@ -227,7 +228,10 @@ static int surface_platform_profile_probe(struct ssam_= device *sdev) =20 static void surface_platform_profile_remove(struct ssam_device *sdev) { - platform_profile_remove(); + struct ssam_platform_profile_device *tpd; + + tpd =3D ssam_device_get_drvdata(sdev); + platform_profile_remove(&tpd->handler); } =20 static const struct ssam_device_id ssam_platform_profile_match[] =3D { diff --git a/drivers/platform/x86/acer-wmi.c b/drivers/platform/x86/acer-wm= i.c index 53fbc9b4d3df7..71761d4220c26 100644 --- a/drivers/platform/x86/acer-wmi.c +++ b/drivers/platform/x86/acer-wmi.c @@ -2546,7 +2546,7 @@ static int acer_platform_probe(struct platform_device= *device) =20 error_hwmon: if (platform_profile_support) - platform_profile_remove(); + platform_profile_remove(&platform_profile_handler); error_platform_profile: acer_rfkill_exit(); error_rfkill: @@ -2569,7 +2569,7 @@ static void acer_platform_remove(struct platform_devi= ce *device) acer_rfkill_exit(); =20 if (platform_profile_support) - platform_profile_remove(); + platform_profile_remove(&platform_profile_handler); } =20 #ifdef CONFIG_PM_SLEEP diff --git a/drivers/platform/x86/amd/pmf/sps.c b/drivers/platform/x86/amd/= pmf/sps.c index e2d0cc92c4396..cfa88c0c9e594 100644 --- a/drivers/platform/x86/amd/pmf/sps.c +++ b/drivers/platform/x86/amd/pmf/sps.c @@ -425,5 +425,5 @@ int amd_pmf_init_sps(struct amd_pmf_dev *dev) =20 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-wm= i.c index c7c104c65a85a..f5f8cda7fd19c 100644 --- a/drivers/platform/x86/asus-wmi.c +++ b/drivers/platform/x86/asus-wmi.c @@ -4885,7 +4885,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); @@ -4912,7 +4912,7 @@ static void asus_wmi_remove(struct platform_device *d= evice) asus_wmi_battery_exit(asus); =20 if (asus->platform_profile_support) - platform_profile_remove(); + platform_profile_remove(&asus->platform_profile_handler); =20 kfree(asus); } diff --git a/drivers/platform/x86/dell/alienware-wmi.c b/drivers/platform/x= 86/dell/alienware-wmi.c index ac0038afd98fa..e7f97eb24a014 100644 --- a/drivers/platform/x86/dell/alienware-wmi.c +++ b/drivers/platform/x86/dell/alienware-wmi.c @@ -1064,7 +1064,7 @@ static int create_thermal_profile(void) static void remove_thermal_profile(void) { if (quirks->thermal) - platform_profile_remove(); + platform_profile_remove(&pp_handler); } =20 static int __init alienware_wmi_init(void) diff --git a/drivers/platform/x86/dell/dell-pc.c b/drivers/platform/x86/del= l/dell-pc.c index 0cd9b26572b61..b1ada199e7978 100644 --- a/drivers/platform/x86/dell/dell-pc.c +++ b/drivers/platform/x86/dell/dell-pc.c @@ -288,7 +288,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); } =20 diff --git a/drivers/platform/x86/hp/hp-wmi.c b/drivers/platform/x86/hp/hp-= wmi.c index 26cac73caf2b9..bb8771d8b5cd8 100644 --- a/drivers/platform/x86/hp/hp-wmi.c +++ b/drivers/platform/x86/hp/hp-wmi.c @@ -1692,7 +1692,7 @@ static void __exit hp_wmi_bios_remove(struct platform= _device *device) } =20 if (platform_profile_support) - platform_profile_remove(); + platform_profile_remove(&platform_profile_handler); } =20 static int hp_wmi_resume_handler(struct device *device) diff --git a/drivers/platform/x86/ideapad-laptop.c b/drivers/platform/x86/i= deapad-laptop.c index 1f94c14c3b832..50819ac919e87 100644 --- a/drivers/platform/x86/ideapad-laptop.c +++ b/drivers/platform/x86/ideapad-laptop.c @@ -1135,7 +1135,7 @@ static void ideapad_dytc_profile_exit(struct ideapad_= private *priv) if (!priv->dytc) return; =20 - platform_profile_remove(); + platform_profile_remove(&priv->dytc->pprof); mutex_destroy(&priv->dytc->mutex); kfree(priv->dytc); =20 diff --git a/drivers/platform/x86/inspur_platform_profile.c b/drivers/platf= orm/x86/inspur_platform_profile.c index 03da2c8cf6789..d8fd59b826f3a 100644 --- a/drivers/platform/x86/inspur_platform_profile.c +++ b/drivers/platform/x86/inspur_platform_profile.c @@ -190,7 +190,10 @@ static int inspur_wmi_probe(struct wmi_device *wdev, c= onst void *context) =20 static void inspur_wmi_remove(struct wmi_device *wdev) { - platform_profile_remove(); + struct inspur_wmi_priv *priv; + + priv =3D dev_get_drvdata(&wdev->dev); + platform_profile_remove(&priv->handler); } =20 static const struct wmi_device_id inspur_wmi_id_table[] =3D { diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/th= inkpad_acpi.c index c8c316b8507a5..619a4db74e5f3 100644 --- a/drivers/platform/x86/thinkpad_acpi.c +++ b/drivers/platform/x86/thinkpad_acpi.c @@ -10637,7 +10637,7 @@ static int tpacpi_dytc_profile_init(struct ibm_init= _struct *iibm) =20 static void dytc_profile_exit(void) { - platform_profile_remove(); + platform_profile_remove(&dytc_profile); } =20 static struct ibm_struct dytc_profile_driver_data =3D { diff --git a/include/linux/platform_profile.h b/include/linux/platform_prof= ile.h index 6fa988e417428..58279b76d740e 100644 --- a/include/linux/platform_profile.h +++ b/include/linux/platform_profile.h @@ -36,7 +36,7 @@ struct platform_profile_handler { }; =20 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); =20 --=20 2.43.0 From nobody Sun Nov 24 03:28:03 2024 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2047.outbound.protection.outlook.com [40.107.223.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EB66B194ACA; Thu, 7 Nov 2024 06:03:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.223.47 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730959417; cv=fail; b=NgjLj1OQ+QGBAdt/NPaiELcEgAq/wSreszASZK/A13tHLyG6JmhPMXt1oFMrS2vOKEBttH56+pEZnzhIfC0Kj17DfWgsjCbh8g3K9BNlQT+r39uGT3Orw9lpoVcOCwi4E6whrlT8bdsJumM9wFPGVYha45tLvz3QMjvFh96r9yY= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730959417; c=relaxed/simple; bh=qRMkcNUifXAtXpphjU+checUJ1PxliYj1y1hj/6MSRU=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=ChXBMTmthbxzRUK43LphI0kvK26iEoaZEM5S3nc6zEpCPmRN4A30zSLK6sc/GGKiVgfcpSgiYwt4XBUIfR6wOfzEOsHgbYrHiMXQAu/h05z79/WQX8WYjgwnve7tpe9TGhMnMXDoYOdNVY5Rehf2QZahPboYItIH9WfDJlK/xnU= 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=qlpJPxdm; arc=fail smtp.client-ip=40.107.223.47 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="qlpJPxdm" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=FSK1urzYDmKgs/r5nGXyd7HdcdpEyEx0X6gCF5L+nuaIpXjg14FIVmWaQYoBX+pwntEqubvKuX+k0/5oQDeuLrAnNweOgd5yHpU1EEEb6SS3emQhJNUxFl5ytgOuuTXuHQuxwBbalEJ3Y8sEdIfj6llLwqrPQkyLh4Yne5SaquxOYMuxfG4naknJ7j3sYzRqai6ayIbIzP2+XgyCUXBj+HrSP6JwHvaURGDJ9ONtN4txL59MYjpmTT3A14m+8lJI1ANDC8s2M1DjejWowZkbWdY4NZB6wQjz9hTPJw++HrxOdxg2o7vgevZ3bJs9a+ZrWb3T6NXjlPaq2IdruD/XHw== 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=cT2khbTtZ2PklkeQ8e6PL1V7vzlpvNCYOcZuzpHGU/Y=; b=Ol99oQuH9K9Fe7xpe1y+lYhBoIT/q9k8ll+nzK1BCOGqfAqvtG2Kx21WC513CZGDLxN96/4VzlaVNZFTOj5Lp4dTS/8gkQs7jHlPKO+rA1+DPG+HzcVyvCnMKTBqZnevwkjbGgidNXTQC8jg2xH4879ePQLSm5pteK4PMHQktJUV41wyNJO1PEK01J2GWW65lYN8d2rzZZ5SV/JjVSo7/CpG/5750EcDz/Oka1u2Y+eCT/GS6Op+U4gYKK3I/kmTjnzoJZg0ZyrAB3CpohJJ7k50UxFWxhEYTz3soqrcsnvJWq8huJhF+Ach0Wwp0jXmJImWx9jbShYFVLvk4D+0sA== 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=cT2khbTtZ2PklkeQ8e6PL1V7vzlpvNCYOcZuzpHGU/Y=; b=qlpJPxdmBUtzsThAkjfbpDODw/hrTZoe7elO7vSaiwCTeweMQUmEDsPleyOP7kdL4a2IQo34asn7RMIi9EcIhFL9PCDS3SfGnFJ69lVIdiWsXgUkXRqAhP0I+50kyRSSUWHRvz+MR9tqw9EoSwqoDqmla+s6rbU8FEh21+LBWms= Received: from CH2PR03CA0009.namprd03.prod.outlook.com (2603:10b6:610:59::19) by CY5PR12MB6480.namprd12.prod.outlook.com (2603:10b6:930:33::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.30; Thu, 7 Nov 2024 06:03:33 +0000 Received: from CH2PEPF00000146.namprd02.prod.outlook.com (2603:10b6:610:59:cafe::ce) by CH2PR03CA0009.outlook.office365.com (2603:10b6:610:59::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8137.19 via Frontend Transport; Thu, 7 Nov 2024 06:03: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 CH2PEPF00000146.mail.protection.outlook.com (10.167.244.103) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8137.17 via Frontend Transport; Thu, 7 Nov 2024 06:03: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; Thu, 7 Nov 2024 00:03:30 -0600 From: Mario Limonciello To: Hans de Goede , =?UTF-8?q?Ilpo=20J=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=20Kleine-K=C3=B6nig?= , Ai Chao , Gergo Koteles , open list , "open list:ACPI" , "open list:MICROSOFT SURFACE PLATFORM PROFILE DRIVER" , "open list:THINKPAD ACPI EXTRAS DRIVER" , Mark Pearson , Matthew Schwartz , Mario Limonciello , Armin Wolf Subject: [PATCH v5 04/20] ACPI: platform_profile: Move sanity check out of the mutex Date: Thu, 7 Nov 2024 00:02:38 -0600 Message-ID: <20241107060254.17615-5-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241107060254.17615-1-mario.limonciello@amd.com> References: <20241107060254.17615-1-mario.limonciello@amd.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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: CH2PEPF00000146:EE_|CY5PR12MB6480:EE_ X-MS-Office365-Filtering-Correlation-Id: 32e1fc26-143f-43cf-89c4-08dcfef1e930 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|7416014|82310400026|36860700013|376014; X-Microsoft-Antispam-Message-Info: =?utf-8?B?T0lBZWJ2Y25BU0hnYnE1UDUwN2oxbEFrblAydFczQlEyL0prei92VEZWakVJ?= =?utf-8?B?UWY2LytHWUdzODdnRHdleklKZmQyR2ZaZTY4VGdPMkRKSzBEOVY1Rlo1VGx6?= =?utf-8?B?alVVa0U4bmtlTFEyNWpKa0wyMkdnK0RTLzZROVNFTUJ6NllFckJsNTF1akN0?= =?utf-8?B?NGFjeTh0bHNtMllPSEllZDVtOW4yeGYxSFN3U09tY29TNVpXdWUxVVpCRDdL?= =?utf-8?B?TWxJTE0vd0JiejRqYXBoQkRyMDRVaGxhYU16ZUZ6TXh4blEweGxkMktyb3RQ?= =?utf-8?B?K3VNMVp4UnFrbGxkSVpsblhYZG0xTDJ6ZWdNNzV2dFFkdzQzUEtXc3RBSlEw?= =?utf-8?B?ZjJPbW1WVGNqNnJXcHh0eWxvSmpLYUxubGlyN2wyUmFYSlZLbGhYZWhtbElU?= =?utf-8?B?UkErQktES3lOUTc3M3BrSEc3Wm43Q3UrNWFFUDlDQWhaNkRKQnpna0JtUHJw?= =?utf-8?B?OVREWUJQWmFOL285bDJVSXJQTnEvU0E3RU0ySXEzak42aHN5Y1hOTElINWdz?= =?utf-8?B?bkpPd282QStPaERMVXZGbHNyak5qMFBWTVArWStDK0NCU1IzM01UY2ZaYUYr?= =?utf-8?B?RFlPWjN2ZG9BUWNINml3ZnhHUlBvMEFpWUhSU2JYRnBWbml5S1pmYXRTMjNi?= =?utf-8?B?K1RUbkhUL2xKai94eVUzWlBybXp3VjMxZzRFL3dzTVp1azJ6ZVRNcXBwQWR2?= =?utf-8?B?cHNiMGVMUmZuNFUwbktwSDdvMHNqUHFrRTJKeUZDdFE1L0EvaDREbS9SSTBq?= =?utf-8?B?bWpZbWxOUnBOeU1FRnZxd2F0QVlyUHIwTlZodERlUHo4SjNMODZySlgxeFNl?= =?utf-8?B?WTZ0RU9iMURHVGF4cDU1aWJSUmZ5YnFtSGxEVzRoenF1NWFrYkt1UmhCNkVx?= =?utf-8?B?RDNlRE5mLy9nbWhRWDF5bm1TMnBZV1dWNlNpNlJndk1vWlRNZ1ZyWVhyckFV?= =?utf-8?B?YWo4Um83SUFIbkZtME0rb3lJTTZTa1F6REo1UzlsTlZkdDNmcGVCR05NNXRD?= =?utf-8?B?aHd5eEFYOG9mZEZIbkxNNTdoWHI0WGR3MWRUb0k1Z2ozWDY2enFaV0J1ZlR2?= =?utf-8?B?Y1pWaWlMSUxNb3RkVnV3ZExhMERnWnRiakszekFENUNrV2RrZkxaNENGYnpW?= =?utf-8?B?OE5PNHo2ak5WTmVIbWo5TXZBQkI0bzBtNGpVSWFYT3IvMHpwVlpmQ1JhRjNL?= =?utf-8?B?TllRRk1VNks1Vk1Bb3BySVhCMW9tRXhZbmhRWk1yN0RkclFSQWsrQnZncGlV?= =?utf-8?B?VlJTWDQzYTF3cG9Ka0swdHR2ZGZkaDk4eUpBS1d6V1ZFN3BZTktrdCtDNWxZ?= =?utf-8?B?OTBzSjYzZjEzVXhsYi9mZDlFdHZVVG42aHJsNDBxamxiRXBBeXc4ck83ZjdQ?= =?utf-8?B?TW5IeFhBczZpczRTV1Q1eGNFSTlOMlVlNnhHS3A1NWp4Tm92THkrSlcrQlZi?= =?utf-8?B?bi9EQ2Y1SVhldnViczlYN05BNkxxdUdvYVJsNmplRVF1UXpBeUt5YkNYZVQz?= =?utf-8?B?eDhBQktEUFg3NkhYVlhMVnJ6TktyRlUvVW50Rk9GQVkzTzZUTzBpWVhEWVQ2?= =?utf-8?B?dXZOR0dyc2JVK09aSHplczRRSmNCeVhBbWJ6SGxUWHBjVjgyRWRTM1lIMGh6?= =?utf-8?B?QkhydUdkRnEwRGQ4dlB3d2RNejFTeWpsc2VrRVY4dXZ2RldlbU9FUG80WDRz?= =?utf-8?B?UWo4U2NSNHBSVWhOc2Z3UkJJV0IwbzZiR3M2S1VWMXVNd3UvZ2cydEo5Tk5u?= =?utf-8?B?RDV1WTRCbVlzZ3NxS1E3M251d2lkV2poQkxoZTVwU0VOek1nTXd1dk9HbGxU?= =?utf-8?B?Z0RRTS9qR0RUMm41VHNXWDVqeEJmc0ZJbU0xWVQ5S3VONEFpRkIvNWlMYmw0?= =?utf-8?B?RUYyeFRiZ01lN3hobVRpWjFnYlBRQXFSZUxocXdCQ0dEY0E9PQ==?= 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)(82310400026)(36860700013)(376014);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Nov 2024 06:03:33.0894 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 32e1fc26-143f-43cf-89c4-08dcfef1e930 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: CH2PEPF00000146.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY5PR12MB6480 The sanity check that the platform handler had choices set doesn't need the mutex taken. Move it to earlier in the registration. Tested-by: Mark Pearson Tested-by: Matthew Schwartz Reviewed-by: Ilpo J=C3=A4rvinen Reviewed-by: Mark Pearson Reviewed-by: Armin Wolf Signed-off-by: Mario Limonciello --- v5: * Add tag --- drivers/acpi/platform_profile.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profil= e.c index c24744da20916..ce3aa1361721e 100644 --- a/drivers/acpi/platform_profile.c +++ b/drivers/acpi/platform_profile.c @@ -179,6 +179,13 @@ int platform_profile_register(struct platform_profile_= handler *pprof) { int err; =20 + /* Sanity check the profile handler */ + if (!pprof || bitmap_empty(pprof->choices, PLATFORM_PROFILE_LAST) || + !pprof->profile_set || !pprof->profile_get) { + pr_err("platform_profile: handler is invalid\n"); + return -EINVAL; + } + mutex_lock(&profile_lock); /* We can only have one active profile */ if (cur_profile) { @@ -186,13 +193,6 @@ int platform_profile_register(struct platform_profile_= handler *pprof) return -EEXIST; } =20 - /* 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 =3D sysfs_create_group(acpi_kobj, &platform_profile_group); if (err) { mutex_unlock(&profile_lock); --=20 2.43.0 From nobody Sun Nov 24 03:28:03 2024 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2048.outbound.protection.outlook.com [40.107.220.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 552D719750B; Thu, 7 Nov 2024 06:03:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.220.48 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730959420; cv=fail; b=fsA8nF7sDUsZocwW55S7UyxTASwtBACvNUp1mL4lamLBuemRgSbn0qv1UIvvVLhd6SO7jMuwRBuHpYWNhmew1u2Lnr86SPB+rev01HdlmNX77NSjdvQtrVTRdZ6HbnZFbZStOhhfY0CSAx6LFk50IpmrbSCNbRuJQZm2enePxAM= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730959420; c=relaxed/simple; bh=DDkbAG6s/28zVI9+vavafl2eH/ICGR+F1er0g86Vvb4=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=d0kE31KlTpWMXrH5VMgq1U6V8WEaeAmNuMpYn/BQtofcS1yzyJ4ipFL+mucHgXdVNJGQWpf57cd1jrhJ/Do7T4/12Zd4tPn79smncUjtn1l0e/3+kA7ClNtewh2b/eilyxgR3+IGkahOdkM65yD4uyUmgNZVw/9Y6i5QI9pxpcs= 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=BINiz304; arc=fail smtp.client-ip=40.107.220.48 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="BINiz304" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=csQlib47aALnd/QbBRSA5QZ7tni8LaSWVaFY7fkuUO1QQfibBvVvRtijvkQxa1Pe3jZOrWXn8FGhCbM0CxFMlfbciXQ+3YoMfDJnyV7tyu9ntAJgeCgjQkjuguB1oA4DCLa+IZVPVav+c/KgNEEjEBCUULUHxXaPAmO8mFM1GHYXx9h5XFF3f6Aq5jALbyZaiU9cZEsf3D9zI/FYu/Ce6evCW9RIjE+zGDGaioBVbVqrnXj/4kFjTmrfu6g+jeUuZFS7jnY3ftEyuWd4iMnWD1dDh6nyuz1fp5UjRpzn1Qxebd22niZyGQx0dJgwrGKOovN/jgxSMn673fAuM13ppQ== 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=DJwrJ761+yqKmHSkFl44f4+2ZO6F8u0PriKiwW84Lds=; b=kHZIKTXawryPczyJr9nvOHYFTmWVHeVu9SzvVVxRBk7NCxv4JsipnHayxDLOen2y0D+g3+kin+ZXjJlv49cXtDlLl8ZKhPIKX7CC2DfprHZhWdhC8jrBZpSTc4sKOyDtT7wK0trgAhwlGJqMcdr9bwCwcwZNWxO2PLR0qBQFCbdkni2j8cx2RWm49I0O9BnG/Mbp1c/V42SC6tOSpal+xkqBo40e0aFNWE8lSOx5oMY4wQZRCXfuao98E234Anok8sV+zos2PVsYTHiq5Atj7jvHR9EvsDuKSZXG0e5kuhZ2p8uslTfCQbsKoOnsgjTG9IBKxMtChJkqyEtNjEW84w== 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=DJwrJ761+yqKmHSkFl44f4+2ZO6F8u0PriKiwW84Lds=; b=BINiz304ZcTjPON1TUJIaZX99S7CTVTCdQuTDZLivDMtCLBY33btb6I9FMw/qVAGmdNciBDFTSvPLv1XaUjbuCKRVrKRpxC8o83oKpcUqHAFGFFICFlqZlOo6Hnxr9wvyZ/4/6H5S3HG3Ur7ODW+UaRcR3T+nOBZjmTK2hLHiO0= Received: from CH5P222CA0021.NAMP222.PROD.OUTLOOK.COM (2603:10b6:610:1ee::10) by SA1PR12MB8094.namprd12.prod.outlook.com (2603:10b6:806:336::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8137.19; Thu, 7 Nov 2024 06:03:36 +0000 Received: from CH2PEPF0000014A.namprd02.prod.outlook.com (2603:10b6:610:1ee:cafe::24) by CH5P222CA0021.outlook.office365.com (2603:10b6:610:1ee::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8137.20 via Frontend Transport; Thu, 7 Nov 2024 06:03: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 CH2PEPF0000014A.mail.protection.outlook.com (10.167.244.107) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8137.17 via Frontend Transport; Thu, 7 Nov 2024 06:03: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; Thu, 7 Nov 2024 00:03:32 -0600 From: Mario Limonciello To: Hans de Goede , =?UTF-8?q?Ilpo=20J=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=20Kleine-K=C3=B6nig?= , Ai Chao , Gergo Koteles , open list , "open list:ACPI" , "open list:MICROSOFT SURFACE PLATFORM PROFILE DRIVER" , "open list:THINKPAD ACPI EXTRAS DRIVER" , Mark Pearson , Matthew Schwartz , Mario Limonciello , Armin Wolf Subject: [PATCH v5 05/20] ACPI: platform_profile: Move matching string for new profile out of mutex Date: Thu, 7 Nov 2024 00:02:39 -0600 Message-ID: <20241107060254.17615-6-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241107060254.17615-1-mario.limonciello@amd.com> References: <20241107060254.17615-1-mario.limonciello@amd.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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: CH2PEPF0000014A:EE_|SA1PR12MB8094:EE_ X-MS-Office365-Filtering-Correlation-Id: bd5a763e-c87e-4efc-76cb-08dcfef1eb3d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700013|376014|7416014|1800799024|82310400026; X-Microsoft-Antispam-Message-Info: =?utf-8?B?aEIxd05IaDJCdFliM29CZHVvZnBoUXVtS2FpMUtvNUNDTTJkblQxTlQ5ZU14?= =?utf-8?B?TDBrU3I5QkRzcGpSVFJGd3RWRGE1T0NQR25QT2Y0SzhFTDQrY2Q1K0pFTzUz?= =?utf-8?B?MFpXc0JtQ01MaGZIWlp0bnlPV1dQajJnZXhadVFERnY4K1kxUFdLcGZzT0dZ?= =?utf-8?B?SjdQRGdHQk1PSU90SmdoS1hFQUtRUGFOWmIrTHE3R0JabVlVMFdhOUM2Wkxt?= =?utf-8?B?bHdkOENaTGFzQW5OdTlQSjR0TlFpQ2lnQm9oYnY0V3lRbHlOWlNIMytBeEpn?= =?utf-8?B?QWNXVkZCRjc0d2lFa0pmbW82VlYxVDFKUm1qb1hJN0drWWlGRnhzVGJoWSsx?= =?utf-8?B?Nkg2b2s5QTV0bHZicEZUSUJmWmkrNFV3cVNBL1FlYzJmUUhUTWovanpVeS9L?= =?utf-8?B?QVkrMzdpSXdWdnU0UWd5TjQwZjA0ekgrRkRYN0p6amJQOUI1K1YydkxrVm9F?= =?utf-8?B?ZWVkRTRhcjBoOXhWOU1WL2l2T0FVTEdEcGIvN1ZzeFJXd1FPK0VJaXNIemJn?= =?utf-8?B?dThBT1k2UmhPSnRJUDJaMTdYWTFvL294SUk4dEtBMzZ1dkFSRnBFTGwxVUFq?= =?utf-8?B?WHBUbDJicHZYSkZmcGpaVThoSEJoSGlGYlBBNHVYZ05XNVF0clNGT05vbmx1?= =?utf-8?B?OUxSN0ZzVFUvV1NyUGNlNE9lTElOZWE4eHdBbHAzQTB5L0txaGsxNGluZmx4?= =?utf-8?B?Nm5Ga05PaG83cmdGcnl3L3BHb0FjNmYzSEoreGJzTFBITmsrdXNNVmhkOXht?= =?utf-8?B?ODZjTDcyWW5kZ3ovTzFZNFFKRldWU25CV0hIZXpaMVNLc1R3NjBaMkVORC9V?= =?utf-8?B?UGV5ZHRmUm9leStmTEd3bndjSmVXS0djWUJ6V2F0T0YwOVJycDdaZEpSYjVJ?= =?utf-8?B?eGgrMVRuSlVOcHdvdWpibkJQV0NXYU4reVB1cXpGUnpHR2FaY0JUT1M2VHVW?= =?utf-8?B?QTR3WWt4TTNMemlKQlp2NmE3NmprUlRDbzltT1d6NFNRZlFWSi9RanA1THh2?= =?utf-8?B?VXA5aVVET0NTcGdHZVBxYzJISzlidlVDeEZpSXp6MERSUkwrRGovb3BmbE5C?= =?utf-8?B?NTJoZDNFdzUyY3oxWnYvSXFxUDl1OHNzb1g1WG1GWExITVBPMTVqSDRXSmQ3?= =?utf-8?B?ajNwdCs1UmtpSW1zR2ttdzlhTTg4eTIzQWFOanhacnY4c0dSSmFya1h0MkFW?= =?utf-8?B?T2FoUU9EWWdwR3lyMXpUY2xkUnExQms2Z2NXM0dGQTBIaVF5S3R6RzlxSUdK?= =?utf-8?B?eS9jc2lhZmRkM0RVNURGZ2pwOWhCVmtUTHd5S2tiRktZWEVJenFUSFpHaG42?= =?utf-8?B?SXJoTGwybkpoVXFQaDVIcm5lQTZKWi9hL1l0dkt2aGYwSUF0SC9XcDhpYzVl?= =?utf-8?B?OUxQbHo0d2pmOFhWNkpwNzRkSVl0VlRydlRTS3pRNjQ4eW5VWmdjYlZwS3By?= =?utf-8?B?S25nMngxbUsyaE5vOHZXbGJUS1c5TVcvaGhuTTZtUzlQMWVVMFRDY09VeG92?= =?utf-8?B?NUVwN09aOVVtZituTzlmNkFjL3hvUjVDK3Zub3dESkljRXpTRVd6WWlMMmNq?= =?utf-8?B?Zy9Xem1YYzZxUnJWNXpjWngxZlZMWEowMmJDQ2pvM3czQ0V0R2kwSzlXd0Jw?= =?utf-8?B?N1FzYzYzMUtOY1MxM0xmcnBQb1NieVpkSTBqYTd5U1RQY295dDY2QVhUZ05w?= =?utf-8?B?eU51aEVQRmUvSXRibzBrdGZQN2Z3bEZCd2dNV3dMK0pzMzVXRWJMNndwVTdX?= =?utf-8?B?SVptL0hCL2NUWjZDSVNPR0NOazdiMmc0T2NxUjhmZDJuTXRsU01BSkV1WTRW?= =?utf-8?B?c1BvcVFNZEh3VTJ0N2lQeXJVK21LYmZNQUpIaUxJRHV6SzRlclRyamh1RWR0?= =?utf-8?B?MHp1VEo5SkZZOVM4MkNCNGE4RDFXazlMUWdJYmJQMzRPTnc9PQ==?= 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)(1800799024)(82310400026);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Nov 2024 06:03:36.4983 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: bd5a763e-c87e-4efc-76cb-08dcfef1eb3d 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: CH2PEPF0000014A.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR12MB8094 Holding the mutex is not necessary while scanning the string passed into platform_profile_store(). Tested-by: Mark Pearson Reviewed-by: Ilpo J=C3=A4rvinen Reviewed-by: Armin Wolf Signed-off-by: Mario Limonciello --- drivers/acpi/platform_profile.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profil= e.c index ce3aa1361721e..fbdf3cdf1141d 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; =20 + /* Scan for a matching profile */ + i =3D sysfs_match_string(profile_names, buf); + if (i < 0) + return -EINVAL; + err =3D mutex_lock_interruptible(&profile_lock); if (err) return err; @@ -92,13 +97,6 @@ static ssize_t platform_profile_store(struct device *dev, return -ENODEV; } =20 - /* Scan for a matching profile */ - i =3D 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); --=20 2.43.0 From nobody Sun Nov 24 03:28:03 2024 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2052.outbound.protection.outlook.com [40.107.94.52]) (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 E3D28197A7E; Thu, 7 Nov 2024 06:03:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.94.52 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730959421; cv=fail; b=oilVhqzBSdS9Tdhsgksd9GxIeiUS9kmJoX0mm6JktV98lha0/0D/SYtx7sXYFx/9Aa99qLu5BssNO13TJBfdiIuUVJTrlmacPvNqCkrq9scs0hhqQ4ooU1M+iCWknnZ0zDz9dS9y/PZFHFc100Izyd6kYNj+erbKz3ORxesKvbE= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730959421; c=relaxed/simple; bh=M8a3jlvXTMdc/FFBVebMJsQ8wdXj4ZIXAyA82jD0/18=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=RSl9IxJYTBT8iURUy9L1+YLsfnV6k10KAtvnFWNPzgoyCRIvCkqpSPGFQ26NKh1HT+8QVhhpt8XT7QtNpiFeb9klCqSb7fd7bgkNC0z8ZjZSarZuIW0Y1Thye71ZGF9+KU2V4dF45960fC9kKrfTdQb0QiNgnQqLUw5RIwFx/Fk= 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=238mT48P; arc=fail smtp.client-ip=40.107.94.52 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="238mT48P" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=HeRZw1Wkad5JcdLYb/sm1BCmjkf5mk4KvQbNkm621xCcY8bgTlAoddXoD8umq5NpIQPxUNw8I04Q/EPPCVMZp3LuxxKgXvDDxDLh+457sWOIHQ0vxoP1xgAXt/fO44Gy9gqVmaMSy7tZqBiI/HnC4/3JDdIRTFPA51NS0KlEHQfYZ+CGge0iNgwEUcM0d4oohmgw2UdmfV9nB4Cp+yxtdrulJfqfwuaFLx+OBN3jaQBp2fVRURe1sXajDKN8I1AE9sYGROWd5STl6f8yQ1NkgMQ9tOzcfSf/XVtUGSbvccRZnkAcL5riEm9+yicdNfvRs413gNHW7dvQqHfvOxKGGQ== 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=wnfyT3tMCL5FCDOuR+WuRHGXHAYbYss7SLrNrf80Y7w=; b=oRG10fke0HdSeqABf1E7OnkTJIVm/6XWHE1wke04MKIaFVqfXtA5oWXssWls+fFtALUXED+AXtN6QCEeTHUnAUEBfPlGfVtoEb07DE1hO/61kAZrxQ/vmSq1+pBxMkPCSXTXGXEcKH6oG6xkx2XfJYHmwg2Tald8a81vfOC831t1QZ6Fp3hGoMdqbE6xZmOJrPvJ241Zywd5ukryM75Mlu1XiN7PrZ+m5AR0dWjCaBao3r9TcZNNvWUGwpeRVXVyfRdXXw1Vf5EPeOM0YoEWcK8RQzF4+8+Na7bEbBiVYgGlMq3T2Q+fO7eg/4INmZvsONaDLC9KS+ggu23lzlePpQ== 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=wnfyT3tMCL5FCDOuR+WuRHGXHAYbYss7SLrNrf80Y7w=; b=238mT48PuHuV111jTjNXMa0+Ba9qdw8j5a9JRiSQhxNXvHgyogPSM5CL4VQCNCzDPfuw82EtJ50dtGc2orHHGMZniFgEG1NemOhgMJ3o9N0FbSMIRChCmPwkZRSXtvvd+rMJZ1ZDb2hwYgz/ZtQsowm8gaQ1BBoTR5+BT6uPhyY= Received: from CH5P222CA0013.NAMP222.PROD.OUTLOOK.COM (2603:10b6:610:1ee::14) by CH2PR12MB9519.namprd12.prod.outlook.com (2603:10b6:610:27c::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8137.19; Thu, 7 Nov 2024 06:03:37 +0000 Received: from CH2PEPF0000014A.namprd02.prod.outlook.com (2603:10b6:610:1ee:cafe::4e) by CH5P222CA0013.outlook.office365.com (2603:10b6:610:1ee::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8137.20 via Frontend Transport; Thu, 7 Nov 2024 06:03: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 CH2PEPF0000014A.mail.protection.outlook.com (10.167.244.107) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8137.17 via Frontend Transport; Thu, 7 Nov 2024 06:03: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; Thu, 7 Nov 2024 00:03:34 -0600 From: Mario Limonciello To: Hans de Goede , =?UTF-8?q?Ilpo=20J=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=20Kleine-K=C3=B6nig?= , Ai Chao , Gergo Koteles , open list , "open list:ACPI" , "open list:MICROSOFT SURFACE PLATFORM PROFILE DRIVER" , "open list:THINKPAD ACPI EXTRAS DRIVER" , Mark Pearson , Matthew Schwartz , Mario Limonciello , Armin Wolf Subject: [PATCH v5 06/20] ACPI: platform_profile: Use guard(mutex) for register/unregister Date: Thu, 7 Nov 2024 00:02:40 -0600 Message-ID: <20241107060254.17615-7-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241107060254.17615-1-mario.limonciello@amd.com> References: <20241107060254.17615-1-mario.limonciello@amd.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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: CH2PEPF0000014A:EE_|CH2PR12MB9519:EE_ X-MS-Office365-Filtering-Correlation-Id: d38d4228-dc94-45ed-99e1-08dcfef1eba1 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|36860700013|376014|7416014|82310400026; X-Microsoft-Antispam-Message-Info: =?utf-8?B?alpIcGNyemxtZWJYOFpBeVdQSjBuWnRqQ1VjTnRUeEhlSjY0Mk9sVVc1dmJC?= =?utf-8?B?dmVKRSs0ck5sS1BlR0pVbnlYTnRaZVFVYVlJMlRsakR3d3RPMnpMVUhlYlVG?= =?utf-8?B?dzlJUkxoUUhyNDZhN2ZaZHN6aVBBaE9yZUtTbUJpZldUTVFiMllGVEd5dUpF?= =?utf-8?B?MitxTm5BdnM3Wmp2RWZNL2YyZmlaQmdTN25VNnNVOEZXZnEwSFhSM0xNc0hT?= =?utf-8?B?NHRBVTZORlV0bWhJTkhWZzlpRkdEdXVOM3A3SzlyNSt0T0hDMkNHOHozLzFs?= =?utf-8?B?elN4elpVc3ZvRHZKMEtITGVxNE0wUWxCZmFabmJGc2grSE9MYnZ6Y3MvUDZ2?= =?utf-8?B?TlVSbkdadHdzdW5hYmZ2aG14bFdiakl5QnpxWndKRXZyWFVYSzRSUGtubTFl?= =?utf-8?B?TFQ3eXRldVVORGk0UitvVTRBbkRSN0Y5YXBVVXF3RCtaTlFXSXdDOFZFTHZq?= =?utf-8?B?ejJmQitaU0c4S2xtbGRGeXRJNjZZdWxLdUZpeHhLTzh2VXUyRG9RcUZMUkcy?= =?utf-8?B?b2t0SVNTMmtNbWF0elVuY0l2ZGhzZno3V08ybWZsWk5IY1VmOHc0ZFhUUGFV?= =?utf-8?B?N0R6Rmx5TkdObmN6aU1mVnNlRzUxRlMxeHJjcW81emFsYkJOZ2RWWDRzeEVy?= =?utf-8?B?MzliSW9DYXErSkJqVE4vV0xFV1lXYkdiY0JHMVJvYVlMc084eDgvV0oxdVN4?= =?utf-8?B?Zkg4Qk5ySUgxRFU3SllEWmxSQWlZL04vVnZibUNueHJKeFIzS1FZZnpBRStz?= =?utf-8?B?NFJCdFRrNFAzT0FyY0tYekN6OTUxdkdadCtNN09BUkkwY2t5YUIxYksxMUVX?= =?utf-8?B?MWNIR09VdTk5bUZmampmcjFSbFMyejVXSGdadC82VnJEVkE0bGl3OWtkVnNt?= =?utf-8?B?OW5TdHB3aHNUUXZoVlhPSFlHNE9LbFpmNDFxbnF5clR2SHhGYjY4dld4Mm5M?= =?utf-8?B?eDY3eE1zeFVSa0xieWhHa1pZb3BmazlFWnRsY1krNFpSd0ZNVjErMnYwWTlt?= =?utf-8?B?ZzZFMjdQRXY3VHRBTHZmaFd1NE1obEFvL2RhdThpbkNhdnV5eTNaR2RQVW9B?= =?utf-8?B?ZmVaSFh5MDJwczVRT0dGeTlXRjczcmRwTU11dHVmU0lVbDhUTVRJaGpORlFp?= =?utf-8?B?RFFxV2tydU5tSDFJUGgvWll0eXJTdkNFbWNHc250Zm5OWWRzMFNvV1JUUzZh?= =?utf-8?B?Z3NwRWViZTdMLzI3WDNQQUZWdm5EbHBpUmYzUW83YVpicXExSlpVQVMvMVFk?= =?utf-8?B?bWlDWFdmZnpGWGF1QXEvNTdBNlBqQ1BudE1mOFg0K0pXUFNGM1NQNWNMY3lH?= =?utf-8?B?YVVRenhEOVVWZjJIYklSZFY4UHhhRkVhZ2xmSnN1OGk3b2tsVXMzSEFybTY2?= =?utf-8?B?VW9BWWJONnlMdlQrMVl0aGZxWHRrUFU2a1ZZTUhKK29Sd1phWFM1WTdxYlpM?= =?utf-8?B?dmoxOGJ0MXJ6TWFibTg1cWhadCtLYUFqbnVLd1pzZUt3OU5zSWE0UEMxZ3pk?= =?utf-8?B?VFBRVXhHM2tnSC82cWZSL3dFLzdyMHNscGRTb3B6TjVjeWZCK1lNRVJRVHJn?= =?utf-8?B?Qk5lWFJFZGxRcTc5SXJmVytadGFpZzRGbDlxRjZidEhYK2dwSCtTUDRZMHlW?= =?utf-8?B?YUl0WTM2Z1RBSkZBL3dwMFZNeHVIWi9vNkVCLzcxSE5tOWZlTmo1S3Z2YS9w?= =?utf-8?B?bHV2TUhzZEQvVTRxMlViRG5WdFlsdW8wcWgzbUdjeGUwU0xTQnRqYWNSRU90?= =?utf-8?B?YUk5SFM3OVVuSVg1bVhxUm42RDV5ZW1qaGpPbHg4SlFjMHV4dGN2YkhyaVQ5?= =?utf-8?B?UkUzSUZNVzgxRXVvb1NKc05jNjA1WFZuZlFPZGcxMHZaMFhXWW1wOUkydnFE?= =?utf-8?B?ZERuK1QvOVc4cmo1OG4rT2FMMUZ5dEtET1dOUlA5TFpUL3c9PQ==?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(1800799024)(36860700013)(376014)(7416014)(82310400026);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Nov 2024 06:03:37.2015 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: d38d4228-dc94-45ed-99e1-08dcfef1eba1 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: CH2PEPF0000014A.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH2PR12MB9519 guard(mutex) can be used to automatically release mutexes when going out of scope. Tested-by: Mark Pearson Tested-by: Matthew Schwartz Reviewed-by: Hans de Goede Reviewed-by: Mark Pearson Reviewed-by: Ilpo J=C3=A4rvinen Reviewed-by: Armin Wolf Signed-off-by: Mario Limonciello --- drivers/acpi/platform_profile.c | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profil= e.c index fbdf3cdf1141d..548eb99253958 100644 --- a/drivers/acpi/platform_profile.c +++ b/drivers/acpi/platform_profile.c @@ -184,32 +184,26 @@ int platform_profile_register(struct platform_profile= _handler *pprof) return -EINVAL; } =20 - 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; - } =20 err =3D sysfs_create_group(acpi_kobj, &platform_profile_group); - if (err) { - mutex_unlock(&profile_lock); + if (err) return err; - } =20 cur_profile =3D pprof; - mutex_unlock(&profile_lock); return 0; } EXPORT_SYMBOL_GPL(platform_profile_register); =20 int platform_profile_remove(struct platform_profile_handler *pprof) { - sysfs_remove_group(acpi_kobj, &platform_profile_group); + guard(mutex)(&profile_lock); =20 - mutex_lock(&profile_lock); + sysfs_remove_group(acpi_kobj, &platform_profile_group); cur_profile =3D NULL; - mutex_unlock(&profile_lock); return 0; } EXPORT_SYMBOL_GPL(platform_profile_remove); --=20 2.43.0 From nobody Sun Nov 24 03:28:03 2024 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2049.outbound.protection.outlook.com [40.107.223.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 89182199951; Thu, 7 Nov 2024 06:03:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.223.49 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730959424; cv=fail; b=s+BDBWPSxqu1QJpZZHyMx8HcB9hPi0ow6Fb0qs+nVIzqh7+EUNkcJxczZm7ciz6hkfR2j+sC1w2mzBOQOGQq8QffSN244xUDQbUVwftu28mgkRM1+0xim3nkM6gsrtY2IxbZkwT+Ne0S0BzVYgl5TLAuc+z45c4V1Ifug04zHXQ= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730959424; c=relaxed/simple; bh=Eh7GbAEhOApPgwe7sJ19hDwugoPdNvuFgJKEBageevo=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=JJluHLAa3ISo5iznx6e/QLWBZxuqqohfDWzMnpzL9RiKKNfGQVuOxgZG2eMvDM4zaD8ZT0uq4xedOc4PbTRbAve9t/e4bSYc3IopZxAjG+bTg11zDkWdEMxY0bhfakZQOcJqt1WHUagDEwtn3Lg4Fik6MGdX6RJJbA3zHRKgMq4= 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=pPsp9J2C; arc=fail smtp.client-ip=40.107.223.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="pPsp9J2C" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=jp6yA3uyIHUbiNA2u3UPhPt45ry2qCNqqvumWw7q5BTi3Srs79BbK27UwodCrPAQCDz+4stZrJX6+7yBWWFqUlRGXQxZJnvkk5TZ82EoAlRLNNJshuZItGUt5vRBIEZzgJthQXlDVhPNVS2Jul2NB7ZmFnmG5ClFUSb6u7pJNhAqmcl2vn2eUz5NthfAtctUrSmOhFmMZMiIoigJqP+rU2H8PgG2MBqxCDgEmmYUMJG7w96BcluFUbrNvJJEj1XVZ6mdVOvzob6yTJqdDbluLUJFSwpv3XqVAX9fMDtq05AAp3dd5XsTWglrlupVMXSDEHs7Z2ZPKE2vM3Rue9ohdQ== 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=o78hvHLjyjWYhzj1ketM61l/Z9Bnrn7JPtZ4EHIBTBE=; b=yVlfBSqG1vY07IuDrRzMzF7/F2dNxbtGXDw1ZsBaMD/DvVzCYDhSEZs6Usch01igGTKBMAmJe4YERRcq/8T1sM6KoQZozGyLnPRtQrA107wSitqanzTrWeFGiJ1AcarvqWjpFn2fRVqmfTYsz/a6hXQr8vR6hDJx5o1PeD0n15C7qx2/3gfDAeF64u4eZ/yd0CqahK7E6DekLPV65JAWA+rCUpD+8TpQVwXDsGaW2JPyB2UHj59VbOgr042y3vLzCmQuHGetn6iz3KIa261lBQHBliv1TKmLfdFPKI55dKBrPpR2BdMdYwyIo8f6dzKVYZAAZ1S0PLnbct7wACQUSA== 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=o78hvHLjyjWYhzj1ketM61l/Z9Bnrn7JPtZ4EHIBTBE=; b=pPsp9J2CEdSAOVr5c/iRyGfdAu91HjHewI2mrOpwcLAX/F88ghju8eOcrAF4KRFibVdmnq7zd9xb9qFh3M+xoHNe5Jn4ZtRDZw4WrCTWApe9fGx0dgonAkWos/SMHq298EG4JZB68KN9EmZfrKRFweAZzsUqTpUHxAHp41jSqUg= Received: from CH0PR03CA0271.namprd03.prod.outlook.com (2603:10b6:610:e6::6) by DS0PR12MB7653.namprd12.prod.outlook.com (2603:10b6:8:13e::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.33; Thu, 7 Nov 2024 06:03:38 +0000 Received: from CH2PEPF00000147.namprd02.prod.outlook.com (2603:10b6:610:e6:cafe::1c) by CH0PR03CA0271.outlook.office365.com (2603:10b6:610:e6::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8137.19 via Frontend Transport; Thu, 7 Nov 2024 06:03: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 CH2PEPF00000147.mail.protection.outlook.com (10.167.244.104) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8137.17 via Frontend Transport; Thu, 7 Nov 2024 06:03:38 +0000 Received: from AUS-P9-MLIMONCI.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Thu, 7 Nov 2024 00:03:36 -0600 From: Mario Limonciello To: Hans de Goede , =?UTF-8?q?Ilpo=20J=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=20Kleine-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 v5 07/20] ACPI: platform_profile: Use `scoped_cond_guard` Date: Thu, 7 Nov 2024 00:02:41 -0600 Message-ID: <20241107060254.17615-8-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241107060254.17615-1-mario.limonciello@amd.com> References: <20241107060254.17615-1-mario.limonciello@amd.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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: CH2PEPF00000147:EE_|DS0PR12MB7653:EE_ X-MS-Office365-Filtering-Correlation-Id: a8809ab8-8428-4f4b-7896-08dcfef1ec3d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|36860700013|82310400026|7416014|376014; X-Microsoft-Antispam-Message-Info: =?utf-8?B?UEtXQ0IraEFGZWpHK3ZYT2s0bmRqREY4M1d5UE5pS1FNcW5BamdMSjd5VXE4?= =?utf-8?B?OXJnVkkvMHNxblB0UThrOXUxYW0rUlNSMkNPMitZZkRZaldPbmZWek5jUGZK?= =?utf-8?B?bjNFOVpuNWdiK3IwMVBsR2x3WGlvV0QzTzJac3lkYURFN2V2elpIVE1HMmps?= =?utf-8?B?Y0YrcERoOXQzZHJDN0srVDlhRjI1Yy9DOU5xekFJenBhd1IvZ3FsVzdJaXMw?= =?utf-8?B?TVNVMWFYa0VRa0dGYTZxK0JhdTRQV2dhaUdvUkNHaGZRSjZHdTFwK1YySWlP?= =?utf-8?B?bzk2dGM3LzNOYkRtcVloUGtEVFNFVVNCdUs4aC94dlNCbFV6VnloZnJBRGZX?= =?utf-8?B?anlJTVpkTlVVVkFkQm4wQ3c1RVZlNWpzZUJsR1F2NDArN3hzQTM4RE5pcHAx?= =?utf-8?B?WDE4cGZEcTd5RkpocmVQdXhEbkJsSC9PUUZYRWdFYWVJdmpXcDYxcDc2UnhB?= =?utf-8?B?TjljQTZrRG5ZZExqWmNxdEswWTFaNFZReGtoSWdpZFlQVWtCcmtVTzVpZWxS?= =?utf-8?B?QTkrZG5NQVUvYVBQeHMyRHBYaE02ejVmTlArNHk0UTZVQ1oyM2VNMlMxR0Zo?= =?utf-8?B?Ny9ibG1TbERZOHpXVXpORTRmWmhHdEx1SExBcGt2b0hSK2dMY3MwQXozRUVL?= =?utf-8?B?NXNtYmI5b21BelY5QVVET09UaXd5N2ZFV0FkbDlOdVE4NmRjVUJRclF3aGpB?= =?utf-8?B?WDI3UmNPeFdFYjY0ME92WHd5ODJ0c3c3QjVJVkRGQzBGcGlzTnR0NXkrOVJl?= =?utf-8?B?ME9QdUdRNkFVUVF0QjhWZVZZSDlKSmIra2tiNFhqRHViVjV3QmRDSnowL01D?= =?utf-8?B?enV4S2JUdklYbVc4MFZWbFN0aXprWko5Ky9RYUdJLzFPRDBUMHBDSG1CN1FF?= =?utf-8?B?aVJzSXJ5QzJQek4yZ2VkUFNtS0VNSWk5LzFmTTFKS1ZyU2t3MVZYL2RlMGo5?= =?utf-8?B?d0g1US9LTS9XK25yTGpDOHhRdlF1bEZZZUZ3UTRTeVhqYzlrZTB6K3QzOEhQ?= =?utf-8?B?Y0JxUDNmT3lRU3JDYit0ZUFoNHBLVU4xdWhZcFFYeGtlU0VzYkdjVUJMdC8w?= =?utf-8?B?TnNnS0Vub3BLeks3OFRwM1U0NC9CL2pqRFZsVEZldUt2aDlLZy8zOG5YbnFz?= =?utf-8?B?OEc4elV1cnhhWG56Z0xqcmFkc2g1NkQvakJ0SHJQQmc4WVV0cEdXNDl6OCtF?= =?utf-8?B?bUJKeVRkUm9KSzFHNlJNM2RWMUhhbkZ5VVV0QzhBcEFDakFvK1M3RSswSFRO?= =?utf-8?B?YXhmTW5vL0IvZGdUMkVnUm1VZDhRNHNudm1rbFpvd2xuWDF4UEw1TGFHZzlw?= =?utf-8?B?OFpqVTVDSWJLd25xb3BwMDRnZ25HL3FDWWJnQUR1Njc5bTg3bWNqMkJEUHVS?= =?utf-8?B?Z0xtc1prMW5RODFsbStrZUpoYTVQSUgzaUJkRWhYdUdSTmhCVG9OQVBVdVhL?= =?utf-8?B?dzR2SnpNalRKcHJpQ2s0bHVmeG5STllnUWdCZVkyODZMaTlQVXhQZjgrOHVy?= =?utf-8?B?WTVETm1HMEVVRTFvTEdtYzEvUVZsKzhVZ1pqSDNuOURiOXdrS3d4Y21nQTYw?= =?utf-8?B?L0xKbmZ0QkRIS2ZvVEg0MXNrL3lRNno0cDd2MStNWEZXbS9MOFJVTkxKVG9B?= =?utf-8?B?Yy9DQVdhbm1LdWFETS91ZzJRYnRubTNkdlZ3RnQzeE55c3NZclRkTDVGdU5n?= =?utf-8?B?TVJJeWhyaDVoTmJhbUpGYkJTSUE4U0YwUktkN2d6TFZkbkZKMjJGb1pCTHFt?= =?utf-8?B?ckRVVW5PTmgrZ2RvOFltVUdMWndTRzlNY3NYNWJ1NmZhU3Z3bm9BR2xkbGdz?= =?utf-8?B?VjJpamtFNlVhRzV4WDI2cHNwSEVicVMvUmp2bmJucmRIOGNqZXF1dlM5Z3lF?= =?utf-8?B?NUd6aFI0V1pHczhnVDh0VHNGV2dlbUhIMmdFZ00yWjhTRkE9PQ==?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(1800799024)(36860700013)(82310400026)(7416014)(376014);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Nov 2024 06:03:38.1761 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a8809ab8-8428-4f4b-7896-08dcfef1ec3d 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: CH2PEPF00000147.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR12MB7653 Migrate away from using an interruptible mutex to scoped_cond_guard in all functions. While changing, move the sysfs notification used in platform_profile_store() outside of mutex scope. Tested-by: Mark Pearson Reviewed-by: Mark Pearson Reviewed-by: Ilpo J=C3=A4rvinen Signed-off-by: Mario Limonciello --- 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_profil= e.c index 548eb99253958..0450bdae7c88b 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 dev= ice *dev, char *buf) { int len =3D 0; - int err, i; - - err =3D 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 =3D=3D 0) - len +=3D sysfs_emit_at(buf, len, "%s", profile_names[i]); - else - len +=3D 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 =3D=3D 0) + len +=3D sysfs_emit_at(buf, len, "%s", profile_names[i]); + else + len +=3D sysfs_emit_at(buf, len, " %s", profile_names[i]); + } } len +=3D sysfs_emit_at(buf, len, "\n"); - mutex_unlock(&profile_lock); + return len; } =20 @@ -56,20 +52,15 @@ static ssize_t platform_profile_show(struct device *dev, enum platform_profile_option profile =3D PLATFORM_PROFILE_BALANCED; int err; =20 - err =3D mutex_lock_interruptible(&profile_lock); - if (err) - return err; + scoped_cond_guard(mutex_intr, return -ERESTARTSYS, &profile_lock) { + if (!cur_profile) + return -ENODEV; =20 - if (!cur_profile) { - mutex_unlock(&profile_lock); - return -ENODEV; + err =3D cur_profile->profile_get(cur_profile, &profile); + if (err) + return err; } =20 - err =3D 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 >=3D ARRAY_SIZE(profile_names)))) return -EIO; @@ -88,28 +79,20 @@ static ssize_t platform_profile_store(struct device *de= v, if (i < 0) return -EINVAL; =20 - err =3D mutex_lock_interruptible(&profile_lock); - if (err) - return err; + scoped_cond_guard(mutex_intr, return -ERESTARTSYS, &profile_lock) { + if (!cur_profile) + return -ENODEV; =20 - 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; =20 - /* Check that platform supports this profile choice */ - if (!test_bit(i, cur_profile->choices)) { - mutex_unlock(&profile_lock); - return -EOPNOTSUPP; + err =3D cur_profile->profile_set(cur_profile, i); + if (err) + return err; } =20 - err =3D 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; } =20 @@ -140,36 +123,27 @@ int platform_profile_cycle(void) enum platform_profile_option next; int err; =20 - err =3D mutex_lock_interruptible(&profile_lock); - if (err) - return err; + scoped_cond_guard(mutex_intr, return -ERESTARTSYS, &profile_lock) { + if (!cur_profile) + return -ENODEV; =20 - if (!cur_profile) { - mutex_unlock(&profile_lock); - return -ENODEV; - } + err =3D cur_profile->profile_get(cur_profile, &profile); + if (err) + return err; =20 - err =3D cur_profile->profile_get(cur_profile, &profile); - if (err) { - mutex_unlock(&profile_lock); - return err; - } + next =3D find_next_bit_wrap(cur_profile->choices, PLATFORM_PROFILE_LAST, + profile + 1); =20 - next =3D find_next_bit_wrap(cur_profile->choices, PLATFORM_PROFILE_LAST, - profile + 1); + if (WARN_ON(next =3D=3D PLATFORM_PROFILE_LAST)) + return -EINVAL; =20 - if (WARN_ON(next =3D=3D PLATFORM_PROFILE_LAST)) { - mutex_unlock(&profile_lock); - return -EINVAL; + err =3D cur_profile->profile_set(cur_profile, next); + if (err) + return err; } =20 - err =3D 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); =20 --=20 2.43.0 From nobody Sun Nov 24 03:28:03 2024 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2060.outbound.protection.outlook.com [40.107.237.60]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D5B38193425; Thu, 7 Nov 2024 06:03:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.237.60 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730959424; cv=fail; b=TkGvmDavkMjgeM55GHIHVl9BKeNP90MgBbFAyzcIt35PgpuvnSViKj33ECFVt/eTGS4twOan1hsn06ctmbnHMGwvPiJ+6NCK9lXXoOAMtPLcLykAE6bbLBs7HNehD7aa9SQSTcoR5P/bzFqerg1Ye/ipfxt4v5mLwTFunnwwlHs= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730959424; c=relaxed/simple; bh=q9GZvBlwrd92oTt1mnV2lyNEoxYbU4zV1u2AvfyM0ow=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=pcFfgm1UT1O5/vjl0qyfBncoZFSYF6kQt6+CpvuURjNW4tnVfX5EIMsLRwwvWJMNLnM4CnGOeZeUZGSMUN8fePJsDK4pIJruT9DLScO4nJplwg4B+ePWuYN51rq0eTYemNlTWkTe5jxHEKeZdhj7Pd3fD6EKF0AgjmXrxduyU0k= 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=khQYl9cK; arc=fail smtp.client-ip=40.107.237.60 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="khQYl9cK" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=t9EW6nvHB/+V6wRjSlBo15Oid0gL5ZjILbQG98OW78Up4VXM5CuJX6P67kvqyc2C+JXG6BhYxiumbo+3KAdbbi3vl+9j7c1Sya3OIW/u12DfWFVfzzSaYufWkH/yuha3ZpSUFIt5gSGwhq6b7yyMyDv5nMeb75zWkgmq4RWgOJJGO56S6Xt23CKLLIcHq9BR6Qn5p1w+9Dbe7gp339G/RMeaZVqxGkRIY9I3f4v0RGTJcZ2yb4sX5Zie8MvXzi5Fv08N/N/5GKouura+4NjBtI+afoDUseqwWSPgeL9pa0uwCyZlXq0IU7FEEeVjvoFYAocfOMnjyWuR3II6txeI+A== 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=OninPEMgDexlVeaKcBObF+G4EqFFKv7D7USsC0HuLoI=; b=leQexynj7/7qj5y2gyUVffZw8s9dIvfzUd+fOHAUljnov+aZySnkV/J6nfYWtgfdgCsPjlZ+dxqmWvaTJGDznc3/hM+sDk1HPxL5ZVGw/Q9ttwt/dWDTFA7+XeSrS10S/PaI3Wst7L7qEtBOYHEtGIMQRB8vN5T9KyUGlnGYyvznOA9ee7/CrjqD5cYSips6HYYTX28Lan3qSeMXnynycyyI42+l1kjCe4UbO5Mvh9kb4aktDsKZcJKCrTxw6riv58SQla3ZbcKmLVbKWbLxTjlu0GgfUS4dJZrRpY95XQM8KFFXTm9T+sCabh0pKF9P25tLO9P48DHDsPB+qdmTvQ== 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=OninPEMgDexlVeaKcBObF+G4EqFFKv7D7USsC0HuLoI=; b=khQYl9cKsDgAcIydNFuPusSXYYkL8MuxGzrDre4r+dKTPfswW8cZ14DaM//vryEMbpcwWn9VYdnFge/8WcKMHbSM87j/NJEvwd3DdCI1zxSxTwWuPkDDb+906EdwW8VPYcG5KCbgIeT7UXCK2oEG++R5KqtB4J837zOfP5hnOJY= Received: from CH2PR03CA0016.namprd03.prod.outlook.com (2603:10b6:610:59::26) by CH3PR12MB8403.namprd12.prod.outlook.com (2603:10b6:610:133::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8137.19; Thu, 7 Nov 2024 06:03:40 +0000 Received: from CH2PEPF00000146.namprd02.prod.outlook.com (2603:10b6:610:59:cafe::cb) by CH2PR03CA0016.outlook.office365.com (2603:10b6:610:59::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8137.19 via Frontend Transport; Thu, 7 Nov 2024 06:03: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 CH2PEPF00000146.mail.protection.outlook.com (10.167.244.103) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8137.17 via Frontend Transport; Thu, 7 Nov 2024 06:03: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; Thu, 7 Nov 2024 00:03:37 -0600 From: Mario Limonciello To: Hans de Goede , =?UTF-8?q?Ilpo=20J=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=20Kleine-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 v5 08/20] ACPI: platform_profile: Create class for ACPI platform profile Date: Thu, 7 Nov 2024 00:02:42 -0600 Message-ID: <20241107060254.17615-9-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241107060254.17615-1-mario.limonciello@amd.com> References: <20241107060254.17615-1-mario.limonciello@amd.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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: CH2PEPF00000146:EE_|CH3PR12MB8403:EE_ X-MS-Office365-Filtering-Correlation-Id: 1978dc77-2b8f-4baa-a9ec-08dcfef1ed5c 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: =?us-ascii?Q?k39CNQK0MeX/GsszhAkeC9H2/rdHmkHTe1/Md37YtRh5M2kP+UeaKKJesGTp?= =?us-ascii?Q?v2GTl0Abk453BX09Iw0aZ1e/EIauZjh91IcbiIk5IER7ztMpZ5BGOjyHeTP1?= =?us-ascii?Q?/ymygaNbOAiq+uyrgXTTr8DaDxgCjOy26NbKMVNKWjBSMDalGaTSbGyBnuh2?= =?us-ascii?Q?qodDl70ooAxynxl+Gpot3MmYGoZ/oi6dYpusd1UoRcuK5/prGD2M2mfhABce?= =?us-ascii?Q?7JjRNKK2gstuHimJBNKLaV9N0D1ibNsKlT1JD21eecCK7YvrBnrjkDHYg5Zr?= =?us-ascii?Q?CP1VyB43gQOfxoAd80VFzjilZWWZEKxV/1o1XENQjOxeQQua6o0kJ+0A23PD?= =?us-ascii?Q?HJAs9zetspFSUWSye3WLWZ3YBWm4kAPg15YHzFwKWC+AgNltZK2fIwgF7RvT?= =?us-ascii?Q?72ZskZ7WYViYTaPuF/OlRmuJgngGBj+L8R3ZhhSq4+vZ5AuvBMJtT+RwqID+?= =?us-ascii?Q?3LGirytgweWmvFDJbUz4WDuzUdlubhTaTeTqJSvgkvnqxMo1L/iYid/Kmdy6?= =?us-ascii?Q?7RamsoJ1sXsDeMIwhc6+Fro/2vYqO2TiIjXBihB5oZ7sBqMyOi8gGjlPClGa?= =?us-ascii?Q?UjYJpem8Flt5Y2h9nftlHsAdHcKC4PVXrFB3trMI70CKPhQrf0ritLQ3hD9h?= =?us-ascii?Q?PRgTBQgKrQmKoswf6Ucc+pM+2fg0QctHqvE9ZHHOQ7Tl9QXhlQEY6rQpyYwd?= =?us-ascii?Q?oLfuW7z9Bn1XEWEd4nhSGlEID2XGOLHjsyWq1s2Zf9zl5IKsEFMKjf5SVCcT?= =?us-ascii?Q?JslOY7tRaMJqu19ZfARRXJXWoJ6jLFcc6id9oHWp44n/GXb/fdUhxFzKU7dh?= =?us-ascii?Q?8FruipFwpBXTnagemFaHERq2F7TZng+pn1Rjtb9MqmbjawFt8sJM2MVP6Jw6?= =?us-ascii?Q?sBvj24KdLNCic8bHzBUyjXfWeDqoh4ZNh945GgHjWP1+yRJxnEe/ux/1yTxT?= =?us-ascii?Q?5O2SO3p8wbJxtLAi7H3M6J/VQt/f65xNXTH0WhBcHbm64qtf03Hz81L/T+RV?= =?us-ascii?Q?kHtuh3uh6dLH3NVuzzz+pzb+ZLmvxFRdDBkorIwXm2UpBKLEpvZRJchFE/5i?= =?us-ascii?Q?+Ki5HtdZ2+uu71tVoVDKL3UpB0YAc+1bMtXoSehAfP4XMGnJIyfjgwyD3XU2?= =?us-ascii?Q?kZKG8Xs1ls31rI6UvWImj1ER1ItTsDsRgaM9eaMbpufS+Za54puxVJphangL?= =?us-ascii?Q?o3JE7bFP9KtecXy0+/JVJAjoDR2TCydBIRpc1GGhuLhJ8a2/WkA3ALp5qQbV?= =?us-ascii?Q?DXXF6CMt81XqBrbdmRCqLtpgGfgaWDraZWSiYptKCmI7Us28pfb070dadxQ8?= =?us-ascii?Q?TOi5AMUP1rx8hQ4Cr4gHzGK9tiGeswY+fn3rj4Sgd5gJ5dJTKduJJWu2iyt2?= =?us-ascii?Q?9782yWqkawU3lBz4nbpACV8YGlN0jZX5chhxiiwKCGo7n1DTtA=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: 07 Nov 2024 06:03:40.1051 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 1978dc77-2b8f-4baa-a9ec-08dcfef1ed5c 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: CH2PEPF00000146.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR12MB8403 Content-Type: text/plain; charset="utf-8" When registering a platform profile handler create a class device that will allow changing a single platform profile handler. Tested-by: Mark Pearson Signed-off-by: Mario Limonciello --- v5: * Use ida instead of idr * Use device_unregister instead of device_destroy() * MKDEV (0, 0) --- drivers/acpi/platform_profile.c | 50 +++++++++++++++++++++++++++++--- include/linux/platform_profile.h | 2 ++ 2 files changed, 48 insertions(+), 4 deletions(-) diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profil= e.c index 0450bdae7c88b..652034b71ee9b 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[] =3D { }; static_assert(ARRAY_SIZE(profile_names) =3D=3D PLATFORM_PROFILE_LAST); =20 +static DEFINE_IDA(platform_profile_ida); + +static const struct class platform_profile_class =3D { + .name =3D "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; =20 + if (!class_is_registered(&platform_profile_class)) + return -ENODEV; + scoped_cond_guard(mutex_intr, return -ERESTARTSYS, &profile_lock) { if (!cur_profile) return -ENODEV; @@ -163,20 +175,50 @@ int platform_profile_register(struct platform_profile= _handler *pprof) if (cur_profile) return -EEXIST; =20 - err =3D sysfs_create_group(acpi_kobj, &platform_profile_group); - if (err) - return err; + if (!class_is_registered(&platform_profile_class)) { + /* class for individual handlers */ + err =3D class_register(&platform_profile_class); + if (err) + return err; + /* legacy sysfs files */ + err =3D sysfs_create_group(acpi_kobj, &platform_profile_group); + if (err) + goto cleanup_class; + } + + /* create class interface for individual handler */ + pprof->minor =3D ida_alloc(&platform_profile_ida, GFP_KERNEL); + pprof->class_dev =3D device_create(&platform_profile_class, NULL, + MKDEV(0, 0), NULL, "platform-profile-%d", + pprof->minor); + if (IS_ERR(pprof->class_dev)) { + err =3D PTR_ERR(pprof->class_dev); + goto cleanup_ida; + } + dev_set_drvdata(pprof->class_dev, pprof); =20 cur_profile =3D pprof; return 0; + +cleanup_ida: + ida_free(&platform_profile_ida, pprof->minor); + +cleanup_class: + class_unregister(&platform_profile_class); + + return err; } EXPORT_SYMBOL_GPL(platform_profile_register); =20 int platform_profile_remove(struct platform_profile_handler *pprof) { + int id; guard(mutex)(&profile_lock); =20 - sysfs_remove_group(acpi_kobj, &platform_profile_group); + id =3D pprof->minor; + device_unregister(pprof->class_dev); + ida_free(&platform_profile_ida, id); + cur_profile =3D NULL; return 0; } diff --git a/include/linux/platform_profile.h b/include/linux/platform_prof= ile.h index 58279b76d740e..d92a035e6ba6a 100644 --- a/include/linux/platform_profile.h +++ b/include/linux/platform_profile.h @@ -28,6 +28,8 @@ enum platform_profile_option { =20 struct platform_profile_handler { const char *name; + 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); --=20 2.43.0 From nobody Sun Nov 24 03:28:03 2024 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2066.outbound.protection.outlook.com [40.107.92.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 406AE1D88A6; Thu, 7 Nov 2024 06:03:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.92.66 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730959428; cv=fail; b=o9fkBBbkupI4gU2ettFl5vhSEmpiKl0tOM7BiQIhd0PHHFHZRpD5SncjSSY98/N/H8qX3hJg3LWMPNYsMx0oXtnVoxTN0mR/BCZyH8JgPrpfq6IqDo974KlA8FTfHJ9NvGhVAXpYRl6EoZOHVtdmd62oVdsP+UJYeGpgCub/Js8= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730959428; c=relaxed/simple; bh=OQXVw6u+M7syhHbLbRezlPZA30ypVFVMtBz8NgxSXIk=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=sf7bldaxDvheeYHsNpPqEgekPvE/gA+SaAVm0b1tcTuiukjiwKhGEY+w1ymNFeCclz1KfUYmW8rwC4i733cTZ8eVdD10JP8ZEC+numxaA1XR6DK77ZdGkONiX3v9/wwKpHJPZPEGb2/AQnxK/GXE4cc/ZDJ387qb9aF3VnNr61w= 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=LtWUhb4O; arc=fail smtp.client-ip=40.107.92.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="LtWUhb4O" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=dELxqkpltC3sUqSYSutrZqAmdnXVadWVMGhJGaDIufbl//HuxytVf0pMnj9LoaPQjKxCFSLvlf13ywbuP68DaSmzCMbL3H4TmxqHINA0D1Qo3557FqJ183COVsZ4C3MIo0CUnGKi035T/L2Z4U7xaE/vhaG8Bkyv7dydIzbB1CmQsIdixpvOiP2ctzV8bGIgLXAB76w87UIxRaXOR+WWw3RcZWwyZWaXVpyZLbYkyKbx0PcyspHeqqGTCJWcD/YcXkEdtns+8bU2wVXXHcd7izcJ7UiPSgYl2/KwR5C+vpBybfuynFYcN/euE7AffgnumhenwczQBL1OV1S+tqYwpg== 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=LqKSai3N+X4lQ2c3ALLtn0M4GqhAaiwrFQCWs3AImhM=; b=ySL2CPiFT9KbxFAIlMdtCmfwqMROyOV8NtQwlKWY2evn1/VBeCqb08KpydddMJrfkE7WiNoi+4I1vewgyrzZHV3xtIZNQE/lRMc5rb6gHMCY7IUo3hgxM/FwnahxZI1ZqtwdmGRBlGjpY5oFoDU0J02BeGRac5rHHYTPjbsP9G51bM5DjwTnaxxxzrILwsoKw2708aPp7VQkRzZ1enmUUIWLT641Kh+Ju0hrW1ogXa0z25nXfh5jxL3k8toiRRKiim2jj5t8WnCD7vykisDRxihyVqdgW+28Ikv9Vs7IniltPj3M31N0++h3vkao0p6OA8NbXLPkCBMV1n1DysdE5w== 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=LqKSai3N+X4lQ2c3ALLtn0M4GqhAaiwrFQCWs3AImhM=; b=LtWUhb4ODckhbqdD6P1cxX0fs21ztDZpnx01yndOw3zbKWScIylny5hTgl/g5kYbMs2JUjwTKVGynYSXu4YAgyhtep3nkzJ+ZfjUpOKzg8P4UTCCocXUqO/2jCnkhohxbzCq7Z9xHXZWwZQj5SWJJq8ww4iJKk8EflmXShUBzTI= Received: from CH0PR03CA0292.namprd03.prod.outlook.com (2603:10b6:610:e6::27) by CY8PR12MB7313.namprd12.prod.outlook.com (2603:10b6:930:53::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.29; Thu, 7 Nov 2024 06:03:42 +0000 Received: from CH2PEPF00000147.namprd02.prod.outlook.com (2603:10b6:610:e6:cafe::97) by CH0PR03CA0292.outlook.office365.com (2603:10b6:610:e6::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8137.19 via Frontend Transport; Thu, 7 Nov 2024 06:03: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 CH2PEPF00000147.mail.protection.outlook.com (10.167.244.104) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8137.17 via Frontend Transport; Thu, 7 Nov 2024 06:03: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; Thu, 7 Nov 2024 00:03:39 -0600 From: Mario Limonciello To: Hans de Goede , =?UTF-8?q?Ilpo=20J=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=20Kleine-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 v5 09/20] ACPI: platform_profile: Unregister class and sysfs group on module unload Date: Thu, 7 Nov 2024 00:02:43 -0600 Message-ID: <20241107060254.17615-10-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241107060254.17615-1-mario.limonciello@amd.com> References: <20241107060254.17615-1-mario.limonciello@amd.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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: CH2PEPF00000147:EE_|CY8PR12MB7313:EE_ X-MS-Office365-Filtering-Correlation-Id: 79b08a48-9931-4637-9aaa-08dcfef1ee66 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: =?us-ascii?Q?zi44XaYeXA0Q/xlwwKJFktFrcXMuuhlWzczoywW2uL+odWoRqXo90Rr51NUB?= =?us-ascii?Q?WfKfMm6/ZQRSMrTeL1AcWhydXE95QLBLON3uxcs3SrqKrJ6hcb+48obW3tZU?= =?us-ascii?Q?d8uXcT6ksRAEVY1/fuFHXUOcjOHOglju3nvrWHJknWf55gw2OyIhvF7d/jjg?= =?us-ascii?Q?cC7gHbWyVP2lkGgmG7V8XebIauCI/ixpVwi3ntcFhMQZx9KxC0BgdYbvUymx?= =?us-ascii?Q?x+Z0AwMMJs4wemhpz49BmwYH2XuGF1p+HwfHJtfOI3Uxr3aHahtidC3c9/tK?= =?us-ascii?Q?4EC2BwcYmmd2JaacjhRIOq2US/NEZDa1eHTGd/NED4Q/4kpliZwKItnkR528?= =?us-ascii?Q?Ge7hs6BNmRG9DGNADkYBJ9AmZF3Kq0BwuCbUdAcnZ+svtEgWB9J1qNzvZr4X?= =?us-ascii?Q?te7/4AWXypUvTFgzwJg8IfmlMC7gBoPr2IL13vwavBCWHgF2XRtSib9ugog5?= =?us-ascii?Q?R2po0FAna3LCIadSaCVXeWlrgJ+i2WQLIW9Tmx0Kr4A5oz8w3qsuZ+2omtLz?= =?us-ascii?Q?uGfD9/4CbUeh04amtB0ZJmFVooVc6Jo54ViUtYcoCI4LiQEV1XdGuWEyt352?= =?us-ascii?Q?Pz9ccxafxy5ikBNcGIK9Wz0NbPV4MDb6FRTDRHuENLVk4W1BXK8CZoNY6PJy?= =?us-ascii?Q?s+rQZ/1kq2lf9jOEBPvzhB30ulfdVCDmg/SliIHVx+KzBc32u66QdGiyj8iq?= =?us-ascii?Q?7+eofj3jyfDYL+PUSGRL3VpzjZCeQYirnBwxUX0oUAvjxqKHBaeaBPIHZF4p?= =?us-ascii?Q?wnVsE0CZJjPe24Wf43d4I+Cu0UgqEe2vptRf+F8JZbe/c9xTgzPQSsn4L6Ig?= =?us-ascii?Q?n9gnY4L/43h/Uwcg8D8qaPFL+D89HUsqNv/4XDM+nHZA90P7LFH0UUdhA4kl?= =?us-ascii?Q?hgPeufxBZ9bKaL+Od48jw0L/QNiBC96GZ2pqU8Fu7zk5EN+1iltoDXZmYC5V?= =?us-ascii?Q?UVJotGRHpOWzU+tsIm6NFVAnIFcvZSf4ODRtOHU6j2DAuDEmtWTmK0zVns04?= =?us-ascii?Q?vyjfVaHUDh4h+6y6+VWBAYDwCNnHIS+uEd0A6q6e/3RlJ+TfL8MXTmrvgTN1?= =?us-ascii?Q?jUtd9b3pNhxAU3mxNUrUsWpIKRHcoOfVShYI4cSENTc+PLNaL/0pCR0eiSTu?= =?us-ascii?Q?0QcD5hf4kJv8coINs2H7YyjGK8xLkbrm9kjwYD4aGrp2RjsGRICG8sRc5SXW?= =?us-ascii?Q?G9/3xF80OzHhwVU0+PhHuWIxk8V1PqhcTbo+I64CDERR90whSqBrnrAUZzv6?= =?us-ascii?Q?F0blLjBS9pA9P3+vjvDXEf7wEmD4bAPhxynhxep+FAo+fZ5tUDoxg2p6vbh4?= =?us-ascii?Q?MO5yxQf7DBonKCZ5zIfz+jZpeO7HsVwD10PKYK2Y8pSERnHAZh6qAgR2r1ue?= =?us-ascii?Q?JIei+r2vCOYasiIhxuVQcJ5S2CWE667rhZS2m6tmeLJ+CrDuyQ=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: 07 Nov 2024 06:03:41.8167 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 79b08a48-9931-4637-9aaa-08dcfef1ee66 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: CH2PEPF00000147.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY8PR12MB7313 Content-Type: text/plain; charset="utf-8" The class and sysfs group are no longer needed when the platform profile core is a module and unloaded. Signed-off-by: Mario Limonciello --- drivers/acpi/platform_profile.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profil= e.c index 652034b71ee9b..9caf070f77f6a 100644 --- a/drivers/acpi/platform_profile.c +++ b/drivers/acpi/platform_profile.c @@ -224,6 +224,13 @@ int platform_profile_remove(struct platform_profile_ha= ndler *pprof) } EXPORT_SYMBOL_GPL(platform_profile_remove); =20 +static void __exit platform_profile_exit(void) +{ + class_unregister(&platform_profile_class); + sysfs_remove_group(acpi_kobj, &platform_profile_group); +} +module_exit(platform_profile_exit); + MODULE_AUTHOR("Mark Pearson "); MODULE_DESCRIPTION("ACPI platform profile sysfs interface"); MODULE_LICENSE("GPL"); --=20 2.43.0 From nobody Sun Nov 24 03:28:03 2024 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2066.outbound.protection.outlook.com [40.107.244.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 78337197A7E; Thu, 7 Nov 2024 06:03:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.244.66 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730959429; cv=fail; b=e0kCdkgHFm2Decpq2mDzcgbixBVeakTIl4dEFp1pxqn1Oooa0Vi0Ov4iqTTRYtNDEoGIY1ynV1Hs2HnXq2RRBP+hQC+1LOvik/V6NF5rnE2i/gVOPCQvRgJs/cOgaf+kpHMQhyyjhZA7ePN0eOreleexi3tqQZ6AHLXiRgKo5k8= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730959429; c=relaxed/simple; bh=QsAXOgS6tiGey7CpnUZrLRQVOLxqlxqGQKPNtyXWShM=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=h4sbd+YOATcAppuZTXP8TuMyz5esmNQ3gE5ija3G43KNWdvcyD1sdEIf1aqSGx4WykUHfaUCjwiTLr2SqXnNQAaEKGiFgxFkHcwN/am4oSMB6lbhvW+mBw2F00EkCSDQW2VhpxmOXkrIxqlKl7JC7kQ9325hLdjHGMODRgIvDmU= 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=tTPxi6y9; arc=fail smtp.client-ip=40.107.244.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="tTPxi6y9" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=WxgYpNE6fDFh4Tur2mCNxdDSYsox2v2wglHEbEIOtOrCMQ0BlHVB9X10ct+j+tZiQSplcTyVNLZOfK48FgweKx3vlS8BwIMoLcUHhRuuBIp+yGX7zshJfrPqQrauSpaC6XtYpOmymfDgJu8yMwkzqgMf3aBx5IWCUy+qHbkWXuunP/KH7SAD1aFQDG0/ZdAY5rP79mXA0splivmdu8L7e3oWfnlup2REMvytGKjmfaSEmN+f3obhoOJStZrs3tDbRSPhp2ZzVmV6WWNMThlEz0P5WuKWA4y7e+whY8v7lg93jjzULJAjrNRw8VzfRzaPpOO1oruv9Ontml+ZTulbmA== 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=+458Bkc3jM9LeqcDeTMlbe5a/JNm3coZ7L9HhdhC4ko=; b=Nbb/ATORou7SS1R+7B59LBiB+y27GgOglyRbXO4/ySxZr0hQW4moJyjeP09+XpwDvAD/Swb5mY37gao/Yv/nS6vZpmrX9YwrtC2JfODnohdAIxcapvWIFq8/rVZlGV8+hxRQyjkZTMcg5KHu5ef8rrBBuY3XxRBA6hpFFQwRG0exE8c0D/fQ1KfSYxf4//+53CuLaBP6wSIcjb4TRNT+9cGyqjfKDOELw0Iwlk4By4yONwK7T94Oj76G96uC43rbtQMKbHgy3SAxvD8HZdR0HTwLunB0gDofzeQWMtBlWVY2P5NjOvo4D/7PDdRhXHqbUWk1fB6x7kXusy6MEYK6Wg== 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=+458Bkc3jM9LeqcDeTMlbe5a/JNm3coZ7L9HhdhC4ko=; b=tTPxi6y9zCgbwbNHtftWzP2bvyqsylAMaMDbTwcPcJRzHW0c5ELK6+02quMyh4wHYqR9ZcYe2RTcHXo0Yq3D+8xj51z7uRCrV5tqUZs1K2bRzKv0DdlZgCd4Af34b18XdkrV0AP44Qg47TPN/AoxSgK2iO044aEz4sNBalKNtkA= Received: from CH5P222CA0007.NAMP222.PROD.OUTLOOK.COM (2603:10b6:610:1ee::19) by IA1PR12MB6460.namprd12.prod.outlook.com (2603:10b6:208:3a8::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8137.19; Thu, 7 Nov 2024 06:03:43 +0000 Received: from CH2PEPF0000014A.namprd02.prod.outlook.com (2603:10b6:610:1ee:cafe::4d) by CH5P222CA0007.outlook.office365.com (2603:10b6:610:1ee::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8137.20 via Frontend Transport; Thu, 7 Nov 2024 06:03: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 CH2PEPF0000014A.mail.protection.outlook.com (10.167.244.107) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8137.17 via Frontend Transport; Thu, 7 Nov 2024 06:03: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; Thu, 7 Nov 2024 00:03:41 -0600 From: Mario Limonciello To: Hans de Goede , =?UTF-8?q?Ilpo=20J=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=20Kleine-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 v5 10/20] ACPI: platform_profile: Add name attribute to class interface Date: Thu, 7 Nov 2024 00:02:44 -0600 Message-ID: <20241107060254.17615-11-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241107060254.17615-1-mario.limonciello@amd.com> References: <20241107060254.17615-1-mario.limonciello@amd.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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: CH2PEPF0000014A:EE_|IA1PR12MB6460:EE_ X-MS-Office365-Filtering-Correlation-Id: 2d43da61-ea95-441d-e807-08dcfef1ef58 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: =?us-ascii?Q?1FsL5X7vfE1teHQYcy4i2BkLeFd+3KD+zg0ocyRpsy3mr+r0fhADn9hXUkXJ?= =?us-ascii?Q?TFk11yLKWCyd7ru+ZYumKu1UDW8BzO+XrrOt9zm77POC1fPhWGCVTtzMs5GO?= =?us-ascii?Q?/eKFCwdIFazABA4xKNZWqdG8x/g/2DsigOrIuUNtRWP9VtwGtsI6c6HWYiHn?= =?us-ascii?Q?UeemWMrS13xaogxmJq48+GFu1OHhTgNdx2jeEDexsa8unMMmhoFXgEmbuHfM?= =?us-ascii?Q?b86PDqjrWPbOB8TejOKpURvDmh4NxXOPXXex9NzihvsbH9Av8gCYRZXaSrIR?= =?us-ascii?Q?fFxaaDbmV7utuom5rS138IhT2a1KLR5rJVDPv5HdZdffOKU2TJFdvFLOde1s?= =?us-ascii?Q?f5cD+yO3t0xlSSlQeJJfbMe9T4Riu/uE7nYKO9xhwWUuwNsMdG4RXc+C2hfY?= =?us-ascii?Q?TlJW5cZB3yvDVfSCZDcAbfoFSB0X+kz/kvwRm9UuyZA9Kimp+ncbXd8Gsxiw?= =?us-ascii?Q?3CZSUFPJXX9NgbbMml+9bMqbfCHr8hL3dWI2djFuYoCGLKVfjegLelbcPNFn?= =?us-ascii?Q?Y5uY5gaAjdILLmM2PJghixtPMW2KiN/1ERMEoG6QJouf06OC9A+BiC21/QY1?= =?us-ascii?Q?S2X7Y4+t52QY4vqGTfag4tSQopEJIj46LqWSnAkvEKOzgXtdvVkyZFkp4bmC?= =?us-ascii?Q?uhqtvcZtX7iGpgvC+WtIyHklyE3HPNeVJxo/GVlEHbTKz6sI+GKyDN7K9h4j?= =?us-ascii?Q?GfkDnaPScW+ip1JfAMss0vSKbYl2r51Ki0tOqaSxDX3HH4B3if04lmvMmjic?= =?us-ascii?Q?3F7Xpe4Poq0ww8f63D+16P4xCi5G+uH9iXOYAnUU/LXCmxwcU4tND2WkqIjF?= =?us-ascii?Q?xFKEFF4xfdjhT86l0MdUlCxZEAGaLlWYUWDw40kL6SKPSHdxcT7YZ++PlwrN?= =?us-ascii?Q?Lv+KFhrYClmRE17pxqUiJM+mPeim3VAP7p60CFa+3Li1RlRqWtaaumni5fHO?= =?us-ascii?Q?AK9w9S0loxn4gNTwCaw/qCgr4QfI+5gKvoW0SvWGHrRuSOhYD5wSnMCjcGUO?= =?us-ascii?Q?u0CMMyW1XB3td8DXLa9LeYVYah+qNVSYh5PH3D8xE+PCE7TIsyvaAXl9N/0B?= =?us-ascii?Q?VLmE7gf1MRWSAv1W+OAntDEJbqaXIV7xntAF8Ibb50RJcqv61UckrvpWwmv0?= =?us-ascii?Q?KafjoaUlHa0KyqiUYieD/wVl3qt/1J1SR2pnWPenuPCeCvUuEh8o9iPhCI7d?= =?us-ascii?Q?YZnKox2zCzW73vQ6Yqje3iT3SriHDZ1gWxXGhS3JvX6nNcvLiQzvni1rId7V?= =?us-ascii?Q?DBB2r4Lam4REBZq5uDUTJAH5PfpdUOSP5mYOiGF1/Xi2JqCImkjCp272VT7n?= =?us-ascii?Q?B7KnPACcsMQdCbCbSfgq0JksMxc+34yaOmSc4TLrblSMHq0R6CRTI9fVNuUW?= =?us-ascii?Q?akyBIhhgvITb/A4a4///qtrWmhQ09kuVUfCEzGZptXIIZEo+Cg=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)(1800799024)(82310400026);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Nov 2024 06:03:43.4359 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 2d43da61-ea95-441d-e807-08dcfef1ef58 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: CH2PEPF0000014A.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR12MB6460 Content-Type: text/plain; charset="utf-8" The name attribute shows the name of the associated platform profile handler. Tested-by: Mark Pearson Signed-off-by: Mario Limonciello --- v5: * Drop newline * Add mutex for sysfs access --- drivers/acpi/platform_profile.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profil= e.c index 9caf070f77f6a..f605c2bd35c68 100644 --- a/drivers/acpi/platform_profile.c +++ b/drivers/acpi/platform_profile.c @@ -25,8 +25,35 @@ static_assert(ARRAY_SIZE(profile_names) =3D=3D PLATFORM_= PROFILE_LAST); =20 static DEFINE_IDA(platform_profile_ida); =20 +/** + * 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) +{ + scoped_cond_guard(mutex_intr, return -ERESTARTSYS, &profile_lock) { + struct platform_profile_handler *handler =3D dev_get_drvdata(dev); + + return sysfs_emit(buf, "%s\n", handler->name); + } + return -ERESTARTSYS; +} + +static DEVICE_ATTR_RO(name); +static struct attribute *profile_attrs[] =3D { + &dev_attr_name.attr, + NULL +}; +ATTRIBUTE_GROUPS(profile); + static const struct class platform_profile_class =3D { .name =3D "platform-profile", + .dev_groups =3D profile_groups, }; =20 static ssize_t platform_profile_choices_show(struct device *dev, --=20 2.43.0 From nobody Sun Nov 24 03:28:03 2024 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2047.outbound.protection.outlook.com [40.107.243.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B21981DCB2D; Thu, 7 Nov 2024 06:03:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.243.47 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730959435; cv=fail; b=TT7QzAWHD1/DjsSrOnhWfZowekbM7JGtIGzOHrvEP8LDJAQVX8meC/wJe1YatHBmca9cHc03qRBcPS7ywqJw/jA4xDVA0hLlLH6wZvNFN+BAK25FTTtt4DIRLljra3TCJXwUkCkrD3VRMclcN7ahNBHfL6a5kKIt4/1Oh3y9CbI= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730959435; c=relaxed/simple; bh=f0l893LI4FVlohn2BPDpkgTKzCKlgVj83c0H0mShSkg=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=PRSPYj8yExjr11mvKj2MsW2ntR6zAP5gvwKbeK7wencWoVMgAV6IJi6A/Xodx9NIbY1uF/IVHPg2fAB0LfuPHK8jrCzpuLqoO5fJxtBrKEBOPi7mncYVPgu/P5Mhmoh3FU/M3XEmOnWHgUTgRgpXVUmUaDlZfmubIAmqMJVnn0s= 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=E4p/+3fn; arc=fail smtp.client-ip=40.107.243.47 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="E4p/+3fn" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=EtUhRo0weFmkugPGTsY2jNbMY+SqPf7+c1c9Y4xMaF8wwZqe5SW5UxwY7/RZ03gKEwcsQTbFtJ1NiYfIesgsKCZAE7G3nHSyYajxiMTS4BF2La//lm14xDv3sDzU/nmZEWkMY4djM5ms8JiMeZIZCBsW5/iRv6oDwiaQfdtigkQ1UTXElgr2ZvbD2+GuoIOlQQj2jwEIjt1wID7b9NjTVj3epv9QjAAixWZ7OUDRvlhNLjQ7YIi8WEZV/PgnOv5SqQPTDTjqt73HgBmdCr4HCCAHh/gV3Ttn5dV00ZBucQyWvYsN7yaY3K+E1lv4GxoFmJg+UL6Ds41DTO8xqIkkhA== 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=QKO6ignEE16gTq7imld5NyURl13XVX5rOoT2wTuRBDw=; b=mRE4N4b6NaQJDJdeoM7pM3gtsB1jJQo+LeltGY3fodLFgychmbiKbE1m62/b9y/ke4a5vLrDRRmY/h0jGyY2pAMXN3YXAGqDdQ979/uZtoJyxwA0UUz/7RUa1wbUOmEVcLZDSwqybnMDm502uEfWwJ0xW7rO2SmgMVMOhYsmDi0V5oHF5Ezg4pZCdoxk2CMCMB6V8pfWl8HGi5E7wdDsEJl3H+VhCQVCBfEqnUS/ApWzBxhQPjMhstguJIJXkHm91GXdxY1r716FUXvm48oFnBIeQH+HTPgRXjW8s92rLmPGPeYiRPXLAsW3s88EzReVqAT9CCEakINGtYULDdyuiA== 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=QKO6ignEE16gTq7imld5NyURl13XVX5rOoT2wTuRBDw=; b=E4p/+3fntAzw1IXQzi+JJGYMvEAL9+TKcPGQAkryQ2BhI2HEx8Kcloz8txLB7WO2+QVgxIyq7lvfVGbs5POeJRrhFL2R5hbTdXTHQHBxJM1juw5oA4hRJEQPmzfVU0H/1dsWN7ClDuFz7UOlmkxvEX5fsQ9gl9LZKsDP2tjsYAw= Received: from CH5P220CA0019.NAMP220.PROD.OUTLOOK.COM (2603:10b6:610:1ef::17) by DM3PR12MB9413.namprd12.prod.outlook.com (2603:10b6:8:1af::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8137.20; Thu, 7 Nov 2024 06:03:45 +0000 Received: from CH2PEPF00000145.namprd02.prod.outlook.com (2603:10b6:610:1ef:cafe::33) by CH5P220CA0019.outlook.office365.com (2603:10b6:610:1ef::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8137.20 via Frontend Transport; Thu, 7 Nov 2024 06:03: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 CH2PEPF00000145.mail.protection.outlook.com (10.167.244.102) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8137.17 via Frontend Transport; Thu, 7 Nov 2024 06:03: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; Thu, 7 Nov 2024 00:03:43 -0600 From: Mario Limonciello To: Hans de Goede , =?UTF-8?q?Ilpo=20J=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=20Kleine-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 v5 11/20] ACPI: platform_profile: Add choices attribute for class interface Date: Thu, 7 Nov 2024 00:02:45 -0600 Message-ID: <20241107060254.17615-12-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241107060254.17615-1-mario.limonciello@amd.com> References: <20241107060254.17615-1-mario.limonciello@amd.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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: CH2PEPF00000145:EE_|DM3PR12MB9413:EE_ X-MS-Office365-Filtering-Correlation-Id: 3165bf55-0f15-4754-ebce-08dcfef1f085 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|82310400026|376014|7416014|1800799024|36860700013; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?on4eKRnvJEooSDZCAUkhJ0KEGkE16Ne3EbraH9ZWAp5Oc2QRMGxBiELoC9x3?= =?us-ascii?Q?4Rg2KzXGSRE5PLtAfKVQsg3tBVdxkpMHNvB+nIFXtix+npNEIo5H3jyO4GDL?= =?us-ascii?Q?Hpldablw9lJQpjk2FUyvWs2wYYPrDr8KbtyvcMkTXrk5izJd38oxIpc54vHt?= =?us-ascii?Q?BqZNvYqJKzU13mJrFAUDiNmw19n743S+YBrlyLpAF4QukT0gvj30dm/Cl3RU?= =?us-ascii?Q?83UZFgaUil6bpWfL++Etm8NyolgZwCtgQKQc9jRnUPaN5/7PCnaxAJHg/50H?= =?us-ascii?Q?a27XjyrRu2bmSoeErWvFx7nFjjT5br9oKYkGwCOFOzPU/xhgghpVGjFEwrPw?= =?us-ascii?Q?qD4Lrz5644BDHS4NTs/7fWBLiR6DX4koZe6QbgaKD26pwzwOgY9rT271ZplM?= =?us-ascii?Q?0fSr2sYRzO3II8b/5zmoz3dBKsuHoro5ySbIc60iheE0arszqTPVTs+tDfvz?= =?us-ascii?Q?lIyS4rz7JQe8v+9hXGtm9o16NvXStLZOzVG+QXVR/jCl8NzqiBU/lfJT7EdB?= =?us-ascii?Q?AIQbFgwc/Tkuo0/xCRdhB/UvVxFqy5jfRPPhrFjERa4/X42lw5LcPoNk8I77?= =?us-ascii?Q?m8rDKIz80jGpXocAEE0UIE9bQenEe02zjno89451GNtjle/6Ffay6jCUHO+U?= =?us-ascii?Q?3IPctUzvl2zk7jDvMwClWNS89IjplY8f+Uw/V5n8phIrusZf4bHJRps/RgYC?= =?us-ascii?Q?S2UZmk5pl/vIQEsekAZ9aE6W/htAuN6oVEVPzSncicIQGMC4Qe3ziO75ALb4?= =?us-ascii?Q?NSuGT6At/nPbkW0fW42I+3v3+mD2Ub5hx4OAdGl0n6FywPTgDBtzy52Vlr/4?= =?us-ascii?Q?rX7agvU8/ZHfvIAFEf+o3+9u/bOw94xUGVOG78cXR3jJsaUpfVeRwffSzYqf?= =?us-ascii?Q?SBbCaKQMvVrhi1kV8FK8cfLMkGWsrY/ui7ZwVoC2c1ypnqvCQ8TroCpis4so?= =?us-ascii?Q?PkBfQCYPEJ2twacYtvqAyM/mTdQmYC4uFgMJCK0H2fQn0aKUnMBpMmZozg0G?= =?us-ascii?Q?7zF4e2j09d4GRFPfM5ZZnIKgcTy1NHpgFyEL7u/qJcCYTOBWDaSm7nfhNxh6?= =?us-ascii?Q?+bHv4stc1O5YA+7QfisCaK9OZ7M4PxPy98cLhzoGhTHizibL8qNQ+CGd6Ew0?= =?us-ascii?Q?WKZWEcpqHQmwTTUYM4WuFpWdjYIpGwpVwVpHXmg4mEfwBwjs/rpMQsrgTHdk?= =?us-ascii?Q?eu7LO7XV+2cl11EpKbG7lS9RHuIGwE5wPdIqrntZ68ayQhxT0ImBbpZj+nvc?= =?us-ascii?Q?jkSIQ6rOQe9bv7IVfkCOPGt/yxi1npPMb0XI7OWnFD2vKHz5ymxzK/stwRXE?= =?us-ascii?Q?zBfZJP54CKG44NEEV2aih6NrTCibUUdWW9xeR9TWaUyMdww3STLIcXo9uOxf?= =?us-ascii?Q?FclEUAMOjiK6rKk/9v6H03rgdVG32610L8juu0ErOtCywl836g=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)(82310400026)(376014)(7416014)(1800799024)(36860700013);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Nov 2024 06:03:45.3305 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 3165bf55-0f15-4754-ebce-08dcfef1f085 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: CH2PEPF00000145.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM3PR12MB9413 Content-Type: text/plain; charset="utf-8" The `choices` file will show all possible choices that a given platform profile handler can support. Tested-by: Mark Pearson Signed-off-by: Mario Limonciello --- v5: * Fix kdoc * Add tag * Fix whitespace * Adjust mutex use --- drivers/acpi/platform_profile.c | 65 +++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profil= e.c index f605c2bd35c68..5e0bb91c5f451 100644 --- a/drivers/acpi/platform_profile.c +++ b/drivers/acpi/platform_profile.c @@ -25,6 +25,46 @@ static_assert(ARRAY_SIZE(profile_names) =3D=3D PLATFORM_= PROFILE_LAST); =20 static DEFINE_IDA(platform_profile_ida); =20 +/** + * _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 =3D 0; + + for_each_set_bit(i, &choices, PLATFORM_PROFILE_LAST) { + if (len =3D=3D 0) + len +=3D sysfs_emit_at(buf, len, "%s", profile_names[i]); + else + len +=3D sysfs_emit_at(buf, len, " %s", profile_names[i]); + } + len +=3D sysfs_emit_at(buf, len, "\n"); + + return len; +} + +/** + * _get_class_choices - Get the available profile choices for a class devi= ce + * @dev: The class device + * @choices: Pointer to return the available profile choices + * Return: The available profile choices + */ +static int _get_class_choices(struct device *dev, unsigned long *choices) +{ + struct platform_profile_handler *handler; + int i; + + lockdep_assert_held(&profile_lock); + handler =3D dev_get_drvdata(dev); + for_each_set_bit(i, handler->choices, PLATFORM_PROFILE_LAST) + *choices |=3D BIT(i); + + return 0; +} + /** * name_show - Show the name of the profile handler * @dev: The device @@ -44,9 +84,34 @@ static ssize_t name_show(struct device *dev, return -ERESTARTSYS; } =20 +/** + * 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 =3D 0; + int err; + + scoped_cond_guard(mutex_intr, return -ERESTARTSYS, &profile_lock) { + err =3D _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[] =3D { &dev_attr_name.attr, + &dev_attr_choices.attr, NULL }; ATTRIBUTE_GROUPS(profile); --=20 2.43.0 From nobody Sun Nov 24 03:28:03 2024 Received: from NAM04-DM6-obe.outbound.protection.outlook.com (mail-dm6nam04on2080.outbound.protection.outlook.com [40.107.102.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 C3DD9194A44; Thu, 7 Nov 2024 06:03:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.102.80 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730959433; cv=fail; b=C7ZOaE09y2M5DSuoAjjxFS6v9nMMWZXhYh+tRjhDCrtr4Eh3+bHC5TJdEzt+418RGrzhAUQ4IYGIRdPVX51YxDgU6IH3Ybhy+ao8ZUE04YndgWVnKxPVNBlvtp4hzuGZfmVOT6EWiK9ayuwJ7wvl77HGcHfAaRwNZranz+O9Gnk= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730959433; c=relaxed/simple; bh=/J035DqGcKwrpg7UOyQsQjC7qLIPU4AKT/W+VfqOGHY=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=kMQM8Kegj2ypMcJVys6t9eb4NXl/L+JP0HNoBKve+DKr2t24BNTiu2GHGfKX6WgQ5VJIXzi+bIXrrggZ8XY0zoq+GjE1ECMb4cCEXwPHZ5cVLWmWn74W4Tddw4I0l1iqwqcSUcLJ1dgWhNvYpXzcVjpY4xb8/+Hwf9lBfgJsYG4= 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=czPmi3XN; arc=fail smtp.client-ip=40.107.102.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="czPmi3XN" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=dFG6mHH4cdIO0naquAZhil7EqDfFb0Sc5xUXe4wbKFFBA1XIRgi8c4H9bpwulfW6AolClrvcdeFYM19e9vXokjkUnlHTWasFbmkEZCL93ghko/LDQxzwYxVstbZuPZjfsKSbe3+XSu8qvtLqiAF7qkYlCK+o790qqKaJva2u9OhHCDsLwjIRz4od2eeHeXWPsNb2si8Nr0wRxa/YBCaIjz9LBX1qu9ciz5bouwrI19WN2YjOzOiTQx+MpMVDxYr+6MEN9elZCgmpY750eodm9Mwpz0Ibt3wV6hFs0sWWibl4ai39e/iX0jB+6oiR/Gn9TJfrPTQC4dcCiH4tZFjkZQ== 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=0XqfiSKg39ndSnN6DpO8ObLRygWns2SrPtfou36eZxM=; b=Nt3MlfqUsjQQ6KvsfztxheXUmRYV1XQc/Gv0ghOvRNbZzn+iYA2Y+c1xTrlWZfzVJ1kXODd7BpiyHMM7pZ7kTGecEmJqs+y1lLM6bMLebqtTt38R47Y2b2+kACOLmgn3rttHnRhT1PWJChqMjx0OJzWQ7EISbxMnix6qS/pAfcIz7N97Itzfa9MQ6qKzB+SEp0mwC4ad2ScCcoDAO75AGStWpitwpXFItkxvpM+PEP9yCjoDegDy8kjdN9qZ7NPJWYT+qbi6UHOsbQE46hOjaLkCfuGfmLkAnLIMMnX+O4s/KahWNtzS8xvNG+bxW4kO3z0+3Ue9fNTJBhvGT1c3AA== 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=0XqfiSKg39ndSnN6DpO8ObLRygWns2SrPtfou36eZxM=; b=czPmi3XNuD/XXZR/cyQb7PPwtYJG9Z5zsnJ1T//gbJjdS9BKeMmGBLoyNZCtc4/WWLhDPuHbX2dXLrPOBhWCJ7wZbj2s85GZ5/CDB3VRgGQb6z3ihq5lSJS0Id1hLCPDtR5003Ft1oZkLym0C8ZMIkN34wAhR+Wsja87fI/fmYA= Received: from CH2PR07CA0008.namprd07.prod.outlook.com (2603:10b6:610:20::21) by SA1PR12MB6677.namprd12.prod.outlook.com (2603:10b6:806:250::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.30; Thu, 7 Nov 2024 06:03:47 +0000 Received: from CH2PEPF00000148.namprd02.prod.outlook.com (2603:10b6:610:20:cafe::41) by CH2PR07CA0008.outlook.office365.com (2603:10b6:610:20::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8137.19 via Frontend Transport; Thu, 7 Nov 2024 06:03: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 CH2PEPF00000148.mail.protection.outlook.com (10.167.244.105) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8137.17 via Frontend Transport; Thu, 7 Nov 2024 06:03: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; Thu, 7 Nov 2024 00:03:44 -0600 From: Mario Limonciello To: Hans de Goede , =?UTF-8?q?Ilpo=20J=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=20Kleine-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 v5 12/20] ACPI: platform_profile: Add profile attribute for class interface Date: Thu, 7 Nov 2024 00:02:46 -0600 Message-ID: <20241107060254.17615-13-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241107060254.17615-1-mario.limonciello@amd.com> References: <20241107060254.17615-1-mario.limonciello@amd.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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: CH2PEPF00000148:EE_|SA1PR12MB6677:EE_ X-MS-Office365-Filtering-Correlation-Id: 104e5c5b-4d52-4539-d8fd-08dcfef1f176 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: =?us-ascii?Q?H04FeNJN/hxjT5+xuSQE1Oxv9/DhQGnS9bNYNuFQ4mzksSjMcbTW9TRT48W4?= =?us-ascii?Q?po0Km9VJdMNulqmOgbJsGLnMkOBknQmxVsiDBOq4N3x1oCgyfSlIELKCNYHp?= =?us-ascii?Q?KCIM4ZNSZP8xdGrwdhC09/EvhsEpc0XbUP6gt7vUx+tSPvvbHAoYYoroZBNS?= =?us-ascii?Q?Tdsw8Hj4O5mbWJghs62Ifpho0pz5QU670HwjDuwm3dIFoFQ2XFE+Tcn4CPEp?= =?us-ascii?Q?AD9prGmdEiJd32mFr2dWUeTFDtkjT/dDGGmdkpMSIC0vJAJIarJORPnYjo9k?= =?us-ascii?Q?8bbukk4gZuEuKeVLHW4jDEfx51inzax66QjoTEZ/k45pSuyAQOOzp9UVslIA?= =?us-ascii?Q?8xc2hVpo+NDydnUumUtPaT1GDKNndB9TBvoKHg2Llh8SvlXgFLldtfwBfaGi?= =?us-ascii?Q?li7+/KzrnJaRsBR/XFuK5h/GpRP9/Er0FYq/BpSiX3vL1B+lPDKjUVZv2qVo?= =?us-ascii?Q?cxtDdDyL06sCE0JOXG3dknL1TAUqN32n2StZkEWL1UG8Rx3HbGp/XdL19A7Z?= =?us-ascii?Q?X6tqDckJANse0R58yGWRiXVWfGROp32QbAb+HuDoVJt8/WzLVa51LTxSUVIu?= =?us-ascii?Q?QtEiBKtmj3C7Fzbs5GwtQPoHSxh8sw45xdBGp8iEoUebmxu/Zm453yHn7h7G?= =?us-ascii?Q?jwmhTM1aUKMXdlINSfAPCIstYCNFnf7UdkWBJp4pm4XzkFyGsdheS1LRizwW?= =?us-ascii?Q?Cp8tjEP5FH7Vpe3PUtsC3lfoSc23UoDTnpbikZCrjCUdgeA9xe8xhtVsLr2O?= =?us-ascii?Q?dKTgHt0cWBxajDj/dYQyZwAUGcC1VGwCNpu42nPFJjPMUmdaacDX+rGPkYef?= =?us-ascii?Q?dIxWQoF0yRyCRYSpgIP9/X2EMueeD4YuVkEyr0cbfQKvQVK9GiEj4bM6kruC?= =?us-ascii?Q?QcrvpjZPjYfkOONJ7cVgA9vZ26w6zMdDweCoCRIgxQBZJGLOYK1Viz6/s0dE?= =?us-ascii?Q?uSo5Z8v+GGn7PPWdFF58VhHvJgmbd5/m99iXcgVyGIA3TNE0ocEjryFl1dXZ?= =?us-ascii?Q?2yz6bqKIXdPtDpyPFnMeu69DLUVQAC4Zq+NMkfYmCjhgqP8n/2Hxzj4TVT5p?= =?us-ascii?Q?2DvRagHsirvKAGXsOHTqdIvw7l9l0E1YA4JgV4c04xlflNpi0EHaayCylMuV?= =?us-ascii?Q?fQKLirtoI/D/bEnxEgbpYYjBx3iBDOYpVSZ9aRGGOOiZIUjTrwZ/IQiMPjIP?= =?us-ascii?Q?lJ2gStg66BArf/2e+isdvY+RptC2LKiolz1NLFvu3lfthEUWSswd4sXYJzpK?= =?us-ascii?Q?qEtryT3jFy1ewAMFyp57Pr0lJhJaShjpiGng26tFdp/HdNNI9zDZJeUOIDpf?= =?us-ascii?Q?aPkU23HRTAqRA22wkz8Hw28LZvCmrHRKcN3qjrlXQVjmkWTch3KZ03/F7fZo?= =?us-ascii?Q?/fZN06y3dui8z7vzDQbUldtTy79AsfpdpqApRcMbJhwWDcQyqg=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: 07 Nov 2024 06:03:46.9253 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 104e5c5b-4d52-4539-d8fd-08dcfef1f176 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: CH2PEPF00000148.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR12MB6677 Content-Type: text/plain; charset="utf-8" Reading and writing the `profile` sysfs file will use the callbacks for the platform profile handler to read or set the given profile. Tested-by: Mark Pearson Signed-off-by: Mario Limonciello --- v5: * Drop recovery flow * Don't get profile before setting (not needed) * Simplify casting for call to _store_class_profile() * Only notify legacy interface of changes * Adjust mutex use --- drivers/acpi/platform_profile.c | 110 ++++++++++++++++++++++++++++++++ 1 file changed, 110 insertions(+) diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profil= e.c index 5e0bb91c5f451..35e0e8f666072 100644 --- a/drivers/acpi/platform_profile.c +++ b/drivers/acpi/platform_profile.c @@ -65,6 +65,62 @@ static int _get_class_choices(struct device *dev, unsign= ed long *choices) return 0; } =20 +/** + * _store_class_profile - Set the profile for a class device + * @dev: The class device + * @data: The profile to set + */ +static int _store_class_profile(struct device *dev, void *data) +{ + struct platform_profile_handler *handler; + unsigned long choices; + int *i =3D (int *)data; + int err; + + err =3D _get_class_choices(dev, &choices); + if (err) + return err; + + lockdep_assert_held(&profile_lock); + if (!test_bit(*i, &choices)) + return -EOPNOTSUPP; + + handler =3D dev_get_drvdata(dev); + err =3D handler->profile_set(handler, *i); + if (err) + return err; + + 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; + + lockdep_assert_held(&profile_lock); + handler =3D dev_get_drvdata(dev); + err =3D 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 >=3D PLATFORM_PROFILE_LAST)) + return -EINVAL; + *profile =3D val; + + return 0; +} + /** * name_show - Show the name of the profile handler * @dev: The device @@ -106,12 +162,66 @@ static ssize_t choices_show(struct device *dev, return _commmon_choices_show(choices, buf); } =20 +/** + * 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 =3D PLATFORM_PROFILE_LAST; + int err; + + scoped_cond_guard(mutex_intr, return -ERESTARTSYS, &profile_lock) { + err =3D 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 =3D sysfs_match_string(profile_names, buf); + if (i < 0) + return -EINVAL; + + scoped_cond_guard(mutex_intr, return -ERESTARTSYS, &profile_lock) { + ret =3D _store_class_profile(dev, &i); + if (ret) + return ret; + } + + sysfs_notify(acpi_kobj, NULL, "platform_profile"); + + return count; +} + static DEVICE_ATTR_RO(name); static DEVICE_ATTR_RO(choices); +static DEVICE_ATTR_RW(profile); =20 static struct attribute *profile_attrs[] =3D { &dev_attr_name.attr, &dev_attr_choices.attr, + &dev_attr_profile.attr, NULL }; ATTRIBUTE_GROUPS(profile); --=20 2.43.0 From nobody Sun Nov 24 03:28:03 2024 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2076.outbound.protection.outlook.com [40.107.223.76]) (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 99C8B1DD0CD; Thu, 7 Nov 2024 06:03:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.223.76 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730959436; cv=fail; b=CjzorEdpzb5e8JG/Ayctd8S1lzoG/BP+UA6jUbYE16lvMeH5rOs8TQMT5Q4c5CppUTOOJlgXXtTgX97ujkWPA1Kk8ftjIIxFbl0naqxnHVGqOq8tGMdXnEhqmBnJCE3wTuT/jpLN8g2zY84d06aJVnwLTnvwr8aKQNDWzjzT1qo= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730959436; c=relaxed/simple; bh=ygdLyhxsL1E6CrOOFkf3Wil/fb1df9UANwK8eafvuvY=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Et5QoEMX5xj5Cu2essp4MKAlx5GzjE/Am6L7q5vCxshzRSZgjuxpOsaa4XPQqiGA4FBDGYFn584Pd2sCnI9SuuTZ1oJIzQuPC/cMKNpwcx/OgXETATMiLMev4DPwSZ6HX3sOImOSsrv7Tw5S32XzWxolRKX2uuazid7+eoVQhD4= 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=DTzrAPBZ; arc=fail smtp.client-ip=40.107.223.76 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="DTzrAPBZ" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=KXL1gWWOVhTnceKCf+EzUDom2145JrWiXq3dabjVFi0zdREDhXk0qrSzrXWXF/qYGKni3Ggh+Zupt9RVuEjAspLFVxLpxD0xy0iCy4vX49cG0nW9qOTe016ElC7hhB8HWjG8xerfoqeFwV4UAqL9USsOEEtT684ur3qI3ngoOrXN9rNy/an4oFaB6pp87Aq6TcsxLMu/DjN7fBMlsVt3XGwsCUiZ/2VjjF78udnA9o5iNi/gqVbdX+G9IXtvVr5HR+nwK4cQfuL+RTVB1ebpJ5Zibee0qoIvsF1I1Tg2zkiM2hkHlwoljSQwam9qDsI8lVGcXH1FK3sYOl1AoNRTIg== 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=pnoVOYlNJzRgfMoBu5KuIPp1sDfmHYMmm89hNzr+CpM=; b=fe8f55Ib2pPr6wKONaaujDp2k/clK7UU/44krhJdBoaIheZa2MJ0KvARjjLHDfMxuc7AG3R52KY/twfpz1cXD+z4nS2U6K81NYM/ay1kHVMIiCOz1xaFVgpx+K/F/vNhS6PVjbyTq3MoiEMMLKJSK3hp2mmfdvIJxRbsrWdnkqA+oGlBCs4lpbU4ItvLqb212VIV8PTdcnaSqtvEmufjNcFertWupXlXzNBKiFFfGjXtxtpa0mmxDJRa/uZu1Bn/8z7ULwlLV92zRGEfbXNaco0Psevbbz2dnCVbt73F8a/aRQbQV/qqYpj3PZ0SrUtXoV2aCWSl9HdJv0TTJQ24eQ== 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=pnoVOYlNJzRgfMoBu5KuIPp1sDfmHYMmm89hNzr+CpM=; b=DTzrAPBZ+ULPzxDBxZsYnbrXJ4qgNW/VTuQm/mVhI1PShL+grkFwce1Zuy0sDrYkCKvF2ozvza20MYOFsUUXXuAcotQnSGTJo2LGDC+tZiaDnNckqI5nd9YKw18BjYIAABf9nOY94CRWHTcCAfvWKJ7tVfH+yWVZbOOnuEDtqOw= Received: from CH5P221CA0011.NAMP221.PROD.OUTLOOK.COM (2603:10b6:610:1f2::21) by MW3PR12MB4428.namprd12.prod.outlook.com (2603:10b6:303:57::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8137.20; Thu, 7 Nov 2024 06:03:49 +0000 Received: from CH2PEPF00000143.namprd02.prod.outlook.com (2603:10b6:610:1f2:cafe::4f) by CH5P221CA0011.outlook.office365.com (2603:10b6:610:1f2::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8137.19 via Frontend Transport; Thu, 7 Nov 2024 06:03: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 CH2PEPF00000143.mail.protection.outlook.com (10.167.244.100) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8137.17 via Frontend Transport; Thu, 7 Nov 2024 06:03: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; Thu, 7 Nov 2024 00:03:46 -0600 From: Mario Limonciello To: Hans de Goede , =?UTF-8?q?Ilpo=20J=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=20Kleine-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 v5 13/20] ACPI: platform_profile: Notify change events on register and unregister Date: Thu, 7 Nov 2024 00:02:47 -0600 Message-ID: <20241107060254.17615-14-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241107060254.17615-1-mario.limonciello@amd.com> References: <20241107060254.17615-1-mario.limonciello@amd.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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: CH2PEPF00000143:EE_|MW3PR12MB4428:EE_ X-MS-Office365-Filtering-Correlation-Id: 5fbc2ddb-161e-441b-2df4-08dcfef1f2b4 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700013|1800799024|7416014|376014|82310400026; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?+sp6/TA46r8xwq6cFouHZxXimImlWxYlIUWC7WFkVcKa9F5y13h1/kUVg1su?= =?us-ascii?Q?I/cQ3m9KsYS/4VnjRh8MrBgcpXMNjW/ZQvL3BVd4CSPP/suzvA8WgP4DjNtS?= =?us-ascii?Q?CYtk43lg3L7K5vL3PPDEj7kuDpYvnvvyhrxIK9rFFhblmQKLEokAIjEn9Dl8?= =?us-ascii?Q?w3GcfmDvxwEJiuV9osWL88yLllzoAjlBl1oKmaVmqCZ+AGdiFo2nfnLZ8PrX?= =?us-ascii?Q?ich3Yv+kVS9e0Jwph9Pdndu05xgKAg+HFq5WOWPuQ18y4lXQ4+UZFQhmFCin?= =?us-ascii?Q?kap4AhM3gCtZ+jpB0VBfW5UQEBAfoaP2k35LnjDwHPb0oqUOuKpp7rt+7Kcw?= =?us-ascii?Q?vAOPVQSv0iIKh/urvphL8H1xVX6oaT44Efr2rahcBQmkHTgsCv34791RLXeK?= =?us-ascii?Q?pdQXblKKq7kwiy5Sk0cWyube9cloKXBYZciJMP38pZ/SAmjC5MAJGuKVBJAy?= =?us-ascii?Q?au9mMQMDp5s1JJwcnEIsq7nyJemQOpVZa8x1Ha4J1PR4wHUNFIJ2g7Ahr88D?= =?us-ascii?Q?qonUEzxioP7tiwBJLEctfaBf3YbBHuE4VgCH057otCSuhVSAd+HpZrUdyAPM?= =?us-ascii?Q?fY2DX4nzK4VrxntDSx0bYMcecIGQ6CRdHk+dpuX3z9SDBtI28p2X9xRaoIdE?= =?us-ascii?Q?mb7y9TDkQ09nC/FKhBjDyiXowmzKJX/dUCVsQdAwcZpbkGPghioLDkVLUJe5?= =?us-ascii?Q?k3j8RfKPN5nfIY5hm17Ka7mpb3CbzP5NDu/SR5wlqqSriML1XkuE+95NqLB1?= =?us-ascii?Q?5o0stDTjghpWDak+tIWI152Nf0esPivRvPV3pMe58hTWUO26ZXMky7aK1m8+?= =?us-ascii?Q?n41IH3/7bZb41aPHdTbchP9VbcxdZMzGXtnVau8KbikLrwq31bIHEP2A3oCM?= =?us-ascii?Q?gIoHcjMzPJTNnS9rV41Hn02VCiAm0AYbkp7TuYl74v4ofjwm4MqGi+7CZHAH?= =?us-ascii?Q?AIlxp//3Ahm0y0lQMmV8QOIR1He3JOzJsvr6+PllSo8ctF/a1dSLNI/6Ecx3?= =?us-ascii?Q?fbH3eCxa/pCfd8zw7uruv8/PZ4glJcU7Pb0BRuUlRuL/kiEBkIHfk7zgQNx3?= =?us-ascii?Q?kjQiYl7m9XnlZkZwUpETRSBMUuQiSLbEI9KxsuvRkXX165LEibF7yfpQbCk5?= =?us-ascii?Q?Ch1v9hwBTcEwfpaaXVzB6WaQo1ssZ0xEoFEAXUEuhMRiHUa5UBPhEKTW0meo?= =?us-ascii?Q?6B8JmxkOPS2wU7J+2A5ES54sMt5Bd7jxaYyM6OvMS+blqEdZlnVzJksms0PB?= =?us-ascii?Q?hY4cpO5Z47dEINTMEfd1lQMZB5zVbNYLZecSVVWuetvzGT8CDgrDKgohxHJz?= =?us-ascii?Q?zPghx997HqE5IRnyur95vVzUdKZieYqE8LLMJ9mFENffYhZnhC40K8NQpyCl?= =?us-ascii?Q?gGjgWjZuHbl0rQGozMpIzhKrpQwlvVH5cSm0DPXte2/IPt6Jmw=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)(1800799024)(7416014)(376014)(82310400026);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Nov 2024 06:03:49.0360 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 5fbc2ddb-161e-441b-2df4-08dcfef1f2b4 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: CH2PEPF00000143.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW3PR12MB4428 Content-Type: text/plain; charset="utf-8" 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: Mark Pearson Tested-by: Matthew Schwartz Reviewed-by: Mark Pearson Signed-off-by: Mario Limonciello --- drivers/acpi/platform_profile.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profil= e.c index 35e0e8f666072..510e1435d3980 100644 --- a/drivers/acpi/platform_profile.c +++ b/drivers/acpi/platform_profile.c @@ -399,6 +399,8 @@ int platform_profile_register(struct platform_profile_h= andler *pprof) } dev_set_drvdata(pprof->class_dev, pprof); =20 + sysfs_notify(acpi_kobj, NULL, "platform_profile"); + cur_profile =3D pprof; return 0; =20 @@ -421,6 +423,8 @@ int platform_profile_remove(struct platform_profile_han= dler *pprof) device_unregister(pprof->class_dev); ida_free(&platform_profile_ida, id); =20 + sysfs_notify(acpi_kobj, NULL, "platform_profile"); + cur_profile =3D NULL; return 0; } --=20 2.43.0 From nobody Sun Nov 24 03:28:03 2024 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2072.outbound.protection.outlook.com [40.107.237.72]) (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 0C27A1DD525; Thu, 7 Nov 2024 06:03:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.237.72 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730959436; cv=fail; b=XpMOKZ+C4KWcs+emPaMnLilWVItYevmyOB1bac2ngQShm4rahy9i13uKNc8dFBpdmz8/S/feyN0li+zn+mSb/XhrANTElruJRf+CILj14yOqBF0UTCfUL60c8C23cTnXtzZmm121mllGVV64VJgmJ92ZBpyF8mLVIMFdZ2Sbqd8= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730959436; c=relaxed/simple; bh=CTLNKCXi/cTsX4LriEwKBmAvKy6FoN1XxY8tEauqe5c=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=BCe3Y6hleGsWHiiMkZlFB81jS6DlFffOwN9+wnMtRh+N/vvpX0+Q9m1Ln7fuQcwLNwTOoR5kKujJwOKPVF0C+qlFCtsFYcKORPTlj7YL9i9giYNSIFOQMFetqNDSHTzZ0pJozHSaGStj9SGV3QnXLxRa/xxX2CHxWflx8cI0rC8= 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=D8WKsheZ; arc=fail smtp.client-ip=40.107.237.72 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="D8WKsheZ" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=OdL1Knf0UGpiuc7UzbfzFYNboJw3VQxlEUjAqaKS1VLEl6KDnriNgGna/gJkxbFhFZLQceBRXFSmIO+2B9PKY+aZmOJYXVrixupINlJpWRkBx8uDZ+SK0uOD0ueWUUrN7cWARzoL271fc32Ewwv7jtQ0cEZILja6yeq5XVrQzHyTSUrHmU0bJSMmcnASF/D9Ppi9fPw13Zct+/bwPn4CRr6IR6o6hPb/0mGX1RsKkPXGZvXobw85thc4MDkRmpidMyqIkmxb4I9h7J0ZlHxVh7MfRicZJ2ZlKlRtLQ8OcA0W7gMH4bL/6skJ8MZTO3CPXa6/fyLdxTchCqOO7u0JjQ== 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=Ef2WNmNYKfJfZZJpNE5oKPFeLWiXbAbe7aodPN6BEec=; b=EBJTBXOC/dBeGCmTrN+0aphuym1RfnwrHyTXg346BKknl3CyTRKaHiKVCZVjhyrXnCelYQ/AnG9nPicQOCUDEPDTAEjIMsAkr3DdKv05eJG3J0Dd4tsqyKIPsk3oFID0rCMdhWZza/FuDxXn3Zp5ZC5JEg4wuuQdB2bwAo1WDPxoQEIe0ZBWoZwQtyXbq2ayqafry2+Adf+duRhmOBfU2fqn7AoexpyOD6Nby1zx+iSZXOZzsoISadklZvUtYZLr3U+ym8c+gRQrAoF1nkz4+jA/uqzROOu/d+JjLW2yKXqJd8V/YRIyMQZwp38UFfGT2OvRwfCW+jcbOsXuvKjwsA== 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=Ef2WNmNYKfJfZZJpNE5oKPFeLWiXbAbe7aodPN6BEec=; b=D8WKsheZNSMTu7ntmhdrQCJcXWBy2ZlHiwxRNSPIh8rgGmMp4mCBXw1PMa8dT5qd1WUgB9HnNIk2brU6BjbquUON5nNRpV4HP9wOP1fgKZWL9oHo0QJ5fBBIAFQb0+2L3cU3mM9aFUABu4D9D/DNHn+eJTnC2/T4ZIX6ql8Qr9Q= Received: from CH5P221CA0024.NAMP221.PROD.OUTLOOK.COM (2603:10b6:610:1f2::18) by SN7PR12MB8130.namprd12.prod.outlook.com (2603:10b6:806:32e::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8137.19; Thu, 7 Nov 2024 06:03:52 +0000 Received: from CH2PEPF00000143.namprd02.prod.outlook.com (2603:10b6:610:1f2:cafe::17) by CH5P221CA0024.outlook.office365.com (2603:10b6:610:1f2::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8137.19 via Frontend Transport; Thu, 7 Nov 2024 06:03:52 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by CH2PEPF00000143.mail.protection.outlook.com (10.167.244.100) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8137.17 via Frontend Transport; Thu, 7 Nov 2024 06:03:52 +0000 Received: from AUS-P9-MLIMONCI.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Thu, 7 Nov 2024 00:03:48 -0600 From: Mario Limonciello To: Hans de Goede , =?UTF-8?q?Ilpo=20J=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=20Kleine-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 v5 14/20] ACPI: platform_profile: Only show profiles common for all handlers Date: Thu, 7 Nov 2024 00:02:48 -0600 Message-ID: <20241107060254.17615-15-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241107060254.17615-1-mario.limonciello@amd.com> References: <20241107060254.17615-1-mario.limonciello@amd.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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: CH2PEPF00000143:EE_|SN7PR12MB8130:EE_ X-MS-Office365-Filtering-Correlation-Id: 40b61abe-03ec-4110-c9d8-08dcfef1f476 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|82310400026|1800799024|36860700013|376014|7416014; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?53lHTZo8s/T29HjqZxqr2mzb11uv4fTAjocPEKBfpnZWnICJ3ADG+krNYcw2?= =?us-ascii?Q?0d6Sq3BIw807iIMH1UFleTjijEMPwjBJOML8qtGzWEV5Tux1wMJcwTCBUeYs?= =?us-ascii?Q?igSfMv0UgOy6cyVLRDB9yh3/zVvcA/A1pSzZ7GsLvGVrttLXYgykJNeTAbdi?= =?us-ascii?Q?3m/bK6VLlLcIS1IQ13R1NInBzWEEFPcoYnpnXm7hIuRG+H/A7fqb1CPwkh0C?= =?us-ascii?Q?ZR9/EICVARjRxR4dJOmtzQgfJK1WAkGShjYJiFBn9stCXV+9xG8uKz41c53S?= =?us-ascii?Q?jlwJf2/VWL/GlvA6guxUPMjFsyx//8KObX11jrr1iXfibZyzI8oUqL1rsGIU?= =?us-ascii?Q?oECJRi6XSLe0ZBJQpQE8I77RolpQ/OOxP3jbQKwg9yskn/km4pYyGqVtq+g7?= =?us-ascii?Q?pTk0csfz4AZkZRQ6OLOAJHOlpC3ppJb5R8rFZGWAzJjM7UDqkt2D8WDuaSJ9?= =?us-ascii?Q?8JmdwcBDPJUHiGgULL7oQTo3I1zgFQVbpQ9VYtH+R4bVk45kQTlqxSWSI8qZ?= =?us-ascii?Q?P65Q1fA2hXLOn1kcWavxjLr+iW+aZRX3Ten6YWDu2GDpcPAhH9kLkryyrtu0?= =?us-ascii?Q?glFc/Q9BwMUNelmWfklyQdMdMRRL/c61zBCHkxAmjda6OybE8MLl6qjTNmUn?= =?us-ascii?Q?iojGgcHu3W1+HbdGnEeMgK2EKvudf2NrQzHbdpVY64tU4FGTHTb7f8Hkqc7j?= =?us-ascii?Q?mDg3VIskZX4+aoVHbkGrEsJr7wzM8aeZDCe1/xyi31ugTBKOilWAXyZjRsiE?= =?us-ascii?Q?WssGpblMkL0njoW3xZXwoAy2TQoblBF3NXsmmBq0+jcaM1QRPn2NVQzLmLDV?= =?us-ascii?Q?23zbuFKn0+uY7hQ1vv1OwpHtX3PGfmKTfz5MP+6OBhZeRuRjAneg6CXOEMSI?= =?us-ascii?Q?mALJwTgGE9VE+DvyrTwhyvM6ot3/iZCgQhPlktf+Q15RDdEkqLunDo8qywod?= =?us-ascii?Q?4AvoZ8sr41tLUo7uyGKIs6XpgmDnaTHm7p7AK+39g1pA7N1+pkn/4FNYYJOR?= =?us-ascii?Q?x+3YiugB1E4QIu0ptJ1XycoLbfcazT7ItUM3Q0Pp1NukmcK6QSn5UOd3UEUL?= =?us-ascii?Q?uUmrO0Le7mhkBA8ruR7Z0GhI4jrC3dAsxmCFrsCDOWPTzuq/yo0yNiSQC/NB?= =?us-ascii?Q?QJALYQ957UaoRqSfy/AB1F1zLbDFjac+stivSpy/vVq3ckfzDb3ou+hcNfVR?= =?us-ascii?Q?gIVyKaTIt3NKPGk3b2XxvkBR1Xsis82dqBhcZHgYyKn7/gTkHD88XdO5pAz/?= =?us-ascii?Q?9klHuSaNY9b0kA9+/WFjKxF7731W99cZfwrihRt1UTVz9+GxTubazBVB56BR?= =?us-ascii?Q?qnMZIk31z0CK4Lic10csQT2VIPhLX/TtoteaQQZvRvcuC4tL6ErIqSRs59TF?= =?us-ascii?Q?L1ZKtAQwqSql/372KF3JJMRP2Tt/CNtIe9uWfElK6ZFMmeXUkg=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)(82310400026)(1800799024)(36860700013)(376014)(7416014);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Nov 2024 06:03:52.0360 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 40b61abe-03ec-4110-c9d8-08dcfef1f476 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: CH2PEPF00000143.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR12MB8130 Content-Type: text/plain; charset="utf-8" If multiple platform profile handlers have been registered, don't allow switching to profiles unique to only one handler. Tested-by: Mark Pearson Tested-by: Matthew Schwartz Signed-off-by: Mario Limonciello --- v5: * adjust mutex use --- drivers/acpi/platform_profile.c | 59 ++++++++++++++++++++++++--------- 1 file changed, 44 insertions(+), 15 deletions(-) diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profil= e.c index 510e1435d3980..2ae0437623abb 100644 --- a/drivers/acpi/platform_profile.c +++ b/drivers/acpi/platform_profile.c @@ -231,27 +231,56 @@ static const struct class platform_profile_class =3D { .dev_groups =3D profile_groups, }; =20 +/** + * _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) +{ + unsigned long *aggregate =3D data; + unsigned long choices =3D 0; + int err; + + err =3D _get_class_choices(dev, &choices); + if (err) + return err; + + if (!*aggregate) + *aggregate =3D choices; + else + *aggregate &=3D choices; + + return 0; +} + +/** + * platform_profile_choices_show - Show the available profile choices for = legacy sysfs interface + * @dev: The device + * @attr: The attribute + * @buf: The buffer to write to + * Return: The number of bytes written + */ static ssize_t platform_profile_choices_show(struct device *dev, - struct device_attribute *attr, - char *buf) + struct device_attribute *attr, + char *buf) { - int len =3D 0; - int i; + unsigned long aggregate =3D 0; + int err; =20 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 =3D=3D 0) - len +=3D sysfs_emit_at(buf, len, "%s", profile_names[i]); - else - len +=3D sysfs_emit_at(buf, len, " %s", profile_names[i]); - } + err =3D class_for_each_device(&platform_profile_class, NULL, + &aggregate, _aggregate_choices); + if (err) + return err; } - len +=3D sysfs_emit_at(buf, len, "\n"); =20 - return len; + /* no profile handler registered any more */ + if (!aggregate) + return -EINVAL; + + return _commmon_choices_show(aggregate, buf); } =20 static ssize_t platform_profile_show(struct device *dev, --=20 2.43.0 From nobody Sun Nov 24 03:28:03 2024 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2064.outbound.protection.outlook.com [40.107.223.64]) (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 451A01DDC06; Thu, 7 Nov 2024 06:03:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.223.64 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730959437; cv=fail; b=HclJE0ASD7ccp8d232wIMpnrXvVvetko73xXYAXDCtpqNN9UC+eUy0QSc9DykIVfpPrm191lU4oYJBWCkeSTxd0NZyT1CmP4oFBG1K/MlsBRMmswT2n4DpkBqeBaig8H2V+FJXKZH4W4e2WLAi+IFz/zlcT07TkLdHzItgo9BQw= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730959437; c=relaxed/simple; bh=0CE18Owe0jR089hDMR68XR0Uui1Chr7ms5oQtc9in54=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=ePsKmVw4MAx//7ZohNZ7CftLjwYNugXoV89g7yPUUDzIc75JZ5jQs+Zq6/TgbMhpOSiwx8alb5plB10HbTc06Piazed2KGOYRp+OIog3Vl6pnu9VAb6tiWAA2/IU4drmTkxrYrixEVKI/mTJvMovk7Ih0oNcBdltY48kJN2w1C0= 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=3bvoru3X; arc=fail smtp.client-ip=40.107.223.64 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="3bvoru3X" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=ikyobXq+DJSagPh6JbiR5TesvaisuOAtXnlCMlo+wYAkZ6d1zKgVzZ+wBZmu78FnUfR/6MRE6O+ZS5Aurm/M85HtSEM/XAPwXdv1KiQsGl1DadFzYfPEtxNcKHYyghHrt2+IyyM1ERN+x1XPyXGFnP4b+kCz2pHZSjjHlGJpmnNrD1zRtRQVnA71l9MafdOq8N3gFMnY8NFQUhhC+B7hhsSvYNS3+vqI5RZAsfkW+SqAUNxh4z5sDvvjFS6Hf8Zg227+WipjECYDh42dYJxd3TWMgA969oBdQbX8RLPckvYeb64pYuunIF7GyaZihNoB0P5HRY4MdByVdMkN5a2kZA== 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=sNjdOm1VjUvCTcCTPQGwwS/qIN8336LW0MbHgOASTXU=; b=zOA+nqbslJRzTxau9GIc341ruMDRUmWl7fvGcyziRoIRFc5gewg3Exg3PEJsWGcI6Qql+fnKgPrAwZG2hsvpVv7k3ZJR9NTPM4mRBv3utaBCUAv61LU6B5fTtUzbQDYx5HZYqWF7u5hC1egVrlB12af5Fz++81UPQo/S45bRcz3G8l4D9na4poEGzCItknKBVQCeD7QSOzJPEUj58LOtg1MC3DXBaGWqdgcxct2mETGWPdtK1AS3yeOtsTofnBbI3dlx97SuUrMZHRBjGIXG3/oRa06Eaqyal0Jdrax5BXj+JYISJEBpyITaDc6fgWAiQFQDndaOPM8pLzbHca7uVg== 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=sNjdOm1VjUvCTcCTPQGwwS/qIN8336LW0MbHgOASTXU=; b=3bvoru3XLelmXIqgaZaScQ7uN0KV+JEhVDUB5wxbccJg3k7BUsX+yAC3zJVpnriZmwRQ7pnXYQKXQPUWhoDhHBNSz7NOWwA9Ul871TIpo9jDXYWDgls4DPmZfoCl5+ILYM5e4UErzaEpsiaIEFD62ZMIM8f6F22UN2XYesp9JAw= Received: from CH5P221CA0009.NAMP221.PROD.OUTLOOK.COM (2603:10b6:610:1f2::14) by DS0PR12MB8218.namprd12.prod.outlook.com (2603:10b6:8:f2::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8137.20; Thu, 7 Nov 2024 06:03:52 +0000 Received: from CH2PEPF00000143.namprd02.prod.outlook.com (2603:10b6:610:1f2:cafe::63) by CH5P221CA0009.outlook.office365.com (2603:10b6:610:1f2::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8137.19 via Frontend Transport; Thu, 7 Nov 2024 06:03:52 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by CH2PEPF00000143.mail.protection.outlook.com (10.167.244.100) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8137.17 via Frontend Transport; Thu, 7 Nov 2024 06:03:52 +0000 Received: from AUS-P9-MLIMONCI.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Thu, 7 Nov 2024 00:03:50 -0600 From: Mario Limonciello To: Hans de Goede , =?UTF-8?q?Ilpo=20J=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=20Kleine-K=C3=B6nig?= , Ai Chao , Gergo Koteles , open list , "open list:ACPI" , "open list:MICROSOFT SURFACE PLATFORM PROFILE DRIVER" , "open list:THINKPAD ACPI EXTRAS DRIVER" , Mark Pearson , Matthew Schwartz , Mario Limonciello , Armin Wolf Subject: [PATCH v5 15/20] ACPI: platform_profile: Add concept of a "custom" profile Date: Thu, 7 Nov 2024 00:02:49 -0600 Message-ID: <20241107060254.17615-16-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241107060254.17615-1-mario.limonciello@amd.com> References: <20241107060254.17615-1-mario.limonciello@amd.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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: CH2PEPF00000143:EE_|DS0PR12MB8218:EE_ X-MS-Office365-Filtering-Correlation-Id: 0cdce361-5eb2-4b54-b141-08dcfef1f4df X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|82310400026|1800799024|36860700013|7416014|376014; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?mymcLN+Jn6sTmUkjoyPP+z6RZjPKOgzl5IWjtE3XPwWXnfDHb12Bw9+zREEo?= =?us-ascii?Q?Lwn87StmWfEyCEHHZM6l3+lskVDTFfi/V/0rs60BzTU1PcLRSwUztJ44d0is?= =?us-ascii?Q?FmHAwNfxK+bMSkKWJarLFg9EIHVMasDHSNCfuaeBXvYWy6JiSBUSmyiiB3Kr?= =?us-ascii?Q?tCl3X1lWhfY+OO0F0+x0GlS3k4WTRHCwGnPXxlO7ARwbxY8rTRNQ6w70opJW?= =?us-ascii?Q?DeMy02SM8Q5WBEi9aK6sWq+UVfgciW5nZpjf7AVaiCLXl51vbWd4ooO4MATA?= =?us-ascii?Q?5on2SDEYP5BaRe3Yw8eaYQBI747pX30u/voYaNsXwkboboXglbN42xO7kGSJ?= =?us-ascii?Q?QpDkaNiwRr7FrQD7KPf4at0+0OZN4Gvf0O9JUHzbdyubu/aIe48eLPp5Qw5s?= =?us-ascii?Q?hBukPAU/rOTc+6hL1z5TI01x9dQGDpqZUklnMi1xUomtACpSVSwzW2gXK6p6?= =?us-ascii?Q?G+qZPnEitkPk/JpcB8nddcttPnb8WfQB21vt1nZgzyB5o3+xP6OQSz0DJdIs?= =?us-ascii?Q?tFqXe7JP6R1xLgaMU5FokaYGA4cc30ZrX2ltX6H5PJOb7l6IWzYnZAKITaoA?= =?us-ascii?Q?W1rr/1I/Z7uSHvU2JCZxhsJATN2Tsf8H5zOdPf4wlyJuMUocKWL0IMCK44qE?= =?us-ascii?Q?FBfqK1xdMm5fWXrR1O7hzPpnhrN6ePuo0cMsday8dgQkqZRbNuA6V9d8mWcy?= =?us-ascii?Q?qfEFB+fSdCBUG/cD6UkqOs3qn5jeBAdCsjrir2o4mMJxxJ/gq4wlMjW7W1Ep?= =?us-ascii?Q?RhsSVmjVD8Q7X0Zh8hvVJPtrAzSieCqMDbEgTph4lbL06z0UsAoMAi1C1pyP?= =?us-ascii?Q?BZfKsk5mVmrAeL+Zb/FRpCNG9BTGC9Iw1nVzkXIH3BFK4l+3mGBM+lKtAvmg?= =?us-ascii?Q?psJ7aFT+nKcawWvqEILUhn4sjEBx36KbWF5sx2yn0wdtWnP/RkSbSBZ4zVgh?= =?us-ascii?Q?b8eCCvFEp7dGf0Uvzdzf5btJjjfs3Zce7rmJxfPw+urreE4u2YHIjdVC+i0P?= =?us-ascii?Q?VQsWfMUjed2d+jDEMVhBwc/Qtyil1WOHxOCtfAe3PmeqEZvsW5mgfotFNViN?= =?us-ascii?Q?ypFa0WZ8UF+Hfqww18A1jM345xOoetPp8IaAxyt3IfQiUcQkNd8SknKpF1OH?= =?us-ascii?Q?NFDMSD2KdWXkkwly3c67kmIIUvXcJyryFYdyqJGgp+PBVIE3IQcmKde1EbQT?= =?us-ascii?Q?gg7qSCFuT2BVDgucpITVdTJSoiTygn8GuGX5vvmW7G0ie8NTirpiGw2z1XSt?= =?us-ascii?Q?ncX2aZvbfQnemjSAKTBqdLf7vILTQe0wBCWSx8smN3E0TlvYRa6IYg3JDyNR?= =?us-ascii?Q?fcP9ZLtfoG6SE3BbeK4TtjRhA5UtIwpe6TmxZw5wmlnbBqH5sN5TzUXl2rYm?= =?us-ascii?Q?r/JzDglyIkw0t1jw+zuNgE8m84rYRjzxEyuEvmeuG/Q5eXTIqg=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)(82310400026)(1800799024)(36860700013)(7416014)(376014);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Nov 2024 06:03:52.6766 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 0cdce361-5eb2-4b54-b141-08dcfef1f4df 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: CH2PEPF00000143.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR12MB8218 Content-Type: text/plain; charset="utf-8" When two profile handlers don't agree on the current profile it's ambiguous what to show to the legacy sysfs interface. Add a "custom" profile string that userspace will be able to distinguish this situation when using the legacy sysfs interface. Reviewed-by: Armin Wolf Tested-by: Mark Pearson Reviewed-by: Mark Pearson Signed-off-by: Mario Limonciello --- drivers/acpi/platform_profile.c | 1 + include/linux/platform_profile.h | 1 + 2 files changed, 2 insertions(+) diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profil= e.c index 2ae0437623abb..b6f3388b4eef9 100644 --- a/drivers/acpi/platform_profile.c +++ b/drivers/acpi/platform_profile.c @@ -20,6 +20,7 @@ static const char * const profile_names[] =3D { [PLATFORM_PROFILE_BALANCED] =3D "balanced", [PLATFORM_PROFILE_BALANCED_PERFORMANCE] =3D "balanced-performance", [PLATFORM_PROFILE_PERFORMANCE] =3D "performance", + [PLATFORM_PROFILE_CUSTOM] =3D "custom", }; static_assert(ARRAY_SIZE(profile_names) =3D=3D PLATFORM_PROFILE_LAST); =20 diff --git a/include/linux/platform_profile.h b/include/linux/platform_prof= ile.h index d92a035e6ba6a..07807c93fde74 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 */ }; =20 --=20 2.43.0 From nobody Sun Nov 24 03:28:03 2024 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2048.outbound.protection.outlook.com [40.107.243.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5978E1DE88E; Thu, 7 Nov 2024 06:03:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.243.48 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730959439; cv=fail; b=bX8E2QYUc5cQg+oiQ3QvtqKo4o+dhEA+lXG220g26f9j1mWQwTEJdmQUpq+loKJP9I4MwOw4nQAcnGpxfMmUHRlBgSj+KOcoPVJSGy+7ujaIwdMzhFps2FTliI4VYm0Ac9pBNS5T/Pkm2OaYSDjUCCVODTrGxXNhRDpZNfJDGqo= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730959439; c=relaxed/simple; bh=K4AoFKCAu4P4SG3vzBedERFkMX9Pcihfe2eS1/CifE4=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=AzI+4PMW1I5FvQsTo3j2Tb/2jPaP6Y6K0AThDScbDU9S5Sx3U6VQWx2j8iIL/oCfQ8cURFpVi7K56c4yhePbRfHt8B10xdJTe0rT6EtPTbXOmEmBHSbiKZS3SJ7XUZpPuYWcY/uiN6AFRy+Kr7rtInuwMESmwvnUwX+HnBLVQrs= 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=j1wP7RA0; arc=fail smtp.client-ip=40.107.243.48 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="j1wP7RA0" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=PI5lWuG5KV2y2nYMEUyLFKh9QwtM02IEiDlrF2ovyS4ZUxUuYngtd7mR7IXJ55Tdd4h4XnkhsIbaVed3Z7rT1SBCT3r5n4jG9S2NGASt/7Tk/gy6k44IXdL+GbPjBv/9vLp6Q1ZPGDQbya1uREJrJ5K9EHWXDsLBBREva/oW2AdbavbpwH5iywi56mZII1E31Z3IbTA6eTREEZuL6HutAUidyr1bKiSDvEQVMrEM9CJtV893tjEPi/El0ttWTGey9HmTrXkjqmnoch0r+EVusK0Hem768voj7NrERi+51MOlmGoEyI1l6ixdwB5J6kb33d6bnu/0xkiPTgtTZfbRrA== 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=TyKpeqW3CvjjNWY5ZB9puuXGNn8a3q2KFzVzT6du1aE=; b=uVyEvqw8RtD9/bXxmxHsW/Ci/aHbeLv83wUqU4aLHX8szZUa3LYi/Wb/yvoDdPvau+SUfzE0zvgbcdwbFKDSRqrQl4GRyIpzgnPOMBOI6+t28IAiwbVLeYjAfkd0ySn67reFWA8dD3YRp0xCEgaOtOlkzDz/M28AykWGM7LGpa3rDw77S04vbnpsZ0fwXm8NgHbSC6IuYuxSrmrnYPTDRoO/8IgIs27EBw/OXK8BYYbkIEQymRpbdqhv0xiEfkvrSRZJtZas+NxA5ZAqSB9SGPAliIHYCEntayyV5JH/FcaYZdgEVASvCDQLq5cYpr2o9SuXuOTsji6cYQDDqP/9LQ== 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=TyKpeqW3CvjjNWY5ZB9puuXGNn8a3q2KFzVzT6du1aE=; b=j1wP7RA0+MhvNDlL7jO1GwSUUMSAks3TneVzzIbexVS+MQi/KkKO27/Q1115OA3Kpy1IBlaNUGktxCZCIs5WWlPCSIZsZe9BtC6p/Mihx684AN9mX8p9yoUuTZBAF9xTxNABYmZQROi2epwPKwRfinZExnILWprydhasl1uUidE= Received: from CH5P220CA0013.NAMP220.PROD.OUTLOOK.COM (2603:10b6:610:1ef::27) by IA1PR12MB7760.namprd12.prod.outlook.com (2603:10b6:208:418::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8137.20; Thu, 7 Nov 2024 06:03:54 +0000 Received: from CH2PEPF00000145.namprd02.prod.outlook.com (2603:10b6:610:1ef:cafe::de) by CH5P220CA0013.outlook.office365.com (2603:10b6:610:1ef::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8137.19 via Frontend Transport; Thu, 7 Nov 2024 06:03:54 +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 CH2PEPF00000145.mail.protection.outlook.com (10.167.244.102) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8137.17 via Frontend Transport; Thu, 7 Nov 2024 06:03:54 +0000 Received: from AUS-P9-MLIMONCI.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Thu, 7 Nov 2024 00:03:51 -0600 From: Mario Limonciello To: Hans de Goede , =?UTF-8?q?Ilpo=20J=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=20Kleine-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 v5 16/20] ACPI: platform_profile: Make sure all profile handlers agree on profile Date: Thu, 7 Nov 2024 00:02:50 -0600 Message-ID: <20241107060254.17615-17-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241107060254.17615-1-mario.limonciello@amd.com> References: <20241107060254.17615-1-mario.limonciello@amd.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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: CH2PEPF00000145:EE_|IA1PR12MB7760:EE_ X-MS-Office365-Filtering-Correlation-Id: 331b0c0d-ddf3-4026-3e92-08dcfef1f5a5 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: =?us-ascii?Q?s+t+UQnKNiQldBB0elpVKLmAbQzCO2NJE9j8BOAUEbV83bTCUT/eoxvh+w+G?= =?us-ascii?Q?dv5F8e3V96egCw0+xsRXTrNDyXhzEn5e7ofTSSt3asx0bKcjHHDv0Vz3Y8bK?= =?us-ascii?Q?lpSjuongm9d14swE4pRHGKaqCG7iPpAgIXvNgPfEZJ1NDDHSUoDJQV45i9VY?= =?us-ascii?Q?nRu+pdJTsDxW7lPnHzwIzF08CcC8+1vt5dvM6DWadOb6j/kOQ9KwCJhGi8ip?= =?us-ascii?Q?S6uPL56vjRfQKoB0Fmpvj/Tjdwc/VY98oYLQH4HKk2vfzTVb1pdDUHlSJAJV?= =?us-ascii?Q?f6J8/lx7yW0mHRzFl7xD2f2pq2xPONByfIusBR6kLvtULbhHxFVxHfmxlsQV?= =?us-ascii?Q?aNj+dQiysIZySIGurBf53Akm/JeyJ/kEJkDLmEfCfG4OYJQXZT07CJN+4ZUt?= =?us-ascii?Q?gWLoc6VfEGlum7q11V5i7byyYoeFWd1qREjNf7wOBgKfq1hEOMJgg5ECDWTd?= =?us-ascii?Q?n815xRLCVROKRJMahbVk4ryTtRvnzRsNVwJUZ0WihpQNREEEWHW9uHTXBzhJ?= =?us-ascii?Q?9Cp0jWgu/eMJEVsHVQeA3IsqHbhIS04aBorJ9WzpU1lGrE2C0DMguB8baZOB?= =?us-ascii?Q?8TRjLzTDdbdvNklA03qvweYD4Xv22fff+X0MyVDbrz5mM+SngLJcYk3hJjOF?= =?us-ascii?Q?GjrY6nfYBVQ6ZpugU2Vva1YYVO/iRexdW/Z7XUjxfd/8Js+uLap0gNm79yki?= =?us-ascii?Q?1hQDhvNklAOHJOwReajoM5+XBJAMpIuW9easmmYCosKD7NP3XJGanZoPQOV5?= =?us-ascii?Q?Hc1Qqaz+bmWtd94GcI4GoE7uRAQOWxIuMFIba5u/Upy7nq4Zvzp1O6VTaNVx?= =?us-ascii?Q?FzR12lv5Xui3RhlXJAlvKHdAXIJv3sbKStUcvhmDrSNzSQ4wMig1nujKoWro?= =?us-ascii?Q?lMvpD9BgjO+OcuX7C4SXRsRbh6PBEOsbwB/XRnJFlHM7KYFSBJgvLxv6du86?= =?us-ascii?Q?mIvSJLSvmroRFL48M4kqBfO/8qak4MRwO2hSz5KYAHd0EzJcR6Bwm+kS6h9b?= =?us-ascii?Q?yjv9yfPezaexeSomNKfLC8+o5EsGBm60wy8XCjZF4u1nAruc18rxlQoGtNJW?= =?us-ascii?Q?ydJZ3ItFWzpQFedAvJc1nZmezMWGCQWxG/FkbbmA4FuVmKCDhA0+lqZYF+Km?= =?us-ascii?Q?IuwgQljvLCZ+Ar92gD+hLEZir0ozlecVSJe63OoOy7wGd96hvlirXHUETMcB?= =?us-ascii?Q?sLqwd6LjxkLNRwuI6zO1Xi0HXGgbDxS+wi5kaQJaxROuXlehDGA6Y3eSocMv?= =?us-ascii?Q?7jU/KdpXo92lXhjsUvJsQZ8GB+ZrLhAIPEpu2YIjXuGM2cxYDRs3jGy4ErGb?= =?us-ascii?Q?Jhqps7kclKzsGCjcsrFKyN1cmPb1Nq09Ascw+1LTOWd0fPm5JzDXJOgaTeB1?= =?us-ascii?Q?zrYU8+ANXZCNn4Ruliv74CFi+QyCYVhYX2a7n/n9UBCe09l8RQ=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: 07 Nov 2024 06:03:54.0182 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 331b0c0d-ddf3-4026-3e92-08dcfef1f5a5 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: CH2PEPF00000145.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR12MB7760 Content-Type: text/plain; charset="utf-8" If for any reason multiple profile handlers don't agree on the profile return the custom profile. Tested-by: Mark Pearson Reviewed-by: Mark Pearson Signed-off-by: Mario Limonciello --- v5: * Notify class profile of change to legacy interface * Don't show warning when writing custom string, document in last patch instead. * Adjust mutex use --- drivers/acpi/platform_profile.c | 101 ++++++++++++++++++++++++-------- 1 file changed, 76 insertions(+), 25 deletions(-) diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profil= e.c index b6f3388b4eef9..7f302ac4d3779 100644 --- a/drivers/acpi/platform_profile.c +++ b/drivers/acpi/platform_profile.c @@ -94,6 +94,22 @@ static int _store_class_profile(struct device *dev, void= *data) return err ? err : 0; } =20 +/** + * _notify_class_profile - Notify the class device of a profile change + * @dev: The class device + * @data: Unused + */ +static int _notify_class_profile(struct device *dev, void *data) +{ + struct platform_profile_handler *handler =3D dev_get_drvdata(dev); + + lockdep_assert_held(&profile_lock); + sysfs_notify(&handler->class_dev->kobj, NULL, "platform_profile"); + kobject_uevent(&handler->class_dev->kobj, KOBJ_CHANGE); + + return 0; +} + /** * get_class_profile - Show the current profile for a class device * @dev: The class device @@ -284,54 +300,89 @@ static ssize_t platform_profile_choices_show(struct d= evice *dev, return _commmon_choices_show(aggregate, buf); } =20 +/** + * _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 =3D data; + enum platform_profile_option val; + int err; + + err =3D get_class_profile(dev, &val); + if (err) + return err; + + if (*profile !=3D PLATFORM_PROFILE_LAST && *profile !=3D val) + *profile =3D PLATFORM_PROFILE_CUSTOM; + else + *profile =3D val; + + return 0; +} + +/** + * platform_profile_show - Show the current profile for legacy sysfs inter= face + * @dev: The device + * @attr: The attribute + * @buf: The buffer to write to + * Return: The number of bytes written + */ static ssize_t platform_profile_show(struct device *dev, - struct device_attribute *attr, - char *buf) + struct device_attribute *attr, + char *buf) { - enum platform_profile_option profile =3D PLATFORM_PROFILE_BALANCED; + enum platform_profile_option profile =3D PLATFORM_PROFILE_LAST; int err; =20 scoped_cond_guard(mutex_intr, return -ERESTARTSYS, &profile_lock) { - if (!cur_profile) - return -ENODEV; - - err =3D cur_profile->profile_get(cur_profile, &profile); + err =3D class_for_each_device(&platform_profile_class, NULL, + &profile, _aggregate_profiles); if (err) return err; } =20 - /* Check that profile is valid index */ - if (WARN_ON((profile < 0) || (profile >=3D ARRAY_SIZE(profile_names)))) - return -EIO; + /* no profile handler registered any more */ + if (profile =3D=3D PLATFORM_PROFILE_LAST) + return -EINVAL; =20 return sysfs_emit(buf, "%s\n", profile_names[profile]); } =20 +/** + * 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; =20 /* Scan for a matching profile */ i =3D sysfs_match_string(profile_names, buf); - if (i < 0) + if (i < 0 || PLATFORM_PROFILE_CUSTOM) return -EINVAL; =20 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 =3D cur_profile->profile_set(cur_profile, i); - if (err) - return err; + ret =3D class_for_each_device(&platform_profile_class, NULL, &i, + _store_class_profile); + if (ret) + return ret; + ret =3D class_for_each_device(&platform_profile_class, NULL, NULL, + _notify_class_profile); + if (ret) + return ret; } =20 - sysfs_notify(acpi_kobj, NULL, "platform_profile"); return count; } =20 --=20 2.43.0 From nobody Sun Nov 24 03:28:03 2024 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2066.outbound.protection.outlook.com [40.107.244.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 00CE81DF26E; Thu, 7 Nov 2024 06:03:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.244.66 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730959440; cv=fail; b=DZMpMP7YW1rVueQ1z3diNFLlZ465v3RL/tXt5BtpjX4LdkTZH0t4x54deJkhN7nVczvDFZW2n5wXUifKSOEb/PeZUB16D3oa/5hB/tGkX+I0bbAYN6VT645tElr42SOcuFT4Amnawq84eupPbS5J9c7yzNdGG63/CX+MuRSvVbI= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730959440; c=relaxed/simple; bh=hGdIbfS/+jpLYOwWMj/K6zfSfnaWUEf30H2z688aza0=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=FWFqSkS2JXOd7bJ2wLHCxlEbRFpvWvlgm/3pN77UIdgg5OiJKz+2ZAJg+IQKZCU6vu401k/w9seOXCtIdCM1GE2GWONvHZiQWbHS1K2ByDVsg830+GcoLYjadRcq3iak75GT3SPC1m2qnkHxCicye6kZuGpnLLDPhQjg6Bh9Rfc= 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=0zrZ9x+i; arc=fail smtp.client-ip=40.107.244.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="0zrZ9x+i" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=mYH2wlSho/dC8s+Q/jB+qHaq+G4F/LGs+XFekCSuk620xKzDQOfMjzZEfJMEOSqmcDAhN6a4+n21olc6Svo5RcjFDlo6YcUHUOty7IkTNSIz3psak62x3Ou1aImTOsnWC6ak5Rn2bgdtPIf4IIwKLwf8YUlRen/B/+GQob9EpoaSBAFpLZiZVJo77AVN4BdDzngLrfs5xzLfeuUKvQ7XaETelnl6mfpDKEoMxS2+kpKNUNfddvmkxV2rsloUHXxzKrOJ6m/HPqbTxqkxVeg3JUw19ELmpgl5J5jIGo2x95cMZpHVvtp+OZjYffoNzg5YjV20kiv5PrJeAi8vvvT+TQ== 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=mDo+HrkIo28732Z0/g/cJF5z1/K/WaqMVyyvI+DMEr4=; b=LA2Cb6nLcqVElifeBjjtBd3auMIr67nx6mWogxJ8/FEIroc9jOq0MOUC5VX/oA+Y2LDqw5Ni5kJphgDXgBo0M7eky9eIouNJmXVpXGVo62Pkl2XFtDhRrIvtuWwwFkGCBGCnybSA9VPqAzp+ed0Ijnm+xCMeiXK9kvGyS+Gm9Hlt0iK+rfEqi7W5vlcU/OQttpfuNKDITnOGjccBReWg4e2hxLMK9Tz3/bMZFfVZIgy3HyhLMfbJbMHGlj6xGkFN4SUBBBKRsGF4gIadpB4fzYrL1GoBUcFTumoEOYUbZDizOrC0w49+4xSv2MTO66er+6b/IrMmlX5CBfFTI7+ZoQ== 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=mDo+HrkIo28732Z0/g/cJF5z1/K/WaqMVyyvI+DMEr4=; b=0zrZ9x+iitDiM4oilagIPM8pA8kDEak80jreioEG/yboL0ILCQyL1swwmbQHxPMXCilHI+emMNCd3x/RGbBjz4VKKEaSBndlZzbSVHkHI137MrholcHLGWCsrVZq13qKdHuG0/YPXN+TavkZpbAOnsC9x06Otl2qcOvx2tuv58I= Received: from CH0PR04CA0081.namprd04.prod.outlook.com (2603:10b6:610:74::26) by PH8PR12MB7184.namprd12.prod.outlook.com (2603:10b6:510:227::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.30; Thu, 7 Nov 2024 06:03:56 +0000 Received: from CH2PEPF00000149.namprd02.prod.outlook.com (2603:10b6:610:74:cafe::2a) by CH0PR04CA0081.outlook.office365.com (2603:10b6:610:74::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8137.19 via Frontend Transport; Thu, 7 Nov 2024 06:03:55 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by CH2PEPF00000149.mail.protection.outlook.com (10.167.244.106) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8137.17 via Frontend Transport; Thu, 7 Nov 2024 06:03:55 +0000 Received: from AUS-P9-MLIMONCI.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Thu, 7 Nov 2024 00:03:53 -0600 From: Mario Limonciello To: Hans de Goede , =?UTF-8?q?Ilpo=20J=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=20Kleine-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 v5 17/20] ACPI: platform_profile: Check all profile handler to calculate next Date: Thu, 7 Nov 2024 00:02:51 -0600 Message-ID: <20241107060254.17615-18-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241107060254.17615-1-mario.limonciello@amd.com> References: <20241107060254.17615-1-mario.limonciello@amd.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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: CH2PEPF00000149:EE_|PH8PR12MB7184:EE_ X-MS-Office365-Filtering-Correlation-Id: 90db55b4-00d5-4e26-86a0-08dcfef1f6aa X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|82310400026|36860700013|376014|7416014; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?9X+vzBhmZHnq08DAjsIJw0ncFzDtwNXLR6+Z0Z6xnl2d6zZ4xqIuZrBgvTmp?= =?us-ascii?Q?s6zmnK5c/dArvNPstuHdLhBnmOGeFj+L45JoMSwHAQKtFwDcQs469DYC1YJn?= =?us-ascii?Q?QNGa3Y2ToopfXaOJRzW5RQB+/+C5xY6ZeZ7MBN+uaIApc0tSdsjbG0K957G6?= =?us-ascii?Q?K9spb4FSJ5gzgStwvp8vVS7aNF2KZA7Gqn3IuXgYNim8LAvfnesbPxKQ44CZ?= =?us-ascii?Q?dZhOOpukuRhVr0Bnhxu1f9VFq8VVnMZ8dpoXMS+6YNtwrlws0eIrv+sBEURO?= =?us-ascii?Q?U0nqK77zOcArOhr3VXsx1mhZq+0qhFov8obgPettwPKQhrwqYQnxAtj1Msi6?= =?us-ascii?Q?yJNPxCEQ4FmNdtLSMjEag0GeS3nP06a5k/pornUuDmRw5pCcff2kOqEKpvTb?= =?us-ascii?Q?JHE04S42PSGZm0Qh1BTXJCEUJv5dkNPChUXqlsL3SojxTvVSRhWg6j3K5Wgy?= =?us-ascii?Q?i8mvUy/Zbg2dL8jqi0+Jdqe4AVbnsp6/CI8oA5dLvYW631+uFzSUcaFxhzkn?= =?us-ascii?Q?iI03Ne+ItvS08gcLaxEV8SBbrlg/rNW1uDok9KQm/erB+d9pRz8EJo9lk2Ag?= =?us-ascii?Q?j7XIFTqd4lBLEmFOW11Bi0ri4Z+tyTax69Md7bo04TucDgZr6viIE2Fdm0qW?= =?us-ascii?Q?VWpRe40d2oJJlRYhUMHCEslfMZrmCrApUwMcenCHB+3oZTzq+R6GZY79WMgt?= =?us-ascii?Q?hsWq7Kjlz4BrZ6J3XYM5GBYLmIDfUmbau62OJmbZjs2jaCjfT4WRy4mw+DEa?= =?us-ascii?Q?vgW3Om55cUstckiLOstfQ7KYE+T4BZI2Rysf0LlUkYXICFxHos1GmD5f0V0m?= =?us-ascii?Q?PKHWGUW4DPPVvA59fH13hx8J1W78JS/u6V46ISKFcoKOIPzIptMxa5yUgZiw?= =?us-ascii?Q?difvMcb48ctGCQIM5LQx077w8+MijVscI89AVi4ZyqZmKgT8+519VOFt3IN/?= =?us-ascii?Q?6ShObnyHXi9HI0UFkGpX2DwCWW1s12/Cjt6o9fKoAZVv9Wx55Evb+V/Pmz0c?= =?us-ascii?Q?b9eKt0pcNDgUoY+QCCpzFr4tZ+Etr1X3t1HAw8gzI/U7u1yR5yszXHt+nT1W?= =?us-ascii?Q?pUqrRVXNDqj72rzwA7NDj2S1bv3KJNabHnakfH/abvTpPfji7kw9o7ok2Y7t?= =?us-ascii?Q?jZwfur7tE/NPDx3I4YBotzZXGDSL0DicBiFxZL2jA4ARU82J6dSbe8ywM7vT?= =?us-ascii?Q?Hj03SWjQgGWkIRqnJtEk4WvKGmM5qOHkFMVyglIpHup9jyP5+EpiInebNdDZ?= =?us-ascii?Q?HGkAik57DB93jLCZc9NcujmGAKeBpRxxa6lrdEvHtOsRTgpq7Hju1UwU0+Qz?= =?us-ascii?Q?SkRFUadkcB2WQXdFroN4jtJu0IEulfq6+gLXAYe2ogGezP+9XZ446ZDut4sJ?= =?us-ascii?Q?6oU9dXVq4SYdzEkUYOLda29HZV5qSp70rBmg+ny7jUdjMrseUw=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)(1800799024)(82310400026)(36860700013)(376014)(7416014);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Nov 2024 06:03:55.6836 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 90db55b4-00d5-4e26-86a0-08dcfef1f6aa 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: CH2PEPF00000149.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH8PR12MB7184 Content-Type: text/plain; charset="utf-8" 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. Tested-by: Mark Pearson Signed-off-by: Mario Limonciello --- v5: * Adjust mutex use --- drivers/acpi/platform_profile.c | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profil= e.c index 7f302ac4d3779..2c466f2d16b42 100644 --- a/drivers/acpi/platform_profile.c +++ b/drivers/acpi/platform_profile.c @@ -411,34 +411,39 @@ EXPORT_SYMBOL_GPL(platform_profile_notify); =20 int platform_profile_cycle(void) { + enum platform_profile_option next =3D PLATFORM_PROFILE_LAST; enum platform_profile_option profile; - enum platform_profile_option next; + unsigned long choices; int err; =20 if (!class_is_registered(&platform_profile_class)) return -ENODEV; =20 scoped_cond_guard(mutex_intr, return -ERESTARTSYS, &profile_lock) { - if (!cur_profile) - return -ENODEV; + err =3D class_for_each_device(&platform_profile_class, NULL, + &profile, _aggregate_profiles); + if (err) + return err; =20 - err =3D cur_profile->profile_get(cur_profile, &profile); + err =3D class_for_each_device(&platform_profile_class, NULL, + &choices, _aggregate_choices); if (err) return err; =20 - next =3D find_next_bit_wrap(cur_profile->choices, PLATFORM_PROFILE_LAST, + next =3D find_next_bit_wrap(&choices, + PLATFORM_PROFILE_LAST, profile + 1); =20 - if (WARN_ON(next =3D=3D PLATFORM_PROFILE_LAST)) - return -EINVAL; + err =3D class_for_each_device(&platform_profile_class, NULL, &next, + _store_class_profile); =20 - err =3D cur_profile->profile_set(cur_profile, next); if (err) return err; } =20 sysfs_notify(acpi_kobj, NULL, "platform_profile"); - return 0; + + return err; } EXPORT_SYMBOL_GPL(platform_profile_cycle); =20 --=20 2.43.0 From nobody Sun Nov 24 03:28:03 2024 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2077.outbound.protection.outlook.com [40.107.92.77]) (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 566F81DCB2D; Thu, 7 Nov 2024 06:04:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.92.77 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730959442; cv=fail; b=Tc3fk+MAxpRpesoRdsJiVIz47znMctaHpuebMOTG5REjJulD3WzvpctDV7ehkPfPiXRgTOCqrxgq9QLnMfpGJ+Z7taLRZ2YzKXP5t60FvDOQd+2kurndsdVWlb+8woY02dGU/QNZ6JbSO8W5ub1ziXvewd1A7udH8OIRvZMS2jY= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730959442; c=relaxed/simple; bh=cC4TbPX/VQOnAUsgBwm00InxYmXfz2kAuwh50Eqi8Ow=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=MzCjRE/VGTpE/ZwYEqYWnyS8z22yfMTa4d2ZmCBLkmU0eA5bHfK5ohNdukWLZT8A8f954XsIi/fy0Xyejq0G+rWn8xAVl3qk+vR0MkpT6n/a5eIGnFfa6pa98D9jWPTu/95kAku1+EMaGezSRaBcyYtEZULm3TslxuRcseE04ik= 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=Y2iv2TAY; arc=fail smtp.client-ip=40.107.92.77 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="Y2iv2TAY" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=aSzlxci7NaDZKPujspxo8B4HZsYFtzPx3F8rsV6aKbfeS4BfKy4bMaR0U4KFw8EkkH/0yb/kJtnFz2SRqe6BzQqF82FQux2xpwkUaax6fzSZe9H1yWK1MkSRR5iws7Qoey1vYY0rpfLAhCkNbWHAFq9t3g3qqknDOWXj7xGGPSU4vKoDv6qp+0z1qPRrB986h7ofKXlMbRd3y+b0gixymxVQSA6U4EHEPMANccRvF3CFWNNSTiG24AU5GXkON6FvDhoxsaI4M8KvHulBIPaOZqNLkMCmeb0Fi2CZ0rIG87xr7Mn7ubSoMTGcBCgWHiv1o7237GoBuNWavGrUqvHY1w== 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=m1d0S4zb/ctgwx9iRMLS7vElenRqrsErndD/UwbSOy4=; b=gm5MN3uDW9AvfoOYQlizmiujTepLkI8w1kHYJCylWTJ/D9JkcoRCdoz23yvVUlgpCDhQJfGcUiOcdtGWuyjcVk4JxkRobXcNut+hJtQE0lnbvokshdUXo5BfeJiljtAJz9czAGRAdRs+AFMwK9w1MlUplFJvs62dICukyDab2lq7bBbGfaubnRrREsvZwbQgq/d5zvDB/RtGQgukC97Q6KltUexE4AW5kZnoyasPXchhhBU4rFc7B7QZbT/7YOujAm8nZryx/AWqjkReJnAeWvR3UcEsFsMIANjrhpAw2L7PXKKmElCf7ErATQjVLDI3KuACK/CBHwOaeh5mBw/Gmw== 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=m1d0S4zb/ctgwx9iRMLS7vElenRqrsErndD/UwbSOy4=; b=Y2iv2TAYbyLyF+DH1GB+MA8XhLaSB3yTsZej2sYV9VS2RgfInlMu7VFb7dFGoZB0OlbQDXRV3DT8x5W/xHnZlZIVDNLnGtJU8gqR5BUobsc8QC0AwhU3/ZlN4bAycY6gsVc+VTSE0AwOh86djHABM8tKze77QL7nytpP0efhpXI= Received: from CH0PR03CA0295.namprd03.prod.outlook.com (2603:10b6:610:e6::30) by SN7PR12MB7251.namprd12.prod.outlook.com (2603:10b6:806:2ab::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.30; Thu, 7 Nov 2024 06:03:57 +0000 Received: from CH2PEPF00000147.namprd02.prod.outlook.com (2603:10b6:610:e6:cafe::b6) by CH0PR03CA0295.outlook.office365.com (2603:10b6:610:e6::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8137.19 via Frontend Transport; Thu, 7 Nov 2024 06:03:57 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by CH2PEPF00000147.mail.protection.outlook.com (10.167.244.104) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8137.17 via Frontend Transport; Thu, 7 Nov 2024 06:03:57 +0000 Received: from AUS-P9-MLIMONCI.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Thu, 7 Nov 2024 00:03:55 -0600 From: Mario Limonciello To: Hans de Goede , =?UTF-8?q?Ilpo=20J=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=20Kleine-K=C3=B6nig?= , Ai Chao , Gergo Koteles , open list , "open list:ACPI" , "open list:MICROSOFT SURFACE PLATFORM PROFILE DRIVER" , "open list:THINKPAD ACPI EXTRAS DRIVER" , Mark Pearson , Matthew Schwartz , Mario Limonciello , Armin Wolf Subject: [PATCH v5 18/20] ACPI: platform_profile: Allow multiple handlers Date: Thu, 7 Nov 2024 00:02:52 -0600 Message-ID: <20241107060254.17615-19-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241107060254.17615-1-mario.limonciello@amd.com> References: <20241107060254.17615-1-mario.limonciello@amd.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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: CH2PEPF00000147:EE_|SN7PR12MB7251:EE_ X-MS-Office365-Filtering-Correlation-Id: 51eb5401-3ca2-46f9-924f-08dcfef1f79c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700013|7416014|82310400026|376014|1800799024; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?9Yl8zHtshcz2a1Exvwyp4li08VjBVFoODLBUtw+oY1ND1CbSIbgFiOeMasCE?= =?us-ascii?Q?V+cQHZfUzuh6HxCisJLukZfw9FEtuJ6BPiBppCS/BtL8/aCjewPM5KODI8AZ?= =?us-ascii?Q?JyGiEiZCn2Ay1r1Q680jEEuqpKMD46/fNMGywrLaRvsy8XiDmEO1rmkF6ZC6?= =?us-ascii?Q?N0cEfI5K9BYYykFG91l8f9OxQWi941eCE4qKw0k3ZS3UHJnld0llK8eqHFPD?= =?us-ascii?Q?Vm9VU8noN9EMV7z0sPK3wwhFeDbKvQda7Tyma4yrlt07ycolU6dzCswpKNaR?= =?us-ascii?Q?0IRJIQhC3rk0rGNYjJVSGdh/wxCzpOdEf8/Djid0hXe5cJPO1gXA/dt0IE3f?= =?us-ascii?Q?xOg7ju4uRCHnUXtq1BZSTh2DzM3C7TugCOB9olXc9tUo/uxIJ6JBx0rlqkhW?= =?us-ascii?Q?OrB/QJeSPQo9QGcUrtlre0qb4MRWIdd1IiDmEqj+M7OH4Dl7l3+ax50lxCG2?= =?us-ascii?Q?zU1/ODpb6ITIr4rHqJ8UUjl8EWSJTpHrx51Jbq4YNf8NQ9W49UAwvtmWZsyS?= =?us-ascii?Q?egQ54kOR9T4rushCGBufRBq5nplAMz/DAcViUOZ4iWvWYRMJaKxCcKzukqSH?= =?us-ascii?Q?PJwSORQ0GcU6qhtqAsMmw79xXKIotQJQxyvuR/IJ1qLOO6R7lRRRcrp9UMyW?= =?us-ascii?Q?C/w6lMdqI/O8ADQlrf+vHL7ZXw7DXK3d5ZUdU1gBR7F2jIpHRxQrCcjlvtgn?= =?us-ascii?Q?CkWAvMK9zqjGB0wnAm7JujjxMe6T5vJmbI1n8/3H7eZ4URuG4q09LLF4T1Pq?= =?us-ascii?Q?McS/8CCxlKP+RdC1zX7dOmhSLcN/6oQg5qTdWvrAB5f1004gOqymY1Te0TGN?= =?us-ascii?Q?nwGwhbvQNQ8G3zAfbJ47cLx0F8faNrmq/rIXjF7cudc2hWQUyUbDWE8v7W61?= =?us-ascii?Q?gZYY7Krk7Z/YDaQbszCLTcPrjm691nKR2Aam/aHxZulUCSgP0X86PArVDGoX?= =?us-ascii?Q?R+AhqdGFWV492R/3Zf1cJhces/Di+3crgggg5ikNhD/7LGXFLWh/v1Ly/aDo?= =?us-ascii?Q?4li4D713KXukplMvab5t3AxpMHxgKnlQEKIeBwRTCxhjPdq070miBBMVF/c2?= =?us-ascii?Q?P+n5GfD33YjunNcVrvSOXccKNZAq7v4KR31p/wlBPI5//rsXlOH6Hl3WUhoe?= =?us-ascii?Q?T4mRh34cgtZwTplo+lIr7qGhhl8AKTZOAgzcGxDctu7WLku1cxzjSkpTz2Sy?= =?us-ascii?Q?6sEdKOO4m/lhPIIxZ/vmzuElWXsCOHryF+WvF0tei5UEYBmcnODFANCkcMpD?= =?us-ascii?Q?qXEFW/zd2lyc0uKpQtCYtfS9MCP0WmWeiTSb2766mWOfyUNZ2uBm4rKK/Nv0?= =?us-ascii?Q?ZKoz6g/RMbrdl3UCl7V6N80C4wo1ADFZnSlU8MwcbOpXRHHc6uf4ikebimlf?= =?us-ascii?Q?lm9lV8rC0FF1aqWlSNmPtciffZkcmuegCkPBxG3euiacqsJ8kw=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)(82310400026)(376014)(1800799024);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Nov 2024 06:03:57.3012 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 51eb5401-3ca2-46f9-924f-08dcfef1f79c 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: CH2PEPF00000147.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR12MB7251 Content-Type: text/plain; charset="utf-8" Multiple drivers may attempt to register platform profile handlers, but only one may be registered and the behavior is non-deterministic for which one wins. It's mostly controlled by probing order. This can be problematic if one driver changes CPU settings and another driver notifies the EC for changing fan curves. Modify the ACPI platform profile handler to let multiple drivers register platform profile handlers and abstract this detail from userspace. To avoid undefined behaviors only offer profiles that are commonly advertised across multiple handlers. If any problems occur when changing profiles for any driver, then the drivers that were already changed remain changed and the legacy sysfs handler will report 'custom'. Tested-by: Mark Pearson Tested-by: Matthew Schwartz Reviewed-by: Mark Pearson Reviewed-by: Armin Wolf Signed-off-by: Mario Limonciello --- v5: * reword commit message --- drivers/acpi/platform_profile.c | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profil= e.c index 2c466f2d16b42..63ef192f1a07c 100644 --- a/drivers/acpi/platform_profile.c +++ b/drivers/acpi/platform_profile.c @@ -10,7 +10,6 @@ #include #include =20 -static struct platform_profile_handler *cur_profile; static DEFINE_MUTEX(profile_lock); =20 static const char * const profile_names[] =3D { @@ -401,8 +400,7 @@ static const struct attribute_group platform_profile_gr= oup =3D { =20 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"); @@ -459,9 +457,6 @@ int platform_profile_register(struct platform_profile_h= andler *pprof) } =20 guard(mutex)(&profile_lock); - /* We can only have one active profile */ - if (cur_profile) - return -EEXIST; =20 if (!class_is_registered(&platform_profile_class)) { /* class for individual handlers */ @@ -487,7 +482,6 @@ int platform_profile_register(struct platform_profile_h= andler *pprof) =20 sysfs_notify(acpi_kobj, NULL, "platform_profile"); =20 - cur_profile =3D pprof; return 0; =20 cleanup_ida: @@ -511,7 +505,6 @@ int platform_profile_remove(struct platform_profile_han= dler *pprof) =20 sysfs_notify(acpi_kobj, NULL, "platform_profile"); =20 - cur_profile =3D NULL; return 0; } EXPORT_SYMBOL_GPL(platform_profile_remove); --=20 2.43.0 From nobody Sun Nov 24 03:28:03 2024 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2067.outbound.protection.outlook.com [40.107.92.67]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5D3F51E0DDF; Thu, 7 Nov 2024 06:04:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.92.67 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730959445; cv=fail; b=lB1pTFrmAo+HKRH2/lir7ZINrMLzbYbuy49bnF1l63kD0nFSUFzSrqivMCq4mESoWm7ku8Cern28gXU7sg6YjMw7wBdCHAEJgBPwt5ECKCeMjmKrrlNk/5j00DPYHntJULsoUHPweRDc4ZzFV/MFCvOj+CUNtmYMgfkM7TT4wA0= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730959445; c=relaxed/simple; bh=wydFZq9b9U47n3suMunKX8B3Vmy1X7R/gKQy89bbhQ0=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=T/CyCRbZBu5C09Q+edu5wzZ41DloNZbfkKEdQynVQWnRNkbAgZm/VvAp3/rkH4eMi5k547ENliXs9TEUDbv2Q1thpUlrwSk9Cus6iZqLZUAQ/7hdWXLNK+MBAKM1GAmkVDa9AUq4TnZG26vQ8mRwrCblr0v544FVcHQ15SBmZOw= 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=ImkGRgb6; arc=fail smtp.client-ip=40.107.92.67 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="ImkGRgb6" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=J4Zk3lZFS2Q2Z7vyCLeZhy2z8abmu9tZZ059nl+bZRrVmhaUh/+GDFQ2ZEc5HXWoQcK9U3+OeqNbPJOztpxz0LleWvaPVjaTd5N+9YuPIg59X/l3+R8uwEQ7n3Ch+hnEBDfUYMnqb6Gml52ZAVTeoXezLHu+61fdsxYi01ARtTVUHGNEftqwIr0asahj0ap8pX/lfyb9OaK3nILOEqkeMp3c2s1oaGykpCkPRVNy3AW6x1BOfLIDEy11dOM8R16ZYW9RXkSAAEY1zn9W+eyHZx3Qe8ZRta32G7eEthuijgJcJBiFJdOpInsKRNh/dcgswlXud7fl95N15y7MYdA3rA== 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=tGd4uyuf3IiVcajgihcX5MqVnqZNO56nHUgYLRj4468=; b=R2lo35xBl5BqoiiziYDkCeQf3KHOMGfYvyKwrmoQH7RU8wx5R0H1VOtj1jrn8SlZzlUSxGpbNOaWOOcDrQsYZA6OE1YJK+35dgSXVhfRPM8k/mlwqNz4L9Lhgyk8jwAXprnv0+lXr/+JtmFC7FVxVgoMH9xkcVYTqqM0Bv/5+bUzgJhRZe24RX26t58V5BdN02FJDkHSzDHKlnEMjdJMGmKh2Ke1ztLNlDRbBXBKRfSlEIR/1VQmRJmruibDPrkh0Ms+ExWPnP2kdXhcqxBE8I4nutRRRLqmrmTPxjnzwOfhzuQDzvMXGqra5xsiaU432IUyO0MUwdaenu4gkakK0Q== 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=tGd4uyuf3IiVcajgihcX5MqVnqZNO56nHUgYLRj4468=; b=ImkGRgb6KNtHLm9KD0kKr9eDLwib3YmOtAqJvzCZHjtvKYqFPkBDmUcOqsz23Yw/JxeSmd9ZLialayxUVGvAYykj9I0bV9zWPOYsie595M/vQC1ulypm1mYRjlXZo6LPkzBinkcSF1BcR/EJpAA2F18fN7oPPqZcCvmsuyo2J8Y= Received: from CH0PR03CA0245.namprd03.prod.outlook.com (2603:10b6:610:e5::10) by PH0PR12MB7930.namprd12.prod.outlook.com (2603:10b6:510:283::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.30; Thu, 7 Nov 2024 06:04:00 +0000 Received: from CH2PEPF00000144.namprd02.prod.outlook.com (2603:10b6:610:e5:cafe::51) by CH0PR03CA0245.outlook.office365.com (2603:10b6:610:e5::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8137.19 via Frontend Transport; Thu, 7 Nov 2024 06:03:59 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by CH2PEPF00000144.mail.protection.outlook.com (10.167.244.101) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8137.17 via Frontend Transport; Thu, 7 Nov 2024 06:03:59 +0000 Received: from AUS-P9-MLIMONCI.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Thu, 7 Nov 2024 00:03:57 -0600 From: Mario Limonciello To: Hans de Goede , =?UTF-8?q?Ilpo=20J=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=20Kleine-K=C3=B6nig?= , Ai Chao , Gergo Koteles , open list , "open list:ACPI" , "open list:MICROSOFT SURFACE PLATFORM PROFILE DRIVER" , "open list:THINKPAD ACPI EXTRAS DRIVER" , Mark Pearson , Matthew Schwartz , Mario Limonciello , Armin Wolf Subject: [PATCH v5 19/20] platform/x86/amd: pmf: Drop all quirks Date: Thu, 7 Nov 2024 00:02:53 -0600 Message-ID: <20241107060254.17615-20-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241107060254.17615-1-mario.limonciello@amd.com> References: <20241107060254.17615-1-mario.limonciello@amd.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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: CH2PEPF00000144:EE_|PH0PR12MB7930:EE_ X-MS-Office365-Filtering-Correlation-Id: fbdc959c-eb9c-45d5-8049-08dcfef1f8d7 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|82310400026|36860700013|376014|7416014; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?JLbd9yiqNmOW+v9PMuIwCZd5ybjqmlSTMbaKDVDkgUoyAHMXc01sxS8JyU5q?= =?us-ascii?Q?o8zk9x+JAH/5A295syI1sunBjKocDI21n80HA5tio/4o/RDiQyCQoEpIfrIG?= =?us-ascii?Q?kPPeGCAIVFTHk+6lCZTJdqZLNqg8LVrDAjBXnwxlxLdJ/f6T43ZJ4YEA/SZv?= =?us-ascii?Q?TEyILWT9lhCFXWp65amPOqlJnun3PYnWTQvfANYgvqTACcUhV8XzFi8p5NjQ?= =?us-ascii?Q?uM/kY6mznsGqYrwDFCt61WUxYlrVK4mjn0+DQmpRmowwYCagW28fHULSmjw5?= =?us-ascii?Q?mUWL0wMJ3Td7gFLIfcg/EClUtjqmHF2kBOHrLdQYOaAudwghBv461BbjCnj+?= =?us-ascii?Q?RDTtuFnrk1Izan9qCAP1BGvTqS6+vhgW2VTVoBlIpf03i/ouDB7np5E3tNJU?= =?us-ascii?Q?yapstRD2giBgbuzTdo2HcECz0s8BOqXVQqcB+J11EmGB6WnroGHUI8DKdoKo?= =?us-ascii?Q?rx5RuJytFlbZKI0HfwTYKkF3+it5oY9daTp6Bg3rbpu+1ENCdqNzoU7yzu2u?= =?us-ascii?Q?7TTyHCMR86yli2ZFLqO2UagI6eWRsRXTgRFnZkfY/4/hXJKraBz+X6gumPHL?= =?us-ascii?Q?IkRMBR0mPG46Tg1e37q8idLeJLkOgeQuP/fwJreAW8GvnPDjJEB2ESL/TZrV?= =?us-ascii?Q?Bg4fid3vjF6vZ7foOD2alTQqTEwxZoJddhxeLlhpOXLq8I8rHf1UPFjqLyZX?= =?us-ascii?Q?DOcc5JjVCVwx60galdNdkCjWknAxb7619DgRYcUik2kGbnF/cNMSpmCHL4Hz?= =?us-ascii?Q?TeiYYq6fRyzVWIoE5vk71BQAsM80fzNw/FxcDcj0ps+Q6nkIo/y8M7vGQoAS?= =?us-ascii?Q?c+xgPCuPwAxThgH+GKht6vUr9r+X0DXSZsgPiXi0bcXhT3qgnrB2FAg/zS+t?= =?us-ascii?Q?jHTx/3/Wjc2qhDd18hC4YcPH2l94/eQBe0071+hiAwR+QR5ZW7ZB4NT5660s?= =?us-ascii?Q?qtnB8KbbEXVELwwTRvPvWDOoYw/yd4vOPoat21F+V8VJnyzNlWdbZzWWEqre?= =?us-ascii?Q?id2zkTsSF5LpBeJyVsgnD2yA7LR0/EhiwBjv9RuCJ7EpN8/NeucliLEcY1/+?= =?us-ascii?Q?efph/7pWZ2e2secgSX/V0QU7kJ4a6Xbi0CIxMCFy3WxTGaVB6ah0lcyrxd/B?= =?us-ascii?Q?CFqoUebJKuTOO8aJrGhdul3jVS02+sGLU6r3abeHssGUVSTrh/8cY7lSQm+r?= =?us-ascii?Q?V207IlEvC5CXlt0ov+x6FI8MoBaSF4JIE16cJc0cDOP343hOAFTLFkKW+u/t?= =?us-ascii?Q?89OlmQFtMp3r+Ewdnt2rigOiLC9DgcO6iJs4t8vsrkApj1VDsA40GxsrGLeP?= =?us-ascii?Q?nylN/X9A2G80dJzDTh3XdSQxN4lHTCsDchNqA9tJPHf9SlVEdcCP62BEEQs1?= =?us-ascii?Q?Tk4HhR0N1SM8eL0fi9ZSXCLWSW3DHMt9qD9vWXcnMZJxUa1llg=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)(1800799024)(82310400026)(36860700013)(376014)(7416014);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Nov 2024 06:03:59.3495 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: fbdc959c-eb9c-45d5-8049-08dcfef1f8d7 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: CH2PEPF00000144.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR12MB7930 Content-Type: text/plain; charset="utf-8" As multiple platform profile handlers can now be registered, the quirks to avoid registering amd-pmf as a handler are no longer necessary. Drop them. Reviewed-by: Armin Wolf Tested-by: Mark Pearson Tested-by: Matthew Schwartz Acked-by: Shyam Sundar S K Signed-off-by: Mario Limonciello --- drivers/platform/x86/amd/pmf/Makefile | 2 +- drivers/platform/x86/amd/pmf/core.c | 1 - drivers/platform/x86/amd/pmf/pmf-quirks.c | 66 ----------------------- drivers/platform/x86/amd/pmf/pmf.h | 3 -- 4 files changed, 1 insertion(+), 71 deletions(-) delete mode 100644 drivers/platform/x86/amd/pmf/pmf-quirks.c diff --git a/drivers/platform/x86/amd/pmf/Makefile b/drivers/platform/x86/a= md/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) +=3D amd-pmf.o amd-pmf-objs :=3D 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); =20 - 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/x= 86/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 =3D { - .supported_func =3D 0x4003, -}; - -static const struct dmi_system_id fwbug_list[] =3D { - { - .ident =3D "ROG Zephyrus G14", - .matches =3D { - DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."), - DMI_MATCH(DMI_PRODUCT_NAME, "GA403U"), - }, - .driver_data =3D &quirk_no_sps_bug, - }, - { - .ident =3D "ROG Ally X", - .matches =3D { - DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."), - DMI_MATCH(DMI_PRODUCT_NAME, "RC72LA"), - }, - .driver_data =3D &quirk_no_sps_bug, - }, - { - .ident =3D "ASUS TUF Gaming A14", - .matches =3D { - DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."), - DMI_MATCH(DMI_PRODUCT_NAME, "FA401W"), - }, - .driver_data =3D &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 =3D dmi_first_match(fwbug_list); - if (!dmi_id) - return; - - quirks =3D dmi_id->driver_data; - if (quirks->supported_func) { - dev->supported_func =3D 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_de= v *dev, u32 val, u32 preq void amd_pmf_populate_ta_inputs(struct amd_pmf_dev *dev, struct ta_pmf_ena= ct_table *in); void amd_pmf_dump_ta_inputs(struct amd_pmf_dev *dev, struct ta_pmf_enact_t= able *in); =20 -/* Quirk infrastructure */ -void amd_pmf_quirks_init(struct amd_pmf_dev *dev); - #endif /* PMF_H */ --=20 2.43.0 From nobody Sun Nov 24 03:28:03 2024 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2053.outbound.protection.outlook.com [40.107.236.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 AA8831E1021; Thu, 7 Nov 2024 06:04:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.236.53 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730959446; cv=fail; b=lr83RO1eQH1IE0/PxJ0hjl+pIF8c8rF72UzJWLAucgy/J9P2284PU/bYPBBpGe85wDgipADBpKAZ+YJ1kAOAAC5xr32wofah/lZxfv2WFAvGWvtXIH8HF5HwQ8smz3hC+Z7P+Vs4pPJEP2qbAwE0k6wcC1DptX6mUsZXxbovI2g= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730959446; c=relaxed/simple; bh=/+/ROlHIruuC8Ptk3wbPDnl/Q1PdBpPyHTOE4QQFJzE=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=FboL7XL+78UDbOf8qVRZA/W7wOb72IkBKYooJtrKy0kel0haPcbHdb/i9ZK0uatF9JmWHjY1RvHFaZ80b8J2bNHCOB3dAFXY1aArUCjfNDAQBPJDOkgTcSajCxuMxH5q45gcAXgumrmFt0SHNHPest5j8C7sfWFWtxovQ57cAHs= 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=cQfzosWV; arc=fail smtp.client-ip=40.107.236.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="cQfzosWV" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Fs2kiiFqYTzWSVsEpx6+0JLjuX+G+Wb+3xF/o9EHKF2p8LzBzbGUdsExu39sCNO1tQglbPyvZjNnqISiGckvka3ajgj2CUW7tw6KJNUqpTuKAxbYsn8hSMyccq3dWapvDH2Y+/RWbGjQDwKUNSW5/4yQ5xStrj/vAv1T0POATBkDCnujS56Zwx5k8CHc52KQI9mUG171yRn3C728dhKmfGaCg/dglvIGcB7bSCWwDV7PPZ2SlXQMAnR8jfpMiC6TVYmLj6EotWalgrJBAd0phF5VtelC/JR4B/eGLzI9jX4JzHCvgl6GA979tHMJdDIjuWeaFcCXoirX81IYexurQg== 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=xMYzj0HO6grQuskdeKK/x04e7ys9n7Ov1LkG/6DM3OQ=; b=BByhBn7UwfU28KDeFiy4sQSKny/4sOgx89bAnXrrThgSgJDjoiAPnC1iXOYaBYeA56rTpzDqVEpZ42SqVp2SC05bNJ+h7+pM4iw9W42KtpBn3QtT/WJLjgWmbCPpF5HAKnJ2r5E/Ye8SOw4kE3SkWgv/7Q6y+TOKiR4Y/mKL+uCefIqIWFeZysYXKw+k4cOVjXWZHdvQtImRLU/MxeQiF0JDYzxkqdTeGxTyKmNnPRqTpJ7Ps7EW/pJo2OE2MgBu4AkmMSozb5Q+WH+ij1RUb7tCMYWtAWSstxTZUPGGpE6vkvc4WPCowjETibqJkylaAN79A/sXsHfbmZID224AqQ== 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=xMYzj0HO6grQuskdeKK/x04e7ys9n7Ov1LkG/6DM3OQ=; b=cQfzosWVzhMaIL+FoTpVCKLdC+agqHJ6UKhK0fxpJqHPlK5lhbmfaSXefQ1YAWZ/8reIo4Xk1TyDCQkmBdf1UPtW0mn+i7W0oKQOM/oKMcAfglf7NG2nnXYJTr9F6LTy/jR5vqqVpJUdaljIRYjuJxS6/bw9YcyWrKqQo4aGjD0= Received: from CH0PR03CA0267.namprd03.prod.outlook.com (2603:10b6:610:e5::32) by CH3PR12MB7521.namprd12.prod.outlook.com (2603:10b6:610:143::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8137.18; Thu, 7 Nov 2024 06:04:01 +0000 Received: from CH2PEPF00000144.namprd02.prod.outlook.com (2603:10b6:610:e5:cafe::ad) by CH0PR03CA0267.outlook.office365.com (2603:10b6:610:e5::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8137.19 via Frontend Transport; Thu, 7 Nov 2024 06:04:01 +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 CH2PEPF00000144.mail.protection.outlook.com (10.167.244.101) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8137.17 via Frontend Transport; Thu, 7 Nov 2024 06:04:01 +0000 Received: from AUS-P9-MLIMONCI.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Thu, 7 Nov 2024 00:03:58 -0600 From: Mario Limonciello To: Hans de Goede , =?UTF-8?q?Ilpo=20J=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=20Kleine-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 v5 20/20] Documentation: Add documentation about class interface for platform profiles Date: Thu, 7 Nov 2024 00:02:54 -0600 Message-ID: <20241107060254.17615-21-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241107060254.17615-1-mario.limonciello@amd.com> References: <20241107060254.17615-1-mario.limonciello@amd.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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: CH2PEPF00000144:EE_|CH3PR12MB7521:EE_ X-MS-Office365-Filtering-Correlation-Id: 0bf4ad12-8653-4c40-d710-08dcfef1f9d1 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|36860700013|376014|7416014|82310400026; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?zKNmSVcQE/bzmy+yP4SkyMUCC2qTqalsNxjc02NkUBA70jcMLGFkC0m92RGC?= =?us-ascii?Q?7TAsrYvvw1hOLCC7pGQqdO6tAIJeuCKU38shLpc88uvzO/vEL7VU8eK4Vlx/?= =?us-ascii?Q?4PsgJqEDpbmifr0cMollG+bNZFSMsoNARRebkU5MaSGkyk9TJsBVIiLTR8Jw?= =?us-ascii?Q?w3gHjaFRwUT0LASiZ3aneP82wQLQitg/LCpiab2dTO+BqrOCwePapr9KTz45?= =?us-ascii?Q?9kd6iAjpMGAV75TExS6zuD1v+gNL0y/Y7KZNsdG/3EibG+QhBPAMfgJAVPCf?= =?us-ascii?Q?/3+KZDllokPolqvmdtA0ESjHtK4dLSmwfkEauG7MNveal+Y8HCMZRl8VVYTK?= =?us-ascii?Q?3kCsa1wlHCpmEkeZLHXdy4UGbPoz74HTj8bIDOl2pjL90S2nLa/4aTodPETU?= =?us-ascii?Q?Ll771+sl6DegYmrig4ycYaVs2xDqk2ZDponSx2ABhXK3EU7vLJejI8b9YSZ5?= =?us-ascii?Q?+c5kLgyCX1bOQMujgohggrd4FB6FCjG0+maDreQP/g3s8p8GD9tdClc6a/hy?= =?us-ascii?Q?G2FlXd6497Kz/0sVgQyosAg58J7OzhH3TiXdYECB9taKCwZJsiy2WIZsaiVZ?= =?us-ascii?Q?ag3Yr5xSjnAz4H0kgx9k7QfmpvzKcWnJboOCwvpWa3XNYF+1hSN5jAbmvvMQ?= =?us-ascii?Q?MtmIa8BEfSHVOOk0kkpqucCdw4Xw/5nCdwPrx+iqWHnR56rH6nNKV1AyT/K0?= =?us-ascii?Q?7ZKa91KLoz1ItF64IkC0LPs0DMoEChOomY+ZnrbPaT8PN2p0qa/G4QXRLpZM?= =?us-ascii?Q?CjLGzWeJSdZ/Wdg9HV1iAk6po+yHqnSlK65X4wZjBcUY0sYfDaBVth32QYYa?= =?us-ascii?Q?GojLtFMrngo5GGSMRUD/SaASLuh0PNcNO+pcy5VAPhPZk6qLWF0l+bxOnCMF?= =?us-ascii?Q?BtBe93EdsRj/LDUd4+RHgVhiLgfWbdmv3cvx6rwo6zT4bBydibEoUBepo9TI?= =?us-ascii?Q?ArIFXC7YcKHnWugYIfVtMDwf3mUEQsYVkJspmqNxUA/Tyv4xmckckNAOAOb8?= =?us-ascii?Q?9yTXfia6zck74D2fFXuaaMlXeYLK50ApiY/DlvsSimVxgDii9Oge55WiBPOo?= =?us-ascii?Q?J3srM1NS2Y+qHVnxq/w+p+vBxBupNspV3vRhhyToDOZ3zXkKavnW4vYyIJPs?= =?us-ascii?Q?fBuC9P+A7c1Od3eiI9p/EzNyA7rXbgAcWHo3+m9dvOIq3vCCCvrcb5a+1AH+?= =?us-ascii?Q?y280LDdYZ/xVrC+IXHTq5dLI9uQmDlNFEoAHXAVcGsAHdTz0sObAl2RUMB0g?= =?us-ascii?Q?LAV2BVDKW8DI5E0NIedeE37AjxzUFxFRQEpjAsHDE58/f/iAd6vpQdFeqcRL?= =?us-ascii?Q?mNShQ9HV1FIBkTr7YAxF8F7zZbZ4Ju2qj8cFbA2lwboXeKdsGvuCHalzXIrr?= =?us-ascii?Q?nHAfp5Pp9sM7vlcKa8fw6LeM7vxCtjgyusWGBpeya0UQ4vkYpA=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)(1800799024)(36860700013)(376014)(7416014)(82310400026);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Nov 2024 06:04:01.0370 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 0bf4ad12-8653-4c40-d710-08dcfef1f9d1 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: CH2PEPF00000144.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR12MB7521 Content-Type: text/plain; charset="utf-8" The class interface allows changing multiple platform profiles on a system to different values. The semantics of it are similar to the legacy interface. Tested-by: Mark Pearson Signed-off-by: Mario Limonciello --- v5: * Fix some typos --- .../ABI/testing/sysfs-platform_profile | 5 ++++ .../userspace-api/sysfs-platform_profile.rst | 28 +++++++++++++++++++ 2 files changed, 33 insertions(+) diff --git a/Documentation/ABI/testing/sysfs-platform_profile b/Documentati= on/ABI/testing/sysfs-platform_profile index baf1d125f9f83..125324ab53a96 100644 --- a/Documentation/ABI/testing/sysfs-platform_profile +++ b/Documentation/ABI/testing/sysfs-platform_profile @@ -33,3 +33,8 @@ Description: Reading this file gives the current selected= profile for this source such as e.g. a hotkey triggered profile change handled either directly by the embedded-controller or fully handled inside the kernel. + + This file may also emit the string 'custom' to indicate + that multiple platform profiles drivers are in use but + have different values. This string can not be written to + this interface and is solely for informational purposes. diff --git a/Documentation/userspace-api/sysfs-platform_profile.rst b/Docum= entation/userspace-api/sysfs-platform_profile.rst index 4fccde2e45639..b746c30432753 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 +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D +When multiple drivers on a system advertise a platform profile handler, the +platform profile handler core will only advertise the profiles that are +common between all drivers to the ``/sys/firmware/acpi`` interfaces. + +This is to ensure there is no ambiguity on what the profile names mean when +all handlers don't support a profile. + +Individual drivers will register a 'platform_profile' class device that has +similar semantics as the ``/sys/firmware/acpi/platform_profile`` interface. + +To discover 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 t= he +same system. If the selected profile by individual drivers differs the +platform profile handler core will display the profile 'custom' to indicate +that the profiles are not the same. + +While the ``platform_profile`` attribute has the value ``custom``, writing= a +common profile from ``platform_profile_choices`` to the platform_profile +attribute of the platform profile handler core will set the profile for all +drivers. --=20 2.43.0