diff mbox

[v3] crypto: atmel: fix bogus select

Message ID 12173927.U7ILfy5BBh@wuerfel (mailing list archive)
State Accepted
Delegated to: Herbert Xu
Headers show

Commit Message

Arnd Bergmann Nov. 18, 2015, 3:33 p.m. UTC
From 0d53d42a56e9a3769847fd03c703876f2c063fb4 Mon Sep 17 00:00:00 2001
From: Arnd Bergmann <arnd@arndb.de>
Date: Tue, 27 Jan 2015 22:34:04 +0100
Subject: [PATCH] [SUBMITTED] crypto: atmel: fix bogus select

The Atmel at91 crypto driver unconditionally selects AT_HDMAC,
which results in a Kconfig warning if that driver is not enabled:

warning: (CRYPTO_DEV_ATMEL_AES) selects AT_HDMAC which has unmet direct dependencies (DMADEVICES && ARCH_AT91)

The crypto driver itself does not actually have a dependency
on a particular dma engine, other than this being the one that
is used in at91.

Removing the 'select' gets rid of the warning, but can cause
the driver to be unusable if the HDMAC is not enabled at the
same time. To work around that, this patch clarifies the runtime
dependency to be 'AT_HDMAC || AT_XDMAC', but adds an alternative
for COMPILE_TEST, which lets the driver get build on all systems.

The ARCH_AT91 dependency is implied by AT_XDMAC || AT_HDMAC now
and no longer needs to be listed separately.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
I found this one in my backlog, it still seems relevant and I forgot
to send a new version after the last round of comments.


--
To unsubscribe from this list: send the line "unsubscribe linux-crypto" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Comments

kernel test robot Nov. 18, 2015, 6:17 p.m. UTC | #1
Hi Arnd,

[auto build test WARNING on: cryptodev/master]
[also build test WARNING on: v4.4-rc1 next-20151118]

url:    https://github.com/0day-ci/linux/commits/Arnd-Bergmann/crypto-atmel-fix-bogus-select/20151118-233706
base:   https://git.kernel.org/pub/scm/linux/kernel/git/herbert/cryptodev-2.6.git master
config: tile-allmodconfig (attached as .config)
reproduce:
        wget https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # save the attached .config to linux build tree
        make.cross ARCH=tile 

All warnings (new ones prefixed by >>):

   drivers/crypto/atmel-aes.c: In function 'atmel_aes_sg_copy':
>> drivers/crypto/atmel-aes.c:191:11: warning: comparison of distinct pointer types lacks a cast [enabled by default]
   drivers/crypto/atmel-aes.c: In function 'atmel_aes_crypt_dma_start':
   drivers/crypto/atmel-aes.c:447:11: warning: comparison of distinct pointer types lacks a cast [enabled by default]
   drivers/crypto/atmel-aes.c:448:11: warning: comparison of distinct pointer types lacks a cast [enabled by default]
   drivers/crypto/atmel-aes.c: In function 'atmel_aes_crypt_dma_stop':
>> drivers/crypto/atmel-aes.c:642:5: warning: format '%u' expects argument of type 'unsigned int', but argument 2 has type 'size_t' [-Wformat]
   drivers/crypto/atmel-aes.c: In function 'atmel_aes_buff_init':
>> drivers/crypto/atmel-aes.c:669:3: warning: format '%d' expects argument of type 'int', but argument 3 has type 'size_t' [-Wformat]
   drivers/crypto/atmel-aes.c:677:3: warning: format '%d' expects argument of type 'int', but argument 3 has type 'size_t' [-Wformat]

vim +191 drivers/crypto/atmel-aes.c

bd3c7b5c Nicolas Royer 2012-07-01  175  
bd3c7b5c Nicolas Royer 2012-07-01  176  		sg_list = sg_next(sg_list);
bd3c7b5c Nicolas Royer 2012-07-01  177  		if (!sg_list)
bd3c7b5c Nicolas Royer 2012-07-01  178  			total = 0;
bd3c7b5c Nicolas Royer 2012-07-01  179  	}
bd3c7b5c Nicolas Royer 2012-07-01  180  
bd3c7b5c Nicolas Royer 2012-07-01  181  	return sg_nb;
bd3c7b5c Nicolas Royer 2012-07-01  182  }
bd3c7b5c Nicolas Royer 2012-07-01  183  
cadc4ab8 Nicolas Royer 2013-02-20  184  static int atmel_aes_sg_copy(struct scatterlist **sg, size_t *offset,
cadc4ab8 Nicolas Royer 2013-02-20  185  			void *buf, size_t buflen, size_t total, int out)
cadc4ab8 Nicolas Royer 2013-02-20  186  {
cadc4ab8 Nicolas Royer 2013-02-20  187  	unsigned int count, off = 0;
cadc4ab8 Nicolas Royer 2013-02-20  188  
cadc4ab8 Nicolas Royer 2013-02-20  189  	while (buflen && total) {
cadc4ab8 Nicolas Royer 2013-02-20  190  		count = min((*sg)->length - *offset, total);
cadc4ab8 Nicolas Royer 2013-02-20 @191  		count = min(count, buflen);
cadc4ab8 Nicolas Royer 2013-02-20  192  
cadc4ab8 Nicolas Royer 2013-02-20  193  		if (!count)
cadc4ab8 Nicolas Royer 2013-02-20  194  			return off;
cadc4ab8 Nicolas Royer 2013-02-20  195  
cadc4ab8 Nicolas Royer 2013-02-20  196  		scatterwalk_map_and_copy(buf + off, *sg, *offset, count, out);
cadc4ab8 Nicolas Royer 2013-02-20  197  
cadc4ab8 Nicolas Royer 2013-02-20  198  		off += count;
cadc4ab8 Nicolas Royer 2013-02-20  199  		buflen -= count;

:::::: The code at line 191 was first introduced by commit
:::::: cadc4ab8f6f73719ef0e124320cdd210d1c9ff3e crypto: atmel-aes - add support for latest release of the IP (0x130)

:::::: TO: Nicolas Royer <nicolas@eukrea.com>
:::::: CC: Herbert Xu <herbert@gondor.apana.org.au>

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation
kernel test robot Nov. 18, 2015, 6:56 p.m. UTC | #2
Hi Arnd,

[auto build test WARNING on: cryptodev/master]
[also build test WARNING on: v4.4-rc1 next-20151118]

url:    https://github.com/0day-ci/linux/commits/Arnd-Bergmann/crypto-atmel-fix-bogus-select/20151118-233706
base:   https://git.kernel.org/pub/scm/linux/kernel/git/herbert/cryptodev-2.6.git master
config: x86_64-allmodconfig (attached as .config)
reproduce:
        # save the attached .config to linux build tree
        make ARCH=x86_64 

All warnings (new ones prefixed by >>):

   include/linux/compiler.h:228:8: sparse: attribute 'no_sanitize_address': unknown attribute
   drivers/crypto/atmel-aes.c:191:25: sparse: incompatible types in comparison expression (different type sizes)
   drivers/crypto/atmel-aes.c:447:25: sparse: incompatible types in comparison expression (different type sizes)
   drivers/crypto/atmel-aes.c:448:25: sparse: incompatible types in comparison expression (different type sizes)
   In file included from drivers/crypto/atmel-aes.c:17:0:
   drivers/crypto/atmel-aes.c: In function 'atmel_aes_sg_copy':
   include/linux/kernel.h:724:17: warning: comparison of distinct pointer types lacks a cast
     (void) (&_min1 == &_min2);  \
                    ^
>> drivers/crypto/atmel-aes.c:191:11: note: in expansion of macro 'min'
      count = min(count, buflen);
              ^
   drivers/crypto/atmel-aes.c: In function 'atmel_aes_crypt_dma_start':
   include/linux/kernel.h:724:17: warning: comparison of distinct pointer types lacks a cast
     (void) (&_min1 == &_min2);  \
                    ^
   drivers/crypto/atmel-aes.c:447:11: note: in expansion of macro 'min'
      count = min(dd->total, sg_dma_len(dd->in_sg));
              ^
   include/linux/kernel.h:724:17: warning: comparison of distinct pointer types lacks a cast
     (void) (&_min1 == &_min2);  \
                    ^
   drivers/crypto/atmel-aes.c:448:11: note: in expansion of macro 'min'
      count = min(count, sg_dma_len(dd->out_sg));
              ^
   In file included from include/linux/printk.h:6:0,
                    from include/linux/kernel.h:13,
                    from drivers/crypto/atmel-aes.c:17:
   drivers/crypto/atmel-aes.c: In function 'atmel_aes_crypt_dma_stop':
>> include/linux/kern_levels.h:4:18: warning: format '%u' expects argument of type 'unsigned int', but argument 2 has type 'size_t {aka long unsigned int}' [-Wformat=]
    #define KERN_SOH "\001"  /* ASCII Start Of Header */
                     ^
   include/linux/kern_levels.h:10:18: note: in expansion of macro 'KERN_SOH'
    #define KERN_ERR KERN_SOH "3" /* error conditions */
                     ^
   include/linux/printk.h:252:9: note: in expansion of macro 'KERN_ERR'
     printk(KERN_ERR pr_fmt(fmt), ##__VA_ARGS__)
            ^
>> drivers/crypto/atmel-aes.c:642:5: note: in expansion of macro 'pr_err'
        pr_err("not all data converted: %u\n", count);
        ^
   drivers/crypto/atmel-aes.c: In function 'atmel_aes_buff_init':
>> drivers/crypto/atmel-aes.c:669:20: warning: format '%d' expects argument of type 'int', but argument 3 has type 'size_t {aka long unsigned int}' [-Wformat=]
      dev_err(dd->dev, "dma %d bytes error\n", dd->buflen);
                       ^
   drivers/crypto/atmel-aes.c:677:20: warning: format '%d' expects argument of type 'int', but argument 3 has type 'size_t {aka long unsigned int}' [-Wformat=]
      dev_err(dd->dev, "dma %d bytes error\n", dd->buflen);
                       ^

sparse warnings: (new ones prefixed by >>)

   include/linux/compiler.h:228:8: sparse: attribute 'no_sanitize_address': unknown attribute
>> drivers/crypto/atmel-aes.c:191:25: sparse: incompatible types in comparison expression (different type sizes)
   drivers/crypto/atmel-aes.c:447:25: sparse: incompatible types in comparison expression (different type sizes)
   drivers/crypto/atmel-aes.c:448:25: sparse: incompatible types in comparison expression (different type sizes)
   In file included from drivers/crypto/atmel-aes.c:17:0:
   drivers/crypto/atmel-aes.c: In function 'atmel_aes_sg_copy':
   include/linux/kernel.h:724:17: warning: comparison of distinct pointer types lacks a cast
     (void) (&_min1 == &_min2);  \
                    ^
   drivers/crypto/atmel-aes.c:191:11: note: in expansion of macro 'min'
      count = min(count, buflen);
              ^
   drivers/crypto/atmel-aes.c: In function 'atmel_aes_crypt_dma_start':
   include/linux/kernel.h:724:17: warning: comparison of distinct pointer types lacks a cast
     (void) (&_min1 == &_min2);  \
                    ^
   drivers/crypto/atmel-aes.c:447:11: note: in expansion of macro 'min'
      count = min(dd->total, sg_dma_len(dd->in_sg));
              ^
   include/linux/kernel.h:724:17: warning: comparison of distinct pointer types lacks a cast
     (void) (&_min1 == &_min2);  \
                    ^
   drivers/crypto/atmel-aes.c:448:11: note: in expansion of macro 'min'
      count = min(count, sg_dma_len(dd->out_sg));
              ^
   In file included from include/linux/printk.h:6:0,
                    from include/linux/kernel.h:13,
                    from drivers/crypto/atmel-aes.c:17:
   drivers/crypto/atmel-aes.c: In function 'atmel_aes_crypt_dma_stop':
   include/linux/kern_levels.h:4:18: warning: format '%u' expects argument of type 'unsigned int', but argument 2 has type 'size_t {aka long unsigned int}' [-Wformat=]
    #define KERN_SOH "\001"  /* ASCII Start Of Header */
                     ^
   include/linux/kern_levels.h:10:18: note: in expansion of macro 'KERN_SOH'
    #define KERN_ERR KERN_SOH "3" /* error conditions */
                     ^
   include/linux/printk.h:252:9: note: in expansion of macro 'KERN_ERR'
     printk(KERN_ERR pr_fmt(fmt), ##__VA_ARGS__)
            ^
   drivers/crypto/atmel-aes.c:642:5: note: in expansion of macro 'pr_err'
        pr_err("not all data converted: %u\n", count);
        ^
   drivers/crypto/atmel-aes.c: In function 'atmel_aes_buff_init':
   drivers/crypto/atmel-aes.c:669:20: warning: format '%d' expects argument of type 'int', but argument 3 has type 'size_t {aka long unsigned int}' [-Wformat=]
      dev_err(dd->dev, "dma %d bytes error\n", dd->buflen);
                       ^
   drivers/crypto/atmel-aes.c:677:20: warning: format '%d' expects argument of type 'int', but argument 3 has type 'size_t {aka long unsigned int}' [-Wformat=]
      dev_err(dd->dev, "dma %d bytes error\n", dd->buflen);
                       ^

vim +/min +191 drivers/crypto/atmel-aes.c

bd3c7b5c Nicolas Royer 2012-07-01  175  
bd3c7b5c Nicolas Royer 2012-07-01  176  		sg_list = sg_next(sg_list);
bd3c7b5c Nicolas Royer 2012-07-01  177  		if (!sg_list)
bd3c7b5c Nicolas Royer 2012-07-01  178  			total = 0;
bd3c7b5c Nicolas Royer 2012-07-01  179  	}
bd3c7b5c Nicolas Royer 2012-07-01  180  
bd3c7b5c Nicolas Royer 2012-07-01  181  	return sg_nb;
bd3c7b5c Nicolas Royer 2012-07-01  182  }
bd3c7b5c Nicolas Royer 2012-07-01  183  
cadc4ab8 Nicolas Royer 2013-02-20  184  static int atmel_aes_sg_copy(struct scatterlist **sg, size_t *offset,
cadc4ab8 Nicolas Royer 2013-02-20  185  			void *buf, size_t buflen, size_t total, int out)
cadc4ab8 Nicolas Royer 2013-02-20  186  {
cadc4ab8 Nicolas Royer 2013-02-20  187  	unsigned int count, off = 0;
cadc4ab8 Nicolas Royer 2013-02-20  188  
cadc4ab8 Nicolas Royer 2013-02-20  189  	while (buflen && total) {
cadc4ab8 Nicolas Royer 2013-02-20  190  		count = min((*sg)->length - *offset, total);
cadc4ab8 Nicolas Royer 2013-02-20 @191  		count = min(count, buflen);
cadc4ab8 Nicolas Royer 2013-02-20  192  
cadc4ab8 Nicolas Royer 2013-02-20  193  		if (!count)
cadc4ab8 Nicolas Royer 2013-02-20  194  			return off;
cadc4ab8 Nicolas Royer 2013-02-20  195  
cadc4ab8 Nicolas Royer 2013-02-20  196  		scatterwalk_map_and_copy(buf + off, *sg, *offset, count, out);
cadc4ab8 Nicolas Royer 2013-02-20  197  
cadc4ab8 Nicolas Royer 2013-02-20  198  		off += count;
cadc4ab8 Nicolas Royer 2013-02-20  199  		buflen -= count;

:::::: The code at line 191 was first introduced by commit
:::::: cadc4ab8f6f73719ef0e124320cdd210d1c9ff3e crypto: atmel-aes - add support for latest release of the IP (0x130)

:::::: TO: Nicolas Royer <nicolas@eukrea.com>
:::::: CC: Herbert Xu <herbert@gondor.apana.org.au>

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation
Arnd Bergmann Nov. 18, 2015, 7:54 p.m. UTC | #3
On Thursday 19 November 2015 02:17:21 kbuild test robot wrote:
> 
> [auto build test WARNING on: cryptodev/master]
> [also build test WARNING on: v4.4-rc1 next-20151118]
> 
> url:    https://github.com/0day-ci/linux/commits/Arnd-Bergmann/crypto-atmel-fix-bogus-select/20151118-233706
> base:   https://git.kernel.org/pub/scm/linux/kernel/git/herbert/cryptodev-2.6.git master
> config: tile-allmodconfig (attached as .config)
> reproduce:
>         wget https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross -O ~/bin/make.cross
>         chmod +x ~/bin/make.cross
>         # save the attached .config to linux build tree
>         make.cross ARCH=tile 
> 
> All warnings (new ones prefixed by >>):
> 
>    drivers/crypto/atmel-aes.c: In function 'atmel_aes_sg_copy':
> >> drivers/crypto/atmel-aes.c:191:11: warning: comparison of distinct pointer types lacks a cast [enabled by default]
>    drivers/crypto/atmel-aes.c: In function 'atmel_aes_crypt_dma_start':
>    drivers/crypto/atmel-aes.c:447:11: warning: comparison of distinct pointer types lacks a cast [enabled by default]
>    drivers/crypto/atmel-aes.c:448:11: warning: comparison of distinct pointer types lacks a cast [enabled by default]
>    drivers/crypto/atmel-aes.c: In function 'atmel_aes_crypt_dma_stop':
> >> drivers/crypto/atmel-aes.c:642:5: warning: format '%u' expects argument of type 'unsigned int', but argument 2 has type 'size_t' [-Wformat]
>    drivers/crypto/atmel-aes.c: In function 'atmel_aes_buff_init':
> >> drivers/crypto/atmel-aes.c:669:3: warning: format '%d' expects argument of type 'int', but argument 3 has type 'size_t' [-Wformat]
>    drivers/crypto/atmel-aes.c:677:3: warning: format '%d' expects argument of type 'int', but argument 3 has type 'size_t' [-Wformat]
> 
> 

Thanks for the report. I actually submitted a patch for these yesterday, but
I should have realized now that there is a dependency between the two patches,
and the other one needs to be applied first to avoid generating these
warnings in allmodconfig builds for all architectures.

	Arnd
--
To unsubscribe from this list: send the line "unsubscribe linux-crypto" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Herbert Xu Nov. 23, 2015, 1:05 p.m. UTC | #4
On Wed, Nov 18, 2015 at 04:33:54PM +0100, Arnd Bergmann wrote:
> >From 0d53d42a56e9a3769847fd03c703876f2c063fb4 Mon Sep 17 00:00:00 2001
> From: Arnd Bergmann <arnd@arndb.de>
> Date: Tue, 27 Jan 2015 22:34:04 +0100
> Subject: [PATCH] [SUBMITTED] crypto: atmel: fix bogus select
> 
> The Atmel at91 crypto driver unconditionally selects AT_HDMAC,
> which results in a Kconfig warning if that driver is not enabled:
> 
> warning: (CRYPTO_DEV_ATMEL_AES) selects AT_HDMAC which has unmet direct dependencies (DMADEVICES && ARCH_AT91)
> 
> The crypto driver itself does not actually have a dependency
> on a particular dma engine, other than this being the one that
> is used in at91.
> 
> Removing the 'select' gets rid of the warning, but can cause
> the driver to be unusable if the HDMAC is not enabled at the
> same time. To work around that, this patch clarifies the runtime
> dependency to be 'AT_HDMAC || AT_XDMAC', but adds an alternative
> for COMPILE_TEST, which lets the driver get build on all systems.
> 
> The ARCH_AT91 dependency is implied by AT_XDMAC || AT_HDMAC now
> and no longer needs to be listed separately.
> 
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>

Patch applied.  Thanks.
diff mbox

Patch

diff --git a/drivers/crypto/Kconfig b/drivers/crypto/Kconfig
index 2569e043317e..5357bc1f9e4b 100644
--- a/drivers/crypto/Kconfig
+++ b/drivers/crypto/Kconfig
@@ -378,10 +378,9 @@  config CRYPTO_DEV_BFIN_CRC
 
 config CRYPTO_DEV_ATMEL_AES
 	tristate "Support for Atmel AES hw accelerator"
-	depends on ARCH_AT91
+	depends on AT_XDMAC || AT_HDMAC || COMPILE_TEST
 	select CRYPTO_AES
 	select CRYPTO_BLKCIPHER
-	select AT_HDMAC
 	help
 	  Some Atmel processors have AES hw accelerator.
 	  Select this if you want to use the Atmel module for