Received: by 2002:a05:7412:b995:b0:f9:9502:5bb8 with SMTP id it21csp6714182rdb; Tue, 2 Jan 2024 10:41:51 -0800 (PST) X-Google-Smtp-Source: AGHT+IFaBXUmxBblAoo7krBz7pIfQIzHJNvlyQByK1/pn0dhcJYfOfwWeD/UKjgNYiiet+5bpSYX X-Received: by 2002:a05:6a00:2d8f:b0:6d9:b324:8140 with SMTP id fb15-20020a056a002d8f00b006d9b3248140mr16474027pfb.13.1704220911507; Tue, 02 Jan 2024 10:41:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704220911; cv=none; d=google.com; s=arc-20160816; b=JkNqbfzwOnDPUwBO3I8DLJ0crWkE+nJxMffJLQFGUw4NUP/BTgwtf7NDrvNsCtpmKt niRnibUv8ieptM1kZvujaQmcy2sEvtqWksluMc80quD2MElAGKdi4HBkQ8Q89TUbDcL1 6x+qmPjViqqob6gxKEDYf/qI8SjGdSYmzAi7OD1Rg7a+Tzq0WYQvHHnya7EIhh0ekvok EHFBuPOondjXhn/V4DKS7ub8hUVSO8ra4sgtAAJxScmwG75ifzX0jnVSwfR69p3bC0IT KnwSC5l58gpNBwo4NbW2/6CulPr053Z4GmBpjeKkoLOebq2My23zBettz0qUco7o1H3B n2VA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=eiARnTFtPVzqukdZN0RA3ZaMhVEbsu3YcZKj4/r2OWM=; fh=svKNWFYJxh2u6ZkK+RnMI40U+f7zS4sXpFU4I/ek8Cw=; b=u0e/d/3pgQd7zKBY9dUKjHGSRv3gjJHO7VM98MIfWGdjjmNTiS+35Hb8xQE1PW81A/ rkfNmWuMF3rWh/7TmxQwNjQHamOGyTSNHZZcrGYKvRIQ/haqUjcXKw+37Nt6jFeqmYoU XtSoSEhGzvWbeAJn+SUag4hKReR8bop2lhhw4PC9lXr3sJsNZyIBGse4HJF5zbJribRP I4SPnsEykkqthiNSVtFWIkhIIrj6iR3nlc3tyjGWya7VC955J6NOY18HPdwoYREE6HT9 ZBol3eW0sWRznTss8oZruEi0XioBRP3tjpxgkvVDmZYjkCnU6CjpKDLDmqPPhlNQPUfg URMw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=EauHZchQ; spf=pass (google.com: domain of linux-kernel+bounces-14724-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-14724-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id k206-20020a6284d7000000b006d9bf6f20efsi13672625pfd.170.2024.01.02.10.41.51 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Jan 2024 10:41:51 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-14724-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=EauHZchQ; spf=pass (google.com: domain of linux-kernel+bounces-14724-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-14724-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 2206E2816CE for ; Tue, 2 Jan 2024 18:41:51 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id EF66F15AD4; Tue, 2 Jan 2024 18:41:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="EauHZchQ" X-Original-To: linux-kernel@vger.kernel.org Received: from mail-pg1-f178.google.com (mail-pg1-f178.google.com [209.85.215.178]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CA81815ACE for ; Tue, 2 Jan 2024 18:41:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Received: by mail-pg1-f178.google.com with SMTP id 41be03b00d2f7-5cdfa676fa3so4919696a12.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=vger.kernel.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=EauHZchQ0zMMRkkZdcBgYGFCEznbC69X2G2LdTUDks7TsYM9yAr+tqcvqGwvVFVbhl BzkhUnV01k4po1ypcQk+9nrx2sSr3hpj0ytO2YwQKqlFn3jrheG7e4NvfYlcbMdEXFfi 4VsdXlshpk1df8NsXRMvV6pkMQxDVrZhyp/BLX1+RFUamM7cOld35wJ5fBzFKf/wu9gU WcuALcZF5K9EjTcvXKuI/YOlmFxVRld8x4yuZa1LAMmT4RBhgPj51MRA058M2Q6dZf49 rkJfyVYRNCJ8HyB7cWHZzN4EOHtYOViBn7VC4GOQbffZLxUPWxHfrVZRTIQZwCM6a1Qd 5z0A== 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=m9NpH7AVp11C1mbjQ3hA2UOVbCWxPhsujYmEAi+K8TxIVVh8qlpGVLfdfvUztQ+6om QV4DUjTudEk5IR5EFSqG0sznM6mMy2M9MqzMAVqOZcCZke6BvvHo4h8WAh7GkfAWG+k4 13lWk18CrUwRWqMBLxKqBRMzDRwZObuJmSh6o6Tbojk1HGa/TnCV/eb99cUAPNvQqjz6 zlHieYBj+mUGlrF7c0lVomi6IzvKx/lXa0dpjZrxT66LGqWjkdhKxjll7nwuFCxcgctO 6eC1zf5almGF6uUs8h3+YTURJPVNDNhZh5FLskPGxSJa7NlxsBh8BxO7Xv48+d1kPDh3 Tw4w== X-Gm-Message-State: AOJu0YzbEK875lkiGlduEN//HOmTCKUMIjDpSxLhk4uKpAi7l5hc+yWA xJKr57DDyj3T+5Anj6DZ5xCIEd0dmv2N1w== 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> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20231228114157.104822-4-ulf.hansson@linaro.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 >