diff mbox series

[4/4] Enable Driver compilation in crypto Kconfig and Makefile file

Message ID 20231114050525.471854-5-pavitrakumarm@vayavyalabs.com (mailing list archive)
State Changes Requested
Delegated to: Herbert Xu
Headers show
Series Add crypto spacc driver to support cipher, hash and aead | expand

Commit Message

Pavitrakumar Managutte Nov. 14, 2023, 5:05 a.m. UTC
Signed-off-by: shwetar <shwetar@vayavyalabs.com>
Signed-off-by: Pavitrakumar M <pavitrakumarm@vayavyalabs.com>
Acked-by: Ruud Derwig <Ruud.Derwig@synopsys.com>
---
 drivers/crypto/Kconfig  | 1 +
 drivers/crypto/Makefile | 1 +
 2 files changed, 2 insertions(+)

Comments

Yujie Liu Nov. 15, 2023, 1:57 a.m. UTC | #1
Hi Pavitrakumar,

kernel test robot noticed the following build errors:

[auto build test ERROR on herbert-cryptodev-2.6/master]
[also build test ERROR on herbert-crypto-2.6/master linus/master v6.7-rc1]
[cannot apply to xilinx-xlnx/master next-20231114]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Pavitrakumar-M/Add-SPACC-driver-to-Linux-kernel/20231114-143618
base:   https://git.kernel.org/pub/scm/linux/kernel/git/herbert/cryptodev-2.6.git master
patch link:    https://lore.kernel.org/r/20231114050525.471854-5-pavitrakumarm%40vayavyalabs.com
patch subject: [PATCH 4/4] Enable Driver compilation in crypto Kconfig and Makefile file
config: csky-randconfig-001-20231114 (https://download.01.org/0day-ci/archive/20231114/202311141830.g6TK9OTS-lkp@intel.com/config)
compiler: csky-linux-gcc (GCC) 13.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20231114/202311141830.g6TK9OTS-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <yujie.liu@intel.com>
| Closes: https://lore.kernel.org/r/202311141830.g6TK9OTS-lkp@intel.com/

All error/warnings (new ones prefixed by >>):

>> drivers/crypto/dwc-spacc/spacc_skcipher.c:87:5: warning: no previous prototype for 'spacc_skcipher_fallback' [-Wmissing-prototypes]
      87 | int spacc_skcipher_fallback(unsigned char *name, struct skcipher_request *req,
         |     ^~~~~~~~~~~~~~~~~~~~~~~
   drivers/crypto/dwc-spacc/spacc_skcipher.c: In function 'spacc_cipher_cb':
>> drivers/crypto/dwc-spacc/spacc_skcipher.c:131:18: warning: variable 'rc' set but not used [-Wunused-but-set-variable]
     131 |         int err, rc;
         |                  ^~
   drivers/crypto/dwc-spacc/spacc_skcipher.c: At top level:
>> drivers/crypto/dwc-spacc/spacc_skcipher.c:155:5: warning: no previous prototype for 'spacc_cipher_init_dma' [-Wmissing-prototypes]
     155 | int spacc_cipher_init_dma(struct device *dev, struct skcipher_request *req)
         |     ^~~~~~~~~~~~~~~~~~~~~
>> drivers/crypto/dwc-spacc/spacc_skcipher.c:179:5: warning: no previous prototype for 'spacc_cipher_cra_init' [-Wmissing-prototypes]
     179 | int spacc_cipher_cra_init(struct crypto_tfm *tfm)
         |     ^~~~~~~~~~~~~~~~~~~~~
>> drivers/crypto/dwc-spacc/spacc_skcipher.c:210:5: warning: no previous prototype for 'spacc_cipher_setkey' [-Wmissing-prototypes]
     210 | int spacc_cipher_setkey(struct crypto_skcipher *tfm, const u8 *key,
         |     ^~~~~~~~~~~~~~~~~~~
>> drivers/crypto/dwc-spacc/spacc_skcipher.c:283:5: warning: no previous prototype for 'spacc_cipher_process' [-Wmissing-prototypes]
     283 | int spacc_cipher_process(struct skcipher_request *req, int enc_dec)
         |     ^~~~~~~~~~~~~~~~~~~~
   drivers/crypto/dwc-spacc/spacc_skcipher.c: In function 'spacc_cipher_process':
>> drivers/crypto/dwc-spacc/spacc_skcipher.c:293:13: warning: variable 'ivsize' set but not used [-Wunused-but-set-variable]
     293 |         int ivsize;
         |             ^~~~~~
   drivers/crypto/dwc-spacc/spacc_skcipher.c: At top level:
>> drivers/crypto/dwc-spacc/spacc_skcipher.c:473:5: warning: no previous prototype for 'spacc_cipher_encrypt' [-Wmissing-prototypes]
     473 | int spacc_cipher_encrypt(struct skcipher_request *req)
         |     ^~~~~~~~~~~~~~~~~~~~
>> drivers/crypto/dwc-spacc/spacc_skcipher.c:487:5: warning: no previous prototype for 'spacc_cipher_decrypt' [-Wmissing-prototypes]
     487 | int spacc_cipher_decrypt(struct skcipher_request *req)
         |     ^~~~~~~~~~~~~~~~~~~~
   drivers/crypto/dwc-spacc/spacc_skcipher.c: In function 'probe_ciphers':
>> drivers/crypto/dwc-spacc/spacc_skcipher.c:533:59: warning: '%s' directive output may be truncated writing up to 5299 bytes into a region of size 128 [-Wformat-truncation=]
     533 |         snprintf(calg->cra_name, sizeof(calg->cra_name), "%s", mode->name);
         |                                                           ^~
   In function 'spacc_init_calg',
       inlined from 'spacc_register_cipher' at drivers/crypto/dwc-spacc/spacc_skcipher.c:549:2,
       inlined from 'probe_ciphers' at drivers/crypto/dwc-spacc/spacc_skcipher.c:596:11:
   drivers/crypto/dwc-spacc/spacc_skcipher.c:533:9: note: 'snprintf' output between 1 and 5300 bytes into a destination of size 128
     533 |         snprintf(calg->cra_name, sizeof(calg->cra_name), "%s", mode->name);
         |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/crypto/dwc-spacc/spacc_skcipher.c: In function 'probe_ciphers':
   drivers/crypto/dwc-spacc/spacc_skcipher.c:535:25: warning: '%s' directive output may be truncated writing up to 5299 bytes into a region of size 122 [-Wformat-truncation=]
     535 |                  "spacc-%s", mode->name);
         |                         ^~
   In function 'spacc_init_calg',
       inlined from 'spacc_register_cipher' at drivers/crypto/dwc-spacc/spacc_skcipher.c:549:2,
       inlined from 'probe_ciphers' at drivers/crypto/dwc-spacc/spacc_skcipher.c:596:11:
   drivers/crypto/dwc-spacc/spacc_skcipher.c:534:9: note: 'snprintf' output between 7 and 5306 bytes into a destination of size 128
     534 |         snprintf(calg->cra_driver_name, sizeof(calg->cra_driver_name),
         |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     535 |                  "spacc-%s", mode->name);
         |                  ~~~~~~~~~~~~~~~~~~~~~~~
--
>> drivers/crypto/dwc-spacc/spacc_core.c:1113:5: warning: no previous prototype for 'spacc_sgs_to_ddt' [-Wmissing-prototypes]
    1113 | int spacc_sgs_to_ddt(struct device *dev,
         |     ^~~~~~~~~~~~~~~~
>> drivers/crypto/dwc-spacc/spacc_core.c:1179:5: warning: no previous prototype for 'modify_scatterlist' [-Wmissing-prototypes]
    1179 | int modify_scatterlist(struct scatterlist *src, struct scatterlist *dst,
         |     ^~~~~~~~~~~~~~~~~~
>> drivers/crypto/dwc-spacc/spacc_core.c:1215:5: warning: no previous prototype for 'spacc_sg_to_ddt' [-Wmissing-prototypes]
    1215 | int spacc_sg_to_ddt(struct device *dev, struct scatterlist *sg,
         |     ^~~~~~~~~~~~~~~
>> drivers/crypto/dwc-spacc/spacc_core.c:2991:12: warning: 'spacc_load_skp' defined but not used [-Wunused-function]
    2991 | static int spacc_load_skp(struct spacc_device *spacc, uint32_t *key, int keysz,
         |            ^~~~~~~~~~~~~~
>> drivers/crypto/dwc-spacc/spacc_core.c:2849:13: warning: 'spacc_set_secure_mode' defined but not used [-Wunused-function]
    2849 | static void spacc_set_secure_mode(struct spacc_device *spacc, int src, int dst,
         |             ^~~~~~~~~~~~~~~~~~~~~
>> drivers/crypto/dwc-spacc/spacc_core.c:974:26: warning: 'names' defined but not used [-Wunused-const-variable=]
     974 | static const char *const names[] = {
         |                          ^~~~~
   In file included from <command-line>:
   In function 'spacc_sg_chain',
       inlined from 'fixup_sg' at drivers/crypto/dwc-spacc/spacc_core.c:1105:4,
       inlined from 'spacc_sgs_to_ddt' at drivers/crypto/dwc-spacc/spacc_core.c:1132:16:
>> include/linux/compiler_types.h:425:45: error: call to '__compiletime_assert_235' declared with attribute error: BUILD_BUG_ON failed: IS_ENABLED(CONFIG_DEBUG_SG)
     425 |         _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
         |                                             ^
   include/linux/compiler_types.h:406:25: note: in definition of macro '__compiletime_assert'
     406 |                         prefix ## suffix();                             \
         |                         ^~~~~~
   include/linux/compiler_types.h:425:9: note: in expansion of macro '_compiletime_assert'
     425 |         _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
         |         ^~~~~~~~~~~~~~~~~~~
   include/linux/build_bug.h:39:37: note: in expansion of macro 'compiletime_assert'
      39 | #define BUILD_BUG_ON_MSG(cond, msg) compiletime_assert(!(cond), msg)
         |                                     ^~~~~~~~~~~~~~~~~~
   include/linux/build_bug.h:50:9: note: in expansion of macro 'BUILD_BUG_ON_MSG'
      50 |         BUILD_BUG_ON_MSG(condition, "BUILD_BUG_ON failed: " #condition)
         |         ^~~~~~~~~~~~~~~~
   drivers/crypto/dwc-spacc/spacc_core.c:1072:9: note: in expansion of macro 'BUILD_BUG_ON'
    1072 |         BUILD_BUG_ON(IS_ENABLED(CONFIG_DEBUG_SG));
         |         ^~~~~~~~~~~~
   In function 'spacc_sg_chain',
       inlined from 'fixup_sg' at drivers/crypto/dwc-spacc/spacc_core.c:1105:4,
       inlined from 'spacc_sg_to_ddt' at drivers/crypto/dwc-spacc/spacc_core.c:1222:15:
>> include/linux/compiler_types.h:425:45: error: call to '__compiletime_assert_235' declared with attribute error: BUILD_BUG_ON failed: IS_ENABLED(CONFIG_DEBUG_SG)
     425 |         _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
         |                                             ^
   include/linux/compiler_types.h:406:25: note: in definition of macro '__compiletime_assert'
     406 |                         prefix ## suffix();                             \
         |                         ^~~~~~
   include/linux/compiler_types.h:425:9: note: in expansion of macro '_compiletime_assert'
     425 |         _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
         |         ^~~~~~~~~~~~~~~~~~~
   include/linux/build_bug.h:39:37: note: in expansion of macro 'compiletime_assert'
      39 | #define BUILD_BUG_ON_MSG(cond, msg) compiletime_assert(!(cond), msg)
         |                                     ^~~~~~~~~~~~~~~~~~
   include/linux/build_bug.h:50:9: note: in expansion of macro 'BUILD_BUG_ON_MSG'
      50 |         BUILD_BUG_ON_MSG(condition, "BUILD_BUG_ON failed: " #condition)
         |         ^~~~~~~~~~~~~~~~
   drivers/crypto/dwc-spacc/spacc_core.c:1072:9: note: in expansion of macro 'BUILD_BUG_ON'
    1072 |         BUILD_BUG_ON(IS_ENABLED(CONFIG_DEBUG_SG));
         |         ^~~~~~~~~~~~
--
>> drivers/crypto/dwc-spacc/spacc_ahash.c:499:5: warning: no previous prototype for 'do_shash' [-Wmissing-prototypes]
     499 | int do_shash(unsigned char *name, unsigned char *result,
         |     ^~~~~~~~
   drivers/crypto/dwc-spacc/spacc_ahash.c: In function 'spacc_hash_final':
>> drivers/crypto/dwc-spacc/spacc_ahash.c:1007:13: warning: variable 'err' set but not used [-Wunused-but-set-variable]
    1007 |         int err;
         |             ^~~
   drivers/crypto/dwc-spacc/spacc_ahash.c: In function 'probe_hashes':
>> drivers/crypto/dwc-spacc/spacc_ahash.c:177:59: warning: '%s' directive output may be truncated writing up to 8479 bytes into a region of size 128 [-Wformat-truncation=]
     177 |         snprintf(calg->cra_name, sizeof(calg->cra_name), "%s", mode->name);
         |                                                           ^~
   In function 'spacc_init_calg',
       inlined from 'spacc_register_hash' at drivers/crypto/dwc-spacc/spacc_ahash.c:1164:2,
       inlined from 'probe_hashes' at drivers/crypto/dwc-spacc/spacc_ahash.c:1211:9:
   drivers/crypto/dwc-spacc/spacc_ahash.c:177:9: note: 'snprintf' output between 1 and 8480 bytes into a destination of size 128
     177 |         snprintf(calg->cra_name, sizeof(calg->cra_name), "%s", mode->name);
         |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/crypto/dwc-spacc/spacc_ahash.c: In function 'probe_hashes':
   drivers/crypto/dwc-spacc/spacc_ahash.c:179:25: warning: '%s' directive output may be truncated writing up to 8479 bytes into a region of size 122 [-Wformat-truncation=]
     179 |                  "spacc-%s", mode->name);
         |                         ^~
   In function 'spacc_init_calg',
       inlined from 'spacc_register_hash' at drivers/crypto/dwc-spacc/spacc_ahash.c:1164:2,
       inlined from 'probe_hashes' at drivers/crypto/dwc-spacc/spacc_ahash.c:1211:9:
   drivers/crypto/dwc-spacc/spacc_ahash.c:178:9: note: 'snprintf' output between 7 and 8486 bytes into a destination of size 128
     178 |         snprintf(calg->cra_driver_name, sizeof(calg->cra_driver_name),
         |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     179 |                  "spacc-%s", mode->name);
         |                  ~~~~~~~~~~~~~~~~~~~~~~~
--
>> drivers/crypto/dwc-spacc/spacc_interrupt.c:188:6: warning: no previous prototype for 'spacc_disable_int' [-Wmissing-prototypes]
     188 | void spacc_disable_int (struct spacc_device *spacc)
         |      ^~~~~~~~~~~~~~~~~
>> drivers/crypto/dwc-spacc/spacc_interrupt.c:194:13: warning: no previous prototype for 'spacc_irq_handler' [-Wmissing-prototypes]
     194 | irqreturn_t spacc_irq_handler(int irq, void *dev)
         |             ^~~~~~~~~~~~~~~~~
--
   drivers/crypto/dwc-spacc/spacc_hal.c: In function 'pdu_get_version':
>> drivers/crypto/dwc-spacc/spacc_hal.c:19:28: warning: variable 'ver' set but not used [-Wunused-but-set-variable]
      19 |         unsigned long tmp, ver;
         |                            ^~~
   drivers/crypto/dwc-spacc/spacc_hal.c: At top level:
>> drivers/crypto/dwc-spacc/spacc_hal.c:374:5: warning: no previous prototype for 'pdu_sg_to_ddt' [-Wmissing-prototypes]
     374 | int pdu_sg_to_ddt(struct scatterlist *sg, int sg_count, struct pdu_ddt *ddt)
         |     ^~~~~~~~~~~~~
--
   drivers/crypto/dwc-spacc/spacc_aead.c: In function 'spacc_aead_init_dma':
>> drivers/crypto/dwc-spacc/spacc_aead.c:256:31: warning: variable 'buf' set but not used [-Wunused-but-set-variable]
     256 |                         char *buf = sg_virt(req->src);
         |                               ^~~


vim +/__compiletime_assert_235 +425 include/linux/compiler_types.h

eb5c2d4b45e3d2d5 Will Deacon 2020-07-21  411  
eb5c2d4b45e3d2d5 Will Deacon 2020-07-21  412  #define _compiletime_assert(condition, msg, prefix, suffix) \
eb5c2d4b45e3d2d5 Will Deacon 2020-07-21  413  	__compiletime_assert(condition, msg, prefix, suffix)
eb5c2d4b45e3d2d5 Will Deacon 2020-07-21  414  
eb5c2d4b45e3d2d5 Will Deacon 2020-07-21  415  /**
eb5c2d4b45e3d2d5 Will Deacon 2020-07-21  416   * compiletime_assert - break build and emit msg if condition is false
eb5c2d4b45e3d2d5 Will Deacon 2020-07-21  417   * @condition: a compile-time constant condition to check
eb5c2d4b45e3d2d5 Will Deacon 2020-07-21  418   * @msg:       a message to emit if condition is false
eb5c2d4b45e3d2d5 Will Deacon 2020-07-21  419   *
eb5c2d4b45e3d2d5 Will Deacon 2020-07-21  420   * In tradition of POSIX assert, this macro will break the build if the
eb5c2d4b45e3d2d5 Will Deacon 2020-07-21  421   * supplied condition is *false*, emitting the supplied error message if the
eb5c2d4b45e3d2d5 Will Deacon 2020-07-21  422   * compiler has support to do so.
eb5c2d4b45e3d2d5 Will Deacon 2020-07-21  423   */
eb5c2d4b45e3d2d5 Will Deacon 2020-07-21  424  #define compiletime_assert(condition, msg) \
eb5c2d4b45e3d2d5 Will Deacon 2020-07-21 @425  	_compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
eb5c2d4b45e3d2d5 Will Deacon 2020-07-21  426
Yujie Liu Nov. 15, 2023, 1:58 a.m. UTC | #2
Hi Pavitrakumar,

kernel test robot noticed the following build errors:

[auto build test ERROR on herbert-cryptodev-2.6/master]
[also build test ERROR on herbert-crypto-2.6/master linus/master v6.7-rc1]
[cannot apply to xilinx-xlnx/master next-20231114]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Pavitrakumar-M/Add-SPACC-driver-to-Linux-kernel/20231114-143618
base:   https://git.kernel.org/pub/scm/linux/kernel/git/herbert/cryptodev-2.6.git master
patch link:    https://lore.kernel.org/r/20231114050525.471854-5-pavitrakumarm%40vayavyalabs.com
patch subject: [PATCH 4/4] Enable Driver compilation in crypto Kconfig and Makefile file
config: microblaze-defconfig (https://download.01.org/0day-ci/archive/20231114/202311141906.Ai9VGcKQ-lkp@intel.com/config)
compiler: microblaze-linux-gcc (GCC) 13.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20231114/202311141906.Ai9VGcKQ-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <yujie.liu@intel.com>
| Closes: https://lore.kernel.org/r/202311141906.Ai9VGcKQ-lkp@intel.com/

All errors (new ones prefixed by >>):

   microblaze-linux-ld: drivers/crypto/dwc-spacc/spacc_ahash.o: in function `zero_message_process':
>> drivers/crypto/dwc-spacc/spacc_ahash.c:427:(.text+0x284): undefined reference to `sm3_zero_message_hash'


vim +427 drivers/crypto/dwc-spacc/spacc_ahash.c

188d801c0d4bbe Pavitrakumar M 2023-11-14  417  
188d801c0d4bbe Pavitrakumar M 2023-11-14  418  static int zero_message_process(struct ahash_request *req)
188d801c0d4bbe Pavitrakumar M 2023-11-14  419  {
188d801c0d4bbe Pavitrakumar M 2023-11-14  420  	struct crypto_ahash *tfm = crypto_ahash_reqtfm(req);
188d801c0d4bbe Pavitrakumar M 2023-11-14  421  	int digest_sz = crypto_ahash_digestsize(tfm);
188d801c0d4bbe Pavitrakumar M 2023-11-14  422  	const struct spacc_alg *salg = spacc_tfm_ahash(&tfm->base);
188d801c0d4bbe Pavitrakumar M 2023-11-14  423  
188d801c0d4bbe Pavitrakumar M 2023-11-14  424  	switch (salg->mode->id) {
188d801c0d4bbe Pavitrakumar M 2023-11-14  425  	case CRYPTO_MODE_HASH_SM3:
188d801c0d4bbe Pavitrakumar M 2023-11-14  426  	case CRYPTO_MODE_HMAC_SM3:
188d801c0d4bbe Pavitrakumar M 2023-11-14 @427  		memcpy(req->result, sm3_zero_message_hash, digest_sz);
188d801c0d4bbe Pavitrakumar M 2023-11-14  428  		break;
188d801c0d4bbe Pavitrakumar M 2023-11-14  429  
188d801c0d4bbe Pavitrakumar M 2023-11-14  430  	case CRYPTO_MODE_HMAC_SHA224:
188d801c0d4bbe Pavitrakumar M 2023-11-14  431  	case CRYPTO_MODE_HASH_SHA224:
188d801c0d4bbe Pavitrakumar M 2023-11-14  432  		memcpy(req->result, sha224_zero_message_hash, digest_sz);
188d801c0d4bbe Pavitrakumar M 2023-11-14  433  		break;
188d801c0d4bbe Pavitrakumar M 2023-11-14  434  
188d801c0d4bbe Pavitrakumar M 2023-11-14  435  	case CRYPTO_MODE_HMAC_SHA256:
188d801c0d4bbe Pavitrakumar M 2023-11-14  436  	case CRYPTO_MODE_HASH_SHA256:
188d801c0d4bbe Pavitrakumar M 2023-11-14  437  		memcpy(req->result, sha256_zero_message_hash, digest_sz);
188d801c0d4bbe Pavitrakumar M 2023-11-14  438  		break;
188d801c0d4bbe Pavitrakumar M 2023-11-14  439  
188d801c0d4bbe Pavitrakumar M 2023-11-14  440  	case CRYPTO_MODE_HMAC_SHA384:
188d801c0d4bbe Pavitrakumar M 2023-11-14  441  	case CRYPTO_MODE_HASH_SHA384:
188d801c0d4bbe Pavitrakumar M 2023-11-14  442  		memcpy(req->result, sha384_zero_message_hash, digest_sz);
188d801c0d4bbe Pavitrakumar M 2023-11-14  443  		break;
188d801c0d4bbe Pavitrakumar M 2023-11-14  444  
188d801c0d4bbe Pavitrakumar M 2023-11-14  445  	case CRYPTO_MODE_HMAC_SHA512:
188d801c0d4bbe Pavitrakumar M 2023-11-14  446  	case CRYPTO_MODE_HASH_SHA512:
188d801c0d4bbe Pavitrakumar M 2023-11-14  447  		memcpy(req->result, sha512_zero_message_hash, digest_sz);
188d801c0d4bbe Pavitrakumar M 2023-11-14  448  		break;
188d801c0d4bbe Pavitrakumar M 2023-11-14  449  
188d801c0d4bbe Pavitrakumar M 2023-11-14  450  	case CRYPTO_MODE_HMAC_MD5:
188d801c0d4bbe Pavitrakumar M 2023-11-14  451  	case CRYPTO_MODE_HASH_MD5:
188d801c0d4bbe Pavitrakumar M 2023-11-14  452  		memcpy(req->result, md5_zero_message_hash, digest_sz);
188d801c0d4bbe Pavitrakumar M 2023-11-14  453  		break;
188d801c0d4bbe Pavitrakumar M 2023-11-14  454  
188d801c0d4bbe Pavitrakumar M 2023-11-14  455  	case CRYPTO_MODE_HMAC_SHA1:
188d801c0d4bbe Pavitrakumar M 2023-11-14  456  	case CRYPTO_MODE_HASH_SHA1:
188d801c0d4bbe Pavitrakumar M 2023-11-14  457  		memcpy(req->result, sha1_zero_message_hash, digest_sz);
188d801c0d4bbe Pavitrakumar M 2023-11-14  458  		break;
188d801c0d4bbe Pavitrakumar M 2023-11-14  459  
188d801c0d4bbe Pavitrakumar M 2023-11-14  460  	case CRYPTO_MODE_MAC_XCBC:
188d801c0d4bbe Pavitrakumar M 2023-11-14  461  		memcpy(req->result, xcbc_aes_zero_message_hash, digest_sz);
188d801c0d4bbe Pavitrakumar M 2023-11-14  462  		break;
188d801c0d4bbe Pavitrakumar M 2023-11-14  463  
188d801c0d4bbe Pavitrakumar M 2023-11-14  464  	case CRYPTO_MODE_MAC_CMAC:
188d801c0d4bbe Pavitrakumar M 2023-11-14  465  		memcpy(req->result, cmac_aes_zero_message_hash, digest_sz);
188d801c0d4bbe Pavitrakumar M 2023-11-14  466  		break;
188d801c0d4bbe Pavitrakumar M 2023-11-14  467  
188d801c0d4bbe Pavitrakumar M 2023-11-14  468  	case CRYPTO_MODE_HASH_SHA3_224:
188d801c0d4bbe Pavitrakumar M 2023-11-14  469  		memcpy(req->result, sha3_224_zero_message_hash, digest_sz);
188d801c0d4bbe Pavitrakumar M 2023-11-14  470  		break;
188d801c0d4bbe Pavitrakumar M 2023-11-14  471  
188d801c0d4bbe Pavitrakumar M 2023-11-14  472  	case CRYPTO_MODE_HASH_SHA3_256:
188d801c0d4bbe Pavitrakumar M 2023-11-14  473  		memcpy(req->result, sha3_256_zero_message_hash, digest_sz);
188d801c0d4bbe Pavitrakumar M 2023-11-14  474  		break;
188d801c0d4bbe Pavitrakumar M 2023-11-14  475  
188d801c0d4bbe Pavitrakumar M 2023-11-14  476  	case CRYPTO_MODE_HASH_SHA3_384:
188d801c0d4bbe Pavitrakumar M 2023-11-14  477  		memcpy(req->result, sha3_384_zero_message_hash, digest_sz);
188d801c0d4bbe Pavitrakumar M 2023-11-14  478  		break;
188d801c0d4bbe Pavitrakumar M 2023-11-14  479  
188d801c0d4bbe Pavitrakumar M 2023-11-14  480  	case CRYPTO_MODE_HASH_SHA3_512:
188d801c0d4bbe Pavitrakumar M 2023-11-14  481  		memcpy(req->result, sha3_512_zero_message_hash, digest_sz);
188d801c0d4bbe Pavitrakumar M 2023-11-14  482  		break;
188d801c0d4bbe Pavitrakumar M 2023-11-14  483  
188d801c0d4bbe Pavitrakumar M 2023-11-14  484  	case CRYPTO_MODE_MAC_MICHAEL:
188d801c0d4bbe Pavitrakumar M 2023-11-14  485  		memcpy(req->result, michael_mic_zero_message_hash, digest_sz);
188d801c0d4bbe Pavitrakumar M 2023-11-14  486  		break;
188d801c0d4bbe Pavitrakumar M 2023-11-14  487  
188d801c0d4bbe Pavitrakumar M 2023-11-14  488  	case CRYPTO_MODE_MAC_SM4_XCBC:
188d801c0d4bbe Pavitrakumar M 2023-11-14  489  		memcpy(req->result, sm4_xcbc128_zero_message_hash, digest_sz);
188d801c0d4bbe Pavitrakumar M 2023-11-14  490  		break;
188d801c0d4bbe Pavitrakumar M 2023-11-14  491  
188d801c0d4bbe Pavitrakumar M 2023-11-14  492  	default:
188d801c0d4bbe Pavitrakumar M 2023-11-14  493  		return -EINVAL;
188d801c0d4bbe Pavitrakumar M 2023-11-14  494  	}
188d801c0d4bbe Pavitrakumar M 2023-11-14  495  
188d801c0d4bbe Pavitrakumar M 2023-11-14  496  	return 0;
188d801c0d4bbe Pavitrakumar M 2023-11-14  497  }
188d801c0d4bbe Pavitrakumar M 2023-11-14  498
Yujie Liu Nov. 15, 2023, 2 a.m. UTC | #3
Hi Pavitrakumar,

kernel test robot noticed the following build warnings:

[auto build test WARNING on herbert-cryptodev-2.6/master]
[also build test WARNING on herbert-crypto-2.6/master linus/master v6.7-rc1]
[cannot apply to xilinx-xlnx/master next-20231114]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Pavitrakumar-M/Add-SPACC-driver-to-Linux-kernel/20231114-143618
base:   https://git.kernel.org/pub/scm/linux/kernel/git/herbert/cryptodev-2.6.git master
patch link:    https://lore.kernel.org/r/20231114050525.471854-5-pavitrakumarm%40vayavyalabs.com
patch subject: [PATCH 4/4] Enable Driver compilation in crypto Kconfig and Makefile file
config: mips-allyesconfig (https://download.01.org/0day-ci/archive/20231114/202311142123.lwAnyUEZ-lkp@intel.com/config)
compiler: mips-linux-gcc (GCC) 13.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20231114/202311142123.lwAnyUEZ-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <yujie.liu@intel.com>
| Closes: https://lore.kernel.org/r/202311142123.lwAnyUEZ-lkp@intel.com/

All warnings (new ones prefixed by >>):

   drivers/crypto/dwc-spacc/spacc_core.c:1113:5: warning: no previous prototype for 'spacc_sgs_to_ddt' [-Wmissing-prototypes]
    1113 | int spacc_sgs_to_ddt(struct device *dev,
         |     ^~~~~~~~~~~~~~~~
   drivers/crypto/dwc-spacc/spacc_core.c:1179:5: warning: no previous prototype for 'modify_scatterlist' [-Wmissing-prototypes]
    1179 | int modify_scatterlist(struct scatterlist *src, struct scatterlist *dst,
         |     ^~~~~~~~~~~~~~~~~~
   drivers/crypto/dwc-spacc/spacc_core.c:1215:5: warning: no previous prototype for 'spacc_sg_to_ddt' [-Wmissing-prototypes]
    1215 | int spacc_sg_to_ddt(struct device *dev, struct scatterlist *sg,
         |     ^~~~~~~~~~~~~~~
   drivers/crypto/dwc-spacc/spacc_core.c: In function 'spacc_fini':
   drivers/crypto/dwc-spacc/spacc_core.c:2565:9: error: implicit declaration of function 'vfree'; did you mean 'kvfree'? [-Werror=implicit-function-declaration]
    2565 |         vfree(spacc->ctx);
         |         ^~~~~
         |         kvfree
   drivers/crypto/dwc-spacc/spacc_core.c: In function 'spacc_init':
   drivers/crypto/dwc-spacc/spacc_core.c:2744:22: error: implicit declaration of function 'vmalloc'; did you mean 'kvmalloc'? [-Werror=implicit-function-declaration]
    2744 |         spacc->ctx = vmalloc(sizeof(struct spacc_ctx) *
         |                      ^~~~~~~
         |                      kvmalloc
>> drivers/crypto/dwc-spacc/spacc_core.c:2744:20: warning: assignment to 'struct spacc_ctx *' from 'int' makes pointer from integer without a cast [-Wint-conversion]
    2744 |         spacc->ctx = vmalloc(sizeof(struct spacc_ctx) *
         |                    ^
>> drivers/crypto/dwc-spacc/spacc_core.c:2750:20: warning: assignment to 'struct spacc_job *' from 'int' makes pointer from integer without a cast [-Wint-conversion]
    2750 |         spacc->job = vmalloc(sizeof(struct spacc_job) * SPACC_MAX_JOBS);
         |                    ^
   drivers/crypto/dwc-spacc/spacc_core.c: At top level:
   drivers/crypto/dwc-spacc/spacc_core.c:2991:12: warning: 'spacc_load_skp' defined but not used [-Wunused-function]
    2991 | static int spacc_load_skp(struct spacc_device *spacc, uint32_t *key, int keysz,
         |            ^~~~~~~~~~~~~~
   drivers/crypto/dwc-spacc/spacc_core.c:2849:13: warning: 'spacc_set_secure_mode' defined but not used [-Wunused-function]
    2849 | static void spacc_set_secure_mode(struct spacc_device *spacc, int src, int dst,
         |             ^~~~~~~~~~~~~~~~~~~~~
   drivers/crypto/dwc-spacc/spacc_core.c:974:26: warning: 'names' defined but not used [-Wunused-const-variable=]
     974 | static const char *const names[] = {
         |                          ^~~~~
   In file included from <command-line>:
   In function 'spacc_sg_chain',
       inlined from 'fixup_sg' at drivers/crypto/dwc-spacc/spacc_core.c:1105:4,
       inlined from 'spacc_sgs_to_ddt' at drivers/crypto/dwc-spacc/spacc_core.c:1132:16:
   include/linux/compiler_types.h:425:45: error: call to '__compiletime_assert_354' declared with attribute error: BUILD_BUG_ON failed: IS_ENABLED(CONFIG_DEBUG_SG)
     425 |         _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
         |                                             ^
   include/linux/compiler_types.h:406:25: note: in definition of macro '__compiletime_assert'
     406 |                         prefix ## suffix();                             \
         |                         ^~~~~~
   include/linux/compiler_types.h:425:9: note: in expansion of macro '_compiletime_assert'
     425 |         _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
         |         ^~~~~~~~~~~~~~~~~~~
   include/linux/build_bug.h:39:37: note: in expansion of macro 'compiletime_assert'
      39 | #define BUILD_BUG_ON_MSG(cond, msg) compiletime_assert(!(cond), msg)
         |                                     ^~~~~~~~~~~~~~~~~~
   include/linux/build_bug.h:50:9: note: in expansion of macro 'BUILD_BUG_ON_MSG'
      50 |         BUILD_BUG_ON_MSG(condition, "BUILD_BUG_ON failed: " #condition)
         |         ^~~~~~~~~~~~~~~~
   drivers/crypto/dwc-spacc/spacc_core.c:1072:9: note: in expansion of macro 'BUILD_BUG_ON'
    1072 |         BUILD_BUG_ON(IS_ENABLED(CONFIG_DEBUG_SG));
         |         ^~~~~~~~~~~~
   In function 'spacc_sg_chain',
       inlined from 'fixup_sg' at drivers/crypto/dwc-spacc/spacc_core.c:1105:4,
       inlined from 'spacc_sg_to_ddt' at drivers/crypto/dwc-spacc/spacc_core.c:1222:15:
   include/linux/compiler_types.h:425:45: error: call to '__compiletime_assert_354' declared with attribute error: BUILD_BUG_ON failed: IS_ENABLED(CONFIG_DEBUG_SG)
     425 |         _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
         |                                             ^
   include/linux/compiler_types.h:406:25: note: in definition of macro '__compiletime_assert'
     406 |                         prefix ## suffix();                             \
         |                         ^~~~~~
   include/linux/compiler_types.h:425:9: note: in expansion of macro '_compiletime_assert'
     425 |         _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
         |         ^~~~~~~~~~~~~~~~~~~
   include/linux/build_bug.h:39:37: note: in expansion of macro 'compiletime_assert'
      39 | #define BUILD_BUG_ON_MSG(cond, msg) compiletime_assert(!(cond), msg)
         |                                     ^~~~~~~~~~~~~~~~~~
   include/linux/build_bug.h:50:9: note: in expansion of macro 'BUILD_BUG_ON_MSG'
      50 |         BUILD_BUG_ON_MSG(condition, "BUILD_BUG_ON failed: " #condition)
         |         ^~~~~~~~~~~~~~~~
   drivers/crypto/dwc-spacc/spacc_core.c:1072:9: note: in expansion of macro 'BUILD_BUG_ON'
    1072 |         BUILD_BUG_ON(IS_ENABLED(CONFIG_DEBUG_SG));
         |         ^~~~~~~~~~~~
   cc1: some warnings being treated as errors


vim +2744 drivers/crypto/dwc-spacc/spacc_core.c

188d801c0d4bbe Pavitrakumar M 2023-11-14  2568  
188d801c0d4bbe Pavitrakumar M 2023-11-14  2569  int spacc_init(void *baseaddr, struct spacc_device *spacc,
188d801c0d4bbe Pavitrakumar M 2023-11-14  2570  	       struct pdu_info *info)
188d801c0d4bbe Pavitrakumar M 2023-11-14  2571  {
188d801c0d4bbe Pavitrakumar M 2023-11-14  2572  	unsigned long id;
188d801c0d4bbe Pavitrakumar M 2023-11-14  2573  	char version_string[3][16] = { "SPACC", "SPACC-PDU" };
188d801c0d4bbe Pavitrakumar M 2023-11-14  2574  	char idx_string[2][16] = { "(Normal Port)", "(Secure Port)" };
188d801c0d4bbe Pavitrakumar M 2023-11-14  2575  	char dma_type_string[4][16] = {"Unknown", "Scattergather", "Linear",
188d801c0d4bbe Pavitrakumar M 2023-11-14  2576  		"Unknown"};
188d801c0d4bbe Pavitrakumar M 2023-11-14  2577  
188d801c0d4bbe Pavitrakumar M 2023-11-14  2578  	if (!baseaddr) {
188d801c0d4bbe Pavitrakumar M 2023-11-14  2579  		pr_err("ERR: baseaddr is NULL\n");
188d801c0d4bbe Pavitrakumar M 2023-11-14  2580  		return -1;
188d801c0d4bbe Pavitrakumar M 2023-11-14  2581  	}
188d801c0d4bbe Pavitrakumar M 2023-11-14  2582  	if (!spacc) {
188d801c0d4bbe Pavitrakumar M 2023-11-14  2583  		pr_err("ERR: spacc is NULL\n");
188d801c0d4bbe Pavitrakumar M 2023-11-14  2584  		return -1;
188d801c0d4bbe Pavitrakumar M 2023-11-14  2585  	}
188d801c0d4bbe Pavitrakumar M 2023-11-14  2586  
188d801c0d4bbe Pavitrakumar M 2023-11-14  2587  	memset(spacc, 0, sizeof(*spacc));
188d801c0d4bbe Pavitrakumar M 2023-11-14  2588  	spin_lock_init(&spacc->lock);
188d801c0d4bbe Pavitrakumar M 2023-11-14  2589  	spin_lock_init(&spacc->ctx_lock);
188d801c0d4bbe Pavitrakumar M 2023-11-14  2590  
188d801c0d4bbe Pavitrakumar M 2023-11-14  2591  	/* assign the baseaddr*/
188d801c0d4bbe Pavitrakumar M 2023-11-14  2592  	spacc->regmap = baseaddr;
188d801c0d4bbe Pavitrakumar M 2023-11-14  2593  
188d801c0d4bbe Pavitrakumar M 2023-11-14  2594  	/* version info*/
188d801c0d4bbe Pavitrakumar M 2023-11-14  2595  	spacc->config.version     = info->spacc_version.version;
188d801c0d4bbe Pavitrakumar M 2023-11-14  2596  	spacc->config.pdu_version = (info->pdu_config.major << 4) |
188d801c0d4bbe Pavitrakumar M 2023-11-14  2597  		info->pdu_config.minor;
188d801c0d4bbe Pavitrakumar M 2023-11-14  2598  	spacc->config.project     = info->spacc_version.project;
188d801c0d4bbe Pavitrakumar M 2023-11-14  2599  	spacc->config.is_pdu      = info->spacc_version.is_pdu;
188d801c0d4bbe Pavitrakumar M 2023-11-14  2600  	spacc->config.is_qos      = info->spacc_version.qos;
188d801c0d4bbe Pavitrakumar M 2023-11-14  2601  
188d801c0d4bbe Pavitrakumar M 2023-11-14  2602  	/* misc*/
188d801c0d4bbe Pavitrakumar M 2023-11-14  2603  	spacc->config.is_partial        = info->spacc_version.partial;
188d801c0d4bbe Pavitrakumar M 2023-11-14  2604  	spacc->config.num_ctx           = info->spacc_config.num_ctx;
188d801c0d4bbe Pavitrakumar M 2023-11-14  2605  	spacc->config.ciph_page_size    = 1U <<
188d801c0d4bbe Pavitrakumar M 2023-11-14  2606  		info->spacc_config.ciph_ctx_page_size;
188d801c0d4bbe Pavitrakumar M 2023-11-14  2607  	spacc->config.hash_page_size    = 1U <<
188d801c0d4bbe Pavitrakumar M 2023-11-14  2608  		info->spacc_config.hash_ctx_page_size;
188d801c0d4bbe Pavitrakumar M 2023-11-14  2609  	spacc->config.dma_type          = info->spacc_config.dma_type;
188d801c0d4bbe Pavitrakumar M 2023-11-14  2610  	spacc->config.idx               = info->spacc_version.vspacc_idx;
188d801c0d4bbe Pavitrakumar M 2023-11-14  2611  	spacc->config.cmd0_fifo_depth   = info->spacc_config.cmd0_fifo_depth;
188d801c0d4bbe Pavitrakumar M 2023-11-14  2612  	spacc->config.cmd1_fifo_depth   = info->spacc_config.cmd1_fifo_depth;
188d801c0d4bbe Pavitrakumar M 2023-11-14  2613  	spacc->config.cmd2_fifo_depth   = info->spacc_config.cmd2_fifo_depth;
188d801c0d4bbe Pavitrakumar M 2023-11-14  2614  	spacc->config.stat_fifo_depth   = info->spacc_config.stat_fifo_depth;
188d801c0d4bbe Pavitrakumar M 2023-11-14  2615  	spacc->config.fifo_cnt          = 1;
188d801c0d4bbe Pavitrakumar M 2023-11-14  2616  
188d801c0d4bbe Pavitrakumar M 2023-11-14  2617  	spacc->config.is_ivimport = info->spacc_version.ivimport;
188d801c0d4bbe Pavitrakumar M 2023-11-14  2618  
188d801c0d4bbe Pavitrakumar M 2023-11-14  2619  	/* ctrl register map*/
188d801c0d4bbe Pavitrakumar M 2023-11-14  2620  	if (spacc->config.version <= 0x4E)
188d801c0d4bbe Pavitrakumar M 2023-11-14  2621  		spacc->config.ctrl_map = spacc_ctrl_map[SPACC_CTRL_VER_0];
188d801c0d4bbe Pavitrakumar M 2023-11-14  2622  	else if (spacc->config.version <= 0x60)
188d801c0d4bbe Pavitrakumar M 2023-11-14  2623  		spacc->config.ctrl_map = spacc_ctrl_map[SPACC_CTRL_VER_1];
188d801c0d4bbe Pavitrakumar M 2023-11-14  2624  	else
188d801c0d4bbe Pavitrakumar M 2023-11-14  2625  		spacc->config.ctrl_map = spacc_ctrl_map[SPACC_CTRL_VER_2];
188d801c0d4bbe Pavitrakumar M 2023-11-14  2626  
188d801c0d4bbe Pavitrakumar M 2023-11-14  2627  	spacc->job_next_swid            = 0;
188d801c0d4bbe Pavitrakumar M 2023-11-14  2628  	spacc->wdcnt                    = 0;
188d801c0d4bbe Pavitrakumar M 2023-11-14  2629  	spacc->config.wd_timer          = SPACC_WD_TIMER_INIT;
188d801c0d4bbe Pavitrakumar M 2023-11-14  2630  
188d801c0d4bbe Pavitrakumar M 2023-11-14  2631  	/* version 4.10 uses IRQ,
188d801c0d4bbe Pavitrakumar M 2023-11-14  2632  	 * above uses WD and we don't support below 4.00
188d801c0d4bbe Pavitrakumar M 2023-11-14  2633  	 */
188d801c0d4bbe Pavitrakumar M 2023-11-14  2634  	if (spacc->config.version < 0x40) {
188d801c0d4bbe Pavitrakumar M 2023-11-14  2635  		pr_err("ERR: Unsupported SPAcc version\n");
188d801c0d4bbe Pavitrakumar M 2023-11-14  2636  		return -EIO;
188d801c0d4bbe Pavitrakumar M 2023-11-14  2637  	} else if (spacc->config.version < 0x4B) {
188d801c0d4bbe Pavitrakumar M 2023-11-14  2638  		spacc->op_mode                  = SPACC_OP_MODE_IRQ;
188d801c0d4bbe Pavitrakumar M 2023-11-14  2639  	} else {
188d801c0d4bbe Pavitrakumar M 2023-11-14  2640  		spacc->op_mode                  = SPACC_OP_MODE_WD;
188d801c0d4bbe Pavitrakumar M 2023-11-14  2641  	}
188d801c0d4bbe Pavitrakumar M 2023-11-14  2642  
188d801c0d4bbe Pavitrakumar M 2023-11-14  2643  	/* set threshold and enable irq
188d801c0d4bbe Pavitrakumar M 2023-11-14  2644  	 * on 4.11 and newer cores we can derive this
188d801c0d4bbe Pavitrakumar M 2023-11-14  2645  	 * from the HW reported depths.
188d801c0d4bbe Pavitrakumar M 2023-11-14  2646  	 */
188d801c0d4bbe Pavitrakumar M 2023-11-14  2647  	if (spacc->config.stat_fifo_depth == 1)
188d801c0d4bbe Pavitrakumar M 2023-11-14  2648  		spacc->config.ideal_stat_level = 1;
188d801c0d4bbe Pavitrakumar M 2023-11-14  2649  	else if (spacc->config.stat_fifo_depth <= 4)
188d801c0d4bbe Pavitrakumar M 2023-11-14  2650  		spacc->config.ideal_stat_level = spacc->config.stat_fifo_depth
188d801c0d4bbe Pavitrakumar M 2023-11-14  2651  			- 1;
188d801c0d4bbe Pavitrakumar M 2023-11-14  2652  	else if (spacc->config.stat_fifo_depth <= 8)
188d801c0d4bbe Pavitrakumar M 2023-11-14  2653  		spacc->config.ideal_stat_level = spacc->config.stat_fifo_depth
188d801c0d4bbe Pavitrakumar M 2023-11-14  2654  			- 2;
188d801c0d4bbe Pavitrakumar M 2023-11-14  2655  	else
188d801c0d4bbe Pavitrakumar M 2023-11-14  2656  		spacc->config.ideal_stat_level = spacc->config.stat_fifo_depth
188d801c0d4bbe Pavitrakumar M 2023-11-14  2657  			- 4;
188d801c0d4bbe Pavitrakumar M 2023-11-14  2658  
188d801c0d4bbe Pavitrakumar M 2023-11-14  2659  	/* determine max PROClen value */
188d801c0d4bbe Pavitrakumar M 2023-11-14  2660  	writel(0xFFFFFFFF, spacc->regmap + SPACC_REG_PROC_LEN);
188d801c0d4bbe Pavitrakumar M 2023-11-14  2661  	spacc->config.max_msg_size = readl(spacc->regmap + SPACC_REG_PROC_LEN);
188d801c0d4bbe Pavitrakumar M 2023-11-14  2662  
188d801c0d4bbe Pavitrakumar M 2023-11-14  2663  	/* read config info*/
188d801c0d4bbe Pavitrakumar M 2023-11-14  2664  	if (spacc->config.is_pdu) {
188d801c0d4bbe Pavitrakumar M 2023-11-14  2665  		pr_debug("PDU:\n");
188d801c0d4bbe Pavitrakumar M 2023-11-14  2666  		pr_debug("   MAJOR      : %u\n", info->pdu_config.major);
188d801c0d4bbe Pavitrakumar M 2023-11-14  2667  		pr_debug("   MINOR      : %u\n", info->pdu_config.minor);
188d801c0d4bbe Pavitrakumar M 2023-11-14  2668  	}
188d801c0d4bbe Pavitrakumar M 2023-11-14  2669  	id = readl(spacc->regmap + SPACC_REG_ID);
188d801c0d4bbe Pavitrakumar M 2023-11-14  2670  	pr_debug("SPACC ID: (%08lx)\n", (unsigned long)id);
188d801c0d4bbe Pavitrakumar M 2023-11-14  2671  	pr_debug("   MAJOR      : %x\n", info->spacc_version.major);
188d801c0d4bbe Pavitrakumar M 2023-11-14  2672  	pr_debug("   MINOR      : %x\n", info->spacc_version.minor);
188d801c0d4bbe Pavitrakumar M 2023-11-14  2673  	pr_debug("   QOS        : %x\n", info->spacc_version.qos);
188d801c0d4bbe Pavitrakumar M 2023-11-14  2674  	pr_debug("   IVIMPORT   : %x\n", spacc->config.is_ivimport);
188d801c0d4bbe Pavitrakumar M 2023-11-14  2675  
188d801c0d4bbe Pavitrakumar M 2023-11-14  2676  	if (spacc->config.version >= 0x48)
188d801c0d4bbe Pavitrakumar M 2023-11-14  2677  		pr_debug("   TYPE       : %lx (%s)\n", SPACC_ID_TYPE(id),
188d801c0d4bbe Pavitrakumar M 2023-11-14  2678  			version_string[SPACC_ID_TYPE(id) & 3]);
188d801c0d4bbe Pavitrakumar M 2023-11-14  2679  
188d801c0d4bbe Pavitrakumar M 2023-11-14  2680  	pr_debug("   AUX        : %x\n", info->spacc_version.qos);
188d801c0d4bbe Pavitrakumar M 2023-11-14  2681  	pr_debug("   IDX        : %lx %s\n", SPACC_ID_VIDX(id),
188d801c0d4bbe Pavitrakumar M 2023-11-14  2682  		spacc->config.is_secure ?
188d801c0d4bbe Pavitrakumar M 2023-11-14  2683  		(idx_string[spacc->config.is_secure_port & 1]) : "");
188d801c0d4bbe Pavitrakumar M 2023-11-14  2684  	pr_debug("   PARTIAL    : %x\n", info->spacc_version.partial);
188d801c0d4bbe Pavitrakumar M 2023-11-14  2685  	pr_debug("   PROJECT    : %x\n", info->spacc_version.project);
188d801c0d4bbe Pavitrakumar M 2023-11-14  2686  	if (spacc->config.version >= 0x48)
188d801c0d4bbe Pavitrakumar M 2023-11-14  2687  		id = readl(spacc->regmap + SPACC_REG_CONFIG);
188d801c0d4bbe Pavitrakumar M 2023-11-14  2688  	else
188d801c0d4bbe Pavitrakumar M 2023-11-14  2689  		id = 0xFFFFFFFF;
188d801c0d4bbe Pavitrakumar M 2023-11-14  2690  
188d801c0d4bbe Pavitrakumar M 2023-11-14  2691  	pr_debug("SPACC CFG: (%08lx)\n", id);
188d801c0d4bbe Pavitrakumar M 2023-11-14  2692  	pr_debug("   CTX CNT    : %u\n", info->spacc_config.num_ctx);
188d801c0d4bbe Pavitrakumar M 2023-11-14  2693  	pr_debug("   VSPACC CNT : %u\n", info->spacc_config.num_vspacc);
188d801c0d4bbe Pavitrakumar M 2023-11-14  2694  	pr_debug("   CIPH SZ    : %-3lu bytes\n", 1UL <<
188d801c0d4bbe Pavitrakumar M 2023-11-14  2695  			info->spacc_config.ciph_ctx_page_size);
188d801c0d4bbe Pavitrakumar M 2023-11-14  2696  	pr_debug("   HASH SZ    : %-3lu bytes\n", 1UL <<
188d801c0d4bbe Pavitrakumar M 2023-11-14  2697  			info->spacc_config.hash_ctx_page_size);
188d801c0d4bbe Pavitrakumar M 2023-11-14  2698  	pr_debug("   DMA TYPE   : %u (%s)\n", info->spacc_config.dma_type,
188d801c0d4bbe Pavitrakumar M 2023-11-14  2699  		dma_type_string[info->spacc_config.dma_type & 3]);
188d801c0d4bbe Pavitrakumar M 2023-11-14  2700  	pr_debug("   MAX PROCLEN: %lu bytes\n", (unsigned
188d801c0d4bbe Pavitrakumar M 2023-11-14  2701  				long)spacc->config.max_msg_size);
188d801c0d4bbe Pavitrakumar M 2023-11-14  2702  	pr_debug("   FIFO CONFIG :\n");
188d801c0d4bbe Pavitrakumar M 2023-11-14  2703  	pr_debug("      CMD0 DEPTH: %d\n", spacc->config.cmd0_fifo_depth);
188d801c0d4bbe Pavitrakumar M 2023-11-14  2704  	if (spacc->config.is_qos) {
188d801c0d4bbe Pavitrakumar M 2023-11-14  2705  		pr_debug("      CMD1 DEPTH: %d\n",
188d801c0d4bbe Pavitrakumar M 2023-11-14  2706  			spacc->config.cmd1_fifo_depth);
188d801c0d4bbe Pavitrakumar M 2023-11-14  2707  		pr_debug("      CMD2 DEPTH: %d\n",
188d801c0d4bbe Pavitrakumar M 2023-11-14  2708  			spacc->config.cmd2_fifo_depth);
188d801c0d4bbe Pavitrakumar M 2023-11-14  2709  	}
188d801c0d4bbe Pavitrakumar M 2023-11-14  2710  	pr_debug("      STAT DEPTH: %d\n", spacc->config.stat_fifo_depth);
188d801c0d4bbe Pavitrakumar M 2023-11-14  2711  
188d801c0d4bbe Pavitrakumar M 2023-11-14  2712  	if (spacc->config.dma_type == SPACC_DMA_DDT) {
188d801c0d4bbe Pavitrakumar M 2023-11-14  2713  		writel(0x1234567F, baseaddr + SPACC_REG_DST_PTR);
188d801c0d4bbe Pavitrakumar M 2023-11-14  2714  		writel(0xDEADBEEF, baseaddr + SPACC_REG_SRC_PTR);
188d801c0d4bbe Pavitrakumar M 2023-11-14  2715  		if (((readl(baseaddr + SPACC_REG_DST_PTR)) !=
188d801c0d4bbe Pavitrakumar M 2023-11-14  2716  					(0x1234567F & SPACC_DST_PTR_PTR)) ||
188d801c0d4bbe Pavitrakumar M 2023-11-14  2717  		    ((readl(baseaddr + SPACC_REG_SRC_PTR)) !=
188d801c0d4bbe Pavitrakumar M 2023-11-14  2718  		     (0xDEADBEEF & SPACC_SRC_PTR_PTR))) {
188d801c0d4bbe Pavitrakumar M 2023-11-14  2719  			pr_err("ERR: Failed to set pointers\n");
188d801c0d4bbe Pavitrakumar M 2023-11-14  2720  			goto ERR;
188d801c0d4bbe Pavitrakumar M 2023-11-14  2721  		}
188d801c0d4bbe Pavitrakumar M 2023-11-14  2722  	}
188d801c0d4bbe Pavitrakumar M 2023-11-14  2723  
188d801c0d4bbe Pavitrakumar M 2023-11-14  2724  	/* zero the IRQ CTRL/EN register
188d801c0d4bbe Pavitrakumar M 2023-11-14  2725  	 * (to make sure we're in a sane state)
188d801c0d4bbe Pavitrakumar M 2023-11-14  2726  	 */
188d801c0d4bbe Pavitrakumar M 2023-11-14  2727  	writel(0, spacc->regmap + SPACC_REG_IRQ_CTRL);
188d801c0d4bbe Pavitrakumar M 2023-11-14  2728  	writel(0, spacc->regmap + SPACC_REG_IRQ_EN);
188d801c0d4bbe Pavitrakumar M 2023-11-14  2729  	writel(0xFFFFFFFF, spacc->regmap + SPACC_REG_IRQ_STAT);
188d801c0d4bbe Pavitrakumar M 2023-11-14  2730  
188d801c0d4bbe Pavitrakumar M 2023-11-14  2731  	/* init cache*/
188d801c0d4bbe Pavitrakumar M 2023-11-14  2732  	memset(&spacc->cache, 0, sizeof(spacc->cache));
188d801c0d4bbe Pavitrakumar M 2023-11-14  2733  	writel(0, spacc->regmap + SPACC_REG_SRC_PTR);
188d801c0d4bbe Pavitrakumar M 2023-11-14  2734  	writel(0, spacc->regmap + SPACC_REG_DST_PTR);
188d801c0d4bbe Pavitrakumar M 2023-11-14  2735  	writel(0, spacc->regmap + SPACC_REG_PROC_LEN);
188d801c0d4bbe Pavitrakumar M 2023-11-14  2736  	writel(0, spacc->regmap + SPACC_REG_ICV_LEN);
188d801c0d4bbe Pavitrakumar M 2023-11-14  2737  	writel(0, spacc->regmap + SPACC_REG_ICV_OFFSET);
188d801c0d4bbe Pavitrakumar M 2023-11-14  2738  	writel(0, spacc->regmap + SPACC_REG_PRE_AAD_LEN);
188d801c0d4bbe Pavitrakumar M 2023-11-14  2739  	writel(0, spacc->regmap + SPACC_REG_POST_AAD_LEN);
188d801c0d4bbe Pavitrakumar M 2023-11-14  2740  	writel(0, spacc->regmap + SPACC_REG_IV_OFFSET);
188d801c0d4bbe Pavitrakumar M 2023-11-14  2741  	writel(0, spacc->regmap + SPACC_REG_OFFSET);
188d801c0d4bbe Pavitrakumar M 2023-11-14  2742  	writel(0, spacc->regmap + SPACC_REG_AUX_INFO);
188d801c0d4bbe Pavitrakumar M 2023-11-14  2743  
188d801c0d4bbe Pavitrakumar M 2023-11-14 @2744  	spacc->ctx = vmalloc(sizeof(struct spacc_ctx) *
188d801c0d4bbe Pavitrakumar M 2023-11-14  2745  			spacc->config.num_ctx);
188d801c0d4bbe Pavitrakumar M 2023-11-14  2746  	if (!spacc->ctx) {
188d801c0d4bbe Pavitrakumar M 2023-11-14  2747  		pr_err("ERR: Out of memory for ctx\n");
188d801c0d4bbe Pavitrakumar M 2023-11-14  2748  		goto ERR;
188d801c0d4bbe Pavitrakumar M 2023-11-14  2749  	}
188d801c0d4bbe Pavitrakumar M 2023-11-14 @2750  	spacc->job = vmalloc(sizeof(struct spacc_job) * SPACC_MAX_JOBS);
188d801c0d4bbe Pavitrakumar M 2023-11-14  2751  	if (!spacc->job) {
188d801c0d4bbe Pavitrakumar M 2023-11-14  2752  		pr_err("ERR: Out of memory for job\n");
188d801c0d4bbe Pavitrakumar M 2023-11-14  2753  		goto ERR;
188d801c0d4bbe Pavitrakumar M 2023-11-14  2754  	}
188d801c0d4bbe Pavitrakumar M 2023-11-14  2755  
188d801c0d4bbe Pavitrakumar M 2023-11-14  2756  	/* initialize job_idx and lookup table */
188d801c0d4bbe Pavitrakumar M 2023-11-14  2757  	spacc_job_init_all(spacc);
188d801c0d4bbe Pavitrakumar M 2023-11-14  2758  
188d801c0d4bbe Pavitrakumar M 2023-11-14  2759  	/* initialize contexts */
188d801c0d4bbe Pavitrakumar M 2023-11-14  2760  	spacc_ctx_init_all(spacc);
188d801c0d4bbe Pavitrakumar M 2023-11-14  2761  
188d801c0d4bbe Pavitrakumar M 2023-11-14  2762  	/* autodetect and set string size setting*/
188d801c0d4bbe Pavitrakumar M 2023-11-14  2763  	if (spacc->config.version == 0x61 || spacc->config.version >= 0x65)
188d801c0d4bbe Pavitrakumar M 2023-11-14  2764  		spacc_xof_stringsize_autodetect(spacc);
188d801c0d4bbe Pavitrakumar M 2023-11-14  2765  
188d801c0d4bbe Pavitrakumar M 2023-11-14  2766  	return CRYPTO_OK;
188d801c0d4bbe Pavitrakumar M 2023-11-14  2767  ERR:
188d801c0d4bbe Pavitrakumar M 2023-11-14  2768  	spacc_fini(spacc);
188d801c0d4bbe Pavitrakumar M 2023-11-14  2769  	pr_err("ERR: Crypto Failed\n");
188d801c0d4bbe Pavitrakumar M 2023-11-14  2770  	return -EIO;
188d801c0d4bbe Pavitrakumar M 2023-11-14  2771  }
188d801c0d4bbe Pavitrakumar M 2023-11-14  2772
diff mbox series

Patch

diff --git a/drivers/crypto/Kconfig b/drivers/crypto/Kconfig
index 79c3bb9c99c3..c80b63438b55 100644
--- a/drivers/crypto/Kconfig
+++ b/drivers/crypto/Kconfig
@@ -703,6 +703,7 @@  config CRYPTO_DEV_BCM_SPU
 	  ahash, and aead algorithms with the kernel cryptographic API.
 
 source "drivers/crypto/stm32/Kconfig"
+source "drivers/crypto/dwc-spacc/Kconfig"
 
 config CRYPTO_DEV_SAFEXCEL
 	tristate "Inside Secure's SafeXcel cryptographic engine driver"
diff --git a/drivers/crypto/Makefile b/drivers/crypto/Makefile
index d859d6a5f3a4..25558a26c4e3 100644
--- a/drivers/crypto/Makefile
+++ b/drivers/crypto/Makefile
@@ -47,6 +47,7 @@  obj-$(CONFIG_CRYPTO_DEV_BCM_SPU) += bcm/
 obj-$(CONFIG_CRYPTO_DEV_SAFEXCEL) += inside-secure/
 obj-$(CONFIG_CRYPTO_DEV_ARTPEC6) += axis/
 obj-y += xilinx/
+obj-y += dwc-spacc/
 obj-y += hisilicon/
 obj-$(CONFIG_CRYPTO_DEV_AMLOGIC_GXL) += amlogic/
 obj-y += intel/