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: 11599097 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 648E7138C 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 4B5FE2074B 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 S1726533AbgFKByF (ORCPT ); Wed, 10 Jun 2020 21:54:05 -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 S1726268AbgFKByE (ORCPT ); Wed, 10 Jun 2020 21:54:04 -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 937BDC08C5C3 for ; Wed, 10 Jun 2020 18:54:04 -0700 (PDT) Received: by mail-pl1-x644.google.com with SMTP id bg4so1705967plb.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=ljeg8M5rDOamyjNrlaBlWEXRFXK6YoGndey75P1ne9JadyceFSn7CaMFGq9CmnVQF0 tWcaP0HIH5yvj560xpNKI7ydDNT12j2NTmz8uQi3vcLE/UrJ13hGGBJ5ucLikja2CDuw AOsPoXwJYVx55PNbZk3qEXKom/t6W3e8Qgk5SfboI5UtMEvR3l0yCj5Keebt0iqbXSm7 Rs4K7qBBs5gFBuFQoSerWMFBX8zgOKo6XbpYxNpTRw63oFAsJuV2gEMbwyqGAfk5TTVn CP6SWqcjVWuz3569i+z1t05wFk11qPwXF/t5s42NiOXMY9+3JPdqGclZ0S3Vc9BJQhMR ommg== X-Gm-Message-State: AOAM532ibJimSTqIc37YLrp34z93HMQCwI9vfWx3qow083tUSawt+M+W hRcS8d8zjeCV5ElWPVqHCGKfEA== 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-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@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: 11599103 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 70761138C for ; Thu, 11 Jun 2020 01:54:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 56CB32074B for ; Thu, 11 Jun 2020 01:54:12 +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 S1726510AbgFKByJ (ORCPT ); Wed, 10 Jun 2020 21:54:09 -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 S1726508AbgFKByG (ORCPT ); Wed, 10 Jun 2020 21:54:06 -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 A0CCEC08C5C3 for ; Wed, 10 Jun 2020 18:54:05 -0700 (PDT) Received: by mail-pl1-x644.google.com with SMTP id n9so1710552plk.1 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=q86nMQ3CejiR1MqQ7uzsb5OCrE32IrfseFAg1HMbvsH0c/gNVUmPReVWPl+RaIqUGS M8tYEbgmDdcR9WviBTXwPYMFokvMWzbfR71+jxFwwcwMEPo93VodA6kopJEC+WJ/vlAk EQfua63y/yRYsHWrlaNirQYxgm8G9D0ikFrDk79XRCg/8iTXahLWDJD5mCZUaI/6MS60 ugZWc1sPI1zMA2yTfLK0desiieY3x5hnRHSrRuFWnrhzJi7YQVdnFeFgA+rIjiIrb9kn bXAZLYQ2bHJoiguZ2rhiomE1q1AFmbpf7vz4UlPrk80XcdlK7FrGu5kA+hhjXLlDEqrb U6/A== X-Gm-Message-State: AOAM530bdC0Krv/PKim4Cbl7F4nJ+MVrQSgO3xlm+gTl7kfcE8ijKoGL lrUNAE0x2Dz/UhPjiJ6SgFqvyw== 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-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@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: 11599109 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 BA33960D for ; Thu, 11 Jun 2020 01:54:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 992252072F for ; Thu, 11 Jun 2020 01:54:20 +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 S1726561AbgFKByM (ORCPT ); Wed, 10 Jun 2020 21:54:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56450 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726552AbgFKByH (ORCPT ); Wed, 10 Jun 2020 21:54:07 -0400 Received: from mail-pj1-x1043.google.com (mail-pj1-x1043.google.com [IPv6:2607:f8b0:4864:20::1043]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A92DBC08C5C5 for ; Wed, 10 Jun 2020 18:54:06 -0700 (PDT) Received: by mail-pj1-x1043.google.com with SMTP id m2so1701359pjv.2 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=GyptkN60knRZ837ltZdiS1AfxJBtskjxBLGY9TzUFpzxzW0K4fqnaQH1knMfIk/iao 4BouIFi8j+hyqj58EYEOF5pEsP7trBzwADIDGMaUckoo8ALvFTpnj5w5v9nv3HBoMUYw gzsYyoRtcQRC1h8xBYsZ05Pjg8KdTxgo7oj2/4OsWU0L6YnQ9iP+1Vwu2B86Q+tzl1IC YqmVXULvhL+ecpbHno4PfbEgkEfip2jcpDSCLDftPS0y2MlZyJj0CVhoUJizoSqjf0q9 xjk0rvRVZXQsNgYBrXGeFqsfpJfZLVNSJ/maA3bdsplHQpIeCpEx7gpR6nzFgdJO3UNu dfBA== X-Gm-Message-State: AOAM531zDvniXT7d5ReUdOS3HjJL7gkyGTIxu2t1Z3+4NKryIL+UDUWE ZoLmOX5JAJSurvBF2CWFYPbcrQ== 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-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@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)