From patchwork Sat Nov 9 04:41:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 842128 Received: from NAM04-DM6-obe.outbound.protection.outlook.com (mail-dm6nam04on2083.outbound.protection.outlook.com [40.107.102.83]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 442611E505; Sat, 9 Nov 2024 04:42:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.102.83 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731127344; cv=fail; b=pLlEx5jniFInUeajF9BlGeeTcgDgO+rj3HtTtMRfPMA7Lh4rHp1is/4Ag7iYFoQD/DJoqU/3CfuBb31+M8rpA1HWs3ucMjRF9dMDKiwJ1vAHojBATgzb0VWF1LgYTv+UuU+trYQ51KB8JnSk7/WhdBrmER2w2o6lfgWnVFpfmiE= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731127344; c=relaxed/simple; bh=AYvJHrr1DuzvBxnCLI2rzsMN92SzriWbCF0hjGw1VGM=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=feIkFxpaHPo7VEMa5/NjswQCa95oTQN7OdYUksYiEUvYmyzSTUQpl9cI6mxnpyuyXLvcSp/Q7G+tnKOZg5TYXzHkdeTdgjiNT3Qp0PPKiMgcmoXjX/Yyfhk+pYr0GWZz+qHvySOcrlymdqVT5g3A3MaRfatea/y1vBwIU9mbXIw= 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=E0XsaV8c; arc=fail smtp.client-ip=40.107.102.83 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="E0XsaV8c" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=cVFdsPw5NWnRC5+AZLUY/rgzegqjypMVHdcxP5OX2157v6st3ngqBcHXWE3e4jmRko1PUNyAHqE80VvppqenEuP2ftoTo6k/RNVGhj9UGPKghD2gTAeBYXhiFxuko+OEsN8tUJ5FmZQ+zd+TnOw7PheXdyEPE5UAsG69dk+4dZl6Sg70NUN8OEGTyYFXgtSACeLISVMo72jUR6q9Gdb/fX35Rfi+2lJtQWK8pHCRJ9i35a0HXxPM5b7j2JV10VQh+0fAaCmiLWiLj9NrfrJjw200YpbkNVofoVXt2L9FSqEFQigdI9jMFdbOv2c8F2LDayJXTny8wflxoYgxe9OMmA== 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=wny8nbFzMuwNBi9IwJhOKNvnnz1x4iA/E1KTavC0zNo=; b=pd1IsmROQZmSdpEvsEECfLw7xjyfL64aA/IftHR1HI9suuVN7yn8hALcrZVe8FQW4Dse41bW8yQd1NLFMI2nIuu0cVJfWSsVk7BIDt685kZFyGoNgfIEqLEHKfZoyV7gHCgPItaAo867rIPB8LJ5SDfDb3Bs0Gol9EdCjgAg07W+Epsa0gMWH83sJdG9ehEa3kLESCWv4JYjHQhd2hCVE3WhUff9QBQt5WJQKFN8ws7VOqaz7AhUdY0HCuGIY2ADXMZjJmz575ulObXXxBNdxh+Kaa5XKoM6I05uJZkK7dzGWR/KyN+FheZyMilspq8wZzrIOdMi7B9p1jh0DkU6xA== 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=wny8nbFzMuwNBi9IwJhOKNvnnz1x4iA/E1KTavC0zNo=; b=E0XsaV8c8Qg3AL0fDSVHwxXIhZW5u3ISPMiE6k4vrOg08D/ZAGl2VrL7AXQA98xm247mj7Ijtx4v9IoMukK03guAoN33mfYKQ/v00LwHgNUlVaba2eBz68LUv3KlHcySbtK6yWXIub6HF12eoyqqPcPuePAuE5ZP3lruiHWTP6w= Received: from SN6PR04CA0085.namprd04.prod.outlook.com (2603:10b6:805:f2::26) by SA1PR12MB6773.namprd12.prod.outlook.com (2603:10b6:806:258::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8137.19; Sat, 9 Nov 2024 04:42:19 +0000 Received: from SN1PEPF00026368.namprd02.prod.outlook.com (2603:10b6:805:f2:cafe::5d) by SN6PR04CA0085.outlook.office365.com (2603:10b6:805:f2::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8137.21 via Frontend Transport; Sat, 9 Nov 2024 04:42:19 +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 SN1PEPF00026368.mail.protection.outlook.com (10.167.241.133) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8137.17 via Frontend Transport; Sat, 9 Nov 2024 04:42:19 +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; Fri, 8 Nov 2024 22:42:17 -0600 From: Mario Limonciello To: Hans de Goede , =?utf-8?q?Ilpo_J=C3=A4rvinen?= CC: "Rafael J . Wysocki" , Len Brown , Maximilian Luz , Lee Chun-Yi , "Shyam Sundar S K" , Corentin Chary , "Luke D . Jones" , Ike Panhc , Henrique de Moraes Holschuh , "Alexis Belmonte" , =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= , Ai Chao , Gergo Koteles , open list , "open list:ACPI" , "open list:MICROSOFT SURFACE PLATFORM PROFILE DRIVER" , "open list:THINKPAD ACPI EXTRAS DRIVER" , Mark Pearson , Matthew Schwartz , Mario Limonciello , Armin Wolf Subject: [PATCH v6 01/22] ACPI: platform-profile: Add a name member to handlers Date: Fri, 8 Nov 2024 22:41:30 -0600 Message-ID: <20241109044151.29804-2-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241109044151.29804-1-mario.limonciello@amd.com> References: <20241109044151.29804-1-mario.limonciello@amd.com> Precedence: bulk X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SN1PEPF00026368:EE_|SA1PR12MB6773:EE_ X-MS-Office365-Filtering-Correlation-Id: c4a4f915-34dc-41a1-b7f0-08dd0078e510 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|376014|7416014|1800799024|82310400026|36860700013; X-Microsoft-Antispam-Message-Info: =?utf-8?q?6Re/2DK9ne2G+z3tNC8C0MC8xgfn0ua?= =?utf-8?q?XXwRyyJZsm7Z8dqQodMVf39MLQIA8fTEgGE9oDAttQmv8h048LdFleXINwVDAXCDS?= =?utf-8?q?JPapn8apibdiqFpIRrolw+qYhPXqtecxKBLIr3bUcMthRTsIwixvRIfPlxcMUEpYf?= =?utf-8?q?Jk8uUAvFGKB1YAo9J5DFx5EvN+Ul2Gr30mMyLuaI+X0Jmdbz0UZ94ktMcTPTsxaWW?= =?utf-8?q?damudBVnjN2mEhDnOPfZxFDpOVymtYINY1Gl/Ek+nPB3qn8V+SisnMd9/F5wH+ck4?= =?utf-8?q?XbpWu/21OSQ7/nGJ3DN3y7mOOVvsJkF4zALQ+ZL+FKWXea7Zr0/vkOElHKH231g1H?= =?utf-8?q?WPuz47j93UbIqr6HuN1M/V9pbHyvYUFwGAm1lkuE3RE8CUc1wczzNOyTSBeOVGtFa?= =?utf-8?q?jacnl2c9iCTsdfm96IUN5CqM3eQWs/V4iySEakoryajkv/at6AU1DX6ImNIY7r0oZ?= =?utf-8?q?KrOxtDSir5DwLG1eAkslDVA2IkHEMfskPBPnjeRBCtWY9r6MkODuBibKEYhUSZaKa?= =?utf-8?q?HmQb98VwN6zi2JF4lEH4p3q9YQNYpHUSp3664hZQe1nJj7xQdZgRP3laafCrR2hIS?= =?utf-8?q?X4o3I5aQWqaiMEITVXVBfE3tKPeYV3Sky5WyjilGzuPAuywzSCe1shL8vQAJ4fwOJ?= =?utf-8?q?9vaNB1+FY36Rrcbx6stsVH6GFuPWs7CrsGoPHBgKCtRZEDGncRzksPVtxJ+kpTmcB?= =?utf-8?q?dIzZ3HVEOiHH8ruMhb1895mQphA7BbeIQzKoL1tXrj7iRb5sWJvbiFg/6j3w9kCYW?= =?utf-8?q?+unNvIsDj9cJ+GPGd9wFsPBXqVGnFIsOmFVWSQKkXcTL71GrhelIL1M4fO6l03bxG?= =?utf-8?q?ORIqIUPp5glybB1T5xWb8+ldvpvaxCs43f4s397H3W0EXd2brwFzuuOXqSOqzbNMy?= =?utf-8?q?P1QzOlumOKgQQ4m9MGRyAHYGbwLM4u6PjvGyygxIiJdukzNmM1llPOhsSoZiOmC3y?= =?utf-8?q?avT5W9RUjG7kisq/G3J/LP1xkqxX0Sqhaj7Z625vYIjVR0NQWYnXtG3TE9WOLmT5Z?= =?utf-8?q?cQ4xU4XOZgUclhB8+CCI+V8zhfKSBVAnmF6nkOTHZu1h/wGWQH3Fs1msswrfxaiFY?= =?utf-8?q?1PXxtFSraDZvsCXNzYPwfAZApkV2E+QAWsJWM8H636RwKeFyOuCeZfHN/uEmV1iSY?= =?utf-8?q?9SmnMZEsVrGEVpV5Ra+Nl4FCe8VvR/ClZgHTjKxLAAcYBJSphUZbOKQq3KoEsM0np?= =?utf-8?q?uvUBnt+rjdW8j4QYLeQYoFeQBcWFCyJLQU5o6UFd88SdXFlr+gY7O/ebHHatcJ+2y?= =?utf-8?q?a2rWYYFdBlw3HOlhlZOuq/l/SEGUmNEllA4P4HYMo6mtnDRkHTlIBIVtTZONvQ115?= =?utf-8?q?VLKvi6NFaBnQf3O6W3GTfkseHpZgrfQJow=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)(1800799024)(82310400026)(36860700013); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Nov 2024 04:42:19.4694 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c4a4f915-34dc-41a1-b7f0-08dd0078e510 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: SN1PEPF00026368.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR12MB6773 In order to prepare for allowing multiple handlers, introduce a name field that can be used to distinguish between different handlers. Tested-by: Mark Pearson Tested-by: Matthew Schwartz Reviewed-by: Hans de Goede Reviewed-by: Mark Pearson Reviewed-by: Maximilian Luz Reviewed-by: Ilpo Järvinen Reviewed-by: Armin Wolf Signed-off-by: Mario Limonciello --- 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(+) base-commit: d68cb6023356af3bd3193983ad4ec03954a0b3e2 diff --git a/drivers/platform/surface/surface_platform_profile.c b/drivers/platform/surface/surface_platform_profile.c index 3de864bc66108..61aa488a80eb5 100644 --- a/drivers/platform/surface/surface_platform_profile.c +++ b/drivers/platform/surface/surface_platform_profile.c @@ -211,6 +211,7 @@ static int surface_platform_profile_probe(struct ssam_device *sdev) tpd->sdev = sdev; + tpd->handler.name = "Surface Platform Profile"; tpd->handler.profile_get = ssam_platform_profile_get; tpd->handler.profile_set = ssam_platform_profile_set; diff --git a/drivers/platform/x86/acer-wmi.c b/drivers/platform/x86/acer-wmi.c index d09baa3d3d902..53fbc9b4d3df7 100644 --- a/drivers/platform/x86/acer-wmi.c +++ b/drivers/platform/x86/acer-wmi.c @@ -1878,6 +1878,7 @@ static int acer_platform_profile_setup(void) if (quirks->predator_v4) { int err; + platform_profile_handler.name = "acer-wmi"; platform_profile_handler.profile_get = acer_predator_v4_platform_profile_get; platform_profile_handler.profile_set = diff --git a/drivers/platform/x86/amd/pmf/sps.c b/drivers/platform/x86/amd/pmf/sps.c index 92f7fb22277dc..e2d0cc92c4396 100644 --- a/drivers/platform/x86/amd/pmf/sps.c +++ b/drivers/platform/x86/amd/pmf/sps.c @@ -405,6 +405,7 @@ int amd_pmf_init_sps(struct amd_pmf_dev *dev) amd_pmf_set_sps_power_limits(dev); } + dev->pprof.name = "amd-pmf"; dev->pprof.profile_get = amd_pmf_profile_get; dev->pprof.profile_set = amd_pmf_profile_set; diff --git a/drivers/platform/x86/asus-wmi.c b/drivers/platform/x86/asus-wmi.c index 2ccc23b259d3e..c7c104c65a85a 100644 --- a/drivers/platform/x86/asus-wmi.c +++ b/drivers/platform/x86/asus-wmi.c @@ -3910,6 +3910,7 @@ static int platform_profile_setup(struct asus_wmi *asus) dev_info(dev, "Using throttle_thermal_policy for platform_profile support\n"); + asus->platform_profile_handler.name = "asus-wmi"; asus->platform_profile_handler.profile_get = asus_wmi_platform_profile_get; asus->platform_profile_handler.profile_set = asus_wmi_platform_profile_set; diff --git a/drivers/platform/x86/dell/alienware-wmi.c b/drivers/platform/x86/dell/alienware-wmi.c index a800c28bb4d51..ac0038afd98fa 100644 --- a/drivers/platform/x86/dell/alienware-wmi.c +++ b/drivers/platform/x86/dell/alienware-wmi.c @@ -1056,6 +1056,7 @@ static int create_thermal_profile(void) pp_handler.profile_get = thermal_profile_get; pp_handler.profile_set = thermal_profile_set; + pp_handler.name = "alienware-wmi"; return platform_profile_register(&pp_handler); } diff --git a/drivers/platform/x86/dell/dell-pc.c b/drivers/platform/x86/dell/dell-pc.c index 972385ca1990b..3cf79e55e3129 100644 --- a/drivers/platform/x86/dell/dell-pc.c +++ b/drivers/platform/x86/dell/dell-pc.c @@ -247,6 +247,7 @@ static int thermal_init(void) thermal_handler = kzalloc(sizeof(*thermal_handler), GFP_KERNEL); if (!thermal_handler) return -ENOMEM; + thermal_handler->name = "dell-pc"; thermal_handler->profile_get = thermal_platform_profile_get; thermal_handler->profile_set = thermal_platform_profile_set; diff --git a/drivers/platform/x86/hp/hp-wmi.c b/drivers/platform/x86/hp/hp-wmi.c index 81ccc96ffe40a..26cac73caf2b9 100644 --- a/drivers/platform/x86/hp/hp-wmi.c +++ b/drivers/platform/x86/hp/hp-wmi.c @@ -1624,6 +1624,7 @@ static int thermal_profile_setup(void) set_bit(PLATFORM_PROFILE_COOL, platform_profile_handler.choices); } + platform_profile_handler.name = "hp-wmi"; set_bit(PLATFORM_PROFILE_BALANCED, platform_profile_handler.choices); set_bit(PLATFORM_PROFILE_PERFORMANCE, platform_profile_handler.choices); diff --git a/drivers/platform/x86/ideapad-laptop.c b/drivers/platform/x86/ideapad-laptop.c index 9d8c3f064050e..1f94c14c3b832 100644 --- a/drivers/platform/x86/ideapad-laptop.c +++ b/drivers/platform/x86/ideapad-laptop.c @@ -1102,6 +1102,7 @@ static int ideapad_dytc_profile_init(struct ideapad_private *priv) mutex_init(&priv->dytc->mutex); + priv->dytc->pprof.name = "ideapad-laptop"; priv->dytc->priv = priv; priv->dytc->pprof.profile_get = dytc_profile_get; priv->dytc->pprof.profile_set = dytc_profile_set; diff --git a/drivers/platform/x86/inspur_platform_profile.c b/drivers/platform/x86/inspur_platform_profile.c index 8440defa67886..03da2c8cf6789 100644 --- a/drivers/platform/x86/inspur_platform_profile.c +++ b/drivers/platform/x86/inspur_platform_profile.c @@ -177,6 +177,7 @@ static int inspur_wmi_probe(struct wmi_device *wdev, const void *context) priv->wdev = wdev; dev_set_drvdata(&wdev->dev, priv); + priv->handler.name = "inspur-wmi"; priv->handler.profile_get = inspur_platform_profile_get; priv->handler.profile_set = inspur_platform_profile_set; diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c index 4c1b0553f8720..c8c316b8507a5 100644 --- a/drivers/platform/x86/thinkpad_acpi.c +++ b/drivers/platform/x86/thinkpad_acpi.c @@ -10549,6 +10549,7 @@ static void dytc_profile_refresh(void) } static struct platform_profile_handler dytc_profile = { + .name = "thinkpad-acpi", .profile_get = dytc_profile_get, .profile_set = dytc_profile_set, }; diff --git a/include/linux/platform_profile.h b/include/linux/platform_profile.h index f5492ed413f36..6fa988e417428 100644 --- a/include/linux/platform_profile.h +++ b/include/linux/platform_profile.h @@ -27,6 +27,7 @@ enum platform_profile_option { }; struct platform_profile_handler { + const char *name; unsigned long choices[BITS_TO_LONGS(PLATFORM_PROFILE_LAST)]; int (*profile_get)(struct platform_profile_handler *pprof, enum platform_profile_option *profile); From patchwork Sat Nov 9 04:41:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 842127 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2047.outbound.protection.outlook.com [40.107.220.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 3FE8F13B58F; Sat, 9 Nov 2024 04:42:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.220.47 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731127347; cv=fail; b=OU4vPXbF1t/c/6KK3k09O90QY8WmAwrdSqCBSjgWg8awSfYWQgSPFIlQcJqwvcKkTXaESf3kjwHKBW8P2JkG+W8kO2SRRExaFzsddIcRkH28eBBPWfZEd35jygA5/c/5fGp1V5SndsPRTL8J8EgjxenpDk3JmpqT6q91t7Soa74= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731127347; c=relaxed/simple; bh=gVOFZQ1NkY8btPf86/D8ZFqsha0+GCMWANbhEBwFGl4=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=iqjMfeAbJtiEof8fKWdwN7Li8BiT97OKO/E4P0bntBjOt5Es4Bt2lYGF3AOMfLPefdiDTOUWZ/xQ3exu9QkZEKNLjlSJKz8o+WG9gjwQoI25mnaV3fxgvW7d9fhjevAeYb/upJSAnXo11Y9AWP+OcTYeXdF2SEbIU++Ny87Q6uc= 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=gxhR+9EE; arc=fail smtp.client-ip=40.107.220.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="gxhR+9EE" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=msLyqs/qwJ+t67xCTooBZTO0i1Dj2mNUtFhCphlhcpymURlyCg/5NGdf/cjpQygMoV69hZv6o7B74eAd2J5QzQ1U4izZa+JrBq1q3ajM/vDpY6SLvYVvhODstAujfaTf1m/h7lgW9y2kaXcDfls4gNKqueLvI4sHU9kHot0iO45Y0FtaSvoC85tDdN80aPAB1PdOQad0uMPCqDSEwp38Q+nB93Ua5L7VvM2TlXI8rEe7GiV+IdQMQud3rP2VPOVjVpOh3Y0GmX29WxoMLGnoA06n+rVzXcpM9cNobuG22CyXX6Mj/MnkXm3uj+sv/Z6PXnsuLls0fUz3UkYxnPzw9g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=Rcake+aW7InzlrriCA9veWw0Iv9E+pdMZvM9w0hzudg=; b=Kjn8nX075WczG/ajkATFpyA2YrfBC/rgVYgf7/8auehgG196cnsfqlR6CotHTeJNS1RUTdnjulFG3ZBVJ6+BnXuve7/KW8YJ1DvK+MdHDsiKBJregOk7rjfnbdKR4lSNQCLNnbBcaEmxjO1z7ctpP7pXVUiLHVcgr6HyTs9JJmkd9n2De4mbhxYUw2cChZxCKKxvVOBNwb4/x2JEeuA1ztWi+ch0ZV1H7K8NoHeJ4orc9JwIM9GrPXIJRiNPTb8phk9R9xWqF6FKaX9yVt12jwSasp0ikcL4PfwVrdDfGCtuXsGG9hWKEY+yJ0dbQeXvXMoD/kCQVqpOqTSnteAnxQ== 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=Rcake+aW7InzlrriCA9veWw0Iv9E+pdMZvM9w0hzudg=; b=gxhR+9EE/24lXBODQeRVvoRJHYhjNi1iwY3YtQq89qmH/hh2VvQ6npfUKlKnL3SzjWVvs+VNeEd6tJi86CxlL8WmTbXVBzCDP2njjrR9ngpbPpzMcD5qXv1rcCZfGTtMpQuDldrds7GyjNObmqGJj5REehwM1sGb74RwD9FnU4E= Received: from SN6PR04CA0079.namprd04.prod.outlook.com (2603:10b6:805:f2::20) by PH8PR12MB6723.namprd12.prod.outlook.com (2603:10b6:510:1ce::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8137.19; Sat, 9 Nov 2024 04:42:21 +0000 Received: from SN1PEPF00026368.namprd02.prod.outlook.com (2603:10b6:805:f2:cafe::ea) by SN6PR04CA0079.outlook.office365.com (2603:10b6:805:f2::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8137.21 via Frontend Transport; Sat, 9 Nov 2024 04:42:21 +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 SN1PEPF00026368.mail.protection.outlook.com (10.167.241.133) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8137.17 via Frontend Transport; Sat, 9 Nov 2024 04:42:21 +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; Fri, 8 Nov 2024 22:42:19 -0600 From: Mario Limonciello To: Hans de Goede , =?utf-8?q?Ilpo_J=C3=A4rvinen?= CC: "Rafael J . Wysocki" , Len Brown , Maximilian Luz , Lee Chun-Yi , "Shyam Sundar S K" , Corentin Chary , "Luke D . Jones" , Ike Panhc , Henrique de Moraes Holschuh , "Alexis Belmonte" , =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= , Ai Chao , Gergo Koteles , open list , "open list:ACPI" , "open list:MICROSOFT SURFACE PLATFORM PROFILE DRIVER" , "open list:THINKPAD ACPI EXTRAS DRIVER" , Mark Pearson , Matthew Schwartz , Mario Limonciello , Armin Wolf Subject: [PATCH v6 02/22] platform/x86/dell: dell-pc: Create platform device Date: Fri, 8 Nov 2024 22:41:31 -0600 Message-ID: <20241109044151.29804-3-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241109044151.29804-1-mario.limonciello@amd.com> References: <20241109044151.29804-1-mario.limonciello@amd.com> Precedence: bulk X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SN1PEPF00026368:EE_|PH8PR12MB6723:EE_ X-MS-Office365-Filtering-Correlation-Id: f9a8936d-63ad-4755-721b-08dd0078e60d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|36860700013|376014|7416014|82310400026|1800799024; X-Microsoft-Antispam-Message-Info: =?utf-8?q?hobeLkt8zmdEH8jw+DUW9mOOOkFmB9B?= =?utf-8?q?h7RaDB6OXTSo6YQk4Zdvv9eBGGgM9QrsaaJYyi4zaFfEIqGxd80oBdv/sl+C9DmmZ?= =?utf-8?q?lpMwjItboocNZ5QtgbAcnwW2Ki9hAko8vu6wkdyaezX0DreyBwPrB/fT6q/MNZoqC?= =?utf-8?q?xK6D4Mo+6mrHABRkDxUG+tLOGqijF3roloTL8eBTCryBfEARqo9/WuWMemyd78dw9?= =?utf-8?q?BGd99+Ja4R1mIMdbZMyp3vuWkZ5WtUy9DsF/XIzbr4vHcR0bwA+cZQmBNUXnnCpey?= =?utf-8?q?DBYpvA9AQQ8JqYpGZj0lSuUimhkRxdVFqnEFBnXjXMXRHz6qnWjT1BqKPUhceDmCw?= =?utf-8?q?yn8y1bCtyo7+VB3FNqGno3Px8p75rAYBO5JlRcjqJEcSmwfsRbcLki0hRIjaHiXem?= =?utf-8?q?bMU1Wle1SbQ74YuD8hIabPEquxQcsf6yf2vSECj+lbNOKAIEmtT79tv3xDlZmyhrG?= =?utf-8?q?gCDRwT2A0KZvImLIXFBScJZTHfLAvL4jTFnkQF1Y5GWUxzJ5Zb1UgOV1EMS60Yoh7?= =?utf-8?q?SJCr7lIGt7To3qGqJvnzQyRgJqP30HP+qAF81dSpaDY4uFs7Zx6IV9BFcKbPIdO2b?= =?utf-8?q?UaJBAHBURb9xnNv/9Nhq1UhCKichPwSZ1gdg3qz7ZVMg43btp/kQiVpWtzJh/4DwB?= =?utf-8?q?KTQzf3JDdshlc5aP8ChKCvaNiU1edUZgXJZ5gofhCN8xiNMobsWt5sFiicSeEa99r?= =?utf-8?q?E3NO4BPbJAQ4qiKfFB++9XcpPaE0RXkGc2CMIgPKDVWJT3yPNSwoRbEMkcUmTjqvQ?= =?utf-8?q?UZ9Yyh6z2uRB2xa92qNa17tHuFkYyawgPC6ErTI5k+IFg9XhH2/QpwxH6dyfxIHn/?= =?utf-8?q?RJ43OBG+lCPx4C5JP8pvS5K/Tw2PWVMiKsQx3SGPzUQGsORIGXEGodnuN7h2NI10f?= =?utf-8?q?UHq7/ox8Wi4PaQagWuZ6mgYWf8PbXEY8igorNZi/yvMEXFAjm4PMp1RflogYag+P3?= =?utf-8?q?7FflOn0foBwgt6YNSHlSyx96ybrN/wsAKIrjW/LR3ctuLFRyLI/F1Wg/ObwhFHBR6?= =?utf-8?q?nG0IgrWbvH4e5Gu/orHl3pOOueD1r9wUzyz0s/dCGKjK/OCk4YFbr/XEz70Py4qwA?= =?utf-8?q?psC6KeyBOktxYR3zvDHKIVQbCYUcI0OIM7+NYN0EVEuqFR/ZFXmSSLTrGtZyv7A6A?= =?utf-8?q?8ZX6A+Pa4gvCCvKLhSyC0CArsoFqY8i1muBSDBEyr2B76w4DflUQEh6FOQ1C8jfkr?= =?utf-8?q?ZmGK0tLyLro3TnqPGmWJkc41JrOEhHqWjpYC0KrpGfwTjAOrYxpD5fjeKlKPkLGDo?= =?utf-8?q?4dqLHLOFsyWHAU7jKXrlOEfAsboLJ/lPHDqsoNRrSiKz57qo0OAhzAXBvlFMlkyUG?= =?utf-8?q?+V9jRcPQvcl0KQgsQ8CncdQ88VnPu+UuZw=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)(376014)(7416014)(82310400026)(1800799024); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Nov 2024 04:42:21.1257 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f9a8936d-63ad-4755-721b-08dd0078e60d 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: SN1PEPF00026368.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH8PR12MB6723 In order to have a device for the platform profile core to reference create a platform device for dell-pc. While doing this change the memory allocation for the thermal handler to be device managed to follow the lifecycle of that device. Reviewed-by: Armin Wolf Tested-by: Mark Pearson Reviewed-by: Ilpo Järvinen Signed-off-by: Mario Limonciello --- v6: * Use PLATFORM_DEVID_NONE (Armin) v5: * use platform_device_register_simple() --- drivers/platform/x86/dell/dell-pc.c | 32 +++++++++++++++++++++-------- 1 file changed, 23 insertions(+), 9 deletions(-) diff --git a/drivers/platform/x86/dell/dell-pc.c b/drivers/platform/x86/dell/dell-pc.c index 3cf79e55e3129..805497e44b3a5 100644 --- a/drivers/platform/x86/dell/dell-pc.c +++ b/drivers/platform/x86/dell/dell-pc.c @@ -18,10 +18,13 @@ #include #include #include +#include #include #include "dell-smbios.h" +static struct platform_device *platform_device; + static const struct dmi_system_id dell_device_table[] __initconst = { { .ident = "Dell Inc.", @@ -244,9 +247,15 @@ static int thermal_init(void) if (!supported_modes) return 0; - thermal_handler = kzalloc(sizeof(*thermal_handler), GFP_KERNEL); - if (!thermal_handler) + platform_device = platform_device_register_simple("dell-pc", PLATFORM_DEVID_NONE, NULL, 0); + if (!platform_device) return -ENOMEM; + + thermal_handler = devm_kzalloc(&platform_device->dev, sizeof(*thermal_handler), GFP_KERNEL); + if (!thermal_handler) { + ret = -ENOMEM; + goto cleanup_platform_device; + } thermal_handler->name = "dell-pc"; thermal_handler->profile_get = thermal_platform_profile_get; thermal_handler->profile_set = thermal_platform_profile_set; @@ -262,20 +271,25 @@ static int thermal_init(void) /* Clean up if failed */ ret = platform_profile_register(thermal_handler); - if (ret) { - kfree(thermal_handler); - thermal_handler = NULL; - } + if (ret) + goto cleanup_thermal_handler; + + return 0; + +cleanup_thermal_handler: + thermal_handler = NULL; + +cleanup_platform_device: + platform_device_unregister(platform_device); return ret; } static void thermal_cleanup(void) { - if (thermal_handler) { + if (thermal_handler) platform_profile_remove(); - kfree(thermal_handler); - } + platform_device_unregister(platform_device); } static int __init dell_init(void) From patchwork Sat Nov 9 04:41:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 842756 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2062.outbound.protection.outlook.com [40.107.237.62]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B8EFB13BC35; Sat, 9 Nov 2024 04:42:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.237.62 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731127348; cv=fail; b=QW5IvibyokjQp/iqM88j+Rz8mh1PKFXGau+zi2bNuamYNgYFWM4icxkpEaYZAPO7CLdMQpSJkr6YBF62dEPeuE5kt5j/1pzpRA9gJAFDvJKaAAMuWq9NYpBMkdycUCXylnS4gs6Dthcw0iEdDTF2JEu9/g+83pDC5gcheU7TMJE= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731127348; c=relaxed/simple; bh=pmiwS7Cn2IBK/mY0my8lyXOxLznshvN34Vbg+Yax69E=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=bxE7mv5qgH9tFe41uoc42DpVFYK5tuIjKvrGqj55UBGdfvwr9kTJwE8JSMF6NGIybkp4P0lWfsrKzbce4N689rAEv99DmBRLu3CqHs4owH3TrBesRejsB+Sewm8DkcsWBnUqp8KW+ijKNBtfOU9Az7+kVV0uoldOoPDSgtzCBhY= 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=1jfRtubs; arc=fail smtp.client-ip=40.107.237.62 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="1jfRtubs" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=ErQS7Yfojhgdc9E3RIVonDjZYOIVJ8P/VDlhCwOhI0afUC17rgYXwyDSA2cj8YrKXroMrwvtJSsOBr8KcqxFI5wmil8hkX62ift6x/SLbbD8hfBTHIFF0Mc8lWbN3NcTMx9B/FcucKyagjbHRUALOL+29lgDJCyDA/HnojJyKctm/Vx+pkFlDzpBhttsPilNXCY/3993OunqrOhAmGGIl1C0E4HjagdPV6hiXorzh2nYjrPZPrcE3/00p1wipyFyaCof881/SzEsubtetQufw/ij8zj/RR5xHwLYqXXdo+Kw0wMWeZF9eK7qmnrrX3tx7s5D3PWJM0MYKsM0gp5rLA== 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=1RTcnTJSuJrspg9JmB8gQxmk+Ggi8y5bR2Vd3IBVqP8=; b=R2gG5N7CiSB5q+T7tgvMBr4d7gdbUP+y91gwdkHMN+QOfqKzSEPGAURpGtE/ZJUP/oSmU4aD95SOLun/au3DmkhJpHRvBjHoUb+k+qAUONk5d2S4B0gmBq6bZMhXAgXGTWKw238dbZ5pETFaFVWSnzOjeeUuIgPir5HwUX2ORFEBXbFoBPMA8+6zoe6OnXyOu/9xfqpDeuMTEFUDSpS0n2x42BWayXOc9A3yXIhYGJ909Nv2k8JnPFqyTyvdDbE+jcHzWr0T3kSGI1vz3QLV5L45HdoBCsqYyVXQBMAIdLqNr+BNsNqCxEa+FhE/tvvbS93yJJmLZOJREZXWu3gh/w== 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=1RTcnTJSuJrspg9JmB8gQxmk+Ggi8y5bR2Vd3IBVqP8=; b=1jfRtubsRMeitUgTTU5dKoFX7OlBndbD492RlYV4/7oeiU5b9ug6JLp1yvpHHrN1LR/FNlu3bWmcG9lb7AQbaEHYLL5XzNFWzVtnTucFlkEOhOGL1TU7XLfCdD/+uDIr5a2+u6HtDJgIfhetJ6pErtKOBudZy9zsRX0thQhfu3I= Received: from SN4PR0501CA0037.namprd05.prod.outlook.com (2603:10b6:803:41::14) by DS0PR12MB9347.namprd12.prod.outlook.com (2603:10b6:8:193::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8137.19; Sat, 9 Nov 2024 04:42:23 +0000 Received: from SN1PEPF00026369.namprd02.prod.outlook.com (2603:10b6:803:41:cafe::e5) by SN4PR0501CA0037.outlook.office365.com (2603:10b6:803:41::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.12 via Frontend Transport; Sat, 9 Nov 2024 04:42:23 +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 SN1PEPF00026369.mail.protection.outlook.com (10.167.241.134) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8137.17 via Frontend Transport; Sat, 9 Nov 2024 04:42:22 +0000 Received: from AUS-P9-MLIMONCI.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Fri, 8 Nov 2024 22:42:20 -0600 From: Mario Limonciello To: Hans de Goede , =?utf-8?q?Ilpo_J=C3=A4rvinen?= CC: "Rafael J . Wysocki" , Len Brown , Maximilian Luz , Lee Chun-Yi , "Shyam Sundar S K" , Corentin Chary , "Luke D . Jones" , Ike Panhc , Henrique de Moraes Holschuh , "Alexis Belmonte" , =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= , Ai Chao , Gergo Koteles , open list , "open list:ACPI" , "open list:MICROSOFT SURFACE PLATFORM PROFILE DRIVER" , "open list:THINKPAD ACPI EXTRAS DRIVER" , Mark Pearson , Matthew Schwartz , Mario Limonciello Subject: [PATCH v6 03/22] ACPI: platform_profile: Add device pointer into platform profile handler Date: Fri, 8 Nov 2024 22:41:32 -0600 Message-ID: <20241109044151.29804-4-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241109044151.29804-1-mario.limonciello@amd.com> References: <20241109044151.29804-1-mario.limonciello@amd.com> Precedence: bulk X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SN1PEPF00026369:EE_|DS0PR12MB9347:EE_ X-MS-Office365-Filtering-Correlation-Id: e1d0c419-f69c-4334-8b46-08dd0078e700 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: =?utf-8?q?qbBbpqO5YGIf507826HFI5qhjeZaqVK?= =?utf-8?q?PGZvy687L8JjCctOrBGTPRO2izboG/s6fjdTrMBc0j6FcEzVKHFh1723ol8to7kG1?= =?utf-8?q?aOja9rYQ3ZCTJKrrGf/lMRDeLvnEDO/dGBcRb3/M/rCE7q9pFGCpUbkF+RPIh5nA9?= =?utf-8?q?RFZquKciIO1l4oLLPjAoyk0UzEXOaWTsisJHrn7oDMXaGzzssvBB7A0++2InozqTG?= =?utf-8?q?6xZ6s4ahhPVdILLuJ8a/E89gv70Tu/7TmhVr0BHPN5LXJUOOrPhHin4CpF0jUUmdI?= =?utf-8?q?41Us0zX0uPkAIMMPBMQIb4l5jVBLr3/v0g213tJpNpFDTahV1rja1rHxTazPxIvP+?= =?utf-8?q?xFJb/4bnxZ/oc8uDUROUVx5OY9cqERMYCRe3pxSzk7kGRlDSWDPxIGdi4a/SaqOde?= =?utf-8?q?z+z7Rsv595lmTfNJ3fGXDBPSp0evgoNk2Wsy58jM8Ke7LbFRFRpEdnGrP6O+WsPnU?= =?utf-8?q?zv9a24X4FGzD5lt0SAbRCHxUi6dM6eQm5BhVO9GUg9cQYNWHzDSnVRn7IE8MmdNgZ?= =?utf-8?q?9AS+r9OD/euFGcMXyE5IhrX7FRrrtfLH+nxub0tgt5WT1ZCtWaQ+rukmioIQoz1c8?= =?utf-8?q?HpRqCsxmEPMfb7/u8al/j/kwIvfG72qZj15Uwu9kHD1H80g16UPbqx+5WY44jOhUs?= =?utf-8?q?fk2lx6HaSum6/IF49u3NOq6BeGa6LbtaotBk7LlFDqmluA/C5dSeXGZPN4i6BfhuY?= =?utf-8?q?ku+hgxr6RmrEg+sysBcWN4GyhPyhVydctY4JezbTLDyKRKvO7ViNfoq5hHD3RCHJW?= =?utf-8?q?0ZIhFVRTYTbmBSn7fUFSjTchyA7/lZJPlsXIH6/V7gk4v4/6Tx2xoGyvaFm74kN/d?= =?utf-8?q?akM+dm0cVSmpflE3ozW3jZCpCvEPBQ+CsxBfiwTTuVh0HcgkFsD7E8IZR3AqppSyu?= =?utf-8?q?abp5gRp6xm6WLau/AHouyalQ2SiIGm5Td207k9Z+X6bhjc4dvWVapeLvbnBI/HsdX?= =?utf-8?q?nroaXTJYYdT+BeLMIoC/BzoB5I288JNLeK0I/RMNDCFTqDyqDMmLP+oNjAiO6kln7?= =?utf-8?q?p1Uqz2mogTagd9lcfeUV9k5mBCV0CrwvSFff6EY7RX+vQTuOzwU4Ag3UZ/TMYIdNH?= =?utf-8?q?3iIh8ehiCTFa+CtpXjHc97gOSaYk16uTDXC/eyaiRmMvwzvWKiVVZHP1JSBwm7d/L?= =?utf-8?q?BS7L8jspDpf4Ib5l0WJepVKFY+dRH8TBPEWQ2XHhka9m2vTNGM0eia+uj/o11zpyr?= =?utf-8?q?W8L11aBPE5iO/HCV9zEaFaZbpAz03vuTm9bXD8Mj6jqmFP7p6+6LKaoOK3Iu0Hxz8?= =?utf-8?q?vlwwPQZ8kEhpi8/BMRNhKhqRO6eTbVEYhamAuIYuse2gZ46U7zTQoWdfiqxhpFpKT?= =?utf-8?q?Cg8Lm6llxHf8uKwQXl7JmKEmFjSj8fZwlA=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: 09 Nov 2024 04:42:22.7345 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e1d0c419-f69c-4334-8b46-08dd0078e700 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: SN1PEPF00026369.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR12MB9347 In order to let platform profile handlers manage platform profile for their driver the core code will need a pointer to the device. Add this to the structure and use it in the trivial driver cases. Reviewed-by: Ilpo Järvinen Reviewed-by: Maximilian Luz Reviewed-by: Mark Pearson Signed-off-by: Mario Limonciello Reviewed-by: Armin Wolf --- v6: * Don't require to be set v4: * add alienware-wmi too --- drivers/platform/surface/surface_platform_profile.c | 1 + drivers/platform/x86/acer-wmi.c | 5 +++-- drivers/platform/x86/amd/pmf/sps.c | 1 + drivers/platform/x86/asus-wmi.c | 1 + drivers/platform/x86/dell/alienware-wmi.c | 5 +++-- drivers/platform/x86/dell/dell-pc.c | 1 + drivers/platform/x86/hp/hp-wmi.c | 5 +++-- drivers/platform/x86/ideapad-laptop.c | 1 + drivers/platform/x86/inspur_platform_profile.c | 1 + drivers/platform/x86/thinkpad_acpi.c | 1 + include/linux/platform_profile.h | 1 + 11 files changed, 17 insertions(+), 6 deletions(-) diff --git a/drivers/platform/surface/surface_platform_profile.c b/drivers/platform/surface/surface_platform_profile.c index 61aa488a80eb5..5f45f8e8cd69b 100644 --- a/drivers/platform/surface/surface_platform_profile.c +++ b/drivers/platform/surface/surface_platform_profile.c @@ -212,6 +212,7 @@ static int surface_platform_profile_probe(struct ssam_device *sdev) tpd->sdev = sdev; tpd->handler.name = "Surface Platform Profile"; + tpd->handler.dev = &sdev->dev; tpd->handler.profile_get = ssam_platform_profile_get; tpd->handler.profile_set = ssam_platform_profile_set; diff --git a/drivers/platform/x86/acer-wmi.c b/drivers/platform/x86/acer-wmi.c index 53fbc9b4d3df7..aca4a5746bee1 100644 --- a/drivers/platform/x86/acer-wmi.c +++ b/drivers/platform/x86/acer-wmi.c @@ -1873,12 +1873,13 @@ acer_predator_v4_platform_profile_set(struct platform_profile_handler *pprof, return 0; } -static int acer_platform_profile_setup(void) +static int acer_platform_profile_setup(struct platform_device *device) { if (quirks->predator_v4) { int err; platform_profile_handler.name = "acer-wmi"; + platform_profile_handler.dev = &device->dev; platform_profile_handler.profile_get = acer_predator_v4_platform_profile_get; platform_profile_handler.profile_set = @@ -2531,7 +2532,7 @@ static int acer_platform_probe(struct platform_device *device) goto error_rfkill; if (has_cap(ACER_CAP_PLATFORM_PROFILE)) { - err = acer_platform_profile_setup(); + err = acer_platform_profile_setup(device); if (err) goto error_platform_profile; } diff --git a/drivers/platform/x86/amd/pmf/sps.c b/drivers/platform/x86/amd/pmf/sps.c index e2d0cc92c4396..1b94af7c0e0c4 100644 --- a/drivers/platform/x86/amd/pmf/sps.c +++ b/drivers/platform/x86/amd/pmf/sps.c @@ -406,6 +406,7 @@ int amd_pmf_init_sps(struct amd_pmf_dev *dev) } dev->pprof.name = "amd-pmf"; + dev->pprof.dev = dev->dev; dev->pprof.profile_get = amd_pmf_profile_get; dev->pprof.profile_set = amd_pmf_profile_set; diff --git a/drivers/platform/x86/asus-wmi.c b/drivers/platform/x86/asus-wmi.c index c7c104c65a85a..78621b2af0ddb 100644 --- a/drivers/platform/x86/asus-wmi.c +++ b/drivers/platform/x86/asus-wmi.c @@ -3911,6 +3911,7 @@ static int platform_profile_setup(struct asus_wmi *asus) dev_info(dev, "Using throttle_thermal_policy for platform_profile support\n"); asus->platform_profile_handler.name = "asus-wmi"; + asus->platform_profile_handler.dev = dev; asus->platform_profile_handler.profile_get = asus_wmi_platform_profile_get; asus->platform_profile_handler.profile_set = asus_wmi_platform_profile_set; diff --git a/drivers/platform/x86/dell/alienware-wmi.c b/drivers/platform/x86/dell/alienware-wmi.c index ac0038afd98fa..c03b1aa7dfb5f 100644 --- a/drivers/platform/x86/dell/alienware-wmi.c +++ b/drivers/platform/x86/dell/alienware-wmi.c @@ -1017,7 +1017,7 @@ static int thermal_profile_set(struct platform_profile_handler *pprof, return wmax_thermal_control(supported_thermal_profiles[profile]); } -static int create_thermal_profile(void) +static int create_thermal_profile(struct platform_device *platform_device) { u32 out_data; enum wmax_thermal_mode mode; @@ -1057,6 +1057,7 @@ static int create_thermal_profile(void) pp_handler.profile_get = thermal_profile_get; pp_handler.profile_set = thermal_profile_set; pp_handler.name = "alienware-wmi"; + pp_handler.dev = &platform_device->dev; return platform_profile_register(&pp_handler); } @@ -1125,7 +1126,7 @@ static int __init alienware_wmi_init(void) } if (quirks->thermal) { - ret = create_thermal_profile(); + ret = create_thermal_profile(platform_device); if (ret) goto fail_prep_thermal_profile; } diff --git a/drivers/platform/x86/dell/dell-pc.c b/drivers/platform/x86/dell/dell-pc.c index 805497e44b3a5..e5724e76a2082 100644 --- a/drivers/platform/x86/dell/dell-pc.c +++ b/drivers/platform/x86/dell/dell-pc.c @@ -257,6 +257,7 @@ static int thermal_init(void) goto cleanup_platform_device; } thermal_handler->name = "dell-pc"; + thermal_handler->dev = &platform_device->dev; thermal_handler->profile_get = thermal_platform_profile_get; thermal_handler->profile_set = thermal_platform_profile_set; diff --git a/drivers/platform/x86/hp/hp-wmi.c b/drivers/platform/x86/hp/hp-wmi.c index 26cac73caf2b9..ffb09799142bc 100644 --- a/drivers/platform/x86/hp/hp-wmi.c +++ b/drivers/platform/x86/hp/hp-wmi.c @@ -1565,7 +1565,7 @@ static inline void omen_unregister_powersource_event_handler(void) unregister_acpi_notifier(&platform_power_source_nb); } -static int thermal_profile_setup(void) +static int thermal_profile_setup(struct platform_device *device) { int err, tp; @@ -1625,6 +1625,7 @@ static int thermal_profile_setup(void) } platform_profile_handler.name = "hp-wmi"; + platform_profile_handler.dev = &device->dev; set_bit(PLATFORM_PROFILE_BALANCED, platform_profile_handler.choices); set_bit(PLATFORM_PROFILE_PERFORMANCE, platform_profile_handler.choices); @@ -1664,7 +1665,7 @@ static int __init hp_wmi_bios_setup(struct platform_device *device) if (err < 0) return err; - thermal_profile_setup(); + thermal_profile_setup(device); return 0; } diff --git a/drivers/platform/x86/ideapad-laptop.c b/drivers/platform/x86/ideapad-laptop.c index 1f94c14c3b832..24367c3590c99 100644 --- a/drivers/platform/x86/ideapad-laptop.c +++ b/drivers/platform/x86/ideapad-laptop.c @@ -1103,6 +1103,7 @@ static int ideapad_dytc_profile_init(struct ideapad_private *priv) mutex_init(&priv->dytc->mutex); priv->dytc->pprof.name = "ideapad-laptop"; + priv->dytc->pprof.dev = &priv->platform_device->dev; priv->dytc->priv = priv; priv->dytc->pprof.profile_get = dytc_profile_get; priv->dytc->pprof.profile_set = dytc_profile_set; diff --git a/drivers/platform/x86/inspur_platform_profile.c b/drivers/platform/x86/inspur_platform_profile.c index 03da2c8cf6789..5a53949bbbf5f 100644 --- a/drivers/platform/x86/inspur_platform_profile.c +++ b/drivers/platform/x86/inspur_platform_profile.c @@ -178,6 +178,7 @@ static int inspur_wmi_probe(struct wmi_device *wdev, const void *context) dev_set_drvdata(&wdev->dev, priv); priv->handler.name = "inspur-wmi"; + priv->handler.dev = &wdev->dev; priv->handler.profile_get = inspur_platform_profile_get; priv->handler.profile_set = inspur_platform_profile_set; diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c index c8c316b8507a5..222fba97d79a7 100644 --- a/drivers/platform/x86/thinkpad_acpi.c +++ b/drivers/platform/x86/thinkpad_acpi.c @@ -10616,6 +10616,7 @@ static int tpacpi_dytc_profile_init(struct ibm_init_struct *iibm) dbg_printk(TPACPI_DBG_INIT, "DYTC version %d: thermal mode available\n", dytc_version); + dytc_profile.dev = &tpacpi_pdev->dev; /* Create platform_profile structure and register */ err = platform_profile_register(&dytc_profile); /* diff --git a/include/linux/platform_profile.h b/include/linux/platform_profile.h index 6fa988e417428..daec6b9bad81f 100644 --- a/include/linux/platform_profile.h +++ b/include/linux/platform_profile.h @@ -28,6 +28,7 @@ enum platform_profile_option { struct platform_profile_handler { const char *name; + struct device *dev; unsigned long choices[BITS_TO_LONGS(PLATFORM_PROFILE_LAST)]; int (*profile_get)(struct platform_profile_handler *pprof, enum platform_profile_option *profile); From patchwork Sat Nov 9 04:41:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 842754 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2077.outbound.protection.outlook.com [40.107.93.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 E7EAD1465B1; Sat, 9 Nov 2024 04:42:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.93.77 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731127354; cv=fail; b=X4T76IREFbayxlqkTBf8hbt7/ZlVl0B3yIo2Vis0IQuH8F7J1XqQV+XW+94Bhx8J8kZh8AytGPP3lCJgCz85ZgL6676mxePO7rz3ZkFoYLyXGCMiAjUuTygkj/v8l87peYEFUlPQBN/T4P1CFhNBnZ0iBNaOJUYRtTfFasjZe7c= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731127354; c=relaxed/simple; bh=AkmQ0mQfkawEwQ8/KAwjZJ+3v6g6OEDKZT+xC0UovgA=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=JB+VaB5SGS6HiD2NjeE1JJL4Jin/q32gTsokhM4MK26D/vNyV+5ert0gPPhHMJiaDloaoep4qm52JBPkdMHyNtLQq2QBF0/wKbxUJFQc+CBdUkYT+m3SSPPaDEB0Cv51e+Cmev/es5wAAOwlGfmocC9WQMs3LhOdCRpDPI/RRDs= 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=AiV7k/0Z; arc=fail smtp.client-ip=40.107.93.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="AiV7k/0Z" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=ZFUgFvXzs7YKy8iNEGZUPUD01+yLftee+A93nA/Vpot6nwuzHuA7x6CyDgQ8L9dK7TC+8LIculdyZRRnYQXfZ9WHIkn7L/oqODidtaZ/zGumlhv/KFjDCjKEZ2UX5y0nGcwdLnSsCyuU5Ponn1p0Dc1C5JhflvVq6RFrtO4FrW4EIfXn5r/ULWGyCdo75/CGywgDlOEnkjyhg23xJDS/pPRQvgy5kBcOni5rLr5Pktrwp79zD5z5fsUDDWklYEeU15UP4F+NOvlqVBN7TOueGChYhGfIQJRyCrjpq8Jx+LxeUvq/CdXDRmAa2teY1+i5N0N/XoVwEm+v8w6jUyhm0A== 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=Kjz/+hRXrRT1TN+GmPsK+9EeUP5afNROOS/roqGFiJQ=; b=cCgqzH3dUlZjNYKxzpfMuIhJGOCICST95IWeFoBIfxRxE86inSmTLOmjrMDnnmVyK4c9KWVOsgZ0qS2ymltnxI/K543m7c4GXbmApojBaJbP5O7GLX9L/dofahGD0jhFkCToG/xJ9Yvt16js+q/DUEQgCNzR+/fZZvFc5JqNS07+nnz181+hayzWWu3X8d2V2llGSqEjuXe2GhIlz4e7t/JAho+ONY+CORFS2pOdS6JlbVslwdjEw/GSaCUzWPVysn3TR0BSYsSuiwvx0Cbj5FO0oz0E47/eFrImbyifAWbsWBSTU2ry4l3khe/TykG0YzuUa9XE5S1g8deVIf9Bpw== 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=Kjz/+hRXrRT1TN+GmPsK+9EeUP5afNROOS/roqGFiJQ=; b=AiV7k/0Z283eaal0DhXTI91ltOT2YQsrhhKI7Nen3wCeIElsEf4MrAU0ahb7fZ+nqeIjB/1MpP2nX4a9njKE8TbqNoVgTp+jXjtFh81BdCCOIfgo5x87cqL5CzraEP35/+xAA5s9anckeKqmWl+07dcOGZqOVKjMBNM+UzC2uoc= Received: from SN6PR04CA0096.namprd04.prod.outlook.com (2603:10b6:805:f2::37) by MN0PR12MB5932.namprd12.prod.outlook.com (2603:10b6:208:37f::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8137.19; Sat, 9 Nov 2024 04:42:24 +0000 Received: from SN1PEPF0002636B.namprd02.prod.outlook.com (2603:10b6:805:f2:cafe::7f) by SN6PR04CA0096.outlook.office365.com (2603:10b6:805:f2::37) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8137.20 via Frontend Transport; Sat, 9 Nov 2024 04:42:24 +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 SN1PEPF0002636B.mail.protection.outlook.com (10.167.241.136) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8137.17 via Frontend Transport; Sat, 9 Nov 2024 04:42:24 +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; Fri, 8 Nov 2024 22:42:22 -0600 From: Mario Limonciello To: Hans de Goede , =?utf-8?q?Ilpo_J=C3=A4rvinen?= CC: "Rafael J . Wysocki" , Len Brown , Maximilian Luz , Lee Chun-Yi , "Shyam Sundar S K" , Corentin Chary , "Luke D . Jones" , Ike Panhc , Henrique de Moraes Holschuh , "Alexis Belmonte" , =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= , Ai Chao , Gergo Koteles , open list , "open list:ACPI" , "open list:MICROSOFT SURFACE PLATFORM PROFILE DRIVER" , "open list:THINKPAD ACPI EXTRAS DRIVER" , Mark Pearson , Matthew Schwartz , Mario Limonciello , Armin Wolf Subject: [PATCH v6 04/22] ACPI: platform_profile: Add platform handler argument to platform_profile_remove() Date: Fri, 8 Nov 2024 22:41:33 -0600 Message-ID: <20241109044151.29804-5-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241109044151.29804-1-mario.limonciello@amd.com> References: <20241109044151.29804-1-mario.limonciello@amd.com> Precedence: bulk X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SN1PEPF0002636B:EE_|MN0PR12MB5932:EE_ X-MS-Office365-Filtering-Correlation-Id: a1aae2bd-216f-4dfb-3c2f-08dd0078e7f9 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|1800799024|82310400026|36860700013|7416014|376014; X-Microsoft-Antispam-Message-Info: =?utf-8?q?Vx849OfX9zM+W49KAuVB20OJt2qt5Hw?= =?utf-8?q?ZtJGtMSLaEj/VGgpbUutdHn7g1AwDFwY0HsAC8N51Ti9+V1VZS6sLWsaQNsFu2aHH?= =?utf-8?q?DFDoX4LT9H4uuCC2Poylbg6tcd1UrwDUUXfmuTGsYV32euStHHLQIUN0EZIUUCRVf?= =?utf-8?q?S8eb5wiSslgrPys1EhecfupjGSj8haiI9w6GY8Hcn4Sy8gM4aYE+rynmbrns8pTeK?= =?utf-8?q?fAj68J9XTmgGhMBYQjnmee4VvM5OKe5kyHoQWG709/EwX5X2Zil7cJElONawdJHd9?= =?utf-8?q?ScGB+SZMtSV1MVjbvfYKgCiH+Fep6SEaxCh+R4nP/YJiADI33migEWq2T82Ha1lAE?= =?utf-8?q?rQ0odAnKbDCgrBN/Fz92glRjlPPlaH0hde+ui8DmBHDtcI3k+3c5CIGRCuYt1YaGg?= =?utf-8?q?4MP7Qweb1wQozUwcVuWE6cZpk+yEabdc1fNyAXz2PysgVu3Ak0lPKrCyEIjE5MbqW?= =?utf-8?q?2KBz9+fIoqaPLCTcWqXrXgSBbMTs+9L9ndAC7AIS6wxSV4EpTaTeCQn7ZIFv5Resk?= =?utf-8?q?18ZVpu52FeBgE+wNiI0sL5Tc/Buykz/jHCL1VEr0nyI/Nc5LqipbYIFZMeWaTWeDH?= =?utf-8?q?FAcd474wZjRyucHoFNLaX+6c63C+Npb0D/7iIa0uUtKxooENiN3KJOeF6YAqLGA18?= =?utf-8?q?03/+i85tbPhFJrgb8vU+kB92maAwTAR2IVxcQg5Do28p+kKkdyVSOU8ghwhtO3D5j?= =?utf-8?q?ZFpwq+URvypFCszXfnXfiI9fVlP8SI92jE8QQ9QkzmfnEZL6CNNVPDNfWX5x/5QFH?= =?utf-8?q?7wFBeMr6y+QEMpBbZT7hK/sTX8Ay251TwgorELUvifEURA0Or+x0i+0CVWOxltgBf?= =?utf-8?q?qy1W129BidOhMJMo8Xb6xYxlx59MSwycsKzfyFXl2quyB5Wm4y+ekZ91SegIjCw65?= =?utf-8?q?akfqaSGVeRB1UmwKOi0fVMNFVISDfE0aEbTSyOfrwWkOhqH4LnqXNWLh63Ka6liuy?= =?utf-8?q?qo9s9Y5WpKSOYWUMZmUNxzKiU/SVEzrBxsAzmjVuNz5gdu6Td526Z4Egp1OilH7Ha?= =?utf-8?q?er3KYCCjWMea7pyNUeM9vcajrLMNrQIEwu4JMlaYJZe/OgLD/Kv2vWSef517TsKhO?= =?utf-8?q?Iwn58Kyh564P+aEDhVlRn5BiNJYiWeU8tRxlAD5e7Q28nuGN1XoP75/FcbEVUX3tO?= =?utf-8?q?K7DzJ/aqVQePFaN1uY8wR4GC6u5QyekN/T8BfZuKw/ziFQsnJ+BKBplMppJSu8qmP?= =?utf-8?q?UyJYUACQHiFOD7weLmfiUAI/UmlHfeleSHpTHUO01LZr3uT97pEpjBbwsgE9R9NCg?= =?utf-8?q?e9AXkPda8Tqy4CjGQe9qvZG2prBMa0FDl5e/0pb09tCX3MoDqIEeHu/uKpIazaZ6L?= =?utf-8?q?iVHOTz/fiZ99gzfPo10HXN2PWBy7sBm+1g=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)(7416014)(376014); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Nov 2024 04:42:24.3487 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a1aae2bd-216f-4dfb-3c2f-08dd0078e7f9 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: SN1PEPF0002636B.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN0PR12MB5932 To allow registering and unregistering multiple platform handlers calls to platform_profile_remove() will need to know which handler is to be removed. Add an argument for this. Tested-by: Mark Pearson Tested-by: Matthew Schwartz Reviewed-by: Hans de Goede Reviewed-by: Mark Pearson Reviewed-by: Maximilian Luz Reviewed-by: Ilpo Järvinen Reviewed-by: Armin Wolf Signed-off-by: Mario Limonciello --- v5: * Add tag v4: * Add alienware-wmi too --- drivers/acpi/platform_profile.c | 2 +- drivers/platform/surface/surface_platform_profile.c | 6 +++++- drivers/platform/x86/acer-wmi.c | 4 ++-- drivers/platform/x86/amd/pmf/sps.c | 2 +- drivers/platform/x86/asus-wmi.c | 4 ++-- drivers/platform/x86/dell/alienware-wmi.c | 2 +- drivers/platform/x86/dell/dell-pc.c | 2 +- drivers/platform/x86/hp/hp-wmi.c | 2 +- drivers/platform/x86/ideapad-laptop.c | 2 +- drivers/platform/x86/inspur_platform_profile.c | 5 ++++- drivers/platform/x86/thinkpad_acpi.c | 2 +- include/linux/platform_profile.h | 2 +- 12 files changed, 21 insertions(+), 14 deletions(-) diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profile.c index d2f7fd7743a13..c24744da20916 100644 --- a/drivers/acpi/platform_profile.c +++ b/drivers/acpi/platform_profile.c @@ -205,7 +205,7 @@ int platform_profile_register(struct platform_profile_handler *pprof) } EXPORT_SYMBOL_GPL(platform_profile_register); -int platform_profile_remove(void) +int platform_profile_remove(struct platform_profile_handler *pprof) { sysfs_remove_group(acpi_kobj, &platform_profile_group); diff --git a/drivers/platform/surface/surface_platform_profile.c b/drivers/platform/surface/surface_platform_profile.c index 5f45f8e8cd69b..b449c4c8b883c 100644 --- a/drivers/platform/surface/surface_platform_profile.c +++ b/drivers/platform/surface/surface_platform_profile.c @@ -210,6 +210,7 @@ static int surface_platform_profile_probe(struct ssam_device *sdev) return -ENOMEM; tpd->sdev = sdev; + ssam_device_set_drvdata(sdev, tpd); tpd->handler.name = "Surface Platform Profile"; tpd->handler.dev = &sdev->dev; @@ -228,7 +229,10 @@ static int surface_platform_profile_probe(struct ssam_device *sdev) static void surface_platform_profile_remove(struct ssam_device *sdev) { - platform_profile_remove(); + struct ssam_platform_profile_device *tpd; + + tpd = ssam_device_get_drvdata(sdev); + platform_profile_remove(&tpd->handler); } static const struct ssam_device_id ssam_platform_profile_match[] = { diff --git a/drivers/platform/x86/acer-wmi.c b/drivers/platform/x86/acer-wmi.c index aca4a5746bee1..b12965d9fcdb7 100644 --- a/drivers/platform/x86/acer-wmi.c +++ b/drivers/platform/x86/acer-wmi.c @@ -2547,7 +2547,7 @@ static int acer_platform_probe(struct platform_device *device) error_hwmon: if (platform_profile_support) - platform_profile_remove(); + platform_profile_remove(&platform_profile_handler); error_platform_profile: acer_rfkill_exit(); error_rfkill: @@ -2570,7 +2570,7 @@ static void acer_platform_remove(struct platform_device *device) acer_rfkill_exit(); if (platform_profile_support) - platform_profile_remove(); + platform_profile_remove(&platform_profile_handler); } #ifdef CONFIG_PM_SLEEP diff --git a/drivers/platform/x86/amd/pmf/sps.c b/drivers/platform/x86/amd/pmf/sps.c index 1b94af7c0e0c4..bd2bd6cfc39a0 100644 --- a/drivers/platform/x86/amd/pmf/sps.c +++ b/drivers/platform/x86/amd/pmf/sps.c @@ -426,5 +426,5 @@ int amd_pmf_init_sps(struct amd_pmf_dev *dev) void amd_pmf_deinit_sps(struct amd_pmf_dev *dev) { - platform_profile_remove(); + platform_profile_remove(&dev->pprof); } diff --git a/drivers/platform/x86/asus-wmi.c b/drivers/platform/x86/asus-wmi.c index 78621b2af0ddb..0750e2fe65325 100644 --- a/drivers/platform/x86/asus-wmi.c +++ b/drivers/platform/x86/asus-wmi.c @@ -4886,7 +4886,7 @@ static int asus_wmi_add(struct platform_device *pdev) fail_custom_fan_curve: fail_platform_profile_setup: if (asus->platform_profile_support) - platform_profile_remove(); + platform_profile_remove(&asus->platform_profile_handler); fail_fan_boost_mode: fail_platform: kfree(asus); @@ -4913,7 +4913,7 @@ static void asus_wmi_remove(struct platform_device *device) asus_wmi_battery_exit(asus); if (asus->platform_profile_support) - platform_profile_remove(); + platform_profile_remove(&asus->platform_profile_handler); kfree(asus); } diff --git a/drivers/platform/x86/dell/alienware-wmi.c b/drivers/platform/x86/dell/alienware-wmi.c index c03b1aa7dfb5f..3cf6c371d4220 100644 --- a/drivers/platform/x86/dell/alienware-wmi.c +++ b/drivers/platform/x86/dell/alienware-wmi.c @@ -1065,7 +1065,7 @@ static int create_thermal_profile(struct platform_device *platform_device) static void remove_thermal_profile(void) { if (quirks->thermal) - platform_profile_remove(); + platform_profile_remove(&pp_handler); } static int __init alienware_wmi_init(void) diff --git a/drivers/platform/x86/dell/dell-pc.c b/drivers/platform/x86/dell/dell-pc.c index e5724e76a2082..5c4d48e4b667a 100644 --- a/drivers/platform/x86/dell/dell-pc.c +++ b/drivers/platform/x86/dell/dell-pc.c @@ -289,7 +289,7 @@ static int thermal_init(void) static void thermal_cleanup(void) { if (thermal_handler) - platform_profile_remove(); + platform_profile_remove(thermal_handler); platform_device_unregister(platform_device); } diff --git a/drivers/platform/x86/hp/hp-wmi.c b/drivers/platform/x86/hp/hp-wmi.c index ffb09799142bc..6d6e13a0c6e2d 100644 --- a/drivers/platform/x86/hp/hp-wmi.c +++ b/drivers/platform/x86/hp/hp-wmi.c @@ -1693,7 +1693,7 @@ static void __exit hp_wmi_bios_remove(struct platform_device *device) } if (platform_profile_support) - platform_profile_remove(); + platform_profile_remove(&platform_profile_handler); } static int hp_wmi_resume_handler(struct device *device) diff --git a/drivers/platform/x86/ideapad-laptop.c b/drivers/platform/x86/ideapad-laptop.c index 24367c3590c99..80797c6ae8b0b 100644 --- a/drivers/platform/x86/ideapad-laptop.c +++ b/drivers/platform/x86/ideapad-laptop.c @@ -1136,7 +1136,7 @@ static void ideapad_dytc_profile_exit(struct ideapad_private *priv) if (!priv->dytc) return; - platform_profile_remove(); + platform_profile_remove(&priv->dytc->pprof); mutex_destroy(&priv->dytc->mutex); kfree(priv->dytc); diff --git a/drivers/platform/x86/inspur_platform_profile.c b/drivers/platform/x86/inspur_platform_profile.c index 5a53949bbbf5f..53af73a7fbf7b 100644 --- a/drivers/platform/x86/inspur_platform_profile.c +++ b/drivers/platform/x86/inspur_platform_profile.c @@ -191,7 +191,10 @@ static int inspur_wmi_probe(struct wmi_device *wdev, const void *context) static void inspur_wmi_remove(struct wmi_device *wdev) { - platform_profile_remove(); + struct inspur_wmi_priv *priv; + + priv = dev_get_drvdata(&wdev->dev); + platform_profile_remove(&priv->handler); } static const struct wmi_device_id inspur_wmi_id_table[] = { diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c index 222fba97d79a7..13798c6d5fcf3 100644 --- a/drivers/platform/x86/thinkpad_acpi.c +++ b/drivers/platform/x86/thinkpad_acpi.c @@ -10638,7 +10638,7 @@ static int tpacpi_dytc_profile_init(struct ibm_init_struct *iibm) static void dytc_profile_exit(void) { - platform_profile_remove(); + platform_profile_remove(&dytc_profile); } static struct ibm_struct dytc_profile_driver_data = { diff --git a/include/linux/platform_profile.h b/include/linux/platform_profile.h index daec6b9bad81f..bcaf3aa39160f 100644 --- a/include/linux/platform_profile.h +++ b/include/linux/platform_profile.h @@ -37,7 +37,7 @@ struct platform_profile_handler { }; int platform_profile_register(struct platform_profile_handler *pprof); -int platform_profile_remove(void); +int platform_profile_remove(struct platform_profile_handler *pprof); int platform_profile_cycle(void); void platform_profile_notify(void); From patchwork Sat Nov 9 04:41:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 842126 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2049.outbound.protection.outlook.com [40.107.243.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 37F1313FD86; Sat, 9 Nov 2024 04:42:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.243.49 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731127350; cv=fail; b=FJDmzMCAWj9RGQIR8mrzWvdQ43HXH+gZN2Hq6Iq/zD7dZgox+kCbS+QPkUyi7alUcwI76zAjLaim46h+w4Tw8I6J8Sz/MsWGX/hXX6b+GwzN3vOL0ov4bpkJJ+hLbkHLD/Db1uhDdtsWH6F/9V/yPBBRfuZw5VQhBxKTKiqngtk= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731127350; c=relaxed/simple; bh=F1Pxy1S1dRqyvuiXU8C/QmcFr5MXUQihSapuszxXgEY=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=pddilueesMTUlEF98o4DioQjjQ2pBDWOZQ4noWsr+0umejyLxc2F4IGNXFSWUjpUreyc3eHtgKk1hAOLiK4BdeAKOwMgsle8MTId1IxY3nyHI7IZCvw0gVtTu1YQHpKT//i+NuF1ciEJtJrY4XclhEfpPNmoxeQ4CCNXI4/8r44= 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=NcT7ZEI1; arc=fail smtp.client-ip=40.107.243.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="NcT7ZEI1" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=AihIoIMlfdXbI97X8heVW9MtHtWRG7cAMybuU3mAOG/NCH9dLKZWGqf3Jn49KX6AAioyOy4nbw2QuOgRN8myyd7XEa2HKWTb+8YFG6D92Neoz7BxLdoCVZV85UnsbFLObHs+SxxofFbIFj0aUnsyU1OP3On5fDRGNmEjiRoblKAIXux8823xQQ+TFHibiW/Ad7/UKhFBfh+vmtosTmlr+T6MFccZI6oHHKp1KQ7ARsJzN34doQSXQclioSFYuRZmmhUltpcxIehtlTVk7/HWr6O8fLU63YsZPZti9jiNrc6feSQpm+c02bk9bwTWSp3fypXFREkKSV0dnO+0fnqkMg== 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=W2hDAjXmMDYtqw1TqBySTR0sDGwr71iZc6aE/2BH68o=; b=ebIGnTjRzW9QOPckY0UbqMEvTbf7ZcLdCMWiNhBC5DSVWjnXeHyieGSHsP0qguZjanaOHAz6ojThOyjKvcmB6UZhlqyNgxA9lE9n1ENUwFNNcqeKWrPIZf6qrD70tRtOH/q5LVA+1mEg8nwPCqbx0wgLiwrpgJ0dFKN9Hww6+Aoxj3kpW93bvRGEh359esTIfZmcTJVdHVvLbp5lHVB/1DVhJL303Tj73oXxD2s5BuhfHPYSrYDxdtDNuvcwx4U9X3g3IZ5Cicjkutu/XhJ6qstKl4gZce7m5Q+O1EyuJcFVihPztDa4B5VG3/12ZuKDV0mgb3w3P7faQK/QMDC0qg== 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=W2hDAjXmMDYtqw1TqBySTR0sDGwr71iZc6aE/2BH68o=; b=NcT7ZEI14YIlkS54xdPObOOXhuUP1ZlOX7FpCs/nOjOxcY7Nsi+/a6iVjcQ1iEsCFpIUJqnTMJtY8ha6v7y54ddGt5gcZflnaHPJNgp9KyIVcwpsB/cYIu13fVcaukuShlEs7PDiuBec8w9bqmZBBUv7H4cquZeFH3C9JHGMaOU= Received: from SA1PR05CA0023.namprd05.prod.outlook.com (2603:10b6:806:2d2::17) by IA1PR12MB6259.namprd12.prod.outlook.com (2603:10b6:208:3e5::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8137.19; Sat, 9 Nov 2024 04:42:26 +0000 Received: from SN1PEPF0002636C.namprd02.prod.outlook.com (2603:10b6:806:2d2:cafe::44) by SA1PR05CA0023.outlook.office365.com (2603:10b6:806:2d2::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.12 via Frontend Transport; Sat, 9 Nov 2024 04:42:26 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by SN1PEPF0002636C.mail.protection.outlook.com (10.167.241.137) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8114.16 via Frontend Transport; Sat, 9 Nov 2024 04:42:26 +0000 Received: from AUS-P9-MLIMONCI.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Fri, 8 Nov 2024 22:42:23 -0600 From: Mario Limonciello To: Hans de Goede , =?utf-8?q?Ilpo_J=C3=A4rvinen?= CC: "Rafael J . Wysocki" , Len Brown , Maximilian Luz , Lee Chun-Yi , "Shyam Sundar S K" , Corentin Chary , "Luke D . Jones" , Ike Panhc , Henrique de Moraes Holschuh , "Alexis Belmonte" , =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= , Ai Chao , Gergo Koteles , open list , "open list:ACPI" , "open list:MICROSOFT SURFACE PLATFORM PROFILE DRIVER" , "open list:THINKPAD ACPI EXTRAS DRIVER" , Mark Pearson , Matthew Schwartz , Mario Limonciello Subject: [PATCH v6 05/22] ACPI: platform_profile: Pass the profile handler into platform_profile_notify() Date: Fri, 8 Nov 2024 22:41:34 -0600 Message-ID: <20241109044151.29804-6-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241109044151.29804-1-mario.limonciello@amd.com> References: <20241109044151.29804-1-mario.limonciello@amd.com> Precedence: bulk X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SN1PEPF0002636C:EE_|IA1PR12MB6259:EE_ X-MS-Office365-Filtering-Correlation-Id: 39018bed-ca04-4303-3915-08dd0078e8f3 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|7416014|1800799024|376014|82310400026|36860700013; X-Microsoft-Antispam-Message-Info: oCYzn8KIWahO+/ObCKLKeRjSdT82t10xTEK48x+j0f7ZKwSk6uZZ6u5iBpPNbBbnRVjOihNtPTEBs6oB7INUK1SfF6eZ7bcWxHykEIDlKLCWjmeJMNNo8+r2b6Y408sNWyCQK97aFk/iBHfRtFu7dlsKxrzkyryAeSDD+QWmHtyjLpBCUSUxaaRkUGWgqh7dsOP8pXcm1j4mEcJsdiKwA/Fww+scOH/dHNUAr1v5NHNCohJ7sgMNDoD+3weBlF7zXW0Xjrfk/HUjTGQIYaayPmyJdEpWYM/rAMmrFn8hDd/a7wNz66a6HTu+Qe+PvlQNmG7anVc5qdzUBcn1SYPEXFyfkXzmvN46419PP/bKCHPzJ3X3eMBPoa9sz06hqcRr5a1K8XUSyNHC3aasJ1wVScMLrhKD/v348pT1o4/sqNQsUdcWbARTz2F8i9OO66QbXZ8ilZsZXRKbkDRdDK3+cSDyQcWfPXDlH74e0qm2V0p+iIwvlqTYprCyXZ1IYftfLfMASt45lbkK3ASzxhLlMi+P5F8mDh7wQrLQHAzrLSXy1FXlB1jeLllexG267Tp08kobydlYMbdPUgeIJTrwrobMOQi1y1riL0DZsMXjpOptLklsebj2pAmrScwU9k2LsZwi0tC7efYl9NEKHWHg5ocOmKgf5FWbuLIgNoHIGLOr/Pkc/lwg+vdm4f3SFioMYWgn0Pp3CKKMHSrx/IA0vBocAogK88ozqzkfLLzaytiOB5AIxwS/OdcFr9nYTlxUe3TWqJ/RHfnP+NL/HkHLOIQpZMf17SCHWrA6PcCDkRBOZzh/b2Tf4VKc/ZrdfwDwEA1Hgw6VK5OB2coHasjPqsPOwPXrpFvUw92S2UocMKCZ4cQL15hsKS6NzTHpJ2dX0ZUgh0YwDdqlzVCO6tHde77r+k2IuZJ7zX1NBV5u3L/A6q2j8qzpvmFRPD/hMoUtS0VPm9a25O8XYbUXm4qMGu0uNRI6qJXcTTOZTEZcIysTKqKiwf41U58rSqxlsnQuLl23RXhW5iS/53pUVx+xOs5eYr/txHmO8VkITAdWrkCKHq12GQ/vk8U+uX/Gl72x+XUPYc1ZVENWA7azd8Gv1b2Szu45ftKpvCUw2R5DFuH8Txflq3puZpAVjLupl9RS6ebdL6ApdQE4CqbNihu9yXwxXhACu6uxXy1gzz/2qnERVqpFUx6qhXFZPoVh+ntSg+K57q8PYAYiY5GkO3xqnvnCQVKlXe1P7F2+1lpe+b6ZHM6VlxpMmIGdZIH1niOwK8X4b8GNDuu2QFX99WY5Czp8JlRoAvfEo2aDsS+g/yXYTUcQaiwgyaH5HULjp9SAbmPMPz3hqO8X5JOiViW0KiIrSCBrQEms3JUMpCeyHRlv5TgqZowRRduJPZMy21XQ5b4G1Fdzrv2H2YoGWr5ghg== X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230040)(7416014)(1800799024)(376014)(82310400026)(36860700013); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Nov 2024 04:42:26.0026 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 39018bed-ca04-4303-3915-08dd0078e8f3 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: SN1PEPF0002636C.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR12MB6259 The profile handler will be used to notify the appropriate class devices. Signed-off-by: Mario Limonciello Reviewed-by: Armin Wolf --- drivers/acpi/platform_profile.c | 2 +- drivers/platform/x86/acer-wmi.c | 2 +- drivers/platform/x86/asus-wmi.c | 4 ++-- drivers/platform/x86/ideapad-laptop.c | 2 +- drivers/platform/x86/thinkpad_acpi.c | 14 +++++++------- include/linux/platform_profile.h | 2 +- 6 files changed, 13 insertions(+), 13 deletions(-) diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profile.c index c24744da20916..927a2f7456c9a 100644 --- a/drivers/acpi/platform_profile.c +++ b/drivers/acpi/platform_profile.c @@ -128,7 +128,7 @@ static const struct attribute_group platform_profile_group = { .attrs = platform_profile_attrs }; -void platform_profile_notify(void) +void platform_profile_notify(struct platform_profile_handler *pprof) { if (!cur_profile) return; diff --git a/drivers/platform/x86/acer-wmi.c b/drivers/platform/x86/acer-wmi.c index b12965d9fcdb7..0018818258070 100644 --- a/drivers/platform/x86/acer-wmi.c +++ b/drivers/platform/x86/acer-wmi.c @@ -1988,7 +1988,7 @@ static int acer_thermal_profile_change(void) if (tp != ACER_PREDATOR_V4_THERMAL_PROFILE_TURBO_WMI) last_non_turbo_profile = tp; - platform_profile_notify(); + platform_profile_notify(&platform_profile_handler); } return 0; diff --git a/drivers/platform/x86/asus-wmi.c b/drivers/platform/x86/asus-wmi.c index 0750e2fe65325..2a8d789ee05cf 100644 --- a/drivers/platform/x86/asus-wmi.c +++ b/drivers/platform/x86/asus-wmi.c @@ -3754,7 +3754,7 @@ static int throttle_thermal_policy_switch_next(struct asus_wmi *asus) * Ensure that platform_profile updates userspace with the change to ensure * that platform_profile and throttle_thermal_policy_mode are in sync. */ - platform_profile_notify(); + platform_profile_notify(&asus->platform_profile_handler); return 0; } @@ -3793,7 +3793,7 @@ static ssize_t throttle_thermal_policy_store(struct device *dev, * Ensure that platform_profile updates userspace with the change to ensure * that platform_profile and throttle_thermal_policy_mode are in sync. */ - platform_profile_notify(); + platform_profile_notify(&asus->platform_profile_handler); return count; } diff --git a/drivers/platform/x86/ideapad-laptop.c b/drivers/platform/x86/ideapad-laptop.c index 80797c6ae8b0b..79c65c24b433a 100644 --- a/drivers/platform/x86/ideapad-laptop.c +++ b/drivers/platform/x86/ideapad-laptop.c @@ -1041,7 +1041,7 @@ static void dytc_profile_refresh(struct ideapad_private *priv) if (profile != priv->dytc->current_profile) { priv->dytc->current_profile = profile; - platform_profile_notify(); + platform_profile_notify(&priv->dytc->pprof); } } diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c index 13798c6d5fcf3..8539cac042be8 100644 --- a/drivers/platform/x86/thinkpad_acpi.c +++ b/drivers/platform/x86/thinkpad_acpi.c @@ -10516,6 +10516,12 @@ static int dytc_profile_set(struct platform_profile_handler *pprof, return err; } +static struct platform_profile_handler dytc_profile = { + .name = "thinkpad-acpi", + .profile_get = dytc_profile_get, + .profile_set = dytc_profile_set, +}; + static void dytc_profile_refresh(void) { enum platform_profile_option profile; @@ -10544,16 +10550,10 @@ static void dytc_profile_refresh(void) err = convert_dytc_to_profile(funcmode, perfmode, &profile); if (!err && profile != dytc_current_profile) { dytc_current_profile = profile; - platform_profile_notify(); + platform_profile_notify(&dytc_profile); } } -static struct platform_profile_handler dytc_profile = { - .name = "thinkpad-acpi", - .profile_get = dytc_profile_get, - .profile_set = dytc_profile_set, -}; - static int tpacpi_dytc_profile_init(struct ibm_init_struct *iibm) { int err, output; diff --git a/include/linux/platform_profile.h b/include/linux/platform_profile.h index bcaf3aa39160f..8ec0b8da56db5 100644 --- a/include/linux/platform_profile.h +++ b/include/linux/platform_profile.h @@ -39,6 +39,6 @@ struct platform_profile_handler { int platform_profile_register(struct platform_profile_handler *pprof); int platform_profile_remove(struct platform_profile_handler *pprof); int platform_profile_cycle(void); -void platform_profile_notify(void); +void platform_profile_notify(struct platform_profile_handler *pprof); #endif /*_PLATFORM_PROFILE_H_*/ From patchwork Sat Nov 9 04:41:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 842125 Received: from NAM02-DM3-obe.outbound.protection.outlook.com (mail-dm3nam02on2060.outbound.protection.outlook.com [40.107.95.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 53802146599; Sat, 9 Nov 2024 04:42:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.95.60 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731127354; cv=fail; b=XUuJx/walmlLl97XovPlVRskS67g9RGsUZBf+jIBE/Oz8KKGn99FV6JjyN5YqCIE+XIDRjMMWRIIfbQpL53hrzCoNDwnhHtuorCkGSndJ/OaIqbZHgu3oLc/eTBgO/WQtBZhXfrp1qALId9M1UJX4u+qNWxEw9hRWetJAtwA98o= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731127354; c=relaxed/simple; bh=qxZR0ioXhz7I9mrAT8p2DAj4zP/orxCZ1guCEIlDwcY=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=GSTsV94rXmO7iqJAXrtcD0a4gCdFxRU1Nb1gaNfIXaiNRISghYThNemstTCywv12Hchz6exk5toIiwon8xW+lNwCzZjHOv2W+wJatmBc8iG8vfJb05pSodFDViSwoIBuVMLHOWwRsdtuC4VH0nxoSkVpKU9jDkQiXX9MwElgbW0= 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=COY1Kx2t; arc=fail smtp.client-ip=40.107.95.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="COY1Kx2t" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=SlWCXY+RH7u32d0IGO/F6E6IqpCTRvqCnWX3mMztgEyE89c396Nq/SBaSUWYWAb0jKlCP3LiTM/xhfqKX5hCas1KtOFw3JpaiaKhe/o5c8+oxyon5Smf4CjMLCQEhXZPzIT5ABwEVfm7C2sy+MkfinJu/Zgnb7oBj7CzF/cO9Z62k0PRLxpdv6Ly5jPxB7Ve0xAX3xGWXAQISp/MAi8xExslPKVLWwAE8TJz7AsGYEuTsCNpqm8LQc31QgCwlXWcWiF/0VgK3YA7vU8eIQCmf+p+5gdEwVYebU6X0U2dGmGQnY1yhlRPM6DddAGu+5XAVONlKqf+x80/khZX7rn4IQ== 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=eb96Rfxdmtyo0JIpdtirBRC/6HMVRjTmHsGHHm4KVnY=; b=HSCBrXYmByMYaxv44Ge+K5uiA2OZTxLLggZ82lk/CR6cQFlM5JbWx71iFREU/Ovl//chIFXLPO3W3/1guSIR8Vtx91lyV7jiyNsz+cMjMFBJzLI42O/G2BmiOtZtZrrDEa8LRtT1oThcTotQW/jjMEVP2tMa2APj6jXoXe8xdnCuEgD+w89hDwS3vOLKpLYIHR29xdakjAB0z08lgxSjrn79NiVWNMjNvCuJyegW5QxwkUffwqOA6xU3lsl4FyGudTbZ8Fa2HRd/kNjN//8fMAO8JbQSObZEN9UJtjcTMM0laAHweDZBC8C2oETP0k2JSbbjsSKvXzsHFL/ur8sOXQ== 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=eb96Rfxdmtyo0JIpdtirBRC/6HMVRjTmHsGHHm4KVnY=; b=COY1Kx2th7qMioNVYodIB8AWqiSubSJipJpeisBY3q2JYEG7UPG75Wmjldmi44SJRnXFpxjY75sGGX8VFKkJDONzeNIobNP3mxRi3k8XWg8Rt+nlysnrYEOR/Xxyo/bmZfmXshG1GaugLbUTa1QjQMtb+bHAMxfTcBcBWvhcxMU= Received: from SA1PR05CA0021.namprd05.prod.outlook.com (2603:10b6:806:2d2::21) by BY1PR12MB8446.namprd12.prod.outlook.com (2603:10b6:a03:52d::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8137.20; Sat, 9 Nov 2024 04:42:27 +0000 Received: from SN1PEPF0002636C.namprd02.prod.outlook.com (2603:10b6:806:2d2:cafe::55) by SA1PR05CA0021.outlook.office365.com (2603:10b6:806:2d2::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8137.18 via Frontend Transport; Sat, 9 Nov 2024 04:42: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 SN1PEPF0002636C.mail.protection.outlook.com (10.167.241.137) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8114.16 via Frontend Transport; Sat, 9 Nov 2024 04:42: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; Fri, 8 Nov 2024 22:42:25 -0600 From: Mario Limonciello To: Hans de Goede , =?utf-8?q?Ilpo_J=C3=A4rvinen?= CC: "Rafael J . Wysocki" , Len Brown , Maximilian Luz , Lee Chun-Yi , "Shyam Sundar S K" , Corentin Chary , "Luke D . Jones" , Ike Panhc , Henrique de Moraes Holschuh , "Alexis Belmonte" , =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= , Ai Chao , Gergo Koteles , open list , "open list:ACPI" , "open list:MICROSOFT SURFACE PLATFORM PROFILE DRIVER" , "open list:THINKPAD ACPI EXTRAS DRIVER" , Mark Pearson , Matthew Schwartz , Mario Limonciello , Armin Wolf Subject: [PATCH v6 06/22] ACPI: platform_profile: Move sanity check out of the mutex Date: Fri, 8 Nov 2024 22:41:35 -0600 Message-ID: <20241109044151.29804-7-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241109044151.29804-1-mario.limonciello@amd.com> References: <20241109044151.29804-1-mario.limonciello@amd.com> Precedence: bulk X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SN1PEPF0002636C:EE_|BY1PR12MB8446:EE_ X-MS-Office365-Filtering-Correlation-Id: 9365be0c-e2fa-4cb1-428b-08dd0078e9df X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|36860700013|1800799024|376014|7416014|82310400026; X-Microsoft-Antispam-Message-Info: =?utf-8?q?XZiodMQT3hHWt57izsmyW5It6YPp+6J?= =?utf-8?q?JzIs1o+usbOAQRHi3MQld41Ia6bVBxLUPXsfA+UCvPF4akv+gxeElcPIhqTtXHIRm?= =?utf-8?q?F6YQgyWX0zXI7kJoASXyVzyyouYeX4oTG+uouYh9M7p5BUrLGv+cE2RjYkZu4spsE?= =?utf-8?q?vbPCUsWxT+YvRlmIDU7R927sos00u202eXCroaP4AneR1cq7STt++sYH74+kE0Qz8?= =?utf-8?q?CWfrRFqY59cRw/P8Jck45BaRmKnhczBrC8xDENW1e6E3LIG7wDillL5IprY+7Be3Y?= =?utf-8?q?tA/w5WV+7wZWX/3AVXKQrzSH7GGWk5XeYsBi0cTP+WLSod8jXU8dew41eYQ0SGS0z?= =?utf-8?q?0YPFJxv12VbExsyJmPMVa8Q2NRVB89Yb4lZvPR9QznpkcBl8IKelC8NSwIHLP54IO?= =?utf-8?q?PaB3GrTSz7oO3VVJtuTDQ/Ew7mCJw1z+u2/vLzKH5D/uy/CVlqfyrmFeMaZ8bMvT5?= =?utf-8?q?IcsT6yTtsNSaRQRrmu3hY+jmC8e5lO4zMfsexGfFpaLq8p0E3+YJade75S+QWusaF?= =?utf-8?q?zKYAmT56a8c6PiNpGHqK3ucTsHO6aUwCdMDKPStnI0C4n1hiyi2ddiLC9OTNZWZ27?= =?utf-8?q?HNSj8PKyrT0gt/CtoSWG1hvQue95b/YoNSrJNJalrci9hApnbVtQ962e/QXMR4o42?= =?utf-8?q?ea3LB7bcrPn3fhcoMRr884JcxHtf5nWBENvB2rPMSV0npRJJSR07QO2o+c1s/WyPQ?= =?utf-8?q?FPUfv+cJmyThnDQ1teI+bJgCKOwnYgVVWhJWcMs0iFZxBrplHdZ4PzlZ2YD0MMIWa?= =?utf-8?q?6HfiyQGvrp3YyUgPk034HRNEa8hChKS45xfP+lXa39FT+YtTOFIiZlLe1d8znbNyb?= =?utf-8?q?a0VJZyw97s7t8tjV7idCbRbcDxdPRaxVhqXYHV4123eCY0093T6l3H6BOlFfNu1Xd?= =?utf-8?q?zK9Zj/kxoKtEFCxfmsBnA5yR4OMFuOmoqtIvMmyShHbiym4VYtZjItI4BDl4fQ1dc?= =?utf-8?q?uSvtL8RQZ7vNgiY7JSgxHsFsw0eiFTtvwIzVTwHEWb97ugInxDg60qjYtgOzjz26b?= =?utf-8?q?loi+XmRF9mFMzR43AOwmQk5SQo5HgJJlgJdPDVTD9YRKz7AiBXJesIPBTsxYxwYc8?= =?utf-8?q?B120t1WffNTBo+B0uK8q78TbrMtU8R1je8xBTcYolobWbrskfcX1vKfRkMdir2qF8?= =?utf-8?q?7nmGPtzqIcSAA5If4j/sGhs5Ez+cAv9+Iw78CP37J7T5TTPSKsnR1OcMQ3BRLZp5u?= =?utf-8?q?bmUrPpJJPU38yT4yH3NFxziHJ0aAYKjSAwVixtpy3zJ3JIfnT9vjgepgDr86//NcB?= =?utf-8?q?D7x3Xm1ZH0x3qo/bNThNPkEvu9sLUgEF5YqvItsbOjf0jQmQ1XpX4ECtB1r/u+T2k?= =?utf-8?q?OhiY2Mv0EfkeUnKwdNz5so14zOYPSrzjHA=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)(376014)(7416014)(82310400026); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Nov 2024 04:42:27.5495 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 9365be0c-e2fa-4cb1-428b-08dd0078e9df 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: SN1PEPF0002636C.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY1PR12MB8446 The sanity check that the platform handler had choices set doesn't need the mutex taken. Move it to earlier in the registration. Tested-by: Mark Pearson Tested-by: Matthew Schwartz Reviewed-by: Ilpo Järvinen Reviewed-by: Mark Pearson Reviewed-by: Armin Wolf Signed-off-by: Mario Limonciello --- 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_profile.c index 927a2f7456c9a..4f5623fc27c09 100644 --- a/drivers/acpi/platform_profile.c +++ b/drivers/acpi/platform_profile.c @@ -179,6 +179,13 @@ int platform_profile_register(struct platform_profile_handler *pprof) { int err; + /* Sanity check the profile handler */ + if (!pprof || bitmap_empty(pprof->choices, PLATFORM_PROFILE_LAST) || + !pprof->profile_set || !pprof->profile_get) { + pr_err("platform_profile: handler is invalid\n"); + return -EINVAL; + } + mutex_lock(&profile_lock); /* We can only have one active profile */ if (cur_profile) { @@ -186,13 +193,6 @@ int platform_profile_register(struct platform_profile_handler *pprof) return -EEXIST; } - /* Sanity check the profile handler field are set */ - if (!pprof || bitmap_empty(pprof->choices, PLATFORM_PROFILE_LAST) || - !pprof->profile_set || !pprof->profile_get) { - mutex_unlock(&profile_lock); - return -EINVAL; - } - err = sysfs_create_group(acpi_kobj, &platform_profile_group); if (err) { mutex_unlock(&profile_lock); From patchwork Sat Nov 9 04:41:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 842755 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2048.outbound.protection.outlook.com [40.107.94.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 3D01A14658C; Sat, 9 Nov 2024 04:42:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.94.48 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731127353; cv=fail; b=WzpOhmfDgDH2gsoxBQteJu+szTF2H32tdpoD4grJ1oJdn1iqR38OcIZBHOh9NjoRv1iCc50aAnfWc1o/4Xb81gLfw93FWzdW8ChNdRqmp/i0eSYV8lJLAGeSvdotN/xqIeRu7YZbIkrjHWfDKuvgaK02HRMkx3vrb/PuUny3Cm8= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731127353; c=relaxed/simple; bh=vmgke1hNgi+9jY2YjBI6Ei/XWu/10vuyZ2DT0pBncCY=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=uoiBBU2pUnd/gse9YD+7XkeMrwlwEpVL0gs4ZiDmyt8fFlqN6ns36As/S/DbrfDaz3K6d0VGDzX41xDgmn1NdBN8sdLst+WKh0h27Ar/ycTjXhixwsX2XRhrWQ96J9XbAw1p87uHdoNQXd7gxPGkiLJ/zVY+wDbwCN9oviascfU= 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=fW4iGcha; arc=fail smtp.client-ip=40.107.94.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="fW4iGcha" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=VeADo22EtHaZb7IeoQdTC35nX4m4DVRUUZ5S43oKrSOX7tBD2oqIW6uNhwJfIK6Omhx9s+YVLIS8WA0znUUbvcycs9ron6XBQ1e/nLwdRWEVKaPY97qmAocj/RF/9gpHKaMtz05yawD/LREcemYu0pMntDZYKqpWiM91mBwAiO3WhOwjYTXp6HteJURyrt8Kxn9cx2Pi1d6PWO8tNrBhXCcBdlDll/MCqS4UW31eLZh0+YlC2O1eoYFOJ/zIFdiiPwUktyGODg/CJIf+tJNAC9AGoQtX6hSB62R1qNksHroRjX6twThDE69H6cjkpnOQZp3xkyJtKx9QI3xDM2kmdg== 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=2JOepbNXpw+MaowhRv9S0+a5ySr6FY/Rm6BniVYK8xY=; b=XhUx7/lKmWvwO8ckBGXIja7xdR5P0V0rqMfNmzRsnk1Hqop7O4A48jTAYAbYnkBhTBbIxaekIKUyZp9xhoiruUB0uFvHuGbOTVa2vsefWcca5XSAA0PailsFRH8oB5DwcmGiTEJlw2IycspkpNi7ERXpzZ4zVPonSqG3mRdoazJ2TJxg0g3jHFX8Nn7b0+UlkgI7lvtqwA+oHNFFnEDbGvMef98zza6OiSc/8gbC15OJDePXYmk/QsMw5yb9Z10plQAss+jhtk7pOGil/6dva96q8+yxNIzYaTwf/6QGYkN6CkV/gDQPPWXf9XNH9BJ9cdin/Bv6RAJlqNQeCxw/Ww== 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=2JOepbNXpw+MaowhRv9S0+a5ySr6FY/Rm6BniVYK8xY=; b=fW4iGchauHs6ApJwxH4e6nEeUAoi8ZsRZiOg6FrbVYeX9neDR+P2xI2QaiMqEiwuBDxNqVV3Tj38a4opUxnjR1HW1zCXR3qmEiqQfwvTHNSnh9ey1mZfhow2ZErNAmzFYCb5GIgEiKik3FJFyFDh9n3xbhWqKuU6DqoN7F/0vmc= Received: from SN7PR04CA0224.namprd04.prod.outlook.com (2603:10b6:806:127::19) by IA0PR12MB8648.namprd12.prod.outlook.com (2603:10b6:208:486::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8137.20; Sat, 9 Nov 2024 04:42:29 +0000 Received: from SN1PEPF0002636E.namprd02.prod.outlook.com (2603:10b6:806:127:cafe::23) by SN7PR04CA0224.outlook.office365.com (2603:10b6:806:127::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8137.21 via Frontend Transport; Sat, 9 Nov 2024 04:42: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 SN1PEPF0002636E.mail.protection.outlook.com (10.167.241.139) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8137.17 via Frontend Transport; Sat, 9 Nov 2024 04:42: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; Fri, 8 Nov 2024 22:42:27 -0600 From: Mario Limonciello To: Hans de Goede , =?utf-8?q?Ilpo_J=C3=A4rvinen?= CC: "Rafael J . Wysocki" , Len Brown , Maximilian Luz , Lee Chun-Yi , "Shyam Sundar S K" , Corentin Chary , "Luke D . Jones" , Ike Panhc , Henrique de Moraes Holschuh , "Alexis Belmonte" , =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= , Ai Chao , Gergo Koteles , open list , "open list:ACPI" , "open list:MICROSOFT SURFACE PLATFORM PROFILE DRIVER" , "open list:THINKPAD ACPI EXTRAS DRIVER" , Mark Pearson , Matthew Schwartz , Mario Limonciello , Armin Wolf Subject: [PATCH v6 07/22] ACPI: platform_profile: Move matching string for new profile out of mutex Date: Fri, 8 Nov 2024 22:41:36 -0600 Message-ID: <20241109044151.29804-8-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241109044151.29804-1-mario.limonciello@amd.com> References: <20241109044151.29804-1-mario.limonciello@amd.com> Precedence: bulk X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SN1PEPF0002636E:EE_|IA0PR12MB8648:EE_ X-MS-Office365-Filtering-Correlation-Id: 6680f159-39c2-4474-fda5-08dd0078ead3 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|1800799024|82310400026|36860700013|7416014|376014; X-Microsoft-Antispam-Message-Info: =?utf-8?q?2XmmlKLeVm/9gv0FBSrrRduFBpC/2G5?= =?utf-8?q?tS70aJwFh1dqIv1fU0vIZFj2ZL+UwbyuTofYGcr/BVM+XhTgbYm7JHJe/eToIkgpg?= =?utf-8?q?lM/Xazfww8x3ANSLZnGHOmJGZUnRaiLhKRYkHjLnUXfCipkGMqEebfS4ZW6M7W2UM?= =?utf-8?q?tC5bgHuP+rcIYHTDM+vdd2Q2+e+ImmwPltSQZunPxWY+IbRGBCIUqKS930GgseF7P?= =?utf-8?q?NC4hWnGpzU9eIC2rYYiREPPA6eujOZTUYtYyV0Th2w757AGxDDycsXV+mygwfxRTi?= =?utf-8?q?/nA4/gXXxa7PPFYnHo2sRwpoTTnVfk7ujM/f7VXjefplnhTbBOrMeG6mXVvZqxZVM?= =?utf-8?q?r45LpsIzg6qAElVmvgkX9DEep/DFk75VCnr3sm80OeXON6PKEeFL296k+EiaKJxZe?= =?utf-8?q?usm+h0E4WGaZux+GNFFIj+33pMGZ3509W2s+xoa6V9GS14dCUX52+7lOcbj/TJdmG?= =?utf-8?q?uMQN06HLL1UsJpozqy36ncrdcUlPPU5ubQCp93uDNW91zEI8geDL0//aob3KZI781?= =?utf-8?q?JfUR6ctQwVOfrwn7SEALc43zuEyNnznYdj/QWzpx1wVusoCkW5nRwhMD8VN2Fj5Bv?= =?utf-8?q?9KMbUr8pnpXtJcdEyYRFI/AhVLf+p+IpkExu7dlIoyJjwrvgNcD2hK+QMjLSguECM?= =?utf-8?q?sfD5eHj/SRXWH+Nl+JMJa1jP4QyjxfvOBnkGSceg1vHrv/kMyvsFPUlOevsBuTJUW?= =?utf-8?q?N4DIHHdTxqQSeow8IJiZSfZIYDFFzg+UpFyxMLg66u/LqwiykBSDIRpTyfzQvdEmE?= =?utf-8?q?Hgv8F0ovK5Sklc54gOfDhrvX3zZWuuDndIKeVYEZ+e+ShJM4zPJ6CQO+zetpcDsXp?= =?utf-8?q?kRfGVQ0ApocVLtv1U1yLFi9ID1AbYdeJdGLRur17IT7Cp3fujom3KFUsfS+CNP4zD?= =?utf-8?q?MjmllGAy8fLiZOJdvw3gbccf4F4vJ+i3OgUMzluae0c0J7kV0XSXMSkN+EzbwTH4s?= =?utf-8?q?VreTSfohV3Dz/pMLplSVZSconkBg0dWkfGRWKNj1kMgSLbEO4d4H28XZvP5Dnwgl8?= =?utf-8?q?lbYGnQRyBzWiVICh/t1P3n61TlemvxtOYecNhm7ZRzp+NAGE3AUPJLgBj3ZiL+Qxz?= =?utf-8?q?7NfruRDh+Oy6PnqpHrvwLxYZplsGqGkZA+3oiy9tp9FEVOexzHSN+rTSbp+fULTSf?= =?utf-8?q?+p7vrOvmsJDJsaxDeKDjYPQK1kLiklHmUc56EdIzwrVOCmOTeYOyXI/035eBxZa+e?= =?utf-8?q?K7HVi7TeU9oDW77bMnYJpI9V5qESRsNoNOjqOAeDLbiJvxo4j0BQRHr7VUFxT3uwr?= =?utf-8?q?CE56sFoHGvl30cLhMMYCAyifxOgaFwB9lRLHSctAmTZXwQsgcCnDD7x0dPkb37hg7?= =?utf-8?q?EsWRmj9NJJWPtV5/YdNTKUU5Q67AP/DViw=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)(7416014)(376014); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Nov 2024 04:42:29.1534 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 6680f159-39c2-4474-fda5-08dd0078ead3 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: SN1PEPF0002636E.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA0PR12MB8648 Holding the mutex is not necessary while scanning the string passed into platform_profile_store(). Tested-by: Mark Pearson Reviewed-by: Ilpo Järvinen Reviewed-by: Armin Wolf Signed-off-by: Mario Limonciello --- drivers/acpi/platform_profile.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profile.c index 4f5623fc27c09..45ffd85a71dd5 100644 --- a/drivers/acpi/platform_profile.c +++ b/drivers/acpi/platform_profile.c @@ -83,6 +83,11 @@ static ssize_t platform_profile_store(struct device *dev, { int err, i; + /* Scan for a matching profile */ + i = sysfs_match_string(profile_names, buf); + if (i < 0) + return -EINVAL; + err = mutex_lock_interruptible(&profile_lock); if (err) return err; @@ -92,13 +97,6 @@ static ssize_t platform_profile_store(struct device *dev, return -ENODEV; } - /* Scan for a matching profile */ - i = sysfs_match_string(profile_names, buf); - if (i < 0) { - mutex_unlock(&profile_lock); - return -EINVAL; - } - /* Check that platform supports this profile choice */ if (!test_bit(i, cur_profile->choices)) { mutex_unlock(&profile_lock); From patchwork Sat Nov 9 04:41:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 842124 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2065.outbound.protection.outlook.com [40.107.94.65]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 39B571487E1; Sat, 9 Nov 2024 04:42:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.94.65 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731127356; cv=fail; b=V5uh9XLeBTLx+Bi9kbLyk7r9qmN4X5TNYxqDsI7OPYsbw0eremWtGI7dqEYxIchsYhUmyMj1W5f6vZGU/MJ2OQyxOpN3rRMT9F1kQOGB25bvBLztJWq/n5ORafn9ncY3OC1nd8i3fHJlTINg489yvY7+4icD5Ky39Upwd64vB8g= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731127356; c=relaxed/simple; bh=JewyXTxhFRqy6h34+YKrMpsgMeLgKwlZqckAx0I+7ck=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=dy1CfJODhPJwhFlJxGTJqvqgeANYw/fBlw/+2HPWQF5ZaAunY8If4HU+qs1dJ77NI0xWhy78bjn5gj91ckfEae22NuVLMWGYVKx1oIrsr9lKeO7cto3O4Tl6q9mvTH/BCcvvlnG4a7ujORHncPvxV4unhfziWLReSOx0c4NWvog= 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=Qdq5PoEm; arc=fail smtp.client-ip=40.107.94.65 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="Qdq5PoEm" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=joHCKdAm+rc0b3ZqH0NmCcJzLjY7qj6FwsSv40nh7fWQFdDOCQ4Z9uYuWAU31MVnf00YFfT4JQjiGy+s1ZjcyIpCLcvCgvVU/iVxy0oIH8xWPiu00zsOvsd0Vqat5YepsTS1FrkIxAxUxt6o+l9mZgy/QvBQv+hGqDRzSlcgOJyykrTl7+mwyEJJJ5hmiBMRPX1cL7hjYIGKTSC6k14pX6U8Swz7xP8FGZt5CfqTv2iq3vhLSc6BR0JMvHYuGDQePpofmy+g7d3Jk61cEz3/ykFAc4BS/JUxKOfwXbqCMYSOvc/+SYQMwMBDh9ftKRhnQpWI010VtCNAARs495srfg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=se/DRSG0jq4mSe3JIlni8+u15VBvik79rcxTvY6iGeE=; b=eEdXocRJzCkfZzbYd5cds0RbuNsEfxPo0P8GkyrjhbG0FjpjonvjSOxaKGVx3171mZrJKtWaHwh2F9qOBdpZn3jtqkVAbg0xzbTE7wGqqkamnsklB5RZXa61HiHrPr0AuWyWukCTCPReeDI6M8CNhOIJaAflAHUYRkoKpToZpWquU1lhufVt4/Qxzao9CHQZDjIPl/XAHAcSwBMyrztc1w7wrY844f0qnYtrytjstjSPqQ30tZrTCxbUc/xHd8wsBvCmg2Nc1fLuX/iMsM8UwNRmsf0nPGBXxE/MHwCOeliedAcyXVKKJgWPzywYfVJrlIZVv5Vn0z6tpMDiVe6USw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=redhat.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=se/DRSG0jq4mSe3JIlni8+u15VBvik79rcxTvY6iGeE=; b=Qdq5PoEm0w6daE4ETcqy10NjkZvP13NVPYw7d3BBYIeMUsy7H64c8r/scNO7ZLbAuHFgqAyTT1sMuPY4aMnDJclbkFWWoiPobOzCXZMO6XTA+H/kr6BTesofM5WiESvWFxbjx4Z8bbqgm5zk6KYzsOiG2/HEaCAwob51RrmC9P8= Received: from SN6PR05CA0027.namprd05.prod.outlook.com (2603:10b6:805:de::40) by MN2PR12MB4111.namprd12.prod.outlook.com (2603:10b6:208:1de::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8137.21; Sat, 9 Nov 2024 04:42:31 +0000 Received: from SN1PEPF0002636D.namprd02.prod.outlook.com (2603:10b6:805:de:cafe::fe) by SN6PR05CA0027.outlook.office365.com (2603:10b6:805:de::40) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.11 via Frontend Transport; Sat, 9 Nov 2024 04:42:30 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by SN1PEPF0002636D.mail.protection.outlook.com (10.167.241.138) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8137.17 via Frontend Transport; Sat, 9 Nov 2024 04:42:30 +0000 Received: from AUS-P9-MLIMONCI.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Fri, 8 Nov 2024 22:42:28 -0600 From: Mario Limonciello To: Hans de Goede , =?utf-8?q?Ilpo_J=C3=A4rvinen?= CC: "Rafael J . Wysocki" , Len Brown , Maximilian Luz , Lee Chun-Yi , "Shyam Sundar S K" , Corentin Chary , "Luke D . Jones" , Ike Panhc , Henrique de Moraes Holschuh , "Alexis Belmonte" , =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= , Ai Chao , Gergo Koteles , open list , "open list:ACPI" , "open list:MICROSOFT SURFACE PLATFORM PROFILE DRIVER" , "open list:THINKPAD ACPI EXTRAS DRIVER" , Mark Pearson , Matthew Schwartz , Mario Limonciello , Armin Wolf Subject: [PATCH v6 08/22] ACPI: platform_profile: Use guard(mutex) for register/unregister Date: Fri, 8 Nov 2024 22:41:37 -0600 Message-ID: <20241109044151.29804-9-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241109044151.29804-1-mario.limonciello@amd.com> References: <20241109044151.29804-1-mario.limonciello@amd.com> Precedence: bulk X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SN1PEPF0002636D:EE_|MN2PR12MB4111:EE_ X-MS-Office365-Filtering-Correlation-Id: b8437734-645f-4aad-01f6-08dd0078ebd0 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|7416014|376014|82310400026|1800799024|36860700013; X-Microsoft-Antispam-Message-Info: =?utf-8?q?ALKqO6+TvrIIA9avEuiY8voNLbrzutg?= =?utf-8?q?8vGePd/iCqkJfoL853ZYTctirsdxsstVrydf7/CkqOLD9ODUZ3a+pLovz50FZ+wZy?= =?utf-8?q?xwHfmO1fUvmwsy4UsBps9acr1bX7sInAryU5AhgkZ2DE0/1c/wYpYSiu2iE4+hDHj?= =?utf-8?q?jY+ZX97ZVj+xeEOntZgNEE+G/LLJRKpBmvyScKhc7wlmK9SHUl8AbRBaa1Q+xXrL/?= =?utf-8?q?/T34oR8Xu4PpgCw8yrkng1k3mo72pTFGZHXaIgcJis9IF2zG69prSJGPkUBINxgQc?= =?utf-8?q?iw1SUASR2gy3XyOxlAGqQg8bUsSgae9NvDC2acfod6pauLPhf7WDhV6RVfjRa0RjE?= =?utf-8?q?Gt3DfkGL5laHZNttrDIamVvvo0xSxtMA/tX8Z/L6m4ayTZ/SCUxSizeU0RAd4+b9E?= =?utf-8?q?iuD+GlnNzwZ0yajIJKc5pjNsHgYW6cFOH+dlZFniXSz9O/Z/Py+4PVZ3rjAMXX+9c?= =?utf-8?q?g9aS4wnxLkladLDgeKTUNq7Fqy1w/Zr7Uzn8dLWXHZ1d6jD+I7CcQuumJ4OUPdcxO?= =?utf-8?q?n/R/zBqfQxeME0Bxrf5Zu2c5T1rLn6w7H0jNZfxV8NSHe5aWOogCH7ox37wlMbCEe?= =?utf-8?q?bQiiF4qAnjre5JJB2h8GeXWbhQ5BlKJbN1ZufurN4r+nLbNMuBiFAd+/YPZNY+76A?= =?utf-8?q?0em7ugs04tR/GwsjbhbhXQUqWOPscgZscP5yIJsOJoahF6e/lEBACArRBwkvH0l/x?= =?utf-8?q?82nqzxVV9fNkeHbUF7T4Sb/wckMrci8x6H8so5ZPLWaHLc3IdZJyoSKlP4oHrPxQ0?= =?utf-8?q?D277VKY6sNP795ugdyTe1IFKakksTBZew3xa9JCvTcXaEzneXuAhcrhp4tMp/+x2a?= =?utf-8?q?m2XZjE24EPAscPd6tz03B7eF7qJB3wO/29Yp9UnLRTx0v3vRq+P2GlAkLNLBKlwb0?= =?utf-8?q?HbZ8fTi0tYd2nhTP2O91r0m1wxPjpBaZao+K9f5V7TciUAfEbx3Piq2pVfOxhs/VJ?= =?utf-8?q?jnKsTg4uEEkMFIHeXvx8VrPgCDnBWftjhHMEnhJ/2dYBFtwjTNpWMNvAH1Jo7XMHn?= =?utf-8?q?VGhq9sT30ycPRVCo5eYJUSqC5uIizSUI+TD8VznZ0yMhEaXDsCinMxqld6CF8v9e1?= =?utf-8?q?Fsk2tErj8HC5FQwPPEp95C3sZRQRLJjW2O41jLBJijuIjHKQO7LpJt1T/Wdp8KPCX?= =?utf-8?q?CtYu5BrjVQ00f3OVT0YM+ro+q/DJ39v69t+FIiSBuD4qcV5Ro2Dt4RdcWSu/ZmYtI?= =?utf-8?q?/4owkGyT7hDZOvj6VNhn7shlx/RFQ7Mu9uG2Oas6fZ9E7GhjpkbrvTuOd+XAoQwCy?= =?utf-8?q?MdyG6ldA0mqLkLpOz37pygWIzmWDEmWY8Ku5GHG7Wz/QIUBlh45G4nwOCat6nO2ru?= =?utf-8?q?w5QPDqjPyZ3x8GumFbVJ67uMgx0YJTzeog=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)(1800799024)(36860700013); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Nov 2024 04:42:30.8050 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b8437734-645f-4aad-01f6-08dd0078ebd0 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: SN1PEPF0002636D.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR12MB4111 guard(mutex) can be used to automatically release mutexes when going out of scope. Tested-by: Mark Pearson Tested-by: Matthew Schwartz Reviewed-by: Hans de Goede Reviewed-by: Mark Pearson Reviewed-by: Ilpo Järvinen Reviewed-by: Armin Wolf Signed-off-by: Mario Limonciello --- drivers/acpi/platform_profile.c | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profile.c index 45ffd85a71dd5..9729543df6333 100644 --- a/drivers/acpi/platform_profile.c +++ b/drivers/acpi/platform_profile.c @@ -184,32 +184,26 @@ int platform_profile_register(struct platform_profile_handler *pprof) return -EINVAL; } - mutex_lock(&profile_lock); + guard(mutex)(&profile_lock); /* We can only have one active profile */ - if (cur_profile) { - mutex_unlock(&profile_lock); + if (cur_profile) return -EEXIST; - } err = sysfs_create_group(acpi_kobj, &platform_profile_group); - if (err) { - mutex_unlock(&profile_lock); + if (err) return err; - } cur_profile = pprof; - mutex_unlock(&profile_lock); return 0; } EXPORT_SYMBOL_GPL(platform_profile_register); int platform_profile_remove(struct platform_profile_handler *pprof) { - sysfs_remove_group(acpi_kobj, &platform_profile_group); + guard(mutex)(&profile_lock); - mutex_lock(&profile_lock); + sysfs_remove_group(acpi_kobj, &platform_profile_group); cur_profile = NULL; - mutex_unlock(&profile_lock); return 0; } EXPORT_SYMBOL_GPL(platform_profile_remove); From patchwork Sat Nov 9 04:41:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 842753 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2083.outbound.protection.outlook.com [40.107.236.83]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8270314A0B3; Sat, 9 Nov 2024 04:42:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.236.83 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731127359; cv=fail; b=OGpvk/Dkhxsp3wJuYt5zqJZ2j5ZyDx3JKNbxHwSSHFoEj/F33vbhHIDIbIfUZrCkIApxsCeKD+7N5gulSsPPqK8kYiKHNJVFrtY+en7JxH3i8/oipc6HFFHr8tDGRnQflIupXJIdnFWq9AFBKE5lJxMVhHBRb5cNl1F56hphVhc= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731127359; c=relaxed/simple; bh=eR/kuOWvhZLZUdUk6IKGkBbP0bE5GeKHJI29oIiDKh4=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=ct5+rp4Jjk9Ao1RpYUxQeNvKE9xnMVIX4m2Novqe4p7j9qabWaE4IuOHUrSZQ7u/40mJkUBmIu0lRztY73ARmAWGzY8e2izg8ssEwB24Efwx0Z4rxp8RRsCe9/KVNhKdwLI1Fa6gHYlHsOYLHQDgZps0oHatHES+POTPse/AON4= 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=glxb5FWw; arc=fail smtp.client-ip=40.107.236.83 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="glxb5FWw" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=UJ+VEQEXf053cNlNoGJtAvGngmYgOusnrFuLfg+PdASwrH8gMtKUjTlvKIuqpWsEE2i6kf7V7ATFB8oO8BkpkDbQnlGUq8vh6Pw1/4hTkItNSzGauGLVHTbppmYGoAwLGKRghfRcED9f5fWun9Lu+cjQ5chcgcSyUh4tToIpbpIN6/vEa8bNViKdiU+hBDmz6aYGdzbFRZ35S5R/orHaBY+gY9j4BVEGQAIp7IcbUVHnh5RwvaHRYgvrFok/AuoKEfXNsd2zGh98BakqxsdL2KDgtNBjLx7luv++AVZaMFD+eaB1Q0OpDJfZFmSVLhpU/FWaTWLJ+mDNCQEgGbkYfg== 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=ZLQ/qcNQHbvVxO8H7Dy9mDWXqRfXGHQv2or+UNEXmN8=; b=K5mENcUVKgcfvXkr8sBIH2mZuFUs3dEamBfQmv4n4/3FQ5NxAprCKmO8hvxFpciMBX0xQlGwTNMCUx0A7/EsHGEIhIevM8z7PYQNip4Wlc7WDcK8NCficpQou6L9vtnqTS++NanBZy6iLMcVHtPQxKOeAKL+lzRaI6THNQuPL4u5P/ZxcN8eYfj4wUzFq6nYIPTUsMlQFtpVRyJ99awUv5P7q1EpPp2yWOom4ngUicuSBYaYQFh/Svtjc2AsYe/GlCLM26ReqZDnymxaetTpTWK1k/tjl+fJY1VdrT4VBIGi4HvCLqXLID6leMtSqJNRCNbzx91ukUdoeGwE1MLo9Q== 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=ZLQ/qcNQHbvVxO8H7Dy9mDWXqRfXGHQv2or+UNEXmN8=; b=glxb5FWwNDw9tUaEEe3P7h394JNT/F/LFCFKqXb6rC/Zb0m0kmq1fufy23sE4fauxaNeY3JfXln1EU8LV5lcO3NSrwT82hu3tO60adphaMihoyBznNYLFC3JrsP4Algw9hYoh0sIz+q2rYU2HbXhYStMd5RLuDc8aoa6Bt6XaVg= Received: from SN4PR0501CA0069.namprd05.prod.outlook.com (2603:10b6:803:41::46) by MN2PR12MB4335.namprd12.prod.outlook.com (2603:10b6:208:1d4::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8137.22; Sat, 9 Nov 2024 04:42:32 +0000 Received: from SN1PEPF00026369.namprd02.prod.outlook.com (2603:10b6:803:41:cafe::63) by SN4PR0501CA0069.outlook.office365.com (2603:10b6:803:41::46) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.11 via Frontend Transport; Sat, 9 Nov 2024 04:42:32 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by SN1PEPF00026369.mail.protection.outlook.com (10.167.241.134) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8137.17 via Frontend Transport; Sat, 9 Nov 2024 04:42:32 +0000 Received: from AUS-P9-MLIMONCI.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Fri, 8 Nov 2024 22:42:30 -0600 From: Mario Limonciello To: Hans de Goede , =?utf-8?q?Ilpo_J=C3=A4rvinen?= CC: "Rafael J . Wysocki" , Len Brown , Maximilian Luz , Lee Chun-Yi , "Shyam Sundar S K" , Corentin Chary , "Luke D . Jones" , Ike Panhc , Henrique de Moraes Holschuh , "Alexis Belmonte" , =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= , Ai Chao , Gergo Koteles , open list , "open list:ACPI" , "open list:MICROSOFT SURFACE PLATFORM PROFILE DRIVER" , "open list:THINKPAD ACPI EXTRAS DRIVER" , Mark Pearson , Matthew Schwartz , Mario Limonciello Subject: [PATCH v6 09/22] ACPI: platform_profile: Use `scoped_cond_guard` Date: Fri, 8 Nov 2024 22:41:38 -0600 Message-ID: <20241109044151.29804-10-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241109044151.29804-1-mario.limonciello@amd.com> References: <20241109044151.29804-1-mario.limonciello@amd.com> Precedence: bulk X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SN1PEPF00026369:EE_|MN2PR12MB4335:EE_ X-MS-Office365-Filtering-Correlation-Id: d15dbcfc-e2c8-4129-30c8-08dd0078ecfb X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|36860700013|82310400026|1800799024|7416014|376014; X-Microsoft-Antispam-Message-Info: =?utf-8?q?O21KDmQr4cvvLa7EZydhILFfpaOBJ3H?= =?utf-8?q?aMvZHYgELNoFgiErOzl+GQUQ6IkKru5m8Qz8L0bNGDuHx1QeTudhUUk0tdAlkPYxf?= =?utf-8?q?RvGH+7m2E0NXFHFLxKyzcaDtus6oR7uoewMKxaOJGoiwhqKwQRg6aTBmaHtgJLLwH?= =?utf-8?q?pLkxSmLqLDy8BNPrbMwBUzbq6bkW8Vze0/6/y0sHUSmSMWNvDfBM6LNKwuoKSXADR?= =?utf-8?q?4wZKVzIUpzxBnj/xU+X6whZ7yFaQelzeV79RxEEj9pgg5crlMBMbKSK0cISfVcQsm?= =?utf-8?q?9rMhq1BMpZNgpGq71ZcPNMnWCl6Afavht91y1F+BicSeacfzO+Q+iZ5qJrCOLZzQa?= =?utf-8?q?2JWk0qS661+k25kQ/QRtZmfZJGy6ah5D1muqA1VGLkwhkfONPyd7b5iFTgMgx7B0z?= =?utf-8?q?VDPNlvSeaDsFtbmROfJvwKT4NgveV9e4qSWxq93y9zmWjmMuSks/VGEfKumU7AJKv?= =?utf-8?q?5SAVjTyLnBcAfoWWdXkTBCfRdEqmoqbwo47/GFS3GfWI/85g48wxDmGgGRj5cjSkS?= =?utf-8?q?9J2xoTAptb9AR2aA/ukDTjF2/4h/ZKpyM6LEdj9KZ4g79uS55twtLI1yys+sUdUZ/?= =?utf-8?q?9CDbWao4JmZ473dhPzVjO8LWMNR0J7lTpFXjmoeQsjVCONLK4z0UnBtgKIMTsqZH0?= =?utf-8?q?jm0gUuI0zXtu2e6FRy1p//LGVMxs2U9noYLiBUxvySZEPpe/LhLNQJgsyNwVeHUD6?= =?utf-8?q?7TukhAt+dEaKkthewXYfIBU5Bq4bAGygD1YEW/RLehbkR8z1ba/YUGuQOerwl3EyR?= =?utf-8?q?s5rvwi8Q8RVyKXVx72mr5R57wWo335QnwhApCxLDcG7kTeqL26LsBz58vV1l0k1+r?= =?utf-8?q?9KPAiUmFq9BapS6PpyGad0W3myY/50kUHBegopzT32oPeTfaQFDISHOH7oCLx2hER?= =?utf-8?q?lySKybrB0SutpIdYR6WexgPOigtTDoDzPSnN6pd+cAqk6x11noAd4u3oRNb4iB8wn?= =?utf-8?q?zNr0O7FXZwNwq5w5FRKlLmmdO1xnDlHRg/NscoOZ7Y8r+sU69z6Ir2FpenLfA0h0n?= =?utf-8?q?0KelzykmIoGNMnjNmhK9AR4y/yBLUjZbalOWRVi+2qyE6mMmc1rc0NSGoaQAtpL5a?= =?utf-8?q?9t9+isVWBLLD6JxeAC0Amu2uq7mvLTHph+Qdt6c83bZQJvfWAaXs5GZi4Kay0++I2?= =?utf-8?q?hjsC8ub42VQO7/qgTy9xKV/JuWT/LcErPyHbL3pj3xRVmbSnoyNKOtWrO4jKTk7wq?= =?utf-8?q?C4bnJwoy9bOekpcEMMmdm47PQBc4pgYX3ufnUkh7ImFA15/KAsFpV6hZoHiYTErRS?= =?utf-8?q?meaf+FhyLLUEujSvCR4FRwFIxtZPvAXxvumRTZmkkZkNh6LV4ajQMyHPfNaiBOUgi?= =?utf-8?q?jEsZWa+t0bFZ3OqYEP+n5TCSV+Fp90JQew=3D=3D?= X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230040)(36860700013)(82310400026)(1800799024)(7416014)(376014); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Nov 2024 04:42:32.7501 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: d15dbcfc-e2c8-4129-30c8-08dd0078ecfb 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: SN1PEPF00026369.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR12MB4335 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ärvinen Signed-off-by: Mario Limonciello Reviewed-by: Armin Wolf --- drivers/acpi/platform_profile.c | 111 +++++++++++++------------------- 1 file changed, 43 insertions(+), 68 deletions(-) diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profile.c index 9729543df6333..32affb75e782d 100644 --- a/drivers/acpi/platform_profile.c +++ b/drivers/acpi/platform_profile.c @@ -27,25 +27,20 @@ static ssize_t platform_profile_choices_show(struct device *dev, char *buf) { int len = 0; - int err, i; - - err = mutex_lock_interruptible(&profile_lock); - if (err) - return err; - - if (!cur_profile) { - mutex_unlock(&profile_lock); - return -ENODEV; - } - - for_each_set_bit(i, cur_profile->choices, PLATFORM_PROFILE_LAST) { - if (len == 0) - len += sysfs_emit_at(buf, len, "%s", profile_names[i]); - else - len += sysfs_emit_at(buf, len, " %s", profile_names[i]); + int i; + + scoped_cond_guard(mutex_intr, return -ERESTARTSYS, &profile_lock) { + if (!cur_profile) + return -ENODEV; + for_each_set_bit(i, cur_profile->choices, PLATFORM_PROFILE_LAST) { + if (len == 0) + len += sysfs_emit_at(buf, len, "%s", profile_names[i]); + else + len += sysfs_emit_at(buf, len, " %s", profile_names[i]); + } } len += sysfs_emit_at(buf, len, "\n"); - mutex_unlock(&profile_lock); + return len; } @@ -56,20 +51,15 @@ static ssize_t platform_profile_show(struct device *dev, enum platform_profile_option profile = PLATFORM_PROFILE_BALANCED; int err; - err = mutex_lock_interruptible(&profile_lock); - if (err) - return err; + scoped_cond_guard(mutex_intr, return -ERESTARTSYS, &profile_lock) { + if (!cur_profile) + return -ENODEV; - if (!cur_profile) { - mutex_unlock(&profile_lock); - return -ENODEV; + err = cur_profile->profile_get(cur_profile, &profile); + if (err) + return err; } - err = cur_profile->profile_get(cur_profile, &profile); - mutex_unlock(&profile_lock); - if (err) - return err; - /* Check that profile is valid index */ if (WARN_ON((profile < 0) || (profile >= ARRAY_SIZE(profile_names)))) return -EIO; @@ -88,28 +78,21 @@ static ssize_t platform_profile_store(struct device *dev, if (i < 0) return -EINVAL; - err = mutex_lock_interruptible(&profile_lock); - if (err) - return err; + scoped_cond_guard(mutex_intr, return -ERESTARTSYS, &profile_lock) { + if (!cur_profile) + return -ENODEV; - if (!cur_profile) { - mutex_unlock(&profile_lock); - return -ENODEV; - } + /* Check that platform supports this profile choice */ + if (!test_bit(i, cur_profile->choices)) + return -EOPNOTSUPP; - /* Check that platform supports this profile choice */ - if (!test_bit(i, cur_profile->choices)) { - mutex_unlock(&profile_lock); - return -EOPNOTSUPP; + err = cur_profile->profile_set(cur_profile, i); + if (err) + return err; } - err = cur_profile->profile_set(cur_profile, i); - if (!err) - sysfs_notify(acpi_kobj, NULL, "platform_profile"); + sysfs_notify(acpi_kobj, NULL, "platform_profile"); - mutex_unlock(&profile_lock); - if (err) - return err; return count; } @@ -140,36 +123,28 @@ int platform_profile_cycle(void) enum platform_profile_option next; int err; - err = mutex_lock_interruptible(&profile_lock); - if (err) - return err; + scoped_cond_guard(mutex_intr, return -ERESTARTSYS, &profile_lock) { + if (!cur_profile) + return -ENODEV; - if (!cur_profile) { - mutex_unlock(&profile_lock); - return -ENODEV; - } + err = cur_profile->profile_get(cur_profile, &profile); + if (err) + return err; - err = cur_profile->profile_get(cur_profile, &profile); - if (err) { - mutex_unlock(&profile_lock); - return err; - } + next = find_next_bit_wrap(cur_profile->choices, PLATFORM_PROFILE_LAST, + profile + 1); - next = find_next_bit_wrap(cur_profile->choices, PLATFORM_PROFILE_LAST, - profile + 1); + if (WARN_ON(next == PLATFORM_PROFILE_LAST)) + return -EINVAL; - if (WARN_ON(next == PLATFORM_PROFILE_LAST)) { - mutex_unlock(&profile_lock); - return -EINVAL; + err = cur_profile->profile_set(cur_profile, next); + if (err) + return err; } - err = cur_profile->profile_set(cur_profile, next); - mutex_unlock(&profile_lock); - - if (!err) - sysfs_notify(acpi_kobj, NULL, "platform_profile"); + sysfs_notify(acpi_kobj, NULL, "platform_profile"); - return err; + return 0; } EXPORT_SYMBOL_GPL(platform_profile_cycle); From patchwork Sat Nov 9 04:41:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 842123 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2071.outbound.protection.outlook.com [40.107.94.71]) (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 1A2F814BFA2; Sat, 9 Nov 2024 04:42:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.94.71 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731127360; cv=fail; b=GuY/DvA2+/RUMdk9A5+zcRtbTEeupUuSwGUuv04BtC7aVcY5aggMBttfNidc4iur2f4alovhseuVisKqZDUcnSHChNB2gAb7Me5UXVHtLmYVGsNmoGynAPi55CYxRFbHLkxQIsiimSjDBlOw8q2pjZ3Sx8ofaONEPqcy8YTTtAI= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731127360; c=relaxed/simple; bh=D+yCQxbo6OQVYgq4rUDJX6Wq9/+HRYxdcjv7STWA1cE=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=HtaoegAd6Kdr9zsjx42xYbQyWr2FqaVTo9lxHlHnUPioGqRV+rVzXzDENWLHOTFsJqYPkArNIbWFh/80zFIH3Grmdw+wXt4FCS6U8UK+rpCvdQmgkT2OW2defj6bPZu0JJucVCzT8ZUGsO96fLwK5EM6JUhwItkOo7KCnZchQrI= 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=b80oDnBq; arc=fail smtp.client-ip=40.107.94.71 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="b80oDnBq" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=NDRsRj3WpSONFMN8ED3oJ3Ud17IkJvxx5Q4dGBKcIT4C6zieCxY5TJUdDFidlOAY8MMau7oNbXBvUIO8og81xoowg0lKiQy82RVyhKGrRrveo94Lwkll2LaQaY5KPqTVjOrjL/UnhAvrVO/2DkbgEcOyGmQCLN/pUSRvA7ZXcXqgg3AsT4Q0DarcJO0qDdM+FQnKUpRojnxOMfDjW9Ei5CAVl+vdAPhs4+xOXj2P2MCTv7JPGgvOG2VvST26xx+gt0++KSdquhue6e77GMvkDyd4RBJtpjsFYlCqst+YDS9o8afAHHs5GFcTxasGkyT3537tXkK+kiMoGVW7h9PxTg== 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=SmA0qmmNZISG15FOi9ca4nKDuX+mtJBiIBI0F557wD8=; b=J/dMz5UqcImCLFq7eRj4bELv/d5zuXp/dGdVduiv6Ub3rUzYiP/D6ehYxuY64Zi+A8uUzeKfmh88YFGR53sVPGezzKpKSgEgh75AuG/U9YJ/qVTKMfCrewAZZn3LCaRHMJnFLTgf5VMJH0Cqnzr5EXRRlnTFaJcT1DDuMXuweVgXv274C8vq8PuOJ8y51zq++QWtvSNoRXDqeF3n6W+I6fCxSE6AXbdcLPMAkvrh42LZSnZC+Oghk31mvLoyP71i7ZID/xoptigpke+uVlsV9Ajo6gitAxHRqxRzaw9ReC7R9OEf7g93UlwDEzustEmw3+59VTPzNJbp1MmjwC71Ew== 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=SmA0qmmNZISG15FOi9ca4nKDuX+mtJBiIBI0F557wD8=; b=b80oDnBq4h4LzvhHUVhpfbDaR7+zNAEsHMbih08YAnyju1Bo4UE+ZStLcGQ47lFEOaD714yguYAcvdcw1FAj2AtOjoVbtTfmF0LdwixPptJN2XxiM0xHGodz5XCAEvFNmuJ7r3/QDScTPae0pSyND/Jb/T2vouQgGr4wjN4Il6Y= Received: from SA0PR11CA0166.namprd11.prod.outlook.com (2603:10b6:806:1bb::21) by DM4PR12MB6496.namprd12.prod.outlook.com (2603:10b6:8:bd::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8137.20; Sat, 9 Nov 2024 04:42:34 +0000 Received: from SN1PEPF00026367.namprd02.prod.outlook.com (2603:10b6:806:1bb:cafe::fc) by SA0PR11CA0166.outlook.office365.com (2603:10b6:806:1bb::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; Sat, 9 Nov 2024 04:42:34 +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 SN1PEPF00026367.mail.protection.outlook.com (10.167.241.132) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8137.17 via Frontend Transport; Sat, 9 Nov 2024 04:42:34 +0000 Received: from AUS-P9-MLIMONCI.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Fri, 8 Nov 2024 22:42:32 -0600 From: Mario Limonciello To: Hans de Goede , =?utf-8?q?Ilpo_J=C3=A4rvinen?= CC: "Rafael J . Wysocki" , Len Brown , Maximilian Luz , Lee Chun-Yi , "Shyam Sundar S K" , Corentin Chary , "Luke D . Jones" , Ike Panhc , Henrique de Moraes Holschuh , "Alexis Belmonte" , =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= , Ai Chao , Gergo Koteles , open list , "open list:ACPI" , "open list:MICROSOFT SURFACE PLATFORM PROFILE DRIVER" , "open list:THINKPAD ACPI EXTRAS DRIVER" , Mark Pearson , Matthew Schwartz , Mario Limonciello Subject: [PATCH v6 10/22] ACPI: platform_profile: Create class for ACPI platform profile Date: Fri, 8 Nov 2024 22:41:39 -0600 Message-ID: <20241109044151.29804-11-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241109044151.29804-1-mario.limonciello@amd.com> References: <20241109044151.29804-1-mario.limonciello@amd.com> Precedence: bulk X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SN1PEPF00026367:EE_|DM4PR12MB6496:EE_ X-MS-Office365-Filtering-Correlation-Id: fdb49b3e-a894-4f93-4433-08dd0078edba 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: hD2M5cuPykH55vXN4pTg9NWmQ4fI9AkTHQYHCSBf4OUKRezF2IOSdyox7OKxmugHyDFYSFDo9wVbiNeXdXKecDJHaPc85T1JalWN8q7mRSxd0E+zacQT06N5Uyjhg27y7Xyzy4ZpBAf6Ed8si+WiqLMIuJSgGEEkJMoSX07kSvo3Hwz2RnblXjkDkKuK81ISjsUvzbd9Jr5SqvC/0ri7ZStvQrwDmJ8tr81bhVk1gHpycGJbBsfBilklGIUbZvrSNevpxqECkjFEfKqWEsxZB9l3JfNGu6YoirUvHf4obTgIN2HjlUEkl5q+A8he/kUtGM7xMnzPL0pCLDddqv954Gn/9y7Arh72kYy41vhG+TnYHYzb88nX3d96kGjuODWzfK1EMCLtkQ075k5MR4/dPxBQdgR4TBo/EyrtFZB/muIrrcjMEcKe8iF5tFubd6iSJAVBbl07WyPUyEILwysBmeWMX65aqPw2kY+GUZJ7hHI8XmCXqjYOppA9nabp5bVQ0sDpLm2iP2WEuSb9sIuejVxvssXCJfU7mk3+8f1K9OC+KxFBpwAFQit76PqWwQc3BGXd7Hcbs/A8Oe9W/lPEqUiTcTZeXEOfBXa++RtILEKKoOLG5/2+vjhRXVNoF4qyd0FHixnkwx4SCjaazn5AWkfsmAsB4fxr8tXQF0GQ9rESShPjKeF0Dg5ShPe5lpSWrTF1XP1Rb8aKmV0PGl4qeSjQLouBEyf1ZrT/vxjvLOKok7qD+4zXwOQGK6AmkdRae0lBDIBZeKyGdj7XiwYBphcA0qDRu/8sGSHH0ODrKAjsaK5NV6MfrYsLV6Cn8ztNa/VzdcLoDZsIO08611gkjmv58yVFGcSHHq4Pf7uleXLEp+vKWsfiIRn4doBM1BBAA/yiPQtPHxVk7upmHckge5papO3c6L4y5KIkVuALlFETLS1T2XRJukhVSAugk/5gAjvrEtIDrkHGd/AmDvgAmzvirGBHyJdpkOAc/bdY0ql49uxi14T9MP7EHDaDX670ewwH6kwF9/Gx3rg0BSLX4ui5kO9uOLhKlHxTh5RLZcBeo59UTD9/Ttfql4+DlviDMJiwEq1GTcJK0ajGHAxFQjoPeTVzeV5gla0AjKMIwKDpyo/kcSZ4b71BW0NlUvutyo04jLa1dKcNzouapJU2Qe9JyE58yzgzwy9faJ8jz3DjHmnvm2Tmve5riOOYCYayjaK1uzZpNVv0DCz6Il+PcVIa+4eHA23vm12yZ1JmS69kJsCfDsY4aqG7U/018Y1owJkjHKnaiWwRk78EWYroflqGrIUcbar/KVaIQsXyq10L3veAnC77op7cUP8z8cavTM1lGatxdOSZpkc1KQyKIWGCiubIh2JuG6osaqWCN3y4JTP7UTVP3w8UFASgEtAptr1NoYZhzes8tTFheaopmw== 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: 09 Nov 2024 04:42:34.0180 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: fdb49b3e-a894-4f93-4433-08dd0078edba 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: SN1PEPF00026367.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB6496 When registering a platform profile handler create a class device that will allow changing a single platform profile handler. The class and sysfs group are no longer needed when the platform profile core is a module and unloaded, so remove them at that time as well. Tested-by: Mark Pearson Signed-off-by: Mario Limonciello Reviewed-by: Armin Wolf --- v6: * Catch failures in ida_alloc * Use 4th argument of device_create instead of dev_set_drvdata() * Squash unregister patch * Add module init callback * Move class creation to module init * Update visibility based on group presence * Add back parent device v5: * Use ida instead of idr * Use device_unregister instead of device_destroy() * MKDEV (0, 0) --- drivers/acpi/platform_profile.c | 88 ++++++++++++++++++++++++++++++-- include/linux/platform_profile.h | 2 + 2 files changed, 85 insertions(+), 5 deletions(-) diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profile.c index 32affb75e782d..ef6af2c655524 100644 --- a/drivers/acpi/platform_profile.c +++ b/drivers/acpi/platform_profile.c @@ -5,6 +5,7 @@ #include #include #include +#include #include #include #include @@ -22,6 +23,12 @@ static const char * const profile_names[] = { }; static_assert(ARRAY_SIZE(profile_names) == PLATFORM_PROFILE_LAST); +static DEFINE_IDA(platform_profile_ida); + +static const struct class platform_profile_class = { + .name = "platform-profile", +}; + static ssize_t platform_profile_choices_show(struct device *dev, struct device_attribute *attr, char *buf) @@ -105,8 +112,25 @@ static struct attribute *platform_profile_attrs[] = { NULL }; +static int profile_class_registered(struct device *dev, const void *data) +{ + return 1; +} + +static umode_t profile_class_is_visible(struct kobject *kobj, struct attribute *attr, int idx) +{ + if (!class_find_device(&platform_profile_class, NULL, NULL, profile_class_registered)) + return 0; + if (attr == &dev_attr_platform_profile_choices.attr) + return 0444; + if (attr == &dev_attr_platform_profile.attr) + return 0644; + return 0; +} + static const struct attribute_group platform_profile_group = { - .attrs = platform_profile_attrs + .attrs = platform_profile_attrs, + .is_visible = profile_class_is_visible, }; void platform_profile_notify(struct platform_profile_handler *pprof) @@ -123,6 +147,9 @@ int platform_profile_cycle(void) enum platform_profile_option next; int err; + if (!class_is_registered(&platform_profile_class)) + return -ENODEV; + scoped_cond_guard(mutex_intr, return -ERESTARTSYS, &profile_lock) { if (!cur_profile) return -ENODEV; @@ -164,25 +191,76 @@ int platform_profile_register(struct platform_profile_handler *pprof) if (cur_profile) return -EEXIST; - err = sysfs_create_group(acpi_kobj, &platform_profile_group); - if (err) - return err; + /* create class interface for individual handler */ + pprof->minor = ida_alloc(&platform_profile_ida, GFP_KERNEL); + if (pprof->minor < 0) + return pprof->minor; + pprof->class_dev = device_create(&platform_profile_class, pprof->dev, + MKDEV(0, 0), pprof, "platform-profile-%d", + pprof->minor); + if (IS_ERR(pprof->class_dev)) { + err = PTR_ERR(pprof->class_dev); + goto cleanup_ida; + } cur_profile = pprof; + + err = sysfs_update_group(acpi_kobj, &platform_profile_group); + if (err) + goto cleanup_cur; + return 0; + +cleanup_cur: + cur_profile = NULL; + device_unregister(pprof->class_dev); + +cleanup_ida: + ida_free(&platform_profile_ida, pprof->minor); + + return err; } EXPORT_SYMBOL_GPL(platform_profile_register); int platform_profile_remove(struct platform_profile_handler *pprof) { + int id; guard(mutex)(&profile_lock); - sysfs_remove_group(acpi_kobj, &platform_profile_group); + id = pprof->minor; + device_unregister(pprof->class_dev); + ida_free(&platform_profile_ida, id); + cur_profile = NULL; + + sysfs_update_group(acpi_kobj, &platform_profile_group); + return 0; } EXPORT_SYMBOL_GPL(platform_profile_remove); +static int __init platform_profile_init(void) +{ + int err; + + err = class_register(&platform_profile_class); + if (err) + return err; + + err = sysfs_create_group(acpi_kobj, &platform_profile_group); + if (err) + class_unregister(&platform_profile_class); + + return err; +} +static void __exit platform_profile_exit(void) +{ + class_unregister(&platform_profile_class); + sysfs_remove_group(acpi_kobj, &platform_profile_group); +} +module_init(platform_profile_init); +module_exit(platform_profile_exit); + MODULE_AUTHOR("Mark Pearson "); MODULE_DESCRIPTION("ACPI platform profile sysfs interface"); MODULE_LICENSE("GPL"); diff --git a/include/linux/platform_profile.h b/include/linux/platform_profile.h index 8ec0b8da56db5..a888fd085c513 100644 --- a/include/linux/platform_profile.h +++ b/include/linux/platform_profile.h @@ -29,6 +29,8 @@ enum platform_profile_option { struct platform_profile_handler { const char *name; struct device *dev; + struct device *class_dev; + int minor; unsigned long choices[BITS_TO_LONGS(PLATFORM_PROFILE_LAST)]; int (*profile_get)(struct platform_profile_handler *pprof, enum platform_profile_option *profile); From patchwork Sat Nov 9 04:41:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 842752 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 A57B614E2E2; Sat, 9 Nov 2024 04:42:39 +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=1731127362; cv=fail; b=HrpgokYDQkxdER3H8h4s4aYoCtK0GW25M+moswYHiys23TbedhOxvz8UAv9SlakC80KCCIorcU1IWX8xNuwjsvp5nDw0clvLmFY4fduVwwDQ75HID2QxpQ312k/zIU3716AY1SIerLXouD3qWo58Tk+ecW2Ov8aMes1pP+yAMWI= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731127362; c=relaxed/simple; bh=HGDYb6E3Ep9CGITCDX/pPIR65jpsAY74b5ZZzMATpFY=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=lpy3z0jucT4BybE761ADQbB2vaTZBqN24NjohAzLSAxiDv1yuslJ35jz6rnyEcDsz2VkKzTQNJ+AsLeW6PkeEcxNB7AfOLW8JGRSrnUSI4P+G+KXSfQtCQP5mPITUOuqycpwAHuavsq6OUd/jL8XoKMvIIdD1QcaJuu9SR+OiNQ= 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=Vg6byXr+; 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="Vg6byXr+" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=iL3VgvL5QYp3mFvWRkbKgAG4EQyN1w990kTg8KgG0BjJ8mQOzEUlYJjJ7PpmToAQW0pymjobSZRO8e0/KKCcWD/HPdWf90wx1Owd13I+iPMBwKPCzsTraBre8hMu8WJxnxX3CqJevgcF5IiippvJv/L0bcF+xHWMY9ypmAIGE4N0ZmHbMPTDJ8gd1cma8NA17ps3bfLpU+rM4E4wC2PGMZJCw7AUP4rZwsISZ5CR5IiCh/Rk7ipPIgHxlaszABtGvwBKQ3Hp0VpCODv0AP3yo2WsiuhYdG8yvhzNAgcXEmgsJhrw+LZYkFjm7UD/T1TIqPt4yO4DRSDohUrMAtK94Q== 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=BOXcBrBLAH9/3L6MbvMpLc15RNFiukcUladgc2K1Irs=; b=IxCYn3iu1vQMfLZBrdCfLEyCCofWyIxhrxakRrD9qsPkmAMw6vvbdKqw7kiDrxMYr469Ui6QSGltNPSti4gRlfnUPcjOpXQmZtbAu/aMNUtwgZichm2N5J+TO/98OxWAeqdEbQZolwZPNzzxOLacY98cqokbCkmcb5FQdIWRoTI2Fs0utOA5quuqCYPiWhA3fHrF57Rj4Fiwtw5hFxamqIeZBCRDWHtNsWgi9s1CY9QXWy/DqDo5UWQ+4pN1H7U16awP1zQQW0hgeGr7IACLsGmUZso2jWwCTlOm2EoEPC4Rz7XLhVbiwgfig51yU/Cd6jqQAEGg+Qzpm6iQuG7eSg== 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=BOXcBrBLAH9/3L6MbvMpLc15RNFiukcUladgc2K1Irs=; b=Vg6byXr+JSSw0rvmkAGju6yEWm9+hMFb2LZFyVHRtZDCnk3MKzFOpL56mOM5EsPwMdK4YlR+SxB3q/4QGo4A2MJt4Km1RgTfccA3qT3fg/r+Vqmpxcnf1lePP0VG7uUVoVu8ZArUDJMjMvH1vRWc+wKBPCXbjstGzJpbkj773ac= Received: from SN6PR04CA0096.namprd04.prod.outlook.com (2603:10b6:805:f2::37) by SN7PR12MB7884.namprd12.prod.outlook.com (2603:10b6:806:343::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8137.19; Sat, 9 Nov 2024 04:42:35 +0000 Received: from SN1PEPF0002636B.namprd02.prod.outlook.com (2603:10b6:805:f2:cafe::c3) by SN6PR04CA0096.outlook.office365.com (2603:10b6:805:f2::37) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8137.20 via Frontend Transport; Sat, 9 Nov 2024 04:42:35 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by SN1PEPF0002636B.mail.protection.outlook.com (10.167.241.136) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8137.17 via Frontend Transport; Sat, 9 Nov 2024 04:42:35 +0000 Received: from AUS-P9-MLIMONCI.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Fri, 8 Nov 2024 22:42:33 -0600 From: Mario Limonciello To: Hans de Goede , =?utf-8?q?Ilpo_J=C3=A4rvinen?= CC: "Rafael J . Wysocki" , Len Brown , Maximilian Luz , Lee Chun-Yi , "Shyam Sundar S K" , Corentin Chary , "Luke D . Jones" , Ike Panhc , Henrique de Moraes Holschuh , "Alexis Belmonte" , =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= , Ai Chao , Gergo Koteles , open list , "open list:ACPI" , "open list:MICROSOFT SURFACE PLATFORM PROFILE DRIVER" , "open list:THINKPAD ACPI EXTRAS DRIVER" , Mark Pearson , Matthew Schwartz , Mario Limonciello Subject: [PATCH v6 11/22] ACPI: platform_profile: Add name attribute to class interface Date: Fri, 8 Nov 2024 22:41:40 -0600 Message-ID: <20241109044151.29804-12-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241109044151.29804-1-mario.limonciello@amd.com> References: <20241109044151.29804-1-mario.limonciello@amd.com> Precedence: bulk X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SN1PEPF0002636B:EE_|SN7PR12MB7884:EE_ X-MS-Office365-Filtering-Correlation-Id: cd2ef65f-6756-4112-7808-08dd0078eeab X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|376014|7416014|1800799024|82310400026|36860700013; X-Microsoft-Antispam-Message-Info: f1dJI+7yXu88LGjn2IxnW8dKqCKLsEyh3YaECzTc5G3U5lSI1F+nRrwUdSmHVc8i4t+MAvtidgV08i4HuQzKpwRACvj6BGEN8BLVIpPWWNHJZlkVy2JMWCI1RH6YPHB0andCFM256p7fME2cWpt/9nUWzImYdGUimDpME/084/Fm+Hsb87jc9cWvCxjByXdxTsxhlVj50SrlHhNkV2qCOFaSRQVWl/akLfXTewZ6C5aRDRtZn0MivMiglYuj0putQzcmJYqF/sebbB+zn3LTF9RcOxdM7GtsQUi/LgZIWgd2Nfk5DlqSqfvSpEGbBj6QU+JcThvIsZWhxez+BpjKXoxApbpP205yNAaEPLJ9zkUZEb7IozEdIR8ZmFC0jklFo9DlR2Qu0vR8mWOj5H7ZUTFWyDeFGBuvaDYf9mA2GzeS4hLjoLZ6vhQLaRMLwZ3A4SLlUMAA1AdkatgryxcN+7f4BUnDwoFKZ34rz2sRpz+OVXU4nh7c2cscYpmuG82QpIaub86e2fB9RBofVYrmsZ8ZLmk3vj71YbRPfkFnyBzPX7loBCBpd2cmxUKIVgPirQVp/fOMA3/mlrETE0IW3bEje3iwiUeEuOLWzY4NhQjX5Vgm91OmVi5bUTVBOH43IudzQBpc05DXNEKkVNHczEJ+Cyvkcu/v4N9D86jCsrAeMJ3OcuHwr7RXXu2zCbRMTaQTWCIX58U5CThuEwxs5kedN6hJ+w8UNr8TWv9AvHSR48QLyq6TT4sgDKWRKASoO4i1NK6aM/wgSlZLFdz/z3/2Yg0Sn6u91vhW89akw/L9/1XexEwn0hZTvYLpnRqXR9HkhWY83bkJoxH7CbQbsLtkFKaD0hH/T3cZsxy29BTn+HBKi97if/aS/Vys3hCe8gKfJC9/MeICfZz1yXfmANH8TeR7C1TzpWnOj71ciIEwWY/Gf57fMO+cyLRmxE9qSOET/weXb79iXzlQKIYVhwOl6jVXhIUgxp3ipn7S6vml/WSOczQuLAm/NP4zmRg1/x37sAQ14wFtR/U18ozHii8rZjIIir1F7m2Y7bDoJotOjrjstO6UEKUbFKy7AXKZllDksR0oACQevSknmxPJVPriW3dcVVPuguccvO0tH78F4Dgzgys+mAya/72jRSb766xSDvR3CuJ9j5FDALhNGF99ZEv3IoMk5MlMcUBkoTHy0bBFoiQXV4o5CQG2o9uSsfTvZ4YL+34Ok0YF0dLiad9bz/HDbTBVM2MtihGYyYLqzuz0bO9jBFUj9xyWguFSuhSeRtjairHhx+Nw8eqwyMeJ/v8ilzIHGmqq2pJLCP6O1vrLW3reDGhEBNjiZYUguq92oUcdp973llbXKwIamanAJdOIF4Ykiz8+xBRhot89PtFV/9tDBsJdmttaAbI3kFZa6eqnqO2N/G6LO6yCPg== X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230040)(376014)(7416014)(1800799024)(82310400026)(36860700013); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Nov 2024 04:42:35.5831 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: cd2ef65f-6756-4112-7808-08dd0078eeab 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: SN1PEPF0002636B.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR12MB7884 The name attribute shows the name of the associated platform profile handler. Tested-by: Mark Pearson Signed-off-by: Mario Limonciello --- drivers/acpi/platform_profile.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profile.c index ef6af2c655524..4e2eda18f7f5f 100644 --- a/drivers/acpi/platform_profile.c +++ b/drivers/acpi/platform_profile.c @@ -25,8 +25,35 @@ static_assert(ARRAY_SIZE(profile_names) == PLATFORM_PROFILE_LAST); static DEFINE_IDA(platform_profile_ida); +/** + * name_show - Show the name of the profile handler + * @dev: The device + * @attr: The attribute + * @buf: The buffer to write to + * Return: The number of bytes written + */ +static ssize_t name_show(struct device *dev, + struct device_attribute *attr, + char *buf) +{ + struct platform_profile_handler *handler = dev_get_drvdata(dev); + + scoped_cond_guard(mutex_intr, return -ERESTARTSYS, &profile_lock) { + return sysfs_emit(buf, "%s\n", handler->name); + } + return -ERESTARTSYS; +} + +static DEVICE_ATTR_RO(name); +static struct attribute *profile_attrs[] = { + &dev_attr_name.attr, + NULL +}; +ATTRIBUTE_GROUPS(profile); + static const struct class platform_profile_class = { .name = "platform-profile", + .dev_groups = profile_groups, }; static ssize_t platform_profile_choices_show(struct device *dev, From patchwork Sat Nov 9 04:41:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 842122 Received: from NAM04-MW2-obe.outbound.protection.outlook.com (mail-mw2nam04on2070.outbound.protection.outlook.com [40.107.101.70]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5FF4F153828; Sat, 9 Nov 2024 04:42:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.101.70 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731127362; cv=fail; b=QiDOO7ySY4iivCzoG/fVkfGgihvbEYJv2WdT0+DqLICbcVJTgobxy+ay8rC47FGkZPwT2MMM7GfT49Gshhl12svSdBfJpzDH9qPmH1yprHSGeaNNEvYQePSU504J0u/AvbU1GIvvRv3r96Hj4/THIRZJRqUZIpvRhEY0rZfxAvs= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731127362; c=relaxed/simple; bh=Rf7su+HSPVdgq36Yj8jujQk6/H5RCWvxS50NzowJhes=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=EaDLdNu5ENEaAbP97CVatDqDn/PiEP2wtvYWR6TYlgv1P+sMtbMFcBnaWQNURLrRDKr87quKKCnoKCAnVxcXJf7i/xgUjIrI5YgfMjWKF+7fcRr/F2SuZuP4FLuFOhV3Bb8VdNWNr+bjgfdBDRAs+leRPwVRb3UqcQZWQhctS5A= 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=MT02j6as; arc=fail smtp.client-ip=40.107.101.70 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="MT02j6as" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=tFJ4tkGiTtPpVJZHjxNc3ZTsEoZ76WH2QnKwD9OwUGYdjH7aUYJULOGklDI5+pSuDyDnADkuD5dIssPU9W6wKcB5fWQdPuviRdkJ5x6XtEv7yghRRyY+nHxIcQjLtTcnjIVuqEeqxL4wgtu56OfwmchMSYUMdX/td1UBtEzrVdnTOj9M2obTj6lkgQCCvxoYMYXm5VIFWcZAFjwJgmBOH4lxDikFJXZxv9pjg4p8oBk+9ReMFklgLQN/bW7eOh+WCtdaQWb14I9jY0jb2A9bGJ5tYuVdJN/pu+Md2QFTIuvFSdtQtixiwyYbLwRrPjxqZlNvUVAvhu3QgjxwyeBr5Q== 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=5Z41Dx+lgJIJApg61W8wnpRXUX4cXnyjQpNEFZIlus8=; b=mnyT5LqkkG942OHB+xH7u7Yuy4rkQSWl2kxxLnCiak+KJMKRX6xLYA16lW0VwXuLc8JO2+tMX0uSeHCIDcfclJX3ST2n8/jA37aEyHIYyMUeKTP+1hDzKVcGJWQIdXFg4lhzuF4nOPs1iEoSkXo3AmJX6sOY/3hWHFp6jaAsTagzKQnsa3OV1N58wmRCqk87Xp7CaAxgaPV/DYI2QAChQtX6vdIvriW13AinAynskbCqnk9k9SRNSeOUF6Qq+PgdjPTLEZrksQ43tgXBO2zDaiTNANpDWvMNgq4JkxRmESAnS2FgDE9Tvoru7GmKX0Y0BJlVPyw8nxAoxwnv5OVn4Q== 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=5Z41Dx+lgJIJApg61W8wnpRXUX4cXnyjQpNEFZIlus8=; b=MT02j6asIT/mb5JkdOQ14Jk6HtqnjXwo/N78S7denbUKYSrSUzuyg4jNok0y88BQCZcYoqhnKLEoNpp11BSNI9qwwE8BraOPNhViNcZmtLS6VWIELWM/hGoQ8kK5fXGs2mWbUwJsjftPmXX9U2MQei1XagITb7tHs5xLipCT4hM= Received: from SN4PR0501CA0055.namprd05.prod.outlook.com (2603:10b6:803:41::32) by CYYPR12MB8963.namprd12.prod.outlook.com (2603:10b6:930:c3::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8137.19; Sat, 9 Nov 2024 04:42:37 +0000 Received: from SN1PEPF00026369.namprd02.prod.outlook.com (2603:10b6:803:41:cafe::d8) by SN4PR0501CA0055.outlook.office365.com (2603:10b6:803:41::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.12 via Frontend Transport; Sat, 9 Nov 2024 04:42: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 SN1PEPF00026369.mail.protection.outlook.com (10.167.241.134) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8137.17 via Frontend Transport; Sat, 9 Nov 2024 04:42: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; Fri, 8 Nov 2024 22:42:35 -0600 From: Mario Limonciello To: Hans de Goede , =?utf-8?q?Ilpo_J=C3=A4rvinen?= CC: "Rafael J . Wysocki" , Len Brown , Maximilian Luz , Lee Chun-Yi , "Shyam Sundar S K" , Corentin Chary , "Luke D . Jones" , Ike Panhc , Henrique de Moraes Holschuh , "Alexis Belmonte" , =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= , Ai Chao , Gergo Koteles , open list , "open list:ACPI" , "open list:MICROSOFT SURFACE PLATFORM PROFILE DRIVER" , "open list:THINKPAD ACPI EXTRAS DRIVER" , Mark Pearson , Matthew Schwartz , Mario Limonciello Subject: [PATCH v6 12/22] ACPI: platform_profile: Add choices attribute for class interface Date: Fri, 8 Nov 2024 22:41:41 -0600 Message-ID: <20241109044151.29804-13-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241109044151.29804-1-mario.limonciello@amd.com> References: <20241109044151.29804-1-mario.limonciello@amd.com> Precedence: bulk X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SN1PEPF00026369:EE_|CYYPR12MB8963:EE_ X-MS-Office365-Filtering-Correlation-Id: 93aa8639-5d3c-405e-87e5-08dd0078ef9b 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: uJlqwgvtC/0B1rAXZBCGNep3BCP+x1jcFgPRO8eB7Uq0GlFqodrwCnGhWELvYVbAymBHMSHgjzOJrT911ZAxFsg5U5Nlo/Zz/i5ZGp36qFrTYjI8kA5O/HzkdlDq7m8koVYy8H1+rjFJJf3O9wcVtmkdDKNCDQibM/ll4tYOGPnoYT4vJr3zglaT4q2Td0F6WlPaYAXE1rgRTwAj3HUN6lFEtmMaqQjw+zzzHTgrsFTnksl9T8P82DoaRBGdFkcQQQgEwO7XstBq2+fV7FaUQfmSG+OnoH8P0wPpyYUXTemvuDzWhjrCRuxW+8EexJac64unWtxWnHTBa3YPCfxg7088hbgaDGgnTy7KRxBC0UF64eo/m2CS/Y30Y9VJJSHWVzDer33dVKFGyIslNbDf1EqeOnDWSuzzZKXq9mvu3TOFoJQe3Y2q8WJYuSLq+IVGyatI8l7QMw7ELsFkOySVPwZU2oZ2dzKngfZ9td2jLGREjVgUPrPb6HtLYGV3ynfb2RevmA0W7/EJ8BfCgMPBmJKy815GTwve/IQC3Ag1rTjTDtsryMk1u+a3ni2JLpWuSzy1QteY/HLUBF5+X49LhYfZSs4oP0s0oVHAIdT08RoT/hhE/mIn6d8dq06fdzNUgebhCzyQyzJo1sbJf7zyi3OyHKNu6Dxx1lZ/QLCspTkK305rDpIT62Sge3xxrMKQlREp7yIFI3cD54PVBdRWIGqE5uWu9X2isAHQMhFOBd4K9uv6QuYHo1xAOVQKUjmB39+5wxG0KD03YWPuvFsuFiVXvIPJ6bOpDAHwS9qWVm8eT6+b49mnylIAcQJYicvinubx9bfWjTbN2nQ09inzjsVPa1AO8AZ64A+de/gm4PB274u8O4ZnIeJwiVDCYoLjaOYfKbqPCrQ8OOK0BeqpPnQgwW6/L3omblR3Q7S09nnzI8uR95E5dhW86ksLUfOcNS/5sG1SnUfelFTyyjrtahO+XGxfW6t32h6ZQ7WrmisFMGtuMg5wtgZkAfKVR0uijVlzd/ecCbiSucYWc7yUQjGnTTLUdIU7OVNImZXQAJGqcOWcL6+K/bmHPfqqXL8ZThxgOhqpeEHFuVp6kkUGuBvxaRR2yhM2hbc/XjCAgNeDV7F3XIB2fclej/END4DCeeNjqYlMjsELqHje1M8b/ICBm4PggoHGPbw4jU3bIsDriaui6mGdTFp+XQHvYOFuzsz9bDGhWJf7ncZ8Jd6Gwbcw8jgZpeDQH68nGUeoQTA1GcEG/28BmUDiU2dKu/mS4q8ouS0ZnSyjeKn6N3/c/6Wd9BcBHE4VwLC1R4zGholKOB7+UGbyUV7ZzpJXdNMibjVn/pmzuK8uFCjT21ggCQIKFA5QZH+aryMGLp4boSaStrOw/0bWQYN5jSjXAQ2fHLEFoSsC2dmG/zqbcuo28A== 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: 09 Nov 2024 04:42:37.1720 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 93aa8639-5d3c-405e-87e5-08dd0078ef9b 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: SN1PEPF00026369.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CYYPR12MB8963 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 | 44 +++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profile.c index 4e2eda18f7f5f..86d0eb7cc6fc3 100644 --- a/drivers/acpi/platform_profile.c +++ b/drivers/acpi/platform_profile.c @@ -25,6 +25,27 @@ static_assert(ARRAY_SIZE(profile_names) == PLATFORM_PROFILE_LAST); static DEFINE_IDA(platform_profile_ida); +/** + * _commmon_choices_show - Show the available profile choices + * @choices: The available profile choices + * @buf: The buffer to write to + * Return: The number of bytes written + */ +static ssize_t _commmon_choices_show(unsigned long *choices, char *buf) +{ + int i, len = 0; + + for_each_set_bit(i, choices, PLATFORM_PROFILE_LAST) { + if (len == 0) + len += sysfs_emit_at(buf, len, "%s", profile_names[i]); + else + len += sysfs_emit_at(buf, len, " %s", profile_names[i]); + } + len += sysfs_emit_at(buf, len, "\n"); + + return len; +} + /** * name_show - Show the name of the profile handler * @dev: The device @@ -44,9 +65,32 @@ static ssize_t name_show(struct device *dev, return -ERESTARTSYS; } +/** + * 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) +{ + struct platform_profile_handler *handler; + + scoped_cond_guard(mutex_intr, return -ERESTARTSYS, &profile_lock) { + handler = dev_get_drvdata(dev); + return _commmon_choices_show(handler->choices, buf); + } + + return -ERESTARTSYS; +} + static DEVICE_ATTR_RO(name); +static DEVICE_ATTR_RO(choices); + static struct attribute *profile_attrs[] = { &dev_attr_name.attr, + &dev_attr_choices.attr, NULL }; ATTRIBUTE_GROUPS(profile); From patchwork Sat Nov 9 04:41:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 842751 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2050.outbound.protection.outlook.com [40.107.93.50]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7AC2E13D882; Sat, 9 Nov 2024 04:42:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.93.50 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731127371; cv=fail; b=i/JERaqhNW9tfb1FWKVSQOEY9gDFhLQ+jeRLiTbk4JLy2Xi0wGWP1v8sJnthkxmqZF11ZoowYzouFA69Pz416sCdrMANcPka8nYFFj3XSDpP6z5U3PHnsOez4Ns7HuQTvHY1an2hxN3/ZwIUPaIQ4J+1MnLSvgfC9aSO1fuJU6w= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731127371; c=relaxed/simple; bh=n6C5QFardExgYW1Ni3u6F/ge0lNfYFhVDD9M6/rvTa4=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=KDl4HyeUFq0QSRO0/mHRcTYMVUlqpmA+5lQathDl4PK1swqn06DXrlZzqsR9s6X0T3NiRozcCALKVUvDwP3RXch2mXcPBipbdIHwj0VxMhljhipUnFvCfljidkTnhzq3kRZMe4rapLE/oM1NzH0x0qeNoVtuDXL0FUgoyqLgJec= 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=zk2xKB4b; arc=fail smtp.client-ip=40.107.93.50 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="zk2xKB4b" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=EV1FpYh9ZVHoU4708jXLkz3dAmK0xbSSretn2aWtJBOQaLJC1KJe3ukWNRjXJJC7CmE1+LMSdhlGIr3bTErsq1ziLn2GNFaKHio5qyxkrpHMozJEbySnXJK7jLzJ4tsz4vXM4OdZkulKy2z4og79KCzkt1uI/c+zuqJePRCSFmBnMo0rOwrPA4rUDI0IpnaLJAT7uRQW7Irfmo+qcWtLUWN5eZDHDxVAYy2FPwWyAwwpTkWrrsKZ846lNUtJXKdbadhOHjV+UhQWo9WxkWCQqY59px7E23bCKXX+0sMXWGSUnoyPNek8DiLWS+9NqX73rE2AchkhYu84vSRhDNUDuQ== 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=eQm/S63A77MvKwU8l2hIw/TuavTv044wqWiPewpk2jc=; b=v/AhAFIURPuwfnvIMHZPbyqR70Djaij4ERHQxJxGKOGCEI3dyTR/KSjb1tgNA7Lm8zUuZohNqmonC8+OrWS2IfmoHnqwaXThp4XGJ3VV2vB2WDarvLg6KlKoaX3VyYcXqY1SRrNhFyjHnYTBffkSmVhGS+wiLloYZE6q3UjHQMxiM5A80cbmp08mXgR7HhVDXhAiSTW1uFewf1FQg3RsHfjzsznGcaAHtzTvo5F/PefOdwVvCGQ+Y7fTrKPqIAUwgOCn54ut8y1km2vgeVMghqlv6cRR87oPbw3DlmbXBnCM8ocn5roR3egxkGfAnOCevh4PT69d3Q6KZdo8l6II9w== 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=eQm/S63A77MvKwU8l2hIw/TuavTv044wqWiPewpk2jc=; b=zk2xKB4b9Xzv4GF1t8E8UWZ7D/pklcaMZpkJL/IZIqxm9IJTawthWH4znbPUla0OIfse9y3Bn7KZlLh00JZN5nln5uYjv0KCAYyXt52FdM4pM0dXTUqr9BLq/RN5qyT3wbbEWDlWPxbyvfJDtYGtM94RrW0CbeQAvpgGssDMSvo= Received: from SN7PR04CA0221.namprd04.prod.outlook.com (2603:10b6:806:127::16) by CY8PR12MB7170.namprd12.prod.outlook.com (2603:10b6:930:5a::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.31; Sat, 9 Nov 2024 04:42:47 +0000 Received: from SN1PEPF0002636E.namprd02.prod.outlook.com (2603:10b6:806:127:cafe::6f) by SN7PR04CA0221.outlook.office365.com (2603:10b6:806:127::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8137.22 via Frontend Transport; Sat, 9 Nov 2024 04:42:46 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by SN1PEPF0002636E.mail.protection.outlook.com (10.167.241.139) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8137.17 via Frontend Transport; Sat, 9 Nov 2024 04:42: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; Fri, 8 Nov 2024 22:42:36 -0600 From: Mario Limonciello To: Hans de Goede , =?utf-8?q?Ilpo_J=C3=A4rvinen?= CC: "Rafael J . Wysocki" , Len Brown , Maximilian Luz , Lee Chun-Yi , "Shyam Sundar S K" , Corentin Chary , "Luke D . Jones" , Ike Panhc , Henrique de Moraes Holschuh , "Alexis Belmonte" , =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= , Ai Chao , Gergo Koteles , open list , "open list:ACPI" , "open list:MICROSOFT SURFACE PLATFORM PROFILE DRIVER" , "open list:THINKPAD ACPI EXTRAS DRIVER" , Mark Pearson , Matthew Schwartz , Mario Limonciello Subject: [PATCH v6 13/22] ACPI: platform_profile: Add profile attribute for class interface Date: Fri, 8 Nov 2024 22:41:42 -0600 Message-ID: <20241109044151.29804-14-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241109044151.29804-1-mario.limonciello@amd.com> References: <20241109044151.29804-1-mario.limonciello@amd.com> Precedence: bulk X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SN1PEPF0002636E:EE_|CY8PR12MB7170:EE_ X-MS-Office365-Filtering-Correlation-Id: f47b19fb-f241-416e-d5ad-08dd0078f56a 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: KMSwu1engp4jdTjYd5M6/fY9MwEOu7jJkRJCl1tlz6xIE/H7Vcn2Yu7mqVivaIRNdL9we38clmnUDvUpzygx+9dia41JS/tRyCJyLKEnzjonay8cowlD5vXoD/zBkm6KoUGyJhlel9I0l1His32lX3u6axEdUc7/mC9KeBszA72TivjZASIYq0pnTyQ+R8rHB9ng5DfGA42WwhSI3IX5QNKBahaPFX6ARwATOm90BDWshXDpAUDAbIGMiOk3Dg/1G9tkjGsMm8VJbkqEv7iacc2kEsL5wY72WkFc5KnMnibj4tlnfWpUJsE92EHh9atfxgyA5B1udfSnPqvcLmmFZF8JfP9rRHwAEerODiytz5lXlGvOlLEgK+ogEeR6CO6juzgkzjQaQv7VDYcy482mtwMlj3UOl72mmHnHxWd6GPfPGpmowVFxZpdF4kQfV9txp/JS8iAJyWcL8KaDJFi6j4HmSOnxkk7IBdkItA2qxS9Fa05W9CJGbnLt6QT5f99ctUpicAP8dbH3v4tefgWbDAsvYLRU8CxXZFiFMa27XHTuyGmbT/ZICbQTiAXDYB5OREAvUVS/bYyEsgLsUnbCv21uFAT7skXElv9jTds957Qa7HI6zk7Tb2JzYh6QpomUhWDcyhUiECBOQz/l7Jh1uFP+xD7aKY0hMD8YraMxpbO4cQ/+A0oGyMzfugswYAGMQy9+WjGtBBvH6uNQqV507TZdUN/C+wsH8FvmSaMLUITyLNkIEtZYFJk3f8DQgp88QG2+bzIeWY5XKHBoSAmCFDt0ou6k39JwthVGqdgXDfmP10C+D+3IwFuDFcBxrwxcDs4YEbP6LJNg57ubEGuExzK4npmCjnk3xZtQgD7romt0S2cxrn1euHmYowLhbQjMtR3gwwOVsoI+HBn2kJZ3r2TmUEFmIMhpX60Gpf4hdAlja1ROzdAjWg69Fa7kzIwyyrRD5rtEKAHJs6ZMb6f6fIAu16BGRnDbWyM/1OvNUN/0mXkSHlo+Gj+GQTb1e5A2xtdurd4I2hdh51/idinupl6pLiduniXGK6EjDGWsFYjWjUIOHwDcJVqjO1om6mhTjvXlFvj7DquDQ+p7tPVp+5MoLQoeKqTyw53Nlt1kwHvl1uVI3U+37QWqlrWpjjP1b2AuHpKtbeYh1fgs281ocs+Ie2Jy7kvxQz3AKoHDAS8FAxsxdr1ZNc7554SWzb3GGW/jzrRSW6kZyd0sqZNPA6bqUvuBu8WmQkaeFtAhpSc2TgWu8HqR9+0WoQ2XB90B2dab7V/TCqoLbkF/x0AC1EPkIvoTrUA0wkpE4PYdpPTL4ilrBloog+RpvyPBVNr5HTMAhJoR1PuiFk2sbhsCKdoYSM3Qyh4Sik3+/f+YQWfRuW8eAdOHWq90J32B8QsiQsOEvkO3S/7KKRyhX/dCAg== 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: 09 Nov 2024 04:42:46.9192 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f47b19fb-f241-416e-d5ad-08dd0078f56a 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: SN1PEPF0002636E.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY8PR12MB7170 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 --- v6: * Fix return v5: * Drop recovery flow * Don't get profile before setting (not needed) * Simplify casting for call to _store_class_profile() * Only notify legacy interface of changes * Adjust mutex use --- drivers/acpi/platform_profile.c | 106 ++++++++++++++++++++++++++++++++ 1 file changed, 106 insertions(+) diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profile.c index 86d0eb7cc6fc3..c5487d3928c1b 100644 --- a/drivers/acpi/platform_profile.c +++ b/drivers/acpi/platform_profile.c @@ -46,6 +46,58 @@ static ssize_t _commmon_choices_show(unsigned long *choices, char *buf) return len; } +/** + * _store_class_profile - Set the profile for a class device + * @dev: The class device + * @data: The profile to set + */ +static int _store_class_profile(struct device *dev, void *data) +{ + struct platform_profile_handler *handler; + int *i = (int *)data; + int err; + + lockdep_assert_held(&profile_lock); + handler = dev_get_drvdata(dev); + if (!test_bit(*i, handler->choices)) + return -EOPNOTSUPP; + + handler = dev_get_drvdata(dev); + err = handler->profile_set(handler, *i); + if (err) + return err; + + return 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 = dev_get_drvdata(dev); + err = handler->profile_get(handler, &val); + if (err) { + pr_err("Failed to get profile for handler %s\n", handler->name); + return err; + } + + if (WARN_ON(val >= PLATFORM_PROFILE_LAST)) + return -EINVAL; + *profile = val; + + return 0; +} + /** * name_show - Show the name of the profile handler * @dev: The device @@ -85,12 +137,66 @@ static ssize_t choices_show(struct device *dev, return -ERESTARTSYS; } +/** + * profile_show - Show the current profile for a class device + * @dev: The device + * @attr: The attribute + * @buf: The buffer to write to + * Return: The number of bytes written + */ +static ssize_t profile_show(struct device *dev, + struct device_attribute *attr, + char *buf) +{ + enum platform_profile_option profile = PLATFORM_PROFILE_LAST; + int err; + + scoped_cond_guard(mutex_intr, return -ERESTARTSYS, &profile_lock) { + err = get_class_profile(dev, &profile); + if (err) + return err; + } + + return sysfs_emit(buf, "%s\n", profile_names[profile]); +} + +/** + * profile_store - Set the profile for a class device + * @dev: The device + * @attr: The attribute + * @buf: The buffer to read from + * @count: The number of bytes to read + * Return: The number of bytes read + */ +static ssize_t profile_store(struct device *dev, + struct device_attribute *attr, + const char *buf, size_t count) +{ + int i, ret; + + i = sysfs_match_string(profile_names, buf); + if (i < 0) + return -EINVAL; + + scoped_cond_guard(mutex_intr, return -ERESTARTSYS, &profile_lock) { + ret = _store_class_profile(dev, &i); + if (ret) + return ret; + } + + sysfs_notify(acpi_kobj, NULL, "platform_profile"); + + return count; +} + static DEVICE_ATTR_RO(name); static DEVICE_ATTR_RO(choices); +static DEVICE_ATTR_RW(profile); static struct attribute *profile_attrs[] = { &dev_attr_name.attr, &dev_attr_choices.attr, + &dev_attr_profile.attr, NULL }; ATTRIBUTE_GROUPS(profile); From patchwork Sat Nov 9 04:41:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 842121 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2065.outbound.protection.outlook.com [40.107.220.65]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 05C8715B102; Sat, 9 Nov 2024 04:42:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.220.65 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731127374; cv=fail; b=eVOULfOzUKjA9eoTpB4oSAWs5lX9kWtW57Zoi+hyq0ZQ2HufqEvz0e7kz8ujDxkD6L3SB9oEXWOMvGMbaY4BoyX47SlK+YNEoBm6Fpf3jZGS6Jgtugm83D/rhDi9tctpcF2c/5WBCXINVJMBjL6XQ41FijLz6Xo5ES+C+yMfkzI= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731127374; c=relaxed/simple; bh=R/D0pZCX7xPWmwET/WRTWsCIwAuy4oYe3zFjmaYpqb4=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=N1N3kRcPl52itzvHZOOBhu0il/qIhp+qAKMC/4IXArb5rDHw/g6mOcRf6WQLdJ82e9vX61ymW/87grLy9aYrmXNChhvW9lO7pKgYfQp2T4vyCcB7Ly2GgD0G6edGoWxklddZCdZ4W4hCoTvUAwJC/rmEEpfNpOyUjqylPZWSxE8= 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=r+Cwx6rO; arc=fail smtp.client-ip=40.107.220.65 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="r+Cwx6rO" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=YpaK3KDLN8+jCnHsIDUw+fcxr2D8WFpP1vGesAA3Qmr76cieru50icBcWUGJUh4kseKcSUZ2udlMr8l6QXwuDRRDT2HH2siEHio0rc5p6DNgagVdcwfhM+/yxrYKWVB0K3hQuOUOiI6QOwv8ThhcZpwRavycZ0gaiGx5YhjL2LsE/JNFN2QTNMG5ocqX0tWUw+iMhKAOIT6j4p907i3cATFl2jcm7S1RJog7b7CnAsmdehZ3UbPJ4x9tApIjvfjnPmyp+RDmlGFqH3B0PbaDL0o/VejWEJtM3vp5qqSdULUG6Fc/9CYuT4l2QCdjNr3E6Y8AbF7QUHQC/+SvT6T43g== 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=ZdoBQmoVGQvItmMMHUhxb3OZe7hpOCSc1K41jQ3+6bo=; b=Ty2D1oFoFhpX08KzpBxSsbXPiQoNH5WmRq8CfOlNT2uBTc8nGAhLvvwgN5Z6UWzf6A2k0XXJmlwF9DHIiz/2TUS0r3oZSzafEBmHUtjd9Y6buyssdJ+LTsyaswD3qAWV31gcheXU3LB94cmOgmCG7pbobU2feHwuOptleufQKJtBbmtOBu9FTkNzmTENpcLpcCGRHCTd6JyNQqJZUdmFJXDQHIj8Yfn/LnwkhS1P/zHoMBN1x8hFjy6c78W4e9oWu/MswwIt2EPRFAljgHPyWC6U8wZjqDZVFLKbii8jpUQ0uA+PVV2AISAZ+xGuWqYeFQQxfESL3iudD/qEJ6MDOQ== 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=ZdoBQmoVGQvItmMMHUhxb3OZe7hpOCSc1K41jQ3+6bo=; b=r+Cwx6rOQSl3AaJCmRAo4tWW3t/vMmLgukU6weqJCkrjNcY/xixgdu4m8KWXHiuAekwGfsK8okNPvnif9s7zOfhg2dzieraWGwqjlTBQLP/ELaSE/XWE6DSiOvY3O+pW/l1RexeO339xOM+UOMm4Ft9g25E0xeO9l6eXRPfByss= Received: from SN6PR05CA0007.namprd05.prod.outlook.com (2603:10b6:805:de::20) by SN7PR12MB6714.namprd12.prod.outlook.com (2603:10b6:806:272::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8137.18; Sat, 9 Nov 2024 04:42:48 +0000 Received: from SN1PEPF0002636D.namprd02.prod.outlook.com (2603:10b6:805:de:cafe::fc) by SN6PR05CA0007.outlook.office365.com (2603:10b6:805:de::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.11 via Frontend Transport; Sat, 9 Nov 2024 04:42:48 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by SN1PEPF0002636D.mail.protection.outlook.com (10.167.241.138) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8137.17 via Frontend Transport; Sat, 9 Nov 2024 04:42:48 +0000 Received: from AUS-P9-MLIMONCI.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Fri, 8 Nov 2024 22:42:46 -0600 From: Mario Limonciello To: Hans de Goede , =?utf-8?q?Ilpo_J=C3=A4rvinen?= CC: "Rafael J . Wysocki" , Len Brown , Maximilian Luz , Lee Chun-Yi , "Shyam Sundar S K" , Corentin Chary , "Luke D . Jones" , Ike Panhc , Henrique de Moraes Holschuh , "Alexis Belmonte" , =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= , Ai Chao , Gergo Koteles , open list , "open list:ACPI" , "open list:MICROSOFT SURFACE PLATFORM PROFILE DRIVER" , "open list:THINKPAD ACPI EXTRAS DRIVER" , Mark Pearson , Matthew Schwartz , Mario Limonciello Subject: [PATCH v6 14/22] ACPI: platform_profile: Notify change events on register and unregister Date: Fri, 8 Nov 2024 22:41:43 -0600 Message-ID: <20241109044151.29804-15-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241109044151.29804-1-mario.limonciello@amd.com> References: <20241109044151.29804-1-mario.limonciello@amd.com> Precedence: bulk X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SN1PEPF0002636D:EE_|SN7PR12MB6714:EE_ X-MS-Office365-Filtering-Correlation-Id: da628f72-8d43-43e2-4d31-08dd0078f65d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|36860700013|82310400026|7416014|1800799024|376014; X-Microsoft-Antispam-Message-Info: /h0K4Kd88hAExOdDhKPS5aw4QPhJKrLajpa9R23ResBTTgEfaQgfx6T5+MdglTIQVricVab9DJ3jRFk0LIaA8lAya3lc8cbMyJT6KJ0qzHj1TgNHX0xKwAlheGDUTpmx+PjGI2pWiiA04nQHc43lQVwvoBKEA/o8p8sSiVn3n7MSgViRlIzvug3m4iUnrVLzlKpzwnYYd7f3ulTf6V0ALOT7Zp7CQ+i0vOi7TlNbruDFl0YgHeBeIHjwzs2kHFbblRaHarkOAeLPXua2qm9GK7gs/gQ6+TYx+nJe9zbiqVRaOEm7N/OKENckPe6A1iMitNcU/2E6EjUeuHu1qULyjrHqlgDGDDqYC2gBhaXdOsxJjhjCEyY6Hp2X5QPPwgJJKWUN4hFQVPISwvYmRvko03I7l8JqSDvFT1bcC3IkwjxtrCwJOv50/DXPYi60ar7xYLK8GDhAPM2nLofLqNF6/uuMaeSBsE+w3Q+UPe2pWL8IOXl7W4g061PpGKK01aziqekgIVo/P/Pjuvv1SpKsrAT9hRszOMBgmh9+P+H0sVY+8fSf3+lRNcVuRQwFbalySiXoZ1wQ+FjH8npISVkhT+JuIRsd91RuLnvVXUEu+nTMMgYxGPMAXqKlbKLYh27czMI09rgqrzF6y1M2ctPQ8YlEWEASqJ7jINlqvvcpCQSLsCrOS5KIhttdgxRSlMamXb8cVcaLC206HP1T6VR9/zRQE9rkdq+xlYGFSBL374UNXJ5HMvifP0jYBf5lo6TbXNpe1seTX3DIatvsQfDXjpic1hH+of97C7i96xJu6Fne5ar8jXXS3nH3UmY0cmCWWtNfcmAXd3bKQvXQqYUg4gMrrj2h1Wc1EZWtKK7IWXTm02vClmQ99w4bnn0A6/4W7RjF31SL7M7I2YYyDVii8b85wgg0EP967hrS7dIIVIgo1EaAreu3VJRa61eAlxhm7efpExvrlxzoYYkOcVg37scapZcj39X4vJGOEe/rpBA4gI6lkE07jFcv7flQOxqM/Km4E46SFUzHLu7eBqOVYCT9rCF8pwn2FUGRBLrCBIaOVzNGHaKbaqLv9kigIhzc4ENJYAsMr9DkolW3kf12YSDPrY+GkllM2eS4ZkGjwK06V/D93fiohsAMfJEShyIr2A/1S1eMqJoYb31VyqiaE6x/Hhq7Lkew3tqiwqj+pxUPjJOkTDRnKLkQkAy6LBb55RxmzWs8WsAum9XDaNlI2lNbyJjvTGcJSrodmZuCcZW85j0xd9MItjURGXxOxYwQvfHvr23VLGEMi8Htw9ShfdrjPL2RqRo1/HTwml/HRqXJ9qGXcXLJckyRSQ3j4jU0AveH8d40xdStMuKK/gXP1RG3hQfX8s3Qm4EywxviWtOG5eex8L6raHwsBWjVUttF8iSMXoVMsQHAxUUlJLx92g== 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)(1800799024)(376014); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Nov 2024 04:42:48.5082 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: da628f72-8d43-43e2-4d31-08dd0078f65d 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: SN1PEPF0002636D.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR12MB6714 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 Reviewed-by: Armin Wolf --- drivers/acpi/platform_profile.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profile.c index c5487d3928c1b..c4d451782ff18 100644 --- a/drivers/acpi/platform_profile.c +++ b/drivers/acpi/platform_profile.c @@ -380,6 +380,8 @@ int platform_profile_register(struct platform_profile_handler *pprof) goto cleanup_ida; } + sysfs_notify(acpi_kobj, NULL, "platform_profile"); + cur_profile = pprof; err = sysfs_update_group(acpi_kobj, &platform_profile_group); @@ -408,6 +410,8 @@ int platform_profile_remove(struct platform_profile_handler *pprof) device_unregister(pprof->class_dev); ida_free(&platform_profile_ida, id); + sysfs_notify(acpi_kobj, NULL, "platform_profile"); + cur_profile = NULL; sysfs_update_group(acpi_kobj, &platform_profile_group); From patchwork Sat Nov 9 04:41:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 842750 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2055.outbound.protection.outlook.com [40.107.243.55]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8B9FA13E043; Sat, 9 Nov 2024 04:42:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.243.55 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731127376; cv=fail; b=Tk1/jBBYMsgVilpnv6Yqby2GEJ8uwMpA1/aSVWa+qWtfD3Zv2LYxCVw5YuYnFinlAujEJmKkMnrKUA52lpWKWmWqQKHdt1ecn8hqLDDPJzdfImLUDP836PZkmg2zacZl+n+Pu355Zm3l2PadKgl11wSO0mUv+pXO2kP5ujPGz6U= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731127376; c=relaxed/simple; bh=C+p2hzq4u4uIsrCC4IXSD1x5HQQJ03WNBhXnryrH2eQ=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=MZCaCbVL1hNEo8ZsXYtbbuSFpEC/dcKVe4Rfh7AuF0s3ThyqDgHa3ps0kjjWimWOubX7JXPPJP9LDtdWVhap5Cj+kpd7nUbsGACYx6MrUW4baoCi68hSrwrVcwbQsdfo6szZbnvN/gjG3eyoMIC+W11K4ewGBbxFsen0oLYli4o= 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=JZDBIXBc; arc=fail smtp.client-ip=40.107.243.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="JZDBIXBc" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=nJo6r0vIjGGm9Nd1JmBzMQs397MkQqfDA1PS+2JbvHwPsrpko5Yn2aknSjdOMDyXiRzinKgjoZHYAYTx/KYq7g14FMYU8hsbmR8Cna+AV6ey7dZjidhS6lhdKVcBrUYMw81m9d6WseOjztZmNG81TZer7mpCr4g9e4l8spOsFYfSBY8u27EtOZqrh6fhk5IiKF2oJnYHmP9cfvWzXp996KpdOtJUUB+2wk9b4j90F7gh1bkVafFrFfWXY1V+V6L2f2VG5tjuneAXrv/8v+beH4it43DlPnjZgUOSSEzv+agWJX/wRtG5FkgQP5s0tZh7WD3qqNeIY7oM1yfXSqmqjg== 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=g81IshNh8Mcuu+0a63QTns1Nusp4GpGpjTLC6h9atmE=; b=bmo4Evp9Tqa2ZEZ3WKGIudv03eClETDXKiKfzJXlVh7DAehQS3A2hgsHncbBpnH120f9kbQ6SP/TpxgmeVM6IdHqODdg9gMERc3zNFdpVF5Leg3D75igh1fYUYojHPGUpnfRx4977TzHXVHMNFK+9QitJ41X4OYZ1LJi3S7cbTn5GuP7XE1/zE9BJ6+rl0HLIkPmvgr+j+hT9Jb9CJzFOlq+jDSgr4qDqPupsB8Q37qLn4/2lVaINS7WjwgDLPiTUsO4FE1I/h5YlCGWK0CcLiAvrLwTEkluR2KH9iaZtpWzDIoO3telzl1ojv5rU3eJ0cEBDUszQ+WxuMVVdgTtGQ== 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=g81IshNh8Mcuu+0a63QTns1Nusp4GpGpjTLC6h9atmE=; b=JZDBIXBcO3T4v/osnzudp1FWL0iiBD5MZK9vIcvYLigqwfMD0CK5CUPFmyoBFEop/JT5WIPEF3idw3PY4gjPiZB59mWPzvf0MgM5haTFqYbb3dmZtzKEN2w/zl9hhNkssnfgQaSkcbnPgRIasyfYmUGWwPn73mABkHEbz1UaVWw= Received: from SN6PR04CA0087.namprd04.prod.outlook.com (2603:10b6:805:f2::28) by MN2PR12MB4142.namprd12.prod.outlook.com (2603:10b6:208:1dd::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8137.22; Sat, 9 Nov 2024 04:42:50 +0000 Received: from SN1PEPF0002636B.namprd02.prod.outlook.com (2603:10b6:805:f2:cafe::71) by SN6PR04CA0087.outlook.office365.com (2603:10b6:805:f2::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8137.19 via Frontend Transport; Sat, 9 Nov 2024 04:42:50 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by SN1PEPF0002636B.mail.protection.outlook.com (10.167.241.136) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8137.17 via Frontend Transport; Sat, 9 Nov 2024 04:42: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; Fri, 8 Nov 2024 22:42:48 -0600 From: Mario Limonciello To: Hans de Goede , =?utf-8?q?Ilpo_J=C3=A4rvinen?= CC: "Rafael J . Wysocki" , Len Brown , Maximilian Luz , Lee Chun-Yi , "Shyam Sundar S K" , Corentin Chary , "Luke D . Jones" , Ike Panhc , Henrique de Moraes Holschuh , "Alexis Belmonte" , =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= , Ai Chao , Gergo Koteles , open list , "open list:ACPI" , "open list:MICROSOFT SURFACE PLATFORM PROFILE DRIVER" , "open list:THINKPAD ACPI EXTRAS DRIVER" , Mark Pearson , Matthew Schwartz , Mario Limonciello Subject: [PATCH v6 15/22] ACPI: platform_profile: Only show profiles common for all handlers Date: Fri, 8 Nov 2024 22:41:44 -0600 Message-ID: <20241109044151.29804-16-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241109044151.29804-1-mario.limonciello@amd.com> References: <20241109044151.29804-1-mario.limonciello@amd.com> Precedence: bulk X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SN1PEPF0002636B:EE_|MN2PR12MB4142:EE_ X-MS-Office365-Filtering-Correlation-Id: b42df97f-595e-493d-4f41-08dd0078f73f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|36860700013|82310400026|1800799024|7416014|376014; X-Microsoft-Antispam-Message-Info: WG17Tc7nRUTrj0m+Z8HZWOlURUCJQPIMbc2YxOgbcXC7hClcwEliChI3cTMSooEHR0XHGZUfp1w4vyMTCBQ+PCSVssTvTvErVOj7Ji3w9GDQ3rL/DjRkRheUVsX3n/YYSvVUiYI90VJyvE1Icmhqhpyb2gANw+pR870Okd4G4Ha5IlOx6QzmHTPHbIJ/cftcODvKVqvS2SbiMHemtJ8yiG013nh2NF1V0AKljBVDCzbdMkNhmJDBv8rxf6kYgT57qwlVbywGmDKLbGW5idk1XnDFECInqLi+MZKHMqAD6/xaIBMe/Ap/NIsd8MzkTwPQlZzuKbFs+6/hC35Xstd5Kfay9HKpXRBsyKmPdUYJ/08wKMxiulK2/xVJjKnn2v/i09uRQiwt6Ik+ZL5pVqcfUN1Khx9JK1TdlvtwHkxKuIy3j0N3AGsLAYtDTxq9xpe6wsLoVfZugJgnSpi/xzh2Ga1Eg7kVHzC9FQ0z+VakVqHUt0FlkDUU4Nk2bclg6fVLJNh7GKeeWUmKJIW51J4lm7We7gAnUNZJ14t1vK6yfPrh44GvL1PTlBVt9CfXwF53dcWTSa+2rGEsM1p+RL9XvGjfs+YcRmYUyKgC7MiGtXXg/tCGFjPSUttKdrNSBm18fDPWN0KMYtYC49V/r9+9HS5myoKBST1ktaZouxz6q7pDYcIeGmbQOEAm00td8Wra45QEUbvt2QxBr+R0bCKD2ojnyF5sv5r+3XhhHJvDG5+QI3JyFxmJK/S5P8XS6MY8tcbly7J9zxPQScWpnltf3IdgIGLqI4ixEDHuR4ZldJpL2WTkq14i+PiXC2/qyLhP4tE6XxtyMGb8RW83gLwe3ujvQUP+5tCFJqyAWJesJAOfkiJCru3AaoXQHTvAGJZLxp5wlpJxs4b6poAXjzgxdUM131/cNlWIkCIUxx8qzsfD093Nsq0JL9c5mouV/oycmKAt9h4JZfagtfwKRqV3iwoSfMJTjWaIsGRZ13q7q8r3eF1LGlaLj4E0BrvdbP2/n7TJvEjHTAXra3e7l8JQsoC3Fp5vFmJhIpiZki0ax3hqwwBZqSoKmsY6pt3QdLtDUFuy6wxpmu7JDaFVWID5mA2f3YJcZT18sccT8Y3gVTzFUFXWvjbskLZWXuqwrBjNR+3hxEx5erwoWSnaGHPcizTMV3exQWJ/rTHva0Mlp6vbrd4ZXfKP9lF+mDovFYY8y1Kc7gtLdNI6rxLErmnwOdoIVmk1E7jRu0mTolW4ohSHl+37gcUnXKNq2Bk9rqDvmOjvYO34m4xp4b40YIW24yak9+6WDVBeiU9zhDrQdxCKI7CCKappljgL3pN0LYAxefSJ0LYKKjHAyXkMJsOkzC5zeBPd8+oEX7T7HJI6SxtlBThKZWh2btXTJS/ekOAjygVDAaRvpsxfEa7abBzk+g== X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230040)(36860700013)(82310400026)(1800799024)(7416014)(376014); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Nov 2024 04:42:49.9894 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b42df97f-595e-493d-4f41-08dd0078f73f 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: SN1PEPF0002636B.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR12MB4142 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 Reviewed-by: Armin Wolf --- v5: * adjust mutex use --- drivers/acpi/platform_profile.c | 56 ++++++++++++++++++++++++--------- 1 file changed, 42 insertions(+), 14 deletions(-) diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profile.c index c4d451782ff18..c4e2c75116988 100644 --- a/drivers/acpi/platform_profile.c +++ b/drivers/acpi/platform_profile.c @@ -206,26 +206,54 @@ static const struct class platform_profile_class = { .dev_groups = profile_groups, }; +/** + * _aggregate_choices - Aggregate the available profile choices + * @dev: The device + * @data: The available profile choices + * Return: 0 on success, -errno on failure + */ +static int _aggregate_choices(struct device *dev, void *data) +{ + struct platform_profile_handler *handler; + unsigned long *aggregate = data; + + lockdep_assert_held(&profile_lock); + handler = dev_get_drvdata(dev); + if (test_bit(PLATFORM_PROFILE_LAST, aggregate)) + bitmap_copy(aggregate, handler->choices, PLATFORM_PROFILE_LAST); + else + bitmap_and(aggregate, handler->choices, aggregate, PLATFORM_PROFILE_LAST); + + return 0; +} + +/** + * platform_profile_choices_show - Show the available profile choices for legacy sysfs interface + * @dev: The device + * @attr: The attribute + * @buf: The buffer to write to + * Return: The number of bytes written + */ static ssize_t platform_profile_choices_show(struct device *dev, - struct device_attribute *attr, - char *buf) + struct device_attribute *attr, + char *buf) { - int len = 0; - int i; + unsigned long aggregate[BITS_TO_LONGS(PLATFORM_PROFILE_LAST)]; + int err; + set_bit(PLATFORM_PROFILE_LAST, aggregate); scoped_cond_guard(mutex_intr, return -ERESTARTSYS, &profile_lock) { - if (!cur_profile) - return -ENODEV; - for_each_set_bit(i, cur_profile->choices, PLATFORM_PROFILE_LAST) { - if (len == 0) - len += sysfs_emit_at(buf, len, "%s", profile_names[i]); - else - len += sysfs_emit_at(buf, len, " %s", profile_names[i]); - } + err = class_for_each_device(&platform_profile_class, NULL, + aggregate, _aggregate_choices); + if (err) + return err; } - len += sysfs_emit_at(buf, len, "\n"); - return len; + /* no profile handler registered any more */ + if (bitmap_empty(aggregate, PLATFORM_PROFILE_LAST)) + return -EINVAL; + + return _commmon_choices_show(aggregate, buf); } static ssize_t platform_profile_show(struct device *dev, From patchwork Sat Nov 9 04:41:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 842120 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2066.outbound.protection.outlook.com [40.107.223.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 1FF5E170A26; Sat, 9 Nov 2024 04:42:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.223.66 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731127376; cv=fail; b=udqphD0jc301r5R9hRJ3MQlu0kvQGcvbmrTeTdRwkf00A3Z3Gi0aFjfxZTT+jS1ZQ+xNSxIYS/Q9jTppF5j4PRznFVGCTQO6Lk98sYFudLqsUt2XZ+CxXMu1ArGstvAk/KD5l3O75R/RXPNDBSk/DSqU8+tpPt0KE+5Min/pCDk= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731127376; c=relaxed/simple; bh=5ok8HyywPi7zBzNVKuFwEwwp0ngJF6+GHEz3IGeEUe0=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=I38oA6RgOvKk6DjnxU0Jy7sXwE+Ng+EgPjdmJ24mPoIrhW6YxKmgVm7hNMFXB8FYUsenIJNxtmjY71i5MoaACNCn60OO+cKpHkFq66pSGktis1/5FP14y4Hd2fL2d5z7cx+2CTxKXqhPAlT6rPhlUvBBn9kYUeJ4fEfy7qgICvg= 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=R/HAukMK; arc=fail smtp.client-ip=40.107.223.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="R/HAukMK" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=zSVx/1ITDrE1/AlpUpC5FmCBDcUGVT0eHqqDKhfwOi51U6kOUPHvJ7luV2n0wB+s8Ydup2FE8PiK9jAX0J8XqlcZOAhzdxgzgxx/AkdH/9+bR4hDro0A3peiarY3H+z4jxDn3z8xpDLbehX1tNppf704aogse9/qc2EGseD1WzABdCj8b3zMIa0CR9LXKSSkbbYAeVmWWc21g+CUpCuOoi85wfZfqKB+F8DEhn4+/bVhL1ca2gT34hWyx87nlROfHoml25Xfzc8RiGYy1vk2LDkRAWEPVXkJejxZe71bnw6l8AJGCmkb4FITaUAA/LGoa3ETmzAvC+vIrwERtCrT9w== 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=zsZMqzt8tT5M++EZAQxlGMoBZHQY/vNLsNUz9A427kY=; b=eCtUhYFzpD8QCORZSJ40cgpUGNlDRY7TtQ0w2qr46837yiUB/vX5VRlOLaTdrNS4QccnQVlheLl0R9AYSCNCMzkLf1/wLxs9leKy0NW+9FjmlUFhTMr2E6aWRSR1K2ERNuHuKK5ylbYjTilRNJ3cvjvVexjRSMM4xMWIv54V+zBQ0BEhuHPkWkzA+CK01S9vqdYhL62uJ3ouU6B29jGDK5Kq8xNsMZG49qC7P2rGo6deGITMFEG5bZmbqbDUtTbiucopAda3sBAezVlmjqscBroMjSuH+HBIKSeEbd2n0vsc7qY9F8KmS+YpX564x51HOUpBvZOELFzj+MFA77//wQ== 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=zsZMqzt8tT5M++EZAQxlGMoBZHQY/vNLsNUz9A427kY=; b=R/HAukMKRqrU9gOw+gI+G6DmQ22MZCue1U6iNTN42P8oZlfwKql9FykT3QbtUwRLUGMo0In5RgyEA1+DgpcLsa9vYXLVrj5kSfb2FahOLcRPEtaZFnPmIEdPaNgmHK+0lNr9N7h8MMrdvHdnauDGsELYSTdf3+rwJk9lAOuLMfE= Received: from SN7PR04CA0221.namprd04.prod.outlook.com (2603:10b6:806:127::16) by SA1PR12MB5671.namprd12.prod.outlook.com (2603:10b6:806:23b::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8137.20; Sat, 9 Nov 2024 04:42:52 +0000 Received: from SN1PEPF0002636E.namprd02.prod.outlook.com (2603:10b6:806:127:cafe::50) by SN7PR04CA0221.outlook.office365.com (2603:10b6:806:127::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8137.22 via Frontend Transport; Sat, 9 Nov 2024 04:42: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 SN1PEPF0002636E.mail.protection.outlook.com (10.167.241.139) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8137.17 via Frontend Transport; Sat, 9 Nov 2024 04:42:51 +0000 Received: from AUS-P9-MLIMONCI.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Fri, 8 Nov 2024 22:42:49 -0600 From: Mario Limonciello To: Hans de Goede , =?utf-8?q?Ilpo_J=C3=A4rvinen?= CC: "Rafael J . Wysocki" , Len Brown , Maximilian Luz , Lee Chun-Yi , "Shyam Sundar S K" , Corentin Chary , "Luke D . Jones" , Ike Panhc , Henrique de Moraes Holschuh , "Alexis Belmonte" , =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= , Ai Chao , Gergo Koteles , open list , "open list:ACPI" , "open list:MICROSOFT SURFACE PLATFORM PROFILE DRIVER" , "open list:THINKPAD ACPI EXTRAS DRIVER" , Mark Pearson , Matthew Schwartz , Mario Limonciello , Armin Wolf Subject: [PATCH v6 16/22] ACPI: platform_profile: Add concept of a "custom" profile Date: Fri, 8 Nov 2024 22:41:45 -0600 Message-ID: <20241109044151.29804-17-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241109044151.29804-1-mario.limonciello@amd.com> References: <20241109044151.29804-1-mario.limonciello@amd.com> Precedence: bulk X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SN1PEPF0002636E:EE_|SA1PR12MB5671:EE_ X-MS-Office365-Filtering-Correlation-Id: 7fb677c8-6cc7-4af2-ef59-08dd0078f86c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|82310400026|376014|1800799024|7416014|36860700013; X-Microsoft-Antispam-Message-Info: CtvBREi1Y3UhqYbnEUAWdz+YwZY6sUjVsdblJXD1YpsPGD6xmK0qQiPHVzPvJIPU02oLt5lHkLn664FW88QeWU0OFAJTZL8YWRHSWJjrQrTHZEwIQGU8TYgWulHOgN5lOsc5f8PMI7OZHZFoQL9Kc1+lQgSIoNJS4FcLZzNJuWXaUwLk+bdZhOnwUp/ZLqZD8vc5l70afUigr9Hb8TepsiqaaH4xuf/CNRq6PzTTNyOoIQZDFZW8V3BuqaCMMsmKAZbmvAnD2DRfSsWi9tXiPGBsY9f57KqSzrSl6Xy1rrScd/crrAjEJa2+a8W9IuH0jVBobYMvhcXOI6TID1DQ23JKIJY64vM9xz+G9AnQ6TJyx4EGdKkmJmGVjrEDUrPs/xCv7cczBDk4XTSuLucfIjlMHrF0DrZ1S2TUx16lupM2HQuVXjO6owE2XBN5EpB4BdeEW+q6Oi/nX6BaQA07y+LN+D9NI2ho8hW3pZAY4P+z56LSEhG+lTYoLDqg7C//TVnXiuj4nZWMgBw3WDySr548irVq0A9KOMAIGIYPUjXTANcxIZJiYexrmly8ezUGVIqNEg1K/ujjQP9Ecx37oHBBj47toEyX09eIu7DUvk/ynB14Sv396M6jPFbwEZH69x7KEHjcTeBc1zzde4XawvGAu6zuFwgSEV1y6XDRhgfdfZFZALoYrTGShHcrqAxOXLx5yE739frmLVG6ig+48V31Y2p2OhhXG6y47y6fYjJj9ZbGTP+ecb8R/4X/4hnnzzMhUjRBl0VK4cdmxLAkLS9W7U8R+cIwRuA8kF+BhRC2469n6dWb598OmCE2XeXIWryGlj5i6piH/mct2HA/z1VAdF8nnXn3fkZ37LJBNpQToMOMdPnotKY0IPQgBlMmFOgENko98vfKIszm1LVu49MziwPNRr8dK7rt8E3KX/pyI0eBsKM/jpG545o86msLEZeekz0aZ0pSG2U2jjcWm84rktyinBrEmnLVH52sTWqVVQNT5zqLssunCpbFOie1xgrgB6YPrCVLXc8+R/Ljudbbp78AKyJzkf3Dx6iWDp8pK1WpsnO6hGtK68T4ynlHyh972R+pZyKim0Ch8XZKGE3apEQyDzparOTE4JWBEyYJ4Cp4fZGU8EqU8itN90vfCbknRuLhamibmRZF2sNF67eZXzX80SVMNfkVNeBjyPkKatzOHLCv/SyKREKA+pz6pZEVnC0Urn0N1M6Ub2RP2ywOibz1axYdETPG7kTfPx1OVH8CEf6YBkK0oQDKKiJjnknZmCWtSGgcLJnheRrTBMyCWARo/OmHssPZW24Q4sc/WS5D7S2IChpKpVYD00uTv9VugUJzvg3xfRSo/OzpZv1buj8B28zIidz12Kr82Bp2CyvlrhzLTHLkCRyC8LXo3fa8SkSdgxeioGu3UH6jcQ== 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)(1800799024)(7416014)(36860700013); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Nov 2024 04:42:51.8723 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 7fb677c8-6cc7-4af2-ef59-08dd0078f86c 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: SN1PEPF0002636E.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR12MB5671 When two profile handlers don't agree on the current profile it's ambiguous what to show to the legacy sysfs interface. Add a "custom" profile string that userspace will be able to distinguish this situation when using the legacy sysfs interface. Reviewed-by: Armin Wolf Tested-by: Mark Pearson Reviewed-by: Mark Pearson Signed-off-by: Mario Limonciello --- drivers/acpi/platform_profile.c | 1 + include/linux/platform_profile.h | 1 + 2 files changed, 2 insertions(+) diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profile.c index c4e2c75116988..089ac73b3ec97 100644 --- a/drivers/acpi/platform_profile.c +++ b/drivers/acpi/platform_profile.c @@ -20,6 +20,7 @@ static const char * const profile_names[] = { [PLATFORM_PROFILE_BALANCED] = "balanced", [PLATFORM_PROFILE_BALANCED_PERFORMANCE] = "balanced-performance", [PLATFORM_PROFILE_PERFORMANCE] = "performance", + [PLATFORM_PROFILE_CUSTOM] = "custom", }; static_assert(ARRAY_SIZE(profile_names) == PLATFORM_PROFILE_LAST); diff --git a/include/linux/platform_profile.h b/include/linux/platform_profile.h index a888fd085c513..0682bb4c57e5d 100644 --- a/include/linux/platform_profile.h +++ b/include/linux/platform_profile.h @@ -23,6 +23,7 @@ enum platform_profile_option { PLATFORM_PROFILE_BALANCED, PLATFORM_PROFILE_BALANCED_PERFORMANCE, PLATFORM_PROFILE_PERFORMANCE, + PLATFORM_PROFILE_CUSTOM, PLATFORM_PROFILE_LAST, /*must always be last */ }; From patchwork Sat Nov 9 04:41:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 842749 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2069.outbound.protection.outlook.com [40.107.92.69]) (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 5981B13D886; Sat, 9 Nov 2024 04:42:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.92.69 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731127378; cv=fail; b=oBCuep098iXqNb7GWH/tz09+AFxYGb8Xrn7+0KEGwP24jCflF2S2c8NM81v3k+bmnql+BY6YhiVOSulCSMa14NVeXx7NaX73Y/bG4jgVrO1WbelNu1mBANMaPtyj0cUdbJkY0Fjkh7voa70H89uUlhxhaAt1bniQvejQ4IhhO9U= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731127378; c=relaxed/simple; bh=m1EAp1mhUE37Ciip74hEcu+lOeknOcMmA42WqHgr1zw=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=dO2+QtUa5ZtZlG7DHKTL62/zxzNvSWciMHUXjrYiEAOSD0SeYE+sA5OdFNtfbz3LRcJcykCLtkocLtACJWrcv+mdaPGzzZ/6OJJMOMhl9eDPpa0T1HbTqiQ4XALgYGUdC/IJ0i7Ty+6p1b2wwhfRPen5Y//D3ZuW/30OIQ8P8ZE= 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=HQxcuagd; arc=fail smtp.client-ip=40.107.92.69 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="HQxcuagd" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=UZXE6CUKkGr6aiAQbueCle9hZMP32VIXdLrF+zkSWoRUifRZSPg28dIdgOehou98UyrDXww/HsClH2VEqACZvPP4YhC+mJagiEwYsIYjIzTIGzoZ/HyO4hgjdBBF/wABGhGldE7c2gn0KkXeCoOCssKRH52BKBPIDpcYaZcXVLe+82ZrMQw4q8WaRty9FvCbGP1b/4F/hg1EDiRoGKWSZcyweW2Yn1b/y1rIztE9ovJ2guTDAuqCOCOved4lqlRHXB8VpncQzsD3YdnJp8bblIM1mNTQS9o0ooLpHEtJGs4JoMxKosCiLkpgCvvGTT356miqzZsdTIwl+qN7eyw9TQ== 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=QEXniE+ZSQVj23HmSp3rjWwsQIqfFBDdu9eCr2VUMZw=; b=J6sOzCcdM1GlvN36nu1GXwibfEod8l91X9McbLbwbmqWxVLSueJfnMD6tDS09ik730nhDgJJR1a+KaZw/D8myR0nE6q1vRXapaHQyu3g6ODUjqULPBI6JkHUVnoP1TtMW1J1J1veG5EUxKYi/vgKo3Q0hksVqtIFEKmy2Qse1nRcd7z+3GaJJCS32QtxRyeyEGQRGM+u6z2BUdEKURBnLr0VMeItNWwwKTcf9o3qfs2w1oS2JXYVBL+GyU4TRJDy5FNXVYO0mbt4wden1ORJsSCmCGL3xgk2cpXoGP4R/C2mtszgDuOirz36bADhcpLb9dsfT1Wrm72cXFJZzjWa1g== 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=QEXniE+ZSQVj23HmSp3rjWwsQIqfFBDdu9eCr2VUMZw=; b=HQxcuagdUazwmSf0RTpjn2BveidIQ+n1pXHt06vTOpfypJyjoV3Ve/GVJPF0AtIFA42T4vgJlZ9NgRBnYEIepECIUhL1LBgJiZAzxHAli2p7ibkgXHfVPtuz/44NpizLdIlNGjaWJ0sHzNX/xqsFNL7jPjfisdYCMhB5r7xUqeU= Received: from SN6PR05CA0014.namprd05.prod.outlook.com (2603:10b6:805:de::27) by CH3PR12MB8970.namprd12.prod.outlook.com (2603:10b6:610:176::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8137.21; Sat, 9 Nov 2024 04:42:53 +0000 Received: from SN1PEPF0002636D.namprd02.prod.outlook.com (2603:10b6:805:de:cafe::af) by SN6PR05CA0014.outlook.office365.com (2603:10b6:805:de::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8137.18 via Frontend Transport; Sat, 9 Nov 2024 04:42:53 +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 SN1PEPF0002636D.mail.protection.outlook.com (10.167.241.138) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8137.17 via Frontend Transport; Sat, 9 Nov 2024 04:42:53 +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; Fri, 8 Nov 2024 22:42:51 -0600 From: Mario Limonciello To: Hans de Goede , =?utf-8?q?Ilpo_J=C3=A4rvinen?= CC: "Rafael J . Wysocki" , Len Brown , Maximilian Luz , Lee Chun-Yi , "Shyam Sundar S K" , Corentin Chary , "Luke D . Jones" , Ike Panhc , Henrique de Moraes Holschuh , "Alexis Belmonte" , =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= , Ai Chao , Gergo Koteles , open list , "open list:ACPI" , "open list:MICROSOFT SURFACE PLATFORM PROFILE DRIVER" , "open list:THINKPAD ACPI EXTRAS DRIVER" , Mark Pearson , Matthew Schwartz , Mario Limonciello Subject: [PATCH v6 17/22] ACPI: platform_profile: Make sure all profile handlers agree on profile Date: Fri, 8 Nov 2024 22:41:46 -0600 Message-ID: <20241109044151.29804-18-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241109044151.29804-1-mario.limonciello@amd.com> References: <20241109044151.29804-1-mario.limonciello@amd.com> Precedence: bulk X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SN1PEPF0002636D:EE_|CH3PR12MB8970:EE_ X-MS-Office365-Filtering-Correlation-Id: c10edbb7-c37a-4bb8-05e2-08dd0078f91f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|1800799024|36860700013|7416014|82310400026|376014; X-Microsoft-Antispam-Message-Info: LO+Z2H05uha+8tZSzGNT6ld1pwXceUN4HGLhXI4ALCS4bpWo+EZmAAZtoeIVhjypmUCz2PwhWvEUs5i5Ue0fC5+3t8mJdBP9kM73RD1JGkYtG8ctolrGvQ1cVR7tgG5F6j0cuHqLrf4iicXRTRbwTXGeZ07KN9jxyx3y8ZM3thchv2L/WRm3TKKrQAknnUF2Seu/m086XyD55DmPmR8doQi/u2qqpNALEKJdKxMNivpEmf43P8HHoxbL6HXZADKBdFDAkGbQZNhrR6jIHNyhm7EirGNfXU9RS26Kln3XwZS8CtjAYYjG1p+qtR/dwkq4KjyHRoH+IbqYOMOpGQVGmVbps6z1E7CZyWIsWY0rPl04gxFQ8x+aXZ3XzhJWvDZHaPr8bd72Yue7aGF3DIh+S/j1xc+LiGA5qpmpRf+R3rTEf/GRAqyJPHYnXBwY32sYrhtd+sFoJcy1elUz+gjbbKX/umWvvf+dm2CAXxXUxKLsGlfb6xWD6p2FnujB4aPEYRJbu0+9RYkebSkLqgMulVNj6Ab4+9+00NWHlwoRZryu+djde82Ezn5WGF79vTP7JQdg0eRTFNbZG9c0CbDzRDsxfrdsh3Q5C38AU7xL2nbkOLWnOZOOVbXAZ1YdVZjSI8tOrepzyJaphEpZb+2lI9vN5Ml5FAgn6cQg/yAWY+9AHWEhS+fSUYGugjfOGrwTbs0mkGY9GmUPaettgMRyJImjfb3KLmBze5YA/RNxCEQuLwnUqKxiuKY95dN499GsI0pNMzPEUxeiOZN/MOuPtyaow1ja0NGEUH96gzkIUXimF5hoHrJLxCORGZpUk3gwFNBy4nol2fVe92miUkiXiLAupbYp2FpXkrXAS/phWVK5/W9Fm4RllmqXyRK1NUreo8J/qGNCxZScelbYmVwmveFigaD/gs7jkp6e5m3xerFf/K8k1eBBhWKauMEzI4C3a01aqKUpFnvCdYdahgERcNVwLMgYlfz/4Yak3Q1VqjuoSUU+KuNERdbAToCprOpsAbXazPAKYDLOWUMQyHUgg4wfau6mOTU3TGdH+MfKbPbQAyl1uL/1UlE8zx6m+o5G19ubTgR3Fg7x+BrzTgWTrgRlyxLe9C5AXWEkA3UgpKcorlxAJLybGaUzK5aL1y53W+RywD5XedJ65erauKkTPNWtVdYsaWfaNvz0epzBDiigv+dOZ8I2WMNjJIXcZXq1tsOTVn4W7gxRdeq0BPBF19bd5sbQzOCCR6aY5MZpUN2QC71+yOsJPHfyxdL6mrDz0M1bONP2Zy813OMYYyobZN5jnzfhdUu3Caw1fVE75zbVfP1pgPG/qlIaPDqkFXbr4H9zrlD6qLQiN9umZFdYlvfD7rmhfosvnDqtolonodu0yCP6i+6ExemjU6GN/Iwp9HNH/PjH+Ngt50kEbq7ziQ== X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230040)(1800799024)(36860700013)(7416014)(82310400026)(376014); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Nov 2024 04:42:53.1176 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c10edbb7-c37a-4bb8-05e2-08dd0078f91f 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: SN1PEPF0002636D.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR12MB8970 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 Reviewed-by: Armin Wolf --- v6: * Fix logic error with PLATFORM_PROFILE_CUSTOM 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 | 120 ++++++++++++++++++++++++++------ 1 file changed, 97 insertions(+), 23 deletions(-) diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profile.c index 089ac73b3ec97..2676f4a13689e 100644 --- a/drivers/acpi/platform_profile.c +++ b/drivers/acpi/platform_profile.c @@ -71,6 +71,22 @@ static int _store_class_profile(struct device *dev, void *data) return 0; } +/** + * _notify_class_profile - Notify the class device of a profile change + * @dev: The class device + * @data: Unused + */ +static int _notify_class_profile(struct device *dev, void *data) +{ + struct platform_profile_handler *handler = dev_get_drvdata(dev); + + lockdep_assert_held(&profile_lock); + sysfs_notify(&handler->class_dev->kobj, NULL, "profile"); + kobject_uevent(&handler->class_dev->kobj, KOBJ_CHANGE); + + return 0; +} + /** * get_class_profile - Show the current profile for a class device * @dev: The class device @@ -257,51 +273,109 @@ static ssize_t platform_profile_choices_show(struct device *dev, return _commmon_choices_show(aggregate, buf); } +/** + * _aggregate_profiles - Aggregate the profiles for legacy sysfs interface + * @dev: The device + * @data: The profile to return + * Return: 0 on success, -errno on failure + */ +static int _aggregate_profiles(struct device *dev, void *data) +{ + enum platform_profile_option *profile = data; + enum platform_profile_option val; + int err; + + err = get_class_profile(dev, &val); + if (err) + return err; + + if (*profile != PLATFORM_PROFILE_LAST && *profile != val) + *profile = PLATFORM_PROFILE_CUSTOM; + else + *profile = val; + + return 0; +} + + +/** + * _store_and_notify - Atomically store and notify a class from legacy sysfs interface + * @dev: The device + * @data: The profile to return + * Return: 0 on success, -errno on failure + */ +static int _store_and_notify(struct device *dev, void *data) +{ + enum platform_profile_option *profile = data; + int err; + + err = _store_class_profile(dev, profile); + if (err) + return err; + return _notify_class_profile(dev, NULL); +} + +/** + * platform_profile_show - Show the current profile for legacy sysfs interface + * @dev: The device + * @attr: The attribute + * @buf: The buffer to write to + * Return: The number of bytes written + */ static ssize_t platform_profile_show(struct device *dev, - struct device_attribute *attr, - char *buf) + struct device_attribute *attr, + char *buf) { - enum platform_profile_option profile = PLATFORM_PROFILE_BALANCED; + enum platform_profile_option profile = PLATFORM_PROFILE_LAST; int err; scoped_cond_guard(mutex_intr, return -ERESTARTSYS, &profile_lock) { - if (!cur_profile) - return -ENODEV; - - err = cur_profile->profile_get(cur_profile, &profile); + err = class_for_each_device(&platform_profile_class, NULL, + &profile, _aggregate_profiles); if (err) return err; } - /* Check that profile is valid index */ - if (WARN_ON((profile < 0) || (profile >= ARRAY_SIZE(profile_names)))) - return -EIO; + /* no profile handler registered any more */ + if (profile == PLATFORM_PROFILE_LAST) + return -EINVAL; return sysfs_emit(buf, "%s\n", profile_names[profile]); } +/** + * platform_profile_store - Set the profile for legacy sysfs interface + * @dev: The device + * @attr: The attribute + * @buf: The buffer to read from + * @count: The number of bytes to read + * Return: The number of bytes read + */ static ssize_t platform_profile_store(struct device *dev, - struct device_attribute *attr, - const char *buf, size_t count) + struct device_attribute *attr, + const char *buf, size_t count) { - int err, i; + unsigned long choices[BITS_TO_LONGS(PLATFORM_PROFILE_LAST)]; + int ret; + int i; /* Scan for a matching profile */ i = sysfs_match_string(profile_names, buf); - if (i < 0) + if (i < 0 || i == PLATFORM_PROFILE_CUSTOM) return -EINVAL; - + set_bit(PLATFORM_PROFILE_LAST, choices); scoped_cond_guard(mutex_intr, return -ERESTARTSYS, &profile_lock) { - if (!cur_profile) - return -ENODEV; - - /* Check that platform supports this profile choice */ - if (!test_bit(i, cur_profile->choices)) + ret = class_for_each_device(&platform_profile_class, NULL, + choices, _aggregate_choices); + if (ret) + return ret; + if (!test_bit(i, choices)) return -EOPNOTSUPP; - err = cur_profile->profile_set(cur_profile, i); - if (err) - return err; + ret = class_for_each_device(&platform_profile_class, NULL, &i, + _store_and_notify); + if (ret) + return ret; } sysfs_notify(acpi_kobj, NULL, "platform_profile"); From patchwork Sat Nov 9 04:41:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 842119 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2072.outbound.protection.outlook.com [40.107.93.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 5E671192D6D; Sat, 9 Nov 2024 04:42:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.93.72 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731127381; cv=fail; b=tLtPrbov+7KCahGSjU8YRgoQ7eIi+LkpkLE4zk6rY4cP+dW0J38XpqcTnMK2E8KHBNwRfB44Jb3udzRtS4EhbkzmVn1VHP/b7YrUmaTVWJAxNYQM70Hpjsbt3j+G14hSUZjR3EO4p6KTLlQvSVUOjr5zMfDeXbblvngiKHQj824= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731127381; c=relaxed/simple; bh=HpTBxpGWcFUk1njHPyD8zpusRLZCSn+TW4gmVMOWUb0=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=KjIVdrJqVEr1HuwV1XAwV+BPgUYgD5XPyRiTdoLdmCxq93gVPkqN/hmiiryBwmxuFAUlOSIAs1iPwxFMxyM5b63bzFrueyQRVw1ZHEuZhNYci2lGRhbd0XWW3LlFt3cGSX9smFZK4MGjREjs6sQ+k82jw3W4+C4caOS1EtTeeO4= 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=E86VPkc8; arc=fail smtp.client-ip=40.107.93.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="E86VPkc8" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=EZZdIYQynjQ//dfF4GnG6ExI5Knoozic+e4rW/0paLyFd39BFwg49n7bNRhByOvinH6bgvFsFR3JPBckVfCt7RzA3oinI+kGefc1lmi1Kixmyc0qaEVtlF04GLbEwGXvC/q0n2C5TsXYBoEfbD/CbfutkwuDgryMaXHEgplL5hA6Pv/X1Vx7//0EIorcwaQ8K8JKFBMAKn+lz29l3FHJwCY+xOKIIayXECL1eov9USx5S4tJH8Ju7uAHDAY/lfFG42eVVyjy9qSjWdQZVPk9KSB7oCCukcGoZKiz+NoX/HjeQ3aQQznXgriqHN75lEn0nXgWRCmqMQO2VfEse3BdBg== 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=dZoCYD/0/64rjoFoTrPbqlFnT6HYWqcKLBXHrf/XwKs=; b=YyPnToQcXKHnmS2Va5mSXXvQM17GiIJkDzjHPNlih0MmClzDOI9msIncI2+2aT01+I9yIxme+if7WkAv30WbYUAvYQJqD/4p3fS/Inje/G6VUPt9PBapi4L7fZrPanwWYFPZk6WkKZrmLOR9Mxsr/DYeqdiTbVrhy8vhlUf2LyKsPwfv/kAsLNozK9KXPmf3ChfK9mZeRPe7JSABRKT5aayN4tnU99FOM1YztOiVCSxbVpiVkP/CbLeVJwQRjHDvI4K6sAPBXcAwF9wLqw6R+6++mRk0jchMAUDGs3KwI2N8aLYK/qBsN0EXjaHXLoLBLY15kfu4tG3PLC0GRN+Hcg== 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=dZoCYD/0/64rjoFoTrPbqlFnT6HYWqcKLBXHrf/XwKs=; b=E86VPkc8BNT7Gn5I71kzduqUCI9kPOaTPpx3DHtQCvREp2P2+bu7d/EKBvgx7UYeHWJQVafK7+XCmbR9hRSoxWX204OJqULIHCuRukRAO8H0HbXRaRGMrHW+c2iMMQwht2+CYfe1PEvaJw060Jp+DUQe0OeHG+7jECZdPxYYc+o= Received: from SN4PR0501CA0060.namprd05.prod.outlook.com (2603:10b6:803:41::37) by PH7PR12MB8155.namprd12.prod.outlook.com (2603:10b6:510:2b2::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8137.20; Sat, 9 Nov 2024 04:42:55 +0000 Received: from SN1PEPF00026369.namprd02.prod.outlook.com (2603:10b6:803:41:cafe::51) by SN4PR0501CA0060.outlook.office365.com (2603:10b6:803:41::37) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8137.20 via Frontend Transport; Sat, 9 Nov 2024 04:42: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 SN1PEPF00026369.mail.protection.outlook.com (10.167.241.134) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8137.17 via Frontend Transport; Sat, 9 Nov 2024 04:42: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; Fri, 8 Nov 2024 22:42:52 -0600 From: Mario Limonciello To: Hans de Goede , =?utf-8?q?Ilpo_J=C3=A4rvinen?= CC: "Rafael J . Wysocki" , Len Brown , Maximilian Luz , Lee Chun-Yi , "Shyam Sundar S K" , Corentin Chary , "Luke D . Jones" , Ike Panhc , Henrique de Moraes Holschuh , "Alexis Belmonte" , =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= , Ai Chao , Gergo Koteles , open list , "open list:ACPI" , "open list:MICROSOFT SURFACE PLATFORM PROFILE DRIVER" , "open list:THINKPAD ACPI EXTRAS DRIVER" , Mark Pearson , Matthew Schwartz , Mario Limonciello Subject: [PATCH v6 18/22] ACPI: platform_profile: Check all profile handler to calculate next Date: Fri, 8 Nov 2024 22:41:47 -0600 Message-ID: <20241109044151.29804-19-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241109044151.29804-1-mario.limonciello@amd.com> References: <20241109044151.29804-1-mario.limonciello@amd.com> Precedence: bulk X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SN1PEPF00026369:EE_|PH7PR12MB8155:EE_ X-MS-Office365-Filtering-Correlation-Id: 00267fcf-5197-4d8d-bbfb-08dd0078fa34 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|36860700013|7416014|376014|82310400026|1800799024; X-Microsoft-Antispam-Message-Info: 9pY2e9GNlN7gQIPQJ5DrgkurVVrfypRlOzGYv3HQuzNkJ6t8ptPXnHNM02xJ1o/zaYjIepvGTTkUPIhbr6hqb9dr/l/6d1aSmwT+A14gnhyBZqGcFXNSUIRMCLBUiAVlSc4F3gFPyIXC2Lwhc8xbqXhDdGmhJ1tXjDdSJyYxZUk95novBnBQv/L/3/XbbWXJRWmrDdyG6trBLkBg9drzkmIwZsUgg1jS8MOMGdLj+XpRvPtz4lUx64P0QnAY5PrAl0RGb8ZtTIuGBr50VqMU8P5H8Eb0YWq6xLjEZCC69KhUar3s0PVphRhWB7VjmzPYA1ymS67OcX4QRJwLPwhgxNrqPOmzvv2CVN4jEUXGhXRDCvB3CzQPS8ZSxMbD+Aom7vsxb9ord/R9XJUosDjNMUNxmPkRZZjTX9sWIsy6UwXAJ9Uftczp1KfV2RRQGjMZYhtS7V50H63E84s9COOZgFrqjrOe+LmpOHgxhvtk40Jz1YLI93g4cqXcA8jF0m59HxHhfqhqmBvet/+FUP6ItuO2boG/FWd5r41QfsVJjQIbSaq0GGW3V6xDsA8cBVI+LG/VC2H+nOV8cqPocAgzqHblhJ3JIRo9y2Oj7yyfU282bj6zy5ywbON7NWTNddjGtu4lt253GRKY7hksa2c4asV+lUW5WYW3U5AQ52xPMFyeeLwBHPIYIe6LNPcDi7raldcewGFQd9l6AfZWtvLtDCybRwtk+/tojwPe3A9pY0rnB9PMmzBVcAKxkvpg5r0H3WfETo7UMM0C4Q+iwG0dAhRcd73ZBr3gGJjuMnvEbjawKl9sV18yp4M3mxSz8auHo3vWmQq1DteeSASj2ZkDO1UIjJ7oyBQQzwhxD8Of4SRayTOZJSuvWYLGAB8AQ0PSQveaWsFX1xn0ngN+Dw9oxy76QS51krzwk7LexTMwDOgaGrlb1ObXtFoyLzVMjOTkizzsAIHnKgMsZW3H8Q41QkheLdM4hBX5Fob6yEKETGIXDKx1HbZB0wo6Hw6iuAniHLaiV8nmWj2f49lGg1RUO3ruYvIRsvM0RUTf8gRMOMpziYk2btDcJGlFWW/29OCAvalnR8LVsyGE2GHTOwPFycfqzclck0PQJpVrsLOAcRDgrhleNX+P1NUcuOLt+YnIM1gDvIGFGguHXo9GKlkW2rLoXmNcD6nan6FrKhUb7JiXU2sibDnaCj1zpESTXWJQr78Zk4LwChU/0Znv8tWA9Rt+3gilj4b00rjnYSOvvDdY20mMIBf4rSQxdSFdD4wP4taY3/2r7qwg3IvOzyNykWP3m4U5VyxnnEEzzXvStekoM9MYdKXQ6/OPCtDbP4CvND/a4JZkRQe2t7KF3/XR5rqi3drUCbUGADhqga/xvFKjRhbD80mGMI7TVqDpfJ+tg0Sx5Ld+dVVkiS6FmlldnA== X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230040)(36860700013)(7416014)(376014)(82310400026)(1800799024); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Nov 2024 04:42:54.8907 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 00267fcf-5197-4d8d-bbfb-08dd0078fa34 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: SN1PEPF00026369.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB8155 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 Reviewed-by: Armin Wolf --- v6: * Handle cases of inconsistent profiles or all profile handlers supporting custom. v5: * Adjust mutex use --- drivers/acpi/platform_profile.c | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profile.c index 2676f4a13689e..c574483be4fd1 100644 --- a/drivers/acpi/platform_profile.c +++ b/drivers/acpi/platform_profile.c @@ -423,28 +423,40 @@ EXPORT_SYMBOL_GPL(platform_profile_notify); int platform_profile_cycle(void) { - enum platform_profile_option profile; - enum platform_profile_option next; + enum platform_profile_option next = PLATFORM_PROFILE_LAST; + enum platform_profile_option profile = PLATFORM_PROFILE_LAST; + unsigned long choices[BITS_TO_LONGS(PLATFORM_PROFILE_LAST)]; int err; if (!class_is_registered(&platform_profile_class)) return -ENODEV; + set_bit(PLATFORM_PROFILE_LAST, choices); scoped_cond_guard(mutex_intr, return -ERESTARTSYS, &profile_lock) { - if (!cur_profile) - return -ENODEV; + err = class_for_each_device(&platform_profile_class, NULL, + &profile, _aggregate_profiles); + if (err) + return err; - err = cur_profile->profile_get(cur_profile, &profile); + if (profile == PLATFORM_PROFILE_CUSTOM || + profile == PLATFORM_PROFILE_LAST) + return -EINVAL; + + err = class_for_each_device(&platform_profile_class, NULL, + choices, _aggregate_choices); if (err) return err; - next = find_next_bit_wrap(cur_profile->choices, PLATFORM_PROFILE_LAST, + /* never iterate into a custom if all drivers supported it */ + clear_bit(PLATFORM_PROFILE_CUSTOM, choices); + + next = find_next_bit_wrap(choices, + PLATFORM_PROFILE_LAST, profile + 1); - if (WARN_ON(next == PLATFORM_PROFILE_LAST)) - return -EINVAL; + err = class_for_each_device(&platform_profile_class, NULL, &next, + _store_class_profile); - err = cur_profile->profile_set(cur_profile, next); if (err) return err; } From patchwork Sat Nov 9 04:41:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 842748 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2045.outbound.protection.outlook.com [40.107.92.45]) (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 36A26194125; Sat, 9 Nov 2024 04:43:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.92.45 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731127383; cv=fail; b=MaZ5fKzQONS9i8n2uO2gw9B1KdQkTDeMLom0dRv9g7pHIOBiX8CFVzkZaKHqhmeiRYoZN5zaa2h5u0PlNYcY+n0VXg+4k24LTD/PpyECGRTaOKLtjObPGLFhKFfVFlfbgvq1cL4SYyMKnZNSP3+SslnJzPaXd0AEwUy2isd/2IM= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731127383; c=relaxed/simple; bh=bsZ5S0XqXIx6iShhLJvyj3hXrAuYsaqPy/0QTkCK938=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=m7C0C6tgswAKr0t2UzgodW1HobLWNFok6Bm8SgZM+CP5ZRAhbGVnGsfLexnQ6jWguk57ekDSWnzAsDELszrsQqhcSEHM+vzVdAlKaZgpRXHNCvlzmQqJkoaPpx8aqY0MWbpGaP76jFS1h7MGs6Dv5vrWR5UTkDFmUhx/FRDlfXg= 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=WKj6cWMm; arc=fail smtp.client-ip=40.107.92.45 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="WKj6cWMm" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=lsrbLHfJpOSZumFsK27H0MUa7e13/sU7Eodsv3ueTU8hivmQeV3sBrfskDI56NGsSjVMh/AnQJf5gTzLY5ffMa9+ydCkYAa8geKhMOKJZ/B8oARSxS+qNwKCr8MyAuAQDCXUBtIvLd1MDBX7S4Wuj9yHqs8D9e4vEe4H/xyGBpn+e4T/D+TEm1BFafsDC686BO+5HnlXZdE39uuPI7wlWZObEuNpv07JZQ88G++kLavWYXTr4syZJdUeiZ0WBlbsyshMJqxuTOSThxKJwCfReFQg6rj/oOyUhs7jM9Qx59dPuoYlvqX6IkknqpC3pXSwSD3UxVEr469Tsp0CJDNqDg== 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=cAhosvhTd9HzwxFi/2c19ZuT0eHX5TvU0LmaRci9rSM=; b=sUXX/Xp6b8R5ZN6VeFFToofqvzThX0wH20JC+jsnIQLCLxYwNbbZG+QKDCS3EHVcArqCRhKFnDTdJaalgXFX0ACbDrV5QNwG1J4qRhKYSMiPDNJMfiODZ4LttO69oqMwFypoQpO6tyq2TcAFY0b20LUnEgPrLCQ21ezp8tt5oLbkTiBkP324rR8YFtLeADnO800MiSfAb8AblCrsM6XogwbhQfVhiw4lYmotZPjZSnGhyKW74qCCyRscfTm5xBjVJgQeBka51tZOzUN93s8GHVPNR24JHh2S2sw11Oz1Dmb07bIZMFXKRifdz5MslAtaHViXBP2oWD58OvvreTByAw== 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=cAhosvhTd9HzwxFi/2c19ZuT0eHX5TvU0LmaRci9rSM=; b=WKj6cWMmrptuHVDtxr6v4ADbUP8ISZCDdvZqYalORypjbuxG16s0jvDVQvB5OTG0xNnbqUkjEFaeg/+3uaPGuP4G1InTk3cGjyj3Ybv4xUNUwjGquRd6zuMbNX0fBRnILwN/LDPA8ll4LnS4peGTdvnaZLj54KLaYY6Gku1yYcM= Received: from SA0PR11CA0176.namprd11.prod.outlook.com (2603:10b6:806:1bb::31) by PH0PR12MB5605.namprd12.prod.outlook.com (2603:10b6:510:129::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8137.25; Sat, 9 Nov 2024 04:42:56 +0000 Received: from SN1PEPF00026367.namprd02.prod.outlook.com (2603:10b6:806:1bb:cafe::e0) by SA0PR11CA0176.outlook.office365.com (2603:10b6:806:1bb::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8137.20 via Frontend Transport; Sat, 9 Nov 2024 04:42:56 +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 SN1PEPF00026367.mail.protection.outlook.com (10.167.241.132) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8137.17 via Frontend Transport; Sat, 9 Nov 2024 04:42:56 +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; Fri, 8 Nov 2024 22:42:54 -0600 From: Mario Limonciello To: Hans de Goede , =?utf-8?q?Ilpo_J=C3=A4rvinen?= CC: "Rafael J . Wysocki" , Len Brown , Maximilian Luz , Lee Chun-Yi , "Shyam Sundar S K" , Corentin Chary , "Luke D . Jones" , Ike Panhc , Henrique de Moraes Holschuh , "Alexis Belmonte" , =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= , Ai Chao , Gergo Koteles , open list , "open list:ACPI" , "open list:MICROSOFT SURFACE PLATFORM PROFILE DRIVER" , "open list:THINKPAD ACPI EXTRAS DRIVER" , Mark Pearson , Matthew Schwartz , Mario Limonciello Subject: [PATCH v6 19/22] ACPI: platform_profile: Notify class device from platform_profile_notify() Date: Fri, 8 Nov 2024 22:41:48 -0600 Message-ID: <20241109044151.29804-20-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241109044151.29804-1-mario.limonciello@amd.com> References: <20241109044151.29804-1-mario.limonciello@amd.com> Precedence: bulk X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SN1PEPF00026367:EE_|PH0PR12MB5605:EE_ X-MS-Office365-Filtering-Correlation-Id: ceaed80e-568f-4178-f5ff-08dd0078fafa X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|36860700013|82310400026|1800799024|7416014|376014; X-Microsoft-Antispam-Message-Info: BStWwf7phVdXShOdKPDwNGrNYWq0V2JhgUOBQ6NQKN9EvkekpAtBc5Nuewuq8iPiY1iAHFjqYh14YK6ho4ozevpf5JXkygAxn5BhZ/h1t8OLjAkFYI5rxV8c4fk1kLYJSWOsDDOOpF5WgGh6bzAhAOBnbT7NYNOLqzNBL599R/pjymhirjupM0BApE57e7R6iE/5SK+Q1Wxza7CiEIJCaHDJJbFU2s7y9JBx6iM8wCGftn2xSsQ77zjBC6buaLcuQKCyIVVoOPdvS2TmhPLeKi37QLwsjUCImzL2ePJqHdjxxzdzd14zVFRzSSF+3LNaIMtoA0MquW6EjQmAr2NnQz7rdQzfrYrkjIXZwwm/JoRkpvrmU2PLZP4pHa/hkwiFAAkj9jvNGH6+wns4q6IaFKFwLSb51CMDMlqFVZ85cCnVj5QzW3Dcm668W3i9RQsk7pY//uFoY/DAaeLuzS3MKVRaqhlPaUy0MclijuF0OtqNmhCXpInZl4jMq4dhcpTWIbi6++f9vb2kND9IXDmOWHUM9we75SKZLmGSuD7inB1RkCDZXDyVqeLkstg0EzauEPvoW/x/k7gGKV1WvpDrZCODHit4FN1jlMWzNiqghs5UzhVCENiS46OIRfxjd70f6RDPZpH55NTvgo+VwDwPFH6gOX26kRo0+R+7StOe0Jp/aO2jMIY3qB9dVNcHCKiIEmuQyv4kZu6b2qei3XTCTQjI3NivPnT+nY/9raVIytQwXK6iI0i4AD+KRZ6A8XINojo92PURP0ElqKekarKtpr8vGssclu3aRh13HnYaNB0S+/nq4rNNPv0cDWuEAKyjaFsXYdVBSwTAiEoqeGbaFEgyePYFsTqJ9GIysutrcrgE9TeBVo6kET7aU5gVhZtB44tu02byNFo6pKn2Sn42TdGmB0QBZGKRY/ubepmatsZTRFNKVPUx6Gw4B2OFYl2GM8EzTLKfVg+SNPqhbqnj31RTJCfp/fUT5wAk7yr8g/RntmsYAKj1Aksp7np9xcwlkRdrjpCs+usAiM3no8qVRTihPOEL9CttZJtVhzaTfHrCQ9psHn0BVWuF+lWyC6rnQ6Mn/y9YiYQ236tMybcvRD3FpisgnvmH1ppkPUZakh20aGlTx6Gb2Y0y+sYb9M4AwDN680oP+X2iUY9nkxAeLBLQJ3UMZ+UAuFKmjc/x+6Kbws7TqHQrmS6KyNgTeeqtu+60kAUzg1eZ1wna/K4inYSH2E9fnrtJr82Zt+6OW+j00dR/fsJk+V14F5+zymXFIM6kHdIFA72tR6NPO5ex53LJKBEZFPnxKHIgmm+vO3/W6rxIFR/GBd/AzNMQ5sXhdtCOMVuUOF9i7Ab3UaRqx1mx1h5j4yuBtjW2i5fbVXSeSe5dwDEmx59lUa/JEr1OKo8MN8+Rgx89OKsak3ATCA== X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230040)(36860700013)(82310400026)(1800799024)(7416014)(376014); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Nov 2024 04:42:56.2523 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ceaed80e-568f-4178-f5ff-08dd0078fafa 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: SN1PEPF00026367.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR12MB5605 When a driver has called platform_profile_notify() both the legacy sysfs interface and the class device should be notified as userspace may listen to either. Signed-off-by: Mario Limonciello --- drivers/acpi/platform_profile.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profile.c index c574483be4fd1..7ad473982ab11 100644 --- a/drivers/acpi/platform_profile.c +++ b/drivers/acpi/platform_profile.c @@ -417,6 +417,7 @@ void platform_profile_notify(struct platform_profile_handler *pprof) { if (!cur_profile) return; + _notify_class_profile(NULL, pprof); sysfs_notify(acpi_kobj, NULL, "platform_profile"); } EXPORT_SYMBOL_GPL(platform_profile_notify); From patchwork Sat Nov 9 04:41:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 842118 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2049.outbound.protection.outlook.com [40.107.94.49]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6C10A19414E; Sat, 9 Nov 2024 04:43:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.94.49 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731127384; cv=fail; b=AvVbrSaBe84piIpU1/0gV7xTNCn5s+Pk+nkvWxu/4yh4L5uXRFJmLVkHwgjG0AP10FdBHqOkFtkTjW+EU/LP/m6bBjDwtZh9uOvDCfAo+lNyhIaw4+mYfLXJKte0L08+JXS/WhjnnjmBojebZibD8gJJ45vx2KqfvU/nnRXjN/Y= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731127384; c=relaxed/simple; bh=3B+dpjIHZLzwXnNd2dzibnbD3DvZu+qvT4q+s2VuMPM=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=nB6trqyjrwgS3kwNRfhc5S7Ssf2F2g1KEHBPOxFHVex1ndQglrZxT2mOWZGmxIEDOKQAehOlKMR71hHYbpo3y1rV1rISvPIBRFHD34HS9ka811hSU4H+kHntz0P7viCtmmIdPuJPzXscpbgpx/vX2+6XEuec5RgSq3pB67t+Vm8= 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=MofeEMeM; arc=fail smtp.client-ip=40.107.94.49 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="MofeEMeM" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=WYL3IZcV3WG/bxpg20puDremEY5J0+vZE10biTmXVjMTL3cNJUy7+qlky+0Lbb8eLCZi9tKuPbXL23cg0cyefmCwLWCCLdxDiGndUb9umq1QYbHBvaQFCi93Fgcn66egvxubqFTlKAnYh74NNiw1hWDusC0LVlrD+XS79kr3Saf9vci/7H+MMfs8r9gJ2M6wTgjFDLnZHeuxLHXWIs2ZNoT/45kuCj6wLQxVoOO7Nh6biJr3xDW4X57uqBYH/YeIYbxfQEIclMKrqlMz1DlMj1tj/CQazdnEy5YsKU+l5f41DX5Q7MYbDFUnvbB9P7gg9ZxhOYSyOtNUZe80Ta5XUA== 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=6fC5Cm4kxPJvgqyqj/FkinH308BLgLXliGBafw3INL4=; b=bCh605xI/5/en/AWx6TwLKL01r54qtgApfo4DLWwfjpb8sIvwfIavSkbK2ck4YbRnRsw20+hq7+WG7NU+UK96LLsPTRuE1/zSy8zff+HqRlzRQYKrJZ/m6J3A1pybAD/2brbofn5BBIP3AD/Q0SVMP/aL300+nYtThpcRy6DLNKNSkg7GfligNzYzOtgKyEfMjI3+lbI5VL2wMYHBhNjp/yg3jO4uG6hSuSCB9bO2eDaX2+mOy3+ayUTDntKts8+swuGUPsCNMZBHAZVD5dcWi045WYdhDYuqGTEG0Ovthh+Fh7nOQG8KT89mw9+5h0Z32TFvDZBbBS9Y/ejxERIlA== 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=6fC5Cm4kxPJvgqyqj/FkinH308BLgLXliGBafw3INL4=; b=MofeEMeMd2Sr1GX9Eq3OmJxW401A9sPh6nWgllYVrm+m2lL6qkXH3fNfDEK8t45EPmtgEet1e8f3RcGd+yHOM+oyN3zhoWOb1uWd1EDyOWPiLqvont4yxVZgPr04TByXXaWP3OQuhv+3O6syGfrMUdLwauXLbs8IhOy9YCpjt8U= Received: from SN6PR04CA0102.namprd04.prod.outlook.com (2603:10b6:805:f2::43) by LV2PR12MB5967.namprd12.prod.outlook.com (2603:10b6:408:170::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8137.19; Sat, 9 Nov 2024 04:42:58 +0000 Received: from SN1PEPF00026368.namprd02.prod.outlook.com (2603:10b6:805:f2:cafe::22) by SN6PR04CA0102.outlook.office365.com (2603:10b6:805:f2::43) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8137.21 via Frontend Transport; Sat, 9 Nov 2024 04:42: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 SN1PEPF00026368.mail.protection.outlook.com (10.167.241.133) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8137.17 via Frontend Transport; Sat, 9 Nov 2024 04:42: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; Fri, 8 Nov 2024 22:42:55 -0600 From: Mario Limonciello To: Hans de Goede , =?utf-8?q?Ilpo_J=C3=A4rvinen?= CC: "Rafael J . Wysocki" , Len Brown , Maximilian Luz , Lee Chun-Yi , "Shyam Sundar S K" , Corentin Chary , "Luke D . Jones" , Ike Panhc , Henrique de Moraes Holschuh , "Alexis Belmonte" , =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= , Ai Chao , Gergo Koteles , open list , "open list:ACPI" , "open list:MICROSOFT SURFACE PLATFORM PROFILE DRIVER" , "open list:THINKPAD ACPI EXTRAS DRIVER" , Mark Pearson , Matthew Schwartz , Mario Limonciello , Armin Wolf Subject: [PATCH v6 20/22] ACPI: platform_profile: Allow multiple handlers Date: Fri, 8 Nov 2024 22:41:49 -0600 Message-ID: <20241109044151.29804-21-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241109044151.29804-1-mario.limonciello@amd.com> References: <20241109044151.29804-1-mario.limonciello@amd.com> Precedence: bulk X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SN1PEPF00026368:EE_|LV2PR12MB5967:EE_ X-MS-Office365-Filtering-Correlation-Id: a1306266-45d3-4da0-e29b-08dd0078fbf9 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|376014|7416014|1800799024|36860700013|82310400026; X-Microsoft-Antispam-Message-Info: NRV8hp0wfkF7gRQj6IzOAVQtE/IYPjTHr/EAkLAV8AlG6pMhWKkSOqqFQlmPha74elQk/0H2kD2DMwPSu5xj9i02bf5jW9asFlWC0MLjUqJnTdhtLYq98SMX9VO46HDiJ8P9wZBYOwx+wjNCIK+mfTwddbIBJEtUZeqJh48aBNbEvH2gCOG8lpWiqPX6X3O+KC4l3RrIXZS8rZk32GccUpyQwZv41HQ5Sx7RQXcsqlLnRb1hV0OQYzyUsFsy/ZRUDK/bZxWHa8NT5OKqGolGvlVcRo8Ls5cYQUlsHhgu/dO/b316/WRtu2nyhqv21hfF/ijI7Mg0JXKeUt5IYAvHdOSN1oOoUBnOKk2/QOYTX0D71BIbJ+F+5UiELpbAunsuTAUxau0PD1F4CVMQcDJXCpgUpz0/8INqXjVQFRNikp8ddfjDvL9g3Zga76728+vnJNy9geOUmX9yX1R7gJoa2J9OyOWTLrQcl5Pge5N+7eG+F3DWvwjvEDz9U44PLGFK/raxfDhxzab9X5TYSxgjHRbGz0n8fKXtB8hKCBsWe8vqfyxkh9dLdb4psvq7DKA2koEYccxXndMzmZHL2txLuqVzz/aRKgqFwCvuqbnL+a3008fgaPha0vHt9BjDLUqPj2r2T8lyxc3X6YYodOia8rzshkKHSq2YoxBVKIfAYeEJwHSQT8mwbeX/QeelBl1wT+PRLBiopQ23acQ+HANvLyWKTxnrMt79BrrcTrk6h42mv+miR1rS+gU2Ueh1mqg2PsOHZiZ9SaHMB0xXfTbV+7sYtNcevCq/L8hvYJCenu6AEKsfqzpr5Borzr0shNanaLtDBqVFoGjDD1LJ9O736AOxFQUaqDXIk/6iaEQpYtcK8YVsTmuADU8ZLw4BH0cTxEZiZ0MHNpCtnzOPBsMhHJDh8U2PQd1K58coJAYAVcCxJFSfUM8V3nCnEBflfcReTiF7rjYayPy4Mxvr6Z+2XTmBlODjfHjEVodqeSn8DGa80UUrJmogobZwNypfUuulDKoBCjRrVTxXz4sLlj3OT+e5gWczDEf89LUtDYPPSge0xbKFCXDKtyAdwGp1xRFCv4Utl8hQBF1JuicHEG5yo7YfBhKNPtYG/xgn4dCx7ruJ7iJLCJHnhcnSSGGWnwJnl1I5PqW+hW5Ezlz2PlRMlxM6v92ZitiFV6qIQORA3APF3SP+Qdz7UIgPS+JFfJF0mOCp8Umt0Cb4tMOtOaH1y9/yC0O90A96Pi4I5lMqX7Nb+89VBdzST9zcn+0pIyFdOd7YNoa6QWdVueqd+HES7uLbILmgVntMKdgcR0/fIcAmMDZTt/rgSRlWoLFv8p+nKXJRymZNUE55SpQzZ3F7vGLlZkN5anwDAadNUFrSRbwALJ0BD5o32pZs1LmdqR7I3+AKppDTzH6jzBjl+Hc4jg== X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230040)(376014)(7416014)(1800799024)(36860700013)(82310400026); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Nov 2024 04:42:57.9230 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a1306266-45d3-4da0-e29b-08dd0078fbf9 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: SN1PEPF00026368.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: LV2PR12MB5967 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 Reviewed-by: Armin Wolf --- v6: * rebase v5: * reword commit message --- drivers/acpi/platform_profile.c | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profile.c index 7ad473982ab11..0a8b86b44e161 100644 --- a/drivers/acpi/platform_profile.c +++ b/drivers/acpi/platform_profile.c @@ -10,7 +10,6 @@ #include #include -static struct platform_profile_handler *cur_profile; static DEFINE_MUTEX(profile_lock); static const char * const profile_names[] = { @@ -415,8 +414,7 @@ static const struct attribute_group platform_profile_group = { void platform_profile_notify(struct platform_profile_handler *pprof) { - if (!cur_profile) - return; + guard(mutex)(&profile_lock); _notify_class_profile(NULL, pprof); sysfs_notify(acpi_kobj, NULL, "platform_profile"); } @@ -480,9 +478,6 @@ int platform_profile_register(struct platform_profile_handler *pprof) } guard(mutex)(&profile_lock); - /* We can only have one active profile */ - if (cur_profile) - return -EEXIST; /* create class interface for individual handler */ pprof->minor = ida_alloc(&platform_profile_ida, GFP_KERNEL); @@ -498,8 +493,6 @@ int platform_profile_register(struct platform_profile_handler *pprof) sysfs_notify(acpi_kobj, NULL, "platform_profile"); - cur_profile = pprof; - err = sysfs_update_group(acpi_kobj, &platform_profile_group); if (err) goto cleanup_cur; @@ -507,7 +500,6 @@ int platform_profile_register(struct platform_profile_handler *pprof) return 0; cleanup_cur: - cur_profile = NULL; device_unregister(pprof->class_dev); cleanup_ida: @@ -528,8 +520,6 @@ int platform_profile_remove(struct platform_profile_handler *pprof) sysfs_notify(acpi_kobj, NULL, "platform_profile"); - cur_profile = NULL; - sysfs_update_group(acpi_kobj, &platform_profile_group); return 0; From patchwork Sat Nov 9 04:41:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 842747 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 958C71442E8; Sat, 9 Nov 2024 04:43:04 +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=1731127386; cv=fail; b=BT4zjrxztRwvFWo/7V+uhva3mtD0tjMNSkFJE0p/PndiBEuiwyyNEFquQkCM1nrT/1Iqbxr7Uy86SXINqAUhRY1jK1CFz3OmZ2VEEL0eA16TLPMR2yUBE3Iap48SpOfEd8NGb8ycV+dKKnlnMdnYEtClaH4dGIYB3qZfQhYIkrs= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731127386; c=relaxed/simple; bh=wydFZq9b9U47n3suMunKX8B3Vmy1X7R/gKQy89bbhQ0=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=bfSMeJFH0p5KyjAgElMmVom4szWohoVnCmF+BuQ7Uz0j/Kh2yHIBWE6tijn4udseKDJzFbQasl31x9ceBXg4jbv5nt58MPxK4BSas5qizjgAVlOaNVlVQHVdsj4fHOoY3u4oEMlAXt7j57oZ4xEGtgUKQJJcUHne++mh55T7drw= 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=RwWPN6Bl; 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="RwWPN6Bl" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=bhUAV/aEeojzSSCSlGPE1Bi0xnSFRFQnaDyKkG30G5cO10tUQQNwY8FzjS8Bb8ISFp8MiyDFWBZ9goeLqkhSRiSnFQgMH/4C7xH7toj/5m7AOekgmkZd08AngeVuQ9V/i9PoAtizj/eF2lJ4Sgb5Ku6HT61p1HeAAGAr/S7QP8DhCpukPxVdHLnKdRInCmd6XETKfyRoAnqmTIQMlWUkrajKVxh2LpVlCldsuQ5AAsmwcYujXXQXnwWsni5c4ZK/ikPRDMrGRDGCP3J3GZXCBj/3bef6ODXTWWtsAsWiluf3HAoIMA5bdUdiJNUM748sj70eYzNTKfIR7oEw9QMaLA== 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=cKHL8QUwPLmQbXZTvlLQE4Ru6fBz6C26Aw1v2igp9kr0chO3/d+yVJXXciOncwetUqiOVq7GLhd22dq1+mgwR3auV78oh4/jlSRLQJRXulnae1D88E5WgVeO7Pvk/QTG95BbF9ilzfLcF2dSSbWVlRvC66lR+1Q5A3PUG9PR+t5Lp0JQmgVWpTA/RfWLRq2KM25U8VNbnxOCsfsJ5Kp0FBTkBcICRG43cbjjvliZC65Vj+tjSQXYyMFJjfxhvtNCL7Ap0lJaGz7dfG75harXWhld4I6/GpDWsy94KteOyyKMyYjMmpiaFsiRHIRRB49SkDmDAPq59ZUb4fILXr3U1w== 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=RwWPN6BlFnSVQQ4WY2MOLgJ4ux8kDcgN+rzXRa9BpnFdwhkBHWpT1YB28Beq06/2Ka6xMovBBAXX0uvIuXaqy4e8LFS82U59E9TICk+fTZN+Fxmv1/kiMe6QrLq0tHDcG6b+rz5TlzLWiZyanL0SPAQQxMr4dKqwQ0sK3EZdze4= Received: from SA1PR05CA0017.namprd05.prod.outlook.com (2603:10b6:806:2d2::20) by CH3PR12MB8903.namprd12.prod.outlook.com (2603:10b6:610:17a::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8137.19; Sat, 9 Nov 2024 04:42:59 +0000 Received: from SN1PEPF0002636C.namprd02.prod.outlook.com (2603:10b6:806:2d2:cafe::b7) by SA1PR05CA0017.outlook.office365.com (2603:10b6:806:2d2::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; Sat, 9 Nov 2024 04:42: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 SN1PEPF0002636C.mail.protection.outlook.com (10.167.241.137) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8114.16 via Frontend Transport; Sat, 9 Nov 2024 04:42: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; Fri, 8 Nov 2024 22:42:57 -0600 From: Mario Limonciello To: Hans de Goede , =?utf-8?q?Ilpo_J=C3=A4rvinen?= CC: "Rafael J . Wysocki" , Len Brown , Maximilian Luz , Lee Chun-Yi , "Shyam Sundar S K" , Corentin Chary , "Luke D . Jones" , Ike Panhc , Henrique de Moraes Holschuh , "Alexis Belmonte" , =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= , Ai Chao , Gergo Koteles , open list , "open list:ACPI" , "open list:MICROSOFT SURFACE PLATFORM PROFILE DRIVER" , "open list:THINKPAD ACPI EXTRAS DRIVER" , Mark Pearson , Matthew Schwartz , Mario Limonciello , Armin Wolf Subject: [PATCH v6 21/22] platform/x86/amd: pmf: Drop all quirks Date: Fri, 8 Nov 2024 22:41:50 -0600 Message-ID: <20241109044151.29804-22-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241109044151.29804-1-mario.limonciello@amd.com> References: <20241109044151.29804-1-mario.limonciello@amd.com> Precedence: bulk X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SN1PEPF0002636C:EE_|CH3PR12MB8903:EE_ X-MS-Office365-Filtering-Correlation-Id: 761fe3fd-1243-4767-5a49-08dd0078fced X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|1800799024|82310400026|376014|7416014|36860700013; X-Microsoft-Antispam-Message-Info: JrWY8W6V6+36p61bp6YW//t56zovNHUnNGikgVxEoRThgj8iaOaUP2b6Bs1V9olNzuWmh5ZFJXpIMWmIFVaIPz111UY1sPfblx8dxhqsfIK2KLMxLGyu32H4GTODDAr+Y93T6ho22SMITGUnVKL+cwMpjzsuXneFzNnZ8sQYiUiSqnFna99BUZwVPpiWMUXRaC1Vdu1sau9eZ59WI2VYxtRBQqS9cP/mz8lmcfoSaQU05tURJCCJT1g+Aa7LaaKjM92wgzFoeiA5v02bQo7RZ5l+JUV9JJLQ8bjT+z2dwUZhFxGbouoTqw23yUfGihOUmgECeuV84MXW6MIICM9IVni39cwy2VeAs6qFRhtekVQlRB0Zzoiod0SbcmBig8xwi1JHRkjEClZB1kANs7XnIuLpmIXE5lWf4S3OMUSr94AO+A+Djl7ljJBD3Nosf9c4V5RRQk1lY6Snuo/3EdWjkT2atWbgiaK4m+8Z8UiazhQ6rscDRmI2mB55rbg2e2Ht7b9b0RKD+WuB7gt8ZERr27l2BxKhMS1NVRNa9bGjwpkKnXFeudrxx6F4UwN6lLxfHX0Lz2+cR1lOJ96blMNo/BSRKyRHAJ4OA7/dIRBPZ4PPcitGZ0l5eUr5sYzW0GprYUcdJMfA6uiP24qK43auygRs+vLsvzk1WeHbuos4uMOBUa7USD2rvlYwL6d5/uTMpJMhjJCQR3dY91z6M7WAsF3IZxGzPv34m0h7mDuU8rDfzWYtf/mYZQd0GMlAw1J5KwJ+mgPR7Svoq29NKvN0ZaATKFilUBezI3nmNilagQZ3PA0LoEeVXVH4vVSxo7bqHj6HPtFraZJ9ihgaien/5VvkASgqseKZKN2uVhNGYCtAJ6ChZU0/lDMH3WgOq8YOa5tG+qr2ytafudQUE5ofCJdCcLXI3+EuitQDHD+NFfvsOhhr4Xc0EaORUGu56FufKS4/YoJpLLBHPm5xTcnDsKpCxMLhOKoRBSkDf0ooPZXgT/x0OGQupGJXV6voanVdtjp/9sxNdmchViJsOXptTEeCk2wrgO8GawGOgfI5EIRd+vrPtYDtQOeXirYyUT+T4qwcHLsP4YHbQ1qupL577iTcEf5efvOs2se4Yh7ktKnfG/02i2VEFYsXyFSTrYO44FFd+I/Ugz2lMiJsTf/5oM2WpxQmNJ5XF+H7TCGImHtRX6Xzfzwxm/ztbivySd9d66UDSMA2fQLBT+JrugYoC9JHj/9L9cbBkPqku+h28fFj38kD5nNeFBJ/YCQSoiQp4XtR5JRy1dx2LJSNqQeWutezng8/rQZ48is7ZF7ArQHqBh2mm71J9PR5qvrIoDWLv1H55ZUMpfx0SQYqEXcrYHd2YdZxAp1Y3/G1tVInl+s2EEnUeiIZv0m371mBGu7/BHRT7rWOPRbQzFwPKx08lg== 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)(376014)(7416014)(36860700013); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Nov 2024 04:42:59.5186 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 761fe3fd-1243-4767-5a49-08dd0078fced 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: SN1PEPF0002636C.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR12MB8903 As multiple platform profile handlers can now be registered, the quirks to avoid registering amd-pmf as a handler are no longer necessary. Drop them. Reviewed-by: Armin Wolf Tested-by: Mark Pearson Tested-by: Matthew Schwartz Acked-by: Shyam Sundar S K Signed-off-by: Mario Limonciello --- drivers/platform/x86/amd/pmf/Makefile | 2 +- drivers/platform/x86/amd/pmf/core.c | 1 - drivers/platform/x86/amd/pmf/pmf-quirks.c | 66 ----------------------- drivers/platform/x86/amd/pmf/pmf.h | 3 -- 4 files changed, 1 insertion(+), 71 deletions(-) delete mode 100644 drivers/platform/x86/amd/pmf/pmf-quirks.c diff --git a/drivers/platform/x86/amd/pmf/Makefile b/drivers/platform/x86/amd/pmf/Makefile index 7d6079b02589c..6b26e48ce8ad2 100644 --- a/drivers/platform/x86/amd/pmf/Makefile +++ b/drivers/platform/x86/amd/pmf/Makefile @@ -7,4 +7,4 @@ obj-$(CONFIG_AMD_PMF) += amd-pmf.o amd-pmf-objs := core.o acpi.o sps.o \ auto-mode.o cnqf.o \ - tee-if.o spc.o pmf-quirks.o + tee-if.o spc.o diff --git a/drivers/platform/x86/amd/pmf/core.c b/drivers/platform/x86/amd/pmf/core.c index 47126abd13ca0..6ad00b3d472fe 100644 --- a/drivers/platform/x86/amd/pmf/core.c +++ b/drivers/platform/x86/amd/pmf/core.c @@ -455,7 +455,6 @@ static int amd_pmf_probe(struct platform_device *pdev) mutex_init(&dev->lock); mutex_init(&dev->update_mutex); - amd_pmf_quirks_init(dev); apmf_acpi_init(dev); platform_set_drvdata(pdev, dev); amd_pmf_dbgfs_register(dev); diff --git a/drivers/platform/x86/amd/pmf/pmf-quirks.c b/drivers/platform/x86/amd/pmf/pmf-quirks.c deleted file mode 100644 index 7cde5733b9cac..0000000000000 --- a/drivers/platform/x86/amd/pmf/pmf-quirks.c +++ /dev/null @@ -1,66 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0-or-later -/* - * AMD Platform Management Framework Driver Quirks - * - * Copyright (c) 2024, Advanced Micro Devices, Inc. - * All Rights Reserved. - * - * Author: Mario Limonciello - */ - -#include - -#include "pmf.h" - -struct quirk_entry { - u32 supported_func; -}; - -static struct quirk_entry quirk_no_sps_bug = { - .supported_func = 0x4003, -}; - -static const struct dmi_system_id fwbug_list[] = { - { - .ident = "ROG Zephyrus G14", - .matches = { - DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."), - DMI_MATCH(DMI_PRODUCT_NAME, "GA403U"), - }, - .driver_data = &quirk_no_sps_bug, - }, - { - .ident = "ROG Ally X", - .matches = { - DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."), - DMI_MATCH(DMI_PRODUCT_NAME, "RC72LA"), - }, - .driver_data = &quirk_no_sps_bug, - }, - { - .ident = "ASUS TUF Gaming A14", - .matches = { - DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."), - DMI_MATCH(DMI_PRODUCT_NAME, "FA401W"), - }, - .driver_data = &quirk_no_sps_bug, - }, - {} -}; - -void amd_pmf_quirks_init(struct amd_pmf_dev *dev) -{ - const struct dmi_system_id *dmi_id; - struct quirk_entry *quirks; - - dmi_id = dmi_first_match(fwbug_list); - if (!dmi_id) - return; - - quirks = dmi_id->driver_data; - if (quirks->supported_func) { - dev->supported_func = quirks->supported_func; - pr_info("Using supported funcs quirk to avoid %s platform firmware bug\n", - dmi_id->ident); - } -} diff --git a/drivers/platform/x86/amd/pmf/pmf.h b/drivers/platform/x86/amd/pmf/pmf.h index 8ce8816da9c16..b89aa38434faa 100644 --- a/drivers/platform/x86/amd/pmf/pmf.h +++ b/drivers/platform/x86/amd/pmf/pmf.h @@ -795,7 +795,4 @@ int amd_pmf_smartpc_apply_bios_output(struct amd_pmf_dev *dev, u32 val, u32 preq void amd_pmf_populate_ta_inputs(struct amd_pmf_dev *dev, struct ta_pmf_enact_table *in); void amd_pmf_dump_ta_inputs(struct amd_pmf_dev *dev, struct ta_pmf_enact_table *in); -/* Quirk infrastructure */ -void amd_pmf_quirks_init(struct amd_pmf_dev *dev); - #endif /* PMF_H */ From patchwork Sat Nov 9 04:41:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 842117 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2049.outbound.protection.outlook.com [40.107.237.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 7FDCC197A6A; Sat, 9 Nov 2024 04:43:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.237.49 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731127387; cv=fail; b=JOb74QiJ8Kh4ICGRm+PNdrZFCaBkCktJ7xq0LGA08bE9vqbf2Mmuj3WKr5upRQ1XVeOSm71ifKzobiyCqdG17UMLVicOuEL95lZJg+h1FA20TR8wwJSQZTPeW6+Hfg04T6eM7SUNg9r/F5McvnYdvx5VwgJNcHZyMAzo9OL9OII= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731127387; c=relaxed/simple; bh=/+/ROlHIruuC8Ptk3wbPDnl/Q1PdBpPyHTOE4QQFJzE=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=g9/gfv84kkmQGeRrAN0UYbMrpB/U+23gMI2M3ZWRVxrPmkv9M5w+rJIB/E20T6roPbthd4u2HaXYdudeJ2u34vm4wmnxRlKg9wroTbmRY9ognMQbARrCOLuh6Z9ZFPn2l9ZJEoHqpFqRcK4vD0GJuig3ZBgLwQI7qc1XVOwHDlw= 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=VSjSz/pW; arc=fail smtp.client-ip=40.107.237.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="VSjSz/pW" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=ellgB+9wHNiTkVpQi3zS129lXjeeNGUkZIsEhWZsQNT+TIfW4PU+jGoCpGuV4nb4/dVe1o0BDGTCBwgDl/oBoHWOMU+5wqwKPy913O2ZaHdz5Qc/4WsI4UVfEAexpEiNJEmzfDp74L9VMlnf2HCH1E2YyImRcX5bKH/1+gsEIv+r7b07n1QyDQoM4bBkIyfRyHgM/ULZbHmxnhYBBBRTtTJmciyQ78FeeWHZWaYpH7X2GBrmz4zyVw2rwKn4cVFUNMveE0mCeprVJC3irDw6Qr3ra/cLk9368bV4g0fBtJAT00F2MvyakpwuvDwyWuZUxJRNKazby5Ov7BC0PgVqgQ== 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=MoWgFH3bh/Uwyq9wV72bOt8bg3QwN+n0hwBFz4Qr2FKAX6+PlIQ1t1KnGTW3Cdl2A9Xuat2tBBDzx2e4IPogaDqT1wh6+mt6ZYf9sS+TwMFnO32sfqxY1lKwOrkUmVbU0sZzuz1eRDQlsNcbM9QLbWsWiCRADktKdAj5xwQvWjTCRQOgBTgvbmPGmQY3BXjoeKDSIxHkKk/+qDe4rujzMCZJcOeJT2atXDq5YINu4xzecEvW8bmoSrSbmgpRy5hxJlrfiEZ1ttSobPApYDhqjCVIdzKehv4QgdhwJiaDjYyYvTUUxyM6I8tvudA3Qko2PO3k16s4Beerx2rZ0TX1KQ== 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=VSjSz/pWlJaZgaeuOM77sZeEC1qhWc/FZ8lexx6kbr0ApiY0JCr3rIA9ukawe7Xkh6Ifc/BnSTX4PfCOvfdw2ulg4MmyXRSATgc1uDL4hor6ep/QlDzuksOu4OJOM8XQc3NfLF3VT5OyyRrh8ns6ipeoLaoLtS6uNIWaMWRYUME= Received: from SN4PR0501CA0046.namprd05.prod.outlook.com (2603:10b6:803:41::23) by IA0PR12MB8974.namprd12.prod.outlook.com (2603:10b6:208:488::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8137.18; Sat, 9 Nov 2024 04:43:01 +0000 Received: from SN1PEPF00026369.namprd02.prod.outlook.com (2603:10b6:803:41:cafe::cf) by SN4PR0501CA0046.outlook.office365.com (2603:10b6:803:41::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.11 via Frontend Transport; Sat, 9 Nov 2024 04:43: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 SN1PEPF00026369.mail.protection.outlook.com (10.167.241.134) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8137.17 via Frontend Transport; Sat, 9 Nov 2024 04:43: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; Fri, 8 Nov 2024 22:42:59 -0600 From: Mario Limonciello To: Hans de Goede , =?utf-8?q?Ilpo_J=C3=A4rvinen?= CC: "Rafael J . Wysocki" , Len Brown , Maximilian Luz , Lee Chun-Yi , "Shyam Sundar S K" , Corentin Chary , "Luke D . Jones" , Ike Panhc , Henrique de Moraes Holschuh , "Alexis Belmonte" , =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= , Ai Chao , Gergo Koteles , open list , "open list:ACPI" , "open list:MICROSOFT SURFACE PLATFORM PROFILE DRIVER" , "open list:THINKPAD ACPI EXTRAS DRIVER" , Mark Pearson , Matthew Schwartz , Mario Limonciello Subject: [PATCH v6 22/22] Documentation: Add documentation about class interface for platform profiles Date: Fri, 8 Nov 2024 22:41:51 -0600 Message-ID: <20241109044151.29804-23-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241109044151.29804-1-mario.limonciello@amd.com> References: <20241109044151.29804-1-mario.limonciello@amd.com> Precedence: bulk X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SN1PEPF00026369:EE_|IA0PR12MB8974:EE_ X-MS-Office365-Filtering-Correlation-Id: a2a6b79b-46fd-4b88-55ce-08dd0078fddb 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: Vn4gPE5YCOLR/tto7r0y26CsmogVlqpgTEciqZD3WJxRhh/7u4+ku/7nmNUWxXcE5pth8vFfDWhf6QSrZE2k4u9Kwe9ddWlov9BptU0BwEwC5SH3GSgWwc6fzThWhwPwymPc1YkcAO96zKGDfopcVKd5KSxSh4Y3mqvEeks0SD2zWRTuN+tUUEBPvJ9T4ARdnW31gt24F9fqpQ7FTeCuRfSVhoHWv/gBDYNE3hPT525wKfOEQMmBXW6+g8U4zVXlC82yII5OUuKqP8vYsUjt0yiyFq6l8DDTY8ysVaaOEVQ6hdiiWZ5sQBdXGOkBZymF8/wbAFnZlP1LEOo0gXcrVPuY9LibeDvQV/CUiRKkGej3AwYE49QxVJbMda/9/dNLyczQpw6+dI4yMZX6eczrjL9eUs9/CZNp6zwxwLTBokoMdGzFc5nZXdEiwZiqwwEHu4AADnarBpTbVJIWdLCJ897j6o2Ja1LlNwsXyteUaNCDTWVulPtg7h3pT5ICgoNutE/eQyEns4Q6cw/pHFEmkjE91qQxB3ckBrbbIckF2Sb0a/lwNAcIcc/WR9aI30MiHmZ6v+IhPv0BqTACZMdBkEJvVQChcHJRXw8xYCBxwaRzjXB/VWMRlog6zYIsnlvNYMJARdTVHKDInoUjnDeI4G9B5g5VrqPuJv1em9irTTuaT2K+1P12iNPxoMmnKjjArGE0IDfjKzF3l2c2HSCSksZBTmi78wloNsNpbuJdKkq9z1eIIVQJzf66btWayCEsjXbp68026+nDqid5ROrr1svdq9+LeriehY4XO7SyC+fY1JPfOpTNWYEDf1Z3P7Dw+FuqhddRGu4m5pStMoKb+lOzbHbTgJcQAKothcNIsQutO8QbU+uCF20S48o5bsd0CXOypmvrHwvyhDfRW1lpEjqnNozB+e4uRFGi8cmngUdBgM2zhWEanHuvn/kodz4ldr4sVkhzcCORUMxit78Ioc3glkPhu1hCtJTbyokb95xLr4f0dbXRMKBQIT6m8Ei2BpCnjhseID066HkgmNkESF6QNPKD9eLI0paaE5AnbGeLDvmR46lPmZpoN6qcrTRm4UTjbE2D3yvycdfvxVV5Ekjk46+GX8xQt3QHBEWP+fNnG0KmGeablKL8E5cMj+WFyeaj0l8tjyx0VwoqH7vaYoGhy8DHM0IdrNb8dvTNRnhjYafDhJlUCLHlwj3OfrcDlgyQdOz9o0wAHnMK2sXqu3VwK4J8vl6vYQz8utP+Fd5uAvjbNtazabRT4dUHBpF7xnvJhdl7aCIYwdCuoVJs+MYQsjjXtiQgRTwx39ryHdrLhSyXiMp7G+hMCqHCRE+LBOi5KeGpBd2IP63OV++SJ3qU0Zh7lrtq1Ovh2g7M6fqtPc+oOUhgATMKYzj1cPon9u3zfOgVW5TLpRhIGIg70Q== 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: 09 Nov 2024 04:43:01.0782 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a2a6b79b-46fd-4b88-55ce-08dd0078fddb 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: SN1PEPF00026369.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA0PR12MB8974 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 Reviewed-by: Armin Wolf --- 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/Documentation/ABI/testing/sysfs-platform_profile index baf1d125f9f83..125324ab53a96 100644 --- a/Documentation/ABI/testing/sysfs-platform_profile +++ b/Documentation/ABI/testing/sysfs-platform_profile @@ -33,3 +33,8 @@ Description: Reading this file gives the current selected profile for this source such as e.g. a hotkey triggered profile change handled either directly by the embedded-controller or fully handled inside the kernel. + + This file may also emit the string 'custom' to indicate + that multiple platform profiles drivers are in use but + have different values. This string can not be written to + this interface and is solely for informational purposes. diff --git a/Documentation/userspace-api/sysfs-platform_profile.rst b/Documentation/userspace-api/sysfs-platform_profile.rst index 4fccde2e45639..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 +======================= +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 the +same system. If the selected profile by individual drivers differs the +platform profile handler core will display the profile 'custom' to indicate +that the profiles are not the same. + +While the ``platform_profile`` attribute has the value ``custom``, writing a +common profile from ``platform_profile_choices`` to the platform_profile +attribute of the platform profile handler core will set the profile for all +drivers.