From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8BD1F2E1F06 for ; Sun, 2 Aug 2026 06:32:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.168.131 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785652326; cv=none; b=LM33eP33i4bbzmH8ApjwiFFxXFGRpPGMb+ZyoWU6+Bv+kRKU6Y+qh204ueoFUL7FzxOcR1IvhRVfjufVynlYgLN7OmBwvdxjtkDGRgxPd7gJm0vB6V10iAlAPt6BJuCAqoTDNWGlnCTLxL/dRaGki0iwyJhVz2mP8hrrcIyxsPI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785652326; c=relaxed/simple; bh=lzIyHiA7wkm/Q1XRhS+4tVqfs6XOy4lON2is8fZD8fI=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=kaPjbMaczYZtWLUVVOS+nAAPDnTof8V4Z+7iYsepXdXhRicLekjXM4ABdrxHi5jF4xfSIIGfc3G2c8h3EyrQ+ZuYka62kgk6pe0nuswUMYLTmgzK6qq2ZNYVAgMitGr+7aTHitzKEkcrXJpU8OVbs7Xd2D2pbs9EJo6IzelUep4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oss.qualcomm.com; spf=pass smtp.mailfrom=oss.qualcomm.com; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b=IaFnRbxp; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b=YCmbNFhM; arc=none smtp.client-ip=205.220.168.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b="IaFnRbxp"; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="YCmbNFhM" Received: from pps.filterd (m0279862.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 6724amw6563149 for ; Sun, 2 Aug 2026 06:32:04 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=qcppdkim1; bh= rnfAF7jntq0imixhjb4atbRiGN55VN6m38GgbhFaKN4=; b=IaFnRbxpJiftSfe+ Hzc0aCn9ZsfSGYCxQoP8i9hPkmm/je/d0wvPnyGQLFWadEiah1mO/3FG+ZTv7gpP YMb6I+1jTSZNHYad2FOrWI+ITgcz+kfJJp7Iq8H/cEq41NZdD5Vna/aZXTW2E0iL G+zOcHPOISBAqmQcyIgkXOIGzC9z+/hpCi7TWanNyoO0EaRfhaNDwx1Y9tqJFS69 KDkSZPFnBz+hK730AtMGtNJ3DXzp5c7IsdaqC6lkgZfdSh3ImqW68LRo3e+Vanwx u5pfMXwkPOUEzu7snc6SCkj91QVzw/U8uUbHaYdSL/c0iPe0mzFQRAZcOq1hJ9zP qqj7yA== Received: from mail-pg1-f199.google.com (mail-pg1-f199.google.com [209.85.215.199]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4fs9jft7c5-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Sun, 02 Aug 2026 06:32:04 +0000 (GMT) Received: by mail-pg1-f199.google.com with SMTP id 41be03b00d2f7-ca8aee882c4so205747a12.3 for ; Sat, 01 Aug 2026 23:32:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1785652324; x=1786257124; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=rnfAF7jntq0imixhjb4atbRiGN55VN6m38GgbhFaKN4=; b=YCmbNFhMsJfJFOquFhNnlapC9S1/1bE2TdSxmum2KJ/Jnmu2Kh/1UeEOmA49UwXrgy pTFPe5HtEkE74ueIOXfnp544vyaPXMxteVj2douiniKanTG4CZMQaLs92KIS+Y5dIWN7 UXq9AN56iePMvYzqWG4JNvaRxw4LBcXzc8P8Bk1XesHEJKlqWzBzGebwM/6ZlZHpiY2S l+35jUA5MDTFqN5IRbj8zQc9RuqADBZ8GDahQ9n9amcqFGDJUUHnF18gbY9rElLvukVI rnrFCNQbT7YyB67iC8IgU2MJ+cefCyjr06nBgRSSzcy0hhTEA8emtr+fhlvYvSbqQ+N9 7LpQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1785652324; x=1786257124; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=rnfAF7jntq0imixhjb4atbRiGN55VN6m38GgbhFaKN4=; b=Ra2SGL6Fq8rXnbI429Q75GNJz1c15oQVXV7GOmsCqcKDQjc+hv8OrGlGZCMQLhzBzU RCfqpJNVbQMI6p/jfngTWlABrOljBs0efiGnIzmSyf6qucA9R/L2m/kfO0i0OK91r7cc jigmB1ST5c7mbEhEL4dG5/h7jyflinYGLfFR61NnPwvT7CpjaCj01y15//WDzE++4Egd CU9oEC4p8vDMBFgUM6bQIumv4Kh2HavHNBUZiYAhU1A8daqGnrvc4qcTeT4kDDB6TGul 9/1npG3CY0MFEsIKpLOpUnytNJ/qLhc6eJmUUTyN/OVr3ExCIGc2zV5ijs/F/EZ0l9Vh AWWg== X-Forwarded-Encrypted: i=1; AHgh+Ro2wFhmZWZuOoiJ2wyVauvCtObBGWfffWDT9Bp2C8yxhis6hzkVDpaDk1nLLdURKanoYob1sGFbRDb/eM8=@vger.kernel.org X-Gm-Message-State: AOJu0YyZD7LGWFTQ8xdCFlwiIXvIu21wuofg1Dc5GGCyElFiVzE+K7zV Xbg4+XbvPplMwPP7qr+GWusSlXZEHiLwRsBPsdLwxB4nU+zEJSI8iYZHetAyo2Rtz3eIxFGpvcD RR97dpgoahE4Z13qSYfvZYbtCcYgj7cnDAigOL7pcG1ie0Zl3BKLOmO0t1knj4RwamI8= X-Gm-Gg: AR+sD116peoxAlrbQnCDHcX+4YYelHDthewsxIAiplV99qPkCP73CDi5dv45ATN4czW RorWAFWjZ2265kLO4vG1o/iLTh3o9ZjKhagIREWInroKhzgnUsLZfNYNp182mevXh4iUvAZMsrX 6dBARhm0okAw048gFD8qP/fEloO5N6123rI5rMlav4bz7oBfdi4vxxzRrPhadMf5CgZs3TRD8eO jMIGLZFzgAGlpgucIRx8KmKX6OifQTAfQa2+j9i0xAYYCw5P9crBYNWvmoUKNSNm4b0ylpbXuVk FmW84ZnmUHuVfP1BeTSlqhCwlClrJgjDMHNj154ARmC+aB+QWFhvoqC0V5NvvD5TH699AFKkzbs z+e+kcdFHBmmoDqT3dSWyHtYWrGcDCtCaBUP7tKANeNdq/8Y= X-Received: by 2002:a17:90b:51c3:b0:38e:6a7c:abbc with SMTP id 98e67ed59e1d1-38fbc5482f1mr7357470a91.3.1785652323872; Sat, 01 Aug 2026 23:32:03 -0700 (PDT) X-Received: by 2002:a17:90b:51c3:b0:38e:6a7c:abbc with SMTP id 98e67ed59e1d1-38fbc5482f1mr7357442a91.3.1785652323462; Sat, 01 Aug 2026 23:32:03 -0700 (PDT) Received: from hu-zijuhu-lv.qualcomm.com (Global_NAT1.qualcomm.com. [129.46.96.20]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-3153dd9c93dsm24233304eec.8.2026.08.01.23.32.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 01 Aug 2026 23:32:02 -0700 (PDT) From: Zijun Hu Date: Sat, 01 Aug 2026 23:31:41 -0700 Subject: [PATCH v3 6/7] Bluetooth: hci_event: Introduce handle_ev_vendor() for HCI_EV_VENDOR Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20260801-generic_fix-v3-6-efdd8dcf3430@oss.qualcomm.com> References: <20260801-generic_fix-v3-0-efdd8dcf3430@oss.qualcomm.com> In-Reply-To: <20260801-generic_fix-v3-0-efdd8dcf3430@oss.qualcomm.com> To: Marcel Holtmann , Luiz Augusto von Dentz , Abhishek Pandit-Subedi , Manish Mandlik , Chethan Tumkur Narayan , Amitkumar Karwar , Neeraj Kale Cc: Zijun Hu , Luiz Augusto von Dentz , linux-bluetooth@vger.kernel.org, linux-kernel@vger.kernel.org, Zijun Hu X-Mailer: b4 0.15.2 X-Proofpoint-GUID: VNGfrOO15KVBIAaHwiDdjMdFqf1QcAqv X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwODAyMDA1MCBTYWx0ZWRfX4Hx4rTVLkfhy 8Esap+4uMWbCcPX0gt1c/h9t+4YjzZKAk9HE/jhJRIkOb0DigiVAFdMbr1HHfqoLXrQXVUPZMbn VfysNfFetMpzxWhOgU4FQGPMhNzv2MzTFxrZZhUwVZabCHvZjvsZE4QiUVVcrHlRbXCsWvxDJd4 EAS5jrvi/ejKmqMajyL+k+jhWwMFOKn2MiM7mMLIpgE3rXLA824Nvz0N6AtQfcbfjGGQF49iINL 91ixXDw17x13/LpIi/aNXJQaAm7UDeqIuX/LR8pusg9Ivxu7lyaB5s3Qjgf51C6ChfwkZQrnmNj JZX4ERnD4VoC8seZ5NRkIMn4eJjmnc8cZr2Q9xbU5FLtIGk2AyqwpTWiMXAsPY3TPjpz1wt6Ogb DsWj4Z+h5IhFsgyX7HyD9CdW0fdFvw4daV8GTm+XenXj0jQ65fhWcr7xihLALcA9fl0mEw7jekZ tKWqfMVZ0j71z5wJV0g== X-Authority-Analysis: v=2.4 cv=TYSmcxQh c=1 sm=1 tr=0 ts=6a6ee464 cx=c_pps a=Oh5Dbbf/trHjhBongsHeRQ==:117 a=ouPCqIW2jiPt+lZRy3xVPw==:17 a=IkcTkHD0fZMA:10 a=Sv0fKeRqtYgA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=_K5XuSEh1TEqbUxoQ0s3:22 a=VwQbUJbxAAAA:8 a=EUspDBNiAAAA:8 a=ApFb6xzRbVrLEhc_c74A:9 a=QEXdDO2ut3YA:10 a=_Vgx9l1VpLgwpw_dHYaR:22 X-Proofpoint-ORIG-GUID: VNGfrOO15KVBIAaHwiDdjMdFqf1QcAqv X-Proofpoint-Spam-Info: AW1haW4tMjYwODAyMDA1MCBTYWx0ZWRfX9w/Qqj9IF40J v5nR8etJ9Lgouwj4vG8szmPvsydLHz3G+fxexwEx8tMrwRn4FAWrGv12aWDA/2nghVgrv2F1m/4 wWEq21euP+nV8uqrIGBRfoSU4l1QI9g= X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.134,FMLib:17.12.100.49 definitions=2026-08-02_02,2026-07-30_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 adultscore=0 spamscore=0 lowpriorityscore=0 malwarescore=0 phishscore=0 suspectscore=0 priorityscore=1501 bulkscore=0 clxscore=1015 impostorscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2606150000 definitions=main-2608020050 Introduce the hook to solve issues below: msft_vendor_evt(), the current handler for all VSEs, is unsuitable since: - many VSEs are not MSFT ones; - it always corrupts the non-MSFT VSEs by calling skb_pull_data() once the MSFT extension is enabled. Several issues are caused by many transport drivers pre-processing VSEs in their RX path, often an IRQ-disabled atomic context. Take the two typical cases below as examples: Case 1: // no btmon log, no way to reach userspace Step 1: handle and free @original_skb directly Case 2: // hurts performance and consumes GFP_ATOMIC memory Step 1: cloned_skb = skb_clone(original_skb, GFP_ATOMIC); // the VSE is handled here Step 2: handle and free @cloned_skb Step 3: hci_recv_frame(hdev, original_skb); // already handled, but re-enters the stack's event-handling path Step 4: hci_event_packet(hdev, original_skb); Fix by introducing the hook with usage: 1) the transport driver registers the hook for VSEs of interest; 2) the stack calls it in process context, handling the VSE like any other event: - if interested, handle the VSE - no need to free it - and return true; - otherwise return false. Signed-off-by: Zijun Hu --- Previous version: https://lore.kernel.org/all/20260722-support_vendor_hci-v2-3-132b506460a4@oss.qualcomm.com Changes since previous version: 1) Don't handle ACL frames with a vendor-reserved handle for special usage. 2) Rename recv_bt_vendor() to handle_ev_vendor(), since the event is only in the RX direction. --- include/net/bluetooth/hci_core.h | 2 ++ net/bluetooth/hci_event.c | 10 +++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h index b7e71733f360..87db877f8c5c 100644 --- a/include/net/bluetooth/hci_core.h +++ b/include/net/bluetooth/hci_core.h @@ -641,16 +641,18 @@ struct hci_dev { #endif int (*open)(struct hci_dev *hdev); int (*close)(struct hci_dev *hdev); int (*flush)(struct hci_dev *hdev); int (*setup)(struct hci_dev *hdev); int (*shutdown)(struct hci_dev *hdev); int (*send)(struct hci_dev *hdev, struct sk_buff *skb); + /* Handle HCI_EV_VENDOR; return true if handled, false otherwise */ + bool (*handle_ev_vendor)(struct hci_dev *hdev, struct sk_buff *skb); void (*notify)(struct hci_dev *hdev, unsigned int evt); void (*hw_error)(struct hci_dev *hdev, u8 code); int (*post_init)(struct hci_dev *hdev); int (*set_diag)(struct hci_dev *hdev, bool enable); int (*set_bdaddr)(struct hci_dev *hdev, const bdaddr_t *bdaddr); void (*reset)(struct hci_dev *hdev); bool (*wakeup)(struct hci_dev *hdev); int (*set_quality_report)(struct hci_dev *hdev, bool enable); diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c index 9c8bf6708356..8452d372524f 100644 --- a/net/bluetooth/hci_event.c +++ b/net/bluetooth/hci_event.c @@ -7597,16 +7597,24 @@ static void hci_le_meta_evt(struct hci_dev *hdev, void *data, ev->subevent, skb->len, subev->max_len); data = hci_le_ev_skb_pull(hdev, skb, ev->subevent, subev->min_len); if (!data) return; subev->func(hdev, data, skb); } +static void hci_vendor_evt(struct hci_dev *hdev, void *data, struct sk_buff *skb) +{ + if (hdev->handle_ev_vendor && hdev->handle_ev_vendor(hdev, skb)) + return; + + msft_vendor_evt(hdev, data, skb); +} + static bool hci_get_cmd_complete(struct hci_dev *hdev, u16 opcode, u8 event, struct sk_buff *skb) { struct hci_ev_cmd_complete *ev; struct hci_event_hdr *hdr; if (!skb) return false; @@ -7824,17 +7832,17 @@ static const struct hci_ev { sizeof(struct hci_ev_keypress_notify)), /* [0x3d = HCI_EV_REMOTE_HOST_FEATURES] */ HCI_EV(HCI_EV_REMOTE_HOST_FEATURES, hci_remote_host_features_evt, sizeof(struct hci_ev_remote_host_features)), /* [0x3e = HCI_EV_LE_META] */ HCI_EV_REQ_VL(HCI_EV_LE_META, hci_le_meta_evt, sizeof(struct hci_ev_le_meta), HCI_MAX_EVENT_SIZE), /* [0xff = HCI_EV_VENDOR] */ - HCI_EV_VL(HCI_EV_VENDOR, msft_vendor_evt, 0, HCI_MAX_EVENT_SIZE), + HCI_EV_VL(HCI_EV_VENDOR, hci_vendor_evt, 0, HCI_MAX_EVENT_SIZE), }; static void hci_event_func(struct hci_dev *hdev, u8 event, struct sk_buff *skb, u16 *opcode, u8 *status, hci_req_complete_t *req_complete, hci_req_complete_skb_t *req_complete_skb) { const struct hci_ev *ev = &hci_ev_table[event]; -- 2.34.1