From patchwork Sat Nov 30 14:04:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 846309 Received: from NAM02-BN1-obe.outbound.protection.outlook.com (mail-bn1nam02on2082.outbound.protection.outlook.com [40.107.212.82]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DEDFF18CC15; Sat, 30 Nov 2024 14:05:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.212.82 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732975528; cv=fail; b=UiPVBK3ZnWceJ/WNwKMMZjJpLmzaz/awocfZxxKhiStYrGezWD9Zq8Yv2pJW2j9kC4fV23FF0dsxnoPQVYZAJYhw2AGcmNy2UfbLdYCoIf3vWArDXLJpEt4hWqnYkzS4xQ9+65qO17b1cyGg4azuFW6G1WJvcnSEngcPABJqsBU= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732975528; c=relaxed/simple; bh=2GfJ/SjUIoNaiwHOnGXTGKoy8oQY1NZVgcne1nh591o=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=WWuhCEuEpzac8NlNqZjFMuYtv3Viu+XZqScvwjzDHlpxR4zI8SiBxmtJPdZHAJAlFHRslEm+/AUj6orNGiywKc9flD5A0VF/5D49A7Nn4u3BjL6ZzUqHkjF3vb2jcDThVvdsayG32PHU3bWaIDEaia7h5N+OOsQneC36UlJ0inU= 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=c6/ZXA8F; arc=fail smtp.client-ip=40.107.212.82 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="c6/ZXA8F" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=C7mk9czPL774JeeoAyu+v/8myXo2/yw3zqtBxVsk+xhH167hQ2f8N0UuBAiuKUOL2m2H1AQEP6f838c6Zc2yFYVd4Mie6NeQA3REU7UJFzpfkRUqksPFSocrH4nwxNnu7TFdzxhSwD9Nk9HOTyFBnKYJ4mpij5Jnlwt97+eVaYZaX7S6ChCvPVtcg3oCRaxS+NqJlVyRNOynwkR+2W6vfiinyUnlbnUZ1hG49BH+GfS2sSkHcw+h61u57ynMOgfPJs1pOUm1EhFCKrywVgUYn5+9NcqG8z4XESmqiIXzmbTpz9lKNB2+DEi39pKKSm9xZT1RTQ5TTuJ/1/T8MLVQUg== 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=ICOCCdrMeGVTMAZEQ5e+/50johT61zFoPMMBSCpneVMlq7rrd88Xes5/KjLg6yJUBbBQKV9LsUqzIWtXSvRWSE5m+JJoBQyF+dckb2jvfeCZTDA/Re4SV6NUiTzYA8X//5KRgcGuK4sdqzoxSy2eOhonCCx9j+r56FJ+KfIXPZDu8gxEC2ESL5p1bGAKM2wL8NDtyxtcUC/hxwnVTopFEjJ1XnOkTeirTrMptKDLf5WpIwjIFB2XbaZDVcz9o5wAHqpWoo/auBstm5IvobCsTWwvBcxMNpNidU5aPHlHPeKdzedkA/qnwHenIhvUTaHd27FyyG1/qimglIQaydb0Ug== 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=c6/ZXA8F9c8yi4vfjJMDWCaLjzPyBI+3/gzsk3GsO1TVjHQ8uMOqMK+wHBjaMB+r1IuK7I65Se5HjMN4o13hj26Rrsqb1dozk2hRPhc0CdKhJE0Bcwnfu41QVN9zu65M3QE7xVQylFaEuMzE+RUSKDdvtmWbDzUnhbzTwrwS6tM= Received: from DS7PR05CA0083.namprd05.prod.outlook.com (2603:10b6:8:57::29) by MN6PR12MB8515.namprd12.prod.outlook.com (2603:10b6:208:470::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8207.16; Sat, 30 Nov 2024 14:05:22 +0000 Received: from CY4PEPF0000EDD3.namprd03.prod.outlook.com (2603:10b6:8:57:cafe::13) by DS7PR05CA0083.outlook.office365.com (2603:10b6:8:57::29) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8230.5 via Frontend Transport; Sat, 30 Nov 2024 14:05:21 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by CY4PEPF0000EDD3.mail.protection.outlook.com (10.167.241.199) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8230.7 via Frontend Transport; Sat, 30 Nov 2024 14:05:21 +0000 Received: from AUS-P9-MLIMONCI.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Sat, 30 Nov 2024 08:05:18 -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 v8 01/22] ACPI: platform-profile: Add a name member to handlers Date: Sat, 30 Nov 2024 08:04:33 -0600 Message-ID: <20241130140454.455-2-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241130140454.455-1-mario.limonciello@amd.com> References: <20241130140454.455-1-mario.limonciello@amd.com> Precedence: bulk X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000EDD3:EE_|MN6PR12MB8515:EE_ X-MS-Office365-Filtering-Correlation-Id: b34e8e3d-8b36-434b-1d9b-08dd11480779 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|7416014|376014|1800799024|36860700013|82310400026|7053199007; X-Microsoft-Antispam-Message-Info: =?utf-8?q?jQKjY8S5AzK5BysUnz6VjHXedmBI9QN?= =?utf-8?q?iQCHwhM8gKVJbOpipKWRwQxVsmVla9xwb9rpb2CFUPDu+WJGv3klydO3Dyc79zzBo?= =?utf-8?q?W/3r2DMdj7EiKZARk0L+Bb+lGvLL9EQf0396/yXz/dPrJYqMcpFZ/G9wWcltggg7g?= =?utf-8?q?3/effPkE6MFUbuTLTgG7HJZEiDmTDOwphunf5hDTjULLg326Br63sJCrBDftrKVnZ?= =?utf-8?q?ZD/IGvrfweVeNCu1sEk/UjHExMic9122Zon6Hgo0cL8/tX4S4FLxm8RzkBQ3IRZt7?= =?utf-8?q?tBO7KNI5ySuW0tjOg5y4G/j4rdKqMf0zpTo5QDTtBciWb97JrP1ZVOc9p+iNBJp+G?= =?utf-8?q?bImIM6OEHk7EZUM4mqhSyANFWiI381czhbvqW1ISBAmct9U8BCtydfjTlJRVJQOpn?= =?utf-8?q?P3fnFOZqPSoIXAxJgKvNKAUHa/GMhynT5O624RUakv0PCgXxDz7cd3NEm+Knq2oyt?= =?utf-8?q?P7/IxH20aH8acit5B/vtOH70DBM40PiFBH/Tc847kWY0K257TqLDid3rBdfxN8tGJ?= =?utf-8?q?jdCe0eTO2ZsLn/6MeAhvThDm5lyFu0f9qVzNs6Mo1VSdpiHebRPzFy4OBjCvu6iLk?= =?utf-8?q?IhGdtV/TNNqPRrhy6BzhmIn3kS0RYWeCKYgfsngGMaZeR1R6fm5AehOmcZRnBx+AV?= =?utf-8?q?e+WKnnbFRtqjN1e6jfUrxX7Qkw+PelhKR8X1AloPsHqylOVNfrfFF8eMzg3DSj393?= =?utf-8?q?6UBj5dnDooLAaaqaPIfvU/8/lzYcbn5EJQg+qbkyilqusmWCGoGbRKgL4+0t77+3+?= =?utf-8?q?14wOk9YGv9eO2rbK7hHzi6Fl5bbUjEheDyU9gkWX58d2R1nVoEZATUdz5VmP/bXZB?= =?utf-8?q?HCvWr7nFvgqL6wot9hBsYNFRnFfe35ji95Me7HJfTNCVxOBFV/exbv02Hve1EyOP3?= =?utf-8?q?2o0/u0m5aOVZWM+GNZ48qfV2DtvfLYznAckhk3G/+NrnCc7+xpHphVghT7AJkmrHL?= =?utf-8?q?Jfe8A/zP9lMUxrbrDDve3+vo+sUy555ROQGtSxZSMUsp4WDzbxIQtXpaVqMJt0Xpn?= =?utf-8?q?3odMfCHeF9vAT5vBXAWFT8b9qekkL/GEYGU+RDHFVgOp5fy9tvJdoaI/R99J/TRKs?= =?utf-8?q?rVtSBJszftcGMBo9qp/HT1Rj3MPyCKxd38RbhwHjNYK94c2wIaWrELFSlqDuQdYuc?= =?utf-8?q?OhimwVJElUE38LhLLMcyNbIUcBoa6x/KMZX2yQ49Vq9P1Ofo0t9dfoxf5uKkfzSi5?= =?utf-8?q?vah5fFjPI17xneOA/cddrKIsAsBE7s1EkVOQgZ9Jdc2GIN2+bzXzj1ADq2Vmj2G1Q?= =?utf-8?q?CpC2gqekOyfesgQkuygzn6zL5t0gSn9RaqS0ThH+37UPl5oLpDbnmOy4TYEovh7e2?= =?utf-8?q?wql16Y6KhKAkPNXtT/c/bZbGwnPA5yE5TJ3/coJ6Q853vt1l8J4bZyK4eWqXomJ2B?= =?utf-8?q?AdP/SJBx1Qh?= X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230040)(7416014)(376014)(1800799024)(36860700013)(82310400026)(7053199007); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Nov 2024 14:05:21.5455 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b34e8e3d-8b36-434b-1d9b-08dd11480779 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: CY4PEPF0000EDD3.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN6PR12MB8515 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 Sat Nov 30 14:04:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 846308 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2054.outbound.protection.outlook.com [40.107.93.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 01E3519EED7; Sat, 30 Nov 2024 14:05:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.93.54 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732975535; cv=fail; b=hWGhQmY0W9AYgUB7gl1qy6W989cFU/k80fQNCXwrqbFWlPX9VgpINF7BlQqswie7eEQ4GHKJZH7jrkXcPBDCoqnUISse8SD99nmXAjSGOSsmTms0f1zTIty8rqSaVMLn067S+xnvr6XRs3xRWrghn5rujHEiYzJvo0iiLPVoi6U= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732975535; c=relaxed/simple; bh=DJ7yecRfFdjZ6h4DsR/Q0ETjDidYjDcuSCiQNrFW6tk=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=fYbE9hlDMRCY0OKxKJEI4izNW5uBqucji03f70zjDBJ/ySsqzP8FsT0cMxqaWHc9yJt3ShRf+2AMsdkF9OWlnj3Wyy0zWX76pKSoXNisweSLNHd5yPruPBcLo5x/T6J/qyUOKZ1A8dJlPzzTDtPdF2xAA5rJRlyQGakCHTDP5NE= 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=bw68iHDI; arc=fail smtp.client-ip=40.107.93.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="bw68iHDI" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Js26h+H2TNLULl3QV1yA5ukZ/xRwNTEEedbATM1R8JUL4auWqx5QBzPwCGu+7Kf+YXlwYd6VEbT4PaZYW8Z+/0+V0RlnpqrJGyMNqlqn7V0R0A3LYxuUU1iHGcyGsvSljy3uPob4oZqhi9QxLFTkuXNBTYqGdVELcClfZ57a78ZSS8n/v8KxE0Rbxyo6F/c0aeVUynAGIwApRhfpxBkykFYDYlNwQEciDDDbYyojsSo9SGHtaG6rSrt85HiN1tbhWZfZYAcHGfW58XtGWs3CpEefDplCL386Bpu49lKn0WGjli2FlyIE++Ckb8mUzgRbTEHjhUSfc8vNONtlTSEYEA== 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=ARvH4Vt/K8c944FfThFOJb4Ly2SmZHct8fdk8/8lZ4U=; b=aeoT8zyvBee6BjA5gyKbC5ZS4rfPMQrX5h7zhXdqAsTd6sp49XpZpCxxejcQjiGGf1O/km+jJn9KSKkPf5UEQo2An6maNPASS5hxvKXOFl4H+xGJHJdZz44MIrnyg/FkxtODjEr3DHrbBXBwwJdQrHcHybio7uki9TbrOV3NQOewiEfUzv7iGOSFpl/QrtyAArKW5ckPXTD4PXSHlq5tw5du5XHYeEwxyVSEhigX7CMdwlkGjidITaHtsVBOkXQf0Cym5QmL+EwwHInurTHiIXnm4g5ZBLjK0itSS1axSaKtBbpKx4wYJpS+wMjlJHvMC4rYyH9nzaRyAtV1yAxvHg== 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=ARvH4Vt/K8c944FfThFOJb4Ly2SmZHct8fdk8/8lZ4U=; b=bw68iHDI28AnqCIedAJOYE8M+0NsROoHXJ24eg+yKWlG02kFrr33jRH8koP0QRIiNvxEQLcmGyFHKbmXmLUTO5b1Q1EvK3eBjpZ7eGndCJIDPl1EHU6DyRZz+pzML056viUMKPGbbiXeVINF+iQMD9LvX+lDjpX2lLO2UgDQZbw= Received: from PH7PR10CA0004.namprd10.prod.outlook.com (2603:10b6:510:23d::22) by CH3PR12MB8711.namprd12.prod.outlook.com (2603:10b6:610:176::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8207.14; Sat, 30 Nov 2024 14:05:24 +0000 Received: from CY4PEPF0000EDD6.namprd03.prod.outlook.com (2603:10b6:510:23d:cafe::51) by PH7PR10CA0004.outlook.office365.com (2603:10b6:510:23d::22) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8207.16 via Frontend Transport; Sat, 30 Nov 2024 14:05: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 CY4PEPF0000EDD6.mail.protection.outlook.com (10.167.241.202) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8230.7 via Frontend Transport; Sat, 30 Nov 2024 14:05:23 +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; Sat, 30 Nov 2024 08:05:20 -0600 From: Mario Limonciello To: Hans de Goede , =?utf-8?q?Ilpo_J=C3=A4rvinen?= CC: "Rafael J . Wysocki" , Len Brown , Maximilian Luz , Lee Chun-Yi , "Shyam Sundar S K" , Corentin Chary , "Luke D . Jones" , Ike Panhc , Henrique de Moraes Holschuh , "Alexis Belmonte" , =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= , Ai Chao , Gergo Koteles , open list , "open list:ACPI" , "open list:MICROSOFT SURFACE PLATFORM PROFILE DRIVER" , "open list:THINKPAD ACPI EXTRAS DRIVER" , Mark Pearson , Matthew Schwartz , Mario Limonciello , Armin Wolf Subject: [PATCH v8 02/22] platform/x86/dell: dell-pc: Create platform device Date: Sat, 30 Nov 2024 08:04:34 -0600 Message-ID: <20241130140454.455-3-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241130140454.455-1-mario.limonciello@amd.com> References: <20241130140454.455-1-mario.limonciello@amd.com> Precedence: bulk X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000EDD6:EE_|CH3PR12MB8711:EE_ X-MS-Office365-Filtering-Correlation-Id: d8dc0dd3-393c-440c-c280-08dd11480867 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|1800799024|376014|36860700013|7416014|82310400026; X-Microsoft-Antispam-Message-Info: =?utf-8?q?6Nhr7U5n4j+kntJDAz3sVLSRkU+UtXW?= =?utf-8?q?ykBde8Ya5PUFaaxjztLZpdWsNQQMWba8zkARcZLC3sBrK8xFrLpbVZV9bBLtYTt5p?= =?utf-8?q?TASqz32phpkZvDq9v5dACD2+Hs9ok/KUfR3lruFakG7BMJ6UjpAJnhTgLRA+onO/Z?= =?utf-8?q?oZscioH31OWfA1EXX9EPgTzVfH7+1Fsd1GYRB+2p29JK0Pu7TYYz/+YmyhyINbOdO?= =?utf-8?q?mJLNWwowM/mS5PkUzlShEQ10SvjKCMpcekaSrqcAKxp97WYHkeM6T+Gkqlsarm+ZQ?= =?utf-8?q?5m4LFSG0rhBWvWw8jlM+MckcrIvOKq+mEMMtOatdZGx10AOprBSjLWofckKuCI4Lw?= =?utf-8?q?dyA/bZGTuuYhIaKmeUQxWHsyH4OtDf1kK12mQSLuCI3AwQavf0P9e+P+8maSdra62?= =?utf-8?q?6P9V8L1aX1MJJX5LaPnv1lURCe1WAngRgzMzOtu4h8BHoIkJRXT+AGff47DiMjitT?= =?utf-8?q?bRrj371tYUNMDlNjBIXT3l5l+P/DJmVUSifI0iUmXJFJP1jLDseFrBzLiVJgeTibW?= =?utf-8?q?q7fiixPeZvNmQYsPXJmHXOJkUpePvSjjRX6FJsoCqYoGTlNLnfsn4Ef/XkK3OC5g3?= =?utf-8?q?lSydnEjBTuEayhsjXMB6k28vG3vLjVwSHpdlQ/gzGiQQOgyucrI9f8I1mJAiJddtJ?= =?utf-8?q?dIRvw7ryrfbJOleZcdccCmOhy4foCD0raGG+5/Hxkhi4Zbh8Fu+dqQwZf3/1b0ZAA?= =?utf-8?q?muL70R67D/iBhOshtkscZ5RG5idlR0pMD134doQec08ZdqnBOygGaREt8ge/T3E6r?= =?utf-8?q?OPJZWna4iA+NBNqJ+gDkFozJWHZOqbyj0H9lVxj8N3cQXtkK6CvSc2z/kOy5P1Tyx?= =?utf-8?q?S4+LFpHX42cUFRTMtH3u7qJS0SSdTKvEx/H6r3QzvqAI/5+GZp2QqG79mNShNRqYs?= =?utf-8?q?toqeqF09NJbbVm7MHEApJNnIKuVBEB6XZCTOYFaoSjtQStc1lspijhQzq2q6OPlFB?= =?utf-8?q?z3CRv7hCvU6D5wtcpkPU9QktVN9IhZjepMGmPE4XegmKZj/mbsJDMab7RVCBE0Ulv?= =?utf-8?q?nQDA0UImsnHqKYnKWo3sHI5bwRXJ2MtW/gC/52gwjccaksS/xPErrpaGYjlxEmP1i?= =?utf-8?q?Glf8D1abYBilqg19pjP2quFyZCu5pphOv6RKWFkvNMeUUBEFWXB1f2LoRsRoa/6ZH?= =?utf-8?q?JAnoCaBcQVV5q31fvRyAPGhpm1Clcb3RBs+2msLlbffHPMpUIADQ5MsiTcu1xjQKE?= =?utf-8?q?CBQDZk83++tq7zYBKGW6mRrv/OembV1MbbN6kzhzxvEMoAI9B5iap1JcQKH6sMgCJ?= =?utf-8?q?QZzgnAIfrrvRmX3hftFCGoekoC1YgkREc25hmsv8VVDtcRMVfzlBQat7TPtMjo6xD?= =?utf-8?q?LkjPHni9qrTDgGhPBf9JbMmBRhlECcksOfFphVQ3b34AZpOIFBH+vL9Zsi+TQ+EVE?= =?utf-8?q?7UqaKN2cpP5?= 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)(36860700013)(7416014)(82310400026); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Nov 2024 14:05:23.1094 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: d8dc0dd3-393c-440c-c280-08dd11480867 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: CY4PEPF0000EDD6.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR12MB8711 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 Reviewed-by: Armin Wolf --- v8: * Use IS_ERR()/ERR_PTR() --- drivers/platform/x86/dell/dell-pc.c | 34 ++++++++++++++++++++--------- 1 file changed, 24 insertions(+), 10 deletions(-) diff --git a/drivers/platform/x86/dell/dell-pc.c b/drivers/platform/x86/dell/dell-pc.c index 3cf79e55e3129..8bacbde0f0506 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 ERR_PTR(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 Sat Nov 30 14:04:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 846549 Received: from NAM04-MW2-obe.outbound.protection.outlook.com (mail-mw2nam04on2049.outbound.protection.outlook.com [40.107.101.49]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 40F36199244; Sat, 30 Nov 2024 14:05:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.101.49 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732975534; cv=fail; b=YO2pDzcGMidC7IHNad891gqnK3AznKDFCyXRodZzwQ0JhnRgDAFh9HEiJBDCN5c30hISWqdJHLO62WTLuOcURj6qTJPMZLKnfCbJEfTcT+mm1Yh5GEH4sDaToJhJ0aIKlYuIDzu6ZjcBgG8n7bUQiLXReGnFEnct24v+C/bDjEw= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732975534; c=relaxed/simple; bh=KAmzADGxJcKaLoK6Fox40IFyK6MzX7KbT757o8ri+xk=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=QB2XOOFNePPCoz3k5xk1Q2sAyo9PeiZpDPnw/g7UnPF7Fk/7oZhdWqbFcPJ82QyA1igkHy7EScYFB/n0l0mlu/JnC02D9X7KI50iYrhqHTCBmoJ9Mr9REJO3e4zIq6RMiBb+nntargF9yW+3ONvIrLj2gaWcSQ03lcARwQwivbY= 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=MrhESAUx; arc=fail smtp.client-ip=40.107.101.49 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="MrhESAUx" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=qVNYmOFTrMzNom/1ZctyqLfqYW0Kakg+u7CNzaCmeYMYFHnBGDp1Ybgbc0awCk4EUPmQk/ismTMYliJua+gdnb8WhjbrX2mDqfWFXzDD3YZSsG+uL8pIwqQaiBhuqkOIXC0gDQ7Em68arhK1EzyS3I4v7yCmUXMLpi2aA7ENTLAmmSrFgsbz01IwPY8cuPrSjo3PFNyNJhv72n5DicZoRT1zTP07+3Jjr9rjaY+RUCVGX0lUg4qlFltYAd8QYXeCSYClDKwxVv3RXnextfKwNOTRq/yaA+cojEnSFSRM0eI9fxo7y8YMeepCE2u9RRz3NeEwN9MYGNLYde1JFeEiAA== 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=2NrUQsRvirxCQhPmkPFs67B2eZRv9FTrzqwvVJHiK4o=; b=ZZTLlr5eXR36Mhyqc/iAIr5SjBPMA3g8cwV2drrWUiB/vNut0pBHr3QeTllBx+Gka78/pSRIQGeBZcVUSXBH//0SuN0VpjpLtQpve9HN8sEZMgoHdw5D85o1nR+Pw9e0vHqijrXZBwsZaakSGkkL9QR++aYAOvMXSMMtLzosdNc07ZeOowg883vCq3kYXvkVhaL+B4nvzhJleHMq1tqgMRVkKiLEbLxpxEiJGJzdwbEXzYV2lDYEzI0wPJBKG+mtTNc34YdDSeQ1t8Hgt3HVHSteuM1vCOCouFsch0T4iormjj4R/arsHhvq+qe2CufHWR/x757flKIwrXsvQlufVg== 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=2NrUQsRvirxCQhPmkPFs67B2eZRv9FTrzqwvVJHiK4o=; b=MrhESAUxo4eXBRP9blXEUI/XkJlHo7uXWOWqPaJnERZo23CJaH+a2ljdtDZzz+BxV+NnXMhiRV95iRPemuU0BOc9XpgogaBZe8fpLEwjPUfwQkWcat4ZilDPd7libt54aUjKitYepphfcK7oYEbZqIYyG2N0fiDIJxyci0NpaTs= Received: from PH7PR10CA0011.namprd10.prod.outlook.com (2603:10b6:510:23d::12) by IA1PR12MB6257.namprd12.prod.outlook.com (2603:10b6:208:3e7::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8207.16; Sat, 30 Nov 2024 14:05:26 +0000 Received: from CY4PEPF0000EDD6.namprd03.prod.outlook.com (2603:10b6:510:23d:cafe::88) by PH7PR10CA0011.outlook.office365.com (2603:10b6:510:23d::12) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8207.15 via Frontend Transport; Sat, 30 Nov 2024 14:05:25 +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 CY4PEPF0000EDD6.mail.protection.outlook.com (10.167.241.202) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8230.7 via Frontend Transport; Sat, 30 Nov 2024 14:05:25 +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; Sat, 30 Nov 2024 08:05:22 -0600 From: Mario Limonciello To: Hans de Goede , =?utf-8?q?Ilpo_J=C3=A4rvinen?= CC: "Rafael J . Wysocki" , Len Brown , Maximilian Luz , Lee Chun-Yi , "Shyam Sundar S K" , Corentin Chary , "Luke D . Jones" , Ike Panhc , Henrique de Moraes Holschuh , "Alexis Belmonte" , =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= , Ai Chao , Gergo Koteles , open list , "open list:ACPI" , "open list:MICROSOFT SURFACE PLATFORM PROFILE DRIVER" , "open list:THINKPAD ACPI EXTRAS DRIVER" , Mark Pearson , Matthew Schwartz , Mario Limonciello , Armin Wolf Subject: [PATCH v8 03/22] ACPI: platform_profile: Add device pointer into platform profile handler Date: Sat, 30 Nov 2024 08:04:35 -0600 Message-ID: <20241130140454.455-4-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241130140454.455-1-mario.limonciello@amd.com> References: <20241130140454.455-1-mario.limonciello@amd.com> Precedence: bulk X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000EDD6:EE_|IA1PR12MB6257:EE_ X-MS-Office365-Filtering-Correlation-Id: b3db0e60-311a-47fe-3b1b-08dd114809e5 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|376014|7416014|82310400026|1800799024|36860700013; X-Microsoft-Antispam-Message-Info: =?utf-8?q?xfWEbKJWSVMBHNxo2qc+ddDIOmgAp43?= =?utf-8?q?Kd3QogyRb32830uXy46GHQ9xEXChqZGpkS4b3gd/06qf6wG5SxsY6OgePtr8jsROb?= =?utf-8?q?LRNLzdF8AsHeLQ3uUitsFjAKXfAq9Eh410ZNyttuuSH119NF5qAdW7MY0YWAN+J5R?= =?utf-8?q?lHrZRvwCrhs7Ed3SCAozvy3l7NsBuWwSH9p4Rc8x5Vxj7/dww6ODfjLFXjNI2zYm2?= =?utf-8?q?J6doRS0SVYpPMYl37Q/DQEm0MKjPKeLkV1LdQemv5Ug2gqxkTJyqNIAbLAmrfeqQs?= =?utf-8?q?WggV8RwYNLpJfEKqvuD6Btlu1AqO3tBJZ+vUwaal/LYswPH0MFSzEcU3UcFLU7jAl?= =?utf-8?q?MnmCM1gQ+wkpnA0OxbWWdgg5HceeWfP91hnbuOXseMBrs+CuroENX79WbU41+hT2k?= =?utf-8?q?9J3gcsicmx1NGiOfSeIyFifFPQ4CEI6wcPezWnZsVGcqXG25yhXLO2ySaLY3/E8Vk?= =?utf-8?q?kWI4QVjQ3hx3AIml/wQC1a4zg1THbbNHY4fIeJ9t4orpFZRUWeLW+n97xnYvgU8L5?= =?utf-8?q?zQgJWeFJq14q4jIZfLTJ3XMp1GnhgRkMu6fz3tQ/3bL7SUCVupX6A+G/0NPP32+ZO?= =?utf-8?q?1oRLB0nqhtJP1+VOxhNEwtBQWsZanxkEQD9Uv9eWi+INNDFxTUeXaq+AE6a8A9jnU?= =?utf-8?q?2MToGi9bIBmMSx6mtF72IuBvJ85d5NJLluwZu73CMLqpqrYJAojzz3LUrwk8Zr8A8?= =?utf-8?q?3TrTIsMGHAkY5Ax90FMwtH8hyiizmaRdqswqGq9MsXUyd+HuTu6UhaUru+z/GACx0?= =?utf-8?q?27z06xlgJCqBg7aXLlPquCz1hNvkfEIZmvZOV57GnmxGL8r4CQsaip1IZsCg0qt28?= =?utf-8?q?UYtYGJRxF5qjmwayIhWKMpOjVIBHfaZixuHhJF+D4BpTyxwxX/4TZouOT/PlgxwxV?= =?utf-8?q?4QjLU6hx0zaCHVbaMj4CPRUJV+sNHMUR0KtC7ADpEJSFc1qClfyDiGIN5KBJAn3pA?= =?utf-8?q?wF0Db1tcz/2J4cX8Kd959hDotI36BVZVhVftZurXVOy8yqoyn7cWIU3jWWaafgA2Q?= =?utf-8?q?2X+1tWoll7uxWv4IPRFWtvOL6xFhIXflPgPs3HV3LZdob8kpRLgZ9+VoE+1MCBZ/W?= =?utf-8?q?l8eJCc0lKYNTFZgWOp8yBrxcOaIAlOU6kXU4ro9tvyAajMksT1ouzTps/dkktEZa0?= =?utf-8?q?luxhbWWRqoDIg2p6phTwLz09+k3/dEnUU/EsLBxrURs+9dxEfATPftqVo6yBstHbU?= =?utf-8?q?stzvdiTSsYuga5HQIAnb5bJ3Kpndfe9Umw5dyftXge5awtGtPzMaWTIg2UOahD+R6?= =?utf-8?q?4r+S7qlRPvfaLchy4Fs3gSelXnL0RlfrQBGHisc9IzETrTfiRA8kn8dMSqE5ODzuq?= =?utf-8?q?lVg6PfsAHLIehyPI+klYnX7NMFVgeYGGfqqLFCZQ8Md8SxAUMQjQDPx2JA+IrkJi1?= =?utf-8?q?FHZ6be62aha?= X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230040)(376014)(7416014)(82310400026)(1800799024)(36860700013); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Nov 2024 14:05:25.6095 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b3db0e60-311a-47fe-3b1b-08dd114809e5 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: CY4PEPF0000EDD6.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR12MB6257 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 8bacbde0f0506..398a454d1fdcb 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 Sat Nov 30 14:04:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 846548 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2046.outbound.protection.outlook.com [40.107.243.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 41D4619F40B; Sat, 30 Nov 2024 14:05:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.243.46 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732975536; cv=fail; b=WeS0v4h/Uk8pnvdAjK3kj0QNiSscy+5AwjgF3wo3SNJr/6v+8EJ+htRGB5QAFDj9XRvu5oqwO11/zlJ1oz8SXkQv/8bP5t6Z3acfGmvm+cVVxvlym8kzGXjWr/LMs+zTDj/Q/j0zLWrB/vY3MVqM3CrYUqakoWnDVNvj9z3u/ko= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732975536; c=relaxed/simple; bh=X/qMGPGxaczfeyQYZqIbSekaoNFIghO+Qa3UeDEu/qw=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=F1DlQ/SQFL1+ALiA7R62YKOI6lnfj7MgUhUnScMp+CpNeD7bot3vGGLZPxJpgZLfI62ln7/ezpRXL3ISfS19Lb0LWcE1F0f4lvP//VasSvGEvN4m26eAHjZCi9fCeolSm6/Bw/97InwWtjofUPzZ3s2yt/FVDL9nRIJkzKVUZ04= 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=flstuPZH; arc=fail smtp.client-ip=40.107.243.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="flstuPZH" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=B9diL+7TPR7brELHwL6uI/QQUg5PzHgj+Y7yMD2pt41TmYKEsmKQFLWE+mKXn3/k9Hl4iAL9Dpx45rXXu5ad9zLXtfAHLnvT1A1dp63TLdk0vibKUhit2gzvfz6632pGIGFc3Mm771N7GfiJCv16ed5Ahe3MNgZjyJh4FhU/MuDk5Z5teQ+6/fyZIcV/hmIe4GHptipLWNOdtBt0xQiHWugDes/lXf8k/EIb/ybpefOte8odxh66T/tW/4BPDPLogRaMkBU3hMLqg19tSqjhRPDKAT/tfcWvzCwfpIi7KtuyLKGJzpRe7DDYR4j99aWVtgvUQ1L7hpf4VOBxUpO3tQ== 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=zmlXKXUDmnHnEntQh6ap6iIrJjGGXd++LXeeuvAjzvY=; b=pYs64URS6yEA+vPO3JcFiMA48S+cerwM5tn1ftB1MjJmpk67jiPq6n1ZJegscsWIiDSztxl1E26JSxl5DyZazY2prhvHQZXyqrKe5qACwL8WHc0q/YCSiMUrpDpYpCNV3ybJoua1golHz458rIvYI3M6FfZ2G918Pfwa2TThndetA8kTIGtAq+HT7pgQJ2hBcmrhgln57M6fjSQS4YeeRz4UKntQm7VAISkIsPpaYfD5yL0V4wIH5XBGBOZhdaMBqaqN2NBnibRp9gvMyuvQSVmWIMmctHJrJBMqbhtFZgB4aLTTqTerpIvbwnk56Gs8fvlbcvZZdYef5m5ZSYw60g== 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=zmlXKXUDmnHnEntQh6ap6iIrJjGGXd++LXeeuvAjzvY=; b=flstuPZHEzZDTcBabhmG0DaRqvhLUEYPT426OGgau8qL/RnxIqFSPCw26OsBKreHDc4Au4qkTXwNJZam9wS5OZuflchHBKBHSoHXnYU1/bBC7XFCEJzQ4UrG8KbrN0Zc13nks4pbX76OEd6tNkYZydmV2k3H9LsOeNpcz9SvEmg= Received: from CY8PR10CA0025.namprd10.prod.outlook.com (2603:10b6:930:4b::17) by PH7PR12MB6978.namprd12.prod.outlook.com (2603:10b6:510:1b8::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8207.16; Sat, 30 Nov 2024 14:05:28 +0000 Received: from CY4PEPF0000EDD4.namprd03.prod.outlook.com (2603:10b6:930:4b:cafe::80) by CY8PR10CA0025.outlook.office365.com (2603:10b6:930:4b::17) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8207.15 via Frontend Transport; Sat, 30 Nov 2024 14:05:27 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by CY4PEPF0000EDD4.mail.protection.outlook.com (10.167.241.200) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8230.7 via Frontend Transport; Sat, 30 Nov 2024 14:05:27 +0000 Received: from AUS-P9-MLIMONCI.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Sat, 30 Nov 2024 08:05:25 -0600 From: Mario Limonciello To: Hans de Goede , =?utf-8?q?Ilpo_J=C3=A4rvinen?= CC: "Rafael J . Wysocki" , Len Brown , Maximilian Luz , Lee Chun-Yi , "Shyam Sundar S K" , Corentin Chary , "Luke D . Jones" , Ike Panhc , Henrique de Moraes Holschuh , "Alexis Belmonte" , =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= , Ai Chao , Gergo Koteles , open list , "open list:ACPI" , "open list:MICROSOFT SURFACE PLATFORM PROFILE DRIVER" , "open list:THINKPAD ACPI EXTRAS DRIVER" , Mark Pearson , Matthew Schwartz , Mario Limonciello , Armin Wolf Subject: [PATCH v8 04/22] ACPI: platform_profile: Add platform handler argument to platform_profile_remove() Date: Sat, 30 Nov 2024 08:04:36 -0600 Message-ID: <20241130140454.455-5-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241130140454.455-1-mario.limonciello@amd.com> References: <20241130140454.455-1-mario.limonciello@amd.com> Precedence: bulk X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000EDD4:EE_|PH7PR12MB6978:EE_ X-MS-Office365-Filtering-Correlation-Id: 619b6a5c-d38c-4a96-7785-08dd11480b07 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|1800799024|82310400026|7416014|36860700013|376014|7053199007; X-Microsoft-Antispam-Message-Info: =?utf-8?q?yl7h9uwc3m6vIk6tq4daVgSk5pY6m4a?= =?utf-8?q?4LH+yM7drCj0yGKjVvUTyY5CdNEKCN5so6eN6yWQthz3ebsBRQ+Lr1TD09WJ81gda?= =?utf-8?q?VyG/mH8RmYOMWQGRf/8shSqkind8+IxoKxZdRm7F4kSlY5lc77wXGpY0JuQiESfY+?= =?utf-8?q?aX3qhfZC4u29m2LixTF/u/3t8JToFWSzAWnh3n4kKYGV7dpbmEIvOaRSBE7nOE8Y8?= =?utf-8?q?cmcndZd/hhn2+RT3sNoj625TLoBSCMbjxpeNvGRG5tk6LjD0B/QrY8p8oJCMgwXnU?= =?utf-8?q?a78rtmWNZkXZiZyN/Nk+V0oyw9CM4gxHs71R7CxUwLR1ZCDaKoYlMbkdWOhJByB/q?= =?utf-8?q?MZ20QDSxaAtKSKRPvu9UZSDWqHGiMwSk35mGz7CFZ14A8i4kEg8blNQNF35MSudOZ?= =?utf-8?q?irnLdRyfxaPnloP/XqVzJn/sgZLtTlgCcJmSowmODcpv205M83Hy4AIYQtzCOQEBj?= =?utf-8?q?5HI3jV6RoLdqQKXHdHwADjv8IGFwJsmcp2xZyO45y69/NnYeoILq76eMuxxUppwre?= =?utf-8?q?2DUY7TfX2A/3jAEQpcdku/2zzMz+8HI1Y8gPaVpnRsR9wUEPHpdkwhRGpdzOaxeQa?= =?utf-8?q?9CVIMgbYmb+M5u4L/r9rBnRnpWA9yIqj60V1W1KgwdCwXDhzG0ZHylcBuIlVbiGn7?= =?utf-8?q?l7ukMoyBb0zB1h06Xv3CvwpLN85wrUu3KHbNBpocy7pFlRcez4rg5zflj807k5o2t?= =?utf-8?q?prM216MXgy8sZFxa5VBls17lpKwryapO0PuPisDHBB7cU1iNfqswyZH+9Lka0hlUX?= =?utf-8?q?CkdXaRFsQPpVdjZQRlTBawqY+z3BrRaCKeI+j1VrkPztm7kETCxbD7iAZTq0gP8fR?= =?utf-8?q?qZUgNW1PSWjHFgJNrgzvakMJ9x5OYGz21eaPE1Zho3F6XPBj9TSTpU1rvVV3qqWkc?= =?utf-8?q?IyRSqEq9EdeqX3yM0JEUmpNOBbmN/OQNQhwTtmJRYRO25qThjJIpl8zNSgwi/Opsv?= =?utf-8?q?9FKwXklkMbvXZsHO0faVHBUq5Y2CSaZho91/ZqKK/9ehYhYnmIfL1VGdgqR8tB8nS?= =?utf-8?q?EjmWfILVjqGwJ9ha/sU3CAGM2WKZ23oWByKXvrmI6Bhdo30FETHk+oEw8pJXMFXEJ?= =?utf-8?q?II3KHINEAPqFrymNBoSaogZm0+uW7Rp5VlXFFU3j+Q8QcM/1PRR78hGDQr3Ntz60H?= =?utf-8?q?tlvEHtl0nypDQoDHsWfZSURCEd9wesia9gGWEp1Vfb12J5O2Cf4aX1TAiVEVE/2VW?= =?utf-8?q?WTQsFdb2Ju0pe3On+FOkwYwizJtHPtD0p90T0+xgOkdRni9bH6W47z2FKZAadhfby?= =?utf-8?q?wMRQu9YifOIFY+os5qjhqxlf1Zy6ZAh1GtObYvvEh5vo75ZmOlDEz6SAFgoTB3del?= =?utf-8?q?/Y+1+Ix5WjdHu1qxNzNzaFzcoDyUCc9fbtz3gmFrKeCGrgKqqXNoYFiZZLlZj7yaB?= =?utf-8?q?ukw6lx0VTwC?= X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230040)(1800799024)(82310400026)(7416014)(36860700013)(376014)(7053199007); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Nov 2024 14:05:27.5115 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 619b6a5c-d38c-4a96-7785-08dd11480b07 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: CY4PEPF0000EDD4.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB6978 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 398a454d1fdcb..011b5d1609b0d 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 Sat Nov 30 14:04:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 846307 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2044.outbound.protection.outlook.com [40.107.244.44]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8D2BE19F485; Sat, 30 Nov 2024 14:05:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.244.44 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732975537; cv=fail; b=NG9oabXopOrTltJLVjZ2zm8Z9PzivKaEtEOw5LxfleUwcAtPGLuZY8YIg6X8Q6xB9zGWaMuLWJEAJemY9KGaD7DDpU6JTsGJa9VuZaX2jeWjjoF5vq1vDws7qOuzBM2Qdstiyk6dTzy+YO7feGhOlFH7B8O792IxGrrJloo23jU= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732975537; c=relaxed/simple; bh=2sGp8nsceMSqqbGFXAGu40PROo274ncRCGZ1RbgNNlw=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=aQt+hK8KpFFcbapDiR0NKVjfZ6lMEndorT5PrumQbjJ3ugGMpsuxfnxNmNXhGLGrvZxOFggCSPlZ4iSi0Ml53lLQC5DUKzYa18F7AYmW5wES2KbxSIJe8lFcySxu8JoIy4s6ymCOiSQoH102qZKsHnpLqwLgTunqrilsyCCPrA0= 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=Lbsb78tD; arc=fail smtp.client-ip=40.107.244.44 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="Lbsb78tD" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=BH90ucLw02Oe+2A5031CbqXpFMixSTaHfdBDmqt4cEhIi6OcDEDgtYAPIcTYeL5He570PlLTFWykzOKRm2kGz7F06ljPPNh12Xeobbx7VvBIXMyhoToz2GUxIshPOkCS3zp/rqjhlM/I1QOdicsotMHcnn58bfQIwX6Z9ZHE3+KvOSgyJ3uqAjYAdwyrtSKNeySHZv5FJO8zADn5FnZtmLsXA4inT2x7OuJaN2B0+aYES/CpLR/asEhL5obM7v74zCJU88U5v277uR6yOlGQpBqQWiHhh2eFb6clpnmMm1Q+bDP0VijtB8QdRndOHOFkCK3gt9OhZWTbDNcNLp3oXQ== 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=L69tq9mHLT0lMQk6UrUfxjMKZlBFcls99rQZug8nBdIKldvOLBBbRx/sHGBQpxWCtkMicvH/UK+yMHvlJium2anOb9aMffy7IeKDNXfR8dDUq82Q8F39TBXj80Duy7Eo9XO8Wf4A/h0eGDOS18xSAVuL64h3kS6MiQGBx+4tIaPHiZ3rd46tY0HbyhmoDaTJlB8dXzNG+LKO9U0dwzxjIjsyG45O/hgsklDnAHYwIhznQ+EWOwyxlSXZpYq0Go8hIQneuQcUAvgCH20eNMU2cBt/rO99a5JcyF6sZ0EqdHLTj43a6V9D2dSLWxsQkiaSZ2+t8DJSHhSZrnFX+wr9hA== 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=Lbsb78tDIhFYQK5l9RYqSVHIiSC3Bp1N8uIFvm0dMyPAo7pfJBekyhqaUkUsCuRIbOoMb9k49m4wCN8WjACZIGhxwKHMQm3dcyjlJFGBRYfo1BOBeSZfKzNNVfwYomi1YkmDnEbvDDeYsIIECGhOVHv01uOFq6CPIFS/dgQ5WAA= Received: from PH8PR05CA0004.namprd05.prod.outlook.com (2603:10b6:510:2cc::23) by DM6PR12MB4265.namprd12.prod.outlook.com (2603:10b6:5:211::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8207.13; Sat, 30 Nov 2024 14:05:31 +0000 Received: from CY4PEPF0000EDD5.namprd03.prod.outlook.com (2603:10b6:510:2cc:cafe::cf) by PH8PR05CA0004.outlook.office365.com (2603:10b6:510:2cc::23) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8230.6 via Frontend Transport; Sat, 30 Nov 2024 14:05:31 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by CY4PEPF0000EDD5.mail.protection.outlook.com (10.167.241.201) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8230.7 via Frontend Transport; Sat, 30 Nov 2024 14:05:31 +0000 Received: from AUS-P9-MLIMONCI.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Sat, 30 Nov 2024 08:05: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 v8 05/22] ACPI: platform_profile: Pass the profile handler into platform_profile_notify() Date: Sat, 30 Nov 2024 08:04:37 -0600 Message-ID: <20241130140454.455-6-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241130140454.455-1-mario.limonciello@amd.com> References: <20241130140454.455-1-mario.limonciello@amd.com> Precedence: bulk X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000EDD5:EE_|DM6PR12MB4265:EE_ X-MS-Office365-Filtering-Correlation-Id: 660205db-bc76-450c-1edf-08dd11480d21 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: h0oKNY1hbV3amxPzNPW9nuxWpUglr3/qeY6nPsZEEa7UDR7cR36vz98O21i7HNJQy4PTPw7vuRsGp/9u/pglG6qQTRD5vJkzr9hwBHuO19Gt0d+sjxBZYKWkdt53DEoa0MsHaMsoNrj76Gg2O5UGr67tql0eAA9czIDNWn5+yOhtZh3CHVOhA9O9XCzJ6s/R8SrjAv8yAnXT2WvNg38tkx4Bafd0wgb3qUH72R//aO4TUGftvyJ28JVZ6/ZsdmFvg6kEm47BToI+7nFINdkS4/s8B9l0oaGnf7mVrDm1n+NVtifN3mSvmu5D3dtDjTkM6+nYarLL2InPvbvdHjmnc2KvE1CKm1zH2iRrGMxl1/vL8ef521eYPO+jE87FMEKY9KMDUdNwyw6b2szk9EcQlzeef87l64xpcZz0wcX4h+XVVYAG4ir73cjW23DTGedAXxdWnp70LupHHDcdtW+INk3ewD/Po3tGkJDPkJWwXEKUCvlGfnZk2vNLCtOJeR295UPy201jKgfJYLtu1PRG2B8Tpj5rqFQ0WetlLQOE157ynOw2jDvK0Wc3IxtrUFYtQaIEIeU9MWu3gr2Zx/tdqkm1IhcvSLTyquPQco3INy6aJFLKQxYMbMgLS8RPiDRD/p2aMfNRbHp1kr8NQoRmqAU5ggUTGfDUm/fhJEkrPFSWfBhSgwbPtM0jPTpwHYHyyS2iEdVyKcOQ9t/1Zdv2IPFxy5U9itIQWUq10rlXqiAyRIuQjKPxDkN429n/0E3L+D2O2og5w5cjEWQGM+T9nRW9Ah5cDq6aeyTDRe+UfAK4MRZLLuWIuyzFN9g/vdBU+RmXSC5jBNJkGV+AeCMqE/X0g8vSJGVyHBOsFg5u3nQ3yQS/xtFE8mpdqYHzYLrR9xoSR1IvNDi90DzVJxBXBelYFgyZtm9aTlsntQ5TXNP8VEAX4rGC4sxb7WVwh39nxqigq7ugJO7nqylx9URDxLenPlcG6Ep8z8Yvv4Y2HXYlkDBDAmt1bIpVCf6AksX9su9DuvgRdgz1oNKnHb7DUW9mq5MgWqL7FkSwPz0z+y+RJOUL/PfNlbwmNYtwYXQFkstbdJ9fJcffY8gGNSGHTHDmC+HvC0fQ4wcaQgJLfmxnx73FsgA+ANT7K0tOUedB6ClO0WL715/TIT7OnweswdIb8P47d2Q0flMW/YrxSzJjmf8l9sEPerAHfBxm5EaaKIHsj/Sd4x0/5OVOIFaK2nkJPZl6YtdgzWXfh0sXAgn9mp5perfyXJWfXgvQYuZWUthOx8KtOfnE9FBD0Tr8240/fvuO4EqBZhCelTiFnusQkj3PV+QxY5sZZ/wjIfceCB8YOpYuo6YooUmvPh8SA1F02pgmDIsm/vwT58HYQ/9IEdShSdCJZhxLtMxzajTHggtLyvMzFpfE/RTCBkQTlH0loWWIKra55m58582M+ZqxK3rqS81KrJ94/csDSPvt 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: 30 Nov 2024 14:05:31.0351 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 660205db-bc76-450c-1edf-08dd11480d21 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: CY4PEPF0000EDD5.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB4265 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 Sat Nov 30 14:04:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 846547 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2072.outbound.protection.outlook.com [40.107.94.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 0B4881A08AF; Sat, 30 Nov 2024 14:05:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.94.72 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732975538; cv=fail; b=al16TJ2/UKxESHRC4I3ZwuFiRa6wk2KKDUtOyC/wZgVLX06YeTl3hyjU8IEoMDdZPdjZp9vvOKUUDmnhMHVUliIjOTxOHkSa5mjmjEpcSfrDYk5pf+4h4QQgjHgsPxgQMeCgvlX4Er1Li7vqwy6lL+jY+pGb7zxot3tFMEkj41Y= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732975538; c=relaxed/simple; bh=z0GlcC9vwRUmxS0LWl2nrqiX/2qAQj38IxksQe1F4C8=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=XQxHo14ignqSysoopP6Q+OqBwpOMLPkMLPOwEt0zpmIqSPKlxUL53gBKWZslTqr3Fbuu7C6KNdWASKgXW7Rx/iFb4wyxaUE0LL6FsiJAv3eWAE8Fepdxn56TDaWLYk0Z5DSOiYbyBheusUaKom6/7yMkeLzYRiU5iad6GgY4aLQ= 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=LCvtUZf/; arc=fail smtp.client-ip=40.107.94.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="LCvtUZf/" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=J89VvtvmILQx6VHBAj35XWQmxyE24I86d4jJ9RQvSsq+smBiZcWDr7bZI+TZTNFMCTrjOpYlZFjy2FESFGES5TguuBfBhHWY5FxR5UhkoRI6UEMEck/Ps+7Xiz/hd9/eo1GKw5pSdqUP1i0eqAs8tI2NZnh62SOQYjLcnCIdpXvktUU9rGs9wNAr2TbqKJLhREgQWZRH5YftIyVZWciK8sOosLE90uLcPnC1Eqnn4zcEEBu6LfzLyXBPzYRB7odtdeSAYPNpnMS19p/XmWaC/91A/94n8py4rGpZdGr7uxYiHKHsuMGxO5VOEOwwKBVo9Elez6GlWj0p9Yg/aoi+kQ== 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=vJgGfRz/6pI+DqoqDvNz8bIU/zOni2CDHJWkgBIACl89mo4DaLruI86gdz66AnsMmJNuYEx8JkpfZonzK0TfD/ScTlCkr0oJOScswpGR/3IN3kLXk8AVmRrENIP7TS6PPpf6TOLyzOieisFFa5B0D1YRF9kLOaJSEsDf3gv7jGjuR8UcfEtPZPSCWsEc4hfzhzl3tks2Pc9L2ZdjN7xg6Bl1cGsajO1e3dowGPF61JS0VkH0OegqkNAP9HfkvDUmYevo9f95CG3MUazZfkPPjpQV96vqvHuQ0yaLAzuA14scnejvYzZyqejkT41goieFMzr17v7OXIg/W8pXpgfeAg== 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=LCvtUZf/HQtUj74QhTzqy2wHuEevh3+rVWEtQnjBKobWgi1Qyn37HUb89IU6lqI/K+C4lWxkS/0ZEjBqT6rRdchEYPlm2uhrS7uA/UvMZnylCfk8LJF9zKAkju0R80CBA0z/PVSu46F4MNz0RuzNcwbsvaElNI1AXU/Zs3CMMxQ= Received: from PH8PR05CA0006.namprd05.prod.outlook.com (2603:10b6:510:2cc::6) by IA1PR12MB7589.namprd12.prod.outlook.com (2603:10b6:208:42b::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8207.14; Sat, 30 Nov 2024 14:05:33 +0000 Received: from CY4PEPF0000EDD5.namprd03.prod.outlook.com (2603:10b6:510:2cc:cafe::ad) by PH8PR05CA0006.outlook.office365.com (2603:10b6:510:2cc::6) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8230.5 via Frontend Transport; Sat, 30 Nov 2024 14:05:32 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by CY4PEPF0000EDD5.mail.protection.outlook.com (10.167.241.201) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8230.7 via Frontend Transport; Sat, 30 Nov 2024 14:05:32 +0000 Received: from AUS-P9-MLIMONCI.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Sat, 30 Nov 2024 08:05: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 v8 06/22] ACPI: platform_profile: Move sanity check out of the mutex Date: Sat, 30 Nov 2024 08:04:38 -0600 Message-ID: <20241130140454.455-7-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241130140454.455-1-mario.limonciello@amd.com> References: <20241130140454.455-1-mario.limonciello@amd.com> Precedence: bulk X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000EDD5:EE_|IA1PR12MB7589:EE_ X-MS-Office365-Filtering-Correlation-Id: b4d2d5b8-35e6-43d7-3db3-08dd11480de2 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|376014|7416014|1800799024|36860700013|82310400026; X-Microsoft-Antispam-Message-Info: =?utf-8?q?XYyjPB3Qw3fNjtjxpML9Gd3BE+Ngmtz?= =?utf-8?q?nZVSRy+KwmHPC2TXeDFcxgQfEZ1oUrSClwFjMtaycUHWZ4qf4Ct44CbPBWkOnN7TV?= =?utf-8?q?VmYnGFvvrCuXRd2gSJHUOXB5ThPjM8io9uPtUei9etjXEIBY/0B2hbQYR8yKoG0KB?= =?utf-8?q?tpC59eFYtGRV19dKrjVMDpdgz02ZN0HXPlnW+kzJwgPn8ryWVDi/TnW/Z01ntYDia?= =?utf-8?q?hPiNCY/cdBg1SurH4m9ZqJ2euxmHdfrlzNpJxnlxIBza9++slhpxnZa8Bty8wGJzP?= =?utf-8?q?nPATXsaye1TSwUBhr1hdJsxUdOx01sNxOXk1k/4OjzcVZMy7K719nUJfR/f60tUhq?= =?utf-8?q?s9PkSG0X2rZGw6lgedTl7Xs9GUGyNkjg62bUbv8nMGDx4ZcnTlnHpwGL+Wfb3ux2g?= =?utf-8?q?oVWZO+EB8n0PaGqT9GqXIR4R45b4MNaI3J9SR41ZWBKfKJHAsS5Zh68svqiHlsAV3?= =?utf-8?q?g4xs0Dqr/SXjlyN4dS5DjaU5jXywdzx5Fe6hJZwO4k6BkxZ1FMrW9gYZ2SNykl2Zw?= =?utf-8?q?SLrIDcCxwwDEPYdvKHnHNWTW5BBChtRuj6WNEmo40UIFDBOBjO70UeOxPR+4pSm8Y?= =?utf-8?q?HplXMB+qW6Os5+nscxGeAQimFsTbEja8R+FMF7DD6cOKkrSentVPX4XSeI0vdqzG/?= =?utf-8?q?9l8MItl5FOYABPMs+reueRaQqb0AZCB6C/8UuE22JLMU4V+aVDx6WioyZgEn4viWr?= =?utf-8?q?o+iY0NadwMaFix1Q+Ha3sWYsP9/kg29dT/stSEHkfBsvs5uISacvddhV6UZIVyiQL?= =?utf-8?q?5gV3IWp91pB5lOcSxj8S3I5Iur7wdOXugr5wSopdD3AwkJB1/Oq90ZoAcD+yrjT9d?= =?utf-8?q?vIS+vHpnYoHw6Hos3aOmJiSxykjs8aq95KSSHYn03geNAWNXoz1k+gpeyDzARG1PO?= =?utf-8?q?yjcD4fA9LRf6bwW4fuJgbzcizfo/EYjH8q0v0N5JsI3Vhr2+JqT3ltZVq2Z6ijdjO?= =?utf-8?q?TWUuMymSaUhIUQo6j+8Gm4NmtLl6nkfG4G0W5ItZ7cbNgW3Fy8GDeH2+zoko6PpTo?= =?utf-8?q?udBNBw1OolVvaEVk/HArDlY4onRdjZM8zQVQEqIW81tbOnFvQMZLtkUMqADxxM2C8?= =?utf-8?q?A0eBusMV/ks/Rxu7HWOVJiF6bCCWeQTlj/gc71f/wqGxLYS3cNTqc2sYfdaQUWdX4?= =?utf-8?q?2JIQDLTBLUJ+6tTM1KuUAR4sTXY1+jP2bc7rbGXwQSgA96Gc58Xa8eYFyk6+NjuZ6?= =?utf-8?q?hj1rF7K7MLOvp0uE0ddHZ3JiPa6FkOlBpelMO7emuMc1frWiGzy30K7KK4fsMOXRC?= =?utf-8?q?k4QePTqJZGTH32OmOIsnB4uMay3GSA6mwCvydLjv+opqRtcNlsTsh65MnRVniyPOY?= =?utf-8?q?OiVOlpnPbUW4rOZaismjK7BWr7khp3dYHTU7if5gWqL9EzSajGsU+rbwye3jaRVxG?= =?utf-8?q?g7uej+1fQaV?= X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230040)(376014)(7416014)(1800799024)(36860700013)(82310400026); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Nov 2024 14:05:32.3007 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b4d2d5b8-35e6-43d7-3db3-08dd11480de2 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: CY4PEPF0000EDD5.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR12MB7589 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 Sat Nov 30 14:04:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 846306 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2047.outbound.protection.outlook.com [40.107.92.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3D43E19D89D; Sat, 30 Nov 2024 14:05:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.92.47 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732975539; cv=fail; b=cXKKxm/vJZv+vBojemkRFlvB7Gb67pEENw8NeyEkyjcE4E5srfw1u0qMgxgCraWNPq5hr6rZP1MMMCQmIlsI8gRqJNrKh6wplTlXoSe0orzlLghfU8LQIpXk0fvRWK/BdlGvKcaFk2MOUDR9MwtiO0l9w3MbR/r9c0vl7GSzyvM= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732975539; 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=ZH04s30hCERY2b+306sEhPMOQwx/+MIKejh6e6SUWzKJB9x+3w6iCoXM7aoJ0aQFQYGtQ19mHfR68AFPy3Iu6qV+JSg5YMvbRTsJQEuOZDkJ+Ez6G8sECbX7qfRE3GxLY6C3dOIpD/fPix+yVwHNoowqMvMVwt1vh9byUUkU2R8= 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=J7hpyV2i; arc=fail smtp.client-ip=40.107.92.47 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="J7hpyV2i" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=IhJO+bHDYeaIU3CfwJgTG3q2Xb3g0tF2bVHqlUlxXz1hvmFW9c4c7vUILJ0I1Px1iHcAFY89hDPD7dKaOuqu+nGc3AmpvOE6+6rq8EktrwCfoYnK8fDL0gMN5pw/2FXLniyMOIyRbTKQ6HFhgEDDTu3Ekjtljfz1rvWHvAvcOFDes91G4a+mt02jlXOXHushVHTmLzs2E1WgHaqlHDwG4Mp5HaoeqsME63O5eMval881kOffF6A/6qGmwb+viR7JZkvN5MICiX6tiWeKoOuqwnpDGQrZSQtj+elzguPIR4N9QgbYeD+YRAKRT5Ti39r2kaBdnhPlosVp/xnPm8Ymzw== 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=ViX785Eh7wEH2gg+ydGXTYT7ivMsO5bFv/qLVBXciTJ1CJux8mc75S2wPv2oesT5jiCys45Rfr9L0ybKncuHFZ+NiX8QTwPj5dMzI8zJZp0Qepuzn7qcoEy6TZ24IbsVXOQj+yvljhVP62yDEQlaYFj+R0lp/be0IfBOJdhGgCsehfj3n6BGvFh1V6gOwuE72tu8DYuJDtOYhGD981/y5rcHSTb6+TETMq/0LXC4pD0NL5wAsva+CxmxV2A8/+X4BQLxon2wfkjmQBiKWWBio0xxn7AdRtK92P5E8wl4+oMjZB3wZKLb91ljf7EyJvoJXD8khj1Tcnq8BD5jJvHXMw== 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=J7hpyV2it861k2eOxK+pNeM+wBVOadlS8bVSqw84Cnoi6z7V9XglxmsvJG4qpAE5LZirbS3a6ywn223I7DKruPKzQFBPplVqYxNEXEFqhxzlXksRs8KNcMjuBm0aBjO6rme0EXdyEgTBPTLcm/2ETpm67HUFx7bn19cs5G10M5c= Received: from PH8PR05CA0009.namprd05.prod.outlook.com (2603:10b6:510:2cc::26) by IA0PR12MB8896.namprd12.prod.outlook.com (2603:10b6:208:493::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8207.16; Sat, 30 Nov 2024 14:05:34 +0000 Received: from CY4PEPF0000EDD5.namprd03.prod.outlook.com (2603:10b6:510:2cc:cafe::cc) by PH8PR05CA0009.outlook.office365.com (2603:10b6:510:2cc::26) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8230.5 via Frontend Transport; Sat, 30 Nov 2024 14:05:34 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by CY4PEPF0000EDD5.mail.protection.outlook.com (10.167.241.201) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8230.7 via Frontend Transport; Sat, 30 Nov 2024 14:05:33 +0000 Received: from AUS-P9-MLIMONCI.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Sat, 30 Nov 2024 08:05:30 -0600 From: Mario Limonciello To: Hans de Goede , =?utf-8?q?Ilpo_J=C3=A4rvinen?= CC: "Rafael J . Wysocki" , Len Brown , Maximilian Luz , Lee Chun-Yi , "Shyam Sundar S K" , Corentin Chary , "Luke D . Jones" , Ike Panhc , Henrique de Moraes Holschuh , "Alexis Belmonte" , =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= , Ai Chao , Gergo Koteles , open list , "open list:ACPI" , "open list:MICROSOFT SURFACE PLATFORM PROFILE DRIVER" , "open list:THINKPAD ACPI EXTRAS DRIVER" , Mark Pearson , Matthew Schwartz , Mario Limonciello , Armin Wolf Subject: [PATCH v8 07/22] ACPI: platform_profile: Move matching string for new profile out of mutex Date: Sat, 30 Nov 2024 08:04:39 -0600 Message-ID: <20241130140454.455-8-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241130140454.455-1-mario.limonciello@amd.com> References: <20241130140454.455-1-mario.limonciello@amd.com> Precedence: bulk X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000EDD5:EE_|IA0PR12MB8896:EE_ X-MS-Office365-Filtering-Correlation-Id: b55cd38b-4d3a-4841-3239-08dd11480eda X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|376014|7416014|36860700013|1800799024|82310400026; X-Microsoft-Antispam-Message-Info: =?utf-8?q?yjp92yAtg9CJpxDmaSMc0BFF/Ig+L9c?= =?utf-8?q?Zgw2PhauHLPnDIilL5SO1CiekmvTzbgleGwZ161Cm37CxdR5uLhQI57fldfcvhgjY?= =?utf-8?q?bO2j23HEgQfVFzbC2BJKHahpZI7SYOakl1lqo8PnRw8ZGdW2wjIYJ7d7XnzJXqgcw?= =?utf-8?q?DdNofg1y75MxB4NfheOWZ0CCSpVIdsLmCRkGnyY4EncDFVwdPVTHEvuXXjypYp2bu?= =?utf-8?q?dmzBtUHYVd+3VmYjSPNnDr1Vl8qeOfVcvG9NvKqyd3RTUflY+FWasoshMstD9ZcRg?= =?utf-8?q?Dcafs5xgNOW/z7Qpvnr3RKeXsqWYN1wiGrd8wM/HAjNuKtDIyl1yWxLhcgGWYYUTt?= =?utf-8?q?n0MOdSI0uEsOEzTC/2Uuf26JXo2/GwVm3KkvshYJMGXeTUTZIRLWc4repdzKSS0C7?= =?utf-8?q?vbJ3UDinltTpmwnGj/Jnxt97lH/FQmBGwR2GQx5+8pBF0N7uqifRoy4GjsjqwYfrP?= =?utf-8?q?YrVIv3am+lxHc7TsnMHceOVRmrPaeFq/x3JQqtvXIR3mGUuUwo7dkLX4OW4UEVl2r?= =?utf-8?q?2trJ90zmNO3o/ilI249PLeKLkP6ETKeUzXbFjXMg2GfrOKTyTBvyaQO2puglLNITa?= =?utf-8?q?Go/bcVGAUjk9zIM6GR6xSPu1qkX5m0XfzDylyoRhV1L3qoE49WOln75BpT7P3gi9h?= =?utf-8?q?L8IFUIVdvGEOsR4aTcJtQ4sVAE4s56LVMnV7bDLdMBI56gNTts3TfEex/T10Xuvn+?= =?utf-8?q?B+EDhTwibJeHQ8E9BLL9KvY2L/qrvgNpkfYMrLbwypux4mMMI5mdIuTbDFtgcgd19?= =?utf-8?q?YKaFNyI9rbiQnnGf3jITJnZrZPeaUA2uRCQA6COt7u4x3iZY+6Bqudwll/0YGX6dN?= =?utf-8?q?bGy+SXA+6si5cznrIuwqXCIm2XFWkAzPbotqxZ453/Kmg34dii0lSqJldgZ1j+471?= =?utf-8?q?efpzJhSyYT3bEDtbwKgVztAyu1NqWUnWKoNIkVBseRclFuSGdWVHzIEWMG1QYYE3n?= =?utf-8?q?EWxDS6BPupfUlURGmjyqCwV9vt55rPaMhh3KKNY2toGUEDo1YgZHu/mgisy6uCS/d?= =?utf-8?q?dPcEJwpVN9HYbbweGXKH3WSjb6pJuG0dCV4SXi6gtwkTXglfIkZjVsuOAD9NVAaFU?= =?utf-8?q?nprTGDvXg5nSE+9HPwv7r/RxU/z6hIbLq85QBTn5ZbnI35CYVkQ6OOqvPWmzJy34B?= =?utf-8?q?cRig14SDgvjL+9SP8YX8VP6Dgg0KO2GBwSQJtXYVBH14tWy4po8+O3xQNX4RTBe+e?= =?utf-8?q?3AUYlVfxrPesuvPwPwVoe3dXUXu+S3GCSKEp6ymw5IEfB9+fLEtxSAXTVpxuCQ8ge?= =?utf-8?q?CCekQXG28mRHYySaPZgpGTctrsFTXEIZuYsGBSPNMkSNtDVc+9WolNJkjcEbbOGpu?= =?utf-8?q?lMXxWDsK7P3w7QxytYT74o8toemNSsoBEdWfzKYCrb6wPmv+/jWhSDkGrNXRqDQy0?= =?utf-8?q?ZCtQe6H0UZ+?= X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230040)(376014)(7416014)(36860700013)(1800799024)(82310400026); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Nov 2024 14:05:33.9257 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b55cd38b-4d3a-4841-3239-08dd11480eda 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: CY4PEPF0000EDD5.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA0PR12MB8896 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 Sat Nov 30 14:04:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 846546 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2059.outbound.protection.outlook.com [40.107.243.59]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3E87F1A3BD5; Sat, 30 Nov 2024 14:05:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.243.59 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732975541; cv=fail; b=ndmoyixBQGuF5rh8Hz9NbS+W9Yw9+fgoZopMAPz5hLvvi7I9vmYtzKBFWEP9dZurrnQ+9DOiegzcsZGMEy0EiHz3zmXDOGhXxhdmkyy31bt1Tv15wfMApAhPEDc+TSvBve6ABuq2w3Wfoml16d3JRMksHUbJ9Wo2wutIRUDg9XU= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732975541; c=relaxed/simple; bh=JewyXTxhFRqy6h34+YKrMpsgMeLgKwlZqckAx0I+7ck=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=YnGAvPnnkdvFl27xmRCBJLJSFCRblOO+2GFhIQ9Qtz/of9GFRu2G/PdK8VCjoaI/nn6KEKlkfKFgqrxZM+bSgUXk93EyYkg8r8eW1itb5tRqh8JIzOYhZmpfAKVMHocvO307hJ7954qDFOBf9JUHPBEADn2dR1mJOK0ZccX6rQY= 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=m52Bt791; arc=fail smtp.client-ip=40.107.243.59 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="m52Bt791" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=GfyC+9Wbopz/4uHDjVZSOvvKm5zNF/U8HPEgHD9lJRY3eeI/T9a1UGSJzAOiRxfcyVgY2EEFUm1P7WjqYsZYlQc3VxuV+NLEeQKWM76r5aWQmCcsAQwsOtIBF+BxXbiflDmHzRLbHjXjF/rjGQCFOPFtSJsn4WSj8aJCl9bwvKfaeV50OrPfIEyoVaEFebdGA96udJkC50efBd5mwXkkBiNirRYNhU9D4yBcIiqTOVyubrDjNUHkVPMbNsEmJQkuXZ5ToEjUCTYLkaLCCUbO+C8Sbhrumt1/suonOr4ZJ4YilEJ9xp9iFWBqtTi6qJuorPLCRwfeuHUZ0Kjf4if3nw== 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=v3A5Z8ubVh/LDkGRq2Yu90KeZHSpUBn/nrLIrWCndB31hPZujkmMm6s2oR5BsWi8NH0/HklTk8XIniDgnYfgnzjKYoVh+qO1lTKQhAxvdud8cF8B9v3/r2rfo2UvcuYPcyY67DXDru6+iFsfqkKl4ZNZb7wXba668kOlxIw2DOfbvf9ZYZpxQgysGAG2d9fW8v5aw2RVhqx0HDFDtS/tYcr29txs5cRpeIq32qqpYAeH60oobQW/yweuxDBIp2pj5MPl5gGssxqr/obRPiCZgNqTy9ile3XtX4nmKbU0uBWx+esZLkPvHQsE3C5mTCx9LTaMEn1/4vzDTkrz4+JJQA== 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=m52Bt7913zToxC+muJtg0I39rGFlwczGwiHm+E2MdqAKfRx2Zbe6w0uw6tPowXtRZcsEdtt51T1ANwfhlG5IqllTXXuSZtlcNxg4De3zQ7BTb+/PKf2cYXW54PcOfsVFTQc9yKrwt8KZFRyW4Oz0bxBRZqw1O51Cg/YnJgMzCZ8= Received: from PH8PR05CA0024.namprd05.prod.outlook.com (2603:10b6:510:2cc::12) by CY8PR12MB7415.namprd12.prod.outlook.com (2603:10b6:930:5d::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8207.15; Sat, 30 Nov 2024 14:05:36 +0000 Received: from CY4PEPF0000EDD5.namprd03.prod.outlook.com (2603:10b6:510:2cc:cafe::c) by PH8PR05CA0024.outlook.office365.com (2603:10b6:510:2cc::12) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8230.6 via Frontend Transport; Sat, 30 Nov 2024 14:05:36 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by CY4PEPF0000EDD5.mail.protection.outlook.com (10.167.241.201) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8230.7 via Frontend Transport; Sat, 30 Nov 2024 14:05:36 +0000 Received: from AUS-P9-MLIMONCI.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Sat, 30 Nov 2024 08:05:32 -0600 From: Mario Limonciello To: Hans de Goede , =?utf-8?q?Ilpo_J=C3=A4rvinen?= CC: "Rafael J . Wysocki" , Len Brown , Maximilian Luz , Lee Chun-Yi , "Shyam Sundar S K" , Corentin Chary , "Luke D . Jones" , Ike Panhc , Henrique de Moraes Holschuh , "Alexis Belmonte" , =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= , Ai Chao , Gergo Koteles , open list , "open list:ACPI" , "open list:MICROSOFT SURFACE PLATFORM PROFILE DRIVER" , "open list:THINKPAD ACPI EXTRAS DRIVER" , Mark Pearson , Matthew Schwartz , Mario Limonciello , Armin Wolf Subject: [PATCH v8 08/22] ACPI: platform_profile: Use guard(mutex) for register/unregister Date: Sat, 30 Nov 2024 08:04:40 -0600 Message-ID: <20241130140454.455-9-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241130140454.455-1-mario.limonciello@amd.com> References: <20241130140454.455-1-mario.limonciello@amd.com> Precedence: bulk X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000EDD5:EE_|CY8PR12MB7415:EE_ X-MS-Office365-Filtering-Correlation-Id: b412c357-174c-4657-ac08-08dd11481038 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|1800799024|36860700013|376014|7416014|82310400026|7053199007; X-Microsoft-Antispam-Message-Info: =?utf-8?q?26aSt9uzC4Mt9HZVo6vXIu+9orpsJ+r?= =?utf-8?q?IQI8uRV8kkaKtpSUAUq9GEuRw8UG3ymT17vEeYxWTi4eZ+0SDq5MfVfaFVm+0yLGP?= =?utf-8?q?WaJeciuNAsaNEu7lXTlJmmq09c6ncHiB65+lZmnViEDI2lm4yc0IczGopf0Jnv6aL?= =?utf-8?q?8U/L/R55YClhL4uUnEkSiXqihdv+/ff7MqNZYyCWmuy7kom5pdZsW2TmBL6EgUVXF?= =?utf-8?q?kbBsUqs4/UjTdaPLX7hPt3N78XEoqtQoqdbnxseHnRA8LLfCZXyqIplh7Vjqr/elo?= =?utf-8?q?+K3cIXENhA6bXzT3xI4T8TRgywjjfkeSDdEgTv+iUCXoejNJ6alXxC7wYWzOd0OUj?= =?utf-8?q?ouJfQvhaUAK7md4BQ4BtnTXnE52uW8sI43KBsEGjyZxJZa4GtMgA2GXNQUSh86RrQ?= =?utf-8?q?57rM8PnyXVBulknaH0XaLLNhKnOoQnL3+F3j4sH81WV9dFHModXOErY+fcPL9fkY8?= =?utf-8?q?ArFzI5WBNYBV2qYVKLoXWU6nB45PjhXlS7DxWipOniXTEuN3YA4xNAw5MG9ySqd0V?= =?utf-8?q?DeX0VfKEnryk53s1CAa+JyxmJxRCdgoBxqj81+SJ0KFBJhrVRIgm76WPbLMmgJosT?= =?utf-8?q?5XISa9CmbPCrRnkJIW5pXr+2gKSJ3MBPSw3QvwOXCd0whzo4Qz23W7lT7fZAw51U5?= =?utf-8?q?jQhd6ET4ZHjYOGwoA8IUjz2g0eJx65P5TKf/jKu3KjVepMTz6cnCAJLRf8SD4iHdy?= =?utf-8?q?kSMYjmx2gUi0o4IaqcAjz7q489/IdIuI0qmx+VUTPkcHN8tbpFAKkViDaH8/kI2Fx?= =?utf-8?q?kwYtfP0HsQNTKgEJjhnaAFXjrIuHZyDcr5ISUotCXlruruGwzTNncQHJbL+drkybA?= =?utf-8?q?DdCtWHkzpwRYq1BVo1Ih90JAqF52HHJph5fnIgT5SbM89q4DvSGoPyH21RfOiB0IK?= =?utf-8?q?EBOPDFAfmQEpXHXUQLhDzq4/N1wSUNcflTIcL0XmxK8pqX4UAdJSbhR/3xjWa4ckV?= =?utf-8?q?/IqHDy7wNRfy3f2SECu4Zx77/q5gVvhniNgM+RV18wR+OKvAIHxnmXbUWyU04o3/R?= =?utf-8?q?HB3DBo4QeFMDqxEfzTg8ea0W4YlZNCiJk4ltv5tr/RJmWV1sOEixT6GVhG0VW5685?= =?utf-8?q?3qgIpYozSQMr+iyoNrnK1YGYPmhqSr3k6PhGCr1KXOTxEe3sp7sMm7nfuPTXPF8Dc?= =?utf-8?q?ke8+ajwkxIdlZDSClFzpPQ7xRTQqCPvapjgA+pyq0Ttd0lkQV9gcWUnQwkgyDn8Ss?= =?utf-8?q?gGRAeOczPeQ262SuaW2Q5KijakJPs1TS+/SKYty0iz/j6ak4ARo94w8EGrwOA0SIU?= =?utf-8?q?aDMlHWiMmbBwtMVAinW6CCXXOLfRbi/BzYHPJqMr7VtzULuEERrtRSm37y2hr4iTK?= =?utf-8?q?Qg8SLJA5J0PKMnI+kmIrDcQwwDuaz6luc14LXke0oGzwdPVzIKByGisgSFJjzOSZ1?= =?utf-8?q?HDB23aecLXK?= 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)(7053199007); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Nov 2024 14:05:36.2226 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b412c357-174c-4657-ac08-08dd11481038 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: CY4PEPF0000EDD5.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY8PR12MB7415 guard(mutex) can be used to automatically release mutexes when going out of scope. Tested-by: Mark Pearson Tested-by: Matthew Schwartz Reviewed-by: Hans de Goede Reviewed-by: Mark Pearson Reviewed-by: Ilpo Järvinen Reviewed-by: Armin Wolf Signed-off-by: Mario Limonciello --- drivers/acpi/platform_profile.c | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profile.c index 45ffd85a71dd5..9729543df6333 100644 --- a/drivers/acpi/platform_profile.c +++ b/drivers/acpi/platform_profile.c @@ -184,32 +184,26 @@ int platform_profile_register(struct platform_profile_handler *pprof) return -EINVAL; } - mutex_lock(&profile_lock); + guard(mutex)(&profile_lock); /* We can only have one active profile */ - if (cur_profile) { - mutex_unlock(&profile_lock); + if (cur_profile) return -EEXIST; - } err = sysfs_create_group(acpi_kobj, &platform_profile_group); - if (err) { - mutex_unlock(&profile_lock); + if (err) return err; - } cur_profile = pprof; - mutex_unlock(&profile_lock); return 0; } EXPORT_SYMBOL_GPL(platform_profile_register); int platform_profile_remove(struct platform_profile_handler *pprof) { - sysfs_remove_group(acpi_kobj, &platform_profile_group); + guard(mutex)(&profile_lock); - mutex_lock(&profile_lock); + sysfs_remove_group(acpi_kobj, &platform_profile_group); cur_profile = NULL; - mutex_unlock(&profile_lock); return 0; } EXPORT_SYMBOL_GPL(platform_profile_remove); From patchwork Sat Nov 30 14:04:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 846305 Received: from NAM04-BN8-obe.outbound.protection.outlook.com (mail-bn8nam04on2063.outbound.protection.outlook.com [40.107.100.63]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1037319E810; Sat, 30 Nov 2024 14:05:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.100.63 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732975545; cv=fail; b=DowBcg1y5AOChr84a8GrYsSFZNUhU09P3PHADHVQNj9tfYgQmR8HhgxbdnhZIOi2ritiTr/zJmKftUB1zD+pjQe+Id/kjBMNSJPZCTq1VCCU8pBRpyWgH4jhpJNuQy2bQKijizrbC+SjQYxZMGIxOMp6Vlr6BABTwKka1zXwJRE= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732975545; c=relaxed/simple; bh=V3j6Quiii/WwfOPqQqSXcjQgntdEWqh0e4XnsPoRYZ4=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=lviAeeV0U9L1VX+hkr6ri4GT33BVkwfX0zQLxllv3nzbhuE0r2zbDAPf1P/Qa4DsJx6YX6yKVgLCVKOIRtBslTZ69OYSR0CLu1oH6T+cUKTUW+VMscTuxyoK5XfpwyjCIhGP0LYn3zpylRhsOtqcGOyI0Z/Sr7nInQC+0kB62tk= 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=vwyS8QH9; arc=fail smtp.client-ip=40.107.100.63 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="vwyS8QH9" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=dPDdZcHTH6aUjoE8I8HJ5UuSv+kMDAiI6BM0c8PT+6vM7S1VXepaL+hbkr/L3ZrL/kdTdfaDyCuZZwt4BS9m53zSmo73mt8WFAfEg5BIORgH8/XPHsJUb7Gs52yhTMuSn6vgfqSlCgWYbHhi6TghWC5aDCE1fjGd6YtwBwrTrZOQ20Smt7PbUqmUNzUdF64E9V8pG4kV89GvwdU0S0k3PYqUpAnFtGEfzt6kkgUKNxo9KvDxpSdXYT9gTX2X2UGMqA+C8KOgKx+dmgQX5dPN+uZQ4GQzjY9xGXzH/13SVZQ7aSuu37S68T3NPFtGOZ37xnZFFPX5gsUhVuQdS/c8jg== 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=gFzS4aCzkKI1sKuTsJPHF2D67+jU+JB8yqsEk0kOkA0=; b=im0yF9FdmnEYIz1EDgSs84Iw5tyYms+5SOA/rkluzN1FWOAnS2Nzk2go4gfQA4RQxi/6aZYGgK23lBRDGV60LvmLWDzsSWAv1XJej+cLx3niYmDyKDDhebS7W1XMTjzh3Rie7TFjciBJknGiB2Wih5oZCWMmNoYqNgkRBfUOC57/yFTT2j4SC6VC/OMAgzZeJsw7STDhNqf5leXExw6wV6oBnDHmcmgMJx7m6l18F8fHDdSOeEuYBu8M2bR0lZ5OqP0GqgqE8r2GYqKKniTkxzwcWVSOtUxGSlwX/x8HiiORUuzI4xs4PQSoWn0mZ0pHGJy8ujMcdXGLyDBjjuFpfw== 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=gFzS4aCzkKI1sKuTsJPHF2D67+jU+JB8yqsEk0kOkA0=; b=vwyS8QH9hrRqL2PP3N6VhxJmTYPZ2Uabf3FU558UuLJv5FMdhaoiU0liBJKl2Ws0cfbs2Gd5rdZrsxLGbLxQn3eJd0WJlXArqA5ajB2PGolZwhtpfQQLbdjkuXQOR24Ru/cMpURDsb/1o4jN8OTXfriApgnnvcREntMGBd4rwWI= Received: from PH8PR05CA0014.namprd05.prod.outlook.com (2603:10b6:510:2cc::7) by CY8PR12MB8339.namprd12.prod.outlook.com (2603:10b6:930:7e::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8207.14; Sat, 30 Nov 2024 14:05:38 +0000 Received: from CY4PEPF0000EDD5.namprd03.prod.outlook.com (2603:10b6:510:2cc:cafe::fa) by PH8PR05CA0014.outlook.office365.com (2603:10b6:510:2cc::7) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8230.6 via Frontend Transport; Sat, 30 Nov 2024 14:05: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 CY4PEPF0000EDD5.mail.protection.outlook.com (10.167.241.201) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8230.7 via Frontend Transport; Sat, 30 Nov 2024 14:05: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; Sat, 30 Nov 2024 08:05:35 -0600 From: Mario Limonciello To: Hans de Goede , =?utf-8?q?Ilpo_J=C3=A4rvinen?= CC: "Rafael J . Wysocki" , Len Brown , Maximilian Luz , Lee Chun-Yi , "Shyam Sundar S K" , Corentin Chary , "Luke D . Jones" , Ike Panhc , Henrique de Moraes Holschuh , "Alexis Belmonte" , =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= , Ai Chao , Gergo Koteles , open list , "open list:ACPI" , "open list:MICROSOFT SURFACE PLATFORM PROFILE DRIVER" , "open list:THINKPAD ACPI EXTRAS DRIVER" , Mark Pearson , Matthew Schwartz , Mario Limonciello , Armin Wolf Subject: [PATCH v8 09/22] ACPI: platform_profile: Use `scoped_cond_guard` Date: Sat, 30 Nov 2024 08:04:41 -0600 Message-ID: <20241130140454.455-10-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241130140454.455-1-mario.limonciello@amd.com> References: <20241130140454.455-1-mario.limonciello@amd.com> Precedence: bulk X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000EDD5:EE_|CY8PR12MB8339:EE_ X-MS-Office365-Filtering-Correlation-Id: 22e2d806-bfcb-466c-debc-08dd114810ed X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|36860700013|7416014|376014|1800799024|82310400026; X-Microsoft-Antispam-Message-Info: =?utf-8?q?4nOh6grUE57oUNVWduHYcCuqOF3o240?= =?utf-8?q?qWny/wbsVU7YH7qpJzRpbx8OShtvYsxD/8CY1PPbSbgsRZj3lQuGLv1s29gNiVxGJ?= =?utf-8?q?N0zxcptzGe6Jm/lc80WrsAxpNfyEZrZ3hkUcgIqsLB920yOmmw0Jqb7DOPM/AVHPE?= =?utf-8?q?0RJJrhEsBYJZKrf90+jJrfybuaEGhtg/0VB7NQEp32BWl0wbm8MLkGxY4Z4ZtazFj?= =?utf-8?q?3efDTFam+Tt39y5rCBjaF6p4uNPUHpBTHV8LhiqIRuLPcq0UYGqZr28FYQHe6h/16?= =?utf-8?q?8J52A4u8I0EunwX33VBptuUiJdLDk3dRbkUvm1v4ZoS5Q5RPavstsFS5JWMCVg1Vf?= =?utf-8?q?iq0aNqRJi5McJgAVZ+GDJPlWWqgAFfPTailoXM9RAZ6UucAxu38qSnu4Lix2rNUV4?= =?utf-8?q?xeocKxmjCUPkE+QAxDPcJY6dBZi1XS4MXQGZgj+H+eFG91hGq/uE49+Topa3oWLEp?= =?utf-8?q?LzGYK+QvURhFtnRduQGT11Z2iPhCbGVChQ6wIXgS99M+dKzRDui8x1QN9+0uHeudw?= =?utf-8?q?SJyZb0dZNrbfHcjub4sRic72ikMFmVDduMOFyI3meBH/aFSamASLkOaoeSqtVswAw?= =?utf-8?q?dU4vPcG+H9yB4DKaIGvKBW7blGxKl8y5fYPwbmkw1oqgg1gCH23GDjC9nNxct2O/5?= =?utf-8?q?/onUFN7lAIEMFcv8NfgJDvcMTvOnMuA05nEuYVSL1tTA5DnY/77AW/zGDTXpjOtjq?= =?utf-8?q?yA2tQLYJqZi4h9mRy5pvDTVVsjX3O27qlnSFypUTMtmtoyTjvbPI0SyNdIS0uur8h?= =?utf-8?q?HjklG0uyTMNZ1NroiZPddZFhJLu6Zu7xxyZvS0PznP3UVOi6UinHevfgIid0av4+i?= =?utf-8?q?UTUsiYrVFGkPqvtHx4GGClfNtDg9bQAxShj+bFHlHPe6XiaVJ5qaD5s0lcP6he7sa?= =?utf-8?q?8eTUwSxAv0Fyn7CActkJNse2LQZ7jFxJ9dyOr6xGlcopIUTAE4cBaWS6rOziWzp98?= =?utf-8?q?v00sl31aLPI4WyeqxSbwcpiA5G5qDvWtYjieVtLgdKOQCyOGxdQLBweMDY+sO0n33?= =?utf-8?q?t8hcAbG4rDkseLKWTWO+h4BYzulNhx+dGT77O0RNnUAaLAHcfDoT088xa7NP+Kiuc?= =?utf-8?q?MKgWd2jmyQtVCrQCiJZcGDu/+Vd+ND8lcTFYE8yH3CFPPSxuMb8mfSWHzzSVCpDZq?= =?utf-8?q?r3f5IB85224w6cGgC0hcOdLY2yYTgxUbFuecJScvQtYNmmgk2m4L3PnpBTaB9+73K?= =?utf-8?q?7ktJUwSU3g8OIBaZVAc3WZYi3eAn74MT7L7AaBaxYCLqZGIdJhCWmpOmwxZK7KF13?= =?utf-8?q?RoP/+I8peibTaUsCKR/QFEQRMIuViSH37F3hep84cqu0h9DaRnJhqQ4RjxgTCHL5O?= =?utf-8?q?eb9rDVlWEirP++8NG8Qg8+Rw61wEcwHkGo5Y5cunB+3SaXkTdQuiQzqrwuLRdnpZ6?= =?utf-8?q?vz8dlUIZv8K?= 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: 30 Nov 2024 14:05:37.4102 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 22e2d806-bfcb-466c-debc-08dd114810ed 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: CY4PEPF0000EDD5.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY8PR12MB8339 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 | 111 +++++++++++++------------------- 1 file changed, 43 insertions(+), 68 deletions(-) diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profile.c index 9729543df6333..32affb75e782d 100644 --- a/drivers/acpi/platform_profile.c +++ b/drivers/acpi/platform_profile.c @@ -27,25 +27,20 @@ static ssize_t platform_profile_choices_show(struct device *dev, char *buf) { int len = 0; - int err, i; - - err = mutex_lock_interruptible(&profile_lock); - if (err) - return err; - - if (!cur_profile) { - mutex_unlock(&profile_lock); - return -ENODEV; - } - - for_each_set_bit(i, cur_profile->choices, PLATFORM_PROFILE_LAST) { - if (len == 0) - len += sysfs_emit_at(buf, len, "%s", profile_names[i]); - else - len += sysfs_emit_at(buf, len, " %s", profile_names[i]); + int i; + + scoped_cond_guard(mutex_intr, return -ERESTARTSYS, &profile_lock) { + if (!cur_profile) + return -ENODEV; + for_each_set_bit(i, cur_profile->choices, PLATFORM_PROFILE_LAST) { + if (len == 0) + len += sysfs_emit_at(buf, len, "%s", profile_names[i]); + else + len += sysfs_emit_at(buf, len, " %s", profile_names[i]); + } } len += sysfs_emit_at(buf, len, "\n"); - mutex_unlock(&profile_lock); + return len; } @@ -56,20 +51,15 @@ static ssize_t platform_profile_show(struct device *dev, enum platform_profile_option profile = PLATFORM_PROFILE_BALANCED; int err; - err = mutex_lock_interruptible(&profile_lock); - if (err) - return err; + scoped_cond_guard(mutex_intr, return -ERESTARTSYS, &profile_lock) { + if (!cur_profile) + return -ENODEV; - if (!cur_profile) { - mutex_unlock(&profile_lock); - return -ENODEV; + err = cur_profile->profile_get(cur_profile, &profile); + if (err) + return err; } - err = cur_profile->profile_get(cur_profile, &profile); - mutex_unlock(&profile_lock); - if (err) - return err; - /* Check that profile is valid index */ if (WARN_ON((profile < 0) || (profile >= ARRAY_SIZE(profile_names)))) return -EIO; @@ -88,28 +78,21 @@ static ssize_t platform_profile_store(struct device *dev, if (i < 0) return -EINVAL; - err = mutex_lock_interruptible(&profile_lock); - if (err) - return err; + scoped_cond_guard(mutex_intr, return -ERESTARTSYS, &profile_lock) { + if (!cur_profile) + return -ENODEV; - if (!cur_profile) { - mutex_unlock(&profile_lock); - return -ENODEV; - } + /* Check that platform supports this profile choice */ + if (!test_bit(i, cur_profile->choices)) + return -EOPNOTSUPP; - /* Check that platform supports this profile choice */ - if (!test_bit(i, cur_profile->choices)) { - mutex_unlock(&profile_lock); - return -EOPNOTSUPP; + err = cur_profile->profile_set(cur_profile, i); + if (err) + return err; } - err = cur_profile->profile_set(cur_profile, i); - if (!err) - sysfs_notify(acpi_kobj, NULL, "platform_profile"); + sysfs_notify(acpi_kobj, NULL, "platform_profile"); - mutex_unlock(&profile_lock); - if (err) - return err; return count; } @@ -140,36 +123,28 @@ int platform_profile_cycle(void) enum platform_profile_option next; int err; - err = mutex_lock_interruptible(&profile_lock); - if (err) - return err; + scoped_cond_guard(mutex_intr, return -ERESTARTSYS, &profile_lock) { + if (!cur_profile) + return -ENODEV; - if (!cur_profile) { - mutex_unlock(&profile_lock); - return -ENODEV; - } + err = cur_profile->profile_get(cur_profile, &profile); + if (err) + return err; - err = cur_profile->profile_get(cur_profile, &profile); - if (err) { - mutex_unlock(&profile_lock); - return err; - } + next = find_next_bit_wrap(cur_profile->choices, PLATFORM_PROFILE_LAST, + profile + 1); - next = find_next_bit_wrap(cur_profile->choices, PLATFORM_PROFILE_LAST, - profile + 1); + if (WARN_ON(next == PLATFORM_PROFILE_LAST)) + return -EINVAL; - if (WARN_ON(next == PLATFORM_PROFILE_LAST)) { - mutex_unlock(&profile_lock); - return -EINVAL; + err = cur_profile->profile_set(cur_profile, next); + if (err) + return err; } - err = cur_profile->profile_set(cur_profile, next); - mutex_unlock(&profile_lock); - - if (!err) - sysfs_notify(acpi_kobj, NULL, "platform_profile"); + sysfs_notify(acpi_kobj, NULL, "platform_profile"); - return err; + return 0; } EXPORT_SYMBOL_GPL(platform_profile_cycle); From patchwork Sat Nov 30 14:04:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 846545 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2050.outbound.protection.outlook.com [40.107.244.50]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A44511A9B4B; Sat, 30 Nov 2024 14:05:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.244.50 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732975546; cv=fail; b=lvnHendQ8rXQp2KZFm3Cah94P48LrUzouapoRX19kfzogOxhF4QBF6QBgVDFlXiO4W53LE4uU7D0WnMMulMUjZzeeKoAXkQl3qsKQhKxCVyavSKOQG7z3JFruUq7z5p/26lCZHxaQkf3yI+eZYmVMHNbmmuwzOk4DyLuiKoYbJg= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732975546; c=relaxed/simple; bh=FI7FSjcQBb4qdhj94EVuAigUaPmcDtV3WEUVFUlKcxE=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=F/uQcRgJnqW5EFqPGhKeba29vSVZrPCsZq8WyH8rUO+DHW+uNcyHGodMt9Bl6bqWVcNXQRV1y/vqsILENcFt0SPfEK1h8SS5QVDaIdjpwhuvnD2bRcmKDue5SJ/5iYPOc02Jk4jW7Xlpmq76MYzclP47FLiqZFHb47RYuAVbhl8= 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=MYbTL7QL; arc=fail smtp.client-ip=40.107.244.50 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="MYbTL7QL" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=eM9Z/vMEwPb71Zg12zJW+Q4hclce+5KxquVNE7nUOGnc8e0nAW5gjQhCZzsod4ntLqCLAQXLHrtRdV8RUmBttBiEF9V0iiPaSLYnOJrY9DWW+u9wT4nuhfNwblJQ2gHajAWGyY9CFTN8wdO+Ww9gW+gHHnyD3VEi1sErw+Yc2Syt3JM1o21zDRt60Ybg2mt/a2C+O/UeGWQxzjFa3Z0ArzFbqd+az6wkZyCe9PgJc5BsNcUNxuE1keQiFwuhCPl/Q5tDjznO5eyj0y/RRqbJ1/jcofCvOTmnQHestDlkBGE8E/YZhNwNd1WvqbyJd6Qb6m4C6yXOYdXtlfG2wbcfxQ== 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=3AlGnRfO7dlsSelCXZkRBoMdAmTa4FQanRex3onNr0I=; b=lKfW+/x4lr3qKmYpsjIl9TNmw8fcFog/pWd85bl/JlS/T/XVJk8EAB5NGyEJ70SuGlAt2R7PedOuIgL+jnoLRK5+SeIIAYeyvrmf6o6D5AI0qbtdFuFx6hVq0eyUSz5x0qDQQ+j4yDjBPxg9B0sSqFO7NfIjtixwBIoHzLlw4omAaA1bZzdeMPrDiUbPa/fRddKIE+mI7Ubkf1ulGnF0M9Ws2H2PJLWH8+mzQntmJrNrtv7z5RZXKHTojYu39KtlHbm2wR+92rzKW8W18exC0EQBGIhQ1DF3KuFZtZeSxspV9QBDbHSBasqfqpNJdgZ8s5ApdF9Df9h4s0yCDPHz/Q== 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=3AlGnRfO7dlsSelCXZkRBoMdAmTa4FQanRex3onNr0I=; b=MYbTL7QLK1vMp8vaVl9oOd5U1EEzNisRIC5jZyyaC/T11B3twm7btIQxc1WeVOYkVV0uXqM2S43BW+ZDKzS3neY6eQ/CBtr3iP09LDhC9KEcGDlFlHbPqwXevQgE1y8W4ONeIXnL4BWSO/m4Dh7dRb8z6F4e0vExto7VqmjmBLw= Received: from CY8PR10CA0034.namprd10.prod.outlook.com (2603:10b6:930:4b::11) by DS0PR12MB6485.namprd12.prod.outlook.com (2603:10b6:8:c6::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8207.13; Sat, 30 Nov 2024 14:05:40 +0000 Received: from CY4PEPF0000EDD4.namprd03.prod.outlook.com (2603:10b6:930:4b:cafe::30) by CY8PR10CA0034.outlook.office365.com (2603:10b6:930:4b::11) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8207.15 via Frontend Transport; Sat, 30 Nov 2024 14:05: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 CY4PEPF0000EDD4.mail.protection.outlook.com (10.167.241.200) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8230.7 via Frontend Transport; Sat, 30 Nov 2024 14:05: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; Sat, 30 Nov 2024 08:05:37 -0600 From: Mario Limonciello To: Hans de Goede , =?utf-8?q?Ilpo_J=C3=A4rvinen?= CC: "Rafael J . Wysocki" , Len Brown , Maximilian Luz , Lee Chun-Yi , "Shyam Sundar S K" , Corentin Chary , "Luke D . Jones" , Ike Panhc , Henrique de Moraes Holschuh , "Alexis Belmonte" , =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= , Ai Chao , Gergo Koteles , open list , "open list:ACPI" , "open list:MICROSOFT SURFACE PLATFORM PROFILE DRIVER" , "open list:THINKPAD ACPI EXTRAS DRIVER" , Mark Pearson , Matthew Schwartz , Mario Limonciello , Armin Wolf Subject: [PATCH v8 10/22] ACPI: platform_profile: Create class for ACPI platform profile Date: Sat, 30 Nov 2024 08:04:42 -0600 Message-ID: <20241130140454.455-11-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241130140454.455-1-mario.limonciello@amd.com> References: <20241130140454.455-1-mario.limonciello@amd.com> Precedence: bulk X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000EDD4:EE_|DS0PR12MB6485:EE_ X-MS-Office365-Filtering-Correlation-Id: eab8c6d3-3c9f-4af8-221c-08dd1148124b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|376014|82310400026|7416014|1800799024|36860700013; X-Microsoft-Antispam-Message-Info: 5IEdJ4sDwbs/5ylbqFeTLFB/GhHMDb6RbHwF2YhH5XpUlZJ81vAHSSidR0bOAq/6SsDY09LX+8vHEYGJdTiNFrTft8pCkpCwyrGtIA3JNGz2k6f0hAI6pSr5An9wH5c8kEnxkgBc6Y+maKekj2+BF+rUjkxZzjQ6CIolNgAQ0zuX31aybkSHwcJ2U0BFDJJyHmwHQ+KN+x6QKDKk9t094URm9NZJ6A/iVqvZhzU/vh9vWLt7h3/TOhhYPZIaXgFWPZPV92Rr0OPFY03cloN+kLa04RpsVafp2ovGtQQEZjVqIpuZ6aBC1sheuTXXjGJn6WC0mv05khCAYPCgZiqU3pKjZtuWR6Zi9dtapGC6ILIHSRWyOYW0wmFOB0+3U566eBTWbg0s/53VhtDY2Cv/dmvozfnNPUUw01iCOouILWxd5QKLHm/fFhiNm4P83UZczIJ1CaXUybLZTicBCOXyL3eQXV/ZclorHMT9hvzyhVkmpMZuXgqqMA+tHSzDofBun6uHT1NC2vJWCnl237/L+9MfbyRmZOfGklq8vjaww56U8FAGF6MvTUXfoPkMz99v+LxhCSquuKhpJqnudp8/SVybX4I3ErGcMlfOsTN/cAigx5yUM6x50KBEqLv7fvqqAu6R+kR38CW3OkzQpJUVetOka7pKi4owAj42l0fUw9/QoLR/qXGqsIAsZSwR5EnIhEKvESFyCTmqYaBIE/R0M9S7NFDjEtHufSZvydInl8ttsU+m3VRSQiqGpVQfL3fXxRJ78BNFBEyOpFEBt03YmKC/9mIE4KhilEBrlmW5yc54sDXr1RbezJmYriK6fjpWy7zLJjEahnnCq6uHWqdaHwDudEpD4ewFJw7ICHOWUftTDLGSIhSdMUKchMdQIfIQiaufQtiV1bLvHLTYgymqKRMSFYi/fXZpbL+aN3UwPITs3RB33cPOvaa8N0QbI/CXBmubIqVeCsaPDdjp2+t3/aN9nYeugaj49xRxr8LkXTb6/vYqe/0QJZEVeUFFYS1n37OiR0X++2gYFA+UZKu6z3tqylcAr9Bzv3ePEGpJQ27NZURPDGijztNYk/crP02KshrlgGZBEGZ5ScdfOUO7iTS5cJDR15Te7OQKqbXsVq9mdquhRGK5/w5EV92fHCqcSN/NVlTcrFHgU30FB927QVpiIUlVJAh04LkERIuhxZun0vWPCVV2n5KREajXfyH873YJd+a6xzZihiMApjfwxltsrIcj71AR2xzSulGxhDh2w7hxfxP9Z8ACYtfur+pJSYMxuMOHYf5wzdj2uhPAbLCu28Ix5Xrh+tKTjRLrNrK+l+NpelKO5H8AWi5JBW3MLxqv9s7DJIWMDc7ZOTtbHMDaxHuC1mzdxEzVATUKKs58RzTA5KTHWuEsZ7MAgG5tOPDQe0FdVw1+wFux6DsawQ/MJrjWDJwZRq9xpQY2Gl/9SdsMclvUv8RLF9N+xM8S 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)(82310400026)(7416014)(1800799024)(36860700013); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Nov 2024 14:05:39.6991 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: eab8c6d3-3c9f-4af8-221c-08dd1148124b 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: CY4PEPF0000EDD4.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR12MB6485 When registering a platform profile handler create a class device that will allow changing a single platform profile handler. The class and sysfs group are no longer needed when the platform profile core is a module and unloaded, so remove them at that time as well. Reviewed-by: Armin Wolf Tested-by: Mark Pearson Reviewed-by: Mark Pearson Signed-off-by: Mario Limonciello --- v8: * Use attr->mode --- drivers/acpi/platform_profile.c | 82 ++++++++++++++++++++++++++++++-- include/linux/platform_profile.h | 2 + 2 files changed, 79 insertions(+), 5 deletions(-) diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profile.c index 32affb75e782d..36f7b568deba5 100644 --- a/drivers/acpi/platform_profile.c +++ b/drivers/acpi/platform_profile.c @@ -5,6 +5,7 @@ #include #include #include +#include #include #include #include @@ -22,6 +23,12 @@ static const char * const profile_names[] = { }; static_assert(ARRAY_SIZE(profile_names) == PLATFORM_PROFILE_LAST); +static DEFINE_IDA(platform_profile_ida); + +static const struct class platform_profile_class = { + .name = "platform-profile", +}; + static ssize_t platform_profile_choices_show(struct device *dev, struct device_attribute *attr, char *buf) @@ -105,8 +112,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) @@ -164,25 +184,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 Sat Nov 30 14:04:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 846304 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2059.outbound.protection.outlook.com [40.107.94.59]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5FEDF19E99E; Sat, 30 Nov 2024 14:05:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.94.59 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732975549; cv=fail; b=AW2xvJfKZhRatcKh+qIc+uE3VvSNUNZ0ILYD7Dmmz+u8dr14VpnLgRQGD+7UhYAF9k+uWyb54G98lZhNhVhU5qr8dwKQ31hiAUwq7tT0n7ss9e3pvs9VbpIw6/QD3YoWiamxQpdxO/qog8fywlXJUXTwirPger0Fu17fRPPES/4= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732975549; c=relaxed/simple; bh=DVbufMv2cR+FoQSgLi9r41SU5f9qJwfd5FmEJpPVzaA=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Zf6JKoLynTHQzjrzsn+kmQ9R7Vz94sPiLaW9zDdJM+Nllr+VHyM1FbLp2ei4TINX4FvnvlUhQq49zh/4RyY9w0TYUEIHo/EtcUY1aQXPYiVkaAFqR0WBHr1Yx5dgeDkKlLyF30uitsC53qHi+hC97k9gYmEX/31SGk/QBW5gPMw= 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=c/LjrBqr; arc=fail smtp.client-ip=40.107.94.59 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="c/LjrBqr" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=eoWZdIWwcd+GjOOmr6LzWJzDROuietMKAzeQLWriE6LyX+UO/joXhoMFA6jlXdxtsEvPQECpLPYtfJMl2YkcCwsE0lbhER4nL9tJRLEYFB7G75MUjfwhcosriDtTO9XodlybOl09mHf+IVG1emzcTDjb/1vYB6H2ldE45Ug4dYGHfeIk2C331/KJGWh4Xd72ZWRLKH3drWgHpLHgYz9yQvT7n9jA4EtdwlhwBsd+U2I9ZeuO7L+XLOm9C3dg82ukURprbWufFWGZeFyAsbFD5S6mlI0kXBU5w8K9K2xlh+42GOOmb/jvU2ipcGR75r3rJG5LnYcKPjL0MQksoBnTkg== 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=mDXx9JQ2KLp0jPqHncOkllsoPJc+kZfrcqYY2hdE8+U=; b=FrRBKApQZurbpkXOJckhFb4kYdhGVCEV5kHuZWuMj8GvCOEfC2V9hOYjeo5T5M2Is8vNBDusrlwLDa/WhnWZYvI2yZSBPFG04FwvqB9N9sVTxJiVmY+W6d2qPlXoBXoFnbVBB5Lfu/x5zKEM6OtaEz+VtGaEDeI8nHBnW54vh2ddJhKdaObNMYqWa7BFsVbqiDvv+Oxn07hA9SStR3UqqO2cmS9NbusFk8yUMCDQDr55SxpfziaAwiA9aPWT097pRt4Zai6bJkl+/HiyZ8LT4ujB+DLiF7iDUZ02Q/kqs0aPt75PzgbHfC0X4KJ1VrBqpd66oflqkbfCJxHhcqT6mg== 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=mDXx9JQ2KLp0jPqHncOkllsoPJc+kZfrcqYY2hdE8+U=; b=c/LjrBqrxuicRnMh+WTVJ7MB/2w4CGzbJuhP17Pq03yKlnPWzZPmYBA7buft+y9602KA+zquV6mtbr6jKWNkIQjIudO0A6I0hS3G98I8/fuckaqx96Uon4IBJ6bI1xS/trt9YBOjYkrgqZ8iJqb4CXR2crGohY+mpq8j9H7sJRs= Received: from PH7PR10CA0011.namprd10.prod.outlook.com (2603:10b6:510:23d::12) by MN2PR12MB4061.namprd12.prod.outlook.com (2603:10b6:208:19a::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8207.13; Sat, 30 Nov 2024 14:05:43 +0000 Received: from CY4PEPF0000EDD6.namprd03.prod.outlook.com (2603:10b6:510:23d:cafe::10) by PH7PR10CA0011.outlook.office365.com (2603:10b6:510:23d::12) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8207.15 via Frontend Transport; Sat, 30 Nov 2024 14:05:42 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by CY4PEPF0000EDD6.mail.protection.outlook.com (10.167.241.202) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8230.7 via Frontend Transport; Sat, 30 Nov 2024 14:05:42 +0000 Received: from AUS-P9-MLIMONCI.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Sat, 30 Nov 2024 08:05:39 -0600 From: Mario Limonciello To: Hans de Goede , =?utf-8?q?Ilpo_J=C3=A4rvinen?= CC: "Rafael J . Wysocki" , Len Brown , Maximilian Luz , Lee Chun-Yi , "Shyam Sundar S K" , Corentin Chary , "Luke D . Jones" , Ike Panhc , Henrique de Moraes Holschuh , "Alexis Belmonte" , =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= , Ai Chao , Gergo Koteles , open list , "open list:ACPI" , "open list:MICROSOFT SURFACE PLATFORM PROFILE DRIVER" , "open list:THINKPAD ACPI EXTRAS DRIVER" , Mark Pearson , Matthew Schwartz , Mario Limonciello , Armin Wolf Subject: [PATCH v8 11/22] ACPI: platform_profile: Add name attribute to class interface Date: Sat, 30 Nov 2024 08:04:43 -0600 Message-ID: <20241130140454.455-12-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241130140454.455-1-mario.limonciello@amd.com> References: <20241130140454.455-1-mario.limonciello@amd.com> Precedence: bulk X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000EDD6:EE_|MN2PR12MB4061:EE_ X-MS-Office365-Filtering-Correlation-Id: 8deb3eea-ba52-4f15-6419-08dd1148140e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|36860700013|7416014|376014|1800799024|82310400026; X-Microsoft-Antispam-Message-Info: =?utf-8?q?Y3xQVNzvcBwtC0KafeJlguXS5uuEjXu?= =?utf-8?q?LQ3zeY1W6SN4N+/JNJhkBbdt/7iJV4sm09Kw6+6uEBaT6rBZgX9yjuxGBdSL8xckv?= =?utf-8?q?/XhG4TKHxhNx8n/9+wIj8N82sFKLSQQPdvSKuJGoW+/pf0+OlnuNkoEdBjfSfN8mM?= =?utf-8?q?smeYGJDNcnGXT9An90xHAXE4bgcsguCDvSpXv4pkidLybGAUzISrtnMuj0sz7YooC?= =?utf-8?q?CFyQLsdh5VeNQYcI7mtPq0TNShPRAKyyV8DdO5neVrbot1FwRzyOUSVguVDE4wogH?= =?utf-8?q?xbvmGUnzYhLq6VtfNvRwY8beINpjfOi76f6HUnTt3OcCFwWwjkUW3h6xz4FhB0umO?= =?utf-8?q?KM1l2o9yDkYBOnHo8fTxyWCvKRExPXn7so2neShwOV21Hspc9M25sgUkcJItVhlea?= =?utf-8?q?l22sAMh5CuBYn+5cnmKVrhaOKZmyllZOLxPNoh5G/QccY85Xd/lsIZ1b6POBfaLUS?= =?utf-8?q?+eDuJolb2S+Ex6UanjLihynYqZW2M+tsi8I8wqfHTIX/LZXZ+L+yujVZfYanBDAB2?= =?utf-8?q?RyCD3jXS+UX16Qy/Oe2BKMEfgyOlimnxOqoOvwWknAS3GktT8oW5Y6hIBdWqUJkP3?= =?utf-8?q?NegcpPixvPWnn7EmjzoVMgtMKyEnW6tqXHSONmrmwd8tsIiYNTBv2Jw+KVy9oEuGi?= =?utf-8?q?NaqK2NVIFmknhlmmkji9Dei526Kp3fLQlxuL9nOovrKa8TJTwu/5Jym3g6RVhXQBI?= =?utf-8?q?+0N2rUVonzwRd9hM4DDHQDJBnJg0kMD1zN1aOIFsFsoN1Gru2nCNf3Fd0hVZef44n?= =?utf-8?q?bBnemufOfs4bn/foEp2rOHMqrSwQMycRU0EKWDK9ZZU1Lt8fCVB+Eb2dM8p5tPsYb?= =?utf-8?q?j+Ai59etsOUlhuRYGdLW/YW7QOlSvEG1pWZhgAib/dNF7mLJWnkdo8WulaewFNatV?= =?utf-8?q?U9xk+R31UcaLT2soBuW8Z2VAqgosmJSKGd8uYncIbywEpbVp1af3H3bk/xb1WFitD?= =?utf-8?q?WH8+TKIA4HgIUMASbj/cwFnNpvVTFi3GWRpGwjGL38hcsdvfiDAZrC05sxtaPUDyj?= =?utf-8?q?4IXI7OKLDOocJBLBcvrF64+xrzjWpADmwAcSIlcsAo8mcjP1wE1gsUK6k382oobYk?= =?utf-8?q?Q+qY/k0EjKxU+5pl/WwX06REBlGqmpdLI608u4hG476mZV8nNZtGSp8vsfL0XIKF4?= =?utf-8?q?GJerBoa4MxuV85iVoqpWWvXd/qzJx2xLVDaKQvzcys59oSG/4q3lBvPGD4HOs2Q5m?= =?utf-8?q?WW4RDMDtNATgmisAoqu0TDzQ2HkSmEZsE+siWXm3XaOdvNXaLJcG27dO4EwrPzZmy?= =?utf-8?q?572LEXT7KQYX+OOCK249flcbtFzsngabezyfI9oCE9/f7igam2VhxHQ9YTVG2NfCN?= =?utf-8?q?vOhTexrGKU7I62AbkNz26q22wbTWnysTnK9Wiqm9DRLbL03IQEdDGwQWSOBXeix3j?= =?utf-8?q?Wbv08x7+n16?= 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: 30 Nov 2024 14:05:42.6564 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 8deb3eea-ba52-4f15-6419-08dd1148140e 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: CY4PEPF0000EDD6.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR12MB4061 The name attribute shows the name of the associated platform profile handler. Tested-by: Mark Pearson Reviewed-by: Ilpo Järvinen Reviewed-by: Armin Wolf Reviewed-by: Mark Pearson Signed-off-by: Mario Limonciello --- v8: * Whitespace --- drivers/acpi/platform_profile.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profile.c index 36f7b568deba5..eec842bd00643 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 Sat Nov 30 14:04:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 846544 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2057.outbound.protection.outlook.com [40.107.244.57]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 799131AAE0C; Sat, 30 Nov 2024 14:05:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.244.57 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732975555; cv=fail; b=hlWGXPsKDwWcv2HTeC4Q+1kM3xlfmSkOROcVPcPJaUxVp8lfeYQFGeynLqn/F1UbLeksTx6j6MWNidqRKiqO9jMWSBHyUiwCdk1pcWNfwdkxhXuCXHcVYRgyXB5n0dgQ1v7DqbMDfFsXKIm8AHeTQBlMwFpG2EEgPONeNtvrKO8= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732975555; c=relaxed/simple; bh=t1I6XbTlAg32LuZyx/zXnSdsSg4Grm5d56jAKU8vPec=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=dgVFAqWOLj2qUSBNS/dwKAXdNRiKg0mZj3zHGhVHpy3Wh9TWIRMllHwK9pcF8mylhuL/StA5aWNCKwLOlDcRDdpNqOXVd2Jx9UhVB2OYqlGqJSvP0UquHOZZIYEpD77U1U85eB2T2NhSqwVeWjVzJ+xdjBPIi4CgVH4UImpKREo= 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=AIRSw85u; arc=fail smtp.client-ip=40.107.244.57 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="AIRSw85u" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=qAfOZ0Dbir25uyJf/mA4/TXu/W6Cee62sZXRM8NVhsSr+AchUNG4scUx4/VN+C1Rgd1Qzi2zkb00ysKcIQ0nqv+9sG21LW/cI38b2vzwpYMgyL/EE3pH/uaUPy74vsGYv1kTlJtTtJAbipPiYFZomxCrOKDj3h9ZvDd5JVc0tsht6ltLrzGoEgwRbkuQE0yV2Fp1hbpJ+XXsC7ABcpL4ITSxV/QVGNV8KRdc/szGl7IPzvkFOtsrk3ucNYzlPWfFRTk2L1mBAs2uy8XU/ob6leZcOxcL6Z+QSYDT9VwEkJ0SMobPKdsX9X0oVMrmYvREeS9mDjmtsm1Mp7/DgGkP6g== 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=8ZRiBc29Tzl09/U6QRzkiEpEHzP9HtzUZIQBk5q6oLw=; b=J02DDQt0jKwSmEfd728uMa8/DYwDjYzY3SZercl1DaRE837IgOaqL7pxJxYuoayP/YlNiR271cEsIPAU4mQBrnUGPVvOlRsTYBNMV02kOk5xuznj2ul6Tki91jNujsRgVpyrJXGKkLlQgpcuC3ktHw3mOsguPvZEg5rmovnGfZDcpXBrEPtu4VI4jnT7Z67aJPAdXs4+O0l+xglvsc2ypPQeGAGY4C+dIXOlpq+gyfrcmtRHk7Nvrfog7IQoZmlNQTfTyqam+owmn7FW94i+mkA2ok/A800bveZVjSPGc4pkmhybbixGUnLFYAyqpbDmUd21nmQkFC7YuaX9rcuXGg== 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=8ZRiBc29Tzl09/U6QRzkiEpEHzP9HtzUZIQBk5q6oLw=; b=AIRSw85uJY1CiNn7zqOqpas2HRIxLdfpJOvPbUNQQnOqMS0vn/ePPVxfhajrNViLiIcGxpn5Kt1Di8XDMhev2k4tgfY5D1vPvQ/oQpwc2FdiL7teD478hAbozLjcmMo36N/fXM4jgTrf0TFGaWGejGJdhdvti6VNlDa0ZAnkl0I= Received: from PH7PR10CA0006.namprd10.prod.outlook.com (2603:10b6:510:23d::25) by IA0PR12MB8087.namprd12.prod.outlook.com (2603:10b6:208:401::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8207.16; Sat, 30 Nov 2024 14:05:46 +0000 Received: from CY4PEPF0000EDD6.namprd03.prod.outlook.com (2603:10b6:510:23d:cafe::c9) by PH7PR10CA0006.outlook.office365.com (2603:10b6:510:23d::25) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8207.15 via Frontend Transport; Sat, 30 Nov 2024 14:05: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 CY4PEPF0000EDD6.mail.protection.outlook.com (10.167.241.202) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8230.7 via Frontend Transport; Sat, 30 Nov 2024 14:05: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; Sat, 30 Nov 2024 08:05:42 -0600 From: Mario Limonciello To: Hans de Goede , =?utf-8?q?Ilpo_J=C3=A4rvinen?= CC: "Rafael J . Wysocki" , Len Brown , Maximilian Luz , Lee Chun-Yi , "Shyam Sundar S K" , Corentin Chary , "Luke D . Jones" , Ike Panhc , Henrique de Moraes Holschuh , "Alexis Belmonte" , =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= , Ai Chao , Gergo Koteles , open list , "open list:ACPI" , "open list:MICROSOFT SURFACE PLATFORM PROFILE DRIVER" , "open list:THINKPAD ACPI EXTRAS DRIVER" , Mark Pearson , Matthew Schwartz , Mario Limonciello , Armin Wolf Subject: [PATCH v8 12/22] ACPI: platform_profile: Add choices attribute for class interface Date: Sat, 30 Nov 2024 08:04:44 -0600 Message-ID: <20241130140454.455-13-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241130140454.455-1-mario.limonciello@amd.com> References: <20241130140454.455-1-mario.limonciello@amd.com> Precedence: bulk X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000EDD6:EE_|IA0PR12MB8087:EE_ X-MS-Office365-Filtering-Correlation-Id: 6e30b921-7553-4603-89a6-08dd114815f9 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|7416014|376014|1800799024|36860700013|82310400026; X-Microsoft-Antispam-Message-Info: =?utf-8?q?8CoD1vzqIQjWFOBjSfRrPGFJV/upiSR?= =?utf-8?q?QpiDQHgIh805K3Bp3r0wzh3KvMqJ7PTs0mbrkWUNIUHrw72mulcAPnAP34Tb7cXU8?= =?utf-8?q?rwHgDYoACDLpo3WyASK+4TO0f8sRNiUJSup8x+1j1TvccCYRWVPlzToDGbKBWJ89A?= =?utf-8?q?cU1+/+3PlOD3qZ6yi5eHLNwBwHV3u4Cfe3nzYnN6rdw0Hm3I6THtB4kDYxh3TtgKZ?= =?utf-8?q?7Crg/fi90lu6bLEsNqV/VrX401Aa7UnA7/43Lp3MWXHNqVAk7qgxYyvwIpsiEQTAE?= =?utf-8?q?+p8IQho18jzHVh6idSv3DZL0PV2hUbqTxFGofxhU3I/5+stTf/K2wQDVm/hSANOIZ?= =?utf-8?q?AuY2obFhd+bSsvyIwfK/rfD0puxfe9pAH7WySUbXXb3c1d5lTLxVl5ZtF4/WnKdDm?= =?utf-8?q?gXn8ab7w0/kYe0ZkY4TuzBHpaITPmVL47prbwb6ib6iTRebArNylvvR/WT/WMnoIb?= =?utf-8?q?1ZXU5D34FJTH6LPO0Qxf1pfA7OPVoms6HwKvZfPZUecCjOpnii+JAJktkbQlP7XoI?= =?utf-8?q?eXKRB4GCUnLbYpeEfoy+rRo1lRFujZLtXcR2s1bUvr6k7wxSd3sYPnmehoLHs3dMw?= =?utf-8?q?B7RDP+YWeb/CNJWbv2Typ+8//U75alN1Fqku4rEGNZ22eJ+en3Bn9peoPxYYTHKTi?= =?utf-8?q?xiZ4emPUu0gyhZD1zkHvUnayRxx5XRSy1V+0gnLODSuVghuwZVQA7HEfPzXWDVCqb?= =?utf-8?q?VjBpDJWfbuUzAL7c47oqKqBUV43LpUMgUlxTCZ5q2m2K3XOJT/AxBqIu2EqZGozhA?= =?utf-8?q?tHdWbos/jzbK78NBy8AMfxq/hAifqPdGK9hd3LLS6WPdMD46Q6/dnCGd6AUM8dneH?= =?utf-8?q?/c/8kamGmibl1seNDAeHXf9d16OMgdPD5Fr7MSBUt8uEoljTwSZXiqA08yZcDWASL?= =?utf-8?q?11mHrJ18DzCH4FnJFVXCccMiXBAB9rcJT2Y3bDxAYQtSk3LLshXE2jbKoslBTRsAa?= =?utf-8?q?La96YBKCVb8aJS8yLIFvTaTJCjKAG0IS1Iby42XXbbkwhb41HYHEpIjhTFausA5Ui?= =?utf-8?q?TNN6in6V+ymCSGoeczthRybyNI+JBi6/BbgDgkNeCld2nY3eNMETJMedKeMzA3BTs?= =?utf-8?q?7/vfGfzZiDYw9T/2agol6fNUVvO7PScPuhomr/zBimnaF4I+5ebuaoL/djs1PpLXL?= =?utf-8?q?JGVNkYv9b5TBDYQdj7W6rPrdnLRq/rFo9x0MaVxkoxqgQX0ZU95fmCzJhtGGxaEpN?= =?utf-8?q?ZXW7GLf4YhvGYqvcNu5FsAS+tzmZafbrcrHyshPjHNuEdgtPw+dLla/DO+9PsjdkO?= =?utf-8?q?k9MLL1qCsiuYN31/gYy/HUagbcJo2WjbVCT4I5pu75MLX+ZljunD5K06p8h6G3URp?= =?utf-8?q?PKfhsHsQP8z9jPrErXWOT+fhILeUwwYqSPJAapRdIjkmAmxDuiH8dm3jJReEyxhIg?= =?utf-8?q?L9PkXdycCeQ?= X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230040)(7416014)(376014)(1800799024)(36860700013)(82310400026); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Nov 2024 14:05:45.8752 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 6e30b921-7553-4603-89a6-08dd114815f9 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: CY4PEPF0000EDD6.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA0PR12MB8087 The `choices` file will show all possible choices that a given platform profile handler can support. Tested-by: Mark Pearson Reviewed-by: Ilpo Järvinen Reviewed-by: Armin Wolf Reviewed-by: Mark Pearson Signed-off-by: Mario Limonciello --- v8: whitespace --- drivers/acpi/platform_profile.c | 41 +++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profile.c index eec842bd00643..6a257e500b190 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 Sat Nov 30 14:04:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 846303 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2079.outbound.protection.outlook.com [40.107.236.79]) (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 2B73D1AAE1C; Sat, 30 Nov 2024 14:05:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.236.79 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732975556; cv=fail; b=YzHfiGeKk7gft4BAoMBd1bVHsKqJjmccazhVVpuN9Cm8PseQQx9+2zCAIGHTsylp42bgvfMWi8P29U5FaSXnTC9A6uwfAkUp5pzGFiwoGVxH+NpPitEb98dbPxiCwP0laFAt9gYxfaCJSqePdLnZhKZSD+/sWb43RKuJ0GNUSVw= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732975556; c=relaxed/simple; bh=h2Ky7jtzBaaR5QlbUS5caTXpmWSM38o1jfEgxVkS04I=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=YxnCkURksmnfmjO4BscCmMkhrGTt/ve+FZnUGCBscK9PQKknkJJ6sdn+jNSqgUB0TruPwDwoFwdgmMspFTCcuMB/wagnsRJY0+RRVZmyzsKkiQ0+PnVfiQpi1FDXB+ZQdHFfYSpX+/2dho/J44wKPYAYOGYLj0i/8zsuL06lg7A= 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=IHH96HZ+; arc=fail smtp.client-ip=40.107.236.79 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="IHH96HZ+" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=pxXpU9QBi/UmRm58CCYYHLp7EXH68hG8hh6C8fNkw/h8oMiZFgIyzquOvDEnuN1w70oW45coMw5y4+WkuxuFdPLo14HOKrJ/5p94CqI0q8W1xgepqwPzF36ImjH4MpQlFD1OqN2Tr/tebkacptH90GucemyPRsvVlopuaBFV+s1MxuxvU15bzqGcQoJoGBAQiSMfEany70LOn+x9jUKq71T0NIF2SpqfaEUxFYw1p2jU4DokXj2CKU04jGZKnrncHft72RAgqnr8CjHeIL637iRm3JO+TWPRooJ5VxHF6EDQN7cyyRNUfMlAWJnSZYipVKxELzyLuyngFfmO8pMaYQ== 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=H5u9rsFMLdnHOXF2WWNeZ48KTr43LMKytBkZyDTIzUI=; b=AqgzWmLxiWo+PCgRSvBmZ5kLEml9NfjD+TeJdpiWLW9ref4ynICrzYtFQv7Olz5h1/k0tNhxJRdo1Az9BoO2M18dArM5oxMrdvCxlD4mHNJqVKzdtT0Ndi3UypMGJqkCKnZgbS8SGtTysBppZwtMcB/9kUtwT1gWd1kEkpMltb5qu0x/ClAcJklAIFxzGeRM/d5aQDxZeNFWQbYFoujsQLcbfuGqFZAF7EH/TpkYW9w6QCOvA5Gw7LDYGZYN/6l/uYFEQHIElzRDwZNMa6IzE6vaviPgYlhso4OS+VRrn1iDz0+6lYzjjhmRWXMjsO4Qx3Zc0fSGSjs3gRZRzrTNBQ== 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=H5u9rsFMLdnHOXF2WWNeZ48KTr43LMKytBkZyDTIzUI=; b=IHH96HZ+GzCfBgB0UmutNjU4PUih1q6QaGlwGD2lI31CNbZLgcNgRQtySXIxIWZjQzWY6+h5ibytj+Wko6KClbDRZg0B+vOHgdkO/27qIUjd5cepKXmRspgovAh/tNvZWFuKXDLfEKZtqgFteM7Ki9M3B5OB3Yo2ASfN2w+MKy8= Received: from PH8PR05CA0004.namprd05.prod.outlook.com (2603:10b6:510:2cc::23) by MW3PR12MB4378.namprd12.prod.outlook.com (2603:10b6:303:52::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8207.16; Sat, 30 Nov 2024 14:05:49 +0000 Received: from CY4PEPF0000EDD5.namprd03.prod.outlook.com (2603:10b6:510:2cc:cafe::5a) by PH8PR05CA0004.outlook.office365.com (2603:10b6:510:2cc::23) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8230.6 via Frontend Transport; Sat, 30 Nov 2024 14:05:48 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by CY4PEPF0000EDD5.mail.protection.outlook.com (10.167.241.201) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8230.7 via Frontend Transport; Sat, 30 Nov 2024 14:05: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; Sat, 30 Nov 2024 08:05:45 -0600 From: Mario Limonciello To: Hans de Goede , =?utf-8?q?Ilpo_J=C3=A4rvinen?= CC: "Rafael J . Wysocki" , Len Brown , Maximilian Luz , Lee Chun-Yi , "Shyam Sundar S K" , Corentin Chary , "Luke D . Jones" , Ike Panhc , Henrique de Moraes Holschuh , "Alexis Belmonte" , =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= , Ai Chao , Gergo Koteles , open list , "open list:ACPI" , "open list:MICROSOFT SURFACE PLATFORM PROFILE DRIVER" , "open list:THINKPAD ACPI EXTRAS DRIVER" , Mark Pearson , Matthew Schwartz , Mario Limonciello , Armin Wolf Subject: [PATCH v8 13/22] ACPI: platform_profile: Add profile attribute for class interface Date: Sat, 30 Nov 2024 08:04:45 -0600 Message-ID: <20241130140454.455-14-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241130140454.455-1-mario.limonciello@amd.com> References: <20241130140454.455-1-mario.limonciello@amd.com> Precedence: bulk X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000EDD5:EE_|MW3PR12MB4378:EE_ X-MS-Office365-Filtering-Correlation-Id: 1eab7266-e5ea-4b29-1cc2-08dd11481762 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: cQBbXZHunCphh2Id4GkQUK1iTKyIf1amS+3kgKRq/8AVsvpJYz3RIuHT5yDaO07scq7/rGT5+XMSdeJEPy51ecCXaY7SwY0qsNnCC7uh6QHx5Qk3REJ0zWsltx1WTMP6ObGKtly0pwWC/7/YuM8XvO6+Xq1mKYPK7h/PGXoZqZIb+W0JZiG0sPNpQI8akFRC/Y2RhvBzPP/rjIXHC0TNLG3WDA2yw4IAghEo9QrfAEkc65nuFXHSgoCQeorRZuEGFa3yuxjoFg/fFA5KdhFTPr408am/npaAkRsYXoaLALDbDX0pkb0+AJyOMHn5/m/0PncMGZxb3edS2LjmDk4RRWV+Af5Qe9BNZJDFlfbxMTQg1lWEcNTvTZxugdTxiGe/xxP9b1D6sskyBh4OAWUsDMUqEUirXKqBw6pIwHgyDeUYiDrbCinHP1ODZJsCQQd5KAy3X4E1/162zjQmahAaITq+CXVFZT46oGkak/n/P/sID/j56niU5Sb4gzPg44Ul7m5VCg991EtwhdHqqhWtg6SFBql61vB748YIhexKysOvc9c1WF+JuM3lrIfpcDzyl0CRq3sTSBO3VJKqROaZXxD8SG9C2qckFcjJjCabCf+3A07tXnXdNymXn3X7oQ9VW3SaYZWomZtTMw4iLEUi5ta2WKiO4M3bCLiGH/fcqKK0ZNBAbe7yAxeBP9mR8MTKzZ7DP8Ucxj90PTNq3/fRpqz7aWrqIeMqfxaAzeRxO8ihCqA4ZaFSAsHKQqQjj3wuJ4HLHSi4OQ4zHFZqUJCbhH7IGHNw3y6XmRbHcYdqVJSERuI434H0htDiqnluCIs2sIEVcm1AuZI6O3ItOFN4yBsE3GENqFOk/WISxIoVTpqxm+6MIXqX/JvoDpzsiet3LkqWEBspnastcUadn5mHSbqIA4bmYcu+aKKLSXdKJuBcBZvhWxcg9gH96JT6CYz+vtfJOFGqtoOpUJK9VAkWYmmbWShRLzrDcsE/71js/0gpfP/b1O/soBhMO9TjEqsxHL4McxPSatfSzozjyPwB78AFZmBJ0s8vOsynBR9TP92QXCbWZ8AiwwOudbXXCJ039yeDQC4DzroCHPEsjzQMzajmF3bQVNoOSzn4+6BxWy+RoSkUZGor6sQDnRhfh1Y+ic2uKfNcp8+wTaH+aMJI76mlZqkkzjrKkVTOqw6mxRd0JP6uJknTiT77HLPNnA5eAQTJ7OfvkFePDKFOBvIb/Csw6zumSum0L0BG+jlILB0x7ldGc9Zkeonqc/COygJDoz4krLgbeba+m/k3+cWpMHnFltoC4X8yHAgRhf863Y681HBg1S1X+z3RwaV85En1KRwHncOoBMxRyUxtvB3g7FrFdqIV6pH3Nlr5zkJNtElD4IaxnohyqQR/D4Td8CkGSxfJjpLGR1s7uXHvY9lX5k3p19vkP+L+K6k9zmVxRaBtyd9OgeJK/WBOgHXlhVXh 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: 30 Nov 2024 14:05:48.2383 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 1eab7266-e5ea-4b29-1cc2-08dd11481762 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: CY4PEPF0000EDD5.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW3PR12MB4378 Reading and writing the `profile` sysfs file will use the callbacks for the platform profile handler to read or set the given profile. Tested-by: Mark Pearson Reviewed-by: Mark Pearson Reviewed-by: Armin Wolf Signed-off-by: Mario Limonciello --- v8: * whitespace * rename variables --- drivers/acpi/platform_profile.c | 102 ++++++++++++++++++++++++++++++++ 1 file changed, 102 insertions(+) diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profile.c index 6a257e500b190..dbb6428de3ad7 100644 --- a/drivers/acpi/platform_profile.c +++ b/drivers/acpi/platform_profile.c @@ -47,6 +47,52 @@ static ssize_t _commmon_choices_show(unsigned long *choices, char *buf) return len; } +/** + * _store_class_profile - Set the profile for a class device + * @dev: The class device + * @data: The profile to set + */ +static int _store_class_profile(struct device *dev, void *data) +{ + struct platform_profile_handler *handler; + int *bit = (int *)data; + + lockdep_assert_held(&profile_lock); + handler = dev_get_drvdata(dev); + if (!test_bit(*bit, handler->choices)) + return -EOPNOTSUPP; + + return handler->profile_set(handler, *bit); +} + +/** + * get_class_profile - Show the current profile for a class device + * @dev: The class device + * @profile: The profile to return + * Return: 0 on success, -errno on failure + */ +static int get_class_profile(struct device *dev, + enum platform_profile_option *profile) +{ + struct platform_profile_handler *handler; + enum platform_profile_option val; + int err; + + lockdep_assert_held(&profile_lock); + handler = dev_get_drvdata(dev); + err = handler->profile_get(handler, &val); + if (err) { + pr_err("Failed to get profile for handler %s\n", handler->name); + return err; + } + + if (WARN_ON(val >= PLATFORM_PROFILE_LAST)) + return -EINVAL; + *profile = val; + + return 0; +} + /** * name_show - Show the name of the profile handler * @dev: The device @@ -81,9 +127,65 @@ static ssize_t choices_show(struct device *dev, } static DEVICE_ATTR_RO(choices); +/** + * profile_show - Show the current profile for a class device + * @dev: The device + * @attr: The attribute + * @buf: The buffer to write to + * + * Return: The number of bytes written + */ +static ssize_t profile_show(struct device *dev, + struct device_attribute *attr, + char *buf) +{ + enum platform_profile_option profile = PLATFORM_PROFILE_LAST; + int err; + + scoped_cond_guard(mutex_intr, return -ERESTARTSYS, &profile_lock) { + err = get_class_profile(dev, &profile); + if (err) + return err; + } + + return sysfs_emit(buf, "%s\n", profile_names[profile]); +} + +/** + * profile_store - Set the profile for a class device + * @dev: The device + * @attr: The attribute + * @buf: The buffer to read from + * @count: The number of bytes to read + * + * Return: The number of bytes read + */ +static ssize_t profile_store(struct device *dev, + struct device_attribute *attr, + const char *buf, size_t count) +{ + int index, ret; + + index = sysfs_match_string(profile_names, buf); + if (index < 0) + return -EINVAL; + + scoped_cond_guard(mutex_intr, return -ERESTARTSYS, &profile_lock) { + ret = _store_class_profile(dev, &index); + if (ret) + return ret; + } + + sysfs_notify(acpi_kobj, NULL, "platform_profile"); + + return count; +} +static DEVICE_ATTR_RW(profile); + static struct attribute *profile_attrs[] = { &dev_attr_name.attr, &dev_attr_choices.attr, + &dev_attr_profile.attr, NULL }; ATTRIBUTE_GROUPS(profile); From patchwork Sat Nov 30 14:04:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 846543 Received: from NAM02-SN1-obe.outbound.protection.outlook.com (mail-sn1nam02on2080.outbound.protection.outlook.com [40.107.96.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 BCAEE1AAE37; Sat, 30 Nov 2024 14:05:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.96.80 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732975558; cv=fail; b=FAxKDvRvR8XREaYA4Y4sJqvtSkaCVK0+aaWwbKljVtHi7vGzUTZDAtZr3xek6yex/HrqN6tW8flD1F7XZu0OEjuGw33sNVO/aANDGDxj2dZEejxkubFhHEWiChza/8x3VXgztcroLWUtR+6OmIcyvlTT44+yh1HdiIimFgLGRes= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732975558; c=relaxed/simple; bh=wmdPWQqIJG/NThga/EvctX/BUlGiwWiYT2gh2w6KJCY=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=fFZJDiKw5SoYkQUuB07yjNrnzu5iT2r5svm8aFmLi6qzM/+PziR/rHTRdXR0V9IFwgF0oIzInITIDBEsb1+DFT5f8dWNzP/n9Oe6AO0r6bqPm3JA0a3PmET4+otrxBK9QReFIO4UKNL8jZA8HJucJJq3Ws/nEuFO1ngRr6l8isE= 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=S3F5vUoW; arc=fail smtp.client-ip=40.107.96.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="S3F5vUoW" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=pJs9LuA+VrrirYaPvLThjbQz0Z++3Tq4E1WHCyPQgZHzrwZ+CDpdPNjrnQK5xP050J4Pzrz2UQecOVd2zlwY10eRfGNS48Her4K/JTwEcwaXFjn41eiApe93wf1uUUQvAd51mdcu5uvmooeJVZpYu2VoBnBr5DWNQiUT4xDFuAykhXoB0GFgSQfRTPiSmPrg38aZcjSVQqfAn8HgqdRy9t/3+B3KThrq15BYCHWQcmnvM+MAVGlGsdnQ4lfrzStDBig+oKSCUqD1u7UR8rNvstoug2sVlO2d58b2/vP48zIeqxcYVVgMVWkoof1i9eFCcHksFRKr0D76RFx8q8WBsQ== 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=52hZzlVsBau/wCrbXAcGrGvAfqAMPX2AQWVoJTndIdU=; b=iS2rCM1ewFdzlLYuX5T3enSAR/Z+zgNm4uJvcEwR00AutQSv9Vbv22tNrl41aRrBs08x3MlExOlJPYIzpp8EFOesQF0qHV0xFxOh9ofvcFIIu8kjeowCJX92KuhT+/7hYZeYZ5qekukDKk8O1AS8Y6uu0dHQBJrUQYjRPFTvc2pBjpI751WJa6fmZrUN16Ku0xQyu8/FBh0jWvUce5ksDmMXAAE1Y79rkcP98ZLvHLyfjA+Wwu4mYKcglIaDYdVK6Exq9HY+TnmRehfh0svcdH5hoMTIP5Ufsay3/0DCUYJHJ/30aub7gi9eqolwL13DnBPP1xvWVa5iSPTLo+a0mQ== 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=52hZzlVsBau/wCrbXAcGrGvAfqAMPX2AQWVoJTndIdU=; b=S3F5vUoW6YJPqKM/uPLpP1fSFsnT2KqEB/Bpqil76dZhDxk9JoWOZlq5wjTMcz0fL0Eoxy4MadkV/xecZhrW08HWM5xWORkQ3aln20JdqhUp6AF2ettIjLrJRs0Pfecrpm7IihqHzA0sZrovQyHsGDRyLmVhwESo9MUNeXG46ZE= Received: from PH0PR07CA0048.namprd07.prod.outlook.com (2603:10b6:510:e::23) by SJ2PR12MB7848.namprd12.prod.outlook.com (2603:10b6:a03:4ca::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8207.17; Sat, 30 Nov 2024 14:05:51 +0000 Received: from CY4PEPF0000EDD0.namprd03.prod.outlook.com (2603:10b6:510:e:cafe::33) by PH0PR07CA0048.outlook.office365.com (2603:10b6:510:e::23) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8207.13 via Frontend Transport; Sat, 30 Nov 2024 14:05: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 CY4PEPF0000EDD0.mail.protection.outlook.com (10.167.241.196) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8230.7 via Frontend Transport; Sat, 30 Nov 2024 14:05: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; Sat, 30 Nov 2024 08:05:47 -0600 From: Mario Limonciello To: Hans de Goede , =?utf-8?q?Ilpo_J=C3=A4rvinen?= CC: "Rafael J . Wysocki" , Len Brown , Maximilian Luz , Lee Chun-Yi , "Shyam Sundar S K" , Corentin Chary , "Luke D . Jones" , Ike Panhc , Henrique de Moraes Holschuh , "Alexis Belmonte" , =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= , Ai Chao , Gergo Koteles , open list , "open list:ACPI" , "open list:MICROSOFT SURFACE PLATFORM PROFILE DRIVER" , "open list:THINKPAD ACPI EXTRAS DRIVER" , Mark Pearson , Matthew Schwartz , Mario Limonciello , Armin Wolf Subject: [PATCH v8 14/22] ACPI: platform_profile: Notify change events on register and unregister Date: Sat, 30 Nov 2024 08:04:46 -0600 Message-ID: <20241130140454.455-15-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241130140454.455-1-mario.limonciello@amd.com> References: <20241130140454.455-1-mario.limonciello@amd.com> Precedence: bulk X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000EDD0:EE_|SJ2PR12MB7848:EE_ X-MS-Office365-Filtering-Correlation-Id: 9c916f69-9aee-4809-40fb-08dd1148189a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|7416014|376014|1800799024|36860700013|82310400026; X-Microsoft-Antispam-Message-Info: Dxbw7dgsuKQ/p6uiyG0Kr5xRpMRsC4l0ugBEKoqa9bf1AQY/UkUV2F+Twk0yq0rHikIgL1DlhAKB9ijw5U/eFM/tOFoy7g2aCloDQ3/GvBR1DL5tYEh//OF2232mp2qj40bIfx/JgbtPP+eUgCgs74uVlHg+ae6o31f5tP9Fu79TBfqviK/aCPGC7bg2/nsuQxe6bVVFDWX631HmEsZljUhJDd+iuNYA7ozJlYUpLd4PzzKrr6gmF7Ly1CEnA0ZkepfYVf8wK5Km1EU9SUezBRCU6wrBdIGYVKaNDm5LRpNwPoX0o1XXFCQom/KxJjyA1F/UYw9eBz8kcPZPVG5CPiZqEto3V+JzIvSE4xY+8mrCc9zJ/gbQmc/FPKQK8niG59vEXCx4d8zpOl1prjBlP3hHFEMIU0+M+pTcnuDbnWbCThVeyg/E238v+33iIUw4DULUbo0+Zajp2osnwMbXXNhm0jhTHJPXoFfIbez+esMjERMAGn7q8Ze/UmmWJP8qLUI8SDTnYf4Q757OAwo1qi2EVxbIZUoLOD/crodnmPHlQKnfc8266woJePLP16sO1Mj0OFXE+MF9El1BkJrNdfvKW+uu7S+nSNmGn/yFZYev6gvQRX/U9l62VpqJI5BzySLkjUhkxiX0PuZazUNqLzGATb8Ag5EMpiEECKILMVFEs5qzjvwEZsJtL/RvNzBEz5wsHsUh5P0htF5LWbUj/YjcTzq1++PCmOTF+dwMrdt9Oe79pS8o3TSi3ZlUo2ItEuZXb+0DploWnHuSkTjgw1T7KMacy1xASRTvQoKMDa8Xv0BVBKk9T0Oro1edYb9UXruu6JXPJk30AMjdam5jp/qbNOsceYe+NB1g+wWFUpgHVDqhll1Q1QbRhiVf96dbUSrelAosVzLupdXTwC8gCKwA5GqrMJcBOfJKTkKkdM0yLaSZDgWSjKjl2BiJ+wuIQ7EWhsHoygp3qVASbjQEZrFpxTG0mnI4HvKF3cAVnkQQUM8ir2CuBPK6nhZ9ozqnwX0c7BRxsearqDthInpfTS4jtnU08t1QQvcDN1PRFAMsq/EpqlxtfmYed5KN1F+HmKR4gWgQuEiM10KL1rlXCMObuqqDdXp3oBJYFV9Y9DbvMgUShgsrlEvJNsDktgE9IgvPm4No4o/Jcn2STOafLaN3sj07srSQrYHfoC6Sw9yXqZ/y9Yyvq2iQx08u9MLPhpU1rifrVY1fj3ToVzbE3w7+y6lqH8ys1y9svyr63eIac4en3aZr2JDxTh46ArC4t70B8rVCURYeR5NW+zNM5/Az+w81HfAjohR+43mjcCASKtKdUrHgJn3H8gHnXWwrrRpiNcrbobHJO82RjJMbMwNZ20OzjB8hk0XxRbHGQfE9wLaVGgaCjnxQ7R0k2DfXPxZ3ymIrB3B0ZuDnd3dULdgpKINdNsWt8fcoWrXs7x5kIvzasnDd7SJwrdivrvtq X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230040)(7416014)(376014)(1800799024)(36860700013)(82310400026); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Nov 2024 14:05:50.2839 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 9c916f69-9aee-4809-40fb-08dd1148189a 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: CY4PEPF0000EDD0.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ2PR12MB7848 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 dbb6428de3ad7..e93b79f654955 100644 --- a/drivers/acpi/platform_profile.c +++ b/drivers/acpi/platform_profile.c @@ -362,6 +362,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); @@ -392,6 +394,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 Sat Nov 30 14:04:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 846302 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2082.outbound.protection.outlook.com [40.107.236.82]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 099AF19F41C; Sat, 30 Nov 2024 14:05:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.236.82 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732975558; cv=fail; b=u+YFOorsDr7pMA0wrUZsUerYWXvj1ktkbQg/ktY3H82aigXBCLBrQqFbEQRko2JmvDrNkOFyoy6dcFN1eN1zr4CVqt9ZRcdjIpAZCbRxvdyUopZ9KREh0IrNh1KCMb4g21vD1Plh7uEOSSJ11IGDX2DijCtJh+AFlgcL6eefvs8= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732975558; c=relaxed/simple; bh=FivEVQiSvcrqfbiILyAdo9Dr0Eh5WgZGDz8iwEejHcs=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=iGS/Y7yVcATUPB/aCs/ox/YUGYZtBSjggdZXbADXJDGKX+hOza8uBK3RAk/ue1Qlc0Ei98phFZUxM/3xnREsTOr4rGIbSX/EBmzCJ9xtoyASeQ2m3JK7rA58Dk5OzxZC2vzZft4VCSlYNZsW98Cdf+f37kTUhlIoO2OxgJuu91I= 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=2h4Pulvg; arc=fail smtp.client-ip=40.107.236.82 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="2h4Pulvg" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=h4DKLL8hwUk0JyI1+lgSTampWNMMHdoCgRczbscggSd8UQcfDZ50cXaTBabFYFwrRhBEPlVXvHLw/2P9h3wjGdrXSIwID04SyYYF+ScTd9o/fVp3q4+k3VthgCW28tHgq5iSMxaCyUYJ30lScSd0hqvgMSPkk1mCJMY2Yph7KEEh64rSJIlrHJuyXyM2PGelkuxIVOGNoFWKzSC27VODzZRdQxAYnpRPCRzMJ8DN1mNNSk+bnYM60oI3hC2sH8gS9Cu+gNhOGg1Pt3Fdhkr70LS/+qkbteflqoHlQ9FBTIcU9HhffFqSg1vKdKtadoEHeTUA1OSAXUv+tN+3QjDy1A== 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=+6Uyj5RLLZRUpnauTTNAsnw7YZmXfOqC4zYTLtxs1rI=; b=W08PyN0TrDIRP7s0Udm5lTqO7dyK3idz/cgoIhMzKlbbqS3iLy4dspoU3V9F0eX0dVB+yahq7wtpXkQl6JEZ/3dw+4bqhGE2yM8Gwtgw83F1n9vZL0kM41XQFdAh3ocTOo/61qYt/BVX9f2Q8Yzrfd0IYEu4hIFJ4ZllFXcDETBgIZJzfRkKvNyjteUNmB2qTb8KdziALB8G+8yLPCKF59ulADFi45EymyK1NJkR6jw7t5tLn37WDbCU5ASboOxKvoLpLXyZW6LS6ZA6oNleSo2U7tBY8ZfdbUshBUGKtV2p/QW2de9DCmm0G1sQyXtmSvvGuO8PbL78gONlMHxZJw== 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=+6Uyj5RLLZRUpnauTTNAsnw7YZmXfOqC4zYTLtxs1rI=; b=2h4PulvgNDzUKyuCYFfF7NzC43TRL11oFZ32OuWec/dz/ks/qMOAvij5Vm6FlQpMcvwbnBDOXY98vDGZ0wMuOEGswydBIlF1tQ3hY0W/x3N8GHM8JXpArcaK6guE0Qu0nUga4/p3Cs4noerwO9w++fSnnpK8Tcy1ZrGS+UUVdgA= Received: from PH0PR07CA0041.namprd07.prod.outlook.com (2603:10b6:510:e::16) by DS0PR12MB8041.namprd12.prod.outlook.com (2603:10b6:8:147::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8207.16; Sat, 30 Nov 2024 14:05:52 +0000 Received: from CY4PEPF0000EDD0.namprd03.prod.outlook.com (2603:10b6:510:e:cafe::3a) by PH0PR07CA0041.outlook.office365.com (2603:10b6:510:e::16) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8207.14 via Frontend Transport; Sat, 30 Nov 2024 14:05: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 CY4PEPF0000EDD0.mail.protection.outlook.com (10.167.241.196) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8230.7 via Frontend Transport; Sat, 30 Nov 2024 14:05: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; Sat, 30 Nov 2024 08:05:49 -0600 From: Mario Limonciello To: Hans de Goede , =?utf-8?q?Ilpo_J=C3=A4rvinen?= CC: "Rafael J . Wysocki" , Len Brown , Maximilian Luz , Lee Chun-Yi , "Shyam Sundar S K" , Corentin Chary , "Luke D . Jones" , Ike Panhc , Henrique de Moraes Holschuh , "Alexis Belmonte" , =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= , Ai Chao , Gergo Koteles , open list , "open list:ACPI" , "open list:MICROSOFT SURFACE PLATFORM PROFILE DRIVER" , "open list:THINKPAD ACPI EXTRAS DRIVER" , Mark Pearson , Matthew Schwartz , Mario Limonciello , Armin Wolf Subject: [PATCH v8 15/22] ACPI: platform_profile: Only show profiles common for all handlers Date: Sat, 30 Nov 2024 08:04:47 -0600 Message-ID: <20241130140454.455-16-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241130140454.455-1-mario.limonciello@amd.com> References: <20241130140454.455-1-mario.limonciello@amd.com> Precedence: bulk X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000EDD0:EE_|DS0PR12MB8041:EE_ X-MS-Office365-Filtering-Correlation-Id: aaa4fe9f-bfc5-4116-4bab-08dd11481967 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|7416014|376014|1800799024|36860700013|82310400026; X-Microsoft-Antispam-Message-Info: A41QvsaugtCQ6sLJa777RMWP4yK0uKwIf22f0FaXGYqoz/T+0ZzNRg/MjFIovYUgUUqzYRAKFfObPgeuh1Zm2QlF27m0Cfn4i9B85VbHXZvHqR0Ohcv2yf0/FTfrvif/dLxIQulTfKTwZP8uU8WNEdyD6ss2wyZZ9TSwylyoDPGeS61SZaL1rvu6pVKHbg0UekU4tv1tVwUHRyMYVOtB/JM4q6yQUeIapCTYDAfRae4RkHQFzlKQR3fd1H8RL5s6L6d9Vl/Mp6hCZWsU9F6uMUxyqY03HOF5EdzKVd5aSAaD4+4WOdqUB7YCN0He2omGhCUUEv3751fRPTZRV8tv9eLuBPvDEOsJxwDPayI4zmw/EjRns2NooKOgHUvs7aWoeyHrbgvoCqpmGvgeRQ5VgjRXm15wfcmN8C/Xg6MdWRHWPIOfXK7ulPzlblwhIwtgrtRljiTGnESVpolzp/XEiGaoB/W2AQgWRD7UEniOCIaZ5R4j7eWt3zH6PkhJ+/GIvnPs7xUGOVq9RPZFKxcu0WHAfyyKzRCZ6DzPoAmYl2LTL4G0fym3GIE+uBleKMZwMMgG7oX3K29VKSyc57nqJj09TDLlP7kctf3uEDVzmjh7Yz96mm/TrZIxHsTRbk8b8dFBWjCrxUjbNEznb/RsgDwohgtoq3oZ3DE9XX6R0St4g63R5yTA+nq2FIL1IXOEjO9B6cnd77aR5vTWaUIzKCi4xkioO7I0BI460tR69zjF+Pkv/wJWVtR2Y3dT3qW78XaQzggz+bS2y6K13XO6A8G/UrhwImT9dytd1VdGlt2DHGOMWUWKCQWk+HT59IXAPPrk5N4H+gimRglMFwAuf1rdZ3+ic45I456CRYkIi/uKIsG7W+IrmdmBsev86oY2IFwO3dU1j99UklMXaiRaOzfLtho0x3oBmmO9ZuxhY5/2g9SplVqav69b6zpCG3vpNXe+Kqoc6Ikoyw6tMEIlC7ZG9MBxTSIJV39VnTtLLT+uU5ifhmd9tevNF7u2YFJMyphfKXoCC0DrGnLMQcko+YRi7s4AyGRXtBA3SGIwn6+bH2uAw4jgmrKK6HOqXnK3kL1Q2LcYBgODOuXg+Y1u5ycqDTwK1K2DHmnxlzN6CcaFAJ4s/iNnnf/9l4zPRYFMdXgFlc6peVH2wE3Ec6eB9h4jGqKSsS+zWK9Tndr7BSnDGDO1lM0ywl5YuMriav7n8COmmCjb7IqQnYnYJ2Ztcvd/s8xi1R4sC/K3amoxUtA1LY4RwdUCTx5V6WQASQiXcs2PMux3outxluz99Nm5Fe+yhNqLs8thKKwX2L6Up/Wu+LbFB0kvqg/4TVrG6O/EOCLDPnwpTH4oTqyBqeYadnSEGVTd9J2q8SYOw2PW0OPBrYAt20shO4mvEV81Q/eCdIGXVL03ovk8pU+9+I27ocjMFzCIybnU2qjt1RD1X9HcY/+nKejI7WgKDZYxk9/v X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230040)(7416014)(376014)(1800799024)(36860700013)(82310400026); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Nov 2024 14:05:51.6277 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: aaa4fe9f-bfc5-4116-4bab-08dd11481967 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: CY4PEPF0000EDD0.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR12MB8041 If multiple platform profile handlers have been registered, don't allow switching to profiles unique to only one handler. Reviewed-by: Armin Wolf Tested-by: Mark Pearson Tested-by: Matthew Schwartz Reviewed-by: Mark Pearson Signed-off-by: Mario Limonciello --- drivers/acpi/platform_profile.c | 56 ++++++++++++++++++++++++--------- 1 file changed, 42 insertions(+), 14 deletions(-) diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profile.c index e93b79f654955..40826876006b5 100644 --- a/drivers/acpi/platform_profile.c +++ b/drivers/acpi/platform_profile.c @@ -195,26 +195,54 @@ static const struct class platform_profile_class = { .dev_groups = profile_groups, }; +/** + * _aggregate_choices - Aggregate the available profile choices + * @dev: The device + * @data: The available profile choices + * Return: 0 on success, -errno on failure + */ +static int _aggregate_choices(struct device *dev, void *data) +{ + struct platform_profile_handler *handler; + unsigned long *aggregate = data; + + lockdep_assert_held(&profile_lock); + handler = dev_get_drvdata(dev); + if (test_bit(PLATFORM_PROFILE_LAST, aggregate)) + bitmap_copy(aggregate, handler->choices, PLATFORM_PROFILE_LAST); + else + bitmap_and(aggregate, handler->choices, aggregate, PLATFORM_PROFILE_LAST); + + return 0; +} + +/** + * platform_profile_choices_show - Show the available profile choices for legacy sysfs interface + * @dev: The device + * @attr: The attribute + * @buf: The buffer to write to + * Return: The number of bytes written + */ static ssize_t platform_profile_choices_show(struct device *dev, - struct device_attribute *attr, - char *buf) + struct device_attribute *attr, + char *buf) { - int len = 0; - int i; + unsigned long aggregate[BITS_TO_LONGS(PLATFORM_PROFILE_LAST)]; + int err; + set_bit(PLATFORM_PROFILE_LAST, aggregate); scoped_cond_guard(mutex_intr, return -ERESTARTSYS, &profile_lock) { - if (!cur_profile) - return -ENODEV; - for_each_set_bit(i, cur_profile->choices, PLATFORM_PROFILE_LAST) { - if (len == 0) - len += sysfs_emit_at(buf, len, "%s", profile_names[i]); - else - len += sysfs_emit_at(buf, len, " %s", profile_names[i]); - } + err = class_for_each_device(&platform_profile_class, NULL, + aggregate, _aggregate_choices); + if (err) + return err; } - len += sysfs_emit_at(buf, len, "\n"); - return len; + /* no profile handler registered any more */ + if (bitmap_empty(aggregate, PLATFORM_PROFILE_LAST)) + return -EINVAL; + + return _commmon_choices_show(aggregate, buf); } static ssize_t platform_profile_show(struct device *dev, From patchwork Sat Nov 30 14:04:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 846542 Received: from NAM04-DM6-obe.outbound.protection.outlook.com (mail-dm6nam04on2086.outbound.protection.outlook.com [40.107.102.86]) (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 DB0A81AB6E9; Sat, 30 Nov 2024 14:05:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.102.86 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732975560; cv=fail; b=ugyRe5dsrnmHWX7XtCuphncGA4LtuLZCeDLllhm826h3Um5DbTxvVGnqpszoOQ418DdYDWeQVu62J9YFUW1/+K2Tqav9FXUS1o5x7jLfr2k8XZctNVIh/frCma+J+9855/gS+gk/G7SGEbT0V4RvMDPZ1x+KpnLkzOP3IeVeRnA= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732975560; c=relaxed/simple; bh=f+GAxf2ilYPGunufrK0qKluIJjjPc6FBvYYjc4HgZf4=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=D6n2PbMU3+U1Bx86opB6fWsTUJeEnVmrIcfC2+ZVUMGJ8w3clgIEadbY/ODIy2Z08kZsN0LIaGvEaYHsHUCIPiyoAzUGKXSqgHv3q/GCaUD+jsO3zliHsSMMDOTovxv4tX+l5vAT6/2PjOe8d8FABE1ykjsybEQY60+8J3p1J74= 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=EFAiME2Q; arc=fail smtp.client-ip=40.107.102.86 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="EFAiME2Q" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=qO2V4bL+wY4YKX66pCoclzI1z1pyl8YQ4Nt1oneuQnV0tmxZCQDfPkdUGhD6sgw/Q6NGu1Bgw/IADoyOw5xR8XbEIKNZRzULOt7fcmdTkfladcjyUpQjphiZNYz8daghusFFbguIIbubpww3LbaEEHhJVy8xOm/lyP7B2lw96o9+IX28Z9/zWri5i3B9IVOpEo/M+BMYQqABhW7UtSJLDOAwJKkQDMkWDctdQprBwftiy+y4K+oxo1z3YRTdehpGwd6E3xpiWiolwefG5oaEznGShHH+mDaz6tdoDw1u55OAF960peYsgCMxLQBfUpV9E4HoW4k2fSFibatK+5cEXQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=gJM86/5fT/kTWIaWTa20k/1Hba2Jgn8oT1io5vhyWVs=; b=cR/qiM20Lp7zH2Tw3whT26XimHSsDgM3V1Uw6H6z6D0A/2HWHCCkTpQa5w7XS6DbSGh1rpXt6RaiK9C1t6InAxpMBtS2kX7xR3KtB6yJNJKXy8iYS9OoDmXKiy9EDDl5GXr7+iIHJcGQWO4rF+hXr8heB0J167J9N0+3mNXnKlc1H/gi9S8M1MwXrUKrvLfLEm50aoAwZYRCrVL4+3R5l4JXIiNUEtGvvYneYAvWHcFUwhXshOK0OvR5Vnt5SQADbE7WQH4eA+Jo/G4nhzV/e/Obvgfkrg5UKPgFNsYtgbjWUOt4EXHpcYAuet63F6YMJaFaCdcQ/nW/TUQe7638lQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=redhat.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=gJM86/5fT/kTWIaWTa20k/1Hba2Jgn8oT1io5vhyWVs=; b=EFAiME2Qeelqix/nzt121aiL+e/x60kmlT5rbKUKc5U8TAUOqZpsBHvTIm2+cmQ4vwcdTSbjU8qZD2HBQwJ5dxjUJ4eVEpdiIH/nm4N/tMeWHsEG+tTWnWtrp8a6t6EW+RDTNboey7+AqoTIPSyjwT59RX/lpAn7B3UniBBXRFY= Received: from DS7PR05CA0069.namprd05.prod.outlook.com (2603:10b6:8:57::21) by SA3PR12MB9157.namprd12.prod.outlook.com (2603:10b6:806:39a::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8207.16; Sat, 30 Nov 2024 14:05:54 +0000 Received: from CY4PEPF0000EDD3.namprd03.prod.outlook.com (2603:10b6:8:57:cafe::e4) by DS7PR05CA0069.outlook.office365.com (2603:10b6:8:57::21) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8230.5 via Frontend Transport; Sat, 30 Nov 2024 14:05:54 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by CY4PEPF0000EDD3.mail.protection.outlook.com (10.167.241.199) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8230.7 via Frontend Transport; Sat, 30 Nov 2024 14:05:54 +0000 Received: from AUS-P9-MLIMONCI.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Sat, 30 Nov 2024 08:05: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 v8 16/22] ACPI: platform_profile: Add concept of a "custom" profile Date: Sat, 30 Nov 2024 08:04:48 -0600 Message-ID: <20241130140454.455-17-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241130140454.455-1-mario.limonciello@amd.com> References: <20241130140454.455-1-mario.limonciello@amd.com> Precedence: bulk X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000EDD3:EE_|SA3PR12MB9157:EE_ X-MS-Office365-Filtering-Correlation-Id: 757e29dd-8bd7-4a2f-f56e-08dd11481afb X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|82310400026|36860700013|376014|7416014|1800799024; X-Microsoft-Antispam-Message-Info: W7ottaj8Pt5bcg56Gf/ggDaWUAzrqY1yWkDyLUviJBXApyBTUTITnXmUBYaTV+VBl/vkSuvW0JGCjJDTaZeouIWqNZcmSe9XaWkP6oKsgEH/bf3PasxDWykIMTs6qtKqEtBxEuWXeC5sC5DiPs7pzvwUS0ae/Ig/oZcr+J1Cr7pn4odIt04sfIc/vJEIZb/iOW2PvNb6U2sTwanA+InB1GsBSwZMX1fY9b7FT2ZA9RvvEBkGFTAM+kIylQQSaeNIMFbb8XbnUa0reXW3HQWOdRhoMeNwFTlUTrwSAz5MNiPAv+Rw/5cVCW0w9I19iOf8lMLap43iiILulvJg8Qv/rS6RMIaLtRBon+oLRva4Td+bJtTSWg36XmDnETuxmmvwgzlgdZ2m3ovgJRegqFowreq0Ldd5u7OqtbAnwIsvoY7MY8DhoNsPddcMlMTVt/uh+PIE+yh1FW3p1ImgTTeBknVPZAfmBMs0PjkFgYrbQplH4NBMkhYpwXUKvPkf6+PDJKV709DO9wl5HQjafW7Smxq7uKuGg3U37CLt0HLH/PUFwTwQ5NDspzozKqbxLbsOIE4kocP9/K+6wNBsbhwEvsrSP75nU2Wwl8thRGrtJBZ2mBZloJPHhzI6jTjG929c/YinXKurqRh/AutPI6PE1kuGYlKtTfAcibxx0m4j7oCwjcdMg1dmFCjgN1Z6CD8zjIecy8CH7XloGgHmdegnR/lhfnPNQBdBIedZANbfr9LnAaVk379mcaGw5Zt9QLx0RxL5EQZjcwDBp4mwVY4kQSiKAPGPEDkUXIF0PafB39U4c8H7wzxzotgpys74HwIUCp6K6lRgSsYQWs9ic/Mkuu7GP6ybRUm2S2UTZyBaTJEW9ZFvHgdn6WlSiu0wbfGQD7fFj5IgggToX+d9pkC/FEFf3SZzMVDXYN57u3vEuTZsSIJrn9k0u+1s74awROueFPCVwB7Nc7JE6CY6TfJOlrM/NzQKML0+Xxja/1meIriBwBuDgAVbXhV6nbUoDWosMvwmzZIHn2O9dUagOKtwTjrsAaJN/jshD/qGvN8XOmUGJ2pIwGo1Q7JdgTxAx3lYIlOdAxz5q6fZYm5ulX7MwUeG278JW1Acp3eWI6rElRdahLc4XoPk8U9kQK7VicpKgxXulQ2Ywo8KN+S49g/az0e7elmCbLwksWXxxl858MLEhvlp1SHs7AIJItNX5H/+XrqYla+nwjmcYGKiCRMw6KW58w4usbxyypvEmrlKbsxguKUu6bTpm6zM2kOPdT7w7j3QlB3HRczc8ZxL3ZPbc0fb4Upp1pR0SVJQ5lld+jF1Jecme0xmO4TFqiRA4IbScMLGEGEQ3646oOpt/sV/0eiPSKM/B4gdkqLIB+HusUBZBXA5URmLRQLyurJzK68f19Xpt046u3MjJ3b3+TpC7x7wDFPsmOkJXNhsus3YZeFMcaak6oci2X52o0kCQVOu X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230040)(82310400026)(36860700013)(376014)(7416014)(1800799024); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Nov 2024 14:05:54.2797 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 757e29dd-8bd7-4a2f-f56e-08dd11481afb 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: CY4PEPF0000EDD3.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA3PR12MB9157 When two profile handlers don't agree on the current profile it's ambiguous what to show to the legacy sysfs interface. Add a "custom" profile string that userspace will be able to distinguish this situation when using the legacy sysfs interface. Reviewed-by: Armin Wolf Tested-by: Mark Pearson Reviewed-by: Mark Pearson Signed-off-by: Mario Limonciello --- drivers/acpi/platform_profile.c | 1 + include/linux/platform_profile.h | 1 + 2 files changed, 2 insertions(+) diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profile.c index 40826876006b5..a9cd13c5fd39b 100644 --- a/drivers/acpi/platform_profile.c +++ b/drivers/acpi/platform_profile.c @@ -20,6 +20,7 @@ static const char * const profile_names[] = { [PLATFORM_PROFILE_BALANCED] = "balanced", [PLATFORM_PROFILE_BALANCED_PERFORMANCE] = "balanced-performance", [PLATFORM_PROFILE_PERFORMANCE] = "performance", + [PLATFORM_PROFILE_CUSTOM] = "custom", }; static_assert(ARRAY_SIZE(profile_names) == PLATFORM_PROFILE_LAST); diff --git a/include/linux/platform_profile.h b/include/linux/platform_profile.h index a888fd085c513..0682bb4c57e5d 100644 --- a/include/linux/platform_profile.h +++ b/include/linux/platform_profile.h @@ -23,6 +23,7 @@ enum platform_profile_option { PLATFORM_PROFILE_BALANCED, PLATFORM_PROFILE_BALANCED_PERFORMANCE, PLATFORM_PROFILE_PERFORMANCE, + PLATFORM_PROFILE_CUSTOM, PLATFORM_PROFILE_LAST, /*must always be last */ }; From patchwork Sat Nov 30 14:04:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 846301 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2081.outbound.protection.outlook.com [40.107.94.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 C08DC1B0F0B; Sat, 30 Nov 2024 14:06:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.94.81 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732975565; cv=fail; b=UzVunNKpDTFnVNivThGWcXO5X4uZsRrQi3pSQ0TgJVqMGF9SW66mbSETtk3Vd2Vk4AkyY15t6n+/ZQkw9l2hqN30z2Ui7QEjYGdkxN4Pgx/SKwqOC1xX4LbuCUZDpnBfPwb3LTynxz9c+bIeTybVuo8j4o3FFYrIBvJyLnAmQ/M= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732975565; c=relaxed/simple; bh=xJ+M4Lg2cIRGE7DzFAzUz3QMC2iv+n5Ah8qSAwPX1zs=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=P7AZWnVeBkP6TlR3HmHutDcN9R4ECi5gYMRmObwSAiJTMZ9TSOKW75cSIZ+aDB/YcyO/LHPy8WuOI/nHzhB31sylTHr3pRxSQVuOKXv3X1lby2HtrsO773SGIGEeZxA3KkQL4Tm1NMQnrdkIwjpFzAScuyw4VKauc8xT2vsRSng= 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=jiCRChfV; arc=fail smtp.client-ip=40.107.94.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="jiCRChfV" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=haWw623ESxup+Y3ktPqa6AfwZi3sg318or5DoJ9C2If2hrT/kcuawt7pyxBjVXWZ7pZ2dCXhyUjJPsERDWganFM8IHkme/WNs84dqym6gjCm7GE3ITaVJIuHqL1ZtsWam8uTq8AdQUczu7Ijs0f2NWEZZvLvuD6eGG76tOlqkfMcSb8qAy+NHUX8uyt3aw/sFc1dJ14NRPAObWR+aB39IKUiz3ESmbDu2SnGNm1Q/MAAZOIHy028rVo7Nyd78AWWwAHM5CnzmqmsoubW5g7pmo/XNX133jD/Uf3Sn7HQrS5i4g9vyGX/AVkqvE6MVmb6I78WsrykyV+IwKdZnbw3IQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=hKN4rAzipi4gAsFai9pIibJf+kkEH1x3D/3vlXFg0D8=; b=DLRavCF05/BAhVWMldOEQkpGIZ/KmJKaKuXFaPxkhdQxY0b+0cTI4uSzMxqqiZIA/Yzj+Whf8RobTJW/xCiuleJgMvq4PRnOVtQ59waQMeQfdw1ScLpaxOZmEkMFrEQrgZRbUgCWqpxWiDcYMcz/Goy53WyVogwWU6b2LrO55H4g9jTwc2VRQK5moy4Hi5WzGIWh8F2AXuPXkgvySLtLg7tlEeUJZTU6EkSKKLlfVu+UIJUiSiBS3ftNVkBF2Lxo9Cr7U6DqQXZOUYgTmtbLJR8sweK1F2uVa8f9AOWkEmIPON270R5qzvZkD4Q6R0iY2TFmFnLYu89f65CCEfMFqA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=redhat.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=hKN4rAzipi4gAsFai9pIibJf+kkEH1x3D/3vlXFg0D8=; b=jiCRChfVRt8MvhWCcrE/kkaFYAxIMug2aTfZgwNqrYdcnMmHhSThojxOrnQR0e0El3PcEcQ4drWSRZAFL88J9egHsBZZBeXsg1o/wV4/w9b6IvuD82AJkqaWmLZE8zKk9tzFx3oRuffehcXerQeC1EPdMvA+EPf2e91VvGK1TdM= Received: from PH7PR10CA0013.namprd10.prod.outlook.com (2603:10b6:510:23d::9) by SA0PR12MB7002.namprd12.prod.outlook.com (2603:10b6:806:2c0::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8207.15; Sat, 30 Nov 2024 14:05:57 +0000 Received: from CY4PEPF0000EDD6.namprd03.prod.outlook.com (2603:10b6:510:23d:cafe::ad) by PH7PR10CA0013.outlook.office365.com (2603:10b6:510:23d::9) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8207.16 via Frontend Transport; Sat, 30 Nov 2024 14:05:56 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by CY4PEPF0000EDD6.mail.protection.outlook.com (10.167.241.202) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8230.7 via Frontend Transport; Sat, 30 Nov 2024 14:05:56 +0000 Received: from AUS-P9-MLIMONCI.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Sat, 30 Nov 2024 08:05: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 v8 17/22] ACPI: platform_profile: Make sure all profile handlers agree on profile Date: Sat, 30 Nov 2024 08:04:49 -0600 Message-ID: <20241130140454.455-18-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241130140454.455-1-mario.limonciello@amd.com> References: <20241130140454.455-1-mario.limonciello@amd.com> Precedence: bulk X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000EDD6:EE_|SA0PR12MB7002:EE_ X-MS-Office365-Filtering-Correlation-Id: 033cb31f-9eca-4a43-18f1-08dd11481c5d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|1800799024|82310400026|36860700013|376014|7416014; X-Microsoft-Antispam-Message-Info: JhXfx43MaaYL9PnbL9a47cubFfOfhN7sC+Ygwwa40S3V94X2nIGKMMSUiUIH2jmBWHRBRqhmLowhHSsmiKJN3xN+cpZ5frmDbrh/rqoWGRPk/7UXkBL6qDVBczvLnUO7FDu35BQjkudI8EOfn36Ua3cYBBp12mjnN4g1Yp0kyec801e/naMwYtvO2Qh1Ol9U/FlBJzso+GWbRM/91kGR/W5czoX16dbtDD5k09a5cwnaqCbramAu+K3cko7n5cxO0OTvotw17fhPDVcujFP7ubdtE+mefKTs2tWaBmPfMThLwqGP69TzTPfA5MlqedoKZAqVucMmgy63jmIkM2W2bBwT5wHiIpB8h2UdmIn5ueq65oFZY7JdTsT0BuCa180C53YdQHwVw7mFk6dI6uGcIgywXd9kfzGgbgCSl20lIo7Hb8vv8GzelyZrjU8PrnL7xC3pbX57bVvdrOz/OKZDEFy/LweJqq6aETkrVeAJFG2y9ueZRB8WgeW2T9ic3xFrIGn22DqQKNcHcCCZyIKzu0GB8TzpDiXLQQhcv/as09jPuv9avlXVgsbIIkwOj06i2KqoENG4MrLZ0m4fa/pj1UxH7R8y9SrzfjwT3eFupdysxFx7VSgM9kewURkCp16y6dLGbzG/Nby+NywoyAR1ozlKSp1V4+MCjUOFDVQ6P00XHwpaNwUUkXe2iDP7eiY4OdOgWjZJ2jgoDlqRiSEErMcYlqdwxaxxHjVAjmHMTsIqNwJ9/z6mRdZR73lhxDWXgHtBwN/gvuoAOB/0+DBtwmDByQjOntOHr7+iU79KfzLbpO6pamFiN/Mc/0rANC7MnKFBu+mi2eNqZH7bcoFVDcABwSmCJ2D/ajYOjAbc/WQooMvrZ++2TyUBaRI7TEiwtCvYrtfLzV9mleb/3F/L3UCfV143xD4s36cq97hKdL2mlc5KqqgqVqT+tpQmvLNeXLXGIuOKtTf7jXlAxsk6GAhRwZpaEXB8pMbXBAHsY+OtXQ4uxZxcsvmbVEtAre8oZTEoz76drn4t2CLOZKmZmZOKIj8rMEFV39H3qmumdVcVRHjjnaEiesgBXmg6lbzu+bLoKEUZhqOYGG+2v/McGdtXG1/TamO+X2WMwwEnzFN+u8nMskyL9vHqUQ98xzj2opjq1FpCSyGySJncr+wa50biqj/RpJUmvkxpjyO9jmvdrHNMgdOW8XJ+jAZEZmVjMx79k5QDuCxf9p2MFrwH1o99kUxxOoYCOyvde/Yb2y4ZeX8BQpaxYMhalCrOYYePbpEp8Dd5mPn28hjDcogYFqqbD68K6HV54TRv7V+a0vmj4Z2sy/zIaPmf0qE1Hwl7X3h4jUDrtZ24JrQY6cOkWfhSk4B/ZEEMMru77Hdhi+n4hL5urBEvegvlYUM4c9RmiZTFbRVamfEdeTK0PoZb6uRczQsiDlY9xBh7CT4cDizgESEn54UQ92HD9spJ3Oy3 X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230040)(1800799024)(82310400026)(36860700013)(376014)(7416014); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Nov 2024 14:05:56.5940 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 033cb31f-9eca-4a43-18f1-08dd11481c5d 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: CY4PEPF0000EDD6.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA0PR12MB7002 If for any reason multiple profile handlers don't agree on the profile return the custom profile. Reviewed-by: Armin Wolf Tested-by: Mark Pearson Reviewed-by: Mark Pearson Signed-off-by: Mario Limonciello --- drivers/acpi/platform_profile.c | 119 ++++++++++++++++++++++++++------ 1 file changed, 96 insertions(+), 23 deletions(-) diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profile.c index a9cd13c5fd39b..d5f0679d59d50 100644 --- a/drivers/acpi/platform_profile.c +++ b/drivers/acpi/platform_profile.c @@ -66,6 +66,22 @@ static int _store_class_profile(struct device *dev, void *data) return handler->profile_set(handler, *bit); } +/** + * _notify_class_profile - Notify the class device of a profile change + * @dev: The class device + * @data: Unused + */ +static int _notify_class_profile(struct device *dev, void *data) +{ + struct platform_profile_handler *handler = dev_get_drvdata(dev); + + lockdep_assert_held(&profile_lock); + sysfs_notify(&handler->class_dev->kobj, NULL, "profile"); + kobject_uevent(&handler->class_dev->kobj, KOBJ_CHANGE); + + return 0; +} + /** * get_class_profile - Show the current profile for a class device * @dev: The class device @@ -246,51 +262,108 @@ static ssize_t platform_profile_choices_show(struct device *dev, return _commmon_choices_show(aggregate, buf); } +/** + * _aggregate_profiles - Aggregate the profiles for legacy sysfs interface + * @dev: The device + * @data: The profile to return + * Return: 0 on success, -errno on failure + */ +static int _aggregate_profiles(struct device *dev, void *data) +{ + enum platform_profile_option *profile = data; + enum platform_profile_option val; + int err; + + err = get_class_profile(dev, &val); + if (err) + return err; + + if (*profile != PLATFORM_PROFILE_LAST && *profile != val) + *profile = PLATFORM_PROFILE_CUSTOM; + else + *profile = val; + + return 0; +} + +/** + * _store_and_notify - Atomically store and notify a class from legacy sysfs interface + * @dev: The device + * @data: The profile to return + * Return: 0 on success, -errno on failure + */ +static int _store_and_notify(struct device *dev, void *data) +{ + enum platform_profile_option *profile = data; + int err; + + err = _store_class_profile(dev, profile); + if (err) + return err; + return _notify_class_profile(dev, NULL); +} + +/** + * platform_profile_show - Show the current profile for legacy sysfs interface + * @dev: The device + * @attr: The attribute + * @buf: The buffer to write to + * Return: The number of bytes written + */ static ssize_t platform_profile_show(struct device *dev, - struct device_attribute *attr, - char *buf) + struct device_attribute *attr, + char *buf) { - enum platform_profile_option profile = PLATFORM_PROFILE_BALANCED; + enum platform_profile_option profile = PLATFORM_PROFILE_LAST; int err; scoped_cond_guard(mutex_intr, return -ERESTARTSYS, &profile_lock) { - if (!cur_profile) - return -ENODEV; - - err = cur_profile->profile_get(cur_profile, &profile); + err = class_for_each_device(&platform_profile_class, NULL, + &profile, _aggregate_profiles); if (err) return err; } - /* Check that profile is valid index */ - if (WARN_ON((profile < 0) || (profile >= ARRAY_SIZE(profile_names)))) - return -EIO; + /* no profile handler registered any more */ + if (profile == PLATFORM_PROFILE_LAST) + return -EINVAL; return sysfs_emit(buf, "%s\n", profile_names[profile]); } +/** + * platform_profile_store - Set the profile for legacy sysfs interface + * @dev: The device + * @attr: The attribute + * @buf: The buffer to read from + * @count: The number of bytes to read + * Return: The number of bytes read + */ static ssize_t platform_profile_store(struct device *dev, - struct device_attribute *attr, - const char *buf, size_t count) + struct device_attribute *attr, + const char *buf, size_t count) { - int err, i; + unsigned long choices[BITS_TO_LONGS(PLATFORM_PROFILE_LAST)]; + int ret; + int i; /* Scan for a matching profile */ i = sysfs_match_string(profile_names, buf); - if (i < 0) + if (i < 0 || i == PLATFORM_PROFILE_CUSTOM) return -EINVAL; - + set_bit(PLATFORM_PROFILE_LAST, choices); scoped_cond_guard(mutex_intr, return -ERESTARTSYS, &profile_lock) { - if (!cur_profile) - return -ENODEV; - - /* Check that platform supports this profile choice */ - if (!test_bit(i, cur_profile->choices)) + ret = class_for_each_device(&platform_profile_class, NULL, + choices, _aggregate_choices); + if (ret) + return ret; + if (!test_bit(i, choices)) return -EOPNOTSUPP; - err = cur_profile->profile_set(cur_profile, i); - if (err) - return err; + ret = class_for_each_device(&platform_profile_class, NULL, &i, + _store_and_notify); + if (ret) + return ret; } sysfs_notify(acpi_kobj, NULL, "platform_profile"); From patchwork Sat Nov 30 14:04:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 846541 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2082.outbound.protection.outlook.com [40.107.93.82]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 579171B5821; Sat, 30 Nov 2024 14:06:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.93.82 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732975568; cv=fail; b=PesIdSRdMZXk1lFGRLIPC5Corn3tDH5Q5obf+Tes4k/nVxCz47a/2XyZAGrsrBsraFfn8LgU2rIAb16H1XNM7OMflkTJQLSJKMlRnpmPWRHjD2cV6/qLdzWFP9KV1SazNQp9a7wDV464KgJuoX+KbFJntTaYqDzLi9OtADOftgU= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732975568; c=relaxed/simple; bh=KM+dPq6fppV/EB4F1B1uEv7wI59aTtfxB2Knml06lVw=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=XngPsRnaReAMUt6SABF7jAkljrmJ9XQCYJUjYUDgER52DVWtGTCrIPKuykpJQPYxKc7BixSh51GtJcDsmoi7U+lg6R5v/3pS7EQkwWIIV4EnpB1W2gadanop9VITsfe5SFBUbDpcpOP+/35+gsij+yUeNxuefvktXNs19ZLP/XQ= 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=3RIYhA5/; arc=fail smtp.client-ip=40.107.93.82 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="3RIYhA5/" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=RUZCdtZ10IxSZAYKPddrKMkyCsBWuZQhsvggh/p7bebUUIb7shBPqA3tGrT+FtViSVo/E8P1YiDq3d69PFvnPMM5u1o8xkfEh4s0rn3ll1RmGMoVu0kVUvmn0enz/XMsTEqj7vHzaLoPH40T5yTuOkDGpyllVG1RXPgv7uPQRHI9q/BDW93iID8yR1hv/OeCC31NqIIld8nbPJQw6K+N4H55pf7RgqZMlnFeDCfQrIeeYQbpUG9ics1e4H90O5Xm5udjn17jF9YrIR8rKB+HZaKFFQaJ4Ub7FIHXiSwaZt34oIf0AzKXE0F3XmbeYN2SnSXBL9yDAXSzK/sTsxvfSA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=smturJnl38zpoH+XcVv6chpREJCbKkNG0Dg6yMqE52A=; b=mSVpdzkmgnCMuieAFAmFOsmHNFJopRWLLo3K529cbh5YqjAzv2yUJYe1l/BdH6TEUIl1a8nBagpXyCLxIsPJhy6oEo4MYjQ2g4tJo2/7C+hFNDsKF3DZ/Z22FV4WJEQ42dNItHc1EQHURXXL960Uxnlw30C/sxjakUN9Cprpv0SfUe7DmwOwFl1TNf/vysG9lAzogjaEiysdI++/m9zDumuiw88N7mZJQPAKeZtXSVsBBIXGUUMW4VPj6bJhyBFDHvT17Z+yUcTh1rcQ3+zd9Kg7Xm1JDCO2Dt+lb2sv58mUT/Egl77eIetnIUu6lzNibD51R23vNrUPgUyC47vE1Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=redhat.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=smturJnl38zpoH+XcVv6chpREJCbKkNG0Dg6yMqE52A=; b=3RIYhA5/qwG6nqPEA2btkjkTQ1yvC7sAysKE/J2V8wFKlWaCX+9cueGA3KLJ5XA8ZqqTKulhH58+fXi2DVdziiCXHO6aDP6vJETX6YoUQbYCO+BbSSAyBGGczu2GoXJxZiZ8v0PKL/zjSWqw+3QQvt/ge7UIRmylkiWrx7xB4ns= Received: from PH7PR10CA0019.namprd10.prod.outlook.com (2603:10b6:510:23d::27) by IA0PR12MB8086.namprd12.prod.outlook.com (2603:10b6:208:403::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8207.16; Sat, 30 Nov 2024 14:06:01 +0000 Received: from CY4PEPF0000EDD6.namprd03.prod.outlook.com (2603:10b6:510:23d:cafe::4c) by PH7PR10CA0019.outlook.office365.com (2603:10b6:510:23d::27) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8207.15 via Frontend Transport; Sat, 30 Nov 2024 14:05:58 +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 CY4PEPF0000EDD6.mail.protection.outlook.com (10.167.241.202) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8230.7 via Frontend Transport; Sat, 30 Nov 2024 14:05:58 +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; Sat, 30 Nov 2024 08:05:56 -0600 From: Mario Limonciello To: Hans de Goede , =?utf-8?q?Ilpo_J=C3=A4rvinen?= CC: "Rafael J . Wysocki" , Len Brown , Maximilian Luz , Lee Chun-Yi , "Shyam Sundar S K" , Corentin Chary , "Luke D . Jones" , Ike Panhc , Henrique de Moraes Holschuh , "Alexis Belmonte" , =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= , Ai Chao , Gergo Koteles , open list , "open list:ACPI" , "open list:MICROSOFT SURFACE PLATFORM PROFILE DRIVER" , "open list:THINKPAD ACPI EXTRAS DRIVER" , Mark Pearson , Matthew Schwartz , Mario Limonciello , Armin Wolf Subject: [PATCH v8 18/22] ACPI: platform_profile: Check all profile handler to calculate next Date: Sat, 30 Nov 2024 08:04:50 -0600 Message-ID: <20241130140454.455-19-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241130140454.455-1-mario.limonciello@amd.com> References: <20241130140454.455-1-mario.limonciello@amd.com> Precedence: bulk X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000EDD6:EE_|IA0PR12MB8086:EE_ X-MS-Office365-Filtering-Correlation-Id: 93121692-6d6d-4d6d-1f0e-08dd11481d87 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: Goa02tBmzZZ01H5wQWT3J/Z7D2h6W/mPUFKt0aYnAcX8WI0dTjRcFjDl8Ce52CtHgH7GleCp71nuF3y7Upt5blgcjTv8fclnsiEb3US2hDbq/pa6G/OhTBR1BZ427bXTE29KqVimc8A3mKQbYLuhsQEkBuOevhgcPr9DoksUQ14iNe0TxeHJU2IvhCZD0AQ2ndib2cY+PepFedLE4FM+y8HSnr3jEYb0+IoUyJfpjUhLHwLiU+sl6qG/VxtVL3A7q3QnBjgHncUmpCVYwrS7rrIJDuCQcmOgqxdJdPUFapX2jm1NcImUm3hQ88zKVgsSd5HRLZwAooFFcPP7gT3S1gnUBW7hFmDagsG79eXiv0VZ11zJBfSxd7JfCUrCUfYv6kkfs53hfba2/ocEOhgkbDJn3xrR6ac4uBAdy6O6KXM7POVd3T4J4YGZv4RRm+76bJbozLSxqF/b5pAXrDJ3TxXTrvBCGh0F5av0nENlF5v6tiNdYVd+ncGqgnNwJ9xVxg0/uWXoM/cfVCDK5rr3ljMYUFQcnpeBibImP4oFouRZpqJGCkJTgWcRP0kPYR5pCKGSoA95ED06xJCv9YplQE/vnwvY5yh4Pe5Mor6oBHL2J1bc43NWKiemuryevagMmgSHhKykRTsMf0mx9R5vRlCJWDdthnSAPRbnvb0XCaCraFW8v1h3hWU07OI0AFlO8Mw42Yzkf52q/1Oz8bUON8UIzZFAKAiV6xM82DFdXd+EWAsCeTe1IpIw0UBqh4K6VNuxAeu26LtEBUOqzfIW80p1I2/E981NaGC0HVdVJZEwx5g1F6Bo9AIZly4pSOIVcfRpmH0AkAuz4FBWQaZ+gJTBbVKZoEERllB2WE9IlP2gxBEareXNXOfbdlL/yoIl0XfWa0E2CiLJNFarNpQj7hcT3c/+qkBsgRSzQ50LNJQXBLqWCufG586uoRGzTGojNf3+wsAN4LTDbrmU7/4I3md9MH8sau58gKoGRsXTm/OcN5K50wv/XS06/qzkBLNO/8c6hy7s2w+1pajQ0j/7fHYGsRKhArYb07DWjp2dtCUcS9ugkoB1dlJmI2c6nNF63T5l0c7GMwz2vrKU7OKmNU2QJpVDMXy93gvlL/HmBQ0lmacJoKcw2CIxkjwRNawRAFlgIY8vIUKqVbiQiYsdAA11nW3HDvwx3YQO3n2uAzVN+Wlc9BdfOYM+wYnrGePpkfs3DgbyuXmLfsMjh+epGI+9GNue4QgGKwS4kpVYKYnR7teuo47xMmuJHS3hgdJKivvS/tl7yEK0osqAMbFXPATdgclSoU0zTORzV92FUQSv3nLcpbDBOjMQuOzi23tzA4rQEoJZW2cQK6hJtJr4KmOmqcT3Wcr8KPY2hYi/KjuLNSiRhhWOK5xHdbSV08T1xuZNpqUTHmBey7WeSyp0l5S8OxkeHDaQ2EEPk7Bb0ECtZ3Bn9BTS8PFXSYmanZi+ 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: 30 Nov 2024 14:05:58.5471 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 93121692-6d6d-4d6d-1f0e-08dd11481d87 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: CY4PEPF0000EDD6.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA0PR12MB8086 As multiple platform profile handlers might not all support the same profile, cycling to the next profile could have a different result depending on what handler are registered. Check what is active and supported by all handlers to decide what to do. Reviewed-by: Armin Wolf Tested-by: Mark Pearson Reviewed-by: Mark Pearson Signed-off-by: Mario Limonciello --- drivers/acpi/platform_profile.c | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profile.c index d5f0679d59d50..16746d9b9aa7c 100644 --- a/drivers/acpi/platform_profile.c +++ b/drivers/acpi/platform_profile.c @@ -407,25 +407,37 @@ EXPORT_SYMBOL_GPL(platform_profile_notify); int platform_profile_cycle(void) { - enum platform_profile_option profile; - enum platform_profile_option next; + enum platform_profile_option next = PLATFORM_PROFILE_LAST; + enum platform_profile_option profile = PLATFORM_PROFILE_LAST; + unsigned long choices[BITS_TO_LONGS(PLATFORM_PROFILE_LAST)]; int err; + set_bit(PLATFORM_PROFILE_LAST, choices); scoped_cond_guard(mutex_intr, return -ERESTARTSYS, &profile_lock) { - if (!cur_profile) - return -ENODEV; + err = class_for_each_device(&platform_profile_class, NULL, + &profile, _aggregate_profiles); + if (err) + return err; - err = cur_profile->profile_get(cur_profile, &profile); + if (profile == PLATFORM_PROFILE_CUSTOM || + profile == PLATFORM_PROFILE_LAST) + return -EINVAL; + + err = class_for_each_device(&platform_profile_class, NULL, + choices, _aggregate_choices); if (err) return err; - next = find_next_bit_wrap(cur_profile->choices, PLATFORM_PROFILE_LAST, + /* never iterate into a custom if all drivers supported it */ + clear_bit(PLATFORM_PROFILE_CUSTOM, choices); + + next = find_next_bit_wrap(choices, + PLATFORM_PROFILE_LAST, profile + 1); - if (WARN_ON(next == PLATFORM_PROFILE_LAST)) - return -EINVAL; + err = class_for_each_device(&platform_profile_class, NULL, &next, + _store_and_notify); - err = cur_profile->profile_set(cur_profile, next); if (err) return err; } From patchwork Sat Nov 30 14:04:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 846300 Received: from NAM04-BN8-obe.outbound.protection.outlook.com (mail-bn8nam04on2074.outbound.protection.outlook.com [40.107.100.74]) (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 D633F1B5827; Sat, 30 Nov 2024 14:06:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.100.74 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732975570; cv=fail; b=O29ssL4Vt4jcrbpcCf1n0JFY11t0r3uvYegd66wLdP/Jlbpz3vYakcP32HAQcSuuvicQm7ltDb566v7Bl7U1YWu0tz9dpR7au9XHDpCJPJlXV66ucLoERIpxw5RH+/sHGekwLpPuD4YAYlkAQn+TpAJ7e/gL882iFWfA2c/fcrc= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732975570; c=relaxed/simple; bh=Q9avaHbOthdc41LgOEuzAOMf3jR41UX86Qe6lJzXjYc=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=r9lNyR8+azf3gZir8HJlivxsk+W8uNX4DhJOndNKiqYDO3VmDRT4fNQqxhAV31Mqm6xnbqlycezaH4l5KFLNSe4POOckhmda3lKB1HmKEPjU+lBnkTrbOpLBvNBM0l/zMAv3Ufm7s1WIunmG9RXjwbB4ipDJin41DFbUU+MtvoY= 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=qRLVVa74; arc=fail smtp.client-ip=40.107.100.74 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="qRLVVa74" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=yaHPwTGP0IzAsuS9hpK3+A5Bj5/1ner115iNmZwlF+jlxNXKRqPAjFYLYt/tBDGuV4Mo25sKQMFZ8dPs5BESIEgVMyNdbzvCBp1205RizKMZBLLZ5t17Wiykw4U0QRoGMwUlGBdmY/jcblCMqvSKMWm+u+6sEANEhspMxmaP1cGyLxqaw17P8c++D/x0EOq37JunlU/zqbxUVgtXEbUgQJ1SfcRVT3BUYprh8K4se+MoRYKnRQ1qSCaTFfDWPRtWvh2Sbzqnlw6QL3Aaji1ltsS+93XSBNdvB716ouTsAcS6y6odoB6WwGEC3bFJr4OKQOw6oLuhTtipcLkqekccBA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=FhPbuhl5p8r1g6n/pTVVP/pO7JKpLp1XJelDnHFGo9k=; b=h28K3ujT6EykzUTRXxFJOqfcVHUPL/ERSTDYhxa4ImHiZHUs0viQPuItIRz8EnbOxsti5N7E04bp0tiLeg8QVRmiIY34KF1xM8/RmwtOHq0AooflIE7WZKZVLP4VxIoiwaFy3OMvtDVTU3JKNL/mXzYUpFlMlDB1eLDxoWxALGfjsGl1S1xk1q82qjOS+hhDrBSxc//vQdl4KuqrbGTGOsOSm240Vs9UBl0D8UO3lT/rvQ4h8vynKHs3pJabtmDFf6zslrCfviQVIy6QG1JCOsvUdijdbfcQTAmRz8dITWpLHj4DnOBhIVfOR24I8G2CkigJscwBke1oFmvME1nLSw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=redhat.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=FhPbuhl5p8r1g6n/pTVVP/pO7JKpLp1XJelDnHFGo9k=; b=qRLVVa74b2SNb6PKTtH3WUjM1pTbLakWTCcgmTsmTVHE2YrIPPWL8nBwfyW8IGIq2iS9kT8TdJL0cMWPgFDDusr1wZmbHN2R/L/L3Z+rQGV4FGvkoKz+hJp2GHp711wmC742+hoz6k5c5wSomgSzKKzSivqnUwKLLNm0/1NcwL4= Received: from PH7PR10CA0007.namprd10.prod.outlook.com (2603:10b6:510:23d::7) by SJ2PR12MB9209.namprd12.prod.outlook.com (2603:10b6:a03:558::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8207.17; Sat, 30 Nov 2024 14:06:03 +0000 Received: from CY4PEPF0000EDD6.namprd03.prod.outlook.com (2603:10b6:510:23d:cafe::5e) by PH7PR10CA0007.outlook.office365.com (2603:10b6:510:23d::7) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8207.15 via Frontend Transport; Sat, 30 Nov 2024 14:06:03 +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 CY4PEPF0000EDD6.mail.protection.outlook.com (10.167.241.202) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8230.7 via Frontend Transport; Sat, 30 Nov 2024 14:06:03 +0000 Received: from AUS-P9-MLIMONCI.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Sat, 30 Nov 2024 08:05:57 -0600 From: Mario Limonciello To: Hans de Goede , =?utf-8?q?Ilpo_J=C3=A4rvinen?= CC: "Rafael J . Wysocki" , Len Brown , Maximilian Luz , Lee Chun-Yi , "Shyam Sundar S K" , Corentin Chary , "Luke D . Jones" , Ike Panhc , Henrique de Moraes Holschuh , "Alexis Belmonte" , =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= , Ai Chao , Gergo Koteles , open list , "open list:ACPI" , "open list:MICROSOFT SURFACE PLATFORM PROFILE DRIVER" , "open list:THINKPAD ACPI EXTRAS DRIVER" , Mark Pearson , Matthew Schwartz , Mario Limonciello , Armin Wolf Subject: [PATCH v8 19/22] ACPI: platform_profile: Notify class device from platform_profile_notify() Date: Sat, 30 Nov 2024 08:04:51 -0600 Message-ID: <20241130140454.455-20-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241130140454.455-1-mario.limonciello@amd.com> References: <20241130140454.455-1-mario.limonciello@amd.com> Precedence: bulk X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000EDD6:EE_|SJ2PR12MB9209:EE_ X-MS-Office365-Filtering-Correlation-Id: 64d8b033-f9c9-42f9-eaa5-08dd1148205b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|7416014|376014|1800799024|36860700013|82310400026; X-Microsoft-Antispam-Message-Info: zDqYMbulF0QMaPk1JUM3sjGz4FkqSxKXbdNAC/Nh2WS2dk7FgIHYIujy6B9X97cnu2cVai5B/QQoMfacU4jUQfoRfzjK/CKyYyfgOTs43PAOct+5tdvaolr+rngtzDFEDZFykstfXZd9GCyN7xgbl7FkGTzADcw633Lstv3tNd0v7zsDW1Cyq+zhlCljv9a+2kuJlXAnBB9jR/0keBZgi4WBo+dg1ZPcRqgOfyMgO05DO2w3InbWjq0CqYCNRP2qAy+srAzimLIduMo20CTdE4XwsCGl/l+wVx3UKWLgGOJcMqlUq9n3o8f/ydoMc/B0nBzOFvIFdLbsAxhwDQXHKF23ZaWMIR+4J7WQA1zvF4dTw4kKfbhny7KQxuZebnrwu/oyWR0sFYmQ2BiiVeBOn3ue6rEpiF1SgETyLvUbJ9xTznvYX+eo7kQYwP6xK+bGdI5mwVKFIh4ZHjU4j5lG1smtUekuAB2XB25ifbxji1cCctETHak26vdiZOSQ9sYVP7b97HGZzCtLvw6fKvL0Cb/UH6E5EGRv9S4Je7cwbb4w6Rm5aieI8i5XVgUEiUTmF27WBkeVOzcKUZUbi0Xjyh4dCFIsD4+cs4IbW/gum3zquSNS+MwWoRZAEd0I+NO8GxICC0ZBJUsOdAkIZP7tnhu5RfyX/aHj0SQFwuGC3gr7Do3DsiA+Q9CEP+PiJcsktHSM9zXvYmjVOcR+XeJjsgv4Gi7b2v+ZkAt3Zd+f+1CT7ciS0jKt9UxqJJqk4e51iKtXyBUaKd7QMuR0DrmIeYOgED5vdQcLO5eaLBKHYVGcpgHfWtrG/BCZmDocu+ckAUf2Td5rasw/+k0JZB+K0PiO5kpj0Ao5rEo6u5MXhwSZzQ3YLA/iSoDaOZcJLYy8m5VcAU6Jv5DfbdTmQ0l6+cOKEBZ3dO15sj2ASTqpdIdckusnd6hk6w9P+xGSLdc3aBWkxzcdI781W3Ag7iMhhBHiy1LmOoe9hMxJsfGTcxid19vFvaRaIKp4WDmUZ1UZXnp62XYQDHjv1tgZksfr1hB70KZRauxtxNuUEG6Qjdc402IXXUW+6B726P7vww4Eb1MH1bIAHGS4H3JK7S3EL6LcWNsLvMrgpBDCqGTe6DlvAuJxdi6LfvMZds2bDIRg+9XmmZGTzfgQXAzcjvKzfdia9qCmyUpu9QtPBQvI3Vn0nNQBaB6/7d1tw78CK9VeA+ueipjANEllEww23nR7cCFjD8mTlk0I2b9rHfmQ2F3eCtJMkyIjmI/JHvsl6EU/bq7eONwB7WJFKs0vpenYtYAG/KhmJcorjldv9BAgyZCnRwOqe3593/U1KIILUGg+zxtlR9AE2OtijMWXfQu3M+DrXCRQfvEDBKxKdReleKN3PuZYjacgRZb4o4syg2wffCuw+MOk/s+Da6KbJL8SId8GvbJjlh/dgP+zBKqidXtcpciEzyVCWyndSPrFvu7x X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230040)(7416014)(376014)(1800799024)(36860700013)(82310400026); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Nov 2024 14:06:03.2972 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 64d8b033-f9c9-42f9-eaa5-08dd1148205b 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: CY4PEPF0000EDD6.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ2PR12MB9209 When a driver has called platform_profile_notify() both the legacy sysfs interface and the class device should be notified as userspace may listen to either. Reviewed-by: Armin Wolf Reviewed-by: Mark Pearson Signed-off-by: Mario Limonciello --- v8: * notify only one dev --- drivers/acpi/platform_profile.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profile.c index 16746d9b9aa7c..289b5d43638ae 100644 --- a/drivers/acpi/platform_profile.c +++ b/drivers/acpi/platform_profile.c @@ -401,6 +401,9 @@ void platform_profile_notify(struct platform_profile_handler *pprof) { if (!cur_profile) return; + scoped_cond_guard(mutex_intr, return, &profile_lock) { + _notify_class_profile(pprof->class_dev, NULL); + } sysfs_notify(acpi_kobj, NULL, "platform_profile"); } EXPORT_SYMBOL_GPL(platform_profile_notify); From patchwork Sat Nov 30 14:04:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 846540 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2082.outbound.protection.outlook.com [40.107.243.82]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 996E01B6D15; Sat, 30 Nov 2024 14:06:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.243.82 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732975572; cv=fail; b=m60865CFmSZO8cN2guAVhvj67wyIzI5WemrdWWeySaKHzaRGDJftwEHMD/9T7ar1XumN6GBFtEh61h3CuxnP06apVp0Ogc0KJFJvk0EztKGMXm4sMBIqOHta7IUX1kZEJwvRFeZvx7lMdD5TF8vHluEKAu57oyep3pbiBH55fRQ= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732975572; c=relaxed/simple; bh=Ic1kSez1p5RhlfYjfiCieTuIGQgUojglIYTT9+//idM=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=P6eCD1+blAWUNPgXJYIr3vpg4fSTpcTOezReFWraRnZxUY9H7W8/IepwxL+6S782oYMwprc9TCCSIarWr3o6c+vKX19VQqO8xtfiCkeedKlpqnWQn4gZh6Zv5lzfSrvV25ywKR9pkGO2Lsn05sDWbAxTgSnTKLEwu3V7ZBVEt+8= 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=5ncOK61T; arc=fail smtp.client-ip=40.107.243.82 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="5ncOK61T" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=kuXH4GQuBkKa3Yb8imCx6gTMChCpWedGENR7zRvYtNFobNaCMv3Kyan/kTdYbS63rlxcmHfA1ym9s1el61vjfsL51NKJjkA1z1rS0ZoVP39NQNy0jdKolD1Hgu5X2jfV9Sb+C++aBqBEaucA3W9JWBALI298pSSWpI3S17vVMwUADzUQ+s/rEQbf1W9OK/eAWLGXXd0/7ZQifhMI7ZJ4EDkh88bQPpXONr9Dr/Klb9zBZ3z3L1pbF6hvXHPKKb2X7pQmUyEurmpCcVGPTpA0QqBbPjhWYZR3QDTlnSc4zh5sUSqt1NI0/ugm4Lgo8zA9qMdx67CR3oDkoQn+uEmOPA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=ZygNqvmrqxLlOcz7KlrmxmajDRP0uJQIhejUlstLa6Q=; b=SaxaFMRsutsULt8cSrOMNAGYeWOdQwRRx5srwwakwGyb8JdWnhVTO67HtcXdILl4czBmGho4LHYzw9vc813KNIWm+0pPsqo5K02VI9ZAzt5DW1i0ncJj6jl48/dj0tgeWctAMD/uNg0GO5glQf3DZT8A+ymn3O2EbPyN9TqbGrSxtstdK/h/5M4KrCL3R8P7QVitPCjO7DdbJ2/FRMqvSyRrMENPmOHavdt3kI4TOKCUxhF+lm1Ug4JiwExAIDvbm12RDo/linMtbBBBKWJrlXHx8/km7lR0pcGjHGci98VsCendfm/vakN9AGIbsj5ZTsq90H8QgZSHUQ/Mgey2mA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=redhat.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ZygNqvmrqxLlOcz7KlrmxmajDRP0uJQIhejUlstLa6Q=; b=5ncOK61T3hkLdtVSip+a98tvF5mYwOV/+LGMQy6e9Y98EJXLvuhEOfA+xOdftJkVdKtskYFrpb9wSjL+QZaj8FnnsPd1T09czitHd8yv8caXvxP5N3tZWbv/rW+P0H9MVyRcOUjwN+A3D0By2JL+Le7TQoLjeiCyV+7G8HvVA1s= Received: from PH7PR10CA0012.namprd10.prod.outlook.com (2603:10b6:510:23d::26) by PH0PR12MB8097.namprd12.prod.outlook.com (2603:10b6:510:295::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8207.16; Sat, 30 Nov 2024 14:06:05 +0000 Received: from CY4PEPF0000EDD6.namprd03.prod.outlook.com (2603:10b6:510:23d:cafe::8d) by PH7PR10CA0012.outlook.office365.com (2603:10b6:510:23d::26) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8207.15 via Frontend Transport; Sat, 30 Nov 2024 14:06:05 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by CY4PEPF0000EDD6.mail.protection.outlook.com (10.167.241.202) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8230.7 via Frontend Transport; Sat, 30 Nov 2024 14:06:05 +0000 Received: from AUS-P9-MLIMONCI.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Sat, 30 Nov 2024 08:06:00 -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 v8 20/22] ACPI: platform_profile: Allow multiple handlers Date: Sat, 30 Nov 2024 08:04:52 -0600 Message-ID: <20241130140454.455-21-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241130140454.455-1-mario.limonciello@amd.com> References: <20241130140454.455-1-mario.limonciello@amd.com> Precedence: bulk X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000EDD6:EE_|PH0PR12MB8097:EE_ X-MS-Office365-Filtering-Correlation-Id: afc79dcc-a784-45c6-efeb-08dd114821a4 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|1800799024|36860700013|7416014|82310400026|376014; X-Microsoft-Antispam-Message-Info: wae5UrM21SFa6n2lCVqf4OZ5K0wfO6pnOVyHvjb7ttq35uI9ykTsW9JpAxpxbJL/kOXwTHzz1GCLpDqIfIpHblWNkVC8XbabcyqL0tX0leSad9SOz2lM/ISYEL/efaMRhCB+CYaHCLIAR0VH1We9FjKSx64DLthqb9eMtl/ZqV8fjpBLLX7oDSptX8kNynaG4rCerOfFjdkkb9y14BbTvax11zRI4bedWlQsRd3zfiBweVTZC/AfdiEb2yQ9AQxZ7dVdgrZnlJJUXy1QBsq6WcX+s0zBKMmhGEmkQCVYozlFQTORbN0rSrAD48LEMSnFSa9PPlYSUU899GXcKWmJFTdEwEb+6sRlM4dEBPUr6FTQ9qLJraPnW0/vV9HpABTsvaWNlMtTkvO9SMQgSTLDu5CuVNS8kr2MKPvjWfRDii1zlZe6n7I/Ub4nlclI5tbZujeBYY+hDHuAIyTnIiBtRPTwWhq6811VqJDalBTQPbqXwIvVzTll9ljvhzWxswFb7RNocIwzhvRHs47W1n/7pvyb7zWLrtGCSRosDB4jslXNm/PNACgYteqVVR7V/1oCgtXi3Hxamevjv8zpCSnVzubehbpUdxR38+VfIepQsFJGxKPP18H7G+10nMZAevFnfRxw/tJb4iLD1lxSLlEYkkDGRcEeAZx4z1M0WSRCqcSv7DryA0TlNTG0qq1V5RxKPBVlIfJqwTeGtZAeLlOpZ1CuUEnZgGfhuBathhIG3TAddruttMetcG9JaR/n+6LfEjnix8JGAaTydYROG7i2ZnPLqUpAM81oMdUn1Ogo+kvLE4BrgEdbIyuR7YZw9EJWD53x7GDKImYWyA7gWd5Btdl/Lf5GCh++KfYMifHSn4oQORaCekIpFDy1GufbqBVzrIkrzN+4sAZAXgq1OSpKmlKrFTo23NlUrvpN89zk3XojIJYya6ikNzwU8tERBpE0TyvM7umJUBtmwKowLcwJ46A9y1WIS9aRaLJMJBQgUwFWRGVo97aVocGsrGDEMfjiuF5Tm1naGxi974ikATt19cKdX6tjhCP6agU0piao+qCb2akMoTG2J51HOm14H0AeeyPxIukRWbRzz8mnFbOUn1xTEcG9503YwnUJGoCCsVl+drQh5Pv46DqV9ctPCLbf+iCDK/Sv67vbNTXDxuSesftE6bHymrNGTo2Sg22NIaQL0iRZXZLrDnwe1cOgRxamQmDm8xcvGwlw2mS6Q426XYvd/Xw2fWG7O3k3/Xm29Iw744kMvOvLkyBR0XRZdJ75r3JYMQgnb4fzKaJOkJTnYbS38RqF9+eXPgd0rL3uoXW7As71vtb0bS7fxS4t6bkspoixV2BnRD8BObfhhzcq/f5WK8orp5NHApDS9wetBhKmeesTexvENsgrvMGQVnw8Kr2vAglGa8QLE4L376mJjm5r4FwXcMHDIWmR//uxz7MgCIyDE0CWk3/KGQgM2fzg X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230040)(1800799024)(36860700013)(7416014)(82310400026)(376014); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Nov 2024 14:06:05.4534 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: afc79dcc-a784-45c6-efeb-08dd114821a4 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: CY4PEPF0000EDD6.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR12MB8097 Multiple drivers may attempt to register platform profile handlers, but only one may be registered and the behavior is non-deterministic for which one wins. It's mostly controlled by probing order. This can be problematic if one driver changes CPU settings and another driver notifies the EC for changing fan curves. Modify the ACPI platform profile handler to let multiple drivers register platform profile handlers and abstract this detail from userspace. To avoid undefined behaviors only offer profiles that are commonly advertised across multiple handlers. If any problems occur when changing profiles for any driver, then the drivers that were already changed remain changed and the legacy sysfs handler will report 'custom'. Tested-by: Mark Pearson Tested-by: Matthew Schwartz Reviewed-by: Mark Pearson Reviewed-by: Armin Wolf Signed-off-by: Mario Limonciello --- drivers/acpi/platform_profile.c | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profile.c index 289b5d43638ae..2e38aa410b3ad 100644 --- a/drivers/acpi/platform_profile.c +++ b/drivers/acpi/platform_profile.c @@ -10,7 +10,6 @@ #include #include -static struct platform_profile_handler *cur_profile; static DEFINE_MUTEX(profile_lock); static const char * const profile_names[] = { @@ -399,8 +398,6 @@ static const struct attribute_group platform_profile_group = { void platform_profile_notify(struct platform_profile_handler *pprof) { - if (!cur_profile) - return; scoped_cond_guard(mutex_intr, return, &profile_lock) { _notify_class_profile(pprof->class_dev, NULL); } @@ -463,9 +460,6 @@ int platform_profile_register(struct platform_profile_handler *pprof) } guard(mutex)(&profile_lock); - /* We can only have one active profile */ - if (cur_profile) - return -EEXIST; /* create class interface for individual handler */ pprof->minor = ida_alloc(&platform_profile_ida, GFP_KERNEL); @@ -481,8 +475,6 @@ int platform_profile_register(struct platform_profile_handler *pprof) sysfs_notify(acpi_kobj, NULL, "platform_profile"); - cur_profile = pprof; - err = sysfs_update_group(acpi_kobj, &platform_profile_group); if (err) goto cleanup_cur; @@ -490,7 +482,6 @@ int platform_profile_register(struct platform_profile_handler *pprof) return 0; cleanup_cur: - cur_profile = NULL; device_unregister(pprof->class_dev); cleanup_ida: @@ -505,8 +496,6 @@ int platform_profile_remove(struct platform_profile_handler *pprof) int id; guard(mutex)(&profile_lock); - cur_profile = NULL; - id = pprof->minor; device_unregister(pprof->class_dev); ida_free(&platform_profile_ida, id); From patchwork Sat Nov 30 14:04:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 846299 Received: from NAM04-BN8-obe.outbound.protection.outlook.com (mail-bn8nam04on2055.outbound.protection.outlook.com [40.107.100.55]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E680D1BAEF8; Sat, 30 Nov 2024 14:06:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.100.55 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732975572; cv=fail; b=qet8OpOufF78+V+2RwmZ6iYGYdta/Y5G3EwK3MM0K+ociyJaOhQ7E0sduzY8xZVyPZZYCSSBppRKLhSoE7H6AFg0K5ct2I/ajatR2qn+viqMtLCCS12MgWbl9bLWMoFMz877BD5W7uQzrspfiF7gOmvGSA82bnW7Bk3GQrF84tI= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732975572; c=relaxed/simple; bh=gnBSoFNrP8JY9HMIGKwmf6pitl5xXDFNXwZjpg8UPDk=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Bmrxcyh7cYWmzvlSGQ4d33c/yUCYQhD2qT8T6aBpKHDEEwQDonsmf/Vnx/eKit46lBJw3QB4UCCD4gB8GtUcel8l2zT6xNwVxYUnlfncnpPEecoyH1BardaVpQI+JjbJsEaF+C4/2QzBfit9SG2qLRZD0heLZXxj9ANOPNL1fvI= 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=0OX3PPQE; arc=fail smtp.client-ip=40.107.100.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="0OX3PPQE" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=JR3XFxbuKj9nNF2IKJoE/eLjA/t2adjxAI+lK1+zHIEr736ZvpzFbJEYHpnrLuIr3J2JqTmV2XCnN+2L/JBOHxPlYR+QMxwDFCZxQKRtiuCiFT4fwwKj6keMK/kQduuGcOneN6KEfKN3KCrhyq+/6gpLKyXtEeY1KamUVBT+jjlKENLu9aOU6t1N3bdTaX2DBHsGcq0/I5tzMAjbVKK7yB9c0iqGdIXk9oWqsO6c4Ez8RfyStO7ufADduVgnLs8eAHcLRzorwWEcLlbgmXvrsBEzZnaJtLqj8/EKUxI8G3yaMrMX2EeiS4JfWHQa8o2E2xqW548MpE75+3Lb7VYxog== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=uvGa/ULj0+7xI0tTFN6XDMWS1c3ltWrpsoEcLfQvXj8=; b=OH8cyUkrX+e57itP+Yvxr4fFr/3QoHvlR8BzyIIAay8tJ+rs6IpYEzKWmO/gl2oF4LrM4PNa5Bnuh0OkrvDuKj4dkXubkgoqEMCLV5m7yWllAlRNWzFc1abbvPnL0W5SLcuerG1EUHZTaY0qjFvrYc3OwiXPMMWu5gdN8/a6H5ngAlO23j5Qz6jiNDdLAc3Cw2AgzHlVfyfHETHxsKvkR4JeKyR54m74LM/8iBWB7H56B8WtV400OfJDJU1GFbRWQWVXR42SZLQeWu4K36b10bXQRR7e6gfJK6iD1Smwhj8dIV+b2p/Ce4NZy8kRkc2QK1UiyeyRvm3YK0B3T/3EfA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=redhat.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=uvGa/ULj0+7xI0tTFN6XDMWS1c3ltWrpsoEcLfQvXj8=; b=0OX3PPQEZjJcxqBLLnPxD++7Fc2aqJX6EiD8uWsClIfmYJiwuVtJ15ECizEAxWa5b7E+2jOw0gmJUmfoQ/0m5rrSf22xqKcydDzP3Xp5i8enZmHiyMvZbG5jTrT/nbyoA7jovnjFtw1R30/Z/UiwVpIE4pKFK3NCqD2E3LeziFg= Received: from PH7PR10CA0009.namprd10.prod.outlook.com (2603:10b6:510:23d::29) by LV8PR12MB9153.namprd12.prod.outlook.com (2603:10b6:408:185::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8207.15; Sat, 30 Nov 2024 14:06:06 +0000 Received: from CY4PEPF0000EDD6.namprd03.prod.outlook.com (2603:10b6:510:23d:cafe::85) by PH7PR10CA0009.outlook.office365.com (2603:10b6:510:23d::29) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8207.15 via Frontend Transport; Sat, 30 Nov 2024 14:06:06 +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 CY4PEPF0000EDD6.mail.protection.outlook.com (10.167.241.202) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8230.7 via Frontend Transport; Sat, 30 Nov 2024 14:06:06 +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; Sat, 30 Nov 2024 08:06:02 -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 v8 21/22] platform/x86/amd: pmf: Drop all quirks Date: Sat, 30 Nov 2024 08:04:53 -0600 Message-ID: <20241130140454.455-22-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241130140454.455-1-mario.limonciello@amd.com> References: <20241130140454.455-1-mario.limonciello@amd.com> Precedence: bulk X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000EDD6:EE_|LV8PR12MB9153:EE_ X-MS-Office365-Filtering-Correlation-Id: 61a348cb-bc23-4878-fd12-08dd11482233 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: 6mkup2rIGSXkMhPnr06D1UdbSg1bX7K1HOFMgcNnWN//8NziSiAyBRCrdDQvGqxpX+G0RL8WAus2vE8tVR/dQTt9MZ1rdvQnKRGEIYJGAOp2rGyHe9JUlbnnHLysDdGxcilOUeS2Wnanx2hvH6zSN3Ky/EOAgWSsMATqmMGiHoiQa55l8YxjOhbd8Yo6rpkUSyCXZAi1KDCgPXID9PtXdu4x+RWyXzBoK4Mpcr/GAoFuLyaITVNQrqrCc0pf9rHTZehsQM96OG4ONusVeGvhHP5RWW40oJLlF0u+IxmKIrp+JIoL4DRw0vzIdtzSS8RNsnmigor8vJNfvXBuvRgalNFh/xofl7p74o9urxotDl1kUE03cWHecs9Kz75qIWSfwHj6fw6QIf6YaH/4fVLxZUxyyuc+eD8IxObOaDJU7eM3izdjlPgy7O6qwdKQ88b9DXV12EaBs+wVQyumi3jMroLnc9lFNa+ZeWFjQ09ai9/P99yEY0jqo6BqJ94qBbiZ/TZQP251z2tD7Q5jpLZv6Ig+ikHfV6+F/OAsbl5DinDQLjPW/n7vuDflPw2w3hPhzXHzpksen0x6lpRisRYzeq8x34noJd6jUIBkrL8q8cot4jzJkyXFeNnwZG+3JdjmIwQ8+1MOqfG9qCKeOZ/oO6OWJJDAAJRrMYB8u0mVYac+QhYkKjUUXmfsnH37Gt0SIwfmaonE8v/CBnPOA5BrW+qHMScE3mbNr+xZxr2yYVnKIRJHyA4G2lUYuDLpyhPKlUtlFMlsXq1bCKqxnO8ej7+q5E99vZJ73Wk26f9z3Si+3BPTuiBDWlDKnKEamH7uq5pUXly7CSmFyPa/NJ1q/CxqR34kuCQQQJ5mpIgBtHpHsWSuI36mREMHipuu6MepQKB8o2fbhWWTfsD6rt1HMTUrP3I0ibYfQU3Uo0FTspr/f9km4b2aLud0WVWebrg21FN6AZqLMQTaNAfGDpNxsfUmOhEL+KcEvQziA4bKJOeG9SsqGwT18cr4yb/z2he2bW908YqQq8igLQCN43DWR7wSExLX5XDRzMbYaCxhMLXrDegP6YNhVDpxzbwNjV6Jr4W7df5tsRiJ/mUhWhJXYwd1axJia27p+RFMvc7Ds/lmzJC3cMj7QIV7GAQKlIbJdGbBAavpCUhsHP/hyGFj/4RUv+hz6Mt0whinxh8IAst07Ovf9qek+K1BCgjZKpIglZEU2ElisbnKOxtOJY2cFw6rLLPomUCFqL5WhKE7nZFomP7c16+XuS3rIaRBJQm9DpRrf2MaOqI4d09pMaKaqhxGYGvMvjoibxXaEtawHHInnVOoBhut+kbCgi+IRsXyy96wY/EIfaqQ3tRkOmBQxFpQJxL6N7Lej1a4gX3tTerN+mwm+UHFQPR8aEX5C7+buev05iUG8xHXBeZ9DjgEJoYFHYUxC3xwt8fTR/lvjWfOdHZaniLIa61u4R5nlN7Q 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: 30 Nov 2024 14:06:06.3909 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 61a348cb-bc23-4878-fd12-08dd11482233 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: CY4PEPF0000EDD6.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: LV8PR12MB9153 As multiple platform profile handlers can now be registered, the quirks to avoid registering amd-pmf as a handler are no longer necessary. Drop them. Reviewed-by: Armin Wolf Tested-by: Mark Pearson Tested-by: Matthew Schwartz Acked-by: Shyam Sundar S K Reviewed-by: Mark Pearson Signed-off-by: Mario Limonciello --- drivers/platform/x86/amd/pmf/Makefile | 2 +- drivers/platform/x86/amd/pmf/core.c | 1 - drivers/platform/x86/amd/pmf/pmf-quirks.c | 66 ----------------------- drivers/platform/x86/amd/pmf/pmf.h | 3 -- 4 files changed, 1 insertion(+), 71 deletions(-) delete mode 100644 drivers/platform/x86/amd/pmf/pmf-quirks.c diff --git a/drivers/platform/x86/amd/pmf/Makefile b/drivers/platform/x86/amd/pmf/Makefile index 7d6079b02589c..6b26e48ce8ad2 100644 --- a/drivers/platform/x86/amd/pmf/Makefile +++ b/drivers/platform/x86/amd/pmf/Makefile @@ -7,4 +7,4 @@ obj-$(CONFIG_AMD_PMF) += amd-pmf.o amd-pmf-objs := core.o acpi.o sps.o \ auto-mode.o cnqf.o \ - tee-if.o spc.o pmf-quirks.o + tee-if.o spc.o diff --git a/drivers/platform/x86/amd/pmf/core.c b/drivers/platform/x86/amd/pmf/core.c index 06a97c533cb85..01eb9ee1eccd9 100644 --- a/drivers/platform/x86/amd/pmf/core.c +++ b/drivers/platform/x86/amd/pmf/core.c @@ -456,7 +456,6 @@ static int amd_pmf_probe(struct platform_device *pdev) mutex_init(&dev->lock); mutex_init(&dev->update_mutex); - amd_pmf_quirks_init(dev); apmf_acpi_init(dev); platform_set_drvdata(pdev, dev); amd_pmf_dbgfs_register(dev); diff --git a/drivers/platform/x86/amd/pmf/pmf-quirks.c b/drivers/platform/x86/amd/pmf/pmf-quirks.c deleted file mode 100644 index 7cde5733b9cac..0000000000000 --- a/drivers/platform/x86/amd/pmf/pmf-quirks.c +++ /dev/null @@ -1,66 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0-or-later -/* - * AMD Platform Management Framework Driver Quirks - * - * Copyright (c) 2024, Advanced Micro Devices, Inc. - * All Rights Reserved. - * - * Author: Mario Limonciello - */ - -#include - -#include "pmf.h" - -struct quirk_entry { - u32 supported_func; -}; - -static struct quirk_entry quirk_no_sps_bug = { - .supported_func = 0x4003, -}; - -static const struct dmi_system_id fwbug_list[] = { - { - .ident = "ROG Zephyrus G14", - .matches = { - DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."), - DMI_MATCH(DMI_PRODUCT_NAME, "GA403U"), - }, - .driver_data = &quirk_no_sps_bug, - }, - { - .ident = "ROG Ally X", - .matches = { - DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."), - DMI_MATCH(DMI_PRODUCT_NAME, "RC72LA"), - }, - .driver_data = &quirk_no_sps_bug, - }, - { - .ident = "ASUS TUF Gaming A14", - .matches = { - DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."), - DMI_MATCH(DMI_PRODUCT_NAME, "FA401W"), - }, - .driver_data = &quirk_no_sps_bug, - }, - {} -}; - -void amd_pmf_quirks_init(struct amd_pmf_dev *dev) -{ - const struct dmi_system_id *dmi_id; - struct quirk_entry *quirks; - - dmi_id = dmi_first_match(fwbug_list); - if (!dmi_id) - return; - - quirks = dmi_id->driver_data; - if (quirks->supported_func) { - dev->supported_func = quirks->supported_func; - pr_info("Using supported funcs quirk to avoid %s platform firmware bug\n", - dmi_id->ident); - } -} diff --git a/drivers/platform/x86/amd/pmf/pmf.h b/drivers/platform/x86/amd/pmf/pmf.h index a79808fda1d89..64ab532550ac3 100644 --- a/drivers/platform/x86/amd/pmf/pmf.h +++ b/drivers/platform/x86/amd/pmf/pmf.h @@ -797,7 +797,4 @@ int amd_pmf_smartpc_apply_bios_output(struct amd_pmf_dev *dev, u32 val, u32 preq void amd_pmf_populate_ta_inputs(struct amd_pmf_dev *dev, struct ta_pmf_enact_table *in); void amd_pmf_dump_ta_inputs(struct amd_pmf_dev *dev, struct ta_pmf_enact_table *in); -/* Quirk infrastructure */ -void amd_pmf_quirks_init(struct amd_pmf_dev *dev); - #endif /* PMF_H */ From patchwork Sat Nov 30 14:04:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 846539 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2072.outbound.protection.outlook.com [40.107.94.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 E74BD1BBBCF; Sat, 30 Nov 2024 14:06:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.94.72 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732975573; cv=fail; b=F2/MHd/KKqLcJG+4vkWxNI+bVbFeA2jArtA96SfpU1laxzrFQj/1vRVyrAIH7tWHErYt0HHWiPPMc3vxM4xRzibAFlGI+iLNz0OnVk+I37s/PYK2jp2TfuEI9FasRp9fXiAhLJsbtrfmgqSSSXLxfmxScbSvqqJMEmNqZYs6Nj8= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732975573; c=relaxed/simple; bh=wf5rKNmIsnUUNoTwfFtQuOKmfayAw2AHgYGdmMq1vBQ=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=jKLaSOr93m75Ck6Bfj6q2rIkw+/O/EvoMdmrLM1M95aHw+PJKsBlJsMuFrXF6/mOWax1p104fjcxJXTEvU7dQ49z7JX+7JavEaijlcd6NekaLEvsYo3tYJzqUSvMqnT1ZqsZhozkWvMNOsN7P3yxfOAVmkMSpg1ryNv6qp/SQmw= 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=Q8jwxZxj; arc=fail smtp.client-ip=40.107.94.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="Q8jwxZxj" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=y6U2fghf4qdEsfzbP/JNoIMa2QtSwi6CEBj+GqoixjD0zqb6qW88H9H5lt5yvAbnux9f8pu/9vBEXNClL8dKDFSp4QBzxgDdOBeG4S0tpVUjB9XMhX9y1hh9QJgcv20CauRAi5M9e5vZNWSkARJ1neCHdYY57PQJaxzEieZGCcLhy/byazqEwCtqivXD34WEd9g7TCfqu6K7+fzMJygGPn67HIC+dI6QQ1DB46u5+BL8FEKBODtRwiNYGgHTk/lZ3hKC/OnMPB/3ikURMlB6HdwWVyNEpEwGMX56uRMZ/6t9ueCzWyd5ZNOam6GBIbU7wwIuVKJQ5LenCTC4W+IEzg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=Y7AsA2wn+UuDjCVQLXzWcZ19ajtJVFU0lsgjVGz13nQ=; b=fmHtdbvcAjE+OJE++mXLYNcswZBFch/i9j71LRVXW/aopEAe6snDilh3h0dCuMSmjG1xibQlSx/4iWTmM6KD5aUxpB4EXcpvHmOSYDwtbZKF5mQzq6YpXJ5SbI60eooDIG7VNUoHLjF/QYUO86PsZqY1EI0FF96e4Yc6VirKKIYjm9B9ujGiZZ9Yg7pY99HLIDQFQU4UpOg00MudGSndWKejlBK/wuf31UmXglv2iXneJ9NJ4Q45N+UaTuDl9VZpHrmKzC7oklZWPnPexEFxpoyyGmHQZ0fhY12e9uqr24hUSOzs9M63IkyVXer6QOMpZwqotyms2G5nJhbChy9n5w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=redhat.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Y7AsA2wn+UuDjCVQLXzWcZ19ajtJVFU0lsgjVGz13nQ=; b=Q8jwxZxj5HOKFD367gFZ4ns1k9JEaeU9qmHx/KumKGdOFwWblsVgA+6k/mOurjfclWjS9h2WLAbFUTiGu5D66zQyYDSfNr/8Va0KuQG0VxZ6s6OJQIzkBe/DNenFQz53lbMdfUysYBvi6m3y0R+IoosrSA1ceLV6dg2FDu3uwdI= Received: from PH7PR10CA0012.namprd10.prod.outlook.com (2603:10b6:510:23d::26) by DM4PR12MB6399.namprd12.prod.outlook.com (2603:10b6:8:b7::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8207.16; Sat, 30 Nov 2024 14:06:08 +0000 Received: from CY4PEPF0000EDD6.namprd03.prod.outlook.com (2603:10b6:510:23d:cafe::45) by PH7PR10CA0012.outlook.office365.com (2603:10b6:510:23d::26) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8207.15 via Frontend Transport; Sat, 30 Nov 2024 14:06: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 CY4PEPF0000EDD6.mail.protection.outlook.com (10.167.241.202) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8230.7 via Frontend Transport; Sat, 30 Nov 2024 14:06: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; Sat, 30 Nov 2024 08:06:03 -0600 From: Mario Limonciello To: Hans de Goede , =?utf-8?q?Ilpo_J=C3=A4rvinen?= CC: "Rafael J . Wysocki" , Len Brown , Maximilian Luz , Lee Chun-Yi , "Shyam Sundar S K" , Corentin Chary , "Luke D . Jones" , Ike Panhc , Henrique de Moraes Holschuh , "Alexis Belmonte" , =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= , Ai Chao , Gergo Koteles , open list , "open list:ACPI" , "open list:MICROSOFT SURFACE PLATFORM PROFILE DRIVER" , "open list:THINKPAD ACPI EXTRAS DRIVER" , Mark Pearson , Matthew Schwartz , Mario Limonciello , Armin Wolf Subject: [PATCH v8 22/22] Documentation: Add documentation about class interface for platform profiles Date: Sat, 30 Nov 2024 08:04:54 -0600 Message-ID: <20241130140454.455-23-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241130140454.455-1-mario.limonciello@amd.com> References: <20241130140454.455-1-mario.limonciello@amd.com> Precedence: bulk X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000EDD6:EE_|DM4PR12MB6399:EE_ X-MS-Office365-Filtering-Correlation-Id: cc87589b-16a8-4bd2-18d1-08dd11482333 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|82310400026|36860700013|7416014|1800799024|376014; X-Microsoft-Antispam-Message-Info: xvvKAGSU1R22XhjCVdMHWjxtChSO6Kdk4bL7WXGvOcwKXznRApCyxMERqomkejQxd+GcV27Lhhwz9hQd8i7h4puHSMgIVIQJB4+mxbnxLyzKoVhJz6yBDRKZWL8J8PaoG3A7TXefTKeLeQnmL+qtvp/Nq6UnB3se6bwYoq8M1BQCj7mbpzvAxZB5dn0M98UfYKnqaK03+3ZDAtN7b+V1qq1rirrJtNNWY8DdUls4csZXjbboBayBYQ7L/28isZTGxFmwcInQrXZfmHFYrk5JGITzx0ho14dnr8r3DyD4bQSvnFIU9RsrEDvClKhygrHEocfFeJ/xNW8YGXO1avW/+MyIijlia2OuPENHnv85D06JiYrXd4qOi85/g8GHG6aw7PdkQ1HQ260oif4s23y4cnsTicp+ug7tRcYyyDLKX/Z/5zOtR7M/5EtS7kfeFk8dhuEwXBSvH6Esru9ZwhjzRuQsR7ZCSFkt5ewR3qTCcbPQgIPKqUhECaIeLx9I0n9arT7coLxOywgoPoCfkqr1p5dh99FDbLX5GEzzMuBot4BEl4rpFdvcpWTZzZJx611VnRuKbxnvdD3Z6zYbSIwVM2j+J+FL4rDRkKFYrgST6gtPyeLiktHfhV17aMOvErdz08/wwH+rpByAvj26RCYbWGuq2/1yUIpPDs+HDnYHmnlkCvCDLwDdojE+gBOz6rz/AcqifFYudjL0oo0SEuXYTEEFjJ5EeQhjVDsQP/dnzvdNl2V+qVDtNwsAsFoWo0u6kGTa3VJQhBrmPtZtaMVIa33cEKS6FBlZBC80yemIV4A4qZf+75KzVqGNxNs/1Y55XZF+5jt41O8fOG6ZKvZxfVjJHwQ2KYnzotRoEgARmzXGDLjh5/jrHI1umi5B/ZZ4eRPri92CZl2oHYwfycEEZWxjqZJTRROrtT/ASkdgd220kzQgHq96vc37DBockHQzw1/on9ParbiXapm7818fuhPx5g/w9BXM2MoF9YHSpTP54qvFZdH9bb+tMSSqfChdqdvxPelL8Flwh9Kzr5hu5+sTvTDtHLMB84fPW+ZP9bPVBYPCrtjHzz6BO6lCf9vA/M2G4qkhNJVM/iMh9fT+64bZwZmTjxOII9BTnH+MhUR/VpYSjPTdJVdJKx/32iS1WyQtG4NTELGmq5dnFp/wULXGtXYA0YrWoPhpdj7mCyeB1YfrOVFV+2/3sk/98eZW/RxN9T+k5Ipzyp7cLQOns0czuxwkxCXnz9BLR+PqVgu8do9WxDWgz8SDXZkTe9BFSMwDl5a58KN19m3kMPwrDRTx5S8HVdTedtZHzOP6avrUy0utyG1WkwttbW/B8qStxlO7txknt9azy/ddveee4+P5HxsVa/+K7NkuxEjtIww/V7LnrtVUwyXCLnnmJu12px///hGozSXQeJo9d3D/sHuLQs8C6pT0zA0a6bbtZnv2RnvTQK5ndELJ9p/GGzYr 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)(7416014)(1800799024)(376014); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Nov 2024 14:06:08.0628 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: cc87589b-16a8-4bd2-18d1-08dd11482333 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: CY4PEPF0000EDD6.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB6399 The class interface allows changing multiple platform profiles on a system to different values. The semantics of it are similar to the legacy interface. Reviewed-by: Armin Wolf Tested-by: Mark Pearson Reviewed-by: Mark Pearson Signed-off-by: Mario Limonciello --- .../ABI/testing/sysfs-platform_profile | 5 +++ .../userspace-api/sysfs-platform_profile.rst | 31 +++++++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/Documentation/ABI/testing/sysfs-platform_profile b/Documentation/ABI/testing/sysfs-platform_profile index baf1d125f9f83..125324ab53a96 100644 --- a/Documentation/ABI/testing/sysfs-platform_profile +++ b/Documentation/ABI/testing/sysfs-platform_profile @@ -33,3 +33,8 @@ Description: Reading this file gives the current selected profile for this source such as e.g. a hotkey triggered profile change handled either directly by the embedded-controller or fully handled inside the kernel. + + This file may also emit the string 'custom' to indicate + that multiple platform profiles drivers are in use but + have different values. This string can not be written to + this interface and is solely for informational purposes. diff --git a/Documentation/userspace-api/sysfs-platform_profile.rst b/Documentation/userspace-api/sysfs-platform_profile.rst index 4fccde2e45639..0aa384c75095a 100644 --- a/Documentation/userspace-api/sysfs-platform_profile.rst +++ b/Documentation/userspace-api/sysfs-platform_profile.rst @@ -40,3 +40,34 @@ added. Drivers which wish to introduce new profile names must: 1. Explain why the existing profile names cannot be used. 2. Add the new profile name, along with a clear description of the expected behaviour, to the sysfs-platform_profile ABI documentation. + +Multiple driver support +======================= +When multiple drivers on a system advertise a platform profile handler, the +platform profile handler core will only advertise the profiles that are +common between all drivers to the ``/sys/firmware/acpi`` interfaces. + +This is to ensure there is no ambiguity on what the profile names mean when +all handlers don't support a profile. + +Individual drivers will register a 'platform_profile' class device that has +similar semantics as the ``/sys/firmware/acpi/platform_profile`` interface. + +To discover which driver is associated with a platform profile handler the +user can read the ``name`` attribute of the class device. + +To discover available profiles from the class interface the user can read the +``choices`` attribute. + +If a user wants to select a profile for a specific driver, they can do so +by writing to the ``profile`` attribute of the driver's class device. + +This will allow users to set different profiles for different drivers on the +same system. If the selected profile by individual drivers differs the +platform profile handler core will display the profile 'custom' to indicate +that the profiles are not the same. + +While the ``platform_profile`` attribute has the value ``custom``, writing a +common profile from ``platform_profile_choices`` to the platform_profile +attribute of the platform profile handler core will set the profile for all +drivers.