<feed xmlns='http://www.w3.org/2005/Atom'>
<title>kernel.git/net/bluetooth/rfcomm/tty.c, branch linux-3.14.y</title>
<subtitle>Hosts the 0x221E linux distro kernel.
</subtitle>
<id>https://git.0xinfinity.dev/distro/kernel.git/atom?h=linux-3.14.y</id>
<link rel='self' href='https://git.0xinfinity.dev/distro/kernel.git/atom?h=linux-3.14.y'/>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/'/>
<updated>2014-01-06T21:51:45Z</updated>
<entry>
<title>Bluetooth: Remove rfcomm_carrier_raised()</title>
<updated>2014-01-06T21:51:45Z</updated>
<author>
<name>Gianluca Anzolin</name>
</author>
<published>2014-01-06T20:23:53Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=f86772af6a0f643d3e13eb3f4f9213ae0c333ee4'/>
<id>urn:sha1:f86772af6a0f643d3e13eb3f4f9213ae0c333ee4</id>
<content type='text'>
Remove the rfcomm_carrier_raised() definition as that function isn't
used anymore.

Signed-off-by: Gianluca Anzolin &lt;gianluca@sottospazio.it&gt;
Signed-off-by: Marcel Holtmann &lt;marcel@holtmann.org&gt;
</content>
</entry>
<entry>
<title>Bluetooth: Always wait for a connection on RFCOMM open()</title>
<updated>2014-01-06T21:51:45Z</updated>
<author>
<name>Gianluca Anzolin</name>
</author>
<published>2014-01-06T20:23:52Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=4a2fb3ecc7467c775b154813861f25a0ddc11aa0'/>
<id>urn:sha1:4a2fb3ecc7467c775b154813861f25a0ddc11aa0</id>
<content type='text'>
This patch fixes two regressions introduced with the recent rfcomm tty
rework.

The current code uses the carrier_raised() method to wait for the
bluetooth connection when a process opens the tty.

However processes may open the port with the O_NONBLOCK flag or set the
CLOCAL termios flag: in these cases the open() syscall returns
immediately without waiting for the bluetooth connection to
complete.

This behaviour confuses userspace which expects an established bluetooth
connection.

The patch restores the old behaviour by waiting for the connection in
rfcomm_dev_activate() and removes carrier_raised() from the tty_port ops.

As a side effect the new code also fixes the case in which the rfcomm
tty device is created with the flag RFCOMM_REUSE_DLC: the old code
didn't call device_move() and ModemManager skipped the detection
probe. Now device_move() is always called inside rfcomm_dev_activate().

Signed-off-by: Gianluca Anzolin &lt;gianluca@sottospazio.it&gt;
Reported-by: Andrey Vihrov &lt;andrey.vihrov@gmail.com&gt;
Reported-by: Beson Chow &lt;blc+bluez@mail.vanade.com&gt;
Signed-off-by: Marcel Holtmann &lt;marcel@holtmann.org&gt;
</content>
</entry>
<entry>
<title>Bluetooth: Move rfcomm_get_device() before rfcomm_dev_activate()</title>
<updated>2014-01-06T21:51:45Z</updated>
<author>
<name>Gianluca Anzolin</name>
</author>
<published>2014-01-06T20:23:51Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=e228b63390536f5b737056059a9a04ea016b1abf'/>
<id>urn:sha1:e228b63390536f5b737056059a9a04ea016b1abf</id>
<content type='text'>
This is a preparatory patch which moves the rfcomm_get_device()
definition before rfcomm_dev_activate() where it will be used.

Signed-off-by: Gianluca Anzolin &lt;gianluca@sottospazio.it&gt;
Signed-off-by: Marcel Holtmann &lt;marcel@holtmann.org&gt;
</content>
</entry>
<entry>
<title>Bluetooth: Release RFCOMM port when the last user closes the TTY</title>
<updated>2014-01-06T21:51:45Z</updated>
<author>
<name>Gianluca Anzolin</name>
</author>
<published>2014-01-06T20:23:50Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=5b899241874dcc1a2b932a668731c80a3a869575'/>
<id>urn:sha1:5b899241874dcc1a2b932a668731c80a3a869575</id>
<content type='text'>
This patch fixes a userspace regression introduced by the commit
29cd718b.

If the rfcomm device was created with the flag RFCOMM_RELEASE_ONHUP the
user space expects that the tty_port is released as soon as the last
process closes the tty.

The current code attempts to release the port in the function
rfcomm_dev_state_change(). However it won't get a reference to the
relevant tty to send a HUP: at that point the tty is already destroyed
and therefore NULL.

This patch fixes the regression by taking over the tty refcount in the
tty install method(). This way the tty_port is automatically released as
soon as the tty is destroyed.

As a consequence the check for RFCOMM_RELEASE_ONHUP flag in the hangup()
method is now redundant. Instead we have to be careful with the reference
counting in the rfcomm_release_dev() function.

Signed-off-by: Gianluca Anzolin &lt;gianluca@sottospazio.it&gt;
Reported-by: Alexander Holler &lt;holler@ahsoftware.de&gt;
Signed-off-by: Marcel Holtmann &lt;marcel@holtmann.org&gt;
</content>
</entry>
<entry>
<title>Bluetooth: don't release the port in rfcomm_dev_state_change()</title>
<updated>2013-09-20T19:17:54Z</updated>
<author>
<name>Gianluca Anzolin</name>
</author>
<published>2013-08-27T16:28:46Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=29cd718beba999bda4bdbbf59b5a4d25c07e1547'/>
<id>urn:sha1:29cd718beba999bda4bdbbf59b5a4d25c07e1547</id>
<content type='text'>
When the dlc is closed, rfcomm_dev_state_change() tries to release the
port in the case it cannot get a reference to the tty. However this is
racy and not even needed.

Infact as Peter Hurley points out:

1. Only consider dlcs that are 'stolen' from a connected socket, ie.
   reused. Allocated dlcs cannot have been closed prior to port
   activate and so for these dlcs a tty reference will always be avail
   in rfcomm_dev_state_change() -- except for the conditions covered by
   #2b below.
2. If a tty was at some point previously created for this rfcomm, then
   either
   (a) the tty reference is still avail, so rfcomm_dev_state_change()
       will perform a hangup. So nothing to do, or,
   (b) the tty reference is no longer avail, and the tty_port will be
       destroyed by the last tty_port_put() in rfcomm_tty_cleanup.
       Again, no action required.
3. Prior to obtaining the dlc lock in rfcomm_dev_add(),
   rfcomm_dev_state_change() will not 'see' a rfcomm_dev so nothing to
   do here.
4. After releasing the dlc lock in rfcomm_dev_add(),
   rfcomm_dev_state_change() will 'see' an incomplete rfcomm_dev if a
   tty reference could not be obtained. Again, the best thing to do here
   is nothing. Any future attempted open() will block on
   rfcomm_dev_carrier_raised(). The unconnected device will exist until
   released by ioctl(RFCOMMRELEASEDEV).

The patch removes the aforementioned code and uses the
tty_port_tty_hangup() helper to hangup the tty.

Signed-off-by: Gianluca Anzolin &lt;gianluca@sottospazio.it&gt;
Reviewed-by: Peter Hurley &lt;peter@hurleysoftware.com&gt;
Signed-off-by: Gustavo Padovan &lt;gustavo.padovan@collabora.co.uk&gt;
</content>
</entry>
<entry>
<title>Bluetooth: Purge the dlc-&gt;tx_queue to avoid circular dependency</title>
<updated>2013-08-21T14:47:08Z</updated>
<author>
<name>Gianluca Anzolin</name>
</author>
<published>2013-07-29T15:08:13Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=ffe6b68cc5999a3f91a15b6667e69e14186e337d'/>
<id>urn:sha1:ffe6b68cc5999a3f91a15b6667e69e14186e337d</id>
<content type='text'>
In rfcomm_tty_cleanup we purge the dlc-&gt;tx_queue which may contain
socket buffers referencing the tty_port and thus preventing the tty_port
destruction.

Signed-off-by: Gianluca Anzolin &lt;gianluca@sottospazio.it&gt;
Reviewed-by: Peter Hurley &lt;peter@hurleysoftware.com&gt;
Signed-off-by: Gustavo Padovan &lt;gustavo.padovan@collabora.co.uk&gt;
</content>
</entry>
<entry>
<title>Bluetooth: Fix the reference counting of tty_port</title>
<updated>2013-08-21T14:47:07Z</updated>
<author>
<name>Gianluca Anzolin</name>
</author>
<published>2013-07-29T15:08:12Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=ece3150dea382c7c961fe2604332ed3474960d25'/>
<id>urn:sha1:ece3150dea382c7c961fe2604332ed3474960d25</id>
<content type='text'>
The tty_port can be released in two cases: when we get a HUP in the
functions rfcomm_tty_hangup() and rfcomm_dev_state_change(). Or when the
user releases the device in rfcomm_release_dev().

In these cases we set the flag RFCOMM_TTY_RELEASED so that no other
function can get a reference to the tty_port.
The use of !test_and_set_bit(RFCOMM_TTY_RELEASED) ensures that the
'initial' tty_port reference is only dropped once.

The rfcomm_dev_del function is removed becase it isn't used anymore.

Signed-off-by: Gianluca Anzolin &lt;gianluca@sottospazio.it&gt;
Reviewed-by: Peter Hurley &lt;peter@hurleysoftware.com&gt;
Signed-off-by: Gustavo Padovan &lt;gustavo.padovan@collabora.co.uk&gt;
</content>
</entry>
<entry>
<title>Bluetooth: Implement .activate, .shutdown and .carrier_raised methods</title>
<updated>2013-08-21T14:47:07Z</updated>
<author>
<name>Gianluca Anzolin</name>
</author>
<published>2013-07-29T15:08:11Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=cad348a17e170451ea8688b532a6ca3e98c63b60'/>
<id>urn:sha1:cad348a17e170451ea8688b532a6ca3e98c63b60</id>
<content type='text'>
Implement .activate, .shutdown and .carrier_raised methods of tty_port
to manage the dlc, moving the code from rfcomm_tty_install() and
rfcomm_tty_cleanup() functions.

At the same time the tty .open()/.close() and .hangup() methods are
changed to use the tty_port helpers that properly call the
aforementioned tty_port methods.

Signed-off-by: Gianluca Anzolin &lt;gianluca@sottospazio.it&gt;
Reviewed-by: Peter Hurley &lt;peter@hurleysoftware.com&gt;
Signed-off-by: Gustavo Padovan &lt;gustavo.padovan@collabora.co.uk&gt;
</content>
</entry>
<entry>
<title>Bluetooth: Move the tty initialization and cleanup out of open/close</title>
<updated>2013-08-21T14:47:06Z</updated>
<author>
<name>Gianluca Anzolin</name>
</author>
<published>2013-07-29T15:08:10Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=54b926a1434e817ca84cb090f36b56763e192470'/>
<id>urn:sha1:54b926a1434e817ca84cb090f36b56763e192470</id>
<content type='text'>
Move the tty_struct initialization from rfcomm_tty_open() to
rfcomm_tty_install() and do the same for the cleanup moving the code from
rfcomm_tty_close() to rfcomm_tty_cleanup().

Add also extra error handling in rfcomm_tty_install() because, unlike
.open()/.close(), .cleanup() is not called if .install() fails.

Signed-off-by: Gianluca Anzolin &lt;gianluca@sottospazio.it&gt;
Reviewed-by: Peter Hurley &lt;peter@hurleysoftware.com&gt;
Signed-off-by: Gustavo Padovan &lt;gustavo.padovan@collabora.co.uk&gt;
</content>
</entry>
<entry>
<title>Bluetooth: Remove the device from the list in the destructor</title>
<updated>2013-08-21T14:47:06Z</updated>
<author>
<name>Gianluca Anzolin</name>
</author>
<published>2013-07-29T15:08:09Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=ebe937f74b8a72cf3ceeae5c2194a160bb092901'/>
<id>urn:sha1:ebe937f74b8a72cf3ceeae5c2194a160bb092901</id>
<content type='text'>
The current code removes the device from the device list in several
places. Do it only in the destructor instead and in the error path of
rfcomm_add_dev() if the device couldn't be initialized.

Signed-off-by: Gianluca Anzolin &lt;gianluca@sottospazio.it&gt;
Reviewed-by: Peter Hurley &lt;peter@hurleysoftware.com&gt;
Signed-off-by: Gustavo Padovan &lt;gustavo.padovan@collabora.co.uk&gt;
</content>
</entry>
</feed>
