Received: by 2002:a05:6358:16cc:b0:ea:6187:17c9 with SMTP id r12csp11709790rwl; Tue, 3 Jan 2023 03:40:18 -0800 (PST) X-Google-Smtp-Source: AMrXdXtbeC9AI9FbNJb9hqWozSQDm3CRndu7qFkBDqH0/5Lqu+XXB7Oz4rvB0YcYErmLdOUOpraW X-Received: by 2002:a17:907:80ca:b0:7c1:540c:e214 with SMTP id io10-20020a17090780ca00b007c1540ce214mr39047294ejc.47.1672746018473; Tue, 03 Jan 2023 03:40:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672746018; cv=none; d=google.com; s=arc-20160816; b=blWNZsnsD7A5/D0pGCXNRLSw8KfQHcf+pxRs8SrJe5Dg1YXGYZQHFBglfFPXk8L29U sTo2DuFdM1vgyEjOMrW33q7JP7Nu7ASadWgfgm48wdA4jHq0Dy22W2FbRjLzPCUVJzqc 31BI7EqlCqKklxH7Rcdws1r1XOII3wcckyGZX1ddIqGSam2B53mH3W3sMrYpsuKGlQKH mppU3Hi8uVRcFlvxQhdQDayWfNheiUTNWWffx8MbbJLVjA5EnLNZuRxtNLFOMCOwO0ul XdEfLfKr7UNpWLvu2gS2SIcsqoBs7qRXRxXogUpBR8b66bfwhv6pJzMFUSrT9wy0OndT M/kw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=7JxZraCjpsatLrwbEdBspSH/du0wNhZBJ69NszFYNqA=; b=HDcpqby2I5IR2nbnJu50K7li4dhZn2/uhy/I21h0kzUc7lSwL0Z9+k3W2Px11PXyhc xUIh1QEdBfWkfGp8nXSkFj68GUAetFs12qKCoCqKQnx5gCNTUkJSnagXTGXsDUbflrTB Gq7GfdVWmQUqG2aLHRv+bBiCjkfWOxdAVREFc0yATRRpod6BmbmOAmzSBe86w+eWZdv/ 9sR9bGzgzHdZ9/vcmjfgecKbkNfLELbH1Nk0dBuic8ZK2nnR1/t4g/uCpyHt6W+S5IrV TWJZJcIcB7DiQgHwaJX0VGT+C71B1MRUbjvzdcy1yzb4xQSLUHktgcUFu3l2Fk2TDwQC PL/A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mediatek.com header.s=dk header.b=enFoLHie; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=mediatek.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id nc8-20020a1709071c0800b007b2a6aaff06si32963391ejc.50.2023.01.03.03.39.58; Tue, 03 Jan 2023 03:40:18 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@mediatek.com header.s=dk header.b=enFoLHie; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=mediatek.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237544AbjACLbr (ORCPT + 62 others); Tue, 3 Jan 2023 06:31:47 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57800 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237476AbjACL3p (ORCPT ); Tue, 3 Jan 2023 06:29:45 -0500 Received: from mailgw02.mediatek.com (unknown [210.61.82.184]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 32D2ADFEA; Tue, 3 Jan 2023 03:29:39 -0800 (PST) X-UUID: c9d21d5e20fb46a2a49c9d2805149651-20230103 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Type:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:CC:To:From; bh=7JxZraCjpsatLrwbEdBspSH/du0wNhZBJ69NszFYNqA=; b=enFoLHieuFsb/RwsfYRlWaAnZWfE0VI+3gg5zfJL01fazrEX+a5R1e/SFTc2dubJLgL5/GHPO7ecw08DkSgMHfxgfooX6SmtaSaBXSzqCHlDp263Y6trRilGJwj8gO5SbBoj4Tw50xxuxbyPWaxCQbSIr0TeQBreh4r/KaiaEJg=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.16,REQID:f6cc51a2-eb7e-4340-b219-b8d3e77c8df4,IP:0,U RL:0,TC:0,Content:0,EDM:0,RT:0,SF:95,FILE:0,BULK:0,RULE:Release_Ham,ACTION :release,TS:95 X-CID-INFO: VERSION:1.1.16,REQID:f6cc51a2-eb7e-4340-b219-b8d3e77c8df4,IP:0,URL :0,TC:0,Content:0,EDM:0,RT:0,SF:95,FILE:0,BULK:0,RULE:Spam_GS981B3D,ACTION :quarantine,TS:95 X-CID-META: VersionHash:09771b1,CLOUDID:b364aaf4-ff42-4fb0-b929-626456a83c14,B ulkID:230103192931S8XQSS7J,BulkQuantity:0,Recheck:0,SF:38|28|17|19|48,TC:n il,Content:0,EDM:-3,IP:nil,URL:11|1,File:nil,Bulk:nil,QS:nil,BEC:nil,COL:0 ,OSI:0,OSA:0 X-CID-BVR: 0 X-UUID: c9d21d5e20fb46a2a49c9d2805149651-20230103 Received: from mtkmbs13n1.mediatek.inc [(172.21.101.193)] by mailgw02.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 1898754391; Tue, 03 Jan 2023 19:29:28 +0800 Received: from mtkmbs11n1.mediatek.inc (172.21.101.186) by mtkmbs13n2.mediatek.inc (172.21.101.108) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.792.15; Tue, 3 Jan 2023 19:29:28 +0800 Received: from mtksdccf07.mediatek.inc (172.21.84.99) by mtkmbs11n1.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.2.792.15 via Frontend Transport; Tue, 3 Jan 2023 19:29:28 +0800 From: Roger Lu To: Matthias Brugger , Enric Balletbo Serra , Kevin Hilman , Nicolas Boichat CC: Fan Chen , Roger Lu , Jia-wei Chang , , , , , , Subject: [PATCH v3 13/14] soc: mediatek: mtk-svs: add thermal voltage compensation if needed Date: Tue, 3 Jan 2023 19:29:24 +0800 Message-ID: <20230103112925.16554-14-roger.lu@mediatek.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20230103112925.16554-1-roger.lu@mediatek.com> References: <20230103112925.16554-1-roger.lu@mediatek.com> MIME-Version: 1.0 Content-Type: text/plain X-MTK: N X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS, SPF_PASS,UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Some extreme test environment may keep IC temperature very low or very high during system boot stage. For stability concern, we add thermal voltage compenstation if needed no matter svs bank phase is in init02 or mon mode. Signed-off-by: Roger Lu --- drivers/soc/mediatek/mtk-svs.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/drivers/soc/mediatek/mtk-svs.c b/drivers/soc/mediatek/mtk-svs.c index 1b4798a9101c..581bb8373b0c 100644 --- a/drivers/soc/mediatek/mtk-svs.c +++ b/drivers/soc/mediatek/mtk-svs.c @@ -585,7 +585,7 @@ static int svs_adjust_pm_opp_volts(struct svs_bank *svsb) } /* Get thermal effect */ - if (svsb->phase == SVSB_PHASE_MON) { + if (!IS_ERR_OR_NULL(svsb->tzd)) { ret = thermal_zone_get_temp(svsb->tzd, &tzone_temp); if (ret || (svsb->temp > SVSB_TEMP_UPPER_BOUND && svsb->temp < SVSB_TEMP_LOWER_BOUND)) { @@ -600,7 +600,8 @@ static int svs_adjust_pm_opp_volts(struct svs_bank *svsb) temp_voffset += svsb->tzone_ltemp_voffset; /* 2-line bank update all opp volts when running mon mode */ - if (svsb->type == SVSB_HIGH || svsb->type == SVSB_LOW) { + if (svsb->phase == SVSB_PHASE_MON && (svsb->type == SVSB_HIGH || + svsb->type == SVSB_LOW)) { opp_start = 0; opp_stop = svsb->opp_count; } @@ -616,11 +617,6 @@ static int svs_adjust_pm_opp_volts(struct svs_bank *svsb) /* do nothing */ goto unlock_mutex; case SVSB_PHASE_INIT02: - svsb_volt = max(svsb->volt[i], svsb->vmin); - opp_volt = svs_bank_volt_to_opp_volt(svsb_volt, - svsb->volt_step, - svsb->volt_base); - break; case SVSB_PHASE_MON: svsb_volt = max(svsb->volt[i] + temp_voffset, svsb->vmin); opp_volt = svs_bank_volt_to_opp_volt(svsb_volt, @@ -1714,7 +1710,7 @@ static int svs_bank_resource_setup(struct svs_platform *svsp) } } - if (svsb->mode_support & SVSB_MODE_MON) { + if (!IS_ERR_OR_NULL(svsb->tzone_name)) { svsb->tzd = thermal_zone_get_zone_by_name(svsb->tzone_name); if (IS_ERR(svsb->tzd)) { dev_err(svsb->dev, "cannot get \"%s\" thermal zone\n", @@ -2158,6 +2154,7 @@ static struct svs_bank svs_mt8192_banks[] = { .type = SVSB_LOW, .set_freq_pct = svs_set_bank_freq_pct_v3, .get_volts = svs_get_bank_volts_v3, + .tzone_name = "gpu1", .volt_flags = SVSB_REMOVE_DVTFIXED_VOLT, .mode_support = SVSB_MODE_INIT02, .opp_count = MAX_OPP_ENTRIES, @@ -2175,6 +2172,10 @@ static struct svs_bank svs_mt8192_banks[] = { .core_sel = 0x0fff0100, .int_st = BIT(0), .ctl0 = 0x00540003, + .tzone_htemp = 85000, + .tzone_htemp_voffset = 0, + .tzone_ltemp = 25000, + .tzone_ltemp_voffset = 7, }, { .sw_id = SVSB_GPU, -- 2.18.0