Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1251823

[PATCH 05/12] iommu/amd: Set alias DTE in do_attach/do_detach

From Joerg Roedel <joro@8bytes.org>
Newsgroups linux.kernel
Subject [PATCH 05/12] iommu/amd: Set alias DTE in do_attach/do_detach
Date 2015-10-20 17:40 +0200
Message-ID <qlHb5-7U3-41@gated-at.bofh.it> (permalink)
References <qlHb4-7U3-5@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


From: Joerg Roedel <jroedel@suse.de>

With this we don't have to create dev_data entries for
non-existent devices (which only exist as request-ids).

Signed-off-by: Joerg Roedel <jroedel@suse.de>
---
 drivers/iommu/amd_iommu.c | 17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)

diff --git a/drivers/iommu/amd_iommu.c b/drivers/iommu/amd_iommu.c
index d47c4b1..187a8bf 100644
--- a/drivers/iommu/amd_iommu.c
+++ b/drivers/iommu/amd_iommu.c
@@ -1114,11 +1114,15 @@ static int device_flush_iotlb(struct iommu_dev_data *dev_data,
 static int device_flush_dte(struct iommu_dev_data *dev_data)
 {
 	struct amd_iommu *iommu;
+	u16 alias;
 	int ret;
 
 	iommu = amd_iommu_rlookup_table[dev_data->devid];
+	alias = amd_iommu_alias_table[dev_data->devid];
 
 	ret = iommu_flush_dte(iommu, dev_data->devid);
+	if (!ret && alias != dev_data->devid)
+		ret = iommu_flush_dte(iommu, alias);
 	if (ret)
 		return ret;
 
@@ -1984,27 +1988,33 @@ static void do_attach(struct iommu_dev_data *dev_data,
 		      struct protection_domain *domain)
 {
 	struct amd_iommu *iommu;
+	u16 alias;
 	bool ats;
 
 	iommu = amd_iommu_rlookup_table[dev_data->devid];
+	alias = amd_iommu_alias_table[dev_data->devid];
 	ats   = dev_data->ats.enabled;
 
 	/* Update data structures */
 	dev_data->domain = domain;
 	list_add(&dev_data->list, &domain->dev_list);
-	set_dte_entry(dev_data->devid, domain, ats);
 
 	/* Do reference counting */
 	domain->dev_iommu[iommu->index] += 1;
 	domain->dev_cnt                 += 1;
 
-	/* Flush the DTE entry */
+	/* Update device table */
+	set_dte_entry(dev_data->devid, domain, ats);
+	if (alias != dev_data->devid)
+		set_dte_entry(dev_data->devid, domain, ats);
+
 	device_flush_dte(dev_data);
 }
 
 static void do_detach(struct iommu_dev_data *dev_data)
 {
 	struct amd_iommu *iommu;
+	u16 alias;
 
 	/*
 	 * First check if the device is still attached. It might already
@@ -2016,6 +2026,7 @@ static void do_detach(struct iommu_dev_data *dev_data)
 		return;
 
 	iommu = amd_iommu_rlookup_table[dev_data->devid];
+	alias = amd_iommu_alias_table[dev_data->devid];
 
 	/* decrease reference counters */
 	dev_data->domain->dev_iommu[iommu->index] -= 1;
@@ -2025,6 +2036,8 @@ static void do_detach(struct iommu_dev_data *dev_data)
 	dev_data->domain = NULL;
 	list_del(&dev_data->list);
 	clear_dte_entry(dev_data->devid);
+	if (alias != dev_data->devid)
+		clear_dte_entry(alias);
 
 	/* Flush the DTE entry */
 	device_flush_dte(dev_data);
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH 00/12] AMD IOMMU alias handling cleanups and code removal Joerg Roedel <joro@8bytes.org> - 2015-10-20 17:40 +0200
  [PATCH 12/12] iommu/amd: Remove find_last_devid_on_pci() Joerg Roedel <joro@8bytes.org> - 2015-10-20 17:40 +0200
  [PATCH 10/12] iommu/amd: Initialize amd_iommu_last_bdf for DEV_ALL Joerg Roedel <joro@8bytes.org> - 2015-10-20 17:40 +0200
  [PATCH 03/12] iommu/amd: Don't disable IRQs in __detach_device Joerg Roedel <joro@8bytes.org> - 2015-10-20 17:40 +0200
  [PATCH 11/12] iommu/amd: Remove first/last_device handling Joerg Roedel <joro@8bytes.org> - 2015-10-20 17:40 +0200
  [PATCH 06/12] iommu/amd: Remove old alias handling code Joerg Roedel <joro@8bytes.org> - 2015-10-20 17:40 +0200
  [PATCH 01/12] iommu/amd: Do not BUG_ON in __detach_device() Joerg Roedel <joro@8bytes.org> - 2015-10-20 17:40 +0200
  [PATCH 02/12] iommu/amd: Do not iterate over alias-list in __[attach|detach]_device Joerg Roedel <joro@8bytes.org> - 2015-10-20 17:40 +0200
  [PATCH 09/12] iommu/amd: Cleanup buffer allocation Joerg Roedel <joro@8bytes.org> - 2015-10-20 17:40 +0200
  [PATCH 05/12] iommu/amd: Set alias DTE in do_attach/do_detach Joerg Roedel <joro@8bytes.org> - 2015-10-20 17:40 +0200
  [PATCH 07/12] iommu/amd: Align DTE flag definitions Joerg Roedel <joro@8bytes.org> - 2015-10-20 17:40 +0200

csiph-web