Received: by 10.213.65.68 with SMTP id h4csp1114242imn; Mon, 26 Mar 2018 00:31:56 -0700 (PDT) X-Google-Smtp-Source: AG47ELv2RtbNuW08mOV/3eJnldkkCMd9b3tmzLC2H7yYSCiq1R8WQs/SYA3AW7/bHU3BxLovF6DY X-Received: by 2002:a17:902:2d24:: with SMTP id o33-v6mr26486832plb.143.1522049516853; Mon, 26 Mar 2018 00:31:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522049516; cv=none; d=google.com; s=arc-20160816; b=ruzmQyihLXP6kGSGaUK1cAfVEmIjAeOqmAwZ2NXhmqg+XSsch++1KkJHKHd30xirRn mlskw43vbs5yg+YWOyuyXKONO25j+V/8o90YRaBZlBzcXK8/xKBVXpXRCztFO669hxWv F5Wsmj6iT9zvHFlQtfMc5lNu1m5u0Wa9Me0FlFnPqanxOE8dYFdfPXYbXI+H8L5rUU8x IDWGWdANVulWKPEY2W8P+e4RCMl+8m+lOry8VqQlDqpj/46aNHEj0p97eFDzLUd5IFHW Jk9p+8u9wR4CjMZIgo/dRcaZxPLycP8ivRRywynaXnzuJi94YaghNs3CYpSfN9LwmxaP n2Cg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:subject:cc:to:from:message-id:date :arc-authentication-results; bh=UeH0YC5FA2NUNX4wgCwOkZ98WD7zInWJ506w/eRfvEg=; b=IKjgZWLmgwI4gfXMqGXWxHDrfSU3EA+ABExEPurygvRFVGhUoykmmS04kZPxAFMmOh i61Qpe2/k0pob62YrVUZ8cB7N0WrVlcaTKQqukkdJF3b17AN9meq+jglmOXfUoHx4Ga8 PkVdxFfhtXz7eRAF2JCZREza5Ifq4gZvUUggl5veInZkd7yD1qda8zlZVzgQ656IaSkE 7SrdsUXOecNokca07GEjmv16XrjKY/lGZR0Zb0rsnWc4RVLMmeJwI32Ip4MH8etNebKq OQFjK/xVsQu17EPxM0MFFpz/OMyQaGYufNFkhjewPtR0CFuU2BurjeLhjgD9bCkvF05R 2m7Q== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j13si9988003pgt.402.2018.03.26.00.31.39; Mon, 26 Mar 2018 00:31:56 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751752AbeCZHan (ORCPT + 99 others); Mon, 26 Mar 2018 03:30:43 -0400 Received: from mx2.suse.de ([195.135.220.15]:59429 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750973AbeCZHai (ORCPT ); Mon, 26 Mar 2018 03:30:38 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 8215CADE3; Mon, 26 Mar 2018 07:30:36 +0000 (UTC) Date: Mon, 26 Mar 2018 09:30:36 +0200 Message-ID: From: Takashi Iwai To: " Subhransu S. Prusty " Cc: "Anshuman Gupta" , "moderated list:SOUND - SOC LAYER / DYNAMIC AUDIO POWER MANAGEM..." , "Liam Girdwood" , "Mark Brown" , "Rafael J. Wysocki" , "Jaroslav Kysela" , "Linux Kernel Mailing List" , "Linux PM" Subject: Re: [PATCH] [sound] hdac-codec runtime suspended at PM:Suspend. In-Reply-To: <20180326070349.GA14895@subhransu-desktop> References: <1520853467-31653-1-git-send-email-anshuman.gupta@intel.com> <5aa8fbe9.4251620a.c3daa.3711SMTPIN_ADDED_BROKEN@mx.google.com> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI/1.14.6 (Maruoka) FLIM/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL/10.8 Emacs/25.3 (x86_64-suse-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 26 Mar 2018 09:03:55 +0200, Subhransu S. Prusty wrote: > > On Thu, Mar 15, 2018 at 09:02:30PM +0530, Anshuman Gupta wrote: > > On Thu, Mar 15, 2018 at 04:12:44PM +0530, Subhransu S. Prusty wrote: > > > On Wed, Mar 14, 2018 at 09:07:14PM +0530, Anshuman Gupta wrote: > > > > On Wed, Mar 14, 2018 at 11:53:58AM +0100, Rafael J. Wysocki wrote: > > > > > 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: > > > > > >> > > > > > > >> > + 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. > > > > Yes, if we do not avoid the code below, complete callback takes about > > > > 3 seconds due to snd_hdac_codec_read timed out because hdac controller > > > > would be in runtime suspend state. > > > > > > > > > > Why is the below code located in the ->complete callback anyway? > > > > > Shouldn't it be there in the ->resume one? > > > > > > > > > Yes even i am also having same doubt, why these power down and power up > > > > sequences are part of prepare and complete callback. > > > > Adding driver author "Subhransu S. Prusty" to provide more inputs on this. > > > > > > This driver needs a late resume as it receives a jack notification from the > > > i915 driver and the skl controller driver resume may not have happened and > > > in turn hda controller may not ready. This ensures a synchronization for > > > jack event during resume from S3. > > Let me give you insight of the issue, this driver blocks the direct complete > > of hda controller PCI 00:1f.3, sometimes it takes 280ms to resume hda controller > > from S3 and s2idle. So it does not make sense to suspend/resume hda controller > > when it is already in runtime suspend. > > I get it now. I think this patch needs rework to address both the issues. > > > > > > > I think this patch defeats the purpose. > > Here in this case PCI driver may kick the direct complete for hda controller > > https://elixir.bootlin.com/linux/latest/source/drivers/pci/pci-driver.c#L691 > > But hdac hdmi codec driver is blocking it. > > So i think it will be ok to keep this codec and hda controller in runtime > > suspend while entering S3 or s2idle, both can resume by runtime PM as well, > > will it brake any audio functionality? > > There was some PM and jack detection issues (I don't recollect now) because > of which this was added. This was due to the gfx display power and hda > controller synchronization. The rework may be required in both hdac_hdmi > and skylake drivers. If it's about the power well issue, it had been fixed in multiple ways. In i915 side, every relevant component callback is wrapped with power domain get/put. And, at least HD-audio legacy side, such a spurious notification is filtered out in the eld notifier: static void intel_pin_eld_notify(void *audio_ptr, int port, int pipe) { .... /* skip notification during system suspend (but not in runtime PM); * the state will be updated at resume */ if (snd_power_get_state(codec->card) != SNDRV_CTL_POWER_D0) return; /* ditto during suspend/resume process itself */ if (atomic_read(&(codec)->core.in_pm)) return; snd_hdac_i915_set_bclk(&codec->bus->core); check_presence_and_report(codec, pin_nid, dev_id); } Last but not least, the jack state is explicitly updated via reading the ELD at resume callback. In that way, we can live with the standard suspend/resume procedure. Takashi