Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3003924pxj; Mon, 17 May 2021 15:21:13 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzT/t2fsYR2zIS/v2SiZ4TJVSDfsy16lKk64VQEcEDLcLxiFjAE3siRIRmZa1vaV0yyXBQV X-Received: by 2002:a05:6402:848:: with SMTP id b8mr2731605edz.159.1621290073603; Mon, 17 May 2021 15:21:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621290073; cv=none; d=google.com; s=arc-20160816; b=YCuxUF+iT8UrsG34Og7IuWOKdNszB9Esxr6E1Q04o94ZoG2JTUguko5HX6//+F1Nu/ 5fUcQ6jiLlS56nTcH12wAAWOY2mzHeVKYQEs2N1gTNbXJ/BZCzlE7TyWidU62eB78tBX eUCtR3qITxl10vBJDG5IU0B712o4g3cMqRIyGA2NNf+ycFUI364vlczXZxs53BLNiyDJ OGj2qkruvkV1GufrID8IOToxQN2A3WfcugiWjmMFeaVjTgRvdBBLe1tekd4kqfaCeULA H7x+A5XeJRdtwAD+tPJwDxB2JrOseaIz/JXPoV0cEvqdexdc69x/vA3Dr1APXvcLMGw9 zwcA== 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=ULb5vMk8PUk9e9PF5HriS1hkVmuoxiUSQBNRgJ/Atbo=; b=xmosI7TL6DDSNwO8wnHSX4BBd+EMRJKBz81VxhbQDDTKRRr+jjmqiP+Dq4ZgXTMhuv JuwYCOyxZ5acfU1/Mrur1Qnb6Wx8Chm4GglWfW+wrKW9r6uMrllGhxi2FhBj4clF4gIy MOMlsso59xi59tzqh3pSxv6tKWDacldSLhWN0Q/P9TedaHU4YCWsLO8dOAVxKM0cHn9P SyN3V2mvwtRXvvhiiaAPE7uxiEhfyrxgQESnkZ4N+KxFjBj/yUxWuEhbPds5j9MfXSrm QRpLpIyxM4oVLc2B7p2UQXqAu+Ai1bQ2WdQKSPASfp1Jllwn9sSsgsezM7aK+8aXYydN 7mLQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=iZCreHNE; 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 j25si7544110ejx.681.2021.05.17.15.20.43; Mon, 17 May 2021 15:21:13 -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=iZCreHNE; 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 S238520AbhEQONI (ORCPT + 99 others); Mon, 17 May 2021 10:13:08 -0400 Received: from mail.kernel.org ([198.145.29.99]:59666 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236513AbhEQOLS (ORCPT ); Mon, 17 May 2021 10:11:18 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id E5F67613B6; Mon, 17 May 2021 14:07:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621260456; bh=+jyHgxAPc73OHt2eH+HMNJcBfYBff92VJHqGAg42OQ8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=iZCreHNE7H2axvy6bFgw8c+D4lGiTRk9hK6yd3drLptMYfMRlPU1VuHoAjcYrOVJs y1HiPNdTRaUNrljAFvGcy7XUCQMdblnRhiKNtrTjjGzdtDTTPCk+L8pDcmlW4aG1Gj Fj9y3ivEWvzo7gZJU5sG5JWXh9Bf1ZOzzfiQN0hM= 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.12 089/363] ALSA: hda/hdmi: fix race in handling acomp ELD notification at resume Date: Mon, 17 May 2021 15:59:15 +0200 Message-Id: <20210517140305.610428823@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210517140302.508966430@linuxfoundation.org> References: <20210517140302.508966430@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 5de3666a7101..4b2cc8cb55c4 100644 --- a/sound/pci/hda/patch_hdmi.c +++ b/sound/pci/hda/patch_hdmi.c @@ -2654,7 +2654,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)) @@ -2840,7 +2840,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