From: Hiroshi Doyu <hdoyu-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
To: "linux-tegra-u79uwXL29TY76Z2rM5mHXA@public.gmane.org"
<linux-tegra-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>
Subject: Re: [PATCHv8 05/21] iommu/core: add ops->{bound,unbind}_driver()
Date: Mon, 16 Jun 2014 14:02:28 +0300 [thread overview]
Message-ID: <878uox15iz.fsf@nvidia.com> (raw)
In-Reply-To: <1401448834-32659-6-git-send-email-hdoyu-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
Hiroshi Doyu <hdoyu-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org> writes:
> ops->{bound,unbind}_driver() functions are called at
> BUS_NOTIFY_{BOUND,UNBIND}_DRIVER respectively.
>
> This is necessary to control the device population order. IOMMU master
> devices depend on an IOMMU device instanciation. IOMMU master devices
> can be registered to an IOMMU only after it's successfully
> populated. This IOMMU registration is done via
> ops->bound_driver(). Currently this population can be deferred if
> depending IOMMU device hasn't yet been populated in driver core. This
> cannot be done via ops->add_device() since after add_device() device's
> population/instanciation can be still deferred via probe().
>
> Signed-off-by: Hiroshi Doyu <hdoyu-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
> ---
> drivers/iommu/iommu.c | 13 +++++++++++--
> include/linux/iommu.h | 4 ++++
> 2 files changed, 15 insertions(+), 2 deletions(-)
I have just noticed that we could make use of IOMMU group for this
purpose so that we could avoid this iommu core part modification but
just tegra-smmu part modification which would be easier to merge.
> diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c
> index e5555fcfe703..5469d361e7bc 100644
> --- a/drivers/iommu/iommu.c
> +++ b/drivers/iommu/iommu.c
> @@ -540,14 +540,23 @@ static int iommu_bus_notifier(struct notifier_block *nb,
> * ADD/DEL call into iommu driver ops if provided, which may
> * result in ADD/DEL notifiers to group->notifier
> */
> - if (action == BUS_NOTIFY_ADD_DEVICE) {
> + switch (action) {
> + case BUS_NOTIFY_ADD_DEVICE:
> if (ops->add_device)
> return ops->add_device(dev);
> - } else if (action == BUS_NOTIFY_DEL_DEVICE) {
> + case BUS_NOTIFY_DEL_DEVICE:
> if (ops->remove_device && dev->iommu_group) {
> ops->remove_device(dev);
> return 0;
> }
> + case BUS_NOTIFY_BOUND_DRIVER:
> + if (ops->bound_driver)
> + ops->bound_driver(dev);
> + break;
> + case BUS_NOTIFY_UNBIND_DRIVER:
> + if (ops->unbind_driver)
> + ops->unbind_driver(dev);
> + break;
> }
>
> /*
> diff --git a/include/linux/iommu.h b/include/linux/iommu.h
> index b96a5b2136e4..141eea25bdea 100644
> --- a/include/linux/iommu.h
> +++ b/include/linux/iommu.h
> @@ -97,6 +97,8 @@ enum iommu_attr {
> * @domain_has_cap: domain capabilities query
> * @add_device: add device to iommu grouping
> * @remove_device: remove device from iommu grouping
> + * @bound_driver: called at BUS_NOTIFY_BOUND_DRIVER
> + * @unbind_driver: called at BUS_NOTIFY_UNBIND_DRIVER
> * @domain_get_attr: Query domain attributes
> * @domain_set_attr: Change domain attributes
> * @pgsize_bitmap: bitmap of supported page sizes
> @@ -115,6 +117,8 @@ struct iommu_ops {
> unsigned long cap);
> int (*add_device)(struct device *dev);
> void (*remove_device)(struct device *dev);
> + int (*bound_driver)(struct device *dev);
> + void (*unbind_driver)(struct device *dev);
> int (*device_group)(struct device *dev, unsigned int *groupid);
> int (*domain_get_attr)(struct iommu_domain *domain,
> enum iommu_attr attr, void *data);
> --
> 2.0.0.rc1.15.g7e76a2f
next prev parent reply other threads:[~2014-06-16 11:02 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-05-30 11:20 [PATCHv8 00/21] Tegra,SMMU update V8 Hiroshi Doyu
[not found] ` <1401448834-32659-1-git-send-email-hdoyu-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2014-05-30 11:20 ` [PATCHv8 01/21] of: introduce of_property_for_each_phandle_with_args() Hiroshi Doyu
2014-05-30 11:20 ` [PATCHv8 02/21] iommu/of: introduce a global iommu device list Hiroshi Doyu
2014-05-30 11:20 ` [PATCHv8 03/21] iommu/of: check if dependee iommu is ready or not Hiroshi Doyu
2014-05-30 11:20 ` [PATCHv8 04/21] driver/core: populate devices in order for IOMMUs Hiroshi Doyu
2014-05-30 11:20 ` [PATCHv8 05/21] iommu/core: add ops->{bound,unbind}_driver() Hiroshi Doyu
[not found] ` <1401448834-32659-6-git-send-email-hdoyu-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2014-06-16 11:02 ` Hiroshi Doyu [this message]
2014-05-30 11:20 ` [PATCHv8 06/21] ARM: tegra: create a DT header defining SWGROUP ID Hiroshi Doyu
2014-05-30 11:20 ` [PATCHv8 07/21] iommu/tegra: smmu: register device to iommu dynamically Hiroshi Doyu
2014-05-30 11:20 ` [PATCHv8 08/21] iommu/tegra: smmu: calculate ASID register offset by ID Hiroshi Doyu
2014-05-30 11:20 ` [PATCHv8 09/21] iommu/tegra: smmu: get swgroups from DT "iommus=" Hiroshi Doyu
2014-05-30 11:20 ` [PATCHv8 10/21] iommu/tegra: smmu: allow duplicate ASID wirte Hiroshi Doyu
2014-05-30 11:20 ` [PATCHv8 11/21] iommu/tegra: smmu: Rename hwgrp -> swgroups Hiroshi Doyu
2014-05-30 11:20 ` [PATCHv8 12/21] iommu/tegra: smmu: add SMMU to an global iommu list Hiroshi Doyu
2014-05-30 11:20 ` [PATCHv8 13/21] iommu/tegra124: smmu: optionaly AHB enables SMMU Hiroshi Doyu
2014-05-30 11:20 ` [PATCHv8 14/21] iommu/tegra124: smmu: convert swgroup ID to asid offset Hiroshi Doyu
2014-05-30 11:20 ` [PATCHv8 15/21] iommu/tegra124: smmu: add support platform data Hiroshi Doyu
[not found] ` <1401448834-32659-16-git-send-email-hdoyu-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2014-05-30 16:31 ` Stephen Warren
[not found] ` <5388B260.5000403-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org>
2014-05-30 16:39 ` Hiroshi Doyu
[not found] ` <87zjhzrzkq.fsf-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2014-05-30 16:40 ` Stephen Warren
2014-06-04 21:37 ` Thierry Reding
2014-05-30 11:20 ` [PATCHv8 16/21] iommu/tegra124: smmu: support more than 32 bit pa Hiroshi Doyu
2014-05-30 11:20 ` [PATCHv8 17/21] iommu/tegra124: smmu: {TLB,PTC} reset value per SoC Hiroshi Doyu
2014-05-30 11:20 ` [PATCHv8 18/21] iommu/tegra124: smmu: adjust TLB_FLUSH_ASID bit range Hiroshi Doyu
2014-05-30 11:20 ` [PATCHv8 19/21] iommu/tegra124: smmu: add multiple asid_security support Hiroshi Doyu
2014-05-30 11:20 ` [PATCHv8 20/21] ARM: dt: tegra124: add tegra,smmu entry Hiroshi Doyu
[not found] ` <1401448834-32659-21-git-send-email-hdoyu-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2014-05-30 16:30 ` Stephen Warren
2014-05-30 11:20 ` [PATCHv8 21/21] ARM: dt: tegra124: add sdhci iommus bindings Hiroshi Doyu
[not found] ` <1401448834-32659-22-git-send-email-hdoyu-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2014-05-30 16:34 ` Stephen Warren
[not found] ` <5388B2FD.7040307-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org>
2014-05-30 16:44 ` Hiroshi Doyu
[not found] ` <87y4xjrzc9.fsf-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2014-06-04 21:39 ` Thierry Reding
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=878uox15iz.fsf@nvidia.com \
--to=hdoyu-ddmlm1+adcrqt0dzr+alfa@public.gmane.org \
--cc=linux-tegra-u79uwXL29TY76Z2rM5mHXA@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).