Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp2720305imj; Mon, 11 Feb 2019 07:29:15 -0800 (PST) X-Google-Smtp-Source: AHgI3IYXRJluKlciBIHjCcaEYcCHt/kikYwMRvinXdNZqS33UP65nEaXZxjtTSVrJl8s5nq09tf5 X-Received: by 2002:a17:902:925:: with SMTP id 34mr36868244plm.14.1549898955253; Mon, 11 Feb 2019 07:29:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549898955; cv=none; d=google.com; s=arc-20160816; b=iI/8tcx3sRsvIZ2lqFNMZE4N8IC8H+4/xvENH5nwZoQVVdMmH/qneZKjQlcs4i1NAz yQV4tXeaWMexTAUWbHuU6Cqd1VBgytI2uBsz3fibQ7rmLU9Dktq2mhmk/+60iTT+QcMN PLlsTR7MfYQbB+DT6vRqhiluefU/VFO95Dbq0W2MDC5HOLRae98+FumlS+eYgEAlONzD M6c/lMPFn8CRbjatIgmB7RIi8Zfi2TgOp/zcJmgmzomiSkbKhOqBvV4P0ePK305JR2ri sJIGaY6qHN90oxPfLLa3hwZ3Bom2cf6H18AYH06u0RF0IeD+z96QETzWcfGqWQL9Hzdn ooqg== 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=ArXIb+m+/qMNrHdc1CzCu0MTniQeVexKj8gbuzCk8o4=; b=AF6jp3QsbuuIi1hXdXPiaXFbT5pXYCaef/9gTFtdNzn7anyASPBIoAtlqlDjSd6j1q +/CbChZgr8V+65yn0cY+u5lVt4MBDCktg2094GQbVeygVegHwzO4MuAJ2/iCeuIHg+hJ xdvnggdH11G0Wd7Drj7AAdmMenL7y+Prv3ur2VoC+zINfjEtgvkFzYTNj9yJt4c/9LdS blTkRAsgTWcuEOMewXGIcK5zyTPFimPmwZYuFrcHiRIKRM8ekfcXyhGlxvRBdoSonQa0 Q0UpfKs4rK5V0uupkaqm7FvJjkcV3BqbYD6UBlJlZOKadmTOJZRIRr3fNhA7kvefRJUw Itvg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=mTXxpxZu; 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 l7si10972423plg.390.2019.02.11.07.28.59; Mon, 11 Feb 2019 07:29: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=mTXxpxZu; 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 S2389617AbfBKO6k (ORCPT + 99 others); Mon, 11 Feb 2019 09:58:40 -0500 Received: from mail.kernel.org ([198.145.29.99]:46328 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389606AbfBKO6i (ORCPT ); Mon, 11 Feb 2019 09:58:38 -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 646372229E; Mon, 11 Feb 2019 14:58:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1549897117; bh=Vv0Qy50dyWF8wZWbPKanvHhg2nlJajtFxmEwPVLRykI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mTXxpxZuK/CjOTEOLAPK55z0nwPAJ5BZlTnmMnZ1eRZ6MlmxQk8mx4kod2m1WIMhF t4+oLPF8A+1pPTn877XsY9Tn9rB1xB1L2+PL1lXT91oc3Obxu4JCeQ4c5VH1EVFUoK w8Mxvk90UihEP4FKfrSLFQATtBFMXJlJiA4mjUy0= 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.14 097/205] memstick: Prevent memstick host from getting runtime suspended during card detection Date: Mon, 11 Feb 2019 15:18:15 +0100 Message-Id: <20190211141834.964847371@linuxfoundation.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190211141827.214852402@linuxfoundation.org> References: <20190211141827.214852402@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.14-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