From patchwork Tue Mar 28 02:27:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tinghan Shen X-Patchwork-Id: 75790 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp1923338vqo; Mon, 27 Mar 2023 19:31:35 -0700 (PDT) X-Google-Smtp-Source: AK7set+6kVLTQ1oJpMyOyKrH/BLcou/LsNTblvgtdB5XoV/DFITwRW8n6pvDIKYX4rOcAQKtFWLu X-Received: by 2002:a05:6a20:66a9:b0:d9:43a5:8cd0 with SMTP id o41-20020a056a2066a900b000d943a58cd0mr13144935pzh.14.1679970694898; Mon, 27 Mar 2023 19:31:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679970694; cv=none; d=google.com; s=arc-20160816; b=LvMKpSuFm4TnRttJrWIQ3gqaZ7DghbJBKBhDRisc/wmczT2WZBnNvnApvtneW9z3kR hmfSHC8acdGLZjYwSyrRMz2vZQkKk1tbj+5FdtGDYmT+GwJFt6BFD8X7Zz6iZZhw9YGM iPK0buwO3x6W+426rhy+QJ69LO1kFUljmwYidXbFqaWVYx7u+6ZfcWo0yiTW87gGAnD3 GLR49NrAWcsMXidHdHSocWBCG/oWtxlfDZ2CEJwBju4RTnjlKcrHQn/6RiY3Xt0+q2Rb uoAIkcG1s/Z4eYqwo+17dzcaQIMRYsUe3uxf86wUkUm2WFDatmQFaMZKJj0/jJtgwYOV s04w== 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=iPmuGgTPXcfyX5TrjJAMLBtjpDpn9RP6N8eyPLJPoIY=; b=oEul2/b7OSXwysoG7MxnLQoX9E4ChAeFM0z/LeNmS1z/8NYKBwETE2DvXFXkxyjBa/ cPt4oFyvxyZDe3eB7NgkHUVAXCJ9/7Mbv8PCaDFHjDra8lsniBp1nW7B4U2yCSvB0pJC Ol1CrZO+PzF93gwje2g3sgaG+krwnYxWN+IqH1o8R0bnWuBAOPv+Bm6EPRmejaGwjjSM i1MVNGy9VOrRr64uCZ6p4BGyYb7kLXX8eEWAtqksDUHWdRli3lJl8/4bqMpzyHzoIuO/ NJU+f99F1kr6PoR5nyTRvkDSMKopoWS92RVpov20kw+83NPFupcMEwn1Qg4PC/7RBr0l vykg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mediatek.com header.s=dk header.b=XJu5vd4B; 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 i31-20020a63585f000000b005030925d31asi28114755pgm.203.2023.03.27.19.31.22; Mon, 27 Mar 2023 19:31:34 -0700 (PDT) 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=XJu5vd4B; 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 S232400AbjC1C2k (ORCPT + 99 others); Mon, 27 Mar 2023 22:28:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55796 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232617AbjC1C2N (ORCPT ); Mon, 27 Mar 2023 22:28:13 -0400 Received: from mailgw02.mediatek.com (unknown [210.61.82.184]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9B99B2681; Mon, 27 Mar 2023 19:28:09 -0700 (PDT) X-UUID: 26f37ee0cd1011edb6b9f13eb10bd0fe-20230328 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=iPmuGgTPXcfyX5TrjJAMLBtjpDpn9RP6N8eyPLJPoIY=; b=XJu5vd4BMmhU23tcjug3nB6CXhzKkdpWVq8z1H/UPvnrPrqBxOFA+fAoKgoFZQEsPsFYsrFmceIANbYQLowaGkBU/DNps9CvZQNjnwzO7lUQ7lHVnYTHlkqTeGJjFpNQaR//doZ6uoFpsKJfGiqTF9V4usHGNPaP4s2HBXRFTEk=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.22,REQID:8e57c2f9-f66a-4d85-8d89-2dabf412d032,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:120426c,CLOUDID:e49a1bf7-ddba-41c3-91d9-10eeade8eac7,B ulkID:nil,BulkQuantity:0,Recheck:0,SF:102,TC:nil,Content:0,EDM:-3,IP:nil,U RL:0,File:nil,Bulk:nil,QS:nil,BEC:nil,COL:0,OSI:0,OSA:0,AV:0 X-CID-BVR: 0 X-CID-BAS: 0,_,0,_ X-UUID: 26f37ee0cd1011edb6b9f13eb10bd0fe-20230328 Received: from mtkmbs11n2.mediatek.inc [(172.21.101.187)] by mailgw02.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 1172088504; Tue, 28 Mar 2023 10:27:57 +0800 Received: from mtkmbs11n1.mediatek.inc (172.21.101.185) by mtkmbs11n2.mediatek.inc (172.21.101.187) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.25; Tue, 28 Mar 2023 10:27:56 +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.1118.25 via Frontend Transport; Tue, 28 Mar 2023 10:27:56 +0800 From: Tinghan Shen To: Bjorn Andersson , Mathieu Poirier , Rob Herring , Krzysztof Kozlowski , Matthias Brugger , AngeloGioacchino Del Regno , Tinghan Shen CC: , , , , , Subject: [PATCH v9 09/11] remoteproc: mediatek: Handle MT8195 SCP core 1 watchdog timeout Date: Tue, 28 Mar 2023 10:27:31 +0800 Message-ID: <20230328022733.29910-10-tinghan.shen@mediatek.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20230328022733.29910-1-tinghan.shen@mediatek.com> References: <20230328022733.29910-1-tinghan.shen@mediatek.com> MIME-Version: 1.0 X-MTK: N X-Spam-Status: No, score=-0.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS, UNPARSEABLE_RELAY autolearn=unavailable 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?1761576951549931297?= X-GMAIL-MSGID: =?utf-8?q?1761576951549931297?= The MT8195 SCP core 1 watchdog timeout needs to be handled in the SCP core 0 IRQ handler because the MT8195 SCP core 1 watchdog timeout IRQ is wired on the same IRQ entry for core 0 watchdog timeout. MT8195 SCP has a watchdog status register to identify the watchdog timeout source when IRQ triggered. Signed-off-by: Tinghan Shen Reviewed-by: AngeloGioacchino Del Regno --- drivers/remoteproc/mtk_common.h | 5 +++++ drivers/remoteproc/mtk_scp.c | 25 ++++++++++++++++++++++++- 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/drivers/remoteproc/mtk_common.h b/drivers/remoteproc/mtk_common.h index 6861543a0825..1e148cbad0fb 100644 --- a/drivers/remoteproc/mtk_common.h +++ b/drivers/remoteproc/mtk_common.h @@ -55,6 +55,10 @@ #define MT8192_CORE0_WDT_IRQ 0x10030 #define MT8192_CORE0_WDT_CFG 0x10034 +#define MT8195_SYS_STATUS 0x4004 +#define MT8195_CORE0_WDT BIT(16) +#define MT8195_CORE1_WDT BIT(17) + #define MT8195_L1TCM_SRAM_PDN_RESERVED_RSI_BITS GENMASK(7, 4) #define MT8195_CPU1_SRAM_PD 0x1084 @@ -63,6 +67,7 @@ #define MT8195_CORE1_SW_RSTN_CLR 0x20000 #define MT8195_CORE1_SW_RSTN_SET 0x20004 #define MT8195_CORE1_MEM_ATT_PREDEF 0x20008 +#define MT8195_CORE1_WDT_IRQ 0x20030 #define MT8195_CORE1_WDT_CFG 0x20034 #define MT8195_SEC_CTRL 0x85000 diff --git a/drivers/remoteproc/mtk_scp.c b/drivers/remoteproc/mtk_scp.c index f74ee80838e9..d08f21c1f947 100644 --- a/drivers/remoteproc/mtk_scp.c +++ b/drivers/remoteproc/mtk_scp.c @@ -231,6 +231,29 @@ static void mt8192_scp_irq_handler(struct mtk_scp *scp) } } +static void mt8195_scp_irq_handler(struct mtk_scp *scp) +{ + u32 scp_to_host; + + scp_to_host = readl(scp->reg_base + MT8192_SCP2APMCU_IPC_SET); + + if (scp_to_host & MT8192_SCP_IPC_INT_BIT) { + scp_ipi_handler(scp); + } else { + u32 reason = readl(scp->reg_base + MT8195_SYS_STATUS); + + if (reason & MT8195_CORE0_WDT) + writel(1, scp->reg_base + MT8192_CORE0_WDT_IRQ); + + if (reason & MT8195_CORE1_WDT) + writel(1, scp->reg_base + MT8195_CORE1_WDT_IRQ); + + scp_wdt_handler(scp, reason); + } + + writel(scp_to_host, scp->reg_base + MT8192_SCP2APMCU_IPC_CLR); +} + static void mt8195_scp_c1_irq_handler(struct mtk_scp *scp) { u32 scp_to_host; @@ -1256,7 +1279,7 @@ static const struct mtk_scp_of_data mt8192_of_data = { static const struct mtk_scp_of_data mt8195_of_data = { .scp_clk_get = mt8195_scp_clk_get, .scp_before_load = mt8195_scp_before_load, - .scp_irq_handler = mt8192_scp_irq_handler, + .scp_irq_handler = mt8195_scp_irq_handler, .scp_reset_assert = mt8192_scp_reset_assert, .scp_reset_deassert = mt8192_scp_reset_deassert, .scp_stop = mt8195_scp_stop,