Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp2760660imj; Mon, 11 Feb 2019 08:05:15 -0800 (PST) X-Google-Smtp-Source: AHgI3IYg/HTXh3DB4ahh6+JS8QOGM3Cit/Qcth+arShlJaM8idmqo4O1h3lYYjku4C1BdvfSA3Cu X-Received: by 2002:a17:902:24d:: with SMTP id 71mr37158490plc.225.1549901115668; Mon, 11 Feb 2019 08:05:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549901115; cv=none; d=google.com; s=arc-20160816; b=BgHKQ8njfHLhmel/WiWnazvqBB1AsQT2h6fcDeXPuSd8U/QZIlt51QQ79bqPOty+w/ KfybVJaZQOOpD6t9KQq5FOqTFn8x2kAnQim2HYRaIsQNUdXGbYPo9F9QPxKDfGnav0NZ cT7Rg5Mkjv2A9xoZMYq+u4zSkmV7jvDjmWKlhBm63dsd8gMdkSHNxe5dLysBXkeEw2m9 zX/rtOlqQTvsNFAGRA7Q3VSpFauzdFS1lGLpwc3cCz0yZzr2qBlrPr0Do3Zpx0/kKfGU /cHkU/EaR52WN78l+fnVfI+c3MykzzLMWvEWNIEbiyPkUSfUBHddxONDVCtWrR0C+1BJ nKrw== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=pEOnHkTR4/V4gsh2Iq7sQ5Os2zEHSSi28EgC5KKVUuQ=; b=I+JISkqQABbROchjMwALdTL6RnhitBSd9tY4wKm9rPEK10P2/9ermbUzKwWxhJPhbT ndC2fxX0a0euZlQRcCBn9fq/wy73cw2BbobWlkOI3XYnteeTLeQ0vhP7AaBqNKLXvwIk eNkxwXnhhL3FuTbh57ThXhuh9SR+zk94M85H79pVPdofNWYG6O3TGr2SNmguQERmymHo pO5cvEDVjdq9S2ggpS/XAtwFwAUe6Pge6+/jdh6Vfclk7Bq6/vViFzNvis9Qcp7vtKCr j2DsP6hLvtZEeBUU7ECpxw9ICsAmy3/7I+FaMWfHpa3/FmpSfiaqt/B+LVB3qN5QhPy2 6I9Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="w5tuv/Qc"; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i20si10133978pgh.187.2019.02.11.08.04.55; Mon, 11 Feb 2019 08:05:15 -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="w5tuv/Qc"; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729943AbfBKO3K (ORCPT + 99 others); Mon, 11 Feb 2019 09:29:10 -0500 Received: from mail.kernel.org ([198.145.29.99]:35174 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728058AbfBKO3I (ORCPT ); Mon, 11 Feb 2019 09:29:08 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 7FBEC20844; Mon, 11 Feb 2019 14:29:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1549895348; bh=yfn545uOGUAhiH/4x9FZqIJ4AHt9Xg/qsqd9fKDNF44=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=w5tuv/QcBQIxpLDtJJHDeeqcS8iXwJumkx8Qh8HMfPG6qBPJNcOL6LwHgGxSw3pA4 Gk1plBsdjOkRJGYY2QfsTHq3fCPOV9z5MBklOtFy1Tx1lA93DNfnaxh1U8dovGU4hT aj5awrTFRmYyrh11GXZriMUFl/jB/P1cAXwM5Qac= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Kai-Heng Feng , Oleksandr Natalenko , Ulf Hansson , Sasha Levin Subject: [PATCH 4.20 174/352] memstick: Prevent memstick host from getting runtime suspended during card detection Date: Mon, 11 Feb 2019 15:16:41 +0100 Message-Id: <20190211141858.161451737@linuxfoundation.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190211141846.543045703@linuxfoundation.org> References: <20190211141846.543045703@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.20-stable review patch. If anyone has any objections, please let me know. ------------------ [ 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 @@ out_power_off: 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