All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/3] musb fixes backport to v4.9+
@ 2018-04-23 17:41 Bin Liu
  2018-04-23 17:41   ` [1/3] " Bin Liu
                   ` (3 more replies)
  0 siblings, 4 replies; 8+ messages in thread
From: Bin Liu @ 2018-04-23 17:41 UTC (permalink / raw)
  To: stable; +Cc: linux-usb, Bin Liu

Hi,

Here are several patches backported to v4.9+ to fix runtime PM problems in musb
drivers.

Regards,
-Bin.
----

Andreas Kemnade (1):
  usb: musb: fix enumeration after resume

Merlijn Wajer (2):
  usb: musb: call pm_runtime_{get,put}_sync before reading vbus registers
  usb: musb: Fix external abort in musb_remove on omap2430

 drivers/usb/musb/musb_core.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

-- 
1.9.1

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH 1/3] usb: musb: fix enumeration after resume
@ 2018-04-23 17:41   ` Bin Liu
  0 siblings, 0 replies; 8+ messages in thread
From: Bin Liu @ 2018-04-23 17:41 UTC (permalink / raw)
  To: stable; +Cc: linux-usb, Bin Liu

From: Andreas Kemnade <andreas@kemnade.info>

commit 17539f2f4f0b7fa906b508765c8ada07a1e45f52 upstream.

On dm3730 there are enumeration problems after resume.
Investigation led to the cause that the MUSB_POWER_SOFTCONN
bit is not set. If it was set before suspend (because it
was enabled via musb_pullup()), it is set in
musb_restore_context() so the pullup is enabled. But then
musb_start() is called which overwrites MUSB_POWER and
therefore disables MUSB_POWER_SOFTCONN, so no pullup is
enabled and the device is not enumerated.

So let's do a subset of what musb_start() does
in the same way as musb_suspend() does it. Platform-specific
stuff it still called as there might be some phy-related stuff
which needs to be enabled.
Also interrupts are enabled, as it was the original idea
of calling musb_start() in musb_resume() according to
Commit 6fc6f4b87cb3 ("usb: musb: Disable interrupts on suspend,
enable them on resume")

Cc: stable@vger.kernel.org # v4.9+
Signed-off-by: Andreas Kemnade <andreas@kemnade.info>
Tested-by: Tony Lindgren <tony@atomide.com>
Signed-off-by: Bin Liu <b-liu@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 drivers/usb/musb/musb_core.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c
index 2d9a8067eaca..0736cc27b5e7 100644
--- a/drivers/usb/musb/musb_core.c
+++ b/drivers/usb/musb/musb_core.c
@@ -2710,7 +2710,8 @@ static int musb_resume(struct device *dev)
 	if ((devctl & mask) != (musb->context.devctl & mask))
 		musb->port1_status = 0;
 
-	musb_start(musb);
+	musb_enable_interrupts(musb);
+	musb_platform_enable(musb);
 
 	spin_lock_irqsave(&musb->lock, flags);
 	error = musb_run_resume_work(musb);
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [1/3] usb: musb: fix enumeration after resume
@ 2018-04-23 17:41   ` Bin Liu
  0 siblings, 0 replies; 8+ messages in thread
From: Bin Liu @ 2018-04-23 17:41 UTC (permalink / raw)
  To: stable; +Cc: linux-usb, Bin Liu

From: Andreas Kemnade <andreas@kemnade.info>

commit 17539f2f4f0b7fa906b508765c8ada07a1e45f52 upstream.

On dm3730 there are enumeration problems after resume.
Investigation led to the cause that the MUSB_POWER_SOFTCONN
bit is not set. If it was set before suspend (because it
was enabled via musb_pullup()), it is set in
musb_restore_context() so the pullup is enabled. But then
musb_start() is called which overwrites MUSB_POWER and
therefore disables MUSB_POWER_SOFTCONN, so no pullup is
enabled and the device is not enumerated.

So let's do a subset of what musb_start() does
in the same way as musb_suspend() does it. Platform-specific
stuff it still called as there might be some phy-related stuff
which needs to be enabled.
Also interrupts are enabled, as it was the original idea
of calling musb_start() in musb_resume() according to
Commit 6fc6f4b87cb3 ("usb: musb: Disable interrupts on suspend,
enable them on resume")

Cc: stable@vger.kernel.org # v4.9+
Signed-off-by: Andreas Kemnade <andreas@kemnade.info>
Tested-by: Tony Lindgren <tony@atomide.com>
Signed-off-by: Bin Liu <b-liu@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 drivers/usb/musb/musb_core.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c
index 2d9a8067eaca..0736cc27b5e7 100644
--- a/drivers/usb/musb/musb_core.c
+++ b/drivers/usb/musb/musb_core.c
@@ -2710,7 +2710,8 @@ static int musb_resume(struct device *dev)
 	if ((devctl & mask) != (musb->context.devctl & mask))
 		musb->port1_status = 0;
 
-	musb_start(musb);
+	musb_enable_interrupts(musb);
+	musb_platform_enable(musb);
 
 	spin_lock_irqsave(&musb->lock, flags);
 	error = musb_run_resume_work(musb);

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 2/3] usb: musb: call pm_runtime_{get,put}_sync before reading vbus registers
@ 2018-04-23 17:41   ` Bin Liu
  0 siblings, 0 replies; 8+ messages in thread
From: Bin Liu @ 2018-04-23 17:41 UTC (permalink / raw)
  To: stable; +Cc: linux-usb, Bin Liu

From: Merlijn Wajer <merlijn@wizzup.org>

commit df6b074dbe248d8c43a82131e8fd429e401841a5 upstream.

Without pm_runtime_{get,put}_sync calls in place, reading
vbus status via /sys causes the following error:

Unhandled fault: external abort on non-linefetch (0x1028) at 0xfa0ab060
pgd = b333e822
[fa0ab060] *pgd=48011452(bad)

[<c05261b0>] (musb_default_readb) from [<c0525bd0>] (musb_vbus_show+0x58/0xe4)
[<c0525bd0>] (musb_vbus_show) from [<c04c0148>] (dev_attr_show+0x20/0x44)
[<c04c0148>] (dev_attr_show) from [<c0259f74>] (sysfs_kf_seq_show+0x80/0xdc)
[<c0259f74>] (sysfs_kf_seq_show) from [<c0210bac>] (seq_read+0x250/0x448)
[<c0210bac>] (seq_read) from [<c01edb40>] (__vfs_read+0x1c/0x118)
[<c01edb40>] (__vfs_read) from [<c01edccc>] (vfs_read+0x90/0x144)
[<c01edccc>] (vfs_read) from [<c01ee1d0>] (SyS_read+0x3c/0x74)
[<c01ee1d0>] (SyS_read) from [<c0106fe0>] (ret_fast_syscall+0x0/0x54)

Solution was suggested by Tony Lindgren <tony@atomide.com>.

Cc: stable@vger.kernel.org # v4.9+
Signed-off-by: Merlijn Wajer <merlijn@wizzup.org>
Acked-by: Tony Lindgren <tony@atomide.com>
Signed-off-by: Bin Liu <b-liu@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 drivers/usb/musb/musb_core.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c
index 0736cc27b5e7..d4c9e9544ba0 100644
--- a/drivers/usb/musb/musb_core.c
+++ b/drivers/usb/musb/musb_core.c
@@ -1774,6 +1774,7 @@ int musb_mailbox(enum musb_vbus_id_status status)
 	int		vbus;
 	u8		devctl;
 
+	pm_runtime_get_sync(dev);
 	spin_lock_irqsave(&musb->lock, flags);
 	val = musb->a_wait_bcon;
 	vbus = musb_platform_get_vbus_status(musb);
@@ -1787,6 +1788,7 @@ int musb_mailbox(enum musb_vbus_id_status status)
 			vbus = 0;
 	}
 	spin_unlock_irqrestore(&musb->lock, flags);
+	pm_runtime_put_sync(dev);
 
 	return sprintf(buf, "Vbus %s, timeout %lu msec\n",
 			vbus ? "on" : "off", val);
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [2/3] usb: musb: call pm_runtime_{get,put}_sync before reading vbus registers
@ 2018-04-23 17:41   ` Bin Liu
  0 siblings, 0 replies; 8+ messages in thread
From: Bin Liu @ 2018-04-23 17:41 UTC (permalink / raw)
  To: stable; +Cc: linux-usb, Bin Liu

From: Merlijn Wajer <merlijn@wizzup.org>

commit df6b074dbe248d8c43a82131e8fd429e401841a5 upstream.

Without pm_runtime_{get,put}_sync calls in place, reading
vbus status via /sys causes the following error:

Unhandled fault: external abort on non-linefetch (0x1028) at 0xfa0ab060
pgd = b333e822
[fa0ab060] *pgd=48011452(bad)

[<c05261b0>] (musb_default_readb) from [<c0525bd0>] (musb_vbus_show+0x58/0xe4)
[<c0525bd0>] (musb_vbus_show) from [<c04c0148>] (dev_attr_show+0x20/0x44)
[<c04c0148>] (dev_attr_show) from [<c0259f74>] (sysfs_kf_seq_show+0x80/0xdc)
[<c0259f74>] (sysfs_kf_seq_show) from [<c0210bac>] (seq_read+0x250/0x448)
[<c0210bac>] (seq_read) from [<c01edb40>] (__vfs_read+0x1c/0x118)
[<c01edb40>] (__vfs_read) from [<c01edccc>] (vfs_read+0x90/0x144)
[<c01edccc>] (vfs_read) from [<c01ee1d0>] (SyS_read+0x3c/0x74)
[<c01ee1d0>] (SyS_read) from [<c0106fe0>] (ret_fast_syscall+0x0/0x54)

Solution was suggested by Tony Lindgren <tony@atomide.com>.

Cc: stable@vger.kernel.org # v4.9+
Signed-off-by: Merlijn Wajer <merlijn@wizzup.org>
Acked-by: Tony Lindgren <tony@atomide.com>
Signed-off-by: Bin Liu <b-liu@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 drivers/usb/musb/musb_core.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c
index 0736cc27b5e7..d4c9e9544ba0 100644
--- a/drivers/usb/musb/musb_core.c
+++ b/drivers/usb/musb/musb_core.c
@@ -1774,6 +1774,7 @@ int musb_mailbox(enum musb_vbus_id_status status)
 	int		vbus;
 	u8		devctl;
 
+	pm_runtime_get_sync(dev);
 	spin_lock_irqsave(&musb->lock, flags);
 	val = musb->a_wait_bcon;
 	vbus = musb_platform_get_vbus_status(musb);
@@ -1787,6 +1788,7 @@ int musb_mailbox(enum musb_vbus_id_status status)
 			vbus = 0;
 	}
 	spin_unlock_irqrestore(&musb->lock, flags);
+	pm_runtime_put_sync(dev);
 
 	return sprintf(buf, "Vbus %s, timeout %lu msec\n",
 			vbus ? "on" : "off", val);

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 3/3] usb: musb: Fix external abort in musb_remove on omap2430
@ 2018-04-23 17:41   ` Bin Liu
  0 siblings, 0 replies; 8+ messages in thread
From: Bin Liu @ 2018-04-23 17:41 UTC (permalink / raw)
  To: stable; +Cc: linux-usb, Bin Liu

From: Merlijn Wajer <merlijn@wizzup.org>

commit 94e46a4f2d5eb14059e42f313c098d4854847376 upstream.

This fixes an oops on unbind / module unload (on the musb omap2430
platform).

musb_remove function now calls musb_platform_exit before disabling
runtime pm.

Cc: stable@vger.kernel.org # v4.9+
Signed-off-by: Merlijn Wajer <merlijn@wizzup.org>
Signed-off-by: Bin Liu <b-liu@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 drivers/usb/musb/musb_core.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c
index d4c9e9544ba0..579aa9accafc 100644
--- a/drivers/usb/musb/musb_core.c
+++ b/drivers/usb/musb/musb_core.c
@@ -2485,10 +2485,11 @@ static int musb_remove(struct platform_device *pdev)
 	musb_generic_disable(musb);
 	spin_unlock_irqrestore(&musb->lock, flags);
 	musb_writeb(musb->mregs, MUSB_DEVCTL, 0);
+	musb_platform_exit(musb);
+
 	pm_runtime_dont_use_autosuspend(musb->controller);
 	pm_runtime_put_sync(musb->controller);
 	pm_runtime_disable(musb->controller);
-	musb_platform_exit(musb);
 	musb_phy_callback = NULL;
 	if (musb->dma_controller)
 		musb_dma_controller_destroy(musb->dma_controller);
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [3/3] usb: musb: Fix external abort in musb_remove on omap2430
@ 2018-04-23 17:41   ` Bin Liu
  0 siblings, 0 replies; 8+ messages in thread
From: Bin Liu @ 2018-04-23 17:41 UTC (permalink / raw)
  To: stable; +Cc: linux-usb, Bin Liu

From: Merlijn Wajer <merlijn@wizzup.org>

commit 94e46a4f2d5eb14059e42f313c098d4854847376 upstream.

This fixes an oops on unbind / module unload (on the musb omap2430
platform).

musb_remove function now calls musb_platform_exit before disabling
runtime pm.

Cc: stable@vger.kernel.org # v4.9+
Signed-off-by: Merlijn Wajer <merlijn@wizzup.org>
Signed-off-by: Bin Liu <b-liu@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 drivers/usb/musb/musb_core.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c
index d4c9e9544ba0..579aa9accafc 100644
--- a/drivers/usb/musb/musb_core.c
+++ b/drivers/usb/musb/musb_core.c
@@ -2485,10 +2485,11 @@ static int musb_remove(struct platform_device *pdev)
 	musb_generic_disable(musb);
 	spin_unlock_irqrestore(&musb->lock, flags);
 	musb_writeb(musb->mregs, MUSB_DEVCTL, 0);
+	musb_platform_exit(musb);
+
 	pm_runtime_dont_use_autosuspend(musb->controller);
 	pm_runtime_put_sync(musb->controller);
 	pm_runtime_disable(musb->controller);
-	musb_platform_exit(musb);
 	musb_phy_callback = NULL;
 	if (musb->dma_controller)
 		musb_dma_controller_destroy(musb->dma_controller);

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH 0/3] musb fixes backport to v4.9+
  2018-04-23 17:41 [PATCH 0/3] musb fixes backport to v4.9+ Bin Liu
                   ` (2 preceding siblings ...)
  2018-04-23 17:41   ` [3/3] " Bin Liu
@ 2018-04-24 11:57 ` Greg KH
  3 siblings, 0 replies; 8+ messages in thread
From: Greg KH @ 2018-04-24 11:57 UTC (permalink / raw)
  To: Bin Liu; +Cc: stable, linux-usb

On Mon, Apr 23, 2018 at 12:41:12PM -0500, Bin Liu wrote:
> Hi,
> 
> Here are several patches backported to v4.9+ to fix runtime PM problems in musb
> drivers.

All now applied, thanks.

greg k-h

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2018-04-24 11:58 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-04-23 17:41 [PATCH 0/3] musb fixes backport to v4.9+ Bin Liu
2018-04-23 17:41 ` [PATCH 1/3] usb: musb: fix enumeration after resume Bin Liu
2018-04-23 17:41   ` [1/3] " Bin Liu
2018-04-23 17:41 ` [PATCH 2/3] usb: musb: call pm_runtime_{get,put}_sync before reading vbus registers Bin Liu
2018-04-23 17:41   ` [2/3] " Bin Liu
2018-04-23 17:41 ` [PATCH 3/3] usb: musb: Fix external abort in musb_remove on omap2430 Bin Liu
2018-04-23 17:41   ` [3/3] " Bin Liu
2018-04-24 11:57 ` [PATCH 0/3] musb fixes backport to v4.9+ Greg KH

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.