LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH 0/2] crypto: hisilicon - some misc bugfix for SEC engine
@ 2021-08-06  9:58 Kai Ye
  2021-08-06  9:58 ` [PATCH 1/2] crypto: hisilicon/sec - fix the abnormal exiting process Kai Ye
  2021-08-06  9:58 ` [PATCH 2/2] crypto: hisilicon/sec - modify the hardware endian configuration Kai Ye
  0 siblings, 2 replies; 4+ messages in thread
From: Kai Ye @ 2021-08-06  9:58 UTC (permalink / raw)
  To: herbert; +Cc: linux-crypto, linux-kernel, wangzhou1, yekai13

some misc bugfix for SEC engine.

Kai Ye (2):
  crypto: hisilicon/sec - fix the abnormal exiting process
  crypto: hisilicon/sec - modify the hardware endian configuration

 drivers/crypto/hisilicon/sec2/sec.h      |  5 -----
 drivers/crypto/hisilicon/sec2/sec_main.c | 38 +++++++++++---------------------
 2 files changed, 13 insertions(+), 30 deletions(-)

-- 
2.7.4


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 1/2] crypto: hisilicon/sec - fix the abnormal exiting process
  2021-08-06  9:58 [PATCH 0/2] crypto: hisilicon - some misc bugfix for SEC engine Kai Ye
@ 2021-08-06  9:58 ` Kai Ye
  2021-08-06  9:58 ` [PATCH 2/2] crypto: hisilicon/sec - modify the hardware endian configuration Kai Ye
  1 sibling, 0 replies; 4+ messages in thread
From: Kai Ye @ 2021-08-06  9:58 UTC (permalink / raw)
  To: herbert; +Cc: linux-crypto, linux-kernel, wangzhou1, yekai13

Because the algs registration process has added a judgment.
So need to add the judgment for the abnormal exiting process.

Signed-off-by: Kai Ye <yekai13@huawei.com>
---
 drivers/crypto/hisilicon/sec2/sec_main.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/crypto/hisilicon/sec2/sec_main.c b/drivers/crypto/hisilicon/sec2/sec_main.c
index 490db7b..8addbd7 100644
--- a/drivers/crypto/hisilicon/sec2/sec_main.c
+++ b/drivers/crypto/hisilicon/sec2/sec_main.c
@@ -984,7 +984,8 @@ static int sec_probe(struct pci_dev *pdev, const struct pci_device_id *id)
 	return 0;
 
 err_alg_unregister:
-	hisi_qm_alg_unregister(qm, &sec_devices);
+	if (qm->qp_num >= ctx_q_num)
+		hisi_qm_alg_unregister(qm, &sec_devices);
 err_qm_stop:
 	sec_debugfs_exit(qm);
 	hisi_qm_stop(qm, QM_NORMAL);
-- 
2.7.4


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 2/2] crypto: hisilicon/sec - modify the hardware endian configuration
  2021-08-06  9:58 [PATCH 0/2] crypto: hisilicon - some misc bugfix for SEC engine Kai Ye
  2021-08-06  9:58 ` [PATCH 1/2] crypto: hisilicon/sec - fix the abnormal exiting process Kai Ye
@ 2021-08-06  9:58 ` Kai Ye
  2021-08-12 11:04   ` Herbert Xu
  1 sibling, 1 reply; 4+ messages in thread
From: Kai Ye @ 2021-08-06  9:58 UTC (permalink / raw)
  To: herbert; +Cc: linux-crypto, linux-kernel, wangzhou1, yekai13

When the endian configuration of the hardware is abnormal, it will
cause the SEC engine is faulty that reports empty message. And it
will affect the normal function of the hardware. Currently the soft
configuration method can't restore the faulty device. The endian
needs to be configured according to the system properties. So fix it.

Signed-off-by: Kai Ye <yekai13@huawei.com>
---
 drivers/crypto/hisilicon/sec2/sec.h      |  5 -----
 drivers/crypto/hisilicon/sec2/sec_main.c | 35 ++++++++++----------------------
 2 files changed, 11 insertions(+), 29 deletions(-)

diff --git a/drivers/crypto/hisilicon/sec2/sec.h b/drivers/crypto/hisilicon/sec2/sec.h
index 018415b..d97cf02 100644
--- a/drivers/crypto/hisilicon/sec2/sec.h
+++ b/drivers/crypto/hisilicon/sec2/sec.h
@@ -157,11 +157,6 @@ struct sec_ctx {
 	struct device *dev;
 };
 
-enum sec_endian {
-	SEC_LE = 0,
-	SEC_32BE,
-	SEC_64BE
-};
 
 enum sec_debug_file_index {
 	SEC_CLEAR_ENABLE,
diff --git a/drivers/crypto/hisilicon/sec2/sec_main.c b/drivers/crypto/hisilicon/sec2/sec_main.c
index 8addbd7..f637fc8 100644
--- a/drivers/crypto/hisilicon/sec2/sec_main.c
+++ b/drivers/crypto/hisilicon/sec2/sec_main.c
@@ -312,31 +312,20 @@ static const struct pci_device_id sec_dev_ids[] = {
 };
 MODULE_DEVICE_TABLE(pci, sec_dev_ids);
 
-static u8 sec_get_endian(struct hisi_qm *qm)
+static void sec_set_endian(struct hisi_qm *qm)
 {
 	u32 reg;
 
-	/*
-	 * As for VF, it is a wrong way to get endian setting by
-	 * reading a register of the engine
-	 */
-	if (qm->pdev->is_virtfn) {
-		dev_err_ratelimited(&qm->pdev->dev,
-				    "cannot access a register in VF!\n");
-		return SEC_LE;
-	}
 	reg = readl_relaxed(qm->io_base + SEC_CONTROL_REG);
-	/* BD little endian mode */
-	if (!(reg & BIT(0)))
-		return SEC_LE;
-
-	/* BD 32-bits big endian mode */
-	else if (!(reg & BIT(1)))
-		return SEC_32BE;
-
-	/* BD 64-bits big endian mode */
-	else
-		return SEC_64BE;
+	reg &= ~(BIT(1) | BIT(0));
+#ifndef CONFIG_64BIT
+	reg |= BIT(1);
+#endif
+
+#ifndef CONFIG_CPU_LITTLE_ENDIAN
+	reg |= BIT(0);
+#endif
+	writel_relaxed(reg, qm->io_base + SEC_CONTROL_REG);
 }
 
 static void sec_open_sva_prefetch(struct hisi_qm *qm)
@@ -429,9 +418,7 @@ static int sec_engine_init(struct hisi_qm *qm)
 		       qm->io_base + SEC_BD_ERR_CHK_EN_REG3);
 
 	/* config endian */
-	reg = readl_relaxed(qm->io_base + SEC_CONTROL_REG);
-	reg |= sec_get_endian(qm);
-	writel_relaxed(reg, qm->io_base + SEC_CONTROL_REG);
+	sec_set_endian(qm);
 
 	return 0;
 }
-- 
2.7.4


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 2/2] crypto: hisilicon/sec - modify the hardware endian configuration
  2021-08-06  9:58 ` [PATCH 2/2] crypto: hisilicon/sec - modify the hardware endian configuration Kai Ye
@ 2021-08-12 11:04   ` Herbert Xu
  0 siblings, 0 replies; 4+ messages in thread
From: Herbert Xu @ 2021-08-12 11:04 UTC (permalink / raw)
  To: Kai Ye; +Cc: linux-crypto, linux-kernel, wangzhou1

On Fri, Aug 06, 2021 at 05:58:34PM +0800, Kai Ye wrote:
>
> +	reg &= ~(BIT(1) | BIT(0));
> +#ifndef CONFIG_64BIT
> +	reg |= BIT(1);
> +#endif
> +
> +#ifndef CONFIG_CPU_LITTLE_ENDIAN
> +	reg |= BIT(0);
> +#endif

Please rewrite these without ifdefs.  For example,

	if (!IS_ENABLED(CONFIG_64BIT))
		reg |= BIT(1);
	if (!IS_ENABLED(CONFIG_CPU_LITTLE_ENDIAN))
		reg |= BIT(0);

I can't vouch for the logic here so please double-check.

Thanks,
-- 
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-08-12 11:04 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-06  9:58 [PATCH 0/2] crypto: hisilicon - some misc bugfix for SEC engine Kai Ye
2021-08-06  9:58 ` [PATCH 1/2] crypto: hisilicon/sec - fix the abnormal exiting process Kai Ye
2021-08-06  9:58 ` [PATCH 2/2] crypto: hisilicon/sec - modify the hardware endian configuration Kai Ye
2021-08-12 11:04   ` Herbert Xu

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).