Received: by 2002:a05:7208:9594:b0:7e:5202:c8b4 with SMTP id gs20csp2395440rbb; Tue, 27 Feb 2024 23:42:28 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWCHl4cFdHXVzPeoeMtXArX5BzdG5ITMtBwIZlY1I2wedyaGMGx9IydcqoQJdKSgoQ/jjHkEGQ6Gd3mGshUq76AHpkK6NetbAKz6MqrBQ== X-Google-Smtp-Source: AGHT+IGjBacu55FbC3puov/elPu7xpbTwM8Do9i8+6oPKyk8b1Cqmj7Q87j63SQDUnAhPmLTKmHA X-Received: by 2002:a17:906:d93c:b0:a43:9ddc:cd28 with SMTP id rn28-20020a170906d93c00b00a439ddccd28mr1741362ejb.0.1709106148568; Tue, 27 Feb 2024 23:42:28 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709106148; cv=pass; d=google.com; s=arc-20160816; b=loHAdWFJ+QgkyO1ZTY3/mitjKC+VGIUVePGtyU+t2iZ5we8xdN83r/ck0s1aecj3tT zGzXCsdIrYoqWuDMwaJV7xbNwn/zgZJg0tsrTL9EagB8vRsAEQiB360jgQ/SgYdLCdRI tCLltiBSsZF6eFvV5qPtQpq7EO3pmrFJLyeDRVWiKKr5VMujLt8TazVBy1XehOsrE0nx bmLXdL/YzbX6eibEsb/EUJhWwcS8IFm4imLbyTLFG72RsV1Fbp3kAAkzi1wB8QATe8rR Or+1ipLNvnosyMkTJhyHT9FcIR29rr+fphD9QVn96xQF1i1DCO6pLFBFVG2jvQHL9qwY v0vA== 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:message-id:date:subject:cc:to :from:dkim-signature; bh=ZJ1CeXr5L+70RmndFbrJnevySNkuujkOo+h0+Lv9h0U=; fh=R7Xc9hvWtEjCt3C5sdVO7KQynrozGKFf7GKe1BUj1rg=; b=lg6Ni22EHDAeCWmW6ahG0X33Y4cA08qdIyfArAw4bthRzC867NSTgdvyrxiXHzLoMf nj9qiJrT0/jWuBqBwG0SG7r2nsbb+g+X3AdkEveAiDmuo01qcFGkUSqRQVUSgZU3iv7K zJ7EgECOXtGqjU6M6DKMDLjr8M8WB6/4zi172NBLWnwFm+WyYSKB8lW6qMVBbPu+QiCN iQqCDSm6/AIBCK1l6onEz3xkOmnY3gPkwcq5vouGP+JrrZadJWjqxuRg0HP1jTecYofE pBfkr1ZdU4sft91MX2BGIswx0u83KFJFe8xOq2jB22lOJJbzRVOpx8cjro5maDppgtAA agAg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@163.com header.s=s110527 header.b=PqujgYET; arc=pass (i=1 spf=pass spfdomain=163.com dkim=pass dkdomain=163.com dmarc=pass fromdomain=163.com); spf=pass (google.com: domain of linux-kernel+bounces-84625-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-84625-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=163.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id z23-20020a170906715700b00a3ec1463a12si1472027ejj.348.2024.02.27.23.42.28 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Feb 2024 23:42:28 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-84625-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@163.com header.s=s110527 header.b=PqujgYET; arc=pass (i=1 spf=pass spfdomain=163.com dkim=pass dkdomain=163.com dmarc=pass fromdomain=163.com); spf=pass (google.com: domain of linux-kernel+bounces-84625-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-84625-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=163.com 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 am.mirrors.kernel.org (Postfix) with ESMTPS id 57EB11F23437 for ; Wed, 28 Feb 2024 07:42:28 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 45BF225542; Wed, 28 Feb 2024 07:42:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=163.com header.i=@163.com header.b="PqujgYET" Received: from m15.mail.163.com (m15.mail.163.com [45.254.50.220]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2C2CD24B41 for ; Wed, 28 Feb 2024 07:42:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.254.50.220 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709106141; cv=none; b=MOLG1UGLTevFiMTe9keRDWA5mUl6eLFYJWzaXOQug44CdyxvJYywOgkcU6Gi3WfG2AaWRrI9gf9A17sra48hpbLWd5K7VXd0NDFqGn4cYCI0Z4muFC7ClguNsoaVZAY96GJ12dDdnNQie8Ub3ToAUL3RU3Osb6hMs5/Rh2eAivI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709106141; c=relaxed/simple; bh=u84TQ2oYytZsBuH/zcjVZljLTWPVxv1MJltl+gVYCDc=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version:Content-Type; b=jGQ84iyMznqDJH+59ZQJth1Fo/Hd4J4gayLTh/VfRaDUQkVWA1xJQUteamJqaCq7SRH80rjKU7e0aXyePpYG5AIUEjdVVO+ZxRmcJoZ8sd8g4+jq4UECMuLreHpuENLk3HNijeELmrH5QDRO4hWshtVB2MQWsparJOpJ75dYWXw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=163.com; spf=pass smtp.mailfrom=163.com; dkim=pass (1024-bit key) header.d=163.com header.i=@163.com header.b=PqujgYET; arc=none smtp.client-ip=45.254.50.220 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=163.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=163.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:Subject:Date:Message-Id:MIME-Version: Content-Type; bh=ZJ1CeXr5L+70RmndFbrJnevySNkuujkOo+h0+Lv9h0U=; b=PqujgYETxj5f7eV9lUrTkoUzayo9LMbSPGWyHOPRvIQDbxPQP1lCJA5gQGeIjU mOrersbX7qIPd8kNbxGZqZSDU/ToKHAHBMu7JpoBQxo7DOOjQjVwUS6OiOfXdzVV 6qq1pkk5xVjb1OQgQlXgMK8qxTXJ45WlpwEL3srKXnuWs= Received: from localhost.localdomain (unknown [111.48.58.12]) by gzga-smtp-mta-g0-3 (Coremail) with SMTP id _____wDH7ou1495l4CPFFQ--.17527S2; Wed, 28 Feb 2024 15:41:41 +0800 (CST) From: songxiebing To: tiwai@suse.com Cc: alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org, songxiebing Subject: [PATCH v1] ALSA: hda: optimize the probe codec process Date: Wed, 28 Feb 2024 15:41:38 +0800 Message-Id: <20240228074138.23679-1-soxiebing@163.com> X-Mailer: git-send-email 2.25.1 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 Content-Transfer-Encoding: 8bit X-CM-TRANSID:_____wDH7ou1495l4CPFFQ--.17527S2 X-Coremail-Antispam: 1Uf129KBjvJXoW7Wry3Jr4UAFW7Ar1UJrWxtFb_yoW8Kr1Up3 W3Cr1fG3yxtF4akFs7Gw43Ka4xWa4kXan8Jw4Yyw13Xwn3Kr1fXr9YyrW8AFW8Cr429r1Y vw4UK3WkX3s8CaUanT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x07j0iifUUUUU= X-CM-SenderInfo: 5vr0xvpelqwqqrwthudrp/xtbB0BqSw2WXwG99aQAAsS From: songxiebing In azx_probe_codecs function,when bus->codec_mask is becomes to 0(no codecs), execute azx_init_chip, bus->codec_mask will be initialized to a value again, this causes snd_hda_codec_new function to run, the process is as follows: -->snd_hda_codec_new -->snd_hda_codec_device_init -->snd_hdac_device_init---snd_hdac_read_parm(...AC_PAR_VENDOR_ID) 2s ---snd_hdac_read_parm(...AC_PAR_VENDOR_ID) 2s ---snd_hdac_read_parm(...AC_PAR_SUBSYSTEM_ID) 2s ---snd_hdac_read_parm(...AC_PAR_REV_ID) 2s ---snd_hdac_read_parm(...AC_PAR_NODE_COUNT) 2s when no codecs, read communication is error, each command will be polled for 2 second,a total of 10s, it is easy to some problem. like this: 2 [ 14.833404][ 6] [ T164] hda 0006:00: Codec #0 probe error; disabling it... 3 [ 14.844178][ 6] [ T164] hda 0006:00: codec_mask = 0x1 4 [ 14.880532][ 6] [ T164] hda 0006:00: too slow response, last cmd=0x0f0000 5 [ 15.891988][ 6] [ T164] hda 0006:00: too slow response, last cmd=0x0f0000 6 [ 16.978090][ 6] [ T164] hda 0006:00: too slow response, last cmd=0x0f0001 7 [ 18.140895][ 6] [ T164] hda 0006:00: too slow response, last cmd=0x0f0002 8 [ 19.135516][ 6] [ T164] hda 0006:00: too slow response, last cmd=0x0f0004 10 [ 19.900086][ 6] [ T164] hda 0006:00: no codecs initialized 11 [ 45.573398][ 2] [ C2] watchdog: BUG: soft lockup - CPU#2 stuck for 22s! [kworker/2:0:25] Here, when bus->codec_mask is 0, use a direct break to avoid execute snd_hda_codec_new function. Signed-off-by: songxiebing --- sound/pci/hda/hda_controller.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/sound/pci/hda/hda_controller.c b/sound/pci/hda/hda_controller.c index e5c53ad..e1ece0a 100644 --- a/sound/pci/hda/hda_controller.c +++ b/sound/pci/hda/hda_controller.c @@ -1474,6 +1474,9 @@ int azx_probe_codecs(struct azx *chip, unsigned int max_slots) dev_warn(chip->card->dev, "Codec #%d probe error; disabling it...\n", c); bus->codec_mask &= ~(1 << c); + /* no codecs */ + if (bus->codec_mask == 0) + break; /* More badly, accessing to a non-existing * codec often screws up the controller chip, * and disturbs the further communications. -- 2.7.4