Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp11855561ybi; Fri, 26 Jul 2019 00:40:29 -0700 (PDT) X-Google-Smtp-Source: APXvYqwr+cJwNaHaOgYMVvhnHo2C3b8fnCYTUq/jxwUkQSgJtgsbd1hf3Za2iJS0sHbH2F+CaiWN X-Received: by 2002:a17:902:934a:: with SMTP id g10mr96779015plp.18.1564126828959; Fri, 26 Jul 2019 00:40:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564126828; cv=none; d=google.com; s=arc-20160816; b=KQ59xZm3+6ngT4GqUsX6wETS8Uzvcw5W89bk+bgJs+La5fxjvMaJHv+Rm4s1Vb4/tH juQQq2f7QWGJ5go6aQPK/SYUMur9+EJpsvcpDz0JGQ6Gpuh1tvUIuTEGJJ0HM9RxKI4q Ej6p5r1fT+vKqHbNRI5WSCJZKFOK5uJT1TCWTI40qTm3KXKz5IdashtQdvuueePmfCji IfBnPDghJqTNP1EWKaMv70F7RMRJsZh+MO6otcjjac4nAfWdfIL4hDboBYTEVLAVsiZ8 uydESk5r00lkItXEVX+EY8w874kgrHbOGqt7aH92C3vRffw6kEFG1fNQYcj8/LyUZjSy SD5A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=5p4gKRrHWyghWpHFR0MTdNSSv+6s44rYt9hvgdn1Vwg=; b=XqvhGRo9zFUHtw78QsAzbHNgaP8a/NE+Kx7/ivMcQXgcLSoJiG6jj4sCZ4phzfxdcm 0HIIU6Zt8EDsh7FcqZ3x9IMGTv2ztd559VEX0mQSUnCbCGD2NTxbbMoL1oXraRcaD1R/ 9Au7SYu79tOj+jTyqIsE/BVVCEaqBlhb39OMjT5RYO3HHN0PNVfYMRfdWzvGegrC4Gnn fcKbOe765QKJpUmWUmUnWcQDNDnwYri21Q9nBOZ5DWGfs2zf8M/qlzImFNaNq9JtpuJ0 ibx3sG4ukitAFsn68IlkTpsPyv4ye+ko6PgMWXCbhHUCjT2B021pMQ/0wgdKirWea++A eUnw== 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 q15si18209067pgt.150.2019.07.26.00.40.12; Fri, 26 Jul 2019 00:40:28 -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 S1725983AbfGZHjg (ORCPT + 99 others); Fri, 26 Jul 2019 03:39:36 -0400 Received: from mga12.intel.com ([192.55.52.136]:18567 "EHLO mga12.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725867AbfGZHjg (ORCPT ); Fri, 26 Jul 2019 03:39:36 -0400 X-Amp-Result: UNKNOWN X-Amp-Original-Verdict: FILE UNKNOWN X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga106.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 26 Jul 2019 00:39:36 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.64,310,1559545200"; d="scan'208";a="198215227" Received: from gliakhov-mobl2.ger.corp.intel.com (HELO ubuntu) ([10.249.35.244]) by fmsmga002.fm.intel.com with ESMTP; 26 Jul 2019 00:39:33 -0700 Date: Fri, 26 Jul 2019 09:39:32 +0200 From: Guennadi Liakhovetski To: Pierre-Louis Bossart Cc: alsa-devel@alsa-project.org, tiwai@suse.de, gregkh@linuxfoundation.org, linux-kernel@vger.kernel.org, vkoul@kernel.org, broonie@kernel.org, srinivas.kandagatla@linaro.org, jank@cadence.com, slawomir.blauciak@intel.com, Sanyog Kale Subject: Re: [alsa-devel] [RFC PATCH 17/40] soundwire: bus: use runtime_pm_get_sync/pm when enabled Message-ID: <20190726073931.GE16003@ubuntu> References: <20190725234032.21152-1-pierre-louis.bossart@linux.intel.com> <20190725234032.21152-18-pierre-louis.bossart@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190725234032.21152-18-pierre-louis.bossart@linux.intel.com> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Pierre, I might be wrong but this doesn't seem right to me. (Supposedly) all RT-PM functions check for "enabled" internally. The only thing that can happen is that if RT-PM isn't enabled some of those functions will return an error. So, in those cases where the return value of RT-PM functions isn't checked, I don't think you need to do anything. Where it is checked maybe do + if (ret < 0 && pm_runtime_enabled(slave->bus->dev)) Thanks Guennadi On Thu, Jul 25, 2019 at 06:40:09PM -0500, 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); > > return ret; > } > @@ -359,13 +363,16 @@ int sdw_nwrite(struct sdw_slave *slave, u32 addr, size_t count, u8 *val) > slave->dev_num, SDW_MSG_FLAG_WRITE, 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); > > return ret; > } > -- > 2.20.1 > > _______________________________________________ > Alsa-devel mailing list > Alsa-devel@alsa-project.org > https://mailman.alsa-project.org/mailman/listinfo/alsa-devel