linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/3] iommu/vt-d: Add support for ACPI/SATC table
@ 2021-02-02  4:40 Lu Baolu
  2021-02-02  4:40 ` [PATCH 1/3] iommu/vt-d: Add new enum value and structure for SATC Lu Baolu
                   ` (3 more replies)
  0 siblings, 4 replies; 16+ messages in thread
From: Lu Baolu @ 2021-02-02  4:40 UTC (permalink / raw)
  To: iommu; +Cc: Yian Chen, Joerg Roedel, Ashok Raj, linux-kernel, Lu Baolu

Intel platform VT-d (v3.2) comes with a new type of DMAR subtable
SATC. The SATC table includes a list of SoC integrated devices
that require SATC. OS software can use this table to enable ATS
only for the devices in the list.

Yian Chen (3):
  iommu/vt-d: Add new enum value and structure for SATC
  iommu/vt-d: Parse SATC reporting structure
  iommu/vt-d: Apply SATC policy

 drivers/iommu/intel/dmar.c  |   9 ++
 drivers/iommu/intel/iommu.c | 161 +++++++++++++++++++++++++++++++++++-
 include/acpi/actbl1.h       |  11 ++-
 include/linux/dmar.h        |   2 +
 4 files changed, 178 insertions(+), 5 deletions(-)

-- 
2.25.1


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

* [PATCH 1/3] iommu/vt-d: Add new enum value and structure for SATC
  2021-02-02  4:40 [PATCH 0/3] iommu/vt-d: Add support for ACPI/SATC table Lu Baolu
@ 2021-02-02  4:40 ` Lu Baolu
  2021-02-02 13:51   ` Joerg Roedel
  2021-02-02 16:02   ` Raj, Ashok
  2021-02-02  4:40 ` [PATCH 2/3] iommu/vt-d: Parse SATC reporting structure Lu Baolu
                   ` (2 subsequent siblings)
  3 siblings, 2 replies; 16+ messages in thread
From: Lu Baolu @ 2021-02-02  4:40 UTC (permalink / raw)
  To: iommu; +Cc: Yian Chen, Joerg Roedel, Ashok Raj, linux-kernel

From: Yian Chen <yian.chen@intel.com>

Starting from Intel Platform VT-d v3.2, BIOS may provide new remapping
structure SATC for SOC integrated devices, according to section 8.8 of
Intel VT-d architecture specification v3.2. The SATC structure reports
a list of the devices that require SATC enabling via ATS capacity.

This patch introduces the new enum value and structure to represent the
remapping information. Kernel should parse the information from the
reporting structure and enable ATC for the devices as needed.

Signed-off-by: Yian Chen <yian.chen@intel.com>
---
 include/acpi/actbl1.h | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/include/acpi/actbl1.h b/include/acpi/actbl1.h
index 43549547ed3e..b7ca802b66d2 100644
--- a/include/acpi/actbl1.h
+++ b/include/acpi/actbl1.h
@@ -514,7 +514,8 @@ enum acpi_dmar_type {
 	ACPI_DMAR_TYPE_ROOT_ATS = 2,
 	ACPI_DMAR_TYPE_HARDWARE_AFFINITY = 3,
 	ACPI_DMAR_TYPE_NAMESPACE = 4,
-	ACPI_DMAR_TYPE_RESERVED = 5	/* 5 and greater are reserved */
+	ACPI_DMAR_TYPE_SATC = 5,
+	ACPI_DMAR_TYPE_RESERVED = 6	/* 5 and greater are reserved */
 };
 
 /* DMAR Device Scope structure */
@@ -607,6 +608,14 @@ struct acpi_dmar_andd {
 	char device_name[1];
 };
 
+/* 5: SOC Integrated Address Translation Cache Reporting Structure */
+
+struct acpi_dmar_satc {
+	struct acpi_dmar_header header;
+	u8 flags;
+	u8 reserved;
+	u16 segment;
+};
 /*******************************************************************************
  *
  * DRTM - Dynamic Root of Trust for Measurement table
-- 
2.25.1


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

* [PATCH 2/3] iommu/vt-d: Parse SATC reporting structure
  2021-02-02  4:40 [PATCH 0/3] iommu/vt-d: Add support for ACPI/SATC table Lu Baolu
  2021-02-02  4:40 ` [PATCH 1/3] iommu/vt-d: Add new enum value and structure for SATC Lu Baolu
@ 2021-02-02  4:40 ` Lu Baolu
  2021-02-02 13:53   ` Joerg Roedel
  2021-02-02 16:41   ` Raj, Ashok
  2021-02-02  4:40 ` [PATCH 3/3] iommu/vt-d: Apply SATC policy Lu Baolu
  2021-02-03  8:41 ` [PATCH 0/3] iommu/vt-d: Add support for ACPI/SATC table Christoph Hellwig
  3 siblings, 2 replies; 16+ messages in thread
From: Lu Baolu @ 2021-02-02  4:40 UTC (permalink / raw)
  To: iommu; +Cc: Yian Chen, Joerg Roedel, Ashok Raj, linux-kernel

From: Yian Chen <yian.chen@intel.com>

Software should parse every SATC table and all devices in the tables
reported by the BIOS and keep the information in kernel list for further
SATC policy deployment.

Signed-off-by: Yian Chen <yian.chen@intel.com>
---
 drivers/iommu/intel/dmar.c  |  9 ++++
 drivers/iommu/intel/iommu.c | 89 +++++++++++++++++++++++++++++++++++++
 include/linux/dmar.h        |  2 +
 3 files changed, 100 insertions(+)

diff --git a/drivers/iommu/intel/dmar.c b/drivers/iommu/intel/dmar.c
index 980e8ae090af..6bd357966d4e 100644
--- a/drivers/iommu/intel/dmar.c
+++ b/drivers/iommu/intel/dmar.c
@@ -526,6 +526,7 @@ dmar_table_print_dmar_entry(struct acpi_dmar_header *header)
 	struct acpi_dmar_reserved_memory *rmrr;
 	struct acpi_dmar_atsr *atsr;
 	struct acpi_dmar_rhsa *rhsa;
+	struct acpi_dmar_satc *satc;
 
 	switch (header->type) {
 	case ACPI_DMAR_TYPE_HARDWARE_UNIT:
@@ -555,6 +556,11 @@ dmar_table_print_dmar_entry(struct acpi_dmar_header *header)
 		/* We don't print this here because we need to sanity-check
 		   it first. So print it in dmar_parse_one_andd() instead. */
 		break;
+	case ACPI_DMAR_TYPE_SATC:
+		satc = container_of(header, struct acpi_dmar_satc, header);
+		pr_info("SATC flags: 0x%x\n", satc->flags);
+		break;
+
 	}
 }
 
@@ -642,6 +648,7 @@ parse_dmar_table(void)
 		.cb[ACPI_DMAR_TYPE_ROOT_ATS] = &dmar_parse_one_atsr,
 		.cb[ACPI_DMAR_TYPE_HARDWARE_AFFINITY] = &dmar_parse_one_rhsa,
 		.cb[ACPI_DMAR_TYPE_NAMESPACE] = &dmar_parse_one_andd,
+		.cb[ACPI_DMAR_TYPE_SATC] = &dmar_parse_one_satc,
 	};
 
 	/*
@@ -2077,6 +2084,7 @@ static guid_t dmar_hp_guid =
 #define	DMAR_DSM_FUNC_DRHD		1
 #define	DMAR_DSM_FUNC_ATSR		2
 #define	DMAR_DSM_FUNC_RHSA		3
+#define	DMAR_DSM_FUNC_SATC		4
 
 static inline bool dmar_detect_dsm(acpi_handle handle, int func)
 {
@@ -2094,6 +2102,7 @@ static int dmar_walk_dsm_resource(acpi_handle handle, int func,
 		[DMAR_DSM_FUNC_DRHD] = ACPI_DMAR_TYPE_HARDWARE_UNIT,
 		[DMAR_DSM_FUNC_ATSR] = ACPI_DMAR_TYPE_ROOT_ATS,
 		[DMAR_DSM_FUNC_RHSA] = ACPI_DMAR_TYPE_HARDWARE_AFFINITY,
+		[DMAR_DSM_FUNC_SATC] = ACPI_DMAR_TYPE_SATC,
 	};
 
 	if (!dmar_detect_dsm(handle, func))
diff --git a/drivers/iommu/intel/iommu.c b/drivers/iommu/intel/iommu.c
index ecd36e456de3..b20fd305fc60 100644
--- a/drivers/iommu/intel/iommu.c
+++ b/drivers/iommu/intel/iommu.c
@@ -316,8 +316,18 @@ struct dmar_atsr_unit {
 	u8 include_all:1;		/* include all ports */
 };
 
+struct dmar_satc_unit {
+	struct list_head list;		/* list of SATC units */
+	struct acpi_dmar_header *hdr;	/* ACPI header */
+	struct dmar_dev_scope *devices;	/* target devices */
+	struct intel_iommu *iommu;	/* the corresponding iommu */
+	int devices_cnt;		/* target device count */
+	u8 atc_required:1;		/* ATS is required */
+};
+
 static LIST_HEAD(dmar_atsr_units);
 static LIST_HEAD(dmar_rmrr_units);
+static LIST_HEAD(dmar_satc_units);
 
 #define for_each_rmrr_units(rmrr) \
 	list_for_each_entry(rmrr, &dmar_rmrr_units, list)
@@ -3736,6 +3746,57 @@ int dmar_check_one_atsr(struct acpi_dmar_header *hdr, void *arg)
 	return 0;
 }
 
+static struct dmar_satc_unit *dmar_find_satc(struct acpi_dmar_satc *satc)
+{
+	struct dmar_satc_unit *satcu;
+	struct acpi_dmar_satc *tmp;
+
+	list_for_each_entry_rcu(satcu, &dmar_satc_units, list,
+				dmar_rcu_check()) {
+		tmp = (struct acpi_dmar_satc *)satcu->hdr;
+		if (satc->segment != tmp->segment)
+			continue;
+		if (satc->header.length != tmp->header.length)
+			continue;
+		if (memcmp(satc, tmp, satc->header.length) == 0)
+			return satcu;
+	}
+
+	return NULL;
+}
+
+int dmar_parse_one_satc(struct acpi_dmar_header *hdr, void *arg)
+{
+	struct acpi_dmar_satc *satc;
+	struct dmar_satc_unit *satcu;
+
+	if (system_state >= SYSTEM_RUNNING && !intel_iommu_enabled)
+		return 0;
+
+	satc = container_of(hdr, struct acpi_dmar_satc, header);
+	satcu = dmar_find_satc(satc);
+	if (satcu)
+		return 0;
+
+	satcu = kzalloc(sizeof(*satcu) + hdr->length, GFP_KERNEL);
+	if (!satcu)
+		return -ENOMEM;
+
+	satcu->hdr = (void *)(satcu + 1);
+	memcpy(satcu->hdr, hdr, hdr->length);
+	satcu->atc_required = satc->flags & 0x1;
+	satcu->devices = dmar_alloc_dev_scope((void *)(satc + 1),
+					      (void *)satc + satc->header.length,
+					      &satcu->devices_cnt);
+	if (satcu->devices_cnt && !satcu->devices) {
+		kfree(satcu);
+		return -ENOMEM;
+	}
+	list_add_rcu(&satcu->list, &dmar_satc_units);
+
+	return 0;
+}
+
 static int intel_iommu_add(struct dmar_drhd_unit *dmaru)
 {
 	int sp, ret;
@@ -3843,6 +3904,7 @@ static void intel_iommu_free_dmars(void)
 {
 	struct dmar_rmrr_unit *rmrru, *rmrr_n;
 	struct dmar_atsr_unit *atsru, *atsr_n;
+	struct dmar_satc_unit *satcu, *satc_n;
 
 	list_for_each_entry_safe(rmrru, rmrr_n, &dmar_rmrr_units, list) {
 		list_del(&rmrru->list);
@@ -3854,6 +3916,11 @@ static void intel_iommu_free_dmars(void)
 		list_del(&atsru->list);
 		intel_iommu_free_atsr(atsru);
 	}
+	list_for_each_entry_safe(satcu, satc_n, &dmar_satc_units, list) {
+		list_del(&satcu->list);
+		dmar_free_dev_scope(&satcu->devices, &satcu->devices_cnt);
+		kfree(satcu);
+	}
 }
 
 int dmar_find_matched_atsr_unit(struct pci_dev *dev)
@@ -3905,8 +3972,10 @@ int dmar_iommu_notify_scope_dev(struct dmar_pci_notify_info *info)
 	int ret;
 	struct dmar_rmrr_unit *rmrru;
 	struct dmar_atsr_unit *atsru;
+	struct dmar_satc_unit *satcu;
 	struct acpi_dmar_atsr *atsr;
 	struct acpi_dmar_reserved_memory *rmrr;
+	struct acpi_dmar_satc *satc;
 
 	if (!intel_iommu_enabled && system_state >= SYSTEM_RUNNING)
 		return 0;
@@ -3947,6 +4016,23 @@ int dmar_iommu_notify_scope_dev(struct dmar_pci_notify_info *info)
 				break;
 		}
 	}
+	list_for_each_entry(satcu, &dmar_satc_units, list) {
+		satc = container_of(satcu->hdr, struct acpi_dmar_satc, header);
+		if (info->event == BUS_NOTIFY_ADD_DEVICE) {
+			ret = dmar_insert_dev_scope(info, (void *)(satc + 1),
+					(void *)satc + satc->header.length,
+					satc->segment, satcu->devices,
+					satcu->devices_cnt);
+			if (ret > 0)
+				break;
+			else if (ret < 0)
+				return ret;
+		} else if (info->event == BUS_NOTIFY_REMOVED_DEVICE) {
+			if (dmar_remove_dev_scope(info, satc->segment,
+					satcu->devices, satcu->devices_cnt))
+				break;
+		}
+	}
 
 	return 0;
 }
@@ -4290,6 +4376,9 @@ int __init intel_iommu_init(void)
 	if (list_empty(&dmar_atsr_units))
 		pr_info("No ATSR found\n");
 
+	if (list_empty(&dmar_satc_units))
+		pr_info("No SATC found\n");
+
 	if (dmar_map_gfx)
 		intel_iommu_gfx_mapped = 1;
 
diff --git a/include/linux/dmar.h b/include/linux/dmar.h
index 65565820328a..e04436a7ff27 100644
--- a/include/linux/dmar.h
+++ b/include/linux/dmar.h
@@ -138,6 +138,7 @@ extern void intel_iommu_shutdown(void);
 extern int dmar_parse_one_rmrr(struct acpi_dmar_header *header, void *arg);
 extern int dmar_parse_one_atsr(struct acpi_dmar_header *header, void *arg);
 extern int dmar_check_one_atsr(struct acpi_dmar_header *hdr, void *arg);
+extern int dmar_parse_one_satc(struct acpi_dmar_header *hdr, void *arg);
 extern int dmar_release_one_atsr(struct acpi_dmar_header *hdr, void *arg);
 extern int dmar_iommu_hotplug(struct dmar_drhd_unit *dmaru, bool insert);
 extern int dmar_iommu_notify_scope_dev(struct dmar_pci_notify_info *info);
@@ -149,6 +150,7 @@ static inline void intel_iommu_shutdown(void) { }
 #define	dmar_parse_one_atsr		dmar_res_noop
 #define	dmar_check_one_atsr		dmar_res_noop
 #define	dmar_release_one_atsr		dmar_res_noop
+#define	dmar_parse_one_satc		dmar_res_noop
 
 static inline int dmar_iommu_notify_scope_dev(struct dmar_pci_notify_info *info)
 {
-- 
2.25.1


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

* [PATCH 3/3] iommu/vt-d: Apply SATC policy
  2021-02-02  4:40 [PATCH 0/3] iommu/vt-d: Add support for ACPI/SATC table Lu Baolu
  2021-02-02  4:40 ` [PATCH 1/3] iommu/vt-d: Add new enum value and structure for SATC Lu Baolu
  2021-02-02  4:40 ` [PATCH 2/3] iommu/vt-d: Parse SATC reporting structure Lu Baolu
@ 2021-02-02  4:40 ` Lu Baolu
  2021-02-02 13:55   ` Joerg Roedel
  2021-02-03  8:41 ` [PATCH 0/3] iommu/vt-d: Add support for ACPI/SATC table Christoph Hellwig
  3 siblings, 1 reply; 16+ messages in thread
From: Lu Baolu @ 2021-02-02  4:40 UTC (permalink / raw)
  To: iommu; +Cc: Yian Chen, Joerg Roedel, Ashok Raj, linux-kernel

From: Yian Chen <yian.chen@intel.com>

Starting from Intel VT-d v3.2, Intel platform BIOS can provide a new SATC
table structure. SATC table lists a set of SoC integrated devices that
require ATC to work (VT-d specification v3.2, section 8.8). Furthermore,
the new version of IOMMU supports SoC device ATS in both its Scalable mode
and legacy mode.

When IOMMU is working in scalable mode, software must enable device ATS
support. On the other hand, when IOMMU is in legacy mode for whatever
reason, the hardware managed ATS will automatically take effect and the
SATC required devices can work transparently to the software. As the
result, software shouldn't enable ATS on that device, otherwise duplicate
device TLB invalidations will occur.

Signed-off-by: Yian Chen <yian.chen@intel.com>
---
 drivers/iommu/intel/iommu.c | 72 ++++++++++++++++++++++++++++++++++---
 1 file changed, 68 insertions(+), 4 deletions(-)

diff --git a/drivers/iommu/intel/iommu.c b/drivers/iommu/intel/iommu.c
index b20fd305fc60..131fac718a4b 100644
--- a/drivers/iommu/intel/iommu.c
+++ b/drivers/iommu/intel/iommu.c
@@ -872,6 +872,59 @@ static bool iommu_is_dummy(struct intel_iommu *iommu, struct device *dev)
 	return false;
 }
 
+static bool iommu_support_ats(struct intel_iommu *iommu)
+{
+	return ecap_dev_iotlb_support(iommu->ecap);
+}
+
+static bool device_support_ats(struct pci_dev *dev)
+{
+	return pci_ats_supported(dev) && dmar_find_matched_atsr_unit(dev);
+}
+
+static int segment_atc_required(u16 segment)
+{
+	struct acpi_dmar_satc *satc;
+	struct dmar_satc_unit *satcu;
+	int ret = 1;
+
+	rcu_read_lock();
+	list_for_each_entry_rcu(satcu, &dmar_satc_units, list) {
+		satc = container_of(satcu->hdr, struct acpi_dmar_satc, header);
+		if (satcu->atc_required &&
+		    satcu->devices_cnt &&
+		    satc->segment == segment)
+			goto out;
+	}
+	ret = 0;
+out:
+	rcu_read_unlock();
+	return ret;
+}
+
+static int device_atc_required(struct pci_dev *dev)
+{
+	struct dmar_satc_unit *satcu;
+	struct acpi_dmar_satc *satc;
+	struct device *tmp;
+	int i, ret = 1;
+
+	dev = pci_physfn(dev);
+	rcu_read_lock();
+	list_for_each_entry_rcu(satcu, &dmar_satc_units, list) {
+		satc = container_of(satcu->hdr, struct acpi_dmar_satc, header);
+		if (satc->segment == pci_domain_nr(dev->bus) && satcu->atc_required) {
+			for_each_dev_scope(satcu->devices, satcu->devices_cnt, i, tmp)
+				if (to_pci_dev(tmp) == dev)
+					goto out;
+		}
+	}
+	ret = 0;
+out:
+	rcu_read_unlock();
+	return ret;
+}
+
 struct intel_iommu *device_to_iommu(struct device *dev, u8 *bus, u8 *devfn)
 {
 	struct dmar_drhd_unit *drhd = NULL;
@@ -2575,10 +2628,16 @@ static struct dmar_domain *dmar_insert_one_dev_info(struct intel_iommu *iommu,
 	if (dev && dev_is_pci(dev)) {
 		struct pci_dev *pdev = to_pci_dev(info->dev);
 
-		if (ecap_dev_iotlb_support(iommu->ecap) &&
-		    pci_ats_supported(pdev) &&
-		    dmar_find_matched_atsr_unit(pdev))
-			info->ats_supported = 1;
+		/*
+		 * Support ATS by default if it's supported by both IOMMU and
+		 * client sides, except that the device's ATS is required by
+		 * ACPI/SATC but the IOMMU scalable mode is disabled. In that
+		 * case the hardware managed ATS will be automatically used.
+		 */
+		if (iommu_support_ats(iommu) && device_support_ats(pdev)) {
+			if (!device_atc_required(pdev) || sm_supported(iommu))
+				info->ats_supported = 1;
+		}
 
 		if (sm_supported(iommu)) {
 			if (pasid_supported(iommu)) {
@@ -3175,6 +3234,11 @@ static int __init init_dmars(void)
 	 * endfor
 	 */
 	for_each_drhd_unit(drhd) {
+		if (pci_ats_disabled() && segment_atc_required(drhd->segment)) {
+			pr_warn("Scalable mode disabled -- Use hardware managed ATS because PCIe ATS is disabled but some devices in PCIe segment 0x%x require it.",
+				drhd->segment);
+			intel_iommu_sm = 0;
+		}
 		/*
 		 * lock not needed as this is only incremented in the single
 		 * threaded kernel __init code path all other access are read
-- 
2.25.1


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

* Re: [PATCH 1/3] iommu/vt-d: Add new enum value and structure for SATC
  2021-02-02  4:40 ` [PATCH 1/3] iommu/vt-d: Add new enum value and structure for SATC Lu Baolu
@ 2021-02-02 13:51   ` Joerg Roedel
  2021-02-03  0:11     ` Lu Baolu
  2021-02-02 16:02   ` Raj, Ashok
  1 sibling, 1 reply; 16+ messages in thread
From: Joerg Roedel @ 2021-02-02 13:51 UTC (permalink / raw)
  To: Lu Baolu; +Cc: iommu, Yian Chen, Ashok Raj, linux-kernel

Hi Baolu,

On Tue, Feb 02, 2021 at 12:40:55PM +0800, Lu Baolu wrote:
> @@ -514,7 +514,8 @@ enum acpi_dmar_type {
>  	ACPI_DMAR_TYPE_ROOT_ATS = 2,
>  	ACPI_DMAR_TYPE_HARDWARE_AFFINITY = 3,
>  	ACPI_DMAR_TYPE_NAMESPACE = 4,
> -	ACPI_DMAR_TYPE_RESERVED = 5	/* 5 and greater are reserved */
> +	ACPI_DMAR_TYPE_SATC = 5,
> +	ACPI_DMAR_TYPE_RESERVED = 6	/* 5 and greater are reserved */

Nit: The comment needs to be updated too.


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

* Re: [PATCH 2/3] iommu/vt-d: Parse SATC reporting structure
  2021-02-02  4:40 ` [PATCH 2/3] iommu/vt-d: Parse SATC reporting structure Lu Baolu
@ 2021-02-02 13:53   ` Joerg Roedel
  2021-02-03  0:26     ` Lu Baolu
  2021-02-02 16:41   ` Raj, Ashok
  1 sibling, 1 reply; 16+ messages in thread
From: Joerg Roedel @ 2021-02-02 13:53 UTC (permalink / raw)
  To: Lu Baolu; +Cc: iommu, Yian Chen, Ashok Raj, linux-kernel

On Tue, Feb 02, 2021 at 12:40:56PM +0800, Lu Baolu wrote:
> +	case ACPI_DMAR_TYPE_SATC:
> +		satc = container_of(header, struct acpi_dmar_satc, header);
> +		pr_info("SATC flags: 0x%x\n", satc->flags);
> +		break;

Did the pr_info() slip through or is there a real purpose for having
this information in the kernel log?


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

* Re: [PATCH 3/3] iommu/vt-d: Apply SATC policy
  2021-02-02  4:40 ` [PATCH 3/3] iommu/vt-d: Apply SATC policy Lu Baolu
@ 2021-02-02 13:55   ` Joerg Roedel
  2021-02-03  0:33     ` Lu Baolu
  0 siblings, 1 reply; 16+ messages in thread
From: Joerg Roedel @ 2021-02-02 13:55 UTC (permalink / raw)
  To: Lu Baolu; +Cc: iommu, Yian Chen, Ashok Raj, linux-kernel

On Tue, Feb 02, 2021 at 12:40:57PM +0800, Lu Baolu wrote:
> +	list_for_each_entry_rcu(satcu, &dmar_satc_units, list) {
> +		satc = container_of(satcu->hdr, struct acpi_dmar_satc, header);
> +		if (satc->segment == pci_domain_nr(dev->bus) && satcu->atc_required) {

You can safe a level of indentation and make this look nicer if you do:

		if (satc->segment != pci_domain_nr(dev->bus) || !satcu->atc_required)
			continue;


> +			for_each_dev_scope(satcu->devices, satcu->devices_cnt, i, tmp)
> +				if (to_pci_dev(tmp) == dev)
> +					goto out;
> +		}
> +	}
> +	ret = 0;
> +out:
> +	rcu_read_unlock();
> +	return ret;
> +}

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

* Re: [PATCH 1/3] iommu/vt-d: Add new enum value and structure for SATC
  2021-02-02  4:40 ` [PATCH 1/3] iommu/vt-d: Add new enum value and structure for SATC Lu Baolu
  2021-02-02 13:51   ` Joerg Roedel
@ 2021-02-02 16:02   ` Raj, Ashok
  2021-02-03  0:15     ` Lu Baolu
  1 sibling, 1 reply; 16+ messages in thread
From: Raj, Ashok @ 2021-02-02 16:02 UTC (permalink / raw)
  To: Lu Baolu; +Cc: iommu, Yian Chen, Joerg Roedel, linux-kernel, Ashok Raj

On Tue, Feb 02, 2021 at 12:40:55PM +0800, Lu Baolu wrote:
> From: Yian Chen <yian.chen@intel.com>
> 
> Starting from Intel Platform VT-d v3.2, BIOS may provide new remapping
> structure SATC for SOC integrated devices, according to section 8.8 of
> Intel VT-d architecture specification v3.2. The SATC structure reports
> a list of the devices that require SATC enabling via ATS capacity.

nit: s/require SATC/require ATS for normal device operation. This is a
functional requirement that these devices will not work without OS enabling
ATS capability.

> 
> This patch introduces the new enum value and structure to represent the
> remapping information. Kernel should parse the information from the
> reporting structure and enable ATC for the devices as needed.
> 
> Signed-off-by: Yian Chen <yian.chen@intel.com>
> ---
>  include/acpi/actbl1.h | 11 ++++++++++-
>  1 file changed, 10 insertions(+), 1 deletion(-)
> 
> diff --git a/include/acpi/actbl1.h b/include/acpi/actbl1.h
> index 43549547ed3e..b7ca802b66d2 100644
> --- a/include/acpi/actbl1.h
> +++ b/include/acpi/actbl1.h
> @@ -514,7 +514,8 @@ enum acpi_dmar_type {
>  	ACPI_DMAR_TYPE_ROOT_ATS = 2,
>  	ACPI_DMAR_TYPE_HARDWARE_AFFINITY = 3,
>  	ACPI_DMAR_TYPE_NAMESPACE = 4,
> -	ACPI_DMAR_TYPE_RESERVED = 5	/* 5 and greater are reserved */
> +	ACPI_DMAR_TYPE_SATC = 5,
> +	ACPI_DMAR_TYPE_RESERVED = 6	/* 5 and greater are reserved */
>  };
>  

Think Joerg spotted the comment update.

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

* Re: [PATCH 2/3] iommu/vt-d: Parse SATC reporting structure
  2021-02-02  4:40 ` [PATCH 2/3] iommu/vt-d: Parse SATC reporting structure Lu Baolu
  2021-02-02 13:53   ` Joerg Roedel
@ 2021-02-02 16:41   ` Raj, Ashok
  2021-02-03  0:29     ` Lu Baolu
  1 sibling, 1 reply; 16+ messages in thread
From: Raj, Ashok @ 2021-02-02 16:41 UTC (permalink / raw)
  To: Lu Baolu; +Cc: iommu, Yian Chen, Joerg Roedel, linux-kernel, Ashok Raj

On Tue, Feb 02, 2021 at 12:40:56PM +0800, Lu Baolu wrote:
> From: Yian Chen <yian.chen@intel.com>
> 
> Software should parse every SATC table and all devices in the tables
> reported by the BIOS and keep the information in kernel list for further
> SATC policy deployment.
> 
The last part seems bit vague? Are you trying to imply, 

if kernel is booted with noats for instance, a device listed in SATC table
as "requires ATS" will fail to load?

Otherwise its not clear what the policy enforcement means.

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

* Re: [PATCH 1/3] iommu/vt-d: Add new enum value and structure for SATC
  2021-02-02 13:51   ` Joerg Roedel
@ 2021-02-03  0:11     ` Lu Baolu
  0 siblings, 0 replies; 16+ messages in thread
From: Lu Baolu @ 2021-02-03  0:11 UTC (permalink / raw)
  To: Joerg Roedel; +Cc: baolu.lu, iommu, Yian Chen, Ashok Raj, linux-kernel

Hi Joerg,

On 2/2/21 9:51 PM, Joerg Roedel wrote:
> Hi Baolu,
> 
> On Tue, Feb 02, 2021 at 12:40:55PM +0800, Lu Baolu wrote:
>> @@ -514,7 +514,8 @@ enum acpi_dmar_type {
>>   	ACPI_DMAR_TYPE_ROOT_ATS = 2,
>>   	ACPI_DMAR_TYPE_HARDWARE_AFFINITY = 3,
>>   	ACPI_DMAR_TYPE_NAMESPACE = 4,
>> -	ACPI_DMAR_TYPE_RESERVED = 5	/* 5 and greater are reserved */
>> +	ACPI_DMAR_TYPE_SATC = 5,
>> +	ACPI_DMAR_TYPE_RESERVED = 6	/* 5 and greater are reserved */
> 
> Nit: The comment needs to be updated too.
> 

Yes. Will update it.

Best regards,
baolu

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

* Re: [PATCH 1/3] iommu/vt-d: Add new enum value and structure for SATC
  2021-02-02 16:02   ` Raj, Ashok
@ 2021-02-03  0:15     ` Lu Baolu
  0 siblings, 0 replies; 16+ messages in thread
From: Lu Baolu @ 2021-02-03  0:15 UTC (permalink / raw)
  To: Raj, Ashok; +Cc: baolu.lu, iommu, Yian Chen, Joerg Roedel, linux-kernel

Hi Ashok,

On 2/3/21 12:02 AM, Raj, Ashok wrote:
> On Tue, Feb 02, 2021 at 12:40:55PM +0800, Lu Baolu wrote:
>> From: Yian Chen <yian.chen@intel.com>
>>
>> Starting from Intel Platform VT-d v3.2, BIOS may provide new remapping
>> structure SATC for SOC integrated devices, according to section 8.8 of
>> Intel VT-d architecture specification v3.2. The SATC structure reports
>> a list of the devices that require SATC enabling via ATS capacity.
> 
> nit: s/require SATC/require ATS for normal device operation. This is a
> functional requirement that these devices will not work without OS enabling
> ATS capability.
> 

Yes. This looks clearer.

Best regards,
baolu

>>
>> This patch introduces the new enum value and structure to represent the
>> remapping information. Kernel should parse the information from the
>> reporting structure and enable ATC for the devices as needed.
>>
>> Signed-off-by: Yian Chen <yian.chen@intel.com>
>> ---
>>   include/acpi/actbl1.h | 11 ++++++++++-
>>   1 file changed, 10 insertions(+), 1 deletion(-)
>>
>> diff --git a/include/acpi/actbl1.h b/include/acpi/actbl1.h
>> index 43549547ed3e..b7ca802b66d2 100644
>> --- a/include/acpi/actbl1.h
>> +++ b/include/acpi/actbl1.h
>> @@ -514,7 +514,8 @@ enum acpi_dmar_type {
>>   	ACPI_DMAR_TYPE_ROOT_ATS = 2,
>>   	ACPI_DMAR_TYPE_HARDWARE_AFFINITY = 3,
>>   	ACPI_DMAR_TYPE_NAMESPACE = 4,
>> -	ACPI_DMAR_TYPE_RESERVED = 5	/* 5 and greater are reserved */
>> +	ACPI_DMAR_TYPE_SATC = 5,
>> +	ACPI_DMAR_TYPE_RESERVED = 6	/* 5 and greater are reserved */
>>   };
>>   
> 
> Think Joerg spotted the comment update.
> 

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

* Re: [PATCH 2/3] iommu/vt-d: Parse SATC reporting structure
  2021-02-02 13:53   ` Joerg Roedel
@ 2021-02-03  0:26     ` Lu Baolu
  0 siblings, 0 replies; 16+ messages in thread
From: Lu Baolu @ 2021-02-03  0:26 UTC (permalink / raw)
  To: Joerg Roedel; +Cc: baolu.lu, iommu, Yian Chen, Ashok Raj, linux-kernel

Hi Joerg,

On 2/2/21 9:53 PM, Joerg Roedel wrote:
> On Tue, Feb 02, 2021 at 12:40:56PM +0800, Lu Baolu wrote:
>> +	case ACPI_DMAR_TYPE_SATC:
>> +		satc = container_of(header, struct acpi_dmar_satc, header);
>> +		pr_info("SATC flags: 0x%x\n", satc->flags);
>> +		break;
> 
> Did the pr_info() slip through or is there a real purpose for having
> this information in the kernel log?
> 

Here is just the easiest way for users to know SATC: system has SATC?
ATS is required?

Best regards,
baolu

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

* Re: [PATCH 2/3] iommu/vt-d: Parse SATC reporting structure
  2021-02-02 16:41   ` Raj, Ashok
@ 2021-02-03  0:29     ` Lu Baolu
  0 siblings, 0 replies; 16+ messages in thread
From: Lu Baolu @ 2021-02-03  0:29 UTC (permalink / raw)
  To: Raj, Ashok; +Cc: baolu.lu, iommu, Yian Chen, Joerg Roedel, linux-kernel

Hi Ashok,

On 2/3/21 12:41 AM, Raj, Ashok wrote:
> On Tue, Feb 02, 2021 at 12:40:56PM +0800, Lu Baolu wrote:
>> From: Yian Chen <yian.chen@intel.com>
>>
>> Software should parse every SATC table and all devices in the tables
>> reported by the BIOS and keep the information in kernel list for further
>> SATC policy deployment.
>>
> The last part seems bit vague? Are you trying to imply,
> 
> if kernel is booted with noats for instance, a device listed in SATC table
> as "requires ATS" will fail to load?
> 
> Otherwise its not clear what the policy enforcement means.
> 

Yes. This is a bit vague. The ATS policy is out of the purpose of this
patch. It only parses the table and keep the device list for further
reference.

Best regards,
baolu

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

* Re: [PATCH 3/3] iommu/vt-d: Apply SATC policy
  2021-02-02 13:55   ` Joerg Roedel
@ 2021-02-03  0:33     ` Lu Baolu
  0 siblings, 0 replies; 16+ messages in thread
From: Lu Baolu @ 2021-02-03  0:33 UTC (permalink / raw)
  To: Joerg Roedel; +Cc: baolu.lu, iommu, Yian Chen, Ashok Raj, linux-kernel

On 2/2/21 9:55 PM, Joerg Roedel wrote:
> On Tue, Feb 02, 2021 at 12:40:57PM +0800, Lu Baolu wrote:
>> +	list_for_each_entry_rcu(satcu, &dmar_satc_units, list) {
>> +		satc = container_of(satcu->hdr, struct acpi_dmar_satc, header);
>> +		if (satc->segment == pci_domain_nr(dev->bus) && satcu->atc_required) {
> 
> You can safe a level of indentation and make this look nicer if you do:
> 
> 		if (satc->segment != pci_domain_nr(dev->bus) || !satcu->atc_required)
> 			continue;
> 
> 

Yes. Thanks!

Best regards,
baolu

>> +			for_each_dev_scope(satcu->devices, satcu->devices_cnt, i, tmp)
>> +				if (to_pci_dev(tmp) == dev)
>> +					goto out;
>> +		}
>> +	}
>> +	ret = 0;
>> +out:
>> +	rcu_read_unlock();
>> +	return ret;
>> +}

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

* Re: [PATCH 0/3] iommu/vt-d: Add support for ACPI/SATC table
  2021-02-02  4:40 [PATCH 0/3] iommu/vt-d: Add support for ACPI/SATC table Lu Baolu
                   ` (2 preceding siblings ...)
  2021-02-02  4:40 ` [PATCH 3/3] iommu/vt-d: Apply SATC policy Lu Baolu
@ 2021-02-03  8:41 ` Christoph Hellwig
  2021-02-03  9:29   ` Lu Baolu
  3 siblings, 1 reply; 16+ messages in thread
From: Christoph Hellwig @ 2021-02-03  8:41 UTC (permalink / raw)
  To: Lu Baolu; +Cc: iommu, Yian Chen, Joerg Roedel, Ashok Raj, linux-kernel

On Tue, Feb 02, 2021 at 12:40:54PM +0800, Lu Baolu wrote:
> Intel platform VT-d (v3.2) comes with a new type of DMAR subtable
> SATC. The SATC table includes a list of SoC integrated devices
> that require SATC. OS software can use this table to enable ATS
> only for the devices in the list.

This all sounds like gibberish. Please expand and if necessary explain
acronyms when first used in each commit log / cover letter.

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

* Re: [PATCH 0/3] iommu/vt-d: Add support for ACPI/SATC table
  2021-02-03  8:41 ` [PATCH 0/3] iommu/vt-d: Add support for ACPI/SATC table Christoph Hellwig
@ 2021-02-03  9:29   ` Lu Baolu
  0 siblings, 0 replies; 16+ messages in thread
From: Lu Baolu @ 2021-02-03  9:29 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: baolu.lu, iommu, Yian Chen, Joerg Roedel, Ashok Raj, linux-kernel

Hi Christoph,

On 2021/2/3 16:41, Christoph Hellwig wrote:
> On Tue, Feb 02, 2021 at 12:40:54PM +0800, Lu Baolu wrote:
>> Intel platform VT-d (v3.2) comes with a new type of DMAR subtable
>> SATC. The SATC table includes a list of SoC integrated devices
>> that require SATC. OS software can use this table to enable ATS
>> only for the devices in the list.
> 
> This all sounds like gibberish. Please expand and if necessary explain
> acronyms when first used in each commit log / cover letter.
> 

I will rephrase the words.

Best regards,
baolu

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

end of thread, other threads:[~2021-02-03  9:31 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-02  4:40 [PATCH 0/3] iommu/vt-d: Add support for ACPI/SATC table Lu Baolu
2021-02-02  4:40 ` [PATCH 1/3] iommu/vt-d: Add new enum value and structure for SATC Lu Baolu
2021-02-02 13:51   ` Joerg Roedel
2021-02-03  0:11     ` Lu Baolu
2021-02-02 16:02   ` Raj, Ashok
2021-02-03  0:15     ` Lu Baolu
2021-02-02  4:40 ` [PATCH 2/3] iommu/vt-d: Parse SATC reporting structure Lu Baolu
2021-02-02 13:53   ` Joerg Roedel
2021-02-03  0:26     ` Lu Baolu
2021-02-02 16:41   ` Raj, Ashok
2021-02-03  0:29     ` Lu Baolu
2021-02-02  4:40 ` [PATCH 3/3] iommu/vt-d: Apply SATC policy Lu Baolu
2021-02-02 13:55   ` Joerg Roedel
2021-02-03  0:33     ` Lu Baolu
2021-02-03  8:41 ` [PATCH 0/3] iommu/vt-d: Add support for ACPI/SATC table Christoph Hellwig
2021-02-03  9:29   ` Lu Baolu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).