Received: by 2002:ab2:3141:0:b0:1ed:23cc:44d1 with SMTP id i1csp2302lqg; Thu, 29 Feb 2024 17:20:46 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVsuoC5q+tbAzV4Dp9lA6DUdqZ2oHxrgnd4bNZUo1K95iZRUSfM9lUxEaRVI3ez/SMYkdx9F19YYV9G5AQ0CcE0iTeP2KPxmtg5mOcpCQ== X-Google-Smtp-Source: AGHT+IGOoohx9cvjB3h/NuJqYG6HKbXl+ttPFXfOdGz8kBvplM3SAOkRJN6JysGQsuDEAlM/4M4Q X-Received: by 2002:a17:90a:4981:b0:29b:6a7:c52c with SMTP id d1-20020a17090a498100b0029b06a7c52cmr313182pjh.38.1709256046413; Thu, 29 Feb 2024 17:20:46 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709256046; cv=pass; d=google.com; s=arc-20160816; b=P1MdtM14fvYADR7wt1XJqmRbErpBK+ZVby0TGXxOoYXPn/FIQr/yVh9twMy4CHpOsj xoKfbdjoRPTzbk8ffn77SQlbnta3u/5Nttpdq7VTVlQ0zhV6bnzggUjrTW8Om2sRyob/ YLInSiRecb6qIHPY8jKSC5BpojqMZMwEHFQep2c8679qhashJCyATpJ6BznNHXZxlN/O 5EFc6hbmwNvEOb0kpROoR7Z1S9mCzz6KV7TOhtYLLWPTDg1RMEW7HPCTk/w/q6yc1JNP 8gwayw036GPqqX2uZJC0UwDMSNzR2hN9E13iQCEFIrKuD7/M4wbyNkTSakaCl57SUjdu tRBg== 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=8eX63ggw/SlvICRxbqzBzag4pSVNVLQSaMXoM3yRais=; fh=qFB0hK5iyshDUWnDVhxBUTsgVdjY1dVVGyM3xYliVGw=; b=ELxsoTntksfdLBV08ByV9BtFwtQg2/CKcfEt582rQle32OE9bpmf3K9y4DDIBSWhIm nW3trw2G4C5/MTC8/99OaYqtLMAdyUw6ys3kKLz+nJVyRXocWGLfTB22fDtLEx3WtON6 gAqSrUx4sgBHMwKBLMQzhaRzsdXqUNvk0Yys2VNMt/lfbIvbyT2K3bAUvuiJIuHwLgMW LPjlooKYKs1hRpAmDHdYJ+SWotlRWd0P0UmxZg5ihoqesggM02EM42OlEUp0bGy3Ym8X niIdBd3odCQb13KUr8mBsqwMpjdcFDiSC/DlkPlexgftTHMWxGsswDQ/lSQC2nc7gm4B sceg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@163.com header.s=s110527 header.b=RYoHruyp; 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-87765-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-87765-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=163.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id j12-20020a170902da8c00b001dc8c109c2bsi2399001plx.267.2024.02.29.17.20.46 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Feb 2024 17:20:46 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-87765-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@163.com header.s=s110527 header.b=RYoHruyp; 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-87765-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-87765-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 1C861285153 for ; Fri, 1 Mar 2024 01:20:46 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id DEF4B374C3; Fri, 1 Mar 2024 01:20:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=163.com header.i=@163.com header.b="RYoHruyp" Received: from m16.mail.163.com (m16.mail.163.com [220.197.31.2]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0EBD736118 for ; Fri, 1 Mar 2024 01:20:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=220.197.31.2 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709256026; cv=none; b=hf+RRND9G9LQeLQqC/kuhyeQsVIwnGTNCG202+m/qHUKKx+BP4ZyMyG0ivIUL7rBn+pjAndWZ8UsRLirSOZaW2xBilDUVCLcxa50V+izhSTNoASSpUnf8txtFYqiBOTw1XWv+fabvXYFOnsQ5BDsF4frT0/xh4kgzoC0yICvfog= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709256026; c=relaxed/simple; bh=0Qce3EgeLPkKjkHYKQFnccarXSgWI3VcDD+V67lSULE=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=EsjJYYuyhaWPCtFKeqDid28R/+zUn50r+pAJXas9oU0Ocke1mJuELiz4KfxIdNNzGD/Bbok30/xoFN9F07Eo+gkK35Z6JP7cB7cFoFeaxcFjBMOLg7msa8FsTQuHMK8uPM60JKGQVAU+NTXJUnNEFIqAkJoutwiQA7OYA6tzH70= 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=RYoHruyp; arc=none smtp.client-ip=220.197.31.2 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; bh=8eX63 ggw/SlvICRxbqzBzag4pSVNVLQSaMXoM3yRais=; b=RYoHruypxU2y8XMLNwpfe x82VogKFQ52DfiQ8DY2anUkdfP78KsUwqx73O6sGczzQ/Fv6zuv7XIb/I7zRBMWr 3RuR6RY72Rui/vcvrkeVGlzukpUiym0GYEK3F/12VWsbUbMelVwosdMOT+mSrhx+ p/I57hKRFvYLYNlvy88co0= Received: from localhost.localdomain (unknown [111.48.58.12]) by gzga-smtp-mta-g1-4 (Coremail) with SMTP id _____wCHb57yLOFlXN+REw--.49146S2; Fri, 01 Mar 2024 09:18:43 +0800 (CST) From: songxiebing To: tiwai@suse.de Cc: alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org, songxiebing@kylinos.cn, soxiebing@163.com, tiwai@suse.com Subject: [PATCH v2] ALSA: hda: optimize the probe codec process Date: Fri, 1 Mar 2024 09:18:41 +0800 Message-Id: <20240301011841.7247-1-soxiebing@163.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <878r35huf0.wl-tiwai@suse.de> References: <878r35huf0.wl-tiwai@suse.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CM-TRANSID:_____wCHb57yLOFlXN+REw--.49146S2 X-Coremail-Antispam: 1Uf129KBjvJXoW7Wry7tFW5Kw43KFW5Cr1DGFg_yoW8KF18p3 W7Cr1fGayxtF4akFs7Gw43Ka4xWa4vqan8Jw1Yyw13Zwn7Kr1fXr9YyrW8AFW8ur4I9r1Y vw4UK3WkX3s8CaUanT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x0piwIDrUUUUU= X-CM-SenderInfo: 5vr0xvpelqwqqrwthudrp/1tbiJxaUw2XAkqqxxgAAsM 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 --- Changes in v2: fix some non-ASCII comma letters. --- 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