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: 8974201 Return-Path: X-Original-To: patchwork-linux-mmc@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 1EC109F1C1 for ; Thu, 28 Apr 2016 18:29:26 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 3D46D2027D for ; Thu, 28 Apr 2016 18:29:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 46F24200FF for ; Thu, 28 Apr 2016 18:29:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751920AbcD1S3X (ORCPT ); Thu, 28 Apr 2016 14:29:23 -0400 Received: from mail-lf0-f46.google.com ([209.85.215.46]:35591 "EHLO mail-lf0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751513AbcD1S3W (ORCPT ); Thu, 28 Apr 2016 14:29:22 -0400 Received: by mail-lf0-f46.google.com with SMTP id c126so106178122lfb.2 for ; Thu, 28 Apr 2016 11:29:22 -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=OD1e0LbhW1nc0FFbyzNPIGCLC+5oZkLq2T7aCnJhR9EsX8DmdxDBoda8v1kGQZU4yy pW7Gx7EuZG2vfSvFD8MMH7zeG5FDDzXMaQEt1wj1w1WWEpj32Lt9tbTLD66YhYHYAfqR 0P+uzxuypmWvShq98gXvgaJDtIz3mqft7XGhmLiw0dv0sZrMWvxa1cSik9NTKbh7D/3S 5EA2wQ9NzrMqfC3BR82cIOFSSWpnA2SRyrnk+vp5a3/2ZhnGrY7a7DKuLCYm4rl25qzs n5lUUopZTjCKx+RGlQsgAGSnEAgFbc9T8LF46TS0cVxkolX5QRQjIhsj2oK8iR1g4V2c 3NVg== X-Gm-Message-State: AOPr4FXYhSLlNm2IkktGT4NLREaISOo/xMgNR0xp5giSsjdvQ2JRuiLF6sX19sM95IQWCv0Y X-Received: by 10.25.85.138 with SMTP id j132mr5737263lfb.123.1461868160995; Thu, 28 Apr 2016 11:29:20 -0700 (PDT) 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 Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org X-Spam-Status: No, score=-7.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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(-) 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 */