- More cleanups and dead code removal.
- Handle TODO item of moving none standard sysfs interface
to debugfs
- One fix to FIPS event irq handling code
Gilad Ben-Yossef (10):
staging: ccree: drop ifdef CONFIG_OF in code
staging: ccree: clean up PM registration
staging: ccree: add explicit module init/exit func
staging: ccree: staging: ccree: replace sysfs by debugfs interface
staging: ccree: remove CC_IRQ_DELAY dead code
staging: ccree: remove useless debug code
staging: ccree: turn compile time debug log to params
staging: ccree: remove ssi_config.h
staging: ccree: fix fips event irq handling build
staging: ccree: update TODO
drivers/staging/ccree/Makefile | 3 +-
drivers/staging/ccree/TODO | 3 +-
drivers/staging/ccree/cc_debugfs.c | 113 +++++++++++++++++++
drivers/staging/ccree/cc_debugfs.h | 45 ++++++++
drivers/staging/ccree/ssi_aead.c | 47 --------
drivers/staging/ccree/ssi_buffer_mgr.h | 1 -
drivers/staging/ccree/ssi_cipher.c | 2 -
drivers/staging/ccree/ssi_config.h | 38 -------
drivers/staging/ccree/ssi_driver.c | 103 +++++++----------
drivers/staging/ccree/ssi_driver.h | 22 ++--
drivers/staging/ccree/ssi_fips.c | 1 -
drivers/staging/ccree/ssi_hash.c | 2 -
drivers/staging/ccree/ssi_ivgen.c | 1 -
drivers/staging/ccree/ssi_pm.c | 6 +-
drivers/staging/ccree/ssi_pm.h | 4 +-
drivers/staging/ccree/ssi_request_mgr.c | 51 +++------
drivers/staging/ccree/ssi_sysfs.c | 192 --------------------------------
drivers/staging/ccree/ssi_sysfs.h | 32 ------
18 files changed, 236 insertions(+), 430 deletions(-)
create mode 100644 drivers/staging/ccree/cc_debugfs.c
create mode 100644 drivers/staging/ccree/cc_debugfs.h
delete mode 100644 drivers/staging/ccree/ssi_config.h
delete mode 100644 drivers/staging/ccree/ssi_sysfs.c
delete mode 100644 drivers/staging/ccree/ssi_sysfs.h
--
2.7.4
As we already depend on CONFIG_OF via Kconfig no need to
support conditional build without it.
Signed-off-by: Gilad Ben-Yossef <[email protected]>
---
drivers/staging/ccree/ssi_driver.c | 4 ----
1 file changed, 4 deletions(-)
diff --git a/drivers/staging/ccree/ssi_driver.c b/drivers/staging/ccree/ssi_driver.c
index 28cfbb4..fbf0338 100644
--- a/drivers/staging/ccree/ssi_driver.c
+++ b/drivers/staging/ccree/ssi_driver.c
@@ -512,20 +512,16 @@ static const struct dev_pm_ops arm_cc7x_driver_pm = {
#define CC_DRIVER_RUNTIME_PM NULL
#endif
-#ifdef CONFIG_OF
static const struct of_device_id arm_cc7x_dev_of_match[] = {
{.compatible = "arm,cryptocell-712-ree"},
{}
};
MODULE_DEVICE_TABLE(of, arm_cc7x_dev_of_match);
-#endif
static struct platform_driver cc7x_driver = {
.driver = {
.name = "cc7xree",
-#ifdef CONFIG_OF
.of_match_table = arm_cc7x_dev_of_match,
-#endif
.pm = CC_DRIVER_RUNTIME_PM,
},
.probe = cc7x_probe,
--
2.7.4
Clean up power management registration.
Signed-off-by: Gilad Ben-Yossef <[email protected]>
---
drivers/staging/ccree/ssi_driver.c | 16 +++-------------
drivers/staging/ccree/ssi_pm.c | 4 ++++
drivers/staging/ccree/ssi_pm.h | 3 +++
3 files changed, 10 insertions(+), 13 deletions(-)
diff --git a/drivers/staging/ccree/ssi_driver.c b/drivers/staging/ccree/ssi_driver.c
index fbf0338..ad02d92 100644
--- a/drivers/staging/ccree/ssi_driver.c
+++ b/drivers/staging/ccree/ssi_driver.c
@@ -500,18 +500,6 @@ static int cc7x_remove(struct platform_device *plat_dev)
return 0;
}
-#if defined(CONFIG_PM)
-static const struct dev_pm_ops arm_cc7x_driver_pm = {
- SET_RUNTIME_PM_OPS(cc_pm_suspend, cc_pm_resume, NULL)
-};
-#endif
-
-#if defined(CONFIG_PM)
-#define CC_DRIVER_RUNTIME_PM (&arm_cc7x_driver_pm)
-#else
-#define CC_DRIVER_RUNTIME_PM NULL
-#endif
-
static const struct of_device_id arm_cc7x_dev_of_match[] = {
{.compatible = "arm,cryptocell-712-ree"},
{}
@@ -522,7 +510,9 @@ static struct platform_driver cc7x_driver = {
.driver = {
.name = "cc7xree",
.of_match_table = arm_cc7x_dev_of_match,
- .pm = CC_DRIVER_RUNTIME_PM,
+#ifdef CONFIG_PM
+ .pm = &ccree_pm,
+#endif
},
.probe = cc7x_probe,
.remove = cc7x_remove,
diff --git a/drivers/staging/ccree/ssi_pm.c b/drivers/staging/ccree/ssi_pm.c
index 3c4892b..0db935d 100644
--- a/drivers/staging/ccree/ssi_pm.c
+++ b/drivers/staging/ccree/ssi_pm.c
@@ -34,6 +34,10 @@
#define POWER_DOWN_ENABLE 0x01
#define POWER_DOWN_DISABLE 0x00
+const struct dev_pm_ops ccree_pm = {
+ SET_RUNTIME_PM_OPS(cc_pm_suspend, cc_pm_resume, NULL)
+};
+
int cc_pm_suspend(struct device *dev)
{
struct cc_drvdata *drvdata = dev_get_drvdata(dev);
diff --git a/drivers/staging/ccree/ssi_pm.h b/drivers/staging/ccree/ssi_pm.h
index a5f2b1b..91140a3 100644
--- a/drivers/staging/ccree/ssi_pm.h
+++ b/drivers/staging/ccree/ssi_pm.h
@@ -30,6 +30,9 @@ int cc_pm_init(struct cc_drvdata *drvdata);
void cc_pm_fini(struct cc_drvdata *drvdata);
#if defined(CONFIG_PM)
+
+extern const struct dev_pm_ops ccree_pm;
+
int cc_pm_suspend(struct device *dev);
int cc_pm_resume(struct device *dev);
--
2.7.4
We need to do a module global scope init/exit operation to support
the debugfs interface we are about to introduce in the next patch,
so wean the module of the boiler plate saving macro as it will no
longer be sufficient.
Signed-off-by: Gilad Ben-Yossef <[email protected]>
---
drivers/staging/ccree/ssi_driver.c | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)
diff --git a/drivers/staging/ccree/ssi_driver.c b/drivers/staging/ccree/ssi_driver.c
index ad02d92..5427c7f 100644
--- a/drivers/staging/ccree/ssi_driver.c
+++ b/drivers/staging/ccree/ssi_driver.c
@@ -517,7 +517,18 @@ static struct platform_driver cc7x_driver = {
.probe = cc7x_probe,
.remove = cc7x_remove,
};
-module_platform_driver(cc7x_driver);
+
+static int __init ccree_init(void)
+{
+ return platform_driver_register(&cc7x_driver);
+}
+module_init(ccree_init);
+
+static void __exit ccree_exit(void)
+{
+ platform_driver_unregister(&cc7x_driver);
+}
+module_exit(ccree_exit);
/* Module description */
MODULE_DESCRIPTION("ARM TrustZone CryptoCell REE Driver");
--
2.7.4
Remove dead code from older version which is not supported in current
hardware.
Signed-off-by: Gilad Ben-Yossef <[email protected]>
---
drivers/staging/ccree/ssi_config.h | 1 -
drivers/staging/ccree/ssi_driver.c | 11 -----------
2 files changed, 12 deletions(-)
diff --git a/drivers/staging/ccree/ssi_config.h b/drivers/staging/ccree/ssi_config.h
index 15725cc..e809103 100644
--- a/drivers/staging/ccree/ssi_config.h
+++ b/drivers/staging/ccree/ssi_config.h
@@ -28,7 +28,6 @@
//#define CC_DUMP_DESCS
// #define CC_DUMP_BYTES
// #define CC_DEBUG
-//#define CC_IRQ_DELAY 100000
/* was 32 bit, but for juno's sake it was enlarged to 48 bit */
#define DMA_BIT_MASK_LEN 48
diff --git a/drivers/staging/ccree/ssi_driver.c b/drivers/staging/ccree/ssi_driver.c
index 14705dc..6158794 100644
--- a/drivers/staging/ccree/ssi_driver.c
+++ b/drivers/staging/ccree/ssi_driver.c
@@ -171,17 +171,6 @@ int init_cc_regs(struct cc_drvdata *drvdata, bool is_probe)
CC_GPR0_IRQ_MASK));
cc_iowrite(drvdata, CC_REG(HOST_IMR), val);
-#ifdef CC_HOST_IRQ_TIMER_INIT_VAL_REG_OFFSET
-#ifdef CC_IRQ_DELAY
- /* Set CC IRQ delay */
- cc_iowrite(drvdata, CC_REG(HOST_IRQ_TIMER_INIT_VAL), CC_IRQ_DELAY);
-#endif
- if (cc_ioread(drvdata, CC_REG(HOST_IRQ_TIMER_INIT_VAL)) > 0) {
- dev_dbg(dev, "irq_delay=%d CC cycles\n",
- cc_ioread(drvdata, CC_REG(HOST_IRQ_TIMER_INIT_VAL)));
- }
-#endif
-
cache_params = (drvdata->coherent ? CC_COHERENT_CACHE_PARAMS : 0x0);
val = cc_ioread(drvdata, CC_REG(AXIM_CACHE_PARAMS));
--
2.7.4
Remove a bunch of useless debug code ifdef'ed out
Signed-off-by: Gilad Ben-Yossef <[email protected]>
---
drivers/staging/ccree/ssi_aead.c | 45 ---------------------------------
drivers/staging/ccree/ssi_config.h | 3 ---
drivers/staging/ccree/ssi_driver.c | 13 ----------
drivers/staging/ccree/ssi_request_mgr.c | 23 -----------------
4 files changed, 84 deletions(-)
diff --git a/drivers/staging/ccree/ssi_aead.c b/drivers/staging/ccree/ssi_aead.c
index dde6797..ce26e68 100644
--- a/drivers/staging/ccree/ssi_aead.c
+++ b/drivers/staging/ccree/ssi_aead.c
@@ -1834,51 +1834,6 @@ static int cc_gcm(struct aead_request *req, struct cc_hw_desc desc[],
return 0;
}
-#ifdef CC_DEBUG
-static void cc_dump_gcm(const char *title, struct aead_request *req)
-{
- struct crypto_aead *tfm = crypto_aead_reqtfm(req);
- struct cc_aead_ctx *ctx = crypto_aead_ctx(tfm);
- struct aead_req_ctx *req_ctx = aead_request_ctx(req);
-
- if (ctx->cipher_mode != DRV_CIPHER_GCTR)
- return;
-
- if (title) {
- dev_dbg(dev, "----------------------------------------------------------------------------------");
- dev_dbg(dev, "%s\n", title);
- }
-
- dev_dbg(dev, "cipher_mode %d, authsize %d, enc_keylen %d, assoclen %d, cryptlen %d\n",
- ctx->cipher_mode, ctx->authsize, ctx->enc_keylen,
- req->assoclen, req_ctx->cryptlen);
-
- if (ctx->enckey)
- dump_byte_array("mac key", ctx->enckey, 16);
-
- dump_byte_array("req->iv", req->iv, AES_BLOCK_SIZE);
-
- dump_byte_array("gcm_iv_inc1", req_ctx->gcm_iv_inc1, AES_BLOCK_SIZE);
-
- dump_byte_array("gcm_iv_inc2", req_ctx->gcm_iv_inc2, AES_BLOCK_SIZE);
-
- dump_byte_array("hkey", req_ctx->hkey, AES_BLOCK_SIZE);
-
- dump_byte_array("mac_buf", req_ctx->mac_buf, AES_BLOCK_SIZE);
-
- dump_byte_array("gcm_len_block", req_ctx->gcm_len_block.len_a,
- AES_BLOCK_SIZE);
-
- if (req->src && req->cryptlen)
- dump_byte_array("req->src", sg_virt(req->src),
- req->cryptlen + req->assoclen);
-
- if (req->dst)
- dump_byte_array("req->dst", sg_virt(req->dst),
- req->cryptlen + ctx->authsize + req->assoclen);
-}
-#endif
-
static int config_gcm_context(struct aead_request *req)
{
struct crypto_aead *tfm = crypto_aead_reqtfm(req);
diff --git a/drivers/staging/ccree/ssi_config.h b/drivers/staging/ccree/ssi_config.h
index e809103..b530974 100644
--- a/drivers/staging/ccree/ssi_config.h
+++ b/drivers/staging/ccree/ssi_config.h
@@ -23,11 +23,8 @@
#include <linux/version.h>
-//#define FLUSH_CACHE_ALL
-//#define COMPLETION_DELAY
//#define CC_DUMP_DESCS
// #define CC_DUMP_BYTES
-// #define CC_DEBUG
/* was 32 bit, but for juno's sake it was enlarged to 48 bit */
#define DMA_BIT_MASK_LEN 48
diff --git a/drivers/staging/ccree/ssi_driver.c b/drivers/staging/ccree/ssi_driver.c
index 6158794..dbca241 100644
--- a/drivers/staging/ccree/ssi_driver.c
+++ b/drivers/staging/ccree/ssi_driver.c
@@ -446,19 +446,6 @@ static int cc7x_probe(struct platform_device *plat_dev)
{
int rc;
struct device *dev = &plat_dev->dev;
-#if defined(CONFIG_ARM) && defined(CC_DEBUG)
- u32 ctr, cacheline_size;
-
- asm volatile("mrc p15, 0, %0, c0, c0, 1" : "=r" (ctr));
- cacheline_size = 4 << ((ctr >> 16) & 0xf);
- dev_dbg(dev, "CP15(L1_CACHE_BYTES) = %u , Kconfig(L1_CACHE_BYTES) = %u\n",
- cacheline_size, L1_CACHE_BYTES);
-
- asm volatile("mrc p15, 0, %0, c0, c0, 0" : "=r" (ctr));
- dev_dbg(dev, "Main ID register (MIDR): Implementer 0x%02X, Arch 0x%01X, Part 0x%03X, Rev r%dp%d\n",
- (ctr >> 24), (ctr >> 16) & 0xF, (ctr >> 4) & 0xFFF,
- (ctr >> 20) & 0xF, ctr & 0xF);
-#endif
/* Map registers space */
rc = init_cc_resources(plat_dev);
diff --git a/drivers/staging/ccree/ssi_request_mgr.c b/drivers/staging/ccree/ssi_request_mgr.c
index 07b9404..f6374b0 100644
--- a/drivers/staging/ccree/ssi_request_mgr.c
+++ b/drivers/staging/ccree/ssi_request_mgr.c
@@ -20,9 +20,6 @@
#include <linux/interrupt.h>
#include <linux/delay.h>
#include <crypto/ctr.h>
-#ifdef FLUSH_CACHE_ALL
-#include <asm/cacheflush.h>
-#endif
#include <linux/pm_runtime.h>
#include "ssi_driver.h"
#include "ssi_buffer_mgr.h"
@@ -359,9 +356,6 @@ int send_request(struct cc_drvdata *drvdata, struct cc_crypto_req *cc_req,
dev_dbg(dev, "Enqueue request head=%u\n", req_mgr_h->req_queue_head);
-#ifdef FLUSH_CACHE_ALL
- flush_cache_all();
-#endif
/*
* We are about to push command to the HW via the command registers
* that may refernece hsot memory. We need to issue a memory barrier
@@ -493,23 +487,6 @@ static void proc_completions(struct cc_drvdata *drvdata)
cc_req = &request_mgr_handle->req_queue[*tail];
-#ifdef FLUSH_CACHE_ALL
- flush_cache_all();
-#endif
-
-#ifdef COMPLETION_DELAY
- /* Delay */
- {
- u32 axi_err;
- int i;
-
- dev_info(dev, "Delay\n");
- for (i = 0; i < 1000000; i++)
- axi_err = cc_ioread(drvdata,
- CC_REG(AXIM_MON_ERR));
- }
-#endif /* COMPLETION_DELAY */
-
if (cc_req->user_cb)
cc_req->user_cb(dev, cc_req->user_arg);
*tail = (*tail + 1) & (MAX_REQUEST_QUEUE_SIZE - 1);
--
2.7.4
The ccree driver has some support to dump runtime data
to kernel log to assist in debugging. The code used to be
enabled by a build time flag. Refactor to enable it via
module/kernel parameters.
Signed-off-by: Gilad Ben-Yossef <[email protected]>
---
drivers/staging/ccree/ssi_config.h | 2 --
drivers/staging/ccree/ssi_driver.c | 18 ++++++++++++------
drivers/staging/ccree/ssi_driver.h | 16 ++++++++++------
drivers/staging/ccree/ssi_request_mgr.c | 26 +++++++++++++-------------
4 files changed, 35 insertions(+), 27 deletions(-)
diff --git a/drivers/staging/ccree/ssi_config.h b/drivers/staging/ccree/ssi_config.h
index b530974..bc90ad0 100644
--- a/drivers/staging/ccree/ssi_config.h
+++ b/drivers/staging/ccree/ssi_config.h
@@ -23,8 +23,6 @@
#include <linux/version.h>
-//#define CC_DUMP_DESCS
-// #define CC_DUMP_BYTES
/* was 32 bit, but for juno's sake it was enlarged to 48 bit */
#define DMA_BIT_MASK_LEN 48
diff --git a/drivers/staging/ccree/ssi_driver.c b/drivers/staging/ccree/ssi_driver.c
index dbca241..195fb27 100644
--- a/drivers/staging/ccree/ssi_driver.c
+++ b/drivers/staging/ccree/ssi_driver.c
@@ -72,20 +72,26 @@
#include "ssi_pm.h"
#include "ssi_fips.h"
-#ifdef CC_DUMP_BYTES
-void dump_byte_array(const char *name, const u8 *buf, size_t len)
+bool cc_dump_desc;
+module_param_named(dump_desc, cc_dump_desc, bool, 0600);
+MODULE_PARM_DESC(cc_dump_desc, "Dump descriptors to kernel log as debugging aid");
+
+bool cc_dump_bytes;
+module_param_named(dump_bytes, cc_dump_bytes, bool, 0600);
+MODULE_PARM_DESC(cc_dump_bytes, "Dump buffers to kernel log as debugging aid");
+
+void __dump_byte_array(const char *name, const u8 *buf, size_t len)
{
- char prefix[NAME_LEN];
+ char prefix[64];
if (!buf)
return;
snprintf(prefix, sizeof(prefix), "%s[%lu]: ", name, len);
- print_hex_dump(KERN_DEBUG, prefix, DUMP_PREFIX_ADDRESS, 16, 1, len,
- false);
+ print_hex_dump(KERN_DEBUG, prefix, DUMP_PREFIX_ADDRESS, 16, 1, buf,
+ len, false);
}
-#endif
static irqreturn_t cc_isr(int irq, void *dev_id)
{
diff --git a/drivers/staging/ccree/ssi_driver.h b/drivers/staging/ccree/ssi_driver.h
index 4e05386..12e2a8b 100644
--- a/drivers/staging/ccree/ssi_driver.h
+++ b/drivers/staging/ccree/ssi_driver.h
@@ -48,6 +48,9 @@
#include "cc_hw_queue_defs.h"
#include "ssi_sram_mgr.h"
+extern bool cc_dump_desc;
+extern bool cc_dump_bytes;
+
#define DRV_MODULE_VERSION "3.0"
#define CC_DEV_NAME_STR "cc715ree"
@@ -169,13 +172,14 @@ static inline struct device *drvdata_to_dev(struct cc_drvdata *drvdata)
return &drvdata->plat_dev->dev;
}
-#ifdef CC_DUMP_BYTES
-void dump_byte_array(const char *name, const u8 *the_array,
- unsigned long size);
-#else
+void __dump_byte_array(const char *name, const u8 *the_array,
+ unsigned long size);
static inline void dump_byte_array(const char *name, const u8 *the_array,
- unsigned long size) {};
-#endif
+ unsigned long size)
+{
+ if (cc_dump_bytes)
+ __dump_byte_array(name, the_array, size);
+}
int init_cc_regs(struct cc_drvdata *drvdata, bool is_probe);
void fini_cc_regs(struct cc_drvdata *drvdata);
diff --git a/drivers/staging/ccree/ssi_request_mgr.c b/drivers/staging/ccree/ssi_request_mgr.c
index f6374b0..2aa21f8 100644
--- a/drivers/staging/ccree/ssi_request_mgr.c
+++ b/drivers/staging/ccree/ssi_request_mgr.c
@@ -161,11 +161,12 @@ int cc_req_mgr_init(struct cc_drvdata *drvdata)
return rc;
}
-static void enqueue_seq(void __iomem *cc_base, struct cc_hw_desc seq[],
+static void enqueue_seq(struct cc_drvdata *drvdata, struct cc_hw_desc seq[],
unsigned int seq_len)
{
int i, w;
- void * __iomem reg = cc_base + CC_REG(DSCRPTR_QUEUE_WORD0);
+ void * __iomem reg = drvdata->cc_base + CC_REG(DSCRPTR_QUEUE_WORD0);
+ struct device *dev = drvdata_to_dev(drvdata);
/*
* We do indeed write all 6 command words to the same
@@ -175,11 +176,12 @@ static void enqueue_seq(void __iomem *cc_base, struct cc_hw_desc seq[],
for (i = 0; i < seq_len; i++) {
for (w = 0; w <= 5; w++)
writel_relaxed(seq[i].word[w], reg);
-#ifdef CC_DUMP_DESCS
- dev_dbg(dev, "desc[%02d]: 0x%08X 0x%08X 0x%08X 0x%08X 0x%08X 0x%08X\n",
- i, seq[i].word[0], seq[i].word[1], seq[i].word[2],
- seq[i].word[3], seq[i].word[4], seq[i].word[5]);
-#endif
+
+ if (cc_dump_desc)
+ dev_dbg(dev, "desc[%02d]: 0x%08X 0x%08X 0x%08X 0x%08X 0x%08X 0x%08X\n",
+ i, seq[i].word[0], seq[i].word[1],
+ seq[i].word[2], seq[i].word[3],
+ seq[i].word[4], seq[i].word[5]);
}
}
@@ -256,7 +258,6 @@ static int cc_queues_status(struct cc_drvdata *drvdata,
int send_request(struct cc_drvdata *drvdata, struct cc_crypto_req *cc_req,
struct cc_hw_desc *desc, unsigned int len, bool is_dout)
{
- void __iomem *cc_base = drvdata->cc_base;
struct cc_req_mgr_handle *req_mgr_h = drvdata->request_mgr_handle;
unsigned int used_sw_slots;
unsigned int iv_seq_len = 0;
@@ -364,9 +365,9 @@ int send_request(struct cc_drvdata *drvdata, struct cc_crypto_req *cc_req,
wmb();
/* STAT_PHASE_4: Push sequence */
- enqueue_seq(cc_base, iv_seq, iv_seq_len);
- enqueue_seq(cc_base, desc, len);
- enqueue_seq(cc_base, &req_mgr_h->compl_desc, (is_dout ? 0 : 1));
+ enqueue_seq(drvdata, iv_seq, iv_seq_len);
+ enqueue_seq(drvdata, desc, len);
+ enqueue_seq(drvdata, &req_mgr_h->compl_desc, (is_dout ? 0 : 1));
if (req_mgr_h->q_free_slots < total_seq_len) {
/* This situation should never occur. Maybe indicating problem
@@ -407,7 +408,6 @@ int send_request(struct cc_drvdata *drvdata, struct cc_crypto_req *cc_req,
int send_request_init(struct cc_drvdata *drvdata, struct cc_hw_desc *desc,
unsigned int len)
{
- void __iomem *cc_base = drvdata->cc_base;
struct cc_req_mgr_handle *req_mgr_h = drvdata->request_mgr_handle;
unsigned int total_seq_len = len; /*initial sequence length*/
int rc = 0;
@@ -426,7 +426,7 @@ int send_request_init(struct cc_drvdata *drvdata, struct cc_hw_desc *desc,
* to make sure there are no outstnading memory writes
*/
wmb();
- enqueue_seq(cc_base, desc, len);
+ enqueue_seq(drvdata, desc, len);
/* Update the free slots in HW queue */
req_mgr_h->q_free_slots =
--
2.7.4
Now that the only thing left in ssi_config is the maximum
DMA mask length we get move that to ssi_driver.h and get
rid of the file.
All of ccree is now runtime configurable or under Kbuild control.
Signed-off-by: Gilad Ben-Yossef <[email protected]>
---
drivers/staging/ccree/cc_debugfs.c | 1 -
drivers/staging/ccree/ssi_aead.c | 1 -
drivers/staging/ccree/ssi_buffer_mgr.h | 1 -
drivers/staging/ccree/ssi_cipher.c | 1 -
drivers/staging/ccree/ssi_config.h | 30 ------------------------------
drivers/staging/ccree/ssi_driver.c | 1 -
drivers/staging/ccree/ssi_driver.h | 4 +++-
drivers/staging/ccree/ssi_fips.c | 1 -
drivers/staging/ccree/ssi_hash.c | 1 -
drivers/staging/ccree/ssi_ivgen.c | 1 -
drivers/staging/ccree/ssi_pm.c | 1 -
drivers/staging/ccree/ssi_pm.h | 1 -
drivers/staging/ccree/ssi_request_mgr.c | 1 -
13 files changed, 3 insertions(+), 42 deletions(-)
delete mode 100644 drivers/staging/ccree/ssi_config.h
diff --git a/drivers/staging/ccree/cc_debugfs.c b/drivers/staging/ccree/cc_debugfs.c
index 7768a7b..7cd33957 100644
--- a/drivers/staging/ccree/cc_debugfs.c
+++ b/drivers/staging/ccree/cc_debugfs.c
@@ -17,7 +17,6 @@
#include <linux/kernel.h>
#include <linux/debugfs.h>
#include <linux/stringify.h>
-#include "ssi_config.h"
#include "ssi_driver.h"
#include "cc_crypto_ctx.h"
diff --git a/drivers/staging/ccree/ssi_aead.c b/drivers/staging/ccree/ssi_aead.c
index ce26e68..1522b00 100644
--- a/drivers/staging/ccree/ssi_aead.c
+++ b/drivers/staging/ccree/ssi_aead.c
@@ -28,7 +28,6 @@
#include <crypto/des.h>
#include <linux/rtnetlink.h>
#include <linux/version.h>
-#include "ssi_config.h"
#include "ssi_driver.h"
#include "ssi_buffer_mgr.h"
#include "ssi_aead.h"
diff --git a/drivers/staging/ccree/ssi_buffer_mgr.h b/drivers/staging/ccree/ssi_buffer_mgr.h
index da43354..395c93f 100644
--- a/drivers/staging/ccree/ssi_buffer_mgr.h
+++ b/drivers/staging/ccree/ssi_buffer_mgr.h
@@ -23,7 +23,6 @@
#include <crypto/algapi.h>
-#include "ssi_config.h"
#include "ssi_driver.h"
enum cc_req_dma_buf_type {
diff --git a/drivers/staging/ccree/ssi_cipher.c b/drivers/staging/ccree/ssi_cipher.c
index f940568..86800a7 100644
--- a/drivers/staging/ccree/ssi_cipher.c
+++ b/drivers/staging/ccree/ssi_cipher.c
@@ -26,7 +26,6 @@
#include <crypto/xts.h>
#include <crypto/scatterwalk.h>
-#include "ssi_config.h"
#include "ssi_driver.h"
#include "cc_lli_defs.h"
#include "ssi_buffer_mgr.h"
diff --git a/drivers/staging/ccree/ssi_config.h b/drivers/staging/ccree/ssi_config.h
deleted file mode 100644
index bc90ad0..0000000
--- a/drivers/staging/ccree/ssi_config.h
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Copyright (C) 2012-2017 ARM Limited or its affiliates.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, see <http://www.gnu.org/licenses/>.
- */
-
-/* \file ssi_config.h
- * Definitions for ARM CryptoCell Linux Crypto Driver
- */
-
-#ifndef __CC_CONFIG_H__
-#define __CC_CONFIG_H__
-
-#include <linux/version.h>
-
-/* was 32 bit, but for juno's sake it was enlarged to 48 bit */
-#define DMA_BIT_MASK_LEN 48
-
-#endif /*__CC_CONFIG_H__*/
-
diff --git a/drivers/staging/ccree/ssi_driver.c b/drivers/staging/ccree/ssi_driver.c
index 195fb27..df6d415 100644
--- a/drivers/staging/ccree/ssi_driver.c
+++ b/drivers/staging/ccree/ssi_driver.c
@@ -59,7 +59,6 @@
#include <linux/clk.h>
#include <linux/of_address.h>
-#include "ssi_config.h"
#include "ssi_driver.h"
#include "ssi_request_mgr.h"
#include "ssi_buffer_mgr.h"
diff --git a/drivers/staging/ccree/ssi_driver.h b/drivers/staging/ccree/ssi_driver.h
index 12e2a8b..5a56f7a 100644
--- a/drivers/staging/ccree/ssi_driver.h
+++ b/drivers/staging/ccree/ssi_driver.h
@@ -21,7 +21,6 @@
#ifndef __CC_DRIVER_H__
#define __CC_DRIVER_H__
-#include "ssi_config.h"
#ifdef COMP_IN_WQ
#include <linux/workqueue.h>
#else
@@ -56,6 +55,9 @@ extern bool cc_dump_bytes;
#define CC_DEV_NAME_STR "cc715ree"
#define CC_COHERENT_CACHE_PARAMS 0xEEE
+/* Maximum DMA mask supported by IP */
+#define DMA_BIT_MASK_LEN 48
+
#define CC_AXI_IRQ_MASK ((1 << CC_AXIM_CFG_BRESPMASK_BIT_SHIFT) | \
(1 << CC_AXIM_CFG_RRESPMASK_BIT_SHIFT) | \
(1 << CC_AXIM_CFG_INFLTMASK_BIT_SHIFT) | \
diff --git a/drivers/staging/ccree/ssi_fips.c b/drivers/staging/ccree/ssi_fips.c
index a1d7782..9ca6857 100644
--- a/drivers/staging/ccree/ssi_fips.c
+++ b/drivers/staging/ccree/ssi_fips.c
@@ -17,7 +17,6 @@
#include <linux/kernel.h>
#include <linux/fips.h>
-#include "ssi_config.h"
#include "ssi_driver.h"
#include "ssi_fips.h"
diff --git a/drivers/staging/ccree/ssi_hash.c b/drivers/staging/ccree/ssi_hash.c
index 0aea404..7f3c22f 100644
--- a/drivers/staging/ccree/ssi_hash.c
+++ b/drivers/staging/ccree/ssi_hash.c
@@ -23,7 +23,6 @@
#include <crypto/md5.h>
#include <crypto/internal/hash.h>
-#include "ssi_config.h"
#include "ssi_driver.h"
#include "ssi_request_mgr.h"
#include "ssi_buffer_mgr.h"
diff --git a/drivers/staging/ccree/ssi_ivgen.c b/drivers/staging/ccree/ssi_ivgen.c
index 0303c85..d1b8ce0 100644
--- a/drivers/staging/ccree/ssi_ivgen.c
+++ b/drivers/staging/ccree/ssi_ivgen.c
@@ -16,7 +16,6 @@
#include <linux/platform_device.h>
#include <crypto/ctr.h>
-#include "ssi_config.h"
#include "ssi_driver.h"
#include "ssi_ivgen.h"
#include "ssi_request_mgr.h"
diff --git a/drivers/staging/ccree/ssi_pm.c b/drivers/staging/ccree/ssi_pm.c
index abc715e..5b80b59 100644
--- a/drivers/staging/ccree/ssi_pm.c
+++ b/drivers/staging/ccree/ssi_pm.c
@@ -14,7 +14,6 @@
* along with this program; if not, see <http://www.gnu.org/licenses/>.
*/
-#include "ssi_config.h"
#include <linux/kernel.h>
#include <linux/platform_device.h>
#include <linux/interrupt.h>
diff --git a/drivers/staging/ccree/ssi_pm.h b/drivers/staging/ccree/ssi_pm.h
index 91140a3..1f601bd 100644
--- a/drivers/staging/ccree/ssi_pm.h
+++ b/drivers/staging/ccree/ssi_pm.h
@@ -20,7 +20,6 @@
#ifndef __CC_POWER_MGR_H__
#define __CC_POWER_MGR_H__
-#include "ssi_config.h"
#include "ssi_driver.h"
#define CC_SUSPEND_TIMEOUT 3000
diff --git a/drivers/staging/ccree/ssi_request_mgr.c b/drivers/staging/ccree/ssi_request_mgr.c
index 2aa21f8..c57c588 100644
--- a/drivers/staging/ccree/ssi_request_mgr.c
+++ b/drivers/staging/ccree/ssi_request_mgr.c
@@ -14,7 +14,6 @@
* along with this program; if not, see <http://www.gnu.org/licenses/>.
*/
-#include "ssi_config.h"
#include <linux/kernel.h>
#include <linux/platform_device.h>
#include <linux/interrupt.h>
--
2.7.4
Update TODO with handling on sysfs -> debugfs transition
Signed-off-by: Gilad Ben-Yossef <[email protected]>
---
drivers/staging/ccree/TODO | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/drivers/staging/ccree/TODO b/drivers/staging/ccree/TODO
index f44edcd..6d8702b 100644
--- a/drivers/staging/ccree/TODO
+++ b/drivers/staging/ccree/TODO
@@ -6,6 +6,5 @@
* *
*************************************************************************
-1. Migrate sysfs to debugfs.
-2. Handle HW FIFO fullness more cleanly.
+1. Handle HW FIFO fullness more cleanly.
--
2.7.4
When moving from internal for kernel FIPS infrastructure the FIPS event irq
handling code was left with the old ifdef by mistake. Fix it.
Fixes: b7e607bf33a2 ("staging: ccree: move FIPS support to kernel infrastructure")
Cc: [email protected]
Signed-off-by: Gilad Ben-Yossef <[email protected]>
---
drivers/staging/ccree/ssi_driver.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/staging/ccree/ssi_driver.c b/drivers/staging/ccree/ssi_driver.c
index df6d415..56b5d45 100644
--- a/drivers/staging/ccree/ssi_driver.c
+++ b/drivers/staging/ccree/ssi_driver.c
@@ -123,7 +123,7 @@ static irqreturn_t cc_isr(int irq, void *dev_id)
irr &= ~CC_COMP_IRQ_MASK;
complete_request(drvdata);
}
-#ifdef CC_SUPPORT_FIPS
+#ifdef CONFIG_CRYPTO_FIPS
/* TEE FIPS interrupt */
if (irr & CC_GPR0_IRQ_MASK) {
/* Mask interrupt - will be unmasked in Deferred service
--
2.7.4
The ccree driver has had a none standard sysfs interface for debugging.
Replace it with a proper debugfs interface.
Signed-off-by: Gilad Ben-Yossef <[email protected]>
---
drivers/staging/ccree/Makefile | 3 +-
drivers/staging/ccree/cc_debugfs.c | 114 +++++++++++++++++++
drivers/staging/ccree/cc_debugfs.h | 45 ++++++++
drivers/staging/ccree/ssi_aead.c | 1 -
drivers/staging/ccree/ssi_cipher.c | 1 -
drivers/staging/ccree/ssi_config.h | 2 -
drivers/staging/ccree/ssi_driver.c | 27 ++---
drivers/staging/ccree/ssi_driver.h | 2 +-
drivers/staging/ccree/ssi_hash.c | 1 -
drivers/staging/ccree/ssi_pm.c | 1 -
drivers/staging/ccree/ssi_request_mgr.c | 1 -
drivers/staging/ccree/ssi_sysfs.c | 192 --------------------------------
drivers/staging/ccree/ssi_sysfs.h | 32 ------
13 files changed, 176 insertions(+), 246 deletions(-)
create mode 100644 drivers/staging/ccree/cc_debugfs.c
create mode 100644 drivers/staging/ccree/cc_debugfs.h
delete mode 100644 drivers/staging/ccree/ssi_sysfs.c
delete mode 100644 drivers/staging/ccree/ssi_sysfs.h
diff --git a/drivers/staging/ccree/Makefile b/drivers/staging/ccree/Makefile
index ae702f3..ab9f073 100644
--- a/drivers/staging/ccree/Makefile
+++ b/drivers/staging/ccree/Makefile
@@ -1,3 +1,4 @@
obj-$(CONFIG_CRYPTO_DEV_CCREE) := ccree.o
-ccree-y := ssi_driver.o ssi_sysfs.o ssi_buffer_mgr.o ssi_request_mgr.o ssi_cipher.o ssi_hash.o ssi_aead.o ssi_ivgen.o ssi_sram_mgr.o ssi_pm.o
+ccree-y := ssi_driver.o ssi_buffer_mgr.o ssi_request_mgr.o ssi_cipher.o ssi_hash.o ssi_aead.o ssi_ivgen.o ssi_sram_mgr.o ssi_pm.o
ccree-$(CONFIG_CRYPTO_FIPS) += ssi_fips.o
+ccree-$(CONFIG_DEBUG_FS) += cc_debugfs.o
diff --git a/drivers/staging/ccree/cc_debugfs.c b/drivers/staging/ccree/cc_debugfs.c
new file mode 100644
index 0000000..7768a7b
--- /dev/null
+++ b/drivers/staging/ccree/cc_debugfs.c
@@ -0,0 +1,114 @@
+/*
+ * Copyright (C) 2012-2017 ARM Limited or its affiliates.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <linux/kernel.h>
+#include <linux/debugfs.h>
+#include <linux/stringify.h>
+#include "ssi_config.h"
+#include "ssi_driver.h"
+#include "cc_crypto_ctx.h"
+
+struct cc_debugfs_ctx {
+ struct dentry *dir;
+};
+
+#define CC_DEBUG_REG(_X) { \
+ .name = __stringify(_X),\
+ .offset = CC_REG(_X) \
+ }
+
+/*
+ * This is a global var for the dentry of the
+ * debugfs ccree/ dir. It is not tied down to
+ * a specific instance of ccree, hence it is
+ * global.
+ */
+static struct dentry *cc_debugfs_dir;
+
+struct debugfs_reg32 debug_regs[] = {
+ CC_DEBUG_REG(HOST_SIGNATURE),
+ CC_DEBUG_REG(HOST_IRR),
+ CC_DEBUG_REG(HOST_POWER_DOWN_EN),
+ CC_DEBUG_REG(AXIM_MON_ERR),
+ CC_DEBUG_REG(DSCRPTR_QUEUE_CONTENT),
+ CC_DEBUG_REG(HOST_IMR),
+ CC_DEBUG_REG(AXIM_CFG),
+ CC_DEBUG_REG(AXIM_CACHE_PARAMS),
+ CC_DEBUG_REG(HOST_VERSION),
+ CC_DEBUG_REG(GPR_HOST),
+ CC_DEBUG_REG(AXIM_MON_COMP),
+};
+
+int cc_debugfs_global_init(void)
+{
+ cc_debugfs_dir = debugfs_create_dir("ccree", NULL);
+
+ return !cc_debugfs_dir;
+}
+
+void cc_debugfs_global_fini(void)
+{
+ debugfs_remove(cc_debugfs_dir);
+}
+
+int cc_debugfs_init(struct cc_drvdata *drvdata)
+{
+ struct device *dev = drvdata_to_dev(drvdata);
+ struct cc_debugfs_ctx *ctx;
+ struct debugfs_regset32 *regset;
+ struct dentry *file;
+
+ ctx = devm_kzalloc(dev, sizeof(*ctx), GFP_KERNEL);
+ if (!ctx)
+ return -ENOMEM;
+
+ regset = devm_kzalloc(dev, sizeof(*regset), GFP_KERNEL);
+ if (!regset)
+ return -ENOMEM;
+
+ regset->regs = debug_regs;
+ regset->nregs = ARRAY_SIZE(debug_regs);
+ regset->base = drvdata->cc_base;
+
+ ctx->dir = debugfs_create_dir(drvdata->plat_dev->name, cc_debugfs_dir);
+ if (!ctx->dir)
+ return -ENFILE;
+
+ file = debugfs_create_regset32("regs", 0400, ctx->dir, regset);
+ if (!file) {
+ debugfs_remove(ctx->dir);
+ return -ENFILE;
+ }
+
+ file = debugfs_create_bool("coherent", 0400, ctx->dir,
+ &drvdata->coherent);
+
+ if (!file) {
+ debugfs_remove_recursive(ctx->dir);
+ return -ENFILE;
+ }
+
+ drvdata->debugfs = ctx;
+
+ return 0;
+}
+
+void cc_debugfs_fini(struct cc_drvdata *drvdata)
+{
+ struct cc_debugfs_ctx *ctx = (struct cc_debugfs_ctx *)drvdata->debugfs;
+
+ debugfs_remove_recursive(ctx->dir);
+}
diff --git a/drivers/staging/ccree/cc_debugfs.h b/drivers/staging/ccree/cc_debugfs.h
new file mode 100644
index 0000000..edfe9ba
--- /dev/null
+++ b/drivers/staging/ccree/cc_debugfs.h
@@ -0,0 +1,45 @@
+/*
+ * Copyright (C) 2012-2017 ARM Limited or its affiliates.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef __CC_DEBUGFS_H__
+#define __CC_DEBUGFS_H__
+
+#ifdef CONFIG_DEBUG_FS
+int cc_debugfs_global_init(void);
+void cc_debugfs_global_fini(void);
+
+int cc_debugfs_init(struct cc_drvdata *drvdata);
+void cc_debugfs_fini(struct cc_drvdata *drvdata);
+
+#else
+
+int cc_debugfs_global_init(void)
+{
+ return 0;
+}
+
+void cc_debugfs_global_fini(void) {}
+
+int cc_debugfs_init(struct cc_drvdata *drvdata)
+{
+ return 0;
+}
+
+void cc_debugfs_fini(struct cc_drvdata *drvdata) {}
+
+#endif
+
+#endif /*__CC_SYSFS_H__*/
diff --git a/drivers/staging/ccree/ssi_aead.c b/drivers/staging/ccree/ssi_aead.c
index 12ceb119..dde6797 100644
--- a/drivers/staging/ccree/ssi_aead.c
+++ b/drivers/staging/ccree/ssi_aead.c
@@ -34,7 +34,6 @@
#include "ssi_aead.h"
#include "ssi_request_mgr.h"
#include "ssi_hash.h"
-#include "ssi_sysfs.h"
#include "ssi_sram_mgr.h"
#define template_aead template_u.aead
diff --git a/drivers/staging/ccree/ssi_cipher.c b/drivers/staging/ccree/ssi_cipher.c
index 791fe75..f940568 100644
--- a/drivers/staging/ccree/ssi_cipher.c
+++ b/drivers/staging/ccree/ssi_cipher.c
@@ -32,7 +32,6 @@
#include "ssi_buffer_mgr.h"
#include "ssi_cipher.h"
#include "ssi_request_mgr.h"
-#include "ssi_sysfs.h"
#define MAX_ABLKCIPHER_SEQ_LEN 6
diff --git a/drivers/staging/ccree/ssi_config.h b/drivers/staging/ccree/ssi_config.h
index ee2d310..15725cc 100644
--- a/drivers/staging/ccree/ssi_config.h
+++ b/drivers/staging/ccree/ssi_config.h
@@ -28,8 +28,6 @@
//#define CC_DUMP_DESCS
// #define CC_DUMP_BYTES
// #define CC_DEBUG
-/* Enable sysfs interface for debugging REE driver */
-#define ENABLE_CC_SYSFS
//#define CC_IRQ_DELAY 100000
/* was 32 bit, but for juno's sake it was enlarged to 48 bit */
#define DMA_BIT_MASK_LEN 48
diff --git a/drivers/staging/ccree/ssi_driver.c b/drivers/staging/ccree/ssi_driver.c
index 5427c7f..14705dc 100644
--- a/drivers/staging/ccree/ssi_driver.c
+++ b/drivers/staging/ccree/ssi_driver.c
@@ -63,7 +63,7 @@
#include "ssi_driver.h"
#include "ssi_request_mgr.h"
#include "ssi_buffer_mgr.h"
-#include "ssi_sysfs.h"
+#include "cc_debugfs.h"
#include "ssi_cipher.h"
#include "ssi_aead.h"
#include "ssi_hash.h"
@@ -299,18 +299,16 @@ static int init_cc_resources(struct platform_device *plat_dev)
goto post_clk_err;
}
-#ifdef ENABLE_CC_SYSFS
- rc = ssi_sysfs_init(&dev->kobj, new_drvdata);
+ rc = cc_debugfs_init(new_drvdata);
if (rc) {
- dev_err(dev, "init_stat_db failed\n");
+ dev_err(dev, "Failed registering debugfs interface\n");
goto post_regs_err;
}
-#endif
rc = cc_fips_init(new_drvdata);
if (rc) {
dev_err(dev, "CC_FIPS_INIT failed 0x%x\n", rc);
- goto post_sysfs_err;
+ goto post_debugfs_err;
}
rc = cc_sram_mgr_init(new_drvdata);
if (rc) {
@@ -394,10 +392,8 @@ static int init_cc_resources(struct platform_device *plat_dev)
cc_sram_mgr_fini(new_drvdata);
post_fips_init_err:
cc_fips_fini(new_drvdata);
-post_sysfs_err:
-#ifdef ENABLE_CC_SYSFS
- ssi_sysfs_fini();
-#endif
+post_debugfs_err:
+ cc_debugfs_fini(new_drvdata);
post_regs_err:
fini_cc_regs(new_drvdata);
post_clk_err:
@@ -425,9 +421,7 @@ static void cleanup_cc_resources(struct platform_device *plat_dev)
cc_req_mgr_fini(drvdata);
cc_sram_mgr_fini(drvdata);
cc_fips_fini(drvdata);
-#ifdef ENABLE_CC_SYSFS
- ssi_sysfs_fini();
-#endif
+ cc_debugfs_fini(drvdata);
fini_cc_regs(drvdata);
cc_clk_off(drvdata);
}
@@ -520,6 +514,12 @@ static struct platform_driver cc7x_driver = {
static int __init ccree_init(void)
{
+ int ret;
+
+ ret = cc_debugfs_global_init();
+ if (ret)
+ return ret;
+
return platform_driver_register(&cc7x_driver);
}
module_init(ccree_init);
@@ -527,6 +527,7 @@ module_init(ccree_init);
static void __exit ccree_exit(void)
{
platform_driver_unregister(&cc7x_driver);
+ cc_debugfs_global_fini();
}
module_exit(ccree_exit);
diff --git a/drivers/staging/ccree/ssi_driver.h b/drivers/staging/ccree/ssi_driver.h
index 35e1b72..4e05386 100644
--- a/drivers/staging/ccree/ssi_driver.h
+++ b/drivers/staging/ccree/ssi_driver.h
@@ -44,7 +44,6 @@
#include "dx_reg_common.h"
#define CC_SUPPORT_SHA CC_DEV_SHA_MAX
#include "cc_crypto_ctx.h"
-#include "ssi_sysfs.h"
#include "hash_defs.h"
#include "cc_hw_queue_defs.h"
#include "ssi_sram_mgr.h"
@@ -127,6 +126,7 @@ struct cc_drvdata {
void *fips_handle;
void *ivgen_handle;
void *sram_mgr_handle;
+ void *debugfs;
struct clk *clk;
bool coherent;
};
diff --git a/drivers/staging/ccree/ssi_hash.c b/drivers/staging/ccree/ssi_hash.c
index 5794ab6..0aea404 100644
--- a/drivers/staging/ccree/ssi_hash.c
+++ b/drivers/staging/ccree/ssi_hash.c
@@ -27,7 +27,6 @@
#include "ssi_driver.h"
#include "ssi_request_mgr.h"
#include "ssi_buffer_mgr.h"
-#include "ssi_sysfs.h"
#include "ssi_hash.h"
#include "ssi_sram_mgr.h"
diff --git a/drivers/staging/ccree/ssi_pm.c b/drivers/staging/ccree/ssi_pm.c
index 0db935d..abc715e 100644
--- a/drivers/staging/ccree/ssi_pm.c
+++ b/drivers/staging/ccree/ssi_pm.c
@@ -24,7 +24,6 @@
#include "ssi_buffer_mgr.h"
#include "ssi_request_mgr.h"
#include "ssi_sram_mgr.h"
-#include "ssi_sysfs.h"
#include "ssi_ivgen.h"
#include "ssi_hash.h"
#include "ssi_pm.h"
diff --git a/drivers/staging/ccree/ssi_request_mgr.c b/drivers/staging/ccree/ssi_request_mgr.c
index 480e6d3..07b9404 100644
--- a/drivers/staging/ccree/ssi_request_mgr.c
+++ b/drivers/staging/ccree/ssi_request_mgr.c
@@ -27,7 +27,6 @@
#include "ssi_driver.h"
#include "ssi_buffer_mgr.h"
#include "ssi_request_mgr.h"
-#include "ssi_sysfs.h"
#include "ssi_ivgen.h"
#include "ssi_pm.h"
diff --git a/drivers/staging/ccree/ssi_sysfs.c b/drivers/staging/ccree/ssi_sysfs.c
deleted file mode 100644
index b2e58f5..0000000
--- a/drivers/staging/ccree/ssi_sysfs.c
+++ /dev/null
@@ -1,192 +0,0 @@
-/*
- * Copyright (C) 2012-2017 ARM Limited or its affiliates.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, see <http://www.gnu.org/licenses/>.
- */
-
-#include <linux/kernel.h>
-#include "ssi_config.h"
-#include "ssi_driver.h"
-#include "cc_crypto_ctx.h"
-#include "ssi_sysfs.h"
-
-#ifdef ENABLE_CC_SYSFS
-
-static struct cc_drvdata *sys_get_drvdata(void);
-
-static ssize_t ssi_sys_regdump_show(struct kobject *kobj,
- struct kobj_attribute *attr, char *buf)
-{
- struct cc_drvdata *drvdata = sys_get_drvdata();
- u32 register_value;
- int offset = 0;
-
- register_value = cc_ioread(drvdata, CC_REG(HOST_SIGNATURE));
- offset += scnprintf(buf + offset, PAGE_SIZE - offset,
- "%s \t(0x%lX)\t 0x%08X\n", "HOST_SIGNATURE ",
- CC_HOST_SIGNATURE_REG_OFFSET, register_value);
- register_value = cc_ioread(drvdata, CC_REG(HOST_IRR));
- offset += scnprintf(buf + offset, PAGE_SIZE - offset,
- "%s \t(0x%lX)\t 0x%08X\n", "HOST_IRR ",
- CC_HOST_IRR_REG_OFFSET, register_value);
- register_value = cc_ioread(drvdata, CC_REG(HOST_POWER_DOWN_EN));
- offset += scnprintf(buf + offset, PAGE_SIZE - offset,
- "%s \t(0x%lX)\t 0x%08X\n", "HOST_POWER_DOWN_EN ",
- CC_HOST_POWER_DOWN_EN_REG_OFFSET, register_value);
- register_value = cc_ioread(drvdata, CC_REG(AXIM_MON_ERR));
- offset += scnprintf(buf + offset, PAGE_SIZE - offset,
- "%s \t(0x%lX)\t 0x%08X\n", "AXIM_MON_ERR ",
- CC_AXIM_MON_ERR_REG_OFFSET, register_value);
- register_value = cc_ioread(drvdata, CC_REG(DSCRPTR_QUEUE_CONTENT));
- offset += scnprintf(buf + offset, PAGE_SIZE - offset,
- "%s \t(0x%lX)\t 0x%08X\n", "DSCRPTR_QUEUE_CONTENT",
- CC_DSCRPTR_QUEUE_CONTENT_REG_OFFSET,
- register_value);
- return offset;
-}
-
-static ssize_t ssi_sys_help_show(struct kobject *kobj,
- struct kobj_attribute *attr, char *buf)
-{
- static const char * const help_str[] = {
- "cat reg_dump ",
- "Print several of CC register values",
- };
- int i = 0, offset = 0;
-
- offset += scnprintf(buf + offset, PAGE_SIZE - offset, "Usage:\n");
- for (i = 0; i < ARRAY_SIZE(help_str); i += 2) {
- offset += scnprintf(buf + offset, PAGE_SIZE - offset,
- "%s\t\t%s\n", help_str[i],
- help_str[i + 1]);
- }
-
- return offset;
-}
-
-/********************************************************
- * SYSFS objects *
- ********************************************************/
-/*
- * Structure used to create a directory
- * and its attributes in sysfs.
- */
-struct sys_dir {
- struct kobject *sys_dir_kobj;
- struct attribute_group sys_dir_attr_group;
- struct attribute **sys_dir_attr_list;
- u32 num_of_attrs;
- struct cc_drvdata *drvdata; /* Associated driver context */
-};
-
-/* top level directory structures */
-static struct sys_dir sys_top_dir;
-
-/* TOP LEVEL ATTRIBUTES */
-static struct kobj_attribute ssi_sys_top_level_attrs[] = {
- __ATTR(dump_regs, 0444, ssi_sys_regdump_show, NULL),
- __ATTR(help, 0444, ssi_sys_help_show, NULL),
-#if defined CC_CYCLE_COUNT
- __ATTR(stats_host, 0664, ssi_sys_stat_host_db_show,
- ssi_sys_stats_host_db_clear),
- __ATTR(stats_cc, 0664, ssi_sys_stat_cc_db_show,
- ssi_sys_stats_cc_db_clear),
-#endif
-
-};
-
-static struct cc_drvdata *sys_get_drvdata(void)
-{
- /* TODO: supporting multiple SeP devices would require avoiding
- * global "top_dir" and finding associated "top_dir" by traversing
- * up the tree to the kobject which matches one of the top_dir's
- */
- return sys_top_dir.drvdata;
-}
-
-static int sys_init_dir(struct sys_dir *sys_dir, struct cc_drvdata *drvdata,
- struct kobject *parent_dir_kobj, const char *dir_name,
- struct kobj_attribute *attrs, u32 num_of_attrs)
-{
- int i;
-
- memset(sys_dir, 0, sizeof(struct sys_dir));
-
- sys_dir->drvdata = drvdata;
-
- /* initialize directory kobject */
- sys_dir->sys_dir_kobj =
- kobject_create_and_add(dir_name, parent_dir_kobj);
-
- if (!(sys_dir->sys_dir_kobj))
- return -ENOMEM;
- /* allocate memory for directory's attributes list */
- sys_dir->sys_dir_attr_list =
- kcalloc(num_of_attrs + 1, sizeof(struct attribute *),
- GFP_KERNEL);
-
- if (!(sys_dir->sys_dir_attr_list)) {
- kobject_put(sys_dir->sys_dir_kobj);
- return -ENOMEM;
- }
-
- sys_dir->num_of_attrs = num_of_attrs;
-
- /* initialize attributes list */
- for (i = 0; i < num_of_attrs; ++i)
- sys_dir->sys_dir_attr_list[i] = &attrs[i].attr;
-
- /* last list entry should be NULL */
- sys_dir->sys_dir_attr_list[num_of_attrs] = NULL;
-
- sys_dir->sys_dir_attr_group.attrs = sys_dir->sys_dir_attr_list;
-
- return sysfs_create_group(sys_dir->sys_dir_kobj,
- &sys_dir->sys_dir_attr_group);
-}
-
-static void sys_free_dir(struct sys_dir *sys_dir)
-{
- if (!sys_dir)
- return;
-
- kfree(sys_dir->sys_dir_attr_list);
-
- if (sys_dir->sys_dir_kobj) {
- sysfs_remove_group(sys_dir->sys_dir_kobj,
- &sys_dir->sys_dir_attr_group);
- kobject_put(sys_dir->sys_dir_kobj);
- }
-}
-
-int ssi_sysfs_init(struct kobject *sys_dev_obj, struct cc_drvdata *drvdata)
-{
- int retval;
- struct device *dev = drvdata_to_dev(drvdata);
-
- dev_info(dev, "setup sysfs under %s\n", sys_dev_obj->name);
-
- /* Initialize top directory */
- retval = sys_init_dir(&sys_top_dir, drvdata, sys_dev_obj, "cc_info",
- ssi_sys_top_level_attrs,
- ARRAY_SIZE(ssi_sys_top_level_attrs));
- return retval;
-}
-
-void ssi_sysfs_fini(void)
-{
- sys_free_dir(&sys_top_dir);
-}
-
-#endif /*ENABLE_CC_SYSFS*/
-
diff --git a/drivers/staging/ccree/ssi_sysfs.h b/drivers/staging/ccree/ssi_sysfs.h
deleted file mode 100644
index 9833d18..0000000
--- a/drivers/staging/ccree/ssi_sysfs.h
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Copyright (C) 2012-2017 ARM Limited or its affiliates.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, see <http://www.gnu.org/licenses/>.
- */
-
-/* \file ssi_sysfs.h
- * ARM CryptoCell sysfs APIs
- */
-
-#ifndef __CC_SYSFS_H__
-#define __CC_SYSFS_H__
-
-#include <asm/timex.h>
-
-/* forward declaration */
-struct cc_drvdata;
-
-int ssi_sysfs_init(struct kobject *sys_dev_obj, struct cc_drvdata *drvdata);
-void ssi_sysfs_fini(void);
-
-#endif /*__CC_SYSFS_H__*/
--
2.7.4
Gilad,
On Thu, Dec 14, 2017 at 3:02 PM, Gilad Ben-Yossef <[email protected]> wrote:
> The ccree driver has had a none standard sysfs interface for debugging.
> Replace it with a proper debugfs interface.
>
> Signed-off-by: Gilad Ben-Yossef <[email protected]>
<snip>
> --- /dev/null
> +++ b/drivers/staging/ccree/cc_debugfs.c
> @@ -0,0 +1,114 @@
> +/*
> + * Copyright (C) 2012-2017 ARM Limited or its affiliates.
> + *
> + * This program is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License version 2 as
> + * published by the Free Software Foundation.
> + *
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
> + * GNU General Public License for more details.
> + *
> + * You should have received a copy of the GNU General Public License
> + * along with this program; if not, see <http://www.gnu.org/licenses/>.
> + */
Could you use the new SPDX tags instead of this fine and long
boilerplate? See Thomas doc for details [1]
You could spare the world from ~14 lines of this fine legalese with this:
// SPDX-License-Identifier: GPL-2.0
// Copyright (C) 2012-2017 ARM Limited or its affiliates.
If you wonder about the C++ style comment, read Thomas doc patches [1]
and check the comments made on the list by Linus.
If you could spread the word out in your team too, this would be much welcomed!
Thanks!
[1] https://lkml.org/lkml/2017/12/4/934
--
Cordially
Philippe Ombredanne
On Thu, Dec 14, 2017 at 4:30 PM, Philippe Ombredanne
<[email protected]> wrote:
> Gilad,
>
> On Thu, Dec 14, 2017 at 3:02 PM, Gilad Ben-Yossef <[email protected]> wrote:
>> The ccree driver has had a none standard sysfs interface for debugging.
>> Replace it with a proper debugfs interface.
>>
>> Signed-off-by: Gilad Ben-Yossef <[email protected]>
>
> <snip>
>
>> --- /dev/null
>> +++ b/drivers/staging/ccree/cc_debugfs.c
>> @@ -0,0 +1,114 @@
>> +/*
>> + * Copyright (C) 2012-2017 ARM Limited or its affiliates.
>> + *
>> + * This program is free software; you can redistribute it and/or modify
>> + * it under the terms of the GNU General Public License version 2 as
>> + * published by the Free Software Foundation.
>> + *
>> + * This program is distributed in the hope that it will be useful,
>> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
>> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
>> + * GNU General Public License for more details.
>> + *
>> + * You should have received a copy of the GNU General Public License
>> + * along with this program; if not, see <http://www.gnu.org/licenses/>.
>> + */
>
> Could you use the new SPDX tags instead of this fine and long
> boilerplate? See Thomas doc for details [1]
That's a good idea. I'll prepare a patch set to turn the entire driver.
Thanks,
Gilad
--
Gilad Ben-Yossef
Chief Coffee Drinker
"If you take a class in large-scale robotics, can you end up in a
situation where the homework eats your dog?"
-- Jean-Baptiste Queru