public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Johan Hovold <jhovold@gmail.com>
To: Pete Zaitcev <zaitcev@redhat.com>, Greg KH <greg@kroah.com>
Cc: Stefani Seibold <stefani@seibold.net>,
	Johan Hovold <jhovold@gmail.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org
Subject: Re: USB: serial: kfifo_len locking
Date: Tue, 5 Jan 2010 12:04:18 +0100	[thread overview]
Message-ID: <20100105110418.GA10442@localhost> (raw)
In-Reply-To: <20100105004344.082bb69f@redhat.com>

> This actually was a side effect of the "byte lost on close" patch
> that I submitted, it should be in Greg's tree. The relevant part goes
> like this:
> diff --git a/drivers/usb/serial/generic.c b/drivers/usb/serial/generic.c
> index f1ea3a3..3372faa 100644
> --- a/drivers/usb/serial/generic.c
> +++ b/drivers/usb/serial/generic.c
> @@ -386,12 +386,15 @@ int usb_serial_generic_chars_in_buffer(struct tty_struct *tty)
>  
>  	dbg("%s - port %d", __func__, port->number);
>  
> +	spin_lock_irqsave(&port->lock, flags);
>  	if (serial->type->max_in_flight_urbs) {
> -		spin_lock_irqsave(&port->lock, flags);
>  		chars = port->tx_bytes_flight;
> -		spin_unlock_irqrestore(&port->lock, flags);
> -	} else if (serial->num_bulk_out)
> -		chars = kfifo_len(&port->write_fifo);
> +	} else if (serial->num_bulk_out) {
> +		/* This overcounts badly, but is good enough for drain wait. */
> +		chars = __kfifo_len(port->write_fifo);
> +		chars += port->write_urb_busy * port->bulk_out_size;
> +	}
> +	spin_unlock_irqrestore(&port->lock, flags);
>  
>  	dbg("%s - returns %d", __func__, chars);
>  	return chars;

That is indeed what you submitted on Dec 7, but this is what is in
Greg's tree:

http://git.kernel.org/?p=linux/kernel/git/gregkh/patches.git;a=blob;f=usb/usb-serial-mct_usb232-add-drain-on-close.patch;h=c464f1a82e93df0dd41762a8cb33b0b22e90cdd7;hb=1ea72e7c40b239c6b6f88a4993196be66fc3d892

38 --- a/drivers/usb/serial/generic.c
39 +++ b/drivers/usb/serial/generic.c
40 @@ -369,8 +369,11 @@ int usb_serial_generic_write_room(struct
41                         room = port->bulk_out_size *
42                                 (serial->type->max_in_flight_urbs -
43                                  port->urbs_in_flight);
44 -       } else if (serial->num_bulk_out)
45 +       } else if (serial->num_bulk_out) {
46 +               /* This overcounts badly, but is good enough for drain wait. */
47                 room = kfifo_avail(&port->write_fifo);
48 +               room += port->write_urb_busy * port->bulk_out_size;
49 +       }
50         spin_unlock_irqrestore(&port->lock, flags);
51  
52         dbg("%s - returns %d", __func__, room);


Which does not make any sense at all. Bad merge? What do you say Greg?

/Johan


  parent reply	other threads:[~2010-01-05 11:04 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-01-04 17:43 USB: serial: kfifo_len locking Johan Hovold
2010-01-04 19:20 ` Stefani Seibold
2010-01-05  7:43   ` Pete Zaitcev
2010-01-05  7:51     ` Stefani Seibold
2010-01-05 11:04     ` Johan Hovold [this message]
2010-01-05 11:09       ` Stefani Seibold
2010-01-05 11:14         ` Johan Hovold
2010-01-05 11:25           ` Stefani Seibold
2010-01-05 11:35             ` Johan Hovold
2010-01-05 12:01               ` Stefani Seibold
2010-01-05 12:10                 ` Johan Hovold
2010-01-05 13:30                 ` [tip:urgent] fix USB serial fix " Stefani Seibold
2010-01-05 14:32                   ` Greg KH
2010-01-05 13:38                 ` [tip:urgent] fix kfifo_out_locked race bug Stefani Seibold
2010-01-08 23:18                   ` Andrew Morton
2010-01-05 17:00         ` USB: serial: kfifo_len locking Pete Zaitcev

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=20100105110418.GA10442@localhost \
    --to=jhovold@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=greg@kroah.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=stefani@seibold.net \
    --cc=zaitcev@redhat.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox