Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp7515703pxb; Thu, 18 Feb 2021 12:08:40 -0800 (PST) X-Google-Smtp-Source: ABdhPJytwub5LOyEPfxaMlPvN0cJ5QI04v7cRdcGgSwj58j4Wukv3ylUyjlXMzjjntsMxuHhG5Qp X-Received: by 2002:a50:a086:: with SMTP id 6mr5637700edo.70.1613678920029; Thu, 18 Feb 2021 12:08:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1613678920; cv=none; d=google.com; s=arc-20160816; b=k+fnAhP/4sCY+hg1XOyXHODBF4IE60WCW6/kOHq2Bhd3fmFR/QUyP7CkZUDHzYOHyn fDIvk70ujYGC7JOMq65pFSFcQtJleMDzr1Ye4c+dKV/Oq9+9GA3kcOGzu512KO7gmI7n 85A2Y8AT5nlPUjoK3SIkBpkZGXPvAs17MrQHmis/RtKg041lcivL+XwFP4ERehfkDYC5 t0v96FvCH0FvLH5NSJzF6W+SpJdh1zCxInBQcOQgoiTy5p0qrpRddUIba7GkGOV6hTHE KR9aqi2bd7QiWT50zBJgFMU3tg6q0m+fsKO1vVDJeXb3jnKh4VlE2ZYF9UfG2F9moCrt JR4A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:to:references:message-id :content-transfer-encoding:cc:date:in-reply-to:from:subject :mime-version; bh=ftr3pwuaGHEBUR/2SXyl3xD4HdISkt0VA7IVTMfhhHI=; b=ASuyBCBR2wARF3A17niuU5CkoFeLd8cIg0jotAPivO0q9gUMJ5f08uGBMd3knNuJGq xfYB/9CEedly5VzjCix9rg3HmIjGGnSAyZNmVFZYXOWIBh2H5pULvfSsvjNH3pBmYc1W lU8z2QGDbfuW8eFLjbx3mYE4ZFxcttjuh7J5MBs6mCb8061TKKrVujPPVbFPRXK5PCeA e5TRDPE3uV4FPY59kNud3Zb63DXTD7mUORIEeoq8O17fU2YuuWrSUnCxApORKTLKaavQ v8HXka6+52XjfhBFxNawAWMUIwnMADtAZzW744dnZWhDzk/VjN+klyUHc94vnL+qzp3v 3Eow== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id k10si4055197ejc.702.2021.02.18.12.07.58; Thu, 18 Feb 2021 12:08:40 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230353AbhBRUEW convert rfc822-to-8bit (ORCPT + 99 others); Thu, 18 Feb 2021 15:04:22 -0500 Received: from coyote.holtmann.net ([212.227.132.17]:55979 "EHLO mail.holtmann.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232282AbhBRUCE (ORCPT ); Thu, 18 Feb 2021 15:02:04 -0500 Received: from marcel-macbook.holtmann.net (p5b3d2dad.dip0.t-ipconnect.de [91.61.45.173]) by mail.holtmann.org (Postfix) with ESMTPSA id 18B84CECD6; Thu, 18 Feb 2021 21:08:48 +0100 (CET) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 14.0 \(3654.60.0.2.21\)) Subject: Re: [PATCH 5.12 regression fix] Bluetooth: btusb: Revert Fix the autosuspend enable and disable From: Marcel Holtmann In-Reply-To: <4510935f-a30b-445d-a048-683619f2855b@redhat.com> Date: Thu, 18 Feb 2021 21:01:17 +0100 Cc: Hui Wang , Johan Hedberg , linux-bluetooth@vger.kernel.org Content-Transfer-Encoding: 8BIT Message-Id: <6CE927B6-449A-472C-9196-AF98895AA5E1@holtmann.org> References: <20210218123728.17067-1-hdegoede@redhat.com> <20210218123728.17067-2-hdegoede@redhat.com> <90d8996d-a376-2e9c-37ce-ce50b8660fd1@canonical.com> <4510935f-a30b-445d-a048-683619f2855b@redhat.com> To: Hans de Goede X-Mailer: Apple Mail (2.3654.60.0.2.21) Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org Hi Hans, >>> drivers/usb/core/hub.c: usb_new_device() contains the following: >> [...] >>> err = hci_register_dev(hdev); >>> if (err < 0) >>> @@ -4688,9 +4688,6 @@ static void btusb_disconnect(struct usb_interface *intf) >>> gpiod_put(data->reset_gpio); >>> hci_free_dev(hdev); >>> - >>> - if (!enable_autosuspend) >>> - usb_enable_autosuspend(data->udev); >> Hi Hans, >> >> And Do we need to call usb_disable_autosuspend() in the disconnect()? like below: >> >> diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c >> index 32161dd40ed6..ef831492363c 100644 >> --- a/drivers/bluetooth/btusb.c >> +++ b/drivers/bluetooth/btusb.c >> @@ -4673,6 +4673,9 @@ static void btusb_disconnect(struct usb_interface *intf) >> >> hci_unregister_dev(hdev); >> >> + if (enable_autosuspend) >> + usb_disable_autosuspend(data->udev); >> + >> if (intf == data->intf) { >> if (data->isoc) >> usb_driver_release_interface(&btusb_driver, data->isoc); >> >> >> Before the btusb_probe() is called, the usb device is autosuspend disabled, suppose users set the btusb.enable_autosuspend=1, the driver btusb will enable the autosuspend on this device. If users remove this driver, the disconnect() will be called, the usb device will keep autosuspend enabled. Next time if users reload this driver by 'sudo modprobe btusb enalbe_autosuspend=0', they will find the device is autosuspend enabled instead of disabled. > > The problem with calling usb_disable_autosuspend() is that the auto-suspend setting is a bool, > rather then a counter, so if a udev-rule or the user manually through e.g. : > > echo auto > /sys/bus/usb/devices/1-10/power/control > > Has enabled autosuspend then we would be disabling it, which is undesirable. > > Most USB drivers which have some way of enabling autosuspend by-default > (IOW which call usb_enable_autosuspend()) simply enable it at the end > of a successful probe and leave it as is on remove. > > Also keep in mind that remove normally runs on unplug of the device, in > which case it does not matter as the device is going away. > > If a user wants to disable autosuspend after loading the btusb module, > the correct way to do this is by simply running e.g. : > > echo on > /sys/bus/usb/devices/1-10/power/control > > Rather then rmmod-ing and insmod-ing the module with a different module-param value. then lets remove the module parameter from btusb.ko. Regards Marcel