Received: by 2002:a05:6a10:7420:0:0:0:0 with SMTP id hk32csp3937541pxb; Mon, 21 Feb 2022 08:40:17 -0800 (PST) X-Google-Smtp-Source: ABdhPJwgVT05neHDGTwbyk9pwVZSHBYMReRJoZDU+MeUOtWG+bB0YehdIbb83eftTpOGasF1jLvI X-Received: by 2002:a17:906:a855:b0:6cd:ba20:39c5 with SMTP id dx21-20020a170906a85500b006cdba2039c5mr15965874ejb.100.1645461616828; Mon, 21 Feb 2022 08:40:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1645461616; cv=none; d=google.com; s=arc-20160816; b=uj3FYQA0btR/wrS8FQKjgjOjCKNGqvg4akahlmVD9AeNNDCJAw+4Jmg3oEYXAw36gS 8KrytbjK0hHoVWr9QufC6Ghk9QiC2s9LWtB1L2pDGorffXndD3vgnxIthQX7C41ThMdo zIz5nSJqWu/oO97Rg/t6kyTAdiSgvuI4sY0lJ5aYnyiynQ+OOJVW2s/JYT98igyZKWOR POmNoPMzu5aRLs2LGR5BwwlwAxC4EM6aAgwdmq+F/rptgLzryQ7HNEtBkGjEZJoqRq6w ZftbFkGRiVB9yPuzero8PZ/aVuRA6hTmWBHabUunjooEgtHIDOGmhbD1T798AL/K/icu 4kQA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=IW8xxYNoi5dEyeW+RC9Vnku9ibThsG151Nr1zGzoA9E=; b=kaUiw2S7GnNq57/Bd9g6cD9gJrwYCgEmNbJ/tt7uvySPHswWBgFAUxEpziRxOULk1t 5Ji86PIMkzhb4gQb/s98d9JfpGa4QagYkN8QSbiZIvDnD4WWyK6CryBivTmu4pQGHakf nN2s2AJYiLkESr/rdOlxxQVYgSjAzrsNOwLbE/j5z4UZTV6k6qOGZQOZQiS8WyRj41Gb BCT05InPWHe5pva/Wqrwq5eDe1UioTirF39UeUJRHU0KkcdlHTc/0JbcBN0Qu39YIOsP PbC8MN8XC4LK9e4ThOBfcckKQEc1cEHGguKIBNKPDlRAI9T+cHmNy1MHtVjLBw/cbrmh /yMQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=BmR5uaZX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c20si10140940ejj.242.2022.02.21.08.39.54; Mon, 21 Feb 2022 08:40:16 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=BmR5uaZX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1354662AbiBUJ6m (ORCPT + 99 others); Mon, 21 Feb 2022 04:58:42 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:34308 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1352050AbiBUJrA (ORCPT ); Mon, 21 Feb 2022 04:47:00 -0500 Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E98514093E; Mon, 21 Feb 2022 01:18:58 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sin.source.kernel.org (Postfix) with ESMTPS id 7492ACE0E93; Mon, 21 Feb 2022 09:18:58 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 649FDC340E9; Mon, 21 Feb 2022 09:18:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1645435136; bh=indKywp9dJc52epAbrsaZRVK+A2snuJPkcrV1d8PNDk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BmR5uaZX5RduS+pkKxF4klFTogZZv9xa2OaZcXvGZEuST9u8u2Slzha6nwLmWOzUe xKMSLx5gS7v5EsuAio4fsYvsHe6xSzQu35xHeOWWYnc4p4BduyPnNHnH4g5iQfJwup yKcrnaC2RLED0liIUNNeDjH6TbejwmrH6qZnpkkg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Bjoren Dasse , Alex Deucher , Mario Limonciello , Sasha Levin Subject: [PATCH 5.16 058/227] drm/amd: Warn users about potential s0ix problems Date: Mon, 21 Feb 2022 09:47:57 +0100 Message-Id: <20220221084936.809880826@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220221084934.836145070@linuxfoundation.org> References: <20220221084934.836145070@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Mario Limonciello [ Upstream commit a6ed2035878e5ad2e43ed175d8812ac9399d6c40 ] On some OEM setups users can configure the BIOS for S3 or S2idle. When configured to S3 users can still choose 's2idle' in the kernel by using `/sys/power/mem_sleep`. Before commit 6dc8265f9803 ("drm/amdgpu: always reset the asic in suspend (v2)"), the GPU would crash. Now when configured this way, the system should resume but will use more power. As such, adjust the `amdpu_acpi_is_s0ix function` to warn users about potential power consumption issues during their first attempt at suspending. Reported-by: Bjoren Dasse Link: https://gitlab.freedesktop.org/drm/amd/-/issues/1824 Reviewed-by: Alex Deucher Signed-off-by: Mario Limonciello Signed-off-by: Alex Deucher Signed-off-by: Sasha Levin --- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 8 ++++++-- drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c | 24 +++++++++++++++++++----- 2 files changed, 25 insertions(+), 7 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h b/drivers/gpu/drm/amd/amdgpu/amdgpu.h index 7d67aec6f4a2b..0a5a5370a2004 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h @@ -1406,12 +1406,10 @@ int amdgpu_acpi_smart_shift_update(struct drm_device *dev, enum amdgpu_ss ss_sta int amdgpu_acpi_pcie_notify_device_ready(struct amdgpu_device *adev); void amdgpu_acpi_get_backlight_caps(struct amdgpu_dm_backlight_caps *caps); -bool amdgpu_acpi_is_s0ix_active(struct amdgpu_device *adev); void amdgpu_acpi_detect(void); #else static inline int amdgpu_acpi_init(struct amdgpu_device *adev) { return 0; } static inline void amdgpu_acpi_fini(struct amdgpu_device *adev) { } -static inline bool amdgpu_acpi_is_s0ix_active(struct amdgpu_device *adev) { return false; } static inline void amdgpu_acpi_detect(void) { } static inline bool amdgpu_acpi_is_power_shift_control_supported(void) { return false; } static inline int amdgpu_acpi_power_shift_control(struct amdgpu_device *adev, @@ -1420,6 +1418,12 @@ static inline int amdgpu_acpi_smart_shift_update(struct drm_device *dev, enum amdgpu_ss ss_state) { return 0; } #endif +#if defined(CONFIG_ACPI) && defined(CONFIG_SUSPEND) +bool amdgpu_acpi_is_s0ix_active(struct amdgpu_device *adev); +#else +static inline bool amdgpu_acpi_is_s0ix_active(struct amdgpu_device *adev) { return false; } +#endif + int amdgpu_cs_find_mapping(struct amdgpu_cs_parser *parser, uint64_t addr, struct amdgpu_bo **bo, struct amdgpu_bo_va_mapping **mapping); diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c index 4811b0faafd9a..b19d407518024 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c @@ -1031,6 +1031,7 @@ void amdgpu_acpi_detect(void) } } +#if IS_ENABLED(CONFIG_SUSPEND) /** * amdgpu_acpi_is_s0ix_active * @@ -1040,11 +1041,24 @@ void amdgpu_acpi_detect(void) */ bool amdgpu_acpi_is_s0ix_active(struct amdgpu_device *adev) { -#if IS_ENABLED(CONFIG_AMD_PMC) && IS_ENABLED(CONFIG_SUSPEND) - if (acpi_gbl_FADT.flags & ACPI_FADT_LOW_POWER_S0) { - if (adev->flags & AMD_IS_APU) - return pm_suspend_target_state == PM_SUSPEND_TO_IDLE; + if (!(adev->flags & AMD_IS_APU) || + (pm_suspend_target_state != PM_SUSPEND_TO_IDLE)) + return false; + + if (!(acpi_gbl_FADT.flags & ACPI_FADT_LOW_POWER_S0)) { + dev_warn_once(adev->dev, + "Power consumption will be higher as BIOS has not been configured for suspend-to-idle.\n" + "To use suspend-to-idle change the sleep mode in BIOS setup.\n"); + return false; } -#endif + +#if !IS_ENABLED(CONFIG_AMD_PMC) + dev_warn_once(adev->dev, + "Power consumption will be higher as the kernel has not been compiled with CONFIG_AMD_PMC.\n"); return false; +#else + return true; +#endif /* CONFIG_AMD_PMC */ } + +#endif /* CONFIG_SUSPEND */ -- 2.34.1