Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp4715552pxk; Wed, 30 Sep 2020 09:48:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxU8Zly5dqaM54G00/MVuyx2VIH0FntPS6FyhvkD6pX92PH90pXZvRoBAleGmIYv9mZ3sOz X-Received: by 2002:a17:906:b784:: with SMTP id dt4mr4001445ejb.376.1601484512194; Wed, 30 Sep 2020 09:48:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1601484512; cv=none; d=google.com; s=arc-20160816; b=pGYcWQSo2uItkBdxFzPpgWr5+ObNGRhJGI8EKb8Us6nsmwJFKVSToMIPJU6/qFZHDs JAjNMn9ThF/IYRsTvnoiT6Fcj+4xZ1IQ/4V+DpzRGNyXUhQrlX5GFDDvmPlbb6aCsccW gatTIZEwM7EkizK5jXvV3GOHj/+2j0rivMXkgNC6QFvIoJid20EH+GS56TWgwJXruACp q1mQ1wBSZ91QC4aQ8jZy4qggYTFPab7TERx4XVkKyCBABNhThi5KFKAbrcHDqgtrZZ2k NCP+XDT35+QHFbqFGRq6kARKSnMfoWc4ZCZpeerLV3XUFDiJippWk92Z1Eh9bLwj0WqC OX4A== 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=dwBlOQMq5+8l62W5AsOI0m1SQ7GJFufU2mYg0ww+V+s=; b=futUdRV3HvoA/uCO9f7ChhCdt181VSwyIw75egH5zNQRZxUUPqtzk1sxwAt9DykBL0 f5CEnm9NMnN4QGkNPcqWpP/NgnhbVCYZW+zYTwkR/BF2ICIY2lO7MfLITsd16Q+4P6tE 4FalxLTVhG1NvEAWn+D7V5UbdbBG370dZO5oBwPxJd9eTX8/Av9+cPE8O5+dCxYQYnm9 3zTx17J/5rIDF50snAunfo4q6O711naugOFjM0KaeU9zPGugTAZWDPTD84nyO4EpKUI3 yHWxxKb6uze61qJI3OzSzEAwesqQNBIvXaPklfxLorvHRhz0oMmWWzJofsygNKQXc+vB 9ILQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=LlQtzLTo; 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 r10si1477668ejr.168.2020.09.30.09.48.08; Wed, 30 Sep 2020 09:48:32 -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=LlQtzLTo; 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 S1730363AbgI3QrM (ORCPT + 99 others); Wed, 30 Sep 2020 12:47:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54468 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725892AbgI3QrM (ORCPT ); Wed, 30 Sep 2020 12:47:12 -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 DF9CEC061755; Wed, 30 Sep 2020 09:47:11 -0700 (PDT) Received: by mail-ej1-x644.google.com with SMTP id nw23so3833154ejb.4; Wed, 30 Sep 2020 09:47:11 -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=dwBlOQMq5+8l62W5AsOI0m1SQ7GJFufU2mYg0ww+V+s=; b=LlQtzLToUwS3qc2V6Fs0G8CkvwmD023iz6KwLcB21kscwYk9l+nG0/DS4EC5KQk+bs JHwajX4MQ/jQTSVtpBbGsX+XtseJgnHt1hwF4yd3TkaCX9NHAl1XRKUmjeNKTUu433OO XIBvHE+5y54gL2vA6+OkIWmguj7pr8BHo5BjMDYcerS6wthRscNfajxXY08EK+sicuHI VpW4h97A6UrLCSsYq/5iWEzHTm9QEE2cOazc3h1ArQwTYTXB++EDUkftvtURcXMEcpto BhIu1OU7+O0C3ExcsCQN37jedc7S0AWpbW00ZLR3vtAkf0NegcdXj+SMYcDDtxsxSFKd UC1A== 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=dwBlOQMq5+8l62W5AsOI0m1SQ7GJFufU2mYg0ww+V+s=; b=QFgrlhewfYcigad7XmWcAyvd8si7gnhwEGHGZgXdjyJRzC8SxnwmP+T/TNVaIBPrzA 0KWxwNaW2x7IKEZcQ+hOpTinhrR/LdmN+1I7PT04/7PdN9s/BPymLw7p5Z4fIMNfm8wm h4ljAKOTQx0UXVD5ZWCjJFao2rXxucGNLxz5Qdsq4cc1zkISyDkjSPs7RIW2V6I+zxEN sqzeYpMcXElYplJfLfA3GN86uNXPUVTBsJLpjhWH+kMFM05H9FAukZewt4rvmM2r6fiE cp2MFjqOig5J2s7Ik7U3//pYvoqdKAmTHkkahAPMnVre3ki5qZkwCqoIUEwmdhd6FLGI +aLQ== X-Gm-Message-State: AOAM530PcAEZFEzdJ9wi0qBVwIOJUSpWFwAmv9DO2D42m7wKkEsIto0B HGfRdTLllmXElzkDDUNCG8o= X-Received: by 2002:a17:906:2dd:: with SMTP id 29mr3886541ejk.31.1601484430509; Wed, 30 Sep 2020 09:47:10 -0700 (PDT) Received: from localhost ([217.111.27.204]) by smtp.gmail.com with ESMTPSA id j20sm1978041ejk.31.2020.09.30.09.47.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 30 Sep 2020 09:47:09 -0700 (PDT) Date: Wed, 30 Sep 2020 18:47:07 +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: <20200930164707.GB3852280@ulmo> References: <20200930084258.25493-1-nicoleotsuka@gmail.com> <20200930084258.25493-3-nicoleotsuka@gmail.com> <20200930153131.GB3833404@ulmo> <20200930160626.GD3833404@ulmo> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="kXdP64Ggrk/fb43R" 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 --kXdP64Ggrk/fb43R Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Wed, Sep 30, 2020 at 07:25:41PM +0300, Dmitry Osipenko wrote: > 30.09.2020 19:06, Thierry Reding =D0=BF=D0=B8=D1=88=D0=B5=D1=82: > > 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); > >>> > >>> 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: > >>> > >>> if (dev_is_pci(dev)) > >>> np =3D find_host_bridge(dev)->of_node; > >>> else > >>> np =3D dev->of_node; > >>> > >>> ? I'm not sure exactly what find_host_bridge() is called, but I'm pre= tty > >>> sure that exists. > >>> > >>> Once we have that we can still iterate over the iommus property and do > >>> not need to rely on this global variable. > >> > >> This sounds more complicated than the current variant. > >> > >> 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. > >=20 > > Why do we need it there? They seem to work fine without it right now. >=20 > All the Tegra30/124/210 EMC drivers are already duplicating that MC > lookup code and only the recent T210 driver does it properly. >=20 > > If it is required for new functionality, we can always make the depende= nt > > on a DT reference via phandle without breaking any existing code. >=20 > That's correct, it will be also needed for the new functionality as > well, hence even more drivers will need to perform the MC lookup. I don't have any issues with adding a helper if we need it from several different locations. But the helper should be working off of a given device and look up the device via the device tree node referenced by phandle. We already have those phandles in place for the EMC devices, and any other device that needs to interoperate with the MC should also get such a reference. > I don't quite understand why you're asking for the phandle reference, > it's absolutely not needed for the MC lookup and won't work for the We need that phandle in order to establish a link between the devices. Yes, you can probably do it without the phandle and just match by compatible string. But we don't do that for other types of devices either, right? For a display driver we reference the attached panel via phandle, but we could also just look it up via name or absolute path or some other heuristic. But a phandle is just a much more explicit way of linking the devices, so why not use it? > older DTs if DT change will be needed. Please give a detailed explanation. New functionality doesn't have to work with older DTs. Thierry --kXdP64Ggrk/fb43R Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCAAdFiEEiOrDCAFJzPfAjcif3SOs138+s6EFAl90tosACgkQ3SOs138+ s6EhVBAAqjpxYzLulCcunbD3SM+z9yRrHLZopF7aAF00WcEq1K4Mp4veCap41y0t 64EvmoHiMuoTAz8LlZkIv6L1ydvzO1F/K37VIWmCHbjHVrTC0qiH/O++wZ3PvNmC uHLPRV7RWGTjYUs8rpcFiVkubdzql+RMiD0nb8GrgbnQbFFLzm8he7Q35b7RtPrr BF6IbyBWLziNYRaPZsDq/XEzcz9KLOycjnpuPnAFQRhFP0whZEBp7nqCbcfPlD5w bpKyQjBywba/5Qi6DB4751HRaKa1l6iyWsOOkW9EV4ZpAagtnOaG6i+pNiwdiebD tw24SQZ+RcIc4Mj4iuly+rgcYVg4pof7qHpJW2Yf6ZYy0x+XHTdzBx/hSx6jhiag frIEyRYSRn1o3F4Y2CwFu/n3iM6JgIgsx+t+qrIz7oQDf2RDOpWMzGU1hZw0bDDh 2LJdKHQ5Xb3tOuIsHvMLD6pp7eCgWkMj87XoTqcUv/IiNxuxrHxmgUExnxXyBGDL JwSVsLxnGe0uo4aMyLsNqfv3swWjsoSfS5gKme5tIdMR/7xjEBHs/HtNzu9otHqU AaE6tuZHc0DxA5CIIgW/OroLkFi9fDFDhRJGL1vrrkeoXGrXhcN6WnJVtLX8WxYS PxBneEM8mVUh0K5AUbL13EMbnm5bgMl/nDS+7fZerv/KmJgef9o= =I0Za -----END PGP SIGNATURE----- --kXdP64Ggrk/fb43R--