From patchwork Thu Jun 11 01:53:53 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Abhishek Pandit-Subedi X-Patchwork-Id: 11599099 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 829C060D for ; Thu, 11 Jun 2020 01:54:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 69C712072F for ; Thu, 11 Jun 2020 01:54:08 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="a7jVBd3h" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726527AbgFKByF (ORCPT ); Wed, 10 Jun 2020 21:54:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56440 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726508AbgFKByE (ORCPT ); Wed, 10 Jun 2020 21:54:04 -0400 Received: from mail-pj1-x1042.google.com (mail-pj1-x1042.google.com [IPv6:2607:f8b0:4864:20::1042]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 94003C08C5C4 for ; Wed, 10 Jun 2020 18:54:04 -0700 (PDT) Received: by mail-pj1-x1042.google.com with SMTP id i12so1592496pju.3 for ; Wed, 10 Jun 2020 18:54:04 -0700 (PDT) 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=YeNSbkNZdz3UbDAq71dC4QETLSzCwObNDb/ZTU7KYpw=; b=a7jVBd3hCZ19FEnc7qi+cVMxFYFf1JeFjV78BrHVBioQuynMLoW65YnsQ2L8URbTCh dzN1oF+HlLtzojDsVmi2NIlE6YNxhzUgWX5r6LHEeGAeYXZ9Fjl1NJ6bgRowMNa1TQHy 1mcQupHAKBJCcpt1tDvQDfTJSWKVhR3zIhgxQ= 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=YeNSbkNZdz3UbDAq71dC4QETLSzCwObNDb/ZTU7KYpw=; b=F2k+pSLVDKGwg+TQXdfYQVSPZFzRUobTKX1PazJf0axvfm5hkIa8pVR2nNuNozqi4R xqGvbiN820DRPk4sfXCB5D1tw6Wz0Y3aaxwXGp9MV3ICInzVWTd5JOwR7mDUP+Ydfz/9 7kzIfhNFFxX5T3NVHyhCJjZo8hepcA9ROHTnJoRh4wjWSIX9vUEPuxLZwpdhPbliMNiF Vm8onihll52j3YZf4D0j4ZJOQ8MsG81pn7Zo4bwM+NkupjLb8RLDW6haJJ5kSehZdhCg eMotaLmZ8OX4g1793QZK5zyblowa8QMzBh7FxcCp4sjRCK32SSzu6S2VnUYZ68lRUEmu iFaA== X-Gm-Message-State: AOAM530y9XdQEsEb1VvA2gD4Pj4MsZhcWFhA2gu2NW7Nb20ncxfEELGd wkkbmAm1BK1i05rxYk9WOqZ614Fx9aE= X-Google-Smtp-Source: ABdhPJyQ0PcHB0iCZQspTboInbpc7xgj3WxD4rgaVgP/Trqg3JM+eHRga3w2hzppB+O7T33cf1Z46g== X-Received: by 2002:a17:902:a515:: with SMTP id s21mr5315672plq.334.1591840444165; Wed, 10 Jun 2020 18:54:04 -0700 (PDT) Received: from apsdesk.mtv.corp.google.com ([2620:15c:202:1:e09a:8d06:a338:aafb]) by smtp.gmail.com with ESMTPSA id b191sm998661pga.13.2020.06.10.18.54.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Jun 2020 18:54:03 -0700 (PDT) From: Abhishek Pandit-Subedi To: marcel@holtman.org, linux-bluetooth@vger.kernel.org Cc: alainm@chromium.org, chromeos-bluetooth-upstreaming@chromium.org, mka@chromium.org, dianders@chromium.org, linux-pm@vger.kernel.org, Abhishek Pandit-Subedi , Johan Hedberg , Marcel Holtmann , linux-kernel@vger.kernel.org Subject: [PATCH 1/3] Bluetooth: btmrvl_sdio: Set parent dev to hdev Date: Wed, 10 Jun 2020 18:53:53 -0700 Message-Id: <20200610185214.1.I01cfe07344286bc26109a3eba1f5582d307309ee@changeid> X-Mailer: git-send-email 2.27.0.278.ge193c7cf3a9-goog In-Reply-To: <20200611015355.186666-1-abhishekpandit@chromium.org> References: <20200611015355.186666-1-abhishekpandit@chromium.org> MIME-Version: 1.0 Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org Set the correct parent dev when registering hdev. This allows userspace tools to find the parent device (for example, to set the power/wakeup property). Before this change, the path was /sys/devices/virtual/bluetooth/hci0 and after this change, it looks more like: /sys/bus/mmc/devices/mmc1:0001/mmc1:0001:2/bluetooth/hci0 Signed-off-by: Abhishek Pandit-Subedi Reviewed-by: Douglas Anderson --- drivers/bluetooth/btmrvl_main.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/bluetooth/btmrvl_main.c b/drivers/bluetooth/btmrvl_main.c index 708ad21683eb31..47e450903af423 100644 --- a/drivers/bluetooth/btmrvl_main.c +++ b/drivers/bluetooth/btmrvl_main.c @@ -669,6 +669,7 @@ static int btmrvl_service_main_thread(void *data) int btmrvl_register_hdev(struct btmrvl_private *priv) { struct hci_dev *hdev = NULL; + struct btmrvl_sdio_card *card = priv->btmrvl_dev.card; int ret; hdev = hci_alloc_dev(); @@ -687,6 +688,7 @@ int btmrvl_register_hdev(struct btmrvl_private *priv) hdev->send = btmrvl_send_frame; hdev->setup = btmrvl_setup; hdev->set_bdaddr = btmrvl_set_bdaddr; + SET_HCIDEV_DEV(hdev, &card->func->dev); hdev->dev_type = priv->btmrvl_dev.dev_type; From patchwork Thu Jun 11 01:53:54 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Abhishek Pandit-Subedi X-Patchwork-Id: 11599107 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 83DBA60D for ; Thu, 11 Jun 2020 01:54:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6BE432072F for ; Thu, 11 Jun 2020 01:54:19 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="bI0QHc97" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726569AbgFKByN (ORCPT ); Wed, 10 Jun 2020 21:54:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56438 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726434AbgFKByH (ORCPT ); Wed, 10 Jun 2020 21:54:07 -0400 Received: from mail-pl1-x644.google.com (mail-pl1-x644.google.com [IPv6:2607:f8b0:4864:20::644]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9FD13C08C5C2 for ; Wed, 10 Jun 2020 18:54:05 -0700 (PDT) Received: by mail-pl1-x644.google.com with SMTP id k1so1598697pls.2 for ; Wed, 10 Jun 2020 18:54:05 -0700 (PDT) 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=68tOX7LFGwg3KdrWFaND58PhUb0yFjG30aqSPFP4qOo=; b=bI0QHc97vrE2ixZB3Ft5YFX2q3YGOLN8XZOWaIdcXk6oSwQhBoTngxIbHYA/p5H2eF qKJkFpEX566vocBObSrMWXEaJzhz2aKnfSqWJuOBpJn36aATpUouuOcI/APl14505Bb1 mPhuGpAqDeS9MhAu1xh1uMBniCzK4iZQ2HZSI= 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=68tOX7LFGwg3KdrWFaND58PhUb0yFjG30aqSPFP4qOo=; b=P6y3pbMTCgCYlb2JMLK0wjfLy+JOsNCIEwMnoauAU/Eql/kn+VB4cyvnRekVoIn2Kc WrkA43nJ+RGjaUf0tvV7p8eYAMBaZFK73fnH/wodo1ysODnACU9kV6tEnSgVaCdJ7sia rJGmFsru03ExL3S2Qy1uSd34LR5rEUFLevrI+fDAr2yXRQr0eBHSu6u5zQ05K8JqYxjD CZA4E087/GlQhv6PHwg5sXjNd9Bae9oubzYrsAOXPpc9b9oat6JY2AVFekL1WXEEu4t+ BIP0A6R4/wItobl2b1kqczcab3N0teWegclB/fjYtCEtSTwLbZwjL260xpyxurAaTqAR jCZg== X-Gm-Message-State: AOAM530eP30fl1GJK2EtHlHwaePL60X4LexzTdzIzzQ2g7UVo10xQ8T+ 3A6ZYsUzzjQJrtyHptE8ZNIWPw== X-Google-Smtp-Source: ABdhPJyB39hYptqE3xQPM4crTPBVQQmD7IFP/wMWPf+cpsmhSEX6xrwYWTCiONcgocktbarjbC642Q== X-Received: by 2002:a17:90a:898a:: with SMTP id v10mr5470622pjn.95.1591840445210; Wed, 10 Jun 2020 18:54:05 -0700 (PDT) Received: from apsdesk.mtv.corp.google.com ([2620:15c:202:1:e09a:8d06:a338:aafb]) by smtp.gmail.com with ESMTPSA id b191sm998661pga.13.2020.06.10.18.54.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Jun 2020 18:54:04 -0700 (PDT) From: Abhishek Pandit-Subedi To: marcel@holtman.org, linux-bluetooth@vger.kernel.org Cc: alainm@chromium.org, chromeos-bluetooth-upstreaming@chromium.org, mka@chromium.org, dianders@chromium.org, linux-pm@vger.kernel.org, Abhishek Pandit-Subedi , Johan Hedberg , Marcel Holtmann , linux-kernel@vger.kernel.org Subject: [PATCH 2/3] Bluetooth: btmrvl_sdio: Implement prevent_wake Date: Wed, 10 Jun 2020 18:53:54 -0700 Message-Id: <20200610185214.2.I317eb69189c90ed26ba88e996f7df59ee62c2495@changeid> X-Mailer: git-send-email 2.27.0.278.ge193c7cf3a9-goog In-Reply-To: <20200611015355.186666-1-abhishekpandit@chromium.org> References: <20200611015355.186666-1-abhishekpandit@chromium.org> MIME-Version: 1.0 Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org Use the parent device's power/wakeup to control whether we support remote wake. If remote wakeup is disabled, Bluetooth will not enable scanning for incoming connections. Signed-off-by: Abhishek Pandit-Subedi Reviewed-by: Douglas Anderson --- drivers/bluetooth/btmrvl_main.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/drivers/bluetooth/btmrvl_main.c b/drivers/bluetooth/btmrvl_main.c index 47e450903af423..8b9d78ce6bb29e 100644 --- a/drivers/bluetooth/btmrvl_main.c +++ b/drivers/bluetooth/btmrvl_main.c @@ -587,6 +587,14 @@ static int btmrvl_set_bdaddr(struct hci_dev *hdev, const bdaddr_t *bdaddr) return 0; } +static bool btmrvl_prevent_wake(struct hci_dev *hdev) +{ + struct btmrvl_private *priv = hci_get_drvdata(hdev); + struct btmrvl_sdio_card *card = priv->btmrvl_dev.card; + + return !device_may_wakeup(&card->func->dev); +} + /* * This function handles the event generated by firmware, rx data * received from firmware, and tx data sent from kernel. @@ -688,6 +696,7 @@ int btmrvl_register_hdev(struct btmrvl_private *priv) hdev->send = btmrvl_send_frame; hdev->setup = btmrvl_setup; hdev->set_bdaddr = btmrvl_set_bdaddr; + hdev->prevent_wake = btmrvl_prevent_wake; SET_HCIDEV_DEV(hdev, &card->func->dev); hdev->dev_type = priv->btmrvl_dev.dev_type; From patchwork Thu Jun 11 01:53:55 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Abhishek Pandit-Subedi X-Patchwork-Id: 11599105 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 12AB2138C for ; Thu, 11 Jun 2020 01:54:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id EC3242074B for ; Thu, 11 Jun 2020 01:54:13 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="byQoXdL9" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726316AbgFKByN (ORCPT ); Wed, 10 Jun 2020 21:54:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56452 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726556AbgFKByH (ORCPT ); Wed, 10 Jun 2020 21:54:07 -0400 Received: from mail-pj1-x1044.google.com (mail-pj1-x1044.google.com [IPv6:2607:f8b0:4864:20::1044]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A9AF9C08C5C6 for ; Wed, 10 Jun 2020 18:54:06 -0700 (PDT) Received: by mail-pj1-x1044.google.com with SMTP id q24so1704178pjd.1 for ; Wed, 10 Jun 2020 18:54:06 -0700 (PDT) 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=1X3ZX/iOwR/Uqfzsx2X/9AVb+bv3TKUHZzyCIU6EnHM=; b=byQoXdL9yUHiIdagQ/QkxkdVIIOdOM55WxCDdNr3/Xu+1inMXbhoEVAhu38ZZyoYSt mrhebQIUmr+EWcM577PZstHgA0MKAo9Yho38axOk/AAPQbtzUYm6PUCvsSqinCrEQUgx LEdJwoj1zqLe6bjhKXQ9Q8BCIGOutpDUq7apU= 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=1X3ZX/iOwR/Uqfzsx2X/9AVb+bv3TKUHZzyCIU6EnHM=; b=aPCElUmpS8AhwyP+A/oQot702J5XgdH17CG3bvUWwhwsyz8jI95tamp+gPeuUjzc6b am8+5VVC6LJiBCPnuSgHVXfy4YVZJ1OzxX+SQ6Eu5mjaF+cxE+cD+bZR4bHhY/+w4RQC Bxh7fs52Y0ALp0J+0d4hdvqbTaXUnr+NjSCpg47OKLToyUpoXAtKKXLWdn3BZUWjsY/Y SmdzFMJlwaUk2ZLJU8M1QkbXiuKy2qtIfkN36bOsOvRiYOCJFTJMad367YxpMKeC9+gu XH5tnFIIDBE2bCUbTI2jM0kq8GY0Jfc5PXWFO4JxVRwnADMIFeZXyAwUtTmYnO/ti0Xx uFOA== X-Gm-Message-State: AOAM532UayTuBnzVEZk/4boKkvi4twf9DdUQsvGFkjZdO/6PVqCOgije FSeAJyEgVaoQTtqgpW8GQyufqg== X-Google-Smtp-Source: ABdhPJxww6szgbZ7bos55brDGgfFhu9RmKbp4hX7/6AFdIVAZUjqS8/AG1a9V5KiAsusG3waIK1W3A== X-Received: by 2002:a17:90a:f3d6:: with SMTP id ha22mr5625289pjb.193.1591840446227; Wed, 10 Jun 2020 18:54:06 -0700 (PDT) Received: from apsdesk.mtv.corp.google.com ([2620:15c:202:1:e09a:8d06:a338:aafb]) by smtp.gmail.com with ESMTPSA id b191sm998661pga.13.2020.06.10.18.54.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Jun 2020 18:54:05 -0700 (PDT) From: Abhishek Pandit-Subedi To: marcel@holtman.org, linux-bluetooth@vger.kernel.org Cc: alainm@chromium.org, chromeos-bluetooth-upstreaming@chromium.org, mka@chromium.org, dianders@chromium.org, linux-pm@vger.kernel.org, Abhishek Pandit-Subedi , Johan Hedberg , Marcel Holtmann , linux-kernel@vger.kernel.org Subject: [PATCH 3/3] Bluetooth: btmrvl_sdio: Refactor irq wakeup Date: Wed, 10 Jun 2020 18:53:55 -0700 Message-Id: <20200610185214.3.If7946e7127c13a422d8c41d10dc8e6fe71396c8c@changeid> X-Mailer: git-send-email 2.27.0.278.ge193c7cf3a9-goog In-Reply-To: <20200611015355.186666-1-abhishekpandit@chromium.org> References: <20200611015355.186666-1-abhishekpandit@chromium.org> MIME-Version: 1.0 Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org Use device_init_wakeup to allow the Bluetooth dev to wake the system from suspend. Currently, the device can wake the system but no power/wakeup entry is created in sysfs to allow userspace to disable wakeup. Signed-off-by: Abhishek Pandit-Subedi Reviewed-by: Douglas Anderson --- drivers/bluetooth/btmrvl_sdio.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/drivers/bluetooth/btmrvl_sdio.c b/drivers/bluetooth/btmrvl_sdio.c index 4c7978cb1786fc..cfb9f9db44a0d9 100644 --- a/drivers/bluetooth/btmrvl_sdio.c +++ b/drivers/bluetooth/btmrvl_sdio.c @@ -111,6 +111,9 @@ static int btmrvl_sdio_probe_of(struct device *dev, "Failed to request irq_bt %d (%d)\n", cfg->irq_bt, ret); } + + /* Configure wakeup (enabled by default) */ + device_init_wakeup(dev, true); disable_irq(cfg->irq_bt); } } @@ -1654,6 +1657,7 @@ static void btmrvl_sdio_remove(struct sdio_func *func) MODULE_SHUTDOWN_REQ); btmrvl_sdio_disable_host_int(card); } + BT_DBG("unregister dev"); card->priv->surprise_removed = true; btmrvl_sdio_unregister_dev(card); @@ -1690,7 +1694,8 @@ static int btmrvl_sdio_suspend(struct device *dev) } /* Enable platform specific wakeup interrupt */ - if (card->plt_wake_cfg && card->plt_wake_cfg->irq_bt >= 0) { + if (card->plt_wake_cfg && card->plt_wake_cfg->irq_bt >= 0 && + device_may_wakeup(dev)) { card->plt_wake_cfg->wake_by_bt = false; enable_irq(card->plt_wake_cfg->irq_bt); enable_irq_wake(card->plt_wake_cfg->irq_bt); @@ -1707,7 +1712,8 @@ static int btmrvl_sdio_suspend(struct device *dev) BT_ERR("HS not activated, suspend failed!"); /* Disable platform specific wakeup interrupt */ if (card->plt_wake_cfg && - card->plt_wake_cfg->irq_bt >= 0) { + card->plt_wake_cfg->irq_bt >= 0 && + device_may_wakeup(dev)) { disable_irq_wake(card->plt_wake_cfg->irq_bt); disable_irq(card->plt_wake_cfg->irq_bt); } @@ -1767,7 +1773,8 @@ static int btmrvl_sdio_resume(struct device *dev) hci_resume_dev(hcidev); /* Disable platform specific wakeup interrupt */ - if (card->plt_wake_cfg && card->plt_wake_cfg->irq_bt >= 0) { + if (card->plt_wake_cfg && card->plt_wake_cfg->irq_bt >= 0 && + device_may_wakeup(dev)) { disable_irq_wake(card->plt_wake_cfg->irq_bt); disable_irq(card->plt_wake_cfg->irq_bt); if (card->plt_wake_cfg->wake_by_bt)