Received: by 2002:a05:6a10:2785:0:0:0:0 with SMTP id ia5csp188401pxb; Wed, 13 Jan 2021 00:43:21 -0800 (PST) X-Google-Smtp-Source: ABdhPJzTAbfWm97GMXf63ws5snzNae8FvOFgVKMqyCMPB2LdOTJcfYZGSqJpr3u1Nq4pFiAhjqYD X-Received: by 2002:a17:906:e94c:: with SMTP id jw12mr839737ejb.56.1610527401579; Wed, 13 Jan 2021 00:43:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610527401; cv=none; d=google.com; s=arc-20160816; b=wyRAjuNtsuCcnuNgd4J8ORrjTSvEaWPDPe0fYpW/zjv5dnnzDhvvd9Ct+MPz58lc3S XJ9V3lUHUuLIPmAEPtLSEuNKLynz/E8pGiGjAIr/TI+6P59k+g8WJ/RG4GWvBRApnzxZ rjzkBR86uQVKMPGyBW9Ur59XWny47p+uF0I7KKyFGvBbzBELqhu/WHEkkOrhUM+DWWpd euqQm3UDW6Uz30NWmzkTly4UPHE5uW0MbWC1bKxCRh1l6XWYv9Cc9PxMaK/86IvMfN28 dkIRDPAwTCOj6awa47UEBWVKO3kveZVBb03JtVRMAzP2IN0MWbRlIKkH7qK31VdLagrh R30w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:organization:user-agent:references :message-id:in-reply-to:subject:cc:to:from:date:ironport-sdr :ironport-sdr; bh=BjEYj8fHxG5MdJfdJC3cDcRsKNmE6y+W9n9NVfIQhbU=; b=dTOkUg2/XE8yYWaBkz2X6B+MtWixzoZbdsUxL4gen2LIdHPczYLdh/zj0OedLLCgv9 fbhruWhEkORhgeYiZbfrcDKdFeGOWhICDaaVzMHUt+EGDp37YYOB+r7Si2rDTYseCQNc O4TSVVw0kNC5rJf/2xUT6PlWedWvOvBrbG1MCuDjodNVPmi1cBrfJF5KSRBVP7wPbAG4 +HoD2JszBftF5atdk3wR9EUarPY7Ma1I6mvyiSCBuBK2Cb/Z3BtkTv7rmqXXarYnWnlt jsBWu+9vDOfiq4YhF4fFK/rXZ4Q4FZ2fdLsD5+yflWR+Lt76nuUBnmNEukayrD03vGvk 7j1Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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. [23.128.96.18]) by mx.google.com with ESMTP id bx26si675636edb.358.2021.01.13.00.42.58; Wed, 13 Jan 2021 00:43:21 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S1726657AbhAMIlV (ORCPT + 99 others); Wed, 13 Jan 2021 03:41:21 -0500 Received: from mga01.intel.com ([192.55.52.88]:56042 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726634AbhAMIlV (ORCPT ); Wed, 13 Jan 2021 03:41:21 -0500 IronPort-SDR: XNLsjDIDMZ0eVnkJ3oIFo3i5hF7tnrjl7WGxW/XVfRuN6LAjwIbSXbYstgZkRcgXoRhmklvMVi TX54H8FdF35A== X-IronPort-AV: E=McAfee;i="6000,8403,9862"; a="196807315" X-IronPort-AV: E=Sophos;i="5.79,343,1602572400"; d="scan'208";a="196807315" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Jan 2021 00:39:32 -0800 IronPort-SDR: y6c/uPMlHWU9i8L6dyLaduYNUjuU3S2kRoIXIr/sJfBiIbfWdEm4uJVPTAkDrACCwaLPpAaBUv FYPYQ0WaOB6A== X-IronPort-AV: E=Sophos;i="5.79,343,1602572400"; d="scan'208";a="353374255" Received: from eliteleevi.tm.intel.com ([10.237.54.20]) by fmsmga008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Jan 2021 00:39:28 -0800 Date: Wed, 13 Jan 2021 10:36:25 +0200 (EET) From: Kai Vehmanen X-X-Sender: kvehmane@eliteleevi.tm.intel.com To: Kai-Heng Feng cc: tiwai@suse.com, pierre-louis.bossart@linux.intel.com, lgirdwood@gmail.com, ranjani.sridharan@linux.intel.com, kai.vehmanen@linux.intel.com, daniel.baluta@nxp.com, "moderated list:SOUND - SOC LAYER / DYNAMIC AUDIO POWER MANAGEM..." , Kuninori Morimoto , Marcin Rajwa , broonie@kernel.org, Keyon Jie , open list , Payal Kshirsagar , "moderated list:SOUND - SOUND OPEN FIRMWARE SOF DRIVERS" Subject: Re: [PATCH v4 3/3] ASoC: SOF: Intel: hda: Avoid checking jack on system suspend In-Reply-To: <20210112181128.1229827-3-kai.heng.feng@canonical.com> Message-ID: References: <20210112181128.1229827-1-kai.heng.feng@canonical.com> <20210112181128.1229827-3-kai.heng.feng@canonical.com> User-Agent: Alpine 2.22 (DEB 394 2020-01-19) Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7 02160 Espoo MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, On Wed, 13 Jan 2021, Kai-Heng Feng wrote: > System takes a very long time to suspend after commit 215a22ed31a1 > ("ALSA: hda: Refactor codec PM to use direct-complete optimization"): [...] > [ 321.262505] snd_hda_codec_realtek ehdaudio0D0: Unable to sync register 0x2b8000. -5 > [ 328.426919] snd_hda_codec_realtek ehdaudio0D0: Unable to sync register 0x2b8000. -5 > [ 329.490933] ACPI: EC: interrupt blocked > > That commit keeps the codec suspended during the system suspend. However, > mute/micmute LED will clear codec's direct-complete flag by > dpm_clear_superiors_direct_complete(). thanks Kai-Heng. This indeed explains why the regression is only seen on some systems (those with mute/micmute LED). > This doesn't play well with SOF driver. When its runtime resume is > called for system suspend, hda_codec_jack_check() schedules > jackpoll_work which uses snd_hdac_is_power_on() to check whether codec The commit explanation is a bit long, but this is indeed the problem. jackpoll_work() is common code (also used by snd-hda-intel) and SOF should align to snd-hda-intel and not call this directly to check jack status, and especially not when going to system suspend. There are a lot of details related to exact conditions when this problem triggers, but in the end, this is the main point. > When direct-complete path is taken, snd_hdac_is_power_on() returns true > and hda_jackpoll_work() is skipped by accident. So this is still not > correct. This doesn't really affect correctness of the patch, but I'm not sure if "accident" is the best characterization. This just explains why the bug was not hit in all cases. snd_hdac_is_power_on() is called in a few places: - hda_jackpoll_work() - snd_hda_bus_reset_codecs() - snd_hda_update_power_acct() In first two, the current logic seems appropriate (if runtime-pm is disabled, the action guarded by is_power_on() should not be taken). The third case seems suspicious and not sure if current is_power_on() is appropriate. So it's not quite clear whether hdaudio.h:snd_hdac_is_power_on() is wrong or not. But that's now a separate discussion to have, and not related to this patchset anymore. > Because devices suspend in reverse order (i.e. child first), it doesn't > make much sense to resume an already suspended codec from audio > controller. So avoid the issue by making sure jackpoll isn't used in > system PM process. The commit explanation is a bit long, but it is probably useful to have the background included. For the whole series: Reviewed-by: Kai Vehmanen Br, Kai