Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp929254pxb; Thu, 28 Jan 2021 04:04:23 -0800 (PST) X-Google-Smtp-Source: ABdhPJw1np8AOuv38xMJvaruutC7xjmNRuBNCeV6Kj8+cl9IzANyZAzC9huwxMDo/9p9XWdRazHo X-Received: by 2002:aa7:d919:: with SMTP id a25mr13914765edr.243.1611835462786; Thu, 28 Jan 2021 04:04:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611835462; cv=none; d=google.com; s=arc-20160816; b=Aznf/w47KBw0EVZg2RMdhKyeu8DPZteKGPK6RnQFve7mL3IASaZJw0sjNL1zRMhIUu 3so5lyEOhcdoluSc+H06UJKbXpPSdOVl3oNklMDYLPw4EWv9Ihk6TkXXnz77y7QQNHHc P0R84hui2gWha+OQUnuDOiQ3PF8vQzJDBAz8r2aoAbNxS1R77q+p3H/YneWxENTr08e8 cpnP6ATq4b1ED0G2OGpPHO77JznCDZKj6dgN5iSpPBL2ggw6mjsq+MrIpkzgV4cPXlgd u+yNDzp1jn86rDpZ1fYUSWetRmKeDmLnTyK/Ccd67X4ur+B9CjUZRuBq7gBnxI8HWw5h UnFg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=xDkyZvkL5/FV8/3DNW7wgIsPXPOvVBPwOXxWUlvHiK4=; b=xkMhFp5TJecbBdhfy1P5jclij9HCkpYrM9jkJdqmwFTV5zeVe/uDf4Bcc1Dorm0rAh 7j5JRumj2OmvLJGl4Y3cZNrOLewSsb5T9mTlEdyKEPEcTRQ4rrBksqSGi4RDfF/Mwgb3 5IiPniAUWcKxE4LoruXW9+A18Se9O2mSiwWTBg27Ym1XZJbzUVDuvA6tlA1mjr01G2KR x+qfh54hd4uvchAkdH53BORKNXL8pT32LwGMmR+UHyCSq2tFejXjP293az0j+VRkeiow XxdEWsn4RlQdtrlP5lG8PGJ13q2KWVa4gEkXDe34XSJdW/P81QocVsNkStgUrNch6JFc Bnaw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=BasTmll2; 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=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id r11si2738452edt.118.2021.01.28.04.03.45; Thu, 28 Jan 2021 04:04:22 -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=@redhat.com header.s=mimecast20190719 header.b=BasTmll2; 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=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231236AbhA1MCP (ORCPT + 99 others); Thu, 28 Jan 2021 07:02:15 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:60612 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229569AbhA1MBj (ORCPT ); Thu, 28 Jan 2021 07:01:39 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1611835212; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=xDkyZvkL5/FV8/3DNW7wgIsPXPOvVBPwOXxWUlvHiK4=; b=BasTmll2WJhC+awjGcutrC4szqElEzmCpZ2SXoGx++Y7+f+LzgEoV5Wq0ev6TTLwyux0om Riw0fyVisKpKltsh1YDS8Wuh51+0S4gCjMl1EDCokzkGbD8MFqBYxAVPCx4OKeIV2n5Wz7 eiSBAUo1S+oz8gnEqoxP9b1yYDvqNwo= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-575-36QffA_yO72GoH1AIJI50w-1; Thu, 28 Jan 2021 07:00:10 -0500 X-MC-Unique: 36QffA_yO72GoH1AIJI50w-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id AD5598144E2; Thu, 28 Jan 2021 12:00:09 +0000 (UTC) Received: from x1.localdomain (ovpn-114-250.ams2.redhat.com [10.36.114.250]) by smtp.corp.redhat.com (Postfix) with ESMTP id 60D0B60C13; Thu, 28 Jan 2021 12:00:08 +0000 (UTC) From: Hans de Goede To: Marcel Holtmann , Johan Hedberg , Abhishek Pandit-Subedi Cc: Hans de Goede , linux-bluetooth@vger.kernel.org Subject: Recent(ish) bluetooth hci_suspend_notifier() changes Date: Thu, 28 Jan 2021 13:00:07 +0100 Message-Id: <20210128120007.5676-1-hdegoede@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org Hi All, While debugging an rtl8723bs bluetooth issue I noticed that last year the bluetooth core has grown a new hci_suspend_notifier() mechanism and I noticed a number of possible issues / improvements with that mechanism which I noticed: 1. HCI_OP_WRITE_SCAN_ENABLE gets send to the HCI in some places without a hci_dev_test_flag(hdev, HCI_BREDR_ENABLED) check 2. HCI_OP_SET_EVENT_FLT gets end to the HCI in some places without a hci_dev_test_flag(hdev, HCI_BREDR_ENABLED) check 3. hci_req_set_event_filter sends the following requests: 1 HCI_OP_SET_EVENT_FLT 2 HCI_OP_WRITE_SCAN_ENABLE (if the scan parameters have changed only) 3 HCI_OP_SET_EVENT_FLT (if their are relevant whitelist entries_ 4 HCI_OP_WRITE_SCAN_ENABLE unconditionally It seems to me that 2. is unnecessary since it will immediately be followed by 4. and 4. misses the check to see if the scan parameters need updating which 2 does (this check is done in __hci_req_update_scan() 4. There is another unconditional, possibly unnecessary HCI_OP_WRITE_SCAN_ENABLE in the if (next == BT_SUSPEND_DISCONNECT) {} block of hci_req_prepare_suspend() Note if this is made conditional then the: set_bit(SUSPEND_SCAN_DISABLE, hdev->suspend_tasks); should also be made conditional since then req might not contain any requests in which case suspend_req_complete() will not run. Regards, Hans