2013-01-10 11:08:33

by Vakul Garg

[permalink] [raw]
Subject: [PATCH] crypto: caam - fix job ring cleanup code

The job ring init function creates a platform device for each job ring.
While the job ring is shutdown, e.g. while module removal, its platform
device was not being removed. This lead to failure while reinserting
caam module again. Same problem appears while platform device for caam
is bound, unbound and then bound again to caam platform driver.

Signed-off-by: Vakul Garg <[email protected]>
Signed-off-by: Bharat Bhushan <[email protected]>
---
drivers/crypto/caam/intern.h | 1 +
drivers/crypto/caam/jr.c | 4 ++++
2 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/drivers/crypto/caam/intern.h b/drivers/crypto/caam/intern.h
index 5cd4c1b..e4a16b7 100644
--- a/drivers/crypto/caam/intern.h
+++ b/drivers/crypto/caam/intern.h
@@ -41,6 +41,7 @@ struct caam_jrentry_info {
/* Private sub-storage for a single JobR */
struct caam_drv_private_jr {
struct device *parentdev; /* points back to controller dev */
+ struct platform_device *jr_pdev;/* points to platform device for JR */
int ridx;
struct caam_job_ring __iomem *rregs; /* JobR's register space */
struct tasklet_struct irqtask;
diff --git a/drivers/crypto/caam/jr.c b/drivers/crypto/caam/jr.c
index 93d1407..b4aa773e 100644
--- a/drivers/crypto/caam/jr.c
+++ b/drivers/crypto/caam/jr.c
@@ -407,6 +407,7 @@ int caam_jr_shutdown(struct device *dev)
dma_free_coherent(dev, sizeof(struct jr_outentry) * JOBR_DEPTH,
jrp->outring, outbusaddr);
kfree(jrp->entinfo);
+ of_device_unregister(jrp->jr_pdev);

return ret;
}
@@ -454,6 +455,8 @@ int caam_jr_probe(struct platform_device *pdev, struct device_node *np,
kfree(jrpriv);
return -EINVAL;
}
+
+ jrpriv->jr_pdev = jr_pdev;
jrdev = &jr_pdev->dev;
dev_set_drvdata(jrdev, jrpriv);
ctrlpriv->jrdev[ring] = jrdev;
@@ -472,6 +475,7 @@ int caam_jr_probe(struct platform_device *pdev, struct device_node *np,
/* Now do the platform independent part */
error = caam_jr_init(jrdev); /* now turn on hardware */
if (error) {
+ of_device_unregister(jr_pdev);
kfree(jrpriv);
return error;
}
--
1.7.7


2013-02-27 16:07:57

by Horia Geantă

[permalink] [raw]
Subject: Re: [PATCH] crypto: caam - fix job ring cleanup code

On 1/10/2013 1:06 PM, Vakul Garg wrote:
> The job ring init function creates a platform device for each job ring.
> While the job ring is shutdown, e.g. while module removal, its platform
> device was not being removed. This lead to failure while reinserting
> caam module again. Same problem appears while platform device for caam
> is bound, unbound and then bound again to caam platform driver.
>
> Signed-off-by: Vakul Garg <[email protected]>
> Signed-off-by: Bharat Bhushan <[email protected]>

Not sure I understand the commit message. You seem to explain there are
two problems, but I see only one: caam module being reinserted.

I guess a stack traceback in the commit message wouldn't hurt.

Regards,
Horia