From patchwork Tue Jan 3 11:29:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roger Lu X-Patchwork-Id: 38385 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp4561993wrt; Tue, 3 Jan 2023 03:31:39 -0800 (PST) X-Google-Smtp-Source: AMrXdXuQqetMTSznpvoDSli+7OA9fIQh0G8+0kOKlo/1KL+9+FoOTu0IAAai3EJTtUcGuq32eIC8 X-Received: by 2002:a17:907:3e05:b0:84c:eca0:5f67 with SMTP id hp5-20020a1709073e0500b0084ceca05f67mr42696ejc.54.1672745498986; Tue, 03 Jan 2023 03:31:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672745498; cv=none; d=google.com; s=arc-20160816; b=0wKXRmRExKJXIvpS0CegNcrg6NT6A4T9m52in8ymTEXqiGJ++tsCX5oMSKRUmXnVF1 dguubrPTUO546godJgs15CYHozwRXe86mmYWNPffgMRDmiSL7VQ1I0/JP9uSXGN1dGWH 8Fb/PcCe+36E6VrLb18/Z7gv6pi46Hd5H9qDZ8+fC0H/mL3B2hggynVROxmZaX6yVNNJ eVJqzUi/VaO6MYHXhr99ELh34KFSVGH67TGTNQzNHXnfHsZ6sOXpAsA2N6JqS4cL+Lyn kAFVu540V1fDubaeFYtwV/BoyYF5L8xuxY7BxYhUvxjtEiiHyK1O5XnDbgn6TuSjh3yo te1A== 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=ehDXbWE7c2/1x4Hvq0je5a3soIAyc70ylWW5qGoa4JM=; b=jXot2Mc3SaySkCNdcsToadoASWzfk6K6jGVmBKpGG/rLSnosW/KcrdgLLoYjeBFUwk fzZZKg1VikqQT+Z1Xdn3vkJidFV/tynM0GXtiid8s9ZgSwDO4EswyWnJajp5MoDGuti2 sT1KWX9HBv1Wi78CdCXx4J4E33wvayj0oCHrcTJc+0Q8Bp3+wMYlk2g+c+JnfuSqy4pN P4yskD/FYUFhb6akrjkv0Waae5hbTSypLBt/CAxFOk9jZsxOEgADjHSWaXyJZUKr+2RL ApYJ1PKMyNaeTa8k+jR9PRLvLe/q3G4pVJk9rU9JlRKpo+eLjNkNHpzW6tu2WM0r/kGq rMxw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mediatek.com header.s=dk header.b=itXlxSQH; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z10-20020a05640240ca00b0047ed405b4a7si28446814edb.224.2023.01.03.03.31.13; Tue, 03 Jan 2023 03:31:38 -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=itXlxSQH; 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 S237411AbjACL3v (ORCPT + 99 others); Tue, 3 Jan 2023 06:29:51 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57504 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237429AbjACL3m (ORCPT ); Tue, 3 Jan 2023 06:29:42 -0500 Received: from mailgw02.mediatek.com (unknown [210.61.82.184]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3248AFAEE; Tue, 3 Jan 2023 03:29:33 -0800 (PST) X-UUID: 0344f89caad3474597815f639370c3b6-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=ehDXbWE7c2/1x4Hvq0je5a3soIAyc70ylWW5qGoa4JM=; b=itXlxSQHD9TRXBvnP3BatwO8XbJ0f3UwqIKF4MDwpNDe0F2ekd9UqoKUSo/oQG1EvHPVMkqLRmKKEBFne2BQea+vptmwWJYUqRaFNdZqHM3sJNRodibA13R//DvjS4W9bH6/ABgPM0RGBHm1XHRp5soJblUg/z8KeQ/l1AwDElI=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.16,REQID:d5c0b618-d91a-46ba-8d27-1389320e442b,IP:0,U RL:0,TC:0,Content:-5,EDM:0,RT:0,SF:95,FILE:0,BULK:0,RULE:Release_Ham,ACTIO N:release,TS:90 X-CID-INFO: VERSION:1.1.16,REQID:d5c0b618-d91a-46ba-8d27-1389320e442b,IP:0,URL :0,TC:0,Content:-5,EDM:0,RT:0,SF:95,FILE:0,BULK:0,RULE:Spam_GS981B3D,ACTIO N:quarantine,TS:90 X-CID-META: VersionHash:09771b1,CLOUDID:7d64aaf4-ff42-4fb0-b929-626456a83c14,B ulkID:230103192928VSUAJLLU,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,NGT X-UUID: 0344f89caad3474597815f639370c3b6-20230103 Received: from mtkcas11.mediatek.inc [(172.21.101.40)] by mailgw02.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256) with ESMTP id 769229823; Tue, 03 Jan 2023 19:29:27 +0800 Received: from mtkmbs11n1.mediatek.inc (172.21.101.186) by mtkmbs10n1.mediatek.inc (172.21.101.34) 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:26 +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:26 +0800 From: Roger Lu To: Matthias Brugger , Enric Balletbo Serra , Kevin Hilman , Nicolas Boichat CC: Fan Chen , Roger Lu , Jia-wei Chang , , , , , , , Ricardo Ribalda Subject: [PATCH v3 01/14] soc: mediatek: mtk-svs: enable the IRQ later Date: Tue, 3 Jan 2023 19:29:12 +0800 Message-ID: <20230103112925.16554-2-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 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1754000784036610749?= X-GMAIL-MSGID: =?utf-8?q?1754000784036610749?= From: Ricardo Ribalda If the system does not come from reset (like when is booted via kexec(), the peripheral might trigger an IRQ before the data structures are initialized. Fixes: [ 0.227710] Unable to handle kernel NULL pointer dereference at virtual address 0000000000000f08 [ 0.227913] Call trace: [ 0.227918] svs_isr+0x8c/0x538 Signed-off-by: Ricardo Ribalda Signed-off-by: Roger Lu --- drivers/soc/mediatek/mtk-svs.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/drivers/soc/mediatek/mtk-svs.c b/drivers/soc/mediatek/mtk-svs.c index 0469c9dfeb04..91e06f43969d 100644 --- a/drivers/soc/mediatek/mtk-svs.c +++ b/drivers/soc/mediatek/mtk-svs.c @@ -2379,20 +2379,6 @@ static int svs_probe(struct platform_device *pdev) goto svs_probe_free_resource; } - svsp_irq = platform_get_irq(pdev, 0); - if (svsp_irq < 0) { - ret = svsp_irq; - goto svs_probe_free_resource; - } - - ret = devm_request_threaded_irq(svsp->dev, svsp_irq, NULL, svs_isr, - IRQF_ONESHOT, svsp->name, svsp); - if (ret) { - dev_err(svsp->dev, "register irq(%d) failed: %d\n", - svsp_irq, ret); - goto svs_probe_free_resource; - } - svsp->main_clk = devm_clk_get(svsp->dev, "main"); if (IS_ERR(svsp->main_clk)) { dev_err(svsp->dev, "failed to get clock: %ld\n", @@ -2414,6 +2400,20 @@ static int svs_probe(struct platform_device *pdev) goto svs_probe_clk_disable; } + svsp_irq = platform_get_irq(pdev, 0); + if (svsp_irq < 0) { + ret = svsp_irq; + goto svs_probe_iounmap; + } + + ret = devm_request_threaded_irq(svsp->dev, svsp_irq, NULL, svs_isr, + IRQF_ONESHOT, svsp->name, svsp); + if (ret) { + dev_err(svsp->dev, "register irq(%d) failed: %d\n", + svsp_irq, ret); + goto svs_probe_iounmap; + } + ret = svs_start(svsp); if (ret) { dev_err(svsp->dev, "svs start fail: %d\n", ret); From patchwork Tue Jan 3 11:29:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roger Lu X-Patchwork-Id: 38384 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp4561947wrt; Tue, 3 Jan 2023 03:31:32 -0800 (PST) X-Google-Smtp-Source: AMrXdXsIlyVpBhJcQKYviRaSIZei/h3/N6cuPOfBk8lwjmUq0YF9IO1ZREViWsDFSm7j2ry2cBQ6 X-Received: by 2002:a17:907:20b0:b0:7d3:8159:f361 with SMTP id pw16-20020a17090720b000b007d38159f361mr37725439ejb.36.1672745491951; Tue, 03 Jan 2023 03:31:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672745491; cv=none; d=google.com; s=arc-20160816; b=Jvo+YCScJQKmHTiefl5ZlgKnSP8OGnEnsXWEzMAqEtARAqeq2lAfqmLP5PiuHuzV3v Odz5EPt4v8TRqoT+TxnyNiEJKl+o1uWHL6DNitOtwjvGT4cRnMp9Qar7ejqpw+0KTYTO 2RKzFwO9x57jVHW1mZM+H/6/J8nugT018LrvOjBqYN6BRo9vPo559pcaEQ9iyPNlhS9l /JRfZcz3aRphI5YmhC6kLDpDmwVDHBz4ycThC2tN4NIHG0OD12+b2Wr4ZaPJyIJBqTZE vnREQbi7thkJG8xCMUGtgzTLMVszxgb3fcNobcuS2ImesZWZJgzekyUFrARou2cqmIWt zWXA== 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=khWND1a5Rv67qi9vjLgUZ2TaIXGaU8aXZECDx6Aj8Jo=; b=lHOMQ6oJeoSNDzlo6Mbahmv2XAXwmkl9PG5+Sl5A6p2OQSwtCxzHpPhGcbpJ2R7mkc hd1KA7lRW2LvIymUconVcR0QnR1P8hV880L9zf3QJTIyBnRJe2i+1QrVYRzfWTxG6b9e DaLha2WQrVHYfR4xyHy19dHryd1p+O03eHppr8CJ1MvACC4LZGTOhGR8AvRrrIvgvC8u BJI61ZQFUvJfgsIjkts6agkjL+itobh2LldaH9DbiDzRE2e3A5H/XWqlqnlOuvLkobw8 aqt56nwgVcoAWRSez6UWOH8HVfNmFaR7CmiO1rqMb/xRPOgb3wFK5d4WrfnI2BTTpOoV ifSg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mediatek.com header.s=dk header.b=Z2SeTwxW; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ji5-20020a170907980500b007addbdb9fbbsi28934065ejc.558.2023.01.03.03.31.06; Tue, 03 Jan 2023 03:31:31 -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=Z2SeTwxW; 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 S237424AbjACL34 (ORCPT + 99 others); Tue, 3 Jan 2023 06:29:56 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57498 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237433AbjACL3n (ORCPT ); Tue, 3 Jan 2023 06:29:43 -0500 Received: from mailgw02.mediatek.com (unknown [210.61.82.184]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2E3F3FCF6; Tue, 3 Jan 2023 03:29:34 -0800 (PST) X-UUID: ab98134abf474af48af11d3afea3b3f1-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=khWND1a5Rv67qi9vjLgUZ2TaIXGaU8aXZECDx6Aj8Jo=; b=Z2SeTwxW8KAXGYEwx6MkuzmiEB6PyLsNWC75EKBtFoBhohzcvXAQSLfv6IHCwm6HBDTB+magGU0GHDmPiAjBwB4rj4r63ZvJKJZ3kF15oVJJzF1fPNpaHBudB3/N5KW5cRklETZvX7tQ16i7rwBkLPepdJtty33LtvNuOzy+b80=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.16,REQID:ef957f4d-cdda-4fc9-a75b-88c6536aab97,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:ef957f4d-cdda-4fc9-a75b-88c6536aab97,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:349e1b8b-8530-4eff-9f77-222cf6e2895b,B ulkID:230103192928HO05TDYF,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,NGT X-UUID: ab98134abf474af48af11d3afea3b3f1-20230103 Received: from mtkcas11.mediatek.inc [(172.21.101.40)] by mailgw02.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256) with ESMTP id 1270680333; Tue, 03 Jan 2023 19:29:27 +0800 Received: from mtkmbs11n1.mediatek.inc (172.21.101.186) by mtkmbs10n1.mediatek.inc (172.21.101.34) 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:26 +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:26 +0800 From: Roger Lu To: Matthias Brugger , Enric Balletbo Serra , Kevin Hilman , Nicolas Boichat CC: Fan Chen , Roger Lu , Jia-wei Chang , , , , , , , Shang XiaoJing Subject: [PATCH v3 02/14] soc: mediatek: mtk-svs: Use pm_runtime_resume_and_get() in svs_init01() Date: Tue, 3 Jan 2023 19:29:13 +0800 Message-ID: <20230103112925.16554-3-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 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1754000776790219264?= X-GMAIL-MSGID: =?utf-8?q?1754000776790219264?= From: Shang XiaoJing svs_init01() calls pm_runtime_get_sync() and added fail path as svs_init01_finish to put usage_counter. However, pm_runtime_get_sync() will increment usage_counter even it failed. Fix it by replacing it with pm_runtime_resume_and_get() to keep usage counter balanced. Fixes: 681a02e95000 ("soc: mediatek: SVS: introduce MTK SVS engine") Signed-off-by: Shang XiaoJing Signed-off-by: Roger Lu --- drivers/soc/mediatek/mtk-svs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/soc/mediatek/mtk-svs.c b/drivers/soc/mediatek/mtk-svs.c index 91e06f43969d..465b60a5cedc 100644 --- a/drivers/soc/mediatek/mtk-svs.c +++ b/drivers/soc/mediatek/mtk-svs.c @@ -1324,7 +1324,7 @@ static int svs_init01(struct svs_platform *svsp) svsb->pm_runtime_enabled_count++; } - ret = pm_runtime_get_sync(svsb->opp_dev); + ret = pm_runtime_resume_and_get(svsb->opp_dev); if (ret < 0) { dev_err(svsb->dev, "mtcmos on fail: %d\n", ret); goto svs_init01_resume_cpuidle; From patchwork Tue Jan 3 11:29:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roger Lu X-Patchwork-Id: 38392 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp4562682wrt; Tue, 3 Jan 2023 03:33:38 -0800 (PST) X-Google-Smtp-Source: AMrXdXu48m8K/XAk5f6kRDvOxkiChPTPGjfhNlQGkm+2hLhO7ijukgaq2wFeU6/4hbkcY2VMv1sV X-Received: by 2002:a17:907:7da1:b0:7c1:31c:e884 with SMTP id oz33-20020a1709077da100b007c1031ce884mr51051247ejc.17.1672745618681; Tue, 03 Jan 2023 03:33:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672745618; cv=none; d=google.com; s=arc-20160816; b=zySXolohjioEwBgcYV6Rc5cU7I1xPVVu+7SYF+f8ITurs0A98+WcUWyNInN8LY9ktY n2K1IgXwonS1vuw9tVCFGHXp5aVKChKawdQZPpGLZO12aeuuHkm7f3hjwvQlljP3PrT4 PZJPyB5vAZ7uPH0pVsNNOiRytKQpfoXA0cssTDdfMd/JXvVwwZLRwye/Kc12eF0BNPk8 kU0R5mLhnXJbiuqyKNIIR/S997eySefJomsrC8OWL7QOyadbj1WFPOEGx8sxvHPpG9bw O/JOMTUPUbodKjd429J/vHMXXvtjoFg1R/Zq0XfiDaNszo19/5p8TbJiL0Z4oSGWIeG0 3ZEg== 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=vf6IcfalnyFtEwcYPBgscSxhCUGC67GQz9ghXYhk16o=; b=Gv+GyL8c9xDZKfXPO3yq5+lLez+Es4BJ97cciKItl8T4oHNoBqY/FUe6+uEY+TNAiA IJTBjCZoGkS/HjRmMVZchOdyYWfOBfzpAtn9647kgiIqIMtr+NurHYLIMeGW3rtqYmgD jLSJ32VeIp0NjoZ98sRGcVcKSZC/DfCykilE4tUSsCiXwriH2MDWbGyaGEloSyFfJCVn OvyMRxBM3ymEFjMusPmlLoEhT0L+w253AzkCm89/aMwEC+sfhZfcgovqwu4LcudiEohG 4JqWugDf9VafPZE/DJSu+kwNktlUbkPPWYdUBCM5JcxNSk3o6RVMsx3HWTD2YWO2wV9l 2gOg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mediatek.com header.s=dk header.b=iXBnmaZm; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id sb31-20020a1709076d9f00b007c4fda74f69si26714862ejc.241.2023.01.03.03.33.14; Tue, 03 Jan 2023 03:33:38 -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=iXBnmaZm; 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 S237535AbjACLb3 (ORCPT + 99 others); Tue, 3 Jan 2023 06:31:29 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57786 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237461AbjACL3p (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 7BE3CF03F; Tue, 3 Jan 2023 03:29:32 -0800 (PST) X-UUID: c0aa10b8ccbf46719f0f612fe6d7d22f-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=vf6IcfalnyFtEwcYPBgscSxhCUGC67GQz9ghXYhk16o=; b=iXBnmaZmVaA3MtKd34q/1M3YfSMRqyZ9ld57d4n4U0X8VJ8RshKnl+58Kx9wItjjHsOnFW7aV+FEcl6QzjBJWyOaAWb/XpIKTDPkzIT9qkaXUqq3+RNkAUmAytQvsNnZhNTKBwjb1OgdRN77ksm56h5pTBHow0Wg8X3UG/mMNXw=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.16,REQID:2957d9b0-b490-45a5-90a6-c71fe306039b,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:2957d9b0-b490-45a5-90a6-c71fe306039b,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:359e1b8b-8530-4eff-9f77-222cf6e2895b,B ulkID:230103192928A19EHKMY,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: c0aa10b8ccbf46719f0f612fe6d7d22f-20230103 Received: from mtkcas11.mediatek.inc [(172.21.101.40)] by mailgw02.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256) with ESMTP id 153076878; Tue, 03 Jan 2023 19:29:27 +0800 Received: from mtkmbs11n1.mediatek.inc (172.21.101.186) by mtkmbs10n1.mediatek.inc (172.21.101.34) 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:26 +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:26 +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 03/14] soc: mediatek: mtk-svs: clean up platform probing Date: Tue, 3 Jan 2023 19:29:14 +0800 Message-ID: <20230103112925.16554-4-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 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1754000909837155740?= X-GMAIL-MSGID: =?utf-8?q?1754000909837155740?= From: Matthias Brugger We only ever call the SoC specific probe function from svs_platform_probe. No need to carry that function in a global datastructure around. Signed-off-by: Matthias Brugger Reviewed-by: AngeloGioacchino Del Regno Signed-off-by: Roger Lu --- drivers/soc/mediatek/mtk-svs.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/drivers/soc/mediatek/mtk-svs.c b/drivers/soc/mediatek/mtk-svs.c index 465b60a5cedc..5abf94aafbac 100644 --- a/drivers/soc/mediatek/mtk-svs.c +++ b/drivers/soc/mediatek/mtk-svs.c @@ -319,7 +319,6 @@ static const u32 svs_regs_v2[] = { * @banks: svs banks that svs platform supports * @rst: svs platform reset control * @efuse_parsing: svs platform efuse parsing function pointer - * @probe: svs platform probe function pointer * @efuse_max: total number of svs efuse * @tefuse_max: total number of thermal efuse * @regs: svs platform registers map @@ -336,7 +335,6 @@ struct svs_platform { struct svs_bank *banks; struct reset_control *rst; bool (*efuse_parsing)(struct svs_platform *svsp); - int (*probe)(struct svs_platform *svsp); size_t efuse_max; size_t tefuse_max; const u32 *regs; @@ -2347,11 +2345,10 @@ static struct svs_platform *svs_platform_probe(struct platform_device *pdev) svsp->name = svsp_data->name; svsp->banks = svsp_data->banks; svsp->efuse_parsing = svsp_data->efuse_parsing; - svsp->probe = svsp_data->probe; svsp->regs = svsp_data->regs; svsp->bank_max = svsp_data->bank_max; - ret = svsp->probe(svsp); + ret = svsp_data->probe(svsp); if (ret) return ERR_PTR(ret); From patchwork Tue Jan 3 11:29:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roger Lu X-Patchwork-Id: 38396 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp4563011wrt; Tue, 3 Jan 2023 03:34:36 -0800 (PST) X-Google-Smtp-Source: AMrXdXuSuqAbzu11ipniklHFpDhqpvEd7/wGwEPyKSYDKIC8/PDSvqsieceNvtU4Mc+2H8HNEx/i X-Received: by 2002:a17:907:c70b:b0:7c0:e535:13fd with SMTP id ty11-20020a170907c70b00b007c0e53513fdmr37627816ejc.70.1672745676530; Tue, 03 Jan 2023 03:34:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672745676; cv=none; d=google.com; s=arc-20160816; b=szlsTkt+kKMJ3z8YFrf+oo9ydFTeCkyQRwagREFLUNiyceBvb6v7upJMt15yisKYRw 6cd3AyQqFYSJJtyBaJsh+fHNqN/wXDWOBQLAMu1Z/Kkad9IhbPnRRxKM7rWXH+10k3CC F9NRS+Z7ct0Vq6p355ULuAO7Dcda7xFc7/kGL31rRwT0fqhoY3vdR1Lt7TjceDyul62U OXWBVUy1M5FRbGM0+J1dyYBiw+XygDYBiDkFrksp+ltg+uokngAqhrM1r9ZFasUYoq0l 0+Bc1gzyXgfC0igHcE4TaRnQKpNL5+eU/7/ICrajto1AaCCTPyARwtDrW76Lb6lL0JE/ 1R0Q== 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=6Sq/sAfTpgkWc7ZeE72qhux4vsS2w/D6it6j/hKEQAs=; b=SpB2V50BGYDMYcaFSib1DYVqEIkhtPa1sEU0/srAUEaqyUT2Kpy10hasGacu7nEC/L x1/37KbUfKDsRceD/Z+XxP2FF8c/bG2L5yWHmByfm4qrnivwD2dH85bh85+Xt0w90kCs 9aztGrbFSexXsHWTu8HSvdu464aeC6jdfWXbY+OitYTzElQ6JwRvu1qRITpgZOEK7NqQ 2MfjtZEOAGMg4c5dWowTcOdVsT700Dek3OXq8tEFQn8FHeKuCybFgfNRBlQnuWYME8zM 22vrN+h1WgS3vrS4vyPGe3NguYpkoeX2sz/A5CpDtEZPrvCzn8GC8/v1ShElPFUt60Z5 QSug== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mediatek.com header.s=dk header.b=M12pbSd3; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id wt12-20020a170906ee8c00b007c0d4f96d8esi26370658ejb.566.2023.01.03.03.34.12; Tue, 03 Jan 2023 03:34:36 -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=M12pbSd3; 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 S237532AbjACLbW (ORCPT + 99 others); Tue, 3 Jan 2023 06:31:22 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57512 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237459AbjACL3p (ORCPT ); Tue, 3 Jan 2023 06:29:45 -0500 Received: from mailgw01.mediatek.com (unknown [60.244.123.138]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5C3EFDFF4; Tue, 3 Jan 2023 03:29:32 -0800 (PST) X-UUID: 529f34589288435bbd11259abc8c49e2-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=6Sq/sAfTpgkWc7ZeE72qhux4vsS2w/D6it6j/hKEQAs=; b=M12pbSd33pUBNXrtfdOe21AnegQXpEhlPgH8BnAB0eVQudERBUdZJZJZQdJvZQP3vhZX/sxs+ntoovZGlnDlERUwG+papn/8Ra1ARu1i2GjZtxdVcpLdluQilXZjarRLlf7lFvbf2iv2vpwF7tDee0Cs8zdwTzlmXNayUt3YmVM=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.16,REQID:ccfb4043-6743-4a94-906d-f3a8e5bd36f0,IP:0,U RL:0,TC:0,Content:-5,EDM:0,RT:0,SF:95,FILE:0,BULK:0,RULE:Release_Ham,ACTIO N:release,TS:90 X-CID-INFO: VERSION:1.1.16,REQID:ccfb4043-6743-4a94-906d-f3a8e5bd36f0,IP:0,URL :0,TC:0,Content:-5,EDM:0,RT:0,SF:95,FILE:0,BULK:0,RULE:Spam_GS981B3D,ACTIO N:quarantine,TS:90 X-CID-META: VersionHash:09771b1,CLOUDID:3d9e1b8b-8530-4eff-9f77-222cf6e2895b,B ulkID:230103192928V0CHKV59,BulkQuantity:1,Recheck:0,SF:38|28|17|19|48,TC:n il,Content:0,EDM:-3,IP:nil,URL:11|1,File:nil,Bulk:40,QS:nil,BEC:nil,COL:0, OSI:0,OSA:0 X-CID-BVR: 0 X-UUID: 529f34589288435bbd11259abc8c49e2-20230103 Received: from mtkcas11.mediatek.inc [(172.21.101.40)] by mailgw01.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256) with ESMTP id 1785882082; Tue, 03 Jan 2023 19:29:28 +0800 Received: from mtkmbs11n1.mediatek.inc (172.21.101.185) by mtkmbs11n1.mediatek.inc (172.21.101.185) 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:26 +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:26 +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 04/14] soc: mediatek: mtk-svs: improve readability of platform_probe Date: Tue, 3 Jan 2023 19:29:15 +0800 Message-ID: <20230103112925.16554-5-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 X-MTK: N X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS,UNPARSEABLE_RELAY autolearn=no 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1754000970623355230?= X-GMAIL-MSGID: =?utf-8?q?1754000970623355230?= From: Matthias Brugger If a compatible misses a match data entry, then something is wrong in the development phase, we don't need to check for that at runtime. Signed-off-by: Matthias Brugger Reviewed-by: AngeloGioacchino Del Regno Signed-off-by: Roger Lu --- drivers/soc/mediatek/mtk-svs.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/drivers/soc/mediatek/mtk-svs.c b/drivers/soc/mediatek/mtk-svs.c index 5abf94aafbac..7fea1a5bb842 100644 --- a/drivers/soc/mediatek/mtk-svs.c +++ b/drivers/soc/mediatek/mtk-svs.c @@ -2332,10 +2332,6 @@ static struct svs_platform *svs_platform_probe(struct platform_device *pdev) int ret; svsp_data = of_device_get_match_data(&pdev->dev); - if (!svsp_data) { - dev_err(&pdev->dev, "no svs platform data?\n"); - return ERR_PTR(-EPERM); - } svsp = devm_kzalloc(&pdev->dev, sizeof(*svsp), GFP_KERNEL); if (!svsp) From patchwork Tue Jan 3 11:29:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roger Lu X-Patchwork-Id: 38394 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp4562821wrt; Tue, 3 Jan 2023 03:34:01 -0800 (PST) X-Google-Smtp-Source: AMrXdXsNela7qFbtyQQVn87dyzNmlvYaV/KHuBIGYGj3HaBVcEhlYw0hvQIo/4Cn++/W9qZ5s3c+ X-Received: by 2002:a17:907:214d:b0:837:4378:dbd6 with SMTP id rk13-20020a170907214d00b008374378dbd6mr39366642ejb.22.1672745641174; Tue, 03 Jan 2023 03:34:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672745641; cv=none; d=google.com; s=arc-20160816; b=Y72USbIVF9E4BVT3rtLWxeIAHce6E17xE2kfJ0+JDc5iwaSNH8jEjud0YD+0v08qVj 7QYDmqbvyCzy4Nw/cm9GGaHhhHiwTVaoea6tIuxPCvzHRLakYACyzNWDVCGEJ1+H6gBU kxyzVzLePr86J5w6wlAfqctSHqPpCACO6Lidj5xfp9CNODTwTzIgocQSHWFXkgAdtTum oU+gnddzINCkbPXcrjyNpKoDeXGQBDCFcgmPhp9ln1rZ16Kml2244tx1hE8/neyGzmFG w+dHPBKX75Tl6+4tCpqRwMv1NhoULXElZqHH0LnhiH7MIvnoeUmE79YhuDdIAVRx7vcY 2eyg== 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=4gNcF7vsUH3TomKrULGmuoGv4uA8ZyTj2XFNqGbNkWo=; b=0RTzbh/NOFULGTj49xYlTMjCNruQTtbYorJLuy3iXGsm1pOd7XLnxj+t1q4YSRE0Kt hGGXMMsI2IXdz6JmCq3zg+kR7aw2BNT0WJmYvsMHDqirM4U+3EffGponkjVOMzasY8pM BNYaaDP+GcfbMzU16D1V7TmxyyjNKvsnPZvD5+vmLe37R+oVXWTU/8DqinNaF5BIxjJf uK2QlxY03NWhHZDEPd4+eSldB5ShMUa+s5cBFrVr8l3UTGmX5gbAjRENaw50ozhZgtjG nK396fS780G+bvIum2Sd29b4yZF12fwDuU/QZla3DKsGHmf4tP+a2UhfSczQOzvi6IQU Kvxg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mediatek.com header.s=dk header.b=UCyBMSNL; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id xi4-20020a170906dac400b007adc8c49d83si17071616ejb.477.2023.01.03.03.33.36; Tue, 03 Jan 2023 03:34:01 -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=UCyBMSNL; 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 S237518AbjACLae (ORCPT + 99 others); Tue, 3 Jan 2023 06:30:34 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57760 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237448AbjACL3o (ORCPT ); Tue, 3 Jan 2023 06:29:44 -0500 Received: from mailgw02.mediatek.com (unknown [210.61.82.184]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 258DA10042; Tue, 3 Jan 2023 03:29:38 -0800 (PST) X-UUID: f69125d12c6d445197d68a33d7d36f85-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=4gNcF7vsUH3TomKrULGmuoGv4uA8ZyTj2XFNqGbNkWo=; b=UCyBMSNLCktALEJjdn1Tg5zzc/hJxnJ1IcL+KpwjWAjSO3BQ5MjCfuc5RBqumGSMrOdqaqWRYZYboXrHC9HKBuSiLhEOiOuq3ZBHzXZ6ogAzeO0wnxIskaWvh0IW8FHR41WnKBj6zPLttWqErqNJRxlOnUF1B7DS7Bshw02nz3E=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.16,REQID:711e4342-8c0e-47e4-9d64-71e63ffc8008,IP:0,U RL:0,TC:0,Content:-25,EDM:0,RT:0,SF:95,FILE:0,BULK:0,RULE:Release_Ham,ACTI ON:release,TS:70 X-CID-INFO: VERSION:1.1.16,REQID:711e4342-8c0e-47e4-9d64-71e63ffc8008,IP:0,URL :0,TC:0,Content:-25,EDM:0,RT:0,SF:95,FILE:0,BULK:0,RULE:Spam_GS981B3D,ACTI ON:quarantine,TS:70 X-CID-META: VersionHash:09771b1,CLOUDID:719e1b8b-8530-4eff-9f77-222cf6e2895b,B ulkID:230103192931P9V2WQ1E,BulkQuantity:1,Recheck:0,SF:38|28|17|19|48,TC:n il,Content:0,EDM:-3,IP:nil,URL:11|1,File:nil,Bulk:40,QS:nil,BEC:nil,COL:0, OSI:0,OSA:0 X-CID-BVR: 0 X-UUID: f69125d12c6d445197d68a33d7d36f85-20230103 Received: from mtkcas11.mediatek.inc [(172.21.101.40)] by mailgw02.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256) with ESMTP id 1460600979; Tue, 03 Jan 2023 19:29:28 +0800 Received: from mtkmbs11n1.mediatek.inc (172.21.101.186) by mtkmbs13n1.mediatek.inc (172.21.101.193) 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:27 +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:27 +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 05/14] soc: mediatek: mtk-svs: move svs_platform_probe into probe Date: Tue, 3 Jan 2023 19:29:16 +0800 Message-ID: <20230103112925.16554-6-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 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1754000933320566856?= X-GMAIL-MSGID: =?utf-8?q?1754000933320566856?= From: Matthias Brugger Moving svs_platform_probe into driver probe function will allow us to reduce svs_platform members. This will be done in a follow-up patch. Signed-off-by: Matthias Brugger Reviewed-by: AngeloGioacchino Del Regno Signed-off-by: Roger Lu --- drivers/soc/mediatek/mtk-svs.c | 20 ++++---------------- 1 file changed, 4 insertions(+), 16 deletions(-) diff --git a/drivers/soc/mediatek/mtk-svs.c b/drivers/soc/mediatek/mtk-svs.c index 7fea1a5bb842..bbec96696c55 100644 --- a/drivers/soc/mediatek/mtk-svs.c +++ b/drivers/soc/mediatek/mtk-svs.c @@ -2325,17 +2325,17 @@ static const struct of_device_id svs_of_match[] = { }, }; -static struct svs_platform *svs_platform_probe(struct platform_device *pdev) +static int svs_probe(struct platform_device *pdev) { struct svs_platform *svsp; const struct svs_platform_data *svsp_data; - int ret; + int ret, svsp_irq; svsp_data = of_device_get_match_data(&pdev->dev); svsp = devm_kzalloc(&pdev->dev, sizeof(*svsp), GFP_KERNEL); if (!svsp) - return ERR_PTR(-ENOMEM); + return -ENOMEM; svsp->dev = &pdev->dev; svsp->name = svsp_data->name; @@ -2346,19 +2346,7 @@ static struct svs_platform *svs_platform_probe(struct platform_device *pdev) ret = svsp_data->probe(svsp); if (ret) - return ERR_PTR(ret); - - return svsp; -} - -static int svs_probe(struct platform_device *pdev) -{ - struct svs_platform *svsp; - int svsp_irq, ret; - - svsp = svs_platform_probe(pdev); - if (IS_ERR(svsp)) - return PTR_ERR(svsp); + return ret; if (!svs_is_efuse_data_correct(svsp)) { dev_notice(svsp->dev, "efuse data isn't correct\n"); From patchwork Tue Jan 3 11:29:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roger Lu X-Patchwork-Id: 38393 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp4562820wrt; Tue, 3 Jan 2023 03:34:01 -0800 (PST) X-Google-Smtp-Source: AMrXdXujG4sbc1JPFyCi3vO6+6VOgd4efDQxR5RJ8utqMf2ZPn3fJ/84Qn1qofjPjebNCp8Y1LXU X-Received: by 2002:a05:6402:1c95:b0:48b:a29f:4bef with SMTP id cy21-20020a0564021c9500b0048ba29f4befmr10720849edb.6.1672745640966; Tue, 03 Jan 2023 03:34:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672745640; cv=none; d=google.com; s=arc-20160816; b=x+fzPM+JAmrYTzxQFhGZKBPMl5QWkqO91wrKkN2emKwjA30kZ25+wxBxCIusgdLdiy 3WlFXZnB/BsUqGWO4zpzhbSeooaWqPVARJE3w3JnfaUVb6Mt6xKpsKgOEHhJhpA9SRjN N2Nik4vEZyT4ZdfDxU++nZsviNhCwgXK5Q8R6P9W0p7c/OfpLITLZt7XOTbPBB1KzZt+ m393nXlCsiSuIef057fjimEcDhJbbtJR2VjaJIlH4idMC7IC9iOmySJuvaYfL9SNYzFZ MwkmIJKMlJheUK8+b5gUTAwAJvj1k6gkEXNRhUHBrFEA3LmWwuUJAqBnEQIAYTCYaRBw Psrg== 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=ZYhjIXpUxLFLAxdNKrtJBR6ZBD1h3ZRO4PIhBpFBTnM=; b=bwnGZYxv+EGQuJjrIaHUBW2EQj4mPHWCZA4UZ/qVH4ysJ0ua36kcycilZuUk9FueCy Ui/+a0S/5DJ+0H0SsajRoVEYK6F+QHPb1fNjMzeT9fxHx7VcqH/FPRl1cXh2K6kyAT7U ndagBc7G4DMqNWjRCkLHDHpJVFvJOkSHRxKZfVd2xmWFdv1d/sAZGV8TQEmEahgF46Yq yVCIRL1hJcoqcbZX8HGArCX58VuMhi7o4cjJblhm2qwoEsFe92wXfnhJtvXYy/NE2UpL dEXzlLaYi4MVPANVufiHb8P0VToB7QNNK//7B6ycEfQofxBBZLjFeCN7orv2zcLOzZdc xbeg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mediatek.com header.s=dk header.b=iVbjB25m; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e8-20020aa7d7c8000000b0046f9bcabfe6si25239338eds.601.2023.01.03.03.33.36; Tue, 03 Jan 2023 03:34:00 -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=iVbjB25m; 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 S230337AbjACLbA (ORCPT + 99 others); Tue, 3 Jan 2023 06:31:00 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57762 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237449AbjACL3o (ORCPT ); Tue, 3 Jan 2023 06:29:44 -0500 Received: from mailgw02.mediatek.com (unknown [210.61.82.184]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3C6A9101C4; Tue, 3 Jan 2023 03:29:40 -0800 (PST) X-UUID: b227e30382c243d48c6f37c664012c1b-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=ZYhjIXpUxLFLAxdNKrtJBR6ZBD1h3ZRO4PIhBpFBTnM=; b=iVbjB25mpGx9FpjLQ0c9QOaPWpusepNufJNvO3iiaZ4sMFWQt0UtLGrk0TLmhfTg6bvH4MFt6Ahs9znQ3sSb/rw0LcJZAL6zN5yxBz1QcruUCULPCyHZkXaql2ilK4iISs467ml53efEOD1FxHLrRMOEdbP31tz/U8fSsZvri0Y=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.16,REQID:213207a3-21b3-455a-af76-e9a972d3b20c,IP:0,U RL:0,TC:0,Content:-5,EDM:0,RT:0,SF:95,FILE:0,BULK:0,RULE:Release_Ham,ACTIO N:release,TS:90 X-CID-INFO: VERSION:1.1.16,REQID:213207a3-21b3-455a-af76-e9a972d3b20c,IP:0,URL :0,TC:0,Content:-5,EDM:0,RT:0,SF:95,FILE:0,BULK:0,RULE:Spam_GS981B3D,ACTIO N:quarantine,TS:90 X-CID-META: VersionHash:09771b1,CLOUDID:b064aaf4-ff42-4fb0-b929-626456a83c14,B ulkID:230103192931VUTDZ9CE,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: b227e30382c243d48c6f37c664012c1b-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 2118861942; 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:27 +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:27 +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 06/14] soc: mediatek: mtk-svs: delete superfluous platform data entries Date: Tue, 3 Jan 2023 19:29:17 +0800 Message-ID: <20230103112925.16554-7-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 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1754000932779496346?= X-GMAIL-MSGID: =?utf-8?q?1754000932779496346?= From: Matthias Brugger The platform name and efuse parsing function pointer are only used while probing the device. Use them from the svs_platform_data struct instead. Signed-off-by: Matthias Brugger Reviewed-by: AngeloGioacchino Del Regno Signed-off-by: Roger Lu --- drivers/soc/mediatek/mtk-svs.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/drivers/soc/mediatek/mtk-svs.c b/drivers/soc/mediatek/mtk-svs.c index bbec96696c55..308cd36a23fc 100644 --- a/drivers/soc/mediatek/mtk-svs.c +++ b/drivers/soc/mediatek/mtk-svs.c @@ -311,14 +311,12 @@ static const u32 svs_regs_v2[] = { /** * struct svs_platform - svs platform control - * @name: svs platform name * @base: svs platform register base * @dev: svs platform device * @main_clk: main clock for svs bank * @pbank: svs bank pointer needing to be protected by spin_lock section * @banks: svs banks that svs platform supports * @rst: svs platform reset control - * @efuse_parsing: svs platform efuse parsing function pointer * @efuse_max: total number of svs efuse * @tefuse_max: total number of thermal efuse * @regs: svs platform registers map @@ -327,14 +325,12 @@ static const u32 svs_regs_v2[] = { * @tefuse: thermal efuse data received from NVMEM framework */ struct svs_platform { - char *name; void __iomem *base; struct device *dev; struct clk *main_clk; struct svs_bank *pbank; struct svs_bank *banks; struct reset_control *rst; - bool (*efuse_parsing)(struct svs_platform *svsp); size_t efuse_max; size_t tefuse_max; const u32 *regs; @@ -2009,7 +2005,7 @@ static bool svs_is_efuse_data_correct(struct svs_platform *svsp) svsp->efuse_max /= sizeof(u32); nvmem_cell_put(cell); - return svsp->efuse_parsing(svsp); + return true; } static struct device *svs_get_subsys_device(struct svs_platform *svsp, @@ -2338,9 +2334,7 @@ static int svs_probe(struct platform_device *pdev) return -ENOMEM; svsp->dev = &pdev->dev; - svsp->name = svsp_data->name; svsp->banks = svsp_data->banks; - svsp->efuse_parsing = svsp_data->efuse_parsing; svsp->regs = svsp_data->regs; svsp->bank_max = svsp_data->bank_max; @@ -2351,6 +2345,12 @@ static int svs_probe(struct platform_device *pdev) if (!svs_is_efuse_data_correct(svsp)) { dev_notice(svsp->dev, "efuse data isn't correct\n"); ret = -EPERM; + goto svs_probe_free_efuse; + } + + if (!svsp_data->efuse_parsing(svsp)) { + dev_err(svsp->dev, "efuse data parsing failed\n"); + ret = -EPERM; goto svs_probe_free_resource; } @@ -2388,7 +2388,7 @@ static int svs_probe(struct platform_device *pdev) } ret = devm_request_threaded_irq(svsp->dev, svsp_irq, NULL, svs_isr, - IRQF_ONESHOT, svsp->name, svsp); + IRQF_ONESHOT, svsp_data->name, svsp); if (ret) { dev_err(svsp->dev, "register irq(%d) failed: %d\n", svsp_irq, ret); @@ -2416,11 +2416,13 @@ static int svs_probe(struct platform_device *pdev) clk_disable_unprepare(svsp->main_clk); svs_probe_free_resource: - if (!IS_ERR_OR_NULL(svsp->efuse)) - kfree(svsp->efuse); if (!IS_ERR_OR_NULL(svsp->tefuse)) kfree(svsp->tefuse); +svs_probe_free_efuse: + if (!IS_ERR_OR_NULL(svsp->efuse)) + kfree(svsp->efuse); + return ret; } From patchwork Tue Jan 3 11:29:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roger Lu X-Patchwork-Id: 38397 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp4563040wrt; Tue, 3 Jan 2023 03:34:40 -0800 (PST) X-Google-Smtp-Source: AMrXdXtBQgR3C7NtJZqBnQ46AMvwmb2VzYiv2F4RjGYjlUbs0U63iryGBdq/ze/AaWE+GXxF2lKC X-Received: by 2002:a17:906:c25a:b0:7c9:6e0e:1428 with SMTP id bl26-20020a170906c25a00b007c96e0e1428mr34272207ejb.47.1672745680840; Tue, 03 Jan 2023 03:34:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672745680; cv=none; d=google.com; s=arc-20160816; b=Hyp74KRDnPbmkKQFy5p+Dc34Sme0/3mYw/8cDY5oxNQaNh8fMEGSxN8QDbkHJRtQp/ pAbF077ne63oEDmyCyKiOzAQmGH7KL5fVf0LABd6i+AQfis8hu6dWj4kwa8I5VCEY23C UrR8D9dV9IyZR/pDBRt5r2W1SA13QYD3a3bfPaQQislO33+aK/jAbWiHDd4zL4s4W1IC 0pxKQt2gF+ifjdpcmvV4HxuaMq9D9fPdG2vLRPM44FtyFEBI7qtmLlc5lInS2DYqoJox 9xNmxLdy96V5LCqjBepS1D6M4AMVbiV1Kuw82DfEGgQsyHZ8XZUkprHmAUGfIb7efhY8 RPKg== 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=7RQEeKIIux1PCUXqzkDn4LBhrz6tKrtyzvHPPUbC6vE=; b=ipn9nsyNGfufRxMWjxkwOtcfWZ+2jVI758sVNo9ESTLN5W61dbAYBac9Ub13MofJqJ lHhekpUNUMM8LqBdvL26gElNwn1EHyScSiesN7QDhFPmE6vc8X50mPu8IJ7QAZ53ooPK XvdqoOC941ZMoCUcNQYoPkbnyql35OhTpUpOgw0QJIoanv9/bDUl1Hvj8ASHhm9CpCp6 OOGMP/e3e+ESx7Cebg7LcNd4BCxudGCDjGcrI5Qiy9sBtA+FKC8rZDKvXk+G4wTfN3WZ 64lee763EIn1CfqqrrxcEiYX2oC1LDamC/X1pK7g9X9qLeOG1SL2U9qav1BR3BsUoRtU dHKg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mediatek.com header.s=dk header.b=d1UgQWq4; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id sh30-20020a1709076e9e00b0084c46478989si23419380ejc.777.2023.01.03.03.34.17; Tue, 03 Jan 2023 03:34:40 -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=d1UgQWq4; 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 S233179AbjACLbi (ORCPT + 99 others); Tue, 3 Jan 2023 06:31:38 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57788 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237463AbjACL3p (ORCPT ); Tue, 3 Jan 2023 06:29:45 -0500 Received: from mailgw01.mediatek.com (unknown [60.244.123.138]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 71EC5FAF6; Tue, 3 Jan 2023 03:29:34 -0800 (PST) X-UUID: 35f120e895814bea8a46946f006df901-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=7RQEeKIIux1PCUXqzkDn4LBhrz6tKrtyzvHPPUbC6vE=; b=d1UgQWq4GLYOAEIDfi53xLwArwSRl7XZrJPp+NyYsgw/Jxflp1ikMhv1OjYcbCkR0BqB4tp/7zY5knMQdLix9/86n/WdA5ZGfewkN/nJs23s94GNYqEtnqicCz6DF5RTuFomcmyzHX05ppcRvBlVNx3NX/KOFDYNJA874a2kKu4=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.16,REQID:8906b7f1-2be3-4f50-9bac-2bf33265a314,IP:0,U RL:0,TC:0,Content:0,EDM:0,RT:0,SF:0,FILE:0,BULK:0,RULE:Release_Ham,ACTION: release,TS:0 X-CID-META: VersionHash:09771b1,CLOUDID:c064aaf4-ff42-4fb0-b929-626456a83c14,B ulkID:nil,BulkQuantity:0,Recheck:0,SF:102,TC:nil,Content:0,EDM:-3,IP:nil,U RL:11|1,File:nil,Bulk:nil,QS:nil,BEC:nil,COL:0,OSI:0,OSA:0 X-CID-BVR: 0 X-UUID: 35f120e895814bea8a46946f006df901-20230103 Received: from mtkmbs10n2.mediatek.inc [(172.21.101.183)] by mailgw01.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 411707678; Tue, 03 Jan 2023 19:29:28 +0800 Received: from mtkmbs11n1.mediatek.inc (172.21.101.186) by mtkmbs10n1.mediatek.inc (172.21.101.34) 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:27 +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:27 +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 07/14] soc: mtk-svs: mt8183: refactor o_slope calculation Date: Tue, 3 Jan 2023 19:29:18 +0800 Message-ID: <20230103112925.16554-8-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 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1754000974921793952?= X-GMAIL-MSGID: =?utf-8?q?1754000974921793952?= The o_slope value is dependent of the o_slope_sign, refactor code to get rid of unnecessary if constructs. Signed-off-by: Matthias Brugger Signed-off-by: Roger Lu --- drivers/soc/mediatek/mtk-svs.c | 51 +++++++++++++++------------------- 1 file changed, 22 insertions(+), 29 deletions(-) diff --git a/drivers/soc/mediatek/mtk-svs.c b/drivers/soc/mediatek/mtk-svs.c index 308cd36a23fc..9578baf3d9a7 100644 --- a/drivers/soc/mediatek/mtk-svs.c +++ b/drivers/soc/mediatek/mtk-svs.c @@ -1893,26 +1893,27 @@ static bool svs_mt8183_efuse_parsing(struct svs_platform *svsp) o_slope_sign = (svsp->tefuse[0] >> 7) & BIT(0); ts_id = (svsp->tefuse[1] >> 9) & BIT(0); - o_slope = (svsp->tefuse[0] >> 26) & GENMASK(5, 0); - - if (adc_cali_en_t == 1) { - if (!ts_id) - o_slope = 0; - - if (adc_ge_t < 265 || adc_ge_t > 758 || - adc_oe_t < 265 || adc_oe_t > 758 || - o_vtsmcu[0] < -8 || o_vtsmcu[0] > 484 || - o_vtsmcu[1] < -8 || o_vtsmcu[1] > 484 || - o_vtsmcu[2] < -8 || o_vtsmcu[2] > 484 || - o_vtsmcu[3] < -8 || o_vtsmcu[3] > 484 || - o_vtsmcu[4] < -8 || o_vtsmcu[4] > 484 || - o_vtsabb < -8 || o_vtsabb > 484 || - degc_cali < 1 || degc_cali > 63) { - dev_err(svsp->dev, "bad thermal efuse, no mon mode\n"); - goto remove_mt8183_svsb_mon_mode; - } + if (!ts_id) { + o_slope = 1534; } else { - dev_err(svsp->dev, "no thermal efuse, no mon mode\n"); + o_slope = (svsp->tefuse[0] >> 26) & GENMASK(5, 0); + if (!o_slope_sign) + o_slope = 1534 + o_slope * 10; + else + o_slope = 1534 - o_slope * 10; + } + + if (adc_cali_en_t == 0 || + adc_ge_t < 265 || adc_ge_t > 758 || + adc_oe_t < 265 || adc_oe_t > 758 || + o_vtsmcu[0] < -8 || o_vtsmcu[0] > 484 || + o_vtsmcu[1] < -8 || o_vtsmcu[1] > 484 || + o_vtsmcu[2] < -8 || o_vtsmcu[2] > 484 || + o_vtsmcu[3] < -8 || o_vtsmcu[3] > 484 || + o_vtsmcu[4] < -8 || o_vtsmcu[4] > 484 || + o_vtsabb < -8 || o_vtsabb > 484 || + degc_cali < 1 || degc_cali > 63) { + dev_err(svsp->dev, "bad thermal efuse, no mon mode\n"); goto remove_mt8183_svsb_mon_mode; } @@ -1931,11 +1932,7 @@ static bool svs_mt8183_efuse_parsing(struct svs_platform *svsp) x_roomt[i] = (((format[i] * 10000) / 4096) * 10000) / gain; temp0 = (10000 * 100000 / gain) * 15 / 18; - - if (!o_slope_sign) - mts = (temp0 * 10) / (1534 + o_slope * 10); - else - mts = (temp0 * 10) / (1534 - o_slope * 10); + mts = (temp0 * 10) / o_slope; for (idx = 0; idx < svsp->bank_max; idx++) { svsb = &svsp->banks[idx]; @@ -1962,11 +1959,7 @@ static bool svs_mt8183_efuse_parsing(struct svs_platform *svsp) temp0 = (degc_cali * 10 / 2); temp1 = ((10000 * 100000 / 4096 / gain) * oe + tb_roomt * 10) * 15 / 18; - - if (!o_slope_sign) - temp2 = temp1 * 100 / (1534 + o_slope * 10); - else - temp2 = temp1 * 100 / (1534 - o_slope * 10); + temp2 = temp1 * 100 / o_slope; svsb->bts = (temp0 + temp2 - 250) * 4 / 10; } From patchwork Tue Jan 3 11:29:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roger Lu X-Patchwork-Id: 38387 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp4562318wrt; Tue, 3 Jan 2023 03:32:31 -0800 (PST) X-Google-Smtp-Source: AMrXdXsIrvy25X/DWA7karsNGdFdyQUhUPweoYm2dIOMVODvDhYzEI5LPG5Yt8//zG6SuNo1czZo X-Received: by 2002:a17:907:3f9f:b0:840:4901:901f with SMTP id hr31-20020a1709073f9f00b008404901901fmr49402095ejc.3.1672745551412; Tue, 03 Jan 2023 03:32:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672745551; cv=none; d=google.com; s=arc-20160816; b=JOath/tJhNzDBXzx3x4WKawloxwGO6mId+PHdoT2x5MK39hty3GjHHkRb0lYf0U7Rb IR/StVh0Xel+4xa+rKl45zwHuS+A78lCBciSffDksUE5b4dAEyxxi8U+6WVmgsChg6FH 4GbVVok8+7+UZp43m9WohI9kVre3r9TBjQyybNYre1BLHs1BQfwjuw8qqgWtcIhUJCEf YoV1fjBCWsqmfOnzoMEd/LdLiZstxkWZ1c5PlP61GncFjOT/XsHzem9JuyU7TOpTJC2V fzA6OOlM8snltrPsvRrvwH84Ozt4oCdgX9wjIw6iJNSQaWyQYhPSkAkBcThWJx8H0PcA WJdg== 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=ncu7dzvmjAzaCKHKvpc5QfiiB7neOIm6BCctvHMioBc=; b=1F/9l9N1oksrcsTlU2d+pA1BjwGy+802AadHX0WDf1A8yJsU0EOCUENMEHDJyJeBCb eiE19gC7e7EoPT5N5cr9JjFA6BcjWMO1qIpkmUnxb6weCzi2pUArGPdB7xfgeisq5x8N 0Qpj//DfYfhLqINlSHXLhOiogBqMZUf6RwOTrxIqinY4wE0ChXYO9j2LUq6QBoWxt3BX 5daDG7V6ZRgZapXs5QUE8OCsVt6w6GrjYKAOjFJr29/tDvgCghW3tGxkV1QpBvHVO2VW sgU8TZSHyBjKLYtOLdrBmgOBPMAYHiYbMENUE1MIHzk7ER6bpxznd6e9CN/+hTpQ0z21 YpyQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mediatek.com header.s=dk header.b=QFi3XXuL; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id sc11-20020a1709078a0b00b0080f0493b9c2si27658111ejc.249.2023.01.03.03.32.08; Tue, 03 Jan 2023 03:32:31 -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=QFi3XXuL; 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 S237527AbjACLbK (ORCPT + 99 others); Tue, 3 Jan 2023 06:31:10 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57778 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237456AbjACL3o (ORCPT ); Tue, 3 Jan 2023 06:29:44 -0500 Received: from mailgw01.mediatek.com (unknown [60.244.123.138]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F36F4F036; Tue, 3 Jan 2023 03:29:31 -0800 (PST) X-UUID: 63566ebf967742f5ac541f8b5c20eb9a-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=ncu7dzvmjAzaCKHKvpc5QfiiB7neOIm6BCctvHMioBc=; b=QFi3XXuLyzMwM5S5LWQv1tIcUXH7ulK2xRL680Y5ewCw/MvIkp/prA8iHNp9eyoiI/wdY0gSCea1bTPaQYMmPnoiXUwbsvBlqk6hJ41CRtdQZ9ltJS+8txsDug3ed9mC5NQKEjpHJHIWqMHq+/pcRJG/KoyX4Oz6uLGyfVvYSaU=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.16,REQID:c5c7e28b-a045-453f-8320-6207cdc5f7a1,IP:0,U RL:0,TC:0,Content:-25,EDM:0,RT:0,SF:95,FILE:0,BULK:0,RULE:Release_Ham,ACTI ON:release,TS:70 X-CID-INFO: VERSION:1.1.16,REQID:c5c7e28b-a045-453f-8320-6207cdc5f7a1,IP:0,URL :0,TC:0,Content:-25,EDM:0,RT:0,SF:95,FILE:0,BULK:0,RULE:Spam_GS981B3D,ACTI ON:quarantine,TS:70 X-CID-META: VersionHash:09771b1,CLOUDID:8164aaf4-ff42-4fb0-b929-626456a83c14,B ulkID:230103192928GRBG3C6P,BulkQuantity:1,Recheck:0,SF:38|28|17|19|48,TC:n il,Content:0,EDM:-3,IP:nil,URL:11|1,File:nil,Bulk:40,QS:nil,BEC:nil,COL:0, OSI:0,OSA:0 X-CID-BVR: 0,NGT X-UUID: 63566ebf967742f5ac541f8b5c20eb9a-20230103 Received: from mtkcas11.mediatek.inc [(172.21.101.40)] by mailgw01.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256) with ESMTP id 1476350300; Tue, 03 Jan 2023 19:29:28 +0800 Received: from mtkmbs11n1.mediatek.inc (172.21.101.185) by mtkmbs11n1.mediatek.inc (172.21.101.185) 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:27 +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:27 +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 08/14] soc: mediatek: mtk-svs: use svs get efuse common function Date: Tue, 3 Jan 2023 19:29:19 +0800 Message-ID: <20230103112925.16554-9-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 X-MTK: N X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS,UNPARSEABLE_RELAY autolearn=no 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1754000839394839347?= X-GMAIL-MSGID: =?utf-8?q?1754000839394839347?= SVS might need to read both svs efuse and thermal efuse on the probe flow. Therefore, add a common efuse read function to remove the superfluous codes. Signed-off-by: Roger Lu --- drivers/soc/mediatek/mtk-svs.c | 69 ++++++++++++---------------------- 1 file changed, 24 insertions(+), 45 deletions(-) diff --git a/drivers/soc/mediatek/mtk-svs.c b/drivers/soc/mediatek/mtk-svs.c index 9578baf3d9a7..70f87715a084 100644 --- a/drivers/soc/mediatek/mtk-svs.c +++ b/drivers/soc/mediatek/mtk-svs.c @@ -1701,26 +1701,28 @@ static int svs_bank_resource_setup(struct svs_platform *svsp) return 0; } -static int svs_thermal_efuse_get_data(struct svs_platform *svsp) +static int svs_get_efuse_data(struct svs_platform *svsp, + const char *nvmem_cell_name, + u32 **svsp_efuse, size_t *svsp_efuse_max) { struct nvmem_cell *cell; - /* Thermal efuse parsing */ - cell = nvmem_cell_get(svsp->dev, "t-calibration-data"); + cell = nvmem_cell_get(svsp->dev, nvmem_cell_name); if (IS_ERR_OR_NULL(cell)) { - dev_err(svsp->dev, "no \"t-calibration-data\"? %ld\n", PTR_ERR(cell)); + dev_err(svsp->dev, "no \"%s\"? %ld\n", + nvmem_cell_name, PTR_ERR(cell)); return PTR_ERR(cell); } - svsp->tefuse = nvmem_cell_read(cell, &svsp->tefuse_max); - if (IS_ERR(svsp->tefuse)) { - dev_err(svsp->dev, "cannot read thermal efuse: %ld\n", - PTR_ERR(svsp->tefuse)); + *svsp_efuse = nvmem_cell_read(cell, svsp_efuse_max); + if (IS_ERR(*svsp_efuse)) { + dev_err(svsp->dev, "cannot read \"%s\" efuse: %ld\n", + nvmem_cell_name, PTR_ERR(*svsp_efuse)); nvmem_cell_put(cell); - return PTR_ERR(svsp->tefuse); + return PTR_ERR(*svsp_efuse); } - svsp->tefuse_max /= sizeof(u32); + *svsp_efuse_max /= sizeof(u32); nvmem_cell_put(cell); return 0; @@ -1768,7 +1770,8 @@ static bool svs_mt8192_efuse_parsing(struct svs_platform *svsp) svsb->vmax += svsb->dvt_fixed; } - ret = svs_thermal_efuse_get_data(svsp); + ret = svs_get_efuse_data(svsp, "t-calibration-data", + &svsp->tefuse, &svsp->tefuse_max); if (ret) return false; @@ -1873,7 +1876,8 @@ static bool svs_mt8183_efuse_parsing(struct svs_platform *svsp) } } - ret = svs_thermal_efuse_get_data(svsp); + ret = svs_get_efuse_data(svsp, "t-calibration-data", + &svsp->tefuse, &svsp->tefuse_max); if (ret) return false; @@ -1975,32 +1979,6 @@ static bool svs_mt8183_efuse_parsing(struct svs_platform *svsp) return true; } -static bool svs_is_efuse_data_correct(struct svs_platform *svsp) -{ - struct nvmem_cell *cell; - - /* Get svs efuse by nvmem */ - cell = nvmem_cell_get(svsp->dev, "svs-calibration-data"); - if (IS_ERR(cell)) { - dev_err(svsp->dev, "no \"svs-calibration-data\"? %ld\n", - PTR_ERR(cell)); - return false; - } - - svsp->efuse = nvmem_cell_read(cell, &svsp->efuse_max); - if (IS_ERR(svsp->efuse)) { - dev_err(svsp->dev, "cannot read svs efuse: %ld\n", - PTR_ERR(svsp->efuse)); - nvmem_cell_put(cell); - return false; - } - - svsp->efuse_max /= sizeof(u32); - nvmem_cell_put(cell); - - return true; -} - static struct device *svs_get_subsys_device(struct svs_platform *svsp, const char *node_name) { @@ -2335,8 +2313,9 @@ static int svs_probe(struct platform_device *pdev) if (ret) return ret; - if (!svs_is_efuse_data_correct(svsp)) { - dev_notice(svsp->dev, "efuse data isn't correct\n"); + ret = svs_get_efuse_data(svsp, "svs-calibration-data", + &svsp->efuse, &svsp->efuse_max); + if (ret) { ret = -EPERM; goto svs_probe_free_efuse; } @@ -2344,13 +2323,13 @@ static int svs_probe(struct platform_device *pdev) if (!svsp_data->efuse_parsing(svsp)) { dev_err(svsp->dev, "efuse data parsing failed\n"); ret = -EPERM; - goto svs_probe_free_resource; + goto svs_probe_free_tefuse; } ret = svs_bank_resource_setup(svsp); if (ret) { dev_err(svsp->dev, "svs bank resource setup fail: %d\n", ret); - goto svs_probe_free_resource; + goto svs_probe_free_tefuse; } svsp->main_clk = devm_clk_get(svsp->dev, "main"); @@ -2358,13 +2337,13 @@ static int svs_probe(struct platform_device *pdev) dev_err(svsp->dev, "failed to get clock: %ld\n", PTR_ERR(svsp->main_clk)); ret = PTR_ERR(svsp->main_clk); - goto svs_probe_free_resource; + goto svs_probe_free_tefuse; } ret = clk_prepare_enable(svsp->main_clk); if (ret) { dev_err(svsp->dev, "cannot enable main clk: %d\n", ret); - goto svs_probe_free_resource; + goto svs_probe_free_tefuse; } svsp->base = of_iomap(svsp->dev->of_node, 0); @@ -2408,7 +2387,7 @@ static int svs_probe(struct platform_device *pdev) svs_probe_clk_disable: clk_disable_unprepare(svsp->main_clk); -svs_probe_free_resource: +svs_probe_free_tefuse: if (!IS_ERR_OR_NULL(svsp->tefuse)) kfree(svsp->tefuse); From patchwork Tue Jan 3 11:29:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roger Lu X-Patchwork-Id: 38389 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp4562621wrt; Tue, 3 Jan 2023 03:33:27 -0800 (PST) X-Google-Smtp-Source: AMrXdXvEws7cImzFz5jbs37EJTKMd9+5xj+lsb5UQatnWlHW8vu6PnpX3v1TGDyid4liTMIIMlvR X-Received: by 2002:a17:907:a051:b0:84b:8885:985d with SMTP id gz17-20020a170907a05100b0084b8885985dmr26185224ejc.5.1672745607032; Tue, 03 Jan 2023 03:33:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672745607; cv=none; d=google.com; s=arc-20160816; b=GaeUhUZTr1mlH5zLecNMB2dUxqO7KjiNO1YS52GzhLpqpMUFW7ok8vpAyANIYuv3TL YtQXCGOI8eiJfH14XXy0KZIwQ+/jqb1COYDJtLZknGusXfLfRJcS9LO6z8eLHdn/4V0N ScoqlrDaYNqPL5PItOqE2RwzjAyI+XnuXkFLDKixfag3eZjecaeFKG4n+pSTb0ljhWQ2 AYnbwyzbEOTW0Bm/ao3m5ExCxlWHwdlzhjR0WRilrtHqQjDhQl5Po67UWzvrhHcP4kMi gE+a3T2k700rTNanDWrZ++2aR4B5oaNBVM9bLSaiN2SWznrQfjvVlJ1+RAJi7nqDRtqU ipjA== 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=mzND0DnWw9AD417JDZhq7g/cwkn0pKOarhIAsIxEwPE=; b=JOPhzeExbn1XWFQDC0ErkhLGxW+Vf5nIdNb71jkxBqDUS8srSF6dwARGKPpyWTyw6D TumE4rKXxw8HbIpgenU+CQgjnMEsmiptFXNU+elG+WEIcFMrZDiCOrrYJ9n/ZnR5y41y J+Lw/ycU7yATx6VWTpvTwplvIFzBOAByfUDVRVgRtjJ/65FoQEgyN9y/P2vZYod369fw D4AJcPWyxKZ6+z0NEQBqdq79mBKCIlUL5Wd/A3xH41CyP16iJu36WUDuxhjeiI4RL5Ml 9FWt7ejQJEUsOhr/s53XbY9wd+8dgOW/MchJFBI6kRY2wBkCXG5zj4xeIVzY04aqPvwx 777g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mediatek.com header.s=dk header.b="Q3JnZ/ym"; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ho6-20020a1709070e8600b007ae186b15f9si11056226ejc.597.2023.01.03.03.32.39; Tue, 03 Jan 2023 03:33:27 -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="Q3JnZ/ym"; 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 S237435AbjACLaS (ORCPT + 99 others); Tue, 3 Jan 2023 06:30:18 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57510 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237442AbjACL3n (ORCPT ); Tue, 3 Jan 2023 06:29:43 -0500 Received: from mailgw01.mediatek.com (unknown [60.244.123.138]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5D153F587; Tue, 3 Jan 2023 03:29:37 -0800 (PST) X-UUID: 13939d70bf5843009e2f0f6053e6b953-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=mzND0DnWw9AD417JDZhq7g/cwkn0pKOarhIAsIxEwPE=; b=Q3JnZ/ymegteFTJkpGCg9BZKz8u0fpM6yq7Nc9XZ5telMOVB9L4pQNYRwDRArg/5hXBX3Y/5Ed9ujjoXVtYL/bwopbarjeCP6nfVUhPtAXshQ5XKZdJczwgOZjLZ5mmcvID2HAra6PZ8IeMfekREfbjN93XboosO/Y+E3IZjM+M=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.16,REQID:2c5014ca-6725-4a8d-80e3-5502e11d5c36,IP:0,U RL:0,TC:0,Content:-25,EDM:0,RT:0,SF:0,FILE:0,BULK:0,RULE:Release_Ham,ACTIO N:release,TS:-25 X-CID-META: VersionHash:09771b1,CLOUDID:90a48053-dd49-462e-a4be-2143a3ddc739,B ulkID:nil,BulkQuantity:0,Recheck:0,SF:102,TC:nil,Content:0,EDM:-3,IP:nil,U RL:11|1,File:nil,Bulk:nil,QS:nil,BEC:nil,COL:0,OSI:0,OSA:0 X-CID-BVR: 0,NGT X-UUID: 13939d70bf5843009e2f0f6053e6b953-20230103 Received: from mtkmbs10n2.mediatek.inc [(172.21.101.183)] by mailgw01.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 98266115; Tue, 03 Jan 2023 19:29:28 +0800 Received: from mtkmbs11n1.mediatek.inc (172.21.101.186) by mtkmbs10n1.mediatek.inc (172.21.101.34) 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:27 +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:27 +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 09/14] soc: mediatek: mtk-svs: use svs clk control APIs Date: Tue, 3 Jan 2023 19:29:20 +0800 Message-ID: <20230103112925.16554-10-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 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1754000897781216383?= X-GMAIL-MSGID: =?utf-8?q?1754000897781216383?= In MediaTek HW design, svs and thermal both use the same clk source. It means that svs clk reference count from CCF includes thermal control counts. That makes svs driver confuse whether it disabled svs's main clk or not from CCF's perspective and lead to turn off their shared clk unexpectedly. Therefore, we add svs clk control APIs to make sure svs's main clk is controlled well by svs driver itself. Here is a NG example. Rely on CCF's reference count and cause problem. thermal probe (clk ref = 1) -> svs probe (clk ref = 2) -> svs suspend (clk ref = 1) -> thermal suspend (clk ref = 0) -> thermal resume (clk ref = 1) -> svs resume (encounter error, clk ref = 1) -> svs suspend (clk ref = 0) -> thermal suspend (Fail here, thermal HW control w/o clk) Signed-off-by: Roger Lu --- drivers/soc/mediatek/mtk-svs.c | 60 ++++++++++++++++++++++++++-------- 1 file changed, 46 insertions(+), 14 deletions(-) diff --git a/drivers/soc/mediatek/mtk-svs.c b/drivers/soc/mediatek/mtk-svs.c index 70f87715a084..d8b759897fec 100644 --- a/drivers/soc/mediatek/mtk-svs.c +++ b/drivers/soc/mediatek/mtk-svs.c @@ -6,6 +6,7 @@ #include #include #include +#include #include #include #include @@ -323,6 +324,7 @@ static const u32 svs_regs_v2[] = { * @bank_max: total number of svs banks * @efuse: svs efuse data received from NVMEM framework * @tefuse: thermal efuse data received from NVMEM framework + * @clk_cnt: clock count shows the clk enable/disable times by svs driver */ struct svs_platform { void __iomem *base; @@ -337,6 +339,7 @@ struct svs_platform { u32 bank_max; u32 *efuse; u32 *tefuse; + s32 clk_cnt; }; struct svs_platform_data { @@ -496,6 +499,32 @@ static void svs_switch_bank(struct svs_platform *svsp) svs_writel_relaxed(svsp, svsb->core_sel, CORESEL); } +static bool svs_is_clk_enabled(struct svs_platform *svsp) +{ + return svsp->clk_cnt > 0 ? true : false; +} + +static int svs_clk_enable(struct svs_platform *svsp) +{ + int ret; + + ret = clk_prepare_enable(svsp->main_clk); + if (ret) { + dev_err(svsp->dev, "cannot enable main_clk: %d\n", ret); + return ret; + } + + svsp->clk_cnt++; + + return 0; +} + +static void svs_clk_disable(struct svs_platform *svsp) +{ + clk_disable_unprepare(svsp->main_clk); + svsp->clk_cnt--; +} + static u32 svs_bank_volt_to_opp_volt(u32 svsb_volt, u32 svsb_volt_step, u32 svsb_volt_base) { @@ -1543,6 +1572,12 @@ static int svs_suspend(struct device *dev) int ret; u32 idx; + if (!svs_is_clk_enabled(svsp)) { + dev_err(svsp->dev, "svs clk is disabled already (%d)\n", + svsp->clk_cnt); + return 0; + } + for (idx = 0; idx < svsp->bank_max; idx++) { svsb = &svsp->banks[idx]; @@ -1564,7 +1599,7 @@ static int svs_suspend(struct device *dev) return ret; } - clk_disable_unprepare(svsp->main_clk); + svs_clk_disable(svsp); return 0; } @@ -1574,28 +1609,27 @@ static int svs_resume(struct device *dev) struct svs_platform *svsp = dev_get_drvdata(dev); int ret; - ret = clk_prepare_enable(svsp->main_clk); - if (ret) { - dev_err(svsp->dev, "cannot enable main_clk, disable svs\n"); + ret = svs_clk_enable(svsp); + if (ret) return ret; - } ret = reset_control_deassert(svsp->rst); if (ret) { dev_err(svsp->dev, "cannot deassert reset %d\n", ret); - goto out_of_resume; + goto svs_resume_clk_disable; } ret = svs_init02(svsp); if (ret) - goto out_of_resume; + goto svs_resume_clk_disable; svs_mon_mode(svsp); return 0; -out_of_resume: - clk_disable_unprepare(svsp->main_clk); +svs_resume_clk_disable: + svs_clk_disable(svsp); + return ret; } @@ -2340,11 +2374,9 @@ static int svs_probe(struct platform_device *pdev) goto svs_probe_free_tefuse; } - ret = clk_prepare_enable(svsp->main_clk); - if (ret) { - dev_err(svsp->dev, "cannot enable main clk: %d\n", ret); + ret = svs_clk_enable(svsp); + if (ret) goto svs_probe_free_tefuse; - } svsp->base = of_iomap(svsp->dev->of_node, 0); if (IS_ERR_OR_NULL(svsp->base)) { @@ -2385,7 +2417,7 @@ static int svs_probe(struct platform_device *pdev) iounmap(svsp->base); svs_probe_clk_disable: - clk_disable_unprepare(svsp->main_clk); + svs_clk_disable(svsp); svs_probe_free_tefuse: if (!IS_ERR_OR_NULL(svsp->tefuse)) From patchwork Tue Jan 3 11:29:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roger Lu X-Patchwork-Id: 38386 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp4562012wrt; Tue, 3 Jan 2023 03:31:42 -0800 (PST) X-Google-Smtp-Source: AMrXdXsQoZggwgtY5vkMS8dylt9jESxi0oZGf8x/L2Fg+dIBSpu1u/BC9TZjwPySox4EICOBMjHI X-Received: by 2002:a05:6402:b3c:b0:47f:ab65:b3ff with SMTP id bo28-20020a0564020b3c00b0047fab65b3ffmr33078190edb.35.1672745502579; Tue, 03 Jan 2023 03:31:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672745502; cv=none; d=google.com; s=arc-20160816; b=TcpEx2zl1m1ZSSN+DmPkC6AKTFxy6WZATegng3lF7zhLLaA+NVH6klIArp73a8Of51 Sw30idKpHeJqmYfYbHKwdPeSjNZmX8x7z2QEUqHEj67dk44TRpy4TGkti9RFe3oorKbP JEoKGDSVUamgPcJP8kJJ+97A3ky7YL0kYgoI4j6ldolak4XU/N8360RNUdvyMh/xGunP EQAKWtzBpmSthgNANDC9BiVwVA8T9y19K5hUD9hi15CQQmGg2qazWHdZ4vNXw6oP9vnW 02wvCUoFW0LwAh80FmsWBAmmvYMEeQ0p8iQxqbCV5fu++gpHJG4Im+2Z6m/bfQf+qmu+ JXqQ== 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=QANQRcbabz/e5AjGyrQQSnGD8OTyugIT5m3Sn9VmQA0=; b=fKtugKZWXirbsF3hLoWCM9iFkQKxKjeGZmLt70mPsVcNZNWXa/xI4lNd6iuUm11i6M uDgetWf3ZI8DNl7Usv34w9VpqTeOzG3Zn8YuDU2kZHpXF5CLKqLYGwiyrQIGJMnJEIea MaMu+PZPp1bD5XDREjXz/MTBEsh1HgxFqM6snwbmy8pwguppXFjMdCHits68DpIcRVBl 3Gn5AN8HYIAc43jdE9PzcL0NiWnwfEDGszX+PZ9F2R/uXVRFdhbNz/bV+xWRSs9hLaAM tiDFMhKc7fSQG7LKnuRv1KA0/26cOW8neUpQPuFvwk7VePjCZPvdycWpj8X7umTjXOKn bukg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mediatek.com header.s=dk header.b=jm3Af5jR; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b8-20020a056402278800b0046fd1b1516dsi30814666ede.478.2023.01.03.03.31.16; Tue, 03 Jan 2023 03:31:42 -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=jm3Af5jR; 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 S237457AbjACLaG (ORCPT + 99 others); Tue, 3 Jan 2023 06:30:06 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57744 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237436AbjACL3n (ORCPT ); Tue, 3 Jan 2023 06:29:43 -0500 Received: from mailgw01.mediatek.com (unknown [60.244.123.138]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5A334FCFC; Tue, 3 Jan 2023 03:29:35 -0800 (PST) X-UUID: e186cd90ce6b4bbd87325d0a4340e1c7-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=QANQRcbabz/e5AjGyrQQSnGD8OTyugIT5m3Sn9VmQA0=; b=jm3Af5jRZXxLBJkPUb3avxeNITJekXai7qCZSdvvHdPAn4rLasVzeiyQhP0bh6KPdPSyHQLH7jMPjg1CHGo0un2icSjCbjZoKBMSNONvshkV9y8wzCSYNoN19xLaSCw4/boHYUJ4bt1GgtInD6QC7Zm2B7xv/OaNxXebgGLRBgM=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.16,REQID:42b10e33-bc9f-49fd-895f-05cb432e4a44,IP:0,U RL:0,TC:0,Content:0,EDM:0,RT:0,SF:0,FILE:0,BULK:0,RULE:Release_Ham,ACTION: release,TS:0 X-CID-META: VersionHash:09771b1,CLOUDID:bf64aaf4-ff42-4fb0-b929-626456a83c14,B ulkID:nil,BulkQuantity:0,Recheck:0,SF:102,TC:nil,Content:0,EDM:-3,IP:nil,U RL:11|1,File:nil,Bulk:nil,QS:nil,BEC:nil,COL:0,OSI:0,OSA:0 X-CID-BVR: 0,NGT X-UUID: e186cd90ce6b4bbd87325d0a4340e1c7-20230103 Received: from mtkmbs10n2.mediatek.inc [(172.21.101.183)] by mailgw01.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 73559374; Tue, 03 Jan 2023 19:29:28 +0800 Received: from mtkmbs11n1.mediatek.inc (172.21.101.186) by mtkmbs10n1.mediatek.inc (172.21.101.34) 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:27 +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:27 +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 10/14] soc: mediatek: mtk-svs: reset svs when svs_resume() fail Date: Tue, 3 Jan 2023 19:29:21 +0800 Message-ID: <20230103112925.16554-11-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 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1754000787867190484?= X-GMAIL-MSGID: =?utf-8?q?1754000787867190484?= Reset svs when svs_resume() fail. Signed-off-by: Roger Lu --- drivers/soc/mediatek/mtk-svs.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/soc/mediatek/mtk-svs.c b/drivers/soc/mediatek/mtk-svs.c index d8b759897fec..567536e32a46 100644 --- a/drivers/soc/mediatek/mtk-svs.c +++ b/drivers/soc/mediatek/mtk-svs.c @@ -1621,12 +1621,16 @@ static int svs_resume(struct device *dev) ret = svs_init02(svsp); if (ret) - goto svs_resume_clk_disable; + goto svs_resume_reset_assert; svs_mon_mode(svsp); return 0; +svs_resume_reset_assert: + dev_info(svsp->dev, "assert reset %d\n", + reset_control_assert(svsp->rst)); + svs_resume_clk_disable: svs_clk_disable(svsp); From patchwork Tue Jan 3 11:29:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roger Lu X-Patchwork-Id: 38390 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp4562679wrt; Tue, 3 Jan 2023 03:33:38 -0800 (PST) X-Google-Smtp-Source: AMrXdXuI5eBbCbRvIqCdqeo4EMKlCBVTJ6qXsyMWuRNLH7E1WZVFZdhQlscBePpGGr32GKPvp0cT X-Received: by 2002:a05:6402:3454:b0:47f:ab65:b3f4 with SMTP id l20-20020a056402345400b0047fab65b3f4mr32715366edc.39.1672745618249; Tue, 03 Jan 2023 03:33:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672745618; cv=none; d=google.com; s=arc-20160816; b=I9fWAfVGjLhB/7nXoiqfUDv6LWnmYMMDKE+VZzO4IJlfh6fe4cLQgikRWbUd+0DVwH 3+ESqVbZja0iUTA3HpqzjaU2cCjpvyx2i5hE476+MUTjVwkt0jMjU0pbX6sikkkrVMuB Z2sGSLGE2wnACMDAW+gTtUu0reP1GYnrhDV6nCagdLhWA0808kxcT/b1driSAxZXxWN4 fwnOTF7CM9SYf35x/JoZZqxm3VJwgy/mdwmBEN5GjL+hcP/jTUDIx4did94bKWCIP0nG xzPoltt+ld3ER3eII8BgmBQXrVRfkCJXU3vwVH3j0b1VhFitip5wP/o1U/ioQnThUGKl 2usg== 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=joDrSmTBJDl3WxJvNdbN5S22yFRRAXSJgMe64PZtVIg=; b=m4scz2QfeLnqTU6kNlqALN1Mw62vDsS08tIgobzNp8hsonINP8gpDYm5En0NPpEJGP ISan5w62lF2aYKzvyyC61DP91XjAIvQm9IucWN9d4+1tBqxGCpVtTg8ei3dkWje7SKSX 34HPJbjUloneIuct5OTumMjIRamFqelIIb2PZAfKoHoaytd8Bd0TpMaQHZnWVBXMgm5D RBRxs2dqkhbXOPYsCbwTA5oXk7da5J4TSV4ZND/nV0zhwUJRUgnV8pZIp/P5014gX8VE s8fGL5F8TIeXyC2yFhiXRCOSJvYSZfLSLl9qu5Ttda0QBvkYXfNwwRYV8tNmuCONf/Qa Mk8w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mediatek.com header.s=dk header.b=oV0rWPkv; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id n18-20020aa7c692000000b0047f2f8bfc05si24619644edq.135.2023.01.03.03.33.00; Tue, 03 Jan 2023 03:33:38 -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=oV0rWPkv; 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 S237102AbjACLaV (ORCPT + 99 others); Tue, 3 Jan 2023 06:30:21 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57502 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237444AbjACL3n (ORCPT ); Tue, 3 Jan 2023 06:29:43 -0500 Received: from mailgw02.mediatek.com (unknown [210.61.82.184]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2731F10048; Tue, 3 Jan 2023 03:29:36 -0800 (PST) X-UUID: 5ab5cb930ba64b2e905959ec2649b4d9-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=joDrSmTBJDl3WxJvNdbN5S22yFRRAXSJgMe64PZtVIg=; b=oV0rWPkvgwUL6Hcl2UyP3sBZs9/RpIEuObGHoo5Mk+8wG5+y7HCGQl6r2sbynOcLaE3dLxIv1Byx2jQafUi56UddErsAVPz6EYl31SDl7wmB3UBJZnhs68CqdfNXQDt8qE6pCZ2h0gVJ2k9OEMZFjNkyz5wvoPN+adk2KgmFAJc=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.16,REQID:9207940a-b425-485f-b014-d477db745bcc,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:9207940a-b425-485f-b014-d477db745bcc,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:729e1b8b-8530-4eff-9f77-222cf6e2895b,B ulkID:230103192931RXVY4C3P,BulkQuantity:1,Recheck:0,SF:38|28|17|19|48,TC:n il,Content:0,EDM:-3,IP:nil,URL:11|1,File:nil,Bulk:40,QS:nil,BEC:nil,COL:0, OSI:0,OSA:0 X-CID-BVR: 0,NGT X-UUID: 5ab5cb930ba64b2e905959ec2649b4d9-20230103 Received: from mtkcas11.mediatek.inc [(172.21.101.40)] by mailgw02.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256) with ESMTP id 997789662; Tue, 03 Jan 2023 19:29:28 +0800 Received: from mtkmbs11n1.mediatek.inc (172.21.101.186) by mtkmbs13n1.mediatek.inc (172.21.101.193) 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:27 +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:27 +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 11/14] soc: mediatek: mtk-svs: use common function to disable restore voltages Date: Tue, 3 Jan 2023 19:29:22 +0800 Message-ID: <20230103112925.16554-12-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 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1754000909397539341?= X-GMAIL-MSGID: =?utf-8?q?1754000909397539341?= The timing of disabling SVS bank and restore default voltage is more than one place. Therefore, add a common function to use for removing the superfluous codes. Signed-off-by: Roger Lu --- drivers/soc/mediatek/mtk-svs.c | 44 +++++++++++++++++----------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/drivers/soc/mediatek/mtk-svs.c b/drivers/soc/mediatek/mtk-svs.c index 567536e32a46..f4382def9736 100644 --- a/drivers/soc/mediatek/mtk-svs.c +++ b/drivers/soc/mediatek/mtk-svs.c @@ -651,6 +651,26 @@ static int svs_adjust_pm_opp_volts(struct svs_bank *svsb) return ret; } +static void svs_bank_disable_and_restore_default_volts(struct svs_platform *svsp, + struct svs_bank *svsb) +{ + unsigned long flags; + + if (svsb->mode_support == SVSB_MODE_ALL_DISABLE) + return; + + /* This spinlock might wait for svs_isr() process */ + spin_lock_irqsave(&svs_lock, flags); + svsp->pbank = svsb; + svs_switch_bank(svsp); + svs_writel_relaxed(svsp, SVSB_PTPEN_OFF, SVSEN); + svs_writel_relaxed(svsp, SVSB_INTSTS_VAL_CLEAN, INTSTS); + spin_unlock_irqrestore(&svs_lock, flags); + + svsb->phase = SVSB_PHASE_ERROR; + svs_adjust_pm_opp_volts(svsb); +} + static int svs_dump_debug_show(struct seq_file *m, void *p) { struct svs_platform *svsp = (struct svs_platform *)m->private; @@ -726,7 +746,6 @@ static ssize_t svs_enable_debug_write(struct file *filp, { struct svs_bank *svsb = file_inode(filp)->i_private; struct svs_platform *svsp = dev_get_drvdata(svsb->dev); - unsigned long flags; int enabled, ret; char *buf = NULL; @@ -742,16 +761,8 @@ static ssize_t svs_enable_debug_write(struct file *filp, return ret; if (!enabled) { - spin_lock_irqsave(&svs_lock, flags); - svsp->pbank = svsb; + svs_bank_disable_and_restore_default_volts(svsp, svsb); svsb->mode_support = SVSB_MODE_ALL_DISABLE; - svs_switch_bank(svsp); - svs_writel_relaxed(svsp, SVSB_PTPEN_OFF, SVSEN); - svs_writel_relaxed(svsp, SVSB_INTSTS_VAL_CLEAN, INTSTS); - spin_unlock_irqrestore(&svs_lock, flags); - - svsb->phase = SVSB_PHASE_ERROR; - svs_adjust_pm_opp_volts(svsb); } kfree(buf); @@ -1568,7 +1579,6 @@ static int svs_suspend(struct device *dev) { struct svs_platform *svsp = dev_get_drvdata(dev); struct svs_bank *svsb; - unsigned long flags; int ret; u32 idx; @@ -1580,17 +1590,7 @@ static int svs_suspend(struct device *dev) for (idx = 0; idx < svsp->bank_max; idx++) { svsb = &svsp->banks[idx]; - - /* This might wait for svs_isr() process */ - spin_lock_irqsave(&svs_lock, flags); - svsp->pbank = svsb; - svs_switch_bank(svsp); - svs_writel_relaxed(svsp, SVSB_PTPEN_OFF, SVSEN); - svs_writel_relaxed(svsp, SVSB_INTSTS_VAL_CLEAN, INTSTS); - spin_unlock_irqrestore(&svs_lock, flags); - - svsb->phase = SVSB_PHASE_ERROR; - svs_adjust_pm_opp_volts(svsb); + svs_bank_disable_and_restore_default_volts(svsp, svsb); } ret = reset_control_assert(svsp->rst); From patchwork Tue Jan 3 11:29:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roger Lu X-Patchwork-Id: 38395 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp4562822wrt; Tue, 3 Jan 2023 03:34:01 -0800 (PST) X-Google-Smtp-Source: AMrXdXsCjUh2ZMqLZFzP+kqRKFe6XExRvGNdeWrQBLiFuLh6FOQ88F12unrOPN0nJ6gxk3atB2cn X-Received: by 2002:a17:906:7714:b0:829:6064:bc52 with SMTP id q20-20020a170906771400b008296064bc52mr33546557ejm.74.1672745641178; Tue, 03 Jan 2023 03:34:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672745641; cv=none; d=google.com; s=arc-20160816; b=uDeh/shER1YT6FlOodaBsJXPwkjtJafIeZiV0JXK16lygWqXpr93T/tSlJBdP+ZYV2 Ur4R0N0rxvKJKr6vS1FThEO+fStRw+JNH/MURdfPOopLHBj5pl6UbAymY2VTuEO5Dve6 p0CGUb6NTQh5g4EXla1Df2eqOhKhIfDKXOG/H3ijcFSorSBFAm1w3ApnGLTFp1G40eNH Ku00kn1JW0ERezxyDnm7++ORQhtBYGlI9Xh4STN2s3Z6MEAhIwhgPFDUyepV7PvJkn7D MSg61nx1QQH7o5sQBhh1iMIx0XTqy9wDG+Us3ya2JWOOSo/0P9m6dLedfMqASP2SyPwu fkYg== 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=9JeE+5LqZ6k4NifYeA8Fk9/IcVz1Gx3PLSu0PON7bng=; b=IgoIWViU9Ic/Mx2ezVOc1vg4br/Dgai8AOsuvlDFGDz6hkKtwz1T4Vo5d7NRFvVHE7 xjarNVY+ppp/t0Ud7cC8RTrjhcZFM0uRkTbbLyZRe/qPSM/PCzjm+PkYErE/+QzCDTq8 U8CH82XcgGLYwEBlGoXRilde9aJ7OID+P67U4AHXnii0o5TaioVLGG56xD00P5SU11ZG VSzwLzV9UZ4o118uKfeMtWL6qSdmgFl8d/+zKxPiCZYAe0nVcFp6sY78htHx8R0nan6l S3NciFGMdFqQj4ZEUayOKY/nCz7qQPQtjESv001NPnLheCnTnkQH1kU6oe8LRtjCINSs +KKg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mediatek.com header.s=dk header.b="u0jyPGc/"; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g11-20020a056402090b00b00469dd6e394asi32265593edz.579.2023.01.03.03.33.36; Tue, 03 Jan 2023 03:34:01 -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="u0jyPGc/"; 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 S237524AbjACLan (ORCPT + 99 others); Tue, 3 Jan 2023 06:30:43 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57548 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237447AbjACL3o (ORCPT ); Tue, 3 Jan 2023 06:29:44 -0500 Received: from mailgw02.mediatek.com (unknown [210.61.82.184]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9E96F10060; Tue, 3 Jan 2023 03:29:37 -0800 (PST) X-UUID: ea8ec37d831044f1a372fe3a8ea97f79-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=9JeE+5LqZ6k4NifYeA8Fk9/IcVz1Gx3PLSu0PON7bng=; b=u0jyPGc/lAFqCi8QD3naz6wyStcVPMK9Z/FrTdfn2Cx+jP47NJfHxUZ8XUZ0pgLf6xu1F2luh371ttJcHAk3ikdITY5cKgAx4E5bi8gu0CPZ/Y0BHKlDxgEKcOQtsypvwjCvNLy50KvWS+yHz3XEbdZQrB17fRk4zz7Ywy0+J6U=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.16,REQID:c7663e6d-4eb0-4e74-9bbb-d8a300b5e91a,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:c7663e6d-4eb0-4e74-9bbb-d8a300b5e91a,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:84a48053-dd49-462e-a4be-2143a3ddc739,B ulkID:230103192931MEA2OUOW,BulkQuantity:1,Recheck:0,SF:38|28|17|19|48,TC:n il,Content:0,EDM:-3,IP:nil,URL:11|1,File:nil,Bulk:40,QS:nil,BEC:nil,COL:0, OSI:0,OSA:0 X-CID-BVR: 0,NGT X-UUID: ea8ec37d831044f1a372fe3a8ea97f79-20230103 Received: from mtkcas11.mediatek.inc [(172.21.101.40)] by mailgw02.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256) with ESMTP id 727530901; Tue, 03 Jan 2023 19:29:28 +0800 Received: from mtkmbs11n1.mediatek.inc (172.21.101.186) by mtkmbs13n1.mediatek.inc (172.21.101.193) 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 12/14] soc: mediatek: mtk-svs: restore default voltages when svs_init02() fail Date: Tue, 3 Jan 2023 19:29:23 +0800 Message-ID: <20230103112925.16554-13-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 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1754000933367769494?= X-GMAIL-MSGID: =?utf-8?q?1754000933367769494?= If svs init02 fail, it means we cannot rely on svs bank voltages anymore. We need to disable svs function and restore DVFS opp voltages back to the default voltages for making sure we have enough DVFS voltages. Signed-off-by: Roger Lu --- drivers/soc/mediatek/mtk-svs.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/drivers/soc/mediatek/mtk-svs.c b/drivers/soc/mediatek/mtk-svs.c index f4382def9736..1b4798a9101c 100644 --- a/drivers/soc/mediatek/mtk-svs.c +++ b/drivers/soc/mediatek/mtk-svs.c @@ -1495,6 +1495,7 @@ static int svs_init02(struct svs_platform *svsp) { struct svs_bank *svsb; unsigned long flags, time_left; + int ret; u32 idx; for (idx = 0; idx < svsp->bank_max; idx++) { @@ -1513,7 +1514,8 @@ static int svs_init02(struct svs_platform *svsp) msecs_to_jiffies(5000)); if (!time_left) { dev_err(svsb->dev, "init02 completion timeout\n"); - return -EBUSY; + ret = -EBUSY; + goto out_of_init02; } } @@ -1531,12 +1533,21 @@ static int svs_init02(struct svs_platform *svsp) if (svsb->type == SVSB_HIGH || svsb->type == SVSB_LOW) { if (svs_sync_bank_volts_from_opp(svsb)) { dev_err(svsb->dev, "sync volt fail\n"); - return -EPERM; + ret = -EPERM; + goto out_of_init02; } } } return 0; + +out_of_init02: + for (idx = 0; idx < svsp->bank_max; idx++) { + svsb = &svsp->banks[idx]; + svs_bank_disable_and_restore_default_volts(svsp, svsb); + } + + return ret; } static void svs_mon_mode(struct svs_platform *svsp) From patchwork Tue Jan 3 11:29:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roger Lu X-Patchwork-Id: 38388 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp4562404wrt; Tue, 3 Jan 2023 03:32:52 -0800 (PST) X-Google-Smtp-Source: AMrXdXttzIuEIchy3WT2AAyDTqHNI74Z71mtatPjkFLakuh4JcX9CoPB7MsvrsgTxoP03ycMRyeG X-Received: by 2002:a05:6402:174c:b0:467:8dd2:b42 with SMTP id v12-20020a056402174c00b004678dd20b42mr35256937edx.10.1672745572045; Tue, 03 Jan 2023 03:32:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672745572; cv=none; d=google.com; s=arc-20160816; b=okzc9G7H2pFcHgDWSYxiAwebX/nFm06uqpt4BS8NWeqgrsPhIzzNlXxv/rSTnHAhz4 8Xxs65nE31B0QcNDxTCuWvV2icDCqXkILNLufm4d9WjFISkAwbmU6kziGYpiGkrmhyJd vj7K2SHgN8HroHmwi8yA0iExWg1395Vr1B7kiK9ka7G+UEdG/ur5LpN9J8XMGWLKyRgb KKIqWoxgtfngSZoVP8lsnCTwy2LhvKLFVzEhPP07C+NYFEUnlsR1TSKpst0Xzx08Lepp IcF4stwVHPqiVKwSby9EeR2+RAL4KO29Jp6b/w/OfBRxb0Exx86X9h8jvxaKG3MOjRx1 F5cQ== 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b10-20020a056402084a00b00477e491fe37si29868203edz.509.2023.01.03.03.32.28; Tue, 03 Jan 2023 03:32:52 -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 + 99 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 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1754000860753354779?= X-GMAIL-MSGID: =?utf-8?q?1754000860753354779?= 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, From patchwork Tue Jan 3 11:29:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roger Lu X-Patchwork-Id: 38391 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp4562678wrt; Tue, 3 Jan 2023 03:33:38 -0800 (PST) X-Google-Smtp-Source: AMrXdXuDMMUNYQbZy5v8oH8IEi0WlNGddAif6a+BV0f7MPq/06skJ+92M60Otkryy+kR/grwrLc4 X-Received: by 2002:a17:907:9a98:b0:7c1:d4c:f08c with SMTP id km24-20020a1709079a9800b007c10d4cf08cmr37479183ejc.4.1672745618265; Tue, 03 Jan 2023 03:33:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672745618; cv=none; d=google.com; s=arc-20160816; b=ev+sipNPHNfj0865IOVD6TucYkF/8JhjGc7Ow7lO3E1KfsMKTFaoxhfXfvJHcdm35c 6DY78S/RWl1h4uAdpGyFpNjC2hleWNf0dX1WpR8Rs4NsiQzDQScnwokgyAlULtuBGRIa mzjzw5/oHK7GyNgLkaWkLAewmfGrfxGZ0YJYTiCippGj6xfKrkOJo0MLQ03IwE2b01ax mVgHY7VHZhqfB9oqY7HVc5q76/EJQmTfMnrnPEiqdXvnTwUiFnoEAlTqLdVXvlZMY3MK MHamO7upmBUCtjREXHPqGKr9hXP9P+c27c67uy1g4mNLQKPAX4B6xEEfeOuOBhZmqg9z oizQ== 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=rA6xPRcCpI0277oPsTRr+M+DbjSu9YjPyZJZSbewd2s=; b=cUrdZQUSRPLrdmxSFm7GiKJaae6SzFL4M9jfQSp9GM/G+8by+W6Ee2GIVk8B7+Ue3D 2fBrXo0bOSts/WTKem19b5zmFKljkOLriK4xVoULpi1OFkT9lBmL2A2/4GxBBVoIgy0j +3lg5FkFUsmEPJ4C8OJGnJG4O5Hez++CCApAUF+FgOLnzA8ZbBatqTgjFwYUTxyQVle4 y4PNhp/nOFFXMlRlGeDbhrbNI9JgPOhaEUUeZm431sF+SaF2hxoH1MbLM3mcjPnDBA+P qG88TMitl9KesMtKenaq9T1M0O8rCItjMPGcFYlcNMgXvEvkk5PR9w7yjuBVPfmRzlTX GNwA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mediatek.com header.s=dk header.b=p0fO7b4J; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id mp28-20020a1709071b1c00b007ae0ca417e4si29172067ejc.690.2023.01.03.03.33.09; Tue, 03 Jan 2023 03:33:38 -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=p0fO7b4J; 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 S237501AbjACLaL (ORCPT + 99 others); Tue, 3 Jan 2023 06:30:11 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57702 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237440AbjACL3n (ORCPT ); Tue, 3 Jan 2023 06:29:43 -0500 Received: from mailgw01.mediatek.com (unknown [60.244.123.138]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 66634FD05; Tue, 3 Jan 2023 03:29:36 -0800 (PST) X-UUID: d064a5fc442e4d75a6c68b3b83213b27-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=rA6xPRcCpI0277oPsTRr+M+DbjSu9YjPyZJZSbewd2s=; b=p0fO7b4JTv80/yhS7HeUrCKBUdqJS3/pRPQC7lzU+0eJJo9KS1KfRgfoukq37hpjZ4pyo+ZJ4CmotgR6A13FOh2oFlLx4l76F6VNh0DEVDoIHFL3q8BzI/anKHhbzR6PIFRCHKhtmaZSJNH4rMKi3sMUAWF/jkD+v6S6R/1Wod4=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.16,REQID:37248c4e-a476-4879-af6d-17dd6a9f2691,IP:0,U RL:0,TC:0,Content:0,EDM:0,RT:0,SF:0,FILE:0,BULK:0,RULE:Release_Ham,ACTION: release,TS:0 X-CID-META: VersionHash:09771b1,CLOUDID:819e1b8b-8530-4eff-9f77-222cf6e2895b,B ulkID:nil,BulkQuantity:0,Recheck:0,SF:102,TC:nil,Content:0,EDM:-3,IP:nil,U RL:11|1,File:nil,Bulk:nil,QS:nil,BEC:nil,COL:0,OSI:0,OSA:0 X-CID-BVR: 0,NGT X-UUID: d064a5fc442e4d75a6c68b3b83213b27-20230103 Received: from mtkmbs10n2.mediatek.inc [(172.21.101.183)] by mailgw01.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 781875080; Tue, 03 Jan 2023 19:29:28 +0800 Received: from mtkmbs11n1.mediatek.inc (172.21.101.186) by mtkmbs10n1.mediatek.inc (172.21.101.34) 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 14/14] soc: mediatek: mtk-svs: keep svs alive even though debug cmd create fail Date: Tue, 3 Jan 2023 19:29:25 +0800 Message-ID: <20230103112925.16554-15-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 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1754000909332988162?= X-GMAIL-MSGID: =?utf-8?q?1754000909332988162?= Some projects might not support DEBUG_FS but still needs svs to be supported. Therefore, keep svs alive even though debug cmd create fail. Signed-off-by: Roger Lu --- drivers/soc/mediatek/mtk-svs.c | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/drivers/soc/mediatek/mtk-svs.c b/drivers/soc/mediatek/mtk-svs.c index 581bb8373b0c..02ecbdb7aa32 100644 --- a/drivers/soc/mediatek/mtk-svs.c +++ b/drivers/soc/mediatek/mtk-svs.c @@ -806,7 +806,7 @@ static int svs_status_debug_show(struct seq_file *m, void *v) debug_fops_ro(status); -static int svs_create_debug_cmds(struct svs_platform *svsp) +static void svs_create_debug_cmds(struct svs_platform *svsp) { struct svs_bank *svsb; struct dentry *svs_dir, *svsb_dir, *file_entry; @@ -831,7 +831,7 @@ static int svs_create_debug_cmds(struct svs_platform *svsp) if (IS_ERR(svs_dir)) { dev_err(svsp->dev, "cannot create %s: %ld\n", d, PTR_ERR(svs_dir)); - return PTR_ERR(svs_dir); + return; } for (i = 0; i < ARRAY_SIZE(svs_entries); i++) { @@ -841,7 +841,7 @@ static int svs_create_debug_cmds(struct svs_platform *svsp) if (IS_ERR(file_entry)) { dev_err(svsp->dev, "cannot create %s/%s: %ld\n", d, svs_entries[i].name, PTR_ERR(file_entry)); - return PTR_ERR(file_entry); + return; } } @@ -855,7 +855,7 @@ static int svs_create_debug_cmds(struct svs_platform *svsp) if (IS_ERR(svsb_dir)) { dev_err(svsp->dev, "cannot create %s/%s: %ld\n", d, svsb->name, PTR_ERR(svsb_dir)); - return PTR_ERR(svsb_dir); + return; } for (i = 0; i < ARRAY_SIZE(svsb_entries); i++) { @@ -866,12 +866,10 @@ static int svs_create_debug_cmds(struct svs_platform *svsp) dev_err(svsp->dev, "no %s/%s/%s?: %ld\n", d, svsb->name, svsb_entries[i].name, PTR_ERR(file_entry)); - return PTR_ERR(file_entry); + return; } } } - - return 0; } static u32 interpolate(u32 f0, u32 f1, u32 v0, u32 v1, u32 fx) @@ -2421,11 +2419,7 @@ static int svs_probe(struct platform_device *pdev) goto svs_probe_iounmap; } - ret = svs_create_debug_cmds(svsp); - if (ret) { - dev_err(svsp->dev, "svs create debug cmds fail: %d\n", ret); - goto svs_probe_iounmap; - } + svs_create_debug_cmds(svsp); return 0;