Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753759Ab2K2KSA (ORCPT ); Thu, 29 Nov 2012 05:18:00 -0500 Received: from moutng.kundenserver.de ([212.227.17.8]:65182 "EHLO moutng.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751392Ab2K2KR5 (ORCPT ); Thu, 29 Nov 2012 05:17:57 -0500 Date: Thu, 29 Nov 2012 11:17:29 +0100 From: Thierry Reding To: Hiroshi Doyu Cc: "m.szyprowski@samsung.com" , "swarren@wwwdotorg.org" , "joro@8bytes.org" , "James.Bottomley@HansenPartnership.com" , "arnd@arndb.de" , Krishna Reddy , "linux@arm.linux.org.uk" , "minchan@kernel.org" , "chunsang.jeong@linaro.org" , "linux-kernel@vger.kernel.org" , "subashrp@gmail.com" , "linaro-mm-sig@lists.linaro.org" , "linux-mm@kvack.org" , "iommu@lists.linux-foundation.org" , "linux-tegra@vger.kernel.org" , "kyungmin.park@samsung.com" , "pullip.cho@samsung.com" , "linux-arm-kernel@lists.infradead.org" Subject: Re: [PATCH 1/1] ARM: tegra: bus_notifier registers IOMMU devices(was: How to specify IOMMU'able devices in DT) Message-ID: <20121129101729.GA6150@avionic-0098.adnet.avionic-design.de> References: <20120924124452.41070ed2ee9944d930cffffc@nvidia.com> <054901cd9a45$db1a7ea0$914f7be0$%szyprowski@samsung.com> <20120924.145014.1452596970914043018.hdoyu@nvidia.com> <20121128.154832.539666140149950229.hdoyu@nvidia.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="vkogqOf2sHV7VnPd" Content-Disposition: inline In-Reply-To: <20121128.154832.539666140149950229.hdoyu@nvidia.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-Provags-ID: V02:K0:jBhMrRhD877xN95BIVNeqC89GO9DdjVI90IBmLZ8d6E vwfCZtcoumlxLB4/+JVisMZSwT/6/HKY5knBrd3eSeioOzWA5x Do96mwjtG6NN5ZH8DsALcfufft94fBSn5Lc2SStrJ++QEA8mlj uqGkhS/zOjwiSIbpzvyJKs16z7FvaVI9tYKvDPaXfcW/k0GQ1J SgpCZlVA8oAzAVRMPhMDnE24FeC5gOBv3ERkgZzz+jsFHwLAyp Jwx2TjoI+CpXMZj2CQdDTzADZA0XTLzy84dV0h7SHpzonrbbxM 9VFDEdKI14VuC86lRoGIDttWpgSLEkjhapipQ/e1z9UZ1qWd0Z 6x6vbEZU+BNP08BpDBF9NJ1Gs2em54I9MGvObu5rYmB7L07pmj CcZABWropLSt7+9jOQRDLJvvT9Obd8eF/s= Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3764 Lines: 116 --vkogqOf2sHV7VnPd Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Wed, Nov 28, 2012 at 02:48:32PM +0100, Hiroshi Doyu wrote: [...] > From: Hiroshi Doyu > Date: Wed, 28 Nov 2012 14:47:04 +0200 > Subject: [PATCH 1/1] ARM: tegra: bus_notifier registers IOMMU devices >=20 > platform_bus notifier registers IOMMU devices if dma-window is > specified. >=20 > Its format is: > dma-window =3D <"start" "size">; > ex) > dma-window =3D <0x12345000 0x8000>; >=20 > Signed-off-by: Hiroshi Doyu > --- > arch/arm/mach-tegra/board-dt-tegra30.c | 40 ++++++++++++++++++++++++++= ++++++ > 1 file changed, 40 insertions(+) >=20 > diff --git a/arch/arm/mach-tegra/board-dt-tegra30.c b/arch/arm/mach-tegra= /board-dt-tegra30.c > index a2b6cf1..570d718 100644 > --- a/arch/arm/mach-tegra/board-dt-tegra30.c > +++ b/arch/arm/mach-tegra/board-dt-tegra30.c > @@ -30,9 +30,11 @@ > #include > #include > #include > +#include > =20 > #include > #include > +#include > =20 > #include "board.h" > #include "clock.h" > @@ -86,10 +88,48 @@ static __initdata struct tegra_clk_init_table tegra_d= t_clk_init_table[] =3D { > { NULL, NULL, 0, 0}, > }; > =20 > +#ifdef CONFIG_ARM_DMA_USE_IOMMU > +static int tegra_iommu_device_notifier(struct notifier_block *nb, > + unsigned long event, void *_dev) > +{ > + struct dma_iommu_mapping *map =3D NULL; > + struct device *dev =3D _dev; > + dma_addr_t base; > + size_t size; > + int err; > + > + switch (event) { > + case BUS_NOTIFY_ADD_DEVICE: > + err =3D of_get_dma_window(dev->of_node, NULL, 0, NULL, &base, > + &size); > + if (!err) > + map =3D arm_iommu_create_mapping(&platform_bus_type, > + base, size, 0); > + if (IS_ERR_OR_NULL(map)) > + break; > + if (arm_iommu_attach_device(dev, map)) > + dev_err(dev, "Failed to attach %s\n", dev_name(dev)); > + dev_dbg(dev, "Attached %s to map %p\n", dev_name(dev), map); > + break; > + } > + return NOTIFY_DONE; > +} > +#else > +#define tegra_iommu_device_notifier NULL > +#endif > + > +static struct notifier_block tegra_iommu_device_nb =3D { > + .notifier_call =3D tegra_iommu_device_notifier, > +}; You don't need this extra protection since you use IS_ENABLED below and these are all static variables. The whole point of IS_ENABLED is to allow full compile coverage while leaving it up to the compiler to eliminate dead code. Thierry --vkogqOf2sHV7VnPd Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.19 (GNU/Linux) iQIcBAEBAgAGBQJQtzY5AAoJEN0jrNd/PrOhuzMP/iJ18BF54Mt6oyjkj7L4SDsE BHtFAOgoS6H6ZE4gDkJcmXotmEb1qSP4dhM6kox7XtEwfQ2QQ19btFNfsvyZrrZF S7oRehteLuY9f9UeattSzMW7p/vLp4ca15krNuS2zMLonsvfARY3+zKshvp95i4w u13XLVCCz8qFqMI+hTC1mG6J38yUX3OE8MatP213sO23gR+M+k2W2hGdShoIkLca FjaeWw8XqapGQNAM7M95IkdWalIZGGQ7VUcWU7J+dYnb1yNS0fIiDPyc+PMXlcDc rRseaEPAjeRKcx+gu7mTf0tZOo+oiwQFy7eRVtj1o/9KteIvL7BE5ePd7pnNQM5v U9zBJ3mTt4suST5xFK0tTnJElbZFMtNA75ZC6mrHfyVFo1HcQd3gx2CN5qxWL709 Sgr8Gr0hrWyodLxiDE+a3q+k4deB5BxYccp1swZMrrlkH4MYVESCrgJ6TyZPjihr OtpJyH4myC+GqBBdyxQ5phNLq13UdgmtiurnXDaKIgqq46yNR5TaUuo4B/bTDK6s 2PmMFziZYyCmnWiMb8JU42J/VHSQrQkv7EC3V9w6BKhkynPvh6CLMcsD7A2Ub+Ta rZKyuy89z0wuGKhyJgpIGXRpjyROIorlHcsWpP9MPGb3V8Hec6hmBbVGFsSrxPqw Io+pFSTddkjReGRA/agl =uArM -----END PGP SIGNATURE----- --vkogqOf2sHV7VnPd-- -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/