From patchwork Tue Sep 6 09:42:35 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 75484 Delivered-To: patch@linaro.org Received: by 10.140.106.11 with SMTP id d11csp454680qgf; Tue, 6 Sep 2016 02:42:42 -0700 (PDT) X-Received: by 10.66.2.168 with SMTP id 8mr516182pav.87.1473154962174; Tue, 06 Sep 2016 02:42:42 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g4si1419947pfj.152.2016.09.06.02.42.41; Tue, 06 Sep 2016 02:42:42 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-usb-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org; spf=pass (google.com: best guess record for domain of linux-usb-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-usb-owner@vger.kernel.org; dmarc=fail (p=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933537AbcIFJmk (ORCPT + 4 others); Tue, 6 Sep 2016 05:42:40 -0400 Received: from mail-wm0-f49.google.com ([74.125.82.49]:36520 "EHLO mail-wm0-f49.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932970AbcIFJmi (ORCPT ); Tue, 6 Sep 2016 05:42:38 -0400 Received: by mail-wm0-f49.google.com with SMTP id b187so54373245wme.1 for ; Tue, 06 Sep 2016 02:42:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=lRziJgI3aRMKU7+iEM4sXx99tcA6mNM7M9ZThpqvJ1E=; b=O6Ck0JH083UmQT+UyZYAY4lsEo321uYk5tugbyuA9SmlemX4fO/tbhBtgdVLALSh80 XG73jXule44GqlhK/tDZR/Ji45bV5AzEYMe66Pe76HA2FQx3apX1riZj7LmXQeAqH8vu sU6NpLE6+7dooERFkRnH2WIq2O5mduvz2Feyc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=lRziJgI3aRMKU7+iEM4sXx99tcA6mNM7M9ZThpqvJ1E=; b=JxVwUWD1f3FW+LiGERblxRNdkHkpCx5gIsCRdfIsFhsT4Wl44pNotlsmkICk8EYbMe qYA5oJE7ZMbpPZbwIk+god8F3X6cA9aH/BSbFl6Sd0+JqehmGbIwzRk8tMKXrB9g3rCr kiIRGUV9d+EXyBU4MiiKcYeXOLPCKUaX/GHU7BjBAMzNZ20scuJu64kquKfBa1LWX+se ZeBX9UkQ7XGpGBOmG9IqvTjjTIG/P+xY2Yp5++qzqwaB91DKOW846W3XOwxOXMTnVTYm CvP5VwVYB+P81HSdHa5wcwk36hyxSNrSbdf3YUBGm8c1M5fFlTeu01wS8PCHe2TZLkjr tU0A== X-Gm-Message-State: AE9vXwMtpvElm3neW5XKKclnmU5tW0lkqFB/qyXHkEqMeqIXNBY1TWBoUX75XD4hylQIs3bBNhCc58jtJsiLw05l X-Received: by 10.28.20.77 with SMTP id 74mr18742717wmu.1.1473154957285; Tue, 06 Sep 2016 02:42:37 -0700 (PDT) MIME-Version: 1.0 Received: by 10.194.40.167 with HTTP; Tue, 6 Sep 2016 02:42:35 -0700 (PDT) In-Reply-To: References: <1473080344.10346.4.camel@researchut.com> From: Ulf Hansson Date: Tue, 6 Sep 2016 11:42:35 +0200 Message-ID: Subject: Re: xHCI problem? [was Re: Erratic USB device behavior and device loss] To: Alan Stern , Ritesh Raj Sarraf Cc: USB list , linux-mmc Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org On 5 September 2016 at 17:58, Alan Stern wrote: > On Mon, 5 Sep 2016, Ritesh Raj Sarraf wrote: > >> -----BEGIN PGP SIGNED MESSAGE----- >> Hash: SHA512 >> >> On Sun, 2016-09-04 at 15:46 -0400, Alan Stern wrote: >> > >> > This is not the problem I was discussing with Ulf. The problem was why >> > the device kept going into and out of runtime suspend every three >> > seconds. The kernel log above does not say whether this was happening. >> > One way to tell is to look at a usbmon trace (like we did before). >> >> https://people.debian.org/~rrs/tmp/usbmon.txt.gz >> >> This should have the logs you asked for, running on 4.8-rc4. > > Confirmed, the runtime suspends and resumes are still happening. > > Ulf, any insights? Alan, Ritesh, Yes, I am starting to understand more about what goes on here. Although I need help to test as I don't have the HW. As you already guessed, I suspect the problem is within the runtime PM deployment in the drivers/mmc/host/rtsx_usb_sdmmc.c. Let me start by first give you some background to how the mmc core deals with runtime PM. *) The mmc core manages most of the calls to the pm_runtime_get|put*() and pm_runtime_mark_last_busy() for the mmc host device. The gets/puts are done when the core is about to access the mmc host device, via the mmc host ops driver interface. You may search for calls to the mmc_claim|release_host() functions to find out when the gets/puts are done. **) The mmc core have also deployed runtime PM for the mmc *card* device and which has the runtime PM autosuspend feature enabled with a 3s default timeout. One important point is that the mmc card device has the mmc host device assigned as being its parent device. I guessing the reason to why you are encountering strange 3s intervals of runtime PM suspend/resume is related to this. Now, in this case, the rtsx_usb_sdmmc driver seems to need a bit of special runtime PM deployment, as the calls to pm_runtime_get|put*() also controls the power to the usb device and thus also the power to the card. I am guessing that's done via the usb device being assigned as parent for the mmc host's platform device!? By reviewing the code of the rtsx_usb_sdmmc driver, particularly how it calls pm_runtime_get|put() I am guessing those calls may not be properly deployed. Perhaps rtsx_usb_sdmmc should convert to use the usb_autopm_put|get_interface() and friends, although I didn't want to make that change at this point so instead I have cooked a patch that might fixes the behaviour. Ritesh, can you please try it out to see what happens? --- drivers/mmc/host/rtsx_usb_sdmmc.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) sd_set_timing(host, ios->timing, &host->ddr_mode); @@ -1336,7 +1331,7 @@ static void rtsx_usb_init_host(struct rtsx_usb_sdmmc *host) MMC_CAP_MMC_HIGHSPEED | MMC_CAP_BUS_WIDTH_TEST | MMC_CAP_UHS_SDR12 | MMC_CAP_UHS_SDR25 | MMC_CAP_UHS_SDR50 | MMC_CAP_NEEDS_POLL; - mmc->caps2 = MMC_CAP2_NO_PRESCAN_POWERUP | MMC_CAP2_FULL_PWR_CYCLE; + mmc->caps2 = MMC_CAP2_FULL_PWR_CYCLE; mmc->max_current_330 = 400; mmc->max_current_180 = 800; -- Kind regards Uffe -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/mmc/host/rtsx_usb_sdmmc.c b/drivers/mmc/host/rtsx_usb_sdmmc.c index 6c71fc9..3d6fe51 100644 --- a/drivers/mmc/host/rtsx_usb_sdmmc.c +++ b/drivers/mmc/host/rtsx_usb_sdmmc.c @@ -1138,11 +1138,6 @@ static void sdmmc_set_ios(struct mmc_host *mmc, struct mmc_ios *ios) dev_dbg(sdmmc_dev(host), "%s\n", __func__); mutex_lock(&ucr->dev_mutex); - if (rtsx_usb_card_exclusive_check(ucr, RTSX_USB_SD_CARD)) { - mutex_unlock(&ucr->dev_mutex); - return; - } - sd_set_power_mode(host, ios->power_mode); sd_set_bus_width(host, ios->bus_width);