linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] iommu: set group default domain before creating direct mappings
@ 2019-12-10 18:56 Jerry Snitselaar
  2019-12-11  0:54 ` Lu Baolu
  0 siblings, 1 reply; 3+ messages in thread
From: Jerry Snitselaar @ 2019-12-10 18:56 UTC (permalink / raw)
  To: linux-kernel; +Cc: Joerg Roedel, Lu Baolu, iommu, stable

iommu_group_create_direct_mappings uses group->default_domain, but
right after it is called, request_default_domain_for_dev calls
iommu_domain_free for the default domain, and sets the group default
domain to a different domain. Move the
iommu_group_create_direct_mappings call to after the group default
domain is set, so the direct mappings get associated with that domain.

Cc: Joerg Roedel <jroedel@suse.de>
Cc: Lu Baolu <baolu.lu@linux.intel.com> 
Cc: iommu@lists.linux-foundation.org
Cc: stable@vger.kernel.org
Fixes: 7423e01741dd ("iommu: Add API to request DMA domain for device")
Signed-off-by: Jerry Snitselaar <jsnitsel@redhat.com>
---
 drivers/iommu/iommu.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c
index db7bfd4f2d20..fa908179b80b 100644
--- a/drivers/iommu/iommu.c
+++ b/drivers/iommu/iommu.c
@@ -2282,13 +2282,13 @@ request_default_domain_for_dev(struct device *dev, unsigned long type)
 		goto out;
 	}
 
-	iommu_group_create_direct_mappings(group, dev);
-
 	/* Make the domain the default for this group */
 	if (group->default_domain)
 		iommu_domain_free(group->default_domain);
 	group->default_domain = domain;
 
+	iommu_group_create_direct_mappings(group, dev);
+
 	dev_info(dev, "Using iommu %s mapping\n",
 		 type == IOMMU_DOMAIN_DMA ? "dma" : "direct");
 
-- 
2.24.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] iommu: set group default domain before creating direct mappings
  2019-12-10 18:56 [PATCH] iommu: set group default domain before creating direct mappings Jerry Snitselaar
@ 2019-12-11  0:54 ` Lu Baolu
  2019-12-17 10:45   ` Joerg Roedel
  0 siblings, 1 reply; 3+ messages in thread
From: Lu Baolu @ 2019-12-11  0:54 UTC (permalink / raw)
  To: Jerry Snitselaar, linux-kernel; +Cc: baolu.lu, Joerg Roedel, iommu, stable

Hi,

On 12/11/19 2:56 AM, Jerry Snitselaar wrote:
> iommu_group_create_direct_mappings uses group->default_domain, but
> right after it is called, request_default_domain_for_dev calls
> iommu_domain_free for the default domain, and sets the group default
> domain to a different domain. Move the
> iommu_group_create_direct_mappings call to after the group default
> domain is set, so the direct mappings get associated with that domain.
> 
> Cc: Joerg Roedel <jroedel@suse.de>
> Cc: Lu Baolu <baolu.lu@linux.intel.com>

This fix looks good to me.

Reviewed-by: Lu Baolu <baolu.lu@linux.intel.com>

Best regards,
baolu

> Cc: iommu@lists.linux-foundation.org
> Cc: stable@vger.kernel.org
> Fixes: 7423e01741dd ("iommu: Add API to request DMA domain for device")
> Signed-off-by: Jerry Snitselaar <jsnitsel@redhat.com>
> ---
>   drivers/iommu/iommu.c | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c
> index db7bfd4f2d20..fa908179b80b 100644
> --- a/drivers/iommu/iommu.c
> +++ b/drivers/iommu/iommu.c
> @@ -2282,13 +2282,13 @@ request_default_domain_for_dev(struct device *dev, unsigned long type)
>   		goto out;
>   	}
>   
> -	iommu_group_create_direct_mappings(group, dev);
> -
>   	/* Make the domain the default for this group */
>   	if (group->default_domain)
>   		iommu_domain_free(group->default_domain);
>   	group->default_domain = domain;
>   
> +	iommu_group_create_direct_mappings(group, dev);
> +
>   	dev_info(dev, "Using iommu %s mapping\n",
>   		 type == IOMMU_DOMAIN_DMA ? "dma" : "direct");
>   
> 

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] iommu: set group default domain before creating direct mappings
  2019-12-11  0:54 ` Lu Baolu
@ 2019-12-17 10:45   ` Joerg Roedel
  0 siblings, 0 replies; 3+ messages in thread
From: Joerg Roedel @ 2019-12-17 10:45 UTC (permalink / raw)
  To: Lu Baolu; +Cc: Jerry Snitselaar, linux-kernel, iommu, stable

On Wed, Dec 11, 2019 at 08:54:21AM +0800, Lu Baolu wrote:
> On 12/11/19 2:56 AM, Jerry Snitselaar wrote:
> > iommu_group_create_direct_mappings uses group->default_domain, but
> > right after it is called, request_default_domain_for_dev calls
> > iommu_domain_free for the default domain, and sets the group default
> > domain to a different domain. Move the
> > iommu_group_create_direct_mappings call to after the group default
> > domain is set, so the direct mappings get associated with that domain.
> > 
> > Cc: Joerg Roedel <jroedel@suse.de>
> > Cc: Lu Baolu <baolu.lu@linux.intel.com>
> 
> This fix looks good to me.
> 
> Reviewed-by: Lu Baolu <baolu.lu@linux.intel.com>

Applied, thanks.


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-12-17 10:45 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-12-10 18:56 [PATCH] iommu: set group default domain before creating direct mappings Jerry Snitselaar
2019-12-11  0:54 ` Lu Baolu
2019-12-17 10:45   ` Joerg Roedel

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).