Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp255855rwb; Wed, 28 Sep 2022 02:10:24 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5jPAZNMvsK2St9muozZ3NkrCUFQFwaK6Fsf9N7Ss/qp7WGbuMFIZ22DeWZxMhduh9G3JgT X-Received: by 2002:a17:907:9619:b0:782:8016:f66f with SMTP id gb25-20020a170907961900b007828016f66fmr23656889ejc.766.1664356224351; Wed, 28 Sep 2022 02:10:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664356224; cv=none; d=google.com; s=arc-20160816; b=mSC4P8NXmCS/SHpzhuCjYh9raIfxBrJ82y1cR588rPl1XZuLLhQYlZzm2NpHBW5hYf eDbwIJfjJHWdE1zfam48yiPH//GOeh/VeU4HxO0EQUhtYJxqtFSyOF4lJ7/Qz5DtY0YP 7osL1xPIyEMF+xdEAdPZWYCqdSz3WwL1d7xjQJBp7AGUGanyGqQIwZZ8IZ0EG5ZF7ZlO JDlJ+R6uv/wTngotBg1fvwm8ONPky4Kp3XO9Pn0nD2lPgBesLjgY/5C47mdUHViuWt+e R3AZgzWj3P+b4k97Fls/40eCulB10+gON9RyTV3fmg7VKhm7cyBR9/oClb/LZsWIovql 3B4Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent:references:in-reply-to :subject:cc:to:from:message-id:date:dkim-signature:dkim-signature; bh=mbYysNXVCBJWhv6YmmbS+6PjzVtkQs9oliOscbllxFE=; b=yEbh3ngGucf9aBM07ejqc57d/JMR8MK2vxepbZocoOeDqiGO13pcUrdpZLlLFWGK0d fHgNLgKHJXzrdrIdGtXDma/6kKRJfQnTLwYtovN+OUx2vpnezsJ5/9l6/D3U98Q7W+w2 9BsxAZpZhXth8O2A86Xe14dDPRxNoFph64Ce9kVMUKh5GraB/yckm2USB8EoDp1OK0S4 yeUkIlBqqfcgDH+ay/6jexoP+y+BTTVwTq0nsVcXpfZBsJEUaBma2OSqKQauKGaq1P1G iTKjlxcTbZuiDUUHG8GIvmBc0JAX+DZXkPNyDTK3ZqxcSUWyVTfJ2oOCc+y4kmRQQTiy NO0A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=eDMs515c; dkim=neutral (no key) header.i=@suse.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id gt13-20020a1709072d8d00b0077bb3c728c5si4806770ejc.20.2022.09.28.02.09.58; Wed, 28 Sep 2022 02:10:24 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=eDMs515c; dkim=neutral (no key) header.i=@suse.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232667AbiI1IiD (ORCPT + 99 others); Wed, 28 Sep 2022 04:38:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50688 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233364AbiI1Ih2 (ORCPT ); Wed, 28 Sep 2022 04:37:28 -0400 Received: from smtp-out1.suse.de (smtp-out1.suse.de [IPv6:2001:67c:2178:6::1c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DE2079F8C7 for ; Wed, 28 Sep 2022 01:37:23 -0700 (PDT) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 93BFA21B20; Wed, 28 Sep 2022 08:37:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1664354242; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=mbYysNXVCBJWhv6YmmbS+6PjzVtkQs9oliOscbllxFE=; b=eDMs515cKj3b9Ip9kxDDvhsUX0I76y1Fal1frs4KOBWrfk/O604+G+12HGfzk3nCiL9LIK 05kb9uTO4roUPdGzNd2uPJGxQlIyTuW4nZQHbZOWTCtdPOuSp5VD3L8MNDVxxqNOfw1e+R zmjtciFKjXcJ0bPJJv3wocxxCDoBem4= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1664354242; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=mbYysNXVCBJWhv6YmmbS+6PjzVtkQs9oliOscbllxFE=; b=lviz9IDu4Ai/WKo0Pd4s7JmwQV3HANHJxat51OnnqMVn/AnE+Me/iFDP/+uyPPOgbOtPEQ Dt005eoB2W7uAkBg== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 5F25D13A84; Wed, 28 Sep 2022 08:37:22 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id inKPFsIHNGM0VwAAMHmgww (envelope-from ); Wed, 28 Sep 2022 08:37:22 +0000 Date: Wed, 28 Sep 2022 10:37:21 +0200 Message-ID: <87y1u3evy6.wl-tiwai@suse.de> From: Takashi Iwai To: "Lu, Brent" Cc: "alsa-devel@alsa-project.org" , "Jaroslav Kysela" , Takashi Iwai , Kai Vehmanen , Pierre-Louis Bossart , Mohan Kumar , Ville =?ISO-8859-1?Q?Syrj=E4l=E4?= , "Zhi, Yong" , "linux-kernel@vger.kernel.org" Subject: Re: [PATCH] ALSA: hda/hdmi: run eld notify in delay work In-Reply-To: <871qrvgbsr.wl-tiwai@suse.de> References: <20220927135807.4097052-1-brent.lu@intel.com> <87ill8gb5c.wl-tiwai@suse.de> <875yh8ezs9.wl-tiwai@suse.de> <871qrvgbsr.wl-tiwai@suse.de> User-Agent: Wanderlust/2.15.9 (Almost Unreal) Emacs/27.2 Mule/6.0 MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=US-ASCII X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 28 Sep 2022 10:09:40 +0200, Takashi Iwai wrote: > > On Wed, 28 Sep 2022 09:14:30 +0200, > Takashi Iwai wrote: > > > > On Wed, 28 Sep 2022 04:06:45 +0200, > > Lu, Brent wrote: > > > > > > > > > > > > > During resolution change, display driver would disable HDMI audio then > > > > > enable it in a short time. There is possibility that eld notify for > > > > > HDMI audio enable is called when previous runtime suspend is still > > > > > running. In this case, the elf nofity just returns and not updating > > > > > the status of corresponding HDMI pin/port. Here we move the eld nofity > > > > > to a delay work so we don't lose it. > > > > > > > > > > Signed-off-by: Brent Lu > > > > > > > > We have already a dedicated per-pin work for the delayed ELD check. > > > > Can we reuse it instead of inventing yet another work? > > > > More work needs more cares, and better to avoid unless really needed (e.g. > > > > you forgot cleanup at suspend/removal in this patch). > > > > > > > > > > > > thanks, > > > > > > > > Takashi > > > > > > Hi Takashi, > > > > > > I've checked the hdmi_repoll_eld() and check_presence_and_report() function to see > > > if we can reuse the per-pin work. I've some questions about reusing the per-pin work: > > > > > > 1. hdmi_repoll_eld() calls snd_hda_jack_tbl_get_mst() function while > > > check_presence_and_report() doesn't. Is it ok? > > > > For the system with the audio component, there is no jack entry, hence > > this will be ignored. > > > > > 2. snd_hdac_i915_set_bclk() is called in intel_pin_eld_notify() function. Since it's > > > skipped, we need to call it in the per-pin work. Need to add a flag in hdmi_spec_per_pin > > > to indicate this situation. > > > > Yeah, I guess this was already a bug. It implies that the set_bclk() > > call is missing in the suspend/resume case, too. We need to call it > > more consistently. > > > > > 3. We can schedule the per-pin work in intel_pin_eld_notify() when snd_hdac_is_in_pm() > > > returns true but there is no guarantee the runtime suspend will finished when the per-pin > > > work is schedule to run. > > > > On the second thought, we may simply proceed the notification if it's > > in a valid context. The only period to prohibit the update is during > > the suspend/resume until the ELD is updated by the resume itself. > > So, something like below may work instead. Could you give it a try? > > A correction in the patch, it still has to check in-pm state; > otherwise it won't be handled when runtime-suspended. ... and on the further consideration, I believe the best solution is to just get rid of the whole check. It was introduced by the commit eb399d3c99d8 along with the 8ae743e82f0b that checks the suspend state. The latter is still meaningful (we should skip the bogus notification at suspend). However, the former -- the code path we're dealing with -- doesn't help much in the recent code. That fix was required because the driver probed the ELD bits via HD-audio verb at the time of the fix commit; that is, the driver had to wake up the codec for updating the ELD. OTOH, now ELD is read directly from the graphics chip without the codec wakeup. So the skip makes little sense. The fix patch is below. Takashi -- 8< -- From: Takashi Iwai Subject: [PATCH] ALSA: hda/hdmi: Don't skip notification handling during PM operation The HDMI driver skips the notification handling from the graphics driver when the codec driver is being in the PM operation. This behavior was introduced by the commit eb399d3c99d8 ("ALSA: hda - Skip ELD notification during PM process"). This skip may cause a problem, as we may miss the ELD update when the connection/disconnection happens right at the runtime-PM operation of the audio codec. Although this workaround was valid at that time, it's no longer true; the fix was required just because the ELD update procedure needed to wake up the audio codec, which had lead to a runtime-resume during a runtime-suspend. Meanwhile, the ELD update procedure doesn't need a codec wake up any longer since the commit 788d441a164c ("ALSA: hda - Use component ops for i915 HDMI/DP audio jack handling"); i.e. there is no much reason for skipping the notification. Let's drop those checks for addressing the missing notification. Signed-off-by: Takashi Iwai --- sound/pci/hda/patch_hdmi.c | 6 ------ 1 file changed, 6 deletions(-) diff --git a/sound/pci/hda/patch_hdmi.c b/sound/pci/hda/patch_hdmi.c index c172640c8a41..21edf7a619f0 100644 --- a/sound/pci/hda/patch_hdmi.c +++ b/sound/pci/hda/patch_hdmi.c @@ -2666,9 +2666,6 @@ static void generic_acomp_pin_eld_notify(void *audio_ptr, int port, int dev_id) */ if (codec->core.dev.power.power_state.event == PM_EVENT_SUSPEND) return; - /* ditto during suspend/resume process itself */ - if (snd_hdac_is_in_pm(&codec->core)) - return; check_presence_and_report(codec, pin_nid, dev_id); } @@ -2852,9 +2849,6 @@ static void intel_pin_eld_notify(void *audio_ptr, int port, int pipe) */ if (codec->core.dev.power.power_state.event == PM_EVENT_SUSPEND) return; - /* ditto during suspend/resume process itself */ - if (snd_hdac_is_in_pm(&codec->core)) - return; snd_hdac_i915_set_bclk(&codec->bus->core); check_presence_and_report(codec, pin_nid, dev_id); -- 2.35.3