LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH v2 0/2] iommu/vt-d: pfsid fix
@ 2018-06-07 16:56 Jacob Pan
2018-06-07 16:56 ` [PATCH v2 1/2] iommu/vt-d: add definitions for PFSID Jacob Pan
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Jacob Pan @ 2018-06-07 16:56 UTC (permalink / raw)
To: iommu, LKML, Joerg Roedel, David Woodhouse; +Cc: Jacob Pan
When device invalidation throttling(DIT) is supported by an IOMMU, device TLB
invalidation should include physical function source ID(PFSID).
Changes since v1:
- Fixed compile error when CONFIG_PCI_ATS is not set
- Simplified how PF source ID is retrieved
Jacob Pan (2):
iommu/vt-d: add definitions for PFSID
iommu/vt-d: fix dev iotlb pfsid use
drivers/iommu/dmar.c | 6 +++---
drivers/iommu/intel-iommu.c | 18 +++++++++++++++++-
include/linux/intel-iommu.h | 8 +++++---
3 files changed, 25 insertions(+), 7 deletions(-)
--
2.7.4
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH v2 1/2] iommu/vt-d: add definitions for PFSID
2018-06-07 16:56 [PATCH v2 0/2] iommu/vt-d: pfsid fix Jacob Pan
@ 2018-06-07 16:56 ` Jacob Pan
2018-06-20 20:25 ` Jacob Pan
2018-06-07 16:57 ` [PATCH v2 2/2] iommu/vt-d: fix dev iotlb pfsid use Jacob Pan
2018-07-06 11:26 ` [PATCH v2 0/2] iommu/vt-d: pfsid fix Joerg Roedel
2 siblings, 1 reply; 5+ messages in thread
From: Jacob Pan @ 2018-06-07 16:56 UTC (permalink / raw)
To: iommu, LKML, Joerg Roedel, David Woodhouse
Cc: Jacob Pan, stable, Ashok Raj, Lu Baolu
When SRIOV VF device IOTLB is invalidated, we need to provide
the PF source ID such that IOMMU hardware can gauge the depth
of invalidation queue which is shared among VFs. This is needed
when device invalidation throttle (DIT) capability is supported.
This patch adds bit definitions for checking and tracking PFSID.
Signed-off-by: Jacob Pan <jacob.jun.pan@linux.intel.com>
Cc: stable@vger.kernel.org
Cc: "Ashok Raj" <ashok.raj@intel.com>
Cc: "Lu Baolu" <baolu.lu@linux.intel.com>
---
drivers/iommu/intel-iommu.c | 1 +
include/linux/intel-iommu.h | 3 +++
2 files changed, 4 insertions(+)
diff --git a/drivers/iommu/intel-iommu.c b/drivers/iommu/intel-iommu.c
index 749d8f2..3d77d61 100644
--- a/drivers/iommu/intel-iommu.c
+++ b/drivers/iommu/intel-iommu.c
@@ -422,6 +422,7 @@ struct device_domain_info {
struct list_head global; /* link to global list */
u8 bus; /* PCI bus number */
u8 devfn; /* PCI devfn number */
+ u16 pfsid; /* SRIOV physical function source ID */
u8 pasid_supported:3;
u8 pasid_enabled:1;
u8 pri_supported:1;
diff --git a/include/linux/intel-iommu.h b/include/linux/intel-iommu.h
index ef169d6..af1c05f 100644
--- a/include/linux/intel-iommu.h
+++ b/include/linux/intel-iommu.h
@@ -114,6 +114,7 @@
* Extended Capability Register
*/
+#define ecap_dit(e) ((e >> 41) & 0x1)
#define ecap_pasid(e) ((e >> 40) & 0x1)
#define ecap_pss(e) ((e >> 35) & 0x1f)
#define ecap_eafs(e) ((e >> 34) & 0x1)
@@ -284,6 +285,7 @@ enum {
#define QI_DEV_IOTLB_SID(sid) ((u64)((sid) & 0xffff) << 32)
#define QI_DEV_IOTLB_QDEP(qdep) (((qdep) & 0x1f) << 16)
#define QI_DEV_IOTLB_ADDR(addr) ((u64)(addr) & VTD_PAGE_MASK)
+#define QI_DEV_IOTLB_PFSID(pfsid) (((u64)(pfsid & 0xf) << 12) | ((u64)(pfsid & 0xfff) << 52))
#define QI_DEV_IOTLB_SIZE 1
#define QI_DEV_IOTLB_MAX_INVS 32
@@ -308,6 +310,7 @@ enum {
#define QI_DEV_EIOTLB_PASID(p) (((u64)p) << 32)
#define QI_DEV_EIOTLB_SID(sid) ((u64)((sid) & 0xffff) << 16)
#define QI_DEV_EIOTLB_QDEP(qd) ((u64)((qd) & 0x1f) << 4)
+#define QI_DEV_EIOTLB_PFSID(pfsid) (((u64)(pfsid & 0xf) << 12) | ((u64)(pfsid & 0xfff) << 52))
#define QI_DEV_EIOTLB_MAX_INVS 32
#define QI_PGRP_IDX(idx) (((u64)(idx)) << 55)
--
2.7.4
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH v2 2/2] iommu/vt-d: fix dev iotlb pfsid use
2018-06-07 16:56 [PATCH v2 0/2] iommu/vt-d: pfsid fix Jacob Pan
2018-06-07 16:56 ` [PATCH v2 1/2] iommu/vt-d: add definitions for PFSID Jacob Pan
@ 2018-06-07 16:57 ` Jacob Pan
2018-07-06 11:26 ` [PATCH v2 0/2] iommu/vt-d: pfsid fix Joerg Roedel
2 siblings, 0 replies; 5+ messages in thread
From: Jacob Pan @ 2018-06-07 16:57 UTC (permalink / raw)
To: iommu, LKML, Joerg Roedel, David Woodhouse
Cc: Jacob Pan, stable, Ashok Raj, Lu Baolu
PFSID should be used in the invalidation descriptor for flushing
device IOTLBs on SRIOV VFs.
Signed-off-by: Jacob Pan <jacob.jun.pan@linux.intel.com>
Cc: stable@vger.kernel.org
Cc: "Ashok Raj" <ashok.raj@intel.com>
Cc: "Lu Baolu" <baolu.lu@linux.intel.com>
---
drivers/iommu/dmar.c | 6 +++---
drivers/iommu/intel-iommu.c | 17 ++++++++++++++++-
include/linux/intel-iommu.h | 5 ++---
3 files changed, 21 insertions(+), 7 deletions(-)
diff --git a/drivers/iommu/dmar.c b/drivers/iommu/dmar.c
index 460bed4..7852678 100644
--- a/drivers/iommu/dmar.c
+++ b/drivers/iommu/dmar.c
@@ -1339,8 +1339,8 @@ void qi_flush_iotlb(struct intel_iommu *iommu, u16 did, u64 addr,
qi_submit_sync(&desc, iommu);
}
-void qi_flush_dev_iotlb(struct intel_iommu *iommu, u16 sid, u16 qdep,
- u64 addr, unsigned mask)
+void qi_flush_dev_iotlb(struct intel_iommu *iommu, u16 sid, u16 pfsid,
+ u16 qdep, u64 addr, unsigned mask)
{
struct qi_desc desc;
@@ -1355,7 +1355,7 @@ void qi_flush_dev_iotlb(struct intel_iommu *iommu, u16 sid, u16 qdep,
qdep = 0;
desc.low = QI_DEV_IOTLB_SID(sid) | QI_DEV_IOTLB_QDEP(qdep) |
- QI_DIOTLB_TYPE;
+ QI_DIOTLB_TYPE | QI_DEV_IOTLB_PFSID(pfsid);
qi_submit_sync(&desc, iommu);
}
diff --git a/drivers/iommu/intel-iommu.c b/drivers/iommu/intel-iommu.c
index 3d77d61..8b533cc 100644
--- a/drivers/iommu/intel-iommu.c
+++ b/drivers/iommu/intel-iommu.c
@@ -1503,6 +1503,20 @@ static void iommu_enable_dev_iotlb(struct device_domain_info *info)
return;
pdev = to_pci_dev(info->dev);
+ /* For IOMMU that supports device IOTLB throttling (DIT), we assign
+ * PFSID to the invalidation desc of a VF such that IOMMU HW can gauge
+ * queue depth at PF level. If DIT is not set, PFSID will be treated as
+ * reserved, which should be set to 0.
+ */
+ if (!ecap_dit(info->iommu->ecap))
+ info->pfsid = 0;
+ else {
+ struct pci_dev *pf_pdev;
+
+ /* pdev will be returned if device is not a vf */
+ pf_pdev = pci_physfn(pdev);
+ info->pfsid = PCI_DEVID(pf_pdev->bus->number, pf_pdev->devfn);
+ }
#ifdef CONFIG_INTEL_IOMMU_SVM
/* The PCIe spec, in its wisdom, declares that the behaviour of
@@ -1568,7 +1582,8 @@ static void iommu_flush_dev_iotlb(struct dmar_domain *domain,
sid = info->bus << 8 | info->devfn;
qdep = info->ats_qdep;
- qi_flush_dev_iotlb(info->iommu, sid, qdep, addr, mask);
+ qi_flush_dev_iotlb(info->iommu, sid, info->pfsid,
+ qdep, addr, mask);
}
spin_unlock_irqrestore(&device_domain_lock, flags);
}
diff --git a/include/linux/intel-iommu.h b/include/linux/intel-iommu.h
index af1c05f..7fd9fbae 100644
--- a/include/linux/intel-iommu.h
+++ b/include/linux/intel-iommu.h
@@ -456,9 +456,8 @@ extern void qi_flush_context(struct intel_iommu *iommu, u16 did, u16 sid,
u8 fm, u64 type);
extern void qi_flush_iotlb(struct intel_iommu *iommu, u16 did, u64 addr,
unsigned int size_order, u64 type);
-extern void qi_flush_dev_iotlb(struct intel_iommu *iommu, u16 sid, u16 qdep,
- u64 addr, unsigned mask);
-
+extern void qi_flush_dev_iotlb(struct intel_iommu *iommu, u16 sid, u16 pfsid,
+ u16 qdep, u64 addr, unsigned mask);
extern int qi_submit_sync(struct qi_desc *desc, struct intel_iommu *iommu);
extern int dmar_ir_support(void);
--
2.7.4
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH v2 1/2] iommu/vt-d: add definitions for PFSID
2018-06-07 16:56 ` [PATCH v2 1/2] iommu/vt-d: add definitions for PFSID Jacob Pan
@ 2018-06-20 20:25 ` Jacob Pan
0 siblings, 0 replies; 5+ messages in thread
From: Jacob Pan @ 2018-06-20 20:25 UTC (permalink / raw)
To: iommu, LKML, Joerg Roedel, David Woodhouse
Cc: stable, Ashok Raj, Lu Baolu, jacob.jun.pan
Hi Joerg/David,
Any comments on this? I will rebase to 18-rc1.
Thanks,
Jacob
On Thu, 7 Jun 2018 09:56:59 -0700
Jacob Pan <jacob.jun.pan@linux.intel.com> wrote:
> When SRIOV VF device IOTLB is invalidated, we need to provide
> the PF source ID such that IOMMU hardware can gauge the depth
> of invalidation queue which is shared among VFs. This is needed
> when device invalidation throttle (DIT) capability is supported.
>
> This patch adds bit definitions for checking and tracking PFSID.
>
> Signed-off-by: Jacob Pan <jacob.jun.pan@linux.intel.com>
> Cc: stable@vger.kernel.org
> Cc: "Ashok Raj" <ashok.raj@intel.com>
> Cc: "Lu Baolu" <baolu.lu@linux.intel.com>
> ---
> drivers/iommu/intel-iommu.c | 1 +
> include/linux/intel-iommu.h | 3 +++
> 2 files changed, 4 insertions(+)
>
> diff --git a/drivers/iommu/intel-iommu.c b/drivers/iommu/intel-iommu.c
> index 749d8f2..3d77d61 100644
> --- a/drivers/iommu/intel-iommu.c
> +++ b/drivers/iommu/intel-iommu.c
> @@ -422,6 +422,7 @@ struct device_domain_info {
> struct list_head global; /* link to global list */
> u8 bus; /* PCI bus number */
> u8 devfn; /* PCI devfn number */
> + u16 pfsid; /* SRIOV physical function source
> ID */ u8 pasid_supported:3;
> u8 pasid_enabled:1;
> u8 pri_supported:1;
> diff --git a/include/linux/intel-iommu.h b/include/linux/intel-iommu.h
> index ef169d6..af1c05f 100644
> --- a/include/linux/intel-iommu.h
> +++ b/include/linux/intel-iommu.h
> @@ -114,6 +114,7 @@
> * Extended Capability Register
> */
>
> +#define ecap_dit(e) ((e >> 41) & 0x1)
> #define ecap_pasid(e) ((e >> 40) & 0x1)
> #define ecap_pss(e) ((e >> 35) & 0x1f)
> #define ecap_eafs(e) ((e >> 34) & 0x1)
> @@ -284,6 +285,7 @@ enum {
> #define QI_DEV_IOTLB_SID(sid) ((u64)((sid) & 0xffff) << 32)
> #define QI_DEV_IOTLB_QDEP(qdep) (((qdep) & 0x1f) << 16)
> #define QI_DEV_IOTLB_ADDR(addr) ((u64)(addr) & VTD_PAGE_MASK)
> +#define QI_DEV_IOTLB_PFSID(pfsid) (((u64)(pfsid & 0xf) << 12) |
> ((u64)(pfsid & 0xfff) << 52)) #define QI_DEV_IOTLB_SIZE 1
> #define QI_DEV_IOTLB_MAX_INVS 32
>
> @@ -308,6 +310,7 @@ enum {
> #define QI_DEV_EIOTLB_PASID(p) (((u64)p) << 32)
> #define QI_DEV_EIOTLB_SID(sid) ((u64)((sid) & 0xffff) << 16)
> #define QI_DEV_EIOTLB_QDEP(qd) ((u64)((qd) & 0x1f) << 4)
> +#define QI_DEV_EIOTLB_PFSID(pfsid) (((u64)(pfsid & 0xf) << 12) |
> ((u64)(pfsid & 0xfff) << 52)) #define QI_DEV_EIOTLB_MAX_INVS 32
>
> #define QI_PGRP_IDX(idx) (((u64)(idx)) << 55)
[Jacob Pan]
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v2 0/2] iommu/vt-d: pfsid fix
2018-06-07 16:56 [PATCH v2 0/2] iommu/vt-d: pfsid fix Jacob Pan
2018-06-07 16:56 ` [PATCH v2 1/2] iommu/vt-d: add definitions for PFSID Jacob Pan
2018-06-07 16:57 ` [PATCH v2 2/2] iommu/vt-d: fix dev iotlb pfsid use Jacob Pan
@ 2018-07-06 11:26 ` Joerg Roedel
2 siblings, 0 replies; 5+ messages in thread
From: Joerg Roedel @ 2018-07-06 11:26 UTC (permalink / raw)
To: Jacob Pan; +Cc: iommu, LKML, David Woodhouse
On Thu, Jun 07, 2018 at 09:56:58AM -0700, Jacob Pan wrote:
> When device invalidation throttling(DIT) is supported by an IOMMU, device TLB
> invalidation should include physical function source ID(PFSID).
>
> Changes since v1:
> - Fixed compile error when CONFIG_PCI_ATS is not set
> - Simplified how PF source ID is retrieved
>
> Jacob Pan (2):
> iommu/vt-d: add definitions for PFSID
> iommu/vt-d: fix dev iotlb pfsid use
Applied, thanks Jacob.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2018-07-06 11:26 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-06-07 16:56 [PATCH v2 0/2] iommu/vt-d: pfsid fix Jacob Pan
2018-06-07 16:56 ` [PATCH v2 1/2] iommu/vt-d: add definitions for PFSID Jacob Pan
2018-06-20 20:25 ` Jacob Pan
2018-06-07 16:57 ` [PATCH v2 2/2] iommu/vt-d: fix dev iotlb pfsid use Jacob Pan
2018-07-06 11:26 ` [PATCH v2 0/2] iommu/vt-d: pfsid fix Joerg Roedel
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).