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 93C9BC46CD2 for ; Tue, 2 Jan 2024 18:42:14 +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=PBLLQwDsxTRq7xuKLQfMrIJWQhfsDeiQR9/FdifDPGs=; b=0wXBd71pyRUJUz yvdkySwAQJnj1KbPQYkZcQfrjFb5hk8dmLYu3JFpZPoPtDhCdFB32M7zcX2189LzXvBgtkieFnqHA 9IDzV1awUc8CzT7ire5toM5qh0LYBjSmy5q2hqZn9eiP7zSMbZkKBv0AMYUswediQzgSz3PuHDAUr 8OxpexBFmXYOr24y6EmjWrM4nrMmVGNNsBkXspT2C3tWP2B0KcWErNx0xb1094QX4tjTv15hYhl+I v3UpyLzQwbuakuFiiDSTNOY9t4KrKkGYBVziRzeyPV/NaqHyvs+NjVlYjO9RFkp1BJL0z8QyxnBWM 5tfHjv/pjTq93ErxIzMg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rKjhz-008kSG-1q; Tue, 02 Jan 2024 18:41:47 +0000 Received: from mail-pg1-x534.google.com ([2607:f8b0:4864:20::534]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rKjhw-008kRt-1c for linux-arm-kernel@lists.infradead.org; Tue, 02 Jan 2024 18:41:46 +0000 Received: by mail-pg1-x534.google.com with SMTP id 41be03b00d2f7-5ce10b5ee01so4062504a12.1 for ; Tue, 02 Jan 2024 10:41:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1704220902; x=1704825702; darn=lists.infradead.org; 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=eiARnTFtPVzqukdZN0RA3ZaMhVEbsu3YcZKj4/r2OWM=; b=Nqht6nolthxOs7V3q91HHdYxUyj+sSvBkI5YYvHBdp9Cs5SdC8WL1q5opl9w/X+uJF ZU1uk67v5GBZjT+yUJGOVGwSqAMdyIoUVO7/bxWgNTfnb3imTeh0o+/fR/seugi15xwJ 6KS7sBOMjhA0lvde5U9IgNiqb9O8CE5p3wDu7x+OWN8w7I3LUoMqX889I3Pgg2Mnunvv Qw6I0/X/TBBUIMDD5dSaeSVCJjiF0jnZ20B7J0m9G2Wr4Ce8RIjKCRjQg/aBuocPks5Z T5dw96LxSIZW9v6tJC2mfyhLchPRTTtMRsWtN1awFVf7VZPRRfHBqpp2ezNk15wYZB+E jw5w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704220902; x=1704825702; 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=eiARnTFtPVzqukdZN0RA3ZaMhVEbsu3YcZKj4/r2OWM=; b=eUCAfqaklgk6UolWjPCHsZ9WEbCL8lKmBWkTFYgUElPh4NLAB6nUPpd/8Y5EESy+yU +PFymKUOfkryBLCN1eXDzlF4JE+QntY+sXbneBi0Pxa5wxdn1mrlbaUQGpeJ2bqoJm3D ILHeVCv15dwripaHqLekdjxVzgxUXfg2X393TK0FUtxnRF+lwCjLa0oX6fFy3GKXE1Js HadADBIHtzXL7olm8VtR2eAY80NF40B7ysA5OC5xnajnzhkckh5bPmJTqKJbn6z24Btd NSyRqUD4PP+lB/ezUP0Sx84KXZ/1QAXj0R9h/TQh1Dhup7sJqBRyhAxOf1L+tqbHFg5Q 7nPQ== X-Gm-Message-State: AOJu0Yz14Yo8jlxMrze1qDQZyQVjjyrA/qc8+ql8Y5bdB/gpy4NeYaUO oh+9iWKawVEkfzqUEc3J4uULMVFvYXrIjw== X-Google-Smtp-Source: AGHT+IHEm6VtNk0s0JFbJROhAiFMpiK1QaSuMZvJp6MECY5QfyLekDrejEAVN4oBbY22Qy7TBjoGxw== X-Received: by 2002:a05:6a20:7d83:b0:196:c73c:2eaf with SMTP id v3-20020a056a207d8300b00196c73c2eafmr4392439pzj.44.1704220902150; Tue, 02 Jan 2024 10:41:42 -0800 (PST) Received: from p14s ([2604:3d09:148c:c800:2dba:4fab:fb9:7d99]) by smtp.gmail.com with ESMTPSA id z188-20020a6265c5000000b006d095553f2asm22388197pfb.81.2024.01.02.10.41.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Jan 2024 10:41:41 -0800 (PST) Date: Tue, 2 Jan 2024 11:41:38 -0700 From: Mathieu Poirier To: Ulf Hansson Cc: "Rafael J . Wysocki" , Greg Kroah-Hartman , Viresh Kumar , linux-pm@vger.kernel.org, Sudeep Holla , Kevin Hilman , Konrad Dybcio , Bjorn Andersson , Nikunj Kela , Prasad Sodagudi , Stephan Gerhold , Ben Horgan , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-remoteproc@vger.kernel.org, linux-media@vger.kernel.org, Shawn Guo , Sascha Hauer Subject: Re: [PATCH 3/5] remoteproc: imx_rproc: Convert to dev_pm_domain_attach|detach_list() Message-ID: References: <20231228114157.104822-1-ulf.hansson@linaro.org> <20231228114157.104822-4-ulf.hansson@linaro.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20231228114157.104822-4-ulf.hansson@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240102_104144_570704_6D2EEF52 X-CRM114-Status: GOOD ( 31.34 ) 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 Hi Ulf, I'm in agreement with the modifications done to imx_rproc.c and imx_dsp_rproc.c. There is one thing I am ambivalent on, please see below. On Thu, Dec 28, 2023 at 12:41:55PM +0100, Ulf Hansson wrote: > Let's avoid the boilerplate code to manage the multiple PM domain case, by > converting into using dev_pm_domain_attach|detach_list(). > > Cc: Mathieu Poirier > Cc: Bjorn Andersson > Cc: Shawn Guo > Cc: Sascha Hauer > Cc: > Signed-off-by: Ulf Hansson > --- > drivers/remoteproc/imx_rproc.c | 73 +++++----------------------------- > 1 file changed, 9 insertions(+), 64 deletions(-) > > diff --git a/drivers/remoteproc/imx_rproc.c b/drivers/remoteproc/imx_rproc.c > index 8bb293b9f327..3161f14442bc 100644 > --- a/drivers/remoteproc/imx_rproc.c > +++ b/drivers/remoteproc/imx_rproc.c > @@ -92,7 +92,6 @@ struct imx_rproc_mem { > > static int imx_rproc_xtr_mbox_init(struct rproc *rproc); > static void imx_rproc_free_mbox(struct rproc *rproc); > -static int imx_rproc_detach_pd(struct rproc *rproc); > > struct imx_rproc { > struct device *dev; > @@ -113,10 +112,8 @@ struct imx_rproc { > u32 rproc_pt; /* partition id */ > u32 rsrc_id; /* resource id */ > u32 entry; /* cpu start address */ > - int num_pd; > u32 core_index; > - struct device **pd_dev; > - struct device_link **pd_dev_link; > + struct dev_pm_domain_list *pd_list; > }; > > static const struct imx_rproc_att imx_rproc_att_imx93[] = { > @@ -853,7 +850,7 @@ static void imx_rproc_put_scu(struct rproc *rproc) > return; > > if (imx_sc_rm_is_resource_owned(priv->ipc_handle, priv->rsrc_id)) { > - imx_rproc_detach_pd(rproc); > + dev_pm_domain_detach_list(priv->pd_list); > return; > } > > @@ -880,72 +877,20 @@ static int imx_rproc_partition_notify(struct notifier_block *nb, > static int imx_rproc_attach_pd(struct imx_rproc *priv) > { > struct device *dev = priv->dev; > - int ret, i; > - > - /* > - * If there is only one power-domain entry, the platform driver framework > - * will handle it, no need handle it in this driver. > - */ > - priv->num_pd = of_count_phandle_with_args(dev->of_node, "power-domains", > - "#power-domain-cells"); > - if (priv->num_pd <= 1) > - return 0; In function dev_pm_domain_attach_list(), this condition is "<= 0" rather than "<= 1". As such the association between the device and power domain will be done twice when there is a single power domain, i.e once by the core and once in dev_pm_domain_attach_list(). I am assuming the runtime PM subsystem is smart enough to deal with this kind of situation but would like a confirmation. Thanks, Mathieu > - > - 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; > + int ret; > + struct dev_pm_domain_attach_data pd_data = { > + .pd_flags = PD_FLAG_DEV_LINK_ON, > + }; > > /* > * If there is only one power-domain entry, the platform driver framework > * will handle it, no need handle it in this driver. > */ > - if (priv->num_pd <= 1) > + if (dev->pm_domain) > 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; > + ret = dev_pm_domain_attach_list(dev, &pd_data, &priv->pd_list); > + return ret < 0 ? ret : 0; > } > > static int imx_rproc_detect_mode(struct imx_rproc *priv) > -- > 2.34.1 > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel