From patchwork Fri Apr 26 15:28:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Pierre-Louis Bossart X-Patchwork-Id: 792688 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 4141DC4345F for ; Fri, 26 Apr 2024 15:33:20 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 59483F53; Fri, 26 Apr 2024 17:33:08 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 59483F53 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1714145598; bh=V8qQRyxQ4EsnHZfZSyfBBhj9fV9onTfLS3y/sSthVA8=; h=From:To:Cc:Subject:Date:List-Id:List-Archive:List-Help:List-Owner: List-Post:List-Subscribe:List-Unsubscribe:From; b=ctDlMWU92flhEF38Da/w7Kck1J4vW3j1mOEzCfwC9nEBcuu0ejZHqzMQ/GI4NRqeh gQMXevjFTGxMCWgVRTvm61fOvDBjD6pk+EePvgbcmUMTl0MzG1ArvHi9Mxp4W+hozB GuE+/xZJgmQGuagg7UGVMrhNQYCKT9EW8trW5eQ4= Received: by alsa1.perex.cz (Postfix, from userid 50401) id 43B27F80612; Fri, 26 Apr 2024 17:28:50 +0200 (CEST) Received: from mailman-core.alsa-project.org (mailman-core.alsa-project.org [10.254.200.10]) by alsa1.perex.cz (Postfix) with ESMTP id D7342F805F7; Fri, 26 Apr 2024 17:28:49 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 57F1DF80587; Fri, 26 Apr 2024 17:28:44 +0200 (CEST) Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 8569FF8003A for ; Fri, 26 Apr 2024 17:28:37 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 8569FF8003A Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key, unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=XqSCF/ws DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1714145320; x=1745681320; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=V8qQRyxQ4EsnHZfZSyfBBhj9fV9onTfLS3y/sSthVA8=; b=XqSCF/wsjoypJVjJ+ACy6eG1TNCIxkKqKw0WNkf30o3v2r5ZKts4QPMJ M/LqBDDTrNG/v7kOxwf/ZiaxLI5yrdYf0aDNxQXbg5b19tjb/ePICrIYi CkK6OkIRPaTgvuqUwn9W/sAXI3ustfKXHx2mdCl7iLOLJC4XsLAo5LOJc KMVcz8m6zH/+2b+yJQ/oMhO91Ig+de7C2hG/kOYfHgXjPZxHd+sN1Ie54 sbuzig5I4PgPMrQVPtIj86/GrG8Gb5Uj7Ygy/cke2Ne8zKDpx8vg05TDf BFA4CRhyxIRMPP03XiB/kSOgfNkJNgAWhc7TAJwePBEGramWItn/fFMep g==; X-CSE-ConnectionGUID: 441Zak2tTSCxwtDa7v35iQ== X-CSE-MsgGUID: Tf9B58WOTgS++gJLwXlgWw== X-IronPort-AV: E=McAfee;i="6600,9927,11056"; a="35272028" X-IronPort-AV: E=Sophos;i="6.07,232,1708416000"; d="scan'208";a="35272028" Received: from fmviesa010.fm.intel.com ([10.60.135.150]) by fmvoesa101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Apr 2024 08:28:36 -0700 X-CSE-ConnectionGUID: RGMX/zuFRkCGAmcJrRUCCA== X-CSE-MsgGUID: 7bCb/w8wQNqlD2D0P90Y3g== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,232,1708416000"; d="scan'208";a="25523682" Received: from atarkhan-mobl2.amr.corp.intel.com (HELO pbossart-mobl6.intel.com) ([10.212.33.33]) by fmviesa010-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Apr 2024 08:28:35 -0700 From: Pierre-Louis Bossart To: linux-sound@vger.kernel.org Cc: alsa-devel@alsa-project.org, tiwai@suse.de, broonie@kernel.org, Pierre-Louis Bossart , Mauro Carvalho Chehab , Bard Liao , =?utf-8?q?P=C3=A9ter_Ujfalusi?= Subject: [PATCH] ALSA: hda: intel-dsp-config: harden I2C/I2S codec detection Date: Fri, 26 Apr 2024 10:28:18 -0500 Message-Id: <20240426152818.38443-1-pierre-louis.bossart@linux.intel.com> X-Mailer: git-send-email 2.40.1 MIME-Version: 1.0 Message-ID-Hash: RJE4FD42KOGTREOE4A7NPORI6SOQLSAO X-Message-ID-Hash: RJE4FD42KOGTREOE4A7NPORI6SOQLSAO X-MailFrom: pierre-louis.bossart@linux.intel.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-alsa-devel.alsa-project.org-0; header-match-alsa-devel.alsa-project.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.9 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: 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 --- 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 6a384b922e4f..d1f6cdcf1866 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; }