diff mbox series

[v2,15/17] crypto: qce: Defer probing if BAM dma is not yet initialized

Message ID 20210505213731.538612-16-bhupesh.sharma@linaro.org
State New
Headers show
Series Enable Qualcomm Crypto Engine on sm8250 | expand

Commit Message

Bhupesh Sharma May 5, 2021, 9:37 p.m. UTC
Since the Qualcomm qce crypto driver needs the BAM dma driver to be
setup first (to allow crypto operations), it makes sense to defer
the qce crypto driver probing in case the BAM dma driver is not yet
probed.

This fixes the qce probe failure issues when both qce and BMA dma
are compiled as static part of the kernel.

Cc: Thara Gopinath <thara.gopinath@linaro.org>
Cc: Bjorn Andersson <bjorn.andersson@linaro.org>
Cc: Rob Herring <robh+dt@kernel.org>
Cc: Andy Gross <agross@kernel.org>
Cc: Herbert Xu <herbert@gondor.apana.org.au>
Cc: David S. Miller <davem@davemloft.net>
Cc: Stephen Boyd <sboyd@kernel.org>
Cc: Michael Turquette <mturquette@baylibre.com>
Cc: Vinod Koul <vkoul@kernel.org>
Cc: dmaengine@vger.kernel.org
Cc: linux-clk@vger.kernel.org
Cc: linux-crypto@vger.kernel.org
Cc: devicetree@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Cc: bhupesh.linux@gmail.com
Signed-off-by: Bhupesh Sharma <bhupesh.sharma@linaro.org>
---
 drivers/crypto/qce/core.c  | 4 ++++
 drivers/dma/qcom/bam_dma.c | 7 +++++++
 2 files changed, 11 insertions(+)

Comments

kernel test robot May 6, 2021, 4:52 a.m. UTC | #1
Hi Bhupesh,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on cryptodev/master]
[also build test ERROR on crypto/master vkoul-dmaengine/next robh/for-next v5.12 next-20210505]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Bhupesh-Sharma/Enable-Qualcomm-Crypto-Engine-on-sm8250/20210506-054114
base:   https://git.kernel.org/pub/scm/linux/kernel/git/herbert/cryptodev-2.6.git master
config: m68k-allmodconfig (attached as .config)
compiler: m68k-linux-gcc (GCC) 9.3.0
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://github.com/0day-ci/linux/commit/4c00d66a1b254454e85dc82cb7358649e1dda72c
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Bhupesh-Sharma/Enable-Qualcomm-Crypto-Engine-on-sm8250/20210506-054114
        git checkout 4c00d66a1b254454e85dc82cb7358649e1dda72c
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross W=1 ARCH=m68k 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All errors (new ones prefixed by >>, old ones prefixed by <<):

>> ERROR: modpost: "bam_is_probed" [drivers/crypto/qce/qcrypto.ko] undefined!

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
Bhupesh Sharma May 7, 2021, 9:16 p.m. UTC | #2
Hi,

On Thu, 6 May 2021 at 10:23, kernel test robot <lkp@intel.com> wrote:
>

> Hi Bhupesh,

>

> Thank you for the patch! Yet something to improve:

>

> [auto build test ERROR on cryptodev/master]

> [also build test ERROR on crypto/master vkoul-dmaengine/next robh/for-next v5.12 next-20210505]

> [If your patch is applied to the wrong git tree, kindly drop us a note.

> And when submitting patch, we suggest to use '--base' as documented in

> https://git-scm.com/docs/git-format-patch]

>

> url:    https://github.com/0day-ci/linux/commits/Bhupesh-Sharma/Enable-Qualcomm-Crypto-Engine-on-sm8250/20210506-054114

> base:   https://git.kernel.org/pub/scm/linux/kernel/git/herbert/cryptodev-2.6.git master

> config: m68k-allmodconfig (attached as .config)

> compiler: m68k-linux-gcc (GCC) 9.3.0

> reproduce (this is a W=1 build):

>         wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross

>         chmod +x ~/bin/make.cross

>         # https://github.com/0day-ci/linux/commit/4c00d66a1b254454e85dc82cb7358649e1dda72c

>         git remote add linux-review https://github.com/0day-ci/linux

>         git fetch --no-tags linux-review Bhupesh-Sharma/Enable-Qualcomm-Crypto-Engine-on-sm8250/20210506-054114

>         git checkout 4c00d66a1b254454e85dc82cb7358649e1dda72c

>         # save the attached .config to linux build tree

>         COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross W=1 ARCH=m68k

>

> If you fix the issue, kindly add following tag as appropriate

> Reported-by: kernel test robot <lkp@intel.com>

>

> All errors (new ones prefixed by >>, old ones prefixed by <<):

>

> >> ERROR: modpost: "bam_is_probed" [drivers/crypto/qce/qcrypto.ko] undefined!


Thanks, I will fix this in v3.

Regards,
Bhupesh
Thara Gopinath May 10, 2021, 1:22 p.m. UTC | #3
On 5/5/21 5:37 PM, Bhupesh Sharma wrote:
> Since the Qualcomm qce crypto driver needs the BAM dma driver to be

> setup first (to allow crypto operations), it makes sense to defer

> the qce crypto driver probing in case the BAM dma driver is not yet

> probed.

> 

> This fixes the qce probe failure issues when both qce and BMA dma

> are compiled as static part of the kernel.

> 

> Cc: Thara Gopinath <thara.gopinath@linaro.org>

> Cc: Bjorn Andersson <bjorn.andersson@linaro.org>

> Cc: Rob Herring <robh+dt@kernel.org>

> Cc: Andy Gross <agross@kernel.org>

> Cc: Herbert Xu <herbert@gondor.apana.org.au>

> Cc: David S. Miller <davem@davemloft.net>

> Cc: Stephen Boyd <sboyd@kernel.org>

> Cc: Michael Turquette <mturquette@baylibre.com>

> Cc: Vinod Koul <vkoul@kernel.org>

> Cc: dmaengine@vger.kernel.org

> Cc: linux-clk@vger.kernel.org

> Cc: linux-crypto@vger.kernel.org

> Cc: devicetree@vger.kernel.org

> Cc: linux-kernel@vger.kernel.org

> Cc: bhupesh.linux@gmail.com

> Signed-off-by: Bhupesh Sharma <bhupesh.sharma@linaro.org>

> ---

>   drivers/crypto/qce/core.c  | 4 ++++

>   drivers/dma/qcom/bam_dma.c | 7 +++++++

>   2 files changed, 11 insertions(+)

> 

> diff --git a/drivers/crypto/qce/core.c b/drivers/crypto/qce/core.c

> index 9a7d7ef94687..3e742e9911fa 100644

> --- a/drivers/crypto/qce/core.c

> +++ b/drivers/crypto/qce/core.c

> @@ -15,6 +15,7 @@

>   #include <linux/types.h>

>   #include <crypto/algapi.h>

>   #include <crypto/internal/hash.h>

> +#include <soc/qcom/bam_dma.h>

>   

>   #include "core.h"

>   #include "cipher.h"

> @@ -201,6 +202,9 @@ static int qce_crypto_probe(struct platform_device *pdev)

>   			of_match_device(qce_crypto_of_match, &pdev->dev);

>   	int ret;

>   

> +	/* qce driver requires BAM dma driver to be setup first */

> +	if (!bam_is_probed())

> +		return -EPROBE_DEFER;


Hi Bhupesh,

You don't need this here. qce_dma_request returns -EPROBE_DEFER if the 
dma controller is not probed yet.

-- 
Warm Regards
Thara
>   

>   	qce = devm_kzalloc(dev, sizeof(*qce), GFP_KERNEL);

>   	if (!qce)

> diff --git a/drivers/dma/qcom/bam_dma.c b/drivers/dma/qcom/bam_dma.c

> index 2bc3b7c7ee5a..c854fcc82dbf 100644

> --- a/drivers/dma/qcom/bam_dma.c

> +++ b/drivers/dma/qcom/bam_dma.c

> @@ -935,6 +935,12 @@ static void bam_channel_init(struct bam_device *bdev, struct bam_chan *bchan,

>   	INIT_LIST_HEAD(&bchan->desc_list);

>   }

>   

> +bool bam_is_probed(void)

> +{

> +	return bam_probed;

> +}

> +EXPORT_SYMBOL_GPL(bam_is_probed);

> +

>   static const struct of_device_id bam_of_match[] = {

>   	{ .compatible = "qcom,bam-v1.3.0", .data = &bam_v1_3_reg_info },

>   	{ .compatible = "qcom,bam-v1.4.0", .data = &bam_v1_4_reg_info },

> @@ -1084,6 +1090,7 @@ static int bam_dma_probe(struct platform_device *pdev)

>   	if (ret)

>   		goto err_unregister_dma;

>   

> +	bam_probed = true;

>   	if (!bdev->bamclk) {

>   		pm_runtime_disable(&pdev->dev);

>   		return 0;

>
Bhupesh Sharma May 18, 2021, 2:44 p.m. UTC | #4
HI Thara,

On Mon, 10 May 2021 at 18:52, Thara Gopinath <thara.gopinath@linaro.org> wrote:
>

>

>

> On 5/5/21 5:37 PM, Bhupesh Sharma wrote:

> > Since the Qualcomm qce crypto driver needs the BAM dma driver to be

> > setup first (to allow crypto operations), it makes sense to defer

> > the qce crypto driver probing in case the BAM dma driver is not yet

> > probed.

> >

> > This fixes the qce probe failure issues when both qce and BMA dma

> > are compiled as static part of the kernel.

> >

> > Cc: Thara Gopinath <thara.gopinath@linaro.org>

> > Cc: Bjorn Andersson <bjorn.andersson@linaro.org>

> > Cc: Rob Herring <robh+dt@kernel.org>

> > Cc: Andy Gross <agross@kernel.org>

> > Cc: Herbert Xu <herbert@gondor.apana.org.au>

> > Cc: David S. Miller <davem@davemloft.net>

> > Cc: Stephen Boyd <sboyd@kernel.org>

> > Cc: Michael Turquette <mturquette@baylibre.com>

> > Cc: Vinod Koul <vkoul@kernel.org>

> > Cc: dmaengine@vger.kernel.org

> > Cc: linux-clk@vger.kernel.org

> > Cc: linux-crypto@vger.kernel.org

> > Cc: devicetree@vger.kernel.org

> > Cc: linux-kernel@vger.kernel.org

> > Cc: bhupesh.linux@gmail.com

> > Signed-off-by: Bhupesh Sharma <bhupesh.sharma@linaro.org>

> > ---

> >   drivers/crypto/qce/core.c  | 4 ++++

> >   drivers/dma/qcom/bam_dma.c | 7 +++++++

> >   2 files changed, 11 insertions(+)

> >

> > diff --git a/drivers/crypto/qce/core.c b/drivers/crypto/qce/core.c

> > index 9a7d7ef94687..3e742e9911fa 100644

> > --- a/drivers/crypto/qce/core.c

> > +++ b/drivers/crypto/qce/core.c

> > @@ -15,6 +15,7 @@

> >   #include <linux/types.h>

> >   #include <crypto/algapi.h>

> >   #include <crypto/internal/hash.h>

> > +#include <soc/qcom/bam_dma.h>

> >

> >   #include "core.h"

> >   #include "cipher.h"

> > @@ -201,6 +202,9 @@ static int qce_crypto_probe(struct platform_device *pdev)

> >                       of_match_device(qce_crypto_of_match, &pdev->dev);

> >       int ret;

> >

> > +     /* qce driver requires BAM dma driver to be setup first */

> > +     if (!bam_is_probed())

> > +             return -EPROBE_DEFER;

>

> Hi Bhupesh,

>

> You don't need this here. qce_dma_request returns -EPROBE_DEFER if the

> dma controller is not probed yet.


Thanks for the review.

Yes, we can just use qce_dma_request() return value to return from the
qce probe() function early, in case the bam dma channels are not
available yet.

I have made the changes in v3 and will post it for review shortly.

Regards,
Bhupesh






> >

> >       qce = devm_kzalloc(dev, sizeof(*qce), GFP_KERNEL);

> >       if (!qce)

> > diff --git a/drivers/dma/qcom/bam_dma.c b/drivers/dma/qcom/bam_dma.c

> > index 2bc3b7c7ee5a..c854fcc82dbf 100644

> > --- a/drivers/dma/qcom/bam_dma.c

> > +++ b/drivers/dma/qcom/bam_dma.c

> > @@ -935,6 +935,12 @@ static void bam_channel_init(struct bam_device *bdev, struct bam_chan *bchan,

> >       INIT_LIST_HEAD(&bchan->desc_list);

> >   }

> >

> > +bool bam_is_probed(void)

> > +{

> > +     return bam_probed;

> > +}

> > +EXPORT_SYMBOL_GPL(bam_is_probed);

> > +

> >   static const struct of_device_id bam_of_match[] = {

> >       { .compatible = "qcom,bam-v1.3.0", .data = &bam_v1_3_reg_info },

> >       { .compatible = "qcom,bam-v1.4.0", .data = &bam_v1_4_reg_info },

> > @@ -1084,6 +1090,7 @@ static int bam_dma_probe(struct platform_device *pdev)

> >       if (ret)

> >               goto err_unregister_dma;

> >

> > +     bam_probed = true;

> >       if (!bdev->bamclk) {

> >               pm_runtime_disable(&pdev->dev);

> >               return 0;

> >

>
diff mbox series

Patch

diff --git a/drivers/crypto/qce/core.c b/drivers/crypto/qce/core.c
index 9a7d7ef94687..3e742e9911fa 100644
--- a/drivers/crypto/qce/core.c
+++ b/drivers/crypto/qce/core.c
@@ -15,6 +15,7 @@ 
 #include <linux/types.h>
 #include <crypto/algapi.h>
 #include <crypto/internal/hash.h>
+#include <soc/qcom/bam_dma.h>
 
 #include "core.h"
 #include "cipher.h"
@@ -201,6 +202,9 @@  static int qce_crypto_probe(struct platform_device *pdev)
 			of_match_device(qce_crypto_of_match, &pdev->dev);
 	int ret;
 
+	/* qce driver requires BAM dma driver to be setup first */
+	if (!bam_is_probed())
+		return -EPROBE_DEFER;
 
 	qce = devm_kzalloc(dev, sizeof(*qce), GFP_KERNEL);
 	if (!qce)
diff --git a/drivers/dma/qcom/bam_dma.c b/drivers/dma/qcom/bam_dma.c
index 2bc3b7c7ee5a..c854fcc82dbf 100644
--- a/drivers/dma/qcom/bam_dma.c
+++ b/drivers/dma/qcom/bam_dma.c
@@ -935,6 +935,12 @@  static void bam_channel_init(struct bam_device *bdev, struct bam_chan *bchan,
 	INIT_LIST_HEAD(&bchan->desc_list);
 }
 
+bool bam_is_probed(void)
+{
+	return bam_probed;
+}
+EXPORT_SYMBOL_GPL(bam_is_probed);
+
 static const struct of_device_id bam_of_match[] = {
 	{ .compatible = "qcom,bam-v1.3.0", .data = &bam_v1_3_reg_info },
 	{ .compatible = "qcom,bam-v1.4.0", .data = &bam_v1_4_reg_info },
@@ -1084,6 +1090,7 @@  static int bam_dma_probe(struct platform_device *pdev)
 	if (ret)
 		goto err_unregister_dma;
 
+	bam_probed = true;
 	if (!bdev->bamclk) {
 		pm_runtime_disable(&pdev->dev);
 		return 0;