public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Will Deacon <will.deacon@arm.com>
To: Joerg Roedel <joro@8bytes.org>
Cc: iommu@lists.linux-foundation.org,
	Alex Williamson <alex.williamson@redhat.com>,
	linux-kernel@vger.kernel.org, Joerg Roedel <jroedel@suse.de>
Subject: Re: [PATCH 8/8] iommu: Move default domain allocation to iommu_group_get_for_dev()
Date: Thu, 29 Oct 2015 18:22:49 +0000	[thread overview]
Message-ID: <20151029182248.GI3440@arm.com> (raw)
In-Reply-To: <1445464303-18206-9-git-send-email-joro@8bytes.org>

Hi Joerg,

Looking at this from an SMMU perspective, I think there's an issue
with attaching to the default domain like this.

On Wed, Oct 21, 2015 at 11:51:43PM +0200, Joerg Roedel wrote:
> From: Joerg Roedel <jroedel@suse.de>
> 
> Now that the iommu core support for iommu groups is not
> pci-centric anymore, we can move default domain allocation
> to the bus independent iommu_group_get_for_dev() function.
> 
> Signed-off-by: Joerg Roedel <jroedel@suse.de>
> ---
>  drivers/iommu/iommu.c | 18 ++++++++++--------
>  1 file changed, 10 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c
> index e2b5526..abae363 100644
> --- a/drivers/iommu/iommu.c
> +++ b/drivers/iommu/iommu.c
> @@ -810,14 +810,6 @@ struct iommu_group *pci_device_group(struct device *dev)
>  	if (IS_ERR(group))
>  		return NULL;
>  
> -	/*
> -	 * Try to allocate a default domain - needs support from the
> -	 * IOMMU driver.
> -	 */
> -	group->default_domain = __iommu_domain_alloc(pdev->dev.bus,
> -						     IOMMU_DOMAIN_DMA);
> -	group->domain = group->default_domain;
> -
>  	return group;
>  }
>  
> @@ -849,6 +841,16 @@ struct iommu_group *iommu_group_get_for_dev(struct device *dev)
>  	if (IS_ERR(group))
>  		return group;
>  
> +	/*
> +	 * Try to allocate a default domain - needs support from the
> +	 * IOMMU driver.
> +	 */
> +	if (!group->default_domain) {
> +		group->default_domain = __iommu_domain_alloc(dev->bus,
> +							     IOMMU_DOMAIN_DMA);
> +		group->domain = group->default_domain;
> +	}
> +
>  	ret = iommu_group_add_device(group, dev);
>  	if (ret) {
>  		iommu_group_put(group);

The call to iommu_group_get_for_dev in arm_smmu_add_device will end up
calling __iommu_attach_device, since group->domain will now be initialised
by the code above. This means the SMMU driver will see an ->attach_dev
call for a device that is part-way through an ->add_device callback and
will be missing the initialisation necessary for us to idenfity the SMMU
instance to which is corresponds. In fact, the iommudata for the group
won't be initialised at all, so the whole thing will fail afaict.

Note that I haven't actually taken this for a spin, so I could be missing
something.

Will

  reply	other threads:[~2015-10-29 18:22 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-10-21 21:51 [PATCH 0/8] iommu: Make core iommu-groups code more generic Joerg Roedel
2015-10-21 21:51 ` [PATCH 1/8] iommu: Revive device_group iommu-ops call-back Joerg Roedel
2015-10-21 21:51 ` [PATCH 2/8] iommu: Export and rename iommu_group_get_for_pci_dev() Joerg Roedel
2015-10-21 21:51 ` [PATCH 3/8] iommu: Add generic_device_group() function Joerg Roedel
2015-10-21 21:51 ` [PATCH 4/8] iommu: Add device_group call-back to x86 iommu drivers Joerg Roedel
2015-10-21 21:51 ` [PATCH 5/8] iommu/fsl: Convert to device_group call-back Joerg Roedel
2015-10-21 21:51 ` [PATCH 6/8] iommu/arm-smmu: Switch " Joerg Roedel
2015-10-21 21:51 ` [PATCH 7/8] iommu: Remove is_pci_dev() fall-back from iommu_group_get_for_dev Joerg Roedel
2015-10-21 21:51 ` [PATCH 8/8] iommu: Move default domain allocation to iommu_group_get_for_dev() Joerg Roedel
2015-10-29 18:22   ` Will Deacon [this message]
2015-10-30 14:13     ` Joerg Roedel
2015-11-19  9:06 ` [PATCH 0/8] iommu: Make core iommu-groups code more generic Yong Wu
     [not found] ` <1447920801.27650.49.camel@mhfsdcap03>
2015-11-19 13:41   ` Joerg Roedel
2015-12-01 11:29     ` Yong Wu
2015-12-01 15:15       ` Joerg Roedel

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=20151029182248.GI3440@arm.com \
    --to=will.deacon@arm.com \
    --cc=alex.williamson@redhat.com \
    --cc=iommu@lists.linux-foundation.org \
    --cc=joro@8bytes.org \
    --cc=jroedel@suse.de \
    --cc=linux-kernel@vger.kernel.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