From: Christian Hohnstaedt <christian@hohnstaedt.de>
To: Herbert Xu <herbert@gondor.apana.org.au>
Cc: Crypto Mailing List <linux-crypto@vger.kernel.org>
Subject: [PATCH] ixp4xx_crypto: avoid firmware loading during module initialisation
Date: Mon, 18 Aug 2008 08:44:55 +0200 [thread overview]
Message-ID: <20080818064455.GK22567@mail3.prorata.de> (raw)
By moving the firmware-loading to the transform initialisation,
the driver may be compiled in.
Notify the user if the firmware does not support AES, or even
no crypto at all.
Signed-off-by: Christian Hohnstaedt <chohnstaedt@innominate.com>
---
drivers/crypto/ixp4xx_crypto.c | 44 ++++++++++++++++++++++++++++++++++++---
1 files changed, 40 insertions(+), 4 deletions(-)
diff --git a/drivers/crypto/ixp4xx_crypto.c b/drivers/crypto/ixp4xx_crypto.c
index 42a107f..c3aa5a4 100644
--- a/drivers/crypto/ixp4xx_crypto.c
+++ b/drivers/crypto/ixp4xx_crypto.c
@@ -438,10 +438,6 @@ static int init_ixp_crypto(void)
if (!npe_c)
return ret;
- if (!npe_running(npe_c)) {
- npe_load_firmware(npe_c, npe_name(npe_c), dev);
- }
-
/* buffer_pool will also be used to sometimes store the hmac,
* so assure it is large enough
*/
@@ -526,9 +522,45 @@ static void free_sa_dir(struct ix_sa_dir *dir)
static int init_tfm(struct crypto_tfm *tfm)
{
struct ixp_ctx *ctx = crypto_tfm_ctx(tfm);
+ u32 msg[2] = { 0, 0 };
+ static u32 image_id = 0;
int ret;
atomic_set(&ctx->configuring, 0);
+
+ if (!npe_running(npe_c)) {
+ ret = npe_load_firmware(npe_c, npe_name(npe_c), dev);
+ if (ret)
+ return ret;
+ if (npe_recv_message(npe_c, msg, "STATUS_MSG"))
+ goto npe_error;
+
+ image_id = msg[1];
+ }
+ if (!image_id) {
+ if (npe_send_message(npe_c, msg, "STATUS_MSG"))
+ goto npe_error;
+
+ if (npe_recv_message(npe_c, msg, "STATUS_MSG"))
+ goto npe_error;
+
+ image_id = msg[1];
+ }
+ switch ((image_id>>16) & 0xff) {
+ case 3:
+ if (cipher_cfg_enc(tfm) & MOD_AES) {
+ printk(KERN_ERR "Firmware of %s lacks AES "
+ "support\n", npe_name(npe_c));
+ return -ENODEV;
+ }
+ case 4:
+ case 5:
+ break;
+ default:
+ printk(KERN_ERR "Firmware of %s lacks crypto support\n",
+ npe_name(npe_c));
+ return -ENODEV;
+ }
ret = init_sa_dir(&ctx->encrypt);
if (ret)
return ret;
@@ -537,6 +569,10 @@ static int init_tfm(struct crypto_tfm *tfm)
free_sa_dir(&ctx->encrypt);
}
return ret;
+
+npe_error:
+ printk(KERN_ERR "%s not responding\n", npe_name(npe_c));
+ return -EIO;
}
static int init_tfm_ablk(struct crypto_tfm *tfm)
--
1.5.6.3
next reply other threads:[~2008-08-18 6:51 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-08-18 6:44 Christian Hohnstaedt [this message]
2008-08-19 4:55 ` [PATCH] ixp4xx_crypto: avoid firmware loading during module initialisation Herbert Xu
2008-10-23 12:28 ` Christian Hohnstaedt
2008-10-30 4:27 ` Herbert Xu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20080818064455.GK22567@mail3.prorata.de \
--to=christian@hohnstaedt.de \
--cc=herbert@gondor.apana.org.au \
--cc=linux-crypto@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox