drivers/crypto/caam/jr.c | 53 +++++++++++++++++++++++++++++++++------- 1 file changed, 44 insertions(+), 9 deletions(-)
From: Horia Geanta <horia.geanta@nxp.com>
Issues:
- Job ring device is busy when do kexec reboot
- Failed to flush job ring when do system suspend-resume
Fix:
Flush the job ring to stop the running jobs.
Signed-off-by: Horia Geanta <horia.geanta@nxp.com>
Signed-off-by: Franck LENORMAND <franck.lenormand@nxp.com>
---
drivers/crypto/caam/jr.c | 53 +++++++++++++++++++++++++++++++++-------
1 file changed, 44 insertions(+), 9 deletions(-)
diff --git a/drivers/crypto/caam/jr.c b/drivers/crypto/caam/jr.c
index 724fdec18bf9..8745fe3cb575 100644
--- a/drivers/crypto/caam/jr.c
+++ b/drivers/crypto/caam/jr.c
@@ -72,19 +72,27 @@ static void caam_jr_crypto_engine_exit(void *data)
crypto_engine_exit(jrpriv->engine);
}
-static int caam_reset_hw_jr(struct device *dev)
+/*
+ * Put the CAAM in quiesce, ie stop
+ *
+ * Must be called with itr disabled
+ */
+static int caam_jr_stop_processing(struct device *dev, u32 jrcr_bits)
{
struct caam_drv_private_jr *jrp = dev_get_drvdata(dev);
unsigned int timeout = 100000;
- /*
- * mask interrupts since we are going to poll
- * for reset completion status
- */
- clrsetbits_32(&jrp->rregs->rconfig_lo, 0, JRCFG_IMSK);
+ /* Check the current status */
+ if (rd_reg32(&jrp->rregs->jrintstatus) & JRINT_ERR_HALT_INPROGRESS)
+ goto wait_quiesce_completion;
- /* initiate flush (required prior to reset) */
- wr_reg32(&jrp->rregs->jrcommand, JRCR_RESET);
+ /* Reset the field */
+ clrsetbits_32(&jrp->rregs->jrintstatus, JRINT_ERR_HALT_MASK, 0);
+
+ /* initiate flush / park (required prior to reset) */
+ wr_reg32(&jrp->rregs->jrcommand, jrcr_bits);
+
+wait_quiesce_completion:
while (((rd_reg32(&jrp->rregs->jrintstatus) & JRINT_ERR_HALT_MASK) ==
JRINT_ERR_HALT_INPROGRESS) && --timeout)
cpu_relax();
@@ -95,8 +103,35 @@ static int caam_reset_hw_jr(struct device *dev)
return -EIO;
}
+ return 0;
+}
+
+/*
+ * Flush the job ring, so the jobs running will be stopped, jobs queued will be
+ * invalidated and the CAAM will no longer fetch fron input ring.
+ *
+ * Must be called with itr disabled
+ */
+static int caam_jr_flush(struct device *dev)
+{
+ return caam_jr_stop_processing(dev, JRCR_RESET);
+}
+
+static int caam_reset_hw_jr(struct device *dev)
+{
+ struct caam_drv_private_jr *jrp = dev_get_drvdata(dev);
+ unsigned int timeout = 100000;
+ int err;
+ /*
+ * mask interrupts since we are going to poll
+ * for reset completion status
+ */
+ clrsetbits_32(&jrp->rregs->rconfig_lo, 0, JRCFG_IMSK);
+ err = caam_jr_flush(dev);
+ if (err)
+ return err;
+
/* initiate reset */
- timeout = 100000;
wr_reg32(&jrp->rregs->jrcommand, JRCR_RESET);
while ((rd_reg32(&jrp->rregs->jrcommand) & JRCR_RESET) && --timeout)
cpu_relax();
--
2.25.1
From: Gaurav Jain <gaurav.jain@nxp.com>
add .shutdown hook in caam_jr driver to support kexec boot
Signed-off-by: Gaurav Jain <gaurav.jain@nxp.com>
---
drivers/crypto/caam/jr.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/drivers/crypto/caam/jr.c b/drivers/crypto/caam/jr.c
index 8745fe3cb575..a2a99d09b4ad 100644
--- a/drivers/crypto/caam/jr.c
+++ b/drivers/crypto/caam/jr.c
@@ -198,6 +198,11 @@ static int caam_jr_remove(struct platform_device *pdev)
return ret;
}
+static void caam_jr_platform_shutdown(struct platform_device *pdev)
+{
+ caam_jr_remove(pdev);
+}
+
/* Main per-ring interrupt handler */
static irqreturn_t caam_jr_interrupt(int irq, void *st_dev)
{
@@ -653,6 +658,7 @@ static struct platform_driver caam_jr_driver = {
},
.probe = caam_jr_probe,
.remove = caam_jr_remove,
+ .shutdown = caam_jr_platform_shutdown,
};
static int __init jr_driver_init(void)
--
2.25.1
On Tue, Feb 21, 2023 at 11:10:47AM +0530, meenakshi.aggarwal@nxp.com wrote: > > @@ -653,6 +658,7 @@ static struct platform_driver caam_jr_driver = { > }, > .probe = caam_jr_probe, > .remove = caam_jr_remove, > + .shutdown = caam_jr_platform_shutdown, Please make your new addition line up with the rest of the code. Thanks, -- Email: Herbert Xu <herbert@gondor.apana.org.au> Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
On 2/20/2023 9:40 PM, meenakshi.aggarwal@nxp.com wrote: > From: Gaurav Jain <gaurav.jain@nxp.com> > > add .shutdown hook in caam_jr driver to support kexec boot > > Signed-off-by: Gaurav Jain <gaurav.jain@nxp.com> Tested-by: Vijay Balakrishna <vijayb@linux.microsoft.com> Thanks, Vijay > --- > drivers/crypto/caam/jr.c | 6 ++++++ > 1 file changed, 6 insertions(+) > > diff --git a/drivers/crypto/caam/jr.c b/drivers/crypto/caam/jr.c > index 8745fe3cb575..a2a99d09b4ad 100644 > --- a/drivers/crypto/caam/jr.c > +++ b/drivers/crypto/caam/jr.c > @@ -198,6 +198,11 @@ static int caam_jr_remove(struct platform_device *pdev) > return ret; > } > > +static void caam_jr_platform_shutdown(struct platform_device *pdev) > +{ > + caam_jr_remove(pdev); > +} > + > /* Main per-ring interrupt handler */ > static irqreturn_t caam_jr_interrupt(int irq, void *st_dev) > { > @@ -653,6 +658,7 @@ static struct platform_driver caam_jr_driver = { > }, > .probe = caam_jr_probe, > .remove = caam_jr_remove, > + .shutdown = caam_jr_platform_shutdown, > }; > > static int __init jr_driver_init(void)
Change the year in the License header. After changing, you can add the reviewed by me. Reviewed-By: Pankaj Gupta <pankaj.gupta@nxp.com> > -----Original Message----- > From: Vijay Balakrishna <vijayb@linux.microsoft.com> > Sent: Tuesday, February 21, 2023 11:02 PM > To: Meenakshi Aggarwal <meenakshi.aggarwal@nxp.com>; Horia Geanta > <horia.geanta@nxp.com>; Varun Sethi <V.Sethi@nxp.com>; Pankaj Gupta > <pankaj.gupta@nxp.com>; Gaurav Jain <gaurav.jain@nxp.com>; > herbert@gondor.apana.org.au; davem@davemloft.net; linux- > crypto@vger.kernel.org; linux-kernel@vger.kernel.org; Franck Lenormand > <franck.lenormand@nxp.com> > Cc: code@tyhicks.com > Subject: [EXT] Re: [PATCH] drivers: crypto: caam: jr: add .shutdown hook > > Caution: EXT Email > > On 2/20/2023 9:40 PM, meenakshi.aggarwal@nxp.com wrote: > > From: Gaurav Jain <gaurav.jain@nxp.com> > > > > add .shutdown hook in caam_jr driver to support kexec boot > > > > Signed-off-by: Gaurav Jain <gaurav.jain@nxp.com> > > Tested-by: Vijay Balakrishna <vijayb@linux.microsoft.com> > > Thanks, > Vijay > > > --- > > drivers/crypto/caam/jr.c | 6 ++++++ > > 1 file changed, 6 insertions(+) > > > > diff --git a/drivers/crypto/caam/jr.c b/drivers/crypto/caam/jr.c index > > 8745fe3cb575..a2a99d09b4ad 100644 > > --- a/drivers/crypto/caam/jr.c > > +++ b/drivers/crypto/caam/jr.c > > @@ -198,6 +198,11 @@ static int caam_jr_remove(struct platform_device > *pdev) > > return ret; > > } > > > > +static void caam_jr_platform_shutdown(struct platform_device *pdev) { > > + caam_jr_remove(pdev); > > +} > > + > > /* Main per-ring interrupt handler */ > > static irqreturn_t caam_jr_interrupt(int irq, void *st_dev) > > { > > @@ -653,6 +658,7 @@ static struct platform_driver caam_jr_driver = { > > }, > > .probe = caam_jr_probe, > > .remove = caam_jr_remove, > > + .shutdown = caam_jr_platform_shutdown, > > }; > > > > static int __init jr_driver_init(void)
Copyright updated in another patch and sent v2, both patches are modifying same file so no need to make any changes in this patch. > -----Original Message----- > From: Pankaj Gupta <pankaj.gupta@nxp.com> > Sent: Monday, February 27, 2023 1:03 PM > To: Vijay Balakrishna <vijayb@linux.microsoft.com>; Meenakshi Aggarwal > <meenakshi.aggarwal@nxp.com>; Horia Geanta <horia.geanta@nxp.com>; > Varun Sethi <V.Sethi@nxp.com>; Gaurav Jain <gaurav.jain@nxp.com>; > herbert@gondor.apana.org.au; davem@davemloft.net; linux- > crypto@vger.kernel.org; linux-kernel@vger.kernel.org; Franck Lenormand > <franck.lenormand@nxp.com> > Cc: code@tyhicks.com > Subject: RE: [EXT] Re: [PATCH] drivers: crypto: caam: jr: add .shutdown hook > > Change the year in the License header. > > After changing, you can add the reviewed by me. > Reviewed-By: Pankaj Gupta <pankaj.gupta@nxp.com> > > > -----Original Message----- > > From: Vijay Balakrishna <vijayb@linux.microsoft.com> > > Sent: Tuesday, February 21, 2023 11:02 PM > > To: Meenakshi Aggarwal <meenakshi.aggarwal@nxp.com>; Horia Geanta > > <horia.geanta@nxp.com>; Varun Sethi <V.Sethi@nxp.com>; Pankaj Gupta > > <pankaj.gupta@nxp.com>; Gaurav Jain <gaurav.jain@nxp.com>; > > herbert@gondor.apana.org.au; davem@davemloft.net; linux- > > crypto@vger.kernel.org; linux-kernel@vger.kernel.org; Franck Lenormand > > <franck.lenormand@nxp.com> > > Cc: code@tyhicks.com > > Subject: [EXT] Re: [PATCH] drivers: crypto: caam: jr: add .shutdown > > hook > > > > Caution: EXT Email > > > > On 2/20/2023 9:40 PM, meenakshi.aggarwal@nxp.com wrote: > > > From: Gaurav Jain <gaurav.jain@nxp.com> > > > > > > add .shutdown hook in caam_jr driver to support kexec boot > > > > > > Signed-off-by: Gaurav Jain <gaurav.jain@nxp.com> > > > > Tested-by: Vijay Balakrishna <vijayb@linux.microsoft.com> > > > > Thanks, > > Vijay > > > > > --- > > > drivers/crypto/caam/jr.c | 6 ++++++ > > > 1 file changed, 6 insertions(+) > > > > > > diff --git a/drivers/crypto/caam/jr.c b/drivers/crypto/caam/jr.c > > > index 8745fe3cb575..a2a99d09b4ad 100644 > > > --- a/drivers/crypto/caam/jr.c > > > +++ b/drivers/crypto/caam/jr.c > > > @@ -198,6 +198,11 @@ static int caam_jr_remove(struct > > > platform_device > > *pdev) > > > return ret; > > > } > > > > > > +static void caam_jr_platform_shutdown(struct platform_device *pdev) { > > > + caam_jr_remove(pdev); > > > +} > > > + > > > /* Main per-ring interrupt handler */ > > > static irqreturn_t caam_jr_interrupt(int irq, void *st_dev) > > > { > > > @@ -653,6 +658,7 @@ static struct platform_driver caam_jr_driver = { > > > }, > > > .probe = caam_jr_probe, > > > .remove = caam_jr_remove, > > > + .shutdown = caam_jr_platform_shutdown, > > > }; > > > > > > static int __init jr_driver_init(void)
Hi Herbert, If you have no comments then please apply the patch > -----Original Message----- > From: Meenakshi Aggarwal <meenakshi.aggarwal@nxp.com> > Sent: Wednesday, March 1, 2023 11:09 AM > To: Pankaj Gupta <pankaj.gupta@nxp.com>; Vijay Balakrishna > <vijayb@linux.microsoft.com>; Horia Geanta <horia.geanta@nxp.com>; Varun > Sethi <V.Sethi@nxp.com>; Gaurav Jain <gaurav.jain@nxp.com>; > herbert@gondor.apana.org.au; davem@davemloft.net; linux- > crypto@vger.kernel.org; linux-kernel@vger.kernel.org; Franck Lenormand > <franck.lenormand@nxp.com> > Cc: code@tyhicks.com > Subject: RE: [EXT] Re: [PATCH] drivers: crypto: caam: jr: add .shutdown hook > > Copyright updated in another patch and sent v2, both patches are modifying > same file so no need to make any changes in this patch. > > > -----Original Message----- > > From: Pankaj Gupta <pankaj.gupta@nxp.com> > > Sent: Monday, February 27, 2023 1:03 PM > > To: Vijay Balakrishna <vijayb@linux.microsoft.com>; Meenakshi Aggarwal > > <meenakshi.aggarwal@nxp.com>; Horia Geanta <horia.geanta@nxp.com>; > > Varun Sethi <V.Sethi@nxp.com>; Gaurav Jain <gaurav.jain@nxp.com>; > > herbert@gondor.apana.org.au; davem@davemloft.net; linux- > > crypto@vger.kernel.org; linux-kernel@vger.kernel.org; Franck Lenormand > > <franck.lenormand@nxp.com> > > Cc: code@tyhicks.com > > Subject: RE: [EXT] Re: [PATCH] drivers: crypto: caam: jr: add > > .shutdown hook > > > > Change the year in the License header. > > > > After changing, you can add the reviewed by me. > > Reviewed-By: Pankaj Gupta <pankaj.gupta@nxp.com> > > > > > -----Original Message----- > > > From: Vijay Balakrishna <vijayb@linux.microsoft.com> > > > Sent: Tuesday, February 21, 2023 11:02 PM > > > To: Meenakshi Aggarwal <meenakshi.aggarwal@nxp.com>; Horia Geanta > > > <horia.geanta@nxp.com>; Varun Sethi <V.Sethi@nxp.com>; Pankaj Gupta > > > <pankaj.gupta@nxp.com>; Gaurav Jain <gaurav.jain@nxp.com>; > > > herbert@gondor.apana.org.au; davem@davemloft.net; linux- > > > crypto@vger.kernel.org; linux-kernel@vger.kernel.org; Franck > > > Lenormand <franck.lenormand@nxp.com> > > > Cc: code@tyhicks.com > > > Subject: [EXT] Re: [PATCH] drivers: crypto: caam: jr: add .shutdown > > > hook > > > > > > Caution: EXT Email > > > > > > On 2/20/2023 9:40 PM, meenakshi.aggarwal@nxp.com wrote: > > > > From: Gaurav Jain <gaurav.jain@nxp.com> > > > > > > > > add .shutdown hook in caam_jr driver to support kexec boot > > > > > > > > Signed-off-by: Gaurav Jain <gaurav.jain@nxp.com> > > > > > > Tested-by: Vijay Balakrishna <vijayb@linux.microsoft.com> > > > > > > Thanks, > > > Vijay > > > > > > > --- > > > > drivers/crypto/caam/jr.c | 6 ++++++ > > > > 1 file changed, 6 insertions(+) > > > > > > > > diff --git a/drivers/crypto/caam/jr.c b/drivers/crypto/caam/jr.c > > > > index 8745fe3cb575..a2a99d09b4ad 100644 > > > > --- a/drivers/crypto/caam/jr.c > > > > +++ b/drivers/crypto/caam/jr.c > > > > @@ -198,6 +198,11 @@ static int caam_jr_remove(struct > > > > platform_device > > > *pdev) > > > > return ret; > > > > } > > > > > > > > +static void caam_jr_platform_shutdown(struct platform_device *pdev) { > > > > + caam_jr_remove(pdev); > > > > +} > > > > + > > > > /* Main per-ring interrupt handler */ > > > > static irqreturn_t caam_jr_interrupt(int irq, void *st_dev) > > > > { > > > > @@ -653,6 +658,7 @@ static struct platform_driver caam_jr_driver = { > > > > }, > > > > .probe = caam_jr_probe, > > > > .remove = caam_jr_remove, > > > > + .shutdown = caam_jr_platform_shutdown, > > > > }; > > > > > > > > static int __init jr_driver_init(void)
From: Gaurav Jain <gaurav.jain@nxp.com>
add .shutdown hook in caam_jr driver to support kexec boot
Signed-off-by: Gaurav Jain <gaurav.jain@nxp.com>
Tested-by: Vijay Balakrishna <vijayb@linux.microsoft.com>
Reviewed-by: Pankaj Gupta <pankaj.gupta@nxp.com>
---
changes in v2:
- corrected alignment
drivers/crypto/caam/jr.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/drivers/crypto/caam/jr.c b/drivers/crypto/caam/jr.c
index 8745fe3cb575..28aef9ba8eac 100644
--- a/drivers/crypto/caam/jr.c
+++ b/drivers/crypto/caam/jr.c
@@ -198,6 +198,11 @@ static int caam_jr_remove(struct platform_device *pdev)
return ret;
}
+static void caam_jr_platform_shutdown(struct platform_device *pdev)
+{
+ caam_jr_remove(pdev);
+}
+
/* Main per-ring interrupt handler */
static irqreturn_t caam_jr_interrupt(int irq, void *st_dev)
{
@@ -653,6 +658,7 @@ static struct platform_driver caam_jr_driver = {
},
.probe = caam_jr_probe,
.remove = caam_jr_remove,
+ .shutdown = caam_jr_platform_shutdown,
};
static int __init jr_driver_init(void)
--
2.25.1
On Thu, Mar 16, 2023 at 11:37:34AM +0530, meenakshi.aggarwal@nxp.com wrote: > From: Gaurav Jain <gaurav.jain@nxp.com> > > add .shutdown hook in caam_jr driver to support kexec boot > > Signed-off-by: Gaurav Jain <gaurav.jain@nxp.com> > Tested-by: Vijay Balakrishna <vijayb@linux.microsoft.com> > Reviewed-by: Pankaj Gupta <pankaj.gupta@nxp.com> > --- > > changes in v2: > - corrected alignment > > drivers/crypto/caam/jr.c | 6 ++++++ > 1 file changed, 6 insertions(+) Patch applied. Thanks. -- Email: Herbert Xu <herbert@gondor.apana.org.au> Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
From: Gaurav Jain <gaurav.jain@nxp.com>
add .shutdown hook in caam_jr driver to support kexec boot
Signed-off-by: Gaurav Jain <gaurav.jain@nxp.com>
Tested-by: Vijay Balakrishna <vijayb@linux.microsoft.com>
Reviewed-by: Pankaj Gupta <pankaj.gupta@nxp.com>
---
drivers/crypto/caam/jr.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/drivers/crypto/caam/jr.c b/drivers/crypto/caam/jr.c
index 724fdec18bf9..ca5b49ea3821 100644
--- a/drivers/crypto/caam/jr.c
+++ b/drivers/crypto/caam/jr.c
@@ -163,6 +163,11 @@ static int caam_jr_remove(struct platform_device *pdev)
return ret;
}
+static void caam_jr_platform_shutdown(struct platform_device *pdev)
+{
+ caam_jr_remove(pdev);
+}
+
/* Main per-ring interrupt handler */
static irqreturn_t caam_jr_interrupt(int irq, void *st_dev)
{
@@ -618,6 +623,7 @@ static struct platform_driver caam_jr_driver = {
},
.probe = caam_jr_probe,
.remove = caam_jr_remove,
+ .shutdown = caam_jr_platform_shutdown,
};
static int __init jr_driver_init(void)
--
2.25.1
From: Horia Geanta <horia.geanta@nxp.com>
Issues:
- Job ring device is busy when do kexec reboot
- Failed to flush job ring when do system suspend-resume
Fix:
Flush the job ring to stop the running jobs.
Signed-off-by: Horia Geanta <horia.geanta@nxp.com>
Signed-off-by: Franck LENORMAND <franck.lenormand@nxp.com>
---
drivers/crypto/caam/jr.c | 53 +++++++++++++++++++++++++++++++++-------
1 file changed, 44 insertions(+), 9 deletions(-)
diff --git a/drivers/crypto/caam/jr.c b/drivers/crypto/caam/jr.c
index 724fdec18bf9..8745fe3cb575 100644
--- a/drivers/crypto/caam/jr.c
+++ b/drivers/crypto/caam/jr.c
@@ -72,19 +72,27 @@ static void caam_jr_crypto_engine_exit(void *data)
crypto_engine_exit(jrpriv->engine);
}
-static int caam_reset_hw_jr(struct device *dev)
+/*
+ * Put the CAAM in quiesce, ie stop
+ *
+ * Must be called with itr disabled
+ */
+static int caam_jr_stop_processing(struct device *dev, u32 jrcr_bits)
{
struct caam_drv_private_jr *jrp = dev_get_drvdata(dev);
unsigned int timeout = 100000;
- /*
- * mask interrupts since we are going to poll
- * for reset completion status
- */
- clrsetbits_32(&jrp->rregs->rconfig_lo, 0, JRCFG_IMSK);
+ /* Check the current status */
+ if (rd_reg32(&jrp->rregs->jrintstatus) & JRINT_ERR_HALT_INPROGRESS)
+ goto wait_quiesce_completion;
- /* initiate flush (required prior to reset) */
- wr_reg32(&jrp->rregs->jrcommand, JRCR_RESET);
+ /* Reset the field */
+ clrsetbits_32(&jrp->rregs->jrintstatus, JRINT_ERR_HALT_MASK, 0);
+
+ /* initiate flush / park (required prior to reset) */
+ wr_reg32(&jrp->rregs->jrcommand, jrcr_bits);
+
+wait_quiesce_completion:
while (((rd_reg32(&jrp->rregs->jrintstatus) & JRINT_ERR_HALT_MASK) ==
JRINT_ERR_HALT_INPROGRESS) && --timeout)
cpu_relax();
@@ -95,8 +103,35 @@ static int caam_reset_hw_jr(struct device *dev)
return -EIO;
}
+ return 0;
+}
+
+/*
+ * Flush the job ring, so the jobs running will be stopped, jobs queued will be
+ * invalidated and the CAAM will no longer fetch fron input ring.
+ *
+ * Must be called with itr disabled
+ */
+static int caam_jr_flush(struct device *dev)
+{
+ return caam_jr_stop_processing(dev, JRCR_RESET);
+}
+
+static int caam_reset_hw_jr(struct device *dev)
+{
+ struct caam_drv_private_jr *jrp = dev_get_drvdata(dev);
+ unsigned int timeout = 100000;
+ int err;
+ /*
+ * mask interrupts since we are going to poll
+ * for reset completion status
+ */
+ clrsetbits_32(&jrp->rregs->rconfig_lo, 0, JRCFG_IMSK);
+ err = caam_jr_flush(dev);
+ if (err)
+ return err;
+
/* initiate reset */
- timeout = 100000;
wr_reg32(&jrp->rregs->jrcommand, JRCR_RESET);
while ((rd_reg32(&jrp->rregs->jrcommand) & JRCR_RESET) && --timeout)
cpu_relax();
--
2.25.1
On 2/20/2023 9:42 PM, meenakshi.aggarwal@nxp.com wrote: > From: Horia Geanta <horia.geanta@nxp.com> > > Issues: > - Job ring device is busy when do kexec reboot > - Failed to flush job ring when do system suspend-resume > > Fix: > Flush the job ring to stop the running jobs. > > Signed-off-by: Horia Geanta <horia.geanta@nxp.com> > Signed-off-by: Franck LENORMAND <franck.lenormand@nxp.com> Tested-by: Vijay Balakrishna <vijayb@linux.microsoft.com> Thanks, Vijay > --- > drivers/crypto/caam/jr.c | 53 +++++++++++++++++++++++++++++++++------- > 1 file changed, 44 insertions(+), 9 deletions(-) > > diff --git a/drivers/crypto/caam/jr.c b/drivers/crypto/caam/jr.c > index 724fdec18bf9..8745fe3cb575 100644 > --- a/drivers/crypto/caam/jr.c > +++ b/drivers/crypto/caam/jr.c > @@ -72,19 +72,27 @@ static void caam_jr_crypto_engine_exit(void *data) > crypto_engine_exit(jrpriv->engine); > } > > -static int caam_reset_hw_jr(struct device *dev) > +/* > + * Put the CAAM in quiesce, ie stop > + * > + * Must be called with itr disabled > + */ > +static int caam_jr_stop_processing(struct device *dev, u32 jrcr_bits) > { > struct caam_drv_private_jr *jrp = dev_get_drvdata(dev); > unsigned int timeout = 100000; > > - /* > - * mask interrupts since we are going to poll > - * for reset completion status > - */ > - clrsetbits_32(&jrp->rregs->rconfig_lo, 0, JRCFG_IMSK); > + /* Check the current status */ > + if (rd_reg32(&jrp->rregs->jrintstatus) & JRINT_ERR_HALT_INPROGRESS) > + goto wait_quiesce_completion; > > - /* initiate flush (required prior to reset) */ > - wr_reg32(&jrp->rregs->jrcommand, JRCR_RESET); > + /* Reset the field */ > + clrsetbits_32(&jrp->rregs->jrintstatus, JRINT_ERR_HALT_MASK, 0); > + > + /* initiate flush / park (required prior to reset) */ > + wr_reg32(&jrp->rregs->jrcommand, jrcr_bits); > + > +wait_quiesce_completion: > while (((rd_reg32(&jrp->rregs->jrintstatus) & JRINT_ERR_HALT_MASK) == > JRINT_ERR_HALT_INPROGRESS) && --timeout) > cpu_relax(); > @@ -95,8 +103,35 @@ static int caam_reset_hw_jr(struct device *dev) > return -EIO; > } > > + return 0; > +} > + > +/* > + * Flush the job ring, so the jobs running will be stopped, jobs queued will be > + * invalidated and the CAAM will no longer fetch fron input ring. > + * > + * Must be called with itr disabled > + */ > +static int caam_jr_flush(struct device *dev) > +{ > + return caam_jr_stop_processing(dev, JRCR_RESET); > +} > + > +static int caam_reset_hw_jr(struct device *dev) > +{ > + struct caam_drv_private_jr *jrp = dev_get_drvdata(dev); > + unsigned int timeout = 100000; > + int err; > + /* > + * mask interrupts since we are going to poll > + * for reset completion status > + */ > + clrsetbits_32(&jrp->rregs->rconfig_lo, 0, JRCFG_IMSK); > + err = caam_jr_flush(dev); > + if (err) > + return err; > + > /* initiate reset */ > - timeout = 100000; > wr_reg32(&jrp->rregs->jrcommand, JRCR_RESET); > while ((rd_reg32(&jrp->rregs->jrcommand) & JRCR_RESET) && --timeout) > cpu_relax();
Change the year in the License header. After changing, you can add the reviewed by me. Reviewed-By: Pankaj Gupta <pankaj.gupta@nxp.com> > -----Original Message----- > From: Vijay Balakrishna <vijayb@linux.microsoft.com> > Sent: Tuesday, February 21, 2023 11:03 PM > To: Meenakshi Aggarwal <meenakshi.aggarwal@nxp.com>; Horia Geanta > <horia.geanta@nxp.com>; Varun Sethi <V.Sethi@nxp.com>; Pankaj Gupta > <pankaj.gupta@nxp.com>; Gaurav Jain <gaurav.jain@nxp.com>; > herbert@gondor.apana.org.au; davem@davemloft.net; linux- > crypto@vger.kernel.org; linux-kernel@vger.kernel.org; Franck Lenormand > <franck.lenormand@nxp.com> > Cc: code@tyhicks.com > Subject: [EXT] Re: [PATCH] drivers: crypto: caam: jr: Allow quiesce when > quiesced > > Caution: EXT Email > > On 2/20/2023 9:42 PM, meenakshi.aggarwal@nxp.com wrote: > > From: Horia Geanta <horia.geanta@nxp.com> > > > > Issues: > > - Job ring device is busy when do kexec reboot > > - Failed to flush job ring when do system suspend-resume > > > > Fix: > > Flush the job ring to stop the running jobs. > > > > Signed-off-by: Horia Geanta <horia.geanta@nxp.com> > > Signed-off-by: Franck LENORMAND <franck.lenormand@nxp.com> > > Tested-by: Vijay Balakrishna <vijayb@linux.microsoft.com> > > Thanks, > Vijay > > > > --- > > drivers/crypto/caam/jr.c | 53 +++++++++++++++++++++++++++++++++- > ------ > > 1 file changed, 44 insertions(+), 9 deletions(-) > > > > diff --git a/drivers/crypto/caam/jr.c b/drivers/crypto/caam/jr.c index > > 724fdec18bf9..8745fe3cb575 100644 > > --- a/drivers/crypto/caam/jr.c > > +++ b/drivers/crypto/caam/jr.c > > @@ -72,19 +72,27 @@ static void caam_jr_crypto_engine_exit(void *data) > > crypto_engine_exit(jrpriv->engine); > > } > > > > -static int caam_reset_hw_jr(struct device *dev) > > +/* > > + * Put the CAAM in quiesce, ie stop > > + * > > + * Must be called with itr disabled > > + */ > > +static int caam_jr_stop_processing(struct device *dev, u32 jrcr_bits) > > { > > struct caam_drv_private_jr *jrp = dev_get_drvdata(dev); > > unsigned int timeout = 100000; > > > > - /* > > - * mask interrupts since we are going to poll > > - * for reset completion status > > - */ > > - clrsetbits_32(&jrp->rregs->rconfig_lo, 0, JRCFG_IMSK); > > + /* Check the current status */ > > + if (rd_reg32(&jrp->rregs->jrintstatus) & JRINT_ERR_HALT_INPROGRESS) > > + goto wait_quiesce_completion; > > > > - /* initiate flush (required prior to reset) */ > > - wr_reg32(&jrp->rregs->jrcommand, JRCR_RESET); > > + /* Reset the field */ > > + clrsetbits_32(&jrp->rregs->jrintstatus, JRINT_ERR_HALT_MASK, 0); > > + > > + /* initiate flush / park (required prior to reset) */ > > + wr_reg32(&jrp->rregs->jrcommand, jrcr_bits); > > + > > +wait_quiesce_completion: > > while (((rd_reg32(&jrp->rregs->jrintstatus) & JRINT_ERR_HALT_MASK) > == > > JRINT_ERR_HALT_INPROGRESS) && --timeout) > > cpu_relax(); > > @@ -95,8 +103,35 @@ static int caam_reset_hw_jr(struct device *dev) > > return -EIO; > > } > > > > + return 0; > > +} > > + > > +/* > > + * Flush the job ring, so the jobs running will be stopped, jobs > > +queued will be > > + * invalidated and the CAAM will no longer fetch fron input ring. > > + * > > + * Must be called with itr disabled > > + */ > > +static int caam_jr_flush(struct device *dev) { > > + return caam_jr_stop_processing(dev, JRCR_RESET); } > > + > > +static int caam_reset_hw_jr(struct device *dev) { > > + struct caam_drv_private_jr *jrp = dev_get_drvdata(dev); > > + unsigned int timeout = 100000; > > + int err; > > + /* > > + * mask interrupts since we are going to poll > > + * for reset completion status > > + */ > > + clrsetbits_32(&jrp->rregs->rconfig_lo, 0, JRCFG_IMSK); > > + err = caam_jr_flush(dev); > > + if (err) > > + return err; > > + > > /* initiate reset */ > > - timeout = 100000; > > wr_reg32(&jrp->rregs->jrcommand, JRCR_RESET); > > while ((rd_reg32(&jrp->rregs->jrcommand) & JRCR_RESET) && -- > timeout) > > cpu_relax();
From: Horia Geanta <horia.geanta@nxp.com>
Issues:
- Job ring device is busy when do kexec reboot
- Failed to flush job ring when do system suspend-resume
Fix:
Flush the job ring to stop the running jobs.
Signed-off-by: Horia Geanta <horia.geanta@nxp.com>
Signed-off-by: Franck LENORMAND <franck.lenormand@nxp.com>
Reviewed-by: Pankaj Gupta <pankaj.gupta@nxp.com>
---
drivers/crypto/caam/jr.c | 55 ++++++++++++++++++++++++++++++++--------
1 file changed, 45 insertions(+), 10 deletions(-)
diff --git a/drivers/crypto/caam/jr.c b/drivers/crypto/caam/jr.c
index 724fdec18bf9..eb3b9a7e9a35 100644
--- a/drivers/crypto/caam/jr.c
+++ b/drivers/crypto/caam/jr.c
@@ -4,7 +4,7 @@
* JobR backend functionality
*
* Copyright 2008-2012 Freescale Semiconductor, Inc.
- * Copyright 2019 NXP
+ * Copyright 2019, 2023 NXP
*/
#include <linux/of_irq.h>
@@ -72,19 +72,27 @@ static void caam_jr_crypto_engine_exit(void *data)
crypto_engine_exit(jrpriv->engine);
}
-static int caam_reset_hw_jr(struct device *dev)
+/*
+ * Put the CAAM in quiesce, ie stop
+ *
+ * Must be called with itr disabled
+ */
+static int caam_jr_stop_processing(struct device *dev, u32 jrcr_bits)
{
struct caam_drv_private_jr *jrp = dev_get_drvdata(dev);
unsigned int timeout = 100000;
- /*
- * mask interrupts since we are going to poll
- * for reset completion status
- */
- clrsetbits_32(&jrp->rregs->rconfig_lo, 0, JRCFG_IMSK);
+ /* Check the current status */
+ if (rd_reg32(&jrp->rregs->jrintstatus) & JRINT_ERR_HALT_INPROGRESS)
+ goto wait_quiesce_completion;
- /* initiate flush (required prior to reset) */
- wr_reg32(&jrp->rregs->jrcommand, JRCR_RESET);
+ /* Reset the field */
+ clrsetbits_32(&jrp->rregs->jrintstatus, JRINT_ERR_HALT_MASK, 0);
+
+ /* initiate flush / park (required prior to reset) */
+ wr_reg32(&jrp->rregs->jrcommand, jrcr_bits);
+
+wait_quiesce_completion:
while (((rd_reg32(&jrp->rregs->jrintstatus) & JRINT_ERR_HALT_MASK) ==
JRINT_ERR_HALT_INPROGRESS) && --timeout)
cpu_relax();
@@ -95,8 +103,35 @@ static int caam_reset_hw_jr(struct device *dev)
return -EIO;
}
+ return 0;
+}
+
+/*
+ * Flush the job ring, so the jobs running will be stopped, jobs queued will be
+ * invalidated and the CAAM will no longer fetch fron input ring.
+ *
+ * Must be called with itr disabled
+ */
+static int caam_jr_flush(struct device *dev)
+{
+ return caam_jr_stop_processing(dev, JRCR_RESET);
+}
+
+static int caam_reset_hw_jr(struct device *dev)
+{
+ struct caam_drv_private_jr *jrp = dev_get_drvdata(dev);
+ unsigned int timeout = 100000;
+ int err;
+ /*
+ * mask interrupts since we are going to poll
+ * for reset completion status
+ */
+ clrsetbits_32(&jrp->rregs->rconfig_lo, 0, JRCFG_IMSK);
+ err = caam_jr_flush(dev);
+ if (err)
+ return err;
+
/* initiate reset */
- timeout = 100000;
wr_reg32(&jrp->rregs->jrcommand, JRCR_RESET);
while ((rd_reg32(&jrp->rregs->jrcommand) & JRCR_RESET) && --timeout)
cpu_relax();
--
2.25.1
On Wed, Mar 01, 2023 at 12:07:58AM +0530, meenakshi.aggarwal@nxp.com wrote: > From: Horia Geanta <horia.geanta@nxp.com> > > Issues: > - Job ring device is busy when do kexec reboot > - Failed to flush job ring when do system suspend-resume > > Fix: > Flush the job ring to stop the running jobs. > > Signed-off-by: Horia Geanta <horia.geanta@nxp.com> > Signed-off-by: Franck LENORMAND <franck.lenormand@nxp.com> > Reviewed-by: Pankaj Gupta <pankaj.gupta@nxp.com> > --- > drivers/crypto/caam/jr.c | 55 ++++++++++++++++++++++++++++++++-------- > 1 file changed, 45 insertions(+), 10 deletions(-) Patch applied. Thanks. -- Email: Herbert Xu <herbert@gondor.apana.org.au> Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
Hi Herbert, Please apply the patch if you have no comments. Thanks, Meenakshi > -----Original Message----- > From: meenakshi.aggarwal@nxp.com <meenakshi.aggarwal@nxp.com> > Sent: Wednesday, March 1, 2023 12:08 AM > To: Horia Geanta <horia.geanta@nxp.com>; Varun Sethi <V.Sethi@nxp.com>; > Pankaj Gupta <pankaj.gupta@nxp.com>; Gaurav Jain <gaurav.jain@nxp.com>; > herbert@gondor.apana.org.au; davem@davemloft.net; linux- > crypto@vger.kernel.org; linux-kernel@vger.kernel.org; Franck Lenormand > <franck.lenormand@nxp.com> > Cc: vijayb@linux.microsoft.com; code@tyhicks.com > Subject: [PATCH] drivers: crypto: caam: jr: Allow quiesce when quiesced > > From: Horia Geanta <horia.geanta@nxp.com> > > Issues: > - Job ring device is busy when do kexec reboot > - Failed to flush job ring when do system suspend-resume > > Fix: > Flush the job ring to stop the running jobs. > > Signed-off-by: Horia Geanta <horia.geanta@nxp.com> > Signed-off-by: Franck LENORMAND <franck.lenormand@nxp.com> > Reviewed-by: Pankaj Gupta <pankaj.gupta@nxp.com> > --- > drivers/crypto/caam/jr.c | 55 ++++++++++++++++++++++++++++++++-------- > 1 file changed, 45 insertions(+), 10 deletions(-) > > diff --git a/drivers/crypto/caam/jr.c b/drivers/crypto/caam/jr.c index > 724fdec18bf9..eb3b9a7e9a35 100644 > --- a/drivers/crypto/caam/jr.c > +++ b/drivers/crypto/caam/jr.c > @@ -4,7 +4,7 @@ > * JobR backend functionality > * > * Copyright 2008-2012 Freescale Semiconductor, Inc. > - * Copyright 2019 NXP > + * Copyright 2019, 2023 NXP > */ > > #include <linux/of_irq.h> > @@ -72,19 +72,27 @@ static void caam_jr_crypto_engine_exit(void *data) > crypto_engine_exit(jrpriv->engine); > } > > -static int caam_reset_hw_jr(struct device *dev) > +/* > + * Put the CAAM in quiesce, ie stop > + * > + * Must be called with itr disabled > + */ > +static int caam_jr_stop_processing(struct device *dev, u32 jrcr_bits) > { > struct caam_drv_private_jr *jrp = dev_get_drvdata(dev); > unsigned int timeout = 100000; > > - /* > - * mask interrupts since we are going to poll > - * for reset completion status > - */ > - clrsetbits_32(&jrp->rregs->rconfig_lo, 0, JRCFG_IMSK); > + /* Check the current status */ > + if (rd_reg32(&jrp->rregs->jrintstatus) & JRINT_ERR_HALT_INPROGRESS) > + goto wait_quiesce_completion; > > - /* initiate flush (required prior to reset) */ > - wr_reg32(&jrp->rregs->jrcommand, JRCR_RESET); > + /* Reset the field */ > + clrsetbits_32(&jrp->rregs->jrintstatus, JRINT_ERR_HALT_MASK, 0); > + > + /* initiate flush / park (required prior to reset) */ > + wr_reg32(&jrp->rregs->jrcommand, jrcr_bits); > + > +wait_quiesce_completion: > while (((rd_reg32(&jrp->rregs->jrintstatus) & JRINT_ERR_HALT_MASK) > == > JRINT_ERR_HALT_INPROGRESS) && --timeout) > cpu_relax(); > @@ -95,8 +103,35 @@ static int caam_reset_hw_jr(struct device *dev) > return -EIO; > } > > + return 0; > +} > + > +/* > + * Flush the job ring, so the jobs running will be stopped, jobs queued > +will be > + * invalidated and the CAAM will no longer fetch fron input ring. > + * > + * Must be called with itr disabled > + */ > +static int caam_jr_flush(struct device *dev) { > + return caam_jr_stop_processing(dev, JRCR_RESET); } > + > +static int caam_reset_hw_jr(struct device *dev) { > + struct caam_drv_private_jr *jrp = dev_get_drvdata(dev); > + unsigned int timeout = 100000; > + int err; > + /* > + * mask interrupts since we are going to poll > + * for reset completion status > + */ > + clrsetbits_32(&jrp->rregs->rconfig_lo, 0, JRCFG_IMSK); > + err = caam_jr_flush(dev); > + if (err) > + return err; > + > /* initiate reset */ > - timeout = 100000; > wr_reg32(&jrp->rregs->jrcommand, JRCR_RESET); > while ((rd_reg32(&jrp->rregs->jrcommand) & JRCR_RESET) && --timeout) > cpu_relax(); > -- > 2.25.1
© 2016 - 2025 Red Hat, Inc.