Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp172032pxj; Tue, 18 May 2021 00:14:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyU5JABCFXiuERxyylHk3FG6K6LuRh1JkartWwKBILwC07iy8P7l9KZ8aeBNMkib0+qASfF X-Received: by 2002:a6b:ec03:: with SMTP id c3mr3128167ioh.103.1621322090515; Tue, 18 May 2021 00:14:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621322090; cv=none; d=google.com; s=arc-20160816; b=IQSUVgNnYyoMpMNa7HrU7P0QU4Ha8Vn1u6FX0/53JFqqh8pmNnMZF8JzLtZ8FRpT13 FcqU6z5PAuMJnc4miu5SfnfD9z79Qrox4NsDpwWmzVjonmeYAulXayDZp21WXLWZQz0t dFdYNgkSAbF5wVGdwEeZD8zXqAglnmocQtVN8i5fu9J41+HcY/d5j3uK6iO81HP/ptbF zWvrGdMYErG9XsBR7TuRI7Mc1G3KTMyVuQHyivA4ncwypwhmfOjN43ba3JD+O9FfI7fS x3dEJ5/fmgQjYQc+hHOk3B7pfzNa7Q6sqhHklqdkXrBlG27OWtBiErq+GA7DnE+SZXjS TeSQ== 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=eobjVTeaB8z1GdEmZ2PwgWedVG411pWqlRrgCm0a79A=; b=F2m9BGJEWea4Acy/NKKeKENV2gK+JcTVLd9C6aGopwsHA+BGH9qkQ/xfSYTWwDgQyJ JTeKQ8gixZpnhsN9QDBwCXe3YSNdJQjnYYF99p3Eh+0bvIO9lCoGJxdU5paWZ+y4p6dy aAPjUGrpQt9cMiaKArgylOI5L1W4wWm0P+nTBlUMDS9aW3Dql4NxYhbaTlkTaqzoHXCl 1dof0yIjVbaxOgGjmGHgDUj7qVK/xNzkGCAYUL8CHtLLgj8iFke3fq51Ys7Mi7eANGHh 86rfLL6VHMqlA/S+lyEEnxTazWEvKKM06thqUTRJGrVXNxSOEpvAm/0nedb+4B2W957j gRPg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=ocPsa4ad; 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 a7si22024180jat.120.2021.05.18.00.14.37; Tue, 18 May 2021 00:14:50 -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=ocPsa4ad; 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 S241319AbhEQOxG (ORCPT + 99 others); Mon, 17 May 2021 10:53:06 -0400 Received: from mail.kernel.org ([198.145.29.99]:54300 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240066AbhEQOlV (ORCPT ); Mon, 17 May 2021 10:41:21 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 4393D6198B; Mon, 17 May 2021 14:19:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621261152; bh=RTOEkZRNQ4VOpCbfLqSuqXmv2lqlX9b9uqe/SCvsp8U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ocPsa4ad9S9F2draESJ4ccD20zdY+PYtiBMAtN06OCEH66gFuNDZcEvxDlHqFGbSj wz+rmI9RlVZ+HqdDnqKnZkCAdNhf5hGGXrlTdlrNheKZED/97GoO4OBag6ktbv6GNB m95/q0IywlrkDMy7xTMuBBUD2qTBymfFpQicxdXU= 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.11 080/329] ALSA: hda/hdmi: fix race in handling acomp ELD notification at resume Date: Mon, 17 May 2021 15:59:51 +0200 Message-Id: <20210517140304.820672658@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210517140302.043055203@linuxfoundation.org> References: <20210517140302.043055203@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 d6387106619f..7b0d9d7a1c38 100644 --- a/sound/pci/hda/patch_hdmi.c +++ b/sound/pci/hda/patch_hdmi.c @@ -2650,7 +2650,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)) @@ -2836,7 +2836,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