Received: by 2002:a17:90b:8d0:0:0:0:0 with SMTP id ds16csp4880397pjb; Mon, 27 Jul 2020 07:28:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxODPU3X6PT/I3PhoAR68wEaWOtnn13IMFLF868cIcJVAqyJfzHZ5KwEz+6px8eYVZIkkHl X-Received: by 2002:a17:906:8602:: with SMTP id o2mr21906491ejx.277.1595860134241; Mon, 27 Jul 2020 07:28:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595860134; cv=none; d=google.com; s=arc-20160816; b=RtHwTcelECZpsPFFOFhRhZAfd3vbQG2JyoOidZCeX0NnboIBOxuVQvRQsLbsAIbBnV 9cc0uHjJnW7JDxubxsooZVF5KnmLUZ5cdc4mlMCJ+tT99EL3UbrHTdqAOpo0waa8yXNE HS9slogoqQMTafKgcJoEQ5Cjuz1mNkjh7PlInBmtrGf9IqwCtqnBxIPyLBoyd0UPoyxX yBd4ihtbWyPBQgok2K3xCcvKapVQPBPRRQDMsrHZcWQPpsnjayFEc4cyYcX/YnDGniGs 6rUm3cfAsc/44i/w3QQ/mFRf5q7DH7y2G+ZsY8KgaT/ZXk6QVRoj2xva1+qcTnQDOIBz EBOg== 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=HCcMtn7q44N1kV1w5VZgsPb2GJ+2RKhHK5jBSi1EdLg=; b=Z6B4kpWrarWWGeLKyYqlNWatYd8ZNIHR5Edq1pXGQl3JeO27NLunuccimD5qBT3DJV onDUk+bE8YwGHxIhoC5EcrVRUmB06jhT56OYDtu3UUovEz3jPArDpX///AxNLYLuXPY/ TT/6KjKN/yyIROCz1jWfPdWJjvqBmVsQYkIqKXGKZmG7GN2wKlVSruRawWaLslAIrDqT +2sofZllj8BM0q4k5KI+MPKTMcU/27osnOXtSfNOm6hM0oAFbcSHVhEzuCbekLmBmYC+ pKa9bjvzUkEanZXvDAS8ykCCfsPHNkhQ8S1YkxjcjSHyxwD/PE51w4dt3M0xeMyleuiv JY9g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=bbLX5Fig; 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 dr10si427137ejc.698.2020.07.27.07.28.32; Mon, 27 Jul 2020 07:28:54 -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=bbLX5Fig; 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 S1732527AbgG0OZx (ORCPT + 99 others); Mon, 27 Jul 2020 10:25:53 -0400 Received: from mail.kernel.org ([198.145.29.99]:56028 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732521AbgG0OZw (ORCPT ); Mon, 27 Jul 2020 10:25:52 -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 4D5EC207FC; Mon, 27 Jul 2020 14:25:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1595859951; bh=9eh4zjibUGsJrkBsVkA2O+Xz5FTZwE39Qzz12cZceuk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bbLX5FigjilCAp1vcII8PENv6fknCe5Y22n7rh8JlWNS3HIHkA2W1qtlAjZauQfEW +kP1IuT1MLyBIoU77Uxs6cwYcZ6Tx35+qB8sb0FI4C2vQ6IUYw0KfKxjnZrrtR0V5a ZkmUGE2w3Y6sfn1g/1R7GUEV7jO0vEJ7emGmoJEI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Evan Quan , Qiu Wenbo , Alex Deucher Subject: [PATCH 5.7 168/179] drm/amd/powerplay: fix a crash when overclocking Vega M Date: Mon, 27 Jul 2020 16:05:43 +0200 Message-Id: <20200727134940.845226365@linuxfoundation.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200727134932.659499757@linuxfoundation.org> References: <20200727134932.659499757@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: Qiu Wenbo commit 88bb16ad998a0395fe4b346b7d3f621aaa0a2324 upstream. 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)") Reviewed-by: Evan Quan Signed-off-by: Qiu Wenbo Signed-off-by: Alex Deucher Cc: stable@vger.kernel.org Signed-off-by: Greg Kroah-Hartman --- drivers/gpu/drm/amd/powerplay/smumgr/vegam_smumgr.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) --- a/drivers/gpu/drm/amd/powerplay/smumgr/vegam_smumgr.c +++ b/drivers/gpu/drm/amd/powerplay/smumgr/vegam_smumgr.c @@ -642,9 +642,6 @@ static int vegam_get_dependency_volt_by_ /* 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 * @@ -652,8 +649,13 @@ static int vegam_get_dependency_volt_by_ 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;