Received: by 2002:a05:7412:e794:b0:fa:551:50a7 with SMTP id o20csp526743rdd; Tue, 9 Jan 2024 11:09:13 -0800 (PST) X-Google-Smtp-Source: AGHT+IG306Rkqycqns6zHbvYPsMjHzQUw0bHg76t2cx+91buZh4yofPHzR3DvSDrbWKHWlh5vQY3 X-Received: by 2002:a05:620a:4592:b0:783:1513:38b8 with SMTP id bp18-20020a05620a459200b00783151338b8mr2565043qkb.52.1704827353251; Tue, 09 Jan 2024 11:09:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704827353; cv=none; d=google.com; s=arc-20160816; b=1Laq+b9BeMuuH9t1K8VXJjb32OkK+xD6+8qn4CKhxh5Sj3ye3AIV7GNxVd/AE8vJQW UV2w7YKjZ6UwcfJ5EGGefobU+gCYSIQkiGiMfPEDzpk+FHeL5IG3TZgicIhRiBBQbRH+ gBaV9WdeeADW+p0mIuL1+ZyCBT2DZfJCzQUcOqUnreZpCnvPoNVBqgrHClPJY/EVEYDv Mfv3szv0QCCfMq5satHhZ7UMJEBZaIz3JKGA7MDuRltkHMufv04UbbdnD6MnPR8f6prz E18V6eszEGdN+AhOE5KZSfYGxk9uUOgyLWBAdSSeSbq1k+SKYB8p0wyBiz1xjMYJ2YIc JULg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:to:from :dkim-signature; bh=gxMh/XZqeJNIbjEzr56tNxTCqRqB1iF8p0Up7EnBXtQ=; fh=4lGQI6056MBa4/oovMyIYaKLn+Wz/24RGvUivMmQP8E=; b=GLN3yWzsiX7c9O+iXYacm1LhD3YvJn2pyuRQDZySquZqAH12jgbgmQFmGRkR/UM8BJ reRx69Bn3ZRoSfub8CGwsXMjzT/C/vMlhIiXheqmXC2D5ADrHzxf8tb2yheCsXDA2fsP XJOPQQE+LgAtSGCoLCNPsRLVEqcpWyOm+gaGh+7Nck4uvCBiYjnHuR0l+y85gQxMCmMw XdEjNU2RwfIlBJag32Nz7hAn94PEoZiTb9z2x44GE4msppmTLrQt2af/I6jycr/8JGHY VBbrvHokQng3F65sUp43BN0CPo047eb4cMT7ntsaHvwY5FmcifGSAh2qO6qY8McENoDs uq/g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=jBSzuVED; spf=pass (google.com: domain of linux-bluetooth+bounces-1011-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-bluetooth+bounces-1011-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id az37-20020a05620a172500b0078323633126si2765554qkb.242.2024.01.09.11.09.13 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Jan 2024 11:09:13 -0800 (PST) Received-SPF: pass (google.com: domain of linux-bluetooth+bounces-1011-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=jBSzuVED; spf=pass (google.com: domain of linux-bluetooth+bounces-1011-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-bluetooth+bounces-1011-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 07AE91C24EE7 for ; Tue, 9 Jan 2024 19:09:13 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0F7E93D0BE; Tue, 9 Jan 2024 19:09:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="jBSzuVED" X-Original-To: linux-bluetooth@vger.kernel.org Received: from mail-qk1-f173.google.com (mail-qk1-f173.google.com [209.85.222.173]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 23BFA3D0AF for ; Tue, 9 Jan 2024 19:09:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-qk1-f173.google.com with SMTP id af79cd13be357-783182d4a0aso255843485a.2 for ; Tue, 09 Jan 2024 11:09:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1704827347; x=1705432147; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:from:to:cc:subject:date:message-id:reply-to; bh=gxMh/XZqeJNIbjEzr56tNxTCqRqB1iF8p0Up7EnBXtQ=; b=jBSzuVEDxfC29KbGyakCLpUmEc15eBcC9rnn5vXqGHHzuvKiQQKNPan1iGsj4rjfCH l6uPT0+AtF6m9b46tHn+i5tq0DFCON0Hmn2zuHARxlzCdykPBFbJxLUG2DN5eLk+uzPH dOyhvvA3daufaQmxtYsCByRUN4wwCwM6DcKb8miN8JDKgg512tLuaYkSbkgvEbTXS9On rrixTgX2FDzPNLrlSI5jfy0OIMQRz3+0Ax1J215TotAJ66Q1Sk3J23PFQtXhd9txhPe2 gCcrgAJhLMEO13Dfb0ZAs4IL4ib9NcG4G5pzntmrWwI4pi2B4tEo6sLIlCJnPhALg0Hl KNLg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704827347; x=1705432147; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=gxMh/XZqeJNIbjEzr56tNxTCqRqB1iF8p0Up7EnBXtQ=; b=ptv+olVO5Yu+GDKuavpPFUd8BdehyLVYMiVzing+iV8LKHOgt91oAKqKNe2w7hr69A LhABAOeqbsrJ8c4SUnltqtPp0BKWFmmt8HF/urTTMgEwaUxopOtLeVdHYzVBIyITgg9t KUvRDnrkXxHeQJTOeZ0tmFpZeL+dqDDis/WwlLaA+35ew+vdP0zI701HQurZmt0D3v4B EReM+thNtB3ODMQTqFBOTnYfnFrrayKDSLqHkhoDo1yrzUjT+yVpsmGin3y6R78qJoIM HYnzVdvjRtwFvRL3HDxVDH6bHZHTs7MBRHs5v1FUaQc1p5truiVWB6RKUKrLOrKAvhAs lY0w== X-Gm-Message-State: AOJu0YyYnyvmYIuHSzdmHxrMKh0clWkMulKJAkPP7OaOXZAvcLPzXAuC e4qiU+bDq1lfMhApqUXXgBp+fFD3Zig= X-Received: by 2002:a05:6214:f24:b0:67f:d5ac:4b3b with SMTP id iw4-20020a0562140f2400b0067fd5ac4b3bmr9248637qvb.115.1704827347474; Tue, 09 Jan 2024 11:09:07 -0800 (PST) Received: from lvondent-mobl4.. (071-047-239-151.res.spectrum.com. [71.47.239.151]) by smtp.gmail.com with ESMTPSA id z17-20020a0cfc11000000b00680ca85b06fsm1110332qvo.31.2024.01.09.11.09.06 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Jan 2024 11:09:06 -0800 (PST) From: Luiz Augusto von Dentz To: linux-bluetooth@vger.kernel.org Subject: [PATCH v1] Bluetooth: hci_core: Complete request if command timeout Date: Tue, 9 Jan 2024 14:09:05 -0500 Message-ID: <20240109190905.546266-1-luiz.dentz@gmail.com> X-Mailer: git-send-email 2.43.0 Precedence: bulk X-Mailing-List: linux-bluetooth@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Luiz Augusto von Dentz If command has timeout notify the hci_req since it will inevitably cause a timeout. Signed-off-by: Luiz Augusto von Dentz --- net/bluetooth/hci_core.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c index e5cb618fa6d3..acf4d99cd8fc 100644 --- a/net/bluetooth/hci_core.c +++ b/net/bluetooth/hci_core.c @@ -1523,10 +1523,21 @@ static void hci_cmd_timeout(struct work_struct *work) cmd_timer.work); if (hdev->sent_cmd) { - struct hci_command_hdr *sent = (void *) hdev->sent_cmd->data; - u16 opcode = __le16_to_cpu(sent->opcode); + u16 opcode = hci_skb_opcode(hdev->sent_cmd); + u8 status = HCI_ERROR_CONNECTION_TIMEOUT; + hci_req_complete_t req_complete = NULL; + hci_req_complete_skb_t req_complete_skb = NULL; bt_dev_err(hdev, "command 0x%4.4x tx timeout", opcode); + + hci_req_cmd_complete(hdev, opcode, status, &req_complete, + &req_complete_skb); + + /* Notify hci_req the command has timed out */ + if (req_complete) + req_complete(hdev, status, opcode); + else if (req_complete_skb) + req_complete_skb(hdev, status, opcode, NULL); } else { bt_dev_err(hdev, "command tx timeout"); } -- 2.43.0