Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp3699587ybv; Mon, 10 Feb 2020 04:57:37 -0800 (PST) X-Google-Smtp-Source: APXvYqzebR3oJEcfRUtZczdW+0XkliLFazWTqssqXi+lUlNAdZAXQPJByIdqnytX8cP6QfC6YFAc X-Received: by 2002:a9d:4e99:: with SMTP id v25mr967247otk.363.1581339457331; Mon, 10 Feb 2020 04:57:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581339457; cv=none; d=google.com; s=arc-20160816; b=v0KPw970Z2hL1PmvYU9v0Y6TEIVUdYWt7GYUKbui1rtePKPIL6kAoXGeK4dXDZPerx S97m4iHFkgFXBft2Co7b794XfomK0TqPnLc8yXk4V5uc3ylxXKzSafoCqJG9Mbvu+nVT pnJf/DODbBwt8V/hUp35CB1wOtF5j6Q+kK5Dh/KrQ5LyHyaBpLv8dr2auQH5xa/yZW5R GAbquehT+SxYMw0C0CrNq1Ku89Z6y7Qqe9dbjaY5iR5t2fbMQTECwybcTb0b6IQ8ZxNU 6jHXNmuv/IDZe5eSbJdQguqOAGHK6zGZKo4gElGVhZZrfyb94TPf9SAJAoAEfPXdiwJC n3lQ== 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=tC1RInRHEx/J57YOI8p4MqBlGGY0t6YoQILeQfv3QOE=; b=aGEojGjdu9o3XvzTb1oF+Pu35XyVQ9NIf53Clg0R5ekyXYJAwC03WA2KjjpcHEJK/F iyvaoIljXbHh/Nxqr6Iy+flhfg2mMoDwBStt/odUCk2xW+YMCV158iwq0hnLTnxg6Hj4 WbnBoWjGlQ8DBhTvNanKsDbQK2w2lik+cRuXr5JlrrVkGmn2v1brOM6bXDJtYwOI1IZU 4QMObYt1b0iGXj3tLYpvhsyGFVfWB3/4tSmepb+2ETAnsfcfTTGIWx/swDfiXNFS9g3P m5o9MA0D3gV1k6bqCTJUtndcqTFtMaHbmsTF6cL1hQlLeVl7pmjTvvkGLOtop23bgr7x DqAA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=u9TJ8ys4; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o8si168778oti.47.2020.02.10.04.57.25; Mon, 10 Feb 2020 04:57:37 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=u9TJ8ys4; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730221AbgBJM5Y (ORCPT + 99 others); Mon, 10 Feb 2020 07:57:24 -0500 Received: from mail.kernel.org ([198.145.29.99]:43710 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728447AbgBJMla (ORCPT ); Mon, 10 Feb 2020 07:41:30 -0500 Received: from localhost (unknown [209.37.97.194]) (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 8065520873; Mon, 10 Feb 2020 12:41:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1581338489; bh=TTfjELHkrQvxjGJE+euxDLDW+9s1L+edJ4D0jtineI8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=u9TJ8ys4ZdSoQb9R+Ju8deKr6W8mc/8EPnQQO8fsRmLw3TANCj2A2kQLKJBwtv0Es cra7GyeAYf9DHenNxOb/UBlMVui1KldN4OVGuSs8t7AMuW703PKIzAABl0rw25qyAu W1X2kYHFlCQR8pQ139Wb/XwpttW0Pn4b5EV7bsDM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Matt Coffin , Alex Deucher Subject: [PATCH 5.5 273/367] drm/amdgpu/smu_v11_0: Correct behavior of restoring default tables (v2) Date: Mon, 10 Feb 2020 04:33:06 -0800 Message-Id: <20200210122449.443658345@linuxfoundation.org> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200210122423.695146547@linuxfoundation.org> References: <20200210122423.695146547@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: Matt Coffin commit 93c5f1f66c6ad4a3b180c1644f74e1b3b4be7864 upstream. Previously, the syfs functionality for restoring the default powerplay table was sourcing it's information from the currently-staged powerplay table. This patch adds a step to cache the first overdrive table that we see on boot, so that it can be used later to "restore" the powerplay table v2: sqaush my original with Matt's fix Bug: https://gitlab.freedesktop.org/drm/amd/issues/1020 Signed-off-by: Matt Coffin Reviewed-by: Alex Deucher Signed-off-by: Alex Deucher Cc: stable@vger.kernel.org # 5.5.x Signed-off-by: Greg Kroah-Hartman --- drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h | 1 drivers/gpu/drm/amd/powerplay/navi10_ppt.c | 7 ++++++ drivers/gpu/drm/amd/powerplay/smu_v11_0.c | 6 +++++ drivers/gpu/drm/amd/powerplay/vega20_ppt.c | 28 +++++++------------------ 4 files changed, 22 insertions(+), 20 deletions(-) --- a/drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h +++ b/drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h @@ -263,6 +263,7 @@ struct smu_table_context uint8_t thermal_controller_type; void *overdrive_table; + void *boot_overdrive_table; }; struct smu_dpm_context { --- a/drivers/gpu/drm/amd/powerplay/navi10_ppt.c +++ b/drivers/gpu/drm/amd/powerplay/navi10_ppt.c @@ -2020,6 +2020,13 @@ static int navi10_od_edit_dpm_table(stru return ret; od_table->UclkFmax = input[1]; break; + case PP_OD_RESTORE_DEFAULT_TABLE: + if (!(table_context->overdrive_table && table_context->boot_overdrive_table)) { + pr_err("Overdrive table was not initialized!\n"); + return -EINVAL; + } + memcpy(table_context->overdrive_table, table_context->boot_overdrive_table, sizeof(OverDriveTable_t)); + break; case PP_OD_COMMIT_DPM_TABLE: navi10_dump_od_table(od_table); ret = smu_update_table(smu, SMU_TABLE_OVERDRIVE, 0, (void *)od_table, true); --- a/drivers/gpu/drm/amd/powerplay/smu_v11_0.c +++ b/drivers/gpu/drm/amd/powerplay/smu_v11_0.c @@ -1807,6 +1807,12 @@ int smu_v11_0_set_default_od_settings(st pr_err("Failed to export overdrive table!\n"); return ret; } + if (!table_context->boot_overdrive_table) { + table_context->boot_overdrive_table = kmemdup(table_context->overdrive_table, overdrive_table_size, GFP_KERNEL); + if (!table_context->boot_overdrive_table) { + return -ENOMEM; + } + } } ret = smu_update_table(smu, SMU_TABLE_OVERDRIVE, 0, table_context->overdrive_table, true); if (ret) { --- a/drivers/gpu/drm/amd/powerplay/vega20_ppt.c +++ b/drivers/gpu/drm/amd/powerplay/vega20_ppt.c @@ -1702,22 +1702,11 @@ static int vega20_set_default_od_setting struct smu_table_context *table_context = &smu->smu_table; int ret; - if (initialize) { - if (table_context->overdrive_table) - return -EINVAL; - - table_context->overdrive_table = kzalloc(sizeof(OverDriveTable_t), GFP_KERNEL); - - if (!table_context->overdrive_table) - return -ENOMEM; - - ret = smu_update_table(smu, SMU_TABLE_OVERDRIVE, 0, - table_context->overdrive_table, false); - if (ret) { - pr_err("Failed to export over drive table!\n"); - return ret; - } + ret = smu_v11_0_set_default_od_settings(smu, initialize, sizeof(OverDriveTable_t)); + if (ret) + return ret; + if (initialize) { ret = vega20_set_default_od8_setttings(smu); if (ret) return ret; @@ -2774,12 +2763,11 @@ static int vega20_odn_edit_dpm_table(str break; case PP_OD_RESTORE_DEFAULT_TABLE: - ret = smu_update_table(smu, SMU_TABLE_OVERDRIVE, 0, table_context->overdrive_table, false); - if (ret) { - pr_err("Failed to export over drive table!\n"); - return ret; + if (!(table_context->overdrive_table && table_context->boot_overdrive_table)) { + pr_err("Overdrive table was not initialized!\n"); + return -EINVAL; } - + memcpy(table_context->overdrive_table, table_context->boot_overdrive_table, sizeof(OverDriveTable_t)); break; case PP_OD_COMMIT_DPM_TABLE: