From: Mark Zhang <nvmarkzhang-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
To: Hiroshi Doyu <hdoyu-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
Cc: iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org,
joro-zLv9SwRftAIdnm+yROfE0A@public.gmane.org,
linux-tegra-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
thierry.reding-RM9K5IK7kjKj5M59NBduVrNAH6kLmebB@public.gmane.org
Subject: Re: [v3 1/1] iommu/tegra: smmu: bus_notifier registers platform IOMMU devices
Date: Wed, 05 Dec 2012 14:29:42 +0800 [thread overview]
Message-ID: <50BEE9D6.2080107@gmail.com> (raw)
In-Reply-To: <1354646264-12126-1-git-send-email-hdoyu-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
On 12/05/2012 02:37 AM, Hiroshi Doyu wrote:
> Most of platform devices are IOMMU'able in Tegra30 SoC. Registering
> all IOMMU'able devices manually isn't nice. This patch allows
> platform bus_notifier to register IOMMU devices. Map info can be
> passed from DT. Info format is:
>
> dma-window = <0 0x40000000>;
>
> TODO:
> A map can be shared with mutiple devices. This info also could be
> passed from DT or default map can be set in advance.
>
> Signed-off-by: Hiroshi Doyu <hdoyu-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
> ---
> v3: Added bus_unregister_notifier
> ---
> drivers/iommu/tegra-smmu.c | 48 +++++++++++++++++++++++++++++++++++++++++++-
> 1 file changed, 47 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/iommu/tegra-smmu.c b/drivers/iommu/tegra-smmu.c
> index 25c1210..8fec9be 100644
> --- a/drivers/iommu/tegra-smmu.c
> +++ b/drivers/iommu/tegra-smmu.c
> @@ -38,6 +38,7 @@
>
> #include <asm/page.h>
> #include <asm/cacheflush.h>
> +#include <asm/dma-iommu.h>
>
> enum smmu_hwgrp {
> HWGRP_AFI,
> @@ -1273,13 +1274,58 @@ static struct platform_driver tegra_smmu_driver = {
> },
> };
>
> +static int tegra_smmu_device_notifier(struct notifier_block *nb,
> + unsigned long event, void *_dev)
> +{
> + struct dma_iommu_mapping *map = NULL;
> + struct device *dev = _dev;
> + dma_addr_t base;
> + size_t size;
> + int err;
> +
> + switch (event) {
> + case BUS_NOTIFY_ADD_DEVICE:
> + err = of_get_dma_window(dev->of_node, NULL, 0, NULL, &base,
> + &size);
> + if (!err)
> + map = arm_iommu_create_mapping(&platform_bus_type,
> + base, size, 0);
> + if (IS_ERR_OR_NULL(map))
> + break;
> + if (arm_iommu_attach_device(dev, map)) {
> + arm_iommu_release_mapping(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);
If "arm_iommu_attach_device" fails, the "dev_err" and "dev_dbg" will all
be called.
> + break;
> + default:
> + break;
> + }
> + return NOTIFY_DONE;
> +}
> +
> +static struct notifier_block tegra_smmu_device_nb = {
> + .notifier_call = tegra_smmu_device_notifier,
> +};
> +
> static int __devinit tegra_smmu_init(void)
> {
> - return platform_driver_register(&tegra_smmu_driver);
> + int err;
> +
> + err = platform_driver_register(&tegra_smmu_driver);
> + if (err)
> + return err;
> + if (IS_ENABLED(CONFIG_ARM_DMA_USE_IOMMU))
> + bus_register_notifier(&platform_bus_type,
> + &tegra_smmu_device_nb);
> + return 0;
> }
>
> static void __exit tegra_smmu_exit(void)
> {
> + if (IS_ENABLED(CONFIG_ARM_DMA_USE_IOMMU))
> + bus_unregister_notifier(&platform_bus_type,
> + &tegra_smmu_device_nb);
Okay. Here unregister the notifier, but where is the
"arm_iommu_release_mapping" for every IOMMU'able devices?
> platform_driver_unregister(&tegra_smmu_driver);
> }
>
>
next prev parent reply other threads:[~2012-12-05 6:29 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-12-04 18:37 [v3 1/1] iommu/tegra: smmu: bus_notifier registers platform IOMMU devices Hiroshi Doyu
[not found] ` <1354646264-12126-1-git-send-email-hdoyu-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2012-12-05 6:29 ` Mark Zhang [this message]
[not found] ` <50BEE9D6.2080107-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2012-12-07 9:32 ` Hiroshi Doyu
2012-12-05 21:11 ` Stephen Warren
[not found] ` <50BFB88C.8080901-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org>
2012-12-07 10:12 ` Hiroshi Doyu
[not found] ` <20121207.121205.1712068640752315024.hdoyu-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2012-12-10 17:43 ` Stephen Warren
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=50BEE9D6.2080107@gmail.com \
--to=nvmarkzhang-re5jqeeqqe8avxtiumwx3w@public.gmane.org \
--cc=hdoyu-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org \
--cc=iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org \
--cc=joro-zLv9SwRftAIdnm+yROfE0A@public.gmane.org \
--cc=linux-tegra-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=thierry.reding-RM9K5IK7kjKj5M59NBduVrNAH6kLmebB@public.gmane.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).