* [PATCH] drivers: crypto: caam: jr: Allow quiesce when quiesced @ 2023-02-20 10:50 meenakshi.aggarwal 2023-02-21 5:40 ` [PATCH] drivers: crypto: caam: jr: add .shutdown hook meenakshi.aggarwal 2023-02-21 5:42 ` [PATCH] drivers: crypto: caam: jr: Allow quiesce when quiesced meenakshi.aggarwal 0 siblings, 2 replies; 16+ messages in thread From: meenakshi.aggarwal @ 2023-02-20 10:50 UTC (permalink / raw) To: horia.geanta, V.sethi, pankaj.gupta, gaurav.jain, herbert, davem, VIJAY.BALAKRISHNA, Tyler.Hicks, linux-crypto, linux-kernel, franck.lenormand Cc: linux-imx 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 ^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH] drivers: crypto: caam: jr: add .shutdown hook 2023-02-20 10:50 [PATCH] drivers: crypto: caam: jr: Allow quiesce when quiesced meenakshi.aggarwal @ 2023-02-21 5:40 ` meenakshi.aggarwal 2023-02-21 17:32 ` Vijay Balakrishna ` (3 more replies) 2023-02-21 5:42 ` [PATCH] drivers: crypto: caam: jr: Allow quiesce when quiesced meenakshi.aggarwal 1 sibling, 4 replies; 16+ messages in thread From: meenakshi.aggarwal @ 2023-02-21 5:40 UTC (permalink / raw) To: horia.geanta, V.sethi, pankaj.gupta, gaurav.jain, herbert, davem, linux-crypto, linux-kernel, franck.lenormand Cc: vijayb, code 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 ^ permalink raw reply related [flat|nested] 16+ messages in thread
* Re: [PATCH] drivers: crypto: caam: jr: add .shutdown hook 2023-02-21 5:40 ` [PATCH] drivers: crypto: caam: jr: add .shutdown hook meenakshi.aggarwal @ 2023-02-21 17:32 ` Vijay Balakrishna 2023-02-27 7:32 ` [EXT] " Pankaj Gupta 2023-03-10 10:53 ` Herbert Xu ` (2 subsequent siblings) 3 siblings, 1 reply; 16+ messages in thread From: Vijay Balakrishna @ 2023-02-21 17:32 UTC (permalink / raw) To: meenakshi.aggarwal, horia.geanta, V.sethi, pankaj.gupta, gaurav.jain, herbert, davem, linux-crypto, linux-kernel, franck.lenormand Cc: code 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) ^ permalink raw reply [flat|nested] 16+ messages in thread
* RE: [EXT] Re: [PATCH] drivers: crypto: caam: jr: add .shutdown hook 2023-02-21 17:32 ` Vijay Balakrishna @ 2023-02-27 7:32 ` Pankaj Gupta 2023-03-01 5:39 ` Meenakshi Aggarwal 0 siblings, 1 reply; 16+ messages in thread From: Pankaj Gupta @ 2023-02-27 7:32 UTC (permalink / raw) To: Vijay Balakrishna, Meenakshi Aggarwal, Horia Geanta, Varun Sethi, Gaurav Jain, herbert@gondor.apana.org.au, davem@davemloft.net, linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org, Franck Lenormand Cc: code@tyhicks.com 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) ^ permalink raw reply [flat|nested] 16+ messages in thread
* RE: [EXT] Re: [PATCH] drivers: crypto: caam: jr: add .shutdown hook 2023-02-27 7:32 ` [EXT] " Pankaj Gupta @ 2023-03-01 5:39 ` Meenakshi Aggarwal 2023-03-10 10:33 ` Meenakshi Aggarwal 0 siblings, 1 reply; 16+ messages in thread From: Meenakshi Aggarwal @ 2023-03-01 5:39 UTC (permalink / raw) To: Pankaj Gupta, Vijay Balakrishna, Horia Geanta, Varun Sethi, Gaurav Jain, herbert@gondor.apana.org.au, davem@davemloft.net, linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org, Franck Lenormand Cc: code@tyhicks.com 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) ^ permalink raw reply [flat|nested] 16+ messages in thread
* RE: [EXT] Re: [PATCH] drivers: crypto: caam: jr: add .shutdown hook 2023-03-01 5:39 ` Meenakshi Aggarwal @ 2023-03-10 10:33 ` Meenakshi Aggarwal 0 siblings, 0 replies; 16+ messages in thread From: Meenakshi Aggarwal @ 2023-03-10 10:33 UTC (permalink / raw) To: Meenakshi Aggarwal, Pankaj Gupta, Vijay Balakrishna, Horia Geanta, Varun Sethi, Gaurav Jain, herbert@gondor.apana.org.au, davem@davemloft.net, linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org, Franck Lenormand Cc: code@tyhicks.com 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) ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH] drivers: crypto: caam: jr: add .shutdown hook 2023-02-21 5:40 ` [PATCH] drivers: crypto: caam: jr: add .shutdown hook meenakshi.aggarwal 2023-02-21 17:32 ` Vijay Balakrishna @ 2023-03-10 10:53 ` Herbert Xu 2023-03-11 8:25 ` meenakshi.aggarwal 2023-03-16 6:07 ` [PATCH v2] " meenakshi.aggarwal 3 siblings, 0 replies; 16+ messages in thread From: Herbert Xu @ 2023-03-10 10:53 UTC (permalink / raw) To: meenakshi.aggarwal Cc: horia.geanta, V.sethi, pankaj.gupta, gaurav.jain, davem, linux-crypto, linux-kernel, franck.lenormand, vijayb, code 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 ^ permalink raw reply [flat|nested] 16+ messages in thread
* [PATCH] drivers: crypto: caam: jr: add .shutdown hook 2023-02-21 5:40 ` [PATCH] drivers: crypto: caam: jr: add .shutdown hook meenakshi.aggarwal 2023-02-21 17:32 ` Vijay Balakrishna 2023-03-10 10:53 ` Herbert Xu @ 2023-03-11 8:25 ` meenakshi.aggarwal 2023-03-16 6:07 ` [PATCH v2] " meenakshi.aggarwal 3 siblings, 0 replies; 16+ messages in thread From: meenakshi.aggarwal @ 2023-03-11 8:25 UTC (permalink / raw) To: horia.geanta, V.sethi, pankaj.gupta, gaurav.jain, herbert, davem, linux-crypto, linux-kernel, franck.lenormand Cc: vijayb, code 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 ^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH v2] drivers: crypto: caam: jr: add .shutdown hook 2023-02-21 5:40 ` [PATCH] drivers: crypto: caam: jr: add .shutdown hook meenakshi.aggarwal ` (2 preceding siblings ...) 2023-03-11 8:25 ` meenakshi.aggarwal @ 2023-03-16 6:07 ` meenakshi.aggarwal 2023-03-24 10:29 ` Herbert Xu 3 siblings, 1 reply; 16+ messages in thread From: meenakshi.aggarwal @ 2023-03-16 6:07 UTC (permalink / raw) To: horia.geanta, V.sethi, pankaj.gupta, gaurav.jain, herbert, davem, linux-crypto, linux-kernel, franck.lenormand Cc: vijayb, code 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 ^ permalink raw reply related [flat|nested] 16+ messages in thread
* Re: [PATCH v2] drivers: crypto: caam: jr: add .shutdown hook 2023-03-16 6:07 ` [PATCH v2] " meenakshi.aggarwal @ 2023-03-24 10:29 ` Herbert Xu 0 siblings, 0 replies; 16+ messages in thread From: Herbert Xu @ 2023-03-24 10:29 UTC (permalink / raw) To: meenakshi.aggarwal Cc: horia.geanta, V.sethi, pankaj.gupta, gaurav.jain, davem, linux-crypto, linux-kernel, franck.lenormand, vijayb, code 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 ^ permalink raw reply [flat|nested] 16+ messages in thread
* [PATCH] drivers: crypto: caam: jr: Allow quiesce when quiesced 2023-02-20 10:50 [PATCH] drivers: crypto: caam: jr: Allow quiesce when quiesced meenakshi.aggarwal 2023-02-21 5:40 ` [PATCH] drivers: crypto: caam: jr: add .shutdown hook meenakshi.aggarwal @ 2023-02-21 5:42 ` meenakshi.aggarwal 2023-02-21 17:33 ` Vijay Balakrishna 2023-02-28 18:37 ` meenakshi.aggarwal 1 sibling, 2 replies; 16+ messages in thread From: meenakshi.aggarwal @ 2023-02-21 5:42 UTC (permalink / raw) To: horia.geanta, V.sethi, pankaj.gupta, gaurav.jain, herbert, davem, linux-crypto, linux-kernel, franck.lenormand Cc: vijayb, code 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 ^ permalink raw reply related [flat|nested] 16+ messages in thread
* Re: [PATCH] drivers: crypto: caam: jr: Allow quiesce when quiesced 2023-02-21 5:42 ` [PATCH] drivers: crypto: caam: jr: Allow quiesce when quiesced meenakshi.aggarwal @ 2023-02-21 17:33 ` Vijay Balakrishna 2023-02-27 7:32 ` [EXT] " Pankaj Gupta 2023-02-28 18:37 ` meenakshi.aggarwal 1 sibling, 1 reply; 16+ messages in thread From: Vijay Balakrishna @ 2023-02-21 17:33 UTC (permalink / raw) To: meenakshi.aggarwal, horia.geanta, V.sethi, pankaj.gupta, gaurav.jain, herbert, davem, linux-crypto, linux-kernel, franck.lenormand Cc: code 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(); ^ permalink raw reply [flat|nested] 16+ messages in thread
* RE: [EXT] Re: [PATCH] drivers: crypto: caam: jr: Allow quiesce when quiesced 2023-02-21 17:33 ` Vijay Balakrishna @ 2023-02-27 7:32 ` Pankaj Gupta 0 siblings, 0 replies; 16+ messages in thread From: Pankaj Gupta @ 2023-02-27 7:32 UTC (permalink / raw) To: Vijay Balakrishna, Meenakshi Aggarwal, Horia Geanta, Varun Sethi, Gaurav Jain, herbert@gondor.apana.org.au, davem@davemloft.net, linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org, Franck Lenormand Cc: code@tyhicks.com 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(); ^ permalink raw reply [flat|nested] 16+ messages in thread
* [PATCH] drivers: crypto: caam: jr: Allow quiesce when quiesced 2023-02-21 5:42 ` [PATCH] drivers: crypto: caam: jr: Allow quiesce when quiesced meenakshi.aggarwal 2023-02-21 17:33 ` Vijay Balakrishna @ 2023-02-28 18:37 ` meenakshi.aggarwal 2023-03-10 10:34 ` Meenakshi Aggarwal 2023-03-10 11:32 ` Herbert Xu 1 sibling, 2 replies; 16+ messages in thread From: meenakshi.aggarwal @ 2023-02-28 18:37 UTC (permalink / raw) To: horia.geanta, V.sethi, pankaj.gupta, gaurav.jain, herbert, davem, linux-crypto, linux-kernel, franck.lenormand Cc: vijayb, code 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 ^ permalink raw reply related [flat|nested] 16+ messages in thread
* RE: [PATCH] drivers: crypto: caam: jr: Allow quiesce when quiesced 2023-02-28 18:37 ` meenakshi.aggarwal @ 2023-03-10 10:34 ` Meenakshi Aggarwal 2023-03-10 11:32 ` Herbert Xu 1 sibling, 0 replies; 16+ messages in thread From: Meenakshi Aggarwal @ 2023-03-10 10:34 UTC (permalink / raw) To: Meenakshi Aggarwal, Horia Geanta, Varun Sethi, Pankaj Gupta, Gaurav Jain, herbert@gondor.apana.org.au, davem@davemloft.net, linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org, Franck Lenormand Cc: vijayb@linux.microsoft.com, code@tyhicks.com 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 ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH] drivers: crypto: caam: jr: Allow quiesce when quiesced 2023-02-28 18:37 ` meenakshi.aggarwal 2023-03-10 10:34 ` Meenakshi Aggarwal @ 2023-03-10 11:32 ` Herbert Xu 1 sibling, 0 replies; 16+ messages in thread From: Herbert Xu @ 2023-03-10 11:32 UTC (permalink / raw) To: meenakshi.aggarwal Cc: horia.geanta, V.sethi, pankaj.gupta, gaurav.jain, davem, linux-crypto, linux-kernel, franck.lenormand, vijayb, code 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 ^ permalink raw reply [flat|nested] 16+ messages in thread
end of thread, other threads:[~2023-03-24 10:29 UTC | newest] Thread overview: 16+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2023-02-20 10:50 [PATCH] drivers: crypto: caam: jr: Allow quiesce when quiesced meenakshi.aggarwal 2023-02-21 5:40 ` [PATCH] drivers: crypto: caam: jr: add .shutdown hook meenakshi.aggarwal 2023-02-21 17:32 ` Vijay Balakrishna 2023-02-27 7:32 ` [EXT] " Pankaj Gupta 2023-03-01 5:39 ` Meenakshi Aggarwal 2023-03-10 10:33 ` Meenakshi Aggarwal 2023-03-10 10:53 ` Herbert Xu 2023-03-11 8:25 ` meenakshi.aggarwal 2023-03-16 6:07 ` [PATCH v2] " meenakshi.aggarwal 2023-03-24 10:29 ` Herbert Xu 2023-02-21 5:42 ` [PATCH] drivers: crypto: caam: jr: Allow quiesce when quiesced meenakshi.aggarwal 2023-02-21 17:33 ` Vijay Balakrishna 2023-02-27 7:32 ` [EXT] " Pankaj Gupta 2023-02-28 18:37 ` meenakshi.aggarwal 2023-03-10 10:34 ` Meenakshi Aggarwal 2023-03-10 11:32 ` Herbert Xu
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox