Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp631414pxb; Mon, 25 Oct 2021 15:23:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz37dkQ267h0gncw9wQfsiHMVnsibgJnVSU3jhxs8W5Kn0itEPJWpCyURFszrAPzfyizEj+ X-Received: by 2002:a17:90b:1e4e:: with SMTP id pi14mr18759741pjb.200.1635200606302; Mon, 25 Oct 2021 15:23:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1635200606; cv=none; d=google.com; s=arc-20160816; b=yQ6cGUWGbn1u6c8ZV4WSH9HdoWR9K9vDcpI+IXDX6nttyPCSkhERXntMRJHYhlVOGd AhS/HAQj/GMPqrQJoYaNxOK+t4FAYEvubb9eqH0090Xfs7NwG8/JRWjk7WI8zzSL50Pc MQ5yxaUHVJDtCFTLO8xp60tceH8eg8HBU5rhRhHPWJjWRHaRLBfXG6smmtsId8Zb+kp8 p0FOu3zo26K9Fu8RjWgeyA78ccvgYQdXm6LEG2olsySGybzXnCGhu13+/eiOT2ux2i8Q E/x5waC5TuisbjId0Q1Pbd2clbI5hYGtKQYxBrwYDckAFQflPRbCihDhwWbYB+T543XZ 5DAg== 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=BPR6xsETYOTjr5Q7ucefWfyGab8Flo+YqeyioO9GhjU=; b=j95If4Z6M5PdXTqzVKq10scGlIgRdh3/ZgrDvSkxtehI8tnFxl1slrMwyn3wnd0Uqr NMTb2Hy8V8nkEp8GuunkHLRkRQTfKSkdF6jn/yFXV5fHeia36crh+UcuShb52flnfiov hJBX83neEfm5T9vzfu5SYihffn4Q5RMwJqmuRsHoujaVWDeS6yaHlPfDCV+N+uC1Vfdi gKr3g2OoLY9aNh79wFJWDT5bg3+raanCS9ZpaDO5Ju6w3NyDbNm011Ht+PqgNmWBhrSo w/kRFh1UJ1CZUqlv1zxacvM1ZBCeveqfD4YeETYIKOiENCRIg5WGGlqvJLToZtT4kidT 27jw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=blgCGbsx; 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 k15si5786096pff.94.2021.10.25.15.23.12; Mon, 25 Oct 2021 15:23:26 -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=blgCGbsx; 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 S234731AbhJYTVC (ORCPT + 99 others); Mon, 25 Oct 2021 15:21:02 -0400 Received: from mail.kernel.org ([198.145.29.99]:38138 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234739AbhJYTT4 (ORCPT ); Mon, 25 Oct 2021 15:19:56 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 5D6576108C; Mon, 25 Oct 2021 19:17:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1635189454; bh=3eublEtbAHJH2wDIYeS2U2RNXI5uX1YDYBvhIOSPYQY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=blgCGbsxJWzfm0JrB0LGbnuY5WecxdgMr8693kHdL8FRZgLmFurtfi9yL1zSkWQVv JqBjr5sqOeL8H1UhPQQ/qHPQ0QBf7e4q+r18rFpAIyyLpPdWdPrzAH9XUC2Tyn58VU rvuCVghP4Ed27PDVVcRGERx+i8oeZpuR4pdA8QoY= 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.4 40/44] ALSA: hda: avoid write to STATESTS if controller is in reset Date: Mon, 25 Oct 2021 21:14:21 +0200 Message-Id: <20211025190936.713963849@linuxfoundation.org> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211025190928.054676643@linuxfoundation.org> References: <20211025190928.054676643@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 4727f5b80e76..4ee3458ad810 100644 --- a/sound/hda/hdac_controller.c +++ b/sound/hda/hdac_controller.c @@ -288,8 +288,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