From patchwork Fri Dec 6 03:18:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 13896329 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2054.outbound.protection.outlook.com [40.107.94.54]) (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 5678434CDE; Fri, 6 Dec 2024 03:21:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.94.54 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733455317; cv=fail; b=T2iuVzOALL1cePe46c6QXPkeDtRqMHvFt+bokpPkmVojYt3tbdiCmunfQDch7ns6RWNTIKQwVibQ3PG5XmsVeD14ahKuP8vftV020vnt+DGztdlTEHNDrRcsdFikKMqYJiIBjg4wXbdpZTsvarOm/ch5LA2wsfBdfiCgJABDHoA= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733455317; c=relaxed/simple; bh=2GfJ/SjUIoNaiwHOnGXTGKoy8oQY1NZVgcne1nh591o=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=B+qXTMu528Pmj7raetFRgnSAZpo3V2BgCCv3PrvoBXswTAPaMXFQnohvnS9ZaAjv8J5G77zOu2FCBGhc9hVZsp0Ylu7PIT0m2xi62fcsYsQDGEfcnQ86h3w794uYRwcBpz4bXF8aX3F2U1oNs7dU0vrhN9vnSJTjUA32J3ZmhHs= 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=WrMsYvCW; arc=fail smtp.client-ip=40.107.94.54 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="WrMsYvCW" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=f6hp2EyvxQVQtkcIt48fcbJcxRXLY01Do1xWUeTZetWMKwukc0fEJ2HdSDdiiJLhRGdsETInQYniCoA9YRsrbH+VzcePBmotNrzA9QEVnQ2L70igYBjbRHfnugnrzU2bpcQ8kPmQMwaMrvBp4IJFDazTIrH/ztVPC0TziWgzOv1yRFl57kpKIV6ClfV7WPNT5iOsHqWcYnYXGiLh3P5hGIp8b/BLhPjV9BLC6Ukntn+1aNXhmYGh306nkg7G2CNvYBQ9i6o87IprNl/dg2LoD6qq1InXI/vN/elJWVnl6trN+XN6xT0MBG980+bcwGrD/+KtgKdwow93hEageJ9KQg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=DoQnBgUUl7eonCm8N3+8uE69DCAavYY1OE4Xsjy+5YI=; b=f6ERln2rqYpjJRhcwI+96zi15Z/tcd0+nFUa4zV2frxNBdjyqdkcDS5xKLFtIOh/3CwBelHUnjlOE9h9gqDtPO1bwfXaiouolYER4fSOiBrF2KrRknh7xVaU54nRGSO17g3AWx2Pivd0SbqLtuSU3tqCsMgGiwfvYG/zejI3MkjIip7mA0uIfX/Kg2Zi7HZgGkdrbwpf8FJc+brsPv0Jn25C4lXyJMySOBJnFQCkSInPPO4/3sCWoWfGcK3ogBBJnukuI13PNoA0qLlilcjLswCSztFAgVGOsMzC5vM4Je8LdeNGgNkC32lBCpWUGoTFSVXYaPjeScS+3dgqbWSawQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=redhat.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=DoQnBgUUl7eonCm8N3+8uE69DCAavYY1OE4Xsjy+5YI=; b=WrMsYvCW0BQt6BDGyB4pk7xyHHUgNde5qBI+jl8a4vya7w2bjyt6Ccyv6Z+MCQGT7pQncdk3+A3aJYu4nak0XP+qGrtVmevzumAN9rpv6wOM4yKrXt9KGTKQ8ZdFJzhvPH7w2H1cSB6mXxV+DlgDiQOiDsrNgHHKlv0w6ya+O7E= Received: from PH7P223CA0011.NAMP223.PROD.OUTLOOK.COM (2603:10b6:510:338::17) by LV2PR12MB5871.namprd12.prod.outlook.com (2603:10b6:408:174::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8207.19; Fri, 6 Dec 2024 03:21:50 +0000 Received: from SN1PEPF00036F3F.namprd05.prod.outlook.com (2603:10b6:510:338:cafe::9f) by PH7P223CA0011.outlook.office365.com (2603:10b6:510:338::17) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8230.11 via Frontend Transport; Fri, 6 Dec 2024 03:21: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 SN1PEPF00036F3F.mail.protection.outlook.com (10.167.248.23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8230.7 via Frontend Transport; Fri, 6 Dec 2024 03:21:50 +0000 Received: from AUS-P9-MLIMONCI.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Thu, 5 Dec 2024 21:20:36 -0600 From: Mario Limonciello To: Hans de Goede , =?utf-8?q?Ilpo_J=C3=A4rvinen?= CC: "Rafael J . Wysocki" , Len Brown , Maximilian Luz , Lee Chun-Yi , "Shyam Sundar S K" , Corentin Chary , "Luke D . Jones" , Ike Panhc , Henrique de Moraes Holschuh , "Alexis Belmonte" , =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= , Ai Chao , Gergo Koteles , open list , "open list:ACPI" , "open list:MICROSOFT SURFACE PLATFORM PROFILE DRIVER" , "open list:THINKPAD ACPI EXTRAS DRIVER" , Mark Pearson , Matthew Schwartz , Mario Limonciello , Armin Wolf Subject: [PATCH v10 01/22] ACPI: platform-profile: Add a name member to handlers Date: Thu, 5 Dec 2024 21:18:57 -0600 Message-ID: <20241206031918.1537-2-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241206031918.1537-1-mario.limonciello@amd.com> References: <20241206031918.1537-1-mario.limonciello@amd.com> Precedence: bulk X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SN1PEPF00036F3F:EE_|LV2PR12MB5871:EE_ X-MS-Office365-Filtering-Correlation-Id: 8aa6d9bd-a096-4a47-19c0-08dd15a51fdd X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|1800799024|36860700013|7416014|82310400026|7053199007; X-Microsoft-Antispam-Message-Info: =?utf-8?q?UNwHBwB/ojo1iJKLjEDGZK49KmI/ATb?= =?utf-8?q?rg++23TajXk9EP4/e3QV7al/LjMr2yBIfK2AgmnEIJMB0V2Q6WhUsOvEvAuvpA31d?= =?utf-8?q?5r9gNGEOn2u/X6rQ822GqHpqjlxU8AwDr+pX6hsLwddr4/yTj2YwFQMTrGaJH6bgz?= =?utf-8?q?bnKHmahl4zCIac0TTq6wcTYAAYDsydH1akTzh5Iw5C4LmUkP+r+gUfni/pC+NZn8a?= =?utf-8?q?qZf2fuzaexneyQfFHGKAymdqrpscm4gVGiD3KkTuxJ5LOKgFjWTw8El9pCJeIsQdH?= =?utf-8?q?5dmu5jD7V3SJCIpacyALjuI1Uz90nx9WaluyioRtPYa7Vrl/DPb/Yw6oV30utUoeh?= =?utf-8?q?oIqByTxG3SHU8AIb1g125eBhnU/Ktp1W3xvJ2g7BZ90Hkf+9i4qgqx5vB3CIhHs4n?= =?utf-8?q?JEPskdC6guauwmbAeAQmBwvOdV4dvGPmGBpp/91QsrX34AaGRqPjHUsvXU2FjMLaG?= =?utf-8?q?krUoRNzs9YgFencQEy8o7HWKFPP+5FZlCwF2Whbu3AfZ3IiR66gxhow38YacmH3WO?= =?utf-8?q?54FoZ2F7jJJVytM5dizLKL8mIWE56nZb0KBK+trw15OUtF7+ejBR4zNh2QwEDov7u?= =?utf-8?q?URr0lffPXY8nwHo8VpCiOl/fIMKbl1UFBDhZgJkzLVEvA9fb/TmSSFuoCxzbQt+2N?= =?utf-8?q?XNTjgVScct4ag9FJRiKMW+mglpjpJPrLQCji8NSxcRZ4MipsGCZS5uUMy3c0uRmCM?= =?utf-8?q?B9RFGVPaYc2Avz3JonuOQjAJffQRjS3XKSZQ/U1Eq2voUsCNZn2RJ7ljksfWzKVyM?= =?utf-8?q?gREJIbiFRWminoTk/qTDk1Bf+DnBXCuouioizGo6MtwEfrfswLj9OmIDGTOthNVIb?= =?utf-8?q?VkmiGIFTTX5SW3zVt6Z8TvEMV3RW+BoUAXSwPb5sJWJjOPyTtWrp8SRp/y5FEbO1i?= =?utf-8?q?NUa/MVBl0eF4J9VgZfLOS9HQWQZAJP8Or/y5k3UKwvDm39LlPb1a0kB5FMr8LNTkN?= =?utf-8?q?Jn8LGt42omj93YA3RyEaOrEgMQmV1C9RuziIRU0U718wN+nZMj6CdmvEk3vcsyZAT?= =?utf-8?q?Cn0FAOqcydFvez5Ln5+EwW63lfJ2MDSECd3tyJKlbB8PQehu9yAKvjfAsuCzDI2gC?= =?utf-8?q?ZOmvDhPDG/N5miuaAxzyUizye5J8X/NpLYvIK5LvE4fS8MXyA04PRyl7iOuMhccVj?= =?utf-8?q?x6iXvnpdSgXAFh6qNFNA9GxhkWqNFlebKpzv+llRr/MwUj0sbudUWWEmUB1FcJeMs?= =?utf-8?q?TBpWjMR/wboCqjfa0OVTySTyV56dbqIbIs2xfOIhDs1qy9zUbUAgxGuG7HMTW87jO?= =?utf-8?q?+82prQxI2KhzkMQ91v3cKp1GlDU9bfL72QJn1VTrFVf0CePVOBRL0y+CqxI9Ulg5o?= =?utf-8?q?Q6EzMiQM8Q5VzVJoLEJEUng6dLKKOlN0iDOVE0gW1l/3SlxpzVUUGbRynlZLytHtB?= =?utf-8?q?gXb7T6ALcDF?= 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)(1800799024)(36860700013)(7416014)(82310400026)(7053199007);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Dec 2024 03:21:50.3755 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 8aa6d9bd-a096-4a47-19c0-08dd15a51fdd 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: SN1PEPF00036F3F.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: LV2PR12MB5871 In order to prepare for allowing multiple handlers, introduce a name field that can be used to distinguish between different handlers. Tested-by: Mark Pearson Tested-by: Matthew Schwartz Reviewed-by: Hans de Goede Reviewed-by: Mark Pearson Reviewed-by: Maximilian Luz Reviewed-by: Ilpo Järvinen Reviewed-by: Armin Wolf Signed-off-by: Mario Limonciello --- drivers/platform/surface/surface_platform_profile.c | 1 + drivers/platform/x86/acer-wmi.c | 1 + drivers/platform/x86/amd/pmf/sps.c | 1 + drivers/platform/x86/asus-wmi.c | 1 + drivers/platform/x86/dell/alienware-wmi.c | 1 + drivers/platform/x86/dell/dell-pc.c | 1 + drivers/platform/x86/hp/hp-wmi.c | 1 + drivers/platform/x86/ideapad-laptop.c | 1 + drivers/platform/x86/inspur_platform_profile.c | 1 + drivers/platform/x86/thinkpad_acpi.c | 1 + include/linux/platform_profile.h | 1 + 11 files changed, 11 insertions(+) diff --git a/drivers/platform/surface/surface_platform_profile.c b/drivers/platform/surface/surface_platform_profile.c index 08db878f1d7d4..9d3e3f9458186 100644 --- a/drivers/platform/surface/surface_platform_profile.c +++ b/drivers/platform/surface/surface_platform_profile.c @@ -211,6 +211,7 @@ static int surface_platform_profile_probe(struct ssam_device *sdev) tpd->sdev = sdev; + tpd->handler.name = "Surface Platform Profile"; tpd->handler.profile_get = ssam_platform_profile_get; tpd->handler.profile_set = ssam_platform_profile_set; diff --git a/drivers/platform/x86/acer-wmi.c b/drivers/platform/x86/acer-wmi.c index d09baa3d3d902..53fbc9b4d3df7 100644 --- a/drivers/platform/x86/acer-wmi.c +++ b/drivers/platform/x86/acer-wmi.c @@ -1878,6 +1878,7 @@ static int acer_platform_profile_setup(void) if (quirks->predator_v4) { int err; + platform_profile_handler.name = "acer-wmi"; platform_profile_handler.profile_get = acer_predator_v4_platform_profile_get; platform_profile_handler.profile_set = diff --git a/drivers/platform/x86/amd/pmf/sps.c b/drivers/platform/x86/amd/pmf/sps.c index 92f7fb22277dc..e2d0cc92c4396 100644 --- a/drivers/platform/x86/amd/pmf/sps.c +++ b/drivers/platform/x86/amd/pmf/sps.c @@ -405,6 +405,7 @@ int amd_pmf_init_sps(struct amd_pmf_dev *dev) amd_pmf_set_sps_power_limits(dev); } + dev->pprof.name = "amd-pmf"; dev->pprof.profile_get = amd_pmf_profile_get; dev->pprof.profile_set = amd_pmf_profile_set; diff --git a/drivers/platform/x86/asus-wmi.c b/drivers/platform/x86/asus-wmi.c index ba8b6d028f9fe..a08dc936276b9 100644 --- a/drivers/platform/x86/asus-wmi.c +++ b/drivers/platform/x86/asus-wmi.c @@ -3876,6 +3876,7 @@ static int platform_profile_setup(struct asus_wmi *asus) dev_info(dev, "Using throttle_thermal_policy for platform_profile support\n"); + asus->platform_profile_handler.name = "asus-wmi"; asus->platform_profile_handler.profile_get = asus_wmi_platform_profile_get; asus->platform_profile_handler.profile_set = asus_wmi_platform_profile_set; diff --git a/drivers/platform/x86/dell/alienware-wmi.c b/drivers/platform/x86/dell/alienware-wmi.c index 77465ed9b449b..f88d898447511 100644 --- a/drivers/platform/x86/dell/alienware-wmi.c +++ b/drivers/platform/x86/dell/alienware-wmi.c @@ -1156,6 +1156,7 @@ static int create_thermal_profile(void) pp_handler.profile_get = thermal_profile_get; pp_handler.profile_set = thermal_profile_set; + pp_handler.name = "alienware-wmi"; return platform_profile_register(&pp_handler); } diff --git a/drivers/platform/x86/dell/dell-pc.c b/drivers/platform/x86/dell/dell-pc.c index 972385ca1990b..3cf79e55e3129 100644 --- a/drivers/platform/x86/dell/dell-pc.c +++ b/drivers/platform/x86/dell/dell-pc.c @@ -247,6 +247,7 @@ static int thermal_init(void) thermal_handler = kzalloc(sizeof(*thermal_handler), GFP_KERNEL); if (!thermal_handler) return -ENOMEM; + thermal_handler->name = "dell-pc"; thermal_handler->profile_get = thermal_platform_profile_get; thermal_handler->profile_set = thermal_platform_profile_set; diff --git a/drivers/platform/x86/hp/hp-wmi.c b/drivers/platform/x86/hp/hp-wmi.c index 81ccc96ffe40a..26cac73caf2b9 100644 --- a/drivers/platform/x86/hp/hp-wmi.c +++ b/drivers/platform/x86/hp/hp-wmi.c @@ -1624,6 +1624,7 @@ static int thermal_profile_setup(void) set_bit(PLATFORM_PROFILE_COOL, platform_profile_handler.choices); } + platform_profile_handler.name = "hp-wmi"; set_bit(PLATFORM_PROFILE_BALANCED, platform_profile_handler.choices); set_bit(PLATFORM_PROFILE_PERFORMANCE, platform_profile_handler.choices); diff --git a/drivers/platform/x86/ideapad-laptop.c b/drivers/platform/x86/ideapad-laptop.c index 5d2c1f0d1e9fb..cbdc965eeb248 100644 --- a/drivers/platform/x86/ideapad-laptop.c +++ b/drivers/platform/x86/ideapad-laptop.c @@ -1102,6 +1102,7 @@ static int ideapad_dytc_profile_init(struct ideapad_private *priv) mutex_init(&priv->dytc->mutex); + priv->dytc->pprof.name = "ideapad-laptop"; priv->dytc->priv = priv; priv->dytc->pprof.profile_get = dytc_profile_get; priv->dytc->pprof.profile_set = dytc_profile_set; diff --git a/drivers/platform/x86/inspur_platform_profile.c b/drivers/platform/x86/inspur_platform_profile.c index 8440defa67886..03da2c8cf6789 100644 --- a/drivers/platform/x86/inspur_platform_profile.c +++ b/drivers/platform/x86/inspur_platform_profile.c @@ -177,6 +177,7 @@ static int inspur_wmi_probe(struct wmi_device *wdev, const void *context) priv->wdev = wdev; dev_set_drvdata(&wdev->dev, priv); + priv->handler.name = "inspur-wmi"; priv->handler.profile_get = inspur_platform_profile_get; priv->handler.profile_set = inspur_platform_profile_set; diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c index 6371a9f765c13..0e03c41e028d4 100644 --- a/drivers/platform/x86/thinkpad_acpi.c +++ b/drivers/platform/x86/thinkpad_acpi.c @@ -10571,6 +10571,7 @@ static void dytc_profile_refresh(void) } static struct platform_profile_handler dytc_profile = { + .name = "thinkpad-acpi", .profile_get = dytc_profile_get, .profile_set = dytc_profile_set, }; diff --git a/include/linux/platform_profile.h b/include/linux/platform_profile.h index f5492ed413f36..6fa988e417428 100644 --- a/include/linux/platform_profile.h +++ b/include/linux/platform_profile.h @@ -27,6 +27,7 @@ enum platform_profile_option { }; struct platform_profile_handler { + const char *name; unsigned long choices[BITS_TO_LONGS(PLATFORM_PROFILE_LAST)]; int (*profile_get)(struct platform_profile_handler *pprof, enum platform_profile_option *profile); From patchwork Fri Dec 6 03:18:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 13896330 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2080.outbound.protection.outlook.com [40.107.93.80]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 149CA1865E2; Fri, 6 Dec 2024 03:22:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.93.80 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733455346; cv=fail; b=sizvDSVn5HkbvcqFTRTxp4nyySr3UXHmbV33kI0ejoUC1jFwDRmYr3R7XqsnsVEv3A7Q0n1kvdBeLTGMjgkx2R/4dDDrSSKeskGmhPDCxIra8pS1yAxOcz/hVeIwZ4bMSlC3aqXnLK5vlRPS8vYd4m1lvlMVGbI9Ta5DSSBtbus= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733455346; c=relaxed/simple; bh=EpBLXuqVtx8vhBhviCCJcSbHzG0FzrqJkf8El0ijwqk=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=sWfu4uuUFDCM/9TMIoOB4c5FffARE22eFWkMg47qqD1dky5nB8ashfPAhQa+47BhT5k3JacQBTipNQmD8U0NXxRZZfWSFZkLLXg1qWk/8eHe6zISG/kQklpIRTOvSPsnWljVcQBH4WtlGY6tPLU0Z/N7i4Lv/n6M61oUAHXJSbI= 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=TZBFGIlX; arc=fail smtp.client-ip=40.107.93.80 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="TZBFGIlX" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=tqQKy2751wvhiZazDzFUfAvtJgEz2rteU4bTH8IJaOHawYG86KIlx9VaB0unMZRTb1SD9ffyB35WgdWc1JKs15tfN/qyJQIEaERyHPGQozy5FDhqN3SmYpWuvWtE6TXr6Z7vu3DsebeshB4Sq3Wa25MEJ3H7HDn4CPBHlQomVu2xYHmq5cjzxfOsipq1eCNO1B1Xp23D7sK/QchQlZ0vIFnDg0hcZm5nRxvJ5Xq/v6HRnR9EngOn9PaglnWRWEOGlOYf21CjeU/fhb8dB9EjDnwsSMfYlSQG8C9kUn9A83m7CHUBnha497jRhvi8rqEOuyzwHL3EtizuN/+IsiQHnw== 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=XLN3wK+RpjaYWFJyskt2+vP6DlyrdcUDBhvHh/FG3y4=; b=aok3f/YrPff8/p/YeetdubMK8DALVduxViMLscf87GlNEEIsdZRiMMB4bQdKjLA/vsOtrP/sRZLgfkT6bf8c4v4grjHdpWn6Z4JoIsHCNnkuY1F2fX9ZoMH0nshFOi0g9jqF517hb9h+jAlwRbQvRmWhCsCTaziRFw8kI14aUq1dTBu71Sghrxa0MZH9rP2g78gcQZhRY/C5OtQtqdoojnECBtMWOjXim4SBrKQJ7YvinBwnDcyOPI9ik5Y02dzNxKBuE9gKQk6MR+7SSUXqopm2B/do+jDLdJtpyT2grpzZ0FsqgulrH+K9nIHwVituFhXt8gNGnBsDcM/XP+7p7A== 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=XLN3wK+RpjaYWFJyskt2+vP6DlyrdcUDBhvHh/FG3y4=; b=TZBFGIlXh/C4geHpTmCq6niSHni/ZQ1gbjgUZ+bYaIfRAQam7EWjnAh8phHOYsedSbPBcBe+TJlXmAFkaoi96Ch9QT1yqkGpmM4RV/kLXtCU1gW7sVj0g7NCoHykVQMVb13qzwo2i0aFkOqPJtg44I720X+h3YR59qTivMy2Tns= Received: from PH7P223CA0004.NAMP223.PROD.OUTLOOK.COM (2603:10b6:510:338::12) by PH0PR12MB7908.namprd12.prod.outlook.com (2603:10b6:510:28e::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8230.11; Fri, 6 Dec 2024 03:22:20 +0000 Received: from SN1PEPF00036F3F.namprd05.prod.outlook.com (2603:10b6:510:338:cafe::f9) by PH7P223CA0004.outlook.office365.com (2603:10b6:510:338::12) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8230.12 via Frontend Transport; Fri, 6 Dec 2024 03:22: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 SN1PEPF00036F3F.mail.protection.outlook.com (10.167.248.23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8230.7 via Frontend Transport; Fri, 6 Dec 2024 03:22: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; Thu, 5 Dec 2024 21:20:43 -0600 From: Mario Limonciello To: Hans de Goede , =?utf-8?q?Ilpo_J=C3=A4rvinen?= CC: "Rafael J . Wysocki" , Len Brown , Maximilian Luz , Lee Chun-Yi , "Shyam Sundar S K" , Corentin Chary , "Luke D . Jones" , Ike Panhc , Henrique de Moraes Holschuh , "Alexis Belmonte" , =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= , Ai Chao , Gergo Koteles , open list , "open list:ACPI" , "open list:MICROSOFT SURFACE PLATFORM PROFILE DRIVER" , "open list:THINKPAD ACPI EXTRAS DRIVER" , Mark Pearson , Matthew Schwartz , Mario Limonciello , Armin Wolf Subject: [PATCH v10 02/22] platform/x86/dell: dell-pc: Create platform device Date: Thu, 5 Dec 2024 21:18:58 -0600 Message-ID: <20241206031918.1537-3-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241206031918.1537-1-mario.limonciello@amd.com> References: <20241206031918.1537-1-mario.limonciello@amd.com> Precedence: bulk X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SN1PEPF00036F3F:EE_|PH0PR12MB7908:EE_ X-MS-Office365-Filtering-Correlation-Id: be8e1358-533b-4c1a-47ca-08dd15a5316b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700013|82310400026|1800799024|376014|7416014; X-Microsoft-Antispam-Message-Info: =?utf-8?q?EDqM0C0nYnoDSu3h0EFih7iddGFy2vC?= =?utf-8?q?wCKwPGpB7axLJEZVKoLsmUNtlbpVIGfkSAom1imTd75DJcyvosDWHGmc/b4x4c1o3?= =?utf-8?q?fanzQbaX1LSygq8SRoiiv+43GNKEDfGRhVIgD1VjjQaEkpTUJs/AydkW1yW1o1WJU?= =?utf-8?q?UmI6cIQR5YVIeeddkdpMdHLwv4BxOW6HUex1ZKESp32EhiHVX8C/L9QlgvLCbZ0zI?= =?utf-8?q?Jj9umHJ1n/cCdBwY5o66D4/e92WYKKomz71Z1Ided20Mv6uEo3fNSoj4atMn8uTrV?= =?utf-8?q?WmzYbJEnJUX+krFEYArKXbJGL9dBYsZsD4rmTpwrWvTSasMjmtNKu9IvQT86taAU9?= =?utf-8?q?GatS49WxaTgx8ClSvGzsL1GSOqJ5eVFKj+32vN8H++TZr/fSQs8eg5dSomxcDBtqB?= =?utf-8?q?3TsA3H9ImbtIB1rnfLyNAQbv34TuBNN7BjYtRUSMdKRno+XsFg9x0TACtQuja3EZW?= =?utf-8?q?9Qg9xMCZdbNb7uUr4kOTKS56o4nAIKNijP9HqVidGXYZpUfVJd9fn+wKGDyq7GL9Z?= =?utf-8?q?RZ4zGU3JqmaUKoS6K3y5fNQMZ5Un8itz8cRLWubpLXJaY0B7AQbOyTkrIX1C1VdaZ?= =?utf-8?q?DmXjxO1MLEseVOOSMLSOrtd77leEI33nkfj7FvU6TTB18PtHQ+4h/FP30GHiN9utb?= =?utf-8?q?Da3sSyZ4y0SgtrpoeHHMUQNidOd+PtFdzhwwV5mkWZhjzrZOJV897VdnXXrTdBsMn?= =?utf-8?q?aSNogP7H8h7l0lf5ecCltltdk9JF1QkcZYwY/4on3XN/yEO1mxP7F5UCiFzd6HoBU?= =?utf-8?q?mIZzUkLRQS+RIyoW8XMc6y9D6uVUSb8qv1yfSlWl8H2Q0PHBJ6XIT3RXnGoiute5o?= =?utf-8?q?I0ddNbY6qZ5yl3pa0gbMyOi/9QRT79ai174ztiqPo9PRnwW/NdcU/nbGxWdgXsrfQ?= =?utf-8?q?Y87Y7JNzAZ+GLhPdadsZ7aDSLJzDOcuOHOcGB96pSlMzPUHapJSXL5gmtawIaX+E5?= =?utf-8?q?Aj/bMaALWM0nV2CkukE0vpsY3UbfHe3UXhGwm9A7zPkm/C7o7s1TsLF0w+ciZz05O?= =?utf-8?q?z1kBtHcic4QLuNJrhj3piEGRpEWICB9riEMPVdWdTRpQgtNbpXZGwJy30r/KfIvRm?= =?utf-8?q?9vRoZaNtF5lCi1R0CX+9CngvMtmA0rkvInbC3TeV+19obYsUYOoTyaZKGtS6BrDwk?= =?utf-8?q?pWqjcUMal7QszmE2TE2ztxnRaaogTv6LnkE2/0W+wJBFUVjZy9rAr4VVX+EHEOoZ1?= =?utf-8?q?y+fRg9phgWVpXvUGzpwsuROQza34gzAK68bsdlgeWYWOdDaTC6F/ExnMWDdKq/7bq?= =?utf-8?q?WXpkTIp3IgSfat1rSvDvpueIqqARgP1QrsUUVgax5yh9TxunYypkhGKT87J2kvwu5?= =?utf-8?q?xk3MoJjcCPKTHU+L+mbqlkAFkMHNF8MCnXI990BGxs2oC/Vk6Xf5d6d+iprO2SaFt?= =?utf-8?q?3jspliuyL8B?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(36860700013)(82310400026)(1800799024)(376014)(7416014);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Dec 2024 03:22:19.8442 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: be8e1358-533b-4c1a-47ca-08dd15a5316b 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: SN1PEPF00036F3F.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR12MB7908 In order to have a device for the platform profile core to reference create a platform device for dell-pc. While doing this change the memory allocation for the thermal handler to be device managed to follow the lifecycle of that device. Reviewed-by: Armin Wolf Tested-by: Mark Pearson Reviewed-by: Ilpo Järvinen Reviewed-by: Mark Pearson Signed-off-by: Mario Limonciello --- drivers/platform/x86/dell/dell-pc.c | 34 ++++++++++++++++++++--------- 1 file changed, 24 insertions(+), 10 deletions(-) diff --git a/drivers/platform/x86/dell/dell-pc.c b/drivers/platform/x86/dell/dell-pc.c index 3cf79e55e3129..c0dbbd3b23065 100644 --- a/drivers/platform/x86/dell/dell-pc.c +++ b/drivers/platform/x86/dell/dell-pc.c @@ -18,10 +18,13 @@ #include #include #include +#include #include #include "dell-smbios.h" +static struct platform_device *platform_device; + static const struct dmi_system_id dell_device_table[] __initconst = { { .ident = "Dell Inc.", @@ -244,9 +247,15 @@ static int thermal_init(void) if (!supported_modes) return 0; - thermal_handler = kzalloc(sizeof(*thermal_handler), GFP_KERNEL); - if (!thermal_handler) - return -ENOMEM; + platform_device = platform_device_register_simple("dell-pc", PLATFORM_DEVID_NONE, NULL, 0); + if (IS_ERR(platform_device)) + return PTR_ERR(platform_device); + + thermal_handler = devm_kzalloc(&platform_device->dev, sizeof(*thermal_handler), GFP_KERNEL); + if (!thermal_handler) { + ret = -ENOMEM; + goto cleanup_platform_device; + } thermal_handler->name = "dell-pc"; thermal_handler->profile_get = thermal_platform_profile_get; thermal_handler->profile_set = thermal_platform_profile_set; @@ -262,20 +271,25 @@ static int thermal_init(void) /* Clean up if failed */ ret = platform_profile_register(thermal_handler); - if (ret) { - kfree(thermal_handler); - thermal_handler = NULL; - } + if (ret) + goto cleanup_thermal_handler; + + return 0; + +cleanup_thermal_handler: + thermal_handler = NULL; + +cleanup_platform_device: + platform_device_unregister(platform_device); return ret; } static void thermal_cleanup(void) { - if (thermal_handler) { + if (thermal_handler) platform_profile_remove(); - kfree(thermal_handler); - } + platform_device_unregister(platform_device); } static int __init dell_init(void) From patchwork Fri Dec 6 03:18:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 13896331 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 D6C5118DF86; Fri, 6 Dec 2024 03:23:00 +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=1733455382; cv=fail; b=e1gdulCVsHQZZpieDAmUrvfuephrlkj6WQNUEQrdL+ADbnxgGO7TDERnlnJSFym5ujIeij1VRdYFncHjXR9vr/dPT6fcwpyR0jmFwTI24O1qttHw+eVHv2uV6+xboGckmOFiKHOUefDdZZFawSh75TYYzfT8cJxDk6sDOSWwLVg= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733455382; c=relaxed/simple; bh=AhcQq/qoPABsrY8CsoC/m8lNX7jnLQEA1NZQjsy9xjY=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=ChFqjR8WYSNfQV0OYsPJOTqjJfNfx+DgARicNbZBKY4/EFKdfgCs7gpIhq78LrP/y/N2w0Sx8OtIg66hi4HTvEHVzWTvxBprpDp+46uNX/ZAPeLcfvhQUfo9UJGhn36DBf88RKPNoSMY3NcUBIubMgNE4C/MJxWQlc0CkEND3kQ= 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=HNQNisG9; 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="HNQNisG9" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=ZV0jExH0XvTVIT0rCtIzxKiKiEd15kcOwBwyqHAW/zCe5NqANJDx3etwXB9BN+1+cOfv427C3pVmS78+lOzw/3CtzRxbAoBujh5lyBcgXEqhSkQXRN6IlPA+P4KLhoOPvSVnM59Nf7/9AgHdaF/rjLIqMSGkMWnX3LfkvaT9Pqx7PgCLM4ve8bh3/YXGTubUo7anI+naUEsCdoCLqWJ6LzZFwfyjLfOalTr2E7fK7V8At1qLjVm6yEcerISK8G1nZc+54vFmdVdYTX504pIqzF10nup684Vpvt4lyYMUBOc8KpyU5VCMEQrsz4HAILRb8zC7i1yLsdLJ6QNjNoCiXg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=lnx4s0xfHI8MWMTVeFUsyesOxs3tBhsZmpwtkndEF7o=; b=p7yEB3Wyt4aOFBXgQiGWjQK4Mzj1kah1vWDJiQaPieFD52aFyI1eaPuZbVGpIRBaw4s0YHNJ67bPS5VrczDWbqwppK6eSuTEkQwgAit4dc+zYSTOY7GXKwptaPHgiiiZb4AYNoKRVJApzHuMk9WXgQjcgSoFPB+Vl2S0Xu+q0ZLmbSzV7u78oyc4d29lKBIE/OInoldN1MpBjHGCWrkjHKI/INuY0TFg+nrw+ogDAljlcqiwY0AwelZcyqBvtIaxARqWNf1kUnVsoFs65xfxRQEBzp82O6qw/nlFw6MaZpAacA5gl61UuaPXBYQkMayZvfYqE6xmDKaSGYojO2MQfg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=redhat.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=lnx4s0xfHI8MWMTVeFUsyesOxs3tBhsZmpwtkndEF7o=; b=HNQNisG9xKSKBVrWjEdfHFlhi1VBox4j49pdsbA3vItMSH8qzZ79r4A1onee8menzj32y42bRLYac8bv0t9ydv1TINFzL9Og3jqKq7a/X2g8BkO3IRYfgqgPrQw6oTjNXyDHTbSre4igifTYH3cUPAn2GZKigOn4jsAS8AJN8b4= Received: from MN2PR11CA0025.namprd11.prod.outlook.com (2603:10b6:208:23b::30) by DS0PR12MB8504.namprd12.prod.outlook.com (2603:10b6:8:155::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8207.22; Fri, 6 Dec 2024 03:22:53 +0000 Received: from BL6PEPF00020E64.namprd04.prod.outlook.com (2603:10b6:208:23b:cafe::86) by MN2PR11CA0025.outlook.office365.com (2603:10b6:208:23b::30) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8230.12 via Frontend Transport; Fri, 6 Dec 2024 03:22: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 BL6PEPF00020E64.mail.protection.outlook.com (10.167.249.25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8230.7 via Frontend Transport; Fri, 6 Dec 2024 03:22:52 +0000 Received: from AUS-P9-MLIMONCI.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Thu, 5 Dec 2024 21:22: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 v10 03/22] ACPI: platform_profile: Add device pointer into platform profile handler Date: Thu, 5 Dec 2024 21:18:59 -0600 Message-ID: <20241206031918.1537-4-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241206031918.1537-1-mario.limonciello@amd.com> References: <20241206031918.1537-1-mario.limonciello@amd.com> Precedence: bulk X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL6PEPF00020E64:EE_|DS0PR12MB8504:EE_ X-MS-Office365-Filtering-Correlation-Id: edd8686d-71cc-4981-8d0d-08dd15a544e2 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|82310400026|36860700013|1800799024|376014|7416014; X-Microsoft-Antispam-Message-Info: =?utf-8?q?19RzURIUbm+rzFoVPl0JadHqYENXq0t?= =?utf-8?q?LCsic3H6I088QSwmcmWMYw/HEVGlZ7qJQNvrIuYv6YN9bY4mHCUH6AUENL1RbPbvw?= =?utf-8?q?mKu+x5Bb/TjTD13GnzG5GlAOq3c55IF0PCt1XcQQFm9Oy/wgI7R2hGtR5y9RUQsM9?= =?utf-8?q?0p2UtKOglXJXvXYzua8D2Ft+FTjHHYddBl2cLTOQJikIarcA/25POcDAqk3tIKMNL?= =?utf-8?q?Lrt6bYfLq6VfjcUlf/o96WI1VoRaDefxp3CHdUjxsgMaVY7bffbd6m2bOq3yb5wZ6?= =?utf-8?q?YQSuNC2lIvO8nk/6va/BWpT79nbJXuDetRTaW4fFD8ZTqIIODIdDa7xz3/+KMCPgy?= =?utf-8?q?hr8YJy/4wze+IUcuAbqaY0iKcvkodwySwXZd+UC3wu3nq0fAPgrY9ZRO8NnRJ2RNc?= =?utf-8?q?HsDBo4CT5ri07V7JeX3IdfkVElABdSqhwMZsbGogoAnqfRG1AxIRz+BPltyqoR55i?= =?utf-8?q?GR6OLrdGMyDpSqV7LCXh4GtXW3mt/byjHScnYC+0llsDaDbNPICcuGUegabk2j81g?= =?utf-8?q?fCoeYE8PsWI3OSCXBIjwdE1mnr7qPcl+cIrMb+t01W3ryVFitOM1tbI03J/qjVzQl?= =?utf-8?q?na9cg+rJrwydcQENpnacLucECbX5dQa0DvP+bKTu3lDRyn+7g2u1xr0fj2DZ4Z8gW?= =?utf-8?q?xK4JG7dY6anGqIbkKKRspTfDH3Re4v6oPi6W2wtBUP3cHcg65d4THyT0TwuMv37V+?= =?utf-8?q?Gh5WL1xx22IRlcnRniGFXc9yK+7GpwGKIiJa3So+D4FbdUjY5Q90M/6mGCht+acDH?= =?utf-8?q?juQ7FQJk/Ym5hjHHsw6W9KHX28G+ClDuQ7dj2qp9h9KRIigHY2qKF+svbgK8Kk8M+?= =?utf-8?q?37nM9OUZ/+/OtFMszIWBSCxJVnqizAqiWXWNWYZD+jovZGdy4ndg67tTL2NT2ecuw?= =?utf-8?q?5yEgWJ0os2OgRyNyZu2zp18cbt9dTGIAVZnQRlxCU1uqHrxXXN9v9VeOh570zvKQF?= =?utf-8?q?zbhmfla/yGVO548IkjrPFndBRGDiTKZ86dZ2qjFzj7WWMieJO8y8+ND9dY1etf7ld?= =?utf-8?q?SbGasmr+MjSpK4RDqdBIInXLpe7QKmVh1vTVXFX/I73Ni2vKGXtaqtP1WuQ0IEirY?= =?utf-8?q?0m6CX2Rf22EMH/mPrISRBV/PCNyp+vd68iQsnUKQZ00yCYgWs6FhxPBnDIr/EYYI6?= =?utf-8?q?KSoTkODOPlA4oThqx1buJAv3cpRTAsVg8iDi358ySL3vkqa+O5lJKFNmavV8ttvDa?= =?utf-8?q?A9af0hSyY9naukzfky3besuSgGKBQRdjgmVyodvO4PJ59NDlHbaK2IkuYX//GmHzb?= =?utf-8?q?UxCk9pyljLAkTgGKMO/EdjlhP3ozIYF3rCY94jmBmKq5oUThaN46gLvfug61cq+QT?= =?utf-8?q?I8ows6eecUCAwyWQX9mtv2+k95FdkCvDrvKZz8hH1DVK4BBG8sGwrerO2nZfmYegR?= =?utf-8?q?buQBwE7QOYZ?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(82310400026)(36860700013)(1800799024)(376014)(7416014);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Dec 2024 03:22:52.5338 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: edd8686d-71cc-4981-8d0d-08dd15a544e2 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: BL6PEPF00020E64.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR12MB8504 In order to let platform profile handlers manage platform profile for their driver the core code will need a pointer to the device. Add this to the structure and use it in the trivial driver cases. Reviewed-by: Armin Wolf Reviewed-by: Ilpo Järvinen Reviewed-by: Maximilian Luz Reviewed-by: Mark Pearson Signed-off-by: Mario Limonciello --- drivers/platform/surface/surface_platform_profile.c | 1 + drivers/platform/x86/acer-wmi.c | 5 +++-- drivers/platform/x86/amd/pmf/sps.c | 1 + drivers/platform/x86/asus-wmi.c | 1 + drivers/platform/x86/dell/alienware-wmi.c | 5 +++-- drivers/platform/x86/dell/dell-pc.c | 1 + drivers/platform/x86/hp/hp-wmi.c | 5 +++-- drivers/platform/x86/ideapad-laptop.c | 1 + drivers/platform/x86/inspur_platform_profile.c | 1 + drivers/platform/x86/thinkpad_acpi.c | 1 + include/linux/platform_profile.h | 1 + 11 files changed, 17 insertions(+), 6 deletions(-) diff --git a/drivers/platform/surface/surface_platform_profile.c b/drivers/platform/surface/surface_platform_profile.c index 9d3e3f9458186..b73cfdd920c66 100644 --- a/drivers/platform/surface/surface_platform_profile.c +++ b/drivers/platform/surface/surface_platform_profile.c @@ -212,6 +212,7 @@ static int surface_platform_profile_probe(struct ssam_device *sdev) tpd->sdev = sdev; tpd->handler.name = "Surface Platform Profile"; + tpd->handler.dev = &sdev->dev; tpd->handler.profile_get = ssam_platform_profile_get; tpd->handler.profile_set = ssam_platform_profile_set; diff --git a/drivers/platform/x86/acer-wmi.c b/drivers/platform/x86/acer-wmi.c index 53fbc9b4d3df7..aca4a5746bee1 100644 --- a/drivers/platform/x86/acer-wmi.c +++ b/drivers/platform/x86/acer-wmi.c @@ -1873,12 +1873,13 @@ acer_predator_v4_platform_profile_set(struct platform_profile_handler *pprof, return 0; } -static int acer_platform_profile_setup(void) +static int acer_platform_profile_setup(struct platform_device *device) { if (quirks->predator_v4) { int err; platform_profile_handler.name = "acer-wmi"; + platform_profile_handler.dev = &device->dev; platform_profile_handler.profile_get = acer_predator_v4_platform_profile_get; platform_profile_handler.profile_set = @@ -2531,7 +2532,7 @@ static int acer_platform_probe(struct platform_device *device) goto error_rfkill; if (has_cap(ACER_CAP_PLATFORM_PROFILE)) { - err = acer_platform_profile_setup(); + err = acer_platform_profile_setup(device); if (err) goto error_platform_profile; } diff --git a/drivers/platform/x86/amd/pmf/sps.c b/drivers/platform/x86/amd/pmf/sps.c index e2d0cc92c4396..1b94af7c0e0c4 100644 --- a/drivers/platform/x86/amd/pmf/sps.c +++ b/drivers/platform/x86/amd/pmf/sps.c @@ -406,6 +406,7 @@ int amd_pmf_init_sps(struct amd_pmf_dev *dev) } dev->pprof.name = "amd-pmf"; + dev->pprof.dev = dev->dev; dev->pprof.profile_get = amd_pmf_profile_get; dev->pprof.profile_set = amd_pmf_profile_set; diff --git a/drivers/platform/x86/asus-wmi.c b/drivers/platform/x86/asus-wmi.c index a08dc936276b9..14d84cad01b49 100644 --- a/drivers/platform/x86/asus-wmi.c +++ b/drivers/platform/x86/asus-wmi.c @@ -3877,6 +3877,7 @@ static int platform_profile_setup(struct asus_wmi *asus) dev_info(dev, "Using throttle_thermal_policy for platform_profile support\n"); asus->platform_profile_handler.name = "asus-wmi"; + asus->platform_profile_handler.dev = dev; asus->platform_profile_handler.profile_get = asus_wmi_platform_profile_get; asus->platform_profile_handler.profile_set = asus_wmi_platform_profile_set; diff --git a/drivers/platform/x86/dell/alienware-wmi.c b/drivers/platform/x86/dell/alienware-wmi.c index f88d898447511..78aac76132788 100644 --- a/drivers/platform/x86/dell/alienware-wmi.c +++ b/drivers/platform/x86/dell/alienware-wmi.c @@ -1108,7 +1108,7 @@ static int thermal_profile_set(struct platform_profile_handler *pprof, return wmax_thermal_control(supported_thermal_profiles[profile]); } -static int create_thermal_profile(void) +static int create_thermal_profile(struct platform_device *platform_device) { u32 out_data; u8 sys_desc[4]; @@ -1157,6 +1157,7 @@ static int create_thermal_profile(void) pp_handler.profile_get = thermal_profile_get; pp_handler.profile_set = thermal_profile_set; pp_handler.name = "alienware-wmi"; + pp_handler.dev = &platform_device->dev; return platform_profile_register(&pp_handler); } @@ -1225,7 +1226,7 @@ static int __init alienware_wmi_init(void) } if (quirks->thermal) { - ret = create_thermal_profile(); + ret = create_thermal_profile(platform_device); if (ret) goto fail_prep_thermal_profile; } diff --git a/drivers/platform/x86/dell/dell-pc.c b/drivers/platform/x86/dell/dell-pc.c index c0dbbd3b23065..b9a6dd7b321d9 100644 --- a/drivers/platform/x86/dell/dell-pc.c +++ b/drivers/platform/x86/dell/dell-pc.c @@ -257,6 +257,7 @@ static int thermal_init(void) goto cleanup_platform_device; } thermal_handler->name = "dell-pc"; + thermal_handler->dev = &platform_device->dev; thermal_handler->profile_get = thermal_platform_profile_get; thermal_handler->profile_set = thermal_platform_profile_set; diff --git a/drivers/platform/x86/hp/hp-wmi.c b/drivers/platform/x86/hp/hp-wmi.c index 26cac73caf2b9..ffb09799142bc 100644 --- a/drivers/platform/x86/hp/hp-wmi.c +++ b/drivers/platform/x86/hp/hp-wmi.c @@ -1565,7 +1565,7 @@ static inline void omen_unregister_powersource_event_handler(void) unregister_acpi_notifier(&platform_power_source_nb); } -static int thermal_profile_setup(void) +static int thermal_profile_setup(struct platform_device *device) { int err, tp; @@ -1625,6 +1625,7 @@ static int thermal_profile_setup(void) } platform_profile_handler.name = "hp-wmi"; + platform_profile_handler.dev = &device->dev; set_bit(PLATFORM_PROFILE_BALANCED, platform_profile_handler.choices); set_bit(PLATFORM_PROFILE_PERFORMANCE, platform_profile_handler.choices); @@ -1664,7 +1665,7 @@ static int __init hp_wmi_bios_setup(struct platform_device *device) if (err < 0) return err; - thermal_profile_setup(); + thermal_profile_setup(device); return 0; } diff --git a/drivers/platform/x86/ideapad-laptop.c b/drivers/platform/x86/ideapad-laptop.c index cbdc965eeb248..b6586c473ba91 100644 --- a/drivers/platform/x86/ideapad-laptop.c +++ b/drivers/platform/x86/ideapad-laptop.c @@ -1103,6 +1103,7 @@ static int ideapad_dytc_profile_init(struct ideapad_private *priv) mutex_init(&priv->dytc->mutex); priv->dytc->pprof.name = "ideapad-laptop"; + priv->dytc->pprof.dev = &priv->platform_device->dev; priv->dytc->priv = priv; priv->dytc->pprof.profile_get = dytc_profile_get; priv->dytc->pprof.profile_set = dytc_profile_set; diff --git a/drivers/platform/x86/inspur_platform_profile.c b/drivers/platform/x86/inspur_platform_profile.c index 03da2c8cf6789..5a53949bbbf5f 100644 --- a/drivers/platform/x86/inspur_platform_profile.c +++ b/drivers/platform/x86/inspur_platform_profile.c @@ -178,6 +178,7 @@ static int inspur_wmi_probe(struct wmi_device *wdev, const void *context) dev_set_drvdata(&wdev->dev, priv); priv->handler.name = "inspur-wmi"; + priv->handler.dev = &wdev->dev; priv->handler.profile_get = inspur_platform_profile_get; priv->handler.profile_set = inspur_platform_profile_set; diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c index 0e03c41e028d4..58af9020382c1 100644 --- a/drivers/platform/x86/thinkpad_acpi.c +++ b/drivers/platform/x86/thinkpad_acpi.c @@ -10638,6 +10638,7 @@ static int tpacpi_dytc_profile_init(struct ibm_init_struct *iibm) dbg_printk(TPACPI_DBG_INIT, "DYTC version %d: thermal mode available\n", dytc_version); + dytc_profile.dev = &tpacpi_pdev->dev; /* Create platform_profile structure and register */ err = platform_profile_register(&dytc_profile); /* diff --git a/include/linux/platform_profile.h b/include/linux/platform_profile.h index 6fa988e417428..daec6b9bad81f 100644 --- a/include/linux/platform_profile.h +++ b/include/linux/platform_profile.h @@ -28,6 +28,7 @@ enum platform_profile_option { struct platform_profile_handler { const char *name; + struct device *dev; unsigned long choices[BITS_TO_LONGS(PLATFORM_PROFILE_LAST)]; int (*profile_get)(struct platform_profile_handler *pprof, enum platform_profile_option *profile); From patchwork Fri Dec 6 03:19:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 13896332 Received: from NAM02-SN1-obe.outbound.protection.outlook.com (mail-sn1nam02on2072.outbound.protection.outlook.com [40.107.96.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 A52581865FA; Fri, 6 Dec 2024 03:23:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.96.72 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733455425; cv=fail; b=kY+kvlx56qfMj4PmcwqqqzQJfe+2Vysl+ZAiWgUff9nG0xv0m3yO/3sn7XceFt9oHr/9PcArXIpnGoeEFE9M9P8xuhn+9L0YNwQ9BnjUE1NX5V46iyEeWMtMJ/NyZTbt51BofwY4a7zb2UvGNjiLZTR50krDAayG4uVa2BvlIrw= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733455425; c=relaxed/simple; bh=ADHAYEGQIN8PMTT+q5E6Wnjocrm/ZEi+CMd0CtE3+mk=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=VRI46Wc/CgV+Ct9VKXL4TlFqJoEBda9ogABZ087TNK1ScTMtkSwFlDu+PFcOTtWEhCetsujyyC7WcrxAPra2VbARxaqrjyDlfXVp1Uf1U08CdyhqB91ZaLWvRIgfl2wp54685KwPI1+jHKih+4U6+DLC+QSvk38dZU3/FJo4Z8Q= 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=h2jbHlb/; arc=fail smtp.client-ip=40.107.96.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="h2jbHlb/" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=v9TPdQRBvcWd2C+s4/FU+L3Gnt6QkQ/PZhNtDCeBaxvnWurPBsHMQD5sj8eMuHR7ikiWgpIrfcDqnvURKSJPBCh+dqVVcdlJd332T5l2ex6/rthFdQkt+X7uG4Bn8HapAsczlysdGJRdOmE/kDqWM8P8lOCIkvDCfjm/zDc0SNoMOqiSYJ34BC1YZZuJo4Lo85YTu7Na64WdPpMnZtKlFFSOgVfrkwZKTVAZ70nzvCAZzt+0v6W3Iig0ta5/P7pXvMABJ27DSzxKpBJtVULdMDbaEAeu2CzkAjW+HEAOhApAqsPvu+Yf5zKVED29qRLxoMmhOIx3E6yzIxBulevVBQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=Vqpumrmwwskxuax8IdkPneF/w2aPuFMAKFy2VR8gjso=; b=YtbWwAtfxYJtXpnTwFNXuaCKXIdS+kMTz15naVX+lg5oaxnXnn6T9+EBO4sXL5plwfrfvcfHZEKjyGozYPnprrX/yVL0s3fmTsVtPqHNLgo8rl6jsHMZvg1ctvXb5NO1CwCMzum3gQTUvbrFiaZQIAR2Y97nj1B7IBR8CAvqJnhhaepmMzfei6fbXYO8sWFu67INS4zEx+yLbij3LSsbcTeuM/0FDs76LNGqWNwNKSvg4WVLMcT8rTh/0GOXmMBHyoYEad+QlRTqNXwFDsRS+qipaNcsEjj2U5CuXxhF4VJkPFy5H7wKaqycyEN5AKrEyVD+ZCMDxad6BYpu7qqDVg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=redhat.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Vqpumrmwwskxuax8IdkPneF/w2aPuFMAKFy2VR8gjso=; b=h2jbHlb/O69CIQ9lNtcrZeSBqRLoy5uv+RkrEXNaMY63D2LqGE4+bu+qIBrmI6ec0xfMfotzEFyhEw8kpwSkrmVn1f9OVm9blE2aRMftxmQN2syJrVxwQfbuugMycrr46MzWHDSNH9rrB+1RYGu/REuroAfmEBFofeudNB6N9G4= Received: from MN2PR11CA0011.namprd11.prod.outlook.com (2603:10b6:208:23b::16) by SN7PR12MB8132.namprd12.prod.outlook.com (2603:10b6:806:321::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8207.18; Fri, 6 Dec 2024 03:23:38 +0000 Received: from BL6PEPF00020E64.namprd04.prod.outlook.com (2603:10b6:208:23b:cafe::9c) by MN2PR11CA0011.outlook.office365.com (2603:10b6:208:23b::16) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8230.10 via Frontend Transport; Fri, 6 Dec 2024 03:23: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 BL6PEPF00020E64.mail.protection.outlook.com (10.167.249.25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8230.7 via Frontend Transport; Fri, 6 Dec 2024 03:23:37 +0000 Received: from AUS-P9-MLIMONCI.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Thu, 5 Dec 2024 21:22: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 v10 04/22] ACPI: platform_profile: Add platform handler argument to platform_profile_remove() Date: Thu, 5 Dec 2024 21:19:00 -0600 Message-ID: <20241206031918.1537-5-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241206031918.1537-1-mario.limonciello@amd.com> References: <20241206031918.1537-1-mario.limonciello@amd.com> Precedence: bulk X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL6PEPF00020E64:EE_|SN7PR12MB8132:EE_ X-MS-Office365-Filtering-Correlation-Id: 75885412-84a0-47e4-b062-08dd15a55fe4 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|1800799024|376014|36860700013|82310400026|7053199007; X-Microsoft-Antispam-Message-Info: =?utf-8?q?lH8Xx8HLqFUy1O4ZJJjDkcC+QNKLE24?= =?utf-8?q?eMybvAXok+Wvk0gj3OcadxURv3EV5dQ0BVwlU4I8cYXzFl+okTbDf+BKDHyfpv7gB?= =?utf-8?q?0X8jSi3Y8weFMY28rYqQlLCki38YtLRqCyvmGcXlt4hLhLt4jZLak9tovRjN27XdL?= =?utf-8?q?jbwXxciKD8cV8T6YKVId0GRmAbX9+Qy1VnBaDd8va1J1WK46vJZHC5XurBBmhC1/U?= =?utf-8?q?o25o+PL5npA+38pZK+aWID3sJnbZaV7MgTkabLVeWJYakOhoCHIYBu5v9W8yi5oc0?= =?utf-8?q?TjptS8BlDveP+q8QhnFhZEmmxWZKnEyQXontIS/67MqQwPj4t36rEYNFGQtvgHA5O?= =?utf-8?q?OpvxVt1W8aKlFZKN/xSTCoQ+9ty62cGWpbzyGnTwTGycRn8YboJWSE7Vh24PCNKTX?= =?utf-8?q?nUgDUwNs8cYMLJyg8S/V8r4o0wN6hODEtRsjZlGehMAqhjG8wLdAbeKh0nHzVfKjZ?= =?utf-8?q?zpdMbYeMViSslVngsdvSRt9C9u8rlgr3wXGoTVKtt8N/3GWQKhfuwoBgDLvq0gYRG?= =?utf-8?q?RR88MiokDsW8AE3MZMpbGv5/ak0/ygReLAo/yz5zMEdmsnV3BAGKaveydhLVna6+t?= =?utf-8?q?gpY1Z9qHdD9KmQm1Cqz3/+jVR6JA7QAOy6OHbuPuJArmqEoN5SP40g3k1BOj/sgqu?= =?utf-8?q?vUwEU1JtxlbHjoALDCmZi+KbCIE2cifKXV01W+u1liNkpXcemvEQhHhUXKmNwQkI6?= =?utf-8?q?FvP6h2bQFbUCxmidTIOz3oh7skI/l+PJqeFWor1nN5w+64+qOiCNhgrkGTl/mPRwQ?= =?utf-8?q?ztyi/IYZzEzz6IrIYY6/+OT0b68USDJz76iqkkr7P8qRDgni/PYn+wB5Ksj04iWWU?= =?utf-8?q?j+M+t4FJ2zN1wZpT2Pa6CQ/u+r5z9IBiBvZ27ctIXtwoEs61TRjN5pe1DMKyma5m7?= =?utf-8?q?aL6SjYOortQqQ7e6x0egC47HGhsPGn0tzuNxODs9Dh/7UhV4oR51FYdd4nKoGQXv3?= =?utf-8?q?M+scHHOzTW8b8EfHBuw5CrapPiprtE92CZHDyj0G532a1bSuL7f/W6p3kV2oyHIGf?= =?utf-8?q?EHlNRip2xG9v65VmCaaInTBiugz4UQuBPQfVqaNUrV1hLdwwatvWdEwlqK5i+2WWM?= =?utf-8?q?TdWds6C+b7sUHojGQWO0UCu65i4G9rHJst9kPWB8wo0qN3ZExp/1X253PK9iSdfmg?= =?utf-8?q?39rQnN5bKeP/RKQMnt6Bf42aEAazH/yOSBQkHXzZnPOWcnfhIBhDna3hQNFWHVtd/?= =?utf-8?q?B38yv1HFI17IOwhFX3K0fERJqARYzfUphH3VRVA9Ps+2FtTyviY44ntVwVmAfVV5h?= =?utf-8?q?GftBOhTWZGt1Oi9FRutvaO36994A7HpzP78mw80ISDth4muOnCL7P/heDjJ0DMY2S?= =?utf-8?q?lVXd3kuLiNFasc9kLaWpOgyf66ppZFFwwsUmHnn6Gz/ikcZ2/cDDaOI5S8XvJCWAT?= =?utf-8?q?XhNdj9freXi?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(7416014)(1800799024)(376014)(36860700013)(82310400026)(7053199007);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Dec 2024 03:23:37.8463 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 75885412-84a0-47e4-b062-08dd15a55fe4 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: BL6PEPF00020E64.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR12MB8132 To allow registering and unregistering multiple platform handlers calls to platform_profile_remove() will need to know which handler is to be removed. Add an argument for this. Tested-by: Mark Pearson Tested-by: Matthew Schwartz Reviewed-by: Hans de Goede Reviewed-by: Mark Pearson Reviewed-by: Maximilian Luz Reviewed-by: Ilpo Järvinen Reviewed-by: Armin Wolf Signed-off-by: Mario Limonciello --- drivers/acpi/platform_profile.c | 2 +- drivers/platform/surface/surface_platform_profile.c | 6 +++++- drivers/platform/x86/acer-wmi.c | 4 ++-- drivers/platform/x86/amd/pmf/sps.c | 2 +- drivers/platform/x86/asus-wmi.c | 4 ++-- drivers/platform/x86/dell/alienware-wmi.c | 2 +- drivers/platform/x86/dell/dell-pc.c | 2 +- drivers/platform/x86/hp/hp-wmi.c | 2 +- drivers/platform/x86/ideapad-laptop.c | 2 +- drivers/platform/x86/inspur_platform_profile.c | 5 ++++- drivers/platform/x86/thinkpad_acpi.c | 2 +- include/linux/platform_profile.h | 2 +- 12 files changed, 21 insertions(+), 14 deletions(-) diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profile.c index d2f7fd7743a13..c24744da20916 100644 --- a/drivers/acpi/platform_profile.c +++ b/drivers/acpi/platform_profile.c @@ -205,7 +205,7 @@ int platform_profile_register(struct platform_profile_handler *pprof) } EXPORT_SYMBOL_GPL(platform_profile_register); -int platform_profile_remove(void) +int platform_profile_remove(struct platform_profile_handler *pprof) { sysfs_remove_group(acpi_kobj, &platform_profile_group); diff --git a/drivers/platform/surface/surface_platform_profile.c b/drivers/platform/surface/surface_platform_profile.c index b73cfdd920c66..6c87e982bfc8f 100644 --- a/drivers/platform/surface/surface_platform_profile.c +++ b/drivers/platform/surface/surface_platform_profile.c @@ -210,6 +210,7 @@ static int surface_platform_profile_probe(struct ssam_device *sdev) return -ENOMEM; tpd->sdev = sdev; + ssam_device_set_drvdata(sdev, tpd); tpd->handler.name = "Surface Platform Profile"; tpd->handler.dev = &sdev->dev; @@ -228,7 +229,10 @@ static int surface_platform_profile_probe(struct ssam_device *sdev) static void surface_platform_profile_remove(struct ssam_device *sdev) { - platform_profile_remove(); + struct ssam_platform_profile_device *tpd; + + tpd = ssam_device_get_drvdata(sdev); + platform_profile_remove(&tpd->handler); } static const struct ssam_device_id ssam_platform_profile_match[] = { diff --git a/drivers/platform/x86/acer-wmi.c b/drivers/platform/x86/acer-wmi.c index aca4a5746bee1..b12965d9fcdb7 100644 --- a/drivers/platform/x86/acer-wmi.c +++ b/drivers/platform/x86/acer-wmi.c @@ -2547,7 +2547,7 @@ static int acer_platform_probe(struct platform_device *device) error_hwmon: if (platform_profile_support) - platform_profile_remove(); + platform_profile_remove(&platform_profile_handler); error_platform_profile: acer_rfkill_exit(); error_rfkill: @@ -2570,7 +2570,7 @@ static void acer_platform_remove(struct platform_device *device) acer_rfkill_exit(); if (platform_profile_support) - platform_profile_remove(); + platform_profile_remove(&platform_profile_handler); } #ifdef CONFIG_PM_SLEEP diff --git a/drivers/platform/x86/amd/pmf/sps.c b/drivers/platform/x86/amd/pmf/sps.c index 1b94af7c0e0c4..bd2bd6cfc39a0 100644 --- a/drivers/platform/x86/amd/pmf/sps.c +++ b/drivers/platform/x86/amd/pmf/sps.c @@ -426,5 +426,5 @@ int amd_pmf_init_sps(struct amd_pmf_dev *dev) void amd_pmf_deinit_sps(struct amd_pmf_dev *dev) { - platform_profile_remove(); + platform_profile_remove(&dev->pprof); } diff --git a/drivers/platform/x86/asus-wmi.c b/drivers/platform/x86/asus-wmi.c index 14d84cad01b49..805bce80beef2 100644 --- a/drivers/platform/x86/asus-wmi.c +++ b/drivers/platform/x86/asus-wmi.c @@ -4852,7 +4852,7 @@ static int asus_wmi_add(struct platform_device *pdev) fail_custom_fan_curve: fail_platform_profile_setup: if (asus->platform_profile_support) - platform_profile_remove(); + platform_profile_remove(&asus->platform_profile_handler); fail_fan_boost_mode: fail_platform: kfree(asus); @@ -4879,7 +4879,7 @@ static void asus_wmi_remove(struct platform_device *device) asus_wmi_battery_exit(asus); if (asus->platform_profile_support) - platform_profile_remove(); + platform_profile_remove(&asus->platform_profile_handler); kfree(asus); } diff --git a/drivers/platform/x86/dell/alienware-wmi.c b/drivers/platform/x86/dell/alienware-wmi.c index 78aac76132788..e95d22c7b60cd 100644 --- a/drivers/platform/x86/dell/alienware-wmi.c +++ b/drivers/platform/x86/dell/alienware-wmi.c @@ -1165,7 +1165,7 @@ static int create_thermal_profile(struct platform_device *platform_device) static void remove_thermal_profile(void) { if (quirks->thermal) - platform_profile_remove(); + platform_profile_remove(&pp_handler); } static int __init alienware_wmi_init(void) diff --git a/drivers/platform/x86/dell/dell-pc.c b/drivers/platform/x86/dell/dell-pc.c index b9a6dd7b321d9..3797a5721dbde 100644 --- a/drivers/platform/x86/dell/dell-pc.c +++ b/drivers/platform/x86/dell/dell-pc.c @@ -289,7 +289,7 @@ static int thermal_init(void) static void thermal_cleanup(void) { if (thermal_handler) - platform_profile_remove(); + platform_profile_remove(thermal_handler); platform_device_unregister(platform_device); } diff --git a/drivers/platform/x86/hp/hp-wmi.c b/drivers/platform/x86/hp/hp-wmi.c index ffb09799142bc..6d6e13a0c6e2d 100644 --- a/drivers/platform/x86/hp/hp-wmi.c +++ b/drivers/platform/x86/hp/hp-wmi.c @@ -1693,7 +1693,7 @@ static void __exit hp_wmi_bios_remove(struct platform_device *device) } if (platform_profile_support) - platform_profile_remove(); + platform_profile_remove(&platform_profile_handler); } static int hp_wmi_resume_handler(struct device *device) diff --git a/drivers/platform/x86/ideapad-laptop.c b/drivers/platform/x86/ideapad-laptop.c index b6586c473ba91..95b66ac3ea1d6 100644 --- a/drivers/platform/x86/ideapad-laptop.c +++ b/drivers/platform/x86/ideapad-laptop.c @@ -1136,7 +1136,7 @@ static void ideapad_dytc_profile_exit(struct ideapad_private *priv) if (!priv->dytc) return; - platform_profile_remove(); + platform_profile_remove(&priv->dytc->pprof); mutex_destroy(&priv->dytc->mutex); kfree(priv->dytc); diff --git a/drivers/platform/x86/inspur_platform_profile.c b/drivers/platform/x86/inspur_platform_profile.c index 5a53949bbbf5f..53af73a7fbf7b 100644 --- a/drivers/platform/x86/inspur_platform_profile.c +++ b/drivers/platform/x86/inspur_platform_profile.c @@ -191,7 +191,10 @@ static int inspur_wmi_probe(struct wmi_device *wdev, const void *context) static void inspur_wmi_remove(struct wmi_device *wdev) { - platform_profile_remove(); + struct inspur_wmi_priv *priv; + + priv = dev_get_drvdata(&wdev->dev); + platform_profile_remove(&priv->handler); } static const struct wmi_device_id inspur_wmi_id_table[] = { diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c index 58af9020382c1..298100d5c535c 100644 --- a/drivers/platform/x86/thinkpad_acpi.c +++ b/drivers/platform/x86/thinkpad_acpi.c @@ -10660,7 +10660,7 @@ static int tpacpi_dytc_profile_init(struct ibm_init_struct *iibm) static void dytc_profile_exit(void) { - platform_profile_remove(); + platform_profile_remove(&dytc_profile); } static struct ibm_struct dytc_profile_driver_data = { diff --git a/include/linux/platform_profile.h b/include/linux/platform_profile.h index daec6b9bad81f..bcaf3aa39160f 100644 --- a/include/linux/platform_profile.h +++ b/include/linux/platform_profile.h @@ -37,7 +37,7 @@ struct platform_profile_handler { }; int platform_profile_register(struct platform_profile_handler *pprof); -int platform_profile_remove(void); +int platform_profile_remove(struct platform_profile_handler *pprof); int platform_profile_cycle(void); void platform_profile_notify(void); From patchwork Fri Dec 6 03:19:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 13896339 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 DBD32187FF4; Fri, 6 Dec 2024 03:24:14 +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=1733455457; cv=fail; b=SofQp9Y6DVRmb4Myth15DSUWFCj7SO7ksHW3oj4ioW24cKye0cPEZB3qLIwhWqblftNsjXYRBlg2gkqdjf5Do1++Bbe3X0xFA5nvQK9rwv8y5JpBKwOgEfi6Ggh4BBQE4WYO2RcWloNkbeSMXRSraYbAMCN8wGk6fSMxed2szaM= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733455457; c=relaxed/simple; bh=2sGp8nsceMSqqbGFXAGu40PROo274ncRCGZ1RbgNNlw=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=hS9RGueC9ceCCeFdXghgam5fuFW4JWUnYbBfaqxJg16jgmBXW53Y1zJfeE12pLzoGXJa9JrQ/WPUtkj1Jpb4HF029Gz1djF89RzVN4XA52leO2F8mpXtIl7wWA7fCNNIlFc5KoQtT0norrEeEsq+ADeh5EcBb/Llt3ezXSJenic= 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=fBdJ2tom; 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="fBdJ2tom" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=HAsKf+y9hW4gdoPjHga4QfNDopP0ajnjQh/mdJ2ecbWFbfZZYAKrkfEgx0PauzxUd64XLT+WW4iQWCm7JD416AI9gPqW2UF/L52lYOB6jQahPNJsbiJM4ckJquILeZ1r6XQbgo/LrGVVqPH/GUxBv4qrYTOLFkZHQTvCRyNoJsyQ7XevB48GfypaH3w/8/ViMhIE+EFj5XHelwleUVV9v1N63EWXqnRG0/c/DAahtQfPGpj8Zy4CytW1qf7tgdJ+3fMPOHvXoO9FkonflqtezVJ8c5TGnye4mF9dwdco8wtHjJnCr7Os4FX+/6XNCgd+rFFCfOb/vET5Hfbt67pbNQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=PtJpblUh8MBOEucV5B3TNCycXxWvmJz0+rzIT5JUVPU=; b=eKLSPSt5J5Ar5Lj9VQUyBAP+ok20LybicIwnU6H7GGfvxun5+nSXll0nS3Kuek6R+YOpGozSXmatzrlEdXYS6nIdYdwJsDTb6s+Si9DnvuRS003hbqmr+lUPPDHjTTNnPwxIrKPjWadsdcNkvP03WwmB9mdezoJ1+EU8aRafKgGS05Wa76/pspMdQWLPbMgEu8X5UEa3ovUdrFM2/mlPa2oQYxTJMT2VN9qkSWhXuMx92cayl4I9SBV+sXRVXjsdWQ2d4fywz0euPHikaKKihZeOnKqhXBo4vM526N5woSQeghdT4FAe2q4++o79J2QLdm+KYTgm9XODgvmZGHriBg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=redhat.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=PtJpblUh8MBOEucV5B3TNCycXxWvmJz0+rzIT5JUVPU=; b=fBdJ2tomi6GFpsX5/frmu4WnsD2klP2shBGoUCvE7zxBJAsT9nhs6K6J1C3nVyAQMkSPmYKJCrARXJKaGrO7fftPM4483pL46Nu8rQpcSYktzn2On3dtFsetR0DM/ePAvprQpNPRZBzALNLiaOxBywj86GQRWRafEea6R+HpI7Q= Received: from BN9PR03CA0611.namprd03.prod.outlook.com (2603:10b6:408:106::16) by CH2PR12MB4040.namprd12.prod.outlook.com (2603:10b6:610:ac::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8207.20; Fri, 6 Dec 2024 03:24:10 +0000 Received: from BL6PEPF00020E65.namprd04.prod.outlook.com (2603:10b6:408:106:cafe::d7) by BN9PR03CA0611.outlook.office365.com (2603:10b6:408:106::16) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8230.10 via Frontend Transport; Fri, 6 Dec 2024 03:24:10 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by BL6PEPF00020E65.mail.protection.outlook.com (10.167.249.26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8230.7 via Frontend Transport; Fri, 6 Dec 2024 03:24:09 +0000 Received: from AUS-P9-MLIMONCI.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Thu, 5 Dec 2024 21:22: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 , Armin Wolf Subject: [PATCH v10 05/22] ACPI: platform_profile: Pass the profile handler into platform_profile_notify() Date: Thu, 5 Dec 2024 21:19:01 -0600 Message-ID: <20241206031918.1537-6-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241206031918.1537-1-mario.limonciello@amd.com> References: <20241206031918.1537-1-mario.limonciello@amd.com> Precedence: bulk X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL6PEPF00020E65:EE_|CH2PR12MB4040:EE_ X-MS-Office365-Filtering-Correlation-Id: bb3d0dd1-aadc-4e07-1315-08dd15a5730c 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: SuMiioMf8wmmjleNSx4efxG14qLsd6lR+ietkZYI+PHpF4YRWTYekuDiii6XpoiaKSqUwClJ5dshEg+RNfytESXQ+ZPNfxtYji1Z3h2b/KsRAT5TROCZuKm0kLHTfwoUkujP7LP3VEUV1Dx+scgPUQynC/qLjp8sbsdziWXhGT7tswxKXKd7j5MQiHgzULuf6BeYNngfTpTZol7hmAHl5SkRPnrkJp3UtRcsX0KAjZdHISDMFQTgTWZPtBQ7Lcp61WA5jj4oLPfxOv84XInArbLyZuL5emcCTb/R5E33sbn1Cajt3t7B3cbky8LkXfheZwUWL2D44j9+VuFtq69Mv7tUZeM4gbj+8WbqfhlC7LdRyn/R3x45VhsLsdA/n+YmhuFtpmBIdaglpyM+mWxEcwDWh9qQbgXeq9uxEY5wR78ZZFW2RScn2GHQb1y1JK/UXR3ek0oHSjKQzg6EbRQTb1isCmcGSQ8ArTstqLENJTzQIa+qsNxmn4r25M6ZzJdfzCjfxG/Je10pe41fEBm3/NFrNhP7ArVes6KCO3RsfopksLuP17dCZ7bivn1o2eF46DBahnLHTNUGCi7a0lAnb6n2zk04HtuQLEEgTC9tYCtkV/45vLhCm2wBUHIg93EdpWBSguwjWpSKNwLLZOc5BamLiwDzam8nTtb3nCMM8X8EkuVsOMhqkaFOj17oW2/KWVLwVAVhHndbbw37bVTKjutyC6KxbId/T4eeUYsWrN2iU7ir4Kk2TBZczAiu1uTrIshB4WqEvMymuUIb3jEiJLZ5HxjNCtHlY4mAGBe99OXad4aVU6FQEf69ovmZIrQALg5jj+5xlwmQD81vJqD3ow8ZUUWGGnQjJGOj3kh9tVwOVtgwKbMq57kh3aNdoc3iq28wv6OGAS5c+MvxI3pzMmzKNxy33j+3m0valIlHjIUv3UOL8QzfzwBGXpGFzqiBpQkPSpZGgEaz6MaTxmugGxQ+2CpxwKAIGfc3VYFuF11m+kvWHUj5cyBv6xNpQGv14c/stNLVhN7CqbUo6+cHmcFVKFQPWaoGlhlKUpr5pQKcqj8K0EzWzRhZwCnmZCOME5xzY0nheiowupnKjcbzIbucaY3I+3UPq3Z5yoPUFaUEThC2ERT+c5qYw/Bwhy9liwgeANhQjw878eoWzcXdDlLF2tbaTZV+bIuLVep0q2rR120cIppqeBTKgnPkSue8Zu0onqfnunHaESlUSrqPzlIN5hlFq4l8MKz8edGx0NbKHGDyL//AgGTC372FrxB8Na2ZVZFhQEe6PMtaOtcSrXkfTF+A+pCf4hh+ysVDnZ+Q/KcsM02gfzuyTCkDHt9aiWL9jWi9QZBy2w857bBvwagKzQKndRHtupFKLl7UtCO4wPgdw5RKkriaTvqHhjFYm0UIRRrCM2gQeSPqkJQLYQBarDl4/YxtNuERmi1XvbjmfFWllfh5BfrV46GkFQZO 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: 06 Dec 2024 03:24:09.9499 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: bb3d0dd1-aadc-4e07-1315-08dd15a5730c 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: BL6PEPF00020E65.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH2PR12MB4040 The profile handler will be used to notify the appropriate class devices. Reviewed-by: Armin Wolf Reviewed-by: Mark Pearson Signed-off-by: Mario Limonciello --- drivers/acpi/platform_profile.c | 2 +- drivers/platform/x86/acer-wmi.c | 2 +- drivers/platform/x86/asus-wmi.c | 2 +- drivers/platform/x86/ideapad-laptop.c | 2 +- drivers/platform/x86/thinkpad_acpi.c | 14 +++++++------- include/linux/platform_profile.h | 2 +- 6 files changed, 12 insertions(+), 12 deletions(-) diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profile.c index c24744da20916..927a2f7456c9a 100644 --- a/drivers/acpi/platform_profile.c +++ b/drivers/acpi/platform_profile.c @@ -128,7 +128,7 @@ static const struct attribute_group platform_profile_group = { .attrs = platform_profile_attrs }; -void platform_profile_notify(void) +void platform_profile_notify(struct platform_profile_handler *pprof) { if (!cur_profile) return; diff --git a/drivers/platform/x86/acer-wmi.c b/drivers/platform/x86/acer-wmi.c index b12965d9fcdb7..0018818258070 100644 --- a/drivers/platform/x86/acer-wmi.c +++ b/drivers/platform/x86/acer-wmi.c @@ -1988,7 +1988,7 @@ static int acer_thermal_profile_change(void) if (tp != ACER_PREDATOR_V4_THERMAL_PROFILE_TURBO_WMI) last_non_turbo_profile = tp; - platform_profile_notify(); + platform_profile_notify(&platform_profile_handler); } return 0; diff --git a/drivers/platform/x86/asus-wmi.c b/drivers/platform/x86/asus-wmi.c index 805bce80beef2..fdeebab96fc00 100644 --- a/drivers/platform/x86/asus-wmi.c +++ b/drivers/platform/x86/asus-wmi.c @@ -3789,7 +3789,7 @@ static ssize_t throttle_thermal_policy_store(struct device *dev, * Ensure that platform_profile updates userspace with the change to ensure * that platform_profile and throttle_thermal_policy_mode are in sync. */ - platform_profile_notify(); + platform_profile_notify(&asus->platform_profile_handler); return count; } diff --git a/drivers/platform/x86/ideapad-laptop.c b/drivers/platform/x86/ideapad-laptop.c index 95b66ac3ea1d6..00b9c0c32239c 100644 --- a/drivers/platform/x86/ideapad-laptop.c +++ b/drivers/platform/x86/ideapad-laptop.c @@ -1041,7 +1041,7 @@ static void dytc_profile_refresh(struct ideapad_private *priv) if (profile != priv->dytc->current_profile) { priv->dytc->current_profile = profile; - platform_profile_notify(); + platform_profile_notify(&priv->dytc->pprof); } } diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c index 298100d5c535c..f516628617384 100644 --- a/drivers/platform/x86/thinkpad_acpi.c +++ b/drivers/platform/x86/thinkpad_acpi.c @@ -10538,6 +10538,12 @@ static int dytc_profile_set(struct platform_profile_handler *pprof, return err; } +static struct platform_profile_handler dytc_profile = { + .name = "thinkpad-acpi", + .profile_get = dytc_profile_get, + .profile_set = dytc_profile_set, +}; + static void dytc_profile_refresh(void) { enum platform_profile_option profile; @@ -10566,16 +10572,10 @@ static void dytc_profile_refresh(void) err = convert_dytc_to_profile(funcmode, perfmode, &profile); if (!err && profile != dytc_current_profile) { dytc_current_profile = profile; - platform_profile_notify(); + platform_profile_notify(&dytc_profile); } } -static struct platform_profile_handler dytc_profile = { - .name = "thinkpad-acpi", - .profile_get = dytc_profile_get, - .profile_set = dytc_profile_set, -}; - static int tpacpi_dytc_profile_init(struct ibm_init_struct *iibm) { int err, output; diff --git a/include/linux/platform_profile.h b/include/linux/platform_profile.h index bcaf3aa39160f..8ec0b8da56db5 100644 --- a/include/linux/platform_profile.h +++ b/include/linux/platform_profile.h @@ -39,6 +39,6 @@ struct platform_profile_handler { int platform_profile_register(struct platform_profile_handler *pprof); int platform_profile_remove(struct platform_profile_handler *pprof); int platform_profile_cycle(void); -void platform_profile_notify(void); +void platform_profile_notify(struct platform_profile_handler *pprof); #endif /*_PLATFORM_PROFILE_H_*/ From patchwork Fri Dec 6 03:19:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 13896340 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2078.outbound.protection.outlook.com [40.107.237.78]) (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 1ECFD1E522; Fri, 6 Dec 2024 03:25:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.237.78 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733455514; cv=fail; b=turZ3sy+CSLGWnH3IN418scUIlIWhsFSWqFIiCD5tQBTa8I4oGGPyUYUSK1F6UHUbRFqmNAG+b72POHL4e1iok2Padyx7914mWphHLA1PFupbsH64UiBZRVANTcjlKshI7n06i23MKm0cK1U/Nr6D/VthqXER38S0suwKZJ7/v8= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733455514; c=relaxed/simple; bh=z0GlcC9vwRUmxS0LWl2nrqiX/2qAQj38IxksQe1F4C8=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=KWMjT89jwlHovqqsaVJDm2FMjpKYzBVxqLK0a1aXEp2OtnPHaf2abOyvCIVL4+hPA+j7c/DdUIn0WlSL7SKgYNqh5qESLkKVnNsGmdIU/3+U5kworEUFSOaVk15OZJD7+othlQR2ghYmyZ6WW7LHIPuEJIuocKdu4hg4NgNguYA= 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=2WIWsEZx; arc=fail smtp.client-ip=40.107.237.78 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="2WIWsEZx" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=vMq+ZnwbAxIjKpmYKdr6lXT81kj6kYozPl7OsQVrCMD0YeeKAEbUXaJ7fgTWG8TKPRM+OFPuGNoWnT6agl6Hi1l0NEQCq7CUz/6odPvTFFnYaXaXn+o1QY1Xg0oCsUBaf3cG1ES8xRydpzdA9HEEIPpWGVwVaGcwPvgg+0RZrpzsvgADf6Tz1B9B6PG7B1TUtpTz5ZtYRxpiNWL7YgQO/67XwYuKGRosZ4zzorpTOyDDtymTkju4mq3k6H6Rzq/Rh7hypCn5eo4YN6v+10BaB2VCqj/L//p+UDeou28L4n1k2VzFM4okDDXYx+Sc9l131dftLATfRPrBoY5wH9H1Pg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=Fbrw9w+y1t+fOwFGCAec/Yj7kmTgUhQgGzFW3WCgW90=; b=SyLE9ZVR6qpUfjLHCd2mnojoub7DeNQ+1/wXZQdZo4oj1y5ItvB4agocZtT1QodBeRWdACf2JuphNIYTB66NC3Tf8uVjYE3eLYQ1FiS3khcgU5DWroXUJ1PTs7Gw7ec/S+dKaY6yWJJ6zf61JfIzitIhyI/KYdl4JMqg2N/e/PIK/8VVG+e2oom+KmRxpTlKQVSyas3dTnfuOW4BU7id3avkw2ssaC0MgTza0gcGlzFqxNzxjJVAk4p0g5bvkj1+PCVmSzJdv05fxkv0kTFpqL08XGMjtrL7UDaCR+KPSQl0zEMioKtOyFZlxauzWogCYedwRN8ILN+FhJrEI3y6Vw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=redhat.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Fbrw9w+y1t+fOwFGCAec/Yj7kmTgUhQgGzFW3WCgW90=; b=2WIWsEZxt11oib+fn8dYtI9212X+ShIShRBqtCCZLE8zQPLR1WjUMG5TDNWLDf5ziunnSEoVseZk/newr6g6Zu+EWJDziuVhd1/FoZTa3HK9zzth3B4GUtTM9jRd8807PBn97Dd/lONvJXv4aDCcSdotRYBlc0yiRIT8VRrimkU= Received: from BYAPR01CA0053.prod.exchangelabs.com (2603:10b6:a03:94::30) by SA3PR12MB9160.namprd12.prod.outlook.com (2603:10b6:806:399::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8230.11; Fri, 6 Dec 2024 03:25:09 +0000 Received: from MWH0EPF000A6735.namprd04.prod.outlook.com (2603:10b6:a03:94:cafe::b) by BYAPR01CA0053.outlook.office365.com (2603:10b6:a03:94::30) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8207.18 via Frontend Transport; Fri, 6 Dec 2024 03:25:08 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by MWH0EPF000A6735.mail.protection.outlook.com (10.167.249.27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8230.7 via Frontend Transport; Fri, 6 Dec 2024 03:25:08 +0000 Received: from AUS-P9-MLIMONCI.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Thu, 5 Dec 2024 21:22:53 -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 v10 06/22] ACPI: platform_profile: Move sanity check out of the mutex Date: Thu, 5 Dec 2024 21:19:02 -0600 Message-ID: <20241206031918.1537-7-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241206031918.1537-1-mario.limonciello@amd.com> References: <20241206031918.1537-1-mario.limonciello@amd.com> Precedence: bulk X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MWH0EPF000A6735:EE_|SA3PR12MB9160:EE_ X-MS-Office365-Filtering-Correlation-Id: 5ae44da0-8b22-4d10-10ce-08dd15a5961c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|82310400026|36860700013|1800799024|376014|7416014; X-Microsoft-Antispam-Message-Info: =?utf-8?q?ENpsiooYtcAYqmEEnjX9yI9cKayZWWy?= =?utf-8?q?OOePoh8B73zL84mPDZqJDWwipATX4rmGvmSrm98WpN0+KIkXzVn0HWHmimDLX3YWf?= =?utf-8?q?oU8HgUsVNJXKblVisLkzwnxynme4wFHS7ry9QKSm0S2nYIE2r86n5oOInX5G01LJg?= =?utf-8?q?hF75LlC+mHo93vifV4DWygfbbZA5jePyn8DaTGcUsawoQBhGi0VpQW4REU/rTO0jd?= =?utf-8?q?hYhWu61Bm4DZG+hcl94w7vPr16+aoIHxe62ih7V10K7aKHRPUrG3ZrMJCSZcqrw2p?= =?utf-8?q?IYwgOLBQug1tDgSsf4xUVNenzAZHe46eBnin+anxQkgifoDdOcVaIXDZaPn27fjc1?= =?utf-8?q?sUWxUr9n7DGjQvSzvehxXwhkaZjDiLGQJrUzeYnX4R+0fYIQAnqyoqnWpONADVXWp?= =?utf-8?q?cAtanxr56vNMVrfzaoq2J7nmVEKPfdBJvTIf8tq8JRFYk7VBjoENySnu7PMxQm3b3?= =?utf-8?q?H0EDt/fvkiP+FCWa8NkS14F6y8zHgqwRRqZYGoHVwpxhigjvemPpobx5EGOt/FhnD?= =?utf-8?q?PjF38df5xuz0fNqmRf6G2UWTXqe8HtKuUTdGRE52BiQUlrSQeuCcIH1Q2N+xJhQns?= =?utf-8?q?AX1cw++3O6EQD0II7fl5UHUwo/x3QLNNQF6bqod9719p91m6H6ISVVbdl9wbEDtiU?= =?utf-8?q?CWDfY6OGtnq/tdNniNaL0+RfgT4t9P6fJNOSkGR5Ri1HawaV+rTyGA777ls2TU0Tx?= =?utf-8?q?Rv1prZN51qoMTDA3x5LSOeXFtfritfVA3AqZs0Upe6PLR++zPKLj/2RQe8lIBAJ6R?= =?utf-8?q?CQE57GAEQozFQi8z08qKOLD0IrPgHMc03b+3CWDK4LWckJMKLzHw+LvkesRl2j8QE?= =?utf-8?q?ihjnLk0L5CElYisRZ+A64ovgvpblPAcC5ot8qCAFhw/I2dmGUjVnoOlfOktpVDyW1?= =?utf-8?q?7HOdMEaL7hOw7VYXJ2e0terfpy5srz7slmfgvzu7vfZAM0NP2Q9zvxUCjwpEXLpZu?= =?utf-8?q?dLqP+seECN+FphNJzVwRRJ2urKVH2VfxM4PgeRjwAo75mtXMV6MXvFjv9BD16bcyW?= =?utf-8?q?FWo5R3S7HeoUr29f652Wo7fISQBpq3/q/UtNVc2Pefb7DBB+BdyCyYiTPMByZrQUQ?= =?utf-8?q?R6Hs1G0LB7e8q0Rjk5c7AmlaBBf6OhqbqNKkqQUg38QR6jepemToFh1v5RomjU8+W?= =?utf-8?q?mz3+Xd/zHR129AxQtlwm6xLHuCcXTxJi0vRetR6zZ5YkQkoe/I+ZAFYaRxlM/ofbM?= =?utf-8?q?KjU/g1peKcNMz4zgDM5Bxn3Rr3oflWcpW72yQ0bMrHUNCmdft2AjWEzR/IgC3UycO?= =?utf-8?q?M1jv1beynenWnLPIvlfzWZtLHhMMyiXDT/Y0fl5jV01d5FtEXr74Ub0bUbOnVw6A4?= =?utf-8?q?Ox8/g7zdlBXOGd/5WZibPvzYAFsdyX7zgpGbm+YQJFXa1UJvY8dOR3c02jXh4G9Hq?= =?utf-8?q?ESXRuvO65K4?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(82310400026)(36860700013)(1800799024)(376014)(7416014);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Dec 2024 03:25:08.7124 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 5ae44da0-8b22-4d10-10ce-08dd15a5961c 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: MWH0EPF000A6735.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA3PR12MB9160 The sanity check that the platform handler had choices set doesn't need the mutex taken. Move it to earlier in the registration. Tested-by: Mark Pearson Tested-by: Matthew Schwartz Reviewed-by: Ilpo Järvinen Reviewed-by: Mark Pearson Reviewed-by: Armin Wolf Signed-off-by: Mario Limonciello --- drivers/acpi/platform_profile.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profile.c index 927a2f7456c9a..4f5623fc27c09 100644 --- a/drivers/acpi/platform_profile.c +++ b/drivers/acpi/platform_profile.c @@ -179,6 +179,13 @@ int platform_profile_register(struct platform_profile_handler *pprof) { int err; + /* Sanity check the profile handler */ + if (!pprof || bitmap_empty(pprof->choices, PLATFORM_PROFILE_LAST) || + !pprof->profile_set || !pprof->profile_get) { + pr_err("platform_profile: handler is invalid\n"); + return -EINVAL; + } + mutex_lock(&profile_lock); /* We can only have one active profile */ if (cur_profile) { @@ -186,13 +193,6 @@ int platform_profile_register(struct platform_profile_handler *pprof) return -EEXIST; } - /* Sanity check the profile handler field are set */ - if (!pprof || bitmap_empty(pprof->choices, PLATFORM_PROFILE_LAST) || - !pprof->profile_set || !pprof->profile_get) { - mutex_unlock(&profile_lock); - return -EINVAL; - } - err = sysfs_create_group(acpi_kobj, &platform_profile_group); if (err) { mutex_unlock(&profile_lock); From patchwork Fri Dec 6 03:19:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 13896341 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2065.outbound.protection.outlook.com [40.107.244.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 99F0812FB0A; Fri, 6 Dec 2024 03:25:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.244.65 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733455550; cv=fail; b=OIz3WokWUEf6KNQNxbEFT7zEYmpwZcfR5HoX/uQU453SDjRkVV+NqqhJ9wkkr8LGHWOzDLyKVnB0HpDlE2/hPbOpImMKeyNHgy62Mg4hMzy/KCVa44IMzr9u5Q18bm3hZ/7vVbyFn7/zlGevgRbUOW+AJo0gmzULWFV5nuoIPN8= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733455550; c=relaxed/simple; bh=+xN18sNC5Ocgap1+ttPhDXae8uq0m/TFsmTPn/lgO0w=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=nTwf2Qb8hY3j7mUAa8pnllu+zNZIQooilvC9HIPYxl16XtVL0UnFlIX/sp8LFYPmA0liwNJ/w6HZfW2ZhM3AMKS7dK7F41WYiJ4SDkk7w+/PJd+gb8F88XrXoo7oWQ/rShwIstx65WoGLOn5Y87GZSZT04YaIVIsW2huL0Of2B0= 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=pcx0vGz2; arc=fail smtp.client-ip=40.107.244.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="pcx0vGz2" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=WhQL+lKXdTUAjpnZwVP1S9uKynPxxRS2TJs33Xps/Npoh7NiEbJaQcLg7T/esbAaP+qqgGu0O9IIvpTujXYYZIiRnDBbZ3J7wNRnanBxzJkkNBdHYvwn6su1XyK990LUsUYWQ7uKxxM66ZKn+3aVO8lFK2sYzFCzzARwIYulbrEJ72Ucs5dLV2+8xGM/2FW9jT3pt3olF5SWvd4YfDOZubWhCYmasAhkhp6j/DXKRqOf4zZyqDgOd8MMRqH+0mvFzAESXYF7aGCdbz6rcEUDE9KLVOBw6y6xQb2umpGSWcADd9u45K/o6T/6jPJSmGCFaCdr7kvNagS3vXA6jW1trg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=N+XaE8yyWjGIn19TzASAZzj0sYETWpxRAyipXeNBClA=; b=mKW4rbBA0uHRmTLhxXi2HCjkrFFt1WwUlrKAmzJ0Ws+wN+yvYIYb1bb4YEMuv8EcB9o3AGSwbe1ytqu8xA4qYTNmcqYY3XnOYoN8jF/hI/mpa9OVSi9CeMSZ3ZwhTqZqvWrAqWHqqggTSS693UgmV8WF7dGMo/LGwBtl9qvizxm7ikqgW1gtLp26O1xuXz/5BcOajShc2S4Tgwpr/Ob4Yn9sEIF4Ym5ifYE8I8pcG0ZOX1ldINOuDnOTY5sxLAbVW01zp8Iunx9FNB5E06jS8CORLok5sNQvPXR44ZE/beg5KeagGUrDCN6kPHVQczgM1pGmR2zJZqLDQ5XEytQg+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=N+XaE8yyWjGIn19TzASAZzj0sYETWpxRAyipXeNBClA=; b=pcx0vGz2h7NbW1UacIreB5MdVtA5FAG0tavVKFH+fQ5xh9Y1lYaEPOwf9J5riH95nfCJhIsDYYDOuG6h6i8VeBlKTBorFEXHqMHXol/L5NXWet2n39GGqGZu9P+m1STnKCadPwJDs0JZCm8Fn1l37hhGPF1biOcAtkR8wWQmCdU= Received: from MW4PR04CA0040.namprd04.prod.outlook.com (2603:10b6:303:6a::15) by DS0PR12MB8416.namprd12.prod.outlook.com (2603:10b6:8:ff::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8230.12; Fri, 6 Dec 2024 03:25:45 +0000 Received: from MWH0EPF000A6734.namprd04.prod.outlook.com (2603:10b6:303:6a:cafe::6a) by MW4PR04CA0040.outlook.office365.com (2603:10b6:303:6a::15) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8230.10 via Frontend Transport; Fri, 6 Dec 2024 03:25:45 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by MWH0EPF000A6734.mail.protection.outlook.com (10.167.249.26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8230.7 via Frontend Transport; Fri, 6 Dec 2024 03:25:45 +0000 Received: from AUS-P9-MLIMONCI.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Thu, 5 Dec 2024 21:24:10 -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 v10 07/22] ACPI: platform_profile: Move matching string for new profile out of mutex Date: Thu, 5 Dec 2024 21:19:03 -0600 Message-ID: <20241206031918.1537-8-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241206031918.1537-1-mario.limonciello@amd.com> References: <20241206031918.1537-1-mario.limonciello@amd.com> Precedence: bulk X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MWH0EPF000A6734:EE_|DS0PR12MB8416:EE_ X-MS-Office365-Filtering-Correlation-Id: 7231f82c-1bd7-4b09-8a0a-08dd15a5abda X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700013|376014|7416014|1800799024|82310400026; X-Microsoft-Antispam-Message-Info: =?utf-8?q?hQ4v23PXC07ektbywLDgFiapwkvDu4J?= =?utf-8?q?tBE0qoGdVQycAhDvya9Z0+MNBxGP8XcKhmQtvFTg7AQHW6KsNFMY+09PrlXhAFRbe?= =?utf-8?q?7l3LOs/7hz7yLlu0Swo/sEUmeWLKbJKJMBo1iMlc5+mOCybg41k98vEnzKnMmcHzF?= =?utf-8?q?p7pCEuCWndiWL5ELV4PDfxRAKyMlSSRnE4ZDM9bjjSxqYmDtb7zD/+buGTx+El4cm?= =?utf-8?q?5OHJRba/jXN9KwPzht5PolWKN1mZM2WeJfPRaVfClLMCoa6saUZUZwads9UnGsZIK?= =?utf-8?q?JEYhHL2QRra4YURB48He9F6+Q+0OD+jta0qgfvzM47/5FHe0WKwpul/SWnb7Zon1/?= =?utf-8?q?uGX7dygTKjF3RAzzzOCes0vCQRadmV4QmpVdjXWjBBt4QQ4TS0XsLXHw106l6rh84?= =?utf-8?q?9WMpzmTqgerXjeSxu9KKrHnggWpcxjOJVHn6uiV6RKAMPQwWXWyVPsa1GvH6VbsFl?= =?utf-8?q?Hp9NTvIvKKgeW+4pOIR3XD9zCzpwdSjgJPKSnax0Hf30607vR5Zy8W5XZI2dhdlRO?= =?utf-8?q?uWiBMkfoHChoew6Ljc5l76+rx9q8uWfn5AYD2g//pNEKShWRsCBpl9QiIE0sqIw4T?= =?utf-8?q?D8R3u8tfTVmVEUcBXcI6p7HcL1E9lBuiWr9f+wtlAS7TeeqrMZSBRDO442fKtrLbi?= =?utf-8?q?a9lFnNNxGHF156QFxLlAnpuSozjYgi3S0/cxOE1V96fED1S2d/XdCI+HyseWBmeY1?= =?utf-8?q?5wT0YqBWMFVzyf/fPvUPYan23W/UFWGeFLEX5d7WsqRa732fstBCrw3Ad0Kj85/vu?= =?utf-8?q?yseNRPlhz39MzEbGWYE1GgO8jzBjrsFN6hfGgKp5ixdSmjqPCEQiPwjW65C6/rUBI?= =?utf-8?q?OA/xztGYaFF6mjrkWhjdv0YEooO0YYNBYIsqJ3yqvvHRf6Rew9nr1lnmwb11hqDup?= =?utf-8?q?Zctt+CievE19rfz/IpJtkrrAwfXRwST8ZnoqrLd/SpSrh/KMdA3Mkt/UvYgwrDDLt?= =?utf-8?q?NVxYfT4ieBrAoGa4lygM9WJ1ORnws/x+03yKl5Bvbzy9jY6y0ORsrGmVj1llg2Zyn?= =?utf-8?q?5x46fjkNyH+azg8FF3JKDqBNSfG5P78EtYXDJ65kRNV/mWyI2SddVCoZH3uAdp2v1?= =?utf-8?q?lAv3c2HsPqVEM3t7oMwhW1oP3qACRfY5K4dh8p3sdtazsxybXlVAmjCQvgI8qABhr?= =?utf-8?q?Sgaqgb3RZTl1vZvGue60Ch9B679KERb1Fxlc+J0IZ0c/c2b55v07AXvFQUC+ZEk2m?= =?utf-8?q?jbkEGDR/A/6ypSCAKj9OxxYM+K+lr61g3uKAcGSI/8K3E2WoR3o/IXlevPKf2i0zV?= =?utf-8?q?r8f+fxXCFed7nnG2J1jLS7OU09AnFvONw9xW+ct8omEfDU2sWpitOVEG73DWRdQL/?= =?utf-8?q?ntFxN1Rz3q959paLQnjrYj/I0wQG4NBuMaFah6400eYJzhF6PJpNngwTPSTV1Cn+D?= =?utf-8?q?jM736z3ZK/S?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(36860700013)(376014)(7416014)(1800799024)(82310400026);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Dec 2024 03:25:45.1772 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 7231f82c-1bd7-4b09-8a0a-08dd15a5abda 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: MWH0EPF000A6734.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR12MB8416 Holding the mutex is not necessary while scanning the string passed into platform_profile_store(). Tested-by: Mark Pearson Reviewed-by: Ilpo Järvinen Reviewed-by: Armin Wolf Reviewed-by: Mark Pearson Signed-off-by: Mario Limonciello --- drivers/acpi/platform_profile.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profile.c index 4f5623fc27c09..45ffd85a71dd5 100644 --- a/drivers/acpi/platform_profile.c +++ b/drivers/acpi/platform_profile.c @@ -83,6 +83,11 @@ static ssize_t platform_profile_store(struct device *dev, { int err, i; + /* Scan for a matching profile */ + i = sysfs_match_string(profile_names, buf); + if (i < 0) + return -EINVAL; + err = mutex_lock_interruptible(&profile_lock); if (err) return err; @@ -92,13 +97,6 @@ static ssize_t platform_profile_store(struct device *dev, return -ENODEV; } - /* Scan for a matching profile */ - i = sysfs_match_string(profile_names, buf); - if (i < 0) { - mutex_unlock(&profile_lock); - return -EINVAL; - } - /* Check that platform supports this profile choice */ if (!test_bit(i, cur_profile->choices)) { mutex_unlock(&profile_lock); From patchwork Fri Dec 6 03:19:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 13896342 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2085.outbound.protection.outlook.com [40.107.92.85]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5168E190482; Fri, 6 Dec 2024 03:25:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.92.85 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733455551; cv=fail; b=Ni2i+cyGjQDHyDamMizNpRlL+S9tTSPXpWRRTc44lLhYzsh9gZ8Lzwo65VRmiHeEFKc3H2A2fw1yGV1e0WI/K1lFbDf+qsgVZ7zqIbgqDcDDUllzJUCoyitE48kQ/+oHnX21faMV/Avy75Pq2w3gKma++hEkISYmRDo1bbZI+kc= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733455551; c=relaxed/simple; bh=JewyXTxhFRqy6h34+YKrMpsgMeLgKwlZqckAx0I+7ck=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=GrVHY86w9Lh/rXFdIsbgckXWci2HsFHoQmWzf+hozRPb5VbA3Xd7fvg+OcwR6N+g4PAEe2IX6FIsuDNABH0MzwO1VE5AlC+iASDU6FLwio7RKQb6wVV4kksBcyIs6QlvSwlGZrhADxXH2ZdrP/Kp7qlQ5s6jzAUeyOJpba8Mf34= 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=YgXt6Y3Z; arc=fail smtp.client-ip=40.107.92.85 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="YgXt6Y3Z" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=AIzWVOz4BlAG3AupRYjg21REcNcznCvf0ncG1O+Y9Kzku979MPZUOx53MX6OKMELe5pl5JI39+ednSHKfELe+JES9kAqTkgX4ZcJ9bCTfPEFZpDlj+TzZ5zvOy7MppvrC7zNUwkV9Dy1DeBWoZdJRucdbd7YSIEOjOXkMq65A5I1LBvANLdwSXfdShboCl46zf4TZwiRRs5dIIORwGcyx2nO7O+oyqLWYeP9cMxQ8jxXg1aoHkKL7y+dWPc+fyke+OU8mwya9om9NFRN8N65QiF0rvlKcQhsCtJ9V3bE6hlfyDGCXh7FrsINQ0lU9pXqiG0SFvKGkZMfXcTV3wYAQg== 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=mCJJhqj3hV6GzcXguPbzpQO8UzCbUivxR/0JBYPdCAEcwo8mUkHKIXpoCaRH2WBINdPzxjLt2x+R0ezdxQS/elRQWeYgpJbrkOvknJcUSm1YV53OaKHngGdjgGQxQ+6b1/F5/T9UYmer1JYIzBcky/BL251HiuziIrWKO4lZhuSVss3f9zIv0R2dkCY3S7aeK2/wsX/78JehbOl7214isRnsFN29A59Z3Gu1IRMJh358eHYnACUGgeNg7SKiLLWsPwjBT9jSYESpYAse/6hX+XDiQLbS8qxhU2UIQ6ccxiwWnraf03bE8xDF4gIY70O+6ZwxLYByavUYa2bmaz7x5w== 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=YgXt6Y3ZUUpBN4ptRQrxW6dvM8CvjmuurXiLJvNUFu4vVjFz6bBi5NLoqDfAR4nFqMzwPZOC/RQivZp3dn/prdfReWFvoO/AkartYI6RHCSmkUZ2/251yaa5c4W4hFSqlbk5OFnxpTc3IPyiyE8kFqiq9FmQ9jCfYVmmF6igVY4= Received: from PH7P221CA0064.NAMP221.PROD.OUTLOOK.COM (2603:10b6:510:328::18) by PH8PR12MB7231.namprd12.prod.outlook.com (2603:10b6:510:225::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8207.13; Fri, 6 Dec 2024 03:25:46 +0000 Received: from MWH0EPF000A6732.namprd04.prod.outlook.com (2603:10b6:510:328:cafe::2c) by PH7P221CA0064.outlook.office365.com (2603:10b6:510:328::18) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8230.10 via Frontend Transport; Fri, 6 Dec 2024 03:25: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 MWH0EPF000A6732.mail.protection.outlook.com (10.167.249.24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8230.7 via Frontend Transport; Fri, 6 Dec 2024 03:25:46 +0000 Received: from AUS-P9-MLIMONCI.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Thu, 5 Dec 2024 21:24:21 -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 v10 08/22] ACPI: platform_profile: Use guard(mutex) for register/unregister Date: Thu, 5 Dec 2024 21:19:04 -0600 Message-ID: <20241206031918.1537-9-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241206031918.1537-1-mario.limonciello@amd.com> References: <20241206031918.1537-1-mario.limonciello@amd.com> Precedence: bulk X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MWH0EPF000A6732:EE_|PH8PR12MB7231:EE_ X-MS-Office365-Filtering-Correlation-Id: 84ae3787-458a-4eb3-c408-08dd15a5ac9b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|7416014|1800799024|82310400026|36860700013|7053199007; X-Microsoft-Antispam-Message-Info: =?utf-8?q?0dCvZPqkeRRqRCgfARAU1D5akjMApja?= =?utf-8?q?od977wJ2M9fJ/5hm4Hee7/N91gxCFpc8Z2mr4u+Ig8U1dV4K1CAddMH/vKBGjuXdo?= =?utf-8?q?NNXL228lkHU5jI+HYe6WgBzQEVsavDrrjOnY9CLrQoYxbHyCYWNI4ay3HfE8QmxPD?= =?utf-8?q?+gpk3KPw4PEYNlhZUWaACxGj4m0YFbpqF9LWPDT7lY8mqvTKNi70kTfOS0GCWUnhM?= =?utf-8?q?OP1LGyixFBKwS0ib11NEZrXbM3+JivLA7E6sShowWx6z+PBykCG4EF5q4C+D5IMkH?= =?utf-8?q?Nv0Y+rcgfCBFqYWtgSmkzVDQVv4Yyr2g3PUXjTOVVC6Dtpa+yV2csfkmxONRRVmX/?= =?utf-8?q?EUAYYX9fDCwbnJB8cFbkPtFl9KoVt+N1ZlAc5trv0zhYashx+Xd+xeYCgaxOuCUZk?= =?utf-8?q?OogG32wc1dtkWJ3hY9bnCxtsG0wsvLr5r/LveFraGxzzmv5Vp/XzVJbuTUerKFerX?= =?utf-8?q?RMVgk9oUeTH7lhmlj+thFMRwef2HlQbsdMRf4R+Eyhoar9NhwbFGYf8Q5UxakS2t5?= =?utf-8?q?0NWR9YXjQ7PW6Q/47HBw8t3fY20xd3/6oBBSgoOgqyHmQImOAcgf5M5zGT+2pTfdD?= =?utf-8?q?iDwaqFFbVI4GCPlfd+SJnxF9QZ9992e/hGhnrEGwGx3IzWZFu+83GlRpEzy9KGssN?= =?utf-8?q?N1Z5l7gp4AsLvqn1H4kxYWPCwpNwJl1Ybhj2IAJPwY0HkTNzfkR+a5dVZgtEkGP1n?= =?utf-8?q?CohyN2aYACHqGaRaWKcAOnthXKiisBNIMsy06HYRYHYflV+0XL88ZDYCAPYOg/9o0?= =?utf-8?q?bG+8kSFf93VTrzZB8wo0ZbfFn44aT2nXOTXXe6Aipg9iXVQx2Pm4ckCbzFgrHH+CP?= =?utf-8?q?jCkQyikVwyQWL2O/dtY3MsHW9rgOjmKqcAQk0RMKZVY07ufJOo+Mv07yIdk7hv8rM?= =?utf-8?q?nm9fsA+4Tnew4pNmMT/mzxXU7RKivOLu8JLlfzWLJL8kEvpnce5Z42FwosgcxdmBl?= =?utf-8?q?ddRX5+1iwRQ4sRR3Me1xBbXEKnYsYv42O8m6yQyuIyscYZXa2ZHToNizJR1IlbSVe?= =?utf-8?q?mS9tCn5wx+ik4tCTrrCzJNLhfJ32+d2xwz0QLDNCne6TAfWL/G7kf8XQZR4OpYcSS?= =?utf-8?q?ejTLyU4VOJsGpYZJopQJoGsW9KSWIJgOKYWqn+dv8udUKqEpM5hIt5WZ/fYnpa4FL?= =?utf-8?q?uvQ0jFZDDpINFyT+LDVcqDTcCrjcaI3+1kDlzIJRsY2pBXe9KzcHvV7GJY+yU4lMO?= =?utf-8?q?frct612ptLjTVC/cfjS+QOtFnlwxSu2b3BTTeYK2c1NENf9QLx2s6TEJUt1vn9fMA?= =?utf-8?q?GodvFR08flVfpZi1IR/CMJImuTsCqD1w6JPzbeVO4ZAZdSIkMJPGwnUT6gpC6R6rW?= =?utf-8?q?5bWG6chrISxvtTO0ZwqOWrJf9csjPn9vPe8MhhnFwZstrQPIJNzu8pVbcqadg+5ED?= =?utf-8?q?aiyOJ7Jp5cy?= 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)(7053199007);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Dec 2024 03:25:46.4748 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 84ae3787-458a-4eb3-c408-08dd15a5ac9b 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: MWH0EPF000A6732.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH8PR12MB7231 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 Fri Dec 6 03:19:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 13896345 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2076.outbound.protection.outlook.com [40.107.220.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 87521193081; Fri, 6 Dec 2024 03:25:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.220.76 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733455555; cv=fail; b=u/3W/jqYF7ooRdwPYO7y13VBeEWP9WFFXlm5q6yh6tftVb8GH+rqbL0+ENEAHuv+fjh8T2fQdo6kzA57ycT9KpqG4moczS1IILR9yTUiL1dTgvE2kdsL6QKXWUQV1Dq0VFHUkzvJSWF3Ky0DmWLFvjqArEoCQK4+OZsM9nhYXCE= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733455555; c=relaxed/simple; bh=/qmctw3i+Wn7MreEBUXF/bnvNkGTZZxbxd5qgq8OyVs=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=SK2rDeqsLDdri19n0yxwYvXEPwtbGpqizBlDfNwYpklifAzMgleStjqPTz1l4MXaELCCtPX2HBqZG7nkL8jlDetk5UBO+TjvQ4rsu9fQmYs+GaETgSZfFNP1g9p+bnWfOZb8qMaacQRO6KPGuYOTTey5dRniOe0uubxkSqSqxO4= 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=FAieoQTt; arc=fail smtp.client-ip=40.107.220.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="FAieoQTt" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=agOQ7weqXfaJ1IdVC3lR5bWT6Yt59Q4P2dNEuw0C4bHABOzyLCzqhg5i/moe6DnAvX7SUiRfD24a7n7jWoOzH+DLVCHQaM7MyqQIOVQiT4bv5/nCBmgl05UhyVWpfWIzxMNiJbwxW1XhF1OOpU8aa5R8OyaWk6csrhe1UuZ6gKD8cAdxkA969M3m/w+tMeTabyJUB9cuZJWbf65ynMHXY6HfAe5HsRaJjlfx+5fI4rn0Pt3FRiGL8hD0aQurXtmmJcQp3RpFIl4/eLW8z1aLn+OUhFDPw1ph8I2gCg2xuNB4ZAd8OUZYMHPkv8OuGqgyBqclm4LzUo45HKjHxIK9NQ== 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=Co2MBzyi5zV9sPvcG3WQUc/xYGa6VyD13j/k/x+NdOw=; b=Vj6g9OHZJIAVany2mN4ALQUDI3+BYYeHS8A7UTIr24o/IR1+KEW29Y7rUOXjfb9qLIdvDTJnvq8pUeRE2Jgdv+FraMp7rszCy+d7XMS+mYuKVmQ6XN5dFjQJpZrmxQlXAmHy9iGCycW6pH5cSz+56bjQG8GfdTlVB0zFsZVi+GwkCbik1AkeNoRo40ni9rNbO8H140WGdCuzvO7RHEZCKGqU0agFJrGqK0PMWrCYdjE/esn4KBMic1m817liVzHmEkWxkkOD3holzGHlw/7HBSlFWH78PtJ3ttrdGrxte/p+jVkCy/p0zAv+NOy2oiEf+vgULQyBd37iyYjIcyYrOw== 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=Co2MBzyi5zV9sPvcG3WQUc/xYGa6VyD13j/k/x+NdOw=; b=FAieoQTtwtuROXbDPE16w+T5kxoNMHscXSB9Cx3GByF5p3tuT0sT+N4DX9Z6GrsMc/D5hG3TD3Uatenz3T7eX1tNPB2+U5hdHEk66GJderuEO2CdFpW8rMUa8oGxnhOM/jfRQ1qFwJ6mimhrpBykxWu9V3esiFQACBanvtqkZ9Y= Received: from MW4PR04CA0052.namprd04.prod.outlook.com (2603:10b6:303:6a::27) by SA0PR12MB4478.namprd12.prod.outlook.com (2603:10b6:806:9c::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8207.19; Fri, 6 Dec 2024 03:25:48 +0000 Received: from MWH0EPF000A6734.namprd04.prod.outlook.com (2603:10b6:303:6a:cafe::1b) by MW4PR04CA0052.outlook.office365.com (2603:10b6:303:6a::27) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8230.10 via Frontend Transport; Fri, 6 Dec 2024 03:25:47 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by MWH0EPF000A6734.mail.protection.outlook.com (10.167.249.26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8230.7 via Frontend Transport; Fri, 6 Dec 2024 03:25:47 +0000 Received: from AUS-P9-MLIMONCI.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Thu, 5 Dec 2024 21:25:08 -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 v10 09/22] ACPI: platform_profile: Use `scoped_cond_guard` Date: Thu, 5 Dec 2024 21:19:05 -0600 Message-ID: <20241206031918.1537-10-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241206031918.1537-1-mario.limonciello@amd.com> References: <20241206031918.1537-1-mario.limonciello@amd.com> Precedence: bulk X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MWH0EPF000A6734:EE_|SA0PR12MB4478:EE_ X-MS-Office365-Filtering-Correlation-Id: d54a01b3-c9cb-4012-dcbc-08dd15a5ad31 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700013|376014|7416014|1800799024|82310400026; X-Microsoft-Antispam-Message-Info: =?utf-8?q?lYz90L5TYyp+B3BLYoHIsk0wJkSPzYa?= =?utf-8?q?eRSmna4cTLBrfyzKnuV88hHzw7HQ/cfLTwhELbDntse/2L9H583INmwqrAm7qJIXK?= =?utf-8?q?7bY47ELppN/lU6Wvd74dSTnFePcCL1iZKY/61tnh0HFBb7c91ckYj7XlMEKm06CLx?= =?utf-8?q?bW60hTBGoYatyDrp32Z+1r8uQHEutF0Wxkob2SJG+srO4W/3oyTl1hmtYIMcspUeR?= =?utf-8?q?Kd6yLgGBrh9L7m8FSR8V/6/BUkwkgcKRBx+YjcHHvMZZm+YWCvqglJmCNV4/NqIkb?= =?utf-8?q?DSXx9x8750p/5e7nUC49AlM/sbvm5j5Qb1p5152ea3NyiUSbSfosYPlRXRKw0Q1RZ?= =?utf-8?q?BfejucfTD8w2EbDsfh+G1Jmc6m6TjtTMoRDHFRfkMLZLd82NTq2Fd5XT4QAmhHJOu?= =?utf-8?q?MqTjBq91WnA1nTTRH8qWi1+u8D3vcoHbPXKtP0Ds8ngIGLLx+0tI1r1Fc7IcH+L7z?= =?utf-8?q?kjI6QKHpBV1H3hx08nZB8mo92tS6vlfEZhZQli1pxqLI9d3Sc3tFj9dH2RlVQ0P/h?= =?utf-8?q?42yYcvGVSNpIWMDWSIxK5zazGuPv4P6sv+xTIX5ACAplQSv6Wfqolyg2MQ9w4VknX?= =?utf-8?q?X/3/Pi+rDB7AI8d/0J0lJqZicCMUVSao3M4HpNe9Jx9ETOfWEqcpigZZtwSVpw6hm?= =?utf-8?q?BrBRoqUer4cNI8AoA/DRMZ6S4gU0HyZ+3BweZe0Fcr4nOpTZVv9z/0mhS30m1WnMX?= =?utf-8?q?W3GpMXuXg0EwanakxtWuJTqQrr1ai2u/glHZ5CNKGxfB4VoyP0PzI/eDNLyyjQxgT?= =?utf-8?q?BP5z3YrP1bAppimp1GLUACJaiV+GxJ6HnrNSGIfnSiLLDzdVmw2BKe5cx8aSnt6+A?= =?utf-8?q?LPa1A32zzcZbTY2jPpI45OEFoU1U0+ZWEikbny5dqdU7g4gNwYgBVU2l5B0E2tdBm?= =?utf-8?q?gHkDyXMyzfwwZ8qIPJl1/eSfT5J/Ho2zVcM53kzFbk6RNl0OTfgkHwehwzEOnyvWF?= =?utf-8?q?wO8Quu99/PS1+lsgU0P+QUwDHuZJEPeHJn6SHbq7a1lVomwUIt95Tu0LFMT8Ltn3w?= =?utf-8?q?s5bHrIuPw6HSw6CEdROJvQ5svDLDuJj6QAZHLvaDhJt75iQgU9zuVZuBjpDYOKVHO?= =?utf-8?q?mE1pi5eVhKFb0ff3ReRaO+GnMSaZ96jqC9w8NmskZyYAcW04WE68CFKNj7CpyWVj+?= =?utf-8?q?KzH2PJ2ajAH2GyTXo0/ztl40uFTiSTaYpu6hvZIAn8JluUjrHU3X1NaCH0/nE4nnh?= =?utf-8?q?i3OIH+vyG+JzkonOG47J6b7QMVlYsEXkFJgecCGYIaEFMUdwJ973xaawW9O5f0mFm?= =?utf-8?q?LNrkRptVwH6gbMstbf4sB3LJo++CFA7pNyYbXOKyzcTWyfTdI+VchJ6k9MeBBKKSg?= =?utf-8?q?9xY2QwgL3veDkrPkjyEx4jcBQ4jjz88ujDatn49QDiztG2ehTilX8/+xZgjfwnKH/?= =?utf-8?q?EfCentFck3E?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(36860700013)(376014)(7416014)(1800799024)(82310400026);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Dec 2024 03:25:47.4272 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: d54a01b3-c9cb-4012-dcbc-08dd15a5ad31 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: MWH0EPF000A6734.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA0PR12MB4478 Migrate away from using an interruptible mutex to scoped_cond_guard in all functions. While changing, move the sysfs notification used in platform_profile_store() outside of mutex scope. Reviewed-by: Armin Wolf Tested-by: Mark Pearson Reviewed-by: Mark Pearson Reviewed-by: Ilpo Järvinen Signed-off-by: Mario Limonciello --- drivers/acpi/platform_profile.c | 105 ++++++++++++-------------------- 1 file changed, 38 insertions(+), 67 deletions(-) diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profile.c index 9729543df6333..a1f0378f15e62 100644 --- a/drivers/acpi/platform_profile.c +++ b/drivers/acpi/platform_profile.c @@ -27,25 +27,16 @@ static ssize_t platform_profile_choices_show(struct device *dev, char *buf) { int len = 0; - int err, i; - - err = mutex_lock_interruptible(&profile_lock); - if (err) - return err; + int i; - if (!cur_profile) { - mutex_unlock(&profile_lock); - return -ENODEV; - } - - for_each_set_bit(i, cur_profile->choices, PLATFORM_PROFILE_LAST) { - if (len == 0) - len += sysfs_emit_at(buf, len, "%s", profile_names[i]); - else - len += sysfs_emit_at(buf, len, " %s", profile_names[i]); + scoped_cond_guard(mutex_intr, return -ERESTARTSYS, &profile_lock) { + if (!cur_profile) + return -ENODEV; + for_each_set_bit(i, cur_profile->choices, PLATFORM_PROFILE_LAST) + len += sysfs_emit_at(buf, len, len ? " %s": "%s", profile_names[i]); } len += sysfs_emit_at(buf, len, "\n"); - mutex_unlock(&profile_lock); + return len; } @@ -56,20 +47,15 @@ static ssize_t platform_profile_show(struct device *dev, enum platform_profile_option profile = PLATFORM_PROFILE_BALANCED; int err; - err = mutex_lock_interruptible(&profile_lock); - if (err) - return err; + scoped_cond_guard(mutex_intr, return -ERESTARTSYS, &profile_lock) { + if (!cur_profile) + return -ENODEV; - if (!cur_profile) { - mutex_unlock(&profile_lock); - return -ENODEV; + err = cur_profile->profile_get(cur_profile, &profile); + if (err) + return err; } - err = cur_profile->profile_get(cur_profile, &profile); - mutex_unlock(&profile_lock); - if (err) - return err; - /* Check that profile is valid index */ if (WARN_ON((profile < 0) || (profile >= ARRAY_SIZE(profile_names)))) return -EIO; @@ -88,28 +74,21 @@ static ssize_t platform_profile_store(struct device *dev, if (i < 0) return -EINVAL; - err = mutex_lock_interruptible(&profile_lock); - if (err) - return err; + scoped_cond_guard(mutex_intr, return -ERESTARTSYS, &profile_lock) { + if (!cur_profile) + return -ENODEV; - if (!cur_profile) { - mutex_unlock(&profile_lock); - return -ENODEV; - } + /* Check that platform supports this profile choice */ + if (!test_bit(i, cur_profile->choices)) + return -EOPNOTSUPP; - /* Check that platform supports this profile choice */ - if (!test_bit(i, cur_profile->choices)) { - mutex_unlock(&profile_lock); - return -EOPNOTSUPP; + err = cur_profile->profile_set(cur_profile, i); + if (err) + return err; } - err = cur_profile->profile_set(cur_profile, i); - if (!err) - sysfs_notify(acpi_kobj, NULL, "platform_profile"); + sysfs_notify(acpi_kobj, NULL, "platform_profile"); - mutex_unlock(&profile_lock); - if (err) - return err; return count; } @@ -140,36 +119,28 @@ int platform_profile_cycle(void) enum platform_profile_option next; int err; - err = mutex_lock_interruptible(&profile_lock); - if (err) - return err; + scoped_cond_guard(mutex_intr, return -ERESTARTSYS, &profile_lock) { + if (!cur_profile) + return -ENODEV; - if (!cur_profile) { - mutex_unlock(&profile_lock); - return -ENODEV; - } + err = cur_profile->profile_get(cur_profile, &profile); + if (err) + return err; - err = cur_profile->profile_get(cur_profile, &profile); - if (err) { - mutex_unlock(&profile_lock); - return err; - } + next = find_next_bit_wrap(cur_profile->choices, PLATFORM_PROFILE_LAST, + profile + 1); - next = find_next_bit_wrap(cur_profile->choices, PLATFORM_PROFILE_LAST, - profile + 1); + if (WARN_ON(next == PLATFORM_PROFILE_LAST)) + return -EINVAL; - if (WARN_ON(next == PLATFORM_PROFILE_LAST)) { - mutex_unlock(&profile_lock); - return -EINVAL; + err = cur_profile->profile_set(cur_profile, next); + if (err) + return err; } - err = cur_profile->profile_set(cur_profile, next); - mutex_unlock(&profile_lock); - - if (!err) - sysfs_notify(acpi_kobj, NULL, "platform_profile"); + sysfs_notify(acpi_kobj, NULL, "platform_profile"); - return err; + return 0; } EXPORT_SYMBOL_GPL(platform_profile_cycle); From patchwork Fri Dec 6 03:19:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 13896343 Received: from NAM02-SN1-obe.outbound.protection.outlook.com (mail-sn1nam02on2075.outbound.protection.outlook.com [40.107.96.75]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3E654191F74; Fri, 6 Dec 2024 03:25:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.96.75 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733455552; cv=fail; b=cmw9VC7ENTH0HgjCcfWEyI3F4Hho57aZbi9MToRg0mr3eJIk+F3DKD72989fvrtsyX12qphCHiEy7JGmqj63+KaySnx/Ka1CvztbtIW8xThvGtzmoRNdVxX36YRn8kCo44WS+ZB4L1sK2pME0sO0czD4WioIqFrqPt4rh3b1Fc8= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733455552; c=relaxed/simple; bh=8TwRzJ07cFwIQ2NazLrB11fm542Y4UBOvveW1k6rnJA=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=sKGiVW9yXYdComOiK5epUJBZvqlm+ZBb3ZSuWOrE7vMkup0YCZyqbMgbxkgDZWlGHCIT9o//cyZB09O4LeHLLlJtUzgxZrWPDRL4A2zy4AAyfyrbgECUVF8k1l19DPRPN+lW8EnXKKu8+2dWew8PPWwbc7ytOi7vb0U0fPQuhqc= 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=nZpj+5rj; arc=fail smtp.client-ip=40.107.96.75 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="nZpj+5rj" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=vFgL/waPV3PSJAWGquzWJ18fUIOiHOpIyvrLmlX94sFO+6qzKaUpxjqCWqASL8fimmeUm4aXAlvwZ7/Dz6Pfh7j2YV1jWyUaCiq/rcHvTClqXKUsDEB9yIeqT11pF5A+3oRInitnSe7WNg+G8G3IF+JuuTIfAGBJdGSFLoXNh95GKX+2bM8r/cTeQjTIcRZ4+Bc0Xz3v8R/W/FODl8J/AQVWAr9HScqqxI7iedP4aazYhltbdimX59+PRu+VAyiLnoqTzWtEtEHroqfnvon1fqiwTB/UIuKsSHjsXdc54kryQGGQ/1AqQKis+zKwTOylibbKRJmUcPJItICQ4YbQBw== 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=FNQgXoRM05ChHUpIFMIBYhAgUYaFBj/pG27lt9b+pes=; b=kd2OYMRKp0fOCtss0D7eFfCtCMbDgOUHOxbQdAXjGHy/RFHRCLtYxHb/Y6+K33pMcwwQMrxIVoegAp3OFqg7h5kpiGAMsiYgwm+uDZiurtThwMdFv1TkQxu9YKeDFhlWCp2f6ZKvCc+aV44voybxa0JeXd8eCczUaU8o9GX0TFQQFsyHWtvi/POv+WTA26chj2UWXpnUPyma1ENw9Utx2B75bLtqye6tHtTijLZRuFcb5mUfMCU696BTMr4VcnCbxrTHEztEvBVvw7TZkKoltJfoRVqrm+2Vs159Pd3gsUTwApsu7+dWl42LWpvdVo61eUw+6maI9YeiA5+BLifmjw== 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=FNQgXoRM05ChHUpIFMIBYhAgUYaFBj/pG27lt9b+pes=; b=nZpj+5rjRfzldwlkLqMwb6It9XDdRczcE6MX/0TjUXVVNDNN8YTHqY10MmEriTKpQJXCP3IvqkIdTYQGdUR4NVA/iErAtKIL7C375WWBR5A+zSSReNar/vBFyzDrK4C1ZC6nobLqkhXMIdfPkpbPiVW9k8x3+xU+/WLY2o3tLgg= Received: from PH7P221CA0090.NAMP221.PROD.OUTLOOK.COM (2603:10b6:510:328::25) by SA3PR12MB7782.namprd12.prod.outlook.com (2603:10b6:806:31c::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8207.19; Fri, 6 Dec 2024 03:25:47 +0000 Received: from MWH0EPF000A6732.namprd04.prod.outlook.com (2603:10b6:510:328:cafe::1e) by PH7P221CA0090.outlook.office365.com (2603:10b6:510:328::25) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8230.10 via Frontend Transport; Fri, 6 Dec 2024 03:25:47 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by MWH0EPF000A6732.mail.protection.outlook.com (10.167.249.24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8230.7 via Frontend Transport; Fri, 6 Dec 2024 03:25:47 +0000 Received: from AUS-P9-MLIMONCI.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Thu, 5 Dec 2024 21:25:10 -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 v10 10/22] ACPI: platform_profile: Create class for ACPI platform profile Date: Thu, 5 Dec 2024 21:19:06 -0600 Message-ID: <20241206031918.1537-11-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241206031918.1537-1-mario.limonciello@amd.com> References: <20241206031918.1537-1-mario.limonciello@amd.com> Precedence: bulk X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MWH0EPF000A6732:EE_|SA3PR12MB7782:EE_ X-MS-Office365-Filtering-Correlation-Id: 30ade6d1-c751-462b-bcc4-08dd15a5ad36 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|376014|7416014|36860700013|82310400026; X-Microsoft-Antispam-Message-Info: =?utf-8?q?Dley494L0BX8oyeXDhTfzDejDx90AdG?= =?utf-8?q?djQ5OtC1gFdpaB7hTbbFtBbgJbOU8kjiMrVPxr79Nx2pZm6aRcSsm4+qeSDMcbZE6?= =?utf-8?q?yo46hyNlNplp5XeADhfFN3GMSia/v9LDGFQL/Bcj0+mdsEa2manE+ZuKLlbhdhwuD?= =?utf-8?q?qZz5eP5SOngp6obFzUCbcypvwZG/nZln/9ZdKB0yAVlTSUZChEqiRkuataNX47oFn?= =?utf-8?q?3C08+1roFCy9/C7Jcuy1dOSqJASxDZhKkF/AkG3dokpkzN2yVqa8UaQb9EL6Z5siH?= =?utf-8?q?aKBaiGwK76U157up93rt2Wdff2mQAs/abveaqI9SlmtkUWcglcbZQ9xEn+pgWoNiU?= =?utf-8?q?FZw85aOtKpijeq/4OoSCOo1VQJZXQXGKAUiJasJ/5SejO/Am0YW5gguPTK21udkCp?= =?utf-8?q?K2y9iGSLu45tKIsHCfXHZU6twWBNRRFoueZrss+nw/iHsQIc+y2ffNZPZEh9DsayL?= =?utf-8?q?vURRJDnRv2bs18VXU27cxqkZo0MzBqFi3sGBj+P04xn7UUbVseUMWhqr9Li0Ih/QG?= =?utf-8?q?JAv7tJGMxLkbV8rQrL+7dFea6fvhGknMXXDK5WpJkltHS5b51BjVeHjlDwda4XXXL?= =?utf-8?q?sZijeOWvOZPCZQ7459bAuOHtRFVfgdIWHwmqyDSO8Fx0xfDw8ypTpLPf0nVzcs/Z6?= =?utf-8?q?20lZWE2HXNdljBVC3p68vHnuypGtF8evdndUJCuaQcqtiPWv0E7q/W+SEhJv4Lx8H?= =?utf-8?q?LG05AFEaCMYh/ZXH8TNs4FDsws5814VK37UHb2dhujP22b96CI0M0UM5mOXcIqvhR?= =?utf-8?q?jSsjCAWL3Hif1pgSP/6mLSiFiKJ3PnQUuSpmGaBM29T/tz9wq+xmwBngXlT4+ZE8W?= =?utf-8?q?Q0yFJtIKpynC8bUGIVfVV68NijzxaA4mgj5fdSGp5lSXhvvN+PutRSNmXn9NCK08L?= =?utf-8?q?IibawqmTFpKPMGTx1DuKKJy0f/lMT+Q6ZMhhn1nL/gjYMDuJDS1AA8951yjY/nTwr?= =?utf-8?q?fvY3HtAOY+w2jm9tyz1hbrUMAri53fWIpx3eq/gAufda53wC452dPiWEeJm+r5Cry?= =?utf-8?q?2nC+B1Ib2rqiWtyZlR20Qjcs4uRCuLS7Rvd76hrWdQa2SEmhMW/oJhuA+zp603c58?= =?utf-8?q?ZrT9E2wcHZsv5mAFg5EckpUMgT6k7UhkKvMvGZdUmt3RKzPBNWwn7iqAu6bRHbKT0?= =?utf-8?q?Q/ln7YRZeslBDhaBaR3xegbh8NDkI8wsvBcgUjJwpzcXJB404y8AoE/YmRzH2F0Pw?= =?utf-8?q?Vr7Hrdx4+X78C3iFsGRTYR2NU0/4k3o8jc0A94XmLXKBcqdCpw1pWTpF59f9eLZ/c?= =?utf-8?q?Zp9c+/rbDDPXcXmf6BzpNENejNuCaoRdRFhY8qPyLJ7T4ElZ0D2fBd95ZU4GSopVv?= =?utf-8?q?xKZOoFqBGzy8Wr/Zx0OOScbYlBsvXpiogXSjzio5W/Hj0ozvayHg+t1SxtYYfaC34?= =?utf-8?q?6ree1FRr3SZ?= 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)(376014)(7416014)(36860700013)(82310400026);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Dec 2024 03:25:47.4904 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 30ade6d1-c751-462b-bcc4-08dd15a5ad36 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: MWH0EPF000A6732.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA3PR12MB7782 When registering a platform profile handler create a class device that will allow changing a single platform profile handler. The class and sysfs group are no longer needed when the platform profile core is a module and unloaded, so remove them at that time as well. Reviewed-by: Armin Wolf Tested-by: Mark Pearson Reviewed-by: Mark Pearson Reviewed-by: Ilpo Järvinen Signed-off-by: Mario Limonciello --- drivers/acpi/platform_profile.c | 82 ++++++++++++++++++++++++++++++-- include/linux/platform_profile.h | 2 + 2 files changed, 79 insertions(+), 5 deletions(-) diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profile.c index a1f0378f15e62..11eb60b09bac4 100644 --- a/drivers/acpi/platform_profile.c +++ b/drivers/acpi/platform_profile.c @@ -5,6 +5,7 @@ #include #include #include +#include #include #include #include @@ -22,6 +23,12 @@ static const char * const profile_names[] = { }; static_assert(ARRAY_SIZE(profile_names) == PLATFORM_PROFILE_LAST); +static DEFINE_IDA(platform_profile_ida); + +static const struct class platform_profile_class = { + .name = "platform-profile", +}; + static ssize_t platform_profile_choices_show(struct device *dev, struct device_attribute *attr, char *buf) @@ -101,8 +108,21 @@ static struct attribute *platform_profile_attrs[] = { NULL }; +static int profile_class_registered(struct device *dev, const void *data) +{ + return 1; +} + +static umode_t profile_class_is_visible(struct kobject *kobj, struct attribute *attr, int idx) +{ + if (!class_find_device(&platform_profile_class, NULL, NULL, profile_class_registered)) + return 0; + return attr->mode; +} + static const struct attribute_group platform_profile_group = { - .attrs = platform_profile_attrs + .attrs = platform_profile_attrs, + .is_visible = profile_class_is_visible, }; void platform_profile_notify(struct platform_profile_handler *pprof) @@ -160,25 +180,77 @@ int platform_profile_register(struct platform_profile_handler *pprof) if (cur_profile) return -EEXIST; - err = sysfs_create_group(acpi_kobj, &platform_profile_group); - if (err) - return err; + /* create class interface for individual handler */ + pprof->minor = ida_alloc(&platform_profile_ida, GFP_KERNEL); + if (pprof->minor < 0) + return pprof->minor; + pprof->class_dev = device_create(&platform_profile_class, pprof->dev, + MKDEV(0, 0), pprof, "platform-profile-%d", + pprof->minor); + if (IS_ERR(pprof->class_dev)) { + err = PTR_ERR(pprof->class_dev); + goto cleanup_ida; + } cur_profile = pprof; + + err = sysfs_update_group(acpi_kobj, &platform_profile_group); + if (err) + goto cleanup_cur; + return 0; + +cleanup_cur: + cur_profile = NULL; + device_unregister(pprof->class_dev); + +cleanup_ida: + ida_free(&platform_profile_ida, pprof->minor); + + return err; } EXPORT_SYMBOL_GPL(platform_profile_register); int platform_profile_remove(struct platform_profile_handler *pprof) { + int id; guard(mutex)(&profile_lock); - sysfs_remove_group(acpi_kobj, &platform_profile_group); cur_profile = NULL; + + id = pprof->minor; + device_unregister(pprof->class_dev); + ida_free(&platform_profile_ida, id); + + sysfs_update_group(acpi_kobj, &platform_profile_group); + return 0; } EXPORT_SYMBOL_GPL(platform_profile_remove); +static int __init platform_profile_init(void) +{ + int err; + + err = class_register(&platform_profile_class); + if (err) + return err; + + err = sysfs_create_group(acpi_kobj, &platform_profile_group); + if (err) + class_unregister(&platform_profile_class); + + return err; +} + +static void __exit platform_profile_exit(void) +{ + sysfs_remove_group(acpi_kobj, &platform_profile_group); + class_unregister(&platform_profile_class); +} +module_init(platform_profile_init); +module_exit(platform_profile_exit); + MODULE_AUTHOR("Mark Pearson "); MODULE_DESCRIPTION("ACPI platform profile sysfs interface"); MODULE_LICENSE("GPL"); diff --git a/include/linux/platform_profile.h b/include/linux/platform_profile.h index 8ec0b8da56db5..a888fd085c513 100644 --- a/include/linux/platform_profile.h +++ b/include/linux/platform_profile.h @@ -29,6 +29,8 @@ enum platform_profile_option { struct platform_profile_handler { const char *name; struct device *dev; + struct device *class_dev; + int minor; unsigned long choices[BITS_TO_LONGS(PLATFORM_PROFILE_LAST)]; int (*profile_get)(struct platform_profile_handler *pprof, enum platform_profile_option *profile); From patchwork Fri Dec 6 03:19:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 13896344 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2053.outbound.protection.outlook.com [40.107.243.53]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0B35D192B8F; Fri, 6 Dec 2024 03:25:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.243.53 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733455554; cv=fail; b=WsSiAcSyJON+T9w1QD7hW+l4qYCs1fd9vJLBb0J8ZQR2lYZo0iba4S8jo/2kX8aUHSo8cv1LVvlR1OaXr0Bf0M/DINe3DHRtpJIZnqK0BzQFNbCCKY8Msjdt6EDcW/ipHZYNc1C1BxWC8ZXRQrQvo2CSN0wDTW1HlA7enB7T+3U= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733455554; c=relaxed/simple; bh=f7rRTPdGt5m3xhvPy2bnOdtnYov7yveNVfhJizBpXq8=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=S+qHgz1X8wd3RahYJkacVtGMDLjAOrwVOoXzh9SG6qmJI0O6mmzEgAKtNXLwzEGBq/79So8WSKgvaKM7+6Zq81xL/1WfQRl4R+lvhzEqBYp3fqIB9RI0+9MWD1D5JYJ1kwqb7ibfwm9NfJwgfYaxKXG7/CRA87a90Ua70taY8oY= 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=KnE0FnnH; arc=fail smtp.client-ip=40.107.243.53 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="KnE0FnnH" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=r83Swbh5CmK1yo3Ao3hDxTx5rf9spmoXzWL+n1KhvWypsI23wcfgpAHyD+6+8f/mIOYqWj+YdSFgtrk86ED4m0FCUs5sOOmTHvYAY9HOMP2lr6EIvKNW0ANmFET701Cdf7hzwNYxSx7dZlzqbMV3nOjs8zoLEw/A46f7Ky9j9vaQ5wpoBmUkFC5TR/Rov9wey4LHcPpi38KYNpVa/FsPM07Vo1ofYcdQCfN8BwWLh2vr8n7JfRkq8pn+jLcwJGX5ajd48/qLvqlEYJlSIqfOyhHBb3WI7bAaHNdai8n0rCJmvlpPd2SHUUozGiBvqLrINOJR0GSFv3YZB/cGWu2cxA== 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=wHTCX93LZBSL0mOWadvLK2NWPAiijv6GOjt7h8l+o/M=; b=hLd9eaWZDGg2Y6EhTWITiDZohOvz+W+0UA7OPZ9aUxhlB629pNZTWUpCof9foCS2Xg8lBDgOdLV6+8fJ5pb2Zrg/65WWaCmv6ygoXjCDgObBeK2bn7ROsBYw77+8GsoTjM+f4FwJeht9ZSYjYzi132XXNfvUYvm+U3hGdHnPO2E+Wp7uJmMvq2kuH3OPw4fmiYEGYfOaIoYfjUzmvO/g9jEuJbtu0gTr7NYcgU6dYNT9A4zwgT+QL2v2kCNKwmuz7BagI7zr+RzuzWfNDDoRvHN7OkRyWc8+jWUmJwEaPOvO0hER2H6vHGzAkqvYoDZajSAEWpIH8TU2OLW3PEzgog== 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=wHTCX93LZBSL0mOWadvLK2NWPAiijv6GOjt7h8l+o/M=; b=KnE0FnnHtFU6POyPPktmHIXm6XQEWvn/d4G2W+ospuoQkqorKINdk2bZ4cdPHgyPOVtgLLPgPJfVaXIuKZ6Jcjwg8ume3/ou18LX4DjK2ZOqZ1kcpCBDp8J+pN/R3f8wwF9GcS2TxLtzl9r9J3qNGXILmfD5cxIqOJyTJHBZG78= Received: from PH7P221CA0061.NAMP221.PROD.OUTLOOK.COM (2603:10b6:510:328::15) by DM4PR12MB6160.namprd12.prod.outlook.com (2603:10b6:8:a7::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8230.11; Fri, 6 Dec 2024 03:25:49 +0000 Received: from MWH0EPF000A6732.namprd04.prod.outlook.com (2603:10b6:510:328:cafe::d3) by PH7P221CA0061.outlook.office365.com (2603:10b6:510:328::15) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8230.10 via Frontend Transport; Fri, 6 Dec 2024 03:25:49 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by MWH0EPF000A6732.mail.protection.outlook.com (10.167.249.24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8230.7 via Frontend Transport; Fri, 6 Dec 2024 03:25: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; Thu, 5 Dec 2024 21:25:12 -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 v10 11/22] ACPI: platform_profile: Add name attribute to class interface Date: Thu, 5 Dec 2024 21:19:07 -0600 Message-ID: <20241206031918.1537-12-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241206031918.1537-1-mario.limonciello@amd.com> References: <20241206031918.1537-1-mario.limonciello@amd.com> Precedence: bulk X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MWH0EPF000A6732:EE_|DM4PR12MB6160:EE_ X-MS-Office365-Filtering-Correlation-Id: e57dc12c-ce64-465b-647e-08dd15a5ae01 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|7416014|82310400026|36860700013|1800799024; X-Microsoft-Antispam-Message-Info: =?utf-8?q?hmBC6uTwf6Ex+2IeKpthRm7tZhyvaNg?= =?utf-8?q?GCPpebU6nGTM9zHME2L5pNAZwuC4hOIFr7jerj2gn1JCPAmu7liNHsvHQfOHWJS45?= =?utf-8?q?GbvB0hy78shsfLl0IWP+OmYH9plbEtJ2SvNGCKe5Yjt5vRCD24+OlMsw7Elgvw8uh?= =?utf-8?q?1hMtDS6v7TX57j7ZjUnEOSUKIFm1e6t/ntjyXPLB/SYj0iWWT7PPmu1yEiB0WgH/5?= =?utf-8?q?3s6eJ8eQhdJlv/j4p0vIYUhUgrMQpGG4F0ZFiRe1geECrE7uLWxz7Tv4cGuSjFZtQ?= =?utf-8?q?+Uw1X/9BzNMgdvQHU8f/F7o4fhVWtfbaf6wImQQ6SBrwADkD5On6m3NFQtuDTeRa5?= =?utf-8?q?YYzFnmi7ludAVjpuelogiBMND/pbfW13sMFKeAXvhiNXV1w4SB1UUTHimWIhNpVps?= =?utf-8?q?eX52xcOJMZDDgqqCD5n6z6PsETQ0xK02+fNouMZ/bsPNKy9d5N0jzLC5bvQBdbh8/?= =?utf-8?q?hC2nPhy1MvK5YZWT0LfhWEkJZTbUD0oTXvKlLCjyU9otW/pWb8vC5qDP0rWh1ISnh?= =?utf-8?q?+yC+5wWwEGIz/gWW0l+biaJxHxQeHBMtx/VZc3vb+RZULDgsRu2EnSzRNFYdMqbOO?= =?utf-8?q?O5PKX9iMhAJGhUoQAv4DtmSpkcuybdJmxCVHCRcqtNoSEHEb69mT0wLpG/PL8+bT7?= =?utf-8?q?W3e1DyIC3zt3ePhFt3teyJTM06dGypY+iBkqYL53kPHj6eihCVFdv5cTG6y2EX9n2?= =?utf-8?q?Fnr82UlEcEWVVjgDFunlFltiS4d8KT1GX44XZ+fc/q8+DLMafLw+Dshsiav3N5B/U?= =?utf-8?q?e4VnxpFl/Dd95mOeGw1TwR2uEGIs7IjvBV0a95s+uDwrFBJFyfg+aRzdjDZHL3snp?= =?utf-8?q?qViyckjdHiNMUfKvwjjUwS0JRgHThj8JT6b56MtrgPjmQVMhSaH6wcYrpeiE/iTGE?= =?utf-8?q?wWPvrikFypHavqciYZ4PKP2jydOXvijHIKHU7FaYPDckdAif6SlghAM2+5LkF7PUq?= =?utf-8?q?Y+2V1FTavtPgPw+8vJrrShph/E85mZNln3cj9gvhKWRzfHXdBIZdQ07/sPX75TBsw?= =?utf-8?q?54Lhlfv+jYuIBFPz/XP5yFTkbcdExpIY0JEjdYhx9ABotjaBSx6iPwbob3FjGtRKr?= =?utf-8?q?RzLXO+EgfhfQk65hbg+lok2kexPhgVD7wfx9ZB6txRyfjyAxzegZ/eVYLFrMw0pU1?= =?utf-8?q?+x3hHxTJANZcBkTwgjpl4Omf7gR3KNV/lc6RidJzex9bAujn8aNpULTddHXz3rC49?= =?utf-8?q?7lpSNvNSlmqluPVz9taEwUg5876n703dcHofpQc5+mQlHAGswyvfeDjcqePD9aU7R?= =?utf-8?q?5yDCFpFQc21udkdW1NE6u0ssgX4YPhTSOQNZkpzuMKuWBhLrx07di99cxK2xL0YIz?= =?utf-8?q?Q3+KHJEW5cYyE0hQ+LHrXF8FsTph4MnG34cUmV7bDtHZReA6obA4XP72bm29DyPVE?= =?utf-8?q?DwH40PU16DA?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(376014)(7416014)(82310400026)(36860700013)(1800799024);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Dec 2024 03:25:48.8029 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e57dc12c-ce64-465b-647e-08dd15a5ae01 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: MWH0EPF000A6732.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB6160 The name attribute shows the name of the associated platform profile handler. Tested-by: Mark Pearson Reviewed-by: Ilpo Järvinen Reviewed-by: Armin Wolf Reviewed-by: Mark Pearson Signed-off-by: Mario Limonciello --- drivers/acpi/platform_profile.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profile.c index 11eb60b09bac4..49a8bd6e97ece 100644 --- a/drivers/acpi/platform_profile.c +++ b/drivers/acpi/platform_profile.c @@ -25,8 +25,31 @@ static_assert(ARRAY_SIZE(profile_names) == PLATFORM_PROFILE_LAST); static DEFINE_IDA(platform_profile_ida); +/** + * name_show - Show the name of the profile handler + * @dev: The device + * @attr: The attribute + * @buf: The buffer to write to + * + * Return: The number of bytes written + */ +static ssize_t name_show(struct device *dev, struct device_attribute *attr, char *buf) +{ + struct platform_profile_handler *handler = dev_get_drvdata(dev); + + return sysfs_emit(buf, "%s\n", handler->name); +} +static DEVICE_ATTR_RO(name); + +static struct attribute *profile_attrs[] = { + &dev_attr_name.attr, + NULL +}; +ATTRIBUTE_GROUPS(profile); + static const struct class platform_profile_class = { .name = "platform-profile", + .dev_groups = profile_groups, }; static ssize_t platform_profile_choices_show(struct device *dev, From patchwork Fri Dec 6 03:19:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 13896346 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2087.outbound.protection.outlook.com [40.107.244.87]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1EBEF193438; Fri, 6 Dec 2024 03:25:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.244.87 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733455555; cv=fail; b=lITz6vqEPZV+xZNAfHQyV8+loHF6fvjfHWLUQf66z2e+Gll4hniti4K594GUlaBEkl0Uypzrs4JLbUUmmiQ+Gl/i1GBSzdmLQNyshp+u3QXE8J8mB0yE8NRHAH3dq3zHhy2SSb17GiQw/MTl0KH8IcozU5x8d4DGM9SCyHjnKbo= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733455555; c=relaxed/simple; bh=VVG53fkGNnXY44nCUBwfGzttiX1QGh+kxAq81MkR3SU=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=LAKAwn2TZP1G5uApROyc/9jZMiybY/YMYQuTCU+PlMdyCbSgA0UQGJLzaHX2NSU8l8qNF/PqQhzLweRhC0kWmJDdhND7UPKcB7fl1/BiL6zxI4gBzI8wXQIFEvQNVspKdwbvE5S6UbBd4htdvzggV4679uANVnHvOjZjnhkiCMg= 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=h6xEdGw3; arc=fail smtp.client-ip=40.107.244.87 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="h6xEdGw3" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=ipLOJjMpLarlk6hWhy9wWBQA4WXr+UUfpfTbfaqjykwciiIayGGOIdn/Xwkyd55NM4cJ3juEIEJeurwJXN4gBjIlgBv9O6ehM7inu1Iji+8mEQagT9DhcavCcZdjvBxW+Nb41vjCC20wy4HJhPrZf3j+EB0cnOpvRrms3IZCsLjzT3/C04Wez6U5vSMKscB9Ziyp3C1/xZ0Jpcsk6hJVyKBgqcxBtORK8t5Y500L28pQRbK8jf37wBTTfPvq68wvdZW3RXlP6mVelUk3xOclOZseQVxASFVH9LFuC5dhmX3Eq0a1PFYU5hseo9gRGde6kOHvyC1HVh92NGh0vQspDw== 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=uBkt/mhA55cPaDFTq1KS/KVyCxO6SdjI4cviXYntBT0=; b=Tiwt1aWsEmgbuyWgPluOgaFdTAsJKaXfyVu+DMN8s8yaiD6C1ffTlIcoG+pLaUy1LGb7jmo2SmD2UJyjETUIazU53LKzbtCFltNMIDsPDcqhiWzceJS3QW0B6BQ1Sb5P3SyJfHNMR/EWHyLHtVIsEgGEnlXS1oUzkSxufMWu6LdomI7Xfl6WZQUXg9vMR2S5aBwccQ3wSJMp+4/JgDuSQKjI+kYK9AZGuWjKC9A9CQBSZWR/paairdF39Vyv0pZf4Lf7XCdvupH0gluQipFHlmRxXuDqd+GIphhPi6mS1mMTA3J7rlYiYGn8EOlF43MSU1eyZQ1LIBHloTGV3jiYLg== 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=uBkt/mhA55cPaDFTq1KS/KVyCxO6SdjI4cviXYntBT0=; b=h6xEdGw3IgvnZTs0JhsqsLkoiuxNLxFGidNR8jpnfLkZm8rW7vh7CkTm3hlXeqmABTdEJN2i17CDC90bj/I9Si5zjjaDT9m4db5PfTPTHS7IZ+JhzecjckaHdH3p9zRiTowfL9u2srq0da6iPtB09UvXDz1g8rxPeAX5+p7rrh8= Received: from MW4PR04CA0053.namprd04.prod.outlook.com (2603:10b6:303:6a::28) by PH7PR12MB7164.namprd12.prod.outlook.com (2603:10b6:510:203::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8230.12; Fri, 6 Dec 2024 03:25:50 +0000 Received: from MWH0EPF000A6734.namprd04.prod.outlook.com (2603:10b6:303:6a:cafe::5e) by MW4PR04CA0053.outlook.office365.com (2603:10b6:303:6a::28) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8230.10 via Frontend Transport; Fri, 6 Dec 2024 03:25: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 MWH0EPF000A6734.mail.protection.outlook.com (10.167.249.26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8230.7 via Frontend Transport; Fri, 6 Dec 2024 03:25:50 +0000 Received: from AUS-P9-MLIMONCI.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Thu, 5 Dec 2024 21:25:46 -0600 From: Mario Limonciello To: Hans de Goede , =?utf-8?q?Ilpo_J=C3=A4rvinen?= CC: "Rafael J . Wysocki" , Len Brown , Maximilian Luz , Lee Chun-Yi , "Shyam Sundar S K" , Corentin Chary , "Luke D . Jones" , Ike Panhc , Henrique de Moraes Holschuh , "Alexis Belmonte" , =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= , Ai Chao , Gergo Koteles , open list , "open list:ACPI" , "open list:MICROSOFT SURFACE PLATFORM PROFILE DRIVER" , "open list:THINKPAD ACPI EXTRAS DRIVER" , Mark Pearson , Matthew Schwartz , Mario Limonciello , Armin Wolf Subject: [PATCH v10 12/22] ACPI: platform_profile: Add choices attribute for class interface Date: Thu, 5 Dec 2024 21:19:08 -0600 Message-ID: <20241206031918.1537-13-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241206031918.1537-1-mario.limonciello@amd.com> References: <20241206031918.1537-1-mario.limonciello@amd.com> Precedence: bulk X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MWH0EPF000A6734:EE_|PH7PR12MB7164:EE_ X-MS-Office365-Filtering-Correlation-Id: 81006754-bd3d-45f3-b5fc-08dd15a5aed0 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?9THWBWQbnYm9QOFg4zz8txs+lzuFGiD?= =?utf-8?q?7WSm+2rGTSdUhmK4TVXZ/eMmxmLB+5yXGJohF/ysagDigyyU2LLo3+4myfp8LhQ/B?= =?utf-8?q?qIF7ITeaeYfY71XN9ub9GP3ZF1P9ZqH7V+wBbvhr2IGLNGxS0hNWBIwLLWlYXCC2r?= =?utf-8?q?FjzT++ENBx/N5ET+wQb+5Q1Vmk5+8URhs59bzvyJwZVkf1mIGqSkjeimXQ5yD61Oj?= =?utf-8?q?zD/7EExFlqIm1GC839NEStImk04m2h7qPdmc5nWcTBHH56ybVLw0qXDitbaKCGucj?= =?utf-8?q?3oEPFKhjDTleA4kqHHsaEp+3RWCU1bWKnoinKP3CVD2e1GgVuvIF6+Z9oKdWyBdS7?= =?utf-8?q?hsQ7DXfvphPBWVY/o6si7KNYVh72XnDkW7OrB4Ixgpbk4JNZj0sXh+0Muv+bA+bWk?= =?utf-8?q?CafvxT6cACrVGEFwdqNwzzyJZCBC8R8EJZnjcD3HYjRwTkTSKvv88sSq69JfE9Oeb?= =?utf-8?q?Oq4g1l6WQ4lNUqtCDS+AvIFYbGOYCLzErp9keiTGXaAbBok6HHQtZFwNsF+IqbdAz?= =?utf-8?q?uDHG7Jmgst3z7cfKMjA4+cW+3UC/KyEUcXA7449+VkEYx+Az9eNd14kw5qYOV3BCs?= =?utf-8?q?1evhOU5QErgrbKp8CJZyYhKCPcal5vN9GFOC3/IjpIK8aJXQb9YsV7OmkxAODnl7e?= =?utf-8?q?p8sjdl2W3OZQI+f1ILCvfpmRk4ZZkpA7Zv/p840ueW79nk0eKku+RlpmSuca1J3hE?= =?utf-8?q?2klOfQOop58nkdGacDbrOP1ErlTNzQsVpJNrZ3LW0Z+EsaFaQ21Xd8PvGfE2Zbc4t?= =?utf-8?q?150DkDVZt+ub2NsOVvlh/f/KP0mH5mO32gg95EsliHhT6Lww1na+2cdJtiv9sm+Qd?= =?utf-8?q?DMbS4z7JqNrO/a1M0oPkJMLp2wBvLrtQKaY1yxQUdVasOObmwioHnEAWuqwmAC8Xu?= =?utf-8?q?lWdMnYjVR7FRqEjMo8Q5kcTULy5WSvj+mRErMUS6dRMrTFQvz8LlER1z1F5bRdVg5?= =?utf-8?q?ewD9DK7E9fzbbQ6/UQwL4HO6oAjRaRx9asfcJg/o2LiV810kHljCKLgSwJA76ZqG4?= =?utf-8?q?BdBsv7NGic4TlfZKPScc/OSaw0wt5BYN7XcKPbz7Ta4sgVHsYjq1K/4X3Smu9Grbd?= =?utf-8?q?2Jd4ymCibn2lepVdOj6P90KM/hTgto6X5rh1C2ijQPRmfwqGs+JzU5NKEibR5tsBi?= =?utf-8?q?vneMcjm/GPC3+yGHFCG1n0AxTbtsp/fPaAVQpYR8aZm7mDE3cws/Rsd5hfY/Bm4eh?= =?utf-8?q?PQ0wUehbXCjKMmNxj1b38inQtjEAlwJo8J8lHFfp0gQt/dw2odk1AUdureFLhOin8?= =?utf-8?q?vrtnIhI7VLlQex4CyfIzj3hwUJtjp+tYSorVaY2Zs+2aAbxDidB+gQA7tlyst5Zly?= =?utf-8?q?kzvO/eOXBW2nnhZkwD8DdzoVxBUJ3QIrXfKteNfrdZpwN4SwCIhy1ScQNycV0aGPI?= =?utf-8?q?GcDx4XfWYa0?= 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: 06 Dec 2024 03:25:50.1616 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 81006754-bd3d-45f3-b5fc-08dd15a5aed0 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: MWH0EPF000A6734.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB7164 The `choices` file will show all possible choices that a given platform profile handler can support. Tested-by: Mark Pearson Reviewed-by: Ilpo Järvinen Reviewed-by: Armin Wolf Reviewed-by: Mark Pearson Signed-off-by: Mario Limonciello --- drivers/acpi/platform_profile.c | 41 +++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profile.c index 49a8bd6e97ece..885f41bca6c25 100644 --- a/drivers/acpi/platform_profile.c +++ b/drivers/acpi/platform_profile.c @@ -25,6 +25,28 @@ static_assert(ARRAY_SIZE(profile_names) == PLATFORM_PROFILE_LAST); static DEFINE_IDA(platform_profile_ida); +/** + * _commmon_choices_show - Show the available profile choices + * @choices: The available profile choices + * @buf: The buffer to write to + * + * Return: The number of bytes written + */ +static ssize_t _commmon_choices_show(unsigned long *choices, char *buf) +{ + int i, len = 0; + + for_each_set_bit(i, choices, PLATFORM_PROFILE_LAST) { + if (len == 0) + len += sysfs_emit_at(buf, len, "%s", profile_names[i]); + else + len += sysfs_emit_at(buf, len, " %s", profile_names[i]); + } + len += sysfs_emit_at(buf, len, "\n"); + + return len; +} + /** * name_show - Show the name of the profile handler * @dev: The device @@ -41,8 +63,27 @@ static ssize_t name_show(struct device *dev, struct device_attribute *attr, char } static DEVICE_ATTR_RO(name); +/** + * choices_show - Show the available profile choices + * @dev: The device + * @attr: The attribute + * @buf: The buffer to write to + * + * Return: The number of bytes written + */ +static ssize_t choices_show(struct device *dev, + struct device_attribute *attr, + char *buf) +{ + struct platform_profile_handler *handler = dev_get_drvdata(dev); + + return _commmon_choices_show(handler->choices, buf); +} +static DEVICE_ATTR_RO(choices); + static struct attribute *profile_attrs[] = { &dev_attr_name.attr, + &dev_attr_choices.attr, NULL }; ATTRIBUTE_GROUPS(profile); From patchwork Fri Dec 6 03:19:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 13896347 Received: from NAM02-BN1-obe.outbound.protection.outlook.com (mail-bn1nam02on2070.outbound.protection.outlook.com [40.107.212.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 A946F190486; Fri, 6 Dec 2024 03:25:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.212.70 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733455558; cv=fail; b=FRpSayUc9j3SVCwX6MQwtqHMulU4GYu5IfLtPqr1MN9pGijOPOJ3VqoWIjbrmyZyXuAh7GLWq0BCCC5hFToC5lLqLj5aKoLtVm3x55qvmcbA39j4He7+kxzBsry7/3wa6oZ3P+Ayoc9c4Dtf43NoO9Le8P3n0OUkLxp7biUWh5o= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733455558; c=relaxed/simple; bh=8j6IZ3JMmu+41jCwPsnsdKYImZaIW8m1wBbpxlRKS84=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=s7SirOF4pt98nQSj0kMxBIbqFiTX5ylr12Qo2Kv6t39x4vovpLXBy7Os1njsOAfM1diP46i+42Fj8YC63RkAfJ6LJKnSNJuwWZuTHiLMlRSH1RfuEIZM83uBZEsh9EX815XU83VgHcnHbZmZxAsmb/1OwEU5AKBzFQYhsm+lnjQ= 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=Ypm3eEFx; arc=fail smtp.client-ip=40.107.212.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="Ypm3eEFx" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=rzFqoOdsfBmlM2zSn/A0gZApBQfoV+KEv7Su05/PhOm3jundxGtA1ecvHFjkDsyP86BWteHcChmzj3coU0OdEr3tbmvGi51pTPvF2xlANQFXnJulW1IHX8wzdt/TjS+z2pULRfKctt6TJH7sZ6ptmikOrGADl0Tey5grMdSWzUtoeDresgpqNF7/DmTd5RoNcD/MC/ZAdhX48skd+KD9/1fRrQp64msDF2d0TTsVKzSJEgFGNSJOP2BRjRjnXKV7m4tpXozd5L/eYl6UVg19kxWrpzf/VTm29je8nhdJdegRblRddoiqLKSPVJrnP31E5Y61TXk0Knnrbf8qPPPuDg== 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=twy81q1cppJjIV1vZtEfQ96qEDUlzNcYT3qqr3gwMdQ=; b=hdPGb6ihAzAY5DDdchSh2DUKAjJP42IFsIem5pzrseIC7iuBaV7SHzpeHRtJP5t4adn9HlmZYkFYgmOGLUiYNEiMHQJSG0ziQsRipYd05Cc78CzgzxrEmcToa2rik0N2zcJaCMJS3BzHTbOSiaa8YWsl57lrOpIs2Zs9tdK1XVhDRAmObvFPb5q12zBEMvCMw/2UVkiN2nAvnqSZLSXWNzrI0zN/PoiRxs6i2wl0i6/VQOhFL5WZs0VkkA+BDUUuOM+BGTUzGTnyK+fHbmendqAkURAgCY5bey0kgWdKfrfhDuqFKm5GeAcq+9SGdTKqoDHBguYBjw3SUsr7zVLh6g== 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=twy81q1cppJjIV1vZtEfQ96qEDUlzNcYT3qqr3gwMdQ=; b=Ypm3eEFxycVgPeZwPcWjbgjgRHuNg07164VaH9x6DvYiTEZ9ByqezclTFZ1uzhjXVshWyEeOjp6s2Kud8HalmBnaSEMyv0J9PHRzXNq6Bvcx+8fzBP5lvm9n2y3xPRSXT02VZY5148RZGmpnolftVqtwGDmuD+qAh04aCKryzhg= Received: from MW4PR04CA0049.namprd04.prod.outlook.com (2603:10b6:303:6a::24) by SJ2PR12MB8159.namprd12.prod.outlook.com (2603:10b6:a03:4f9::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8230.12; Fri, 6 Dec 2024 03:25:51 +0000 Received: from MWH0EPF000A6734.namprd04.prod.outlook.com (2603:10b6:303:6a:cafe::83) by MW4PR04CA0049.outlook.office365.com (2603:10b6:303:6a::24) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8230.10 via Frontend Transport; Fri, 6 Dec 2024 03:25:51 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by MWH0EPF000A6734.mail.protection.outlook.com (10.167.249.26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8230.7 via Frontend Transport; Fri, 6 Dec 2024 03:25: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; Thu, 5 Dec 2024 21:25:48 -0600 From: Mario Limonciello To: Hans de Goede , =?utf-8?q?Ilpo_J=C3=A4rvinen?= CC: "Rafael J . Wysocki" , Len Brown , Maximilian Luz , Lee Chun-Yi , "Shyam Sundar S K" , Corentin Chary , "Luke D . Jones" , Ike Panhc , Henrique de Moraes Holschuh , "Alexis Belmonte" , =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= , Ai Chao , Gergo Koteles , open list , "open list:ACPI" , "open list:MICROSOFT SURFACE PLATFORM PROFILE DRIVER" , "open list:THINKPAD ACPI EXTRAS DRIVER" , Mark Pearson , Matthew Schwartz , Mario Limonciello , Armin Wolf Subject: [PATCH v10 13/22] ACPI: platform_profile: Add profile attribute for class interface Date: Thu, 5 Dec 2024 21:19:09 -0600 Message-ID: <20241206031918.1537-14-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241206031918.1537-1-mario.limonciello@amd.com> References: <20241206031918.1537-1-mario.limonciello@amd.com> Precedence: bulk X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MWH0EPF000A6734:EE_|SJ2PR12MB8159:EE_ X-MS-Office365-Filtering-Correlation-Id: 100f811b-ac8f-48ea-ac09-08dd15a5afa9 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|36860700013|7416014|376014|82310400026; X-Microsoft-Antispam-Message-Info: =?utf-8?q?Pniu4TIJjHWl1xOp2uWfDKWUxhnDeZ5?= =?utf-8?q?TbA5ZxJuPL2QRpXusLZn0bOeSIJre7vOCovpAowVnzLs0GJFXMJDwfIIrB+eoh1Cu?= =?utf-8?q?xHMHBEdE5yZmaFVWWdSHUI6f9xvsXAYuscvtaYkbfrVMpi6YNsaSmqOj6I/CuojD0?= =?utf-8?q?0m/IIgRLqPoDwUU3gO8q+27YEw0PPo8igZF49MQgDtQHSeoFASlXcDgmoSnf83M1f?= =?utf-8?q?ktwMBVrUj3WxbP+yec4dxfHhew8Xkpocfn0nFO6i9GgSAuNQPYidY36u2/D2CiViu?= =?utf-8?q?GMsaSN6a2RpY1uChwa938fcIF2kZkm4qd+1jj4s4Ybh60qyhnWiRFkEJEkesNJC3s?= =?utf-8?q?JAdr3afXBkOSYoRAs18rxbOga4GlaGj3GwvwXP4hmHIU+3+EynXAypsO8vSexGQju?= =?utf-8?q?UVjGXPaC7zt90Px+DQk98ABa2HdjU2s5n4WBWpZQCZTI5+rFswQc2EOT5IuyJjuIr?= =?utf-8?q?4g/QqP5pgc+v+3qi37aoDNBeo9dFP8X+w38KQgBA0bJ285ukz8q9dwiB6S4Q/sZ1Z?= =?utf-8?q?pMRHDYHn5UlpfmFTGZSnL0B5KTW1Y9r1HbFYGRxGpzxNcmlr8Kv/dIdugtTrqqaoM?= =?utf-8?q?GW3y2IgAtL4uyumo2g5qc+v494P6YJ0o5z3almHLBh3R/QpumR/sBlZwhyWqDxgjp?= =?utf-8?q?coyvpqjenr63fNaWlNm75GAe7aqudlgpbkP0BXq5hDinCqPzunZXv4dTOSiZDOYrI?= =?utf-8?q?a4bd1D5Hi6jFU+Wrl7Je3eJ3Qem/gY4rqBtPqll1eYgBLp0FQFbP0wd6oPTzk+xwp?= =?utf-8?q?FSFwWxJwp2qRMZES8X0JXQvje5cIpvb3XxU7mR7qOnSAwyR2h+3eM9iBKiS3wcSvm?= =?utf-8?q?T4TIJeOLCa7b87HaCd1nbbwN0eXzSdOt+/NXKEJazp+B+de9DnEViFnwlxhgACQhn?= =?utf-8?q?ZszERDKwIE+ZAxRu5Epkr7E+30Q9Ux5zL7793z8vjbN1l9A2qylr/1IWXsjdzrGEj?= =?utf-8?q?JJw+A+2xlqxciBGN/SH49wNeJeQ2JqbFa7WyBRIrGciF+GSaV4sZmF5nbzVCw7+Wj?= =?utf-8?q?F012xQBU71iw8AA01EhZqcOSU34rIDyAVc8Gt/UmCZ0pdir8TnbB+F8GGtnuGJo+L?= =?utf-8?q?pTAjLM9bHGndutVX95ljPrt4x34FsAxvce5XCN5dcGTovwfgC7L6zG31Oe9LAb3Pz?= =?utf-8?q?8LXsWUb6ktdUGO0cHnhsixV7hKZh0/Ln69TAI2t5xaCs9nNygmxg6b1lnVgMsak2x?= =?utf-8?q?HEXB3mkBS7DcfwfMe9b1m8ELhODUrjthZtDccZLdn67SWGX54EtLBAegdTzRuvQn4?= =?utf-8?q?Ax9WDH3bTjcG07zoK3FKBgR2JFrtsR2Hh902A3pObcW0cRUtgTxQswZ2plEA7cDV4?= =?utf-8?q?Etfkj71t5qKFf5neIDg1Bh4X6h8cAGZR9GZM6Oj0ftckGJ4AuAWgNTfVmLYtAj2w+?= =?utf-8?q?XJDPvF7Fxd1?= 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)(376014)(82310400026);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Dec 2024 03:25:51.5679 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 100f811b-ac8f-48ea-ac09-08dd15a5afa9 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: MWH0EPF000A6734.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ2PR12MB8159 Reading and writing the `profile` sysfs file will use the callbacks for the platform profile handler to read or set the given profile. Tested-by: Mark Pearson Reviewed-by: Mark Pearson Reviewed-by: Armin Wolf Reviewed-by: Ilpo Järvinen Signed-off-by: Mario Limonciello --- v10: * Whitespace --- drivers/acpi/platform_profile.c | 105 ++++++++++++++++++++++++++++++++ 1 file changed, 105 insertions(+) diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profile.c index 885f41bca6c25..d2c83cb258296 100644 --- a/drivers/acpi/platform_profile.c +++ b/drivers/acpi/platform_profile.c @@ -47,6 +47,55 @@ 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 + * + * Return: 0 on success, -errno on failure + */ +static int _store_class_profile(struct device *dev, void *data) +{ + struct platform_profile_handler *handler; + int *bit = (int *)data; + + lockdep_assert_held(&profile_lock); + handler = dev_get_drvdata(dev); + if (!test_bit(*bit, handler->choices)) + return -EOPNOTSUPP; + + return handler->profile_set(handler, *bit); +} + +/** + * get_class_profile - Show the current profile for a class device + * @dev: The class device + * @profile: The profile to return + * + * Return: 0 on success, -errno on failure + */ +static int get_class_profile(struct device *dev, + enum platform_profile_option *profile) +{ + struct platform_profile_handler *handler; + enum platform_profile_option val; + int err; + + lockdep_assert_held(&profile_lock); + handler = dev_get_drvdata(dev); + err = handler->profile_get(handler, &val); + if (err) { + pr_err("Failed to get profile for handler %s\n", handler->name); + return err; + } + + if (WARN_ON(val >= PLATFORM_PROFILE_LAST)) + return -EINVAL; + *profile = val; + + return 0; +} + /** * name_show - Show the name of the profile handler * @dev: The device @@ -81,9 +130,65 @@ static ssize_t choices_show(struct device *dev, } static DEVICE_ATTR_RO(choices); +/** + * profile_show - Show the current profile for a class device + * @dev: The device + * @attr: The attribute + * @buf: The buffer to write to + * + * Return: The number of bytes written + */ +static ssize_t profile_show(struct device *dev, + struct device_attribute *attr, + char *buf) +{ + enum platform_profile_option profile = PLATFORM_PROFILE_LAST; + int err; + + scoped_cond_guard(mutex_intr, return -ERESTARTSYS, &profile_lock) { + err = get_class_profile(dev, &profile); + if (err) + return err; + } + + return sysfs_emit(buf, "%s\n", profile_names[profile]); +} + +/** + * profile_store - Set the profile for a class device + * @dev: The device + * @attr: The attribute + * @buf: The buffer to read from + * @count: The number of bytes to read + * + * Return: The number of bytes read + */ +static ssize_t profile_store(struct device *dev, + struct device_attribute *attr, + const char *buf, size_t count) +{ + int index, ret; + + index = sysfs_match_string(profile_names, buf); + if (index < 0) + return -EINVAL; + + scoped_cond_guard(mutex_intr, return -ERESTARTSYS, &profile_lock) { + ret = _store_class_profile(dev, &index); + if (ret) + return ret; + } + + sysfs_notify(acpi_kobj, NULL, "platform_profile"); + + return count; +} +static DEVICE_ATTR_RW(profile); + static struct attribute *profile_attrs[] = { &dev_attr_name.attr, &dev_attr_choices.attr, + &dev_attr_profile.attr, NULL }; ATTRIBUTE_GROUPS(profile); From patchwork Fri Dec 6 03:19:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 13896348 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2040.outbound.protection.outlook.com [40.107.92.40]) (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 02ED0197A7C; Fri, 6 Dec 2024 03:25:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.92.40 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733455558; cv=fail; b=OtWiUJci0DhWLMK1hWE/B5rrNMdU+IkSyqarhKuDa9HtTYaUodiaMDb64XCkY0FTumevryCknTNCD2gDfC48D4cAG9PdjSDrJDQaCKngY9WTIZoERbjibi0/zBZJN85l2w4llIAY/ZXik36w4gGRx+rKD8d5tuyCrYQ6ekpFFF4= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733455558; c=relaxed/simple; bh=ZJTxHbpEK+5mOLXway8/LK6Isqc3CD2Ph/03ojflfd4=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=juMcOe4qtzYrXP0PMJN1FT/J4yUIc4OyGE7glRBy/TKeef/x1/65oNRWjg8o6VeFGb4rnxw5+2qshU6BORKx2DIR215vzcD00r1oevPD96nTmGTo1pq05vjbTR9dd9l7fg5LWRFVqtVtZOqCvfy4UhiTLtPT04ByyVUD316IOo8= 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=oA2mXP/l; arc=fail smtp.client-ip=40.107.92.40 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="oA2mXP/l" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=GA2rcQupTnrmxEqnz8QgBqO+CGyqCn0w+bS+3JnelYYHKcSoxuaYPtZgU5b++XTAFs4ayfq4jyjn9iz9npzIGGfo5HHibvY5/XBbMGl5joPa5ZMwzoSozkvaMIXmNX/gvCLKsqRRVb/Pt84702MPCoBY8vQc4unJCeH/rMIFBwlO8sN5UZKHGGh0fN218cyCnlvniozZ46OXkmkYbMO88OKJcezDlMLh+2hSkP6KG1Trrgzn1n8OVCpmA8BB/WOt4Qa2hqx91xMeaKtR0JkJiwwsPmyjD5CQqYPWdls7Srm531D0Si6/d3zdBbVFrlIjnnBHNswr+r+b1F7KdmmFGA== 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=92gntFMECLO6ocWI9qMwLT9+vn6CDeHjsVI2pMahJZo=; b=ob43uLLBgCkCZ/k8ht7dEqwB0E3O1P0zFHkTgP/FSDGtTae+o4jCXnX4SjUdipUJbE6cAeM1G4+rEgXEMtieGcYGnfJJsbRdhu9+6UV5ltQ/Kj8bepXSoKwkbhjK/aG8aIzETp4RXtfTH2tR6ndJ6gUWfC58GSPyJFe4+EriINgvZUn43Az8Yn3aXBJt2BZ62dOoC8uMhStYuq6FoJ1FjYx/iWAPuno8T5o+um0kQCy9+ICKBK4n8Ad2cHDIcIrRTpdcM+IwcbRb4DFwvbHddzhuNUCZ4U9SzaFVX4UQ10ReAEiBFjsJLPLS+gFyme7/Ebo5ZCy+EYeHtpQQuzvSXQ== 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=92gntFMECLO6ocWI9qMwLT9+vn6CDeHjsVI2pMahJZo=; b=oA2mXP/l3Ca0R0MSPwDnLaUlsMUg4dFtZDhRwbEl9Fx80avENy8o8XoTcncp4UCbZcQejlnUuKqMsDpLysKy5mxjSEqH0mit2pAFjEAQtFCwvMW1hQIfI9AgElPrHvLHCRmrbALVI+xTnO5iVev/eFQgPSk7tRxnYd7KcxKYWAs= Received: from MW4PR04CA0051.namprd04.prod.outlook.com (2603:10b6:303:6a::26) by PH7PR12MB8039.namprd12.prod.outlook.com (2603:10b6:510:26a::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8230.11; Fri, 6 Dec 2024 03:25:53 +0000 Received: from MWH0EPF000A6734.namprd04.prod.outlook.com (2603:10b6:303:6a:cafe::6e) by MW4PR04CA0051.outlook.office365.com (2603:10b6:303:6a::26) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8230.9 via Frontend Transport; Fri, 6 Dec 2024 03:25: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 MWH0EPF000A6734.mail.protection.outlook.com (10.167.249.26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8230.7 via Frontend Transport; Fri, 6 Dec 2024 03:25:52 +0000 Received: from AUS-P9-MLIMONCI.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Thu, 5 Dec 2024 21:25: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 , Armin Wolf Subject: [PATCH v10 14/22] ACPI: platform_profile: Notify change events on register and unregister Date: Thu, 5 Dec 2024 21:19:10 -0600 Message-ID: <20241206031918.1537-15-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241206031918.1537-1-mario.limonciello@amd.com> References: <20241206031918.1537-1-mario.limonciello@amd.com> Precedence: bulk X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MWH0EPF000A6734:EE_|PH7PR12MB8039:EE_ X-MS-Office365-Filtering-Correlation-Id: c2a3f5e5-53cb-4cb8-a20b-08dd15a5b082 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|82310400026|36860700013|376014|1800799024|7416014; X-Microsoft-Antispam-Message-Info: WlEPTzoa1a16vJNAwtyjeN0uq5lmBnJlmU/Jye57SJSFbVaGgwRsh6HHyjxf0FI8R7MQFN1CzXDbcSX/vreakgTuc1Oj469Vj00EezecUk+PLkf5D45IAQG0qO1NLnIcJ8Q1leaxuPW4XBpf/XfLZTfST/lqEVvCA4dMc7m7qdlt0kXcMEeSO2mH/CHiMK2rg/LnUx4p+jc90ASmu32p/63x6mfC1IiOt+x4kUh363MH62biEVpQKv7vX7OG63v2NO1gEDkFyCtcFOec8d1YkQCftRlabfQrlwtHGR6qnDuGDIwub9eCbQZZRCVNwYJzjZGM9oAXW7VWxjFhsNWHdSSb62TYS2t+rP+sksLDn1oPYB0q+4ulYTq++CBuZ8Oalp7ncpKXmc34sk3HMwbEwvvEk6C6CklSLlkfNP89U6m6ZZ45/UKnBY5UUSp7f+Bd9uvcyYhB4WZvTzT/jYB7EBvNLvEfSwtNay9T1SHfQrd/62KcGOnJMyc7qcxm6ILJut6GflGgHcI4yCOqnXdxvdqMWDzSgn/QhtH6dRP/OzkMidTEPy5xQL8gLaNvoH3/ugW+n4aCBBxRF2S6OPkJImiV9S9+QZ5XxdSIcAZNBL7qs9vuGaRwBvtq7Tt5a9JiL8ZLVt0zIg5bc1ZoNHQUTqlOhoQzP35gaiLMd1p5W+5xkAdfOoFbW7aGTk3Tr2Wust/t7gE7iTN2HmDI94BXsRTFoHFtjekU/d3MdXkYVLHbQjJW5XUYCSnR6mW5bGf+P85j/o2UdL3zz5fjTMl2sFwWkwB5shSmOdCcPHgT1IrReFxLqA1V6tXjBj4885vg60dFdlEDamYeHL4h2vB9kyDhGO8mJsJFN8+33eTLAKcAGshWXVu5b/BPdeghU3QymMeYFQBvqoTwq1EicZQ+7Slg0HdERZJ+WnL7cUii4nqyROc0OSYyT45wjWk8o/UHWkxjFkcxU1Zblb1S36ktJQCHowdiwgdpURTCWTmEq1Qtb2kcI9gJFcXjY09Yy520G+h1lJMS0OSibeYLWZuXEKtLeDFAdpgeYo0jiflpQtZdNKRn1YPHO4z4jQABhhnAmA/2lbiVn5KQIqaak0BUn/ARevqlqwYsqEiz/F1NZKF1C7W0bkaC01tqgLLYnM/NaRK9ETWZ1g2V1Onnd7mxaSnMN4jOK8uYfplHNObgp07sg6AiXwPlaiIorDWWSbGRUil1Z/FOtVd2QU8IA48fvYHNQh3sPoolAU+wibFr6XkG4HaTSX/pWtiZtYEDEL2VUAw9AbbbhEVVgBPHS0vnJVyW+eTYGg+ZABEVXQeQTuq4mICyn6qA1I0UMRH7simtVOEItxYEsChA2CkH2299ACeQJk2EMNimEeTn6Q/23i877gpybpSTMTDDqnIOEGfNZrRlely/dhbrYsDdPha9GCkrFxDtPkpi/0BNnHFq/6OekB0miYbHbGDdA+lFRBeq X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(82310400026)(36860700013)(376014)(1800799024)(7416014);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Dec 2024 03:25:52.9898 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c2a3f5e5-53cb-4cb8-a20b-08dd15a5b082 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: MWH0EPF000A6734.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB8039 As multiple platform profile handlers may come and go, send a notification to userspace each time that a platform profile handler is registered or unregistered. Reviewed-by: Armin Wolf Tested-by: Mark Pearson Tested-by: Matthew Schwartz Reviewed-by: Mark Pearson Signed-off-by: Mario Limonciello --- drivers/acpi/platform_profile.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profile.c index d2c83cb258296..2a4f067c3c5c1 100644 --- a/drivers/acpi/platform_profile.c +++ b/drivers/acpi/platform_profile.c @@ -361,6 +361,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); @@ -391,6 +393,8 @@ int platform_profile_remove(struct platform_profile_handler *pprof) device_unregister(pprof->class_dev); ida_free(&platform_profile_ida, id); + sysfs_notify(acpi_kobj, NULL, "platform_profile"); + sysfs_update_group(acpi_kobj, &platform_profile_group); return 0; From patchwork Fri Dec 6 03:19:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 13896349 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2040.outbound.protection.outlook.com [40.107.220.40]) (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 D3E0B19258C; Fri, 6 Dec 2024 03:26:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.220.40 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733455575; cv=fail; b=ulWPEV3aTEUGYtV4yoKTBHPO1elgK4JVOSPDoENdZDQogFMTV6fUsbzOmzUeWo3FY86ujs1cYmB6PP67eWDfMrhpohmBHABNQ94qWhqs0/ngUJ+wVrb85NNDEhqoNLpmDEb9g7kSJAAged34AmA/gqTwraqfVC+oxPOafycIvoQ= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733455575; c=relaxed/simple; bh=deBmNxDPRllsYpGw84ggzNBpWk7/UUVrK/nhCONp3v4=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=npwOjZn71doSfLoVqPrHLXXdS2ecpDRE6dMTSBB34h4cUDK3kmG22tmYP+GetwbUFutAlY+qWjgqUPP+fPriQqt4dtnMDMt3+zG+dgk4FWDKvF1Ytd+j2OCJae/+ChLhe0H3xr9NBD+dV+fDDBWEAby00XLFWR8wIPemMyDOoJA= 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=qgMKz6mV; arc=fail smtp.client-ip=40.107.220.40 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="qgMKz6mV" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=bryeuWsawTdv/yQp7LOqWSjq1jAJSwaG0xvABGIh3We6lC9F+nAqIAYDFEA0jHdu3ldBD7YAH8xOIPwRsNcJbaF3jJRk0GpJEbofLst7xJDKKqyZdqaUaqskshqpHHEOUomJueu+O7/BeGJWldkiz845+ca46aq5zRdz/YRAumxA1rkweTOco69EjrE13jKmtAby7W+XlJL6GaK8sPaMxUpaS3Pmasj3n/wgrpdM4UF0RNKS2rIOb01iCmHVx187uBrgzEG2dcZRMaqwlIkmFxCzzV2rtFalgeuogOSumePSrTYbOR4AVKfNJMW6X8QemODSTeBMTHmQUr1S3FSl/A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=Smp5omVcxem4nJZtzzeYdunSFxMaCj7p+L4/uAXrNJ4=; b=yFo1z+oaVclhX5hcvEmoSr89f4McHFA4ppQoQkEm6HaOkhV5u7UaqqtzLiwqP39xLdgZCqkLFZkDapCnotAM3M0b7K/x7glrMZZG6/6fAINqCsGPbSpakWAaHU2GpQg3b3gJrS01lO12vKlFpQEOFBTln8sZ8sritikA/+7dCc9mccQwsgSz6sY1sbbn6nBXzUGLWLxQHXxjfcGR259e7r7J9oxljZnwqf+ZLY4r9wB84qac+Zk4hZ45J+7s/ZnqMn9g15iauFmdYKA70ArXGoFsxA/Jbf8mPehu8mTbnla7r0ww88LyBzg9AYuqbdDUbP9Nk4ZfKWbdgPa0/kgfQg== 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=Smp5omVcxem4nJZtzzeYdunSFxMaCj7p+L4/uAXrNJ4=; b=qgMKz6mVPR0kzJwOd/xfRPJsCiV/GmCXREGf61Zli3ysIkPh/iwtxspUKQlOF6WYT3EyvlSUgj7mpfLBhMGOgoXfo4pqR+eLhcbFDym/Lt/gtN6F/bGiDA4mYfCDl7FuDQt7pbBI6cHH0pRJkST9COGnlRF6KoCy2+Ue75WLxpA= Received: from DS7PR03CA0068.namprd03.prod.outlook.com (2603:10b6:5:3bb::13) by PH7PR12MB5712.namprd12.prod.outlook.com (2603:10b6:510:1e3::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8207.24; Fri, 6 Dec 2024 03:26:09 +0000 Received: from DS2PEPF00003445.namprd04.prod.outlook.com (2603:10b6:5:3bb:cafe::c7) by DS7PR03CA0068.outlook.office365.com (2603:10b6:5:3bb::13) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8230.9 via Frontend Transport; Fri, 6 Dec 2024 03:26:09 +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 DS2PEPF00003445.mail.protection.outlook.com (10.167.17.72) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8230.7 via Frontend Transport; Fri, 6 Dec 2024 03:26:09 +0000 Received: from AUS-P9-MLIMONCI.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Thu, 5 Dec 2024 21:25:52 -0600 From: Mario Limonciello To: Hans de Goede , =?utf-8?q?Ilpo_J=C3=A4rvinen?= CC: "Rafael J . Wysocki" , Len Brown , Maximilian Luz , Lee Chun-Yi , "Shyam Sundar S K" , Corentin Chary , "Luke D . Jones" , Ike Panhc , Henrique de Moraes Holschuh , "Alexis Belmonte" , =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= , Ai Chao , Gergo Koteles , open list , "open list:ACPI" , "open list:MICROSOFT SURFACE PLATFORM PROFILE DRIVER" , "open list:THINKPAD ACPI EXTRAS DRIVER" , Mark Pearson , Matthew Schwartz , Mario Limonciello , Armin Wolf Subject: [PATCH v10 15/22] ACPI: platform_profile: Only show profiles common for all handlers Date: Thu, 5 Dec 2024 21:19:11 -0600 Message-ID: <20241206031918.1537-16-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241206031918.1537-1-mario.limonciello@amd.com> References: <20241206031918.1537-1-mario.limonciello@amd.com> Precedence: bulk X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS2PEPF00003445:EE_|PH7PR12MB5712:EE_ X-MS-Office365-Filtering-Correlation-Id: c73f2996-6e7b-49a5-96e2-08dd15a5ba49 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|36860700013|376014|7416014|82310400026; X-Microsoft-Antispam-Message-Info: =?utf-8?q?lTMLQY5jh64Jh33UxyY0ZqNbxii6X8U?= =?utf-8?q?4ijanuF17JqHTiVApdrCt6ul4mALX9eTJSihWqLafCg5BIWaWY603jENeQHeSej8d?= =?utf-8?q?JV6tR0wUnWtsGRWPbdojDp2vjkJqDuBzeI3xI2cuE9Pgb6qjbg7PGD4uUgOzxbz6E?= =?utf-8?q?IcpQgi0nGHdv5of2neOb1x05kFH/sWVKVjKKA0o6AigKHQYDreHPKJGaYGBieIKrZ?= =?utf-8?q?0uUBtP/GaZsuZHAw2XOEAO5/Lk/JbSQREb4mvnMZLC27zorEi0VyoTkq1ybZnZkSy?= =?utf-8?q?I4oKNu5865v4xfBNmOv4L2SbmCQ0I0NTG8oV7cfzev4fXg9q5/s0zS/Wg4lfUVKSI?= =?utf-8?q?JxlL7f8o3R6sWsMnKKjAolc2SFtpyMLDyvqZTlqBSshafqHDYhRYk15k63IIslqDf?= =?utf-8?q?L7Rwhg1PZ/N6zWRQJF6R7ycFB1D9cilDOwatSfulPw1dAF73vbAB0pWJtxs4g0E1X?= =?utf-8?q?YdZNTe5QP9JNvBDaPuVzy8WUzhRpoaZPXO+fOMO+dycdNi/t81UkSrSIi+BfIvtDR?= =?utf-8?q?beZFWeuFvonmGCbRo1YKQ3m7Gy3wuzNhEXUqKTOxvyw4ol2st+ReJk3GwP4/DDKh7?= =?utf-8?q?H0KslEk7CZ4bGf1VNu563t0KXdoMgtqNZHSVyzhPwFrc8rWuno3P/amLWU3f25BKd?= =?utf-8?q?Nko5XJh7xl/Tdd3FL5WxEAw5lf+KqOrhCUwO8zSlH/Iyi5lBO0s+ICosPGRPZ1p5F?= =?utf-8?q?/r7u5qK88bW2ULpVlp1DvPhB95WbMUELRocv6Y4Nkcw52Z8iF9EtbX+9oUcxXIn7+?= =?utf-8?q?0n5VvpilBCEkmNgheQ4ZyxP3/8R6ePZnvAxAxIhvAA8ayJeIXLGx0e5fPvS8kFVP6?= =?utf-8?q?Tmv43Yqp616nCz/Kv6UtMplzyLcuyF3C5mJuKMEkZtsbQgVNZhjEvBunpuwc+VdsT?= =?utf-8?q?vkY7r11XnU+dA+7zTwV7z/RrmvSVNHZPJW7MRihD3axtRsDB2Mq0M2qAXQ2EdHHMm?= =?utf-8?q?DuAWBGHfLPWvG6G/QsPxdBT1+bkzdfU4Y7mEXNlUkYV+lO7SGhFDf821BGlYXTTxU?= =?utf-8?q?dJotKAoQcRf8KSRRvEG73YlHNFIEMiGkn4KibMiyzjVlA2scVKK+m/7Fba2ZFFOnT?= =?utf-8?q?196NPcjI1GYrZWV8SFJT1RF77POyF8VBdUo+rmX3/DEFo2hP9kLVM8Mx/30xuQaC0?= =?utf-8?q?2uQXaVzKzwdartP73T+ICUarjkZMDE3Isi8TXKY9D3utJsFsdTvW0ygRZR8WdN4nx?= =?utf-8?q?mpnMA1V9XlC7IdU4Q9NpDnd4n2dinNGHStAL7bQdBPcCadenJRQbUqfBuLfrzn5z2?= =?utf-8?q?L7yALikyQrA+7tQgi5+tc6YSybgnUrHBVsBfvDyURVj2prM+vXzkcvgPhQcnd5U3B?= =?utf-8?q?3rpFijx/S2aACdguEpa+76ygYajbSufg3f0XrbFhekeqDO5Y84TDFgReq1wwvuVoc?= =?utf-8?q?yDpRT+fPv+f?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(1800799024)(36860700013)(376014)(7416014)(82310400026);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Dec 2024 03:26:09.4556 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c73f2996-6e7b-49a5-96e2-08dd15a5ba49 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: DS2PEPF00003445.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB5712 If multiple platform profile handlers have been registered, don't allow switching to profiles unique to only one handler. Reviewed-by: Armin Wolf Tested-by: Mark Pearson Tested-by: Matthew Schwartz Reviewed-by: Mark Pearson Reviewed-by: Ilpo Järvinen Signed-off-by: Mario Limonciello --- v10: * whitespace --- drivers/acpi/platform_profile.c | 54 +++++++++++++++++++++++++++------ 1 file changed, 44 insertions(+), 10 deletions(-) diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profile.c index 2a4f067c3c5c1..bdf69255ed9ca 100644 --- a/drivers/acpi/platform_profile.c +++ b/drivers/acpi/platform_profile.c @@ -198,22 +198,56 @@ static const struct class platform_profile_class = { .dev_groups = profile_groups, }; +/** + * _aggregate_choices - Aggregate the available profile choices + * @dev: The device + * @data: The available profile choices + * + * Return: 0 on success, -errno on failure + */ +static int _aggregate_choices(struct device *dev, void *data) +{ + struct platform_profile_handler *handler; + unsigned long *aggregate = data; + + lockdep_assert_held(&profile_lock); + handler = dev_get_drvdata(dev); + if (test_bit(PLATFORM_PROFILE_LAST, aggregate)) + bitmap_copy(aggregate, handler->choices, PLATFORM_PROFILE_LAST); + else + bitmap_and(aggregate, handler->choices, aggregate, PLATFORM_PROFILE_LAST); + + return 0; +} + +/** + * platform_profile_choices_show - Show the available profile choices for legacy sysfs interface + * @dev: The device + * @attr: The attribute + * @buf: The buffer to write to + * + * Return: The number of bytes written + */ static ssize_t platform_profile_choices_show(struct device *dev, - struct device_attribute *attr, - char *buf) + struct device_attribute *attr, + char *buf) { - int len = 0; - int i; + unsigned long aggregate[BITS_TO_LONGS(PLATFORM_PROFILE_LAST)]; + int err; + set_bit(PLATFORM_PROFILE_LAST, aggregate); scoped_cond_guard(mutex_intr, return -ERESTARTSYS, &profile_lock) { - if (!cur_profile) - return -ENODEV; - for_each_set_bit(i, cur_profile->choices, PLATFORM_PROFILE_LAST) - len += sysfs_emit_at(buf, len, len ? " %s": "%s", profile_names[i]); + err = class_for_each_device(&platform_profile_class, NULL, + aggregate, _aggregate_choices); + if (err) + return err; } - len += sysfs_emit_at(buf, len, "\n"); - return len; + /* no profile handler registered any more */ + if (bitmap_empty(aggregate, PLATFORM_PROFILE_LAST)) + return -EINVAL; + + return _commmon_choices_show(aggregate, buf); } static ssize_t platform_profile_show(struct device *dev, From patchwork Fri Dec 6 03:19:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 13896350 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2081.outbound.protection.outlook.com [40.107.93.81]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 313DE192597; Fri, 6 Dec 2024 03:26:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.93.81 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733455576; cv=fail; b=Y42VpVDWExoR9HZBFFMUUIsB0dR0Q55wD463cC0+UD6wBvFNOID/dqnoMFKjAt9DSDKUl+sTOC99UKoF1tRvbWQuYGpeUiIF/BPE+CLDQPYw9f5jzx3UREslBnBEZ0WBZiHfJnXFxWKXJAmq9+PhfasjahJ0FmQZuWbevgt1Vzk= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733455576; c=relaxed/simple; bh=KVqn7cR8jWBeZhJN8eGjfBFPDg6nAG6qCoMhJRJ+uTE=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=L4tQsOeqBLYCCbIZ+phf8ugVQ9DX5bEcqvJuvBzyt9ud6lPQGxrA8Q+LaE2vYQDCKFpQInE1VdBMqDPof03u1sHU/kzXCRx6uGpKHltFDWKpIaB6SBnY/LTQVSWt/yZ9Mdxf67JLcPZS/Hy8dtreigxo15YlQeIGyCIcLyAjElw= 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=grCVmBF8; arc=fail smtp.client-ip=40.107.93.81 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="grCVmBF8" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=j7Shh+Y6xCdN6icvVYS0XqQCp3pSye1iwXunFwpvbvl4XI2yDOLWx/cAJTya1Fs/97v9Bynmp/YNChmkiwI0+qooweNwYLb3gp75rdqltNg7sJiTmAvxseosff8EQZ8qBp4SlsCXRuVo92EDkQgPBOt+skN8rUnyw95Jkir7dK9yywdsCspqWr+m49/yzLdlukztH9v3/b7CrkCUa0HgSFzs3ZjNiNBzmeLsufwjn9ekuFdvDGiGRv7oNeMckrxXWpr2S6lqcoySkDh7XJ13Qv1K7nZwJWnEUjtKKVM1wo1aQJEAgPruMGK2PhxK9+JCjgK0NW77ZRe/lZsatKgMUQ== 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=Q6dHsPQDWl+kzyUKP92nC6SOqRt2FM5/W/XOE/tNYOM=; b=vGXF+27wR9ghxEvAJy0wIlIizJnr21L7uTIXjE3+tKaMBwSWQfumlCdwELw3Obb2SgrEXXPCt1x5L3HRqst0HQ7hsJAiE2ocvvEwLKN1VgY9uRZhTJ2ROrsLwvTMF9mPUDXkRJuMVCTDrpmIiGmwRb6TsodGYSF/AH8oofUI5haByGVtsYnImTZjZ4GJFLBTJ62hrh+sduZ1AxZKh3k8YaX4pam3eXG8KX9xwnwdfcso50xkSAdScNCfwt4epANJMFg2c7WtZ/Fw/PWgqdWJkpEFcYJIgL6uGllMCN0iqHR5xYRqV5a5Kk7Wcuq3ouJo5sy6ulZ1/VVWfAbFb/S/ow== 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=Q6dHsPQDWl+kzyUKP92nC6SOqRt2FM5/W/XOE/tNYOM=; b=grCVmBF8jNZ13JZYCDDcfFZk8fmhJI8RUqw44LQ2TF5lhhQ2eJBTUQ+AruoQymtWSUAAMASDrl5UjBDuvqTZTYNtaRuiMIxkm702SS33TNQnc/tdqtXdLanuozQYkgbOxs11XaRMnxT4b/uA4xwMgyNxIxaOUCf9p0nQWJSz0+o= Received: from PH7P221CA0039.NAMP221.PROD.OUTLOOK.COM (2603:10b6:510:33c::18) by DM4PR12MB7669.namprd12.prod.outlook.com (2603:10b6:8:106::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8230.12; Fri, 6 Dec 2024 03:26:12 +0000 Received: from MWH0EPF000A672F.namprd04.prod.outlook.com (2603:10b6:510:33c:cafe::d2) by PH7P221CA0039.outlook.office365.com (2603:10b6:510:33c::18) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8230.10 via Frontend Transport; Fri, 6 Dec 2024 03:26:11 +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 MWH0EPF000A672F.mail.protection.outlook.com (10.167.249.21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8230.7 via Frontend Transport; Fri, 6 Dec 2024 03:26:11 +0000 Received: from AUS-P9-MLIMONCI.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Thu, 5 Dec 2024 21:26:08 -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 v10 16/22] ACPI: platform_profile: Add concept of a "custom" profile Date: Thu, 5 Dec 2024 21:19:12 -0600 Message-ID: <20241206031918.1537-17-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241206031918.1537-1-mario.limonciello@amd.com> References: <20241206031918.1537-1-mario.limonciello@amd.com> Precedence: bulk X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MWH0EPF000A672F:EE_|DM4PR12MB7669:EE_ X-MS-Office365-Filtering-Correlation-Id: 76928b0e-3b56-48d8-b569-08dd15a5bb8f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|82310400026|376014|36860700013|7416014|1800799024; X-Microsoft-Antispam-Message-Info: =?utf-8?q?aPO/c+Un4j5tUUYm4X/l8fcA4jXaV27?= =?utf-8?q?W60uAAZ4U3riiSVzKsP6CXvaZDmdqU6k50QZArCfef2V2xVcTqavdsuOoz4F6YBgk?= =?utf-8?q?zk+WcRoJBcb4ibH+l3FqImzngBCoR2iQ9GeVfY4l3RWbY2bS6klhD8BGM2WQ12ASf?= =?utf-8?q?7dhuWavSVRxsrEj/GTHy+FnTespD+3pTmtoqmJiqDGcGqIErluZbV4EHKCqeyVsuq?= =?utf-8?q?MdXClEb+7MWJTmMcrb079MA2tUWGdSbGbyl+soZ4Ty5eaeGvsIW7M3+BHr5Ez9aS4?= =?utf-8?q?1hQbNRmauI+582IJnhQvU9jevAzhARbBABewRsA1GzZ3FuwijO9Z6lcOVf2qnyhki?= =?utf-8?q?pMKfZlf4qiz+ueiHGPvmsMmIsx3dUhlrzDdmlDG+KoezgMteCox6oYOkyBQ43nCrn?= =?utf-8?q?4nfUxQJIQr8SXLSoTyHPE03FPo3e3+RncbZCnnkmLPcA25ipP1SLuTtT//Jxb5F6Q?= =?utf-8?q?Vyo9GnFv1SGsnYCDwd54Cyfs0u0sSv//lgj+MbsIbBCs8+5fK4vs/p5V0Y84Z9RJW?= =?utf-8?q?BG6BY1NoSeZeHAvJg03OJzyhrDDVCOKmGNbgzua35Rxu6Q65I7WCnfAhwNM9kVuGT?= =?utf-8?q?kFB7wdxw2saVkKc1eisDqQlHLVPthi4R8cX8YBRfj65yoqdm9LviC//v5w7+h3zOT?= =?utf-8?q?tyMPIciqxXvuoUXvHPDw49n9ftjwLj34ii/7GWQpDEzGeUmES3a5gexbjb0tQrbLx?= =?utf-8?q?2rOpSYh7n4NqkqBWsMEKfMynwB7VQCcTNjDSgRfl/mgZWuOv08shdxul3RP8dJebG?= =?utf-8?q?wxWRVB5qunXM+cswse1eHOmDefTtWCQtw9eyrU5xrMggXmJwI5yMKWcTO2ipshjgy?= =?utf-8?q?7gfh0QWdFEEOhG1U/DX+DKD8p3jq2YH+6/i8sF5RSzdywb/7xiZnxB9ur2P9I/9l4?= =?utf-8?q?oxKafEGG39aOQsWAbXDQPjMwqv35peVZAKjOIPvNoYytN5ijC1FByczdL4wkqQ57s?= =?utf-8?q?jqACLUS9d2Nh+Gqw5d07vAv9WoIzOp+Ubo5ik/8o7IU1yDPEjLipN5VEJE4ec8PXl?= =?utf-8?q?BOnEf6FLpUgaFUJMA8+dewZ5C289XCGHMyVoXSfd5tXiUtE9Z7HdZPrn8vUIuGqbb?= =?utf-8?q?5UlXK7lSjfSfgy/JhAX61Bq2p+7ugEvUnTBUsHNT1AyCi+a+xXQw6vgkHNI13IaqN?= =?utf-8?q?szTdGZXHX/S2rm4SYrZtgmMpzDXVu/7PPuDFjiqVw02D/gXTZvJU+ArrLrF5N05jL?= =?utf-8?q?Udg4p/M+N2e20xovKH18v1dB464UZ9w0JuzZU9cJv9QsEF7blRcdIq2/rJtHOyaUm?= =?utf-8?q?JF0P9trzQWGl5RFt5JWyqVMMWxMvTkjYwB7Wy3JyWitARMRkX4uDYXHeqFKl2pYeA?= =?utf-8?q?u/ZDNoKAgIwFP45J+1NpfUBff4CvB4Qa1L4h5oLSrpc1XftZA0RrLtQqUCBuZzPIT?= =?utf-8?q?+P0R1ITCSjL?= 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)(36860700013)(7416014)(1800799024);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Dec 2024 03:26:11.5304 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 76928b0e-3b56-48d8-b569-08dd15a5bb8f 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: MWH0EPF000A672F.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB7669 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 use the legacy sysfs interface to distinguish this situation.. Additionally drivers can choose to use this to indicate that a user has modified driver settings in a way that the platform profile advertised by a driver is not accurate. Reviewed-by: Armin Wolf Tested-by: Mark Pearson Reviewed-by: Mark Pearson Reviewed-by: Ilpo Järvinen Signed-off-by: Mario Limonciello --- v10: * Update commit message --- 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 bdf69255ed9ca..54483269b8834 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 Fri Dec 6 03:19:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 13896351 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2069.outbound.protection.outlook.com [40.107.244.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 CBDA11D515D; Fri, 6 Dec 2024 03:26:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.244.69 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733455580; cv=fail; b=UE1y9bKUsF+LphmNf7VwwWMuZOBdLOSCaXLAVYki4vSbg1gfJhvREZagdCotqvi5+hcAOA2VtImckBb5wBRVCj/k/miBssyxPs+xr9KWEaocCtmRyA+83WJxedF5MHPyCJx/a4jgnmcZxbARlMyyWB6MP3P6ZKWvmDeHgNp7xws= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733455580; c=relaxed/simple; bh=73VCGxXEUH+QMSbDdxeJ397X7eVUA6+afqZAfy83QXk=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=BMMtfq12pTOMTiXF3SCwNsC1904gSEcdzvbjwgAOWG8uRHx8iJpNIZ4P79nxpYCzYXN5tqmu2YpjRegqiVB50c0+Nt0DskK8VYmArKe88salPqah9jbBWL6bsXz/pCSo5WKooHbUG+CEA+z72L8T7S2sOT7SmhTJ5A9zpsAzXGk= 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=oJDH3Swf; arc=fail smtp.client-ip=40.107.244.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="oJDH3Swf" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=vIIXvIASEIJQwzFiUl2gyQlTMpBd0oTgwhEGvWetBXdFucYv0xNuFHX/GqJlCVHaCb/VUhBAN+MzOTLwii1i5Am7oV4ZINLsxWT69CE3PUcC0EaQgwuIuLdNsR2/y+5f7xaiNnAXWi9CBnBnFHFAIiu4eJSHF/RVsoam0khGhflx66YcBvlZIb8aRyz/jWUUrMKySEMSPRWQMlh4iezX9dxr/1LB9MzsegBqcBkvYYmSb4DaUUBB0fr1LSSZThRf9vr7JXVOf8t++kQFiX3Q3fT4jjGWidOk8r/P8y7tQMUNBMmWB8H6yQXQk2Y1wqrQLg4kp6wuLdLzJ+5K7daTDQ== 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=/orDSLYV1gL0+Vvmo9e+6jP2d9Qr1AnkAhlrFTLpBHs=; b=i/7+xWndZuTSLqo4E1Sebk4vQnxGPlKD2cOW8Geq+42zny23To6v92S8h8zQ0bggixkpwvJkJ+txisAbz62iB1w0JQzrWF9EXM8UmUh3DEO0QgpF6goihR9k2X2Ahs8oXMk4TJ97/bs2DRvEk7l6MNrya3/Kx5ozrw/v6VpqzsNlZ7fqxXHDkWkzAQzWwMrFyNsR3iMKcMpblLZCqwpoiWAxNygXADWR0jblwNpK+Ma20kI8rLOUBQMJZv67sSOL1Wj836dnOtLCJUjdBC7Ve5DUwHu0rfHxtbx1fOVNKOJF4MpSrQ14rfeFC8nxaVEGgFLBCrNwIG6VoFWdquakVg== 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=/orDSLYV1gL0+Vvmo9e+6jP2d9Qr1AnkAhlrFTLpBHs=; b=oJDH3Swfua3jQ6GdSoVQ+vpV2ECvIC13KF0tqPTtG+msNsWpN+4kG5Y2WbY/IilYCZHC1pc8pv7L1a13hItkOaJfZO3GVWGo9MPLLCducMKD2WUrQyvwNi3rHCHj+5eiY8BjgpAKuvuTrmUmy8EMxRQAlmC2huiLO8IC7d751bI= Received: from DS7PR03CA0081.namprd03.prod.outlook.com (2603:10b6:5:3bb::26) by DS0PR12MB7701.namprd12.prod.outlook.com (2603:10b6:8:133::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8230.12; Fri, 6 Dec 2024 03:26:14 +0000 Received: from DS2PEPF00003445.namprd04.prod.outlook.com (2603:10b6:5:3bb:cafe::ad) by DS7PR03CA0081.outlook.office365.com (2603:10b6:5:3bb::26) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8230.10 via Frontend Transport; Fri, 6 Dec 2024 03:26:14 +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 DS2PEPF00003445.mail.protection.outlook.com (10.167.17.72) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8230.7 via Frontend Transport; Fri, 6 Dec 2024 03:26:14 +0000 Received: from AUS-P9-MLIMONCI.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Thu, 5 Dec 2024 21:26:11 -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 v10 17/22] ACPI: platform_profile: Make sure all profile handlers agree on profile Date: Thu, 5 Dec 2024 21:19:13 -0600 Message-ID: <20241206031918.1537-18-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241206031918.1537-1-mario.limonciello@amd.com> References: <20241206031918.1537-1-mario.limonciello@amd.com> Precedence: bulk X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS2PEPF00003445:EE_|DS0PR12MB7701:EE_ X-MS-Office365-Filtering-Correlation-Id: 107b3539-f11c-483b-86b9-08dd15a5bd44 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|82310400026|376014|36860700013|7416014|1800799024; X-Microsoft-Antispam-Message-Info: =?utf-8?q?aTMGOH2W2WMZgwJTL4LsaM77KrmcMLm?= =?utf-8?q?F/Gx87lr3iFOmkXGnAyR6SMTH3ZFlAeOhOMG+TNEfW986PtOZ+uPf68Iqe6FXfTlP?= =?utf-8?q?0P4A9xBj/+Fnx2pr+h3t03qauQ504dlj4AMTLal6zlIk/7reXHkyVqBWBF5ylRr0P?= =?utf-8?q?kt4pvXvZODE7gobTMO9A8EkB+VfrUP3CyjAMYrN3iZSqWmw0wlZhP41zLjoo8ZSYm?= =?utf-8?q?EM5CLQuGacjTw+yUG/XRZ7jKt0XMfpzR9eTanW2njd5UhMKqKZ1fnyIO5v8TJOt6z?= =?utf-8?q?MdyOkSPccxw0tngLRnP7NMlBoPNjY5Rs0BxmfLbmy7aECm8+nhmpjrI71WqSxYvNP?= =?utf-8?q?yPJqh5s8eDkCj2juaOY54trFpRvZvq3fYHOcKoo9DRPkLIOYeisZES3cf6SQOI/fo?= =?utf-8?q?urGdqGRnxxEB9ZGGeInHMTGZato8DUGmnm1Od/QVHeZB1Z0aWwL5iV3NCYIIRx3z8?= =?utf-8?q?zv7ingOPon9n+q0p0/KYe/xHqAw3Cbl5+XV17PJMKGC+h74fHizy1VadijrgJmrDZ?= =?utf-8?q?NRlZU0eCrMAQPV+cC71usg/spNyxTr9LFGBzxIc1Fcdgk/CwsO6GIEpILqzkVxP/M?= =?utf-8?q?lnovvTTpxFZqz9N1fJCsQxNXWT56dnxAj6z9M5d2pNWyXPNVSKhcXfAj5EJUPlIKi?= =?utf-8?q?BXQ3yJRCjEE9ZkvCO7VV0hu0/Nxjbb8nAM8Ar8uES3R7m6GRt5187+FuJWahtuJXn?= =?utf-8?q?QNlfr9j/XUb4APkgVXr4l9fA64j/K964d+rXHYhJkksSED+RZFujo0Fo2w5B4/ZSv?= =?utf-8?q?c+T1H+nPWz9UMqpeZN3162x0b6peiArO3utVrKfu6u8eQPRkwByQeigLKCTpIDB1e?= =?utf-8?q?VL/DrBTAxPI/xll2Se2iWAAgswrdGepuEFWqU23x1hq4M2+gDUFESQqSg32gNxGGG?= =?utf-8?q?rq+caw0juHxSL3Y2+ST//8TXA4TE5yT4LZ8SNrAuio3jSXSuxQOwQPtpbNHprJXkb?= =?utf-8?q?YgzHGenyl+T2qt9OSQM07e/kA1wA3vf88tExNukm7gk7W9GiTmuqtXxfcmEn3z3tT?= =?utf-8?q?Hd1R9QbwCrjj4tKbZ6pmVIj5aSzQoFcbdhLNs7gMSfuZFuVo7U071/FzUR142YRmH?= =?utf-8?q?2uaCUCAw+iS5fUtmoJuKaFoMUT7i/dlP+vix4CmhLPWgbvG4MxPjRraFe15Op4YI/?= =?utf-8?q?jjedVF9H4RD5n0ZFdhSM6riQn+TGlZGJWJd193W/t9cxmTnZW/IZIjreEQ5gprlAa?= =?utf-8?q?9pjTJmkSoMaga5DIQT26FcVZjhQVdqGSHwEPJ6pOXu82A1MnNmmgAF/vX36t9ncQa?= =?utf-8?q?CrodRIOIHR1YmFPIy4TUQPFHyo24UmcPGxhgzozBIjQKLz64HfsJRtT44kQctiJTR?= =?utf-8?q?9fBeTUf+IMUkNTq8gt5yr9nZRUcIrco9RIKrQBDX3Op6T7aYCtnYo5ldkrX/rAZgk?= =?utf-8?q?Yxuhl+C9fS3?= 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)(36860700013)(7416014)(1800799024);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Dec 2024 03:26:14.4556 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 107b3539-f11c-483b-86b9-08dd15a5bd44 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: DS2PEPF00003445.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR12MB7701 If for any reason multiple profile handlers don't agree on the profile return the custom profile. Reviewed-by: Armin Wolf Tested-by: Mark Pearson Reviewed-by: Mark Pearson Reviewed-by: Ilpo Järvinen Signed-off-by: Mario Limonciello --- v10: * Whitespace --- drivers/acpi/platform_profile.c | 125 ++++++++++++++++++++++++++------ 1 file changed, 102 insertions(+), 23 deletions(-) diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profile.c index 54483269b8834..95aff045a1eb3 100644 --- a/drivers/acpi/platform_profile.c +++ b/drivers/acpi/platform_profile.c @@ -68,6 +68,24 @@ static int _store_class_profile(struct device *dev, void *data) return handler->profile_set(handler, *bit); } +/** + * _notify_class_profile - Notify the class device of a profile change + * @dev: The class device + * @data: Unused + * + * Return: 0 on success, -errno on failure + */ +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 @@ -251,51 +269,112 @@ 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 - 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 Fri Dec 6 03:19:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 13896352 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2054.outbound.protection.outlook.com [40.107.244.54]) (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 93C0D1946DF; Fri, 6 Dec 2024 03:26:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.244.54 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733455589; cv=fail; b=UdUkLlYpHQ6/alJFGHnMvLaTgstptl9TYpWud+6FOtiovZupiuJ7L5zx9vbtzIk7togXocu3UZIMZeBIe++gVfShui2HnLps0agbDpCXh7P5Wzpfa8Plgs9T+NcniMXWOzgxzKffdZeDpzW2yfhSdbOjhv80FXFls924Fj38NM0= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733455589; c=relaxed/simple; bh=g3ki28Ci1PiUh/5QyfrbTEjjGzwFD7CbNTldJSWQOc0=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=qtQQA1FSyspfzwqpkpLUunRDHBna+VR0gpfM5q+t9Kj0P8gsb5yzdwJSuyHxCLarPGe91ug1EdwrWNmAVGVKVRz4EntMUV8nOHu6UkOTvK8rhHkmy12+ankjLWYOFt77COfA2lDSHQuYaPtcv7I79QTDgbqMnyEHPh/JAHtjP9o= 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=M7hRlP8Y; arc=fail smtp.client-ip=40.107.244.54 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="M7hRlP8Y" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=t7kTYAyDjgOU6YLeJj+9T3nqStkuMfOJu8Q0jN8WBrxbgvabm1MDUJVaoYIgf29FZKMMW054PvEtRAxpg6lQGiZYGJ1G9MyImHuV+xRx9H7VHGT5T3kszeTV1yex06Mo10Duu7LAMVc7/1DPwSoZKydPsuR7OX7SiRC6QBKJC8fm2f5Qxcx+ftT4B9XJqmP86ooLWbQFzY2Gk803LVMONrNYJsHP6FlMeHbPKpjtxx5ERvLSJig9hq+f1ZGTg7zzGoc5WCXzuos9g5gbuZ7bxjpl1x6iDWTuy687t18seCf8BQnl/rPMwqLtgIWKs/6M5ki5aWT5PdmYncroVGxDrA== 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=S4ORTFObqqN0AW0TcTMHLTYnCDiVe/fvkUiquKZttwM=; b=tZS6IGTEfjesmClnfuHHdf6SjBKDnYBixABXpHUeFeNby4cMOfx2outtS3rbHXz1oFAVHCgwHi2XyIWwwuWIsV8b64V52JVonqCi9irR0XmmSJ03MU+20yzfJGusdtb4yeWwsnul3F8HUMjnssKGOF/EnLaPPLMnQaIy/S0duyIRcxWxSYPsUrPLbuHvVYUxqF5/Ctp3Rk3poXzyXuz7ppUV0aCjk7Pw0/VesuPcNP73tMw5BcCExmFd5n4bW5NdcBTvkvyHBjt1lQcBBZGvcrzAEYrBGnxDdjYEk5aNlZ5FTNyQxgRAsWuTnu095P/CAu0Wof4baPLc4W6ofY02ag== 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=S4ORTFObqqN0AW0TcTMHLTYnCDiVe/fvkUiquKZttwM=; b=M7hRlP8Ysi1FN1CSh4WHT7b7hazBl5Ec2eAltS3wIouetFn7FZBj/CPD27t+3eLT+ugEAS51YRw6K30aMsHHkXPfhYZYyaCkEl3lf9ecyuPMi4+dlKIWJD+01XxFaiesr05/rSQuXefQysYVzw2d8x6LK3jJv84oqpWWAaEPQ14= Received: from MW4PR04CA0060.namprd04.prod.outlook.com (2603:10b6:303:6a::35) by SA1PR12MB9514.namprd12.prod.outlook.com (2603:10b6:806:458::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8207.23; Fri, 6 Dec 2024 03:26:23 +0000 Received: from MWH0EPF000A6734.namprd04.prod.outlook.com (2603:10b6:303:6a:cafe::be) by MW4PR04CA0060.outlook.office365.com (2603:10b6:303:6a::35) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8230.9 via Frontend Transport; Fri, 6 Dec 2024 03:26: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 MWH0EPF000A6734.mail.protection.outlook.com (10.167.249.26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8230.7 via Frontend Transport; Fri, 6 Dec 2024 03:26: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; Thu, 5 Dec 2024 21:26:14 -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 v10 18/22] ACPI: platform_profile: Check all profile handler to calculate next Date: Thu, 5 Dec 2024 21:19:14 -0600 Message-ID: <20241206031918.1537-19-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241206031918.1537-1-mario.limonciello@amd.com> References: <20241206031918.1537-1-mario.limonciello@amd.com> Precedence: bulk X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MWH0EPF000A6734:EE_|SA1PR12MB9514:EE_ X-MS-Office365-Filtering-Correlation-Id: 242c30a0-b1f6-4046-80e8-08dd15a5c25f 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: ED4CUo1StHPgGLFueEhFpDGa8cbdN6L7gkfMsCG7nyqlqA/yWvBKw/9L+WhzNLZ4nopXjk/+c5TjEOy0mpbT3rktXIsRfNNcUESefGnSzOsrQfbX9nkRsJvpVZQ9MEjYl35iOmOsB6uG9AW7ZUiaDzPzV1fe2J1dMTgvN2GBuY6M56emjJxjxaL4Tgn5O1Z+Xel0/C8b2l8c2WuWechiMowlV/E1HFxdy3zCcUHMts4K1h9VC74yI+2YgIr/X1xrrFFU1U6WI05a7HdI7BxNkkNiYUzCtozljdUl+AXkrsJoyaVrKbw1ipRAdCkBQAEEEQA7k7GF77JaBHrOKLBaqF9h/7N1EO0XmGrhkY83BJ1akCPMLgiWD5KhYEJYEcMn4sDkmsIgchooMUhtYcDn1Lv73pAJ8qLv4AkKmuGLBoUhx3f0/wMDy3YKToaJpX7tsFF1hX7dO77mcjZr0bHbnTtImeitRvc27kUWa69orm/0c+ycXwLm2lXjwmA5yYwbgrz64arjEi47oyoOnqnPxMgToNA8/3gkbLRlJxGZxvvYNo9Rt4CfJTp7KWThy74wqOnTE7XRp2bwdjfCOYBO4nvnVqZyowYIkKi/VshMbBihjj52irSdW3V31PxOpE6rFmGB44ZbvBWCNRf3+ceUldEsgcBbYAhw8QK/rFfBd4Jgp48DnwCj7Cf4apxcONIzA/lfYCxwP2hXuDNTzQoO3TTUCUboXPCpfSrB9tUekcJTvyUXHj2NhmoQJXs44DgSxNm8vTIrFFFtY2biNY9H4fvUNMqm7RSN6g6x9KAHH2qeJ5VIH0gsBij8sAvtCtBPjyGSAUlgjrWPKDbkmLC+QnLev+kaNT5lq6/ycrCYA8/EWVD4S2JaD+0gSO63Yxmz+II6sF3mXXe5dWbOCPNhv61OyEvktePPO5pEqwJS4SNd+/55niz+ZQcH+sAqmiR61HEehjNmR/GQNp3LeJh0VEVv4vGcmZLoY4rqLUZXvtGUKR+T/2mYf0H7MIkdWJf/6VLaoBw+r0R3q40HaWJPD2yDpnVtb3Mz06s+HHuuv0a/nvbZQEH9jcoko3+p9v3dBSwOfcr+m3XNLdrI/AXbPhwMkA9CU0pE2qASm132tcCWkC5ZMZBKD6US+rjPdGWkJ4CkHLVYLeLgDlQUDIjndXNeTlu7j1R7frofjoiUmPOMUI4wMU6jlbFIhDuVW6xlUN+IexYqkzCi5BSF680ToyXx+TUuKUHWfKivuXXRt+SmHsmJjAZ7HX++XHQzrxjisA1jCbWeAJUgK6va7JhSlP/ucBygZsJvyVwBid0eSID40oxwZJhtK8dKipiV5+upA7yABfjns8cbj+vHeKUfi56fCbGPQLJIDc0MzZVNYMJd2cUduRpWGFZV+4DfcE0+rbgxAZ4w+e0HN5DIobjZVrJEY1JMST44oUfTrjsSyHdL4yD2XKlxKlwSP8jLkFYI 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: 06 Dec 2024 03:26:22.9741 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 242c30a0-b1f6-4046-80e8-08dd15a5c25f 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: MWH0EPF000A6734.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR12MB9514 As multiple platform profile handlers might not all support the same profile, cycling to the next profile could have a different result depending on what handler are registered. Check what is active and supported by all handlers to decide what to do. Reviewed-by: Armin Wolf Tested-by: Mark Pearson Reviewed-by: Mark Pearson Signed-off-by: Mario Limonciello --- drivers/acpi/platform_profile.c | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profile.c index 95aff045a1eb3..a1fdc56537baf 100644 --- a/drivers/acpi/platform_profile.c +++ b/drivers/acpi/platform_profile.c @@ -418,25 +418,37 @@ EXPORT_SYMBOL_GPL(platform_profile_notify); int platform_profile_cycle(void) { - enum platform_profile_option profile; - enum platform_profile_option next; + enum platform_profile_option next = PLATFORM_PROFILE_LAST; + enum platform_profile_option profile = PLATFORM_PROFILE_LAST; + unsigned long choices[BITS_TO_LONGS(PLATFORM_PROFILE_LAST)]; int err; + set_bit(PLATFORM_PROFILE_LAST, choices); scoped_cond_guard(mutex_intr, return -ERESTARTSYS, &profile_lock) { - if (!cur_profile) - return -ENODEV; + err = class_for_each_device(&platform_profile_class, NULL, + &profile, _aggregate_profiles); + if (err) + return err; - err = cur_profile->profile_get(cur_profile, &profile); + if (profile == PLATFORM_PROFILE_CUSTOM || + profile == PLATFORM_PROFILE_LAST) + return -EINVAL; + + err = class_for_each_device(&platform_profile_class, NULL, + choices, _aggregate_choices); if (err) return err; - next = find_next_bit_wrap(cur_profile->choices, PLATFORM_PROFILE_LAST, + /* never iterate into a custom if all drivers supported it */ + clear_bit(PLATFORM_PROFILE_CUSTOM, choices); + + next = find_next_bit_wrap(choices, + PLATFORM_PROFILE_LAST, profile + 1); - if (WARN_ON(next == PLATFORM_PROFILE_LAST)) - return -EINVAL; + err = class_for_each_device(&platform_profile_class, NULL, &next, + _store_and_notify); - err = cur_profile->profile_set(cur_profile, next); if (err) return err; } From patchwork Fri Dec 6 03:19:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 13896353 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2067.outbound.protection.outlook.com [40.107.223.67]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 054C41D63DD; Fri, 6 Dec 2024 03:26:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.223.67 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733455591; cv=fail; b=KJ9lGuxUQnzZR+rGO8df9sGYgrHLb5rBlNY0GaRHUJrDnx2offEHinIPMOlPQkdsgSRo4r0tsMLHLt/44nA11eOxyocTDQxADRI9pN7K8DJV6JdtsGYtYj01UxqYYRytaK9vcSxb25rxbfJaBtp8z4pZI+2qBJ8MXMau/CSfOTs= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733455591; c=relaxed/simple; bh=sGbhaHKnxUCeVfIBw82qjrNg9XZ+yXrpKwhADJks/s8=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=f+9dgme9M3JZmv4nKI4bcIMNBdCeUBN3FVpQwnoumueUi3yLMq+I0franbMiA2Tgu27Mm/EDFbtrQg0rbLRT64+TN62EKrRoFoMF5H5CPB/Z8R3UB5Fq+ibMTYN3ngznocJmB5/0SjVnmGaBYwkNbo2muL8/CbpVSEvUMAHw0p8= 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=AOpy6c38; arc=fail smtp.client-ip=40.107.223.67 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="AOpy6c38" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=vOAkc9C+Pk+JRJkQnPvnc98kKsS46AbEzukw6C/QgI6oIZFwVQX/ZjVzO4rfZT2PcLHgZXXBAR/qY699qS2lehnDhZuA8pI1zVMyp+PTeRvav1lR91RmiDvmtDy1bqrONWCGmtmyCfcIaXGbrNHGk6c2lCN+yijHiCfpsH+RpGZB2KxJLi+WQUFbN2AkCj0QcKdOAiFBqn2Ad0VH2fcytSiKj0VwFi+CUH0VS3ukOy4zjHGhTGOuT2KmtudFqA91hfij7Ra5654svoetV9AKjjQJdW1bZBzmStA1uNHR7GnzwaYGT+vTrsb7hLkkAWJAUbAOl/qp7fSJ/65Vx+LSog== 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=DLxGtY8u6XPIuvTDIyjdhEuXrsUsoVVsd3SCaU9OYQg=; b=cyTChPY+9wgB7yJrpZfS6tzyJ/zXFJ7cyD2S7XY/blVOQZdoBR6wCIWzsOph57hbEZNKK43Aj14wRiSaG1Xs6aDZDt28Vho0/fcjZUfRzuouQ+aKYhAgPzT+x5dACn/PwIhm2riuMCIF4NZ076x/b3HOnOVzm/gqI43ZNYe9ovhd65pdHaNpbL4UDNfIWTJfMZdNgVJ1kUWFMi9UkdJzsEPCtSvZkofm6JAVRR1G7MFyKG/T78kqievfmL8ycLg9orGUli57uowl5apBy3LePEzOsJJ5QLN00CjyQdk70xl7seD+6K4d0uHn8RC8BqGTLzOol3FhyYbVaAOxkKB6cg== 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=DLxGtY8u6XPIuvTDIyjdhEuXrsUsoVVsd3SCaU9OYQg=; b=AOpy6c38LXWUdLYknaTWnTUs5kzwE4L8QWG5sfz3P2NhevXgdt6Xw0DJ6ljei8XbR87A35rzB+KscgC/KQ5YUIh6KUJdLP3hKh9M1Mt/O89ohcqRUIZ/DJeX3debFkfZ5I6uP020dmyW58W8ztB/3gnWGpCyAL8zlNlMx9ZEJwk= Received: from BLAPR03CA0021.namprd03.prod.outlook.com (2603:10b6:208:32b::26) by MN6PR12MB8541.namprd12.prod.outlook.com (2603:10b6:208:47a::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8207.18; Fri, 6 Dec 2024 03:26:24 +0000 Received: from BN1PEPF00004686.namprd03.prod.outlook.com (2603:10b6:208:32b:cafe::88) by BLAPR03CA0021.outlook.office365.com (2603:10b6:208:32b::26) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8230.9 via Frontend Transport; Fri, 6 Dec 2024 03:26: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 BN1PEPF00004686.mail.protection.outlook.com (10.167.243.91) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8230.7 via Frontend Transport; Fri, 6 Dec 2024 03:26: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; Thu, 5 Dec 2024 21:26:21 -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 v10 19/22] ACPI: platform_profile: Notify class device from platform_profile_notify() Date: Thu, 5 Dec 2024 21:19:15 -0600 Message-ID: <20241206031918.1537-20-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241206031918.1537-1-mario.limonciello@amd.com> References: <20241206031918.1537-1-mario.limonciello@amd.com> Precedence: bulk X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN1PEPF00004686:EE_|MN6PR12MB8541:EE_ X-MS-Office365-Filtering-Correlation-Id: d9a89134-6688-475e-c3e1-08dd15a5c2fd 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: =?utf-8?q?hGfW1uIrc2Pia3S86bD/WLFk5G4Bfdp?= =?utf-8?q?BZB6crJcupMt0UPRKirbRLYoyzoFZl/75vQBtdKGqNJqDp8mRKZTZbNM2R9lgF1SO?= =?utf-8?q?b/PPJCP98I/kr3/9JkF7ZMMQyi2Lzbj/EAENTkc+4CgrD4bOLVSgvvlb84aK6mHLE?= =?utf-8?q?vqoHQxeQt3Hnl6GDony+04WmCEHIoot1bcNfz24keTsxWXmDqx1TlwxwVQN3t5JG4?= =?utf-8?q?hniYk3VlwyijmCL8wz4WD7qSYl2ZUjfXwk8FVz2+/jMeqfhn70gqEHU6CyY/kqyi3?= =?utf-8?q?0d7MBtAOIOUJnbn+Quj0EPXkP6EH4JSykco9NBAVKhPtfVs5xzupoj4FgD6Gb1B9P?= =?utf-8?q?PbwKyIahKeFgjuOPYFxYNFRgzT7jwDshGt+MV7LqwSUF9uvMdQpzqh98mtAc19cVS?= =?utf-8?q?pOePbU5lEj0AzK7HN+fYpNJkK25O+dLmOZLKsgiOQKIU3aGZBADMmFCXFbHy7wtZQ?= =?utf-8?q?8vkmoLIYluN3BRdX4XAbsOmsarcT5W1cLzPC6cYxRsepyufI3v/XG1yMTQaslIZ/J?= =?utf-8?q?w8WPqSQ9+E8HPRT4dvuiuggEdc1pyI7q3QAG9ktdKyVHka9BoPNYipplg/dgUi83r?= =?utf-8?q?+hcC+3F31jihm+a1YD5jD28u8J3DCo0d8DPJxOsnlYbKzdRy5I8hf3zak5ExwgauF?= =?utf-8?q?1s1HjX5u0dry/k2N5tc2Nj+sKx1m1+tmq2+ObVaFu7fHyAzU4IaxmpoDmuq2fWzCG?= =?utf-8?q?M7NXSxeol1G5dgkeyf19c8YJUIa+PGDx21CRFkgQF2GY7J1KAU9ZeF3ykodIRj29G?= =?utf-8?q?9RXJW+Eo+6c1LJUzlp3F7KLqJARd4gmZgu3EmhLIWpsxKpZdHGBbMyq6xIqOJpKo5?= =?utf-8?q?73NQYmWRfjL4GZ1IEnAlcak9Kfi4Jrj51eC6Is6JOnvgHgx968uAk9ij6IvpIikU6?= =?utf-8?q?IpGgAeW8aDN2UemUkM8OuWUjLZUPmwlbOkWlHpGU3vBtFddi5om1dA0N8VWu/5peF?= =?utf-8?q?h57CggzRjggxw4opA/JL4Y3eZhGNGjiEvaAIIJRAF0OTBh77kUV2LnIt43LKE3dbV?= =?utf-8?q?qhD+O6owmFG6EiZ3wPgjhbQSq+1slmdrWu51knhSvvJb3tQC+aam4NFR69+fkxzra?= =?utf-8?q?bWv7CYDWUCUQWtGKiF1zF2CmjGGed3IhIl1b/r6o/sVdG9MR8DCrboS/KOI1xdIQM?= =?utf-8?q?Za+f+WE6OtFp8DYhdIvo3ZhtfnaFfd/CUQsbNiRYJeVTT9WTgp0k9nUYPgdGlrqUk?= =?utf-8?q?AZI9c+kfg7+4NNbon02RUoi/RcGt7qCMViDQqqUjk6JqcslVyN+WbHEt8Fm6n5aG7?= =?utf-8?q?oc7kjEzQs//A/sRhrsuu5PgWxEeiyLGgKuQ8sRq6CmBwJd2zcBzL7Bw9caytONjNt?= =?utf-8?q?+IELBCGRaulym6z1nlGflrGfnfxe3Yo6MihBVry0eC//HDpF8xaqcbLwpy/JLmo+N?= =?utf-8?q?DMsqcRnPvUO?= 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: 06 Dec 2024 03:26:24.1051 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: d9a89134-6688-475e-c3e1-08dd15a5c2fd 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: BN1PEPF00004686.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN6PR12MB8541 When a driver has called platform_profile_notify() both the legacy sysfs interface and the class device should be notified as userspace may listen to either. Reviewed-by: Armin Wolf Reviewed-by: Mark Pearson Reviewed-by: Ilpo Järvinen Signed-off-by: Mario Limonciello --- drivers/acpi/platform_profile.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profile.c index a1fdc56537baf..e105ef48409ec 100644 --- a/drivers/acpi/platform_profile.c +++ b/drivers/acpi/platform_profile.c @@ -412,6 +412,9 @@ void platform_profile_notify(struct platform_profile_handler *pprof) { if (!cur_profile) return; + scoped_cond_guard(mutex_intr, return, &profile_lock) { + _notify_class_profile(pprof->class_dev, NULL); + } sysfs_notify(acpi_kobj, NULL, "platform_profile"); } EXPORT_SYMBOL_GPL(platform_profile_notify); From patchwork Fri Dec 6 03:19:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 13896354 Received: from NAM02-DM3-obe.outbound.protection.outlook.com (mail-dm3nam02on2080.outbound.protection.outlook.com [40.107.95.80]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A2937194C83; Fri, 6 Dec 2024 03:26:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.95.80 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733455596; cv=fail; b=XFcDOq0W+o7gLE0tca2WLQFyC8adDn+mrwVNG0g7w+bfeP35XtDAbNq22sGBLoD6nLkLFAV4TdySKm94DRFZJTNzJngn8AYM4pHMZG4gl9JJv0ijvzvG6fESujiGP/s3FO8uwcz5I2uYXRU+jPnFLb2N9BJIftbT7nJ+uZrLLhI= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733455596; c=relaxed/simple; bh=Pby3tslwiaWul1jpe7jDQmaOMHbh0fenYAG674vWqvE=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=R3eYEMh9M4TWiTlDOY990qUFfg3DA1+s2n9OCelCKjQruO9CQx1uy1ED6Emsk/YtpjcX8XAVnbx5uACzFvhkRr27vEeBoHokQSo6HijM9KtB9ggyfgMFEVtTr0tXczbdr0MJm4ARotrrjtxaTxiToTlSPex8H7t5fcQTN8wBJV0= 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=InkH2ACW; arc=fail smtp.client-ip=40.107.95.80 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="InkH2ACW" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=yS3llCSAyUsyVqQWYmdzq+PGGxgW4xBFq4150AH1Y2hCeZ1DGLYeM8aTnGymPowzlARD+sb/UKHOiUiNKboI7EmZopD+Z581nLUX/jAYFiwHMPVwfAQy+ACPgG6e7fBiUhMhUyLftOLimRHJmJqQ7ri+ht/OMlI6dcLbgHByiT3eQy6qpyCs3yN8IB2YRFC5rcQznFQjt6s2SN0tc9H1/6a1PDzzd7ZKPwsAlxCgYDdMyN2B9PNac71HlHhkmqtm+Fc+Ad2eVsbacKo/zC7MsOESwMNU2myoL7bNFzVBLZyngd49PR5PMsU9UqwR9h3dtnt7bNDKRRtgi0l9BhNRpQ== 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=hyJY5aPn73/DA7rBV+lEr27Aq5GpXoB16YU2Ca577/k=; b=YtZVMZ5++VwZu0SUeIzgc29g6lT2O76SXGEyOp9IO5lJIRvFeegmHuPkj+dGfCRtzjKdPLXo4mmtK9QFrZUtqbcgG9Io2ptcxm1SSmrUFYr67NvvbKO9OiXBqgZZ3Gh4ddcgle9lSBX//mjgFypyduym12f8bSBizlN54EhiGV1/Fx4N2ww3byDHrWLShqTXMyU8DH/vewlZjQsNlnhb87QgDSNSYYE2bq1yK7MTy6Ql+hhocHHmBEFUiCFKFiN3fnu3cMyJHoVzT/lxrr6guRr5yFCjijTb1aYJ0FTrMnZ/cYueXvGEs3gqLvp6AqLKHqdrXstvY36Q+iFvXE+YPQ== 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=hyJY5aPn73/DA7rBV+lEr27Aq5GpXoB16YU2Ca577/k=; b=InkH2ACW0AQVmFFeR1sA8zJvC3fAFBQmRwhR7VVrjEg5TDt5Aw8s7jt7Qu8tPy96dQ0sCR5AJ6RAieDj5n8Iz221ocQJkJNaS/KyDM5vPyMFJRuokBl5Ke8hFkrs/yBaCoXvcTOIRLTfA9wNb0SkdpKROy8cyTh2uppxuTL40hU= Received: from BLAPR03CA0007.namprd03.prod.outlook.com (2603:10b6:208:32b::12) by PH8PR12MB7135.namprd12.prod.outlook.com (2603:10b6:510:22c::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8207.23; Fri, 6 Dec 2024 03:26:26 +0000 Received: from BN1PEPF00004686.namprd03.prod.outlook.com (2603:10b6:208:32b:cafe::7c) by BLAPR03CA0007.outlook.office365.com (2603:10b6:208:32b::12) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8207.19 via Frontend Transport; Fri, 6 Dec 2024 03:26: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 BN1PEPF00004686.mail.protection.outlook.com (10.167.243.91) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8230.7 via Frontend Transport; Fri, 6 Dec 2024 03:26: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; Thu, 5 Dec 2024 21:26:23 -0600 From: Mario Limonciello To: Hans de Goede , =?utf-8?q?Ilpo_J=C3=A4rvinen?= CC: "Rafael J . Wysocki" , Len Brown , Maximilian Luz , Lee Chun-Yi , "Shyam Sundar S K" , Corentin Chary , "Luke D . Jones" , Ike Panhc , Henrique de Moraes Holschuh , "Alexis Belmonte" , =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= , Ai Chao , Gergo Koteles , open list , "open list:ACPI" , "open list:MICROSOFT SURFACE PLATFORM PROFILE DRIVER" , "open list:THINKPAD ACPI EXTRAS DRIVER" , Mark Pearson , Matthew Schwartz , Mario Limonciello , Armin Wolf Subject: [PATCH v10 20/22] ACPI: platform_profile: Allow multiple handlers Date: Thu, 5 Dec 2024 21:19:16 -0600 Message-ID: <20241206031918.1537-21-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241206031918.1537-1-mario.limonciello@amd.com> References: <20241206031918.1537-1-mario.limonciello@amd.com> Precedence: bulk X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN1PEPF00004686:EE_|PH8PR12MB7135:EE_ X-MS-Office365-Filtering-Correlation-Id: 34b174a3-f5bf-4216-7a7b-08dd15a5c438 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700013|376014|1800799024|7416014|82310400026; X-Microsoft-Antispam-Message-Info: =?utf-8?q?izxPp/oLQq46Mbhozp1uRn4VsqrcEFW?= =?utf-8?q?wNVKNSP+F7409GUjt9VkUUT1njvBwMLgpEAvaMOwIRhCHnZaFylm0h85rYvXHGmCe?= =?utf-8?q?orJfo5cLNLHyaPP6V3eQxofHRbEnlhWhTrb1cuLQ+WbWtrqedhseK5OucKQAJD8mz?= =?utf-8?q?JcEls0XwDuI5zFxhWkS/q+S0om67kKAf0G1JMYKuvIvxfjjyKPNiVAoigmTev3BVi?= =?utf-8?q?7vZvREzs0MyamxBF1gkkp6RaDRIfC0AsxEOBoW0Qg2F9u1Qtb7073oWyB4kgBSD6L?= =?utf-8?q?obuL4hSWP7vIHhbr29LEJ8xsC+Hnsunv7ruNYHV+gYxA9/kl42qgybKVFSO+DAKMw?= =?utf-8?q?ySimt0Il6BfjsVlC+n/Qnill7eGZRDkMx2MiIkanlNPleYylwy9Y/QOz9eoPv/Akb?= =?utf-8?q?Pq5GiXDOK7Mok6nEQ7WbfhoghQI0rPpW6LMMw+k7X2w3FdNnMvjliCz9eU056p0+y?= =?utf-8?q?7BOy70DFr5YElA/NgrdWwvqeHjbIWOnyabVUUtDeuXhuznyKZXqa8hgrqQgiotEA0?= =?utf-8?q?389O+vHKul/ll2A/OOqItWbBlDSCAWXjtPPbbuC/UCXj0s8UrfosU6LtHaBUZOobP?= =?utf-8?q?nd1mxURCHnhgd4Vj/v4dHQ6RDe1tQuHHC6JIuMpd0YPnRMA35m4Fy0wQcFuluDIvm?= =?utf-8?q?UjhwUOLaOFvYXjqv57rLhm9NlVTkLRLNKV6OaBcTlRa7ZVxjjpA13xhsP0Xnj1LIy?= =?utf-8?q?wT/dgeiTkT6Acph0Fy7nap0s8UO2TjKh5H/l7eG0d039oruJ7GtgM54YbxyUsV8Rc?= =?utf-8?q?zTmv3K/9Bjo+TfqKzVS/TucQ6gwHvPjVV9TC/7/T0Bl+C/aRhJmfC4iwvB77FoG+g?= =?utf-8?q?hXrwbb2aYpRdKdmC3EGMmuanpdWzojwPry46WgQt7b94/el2WKlz0OEvb0cuQcf7d?= =?utf-8?q?h4zFOBjmw2WsCC+QehhC82udZcbvjoCCXY5vDIIF44DamGegTc+n71osKPn+eeMRd?= =?utf-8?q?lQbY/hw2eO60+wbPzOletSwk+vdCaha64wsatDzSiwi/DvqWeJ+VF9vJCA8cpmGOj?= =?utf-8?q?tkO3UI2+5G+yHPR/c9VcT4M670FwJiXut+htokmNzw4aGIILQWlLZJqFmrBGdMfdw?= =?utf-8?q?rbY/nCUAebqvMA7M5QG0Pghk1Dpi2DNM8RJaTvk2UtN/47t2ZRAgsBZ6K6SGl12g5?= =?utf-8?q?N9Cs/PjAvDsJ6Va4pT4JPEh0h2C7GhgRFsz2UXa+2l7b83C+hbvNlB2p3Pgy2EaR8?= =?utf-8?q?UL0+murnAS+321DwiwZEAALsWuuTAlrMztlCrjq5bn5SQOo6yQa0Dv2tVJaiCdDtC?= =?utf-8?q?+SrkrIZMCKiOfPCvNSrWHAhMIHAxBL+w5GabJZ/KBFvyNPTUaVUvHp6AnFGqDdMhp?= =?utf-8?q?VcBJos50+Eq5/ewDXrSurqZg8w9vUENR8qYw1Tph5NIEB6C8LVfdg3FasPpPKc0Zk?= =?utf-8?q?1Yd6zQ3ewJv?= 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)(1800799024)(7416014)(82310400026);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Dec 2024 03:26:26.1520 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 34b174a3-f5bf-4216-7a7b-08dd15a5c438 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: BN1PEPF00004686.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH8PR12MB7135 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 Reviewed-by: Ilpo Järvinen Signed-off-by: Mario Limonciello --- drivers/acpi/platform_profile.c | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profile.c index e105ef48409ec..75a1415190ace 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[] = { @@ -410,8 +409,6 @@ static const struct attribute_group platform_profile_group = { void platform_profile_notify(struct platform_profile_handler *pprof) { - if (!cur_profile) - return; scoped_cond_guard(mutex_intr, return, &profile_lock) { _notify_class_profile(pprof->class_dev, NULL); } @@ -474,9 +471,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); @@ -492,8 +486,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; @@ -501,7 +493,6 @@ int platform_profile_register(struct platform_profile_handler *pprof) return 0; cleanup_cur: - cur_profile = NULL; device_unregister(pprof->class_dev); cleanup_ida: @@ -516,8 +507,6 @@ int platform_profile_remove(struct platform_profile_handler *pprof) int id; guard(mutex)(&profile_lock); - cur_profile = NULL; - id = pprof->minor; device_unregister(pprof->class_dev); ida_free(&platform_profile_ida, id); From patchwork Fri Dec 6 03:19:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 13896355 Received: from NAM02-DM3-obe.outbound.protection.outlook.com (mail-dm3nam02on2056.outbound.protection.outlook.com [40.107.95.56]) (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 08EC01917C2; Fri, 6 Dec 2024 03:27:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.95.56 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733455664; cv=fail; b=qvuRG7KzbD73w5poiOSe7Ss/DuVPP+mXa032rJ68Jlr0MwaeFa9+TQ8rbnisvMsAfVVNPJyLoWCYt1NYsB+JMoicfVfH8sGsn7IQ+W/8XXj97zro/IOOLH+8Vn+hVGMsvYKE2QNHoXCymVoDBHiZ1KUT6x28Ks13F/cu7/QR6cU= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733455664; c=relaxed/simple; bh=T1bYGn0KpwhUd6ZGujBEzj+/hkw4qrWYZL3oi2BdodI=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=rgB7GMFwGhuTWBSaXxaAZqy1NcZOpNwyw7qtqOI4IWNj2G+51g1Lxg13yQcoihdDcRufrzeTwzqSlUJpixVvsWISgm8shJup7Ad9ie9ofAaerLHgc4dLdhRqisAJCUiPasJnj69AZg7JVXvj3+LiOcUkCY6lI7ZdjfJxO3LP9DQ= 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=Jh6dTeeu; arc=fail smtp.client-ip=40.107.95.56 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="Jh6dTeeu" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Aycj2zTL8vcPOwfvCn21xE9OGJ2xnH2+2ASWmEdLb35Uls7Lyhwblacg9MuGL2uLMF9f42tmcyKbws09GXeuL2Jb6rLo4ZGBuo9sIBhPUen9MtASpq++KUwkU83PJkdxZjNNRmDG9MJ6Yauqe79kRb42jDCeLTOFO2L0/1+//HQmzKjD6U4c6GFQU7HO49lUqWRus2k/hvZxJwfAcaEpITPaOoWbv3UhrFnIbFahHHrIE+2gq6nS42pY2oFshP+b8dlUuVvP1JJ7GuYnXhK/d99B6IsEUhjvV8/DFNe5pJD1AE7Eugr9QwC6BBcmDM1wtp7v3AzeIjeCZ5Kg0ek/vQ== 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=Wb6FvQepg1AVZdVCMCErgELk27WlH2wG4cscML7kY5k=; b=PUzLZYRDA0RZwdeYOlqgxwz/AG6EaO1AkVjB9zu8OE/yGHgMjeA3tPKqiWyytIwK/rmpP3CgU1fiYvUHkQ5de304Uqlg95ZHPYB9efXkqpkFlxe0ZPVfXIMmDrkEET7DVSbAiPRBrUdAmyOOfh0qM7rI23TGTFxdm1iLnT9LRzOQmkmTxiAR9aZBKjqWMQM4uwAGAkHj6Z4izDrAy+AX/blWNewEQGpyaOyKvwTxWPcefbo/Yr4su1kwVm2EcOK0wm64wRq8AhS0kGk2V8FLLTbGJ1vjxrXFaxYD4U4p3iO++0GdWu7gyl+w0fHlJEkmpi4xJGEB4tlyqX+gFPiZHw== 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=Wb6FvQepg1AVZdVCMCErgELk27WlH2wG4cscML7kY5k=; b=Jh6dTeeuvnnWrdCIh8eBARh/bUTkHM9Xs1MgiMF1cpg4+ePNcpJ/XyFJ6/puYD5f7Hijq09VhJlmcxYIzoUTsQUl+4nQpd8YnD2WnHuAaxktCVJMHsBdUcPBQmHvKlUnnSnhsRD89PpuIIrHcBFaoqiKnWhAYHdgPblN0AaI/HE= Received: from SJ0PR05CA0047.namprd05.prod.outlook.com (2603:10b6:a03:33f::22) by CYXPR12MB9338.namprd12.prod.outlook.com (2603:10b6:930:e5::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8230.11; Fri, 6 Dec 2024 03:27:39 +0000 Received: from SJ1PEPF000023D1.namprd02.prod.outlook.com (2603:10b6:a03:33f:cafe::90) by SJ0PR05CA0047.outlook.office365.com (2603:10b6:a03:33f::22) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8230.11 via Frontend Transport; Fri, 6 Dec 2024 03:27:39 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by SJ1PEPF000023D1.mail.protection.outlook.com (10.167.244.7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8230.7 via Frontend Transport; Fri, 6 Dec 2024 03:27:38 +0000 Received: from AUS-P9-MLIMONCI.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Thu, 5 Dec 2024 21:26:26 -0600 From: Mario Limonciello To: Hans de Goede , =?utf-8?q?Ilpo_J=C3=A4rvinen?= CC: "Rafael J . Wysocki" , Len Brown , Maximilian Luz , Lee Chun-Yi , "Shyam Sundar S K" , Corentin Chary , "Luke D . Jones" , Ike Panhc , Henrique de Moraes Holschuh , "Alexis Belmonte" , =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= , Ai Chao , Gergo Koteles , open list , "open list:ACPI" , "open list:MICROSOFT SURFACE PLATFORM PROFILE DRIVER" , "open list:THINKPAD ACPI EXTRAS DRIVER" , Mark Pearson , Matthew Schwartz , Mario Limonciello , Armin Wolf Subject: [PATCH v10 21/22] platform/x86/amd: pmf: Drop all quirks Date: Thu, 5 Dec 2024 21:19:17 -0600 Message-ID: <20241206031918.1537-22-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241206031918.1537-1-mario.limonciello@amd.com> References: <20241206031918.1537-1-mario.limonciello@amd.com> Precedence: bulk X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ1PEPF000023D1:EE_|CYXPR12MB9338:EE_ X-MS-Office365-Filtering-Correlation-Id: 28084663-3a16-401a-335a-08dd15a5efa3 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|82310400026|36860700013|376014|1800799024|7416014; X-Microsoft-Antispam-Message-Info: =?utf-8?q?V3AwtRxKfyrgyelRgSiBsGniPyiBnZB?= =?utf-8?q?iZjVz8DqZxHH/IH6r/lLA489h8n2Y46MXpfzrUjOsS4I+2JEHkQ9x3AbgjJhWAbM5?= =?utf-8?q?j1dy+iitAKGZxh3PgF1XzVPwfJLKIEcnBFNUcbwB+ExgmKYKUX2XPngBO1+qWfoi5?= =?utf-8?q?fQW+bvo6tAmR+3EqAzl5fUSTP/kxZVJBDGUMCgaAEVVI2lKr2v120YAEktkmtP6Mt?= =?utf-8?q?79E2o2rKuMHe8AO1rBvQ7s77qU3S7LucAiztRa/9Div8qXw2ero9DtBPu0dW3cbQW?= =?utf-8?q?IpVeYaWZC0pBKffdAD77SAWJSY6A0kPPOu1qp7HtdzeMcaCjmVS17kxRFNcfJYnqB?= =?utf-8?q?rAnsbBzwlCjAIZBp+C7WRiJU0htdwyWK2jHgzYDHf/lDizEDGkhfdB6f6Iy0WWkQT?= =?utf-8?q?tx9OEmH06OE648IS6TDkU7y4P3AICJCYMZ683hSZQEnfN1AEHUAI4gkV/Fqx8m2tY?= =?utf-8?q?8jeQsiujokoyc79h9A2cyrqiGPwmmyBJaCg0HNT2SqrMx9Yvn2j5uknPTCDZwil2B?= =?utf-8?q?wgfwjynu5B0aH2gQEYeXy/YpSB0Ueko/mhGfUYxzaxWZXG4BQxtpUrsTpPgu+GyH9?= =?utf-8?q?21ZrsERUS0Kdl2cA4VrVi7aqnXJGs7jfjQdrA17Ad8+ZthUr8p+/vSSVjF8ooUehD?= =?utf-8?q?Qu24dGILg4iOV7P1Z5ohSQ9CG5gSnZfJUzkgZXAIaiShFMP6HxJTIHP2TlARIN4QE?= =?utf-8?q?/qpdPrx5vse2bUa5RBK/YgfrLcOV7VL/nYUdQzpaFxn6ooXlt0WD/lKwaJ6tZu+xd?= =?utf-8?q?mDNjgQokhP9hC+iNC3jPGEpR4TK7AjM2COrd5puc3pD/VVYE5guJhu7VnRI6AqPHy?= =?utf-8?q?okJBPkZOVT+9FK5KZsQDRYiQ1VOZU8g5GbDQvg18Kydp2OJ+wKacepOgi+YbLPqdT?= =?utf-8?q?pJp2WXFYKo8qfexmwz1/2uGn237vFnnwKAjlZCbIZmZ/Ik2AzfCilVCF/oh/INDa3?= =?utf-8?q?zQNdJtkTotugTVBVBaT+GCaFISrU8v3I+Ujno2Zw863Pk5J0RTVJpasw2hwHMssjL?= =?utf-8?q?QMYohIhOB2pDWRce96vgAcUC924XLWKEuUqYQXm2rwCsC3znOhImYsB2fDnYHeLjz?= =?utf-8?q?IDDgWy6fhtBr2UCZ/WT+vuHzGNTt5EgDzUQZ2gyNYK26ZMClLX5viizviSpyVylci?= =?utf-8?q?RzAExVXK+ps2LzAHsJidEEc+X+hdoQB98d8EVnU9qJuS22ECo61OaxJ3vqL68DyQm?= =?utf-8?q?wiuRSEsAwFNmy/fP/Q2jyQzcrlygI7/rF62FS1k3vkpd2Fz/FXnGeYaraACoAw/L6?= =?utf-8?q?dAWknlQFmhaP2Lk4owGy+OVa6XUKJxTufFlTS/Js+MYDk9rMlOKCg62Q71hGXb9wY?= =?utf-8?q?1UmeT56aynu0DYP2pjgUA7CiCkXfajsB6WkLf467AdmVVzYZOHd/k1OfCdL+KRfx3?= =?utf-8?q?GViardlTJl7?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(82310400026)(36860700013)(376014)(1800799024)(7416014);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Dec 2024 03:27:38.9153 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 28084663-3a16-401a-335a-08dd15a5efa3 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: SJ1PEPF000023D1.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CYXPR12MB9338 As multiple platform profile handlers can now be registered, the quirks to avoid registering amd-pmf as a handler are no longer necessary. Drop them. Reviewed-by: Armin Wolf Tested-by: Mark Pearson Tested-by: Matthew Schwartz Acked-by: Shyam Sundar S K Reviewed-by: Mark Pearson Reviewed-by: Ilpo Järvinen Signed-off-by: Mario Limonciello --- drivers/platform/x86/amd/pmf/Makefile | 2 +- drivers/platform/x86/amd/pmf/core.c | 1 - drivers/platform/x86/amd/pmf/pmf-quirks.c | 66 ----------------------- drivers/platform/x86/amd/pmf/pmf.h | 3 -- 4 files changed, 1 insertion(+), 71 deletions(-) delete mode 100644 drivers/platform/x86/amd/pmf/pmf-quirks.c diff --git a/drivers/platform/x86/amd/pmf/Makefile b/drivers/platform/x86/amd/pmf/Makefile index 7d6079b02589c..6b26e48ce8ad2 100644 --- a/drivers/platform/x86/amd/pmf/Makefile +++ b/drivers/platform/x86/amd/pmf/Makefile @@ -7,4 +7,4 @@ obj-$(CONFIG_AMD_PMF) += amd-pmf.o amd-pmf-objs := core.o acpi.o sps.o \ auto-mode.o cnqf.o \ - tee-if.o spc.o pmf-quirks.o + tee-if.o spc.o diff --git a/drivers/platform/x86/amd/pmf/core.c b/drivers/platform/x86/amd/pmf/core.c index 06a97c533cb85..01eb9ee1eccd9 100644 --- a/drivers/platform/x86/amd/pmf/core.c +++ b/drivers/platform/x86/amd/pmf/core.c @@ -456,7 +456,6 @@ static int amd_pmf_probe(struct platform_device *pdev) mutex_init(&dev->lock); mutex_init(&dev->update_mutex); - amd_pmf_quirks_init(dev); apmf_acpi_init(dev); platform_set_drvdata(pdev, dev); amd_pmf_dbgfs_register(dev); diff --git a/drivers/platform/x86/amd/pmf/pmf-quirks.c b/drivers/platform/x86/amd/pmf/pmf-quirks.c deleted file mode 100644 index 7cde5733b9cac..0000000000000 --- a/drivers/platform/x86/amd/pmf/pmf-quirks.c +++ /dev/null @@ -1,66 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0-or-later -/* - * AMD Platform Management Framework Driver Quirks - * - * Copyright (c) 2024, Advanced Micro Devices, Inc. - * All Rights Reserved. - * - * Author: Mario Limonciello - */ - -#include - -#include "pmf.h" - -struct quirk_entry { - u32 supported_func; -}; - -static struct quirk_entry quirk_no_sps_bug = { - .supported_func = 0x4003, -}; - -static const struct dmi_system_id fwbug_list[] = { - { - .ident = "ROG Zephyrus G14", - .matches = { - DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."), - DMI_MATCH(DMI_PRODUCT_NAME, "GA403U"), - }, - .driver_data = &quirk_no_sps_bug, - }, - { - .ident = "ROG Ally X", - .matches = { - DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."), - DMI_MATCH(DMI_PRODUCT_NAME, "RC72LA"), - }, - .driver_data = &quirk_no_sps_bug, - }, - { - .ident = "ASUS TUF Gaming A14", - .matches = { - DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."), - DMI_MATCH(DMI_PRODUCT_NAME, "FA401W"), - }, - .driver_data = &quirk_no_sps_bug, - }, - {} -}; - -void amd_pmf_quirks_init(struct amd_pmf_dev *dev) -{ - const struct dmi_system_id *dmi_id; - struct quirk_entry *quirks; - - dmi_id = dmi_first_match(fwbug_list); - if (!dmi_id) - return; - - quirks = dmi_id->driver_data; - if (quirks->supported_func) { - dev->supported_func = quirks->supported_func; - pr_info("Using supported funcs quirk to avoid %s platform firmware bug\n", - dmi_id->ident); - } -} diff --git a/drivers/platform/x86/amd/pmf/pmf.h b/drivers/platform/x86/amd/pmf/pmf.h index a79808fda1d89..64ab532550ac3 100644 --- a/drivers/platform/x86/amd/pmf/pmf.h +++ b/drivers/platform/x86/amd/pmf/pmf.h @@ -797,7 +797,4 @@ int amd_pmf_smartpc_apply_bios_output(struct amd_pmf_dev *dev, u32 val, u32 preq void amd_pmf_populate_ta_inputs(struct amd_pmf_dev *dev, struct ta_pmf_enact_table *in); void amd_pmf_dump_ta_inputs(struct amd_pmf_dev *dev, struct ta_pmf_enact_table *in); -/* Quirk infrastructure */ -void amd_pmf_quirks_init(struct amd_pmf_dev *dev); - #endif /* PMF_H */ From patchwork Fri Dec 6 03:19:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 13896356 Received: from NAM04-BN8-obe.outbound.protection.outlook.com (mail-bn8nam04on2046.outbound.protection.outlook.com [40.107.100.46]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AB04A1917FD; Fri, 6 Dec 2024 03:27:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.100.46 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733455666; cv=fail; b=gCMr6B7xH3RLMJOK0Q+cgFK8XfWGbXj5Ed6tuOrVOybCktm+32tmM4GdJCb22DkXeL1CDn3ltxzC57l8gN24QidyKD3d8V9dhQqy6t6IFxkZmgdI1mQWfFyYf7C3HddbvLhYgZL53UEamTGqmCrJOA5azCe0cYw7es1/OR4NTwQ= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733455666; c=relaxed/simple; bh=l2U2KjFfLUmyApn2ATtD6b4JTW7rGlGqzZsqU6yv/I8=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=plgTxnoDoMuRHl6NYhGM29eklMORq6xf4tiQC3k6aCQBz/4AZVo0SYZPA91IJInKlw/KcOv40kLrF7LEUI9SaWf+lZH4z6zFczHYj5wYY5Y1liHe+zbPmfgtWgOPiy4+M96U0vPeDex3zr72yYdY95osFbkpU3tzu0j5VX6XYl8= 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=XCIvd1c1; arc=fail smtp.client-ip=40.107.100.46 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="XCIvd1c1" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Hv59tU+Zb1lV1PQuzaFF0KbdXB7EfFmSwDON0lio/R5CVs502Vc/FWuIp8kwIu1Ti7GFrT7QCysSQLggS293yPUZC35B6ZJPxbGvvwNctmLobCNFhRHmyjdIA0Tq/nlDdhxxL8J4U7T3z8A9lY6hG7sZth201qJdpMrq4L3tCFdO6jJnGkvMMgb9kDpOWNe/pMkf0bzXAtqMnKBVh80mz3G2Ds8mrKQQnPB8udbwF+pJI1KamkyUQI69c121RcTzfwzAj3wTD7n4I03jXQdY/hnF/3NgDU6n7jC/1ldPtPysvXqupyxuGwvQnT9zmzGuEBDiXHCddFrxuPoEUjUwBg== 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=WUTFvONGs1tTyLtC91QLAACJkBeUgHTdatBQ/+u7ljE=; b=H8vE6Qv2vZjCxpvMl+WdgrlQ9z+xDPQtwTC25Ud95a+m478LM4YYu3XuwVM4AltthdgbAFezMjMA0NPPORr7OAudQ6v6fM5iFjZ5bbqUbHXJOc+fzXv7dLjiSIewhleeLrC4+CSFkQhKosPbO+70VtVV25xK0uW39fhCCJwTBxAnaZ0QWzwNJvz7zj70W/RbL9xBHCuCRhfPJKD68hd1edpgolfNjFhb5Y8vY0kBzDOtigh7/UIsT9yLpd86njaUUBRv/KA9mLlbBwAEKZEGBtjVd/EVfk71OncA0upk60DC+TlGTHI6nFekqAaRE2qVD+J7RePcSZoOqlaZ0Y9mWg== 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=WUTFvONGs1tTyLtC91QLAACJkBeUgHTdatBQ/+u7ljE=; b=XCIvd1c1YoUUXoRDncLRQ32dW3pmD4XMMil8kMIz349pZncAzKygKW1UEJ+925qHjY4FHN0ZN90IQJtbZcdWg/Acm4p0GIVSwWg/2zXmvw25SLqBXOQ/ngvvkV5nHTHklJR9j4SXsdJU7BxHjO68Vy1MFXdX2hiXjdiyvvmsQu4= Received: from BY3PR10CA0007.namprd10.prod.outlook.com (2603:10b6:a03:255::12) by IA1PR12MB9031.namprd12.prod.outlook.com (2603:10b6:208:3f9::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8230.12; Fri, 6 Dec 2024 03:27:39 +0000 Received: from SJ1PEPF000023CF.namprd02.prod.outlook.com (2603:10b6:a03:255:cafe::4a) by BY3PR10CA0007.outlook.office365.com (2603:10b6:a03:255::12) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8230.10 via Frontend Transport; Fri, 6 Dec 2024 03:27:39 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by SJ1PEPF000023CF.mail.protection.outlook.com (10.167.244.11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8230.7 via Frontend Transport; Fri, 6 Dec 2024 03:27:39 +0000 Received: from AUS-P9-MLIMONCI.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Thu, 5 Dec 2024 21:26: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 v10 22/22] Documentation: Add documentation about class interface for platform profiles Date: Thu, 5 Dec 2024 21:19:18 -0600 Message-ID: <20241206031918.1537-23-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241206031918.1537-1-mario.limonciello@amd.com> References: <20241206031918.1537-1-mario.limonciello@amd.com> Precedence: bulk X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ1PEPF000023CF:EE_|IA1PR12MB9031:EE_ X-MS-Office365-Filtering-Correlation-Id: f7b29437-0bb4-4069-77b7-08dd15a5efd4 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700013|376014|1800799024|7416014|82310400026; X-Microsoft-Antispam-Message-Info: =?utf-8?q?OY7tJ5U6c49fQbdmdyJyWmDBl7jeNuC?= =?utf-8?q?krDCdrg9PJb3GjXU2w3cxPn9hyx0RlzkmDfiBw0gxwoCQTEDrhIeqYh6MnwlNn7Rx?= =?utf-8?q?G+nPWuHTM64IvagvWpa3bfQXD/Gh4XaCOTLS8/9Ax9GiBXZPGnzLbnqiSkOV65OdU?= =?utf-8?q?NBzeQk6szSq5pvrx7g/gt42g5oC/5hUBHfJStbzKQ4QLz+M0sxjoDrh46j1ZShI5C?= =?utf-8?q?l3l/wondSePdVfu9kfCqoUBoEwCGhnUB+NzIemeecIqq/KdlMZjB+ZYgi/E4yr3JG?= =?utf-8?q?Ta4AuEdRB+mt7XFRhDbu9lsdKjzBpfZmdFIUqJOfxfcQT961C4oIDDQdtgFowYw3y?= =?utf-8?q?FU273jrOM65ROHS/AmaHjo6HsQMKGDhELwZ7/QCSZmbbYMNCp0W8bHrwykJFrGIQU?= =?utf-8?q?cKqLE5wHeA9wI+tQfYOJ4mlYPv9qEzIxYLVhRXVUWEEoM+1nQaBgANP02ZDB8MBS3?= =?utf-8?q?NN4XfAyrFBALUREFbOfgPdx9KgDNml6+lDox/95QZ1z3569COYeu0rNJXiGAie7MH?= =?utf-8?q?9KkMLL3kub8tBdOHYuCfB5IC1F36k7YPb14lX3qrxW2HlFrBwiIs1nILYm4zQHfO5?= =?utf-8?q?7t7hjrwZxemVfMesY6QvKoS4sLHVnzU6vTyrl89H9H/K2J6yc4ix/jcAGpWi2sDni?= =?utf-8?q?YycHGZfAHA2kWEU4qQZVs7u9be8mgD5zNCsV8LvowGADfwmnDYNMT6/PPMBIMQiFH?= =?utf-8?q?DPemASXxZH1RuWZ11J/FEbdScYJQQrXXWVNOsPnvtn4GRIFAlG0GNvL3QYB234MQF?= =?utf-8?q?3dN/Q0p0lmLDGvSAwcnzqLXj1hoFYAaFagmof/DaIMYK2a8i75DttorggoeN9N9wS?= =?utf-8?q?Lb6kCJso+kkBwPtyOM2LLUZYM1Kn5oD3ReXXMbEVtyGaPBx7kjWksM3mlQMHB9qfL?= =?utf-8?q?mpsNE5IGOiMWRvnJcoxMaNErf90Y9gfQFOLRzanozjFUEX8HMSNvPPn4okEo+C8W+?= =?utf-8?q?NK1DfMXNq82BFBkyuYWnsv89ZHUJ48XaFuoohiW+Ib+wgtpp3LH5A4WBj98BSTvbI?= =?utf-8?q?vEI4E0H4/fHV5T4E45ggmU/7fVtJKnG/m3VCuFVInj2YdXOuYCCpj5ohfLB5IwIca?= =?utf-8?q?sd0DIT33rDtb5+iL7GTVUcRpBrIllqqqIx2SAQHpgXWpHr+0dgP6qX1YPIlHsdI+K?= =?utf-8?q?cE8qNBWEjrcQDPKaJ0Oe9PJscEX/0fqYBP3EEmiTPGKJhsW1w2bPfhVGmqZIJAE60?= =?utf-8?q?6BoFjmc08kLPKS2pq/O146Irksv9pQ6o5P99NIkwnTqGFzHUSGJJjMuOm+6KJvegF?= =?utf-8?q?Q3H/5Bj+b8QeMITUY6YcTuPcWo6CobqIRNVWCuxYAF5gUZviZ3nqyVCklpC7P4z3w?= =?utf-8?q?OR1l+Sj6jUU4aZIeEdaFhQbIQWf6BaJ+Vy54dk+yYYvQm3zeM1q3JAg7ljVsi0yEz?= =?utf-8?q?Kjv8OO61L6M?= 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)(1800799024)(7416014)(82310400026);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Dec 2024 03:27:39.2381 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f7b29437-0bb4-4069-77b7-08dd15a5efd4 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: SJ1PEPF000023CF.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR12MB9031 The class interface allows changing multiple platform profiles on a system to different values. The semantics of it are similar to the legacy interface. Reviewed-by: Armin Wolf Tested-by: Mark Pearson Reviewed-by: Mark Pearson Reviewed-by: Ilpo Järvinen Signed-off-by: Mario Limonciello --- v10: * Add custom section --- .../ABI/testing/sysfs-platform_profile | 5 +++ .../userspace-api/sysfs-platform_profile.rst | 38 +++++++++++++++++++ 2 files changed, 43 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..7f013356118ae 100644 --- a/Documentation/userspace-api/sysfs-platform_profile.rst +++ b/Documentation/userspace-api/sysfs-platform_profile.rst @@ -40,3 +40,41 @@ 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. + +"Custom" profile support +======================== +The platform_profile class also supports profiles advertising a "custom" +profile. This is intended to be set by drivers when the setttings in the +driver have been modified in a way that a standard profile doesn't represent +the current state. + +Multiple driver support +======================= +When multiple drivers on a system advertise a platform profile handler, the +platform profile handler core will only advertise the profiles that are +common between all drivers to the ``/sys/firmware/acpi`` interfaces. + +This is to ensure there is no ambiguity on what the profile names mean when +all handlers don't support a profile. + +Individual drivers will register a 'platform_profile' class device that has +similar semantics as the ``/sys/firmware/acpi/platform_profile`` interface. + +To discover which driver is associated with a platform profile handler the +user can read the ``name`` attribute of the class device. + +To discover available profiles from the class interface the user can read the +``choices`` attribute. + +If a user wants to select a profile for a specific driver, they can do so +by writing to the ``profile`` attribute of the driver's class device. + +This will allow users to set different profiles for different drivers on the +same system. If the selected profile by individual drivers differs the +platform profile handler core will display the profile 'custom' to indicate +that the profiles are not the same. + +While the ``platform_profile`` attribute has the value ``custom``, writing a +common profile from ``platform_profile_choices`` to the platform_profile +attribute of the platform profile handler core will set the profile for all +drivers.