Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Pascal van Leeuwen and committed by
Herbert Xu
b2d92ac1 35c0e6c3

+40 -12
+26 -11
drivers/crypto/inside-secure/safexcel.c
··· 357 357 static int safexcel_hw_setup_rdesc_rings(struct safexcel_crypto_priv *priv) 358 358 { 359 359 u32 hdw, rd_size_rnd, val; 360 - int i; 360 + int i, rd_fetch_cnt; 361 361 362 - hdw = readl(EIP197_HIA_AIC_G(priv) + EIP197_HIA_OPTIONS); 363 - hdw &= GENMASK(27, 25); 364 - hdw >>= 25; 365 - 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 377 for (i = 0; i < priv->config.rings; i++) { 369 378 /* ring base address */ ··· 385 376 priv->config.rd_size, 386 377 EIP197_HIA_RDR(priv, i) + EIP197_HIA_xDR_DESC_SIZE); 387 378 388 - writel(((EIP197_FETCH_COUNT * (rd_size_rnd << hdw)) << 16) | 389 - (EIP197_FETCH_COUNT * priv->config.rd_offset), 379 + writel(((rd_fetch_cnt * (rd_size_rnd << hdw)) << 16) | 380 + (rd_fetch_cnt * priv->config.rd_offset), 390 381 EIP197_HIA_RDR(priv, i) + EIP197_HIA_xDR_CFG); 391 382 392 383 /* Configure DMA tx control */ ··· 1253 1244 priv->hwconfig.hwcfsize = ((hiaopt >> EIP197_CFSIZE_OFFSET) & 1254 1245 EIP197_CFSIZE_MASK) + 1255 1246 EIP197_CFSIZE_ADJUST; 1247 + priv->hwconfig.hwrfsize = ((hiaopt >> EIP197_RFSIZE_OFFSET) & 1248 + EIP197_RFSIZE_MASK) + 1249 + EIP197_RFSIZE_ADJUST; 1256 1250 } else { 1257 1251 /* EIP97 */ 1258 1252 priv->hwconfig.hwdataw = (hiaopt >> EIP197_HWDATAW_OFFSET) & 1259 1253 EIP97_HWDATAW_MASK; 1260 1254 priv->hwconfig.hwcfsize = (hiaopt >> EIP97_CFSIZE_OFFSET) & 1261 1255 EIP97_CFSIZE_MASK; 1256 + priv->hwconfig.hwrfsize = (hiaopt >> EIP97_RFSIZE_OFFSET) & 1257 + EIP97_RFSIZE_MASK; 1262 1258 } 1263 1259 1264 1260 /* Get supported algorithms from EIP96 transform engine */ ··· 1271 1257 EIP197_PE_EIP96_OPTIONS(0)); 1272 1258 1273 1259 /* Print single info line describing what we just detected */ 1274 - dev_info(priv->dev, "EIP%d:%x(%d)-HIA:%x(%d,%d),PE:%x,alg:%08x\n", peid, 1275 - priv->hwconfig.hwver, hwctg, priv->hwconfig.hiaver, 1260 + dev_info(priv->dev, "EIP%d:%x(%d)-HIA:%x(%d,%d,%d),PE:%x,alg:%08x\n", 1261 + peid, priv->hwconfig.hwver, hwctg, priv->hwconfig.hiaver, 1276 1262 priv->hwconfig.hwdataw, priv->hwconfig.hwcfsize, 1277 - priv->hwconfig.pever, priv->hwconfig.algo_flags); 1263 + priv->hwconfig.hwrfsize, priv->hwconfig.pever, 1264 + priv->hwconfig.algo_flags); 1278 1265 1279 1266 safexcel_configure(priv); 1280 1267
+14 -1
drivers/crypto/inside-secure/safexcel.h
··· 30 30 #define EIP197_DEFAULT_RING_SIZE 400 31 31 #define EIP197_MAX_TOKENS 18 32 32 #define EIP197_MAX_RINGS 4 33 - #define EIP197_FETCH_COUNT 1 34 33 #define EIP197_FETCH_DEPTH 2 35 34 #define EIP197_MAX_BATCH_SZ 64 36 35 ··· 233 234 #define EIP97_CFSIZE_OFFSET 8 234 235 #define EIP197_CFSIZE_MASK GENMASK(3, 0) 235 236 #define EIP97_CFSIZE_MASK GENMASK(4, 0) 237 + #define EIP197_RFSIZE_OFFSET 12 238 + #define EIP197_RFSIZE_ADJUST 4 239 + #define EIP97_RFSIZE_OFFSET 12 240 + #define EIP197_RFSIZE_MASK GENMASK(3, 0) 241 + #define EIP97_RFSIZE_MASK GENMASK(4, 0) 236 242 237 243 /* EIP197_HIA_AIC_R_ENABLE_CTRL */ 238 244 #define EIP197_CDR_IRQ(n) BIT((n) * 2) ··· 465 461 466 462 struct result_data_desc result_data; 467 463 } __packed; 464 + 465 + /* 466 + * The EIP(1)97 only needs to fetch the descriptor part of 467 + * the result descriptor, not the result token part! 468 + */ 469 + #define EIP197_RD64_FETCH_SIZE ((sizeof(struct safexcel_result_desc) -\ 470 + sizeof(struct result_data_desc)) /\ 471 + sizeof(u32)) 468 472 469 473 struct safexcel_token { 470 474 u32 packet_length:17; ··· 703 691 int pever; 704 692 int hwdataw; 705 693 int hwcfsize; 694 + int hwrfsize; 706 695 }; 707 696 708 697 struct safexcel_crypto_priv {