Skip to contentSkip to conversation

crypto: caam: map job ring registers without claiming region

PATCH In review Rosen Penev 6 participants 7 messages Sep 1 – Sep 16

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 crypto: caam: map job ring registers without claiming region

devm_platform_ioremap_resource() ends up calling request_mem_region(), which fails with -EBUSY on i.MX SoCs:

There the job rings are modelled as sub-regions of their parent fsl,sec-v4.0 register window, and caam_probe() already reserves the whole window exclusively via devm_of_iomap() before the children are populated. Every job ring therefore collides with its own parent and fails to probe, taking the hardware RNG offline (seen on i.MX6, i.MX7 and i.MX8 boards such as colibri-imx7 and verdin-imx8mp).

Map the job ring registers with devm_ioremap() instead, which does not claim the (already owned) region.

Fixes 9a955c0a7d11 ("crypto: caam - simplify probe resource and IRQ handling")
Assisted-by opencode:big-pickle
---
 drivers/crypto/caam/jr.c | 23 ++++++++++++++++++++---
 1 file changed, 20 insertions(+), 3 deletions(-)
drivers/crypto/caam/jr.c +20 -3
index f9e029945b51..2ed8229d4733 100644
@@ -583,12 +583,29 @@ static int caam_jr_probe(struct platform_device *pdev)
 	struct caam_drv_private_jr *jrpriv;
 	static int total_jobrs;
 	void __iomem *ctrl;
+	struct resource *r;
 	int error;
 	int irq;
 
-	ctrl = devm_platform_ioremap_resource(pdev, 0);
-	if (IS_ERR(ctrl))
-		return PTR_ERR(ctrl);
+	/*
+	 * The job rings live inside the register window of their parent
+	 * fsl,sec-v4.0 node, which caam_probe() already reserves (and maps)
+	 * via devm_of_iomap().  A requested region that overlaps that
+	 * reservation, e.g. from devm_platform_ioremap_resource(), would
+	 * therefore fail with -EBUSY, so map the registers without claiming
+	 * the region here.
+	 */
+	r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+	if (!r) {
+		dev_err(&pdev->dev, "platform_get_resource() failed\n");
+		return -EINVAL;
+	}
+
+	ctrl = devm_ioremap(&pdev->dev, r->start, resource_size(r));
+	if (!ctrl) {
+		dev_err(&pdev->dev, "devm_ioremap() failed\n");
+		return -ENOMEM;
+	}
 
 	irq = platform_get_irq(pdev, 0);
 	if (irq < 0)
Signature · 1 line
2.55.0
#1 lore raw

+ Emanuele

Quoted 10 lines · Rosen Penev

devm_platform_ioremap_resource() ends up calling request_mem_region(), which fails with -EBUSY on i.MX SoCs:

There the job rings are modelled as sub-regions of their parent fsl,sec-v4.0 register window, and caam_probe() already reserves the whole window exclusively via devm_of_iomap() before the children are populated. Every job ring therefore collides with its own parent and fails to probe, taking the hardware RNG offline (seen on i.MX6, i.MX7 and i.MX8 boards such as colibri-imx7 and verdin-imx8mp).

Quoted 6 lines

Map the job ring registers with devm_ioremap() instead, which does not claim the (already owned) region.

Fixes 9a955c0a7d11 ("crypto: caam - simplify probe resource and IRQ handling")
Assisted-by opencode:big-pickle

Thanks,
Francesco

#2 lore raw
Quoted 20 lines · Francesco Dolcini

+ Emanuele

Quoted 10 lines · Rosen Penev

devm_platform_ioremap_resource() ends up calling request_mem_region(), which fails with -EBUSY on i.MX SoCs:

There the job rings are modelled as sub-regions of their parent fsl,sec-v4.0 register window, and caam_probe() already reserves the whole window exclusively via devm_of_iomap() before the children are populated. Every job ring therefore collides with its own parent and fails to probe, taking the hardware RNG offline (seen on i.MX6, i.MX7 and i.MX8 boards such as colibri-imx7 and verdin-imx8mp).

Quoted 6 lines

Map the job ring registers with devm_ioremap() instead, which does not claim the (already owned) region.

Fixes 9a955c0a7d11 ("crypto: caam - simplify probe resource and IRQ handling")
Assisted-by opencode:big-pickle
Quoted 5 lines

Thanks,
Francesco

Tested on colibri-imx7.

Thanks,
Emanuele

Tested-by on v1 1/1
#3 lore raw
In reply to Rosen Penev

Hi Rosen,

Quoted 10 lines · Rosen Penev

devm_platform_ioremap_resource() ends up calling request_mem_region(), which fails with -EBUSY on i.MX SoCs:

There the job rings are modelled as sub-regions of their parent fsl,sec-v4.0 register window, and caam_probe() already reserves the whole window exclusively via devm_of_iomap() before the children are populated. Every job ring therefore collides with its own parent and fails to probe, taking the hardware RNG offline (seen on i.MX6, i.MX7 and i.MX8 boards such as colibri-imx7 and verdin-imx8mp).

Quoted 6 lines

Map the job ring registers with devm_ioremap() instead, which does not claim the (already owned) region.

Fixes 9a955c0a7d11 ("crypto: caam - simplify probe resource and IRQ handling")
Assisted-by opencode:big-pickle

thanks for that fix!

regards;rl

Quoted 45 lines
---
 drivers/crypto/caam/jr.c | 23 ++++++++++++++++++++---
 1 file changed, 20 insertions(+), 3 deletions(-)
drivers/crypto/caam/jr.c +20 -3
index f9e029945b51..2ed8229d4733 100644
@@ -583,12 +583,29 @@ static int caam_jr_probe(struct platform_device *pdev)
 	struct caam_drv_private_jr *jrpriv;
 	static int total_jobrs;
 	void __iomem *ctrl;
+	struct resource *r;
 	int error;
 	int irq;
 
-	ctrl = devm_platform_ioremap_resource(pdev, 0);
-	if (IS_ERR(ctrl))
-		return PTR_ERR(ctrl);
+	/*
+	 * The job rings live inside the register window of their parent
+	 * fsl,sec-v4.0 node, which caam_probe() already reserves (and maps)
+	 * via devm_of_iomap().  A requested region that overlaps that
+	 * reservation, e.g. from devm_platform_ioremap_resource(), would
+	 * therefore fail with -EBUSY, so map the registers without claiming
+	 * the region here.
+	 */
+	r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+	if (!r) {
+		dev_err(&pdev->dev, "platform_get_resource() failed\n");
+		return -EINVAL;
+	}
+
+	ctrl = devm_ioremap(&pdev->dev, r->start, resource_size(r));
+	if (!ctrl) {
+		dev_err(&pdev->dev, "devm_ioremap() failed\n");
+		return -ENOMEM;
+	}
 
 	irq = platform_get_irq(pdev, 0);
 	if (irq < 0)
Signature · 1 line
2.55.0
#4 lore raw

Hi everybody,

just a friendly reminder that this patch is now on the mailing list for 14 days and was not included in the 2 rc's which were released since then.

As this essentially breaks CAAM on multiple i.MX SoC variants, is there any possibility to get this included in v7.3-rc4?

Would be great :-)

Thanks!

regards;rl

Quoted 71 lines · Richard Leitner

Hi Rosen,

Quoted 10 lines · Rosen Penev

devm_platform_ioremap_resource() ends up calling request_mem_region(), which fails with -EBUSY on i.MX SoCs:

There the job rings are modelled as sub-regions of their parent fsl,sec-v4.0 register window, and caam_probe() already reserves the whole window exclusively via devm_of_iomap() before the children are populated. Every job ring therefore collides with its own parent and fails to probe, taking the hardware RNG offline (seen on i.MX6, i.MX7 and i.MX8 boards such as colibri-imx7 and verdin-imx8mp).

Quoted 6 lines

Map the job ring registers with devm_ioremap() instead, which does not claim the (already owned) region.

Fixes 9a955c0a7d11 ("crypto: caam - simplify probe resource and IRQ handling")
Assisted-by opencode:big-pickle

thanks for that fix!

regards;rl

Quoted 45 lines
---
 drivers/crypto/caam/jr.c | 23 ++++++++++++++++++++---
 1 file changed, 20 insertions(+), 3 deletions(-)
drivers/crypto/caam/jr.c +20 -3
index f9e029945b51..2ed8229d4733 100644
@@ -583,12 +583,29 @@ static int caam_jr_probe(struct platform_device *pdev)
 	struct caam_drv_private_jr *jrpriv;
 	static int total_jobrs;
 	void __iomem *ctrl;
+	struct resource *r;
 	int error;
 	int irq;
 
-	ctrl = devm_platform_ioremap_resource(pdev, 0);
-	if (IS_ERR(ctrl))
-		return PTR_ERR(ctrl);
+	/*
+	 * The job rings live inside the register window of their parent
+	 * fsl,sec-v4.0 node, which caam_probe() already reserves (and maps)
+	 * via devm_of_iomap().  A requested region that overlaps that
+	 * reservation, e.g. from devm_platform_ioremap_resource(), would
+	 * therefore fail with -EBUSY, so map the registers without claiming
+	 * the region here.
+	 */
+	r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+	if (!r) {
+		dev_err(&pdev->dev, "platform_get_resource() failed\n");
+		return -EINVAL;
+	}
+
+	ctrl = devm_ioremap(&pdev->dev, r->start, resource_size(r));
+	if (!ctrl) {
+		dev_err(&pdev->dev, "devm_ioremap() failed\n");
+		return -ENOMEM;
+	}
 
 	irq = platform_get_irq(pdev, 0);
 	if (irq < 0)
Signature · 1 line
2.55.0
maintainer Tested-by on v1 1/1
#5 lore raw
In reply to Rosen Penev

Hi Rosen,

Thanks for the fix.

Quoted 7 lines

-----Original Message-----
From: Rosen Penev <[email protected]>
Sent: 02 September 2026 02:08
To: [email protected]
Cc: Horia Geanta <[email protected]>; Pankaj Gupta <[email protected]>; Gaurav Jain <[email protected]>; Herbert Xu <[email protected]>; David S. Miller <[email protected]>;

Rosen

Quoted 2 lines

Penev <[email protected]>; open list <[email protected]>
Subject: [EXT] [PATCH] crypto: caam: map job ring registers without

claiming

Quoted 3 lines

region

Caution: This is an external email. Please take care when clicking links

or opening

Quoted 1 line

attachments. When in doubt, report the message using the 'Report this

email'

Quoted 10 lines

button

devm_platform_ioremap_resource() ends up calling request_mem_region(), which fails with -EBUSY on i.MX SoCs:

There the job rings are modelled as sub-regions of their parent fsl,sec-v4.0 register window, and caam_probe() already reserves the whole window exclusively via devm_of_iomap() before the children are populated. Every job ring therefore collides with its own parent and fails to probe,

taking the

Quoted 1 line

hardware RNG offline (seen on i.MX6, i.MX7 and i.MX8 boards such as

colibri-

Quoted 3 lines

imx7 and verdin-imx8mp).

Map the job ring registers with devm_ioremap() instead, which does not

claim the

Quoted 3 lines

(already owned) region.

Fixes 9a955c0a7d11 ("crypto: caam - simplify probe resource and IRQ

handling")

Quoted 15 lines
Assisted-by opencode:big-pickle
---
 drivers/crypto/caam/jr.c | 23 ++++++++++++++++++++---
 1 file changed, 20 insertions(+), 3 deletions(-)
drivers/crypto/caam/jr.c index renamed from drivers/crypto/caam/jr.c +0 -0

f9e029945b51..2ed8229d4733 100644

drivers/crypto/caam/jr.c +0 -0
@@ -583,12 +583,29 @@ static int caam_jr_probe(struct platform_device
 *pdev)
        struct caam_drv_private_jr *jrpriv;
        static int total_jobrs;
        void __iomem *ctrl;

drivers/crypto/caam/jr.c static int caam_jr_probe(struct platform_device · line 593

Quoted 10 lines
drivers/crypto/caam/jr.c +4 -3
+       struct resource *r;
        int error;
        int irq;
 
-       ctrl = devm_platform_ioremap_resource(pdev, 0);
-       if (IS_ERR(ctrl))
-               return PTR_ERR(ctrl);
+       /*
+        * The job rings live inside the register window of their parent
+        * fsl,sec-v4.0 node, which caam_probe() already reserves (and

maps)

drivers/crypto/caam/jr.c static int caam_jr_probe(struct platform_device *pdev)

Quoted 3 lines
drivers/crypto/caam/jr.c +3 -0
+        * via devm_of_iomap().  A requested region that overlaps that
+        * reservation, e.g. from devm_platform_ioremap_resource(), would
+        * therefore fail with -EBUSY, so map the registers without

claiming

Quoted 19 lines
drivers/crypto/caam/jr.c +13 -0
+        * the region here.
+        */
+       r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+       if (!r) {
+               dev_err(&pdev->dev, "platform_get_resource() failed\n");
+               return -EINVAL;
+       }
+
+       ctrl = devm_ioremap(&pdev->dev, r->start, resource_size(r));
+       if (!ctrl) {
+               dev_err(&pdev->dev, "devm_ioremap() failed\n");
+               return -ENOMEM;
+       }
 
        irq = platform_get_irq(pdev, 0);
        if (irq < 0)

--
2.55.0

maintainer
#6 lore raw
In reply to Rosen Penev
Quoted 13 lines · Rosen Penev

devm_platform_ioremap_resource() ends up calling request_mem_region(), which fails with -EBUSY on i.MX SoCs:

There the job rings are modelled as sub-regions of their parent fsl,sec-v4.0 register window, and caam_probe() already reserves the whole window exclusively via devm_of_iomap() before the children are populated. Every job ring therefore collides with its own parent and fails to probe, taking the hardware RNG offline (seen on i.MX6, i.MX7 and i.MX8 boards such as colibri-imx7 and verdin-imx8mp).

Map the job ring registers with devm_ioremap() instead, which does not claim the (already owned) region.

Quoted 6 lines
Fixes 9a955c0a7d11 ("crypto: caam - simplify probe resource and IRQ handling")
Assisted-by opencode:big-pickle
---
 drivers/crypto/caam/jr.c | 23 ++++++++++++++++++++---
 1 file changed, 20 insertions(+), 3 deletions(-)

Patch applied. Thanks.

Signature · 3 lines
Email: Herbert Xu <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt