Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2405312imu; Thu, 24 Jan 2019 12:11:43 -0800 (PST) X-Google-Smtp-Source: ALg8bN6PW2SA+mm3U57p0rbQuI6jJSSv00Xvql3BDhf15sxWFjpVfFyQBux53kUoYBU83CPLMoOD X-Received: by 2002:a62:4587:: with SMTP id n7mr7858061pfi.118.1548360703282; Thu, 24 Jan 2019 12:11:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548360703; cv=none; d=google.com; s=arc-20160816; b=u8vIJ3eKzUsRBXXe5aK1RA/vkoSLKUqTYmZqsmVzC/WNYUJm2ggWFMsEzEGQGNQGDS /ye1RxQbx/ChTFyBtF+XQt1Ng3wzq0pjVcatS5tbtYRlLph4beZ60Bu7lLFCQ9Zu7AiL s9WgjHpBMLLPwvcapC/bJwmmdzmyUxA6UnW4Swkawwa65hqHksjRp6eCInHIqOadJIJj pg0lhqjufRbzw3kA2HvCPuYescfea395uR/Ibu2T/eJoKBRMWBM7kFp1zZ9hI+F38vcg yG9oLO4vz8VR9OwNEDUxKiKYoQn/6LuxzMJgcvwVhAe8BD5b/4Da2/Xt5E8ch6dYgvJx /DSg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=HG5FNm/40qWdHQsWrUQRMWT/agpt5B2Q6/gk2f7JfZE=; b=OP24Qp1S7r0pnICj0MgDK3v72RuoUjniUCigg0dOwJBc/A53JtsakkdBel6Y1frz0v rnW5FKTes8+ftUnpU/GdubSizYI+MVrv4rebHNbU0mSqg8Qp5lcZt7ltRyNpqAj04Ksu c1mpcbx8GuwOgYB27jU/CYzq420b8RYv/XFl/14Ir4bGQLQf1V8tBSex+aulQeWgc/Ce 9aiLyXQDtV8T/9HWrBA1hc6EWGicmmBtZtLIJoIBEbL8AeZgCF9xQqmHJ9FNXn4vg8VE /Uje0XDw2fMKBnas9lJR+ApX+cW2jfxycigM7Xt2b/AudhMyN8sfArpkLVthuN75gB54 ie3w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=WouYq4kx; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a5si22700391pgg.120.2019.01.24.12.11.27; Thu, 24 Jan 2019 12:11:43 -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; dkim=pass header.i=@google.com header.s=20161025 header.b=WouYq4kx; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730733AbfAXULW (ORCPT + 99 others); Thu, 24 Jan 2019 15:11:22 -0500 Received: from mail-lj1-f195.google.com ([209.85.208.195]:39646 "EHLO mail-lj1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729568AbfAXULV (ORCPT ); Thu, 24 Jan 2019 15:11:21 -0500 Received: by mail-lj1-f195.google.com with SMTP id t9-v6so6392343ljh.6 for ; Thu, 24 Jan 2019 12:11:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=HG5FNm/40qWdHQsWrUQRMWT/agpt5B2Q6/gk2f7JfZE=; b=WouYq4kx3ch3DRkgzhCmjF4AiZ+q05wfeAxbg9N/kksxRerTzVHL3tson1EUF0cfd2 Het0ejVSUjEIFk5p4kdG9qx4UIdhV+IC+uRnfavg89BDbOC3ok21PFqXyRFYOo5+fOZM 0LVImucOuepsNtdqEy25Qo28R1SkvAG7GbjS3J3ZFj/0/3EPyZvR+oSxPv+2yizNKhjj CxTQTDUqwCY/kT+9e4A+oAdCeJ4IOTzO67vpXN4oy3YCPVBngLvfS82dBjMKLiEET4AP 0BYY+0oEc0EMiVuBZQgjNnWbmc5PrGzkJP5DKRf7/fnDT1BPzAp+MH5BbH4SWDCx2rxm b/3A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=HG5FNm/40qWdHQsWrUQRMWT/agpt5B2Q6/gk2f7JfZE=; b=ADPCm3rwsJ5HquwVXwr/028a+nu3Gq8w6Ki8OI8ECXeZlq30BQ58cvKm7CRgNzQnAu OHWL0u2Tx41B8TpWAuz9wzOQa8C9t7mT1G7gSa0+HWH5lTp/0gxFa7S746kjquHngFGi hcpuDbXQcENTNgBLzt0215x9rwpx2oQR57p4NT8+P8tjSwvneaORAiLT9WIP63pVerCj WQgMWn/hpqUgD+uL7sE8miM4tlxyjU6rzHcyyeHa2t9J5RAOdFTcwyeX4SkR9TfWJRt/ xd84NxTxR2MJJ1KKdNYvLgCn2btXrO7YNElmfCCSqRScWobZfeQtxPThj43vlJ2c07kw r+wg== X-Gm-Message-State: AJcUukcFfih9bq70bGZxT68pvZioitisH0eHYAGh7dAksTkpQa63djYZ vzlQAPLuiAUr1eP2mXxLPJg6QLIIt9CLNw6WTZaRLw== X-Received: by 2002:a2e:9395:: with SMTP id g21-v6mr6401932ljh.78.1548360679132; Thu, 24 Jan 2019 12:11:19 -0800 (PST) MIME-Version: 1.0 References: <20181117010748.24347-1-rajatja@google.com> <20190123205725.239661-1-rajatja@google.com> <20190123205725.239661-3-rajatja@google.com> In-Reply-To: From: Rajat Jain Date: Thu, 24 Jan 2019 12:10:42 -0800 Message-ID: Subject: Re: [PATCH v5 3/4] Bluetooth: Allow driver specific cmd timeout handling To: Marcel Holtmann 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 , Rajat Jain , Dmitry Torokhov , Raghuram Hegde , chethan.tumkur.narayan@intel.com, "Ghorai, Sukumar" Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Marcel, On Thu, Jan 24, 2019 at 1:36 AM Marcel Holtmann wrote= : > > 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/h= ci_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 =3D container_of(work, struct hci_dev, > > cmd_timer.work); > > + struct hci_command_hdr *sent =3D NULL; > > > > if (hdev->sent_cmd) { > > - struct hci_command_hdr *sent =3D (void *) hdev->sent_cmd-= >data; > > - u16 opcode =3D __le16_to_cpu(sent->opcode); > > + u16 opcode; > > + > > + sent =3D (void *) hdev->sent_cmd->data; > > + opcode =3D __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. Sure, will do. > > 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 fallb= ack case where hdev->sent_cmd is not available. Unless you have that kind o= f error case, but that is only possible if you have external injection of H= CI commands. Ummm ... my preference would be to keep it outside the block so that the hook is always invoked in any timeout, to be consistent (whether externally injected or not). Let me know if that is OK. I plan to send out an iteration keeping it outside, but I'll be happy to move it in if you feel strongly about it. Thanks, Rajat > > Regards > > Marcel >