Received: by 10.213.65.68 with SMTP id h4csp905890imn; Wed, 14 Mar 2018 03:55:19 -0700 (PDT) X-Google-Smtp-Source: AG47ELtFzSnl+1J9pUrk2K+i/kRJ4wS2v2rVqDKBrhvTBGQS3C8s7Mn+51xN/Uv9wte9FkOMhO+Z X-Received: by 10.98.161.10 with SMTP id b10mr3853858pff.240.1521024919107; Wed, 14 Mar 2018 03:55:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521024919; cv=none; d=google.com; s=arc-20160816; b=YBMf8wLISxdcWLq1nc5VvMQilX0Jz+XVkoIaOsFTO8o5qgrTUlF3EekY6c013ey6IN qh1P+awuv4iuTDnp8kVDyVQm4ki/8/OX+m32vESOQPj6XmAeIhGxQgiOrnIH7hYZKKKY fZC0TB1kmlAgnTVzbaEnJkbyNvzt8/SGBWbmMqei788R0bYgPcUYGMWUtKZodkzy9JQN nBeSGndYvd7jOWrZYKN8A925Oodi13YZeeEwV21JS+IWIGA2vBrbpsD3m+RtB/Mb0rlY nRrt8vQp/5Vnb1pVPWgN0Qyd1gR+IT3fHUR6ISSdNMAofBGv4i9Hf4i19RM1m1W7sjKM B1Kg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=Ak1E8kMY3l1yH61V+mNPNoKiCi5nhQ1KuwAydNiuOc0=; b=A5Lb+WXub1oMr2iGn+BJcs8Z7aJ3t75WBR0NlKJeWVYWon332nqkxy05rhLsarpBJI jDyNCKzpMreBIq5IAs9NUbxfUIGGpuFtWAkXE00tXS8AJBRdqNNVtgdk2CliFlK6sjK/ 1IqVMY/9z1x/p4YUfsaMulcf+QKnYU1K79H5MXxuUvHWpFrizvwUWCf1ORAKcboD7T3i zHdxrkFpYcCWDKYr4wT60QLTUdb/vuewWbINua3wRlrjB4RBTtYHBwmWMxcu3K7cjghq RvYX2WzPNLiFctYOrwo6s20oA+MTbOFNyGkAIyIQp/KSejcezrB0yo1O9HoQS39WlpHm E0kw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=uUP6i2pA; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v4-v6si1777762plb.179.2018.03.14.03.55.04; Wed, 14 Mar 2018 03:55:19 -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; dkim=fail header.i=@gmail.com header.s=20161025 header.b=uUP6i2pA; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751755AbeCNKyB (ORCPT + 99 others); Wed, 14 Mar 2018 06:54:01 -0400 Received: from mail-oi0-f65.google.com ([209.85.218.65]:38450 "EHLO mail-oi0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751440AbeCNKyA (ORCPT ); Wed, 14 Mar 2018 06:54:00 -0400 Received: by mail-oi0-f65.google.com with SMTP id t69so1630460oih.5; Wed, 14 Mar 2018 03:54:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=Ak1E8kMY3l1yH61V+mNPNoKiCi5nhQ1KuwAydNiuOc0=; b=uUP6i2pAy7t7R+shim1me8aa0tQ1H0xHmwlo+E9P0xhuQMmpmBYeT0RYhBYloSaWAl /ZkGFNPGY91kOeEtN4T5Grw6rE1VLbSqjP7plqV/O67kQHDqhZq2opudXFsQpA1Zp4Y4 ca2frfC4aihcGVsAy/w3jc+WFc9iBG6/jrBsH4OOOWeoq9ypKcAopm6j4BWnf4PElzA/ UxtMma4qAIq4I92WLpVhq4QK5KNLo5ce1rgUyHLF3wRLYwznsT2bN697Xh7ojpnTAVLJ DBkpRvTg5O1vKQVQvjpxiX+tXjtg0nokcz5zfgVLe4AQsFcIjF/0hOzzu6Qqc8QCl5FJ dZ1g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc; bh=Ak1E8kMY3l1yH61V+mNPNoKiCi5nhQ1KuwAydNiuOc0=; b=IvnUAO+ftoogDMI0uNk6LtDT3r6Gf4SOdwp/DJBFXPq5/Zr78DkIR8TZfAv/KYW4wA Yhi/wau4ayUL3XQYcTgLbTJxjleoarB8XyUrjSLiLg4lLOzMQLlatXIXblO0UPiIp+Hd MiVfWinyoL5Ak4l1GX64+8LcmHRxFqizYdfVfuerebcq9buTk5oCT8ikU2jsixVswr5A 1HYf1jIuN9XRN98AIvVB6Wt6UPFx3md0w27h/T8WhrakcoIikDvtqopXg/2zs2WfG3Kz 0FjqcrBLy5wxVQrFFEc3jv6y0ztOrMoVmqy9+qi8Zwid+umkuRjRAmcyT6TVb2WEa1ux 1K5A== X-Gm-Message-State: AElRT7GXNjEVwyKYl7qQcGMu1Q3BjmySeJzz+inv4rV3JIbSUGak+7in TL0ftCXL470j93K/q/sA3uvaFtPInGqExaJrYMM= X-Received: by 10.202.71.211 with SMTP id u202mr2560306oia.227.1521024839427; Wed, 14 Mar 2018 03:53:59 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a9d:2c92:0:0:0:0:0 with HTTP; Wed, 14 Mar 2018 03:53:58 -0700 (PDT) In-Reply-To: <5aa8fbe9.4251620a.c3daa.3711SMTPIN_ADDED_BROKEN@mx.google.com> References: <1520853467-31653-1-git-send-email-anshuman.gupta@intel.com> <5aa8fbe9.4251620a.c3daa.3711SMTPIN_ADDED_BROKEN@mx.google.com> From: "Rafael J. Wysocki" Date: Wed, 14 Mar 2018 11:53:58 +0100 X-Google-Sender-Auth: HCXBTnS_zm_4bnJdOhJcHv6Sfk4 Message-ID: Subject: Re: [PATCH] [sound] hdac-codec runtime suspended at PM:Suspend. To: Anshuman Gupta Cc: "Rafael J. Wysocki" , Liam Girdwood , Mark Brown , Jaroslav Kysela , Takashi Iwai , "moderated list:SOUND - SOC LAYER / DYNAMIC AUDIO POWER MANAGEM..." , Linux Kernel Mailing List , Linux PM Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Mar 14, 2018 at 11:38 AM, Anshuman Gupta wrote: > On Mon, Mar 12, 2018 at 12:26:53PM +0100, Rafael J. Wysocki wrote: >> On Mon, Mar 12, 2018 at 12:17 PM, Anshuman Gupta >> wrote: >> > Keep hdac-codec to be in runtime suspended while entering to suspend. >> > If hdac-codec is already in runtime suspend state skip its power down >> > sequence in prepare, power up sequence in complete phase. >> > >> > Avoid resuming hdac controller PCI device 00:1f.3 from runtime suspend >> > state in case hdac-codec already in runtime-suspend state, this is >> > unnecessary and block the direct complete even for hdac controller >> > PCI device 00:1f.3. >> > >> > This enabled direct complete path for hdac-codec and PCI device 00:1f.3. >> > >> > Signed-off-by: Anshuman Gupta >> > --- >> > sound/soc/codecs/hdac_hdmi.c | 4 ++++ >> > 1 file changed, 4 insertions(+) >> > >> > diff --git a/sound/soc/codecs/hdac_hdmi.c b/sound/soc/codecs/hdac_hdmi.c >> > index f3b4f4d..810a8a6 100644 >> > --- a/sound/soc/codecs/hdac_hdmi.c >> > +++ b/sound/soc/codecs/hdac_hdmi.c >> > @@ -1852,6 +1852,8 @@ static int hdmi_codec_prepare(struct device *dev) >> > struct hdac_ext_device *edev = to_hda_ext_device(dev); >> > struct hdac_device *hdac = &edev->hdac; >> > >> > + if (pm_runtime_status_suspended(dev)) >> > + return 1; >> >> This is racy in principle, because the runtime PM status can still >> change after you've checked here. > Will using pm_runtime_disable/pm_runtime_enable for safe check of runtime > status avoids this race? It might help, but is this a leaf device or does it have children? >> But even if it isn't racy in practice, the following >> pm_runtime_get_sync() becomes redundant after it, doesn't it? > I have no idea but if there can be a case that PCI 00:1f.3 (hdac controller) > is runtime suspended and hdac hdmi codec is active, in that case it may be > required to use pm_runtime_get_sync() for hdac controller as it is parent of > hdac hdmi codec. >> >> > pm_runtime_get_sync(&edev->hdac.dev); >> > So it sounds like you need the "get" part, but you don't need the "sync" one, because you've just checked that the device is not suspended. I guess the idea is to return 1 for the direct-complete mechanism to kick in if the device is already suspended, but otherwise bump up its reference counter to prevent it from suspending going forward, right? >> > /* >> > @@ -1873,6 +1875,8 @@ static void hdmi_codec_complete(struct device *dev) >> > struct hdac_hdmi_priv *hdmi = edev->private_data; >> > struct hdac_device *hdac = &edev->hdac; >> > >> > + if (pm_runtime_status_suspended(dev)) >> > + return; >> >> That, again, is somewhat fragile from the concurrency perspective. >> And here you want to avoid the below if the device is still suspended. Why is the below code located in the ->complete callback anyway? Shouldn't it be there in the ->resume one? >> > /* Power up afg */ >> > snd_hdac_codec_read(hdac, hdac->afg, 0, AC_VERB_SET_POWER_STATE, >> > AC_PWRST_D0); >> > -- >> > 2.7.4