Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp1234457pxa; Thu, 20 Aug 2020 06:21:45 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyOUBHLwKhY5ESijWVfG2Y0Kxk6EfUBd+Gy9aSnvhiXK8amBPlZ8qbJ90SwhktKZiKiNouc X-Received: by 2002:a17:906:924b:: with SMTP id c11mr3308452ejx.75.1597929705160; Thu, 20 Aug 2020 06:21:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597929705; cv=none; d=google.com; s=arc-20160816; b=eilMKuwYKSzpzz80FISL+HhV5balO5+pJkEh9wc+6ZdksuuzlB5aE0CoYJ9mNIJmD9 LvxftMm7aH+1+8LQad1OPl+rO2TwelbONhUl30TEPYNNlVjH3qvD46YM220DdwG6iaBW eWNd9iDwI8zEBc3WjeH0V1Ud8RenQpo9krPocS9yXs6nmy69W8UWjGvnZJIWrvZS5Z3/ f4VUqoF3S/VG0fLP+G0/f55DEXBktW7ynGLFwUJ9vx9zHK5sbEqoeltAAlXWdxm1YAUW 51HpFeOigEqR2R5SwPMKk+Rz7UvqYqvdzE1OB8Zfl5EeFDG6sOzwTEgbYkx0kCPsNjnn HSkQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=mNH2Q6jiKYU7RJcfTAtBWG8oVhfqcP26Mortxlb9x68=; b=fEM2CAW3yulUsfvQpGfffnwzqVw6EhMpfIm/B0DhW+zhvivKUVSM4SVi80KWNyGNNT ASySxIbLRpE1oSeaKSHygPgWHb0sOl4pl0+9+qdlmR60LzliEYsXtudk2UF22wRg/JSW yTE0a0p9LorWKNitvVPycbrp1f1MussK4MrreG0ZfQNiwYSJFqg17bV+cHehuYTv3EFo fmsV9orlQWaxRq5ohaEqcUhQNCsiiwyt3dTlbHLj4Q3yWAkWVvtrwoBJt/iP9ulOxK1D oQsbM6D4zudUeHSU99PcFfqQ7IfAsIQnalM33n1QbhfjemtCvj9O612LYBn6Hu0LxWSr xc0Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=r0aEcGUS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ss19si1215531ejb.252.2020.08.20.06.21.20; Thu, 20 Aug 2020 06:21:45 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=r0aEcGUS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730486AbgHTNUm (ORCPT + 99 others); Thu, 20 Aug 2020 09:20:42 -0400 Received: from mail.kernel.org ([198.145.29.99]:47224 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728016AbgHTJeU (ORCPT ); Thu, 20 Aug 2020 05:34:20 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 647AB21775; Thu, 20 Aug 2020 09:34:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1597916060; bh=mdP55MQ5hZd+LjwfofX9mTruh9HHZctyninsRPIAus0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=r0aEcGUSLd8OH0OnXhQKjoeBGaExbm68S0a01nLEktVbz1FVJZQzJgNvn8QauEBlX N0BIHLEy4c19TfvuEc0LV0WaS4t++ksrdCQ2GkUo1vkbjYjycuRoAdKGd/pMJ+51tJ EQ7mTjtaKfyJ+4ByKHRofS9Q5wxjVMpESeFiS+6M= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Sandeep Raghuraman , Alex Deucher Subject: [PATCH 5.8 230/232] drm/amdgpu: Fix bug where DPM is not enabled after hibernate and resume Date: Thu, 20 Aug 2020 11:21:21 +0200 Message-Id: <20200820091623.916974874@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200820091612.692383444@linuxfoundation.org> References: <20200820091612.692383444@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Sandeep Raghuraman commit f87812284172a9809820d10143b573d833cd3f75 upstream. Reproducing bug report here: After hibernating and resuming, DPM is not enabled. This remains the case even if you test hibernate using the steps here: https://www.kernel.org/doc/html/latest/power/basic-pm-debugging.html I debugged the problem, and figured out that in the file hardwaremanager.c, in the function, phm_enable_dynamic_state_management(), the check 'if (!hwmgr->pp_one_vf && smum_is_dpm_running(hwmgr) && !amdgpu_passthrough(adev) && adev->in_suspend)' returns true for the hibernate case, and false for the suspend case. This means that for the hibernate case, the AMDGPU driver doesn't enable DPM (even though it should) and simply returns from that function. In the suspend case, it goes ahead and enables DPM, even though it doesn't need to. I debugged further, and found out that in the case of suspend, for the CIK/Hawaii GPUs, smum_is_dpm_running(hwmgr) returns false, while in the case of hibernate, smum_is_dpm_running(hwmgr) returns true. For CIK, the ci_is_dpm_running() function calls the ci_is_smc_ram_running() function, which is ultimately used to determine if DPM is currently enabled or not, and this seems to provide the wrong answer. I've changed the ci_is_dpm_running() function to instead use the same method that some other AMD GPU chips do (e.g Fiji), which seems to read the voltage controller. I've tested on my R9 390 and it seems to work correctly for both suspend and hibernate use cases, and has been stable so far. Bug: https://bugzilla.kernel.org/show_bug.cgi?id=208839 Signed-off-by: Sandeep Raghuraman Signed-off-by: Alex Deucher Cc: stable@vger.kernel.org Signed-off-by: Greg Kroah-Hartman --- drivers/gpu/drm/amd/powerplay/smumgr/ci_smumgr.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) --- a/drivers/gpu/drm/amd/powerplay/smumgr/ci_smumgr.c +++ b/drivers/gpu/drm/amd/powerplay/smumgr/ci_smumgr.c @@ -2725,7 +2725,10 @@ static int ci_initialize_mc_reg_table(st static bool ci_is_dpm_running(struct pp_hwmgr *hwmgr) { - return ci_is_smc_ram_running(hwmgr); + return (1 == PHM_READ_INDIRECT_FIELD(hwmgr->device, + CGS_IND_REG__SMC, FEATURE_STATUS, + VOLTAGE_CONTROLLER_ON)) + ? true : false; } static int ci_smu_init(struct pp_hwmgr *hwmgr)