Linux bluetooth development
 help / color / mirror / Atom feed
From: Tedd Ho-Jeong An <tedd.an@intel.com>
To: BlueZ development <linux-bluetooth@vger.kernel.org>
Cc: Marcel Holtmann <marcel@holtmann.org>, "An, Tedd" <tedd.an@intel.com>
Subject: [PATCH v2] Bluetooth: btusb: fixed command length alignment on Intel 8260
Date: Mon, 18 May 2015 15:52:07 -0700	[thread overview]
Message-ID: <20150518155207.31ce2835@tedd-fedora-vm> (raw)

From: Tedd Ho-Jeong An <tedd.an@intel.com>

This patch fixes the command length alignment issue for Intel Bluetooth
8260.

The length of parameters in the firmware downloading command must be
multiplication of 4. If not, the command must append Intel_NOP command
with extra parameters, zeros, at the end, and the firmware file is
already included Intel_NOP command for alignment.

This patch checks the next command and if the next command is Intel_NOP
command, it reads the Intel_NOP command and send them together.

For example, if the data from the firmware file looks like this:
8E FC 03 11 22 33 02 FC 03 00 00 00

Previously, btusb sends two commands:
09 FC 06 8E FC 03 11 22 33
09 FC 06 02 FC 03 00 00 00

This won't work because the length of parameters are 6 which violates
the 4 byte alignment.

This patch will append them together and send as one command:
09 FC 0B 8E FC 03 11 22 33 02 FC 03 00 00 00

Signed-off-by: Tedd Ho-Jeong An <tedd.an@intel.com>
---
 drivers/bluetooth/btusb.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c
index d21f3b4..13b9969 100644
--- a/drivers/bluetooth/btusb.c
+++ b/drivers/bluetooth/btusb.c
@@ -2541,6 +2541,22 @@ static int btusb_setup_intel_new(struct hci_dev *hdev)
 
 		cmd_len = sizeof(*cmd) + cmd->plen;
 
+		/* The parameter length of secure send command should be a
+		 * multiplication of 4. If it is not, it needs to append
+		 * Intel_NOP command with arbitrary number of parameters (zeros)
+		 * to meet the 4 byte alignment.
+		 * The FW file has already formatted with this. So if the next
+		 * command is Intel_NOP then send them together.
+		 */
+		cmd = (void *)(fw_ptr + cmd_len);
+		if (le16_to_cpu(cmd->opcode) == 0xfc02) {
+			BT_DBG("%s: Updated cmd to include Intel_NOP",
+			       hdev->name);
+			/* Update cmd_len to include the Intel_NOP command
+			 */
+			cmd_len += sizeof(*cmd) + cmd->plen;
+		}
+
 		/* Send each command from the firmware data buffer as
 		 * a single Data fragment.
 		 */
-- 
2.1.0

             reply	other threads:[~2015-05-18 22:52 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-18 22:52 Tedd Ho-Jeong An [this message]
2015-05-26 16:28 ` [PATCH v2] Bluetooth: btusb: fixed command length alignment on Intel 8260 Tedd Ho-Jeong An
2015-06-06  6:15 ` Marcel Holtmann
2015-06-08 18:57   ` Tedd Ho-Jeong An

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=20150518155207.31ce2835@tedd-fedora-vm \
    --to=tedd.an@intel.com \
    --cc=linux-bluetooth@vger.kernel.org \
    --cc=marcel@holtmann.org \
    /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