Received: by 2002:a05:7412:b995:b0:f9:9502:5bb8 with SMTP id it21csp3893147rdb; Thu, 28 Dec 2023 03:43:14 -0800 (PST) X-Google-Smtp-Source: AGHT+IFA/zvLpirrmVskcoIcM4Sr6IOwbHM7LjdVtFcIYhvSfBAsMFhMUJRLJ+28fPplSwAS7tTq X-Received: by 2002:a17:906:142:b0:a27:6560:a21b with SMTP id 2-20020a170906014200b00a276560a21bmr517737ejh.63.1703763794682; Thu, 28 Dec 2023 03:43:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703763794; cv=none; d=google.com; s=arc-20160816; b=AFU/GzJ4G9ZLwTOT9fhquwZrwQaImfXwEL2AdrMDoU2NpIXom96gHLjZZczcTK+7N9 HTred4h/BIqL/VhSDbVjajtG6pbJbZFNeDGxEO8/Ij/sAmrnX0KXHJgv7e+I1KcubDGX CHkq0uYUxzigwaPg298FSP0IT4jDKRj+1VI2zqPGpbb3gwSKXyEY41DsWe79Q1NLvFSc kxuooXyz5tB+nd8kKQ0gzXegoGgtV4NuF6m/A0DWJujao/XBk6toBaBmg7ZahhZPVO0d FUZLCv8fNonxwiliO2r0zn8f/KJuq0dw8n1Jyyf7+idPRxU7w1RleQ/NHO98H3c1rIEj vwpQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=hHvHY3P8pUAm5EVfyC69y/g7bbhD/gOrqJUHaYKsX0I=; fh=dVwMBI1feONzgU32qeNvRjj9mtY0XdBxodmYfv9SX3U=; b=rxlBU/NbXoUlx1pI1g/2gpNZ7rBS/jtxt61Ewj7MNulsCG9OhTOgWyXehSqpSejas3 XVssKVE8beuT/9eNRHtMD1QLfe4xTC7DWiB+ZpXbj57g/43lbKMRseGApyczazHyCSW4 V8oME8dutlHsMvmriVD3pCTxAkoHD92QBxgSkM6eoA7w92umtJEgbNP/SXmXY62xG7nE +BkVoVoAxKcAfPSKdhwRqdgfF4DC+O/6TjXUCPek5j2zqWGeXuN9Zw9ppxzO3nyUmA5L L8cXQnsTSvMTuTgDQHjzncm1jI6p/HljGYRDw6oD8JylN5xCwuXaAf/2VTPPWMP6kRro C/vw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=vDtxXkeM; spf=pass (google.com: domain of linux-kernel+bounces-12621-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-12621-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id r26-20020a1709067fda00b00a2357304edesi6709283ejs.770.2023.12.28.03.43.14 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Dec 2023 03:43:14 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-12621-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=vDtxXkeM; spf=pass (google.com: domain of linux-kernel+bounces-12621-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-12621-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 am.mirrors.kernel.org (Postfix) with ESMTPS id 487CA1F2132C for ; Thu, 28 Dec 2023 11:43:14 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0EAA8D2FC; Thu, 28 Dec 2023 11:42:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="vDtxXkeM" X-Original-To: linux-kernel@vger.kernel.org Received: from mail-lj1-f180.google.com (mail-lj1-f180.google.com [209.85.208.180]) (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 9FD9F6FC3 for ; Thu, 28 Dec 2023 11:42:15 +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-lj1-f180.google.com with SMTP id 38308e7fff4ca-2cce70ad1a3so3736961fa.1 for ; Thu, 28 Dec 2023 03:42:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1703763734; x=1704368534; darn=vger.kernel.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=hHvHY3P8pUAm5EVfyC69y/g7bbhD/gOrqJUHaYKsX0I=; b=vDtxXkeM6G5INBnIN53aewNY2fXi7XQXwZawqxTkxiiNr4Sj+AYPdqLJzHbSNE67Za rrfOLSkXLcG+RpPVSMhdbQ/z0tNMI44cy15G7XyL9JPEtHtWdFQTY5eokgq+n91Mv0dI OYQhg4vBnSgsbrTEPrOYKOGorC+revEhQtxZ4wV62ZX6Y1H6vZQiJwjFwMabRoofdhqD A1XgqOK2UZliyiX2Qg/mi+arFRLQoqh5vrHBsUvjz84RdNUyuSTT8BTGc7irATK0eIKP M6nvZDfwlJJ5GkRmBjX03extN1coVqYSJWuMxu7qShqwqbpwskrbHPoDkmKYpGayS9JX RROA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703763734; x=1704368534; 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=hHvHY3P8pUAm5EVfyC69y/g7bbhD/gOrqJUHaYKsX0I=; b=RLHEMOjeaeq2rfBKMOjvsJHGdxVvzDFN2BehDAklKNLvLvGeSKlRjVDgrBTHMksQ3w 5uv5fJm6dnBvXTR6Uea57pQ84GE/ZUtwsPjtgGKpOfPWihi1Zdo6jvBnpg2Ar0OV2M++ 6wGbaHM7S6PhNiyBeHAh4T/46HV7xXJLz2Sxd17P3YnZqGEtbAmWYEWu8Dpzi3g6nhY1 ABVMt72wqZmbECYS5u9+WoqS/589YGTdFG3YAimzZ3JMaORE44cRXybM+OiE67+1O5nf 8VG+qEe0AQ7WQ19p23DBWG8YOYel5mfYoh2GLk8gWDZAgqWg/CqOwa+NP+mtxbqaqILY YVQw== X-Gm-Message-State: AOJu0YwOxjN+B0geGeRHuoIbR2qrr0TqkPcskuzsfzvjI79UcinTqQue Pgc2t1qApLAPd0Ovuv4wug0HtF0zjkVxSw== X-Received: by 2002:a05:651c:486:b0:2cc:3fb2:82c with SMTP id s6-20020a05651c048600b002cc3fb2082cmr3350929ljc.75.1703763733742; Thu, 28 Dec 2023 03:42:13 -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 a4-20020a05651c210400b002cc32fbe2e5sm2792867ljq.51.2023.12.28.03.42.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Dec 2023 03:42:12 -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 Subject: [PATCH 3/5] remoteproc: imx_rproc: Convert to dev_pm_domain_attach|detach_list() Date: Thu, 28 Dec 2023 12:41:55 +0100 Message-Id: <20231228114157.104822-4-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231228114157.104822-1-ulf.hansson@linaro.org> References: <20231228114157.104822-1-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-Transfer-Encoding: 8bit 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; - - 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