From: Ajay KV <ajay.k.v@intel.com>
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 <ajay.k.v@intel.com>
Subject: [PATCH v2 1/3] Bluetooth: btintel_pcie: Add yoyo configuration for trigger tlv
Date: Wed, 2 Dec 2026 13:31:01 +0200 [thread overview]
Message-ID: <20261202113103.69237-1-ajay.k.v@intel.com> (raw)
This patch enables TLV-based debug configuration for Trigger TLV
Type.
A Trigger TLV binds a timepoint to a 64-bit bitmask of debug region
IDs. It collects nothing by itself: it records which regions a dump
should contain when the matching timepoint is reached. Looking the
trigger up and acting on its region mask is done by a later patch.
Only the timepoint, trigger reason, and region mask are kept at
runtime. The on-disk structure still declares every field, because
it defines the wire layout and drives the fixed-size length check.
Occurrence limit, ignore consecutive duration, delayed dumping,
stop dump limit, trigger policy mask and firmware reset mode are
not supported in phase 1.
A duplicate timepoint replaces the earlier entry, since lookup returns
the first match and a later entry would otherwise sit unreachable
behind it. A domain or version mismatch skips the record and keeps
parsing the rest of the file.
This patch contains :
- Handling of TLV parser/validation for Trigger TLV.
- Add configuration into trigger list in yoyo context
- Look up the trigger configured for a timepoint
Signed-off-by: Ajay KV <ajay.k.v@intel.com>
---
drivers/bluetooth/btintel_pcie_debug.c | 98 ++++++++++++++++++++++++++
drivers/bluetooth/btintel_pcie_debug.h | 51 +++++++++++++-
2 files changed, 148 insertions(+), 1 deletion(-)
diff --git a/drivers/bluetooth/btintel_pcie_debug.c b/drivers/bluetooth/btintel_pcie_debug.c
index fb18e18c0b76..9dc380ec9c6b 100644
--- a/drivers/bluetooth/btintel_pcie_debug.c
+++ b/drivers/bluetooth/btintel_pcie_debug.c
@@ -702,6 +702,67 @@ static int btintel_pcie_yoyo_parse_hcmd(struct btintel_pcie_yoyo_ctx *ctx,
return 0;
}
+static int btintel_pcie_yoyo_parse_trigger(struct btintel_pcie_yoyo_ctx *ctx,
+ const struct btintel_pcie_tlv_trigger *tlv,
+ u32 len)
+{
+ u32 fixed_size = sizeof(*tlv) - sizeof(struct btintel_pcie_tlv_hdr);
+ struct btintel_pcie_yoyo_trigger *old_trigger, *trigger;
+ u32 domain, time_point, version;
+
+ if (len < fixed_size) {
+ BT_WARN("YoYo: trigger tlv is too short or Invalid");
+ return -EBADMSG;
+ }
+
+ domain = get_unaligned_le32(&tlv->dbg_hdr.domain);
+ version = get_unaligned_le32(&tlv->dbg_hdr.tlv_data_version);
+ if (domain != BTINTEL_PCIE_DOMAIN_BT ||
+ version != BTINTEL_PCIE_TRIGGER_TLV_VERSION) {
+ BT_WARN("YoYo: unsupported trigger domain/version (%u/%u), skipping",
+ domain, version);
+ return 0;
+ }
+
+ time_point = get_unaligned_le32(&tlv->time_point);
+ if (time_point <= BTINTEL_PCIE_TP_INVALID ||
+ time_point >= BTINTEL_PCIE_TP_MAX_NUM) {
+ BT_WARN("YoYo: invalid trigger timepoint %u, skipping",
+ time_point);
+ return 0;
+ }
+
+ trigger = kzalloc_obj(*trigger, GFP_KERNEL);
+ if (!trigger)
+ return -ENOMEM;
+
+ /* Phase 1 consumes only the timepoint, trigger_reason, and the region
+ * mask. Remaining TLV fields stay unparsed.
+ */
+ trigger->time_point = time_point;
+ trigger->trigger_reason = get_unaligned_le32(&tlv->trigger_reason);
+ trigger->regions_mask[0] = get_unaligned_le32(&tlv->regions_list_mask[0]);
+ trigger->regions_mask[1] = get_unaligned_le32(&tlv->regions_list_mask[1]);
+
+ BT_DBG("YoYo: trigger tp=%u reason=%u regions=0x%08x%08x",
+ trigger->time_point, trigger->trigger_reason,
+ trigger->regions_mask[1], trigger->regions_mask[0]);
+
+ /* Lookup returns the first match, so a later duplicate must replace
+ * the earlier entry rather than sit unreachable behind it.
+ */
+ list_for_each_entry(old_trigger, &ctx->trigger_list, list) {
+ if (old_trigger->time_point == time_point) {
+ list_replace(&old_trigger->list, &trigger->list);
+ kfree(old_trigger);
+ return 0;
+ }
+ }
+
+ list_add_tail(&trigger->list, &ctx->trigger_list);
+ return 0;
+}
+
/*
* Parse the optional YoYo firmware TLV stream and validate each record.
* This is the entry point for the runtime debug configuration payload.
@@ -752,6 +813,8 @@ static int btintel_pcie_yoyo_parse_tlv_buffer(struct btintel_pcie_yoyo_ctx *ctx,
ret = btintel_pcie_yoyo_parse_hcmd(ctx, (const void *)tlv, len);
break;
case BTINTEL_PCIE_TLV_TYPE_DBG_TRIGGER:
+ ret = btintel_pcie_yoyo_parse_trigger(ctx, (const void *)tlv, len);
+ break;
case BTINTEL_PCIE_TLV_TYPE_DBG_PRESET_OVERRIDE:
BT_DBG("YoYo: valid tlv type 0x%x len=%u", type, len);
break;
@@ -811,6 +874,7 @@ EXPORT_SYMBOL_GPL(btintel_pcie_yoyo_init);
void btintel_pcie_yoyo_cleanup(struct btintel_pcie_yoyo_ctx *ctx)
{
struct btintel_pcie_yoyo_config_set *config_set, *config_tmp;
+ struct btintel_pcie_yoyo_trigger *trigger, *trigger_tmp;
struct btintel_pcie_yoyo_region *region, *region_tmp;
struct btintel_pcie_yoyo_hcmd *hcmd, *hcmd_tmp;
@@ -842,6 +906,12 @@ void btintel_pcie_yoyo_cleanup(struct btintel_pcie_yoyo_ctx *ctx)
kfree(hcmd->cmd_data);
kfree(hcmd);
}
+
+ list_for_each_entry_safe(trigger, trigger_tmp, &ctx->trigger_list, list) {
+ list_del(&trigger->list);
+ kfree(trigger);
+ }
+
mutex_unlock(&ctx->lock);
}
EXPORT_SYMBOL_GPL(btintel_pcie_yoyo_cleanup);
@@ -903,6 +973,34 @@ int btintel_pcie_yoyo_load_and_parse(struct btintel_pcie_yoyo_ctx *ctx,
}
EXPORT_SYMBOL_GPL(btintel_pcie_yoyo_load_and_parse);
+/**
+ * btintel_pcie_yoyo_find_trigger - Look up the trigger configured for a timepoint
+ * @ctx: YoYo context holding the parsed trigger list
+ * @tp: timepoint to resolve
+ *
+ * Caller must hold @ctx->lock to serialize against btintel_pcie_yoyo_cleanup()
+ * and ensure the returned pointer remains valid during use.
+ *
+ * Return: the first matching trigger, or NULL when none is configured or YoYo
+ * is disabled.
+ */
+const struct btintel_pcie_yoyo_trigger *
+btintel_pcie_yoyo_find_trigger(struct btintel_pcie_yoyo_ctx *ctx,
+ enum btintel_pcie_dbg_timepoint tp)
+{
+ struct btintel_pcie_yoyo_trigger *t;
+
+ if (!ctx || !ctx->enabled)
+ return NULL;
+
+ list_for_each_entry(t, &ctx->trigger_list, list) {
+ if (t->time_point == tp)
+ return t;
+ }
+ return NULL;
+}
+EXPORT_SYMBOL_GPL(btintel_pcie_yoyo_find_trigger);
+
/**
* 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 6882895de18d..9d5ed7729fe8 100644
--- a/drivers/bluetooth/btintel_pcie_debug.h
+++ b/drivers/bluetooth/btintel_pcie_debug.h
@@ -63,6 +63,7 @@ bool btintel_pcie_fatal_err_testmode_active(struct btintel_pcie_data *data);
#define BTINTEL_PCIE_CONFIG_SET_TLV_VERSION 1
#define BTINTEL_PCIE_REGION_TLV_VERSION 3
#define BTINTEL_PCIE_HCMD_TLV_VERSION 1
+#define BTINTEL_PCIE_TRIGGER_TLV_VERSION 1
/* Debug Info TLV */
#define BTINTEL_PCIE_CONFIG_NAME_LEN 64
@@ -76,6 +77,7 @@ bool btintel_pcie_fatal_err_testmode_active(struct btintel_pcie_data *data);
/* Region Tlv */
#define BTINTEL_PCIE_REGION_ID_MAX 63
#define BTINTEL_PCIE_REGION_NAME_LEN 32
+#define BTINTEL_PCIE_REGION_LIST_SIZE 2
enum btintel_pcie_image_tlv_type {
BTINTEL_PCIE_IMAGE_TLV_TYPE_EXTERNAL = 0x1,
@@ -354,7 +356,42 @@ struct btintel_pcie_tlv_hcmd {
u8 cmd_data[];
} __packed;
-/* Parsed buffer allocation entry in the YoYo context */
+/*
+ * struct btintel_pcie_tlv_trigger - YoYo debug trigger TLV
+ * @hdr: Common TLV type and payload length
+ * @dbg_hdr: Debug TLV version and domain
+ * @time_point: Timepoint at which to evaluate this trigger
+ * @trigger_reason: Reason code for the trigger
+ * @trigger_policy_mask: Policy flags controlling trigger matching and overrides
+ * @dump_delay_usec: Delay in microseconds before dump collection
+ * @occurrences_limit: Maximum number of times this trigger may fire
+ * @stop_dump_limit: Limit of dump collections before stopping
+ * @ignore_consec_usec: Minimum elapsed time in microseconds between firings
+ * @reset_fw_mode: Firmware reset mode after trigger
+ * @multi_dut_trigger: Multi-DUT trigger flag
+ * @regions_list_mask: Bitmask of debug region IDs to collect
+ * @data: Optional variable-length timepoint-specific trigger data
+ *
+ * Describes a debug trigger in the packed firmware TLV. Multi-byte fields
+ * are stored in little-endian format.
+ */
+struct btintel_pcie_tlv_trigger {
+ struct btintel_pcie_tlv_hdr hdr;
+ struct btintel_pcie_dbg_hdr dbg_hdr;
+ __le32 time_point;
+ __le32 trigger_reason;
+ __le32 trigger_policy_mask;
+ __le32 dump_delay_usec;
+ __le32 occurrences_limit;
+ __le32 stop_dump_limit;
+ __le32 ignore_consec_usec;
+ __le32 reset_fw_mode;
+ __le32 multi_dut_trigger;
+ __le32 regions_list_mask[BTINTEL_PCIE_REGION_LIST_SIZE];
+ __le32 data[];
+} __packed;
+
+/* Parsed buffer allocation entry in yoyo ctx */
struct btintel_pcie_buf_alloc {
u32 alloc_id;
u32 buf_location;
@@ -397,6 +434,14 @@ struct btintel_pcie_yoyo_hcmd {
u8 *cmd_data;
};
+/* Parsed trigger entry */
+struct btintel_pcie_yoyo_trigger {
+ struct list_head list;
+ u32 time_point;
+ u32 trigger_reason;
+ u32 regions_mask[BTINTEL_PCIE_REGION_LIST_SIZE];
+};
+
/*
* struct btintel_pcie_yoyo_ctx - Runtime state for YoYo debug configuration
* @enabled: Whether the loaded YoYo configuration passed validation
@@ -437,4 +482,8 @@ int btintel_pcie_yoyo_load_and_parse(struct btintel_pcie_yoyo_ctx *ctx,
const struct btintel_pcie_buf_alloc *
btintel_pcie_yoyo_get_buf_alloc(struct btintel_pcie_yoyo_ctx *ctx, u32 alloc_id);
+const struct btintel_pcie_yoyo_trigger *
+btintel_pcie_yoyo_find_trigger(struct btintel_pcie_yoyo_ctx *ctx,
+ enum btintel_pcie_dbg_timepoint tp);
+
#endif /* __BTINTEL_PCIE_DEBUG_H__ */
--
2.53.0
next reply other threads:[~2026-12-02 11:31 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-02 11:31 Ajay KV [this message]
2026-12-02 11:31 ` [PATCH v2 2/3] Bluetooth: btintel_pcie: Collect dump regions from yoyo region TLVs Ajay KV
2026-12-02 11:31 ` [PATCH v2 3/3] Bluetooth: btintel_pcie: Dispatch yoyo triggers at timepoints Ajay KV
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261202113103.69237-1-ajay.k.v@intel.com \
--to=ajay.k.v@intel.com \
--cc=chandrashekar.devegowda@intel.com \
--cc=chethan.tumkur.narayan@intel.com \
--cc=kiran.k@intel.com \
--cc=lakshmipathi.k@intel.com \
--cc=linux-bluetooth@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=luiz.dentz@gmail.com \
--cc=marcel@holtmann.org \
--cc=stable@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox