Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp454973ybi; Fri, 26 Jul 2019 12:38:34 -0700 (PDT) X-Google-Smtp-Source: APXvYqx4dbNeiyRND1/ZMKjAZ//14Rv1AiABAjqFhrPNIbP6x4WG/2hm5m6ghaY0HB2bagutI5T7 X-Received: by 2002:a65:4189:: with SMTP id a9mr65980860pgq.399.1564169914316; Fri, 26 Jul 2019 12:38:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564169914; cv=none; d=google.com; s=arc-20160816; b=cZYrSoeDpgxXfY9NCwJCESl2VDZW6cOdLv2NDihimgwAkrBU8SMbelBLLftw6td0QA dKaIILoFL9EPUMYYEMTsnGB3M0wxi+EbjmMo1OfZKSkkxfwem0U7iyBfVb0J+ZISpk+3 6wJ+PX+Az56KwJ60HpVwrpUDLPBgweZTBOv0KJie45y3H/wegAk5fM67BHOWF3x6O0m4 xqUa6wwONAwyGL3mdEg9zdQYbE98YLcmqHMJC9jz23S3E4soZflaCozc/Mr0HekR6q3F gDkbHD5vWtm2Kw7rFANnZ8vofpHROx+Yjbw1EoSJISthBLFMDXfO5e32LYGlHck0iUuk Rh5A== 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:from:references:cc:to:subject; bh=qoS1t2zI1CeNmyIqQWkDMWVbSBiYPYHit5FOVh+8eh4=; b=TbCqGl7XRcE/x5aatnw5kX8+drI9fbUqzuaIqQeFqk3drMQydXUW10UNvTNPke/rVk um65zRrnUrl7Idlb4I2KkBiishOzWDjaPyvf0f3ngCqanYI9FwsTeCr1pH0DVcy/Pyyj ZqB/GLgjTPCpezS5NSigXPEpCjxL/qI5DB+GCFhRJNpY/FUQZIe/0m4jBCsmhZfIJosJ ew4NW4yOUMNUMTYETOnu4b2jqXCfG09wj7vmauEG+CIr8jb2SPPFqYtm6MgaZP8FtqVW MmxQ7aCeFHRgiFjBNF2qP0PASmHB5WikI1l3FTl2j3KDq3HAdKc1OlIUDOJh2axbfvVO O9NA== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t23si18151144pjw.56.2019.07.26.12.38.19; Fri, 26 Jul 2019 12:38:34 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729136AbfGZSI7 (ORCPT + 99 others); Fri, 26 Jul 2019 14:08:59 -0400 Received: from mga06.intel.com ([134.134.136.31]:13670 "EHLO mga06.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725899AbfGZSI7 (ORCPT ); Fri, 26 Jul 2019 14:08:59 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga104.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 26 Jul 2019 11:08:58 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.64,311,1559545200"; d="scan'208";a="198474640" Received: from andawes-mobl.amr.corp.intel.com (HELO [10.251.145.66]) ([10.251.145.66]) by fmsmga002.fm.intel.com with ESMTP; 26 Jul 2019 11:08:57 -0700 Subject: Re: [RFC PATCH 17/40] soundwire: bus: use runtime_pm_get_sync/pm when enabled To: alsa-devel@alsa-project.org Cc: linux-kernel@vger.kernel.org, tiwai@suse.de, broonie@kernel.org, vkoul@kernel.org, gregkh@linuxfoundation.org, jank@cadence.com, srinivas.kandagatla@linaro.org, slawomir.blauciak@intel.com, Sanyog Kale , "Rafael J. Wysocki" , Andy Shevchenko , linux-pm@vger.kernel.org References: <20190725234032.21152-1-pierre-louis.bossart@linux.intel.com> <20190725234032.21152-18-pierre-louis.bossart@linux.intel.com> From: Pierre-Louis Bossart Message-ID: <45a912c5-134b-8642-70ef-8c1060389300@linux.intel.com> Date: Fri, 26 Jul 2019 13:08:57 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 MIME-Version: 1.0 In-Reply-To: <20190725234032.21152-18-pierre-louis.bossart@linux.intel.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This thread became unreadable with interleaved top-posting, allow me restate the options and ask PM folks what they think On 7/25/19 6:40 PM, Pierre-Louis Bossart wrote: > Not all platforms support runtime_pm for now, let's use runtime_pm > only when enabled. > > Suggested-by: Srinivas Kandagatla > Signed-off-by: Pierre-Louis Bossart > --- > drivers/soundwire/bus.c | 25 ++++++++++++++++--------- > 1 file changed, 16 insertions(+), 9 deletions(-) > > diff --git a/drivers/soundwire/bus.c b/drivers/soundwire/bus.c > index 5ad4109dc72f..0a45dc5713df 100644 > --- a/drivers/soundwire/bus.c > +++ b/drivers/soundwire/bus.c > @@ -332,12 +332,16 @@ int sdw_nread(struct sdw_slave *slave, u32 addr, size_t count, u8 *val) > if (ret < 0) > return ret; > > - ret = pm_runtime_get_sync(slave->bus->dev); > - if (ret < 0) > - return ret; > + if (pm_runtime_enabled(slave->bus->dev)) { > + ret = pm_runtime_get_sync(slave->bus->dev); > + if (ret < 0) > + return ret; > + } > > ret = sdw_transfer(slave->bus, &msg); > - pm_runtime_put(slave->bus->dev); > + > + if (pm_runtime_enabled(slave->bus->dev)) > + pm_runtime_put(slave->bus->dev); This is option1: we explicitly test if pm_runtime is enabled before calling _get_sync() and _put() option2 (suggested by Jan Kotas): catch the -EACCESS error code ret = pm_runtime_get_sync(slave->bus->dev); - if (ret < 0) + if (ret < 0 && ret != -EACCES) return ret; option3: ignore the return value as done in quite a few drivers Are there any other options? I am personally surprised this is not handled in the pm_runtime core, not sure why users need to test for this? Thanks Pierre