* [PATCH] iommu/amd: Add prefetch iommu pages command build function
@ 2020-09-05 7:14 Wesley Sheng
2020-09-18 8:49 ` Joerg Roedel
0 siblings, 1 reply; 3+ messages in thread
From: Wesley Sheng @ 2020-09-05 7:14 UTC (permalink / raw)
To: joro, iommu, linux-kernel; +Cc: wesleyshenggit, Wesley Sheng
Add function to build prefetch iommu pages command
Signed-off-by: Wesley Sheng <wesley.sheng@amd.com>
---
drivers/iommu/amd/amd_iommu_types.h | 2 ++
drivers/iommu/amd/iommu.c | 19 +++++++++++++++++++
2 files changed, 21 insertions(+)
diff --git a/drivers/iommu/amd/amd_iommu_types.h b/drivers/iommu/amd/amd_iommu_types.h
index baa31cd2411c..73734a0c4679 100644
--- a/drivers/iommu/amd/amd_iommu_types.h
+++ b/drivers/iommu/amd/amd_iommu_types.h
@@ -173,6 +173,7 @@
#define CMD_INV_IOMMU_PAGES 0x03
#define CMD_INV_IOTLB_PAGES 0x04
#define CMD_INV_IRT 0x05
+#define CMD_PF_IOMMU_PAGES 0x06
#define CMD_COMPLETE_PPR 0x07
#define CMD_INV_ALL 0x08
@@ -181,6 +182,7 @@
#define CMD_INV_IOMMU_PAGES_SIZE_MASK 0x01
#define CMD_INV_IOMMU_PAGES_PDE_MASK 0x02
#define CMD_INV_IOMMU_PAGES_GN_MASK 0x04
+#define CMD_PF_IOMMU_PAGES_INV_MASK 0x10
#define PPR_STATUS_MASK 0xf
#define PPR_STATUS_SHIFT 12
diff --git a/drivers/iommu/amd/iommu.c b/drivers/iommu/amd/iommu.c
index ba9f3dbc5b94..b3971595b0e9 100644
--- a/drivers/iommu/amd/iommu.c
+++ b/drivers/iommu/amd/iommu.c
@@ -976,6 +976,25 @@ static void build_inv_irt(struct iommu_cmd *cmd, u16 devid)
CMD_SET_TYPE(cmd, CMD_INV_IRT);
}
+static void build_pf_iommu_pages(struct iommu_cmd *cmd, u64 address,
+ u16 devid, int pfcnt, bool size,
+ bool inv)
+{
+ memset(cmd, 0, sizeof(*cmd));
+
+ address &= PAGE_MASK;
+
+ cmd->data[0] = devid;
+ cmd->data[0] |= (pfcnt & 0xff) << 24;
+ cmd->data[2] = lower_32_bits(address);
+ cmd->data[3] = upper_32_bits(address;
+ if (size)
+ cmd->data[2] |= CMD_INV_IOMMU_PAGES_SIZE_MASK;
+ if (inv)
+ cmd->data[2] |= CMD_PF_IOMMU_PAGES_INV_MASK;
+ CMD_SET_TYPE(cmd, CMD_PF_IOMMU_PAGES);
+}
+
/*
* Writes the command to the IOMMUs command buffer and informs the
* hardware about the new command.
--
2.16.2
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] iommu/amd: Add prefetch iommu pages command build function
2020-09-05 7:14 [PATCH] iommu/amd: Add prefetch iommu pages command build function Wesley Sheng
@ 2020-09-18 8:49 ` Joerg Roedel
0 siblings, 0 replies; 3+ messages in thread
From: Joerg Roedel @ 2020-09-18 8:49 UTC (permalink / raw)
To: Wesley Sheng; +Cc: iommu, linux-kernel, wesleyshenggit
On Sat, Sep 05, 2020 at 03:14:20PM +0800, Wesley Sheng wrote:
> +static void build_pf_iommu_pages(struct iommu_cmd *cmd, u64 address,
> + u16 devid, int pfcnt, bool size,
> + bool inv)
> +{
> + memset(cmd, 0, sizeof(*cmd));
> +
> + address &= PAGE_MASK;
> +
> + cmd->data[0] = devid;
> + cmd->data[0] |= (pfcnt & 0xff) << 24;
> + cmd->data[2] = lower_32_bits(address);
> + cmd->data[3] = upper_32_bits(address;
> + if (size)
> + cmd->data[2] |= CMD_INV_IOMMU_PAGES_SIZE_MASK;
> + if (inv)
> + cmd->data[2] |= CMD_PF_IOMMU_PAGES_INV_MASK;
> + CMD_SET_TYPE(cmd, CMD_PF_IOMMU_PAGES);
> +}
This also needs to add a user of this function.
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH] iommu/amd: Add prefetch iommu pages command build function
@ 2020-09-06 1:18 Wesley Sheng
0 siblings, 0 replies; 3+ messages in thread
From: Wesley Sheng @ 2020-09-06 1:18 UTC (permalink / raw)
To: joro, iommu, linux-kernel; +Cc: wesleyshenggit, Wesley Sheng
Add function to build prefetch iommu pages command
Signed-off-by: Wesley Sheng <wesley.sheng@amd.com>
---
drivers/iommu/amd/amd_iommu_types.h | 2 ++
drivers/iommu/amd/iommu.c | 19 +++++++++++++++++++
2 files changed, 21 insertions(+)
diff --git a/drivers/iommu/amd/amd_iommu_types.h b/drivers/iommu/amd/amd_iommu_types.h
index baa31cd2411c..73734a0c4679 100644
--- a/drivers/iommu/amd/amd_iommu_types.h
+++ b/drivers/iommu/amd/amd_iommu_types.h
@@ -173,6 +173,7 @@
#define CMD_INV_IOMMU_PAGES 0x03
#define CMD_INV_IOTLB_PAGES 0x04
#define CMD_INV_IRT 0x05
+#define CMD_PF_IOMMU_PAGES 0x06
#define CMD_COMPLETE_PPR 0x07
#define CMD_INV_ALL 0x08
@@ -181,6 +182,7 @@
#define CMD_INV_IOMMU_PAGES_SIZE_MASK 0x01
#define CMD_INV_IOMMU_PAGES_PDE_MASK 0x02
#define CMD_INV_IOMMU_PAGES_GN_MASK 0x04
+#define CMD_PF_IOMMU_PAGES_INV_MASK 0x10
#define PPR_STATUS_MASK 0xf
#define PPR_STATUS_SHIFT 12
diff --git a/drivers/iommu/amd/iommu.c b/drivers/iommu/amd/iommu.c
index ba9f3dbc5b94..b3971595b0e9 100644
--- a/drivers/iommu/amd/iommu.c
+++ b/drivers/iommu/amd/iommu.c
@@ -976,6 +976,25 @@ static void build_inv_irt(struct iommu_cmd *cmd, u16 devid)
CMD_SET_TYPE(cmd, CMD_INV_IRT);
}
+static void build_pf_iommu_pages(struct iommu_cmd *cmd, u64 address,
+ u16 devid, int pfcnt, bool size,
+ bool inv)
+{
+ memset(cmd, 0, sizeof(*cmd));
+
+ address &= PAGE_MASK;
+
+ cmd->data[0] = devid;
+ cmd->data[0] |= (pfcnt & 0xff) << 24;
+ cmd->data[2] = lower_32_bits(address);
+ cmd->data[3] = upper_32_bits(address);
+ if (size)
+ cmd->data[2] |= CMD_INV_IOMMU_PAGES_SIZE_MASK;
+ if (inv)
+ cmd->data[2] |= CMD_PF_IOMMU_PAGES_INV_MASK;
+ CMD_SET_TYPE(cmd, CMD_PF_IOMMU_PAGES);
+}
+
/*
* Writes the command to the IOMMUs command buffer and informs the
* hardware about the new command.
--
2.16.2
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-09-18 8:49 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-05 7:14 [PATCH] iommu/amd: Add prefetch iommu pages command build function Wesley Sheng
2020-09-18 8:49 ` Joerg Roedel
2020-09-06 1:18 Wesley Sheng
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).