Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3701406imu; Mon, 28 Jan 2019 09:16:44 -0800 (PST) X-Google-Smtp-Source: ALg8bN4MGgQdAF0ydlaYSKL9ekImKjHAvvFSX+/g6Mz0HlhADv4JZPUjj8rW9Y2o1E7/UEstj5rP X-Received: by 2002:a63:5b48:: with SMTP id l8mr20650846pgm.80.1548695804841; Mon, 28 Jan 2019 09:16:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548695804; cv=none; d=google.com; s=arc-20160816; b=iKgUMiAtgYwp9lKVXrKyFP4kTkMVZlqOH/NX5hHNDgyt+xSLgxTLvEUR6MySykdNTb GSJmOLe3cySYQcHpQeNu2hYDsYoUnQfroTA8bo/9Q7x7TPmxdcWCvnSuYQ6P0PDNmyF0 vxZv+kmZxdZh3IyBMVoYZ3ZqF17o24En9HxNJm4QLH0to1S4LOGxiPB8mu/TOHD+oJdL wBgqYRsjvu9zPgP9AQ4UKNJyXfGdMj7apoA7jyq95oXd/0teNBhxubbdC6ekhVUSvXIM ABiDT0km63OAUNq3S4kwmqrHj8OeAsrFyrgwpWU3W2W3GNT5MVgz4QGlAJFjLTvsmFTa 1cCA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=+ZdjxmtDm9YujxddDXFQTGdkuUQ9hljO4cy2iT3YVyU=; b=cUBV9NSZALj5fKu15qCQHOqTif0heXOfCjDp74TRn5B1hyr5giLX5G/pOy6HL5MzLV YrbYfpSTEtgq5BSrPOcrI5ERUiRLiQPRUZoJm81vLoj/7pM/8DeEttEAyda63+xv+6iZ 9rk6MZ5CzlFLN5RzkzdpRQiDsrLGGgG3mV2xuiPhGgiVBcYAsZ7Vz4jYvZChhXRQ8JvB 4peU9zQ0VJ8gy3TCm4Ti2g7uWpeBzaBK3nuyOECCvSGaHl0ueDl76rVFv8qdf0UV7u46 OVfuzMwmTrYR+bt5awEx4h4ZyXvrhIv2TFjhEFhf3T0fDE5JKY1qXREpqHR7Az6y1mbl IX+w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="T/etb+tY"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x6si22912717pgh.363.2019.01.28.09.16.29; Mon, 28 Jan 2019 09:16:44 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="T/etb+tY"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731634AbfA1RQJ (ORCPT + 99 others); Mon, 28 Jan 2019 12:16:09 -0500 Received: from mail.kernel.org ([198.145.29.99]:55834 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731313AbfA1QGi (ORCPT ); Mon, 28 Jan 2019 11:06:38 -0500 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 2E21B20989; Mon, 28 Jan 2019 16:06:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1548691597; bh=1lo/rXqcyk+Uvm7ySNkdnHLfIbMaG7qc5NVc1MfvC7k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=T/etb+tY+Tc+HgoBC2WK4a2ZLjrYlEVxK+XQx7uYDWlfW33m9A3kGvhq0Hk4hg/G8 npA3lcb8zLfD2TgJx6g8fsJURDd5RP27DkvAul8ZTeWeizpj3Hhxvt+CRC6m3Eombg yFwJx62iitG8qUO2UrTFxJIo4A3AMBEJaufdwRfA= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Kai-Heng Feng , Ulf Hansson , Sasha Levin Subject: [PATCH AUTOSEL 4.19 154/258] memstick: Prevent memstick host from getting runtime suspended during card detection Date: Mon, 28 Jan 2019 10:57:40 -0500 Message-Id: <20190128155924.51521-154-sashal@kernel.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190128155924.51521-1-sashal@kernel.org> References: <20190128155924.51521-1-sashal@kernel.org> MIME-Version: 1.0 X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Kai-Heng Feng [ Upstream commit e03e303edf1c63e6dd455ccd568c74e93ef3ba8c ] We can use MEMSTICK_POWER_{ON,OFF} along with pm_runtime_{get,put} helpers to let memstick host support runtime pm. The rpm count may go down to zero before the memstick host powers on, so the host can be runtime suspended. So before doing card detection, increment the rpm count to avoid the host gets runtime suspended. Balance the rpm count after card detection is done. Signed-off-by: Kai-Heng Feng Tested-by: Oleksandr Natalenko Signed-off-by: Ulf Hansson Signed-off-by: Sasha Levin --- drivers/memstick/core/memstick.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/memstick/core/memstick.c b/drivers/memstick/core/memstick.c index 76382c858c35..1246d69ba187 100644 --- a/drivers/memstick/core/memstick.c +++ b/drivers/memstick/core/memstick.c @@ -18,6 +18,7 @@ #include #include #include +#include #define DRIVER_NAME "memstick" @@ -436,6 +437,7 @@ static void memstick_check(struct work_struct *work) struct memstick_dev *card; dev_dbg(&host->dev, "memstick_check started\n"); + pm_runtime_get_noresume(host->dev.parent); mutex_lock(&host->lock); if (!host->card) { if (memstick_power_on(host)) @@ -479,6 +481,7 @@ static void memstick_check(struct work_struct *work) host->set_param(host, MEMSTICK_POWER, MEMSTICK_POWER_OFF); mutex_unlock(&host->lock); + pm_runtime_put(host->dev.parent); dev_dbg(&host->dev, "memstick_check finished\n"); } -- 2.19.1