diff mbox

[2/3] iommu/fsl: Fix the device domain attach condition.

Message ID 20140704105430.GE13434@8bytes.org (mailing list archive)
State Not Applicable
Delegated to: Scott Wood
Headers show

Commit Message

Joerg Roedel July 4, 2014, 10:54 a.m. UTC
Hmm,

On Tue, Jun 24, 2014 at 07:27:16PM +0530, Varun Sethi wrote:
> -	old_domain_info = find_domain(dev);
> +	old_domain_info = dev->archdata.iommu_domain;
>  	if (old_domain_info && old_domain_info->domain != dma_domain) {
>  		spin_unlock_irqrestore(&device_domain_lock, flags);
>  		detach_device(dev, old_domain_info->domain);

Wouldn't this set dev->archdata.iommu_domain to NULL anyway, so that ...

> @@ -399,7 +394,7 @@ static void attach_device(struct fsl_dma_domain *dma_domain, int liodn, struct d
>  	 * the info for the first LIODN as all
>  	 * LIODNs share the same domain
>  	 */
> -	if (!old_domain_info)
> +	if (!dev->archdata.iommu_domain)
>  		dev->archdata.iommu_domain = info;

We already know that it _must_ be NULL here?

>  	spin_unlock_irqrestore(&device_domain_lock, flags);

This would shrink down the patch to:

Comments

Varun Sethi July 4, 2014, 12:50 p.m. UTC | #1
> -----Original Message-----
> From: Joerg Roedel [mailto:joro@8bytes.org]
> Sent: Friday, July 04, 2014 4:25 PM
> To: Sethi Varun-B16395
> Cc: iommu@lists.linux-foundation.org; linux-kernel@vger.kernel.org;
> linuxppc-dev@lists.ozlabs.org; alex.williamson@redhat.com
> Subject: Re: [PATCH 2/3] iommu/fsl: Fix the device domain attach
> condition.
> 
> Hmm,
> 
> On Tue, Jun 24, 2014 at 07:27:16PM +0530, Varun Sethi wrote:
> > -	old_domain_info = find_domain(dev);
> > +	old_domain_info = dev->archdata.iommu_domain;
> >  	if (old_domain_info && old_domain_info->domain != dma_domain) {
> >  		spin_unlock_irqrestore(&device_domain_lock, flags);
> >  		detach_device(dev, old_domain_info->domain);
> 
> Wouldn't this set dev->archdata.iommu_domain to NULL anyway, so that ...
> 
Not for the case where device has multiple LIODNs.

> > @@ -399,7 +394,7 @@ static void attach_device(struct fsl_dma_domain
> *dma_domain, int liodn, struct d
> >  	 * the info for the first LIODN as all
> >  	 * LIODNs share the same domain
> >  	 */
> > -	if (!old_domain_info)
> > +	if (!dev->archdata.iommu_domain)
> >  		dev->archdata.iommu_domain = info;
> 
> We already know that it _must_ be NULL here?
> 

That won't be true for devices having multiple LIODNs

> >  	spin_unlock_irqrestore(&device_domain_lock, flags);
> 
> This would shrink down the patch to:
> 
> diff --git a/drivers/iommu/fsl_pamu_domain.c
> b/drivers/iommu/fsl_pamu_domain.c index 93072ba..d21b554 100644
> --- a/drivers/iommu/fsl_pamu_domain.c
> +++ b/drivers/iommu/fsl_pamu_domain.c
> @@ -399,8 +399,7 @@ static void attach_device(struct fsl_dma_domain
> *dma_domain, int liodn, struct d
>  	 * the info for the first LIODN as all
>  	 * LIODNs share the same domain
>  	 */
> -	if (!old_domain_info)
> -		dev->archdata.iommu_domain = info;
> +	dev->archdata.iommu_domain = info;

For devices having multiple LIODNs, we don't want to overwrite the info.

-Varun
diff mbox

Patch

diff --git a/drivers/iommu/fsl_pamu_domain.c b/drivers/iommu/fsl_pamu_domain.c
index 93072ba..d21b554 100644
--- a/drivers/iommu/fsl_pamu_domain.c
+++ b/drivers/iommu/fsl_pamu_domain.c
@@ -399,8 +399,7 @@  static void attach_device(struct fsl_dma_domain *dma_domain, int liodn, struct d
 	 * the info for the first LIODN as all
 	 * LIODNs share the same domain
 	 */
-	if (!old_domain_info)
-		dev->archdata.iommu_domain = info;
+	dev->archdata.iommu_domain = info;
 	spin_unlock_irqrestore(&device_domain_lock, flags);
 
 }