From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-0.8 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B9B28C33CB1 for ; Thu, 16 Jan 2020 09:21:52 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 4549E2073A for ; Thu, 16 Jan 2020 09:21:52 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=alsa-project.org header.i=@alsa-project.org header.b="vXxpEBXN" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4549E2073A Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=suse.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-devel-bounces@alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 6D62D17A4; Thu, 16 Jan 2020 10:21:00 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 6D62D17A4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1579166510; bh=BK3H546RMmCUcx0oVr7ns7aRydAqa2LanMkEQBaCN50=; h=Date:From:To:In-Reply-To:References:Cc:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=vXxpEBXN3neiFfvpiIyAFThB/XozYFHKpDXi6zInbDDmHiIX844Ndb5CeG1u4LksH Fm8+Auv7bLgV5+DC0+cxUyGYhK+8AupYROuHTkj+Ch7FiVo5UI4ZzVgqJEGd1+nt6u gAlNBz/eiRNB/weGH/yV84t/jaY5oqtB0wfo2BjU= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id D1DC4F8014D; Thu, 16 Jan 2020 10:20:59 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id CD9B5F8016F; Thu, 16 Jan 2020 10:20:57 +0100 (CET) Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 92A36F8014D for ; Thu, 16 Jan 2020 10:20:51 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 92A36F8014D X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 3522DAE7F; Thu, 16 Jan 2020 09:20:50 +0000 (UTC) Date: Thu, 16 Jan 2020 10:20:50 +0100 Message-ID: From: Takashi Iwai To: Jaska Uimonen In-Reply-To: References: 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") Cc: "Vehmanen, Kai" , "Uimonen, Jaska" , Linux-ALSA , "Sridharan, Ranjani" , Pierre-louis Bossart Subject: Re: [alsa-devel] Question about runtime PM for HDA codecs X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" On Thu, 16 Jan 2020 08:42:24 +0100, Jaska Uimonen wrote: > > On Thu, 2020-01-16 at 08:03 +0100, Takashi Iwai wrote: > > On Wed, 15 Jan 2020 21:28:20 +0100, > > Sridharan, Ranjani wrote: > > > [1 ] > > > > > > On Wed, Jan 15, 2020 at 11:40 AM Takashi Iwai > > > wrote: > > > > > > On Wed, 15 Jan 2020 19:15:40 +0100, > > > Sridharan, Ranjani wrote: > > > > > > > > Hi Takashi, > > > > > > > > Can I please bother you with a question about how to handle > > > the > > > situation > > > > with runtime PM for HDA codec on one of the Intel CML-based > > > platforms > > > with > > > > an ALC285 codec. > > > > Basically, the problem we're facing is that when using the > > > SOF driver, > > > > jack detection doesn't seem to work as intended because the > > > codec gets > > > > suspended right after the headset is plugged in. > > > > > > The codec going to the runtime suspend is actually the right > > > behavior. Even the bus goes down if the codec has > > > AC_PWRST_CLKSTOP > > > and AC_PWRST_EPSS capabilities, the link goes also down. But > > > this > > > means that the irq is still triggered upon the jack detection > > > event > > > even in D3 state. > > > I guess this implementation is missing in SOF DSP side. > > > > > > We do have the WAKEEN feature implemented in SOF for capturing the > > > jack > > > detecting events when the SOF device is in D3. We have this feature > > > working as > > > expected on some previous platforms. > > > > Which codec was it? > > > > > The problem specific to the ALC285 codec. > > > > AFAIK, there is no specific change to ALC285 that is relevant with > > runtime PM. > > > > > > > > After a bit of experimenting, what we found was that calling > > > > snd_hda_set_power_save() with a delay of 0 or something > 0, > > > both help > > > with > > > > fixing the problem. > > > > > > > > But, I have a basic question about this. What is the > > > expectation for > > > > enabling the codec runtime PM? > > > > I see that the legacy driver calls snd_hda_set_power_save() > > > based on the > > > > CONFIG_SND_HDA_POWER_SAVE_DEFAULT value. In the case of SOF, > > > we do not > > > > explicitly set this value so it is 0 by default. Also, when > > > the codec is > > > > registered, the runtime PM for the codec is enabled by > > > default without > > > > checking if the power_save delay is set to 0 or not. And > > > later when the > > > > snd_hda_set_power_save() is called from the legacy HDA driver > > > probe, it > > > > sets the use of auto suspend and the delay to be used based > > > on the > > > config. > > > > > > The runtime setup purely depends on the user's configuration. > > > As > > > default, kernel may set to certain value via Kconfig, and some > > > codecs > > > (e.g. HDMI) prefer the runtime PM enablement as default. Other > > > than > > > that, it's supposed to be set explicitly via sysfs, typically > > > from > > > udev rules. > > > > > > The driver initial code does set up some default value from > > > historical > > > reasons, but basically the setup is done from user-space. > > > > > > > Would it be correct to remove the pm_runtime_enable() call > > > > in snd_hda_codec_register() and let the codec runtime PM > > > enabling be set > > > > with the call to snd_hda_set_power_save() for both the legacy > > > HDA driver > > > > and the SOF driver? > > > > > > The basic problem isn't about how the runtime PM is set. It > > > can be > > > changed at any time, and the driver should work no matter how > > > it is > > > set. > > > > > > In this case then, I suppose it is up to the SOF driver to set the > > > auto > > > suspend delay to define the expected default behaviour? > > > > Yes and no. User can still set the value and the driver still needs > > to behave correctly no matter what value is set. > > > Takashi, AFAIK with legacy Intel HDA you are always setting > suspend_delay to 0 ("PM off") or some value in seconds. So I don't > even know how you would configure immeadiate suspend with legacy HDA. > > With SOF we we're able to cause this immediate suspend for the codec by > not calling any HDA delay setting function (sof probe vs. intel hda > probe). > > This has been working so far, but we noticed that Mic Jack detection > with some codecs didn't like this immediate suspend and we also got > some informal info from Realtek folks that the reason could be the > quick suspend. And indeed if I set HDA suspend delay from SOF > to SOF default 2s or 0 (PM off) the Mic Jack starts to work. OK, point taken. So the same problem could happen on the legacy HD-audio if user sets it up in that way. (You can still override the autosuspend_delay_ms value via sysfs after the driver setup.) > So setting the delay from SOF solves the Mic Jack issue, but there is > static "default power save" function in hda_intel.c, which involves > PM quirks and value set in CONFIG_SND_HDA_POWER_SAVE_DEFAULT. So I > would like to call this function and not duplicate the quirks in SOF > code. Not sure if these platforms in the quirks will ever run SOF > though... Yeah, that sounds feasible. It would be good if we can set the min value, but as far as I read the code, the runtime PM base code simply allows any value as is, so there is no way to set the lower limit. BTW, this reminds me of another similar topic: currently, most systems use power_save option and sysfs interface to adjust the runtime PM behavior dynamically. This feature will be lost on SOF. Though, nowadays there is little merit to disable power-saving and I don't know whether there is any requirement for this feature. thanks, Takashi _______________________________________________ Alsa-devel mailing list Alsa-devel@alsa-project.org https://mailman.alsa-project.org/mailman/listinfo/alsa-devel