Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
831be42
Bluetooth: MGMT: Make MGMT_OP_LOAD_CONN_PARAM update existing connection
Vudentz May 10, 2024
1a556e6
Bluetooth: hci_sync: Fix not using correct handle
Vudentz May 15, 2024
9dc8ac1
Bluetooth: Add quirk to ignore reserved PHY bits in LE Extended Adv R…
svenpeter42 May 15, 2024
9ee7bee
Bluetooth: hci_bcm4377: Use correct unit for timeouts
svenpeter42 May 15, 2024
710a05b
Bluetooth: hci_bcm4377: Increase boot timeout
marcan May 15, 2024
bb0e96c
Bluetooth: hci_bcm4377: Fix msgid release
marcan May 15, 2024
50f1fe9
Bluetooth: btnxpuart: Fix Null pointer dereference in btnxpuart_flush()
NeerajSanjayKale May 15, 2024
aed7431
Bluetooth: btnxpuart: Enable status prints for firmware download
NeerajSanjayKale May 15, 2024
3b42b64
Bluetooth: btnxpuart: Handle FW Download Abort scenario
NeerajSanjayKale May 15, 2024
3afc41c
Bluetooth: btnxpuart: Shutdown timer and prevent rearming when driver…
May 17, 2024
287da90
Bluetooth: btintel: Refactor btintel_set_ppag()
kirankrishnappa-intel May 16, 2024
1a9f00a
Bluetooth: btmtk: add the function to get the fw name
moore-bros May 15, 2024
8a5b9ee
Bluetooth: btmtk: apply the common btmtk_fw_get_filename
moore-bros May 15, 2024
9d5a3b4
Bluetooth: btusb: mediatek: refactor the function btusb_mtk_reset
May 15, 2024
8f9fa6c
Bluetooth: btusb: mediatek: reset the controller before downloading t…
May 15, 2024
2a6bc57
Bluetooth: btusb: mediatek: add MT7922 subsystem reset
May 15, 2024
6197d39
Bluetooth: btintel_pcie: Print Firmware Sequencer information
kirankrishnappa-intel May 17, 2024
cb49bd0
Bluetooth: btintel_pcie: Fix irq leak
kirankrishnappa-intel May 17, 2024
637579e
Bluetooth: btintel_pcie: Fix REVERSE_INULL issue reported by coverity
satijav May 17, 2024
d2526cc
Bluetooth: hci_core: Prefer struct_size over open coded arithmetic
May 18, 2024
68b1e55
Bluetooth: hci_core: Prefer array indexing over pointer arithmetic
May 18, 2024
b7a6ed6
tty: rfcomm: prefer struct_size over open coded arithmetic
May 17, 2024
7b13a74
tty: rfcomm: prefer array indexing over pointer arithmetic
May 17, 2024
e12bde5
dependabot[bot] May 21, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
122 changes: 36 additions & 86 deletions drivers/bluetooth/btintel.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,21 +26,11 @@
#define ECDSA_OFFSET 644
#define ECDSA_HEADER_LEN 320

#define BTINTEL_PPAG_NAME "PPAG"

enum {
DSM_SET_WDISABLE2_DELAY = 1,
DSM_SET_RESET_METHOD = 3,
};

/* structure to store the PPAG data read from ACPI table */
struct btintel_ppag {
u32 domain;
u32 mode;
acpi_status status;
struct hci_dev *hdev;
};

#define CMD_WRITE_BOOT_PARAMS 0xfc0e
struct cmd_write_boot_params {
__le32 boot_addr;
Expand Down Expand Up @@ -1324,65 +1314,6 @@ static int btintel_read_debug_features(struct hci_dev *hdev,
return 0;
}

static acpi_status btintel_ppag_callback(acpi_handle handle, u32 lvl, void *data,
void **ret)
{
acpi_status status;
size_t len;
struct btintel_ppag *ppag = data;
union acpi_object *p, *elements;
struct acpi_buffer string = {ACPI_ALLOCATE_BUFFER, NULL};
struct acpi_buffer buffer = {ACPI_ALLOCATE_BUFFER, NULL};
struct hci_dev *hdev = ppag->hdev;

status = acpi_get_name(handle, ACPI_FULL_PATHNAME, &string);
if (ACPI_FAILURE(status)) {
bt_dev_warn(hdev, "PPAG-BT: ACPI Failure: %s", acpi_format_exception(status));
return status;
}

len = strlen(string.pointer);
if (len < strlen(BTINTEL_PPAG_NAME)) {
kfree(string.pointer);
return AE_OK;
}

if (strncmp((char *)string.pointer + len - 4, BTINTEL_PPAG_NAME, 4)) {
kfree(string.pointer);
return AE_OK;
}
kfree(string.pointer);

status = acpi_evaluate_object(handle, NULL, NULL, &buffer);
if (ACPI_FAILURE(status)) {
ppag->status = status;
bt_dev_warn(hdev, "PPAG-BT: ACPI Failure: %s", acpi_format_exception(status));
return status;
}

p = buffer.pointer;
ppag = (struct btintel_ppag *)data;

if (p->type != ACPI_TYPE_PACKAGE || p->package.count != 2) {
kfree(buffer.pointer);
bt_dev_warn(hdev, "PPAG-BT: Invalid object type: %d or package count: %d",
p->type, p->package.count);
ppag->status = AE_ERROR;
return AE_ERROR;
}

elements = p->package.elements;

/* PPAG table is located at element[1] */
p = &elements[1];

ppag->domain = (u32)p->package.elements[0].integer.value;
ppag->mode = (u32)p->package.elements[1].integer.value;
ppag->status = AE_OK;
kfree(buffer.pointer);
return AE_CTRL_TERMINATE;
}

static int btintel_set_debug_features(struct hci_dev *hdev,
const struct intel_debug_features *features)
{
Expand Down Expand Up @@ -2427,10 +2358,13 @@ static int btintel_configure_offload(struct hci_dev *hdev)

static void btintel_set_ppag(struct hci_dev *hdev, struct intel_version_tlv *ver)
{
struct btintel_ppag ppag;
struct sk_buff *skb;
struct hci_ppag_enable_cmd ppag_cmd;
acpi_handle handle;
struct acpi_buffer buffer = {ACPI_ALLOCATE_BUFFER, NULL};
union acpi_object *p, *elements;
u32 domain, mode;
acpi_status status;

/* PPAG is not supported if CRF is HrP2, Jfp2, JfP1 */
switch (ver->cnvr_top & 0xFFF) {
Expand All @@ -2448,22 +2382,34 @@ static void btintel_set_ppag(struct hci_dev *hdev, struct intel_version_tlv *ver
return;
}

memset(&ppag, 0, sizeof(ppag));

ppag.hdev = hdev;
ppag.status = AE_NOT_FOUND;
acpi_walk_namespace(ACPI_TYPE_PACKAGE, handle, 1, NULL,
btintel_ppag_callback, &ppag, NULL);

if (ACPI_FAILURE(ppag.status)) {
if (ppag.status == AE_NOT_FOUND) {
status = acpi_evaluate_object(handle, "PPAG", NULL, &buffer);
if (ACPI_FAILURE(status)) {
if (status == AE_NOT_FOUND) {
bt_dev_dbg(hdev, "PPAG-BT: ACPI entry not found");
return;
}
bt_dev_warn(hdev, "PPAG-BT: ACPI Failure: %s", acpi_format_exception(status));
return;
}

p = buffer.pointer;
if (p->type != ACPI_TYPE_PACKAGE || p->package.count != 2) {
bt_dev_warn(hdev, "PPAG-BT: Invalid object type: %d or package count: %d",
p->type, p->package.count);
kfree(buffer.pointer);
return;
}

if (ppag.domain != 0x12) {
elements = p->package.elements;

/* PPAG table is located at element[1] */
p = &elements[1];

domain = (u32)p->package.elements[0].integer.value;
mode = (u32)p->package.elements[1].integer.value;
kfree(buffer.pointer);

if (domain != 0x12) {
bt_dev_dbg(hdev, "PPAG-BT: Bluetooth domain is disabled in ACPI firmware");
return;
}
Expand All @@ -2474,19 +2420,22 @@ static void btintel_set_ppag(struct hci_dev *hdev, struct intel_version_tlv *ver
* BIT 1 : 0 Disabled in China
* 1 Enabled in China
*/
if ((ppag.mode & 0x01) != BIT(0) && (ppag.mode & 0x02) != BIT(1)) {
bt_dev_dbg(hdev, "PPAG-BT: EU, China mode are disabled in CB/BIOS");
mode &= 0x03;

if (!mode) {
bt_dev_dbg(hdev, "PPAG-BT: EU, China mode are disabled in BIOS");
return;
}

ppag_cmd.ppag_enable_flags = cpu_to_le32(ppag.mode);
ppag_cmd.ppag_enable_flags = cpu_to_le32(mode);

skb = __hci_cmd_sync(hdev, INTEL_OP_PPAG_CMD, sizeof(ppag_cmd), &ppag_cmd, HCI_CMD_TIMEOUT);
skb = __hci_cmd_sync(hdev, INTEL_OP_PPAG_CMD, sizeof(ppag_cmd),
&ppag_cmd, HCI_CMD_TIMEOUT);
if (IS_ERR(skb)) {
bt_dev_warn(hdev, "Failed to send PPAG Enable (%ld)", PTR_ERR(skb));
return;
}
bt_dev_info(hdev, "PPAG-BT: Enabled (Mode %d)", ppag.mode);
bt_dev_info(hdev, "PPAG-BT: Enabled (Mode %d)", mode);
kfree_skb(skb);
}

Expand Down Expand Up @@ -2713,7 +2662,7 @@ void btintel_set_msft_opcode(struct hci_dev *hdev, u8 hw_variant)
}
EXPORT_SYMBOL_GPL(btintel_set_msft_opcode);

static void btintel_print_fseq_info(struct hci_dev *hdev)
void btintel_print_fseq_info(struct hci_dev *hdev)
{
struct sk_buff *skb;
u8 *p;
Expand Down Expand Up @@ -2825,6 +2774,7 @@ static void btintel_print_fseq_info(struct hci_dev *hdev)

kfree_skb(skb);
}
EXPORT_SYMBOL_GPL(btintel_print_fseq_info);

static int btintel_setup_combined(struct hci_dev *hdev)
{
Expand Down
5 changes: 5 additions & 0 deletions drivers/bluetooth/btintel.h
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,7 @@ int btintel_bootloader_setup_tlv(struct hci_dev *hdev,
struct intel_version_tlv *ver);
int btintel_shutdown_combined(struct hci_dev *hdev);
void btintel_hw_error(struct hci_dev *hdev, u8 code);
void btintel_print_fseq_info(struct hci_dev *hdev);
#else

static inline int btintel_check_bdaddr(struct hci_dev *hdev)
Expand Down Expand Up @@ -373,4 +374,8 @@ static inline int btintel_shutdown_combined(struct hci_dev *hdev)
static inline void btintel_hw_error(struct hci_dev *hdev, u8 code)
{
}

static inline void btintel_print_fseq_info(struct hci_dev *hdev)
{
}
#endif
10 changes: 9 additions & 1 deletion drivers/bluetooth/btintel_pcie.c
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ static int btintel_pcie_recv_frame(struct btintel_pcie_data *data,

/* The first 4 bytes indicates the Intel PCIe specific packet type */
pdata = skb_pull_data(skb, BTINTEL_PCIE_HCI_TYPE_LEN);
if (!data) {
if (!pdata) {
bt_dev_err(hdev, "Corrupted packet received");
ret = -EILSEQ;
goto exit_error;
Expand Down Expand Up @@ -1197,9 +1197,11 @@ static int btintel_pcie_setup(struct hci_dev *hdev)
bt_dev_err(hdev, "Unsupported Intel hw variant (%u)",
INTEL_HW_VARIANT(ver_tlv.cnvi_bt));
err = -EINVAL;
goto exit_error;
break;
}

btintel_print_fseq_info(hdev);
exit_error:
kfree_skb(skb);

Expand Down Expand Up @@ -1327,6 +1329,12 @@ static void btintel_pcie_remove(struct pci_dev *pdev)
data = pci_get_drvdata(pdev);

btintel_pcie_reset_bt(data);
for (int i = 0; i < data->alloc_vecs; i++) {
struct msix_entry *msix_entry;

msix_entry = &data->msix_entries[i];
free_irq(msix_entry->vector, msix_entry);
}

pci_free_irq_vectors(pdev);

Expand Down
18 changes: 18 additions & 0 deletions drivers/bluetooth/btmtk.c
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,24 @@ static void btmtk_coredump_notify(struct hci_dev *hdev, int state)
}
}

void btmtk_fw_get_filename(char *buf, size_t size, u32 dev_id, u32 fw_ver,
u32 fw_flavor)
{
if (dev_id == 0x7925)
snprintf(buf, size,
"mediatek/mt%04x/BT_RAM_CODE_MT%04x_1_%x_hdr.bin",
dev_id & 0xffff, dev_id & 0xffff, (fw_ver & 0xff) + 1);
else if (dev_id == 0x7961 && fw_flavor)
snprintf(buf, size,
"mediatek/BT_RAM_CODE_MT%04x_1a_%x_hdr.bin",
dev_id & 0xffff, (fw_ver & 0xff) + 1);
else
snprintf(buf, size,
"mediatek/BT_RAM_CODE_MT%04x_1_%x_hdr.bin",
dev_id & 0xffff, (fw_ver & 0xff) + 1);
}
EXPORT_SYMBOL_GPL(btmtk_fw_get_filename);

int btmtk_setup_firmware_79xx(struct hci_dev *hdev, const char *fwname,
wmt_cmd_sync_func_t wmt_cmd_sync)
{
Expand Down
8 changes: 8 additions & 0 deletions drivers/bluetooth/btmtk.h
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,9 @@ int btmtk_register_coredump(struct hci_dev *hdev, const char *name,
u32 fw_version);

int btmtk_process_coredump(struct hci_dev *hdev, struct sk_buff *skb);

void btmtk_fw_get_filename(char *buf, size_t size, u32 dev_id, u32 fw_ver,
u32 fw_flavor);
#else

static inline int btmtk_set_bdaddr(struct hci_dev *hdev,
Expand Down Expand Up @@ -194,4 +197,9 @@ static int btmtk_process_coredump(struct hci_dev *hdev, struct sk_buff *skb)
{
return -EOPNOTSUPP;
}

static void btmtk_fw_get_filename(char *buf, size_t size, u32 dev_id,
u32 fw_ver, u32 fw_flavor)
{
}
#endif
3 changes: 3 additions & 0 deletions drivers/bluetooth/btmtksdio.c
Original file line number Diff line number Diff line change
Expand Up @@ -1117,6 +1117,9 @@ static int btmtksdio_setup(struct hci_dev *hdev)
return err;
}

btmtk_fw_get_filename(fwname, sizeof(fwname), dev_id,
fw_version, 0);

snprintf(fwname, sizeof(fwname),
"mediatek/BT_RAM_CODE_MT%04x_1_%x_hdr.bin",
dev_id & 0xffff, (fw_version & 0xff) + 1);
Expand Down
Loading