From: Stanimir Varbanov <svarbanov@mm-sol.com>
To: Courtney Cavin <courtney.cavin@sonymobile.com>
Cc: Herbert Xu <herbert@gondor.apana.org.au>,
"David S. Miller" <davem@davemloft.net>,
Grant Likely <grant.likely@linaro.org>,
Rob Herring <robh+dt@kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"linux-crypto@vger.kernel.org" <linux-crypto@vger.kernel.org>,
"devicetree@vger.kernel.org" <devicetree@vger.kernel.org>,
"linux-arm-msm@vger.kernel.org" <linux-arm-msm@vger.kernel.org>
Subject: Re: [PATCH 1/9] crypto: qce: Add core driver implementation
Date: Tue, 08 Apr 2014 19:26:44 +0300 [thread overview]
Message-ID: <53442344.8000801@mm-sol.com> (raw)
In-Reply-To: <20140403233844.GF17066@sonymobile.com>
Hi Courtney,
Thanks for the review!
On 04/04/2014 02:38 AM, Courtney Cavin wrote:
> On Thu, Apr 03, 2014 at 06:17:58PM +0200, Stanimir Varbanov wrote:
>> This adds core driver files. The core part is implementing a
>> platform driver probe and remove callbaks, the probe enables
>> clocks, checks crypto version, initialize and request dma
>> channels, create done tasklet and work queue and finally
>> register the algorithms into crypto subsystem.
>>
>> Signed-off-by: Stanimir Varbanov <svarbanov@mm-sol.com>
>> ---
>> drivers/crypto/qce/core.c | 333 ++++++++++++++++++++++++++++++++++++++++++++++
>> drivers/crypto/qce/core.h | 69 ++++++++++
>> 2 files changed, 402 insertions(+)
>> create mode 100644 drivers/crypto/qce/core.c
>> create mode 100644 drivers/crypto/qce/core.h
>>
>> diff --git a/drivers/crypto/qce/core.c b/drivers/crypto/qce/core.c
> [...]
>> +static struct qce_algo_ops qce_ops[] = {
>> + {
>> + .type = CRYPTO_ALG_TYPE_ABLKCIPHER,
>> + .register_alg = qce_ablkcipher_register,
>> + },
>> + {
>> + .type = CRYPTO_ALG_TYPE_AHASH,
>> + .register_alg = qce_ahash_register,
>> + },
>> +};
>> +
>> +static void qce_unregister_algs(struct qce_device *qce)
>> +{
>> + struct qce_alg_template *tmpl, *n;
>> +
>> + list_for_each_entry_safe(tmpl, n, &qce->alg_list, entry) {
>> + if (tmpl->crypto_alg_type == CRYPTO_ALG_TYPE_AHASH)
>> + crypto_unregister_ahash(&tmpl->alg.ahash);
>> + else
>> + crypto_unregister_alg(&tmpl->alg.crypto);
>> +
>> + list_del(&tmpl->entry);
>> + kfree(tmpl);
>
> I find this whole memory/list management to be very disorganised.
> ops->register_alg() is supposed to allocate this item--more precisely,
> multiple items--using something that must be able to be kfree'd
> directly, register it with the crypto core, and put it on this list
> manually. Here we unregister/remove/free this in the core. Josh's
> recommendation of a unregister_alg callback might help, but it all
> remains a bit unclear with register_alg/unregister_alg managing X
> algorithms per call.
>
> Additionally, above you have qce_ops, which clearly defines the
> operations for specific algorithms types/groups, which in later patches
> are shown to be seperated out into independent implementations.
>
> From what I can tell, this seems to be a framework with built-in yet
> independent crypto implementations which call the crypto API directly.
>
> It would be more logical to me if this was seperated out into a
> "library/core" API, with the individual implementations as platform
> drivers of their own. Then they can register with the core, managing
> memory how they please.
>
> What am I missing?
>
No, you have not miss nothing.
OK I see your point. I made few changes in the core, killed the alg_list
and its manipulation function and added a .unregister_algs operation.
Now every type of algorithm will handle all core crypto api functions
itself. Also I'm using devm_kzalloc() in .register_algs when allocating
memory for qce_alg_template structures to avoid kfree(). The callbacks
async_req_queue/done are now embedded in qce_device structure and they
are invoked directly from algorithm implementations. Thus I have
separated the interfaces: functions implemented in core part of the
driver and struct qce_algo_ops having the function pointers implemented
by every type of algorithm.
If you don't have some objections I can send out a version 2.
--
regards,
Stan
next prev parent reply other threads:[~2014-04-08 16:26 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-04-03 16:17 [PATCH 0/9] Add Qualcomm crypto driver Stanimir Varbanov
2014-04-03 16:17 ` [PATCH 1/9] crypto: qce: Add core driver implementation Stanimir Varbanov
2014-04-03 18:19 ` Josh Cartwright
2014-04-04 15:54 ` Stanimir Varbanov
2014-04-03 23:38 ` Courtney Cavin
2014-04-08 16:26 ` Stanimir Varbanov [this message]
2014-04-08 22:00 ` Courtney Cavin
2014-04-14 8:19 ` Stanimir Varbanov
2014-04-03 16:17 ` [PATCH 2/9] crypto: qce: Add register defines Stanimir Varbanov
2014-04-03 16:24 ` Kumar Gala
2014-04-03 16:33 ` Stanimir Varbanov
2014-04-03 16:42 ` Kumar Gala
2014-04-04 9:23 ` Srinivas Kandagatla
2014-04-04 22:14 ` Stanimir Vabanov
2014-04-03 16:18 ` [PATCH 3/9] crypto: qce: Add dma and sg helpers Stanimir Varbanov
2014-04-03 18:25 ` Josh Cartwright
2014-04-04 8:49 ` Stanimir Varbanov
2014-04-03 23:15 ` Courtney Cavin
2014-04-04 13:07 ` Stanimir Varbanov
2014-04-07 22:42 ` Courtney Cavin
2014-04-08 12:08 ` Stanimir Varbanov
2014-04-03 16:18 ` [PATCH 4/9] crypto: qce: Add ablkcipher algorithms Stanimir Varbanov
2014-04-03 16:18 ` [PATCH 5/9] crypto: qce: Adds sha and hmac transforms Stanimir Varbanov
2014-04-09 0:09 ` Stephen Boyd
2014-04-10 14:40 ` Stanimir Varbanov
2014-04-11 20:12 ` Stephen Boyd
2014-04-14 8:23 ` Stanimir Varbanov
2014-04-03 16:18 ` [PATCH 6/9] crypto: qce: Adds infrastructure to setup the crypto block Stanimir Varbanov
2014-04-03 16:18 ` [PATCH 7/9] crypto: qce: Adds Makefile to build the driver Stanimir Varbanov
2014-04-03 16:18 ` [PATCH 8/9] crypto: qce: Build Qualcomm qce driver Stanimir Varbanov
2014-04-03 16:18 ` [PATCH 9/9] ARM: DT: qcom: Add Qualcomm crypto driver binding document Stanimir Varbanov
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=53442344.8000801@mm-sol.com \
--to=svarbanov@mm-sol.com \
--cc=courtney.cavin@sonymobile.com \
--cc=davem@davemloft.net \
--cc=devicetree@vger.kernel.org \
--cc=grant.likely@linaro.org \
--cc=herbert@gondor.apana.org.au \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-crypto@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=robh+dt@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.