Linux USB
 help / color / mirror / Atom feed
* [PATCH V2 0/1] usb: mos7840: Fix hangup after resume
@ 2024-06-09 22:58 Dmitry Smirnov
  2024-06-09 22:58 ` [PATCH V2 1/1] " Dmitry Smirnov
  0 siblings, 1 reply; 4+ messages in thread
From: Dmitry Smirnov @ 2024-06-09 22:58 UTC (permalink / raw)
  To: linux-usb; +Cc: Dmitry Smirnov

This patch addresses a kernel hang issue with the mos7840 driver when
resuming from a suspend with a device connected to the serial port.

This patch introduces two new functions: mos7840_suspend() and mos7840_resume()

Tested with Delock 87414 USB 2.0 to 4x serial adapter.

Signed-off-by: Dmitry Smirnov <d.smirnov@inbox.lv>
---
V1 -> V2: Addressed review comments

Dmitry Smirnov (1):
  usb: mos7840: Fix hangup after resume

 drivers/usb/serial/mos7840.c | 50 ++++++++++++++++++++++++++++++++++++
 1 file changed, 50 insertions(+)


base-commit: c3f38fa61af77b49866b006939479069cd451173
-- 
2.45.1


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

* [PATCH V2 1/1] usb: mos7840: Fix hangup after resume
  2024-06-09 22:58 [PATCH V2 0/1] usb: mos7840: Fix hangup after resume Dmitry Smirnov
@ 2024-06-09 22:58 ` Dmitry Smirnov
  2024-06-10  4:39   ` Greg KH
  2024-06-10  7:38   ` Sergey Shtylyov
  0 siblings, 2 replies; 4+ messages in thread
From: Dmitry Smirnov @ 2024-06-09 22:58 UTC (permalink / raw)
  To: linux-usb; +Cc: Dmitry Smirnov

Signed-off-by: Dmitry Smirnov <d.smirnov@inbox.lv>
---
V1 -> V2: Addressed review comments

 drivers/usb/serial/mos7840.c | 50 ++++++++++++++++++++++++++++++++++++
 1 file changed, 50 insertions(+)

diff --git a/drivers/usb/serial/mos7840.c b/drivers/usb/serial/mos7840.c
index 8b0308d84270..30c5b09a4409 100644
--- a/drivers/usb/serial/mos7840.c
+++ b/drivers/usb/serial/mos7840.c
@@ -1737,6 +1737,54 @@ static void mos7840_port_remove(struct usb_serial_port *port)
 	kfree(mos7840_port);
 }
 
+static int mos7840_suspend(struct usb_serial *serial, pm_message_t message)
+{
+	struct moschip_port *mos7840_port;
+	struct usb_serial_port *port;
+	int i;
+	dev_dbg(&serial->interface->dev, "mos7840_suspend\n");
+
+	for (i = 0; i < serial->num_ports; ++i) {
+		port = serial->port[i];
+		if (!tty_port_initialized(&port->port))
+			continue;
+
+		mos7840_port = usb_get_serial_port_data(port);
+
+		usb_kill_urb(mos7840_port->read_urb);
+		mos7840_port->read_urb_busy = false;
+	}
+	return 0;
+}
+
+static int mos7840_resume(struct usb_serial *serial)
+{
+	struct moschip_port *mos7840_port;
+	struct usb_serial_port *port;
+	int res;
+	int i;
+	dev_dbg(&serial->interface->dev, "mos7840_resume\n");
+
+	for (i = 0; i < serial->num_ports; ++i) {
+		port = serial->port[i];
+		if (!tty_port_initialized(&port->port))
+			continue;
+
+		mos7840_port = usb_get_serial_port_data(port);
+
+		if (port->bulk_in_size) {
+			res = usb_submit_urb(mos7840_port->read_urb, GFP_NOIO);
+
+			if (res) {
+				usb_kill_urb(mos7840_port->read_urb);
+				mos7840_port->read_urb_busy = false;
+			}
+		}
+	}
+
+	return 0;
+}
+
 static struct usb_serial_driver moschip7840_4port_device = {
 	.driver = {
 		   .owner = THIS_MODULE,
@@ -1764,6 +1812,8 @@ static struct usb_serial_driver moschip7840_4port_device = {
 	.port_probe = mos7840_port_probe,
 	.port_remove = mos7840_port_remove,
 	.read_bulk_callback = mos7840_bulk_in_callback,
+	.suspend = mos7840_suspend,
+	.resume = mos7840_resume,
 };
 
 static struct usb_serial_driver * const serial_drivers[] = {
-- 
2.45.1


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

* Re: [PATCH V2 1/1] usb: mos7840: Fix hangup after resume
  2024-06-09 22:58 ` [PATCH V2 1/1] " Dmitry Smirnov
@ 2024-06-10  4:39   ` Greg KH
  2024-06-10  7:38   ` Sergey Shtylyov
  1 sibling, 0 replies; 4+ messages in thread
From: Greg KH @ 2024-06-10  4:39 UTC (permalink / raw)
  To: Dmitry Smirnov; +Cc: linux-usb

On Mon, Jun 10, 2024 at 01:58:50AM +0300, Dmitry Smirnov wrote:
> Signed-off-by: Dmitry Smirnov <d.smirnov@inbox.lv>
> ---

Sorry, but we can't take patches with no changelog text for obvious
reasons.

greg k-h

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

* Re: [PATCH V2 1/1] usb: mos7840: Fix hangup after resume
  2024-06-09 22:58 ` [PATCH V2 1/1] " Dmitry Smirnov
  2024-06-10  4:39   ` Greg KH
@ 2024-06-10  7:38   ` Sergey Shtylyov
  1 sibling, 0 replies; 4+ messages in thread
From: Sergey Shtylyov @ 2024-06-10  7:38 UTC (permalink / raw)
  To: Dmitry Smirnov, linux-usb

On 6/10/24 1:58 AM, Dmitry Smirnov wrote:

   No description?

> Signed-off-by: Dmitry Smirnov <d.smirnov@inbox.lv>
> ---
> V1 -> V2: Addressed review comments

   I think this won't do, you need to be more detailed.

>  drivers/usb/serial/mos7840.c | 50 ++++++++++++++++++++++++++++++++++++
>  1 file changed, 50 insertions(+)
> 
> diff --git a/drivers/usb/serial/mos7840.c b/drivers/usb/serial/mos7840.c
> index 8b0308d84270..30c5b09a4409 100644
> --- a/drivers/usb/serial/mos7840.c
> +++ b/drivers/usb/serial/mos7840.c
> @@ -1737,6 +1737,54 @@ static void mos7840_port_remove(struct usb_serial_port *port)
>  	kfree(mos7840_port);
>  }
>  
> +static int mos7840_suspend(struct usb_serial *serial, pm_message_t message)
> +{
> +	struct moschip_port *mos7840_port;
> +	struct usb_serial_port *port;
> +	int i;

   You need an empty line here...

> +	dev_dbg(&serial->interface->dev, "mos7840_suspend\n");
> +
[...]
> +static int mos7840_resume(struct usb_serial *serial)
> +{
> +	struct moschip_port *mos7840_port;
> +	struct usb_serial_port *port;
> +	int res;
> +	int i;

   And here...

> +	dev_dbg(&serial->interface->dev, "mos7840_resume\n");
> +
> +	for (i = 0; i < serial->num_ports; ++i) {
> +		port = serial->port[i];
> +		if (!tty_port_initialized(&port->port))
> +			continue;
> +
> +		mos7840_port = usb_get_serial_port_data(port);
> +
> +		if (port->bulk_in_size) {
> +			res = usb_submit_urb(mos7840_port->read_urb, GFP_NOIO);

   Contrariwise, the empty line here doesn't seem justified.

> +
> +			if (res) {
> +				usb_kill_urb(mos7840_port->read_urb);
> +				mos7840_port->read_urb_busy = false;
> +			}
> +		}
> +	}
> +
> +	return 0;
> +}
> +
>  static struct usb_serial_driver moschip7840_4port_device = {
>  	.driver = {
>  		   .owner = THIS_MODULE,
[...]

MBR, Sergey

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

end of thread, other threads:[~2024-06-10  7:38 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-06-09 22:58 [PATCH V2 0/1] usb: mos7840: Fix hangup after resume Dmitry Smirnov
2024-06-09 22:58 ` [PATCH V2 1/1] " Dmitry Smirnov
2024-06-10  4:39   ` Greg KH
2024-06-10  7:38   ` Sergey Shtylyov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox