Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp7580856pxb; Thu, 18 Feb 2021 14:08:45 -0800 (PST) X-Google-Smtp-Source: ABdhPJxfedSjpVCw8C61cB/LkC5R2g5NyLOJ5001A+zKxCLKHsluX6nX/sxul+96+0UJJS4BqZUA X-Received: by 2002:a17:906:8519:: with SMTP id i25mr6159251ejx.106.1613686125082; Thu, 18 Feb 2021 14:08:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1613686125; cv=none; d=google.com; s=arc-20160816; b=WZ671ZezQykYj2sTQfGabYj8gtGE4ABq9BhY7jt5RnjujT4VB4f1De+D2m6xk2aQSO lZLLpiDoWMIp3gdMIB4T+8el2Go0Bu2KY7WM5ZdTjcXJbjBrWqlasNgn0NcpQjAdHvEq IAsWqXbtp07AH4Jbt1At1MEevZyD7aSGqW3P+QZyTse0TqNUWmHXs20/CpxFzw+RkQHX yUc5cYMb3m5TT8elZyryEdqRt/pBzfC4YuP/Yk6qcBzf7nk3YKydlUcmNhyMgZRjA3/y nU30sBeSAnZc2WB6lXu9GpLAjkyuC4slOWOTurVQzxZZwySUOllHD4FmDFlhqFgmg10S kDSQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:dkim-signature; bh=6+U6B/xWVZLn93Gyql2CCv6bDVOtEzXPJ1zRqxRggkk=; b=mxexoLNfSXJCzgpuSZrdyqh/6xH3LDYi8RbU1jirbS4Fh9/IFHKSJad4yCyQXZ/5YM wXs1XTpqutm8tr/JINIz7jQ4ZmWUjMNKAFemYu4+dK/691YQDVPP3/67FDHJ0nFXn3Zk z7Iw3teiZlmbr0e3511iK7l5Dmp0f1piyVf97ICH6FsWUCkWKCvVKawMECa6uGDwkTJQ LFviJs4iXY4mN0R24xSw0a4qV3BuQSSX/IH/WbqubR+D1ZyoQF7htyLwObENm8ZUefGV yLXORuOqJ0sv77gbkFoLOq4rEGLKhP383MSqOLQIELVHyx3GW8RgXtr4QLB9i0sDbJeW Z44Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=AHRQPzEK; 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 j4si4443425ejm.600.2021.02.18.14.07.57; Thu, 18 Feb 2021 14:08:45 -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=AHRQPzEK; 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 S229765AbhBRWGY (ORCPT + 99 others); Thu, 18 Feb 2021 17:06:24 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:60265 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229480AbhBRWGX (ORCPT ); Thu, 18 Feb 2021 17:06:23 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1613685896; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=6+U6B/xWVZLn93Gyql2CCv6bDVOtEzXPJ1zRqxRggkk=; b=AHRQPzEK5LivWRmaX8AARagihp/7F7UF+7Y48QtIQ4KELWSkyLA2jFrfX1vXbOVOz92hFU 0BGbXAGpEOlDhQDCQ+Zf/l9Lw9bKQFaHLSQ14Pxyeq27yYTluvNciSobVVZHnI1nNaNSza TK0lDkkb6TZtWWBoReznawXppFz13BQ= Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-286-UzDTji66MoKQQHmsxs0QzQ-1; Thu, 18 Feb 2021 17:04:54 -0500 X-MC-Unique: UzDTji66MoKQQHmsxs0QzQ-1 Received: by mail-wr1-f71.google.com with SMTP id w11so1559844wrp.6 for ; Thu, 18 Feb 2021 14:04:54 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=6+U6B/xWVZLn93Gyql2CCv6bDVOtEzXPJ1zRqxRggkk=; b=tAH5ow/4DU+QqejBtBRCCQjm89dEaBwGhIZVvOg0y5T3P+l6HGqx2Zi1z6FLvEBtsj +NwkuSkLUoPMdKHgJYlv7v7gfTbTVA+UzDI0zccqoroLqdscwb3kyCJik2tg6f22/tMU SIIKZ3HdaDgx+GwqkkTho5gYabxNF8Y9o8Kbkg3/JG52rXM98eo0KPp8pQQS8rx4jkgD Ky7BjJoSojm8uUEJoBoEGkFMkJxOImiCMAUG/uKrWcQhv70XGCeO4hnCi4jikDErRu1v WC0UKL5pGnlaSNhfS+reahYN5Axo5kkiDyl4PrKH3ma9T/LqtVt9606OTD7WRUanuAUu ed7w== X-Gm-Message-State: AOAM530FpKexxDkbdLmmkgN0eYmME8gjdwVYfwnZtchSSCsSiluLWocU eXExgQhdrnNZigZddPs8ErE6Upl8DImAaNG0O3N/bO2tBOhihLm10D5RFpnE/PWyF9ZQF47GEjU rhe/TETeq6D4MzviAi05L7yL4OmVxuCng9S8g0ox5XMW+Tqd9iH5S4snSR19QrxGANCh806oWBm fZvIGz X-Received: by 2002:aa7:c9c9:: with SMTP id i9mr5992684edt.160.1613685892195; Thu, 18 Feb 2021 14:04:52 -0800 (PST) X-Received: by 2002:aa7:c9c9:: with SMTP id i9mr5992659edt.160.1613685891943; Thu, 18 Feb 2021 14:04:51 -0800 (PST) Received: from x1.localdomain (2001-1c00-0c1e-bf00-1054-9d19-e0f0-8214.cable.dynamic.v6.ziggo.nl. [2001:1c00:c1e:bf00:1054:9d19:e0f0:8214]) by smtp.gmail.com with ESMTPSA id de33sm2923055ejc.37.2021.02.18.14.04.51 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 18 Feb 2021 14:04:51 -0800 (PST) Subject: Re: [PATCH 5.12 regression fix] Bluetooth: btusb: Revert Fix the autosuspend enable and disable To: Marcel Holtmann Cc: Hui Wang , Johan Hedberg , linux-bluetooth@vger.kernel.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> <6CE927B6-449A-472C-9196-AF98895AA5E1@holtmann.org> From: Hans de Goede Message-ID: <2bf12891-eeae-e55f-ab46-7434dffbad76@redhat.com> Date: Thu, 18 Feb 2021 23:04:50 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.7.0 MIME-Version: 1.0 In-Reply-To: <6CE927B6-449A-472C-9196-AF98895AA5E1@holtmann.org> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org Hi Marcel, On 2/18/21 9:01 PM, Marcel Holtmann wrote: > 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. The module parameter is useful to make sure runtime-suspend never gets enabled starting from boot onwards, either through the kernel cmdline or through modprobe.conf settings. Also the module parameter is used to implement CONFIG_BT_HCIBTUSB_AUTOSUSPEND Kconfig option which sets the default value for the module param; and most distros enable that option since it having autosuspend enabled is the right thing to do in almost all cases. Regards, Hans