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 0024AC4332F for ; Wed, 12 Oct 2022 21:47:05 +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:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=nCs0ftAzCMMD+6SmfHSIqpQQTPhcWPEHhcg9LgmGLJQ=; b=z6LkdlEyb/+ER6 LZl1+2NiVSiIqeLX62qBZD3hODEfRJP/qQkD8v+0P3Pjwt5PO+BcVdg7+T51qBi7894uYhGNJXSRa nM53KPorreIBFwTpBLIrtgD2inim6Ly8kHB6g1QWFwA37ChLynexBNN36Ojlrra2Ci8qgGCrK9DPZ u8QIyN5909q5OsKWJ41O42nzJ6FLgv+tAAf8zfLMEI3t9u1N7qMuNHkW97LG5MoarTLMWly5Q3Kt2 jSg1ekhtXgOw5JqwMOE1aoDRnjYHLwn2aXWVPIPcHrWAxMmxkGT9SXIl0C3I/eEJDgsotkENC94wV WiGl1OmKNlRey2N1Ke+g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oijXj-009Ruh-I3; Wed, 12 Oct 2022 21:45:35 +0000 Received: from mail-pf1-x42a.google.com ([2607:f8b0:4864:20::42a]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oijXg-009RtQ-Dd for linux-arm-kernel@lists.infradead.org; Wed, 12 Oct 2022 21:45:34 +0000 Received: by mail-pf1-x42a.google.com with SMTP id p14so220952pfq.5 for ; Wed, 12 Oct 2022 14:45:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; 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=XnSNmVn3ksCv9S8MOdNsWwpNq6AQ/Pcm1KHOD5G+EMY=; b=MGsnnOGYTmmJRtA8umlAumAHrBbfsJN0AzQcAOW94b1F1EZyLaMrEapXfxR+MbLt1F W2dt3XXHj0SG4HooyYMQ9meAu/G8kNck5O2VrATPQ2cGiCcbfelZXmZx7q9pZXhrLgRd IaBflRnpcnLpOFjCPjOR/w1kgyhbDdQPHbZko4MGBD5MyAVlVf2dG03HSSImTJSC/i9S jCZWDLNzif5W+2yjoxkfY2WHUGV5rhNAHCDAvB+LWqLgdoicKE2bZkCabXNfDu2TyszF jUbvzs7DEtjoSPUKBfYdNk3Q9L+iGArIxaCeNPJan3kmlNQbF0IkuahIa8meBvSEwLi6 D63Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=XnSNmVn3ksCv9S8MOdNsWwpNq6AQ/Pcm1KHOD5G+EMY=; b=N7tOHiMHSIUk09NW5pi5paU1OplEg3fvZkNO5D7/Lql1Ml5gViQo8qRxygbJPenwey 7BIUtIgYQn8DZsSxYNHN8BO7daKc+KxGquAT0Cu/jt+e4KLubPV55sykDEGyd2DTxrLn lQLHqq+cwhVciHP2yax9Wc/eAw+zBJcEvR3CRJ6fHm+jH3qqceBac0/9f5ypKuRvT6bN RKS7Ofn+nFsDWQw5eh3rqIntbR3oBsyp6GesD+dwqdsW9r8BXI768mxX08UZRMpvuy4G Hcz+Kj7hlT+jKvQdcTyE01TaBaWYjItrBewlJGn7RCiELcfRnB4c7NGNy5us5w3i/DQ/ 2Ezg== X-Gm-Message-State: ACrzQf3Z+gQ/+/RQFRRmgRgXIxE+8UhRXeK5MaslZ/Q00sq75B2pRUZk P97dMkI4uAIromwEbPkjmyEC5w== X-Google-Smtp-Source: AMsMyM6HbXJvvwCvGKgvg48z9e4cYGEm947nwbG/SYEqqcBQ9dDCX+0Mato1F438T8S1GJHJ2ZdJxQ== X-Received: by 2002:a63:4b4c:0:b0:45a:5f8:b49d with SMTP id k12-20020a634b4c000000b0045a05f8b49dmr26997295pgl.490.1665611121849; Wed, 12 Oct 2022 14:45:21 -0700 (PDT) Received: from p14s (S0106889e681aac74.cg.shawcable.net. [68.147.0.187]) by smtp.gmail.com with ESMTPSA id ik7-20020a170902ab0700b0016f8e8032c4sm11006457plb.129.2022.10.12.14.45.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Oct 2022 14:45:20 -0700 (PDT) Date: Wed, 12 Oct 2022 15:45:18 -0600 From: Mathieu Poirier To: "Peng Fan (OSS)" Cc: andersson@kernel.org, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, shawnguo@kernel.org, s.hauer@pengutronix.de, kernel@pengutronix.de, festevam@gmail.com, linux-imx@nxp.com, linux-remoteproc@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Peng Fan Subject: Re: [PATCH V6 4/7] remoteproc: imx_rproc: support kicking Mcore from Linux for i.MX8QXP Message-ID: <20221012214518.GB1196937@p14s> References: <20220929061704.1571746-1-peng.fan@oss.nxp.com> <20220929061704.1571746-5-peng.fan@oss.nxp.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20220929061704.1571746-5-peng.fan@oss.nxp.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221012_144532_487985_E663D0A9 X-CRM114-Status: GOOD ( 31.48 ) 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 Thu, Sep 29, 2022 at 02:17:01PM +0800, Peng Fan (OSS) wrote: > From: Peng Fan > > When M4 is in the same hardware partition with Cortex-A, it > could be start/stop by Linux. > > Added power domain to make sure M4 could run, it requires several power > domains to work. Make clk always optional for i.MX8QXP, because > SCFW handles it when power up M4 core. > > Signed-off-by: Peng Fan > --- > drivers/remoteproc/imx_rproc.c | 88 ++++++++++++++++++++++++++++++++-- > 1 file changed, 85 insertions(+), 3 deletions(-) > > diff --git a/drivers/remoteproc/imx_rproc.c b/drivers/remoteproc/imx_rproc.c > index a56aecae00c6..7d2e11aed0aa 100644 > --- a/drivers/remoteproc/imx_rproc.c > +++ b/drivers/remoteproc/imx_rproc.c > @@ -16,6 +16,7 @@ > #include > #include > #include > +#include > #include > #include > #include > @@ -79,6 +80,8 @@ struct imx_rproc_mem { > #define ATT_OWN BIT(1) > #define ATT_IOMEM BIT(2) > > +static int imx_rproc_detach_pd(struct rproc *rproc); > + > struct imx_rproc { > struct device *dev; > struct regmap *regmap; > @@ -96,6 +99,10 @@ struct imx_rproc { > struct notifier_block rproc_nb; > u32 rproc_pt; /* partition id */ > u32 rsrc_id; /* resource id */ > + u32 entry; /* cpu start address */ > + int num_pd; > + struct device **pd_dev; > + struct device_link **pd_dev_link; > }; > > static const struct imx_rproc_att imx_rproc_att_imx93[] = { > @@ -335,6 +342,9 @@ static int imx_rproc_start(struct rproc *rproc) > arm_smccc_smc(IMX_SIP_RPROC, IMX_SIP_RPROC_START, 0, 0, 0, 0, 0, 0, &res); > ret = res.a0; > break; > + case IMX_RPROC_SCU_API: > + ret = imx_sc_pm_cpu_start(priv->ipc_handle, priv->rsrc_id, true, priv->entry); > + break; > default: > return -EOPNOTSUPP; > } > @@ -364,6 +374,9 @@ static int imx_rproc_stop(struct rproc *rproc) > if (res.a1) > dev_info(dev, "Not in wfi, force stopped\n"); > break; > + case IMX_RPROC_SCU_API: > + ret = imx_sc_pm_cpu_start(priv->ipc_handle, priv->rsrc_id, false, priv->entry); > + break; > default: > return -EOPNOTSUPP; > } > @@ -713,8 +726,10 @@ static void imx_rproc_put_scu(struct rproc *rproc) > if (dcfg->method != IMX_RPROC_SCU_API) > return; > > - if (imx_sc_rm_is_resource_owned(priv->ipc_handle, priv->rsrc_id)) > + if (imx_sc_rm_is_resource_owned(priv->ipc_handle, priv->rsrc_id)) { > + imx_rproc_detach_pd(rproc); > return; > + } > > imx_scu_irq_group_enable(IMX_SC_IRQ_GROUP_REBOOTED, BIT(priv->rproc_pt), false); > imx_scu_irq_unregister_notifier(&priv->rproc_nb); > @@ -736,6 +751,69 @@ static int imx_rproc_partition_notify(struct notifier_block *nb, > return 0; > } > > +static int imx_rproc_attach_pd(struct imx_rproc *priv) > +{ > + struct device *dev = priv->dev; > + int ret, i; > + > + priv->num_pd = of_count_phandle_with_args(dev->of_node, "power-domains", > + "#power-domain-cells"); > + if (priv->num_pd <= 1) What happens if we get 1 power domains? How is it handled? There should be a comment explaining what is happening here. > + return 0; > + > + priv->pd_dev = devm_kmalloc_array(dev, priv->num_pd, sizeof(*priv->pd_dev), GFP_KERNEL); > + if (!priv->pd_dev) > + return -ENOMEM; > + > + priv->pd_dev_link = devm_kmalloc_array(dev, priv->num_pd, sizeof(*priv->pd_dev_link), > + GFP_KERNEL); > + > + if (!priv->pd_dev_link) > + return -ENOMEM; > + > + for (i = 0; i < priv->num_pd; i++) { > + priv->pd_dev[i] = dev_pm_domain_attach_by_id(dev, i); > + if (IS_ERR(priv->pd_dev[i])) { > + ret = PTR_ERR(priv->pd_dev[i]); > + goto detach_pd; > + } > + > + priv->pd_dev_link[i] = device_link_add(dev, priv->pd_dev[i], DL_FLAG_STATELESS | > + DL_FLAG_PM_RUNTIME | DL_FLAG_RPM_ACTIVE); > + if (!priv->pd_dev_link[i]) { > + dev_pm_domain_detach(priv->pd_dev[i], false); > + ret = -EINVAL; > + goto detach_pd; > + } > + } > + > + return 0; > + > +detach_pd: > + while (--i >= 0) { > + device_link_del(priv->pd_dev_link[i]); > + dev_pm_domain_detach(priv->pd_dev[i], false); > + } > + > + return ret; > +} > + > +static int imx_rproc_detach_pd(struct rproc *rproc) > +{ > + struct imx_rproc *priv = rproc->priv; > + int i; > + > + if (priv->num_pd <= 1) Same here. With the above: Reviewed-by: Mathieu Poirier > + return 0; > + > + for (i = 0; i < priv->num_pd; i++) { > + device_link_del(priv->pd_dev_link[i]); > + dev_pm_domain_detach(priv->pd_dev[i], false); > + } > + > + return 0; > +} > + > static int imx_rproc_detect_mode(struct imx_rproc *priv) > { > struct regmap_config config = { .name = "imx-rproc" }; > @@ -770,8 +848,12 @@ static int imx_rproc_detect_mode(struct imx_rproc *priv) > * If Mcore resource is not owned by Acore partition, It is kicked by ROM, > * and Linux could only do IPC with Mcore and nothing else. > */ > - if (imx_sc_rm_is_resource_owned(priv->ipc_handle, priv->rsrc_id)) > - return 0; > + if (imx_sc_rm_is_resource_owned(priv->ipc_handle, priv->rsrc_id)) { > + if (of_property_read_u32(dev->of_node, "fsl,entry-address", &priv->entry)) > + return -EINVAL; > + > + return imx_rproc_attach_pd(priv); > + } > > priv->rproc->state = RPROC_DETACHED; > priv->rproc->recovery_disabled = true; > -- > 2.37.1 > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel