From: Wesley Sheng <wesley.sheng@amd.com>
To: <joro@8bytes.com>, <iommu@lists.linux-foundation.org>,
<linux-kernel@vger.kernel.org>
Cc: Wesley Sheng <wesley.sheng@amd.com>, wesleyshenggit@sina.com
Subject: [PATCH] iommu/amd: Add prefetch iommu pages command build function
Date: Sun, 6 Sep 2020 09:18:08 +0800 [thread overview]
Message-ID: <20200906011808.22614-1-wesley.sheng@amd.com> (raw)
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
_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu
next reply other threads:[~2020-09-06 4:52 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-09-06 1:18 Wesley Sheng [this message]
-- strict thread matches above, loose matches on Subject: below --
2020-09-05 7:14 [PATCH] iommu/amd: Add prefetch iommu pages command build function Wesley Sheng
2020-09-18 8:49 ` Joerg Roedel
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200906011808.22614-1-wesley.sheng@amd.com \
--to=wesley.sheng@amd.com \
--cc=iommu@lists.linux-foundation.org \
--cc=joro@8bytes.com \
--cc=linux-kernel@vger.kernel.org \
--cc=wesleyshenggit@sina.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).