Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp324657pxj; Tue, 18 May 2021 04:22:58 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxbO8sHC0AQeGEwAWTmVF7PmMcwsp8FVitKQpZuAW2lgRfGNxCB+fBswX9ffIelwaHGbi8+ X-Received: by 2002:a5e:c202:: with SMTP id v2mr3772971iop.89.1621336977953; Tue, 18 May 2021 04:22:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621336977; cv=none; d=google.com; s=arc-20160816; b=ktMoKlBnW2Y3fXHe0WSUhGIZQKQAXDk2o87Wl15nVpBi3Y24DyP1KXRnhTTaHscraF SpUoUY9NUgqHFjsfyvSh98WM8JQ6IZANqa3vhmM/hJGODc1wPd3vjPCNcgU8ZSrz4tFJ yAdGp7th8vE1Z8TM0aWP6zKIVhUYgBaLWEDZnrVKv8FUOQ7xSwLdOaW9hoeQY0xW9Apt 8L23/3GPL2TQXbiDX7XrDhsz+2D0LPj+4lpARMvJLDAGQfSgPTGWEtk75Px2tZsjpM3u n5HpmKWI4xuhXqH0TbMEswaK+ZsqW9aUZ+iJXjf3OmiNlaFgOTtjyYei7la1/or76C9r iMrw== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=EQj/uoYucNxGY620mm+BdjWbB1fvIbf3V1spiwdZL4k=; b=lfy/HSUrav4U9ACDWAxMOlwi5Rhlq1MW7Arg5d+TtyZAl9qycBQ8crybwY9Jmuczs8 mdQ+S3KhdC4ExIAw4BhK2u/vvN2N9hW9sE6rJVty/9he3Vf0kscsguZg8eEe5ufY0Uxt Qatabb6VlaDhB9AURgAKpbytM7uzzRu/N6eD1rPQDusjkd3jWM0UWlqby4dcijXq8BHM 5DPPjQBL3VBna8wTnTecf1mHU3lmJnvjG7VGNpwtvqygNkm0vKU/APPD7IO46QElldFX pxh+vxYvFKCVCNXx7BP58e6RhCjEsKHGdyEOaQZOf7Fl2lsGliHLM7qVnrGa1xISgsDe 4ylw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=PNYq5Uvt; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l23si10559496jas.94.2021.05.18.04.22.45; Tue, 18 May 2021 04:22:57 -0700 (PDT) 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; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=PNYq5Uvt; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243210AbhEQPSk (ORCPT + 99 others); Mon, 17 May 2021 11:18:40 -0400 Received: from mail.kernel.org ([198.145.29.99]:45116 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242665AbhEQPHb (ORCPT ); Mon, 17 May 2021 11:07:31 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 2392E6162B; Mon, 17 May 2021 14:29:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621261776; bh=l6UOsSfIwMVHstmtkJIX4n+JtKICvV4bJ/QTOVkiPiM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PNYq5UvtXwg+v5mqY4mBc6BXcrk0xYbYmxTcYsXsc83s3qMtr9OUgcv9xg43sqHlj HBDlQ/kFhuzTX/MX3+7loxa57DI+PnvyFLFqTZObqWwMzSRhwy96cBZoz6kEcwGTlh bb4GFADj64qf2N+phVxBCiZplj7ZdPS/tNKoOquU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Takashi Iwai , Kai Vehmanen , Sasha Levin Subject: [PATCH 5.10 064/289] ALSA: hda/hdmi: fix race in handling acomp ELD notification at resume Date: Mon, 17 May 2021 15:59:49 +0200 Message-Id: <20210517140307.352444039@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210517140305.140529752@linuxfoundation.org> References: <20210517140305.140529752@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Kai Vehmanen [ Upstream commit 0c37e2eb6b83e375e8a654d01598292d5591fc65 ] When snd-hda-codec-hdmi is used with ASoC HDA controller like SOF (acomp used for ELD notifications), display connection change done during suspend, can be lost due to following sequence of events: 1. system in S3 suspend 2. DP/HDMI receiver connected 3. system resumed 4. HDA controller resumed, but card->deferred_resume_work not complete 5. acomp eld_notify callback 6. eld_notify ignored as power state is not CTL_POWER_D0 7. HDA resume deferred work completed, power state set to CTL_POWER_D0 This results in losing the notification, and the jack state reported to user-space is not correct. The check on step 6 was added in commit 8ae743e82f0b ("ALSA: hda - Skip ELD notification during system suspend"). It would seem with the deferred resume logic in ASoC core, this check is not safe. Fix the issue by modifying the check to use "dev.power.power_state.event" instead of ALSA specific card power state variable. BugLink: https://github.com/thesofproject/linux/issues/2825 Suggested-by: Takashi Iwai Signed-off-by: Kai Vehmanen Link: https://lore.kernel.org/r/20210416131157.1881366-1-kai.vehmanen@linux.intel.com Signed-off-by: Takashi Iwai Signed-off-by: Sasha Levin --- sound/pci/hda/patch_hdmi.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sound/pci/hda/patch_hdmi.c b/sound/pci/hda/patch_hdmi.c index 8c6f10cbced3..6d2a4dfcfe43 100644 --- a/sound/pci/hda/patch_hdmi.c +++ b/sound/pci/hda/patch_hdmi.c @@ -2653,7 +2653,7 @@ static void generic_acomp_pin_eld_notify(void *audio_ptr, int port, int dev_id) /* 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) + 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)) @@ -2839,7 +2839,7 @@ 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) + 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)) -- 2.30.2