From patchwork Thu May 31 09:40:38 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 137343 Delivered-To: patches@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp6373670lji; Thu, 31 May 2018 02:40:53 -0700 (PDT) X-Received: by 2002:a2e:21c6:: with SMTP id h67-v6mr4568846lji.132.1527759653128; Thu, 31 May 2018 02:40:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527759653; cv=none; d=google.com; s=arc-20160816; b=fjRlHYSlnSKNq+ieOqTItKBeHpTOr+UgaEtZ9shHdEiOVh331m2dMknK2eaiKDOSDK ZuxfOizee+5LhcYhlVOzXu75kst/C+gWQkaEFfrwfxyroQee19p6ecAFHPT8Tdjq991Z uusqyORI0veMQobdBL0iNIZBbb6YL3GsYYRCw72NQ5K84m+whZj0Z4xDegndmxl92bCT +B39TmAuB19DT8v9GbYJ+asp1UP+U1fv1BaLA4yJZL92bgw0Tl5JYf+7b4O0yjL2LsKI nWMc9JyTh+F9BBgElEGpN8wHhXbGfAOpecTGk9uybh0WVNTsoGD+dYzwkLVTed/pulgT v6pw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=W1SRBFn/gdnSVACY7EkMb9DeGS0PM23CHrziIOkLPl4=; b=Z/tHPo5U31rrQcHsQV/JYyqw0bm3fOch0QJ5XR6bkpbkdrG+NQdlhrLB3XzTHdVLlG OadBaeMekAZ12bP2A6oDR8ZZra24PT3FYzPD+i7Pu1eaNLVBtGMMzEDX0am7ZcAn936+ n+hpYcWksKb/N/lBwY4VFk7FtjIYSDtAFJh9Cy7Elp3J0cotp+QHc2NbEUtXGjcRUbef LqGxg9UyiPjWFhImVQd9SOj+2gBwPMryRmcmNQpDxTnqFeizI+SVTKI2QcPBTghDBeiY Ur2qS6SVx9x+wDc4/SvXHZsDd2fyAILtN1NcdvHA204Q0C++2UZIKQI6LcYnU0MyM1sS vc9A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Nj1R9dxm; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id d82-v6sor8514208lfl.22.2018.05.31.02.40.53 for (Google Transport Security); Thu, 31 May 2018 02:40:53 -0700 (PDT) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Nj1R9dxm; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=W1SRBFn/gdnSVACY7EkMb9DeGS0PM23CHrziIOkLPl4=; b=Nj1R9dxm9WmXpEV3WnL75V+hTk9epD0yMoQTXsMyLm9kuQrJkHBinQ+wXnCMy+bL1s 6wBvy8nVzChXQMVf6mGkMYLkl93lGpJujiY62twB67xcLqrORHVyFaSL01+vX631OLwp HUtN10LSdCsnqb9lCVfR4pw3es3U2UKiMDW9w= 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; bh=W1SRBFn/gdnSVACY7EkMb9DeGS0PM23CHrziIOkLPl4=; b=aXWOp/Se27WVzonMemT/Hrz/06+0I8cPlLHBKhg+hWJBBXEfDJL6x8Yx2W+71xGYBW 6hSqbQxjcqus3CqrkAe/lknrAxC7E01CJkaDKWvOlD/FbqMUAIUF1F0vemZ1mgjFWLZi +YAsEXEXOi0IijsHAugkWQrd0+55rEwr6sebhJq0yZFNYLG2KjdWgm3sHIE0fRY+UiXW wxbwTU4PaM9O5imv88agfZMqBJ50YkTpoDh6Q13XioKhXWSSxyyIB0RcAZf8bxYNy+2s WJZ9hMXgoZ9RjkQoHv/CcQyegAHAOC8xbeOhQHXp8ognPryy1lIJwaxonJv+21hw1uRt V4zw== X-Gm-Message-State: ALKqPwfkeAt4tswa3Vz9OPOcTe8u/F1yGaSvjCgPZGZ0rt8qpiwqQxts 5BKVq3wSxFjBUfO7BuSEu7E5MxKP X-Google-Smtp-Source: ADUXVKIohzSmXQRn0+jfwh0cXoPEFdixwSymX3VDpuFHGq5KfXOS8mknSIOLxsS9+SCv/8s+2aDSdA== X-Received: by 2002:a19:6915:: with SMTP id e21-v6mr3709245lfc.8.1527759652911; Thu, 31 May 2018 02:40:52 -0700 (PDT) Return-Path: Received: from localhost.localdomain (h-158-174-22-210.NA.cust.bahnhof.se. [158.174.22.210]) by smtp.gmail.com with ESMTPSA id y12-v6sm7496302lji.34.2018.05.31.02.40.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 31 May 2018 02:40:52 -0700 (PDT) From: Ulf Hansson To: linux-mmc@vger.kernel.org, Ulf Hansson , Kai-Heng Feng Cc: michal.pecio@gmail.com, Ritesh Raj Sarraf , Bauer Chen , Alan Stern Subject: [PATCH 1/4] mmc: core: Introduce MMC_CAP_SYNC_RUNTIME_PM Date: Thu, 31 May 2018 11:40:38 +0200 Message-Id: <20180531094041.27902-2-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180531094041.27902-1-ulf.hansson@linaro.org> References: <20180531094041.27902-1-ulf.hansson@linaro.org> To allow mmc host drivers to inform the mmc core about rather using pm_runtime_put_sync_suspend() instead of pm_runtime_put_autosuspend(), let's introduce MMC_CAP_SYNC_RUNTIME_PM. This is especially useful for those mmc host drivers that don't benefit from using the runtime PM autosuspend feature. Typically this is those that relies on parent devices to power the card via runtime PM, like some USB host drivers for example. Signed-off-by: Ulf Hansson --- drivers/mmc/core/core.c | 5 ++++- include/linux/mmc/host.h | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) -- 2.17.0 diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c index 281826d1fcca..fd366b3677b6 100644 --- a/drivers/mmc/core/core.c +++ b/drivers/mmc/core/core.c @@ -887,7 +887,10 @@ void mmc_release_host(struct mmc_host *host) spin_unlock_irqrestore(&host->lock, flags); wake_up(&host->wq); pm_runtime_mark_last_busy(mmc_dev(host)); - pm_runtime_put_autosuspend(mmc_dev(host)); + if (host->caps & MMC_CAP_SYNC_RUNTIME_PM) + pm_runtime_put_sync_suspend(mmc_dev(host)); + else + pm_runtime_put_autosuspend(mmc_dev(host)); } } EXPORT_SYMBOL(mmc_release_host); diff --git a/include/linux/mmc/host.h b/include/linux/mmc/host.h index 64300a48dcce..f029675b9a52 100644 --- a/include/linux/mmc/host.h +++ b/include/linux/mmc/host.h @@ -324,7 +324,7 @@ struct mmc_host { #define MMC_CAP_UHS (MMC_CAP_UHS_SDR12 | MMC_CAP_UHS_SDR25 | \ MMC_CAP_UHS_SDR50 | MMC_CAP_UHS_SDR104 | \ MMC_CAP_UHS_DDR50) -/* (1 << 21) is free for reuse */ +#define MMC_CAP_SYNC_RUNTIME_PM (1 << 21) /* Synced runtime PM suspends. */ #define MMC_CAP_DRIVER_TYPE_A (1 << 23) /* Host supports Driver Type A */ #define MMC_CAP_DRIVER_TYPE_C (1 << 24) /* Host supports Driver Type C */ #define MMC_CAP_DRIVER_TYPE_D (1 << 25) /* Host supports Driver Type D */ From patchwork Thu May 31 09:40:39 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 137344 Delivered-To: patches@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp6373703lji; Thu, 31 May 2018 02:40:54 -0700 (PDT) X-Received: by 2002:a2e:3503:: with SMTP id z3-v6mr4816691ljz.95.1527759654841; Thu, 31 May 2018 02:40:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527759654; cv=none; d=google.com; s=arc-20160816; b=eJVMB22k0oVZrLZmagQd+Nx3LyAdbK+RIPXZo5M7GOLVfdGnid2xoW7BFAVzxefVUp y7Z9yWAnDdkZOSs37ATAsmjsfBiHA8qRWwZvIOKIJ4HkgEWQX3YuGHFmfd2cuG/Rs5Xt mylyKTDq2qnNfBTCdzsP881MH8jt9NqMoH1h8qS307cbbNWnkQtG6BDW6uG2XQ/uI/k4 h+2L2isv+5t1pqaqrcN2gHhw9oI6jNFqphA0dVULLpNsFZV5pjAcBWoTls6/kUDK8u9h M/e9s6Ds3+UM0cLEW5kYjfxkIbCiMELUVYSrgSZff+VaPdETfLGpHXqKdhvx+UfuQ5Jb BbUQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=CBKeFwqAQWYhqKSnKc7kFvjDVkbadO7fnW1Kzv+8VQA=; b=FV1mKPTBVtOdAIPmQ3Iru1N9L9fm4c5oTZmn5A6HpOtbHND/Y+i3ZlgmDzrQgYFfl/ B+mEAfPlyR7QDMY2gIHAQY3WrgVK6HIrlDGEt9A8+bcj1khj+qzj9SxyxhA6t01mCAsT vX3FY/dzoD/c1Xi/CBo3a57ar3h+68dnljM+hMFTR4voPdNSsswlo3IWTlboxg0VY3KD 376oL/C9sqoOnWNr7DX/JcGEiTIHcVEMzy7Old8aG5Ye1UqdR0P6Um210k5A2PtE1SD/ TFVKNFpr8nUN3nVlyYajxqUcZVI3zP9Vcn5b3FERnSD+iaTLBW0B2Ng/dwbxapRBcVUC g39Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=LUnEOhzh; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id a26-v6sor4702165lfc.56.2018.05.31.02.40.54 for (Google Transport Security); Thu, 31 May 2018 02:40:54 -0700 (PDT) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=LUnEOhzh; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=CBKeFwqAQWYhqKSnKc7kFvjDVkbadO7fnW1Kzv+8VQA=; b=LUnEOhzh0dZxRzHuUnYoyP2KwsPoeGbeVeh9FTDBlvTzUmhCc/j9l3aP2rFg0kG8mv gEFkEIae6AgY/HOSNbaVDygxYDJB2Ophupa9TCOL7MVX0hmPIRqfO8IYw0SoCQaGWxi0 BdGiSMaZhfCHkv/yLi4Xif9cw0R3qfPqZl+hY= 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; bh=CBKeFwqAQWYhqKSnKc7kFvjDVkbadO7fnW1Kzv+8VQA=; b=j8lp2WgBimjx7EtJws81+21Anq+vm6JFuAIqBiN5ituZmNtVPm+0bfkCWlH4KHvoNS neUFMLE+QgGkupRy/jI4OQsnR0KKW8UwKMPVf+CqYpBWKU8bT5fSj9f7MJiMhOHZAaeI 4hLnXp/HWjn9LUxdb4k2KRClZ5ux/aAgIhytYWY0u5MIuFxnGzD/zzC4B6YW5jJn78E0 R2N7BsDfEDg2Kw96SfAlA6GK98B87mK8MZhvCRqN4Pga3frwjXIMZ7FNUJnwimC347If 5jL9LTRv4PkGIFb5AovCupVeZuEGx4mZvLeLuz1YUY7tOwDvuLAw0u7IaR1PG/eeH3FW tS4A== X-Gm-Message-State: ALKqPwdRj1z8+Jwu/WwauJukLekIJi7u9amQFRSw2SVlnwoCFcDQ2hgM rgeD4VtRrAl12d4tGXjXZSRY/yWF X-Google-Smtp-Source: ADUXVKJwZjaPxXz81KLCeiLWHmr9LVY/v8O12MFrp2ZuqsiaKITcatIgccnAnE9XDYVqXDFBUm3rOw== X-Received: by 2002:a19:b2c2:: with SMTP id t63-v6mr4060072lfk.27.1527759654582; Thu, 31 May 2018 02:40:54 -0700 (PDT) Return-Path: Received: from localhost.localdomain (h-158-174-22-210.NA.cust.bahnhof.se. [158.174.22.210]) by smtp.gmail.com with ESMTPSA id y12-v6sm7496302lji.34.2018.05.31.02.40.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 31 May 2018 02:40:53 -0700 (PDT) From: Ulf Hansson To: linux-mmc@vger.kernel.org, Ulf Hansson , Kai-Heng Feng Cc: michal.pecio@gmail.com, Ritesh Raj Sarraf , Bauer Chen , Alan Stern Subject: [PATCH 2/4] mmc: rtsx_usb_sdmmc: Don't runtime resume the device while changing led Date: Thu, 31 May 2018 11:40:39 +0200 Message-Id: <20180531094041.27902-3-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180531094041.27902-1-ulf.hansson@linaro.org> References: <20180531094041.27902-1-ulf.hansson@linaro.org> In case the card has been powered off, it seems silly to continue to allow the led to be updated. Instead let's forbid that, as it enables us to prevent runtime resuming the device and thus avoids wasting energy. Signed-off-by: Ulf Hansson --- drivers/mmc/host/rtsx_usb_sdmmc.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) -- 2.17.0 diff --git a/drivers/mmc/host/rtsx_usb_sdmmc.c b/drivers/mmc/host/rtsx_usb_sdmmc.c index 9a3ff22dd0fe..14b4a4e13fe6 100644 --- a/drivers/mmc/host/rtsx_usb_sdmmc.c +++ b/drivers/mmc/host/rtsx_usb_sdmmc.c @@ -1297,14 +1297,18 @@ static void rtsx_usb_update_led(struct work_struct *work) container_of(work, struct rtsx_usb_sdmmc, led_work); struct rtsx_ucr *ucr = host->ucr; - pm_runtime_get_sync(sdmmc_dev(host)); + pm_runtime_get_noresume(sdmmc_dev(host)); mutex_lock(&ucr->dev_mutex); + if (host->power_mode == MMC_POWER_OFF) + goto out; + if (host->led.brightness == LED_OFF) rtsx_usb_turn_off_led(ucr); else rtsx_usb_turn_on_led(ucr); +out: mutex_unlock(&ucr->dev_mutex); pm_runtime_put(sdmmc_dev(host)); } From patchwork Thu May 31 09:40:40 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 137345 Delivered-To: patches@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp6373730lji; Thu, 31 May 2018 02:40:56 -0700 (PDT) X-Received: by 2002:a19:e450:: with SMTP id b77-v6mr3992865lfh.76.1527759656113; Thu, 31 May 2018 02:40:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527759656; cv=none; d=google.com; s=arc-20160816; b=STlKmLgSBs7gvOqrFDnlXfQK0H+IQ1J8eMweQmDLD2WCQS72gJYAVyrIW4BNyEHDLH onjnVQ8KaVeBcIRqhikRsZn70Lbzl4jR/QTiQ+KTnell7NoV7zBjkWcBqG0BR5aZCTvW xV9DNZSOIHhFtc9zk+Cj7l8Mlh1TVuulVEf3zD4YMuoXvx6666lly+DK/86G+TTBdvFw llobkkoFNWchT23taU4p5f/rXmW9jqXZReHT8XAmR4b0qemnHBjvGxP+gp+mMk/39Sy/ nfe6khADmkC8ME/Cz3AJLr/ANQzHWOZgQF/1UtzoYfyFGqS1cbp1X9kfOMJEoJnAWYG7 764g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=1wDmHuu41H26My38+y7oN3y+/HOiv7qPFVsgkCWF1gQ=; b=z0uJKeAlCXDoIH+1dcn3aWwVBuitsB9JEfHOMeoJm+MzZ9Gvk65MChmd59Ioyg6bLz w6P5++EbgFNYp+1ZZQrerzp39vX/Pwd0qPiVm0wE+oTPtsdCI+sAyvE21/FEu9pcDG0e 0bdOvMrSggT6VRMIRIKlXn7iQjWrF1mLdUXV0ZVJxqSKQEFR079rLYusm8gszMwx5PRc i+HyIfZFAMr59SqdGTtXgkBSOUhmSJRecFnmkf+DNwAzibAE2Tiy9k6MZZpy8z7WVM5s vi5wlZ2igL8VB62EKYKvc4Hyd8cCgW24g0HrD9c2JLZF5tBtS3wUC/flUnzvaFqgrRzX jY2Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Kdh+UQkJ; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id p27-v6sor8740187ljb.48.2018.05.31.02.40.56 for (Google Transport Security); Thu, 31 May 2018 02:40:56 -0700 (PDT) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Kdh+UQkJ; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=1wDmHuu41H26My38+y7oN3y+/HOiv7qPFVsgkCWF1gQ=; b=Kdh+UQkJJM2AA1kVKrYy5gyEFPiEg3OWTYohUHJ0TUlDJPv4QikHU3ctfZTzi7jf72 MMt8rDnV3ptKy3h6JiAGZKD/KBXEFmoV7mAKYyhmaqjFtrP/70JbYShoi67OPVmPzSX5 EDtvAUWweJK67SdMM2xLF/yc0CzgFQVFjgB5U= 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; bh=1wDmHuu41H26My38+y7oN3y+/HOiv7qPFVsgkCWF1gQ=; b=mmmz6ydF6JkFyaRzP4oZQ8tpZje0yLK4AYe0z8171wGSi4KLp02zeGy2OK1Lfv2dHj 9dIe1/l8r8ukr/K/XRzv5yA0MwSdeLx71y7KSVh4BADsvGYesVXnMtFnBMI8iYWYF5QU 0JUOJvrSO2jMQ7RYbX9+A95HoSAeqZdLTSjdUbbAppBbI61juzPPHpfeAtnbsj6vIdT7 Mi6mxacwD+tXst/FT1BERYAPokdQutvIZNDwrePyLwZF0Dbk1gUOzRCnjFi1ymdXbrr3 lRWgPUX9p2EYNMcK835ZZliOeREtf82eIQhpXw++rJJ3jaLi9rn9EcCjtLP5+TPE2Psn +XzQ== X-Gm-Message-State: ALKqPwevJKid9uT0sKZFkVZKwBXgnj5zMPx/oO/urR8cysY11HN4dkXX MULN1rFRxBrT6G2HMRWwzumGlA63S+1/xg== X-Google-Smtp-Source: ADUXVKKkLhGFuCB8citzjmDZLqzCYHImPPtFxboPk9MakQqi/alWYZ1DfDpRRnP49Lo4vdnZUzz3fA== X-Received: by 2002:a2e:650a:: with SMTP id z10-v6mr4869248ljb.41.1527759655930; Thu, 31 May 2018 02:40:55 -0700 (PDT) Return-Path: Received: from localhost.localdomain (h-158-174-22-210.NA.cust.bahnhof.se. [158.174.22.210]) by smtp.gmail.com with ESMTPSA id y12-v6sm7496302lji.34.2018.05.31.02.40.54 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 31 May 2018 02:40:55 -0700 (PDT) From: Ulf Hansson To: linux-mmc@vger.kernel.org, Ulf Hansson , Kai-Heng Feng Cc: michal.pecio@gmail.com, Ritesh Raj Sarraf , Bauer Chen , Alan Stern Subject: [PATCH 3/4] mmc: rtsx_usb_sdmmc: Re-work runtime PM support Date: Thu, 31 May 2018 11:40:40 +0200 Message-Id: <20180531094041.27902-4-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180531094041.27902-1-ulf.hansson@linaro.org> References: <20180531094041.27902-1-ulf.hansson@linaro.org> The current implementation uses the runtime PM autosuspend feature with a default timeout set to 50ms. This really doesn't makes sense, as it's a USB driven host device, which needs it rtsx USB device (parent device) to be runtime resumed to provide power to the card. In practise, using the autosuspend or any async runtime PM suspend method, means unnecessary delaying the host device and thus the parent, to be runtime suspended when a card is removed/powered off. For this reasons, let's simply drop the support for runtime PM autosuspend and tell the mmc core to use synced runtime PM suspend methods, via setting MMC_CAP_SYNC_RUNTIME_PM during probe. Moreover, as the mmc core nowadays deploys runtime PM reference counting of the mmc host device, convert ->set_ios() to use the more lightweight pm_runtime_get_noresume() and pm_runtime_put_noidle() APIs. Signed-off-by: Ulf Hansson --- drivers/mmc/host/rtsx_usb_sdmmc.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) -- 2.17.0 diff --git a/drivers/mmc/host/rtsx_usb_sdmmc.c b/drivers/mmc/host/rtsx_usb_sdmmc.c index 14b4a4e13fe6..ca0ab8eb30c3 100644 --- a/drivers/mmc/host/rtsx_usb_sdmmc.c +++ b/drivers/mmc/host/rtsx_usb_sdmmc.c @@ -1042,9 +1042,9 @@ static int sd_set_power_mode(struct rtsx_usb_sdmmc *host, if (power_mode == MMC_POWER_OFF) { err = sd_power_off(host); - pm_runtime_put(sdmmc_dev(host)); + pm_runtime_put_noidle(sdmmc_dev(host)); } else { - pm_runtime_get_sync(sdmmc_dev(host)); + pm_runtime_get_noresume(sdmmc_dev(host)); err = sd_power_on(host); } @@ -1310,7 +1310,7 @@ static void rtsx_usb_update_led(struct work_struct *work) out: mutex_unlock(&ucr->dev_mutex); - pm_runtime_put(sdmmc_dev(host)); + pm_runtime_put_sync_suspend(sdmmc_dev(host)); } #endif @@ -1324,7 +1324,7 @@ static void rtsx_usb_init_host(struct rtsx_usb_sdmmc *host) mmc->caps = MMC_CAP_4_BIT_DATA | MMC_CAP_SD_HIGHSPEED | MMC_CAP_MMC_HIGHSPEED | MMC_CAP_BUS_WIDTH_TEST | MMC_CAP_UHS_SDR12 | MMC_CAP_UHS_SDR25 | MMC_CAP_UHS_SDR50 | - MMC_CAP_NEEDS_POLL | MMC_CAP_ERASE; + MMC_CAP_NEEDS_POLL | MMC_CAP_ERASE | MMC_CAP_SYNC_RUNTIME_PM; mmc->caps2 = MMC_CAP2_NO_PRESCAN_POWERUP | MMC_CAP2_FULL_PWR_CYCLE | MMC_CAP2_NO_SDIO; @@ -1367,8 +1367,6 @@ static int rtsx_usb_sdmmc_drv_probe(struct platform_device *pdev) mutex_init(&host->host_mutex); rtsx_usb_init_host(host); - pm_runtime_use_autosuspend(&pdev->dev); - pm_runtime_set_autosuspend_delay(&pdev->dev, 50); pm_runtime_enable(&pdev->dev); #ifdef RTSX_USB_USE_LEDS_CLASS @@ -1423,7 +1421,6 @@ static int rtsx_usb_sdmmc_drv_remove(struct platform_device *pdev) mmc_free_host(mmc); pm_runtime_disable(&pdev->dev); - pm_runtime_dont_use_autosuspend(&pdev->dev); platform_set_drvdata(pdev, NULL); dev_dbg(&(pdev->dev), From patchwork Thu May 31 09:40:41 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 137346 Delivered-To: patches@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp6373749lji; Thu, 31 May 2018 02:40:57 -0700 (PDT) X-Received: by 2002:a19:1329:: with SMTP id j41-v6mr3772681lfi.141.1527759657592; Thu, 31 May 2018 02:40:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527759657; cv=none; d=google.com; s=arc-20160816; b=wjX+w/hllqqje53uaARqqQW4914XVmpZwLF9WdSjIAjRSOB7hZNIU+CV0gYQZlBdKD YftmoOJiiuZeYEvqJ4+hWeVJX6rgpqWLm0DGw5di2MW/Eid0xpuNkliaVTtpxPgBGIPQ 6G6Rrw/l/rR/crXspVJYvhTryG12pCEsGolUcoAbjZGg5jgKfvBKPNqCLjVf0vDjCf4j /yfDyQEauIgLCDPQhY/T+6EblqAcbqizlOO1u7zGp6zsKRvNF2UkElrerQcSZEoC6AAt J4NEXVGcpaYIxmTPnvg1c7Vj15W+29PM+m7x5dbJj6qUS2i0Yv/l/Sglw+gcqJHAekfA mVbA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=QdA4eLivmm4GmqhEv/vJyACJVRc4XAMEwA1ofpsDyDI=; b=WkS1q9u1/LeTFStWE7lr400+5Z1qUJkUYqyV7LN4h+DVRNii5pce5h1No5xMtBJSTz 4xsh6tyIQCELdxlXiQ7jjjKMWqFKHuN9RnD6IAFtFgVDci+/+tHiKsoeO69UZTgU1Tq8 Z+TiOSOARX1jLg9nNJxEmaXMiDtAuUsmUgf2xq0j56SdnDBRqx341GRdJKjlpMqFYqGu NgGnoAlfXbZcC65BlCTATYGxgcKQNAIM7c3Jw5WxNCDp9H/Q0HW5x5xjNkPesZ2wb9dR Yxk9yav9ybDGwTYZqGvOlVyY3fbTMrq/WpoJWdmXYulfrjTdRJiCWIuCyrzIuDhOsibh Wf+w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=HYzHgEqc; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id r18-v6sor2861535lja.40.2018.05.31.02.40.57 for (Google Transport Security); Thu, 31 May 2018 02:40:57 -0700 (PDT) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=HYzHgEqc; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=QdA4eLivmm4GmqhEv/vJyACJVRc4XAMEwA1ofpsDyDI=; b=HYzHgEqc7z+L12QeqR68eC3TYvRhJl/jYTPbNPC82dlMSrBEiEhfGOlntkOqiKXlLY n9ENuKuH61pCW+NQhFZTRspY7ymNmhQtw2uI6pPTvrs97n+H+j3kLuc+m0dcZDbQAeGK +OlLV+H6gUby78bYRZjnd2GfNZO6m7Ud1KGkM= 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; bh=QdA4eLivmm4GmqhEv/vJyACJVRc4XAMEwA1ofpsDyDI=; b=aRk4EfJdtm4vUR4h75G26tNE0dXIGYYMixzm72L/48oqBviKomGbFygeGi6VHYz9Ks r2jFdg/NrL0KPaXgxfQQrI9+YIFXzsPN82J2HsjMB6JQu4niJxb7iBD67RKwwcpitk9u OUav3gGOoyKfbxnzH4bv8sdyR/rUmirVEo5cmFhw3gDNudJvf81O5TH8cXpilwG0wlLE rWDy0BBIeXz/4C59IG0J/MMcPSCoDyEGeyZkAJEcvTvBskQfIkxRaw4MIHJZ++CDQT7a wv/NFpDy6AyFe6Lue7q3pF1Q0b6GpLZUiGafBsQXFhXa0PYbjYGJzspX157oahodpRcv e32g== X-Gm-Message-State: ALKqPwcT/KlKfA9f9FM/4D6qV/4PUzBXI6Ud0Ry3P+vB4t/T34QTUaB6 R64lVNlCSsaLENpQR8DDcoDnK3oF X-Google-Smtp-Source: ADUXVKKpIDeEsl9TnBnL6uZR1F51TJO79WvKlvKUWHJFzwR/K3zHabawQqbMarsUDSq0eGufsLeIrA== X-Received: by 2002:a2e:3e0c:: with SMTP id l12-v6mr4942906lja.23.1527759657414; Thu, 31 May 2018 02:40:57 -0700 (PDT) Return-Path: Received: from localhost.localdomain (h-158-174-22-210.NA.cust.bahnhof.se. [158.174.22.210]) by smtp.gmail.com with ESMTPSA id y12-v6sm7496302lji.34.2018.05.31.02.40.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 31 May 2018 02:40:56 -0700 (PDT) From: Ulf Hansson To: linux-mmc@vger.kernel.org, Ulf Hansson , Kai-Heng Feng Cc: michal.pecio@gmail.com, Ritesh Raj Sarraf , Bauer Chen , Alan Stern Subject: [PATCH 4/4] mmc: rtsx_usb_sdmmc: Re-work card detection/removal support Date: Thu, 31 May 2018 11:40:41 +0200 Message-Id: <20180531094041.27902-5-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180531094041.27902-1-ulf.hansson@linaro.org> References: <20180531094041.27902-1-ulf.hansson@linaro.org> The rtsx USB parent device, has logic to detect when a card is inserted into the card slot. Although, the logic can't detect when a card is removed. This makes things a bit tricky, which is why the current method is simply to turn on MMC_CAP_NEEDS_POLL during probe. Using MMC_CAP_NEEDS_POLL means lots of energy being wasted, as the mmc host becomes runtime resumed frequently by the mmc core, while it polls for new cards being inserted. To address this problem, let's start relying on that the rtsx USB driver runtime resumes its child device, which is the rtsx_usb_sdmmc device, when it detects that a new card being inserted. This means dropping MMC_CAP_NEEDS_POLL from being set during probe. Instead let's implement a ->runtime_resume() callback to schedule a detect work and to set MMC_CAP_NEEDS_POLL. In this way, polling is enabled as long as there is card inserted, thus we can rely on the mmc core to detect also when the card becomes removed. Furthermore, to avoid polling forever after a card has been removed, let's implement a ->runtime_suspend() callback and make it clear MMC_CAP_NEEDS_POLL. Signed-off-by: Ulf Hansson --- drivers/mmc/host/rtsx_usb_sdmmc.c | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) -- 2.17.0 diff --git a/drivers/mmc/host/rtsx_usb_sdmmc.c b/drivers/mmc/host/rtsx_usb_sdmmc.c index ca0ab8eb30c3..91eb3b32d068 100644 --- a/drivers/mmc/host/rtsx_usb_sdmmc.c +++ b/drivers/mmc/host/rtsx_usb_sdmmc.c @@ -28,6 +28,7 @@ #include #include #include +#include #include #include @@ -1324,7 +1325,7 @@ static void rtsx_usb_init_host(struct rtsx_usb_sdmmc *host) mmc->caps = MMC_CAP_4_BIT_DATA | MMC_CAP_SD_HIGHSPEED | MMC_CAP_MMC_HIGHSPEED | MMC_CAP_BUS_WIDTH_TEST | MMC_CAP_UHS_SDR12 | MMC_CAP_UHS_SDR25 | MMC_CAP_UHS_SDR50 | - MMC_CAP_NEEDS_POLL | MMC_CAP_ERASE | MMC_CAP_SYNC_RUNTIME_PM; + MMC_CAP_ERASE | MMC_CAP_SYNC_RUNTIME_PM; mmc->caps2 = MMC_CAP2_NO_PRESCAN_POWERUP | MMC_CAP2_FULL_PWR_CYCLE | MMC_CAP2_NO_SDIO; @@ -1429,6 +1430,30 @@ static int rtsx_usb_sdmmc_drv_remove(struct platform_device *pdev) return 0; } +#ifdef CONFIG_PM +static int rtsx_usb_sdmmc_runtime_suspend(struct device *dev) +{ + struct rtsx_usb_sdmmc *host = dev_get_drvdata(dev); + + host->mmc->caps &= ~MMC_CAP_NEEDS_POLL; + return 0; +} + +static int rtsx_usb_sdmmc_runtime_resume(struct device *dev) +{ + struct rtsx_usb_sdmmc *host = dev_get_drvdata(dev); + + host->mmc->caps |= MMC_CAP_NEEDS_POLL; + mmc_detect_change(host->mmc, 0); + return 0; +} +#endif + +static const struct dev_pm_ops rtsx_usb_sdmmc_dev_pm_ops = { + SET_RUNTIME_PM_OPS(rtsx_usb_sdmmc_runtime_suspend, + rtsx_usb_sdmmc_runtime_resume, NULL) +}; + static const struct platform_device_id rtsx_usb_sdmmc_ids[] = { { .name = "rtsx_usb_sdmmc", @@ -1444,6 +1469,7 @@ static struct platform_driver rtsx_usb_sdmmc_driver = { .id_table = rtsx_usb_sdmmc_ids, .driver = { .name = "rtsx_usb_sdmmc", + .pm = &rtsx_usb_sdmmc_dev_pm_ops, }, }; module_platform_driver(rtsx_usb_sdmmc_driver);