From mboxrd@z Thu Jan 1 00:00:00 1970 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id C148EECAAD8 for ; Fri, 16 Sep 2022 17:16:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:Subject:Message-ID:Date:From: In-Reply-To:References:MIME-Version:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=zZq7Xw4MYKGifOG8DDLuDbDOZtZZLrmHElBVPXSt8h8=; b=RVVazswi4huBug HL9g/PjP3uvbMWzYn+7RrB6rEolkK4ybYlzEgZVhW7c1J38K5M42QuGCIuLPB10UlGwOWpaB3YboG W9/HDdQodp6F6Y7gLT/YSIdkDnTIK6BWM8+9hzFccNPsi3RKIHNJRQAk/SQuXEugLnUY7GFvh6gQd HbAsdkEaTbNxpsX4smnc/qStW65iIxO5fD3RbfsaPG6FimMb8szWy/n36lG1x1J3LM0CfqATPo3QB vn//Y3LGRCQEsFLIiht67gEHj6MFLl70vv39g3h/tpf1jhYQkmeXyX/+zMtDqRNpzVgskZje7A8/e uSXJ6+nLCSp2AEuJK87w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oZEwC-00FLig-RT; Fri, 16 Sep 2022 17:15:37 +0000 Received: from mail-ej1-x62b.google.com ([2a00:1450:4864:20::62b]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oZEw6-00FLeX-D6 for linux-arm-kernel@lists.infradead.org; Fri, 16 Sep 2022 17:15:35 +0000 Received: by mail-ej1-x62b.google.com with SMTP id go34so50948274ejc.2 for ; Fri, 16 Sep 2022 10:15:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date; bh=UKj9UGbXYvEgM0CJerOBIFmYNI3OH+KXrWnGoYkjkbc=; b=JkWCKXbyMNHGdGJZpg3xwevNAHEElmCrtUwV0oTmQOerPQBVslZbRYD932oLcbhXC/ Af/yZk6mE7xNlm/+jeLPbjRYQt0KeKUXX9A1YZgKq9FUizyvBit8uzSbWys9VPuIGTVH qSvCEGjTYtm0oRTWzEXh2F50X6GvfusYC/xUFpaeNk4btCeEH1YTHFHdQHr2vjKdYgGT 9rDm3XN0Fcs/yhc2Ldeb+53NQr4bU3xGcY8rbDFh4BIkjnRhtUsEq/s2kUECcDn1MfrS G+tcUNsVOdhbFIgQHJdvYLGRUQWduPdColxMcPnQylVhxssGoj4v4ESu9CepZ32l/hOD aXUA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date; bh=UKj9UGbXYvEgM0CJerOBIFmYNI3OH+KXrWnGoYkjkbc=; b=eGxh7vaxudJ+dIJcmOT+RI6eKKXnKtGG1H8nOObYrDEK4ITSSG5RQsiXNIvDM6RrD4 0oE4s5GrBePMGdAk+3L6JKhFdKSBGr9M1IqBXo5gw/hA07gEBe0+8CA96J6lFzQn4VpX 4X8hbmLZG4BT0you9PvPgda8c4NJkmAAcNJb6geNYUHVfOjdGEQ0VflsRBUOBhHgNuj6 HITykUu0EPP1vtGhxgyHRtgL5LWUQ9hfQ8bd+GQ7VkGfC+yc8anGRbBRG1TnzYLM2Ig/ soY1yPDQ9THymXxXkAJR02v+bX59c3aMwIqywHH0Z+g0ZwltpoGDC/vHwpTtQpr0TBhB jAaA== X-Gm-Message-State: ACrzQf1E0UVcX5hvr+UjWOAFgs+4RnF312w4kETdhz4Q5qr3AKZiMJtW JuZfZ/ojfXWAJk62SoGJxc6LXSH4oAIExOao6ZmvcA== X-Google-Smtp-Source: AMsMyM79jF/mQUjZkPBzBVS66n8GDckLQzu9iZ4Q2FgLNCzLYn6iwTiqqFodYM/inPq47dG72kAYJzNkRM/I3UtTlRs= X-Received: by 2002:a17:907:1df1:b0:779:4f57:6bb2 with SMTP id og49-20020a1709071df100b007794f576bb2mr4327098ejc.407.1663348526555; Fri, 16 Sep 2022 10:15:26 -0700 (PDT) MIME-Version: 1.0 References: <20220829194247.GC2264818@p14s> <20220908111757.14633-1-tinghan.shen@mediatek.com> In-Reply-To: From: Mathieu Poirier Date: Fri, 16 Sep 2022 11:15:14 -0600 Message-ID: Subject: Re: [PATCH v2 4/9] remoteproc: mediatek: Support probing for the 2nd core of dual-core SCP To: TingHan Shen Cc: Project_Global_Chrome_Upstream_Group@mediatek.com, bjorn.andersson@linaro.org, bleung@chromium.org, chrome-platform@lists.linux.dev, devicetree@vger.kernel.org, dnojiri@chromium.org, enric.balletbo@collabora.com, groeck@chromium.org, gustavoars@kernel.org, keescook@chromium.org, krzk+dt@kernel.org, lee.jones@linaro.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-mediatek@lists.infradead.org, linux-remoteproc@vger.kernel.org, matthias.bgg@gmail.com, pmalani@chromium.org, robh+dt@kernel.org, sebastian.reichel@collabora.com, weishunc@google.com X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220916_101530_482201_B89D2C2A X-CRM114-Status: GOOD ( 50.61 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Fri, 16 Sept 2022 at 06:00, TingHan Shen wrote: > > On Thu, 2022-09-08 at 14:58 -0600, Mathieu Poirier wrote: > > On Thu, 8 Sept 2022 at 05:21, Tinghan Shen > > wrote: > > > > > Hi Mathieu, > > > > > > > > The mtk_scp.c driver only supports the single core SCP and the > > > > > 1st core of a dual-core SCP. This patch extends it for the 2nd core. > > > > > > > > > > MT8195 SCP is a dual-core MCU. Both cores are housed in the same > > > > > > subsys. > > > > > > > > s/subsys/subsystem > > > > > > > > > They have the same viewpoint of registers and memory. > > > > > > > > > > Core 1 of the SCP features its own set of core configuration registers, > > > > > interrupt controller, timers, and DMAs. The rest of the peripherals > > > > > in this subsystem are shared by core 0 and core 1. > > > > > > > > > > As for memory, core 1 has its own cache memory. the SCP SRAM is shared > > > > > > > > /the/The > > > > > > > > > by core 0 and core 1. > > > > > > > > > > Signed-off-by: Tinghan Shen > > > > > --- > > > > > drivers/remoteproc/mtk_scp.c | 22 ++++++++++++++++++++-- > > > > > 1 file changed, 20 insertions(+), 2 deletions(-) > > > > > > > > > > diff --git a/drivers/remoteproc/mtk_scp.c > > > > > > b/drivers/remoteproc/mtk_scp.c > > > > > index 3510c6d0bbc8..91b4aefde4ac 100644 > > > > > --- a/drivers/remoteproc/mtk_scp.c > > > > > +++ b/drivers/remoteproc/mtk_scp.c > > > > > @@ -23,6 +23,10 @@ > > > > > #define MAX_CODE_SIZE 0x500000 > > > > > #define SECTION_NAME_IPI_BUFFER ".ipi_buffer" > > > > > > > > > > +#define SCP_CORE_0 0 > > > > > +#define SCP_CORE_1 1 > > > > > +#define SCP_CORE_SINGLE 0xF > > > > > + > > > > > /** > > > > > * scp_get() - get a reference to SCP. > > > > > * > > > > > @@ -836,6 +840,7 @@ static int scp_probe(struct platform_device *pdev) > > > > > struct resource *res; > > > > > const char *fw_name = "scp.img"; > > > > > int ret, i; > > > > > + u32 core_id = SCP_CORE_SINGLE; > > > > > > > > > > ret = rproc_of_parse_firmware(dev, 0, &fw_name); > > > > > if (ret < 0 && ret != -EINVAL) > > > > > @@ -851,8 +856,16 @@ static int scp_probe(struct platform_device *pdev) > > > > > scp->data = of_device_get_match_data(dev); > > > > > platform_set_drvdata(pdev, scp); > > > > > > > > > > + ret = of_property_read_u32_index(dev->of_node, > > > > > > "mediatek,scp-core", 1, &core_id); > > > > > + if (ret == 0) > > > > > + dev_info(dev, "Boot SCP dual core %u\n", core_id); > > > > > > > > Why is the DT property "mediatek,scp-core" needed at all? Since the > > > > > > compatible > > > > "mediatek,mt8195-scp-dual" has already been defined previously in this > > > > > > patchset, > > > > initialising the second core, if present, is a matter of looking at the > > > > compatile string. > > > > > > This idea of identify cores by the compatible looks workable. > > > I'll update this series at next version. > > > Thanks! > > > > > > > > > > > > + > > > > > res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "sram"); > > > > > - scp->sram_base = devm_ioremap_resource(dev, res); > > > > > + if (core_id == SCP_CORE_1) > > > > > + scp->sram_base = devm_ioremap(dev, res->start, > > > > > > resource_size(res)); > > > > > + else > > > > > + scp->sram_base = devm_ioremap_resource(dev, res); > > > > > + > > > > > > > > This looks very broken... For this to work you would need to have two DT > > > > entries with the "mediatek,mt8195-scp-dual" compatible properly, one with > > > > "mediatek,scp-core = <&scp_dual1 0>;" and another one with > > > > > > "mediatek,scp-core = <&scp_dual0 1>;". > > > > > > > > Which is also very broken... Here you have a binding whose first > > > > > > argument is a > > > > reference to the core sibling while the second argument is a > > > > > > characteristic of > > > > the current core, which is highly confusing. > > > > > > > > I suggest what when you see the compatible binding > > > > > > "mediatek,mt8195-scp", a > > > > single core is initialized. If you see "mediatek,mt8195-scp-dual", both > > > > > > cores > > > > are initialized as part of the _same_ probe. > > > > > > > > If the above analysis is not correct it means I misinterpreted your > > > > work and if so, a serious amount of comments is needed _and_ a very > > > > > > detailed > > > > example in "mtk,scp.yaml" that leaves no room for interpretation. > > > > > > > > I will stop reviewing this patchset until you have clarified how this > > > > > > works. > > > > > > > > Thanks, > > > > Mathieu > > > > > > There's one problem of initializng the CORE1 using the same probe flow. > > > The register space of CORE0 and CORE1 are overlapped in the device node. > > > Both cores need to use the 'cfg' registers defined in scp yaml. > > > The devm_ioremap_resource catches address overlapping and returns error > > > when > > > probing CORE1 driver. > > > > > > > That is exactly why I suggest to initialise both cores within the same > > probe() function. > > > > Hi Mathieu, > > I'm thinking about how to initialise in the same probe() function. > I'm wondering if this implies that using one scp driver to initialize 2 cores? > If it is, I assume the dts descriptions for both cores should be contained in one node. > > When there's one node for both cores, it looks like that there is a problem of > using dma_allocate_coherent(). Each core has its own reserved memory region. > When there's only one device for both cores, it's not able to identify the memory region > by the device parameter of dma_allocate_coherent(). > > Is it acceptable to consider manually allocating core 1 device in the probe() when probing core 0? Look at what Suman did for TI's K3 R5[1] and DSP[2] platforms. Reviewing the bindings for both platforms will also give you a good idea of how things work. [1]. https://elixir.bootlin.com/linux/v6.0-rc5/source/drivers/remoteproc/ti_k3_r5_remoteproc.c#L1683 [2]. https://elixir.bootlin.com/linux/v6.0-rc5/source/drivers/remoteproc/ti_k3_dsp_remoteproc.c#L673 > > > Best regards, > TingHan > > > > > > > > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel