<feed xmlns='http://www.w3.org/2005/Atom'>
<title>kernel/linux.git/drivers/usb/serial/generic.c, branch v4.4.235</title>
<subtitle>Linux kernel stable tree (mirror)</subtitle>
<id>https://git.radix-linux.su/kernel/linux.git/atom?h=v4.4.235</id>
<link rel='self' href='https://git.radix-linux.su/kernel/linux.git/atom?h=v4.4.235'/>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/'/>
<updated>2019-05-16T17:45:16+00:00</updated>
<entry>
<title>USB: serial: fix unthrottle races</title>
<updated>2019-05-16T17:45:16+00:00</updated>
<author>
<name>Johan Hovold</name>
<email>johan@kernel.org</email>
</author>
<published>2019-04-25T16:05:36+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=27d9e822a71620d4a600a5694794ddf1d27385f7'/>
<id>urn:sha1:27d9e822a71620d4a600a5694794ddf1d27385f7</id>
<content type='text'>
[ Upstream commit 3f5edd58d040bfa4b74fb89bc02f0bc6b9cd06ab ]

Fix two long-standing bugs which could potentially lead to memory
corruption or leave the port throttled until it is reopened (on weakly
ordered systems), respectively, when read-URB completion races with
unthrottle().

First, the URB must not be marked as free before processing is complete
to prevent it from being submitted by unthrottle() on another CPU.

	CPU 1				CPU 2
	================		================
	complete()			unthrottle()
	  process_urb();
	  smp_mb__before_atomic();
	  set_bit(i, free);		  if (test_and_clear_bit(i, free))
	  					  submit_urb();

Second, the URB must be marked as free before checking the throttled
flag to prevent unthrottle() on another CPU from failing to observe that
the URB needs to be submitted if complete() sees that the throttled flag
is set.

	CPU 1				CPU 2
	================		================
	complete()			unthrottle()
	  set_bit(i, free);		  throttled = 0;
	  smp_mb__after_atomic();	  smp_mb();
	  if (throttled)		  if (test_and_clear_bit(i, free))
	  	  return;			  submit_urb();

Note that test_and_clear_bit() only implies barriers when the test is
successful. To handle the case where the URB is still in use an explicit
barrier needs to be added to unthrottle() for the second race condition.

Fixes: d83b405383c9 ("USB: serial: add support for multiple read urbs")
Signed-off-by: Johan Hovold &lt;johan@kernel.org&gt;
Signed-off-by: Sasha Levin &lt;sashal@kernel.org&gt;
</content>
</entry>
<entry>
<title>USB: serial: use variable for status</title>
<updated>2019-05-16T17:45:16+00:00</updated>
<author>
<name>Oliver Neukum</name>
<email>oneukum@suse.com</email>
</author>
<published>2016-07-14T13:01:40+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=f2387d0c34676524287e28ee8e87da45677afac6'/>
<id>urn:sha1:f2387d0c34676524287e28ee8e87da45677afac6</id>
<content type='text'>
[ Upstream commit 3161da970d38cd6ed2ba8cadec93874d1d06e11e ]

This patch turns status in a variable read once from the URB.
The long term plan is to deliver status to the callback.
In addition it makes the code a bit more elegant.

Signed-off-by: Oliver Neukum &lt;oneukum@suse.com&gt;
Signed-off-by: Johan Hovold &lt;johan@kernel.org&gt;
Signed-off-by: Sasha Levin &lt;sashal@kernel.org&gt;
</content>
</entry>
<entry>
<title>USB: serial: fix infinite wait_until_sent timeout</title>
<updated>2015-03-07T02:44:14+00:00</updated>
<author>
<name>Johan Hovold</name>
<email>johan@kernel.org</email>
</author>
<published>2015-03-04T09:39:05+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=f528bf4f57e43d1af4b2a5c97f09e43e0338c105'/>
<id>urn:sha1:f528bf4f57e43d1af4b2a5c97f09e43e0338c105</id>
<content type='text'>
Make sure to handle an infinite timeout (0).

Note that wait_until_sent is currently never called with a 0-timeout
argument due to a bug in tty_wait_until_sent.

Fixes: dcf010503966 ("USB: serial: add generic wait_until_sent
implementation")
Cc: stable &lt;stable@vger.kernel.org&gt;	# v3.10

Signed-off-by: Johan Hovold &lt;johan@kernel.org&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>usb: serial: handle -ENODEV quietly in generic_submit_read_urb</title>
<updated>2015-01-12T09:23:54+00:00</updated>
<author>
<name>Jeremiah Mahler</name>
<email>jmmahler@gmail.com</email>
</author>
<published>2015-01-11T13:42:07+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=04f9c6e6d17584340fb6c8a9469a0e6df28876d2'/>
<id>urn:sha1:04f9c6e6d17584340fb6c8a9469a0e6df28876d2</id>
<content type='text'>
If a USB serial device (e.g. /dev/ttyUSB0) with an active program is
unplugged, an -ENODEV (19) error will be produced after it gives up
trying to resubmit a read.

  usb_serial_generic_submit_read_urb - usb_submit_urb failed: -19

Add -ENODEV as one of the permanent errors along with -EPERM that
usb_serial_generic_submit_read_urb() handles quietly without an error.

Signed-off-by: Jeremiah Mahler &lt;jmmahler@gmail.com&gt;
Signed-off-by: Johan Hovold &lt;johan@kernel.org&gt;
</content>
</entry>
<entry>
<title>usb: serial: silence all non-critical read errors</title>
<updated>2015-01-12T09:23:35+00:00</updated>
<author>
<name>Jeremiah Mahler</name>
<email>jmmahler@gmail.com</email>
</author>
<published>2015-01-11T13:42:06+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=aa8e22128b40590b291cd13512098bf258a7e6c5'/>
<id>urn:sha1:aa8e22128b40590b291cd13512098bf258a7e6c5</id>
<content type='text'>
If a USB serial device is unplugged while there is an active program
using the device it may spam the logs with -EPROTO (71) messages as it
attempts to retry.

Most serial usb drivers (metro-usb, pl2303, mos7840, ...) only output
these messages for debugging.  The generic driver treats these as
errors.

Change the default output for the generic serial driver from error to
debug to silence these non-critical errors.

Signed-off-by: Jeremiah Mahler &lt;jmmahler@gmail.com&gt;
Signed-off-by: Johan Hovold &lt;johan@kernel.org&gt;
</content>
</entry>
<entry>
<title>USB: serial: add missing braces</title>
<updated>2014-03-12T19:44:50+00:00</updated>
<author>
<name>Johan Hovold</name>
<email>jhovold@gmail.com</email>
</author>
<published>2014-03-12T18:09:41+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=ca0400d2caf0d6f18445feea79c8c5a4ccf77e61'/>
<id>urn:sha1:ca0400d2caf0d6f18445feea79c8c5a4ccf77e61</id>
<content type='text'>
Add missing braces to conditional branches and one loop in usb-serial
core and generic implementation.

Signed-off-by: Johan Hovold &lt;jhovold@gmail.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;greg@kroah.com&gt;
</content>
</entry>
<entry>
<title>USB: serial: continue to write on errors</title>
<updated>2014-03-12T19:44:49+00:00</updated>
<author>
<name>Johan Hovold</name>
<email>jhovold@gmail.com</email>
</author>
<published>2014-03-12T18:09:40+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=bd58c7bd6fd5f803b4127717bda9cc6c30d0c806'/>
<id>urn:sha1:bd58c7bd6fd5f803b4127717bda9cc6c30d0c806</id>
<content type='text'>
Do not discard buffered data and make sure to try to resubmit the write
urbs on errors.

Currently a recoverable error would lead to more data than necessary
being dropped.

Also upgrade error messages from debug to error log level.

Signed-off-by: Johan Hovold &lt;jhovold@gmail.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;greg@kroah.com&gt;
</content>
</entry>
<entry>
<title>USB: serial: continue to read on errors</title>
<updated>2014-03-12T19:44:49+00:00</updated>
<author>
<name>Johan Hovold</name>
<email>jhovold@gmail.com</email>
</author>
<published>2014-03-12T18:09:39+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=fc11efe2800f2f9ba2ccb268321642b7e9f73a65'/>
<id>urn:sha1:fc11efe2800f2f9ba2ccb268321642b7e9f73a65</id>
<content type='text'>
Make sure to try to resubmit the read urb on errors.

Currently a recoverable error would lead to reduced throughput as only
one urb will be used until the port is closed and reopened (or
resumed or unthrottled).

Also upgrade error messages from debug to error log level.

Signed-off-by: Johan Hovold &lt;jhovold@gmail.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;greg@kroah.com&gt;
</content>
</entry>
<entry>
<title>USB: serial: fix write memory-allocation flag</title>
<updated>2013-11-25T16:39:40+00:00</updated>
<author>
<name>Johan Hovold</name>
<email>jhovold@gmail.com</email>
</author>
<published>2013-11-09T11:38:10+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=043e3f834530e15e89c58c1b7af59cc646700134'/>
<id>urn:sha1:043e3f834530e15e89c58c1b7af59cc646700134</id>
<content type='text'>
Fix regression introduced by commit 818f60365a29 ("USB: serial: add
memory flags to usb_serial_generic_write_start"), which incorrectly used
GFP_KERNEL in write(), which must not not sleep.

Reported-by: Dave Jones &lt;davej@fedoraproject.org&gt;
Tested-by: Dave Jones &lt;davej@fedoraproject.org&gt;
Cc: Dave Jones &lt;davej@fedoraproject.org&gt;
Signed-off-by: Johan Hovold &lt;jhovold@gmail.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>USB: serial: fix race in generic write</title>
<updated>2013-11-25T16:39:40+00:00</updated>
<author>
<name>Johan Hovold</name>
<email>jhovold@gmail.com</email>
</author>
<published>2013-11-09T11:38:09+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=6f6485463aada1ec6a0f3db6a03eb8e393d6bb55'/>
<id>urn:sha1:6f6485463aada1ec6a0f3db6a03eb8e393d6bb55</id>
<content type='text'>
Fix race in generic write implementation, which could lead to
temporarily degraded throughput.

The current generic write implementation introduced by commit
27c7acf22047 ("USB: serial: reimplement generic fifo-based writes") has
always had this bug, although it's fairly hard to trigger and the
consequences are not likely to be noticed.

Specifically, a write() on one CPU while the completion handler is
running on another could result in only one of the two write urbs being
utilised to empty the remainder of the write fifo (unless there is a
second write() that doesn't race during that time).

Cc: stable &lt;stable@vger.kernel.org&gt; # 2.6.35
Signed-off-by: Johan Hovold &lt;jhovold@gmail.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
</feed>
