From patchwork Thu Apr 18 03:11:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: quic_zijuhu X-Patchwork-Id: 13634086 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.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 2E3134F1EB for ; Thu, 18 Apr 2024 03:12:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.180.131 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713409928; cv=none; b=TGMrATODDRMbGo9T2zFhJciGYUqeNdpFtWYV9SuwRBJr0wc3kPIGz5tp8a1NEd3ZIQwsE8iRkowz4w7o7IjWyX83Ay/VMCIDcZuhAMSPsc0Rcegpd42H1qlEFrKFQurh2y9fZY+3XaxEDvMBNyfq7KJH1hJQ0jpZ9bqNQ796bgM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713409928; c=relaxed/simple; bh=2/0X7FRfyjGBCSToTSuA//BVfSa1LcfsCK7DeLXmxdE=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=qTRNLyFrQCoiyI9X/m4fZMZdP3HGHc5Rg+UawNyLVtvqraL1yJIZC9SxU80JnfQmm3heyRdXGwxmvgy2QS44FyctDwZ1O+hlb1eE/bzs8GvZ4dPXwGg6+HFRxpQs8xdaDCTs9KoB2nYiqVsoKv5e5rnKJWQViHyKUDbPyO0VpF8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com; spf=pass smtp.mailfrom=quicinc.com; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b=MA1pIkfu; arc=none smtp.client-ip=205.220.180.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=quicinc.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b="MA1pIkfu" Received: from pps.filterd (m0279871.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.24/8.17.1.24) with ESMTP id 43I1AEpX024044; Thu, 18 Apr 2024 03:12:03 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h= from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-type; s=qcppdkim1; bh=vNjJi2eQTlb9I4zDZ4Gx mioq7hosmZFnhGoavP4qz+Q=; b=MA1pIkfuUEDcGat+9kd8uyyRsnwobbmqMLr0 7FvuIkKHTZG2Ha1xZQDVtiE3IqJ1Qy7IMCGdp1vVA5P+cFOLtIQJV7yzT9o5AZSv QcApF/Wybmk7NdsjB3EbUDsZns3VPHsBFF1s4mId7tRrlUXGs0qQ/7Zn3zuREAB2 91QTFKuE0K3Kpzv1XlCMASjQ7kTU6Um8/X+QtmVV4YgSC1E2h5hYM7b1mpALpkme iTp72E5GJsuzsHp2yfTnjLdi3oNR1xg4hqLyMu6XE4X3FSm7i6LmfnQP27/kERis pXQz6XG2IzZ8eQORqcKLQ0H2+7PzxCNCa0QKz+17qDCGh2XPdQ== Received: from nasanppmta05.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3xjrfxggv0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 18 Apr 2024 03:12:03 +0000 (GMT) Received: from nasanex01a.na.qualcomm.com (nasanex01a.na.qualcomm.com [10.52.223.231]) by NASANPPMTA05.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 43I3C2qK020332 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 18 Apr 2024 03:12:02 GMT Received: from zijuhu-gv.qualcomm.com (10.80.80.8) by nasanex01a.na.qualcomm.com (10.52.223.231) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.9; Wed, 17 Apr 2024 20:12:00 -0700 From: Zijun Hu To: , , CC: , Subject: [PATCH v3 1/4] Bluetooth: qca: Fix crash caused by tool btattach for QCA_ROME Date: Thu, 18 Apr 2024 11:11:50 +0800 Message-ID: <1713409913-13042-2-git-send-email-quic_zijuhu@quicinc.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1713409913-13042-1-git-send-email-quic_zijuhu@quicinc.com> References: <1713358336-29619-1-git-send-email-quic_zijuhu@quicinc.com> <1713409913-13042-1-git-send-email-quic_zijuhu@quicinc.com> Precedence: bulk X-Mailing-List: linux-bluetooth@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: nasanex01b.na.qualcomm.com (10.46.141.250) To nasanex01a.na.qualcomm.com (10.52.223.231) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-ORIG-GUID: dCCYKupiipKtfrKk5OxrBXn4qklP7D5- X-Proofpoint-GUID: dCCYKupiipKtfrKk5OxrBXn4qklP7D5- X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-04-18_02,2024-04-17_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 priorityscore=1501 spamscore=0 mlxscore=0 phishscore=0 suspectscore=0 adultscore=0 mlxlogscore=999 clxscore=1015 malwarescore=0 impostorscore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2404010003 definitions=main-2404180021 A kernel crash will happen when use tool btattach for a BT controller with soc type QCA_ROME, and it is caused by dereferencing nullptr hu->serdev, fixed by null check before access. sudo btattach -B /dev/ttyUSB0 -P qca Bluetooth: hci1: QCA setup on UART is completed BUG: kernel NULL pointer dereference, address: 00000000000002f0 ...... Workqueue: hci1 hci_power_on [bluetooth] RIP: 0010:qca_setup+0x7c1/0xe30 [hci_uart] ...... Call Trace: ? show_regs+0x72/0x90 ? __die+0x25/0x80 ? page_fault_oops+0x154/0x4c0 ? srso_alias_return_thunk+0x5/0xfbef5 ? kmem_cache_alloc+0x16b/0x310 ? do_user_addr_fault+0x330/0x6e0 ? srso_alias_return_thunk+0x5/0xfbef5 ? exc_page_fault+0x84/0x1b0 ? asm_exc_page_fault+0x27/0x30 ? qca_setup+0x7c1/0xe30 [hci_uart] hci_uart_setup+0x5c/0x1a0 [hci_uart] hci_dev_open_sync+0xee/0xca0 [bluetooth] hci_dev_do_open+0x2a/0x70 [bluetooth] hci_power_on+0x46/0x210 [bluetooth] process_one_work+0x17b/0x360 worker_thread+0x307/0x430 ? __pfx_worker_thread+0x10/0x10 kthread+0xf7/0x130 ? __pfx_kthread+0x10/0x10 ret_from_fork+0x46/0x70 ? __pfx_kthread+0x10/0x10 ret_from_fork_asm+0x1b/0x30 Fixes: 03b0093f7b31 ("Bluetooth: hci_qca: get wakeup status from serdev device handle") Signed-off-by: Zijun Hu Tested-by: Zijun Hu --- drivers/bluetooth/hci_qca.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/bluetooth/hci_qca.c b/drivers/bluetooth/hci_qca.c index 92fa20f5ac7d..fdaf83d817af 100644 --- a/drivers/bluetooth/hci_qca.c +++ b/drivers/bluetooth/hci_qca.c @@ -1955,7 +1955,7 @@ static int qca_setup(struct hci_uart *hu) qca_debugfs_init(hdev); hu->hdev->hw_error = qca_hw_error; hu->hdev->cmd_timeout = qca_cmd_timeout; - if (device_can_wakeup(hu->serdev->ctrl->dev.parent)) + if (hu->serdev && device_can_wakeup(hu->serdev->ctrl->dev.parent)) hu->hdev->wakeup = qca_wakeup; } else if (ret == -ENOENT) { /* No patch/nvm-config found, run with original fw/config */ From patchwork Thu Apr 18 03:11:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: quic_zijuhu X-Patchwork-Id: 13634087 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.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 9F8384F1E4 for ; Thu, 18 Apr 2024 03:12:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.180.131 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713409932; cv=none; b=htlO2oKiWY6HWRfwhFvBDZiuPwwIwzXUPp+PjYJfcUAklWAAtO/3Fn3boRvhm2Xwh4rssbf56mawby1juAxNIGPCeaJZXZ6o26gkGWW2esxBSMZC/2veUPIpYEzvpcrgSQaB/X4+nhmissMzS63WJJkOPMngTJIWUvBYO5TwPVs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713409932; c=relaxed/simple; bh=a0Dws8bCHWQDjut/dq6Un5iD5BkUvh71mEh3bVz34dE=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=jOqIuT5Jg/TyaM2KXidXdoQqyGMbUyQe8snPG2NwVVwvnMzdYF8/UtQoO21zBhLdL7BRZzHgfkNnIe5XG2TgXu+E5rKW/hDJir4MpR3LYAguiMkAY6cvcIK+1I5ByAam9WxGWIgzcqw3wYLdeQXF8K6TYOGoRwAOFpVi046Bw84= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com; spf=pass smtp.mailfrom=quicinc.com; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b=PhbC5r0c; arc=none smtp.client-ip=205.220.180.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=quicinc.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b="PhbC5r0c" Received: from pps.filterd (m0279868.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.24/8.17.1.24) with ESMTP id 43I1dwC0031435; Thu, 18 Apr 2024 03:12:06 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h= from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-type; s=qcppdkim1; bh=xGf06k19GpmCskoVfaxh sQXJwVrhXkDkROvHSn0eFw4=; b=PhbC5r0ccUQ35vhEFsEMGTjzT+UdPAXi0KSa yAmSzzi3JOuZe/A2CZQqkKlqWobMBuOqAyQQYueYmlSfq5qzIrWFzaJSfh3T8duO 6tFTwGxRDG4Ux3CYunc1VlEBQ30ICqoDUe/zCH4UVV61kznEnkQkI3vURGqeKpbM XBjzs5iR04zJNwDgabTw/psIePWfSJn1T4pNfXwd425MOM1oAZrh2izNgHQ0f0zz dQaPiVVycTmnQUlgeE/L+LScEkYuuEnQcGI+IG/2VHHvs7vGrujfFOcGgPC6m6yo Ey+8g0TpHAVMIHlhs91uJRn6VX2H54PDTnGATFa7KwkziyrJpw== Received: from nasanppmta01.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3xjqcurn2m-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 18 Apr 2024 03:12:06 +0000 (GMT) Received: from nasanex01a.na.qualcomm.com (nasanex01a.na.qualcomm.com [10.52.223.231]) by NASANPPMTA01.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 43I3C5MA003846 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 18 Apr 2024 03:12:05 GMT Received: from zijuhu-gv.qualcomm.com (10.80.80.8) by nasanex01a.na.qualcomm.com (10.52.223.231) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.9; Wed, 17 Apr 2024 20:12:03 -0700 From: Zijun Hu To: , , CC: , Subject: [PATCH v3 2/4] Bluetooth: qca: Fix nullptr dereference for non-serdev devices Date: Thu, 18 Apr 2024 11:11:51 +0800 Message-ID: <1713409913-13042-3-git-send-email-quic_zijuhu@quicinc.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1713409913-13042-1-git-send-email-quic_zijuhu@quicinc.com> References: <1713358336-29619-1-git-send-email-quic_zijuhu@quicinc.com> <1713409913-13042-1-git-send-email-quic_zijuhu@quicinc.com> Precedence: bulk X-Mailing-List: linux-bluetooth@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: nasanex01b.na.qualcomm.com (10.46.141.250) To nasanex01a.na.qualcomm.com (10.52.223.231) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-GUID: mor-LxtjF-NPuHxkRs3fmmbmaWY8Z-IK X-Proofpoint-ORIG-GUID: mor-LxtjF-NPuHxkRs3fmmbmaWY8Z-IK X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-04-18_02,2024-04-17_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxlogscore=999 adultscore=0 lowpriorityscore=0 impostorscore=0 suspectscore=0 spamscore=0 priorityscore=1501 phishscore=0 mlxscore=0 bulkscore=0 clxscore=1015 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2404010003 definitions=main-2404180021 hu->serdev is nullptr and will cause nullptr dereference if qca_setup() is called by non-serdev device, fixed by nullptr checking before access. Signed-off-by: Zijun Hu --- drivers/bluetooth/hci_qca.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/drivers/bluetooth/hci_qca.c b/drivers/bluetooth/hci_qca.c index fdaf83d817af..c04b97332bca 100644 --- a/drivers/bluetooth/hci_qca.c +++ b/drivers/bluetooth/hci_qca.c @@ -1905,10 +1905,11 @@ static int qca_setup(struct hci_uart *hu) case QCA_WCN6750: case QCA_WCN6855: case QCA_WCN7850: - qcadev = serdev_device_get_drvdata(hu->serdev); - if (qcadev->bdaddr_property_broken) - set_bit(HCI_QUIRK_BDADDR_PROPERTY_BROKEN, &hdev->quirks); - + if (hu->serdev) { + qcadev = serdev_device_get_drvdata(hu->serdev); + if (qcadev->bdaddr_property_broken) + set_bit(HCI_QUIRK_BDADDR_PROPERTY_BROKEN, &hdev->quirks); + } hci_set_aosp_capable(hdev); ret = qca_read_soc_version(hdev, &ver, soc_type); From patchwork Thu Apr 18 03:11:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: quic_zijuhu X-Patchwork-Id: 13634088 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.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 B90544F1E4 for ; Thu, 18 Apr 2024 03:12:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.180.131 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713409935; cv=none; b=JaphFLziWa26fbjo+W1iG/LMU4RnLHVLExL569VMLNcOnXMTBDfuVgl+0w2mT7XElc0qtk0xENXodjZKDUYkeUeh7sntbUQFv7jGuoXVyLU4tS5g91dVQsGoy3LJy2Zo4ZCDJmrO1zA9UGn8Obg2ai+/0Vxs+BML+BuYgnsaLLs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713409935; c=relaxed/simple; bh=zjjNUY5zEgxlr+XaqfhTEQ/BTaSPRRcX+Dpu77cqKKQ=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=YL0UNq+5gFSJ+aXM9qWUjfACDQ+XZtBNdwpvN5cPi3mIWlbbfexrypYSQNJkw2PVxKhDkrPepLK50ra285e4zBztQ+VA36VyC9ijoS3M6Gpt/h3R4RZjXZ6XQaMRPJtDUSV/JXyYfrYsBdMVd5Jx33QmQQP+7NLsWdy9+z4/v1Q= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com; spf=pass smtp.mailfrom=quicinc.com; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b=ZYksuvRO; arc=none smtp.client-ip=205.220.180.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=quicinc.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b="ZYksuvRO" Received: from pps.filterd (m0279870.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.24/8.17.1.24) with ESMTP id 43I1aamZ028691; Thu, 18 Apr 2024 03:12:10 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h= from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-type; s=qcppdkim1; bh=RFq5ecCEP3q85c1BN2iF zK8JqwCVOInWfClSJc0Wp54=; b=ZYksuvRO7Wa3LY0MR+XIXy8n9HRtf5pGebVS +h0KnYflThpNT28wJDdKVs8nbz73Kpt8VEjMcrwVvDfoinWos8FnRh9GWpqyZJyG K5jnD5y2+Fdl9qSyE5owucMHtZanmqjr8vVWeIDwnu9XUgV+u74Fh9SE5U+OZRF9 0XJNhoPTj/h6q3VnRcsn3A5P56qDUacppAelxOHeFy0e5OoYFk5pqk6PBs6Gm1b/ cgvU+vehwQ9OEHeJB2KyLi8KDGYkxe798gL1zeqNdKtsUtZJjp59Q+EJleQDYnJE Uzf5XIS1qX3nvLoe4KSG46GX4b4417CWy8EELMumyiNP9DAymg== Received: from nasanppmta02.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3xjrdbghpy-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 18 Apr 2024 03:12:09 +0000 (GMT) Received: from nasanex01a.na.qualcomm.com (nasanex01a.na.qualcomm.com [10.52.223.231]) by NASANPPMTA02.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 43I3C8Pc026643 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 18 Apr 2024 03:12:08 GMT Received: from zijuhu-gv.qualcomm.com (10.80.80.8) by nasanex01a.na.qualcomm.com (10.52.223.231) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.9; Wed, 17 Apr 2024 20:12:06 -0700 From: Zijun Hu To: , , CC: , Subject: [PATCH v3 3/4] Bluetooth: hci_ldisc: Add a ioctl HCIUARTSETPROTODATA Date: Thu, 18 Apr 2024 11:11:52 +0800 Message-ID: <1713409913-13042-4-git-send-email-quic_zijuhu@quicinc.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1713409913-13042-1-git-send-email-quic_zijuhu@quicinc.com> References: <1713358336-29619-1-git-send-email-quic_zijuhu@quicinc.com> <1713409913-13042-1-git-send-email-quic_zijuhu@quicinc.com> Precedence: bulk X-Mailing-List: linux-bluetooth@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: nasanex01b.na.qualcomm.com (10.46.141.250) To nasanex01a.na.qualcomm.com (10.52.223.231) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-GUID: aSpYFXjr-ibA2VobBJqpYyUVK8ya6Nwr X-Proofpoint-ORIG-GUID: aSpYFXjr-ibA2VobBJqpYyUVK8ya6Nwr X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-04-18_02,2024-04-17_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 impostorscore=0 bulkscore=0 lowpriorityscore=0 clxscore=1015 adultscore=0 malwarescore=0 spamscore=0 priorityscore=1501 suspectscore=0 mlxlogscore=999 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2404010003 definitions=main-2404180021 HCIUARTSETPROTODATA is introduced to specify protocol specific settings prior to HCIUARTSETPROTO, for protocal QCA, it is used by tool btattch to specify soc type. Signed-off-by: Zijun Hu --- drivers/bluetooth/hci_ldisc.c | 10 ++++++++++ drivers/bluetooth/hci_uart.h | 3 +++ 2 files changed, 13 insertions(+) diff --git a/drivers/bluetooth/hci_ldisc.c b/drivers/bluetooth/hci_ldisc.c index a26367e9fb19..4be09c61bae5 100644 --- a/drivers/bluetooth/hci_ldisc.c +++ b/drivers/bluetooth/hci_ldisc.c @@ -506,6 +506,7 @@ static int hci_uart_tty_open(struct tty_struct *tty) /* disable alignment support by default */ hu->alignment = 1; hu->padding = 0; + hu->proto_data = 0; INIT_WORK(&hu->init_ready, hci_uart_init_work); INIT_WORK(&hu->write_work, hci_uart_write_work); @@ -795,6 +796,15 @@ static int hci_uart_tty_ioctl(struct tty_struct *tty, unsigned int cmd, err = hu->hdev_flags; break; + case HCIUARTSETPROTODATA: + if (test_bit(HCI_UART_PROTO_SET, &hu->flags)) { + err = -EBUSY; + } else { + hu->proto_data = arg; + BT_DBG("HCIUARTSETPROTODATA %lu okay.", arg); + } + break; + default: err = n_tty_ioctl_helper(tty, cmd, arg); break; diff --git a/drivers/bluetooth/hci_uart.h b/drivers/bluetooth/hci_uart.h index 68c8c7e95d64..fc35e9bd4398 100644 --- a/drivers/bluetooth/hci_uart.h +++ b/drivers/bluetooth/hci_uart.h @@ -18,6 +18,8 @@ #define HCIUARTGETDEVICE _IOR('U', 202, int) #define HCIUARTSETFLAGS _IOW('U', 203, int) #define HCIUARTGETFLAGS _IOR('U', 204, int) +/* Used prior to HCIUARTSETPROTO */ +#define HCIUARTSETPROTODATA _IOW('U', 205, unsigned long) /* UART protocols */ #define HCI_UART_MAX_PROTO 12 @@ -71,6 +73,7 @@ struct hci_uart { struct work_struct init_ready; struct work_struct write_work; + unsigned long proto_data; const struct hci_uart_proto *proto; struct percpu_rw_semaphore proto_lock; /* Stop work for proto close */ void *priv; From patchwork Thu Apr 18 03:11:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: quic_zijuhu X-Patchwork-Id: 13634089 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.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 2191D52F7D for ; Thu, 18 Apr 2024 03:12:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.180.131 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713409937; cv=none; b=BOt0cEysLg++xOs7W8bKLyOxljMdIzm/7fmJZuAvzsoZVC0aRT8iTfw0c3+FtII40rOAzGUcbcVFyNMv6FY5lQhtTG+9qwU1z8CkFOc98kOp4uHn76DL5G8shUkebdrfNOPPov3zIytzxdQ0hnINGcGeXLVlw7BGtAl/4EJv430= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713409937; c=relaxed/simple; bh=jvdviXRTEYKOwSh9B+7MQhVwK2YaJeko9Uxqkbfnxng=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=aONioHyvor0b7EERa0zViFqOYisgi7SRM7k3SJL/9mk1tIOtZiYQUPMvHvVj1p0z3KEzavQR8lsJrdn12T9s+F5dIoKhR06M71Rpg4Jd/JMCynhPMF/pvNeEk1PlIImn6M8QuAdFPhjfn6P7bqBLKVh1TjJYfW008vu3EbcWZNg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com; spf=pass smtp.mailfrom=quicinc.com; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b=D3Z0xJzk; arc=none smtp.client-ip=205.220.180.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=quicinc.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b="D3Z0xJzk" Received: from pps.filterd (m0279868.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.24/8.17.1.24) with ESMTP id 43HMbtGO013268; Thu, 18 Apr 2024 03:12:12 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h= from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-type; s=qcppdkim1; bh=IeGdeT0OgTSlhFkGrdHH x2BXOgKvrIZZ2TLuZbaW/tw=; b=D3Z0xJzkbB4sHXiagtasuOiOie7PlmCuoGsx SInNDkNtghOMVLqYTCqZPeNXj+3duuWveTnsDfdrTCGapSQoq1ILiwQgopP6So7c f2970k1zTjbCfHp317tsKp6yFSDcoacysD6U16Y9RMR8WCh8Qpk/6DntU+SHnADO k2rNJqzrbY9kox356mRyRc9VRt9+UMv0jnyNeDZTSwme2+64G8lcIK9ntu1aqQFD 6XoW0AmEoMG8jjaC6U3IsvKIEzvefBxpLOwBsW9NegY+ixg5dJdCjdy+qKC8n0Qv 035aeK/ce6T8u0F6Pvu0nD6aza8YrfdLt0GIobgb2gYRRblU9g== Received: from nasanppmta02.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3xjqcurn2t-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 18 Apr 2024 03:12:12 +0000 (GMT) Received: from nasanex01a.na.qualcomm.com (nasanex01a.na.qualcomm.com [10.52.223.231]) by NASANPPMTA02.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 43I3CBda026665 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 18 Apr 2024 03:12:11 GMT Received: from zijuhu-gv.qualcomm.com (10.80.80.8) by nasanex01a.na.qualcomm.com (10.52.223.231) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.9; Wed, 17 Apr 2024 20:12:09 -0700 From: Zijun Hu To: , , CC: , Subject: [PATCH v3 4/4] Bluetooth: qca: Support more soc types for non-serdev devices Date: Thu, 18 Apr 2024 11:11:53 +0800 Message-ID: <1713409913-13042-5-git-send-email-quic_zijuhu@quicinc.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1713409913-13042-1-git-send-email-quic_zijuhu@quicinc.com> References: <1713358336-29619-1-git-send-email-quic_zijuhu@quicinc.com> <1713409913-13042-1-git-send-email-quic_zijuhu@quicinc.com> Precedence: bulk X-Mailing-List: linux-bluetooth@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: nasanex01b.na.qualcomm.com (10.46.141.250) To nasanex01a.na.qualcomm.com (10.52.223.231) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-GUID: B4_VAFVQuMJMQBWRy9jnm5XvT7nhIN5Y X-Proofpoint-ORIG-GUID: B4_VAFVQuMJMQBWRy9jnm5XvT7nhIN5Y X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-04-18_02,2024-04-17_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxlogscore=999 adultscore=0 lowpriorityscore=0 impostorscore=0 suspectscore=0 spamscore=0 priorityscore=1501 phishscore=0 mlxscore=0 bulkscore=0 clxscore=1015 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2404010003 definitions=main-2404180021 For non-serdev devices which are derived from tool btattach, only default soc type QCA_ROME is supported currently since there are no way to get soc type from DT or ACPI, this change supports more soc types by using user specified soc type for non-serdev devices. Signed-off-by: Zijun Hu --- drivers/bluetooth/btqca.h | 1 + drivers/bluetooth/hci_qca.c | 8 +++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/drivers/bluetooth/btqca.h b/drivers/bluetooth/btqca.h index dc31984f71dc..a148d4c4e1bd 100644 --- a/drivers/bluetooth/btqca.h +++ b/drivers/bluetooth/btqca.h @@ -153,6 +153,7 @@ enum qca_btsoc_type { QCA_WCN6750, QCA_WCN6855, QCA_WCN7850, + QCA_MAX, }; #if IS_ENABLED(CONFIG_BT_QCA) diff --git a/drivers/bluetooth/hci_qca.c b/drivers/bluetooth/hci_qca.c index c04b97332bca..7c3577a4887c 100644 --- a/drivers/bluetooth/hci_qca.c +++ b/drivers/bluetooth/hci_qca.c @@ -238,12 +238,17 @@ static void qca_dmp_hdr(struct hci_dev *hdev, struct sk_buff *skb); static enum qca_btsoc_type qca_soc_type(struct hci_uart *hu) { + /* For Non-serdev device, hu->proto_data records soc type + * set by ioctl HCIUARTSETPROTODATA. + */ + int proto_data = (int)hu->proto_data; enum qca_btsoc_type soc_type; if (hu->serdev) { struct qca_serdev *qsd = serdev_device_get_drvdata(hu->serdev); - soc_type = qsd->btsoc_type; + } else if ((proto_data > 0) && (proto_data < QCA_MAX)) { + soc_type = (enum qca_btsoc_type)proto_data; } else { soc_type = QCA_ROME; } @@ -2281,6 +2286,7 @@ static int qca_serdev_probe(struct serdev_device *serdev) return -ENOMEM; qcadev->serdev_hu.serdev = serdev; + qcadev->serdev_hu.proto_data = 0; data = device_get_match_data(&serdev->dev); serdev_device_set_drvdata(serdev, qcadev); device_property_read_string(&serdev->dev, "firmware-name",