Commit 8824bc5e authored by Longfang Liu's avatar Longfang Liu Committed by Herbert Xu

crypto: hisilicon/sec2 - Add iommu status check

In order to improve performance of small packets (<512Bytes)
in SMMU translation scenario, we need to identify the type of IOMMU
in the SEC probe to process small packets by a different method.
Signed-off-by: default avatarLongfang Liu <liulongfang@huawei.com>
Signed-off-by: default avatarZaibo Xu <xuzaibo@huawei.com>
Reviewed-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
parent a13c9711
...@@ -165,6 +165,7 @@ struct sec_dev { ...@@ -165,6 +165,7 @@ struct sec_dev {
struct list_head list; struct list_head list;
struct sec_debug debug; struct sec_debug debug;
u32 ctx_q_num; u32 ctx_q_num;
bool iommu_used;
u32 num_vfs; u32 num_vfs;
unsigned long status; unsigned long status;
}; };
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#include <linux/debugfs.h> #include <linux/debugfs.h>
#include <linux/init.h> #include <linux/init.h>
#include <linux/io.h> #include <linux/io.h>
#include <linux/iommu.h>
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/pci.h> #include <linux/pci.h>
...@@ -832,6 +833,23 @@ static void sec_probe_uninit(struct hisi_qm *qm) ...@@ -832,6 +833,23 @@ static void sec_probe_uninit(struct hisi_qm *qm)
destroy_workqueue(qm->wq); destroy_workqueue(qm->wq);
} }
static void sec_iommu_used_check(struct sec_dev *sec)
{
struct iommu_domain *domain;
struct device *dev = &sec->qm.pdev->dev;
domain = iommu_get_domain_for_dev(dev);
/* Check if iommu is used */
sec->iommu_used = false;
if (domain) {
if (domain->type & __IOMMU_DOMAIN_PAGING)
sec->iommu_used = true;
dev_info(dev, "SMMU Opened, the iommu type = %u\n",
domain->type);
}
}
static int sec_probe(struct pci_dev *pdev, const struct pci_device_id *id) static int sec_probe(struct pci_dev *pdev, const struct pci_device_id *id)
{ {
struct sec_dev *sec; struct sec_dev *sec;
...@@ -845,6 +863,7 @@ static int sec_probe(struct pci_dev *pdev, const struct pci_device_id *id) ...@@ -845,6 +863,7 @@ static int sec_probe(struct pci_dev *pdev, const struct pci_device_id *id)
pci_set_drvdata(pdev, sec); pci_set_drvdata(pdev, sec);
sec->ctx_q_num = ctx_q_num; sec->ctx_q_num = ctx_q_num;
sec_iommu_used_check(sec);
qm = &sec->qm; qm = &sec->qm;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment