All of lore.kernel.org
 help / color / mirror / Atom feed
From: Johan Hovold <johan@kernel.org>
To: "Ji-Ze Hong \(Peter Hong\)" <hpeter@gmail.com>
Cc: peter_hong@fintek.com.tw, johan@kernel.org,
	gregkh@linuxfoundation.org, linux-usb@vger.kernel.org,
	linux-kernel@vger.kernel.org,
	"Ji-Ze Hong \(Peter Hong\)" <hpeter+linux_kernel@gmail.com>,
	Oliver Neukum <oneukum@suse.com>
Subject: [V8,1/4] USB: serial: f81232: clear overrun flag
Date: Fri, 26 Apr 2019 08:23:12 +0200	[thread overview]
Message-ID: <20190426062312.GB12280@localhost> (raw)

On Fri, Apr 19, 2019 at 10:45:30AM +0800, Ji-Ze Hong (Peter Hong) wrote:
> The F81232 will report data and LSR with bulk like following format:
> bulk-in data: [LSR(1Byte)+DATA(1Byte)][LSR(1Byte)+DATA(1Byte)]...
> 
> LSR will auto clear frame/parity/break error flag when reading by H/W,
> but overrrun will only cleared when reading LSR. So this patch add a
> worker to read LSR when overrun and flush the worker on close() &
> suspend().
> 
> Cc: Oliver Neukum <oneukum@suse.com>
> Signed-off-by: Ji-Ze Hong (Peter Hong) <hpeter+linux_kernel@gmail.com>
> ---
> v8:
> 	1: Fix usb_submit_urb() in f81232_resume() with GFP_NOIO, not
> 	   GFP_KERNEL.
> 
> v7:
> 	1: Remove serial->suspending check
> 	2: Add port priv is_port_open to save port open state. We'll
> 	   register interrupt-in urb in f81232_resume() when port is
> 	   opened.
> 	3: Using usb_kill_urb for read/interrupt urb to ensure urb
> 	   stopped.

>  drivers/usb/serial/f81232.c | 97 +++++++++++++++++++++++++++++++++++++++++----
>  1 file changed, 89 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/usb/serial/f81232.c b/drivers/usb/serial/f81232.c
> index 0dcdcb4b2cde..1f0dd4087d79 100644
> --- a/drivers/usb/serial/f81232.c
> +++ b/drivers/usb/serial/f81232.c
> @@ -41,12 +41,15 @@ MODULE_DEVICE_TABLE(usb, id_table);
>  #define FIFO_CONTROL_REGISTER		(0x02 + SERIAL_BASE_ADDRESS)
>  #define LINE_CONTROL_REGISTER		(0x03 + SERIAL_BASE_ADDRESS)
>  #define MODEM_CONTROL_REGISTER		(0x04 + SERIAL_BASE_ADDRESS)
> +#define LINE_STATUS_REGISTER		(0x05 + SERIAL_BASE_ADDRESS)
>  #define MODEM_STATUS_REGISTER		(0x06 + SERIAL_BASE_ADDRESS)
>  
>  struct f81232_private {
>  	struct mutex lock;
>  	u8 modem_control;
>  	u8 modem_status;
> +	bool is_port_open;

This patch can be simplified by using the tty_port_initialized() macro
in resume instead of adding a new open flag. This is the common way USB
serial drivers deal with this and will allow a lot the new locking to go
away.

> +static int f81232_resume(struct usb_serial *serial)
> +{
> +	struct usb_serial_port *port = serial->port[0];
> +	struct f81232_private *port_priv = usb_get_serial_port_data(port);
> +	int result = 0;
> +
> +	mutex_lock(&port_priv->lock);
> +
> +	if (port_priv && port_priv->is_port_open) {
> +		result = usb_submit_urb(port->interrupt_in_urb, GFP_NOIO);
> +		if (result) {
> +			dev_err(&port->dev,
> +					"%s: submit interrupt urb failed: %d",
> +					__func__, result);

Missing '\n', also please drop the function prefix.

Johan

WARNING: multiple messages have this Message-ID (diff)
From: Johan Hovold <johan@kernel.org>
To: "Ji-Ze Hong (Peter Hong)" <hpeter@gmail.com>
Cc: peter_hong@fintek.com.tw, johan@kernel.org,
	gregkh@linuxfoundation.org, linux-usb@vger.kernel.org,
	linux-kernel@vger.kernel.org,
	"Ji-Ze Hong (Peter Hong)" <hpeter+linux_kernel@gmail.com>,
	Oliver Neukum <oneukum@suse.com>
Subject: Re: [PATCH V8 1/4] USB: serial: f81232: clear overrun flag
Date: Fri, 26 Apr 2019 08:23:12 +0200	[thread overview]
Message-ID: <20190426062312.GB12280@localhost> (raw)
Message-ID: <20190426062312.HG8mNehyFRe7H0IoGIaPWmUU4uOFUvCIr4NEu2VXZiM@z> (raw)
In-Reply-To: <1555641933-19336-1-git-send-email-hpeter+linux_kernel@gmail.com>

On Fri, Apr 19, 2019 at 10:45:30AM +0800, Ji-Ze Hong (Peter Hong) wrote:
> The F81232 will report data and LSR with bulk like following format:
> bulk-in data: [LSR(1Byte)+DATA(1Byte)][LSR(1Byte)+DATA(1Byte)]...
> 
> LSR will auto clear frame/parity/break error flag when reading by H/W,
> but overrrun will only cleared when reading LSR. So this patch add a
> worker to read LSR when overrun and flush the worker on close() &
> suspend().
> 
> Cc: Oliver Neukum <oneukum@suse.com>
> Signed-off-by: Ji-Ze Hong (Peter Hong) <hpeter+linux_kernel@gmail.com>
> ---
> v8:
> 	1: Fix usb_submit_urb() in f81232_resume() with GFP_NOIO, not
> 	   GFP_KERNEL.
> 
> v7:
> 	1: Remove serial->suspending check
> 	2: Add port priv is_port_open to save port open state. We'll
> 	   register interrupt-in urb in f81232_resume() when port is
> 	   opened.
> 	3: Using usb_kill_urb for read/interrupt urb to ensure urb
> 	   stopped.

>  drivers/usb/serial/f81232.c | 97 +++++++++++++++++++++++++++++++++++++++++----
>  1 file changed, 89 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/usb/serial/f81232.c b/drivers/usb/serial/f81232.c
> index 0dcdcb4b2cde..1f0dd4087d79 100644
> --- a/drivers/usb/serial/f81232.c
> +++ b/drivers/usb/serial/f81232.c
> @@ -41,12 +41,15 @@ MODULE_DEVICE_TABLE(usb, id_table);
>  #define FIFO_CONTROL_REGISTER		(0x02 + SERIAL_BASE_ADDRESS)
>  #define LINE_CONTROL_REGISTER		(0x03 + SERIAL_BASE_ADDRESS)
>  #define MODEM_CONTROL_REGISTER		(0x04 + SERIAL_BASE_ADDRESS)
> +#define LINE_STATUS_REGISTER		(0x05 + SERIAL_BASE_ADDRESS)
>  #define MODEM_STATUS_REGISTER		(0x06 + SERIAL_BASE_ADDRESS)
>  
>  struct f81232_private {
>  	struct mutex lock;
>  	u8 modem_control;
>  	u8 modem_status;
> +	bool is_port_open;

This patch can be simplified by using the tty_port_initialized() macro
in resume instead of adding a new open flag. This is the common way USB
serial drivers deal with this and will allow a lot the new locking to go
away.

> +static int f81232_resume(struct usb_serial *serial)
> +{
> +	struct usb_serial_port *port = serial->port[0];
> +	struct f81232_private *port_priv = usb_get_serial_port_data(port);
> +	int result = 0;
> +
> +	mutex_lock(&port_priv->lock);
> +
> +	if (port_priv && port_priv->is_port_open) {
> +		result = usb_submit_urb(port->interrupt_in_urb, GFP_NOIO);
> +		if (result) {
> +			dev_err(&port->dev,
> +					"%s: submit interrupt urb failed: %d",
> +					__func__, result);

Missing '\n', also please drop the function prefix.

Johan

             reply	other threads:[~2019-04-26  6:23 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-26  6:23 Johan Hovold [this message]
2019-04-26  6:23 ` [PATCH V8 1/4] USB: serial: f81232: clear overrun flag Johan Hovold
  -- strict thread matches above, loose matches on Subject: below --
2019-04-26  6:26 [V8,2/4] USB: serial: f81232: fix interrupt worker not stop Johan Hovold
2019-04-26  6:26 ` [PATCH V8 2/4] " Johan Hovold
2019-04-19  2:45 [V8,4/4] USB: serial: f81232: implement break control Ji-Ze Hong (Peter Hong)
2019-04-19  2:45 ` [PATCH V8 4/4] " Ji-Ze Hong (Peter Hong)
2019-04-19  2:45 [V8,3/4] USB: serial: f81232: add high baud rate support Ji-Ze Hong (Peter Hong)
2019-04-19  2:45 ` [PATCH V8 3/4] " Ji-Ze Hong (Peter Hong)
2019-04-19  2:45 [V8,2/4] USB: serial: f81232: fix interrupt worker not stop Ji-Ze Hong (Peter Hong)
2019-04-19  2:45 ` [PATCH V8 2/4] " Ji-Ze Hong (Peter Hong)
2019-04-19  2:45 [V8,1/4] USB: serial: f81232: clear overrun flag Ji-Ze Hong (Peter Hong)
2019-04-19  2:45 ` [PATCH V8 1/4] " Ji-Ze Hong (Peter Hong)

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190426062312.GB12280@localhost \
    --to=johan@kernel.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=hpeter+linux_kernel@gmail.com \
    --cc=hpeter@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=oneukum@suse.com \
    --cc=peter_hong@fintek.com.tw \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.