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 B21BBC77B75 for ; Wed, 17 May 2023 17:58:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=PRGNMLfUfmstzWu7T2z9+f63mnhBNH1tSnmTg/DwAEQ=; b=gAF14OVUjV3Vf5XMNihCeexDgq YdmKqu1IOYa+aSchzpV2Gj9Uc4ouM53aiTQBrFEzTXDFGXW8cNmS0YoQXBMF6Kxa+i/3QL8cB0qi+ j4GQFIQY8Rujbhfna2APtI86vhNlJQZrel/7o783zWTM+yfYPnu4P9o2Kdzqb0jPGoug9nUZ7A3/j 4df6ApyPXiCS7f5RTvEpy2UOSt8UBJHXJTFhVuUO9pfqkhaejsKCWZ6gQlI9ohG1FdFBNI93nBGsP dPk/3T4KxwE2J42yhWNBVgZMLZIwaAexK0fxNsGO+FrJ0tvFBewsthwKOlCNoe5cYEpoxOcgKEg5j 7eEeJRjQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1pzLQ5-00AfzI-1C; Wed, 17 May 2023 17:58:37 +0000 Received: from mail-pl1-x633.google.com ([2607:f8b0:4864:20::633]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1pzLQ1-00Afxz-0c for linux-mediatek@lists.infradead.org; Wed, 17 May 2023 17:58:34 +0000 Received: by mail-pl1-x633.google.com with SMTP id d9443c01a7336-1ae3ed1b08eso12272255ad.0 for ; Wed, 17 May 2023 10:58:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1684346310; x=1686938310; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=PRGNMLfUfmstzWu7T2z9+f63mnhBNH1tSnmTg/DwAEQ=; b=Jm35xW1cRZ/F90wt0h3bGOPCTen8c2gmnjncdgF7e6KT31+WA4SPRSQyhim1XvnVLE QKtw0N3QiJoYq245Fn8iEDOje5JMajAUKJzEvXg/XZdy5c2MJNZDvfBf6WY6A+5bBmMb aLVuWby9tuvdq7cnnCX9aZ1luqZccYwz9WuLTE3f1ezVy/t4hOCUexz/VbmWXVin3zhn kZCn41MWOIvMjVM/tirechE8eoAPoKpBGBYKADjnAcmkVw5d9qzR9vx1FE/s1FvNiFPR U+47siOH7AKayqHhSZpPNQkXWJxiBro6iWDzR30Ug2oZidtNvtgR/plTAlyJ0xObY9MI CZIg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684346310; x=1686938310; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=PRGNMLfUfmstzWu7T2z9+f63mnhBNH1tSnmTg/DwAEQ=; b=B//sCaPgnzpQuF7lNrIxKnopul9yTNTs2MVZgllfnF8euDr4xuWGttDSuIhxgvG7rB 78t62dnzLl+j4OyE3IzFXI/0tPJE6uARgMYH+WiUMG0LtvrGDWDmzT4OnhaiJovflbeu V3X2yVRS3QimafjhwAHjqv5kxV5gQzndFNr1jYjk3JD4apiJyrd09Yl+/E4Nb/Sx9Lir 7qzHX5QjuEwcabOgID5ONzkrD3n89+vFIzdYW+DbbJnzp6DwxQxrJ7yZaYwSkdUOI8zP mgC+L0nr83H4JcgWyUJPg+zEigEpePejVRmpAKyGHcFtHzuHNpy/WN5dT9ASTpB3WIII VvWg== X-Gm-Message-State: AC+VfDxEFS1cH2Uj3uIXQkF4IQYM5FiEPJ+zZnMdQ4bd7X3zUkCsQsLf xaJ6PLBnBCrtgiMYJQnAezONzg== X-Google-Smtp-Source: ACHHUZ7fbLj71H3Bwby0ODNkhv4RQWQwdhA80KwYsAbIM+bAk2Oy0dY4Cocm5quS5tQgZjjK5i/igQ== X-Received: by 2002:a17:903:234c:b0:1ab:289f:65cf with SMTP id c12-20020a170903234c00b001ab289f65cfmr56070844plh.54.1684346310357; Wed, 17 May 2023 10:58:30 -0700 (PDT) Received: from p14s ([2604:3d09:148c:c800:fd0b:2592:d377:e4e3]) by smtp.gmail.com with ESMTPSA id b15-20020a170902b60f00b001aafe232bcfsm17853795pls.44.2023.05.17.10.58.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 May 2023 10:58:29 -0700 (PDT) Date: Wed, 17 May 2023 11:58:27 -0600 From: Mathieu Poirier To: Tinghan Shen Cc: Bjorn Andersson , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Matthias Brugger , AngeloGioacchino Del Regno , linux-remoteproc@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, Project_Global_Chrome_Upstream_Group@mediatek.com Subject: Re: [PATCH v12 07/11] remoteproc: mediatek: Control SCP core 1 by rproc subdevice Message-ID: References: <20230517043449.26352-1-tinghan.shen@mediatek.com> <20230517043449.26352-8-tinghan.shen@mediatek.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230517043449.26352-8-tinghan.shen@mediatek.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230517_105833_252925_81072351 X-CRM114-Status: GOOD ( 27.78 ) X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@lists.infradead.org On Wed, May 17, 2023 at 12:34:45PM +0800, Tinghan Shen wrote: > Register SCP core 1 as a subdevice of core 0 for the boot sequence > and watchdog timeout handling. The core 1 has to boot after core 0 > because the SCP clock and SRAM power is controlled by SCP core 0. > As for watchdog timeout handling, the remoteproc framework helps to > stop/start subdevices automatically when SCP driver receives watchdog > timeout event. > Subdevices should be reserved for virtio devices and not used for remote processors. Mixing both will get us into trouble at some point in the future. The way to address power and clock dependencies is to use a different rproc_ops for SCP1. That rproc_ops would implemented the prepare() and unprepare() functions to power up SCP1's power domain and deal with its clock. I will stop here for this revision. Thanks, Mathieu > Signed-off-by: Tinghan Shen > Reviewed-by: AngeloGioacchino Del Regno > --- > drivers/remoteproc/mtk_common.h | 9 ++++ > drivers/remoteproc/mtk_scp.c | 88 +++++++++++++++++++++++++++++++++ > 2 files changed, 97 insertions(+) > > diff --git a/drivers/remoteproc/mtk_common.h b/drivers/remoteproc/mtk_common.h > index 56395e8664cb..85afed2e6928 100644 > --- a/drivers/remoteproc/mtk_common.h > +++ b/drivers/remoteproc/mtk_common.h > @@ -100,6 +100,13 @@ struct mtk_scp_of_data { > size_t ipi_buf_offset; > }; > > +struct mtk_scp_core_subdev { > + struct rproc_subdev subdev; > + struct mtk_scp *scp; > +}; > + > +#define to_core_subdev(d) container_of(d, struct mtk_scp_core_subdev, subdev) > + > struct mtk_scp { > struct device *dev; > struct rproc *rproc; > @@ -130,6 +137,8 @@ struct mtk_scp { > struct rproc_subdev *rpmsg_subdev; > > struct list_head elem; > + struct list_head *cluster; > + struct mtk_scp_core_subdev *core_subdev; > }; > > /** > diff --git a/drivers/remoteproc/mtk_scp.c b/drivers/remoteproc/mtk_scp.c > index d644e232dfec..18534b1179b5 100644 > --- a/drivers/remoteproc/mtk_scp.c > +++ b/drivers/remoteproc/mtk_scp.c > @@ -863,6 +863,60 @@ static void scp_remove_rpmsg_subdev(struct mtk_scp *scp) > } > } > > +static int scp_core_subdev_start(struct rproc_subdev *subdev) > +{ > + struct mtk_scp_core_subdev *core_subdev = to_core_subdev(subdev); > + struct mtk_scp *scp = core_subdev->scp; > + > + rproc_boot(scp->rproc); > + > + return 0; > +} > + > +static void scp_core_subdev_stop(struct rproc_subdev *subdev, bool crashed) > +{ > + struct mtk_scp_core_subdev *core_subdev = to_core_subdev(subdev); > + struct mtk_scp *scp = core_subdev->scp; > + > + rproc_shutdown(scp->rproc); > +} > + > +static int scp_core_subdev_register(struct mtk_scp *scp) > +{ > + struct device *dev = scp->dev; > + struct mtk_scp_core_subdev *core_subdev; > + struct mtk_scp *scp_c0; > + > + scp_c0 = list_first_entry(scp->cluster, struct mtk_scp, elem); > + if (!scp_c0) > + return -ENODATA; > + > + core_subdev = devm_kzalloc(dev, sizeof(*core_subdev), GFP_KERNEL); > + if (!core_subdev) > + return -ENOMEM; > + > + core_subdev->scp = scp; > + core_subdev->subdev.start = scp_core_subdev_start; > + core_subdev->subdev.stop = scp_core_subdev_stop; > + > + scp->core_subdev = core_subdev; > + rproc_add_subdev(scp_c0->rproc, &scp->core_subdev->subdev); > + > + return 0; > +} > + > +static void scp_core_subdev_unregister(struct mtk_scp *scp) > +{ > + struct mtk_scp *scp_c0; > + > + if (scp->core_subdev) { > + scp_c0 = list_first_entry(scp->cluster, struct mtk_scp, elem); > + rproc_remove_subdev(scp_c0->rproc, &scp->core_subdev->subdev); > + devm_kfree(scp->dev, scp->core_subdev); > + scp->core_subdev = NULL; > + } > +} > + > static struct mtk_scp *scp_rproc_init(struct platform_device *pdev, > struct mtk_scp_of_cluster *scp_cluster, > const struct mtk_scp_of_data *of_data) > @@ -957,6 +1011,7 @@ static void scp_free(struct mtk_scp *scp) > { > int i; > > + scp_core_subdev_unregister(scp); > scp_remove_rpmsg_subdev(scp); > scp_ipi_unregister(scp, SCP_IPI_INIT); > scp_unmap_memory_region(scp); > @@ -989,6 +1044,15 @@ static int scp_add_single_core(struct platform_device *pdev) > return 0; > } > > +static void scp_rproc_boot_callback(const struct firmware *fw, void *context) > +{ > + struct rproc *rproc = context; > + > + rproc_boot(rproc); > + > + release_firmware(fw); > +} > + > static int scp_add_multi_core(struct platform_device *pdev) > { > struct device *dev = &pdev->dev; > @@ -1029,6 +1093,20 @@ static int scp_add_multi_core(struct platform_device *pdev) > goto init_fail; > } > > + scp->cluster = cluster; > + if (!list_empty(cluster)) { > + ret = scp_core_subdev_register(scp); > + if (ret) { > + dev_err(dev, "Failed to register core %d as subdev\n", core_id); > + of_node_put(child); > + scp_free(scp); > + goto init_fail; > + } > + } > + > + /* boot after all cores finished rproc_add() */ > + scp->rproc->auto_boot = false; > + > ret = rproc_add(scp->rproc); > if (ret) { > dev_err(dev, "Failed to add rproc of core %d\n", core_id); > @@ -1041,6 +1119,16 @@ static int scp_add_multi_core(struct platform_device *pdev) > core_id++; > } > > + /* boot core 0, and other cores are booted following core 0 as subdevices */ > + scp = list_first_entry(cluster, struct mtk_scp, elem); > + ret = request_firmware_nowait(THIS_MODULE, FW_ACTION_UEVENT, > + scp->rproc->firmware, &scp->rproc->dev, GFP_KERNEL, > + scp->rproc, scp_rproc_boot_callback); > + if (ret < 0) { > + dev_err(dev, "request_firmware_nowait err: %d\n", ret); > + goto init_fail; > + } > + > return 0; > > init_fail: > -- > 2.18.0 >