Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp702362pxb; Thu, 21 Jan 2021 18:38:47 -0800 (PST) X-Google-Smtp-Source: ABdhPJxNrcmg0SC1wMKiwnmSBoslfsOMfNtCQ+TmceE/lxxab3DZ7P79ZteqZDYG9ahPBoql6C88 X-Received: by 2002:a17:907:da9:: with SMTP id go41mr1586632ejc.326.1611283127336; Thu, 21 Jan 2021 18:38:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611283127; cv=none; d=google.com; s=arc-20160816; b=EX+CtrGpBpzNVqGJm66ZuFRu76iGo9McPbs12p5kB9GyUBuw8eJy0rY1oJQ4oSUSvx BbXn29GmV2Tm0MblKWTyD8eJN2a1kHaogmaj6iMW5VqYFOZdztdEUpFzzxvSyCpvfRBL ILa73nxtFGygGHq+YTvlQ0LkbXKIoq+XilBX/LNmE5tv0WqJVYxEjE8QYS4v6IpUYdbb LoDz0UPbSx3Srz7i3Iwluw7If/TgBcjPVYRu8NIOu8K9IfRmaWGPhIxqixiaox13U3hf wyxgwusCplemz5hfM9xSyO8stWOcB98IIduAYYRwF3ro1ENu+RLvDiOrq985A45Zl/Mt B/gA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=RCP0VJStTzPj9G2IsY14W0aFRvVkpeiVaW3fq1R6f4E=; b=nUC5/JP7XbXcf3AmHR7V4tGgvKpd/2quEMetNkKw2XGExzpxVBSSvJkCpP84RHU7d+ dRw5p3Au7/iWSQJUQ3jqiVTG1l3TwCRMiQvf7Our6XgXTeFGwj2CRBNKAy7O9DIltMHl epwIZ9kZKyH8A3AmUcfEmfNWIM9CvYUCLcNm0RSqkvdsFLDzssH2d4njJ2zOo0qd2tZI vagYwvb2IOcniJr2UaEjZo/SNgBIWVU9EVFlI1kQ8Bvwa14HbggMBnxbMDGxc5+CuhZD jRcXcvZTL+i/h5yLL/7IHaEkGV27JdcFfUFbHmi5GIMikc4C2q+RnjyEjOzhWdh7OGN8 SMMA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=RZUF6zIl; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j15si2994638edv.474.2021.01.21.18.38.08; Thu, 21 Jan 2021 18:38:47 -0800 (PST) Received-SPF: pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=RZUF6zIl; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726182AbhAVAwk (ORCPT + 99 others); Thu, 21 Jan 2021 19:52:40 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45842 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725831AbhAVAwk (ORCPT ); Thu, 21 Jan 2021 19:52:40 -0500 Received: from mail-ej1-x632.google.com (mail-ej1-x632.google.com [IPv6:2a00:1450:4864:20::632]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B666BC061756 for ; Thu, 21 Jan 2021 16:51:59 -0800 (PST) Received: by mail-ej1-x632.google.com with SMTP id ox12so5323909ejb.2 for ; Thu, 21 Jan 2021 16:51:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=RCP0VJStTzPj9G2IsY14W0aFRvVkpeiVaW3fq1R6f4E=; b=RZUF6zIllbmIQ2P+V0dIsxqHn+lIJAndn8catulIKXNeQVBnIXUomB7iqFA4zMbkZ0 A8plKuFVR2GUhlVvv5lVtiNwYJZWnFiJmQMdXi1uRI+MpBqBeysCByaI+UUx9lclDEbq plxy38xd3dyhKWl9NtlAzseQKwfdqyMamzXmE= 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=RCP0VJStTzPj9G2IsY14W0aFRvVkpeiVaW3fq1R6f4E=; b=Wmg493w2PBT6+MSCoytQxvovwfUIYhbcV6g/7+MmACyENcHz3achu7rJ9GmGzAsZ9a tpadS7kgbnaJ3kcfE44T3GoutTgsh5tyOwTG76D/M+Xk48fxVbl6VilpTtbqfGr/FFFI rHV/9ullbnFqw5t9PZmGTDnGdL7oRGDtVqd+Fjm8J7GiRyrooaxlxQK+xtsjWv2Z/Twb DCE03K3nyAiMbmNikWYT2FsHKAJSqq9d6oSOUFpXXDuxAP0iqzbxyxUwN61M09cNODSx KXhxHY4TzfXvNRKpUuZwJQ8aVXNXMPL6BJYMAsCmCTvAWcwbfbM1lexvCkUrSmHnh0vt Ilsg== X-Gm-Message-State: AOAM532tpFnhBW4L6oupkzlMgqKGe01PKS6DNmNKSjpRpNuugYSy/V5Y a/yWV3sTauYzcieIxoOCmxf86IWNyLSFlQ== X-Received: by 2002:a17:906:478a:: with SMTP id cw10mr1295891ejc.533.1611276718314; Thu, 21 Jan 2021 16:51:58 -0800 (PST) Received: from mail-wr1-f45.google.com (mail-wr1-f45.google.com. [209.85.221.45]) by smtp.gmail.com with ESMTPSA id h16sm3885736eds.21.2021.01.21.16.51.57 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 21 Jan 2021 16:51:57 -0800 (PST) Received: by mail-wr1-f45.google.com with SMTP id g10so3526377wrx.1 for ; Thu, 21 Jan 2021 16:51:57 -0800 (PST) X-Received: by 2002:a5d:4d8b:: with SMTP id b11mr1870321wru.215.1611276717462; Thu, 21 Jan 2021 16:51:57 -0800 (PST) MIME-Version: 1.0 References: <20210122001326.14263-1-sonnysasaka@chromium.org> In-Reply-To: From: Sonny Sasaka Date: Thu, 21 Jan 2021 16:51:45 -0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH BlueZ v2 1/2] input/hog: Fix double registering report value callbacks To: Luiz Augusto von Dentz Cc: "linux-bluetooth@vger.kernel.org" Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org Hi Luiz, Sorry I missed your reply before. I think it's a good idea using notifyid, let me give it a try. On Thu, Jan 21, 2021 at 4:39 PM Luiz Augusto von Dentz wrote: > > Hi Sonny, > > On Thu, Jan 21, 2021 at 4:19 PM Sonny Sasaka wrote: > > > > In commit 23b69ab3e484 ("input/hog: Cache the HID report map"), we > > optimized HOG reconnection by registering report value callbacks early, > > but there was a bug where we also re-register the same report value > > callbacks after at CCC write callback. We should handle this case by > > avoiding the second callback register if we know we have done it > > earlier. > > > > --- > > profiles/input/hog-lib.c | 12 ++++++++++++ > > 1 file changed, 12 insertions(+) > > > > diff --git a/profiles/input/hog-lib.c b/profiles/input/hog-lib.c > > index 1f132aa4c..089f42826 100644 > > --- a/profiles/input/hog-lib.c > > +++ b/profiles/input/hog-lib.c > > @@ -80,6 +80,7 @@ struct bt_hog { > > struct bt_uhid *uhid; > > int uhid_fd; > > bool uhid_created; > > + bool report_value_cb_registered; > > gboolean has_report_id; > > uint16_t bcdhid; > > uint8_t bcountrycode; > > @@ -336,6 +337,13 @@ static void report_ccc_written_cb(guint8 status, const guint8 *pdu, > > return; > > } > > > > + /* If we already had the report map cache, we must have registered UHID > > + * and the report value callbacks. In that case, don't re-register the > > + * report value callbacks here. > > + */ > > + if (hog->report_value_cb_registered) > > + return; > > + > > Didn't I comment on this problem before? I do recall suggesting using > notifyid instead of adding yet another flag. > > > report->notifyid = g_attrib_register(hog->attrib, > > ATT_OP_HANDLE_NOTIFY, > > report->value_handle, > > @@ -1703,6 +1711,8 @@ bool bt_hog_attach(struct bt_hog *hog, void *gatt) > > report_value_cb, r, NULL); > > } > > > > + hog->report_value_cb_registered = true; > > + > > return true; > > } > > > > @@ -1753,6 +1763,8 @@ void bt_hog_detach(struct bt_hog *hog) > > } > > } > > > > + hog->report_value_cb_registered = false; > > + > > if (hog->scpp) > > bt_scpp_detach(hog->scpp); > > > > -- > > 2.29.2 > > > > > -- > Luiz Augusto von Dentz