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=1796205885; b=mObxePLEtc8djI3K0AkqDYom7x9LKfRrUeCIH9HfAIsuoEyse35EW+8BPj3by8RXGp6Q c2h6El4nPkybr7mFwmOAYvnWQORr1GzKA/yDn3EOr1dnGrRr7uu8dGcun2BaWyw0Dq2we J1y1Zh6okshkzZkYsbXWHi7R9CpA5uoFiE8/DdTC6ouuxuRBGx5BTeDZfeMAEfXgCfKWV d/0wUTej95ZB9E2wGNpY8SVdsMTdE3ISkxAFs75d0ExYTTlNHwwJWDaB3qN0AuEbxSnL+ Oz313B5QaxYM5mrFLabxo7TzZRKUzNZ15mCooLG09rXetaVJeJxTDxTeFg9H7LUpLLg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796205885; 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:MIME-Version:Content-Transfer-Encoding; bh=mJCds1Z6JFupUYH7XIhNSimGdGTQePsZSeTmwVl7YSY=; b=S5EwEYRYDt7TEklY7UACewWnPoViA5xhgToZBvpncJWEP2omJ3SYzhItZS8cHPrr9HI4 0nEaIL41crpBg4tY5Qk2h9QCXcO95K4aC9wlWaqWY0LZtIVHr2ghhDNhU0Vfys254eZA/ 7OBmz+PDjFHJ1vHg1eimCfC2X0eeVK7VGQuso/ITd6KBxDG+kaxnHxo5fNOnXDTd9KGUB CtJNa89hBK4Qklk1kVH/1FZ6AH2PYiKlr/BzV4BZlJgADXtob53ntOf8inb+ITGkwGD0s IsKKqothDu7H2t0Qa7XleT9iIo5EdfP/Qp05ehy69tCn815tZA8cr+J+Ip4CIeBq7VA== 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=FIe7l4h2; 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 E512B606A31A; Wed, 2 Dec 2026 10:04:43 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org E512B606A31A 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=FIe7l4h2 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1796205885; x=1827741885; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=mJCds1Z6JFupUYH7XIhNSimGdGTQePsZSeTmwVl7YSY=; b=FIe7l4h2gbWxY8/HQM82f8PdWtN3bx67NfmfCWTXX4Uxtsn2OOKYiTVD GxUnFkEC9L4RmbzJqVhaLKfL9yNoFp0cOm41vyhpFBsSEMXK4PxK/NgpL ENQrNoT67QhDqGILUzynYHYYxg099MyrTwA9T3KZ1OUBbIX9/wRm0uELD 82/dDQyNnrWxxf30SplQN/z1Vr68QvSuo8nxACJZkhhLmxU//8SG08ATj zKVC6m5xbE4Ikl9lfdRXXia5117hYD4uZNboEt9vQ4nkjm491eBsQpPc4 wgL+s7PWRocRFHyzLi9po+anK47gM4AwAIWic4IGw57a6eHuKGfGGeBlu Q==; X-CSE-ConnectionGUID: G9V1+scTTJa25z4cPnqjiQ== X-CSE-MsgGUID: BOo0pBOES6WKkU7lkReyiw== X-IronPort-AV: E=McAfee;i="6800,10657,11983"; a="5030598" X-IronPort-AV: E=Sophos;i="6.27,246,1787036400"; d="scan'208";a="5030598" 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:44 -0800 X-CSE-ConnectionGUID: Lqd+dq6lT1uE30ppWTFzYQ== X-CSE-MsgGUID: ejohxmmWQvanr1kXC09ceA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.27,246,1787036400"; d="scan'208";a="13297100" Received: from unknown (HELO WEBAPTLH032.iind.intel.com) ([10.66.250.231]) by orviesa005.jf.intel.com with ESMTP; 02 Dec 2026 02:04:40 -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 1/3] Bluetooth: btintel_pcie: Add yoyo configuration for trigger tlv Date: Wed, 2 Dec 2026 12:04:34 +0200 Message-ID: <20261202100436.56353-1-ajay.k.v@intel.com> X-Mailer: git-send-email 2.53.0 X-Mailing-List: linux-kernel@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 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 --- 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