Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp4690606pxk; Wed, 30 Sep 2020 09:12:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzl5VhwLjVtE4+M8uxjPyTU5tPLzTiEJn95Jf/khRDMEIaIIGci/S/xNCbzJOYe4O58RuBg X-Received: by 2002:a17:906:6881:: with SMTP id n1mr3683677ejr.487.1601482369366; Wed, 30 Sep 2020 09:12:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1601482369; cv=none; d=google.com; s=arc-20160816; b=vTas+sGF83ldt6vr4PEbwNRuK/DZvc4xcvhUG6FEgFL4jki+icQh6wLIwK8hM/o2xp QGBetm4sPlgjfAFszRUMybAZBYRumYirb6PedAy+GAnGz9jKhgFYFEJwC7CNZES/pviV aR7M15Wk4sTySV4Dl+z3C2nzAalAcJXvLMebSIWSD2pm690tIY/19aPHcku7h4haeJNN SVW1X+8P7p3j8dEaG2rBfJ1l2FPOgMwVTBJ1NMb39D4XOec7AKaibHbKgRNAiv9ybXgo TU5Yh/Oql/4/j4fs6mwO4S2O3czDGhaNHfI1XDnucWwOfnjVJiGPCrO0hSSgomwrqZ4Z lphw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=Gz8YbIcBLxDIo/9xfQsLMToZ+yZY22BQ/9LJJe3pu9A=; b=fRcBUr8TGSqrgObNPYtCilxYenMmniupOEf+sOJPgk0C20C06Q1XdSIa4m6mAVxAis 7DYrXrHmilB+0pPvPE8GAS88MgWmSnAkMwPftJaj0uqOcTOJG3LTzpCiaD/dccx9Ui/L AvAUh2ZPr+mIIhF69UVzpyrDg9P+wbuDtY46Z91VIoy0TZXwSX8Lt/nGT7J+DCynTxso JT4eeLFB8bbdQ+QdNEG7M0nQxhKQdrNQO5ElqvfBWkI2QgArjJhk9L8ABMy6alYtZgB6 UREGs4MtDZ2PTGoXv6llTSRdskGy9yjJrbgCGauTYqK02+YENEc14nHgFRGnZFkBC6XJ KueQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=GauHFVbi; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id n15si1648186eje.173.2020.09.30.09.12.25; Wed, 30 Sep 2020 09:12:49 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=GauHFVbi; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730196AbgI3QKh (ORCPT + 99 others); Wed, 30 Sep 2020 12:10:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48744 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725385AbgI3QKh (ORCPT ); Wed, 30 Sep 2020 12:10:37 -0400 Received: from mail-ej1-x644.google.com (mail-ej1-x644.google.com [IPv6:2a00:1450:4864:20::644]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1FEEBC061755; Wed, 30 Sep 2020 09:10:37 -0700 (PDT) Received: by mail-ej1-x644.google.com with SMTP id i26so3607724ejb.12; Wed, 30 Sep 2020 09:10:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=Gz8YbIcBLxDIo/9xfQsLMToZ+yZY22BQ/9LJJe3pu9A=; b=GauHFVbinz4XzRFmxPc5VJod/LYJfLbRDipc4McYlUB3hVnqVjURSXx6M6nlzYN/tk P4R3ExcmAE5zADSbavU6moHxKHs5Zs5nNEAlMCUSgsuueYepEwZjDnb0qfKezrv2xyLX fv7zVccFO3rZy3IcASGz3zg6dvDtPYJuUKzUMsO0H1d+Zmh6HP2vkPZqWWJezskG6EJu s0GdeeePVwdTChyw807eP2FqHWBwQQcdjsh1GRe2h6TMeMhC4JFyhfWXzbanGZtmPB12 kQIWfBSCtqLGBVmwluh/Ac0MwR++/ousPynRcxoADcSBf0VXi0gXufw9QRh/FbxmoHXg 8kDA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=Gz8YbIcBLxDIo/9xfQsLMToZ+yZY22BQ/9LJJe3pu9A=; b=D9l+M9ZLqFsPtS23MhFMrx2dZbLtGk7kKiZKX8KzUmcIibUFUMFaoQCeIzTc4a8oej rbe6fY2UPBvuqUGTk4ug1wnYXMr8AWPp0nkFUOCQsXxqmltRTWrmEeOexeZ7JcDy41I5 iidhyd8yLxeUoiTMxo83RsvWTrTy0n3pvODzNwgcqxe4rABh05Yt2U2jYOcW3Xm48a9S KRZh1+XZ6yJZFP0V5m605nIQjmnswVyIbStYNQ3Cdqe0pKY/ZTBz1zMIgVvOobh5PZmy hLNxSGFZB9E513PaU+DxJCrs4YS/wokZHvZMm3nvkfZqS5JAtzA62zRPUs7r9RSyXvIU z4ow== X-Gm-Message-State: AOAM532sVnpsigQ1E3eeP/N+z92amxBtKP9KVlZ/ZAP+tPYOdwGnzMrx BGXShb4eciioZ32hdzYd7sQ= X-Received: by 2002:a17:906:f11:: with SMTP id z17mr3697701eji.88.1601482235786; Wed, 30 Sep 2020 09:10:35 -0700 (PDT) Received: from localhost ([217.111.27.204]) by smtp.gmail.com with ESMTPSA id l26sm1913672ejr.78.2020.09.30.09.10.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 30 Sep 2020 09:10:34 -0700 (PDT) Date: Wed, 30 Sep 2020 18:10:33 +0200 From: Thierry Reding To: Dmitry Osipenko Cc: Nicolin Chen , joro@8bytes.org, krzk@kernel.org, vdumpa@nvidia.com, jonathanh@nvidia.com, linux-tegra@vger.kernel.org, iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v3 2/3] iommu/tegra-smmu: Rework .probe_device and .attach_dev Message-ID: <20200930161033.GE3833404@ulmo> References: <20200930084258.25493-1-nicoleotsuka@gmail.com> <20200930084258.25493-3-nicoleotsuka@gmail.com> <20200930153131.GB3833404@ulmo> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="brEuL7wsLY8+TuWz" Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.14.7 (2020-08-29) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --brEuL7wsLY8+TuWz Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Wed, Sep 30, 2020 at 06:36:52PM +0300, Dmitry Osipenko wrote: > I'... > >> + struct tegra_mc *mc =3D devm_tegra_get_memory_controller(dev); > >> + struct iommu_fwspec *fwspec =3D dev_iommu_fwspec_get(dev); > >=20 > > It looks to me like the only reason why you need this new global API is > > because PCI devices may not have a device tree node with a phandle to > > the IOMMU. However, SMMU support for PCI will only be enabled if the > > root complex has an iommus property, right? In that case, can't we > > simply do something like this: > >=20 > > if (dev_is_pci(dev)) > > np =3D find_host_bridge(dev)->of_node; > > else > > np =3D dev->of_node; > >=20 > > ? I'm not sure exactly what find_host_bridge() is called, but I'm pretty > > sure that exists. > >=20 > > Once we have that we can still iterate over the iommus property and do > > not need to rely on this global variable. >=20 > This sounds more complicated than the current variant. I don't think so. It's actually very clear and explicit. And yes, this might be a little more work (and honestly, this is what? a handful of lines?) than accessing a global variable, but that's a fair price to pay for proper encapsulation. > Secondly, I'm already about to use the new tegra_get_memory_controller() > API for all the T20/30/124/210 EMC and devfreq drivers. Also, this really proves the point I was trying to make about how this is going to proliferate... Thierry --brEuL7wsLY8+TuWz Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCAAdFiEEiOrDCAFJzPfAjcif3SOs138+s6EFAl90rfkACgkQ3SOs138+ s6HL9A/+Ol+FddqakzBkR5ybYmsPeEUyPF5dwncQF++WGcerrvQx2DTXQYpIoGHl LnUCBYK+np/rcAvNEScWYVUfMD3BslmIHjpAzhza004NLLtz0/m8EUBxfaRxA76i GRZbr0SEXrIPWdEFwx6gSQMnZvG7+tGsQSybMi+vWWUCItxVYLar9XBg3PLhcZoP 5WURiPyas+HF4wuNzT2e100vACoLos2DexhIRnxGCF0tkDRsBFCEN++0XfWTrBGh NxdIsX9O6/HYJEZ5ncbP5hUYJ+vnw0xs9EYKXyQsB1P0zxm5dmBsZEnsYm5FvB7o qC6NK2Aje5ovdIDjJCwNb84c4B1/jW1Q6e7wFZuoO9i3cacbchucH96j5qPM+1Wy J7gabVPsv/qZ3MDHA+9s1Bs899QWp5gs1NvLu509DcHCtEFfMexG0tnZUDeIB4Fb wqDhGpfcil6pRL5Q5wvswnKJ+Zji9x/CwbgIu3V1R1ehHOPnOPyy9EjhqvJm7RKE tvzHLAi4/LXgMBhe1dvO8RE7Ya9c9qGQm0QOi+r+jNWHIsEGI9By2u7kzHKOqBx0 PZctFqhKFVUmSftXv2xp5Gx2hsd+7YIKesZf74lswWCh3c2Sphrb274O3uPHR1qa ean/rNOn65fNW95vSsOpT9NQ1aJWk0Du8xx7Jv7BZVRZp2KJxtw= =n10A -----END PGP SIGNATURE----- --brEuL7wsLY8+TuWz--