2020-03-02 06:19:25

by Xu Zaibo

[permalink] [raw]
Subject: [PATCH v2 0/5] crypto: hisilicon - Improve SEC performance

From: liulongfang <[email protected]>

Improve SEC throughput by allocating a workqueue for each device
instead of one workqueue for all SEC devices. What's more,
when IOMMU translation is turned on, the plat buffer (pbuffer)
will be reserved for small packets (<512Bytes) to
which small packets are copied. This can avoid DMA mapping on
user small packets and improve performance.

This series is based on:
git://git.kernel.org/pub/scm/linux/kernel/git/herbert/cryptodev-2.6.git

Changes v1 -> v2:
- Split pbuf patch into two patches.
- Move 'use_pbuf' from 'qp_ctx' to TFM request.
- Misc fixes on coding style.

Shukun Tan (1):
crypto: hisilicon - Use one workqueue per qm instead of per qp

liulongfang (3):
crypto: hisilicon/sec2 - Add iommu status check
crypto: hisilicon/sec2 - Update IV and MAC operation
crypto: hisilicon/sec2 - Add pbuffer mode for SEC driver

yekai13 (1):
crypto: hisilicon/sec2 - Add workqueue for SEC driver.

drivers/crypto/hisilicon/qm.c | 38 ++---
drivers/crypto/hisilicon/qm.h | 5 +-
drivers/crypto/hisilicon/sec2/sec.h | 7 +
drivers/crypto/hisilicon/sec2/sec_crypto.c | 242 ++++++++++++++++++++++++-----
drivers/crypto/hisilicon/sec2/sec_main.c | 45 +++++-
5 files changed, 274 insertions(+), 63 deletions(-)

--
2.8.1


2020-03-02 06:19:29

by Xu Zaibo

[permalink] [raw]
Subject: [PATCH v2 3/5] crypto: hisilicon/sec2 - Add iommu status check

From: liulongfang <[email protected]>

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 <[email protected]>
Reviewed-by: Zaibo Xu <[email protected]>
---
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;

--
2.8.1

2020-03-02 11:55:42

by Jonathan Cameron

[permalink] [raw]
Subject: Re: [PATCH v2 3/5] crypto: hisilicon/sec2 - Add iommu status check

On Mon, 2 Mar 2020 14:15:14 +0800
Zaibo Xu <[email protected]> wrote:

> From: liulongfang <[email protected]>
>
> 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 <[email protected]>
> Reviewed-by: Zaibo Xu <[email protected]>

This looks like what we ended up with for the SECv1 driver.

Reviewed-by: Jonathan Cameron <[email protected]>
> ---
> 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;
>


2020-03-03 01:26:04

by Xu Zaibo

[permalink] [raw]
Subject: Re: [PATCH v2 3/5] crypto: hisilicon/sec2 - Add iommu status check

Hi,


On 2020/3/2 19:54, Jonathan Cameron wrote:
> On Mon, 2 Mar 2020 14:15:14 +0800
> Zaibo Xu <[email protected]> wrote:
>
>> From: liulongfang <[email protected]>
>>
>> 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 <[email protected]>
>> Reviewed-by: Zaibo Xu <[email protected]>
> This looks like what we ended up with for the SECv1 driver.
Yes.
>
> Reviewed-by: Jonathan Cameron <[email protected]>
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;
>>
>
> .
>


2020-03-03 02:16:50

by Yunsheng Lin

[permalink] [raw]
Subject: Re: [PATCH v2 3/5] crypto: hisilicon/sec2 - Add iommu status check

On 2020/3/2 19:54, Jonathan Cameron wrote:
> On Mon, 2 Mar 2020 14:15:14 +0800
> Zaibo Xu <[email protected]> wrote:
>
>> From: liulongfang <[email protected]>
>>
>> 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 <[email protected]>
>> Reviewed-by: Zaibo Xu <[email protected]>
>
> This looks like what we ended up with for the SECv1 driver.
>
> Reviewed-by: Jonathan Cameron <[email protected]>
>> ---
>> 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
> [email protected]
> http://hulk.huawei.com/mailman/listinfo/linuxarm
>
> .
>

2020-03-03 02:22:48

by Xu Zaibo

[permalink] [raw]
Subject: Re: [PATCH v2 3/5] crypto: hisilicon/sec2 - Add iommu status check


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 <[email protected]> wrote:
>>
>>> From: liulongfang <[email protected]>
>>>
>>> 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 <[email protected]>
>>> Reviewed-by: Zaibo Xu <[email protected]>
>> This looks like what we ended up with for the SECv1 driver.
>>
>> Reviewed-by: Jonathan Cameron <[email protected]>
>>> ---
>>> 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
>> [email protected]
>> http://hulk.huawei.com/mailman/listinfo/linuxarm
>>
>> .
>>
> .
>