From patchwork Wed Jan 23 20:57:24 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rajat Jain X-Patchwork-Id: 1030167 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=google.com header.i=@google.com header.b="UGrv71G9"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 43lHg072G6z9s55 for ; Thu, 24 Jan 2019 07:57:48 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726946AbfAWU5m (ORCPT ); Wed, 23 Jan 2019 15:57:42 -0500 Received: from mail-pl1-f202.google.com ([209.85.214.202]:52192 "EHLO mail-pl1-f202.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726867AbfAWU5i (ORCPT ); Wed, 23 Jan 2019 15:57:38 -0500 Received: by mail-pl1-f202.google.com with SMTP id 12so2325946plb.18 for ; Wed, 23 Jan 2019 12:57:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=b1uUbZsyhmSj82CJe/fFgzrboSy+IQsjI8LagdR/gaM=; b=UGrv71G90YQNeN5Vvdea+LRmvJ2MZnJhJOpfkZTfdIcOtavVJazMi0+Gw37w+Un9on M0vSFHl6xhJNXXr3vnSwaK5OLjVSgv1ZK2nDZI0BAx1iSOUkRdCfIw+3KFlsjbwP1E/I sozdRo4HJal7EgSWnckzLV66uoAn77pqWacV187BtF+XwrsqB425EGQLkQxCOqtX6MBd 3pTOmueac2f/7tHoeBKrk/ul7gAFKyxjPnJZVoutBanZdqfSUGXlZU0sZEzBntoutC0V 7VrKJNyf/tyN46FjHD9V/WMcuaB27K/24MTB7pkWSGu3TdwnqHVVv5CBr+EktXlbcdo5 FIiw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=b1uUbZsyhmSj82CJe/fFgzrboSy+IQsjI8LagdR/gaM=; b=dqsGhsliHDlvIzfYAO1pRpedkzEN5XtSFQ3FQDXnFGBtgjXmxlzVD9rhQ2FunYkzQc 2Bvkl59b0u2ckjCU5XnRV/cR4G4BGIiIqF6ILwGj9ADIsrYyBtsfqdHPH9ylD+MgrvfF IEcjsdFpuVQDA3BLOCg2UI+aPYzYVfsECJoST8ywas2sh/naQE+gvAOdTAT8Vb2MIWji Zi0lOny1XgrNY+PeU0yDqrjrLL9P/VHXy5efeTRNqvwn4BFdgs+XRyyoQ67vmAllYW23 BaMg5XNgwzIkKg2DgiLJr8+UpcD3KUnTde96I319fpl4SvSDKk4dcdy403u65R9lA832 21SA== X-Gm-Message-State: AJcUukdr6ATK7KwnPCcP0nMQ8byuPRHUB9Q++1gmgaP5Hf2qzsYKiHr+ 3yuKdEkUlQHPGFNE37yeOanp0BoXS3uU X-Google-Smtp-Source: ALg8bN4fb62tI1JN8/1GdsgJIFzKkowPGf7t+rbHtvK6Su1eMYtqXFjaphAT7mQ+h4NP+ysf0TcZAq4/KFU7 X-Received: by 2002:a62:1195:: with SMTP id 21mr1544185pfr.61.1548277057637; Wed, 23 Jan 2019 12:57:37 -0800 (PST) Date: Wed, 23 Jan 2019 12:57:24 -0800 In-Reply-To: <20190123205725.239661-1-rajatja@google.com> Message-Id: <20190123205725.239661-3-rajatja@google.com> Mime-Version: 1.0 References: <20181117010748.24347-1-rajatja@google.com> <20190123205725.239661-1-rajatja@google.com> X-Mailer: git-send-email 2.20.1.321.g9e740568ce-goog Subject: [PATCH v5 3/4] Bluetooth: Allow driver specific cmd timeout handling From: Rajat Jain To: Marcel Holtmann , Johan Hedberg , Greg Kroah-Hartman , "David S. Miller" , Dmitry Torokhov , Rajat Jain , Alex Hung , linux-bluetooth@vger.kernel.org, linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org, netdev@vger.kernel.org Cc: rajatxjain@gmail.com, dtor@google.com, raghuram.hegde@intel.com, chethan.tumkur.narayan@intel.com, sukumar.ghorai@intel.com Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Add a hook to allow the BT driver to do device or command specific handling in case of timeouts. This is to be used by Intel driver to reset the device after certain number of timeouts. Signed-off-by: Rajat Jain --- v5: Drop the quirk, and rename the hook function to cmd_timeout() v4: same as v1 v3: same as v1 v2: same as v1 include/net/bluetooth/hci_core.h | 1 + net/bluetooth/hci_core.c | 10 ++++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h index e5ea633ea368..624d5f2b1f36 100644 --- a/include/net/bluetooth/hci_core.h +++ b/include/net/bluetooth/hci_core.h @@ -437,6 +437,7 @@ struct hci_dev { 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 (*cmd_timeout)(struct hci_dev *hdev, struct hci_command_hdr *cmd); }; #define HCI_PHY_HANDLE(handle) (handle & 0xff) diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c index 7352fe85674b..c6917f57581a 100644 --- a/net/bluetooth/hci_core.c +++ b/net/bluetooth/hci_core.c @@ -2568,16 +2568,22 @@ static void hci_cmd_timeout(struct work_struct *work) { struct hci_dev *hdev = container_of(work, struct hci_dev, cmd_timer.work); + struct hci_command_hdr *sent = NULL; if (hdev->sent_cmd) { - struct hci_command_hdr *sent = (void *) hdev->sent_cmd->data; - u16 opcode = __le16_to_cpu(sent->opcode); + u16 opcode; + + sent = (void *) hdev->sent_cmd->data; + opcode = __le16_to_cpu(sent->opcode); bt_dev_err(hdev, "command 0x%4.4x tx timeout", opcode); } else { bt_dev_err(hdev, "command tx timeout"); } + if (hdev->cmd_timeout) + hdev->cmd_timeout(hdev, sent); + atomic_set(&hdev->cmd_cnt, 1); queue_work(hdev->workqueue, &hdev->cmd_work); }