* [PATCH v1] Bluetooth: btintel_pcie: Add support for paging over DRAM
@ 2026-11-19 17:41 Chandrashekar Devegowda
2026-11-20 0:00 ` [v1] " bluez.test.bot
0 siblings, 1 reply; 2+ messages in thread
From: Chandrashekar Devegowda @ 2026-11-19 17:41 UTC (permalink / raw)
To: linux-bluetooth; +Cc: chethan.tumkur.narayan, kiran.k, Chandrashekar Devegowda
Configure the extended context info so that the controller can page
firmware code over host DRAM. Allocate DMA memory for the paging TLV, the
paged DRAM table and the pages it describes, and pass their address and
size to the controller through the extended context info address and size
fields of the context info.
All allocations are device managed, so no additional cleanup is needed in
the error or remove paths.
Tested on PTL platform by downloading the firmware with the extended
context info configured. The download completes and the controller comes
up.
Signed-off-by: Chandrashekar Devegowda <chandrashekar.devegowda@intel.com>
---
drivers/bluetooth/btintel_pcie.c | 71 ++++++++++++++++++++++++++++++++
drivers/bluetooth/btintel_pcie.h | 57 +++++++++++++++++++++++++
2 files changed, 128 insertions(+)
diff --git a/drivers/bluetooth/btintel_pcie.c b/drivers/bluetooth/btintel_pcie.c
index 382e02851758..435ee41a298d 100644
--- a/drivers/bluetooth/btintel_pcie.c
+++ b/drivers/bluetooth/btintel_pcie.c
@@ -7,6 +7,7 @@
*/
#include <linux/kernel.h>
+#include <linux/bitfield.h>
#include <linux/module.h>
#include <linux/firmware.h>
#include <linux/overflow.h>
@@ -3576,6 +3577,72 @@ static int btintel_pcie_config_pcie(struct pci_dev *pdev,
return 0;
}
+/* Set up the extended context info with the paging TLV and the DRAM pages
+ * the controller can use for paging. All memory is device managed and is
+ * released when the driver is unbound.
+ */
+static int btintel_pcie_alloc_ext_ctxt_info(struct btintel_pcie_data *data)
+{
+ struct device *dev = &data->pdev->dev;
+ struct btintel_pcie_page_table *page_table;
+ struct btintel_pcie_paging_tlv *paging;
+ struct btintel_pcie_ext_ctxt *ext_ci;
+ u32 ext_ci_size;
+ size_t info_size, total_size;
+ dma_addr_t p_addr, page_p_addr;
+ void *v_addr;
+ int i;
+
+ info_size = ALIGN(sizeof(*ext_ci), BTINTEL_PCIE_DMA_ALIGN_128B);
+ total_size = info_size + ALIGN(sizeof(*page_table),
+ BTINTEL_PCIE_DMA_ALIGN_128B);
+
+ v_addr = dmam_alloc_coherent(dev, total_size, &p_addr,
+ GFP_KERNEL | __GFP_NOWARN);
+ if (!v_addr)
+ return -ENOMEM;
+
+ ext_ci = v_addr;
+ page_table = v_addr + info_size;
+
+ ext_ci->version = cpu_to_le16(BTINTEL_PCIE_EXTCTXT_INFO_VER);
+ ext_ci->size_dw = cpu_to_le16(sizeof(*paging) / sizeof(u32));
+
+ paging = &ext_ci->paging;
+ paging->type = cpu_to_le16(BTINTEL_PCIE_PAGING_TYPE);
+ paging->len_dw = cpu_to_le16((sizeof(*paging) -
+ offsetof(struct btintel_pcie_paging_tlv,
+ high)) / sizeof(u32));
+ paging->high = cpu_to_le32(upper_32_bits(p_addr + info_size));
+ paging->low = cpu_to_le32(lower_32_bits(p_addr + info_size));
+ paging->size = cpu_to_le32(sizeof(*page_table));
+
+ page_table->num_of_pages = cpu_to_le32(BTINTEL_PCIE_PAGING_NUM_PAGES);
+ page_table->bytes_per_page = cpu_to_le32(BTINTEL_PCIE_PAGING_PAGE_SIZE);
+
+ for (i = 0; i < BTINTEL_PCIE_PAGING_NUM_PAGES; i++) {
+ if (!dmam_alloc_coherent(dev, BTINTEL_PCIE_PAGING_PAGE_SIZE,
+ &page_p_addr,
+ GFP_KERNEL | __GFP_NOWARN))
+ return -ENOMEM;
+
+ page_table->pages[i].addr_high =
+ cpu_to_le32(upper_32_bits(page_p_addr));
+ page_table->pages[i].addr_low =
+ cpu_to_le32(lower_32_bits(page_p_addr));
+ }
+
+ ext_ci_size = FIELD_PREP(BTINTEL_PCIE_EXT_CI_SIZE_MASK,
+ sizeof(*ext_ci)) |
+ BTINTEL_PCIE_EXT_CI_BLOCKING_MODE |
+ BTINTEL_PCIE_EXT_CI_VALID;
+
+ data->ci->ext_addr = p_addr;
+ data->ci->ext_size = ext_ci_size;
+
+ return 0;
+}
+
static void btintel_pcie_init_ci(struct btintel_pcie_data *data,
struct ctx_info *ci)
{
@@ -3862,6 +3929,10 @@ static int btintel_pcie_alloc(struct btintel_pcie_data *data)
data->ci = v_addr;
data->ci_p_addr = p_addr;
+ err = btintel_pcie_alloc_ext_ctxt_info(data);
+ if (err)
+ goto exit_error_rxq;
+
/* Initialize the CI */
btintel_pcie_init_ci(data, data->ci);
diff --git a/drivers/bluetooth/btintel_pcie.h b/drivers/bluetooth/btintel_pcie.h
index b60e24ca558d..615e2218ad99 100644
--- a/drivers/bluetooth/btintel_pcie.h
+++ b/drivers/bluetooth/btintel_pcie.h
@@ -137,6 +137,12 @@
#define BTINTEL_PCIE_DEVICE_ID_NVL_Hx_SCP2 0xD346
#define BTINTEL_PCIE_DEVICE_ID_PTL_FMP2 0xE476
+/* Extended context information */
+#define BTINTEL_PCIE_EXTCTXT_INFO_VER 0xA00A
+#define BTINTEL_PCIE_PAGING_TYPE 0x0081
+#define BTINTEL_PCIE_PAGING_NUM_PAGES 256
+#define BTINTEL_PCIE_PAGING_PAGE_SIZE (4 * 1024)
+
/* Causes for the FH register interrupts */
enum msix_fh_int_causes {
BTINTEL_PCIE_MSIX_FH_INT_CAUSES_0 = BIT(0), /* cause 0 */
@@ -282,6 +288,17 @@ enum {
#define BTINTEL_PCIE_TLV_TYPE_ECL_MEM_ADDRESS 0x07
#define BTINTEL_PCIE_TLV_TYPE_SMEM_ADDRESS 0x08
+/*
+ * Extended context info size, written to ctx_info.ext_size
+ * bits[0:15] - extended context info size in bytes
+ * bits[16:29] - reserved
+ * bit[30] - blocking_mode
+ * bit[31] - valid
+ */
+#define BTINTEL_PCIE_EXT_CI_SIZE_MASK GENMASK(15, 0)
+#define BTINTEL_PCIE_EXT_CI_BLOCKING_MODE BIT(30)
+#define BTINTEL_PCIE_EXT_CI_VALID BIT(31)
+
/*
* Struct for Context Information (v2)
*
@@ -712,6 +729,46 @@ struct btintel_pcie_ini_dump_info {
/* no cfg_names for BT - keep zero-length */
} __packed;
+/* TLV describing the paged DRAM table
+ * @type: The TLV id
+ * @len_dw: The TLV payload length in dwords
+ * @high: The MSB of the paged DRAM table address
+ * @low: The LSB of the paged DRAM table address
+ * @size: The size of the paged DRAM table in bytes
+ */
+struct btintel_pcie_paging_tlv {
+ __le16 type;
+ __le16 len_dw;
+ __le32 high;
+ __le32 low;
+ __le32 size;
+} __packed;
+
+/* Extended context info, pointed to by ctx_info.ext_addr
+ * @version: The extended context info version
+ * @size_dw: The size of all the TLVs that follow in dwords
+ * @paging: The paging TLV
+ */
+struct btintel_pcie_ext_ctxt {
+ __le16 version;
+ __le16 size_dw;
+ struct btintel_pcie_paging_tlv paging;
+} __packed;
+
+/* Paged DRAM table
+ * @num_of_pages: Total number of pages allocated in host DRAM
+ * @bytes_per_page: Size of each page in bytes
+ * @pages: DMA address of each page
+ */
+struct btintel_pcie_page_table {
+ __le32 num_of_pages;
+ __le32 bytes_per_page;
+ struct {
+ __le32 addr_high;
+ __le32 addr_low;
+ } pages[BTINTEL_PCIE_PAGING_NUM_PAGES];
+} __packed;
+
/* struct btintel_pcie_data
* @pdev: pci device
* @hdev: hdev device
--
2.43.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-11-20 0:00 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-19 17:41 [PATCH v1] Bluetooth: btintel_pcie: Add support for paging over DRAM Chandrashekar Devegowda
2026-11-20 0:00 ` [v1] " bluez.test.bot
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox