From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.1 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B5476C43381 for ; Mon, 18 Feb 2019 14:27:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 8657D21900 for ; Mon, 18 Feb 2019 14:27:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1550500031; bh=jLbXXl5oQSoJ/as9st8I9NdaZhLwuO/QlaDs2IDJLds=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=pQFquX6UeXTDI43K/v8r9zpxzy7gPwgWXZ9mR5DVl1hl9mjnb+V+cB4eZx7lehoQi 3GxcEARQLg2/izduYU0Eg9A3bXXeQKvYPYtetReczhaIEAowTeaGp8f+k/++VzCRFt vM1mcdW9sicbroYRcByxrgR1VZCvYx9Q+94kZ65g= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390160AbfBRO1K (ORCPT ); Mon, 18 Feb 2019 09:27:10 -0500 Received: from mail.kernel.org ([198.145.29.99]:43774 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388647AbfBROCM (ORCPT ); Mon, 18 Feb 2019 09:02:12 -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 DF16D2173C; Mon, 18 Feb 2019 14:02:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1550498531; bh=jLbXXl5oQSoJ/as9st8I9NdaZhLwuO/QlaDs2IDJLds=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lGko816TkKJilphl2Qg+i4pZbgsh4dEpW2UWJjtHDvBebxaU8ubbxRly71LU57uRw kye5El4Z4VwBaRmp5en2aajnYE59ayG8wFLacrUBiBH4umMiECw9oex2V3wqbnofR9 ZcNWvxfSdB/uFIzonu49aLPJOZ1s/9rtp7Vlc2K0= 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.4 038/143] memstick: Prevent memstick host from getting runtime suspended during card detection Date: Mon, 18 Feb 2019 14:42:46 +0100 Message-Id: <20190218133530.538455739@linuxfoundation.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190218133529.099444112@linuxfoundation.org> References: <20190218133529.099444112@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.4-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 a0547dbf9806..4d673a626db4 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