Received: by 2002:ab2:6991:0:b0:1f7:f6c3:9cb1 with SMTP id v17csp176970lqo; Tue, 7 May 2024 16:48:58 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWl9rSweG3wjA+D+ckgIzHqivYHNERaD2UWSkHEyDJR5UJgZcmrdB85JidPWlltszlddQETPZDpqWCaDRYykzwtc8Wr4BqBIphtrLIggw== X-Google-Smtp-Source: AGHT+IGDQIk+8UCJBHGXI/U32FYu0xFSFTr44Ede2LPfRcuM21WF7ftQfTUjRO5ktsbJ+gtuhLl+ X-Received: by 2002:a9d:7e93:0:b0:6f0:39d2:69ca with SMTP id 46e09a7af769-6f0b796293amr1107598a34.19.1715125738622; Tue, 07 May 2024 16:48:58 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715125738; cv=pass; d=google.com; s=arc-20160816; b=PgD1y9hIJQ3tuyAVMB7pTWWoLZojWIoXWzel+8ibfsCgZcaHcOAqEFMU0KfY6Vd/cx zTj3sJCNSbSLo4pqfBk+LL97jBnVDCg8gKTfbpCCJlFAafHArkGC629qb2P+e6ptde5n vqQcHuUcR+T1ZveEe3fI34bq89t6x4h6XNmsM+j00UdgvTIqC2EJeeLAWTcGCHJbVJiR 3uWR5LEaDV/UCwwT/MdWkzVKM5SDd+KqAixxg5lZO9x98eBCi3x/eAIgmAXwyEUVSHyc bTV5MZZhoZKy1KUAASj3wjbWTJHdzDQJ0GW7JODU+w3+NzilvyWYvnDy49qSVYDaQlp/ 8mjA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=WGhrKCObJEyX4Yg2z3Yy+FFStcNuKnJHobSmVMjAh30=; fh=ebVdt33s7u9NcZMpue4ZuohinLgYfj/ejprHR95KLaE=; b=TboqZNMGqWwBoqGXiluTKLOjnVKb9IY27FGvM6xPR8DklRV043Q5+CVyZ70S4yYt4s O4tUdKmJL9DZTdqQ8gMdGzUVOmuiNiqHU58XUxj7TKFbYsdnk+XRVYDYjAYM14B848/t de1ERH+k+nMWU6nynN+VpRtOCZrvFkh4EFqmIqo8+JE5T0zt9/1gCUYkVtK86ccCYPtY q3RDSFoYFF6SSedBqTTHTGRIyvhb4e8NSXgoFN/+8Bpz+pwchHk3VtDVAgtmRpPvu+tz O/NBmgSp9J/gupTVKCTacGX+KeQdGu+lj3hhA1Fu0CjchB2z6Lk7QcE2+gLxuf4AT8Po ayfg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=oDGSunz5; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-172376-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-172376-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id a10-20020a631a0a000000b005d7bf204e26si11721062pga.899.2024.05.07.16.48.58 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 May 2024 16:48:58 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-172376-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=oDGSunz5; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-172376-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-172376-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 11336B27FE8 for ; Tue, 7 May 2024 23:30:24 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9A8A0144315; Tue, 7 May 2024 23:09:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="oDGSunz5" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BB3E61442EA; Tue, 7 May 2024 23:09:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715123344; cv=none; b=T8KhOeokMEO3VoseBVgGd3qyD0ar+H+r/raGds/8lDsJDzd7QojVX4loOcMZSiK3SGkqYvMRX/8K1836r88vpiy/DXtn+PNTCijSSM/aHSZdqE0xG3me2LhEVvd7TxibjsWoQX1G9HCvjfyCnG7a3b+1O2lvh2mSsvxz6n59dME= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715123344; c=relaxed/simple; bh=n62GchpgHmjR40eE42PIoLqi1koZrXaqgEhx3LCtJdE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=XnRzHeHEHODhA7AulipPBXKsOVuyzJgCTp7GIrZUMZvdRdh+XahUrQfLYsBuDW0LdlocgOyAc3wqX0rsL4gLXLQfkC2iE2aIMgO5utx3qPGgd59WpWfMwFg/hU0jXw8gjjORgoAqTKsTcTY4WcZKW47a+NjuVcKn7mBaNLkvAHw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=oDGSunz5; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1418CC4AF68; Tue, 7 May 2024 23:09:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1715123344; bh=n62GchpgHmjR40eE42PIoLqi1koZrXaqgEhx3LCtJdE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=oDGSunz5CJ/ULz9l/TG14bd4PJ8vMdxO84/5NtOMXApKwfNfX1ocGdYMcEf4OQR1H k1JE0R2by4v8dg0T7gjSunLlSlftQrtyZmv5SQYMBDIoArNEnaYBG4F5s8tKCUSsXA f+l3KrS07w4aGzi7KzzSoPjt0MW5/xobPRSa9G5k6OuuM1KPEGzboTjcK7ye0Rmeeo eQw/DzljwcnvF0ymCXZWeAqwzGfPPOwUKOG8qITMgLD0fqXipPvCfYaxDSWsZPQa/N PNZyNpyDNxW+jfcbrWSWjaEeSwSHcBpuY7guyIMh1fIHXTsEtfEOKQd49Yom+DUp+E JiOTnMAiW0gAA== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Pierre-Louis Bossart , Mauro Carvalho Chehab , Bard Liao , =?UTF-8?q?P=C3=A9ter=20Ujfalusi?= , Takashi Iwai , Sasha Levin , perex@perex.cz, tiwai@suse.com, broonie@kernel.org, amadeuszx.slawinski@linux.intel.com, markhas@chromium.org, bradynorander@gmail.com, linux-sound@vger.kernel.org Subject: [PATCH AUTOSEL 6.8 33/52] ALSA: hda: intel-dsp-config: harden I2C/I2S codec detection Date: Tue, 7 May 2024 19:06:59 -0400 Message-ID: <20240507230800.392128-33-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240507230800.392128-1-sashal@kernel.org> References: <20240507230800.392128-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-stable: review X-Patchwork-Hint: Ignore X-stable-base: Linux 6.8.9 Content-Transfer-Encoding: 8bit From: Pierre-Louis Bossart [ Upstream commit 79ac4c1443eaec0d09355307043a9149287f23c1 ] The SOF driver is selected whenever specific I2C/I2S HIDs are reported as 'present' in the ACPI DSDT. In some cases, an HID is reported but the hardware does not actually rely on I2C/I2S. This false positive leads to an invalid selection of the SOF driver and as a result an invalid topology is loaded. This patch hardens the detection with a check that the NHLT table is consistent with the report of an I2S-based codec in DSDT. This table should expose at least one SSP endpoint configured for an I2S-codec connection. Tested on Huawei Matebook D14 (NBLB-WAX9N) using an HDaudio codec with an invalid ES8336 ACPI HID reported: [ 7.858249] snd_hda_intel 0000:00:1f.3: DSP detected with PCI class/subclass/prog-if info 0x040380 [ 7.858312] snd_hda_intel 0000:00:1f.3: snd_intel_dsp_find_config: no valid SSP found for HID ESSX8336, skipped Reported-by: Mauro Carvalho Chehab Tested-by: Mauro Carvalho Chehab Closes: https://github.com/thesofproject/linux/issues/4934 Signed-off-by: Pierre-Louis Bossart Reviewed-by: Bard Liao Reviewed-by: Péter Ujfalusi Message-ID: <20240426152818.38443-1-pierre-louis.bossart@linux.intel.com> Signed-off-by: Takashi Iwai Signed-off-by: Sasha Levin --- sound/hda/intel-dsp-config.c | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/sound/hda/intel-dsp-config.c b/sound/hda/intel-dsp-config.c index 6a384b922e4fa..d1f6cdcf1866e 100644 --- a/sound/hda/intel-dsp-config.c +++ b/sound/hda/intel-dsp-config.c @@ -557,9 +557,32 @@ static const struct config_entry *snd_intel_dsp_find_config if (table->codec_hid) { int i; - for (i = 0; i < table->codec_hid->num_codecs; i++) - if (acpi_dev_present(table->codec_hid->codecs[i], NULL, -1)) + for (i = 0; i < table->codec_hid->num_codecs; i++) { + struct nhlt_acpi_table *nhlt; + bool ssp_found = false; + + if (!acpi_dev_present(table->codec_hid->codecs[i], NULL, -1)) + continue; + + nhlt = intel_nhlt_init(&pci->dev); + if (!nhlt) { + dev_warn(&pci->dev, "%s: NHLT table not found, skipped HID %s\n", + __func__, table->codec_hid->codecs[i]); + continue; + } + + if (intel_nhlt_has_endpoint_type(nhlt, NHLT_LINK_SSP) && + intel_nhlt_ssp_endpoint_mask(nhlt, NHLT_DEVICE_I2S)) + ssp_found = true; + + intel_nhlt_free(nhlt); + + if (ssp_found) break; + + dev_warn(&pci->dev, "%s: no valid SSP found for HID %s, skipped\n", + __func__, table->codec_hid->codecs[i]); + } if (i == table->codec_hid->num_codecs) continue; } -- 2.43.0