* [PATCH] intel-iommu: Add device info into list before doing context mapping
@ 2011-12-17 13:06 Hao, Xudong
2011-12-20 16:07 ` Chris Wright
0 siblings, 1 reply; 6+ messages in thread
From: Hao, Xudong @ 2011-12-17 13:06 UTC (permalink / raw)
To: iommu, dwmw2; +Cc: linux-kernel, kvm, Zhang, Xiantao
This patch add device info into list before do context mapping. Because device info will be used by iommu_enable_dev_iotlb function, in this function, pci_enable_ats would not be called without this patch, so ATS did not enable while a PCI device which has ATS capability is assigned to a guest.
Signed-off-by: Xudong Hao <xudong.hao@intel.com>
Signed-off-by: Xiantao Zhang <xiantao.zhang@intel.com>
---
drivers/iommu/intel-iommu.c | 14 ++++++++------
1 files changed, 8 insertions(+), 6 deletions(-)
diff --git a/drivers/iommu/intel-iommu.c b/drivers/iommu/intel-iommu.c
index c0c7820..f0b5d38 100644
--- a/drivers/iommu/intel-iommu.c
+++ b/drivers/iommu/intel-iommu.c
@@ -2264,12 +2264,6 @@ static int domain_add_dev_info(struct dmar_domain *domain,
if (!info)
return -ENOMEM;
- ret = domain_context_mapping(domain, pdev, translation);
- if (ret) {
- free_devinfo_mem(info);
- return ret;
- }
-
info->segment = pci_domain_nr(pdev->bus);
info->bus = pdev->bus->number;
info->devfn = pdev->devfn;
@@ -2282,6 +2276,14 @@ static int domain_add_dev_info(struct dmar_domain *domain,
pdev->dev.archdata.iommu = info;
spin_unlock_irqrestore(&device_domain_lock, flags);
+ ret = domain_context_mapping(domain, pdev, translation);
+ if (ret) {
+ list_del(&info->link);
+ list_del(&info->global);
+ free_devinfo_mem(info);
+ return ret;
+ }
+
return 0;
}
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] intel-iommu: Add device info into list before doing context mapping
2011-12-17 13:06 [PATCH] intel-iommu: Add device info into list before doing context mapping Hao, Xudong
@ 2011-12-20 16:07 ` Chris Wright
2011-12-21 2:04 ` Hao, Xudong
0 siblings, 1 reply; 6+ messages in thread
From: Chris Wright @ 2011-12-20 16:07 UTC (permalink / raw)
To: Hao, Xudong; +Cc: iommu, dwmw2, Zhang, Xiantao, linux-kernel, kvm
* Hao, Xudong (xudong.hao@intel.com) wrote:
> @@ -2282,6 +2276,14 @@ static int domain_add_dev_info(struct dmar_domain *domain,
> pdev->dev.archdata.iommu = info;
> spin_unlock_irqrestore(&device_domain_lock, flags);
>
> + ret = domain_context_mapping(domain, pdev, translation);
> + if (ret) {
> + list_del(&info->link);
> + list_del(&info->global);
At the very least, this is not correct locking.
> + free_devinfo_mem(info);
> + return ret;
> + }
> +
^ permalink raw reply [flat|nested] 6+ messages in thread
* RE: [PATCH] intel-iommu: Add device info into list before doing context mapping
2011-12-20 16:07 ` Chris Wright
@ 2011-12-21 2:04 ` Hao, Xudong
2011-12-21 18:41 ` Chris Wright
0 siblings, 1 reply; 6+ messages in thread
From: Hao, Xudong @ 2011-12-21 2:04 UTC (permalink / raw)
To: Chris Wright, dwmw2; +Cc: iommu, Zhang, Xiantao, linux-kernel, kvm
Yes, Chris, thanks your comments.
How about this one?
---
drivers/iommu/intel-iommu.c | 16 ++++++++++------
1 files changed, 10 insertions(+), 6 deletions(-)
diff --git a/drivers/iommu/intel-iommu.c b/drivers/iommu/intel-iommu.c
index a004c39..0fc5efd 100644
--- a/drivers/iommu/intel-iommu.c
+++ b/drivers/iommu/intel-iommu.c
@@ -2264,12 +2264,6 @@ static int domain_add_dev_info(struct dmar_domain *domain,
if (!info)
return -ENOMEM;
- ret = domain_context_mapping(domain, pdev, translation);
- if (ret) {
- free_devinfo_mem(info);
- return ret;
- }
-
info->segment = pci_domain_nr(pdev->bus);
info->bus = pdev->bus->number;
info->devfn = pdev->devfn;
@@ -2282,6 +2276,16 @@ static int domain_add_dev_info(struct dmar_domain *domain,
pdev->dev.archdata.iommu = info;
spin_unlock_irqrestore(&device_domain_lock, flags);
+ ret = domain_context_mapping(domain, pdev, translation);
+ if (ret) {
+ spin_lock_irqsave(&device_domain_lock, flags);
+ list_del(&info->link);
+ list_del(&info->global);
+ spin_unlock_irqrestore(&device_domain_lock, flags);
+ free_devinfo_mem(info);
+ return ret;
+ }
+
return 0;
}
> -----Original Message-----
> From: Chris Wright [mailto:chrisw@sous-sol.org]
> Sent: Wednesday, December 21, 2011 12:08 AM
> To: Hao, Xudong
> Cc: iommu@lists.linux-foundation.org; dwmw2@infradead.org; Zhang, Xiantao;
> linux-kernel@vger.kernel.org; kvm@vger.kernel.org
> Subject: Re: [PATCH] intel-iommu: Add device info into list before doing context
> mapping
>
> * Hao, Xudong (xudong.hao@intel.com) wrote:
> > @@ -2282,6 +2276,14 @@ static int domain_add_dev_info(struct
> dmar_domain *domain,
> > pdev->dev.archdata.iommu = info;
> > spin_unlock_irqrestore(&device_domain_lock, flags);
> >
> > + ret = domain_context_mapping(domain, pdev, translation);
> > + if (ret) {
> > + list_del(&info->link);
> > + list_del(&info->global);
>
> At the very least, this is not correct locking.
>
> > + free_devinfo_mem(info);
> > + return ret;
> > + }
> > +
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] intel-iommu: Add device info into list before doing context mapping
2011-12-21 2:04 ` Hao, Xudong
@ 2011-12-21 18:41 ` Chris Wright
2011-12-21 18:48 ` Chris Wright
0 siblings, 1 reply; 6+ messages in thread
From: Chris Wright @ 2011-12-21 18:41 UTC (permalink / raw)
To: Hao, Xudong; +Cc: Chris Wright, dwmw2, iommu, linux-kernel, Zhang, Xiantao, kvm
* Hao, Xudong (xudong.hao@intel.com) wrote:
> Yes, Chris, thanks your comments.
> How about this one?
Yes, it gets the locking right.
Also makes host device and guest assigned device go through the same order:
alloc_devinfo and init
lock; place info on lists; unlock
domain_context_mapping()
The patch itself is whitespace damaged and does not apply. Please fix
and feel free to add my:
Acked-by: Chris Wright <chrisw@sous-sol.org>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] intel-iommu: Add device info into list before doing context mapping
2011-12-21 18:41 ` Chris Wright
@ 2011-12-21 18:48 ` Chris Wright
0 siblings, 0 replies; 6+ messages in thread
From: Chris Wright @ 2011-12-21 18:48 UTC (permalink / raw)
To: Hao, Xudong; +Cc: Chris Wright, dwmw2, iommu, linux-kernel, Zhang, Xiantao, kvm
* Chris Wright (chrisw@sous-sol.org) wrote:
> * Hao, Xudong (xudong.hao@intel.com) wrote:
> > Yes, Chris, thanks your comments.
> > How about this one?
>
> Yes, it gets the locking right.
Sorry, I missed one other problem on the error path. You need to also
update pdev->dev.archdata.iommu to NULL (otherwise it is left pointing
to freed memory).
> Also makes host device and guest assigned device go through the same order:
>
> alloc_devinfo and init
> lock; place info on lists; unlock
> domain_context_mapping()
>
> The patch itself is whitespace damaged and does not apply. Please fix
> and feel free to add my:
>
> Acked-by: Chris Wright <chrisw@sous-sol.org>
^ permalink raw reply [flat|nested] 6+ messages in thread
* RE: [PATCH] intel-iommu: Add device info into list before doing context mapping
@ 2011-12-20 10:47 Hao, Xudong
0 siblings, 0 replies; 6+ messages in thread
From: Hao, Xudong @ 2011-12-20 10:47 UTC (permalink / raw)
To: iommu, dwmw2; +Cc: linux-kernel, kvm, Zhang, Xiantao
Hi, David
Do you have any comments for this patch?
Thanks,
-Xudong
> -----Original Message-----
> From: Hao, Xudong
> Sent: Saturday, December 17, 2011 9:07 PM
> To: 'iommu@lists.linux-foundation.org'; 'dwmw2@infradead.org'
> Cc: 'linux-kernel@vger.kernel.org'; 'kvm@vger.kernel.org'; Zhang, Xiantao
> Subject: [PATCH] intel-iommu: Add device info into list before doing context
> mapping
>
> This patch add device info into list before do context mapping. Because device
> info will be used by iommu_enable_dev_iotlb function, in this function,
> pci_enable_ats would not be called without this patch, so ATS did not enable
> while a PCI device which has ATS capability is assigned to a guest.
>
> Signed-off-by: Xudong Hao <xudong.hao@intel.com>
> Signed-off-by: Xiantao Zhang <xiantao.zhang@intel.com>
> ---
> drivers/iommu/intel-iommu.c | 14 ++++++++------
> 1 files changed, 8 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/iommu/intel-iommu.c b/drivers/iommu/intel-iommu.c index
> c0c7820..f0b5d38 100644
> --- a/drivers/iommu/intel-iommu.c
> +++ b/drivers/iommu/intel-iommu.c
> @@ -2264,12 +2264,6 @@ static int domain_add_dev_info(struct
> dmar_domain *domain,
> if (!info)
> return -ENOMEM;
>
> - ret = domain_context_mapping(domain, pdev, translation);
> - if (ret) {
> - free_devinfo_mem(info);
> - return ret;
> - }
> -
> info->segment = pci_domain_nr(pdev->bus);
> info->bus = pdev->bus->number;
> info->devfn = pdev->devfn;
> @@ -2282,6 +2276,14 @@ static int domain_add_dev_info(struct
> dmar_domain *domain,
> pdev->dev.archdata.iommu = info;
> spin_unlock_irqrestore(&device_domain_lock, flags);
>
> + ret = domain_context_mapping(domain, pdev, translation);
> + if (ret) {
> + list_del(&info->link);
> + list_del(&info->global);
> + free_devinfo_mem(info);
> + return ret;
> + }
> +
> return 0;
> }
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2011-12-21 18:48 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-12-17 13:06 [PATCH] intel-iommu: Add device info into list before doing context mapping Hao, Xudong
2011-12-20 16:07 ` Chris Wright
2011-12-21 2:04 ` Hao, Xudong
2011-12-21 18:41 ` Chris Wright
2011-12-21 18:48 ` Chris Wright
2011-12-20 10:47 Hao, Xudong
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.