Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp1061675rwb; Tue, 27 Sep 2022 08:00:13 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7iVrWiflLXYKYwcj0gbT56y+sMtXR0jZhEqr7CCAHbjNiD17GL7cys9kBisG+E46Csty1N X-Received: by 2002:a17:906:847b:b0:773:db0f:d533 with SMTP id hx27-20020a170906847b00b00773db0fd533mr23599319ejc.0.1664290813249; Tue, 27 Sep 2022 08:00:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664290813; cv=none; d=google.com; s=arc-20160816; b=m7oiFe9kwcCyqOoPBwBWxNbH3Eqesb1oS/VzKOqUfAFJdXZOgVE18yC4S4Wvq5gIWm Pk/wPSGwAgwqJnupo6/bU/sSfgVg9bIfhB2Fu5fad6GST3I18Wpwy6qDnYH02Q2e1yJJ yLaCqCIwGmdLZ2h9QJdFqyxZGQLBhlIM0xYYa+7RC08nUMyr1v/59jYMREH9xKJ5qzOe 4Zl/e6DUMPn7eU62xVNx5l04XrMYKHqJKhiCOqIz4V8gmy0HsYGHcYu3qyc9fRJq+VX/ rOLgJnhR+cu1ROKdRpp0VFyepRYg5eubICqdeUsU8/uy7oBqIYUrItFX3s5/Ws526EBS 2Vbg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=agSTYjJUJBXsRlSGSur+AOgur5CIbsNH1grlLGzw6Zw=; b=Wn62ZN66zCsRvRusfxtSGLuyLr1STFO8rra1gu4PSDJ2AZYFtgHTdUFAeN0WjwyWDf vIcOgi4ikA6Ixf623gBP2WiVvXR9T7t1fge9Xiu7YPL9CH2Ygy7wrrblrSkJgdnJWCg2 0pLOhq47MsT/9CBcqbLBwdcWjwi+C5WnuXLcYB0bYbK6ymiHDlkv/uWKh66/9w1Qde/q o+bF47hdbIrntEY/n0myYvPfhTZn4AfaxqSVx00o8RFNW0+TPdMkdZDILeX1askJKEYa o8JcZswseKkCo1htXoqpb49D6JSszcQHIXEgGcDRhL/Bs/5aAshw6mLevGc46R1A2P7n CYKg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=Ns8YpL9M; 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=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id hs41-20020a1709073ea900b007828388864dsi1647468ejc.692.2022.09.27.07.59.46; Tue, 27 Sep 2022 08:00:13 -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=@intel.com header.s=Intel header.b=Ns8YpL9M; 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=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232971AbiI0OAw (ORCPT + 99 others); Tue, 27 Sep 2022 10:00:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56934 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233010AbiI0OAX (ORCPT ); Tue, 27 Sep 2022 10:00:23 -0400 Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 113B06DAE4 for ; Tue, 27 Sep 2022 06:59:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1664287184; x=1695823184; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=ZXrmu/PunYDe1xIi4jB5rE+3PR+QFCMY2cJy+0qk9sE=; b=Ns8YpL9MPL/E+gzlIW7Nh/yMhxg6NO0UbBhSNWthjH2VxjNmIfgBCJC8 QQjbBbA401YNO2nFcP3GgsU2Qw3eKqQR7579AlWElU/J2PuHf+dO82aNS 6jhh7ZfF/hpjq9mBJVyb5NBOg5Oy7E4KwelSOO3dLtFBL6vyM3Uhtec59 rVxpW/JunVl5TzDGr4nnbYnYT1vv6ABipMieqju2QurRSAHqnuVJmNaz6 5bcFT+FhOAKKAxdUFAYaSky09b3ww4o0w1HT2slx7CNZT1AP2VAIc/ECr xUsANBbSaBVQ9N1RgKqm/KyzlEPdkHUNOH2orGxyvt/rxMwQoICDiXr2v Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10483"; a="301299147" X-IronPort-AV: E=Sophos;i="5.93,349,1654585200"; d="scan'208";a="301299147" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Sep 2022 06:59:44 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10483"; a="683999422" X-IronPort-AV: E=Sophos;i="5.93,349,1654585200"; d="scan'208";a="683999422" Received: from brentlu-brix.itwn.intel.com ([10.5.253.25]) by fmsmga008.fm.intel.com with ESMTP; 27 Sep 2022 06:59:42 -0700 From: Brent Lu To: alsa-devel@alsa-project.org Cc: Jaroslav Kysela , Takashi Iwai , Kai Vehmanen , Pierre-Louis Bossart , Mohan Kumar , =?UTF-8?q?Ville=20Syrj=C3=A4l=C3=A4?= , Brent Lu , Yong Zhi , linux-kernel@vger.kernel.org Subject: [PATCH] ALSA: hda/hdmi: run eld notify in delay work Date: Tue, 27 Sep 2022 21:58:07 +0800 Message-Id: <20220927135807.4097052-1-brent.lu@intel.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.2 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_NONE 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 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 --- sound/pci/hda/patch_hdmi.c | 38 +++++++++++++++++++++++++++++++++----- 1 file changed, 33 insertions(+), 5 deletions(-) diff --git a/sound/pci/hda/patch_hdmi.c b/sound/pci/hda/patch_hdmi.c index 6c209cd26c0c..a4c305ee8ff9 100644 --- a/sound/pci/hda/patch_hdmi.c +++ b/sound/pci/hda/patch_hdmi.c @@ -2907,13 +2907,21 @@ static int intel_port2pin(struct hda_codec *codec, int port) return spec->port_map[port]; } -static void intel_pin_eld_notify(void *audio_ptr, int port, int pipe) +struct pin_eld_notify { + void *audio_ptr; + int port; + int pipe; + struct delayed_work notify_work; +}; + +static void pin_eld_notify_work(struct work_struct *work) { - struct hda_codec *codec = audio_ptr; + struct pin_eld_notify *notify = container_of(work, struct pin_eld_notify, notify_work.work); + struct hda_codec *codec = notify->audio_ptr; int pin_nid; - int dev_id = pipe; + int dev_id = notify->pipe; - pin_nid = intel_port2pin(codec, port); + pin_nid = intel_port2pin(codec, notify->port); if (!pin_nid) return; /* skip notification during system suspend (but not in runtime PM); @@ -2922,13 +2930,33 @@ 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)) + if (snd_hdac_is_in_pm(&codec->core)) { + schedule_delayed_work(¬ify->notify_work, msecs_to_jiffies(10)); return; + } snd_hdac_i915_set_bclk(&codec->bus->core); check_presence_and_report(codec, pin_nid, dev_id); } +static void intel_pin_eld_notify(void *audio_ptr, int port, int pipe) +{ + struct hda_codec *codec = audio_ptr; + struct device *dev = hda_codec_dev(codec); + struct pin_eld_notify *notify; + + notify = devm_kzalloc(dev, sizeof(struct pin_eld_notify), GFP_KERNEL); + if (!notify) + return; + + notify->audio_ptr = audio_ptr; + notify->port = port; + notify->pipe = pipe; + INIT_DELAYED_WORK(¬ify->notify_work, pin_eld_notify_work); + + schedule_delayed_work(¬ify->notify_work, 0); +} + static const struct drm_audio_component_audio_ops intel_audio_ops = { .pin2port = intel_pin2port, .pin_eld_notify = intel_pin_eld_notify, -- 2.25.1