Skip to content

Commit 176435a

Browse files
horiagherbertx
authored andcommitted
crypto: caam - defer probing until QMan is available
When QI (Queue Interface) support is enabled on DPAA 1.x platforms, defer probing if dependencies (QMan drivers) are not available yet. Signed-off-by: Horia Geantă <[email protected]> Signed-off-by: Herbert Xu <[email protected]>
1 parent 2ef5404 commit 176435a

File tree

1 file changed

+48
-26
lines changed

1 file changed

+48
-26
lines changed

drivers/crypto/caam/ctrl.c

Lines changed: 48 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -527,15 +527,54 @@ static int caam_probe(struct platform_device *pdev)
527527
dev_set_drvdata(dev, ctrlpriv);
528528
nprop = pdev->dev.of_node;
529529

530+
/* Get configuration properties from device tree */
531+
/* First, get register page */
532+
ctrl = of_iomap(nprop, 0);
533+
if (!ctrl) {
534+
dev_err(dev, "caam: of_iomap() failed\n");
535+
return -ENOMEM;
536+
}
537+
538+
caam_little_end = !(bool)(rd_reg32(&ctrl->perfmon.status) &
539+
(CSTA_PLEND | CSTA_ALT_PLEND));
530540
caam_imx = (bool)soc_device_match(imx_soc);
531541

542+
comp_params = rd_reg32(&ctrl->perfmon.comp_parms_ms);
543+
caam_dpaa2 = !!(comp_params & CTPR_MS_DPAA2);
544+
ctrlpriv->qi_present = !!(comp_params & CTPR_MS_QI_MASK);
545+
546+
#ifdef CONFIG_CAAM_QI
547+
/* If (DPAA 1.x) QI present, check whether dependencies are available */
548+
if (ctrlpriv->qi_present && !caam_dpaa2) {
549+
ret = qman_is_probed();
550+
if (!ret) {
551+
ret = -EPROBE_DEFER;
552+
goto iounmap_ctrl;
553+
} else if (ret < 0) {
554+
dev_err(dev, "failing probe due to qman probe error\n");
555+
ret = -ENODEV;
556+
goto iounmap_ctrl;
557+
}
558+
559+
ret = qman_portals_probed();
560+
if (!ret) {
561+
ret = -EPROBE_DEFER;
562+
goto iounmap_ctrl;
563+
} else if (ret < 0) {
564+
dev_err(dev, "failing probe due to qman portals probe error\n");
565+
ret = -ENODEV;
566+
goto iounmap_ctrl;
567+
}
568+
}
569+
#endif
570+
532571
/* Enable clocking */
533572
clk = caam_drv_identify_clk(&pdev->dev, "ipg");
534573
if (IS_ERR(clk)) {
535574
ret = PTR_ERR(clk);
536575
dev_err(&pdev->dev,
537576
"can't identify CAAM ipg clk: %d\n", ret);
538-
return ret;
577+
goto iounmap_ctrl;
539578
}
540579
ctrlpriv->caam_ipg = clk;
541580

@@ -547,7 +586,7 @@ static int caam_probe(struct platform_device *pdev)
547586
ret = PTR_ERR(clk);
548587
dev_err(&pdev->dev,
549588
"can't identify CAAM mem clk: %d\n", ret);
550-
return ret;
589+
goto iounmap_ctrl;
551590
}
552591
ctrlpriv->caam_mem = clk;
553592
}
@@ -557,7 +596,7 @@ static int caam_probe(struct platform_device *pdev)
557596
ret = PTR_ERR(clk);
558597
dev_err(&pdev->dev,
559598
"can't identify CAAM aclk clk: %d\n", ret);
560-
return ret;
599+
goto iounmap_ctrl;
561600
}
562601
ctrlpriv->caam_aclk = clk;
563602

@@ -570,15 +609,15 @@ static int caam_probe(struct platform_device *pdev)
570609
ret = PTR_ERR(clk);
571610
dev_err(&pdev->dev,
572611
"can't identify CAAM emi_slow clk: %d\n", ret);
573-
return ret;
612+
goto iounmap_ctrl;
574613
}
575614
ctrlpriv->caam_emi_slow = clk;
576615
}
577616

578617
ret = clk_prepare_enable(ctrlpriv->caam_ipg);
579618
if (ret < 0) {
580619
dev_err(&pdev->dev, "can't enable CAAM ipg clock: %d\n", ret);
581-
return ret;
620+
goto iounmap_ctrl;
582621
}
583622

584623
if (ctrlpriv->caam_mem) {
@@ -605,25 +644,10 @@ static int caam_probe(struct platform_device *pdev)
605644
}
606645
}
607646

608-
/* Get configuration properties from device tree */
609-
/* First, get register page */
610-
ctrl = of_iomap(nprop, 0);
611-
if (ctrl == NULL) {
612-
dev_err(dev, "caam: of_iomap() failed\n");
613-
ret = -ENOMEM;
614-
goto disable_caam_emi_slow;
615-
}
616-
617-
caam_little_end = !(bool)(rd_reg32(&ctrl->perfmon.status) &
618-
(CSTA_PLEND | CSTA_ALT_PLEND));
619-
620-
/* Finding the page size for using the CTPR_MS register */
621-
comp_params = rd_reg32(&ctrl->perfmon.comp_parms_ms);
622-
pg_size = (comp_params & CTPR_MS_PG_SZ_MASK) >> CTPR_MS_PG_SZ_SHIFT;
623-
624647
/* Allocating the BLOCK_OFFSET based on the supported page size on
625648
* the platform
626649
*/
650+
pg_size = (comp_params & CTPR_MS_PG_SZ_MASK) >> CTPR_MS_PG_SZ_SHIFT;
627651
if (pg_size == 0)
628652
BLOCK_OFFSET = PG_SIZE_4K;
629653
else
@@ -648,7 +672,6 @@ static int caam_probe(struct platform_device *pdev)
648672
* In case of SoCs with Management Complex, MC f/w performs
649673
* the configuration.
650674
*/
651-
caam_dpaa2 = !!(comp_params & CTPR_MS_DPAA2);
652675
np = of_find_compatible_node(NULL, NULL, "fsl,qoriq-mc");
653676
ctrlpriv->mc_en = !!np;
654677
of_node_put(np);
@@ -700,7 +723,7 @@ static int caam_probe(struct platform_device *pdev)
700723
}
701724
if (ret) {
702725
dev_err(dev, "dma_set_mask_and_coherent failed (%d)\n", ret);
703-
goto iounmap_ctrl;
726+
goto disable_caam_emi_slow;
704727
}
705728

706729
ctrlpriv->era = caam_get_era(ctrl);
@@ -719,7 +742,6 @@ static int caam_probe(struct platform_device *pdev)
719742
#endif
720743

721744
/* Check to see if (DPAA 1.x) QI present. If so, enable */
722-
ctrlpriv->qi_present = !!(comp_params & CTPR_MS_QI_MASK);
723745
if (ctrlpriv->qi_present && !caam_dpaa2) {
724746
ctrlpriv->qi = (struct caam_queue_if __iomem __force *)
725747
((__force uint8_t *)ctrl +
@@ -906,8 +928,6 @@ static int caam_probe(struct platform_device *pdev)
906928
if (ctrlpriv->qi_init)
907929
caam_qi_shutdown(dev);
908930
#endif
909-
iounmap_ctrl:
910-
iounmap(ctrl);
911931
disable_caam_emi_slow:
912932
if (ctrlpriv->caam_emi_slow)
913933
clk_disable_unprepare(ctrlpriv->caam_emi_slow);
@@ -918,6 +938,8 @@ static int caam_probe(struct platform_device *pdev)
918938
clk_disable_unprepare(ctrlpriv->caam_mem);
919939
disable_caam_ipg:
920940
clk_disable_unprepare(ctrlpriv->caam_ipg);
941+
iounmap_ctrl:
942+
iounmap(ctrl);
921943
return ret;
922944
}
923945

0 commit comments

Comments
 (0)