Received: by 2002:a25:e7d8:0:0:0:0:0 with SMTP id e207csp3005789ybh; Mon, 16 Mar 2020 13:58:32 -0700 (PDT) X-Google-Smtp-Source: ADFU+vuEZhh8u6TdR4I2o4x6q00Hv1GMcl7NUH6BI3WGRSi02cxEMOcowYBsupv9xPAVP0U26R0e X-Received: by 2002:a9d:21f5:: with SMTP id s108mr854482otb.227.1584392312791; Mon, 16 Mar 2020 13:58:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584392312; cv=none; d=google.com; s=arc-20160816; b=vnzTNXnmIL03xF7fMdill8KDgpt5Y16RDTmxv5dsCOLZR1HO2Tu9e6pI+rAoQ7mqKP R2t2aFpeujTEy6lI8zLBDYiKIHsTgVRfD8JMs8yc9V7YRxEkSHiMA/qxweVzt1XcahVR J9YmMGZ31k6/KB6xoSFAPh1FyGzu7SCvYvwU+ZlfldM+PeGt69IIey8ChlTGygooi7Ec PolKZiDwKy4QcMeXZMZD61aXV1+WwYSZYgerN3qeGkwCWt/tvJWfr6sxk9hRD9u9uCx9 OdHG9oGLZ33BRPS7RF53xtNvGopbrYBZR9IBTgPmFB2FZZRJkoxlUHK8iBCifAmfB9fY TMeQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=v2p+kt+gi7mSwR21kEdKeJj/xtKUzlw9AhJc+uvOCNA=; b=ODme9Bpdi/jKNsIfDXlssKYyQ3c0fz0LXYmF+v0hAEfIgEnhKsy17+P1f4yvTicCoB kzzoUKcGX5jyG70qJVzwtzCYOfuS1TRJ58lgz8Ny7hqpBpdZo/DQcZ+uU8ep+eDMVHD1 bvEt9awDASZlGZwCPXDWJ6lUtUACZoKsM8CGFbEZ46kNKi6U0cMQodlSyVTjoNeJfDVD Bjhb6ywa+2Gt7eYC/F3VBTot/TCOqPbWD9cH3ln/6xG0oG35d1o5ikSZNGIgJzyohiq3 uhUPQgVQOYmXdHEBu0ucXcGs/nWeozHjCp+GfS2xmes9d3lmnpB07mG4bb4+YIUBDAjC fpFQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=S0eklOvb; spf=pass (google.com: best guess record for domain of linux-bluetooth-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h23si558024otk.315.2020.03.16.13.58.15; Mon, 16 Mar 2020 13:58:32 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-bluetooth-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=@gmail.com header.s=20161025 header.b=S0eklOvb; spf=pass (google.com: best guess record for domain of linux-bluetooth-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732571AbgCPU6K (ORCPT + 99 others); Mon, 16 Mar 2020 16:58:10 -0400 Received: from mail-ot1-f68.google.com ([209.85.210.68]:42949 "EHLO mail-ot1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732567AbgCPU6K (ORCPT ); Mon, 16 Mar 2020 16:58:10 -0400 Received: by mail-ot1-f68.google.com with SMTP id 66so19374794otd.9 for ; Mon, 16 Mar 2020 13:58:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=v2p+kt+gi7mSwR21kEdKeJj/xtKUzlw9AhJc+uvOCNA=; b=S0eklOvbcosWStObSU9Szzy4IvLjwCqirFsGDfOeI+CDc/73GBENPs78RIESnOTAh/ mW82VStby+qvTbur4vNPtFDkYRHj9aqQzBCTdspjz9+wwtCZdRF3nLqvzW1cEP1DH9Jq aOiLSukn+Vq0BVJ3EoMYBDrzrcT1nyGi51tm8I6msGZbbAfx8KEnSIhpQ+MjfU4KcFA8 t0WO1/jSxAZfXG+9Vwb9Kg+0XuyDmWL2T/ElFlITz9ZNS1cEt5z3HUgdQ+LsgTmBMZS+ QFCI5yCQffkrWoBNqNCWD5ZORM6rZoZwiGltFRuLFZY6pIrwJsr9PpYZRsax+ML4aXOw riHw== 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; bh=v2p+kt+gi7mSwR21kEdKeJj/xtKUzlw9AhJc+uvOCNA=; b=aUuHzYdCivc7ZGu9B9ODZWKGwyJe0wO3Z2pV4reh9OoBmjuexS1X9l2U+fGPjIhiBA Hhu9zTAkoA4soMHHSKvLe3VIPWhB67NNAkNeiYAo4raHL+TyNYEIlNZm9dyqeVrxxxu7 rnYexGlEiy2lmtgPzRCGksyEuX9+eVVDVFFbtN3Hz04/Ve4CwlaIFrlTkotYeT6pA/JH D4SeyI7j+KU5myBsUqbUjjDikNaXokhjqWOQrmDadAMF/sHEG6pRFngXNhEScY/nudki uxJ1j+vLo09Ttck3qKDFSWzDlgHyzhCP2CldZrwX/AQNgjkWgawKhJlwPTOe79sgA+IZ doMA== X-Gm-Message-State: ANhLgQ3CsligXaX8wpl2i1CBZU5/eZxW25Bj0qaZIV3nS0vvocWWs/nj M6vm4Pw3jAAsb3thCT8ddulhXxNJ3gkvRxRyc6M= X-Received: by 2002:a05:6830:1e06:: with SMTP id s6mr1017910otr.28.1584392289471; Mon, 16 Mar 2020 13:58:09 -0700 (PDT) MIME-Version: 1.0 References: <20200316123914.Bluez.v1.1.I2c83372de789a015c1ee506690bb795ee0b0b0d9@changeid> In-Reply-To: <20200316123914.Bluez.v1.1.I2c83372de789a015c1ee506690bb795ee0b0b0d9@changeid> From: Luiz Augusto von Dentz Date: Mon, 16 Mar 2020 13:57:57 -0700 Message-ID: Subject: Re: [Bluez PATCH v1] input: disconnect intr channel before ctrl channel To: Archie Pusaka Cc: linux-bluetooth , Archie Pusaka Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org Hi Archie, On Sun, Mar 15, 2020 at 9:40 PM Archie Pusaka wrote: > > From: Archie Pusaka > > According to bluetooth HID Profile spec Ver 1.0, section 7.2.2, A > host or device shall always complete the disconnection of the > interrupt channel before disconnecting the control channel. > However, the current implementation disconnects them both > simultaneously. > > This patch postpone the disconnection of control channel to the > callback of interrupt watch, which shall be called upon receiving > interrupt channel disconnection response. > --- > > profiles/input/device.c | 15 ++++++++++----- > 1 file changed, 10 insertions(+), 5 deletions(-) > > diff --git a/profiles/input/device.c b/profiles/input/device.c > index 8ada1b4ff..8ef3714c9 100644 > --- a/profiles/input/device.c > +++ b/profiles/input/device.c > @@ -1010,14 +1010,19 @@ static bool is_connected(struct input_device *idev) > > static int connection_disconnect(struct input_device *idev, uint32_t flags) > { > + int sock; > + > if (!is_connected(idev)) > return -ENOTCONN; > > - /* Standard HID disconnect */ > - if (idev->intr_io) > - g_io_channel_shutdown(idev->intr_io, TRUE, NULL); > - if (idev->ctrl_io) > - g_io_channel_shutdown(idev->ctrl_io, TRUE, NULL); > + /* Standard HID disconnect > + * Intr channel must be disconnected before ctrl channel, so only > + * disconnect intr here, ctrl is disconnected in intr_watch_cb. > + */ > + if (idev->intr_io) { > + sock = g_io_channel_unix_get_fd(idev->intr_io); > + shutdown(sock, SHUT_RDWR); > + } > > if (idev->uhid) > return 0; > -- > 2.25.1.481.gfbce0eb801-goog Just to confirm, have you checked if this works with both situation where the device is being removed or just being disconnected, specially the case of HIDP_CTRL_VIRTUAL_CABLE_UNPLUG which perhaps was not working before as well since we disconnect the ctrl channel before transmitting it. -- Luiz Augusto von Dentz