Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Bluetooth: btintel_pcie: Setup buffers for firmware traces

This patch allocates the host memory which is used by controller to dump
the firmware traces. The memory needs to be shared with controller via
context information.

Co-developed-by: Vijay Satija <vijay.satija@intel.com>
Signed-off-by: Vijay Satija <vijay.satija@intel.com>
Signed-off-by: Kiran K <kiran.k@intel.com>
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Signed-off-by: Arnd Bergmann <arnd@arndb.de>

authored by

Kiran K and committed by
Luiz Augusto von Dentz
6ed83047 d5712c51

+121
+89
drivers/bluetooth/btintel_pcie.c
··· 49 49 #define BTINTEL_PCIE_HCI_EVT_PKT 0x00000004 50 50 #define BTINTEL_PCIE_HCI_ISO_PKT 0x00000005 51 51 52 + #define BTINTEL_PCIE_MAGIC_NUM 0xA5A5A5A5 53 + 52 54 /* Alive interrupt context */ 53 55 enum { 54 56 BTINTEL_PCIE_ROM, ··· 61 59 BTINTEL_PCIE_D0, 62 60 BTINTEL_PCIE_D3 63 61 }; 62 + 63 + /* Structure for dbgc fragment buffer 64 + * @buf_addr_lsb: LSB of the buffer's physical address 65 + * @buf_addr_msb: MSB of the buffer's physical address 66 + * @buf_size: Total size of the buffer 67 + */ 68 + struct btintel_pcie_dbgc_ctxt_buf { 69 + u32 buf_addr_lsb; 70 + u32 buf_addr_msb; 71 + u32 buf_size; 72 + }; 73 + 74 + /* Structure for dbgc fragment 75 + * @magic_num: 0XA5A5A5A5 76 + * @ver: For Driver-FW compatibility 77 + * @total_size: Total size of the payload debug info 78 + * @num_buf: Num of allocated debug bufs 79 + * @bufs: All buffer's addresses and sizes 80 + */ 81 + struct btintel_pcie_dbgc_ctxt { 82 + u32 magic_num; 83 + u32 ver; 84 + u32 total_size; 85 + u32 num_buf; 86 + struct btintel_pcie_dbgc_ctxt_buf bufs[BTINTEL_PCIE_DBGC_BUFFER_COUNT]; 87 + }; 88 + 89 + /* This function initializes the memory for DBGC buffers and formats the 90 + * DBGC fragment which consists header info and DBGC buffer's LSB, MSB and 91 + * size as the payload 92 + */ 93 + static int btintel_pcie_setup_dbgc(struct btintel_pcie_data *data) 94 + { 95 + struct btintel_pcie_dbgc_ctxt db_frag; 96 + struct data_buf *buf; 97 + int i; 98 + 99 + data->dbgc.count = BTINTEL_PCIE_DBGC_BUFFER_COUNT; 100 + data->dbgc.bufs = devm_kcalloc(&data->pdev->dev, data->dbgc.count, 101 + sizeof(*buf), GFP_KERNEL); 102 + if (!data->dbgc.bufs) 103 + return -ENOMEM; 104 + 105 + data->dbgc.buf_v_addr = dmam_alloc_coherent(&data->pdev->dev, 106 + data->dbgc.count * 107 + BTINTEL_PCIE_DBGC_BUFFER_SIZE, 108 + &data->dbgc.buf_p_addr, 109 + GFP_KERNEL | __GFP_NOWARN); 110 + if (!data->dbgc.buf_v_addr) 111 + return -ENOMEM; 112 + 113 + data->dbgc.frag_v_addr = dmam_alloc_coherent(&data->pdev->dev, 114 + sizeof(struct btintel_pcie_dbgc_ctxt), 115 + &data->dbgc.frag_p_addr, 116 + GFP_KERNEL | __GFP_NOWARN); 117 + if (!data->dbgc.frag_v_addr) 118 + return -ENOMEM; 119 + 120 + data->dbgc.frag_size = sizeof(struct btintel_pcie_dbgc_ctxt); 121 + 122 + db_frag.magic_num = BTINTEL_PCIE_MAGIC_NUM; 123 + db_frag.ver = BTINTEL_PCIE_DBGC_FRAG_VERSION; 124 + db_frag.total_size = BTINTEL_PCIE_DBGC_FRAG_PAYLOAD_SIZE; 125 + db_frag.num_buf = BTINTEL_PCIE_DBGC_FRAG_BUFFER_COUNT; 126 + 127 + for (i = 0; i < data->dbgc.count; i++) { 128 + buf = &data->dbgc.bufs[i]; 129 + buf->data_p_addr = data->dbgc.buf_p_addr + i * BTINTEL_PCIE_DBGC_BUFFER_SIZE; 130 + buf->data = data->dbgc.buf_v_addr + i * BTINTEL_PCIE_DBGC_BUFFER_SIZE; 131 + db_frag.bufs[i].buf_addr_lsb = lower_32_bits(buf->data_p_addr); 132 + db_frag.bufs[i].buf_addr_msb = upper_32_bits(buf->data_p_addr); 133 + db_frag.bufs[i].buf_size = BTINTEL_PCIE_DBGC_BUFFER_SIZE; 134 + } 135 + 136 + memcpy(data->dbgc.frag_v_addr, &db_frag, sizeof(db_frag)); 137 + return 0; 138 + } 64 139 65 140 static inline void ipc_print_ia_ring(struct hci_dev *hdev, struct ia *ia, 66 141 u16 queue_num) ··· 1087 1008 ci->addr_urbdq1 = data->rxq.urbd1s_p_addr; 1088 1009 ci->num_urbdq1 = data->rxq.count; 1089 1010 ci->urbdq_db_vec = BTINTEL_PCIE_RXQ_NUM; 1011 + 1012 + ci->dbg_output_mode = 0x01; 1013 + ci->dbgc_addr = data->dbgc.frag_p_addr; 1014 + ci->dbgc_size = data->dbgc.frag_size; 1015 + ci->dbg_preset = 0x00; 1090 1016 } 1091 1017 1092 1018 static void btintel_pcie_free_txq_bufs(struct btintel_pcie_data *data, ··· 1303 1219 1304 1220 /* Setup Index Array */ 1305 1221 btintel_pcie_setup_ia(data, p_addr, v_addr, &data->ia); 1222 + 1223 + /* Setup data buffers for dbgc */ 1224 + err = btintel_pcie_setup_dbgc(data); 1225 + if (err) 1226 + goto exit_error_txq; 1306 1227 1307 1228 /* Setup Context Information */ 1308 1229 p_addr += sizeof(u16) * BTINTEL_PCIE_NUM_QUEUES * 4;
+32
drivers/bluetooth/btintel_pcie.h
··· 48 48 #define BTINTEL_PCIE_CSR_MSIX_IVAR_BASE (BTINTEL_PCIE_CSR_MSIX_BASE + 0x0880) 49 49 #define BTINTEL_PCIE_CSR_MSIX_IVAR(cause) (BTINTEL_PCIE_CSR_MSIX_IVAR_BASE + (cause)) 50 50 51 + /* The DRAM buffer count, each buffer size, and 52 + * fragment buffer size 53 + */ 54 + #define BTINTEL_PCIE_DBGC_BUFFER_COUNT 16 55 + #define BTINTEL_PCIE_DBGC_BUFFER_SIZE (256 * 1024) /* 256 KB */ 56 + 57 + #define BTINTEL_PCIE_DBGC_FRAG_VERSION 1 58 + #define BTINTEL_PCIE_DBGC_FRAG_BUFFER_COUNT BTINTEL_PCIE_DBGC_BUFFER_COUNT 59 + 60 + /* Magic number(4), version(4), size of payload length(4) */ 61 + #define BTINTEL_PCIE_DBGC_FRAG_HEADER_SIZE 12 62 + 63 + /* Num of alloc Dbg buff (4) + (LSB(4), MSB(4), Size(4)) for each buffer */ 64 + #define BTINTEL_PCIE_DBGC_FRAG_PAYLOAD_SIZE 196 65 + 51 66 /* Causes for the FH register interrupts */ 52 67 enum msix_fh_int_causes { 53 68 BTINTEL_PCIE_MSIX_FH_INT_CAUSES_0 = BIT(0), /* cause 0 */ ··· 340 325 struct data_buf *bufs; 341 326 }; 342 327 328 + /* Structure for DRAM Buffer 329 + * @count: Number of descriptors 330 + * @buf: Array of data_buf structure 331 + */ 332 + struct btintel_pcie_dbgc { 333 + u16 count; 334 + 335 + void *frag_v_addr; 336 + dma_addr_t frag_p_addr; 337 + u16 frag_size; 338 + 339 + dma_addr_t buf_p_addr; 340 + void *buf_v_addr; 341 + struct data_buf *bufs; 342 + }; 343 + 343 344 /* struct btintel_pcie_data 344 345 * @pdev: pci device 345 346 * @hdev: hdev device ··· 436 405 struct txq txq; 437 406 struct rxq rxq; 438 407 u32 alive_intr_ctxt; 408 + struct btintel_pcie_dbgc dbgc; 439 409 }; 440 410 441 411 static inline u32 btintel_pcie_rd_reg32(struct btintel_pcie_data *data,