Received: by 2002:a05:7412:5112:b0:fa:6e18:a558 with SMTP id fm18csp63934rdb; Mon, 22 Jan 2024 12:02:34 -0800 (PST) X-Google-Smtp-Source: AGHT+IFXy37MWZEIFRzwcKLWkXQGgBqUAqhp5oJkvuZimluCGKLV2cOfSd2Uhix9Txcq5RcFu1i3 X-Received: by 2002:a05:620a:29c1:b0:783:a2a8:33dd with SMTP id s1-20020a05620a29c100b00783a2a833ddmr1463239qkp.80.1705953754588; Mon, 22 Jan 2024 12:02:34 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1705953754; cv=pass; d=google.com; s=arc-20160816; b=04HJyyCza5tgd5dwDiC2t0C4llDazQ14n5wVHS5nYX88zLWMK9FKfxqMnB39oCaAFr pEK04CnOa4G8WNACDDdzNW1knpeYuvNPztn9qQUoNQAYNN02xg8c00sFsqU/V9Axkc0a P7CC14alMdQ2/EgUQHs1h80p78VlickPhhmw2+NXN+75xVYjhFU5fe7uXqGDwpleUjJm p/Xkeb+8/2PhhFpmIs3++RGUEFZ+KZrO2UnOi5sEtZD5e2jDWLSoOrV/SNUfjbhhFSlg kXjqxLcXosI4sBfcvOSYBptMvGSnYVifiuyX0ZdGQVwfQpuYu0erkG+/D34m1FGt/pyD Q21A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :dkim-signature; bh=S9XdGfwCaFqRS40nSS7oXOASpHTiWciWWg6+rB3mocA=; fh=y/gfZPsuMyBTp2mLS33m2xjy/LQjLW7gdNtmaT0RqTE=; b=Oq6TsZORe7lHrP5wnFvbGafBw6vYKc6Cek3zbkSvpE9JWBJ9hhOfpRtu7wcApxBGHL ImDCx30/0wM9SBU1XGi1iDJvlS0sYqUAnWifZr13ajsgx5apdTJIX8B9JJgrFH+he0fu mQSWjofsRH7VYWckxq34hC2ufBaCkfrNR8pPuZJ6cyPUGkXTiRCuu0cIE1W1S2gJU5mU 4YlvExnCrvP0DTf9MwYEOYBptkv/lFFfmfkK321JmJlal4wuB0C8rnUKpZqgtkRBySNV uYvSXxpa5CDAgW6C7oF4VoNVkUBYMGQ/bGoD10BJ+HkRHp6IZtTgFENQsHZVaoUWgmoZ O/Hg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=elCw2513; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-kernel+bounces-34098-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-34098-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id s11-20020a05620a254b00b0078314abc23dsi6856569qko.478.2024.01.22.12.02.34 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Jan 2024 12:02:34 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-34098-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=elCw2513; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-kernel+bounces-34098-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-34098-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 4AC151C2429F for ; Mon, 22 Jan 2024 20:02:34 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1EF6E405EE; Mon, 22 Jan 2024 20:02:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="elCw2513" Received: from mail-wr1-f54.google.com (mail-wr1-f54.google.com [209.85.221.54]) (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 6CD12405C0 for ; Mon, 22 Jan 2024 20:02:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.54 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705953743; cv=none; b=QJM9MBfs3Ob3rYeRx8SFcWbvqSljn9u0lawdSuScpopKW3GWgFMDpA0CPcIbvhENhEiXWZKzbPWsRzHRZrQ2P65t2P1kMTZp7n4RPMUl3LrHmbbFh3C5ess+xoiq0uPks10fkMs0DD2oioXcrwDF1TS6rZ0MnLMqHVR9N6F82wc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705953743; c=relaxed/simple; bh=VdkhAorzBPaH/4Q+W05lpm+qjGuxdMhhs5V7dPnuTyo=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=f2jqwSqtA1oL8xzoeSXVAKZ8yWXmrPXjZ1vmY99V+jaZONljWl+gVeMoatg/km+LgmWvvseiMGuIBABBVy7HBpErbIXkjsmp/aRGfuIr+x70x9/5BIEAQUWjkIczMozPWXrWWbBym7dmmdevigsaOrIYUHq5UaELuweGtQWry/Y= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=elCw2513; arc=none smtp.client-ip=209.85.221.54 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-wr1-f54.google.com with SMTP id ffacd0b85a97d-339261a6ec2so2103666f8f.0 for ; Mon, 22 Jan 2024 12:02:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1705953739; x=1706558539; darn=vger.kernel.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=S9XdGfwCaFqRS40nSS7oXOASpHTiWciWWg6+rB3mocA=; b=elCw25134BVwV6RfN8JXNOtKbmsUpYd9YOysB48fI+PXuloobbPgxSM/0B2C2aKpt9 4LMN2D99w+NSPQ15mVlRQ4L+M1mz8FbFLmBELaBXgsUXnGmb+OQmrKB1tx1fhtUmu8/n 6awumyw2WUuhsfW3OfTP+ZMEo//RzIwRiDw/lXxecpMsxNjrdUc0r22ZcOz4BVcWs4lf ALrgNZ9b7qbzZjOWA3zOM0kYjLKHNEu7Q6t7pTM+3gBkseXgdhetnRmgtdGdseVZF+C1 K2YvF3du/hSW/FHbyaorOFTUcfnkbcjHV2zAkvC5QpYX2jjO6hAUb7ip5v3jc2jdYevt 94BQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705953739; x=1706558539; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=S9XdGfwCaFqRS40nSS7oXOASpHTiWciWWg6+rB3mocA=; b=j2LmrYP27kVhnhQKPiM1VRuBa9efUqf5ttretgfmTAn51qeQ8pLN2kcR9mFDzHb6uq Ip0jv2idzWqyiMDrdqoGBpbrrvjoA3V5kNR0suEsY4N5UN921C+N3UggqdrDh27CbCzu VQ08+Q/q4K++wKPzag6VLGPcXllhIuFAhJPkZ+1G9qi2BnvgzssJ3XSiraDVXA5BEB2b WhkP1xgis2uXjCmCWypG3bsHkqteaih+hdcJkBh6Ce8oAqkTtNtebWbWbtg9DxJAR/UL Nb3N0pDbrSILIStkW5JT46SssH6OZHFkxz/UH9p/4Pa269Xge6+CJKOazqUwXWybq8dN gQFQ== X-Gm-Message-State: AOJu0YymRRQIAfFXh32vCbyqmVMEIl6Gfc+NLiHQHzetE2TYAGMwnELK OnTEk2B2DW/bCpL/KWmbz6uDxgXxusTXUxlv/SroRwBQxFfzFo3PEmFg15Km34VoGlJsO0zz1RM aQf+QNpkEjCbAwrxeWXLTRpIWR4NDCb4iorAC+Q== X-Received: by 2002:adf:e68b:0:b0:337:6e32:1811 with SMTP id r11-20020adfe68b000000b003376e321811mr2954342wrm.75.1705953739678; Mon, 22 Jan 2024 12:02:19 -0800 (PST) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240105160103.183092-1-ulf.hansson@linaro.org> <20240105160103.183092-4-ulf.hansson@linaro.org> <87801f3e-b7ce-46ba-9856-1321635a11b5@nxp.com> In-Reply-To: <87801f3e-b7ce-46ba-9856-1321635a11b5@nxp.com> From: Mathieu Poirier Date: Mon, 22 Jan 2024 13:02:08 -0700 Message-ID: Subject: Re: [PATCH v2 3/5] remoteproc: imx_rproc: Convert to dev_pm_domain_attach|detach_list() To: Iuliana Prodan Cc: Ulf Hansson , "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 , Daniel Baluta Content-Type: text/plain; charset="UTF-8" On Mon, 22 Jan 2024 at 10:51, Iuliana Prodan wrote: > > On 1/5/2024 6:01 PM, 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: Iuliana Prodan > > Cc: Daniel Baluta > > Cc: > > Signed-off-by: Ulf Hansson > > --- > > > > 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 > > Tested-by: Iuliana Prodan > Reviewed-by: Iuliana Prodan > Thanks for the leg-work on this. I'll pick this up in rc1 later this week. > Iulia > > > --- > > 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)