Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp34706pxb; Wed, 18 Nov 2020 15:45:50 -0800 (PST) X-Google-Smtp-Source: ABdhPJz6uvr3qAyYleID3uohnED6Fdaty4WwAc1f3yFuz1jOIptEVN1T3trLeN2tnHJwsVaBGSYq X-Received: by 2002:aa7:ce8c:: with SMTP id y12mr28973517edv.185.1605743149933; Wed, 18 Nov 2020 15:45:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605743149; cv=none; d=google.com; s=arc-20160816; b=jJQQIaoMKUUhjE0g9zWzwIL9qgGSYflXDo03FZCQq4xn2nRiVcAEHAEZ/8m6xj59mR nypkP7gE2e6N9Ync1ZH8t7DJXP4u07l+7yDA3D0XH1RgEpEYMNf0GbCjJyl0IqPIJuCW GAe8WK0bcYiwEUgs683B1Y38b08kGlbjXGXsVWr4M4oFjYF0so+Wkv3uj6uryLTHepLs +Okv849D4x0WEDlOOlzn8fZRvZBrOFobavLvd9ef0fNgolWgWMdJq/T6NUfs5VNLBlKf B6BX4EzcDxr2QNfR1KlSN+Ouy7LbYSy/YnMFZTa6XZkP8ddlXghvHHwj6eCHjb7jnyqO QQqw== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=iTB3bo1UF4JJAzKkMT7p3MoDedREDQBRrj3yyH4Dl9Y=; b=LapU5ajsNVlQZAdpiw7JWFnQbmgdvd6S5Elxo+Z+LwCKS+2AeSguapnYKP5nQ9CMY4 zI8ueqdvry0icBCzLgtWEHKSyIKkkaHmC4Pqkgqdsfd5DOaUrs4VwAKhia4bVWl+OBEz H8/rEfZlbErWmPzqPK29MSWKYqqBmeIVI8auHvNHJs/tN410EaBwgu8hS2Aj41BZH5nx y1hB35PVEvZmUPYuxguo7zsEVsEB2SG2naNwooC3XlWejcOxQife1Q0FB8aXEFgqNtiZ 5kX+S+ptup/qgip3cCxZDhIQvinGXH9JFIcjhi25QDj8Cft29qKdCffR9wCxU4IYkLFf Z9Fg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=WYix7Y11; 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 p14si13339579edy.555.2020.11.18.15.45.24; Wed, 18 Nov 2020 15:45:49 -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=WYix7Y11; 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 S1727338AbgKRXoK (ORCPT + 99 others); Wed, 18 Nov 2020 18:44:10 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40526 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727363AbgKRXoI (ORCPT ); Wed, 18 Nov 2020 18:44:08 -0500 Received: from mail-pl1-x642.google.com (mail-pl1-x642.google.com [IPv6:2607:f8b0:4864:20::642]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B670AC0613D4 for ; Wed, 18 Nov 2020 15:44:08 -0800 (PST) Received: by mail-pl1-x642.google.com with SMTP id j5so1905414plk.7 for ; Wed, 18 Nov 2020 15:44:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=iTB3bo1UF4JJAzKkMT7p3MoDedREDQBRrj3yyH4Dl9Y=; b=WYix7Y11RrVt/dV88uG6yY7owq0gesu0k3Uq1qb9Jo40C/n097r0FsHMlWEZqBrVSI ML5yXL/+0ZlmVhUqg0d7l3feJCosQNnAHwuZZOHbxACwxin1AUgod0sJcLMh4ULrPD/3 nos0h6RJi90luya6+9dAc3gfYPJU/Lau8xW2g= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=iTB3bo1UF4JJAzKkMT7p3MoDedREDQBRrj3yyH4Dl9Y=; b=cA1+36jO8bI9U9hUOFU0Bq9no5hWysfjitr3/vbup2fCxufeS9jgskFFVf21R4KEJs W/CwgbHGtv9OgozOfrevo9YoQxQgMMmOjyDJ5TK7rhlptQ64Hp1yXcU6lx9IWvEZfm7Y AwKME3GCBUQspeNAwvcYqt0HJzs1zWyLLWR9UIXxXCFIzVjfbpfZyEs45mq1AT5B4x2v 1pHCfFTMn1JS8gQjKCX4GrX1LwZsyXjw/GYOH7P1a3dn3rkP81Uywue6mRG1ztcVJ615 KHuJvEgt/CijqTCkk99cwaM7u8xeeFHgIHlbSYL3//grOLYlm/qFtqYt1XDoyvC4TPxy rPyw== X-Gm-Message-State: AOAM533/940kO3Rc/NPhtKdBRlGOScb6UN6nXQWtPUM8JJsYtYaghsJi pZeYU/ncZyqE/rgS9Linnwbu5Q== X-Received: by 2002:a17:902:9042:b029:d6:fe3f:6688 with SMTP id w2-20020a1709029042b02900d6fe3f6688mr6388780plz.75.1605743048346; Wed, 18 Nov 2020 15:44:08 -0800 (PST) Received: from apsdesk.mtv.corp.google.com ([2620:15c:202:1:7220:84ff:fe09:2b94]) by smtp.gmail.com with ESMTPSA id f6sm21437435pgi.70.2020.11.18.15.44.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Nov 2020 15:44:07 -0800 (PST) From: Abhishek Pandit-Subedi To: marcel@holtmann.org, linux-bluetooth@vger.kernel.org Cc: chromeos-bluetooth-upstreaming@chromium.org, mcchou@chromium.org, danielwinkler@chromium.org, Abhishek Pandit-Subedi , Johan Hedberg , linux-kernel@vger.kernel.org Subject: [PATCH 3/3] Bluetooth: btmrvl_sdio: Power down when suspending Date: Wed, 18 Nov 2020 15:43:52 -0800 Message-Id: <20201118154349.3.If6a8ea0def7ff7a1f6a8ba349b9c840201b1d1f0@changeid> X-Mailer: git-send-email 2.29.2.299.gdc1121823c-goog In-Reply-To: <20201118234352.2138694-1-abhishekpandit@chromium.org> References: <20201118234352.2138694-1-abhishekpandit@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org After seeing a large number of suspend failures due to -EBUSY, the most common cause for failure seems to be the log snippet below: [ 4764.773873] Bluetooth: hci_cmd_timeout() hci0 command 0x0c14 tx timeout [ 4767.777897] Bluetooth: btmrvl_enable_hs() Host sleep enable command failed [ 4767.777920] Bluetooth: btmrvl_sdio_suspend() HS not actived, suspend failed! [ 4767.777946] dpm_run_callback(): pm_generic_suspend+0x0/0x48 returns -16 [ 4767.777963] call mmc2:0001:2+ returned -16 after 4882288 usecs Since the sleep command is timing out, this points to the firmware as the most likely source of the problem and we don't have a way to address the fix there (this is an old controller). So, to mitigate this issue, we can simply power down the Bluetooth controller when entering suspend and power it back up when exiting suspend. We control setting this quirk via a module parameter, power_down_suspend (which defaults to false). Signed-off-by: Abhishek Pandit-Subedi --- drivers/bluetooth/btmrvl_sdio.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/drivers/bluetooth/btmrvl_sdio.c b/drivers/bluetooth/btmrvl_sdio.c index 33d58b30c5acfc..e2e4917b4fe589 100644 --- a/drivers/bluetooth/btmrvl_sdio.c +++ b/drivers/bluetooth/btmrvl_sdio.c @@ -35,6 +35,12 @@ #define VERSION "1.0" +/* Add module param to control whether the controller is powered down during + * suspend. Default is False. + */ +static bool power_down_suspend; +module_param(power_down_suspend, bool, 0644); + static struct memory_type_mapping mem_type_mapping_tbl[] = { {"ITCM", NULL, 0, 0xF0}, {"DTCM", NULL, 0, 0xF1}, @@ -1587,6 +1593,10 @@ static int btmrvl_sdio_probe(struct sdio_func *func, goto disable_host_int; } + if (power_down_suspend) + set_bit(HCI_QUIRK_POWER_DOWN_SYSTEM_SUSPEND, + &priv->btmrvl_dev.hcidev->quirks); + return 0; disable_host_int: -- 2.29.2.299.gdc1121823c-goog