Skip to contentSkip to conversation

soc: qcom: ice: Stop probe deferring once ICE isn't detected

PATCH In review Sumit Garg 4 participants 5 messages Feb 2 – Feb 3

Subsystems (3)
lore
Share & tools
lore

Sumit Garg

author
#0 lore raw

PATCH v2 1/1 soc: qcom: ice: Stop probe deferring once ICE isn't detected

From: Sumit Garg <[email protected]>

ICE related SCM calls may not be supported in every TZ environment like OP-TEE or a no-TZ environment too. So let's try to stop probe deferring when it's known that ICE feature isn't supported.

This problem only came to notice after the inline encryption drivers were enabled in the arm64 defconfig by: commit 5f37788adedd ("arm64: defconfig:
Enable SCSI UFS Crypto and Block Inline encryption drivers").

Fixes 2afbf43a4aec ("soc: qcom: Make the Qualcomm UFS/SDCC ICE a dedicated driver")

---

Changes in v2:
- Keep the probe deferring intact but stop it once it's know ICE SCM calls aren't supported by the TZ firmware.

 drivers/soc/qcom/ice.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)
drivers/soc/qcom/ice.c +7 -4
index b203bc685cad..5a630c9010ee 100644
@@ -559,7 +559,7 @@ static struct qcom_ice *qcom_ice_create(struct device *dev,
 
 	if (!qcom_scm_ice_available()) {
 		dev_warn(dev, "ICE SCM interface not found\n");
-		return NULL;
+		return ERR_PTR(-EOPNOTSUPP);
 	}
 
 	engine = devm_kzalloc(dev, sizeof(*engine), GFP_KERNEL);
@@ -648,11 +648,14 @@ static struct qcom_ice *of_qcom_ice_get(struct device *dev)
 	}
 
 	ice = platform_get_drvdata(pdev);
-	if (!ice) {
+	if (IS_ERR_OR_NULL(ice)) {
 		dev_err(dev, "Cannot get ice instance from %s\n",
 			dev_name(&pdev->dev));
 		platform_device_put(pdev);
-		return ERR_PTR(-EPROBE_DEFER);
+		if (PTR_ERR(ice) == -EOPNOTSUPP)
+			return NULL;
+		else
+			return ERR_PTR(-EPROBE_DEFER);
 	}
 
 	link = device_link_add(dev, &pdev->dev, DL_FLAG_AUTOREMOVE_SUPPLIER);
@@ -726,7 +729,7 @@ static int qcom_ice_probe(struct platform_device *pdev)
 	}
 
 	engine = qcom_ice_create(&pdev->dev, base);
-	if (IS_ERR(engine))
+	if (IS_ERR(engine) && PTR_ERR(engine) != -EOPNOTSUPP)
 		return PTR_ERR(engine);
 
 	platform_set_drvdata(pdev, engine);
Signature · 1 line
2.51.0
#1 lore raw
Quoted 36 lines · Sumit Garg

From: Sumit Garg <[email protected]>

ICE related SCM calls may not be supported in every TZ environment like OP-TEE or a no-TZ environment too. So let's try to stop probe deferring when it's known that ICE feature isn't supported.

This problem only came to notice after the inline encryption drivers were enabled in the arm64 defconfig by: commit 5f37788adedd ("arm64: defconfig:
Enable SCSI UFS Crypto and Block Inline encryption drivers").

Fixes 2afbf43a4aec ("soc: qcom: Make the Qualcomm UFS/SDCC ICE a dedicated driver")

---

Changes in v2:
- Keep the probe deferring intact but stop it once it's know ICE SCM calls aren't supported by the TZ firmware.

 drivers/soc/qcom/ice.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)
drivers/soc/qcom/ice.c +1 -1
index b203bc685cad..5a630c9010ee 100644
@@ -559,7 +559,7 @@ static struct qcom_ice *qcom_ice_create(struct device *dev,
 
 	if (!qcom_scm_ice_available()) {
 		dev_warn(dev, "ICE SCM interface not found\n");
-		return NULL;
+		return ERR_PTR(-EOPNOTSUPP);
 	}
 
 	engine = devm_kzalloc(dev, sizeof(*engine), GFP_KERNEL);
@@ -648,11 +648,14 @@ static struct qcom_ice *of_qcom_ice_get(struct device *dev)
 	}

drivers/soc/qcom/ice.c static struct qcom_ice *of_qcom_ice_get(struct device *dev) · line 656

Quoted 10 lines
drivers/soc/qcom/ice.c +3 -2
 
 	ice = platform_get_drvdata(pdev);
-	if (!ice) {
+	if (IS_ERR_OR_NULL(ice)) {
 		dev_err(dev, "Cannot get ice instance from %s\n",
 			dev_name(&pdev->dev));
 		platform_device_put(pdev);
-		return ERR_PTR(-EPROBE_DEFER);
+		if (PTR_ERR(ice) == -EOPNOTSUPP)
+			return NULL;

The consumer drivers check specifically for -EOPNOTSUPP, let's just return that

drivers/soc/qcom/ice.c static int qcom_ice_probe(struct platform_device *pdev) · line 733

Quoted 12 lines
drivers/soc/qcom/ice.c +3 -1
+		else
+			return ERR_PTR(-EPROBE_DEFER);
 	}
 
 	link = device_link_add(dev, &pdev->dev, DL_FLAG_AUTOREMOVE_SUPPLIER);
@@ -726,7 +729,7 @@ static int qcom_ice_probe(struct platform_device *pdev)
 	}
 
 	engine = qcom_ice_create(&pdev->dev, base);
-	if (IS_ERR(engine))
+	if (IS_ERR(engine) && PTR_ERR(engine) != -EOPNOTSUPP)
 		return PTR_ERR(engine);

This essentially says "probe succeeded, device not operational", I have mixed feelings.. That said I'm not sure about the lifecycle of a platform_device, i.e. can we set the drvdata and return an error in .probe anyway?

Konrad

Quoted 2 lines
drivers/soc/qcom/ice.c +0 -0
 	platform_set_drvdata(pdev, engine);
#2 lore raw
Quoted 59 lines · Konrad Dybcio
Quoted 36 lines · Sumit Garg

From: Sumit Garg <[email protected]>

ICE related SCM calls may not be supported in every TZ environment like OP-TEE or a no-TZ environment too. So let's try to stop probe deferring when it's known that ICE feature isn't supported.

This problem only came to notice after the inline encryption drivers were enabled in the arm64 defconfig by: commit 5f37788adedd ("arm64: defconfig:
Enable SCSI UFS Crypto and Block Inline encryption drivers").

Fixes 2afbf43a4aec ("soc: qcom: Make the Qualcomm UFS/SDCC ICE a dedicated driver")

---

Changes in v2:
- Keep the probe deferring intact but stop it once it's know ICE SCM calls aren't supported by the TZ firmware.

 drivers/soc/qcom/ice.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)
drivers/soc/qcom/ice.c +1 -1
index b203bc685cad..5a630c9010ee 100644
@@ -559,7 +559,7 @@ static struct qcom_ice *qcom_ice_create(struct device *dev,
 
 	if (!qcom_scm_ice_available()) {
 		dev_warn(dev, "ICE SCM interface not found\n");
-		return NULL;
+		return ERR_PTR(-EOPNOTSUPP);
 	}
 
 	engine = devm_kzalloc(dev, sizeof(*engine), GFP_KERNEL);
@@ -648,11 +648,14 @@ static struct qcom_ice *of_qcom_ice_get(struct device *dev)
 	}

drivers/soc/qcom/ice.c static struct qcom_ice *of_qcom_ice_get(struct device *dev) · line 656

Quoted 10 lines
drivers/soc/qcom/ice.c +3 -2
 
 	ice = platform_get_drvdata(pdev);
-	if (!ice) {
+	if (IS_ERR_OR_NULL(ice)) {
 		dev_err(dev, "Cannot get ice instance from %s\n",
 			dev_name(&pdev->dev));
 		platform_device_put(pdev);
-		return ERR_PTR(-EPROBE_DEFER);
+		if (PTR_ERR(ice) == -EOPNOTSUPP)
+			return NULL;

The consumer drivers check specifically for -EOPNOTSUPP, let's just return that

Quoted 8 lines
drivers/soc/qcom/ice.c +2 -0
+		else
+			return ERR_PTR(-EPROBE_DEFER);
 	}
 
 	link = device_link_add(dev, &pdev->dev, DL_FLAG_AUTOREMOVE_SUPPLIER);
@@ -726,7 +729,7 @@ static int qcom_ice_probe(struct platform_device *pdev)
 	}
 
Quoted 10 lines

drivers/soc/qcom/ice.c static int qcom_ice_probe(struct platform_device *pdev) · line 733

Quoted 4 lines
drivers/soc/qcom/ice.c +1 -1
 	engine = qcom_ice_create(&pdev->dev, base);
-	if (IS_ERR(engine))
+	if (IS_ERR(engine) && PTR_ERR(engine) != -EOPNOTSUPP)
 		return PTR_ERR(engine);

This essentially says "probe succeeded, device not operational", I have mixed feelings.. That said I'm not sure about the lifecycle of a platform_device, i.e. can we set the drvdata and return an error in .probe anyway?

No. Let's remove the probe() altogether and expose this driver as a pure library.

- Mani

Signature · 1 line
மணிவண்ணன் சதாசிவம்
#3 lore raw
Quoted 71 lines · Manivannan Sadhasivam
Quoted 59 lines · Konrad Dybcio
Quoted 36 lines · Sumit Garg

From: Sumit Garg <[email protected]>

ICE related SCM calls may not be supported in every TZ environment like OP-TEE or a no-TZ environment too. So let's try to stop probe deferring when it's known that ICE feature isn't supported.

This problem only came to notice after the inline encryption drivers were enabled in the arm64 defconfig by: commit 5f37788adedd ("arm64: defconfig:
Enable SCSI UFS Crypto and Block Inline encryption drivers").

Fixes 2afbf43a4aec ("soc: qcom: Make the Qualcomm UFS/SDCC ICE a dedicated driver")

---

Changes in v2:
- Keep the probe deferring intact but stop it once it's know ICE SCM calls aren't supported by the TZ firmware.

 drivers/soc/qcom/ice.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)
drivers/soc/qcom/ice.c +1 -1
index b203bc685cad..5a630c9010ee 100644
@@ -559,7 +559,7 @@ static struct qcom_ice *qcom_ice_create(struct device *dev,
 
 	if (!qcom_scm_ice_available()) {
 		dev_warn(dev, "ICE SCM interface not found\n");
-		return NULL;
+		return ERR_PTR(-EOPNOTSUPP);
 	}
 
 	engine = devm_kzalloc(dev, sizeof(*engine), GFP_KERNEL);
@@ -648,11 +648,14 @@ static struct qcom_ice *of_qcom_ice_get(struct device *dev)
 	}

drivers/soc/qcom/ice.c static struct qcom_ice *of_qcom_ice_get(struct device *dev) · line 656

Quoted 10 lines
drivers/soc/qcom/ice.c +3 -2
 
 	ice = platform_get_drvdata(pdev);
-	if (!ice) {
+	if (IS_ERR_OR_NULL(ice)) {
 		dev_err(dev, "Cannot get ice instance from %s\n",
 			dev_name(&pdev->dev));
 		platform_device_put(pdev);
-		return ERR_PTR(-EPROBE_DEFER);
+		if (PTR_ERR(ice) == -EOPNOTSUPP)
+			return NULL;

The consumer drivers check specifically for -EOPNOTSUPP, let's just return that

Quoted 8 lines
drivers/soc/qcom/ice.c +2 -0
+		else
+			return ERR_PTR(-EPROBE_DEFER);
 	}
 
 	link = device_link_add(dev, &pdev->dev, DL_FLAG_AUTOREMOVE_SUPPLIER);
@@ -726,7 +729,7 @@ static int qcom_ice_probe(struct platform_device *pdev)
 	}
 
Quoted 10 lines

drivers/soc/qcom/ice.c static int qcom_ice_probe(struct platform_device *pdev) · line 733

Quoted 4 lines
drivers/soc/qcom/ice.c +1 -1
 	engine = qcom_ice_create(&pdev->dev, base);
-	if (IS_ERR(engine))
+	if (IS_ERR(engine) && PTR_ERR(engine) != -EOPNOTSUPP)
 		return PTR_ERR(engine);

This essentially says "probe succeeded, device not operational", I have mixed feelings.. That said I'm not sure about the lifecycle of a platform_device, i.e. can we set the drvdata and return an error in .probe anyway?

Quoted 3 lines

No. Let's remove the probe() altogether and expose this driver as a pure library.

The ICE driver already acts as a library for legacy DT case where consumer device provides 'ice' reg range. It was made dedicated platform driver as ICE is a common IP for UFS and SDCC. See here:
https://lore.kernel.org/all/[email protected]/
I think it will be better if we resolve the race between probe() and *of_qcom_ice_get().

Quoted 2 lines

- Mani
Regards

Neeraj

#4 lore raw
Quoted 74 lines · Neeraj Soni
Quoted 71 lines · Manivannan Sadhasivam
Quoted 69 lines · Konrad Dybcio
Quoted 36 lines · Sumit Garg

From: Sumit Garg <[email protected]>

ICE related SCM calls may not be supported in every TZ environment like OP-TEE or a no-TZ environment too. So let's try to stop probe deferring when it's known that ICE feature isn't supported.

This problem only came to notice after the inline encryption drivers were enabled in the arm64 defconfig by: commit 5f37788adedd ("arm64: defconfig:
Enable SCSI UFS Crypto and Block Inline encryption drivers").

Fixes 2afbf43a4aec ("soc: qcom: Make the Qualcomm UFS/SDCC ICE a dedicated driver")

---

Changes in v2:
- Keep the probe deferring intact but stop it once it's know ICE SCM calls aren't supported by the TZ firmware.

 drivers/soc/qcom/ice.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)
drivers/soc/qcom/ice.c +1 -1
index b203bc685cad..5a630c9010ee 100644
@@ -559,7 +559,7 @@ static struct qcom_ice *qcom_ice_create(struct device *dev,
 
 	if (!qcom_scm_ice_available()) {
 		dev_warn(dev, "ICE SCM interface not found\n");
-		return NULL;
+		return ERR_PTR(-EOPNOTSUPP);
 	}
 
 	engine = devm_kzalloc(dev, sizeof(*engine), GFP_KERNEL);
@@ -648,11 +648,14 @@ static struct qcom_ice *of_qcom_ice_get(struct device *dev)
 	}

drivers/soc/qcom/ice.c static struct qcom_ice *of_qcom_ice_get(struct device *dev) · line 656

Quoted 10 lines
drivers/soc/qcom/ice.c +3 -2
 
 	ice = platform_get_drvdata(pdev);
-	if (!ice) {
+	if (IS_ERR_OR_NULL(ice)) {
 		dev_err(dev, "Cannot get ice instance from %s\n",
 			dev_name(&pdev->dev));
 		platform_device_put(pdev);
-		return ERR_PTR(-EPROBE_DEFER);
+		if (PTR_ERR(ice) == -EOPNOTSUPP)
+			return NULL;

The consumer drivers check specifically for -EOPNOTSUPP, let's just return that

drivers/soc/qcom/ice.c static int qcom_ice_probe(struct platform_device *pdev) · line 733

Quoted 12 lines
drivers/soc/qcom/ice.c +3 -1
+		else
+			return ERR_PTR(-EPROBE_DEFER);
 	}
 
 	link = device_link_add(dev, &pdev->dev, DL_FLAG_AUTOREMOVE_SUPPLIER);
@@ -726,7 +729,7 @@ static int qcom_ice_probe(struct platform_device *pdev)
 	}
 
 	engine = qcom_ice_create(&pdev->dev, base);
-	if (IS_ERR(engine))
+	if (IS_ERR(engine) && PTR_ERR(engine) != -EOPNOTSUPP)
 		return PTR_ERR(engine);

This essentially says "probe succeeded, device not operational", I have mixed feelings.. That said I'm not sure about the lifecycle of a platform_device, i.e. can we set the drvdata and return an error in .probe anyway?

Quoted 6 lines
Quoted 3 lines

No. Let's remove the probe() altogether and expose this driver as a pure library.

The ICE driver already acts as a library for legacy DT case where consumer device provides 'ice' reg range. It was made dedicated platform driver as ICE is a common IP for UFS and SDCC. See here:
https://lore.kernel.org/all/[email protected]/

I know. That's why I said 'pure' library.

Quoted 2 lines

I think it will be better if we resolve the race between probe() and *of_qcom_ice_get().

I don't yet see a need to make it as a platform driver. So I removed it and made the driver as a pure library:
https://lore.kernel.org/linux-arm-msm/[email protected]/

- Mani

Signature · 1 line
மணிவண்ணன் சதாசிவம்