Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp592723ybi; Fri, 26 Jul 2019 15:31:14 -0700 (PDT) X-Google-Smtp-Source: APXvYqy12pUbT4C16msrboQouG06aSY3GMV6L2B9BYhMEMWun0K+Wqh9DeUrPrRQQdXJ7aAsWKO3 X-Received: by 2002:a62:2c8e:: with SMTP id s136mr24869426pfs.3.1564180274613; Fri, 26 Jul 2019 15:31:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564180274; cv=none; d=google.com; s=arc-20160816; b=XpP1USddt58XT9S3rpK8HH7FBXwwmkE7EY4xbVb8u3H0VsZ8fq5fzLK9CWNVgRKdXJ g4kVUapalyx9Jsbep9N/bJxEA1Q8IWDTeugkaBWGSuyce+dFKQunj1l4fLSWaRvbiMUX w9vNYOO0g6AB2flVkafctYdU3wKPl2Gomtx6Mrt3eBh3gOS/kfIixC/4yS9sxyEQNRlx 2smtwJEUjt3/47eqvQPFcGsGsjK8/BNV0EEdZ0pYxTT9qdaf9/q8FmfK9Z77+UQivUAk TNqJzNxSG8J8g2o4NiSADhVOvhTA36Xv8lPUDrKWwp2o6g3JKQSJCwG4hKthkre8tE67 yKCA== 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=ZHEy5VRN4syEwxXiNET6giElAdh4plSPnn5HxX7P7Gs=; b=KFRV+whxQNi50XqLjRukDUBjXv7ADei9pwaDYtZUWAYe50848Z49KEIKyYHs7VLS38 yn+vwOvk+ZOd6xQeLMmXTLUvBPmGrZ1TcGQr+6n7pmfpVBxX6wBpfY2xjB1kZXLIw9RV bGKQyuGfQ91IBobCIfZfeNzS0lmFUJQm5fzHx/RHajC4KL56x5+mBvThaI3rUFhnVoT9 9dWhiv9ySzVrbphMS9ZL536wUfJ1fLJ5S0pOwhF/Cv3RBfj++AHI6boRXreX193gEd9x aaReW1G0g7jU6pbb+EOjXCqUejnjG6MAR9Cv0BNfSwcBXWSYNlo1XtThSN25INpdLKV+ iWnQ== 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 f15si19479603plr.260.2019.07.26.15.30.58; Fri, 26 Jul 2019 15:31:14 -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 S2387645AbfGZSZm (ORCPT + 99 others); Fri, 26 Jul 2019 14:25:42 -0400 Received: from mga17.intel.com ([192.55.52.151]:44335 "EHLO mga17.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727935AbfGZSZj (ORCPT ); Fri, 26 Jul 2019 14:25:39 -0400 X-Amp-Result: UNKNOWN X-Amp-Original-Verdict: FILE UNKNOWN X-Amp-File-Uploaded: False Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga107.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 26 Jul 2019 11:25:39 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.64,311,1559545200"; d="scan'208";a="370158312" Received: from gliakhov-mobl2.ger.corp.intel.com (HELO ubuntu) ([10.249.35.244]) by fmsmga006.fm.intel.com with ESMTP; 26 Jul 2019 11:25:36 -0700 Date: Fri, 26 Jul 2019 20:25:35 +0200 From: Guennadi Liakhovetski To: Pierre-Louis Bossart Cc: alsa-devel@alsa-project.org, "Rafael J. Wysocki" , tiwai@suse.de, gregkh@linuxfoundation.org, linux-pm@vger.kernel.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 , Andy Shevchenko Subject: Re: [alsa-devel] [RFC PATCH 17/40] soundwire: bus: use runtime_pm_get_sync/pm when enabled Message-ID: <20190726182534.GO16003@ubuntu> References: <20190725234032.21152-1-pierre-louis.bossart@linux.intel.com> <20190725234032.21152-18-pierre-louis.bossart@linux.intel.com> <45a912c5-134b-8642-70ef-8c1060389300@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <45a912c5-134b-8642-70ef-8c1060389300@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 On Fri, Jul 26, 2019 at 01:08:57PM -0500, Pierre-Louis Bossart wrote: > 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? option 4: fix this in runtime PM :-) This seems like the best option to me, but probably not the easiest one. Otherwise I'd go with (2), I think, since that's also the official purpose of the -EACCESS return code: https://lists.linuxfoundation.org/pipermail/linux-pm/2011-June/031930.html Thanks Guennadi