From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=192.198.163.10 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796211071; b=IyWzJVkNQ4NluVzyYRcc+OtnsNAyWMiAfx1oWMxpkfksfK2rdJnAeISYJAy1XnkTVWfW uVh8PWks5B20UDQW71npZnKv8BAfnHAs06lsMPQMFCBApreMNkkZHZ/URlY3F+Ej6LhMS bI+DSNjh7AiWCbsq4/mV20B2Gcqrnk/pUS8WdXpCIhpulkKNUivndUnNKjqgagl0IrKyJ sXRinluAyKqRs2P5aoihGMvPmnmrceKoS6nRQWCO5hbn1DebWryq/ykmH5ZrP8APM8v6a tl2Tw+Y++Bb2vqBrsdDlGcQzgW6oxbe+4lmHu6qRJlcK0Hvc2Z8v1ZhOOLbn+bzPd6Q== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796211071; 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=kM60Pgor5JsdQATzc7C2zVFWervKidCvVE0sis90QG8cqSwsaZuEBaHCyixbYHyhFYhB zhlzTDa1t31WJx1Dm6RTcmObOi0oCaXQI09P8nvMTnv1IF9kMmRc7kK9LXrPQrwiAYhUa Fopz2idogFq0EPBo7fovBeIo6mpf7w4W4qRkrZQ0j9sWzwHY7GBUH9gLK5at/FyR7F1Wi PSEQbj4uJZFQXc9biOTzs/APcIlh7z+9f1uv/FqI2mcIbiKv9PH72/rajm9tjDzwj/xk+ E4qcHtfl+thDciOvuXY13H61l9ykJ/5nUY1UGlph3i55bRoK983XEQhIeyfRzWsMvZQ== 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=kwmEwW9S; arc=none smtp.remote-ip=192.198.163.10 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.10]) (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 72E55606A31A; Wed, 2 Dec 2026 11:31:10 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 72E55606A31A 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=kwmEwW9S DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1796211070; x=1827747070; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=mJCds1Z6JFupUYH7XIhNSimGdGTQePsZSeTmwVl7YSY=; b=kwmEwW9SIm+ZxBQjGz37rndwOPO9PlQUK4jRujWjAzKh2+e0MRe/vP3u e5fA6b7ftc1Av6iVz3p1SsFlFewK/KcQ0dTOfQ+OGpOax9Mt9n1AQRcD8 W1aCyDfEdzyXy4BuOMNmAoyJUgJMjbNvPufAHOKK2c803y/uf01VE0OKh 21EMmRXaZX2rk0ZwKNOqFyHxQq+LYxo201K6pQOaYugC0BoXe+RE4onD3 Eg3NhMGM1iJmCBN1QeyvyxUla0qRp0VPunfn/SCeMlgkod5EoAIaDgCxb 5GP1GUmi/JaR0wm7dx+lV+yyYL9u2Pb+Anu3COGLcYLdiqu48N/mPtNb+ A==; X-CSE-ConnectionGUID: fWo370fzQi6mG7x0m4bWWg== X-CSE-MsgGUID: sI1XTCYnR7uXBuKO1GNbrQ== X-IronPort-AV: E=McAfee;i="6800,10657,11983"; a="5015356" X-IronPort-AV: E=Sophos;i="6.27,246,1787036400"; d="scan'208";a="5015356" Received: from orviesa003.jf.intel.com ([10.64.159.143]) by fmvoesa104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Dec 2026 03:31:09 -0800 X-CSE-ConnectionGUID: mlYM9mgBR060HTYMMLywew== X-CSE-MsgGUID: MWgUlyatS9iQeGJaNArT2A== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.27,246,1787036400"; d="scan'208";a="13359912" Received: from unknown (HELO WEBAPTLH032.iind.intel.com) ([10.66.250.231]) by orviesa003.jf.intel.com with ESMTP; 02 Dec 2026 03:31:07 -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 v2 1/3] Bluetooth: btintel_pcie: Add yoyo configuration for trigger tlv Date: Wed, 2 Dec 2026 13:31:01 +0200 Message-ID: <20261202113103.69237-1-ajay.k.v@intel.com> X-Mailer: git-send-email 2.53.0 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 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