Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp349407pxu; Thu, 7 Jan 2021 06:40:57 -0800 (PST) X-Google-Smtp-Source: ABdhPJzbv5ew1IweqecBni7b/0ZfNUZWsmHyiRBtP3JT7wL7O7KZD81oiCiLcCt7I3amqxhl1dov X-Received: by 2002:a17:906:d101:: with SMTP id b1mr6793976ejz.80.1610030457169; Thu, 07 Jan 2021 06:40:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610030457; cv=none; d=google.com; s=arc-20160816; b=UFftwqzYAmjrKGxsN6SbYgPU1j8ZFmKzOcq4MSdlceB/VWxhJkkG6u+tHWYTeYXiwl P0U+AJ/lAxEiYNiXkADtc+aeugj3WbT0PMM05yVTKhyU8IFkhZiBQR+ewyamEZ0u0+si Z0K5oPmMCRQ3rT+vEhX0bYXk+bkoY0o9CstXiX24GqLcrS75g+/k24RUKL2ysmhDvd05 2uYre/pBfNDnerVbGt13i1Qg4TSefEBm0mLHxPfD9WVTcEeVABGK3S5Q45q8XnugkyXO frxQLMYtdZAhygsZx1W7TfARJgTYm2b+WtLFVpY5nWOQ+TgZc+3/wgr8pWznZSZe1bhG K9lg== 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=ewMU4Qv2HqMmmiGaVA/3VwsaB780Uf5MZV+dfDZNTNw=; b=I9Q4iv6PC94sOtpOC0SAhAYWVb5BdjW44lptJK/CxWjyb7hmTSxEFOQwkgEE5hL22k EXoAd/gvIt3ZkKDnHH5M4ImQWCfnZYev5gCFUA9ISuXwreN6qkIfMjG5plclf5XLtLsI kdCHwQJfogrW/hJ9bv86R3VbbiLe4GDnvsQJzPJ+WmH7z9FmvFohFpK2M4N0wfccX3Zz pw23/vYeWBW6B0GWmnKdJcH09MNPPj//6JR2+wR1BX4Ff+2hut73v3cMgTcS5spuPBOI cekD0DtQn6tHyh08fLvYjbRW1l6nCfFeF1AAkyU66LwFdAZPBMDEJ3kvK1+qHHYySvzh ekKw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=zek+EV8G; 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 n3si2369355edr.560.2021.01.07.06.40.33; Thu, 07 Jan 2021 06:40:57 -0800 (PST) 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=zek+EV8G; 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 S1728327AbhAGOkB (ORCPT + 99 others); Thu, 7 Jan 2021 09:40:01 -0500 Received: from mail.kernel.org ([198.145.29.99]:45348 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729086AbhAGOby (ORCPT ); Thu, 7 Jan 2021 09:31:54 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id D8133233CE; Thu, 7 Jan 2021 14:31:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1610029879; bh=7Tt5NhYT2QB2Fby398qNEU9l5KBPFcDzoFuadTPvOVs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=zek+EV8GZaBYrxJBVnOFjs0hyCd8MVRlQ35yBsELPq8xIepAD4a4N7lB8PGbmiTZD no3QAIB0liGeMmlYKdmn4EAMB9UPsAnPrAXHfJWVer8iNghir2MLF6JVGeAxHnCgf0 6GWI60UEwjKEdnx8kfjqeoCAi2IxtZTbiZZPZeow= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Takashi Iwai , Sudip Mukherjee Subject: [PATCH 4.14 03/29] ALSA: hda/ca0132 - Fix work handling in delayed HP detection Date: Thu, 7 Jan 2021 15:31:18 +0100 Message-Id: <20210107143053.414602517@linuxfoundation.org> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210107143052.973437064@linuxfoundation.org> References: <20210107143052.973437064@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: Takashi Iwai commit 42fb6b1d41eb5905d77c06cad2e87b70289bdb76 upstream CA0132 has the delayed HP jack detection code that is invoked from the unsol handler, but it does a few weird things: it contains the cancel of a work inside the work handler, and yet it misses the cancel-sync call at (runtime-)suspend. This patch addresses those issues. Fixes: 15c2b3cc09a3 ("ALSA: hda/ca0132 - Fix possible workqueue stall") Cc: Link: https://lore.kernel.org/r/20191213085111.22855-4-tiwai@suse.de Signed-off-by: Takashi Iwai [sudip: adjust context] Signed-off-by: Sudip Mukherjee Signed-off-by: Greg Kroah-Hartman --- sound/pci/hda/patch_ca0132.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) --- a/sound/pci/hda/patch_ca0132.c +++ b/sound/pci/hda/patch_ca0132.c @@ -4443,11 +4443,10 @@ static void hp_callback(struct hda_codec /* Delay enabling the HP amp, to let the mic-detection * state machine run. */ - cancel_delayed_work(&spec->unsol_hp_work); - schedule_delayed_work(&spec->unsol_hp_work, msecs_to_jiffies(500)); tbl = snd_hda_jack_tbl_get(codec, cb->nid); if (tbl) tbl->block_report = 1; + schedule_delayed_work(&spec->unsol_hp_work, msecs_to_jiffies(500)); } static void amic_callback(struct hda_codec *codec, struct hda_jack_callback *cb) @@ -4625,12 +4624,25 @@ static void ca0132_free(struct hda_codec kfree(codec->spec); } +#ifdef CONFIG_PM +static int ca0132_suspend(struct hda_codec *codec) +{ + struct ca0132_spec *spec = codec->spec; + + cancel_delayed_work_sync(&spec->unsol_hp_work); + return 0; +} +#endif + static const struct hda_codec_ops ca0132_patch_ops = { .build_controls = ca0132_build_controls, .build_pcms = ca0132_build_pcms, .init = ca0132_init, .free = ca0132_free, .unsol_event = snd_hda_jack_unsol_event, +#ifdef CONFIG_PM + .suspend = ca0132_suspend, +#endif }; static void ca0132_config(struct hda_codec *codec)