All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/3] dmar: Fix domain id not update to newly create
@ 2013-12-13  5:16 Youquan Song
  2013-12-13  5:16 ` [PATCH 2/3] dmar: Move the confuse comments to proper place Youquan Song
  0 siblings, 1 reply; 3+ messages in thread
From: Youquan Song @ 2013-12-13  5:16 UTC (permalink / raw)
  To: David Woodhouse, David Woodhouse
  Cc: iommu, linux-kernel, Youquan Song, Youquan Song, zhiyuan.zhou

At domain_context_mapping_one(), if the domain is still not assign domain id,
it will assign a new domain_id for it, but the newly creating domain id is not
update to domain, so the domain will keep an unkown domain id.

It will cause the issues: like flush wrong domain in iommu->flush.flush_iotlb,
and free/release wrong domain.

Tested-by: Zhiyuan Zhou <zhiyuan.zhou@intel.com>
Signed-off-by: Youquan Song <youquan.song@intel.com>
---
 drivers/iommu/intel-iommu.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/drivers/iommu/intel-iommu.c b/drivers/iommu/intel-iommu.c
index 43b9bfe..9cd522f 100644
--- a/drivers/iommu/intel-iommu.c
+++ b/drivers/iommu/intel-iommu.c
@@ -1625,6 +1625,7 @@ static int domain_context_mapping_one(struct dmar_domain *domain, int segment,
 		}
 	}
 
+	domain->id = id;
 	context_set_domain_id(context, id);
 
 	if (translation != CONTEXT_TT_PASS_THROUGH) {
-- 
1.7.7.4


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

* [PATCH 2/3] dmar: Move the confuse comments to proper place
  2013-12-13  5:16 [PATCH 1/3] dmar: Fix domain id not update to newly create Youquan Song
@ 2013-12-13  5:16 ` Youquan Song
  2013-12-13  5:16   ` [PATCH 3/3] dmar: reduce loop to find multi-devices owned by IOMMU Youquan Song
  0 siblings, 1 reply; 3+ messages in thread
From: Youquan Song @ 2013-12-13  5:16 UTC (permalink / raw)
  To: David Woodhouse, David Woodhouse
  Cc: iommu, linux-kernel, Youquan Song, Youquan Song, zhiyuan.zhou

the "found=1" should be "there are other device owned by the domain", the
comments is put at wrong place and make the code reviewing confuse, so move it
to the correct place.

Signed-off-by: Youquan Song <youquan.song@intel.com>
---
 drivers/iommu/intel-iommu.c |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/iommu/intel-iommu.c b/drivers/iommu/intel-iommu.c
index 9cd522f..aa821fc 100644
--- a/drivers/iommu/intel-iommu.c
+++ b/drivers/iommu/intel-iommu.c
@@ -3813,10 +3813,6 @@ static void domain_remove_one_dev_info(struct dmar_domain *domain,
 				continue;
 		}
 
-		/* if there is no other devices under the same iommu
-		 * owned by this domain, clear this iommu in iommu_bmp
-		 * update iommu count and coherency
-		 */
 		if (iommu == device_to_iommu(info->segment, info->bus,
 					    info->devfn))
 			found = 1;
@@ -3824,6 +3820,10 @@ static void domain_remove_one_dev_info(struct dmar_domain *domain,
 
 	spin_unlock_irqrestore(&device_domain_lock, flags);
 
+	/* if there is no other devices under the same iommu
+	 * owned by this domain, clear this iommu in iommu_bmp
+	 * update iommu count and coherency
+	 */
 	if (found == 0) {
 		unsigned long tmp_flags;
 		spin_lock_irqsave(&domain->iommu_lock, tmp_flags);
-- 
1.7.7.4


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

* [PATCH 3/3] dmar: reduce loop to find multi-devices owned by IOMMU
  2013-12-13  5:16 ` [PATCH 2/3] dmar: Move the confuse comments to proper place Youquan Song
@ 2013-12-13  5:16   ` Youquan Song
  0 siblings, 0 replies; 3+ messages in thread
From: Youquan Song @ 2013-12-13  5:16 UTC (permalink / raw)
  To: David Woodhouse, David Woodhouse
  Cc: iommu, linux-kernel, Youquan Song, Youquan Song, zhiyuan.zhou

When try to find if the iommu owns other devices in the domain except the 
device will be moved. It will loop all devices under the domain if the removed
device is the first device in domain devices list.

This patch will improve it and it only loop before find the removed device and
 one of other device, so save the loop time and make the code more clear.

Signed-off-by: Youquan Song <youquan.song@intel.com>
---
 drivers/iommu/intel-iommu.c |   15 ++++++---------
 1 files changed, 6 insertions(+), 9 deletions(-)

diff --git a/drivers/iommu/intel-iommu.c b/drivers/iommu/intel-iommu.c
index aa821fc..9f3bf3f 100644
--- a/drivers/iommu/intel-iommu.c
+++ b/drivers/iommu/intel-iommu.c
@@ -3785,7 +3785,7 @@ static void domain_remove_one_dev_info(struct dmar_domain *domain,
 	struct device_domain_info *info, *tmp;
 	struct intel_iommu *iommu;
 	unsigned long flags;
-	int found = 0;
+	int found = 0, del = 0;
 
 	iommu = device_to_iommu(pci_domain_nr(pdev->bus), pdev->bus->number,
 				pdev->devfn);
@@ -3806,16 +3806,13 @@ static void domain_remove_one_dev_info(struct dmar_domain *domain,
 			free_devinfo_mem(info);
 
 			spin_lock_irqsave(&device_domain_lock, flags);
-
-			if (found)
-				break;
-			else
-				continue;
-		}
-
-		if (iommu == device_to_iommu(info->segment, info->bus,
+			del = 1;
+		} else if (iommu == device_to_iommu(info->segment, info->bus,
 					    info->devfn))
 			found = 1;
+
+		if (found & del)
+			break;
 	}
 
 	spin_unlock_irqrestore(&device_domain_lock, flags);
-- 
1.7.7.4


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

end of thread, other threads:[~2013-12-12 16:40 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-12-13  5:16 [PATCH 1/3] dmar: Fix domain id not update to newly create Youquan Song
2013-12-13  5:16 ` [PATCH 2/3] dmar: Move the confuse comments to proper place Youquan Song
2013-12-13  5:16   ` [PATCH 3/3] dmar: reduce loop to find multi-devices owned by IOMMU Youquan Song

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.