Skip to contentSkip to conversation

iommu/vt-d: Add set_dev_pasid callbacks for default domain

PATCH In review Lu Baolu 2 participants 7 messages Jun 14, 2022

Subsystems (2)
lore
Share & tools
lore

Lu Baolu

author maintainer
#0 lore raw

PATCH 1/1 iommu/vt-d: Add set_dev_pasid callbacks for default domain

This allows the upper layers to set a domain to a PASID of a device if the PASID feature is supported by the IOMMU hardware. The typical use cases are, for example, kernel DMA with PASID and hardware assisted mediated device drivers.

The attaching device and pasid information is tracked in a per-domain list and is used for IOTLB and devTLB invalidation.

---
 drivers/iommu/intel/iommu.h |   8 +++
 drivers/iommu/intel/iommu.c | 118 +++++++++++++++++++++++++++++++++++-
 2 files changed, 124 insertions(+), 2 deletions(-)

---
Note: This is a follow-up of this patch:
https://lore.kernel.org/linux-iommu/[email protected]/
which, removed the SVM_FLAG_SUPERVISOR_MODE support from the IOMMU SVA interface and recommended the device driver to handle kernel DMA with PASID through the kernel DMA APIs. It is nothing new anyway. It's a simplified version of the previous callbacks which have existed in the tree for more than one year. Those callbacks have been removed by commit 241469685d8d ("iommu/vt-d: Remove aux-domain related callbacks") in order for the new iommufd framework.

drivers/iommu/intel/iommu.h +8 -0
index 2dd4c5193cc1..a703e0768f47 100644
@@ -541,6 +541,7 @@ struct dmar_domain {
 
 	spinlock_t lock;		/* Protect device tracking lists */
 	struct list_head devices;	/* all devices' list */
+	struct list_head subdevices;	/* all subdevices' list */
 
 	struct dma_pte	*pgd;		/* virtual address */
 	int		gaw;		/* max guest address width */
@@ -626,6 +627,13 @@ struct device_domain_info {
 	struct pasid_table *pasid_table; /* pasid table */
 };
 
+/* PCI domain-subdevice relationship */
+struct subdev_domain_info {
+	struct list_head link_domain;	/* link to domain siblings */
+	struct device *dev;		/* physical device derived from */
+	ioasid_t pasid;			/* PASID on physical device */
+};
+
 static inline void __iommu_flush_cache(
 	struct intel_iommu *iommu, void *addr, int size)
 {
drivers/iommu/intel/iommu.c +116 -2

172 lines not on this page · raw message

Signature · 6 lines
2.25.1

_______________________________________________
iommu mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/iommu
#1 lore raw
Quoted 8 lines

From: Lu Baolu <[email protected]>
Sent: Tuesday, June 14, 2022 11:44 AM

This allows the upper layers to set a domain to a PASID of a device if the PASID feature is supported by the IOMMU hardware. The typical use cases are, for example, kernel DMA with PASID and hardware assisted mediated device drivers.

why is it not part of the series for those use cases? There is no consumer of added callbacks in this patch...

drivers/iommu/intel/iommu.h struct device_domain_info { · line 636

Quoted 7 lines
drivers/iommu/intel/iommu.h +7 -0
+/* PCI domain-subdevice relationship */
+struct subdev_domain_info {
+	struct list_head link_domain;	/* link to domain siblings */
+	struct device *dev;		/* physical device derived from */
+	ioasid_t pasid;			/* PASID on physical device */
+};
+

It's not subdev. Just dev+pasid in iommu's context.
_______________________________________________
iommu mailing list [email protected]
https://lists.linuxfoundation.org/mailman/listinfo/iommu

author maintainer
#2 lore raw
Quoted 11 lines · Kevin
Quoted 8 lines

From: Lu Baolu <[email protected]>
Sent: Tuesday, June 14, 2022 11:44 AM

This allows the upper layers to set a domain to a PASID of a device if the PASID feature is supported by the IOMMU hardware. The typical use cases are, for example, kernel DMA with PASID and hardware assisted mediated device drivers.

why is it not part of the series for those use cases? There is no consumer of added callbacks in this patch...

It could be. I just wanted to maintain the integrity of Intel IOMMU driver implementation.

Quoted 10 lines

drivers/iommu/intel/iommu.h struct device_domain_info { · line 636

Quoted 8 lines
drivers/iommu/intel/iommu.h +7 -0
+/* PCI domain-subdevice relationship */
+struct subdev_domain_info {
+	struct list_head link_domain;	/* link to domain siblings */
+	struct device *dev;		/* physical device derived from */
+	ioasid_t pasid;			/* PASID on physical device */
+};
+

It's not subdev. Just dev+pasid in iommu's context.

How about struct device_pasid_info?

Best regards,
baolu

#3 lore raw
Quoted 13 lines

From: Baolu Lu <[email protected]>
Sent: Tuesday, June 14, 2022 12:48 PM

Quoted 9 lines · Kevin
Quoted 8 lines

From: Lu Baolu <[email protected]>
Sent: Tuesday, June 14, 2022 11:44 AM

This allows the upper layers to set a domain to a PASID of a device if the PASID feature is supported by the IOMMU hardware. The typical use cases are, for example, kernel DMA with PASID and hardware assisted mediated device drivers.

Quoted 5 lines
Quoted 2 lines

why is it not part of the series for those use cases? There is no consumer of added callbacks in this patch...

It could be. I just wanted to maintain the integrity of Intel IOMMU driver implementation.

but let's not add dead code. and this patch is actually a right step simply from set_dev_pasid() p.o.v hence you should include in any series which first tries to use that interface.

Quoted 12 lines
Quoted 11 lines

drivers/iommu/intel/iommu.h struct device_domain_info { · line 636

Quoted 9 lines
drivers/iommu/intel/iommu.h +7 -0
+/* PCI domain-subdevice relationship */
+struct subdev_domain_info {
+	struct list_head link_domain;	/* link to domain siblings */
+	struct device *dev;		/* physical device derived from */
+	ioasid_t pasid;			/* PASID on physical device */
+};
+

It's not subdev. Just dev+pasid in iommu's context.

Quoted 2 lines

How about struct device_pasid_info?

this is better.
_______________________________________________
iommu mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/iommu

author maintainer
#4 lore raw
Quoted 12 lines · Kevin
Quoted 12 lines

From: Baolu Lu<[email protected]>
Sent: Tuesday, June 14, 2022 12:48 PM

Quoted 8 lines · Kevin
Quoted 8 lines

From: Lu Baolu<[email protected]>
Sent: Tuesday, June 14, 2022 11:44 AM

This allows the upper layers to set a domain to a PASID of a device if the PASID feature is supported by the IOMMU hardware. The typical use cases are, for example, kernel DMA with PASID and hardware assisted mediated device drivers.

Quoted 8 lines
Quoted 4 lines
Quoted 2 lines

why is it not part of the series for those use cases? There is no consumer of added callbacks in this patch...

It could be. I just wanted to maintain the integrity of Intel IOMMU driver implementation.

but let's not add dead code. and this patch is actually a right step simply from set_dev_pasid() p.o.v hence you should include in any series which first tries to use that interface.

Yes, that's my intention. If it reviews well, we can include it in the driver's implementation.

Best regards,
baolu
_______________________________________________
iommu mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/iommu

#5 lore raw
Quoted 20 lines

From: Baolu Lu <[email protected]>
Sent: Tuesday, June 14, 2022 2:13 PM

Quoted 16 lines · Kevin
Quoted 16 lines

From: Baolu Lu<[email protected]>
Sent: Tuesday, June 14, 2022 12:48 PM

Quoted 10 lines · Kevin
Quoted 8 lines

From: Lu Baolu<[email protected]>
Sent: Tuesday, June 14, 2022 11:44 AM

This allows the upper layers to set a domain to a PASID of a device if the PASID feature is supported by the IOMMU hardware. The typical use cases are, for example, kernel DMA with PASID and hardware assisted mediated device drivers.

why is it not part of the series for those use cases? There is no consumer of added callbacks in this patch...

It could be. I just wanted to maintain the integrity of Intel IOMMU driver implementation.

Quoted 8 lines
Quoted 4 lines

but let's not add dead code. and this patch is actually a right step simply from set_dev_pasid() p.o.v hence you should include in any series which first tries to use that interface.

Yes, that's my intention. If it reviews well, we can include it in the driver's implementation.

Then you should make it clear in the first place. otherwise a patch like this implies a review for merge. 😊
_______________________________________________
iommu mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/iommu

author maintainer
#6 lore raw
Quoted 25 lines · Kevin
Quoted 25 lines

From: Baolu Lu <[email protected]>
Sent: Tuesday, June 14, 2022 2:13 PM

Quoted 20 lines · Kevin
Quoted 12 lines

From: Baolu Lu<[email protected]>
Sent: Tuesday, June 14, 2022 12:48 PM

Quoted 8 lines · Kevin
Quoted 8 lines

From: Lu Baolu<[email protected]>
Sent: Tuesday, June 14, 2022 11:44 AM

This allows the upper layers to set a domain to a PASID of a device if the PASID feature is supported by the IOMMU hardware. The typical use cases are, for example, kernel DMA with PASID and hardware assisted mediated device drivers.

Quoted 4 lines
Quoted 2 lines

why is it not part of the series for those use cases? There is no consumer of added callbacks in this patch...

It could be. I just wanted to maintain the integrity of Intel IOMMU driver implementation.

but let's not add dead code. and this patch is actually a right step simply from set_dev_pasid() p.o.v hence you should include in any series which first tries to use that interface.

Quoted 6 lines
Quoted 3 lines

Yes, that's my intention. If it reviews well, we can include it in the driver's implementation.

Then you should make it clear in the first place. otherwise a patch like this implies a review for merge. 😊

Yeah! Will update this in the next version.

Best regards,
baolu
_______________________________________________
iommu mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/iommu