Received: by 2002:a25:c205:0:0:0:0:0 with SMTP id s5csp2191211ybf; Mon, 2 Mar 2020 03:55:42 -0800 (PST) X-Google-Smtp-Source: APXvYqyaSsS7u2TSC52siFr2LEDRY/BkguTYRh9fa+yPk9eZcY4yLOe7CBe/5ySn1wNaB5zsav5i X-Received: by 2002:aca:cccb:: with SMTP id c194mr8623941oig.15.1583150142625; Mon, 02 Mar 2020 03:55:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1583150142; cv=none; d=google.com; s=arc-20160816; b=U64ch9V12OFoAyutUb0tMBreL+l+lscwyePqtZYi9ods8Y2jzYbJN2h499geOfG5gq Y54a4mzn6JEFSa8koa74R1muBM2w+LjJyaMYoB4I23ul4mHcWz5uAPLqV0/kEGvDnJKc KXHV9CL/0YCPmKWhwR8IW3YM6/LSje18RNVykEvCykD4xb7nKG7nrU8VpDnrcuWIJgd4 5w11LZJt8tiyA5XoXWdzT1hsWcPhPAVtgurPO7VlsnQZTf+7YhntdY2GRDjnooY4G0xX Za1+dKbnQmwCRmKqZxXfsfTnGKfpShKkK3IIq5GWHKoeGXH9Cvrjc9lep5erI1VD0xu+ bSwQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :organization:references:in-reply-to:message-id:subject:cc:to:from :date; bh=jT5Ba+exm7lIjfEil/leMEHbTEFD/ZDLC4ozdyYquKg=; b=OmrWNL5ldnk/WU9er9qRL1Fqn5KNGVaaBJzBIlLtoZpZ9jYUXkVB0GHwFJyLzWivAe 5ViPV9eCf03pkHZ5zsgVwqEr0bhw5JSKi+RKOwNcdOv65VB1Dc0W5OuyMXLv6YzbJKgy d0mBU2jDOdwudAhQDZYHyPeskkBcRM46Ck1CSHePAJ4A95s0JGv5v+WRI2afqPr3z6Mz JuV5+sAzj37mcbOHgmEr3Dvz4fBoY+zVQKrJnIKAG/XuIt7GH88w8bNSTo6tfv3GjAL3 qnYBTiYnYnkHAKffwoua3vfrCTPrfW3sX1pHw4LEFmESMYAu2F4FHlc+Zfi43F0OtSNZ HQsQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q64si3130341oic.155.2020.03.02.03.55.30; Mon, 02 Mar 2020 03:55:42 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727717AbgCBLyM (ORCPT + 99 others); Mon, 2 Mar 2020 06:54:12 -0500 Received: from lhrrgout.huawei.com ([185.176.76.210]:2490 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727485AbgCBLyM (ORCPT ); Mon, 2 Mar 2020 06:54:12 -0500 Received: from LHREML711-CAH.china.huawei.com (unknown [172.18.7.107]) by Forcepoint Email with ESMTP id 886973436FDF33285904; Mon, 2 Mar 2020 11:54:11 +0000 (GMT) Received: from lhreml710-chm.china.huawei.com (10.201.108.61) by LHREML711-CAH.china.huawei.com (10.201.108.34) with Microsoft SMTP Server (TLS) id 14.3.408.0; Mon, 2 Mar 2020 11:54:10 +0000 Received: from localhost (10.202.226.57) by lhreml710-chm.china.huawei.com (10.201.108.61) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5; Mon, 2 Mar 2020 11:54:10 +0000 Date: Mon, 2 Mar 2020 11:54:09 +0000 From: Jonathan Cameron To: Zaibo Xu CC: , , , , , , , , Subject: Re: [PATCH v2 3/5] crypto: hisilicon/sec2 - Add iommu status check Message-ID: <20200302115409.0000685e@Huawei.com> In-Reply-To: <1583129716-28382-4-git-send-email-xuzaibo@huawei.com> References: <1583129716-28382-1-git-send-email-xuzaibo@huawei.com> <1583129716-28382-4-git-send-email-xuzaibo@huawei.com> Organization: Huawei Technologies Research and Development (UK) Ltd. X-Mailer: Claws Mail 3.17.4 (GTK+ 2.24.32; i686-w64-mingw32) MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.202.226.57] X-ClientProxiedBy: lhreml730-chm.china.huawei.com (10.201.108.81) To lhreml710-chm.china.huawei.com (10.201.108.61) X-CFilter-Loop: Reflected Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org On Mon, 2 Mar 2020 14:15:14 +0800 Zaibo Xu wrote: > From: liulongfang > > 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 > Reviewed-by: Zaibo Xu This looks like what we ended up with for the SECv1 driver. Reviewed-by: Jonathan Cameron > --- > 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 > #include > #include > +#include > #include > #include > #include > @@ -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; >