Skip to contentSkip to conversation

mfd: tc6393xb fail ohci suspend if full state restore is required

PATCH Applied Dmitry Eremin-Solenikov 2 participants 7 messages Oct 24, 2014 – Nov 4, 2014

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

PATCH 1/1 mfd: tc6393xb fail ohci suspend if full state restore is required

Some boards with TC6393XB chip require full state restore during system resume thanks to chip's VCC being cut off during suspend (Sharp SL-6000 tosa is one of them). Failing to do so would result in ohci Oops on resume due to internal memory contentes being changed. Fail ohci suspend on tc6393xb is full state restore is required.

Recommended workaround is to unbind tmio-ohci driver before suspend and rebind it after resume.

---
 drivers/mfd/tc6393xb.c | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)
drivers/mfd/tc6393xb.c +12 -1
index 11c19e5..48579e5 100644
@@ -263,6 +263,17 @@ static int tc6393xb_ohci_disable(struct platform_device *dev)
 	return 0;
 }
 
+static int tc6393xb_ohci_suspend(struct platform_device *dev)
+{
+	struct tc6393xb_platform_data *tcpd = dev_get_platdata(dev->dev.parent);
+
+	/* We can't properly store/restore OHCI state, so fail here */
+	if (tcpd->resume_restore)
+		return -EBUSY;
+
+	return tc6393xb_ohci_disable(dev);
+}
+
 static int tc6393xb_fb_enable(struct platform_device *dev)
 {
 	struct tc6393xb *tc6393xb = dev_get_drvdata(dev->dev.parent);
@@ -403,7 +414,7 @@ static struct mfd_cell tc6393xb_cells[] = {
 		.num_resources = ARRAY_SIZE(tc6393xb_ohci_resources),
 		.resources = tc6393xb_ohci_resources,
 		.enable = tc6393xb_ohci_enable,
-		.suspend = tc6393xb_ohci_disable,
+		.suspend = tc6393xb_ohci_suspend,
 		.resume = tc6393xb_ohci_enable,
 		.disable = tc6393xb_ohci_disable,
 	},
Signature · 1 line
2.1.1
#1 lore raw

2014-10-24 20:19 GMT+03:00 Dmitry Eremin-Solenikov <[email protected]>:

Quoted 8 lines

Some boards with TC6393XB chip require full state restore during system resume thanks to chip's VCC being cut off during suspend (Sharp SL-6000 tosa is one of them). Failing to do so would result in ohci Oops on resume due to internal memory contentes being changed. Fail ohci suspend on tc6393xb is full state restore is required.

Recommended workaround is to unbind tmio-ohci driver before suspend and rebind it after resume.

ping

Quoted 6 lines
---
 drivers/mfd/tc6393xb.c | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)
Signature · 2 lines
With best wishes
Dmitry
#2 lore raw
Quoted 11 lines · Dmitry Eremin-Solenikov

2014-10-24 20:19 GMT+03:00 Dmitry Eremin-Solenikov <[email protected]>:

Quoted 8 lines

Some boards with TC6393XB chip require full state restore during system resume thanks to chip's VCC being cut off during suspend (Sharp SL-6000 tosa is one of them). Failing to do so would result in ohci Oops on resume due to internal memory contentes being changed. Fail ohci suspend on tc6393xb is full state restore is required.

Recommended workaround is to unbind tmio-ohci driver before suspend and rebind it after resume.

ping

Don't do that. If you think the patch has slipped through the net please sent it again with a [RESEND] tag in the email's subject line.

As it happens it hasn't been forgotten about, I was on vacation last week and will get round to reviewing this shortly.

Quoted 8 lines
Quoted 5 lines
---
 drivers/mfd/tc6393xb.c | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)
Signature · 4 lines
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
#3 lore raw
In reply to Dmitry Eremin-Solenikov
Quoted 20 lines · Dmitry Eremin-Solenikov

Some boards with TC6393XB chip require full state restore during system resume thanks to chip's VCC being cut off during suspend (Sharp SL-6000 tosa is one of them). Failing to do so would result in ohci Oops on resume due to internal memory contentes being changed. Fail ohci suspend on tc6393xb is full state restore is required.

Recommended workaround is to unbind tmio-ohci driver before suspend and rebind it after resume.

---
 drivers/mfd/tc6393xb.c | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)
drivers/mfd/tc6393xb.c +0 -0
index 11c19e5..48579e5 100644

drivers/mfd/tc6393xb.c static int tc6393xb_ohci_disable(struct platform_device *dev) · line 272

Quoted 10 lines
drivers/mfd/tc6393xb.c +7 -0
@@ -263,6 +263,17 @@ static int tc6393xb_ohci_disable(struct platform_device *dev)
 	return 0;
 }
 
+static int tc6393xb_ohci_suspend(struct platform_device *dev)
+{
+	struct tc6393xb_platform_data *tcpd = dev_get_platdata(dev->dev.parent);
+
+	/* We can't properly store/restore OHCI state, so fail here */
+	if (tcpd->resume_restore)
+		return -EBUSY;

Wouldn't it be easier to just put these three lines into tc6393xb_ohci_disable() instead off adding 7 superfluous lines and making the Ops names inconsistent?

Quoted 15 lines
drivers/mfd/tc6393xb.c +4 -1
+	return tc6393xb_ohci_disable(dev);
+}
+
 static int tc6393xb_fb_enable(struct platform_device *dev)
 {
 	struct tc6393xb *tc6393xb = dev_get_drvdata(dev->dev.parent);
@@ -403,7 +414,7 @@ static struct mfd_cell tc6393xb_cells[] = {
 		.num_resources = ARRAY_SIZE(tc6393xb_ohci_resources),
 		.resources = tc6393xb_ohci_resources,
 		.enable = tc6393xb_ohci_enable,
-		.suspend = tc6393xb_ohci_disable,
+		.suspend = tc6393xb_ohci_suspend,
 		.resume = tc6393xb_ohci_enable,
 		.disable = tc6393xb_ohci_disable,
 	},
Signature · 4 lines
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
#4 lore raw

Hello.

2014-11-03 17:56 GMT+03:00 Lee Jones <[email protected]>:

Quoted 25 lines · Dmitry Eremin-Solenikov
Quoted 24 lines

Some boards with TC6393XB chip require full state restore during system resume thanks to chip's VCC being cut off during suspend (Sharp SL-6000 tosa is one of them). Failing to do so would result in ohci Oops on resume due to internal memory contentes being changed. Fail ohci suspend on tc6393xb is full state restore is required.

Recommended workaround is to unbind tmio-ohci driver before suspend and rebind it after resume.

---
 drivers/mfd/tc6393xb.c | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)
drivers/mfd/tc6393xb.c +0 -0
index 11c19e5..48579e5 100644
@@ -263,6 +263,17 @@ static int tc6393xb_ohci_disable(struct platform_device *dev)
      return 0;
 }
 
Quoted 11 lines

drivers/mfd/tc6393xb.c static int tc6393xb_ohci_disable(struct platform_device *dev) · line 272

Quoted 7 lines
drivers/mfd/tc6393xb.c +7 -0
+static int tc6393xb_ohci_suspend(struct platform_device *dev)
+{
+     struct tc6393xb_platform_data *tcpd = dev_get_platdata(dev->dev.parent);
+
+     /* We can't properly store/restore OHCI state, so fail here */
+     if (tcpd->resume_restore)
+             return -EBUSY;

Wouldn't it be easier to just put these three lines into tc6393xb_ohci_disable() instead off adding 7 superfluous lines and making the Ops names inconsistent?

No. The problem only exists on suspend/resume path. tc6393xb_ohci_disable is also used on driver removal and can (should?) be used on device shutdown. Using the tc6393xb_ohci_disable() function in that paths is not a problem.

Also with this patch the Oops name will not be inconsistent - returning -EBUSY from this disable callback will cancel the device suspension with clearly stating
that OHCI is busy in dmesg.

Quoted 17 lines
Quoted 17 lines
drivers/mfd/tc6393xb.c +4 -1
+     return tc6393xb_ohci_disable(dev);
+}
+
 static int tc6393xb_fb_enable(struct platform_device *dev)
 {
      struct tc6393xb *tc6393xb = dev_get_drvdata(dev->dev.parent);
@@ -403,7 +414,7 @@ static struct mfd_cell tc6393xb_cells[] = {
              .num_resources = ARRAY_SIZE(tc6393xb_ohci_resources),
              .resources = tc6393xb_ohci_resources,
              .enable = tc6393xb_ohci_enable,
-             .suspend = tc6393xb_ohci_disable,
+             .suspend = tc6393xb_ohci_suspend,
              .resume = tc6393xb_ohci_enable,
              .disable = tc6393xb_ohci_disable,
      },
Signature · 2 lines
With best wishes
Dmitry
#5 lore raw
Quoted 40 lines · Dmitry Eremin-Solenikov

Hello.

2014-11-03 17:56 GMT+03:00 Lee Jones <[email protected]>:

Quoted 25 lines · Dmitry Eremin-Solenikov
Quoted 24 lines

Some boards with TC6393XB chip require full state restore during system resume thanks to chip's VCC being cut off during suspend (Sharp SL-6000 tosa is one of them). Failing to do so would result in ohci Oops on resume due to internal memory contentes being changed. Fail ohci suspend on tc6393xb is full state restore is required.

Recommended workaround is to unbind tmio-ohci driver before suspend and rebind it after resume.

---
 drivers/mfd/tc6393xb.c | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)
drivers/mfd/tc6393xb.c +0 -0
index 11c19e5..48579e5 100644
@@ -263,6 +263,17 @@ static int tc6393xb_ohci_disable(struct platform_device *dev)
      return 0;
 }
 
Quoted 11 lines

drivers/mfd/tc6393xb.c static int tc6393xb_ohci_disable(struct platform_device *dev) · line 272

Quoted 7 lines
drivers/mfd/tc6393xb.c +7 -0
+static int tc6393xb_ohci_suspend(struct platform_device *dev)
+{
+     struct tc6393xb_platform_data *tcpd = dev_get_platdata(dev->dev.parent);
+
+     /* We can't properly store/restore OHCI state, so fail here */
+     if (tcpd->resume_restore)
+             return -EBUSY;

Wouldn't it be easier to just put these three lines into tc6393xb_ohci_disable() instead off adding 7 superfluous lines and making the Ops names inconsistent?

Quoted 8 lines

No. The problem only exists on suspend/resume path. tc6393xb_ohci_disable is also used on driver removal and can (should?) be used on device shutdown. Using the tc6393xb_ohci_disable() function in that paths is not a problem.

Also with this patch the Oops name will not be inconsistent - returning -EBUSY from this disable callback will cancel the device suspension with clearly stating
that OHCI is busy in dmesg.

Understood. Thanks for the explanation.

Quoted 17 lines
Quoted 15 lines
Quoted 15 lines
drivers/mfd/tc6393xb.c +4 -1
+     return tc6393xb_ohci_disable(dev);
+}
+
 static int tc6393xb_fb_enable(struct platform_device *dev)
 {
      struct tc6393xb *tc6393xb = dev_get_drvdata(dev->dev.parent);
@@ -403,7 +414,7 @@ static struct mfd_cell tc6393xb_cells[] = {
              .num_resources = ARRAY_SIZE(tc6393xb_ohci_resources),
              .resources = tc6393xb_ohci_resources,
              .enable = tc6393xb_ohci_enable,
-             .suspend = tc6393xb_ohci_disable,
+             .suspend = tc6393xb_ohci_suspend,
              .resume = tc6393xb_ohci_enable,
              .disable = tc6393xb_ohci_disable,
      },
Signature · 4 lines
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
Applied
#6 lore raw
In reply to Dmitry Eremin-Solenikov
Quoted 6 lines · Dmitry Eremin-Solenikov

Some boards with TC6393XB chip require full state restore during system resume thanks to chip's VCC being cut off during suspend (Sharp SL-6000 tosa is one of them). Failing to do so would result in ohci Oops on resume due to internal memory contentes being changed. Fail ohci suspend on tc6393xb is full state restore is required.

Quoted 8 lines

Recommended workaround is to unbind tmio-ohci driver before suspend and rebind it after resume.

---
 drivers/mfd/tc6393xb.c | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

Applied, thanks.

Quoted 31 lines
drivers/mfd/tc6393xb.c +12 -1
index 11c19e5..48579e5 100644
@@ -263,6 +263,17 @@ static int tc6393xb_ohci_disable(struct platform_device *dev)
 	return 0;
 }
 
+static int tc6393xb_ohci_suspend(struct platform_device *dev)
+{
+	struct tc6393xb_platform_data *tcpd = dev_get_platdata(dev->dev.parent);
+
+	/* We can't properly store/restore OHCI state, so fail here */
+	if (tcpd->resume_restore)
+		return -EBUSY;
+
+	return tc6393xb_ohci_disable(dev);
+}
+
 static int tc6393xb_fb_enable(struct platform_device *dev)
 {
 	struct tc6393xb *tc6393xb = dev_get_drvdata(dev->dev.parent);
@@ -403,7 +414,7 @@ static struct mfd_cell tc6393xb_cells[] = {
 		.num_resources = ARRAY_SIZE(tc6393xb_ohci_resources),
 		.resources = tc6393xb_ohci_resources,
 		.enable = tc6393xb_ohci_enable,
-		.suspend = tc6393xb_ohci_disable,
+		.suspend = tc6393xb_ohci_suspend,
 		.resume = tc6393xb_ohci_enable,
 		.disable = tc6393xb_ohci_disable,
 	},
Signature · 4 lines
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog