Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1294068
| From | Cyrille Pitchen <cyrille.pitchen@atmel.com> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | [PATCH 24/24] crypto: atmel-aes: add debug facilities to monitor register accesses. |
| Date | 2015-12-17 18:20 +0100 |
| Message-ID | <qGKnE-2nS-11@gated-at.bofh.it> (permalink) |
| References | <qGJUB-1Y1-7@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
This feature should not be enabled in release but can be usefull for
developers who need to monitor register accesses at some specific places.
Set the AES_FLAGS_DUMP_REG flag inside dd->flags to start monitoring the
I/O accesses, clear it to stop monitoring.
Signed-off-by: Cyrille Pitchen <cyrille.pitchen@atmel.com>
---
drivers/crypto/atmel-aes.c | 115 ++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 114 insertions(+), 1 deletion(-)
diff --git a/drivers/crypto/atmel-aes.c b/drivers/crypto/atmel-aes.c
index 0a37e5683c80..5621612ee921 100644
--- a/drivers/crypto/atmel-aes.c
+++ b/drivers/crypto/atmel-aes.c
@@ -75,6 +75,7 @@
#define AES_FLAGS_INIT BIT(2)
#define AES_FLAGS_BUSY BIT(3)
+#define AES_FLAGS_DUMP_REG BIT(4)
#define AES_FLAGS_PERSISTENT (AES_FLAGS_INIT | AES_FLAGS_BUSY)
@@ -197,16 +198,128 @@ static struct atmel_aes_drv atmel_aes = {
.lock = __SPIN_LOCK_UNLOCKED(atmel_aes.lock),
};
+#ifdef VERBOSE_DEBUG
+static const char *atmel_aes_reg_name(u32 offset, char *tmp, size_t sz)
+{
+ switch (offset) {
+ case AES_CR:
+ return "CR";
+
+ case AES_MR:
+ return "MR";
+
+ case AES_ISR:
+ return "ISR";
+
+ case AES_IMR:
+ return "IMR";
+
+ case AES_IER:
+ return "IER";
+
+ case AES_IDR:
+ return "IDR";
+
+ case AES_KEYWR(0):
+ case AES_KEYWR(1):
+ case AES_KEYWR(2):
+ case AES_KEYWR(3):
+ case AES_KEYWR(4):
+ case AES_KEYWR(5):
+ case AES_KEYWR(6):
+ case AES_KEYWR(7):
+ snprintf(tmp, sz, "KEYWR[%u]", (offset - AES_KEYWR(0)) >> 2);
+ break;
+
+ case AES_IDATAR(0):
+ case AES_IDATAR(1):
+ case AES_IDATAR(2):
+ case AES_IDATAR(3):
+ snprintf(tmp, sz, "IDATAR[%u]", (offset - AES_IDATAR(0)) >> 2);
+ break;
+
+ case AES_ODATAR(0):
+ case AES_ODATAR(1):
+ case AES_ODATAR(2):
+ case AES_ODATAR(3):
+ snprintf(tmp, sz, "ODATAR[%u]", (offset - AES_ODATAR(0)) >> 2);
+ break;
+
+ case AES_IVR(0):
+ case AES_IVR(1):
+ case AES_IVR(2):
+ case AES_IVR(3):
+ snprintf(tmp, sz, "IVR[%u]", (offset - AES_IVR(0)) >> 2);
+ break;
+
+ case AES_AADLENR:
+ return "AADLENR";
+
+ case AES_CLENR:
+ return "CLENR";
+
+ case AES_GHASHR(0):
+ case AES_GHASHR(1):
+ case AES_GHASHR(2):
+ case AES_GHASHR(3):
+ snprintf(tmp, sz, "GHASHR[%u]", (offset - AES_GHASHR(0)) >> 2);
+ break;
+
+ case AES_TAGR(0):
+ case AES_TAGR(1):
+ case AES_TAGR(2):
+ case AES_TAGR(3):
+ snprintf(tmp, sz, "TAGR[%u]", (offset - AES_TAGR(0)) >> 2);
+ break;
+
+ case AES_CTRR:
+ return "CTRR";
+
+ case AES_GCMHR(0):
+ case AES_GCMHR(1):
+ case AES_GCMHR(2):
+ case AES_GCMHR(3):
+ snprintf(tmp, sz, "GCMHR[%u]", (offset - AES_GCMHR(0)) >> 2);
+
+ default:
+ snprintf(tmp, sz, "0x%02x", offset);
+ break;
+ }
+
+ return tmp;
+}
+#endif /* VERBOSE_DEBUG */
+
/* Shared functions */
static inline u32 atmel_aes_read(struct atmel_aes_dev *dd, u32 offset)
{
- return readl_relaxed(dd->io_base + offset);
+ u32 value = readl_relaxed(dd->io_base + offset);
+
+#ifdef VERBOSE_DEBUG
+ if (dd->flags & AES_FLAGS_DUMP_REG) {
+ char tmp[16];
+
+ dev_vdbg(dd->dev, "read 0x%08x from %s\n", value,
+ atmel_aes_reg_name(offset, tmp, sizeof(tmp)));
+ }
+#endif /* VERBOSE_DEBUG */
+
+ return value;
}
static inline void atmel_aes_write(struct atmel_aes_dev *dd,
u32 offset, u32 value)
{
+#ifdef VERBOSE_DEBUG
+ if (dd->flags & AES_FLAGS_DUMP_REG) {
+ char tmp[16];
+
+ dev_vdbg(dd->dev, "write 0x%08x into %s\n", value,
+ atmel_aes_reg_name(offset, tmp));
+ }
+#endif /* VERBOSE_DEBUG */
+
writel_relaxed(value, dd->io_base + offset);
}
--
1.8.2.2
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH 00/24] crypto: atmel-aes: global rework of the driver Cyrille Pitchen <cyrille.pitchen@atmel.com> - 2015-12-17 17:50 +0100 [PATCH 02/24] crypto: atmel-aes: constify value argument of atmel_aes_write_n() Cyrille Pitchen <cyrille.pitchen@atmel.com> - 2015-12-17 17:50 +0100 [PATCH 01/24] crypto: atmel-aes: add new version Cyrille Pitchen <cyrille.pitchen@atmel.com> - 2015-12-17 17:50 +0100 [PATCH 06/24] crypto: atmel-aes: propagate error from atmel_aes_hw_version_init() Cyrille Pitchen <cyrille.pitchen@atmel.com> - 2015-12-17 18:00 +0100 [PATCH 11/24] crypto: atmel-aes: rework crypto request completion Cyrille Pitchen <cyrille.pitchen@atmel.com> - 2015-12-17 18:00 +0100 [PATCH 08/24] crypto: atmel-aes: make crypto request queue management more generic Cyrille Pitchen <cyrille.pitchen@atmel.com> - 2015-12-17 18:00 +0100 [PATCH 14/24] crypto: atmel-aes: remove useless AES_FLAGS_DMA flag Cyrille Pitchen <cyrille.pitchen@atmel.com> - 2015-12-17 18:00 +0100 [PATCH 15/24] crypto: atmel-aes: fix atmel_aes_remove() Cyrille Pitchen <cyrille.pitchen@atmel.com> - 2015-12-17 18:00 +0100 [PATCH 10/24] crypto: atmel-aes: simplify the configuration of the AES IP Cyrille Pitchen <cyrille.pitchen@atmel.com> - 2015-12-17 18:00 +0100 [PATCH 13/24] crypto: atmel-aes: reduce latency of DMA completion Cyrille Pitchen <cyrille.pitchen@atmel.com> - 2015-12-17 18:00 +0100 [PATCH 07/24] crypto: atmel-aes: change atmel_aes_write_ctrl() signature Cyrille Pitchen <cyrille.pitchen@atmel.com> - 2015-12-17 18:00 +0100 [PATCH 12/24] crypto: atmel-aes: remove unused 'err' member of struct atmel_aes_dev Cyrille Pitchen <cyrille.pitchen@atmel.com> - 2015-12-17 18:00 +0100 [PATCH 09/24] crypto: atmel-aes: remove useless write in the Control Register Cyrille Pitchen <cyrille.pitchen@atmel.com> - 2015-12-17 18:00 +0100 [PATCH 18/24] crypto: atmel-aes: fix typo and indentation Cyrille Pitchen <cyrille.pitchen@atmel.com> - 2015-12-17 18:20 +0100 [PATCH 22/24] crypto: atmel-aes: change the DMA threshold Cyrille Pitchen <cyrille.pitchen@atmel.com> - 2015-12-17 18:20 +0100 [PATCH 20/24] crypto: atmel-aes: fix atmel-ctr-aes driver for RFC 3686 Cyrille Pitchen <cyrille.pitchen@atmel.com> - 2015-12-17 18:20 +0100 [PATCH 23/24] crypto: atmel-aes: add support to GCM mode Cyrille Pitchen <cyrille.pitchen@atmel.com> - 2015-12-17 18:20 +0100 [PATCH 16/24] crypto: atmel-aes: improve performances of data transfer Cyrille Pitchen <cyrille.pitchen@atmel.com> - 2015-12-17 18:20 +0100 [PATCH 24/24] crypto: atmel-aes: add debug facilities to monitor register accesses. Cyrille Pitchen <cyrille.pitchen@atmel.com> - 2015-12-17 18:20 +0100 [PATCH 19/24] crypto: atmel-aes: create sections to regroup functions by usage Cyrille Pitchen <cyrille.pitchen@atmel.com> - 2015-12-17 18:20 +0100 [PATCH 21/24] crypto: atmel-aes: fix the counter overflow in CTR mode Cyrille Pitchen <cyrille.pitchen@atmel.com> - 2015-12-17 18:20 +0100 [PATCH 17/24] crypto: atmel-aes: use SIZE_IN_WORDS() helper macro Cyrille Pitchen <cyrille.pitchen@atmel.com> - 2015-12-17 18:20 +0100 Re: [PATCH 00/24] crypto: atmel-aes: global rework of the driver Herbert Xu <herbert@gondor.apana.org.au> - 2015-12-23 11:30 +0100
csiph-web