Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp1780767imu; Thu, 24 Jan 2019 01:38:05 -0800 (PST) X-Google-Smtp-Source: ALg8bN4n/5iIUcVQoMxxq17e/bF4VWkrkYQAaIf74L7rTnm/sJBbKqqaJ9DaekNXuema+8VJx3gK X-Received: by 2002:a62:1f97:: with SMTP id l23mr5670679pfj.13.1548322685211; Thu, 24 Jan 2019 01:38:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548322685; cv=none; d=google.com; s=arc-20160816; b=I81r0FKJzCHHdKpITvJWT+VqjP+TheAyMsZ6XZCLRdqISWqpvuHtG5UdnNIA/uxT8n Dhaq78emooJBp2EhvVP9UgbuSYUV7Glc++Xi1nkCR92VexXiEDXq2Zum8lvzP1mK5pWL mOUWIV7BYCureVwAR184rR/Mf6o67hBCfUZ5kUjP6w/jPowoVjet2nG9CvrTp25QWoDR pGCrJjef51AZ6EcO8v6UMR3TkDWOA1P94coBoihnxGXuziUd073tVA9/0v8fP+pUae1g ChWkq5xcvNf2H37hwhIKe0o4nWCJQne0OdF546lTedZkI41Tf5DrDvn8QTDoh06PuQds iRnw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:to:references:message-id :content-transfer-encoding:cc:date:in-reply-to:from:subject :mime-version; bh=lSCccMNaPz0RJSZWWl2iCPqyipLtH96KOSDTd9hcyQM=; b=g3DaqVRMJI4ME8RKTo7QeP77Y89G6ocJ5pnGwNH1SlofpAgHELHEsxBW+Z9UDBPMij 02RgnPFc1CkWunHKcRmf7t5RKmyQrDNXq1jBdT9P21N/6QlO18ppcjj1d1ZnUgTey7rG Zhqb65/TDm3317S/9n7kK8nBWP7kwCh+MxbdSiUg8gjkr0DPHuQTk6WyWz+G7FokUrBL QYYMZNKVHDlfvWDQMOZwvnV0eqFuOITT5RvI8CF3HXhsUJH/Hmlbv16PPPNlZst0GLYi PZpuuqnLD0Zcf4X7EDoPKnlbQIAaAE8zOZwpYZPMl5roDpdhsxkvd0DJVjzYrHFKArF2 cspA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b21si22562401pfb.89.2019.01.24.01.37.49; Thu, 24 Jan 2019 01:38:05 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727126AbfAXJgY convert rfc822-to-8bit (ORCPT + 99 others); Thu, 24 Jan 2019 04:36:24 -0500 Received: from coyote.holtmann.net ([212.227.132.17]:56158 "EHLO mail.holtmann.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726025AbfAXJgY (ORCPT ); Thu, 24 Jan 2019 04:36:24 -0500 Received: from marcel-macpro.fritz.box (p4FF9FD60.dip0.t-ipconnect.de [79.249.253.96]) by mail.holtmann.org (Postfix) with ESMTPSA id 4CC34CF166; Thu, 24 Jan 2019 10:44:09 +0100 (CET) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 12.2 \(3445.102.3\)) Subject: Re: [PATCH v5 3/4] Bluetooth: Allow driver specific cmd timeout handling From: Marcel Holtmann In-Reply-To: <20190123205725.239661-3-rajatja@google.com> Date: Thu, 24 Jan 2019 10:36:21 +0100 Cc: Johan Hedberg , Greg Kroah-Hartman , "David S. Miller" , Dmitry Torokhov , Alex Hung , Bluez mailing list , Linux Kernel Mailing List , linux-usb@vger.kernel.org, netdev , rajatxjain@gmail.com, dtor@google.com, Raghuram Hegde , chethan.tumkur.narayan@intel.com, sukumar.ghorai@intel.com Content-Transfer-Encoding: 8BIT Message-Id: References: <20181117010748.24347-1-rajatja@google.com> <20190123205725.239661-1-rajatja@google.com> <20190123205725.239661-3-rajatja@google.com> To: Rajat Jain X-Mailer: Apple Mail (2.3445.102.3) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Rajat, > 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); > + drop the sent parameter. You are not using it and if at some point in the future you might want to use it, then we add it and fix up all users. And frankly, I would move the hdev->cmd_timeout call into the hdev->sent_cmd block since I do not even know if it makes sense to deal with the fallback case where hdev->sent_cmd is not available. Unless you have that kind of error case, but that is only possible if you have external injection of HCI commands. Regards Marcel