Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp630298pxb; Tue, 2 Feb 2021 13:45:00 -0800 (PST) X-Google-Smtp-Source: ABdhPJyFTW90H4ZmKR8uo5OI9K/FMARbAcp+NdPzUn7/S8wpdOGnbZm/Z03H4Oi2cJ4KCCVuMcmH X-Received: by 2002:a17:906:1c11:: with SMTP id k17mr54076ejg.70.1612302300313; Tue, 02 Feb 2021 13:45:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612302300; cv=none; d=google.com; s=arc-20160816; b=aS5Guh2e82eSYRLaobCwC9b6aREw0IELXdxwi0wX9IYYle7t45whJIjf22JEnd/WEX LLXHwd2l4IQhDuvwX/1dDU2QrffcFyBYma00S2edPI59jmwm9dheh5RfgZORmLZHbjqp bXOEt9aYUeP85gz8d3fezI6r4ek65YpJSTn/pXSg+tzdD0InscOOxhSZ/+VMnNlN02Cl KZOKrwIJOzXaBKIrVR97CGgcGev8Z0oq+JpOgWt1XGWz9io96nulymgcl9s9rcygdA7v QsN086cYSLYkzmrnhgTkg97+NLI1XV/0avBj9Iu3zMpfni/T14bjiLLvmeyVVXd3/Ehr Vjmg== 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=ZB/o4lDFjU9Xyzny3a7br1yn+qfN6PVf6yjc5XxvTdM=; b=bmfkXBeu+FJKBvjDE8zNmXxUJd6WoFLESkMt2/A49J0yPvidCLtqlEvS2CoDf5RTax gUphdsGy2XF9woElFqvaW2CuJaC8WZDst73U5YJBWmLID5zQrHpgA5u0ZJ81mSYAYOx9 9uS4h6pi/CQwfiNaaRPFfSARCve6F3xSdvYEm47pCsMluOpFmJfjf4TObMO49tgifeoc D8jwZx0dszgn3qdB9HCVOdQ8CNNfZL8w79x5ZBk09YiA4AqKnERCXP9fSQneWGDD1YPC mWx2+4wj/c2FQJGpuLSKhBf16J/RtCjY5Xvaa1Qgquf6RDIIIpANO6rsu5faJq8HxJyQ rhIg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=J4G7o7kj; 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=pass (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 24si17844693edv.406.2021.02.02.13.44.30; Tue, 02 Feb 2021 13:45:00 -0800 (PST) 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=@linuxfoundation.org header.s=korg header.b=J4G7o7kj; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232572AbhBBNpr (ORCPT + 99 others); Tue, 2 Feb 2021 08:45:47 -0500 Received: from mail.kernel.org ([198.145.29.99]:36462 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232846AbhBBNnC (ORCPT ); Tue, 2 Feb 2021 08:43:02 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 784F764F6B; Tue, 2 Feb 2021 13:40:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1612273211; bh=vDgI0KISKsQpwYAOn5Nnpa0DlPBe8ruIWp/pmp29/k8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=J4G7o7kjhkiuSYIxrMWJq3SDaXV4pLMmRaxE6QN23TChJSnSsIa3hvgA4QiGBNpA6 Xy/xaeb7qZWYy44rUE33k9CHooTSUg/W0KqCl+5UoDnMfRWHSBTkToSVAGzzcjzbxg 4m5ULDX669jlHSlz3EE/g01OSvI4vgQS8MLl5kuk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Alex Deucher Subject: [PATCH 5.10 022/142] Revert "drm/amdgpu/swsmu: drop set_fan_speed_percent (v2)" Date: Tue, 2 Feb 2021 14:36:25 +0100 Message-Id: <20210202132958.627180725@linuxfoundation.org> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210202132957.692094111@linuxfoundation.org> References: <20210202132957.692094111@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Alex Deucher commit a119f87b86bcdf14a18ce39a899e97a1e9160f7f upstream. On some boards the rpm interface apparently does not work at all leading to the fan not spinning or spinning at strange speeds. Revert this for now to fix 5.10, 5.11. The follow on patch fixes this properly for 5.12. This reverts commit 8d6e65adc25e23fabbc5293b6cd320195c708dca. Bug: https://gitlab.freedesktop.org/drm/amd/-/issues/1408 Signed-off-by: Alex Deucher Cc: stable@vger.kernel.org Signed-off-by: Greg Kroah-Hartman --- drivers/gpu/drm/amd/pm/inc/amdgpu_smu.h | 1 drivers/gpu/drm/amd/pm/inc/smu_v11_0.h | 3 + drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c | 9 +--- drivers/gpu/drm/amd/pm/swsmu/smu11/arcturus_ppt.c | 1 drivers/gpu/drm/amd/pm/swsmu/smu11/navi10_ppt.c | 1 drivers/gpu/drm/amd/pm/swsmu/smu11/sienna_cichlid_ppt.c | 1 drivers/gpu/drm/amd/pm/swsmu/smu11/smu_v11_0.c | 31 +++++++++++++++- 7 files changed, 39 insertions(+), 8 deletions(-) --- a/drivers/gpu/drm/amd/pm/inc/amdgpu_smu.h +++ b/drivers/gpu/drm/amd/pm/inc/amdgpu_smu.h @@ -575,6 +575,7 @@ struct pptable_funcs { int (*conv_power_profile_to_pplib_workload)(int power_profile); uint32_t (*get_fan_control_mode)(struct smu_context *smu); int (*set_fan_control_mode)(struct smu_context *smu, uint32_t mode); + int (*set_fan_speed_percent)(struct smu_context *smu, uint32_t speed); int (*set_fan_speed_rpm)(struct smu_context *smu, uint32_t speed); int (*set_xgmi_pstate)(struct smu_context *smu, uint32_t pstate); int (*gfx_off_control)(struct smu_context *smu, bool enable); --- a/drivers/gpu/drm/amd/pm/inc/smu_v11_0.h +++ b/drivers/gpu/drm/amd/pm/inc/smu_v11_0.h @@ -200,6 +200,9 @@ int smu_v11_0_set_fan_control_mode(struct smu_context *smu, uint32_t mode); +int +smu_v11_0_set_fan_speed_percent(struct smu_context *smu, uint32_t speed); + int smu_v11_0_set_fan_speed_rpm(struct smu_context *smu, uint32_t speed); --- a/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +++ b/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c @@ -2255,19 +2255,14 @@ int smu_get_fan_speed_percent(struct smu int smu_set_fan_speed_percent(struct smu_context *smu, uint32_t speed) { int ret = 0; - uint32_t rpm; if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled) return -EOPNOTSUPP; mutex_lock(&smu->mutex); - if (smu->ppt_funcs->set_fan_speed_rpm) { - if (speed > 100) - speed = 100; - rpm = speed * smu->fan_max_rpm / 100; - ret = smu->ppt_funcs->set_fan_speed_rpm(smu, rpm); - } + if (smu->ppt_funcs->set_fan_speed_percent) + ret = smu->ppt_funcs->set_fan_speed_percent(smu, speed); mutex_unlock(&smu->mutex); --- a/drivers/gpu/drm/amd/pm/swsmu/smu11/arcturus_ppt.c +++ b/drivers/gpu/drm/amd/pm/swsmu/smu11/arcturus_ppt.c @@ -2366,6 +2366,7 @@ static const struct pptable_funcs arctur .display_clock_voltage_request = smu_v11_0_display_clock_voltage_request, .get_fan_control_mode = smu_v11_0_get_fan_control_mode, .set_fan_control_mode = smu_v11_0_set_fan_control_mode, + .set_fan_speed_percent = smu_v11_0_set_fan_speed_percent, .set_fan_speed_rpm = smu_v11_0_set_fan_speed_rpm, .set_xgmi_pstate = smu_v11_0_set_xgmi_pstate, .gfx_off_control = smu_v11_0_gfx_off_control, --- a/drivers/gpu/drm/amd/pm/swsmu/smu11/navi10_ppt.c +++ b/drivers/gpu/drm/amd/pm/swsmu/smu11/navi10_ppt.c @@ -2710,6 +2710,7 @@ static const struct pptable_funcs navi10 .display_clock_voltage_request = smu_v11_0_display_clock_voltage_request, .get_fan_control_mode = smu_v11_0_get_fan_control_mode, .set_fan_control_mode = smu_v11_0_set_fan_control_mode, + .set_fan_speed_percent = smu_v11_0_set_fan_speed_percent, .set_fan_speed_rpm = smu_v11_0_set_fan_speed_rpm, .set_xgmi_pstate = smu_v11_0_set_xgmi_pstate, .gfx_off_control = smu_v11_0_gfx_off_control, --- a/drivers/gpu/drm/amd/pm/swsmu/smu11/sienna_cichlid_ppt.c +++ b/drivers/gpu/drm/amd/pm/swsmu/smu11/sienna_cichlid_ppt.c @@ -2776,6 +2776,7 @@ static const struct pptable_funcs sienna .display_clock_voltage_request = smu_v11_0_display_clock_voltage_request, .get_fan_control_mode = smu_v11_0_get_fan_control_mode, .set_fan_control_mode = smu_v11_0_set_fan_control_mode, + .set_fan_speed_percent = smu_v11_0_set_fan_speed_percent, .set_fan_speed_rpm = smu_v11_0_set_fan_speed_rpm, .set_xgmi_pstate = smu_v11_0_set_xgmi_pstate, .gfx_off_control = smu_v11_0_gfx_off_control, --- a/drivers/gpu/drm/amd/pm/swsmu/smu11/smu_v11_0.c +++ b/drivers/gpu/drm/amd/pm/swsmu/smu11/smu_v11_0.c @@ -1123,6 +1123,35 @@ smu_v11_0_set_fan_static_mode(struct smu } int +smu_v11_0_set_fan_speed_percent(struct smu_context *smu, uint32_t speed) +{ + struct amdgpu_device *adev = smu->adev; + uint32_t duty100, duty; + uint64_t tmp64; + + if (speed > 100) + speed = 100; + + if (smu_v11_0_auto_fan_control(smu, 0)) + return -EINVAL; + + duty100 = REG_GET_FIELD(RREG32_SOC15(THM, 0, mmCG_FDO_CTRL1), + CG_FDO_CTRL1, FMAX_DUTY100); + if (!duty100) + return -EINVAL; + + tmp64 = (uint64_t)speed * duty100; + do_div(tmp64, 100); + duty = (uint32_t)tmp64; + + WREG32_SOC15(THM, 0, mmCG_FDO_CTRL0, + REG_SET_FIELD(RREG32_SOC15(THM, 0, mmCG_FDO_CTRL0), + CG_FDO_CTRL0, FDO_STATIC_DUTY, duty)); + + return smu_v11_0_set_fan_static_mode(smu, FDO_PWM_MODE_STATIC); +} + +int smu_v11_0_set_fan_control_mode(struct smu_context *smu, uint32_t mode) { @@ -1130,7 +1159,7 @@ smu_v11_0_set_fan_control_mode(struct sm switch (mode) { case AMD_FAN_CTRL_NONE: - ret = smu_v11_0_set_fan_speed_rpm(smu, smu->fan_max_rpm); + ret = smu_v11_0_set_fan_speed_percent(smu, 100); break; case AMD_FAN_CTRL_MANUAL: ret = smu_v11_0_auto_fan_control(smu, 0);