From patchwork Thu Apr 28 18:29:16 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 66930 Delivered-To: patches@linaro.org Received: by 10.140.93.198 with SMTP id d64csp369255qge; Thu, 28 Apr 2016 11:29:21 -0700 (PDT) X-Received: by 10.25.18.215 with SMTP id 84mr6832716lfs.154.1461868161412; Thu, 28 Apr 2016 11:29:21 -0700 (PDT) Return-Path: Received: from mail-lf0-x22e.google.com (mail-lf0-x22e.google.com. [2a00:1450:4010:c07::22e]) by mx.google.com with ESMTPS id 42si7606887lfs.5.2016.04.28.11.29.21 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 28 Apr 2016 11:29:21 -0700 (PDT) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 2a00:1450:4010:c07::22e as permitted sender) client-ip=2a00:1450:4010:c07::22e; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 2a00:1450:4010:c07::22e as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE dis=NONE) header.from=linaro.org Received: by mail-lf0-x22e.google.com with SMTP id c126so106178099lfb.2 for ; Thu, 28 Apr 2016 11:29:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=YBsBJWV+OsrNc0f99twkrqElw3hb8N9Huo6N/PxJDo4=; b=Mgt91k4FDRzy/ncy1HvtS3jdHrpQTzspnDr5rUTcV+B3/SjeURmELynl0qtQ1TWc58 kVz1zccNwx6L4AIHtaPcfJhFoR9KEOFpRowaEmGRo23GmZoN9/Wyi/Y8k5IRLhrxbNjb nwvqNYbvW64dsaNOeSwD7wE2m1C+zSvrFdJp8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=YBsBJWV+OsrNc0f99twkrqElw3hb8N9Huo6N/PxJDo4=; b=Vlff3e6ZTgo4rMmw2JeVNWc/Ago1sYLHeQ3Jcr/MOSnolXzN62akbZuAIIfg1La5AP mvLTWOJ6J/0y0Y6DJOBDaRO1hbUg35ZFcnSYhnbx1PQ7T5r7f4Nc4LDzRaE9zP4+tn8n 9gJQ2Wwv18Ejf+/R8XLo2J15KiYjO6Da+Muc8t9P48J4REAIrmjDJWGemRHbznfwCTSj dkBGY9pOUiCMa07X1+OesS1EwiDZxI0NWwo84nTMJIKWt9brEoZEbx9s4k7DBXWrLbhz zyv7qbS90Vm6ThVtoFFvAYwszRRQOg0KouoKDWuVR2u7ZSuNi5TswzcpSO2nQ8TePGMG azkQ== X-Gm-Message-State: AOPr4FX4YYuUh0AbumZFT4P6tUmY5eLToNol69qmFE/4Wyerai7wPs+9UVLJh0iFW8aedYSS/0M= X-Received: by 10.25.85.138 with SMTP id j132mr5737263lfb.123.1461868160995; Thu, 28 Apr 2016 11:29:20 -0700 (PDT) Return-Path: Received: from localhost.localdomain (h-155-4-128-67.na.cust.bahnhof.se. [155.4.128.67]) by smtp.gmail.com with ESMTPSA id j2sm1870133lfb.13.2016.04.28.11.29.18 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 28 Apr 2016 11:29:19 -0700 (PDT) From: Ulf Hansson To: linux-mmc@vger.kernel.org, Ulf Hansson Cc: Jaehoon Chung , Adrian Hunter Subject: [PATCH v2] mmc: core: Remove redundant rescan_disable flag Date: Thu, 28 Apr 2016 20:29:16 +0200 Message-Id: <1461868156-5734-1-git-send-email-ulf.hansson@linaro.org> X-Mailer: git-send-email 1.9.1 For the reasons explained below, it's safe to remove the rescan_disable flag. 1) cancel_delayed_work_sync() prevents an executing work from re-scheduling itself. 2) We are using the system_freezable_wq for the rescan works. As that queue becomes frozen when userspace becomes frozen during system PM, we don't need to disable the rescan works in the PM_SUSPEND_PREPARE phase. 3) At host registration it's not safe to schedule a detect work until mmc_start_host() is invoked. Trying to use the rescan_disable flag to prevent a rescan work from being executed isn't helping. Signed-off-by: Ulf Hansson --- Changes in v2: Updated changelog to better reflect why rescan_flag is redundant. --- drivers/mmc/core/core.c | 12 ------------ drivers/mmc/core/host.c | 3 --- include/linux/mmc/host.h | 1 - 3 files changed, 16 deletions(-) -- 1.9.1 diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c index 99275e4..b8c6a11 100644 --- a/drivers/mmc/core/core.c +++ b/drivers/mmc/core/core.c @@ -2580,9 +2580,6 @@ void mmc_rescan(struct work_struct *work) container_of(work, struct mmc_host, detect.work); int i; - if (host->rescan_disable) - return; - /* If there is a non-removable card registered, only scan once */ if (!mmc_card_is_removable(host) && host->rescan_entered) return; @@ -2649,7 +2646,6 @@ void mmc_rescan(struct work_struct *work) void mmc_start_host(struct mmc_host *host) { host->f_init = max(freqs[0], host->f_min); - host->rescan_disable = 0; host->ios.power_mode = MMC_POWER_UNDEFINED; mmc_claim_host(host); @@ -2674,7 +2670,6 @@ void mmc_stop_host(struct mmc_host *host) if (host->slot.cd_irq >= 0) disable_irq(host->slot.cd_irq); - host->rescan_disable = 1; cancel_delayed_work_sync(&host->detect); /* clear pm flags now and let card drivers set them as needed */ @@ -2788,9 +2783,6 @@ static int mmc_pm_notify(struct notifier_block *notify_block, case PM_HIBERNATION_PREPARE: case PM_SUSPEND_PREPARE: case PM_RESTORE_PREPARE: - spin_lock_irqsave(&host->lock, flags); - host->rescan_disable = 1; - spin_unlock_irqrestore(&host->lock, flags); cancel_delayed_work_sync(&host->detect); if (!host->bus_ops) @@ -2814,10 +2806,6 @@ static int mmc_pm_notify(struct notifier_block *notify_block, case PM_POST_SUSPEND: case PM_POST_HIBERNATION: case PM_POST_RESTORE: - - spin_lock_irqsave(&host->lock, flags); - host->rescan_disable = 0; - spin_unlock_irqrestore(&host->lock, flags); _mmc_detect_change(host, 0, false); } diff --git a/drivers/mmc/core/host.c b/drivers/mmc/core/host.c index e0a3ee1..e972489 100644 --- a/drivers/mmc/core/host.c +++ b/drivers/mmc/core/host.c @@ -319,9 +319,6 @@ struct mmc_host *mmc_alloc_host(int extra, struct device *dev) if (!host) return NULL; - /* scanning will be enabled when we're ready */ - host->rescan_disable = 1; - again: if (!ida_pre_get(&mmc_host_ida, GFP_KERNEL)) { kfree(host); diff --git a/include/linux/mmc/host.h b/include/linux/mmc/host.h index 85800b4..7fbe5c0 100644 --- a/include/linux/mmc/host.h +++ b/include/linux/mmc/host.h @@ -330,7 +330,6 @@ struct mmc_host { unsigned int doing_retune:1; /* re-tuning in progress */ unsigned int retune_now:1; /* do re-tuning at next req */ - int rescan_disable; /* disable card detection */ int rescan_entered; /* used with nonremovable devices */ int need_retune; /* re-tuning is needed */