msm: socinfo: Add support for socinfo v6

socinfo v6 provides information for identifying the
platform subtype.

Change-Id: Ifdeb036c9804ca54b185fbc4d28541f4708052a8
Signed-off-by: Naveen Ramaraj <nramaraj@codeaurora.org>
Signed-off-by: Laura Abbott <lauraa@codeaurora.org>
Signed-off-by: Andika Edo <dhiika@phiexz.com>
Bluetooth: Remove max_tx and tx_window module paramenters from L2CAP

We don't need these parameters anymore since we have socket options for
them.

Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
(cherry picked from commit fd059b9bd0af2e217f29d5a34e1c71039d26af8c)

Change-Id: I1f99ecd791d5f8657f76c4b0b1ba1920a6c281b9
Signed-off-by: Mat Martineau <mathewm@codeaurora.org>
Signed-off-by: Andika Edo <dhiika@phiexz.com>
Bluetooth: Remove L2CAP Extended Features from Kconfig

This reverts commit 84fb0a6334af0ccad3544f6972c055d90fbb9fbe which adds
the L2CAP Extended Features to the Kconfig, that is actually not needed.
One can use other mechanisms to enable L2CAP Extended Features.

Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
(cherry picked from commit 0b31c85ce78d3646ac1e90d62969e7cd8cfd8b15)

Change-Id: I0b7a2275b61954e386874d594a404b33f896c809
Signed-off-by: Mat Martineau <mathewm@codeaurora.org>
Signed-off-by: Andika Edo <dhiika@phiexz.com>
Bluetooth: Fix drop of packets with invalid req_seq/tx_seq

We shall not use an unsigned var since we are expecting negatives value
there. Using unsigned causes ERTM connection to close due to invalid
ReqSeq numbers.

Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
(cherry picked from commit f6337c771126420c348b702e012262cfb5f0d56e)

Change-Id: I4f77f8791ec037c721804c7841e057ac4c3064bc
Signed-off-by: Mat Martineau <mathewm@codeaurora.org>
Signed-off-by: Andika Edo <dhiika@phiexz.com>
Bluetooth: Fix bug with ERTM vars increment

All ERTM operations regarding the txWindow should be modulo 64,
otherwise we confuse the ERTM logic and connections will break.

Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
Reviewed-by: João Paulo Rechi Vita <jprvita@profusion.mobi>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
(cherry picked from commit 8ff50ec04a7ecdbba6e0a5423cf6f2c5f7fc605e)

Change-Id: I3db37d789a6931071715f0605365177992d36781
Signed-off-by: Mat Martineau <mathewm@codeaurora.org>
Signed-off-by: Andika Edo <dhiika@phiexz.com>
Bluetooth: Only check SAR bits if frame is an I-frame

The SAR bits doesn't make sense for an S-frame. It doesn't use SAR.

Checking SAR for a S-frames can lead to L2CAP errors, it could close
the channel with an invalid packet length, since we was removing the 2
of the of any frame that match SAR start bits, without check if it is
an I-frame.

Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
(cherry picked from commit bc1b1f8bee63966649dd5ac7d10d31a6556bf19b)

Change-Id: Id5f2527020266b8f078a8f77881023d404d79116
Signed-off-by: Mat Martineau <mathewm@codeaurora.org>
Signed-off-by: Andika Edo <dhiika@phiexz.com>
Bluetooth: Fix bug in l2cap_ertm_send() behavior

This patch makes l2cap_ertm_send() similar to the Send-Data action of
the ERTM spec. We shall not check for RemoteBusy or WAIT_F state
inside l2cap_ertm_send().

Such checks were causing a bug in the retransmission logic of ERTM and
making ERTM stalls until the ACL is dropped.

Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
Reviewed-by: João Paulo Rechi Vita <jprvita@profusion.mobi>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
(cherry picked from commit 6e2b6722abaa3f6042357e11f465488b7c12f94c)

Change-Id: I9fa126500187f73a5586d55fa6c2e45118a624c2
Signed-off-by: Mat Martineau <mathewm@codeaurora.org>
Signed-off-by: Andika Edo <dhiika@phiexz.com>
Bluetooth: Fix SREJ_QUEUE corruption in L2CAP

Since all TxSeq values are modulo, we shall not compare them directly. We
have to compare their offset inside the TxWindow instead.

Signed-off-by: João Paulo Rechi Vita <jprvita@profusion.mobi>
Acked-by: Gustavo F. Padovan <padovan@profusion.mobi>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
(cherry picked from commit bfbacc11550a785caf082f3ccfcd7ecf882e09a4)

Change-Id: I1d138364842267cdf4fef561cf248416605a2ead
Signed-off-by: Mat Martineau <mathewm@codeaurora.org>
Signed-off-by: Andika Edo <dhiika@phiexz.com>
Bluetooth: Fix bug with ERTM minimum packet length

ERTM and streaming mode L2CAP sockets have no minimum packet length. Only
basic mode connections have minimum length.

Instead, validate the packet containing all necessary control, FCS,
and SAR fields.

The patch fixes the drop of valid packets with length lower than 4.

Signed-off-by: Nathan Holstein <ngh@isomerica.net>
Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
(cherry picked from commit 51893f88dd916efead5e24a212c907b2cd35e160)

Change-Id: Ic08bc2621aa7900ed1666848187151adab20cd19
Signed-off-by: Mat Martineau <mathewm@codeaurora.org>
Signed-off-by: Andika Edo <dhiika@phiexz.com>
Bluetooth: Proper shutdown ERTM when closing the channel

Fix a crash regarding the Monitor Timeout, it was running even after the
shutdown of the ACL connection, which doesn't make sense.

The same code also fixes another issue, before this patch L2CAP was sending
many Disconnections Requests while we have to send only one.

The issues are related to each other, a expired Monitor Timeout can
trigger a Disconnection Request and then we may have a crash if the link
was already deleted.

Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
(cherry picked from commit c13ffa620f15cb28d18268a773464cf51550fa9f)

Change-Id: Icc996dec4537726aee128262c650aa8507e5966d
Signed-off-by: Mat Martineau <mathewm@codeaurora.org>
Signed-off-by: Andika Edo <dhiika@phiexz.com>
Bluetooth: Fix L2CAP control bit field corruption

When resending an I-frame, ERTM was reusing the control bits from the last
time it was sent, that was causing a corruption in the new control field
due to it dirty fields.

This patches extracts only the SAR bits from the old field and reuse it to
resend the packet, the others bits should be reset and receive the
updated value.

Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
(cherry picked from commit 95ffa97827371ede501615d9bd048eb5b49e8fe1)

Change-Id: Ibfba27e7dd4e73d48e7eebb4c73f9c8f9b338976
Signed-off-by: Mat Martineau <mathewm@codeaurora.org>
Signed-off-by: Andika Edo <dhiika@phiexz.com>
Bluetooth: Add blacklist support for incoming connections

In some circumstances it could be desirable to reject incoming
connections on the baseband level. This patch adds this feature through
two new ioctl's: HCIBLOCKADDR and HCIUNBLOCKADDR. Both take a simple
Bluetooth address as a parameter. BDADDR_ANY can be used with
HCIUNBLOCKADDR to remove all devices from the blacklist.

Signed-off-by: Johan Hedberg <johan.hedberg@nokia.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
(cherry picked from commit f03585689fdff4ae256edd45a35bc2dd83d3684a)

Change-Id: Ib17572d5ccbd73dfdae84a541093a56834931eae
Signed-off-by: Mat Martineau <mathewm@codeaurora.org>
Signed-off-by: Andika Edo <dhiika@phiexz.com>
Bluetooth: Add debugfs support for showing the blacklist

This patch adds a debugfs blacklist entry for each HCI device which can
be used to list the current content of the blacklist.

Signed-off-by: Johan Hedberg <johan.hedberg@nokia.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
(cherry picked from commit 32c2ece5eaec296482077dadc3edd5baa7bd1097)

Change-Id: Ia884eedbf0d8cc3a1ce589c4cee01e71a0e030fd
Signed-off-by: Mat Martineau <mathewm@codeaurora.org>
Signed-off-by: Andika Edo <dhiika@phiexz.com>
Bluetooth: Silence warning in btmrvl SDIO driver

Clone checking of ret to simplify the code.

This patch silences a compiler warning:
drivers/bluetooth/btmrvl_sdio.c: In function ‘btmrvl_sdio_verify_fw_download’:
drivers/bluetooth/btmrvl_sdio.c:80: warning: ‘fws1’ may be used uninitialized in this function
drivers/bluetooth/btmrvl_sdio.c:80: note: ‘fws1’ was declared here

Signed-off-by: Kulikov Vasiliy <segooon@gmail.com>
Reviewed-by: Dan Carpenter <error27@gmail.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
(cherry picked from commit 278be27fc401119c985235ee549dc229d85e6bf5)

Change-Id: I8453ca38e4bd22562c0cbfe33896193044e6b515
Signed-off-by: Mat Martineau <mathewm@codeaurora.org>
Signed-off-by: Andika Edo <dhiika@phiexz.com>
Bluetooth: Fix warning: variable 'tty' set but not used

The patch below fixes a warning message when using gcc 4.6.0.

  CC [M]  drivers/bluetooth/hci_ldisc.o
drivers/bluetooth/hci_ldisc.c: In function 'hci_uart_send_frame':
drivers/bluetooth/hci_ldisc.c:213:21: warning: variable 'tty' set but not used

Signed-off-by: Justin P. Mattock <justinmattock@gmail.com>
Reviewed-By: Gustavo F. Padovan <gustavo@padovan.org>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
(cherry picked from commit 7452d24cfb91e84f9be61beda5ad68d2a56d0938)

Change-Id: I520081071c9dd8693e6cf13332fbacce9de37229
Signed-off-by: Mat Martineau <mathewm@codeaurora.org>
Signed-off-by: Andika Edo <dhiika@phiexz.com>
Bluetooth: Process interrupt in main thread of btmrvl driver as well

When driver is sending a command or data and the firmware is also
sending a sleep event, sometimes it is observed that driver will
continue to send the command/data to firmware right after processing
sleep event. Once sleep event is processed driver is not supposed to
send anything because firmware is in sleep state after that. Previously
interrupt processing was done in SDIO interrupt callback handler.
Now it is done in btmrvl driver main thread to solve the
cross-sending properly.

Signed-off-by: Amitkumar Karwar <akarwar@marvell.com>
Signed-off-by: Bing Zhao <bzhao@marvell.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
(cherry picked from commit d1d10d783089cc26a14be92fc12fccda9aa6593a)

Change-Id: If2d5ec6ba094d1bdaafe28cf796bd5b5a2f43afa
Signed-off-by: Mat Martineau <mathewm@codeaurora.org>
Signed-off-by: Andika Edo <dhiika@phiexz.com>
Bluetooth: Use kmemdup for drivers

Use kmemdup when some other buffer is immediately copied into the
allocated region.

A simplified version of the semantic patch that makes this change is as
follows: (http://coccinelle.lip6.fr/)

// <smpl>
@@
expression from,to,size,flag;
statement S;
@@

-  to = \(kmalloc\|kzalloc\)(size,flag);
+  to = kmemdup(from,size,flag);
   if (to==NULL || ...) S
-  memcpy(to, from, size);
// </smpl>

Signed-off-by: Julia Lawall <julia@diku.dk>
Acked-by: Gustavo F. Padovan <padovan@profusion.mobi>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
(cherry picked from commit 5ee283c063a236b19e4582c675a2d8d615d5809c)

Change-Id: I319a25ed9f7c8efa0c4c3d43ad7d0793ee4dfdc0
Signed-off-by: Mat Martineau <mathewm@codeaurora.org>
Signed-off-by: Andika Edo <dhiika@phiexz.com>
Bluetooth: Use kzalloc for drivers

Use kzalloc rather than the combination of kmalloc and memset.

The semantic patch that makes this change is as follows:
(http://coccinelle.lip6.fr/)

// <smpl>
@@
expression x,size,flags;
statement S;
@@

-x = kmalloc(size,flags);
+x = kzalloc(size,flags);
 if (x == NULL) S
-memset(x, 0, size);
// </smpl>

Signed-off-by: Julia Lawall <julia@diku.dk>
Acked-by: Gustavo F. Padovan <padovan@profusion.mobi>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
(cherry picked from commit f8df39f1810b02f877c1ba1eed8e0710019e3b48)

Change-Id: I1ec1e9643ba2737bc90cade64c1564056033432a
Signed-off-by: Mat Martineau <mathewm@codeaurora.org>
Signed-off-by: Andika Edo <dhiika@phiexz.com>
Bluetooth: Stop ack_timer if ERTM enters in Local Busy or SREJ_SENT

The ack_timer is implemation specific, disabling it in such situation
avoids some potencial errors in the ERTM protocol.

Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
Reviewed-by: João Paulo Rechi Vita <jprvita@profusion.mobi>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
(cherry picked from commit 7fe9b298c98fdfecf3b0efb4c971b7696d091ae9)

Change-Id: Ic7df2c6cd144640981814ebc4190bc51900706f9
Signed-off-by: Mat Martineau <mathewm@codeaurora.org>
Signed-off-by: Andika Edo <dhiika@phiexz.com>
Bluetooth: Update buffer_seq before retransmit frames

Updating buffer_seq first make us able to ack the last I-frame received.
This is also a requirement of the  Profile Tuning Suite software.

Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
(cherry picked from commit 2ece3684b4037ad2394de795d67abbe412ab5e2f)

Change-Id: Icb55810938ae0f6b801d21e366ffc2c35d217834
Signed-off-by: Mat Martineau <mathewm@codeaurora.org>
Signed-off-by: Andika Edo <dhiika@phiexz.com>