From patchwork Tue Nov 19 17:17:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 13880344 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2060.outbound.protection.outlook.com [40.107.92.60]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 190661CF295; Tue, 19 Nov 2024 17:21:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.92.60 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732036867; cv=fail; b=YTXoqfJe7Qmn9Hnijr4lXDuibKqKdmxw3wSfjZvJaT46S6IJbRmzVDxUZlUb354EBZ3K3Dt9eYJdc+qn57PiZyzuGsl967YT/Q3XfLLUvgYZhDiusHrCLKER7e2wxVqz/DhuPIHmKCnEDfS9ghuNbs4YO/7ADBNXne30kRouHIQ= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732036867; c=relaxed/simple; bh=4acWOBTgKXkQXKJ2F6QknLiWxVdZF5ne9UoVI1gHNM4=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Qg5PFMIJ8x5oqLoqilsTKnKKq/DLTZeYUYyN2H7Vm7TBQDqeqrlnf3+7H20vc3q/4AscP8nQQg3ewvUfHxYUJsKlS76/Cny4Md3ZhvJmBDD5f1y2ZQvwd39XIAlrwigBtkY2Dnq9CmdZb66ZL5IX3v7A5nrur3h6LSCtMEds6T8= 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=Pej4slrF; arc=fail smtp.client-ip=40.107.92.60 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="Pej4slrF" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Mww5h4w90RZwvp9TiMEuLq9dg7pQ5B/iXG4C+mtp80/KZ2/sPC4XXDce09g63fWLJ6j/y9266jIsgUaDMkALjwlfjzLbDJ9dR41tVl92gp8t5r5m0fV6fMo8dgBXdlltpDEJZgSsIkmakTsnK+FCexszKQkIZsTNA2vk2+qOcEAS2MtbgisjgTkBafh5vIBIXReshJJEjTqtLgsf4y4EHF0BL8adBJCizCYbcfhQ1JVKrYVrtTYSGdmIOEfaHBADQCZRQu4moaH42K08oQgX7YeQn+ZL2By8NmB8tlDKNEJjwGI7wxu896erX5XeErUSL2HDxYzjQo5BaNoaGHPNbA== 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=Su0YGzELm9tFqAipf3MGeeTvz0dxYZurd0guxOY8Ulo=; b=nI2zXOCoZSVrGWT95k14GuEnjJt9VaOK2MdAKOrvteoekdeOSbcnssy8wD/1brsF3+TqHazbBL8o1L9J1hzv2zpIfIpSvpVOs1FyxuXCnIdDwYrXqcq1tRtF/lNGTV7ONCtIFZgP6ElVH7HGXpMDl/CkVdwy/ejAH8gSiUVPacg/bg6aIqiQy9m6fQdi3J1fWZIzDrkFMKf/HbWZVT5qFJjygd0SWiTTEZfB6b6dPe3XbvdjUzJ1Tze51xtNWFooqIO7z2l5qJ25VWMdVrIftdtG0fyXl9LjVopNRfGj8iNuf01/HCddtPZFGWu9ODIzTJTzVHTATt41a0MMJg2rxw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.12) 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=Su0YGzELm9tFqAipf3MGeeTvz0dxYZurd0guxOY8Ulo=; b=Pej4slrF05r2B3F3ePkzy7uhyBsS5dPTlmJSijtSUlczlfcjTvd4xS0lL7vBIo+5XJkOThTZzOuygsRfiZK06pBuo2wOIm1jAJmJrPRFnt70CSqNISyF3uoInG9SXC5MEDIDq7okUJ4/FIQOiuuEp4Jp1itmNw5TcOolYAXVdCo= Received: from CY5PR15CA0257.namprd15.prod.outlook.com (2603:10b6:930:66::21) by MW4PR12MB6874.namprd12.prod.outlook.com (2603:10b6:303:20b::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.21; Tue, 19 Nov 2024 17:21:00 +0000 Received: from CY4PEPF0000EDD1.namprd03.prod.outlook.com (2603:10b6:930:66:cafe::9c) by CY5PR15CA0257.outlook.office365.com (2603:10b6:930:66::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.24 via Frontend Transport; Tue, 19 Nov 2024 17:21:00 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.12) 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.12 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.12; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.12) by CY4PEPF0000EDD1.mail.protection.outlook.com (10.167.241.197) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8158.14 via Frontend Transport; Tue, 19 Nov 2024 17:21:00 +0000 Received: from AUS-P9-MLIMONCI.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Tue, 19 Nov 2024 11:20: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 v7 01/22] ACPI: platform-profile: Add a name member to handlers Date: Tue, 19 Nov 2024 11:17:18 -0600 Message-ID: <20241119171739.77028-2-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241119171739.77028-1-mario.limonciello@amd.com> References: <20241119171739.77028-1-mario.limonciello@amd.com> Precedence: bulk X-Mailing-List: platform-driver-x86@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: CY4PEPF0000EDD1:EE_|MW4PR12MB6874:EE_ X-MS-Office365-Filtering-Correlation-Id: 358bc359-8a5d-451e-d154-08dd08be89a9 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|7416014|376014|82310400026|36860700013; X-Microsoft-Antispam-Message-Info: =?utf-8?q?JRi439lNdt310KzFYcn6TjJD59YruoZ?= =?utf-8?q?QvGXZSgqy/Rl5Umv1uV64Qsu97cdZpEAggt4GLHoB23RLGnHpGqy2I497e36u9I/h?= =?utf-8?q?ekvH6042UGl14DQBJcP8VAdKWLUGY+bNM67sBEfcQrnGDFHiJw2RpQ++6WsjXNRnU?= =?utf-8?q?IvA7INoKeKb8x54w4VcZM5/yNam97vq62Dsrr9E51MI4GnXB3iGaulX+WnESEAvwU?= =?utf-8?q?JGFpOUFHRjjjk+4Pb/P7rGYjH/tEYNZZf/g3FNrhNCcRI4a0XSBVtRmHfv0SbFm7E?= =?utf-8?q?w9vtyCPDXeO5zpJvyFo/w+2OpU4YDniVgBQ4+8nKI5f3V+nFunmF+4jDFNxqEDKpY?= =?utf-8?q?ybTx2DeswwNvce79+4AXLH3Fvv7Yxzx3Ro1DJWlZklun1Yt2VJpOrwHpY1kHzq0ux?= =?utf-8?q?Pop4S1hdNl+54ZVC1nJxkOoORsFtuNHD+YnJdBZHYnArYHKLrUD6GE7IpwtafQhbi?= =?utf-8?q?DoEZFlg0saMDTIZ0Lvx+eQUvJdFPkrPewO5zajYbIFnF6uoAv3dOnfiki19o9bbyg?= =?utf-8?q?2aSbXLqgl0HpUlXc5hczuHG2oyGQUT98i5IPTmiP8vnLQSfBJs9r0BPrgrwet2Lan?= =?utf-8?q?6QyyKn82uxM6f0Pycb8zaH/xUM+OvrY4B39p8hdit68J2Xjkk2rs+yutlRHIFHuAc?= =?utf-8?q?vCWbIQJE1C/AfAdnpEvYuIpZdjv29u/hNsLt+yfDFrL+6abhnLNNjBhAqjv8lvA92?= =?utf-8?q?U7WDc8rD9LJZ9KVIxjmffaTU9TsqFzK3sn2DOMGi35R0d4DdCG3S8MauqQ55dBDm/?= =?utf-8?q?G3c9vD87WYeUH8I2LDn/jVa7Lx7G88dDCuTD/K19zXFaExvVYGnjAMM+b7VECWtnA?= =?utf-8?q?JsXK1bQ0zmMmI2V7zndORTx7kTUcan0gm4QDYmxIn9ZciwOKeixSW/y01rOvc1Bjd?= =?utf-8?q?9dL0kOuy3zcJ0qin4xMkpl7hoBqMyFZ4hx5UyXTk1apGMS8S8pOjOqQJi58FUVEUi?= =?utf-8?q?Sko7f5qUlns3xgo2oLvM/81Ao6H7VB3H+TdFLcAndNXP1ekQAfPhWAUzSJmreUiA4?= =?utf-8?q?tiwyCtZzoKOmR2G8DsMYc265fRqgr2K+GD7n/fT93VXhLpv3lVk58fi2+tRmz2JmB?= =?utf-8?q?NvbG4AZO1sLe4MvCke65/WOtn12rKWJLPX3DtBBneuhtIzIn4PnKWKXx9tDtfsX3D?= =?utf-8?q?fZNvpXcBDXJNhMjiSPUgYAwVgR5BIpE4RcrPJ3/u/fLcJFQLdyn0nJlXvjpeORn9n?= =?utf-8?q?phhPI4B+klVdKt0lW3MRJpKuxD1CvFYB5Z9oLU/+oddmFqmGfubTJsCtpHP4fZsvy?= =?utf-8?q?7DQ3ut6d8HmSUml1AqwPipZrgDTVogdQ6mOFth52zhsWpHwxqpDh1Fpu+p5DBqfQR?= =?utf-8?q?D8XIqd4JmrRy7ycpYA75G/Z+S8tk+am5LA=3D=3D?= X-Forefront-Antispam-Report: CIP:165.204.84.12;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:atlvpn-bp.amd.com;CAT:NONE;SFS:(13230040)(1800799024)(7416014)(376014)(82310400026)(36860700013);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Nov 2024 17:21:00.1175 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 358bc359-8a5d-451e-d154-08dd08be89a9 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.12];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CY4PEPF0000EDD1.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW4PR12MB6874 In order to prepare for allowing multiple handlers, introduce a name field that can be used to distinguish between different handlers. Tested-by: Mark Pearson Tested-by: Matthew Schwartz Reviewed-by: Hans de Goede Reviewed-by: Mark Pearson Reviewed-by: Maximilian Luz Reviewed-by: Ilpo Järvinen Reviewed-by: Armin Wolf Signed-off-by: Mario Limonciello --- v5: * pick up tag --- drivers/platform/surface/surface_platform_profile.c | 1 + drivers/platform/x86/acer-wmi.c | 1 + drivers/platform/x86/amd/pmf/sps.c | 1 + drivers/platform/x86/asus-wmi.c | 1 + drivers/platform/x86/dell/alienware-wmi.c | 1 + drivers/platform/x86/dell/dell-pc.c | 1 + drivers/platform/x86/hp/hp-wmi.c | 1 + drivers/platform/x86/ideapad-laptop.c | 1 + drivers/platform/x86/inspur_platform_profile.c | 1 + drivers/platform/x86/thinkpad_acpi.c | 1 + include/linux/platform_profile.h | 1 + 11 files changed, 11 insertions(+) diff --git a/drivers/platform/surface/surface_platform_profile.c b/drivers/platform/surface/surface_platform_profile.c index 3de864bc66108..61aa488a80eb5 100644 --- a/drivers/platform/surface/surface_platform_profile.c +++ b/drivers/platform/surface/surface_platform_profile.c @@ -211,6 +211,7 @@ static int surface_platform_profile_probe(struct ssam_device *sdev) tpd->sdev = sdev; + tpd->handler.name = "Surface Platform Profile"; tpd->handler.profile_get = ssam_platform_profile_get; tpd->handler.profile_set = ssam_platform_profile_set; diff --git a/drivers/platform/x86/acer-wmi.c b/drivers/platform/x86/acer-wmi.c index d09baa3d3d902..53fbc9b4d3df7 100644 --- a/drivers/platform/x86/acer-wmi.c +++ b/drivers/platform/x86/acer-wmi.c @@ -1878,6 +1878,7 @@ static int acer_platform_profile_setup(void) if (quirks->predator_v4) { int err; + platform_profile_handler.name = "acer-wmi"; platform_profile_handler.profile_get = acer_predator_v4_platform_profile_get; platform_profile_handler.profile_set = diff --git a/drivers/platform/x86/amd/pmf/sps.c b/drivers/platform/x86/amd/pmf/sps.c index 92f7fb22277dc..e2d0cc92c4396 100644 --- a/drivers/platform/x86/amd/pmf/sps.c +++ b/drivers/platform/x86/amd/pmf/sps.c @@ -405,6 +405,7 @@ int amd_pmf_init_sps(struct amd_pmf_dev *dev) amd_pmf_set_sps_power_limits(dev); } + dev->pprof.name = "amd-pmf"; dev->pprof.profile_get = amd_pmf_profile_get; dev->pprof.profile_set = amd_pmf_profile_set; diff --git a/drivers/platform/x86/asus-wmi.c b/drivers/platform/x86/asus-wmi.c index f15c7ce37b256..c0ed9ffc3913b 100644 --- a/drivers/platform/x86/asus-wmi.c +++ b/drivers/platform/x86/asus-wmi.c @@ -3866,6 +3866,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 9d8c3f064050e..1f94c14c3b832 100644 --- a/drivers/platform/x86/ideapad-laptop.c +++ b/drivers/platform/x86/ideapad-laptop.c @@ -1102,6 +1102,7 @@ static int ideapad_dytc_profile_init(struct ideapad_private *priv) mutex_init(&priv->dytc->mutex); + priv->dytc->pprof.name = "ideapad-laptop"; priv->dytc->priv = priv; priv->dytc->pprof.profile_get = dytc_profile_get; priv->dytc->pprof.profile_set = dytc_profile_set; diff --git a/drivers/platform/x86/inspur_platform_profile.c b/drivers/platform/x86/inspur_platform_profile.c index 8440defa67886..03da2c8cf6789 100644 --- a/drivers/platform/x86/inspur_platform_profile.c +++ b/drivers/platform/x86/inspur_platform_profile.c @@ -177,6 +177,7 @@ static int inspur_wmi_probe(struct wmi_device *wdev, const void *context) priv->wdev = wdev; dev_set_drvdata(&wdev->dev, priv); + priv->handler.name = "inspur-wmi"; priv->handler.profile_get = inspur_platform_profile_get; priv->handler.profile_set = inspur_platform_profile_set; diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c index 4c1b0553f8720..c8c316b8507a5 100644 --- a/drivers/platform/x86/thinkpad_acpi.c +++ b/drivers/platform/x86/thinkpad_acpi.c @@ -10549,6 +10549,7 @@ static void dytc_profile_refresh(void) } static struct platform_profile_handler dytc_profile = { + .name = "thinkpad-acpi", .profile_get = dytc_profile_get, .profile_set = dytc_profile_set, }; diff --git a/include/linux/platform_profile.h b/include/linux/platform_profile.h index f5492ed413f36..6fa988e417428 100644 --- a/include/linux/platform_profile.h +++ b/include/linux/platform_profile.h @@ -27,6 +27,7 @@ enum platform_profile_option { }; struct platform_profile_handler { + const char *name; unsigned long choices[BITS_TO_LONGS(PLATFORM_PROFILE_LAST)]; int (*profile_get)(struct platform_profile_handler *pprof, enum platform_profile_option *profile); From patchwork Tue Nov 19 17:17:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 13880345 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2044.outbound.protection.outlook.com [40.107.243.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 CEA7C1D1E79; Tue, 19 Nov 2024 17:21:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.243.44 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732036870; cv=fail; b=RCF4FGeFQxwgj+wUM0j0vPLxbZpDoH+2qhllsl3fhEILY8O4v58PwJ8wTyHBqUOUriiS0AuC4/1kzC4ppor/+mdClBsMFGcsZ1wrAgWwDNHnRK2VFmXUSrtfQdbOzJFq2fMvk1KcbxyyHDKe+u+Q8RQ4oKdfyRz0A1UkvNLGWAc= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732036870; c=relaxed/simple; bh=gVOFZQ1NkY8btPf86/D8ZFqsha0+GCMWANbhEBwFGl4=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=fL3RYe3DJUVxoC2fSDUtyWru39jqZgVc+RS4XGXY8bsrQrArPTLNigCEnNqcbcHhiFdMeZ6WRvHUyFmfm3pI5zbJt6GkjRucy3vCm7JXFYUxN96NLIC8w/N4h/tC5l7V8lS7jzM3vrWbFTc3WeodsZ7DRV+qSoOsZZxL+ObIDXo= 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=E59xm3d6; arc=fail smtp.client-ip=40.107.243.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="E59xm3d6" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=fRaE5fEaI5G8Uf4IOPcJP33HFq6+6Mtt1RkK5UWLfiOA3nNO80SAYKjEdwBqu71IQjF9tqc1gjE9TekpcE1Jb12Ybz6Gbq3W9bVM4AeqBg18hty3XAPhK9ElGqNjyMWgNg70i92CXmqLK+TjHBfCBkcXRusnbacWFIZ0fNVg8qGNQcu+OUowfNSkBAInwH1uiQ294LmuKy9FJp4pSCluNJbfVIKi+mZ1L366u7dX+r0vXG18o5nCsncBD77qW7BBZ8uTE54sXwkkFs4wVMNo9v8dmDXi9OJjEDgvtM7iM6N13lwCJ2IeAOP7ev8DBQjIBLUOJ+0je5u96e+mtsRcHw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=Rcake+aW7InzlrriCA9veWw0Iv9E+pdMZvM9w0hzudg=; b=kkqipRyXGiCgLdcAQTvutvs2K5Wb52weCnsGqsOektUs6B7d4DWyhfohQHTZUppz0uQnppd890gJzdJP6eWTmq1/3UU264BeLZROhO8wI5OjIgsFxyXps8VZLA4zcyvnGOClKjLYIwCAreLcuuvz0E8TnIHJAu4EB/QOPZGTeWIhcBdTOq3N5xLPqu9QOF/iKie98Q7ACgdHZRDNj00O/+OmjwXPPEsPGi2+B556hINgZQPWUZw5F+btomsuOvFc99qukIsgGbmjEvki+bvt/KXfT1kI2tK84aGRfo+qnycPcDgB/TpRCAVgJQl492bPkfcA9vmB026607een5oIcA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.12) smtp.rcpttodomain=redhat.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Rcake+aW7InzlrriCA9veWw0Iv9E+pdMZvM9w0hzudg=; b=E59xm3d6xDoyojZQCFMUfz8/heJvf1H26odjeB4IwT6zq4LQy5uzQuVNGm7ul9AA+ujDjDdUW5LvbkRBoj9j6sv1749yV+nhRKC2i8h9ZqlyRHy5UasIuKt4cTlO7cKTt8d4RrbeakUHN8iOnnCK12YqNGkmS7XzdD/j6GIS/Kg= Received: from SJ2PR07CA0008.namprd07.prod.outlook.com (2603:10b6:a03:505::8) by DS7PR12MB6239.namprd12.prod.outlook.com (2603:10b6:8:95::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.22; Tue, 19 Nov 2024 17:21:02 +0000 Received: from CY4PEPF0000EDD4.namprd03.prod.outlook.com (2603:10b6:a03:505:cafe::69) by SJ2PR07CA0008.outlook.office365.com (2603:10b6:a03:505::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.25 via Frontend Transport; Tue, 19 Nov 2024 17:21:02 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.12) 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.12 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.12; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.12) 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.8158.14 via Frontend Transport; Tue, 19 Nov 2024 17:21:02 +0000 Received: from AUS-P9-MLIMONCI.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Tue, 19 Nov 2024 11:20:59 -0600 From: Mario Limonciello To: Hans de Goede , =?utf-8?q?Ilpo_J=C3=A4rvinen?= CC: "Rafael J . Wysocki" , Len Brown , Maximilian Luz , Lee Chun-Yi , "Shyam Sundar S K" , Corentin Chary , "Luke D . Jones" , Ike Panhc , Henrique de Moraes Holschuh , "Alexis Belmonte" , =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= , Ai Chao , Gergo Koteles , open list , "open list:ACPI" , "open list:MICROSOFT SURFACE PLATFORM PROFILE DRIVER" , "open list:THINKPAD ACPI EXTRAS DRIVER" , Mark Pearson , Matthew Schwartz , Mario Limonciello , Armin Wolf Subject: [PATCH v7 02/22] platform/x86/dell: dell-pc: Create platform device Date: Tue, 19 Nov 2024 11:17:19 -0600 Message-ID: <20241119171739.77028-3-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241119171739.77028-1-mario.limonciello@amd.com> References: <20241119171739.77028-1-mario.limonciello@amd.com> Precedence: bulk X-Mailing-List: platform-driver-x86@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_|DS7PR12MB6239:EE_ X-MS-Office365-Filtering-Correlation-Id: fafd6b68-d250-4506-3513-08dd08be8af9 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|82310400026|376014|7416014|36860700013|1800799024; X-Microsoft-Antispam-Message-Info: =?utf-8?q?bhPbb0eSubmlGNMyn4v+7ZQP0zyXJ3Y?= =?utf-8?q?mUNJ6EMTZHVx7WTEFZ27tBSA4w2e4EWYXGpZE4yJjExq9/NwV5AoPk7LRgjmddfM6?= =?utf-8?q?IBqvk6uJznc8MUPySg6MhDXaWbKUCh0ptJ3x0wDJvkUgvKkwWLn8didZp9n10mQDt?= =?utf-8?q?6QK2VbDaq74NCIf+gzXMOTWJ5MlyPRjQbVdo6fdZsNvneLR455ebEgXmwNYiogCFy?= =?utf-8?q?ZwrPAwZEycJ2Z6PUXcIkYhOiT0XssRp2cZTzT39ipS9XVE8y0bhdzVhlPODJzwpxb?= =?utf-8?q?bX3+UYpvztmXegcWhLtYODiDxhw/Jj+xdIgfwXUfbLf2k87RgDpYp7XTQKqBGB8Ty?= =?utf-8?q?zled3aBqqPRy9s0xU9EnvQ069v0p9r6R1NYoa4Un/tCN04AwMv54TQrHbFbCrdotq?= =?utf-8?q?BcCVaFF670FwaYvsk8aLzZUu9xy3qA8jXUmpvpIpB9Erev0I0MvTD+SpcVS1iktf3?= =?utf-8?q?vKagmuly8tcFJyahMUk4KohXRR7v5Em+HOTk1+a7R9RbruTyaV72Dzd/82lgYL1me?= =?utf-8?q?g2XMfclXIQ6PPXiGQ0ipQ7KZFt0SlYuqE1xVw0Zdc97OCC//+DRHpm0x8VIC7L6Zw?= =?utf-8?q?mBgpDJtoXyiP6AvP/D7VuLM47+cpoQ7eld5vra+ZAGKt1bwEtXeyzaeEW8dHr/pjq?= =?utf-8?q?6owyzh95e8PJu6teov9fLz0RVX3a23vb2jWMzM18g2b6k72DRCbYVh8l1r6+ZDOkg?= =?utf-8?q?f2EEdTCO6IY0xlHZl2ne+g7w1zhXipsC44sH4VgagbOEJRjzBOJqpsnUSWVnuMy5O?= =?utf-8?q?nEP0m0aqiDvoQv/olYGE18k9Hn9cna+c9bWdWl4AuuF1rT+BQRoh8gYAQBJZTuFfs?= =?utf-8?q?xuOW3Og1r/ZydI92/9L7+G0PwQ/xGiOYGq6v4o1EoU4EwBXpC4aGsOZ5APApDu3d5?= =?utf-8?q?Z8YW35Zi5Egk6BJh0P/EzbVFmzUOTqZtzwf8S6bqXu6YTx+fvHeaISiI0PWuEoqXX?= =?utf-8?q?fSiLMfJZIayOPNhSW9IG2RZAZv66NCOa3TU/c9kglrL+cEL6V6gGVVANx9TIyHlwt?= =?utf-8?q?ueEUVIL23crNulMLnhF5l5BOnYqvB7KDIeqNV9Dy2SkuOeSVat6PQbF3a/YuUxf74?= =?utf-8?q?C9iQv8tY8CTigtLx9rkyRxUpzWV8JtxA6eUYeHJN3Y9Mu/5vQasrDEA5adoPDisPA?= =?utf-8?q?IYtD1xLC8GVtFi0I6rrl3M3uoaGxCXYIyK8nGKiOJSV1zNQIMzxE6zCK4qFWZ3edq?= =?utf-8?q?0ly456tSDH9QIkmtK8omUVTQFD56tPaQETfu9AbZ7SPg8Jo1i3tGp6Okl1GK0J4xP?= =?utf-8?q?rLvFwfXTIAX7X8QIZS0skIVvt1KTjoy/BvIciMWNMpLiZPCFymGdR06qBwzJiy3WT?= =?utf-8?q?6o0xCVTMvHqyszBWWzLVCvAhmYyuFY3v/w=3D=3D?= X-Forefront-Antispam-Report: CIP:165.204.84.12;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:atlvpn-bp.amd.com;CAT:NONE;SFS:(13230040)(82310400026)(376014)(7416014)(36860700013)(1800799024);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Nov 2024 17:21:02.3156 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: fafd6b68-d250-4506-3513-08dd08be8af9 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.12];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: DS7PR12MB6239 In order to have a device for the platform profile core to reference create a platform device for dell-pc. While doing this change the memory allocation for the thermal handler to be device managed to follow the lifecycle of that device. Reviewed-by: Armin Wolf Tested-by: Mark Pearson Reviewed-by: Ilpo Järvinen Signed-off-by: Mario Limonciello --- v6: * Use PLATFORM_DEVID_NONE (Armin) v5: * use platform_device_register_simple() --- drivers/platform/x86/dell/dell-pc.c | 32 +++++++++++++++++++++-------- 1 file changed, 23 insertions(+), 9 deletions(-) diff --git a/drivers/platform/x86/dell/dell-pc.c b/drivers/platform/x86/dell/dell-pc.c index 3cf79e55e3129..805497e44b3a5 100644 --- a/drivers/platform/x86/dell/dell-pc.c +++ b/drivers/platform/x86/dell/dell-pc.c @@ -18,10 +18,13 @@ #include #include #include +#include #include #include "dell-smbios.h" +static struct platform_device *platform_device; + static const struct dmi_system_id dell_device_table[] __initconst = { { .ident = "Dell Inc.", @@ -244,9 +247,15 @@ static int thermal_init(void) if (!supported_modes) return 0; - thermal_handler = kzalloc(sizeof(*thermal_handler), GFP_KERNEL); - if (!thermal_handler) + platform_device = platform_device_register_simple("dell-pc", PLATFORM_DEVID_NONE, NULL, 0); + if (!platform_device) return -ENOMEM; + + thermal_handler = devm_kzalloc(&platform_device->dev, sizeof(*thermal_handler), GFP_KERNEL); + if (!thermal_handler) { + ret = -ENOMEM; + goto cleanup_platform_device; + } thermal_handler->name = "dell-pc"; thermal_handler->profile_get = thermal_platform_profile_get; thermal_handler->profile_set = thermal_platform_profile_set; @@ -262,20 +271,25 @@ static int thermal_init(void) /* Clean up if failed */ ret = platform_profile_register(thermal_handler); - if (ret) { - kfree(thermal_handler); - thermal_handler = NULL; - } + if (ret) + goto cleanup_thermal_handler; + + return 0; + +cleanup_thermal_handler: + thermal_handler = NULL; + +cleanup_platform_device: + platform_device_unregister(platform_device); return ret; } static void thermal_cleanup(void) { - if (thermal_handler) { + if (thermal_handler) platform_profile_remove(); - kfree(thermal_handler); - } + platform_device_unregister(platform_device); } static int __init dell_init(void) From patchwork Tue Nov 19 17:17:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 13880346 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2088.outbound.protection.outlook.com [40.107.223.88]) (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 817571D26F9; Tue, 19 Nov 2024 17:21:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.223.88 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732036873; cv=fail; b=EpnLgkhfCSAZtCBCrf4n2zDBqgF0ri5hX10ildfXW3q5kmmeadiqXJp/EPcLCTGyEsIn2eqk0h3whCEDYRIZXVR/I8Li8zXfw+oa5SOljGZCqUTD9Ab6jNvI7pps2YV/vXDiHKFcit7UGlkyMvIz7h/WDoYngREtfjVh2b/1sQU= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732036873; c=relaxed/simple; bh=tJ4DVdV7cYXpMcLZGQ2X1sYu4uUhOwjck0xtfjKy1Tw=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=H72K2V7Z21gha7nv1i97xumt2hPHIj6x72Q4Ei2F12x/yYE+vjzWvhSjh3PH4GDNXS6ASHOMeOxgANMmYjO2kw2nrGXOTmvlc4jvfOqXI4oeSEEWZtv5DFbAZwFMKqERO6EYshpF0tvnZAyYufDJ5NQUnBE3ftg7H6jv7JqRlW4= 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=VojsyqSA; arc=fail smtp.client-ip=40.107.223.88 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="VojsyqSA" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=eDlmVAt0lzqGj4HtHEo0+BlJGPvh5Bm/Ga0gqkwolZw0+hH7LWhcJ3n+QwFvpGlkR/DHk0pYbqzBvzF2RgGtbAaf7wAv3Lg6GLJMA1W0RZRtRXYZQVoaMsg1aI9eLLZGHtifEeniHFL2ZC1kgWwT/5f3Y9m/aPpOOoFakRW2YNtFlNSNvch4+T2VMWjZqP1M/+zeT4hiGUwGIWLEx319WkIo3n8HStnPgpWykUI16kmny2PGmOCk65Qe85/OuClECt7jEu/9vYmF+iw9m0c64X9RBg5mIhFNCNcmkesh1ov6OtKwHragUCU3TB4wKPwXOjOUwphkbUJi+1Gd3L7VYQ== 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=DxHNLh8X+PGIiA3w7kI8/pf3Usx2TD2JwkiwHrhZM6g=; b=kmgRT8O0vgVQ3zYYpVYjdRYrP2rYJVts49C1a2y17aun702W6G9ffDLTERR08p00YxLgHhxGmZcDCuHnbAyDf/Unu/uEwQ8MwSiiX+yvy0ipMfglhQWVQenEFdnmHR0E091H2P5byZ50mGMECUYhBC0aCWPwP2oWDtN2N7EQx3iv+IQfg+y3otzdIpas3I5RGVYvF56QLt3TJdYWxq052fIWvV9badTvsc2xSgW9jZsf9hNnnT3ZKD7zIg8xOub2TClWTntywEALbpnFdNA9c5lFuXB11MvYwNyp82EWFfW416hdVxxybO8aQqjruBtQrS50xhZrxbMLWKjVebE0Hw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.12) 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=DxHNLh8X+PGIiA3w7kI8/pf3Usx2TD2JwkiwHrhZM6g=; b=VojsyqSAqUj+KnzjrHxxwsWnKoHCzVVJOxaHi99SIoOFMS8TObLNUxZ7rFyt9Bh5fSw0Eo38vgZ1aXPrLhHw/FbjvMhgFSXC7XfIlrfbryXf5wEu28zTEuEFjZ2bNeuMNWrCQPX3/C25kO/8CvG18eSwDLyM8Ydn2tsSMQnr7D4= Received: from SJ2PR07CA0023.namprd07.prod.outlook.com (2603:10b6:a03:505::9) by MN0PR12MB6128.namprd12.prod.outlook.com (2603:10b6:208:3c4::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.23; Tue, 19 Nov 2024 17:21:05 +0000 Received: from CY4PEPF0000EDD4.namprd03.prod.outlook.com (2603:10b6:a03:505:cafe::64) by SJ2PR07CA0023.outlook.office365.com (2603:10b6:a03:505::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.24 via Frontend Transport; Tue, 19 Nov 2024 17:21:04 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.12) 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.12 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.12; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.12) 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.8158.14 via Frontend Transport; Tue, 19 Nov 2024 17:21:04 +0000 Received: from AUS-P9-MLIMONCI.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Tue, 19 Nov 2024 11:21:01 -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 v7 03/22] ACPI: platform_profile: Add device pointer into platform profile handler Date: Tue, 19 Nov 2024 11:17:20 -0600 Message-ID: <20241119171739.77028-4-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241119171739.77028-1-mario.limonciello@amd.com> References: <20241119171739.77028-1-mario.limonciello@amd.com> Precedence: bulk X-Mailing-List: platform-driver-x86@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_|MN0PR12MB6128:EE_ X-MS-Office365-Filtering-Correlation-Id: e5c52dd9-1a41-497a-114e-08dd08be8c5a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|36860700013|82310400026|376014|7416014; X-Microsoft-Antispam-Message-Info: =?utf-8?q?4zgsMfTfjESMDkCxl+IpDHMnE90Vv1k?= =?utf-8?q?zi3XX4L7844DVFYDj9kkduLFftF0H6y+3vO0+Nc1besUedzN+9eidlqV0xQRJ6PiY?= =?utf-8?q?+Ve9gKQVmoi/F3AuYwczwmYt7+sMV7JzoLKGcAugualg+uHJEeiaaZUbKAkoAn1Ik?= =?utf-8?q?pA+4OUUnBV0wW+99Ds4llIo0MYOR03akX6YNKIghLMOqaY9XngChi/H26i08BmflG?= =?utf-8?q?E7WBrx7YRNrFl/9tirkGORj8u1ENFfwayH5qSN1n7sTRee2EBbNdVJuIoPbo8/nvv?= =?utf-8?q?ZXNgD6mBdJpKJCh7C3X9VSnFBKapqPkKM7LBhRL3dnYQzGn3KB6InyPNfoZUAO1V6?= =?utf-8?q?8Txx5OaoaZ+gbiYtz0Zc9c5ySV13sDa5J0BkhbsPQRyxC1PInm4wOrVXqkT6NxpBY?= =?utf-8?q?iMBNjPys+bug4uciVRm4iqasD6DiBuwIPuO5Y7is+/s0fNQ8E8/mw6H4dEv+D3lG5?= =?utf-8?q?MATAZDjRf7+ZQy8zBhjr1stz1nVFneFADc4RzP2camkQSAx8Xnr8/OzGR/GNwESr4?= =?utf-8?q?Mk+kU8opaBvhNsIV5InTltk1GeQ4ZBCwHuDhri1tM3WBDmLzGhBB+oS+Q9aX5hlyi?= =?utf-8?q?4AgARJNjLY8BkVsIMGVJVzJjrWa22147WxSo2eU0pJYiKY1FTaFERV8rjcRTYhxDN?= =?utf-8?q?JQsjPLNkP/xFfzGKVQu6IM+AFNKjZ/+B7Bi9kEwBTJZQj0LbGZDaZuz4z3RFF+kr9?= =?utf-8?q?ZB5JOiNxCt6wJ4V6ncunhraAj0ThlB2H1y0+O7VYHYd3wU6Zu6rywzI/fJq4wGnIU?= =?utf-8?q?jlNFtNWcLgs/KBfGKusGiqaiwKOu6GDgznqF2fcLPOTXu1atjwADD4ZDsbWewd0W2?= =?utf-8?q?Yh5XLIxh7BL6G9EGyXFn7AKgpaOVaxmxB8q1WFNNmoBGbTSyIXz7tl/5WtN1PuokL?= =?utf-8?q?BhwZvPR5jKd3XachFQW2stImqlUvY5HwFU23qDIdSZubLi2dvDQ5bogGiQo1Lqxg/?= =?utf-8?q?I5rXIdJQOLMEZwGOL/39qDs/9CRAq46gYryvnjoQW0jglkK59dfoY+RmQ0p/qmjTu?= =?utf-8?q?a1Xc7idfRtbBLY0zgKmfSXoyUS0lsT8mRw9xsA95FqfdI0AXditjVpN9UAXL0e+N6?= =?utf-8?q?Mq6kAakUN19x8uPTTzgJBmOmzVbxf3ubiWlMVzUbDU/Kx33TfzBnzajf667d4VX/h?= =?utf-8?q?lh3NSEvtqqtj+CREzrS7mP+am8zw6qs3VXRjzRQpwCdlURJxW5CtvTi/UyWzAmU/v?= =?utf-8?q?g5mfkXM1uKoXeSTO/jw7U+6NcK4GhBumxCvOlLH0PFS1Zv1dYPBRDSF8yxlSoGVOx?= =?utf-8?q?zv/x37VuEevSDEAxp2AST8U9PXiDugSNCGl0mEnRHQcTtf9TRF/OVduZB/NmKhS2q?= =?utf-8?q?9qvxoVy3TPA/DD9bU/TX59oOW3ksc51C4g=3D=3D?= X-Forefront-Antispam-Report: CIP:165.204.84.12;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:atlvpn-bp.amd.com;CAT:NONE;SFS:(13230040)(1800799024)(36860700013)(82310400026)(376014)(7416014);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Nov 2024 17:21:04.6124 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e5c52dd9-1a41-497a-114e-08dd08be8c5a 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.12];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: MN0PR12MB6128 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 --- v7: * Add Armin's tag v6: * Don't require to be set v4: * add alienware-wmi too --- drivers/platform/surface/surface_platform_profile.c | 1 + drivers/platform/x86/acer-wmi.c | 5 +++-- drivers/platform/x86/amd/pmf/sps.c | 1 + drivers/platform/x86/asus-wmi.c | 1 + drivers/platform/x86/dell/alienware-wmi.c | 5 +++-- drivers/platform/x86/dell/dell-pc.c | 1 + drivers/platform/x86/hp/hp-wmi.c | 5 +++-- drivers/platform/x86/ideapad-laptop.c | 1 + drivers/platform/x86/inspur_platform_profile.c | 1 + drivers/platform/x86/thinkpad_acpi.c | 1 + include/linux/platform_profile.h | 1 + 11 files changed, 17 insertions(+), 6 deletions(-) diff --git a/drivers/platform/surface/surface_platform_profile.c b/drivers/platform/surface/surface_platform_profile.c index 61aa488a80eb5..5f45f8e8cd69b 100644 --- a/drivers/platform/surface/surface_platform_profile.c +++ b/drivers/platform/surface/surface_platform_profile.c @@ -212,6 +212,7 @@ static int surface_platform_profile_probe(struct ssam_device *sdev) tpd->sdev = sdev; tpd->handler.name = "Surface Platform Profile"; + tpd->handler.dev = &sdev->dev; tpd->handler.profile_get = ssam_platform_profile_get; tpd->handler.profile_set = ssam_platform_profile_set; diff --git a/drivers/platform/x86/acer-wmi.c b/drivers/platform/x86/acer-wmi.c index 53fbc9b4d3df7..aca4a5746bee1 100644 --- a/drivers/platform/x86/acer-wmi.c +++ b/drivers/platform/x86/acer-wmi.c @@ -1873,12 +1873,13 @@ acer_predator_v4_platform_profile_set(struct platform_profile_handler *pprof, return 0; } -static int acer_platform_profile_setup(void) +static int acer_platform_profile_setup(struct platform_device *device) { if (quirks->predator_v4) { int err; platform_profile_handler.name = "acer-wmi"; + platform_profile_handler.dev = &device->dev; platform_profile_handler.profile_get = acer_predator_v4_platform_profile_get; platform_profile_handler.profile_set = @@ -2531,7 +2532,7 @@ static int acer_platform_probe(struct platform_device *device) goto error_rfkill; if (has_cap(ACER_CAP_PLATFORM_PROFILE)) { - err = acer_platform_profile_setup(); + err = acer_platform_profile_setup(device); if (err) goto error_platform_profile; } diff --git a/drivers/platform/x86/amd/pmf/sps.c b/drivers/platform/x86/amd/pmf/sps.c index e2d0cc92c4396..1b94af7c0e0c4 100644 --- a/drivers/platform/x86/amd/pmf/sps.c +++ b/drivers/platform/x86/amd/pmf/sps.c @@ -406,6 +406,7 @@ int amd_pmf_init_sps(struct amd_pmf_dev *dev) } dev->pprof.name = "amd-pmf"; + dev->pprof.dev = dev->dev; dev->pprof.profile_get = amd_pmf_profile_get; dev->pprof.profile_set = amd_pmf_profile_set; diff --git a/drivers/platform/x86/asus-wmi.c b/drivers/platform/x86/asus-wmi.c index c0ed9ffc3913b..c15fccf5131af 100644 --- a/drivers/platform/x86/asus-wmi.c +++ b/drivers/platform/x86/asus-wmi.c @@ -3867,6 +3867,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 805497e44b3a5..e5724e76a2082 100644 --- a/drivers/platform/x86/dell/dell-pc.c +++ b/drivers/platform/x86/dell/dell-pc.c @@ -257,6 +257,7 @@ static int thermal_init(void) goto cleanup_platform_device; } thermal_handler->name = "dell-pc"; + thermal_handler->dev = &platform_device->dev; thermal_handler->profile_get = thermal_platform_profile_get; thermal_handler->profile_set = thermal_platform_profile_set; diff --git a/drivers/platform/x86/hp/hp-wmi.c b/drivers/platform/x86/hp/hp-wmi.c index 26cac73caf2b9..ffb09799142bc 100644 --- a/drivers/platform/x86/hp/hp-wmi.c +++ b/drivers/platform/x86/hp/hp-wmi.c @@ -1565,7 +1565,7 @@ static inline void omen_unregister_powersource_event_handler(void) unregister_acpi_notifier(&platform_power_source_nb); } -static int thermal_profile_setup(void) +static int thermal_profile_setup(struct platform_device *device) { int err, tp; @@ -1625,6 +1625,7 @@ static int thermal_profile_setup(void) } platform_profile_handler.name = "hp-wmi"; + platform_profile_handler.dev = &device->dev; set_bit(PLATFORM_PROFILE_BALANCED, platform_profile_handler.choices); set_bit(PLATFORM_PROFILE_PERFORMANCE, platform_profile_handler.choices); @@ -1664,7 +1665,7 @@ static int __init hp_wmi_bios_setup(struct platform_device *device) if (err < 0) return err; - thermal_profile_setup(); + thermal_profile_setup(device); return 0; } diff --git a/drivers/platform/x86/ideapad-laptop.c b/drivers/platform/x86/ideapad-laptop.c index 1f94c14c3b832..24367c3590c99 100644 --- a/drivers/platform/x86/ideapad-laptop.c +++ b/drivers/platform/x86/ideapad-laptop.c @@ -1103,6 +1103,7 @@ static int ideapad_dytc_profile_init(struct ideapad_private *priv) mutex_init(&priv->dytc->mutex); priv->dytc->pprof.name = "ideapad-laptop"; + priv->dytc->pprof.dev = &priv->platform_device->dev; priv->dytc->priv = priv; priv->dytc->pprof.profile_get = dytc_profile_get; priv->dytc->pprof.profile_set = dytc_profile_set; diff --git a/drivers/platform/x86/inspur_platform_profile.c b/drivers/platform/x86/inspur_platform_profile.c index 03da2c8cf6789..5a53949bbbf5f 100644 --- a/drivers/platform/x86/inspur_platform_profile.c +++ b/drivers/platform/x86/inspur_platform_profile.c @@ -178,6 +178,7 @@ static int inspur_wmi_probe(struct wmi_device *wdev, const void *context) dev_set_drvdata(&wdev->dev, priv); priv->handler.name = "inspur-wmi"; + priv->handler.dev = &wdev->dev; priv->handler.profile_get = inspur_platform_profile_get; priv->handler.profile_set = inspur_platform_profile_set; diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c index c8c316b8507a5..222fba97d79a7 100644 --- a/drivers/platform/x86/thinkpad_acpi.c +++ b/drivers/platform/x86/thinkpad_acpi.c @@ -10616,6 +10616,7 @@ static int tpacpi_dytc_profile_init(struct ibm_init_struct *iibm) dbg_printk(TPACPI_DBG_INIT, "DYTC version %d: thermal mode available\n", dytc_version); + dytc_profile.dev = &tpacpi_pdev->dev; /* Create platform_profile structure and register */ err = platform_profile_register(&dytc_profile); /* diff --git a/include/linux/platform_profile.h b/include/linux/platform_profile.h index 6fa988e417428..daec6b9bad81f 100644 --- a/include/linux/platform_profile.h +++ b/include/linux/platform_profile.h @@ -28,6 +28,7 @@ enum platform_profile_option { struct platform_profile_handler { const char *name; + struct device *dev; unsigned long choices[BITS_TO_LONGS(PLATFORM_PROFILE_LAST)]; int (*profile_get)(struct platform_profile_handler *pprof, enum platform_profile_option *profile); From patchwork Tue Nov 19 17:17:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 13880349 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2055.outbound.protection.outlook.com [40.107.93.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 203941CF7C1; Tue, 19 Nov 2024 17:21:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.93.55 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732036877; cv=fail; b=p57k7rWzxMjSURn5PRcCLTBwma3g0dNqYb/+OZVpXXWmvMVZM815KxNFKolLSwaJ1P4AO1HY4qgfILsFliONXP6miWh4QWdILThdHTVadYWhFflGgKLTIdgEaC3EAzfQFe4ut3nWwah11RzP7poCslhgsoQXNUUcv5ncnH5+He0= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732036877; c=relaxed/simple; bh=vwvkuCF6TUIm5sAd8pAAU03EmVf6teWL+lnPU/6KHg4=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=K+uiwIyuYzDaNMaWGDos1xTEQ2isuP10/pKo9+1JjQQXx2fuoEkqTFYCodalFW0+P75/n336ADnsXxZjsHq+Ch9k1do92iJOpHlacjB5IeD2pOdkUnuhWdeENeHA6kwNtdecizyNVkEe0yViUOOdOAaKV1oRv4VVYZ2qljZXgc0= 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=nkpUuvU3; arc=fail smtp.client-ip=40.107.93.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="nkpUuvU3" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=srrFMrOqPaeVWp5glqZ8kBNr+VFg2UhF/XvvxacZlERVySrJuUSzegr439rREJbUOy0bqtznGb3qBc8e/DUdScarEjqQ+NHvAp+jCu30foPNUHa2Muccuf4PXnWMd8hPXVHl4xUihsLxetQQTnk3UokF4ajy+G1QDSccn0cxOWOpC/pO5Tuq0Rksodcv5QMWNEWz7qaHGMO+AdSi09Jmm4+NfEU/yATN1wLLAiyPleiRdLAVkgPmO4KrrzyiMPcWSObym0lfZk1bZ8v02r8rXpKVhQOuExkzM4DyViC7mhwU4QKx5Pfl3yMy/7G3QLijQIR5cC//sUmyNOEGGggnWA== 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=OehAyRoZjLR3a5hc5eWpv7UNPEKV6B1j4xI56uoKf0c=; b=X5zHp3W7IpzCuse6CP165r99P81n9YtFn60+3oQ5WNDg3E/Taoq9jT25FrpluXPN31fLt1Xa/8uefHdabzpxdpccaStSKbEogOxEVS3BSj03T0jzu//Fu1dPrBMHpuuji/OkjnZ+s+FEZuDvt+tlQGivowJg24Ilz8l/9Hbh++ZEySlitLZr54hOaApVDM5gCVZiT6j+fAbothLprSWV7SztvBH6lcei7NK1kjvh/5X3tXDK5h6tF0JaLkL1TC5sGZrqgOIbkhRtT6TFKAJ9AVX+PkJJ1Juy+cRDv33FqO0z+MIYjH2fKAU2dpCBwskCgKlMqk8MpJSdEJFYZratzw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.12) 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=OehAyRoZjLR3a5hc5eWpv7UNPEKV6B1j4xI56uoKf0c=; b=nkpUuvU3seWwlgItY85QqU7dZrwI8yixAUI5flcm4zLKYUOP8//nacz7Xgv8R6z/GNGJ530OOn7IRv0EE9vKEGVhorYRkbOIh6LeGIk7V8J7/eZu71aaFN4JGt1j4Xoidq8VJ1pgj0I7sqfQhkmw2B9CxxfUWQa1em0lRoXFTi4= Received: from SJ2PR07CA0022.namprd07.prod.outlook.com (2603:10b6:a03:505::24) by DS7PR12MB5719.namprd12.prod.outlook.com (2603:10b6:8:72::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.22; Tue, 19 Nov 2024 17:21:08 +0000 Received: from CY4PEPF0000EDD4.namprd03.prod.outlook.com (2603:10b6:a03:505:cafe::40) by SJ2PR07CA0022.outlook.office365.com (2603:10b6:a03:505::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.24 via Frontend Transport; Tue, 19 Nov 2024 17:21:07 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.12) 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.12 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.12; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.12) 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.8158.14 via Frontend Transport; Tue, 19 Nov 2024 17:21:07 +0000 Received: from AUS-P9-MLIMONCI.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Tue, 19 Nov 2024 11:21: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 v7 04/22] ACPI: platform_profile: Add platform handler argument to platform_profile_remove() Date: Tue, 19 Nov 2024 11:17:21 -0600 Message-ID: <20241119171739.77028-5-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241119171739.77028-1-mario.limonciello@amd.com> References: <20241119171739.77028-1-mario.limonciello@amd.com> Precedence: bulk X-Mailing-List: platform-driver-x86@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_|DS7PR12MB5719:EE_ X-MS-Office365-Filtering-Correlation-Id: 8c2ba382-6e14-4de4-2329-08dd08be8e32 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|7416014|376014|82310400026|36860700013; X-Microsoft-Antispam-Message-Info: =?utf-8?q?4dAqlA0A4SmP9oHnFyWOmjDDoR/qRGH?= =?utf-8?q?Nffr2KUMkkI/l02/T/eDNdnsMdOJ2Nyibe9FjNhurGJgZjrwyJJIZkIfFLr5vZsz1?= =?utf-8?q?gR0VVuvg6x9LYWk2VksJUHPrF0G7//siWStrnJSdr4bgtoOLOuZ1/aXRrr4Dz1fFI?= =?utf-8?q?Z8QxlA3WpBc8xaE4/ZEmtBzDRi8oL+xcln4Ysp6vs9+JA+ahCKKDEyGcmdFw1IU3L?= =?utf-8?q?GyV7rgM5b8VZidlkTBX7h+86rEDqtWkmeOv3dIR7SJRCGO955Gr1KHGE2xLLfJi1r?= =?utf-8?q?mbIpJNjh+hkEeCO7ewfiDwIOlsdfEaiG5k1WKhurC2b/t6Jbh0CrtAKrqg40h9qnk?= =?utf-8?q?qSoDNSaeXxYGXi8qFaIvaW9GIbprNFHSLpKX89FFyaicRC18b7LZASO9UanOXn1+b?= =?utf-8?q?maOs2uaA69v+VsHi6YY6wZPrFsSYCf2Wjm7llsNqC4814JYLw4ECcT5SdGvN5MboX?= =?utf-8?q?EVMz6c8qj/Twj9XdHK/jdaBUlyVoeSZRTaVZlzYXe7Ad94RTsR6fiCn35Sa8KJA6q?= =?utf-8?q?f29M3wwz9EJfrFTe1FldaFQNo5kD9ibzRPik/qApbX4s+xwRPMfcFZBSNJDQDYOin?= =?utf-8?q?ZMUlP+du922swFCvI+5Cn34tFGwrOxsxeApnjzQnicbKXhm8TO+BUMTRnZ99Z9FnW?= =?utf-8?q?zDgH6W/zugLK7VK+4eRDkCamzv2uKzPjBO7q3v/NaJU8VOdGh4JUfV1M2kptYQ8U1?= =?utf-8?q?kHLN/cSyzbAW3T6CXVIPfrsiqZ+uBS/AuFTGKAM5IboOJ2oCfxGev7iKOxW932ziK?= =?utf-8?q?svxxKD70yay3/znD+X8lHbzztuYMfFD5tULJIEXwJ103AdjjtOkHJbiUiefDl9gDZ?= =?utf-8?q?OM1dPvAvsvhALQRhLH/3SqUw52cMkWXeyS5S4JugOCTxtaO3ItIfw7INvJ7Fndz0Y?= =?utf-8?q?e0btYLzB7ApLjVYK5wykjaVEZ2uTM+N9wPAnxYl8Fg2GbVogtELzKO8FTU607rFyX?= =?utf-8?q?TVOgO8fAlqxthyaUO+21Orb9V+SCK9LSzTB9LfFVHcq/1m8w25oB0l1T1hDGc/vUK?= =?utf-8?q?yCgr5YZOrSpCHFBswxO/UoIvn7akK85TelSuDrbwoitL9lvvDhNHhyeZqy68wvBBJ?= =?utf-8?q?4YU0PmkHtg3VE8lQWuOXpRtIemCnPIi/gdCRa4yP/u1kzycfQ19A64zs02YVQU5hP?= =?utf-8?q?ieLJUQcvDzdw8pfSPFvDHQrYx1yu+gWkytqugPllsI7Wz8nnd3sSQ1WpL8dmpgSOD?= =?utf-8?q?p59YFnVfRuZMJsV+8vL2QNPsfgZbEbjlt9nm7EAVPNZx3S8eubZLrnjxXoN2unl5F?= =?utf-8?q?pStpfl/iaelEMcObkslkkSQtL3WisOVutcYDHcKoJ1rIHFM0bdiR2IXuPSp75UaUk?= =?utf-8?q?m2vOsL4qCvhcDThd3xZte/77yWDNDbP0tw=3D=3D?= X-Forefront-Antispam-Report: CIP:165.204.84.12;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:atlvpn-bp.amd.com;CAT:NONE;SFS:(13230040)(1800799024)(7416014)(376014)(82310400026)(36860700013);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Nov 2024 17:21:07.7062 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 8c2ba382-6e14-4de4-2329-08dd08be8e32 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.12];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: DS7PR12MB5719 To allow registering and unregistering multiple platform handlers calls to platform_profile_remove() will need to know which handler is to be removed. Add an argument for this. Tested-by: Mark Pearson Tested-by: Matthew Schwartz Reviewed-by: Hans de Goede Reviewed-by: Mark Pearson Reviewed-by: Maximilian Luz Reviewed-by: Ilpo Järvinen Reviewed-by: Armin Wolf Signed-off-by: Mario Limonciello --- v5: * Add tag v4: * Add alienware-wmi too --- drivers/acpi/platform_profile.c | 2 +- drivers/platform/surface/surface_platform_profile.c | 6 +++++- drivers/platform/x86/acer-wmi.c | 4 ++-- drivers/platform/x86/amd/pmf/sps.c | 2 +- drivers/platform/x86/asus-wmi.c | 4 ++-- drivers/platform/x86/dell/alienware-wmi.c | 2 +- drivers/platform/x86/dell/dell-pc.c | 2 +- drivers/platform/x86/hp/hp-wmi.c | 2 +- drivers/platform/x86/ideapad-laptop.c | 2 +- drivers/platform/x86/inspur_platform_profile.c | 5 ++++- drivers/platform/x86/thinkpad_acpi.c | 2 +- include/linux/platform_profile.h | 2 +- 12 files changed, 21 insertions(+), 14 deletions(-) diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profile.c index d2f7fd7743a13..c24744da20916 100644 --- a/drivers/acpi/platform_profile.c +++ b/drivers/acpi/platform_profile.c @@ -205,7 +205,7 @@ int platform_profile_register(struct platform_profile_handler *pprof) } EXPORT_SYMBOL_GPL(platform_profile_register); -int platform_profile_remove(void) +int platform_profile_remove(struct platform_profile_handler *pprof) { sysfs_remove_group(acpi_kobj, &platform_profile_group); diff --git a/drivers/platform/surface/surface_platform_profile.c b/drivers/platform/surface/surface_platform_profile.c index 5f45f8e8cd69b..b449c4c8b883c 100644 --- a/drivers/platform/surface/surface_platform_profile.c +++ b/drivers/platform/surface/surface_platform_profile.c @@ -210,6 +210,7 @@ static int surface_platform_profile_probe(struct ssam_device *sdev) return -ENOMEM; tpd->sdev = sdev; + ssam_device_set_drvdata(sdev, tpd); tpd->handler.name = "Surface Platform Profile"; tpd->handler.dev = &sdev->dev; @@ -228,7 +229,10 @@ static int surface_platform_profile_probe(struct ssam_device *sdev) static void surface_platform_profile_remove(struct ssam_device *sdev) { - platform_profile_remove(); + struct ssam_platform_profile_device *tpd; + + tpd = ssam_device_get_drvdata(sdev); + platform_profile_remove(&tpd->handler); } static const struct ssam_device_id ssam_platform_profile_match[] = { diff --git a/drivers/platform/x86/acer-wmi.c b/drivers/platform/x86/acer-wmi.c index aca4a5746bee1..b12965d9fcdb7 100644 --- a/drivers/platform/x86/acer-wmi.c +++ b/drivers/platform/x86/acer-wmi.c @@ -2547,7 +2547,7 @@ static int acer_platform_probe(struct platform_device *device) error_hwmon: if (platform_profile_support) - platform_profile_remove(); + platform_profile_remove(&platform_profile_handler); error_platform_profile: acer_rfkill_exit(); error_rfkill: @@ -2570,7 +2570,7 @@ static void acer_platform_remove(struct platform_device *device) acer_rfkill_exit(); if (platform_profile_support) - platform_profile_remove(); + platform_profile_remove(&platform_profile_handler); } #ifdef CONFIG_PM_SLEEP diff --git a/drivers/platform/x86/amd/pmf/sps.c b/drivers/platform/x86/amd/pmf/sps.c index 1b94af7c0e0c4..bd2bd6cfc39a0 100644 --- a/drivers/platform/x86/amd/pmf/sps.c +++ b/drivers/platform/x86/amd/pmf/sps.c @@ -426,5 +426,5 @@ int amd_pmf_init_sps(struct amd_pmf_dev *dev) void amd_pmf_deinit_sps(struct amd_pmf_dev *dev) { - platform_profile_remove(); + platform_profile_remove(&dev->pprof); } diff --git a/drivers/platform/x86/asus-wmi.c b/drivers/platform/x86/asus-wmi.c index c15fccf5131af..9105b456eab1f 100644 --- a/drivers/platform/x86/asus-wmi.c +++ b/drivers/platform/x86/asus-wmi.c @@ -4842,7 +4842,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); @@ -4869,7 +4869,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 e5724e76a2082..5c4d48e4b667a 100644 --- a/drivers/platform/x86/dell/dell-pc.c +++ b/drivers/platform/x86/dell/dell-pc.c @@ -289,7 +289,7 @@ static int thermal_init(void) static void thermal_cleanup(void) { if (thermal_handler) - platform_profile_remove(); + platform_profile_remove(thermal_handler); platform_device_unregister(platform_device); } diff --git a/drivers/platform/x86/hp/hp-wmi.c b/drivers/platform/x86/hp/hp-wmi.c index ffb09799142bc..6d6e13a0c6e2d 100644 --- a/drivers/platform/x86/hp/hp-wmi.c +++ b/drivers/platform/x86/hp/hp-wmi.c @@ -1693,7 +1693,7 @@ static void __exit hp_wmi_bios_remove(struct platform_device *device) } if (platform_profile_support) - platform_profile_remove(); + platform_profile_remove(&platform_profile_handler); } static int hp_wmi_resume_handler(struct device *device) diff --git a/drivers/platform/x86/ideapad-laptop.c b/drivers/platform/x86/ideapad-laptop.c index 24367c3590c99..80797c6ae8b0b 100644 --- a/drivers/platform/x86/ideapad-laptop.c +++ b/drivers/platform/x86/ideapad-laptop.c @@ -1136,7 +1136,7 @@ static void ideapad_dytc_profile_exit(struct ideapad_private *priv) if (!priv->dytc) return; - platform_profile_remove(); + platform_profile_remove(&priv->dytc->pprof); mutex_destroy(&priv->dytc->mutex); kfree(priv->dytc); diff --git a/drivers/platform/x86/inspur_platform_profile.c b/drivers/platform/x86/inspur_platform_profile.c index 5a53949bbbf5f..53af73a7fbf7b 100644 --- a/drivers/platform/x86/inspur_platform_profile.c +++ b/drivers/platform/x86/inspur_platform_profile.c @@ -191,7 +191,10 @@ static int inspur_wmi_probe(struct wmi_device *wdev, const void *context) static void inspur_wmi_remove(struct wmi_device *wdev) { - platform_profile_remove(); + struct inspur_wmi_priv *priv; + + priv = dev_get_drvdata(&wdev->dev); + platform_profile_remove(&priv->handler); } static const struct wmi_device_id inspur_wmi_id_table[] = { diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c index 222fba97d79a7..13798c6d5fcf3 100644 --- a/drivers/platform/x86/thinkpad_acpi.c +++ b/drivers/platform/x86/thinkpad_acpi.c @@ -10638,7 +10638,7 @@ static int tpacpi_dytc_profile_init(struct ibm_init_struct *iibm) static void dytc_profile_exit(void) { - platform_profile_remove(); + platform_profile_remove(&dytc_profile); } static struct ibm_struct dytc_profile_driver_data = { diff --git a/include/linux/platform_profile.h b/include/linux/platform_profile.h index daec6b9bad81f..bcaf3aa39160f 100644 --- a/include/linux/platform_profile.h +++ b/include/linux/platform_profile.h @@ -37,7 +37,7 @@ struct platform_profile_handler { }; int platform_profile_register(struct platform_profile_handler *pprof); -int platform_profile_remove(void); +int platform_profile_remove(struct platform_profile_handler *pprof); int platform_profile_cycle(void); void platform_profile_notify(void); From patchwork Tue Nov 19 17:17:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 13880347 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2067.outbound.protection.outlook.com [40.107.92.67]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 350BC1CF295; Tue, 19 Nov 2024 17:21:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.92.67 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732036875; cv=fail; b=opOtR5tAjI3bL5t88Rg3y47Tq2ivLPNITctEFTIhX49BusppU7E7Atbrd5PmMuJgUvPpYTkur5Nva5+ZTB+XL56kwkLzOPy6MJVDMDGi9nETVgDYOfIph2jLhr8lW52rhLEXD5ko2lR6fvtEXuyHX/CDxVueTGUYg5ixw9MzpT8= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732036875; c=relaxed/simple; bh=JPe2DJsTvwK+BxZZsMEmNji+XZXD4uKA1ctPwvtUOf0=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Ya/winkQa577nSVTeMhGlLEoy32xi2nrXkLBYZw4o6aEyX5355c6qSd8UviXml88aJPXaLYGFbG4q0JtLnu7spvtI9PbS9nzL/tkdV2scfQTJzduWqt4w2yiFcxrQ0TVF6stKvx2EmRNqR1NE1BCUsxd+1nOyBZF/Ihp5NYx614= 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=khN3K3JO; arc=fail smtp.client-ip=40.107.92.67 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="khN3K3JO" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=ocUyvG9b/mDzGCwEU1WnX5OnEO0UgknzSXw9QEKpkLV+MpagNytxa6C9QaxYKqm5GQpwCi4v0MEpm2xl5dS1hRkKtJZo6k9qcpq/P7KSlHDoBKGMasuUchxboaD5zNOHIGsHqaIJEMd+R67kA3DRcDzeZYtmCgDJ/0XryP2JcvMyyWVt6TW3WqS63MAWHaiwGsecCKosXS8cOqyYkjcfSyBfQ+xPTren64EyWvSjsVRzHTG74BYPS8IKQrB542aKXo4F9Z+0VxLfK8zYuz2MKR7jHeHIGzgRq4KwFSivfefxrQ5reeB7jV904hMm1lT9sz/VtszVC+9gwVTxlhhhwA== 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=zzCFVbPZgYxPcQ1+GhB7cobM6gVHm22OUaAGLwiiReU=; b=BkDAYvRiBY7JyUaIx60tIpmvv73epvM17nESHdmN57kjOqzV8itPO61ssRsCj+8Fiuqa1U6yfPrR64BcoZWpBFSIjL0i1DTdFmJuuHsJPsserp+0iexMIgUMoOzbQjo5k8eROL1QFLs470KX8mPRxPLJ2q4ipI+ima5JqaSFeFuXLQw7b17ZBZjMzju79Ww6HQp3Xap64+T3BEg5EBWVcSDAMXLLr38xkcvDBQ9zBdExxA7dCjAVDgdkcb1ktSLCvj/Jc9yOf8Bwd60OMtmPCR7o4Kshuf/thm+tHhy4T5yIHhrCCurXGveJTAZON1nw+pCScWRy4IoO06VmDer2fQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.12) 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=zzCFVbPZgYxPcQ1+GhB7cobM6gVHm22OUaAGLwiiReU=; b=khN3K3JOkcDQMw58erNZm0NgzHVxfbIvtfp/q/3cRnPG4n5umGgUBf1BTMOrxZbmdpqaEBjv0ep8fhF6Ggkdu+oABGU3RzmW5QYwW1Ha0JgdKXUd0Q3OafckV6/Xzevf+PHmNZXCqk4do3qLPD/f/SUxQxYRDXJ1QigpY6UPIjQ= Received: from PH7PR17CA0047.namprd17.prod.outlook.com (2603:10b6:510:323::29) by PH8PR12MB7374.namprd12.prod.outlook.com (2603:10b6:510:216::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.23; Tue, 19 Nov 2024 17:21:10 +0000 Received: from CY4PEPF0000EDD6.namprd03.prod.outlook.com (2603:10b6:510:323:cafe::27) by PH7PR17CA0047.outlook.office365.com (2603:10b6:510:323::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.24 via Frontend Transport; Tue, 19 Nov 2024 17:21:09 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.12) 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.12 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.12; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.12) 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.8158.14 via Frontend Transport; Tue, 19 Nov 2024 17:21:09 +0000 Received: from AUS-P9-MLIMONCI.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Tue, 19 Nov 2024 11:21:04 -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 v7 05/22] ACPI: platform_profile: Pass the profile handler into platform_profile_notify() Date: Tue, 19 Nov 2024 11:17:22 -0600 Message-ID: <20241119171739.77028-6-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241119171739.77028-1-mario.limonciello@amd.com> References: <20241119171739.77028-1-mario.limonciello@amd.com> Precedence: bulk X-Mailing-List: platform-driver-x86@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_|PH8PR12MB7374:EE_ X-MS-Office365-Filtering-Correlation-Id: a5410d8f-e214-4d78-ea3f-08dd08be8f47 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|376014|7416014|36860700013|82310400026; X-Microsoft-Antispam-Message-Info: K1psSYPGuzdJ4PrkKJ70Ax5O5+o0HYtVVv7F1kuIsdm6C+vBAY/8FaVV/U0c0wRGeAMNINJvuVSLIhHU/wDmrdktUa1TlN8a7Ij367tl0XIg9R/oBUPbH1HDf9iVp2GOFxH2CqKzo/QvfkwbkyPMBDBPGA/hbvdQWWHamrSwQq1QXzLuX1qBa/WxlZNBEHcsQn7jhiiW6UqJuoGP4LPDXh6dZPgBKKS99WsVXzvVts0m/NFN3WMjFHFVidkpdYtu7qqnwIov//dCpSjHZD27IbjcTwMb59EpKcrWg2QyNf3DNLMwIXDP/9mRLZC/CkgQ+mQ4hPF8gJHHPuPpz8fv2tD65XswujFLyRqOiACjRT7gDR8JllO0nONKJV2mBPmJj4f5VlDHkb1W5R0oGJwXLFlmv5eGMAAC82IqrkmqbtRUVAxUHalJiX3oi8A4Fq7t/jBGm23uSYTKXOEdOPxaBl1/v2NT4kdrmRPUqpgs3ahbdhL5Vx2LwuPGs+Cg757EYHSNoMtdJGJyhmxTQQ2lFyYoRggdblBipjHly+XqxxpGXnLn0keMrTiWuuvyyAbGjbUwao1/kdqJyp25jucp08GSE0glF5fhiWzZAprlrOyB3LEYHb4ZY7gEf3ItKBJbfEmKPhVVOCaBW4sFWAUh9pZjMiORuLj+r6iuzF0njfW7qrfbw/PzWa8jXBwuHUyN4g2/HlKmgFSO2+PGl5RgQgeFVtbqIJ6yYseSXSH+8jbg6NnYiAr0HOjSXBGhjJBUK/braxZ7IC9jGRha4TYIklAhwLOviCe1+iEkY3dxXSxlyNnvBuW5nWkznRuZWCfmi6/5mfQdXRNPGz2KeLCxQpOO5qshaub8kPdXttTw5WKgBBKcsqoI0n9jLR5VlejZ3L2cmFFHXhFF0d2pYp93tj/LcY9IcOCssrM+fcgkSSRC4+S8tbPe+DnnP+95MNK6gzOqHOs2irtLomvlr+9SMBxNyIBozfwPV1tXoXCnbv7S7K8NilDt1GT/VGUbxW3OuHcm49U/dK9YXjsiATPoBXTLjuBtoJddsBHkOfnQN8a9/aNkFlVyDfJKppX25Eva8mLxNqvlFFCnUiFk/5KT0JkhLB+OycKjhDO3gaFSXOTHysYX61O87q9tXSiPc7KHvuJ5u6/p+rgrab6nANhA8muFC5xhAQjuYCZFV43Ea0FklEfV4ZOSIBwZt3nsd5ASZeyIpTjQep0mGQO9UjvGF0fjXOI8dOwCQF1pQDPWCt1QeffkN9faoxwNeSiEJR+JeLguWbXa3BncPC6bEhwo09xrcs1ksvqIxo2Nk+SHsS94SENw+aC763etxnvAxBz2G+p+DNcNKho45DhGyuZ9hf4HVI0J2SU9gnwJ2YKFwT8Q4nWoi23cC/Q3KNWhnvBYUZY+hL0xwYdUyS5kyAn33A== X-Forefront-Antispam-Report: CIP:165.204.84.12;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:atlvpn-bp.amd.com;CAT:NONE;SFS:(13230040)(1800799024)(376014)(7416014)(36860700013)(82310400026);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Nov 2024 17:21:09.3548 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a5410d8f-e214-4d78-ea3f-08dd08be8f47 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.12];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: PH8PR12MB7374 The profile handler will be used to notify the appropriate class devices. Reviewed-by: Armin Wolf Signed-off-by: Mario Limonciello --- v7: * Rebase on pdx86/for-next for asus-wmi change * Add Armin's tag --- 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 9105b456eab1f..dcda7420ca26c 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 80797c6ae8b0b..79c65c24b433a 100644 --- a/drivers/platform/x86/ideapad-laptop.c +++ b/drivers/platform/x86/ideapad-laptop.c @@ -1041,7 +1041,7 @@ static void dytc_profile_refresh(struct ideapad_private *priv) if (profile != priv->dytc->current_profile) { priv->dytc->current_profile = profile; - platform_profile_notify(); + platform_profile_notify(&priv->dytc->pprof); } } diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c index 13798c6d5fcf3..8539cac042be8 100644 --- a/drivers/platform/x86/thinkpad_acpi.c +++ b/drivers/platform/x86/thinkpad_acpi.c @@ -10516,6 +10516,12 @@ static int dytc_profile_set(struct platform_profile_handler *pprof, return err; } +static struct platform_profile_handler dytc_profile = { + .name = "thinkpad-acpi", + .profile_get = dytc_profile_get, + .profile_set = dytc_profile_set, +}; + static void dytc_profile_refresh(void) { enum platform_profile_option profile; @@ -10544,16 +10550,10 @@ static void dytc_profile_refresh(void) err = convert_dytc_to_profile(funcmode, perfmode, &profile); if (!err && profile != dytc_current_profile) { dytc_current_profile = profile; - platform_profile_notify(); + platform_profile_notify(&dytc_profile); } } -static struct platform_profile_handler dytc_profile = { - .name = "thinkpad-acpi", - .profile_get = dytc_profile_get, - .profile_set = dytc_profile_set, -}; - static int tpacpi_dytc_profile_init(struct ibm_init_struct *iibm) { int err, output; diff --git a/include/linux/platform_profile.h b/include/linux/platform_profile.h index bcaf3aa39160f..8ec0b8da56db5 100644 --- a/include/linux/platform_profile.h +++ b/include/linux/platform_profile.h @@ -39,6 +39,6 @@ struct platform_profile_handler { int platform_profile_register(struct platform_profile_handler *pprof); int platform_profile_remove(struct platform_profile_handler *pprof); int platform_profile_cycle(void); -void platform_profile_notify(void); +void platform_profile_notify(struct platform_profile_handler *pprof); #endif /*_PLATFORM_PROFILE_H_*/ From patchwork Tue Nov 19 17:17:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 13880348 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2072.outbound.protection.outlook.com [40.107.93.72]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 255131D2708; Tue, 19 Nov 2024 17:21:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.93.72 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732036877; cv=fail; b=I2CS7hlXA2XadWmrHo1+2Frdxh1qlX3CZlQvhvamr7qnms53q8FkWcqRf6X0gW3S/LzNDcT6192tvMBCkC8nuIaeOKTyXzGNc05vyxnEQU30/NRXOwovtoBBXZzrWuvwtUltwiPMGSPGhBiGpRHc3WUP9j+xJoNRuqQ6olK+zHc= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732036877; c=relaxed/simple; bh=qxZR0ioXhz7I9mrAT8p2DAj4zP/orxCZ1guCEIlDwcY=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Jt56qRUEAnl63xsOCzh+HUWQHopDCNtNsDNZQit93AMD7iZMnhPyK9VsVI6KCiC8u8H0C0XH7NEXHmfD4ZECUh7lzw+rpfQKZtAy8+FulRSZa+iAY6fZAKx22v7zBjzAJXi5nug8ftIXjvIci8n7f3zckDOgyAULc8vLiqk1ASo= 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=uE4qgv67; arc=fail smtp.client-ip=40.107.93.72 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="uE4qgv67" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=W2wylO5jr9tjnFaHHZHHl2IhJHMKm1fO2NG4eJ391VD7qlxQ2W3O6rguP5hHPnPfFy//thiGdYXEPiA+JXz1imW2hMCQefvJQCmpzc8OLrryLFyiTTmCSV8L/vPN8DhV4ELX6I5QDS8LZjFugOoNE46H7aeEwS/a2yst8AdTtBk+rAeYNuvA3eLPMIJ2k9PjO0phnLcaNDaKomZdrwH0b50ulocToP1jsQEX5QO8K8gSMqrn+YXy9YVsHENejC/jbXLrfawJoOM8Tm2VHlpjSrApDbz7zewW2nU/4l1lXT8pDtZ9hpAivVyRnja08qQQhDRk9cIN5wKCMupnzJdPJQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=eb96Rfxdmtyo0JIpdtirBRC/6HMVRjTmHsGHHm4KVnY=; b=EyI3YNO2Z6KchJi9ZGJeNzpv88p44RP6zN41/m9ES4Sbom2gnrweoZbMM72O5cE1pvjdpe9mki90VOZLiVyB1x6bOlo3Po1a2TUjzQByfrHCzUFUBGvOigu1kW6PytIdwkDs//UO1ndjSHq0eT+9CLo1E7puYC2N228HQWnTuHdNvGX7Uocc3saSxgYARrh7LMxLljz28NbAf4LuJeu9mA0EKdjs8U11D3esFvGSECOd/c0mRXHej37mi59JKfY0QJdeRWoAdG9Qx7k5VFmCwRiM2QAGTZUJZDQoGqyQh5SKsPu0l8uuwhO9hWdVbD49RAEI5P6phHLbe6T6iWJYQQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.12) smtp.rcpttodomain=redhat.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=eb96Rfxdmtyo0JIpdtirBRC/6HMVRjTmHsGHHm4KVnY=; b=uE4qgv678V+t+69Pu6mXQnBJ8mG+hyaokDNHf3tSoXVDOQhCd8uukBHt9L1r32/Wbz8CaSX6AAYaKaVdV11RJ6IJpQjqzmyhLMNEoddF5gGrB9ie70boRQ6vnouftuWTrxJu2Xc+uLNl+OYmKIfS19/lJesn6c+j54UgmKlHGuA= Received: from SJ2PR07CA0022.namprd07.prod.outlook.com (2603:10b6:a03:505::24) by BY5PR12MB4065.namprd12.prod.outlook.com (2603:10b6:a03:202::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.24; Tue, 19 Nov 2024 17:21:11 +0000 Received: from CY4PEPF0000EDD4.namprd03.prod.outlook.com (2603:10b6:a03:505:cafe::18) by SJ2PR07CA0022.outlook.office365.com (2603:10b6:a03:505::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.24 via Frontend Transport; Tue, 19 Nov 2024 17:21:10 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.12) 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.12 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.12; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.12) 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.8158.14 via Frontend Transport; Tue, 19 Nov 2024 17:21:10 +0000 Received: from AUS-P9-MLIMONCI.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Tue, 19 Nov 2024 11:21:06 -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 v7 06/22] ACPI: platform_profile: Move sanity check out of the mutex Date: Tue, 19 Nov 2024 11:17:23 -0600 Message-ID: <20241119171739.77028-7-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241119171739.77028-1-mario.limonciello@amd.com> References: <20241119171739.77028-1-mario.limonciello@amd.com> Precedence: bulk X-Mailing-List: platform-driver-x86@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_|BY5PR12MB4065:EE_ X-MS-Office365-Filtering-Correlation-Id: 0dd9ec7a-38fa-46a2-fb33-08dd08be8fef 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?mRfOITZp+iieJatW1eMJgbzWYEmkkDs?= =?utf-8?q?Ez6zh7N4JB1zFn9Wv/+LDImvby7zpAgG3KD2AefBIGenPdgK9vAoE/WLZzn//7Tg1?= =?utf-8?q?HmtSpjj+FZO3PIaLoezA5T23Gq0TtvU6QXYiLpGu7UMCQ2QoQ8g8tBdb0VVxDaaAl?= =?utf-8?q?iaWpQp79OXe5WjumI1TnMzv0KjBXQ0kcJ77Wo6nor3uUb2WD55zRAdYkjnNcupDFp?= =?utf-8?q?3G6cbW+kyqVX7gGJeTCQBDsJlh0dXKxepAHnhCtZ/3Y9qEj0E7gamspS09Wq9y8qi?= =?utf-8?q?vXefBW05E+6HkmG5LTYkLrA4cClFuTw94E8WE27qmMJLXy/eHsd3KbyqVPPF+2+Wv?= =?utf-8?q?3rZ+GZc4OfRUiC5E1p3G+45SCMRm21Gz5ySqV1lmq+rLHp4nrJ1cPZJ0oDQYiPfxW?= =?utf-8?q?bFCEAJZ3zyJqMvu2oUC0lFPNQxL9FzjUGVF+bmsHD0qNgpfi2LjShOI6qFuMz+UJW?= =?utf-8?q?jsZRyCtAc0ahN6xz8jpuNqTvH2SHjhJulb8GlGIYKCTBq65dxLIXjNHmQeUwNMmSQ?= =?utf-8?q?/y1mtFKh+FuSnuONUbHu8qi2OKXNZDxGyBBquh1NwfIzreZzwZJcnvUdIRx2GjCcZ?= =?utf-8?q?/LkL2k7rYc94twG6eELz/iwiCmpNf+qenm9i8Z5YPQoFQp37xepRdt5dqK+H3S91h?= =?utf-8?q?OI+pYUkkvbAF+cDAPlXzuenIZxXIKh1n+Wk/M1woN154hv50ORq9UHpI2YmO+t4wX?= =?utf-8?q?wayPGxnqxScNe+/ysfBCCDO+eCZoz9+hTeFRITZflnhBslFsxJRpsEpm7AAwxjkvO?= =?utf-8?q?AZdTbE8//VOBpzUXZSw/UoE+KoVPgXO1F6ur5DbrehbyXzt9IZUfqjMXp7dQ1XKvZ?= =?utf-8?q?QUw67ku8xsJE/0onCeJgm1NHX7J5Ym60qECVDUAg+TRD6F+Hg2Zdkly4k07Qjn3o1?= =?utf-8?q?GlLhW5CL49bxlmVjq4v8/r0KBhYXBpoxRUq4/gEb3tBWrJxBR0hgmHyOnEYoVJrGc?= =?utf-8?q?6bXwVvSbeQru1YRZHETFK0sIU6+gf7LN7CmFyJdAzBh9tqq3aiOX0NJSiAg1mfHUC?= =?utf-8?q?ImCRV655C8HvGQ/SqBg+JN9k+EBdON1ngdq0sSdqrW73NdgG30PakFi2IQ3PownUv?= =?utf-8?q?b9IE0QQsTuhAisnsOmAuQuRVSRM7bFg2RfOcJRnsJB26Pb2oECJgW1oFke1IagMl5?= =?utf-8?q?+NoJrgqOEDduEvw9NsKqaQn8nbh6Oy1v/4Yj/WKsrXdv8H/b8VO8ydig4WHhvKYGe?= =?utf-8?q?fl1rj+eszI6m96iEF6BTqjqyMMaIPnx2JnthQYY66KB2HzRU3RqTg57sYHF2s2hrE?= =?utf-8?q?S746jNow1vQcsIC6j1g7/HWT0B5i6btcNpV4hilaakILFRsgCj+Eya/LeBytRoYer?= =?utf-8?q?kVcb0CC0ua10+BvwNbabbq2AfAd0O09lmw=3D=3D?= X-Forefront-Antispam-Report: CIP:165.204.84.12;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:atlvpn-bp.amd.com;CAT:NONE;SFS:(13230040)(376014)(7416014)(1800799024)(36860700013)(82310400026);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Nov 2024 17:21:10.5812 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 0dd9ec7a-38fa-46a2-fb33-08dd08be8fef 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.12];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: BY5PR12MB4065 The sanity check that the platform handler had choices set doesn't need the mutex taken. Move it to earlier in the registration. Tested-by: Mark Pearson Tested-by: Matthew Schwartz Reviewed-by: Ilpo Järvinen Reviewed-by: Mark Pearson Reviewed-by: Armin Wolf Signed-off-by: Mario Limonciello --- v5: * Add tag --- drivers/acpi/platform_profile.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profile.c index 927a2f7456c9a..4f5623fc27c09 100644 --- a/drivers/acpi/platform_profile.c +++ b/drivers/acpi/platform_profile.c @@ -179,6 +179,13 @@ int platform_profile_register(struct platform_profile_handler *pprof) { int err; + /* Sanity check the profile handler */ + if (!pprof || bitmap_empty(pprof->choices, PLATFORM_PROFILE_LAST) || + !pprof->profile_set || !pprof->profile_get) { + pr_err("platform_profile: handler is invalid\n"); + return -EINVAL; + } + mutex_lock(&profile_lock); /* We can only have one active profile */ if (cur_profile) { @@ -186,13 +193,6 @@ int platform_profile_register(struct platform_profile_handler *pprof) return -EEXIST; } - /* Sanity check the profile handler field are set */ - if (!pprof || bitmap_empty(pprof->choices, PLATFORM_PROFILE_LAST) || - !pprof->profile_set || !pprof->profile_get) { - mutex_unlock(&profile_lock); - return -EINVAL; - } - err = sysfs_create_group(acpi_kobj, &platform_profile_group); if (err) { mutex_unlock(&profile_lock); From patchwork Tue Nov 19 17:17:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 13880350 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2053.outbound.protection.outlook.com [40.107.94.53]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0150A1D2B3C; Tue, 19 Nov 2024 17:21:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.94.53 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732036878; cv=fail; b=uERnwgBnXDvkMWXFbWHNxjudG7jzxhkTd906O1/JL8EJ6il7zCXvYOi/Z0DkFUmsGOIiz2xnsW78F0+Aww21O+9WsXRVW2oDZykDXXb+Z4gu/FP1etcOYeqaB5vx+YJ0ICvUnsApYBTgWCmv/lnyUdmIkP90qYnQYznTEYvtG3o= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732036878; c=relaxed/simple; bh=vmgke1hNgi+9jY2YjBI6Ei/XWu/10vuyZ2DT0pBncCY=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=huo83eeQO3AHWkBSCP27DJzAt3/3MOdDD1o7xxjo9JcaBX6ZzLFn0WzzL2OmAzmwEHHcHhPHtwI7g5YrbS1v8KJ6KZM16uveJ6TpcUbbLXoOwmcBFmdmfMmrk8KzPjBAf+nB//D6Ttq9fGHpnjW8V7Eji3MjwHtKUqJtvszGCjM= 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=KUrnSnw5; arc=fail smtp.client-ip=40.107.94.53 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="KUrnSnw5" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=qygAIZ7IyCjqHVLXHTp2vHqSrm0dHvMQDwsNBUsh1sr2+UJDrsXSatPZYFhiUM4eXQpgba6tJEEn8eendGBr3kOiKsOcKZcq4hSzZB3YSBLw15ebP9xpBzSMPnXUjuUA4uSejO9IzhQeYCMXNjpSlzkVwi0it4blenIUiNVHR2yZ8Bw623N2/HcBxvQHgzoJ1YLoN/SXoryLONv5p/iOG46FbBLzTM1M84oL1TO3fxCdUnvKt2w2YobLnYCbEY+DcJvI8qwnKPiB4xTFti+24iUIDByPUxZpXBa8u4Ea+a7bzuJuRVuWEViNyRe5cxwrGkL9Z+gmdAEq3ne05ABqTg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=2JOepbNXpw+MaowhRv9S0+a5ySr6FY/Rm6BniVYK8xY=; b=ot92jfqwm+3DYOWGD7X2+aazbF4sAnHBdhdrCd1LnyCWzi30jIW/iva3ts3CcoGmt5mugDrK++mX35yabGAGODXvwf9xySNIoSR9ZrKmu5sdhuJ6exYZVJ5Sdssjulm0uknuYQZJArrkzPzmGtoG+ax1qB5rd9PypC22o89MbfFTzRyI8CpXt20zjRjIEe6CxyFrrWD8DBpSpXc7DTmm1mq0cZFPdImBriBFvAv1xSIVvFL9cl3bwY3OcJrUcgQjOg0GRaoMhR7MLAaI0ygmsBO09Pi7sWCA4WiccaTZ02LGeVClz5ZXEt3c+Qt22h3IKnkpqyg36GeoaianF8Er8A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.12) smtp.rcpttodomain=redhat.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=2JOepbNXpw+MaowhRv9S0+a5ySr6FY/Rm6BniVYK8xY=; b=KUrnSnw5SlUZPe7Pzz6Tqvyi7wvFgQUdhtyb4x1IZvcYzKxvhfvpJLzFUwrE/nr9M7GXRjd4JL5+Zg4LJ5NSFA7eSxFueBcAl1w0r3bICW54xcsPUlMjPpVFuarwc/BcysJpqPO8s59Z6NB4F4rQV1fWRiYuzqe4GSOtShzebGg= Received: from PH7PR17CA0048.namprd17.prod.outlook.com (2603:10b6:510:323::11) by PH7PR12MB6908.namprd12.prod.outlook.com (2603:10b6:510:1ba::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.23; Tue, 19 Nov 2024 17:21:11 +0000 Received: from CY4PEPF0000EDD6.namprd03.prod.outlook.com (2603:10b6:510:323:cafe::fd) by PH7PR17CA0048.outlook.office365.com (2603:10b6:510:323::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.24 via Frontend Transport; Tue, 19 Nov 2024 17:21:11 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.12) 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.12 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.12; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.12) 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.8158.14 via Frontend Transport; Tue, 19 Nov 2024 17:21:11 +0000 Received: from AUS-P9-MLIMONCI.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Tue, 19 Nov 2024 11:21:08 -0600 From: Mario Limonciello To: Hans de Goede , =?utf-8?q?Ilpo_J=C3=A4rvinen?= CC: "Rafael J . Wysocki" , Len Brown , Maximilian Luz , Lee Chun-Yi , "Shyam Sundar S K" , Corentin Chary , "Luke D . Jones" , Ike Panhc , Henrique de Moraes Holschuh , "Alexis Belmonte" , =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= , Ai Chao , Gergo Koteles , open list , "open list:ACPI" , "open list:MICROSOFT SURFACE PLATFORM PROFILE DRIVER" , "open list:THINKPAD ACPI EXTRAS DRIVER" , Mark Pearson , Matthew Schwartz , Mario Limonciello , Armin Wolf Subject: [PATCH v7 07/22] ACPI: platform_profile: Move matching string for new profile out of mutex Date: Tue, 19 Nov 2024 11:17:24 -0600 Message-ID: <20241119171739.77028-8-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241119171739.77028-1-mario.limonciello@amd.com> References: <20241119171739.77028-1-mario.limonciello@amd.com> Precedence: bulk X-Mailing-List: platform-driver-x86@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_|PH7PR12MB6908:EE_ X-MS-Office365-Filtering-Correlation-Id: 69ac4448-5c7f-4907-7cda-08dd08be903d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|7416014|36860700013|376014|82310400026; X-Microsoft-Antispam-Message-Info: =?utf-8?q?nnQB+wcrnUbYVf3iDvHSIUIqTVC6/KF?= =?utf-8?q?2oI1KmQm3RYE8Cw3cMmWsWlxZZxMTesUAPvG226+rawMq4s3a5xziW3P3ExncRsum?= =?utf-8?q?X6IYmorono2jYzT6wBvAcXfXP/lsSus73Yq5OcdMv3bQkZHienGmHUWU2bfIn9eWp?= =?utf-8?q?woPUdcVzgoq7KAgMuEQP2MR9m1A9y4YbMbFZ3zFPJ7nSDUqWp2PsXvDzJBCE6Ka9d?= =?utf-8?q?EDGRe88ynyPKnp7urvipk9jiuXIZ0dC7pHSfSxXiO+51txdQGZHpI+gDKpkOa46lD?= =?utf-8?q?XtYrdIVWfVPvbVE2JzMKeSFP6FU32EyekJ4McP3O+ywuOacJ0AjYi0QsvT2jWw71F?= =?utf-8?q?rJNVYNmpbD8RKdzm5dRpb64tne/MOGlIUZAA3RJ4dz39gfeN05EieQ+Peq2rx8Nsk?= =?utf-8?q?J18ks2ybJwk73x/MV1mvzGirFatKMPay+3HbNbriBLT1gkUznVEGlqGuiHi2ZsFZR?= =?utf-8?q?gAIQnU/Hq7FafZnk1lpTnsqOFmNBgU9IGqd4qNTmC4EdJWRlETjP5kOY5+BA5nVUX?= =?utf-8?q?5op5pqm/lTCsG3+Xh+YMnhwZjyvLQlblV3v39mVpUD9oZ8PGq8pFZqrohh6kubrbm?= =?utf-8?q?471GiwwMZmngLTXTsvs+UoyeyfwZZ4QMbbLbyMqnjMPGWEaPYJe2Wp7CEyVepRIs5?= =?utf-8?q?qUmdK1u79d9imLxUE2gfNTu/ERXJuuq/3Tbsgy+y/rz60xxcRmxmQJb0fGP+EuqkH?= =?utf-8?q?GRDwGBLDimGefU5ufNXwEngOPm/laY3VNtaHHnBkgyJi/87UfVE1j8Bbxfx+U1Sms?= =?utf-8?q?iD3KDzCX92MldklMMAlD/KMfs1YfVhXuHlzIf/zkFYpuQHngEdrqaakXCSParZVNC?= =?utf-8?q?OBMx2zyyV5pB53eS0/sf052g8mfYMtLYQh8luIQtl9TlWKwKsEeYhB0RWSfGTWWz7?= =?utf-8?q?1f2gwa/ApcDYQ6h4piU2adwHL9fIXQji0quZAbLgDqXcuGTQCqPnpGa1LJZl2cE6+?= =?utf-8?q?cmbWhWiifoEw1v6Qe5BTRaudZwaJtX431NEXaUneASM5Ejv0NdqADXrypzVUGlr8c?= =?utf-8?q?b8u7FvQdM4LvA/sFHqUW5mndFeEA2w36SLbLIE7QZlDXskNvjkeARhgqrpS5ZM6Ym?= =?utf-8?q?1w+xGUV2jiPb9yDxywBidXKod4Lfn9+icsZU462bg59OUib9fDoAfiQfSPsIJ+7mH?= =?utf-8?q?Fm6r6BgDZtjNv+Y44afZWKUpxmSCIWp9w3FhPZjpfnnqrB77vsycfbK5mPy+PHgqw?= =?utf-8?q?IDi9+I2fsSrvQjJ+y87V6Lnplvdkj2Davn0PXFrg8bDnZs28ZNGR0iMQiEiJH6Wvo?= =?utf-8?q?Wj+zVaYZijbzHbIMDblc0cUINCnAWWRKKLTI244eD5+PfINgUH4d1cqWSbw4XnK3d?= =?utf-8?q?5mDablmGr9GKtkgDxwAsHfZaWyS/vtrDFQ=3D=3D?= X-Forefront-Antispam-Report: CIP:165.204.84.12;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:atlvpn-bp.amd.com;CAT:NONE;SFS:(13230040)(1800799024)(7416014)(36860700013)(376014)(82310400026);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Nov 2024 17:21:11.1516 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 69ac4448-5c7f-4907-7cda-08dd08be903d 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.12];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: PH7PR12MB6908 Holding the mutex is not necessary while scanning the string passed into platform_profile_store(). Tested-by: Mark Pearson Reviewed-by: Ilpo Järvinen Reviewed-by: Armin Wolf Signed-off-by: Mario Limonciello --- drivers/acpi/platform_profile.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profile.c index 4f5623fc27c09..45ffd85a71dd5 100644 --- a/drivers/acpi/platform_profile.c +++ b/drivers/acpi/platform_profile.c @@ -83,6 +83,11 @@ static ssize_t platform_profile_store(struct device *dev, { int err, i; + /* Scan for a matching profile */ + i = sysfs_match_string(profile_names, buf); + if (i < 0) + return -EINVAL; + err = mutex_lock_interruptible(&profile_lock); if (err) return err; @@ -92,13 +97,6 @@ static ssize_t platform_profile_store(struct device *dev, return -ENODEV; } - /* Scan for a matching profile */ - i = sysfs_match_string(profile_names, buf); - if (i < 0) { - mutex_unlock(&profile_lock); - return -EINVAL; - } - /* Check that platform supports this profile choice */ if (!test_bit(i, cur_profile->choices)) { mutex_unlock(&profile_lock); From patchwork Tue Nov 19 17:17:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 13880351 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2062.outbound.protection.outlook.com [40.107.92.62]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7DCEE1D27B4; Tue, 19 Nov 2024 17:21:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.92.62 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732036879; cv=fail; b=ZZcJpsHRh8cGXhg0GjsrVFst9q1W8uxU3lizVBkFtNY4rjAg4AD81ux3FfQAte6D2slIVXKN/EwTx9KLJs97tK6oKPfaRTPDDHl4GPuqfx2JK14z18ZpdjJm5gitMb65wuGx1gct1fCSdF0KV/XiG554viUzJqW/Vvx0IH2dHH8= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732036879; c=relaxed/simple; bh=JewyXTxhFRqy6h34+YKrMpsgMeLgKwlZqckAx0I+7ck=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=tDb6+Xi9ci6KFLohI+lYejQJH7VeZnAhjpuHrkzx8Sdeg04z1QVPf35IwjAq4/x1DnSgXhcp8KLsONaHkdLNsjCW/CfiR1TY8swwQeWh/W29d5BzShC3vBAV5Hs7Ph5LVroj6ve7m3lIWLeasw8tzn9o1fr9uvzLvT5Rc7NmBbU= 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=edfjn6gy; arc=fail smtp.client-ip=40.107.92.62 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="edfjn6gy" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=hUikfqQSy70sVX+2YpY4GE8ND3kaigEJ0BeUz+SCeY3zLGxy2CyhoIjEnzNrazNYoBsor4Yxmg9/fNV5frWpTmSOnG5wIXbW+E7G7mJsSST2Lh6YgTofO906SCl1GZrUGsqnzJu2uLuadLsqmbvWmW8qGKikY3PLA2xfTf2nSYPRlUOVSQkEksUJPF2+67b5FFkTryESzkdtKJqOmBWYsLEp6hpRY5l7fqn8p7TJLs++Hl7RYjeKXTFCfKXRU06cpSnc6/1G5OZah/Dyv4xuNocOUXwTzuenuUs5o7tEHoeDoehXaEGINF3FFbA3gAzzvRxuW9n3JhcamBQIWiQwhw== 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=qh4oE13lfHnjG5ST/HYAaapJDcq5n8FwrbiUJmSXToddL5a7BhrNPRQMmEA+wDcnpSaURV3XEb/JWtPr04+BLDX0u6pwF1HY7phH3MqNGV+7jzL1igE+Q83DinTiN6nhTKgtGppRnThlB7FandwBYBG5msyyPaFvX13VtKn3BVuV0ygWPJKmi0ftyGajwpr9m7e2jRf4rzki47oppMBXhrK6R9mkl+43Cc9dxpKJSoQxYGoQLRpAgrtiV7PUAxIEX5oc3fVLROpvYnCLUdwxSaRnZJYp0fvmW9NlPLFP8xBLu9g9HOF288inFOFLxinZq0Oazixg2gvFf507xoEHAA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.12) 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=edfjn6gy6/zYuhhLkGa1y+/NRlN79wzmD1ZoBvyOryd7MbwLTRAy8HSo7slqCIZeXU/rR+4pvO0ERK7P9HTyF4TSo6FlBkhNkKJkrkxM91i1plbElgQMCsjTC6E04UAvCeHM6Gix5jMKOVUWQ9DJxkUmikyig+cvehTq2MA3ceA= Received: from PH7PR17CA0041.namprd17.prod.outlook.com (2603:10b6:510:323::24) by DM6PR12MB4219.namprd12.prod.outlook.com (2603:10b6:5:217::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.24; Tue, 19 Nov 2024 17:21:12 +0000 Received: from CY4PEPF0000EDD6.namprd03.prod.outlook.com (2603:10b6:510:323:cafe::32) by PH7PR17CA0041.outlook.office365.com (2603:10b6:510:323::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.23 via Frontend Transport; Tue, 19 Nov 2024 17:21:12 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.12) 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.12 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.12; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.12) 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.8158.14 via Frontend Transport; Tue, 19 Nov 2024 17:21:11 +0000 Received: from AUS-P9-MLIMONCI.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Tue, 19 Nov 2024 11:21:09 -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 v7 08/22] ACPI: platform_profile: Use guard(mutex) for register/unregister Date: Tue, 19 Nov 2024 11:17:25 -0600 Message-ID: <20241119171739.77028-9-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241119171739.77028-1-mario.limonciello@amd.com> References: <20241119171739.77028-1-mario.limonciello@amd.com> Precedence: bulk X-Mailing-List: platform-driver-x86@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_|DM6PR12MB4219:EE_ X-MS-Office365-Filtering-Correlation-Id: 976cc9e1-d22b-4d36-4ffd-08dd08be90b2 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?THUgSlGfXQLaydNARwUSfYXWnr/WJjC?= =?utf-8?q?1OM427arTHqTj1k03ZJDUlvm7bOiiQq9/4VZgAHsD5PlQUdFkZJFf0xIdQWk0dYsa?= =?utf-8?q?1EyhstFRHI6PUVAPr7sH7riYUqdGR/Q2Re2I/GkYGFhfll9GtmcvuV+wOQOsOUX/W?= =?utf-8?q?dAJt62bF5EbiGifsI1sIciIMfYQeecI1uSpbptZkrP6gsqpRzgPkmjAhmYUxRKc+z?= =?utf-8?q?y35sZG0Vr/vHcVQAAzY9g9Vu3PstUpbJuQwrjDUsIZkC3qHJ0OgUb1wzVqrCq8srZ?= =?utf-8?q?I/OyzMQOnwyhax++ybbyouEprxBAv2Hp03I3eQWdDDG6VMzRith49u38Yffh0XFIx?= =?utf-8?q?pClXsKw+mEpghDxXRdlKHKAQzW+q8euI7QjcN4/7DtXrdcYlvtrngxsD6I3C1XF2y?= =?utf-8?q?BQWHeT9hB7WZUxNmP7KiihFtvdQmPN8U5XtUqKS8r+b+wAhud30J6duVf5XeAmUoU?= =?utf-8?q?DNpNvK42Ge+iW8yTBlBg7EgRkwf1luWfYePicsl6a3zTNfDX6HCAWykf1eYTzdoYl?= =?utf-8?q?Km5uHSj/JS54ZY7nDxMmC6q+z+Vf1K8jC+Px5yD6hZAbe8Av3HrybcyHbPX5iK34Q?= =?utf-8?q?PTjyrzpmA1cJxYDNdgrRo52JIpkCQW42j5GswPFvsH/QkxANynXaGq7MtlHEh0bNr?= =?utf-8?q?3vmGaYmH2tFTGUQz4KDei82zZvLDZkdKM+H/viGe7CkAYUFalc76LUR6MjmkFRbzh?= =?utf-8?q?yRmKMvxaWuPO7PUpEm+9e3xsYt7AMCBiBK6Arpzv7Dv19pC2UsfBP5IU9oUtXjcBI?= =?utf-8?q?F6BCvD8zLnhxLZBrlJG7gLELNHVlwiY5WBrDky/GNiI+dPlLLePk1122AIN/kyqg3?= =?utf-8?q?DZr6a3KpdtM0wHTokvKzHpg+s3/jeQntcnPvayrFaBTpJMmHedtffm2xI9pMrc9jW?= =?utf-8?q?td+mqSa1h92wnLd9Y1antt24ID8JcNCBOdkzFDoFKsoFr2T0xNODZPSdt9xkADDJj?= =?utf-8?q?JdQkB3/QjhKmeusos8QQjEJBrYfplUdom7CXbzF3EAMK7ThpPGs1m9c66o/A9DWjV?= =?utf-8?q?OZ1caU8IXqL3uFsmFa7uP1IPa8JrXMophK1tbq+1RAMqWWs/34MWIhvhoY5eq4iJd?= =?utf-8?q?A/RdX0ke2CA9ZbrTt5cNOo+/C+hxx8eyFRM/7p7DiABKJZTpcMQOuu2ZNIHsiwqgs?= =?utf-8?q?B68Wa4thWhAqfoWpgmgXnS2I2faYML59+HSFQ3BIZNLfv3+ZxNoiwNheD907PW7xq?= =?utf-8?q?JwoO2Niqr6cqfXl8SGdEid2vtHT3admu382aYnMMDEW8iEqolwbQDUdgbtt1puhmi?= =?utf-8?q?6+YsOBNUbeu3IU3PPqcdJdR9YXRtWwqwGBBSj6eRQjF0rqMbzEEni8PnLR1ncNSlD?= =?utf-8?q?Vncaft90bFMQmoLs+Bj8bZblLtC+U6AAQQ=3D=3D?= X-Forefront-Antispam-Report: CIP:165.204.84.12;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:atlvpn-bp.amd.com;CAT:NONE;SFS:(13230040)(376014)(7416014)(1800799024)(36860700013)(82310400026);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Nov 2024 17:21:11.9173 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 976cc9e1-d22b-4d36-4ffd-08dd08be90b2 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.12];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: DM6PR12MB4219 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 Tue Nov 19 17:17:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 13880352 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2051.outbound.protection.outlook.com [40.107.93.51]) (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 AD7311D2B39; Tue, 19 Nov 2024 17:21:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.93.51 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732036881; cv=fail; b=TQjkCfaZQjx/8K1blWiZuL4/OeeVFz5BO7FJ0wxg7s8MuSGNjuIaCGrawEdbCIA6bXQ0NtB1wMq7t49gp2XbMhq4JvktwXlfDK/cV2Uqd9oM2Ot5EOo3+akwp6RyOBOannlm5S3VVR5i2ku0EWkxY4qYCLdrVzk16drN29oixTg= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732036881; c=relaxed/simple; bh=PNUcu1E/82BSOFEj+1FIiCzavwo3sGsVB9Qtl0r0bJE=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=O4MohyV75Qts4gepyzq9C99o4MmC7WN2gqBNapAi9SJhiz7iitLoF/0n2mZV58A6CHg0WPxzX7mVaAS1PA+VPYAHTbzJIMagtHAYUV7olRKjmb+VzxUaapDpf8/ERoBjo1zlmqw010mieTEBOlzB9fmtMd3oPwYynWBsxJPADjI= 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=WjeZsJO7; arc=fail smtp.client-ip=40.107.93.51 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="WjeZsJO7" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=vI3zuUMXXupObyBcpAAgDea/pwfX2jmSvXJJq5c8zo993CqnPaz3gOllyHb1KJ96r/UlErkv54zVreB+vSK8FCwJoyhJI686bEvPX9WoQVgJSrOC8ku1GJQXA5ix30ayrbsX6nNQZJF0ld5JDD7uHX22YgMcPkDby0AZzN3oN35wy87QavNznFNi1J1QDESCygnG2XcMk1b+mE4zlrw24YXZZ9FeI6XWbJsdUdv/d9VchvYWgdZBT/EBKYw406jgs/6vY1lMQKaABPGnvVuJVo39k8LiURkNcQPM0BlrIk6owh4UpwefVPOKCOgFicBLOD32HQq0buJN7XtUbuztZQ== 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=G0B2bHKyeeoDyHW0ot5xsOyAVBTpI6KiIUFRqxBndXA=; b=EhpYZHOnXnGpC7WUxgHa2muIpifR7vP2TyUfFz062HYdO6sXSXOIWDBpCDU1K4rWeicWbDY+TM7sJHtx8bwOcsJa8V5ftTLEMN/lSNJzwKp8EuZNcTsvNM5q+XqWL5odqX1zZZfxs4rrD44DAKqYhqgwFS1ZurPKijXBBw/RSKe/OsqogTPmRzr4KzveD5N5pHDuq8krpehWEgEUgXaieFlnq/Ab2NYLqJGOm1kAvsusxKjyNe5I4iPD8IHMmcRehHladURyuJKWAeeMonmFKuPNvtLv74olrXnd66z+Bp9z2NcxT4Mrn97S0U0uPKkAXmVjmjDAvQXrI6LmOMgDzQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.12) 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=G0B2bHKyeeoDyHW0ot5xsOyAVBTpI6KiIUFRqxBndXA=; b=WjeZsJO70YT5SJ8FK1VxgwPLZoUlKU1ElUkQRDE2HfCSBZJ8cAVOuB4gmJ6mK8rcclXOVCthU+ojJdt1zDXsYTfrvXWdKb85AH3sLBIi+iBZixpfsBX1caIgolrh4H7JcwgUv4RiVYTC4LOFOKo6L2dSzTFZzakQlu1zqHhciuQ= Received: from PH7P220CA0043.NAMP220.PROD.OUTLOOK.COM (2603:10b6:510:32b::12) by DS0PR12MB7994.namprd12.prod.outlook.com (2603:10b6:8:149::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.22; Tue, 19 Nov 2024 17:21:15 +0000 Received: from CY4PEPF0000EDD0.namprd03.prod.outlook.com (2603:10b6:510:32b:cafe::b3) by PH7P220CA0043.outlook.office365.com (2603:10b6:510:32b::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.24 via Frontend Transport; Tue, 19 Nov 2024 17:21:15 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.12) 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.12 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.12; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.12) 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.8158.14 via Frontend Transport; Tue, 19 Nov 2024 17:21:14 +0000 Received: from AUS-P9-MLIMONCI.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Tue, 19 Nov 2024 11:21:11 -0600 From: Mario Limonciello To: Hans de Goede , =?utf-8?q?Ilpo_J=C3=A4rvinen?= CC: "Rafael J . Wysocki" , Len Brown , Maximilian Luz , Lee Chun-Yi , "Shyam Sundar S K" , Corentin Chary , "Luke D . Jones" , Ike Panhc , Henrique de Moraes Holschuh , "Alexis Belmonte" , =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= , Ai Chao , Gergo Koteles , open list , "open list:ACPI" , "open list:MICROSOFT SURFACE PLATFORM PROFILE DRIVER" , "open list:THINKPAD ACPI EXTRAS DRIVER" , Mark Pearson , Matthew Schwartz , Mario Limonciello , Armin Wolf Subject: [PATCH v7 09/22] ACPI: platform_profile: Use `scoped_cond_guard` Date: Tue, 19 Nov 2024 11:17:26 -0600 Message-ID: <20241119171739.77028-10-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241119171739.77028-1-mario.limonciello@amd.com> References: <20241119171739.77028-1-mario.limonciello@amd.com> Precedence: bulk X-Mailing-List: platform-driver-x86@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_|DS0PR12MB7994:EE_ X-MS-Office365-Filtering-Correlation-Id: 3efde092-5d25-4967-1414-08dd08be91fa X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|82310400026|1800799024|36860700013|376014|7416014; X-Microsoft-Antispam-Message-Info: =?utf-8?q?hvHdq/GR4+Z/O5Xu5k0ILforSQk6s1b?= =?utf-8?q?tFJpdjzYr0dVwLO9Xvxy/7ijSYU2CZiRrGHXRwxBLfSlkXpbiOOHhnk4ggVFJh8Pg?= =?utf-8?q?nccKH9+gLKkMjlJwZH/ak4OmGKC2pm3DY+UFwBUFQDITc9FtYLKzSP9tSIsaHpqTN?= =?utf-8?q?OzJL1u3Ye4HNZqru0o9o3v8KRxAXZK9vxoMMUkPWlRml2SV9MkYZ6JrtZWHwoo0iy?= =?utf-8?q?rbN7S5cC1yUJBG4nWwqDtgZLv70s6r+k7HRxdgmgQcRvx9xxD/aNO3ut+0k4ZKPOJ?= =?utf-8?q?OZ1ulUmtJWlOiEMtXdSDm/Cgk9PAuzxv6r/OqszZ5cZCWV5tv7Mj1fWzyOygZ5VB8?= =?utf-8?q?hvMz4rkX7Zj9qvdFhw60uUgFqSvm/0za1XyEok1LEzYzSPH6DjJwW2sPdNhgxeQ32?= =?utf-8?q?R0yPoCqDYXSgOL8lr4e94qSDS1StD1Kob9iESI9+Wd18bCJSkkz/HD/R9KUO9flHQ?= =?utf-8?q?okm6oOiQ+5Hg4au40fYbGBnInhLds5y+CuA6uWun2/uSXXwHhfFd+UeGpncFMWilU?= =?utf-8?q?wASYIyGGAkEeJHAAzOzrQa6eJ3ZhqXTsX0OgfG3LDrDmL+h5tUs+oZTuYY/RPfs27?= =?utf-8?q?BkoQ/TCyc1ft0UzNeLKB90s0H9wa//49YNSd10xkRGX2Vnrx5Nmjh0CfbZ/QP1TAE?= =?utf-8?q?C5el1A9SOe0Nk2rPTsQOpRhOU+rAcUUJennQTT8cR5QuNyyskYHCCmDVL6+cy6R8g?= =?utf-8?q?HknjOC3XsG3hwBP+9nU4Md9ecQbLCGYaFs1HHXTimVxU/U2Ww2ev8XSSKLqcKH1pT?= =?utf-8?q?Y9wNeZM7YpN9omHLfJPHvqTcsYGjFRoMwn4jAa3SMYroSPefR1hV1KwvshxMnxV01?= =?utf-8?q?pV72Mq0qGhEEhhKApUNkisGlXmbtle4kE7KbeBMuurOmkmv53isdoINyJf3x41U0W?= =?utf-8?q?flnaVn6W9uNWTiBSzDO+fCELtIPQoYJNEjUvW6p9AWcWPyCZUOwaJylFC+GU/Ufh0?= =?utf-8?q?Fd/ySHp9GMRrN4A8ycXl66GrLJus+Xb2QbiTNMFiQGy5HILm0mdqnGFbaz5z2L8de?= =?utf-8?q?oBNY5nKkIC+OD/CK/hPzp143GexsBYyRKSk1s0KPaB+gtGfmsGZAleMk0vdFLNWRt?= =?utf-8?q?H1d0YRyJm0T+NDzDAgTX0RSLbL7ZzzPl9UiBRN0rtXDrWWKc531MvOaRbOK4vXBGI?= =?utf-8?q?bl2y+J5awFYhwoCdCH8iW19cXs2kUvMf+aQCjxAYacO0wb9ofMfn2qxVexui9YT+C?= =?utf-8?q?uZLB7yWR1sK2saeBVII+TF8GR8N7NryvuUYdzZVsqpdYRW7BE+rdO7CrOEowsTIFB?= =?utf-8?q?m3AooBuRH0xU4rTWTcEI81mVKYxkXyrmU/hr7zYC2/2R4qBZ7/SFRql7c5kLWTBKd?= =?utf-8?q?q0wqxA8yMw3HdZboLq3ZNjckEVPEZf3x/w=3D=3D?= X-Forefront-Antispam-Report: CIP:165.204.84.12;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:atlvpn-bp.amd.com;CAT:NONE;SFS:(13230040)(82310400026)(1800799024)(36860700013)(376014)(7416014);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Nov 2024 17:21:14.0341 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 3efde092-5d25-4967-1414-08dd08be91fa 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.12];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: DS0PR12MB7994 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 --- v7: * Add Armin's tag --- 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 Tue Nov 19 17:17:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 13880353 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2047.outbound.protection.outlook.com [40.107.244.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 1A77D1D4333; Tue, 19 Nov 2024 17:21:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.244.47 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732036884; cv=fail; b=b9UgT1LZAmDa8grCv/FW7NnDkFr9Gt7uupKQOE1EpK4QXa1NeOpltd/r89wfEWD/rkc3i2dBObjaFJKsZlndcB/OK1TX45aCCkdnEiYlqQ9iHG277ml0jjDmDP7XkFTceBFh1JVLmtfa597HUTCDBxwpW1j1aUZAw48BeQ89TwU= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732036884; c=relaxed/simple; bh=wBQDnDbMvL1S6Enbnu3r7J+KMcdaAx15fZAfucZABb4=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=umuDAJkoDNPRwDhVRdJO2o8PhrMezLzkzP2IlwKJlNOqAoXN/oXJBgG6JvecDU1epKMFqdfvtWr/1oPHGvnR7I1L8PzRnzwnA+NvhFTJxo1YxIUuBeE730hOoR4PSJjF+WKhP6NRPSAMpEv1Rahd6GwPNvqjrBEByxTozlMGQoM= 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=KqVVD9xL; arc=fail smtp.client-ip=40.107.244.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="KqVVD9xL" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=bnrcqd9EkW5EWBjMweGi7Byig0ANUSrToCtmYZmMax6xfLx8QcJZJo1RPTk+xJft4+cO0cDWrUnxGYfdS5SFgZhqz1eYNmewQHCpfJZ8EC+nUzwaWPVkOOlygjOqyJr8c2rrzeTyTl9lWyYeHWSFfg/mNOHbm4Y0mcG6xBWLDWBbWXmXnMlidvvdDgtq1R1Ao0r/BH095/+E7jbBbCVrPopStodQ0FSiXoqeWDI78jZnOKQckj4gDjJxSROyyvK629zvUAREA+OZmn79QbXBZswybhoy1eH5haAtETHyrgw1nnlX9/IWY17zWF/JrXHPRmYxfaFfIAKh2Wwf4Mk2yw== 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=K8DYtwULlzPhvvL2ryCL3gCt0hyAcSnLlGYhblzyqNY=; b=Zfk22G2iKsrA/y38+U1j9V8TDGY5ihLXdz/9RTfBgjdQtKxAwLmq38BOAuzIjtjEXI0hhChJs279qOP8ZfQkQSKuZgRohRdgY9qwsf7eWiNrrTe6BDC9HW/uhbSz8v0lcwbG4QEIknQBPfg9OsygoqPQvqSh1a++ynjzYcIdFROBZydf8fxYPNoa7LHGaZEzaMFbmhzQufg2aCUumqO9Nqinpbg+QNy8oVldHMIqTJY86Uj/n/5yiQ0JI68/sKdpCvDlaqjz3Jl1IWOer+w9b8F6aggk1e3Loq9q8GZVhOrOxealF5q5DTs5YqWPx68g+gj99VRLex7V62osv6NHrQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.12) 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=K8DYtwULlzPhvvL2ryCL3gCt0hyAcSnLlGYhblzyqNY=; b=KqVVD9xLQUjWcypc3wAKeu7XLZijtkDj66chsuEM4Iz5gE51kCnr2hF7hXWt0gA6MFpLL5QtvGqVch3QgM8dT1AyYsSSxlwwL9lkKX0QeqzzcHQwEO3GiF3JbmNl/x9vRSbc7HHXijVpYeNngXiPmJEcUoh1s+clvCjxzTAEYtk= Received: from PH7P220CA0051.NAMP220.PROD.OUTLOOK.COM (2603:10b6:510:32b::13) by MW6PR12MB9019.namprd12.prod.outlook.com (2603:10b6:303:23f::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.22; Tue, 19 Nov 2024 17:21:18 +0000 Received: from CY4PEPF0000EDD0.namprd03.prod.outlook.com (2603:10b6:510:32b:cafe::8a) by PH7P220CA0051.outlook.office365.com (2603:10b6:510:32b::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.23 via Frontend Transport; Tue, 19 Nov 2024 17:21:15 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.12) 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.12 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.12; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.12) 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.8158.14 via Frontend Transport; Tue, 19 Nov 2024 17:21:15 +0000 Received: from AUS-P9-MLIMONCI.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Tue, 19 Nov 2024 11:21:13 -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 v7 10/22] ACPI: platform_profile: Create class for ACPI platform profile Date: Tue, 19 Nov 2024 11:17:27 -0600 Message-ID: <20241119171739.77028-11-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241119171739.77028-1-mario.limonciello@amd.com> References: <20241119171739.77028-1-mario.limonciello@amd.com> Precedence: bulk X-Mailing-List: platform-driver-x86@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_|MW6PR12MB9019:EE_ X-MS-Office365-Filtering-Correlation-Id: ed8b494f-42ef-47ee-a6cc-08dd08be92ef X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|376014|82310400026|1800799024|36860700013; X-Microsoft-Antispam-Message-Info: wlgWGg6OeOf3IA7LIOZ6Q+FzSj1hPmCenMoP1ZpKu3PtGOQGhvGyPDgxuYFnsk4T57+G0MKRfGmrOx6q+NkbaaREjbxNKYTdadF+hapNm3Po8Woe/dOZlTPinWpmenVXVURo9/kjXv7vrUw/U9zwRwnBEk5lRpMS8tUQXDdvF5rlC9p/tlmgulogdCpiGR7nW5qg6O8eR0eMrwALhL3YVkjjAylJWG9o5OOWzVVbcK3Y0Q26dOZZ6iH6RaDQbG5Sn9CA0x5Idp1JS4UPxsJCiaA9jFdsnJ0Br3CYRX9F1iD57iRcRznhOnltmNwyCMHQNps6Yrg1++qk34X87/uNV0XZaCAmsj0R/rs9FWJvc0miCuX0DLGVCtcXv3FhMC+12cT0kPWdiXtGLFjvftk0QrZLzqMZrELTVXn8DuqwjQ43a2JDakiIBjKCtJuQwCCWoN6TH6TExC0Z96f1g7Msd71JcuXd6Pc4+96ZhUGZ38Tu5BIB6XBzbHfs3tkzjoD8DUrIK1dRNlP3jm3cbDoe+Mz/ahwaZingbmIrRPs8lh8OBzsKUjtRSh6c/mkBte657PRMgFFJHh6UZRcl8aUXydBllMB4k40bDpjWmGwbiepxMJGT2H8cp9Ihrc1KGIKd8TesztkyTWKqMQgsB8QGYc/5t10GFfINt/YZunoCFN0r0MDTZ42eIZ1/UqP75VdmD/c/y3jEwNH17lLdEimNPHTNU6kCPn1PaUmVvsn5lz/ldrrP/0Eb07tx+XT1VJBHrpQtIMm4Rz6qgHBSrQ6IFaOe8vtUBrIyA2/nDQ5lHwuQ0G3G8TLA7Kqx5K8t08erPgvpgRUlIBCj8TRC+CDz0zSEJFdQmcACBUON4YHGbD4EKBUoSr+QqLJEc8VQcaC/1+unTXHMvbT+JMFrb5pUFZLvmXh959W3vbLUNZCBUaFitV47lO4Wy2BlH6HPKThVhkzptK2y8EUsPZ5udllL6ubXAe1HaHCCYe45mvlNibURdzeg00U+eJ2ogfXmkQwvFAYJs6tzHWp9QIC2xumm16/27Z/Bx1whXn/MsNmc2OIjwWjzhEaZOYkARu1TLaER7S9kOVcw9fVTOpP85gDVQuK8EMu3RXvDCXN3T68Q1TnDtCWudHut0uaR4tZlW+qg0UTZkG25aTIPifFH6QQH1vB98rWT6s+xkRpG09fmFdtGPUV3D7txMNujYY0/Met6/jN8YOot0SpGQbvUKDwsinJyvD7SkYE3IjE9AQBUQoAphPcUQ1F9K5MeLU7fMbRGdd609zXY5VqvxgxoRwvNAe5SJCc0mq4lHCB4bvYvYidOwrujKKoQ07ukNmDKGObpQtZpLOYq4RTOOq45qGpzOonzrOEfRL82AKEBIiFjeXTDW+Jj7SXggeKZxNedji9indnrQuyqZ+HC2BhkX2cKzw== X-Forefront-Antispam-Report: CIP:165.204.84.12;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:atlvpn-bp.amd.com;CAT:NONE;SFS:(13230040)(7416014)(376014)(82310400026)(1800799024)(36860700013);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Nov 2024 17:21:15.6435 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ed8b494f-42ef-47ee-a6cc-08dd08be92ef 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.12];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: MW6PR12MB9019 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 Signed-off-by: Mario Limonciello --- v7: * Whitespace * Add tag * Drop class_is_registered() check * Remove legacy sysfs before class v6: * Catch failures in ida_alloc * Use 4th argument of device_create instead of dev_set_drvdata() * Squash unregister patch * Add module init callback * Move class creation to module init * Update visibility based on group presence * Add back parent device v5: * Use ida instead of idr * Use device_unregister instead of device_destroy() * MKDEV (0, 0) --- drivers/acpi/platform_profile.c | 86 ++++++++++++++++++++++++++++++-- include/linux/platform_profile.h | 2 + 2 files changed, 83 insertions(+), 5 deletions(-) diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profile.c index 32affb75e782d..3524a2b4618ed 100644 --- a/drivers/acpi/platform_profile.c +++ b/drivers/acpi/platform_profile.c @@ -5,6 +5,7 @@ #include #include #include +#include #include #include #include @@ -22,6 +23,12 @@ static const char * const profile_names[] = { }; static_assert(ARRAY_SIZE(profile_names) == PLATFORM_PROFILE_LAST); +static DEFINE_IDA(platform_profile_ida); + +static const struct class platform_profile_class = { + .name = "platform-profile", +}; + static ssize_t platform_profile_choices_show(struct device *dev, struct device_attribute *attr, char *buf) @@ -105,8 +112,25 @@ static struct attribute *platform_profile_attrs[] = { NULL }; +static int profile_class_registered(struct device *dev, const void *data) +{ + return 1; +} + +static umode_t profile_class_is_visible(struct kobject *kobj, struct attribute *attr, int idx) +{ + if (!class_find_device(&platform_profile_class, NULL, NULL, profile_class_registered)) + return 0; + if (attr == &dev_attr_platform_profile_choices.attr) + return 0444; + if (attr == &dev_attr_platform_profile.attr) + return 0644; + return 0; +} + static const struct attribute_group platform_profile_group = { - .attrs = platform_profile_attrs + .attrs = platform_profile_attrs, + .is_visible = profile_class_is_visible, }; void platform_profile_notify(struct platform_profile_handler *pprof) @@ -164,25 +188,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 Tue Nov 19 17:17:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 13880356 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2059.outbound.protection.outlook.com [40.107.92.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 4917F1D5CCD; Tue, 19 Nov 2024 17:21:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.92.59 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732036886; cv=fail; b=fUEd/IEvFVqslOEY0MGppp7ZMCkCW2bFeBeaH1tH8x9scT4rQTvj/unB3ugCpncJwKsdIqsTtth/+0PFtEU9Q7EQ36NmR8FVUwWCjkG57PXYu5fGVnSwGglUtTN4ePoZDlJQoQ7x8PtalBVsQYq963RotJe/HV5eUMovqKq4R7g= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732036886; c=relaxed/simple; bh=o0zMirAhO4Tp1P1JyMZIkB2N+NyjUc4RA+EWuEMlWKk=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=HyHZjmGUpG+JD6JMdUm5apDm0Z7kYUyr9E/rBgmmkYius0GYT1RAW4lzN4fW02R4sboPrv6jZONXDZWkbTz+XDUX1PoOPMojL9biqCJu7f40SlaAXyvJrKIj4kNb7ssPW4D0DDIri2XNxNOT4G4dkeX54321xqbRlc5BUqPKw1Q= 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=fF/2LNgx; arc=fail smtp.client-ip=40.107.92.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="fF/2LNgx" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=WSVmJzIYANTgFmIIxmcZmxZ3rXmBw4cFrwIyii0cFkwQ0E4AG5euSsV3YCzqDnHPPzCGPedk8Ej0aZCKd9/uenQ0tHjag/K77aq6mV0GLQVw3GYyMW/REPg3YYbRyZVAEM8KB/9Zt5OIEyIz9szSZic2Sp6jFSUUU9HqUaugsPCDfWNbbJB+N2nlvvkcvKFT0jjSf1OxHyYP/y0kbsGXGDlrQaUi1qnnb2NeAByFklJPOaxodc50S0qst/NylzWL/ZYRSp06bqUq8xE4pdc6HceapyGFfhvJP6ES5qk03u4gHnidwyXLXrm89qMJ7r4SWYORzZ1+gQEmsoZX3Qyoew== 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=cVfARja3a+pd0OusscE7B/9Ps+rg79WGoSSVHrXd6dI=; b=WO6W6Fm4/gHnT8vlMQEKx7Kj8U0nXQR+pWtzJwHIv9HbY/2mBc6nNvs+mOgw4wcBadIDzjUK5HbTcfwpc8NLtYCB0egxGepe0VFUxRZdhWhzuG2Ay9LKt7wT98ZHc7GL3mxhvcxaPJ2WScAWbakDBMHMYJPRHkCCSj1PFmyKAE8ivkrh5pKe8/SXXrDVLBgCa+YOYpsniExuStHnAkxq+ULu0bWqFZfSe/tngw7G/4H/qnAGIwl0Q1Vvpe5C/uF0ZbFuKFdsZBQ2E7AM5m+y1RgpxAhZ/bUF/D+JA3q9RjFH2F03Ka8Dqwtt0Dyd75L6ONW3DwbEgwOdXC2+FKV4vQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.12) 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=cVfARja3a+pd0OusscE7B/9Ps+rg79WGoSSVHrXd6dI=; b=fF/2LNgxy8OzmQ2uf7FFmDhheSgHvFvSDwEY1nk8std7HdE+fbve6zaGns5HbXtt4/plpeX0be5HGOwmX1UW59vXKcsOvbRlhrU2IDKgDksaJjROx89bLisf1CP83T7UxOxD45Jx/leHaKxrQJQQPeXfu2b0tnxuEs7Lsa/GJTI= Received: from PH7P220CA0058.NAMP220.PROD.OUTLOOK.COM (2603:10b6:510:32b::9) by BY5PR12MB4260.namprd12.prod.outlook.com (2603:10b6:a03:206::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.24; Tue, 19 Nov 2024 17:21:19 +0000 Received: from CY4PEPF0000EDD0.namprd03.prod.outlook.com (2603:10b6:510:32b:cafe::95) by PH7P220CA0058.outlook.office365.com (2603:10b6:510:32b::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.23 via Frontend Transport; Tue, 19 Nov 2024 17:21:18 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.12) 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.12 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.12; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.12) 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.8158.14 via Frontend Transport; Tue, 19 Nov 2024 17:21:18 +0000 Received: from AUS-P9-MLIMONCI.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Tue, 19 Nov 2024 11:21:15 -0600 From: Mario Limonciello To: Hans de Goede , =?utf-8?q?Ilpo_J=C3=A4rvinen?= CC: "Rafael J . Wysocki" , Len Brown , Maximilian Luz , Lee Chun-Yi , "Shyam Sundar S K" , Corentin Chary , "Luke D . Jones" , Ike Panhc , Henrique de Moraes Holschuh , "Alexis Belmonte" , =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= , Ai Chao , Gergo Koteles , open list , "open list:ACPI" , "open list:MICROSOFT SURFACE PLATFORM PROFILE DRIVER" , "open list:THINKPAD ACPI EXTRAS DRIVER" , Mark Pearson , Matthew Schwartz , Mario Limonciello Subject: [PATCH v7 11/22] ACPI: platform_profile: Add name attribute to class interface Date: Tue, 19 Nov 2024 11:17:28 -0600 Message-ID: <20241119171739.77028-12-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241119171739.77028-1-mario.limonciello@amd.com> References: <20241119171739.77028-1-mario.limonciello@amd.com> Precedence: bulk X-Mailing-List: platform-driver-x86@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_|BY5PR12MB4260:EE_ X-MS-Office365-Filtering-Correlation-Id: def880eb-132d-4da0-ce66-08dd08be949c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|376014|1800799024|82310400026|36860700013; X-Microsoft-Antispam-Message-Info: HgtyRz/wEdCIlHu6cEAqePB4oeIxm6pXqh8B9t6pX9Dosobo71uRnXOWIN+jlZzq83GjN9w05iaVGMRJ9GXvnjTlnuMEYhC+Rv01AgoS2RJPSfPhjdgxDqPE6WYp3xm1cXH1inVYUUz3QYfjQbZRNEsbNWX0h9AfSH1Bu3F6uzQ0HJBN2Amd9ycgzLXABDtuntupEIPXp/fQ06z6lvimR9PB1zdRp1CyjjrPMwIixnUGaNdXh2uW7PQX/ahAHEQObvYaWDyQbl0VoMab8IAGMjTPDTKEXn5FjK4Fk0Ap3+EgLXMgLSDtFdUJkbFbRFjFSwMfoVpEzAPxPWrYbFH163XK/lVAxvTXw8IhporoZRJxfnq1uk6EEjs9ChC+zvWuiyh4WtP6t32Qpkgjc6zhpOZJXxGlieQ7Zcz8mKkE9SJAoLr8V/66r4E6kPp//hZsUgGJXJAjFfs1ktW1Kf6e9LCzMiezByqfMqKMxARHFV4rnKWQ+synr2BzTgmvpKlgE5IQTUytIL5JnyStcUUPQmJbxO57SI2zS8uBoHMaY9KP+32TAvNhHm9AW3NGIsimxISdKKxIIQ+60Tw47pirunCBSlBIN/Zqg2NCOkq7+D9fTz2LxbFs4Xp67AVmpEGZTFRz2Rw8hV7Vua+KqnZzT0BlDmGfO2dl55GsW8MtXFYWM1YcYKGdnYJIU5/83IadFDeGvnp2qg0WBABkpFqxwg/eo3PXrTSyCWIyo1JWpDQs+LPv7N0O5x7KN29XKTAFQmDoapca9BaYK8uFBX0BchxaEHKIK/tpuF5L+5m3aNxnMAynTSe/7BmDj+COcNOhO8XpQu7DHjS0JmtzJQtvbMiDQryMLopPJl2f7yKNVxjFxnw6hqxT8qSyamJQ6wYKRJjn5oyJHIQ0mrfuul/dZJqAqbVVET2OdsRJ1+BeFrSQcA+xJuiHUmv9vcHmLXgY9VDb7t1z/wbPwyYy7mvGi8Cv10rzN8fvtTWmb+fccZ4h2ypGZ2w4/LiUSGvz0Y+3PlwR+VFLlfslPTj72iT8LiFWpdkc+9sZinXiN5UpZYW/+OjytjkQMIL6M8t4NGNoEIPQv0DQ/GuYwHxkFudgkv4jpjOvCigEYXEcUti3iiFfHZu3SKE4nzc/V0s1IrKb0O4e1Dh0pV1Zol27ocZFoSVvXK1b9c2DdaAfEkGIGKfcIrdSYkSmy9a1+5qhPNKVe+38pEBefxh6mv6sIwganpi9QOfPMSEDfF+JLbEt+WLgYFu2EYtQjD89RSGzouYMkyKy9R2kOYdqWr6Ac6yQ6NpVjF2/2ckKqjBV83Qq3yL7Cv9EAANO20z5GtaLCODGdRKt0zgMO9/+CyWZSN6oIAyo8JR0QhfVx5XQe/UVAWf7lE7G2smRs6uf9KLwOEB4si5ntGkH9oRAqTrAuqFW+Q== X-Forefront-Antispam-Report: CIP:165.204.84.12;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:atlvpn-bp.amd.com;CAT:NONE;SFS:(13230040)(7416014)(376014)(1800799024)(82310400026)(36860700013);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Nov 2024 17:21:18.4872 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: def880eb-132d-4da0-ce66-08dd08be949c 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.12];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: BY5PR12MB4260 The name attribute shows the name of the associated platform profile handler. Tested-by: Mark Pearson Signed-off-by: Mario Limonciello Reviewed-by: Ilpo Järvinen --- v7: * Drop locking --- drivers/acpi/platform_profile.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profile.c index 3524a2b4618ed..a9d7ec3c85844 100644 --- a/drivers/acpi/platform_profile.c +++ b/drivers/acpi/platform_profile.c @@ -25,8 +25,32 @@ 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 Tue Nov 19 17:17:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 13880354 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2049.outbound.protection.outlook.com [40.107.92.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 2634E1D5148; Tue, 19 Nov 2024 17:21:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.92.49 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732036885; cv=fail; b=RP7PiWxz3xU8R+4abByMzWU3Va19ejT7UIuiY+c9qn1ZXUJMcURsxcMMUEeQSWMlWJtQcgEGUQ7kf+NwvxNJNjLIiGOcvSQUfZBDWSBxf7bwXZX1bqPUgK9BcTfgUv/bsyeI+PDBswlwhO9d5ocm0q+27ArcCd5Xt/4vdMvgBrc= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732036885; c=relaxed/simple; bh=ksb5hm91eMP5xMbwuBZ/g4WF0yYqTIq9mdxdxNxsttk=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=nNYvQiagiRnDtenGLwv0mcLLqeJu5fMf4K3jtRmhZV30nyXhNuksyZUDhgCjicnY7cis4/YYoaxRGNU72/PovOmkQ7QA447MgAkK3Uga079JtPIWmpH+frIs6YhQ9FviEi8S0ycJ96bzfhFNuUQcjqfrlXdopEpyfvSkh8DofbQ= 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=wwKZUGXd; arc=fail smtp.client-ip=40.107.92.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="wwKZUGXd" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=x/C65OqjAzI8ak88f8Ufu6PfhzDR7a+VKXz0DPKd8pBA1voo/l+B+29PLDrM9D4m7shKMZTIIcHhBWAcVsgPmYwTswA/wQaJV5s/ocbUP4r36OKK7prVfHhO1FpSa3clDDYM74nCW+9hlicy5JWDbJRyYaYvz7Ne4L6gFfLMraof3eWMOYhJ+hjHRgjfh+SNcbJ76KDWG5HDcT1KzP7NpSKsLGsCBBDY5r7vuCGawk3b3VqHjoX20BjhWSMaWuqzAZX6IbqAjlHQK9hWVAJhFtOcpQjhapMjJDoSzzvk6UZMdx3zheqx9CZI3zuXgqgsoxZV5B81VoyRM4A38Ke3bg== 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=a6CFc0+6d4W6sohcGl253Idmf7tHdDPMClf+D9DQnQ0=; b=vxobHHC1dsjctDFjyiaNHcjZDT20ouYqddpIBcfslvFfqE8ry2mElSkccOhN60SG2nE7T6nZe/S2m0uEXvhRQKr77pKk+gnzonGrezext3YNK4rug1VUm2BmT5oIBmqffBlRqJ5vZ7WqkGcMrCPPS2EmOfXb54/SE+xhVuANLGM8nRnGDuz/pJEm9Z5A8Xi8/Xn8lKWiCVlD9+GRXx+/lvsIM9c9KEyRFkVHjcIe5T4adt3iRVuRaG3CXZUo/XtUo7viDBwPJeV1NiH5GVLvb34FRrN8BG93mbqlIom/iLB4WzudnKQLaasDJbck/PnXnuSp3mHsZoTv9rJv3mj1gQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.12) 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=a6CFc0+6d4W6sohcGl253Idmf7tHdDPMClf+D9DQnQ0=; b=wwKZUGXd64EFjHOF0QWURh+V7oaUADvz5TQ3Cibbo6AC8ZwzGmeM6Hox3OE39v1665BtVVnk/awP00VEXin/WzaXD5r/MLjBC3+nFbUyqx0cTxUe0GYqpaG2eJ0/+XNRvThofV/yOnEEi06d6RspaQZNB+nAycB0DoZXfFxjuUw= Received: from PH7P220CA0032.NAMP220.PROD.OUTLOOK.COM (2603:10b6:510:32b::31) by SA3PR12MB7829.namprd12.prod.outlook.com (2603:10b6:806:316::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.23; Tue, 19 Nov 2024 17:21:19 +0000 Received: from CY4PEPF0000EDD0.namprd03.prod.outlook.com (2603:10b6:510:32b:cafe::3b) by PH7P220CA0032.outlook.office365.com (2603:10b6:510:32b::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.24 via Frontend Transport; Tue, 19 Nov 2024 17:21:19 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.12) 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.12 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.12; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.12) 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.8158.14 via Frontend Transport; Tue, 19 Nov 2024 17:21:19 +0000 Received: from AUS-P9-MLIMONCI.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Tue, 19 Nov 2024 11:21:16 -0600 From: Mario Limonciello To: Hans de Goede , =?utf-8?q?Ilpo_J=C3=A4rvinen?= CC: "Rafael J . Wysocki" , Len Brown , Maximilian Luz , Lee Chun-Yi , "Shyam Sundar S K" , Corentin Chary , "Luke D . Jones" , Ike Panhc , Henrique de Moraes Holschuh , "Alexis Belmonte" , =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= , Ai Chao , Gergo Koteles , open list , "open list:ACPI" , "open list:MICROSOFT SURFACE PLATFORM PROFILE DRIVER" , "open list:THINKPAD ACPI EXTRAS DRIVER" , Mark Pearson , Matthew Schwartz , Mario Limonciello Subject: [PATCH v7 12/22] ACPI: platform_profile: Add choices attribute for class interface Date: Tue, 19 Nov 2024 11:17:29 -0600 Message-ID: <20241119171739.77028-13-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241119171739.77028-1-mario.limonciello@amd.com> References: <20241119171739.77028-1-mario.limonciello@amd.com> Precedence: bulk X-Mailing-List: platform-driver-x86@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_|SA3PR12MB7829:EE_ X-MS-Office365-Filtering-Correlation-Id: 8b33ff0b-0f57-4363-7948-08dd08be9529 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|82310400026|1800799024|7416014|376014|36860700013; X-Microsoft-Antispam-Message-Info: 5jXSw30kV1770SIMDhc+03bzYiPyGBTJ0dZb9VqsrDErIWCEYFfX6mzEAK8PVoCAXZSOlEK2+82Fjc76qTT9kmTfHhHPsbwhhSGQEPPu3uPpZAQEbSTPA0/ItlsD4z4lf/ahogZZdzQ5hKP5FWYBCecGP1qtZfe/wzIgvS/+unTyS+dOKtJ3dI7kX4DxSL1EMkkpJDnQh+uuCI/pHZENzpezDtiqSwFwtXMWP9TRxGEW7kxcc+xSGbtipK09BtyFl3W43Z7N9KrLbdeJwhIdIolKn364KJXvy5d92F+il3cBbyxkC9/o0QpJoHIJJgf6+CtLssTrxjH7mu3gXQS5uw7+feHzVYqB3oaETi1zRbhXjlZNju6keCNW9rWcjhtOmmXwnYhjWnSfdCXNIk4COzVr4YITeHJ2SskEhiqt0zhkvu8d276TQAO3VaMnIF9pIbJDBSEGk5tquzpyjcNGuklf7VNYwR84S1fim4TY34HeqrXSFvzwkrgRYLFsOzAQ28Dm9s/LvLxGPH6aWm/AJu0X/7N6n9uEoe9pEzVY5xxIlozy9CKahdtpsP7G1EPIcnKoPUeHuo4wAB9QsX52bfo5jyL+C8wSk5p0dDrK6PQvHSRRNQH5Eh+rrqnBHcBsdYX9CQkmsdIYyHfMCQnWPRCnIgPtnafwauZXFJckB19BS7ExGBLbmXxmZQ3R1er3/rDS0Qap8VdpqckhqEPvs9Mr/OogZayhQz9fXEDM6K8qDCc4s1hiixskZiKL1FA+tpdDPjItezK9iHjeiBFyW5BDvEiE9ZnFhBXCtikbsL0pQsD4smr64Bsf7DD0YNnbIposkVOu1u+hK4XpDPEGej2aVxSWmBYXPF2SDZzgTzcYyY0tG0KPWO/eCvEivzkhWrBsgVvYO6+Au+mr9B1r7okIqBoDNDELgJX+sI2kF987ITbImOqkznOeS7GrIXKdBk9aeBnPFZg6/IMQHc+EwHGzNsxVEikPUN540aMFPSd60ljkorCBE3deiSGUvhFBzTiyveOMLG23P7RvDQs+S2PMCxqZexKVqv+faR075NX2mns3duKyQr3tTViEMHLtktSywFMmQWpRvnQ5w0g/+Nv6vL2iO/ochx7iPirM3usMYZPX7zk+3EaQpONnoiTPw5cQ0Nf8bAU7tFirsraPWH1EGf9+kVf3G927oeXdoqCTn2rfOXhz1+i9BAkMZm77S0MtYvgXH57F66Pq8TjVwxFFV6PE7br+mSqsR6pIsBExkMRGJfk4p8D1Cgu+qRt1Ugk4hgTiVfAdvSGOU6IDp6i18UDKdc+2Inp9y/IcXk0kF/EbLrssC22+8ZoXVmIcuHqh3VoOfTirGRS6NABmbDIEb18gZYKAM4pwkplSmVhkNa2txCMIAsdXHNNMlK2jt5B2p5Mi3NVN7Rfk+g/R+A== X-Forefront-Antispam-Report: CIP:165.204.84.12;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:atlvpn-bp.amd.com;CAT:NONE;SFS:(13230040)(82310400026)(1800799024)(7416014)(376014)(36860700013);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Nov 2024 17:21:19.3622 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 8b33ff0b-0f57-4363-7948-08dd08be9529 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.12];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: SA3PR12MB7829 The `choices` file will show all possible choices that a given platform profile handler can support. Tested-by: Mark Pearson Signed-off-by: Mario Limonciello Reviewed-by: Ilpo Järvinen --- v7: * Drop locking v5: * Fix kdoc * Add tag * Fix whitespace * Adjust mutex use --- drivers/acpi/platform_profile.c | 39 +++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profile.c index a9d7ec3c85844..9d6ead043994c 100644 --- a/drivers/acpi/platform_profile.c +++ b/drivers/acpi/platform_profile.c @@ -25,6 +25,27 @@ static_assert(ARRAY_SIZE(profile_names) == PLATFORM_PROFILE_LAST); static DEFINE_IDA(platform_profile_ida); +/** + * _commmon_choices_show - Show the available profile choices + * @choices: The available profile choices + * @buf: The buffer to write to + * Return: The number of bytes written + */ +static ssize_t _commmon_choices_show(unsigned long *choices, char *buf) +{ + int i, len = 0; + + for_each_set_bit(i, choices, PLATFORM_PROFILE_LAST) { + if (len == 0) + len += sysfs_emit_at(buf, len, "%s", profile_names[i]); + else + len += sysfs_emit_at(buf, len, " %s", profile_names[i]); + } + len += sysfs_emit_at(buf, len, "\n"); + + return len; +} + /** * name_show - Show the name of the profile handler * @dev: The device @@ -41,9 +62,27 @@ static ssize_t name_show(struct device *dev, return sysfs_emit(buf, "%s\n", handler->name); } +/** + * choices_show - Show the available profile choices + * @dev: The device + * @attr: The attribute + * @buf: The buffer to write to + */ +static ssize_t choices_show(struct device *dev, + struct device_attribute *attr, + char *buf) +{ + struct platform_profile_handler *handler = dev_get_drvdata(dev); + + return _commmon_choices_show(handler->choices, buf); +} + static DEVICE_ATTR_RO(name); +static DEVICE_ATTR_RO(choices); + static struct attribute *profile_attrs[] = { &dev_attr_name.attr, + &dev_attr_choices.attr, NULL }; ATTRIBUTE_GROUPS(profile); From patchwork Tue Nov 19 17:17:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 13880355 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2088.outbound.protection.outlook.com [40.107.244.88]) (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 BC2751D5171; Tue, 19 Nov 2024 17:21:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.244.88 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732036885; cv=fail; b=PpEcYveasg9/eRpZxZtt/jo5LTVUunfW7mihMiZlg4MbSAfrjcYfnQxDnuzvld7s1dE0JL04aViPxh6Agg4I15sDhFycqbj2S+v1X9wPNeKKcHpz+MH9HjrRg49aSflwukj42V/K7p+jVusGEjbOXHE2cg7wD5icSF3eAnRMwDM= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732036885; c=relaxed/simple; bh=snLFbEnXBKQVGlUks73lyegCvX770SSCXi1gKbSURZI=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=pSiMGVkc+BKS6C+WObsErWhNzyGdC6zE+7QZMBDbezd+VShYleZPsyP9vrrcMC5rHQsLPv2n3enz3WqjRH42++jOSDys5VIuQjSLydbk7DOzCn1ZRBac62RmfMMEOqD3A5Si2uirEEfDzqv6XFeASm5N3rnVyNCogbMewo9FWVI= 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=2QP6FQ2J; arc=fail smtp.client-ip=40.107.244.88 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="2QP6FQ2J" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=FT1ND2OwNEh8HOPE8dyCM70ZUmqb7OimJCkQM6eWB9cOVxWsw5WwjzjaUjRcchc/0VqN0biuO0U4JTeWcTwitOuej3g0GiWJkaX8EPzG6X7gVooC8+s0bZCwwpECZ5vfCgNk+BCWMdw1964lyYhgUkE6DLCWP9vI5jK5efp0wQBKb7CRnfyZWgoHtUMHUdTQFGARP6/uE0F80lrcYPn6kpQTyPGQLSnQGlHTUdQJqeYC5SEsx44PAWnMOWjWd2qJL2jACvaZ5u0HH+Yoku/pxWlWl/3dpskaH9fMocwcP38rFg7mDu8olRAWOEXbvWw3dosut+vHic4jnx7+nVg7EA== 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=mFeIu1OOy7NmI9v4XrT9b1Rd6G/IHgfIrbo7n8grD+A=; b=UjzmNPl4hgdWmVp+X6PYrS6zCHf7+yhPkKoOcFwmnpd4dhIwkhnDeQBcW7GLxYZ67N3ejyk+qtsHYVBUpf+KsPLRctrvrP1w0K4feFNqqkfwnQ0bHQHBp148sk2drq7WqcBW0CMUL4umWE+OL0Wwce36mkxd8Q6Ef7TK+bdOqwCoJXdSmN2XuEjIo9a279eAhJFtCf7GvaSUmZKkR+ryJ60ZaD8Z0vJA9B+HGYRxm6jHMnhHlEmcB2KC9BADvN0GdyMYNSLJGAkwkBJhgr1Ap7DpF5Uqkuuz3HeegaCQWlWbHVhiX8Rw9Ixu4zzQzyOQ3m/j8jCG8H2odjhty8xldA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.12) 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=mFeIu1OOy7NmI9v4XrT9b1Rd6G/IHgfIrbo7n8grD+A=; b=2QP6FQ2JWXZVeQR/eUaL9qUENyMi4P0lyXDD6/rgrycdaz2nm0WgjFFX8wpH5si/TH7E+v8wFu6EUP42lr/Jd03EOPIEMj9W+Z2QA39LeSJl2oDU4fpatKxk20x9UNFO/UiukQXD/Xc+lhnrJTq9A2lrAum/ME9S+qn/VYb53k4= Received: from PH7P220CA0040.NAMP220.PROD.OUTLOOK.COM (2603:10b6:510:32b::24) by SN7PR12MB7450.namprd12.prod.outlook.com (2603:10b6:806:29a::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.22; Tue, 19 Nov 2024 17:21:20 +0000 Received: from CY4PEPF0000EDD0.namprd03.prod.outlook.com (2603:10b6:510:32b:cafe::be) by PH7P220CA0040.outlook.office365.com (2603:10b6:510:32b::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.23 via Frontend Transport; Tue, 19 Nov 2024 17:21:20 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.12) 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.12 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.12; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.12) 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.8158.14 via Frontend Transport; Tue, 19 Nov 2024 17:21:20 +0000 Received: from AUS-P9-MLIMONCI.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Tue, 19 Nov 2024 11:21: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 Subject: [PATCH v7 13/22] ACPI: platform_profile: Add profile attribute for class interface Date: Tue, 19 Nov 2024 11:17:30 -0600 Message-ID: <20241119171739.77028-14-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241119171739.77028-1-mario.limonciello@amd.com> References: <20241119171739.77028-1-mario.limonciello@amd.com> Precedence: bulk X-Mailing-List: platform-driver-x86@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_|SN7PR12MB7450:EE_ X-MS-Office365-Filtering-Correlation-Id: fca57492-3cdb-42e0-155d-08dd08be95a3 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: 1F8i2RiYQdZkgKUe4hlTAKekSF4azYoMAH7PgjH2D44YAFHm1OK5zADlDRSkwxn3TADopUH5gEpCVzTqPoE9hOOToGjC6dRyKFI1NpqJi+8Jk37B9SUsUlx4HGeZ0L0bfLFSG/Rrg9bK1BUrC0HHAf4h9Ktu8ICriK/9+tYAN/B4SKHuK6PjIxQCKOVgZ2e2IjLmTT2DmeDKae+6AmNkp/orYysqrKuOh5RDE6mZ4xyGrJieEpFMSR2eZgUQmOG4+aGNMsLsFRfn9HVD4ZnJ/5w4RVgd2HomVlbbxOoxrhQcb/iOo5+weT39eLhe2W/X2VBN4FXHYhOf2LGi7xov8i1Dr2GxEvwCeXwiAql+CXmfeSXbxdpi+IHz8jJw/rhdNIJyV6zWyUOM6TZop2U84OR8gxZMRLdtbFvhsxV9SwaqreNqB7N9zIojirsuTBeYMai52XXRqjCncAvwCJZxgODDhZBAYTwsZnfQaaRGcKbjc9oB00Q6pv+9KuPZnuznyxtvAPWqHAftC8rTulSwPUtQqqXJ9xuSVzZ1tVKNBe8Ts8I0Rpt3q/Sk2T+g8pbyJhny7beGTVbNQUErV0Ggwbb6enF+8Z0EVTKpIUFuNFR7epApk0S7fzM66TDt/JCHrZQTMWs5c3TC73bg/n3uNPCt17xY9w6DK2T0Y1zH/nxL7YOFtKdgvXrqgRNSobzMFFxOXNpKrwI1rFp28nj717cnpQVfV/awNScJgaUmDlVegei0XbQws3ZP+PjX4tvWTTx4iUIbczc8lWGzjFgptuwNzmTjHVDZlgk4PkvYTGqowm2A7MfwACtCwRIXZ9I8JAJyqeAptkMx7PPUDlgzMwMNtQtF1e8BMkLZZmiYCCPg5n8oGKvYX0P2bbhnDyUCE8XnJYcqDr6At5X+HmBqv50/FM0xps/zNnQKbn2h85sFuKZ6Mq0QDeCPuxMVX5zz0GQJ22L/+RCFgrYNMd4NiiZzcf2EKDDWSakOkpQ75FXY7EwSaime4suLsnwH7uO+nENgsw3YqmtpqRFjTVwaRbJlQ0ocXkuKvti5JqG0bze7stCY73CMn1bQnTd5aidrylzPJIznTJSXOzWcTlpdijOX9FcjveBClvOzDbxnf42JVLTftU1SEkETxz9Mpv4LBsNubccDOnu0dUOb24q3ZPxfO19/8HjaWasJQrwNacYDOU6OZiNZczSCCVPEb/S1u80lI5TLxF7G0RB7vsX0DX9by4QcFukwa7/aUUu30M2UBSmmCiEHt2NYHtquv0EndFzmnn5CjJHW82YNJuPM3ZWeK2CvTr5BjEAvnKsJheAyDMLk+SSCouiwmNMgub3dH3HvnU1KtJB9aahekw4Ujn6PDa9Cx0j8ixVIth9Dind+U09Xbdpddgghyk6ym5GZ40PsbcYtkNtG89h8iuylIg== X-Forefront-Antispam-Report: CIP:165.204.84.12;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:atlvpn-bp.amd.com;CAT:NONE;SFS:(13230040)(376014)(7416014)(82310400026)(1800799024)(36860700013);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Nov 2024 17:21:20.1903 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: fca57492-3cdb-42e0-155d-08dd08be95a3 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.12];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: SN7PR12MB7450 Reading and writing the `profile` sysfs file will use the callbacks for the platform profile handler to read or set the given profile. Tested-by: Mark Pearson Signed-off-by: Mario Limonciello --- v7: * Remove extra handler set * Remove err variable v6: * Fix return v5: * Drop recovery flow * Don't get profile before setting (not needed) * Simplify casting for call to _store_class_profile() * Only notify legacy interface of changes * Adjust mutex use --- drivers/acpi/platform_profile.c | 100 ++++++++++++++++++++++++++++++++ 1 file changed, 100 insertions(+) diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profile.c index 9d6ead043994c..1530e6096cd39 100644 --- a/drivers/acpi/platform_profile.c +++ b/drivers/acpi/platform_profile.c @@ -46,6 +46,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 *i = (int *)data; + + lockdep_assert_held(&profile_lock); + handler = dev_get_drvdata(dev); + if (!test_bit(*i, handler->choices)) + return -EOPNOTSUPP; + + return handler->profile_set(handler, *i); +} + +/** + * 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 @@ -77,12 +123,66 @@ static ssize_t choices_show(struct device *dev, return _commmon_choices_show(handler->choices, buf); } +/** + * profile_show - Show the current profile for a class device + * @dev: The device + * @attr: The attribute + * @buf: The buffer to write to + * Return: The number of bytes written + */ +static ssize_t profile_show(struct device *dev, + struct device_attribute *attr, + char *buf) +{ + enum platform_profile_option profile = PLATFORM_PROFILE_LAST; + int err; + + scoped_cond_guard(mutex_intr, return -ERESTARTSYS, &profile_lock) { + err = get_class_profile(dev, &profile); + if (err) + return err; + } + + return sysfs_emit(buf, "%s\n", profile_names[profile]); +} + +/** + * profile_store - Set the profile for a class device + * @dev: The device + * @attr: The attribute + * @buf: The buffer to read from + * @count: The number of bytes to read + * Return: The number of bytes read + */ +static ssize_t profile_store(struct device *dev, + struct device_attribute *attr, + const char *buf, size_t count) +{ + int i, ret; + + i = sysfs_match_string(profile_names, buf); + if (i < 0) + return -EINVAL; + + scoped_cond_guard(mutex_intr, return -ERESTARTSYS, &profile_lock) { + ret = _store_class_profile(dev, &i); + if (ret) + return ret; + } + + sysfs_notify(acpi_kobj, NULL, "platform_profile"); + + return count; +} + static DEVICE_ATTR_RO(name); static DEVICE_ATTR_RO(choices); +static DEVICE_ATTR_RW(profile); static struct attribute *profile_attrs[] = { &dev_attr_name.attr, &dev_attr_choices.attr, + &dev_attr_profile.attr, NULL }; ATTRIBUTE_GROUPS(profile); From patchwork Tue Nov 19 17:17:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 13880357 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2050.outbound.protection.outlook.com [40.107.93.50]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4720A1D63EC; Tue, 19 Nov 2024 17:21:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.93.50 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732036887; cv=fail; b=P7KlMuPbRej0bpJkxnUYqZMJRSFtZGr/GnDzkyjc8J61LL2nVU5dCoGRLKdFlw4Tz/3livyDOj0nku382QGindcL8q99xgB5M5crdkozBi0wKIUArxe4JlgMMWd7rdThaQIg/duIBZXFXLvgAbZs/bII287vHdW/LOj2DFZw54Q= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732036887; c=relaxed/simple; bh=31AW3D7L+1fTsGrX8PR1c6Lzz+tYtEk1o1RenZxATmM=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=M3rItJOlE7XDWjHYfoHPl2a0s4RGEOGTBx++VKD/Lqe7BjR7FmiG6Q6id4Cjc8GllWldy3vbQipGCHpzo5KnZgnT9UdR49jDcb3nOFbBnCrScqHpnz6JEhDKLY/7PQ7Pi0ZI8N9irTsAwh36EihuvkC4XRAbksgX6XKfWpiWxwI= 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=ZvM2T3RL; arc=fail smtp.client-ip=40.107.93.50 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="ZvM2T3RL" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=pT1JQqNYKf0s9/nMqtWZZV4zlAuTeVsKE8V01VctW9T0XKAUcUcUmyMyPkoAEmxP9FciqPsbTi3No6dbMZXqx6nKT9Sp67LT6X7R+xN2KFQB/1f/SfsAD8MwleSa77jTUsMDnBi62fxK5l2Zu+f+7lAJoQhU7UJXxL24av53J8voAIkU9/mZIfPbG6mITiMB5a4apttgPpnsXd5cNxtDHrL6clDOTvGV30ZOZd7LKp0GwHGCCoc5W+eCFQHWLL6QR9/iLpC5hHQPLMam4JF7ONm7mkS5IHv6nqKD1ddEWw4+S495D5GrbgGu7+BE9F8UiJWYLzUx+cZLblfoxWRqnw== 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=gCLCYYN6yRq3E/e6+tiqhvpUaO+kwcSxOCVD3v5ilIY=; b=Qqin2O4eLCd45Lc3ZhB5IiFFnLkTRm4Ep5uX41kSkubRN+9JnOqAAfAy9RE7j0K+O+pNgmZNW2dXUJXgiNwA7nUdW0CEjt4rQmTu9873thwX3Q1FNwXMTStkJLYANAXJllUvAENtYqTLj/J66vbD1Hgvsb4ZROM5wDaZ0UoKCiWd0EmqMC776VaJbuD2yW/B+SNKOpPVZsJY4ripM7/T9uPUZS32Vfs5puIcAbXJ0ww0N0eEelpea4vU5xjM39h3aL+iVXan+DtW1tA2MCJ/z/mY3fLVe54IdF38qJTCiLL/C57w014F4NO6rV1FuYwkUCkVnwLqqEwR/VDVkGPKBg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.12) 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=gCLCYYN6yRq3E/e6+tiqhvpUaO+kwcSxOCVD3v5ilIY=; b=ZvM2T3RLV5khqQuXDTgL/G9La0mrU/kB2Tuqv1CfR6XPiVgtQLti6wlXrgDvYjw+RgInQHRGFcyOhe5rN5qgW/7EGB88TmTYAeIUm51romHqPbzthqs5WQUqqYIrlJq0ZkfSeTo6jNOpiQ+N6Bq+30IRPp+FQ9VxXqa0Y8cVwPA= Received: from PH7PR02CA0009.namprd02.prod.outlook.com (2603:10b6:510:33d::11) by CH3PR12MB8994.namprd12.prod.outlook.com (2603:10b6:610:171::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.24; Tue, 19 Nov 2024 17:21:22 +0000 Received: from CY4PEPF0000EDD2.namprd03.prod.outlook.com (2603:10b6:510:33d:cafe::e3) by PH7PR02CA0009.outlook.office365.com (2603:10b6:510:33d::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.24 via Frontend Transport; Tue, 19 Nov 2024 17:21:22 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.12) 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.12 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.12; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.12) by CY4PEPF0000EDD2.mail.protection.outlook.com (10.167.241.198) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8158.14 via Frontend Transport; Tue, 19 Nov 2024 17:21:22 +0000 Received: from AUS-P9-MLIMONCI.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Tue, 19 Nov 2024 11:21:19 -0600 From: Mario Limonciello To: Hans de Goede , =?utf-8?q?Ilpo_J=C3=A4rvinen?= CC: "Rafael J . Wysocki" , Len Brown , Maximilian Luz , Lee Chun-Yi , "Shyam Sundar S K" , Corentin Chary , "Luke D . Jones" , Ike Panhc , Henrique de Moraes Holschuh , "Alexis Belmonte" , =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= , Ai Chao , Gergo Koteles , open list , "open list:ACPI" , "open list:MICROSOFT SURFACE PLATFORM PROFILE DRIVER" , "open list:THINKPAD ACPI EXTRAS DRIVER" , Mark Pearson , Matthew Schwartz , Mario Limonciello , Armin Wolf Subject: [PATCH v7 14/22] ACPI: platform_profile: Notify change events on register and unregister Date: Tue, 19 Nov 2024 11:17:31 -0600 Message-ID: <20241119171739.77028-15-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241119171739.77028-1-mario.limonciello@amd.com> References: <20241119171739.77028-1-mario.limonciello@amd.com> Precedence: bulk X-Mailing-List: platform-driver-x86@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: CY4PEPF0000EDD2:EE_|CH3PR12MB8994:EE_ X-MS-Office365-Filtering-Correlation-Id: 69bef7e0-8f32-4fa3-846d-08dd08be96e3 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|7416014|376014|82310400026|36860700013; X-Microsoft-Antispam-Message-Info: /7i3wFtMUUJH+4lYzO3EOCK0jmgwfrzn2UQtyRQO7qBbRw497R/11O++lIwM1vqalbXj8U10S0lT2Hpz65gclY3ipEFoH2LQjDIZ5dZUFEJRkLDXVYBMKFK8xKXjKuNRckqifBlDXntQPCiGp8dEdS6clsiIkwPKOtr0KCZDK82ah90bI0IE8Z5Y8IRHOMMKlj2UI5egZKQWfYbY7xEsDFWp6ML8Rm71HPhH1w3IDXG53y7zG7pZSA72uY0XLtmBviIFOUAt2aFsnPE8hEEzJ68rjFwCNXwxkZOtqevn1Gm1Xtm9dIzf2Os4qgloq/Mg16PTRDgxtdqpcoMQXvK3Rrv1BML6f+8CcxQeK2ruCmfdpSKNjJ0TL73cGNarl47bNEGVdTmxNL8gn0A5Zu4sowbucpXrkW1Y90PjFmGzBRIl8HYd0edP61waESWNyIFBd1Y1zTSywnyjRithj3VJrogbK4EH+ysJ0quwMkDSE1oRPyIGtylzrlw0Ev07+vYoAh2RNiFyCAmDimu2K6vGmfSi9ZBtKg2cWgT4PyvqfuW6OK448425nvxIHhlp8L+dXXg3z2wMfQ1tv43Au4IrvKy0nORvFNWCRqxqk9/cFuUi681uzS6p9GYcgXuQA3LmqlgPxpRU8+GahqS71RstqK54/ojdBhkzDrxrBU6h+KGaSBZolpFk/z+j1qxF62VJe8ISJso740XV7A2/yhnb+84z/scxY7KGkuSutn62wUGfsQT0x6wKL67iLU7MBS1ODwODa0QJ3Vabc0J2h4Puupx/61vDXNUaBjNDyEuN4YY13CQwW4CJPsekkTEuXO7XHgkQ3AzmpNjzy93pAVJNQOl0Q9G3mlTAYDV/C3x2n5iuzA14hh3Vq5TFYglPKI0QXPQMb1c7ZeXHGWIoqbJW01e6Cg9eoADVi4OtNIdJNSdE/25hPQ53HML4R/rv9YxyyB6gdBsrIbRqXY8mv1N4JPMo5H9MlmiovibTMJu5fBO30AmNtfuKMVGzaNV5e7NqBcmUibRGmYasXpX+FpfGxEMNVB03BYKbQ0ZCA4Gk7kka789B5baTviN54w5Y125aGsAIaqc/SrpijYCPLQIQaDdApXwLq/DJd4AztVcsBoQRN2DcPafuO61fk1BXcdykCE6B7mQSlQP77ajoe6k5h3jojXltJJQtJHK+wMctqBjsH6mR6LgdXNYqHsgbewHQnVWb5I56Ona6eMETsqAS6wfnsFEifleNIqNtq47QWps1CSPreT75HCF825rIYhOq2Tk0uu27ZudkCjGVTFBW6RWzvpk21E/i9RK6eDeh+31pVU0HyF68Re5PrOeZUxcjCE4u3eawLDuBemxkQ/rip9IZc2L3Or/s1ab6madxJAAKsk1qg5SN7R4+AKMpx0xb+VhMw4+ZODnL4ZNCxtWDLA== X-Forefront-Antispam-Report: CIP:165.204.84.12;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:atlvpn-bp.amd.com;CAT:NONE;SFS:(13230040)(1800799024)(7416014)(376014)(82310400026)(36860700013);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Nov 2024 17:21:22.3217 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 69bef7e0-8f32-4fa3-846d-08dd08be96e3 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.12];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CY4PEPF0000EDD2.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR12MB8994 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 --- v7: * Add Armin's tag --- 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 1530e6096cd39..de0804305b02c 100644 --- a/drivers/acpi/platform_profile.c +++ b/drivers/acpi/platform_profile.c @@ -363,6 +363,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); @@ -393,6 +395,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 Tue Nov 19 17:17:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 13880358 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2082.outbound.protection.outlook.com [40.107.237.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 5E8F01D1F76; Tue, 19 Nov 2024 17:21:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.237.82 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732036890; cv=fail; b=pHykVmgG4bA6ZQQQZqowpEGxXg1hOdvAHAcC6uFnHmTMPltfrPpsZruirXBVmygdssOUb0xRNKWGOrgeiuXOvdcHpTqJm8a5dXdyCoUfVL5PIi3QANfRTDw9cOJfGZD3SB+SszRILMRTqJzmrodsO4ii4uxe7NYe+capr1kOwpw= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732036890; c=relaxed/simple; bh=2rt6Y87tQPRlcT8Df+nkb4/NaZ8Whknr1aC5eHRa6yI=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=MH130yhA7ZgfCCrL9tMvwcf4Eum/kSVT+h//ak891HU/ZpTt/1bZ4jnVD0njAEYksxNY5TerNQRbc5JZZpuCCzuEvY8cHpOvtdZL3nkQDDiJB8BtbP1Pb00L6UEn4ULjeexI5sAXWXOdew2Hvis27SJs4PGxCsmFrfD+wAud09I= 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=Uio2uQA7; arc=fail smtp.client-ip=40.107.237.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="Uio2uQA7" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=U8KnARZzceNsJKH0B0XiFxo382Tj/n4vdQhf1vqXSr/7tns+i6NJK8CnP90V0S8CZtYyPGvjJxeVnpzWR8JxlwFBkFbgJXsRkNEVHvahE8nd1Ujt+z0j/gHwH5deIKzcKa32qYsrHpzbFDViwbVuSX4+Z+xle4qyaXL7PdKz65wY+gMOUwX42qlqR+l5aafP9wdGSoxw32ne16zXsnTKPfUZXdn75uNL16/3zVFxW12aZLmXG7hSdN9B2Vkl2n3Sac/25/lHljFRHc/6gTCJ+DVirWOMUaF8BzzmtLfgLljQfhVwLjdh+OrXbvEJ9Rbcyu+gvU9kg4dMNNMWAHJ++Q== 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=xJyqyRORx3PN3Q7CjJn9UtLhUkcMdMZ1mFaWGk31Er0=; b=P8oo+Ntmk6CfFMKHicLqylx8XZ2t8C5c0aWyeoHEG/Mqi5gpzsITCqt+6OsZw9GXltEg4RN7Lzb04MIA8Q+vluFSj+oyag8eueNgQTa5bFhuFRo58ch5XQTvOIlyS03aVUXLxoMPjNhqA2Lb14ALHXtgrMOR62S7CqU0rKXtHToiQVH3GedF1Zvst8mDtBB3UoYkfGFd//VlTSEPa177MKV7SiUizYTxrfxPzHQFTWzxayMpJ0SRUxFqlNaBQvh36svRCUNMa9yJ4si0RzTy92Xdj3jZ6XuU8cUBMc+QER0NpOn8tzCGpC8+IJsjuzNyU/rv0cSnpiA88MRXlS4OFA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.12) 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=xJyqyRORx3PN3Q7CjJn9UtLhUkcMdMZ1mFaWGk31Er0=; b=Uio2uQA7S2C9gacRfv+zby0M6texHqmWjJsgM8iOj8Ww3gCnb1TbCGjAArArZ4CiiPE4raYI9S4D9tUr65Yrbc8z/fvb24gc6gHqbLWyikc7fzqxQmJppKcr5i6h4Qc+YX4ZUs0mfwTmo7pJZidiPVtUhCZx/l5AFhKHSPTUalc= Received: from SJ2PR07CA0010.namprd07.prod.outlook.com (2603:10b6:a03:505::27) by IA1PR12MB6233.namprd12.prod.outlook.com (2603:10b6:208:3e7::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.23; Tue, 19 Nov 2024 17:21:24 +0000 Received: from CY4PEPF0000EDD4.namprd03.prod.outlook.com (2603:10b6:a03:505:cafe::20) by SJ2PR07CA0010.outlook.office365.com (2603:10b6:a03:505::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.23 via Frontend Transport; Tue, 19 Nov 2024 17:21:24 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.12) 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.12 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.12; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.12) 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.8158.14 via Frontend Transport; Tue, 19 Nov 2024 17:21: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; Tue, 19 Nov 2024 11:21:21 -0600 From: Mario Limonciello To: Hans de Goede , =?utf-8?q?Ilpo_J=C3=A4rvinen?= CC: "Rafael J . Wysocki" , Len Brown , Maximilian Luz , Lee Chun-Yi , "Shyam Sundar S K" , Corentin Chary , "Luke D . Jones" , Ike Panhc , Henrique de Moraes Holschuh , "Alexis Belmonte" , =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= , Ai Chao , Gergo Koteles , open list , "open list:ACPI" , "open list:MICROSOFT SURFACE PLATFORM PROFILE DRIVER" , "open list:THINKPAD ACPI EXTRAS DRIVER" , Mark Pearson , Matthew Schwartz , Mario Limonciello , Armin Wolf Subject: [PATCH v7 15/22] ACPI: platform_profile: Only show profiles common for all handlers Date: Tue, 19 Nov 2024 11:17:32 -0600 Message-ID: <20241119171739.77028-16-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241119171739.77028-1-mario.limonciello@amd.com> References: <20241119171739.77028-1-mario.limonciello@amd.com> Precedence: bulk X-Mailing-List: platform-driver-x86@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_|IA1PR12MB6233:EE_ X-MS-Office365-Filtering-Correlation-Id: d45d398b-cfb5-4904-76cc-08dd08be97e6 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|376014|82310400026|1800799024|36860700013; X-Microsoft-Antispam-Message-Info: 0zpy2WirGQ5U6D9OMg3/cYB3A01A9pezztk0G82lzh2Nu6PncKt6pdritQOrhngnwBNkZlHxiamqBSd5icBRUL6EpW8VP8fzNRcpoOcegKfq+Lpz7jotIgno5M/qD8cH/nZGquYVn4x1RPqwd0RaC23DT8r8l8LEz2Wb6XmDVAZLiBTMJtzZilW8TWVi2TWVg52/ydZ9J/C6Qf0R1PtYIcrYqaEwi/8x0oGEi84YrxeUoZc1CSiHdFoZVL1etac0mB/oMguDsAXtVa1V1uWDeUTBVzJHsmvGox8PaEM9AWZp4KlCsa+TS/wc/BwlYt4wwfeF0rjxSV48XcHdVQ9+1ptt0MEbyNnwiS5Amc85L6Abbm0IOvitBz6+xMxGabS4+7qBd9wOm9cWks1K306tj+E2/CZds0Zua06fkhklxFKEjDT0gYOTVSiB57PK4YF4mmlXScK78XE7w3/coz9TFQFTMaIfLSzLVg4D29SIZhDsxtw2K/qDWVAwKVPIhNJY42IUL2xMxXjL83pRQOQs8YR3vTicZ4j0Nl7PNhfGTYdLS6JfoXBIyAVINKRYOxzB5oVsxZdn7+rn0m401HFY0PjaCFCgSO9xOc5rFqLG2FXMgfC4ItUBwU1gwVVb8ItUt2tzLFukpisCWSNDuB+rKCdC6/6h2F2uv80wHXOBXCQv9lL9kTb8fS7nbM2NSr4MSzZrnL+GS8iQteh82c8uJRs0TKJIDQ++u2MPQMENaOH5yONJyuN909+MboVWCMl89FWdGUhE2DGYHVwaX4E2nneFjBHWIGexleTQiFIfFCbe2NMwB9mpbd5K9YtYjupX/uVNSRLgyEeAeJV1dg0aZYuc+z7dFXeWhtFsUzMvXX1+E3LuUben0P7qoHLrMYzZECvaHxAa8I9QzZX9YgHlttOg3ovsV4sIOk5WWcPr175ZLbnC9BP0Qm0tJeRteCXdDrEBMgZvXWb/NAKhUO0gIa+X3XyRaF7zEf3CR8by/6pTgehvmQBC7EN71b2YqaJv1fWM9+qdKe6KTnRQEXw26HhUqXP75momhEw59762CIWkCymtR0LYKQNm6FG/gAB2P4dfqNib9hZrDaLioeWvKf0oxU0gMjy2S3jiRYvukHiL0E3reCEvCBEk603z8hMbf1hzS5x9ejpQqO3ygXLnYqvn9tPbAs8oyNS8MYZgm3f5PqirMG/WtrTv0fGbEKRxeRMeNH6SoqXQ0fQ0YRzVPOajiB//hgV8UMm0m1QbJiRjtvW+9L6dm0KcTVvdb1zn+x2NQD6yTlgRzLnqot6pr8J6wW3+8tvzw1NV5r5bt/I4zqY4/Ex6BX5smae8OpAUMYrVsIrjeHHDUKukNCJxToJB9njN0woCRRdgCtEeXrQczIiA7QTmWs4FiSU4JVdN00lTcC81TRcsTtDTY1RlLQ== X-Forefront-Antispam-Report: CIP:165.204.84.12;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:atlvpn-bp.amd.com;CAT:NONE;SFS:(13230040)(7416014)(376014)(82310400026)(1800799024)(36860700013);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Nov 2024 17:21:23.9562 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: d45d398b-cfb5-4904-76cc-08dd08be97e6 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.12];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: IA1PR12MB6233 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 Signed-off-by: Mario Limonciello --- v7: * Add Armin's tag v5: * adjust mutex use --- drivers/acpi/platform_profile.c | 56 ++++++++++++++++++++++++--------- 1 file changed, 42 insertions(+), 14 deletions(-) diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profile.c index de0804305b02c..db2daab5b2a44 100644 --- a/drivers/acpi/platform_profile.c +++ b/drivers/acpi/platform_profile.c @@ -192,26 +192,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 Tue Nov 19 17:17:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 13880359 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2089.outbound.protection.outlook.com [40.107.92.89]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BD14E1D9592; Tue, 19 Nov 2024 17:21:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.92.89 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732036893; cv=fail; b=MiBLBTG2bB66x+KoEkn+9sY/ha1UBu5LMgbwFhQSlbdii4Ooy17zuhgsT9epTGi0YMgJWbdyqTK1fVTyi3UQaq9WikSNf8CyBNTNc6MibJNoN9DKx8ylrfScleAjWRRZUbLwHOKQZ4W8vXlZI6VF7QPrfqb3Qcm22IR2gUS46aM= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732036893; c=relaxed/simple; bh=R4FOJvOdpurkjZ6rAItGPYx1C5vNDKL/Ck1Ok8rE8LM=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=kgVrXtSpyP2GHNRdICpIJVHPJuYEgnXiDSYim3Uqe0R+VhgIUJ/sjgRnQCxKf2nzR4KlUe609lZsbBtRi1YOhLfbAglLGEfT7EyHzM+xsCHlMa3X8PVq3MxyfZVp0elDr8ixbVxQv8UMZtpdyyifXoIucWI6kQ0mHR/nAvhUEWE= 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=CJ5vaEqq; arc=fail smtp.client-ip=40.107.92.89 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="CJ5vaEqq" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=OsqFqK7sU/FtG0ZZhPZ5zqAhj1EtSwzdSxBZNHpNgGFZsAKJ2S87ggtlhUTWcmH8ezsZZSta/gSwFRxIOUb+8zxtyCYmA34xdfKzMB5UWkS1/gtNNIYMOS+dyFQTsh1/0Jk+sjv6PApwIYNFNpgad+do8ffKvYtCGELyeYs+/tA6XM9No+gJa1TqIqF83LatuLS52qfh09rPrmMGrEzqmcCsaxmXitbYDp5+O26a5GpXEqNmkL9x7ZslXzHKfr27C8ZneTtIqi4tWPW0DoN0VtsgtbBrqLMm2grg5M+yh+6lYZIv5uwgnauOwxfRZkIrpcosrLy25S6idxVn6FUeXg== 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=gdz8VhuJ822zb+HDdL0/A5HVsWK/jSuxunFPEBpnYJA=; b=Kx+NOY2aQI0m2+kCeUYkQBE6tvnOuH6WO/sLtjcI2k0vXzoXohtshf16Scqf+wAq7dP3LnpMRnBT7QCrz6aexU5gb/Hxuxx9JhjAyypcYKV3tdjGRtCxMA8nrkJK6QbM3Ggfgoss+3kPivMbu6v9fpNtnbxXh0T1uNoJYneVjivGY6HCNHrOuKgtZgrPXRRccFVSzpA1+/L6FCUtheQD64Zyx1maZE7/Ucg0MgWBRGxWG3Ta4azs0a0Pir026HBn3x5162bby9dkkc5g7YWyAHDuGk/QKpAgBtGioRj3tGg1VNG4MumrDNuW1MehhuCVpCHmdFSUOOjS81es9b0GNQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.12) 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=gdz8VhuJ822zb+HDdL0/A5HVsWK/jSuxunFPEBpnYJA=; b=CJ5vaEqqcm+JXTQ99mmFiIUTnqr3uNqaP1rNQ/ANuzt9x/HpduRA98c0obm7Tnk0i0IqT+WHi27jtmuJ7fkZ3dwL9FMGQTMFXevh3CjflilwbJEX7eXRWMOTd3dvn9XEHuPEXtpNP9lLT+fwmTge+6AidQb5pxrMxUkenKaaICM= Received: from PH7PR17CA0046.namprd17.prod.outlook.com (2603:10b6:510:323::6) by SA0PR12MB4368.namprd12.prod.outlook.com (2603:10b6:806:9f::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.17; Tue, 19 Nov 2024 17:21:26 +0000 Received: from CY4PEPF0000EDD6.namprd03.prod.outlook.com (2603:10b6:510:323:cafe::b) by PH7PR17CA0046.outlook.office365.com (2603:10b6:510:323::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.24 via Frontend Transport; Tue, 19 Nov 2024 17:21:25 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.12) 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.12 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.12; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.12) 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.8158.14 via Frontend Transport; Tue, 19 Nov 2024 17:21: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; Tue, 19 Nov 2024 11:21:23 -0600 From: Mario Limonciello To: Hans de Goede , =?utf-8?q?Ilpo_J=C3=A4rvinen?= CC: "Rafael J . Wysocki" , Len Brown , Maximilian Luz , Lee Chun-Yi , "Shyam Sundar S K" , Corentin Chary , "Luke D . Jones" , Ike Panhc , Henrique de Moraes Holschuh , "Alexis Belmonte" , =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= , Ai Chao , Gergo Koteles , open list , "open list:ACPI" , "open list:MICROSOFT SURFACE PLATFORM PROFILE DRIVER" , "open list:THINKPAD ACPI EXTRAS DRIVER" , Mark Pearson , Matthew Schwartz , Mario Limonciello , Armin Wolf Subject: [PATCH v7 16/22] ACPI: platform_profile: Add concept of a "custom" profile Date: Tue, 19 Nov 2024 11:17:33 -0600 Message-ID: <20241119171739.77028-17-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241119171739.77028-1-mario.limonciello@amd.com> References: <20241119171739.77028-1-mario.limonciello@amd.com> Precedence: bulk X-Mailing-List: platform-driver-x86@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_|SA0PR12MB4368:EE_ X-MS-Office365-Filtering-Correlation-Id: b1d8a5a7-d0b1-4503-caa6-08dd08be98e6 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|82310400026|7416014|1800799024|376014|36860700013; X-Microsoft-Antispam-Message-Info: V8VVbOdcfUinJD86ja1k6NIgmwlbLMiZ0+0knu9KFuLnuthzBRzxS+6wSiuInBMAl7J4FY6zjh5bu6rC5B4UtkLqRbLQ0qBu9t5a45nHgk/awBESyi1mQHX4Oa5lJkb+tjxG4IanV7RcWqekeZ16th3KeoTGGr9Q+CI5U/0ojU9p40FJgwG+7zC7UugfxTyNdxp14ZgGQU+VaROuLkAhy/ocasCwl52qdbj0yrJljzbF9zvMWib3tSE68QOGNLaZt6CTf0c/tGWfl8CYz28D3cjHowHaimsHwvtaYEF6BgGM6Hi4BztwTwbGGWt0pHuwE/WiYyBBGKsn3QVhwhgh1vxelmFW3Uoa+RTiLqYvyHAVmZkZ7h9DV0foInX779jm87EMSGqw+FOiujNYuCoJHlZ3y1tu578i/ejMG+jb9xeduZl/kDtK1V4RUyvITkJ+/GTg60vuXWkCzY9Zrs0Oez4Yvt5o4Le+jtydOU3IGaNCYk8vwxn+0xAtOrmwLntczOkJzAxHf0KhsY3AFp5/JzpX2/QrIP22CqQAKKxg4e3x4Q/eCyyaVFurxej9LZhsB0NNeGQ9MjPBznoQ08JSPbfFvkUUJdIVvoFQosOfMPEg+P1hzAOaC5TJTf+Beap3vVxmLOqw4TegUmKIK3yKFKrsS/i4Cb3Qr8ZPUDLQViU6m1aV31qTpxhO2UnvRSl9/PFLyKOY2Y7xKDzVpL/tIK5D/DU/84g2FyFIO7X89LFj4ljR7NkorWlSeF3uvVEZvHFFEH2SqnSui2AjfQpfvY+/df+bw47xdtjwxLdK0MqP6PQ6+jMIjdrqGz5z7JIP5sY6vX17dMrZREiTYyW28uS2tdtUECRKHHy5fYo7t8aLVM47BJZ3oxhdgQzF6smMlt0spwOALO+KDQkNfuG33XMHu23tVhg1yRLFN7GjnL+t/+8xZv3Ztpu2tirgN34MUPOjx0fdRxB21ZNFHtQueJMSvCZhVbiZO4h9vBKhdnlWqNzmMsbsU5n9VYmpUidbq9p0MaKyhDlNLgp+nigGF9x3MOeGOwVpK12dVLBhamWu9I3Zb/2hHFp3307Q0FuzQyQGP4qImlsrJc9L3RmkXDpyWPswwyJyAzcxCwla94MdUMMJuzl4Wua6i6X0Tsq4PjWdHDL25B42NqHfepko/er2kwvFuiABOMh6hNrtxZ0hhEnd+lyMyJCBvNVGnJf2py/zAly8Ge7DqGpuir90zlqpnaRu68xmV6rOw1z6TywF00dPLwCVWuDKH71EQ7H1NdHWcM7pnqiOdnkIQJ8Q2GECoDUmk6Zf+1N9Ikt2TTTscpA6gtXsMibuLiYbMx5TK3IxchyxAJZ7BuLsNYgK6DCNLSezxblC+SQNFs4FZEN7nb9yC+95aGbWX+bcdHYh30AuE/JXsOXLPbOFSZgyjQ== X-Forefront-Antispam-Report: CIP:165.204.84.12;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:atlvpn-bp.amd.com;CAT:NONE;SFS:(13230040)(82310400026)(7416014)(1800799024)(376014)(36860700013);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Nov 2024 17:21:25.6830 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b1d8a5a7-d0b1-4503-caa6-08dd08be98e6 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.12];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: SA0PR12MB4368 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 db2daab5b2a44..d579de1b31be7 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 Tue Nov 19 17:17:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 13880362 Received: from NAM04-DM6-obe.outbound.protection.outlook.com (mail-dm6nam04on2049.outbound.protection.outlook.com [40.107.102.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 2DE4C1DA11B; Tue, 19 Nov 2024 17:21:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.102.49 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732036897; cv=fail; b=fTl2d0EMOjvrBoO2AYaVypOa6Ly3ZREIOCsIEfo4q2TMlJ7gzQldXhXi8DkOlbrxqptrMIsiD3JbcPp06PqZuYDoVdUgZdv54rKZIRX/s0vpTjlRkwdNoRK4+0QYC6cS37j8ipoDXCJwfnW1k1t+hOCz/2yC7Rdjg9uM0cI/lyw= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732036897; c=relaxed/simple; bh=XdhrySlYFp+OvrJQRA57C4rcdrTgfHNmuwKwtVISUdI=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=BESgtkXWiZ+qzaqEBGpr+8IFzqjaNS3xXVF3MUXYoblzFsrhN9uwBbER87HB734IaNPY8ntYw4snHWISI7VqZ/SWgDvIT7CUiMjbhTdV2RQpTDdQrsWqEyHeLtfNvxTH6CitX0bgWdWkfVDfvmP+qq28mNK4RFUgiYvfsVBFpxs= 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=KME/kyN4; arc=fail smtp.client-ip=40.107.102.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="KME/kyN4" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=UX6RqhbvAjSqHD2c8NnKd3oLMzi4HfrXmmzZfMLWa3+4Xoa7yVITosvVJwOwr8IaaS1S2Rdg/kz8j13zwy9TRN4hw9nxLAgqdHWmVAThoezq0rCapaxLj5LTaYDVwv9XX2PBIQtEYgFTbPrg86gXMC/dVEBwH4tGflYFDg0+ljQgay7NxJ+DMVCumV37vKY40eD3s7e3qI0KR7lSzDGupGkmxYx1e7R1DcvDTq8rnOpX3/cZ8kKeeKKROphXC/kQfbkkJkavzG+p0uMNp8CxuqHcl3gZeHD4iSHyOuihdX1eQA4M0NLroufzWXL/enudRFs93wk4SPVyZXWfZIRrBQ== 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=UGPAqd1+1i81/Riyyy4bkGTFIxSQtRIuLq5MJ9N5+Ag=; b=VgS49ZQoHqz9Y+zBkbGY5IyY3+f09X36Psar1kECmRutQNrsstBX6sduadsPiwC6QL6XIyWcppIHlELL/S2/629ZykoSdSlC953J+EiD+m05LP/4b7+MHFAoEbdRz5a9VcPVB56qcv1H/QKUyfIFh3m3iApFJ9Z6TQmjYQRG1cUYc4tNQXCFYEFFSFJeAaaYx84Bi53OYTUsUJetp2zhtfRDjhNNiYcoN8QqoEtSx//J0ABygMIEoJ5JXg38Fc0F3Hh97aGkHko/Jnv6WdRCbcEmF2uibDM1nPCZ4R3R7F4m9FPfLfKsbGMlXTbGXMwjmyJ1dlj1mFEWvPkScZePuw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.12) 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=UGPAqd1+1i81/Riyyy4bkGTFIxSQtRIuLq5MJ9N5+Ag=; b=KME/kyN4mJl6lQuUdFNSnHJWhjjRDXIqTjbsQXqmQuMXooGWIjR+PbU6XcO19d2mWUtd1xuj4AKsQsiFNdKCd/hK6BC6UN7DTO29iWnG/kVGCpgoPzEGZXnwEW0fFwZDYN9tbZGrTUgii/qGYDvv9/I82POtaRenRzyJHsuy3j0= Received: from PH7PR17CA0027.namprd17.prod.outlook.com (2603:10b6:510:323::13) by PH7PR12MB7139.namprd12.prod.outlook.com (2603:10b6:510:1ef::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.23; Tue, 19 Nov 2024 17:21:27 +0000 Received: from CY4PEPF0000EDD6.namprd03.prod.outlook.com (2603:10b6:510:323:cafe::e1) by PH7PR17CA0027.outlook.office365.com (2603:10b6:510:323::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.24 via Frontend Transport; Tue, 19 Nov 2024 17:21:27 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.12) 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.12 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.12; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.12) 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.8158.14 via Frontend Transport; Tue, 19 Nov 2024 17:21: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; Tue, 19 Nov 2024 11:21: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 v7 17/22] ACPI: platform_profile: Make sure all profile handlers agree on profile Date: Tue, 19 Nov 2024 11:17:34 -0600 Message-ID: <20241119171739.77028-18-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241119171739.77028-1-mario.limonciello@amd.com> References: <20241119171739.77028-1-mario.limonciello@amd.com> Precedence: bulk X-Mailing-List: platform-driver-x86@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_|PH7PR12MB7139:EE_ X-MS-Office365-Filtering-Correlation-Id: c240cc43-cc18-4e1f-d287-08dd08be99f1 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|376014|82310400026|1800799024|36860700013; X-Microsoft-Antispam-Message-Info: gtk2ysN/8gddDLZNfbcJfmxZcz1E7tksdsvduP3IKP3gTg4hK1NWS5i2xb5k4eGFwE/LY4861uCOj6dIDQSRP+mmwUNHUIRl/7qSGhWFrVjNHdTRo+dP5p96TI/Ph5eIwg+Ys5BLjU+kUiLSQWqKVy9fTPhPMCGNn6/FK40Ax7biE+xjgp2Qe/IOhHPhDvgVEYbAf4JH+Fn6pv08mZaSMBw6P6uAyKbyhwznLseX+yxlovHnF3k8EsUgD8GW+Pd0JTIs/S6El2Qs2sWpbVpKnQ+U5vGMQhTbHvCOqSUTCkq9Kvt2gPbb0y4p2JmCFZcV94l57C35Cry4IiPD0LKs1s9AvBy6XPlvbKJmiDUVlcMrr23rL45kA4/jyY801W2vaZDiInNbOp8z38J9u9ialbkWfXrodopJp3SoZphgGd7tSWaMnboHXaB7VqdPrixkg7uN9/QxF+VNCFrfbStKqF9qlT+3DfNPnwaZUvcLzGpz6coCItw6LABPPpawCSgCJr8185sQgryFnLPgUzpB7MrUFfmPxQCQOJVR+8VVcfxxn5NO5p4eArKFQaK7djI1heFfaDY39aiweP7VZony3eZI6G3Kqv0GHPdtyzKptVQY4x7HmeYX7VE28+0XTMar8Dixh9LVhTi+R2ZoB1LoYYGjJVVeQDRoeqEjsZ9QDq+cH8KwapsYpJkeEbQAqO1nIedsXqgjTkOXnWcphaGbniw98eNViAD2eaJoi21SyYJTA/SnbVJEZMy7I0uzJU4fbWCAw/izoviuGBPxzqAHSLrdshxFqecWzBwgwl//zIneZKlO7mljx+ldQdD49ORWH/OwH54i7L/fd5lmzh/gndODGh2t2uGaFF2zNdbAJXN8hwnhSFrjmC/AiJJBXbX5KUqvtfHoiCZ/+Z6DseBowyd/XdfOo+X+BB1moKmiwXtgfJ+5uEAC5EfP0U+F5DHP/aiEQr9872xN6FxsFTW0W7BN9H4qEkgi+zjVNC8IvVRMuj0d+zS/IpLlY0A6dsuFFSOmL9hXke5RoxV8vhbbiub/qcfAxxAsIhgrNNpFHWk5zV8lNiOenb+VOOdB3NyUiTaOcYCv7aO7WxPKSlt8RPK+VWDRgDrp+OX6bBgUXckKJ574lqCC6MVnOlTsE04mMX7wCaq8h4sNJCJKK4VtJriTYeZqO22NCldZF4x0fpNOo12l+6rI2lfSA2jMaHCjQe4SdR+avvJm5yHsBXa9sY6g5L+i88glC4nE0COIYGnlgRommHZPdcotCkhLUROFEIHYFdFWhmLOYk8CdcbIr34GBtWSPZRy8Bg1nC00NTvyF8G46VU933YEQns5YZPnSj3Fz6UB4ULnB6XpPErgBGJC3BDL353p9lJOfB6JCHszv+jth4+Bqr56Mlz8MHq5lqaWorg88P5AJu6u2BW5/Q== X-Forefront-Antispam-Report: CIP:165.204.84.12;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:atlvpn-bp.amd.com;CAT:NONE;SFS:(13230040)(7416014)(376014)(82310400026)(1800799024)(36860700013);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Nov 2024 17:21:27.4330 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c240cc43-cc18-4e1f-d287-08dd08be99f1 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.12];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: PH7PR12MB7139 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 --- v7: * Whitespace * Add Armin's tag v6: * Fix logic error with PLATFORM_PROFILE_CUSTOM v5: * Notify class profile of change to legacy interface * Don't show warning when writing custom string, document in last patch instead. * Adjust mutex use --- drivers/acpi/platform_profile.c | 119 ++++++++++++++++++++++++++------ 1 file changed, 96 insertions(+), 23 deletions(-) diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profile.c index d579de1b31be7..a258f2481246f 100644 --- a/drivers/acpi/platform_profile.c +++ b/drivers/acpi/platform_profile.c @@ -65,6 +65,22 @@ static int _store_class_profile(struct device *dev, void *data) return handler->profile_set(handler, *i); } +/** + * _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 @@ -243,51 +259,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 Tue Nov 19 17:17:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 13880361 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2086.outbound.protection.outlook.com [40.107.93.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 074481DA116; Tue, 19 Nov 2024 17:21:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.93.86 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732036897; cv=fail; b=pk0Z6Ad3aA/7Y5kiXXHgDoL/uxjjgVbbt+ADjb2G/82eCnyX8yeLsX1iHrrPKukakCmWmFPwjWNPDX3EeETMPMmqjA8Ph91hinJQOwr7Nu0tPxHEaZYnSYJQLdy4jw2rSLZcdhyG+lPGCquI1JnvNZgtIlZV0iOVPYyRZKsmmAI= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732036897; c=relaxed/simple; bh=Ef7oQOGf2sOKgbZOMtFN/mM0DbbDnF1zOUyMqKgCTHg=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=HUbYlCUn5ciPv7PHGs7JjyllBuE7K6B7uopmeJgpG9kJrAbXg8EiZOzMHrroxkXwB//On7gJlU4BGBMSQe8OBuGvcEZQDa1XM0hmZ+MJ8EievkZ/0mVHRgD8kZNHFI343CmQzAXboubI8fh+GNjSDH5X/hcgzRI6oEzDUbGbrEo= 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=hHQALUwZ; arc=fail smtp.client-ip=40.107.93.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="hHQALUwZ" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=EIBDB850AgkTtmftts7wzgjnMvEQ+9i6/5nZwCrVEW1cn6gmzHi3v7Y5LhFRckIUV0kJBcFXVCMMocDgXie4kFPx16m8BLvxr7CSOUjMEgvR3+ew8Q3AuHNj4yQFMJv77wNMTifHSTqgwefQgF/qfIRmzJm6ADcn91Mnl7Ju07YqHfeJsG1N61XC2A2UI8NJpAyHd7SPI+kEVQPHcu4nSfdQIodETlqs09g7MMlKJsg/albOOO+aKOxSl9CPZyAtu2GATAZpUbv352FuZrvfMNEuXv8x8G8mMq9ufrrpZIP4wCQ1m/C+OeQHjsSecJDHZE19dXjyOS1IaF7B1e5y6A== 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=cvogErjJOwcVk46qfAaJGl6aKvOdsby22Z+cYER8yMQ=; b=fGLDQRw7LKwLi+rFapkKVOSZLk56VX8OVK1OaM+dE3faBrkNon3iLyyFew0STzxF84Gzl3MqnZsUa2yg7DueToQGjHIh9AqAxV87AT1GJYhujEg4gvBNGiazLvxFbwWI/tNrVOZb00kcdhcfDountls/LDBH5wHpZMs1N1msWKt4GiD01CEJ3FuGfsY8xWo0qMVK326d/L6NFVLnIRtXG6PxiFOzjrqXedXAGh7gUkzLa83C1gTPGlRAybRjExUca8ziu3xMKfnE+eLPKKGq50vguzl3APEv/lKwW+C3/G0oZlQgKvHO12WOH5SAUcmbzGv6rSXxSRVvYNN9DuwviQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.12) 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=cvogErjJOwcVk46qfAaJGl6aKvOdsby22Z+cYER8yMQ=; b=hHQALUwZfgpEBnhSyvfXAYlCspPqhvSHM0doWSPsEAXyYsEC2bQBFTvn2OzY9Q84Ux65HidN+Fr/tW3Vaf5WodNN/38HfvCcyfb1w6N+neuo2t59Qonk1ObGrkRYkpw2oPkFf9UdOPua9p/fuBBIPl7xltV/rpmfvmQVjauyZ4Y= Received: from PH7PR17CA0042.namprd17.prod.outlook.com (2603:10b6:510:323::21) by PH0PR12MB7790.namprd12.prod.outlook.com (2603:10b6:510:289::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.21; Tue, 19 Nov 2024 17:21:30 +0000 Received: from CY4PEPF0000EDD6.namprd03.prod.outlook.com (2603:10b6:510:323:cafe::8c) by PH7PR17CA0042.outlook.office365.com (2603:10b6:510:323::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.24 via Frontend Transport; Tue, 19 Nov 2024 17:21:29 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.12) 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.12 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.12; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.12) 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.8158.14 via Frontend Transport; Tue, 19 Nov 2024 17:21:29 +0000 Received: from AUS-P9-MLIMONCI.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Tue, 19 Nov 2024 11:21: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 v7 18/22] ACPI: platform_profile: Check all profile handler to calculate next Date: Tue, 19 Nov 2024 11:17:35 -0600 Message-ID: <20241119171739.77028-19-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241119171739.77028-1-mario.limonciello@amd.com> References: <20241119171739.77028-1-mario.limonciello@amd.com> Precedence: bulk X-Mailing-List: platform-driver-x86@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_|PH0PR12MB7790:EE_ X-MS-Office365-Filtering-Correlation-Id: 7f8c3051-13c3-43f7-9c59-08dd08be9b3f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|376014|82310400026|1800799024|36860700013; X-Microsoft-Antispam-Message-Info: 7TzWH9uXUfksOny6Q1afVG/MtUTkiRZaQ60NipLZX/PZRJkgGTiDd08eZ1UedK8dL2KVNpDqwLiANXm/aGtn3ypg337qgYJp6tnGjilW/KoYoBBjoEwjYVrkoQywNfSIK7zuaJBGYtO1p7wtdDGgJRonOX5mBetawBaV7O66Gg7j15Mx+qUj9xwack4dg+rHjXJm0emVnla8gV/E4jQtSLvVIrtKWtXEpHB1OOox7TgtaMHbvNI1zm1ZJH5MnuH7X/5qS87At8msHmcUxa/FrXSywGNBLsJOf0MQ/F7KV2Ljkg+xwhcG80k/pgKj2xq493SHYXD2roz3DtnvTXo+iHavC1Sz+I91aSPqAe3SEgyKyjiq3g9Sk9v8P85xGi9v2KQrornw8XQdXw0SrYzJsDDblDwHBar+1+tr6m1JAhXQxI7nLeacpHIzbDX1ryi4bYFux/4HYeEK8Eb/P6LdpwP07ypPIuCfd3tusAmmDdzVPoA1Ylz/wJ+nkesobUed3QULCUi0Qk9nkqiutz0C9qNPqGHL8+PKlGnDTJWN8hH3QPFZ+fWGXXt+SdU7rwsngBo3KWNKK8ZnG8SOlUW3tIhglX8YqFyLeqMLOkFEueXf4d2bgvA7K+ZmhGwFYwy5FWTE6tD+yxwcMMzDERKdseDrZD2gyXee/6XPrJYvVQW+JN21Lx9SjclWYb0zIYEPbIulCnVdBotj7TrNMP27rdEz7Xk5S+8A6foaUjezH5LcbSYwqrvS8fEreSiSpxtWrOuy+gXKvZa7KFna2tHpldAeox6JrI2k5qibbQlHgdBBx5xtQE7aUsgDCmKD4MV62betGVJCqUGzU9nqnCxoHxuzTFsON1hlW9Eu8r8LNq5UzDA8XUISai8+4rAEc0fFouT1oL/3mvUQNE7bQ++LQkM4xfF+U/6yAh1zPZMma1zTOeX92CSbP017fMPaRT2e6/ZghPPjrWd1m0bmhM12jw4r65mxXJ7JTPX/002vFf3JDFy559zJmGUaP/uOaIws24FaVMMxd1lpi6myFri08BZu+EubkJPgYnfRI/fersAWqVrxIY9mAyVTNH9KlXhJevihPbfl++9JLAcQAUMlueZLXLPSbIQCURm72Vg1z6TLwWtlcDOx5iPb1gQS71olR40P1AwJ83ImpLhxf+F6juUjqXbF48xd56aJj6jSifD2OTgRrlIWfhxwLsC2sD5b0xDwhtJAsoBLKkJUd/31hrElrkfIZqAsmrEcu3LvdSpiI+Gzrfvm+Bny4xdM06ix09e119yLH9c5DGqQQq7kF1Mj5D78BtYQFWC//QvZv7eq4s+oAKSYX/nzrcuwkw50sEJ0euYjrh+z6DtpzUehmKWJzIJF6R7UgcLBpdfdbOUSv1GNjgee9U+n+6ZTKdP1rTMqGjGDM5Vd1bt/wzlByQ== X-Forefront-Antispam-Report: CIP:165.204.84.12;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:atlvpn-bp.amd.com;CAT:NONE;SFS:(13230040)(7416014)(376014)(82310400026)(1800799024)(36860700013);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Nov 2024 17:21:29.6049 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 7f8c3051-13c3-43f7-9c59-08dd08be9b3f 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.12];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: PH0PR12MB7790 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 Signed-off-by: Mario Limonciello --- v7: * Add Armin's tag * Use _store_and_notify() instead of _store_class_profile() v6: * Handle cases of inconsistent profiles or all profile handlers supporting custom. v5: * Adjust mutex use --- drivers/acpi/platform_profile.c | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profile.c index a258f2481246f..ca997f4e9a5cb 100644 --- a/drivers/acpi/platform_profile.c +++ b/drivers/acpi/platform_profile.c @@ -408,25 +408,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 Tue Nov 19 17:17:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 13880360 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2044.outbound.protection.outlook.com [40.107.92.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 372681DA0FC; Tue, 19 Nov 2024 17:21:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.92.44 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732036896; cv=fail; b=YroDzWn7bX1SeUwqlLJZ6hmhfLgYFkZM7lo2dyrRkhJ7WB9nbWcS1KzCdapFn56M0zGgxxZQKw2i+84Jv8Egpct1S+vKotXF8H5YqN4HkmBOjZcSdp11RDWaVvBTW9ER3bo4IVzIf9BT89plgqRsiiagZWNRE3taias27xEwCqI= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732036896; c=relaxed/simple; bh=op0V9TbFKl0DZPBs9kLX+o10ntgPOBPf/FzMzaojh48=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=RZYeBdGxnBQrXyG+1oem7Xd6cehzgOd6rYq+qJqeICQwblySXtaA5yEyI1bzptYtJORTwCX3175VsYUQobTqtqPd4COaVLyhzSAVxyKOh+SY8+eUTmRgIhhAOqELab6Wdp3E+yo5DXmpm9ZrFHfcvOSylszzMVCQ9aauQ0PLIt8= 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=x6hO2YJp; arc=fail smtp.client-ip=40.107.92.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="x6hO2YJp" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=A5qWlj2w1k2sTSLe4DRUkJ2B++9FxtAFHexg3IfNAi9nMuTjeUABdniE5fhuFXkk8uiiLTlig94wPjT2WzNTYgew12xdYtOk/9fFnGjoeuycPUrRgQ7XDtEzj2zODEGgaMhlcR1kBtGFE8Humut4Dcjhy8lc1HC4C0iFRZSgnzVZ9lhS0OlSV3zQdwZmco/DPJGl4roTIr1bgJUHVVHUVS60n/S6JQd6N9g+T/i3o52EXlhibNDBr6I1KslBdWbi0Ugv5x4nDeyxV4jwj5Ix0djSyitlKpU3niLIuM975cgqCDLKWqEzaL75V7cP5cdjlNKDzS7Wilp3SP2t3gMQ+Q== 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=/Vn9zVmIz/MhRGI/WHjMYzAQOjJN7vyUN2I6tvttNBs=; b=NQLPFVJU4V96kRA5+iNEIQa+KeDI3dOXajI4ZkRG3TY4llRgE2pwWzYFB8jIU6cda9UnF9fRPVe6x+NaE6eC0wUI3mVHmM9rSlubQwPoGspqAKo8z3zrX91AeB+1nTIZwmdRE+LzMUUr86OR3zmTuI/bWl9KDMGU2FKB1n3IQTmdjCZwOsj5cnDst4IoU8kKanT8iDcLQRb0yHF+19cg6E3OBBCt6kAskkpy8czvLStsvtSCZb1Stv3KT+N6v3RjcJgIbsmLcYnEC13h/G4n1tv1LgiUe+OsX0QDwNjwIrfHAcHB1is3rWnFrx/WzFVHKsMkggZ7+BgGcBk5pl/pWA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.12) 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=/Vn9zVmIz/MhRGI/WHjMYzAQOjJN7vyUN2I6tvttNBs=; b=x6hO2YJpCm8Vgc5CDZWTvP4EC6GlJx2NcHyn/ju2nPJz0hoU1JWvF/lMLglkjTuyxdNg0V09+OQgrugvlc/NB90QCez5po0MGbDriZbUlhlCbuOtQma+6DaVwIy4EfByZyA9HnNmwa+1nnZmYhl+qxYwDQaOLPZXI4Yg4GxBRIM= Received: from PH7PR17CA0026.namprd17.prod.outlook.com (2603:10b6:510:323::19) by MN0PR12MB6294.namprd12.prod.outlook.com (2603:10b6:208:3c1::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.22; Tue, 19 Nov 2024 17:21:30 +0000 Received: from CY4PEPF0000EDD6.namprd03.prod.outlook.com (2603:10b6:510:323:cafe::3) by PH7PR17CA0026.outlook.office365.com (2603:10b6:510:323::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.24 via Frontend Transport; Tue, 19 Nov 2024 17:21:30 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.12) 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.12 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.12; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.12) 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.8158.14 via Frontend Transport; Tue, 19 Nov 2024 17:21:30 +0000 Received: from AUS-P9-MLIMONCI.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Tue, 19 Nov 2024 11:21: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 Subject: [PATCH v7 19/22] ACPI: platform_profile: Notify class device from platform_profile_notify() Date: Tue, 19 Nov 2024 11:17:36 -0600 Message-ID: <20241119171739.77028-20-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241119171739.77028-1-mario.limonciello@amd.com> References: <20241119171739.77028-1-mario.limonciello@amd.com> Precedence: bulk X-Mailing-List: platform-driver-x86@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_|MN0PR12MB6294:EE_ X-MS-Office365-Filtering-Correlation-Id: 696112f5-8a63-4bc9-aad9-08dd08be9baf X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|376014|1800799024|82310400026|36860700013; X-Microsoft-Antispam-Message-Info: hlkUdCYmENVSgZRLl5B288GbNX5kz8K6KfD/++d2uMCsrZHqyoVfbL/pH9xTAh5qglWl6BS/S0z1ap8swGEchLdNmQLgfN+b7QE6PIVWLXqi7doNxwM0rHK0EExcB67AqJFTzDUr2X68aEZs73BYRXGZVhra6fxueljAAExEucara5cqETghv65KOHzw6+rYIymKt4CFgPKDyBA25HVy+tC5FnGgAj1WUq/fjbROAmKannm2tjI1VPDvUdJu/63BWaUr0jHgoNF63eZom95rS0+WPVQd3CrZVBMWuRpwt0LwNO/rjsRhIiEzKf7gpoE1BjSshtJ+zPI6z/PbbJnAD7mg1S2CvObLZ1BmhGRzHEnhhgAexRLz3LShfzLInv68cIMEOVQ3lK/tL+yFZMz+T71cgpWHO5CgC3LCJaQRUCk/QrkVg5d0omRExaAKKJLa1aejMFV0OY7g+ilbGkP0tbflwepMAFVpdf3rVX2NsycujktpyWMgDXf37RhNSsmCauodanAFiS170sktWf5UE2c8oC1T9c9ewDlmVPkHaswFQcQvxNYO5xzgPYGFo1wt3qHVwdf/uDkUc3JUYoI5/n7y8MjRbsgWVMqo+6GYXvmtuGEdu70ZSVpN7DtNGNtc9okuKbW60KQjryDW6iEpbwPe+ynZw2addfyRe+v27DIizV1VL5raCdo0LemfNLHRb5ZMfPK56b1O1QuogyUYz+NGL98tY11IU4SEFxr8UB/JbIE81wZ4g9ND/SK1397la8Irs9BKZVu6lx3HRdByzujPwOEOOCF7dq+RjyT/GbwCfIg+OoGTXEcHDHgeNHIl3R6i7VM1wQ2zJM9rZHauZqdC+VDgs+FMoT+ftdTvD1bWQ9pO1lPEZevJLUeW1EVNzp7eDr0+mHQHsmMmnNN8UQeYswZFOZyOYk2/qZP3y98t4vrdvpshV3RmI6D+KfcWtOlwLy+dTybz4UGym34RJBvejRYPbF9JY/+l/Wsjz4A6m8f2YxX5YXVQDZnwBGgYzF+OhpvfO5cQQR4incWJD4MprnmkQ0Q80siARs98kKJCmtY12OMe+F/il0irKpsYSDlCLqE7Tf8k54fii+GpL8NWs4m7iFQ12YMZQviSOQp+2XssZtAdNTmNsGJ4tWUjk+DuY7OqllCIm96tqQDoJabnQvymkG7Jr4PUOryCo+XdKPUqLjoNZB2dRH1oF6Bbkzm7ZMsd/+/VJP7pKuKZu4oesXUCRoRR0gW0l9C8p+YPYNiSO30ZA9ABJZtEV0fnIauAPssBl6s4QPCIdO4/+Xd4RDfO+MpaCrvTKLg4CNFn3p4nBmliK0RiAuXOo24dOy8VjgRbO6RxZYE4Y2SxE+k+duF2h/R0m9ClVTM18/zkHESiPaqZXbqMSOLDxs9gSG0jZuZwtqI2x5M0Ig/9Mg== X-Forefront-Antispam-Report: CIP:165.204.84.12;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:atlvpn-bp.amd.com;CAT:NONE;SFS:(13230040)(7416014)(376014)(1800799024)(82310400026)(36860700013);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Nov 2024 17:21:30.3549 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 696112f5-8a63-4bc9-aad9-08dd08be9baf 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.12];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: MN0PR12MB6294 When a driver has called platform_profile_notify() both the legacy sysfs interface and the class device should be notified as userspace may listen to either. Signed-off-by: Mario Limonciello --- v7: * Use class_for_each_device --- 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 ca997f4e9a5cb..e88b355a72112 100644 --- a/drivers/acpi/platform_profile.c +++ b/drivers/acpi/platform_profile.c @@ -402,6 +402,10 @@ void platform_profile_notify(struct platform_profile_handler *pprof) { if (!cur_profile) return; + scoped_cond_guard(mutex_intr, return, &profile_lock) { + class_for_each_device(&platform_profile_class, NULL, NULL, + _notify_class_profile); + } sysfs_notify(acpi_kobj, NULL, "platform_profile"); } EXPORT_SYMBOL_GPL(platform_profile_notify); From patchwork Tue Nov 19 17:17: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: 13880363 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2079.outbound.protection.outlook.com [40.107.93.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 495AF1DA2F1; Tue, 19 Nov 2024 17:21:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.93.79 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732036897; cv=fail; b=JIYZP1grE+jedfFiW/ZRtSW/JBV13NdUXuHgF9bHnK0xpKnXzDpCVNssHZuJk9z5ULlJnjD4nWQGsPtMFE5b2C8PxQMCLk/cvzeaEuP5pUDMKVnbORxGDsQoPeZ5GhXrYEI9zpK0Mgvm5fFFG62oFDNt1xicLxvYio61Goc0/ug= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732036897; c=relaxed/simple; bh=tPk8iBelMkozwVP4JFH/dleWnueKOlHY6NqDmg11oOs=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=sWSGv8b7Xue6JIbr0E1PA2mVreqpAAmD2LsSuIC22jqEeTyr8GczayQwVmp+JofOEDEGRTRbg+/2siPRDPbGffOFgDUajtw8wMy7aX28KYGI1KrRq3dA/O7GrYKlYid1l8T/NXBcYxceG/yLdmqLRnItksN4t7B82zhZVva1k6g= 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=0+a4u+3O; arc=fail smtp.client-ip=40.107.93.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="0+a4u+3O" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=sMIxtv5F4lBCpVRzUuD7cMEjYmNPc33gESPv8p52DfkZFPh8tPdIePCL0C+ksbT4/Si1qPNSvEEeekxBP6+O3O7RXRRi6OIUGor4FPjWl7bwPsLtsRuFtsUo9vE84FIGyHhgiS4GU2qcM0byeSdYGegVg9IKR1yeAWt/7D7FtK/6Z6K5mvsR2xPUQuDsEEgCBEOeODEFeE2mU0MXuS/nZ8wR6e3/RbyyiBoXP/79951GcRg9T8hAHYfW4SfLVlcKIujq/XiKrleVKyO5ufDXJ3RCpx7RaKE80ItYWS9C5J2afmGwI751Gf27ZzPZWH2RmzCCmRAYTPrIsFtMjjAKXg== 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=Gdw4LcMjSmWQqzwh5N3XehtHblWWjBa8rpF+/nMuPGw=; b=PVI9GEukSHWDD1AUOAhdzF/Y9JGZH5YcJLpbb3HY+g1O0HeCTndA21vvrWb+/rNC6dzNNsw7opPjQuoIPPHlU/UjzfuwITI7E3bmLZzBODhQN45qRZxzFRmEG9arfwA6M0pwVlj6dgG/NW/D3EFh7Zsj5jx1tM7d0LKgS6CTI68VR1iwRv4RBRiLF2xZBZ6dIA1QgzCKZFxdUJNP+rPpUuiAPQ3NU8hxeSdixoLJobw8UEtEiZp7tgbCTJwLf1gEwIcc2M7+y8dw1FVzidZ3wb70bafIUSovLlu+fIF4vAdoNYfmkbNcwyZ95OysWeRcrGuvCi4/gIUYZLFJkCbZOg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.12) 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=Gdw4LcMjSmWQqzwh5N3XehtHblWWjBa8rpF+/nMuPGw=; b=0+a4u+3OnOgOiBRVFpA41Vd20k1OL6bIsKcIbi5UjpjuaZ1q3nMA2PJi9Xi233wgvdVGcLuEUY3EHuAsNs4UAWx7vK8CZY7kLy9NKwrQY9GBDVf0W+MbW3uXDIFs1zUhk0tzIkQOaFh5ktxFrfbwpgGTovd2ph7TqG15vtU7hRk= Received: from PH7PR02CA0003.namprd02.prod.outlook.com (2603:10b6:510:33d::31) by SA1PR12MB6800.namprd12.prod.outlook.com (2603:10b6:806:25c::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.21; Tue, 19 Nov 2024 17:21:33 +0000 Received: from CY4PEPF0000EDD2.namprd03.prod.outlook.com (2603:10b6:510:33d:cafe::37) by PH7PR02CA0003.outlook.office365.com (2603:10b6:510:33d::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.24 via Frontend Transport; Tue, 19 Nov 2024 17:21:32 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.12) 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.12 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.12; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.12) by CY4PEPF0000EDD2.mail.protection.outlook.com (10.167.241.198) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8158.14 via Frontend Transport; Tue, 19 Nov 2024 17:21: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; Tue, 19 Nov 2024 11:21: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 v7 20/22] ACPI: platform_profile: Allow multiple handlers Date: Tue, 19 Nov 2024 11:17:37 -0600 Message-ID: <20241119171739.77028-21-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241119171739.77028-1-mario.limonciello@amd.com> References: <20241119171739.77028-1-mario.limonciello@amd.com> Precedence: bulk X-Mailing-List: platform-driver-x86@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: CY4PEPF0000EDD2:EE_|SA1PR12MB6800:EE_ X-MS-Office365-Filtering-Correlation-Id: f7072b11-5d1b-4295-8829-08dd08be9cff X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|376014|82310400026|1800799024|36860700013; X-Microsoft-Antispam-Message-Info: mAeT9dXHfaSZ9oBHtIGsi473jTnBGCSLDgqIbRPc3CKj/gpKNcuw/ropT06fhKywW85CG5UWXfpIy9cb0w+kaTy8Z4m0xWaDQrIJBKA1oc2MJaPtWy+8gOvk31EAF5p0U7+ezOYyuX9DYXGtX1OKWH1gJO7XIapbaTGa85GDBz3qQh0jA7BeOMErGD/xk0D1iOdLx9LPoPSCfOF44gw8G5gXYw6s5AS4qNlte4+sLKRhLfJm5iRlCUN7Yr6spX1JjemdMEoU4AcyMK14NRQkjvn/rO7ojapyI/BNjpH5D9WrvTSnq+ZcKhvsgPEsMR+59pnA5OvmqQJhHun0l2XYRjYScYSMRDJebGSZHAvNhPOch6L5pLzBBaKt8E1eixjtW7dcntcQgMWxsYN5Qx7hbWM6hRe+ceNlhsA40ze9tLRqr0FU+MLKC83QM+NquVxJHmMo78RNsmVQ8NBLIiS8ADHZhAb2yhOG6LiMkPeo7BAwQ/Ol67tCdyGQcnklkeM0E6yG6wSceaOmucZ0QdVO15QHCLxEC0RzTtkeFcKOn4X5ZpuNeeHinQWVofNbvgB6euZHaZpa2jY0W7vjFgtj+48V2E+SdkzU1ISefeX1Uw4rQLTcdruwog72GqJ3jpoVWUvTJiu6ThGg7plnI11T8kt6r5kd03XcmrFdpb6IB1ENL/DQ0eagVHsTfkmS+4YHSYWTw8pHQHATy9XQ2VWj8ar+Cm0AJ3k/KojyUA0mQf1YhOifm6GuVWhWX870mHSwqSeMkbO9wHCTC4jAp4Ny+kQAXFa3ozBzWBW6sKec2JMQIn5NDLNCpJaymPorQTAY8c5O4xm5C4OpqThYHeMtO0HLjIC87B0XgaTJJkV4pLZ82k606M5cQ1xKXa0xfTwAaXGWmVNFGxflDWXgKSZYtrNnkFy2tU78ujrVNXf1fEafT4sLSTKYEUhRm6bAMQX8OhYMLhu4x6Pnb9rXpUNEfCupPH0KvXKGTd30u0ND7w7q/kvhFyltwglabDge6sz9Gae0DU/T3xH6vLK0uhLKLP+1saIFppfibPeep2IaIUUnzDT1f8eC11fVAZm+E1VlnR4PicEaIWo4+DSq1aKxqH+J64Gt+SGueklgTMCcwWev5cSGfQcryTjTGhn9K+DshiLUZJnDsCaqFjWImmTkaqJssb+8rVnzoaLJxlxlAqQ3hNc4O/ox46ZkamKShkHF7jpN3IpmomqlRtLWqJm8cWn0f35406WICuBOds+w0083/bxUmy+wQvNYuh5fEvjmkXOLQ09HPuJFbC1t7IaGdIyCxIOKBo3q+ozNv2I6HriXrScRPcblCtwhb5u1ZcIk7fHosL78g7VgnaYIzQ1w4iAs2RvFBLf4RTnBrl8jqjgxU0eTD3b4YOHJiXHirbJCygsw58/+/4adogcIPHM0UQ== X-Forefront-Antispam-Report: CIP:165.204.84.12;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:atlvpn-bp.amd.com;CAT:NONE;SFS:(13230040)(7416014)(376014)(82310400026)(1800799024)(36860700013);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Nov 2024 17:21:32.5716 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f7072b11-5d1b-4295-8829-08dd08be9cff 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.12];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CY4PEPF0000EDD2.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR12MB6800 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 --- v7: * rebase v6: * rebase v5: * reword commit message --- 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 e88b355a72112..7d774c43f4fa7 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[] = { @@ -400,8 +399,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) { class_for_each_device(&platform_profile_class, NULL, NULL, _notify_class_profile); @@ -465,9 +462,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); @@ -483,8 +477,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; @@ -492,7 +484,6 @@ int platform_profile_register(struct platform_profile_handler *pprof) return 0; cleanup_cur: - cur_profile = NULL; device_unregister(pprof->class_dev); cleanup_ida: @@ -507,8 +498,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 Tue Nov 19 17:17:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 13880365 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2081.outbound.protection.outlook.com [40.107.223.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 C25F31DD88B; Tue, 19 Nov 2024 17:21:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.223.81 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732036901; cv=fail; b=qzB96egYEfCxLn3UM1EqnS3hVYiB5gux0obooEd0ZddEQl5cJJguI4uQoZS1XcXO2nkWJUMb+Hdc5po85aWYvfBrn2XPwdxVllTl/qS6DVK8j/1r8tQqEyQn7l/NWCE9rHo1qJsqbh/A+sxsdXNUNBEoZTiyd83shD2aL4Osqio= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732036901; c=relaxed/simple; bh=+bdiJ1Eyfn9MTcWLW4JH4T1uWT0phudmlVUuiFZMgKQ=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=MoLgyFPP6mHiOKm9OAqBvN2bEKYBSeqakdEJ5rpX7LMZAMGAevmVbwrKVjgRpLKU0ZuGMVXHgO56w8K5C389ADAEScWaTk79+fjOD//qCLxffnqWQjIg2TlRCQISY+57CpAjrrrwLJqnUMtFljN+ZYEl8Gs7gnhyy3pCcN5InLY= 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=1/69Iamr; arc=fail smtp.client-ip=40.107.223.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="1/69Iamr" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=pdq5/xnYLbfbQaI7k+12aoRogOn719rY3OqWAlAxObP5dORDVWF3mY+xK0sqagoyl31DJ6k25MObw5BYutPlcvGA8/3KpIq3zwuGWOlJ3mnshDz6W41E4tmJd/wcOPxeJHJxseN9WgdBksLMUQPTz3iQogUCd3FPMJJRJLyEZo9gUsipQ4EHVY+FpphQkgdf/q7ydQjjbLQFKKK3DLHQ231B4z79tQR0yVDHK0LOUxa5wCkqpAn9eVtSIprErI6DXkqWRLE1wFcU/D8V/gFSkpfKBLW3ZDBbKrzVoN6GeGi8LwsTvCoi9z0w1s42K0s32grC6WNs1KHtYdiHkAWb6w== 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=mE5xib2maNaIrlY03QYSAc2xN6cAxJyeeTXImIzPjlg=; b=quLt7Flxk6aoHRLkqVSSq5oGUL7Q566d6cV6eCwxC84ftcpBSfD8ymodn67J7HglUEhGNuqRc5Hkgs29/bNitWLha+BcmrGH3RK4iQb+oVelJPy7AQS9ACjrTDUKra7bwjwnf3lxWJGl66p1Nx3Itd5ihHLWO9VSRmYu6eO4SnXfsL5WLoVFwqDALNuHmccs7MNb4uGwntSo5h7ODzKxrEfOK+R/rYbmeQwslo9fPDMYd2Us/GjwtMGuV4JR4sDRUBiLjdzu+kCC/RUXnFmR2KEKB0fk2F349ER9xMhoaIHKGMxHUrrTvyBS7Hl/7eLNW64csZFvWbGc4vvxlWluVg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.12) 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=mE5xib2maNaIrlY03QYSAc2xN6cAxJyeeTXImIzPjlg=; b=1/69Iamr5wxi8wf7I7e9tw24EldmH6hHFZ7QWY9y+yEr5YtX+Xlh8ZOJ9v1X0Vp7f2LEGtYUr8I2+12NXizF842eDFCRuCzlia+v2STbkWyrek8dwj/F+Rbe/7arGZsmqkEtR4OIZPen7PpN7zN1Ll/NKrvcTFkZ4ou4E5Xi7tA= Received: from SJ2PR07CA0010.namprd07.prod.outlook.com (2603:10b6:a03:505::27) by SJ2PR12MB8035.namprd12.prod.outlook.com (2603:10b6:a03:4d3::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.21; Tue, 19 Nov 2024 17:21:34 +0000 Received: from CY4PEPF0000EDD4.namprd03.prod.outlook.com (2603:10b6:a03:505:cafe::20) by SJ2PR07CA0010.outlook.office365.com (2603:10b6:a03:505::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.23 via Frontend Transport; Tue, 19 Nov 2024 17:21:34 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.12) 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.12 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.12; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.12) 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.8158.14 via Frontend Transport; Tue, 19 Nov 2024 17:21:34 +0000 Received: from AUS-P9-MLIMONCI.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Tue, 19 Nov 2024 11:21:31 -0600 From: Mario Limonciello To: Hans de Goede , =?utf-8?q?Ilpo_J=C3=A4rvinen?= CC: "Rafael J . Wysocki" , Len Brown , Maximilian Luz , Lee Chun-Yi , "Shyam Sundar S K" , Corentin Chary , "Luke D . Jones" , Ike Panhc , Henrique de Moraes Holschuh , "Alexis Belmonte" , =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= , Ai Chao , Gergo Koteles , open list , "open list:ACPI" , "open list:MICROSOFT SURFACE PLATFORM PROFILE DRIVER" , "open list:THINKPAD ACPI EXTRAS DRIVER" , Mark Pearson , Matthew Schwartz , Mario Limonciello , Armin Wolf Subject: [PATCH v7 21/22] platform/x86/amd: pmf: Drop all quirks Date: Tue, 19 Nov 2024 11:17:38 -0600 Message-ID: <20241119171739.77028-22-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241119171739.77028-1-mario.limonciello@amd.com> References: <20241119171739.77028-1-mario.limonciello@amd.com> Precedence: bulk X-Mailing-List: platform-driver-x86@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_|SJ2PR12MB8035:EE_ X-MS-Office365-Filtering-Correlation-Id: dec3c9b0-0bac-4afc-0781-08dd08be9e0c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|82310400026|376014|7416014|1800799024|36860700013; X-Microsoft-Antispam-Message-Info: efuexn/vu9BtnldNg8eCRyNn4GMhv8vMjy/6FqgscQn4/nJ5Xgq6/5QNm2COQtfqOrnqAGPnyZRHWazMkI3Qimo8AlYIXZduW/DFOI2NQaDkPdloqACd1eYSFYxtWp4ZMUiyN3P5mBQatJnHxVSZoNrIDl9dWc0O2rpJbOhEHDn3t67966TKqIDCHx1JVuNcccJeh03bJLKcofKP3M0sJG/pAWGxgU9SK+jP9bEGQEGQPu8J0uQCQTd4x/jdIEG4umGR/unb+buUt2P69jQtQ3O4s90BfDxNYzSpSfxCPYqaeTyANja1R/opDGhEMsV+eP2EzGw3cTjvuNs+KuOw/VRz6ciUWWdUHKSNxULOFQMVpYwHisxWW2kaqhbx17SRfkJJLrGmtLa7tv2Tn9BwMe/aAtuxb1TnBe3lze2kHr3uXKUJeT2iyo8WngFh4CWthQDFxrzNPIv7hPPleG2PuXWs2GgtKRfHSB5Dq7iG5YDw1W54DwV25wxlWWcgrRTT+2+62EnRF2kH4fXv7eqWmqeF+8ZPCqb0v5YmrgY81sB997lQNeg4dEQzy/uXnvtZVD7QvjvzuQ9ZsKkwcLOMwUBGXVk5K78N5mJjy85ONAzpZ++rr9x8CjkebmukzJYqFbEaWYX3ChKH6ZCZFkLia533UeiAkW0DXvTnT5GS2TJfK8ljKVhY50iNom29Ehm7PM4Oj+FgOCticzUB0G7Hfewi6uYlb7kkxVndXPAKILfrZ5/f0VXeNKWN7Lh+hhj4+nueQV+V65vnypwFF8jWe7ICqsLJPxsjMYpl4ZooDpw3RecGACcPjl1YprxGL2FalbAI9rEKNImyJJcqEYAqMj7dnd6rBQN5H5pakgVsSb1lI0uKFyLIC3Dya36lysMvLvXeLjzOh6NfcF2yL8lUdgo5Wyni/XpKbO6RUoM8mdQLEWIuf11IPPouwfPXZpkY5kVFyE80YBfFA3zQEll+n+X7X97I13Xs8BqqMH4tn/3SzQ/wgLBqLS6JdwsAEtj/wbF6KM9Di/efRfJqGDq1tBZ4zMNthPiI9erdMUZbK3MWnLjZzEF16zewpqTmhNHk+04hiBJoHwXe9AHuEfdsWGlkdCYb+6kLIHM4KmbnHK8fhNJHah1d80mO+DmehvnC3nx9phS9bz5CsV0LTcskVmvZ7fnffF/+1sprrAiXyoADAtuHSu5JTDWCv4CH5kEXZ7h+NAuisy8f8m3I487XFVWW/kHpVs9xvGzn343byKdXDKiRv6eHwiIjMq77KmPoryCzY4nvNWVdRQveDCHOdRHDdxDnSSzumbKP6V+eiE/qpMiVxXm+o1We4SyzhMPdfA6lZuJGiJqnnT0ixEqO0nJePSEHUMlcnz50VJjBMrUTWS5DPVa4eO0+aGUscHGXha2bC3VhIyDtrEURGLEL+Q== X-Forefront-Antispam-Report: CIP:165.204.84.12;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:atlvpn-bp.amd.com;CAT:NONE;SFS:(13230040)(82310400026)(376014)(7416014)(1800799024)(36860700013);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Nov 2024 17:21:34.3000 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: dec3c9b0-0bac-4afc-0781-08dd08be9e0c 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.12];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: SJ2PR12MB8035 As multiple platform profile handlers can now be registered, the quirks to avoid registering amd-pmf as a handler are no longer necessary. Drop them. Reviewed-by: Armin Wolf Tested-by: Mark Pearson Tested-by: Matthew Schwartz Acked-by: Shyam Sundar S K Signed-off-by: Mario Limonciello --- drivers/platform/x86/amd/pmf/Makefile | 2 +- drivers/platform/x86/amd/pmf/core.c | 1 - drivers/platform/x86/amd/pmf/pmf-quirks.c | 66 ----------------------- drivers/platform/x86/amd/pmf/pmf.h | 3 -- 4 files changed, 1 insertion(+), 71 deletions(-) delete mode 100644 drivers/platform/x86/amd/pmf/pmf-quirks.c diff --git a/drivers/platform/x86/amd/pmf/Makefile b/drivers/platform/x86/amd/pmf/Makefile index 7d6079b02589c..6b26e48ce8ad2 100644 --- a/drivers/platform/x86/amd/pmf/Makefile +++ b/drivers/platform/x86/amd/pmf/Makefile @@ -7,4 +7,4 @@ obj-$(CONFIG_AMD_PMF) += amd-pmf.o amd-pmf-objs := core.o acpi.o sps.o \ auto-mode.o cnqf.o \ - tee-if.o spc.o pmf-quirks.o + tee-if.o spc.o diff --git a/drivers/platform/x86/amd/pmf/core.c b/drivers/platform/x86/amd/pmf/core.c index 745d0e013a330..44461f2f35e82 100644 --- a/drivers/platform/x86/amd/pmf/core.c +++ b/drivers/platform/x86/amd/pmf/core.c @@ -455,7 +455,6 @@ static int amd_pmf_probe(struct platform_device *pdev) mutex_init(&dev->lock); mutex_init(&dev->update_mutex); - amd_pmf_quirks_init(dev); apmf_acpi_init(dev); platform_set_drvdata(pdev, dev); amd_pmf_dbgfs_register(dev); diff --git a/drivers/platform/x86/amd/pmf/pmf-quirks.c b/drivers/platform/x86/amd/pmf/pmf-quirks.c deleted file mode 100644 index 7cde5733b9cac..0000000000000 --- a/drivers/platform/x86/amd/pmf/pmf-quirks.c +++ /dev/null @@ -1,66 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0-or-later -/* - * AMD Platform Management Framework Driver Quirks - * - * Copyright (c) 2024, Advanced Micro Devices, Inc. - * All Rights Reserved. - * - * Author: Mario Limonciello - */ - -#include - -#include "pmf.h" - -struct quirk_entry { - u32 supported_func; -}; - -static struct quirk_entry quirk_no_sps_bug = { - .supported_func = 0x4003, -}; - -static const struct dmi_system_id fwbug_list[] = { - { - .ident = "ROG Zephyrus G14", - .matches = { - DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."), - DMI_MATCH(DMI_PRODUCT_NAME, "GA403U"), - }, - .driver_data = &quirk_no_sps_bug, - }, - { - .ident = "ROG Ally X", - .matches = { - DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."), - DMI_MATCH(DMI_PRODUCT_NAME, "RC72LA"), - }, - .driver_data = &quirk_no_sps_bug, - }, - { - .ident = "ASUS TUF Gaming A14", - .matches = { - DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."), - DMI_MATCH(DMI_PRODUCT_NAME, "FA401W"), - }, - .driver_data = &quirk_no_sps_bug, - }, - {} -}; - -void amd_pmf_quirks_init(struct amd_pmf_dev *dev) -{ - const struct dmi_system_id *dmi_id; - struct quirk_entry *quirks; - - dmi_id = dmi_first_match(fwbug_list); - if (!dmi_id) - return; - - quirks = dmi_id->driver_data; - if (quirks->supported_func) { - dev->supported_func = quirks->supported_func; - pr_info("Using supported funcs quirk to avoid %s platform firmware bug\n", - dmi_id->ident); - } -} diff --git a/drivers/platform/x86/amd/pmf/pmf.h b/drivers/platform/x86/amd/pmf/pmf.h index 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 Tue Nov 19 17:17:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 13880364 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2048.outbound.protection.outlook.com [40.107.236.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B8F8B1DD885; Tue, 19 Nov 2024 17:21:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.236.48 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732036901; cv=fail; b=nxLtkrHJ1Lw756pvacd0/v4xgLZ4eTNDha/GoAvDyk3if+RMDIfWjF5ighCi1apEoXZWvFsJUbpiWQRiQbi7IAPhB9cRlXuNBPCLSIN6QRH33dSC1q423/fvw9EXm4PzVwsj/XuN73y+xNMspa9mTnOgAIPboDownJQwvOrb4TU= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732036901; c=relaxed/simple; bh=/ijD+PUIhicssB7moXneLFJ/twRbt+uNOZkim5O1JiU=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=N6fhI5uzKnseO9/jhgalbbNdh+W36RcTgSHzZ5PHyaCsMdN7qQxKqV3+5WDJUBlZYtEDB2LKgh6U+vqF6yXcf54Kuvf3diKryd2h5VyxacnaBEeRe+n+g/5ThQDQHjFi8C8mn+Zg47avn81E5VXNBXa+2KB59vuAertICdFQyjI= 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=XOrnoCeK; arc=fail smtp.client-ip=40.107.236.48 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="XOrnoCeK" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=EiS6MEI+dNMpYjeYKRcxJSuZI9092036lt5KuuHHPffiPJEkV4366uqilz7zReOcPhB4vhkp3sDwIHGGFwKgzp5RaLjKuYX5BbqBNITl0xWD4TlTGi0GqHyYuOQ+OgqCyv8bnx/LT6kfzIKwuKz6zjEsbaEZgqU88IxuKZg0fELw7iRMywtix4kR6pNVRsn1XM17zcv4PgueYCeHRoLXdVshlizFO9Zl1Aga/PFEkKFG381NeuROAxnN6RABteXp9RnOQdq/4aPUQmdujDJKInPzLPWA2OXLaHK4VihPb/LCSAzP42/RYNAOxSmxiFMNgxsP/ksgbh/WwOWLQCY8OQ== 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=4AzDiAVdPZo1X4zMIDEdTxASEFf9b61AT6G4X2TX4TA=; b=m+h0ldZE69dK95mC8oXZo8UEz+ZP5Nq2g9F0qKikUtdzKudkTg9t6LNwVbGLtEUV69APLthzUFMfDMysitAbFfUF6X/PFjGF+fFVdacfniLR2ogrIwZQlm/NEwixDx6gwe8osk01su9lrlslWrHyAzmWrBcNTFGOoVYWPXHhkcE4bLOoICVhJoXDD8CfAGVxM2tZKEigOGKeIBxKVpjL1/t/TZhv5yHoKP4wsR159bdV8WaH8OShabC4ENFn/MB22oJ5coPyUAOjkYWQKj7TWRQvBYfLSIJu4Zut8rHN1LI8tv+9JZn+PPIqnsyHMkjGq6h2e3Z9wfOfcyFcWF0i4w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.12) 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=4AzDiAVdPZo1X4zMIDEdTxASEFf9b61AT6G4X2TX4TA=; b=XOrnoCeKMZnh1imad37NdUAs9yCRLNMvy6ypNHk0tRjH15qNiLFVwSfoe7XyWvDifbmJhMfNrzYPmBYZinkqAygPvudnLMLIrLv22zIN3eOWkF2KExCeJ97ivcXAsud3PTzYG1D0SfYZdw37USxuU+9UQ7VJ6GeBlXM1WNp9yW4= Received: from PH3PEPF0000409D.namprd05.prod.outlook.com (2603:10b6:518:1::50) by PH7PR12MB7377.namprd12.prod.outlook.com (2603:10b6:510:20c::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.21; Tue, 19 Nov 2024 17:21:36 +0000 Received: from CY4PEPF0000EDD5.namprd03.prod.outlook.com (2a01:111:f403:f912::1) by PH3PEPF0000409D.outlook.office365.com (2603:1036:903:49::3) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.24 via Frontend Transport; Tue, 19 Nov 2024 17:21:36 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.12) 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.12 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.12; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.12) 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.8158.14 via Frontend Transport; Tue, 19 Nov 2024 17:21:35 +0000 Received: from AUS-P9-MLIMONCI.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Tue, 19 Nov 2024 11:21:33 -0600 From: Mario Limonciello To: Hans de Goede , =?utf-8?q?Ilpo_J=C3=A4rvinen?= CC: "Rafael J . Wysocki" , Len Brown , Maximilian Luz , Lee Chun-Yi , "Shyam Sundar S K" , Corentin Chary , "Luke D . Jones" , Ike Panhc , Henrique de Moraes Holschuh , "Alexis Belmonte" , =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= , Ai Chao , Gergo Koteles , open list , "open list:ACPI" , "open list:MICROSOFT SURFACE PLATFORM PROFILE DRIVER" , "open list:THINKPAD ACPI EXTRAS DRIVER" , Mark Pearson , Matthew Schwartz , Mario Limonciello , Armin Wolf Subject: [PATCH v7 22/22] Documentation: Add documentation about class interface for platform profiles Date: Tue, 19 Nov 2024 11:17:39 -0600 Message-ID: <20241119171739.77028-23-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241119171739.77028-1-mario.limonciello@amd.com> References: <20241119171739.77028-1-mario.limonciello@amd.com> Precedence: bulk X-Mailing-List: platform-driver-x86@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_|PH7PR12MB7377:EE_ X-MS-Office365-Filtering-Correlation-Id: 6c272c68-6453-45b4-46da-08dd08be9f0b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|82310400026|376014|7416014|36860700013; X-Microsoft-Antispam-Message-Info: 5SPm2S8EHlrzBwDV6HQmAmR21vVjw4TnDSN94dlnya9rhbEM/nkRuCxdAoUMJ412WxrjGiABZPKhck8vgbSiQ9ig4y+0vP4Jolpv9yRuvk7GSypaDAx2zypQgeNucBK4QahdsUGPJ8EIZRWhlmA9O1yMzuypCoW7uKS6B1bnSr7kSl9SvvniaGzfqulSqlYU57MaI6oIKvp3yMXm7ug/JfSb8OiL53e9JGkmrUVuuSgF/sM9cPh+2mcgm2n08t+WsRxhGaYUnq6cXND0UU7FzAaB2S7x359dFSLUgdPCqScDiZhcpjzJjf9M0qqJlBPMh4XU7xUMSiaAyFoNGgqXrFbfqcd6iR8Dgl+ELzWG8Cy4VIci2IR2kpGPIQ1iM1y1uMKV+cY8mkR6m7hFwlsQOROAewVDa8xz3qU5qQnxxd9/KEs+t7YRpibjVeeALz8Fw/oLPuKefGOYJhnynj80Ar6uTucO9BUUXi3g7meSl7o3nYZwdP+wQW5WZW2wxCCl1gsX0nAfPfWvmCXxFRihb3XX4azMx4+ZVDLaxci7k7exL1lklABkvwt2/Pk5FCe1PSkZKRTfr+cCrJxFmFsncDQYhatYTx46iXfQIqxFe4E33eXusy+wBlav/TUEFQ//kKzCv/9hwuS9xyVOvs1DvDTHI+FTRt29Etjc4PbwVmWmyc5qiToIVTsq146VIAecqP7ZbTjSOFdNf1Hnk9tkhPnSXn9ACqqjyvyReTlaaJ20UgLMx9/cOwVXp18oilFBCys+JJ8yvG8mpdhdYQedr6YNlGYiYoYtSvpq/7MsbD+S+Nb5mYHppOW726gXKnLnL4ENv3EiMvbAsU2Qil71wakb6WZVpJcFI6HjGvdh4AXGHV+wsm9J092KGrLRRAy9p34U+7LsvwTkZLk8m/V/89gLKKBVsx5jcimGxYS6yXhn2VKovMYJNyVECCL9rxzrKLr+hmCxtfBbDiW1crSKqSS6YKPijiZc8GQJvpq8d8Ytu83PfrGm3xprBHHIP3gr95YPjXM9mDyJxPBIyvqu5jmzjKNFTxyGI6QgPCdEThnSOhBpWk4kXae4bbfhuc9BAAeSUcHr5DzZnJsVok/9/F/4bLn/NGKWMWGBrDOQsVuRlqmuRvC9G0Owch2dP0MW8OtdS/IxyQesHJkNIBldmQhKlKmYXM3A0EJXgCvxuE5RIuAftymhRrYDz2Nht8XNer9BMzWHiJuxRWNgBt4nBB1e3ZVIA/WPeHrBuRwRr1HaIaT2Pspb2zZA3Z0BrquO49RjSW0QDzzHZgGmsAskVcgyO6pQZU6KWRhNgLftfZ7WMxHdFe3w7ltRXGoGKz5DJ1sCNeg8FNFZs2FLMhr8Gk4FRNOS+Gra5PW9XusFGBKgszOXqHs3gOZHcweWIhszjy5Blr8ZmVfMYsM4L4oLqQ== X-Forefront-Antispam-Report: CIP:165.204.84.12;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:atlvpn-bp.amd.com;CAT:NONE;SFS:(13230040)(1800799024)(82310400026)(376014)(7416014)(36860700013);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Nov 2024 17:21:35.9728 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 6c272c68-6453-45b4-46da-08dd08be9f0b 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.12];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: PH7PR12MB7377 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 Signed-off-by: Mario Limonciello --- v7: * Add tag * Add description for name attribute v5: * Fix some typos --- .../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.