Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp675789pxb; Mon, 25 Oct 2021 16:26:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyLpT8XoKYqY3SdOpGLZFxy61+Dp2z5KYb+e+tUbXQtGCaf5EfzJMGblIb8A+Sbo9njUKdz X-Received: by 2002:a05:6402:40f:: with SMTP id q15mr30376502edv.333.1635204419624; Mon, 25 Oct 2021 16:26:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1635204419; cv=none; d=google.com; s=arc-20160816; b=TEh8UtniMngSbXbdFxg3qPwZ18E4TE0GwMU49nAqfMowtfWE8FP/Ju0bfPaFwdRYCt g4iNan5CkLFULRXR0OrdNEJGHRw/jenkzNZeHFrpP3Ds4JV977tVJ93poT4Ola/Ce3gG RW7sxFNXIGzCsizNSb98/j6gjMYKyKdDZSp6pAqdlDyA8ULYveawbZuIMssAcTBREeeS uXX4QX6jbqpsFGnxqwDRW88hxMgbw86SA+qfDZkGd1HRZ+n8Swm/8YUI1gbfbog8+vmo /reoGt36nfwPwLCrHU2mHaJjBCnzKNf/eJ3ZQkjN8jVrzqJxntF9/c4+4HK9YZWe2TQp Sprg== 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=/N2zW9+Panp0fUb/lTtZX0uZxvN/Z167U/pCob2KEkE=; b=A5sCwGpd55qWtEWZ9DCvHPwQdDzu5/7FEDqyrP+C74yX5QPNXH9HmrKeA7+vSnhfhP q8h1fswYqOieJW0o1KgHmQ7RaKPW/LmfqD4YGAvIxpve5TGb80veBQI+zsN5GxoPmRGr q6fe/SJ7aRmJFZqD24SIImEdh7X/rGUqZGj1lJr9jJA3u6cPwtQBkSvBFrW8g958faJ2 tBA6k6OcXC8EV2Ax09U1f8L+iMMbCCrPGfYVOzeaylfCRi+aF7r661vQQyc6xMbJbxWq ZC67a9bFKrmG60oKj5gsYN+Qd8Ik0UAkSzxOWAQW+LpQdSuqY4E0UqzMR08QKuCMrE+9 DspQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=cJUjO2DU; 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 j1si23535870edf.29.2021.10.25.16.26.35; Mon, 25 Oct 2021 16:26:59 -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=cJUjO2DU; 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 S234886AbhJYTYS (ORCPT + 99 others); Mon, 25 Oct 2021 15:24:18 -0400 Received: from mail.kernel.org ([198.145.29.99]:39788 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234912AbhJYTWc (ORCPT ); Mon, 25 Oct 2021 15:22:32 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 33BD26103C; Mon, 25 Oct 2021 19:20:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1635189609; bh=doc7mFVoN1+KAVOoT/ejQ/gIFA+0kecIC14EUT3j4N4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cJUjO2DU4c2b4jEeeygA2mvprquriep/iQRWXe5uZt9faCpvAvbPp5/9dcdY9LaZ3 6waXE+K3Hu0NUYU/8dp5scGU1DYao0YIUSpS9U5Zu0RkkVb0aboj3RdJrfvC/wibqq 6obYQcyq4l3i163IIsCnhwgrifkimQknqAT6W1kc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Kai Vehmanen , Takashi Iwai , Sasha Levin Subject: [PATCH 4.9 46/50] ALSA: hda: avoid write to STATESTS if controller is in reset Date: Mon, 25 Oct 2021 21:14:33 +0200 Message-Id: <20211025190941.056643450@linuxfoundation.org> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211025190932.542632625@linuxfoundation.org> References: <20211025190932.542632625@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 b37a15188eae9d4c49c5bb035e0c8d4058e4d9b3 ] The snd_hdac_bus_reset_link() contains logic to clear STATESTS register before performing controller reset. This code dates back to an old bugfix in commit e8a7f136f5ed ("[ALSA] hda-intel - Improve HD-audio codec probing robustness"). Originally the code was added to azx_reset(). The code was moved around in commit a41d122449be ("ALSA: hda - Embed bus into controller object") and ended up to snd_hdac_bus_reset_link() and called primarily via snd_hdac_bus_init_chip(). The logic to clear STATESTS is correct when snd_hdac_bus_init_chip() is called when controller is not in reset. In this case, STATESTS can be cleared. This can be useful e.g. when forcing a controller reset to retry codec probe. A normal non-power-on reset will not clear the bits. However, this old logic is problematic when controller is already in reset. The HDA specification states that controller must be taken out of reset before writing to registers other than GCTL.CRST (1.0a spec, 3.3.7). The write to STATESTS in snd_hdac_bus_reset_link() will be lost if the controller is already in reset per the HDA specification mentioned. This has been harmless on older hardware. On newer generation of Intel PCIe based HDA controllers, if configured to report issues, this write will emit an unsupported request error. If ACPI Platform Error Interface (APEI) is enabled in kernel, this will end up to kernel log. Fix the code in snd_hdac_bus_reset_link() to only clear the STATESTS if the function is called when controller is not in reset. Otherwise clearing the bits is not possible and should be skipped. Signed-off-by: Kai Vehmanen Link: https://lore.kernel.org/r/20211012142935.3731820-1-kai.vehmanen@linux.intel.com Signed-off-by: Takashi Iwai Signed-off-by: Sasha Levin --- sound/hda/hdac_controller.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/sound/hda/hdac_controller.c b/sound/hda/hdac_controller.c index 00c6af2ae1c2..f0e112906c68 100644 --- a/sound/hda/hdac_controller.c +++ b/sound/hda/hdac_controller.c @@ -389,8 +389,9 @@ static int azx_reset(struct hdac_bus *bus, bool full_reset) if (!full_reset) goto skip_reset; - /* clear STATESTS */ - snd_hdac_chip_writew(bus, STATESTS, STATESTS_INT_MASK); + /* clear STATESTS if not in reset */ + if (snd_hdac_chip_readb(bus, GCTL) & AZX_GCTL_RESET) + snd_hdac_chip_writew(bus, STATESTS, STATESTS_INT_MASK); /* reset controller */ snd_hdac_bus_enter_link_reset(bus); -- 2.33.0