[PATCH] amd-iommu: detach device explicitly before attaching it to a new domain

Joerg Roedel joerg.roedel at amd.com
Tue Jun 9 02:08:01 PDT 2009


On Mon, Jun 08, 2009 at 01:47:33PM -0700, Chris Wright wrote:
> From: Joerg Roedel <joerg.roedel at amd.com>
> 
> This fixes a bug with a device that could not be assigned to a KVM guest
> because it is still assigned to a dma_ops protection domain.
> 
> [chrisw: simply remove WARN_ON(), will always fire since dev->driver
> will be pci-sub]
> Signed-off-by: Chris Wright <chrisw at sous-sol.org>
> 
> ---
>  arch/x86/kernel/amd_iommu.c |    2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> --- a/arch/x86/kernel/amd_iommu.c
> +++ b/arch/x86/kernel/amd_iommu.c
> @@ -1842,7 +1842,7 @@ static int amd_iommu_attach_device(struc
>  
>  	old_domain = domain_for_device(devid);
>  	if (old_domain)
> -		return -EBUSY;
> +		detach_device(old_domain, devid);
>  
>  	attach_device(iommu, domain, devid);

I prepared another fix for this issue. See patch attached. But this
patch needs stable backporting so I apply it for upstream inclusion too.

Joerg



More information about the iommu mailing list