From patchwork Thu Oct 13 11:37:38 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 77613 Delivered-To: patches@linaro.org Received: by 10.140.97.247 with SMTP id m110csp186653qge; Thu, 13 Oct 2016 04:38:00 -0700 (PDT) X-Received: by 10.25.141.67 with SMTP id p64mr9024005lfd.86.1476358680460; Thu, 13 Oct 2016 04:38:00 -0700 (PDT) Return-Path: Received: from mail-lf0-x22d.google.com (mail-lf0-x22d.google.com. [2a00:1450:4010:c07::22d]) by mx.google.com with ESMTPS id e97si8165145lji.26.2016.10.13.04.38.00 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 13 Oct 2016 04:38:00 -0700 (PDT) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 2a00:1450:4010:c07::22d as permitted sender) client-ip=2a00:1450:4010:c07::22d; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 2a00:1450:4010:c07::22d as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE dis=NONE) header.from=linaro.org Received: by mail-lf0-x22d.google.com with SMTP id b75so131020870lfg.3 for ; Thu, 13 Oct 2016 04:38:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=CtnyP3iYQgTS5lngYMKNfSksO5UMELcdD4fXBNnmYm0=; b=ij7n5k11h9wIQjJBq+QCF3SJvptnXY2WSMg1arwWIz7D6mQFXXsoqKUMVHzrkZztF2 /0kQDCkmNPKk8BJNScEdz/gtxiT5U3f85CUXFWNJNyQ2nWRQjphE93T+78JhFesoqFno CfVPAYPAy4DrZh42wOLg13AjCw/H5/ZXRCE68= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=CtnyP3iYQgTS5lngYMKNfSksO5UMELcdD4fXBNnmYm0=; b=A7kSCvmeZOmwr8I1xJJ0p4SQrdB8hZPgBfEQuXq4xhtq0tHiT2W5W9BC6/OWlXo0eW y9y1aX+47UQlBCcObihjaAtoEqqJumFR7ld3qAYwjtV933fnCuRQJr0wrHw7qywH1HBi KrlAN5o3KFYfvTPA+0z34CrphhRt50XZAj3WYNKmbg5+WPQhXlJc1Q6o4aUsBaa0ocZF tASMcuTRBMO0KqH0QesLyTWDYN/7u0q+oFyOrEUjnHH5WP6HZszM6TM9d5v9zEPysTEq TU4zoEritGaiyH8mNXiHKnAYCaCO/ZecX+WImMwFYRwAA8i30X4IHs//S1hE0kHwRRCF fwmw== X-Gm-Message-State: AA6/9RlN6l+9RQ9KDYXjmG41agRdUgYyu3bdlU2Y3sBDd7K0uVYD7jgCuyqx4xEfrxDsSQHUtc8= X-Received: by 10.25.99.4 with SMTP id x4mr8601447lfb.128.1476358679448; Thu, 13 Oct 2016 04:37:59 -0700 (PDT) Return-Path: Received: from localhost.localdomain (h-155-4-221-67.na.cust.bahnhof.se. [155.4.221.67]) by smtp.gmail.com with ESMTPSA id p76sm3648114lfd.11.2016.10.13.04.37.57 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 13 Oct 2016 04:37:58 -0700 (PDT) From: Ulf Hansson To: linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org, Ulf Hansson Cc: Ritesh Raj Sarraf , Alan Stern , Oliver Neukum , USB list , Roger Tseng , Wei WANG , Subject: [PATCH 4/6] memstick: rtsx_usb_ms: Manage runtime PM when accessing the device Date: Thu, 13 Oct 2016 13:37:38 +0200 Message-Id: <1476358660-8338-5-git-send-email-ulf.hansson@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1476358660-8338-1-git-send-email-ulf.hansson@linaro.org> References: <1476358660-8338-1-git-send-email-ulf.hansson@linaro.org> Accesses to the rtsx usb device, which is the parent of the rtsx memstick device, must not be done unless it's runtime resumed. This is currently not the case and it could trigger various errors. Fix this by properly deal with runtime PM in this regards. This means making sure the device is runtime resumed, when serving requests via the ->request() callback or changing settings via the ->set_param() callbacks. Cc: Cc: Ritesh Raj Sarraf Cc: Alan Stern Signed-off-by: Ulf Hansson --- drivers/memstick/host/rtsx_usb_ms.c | 4 ++++ 1 file changed, 4 insertions(+) -- 1.9.1 diff --git a/drivers/memstick/host/rtsx_usb_ms.c b/drivers/memstick/host/rtsx_usb_ms.c index 1b99489..2e3cf01 100644 --- a/drivers/memstick/host/rtsx_usb_ms.c +++ b/drivers/memstick/host/rtsx_usb_ms.c @@ -524,6 +524,7 @@ static void rtsx_usb_ms_handle_req(struct work_struct *work) int rc; if (!host->req) { + pm_runtime_get_sync(ms_dev(host)); do { rc = memstick_next_req(msh, &host->req); dev_dbg(ms_dev(host), "next req %d\n", rc); @@ -544,6 +545,7 @@ static void rtsx_usb_ms_handle_req(struct work_struct *work) host->req->error); } } while (!rc); + pm_runtime_put(ms_dev(host)); } } @@ -570,6 +572,7 @@ static int rtsx_usb_ms_set_param(struct memstick_host *msh, dev_dbg(ms_dev(host), "%s: param = %d, value = %d\n", __func__, param, value); + pm_runtime_get_sync(ms_dev(host)); mutex_lock(&ucr->dev_mutex); err = rtsx_usb_card_exclusive_check(ucr, RTSX_USB_MS_CARD); @@ -635,6 +638,7 @@ static int rtsx_usb_ms_set_param(struct memstick_host *msh, } out: mutex_unlock(&ucr->dev_mutex); + pm_runtime_put(ms_dev(host)); /* power-on delay */ if (param == MEMSTICK_POWER && value == MEMSTICK_POWER_ON)