Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp538679pxx; Wed, 28 Oct 2020 10:35:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz9TKL5f4M5LaCCibFjIZyURY4KgWlaD8/gUuKlSQ7YBAIBz1+PmGSwFbPAmM34E5CAgTSX X-Received: by 2002:a17:906:76d5:: with SMTP id q21mr127924ejn.415.1603906525849; Wed, 28 Oct 2020 10:35:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603906525; cv=none; d=google.com; s=arc-20160816; b=CC/NxiBKErEyb021V4tprLixWlouBQlh/66rKMJ1SvpoKd2X4J6p6ovrk143qKS3U4 r2dpWuAQSNXb52MA+l2qkYySqtCs7HiYYzqV5mFHZNeYRM4hpacKFjhUqMC3V517XwL1 U2o3V8timqpqg7DA46GU/VwvEbmAscfWloqJYkPpF44UVjjyQyl3t2L9HNQZ2QpRKI/E Fqy/idndsC3t9mU5FCfYqd46YBczqBsh8oYntyBMVmNOT9p35wjNZbZKjWgRECvLAR8W J/uyOqJNeBI4ygXjFer72dXa0Hli/TkLKuGwEGEVxLH1zOkkmMNDurknk8hC5TItSI0T wzgw== 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=0jUyU72FXttIROgdq0U02NzNPnfmM747A+ji5hJic94=; b=Na/8YxwW6cb6eQOnPiwZt1Ba/NPSeYjvTOa7vwWZpKeIvUKs/h5KAaYtsM2a15Y/hJ gDApgthg/RoRKRBZ+0thRBXIiMUv+UIA+kqY7TxOGZDmZta1m4XG1c4YQx1Q87K3+Xaq Y0hkRATOVe3pgcL1J6ZAZgyPqCoCwaPvAvsXF6R7SGWNpiYLYN0G7mTHdxsstc1BV+hs s2EIzR+xrPkRjYxXIxry41lc7YQmEhjx5jcNTDEZSFVvB1Ge47iMaLwXYRu99R99ZL69 XCnSfH1GNP7I6/vuTnc2lQGAA19rrnX9RLqQHkRFrdespF9CPT5Fhx+SI4MitYxz0JkE x0lg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=a5mp2zG7; 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=fail (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 g1si6073edt.484.2020.10.28.10.35.03; Wed, 28 Oct 2020 10:35:25 -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=@kernel.org header.s=default header.b=a5mp2zG7; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1822101AbgJ0Rq5 (ORCPT + 99 others); Tue, 27 Oct 2020 13:46:57 -0400 Received: from mail.kernel.org ([198.145.29.99]:57214 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2902129AbgJ0Oak (ORCPT ); Tue, 27 Oct 2020 10:30:40 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 74A3F22202; Tue, 27 Oct 2020 14:30:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603809040; bh=FORQzrbH0JNXbkiJPlvAsPZqJT8xPSN8LuDtji+XeT4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=a5mp2zG7+wtb0KA9so+7nPtVWCfc9tnCxPIUneNboc1dkyyrJK0wXRCsG1ZAoNxDq sCRae+ElpRjiECaJaA4oMNSJ3f3nwYtWCzJSQXIM5X6532F5fxlF5Kd6CLiI8X3Bix Eb+Bxrz8DFWZ7xOiNhnM9DFiZvyE3k/9ZnlVCuMY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Kailang Yang , Kai-Heng Feng , Kai Vehmanen , Takashi Iwai Subject: [PATCH 5.4 022/408] ALSA: hda: fix jack detection with Realtek codecs when in D3 Date: Tue, 27 Oct 2020 14:49:20 +0100 Message-Id: <20201027135456.087078753@linuxfoundation.org> X-Mailer: git-send-email 2.29.1 In-Reply-To: <20201027135455.027547757@linuxfoundation.org> References: <20201027135455.027547757@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 commit a6e7d0a4bdb02a7a3ffe0b44aaa8842b7efdd056 upstream. In case HDA controller becomes active, but codec is runtime suspended, jack detection is not successful and no interrupt is raised. This has been observed with multiple Realtek codecs and HDA controllers from different vendors. Bug does not occur if both codec and controller are active, or both are in suspend. Bug can be easily hit on desktop systems with no built-in speaker. The problem can be fixed by powering up the codec once after every controller runtime resume. Even if codec goes back to suspend later, the jack detection will continue to work. Add a flag to 'hda_codec' to describe codecs that require this flow from the controller driver. Modify __azx_runtime_resume() to use pm_request_resume() to make the intent clearer. Mark all Realtek codecs with the new forced_resume flag. BugLink: https://bugzilla.kernel.org/show_bug.cgi?id=209379 Cc: Kailang Yang Co-developed-by: Kai-Heng Feng Signed-off-by: Kai-Heng Feng Signed-off-by: Kai Vehmanen Cc: Link: https://lore.kernel.org/r/20201012102704.794423-1-kai.vehmanen@linux.intel.com Signed-off-by: Takashi Iwai Signed-off-by: Greg Kroah-Hartman --- include/sound/hda_codec.h | 1 + sound/pci/hda/hda_intel.c | 14 ++++++++------ sound/pci/hda/patch_realtek.c | 1 + 3 files changed, 10 insertions(+), 6 deletions(-) --- a/include/sound/hda_codec.h +++ b/include/sound/hda_codec.h @@ -254,6 +254,7 @@ struct hda_codec { unsigned int force_pin_prefix:1; /* Add location prefix */ unsigned int link_down_at_suspend:1; /* link down at runtime suspend */ unsigned int relaxed_resume:1; /* don't resume forcibly for jack */ + unsigned int forced_resume:1; /* forced resume for jack */ #ifdef CONFIG_PM unsigned long power_on_acct; --- a/sound/pci/hda/hda_intel.c +++ b/sound/pci/hda/hda_intel.c @@ -1001,12 +1001,14 @@ static void __azx_runtime_resume(struct azx_init_pci(chip); hda_intel_init_chip(chip, true); - if (status && from_rt) { - list_for_each_codec(codec, &chip->bus) - if (!codec->relaxed_resume && - (status & (1 << codec->addr))) - schedule_delayed_work(&codec->jackpoll_work, - codec->jackpoll_interval); + if (from_rt) { + list_for_each_codec(codec, &chip->bus) { + if (codec->relaxed_resume) + continue; + + if (codec->forced_resume || (status & (1 << codec->addr))) + pm_request_resume(hda_codec_dev(codec)); + } } /* power down again for link-controlled chips */ --- a/sound/pci/hda/patch_realtek.c +++ b/sound/pci/hda/patch_realtek.c @@ -1141,6 +1141,7 @@ static int alc_alloc_spec(struct hda_cod codec->single_adc_amp = 1; /* FIXME: do we need this for all Realtek codec models? */ codec->spdif_status_reset = 1; + codec->forced_resume = 1; codec->patch_ops = alc_patch_ops; err = alc_codec_rename_from_preset(codec);