From patchwork Fri Jan 5 16:01:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 13512353 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 CE6BCC47079 for ; Fri, 5 Jan 2024 16:01:53 +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:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=1h7mBwpAv1GG1ygRu8D/lF8uLEt7ePGmfH1+eJ7Hxww=; b=xW9QxQFvvJFewO 6iEu+sQkk2WvPBiLFH+0qOGQVOo8lIGpKgzYL2cDq2VASRYjeoH7We2jJtj6gPuXfq+PrN+LOXlHT W+Mq3GOqBiKQEE/Tofgh7yyE6MEo6zaAdlE8XaCzSIe125zYnAxGGmvEtPQqn6V+2ppKSzjgGGIdd 7REZgBvLJrxzPzaltcV4BGQGELR/d0VpHRKpUo0y57MlZd4fejIVgCtJbJZDmK/1WrWR1ITIESG7g ojFWviO89T1v7SakfXOgsyGn5S0mK783bqUTvBUw+qkBa75/8YRdkwgaDki0Q/soQc33N1dnigyf+ x2ESE+/3VFWmqHv3iT7A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rLmdQ-00HFAX-1D; Fri, 05 Jan 2024 16:01:24 +0000 Received: from mail-lf1-x12a.google.com ([2a00:1450:4864:20::12a]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rLmdN-00HF7x-22 for linux-arm-kernel@lists.infradead.org; Fri, 05 Jan 2024 16:01:23 +0000 Received: by mail-lf1-x12a.google.com with SMTP id 2adb3069b0e04-50ea9daac4cso1963303e87.3 for ; Fri, 05 Jan 2024 08:01:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1704470478; x=1705075278; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=+xTV3KNGUOJDAGwGlyDoyXQPDYV81EgjVZP/tKxx0pk=; b=FVGuwyNzuWrZs+8nlX24vWdQf/Wh2uN78HvIQZpofxAxEyoEQGn6e8omjzTogN1NIP O0bumfvf+9R13JTemvwBXf0HXcz8JR/DvvKR/hG/PMsFmkWWwwyu87Jg11LGcoVcwlPw e7KwiUyIbJhnvkRjVVQIUYUailxO4UYpS6hFouGuQnOrHC0US8IqFIqvmPZNcB3eLdDE UQ8RdSquA6h7MW5QgBl2NbkYjZyBfajf2hXF/OZg5pmcXD1WgZp/h3+yE1dfyw9q58yE nMOxCH0uq1SZJxF8MTwWs35+bxlpV6lpGfyXYiyTjkluH/qJOiy9o6fk9ZMG3e0pBtEy MAXg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704470478; x=1705075278; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=+xTV3KNGUOJDAGwGlyDoyXQPDYV81EgjVZP/tKxx0pk=; b=BTAJT7xF/2isSCpKrpDwr3JhAyAlr0Z2hbrXqMydswF00PWG8mXSvTd3+tqols4sac 7M2A6MlfU2OBHQGC4OBwFac59lTYNf8JzBjyehUUOFgQ25XMl/Jq6F9ZVu9ryXldRJL8 +DTjCqgPXczpMzK5K4jCgUnarpBNyY8zWsXLKYd5ZlNXilMlwYm/M7eLZ12Z3BY0jidN 37iVvpF6O3OKWjC5cfKwLY/QzXftaXLqsdUovpRwPs/+xVcmS2XM6ACLkNhfiTpDhSz8 KHdc3jKzgcvDVAs1B2T5mmjVW7MjhGJKYSUSRd4+MOyKXV210ttzcuJcXSXa/HwwwIVP Aqvw== X-Gm-Message-State: AOJu0YwgTy8YrbgwURKxWb+kUJPb6pRXzm15PO68pgoIAGvwn6fd+99y yXQ9vtgCLXDFckGWc9kKy09j2ofP+dRwoQ== X-Google-Smtp-Source: AGHT+IEhceusxqe38aK6YSRaF0oSmtJx101dr5UFrhN3EnDzMmqdMwFzHk96/G1pK1okalt2N+42DA== X-Received: by 2002:a05:6512:532:b0:50e:6e9f:bc89 with SMTP id o18-20020a056512053200b0050e6e9fbc89mr1038688lfc.104.1704470477717; Fri, 05 Jan 2024 08:01:17 -0800 (PST) Received: from uffe-tuxpro14.. (h-178-174-189-39.A498.priv.bahnhof.se. [178.174.189.39]) by smtp.gmail.com with ESMTPSA id n5-20020a056512310500b0050e76978861sm262094lfb.277.2024.01.05.08.01.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Jan 2024 08:01:15 -0800 (PST) From: Ulf Hansson To: "Rafael J . Wysocki" , Greg Kroah-Hartman , Viresh Kumar , linux-pm@vger.kernel.org Cc: Ulf Hansson , 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, Mathieu Poirier , Shawn Guo , Sascha Hauer , Iuliana Prodan , Daniel Baluta Subject: [PATCH v2 3/5] remoteproc: imx_rproc: Convert to dev_pm_domain_attach|detach_list() Date: Fri, 5 Jan 2024 17:01:01 +0100 Message-Id: <20240105160103.183092-4-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240105160103.183092-1-ulf.hansson@linaro.org> References: <20240105160103.183092-1-ulf.hansson@linaro.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240105_080121_669857_80D12242 X-CRM114-Status: GOOD ( 21.42 ) 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: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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: Iuliana Prodan Cc: Daniel Baluta Cc: Signed-off-by: Ulf Hansson Tested-by: Iuliana Prodan Reviewed-by: Iuliana Prodan Reviewed-by: Mathieu Poirier --- Changes in v2: - None. Iuliana/Daniel I am ccing you to request help with test/review of this change. Note that, you will need patch 1/5 in the series too, to be able to test this. Kind regards 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; - - 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)