From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=198.175.65.13 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796205886; b=1B/Satc30AYXebHBiroYAARl1H268p4IE/l7wuu0LNMXcJYotVm/Di1qeiN/s+LIz2Zf 08gAUNPidHP9v6SulHu+faaICZACmDtTcocPmECDnt95lTYrcLCLZy2oIRwcIcxhCjGL7 /cpFFCJbWdKfhv8vbf4sBxqJlT+9KaMa0vtjhlWGp6cebq7bZxLfiiupRgw6k82HG0kHL /BYrky7V4nj13/aQcq965m5n0isPdMRm20XK+v7sxM2WJ682utrOGwmQNj3qt+XYLC+f4 JSzPRdTce8P5MSZit+yqCkAvTGmMVi5fmvMBAniGgiFcLE9/Gy1diyszZA562KIGqpw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796205886; h=DMARC-Filter:DKIM-Signature:X-CSE-ConnectionGUID:X-CSE-MsgGUID: X-IronPort-AV:X-IronPort-AV:Received:X-CSE-ConnectionGUID: X-CSE-MsgGUID:X-ExtLoop1:X-IronPort-AV:Received:From:To:Cc:Subject: Date:Message-ID:X-Mailer:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding; bh=C2XSB13axz8/bgpUdeGEx1ZwU6n1cL6GVpoKX39HloQ=; b=keNedCknrW0Tad2S7Tjb5HO8qn6kPKqQJXl8MuyUJpnw1D/Kaq8eNBLu5G8VDwQr3DDW MRZr10+bbCFYGNlflxZP7CMtp4FKbU4zqmwISx53BctPBGgU4NYj2JUlHnV0ztvh9+VB0 pPQrwugls7v6gEAHMH7+0Ia5m0Cy8Kashoid+0P3XCAFkV29XvE3a6jWnH4xEfiklFDjN wFElF4alZve144h3XSQtduOJ46htuhPoIpcsLvyW7tL43yXU+FNQrgHjHtvLHVoukwRZg YbqDWTKGyw8m5R8r3GHR2SE4oC6WoHScZe5u72fDa10U9HuXjM0oBN0A9qkaVHMWcdA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=Ewsq29XQ; arc=none smtp.remote-ip=198.175.65.13 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.13]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4DCE1606A32F; Wed, 2 Dec 2026 10:04:46 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 4DCE1606A32F Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=Ewsq29XQ DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1796205887; x=1827741887; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=C2XSB13axz8/bgpUdeGEx1ZwU6n1cL6GVpoKX39HloQ=; b=Ewsq29XQOL69vIUa4zpM6YTLht3UQNi4J+TW7utI+JMAYiTlR9i6LgYr SSGzR4BNr8+W2PA31uk1Z2URR8ym5xNJrSlmX1JMV96Fx2RfkRU1Lg6zL NJydnC6RS+aBQM+IlZVuo2gf3BbRbSCCB4rM521B8bE+Dven/1Mim9m3y nfbSAWFlaxsQcGL51HKShyTENxW87BaO5ABvAWpJ7vpZ7d5mvZKtUTvHh v8wS5T0YtUD+h9+HTYzUfVMRcUEkkimAK2a/YD0tnV7kUC4MnQIxLHzXx cbIvqkwwY4JmFhD6Za3j2xU1jq153JJPsjY4yDR6abIHNdiONs29MNoOf w==; X-CSE-ConnectionGUID: WdzbXicyR+eFzAhS6Q1onw== X-CSE-MsgGUID: ihQhmDgCRra4j/pWHy7+WQ== X-IronPort-AV: E=McAfee;i="6800,10657,11983"; a="5030610" X-IronPort-AV: E=Sophos;i="6.27,246,1787036400"; d="scan'208";a="5030610" Received: from orviesa005.jf.intel.com ([10.64.159.145]) by orvoesa105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Dec 2026 02:04:47 -0800 X-CSE-ConnectionGUID: G+R6oBgrSGC5j4xICpLVVQ== X-CSE-MsgGUID: L/tPg1HBTJeIC2PfzUmfwQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.27,246,1787036400"; d="scan'208";a="13297104" Received: from unknown (HELO WEBAPTLH032.iind.intel.com) ([10.66.250.231]) by orviesa005.jf.intel.com with ESMTP; 02 Dec 2026 02:04:43 -0800 From: Ajay KV To: linux-bluetooth@vger.kernel.org Cc: chandrashekar.devegowda@intel.com, kiran.k@intel.com, linux-kernel@vger.kernel.org, luiz.dentz@gmail.com, marcel@holtmann.org, stable@vger.kernel.org, chethan.tumkur.narayan@intel.com, lakshmipathi.k@intel.com, Ajay KV Subject: [PATCH v1 2/3] Bluetooth: btintel_pcie: Collect dump regions from yoyo region TLVs Date: Wed, 2 Dec 2026 12:04:35 +0200 Message-ID: <20261202100436.56353-2-ajay.k.v@intel.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20261202100436.56353-1-ajay.k.v@intel.com> References: <20261202100436.56353-1-ajay.k.v@intel.com> X-Mailing-List: linux-bluetooth@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit The yoyo configuration declares the debug regions to collect through Region TLVs, which are parsed and stored but not yet used by the dump. With yoyo enabled, the coredump now collects those regions instead of the built-in set. Device memory regions are read through target access. DRAM regions resolve their allocation ID to its DBGC buffers, copied once even when several regions name the same allocation. The built-in DRAM monitors are collected only when yoyo is disabled, so a configuration declaring none collects no DBGC buffers, as on Windows. A fixed region is skipped when a Region TLV claims its ID, unless the dump path cannot emit that region type. Region sizes from the file are capped so they cannot wrap the dump allocation, and unaligned device memory regions are skipped. Selecting regions by trigger follows in the next patch. Signed-off-by: Ajay KV --- drivers/bluetooth/btintel_pcie.c | 291 ++++++++++++++++++------- drivers/bluetooth/btintel_pcie.h | 19 +- drivers/bluetooth/btintel_pcie_debug.c | 34 +++ drivers/bluetooth/btintel_pcie_debug.h | 16 ++ 4 files changed, 269 insertions(+), 91 deletions(-) diff --git a/drivers/bluetooth/btintel_pcie.c b/drivers/bluetooth/btintel_pcie.c index e033bfed589a..3d4ce6f1f1ba 100644 --- a/drivers/bluetooth/btintel_pcie.c +++ b/drivers/bluetooth/btintel_pcie.c @@ -1295,8 +1295,9 @@ btintel_pcie_dump_dram_monitor(struct btintel_pcie_data *data, "allocation=%u wr_ptr_status=0x%08x write_ptr=0x%06x cur_frag=%u wrap_ctr=0x%08x", allocation_id, wr_ptr_status, write_ptr, cur_frag, wrap_ctr); - return btintel_pcie_dump_dram(list, count, buf_size, bufs, write_ptr, - wrap_ctr, cur_frag, region_id, name); + return btintel_pcie_dump_dram(list, count, buf_size, bufs, + write_ptr, wrap_ctr, cur_frag, region_id, + name); } static int btintel_pcie_dump_target_region(struct btintel_pcie_data *data, @@ -1332,6 +1333,13 @@ static int btintel_pcie_dump_target_region(struct btintel_pcie_data *data, } /* Align to 4 bytes - target access reads 32-bit words */ + if (!IS_ALIGNED(addr_start, sizeof(u32))) { + bt_dev_warn(data->hdev, + "Skipping dump region %s: addr_start 0x%08x is not 4-byte aligned", + name, addr_start); + return 1; + } + size = round_down(size, sizeof(u32)); if (!size) { bt_dev_warn(data->hdev, @@ -1444,6 +1452,9 @@ static int btintel_pcie_dump_smem_monitor_region(struct btintel_pcie_data *data, dest += sizeof(tempdata); } + bt_dev_dbg(data->hdev, "dumped smem region %u (%s) size=%u", + region_id, name, size); + list_add_tail(&entry->list, list); return 0; } @@ -1550,50 +1561,157 @@ static bool btintel_pcie_is_mdbgc_supported(struct btintel_pcie_data *data) data->pdev->device == BTINTEL_PCIE_DEVICE_ID_PTL_FMP2; } +/* Built-in DRAM monitor regions, dumped only when yoyo is disabled. An + * enabled configuration declares the DRAM regions it wants, as on Windows. + */ +static const struct btintel_pcie_dram_monitor { + u32 alloc_id; + u32 region_id; + const char *name; +} dram_monitors[] = { + { BTINTEL_PCIE_ALLOC_ID_DBGC1, BTINTEL_PCIE_INI_ID_DRAM_MONITOR1, "monitor" }, + { BTINTEL_PCIE_ALLOC_ID_DBGC2, BTINTEL_PCIE_INI_ID_DRAM_MONITOR2, "monitor2" }, + { BTINTEL_PCIE_ALLOC_ID_DBGC3, BTINTEL_PCIE_INI_ID_DRAM_MONITOR3, "monitor3" }, +}; + +/* Resolves @alloc_id to its allocated DBGC buffers. Returns false when the ID + * is not one this SKU allocates. + */ +static bool btintel_pcie_get_dbgc_buf_set(struct btintel_pcie_data *data, + u32 alloc_id, + struct btintel_pcie_dbgc_buf_set *set) +{ + if (!btintel_pcie_is_mdbgc_supported(data)) { + if (alloc_id != BTINTEL_PCIE_ALLOC_ID_DBGC1) + return false; + + set->bufs = data->dbgc.bufs; + set->count = data->dbgc.count; + set->buf_size = data->dbgc.buf_size; + set->allocation_id = BTINTEL_PCIE_MDBGC_ALLOCATIONID_1; + return true; + } + + switch (alloc_id) { + case BTINTEL_PCIE_ALLOC_ID_DBGC1: + set->bufs = data->mdbgc.buf1; + set->count = data->mdbgc.buf1_count; + set->buf_size = data->mdbgc.buf1_size; + set->allocation_id = BTINTEL_PCIE_MDBGC_ALLOCATIONID_1; + return true; + case BTINTEL_PCIE_ALLOC_ID_DBGC2: + set->bufs = data->mdbgc.buf2; + set->count = data->mdbgc.buf2_count; + set->buf_size = data->mdbgc.buf2_size; + set->allocation_id = BTINTEL_PCIE_MDBGC_ALLOCATIONID_2; + return true; + case BTINTEL_PCIE_ALLOC_ID_DBGC3: + set->bufs = data->mdbgc.buf3; + set->count = data->mdbgc.buf3_count; + set->buf_size = data->mdbgc.buf3_size; + set->allocation_id = BTINTEL_PCIE_MDBGC_ALLOCATIONID_3; + return true; + default: + return false; + } +} + static void btintel_pcie_dump_mem_range(struct btintel_pcie_data *data, struct list_head *list, u32 region_id, const char *name, u32 addr_start, u32 region_size, u64 *regions_mask) { - if (!region_size) + if (!region_size || + btintel_pcie_yoyo_region_configured(&data->yoyo, region_id)) { return; + } + + bt_dev_dbg(data->hdev, "dumping region %u (%s) size=%u", + region_id, name, region_size); if (!btintel_pcie_dump_target_region(data, list, region_id, name, addr_start, region_size)) *regions_mask |= BIT_ULL(region_id); } +static int btintel_pcie_yoyo_dump_region(struct btintel_pcie_data *data, + struct list_head *list, + struct btintel_pcie_yoyo_region *region, + u32 status_reg, u32 wrap_reg) +{ + char name[BTINTEL_PCIE_REGION_NAME_LEN + 1]; + struct btintel_pcie_dbgc_buf_set set; + u32 addr_offset, addr_start, alloc_id, size; + + memcpy(name, region->name, BTINTEL_PCIE_REGION_NAME_LEN); + name[BTINTEL_PCIE_REGION_NAME_LEN] = '\0'; + + switch (region->type) { + case BTINTEL_PCIE_REGION_DEVICE_MEM: + if (!region->num_addrs || !region->addrs) { + bt_dev_warn(data->hdev, + "YoYo: device-memory region %u has no address", + region->region_id); + return -ENOENT; + } + + size = get_unaligned_le32(®ion->conf.dev_addr.size_bytes); + addr_offset = get_unaligned_le32(®ion->conf.dev_addr.addr_offset); + + if (check_add_overflow(region->addrs[0], addr_offset, + &addr_start)) { + bt_dev_warn(data->hdev, + "YoYo: region %u address 0x%08x + offset 0x%08x overflows", + region->region_id, region->addrs[0], + addr_offset); + return -EINVAL; + } + + return btintel_pcie_dump_target_region(data, list, region->region_id, + name, addr_start, size); + case BTINTEL_PCIE_REGION_DRAM_BUF: + alloc_id = get_unaligned_le32(®ion->conf.dram_alloc_id); + if (!btintel_pcie_get_dbgc_buf_set(data, alloc_id, &set)) { + bt_dev_warn(data->hdev, + "YoYo: invalid DRAM allocation ID %u for region %u", + alloc_id, region->region_id); + return -EINVAL; + } + + return btintel_pcie_dump_dram_monitor(data, list, set.count, + set.buf_size, set.bufs, + status_reg, wrap_reg, + set.allocation_id, + region->region_id, name); + default: + bt_dev_warn(data->hdev, + "YoYo: unsupported region type %u for region %u", + region->type, region->region_id); + return -EOPNOTSUPP; + } +} + static int btintel_pcie_read_debug_regions(struct btintel_pcie_data *data) { - struct btintel_pcie_dbgc *dbgc = NULL; - struct btintel_pcie_mdbgc *mdbgc = NULL; struct btintel_pcie_dump_mem_info *dump_info = &data->dump_info; struct hci_dev *hdev = data->hdev; struct btintel_pcie_dump_entry *entry; struct btintel_pcie_dump_file_hdr *file_hdr; + struct btintel_pcie_yoyo_region *region; struct scatterlist *sg_dump_data; u32 status_reg, wrap_reg; + u32 dumped_dram_allocs = 0; + u32 alloc_id; u64 regions_mask = 0; u8 hw_variant; u32 file_len; - u8 count; - u32 buf_size; int ret; + u32 i; LIST_HEAD(dump_list); if (!IS_ENABLED(CONFIG_DEV_COREDUMP)) return -EOPNOTSUPP; - if (btintel_pcie_is_mdbgc_supported(data)) { - mdbgc = &data->mdbgc; - count = mdbgc->buf1_count; - buf_size = mdbgc->buf1_size; - } else { - dbgc = &data->dbgc; - count = dbgc->count; - buf_size = dbgc->buf_size; - } - hw_variant = INTEL_HW_VARIANT(data->cnvi); if (hw_variant == BTINTEL_HWID_BZRI || @@ -1610,73 +1728,86 @@ static int btintel_pcie_read_debug_regions(struct btintel_pcie_data *data) return -EINVAL; } - if (btintel_pcie_is_mdbgc_supported(data)) { - ret = btintel_pcie_dump_dram_monitor(data, &dump_list, - mdbgc->buf1_count, - mdbgc->buf1_size, - mdbgc->buf1, status_reg, - wrap_reg, - BTINTEL_PCIE_MDBGC_ALLOCATIONID_1, - BTINTEL_PCIE_INI_ID_DRAM_MONITOR1, - "monitor"); - if (!ret) - regions_mask |= - BIT_ULL(BTINTEL_PCIE_INI_ID_DRAM_MONITOR1); - else if (ret != -ENOENT) - bt_dev_warn(hdev, "Failed to dump DRAM buf1: %d", ret); - - ret = btintel_pcie_dump_dram_monitor(data, &dump_list, - mdbgc->buf2_count, - mdbgc->buf2_size, - mdbgc->buf2, status_reg, - wrap_reg, - BTINTEL_PCIE_MDBGC_ALLOCATIONID_2, - BTINTEL_PCIE_INI_ID_DRAM_MONITOR2, - "monitor2"); - if (!ret) - regions_mask |= - BIT_ULL(BTINTEL_PCIE_INI_ID_DRAM_MONITOR2); - else if (ret != -ENOENT) - bt_dev_warn(hdev, "Failed to dump DRAM buf2: %d", ret); - - ret = btintel_pcie_dump_dram_monitor(data, &dump_list, - mdbgc->buf3_count, - mdbgc->buf3_size, - mdbgc->buf3, status_reg, - wrap_reg, - BTINTEL_PCIE_MDBGC_ALLOCATIONID_3, - BTINTEL_PCIE_INI_ID_DRAM_MONITOR3, - "monitor3"); - if (!ret) - regions_mask |= - BIT_ULL(BTINTEL_PCIE_INI_ID_DRAM_MONITOR3); - else if (ret != -ENOENT) - bt_dev_warn(hdev, "Failed to dump DRAM buf3: %d", ret); + /* Collect the debug regions into a devcoredump. With YoYo enabled the + * REGION TLVs declare them, otherwise the built-in DRAM monitors are + * used. + */ + if (data->yoyo.enabled) { + list_for_each_entry(region, &data->yoyo.region_list, list) { + alloc_id = 0; + /* Several regions may name the same allocation; copy + * its buffers once. + */ + if (region->type == BTINTEL_PCIE_REGION_DRAM_BUF) { + alloc_id = get_unaligned_le32(®ion->conf.dram_alloc_id); + + if (alloc_id < BTINTEL_PCIE_ALLOC_ID_MAX && + dumped_dram_allocs & BIT(alloc_id)) + continue; + } + + ret = btintel_pcie_yoyo_dump_region(data, &dump_list, + region, status_reg, + wrap_reg); + if (!ret) { + regions_mask |= BIT_ULL(region->region_id); + if (alloc_id) + dumped_dram_allocs |= BIT(alloc_id); + } else if (ret < 0 && ret != -ENOENT && ret != -EOPNOTSUPP) { + bt_dev_warn(hdev, + "YoYo: failed to dump region %u: %d", + region->region_id, ret); + } + + bt_dev_dbg(hdev, "YoYo: region %u type=%u dump ret=%d", + region->region_id, region->type, ret); + } } else { - ret = btintel_pcie_dump_dram_monitor(data, &dump_list, count, - buf_size, dbgc->bufs, - status_reg, - wrap_reg, - BTINTEL_PCIE_MDBGC_ALLOCATIONID_1, - BTINTEL_PCIE_INI_ID_DRAM_MONITOR1, - "monitor"); - if (!ret) - regions_mask |= - BIT_ULL(BTINTEL_PCIE_INI_ID_DRAM_MONITOR1); - else - bt_dev_warn(hdev, - "Failed to dump DRAM region: %d", ret); + /* Legacy DRAM monitors. YoYo declares its own via REGION TLVs, + * so this runs instead of the loop above, as on Windows. + * get_dbgc_buf_set() resolves only the allocations this SKU + * has, so single-DBGC skips DBGC2 and DBGC3. + */ + for (i = 0; i < ARRAY_SIZE(dram_monitors); i++) { + const struct btintel_pcie_dram_monitor *mon = &dram_monitors[i]; + struct btintel_pcie_dbgc_buf_set set; + + if (!btintel_pcie_get_dbgc_buf_set(data, mon->alloc_id, &set)) + continue; + + ret = btintel_pcie_dump_dram_monitor(data, &dump_list, + set.count, + set.buf_size, + set.bufs, + status_reg, wrap_reg, + set.allocation_id, + mon->region_id, + mon->name); + if (!ret) + regions_mask |= BIT_ULL(mon->region_id); + else if (ret != -ENOENT) + bt_dev_warn(hdev, "Failed to dump %s: %d", + mon->name, ret); + + bt_dev_dbg(hdev, "builtin region %u (%s) dump ret=%d", + mon->region_id, mon->name, ret); + } } if (dump_info->smem_size && - !btintel_pcie_dump_smem_monitor_region(data, &dump_list, - BTINTEL_PCIE_INI_ID_SMEM, - "monitor_smem", - dump_info->smem_addr_start, - dump_info->smem_size)) - regions_mask |= BIT_ULL(BTINTEL_PCIE_INI_ID_SMEM); - - if (dump_info->exception_dump_addr && dump_info->exception_dump_len) { + !btintel_pcie_yoyo_region_configured(&data->yoyo, + BTINTEL_PCIE_INI_ID_SMEM)) { + if (!btintel_pcie_dump_smem_monitor_region(data, &dump_list, + BTINTEL_PCIE_INI_ID_SMEM, + "monitor_smem", + dump_info->smem_addr_start, + dump_info->smem_size)) + regions_mask |= BIT_ULL(BTINTEL_PCIE_INI_ID_SMEM); + } + + if (dump_info->exception_dump_addr && dump_info->exception_dump_len && + !btintel_pcie_yoyo_region_configured(&data->yoyo, + BTINTEL_PCIE_INI_ID_EXCEPTION_EVT)) { ret = btintel_pcie_dump_target_region(data, &dump_list, BTINTEL_PCIE_INI_ID_EXCEPTION_EVT, "EXCEPTION_EVT_BUFFER", diff --git a/drivers/bluetooth/btintel_pcie.h b/drivers/bluetooth/btintel_pcie.h index 97267a7e9762..1dd32ea64fc4 100644 --- a/drivers/bluetooth/btintel_pcie.h +++ b/drivers/bluetooth/btintel_pcie.h @@ -529,6 +529,14 @@ struct btintel_pcie_mdbgc { struct data_buf *buf3; }; +/* DBGC buffer set resolved from a YoYo allocation ID */ +struct btintel_pcie_dbgc_buf_set { + struct data_buf *bufs; + u8 count; + u32 buf_size; + u8 allocation_id; +}; + struct btintel_pcie_dump_mem_info { u32 exception_dump_addr; u32 exception_dump_len; @@ -591,17 +599,6 @@ struct btintel_pcie_dump_range { #define BTINTEL_PCIE_INI_REGION_DRAM_BUFFER 3 #define BTINTEL_PCIE_INI_REGION_DEVICE_MEMORY 9 -/* INI region IDs - used in dump header region_id field and regions_mask */ -#define BTINTEL_PCIE_INI_ID_EXCEPTION_EVT 7 -#define BTINTEL_PCIE_INI_ID_SMEM 15 -#define BTINTEL_PCIE_INI_ID_DCCM 39 -#define BTINTEL_PCIE_INI_ID_SDS 40 -#define BTINTEL_PCIE_INI_ID_SDS_IOSF 41 -#define BTINTEL_PCIE_INI_ID_ECL 42 -#define BTINTEL_PCIE_INI_ID_DRAM_MONITOR3 61 -#define BTINTEL_PCIE_INI_ID_DRAM_MONITOR2 62 -#define BTINTEL_PCIE_INI_ID_DRAM_MONITOR1 63 - /* * INI (Intel INI debug infrastructure) style dump data TLV - wraps each dump * region. INI is the iwlwifi firmware debug format used by the unified decoder. diff --git a/drivers/bluetooth/btintel_pcie_debug.c b/drivers/bluetooth/btintel_pcie_debug.c index 9dc380ec9c6b..8a7d884f9a0e 100644 --- a/drivers/bluetooth/btintel_pcie_debug.c +++ b/drivers/bluetooth/btintel_pcie_debug.c @@ -593,6 +593,13 @@ static int btintel_pcie_yoyo_parse_region(struct btintel_pcie_yoyo_ctx *ctx, return 0; } + /* An unbounded size from the file would wrap the dump allocation size */ + if (size > BTINTEL_PCIE_YOYO_REGION_MAX_SIZE) { + BT_WARN("YoYo: region id=%u size %u exceeds cap %u, skipping", + region_id, size, BTINTEL_PCIE_YOYO_REGION_MAX_SIZE); + return 0; + } + region = kzalloc(sizeof(*region), GFP_KERNEL); if (!region) return -ENOMEM; @@ -1001,6 +1008,33 @@ btintel_pcie_yoyo_find_trigger(struct btintel_pcie_yoyo_ctx *ctx, } EXPORT_SYMBOL_GPL(btintel_pcie_yoyo_find_trigger); +/* Region types the dump path can emit. The parser accepts every type the + * file may carry, so a region of any other type must not claim its ID. + */ +static bool btintel_pcie_yoyo_region_dumpable(const struct btintel_pcie_yoyo_region *region) +{ + return region->type == BTINTEL_PCIE_REGION_DEVICE_MEM || + region->type == BTINTEL_PCIE_REGION_DRAM_BUF; +} + +/* Check if a region TLV claims region_id */ +bool btintel_pcie_yoyo_region_configured(struct btintel_pcie_yoyo_ctx *ctx, + u32 region_id) +{ + struct btintel_pcie_yoyo_region *region; + + if (!ctx || !ctx->enabled) + return false; + + list_for_each_entry(region, &ctx->region_list, list) { + if (region->region_id == region_id) + return btintel_pcie_yoyo_region_dumpable(region); + } + + return false; +} +EXPORT_SYMBOL_GPL(btintel_pcie_yoyo_region_configured); + /** * btintel_pcie_yoyo_get_buf_alloc - Query buffer allocation config for a DBGC * @ctx: YoYo context diff --git a/drivers/bluetooth/btintel_pcie_debug.h b/drivers/bluetooth/btintel_pcie_debug.h index 9d5ed7729fe8..9fae4f5eb67b 100644 --- a/drivers/bluetooth/btintel_pcie_debug.h +++ b/drivers/bluetooth/btintel_pcie_debug.h @@ -78,6 +78,19 @@ bool btintel_pcie_fatal_err_testmode_active(struct btintel_pcie_data *data); #define BTINTEL_PCIE_REGION_ID_MAX 63 #define BTINTEL_PCIE_REGION_NAME_LEN 32 #define BTINTEL_PCIE_REGION_LIST_SIZE 2 +/* Mirrors BTINTEL_PCIE_REGION_MAX_SIZE, bounds dump allocation */ +#define BTINTEL_PCIE_YOYO_REGION_MAX_SIZE (1 * 1024 * 1024) + +/* INI region IDs - used in dump header region_id field and regions_mask */ +#define BTINTEL_PCIE_INI_ID_EXCEPTION_EVT 7 +#define BTINTEL_PCIE_INI_ID_SMEM 15 +#define BTINTEL_PCIE_INI_ID_DCCM 39 +#define BTINTEL_PCIE_INI_ID_SDS 40 +#define BTINTEL_PCIE_INI_ID_SDS_IOSF 41 +#define BTINTEL_PCIE_INI_ID_ECL 42 +#define BTINTEL_PCIE_INI_ID_DRAM_MONITOR3 61 +#define BTINTEL_PCIE_INI_ID_DRAM_MONITOR2 62 +#define BTINTEL_PCIE_INI_ID_DRAM_MONITOR1 63 enum btintel_pcie_image_tlv_type { BTINTEL_PCIE_IMAGE_TLV_TYPE_EXTERNAL = 0x1, @@ -486,4 +499,7 @@ const struct btintel_pcie_yoyo_trigger * btintel_pcie_yoyo_find_trigger(struct btintel_pcie_yoyo_ctx *ctx, enum btintel_pcie_dbg_timepoint tp); +bool btintel_pcie_yoyo_region_configured(struct btintel_pcie_yoyo_ctx *ctx, + u32 region_id); + #endif /* __BTINTEL_PCIE_DEBUG_H__ */ -- 2.53.0