Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp1773590ybh; Fri, 17 Jul 2020 00:10:56 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyD1KBJtHDpHvcAWzSXciJQeZI+Ju4dkMdrhv7ABaYiOnLM60HQuG0CZka8Emu5n1IGkv79 X-Received: by 2002:a17:906:6499:: with SMTP id e25mr7173878ejm.352.1594969856559; Fri, 17 Jul 2020 00:10:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594969856; cv=none; d=google.com; s=arc-20160816; b=03GQxga3ESPBYs0OS6h6OtufMk1+wkCDOMv2h/Ezj3MN1GOtco0vXXWFv8MV1EduOq CbBfRrCjM4wCBPEBflD0TNvSGgOPvWKyA6Ol77emVvhckv7n8FOn+biLIhfOs7aO51i4 eJF7LHF+e1/KoDQCuuumKZjHGopydPibH9svtjXmIxR9kEgKo1gwH8aXJeVyaNhwzF+e IAmtMvfpl4Mz03yElMa7Co7xLT6/5hSdjxzQ7xAafY9OC8Zg7XVYKPQYOvgJZWN1s7OK JNKIXc8OQQUnVDzFgz3Qg/MlO39rY5bXhFGycCDUeAfjLl5k7E/xceRfSI5rozv/mXtu c0nw== 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 :message-id:date:subject:cc:to:from; bh=+5tey4xEypVJGlB9HI9uj7x1iI56UVrI0wDLoNE528Y=; b=mwFVt2jirUOVxQ11pISlumfV/bDo4kDYUd8AgoPikyAui734jwqKqEFNb4rz1nDz7r fSbQupHspwjjDc+6utgTr7dIpriFk3f+CE3pfS9sTWKWMxB+SSICFE5RNaqVVT8XS/vk KEeMQdUnx/e2u4MSgaOKPyBrIpBMVkYte4zQgl11aw5vIXdJmOwZbn7zf4enLJSBElRx PlIUFOHD6QLnwMKu9TLljUgmUkrQsjPVS8ULcNlDotd1BQ6wD/FbcQX6nHg/MJhyfBNw HKh2exv1TKBGkpQihBhraGmolUeVKeZr4ZRV5myYx3Lpr6+rBWtzJE23yd+GFAVuXIk8 F6BA== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id cm12si4595220edb.333.2020.07.17.00.10.33; Fri, 17 Jul 2020 00:10:56 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726788AbgGQHKY (ORCPT + 99 others); Fri, 17 Jul 2020 03:10:24 -0400 Received: from lonlinode-sdnproxy-1.icoremail.net ([139.162.193.133]:23832 "HELO lonlinode-sdnproxy-1.icoremail.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S1726166AbgGQHKX (ORCPT ); Fri, 17 Jul 2020 03:10:23 -0400 Received: from localhost.localdomain (unknown [218.77.105.7]) by c1app1 (Coremail) with SMTP id AQINCgDnhpnKThFfx6ivAQ--.31076S2; Fri, 17 Jul 2020 15:10:03 +0800 (CST) From: Qiu Wenbo To: Evan Quan , amd-gfx@lists.freedesktop.org Cc: Qiu Wenbo , Alex Deucher , =?UTF-8?q?Christian=20K=C3=B6nig?= , "David (ChunMing) Zhou" , David Airlie , Daniel Vetter , Chen Wandun , YueHaibing , yu kuai , Eric Huang , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org Subject: [PATCH] drm/amd/powerplay: fix a crash when overclocking Vega M Date: Fri, 17 Jul 2020 15:09:57 +0800 Message-Id: <20200717070958.41489-1-qiuwenbo@phytium.com.cn> X-Mailer: git-send-email 2.27.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CM-TRANSID: AQINCgDnhpnKThFfx6ivAQ--.31076S2 X-Coremail-Antispam: 1UD129KBjvJXoW7Zr47Cw1UZF48WFWUJFyxKrg_yoW8CFWrpF 93GrZ0vw15JFZrAFyxAF4rWFn7ZwnrZa4rKryUG390vw12qrW09FyDAFySgrW8Ga97Jr43 Kw47Z345JFsakrUanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUU9j14x267AKxVW8JVW5JwAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2ocxC64kIII0Yj41l84x0c7CEw4AK67xGY2AK02 1l84ACjcxK6xIIjxv20xvE14v26r1I6r4UM28EF7xvwVC0I7IYx2IY6xkF7I0E14v26r4j 6F4UM28EF7xvwVC2z280aVAFwI0_Gr1j6F4UJwA2z4x0Y4vEx4A2jsIEc7CjxVAFwI0_Cr 1j6rxdM2AIxVAIcxkEcVAq07x20xvEncxIr21l5I8CrVACY4xI64kE6c02F40Ex7xfMcIj 6xIIjxv20xvE14v26r1Y6r17McIj6I8E87Iv67AKxVW8JVWxJwAm72CE4IkC6x0Yz7v_Jr 0_Gr1lF7xvr2IYc2Ij64vIr41lF7I21c0EjII2zVCS5cI20VAGYxC7M4IIrI8v6xkF7I0E 8cxan2IY04v7MxkIecxEwVAFwVW8CwCF04k20xvY0x0EwIxGrwCFx2IqxVCFs4IE7xkEbV WUJVW8JwC20s026c02F40E14v26r1j6r18MI8I3I0E7480Y4vE14v26r106r1rMI8E67AF 67kF1VAFwI0_Jw0_GFylIxkGc2Ij64vIr41lIxAIcVC0I7IYx2IY67AKxVWUJVWUCwCI42 IY6xIIjxv20xvEc7CjxVAFwI0_Gr0_Cr1lIxAIcVCF04k26cxKx2IYs7xG6rW3Jr0E3s1l IxAIcVC2z280aVAFwI0_Jr0_Gr1lIxAIcVC2z280aVCY1x0267AKxVW8JVW8JrUvcSsGvf C2KfnxnUUI43ZEXa7VUjE1v3UUUUU== X-Originating-IP: [218.77.105.7] X-CM-SenderInfo: 5tlx4vhqerq15k1wx33pof0zgofq/ Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Avoid kernel crash when vddci_control is SMU7_VOLTAGE_CONTROL_NONE and vddci_voltage_table is empty. It has been tested on Intel Hades Canyon (i7-8809G). Bug: https://bugzilla.kernel.org/show_bug.cgi?id=208489 Fixes: ac7822b0026f ("drm/amd/powerplay: add smumgr support for VEGAM (v2)") Signed-off-by: Qiu Wenbo --- drivers/gpu/drm/amd/powerplay/smumgr/vegam_smumgr.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/amd/powerplay/smumgr/vegam_smumgr.c b/drivers/gpu/drm/amd/powerplay/smumgr/vegam_smumgr.c index 3da71a088b92..0ecc18b55ffb 100644 --- a/drivers/gpu/drm/amd/powerplay/smumgr/vegam_smumgr.c +++ b/drivers/gpu/drm/amd/powerplay/smumgr/vegam_smumgr.c @@ -644,9 +644,6 @@ static int vegam_get_dependency_volt_by_clk(struct pp_hwmgr *hwmgr, /* sclk is bigger than max sclk in the dependence table */ *voltage |= (dep_table->entries[i - 1].vddc * VOLTAGE_SCALE) << VDDC_SHIFT; - vddci = phm_find_closest_vddci(&(data->vddci_voltage_table), - (dep_table->entries[i - 1].vddc - - (uint16_t)VDDC_VDDCI_DELTA)); if (SMU7_VOLTAGE_CONTROL_NONE == data->vddci_control) *voltage |= (data->vbios_boot_state.vddci_bootup_value * @@ -654,8 +651,13 @@ static int vegam_get_dependency_volt_by_clk(struct pp_hwmgr *hwmgr, else if (dep_table->entries[i - 1].vddci) *voltage |= (dep_table->entries[i - 1].vddci * VOLTAGE_SCALE) << VDDC_SHIFT; - else + else { + vddci = phm_find_closest_vddci(&(data->vddci_voltage_table), + (dep_table->entries[i - 1].vddc - + (uint16_t)VDDC_VDDCI_DELTA)); + *voltage |= (vddci * VOLTAGE_SCALE) << VDDCI_SHIFT; + } if (SMU7_VOLTAGE_CONTROL_NONE == data->mvdd_control) *mvdd = data->vbios_boot_state.mvdd_bootup_value * VOLTAGE_SCALE; -- 2.27.0