Skip to contentSkip to conversation

rng: msm_rng: Acquire optional clock even when initialization is skipped

PATCH In review Reza Kurniawan 3 participants 3 messages Sep 15 – Nov 16

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 rng: msm_rng: Acquire optional clock even when initialization is skipped

For devices marked with skip_init ("qcom,prng-ee" and "qcom,trng"), msm_rng_probe() currently returns early before retrieving the clock. As a result, priv->clk remains uninitialized, causing subsequent calls to msm_rng_read() to skip enabling the clock which may cause failure if the device boots with the clock disabled.

Move clk_get_by_index() before the skip_init check so that any clock specified in device tree is properly recorded. Additionally, treat -ENOENT as non-fatal so the clock remains optional for devices (such as some "qcom,trng" nodes) that do not define one.

---
 drivers/rng/msm_rng.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/rng/msm_rng.c +4 -4
index aab602c5e..68f25ac51 100644
@@ -114,13 +114,13 @@ static int msm_rng_probe(struct udevice *dev)
 	if (priv->base == FDT_ADDR_T_NONE)
 		return -EINVAL;
 
-	if (priv->skip_init)
-		return 0;
-
 	ret = clk_get_by_index(dev, 0, &priv->clk);
-	if (ret)
+	if (ret && ret != -ENOENT)
 		return ret;
 
+	if (priv->skip_init)
+		return 0;
+
 	ret = clk_enable(&priv->clk);
 	if (ret < 0)
 		return ret;

---
base-commit: 0e2a0ceeefa0ae10118b8364da62f1fb86f286c0
change-id: 20260914-qcom-rng-fix-a7dabc760daf

Best regards,

Signature · 1 line
Reza Kurniawan <[email protected]>
Reviewed-by on v1 1/1
#1 lore raw

Hi Reza,

Quoted 6 lines · Reza Kurniawan

For devices marked with skip_init ("qcom,prng-ee" and "qcom,trng"), msm_rng_probe() currently returns early before retrieving the clock. As a result, priv->clk remains uninitialized, causing subsequent calls to msm_rng_read() to skip enabling the clock which may cause failure if the device boots with the clock disabled.

Quoted 6 lines

Move clk_get_by_index() before the skip_init check so that any clock specified in device tree is properly recorded. Additionally, treat -ENOENT as non-fatal so the clock remains optional for devices (such as some "qcom,trng" nodes) that do not define one.

Quoted 34 lines
---
  drivers/rng/msm_rng.c | 8 ++++----
  1 file changed, 4 insertions(+), 4 deletions(-)
drivers/rng/msm_rng.c +4 -5
index aab602c5e..68f25ac51 100644
@@ -114,13 +114,13 @@ static int msm_rng_probe(struct udevice *dev)
  	if (priv->base == FDT_ADDR_T_NONE)
  		return -EINVAL;
 
-	if (priv->skip_init)
-		return 0;
-
  	ret = clk_get_by_index(dev, 0, &priv->clk);
-	if (ret)
+	if (ret && ret != -ENOENT)
  		return ret;
 
+	if (priv->skip_init)
+		return 0;
+
  	ret = clk_enable(&priv->clk);
  	if (ret < 0)
  		return ret;
 
---

base-commit: 0e2a0ceeefa0ae10118b8364da62f1fb86f286c0
change-id: 20260914-qcom-rng-fix-a7dabc760daf

Best regards,
--
Reza Kurniawan <[email protected]>

Reviewed-by on v1 1/1
#2 lore raw
In reply to Reza Kurniawan
Quoted 11 lines · Reza Kurniawan

For devices marked with skip_init ("qcom,prng-ee" and "qcom,trng"), msm_rng_probe() currently returns early before retrieving the clock. As a result, priv->clk remains uninitialized, causing subsequent calls to msm_rng_read() to skip enabling the clock which may cause failure if the device boots with the clock disabled.

Move clk_get_by_index() before the skip_init check so that any clock specified in device tree is properly recorded. Additionally, treat -ENOENT as non-fatal so the clock remains optional for devices (such as some "qcom,trng" nodes) that do not define one.

Quoted 4 lines
---
 drivers/rng/msm_rng.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

-Sumit

Quoted 33 lines
drivers/rng/msm_rng.c +4 -5
index aab602c5e..68f25ac51 100644
@@ -114,13 +114,13 @@ static int msm_rng_probe(struct udevice *dev)
 	if (priv->base == FDT_ADDR_T_NONE)
 		return -EINVAL;
 
-	if (priv->skip_init)
-		return 0;
-
 	ret = clk_get_by_index(dev, 0, &priv->clk);
-	if (ret)
+	if (ret && ret != -ENOENT)
 		return ret;
 
+	if (priv->skip_init)
+		return 0;
+
 	ret = clk_enable(&priv->clk);
 	if (ret < 0)
 		return ret;
 
---

base-commit: 0e2a0ceeefa0ae10118b8364da62f1fb86f286c0
change-id: 20260914-qcom-rng-fix-a7dabc760daf

Best regards,

Signature · 1 line
Reza Kurniawan <[email protected]>