diff options
author | Pascal van Leeuwen <pascalvanl@gmail.com> | 2019-09-06 10:31:52 -0400 |
---|---|---|
committer | Herbert Xu <herbert@gondor.apana.org.au> | 2019-09-13 07:17:58 -0400 |
commit | b2d92ac1c5eebcb0510939edfdfc2e87330f6679 (patch) | |
tree | 41a0c6d4b70a5859fef1f6a891b30c1844693c25 /drivers | |
parent | 35c0e6c375ac7a09d1b099ceea101a2258857afa (diff) |
crypto: inside-secure - Base RD fetchcount on actual RD FIFO size
This patch derives the result descriptor fetch count from the actual
FIFO size advertised by the hardware. Fetching result descriptors
one at a time is a performance bottleneck for small blocks, especially
on hardware with multiple pipes. Even moreso if the HW has few rings.
Signed-off-by: Pascal van Leeuwen <pvanleeuwen@verimatrix.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/crypto/inside-secure/safexcel.c | 37 | ||||
-rw-r--r-- | drivers/crypto/inside-secure/safexcel.h | 15 |
2 files changed, 40 insertions, 12 deletions
diff --git a/drivers/crypto/inside-secure/safexcel.c b/drivers/crypto/inside-secure/safexcel.c index 32366f703332..acf26dfa7e94 100644 --- a/drivers/crypto/inside-secure/safexcel.c +++ b/drivers/crypto/inside-secure/safexcel.c | |||
@@ -357,13 +357,22 @@ static int safexcel_hw_setup_cdesc_rings(struct safexcel_crypto_priv *priv) | |||
357 | static int safexcel_hw_setup_rdesc_rings(struct safexcel_crypto_priv *priv) | 357 | static int safexcel_hw_setup_rdesc_rings(struct safexcel_crypto_priv *priv) |
358 | { | 358 | { |
359 | u32 hdw, rd_size_rnd, val; | 359 | u32 hdw, rd_size_rnd, val; |
360 | int i; | 360 | int i, rd_fetch_cnt; |
361 | |||
362 | hdw = readl(EIP197_HIA_AIC_G(priv) + EIP197_HIA_OPTIONS); | ||
363 | hdw &= GENMASK(27, 25); | ||
364 | hdw >>= 25; | ||
365 | 361 | ||
366 | rd_size_rnd = (priv->config.rd_size + (BIT(hdw) - 1)) >> hdw; | 362 | /* determine number of RD's we can fetch into the FIFO as one block */ |
363 | rd_size_rnd = (EIP197_RD64_FETCH_SIZE + | ||
364 | BIT(priv->hwconfig.hwdataw) - 1) >> | ||
365 | priv->hwconfig.hwdataw; | ||
366 | if (priv->flags & SAFEXCEL_HW_EIP197) { | ||
367 | /* EIP197: try to fetch enough in 1 go to keep all pipes busy */ | ||
368 | rd_fetch_cnt = (1 << priv->hwconfig.hwrfsize) / rd_size_rnd; | ||
369 | rd_fetch_cnt = min_t(uint, rd_fetch_cnt, | ||
370 | (priv->config.pes * EIP197_FETCH_DEPTH)); | ||
371 | } else { | ||
372 | /* for the EIP97, just fetch all that fits minus 1 */ | ||
373 | rd_fetch_cnt = ((1 << priv->hwconfig.hwrfsize) / | ||
374 | rd_size_rnd) - 1; | ||
375 | } | ||
367 | 376 | ||
368 | for (i = 0; i < priv->config.rings; i++) { | 377 | for (i = 0; i < priv->config.rings; i++) { |
369 | /* ring base address */ | 378 | /* ring base address */ |
@@ -376,8 +385,8 @@ static int safexcel_hw_setup_rdesc_rings(struct safexcel_crypto_priv *priv) | |||
376 | priv->config.rd_size, | 385 | priv->config.rd_size, |
377 | EIP197_HIA_RDR(priv, i) + EIP197_HIA_xDR_DESC_SIZE); | 386 | EIP197_HIA_RDR(priv, i) + EIP197_HIA_xDR_DESC_SIZE); |
378 | 387 | ||
379 | writel(((EIP197_FETCH_COUNT * (rd_size_rnd << hdw)) << 16) | | 388 | writel(((rd_fetch_cnt * (rd_size_rnd << hdw)) << 16) | |
380 | (EIP197_FETCH_COUNT * priv->config.rd_offset), | 389 | (rd_fetch_cnt * priv->config.rd_offset), |
381 | EIP197_HIA_RDR(priv, i) + EIP197_HIA_xDR_CFG); | 390 | EIP197_HIA_RDR(priv, i) + EIP197_HIA_xDR_CFG); |
382 | 391 | ||
383 | /* Configure DMA tx control */ | 392 | /* Configure DMA tx control */ |
@@ -1244,12 +1253,17 @@ static int safexcel_probe_generic(void *pdev, | |||
1244 | priv->hwconfig.hwcfsize = ((hiaopt >> EIP197_CFSIZE_OFFSET) & | 1253 | priv->hwconfig.hwcfsize = ((hiaopt >> EIP197_CFSIZE_OFFSET) & |
1245 | EIP197_CFSIZE_MASK) + | 1254 | EIP197_CFSIZE_MASK) + |
1246 | EIP197_CFSIZE_ADJUST; | 1255 | EIP197_CFSIZE_ADJUST; |
1256 | priv->hwconfig.hwrfsize = ((hiaopt >> EIP197_RFSIZE_OFFSET) & | ||
1257 | EIP197_RFSIZE_MASK) + | ||
1258 | EIP197_RFSIZE_ADJUST; | ||
1247 | } else { | 1259 | } else { |
1248 | /* EIP97 */ | 1260 | /* EIP97 */ |
1249 | priv->hwconfig.hwdataw = (hiaopt >> EIP197_HWDATAW_OFFSET) & | 1261 | priv->hwconfig.hwdataw = (hiaopt >> EIP197_HWDATAW_OFFSET) & |
1250 | EIP97_HWDATAW_MASK; | 1262 | EIP97_HWDATAW_MASK; |
1251 | priv->hwconfig.hwcfsize = (hiaopt >> EIP97_CFSIZE_OFFSET) & | 1263 | priv->hwconfig.hwcfsize = (hiaopt >> EIP97_CFSIZE_OFFSET) & |
1252 | EIP97_CFSIZE_MASK; | 1264 | EIP97_CFSIZE_MASK; |
1265 | priv->hwconfig.hwrfsize = (hiaopt >> EIP97_RFSIZE_OFFSET) & | ||
1266 | EIP97_RFSIZE_MASK; | ||
1253 | } | 1267 | } |
1254 | 1268 | ||
1255 | /* Get supported algorithms from EIP96 transform engine */ | 1269 | /* Get supported algorithms from EIP96 transform engine */ |
@@ -1257,10 +1271,11 @@ static int safexcel_probe_generic(void *pdev, | |||
1257 | EIP197_PE_EIP96_OPTIONS(0)); | 1271 | EIP197_PE_EIP96_OPTIONS(0)); |
1258 | 1272 | ||
1259 | /* Print single info line describing what we just detected */ | 1273 | /* Print single info line describing what we just detected */ |
1260 | dev_info(priv->dev, "EIP%d:%x(%d)-HIA:%x(%d,%d),PE:%x,alg:%08x\n", peid, | 1274 | dev_info(priv->dev, "EIP%d:%x(%d)-HIA:%x(%d,%d,%d),PE:%x,alg:%08x\n", |
1261 | priv->hwconfig.hwver, hwctg, priv->hwconfig.hiaver, | 1275 | peid, priv->hwconfig.hwver, hwctg, priv->hwconfig.hiaver, |
1262 | priv->hwconfig.hwdataw, priv->hwconfig.hwcfsize, | 1276 | priv->hwconfig.hwdataw, priv->hwconfig.hwcfsize, |
1263 | priv->hwconfig.pever, priv->hwconfig.algo_flags); | 1277 | priv->hwconfig.hwrfsize, priv->hwconfig.pever, |
1278 | priv->hwconfig.algo_flags); | ||
1264 | 1279 | ||
1265 | safexcel_configure(priv); | 1280 | safexcel_configure(priv); |
1266 | 1281 | ||
diff --git a/drivers/crypto/inside-secure/safexcel.h b/drivers/crypto/inside-secure/safexcel.h index 2da757d5b404..7d740b31c056 100644 --- a/drivers/crypto/inside-secure/safexcel.h +++ b/drivers/crypto/inside-secure/safexcel.h | |||
@@ -30,7 +30,6 @@ | |||
30 | #define EIP197_DEFAULT_RING_SIZE 400 | 30 | #define EIP197_DEFAULT_RING_SIZE 400 |
31 | #define EIP197_MAX_TOKENS 18 | 31 | #define EIP197_MAX_TOKENS 18 |
32 | #define EIP197_MAX_RINGS 4 | 32 | #define EIP197_MAX_RINGS 4 |
33 | #define EIP197_FETCH_COUNT 1 | ||
34 | #define EIP197_FETCH_DEPTH 2 | 33 | #define EIP197_FETCH_DEPTH 2 |
35 | #define EIP197_MAX_BATCH_SZ 64 | 34 | #define EIP197_MAX_BATCH_SZ 64 |
36 | 35 | ||
@@ -234,6 +233,11 @@ | |||
234 | #define EIP97_CFSIZE_OFFSET 8 | 233 | #define EIP97_CFSIZE_OFFSET 8 |
235 | #define EIP197_CFSIZE_MASK GENMASK(3, 0) | 234 | #define EIP197_CFSIZE_MASK GENMASK(3, 0) |
236 | #define EIP97_CFSIZE_MASK GENMASK(4, 0) | 235 | #define EIP97_CFSIZE_MASK GENMASK(4, 0) |
236 | #define EIP197_RFSIZE_OFFSET 12 | ||
237 | #define EIP197_RFSIZE_ADJUST 4 | ||
238 | #define EIP97_RFSIZE_OFFSET 12 | ||
239 | #define EIP197_RFSIZE_MASK GENMASK(3, 0) | ||
240 | #define EIP97_RFSIZE_MASK GENMASK(4, 0) | ||
237 | 241 | ||
238 | /* EIP197_HIA_AIC_R_ENABLE_CTRL */ | 242 | /* EIP197_HIA_AIC_R_ENABLE_CTRL */ |
239 | #define EIP197_CDR_IRQ(n) BIT((n) * 2) | 243 | #define EIP197_CDR_IRQ(n) BIT((n) * 2) |
@@ -462,6 +466,14 @@ struct safexcel_result_desc { | |||
462 | struct result_data_desc result_data; | 466 | struct result_data_desc result_data; |
463 | } __packed; | 467 | } __packed; |
464 | 468 | ||
469 | /* | ||
470 | * The EIP(1)97 only needs to fetch the descriptor part of | ||
471 | * the result descriptor, not the result token part! | ||
472 | */ | ||
473 | #define EIP197_RD64_FETCH_SIZE ((sizeof(struct safexcel_result_desc) -\ | ||
474 | sizeof(struct result_data_desc)) /\ | ||
475 | sizeof(u32)) | ||
476 | |||
465 | struct safexcel_token { | 477 | struct safexcel_token { |
466 | u32 packet_length:17; | 478 | u32 packet_length:17; |
467 | u8 stat:2; | 479 | u8 stat:2; |
@@ -691,6 +703,7 @@ struct safexcel_hwconfig { | |||
691 | int pever; | 703 | int pever; |
692 | int hwdataw; | 704 | int hwdataw; |
693 | int hwcfsize; | 705 | int hwcfsize; |
706 | int hwrfsize; | ||
694 | }; | 707 | }; |
695 | 708 | ||
696 | struct safexcel_crypto_priv { | 709 | struct safexcel_crypto_priv { |