Skip to contentSkip to conversation

crypto: hisilicon - some misc bugfix for SEC engine

PATCH In review Kai Ye 2 participants 4 messages Aug 13, 2021 – Aug 21, 2021

Subsystems (2)
lore
Share & tools
lore

Kai Ye

author
#0 lore raw

v4 cover crypto: hisilicon - some misc bugfix for SEC engine

some misc bugfix for SEC engine.

changes v1->v2:
delete the "ifdefs", use the IS_ENABLED.
changes v2->v3:
fix merge conflict
changes v3->v4:
fix build error.

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 | 34 +++++++++++---------------------
 2 files changed, 11 insertions(+), 28 deletions(-)
Signature · 1 line
2.7.4
author
#1 lore raw

PATCH v4 1/2 crypto: hisilicon/sec - fix the abnormal exiting process

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

---
 drivers/crypto/hisilicon/sec2/sec_main.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/crypto/hisilicon/sec2/sec_main.c +2 -1
index db4dbcf..45a1ddd 100644
@@ -1020,7 +1020,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);
Signature · 1 line
2.7.4
author
#2 lore raw

PATCH v4 2/2 crypto: hisilicon/sec - modify the hardware endian configuration

In reply to Kai Ye

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.

---
 drivers/crypto/hisilicon/sec2/sec.h      |  5 -----
 drivers/crypto/hisilicon/sec2/sec_main.c | 31 +++++++++----------------------
 2 files changed, 9 insertions(+), 27 deletions(-)
drivers/crypto/hisilicon/sec2/sec.h +0 -5
index 8c3621d..34c9c22 100644
@@ -206,11 +206,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,
drivers/crypto/hisilicon/sec2/sec_main.c +9 -22
index 45a1ddd..2250c81 100644
@@ -318,31 +318,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;
+	reg &= ~(BIT(1) | BIT(0));
+	if (!IS_ENABLED(CONFIG_64BIT))
+		reg |= BIT(1);
 
-	/* BD 32-bits big endian mode */
-	else if (!(reg & BIT(1)))
-		return SEC_32BE;
 
-	/* BD 64-bits big endian mode */
-	else
-		return SEC_64BE;
+	if (!IS_ENABLED(CONFIG_CPU_LITTLE_ENDIAN))
+		reg |= BIT(0);
+
+	writel_relaxed(reg, qm->io_base + SEC_CONTROL_REG);
 }
 
 static void sec_open_sva_prefetch(struct hisi_qm *qm)
@@ -463,9 +452,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);
 
 	sec_enable_clock_gate(qm);
 
Signature · 1 line
2.7.4
maintainer
#3 lore raw
In reply to Kai Ye
Quoted 9 lines · Kai Ye

some misc bugfix for SEC engine.

changes v1->v2:
delete the "ifdefs", use the IS_ENABLED.
changes v2->v3:
fix merge conflict
changes v3->v4:
fix build error.

Quoted 7 lines

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 | 34 +++++++++++---------------------
 2 files changed, 11 insertions(+), 28 deletions(-)

All applied. Thanks.

Signature · 3 lines
Email: Herbert Xu <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt