Message ID | 20241203-crypto-qce-refactor-v1-8-c5901d2dd45c@linaro.org (mailing list archive) |
---|---|
State | Not Applicable |
Headers | show |
Series | crypto: qce - refactor the driver | expand |
On 03/12/2024 10:19, Bartosz Golaszewski wrote: > From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org> > > There's nothing about the qce driver that requires running from a > tasklet. Switch to using the system workqueue. > > Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org> > --- > drivers/crypto/qce/core.c | 20 ++++++-------------- > drivers/crypto/qce/core.h | 6 ++++-- > 2 files changed, 10 insertions(+), 16 deletions(-) > > diff --git a/drivers/crypto/qce/core.c b/drivers/crypto/qce/core.c > index 5e21754c7f822..6de9f1e23e282 100644 > --- a/drivers/crypto/qce/core.c > +++ b/drivers/crypto/qce/core.c > @@ -122,15 +122,16 @@ static int qce_handle_queue(struct qce_device *qce, > err = qce_handle_request(async_req); > if (err) { > qce->result = err; > - tasklet_schedule(&qce->done_tasklet); > + schedule_work(&qce->done_work); > } > > return ret; > } > > -static void qce_tasklet_req_done(unsigned long data) > +static void qce_req_done_work(struct work_struct *work) > { > - struct qce_device *qce = (struct qce_device *)data; > + struct qce_device *qce = container_of(work, struct qce_device, > + done_work); > struct crypto_async_request *req; > unsigned long flags; > > @@ -154,7 +155,7 @@ static int qce_async_request_enqueue(struct qce_device *qce, > static void qce_async_request_done(struct qce_device *qce, int ret) > { > qce->result = ret; > - tasklet_schedule(&qce->done_tasklet); > + schedule_work(&qce->done_work); > } > > static int qce_check_version(struct qce_device *qce) > @@ -243,8 +244,7 @@ static int qce_crypto_probe(struct platform_device *pdev) > return ret; > > spin_lock_init(&qce->lock); > - tasklet_init(&qce->done_tasklet, qce_tasklet_req_done, > - (unsigned long)qce); > + INIT_WORK(&qce->done_work, qce_req_done_work); > crypto_init_queue(&qce->queue, QCE_QUEUE_LENGTH); > > qce->async_req_enqueue = qce_async_request_enqueue; > @@ -253,13 +253,6 @@ static int qce_crypto_probe(struct platform_device *pdev) > return devm_qce_register_algs(qce); > } > > -static void qce_crypto_remove(struct platform_device *pdev) > -{ > - struct qce_device *qce = platform_get_drvdata(pdev); > - > - tasklet_kill(&qce->done_tasklet); > -} > - > static const struct of_device_id qce_crypto_of_match[] = { > { .compatible = "qcom,crypto-v5.1", }, > { .compatible = "qcom,crypto-v5.4", }, > @@ -270,7 +263,6 @@ MODULE_DEVICE_TABLE(of, qce_crypto_of_match); > > static struct platform_driver qce_crypto_driver = { > .probe = qce_crypto_probe, > - .remove = qce_crypto_remove, > .driver = { > .name = KBUILD_MODNAME, > .of_match_table = qce_crypto_of_match, > diff --git a/drivers/crypto/qce/core.h b/drivers/crypto/qce/core.h > index 228fcd69ec511..39e75a75a4293 100644 > --- a/drivers/crypto/qce/core.h > +++ b/drivers/crypto/qce/core.h > @@ -6,13 +6,15 @@ > #ifndef _CORE_H_ > #define _CORE_H_ > > +#include <linux/workqueue.h> > + > #include "dma.h" > > /** > * struct qce_device - crypto engine device structure > * @queue: crypto request queue > * @lock: the lock protects queue and req > - * @done_tasklet: done tasklet object > + * @done_work: workqueue context > * @req: current active request > * @result: result of current transform > * @base: virtual IO base > @@ -29,7 +31,7 @@ > struct qce_device { > struct crypto_queue queue; > spinlock_t lock; > - struct tasklet_struct done_tasklet; > + struct work_struct done_work; > struct crypto_async_request *req; > int result; > void __iomem *base; > Reviewed-by: Neil Armstrong <neil.armstrong@linaro.org>
diff --git a/drivers/crypto/qce/core.c b/drivers/crypto/qce/core.c index 5e21754c7f822..6de9f1e23e282 100644 --- a/drivers/crypto/qce/core.c +++ b/drivers/crypto/qce/core.c @@ -122,15 +122,16 @@ static int qce_handle_queue(struct qce_device *qce, err = qce_handle_request(async_req); if (err) { qce->result = err; - tasklet_schedule(&qce->done_tasklet); + schedule_work(&qce->done_work); } return ret; } -static void qce_tasklet_req_done(unsigned long data) +static void qce_req_done_work(struct work_struct *work) { - struct qce_device *qce = (struct qce_device *)data; + struct qce_device *qce = container_of(work, struct qce_device, + done_work); struct crypto_async_request *req; unsigned long flags; @@ -154,7 +155,7 @@ static int qce_async_request_enqueue(struct qce_device *qce, static void qce_async_request_done(struct qce_device *qce, int ret) { qce->result = ret; - tasklet_schedule(&qce->done_tasklet); + schedule_work(&qce->done_work); } static int qce_check_version(struct qce_device *qce) @@ -243,8 +244,7 @@ static int qce_crypto_probe(struct platform_device *pdev) return ret; spin_lock_init(&qce->lock); - tasklet_init(&qce->done_tasklet, qce_tasklet_req_done, - (unsigned long)qce); + INIT_WORK(&qce->done_work, qce_req_done_work); crypto_init_queue(&qce->queue, QCE_QUEUE_LENGTH); qce->async_req_enqueue = qce_async_request_enqueue; @@ -253,13 +253,6 @@ static int qce_crypto_probe(struct platform_device *pdev) return devm_qce_register_algs(qce); } -static void qce_crypto_remove(struct platform_device *pdev) -{ - struct qce_device *qce = platform_get_drvdata(pdev); - - tasklet_kill(&qce->done_tasklet); -} - static const struct of_device_id qce_crypto_of_match[] = { { .compatible = "qcom,crypto-v5.1", }, { .compatible = "qcom,crypto-v5.4", }, @@ -270,7 +263,6 @@ MODULE_DEVICE_TABLE(of, qce_crypto_of_match); static struct platform_driver qce_crypto_driver = { .probe = qce_crypto_probe, - .remove = qce_crypto_remove, .driver = { .name = KBUILD_MODNAME, .of_match_table = qce_crypto_of_match, diff --git a/drivers/crypto/qce/core.h b/drivers/crypto/qce/core.h index 228fcd69ec511..39e75a75a4293 100644 --- a/drivers/crypto/qce/core.h +++ b/drivers/crypto/qce/core.h @@ -6,13 +6,15 @@ #ifndef _CORE_H_ #define _CORE_H_ +#include <linux/workqueue.h> + #include "dma.h" /** * struct qce_device - crypto engine device structure * @queue: crypto request queue * @lock: the lock protects queue and req - * @done_tasklet: done tasklet object + * @done_work: workqueue context * @req: current active request * @result: result of current transform * @base: virtual IO base @@ -29,7 +31,7 @@ struct qce_device { struct crypto_queue queue; spinlock_t lock; - struct tasklet_struct done_tasklet; + struct work_struct done_work; struct crypto_async_request *req; int result; void __iomem *base;