Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp513242imm; Wed, 13 Jun 2018 04:16:51 -0700 (PDT) X-Google-Smtp-Source: ADUXVKK5zhPws+ie4IgkYlRkbhIzNiIjI54hP5jL2LcgLizjv5PS+eSh9wzbEZlmlnyAt+kjZMoQ X-Received: by 2002:a17:902:9a4c:: with SMTP id x12-v6mr4696791plv.213.1528888611096; Wed, 13 Jun 2018 04:16:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528888611; cv=none; d=google.com; s=arc-20160816; b=VY4dTnhYlLQMiAeLpvXjfMNsMtq/lKfBr5RaJUyCkTFn4YdsYlK4oF1FPtimVQZOo6 8TDGXtxlaSD7N9Xdj10F8LkLApN09xi0DuGqpsWPazJxt0hn3H0/2o5GIfjJW2gblq+i MNpW2ZLXcB1LYOdY7yTFx4FBP8SvkrQ22TkPbKmR+z9ybUi3VBB2nGwW4Sc6MJ7DdxmY 2X43N0DG0uGtGo+x6EO4/2L/lvtvpLuiCa5B3bPccDNglJv2+T0OVV8zpK7HmV4BDdMY RVBKLJp83PNmiHQJC/jqCdR398yuw6nqaUcQH6g46W1KJJyOz5wXdICqf7zSGIJZqGsA Ov+g== 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 :content-language:in-reply-to:mime-version:user-agent:date :message-id:autocrypt:openpgp:from:references:cc:to:subject :dkim-signature:arc-authentication-results; bh=b/FR4SOZjL64r5pPsIvYIKUHAKFEzWAlETp7/bR3gT8=; b=b5IPqq0mBlJH/SSL52QcqFQVfqH2Ld/Ji3RMVAGBRsjOCHRQpU+m6e3QFphGN4VExC ceWaSxCfHwVzFvEyYX2bNdggmJ8nNWtSudtGtkyMfHkQ+Aj5F2ZOHyTQatSur/utzBq6 2R04HkrTMNY/bFkXSqrS7bPBtGnU12MUSZGEpHnJ/8xbOhsKEmqSBQzFr19Ln9ft80u7 toFg9C9Y0y5i8woaIUbKl3RsdFRTm3vPMFeLRemygRN10TjYLA1DfGmTWSAhsy/eaGPB 12xkNauAS5dxjFUNRPymGvKF3Q0J5rgOczwIeDgR5Icf6vyBJ0ekkboKh/uJ5fIVTxo1 PLfQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=H+S0U4is; 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; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u65-v6si2216625pgc.590.2018.06.13.04.16.36; Wed, 13 Jun 2018 04:16:51 -0700 (PDT) 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=@ti.com header.s=ti-com-17Q1 header.b=H+S0U4is; 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; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S935375AbeFMLP3 (ORCPT + 99 others); Wed, 13 Jun 2018 07:15:29 -0400 Received: from lelnx194.ext.ti.com ([198.47.27.80]:36770 "EHLO lelnx194.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934512AbeFMLP1 (ORCPT ); Wed, 13 Jun 2018 07:15:27 -0400 Received: from dflxv15.itg.ti.com ([128.247.5.124]) by lelnx194.ext.ti.com (8.15.1/8.15.1) with ESMTP id w5DBFFrT008738; Wed, 13 Jun 2018 06:15:15 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1528888515; bh=b/FR4SOZjL64r5pPsIvYIKUHAKFEzWAlETp7/bR3gT8=; h=Subject:To:CC:References:From:Date:In-Reply-To; b=H+S0U4ismyrG5dkIj0MTj3H9yRTnKFINCVxwojqdCvgozls6UlyL5yBkDeyJiirr8 iI4FPIuN20UUdgOoJFBGXVNKVkrqPZ20+MxppDgXtqd9mU1ojB443b0avecxu4/Qkp QpKC07ezNTU6dR2ufHptTnc0PbarmuXHSFyhoHis= Received: from DLEE102.ent.ti.com (dlee102.ent.ti.com [157.170.170.32]) by dflxv15.itg.ti.com (8.14.3/8.13.8) with ESMTP id w5DBFFIm010342; Wed, 13 Jun 2018 06:15:15 -0500 Received: from DLEE105.ent.ti.com (157.170.170.35) by DLEE102.ent.ti.com (157.170.170.32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1466.3; Wed, 13 Jun 2018 06:15:14 -0500 Received: from dlep32.itg.ti.com (157.170.170.100) by DLEE105.ent.ti.com (157.170.170.35) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.1466.3 via Frontend Transport; Wed, 13 Jun 2018 06:15:14 -0500 Received: from [192.168.2.6] (ileax41-snat.itg.ti.com [10.172.224.153]) by dlep32.itg.ti.com (8.14.3/8.13.8) with ESMTP id w5DBFCbC008145; Wed, 13 Jun 2018 06:15:12 -0500 Subject: Re: [PATCH 2/2] usb: dwc3: of_simple: don't call pm_runtime_set_active() To: Felipe Balbi , Tero Kristo , "Gerlach, Dave" CC: , , Nishanth Menon , "Nori, Sekhar" , Alan Stern , Johan Hovold , Greg Kroah-Hartman References: <1527518174-27860-1-git-send-email-rogerq@ti.com> <1527518174-27860-2-git-send-email-rogerq@ti.com> <87k1rlcok2.fsf@linux.intel.com> <87bmcwcl1j.fsf@linux.intel.com> From: Roger Quadros Openpgp: preference=signencrypt Autocrypt: addr=rogerq@ti.com; prefer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iYo1yz8NUH+yHGxz437ccUic8HPB2lIiL/W6C4wVhUbm2w9F 4VdByWgWCCY5Ynhe188sqNL+mFqLAaIssqyYwTBJM+Go6tOuRnP6jrkf2Va/pIwIltzf9QOW cgEAEQEAAcLBXwQYAQIACQUCVPWU9gIbDAAKCRDSWmvTvnYwk8niEACcwBAfe1tTSqCCHkRj zgIrt+NPBBfxilf9JXPGTYqfUkrcVfiNqLGFgIDZKjkLfArxiSmpmtKf1O1VYO9XDgADUKJO RvmUQM/l3Q99QC5b8yUyZOsgfSBOsV6DeqiULO30cXH/uEpR2fUcbtyYXHouiF2UNdq/BV5h HBQkGYtTf7K26NPp4wXMS+YsBm2Gbms/wywJh4KgRPP6LuA+UE/7l0xqMD3pBQ/L1KLTqOQY CItcZ0YbEvlrJc25PRkCssHf1J2c2MXV+CRqsibW8UamBmOyzKHVK/CwvIndwBmcciJrOf+4 uxegvXEnwvYPuQ3wvBSkgbJRFNJemnp5KSczANr4R/aA5cEbxhbg7peLv0FdFyTFJXCsKeuO 1gKoKtOLyxRhDocprSuEamaDWDCy3TmX+6nWaBIPYXDFT7IcHT6l6TyZ6IMjkXiHSLhynTIj f2xjSrvKPljIUxcqjhyqWe+coe/Xwbqz69DsK150xoAaoS3rbNlhmalbg15HNTipNDI/k81A fwt7ncjxvjXVJnA2nqPBDIW3mZO/ED0blLrVdaMZjf5LvS+vvsMdH7dHtrAXA50egr74sX0A NO7iW+gkmFYwap531ipMXthHPWbo5x9xfb+a48xA80ePBJLBDyw9X+cOe40+N4Ybiwy5Q2La IwrfNkJOLj3CvocMIw== Message-ID: <4a4fd59c-84a6-61c6-5567-50660b07302a@ti.com> Date: Wed, 13 Jun 2018 14:15:11 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.8.0 MIME-Version: 1.0 In-Reply-To: <87bmcwcl1j.fsf@linux.intel.com> Content-Type: text/plain; charset="utf-8" Content-Language: en-GB Content-Transfer-Encoding: 8bit X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 31/05/18 10:59, Felipe Balbi wrote: > > Hi, > > Roger Quadros writes: > >> On 30/05/18 15:31, Felipe Balbi wrote: >>> Roger Quadros writes: >>> >>>> Don't call pm_runtime_set_active() as it will prevent the device >>>> from being activated in the next pm_runtime_get_sync() call. >>>> >>>> Also call pm_runtime_get_sync() before of_platform_populate(). >>>> >>>> Signed-off-by: Roger Quadros >>> >>> This patch is wrong. >>> >>>> --- >>>> drivers/usb/dwc3/dwc3-of-simple.c | 7 +++---- >>>> 1 file changed, 3 insertions(+), 4 deletions(-) >>>> >>>> diff --git a/drivers/usb/dwc3/dwc3-of-simple.c b/drivers/usb/dwc3/dwc3-of-simple.c >>>> index e98d221..2cbb5c0 100644 >>>> --- a/drivers/usb/dwc3/dwc3-of-simple.c >>>> +++ b/drivers/usb/dwc3/dwc3-of-simple.c >>>> @@ -121,6 +121,9 @@ static int dwc3_of_simple_probe(struct platform_device *pdev) >>>> if (ret) >>>> goto err_resetc_assert; >>>> >>>> + pm_runtime_enable(dev); >>>> + pm_runtime_get_sync(dev); >>> >>> No, this is the wrong way to do things. My device should be enabled >>> already from probe, specially since I have already enabled clocks. >> >> As far as I understood just enabling clocks (which might not include bus clock) >> doesn't ensure device is enabled. >> >> Did you mean that I don't need to do a pm_runtime_get_sync() to enable my device in probe? >> Who is enabling by device for me then? Is device core supposed to do it? > > Not device core, but the bus code. Look at how PCI handles it. IIRC, > only TI's omap_device behaves peculiarly WRT probe & pm runtime. PCI does it doesn't mean it is a rule that bus code has to enable the device before probe. At least platform bus doesn't seem to do it as part of of_platform_populate(). see __device_attach() and driver_probe_device() in drivers/base/dd.c It does a pm_runtime_get_sync() on dev->parent but not on dev. Also, from section 5 of Documentation/power/runtime_pm.txt "In addition to that, the initial runtime PM status of all devices is 'suspended', but it need not reflect the actual physical state of the device. Thus, if the device is initially active (i.e. it is able to process I/O), its runtime PM status must be changed to 'active', with the help of pm_runtime_set_active(), before pm_runtime_enable() is called for the device." "Note, if the device may execute pm_runtime calls during the probe (such as if it is registers with a subsystem that may call back in) then the pm_runtime_get_sync() call paired with a pm_runtime_put() call will be appropriate to ensure that the device is not put back to sleep during the probe. This can happen with systems such as the network device layer." So looks like we can't assume that the device is "active" when probe() is called. Which means, we need to do pm_runtime_get_sync(); enable optional clocks; pm_runtime_forbid(); if we don't yet want runtime suspend/resume. OR pm_runtime_put(); if we want runtime suspend/resume support. I don't think we should be calling pm_runtime_set_active() as we can't be sure of the initial state of the device for different buses. > >> The issue I was facing is that without this patch my device wasn't being enabled >> as pm_runtime_set_active() is being done _before_ pm_runtime_get_sync(). >> It could be an issue with the platform's PM domain code as well. > > Could be > -- cheers, -roger Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki