Skip to contentSkip to conversation

drm/panfrost: Add support for non-existent reset node

PATCH In review Yejune Deng 2 participants 2 messages Nov 2, 2020

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

PATCH 1/1 drm/panfrost: Add support for non-existent reset node

Some dts hasn't no reset node, is should ok.

---
 drivers/gpu/drm/panfrost/panfrost_device.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)
drivers/gpu/drm/panfrost/panfrost_device.c +8 -2
index ea8d318..a982878 100644
@@ -18,7 +18,12 @@
 
 static int panfrost_reset_init(struct panfrost_device *pfdev)
 {
-	pfdev->rstc = devm_reset_control_array_get(pfdev->dev, false, true);
+	pfdev->rstc = devm_reset_control_array_get_optional_exclusive(pfdev->dev);
+	if (!pfdev->rstc) {
+		dev_info(pfdev->dev, "reset does not exist\n");
+		return 0;
+	}
+
 	if (IS_ERR(pfdev->rstc)) {
 		dev_err(pfdev->dev, "get reset failed %ld\n", PTR_ERR(pfdev->rstc));
 		return PTR_ERR(pfdev->rstc);
@@ -29,7 +34,8 @@ static int panfrost_reset_init(struct panfrost_device *pfdev)
 
 static void panfrost_reset_fini(struct panfrost_device *pfdev)
 {
-	reset_control_assert(pfdev->rstc);
+	if (pfdev->rstc)
+		reset_control_assert(pfdev->rstc);
 }
 
 static int panfrost_clk_init(struct panfrost_device *pfdev)
Signature · 1 line
1.9.1
maintainer
#1 lore raw
Quoted 12 lines · Yejune Deng

Some dts hasn't no reset node, is should ok.

---
  drivers/gpu/drm/panfrost/panfrost_device.c | 10 ++++++++--
  1 file changed, 8 insertions(+), 2 deletions(-)
drivers/gpu/drm/panfrost/panfrost_device.c +0 -0
index ea8d318..a982878 100644

drivers/gpu/drm/panfrost/panfrost_device.c line 21

Quoted 5 lines
drivers/gpu/drm/panfrost/panfrost_device.c +1 -1
@@ -18,7 +18,12 @@
 
  static int panfrost_reset_init(struct panfrost_device *pfdev)
  {
-	pfdev->rstc = devm_reset_control_array_get(pfdev->dev, false, true);
+	pfdev->rstc = devm_reset_control_array_get_optional_exclusive(pfdev->dev);

This change is fine - it should have no functional change and makes the code more readable.

drivers/gpu/drm/panfrost/panfrost_device.c line 23

Quoted 2 lines
drivers/gpu/drm/panfrost/panfrost_device.c +2 -0
+	if (!pfdev->rstc) {
+		dev_info(pfdev->dev, "reset does not exist\n");

I don't think this output is particularly useful.

drivers/gpu/drm/panfrost/panfrost_device.c line 24

Quoted 1 line
drivers/gpu/drm/panfrost/panfrost_device.c +1 -0
+		return 0;

The early return isn't necessary. IS_ERR(NULL) is false, and reset_control_deassert() deals fine with NULL, so the path below would be fine.

drivers/gpu/drm/panfrost/panfrost_device.c static int panfrost_reset_init(struct panfrost_device *pfdev) · line 38

Quoted 12 lines
drivers/gpu/drm/panfrost/panfrost_device.c +4 -1
+	}
+
  	if (IS_ERR(pfdev->rstc)) {
  		dev_err(pfdev->dev, "get reset failed %ld\n", PTR_ERR(pfdev->rstc));
  		return PTR_ERR(pfdev->rstc);
@@ -29,7 +34,8 @@ static int panfrost_reset_init(struct panfrost_device *pfdev)
 
  static void panfrost_reset_fini(struct panfrost_device *pfdev)
  {
-	reset_control_assert(pfdev->rstc);
+	if (pfdev->rstc)
+		reset_control_assert(pfdev->rstc);

reset_control_assert() deals fine with a NULL input, so this is unneeded.

drivers/gpu/drm/panfrost/panfrost_device.c static int panfrost_reset_init(struct panfrost_device *pfdev) · line 41

Quoted 4 lines
drivers/gpu/drm/panfrost/panfrost_device.c +0 -0
  }
 
  static int panfrost_clk_init(struct panfrost_device *pfdev)

Have you actually seen a problem on a platform without a reset node - it works fine for me and I can't see any functional change with this patch.

Steve