From nobody Thu Nov 14 17:27:27 2024 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id F189BCA0FE9 for ; Fri, 1 Sep 2023 08:10:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1348650AbjIAIKZ (ORCPT ); Fri, 1 Sep 2023 04:10:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43896 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1348613AbjIAIKN (ORCPT ); Fri, 1 Sep 2023 04:10:13 -0400 Received: from mailgw01.mediatek.com (unknown [60.244.123.138]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ED2931703; Fri, 1 Sep 2023 01:10:02 -0700 (PDT) X-UUID: ee846e74489e11eea33bb35ae8d461a2-20230901 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=E1I4y94JpFrj/cyXGPiYmWNT42ZTv2aJPznnViXrh1Y=; b=EgL6K11Y4tnOzUQeeyyzaJLIX2709x6Axwi2nf+BJzz6TSsC5XQQ8h/qayGwb04Nm+l4iow++F+ypJWOd7PHZrTat5vJCUpcUOYP5iSjjEh5tEkA3MgHID6SYXIKRpvWBiZgTCnLRUyjvBOHlr68NRTG8L+IZuiHy67iMWPRh2w=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.31,REQID:551cd889-cf3a-4dd3-a904-07f5463c7bf0,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:0ad78a4,CLOUDID:2ef90020-33fd-4aaa-bb43-d3fd68d9d5ae,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,LES:1,SPR:NO, DKR:0,DKP:0,BRR:0,BRE:0 X-CID-BVR: 0 X-CID-BAS: 0,_,0,_ X-CID-FACTOR: TF_CID_SPAM_SNR X-UUID: ee846e74489e11eea33bb35ae8d461a2-20230901 Received: from mtkmbs13n2.mediatek.inc [(172.21.101.108)] by mailgw01.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 472105493; Fri, 01 Sep 2023 16:09:53 +0800 Received: from mtkmbs11n2.mediatek.inc (172.21.101.187) 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.1118.26; Fri, 1 Sep 2023 16:09:52 +0800 Received: from mtksdccf07.mediatek.inc (172.21.84.99) by mtkmbs11n2.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.2.1118.26 via Frontend Transport; Fri, 1 Sep 2023 16:09:52 +0800 From: Tinghan Shen To: Bjorn Andersson , Mathieu Poirier , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Matthias Brugger , AngeloGioacchino Del Regno , Tinghan Shen CC: , , , , , Subject: [PATCH v17 07/14] remoteproc: mediatek: Probe SCP cluster on single-core SCP Date: Fri, 1 Sep 2023 16:09:28 +0800 Message-ID: <20230901080935.14571-8-tinghan.shen@mediatek.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20230901080935.14571-1-tinghan.shen@mediatek.com> References: <20230901080935.14571-1-tinghan.shen@mediatek.com> MIME-Version: 1.0 X-MTK: N Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" This is the 3rd preliminary step for probing multi-core SCP. Rewrite the probing flow of single-core SCP to adapt with the 'cluster' concept needed by the multi-core SCP. The SCP core object(s) is maintained at the cluster list. Signed-off-by: Tinghan Shen Reviewed-by: AngeloGioacchino Del Regno --- drivers/remoteproc/mtk_common.h | 2 + drivers/remoteproc/mtk_scp.c | 86 +++++++++++++++++++++++---------- 2 files changed, 63 insertions(+), 25 deletions(-) diff --git a/drivers/remoteproc/mtk_common.h b/drivers/remoteproc/mtk_commo= n.h index b04d71277c1f..1438159ae736 100644 --- a/drivers/remoteproc/mtk_common.h +++ b/drivers/remoteproc/mtk_common.h @@ -105,6 +105,7 @@ struct mtk_scp_of_cluster { void __iomem *l1tcm_base; size_t l1tcm_size; phys_addr_t l1tcm_phys; + struct list_head mtk_scp_list; }; =20 struct mtk_scp { @@ -132,6 +133,7 @@ struct mtk_scp { =20 struct rproc_subdev *rpmsg_subdev; =20 + struct list_head elem; struct mtk_scp_of_cluster *cluster; }; =20 diff --git a/drivers/remoteproc/mtk_scp.c b/drivers/remoteproc/mtk_scp.c index 7a2ba1e1e95a..d67dcabdab9e 100644 --- a/drivers/remoteproc/mtk_scp.c +++ b/drivers/remoteproc/mtk_scp.c @@ -854,8 +854,8 @@ static void scp_remove_rpmsg_subdev(struct mtk_scp *scp) } } =20 -static int scp_rproc_init(struct platform_device *pdev, - struct mtk_scp_of_cluster *scp_cluster) +static struct mtk_scp *scp_rproc_init(struct platform_device *pdev, + struct mtk_scp_of_cluster *scp_cluster) { struct device *dev =3D &pdev->dev; struct device_node *np =3D dev->of_node; @@ -867,11 +867,13 @@ static int scp_rproc_init(struct platform_device *pde= v, =20 ret =3D rproc_of_parse_firmware(dev, 0, &fw_name); if (ret < 0 && ret !=3D -EINVAL) - return ret; + return ERR_PTR(ret); =20 rproc =3D devm_rproc_alloc(dev, np->name, &scp_ops, fw_name, sizeof(*scp)= ); - if (!rproc) - return dev_err_probe(dev, -ENOMEM, "unable to allocate remoteproc\n"); + if (!rproc) { + dev_err(dev, "unable to allocate remoteproc\n"); + return ERR_PTR(-ENOMEM); + } =20 scp =3D rproc->priv; scp->rproc =3D rproc; @@ -882,20 +884,21 @@ static int scp_rproc_init(struct platform_device *pde= v, =20 res =3D platform_get_resource_byname(pdev, IORESOURCE_MEM, "sram"); scp->sram_base =3D devm_ioremap_resource(dev, res); - if (IS_ERR(scp->sram_base)) - return dev_err_probe(dev, PTR_ERR(scp->sram_base), - "Failed to parse and map sram memory\n"); + if (IS_ERR(scp->sram_base)) { + dev_err(dev, "Failed to parse and map sram memory\n"); + return ERR_CAST(scp->sram_base); + } =20 scp->sram_size =3D resource_size(res); scp->sram_phys =3D res->start; =20 ret =3D scp->data->scp_clk_get(scp); if (ret) - return ret; + return ERR_PTR(ret); =20 ret =3D scp_map_memory_region(scp); if (ret) - return ret; + return ERR_PTR(ret); =20 mutex_init(&scp->send_lock); for (i =3D 0; i < SCP_IPI_MAX; i++) @@ -922,11 +925,7 @@ static int scp_rproc_init(struct platform_device *pdev, goto remove_subdev; } =20 - ret =3D rproc_add(rproc); - if (ret) - goto remove_subdev; - - return 0; + return scp; =20 remove_subdev: scp_remove_rpmsg_subdev(scp); @@ -937,7 +936,43 @@ static int scp_rproc_init(struct platform_device *pdev, mutex_destroy(&scp->ipi_desc[i].lock); mutex_destroy(&scp->send_lock); =20 - return ret; + return ERR_PTR(ret); +} + +static void scp_free(struct mtk_scp *scp) +{ + int i; + + scp_remove_rpmsg_subdev(scp); + scp_ipi_unregister(scp, SCP_IPI_INIT); + scp_unmap_memory_region(scp); + for (i =3D 0; i < SCP_IPI_MAX; i++) + mutex_destroy(&scp->ipi_desc[i].lock); + mutex_destroy(&scp->send_lock); +} + +static int scp_cluster_init(struct platform_device *pdev, + struct mtk_scp_of_cluster *scp_cluster) +{ + struct device *dev =3D &pdev->dev; + struct list_head *scp_list =3D &scp_cluster->mtk_scp_list; + struct mtk_scp *scp; + int ret; + + scp =3D scp_rproc_init(pdev, scp_cluster); + if (IS_ERR(scp)) + return PTR_ERR(scp); + + ret =3D rproc_add(scp->rproc); + if (ret) { + dev_err(dev, "Failed to add rproc\n"); + scp_free(scp); + return ret; + } + + list_add_tail(&scp->elem, scp_list); + + return 0; } =20 static int scp_probe(struct platform_device *pdev) @@ -970,7 +1005,9 @@ static int scp_probe(struct platform_device *pdev) scp_cluster->l1tcm_phys =3D res->start; } =20 - ret =3D scp_rproc_init(pdev, scp_cluster); + INIT_LIST_HEAD(&scp_cluster->mtk_scp_list); + + ret =3D scp_cluster_init(pdev, scp_cluster); if (ret) return ret; =20 @@ -980,15 +1017,14 @@ static int scp_probe(struct platform_device *pdev) static void scp_remove(struct platform_device *pdev) { struct mtk_scp *scp =3D platform_get_drvdata(pdev); - int i; + struct mtk_scp_of_cluster *scp_cluster =3D scp->cluster; + struct mtk_scp *temp; =20 - rproc_del(scp->rproc); - scp_remove_rpmsg_subdev(scp); - scp_ipi_unregister(scp, SCP_IPI_INIT); - scp_unmap_memory_region(scp); - for (i =3D 0; i < SCP_IPI_MAX; i++) - mutex_destroy(&scp->ipi_desc[i].lock); - mutex_destroy(&scp->send_lock); + list_for_each_entry_safe_reverse(scp, temp, &scp_cluster->mtk_scp_list, e= lem) { + list_del(&scp->elem); + rproc_del(scp->rproc); + scp_free(scp); + } } =20 static const struct mtk_scp_of_data mt8183_of_data =3D { --=20 2.18.0