Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp6044938ybi; Sun, 7 Jul 2019 19:25:52 -0700 (PDT) X-Google-Smtp-Source: APXvYqxA6RkhBm9TWVVBiS0tQOjPiN/JsevCcF/xKioHC2EzyyiFhQ0csV6SQj+ogp/pC7/T+NWV X-Received: by 2002:a17:90a:bb8b:: with SMTP id v11mr21630633pjr.64.1562552752835; Sun, 07 Jul 2019 19:25:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562552752; cv=none; d=google.com; s=arc-20160816; b=lQN9jQHpXByMyhRmBk4ZZtRPfJC13Y9TGwrqCgfFedu3Vk8ckl6//3DJASxfi/dX3Y 9ewt7l1KnLj+dQWLPcsmCPX9PYmi6RTcsJpuW8Pp6oV4CU5c7napceyD36qiXNpFiU1o xUpMGihGnSGrzKmKYTJVircZQznlT1zqeCc/dscyvw/07XwxbMyBdgp5MRcr+UmjsMN7 yNoye4bRWtWe7hKojOkDY6gQdHT1Ww4oP37d+otkS5P6Dy7WGB4YWpwID/agLyiFNHYE NdOVnQjGmI/gWEqbqHUCv9tMs7jnmHcu30asCQ1YuzrU8KZQlK7pHjI16e9NlqvvKy5f +g6Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:to:subject:message-id:date:from :mime-version:dkim-signature; bh=wDN6WV33uwNdL5E3I2htUXY1vmcv5ID7wjrKzbaNAcI=; b=vBox7VzuVMwrTmilZiTn+LEHOhCeNx5wPfZ1/Ho2/N59+O24N6DeqiZXNNOfXQRp8S HYTFD2/RS4t66GWOLsM/lyvWbYfXfA8+aUAaskOxLn5pYby9j8aCSkCm980pTSr3yVOH BC9JzkV+LIaeSRwc/e3qPWipxLMTBek9ge0kds/ANYk77bimuPjdox9IdPSyDxOPptoI G2MgfA13HS2q6Gbo9o6VoXcg8fxYxYoB4lDIsCv/kWfg+r9aH+RhPt22GJ0KoHy2aQsK KYFIZ9OQNwrxF19TWfeIXRNHquu8rv9mC2vSZ3m4Vb0NI6NZlJDHbg3tvwXDYZERkPm0 CO7A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=aL+OuQr6; spf=pass (google.com: best guess record for domain of linux-bluetooth-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l63si17107597pge.264.2019.07.07.19.25.20; Sun, 07 Jul 2019 19:25:52 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-bluetooth-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=aL+OuQr6; spf=pass (google.com: best guess record for domain of linux-bluetooth-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727672AbfGHAEy (ORCPT + 99 others); Sun, 7 Jul 2019 20:04:54 -0400 Received: from mail-pl1-f196.google.com ([209.85.214.196]:35503 "EHLO mail-pl1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727455AbfGHAEy (ORCPT ); Sun, 7 Jul 2019 20:04:54 -0400 Received: by mail-pl1-f196.google.com with SMTP id w24so7292352plp.2 for ; Sun, 07 Jul 2019 17:04:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to; bh=wDN6WV33uwNdL5E3I2htUXY1vmcv5ID7wjrKzbaNAcI=; b=aL+OuQr6Vnet7ZPFwuLPz2sY31lDmbW+ABBY/LunEUTnfMAEaK5nDt8VXk5VRQwn9G z1qA1uOx/uCmpIqG9RV0Jx56OF4SscrkPzjdPdCDLOLQ+af3qU14+PwzTUQj28OPu/vC Z94QsyYOTSDLgxYcA0Qlr6o7MQFR5BRdyA/Dtb9s3R099opEoCpGDQUV9wV7NIBrtEFY 1BQ7MZ/G2s+hql0t5nGs2GLS4R1G2Zv53kqyZ1ayogjjtLEg4UL98IRsxDCVcWtKGU73 fLJ7l1UPWCrxsaybYZI176gxfnk8pNX7lYmWeF5kJPFMiOKT3Lb7IWEkTC++oh2OxcdN H1lw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=wDN6WV33uwNdL5E3I2htUXY1vmcv5ID7wjrKzbaNAcI=; b=N5nAYM1NpH+vXHFo0ez3DmaGNZLsdFP7XQBbFTKg7ksX3Res/PIHf2725Ra421Sfh6 Kv4h+JOJGIO1ExztJ3zuLC84qsJDxiN73irZVXPo5HrMJJ0Qn0Gkbm3AY0PsXdp67k9c VqPCqbP7HwAyJfNBvrW+IcxG6T56QpzMzKHJk3hAoBDlXKevRVGpVrff+NyaPQXxgHUF HJFftuuPqsO9vUqObDDKi4HHZPs4v7OhTRUNmriw+fcdM7o+0LiOpc5z3/gONhTVTSfN nKPticc/OKtJygg+WrMbOiP5hU+W6Tp85YE5pgLYiQDq0sc6MLtTO2NbWK2YB+zN3FJ8 /KKw== X-Gm-Message-State: APjAAAU1orBnSuVHU9/FmuiAKb/pAixHxpkIjiYOLfrnL0xlg/xZlzN+ U++daWxsbnpjI28QGmaQm62sdNQuyBsL5e3s6p/ND1j5 X-Received: by 2002:a17:902:da4:: with SMTP id 33mr19000685plv.209.1562544293789; Sun, 07 Jul 2019 17:04:53 -0700 (PDT) MIME-Version: 1.0 From: Andrey Batyiev Date: Mon, 8 Jul 2019 03:04:42 +0300 Message-ID: Subject: [PATCH] Fix endianness bug in hci_core.c To: linux-bluetooth@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org Hello everyone, I'm using Linux on big endian CPU (one of MIPS-based home routers). Also, I'm trying to use Cypress CYW20704A2 USB-Bluetooth dongle on it. However, `hciconfig hci0 up` failed, and `btmon` showed very specific problem: < HCI Command: LE Write Suggested Default Data Length (0x08|0x0024) plen 4 TX octets: 64256 TX time: 18440 > HCI Event: Command Complete (0x0e) plen 4 LE Write Suggested Default Data Length (0x08|0x0024) ncmd 1 Status: Invalid HCI Command Parameters (0x12) After comparing with similar log on the Linux desktop (where TX octets value is `251`), I came to conclusion that it's an endianness problem, therefore here is a patch that fixes it. Thanks, Andrey --- linux-4.14.104-old/net/bluetooth/hci_core.c 2019-07-07 23:39:44.069862824 +0000 +++ linux-4.14.104/net/bluetooth/hci_core.c 2019-07-07 22:43:21.291838543 +0000 @@ -802,8 +802,8 @@ if (hdev->le_features[0] & HCI_LE_DATA_LEN_EXT) { struct hci_cp_le_write_def_data_len cp; - cp.tx_len = hdev->le_max_tx_len; - cp.tx_time = hdev->le_max_tx_time; + cp.tx_len = cpu_to_le16(hdev->le_max_tx_len); + cp.tx_time = cpu_to_le16(hdev->le_max_tx_time); hci_req_add(req, HCI_OP_LE_WRITE_DEF_DATA_LEN, sizeof(cp), &cp); }