Received: by 2002:ab2:6f44:0:b0:1fd:c486:4f03 with SMTP id l4csp64692lqq; Wed, 12 Jun 2024 17:05:19 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUy5HM/Xjgfw8HcIfOeCVEZE9WtL/TIm2hEI9NMMttWHitMeyVlddHYG82YtYXRiFh3zrnVVEs1OvDXPZnMUl64rUQtB1Eoa+/FrB6n0A== X-Google-Smtp-Source: AGHT+IEoiewL1hvU9HkivLVtHRnGbL8cVg6FLPMK7S72Mgccj19D+7/M0f8IYoorC+myHcKO3lt/ X-Received: by 2002:a05:6a20:432a:b0:1b6:dc09:45b8 with SMTP id adf61e73a8af0-1b8a9b1ea87mr4132861637.2.1718237119153; Wed, 12 Jun 2024 17:05:19 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1718237119; cv=pass; d=google.com; s=arc-20160816; b=gQM7IXOO0SErNkLiZKGAsdh0GUwhrVY4vgaNR7v1vXB2KNwriX2Dy0oDeOw2wKP6Wb 1MiXOajO6O7CMvtFaugqpU7A4OMZA0Wp99RE4NbxxiEeeZ1harHutVBmi/3CqjFdonUz 7NxMAFFSw3x9mUoTm5DiHOmg2bE386CjhyEhVedU6sB71THcyLWIL6073UMg8S2AQ3xv OipevZ+jMBkfmYPBq7ZKSFzQlKDm9VxO67p07k0seYq2d+cv1GrKvaLZR1iHaX4wiV/i qDQT+gvgbA+NIoHPE/DNKk5PRTSvcVqkBJWb6j/pz2mRbj+wEb6Wrl2Ww3H+QWNtX/ip E5UQ== ARC-Message-Signature: i=2; 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=GuuGoKbBVYMVCGVBVEzBXW9G4rKMMeCjB3+3ptWkUto=; fh=AhWRPgeLno6n3nNEqS5PgwIIzfewJYGyVMHWHcMTaKc=; b=JXKR7X6R8+pWGGE9WxsT0w9vojejGTLmgJsykj44ZuJ2phsBy7ah0sbUDmz+ZXjfNc hf4O7nbPlHQVPJ3jPsLnL6SfGCGMahy3/OkCp2pxBftDM2qq6q4h6CbVOL8BkI2YV+sw I+q6ENtZGPshz1PXszcfSphUb+VERVps5l9xo4kGjwmkVhNNRAJQJgpEv3SGCrMtochV dLQmkAkkXv+hLXlNFQWQi2RI8csPSdSSuf2ZwTHWaC+1a67BqsXwlUjUuXZ7iuKxmdiL Q5d0PJpW5f0qtLA+bmZRE/3vrFXu6ZP01NAZWQQOBAtNTwtpwLrJ5Baj68F1rwmQoQP8 ftWw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=VGWO3s68; arc=pass (i=1 spf=pass spfdomain=collabora.com dkim=pass dkdomain=collabora.com dmarc=pass fromdomain=collabora.com); spf=pass (google.com: domain of linux-kernel+bounces-212392-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-212392-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id 98e67ed59e1d1-2c4a75f3f28si2453876a91.42.2024.06.12.17.05.18 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Jun 2024 17:05:19 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-212392-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=VGWO3s68; arc=pass (i=1 spf=pass spfdomain=collabora.com dkim=pass dkdomain=collabora.com dmarc=pass fromdomain=collabora.com); spf=pass (google.com: domain of linux-kernel+bounces-212392-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-212392-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com 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 B288828328F for ; Thu, 13 Jun 2024 00:05:18 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D7782811; Thu, 13 Jun 2024 00:05:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b="VGWO3s68" Received: from madrid.collaboradmins.com (madrid.collaboradmins.com [46.235.227.194]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 43796633; Thu, 13 Jun 2024 00:05:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=46.235.227.194 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718237106; cv=none; b=QTKvLz4Srh+l1sfAxgiS2R71T1cDP103a4d09fCouJMhWN+eXfuF9GH4Onkam/GDAEBFi1k51GP2TdEF7acv0a5y926TWzDNqKGaT35wIK/mVPdRwqGelJwWWE8RffjXUvg7UzWxTeKGEzTIBKL5JQsWG3JTeVeseJk2VWsGyKs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718237106; c=relaxed/simple; bh=EgNRkgtKSQMKcbGvUe+V6oqG4AaVX1eRRYE+mhCHvzc=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=MPDODq0CGBKrk4yGFbS5Qxxo4M8C1zc1E5BHKdC4f//8ejakAMk29VkaUxmCAPnTXoxoQE5gqvVQm7zeGllaLgu3gsGXTP5nnNX09VrU2iyDc/+pCCdV5NHHRDKWeKDepPCbf/5g5zHEd+v9S2An2PZy1QBoa9PxlGLYgzECGcc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=collabora.com; spf=pass smtp.mailfrom=collabora.com; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b=VGWO3s68; arc=none smtp.client-ip=46.235.227.194 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=collabora.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=collabora.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1718237103; bh=EgNRkgtKSQMKcbGvUe+V6oqG4AaVX1eRRYE+mhCHvzc=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=VGWO3s68lz90z2VBw1rqhyNBsljHnWPPD4vU+WhwzTWyTxa+7Vg6Q6Wp1t/FtYZlw 4g7qz3BIkNmGZ0GGWTo2U9U1ukx6L1bp60KaPD++3hbjnJyOUQgiDTkx0JFsmvm79q nWuCe/X7rOXxkwnfprLajkmBn+5YrG5jQ/PZccuPgf2XzIp4fyALbJ+FjcwrpSLjTg bwvARlbxf2ouUdMzLvASzTh7IM5cR6GcjQPgNI9vU2L/K0YRsFYGsSE6dAeNcEwGrk gtpWxmnztR7mK2uSjufE0qtb9Qtipyaqn+gMlj7XHdz1ndQhje3pPcYzVT8N0dU9et sM9g7S/FP4AJA== Received: from mercury (cola.collaboradmins.com [195.201.22.229]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) (Authenticated sender: sre) by madrid.collaboradmins.com (Postfix) with ESMTPSA id 1B7FA3782172; Thu, 13 Jun 2024 00:05:03 +0000 (UTC) Received: by mercury (Postfix, from userid 1000) id 8B55A10608F7; Thu, 13 Jun 2024 02:05:02 +0200 (CEST) Date: Thu, 13 Jun 2024 02:05:02 +0200 From: Sebastian Reichel To: Tomeu Vizoso Cc: Joerg Roedel , Will Deacon , Robin Murphy , Heiko Stuebner , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Oded Gabbay , Tomeu Vizoso , David Airlie , Daniel Vetter , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , Philipp Zabel , Sumit Semwal , Christian =?utf-8?B?S8O2bmln?= , iommu@lists.linux.dev, linux-arm-kernel@lists.infradead.org, linux-rockchip@lists.infradead.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-media@vger.kernel.org, linaro-mm-sig@lists.linaro.org Subject: Re: [PATCH 2/9] iommu/rockchip: Attach multiple power domains Message-ID: References: <20240612-6-10-rocket-v1-0-060e48eea250@tomeuvizoso.net> <20240612-6-10-rocket-v1-2-060e48eea250@tomeuvizoso.net> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="klltttveuxmaguyk" Content-Disposition: inline In-Reply-To: <20240612-6-10-rocket-v1-2-060e48eea250@tomeuvizoso.net> --klltttveuxmaguyk Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Hi, On Wed, Jun 12, 2024 at 03:52:55PM GMT, Tomeu Vizoso wrote: > IOMMUs with multiple base addresses can also have multiple power > domains. >=20 > The base framework only takes care of a single power domain, as some > devices will need for these power domains to be powered on in a specific > order. >=20 > Use a helper function to stablish links in the order in which they are > in the DT. >=20 > This is needed by the IOMMU used by the NPU in the RK3588. >=20 > Signed-off-by: Tomeu Vizoso > --- To me it looks like this is multiple IOMMUs, which should each get their own node. I don't see a good reason for merging these together. I will still review this assuming there is one. That would require to first of all update the DT binding: Documentation/devicetree/bindings/iommu/rockchip,iommu.yaml 1. It does not allow using "power-domain-names" property 2. It limits the number of allowed power-domains to 1 3. It limits the number of allowed base addresses to 2 Looking at the DT patch you also add more interrupts and clocks, which are also limited by the binding. You should see a bunch of warnings when you check the DTBS via 'make dtbs_check' > drivers/iommu/rockchip-iommu.c | 36 ++++++++++++++++++++++++++++++++++++ > 1 file changed, 36 insertions(+) >=20 > diff --git a/drivers/iommu/rockchip-iommu.c b/drivers/iommu/rockchip-iomm= u.c > index f5629515bd78..673b0ebb6262 100644 > --- a/drivers/iommu/rockchip-iommu.c > +++ b/drivers/iommu/rockchip-iommu.c > @@ -6,6 +6,8 @@ > * Daniel Kurtz > */ > =20 > +#include "linux/err.h" > +#include "linux/pm_domain.h" > #include > #include > #include > @@ -115,6 +117,7 @@ struct rk_iommu { > struct iommu_device iommu; > struct list_head node; /* entry in rk_iommu_domain.iommus */ > struct iommu_domain *domain; /* domain to which iommu is attached */ > + struct dev_pm_domain_list *pmdomains; > }; > =20 > struct rk_iommudata { > @@ -1186,6 +1189,7 @@ static int rk_iommu_probe(struct platform_device *p= dev) > struct resource *res; > const struct rk_iommu_ops *ops; > int num_res =3D pdev->num_resources; > + int pm_domain_count; > int err, i; > =20 > iommu =3D devm_kzalloc(dev, sizeof(*iommu), GFP_KERNEL); > @@ -1271,6 +1275,35 @@ static int rk_iommu_probe(struct platform_device *= pdev) > if (!dma_dev) > dma_dev =3D &pdev->dev; > =20 > + pm_domain_count =3D of_property_count_strings(iommu->dev->of_node, "pow= er-domain-names"); pm_domain_count =3D device_property_string_array_count(iommu->dev, "power-d= omain-names"); When possible using device_property_ is prefered, since it allows reusing code for systems not using DT. > + if (pm_domain_count > 0) { > + const char **pm_domains =3D kvmalloc_array(pm_domain_count, sizeof(*pm= _domains), GFP_KERNEL); > + struct dev_pm_domain_attach_data pm_domain_data =3D { > + .pd_names =3D pm_domains, > + .num_pd_names =3D pm_domain_count, > + .pd_flags =3D PD_FLAG_DEV_LINK_ON, > + }; > + int i; > + > + if (!pm_domain_data.pd_names) { > + err =3D -ENOMEM; > + goto err_remove_sysfs; > + } > + > + for (i =3D 0; i < pm_domain_count; i++) { > + err =3D of_property_read_string_index(iommu->dev->of_node, "power-dom= ain-names", i, &pm_domains[i]); > + if (err) { > + kfree(pm_domains); > + goto err_remove_sysfs; > + } > + } There is a helper to read a string array: err =3D device_property_read_string_array(iommu->dev, "power-domain-names",= pm_domains, pm_domain_count); -- Sebastian > + > + err =3D dev_pm_domain_attach_list(iommu->dev, &pm_domain_data, &iommu-= >pmdomains); > + kfree(pm_domains); > + if (err < 0) > + goto err_remove_sysfs; > + } > + > pm_runtime_enable(dev); > =20 > for (i =3D 0; i < iommu->num_irq; i++) { > @@ -1292,6 +1325,7 @@ static int rk_iommu_probe(struct platform_device *p= dev) > return 0; > err_pm_disable: > pm_runtime_disable(dev); > + dev_pm_domain_detach_list(iommu->pmdomains); > err_remove_sysfs: > iommu_device_sysfs_remove(&iommu->iommu); > err_unprepare_clocks: > @@ -1310,6 +1344,8 @@ static void rk_iommu_shutdown(struct platform_devic= e *pdev) > devm_free_irq(iommu->dev, irq, iommu); > } > =20 > + dev_pm_domain_detach_list(iommu->pmdomains); > + > pm_runtime_force_suspend(&pdev->dev); > } > =20 >=20 > --=20 > 2.45.2 >=20 >=20 --klltttveuxmaguyk Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEE72YNB0Y/i3JqeVQT2O7X88g7+poFAmZqN6sACgkQ2O7X88g7 +pqVmxAAg7JgRVo1N7aZb+AgIqo70yZ1n7UTJR7CiUdmCaLG0E03/qnaFUfttJqQ CGGew5eHLIg83Frbx3+Ksg+G01emakM5YoT0lGHe/sL80Iz+VZAMldIsWxBJ9U6y bArvV1dFuXik6ZqYfTQ05KhtY1SfCisXl2BuzxPFSFyMJBPiZS/n2QFFAu3KoNTa EKA0I73nytEMoBsk/RmcJdU1wRMI7YgJlkjjIRH/YhzjHJfccyfBP53UemiEo4mV ybb+/IqXhUqW3HQk4BYrovTMw2HaLknvR/C7Lz1PdVvOFWX9cStytD9JHZM3XGcn PGcDHALBksgsIhgZaos55MgWPPdxwRA6VR0pQTaOzg52vuHShZKjgzQbKzlYLMfb UzkEpRbJycI212XVJdwVGH+JhvIr+fd13yjd0RQbdEVUqnIzTBmUTW/CO3kX36Go AMmGEg8UEHtZtJqzdtIXNJ9/Ef6iLVXxCNQ4pz6EzSOdKbotE2pUS+jOshcNJlFk c3ePBJQ3DtKEWsFh3yGtH5Kg/m/LddhUeVoIMTmSlrz73vDecD2IASEE+of8Mho8 7y3+c/PqBfzyfPYVaqEFlO+//llf5xDeRLHXOW8Mm1BtIrMgyD/401KD4wj/63By bLyO2NRg/FXI4kXtQFjBLq7wLmPxujL+S89RolLYMPbbbkxSlsQ= =6VfK -----END PGP SIGNATURE----- --klltttveuxmaguyk--