From patchwork Fri Jan 11 08:30:17 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AceLan Kao X-Patchwork-Id: 1023450 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=canonical.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="rWGl9A7T"; dkim-atps=neutral Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 43bbfn3v4Qz9sLw; Fri, 11 Jan 2019 19:30:57 +1100 (AEDT) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1ghsDM-0005N5-HF; Fri, 11 Jan 2019 08:30:52 +0000 Received: from mail-pf1-f196.google.com ([209.85.210.196]) by huckleberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1ghsDK-0005L2-LD for kernel-team@lists.ubuntu.com; Fri, 11 Jan 2019 08:30:50 +0000 Received: by mail-pf1-f196.google.com with SMTP id i12so6638306pfo.7 for ; Fri, 11 Jan 2019 00:30:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:subject:date:message-id:in-reply-to:references; bh=Z5bp93WXu4omPd2JR9puMF/hujyOw5YYYPVLee4nkQ8=; b=rWGl9A7TIUSneiRptAa+/4H83nMigT77DxmCw0QJshEBRayzYcmKNaG7aMw++Uc2Ff 5Q9gkHwU/KicRywVgOFulnou+xcus0k+7fQpOwCzitEHFSzYxqwnCWRBfzXHZbqhEidA oA2DDhS88lMzWpYoID9+45BVZYkR1GzNnUZYfK4LaCWp501FHcSEdjZ6aW/ucHly5zzU EBL7TiHXCu5uppZyc4bIAz+80to0Ksho1hgJ1RAWi8sWBqIYqP1PNpEoCoUYFCEppwRC 4FA75ViYTG/v/YbhSfMF4BB6fx8xCq7YWviUIjW47H5N57CYfJj627ONIBa2KCgg+lDZ 1d9A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:subject:date:message-id :in-reply-to:references; bh=Z5bp93WXu4omPd2JR9puMF/hujyOw5YYYPVLee4nkQ8=; b=iGZ3czXHZDZ7u8Du3QZJPEQB23RBtPivXG/RTxCok6hYUGEOJEOHQ4hwonOHBtaDOh N2iDh6yy9S0kAPZF0GcH/MNGMOoUjoJbudGD/tKu1G9OCei1HqEbogMZlF+S5YbWXaPg UqkyOX5yR27aKVj+Ki41Hix7tiktrwD5m7I0zHcFxJH4pX+QCAKP6z/p6RJAWHZpOgG7 gaR5x3g0S4LhjCqHhPdB6+hgRzl3+vtUlRwo34kV7K41N3PYPZ+iypNAzzFsMuYJGOov GPd8b+RWOtFYDLs/Sk6AAiP6sLA0j9isDWszLxBavSV8QRWDH8BSFh9Jn0B3VU0uH3Ny fxpQ== X-Gm-Message-State: AJcUukfiflhybanhznunLTKXnOrj61rYHoO+OkT1QqPnHoVVtictKL+Z ytx8hOb9V8szur8oNgY04O1sOrKrP44= X-Google-Smtp-Source: ALg8bN68uXqYXbeeGUjstO01jc3VLyDXxuiQF5rveFZL+C0kJDbt5DU9dbNl2SSUrGNS4nRZbVvFbA== X-Received: by 2002:a63:5f50:: with SMTP id t77mr12539391pgb.76.1547195448801; Fri, 11 Jan 2019 00:30:48 -0800 (PST) Received: from localhost (61-220-137-37.HINET-IP.hinet.net. [61.220.137.37]) by smtp.gmail.com with ESMTPSA id c67sm103833489pfg.170.2019.01.11.00.30.47 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 11 Jan 2019 00:30:48 -0800 (PST) From: AceLan Kao To: kernel-team@lists.ubuntu.com Subject: [PATCH 10/12][SRU][B][C][D][OEM-B] memstick: Prevent memstick host from getting runtime suspended during card detection Date: Fri, 11 Jan 2019 16:30:17 +0800 Message-Id: <20190111083019.32135-11-acelan.kao@canonical.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190111083019.32135-1-acelan.kao@canonical.com> References: <20190111083019.32135-1-acelan.kao@canonical.com> X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Kai-Heng Feng BugLink: https://bugs.launchpad.net/bugs/1811337 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 (cherry picked from commit e03e303edf1c63e6dd455ccd568c74e93ef3ba8c) Signed-off-by: AceLan Kao --- 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"); }