Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp11897605ybi; Fri, 26 Jul 2019 01:25:37 -0700 (PDT) X-Google-Smtp-Source: APXvYqy1UrMCMnBzGZYBZuOQtZrg+ONzVtNN0xfvsjwAbrgHtWV4n04ELYh4S9IJxTiyoNn5rn5m X-Received: by 2002:a17:90a:8d86:: with SMTP id d6mr96497936pjo.94.1564129537253; Fri, 26 Jul 2019 01:25:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564129537; cv=none; d=google.com; s=arc-20160816; b=V/l15xBU/UkyxMIDm36lG7CFG9pdtxP/zbvH2DM0Ww10bBGdQc4Q4QP5QYJiWwkiGT HE2p6YKZaU5cu7u1ZQVZruTPIvaFVvrangWZL1UQdCZtqXPlYiEQYD4E7Lr66Zze5Zff EwlDsew/sS0PjWAZKvW1qpV6+sxDmELqRnh/1zyLcsFcTQoZ2JInh7+sjiih06by3R24 cHRipH8qoqe94NmH4Ccdc4Uc91sNhYYXgfyrcTVt6/weKEMMYRdeJB9N5UpJ2FySiU90 KEsH+vcW8qyrp0RcDeztIXlHMgblsIJv6qRL88aM/LstudEOKopjgk7vqj0uesUNONkX 4pQw== 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=zS+WmpIFFbF//3r9dj6LTtnQ0QYwXJbjYdmC52WAf9c=; b=v0DzlJYGteQae1paWq+o0+GdzWR74tmuPxkZc5/fFzmrz3eV2vr6DLqf6ppogyqzaA uGLTC0hy4i5RAHcI+R2dVLUuffCRxtD+R8pjrvXiUcJg5HK7kF9km9JYIykWq6Ye62jc h8HL3GthAX3eOwpTN25VcMyFtNnCjyZM4r44TdmBbcQd3rECtKn3ts5ddlPQLLMb/4Id q4tFKSDvX6gVwSbtdHPMktb7QrZIKrbZJuD1ovkU5JJBR7cM883RKVF/3K8+pR1L8kjf vGzZSHxQUB+X0upnSr8p/hCcIMSJiLkBhAFUMPdxFhCjjnMChWIy8vF7kzc810Lz50eQ laTg== 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 a190si20700797pgc.25.2019.07.26.01.25.22; Fri, 26 Jul 2019 01:25:37 -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 S1726349AbfGZIXG (ORCPT + 99 others); Fri, 26 Jul 2019 04:23:06 -0400 Received: from mga02.intel.com ([134.134.136.20]:17846 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725815AbfGZIXF (ORCPT ); Fri, 26 Jul 2019 04:23:05 -0400 X-Amp-Result: UNKNOWN X-Amp-Original-Verdict: FILE UNKNOWN X-Amp-File-Uploaded: False Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 26 Jul 2019 01:23:04 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.64,310,1559545200"; d="scan'208";a="254256631" Received: from gliakhov-mobl2.ger.corp.intel.com (HELO ubuntu) ([10.249.35.244]) by orsmga001.jf.intel.com with ESMTP; 26 Jul 2019 01:23:00 -0700 Date: Fri, 26 Jul 2019 10:22:59 +0200 From: Guennadi Liakhovetski To: Jan Kotas Cc: "alsa-devel@alsa-project.org" , "tiwai@suse.de" , "gregkh@linuxfoundation.org" , Pierre-Louis Bossart , LKML , Vinod Koul , Mark Brown , Srinivas Kandagatla , "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: <20190726082258.GF16003@ubuntu> References: <20190725234032.21152-1-pierre-louis.bossart@linux.intel.com> <20190725234032.21152-18-pierre-louis.bossart@linux.intel.com> <20190726073931.GE16003@ubuntu> <716D5D19-D494-4F4E-9180-24CB5A575648@global.cadence.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <716D5D19-D494-4F4E-9180-24CB5A575648@global.cadence.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 Jan, On Fri, Jul 26, 2019 at 07:47:04AM +0000, Jan Kotas wrote: > Hello, > > I while back I proposed a patch for this, but it went nowhere. > > https://patchwork.kernel.org/patch/10887405/ > Maybe something similar can be implemented? Yes, I was thinking about checkint -EACCESS too, but then I noticed this code in rpm_resume(): else if (dev->power.disable_depth == 1 && dev->power.is_suspended && dev->power.runtime_status == RPM_ACTIVE) retval = 1; i.e. if RT-PM is disabled on the device (but only exactly once?..) and it's active and the device is suspended for a system suspend, the function will return 1. I don't understand the logic of this code, but it seems to me it could break the -EACCESS check? Thanks Guennadi > Jan > > > On 26 Jul 2019, at 09:39, Guennadi Liakhovetski wrote: > > > > EXTERNAL MAIL > > > > > > 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://urldefense.proofpoint.com/v2/url?u=https-3A__mailman.alsa-2Dproject.org_mailman_listinfo_alsa-2Ddevel&d=DwIBAg&c=aUq983L2pue2FqKFoP6PGHMJQyoJ7kl3s3GZ-_haXqY&r=g7GAQENVXx_RQdyXHInPMg&m=vETGQLSPeGb7K_ZsXv4Tl3VFfdXzyummTDga97ozJcg&s=LiW4SToh5U0zhnkox54oRhJ1u3vFNbBB9nmzRDuCDjI&e= > > _______________________________________________ > Alsa-devel mailing list > Alsa-devel@alsa-project.org > https://mailman.alsa-project.org/mailman/listinfo/alsa-devel