Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp3170042yba; Mon, 8 Apr 2019 12:40:38 -0700 (PDT) X-Google-Smtp-Source: APXvYqyeVVy+nWD+oWc3XdK+LqKkzWsga5xOtKBfEQPwWgy1x0GRdfFsDYHQM+W36Z4ud7aWBnOR X-Received: by 2002:a63:e445:: with SMTP id i5mr30104012pgk.383.1554752438111; Mon, 08 Apr 2019 12:40:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554752438; cv=none; d=google.com; s=arc-20160816; b=doDu6bNIqE3S6W/AHb62mVMifF37pt422Ylcos740b9rK4KnPV0MDezhjPCw3cFauz 96Hu2658DQcakcTKH1k08IR3bzCqrTgAMR9h7eQI4OUvFhm52D4cBSCVkevadcyGsTiC 0i9RBYCz596terKOehC6EKF1ctQrLSJ2lQ04W8Bn4DI/j+ZtYAyns2TEn2ZzzNBKvHyg C4kLpNjMEPfFdNmt8dpFd3p94dKjXffd/LiMpgc8ZwomDfXrAm7Pu6HF2MJLyJAJwKyI wTaq+re62ZenxRna9zjXwiLoB+03jGFrmnUgVDgvJcuo2rJRLLd9JzRq4K6Fw+LH92G3 9/3g== 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=OJEJjoWIZZsSqpjOZECgS/3IxKu9jak0TiHyKu5ll3I=; b=fi5qH6fWYDeCFWfEkarOOkX28nrIRJ8rNSW5Eg1KpmTZ/bhYnX4PNdDeHU/u+Ikrvk lloRJsiCekfxBS60DSWjpvjXbiFcjn7gFAXFEYjOupst+47oaYrT4GC6t8+1xmPbIVfQ OtVlsq7FIvKHmesYxECNquXv7kMQNUhIabF8UKJL3/fEAqjd4QdCD7NOWsdr/HCe/Aew tgWkVVYFwdri4yBZ975i/XMiFTfVLJKLhz0r5DfLkjcBJBDqEl4f++d7g9nuOuT5TzY5 fpyVtTpEpXof4ARJDsdLH7iH6sit+IeBZ1W39fPDNIr85D978n7PcOD19YY39zpXVYay ixPA== 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 r15si10833293pfn.4.2019.04.08.12.40.22; Mon, 08 Apr 2019 12:40:38 -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 S1727334AbfDHSXT (ORCPT + 99 others); Mon, 8 Apr 2019 14:23:19 -0400 Received: from mga04.intel.com ([192.55.52.120]:56792 "EHLO mga04.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726369AbfDHSXT (ORCPT ); Mon, 8 Apr 2019 14:23:19 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 08 Apr 2019 11:23:14 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.60,326,1549958400"; d="scan'208";a="147550354" Received: from wfang3-mobl.amr.corp.intel.com (HELO [10.254.107.245]) ([10.254.107.245]) by FMSMGA003.fm.intel.com with ESMTP; 08 Apr 2019 11:23:13 -0700 Subject: Re: [alsa-devel] [PATCH] soundwire: fix pm_runtime_get_sync return code checks To: Jan Kotas Cc: "alsa-devel@alsa-project.org" , "linux-kernel@vger.kernel.org" , "vkoul@kernel.org" , Srinivas Kandagatla , "sanyog.r.kale@intel.com" References: <20190405072655.25995-1-jank@cadence.com> <367316fa-9d92-2dfc-32c4-3e0e8c76ef43@linux.intel.com> <92538D7E-C628-40AC-AFE9-52C97B3BC42D@global.cadence.com> From: Pierre-Louis Bossart Message-ID: Date: Mon, 8 Apr 2019 12:43:47 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1 MIME-Version: 1.0 In-Reply-To: <92538D7E-C628-40AC-AFE9-52C97B3BC42D@global.cadence.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 On 4/8/19 2:12 AM, Jan Kotas wrote: > > >> On 5 Apr 2019, at 17:04, Pierre-Louis Bossart wrote: >> >> On 4/5/19 2:26 AM, Jan Kotas wrote: >>> >>> >>> ret = pm_runtime_get_sync(slave->bus->dev); >>> - if (ret < 0) >>> + if (ret < 0 && ret != -EACCES) >>> >> There was a patch submitted on 3/28 by Srinivas Kandagatla who suggested an alternate solution for exactly the same code. >> >> + if (pm_runtime_enabled(slave->bus->dev)) { >> + ret = pm_runtime_get_sync(slave->bus->dev); >> + if (ret < 0) >> + return ret; >> >> I am far from an expert on pm_runtime but Srinivas' solution looks more elegant to me. > > Hello Pierre, > > Please take a look at this patch, that was my inspiration: > https://lists.linuxfoundation.org/pipermail/linux-pm/2011-June/031930.html The two patches seems to be identical: static inline bool pm_runtime_enabled(struct device *dev) { return !dev->power.disable_depth; } static int rpm_resume() [...] else if (dev->power.disable_depth > 0) retval = -EACCES; However I am still not clear on why this might fail. I can only think of one possible explanation: there is no explicit pm_runtime_enable() in the soundwire code, so maybe the expectation is that the pm_runtime status is inherited from the parent (in the intel case the PCI driver), and that's missing in non-intel configurations? > I also took a look, and it seems the value returned by > pm_runtime_get_syncis simply ignored in a lot of places, > so checking its value may be excessive. But not checking seems careless at best...