Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp5980248pxb; Mon, 14 Feb 2022 12:14:29 -0800 (PST) X-Google-Smtp-Source: ABdhPJzBkRAePiaz4QySyr6mst2gopSrZhSMOSrywWzZGFb7aKAG2iiH+0e83v+sScFpeW6Y00b8 X-Received: by 2002:a17:903:228c:: with SMTP id b12mr686405plh.39.1644869669694; Mon, 14 Feb 2022 12:14:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644869669; cv=none; d=google.com; s=arc-20160816; b=CTaiL13H7v/FTuASyMyH+oJckZphzRFDi3VbaMRJXFgkq/6WEfE3IsMbWjN6l3bDQ8 ExBxDFj6Kp33lrNmsUYFK94EFp2c1FSg2ve4vX/w3z9zPrm5cIbXpmrLmdycXkCAA645 /64JeuOEggyWl/11QO11gTdKoa4bO/TpOibIylkB+RNWZu68kqbGBDCtCH5kVU6BXi2C hHuRD+HhxoSlKv7Nj1xj5zVdXftW3K5UfKGILa2VUp0nEU/yyWDlAbSu44ThZCykRXDi FmEsIkW74emGAK6yoowyNuUIlChF4TdIFyAOAiZM5ATsfhGQO//rzEXMOBGXOSWcMeUv O3Dw== 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=51rgRejm4g1o/DWcuu9XgzTIry24iGX+KhOtYI6ugKo=; b=pUQwIkVwc8sbFt7rHbSESOvyiakESqxDDdKclrVwbx4RJE61LP6jdfnnhWXN+Asqxt P1K4Ls9WdF44JHHAYuYzmJDTP4kZkVcF4yyqLDg2f2W5ZSxp5qvltYb9SkO6Pl1SIT1G uphgMrkRawYmWVVPXvSCaUEux5aitEfZTFbkY8aIi3lh87WFhx0r9SpQ7DjQ68MmFKB8 Z8EWNPAIBYcILIG/laEHwTWjqIjzR/GqOzEhGduW2JKm8gPlatiDSkAExHQXM+7P2VKv Fx0TyG085JU+Is9X/5fpq0gc/7zbVZTJN58j68navPXdcgdw8NPPvUf79ZBCFJSeayCe B4VQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=DEkvb6KZ; dkim=neutral (no key) header.i=@suse.de header.b=GW3xkNZ2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id x23si705848pgu.417.2022.02.14.12.14.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Feb 2022 12:14:29 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=DEkvb6KZ; dkim=neutral (no key) header.i=@suse.de header.b=GW3xkNZ2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id E9A4C16A59D; Mon, 14 Feb 2022 11:51:10 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1353509AbiBNMqS (ORCPT + 99 others); Mon, 14 Feb 2022 07:46:18 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:39716 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233510AbiBNMqR (ORCPT ); Mon, 14 Feb 2022 07:46:17 -0500 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9829B4B844 for ; Mon, 14 Feb 2022 04:46:06 -0800 (PST) Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id 470591F38C; Mon, 14 Feb 2022 12:46:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1644842765; 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=51rgRejm4g1o/DWcuu9XgzTIry24iGX+KhOtYI6ugKo=; b=DEkvb6KZRe9YEA1GL5YO4daN+nQaNgmau7Ld1F4oTBmfT69CI0O5/czMvuVNSgK0Gl21g4 2idcx5pF9iqxjXbBqMiABuRHLsO2ksSa3/EfpS+f0yex64F6QVUaCtgH79RtB7MLv7GROW UmnQqoaq+IMgcUUmcGyPwwjPZK4XJXk= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1644842765; 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=51rgRejm4g1o/DWcuu9XgzTIry24iGX+KhOtYI6ugKo=; b=GW3xkNZ2u0Q/AdrPhBiOcYrkxsF76r6+ZEJcK7s27yvNBbb2ow24TD04DCZpHZBixLjoIO ilJ2XwEU6Zu3dbDw== Received: from alsa1.suse.de (alsa1.suse.de [10.160.4.42]) by relay2.suse.de (Postfix) with ESMTP id 4111AA3B83; Mon, 14 Feb 2022 12:46:05 +0000 (UTC) Date: Mon, 14 Feb 2022 13:46:05 +0100 Message-ID: From: Takashi Iwai To: Julian Wollrath Cc: linux-kernel@vger.kernel.org, Takashi Iwai Subject: Re: v5.17.0-rc3: Regression bisecting failing suspend to disk: ALSA: hda: realtek: Fix race at concurrent COEF updates In-Reply-To: <20220214132838.4db10fca@schienar> References: <20220214132838.4db10fca@schienar> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI/1.14.6 (Maruoka) FLIM/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL/10.8 Emacs/25.3 (x86_64-suse-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset=US-ASCII X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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 Mon, 14 Feb 2022 13:28:38 +0100, Julian Wollrath wrote: > > Dear Takashi Iwai, > > since v5.17.0-rc3 my system (HP Elitebook 845 G7) fails to suspend to > disk and instead just hangs. Rebooting via the magic sysrq keys is > still possible though. I bisected the regression to commit > b837a9f5ab3bdfab9233c9f98a6bef717673a3e5 (ALSA: hda: realtek: Fix race > at concurrent COEF updates). Reverting that commit removes the problem. > I you need more information, I am happy to provide it. Does the patch below help? thanks, Takashi --- a/sound/pci/hda/patch_realtek.c +++ b/sound/pci/hda/patch_realtek.c @@ -138,6 +138,22 @@ struct alc_spec { * COEF access helper functions */ +static void coef_mutex_lock(struct hda_codec *codec) +{ + struct alc_spec *spec = codec->spec; + + snd_hda_power_up_pm(codec); + mutex_lock(&spec->coef_mutex); +} + +static void coef_mutex_unlock(struct hda_codec *codec) +{ + struct alc_spec *spec = codec->spec; + + mutex_unlock(&spec->coef_mutex); + snd_hda_power_down_pm(codec); +} + static int __alc_read_coefex_idx(struct hda_codec *codec, hda_nid_t nid, unsigned int coef_idx) { @@ -151,12 +167,11 @@ static int __alc_read_coefex_idx(struct hda_codec *codec, hda_nid_t nid, static int alc_read_coefex_idx(struct hda_codec *codec, hda_nid_t nid, unsigned int coef_idx) { - struct alc_spec *spec = codec->spec; unsigned int val; - mutex_lock(&spec->coef_mutex); + coef_mutex_lock(codec); val = __alc_read_coefex_idx(codec, nid, coef_idx); - mutex_unlock(&spec->coef_mutex); + coef_mutex_unlock(codec); return val; } @@ -173,11 +188,9 @@ static void __alc_write_coefex_idx(struct hda_codec *codec, hda_nid_t nid, static void alc_write_coefex_idx(struct hda_codec *codec, hda_nid_t nid, unsigned int coef_idx, unsigned int coef_val) { - struct alc_spec *spec = codec->spec; - - mutex_lock(&spec->coef_mutex); + coef_mutex_lock(codec); __alc_write_coefex_idx(codec, nid, coef_idx, coef_val); - mutex_unlock(&spec->coef_mutex); + coef_mutex_unlock(codec); } #define alc_write_coef_idx(codec, coef_idx, coef_val) \ @@ -198,11 +211,9 @@ static void alc_update_coefex_idx(struct hda_codec *codec, hda_nid_t nid, unsigned int coef_idx, unsigned int mask, unsigned int bits_set) { - struct alc_spec *spec = codec->spec; - - mutex_lock(&spec->coef_mutex); + coef_mutex_lock(codec); __alc_update_coefex_idx(codec, nid, coef_idx, mask, bits_set); - mutex_unlock(&spec->coef_mutex); + coef_mutex_unlock(codec); } #define alc_update_coef_idx(codec, coef_idx, mask, bits_set) \ @@ -235,9 +246,7 @@ struct coef_fw { static void alc_process_coef_fw(struct hda_codec *codec, const struct coef_fw *fw) { - struct alc_spec *spec = codec->spec; - - mutex_lock(&spec->coef_mutex); + coef_mutex_lock(codec); for (; fw->nid; fw++) { if (fw->mask == (unsigned short)-1) __alc_write_coefex_idx(codec, fw->nid, fw->idx, fw->val); @@ -245,7 +254,7 @@ static void alc_process_coef_fw(struct hda_codec *codec, __alc_update_coefex_idx(codec, fw->nid, fw->idx, fw->mask, fw->val); } - mutex_unlock(&spec->coef_mutex); + coef_mutex_unlock(codec); } /*