From patchwork Tue Feb 6 19:33:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Rafael J. Wysocki" X-Patchwork-Id: 197626 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:168b:b0:106:860b:bbdd with SMTP id ma11csp1770711dyb; Tue, 6 Feb 2024 11:34:10 -0800 (PST) X-Google-Smtp-Source: AGHT+IEpQRGDEoMNh+9iONFNn7caad1SImLWZWUJZGKzGVqL0m6acWQSwczLjzve07eTGT2Am3aY X-Received: by 2002:a17:906:e1a:b0:a36:5e34:3a34 with SMTP id l26-20020a1709060e1a00b00a365e343a34mr2344408eji.69.1707248050393; Tue, 06 Feb 2024 11:34:10 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707248050; cv=pass; d=google.com; s=arc-20160816; b=KOTrtNJTjeeB8Y6shU+iuKMVFey6+3abmRlPDrMahr4xRgrHvsMQMQhwDPmHqhP7n8 c3jfiOExQrWYMhrRT4nk09ACvHwCegVd7YhcTZnObRgQNFZQJ4XFJK1RIJaBSUAdYDG2 6Vp4zHulTXDxtGFjnO6hb62iLdsp2rS4DsHEFXsXlHtMdejoa+tqU40zUZ09TGQDgPNg XorDG3PsWwG93vTC8SoxohOyn4aeHmtuaODhEGK+yn4TpIt8ATLDuuMFGfCjNkdjO5SU Hf+xYE9gJl+p5dcxbQDVbfkl4RvpiWELqbSQSMArHkjV7L/b2WfziHZPXmg5mDyp4VTc Itpw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from; bh=X7rjcF9+0pNoxSKMEFh6r5yCrUpgQeJvDiqZdAw/e0Q=; fh=oeRd2GC+/NA6IkEySPrdkOzZrnOz+dG1IsIvAN2jMVM=; b=CfHvwAPsMTjHhnEs8YpVd1Uzta36y9P6S7xyZKaIeA+Xpxazs2tNz2doDFZ4XsPWtl IM5UTO/iNLV4eGkqYmaN33tGPjCtqCpBvKCNnU1TsRMZ9hyEkRQq79OmuDBDn7mHYcZc T6M8oC4VwyN3gvFsXL6E2Hvhq3ai9khsXGO7/q+sQ98eFgvYkQilDtf0FQGhURu0TGP1 kUGZ6Ou8U75iV3ahXzZ3momGO/CONoz57daHnZBUZMMhxDRvOP1a+w7oIgUjfpmOSws0 59oKyeO6uznwkXKVaiwABAqp8aU5W3Z88Am9c7EKjSydqWeV4hqv2P9GdmChvgXmyTqS DlvQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=rjwysocki.net); spf=pass (google.com: domain of linux-kernel+bounces-55561-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-55561-ouuuleilei=gmail.com@vger.kernel.org" X-Forwarded-Encrypted: i=1; AJvYcCVk1L19FWCVXzApPuyTIdclzTTbuu84LgGxgJ50ZiuNAxYhH8tzgJJjVGuMZOIf84lo535urPYJfXBEhtOJfBzT9Kv8tg== Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id i8-20020a170906264800b00a376a73988fsi1404125ejc.99.2024.02.06.11.34.10 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Feb 2024 11:34:10 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-55561-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=rjwysocki.net); spf=pass (google.com: domain of linux-kernel+bounces-55561-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-55561-ouuuleilei=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 074E11F23A17 for ; Tue, 6 Feb 2024 19:34:10 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4F10917984; Tue, 6 Feb 2024 19:33:53 +0000 (UTC) Received: from cloudserver094114.home.pl (cloudserver094114.home.pl [79.96.170.134]) (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 C0EDC17588; Tue, 6 Feb 2024 19:33:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=79.96.170.134 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707248031; cv=none; b=devFnr7DNUCofOG9W1jXVJ4H2FGwHZXpHd6T1u3w1DLuuATOr64EQrzHluRKB/SYDwpoPckHh2/qN4DmtPb8d40aeB+0eHeio+bkeJwoouyuqy2fn+DCRveIZhe+I5A/+VHyuiSF9o7MIJkRxZYoxlOCRpDi0iv9Q/NQBhW913I= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707248031; c=relaxed/simple; bh=hPCr97Z9WyFkP6rn0WJSREQ0TMUx4xLjks+aVxQlXd4=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version:Content-Type; b=e36PzRZCZL+1JxqSIJr7lCHtpUCtyv9IGXrdCtd/BW+HZAqlm7M46hw57W2BWyt7+lmzi5ZAcveyt6rISFt1l6JRnR+khXh2tKFzrSBXvtY2Lx6TCawtZCCp1KWgmwk3FiYv0c3sv3S3vjmsyXq93a0YwmhP6tHKrbmDcf0u1U8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=rjwysocki.net; spf=pass smtp.mailfrom=rjwysocki.net; arc=none smtp.client-ip=79.96.170.134 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=rjwysocki.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=rjwysocki.net Received: from localhost (127.0.0.1) (HELO v370.home.net.pl) by /usr/run/smtp (/usr/run/postfix/private/idea_relay_lmtp) via UNIX with SMTP (IdeaSmtpServer 5.4.0) id 2129a190197e812a; Tue, 6 Feb 2024 20:33:46 +0100 Received: from kreacher.localnet (unknown [195.136.19.94]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by cloudserver094114.home.pl (Postfix) with ESMTPSA id C2DB7669A9F; Tue, 6 Feb 2024 20:33:45 +0100 (CET) From: "Rafael J. Wysocki" To: Linux ACPI Cc: LKML , Linux PM , "Rafael J. Wysocki" , Srinivas Pandruvada , Stanislaw Gruszka , David Box , Mario Limonciello Subject: [PATCH v1] ACPI: PM: s2idle: Enable Low-Power S0 Idle MSFT UUID for non-AMD systems Date: Tue, 06 Feb 2024 20:33:45 +0100 Message-ID: <12388452.O9o76ZdvQC@kreacher> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-CLIENT-IP: 195.136.19.94 X-CLIENT-HOSTNAME: 195.136.19.94 X-VADE-SPAMSTATE: clean X-VADE-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedvledrtddtgdeljecutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfjqffogffrnfdpggftiffpkfenuceurghilhhouhhtmecuudehtdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujfgurhephffvvefufffkggfgtgesthfuredttddtjeenucfhrhhomhepfdftrghfrggvlhculfdrucghhihsohgtkhhifdcuoehrjhifsehrjhifhihsohgtkhhirdhnvghtqeenucggtffrrghtthgvrhhnpeffffffkefgheehffelteeiveeffeevhfelteejvddvieejjeelvdeiheeuveeuffenucfkphepudelhedrudefiedrudelrdelgeenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepihhnvghtpeduleehrddufeeirdduledrleegpdhhvghlohepkhhrvggrtghhvghrrdhlohgtrghlnhgvthdpmhgrihhlfhhrohhmpedftfgrfhgrvghlucflrdcuhgihshhotghkihdfuceorhhjfiesrhhjfiihshhotghkihdrnhgvtheqpdhnsggprhgtphhtthhopeekpdhrtghpthhtoheplhhinhhugidqrggtphhisehvghgvrhdrkhgvrhhnvghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqkhgvrhhnvghlsehvghgvrhdrkhgvrhhnvghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqphhmsehvghgvrhdrkhgvrhhnvghlrdhorhhgpdhrtghpthhtoheprhgrfhgrvghlsehkvghrnhgvlhdrohhrghdprhgtphhtthhopehsrhhinhhivhgr shdrphgrnhgurhhuvhgruggrsehlihhnuhigrdhinhhtvghlrdgtohhmpdhrtghpthhtohepshhtrghnihhslhgrfidrghhruhhsiihkrgeslhhinhhugidrihhnthgvlhdrtghomh X-DCC--Metrics: v370.home.net.pl 1024; Body=8 Fuz1=8 Fuz2=8 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790179331858213500 X-GMAIL-MSGID: 1790179331858213500 From: Rafael J. Wysocki Systems based on Intel platforms that use the MSFT UUID for Low-Power S0 Idle (LPS0) have started to ship, so allow the kernel to use the MSFT UUID in the non-AMD case too, but in that case make it avoid evaluating the same _DSM function for two different UUIDs and prioritize the MSFT one. While at it, combine two MSFT _DSM function mask checks in acpi_s2idle_restore_early() so as to make it reflect the acpi_s2idle_prepare_late() flow more closely and adjust the Modern Standby entry and exit comments slightly. Non-AMD systems that do not support MSFT UUID for Low-power S0 Idle are not expected to be affected by this change in any way. Signed-off-by: Rafael J. Wysocki Reviewed-by: Mario Limonciello --- drivers/acpi/x86/s2idle.c | 37 +++++++++++++++++++++++++++---------- 1 file changed, 27 insertions(+), 10 deletions(-) Index: linux-pm/drivers/acpi/x86/s2idle.c =================================================================== --- linux-pm.orig/drivers/acpi/x86/s2idle.c +++ linux-pm/drivers/acpi/x86/s2idle.c @@ -488,7 +488,21 @@ static int lps0_device_attach(struct acp rev_id = 1; lps0_dsm_func_mask = validate_dsm(adev->handle, ACPI_LPS0_DSM_UUID, rev_id, &lps0_dsm_guid); - lps0_dsm_func_mask_microsoft = -EINVAL; + if (lps0_dsm_func_mask > 0 && lps0_dsm_func_mask_microsoft > 0) { + unsigned int func_mask; + + /* + * Avoid evaluating the same _DSM function for two + * different UUIDs and prioritize the MSFT one. + */ + func_mask = lps0_dsm_func_mask & lps0_dsm_func_mask_microsoft; + if (func_mask) { + acpi_handle_info(adev->handle, + "Duplicate LPS0 _DSM functions (mask: 0x%x)\n", + func_mask); + lps0_dsm_func_mask &= ~func_mask; + } + } } if (lps0_dsm_func_mask < 0 && lps0_dsm_func_mask_microsoft < 0) @@ -549,19 +563,22 @@ int acpi_s2idle_prepare_late(void) lps0_dsm_func_mask_microsoft, lps0_dsm_guid_microsoft); /* LPS0 entry */ - if (lps0_dsm_func_mask > 0) - acpi_sleep_run_lps0_dsm(acpi_s2idle_vendor_amd() ? - ACPI_LPS0_ENTRY_AMD : - ACPI_LPS0_ENTRY, + if (lps0_dsm_func_mask > 0 && acpi_s2idle_vendor_amd()) + acpi_sleep_run_lps0_dsm(ACPI_LPS0_ENTRY_AMD, lps0_dsm_func_mask, lps0_dsm_guid); + if (lps0_dsm_func_mask_microsoft > 0) { - /* modern standby entry */ + /* Modern Standby entry */ acpi_sleep_run_lps0_dsm(ACPI_LPS0_MS_ENTRY, lps0_dsm_func_mask_microsoft, lps0_dsm_guid_microsoft); acpi_sleep_run_lps0_dsm(ACPI_LPS0_ENTRY, lps0_dsm_func_mask_microsoft, lps0_dsm_guid_microsoft); } + if (lps0_dsm_func_mask > 0 && !acpi_s2idle_vendor_amd()) + acpi_sleep_run_lps0_dsm(ACPI_LPS0_ENTRY, + lps0_dsm_func_mask, lps0_dsm_guid); + list_for_each_entry(handler, &lps0_s2idle_devops_head, list_node) { if (handler->prepare) handler->prepare(); @@ -600,14 +617,14 @@ void acpi_s2idle_restore_early(void) ACPI_LPS0_EXIT_AMD : ACPI_LPS0_EXIT, lps0_dsm_func_mask, lps0_dsm_guid); - if (lps0_dsm_func_mask_microsoft > 0) + + if (lps0_dsm_func_mask_microsoft > 0) { acpi_sleep_run_lps0_dsm(ACPI_LPS0_EXIT, lps0_dsm_func_mask_microsoft, lps0_dsm_guid_microsoft); - - /* Modern standby exit */ - if (lps0_dsm_func_mask_microsoft > 0) + /* Modern Standby exit */ acpi_sleep_run_lps0_dsm(ACPI_LPS0_MS_EXIT, lps0_dsm_func_mask_microsoft, lps0_dsm_guid_microsoft); + } /* Screen on */ if (lps0_dsm_func_mask_microsoft > 0)