Message ID | 1583129716-28382-4-git-send-email-xuzaibo@huawei.com (mailing list archive) |
---|---|
State | Superseded |
Delegated to: | Herbert Xu |
Headers | show |
Series | crypto: hisilicon - Improve SEC performance | expand |
On Mon, 2 Mar 2020 14:15:14 +0800 Zaibo Xu <xuzaibo@huawei.com> wrote: > From: liulongfang <liulongfang@huawei.com> > > 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: liulongfang <liulongfang@huawei.com> > Reviewed-by: Zaibo Xu <xuzaibo@huawei.com> This looks like what we ended up with for the SECv1 driver. Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> > --- > drivers/crypto/hisilicon/sec2/sec.h | 1 + > drivers/crypto/hisilicon/sec2/sec_main.c | 19 +++++++++++++++++++ > 2 files changed, 20 insertions(+) > > diff --git a/drivers/crypto/hisilicon/sec2/sec.h b/drivers/crypto/hisilicon/sec2/sec.h > index 13e2d8d..eab0d22 100644 > --- a/drivers/crypto/hisilicon/sec2/sec.h > +++ b/drivers/crypto/hisilicon/sec2/sec.h > @@ -165,6 +165,7 @@ struct sec_dev { > struct list_head list; > struct sec_debug debug; > u32 ctx_q_num; > + bool iommu_used; > u32 num_vfs; > unsigned long status; > }; > diff --git a/drivers/crypto/hisilicon/sec2/sec_main.c b/drivers/crypto/hisilicon/sec2/sec_main.c > index ebafc1c..6466d90 100644 > --- a/drivers/crypto/hisilicon/sec2/sec_main.c > +++ b/drivers/crypto/hisilicon/sec2/sec_main.c > @@ -7,6 +7,7 @@ > #include <linux/debugfs.h> > #include <linux/init.h> > #include <linux/io.h> > +#include <linux/iommu.h> > #include <linux/kernel.h> > #include <linux/module.h> > #include <linux/pci.h> > @@ -826,6 +827,23 @@ static void sec_probe_uninit(struct hisi_qm *qm) > 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) > { > struct sec_dev *sec; > @@ -839,6 +857,7 @@ static int sec_probe(struct pci_dev *pdev, const struct pci_device_id *id) > pci_set_drvdata(pdev, sec); > > sec->ctx_q_num = ctx_q_num; > + sec_iommu_used_check(sec); > > qm = &sec->qm; >
Hi, On 2020/3/2 19:54, Jonathan Cameron wrote: > On Mon, 2 Mar 2020 14:15:14 +0800 > Zaibo Xu <xuzaibo@huawei.com> wrote: > >> From: liulongfang <liulongfang@huawei.com> >> >> 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: liulongfang <liulongfang@huawei.com> >> Reviewed-by: Zaibo Xu <xuzaibo@huawei.com> > This looks like what we ended up with for the SECv1 driver. Yes. > > Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Okay . >> --- >> drivers/crypto/hisilicon/sec2/sec.h | 1 + >> drivers/crypto/hisilicon/sec2/sec_main.c | 19 +++++++++++++++++++ >> 2 files changed, 20 insertions(+) >> >> diff --git a/drivers/crypto/hisilicon/sec2/sec.h b/drivers/crypto/hisilicon/sec2/sec.h >> index 13e2d8d..eab0d22 100644 >> --- a/drivers/crypto/hisilicon/sec2/sec.h >> +++ b/drivers/crypto/hisilicon/sec2/sec.h >> @@ -165,6 +165,7 @@ struct sec_dev { >> struct list_head list; >> struct sec_debug debug; >> u32 ctx_q_num; >> + bool iommu_used; >> u32 num_vfs; >> unsigned long status; >> }; >> diff --git a/drivers/crypto/hisilicon/sec2/sec_main.c b/drivers/crypto/hisilicon/sec2/sec_main.c >> index ebafc1c..6466d90 100644 >> --- a/drivers/crypto/hisilicon/sec2/sec_main.c >> +++ b/drivers/crypto/hisilicon/sec2/sec_main.c >> @@ -7,6 +7,7 @@ >> #include <linux/debugfs.h> >> #include <linux/init.h> >> #include <linux/io.h> >> +#include <linux/iommu.h> >> #include <linux/kernel.h> >> #include <linux/module.h> >> #include <linux/pci.h> >> @@ -826,6 +827,23 @@ static void sec_probe_uninit(struct hisi_qm *qm) >> 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) >> { >> struct sec_dev *sec; >> @@ -839,6 +857,7 @@ static int sec_probe(struct pci_dev *pdev, const struct pci_device_id *id) >> pci_set_drvdata(pdev, sec); >> >> sec->ctx_q_num = ctx_q_num; >> + sec_iommu_used_check(sec); >> >> qm = &sec->qm; >> > > . >
On 2020/3/2 19:54, Jonathan Cameron wrote: > On Mon, 2 Mar 2020 14:15:14 +0800 > Zaibo Xu <xuzaibo@huawei.com> wrote: > >> From: liulongfang <liulongfang@huawei.com> >> >> In order to improve performance of small packets (<512Bytes) >> in SMMU translation scenario,We need to identify the type of IOMMU nit: space after ','. and We -> we for lower case? >> in the SEC probe to process small packets by a different method. >> >> Signed-off-by: liulongfang <liulongfang@huawei.com> >> Reviewed-by: Zaibo Xu <xuzaibo@huawei.com> > > This looks like what we ended up with for the SECv1 driver. > > Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> >> --- >> drivers/crypto/hisilicon/sec2/sec.h | 1 + >> drivers/crypto/hisilicon/sec2/sec_main.c | 19 +++++++++++++++++++ >> 2 files changed, 20 insertions(+) >> >> diff --git a/drivers/crypto/hisilicon/sec2/sec.h b/drivers/crypto/hisilicon/sec2/sec.h >> index 13e2d8d..eab0d22 100644 >> --- a/drivers/crypto/hisilicon/sec2/sec.h >> +++ b/drivers/crypto/hisilicon/sec2/sec.h >> @@ -165,6 +165,7 @@ struct sec_dev { >> struct list_head list; >> struct sec_debug debug; >> u32 ctx_q_num; >> + bool iommu_used; >> u32 num_vfs; >> unsigned long status; >> }; >> diff --git a/drivers/crypto/hisilicon/sec2/sec_main.c b/drivers/crypto/hisilicon/sec2/sec_main.c >> index ebafc1c..6466d90 100644 >> --- a/drivers/crypto/hisilicon/sec2/sec_main.c >> +++ b/drivers/crypto/hisilicon/sec2/sec_main.c >> @@ -7,6 +7,7 @@ >> #include <linux/debugfs.h> >> #include <linux/init.h> >> #include <linux/io.h> >> +#include <linux/iommu.h> >> #include <linux/kernel.h> >> #include <linux/module.h> >> #include <linux/pci.h> >> @@ -826,6 +827,23 @@ static void sec_probe_uninit(struct hisi_qm *qm) >> 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) >> { >> struct sec_dev *sec; >> @@ -839,6 +857,7 @@ static int sec_probe(struct pci_dev *pdev, const struct pci_device_id *id) >> pci_set_drvdata(pdev, sec); >> >> sec->ctx_q_num = ctx_q_num; >> + sec_iommu_used_check(sec); >> >> qm = &sec->qm; >> > > > _______________________________________________ > Linuxarm mailing list > Linuxarm@huawei.com > http://hulk.huawei.com/mailman/listinfo/linuxarm > > . >
On 2020/3/3 10:16, Yunsheng Lin wrote: > On 2020/3/2 19:54, Jonathan Cameron wrote: >> On Mon, 2 Mar 2020 14:15:14 +0800 >> Zaibo Xu <xuzaibo@huawei.com> wrote: >> >>> From: liulongfang <liulongfang@huawei.com> >>> >>> In order to improve performance of small packets (<512Bytes) >>> in SMMU translation scenario,We need to identify the type of IOMMU > nit: space after ','. and We -> we for lower case? yes, indeed. Thanks, Zaibo . > >>> in the SEC probe to process small packets by a different method. >>> >>> Signed-off-by: liulongfang <liulongfang@huawei.com> >>> Reviewed-by: Zaibo Xu <xuzaibo@huawei.com> >> This looks like what we ended up with for the SECv1 driver. >> >> Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> >>> --- >>> drivers/crypto/hisilicon/sec2/sec.h | 1 + >>> drivers/crypto/hisilicon/sec2/sec_main.c | 19 +++++++++++++++++++ >>> 2 files changed, 20 insertions(+) >>> >>> diff --git a/drivers/crypto/hisilicon/sec2/sec.h b/drivers/crypto/hisilicon/sec2/sec.h >>> index 13e2d8d..eab0d22 100644 >>> --- a/drivers/crypto/hisilicon/sec2/sec.h >>> +++ b/drivers/crypto/hisilicon/sec2/sec.h >>> @@ -165,6 +165,7 @@ struct sec_dev { >>> struct list_head list; >>> struct sec_debug debug; >>> u32 ctx_q_num; >>> + bool iommu_used; >>> u32 num_vfs; >>> unsigned long status; >>> }; >>> diff --git a/drivers/crypto/hisilicon/sec2/sec_main.c b/drivers/crypto/hisilicon/sec2/sec_main.c >>> index ebafc1c..6466d90 100644 >>> --- a/drivers/crypto/hisilicon/sec2/sec_main.c >>> +++ b/drivers/crypto/hisilicon/sec2/sec_main.c >>> @@ -7,6 +7,7 @@ >>> #include <linux/debugfs.h> >>> #include <linux/init.h> >>> #include <linux/io.h> >>> +#include <linux/iommu.h> >>> #include <linux/kernel.h> >>> #include <linux/module.h> >>> #include <linux/pci.h> >>> @@ -826,6 +827,23 @@ static void sec_probe_uninit(struct hisi_qm *qm) >>> 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) >>> { >>> struct sec_dev *sec; >>> @@ -839,6 +857,7 @@ static int sec_probe(struct pci_dev *pdev, const struct pci_device_id *id) >>> pci_set_drvdata(pdev, sec); >>> >>> sec->ctx_q_num = ctx_q_num; >>> + sec_iommu_used_check(sec); >>> >>> qm = &sec->qm; >>> >> >> _______________________________________________ >> Linuxarm mailing list >> Linuxarm@huawei.com >> http://hulk.huawei.com/mailman/listinfo/linuxarm >> >> . >> > . >
diff --git a/drivers/crypto/hisilicon/sec2/sec.h b/drivers/crypto/hisilicon/sec2/sec.h index 13e2d8d..eab0d22 100644 --- a/drivers/crypto/hisilicon/sec2/sec.h +++ b/drivers/crypto/hisilicon/sec2/sec.h @@ -165,6 +165,7 @@ struct sec_dev { struct list_head list; struct sec_debug debug; u32 ctx_q_num; + bool iommu_used; u32 num_vfs; unsigned long status; }; diff --git a/drivers/crypto/hisilicon/sec2/sec_main.c b/drivers/crypto/hisilicon/sec2/sec_main.c index ebafc1c..6466d90 100644 --- a/drivers/crypto/hisilicon/sec2/sec_main.c +++ b/drivers/crypto/hisilicon/sec2/sec_main.c @@ -7,6 +7,7 @@ #include <linux/debugfs.h> #include <linux/init.h> #include <linux/io.h> +#include <linux/iommu.h> #include <linux/kernel.h> #include <linux/module.h> #include <linux/pci.h> @@ -826,6 +827,23 @@ static void sec_probe_uninit(struct hisi_qm *qm) 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) { struct sec_dev *sec; @@ -839,6 +857,7 @@ static int sec_probe(struct pci_dev *pdev, const struct pci_device_id *id) pci_set_drvdata(pdev, sec); sec->ctx_q_num = ctx_q_num; + sec_iommu_used_check(sec); qm = &sec->qm;