Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp2440099imj; Mon, 18 Feb 2019 06:07:10 -0800 (PST) X-Google-Smtp-Source: AHgI3Ibn+kHkc1HgkL9jkZZ50nSCgnMHueOtrTrooSAF13tkkgwamziKUyu7+kYumYqa48BsevOS X-Received: by 2002:a65:424c:: with SMTP id d12mr19114748pgq.126.1550498830366; Mon, 18 Feb 2019 06:07:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550498830; cv=none; d=google.com; s=arc-20160816; b=l70jt8G1laLJR8TD59vF9nvQWoGfTAFC3VBMI66jAnuhNtiG2QRjdsw2Ulp4f1w2h2 5xUVieZnmjjIM+1OgBIt/hpx4SucG3mQiKG9o08wwm/vyLY6QM39WVlZk4eIfDuCMiFo lxsK/ohv0UksoEMwpyF/y6XAlAwV9PEEFZmvB0KF0//aG31D+9Mym71jEfHOG8glnc3P 0Sy1yjY7sJDOIgzN9MUhLuT4ckf/Q9t98YKHAYsbLFaG+3A1Mf/cZ0cFYWnacjzFGnEU kNS4b6n4fX5URI9k+f9gozWgdRrHcuF0Es+FBZVqlZ+0EgN7RaXGfj1z0TIDPrP6lgze H5og== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Z51JSNEPnOB8QtWQfR+NHVMWF/nb0bv3AZG5yH0bc7A=; b=ZUZUNDlvBtQsyPnyE7yUBjKDNukgOBVKvGM+8QtUv15SZLn8hbBRCsAyLhAiKK/lWL kPdz+PsKukrDucm61glE6DBmMSt7xYXFp4FQbvGl64jVBf2Y43XArc5Xlm6q35Us9sWg KjhG7oLwFhrN4/YGoaXUuvv1JAJdbMX/dIAnuGS3Pv/OAmohPzzPAU99n6U1GhFKsh3N qHH1Jq6ayhKGlf4E9ukUgxYaMtBm+Cb+NhOdMy1uYbYI8mqYTnCE1LK+LGdBRQkCCCTN Hi9YRF4wKeKu1BRB40U3iUhJ9kVEdM03gd5zdYEV94Atpq2V6kjfEZx3fBDP728mz/CW 6E2Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=cE3lpatR; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h6si12423468pgs.211.2019.02.18.06.06.54; Mon, 18 Feb 2019 06:07:10 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=cE3lpatR; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389948AbfBROEf (ORCPT + 99 others); Mon, 18 Feb 2019 09:04:35 -0500 Received: from mail.kernel.org ([198.145.29.99]:47002 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389331AbfBROEd (ORCPT ); Mon, 18 Feb 2019 09:04:33 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id CEE38204FD; Mon, 18 Feb 2019 14:04:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1550498672; bh=d8nozL5in4jiV0uR8sRhloYgPPeny4io0wR2zyeTWvc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cE3lpatRjwMrKRdM7Mcn9sQwng5GVvr7bs/5+/GdzS6VcIdNJn+S7EgJYhGZXBUwN D55cyUdBhg9f/r6KWTbbDNdJhhNnnVYGlaLqPq5/6/Em++gnG18YK85Da/QYBVNf8V JgMcz1AxPeHsOyv9qp/UR4PeIEkBY4x1PMSyXdII= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Takashi Iwai Subject: [PATCH 4.4 084/143] ALSA: hda - Serialize codec registrations Date: Mon, 18 Feb 2019 14:43:32 +0100 Message-Id: <20190218133532.140094760@linuxfoundation.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190218133529.099444112@linuxfoundation.org> References: <20190218133529.099444112@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.4-stable review patch. If anyone has any objections, please let me know. ------------------ From: Takashi Iwai commit 305a0ade180981686eec1f92aa6252a7c6ebb1cf upstream. In the current code, the codec registration may happen both at the codec bind time and the end of the controller probe time. In a rare occasion, they race with each other, leading to Oops due to the still uninitialized card device. This patch introduces a simple flag to prevent the codec registration at the codec bind time as long as the controller probe is going on. The controller probe invokes snd_card_register() that does the whole registration task, and we don't need to register each piece beforehand. Cc: Signed-off-by: Takashi Iwai Signed-off-by: Greg Kroah-Hartman --- sound/pci/hda/hda_bind.c | 3 ++- sound/pci/hda/hda_codec.h | 1 + sound/pci/hda/hda_intel.c | 2 ++ 3 files changed, 5 insertions(+), 1 deletion(-) --- a/sound/pci/hda/hda_bind.c +++ b/sound/pci/hda/hda_bind.c @@ -109,7 +109,8 @@ static int hda_codec_driver_probe(struct err = snd_hda_codec_build_controls(codec); if (err < 0) goto error_module; - if (codec->card->registered) { + /* only register after the bus probe finished; otherwise it's racy */ + if (!codec->bus->bus_probing && codec->card->registered) { err = snd_card_register(codec->card); if (err < 0) goto error_module; --- a/sound/pci/hda/hda_codec.h +++ b/sound/pci/hda/hda_codec.h @@ -68,6 +68,7 @@ struct hda_bus { unsigned int response_reset:1; /* controller was reset */ unsigned int in_reset:1; /* during reset operation */ unsigned int no_response_fallback:1; /* don't fallback at RIRB error */ + unsigned int bus_probing :1; /* during probing process */ int primary_dig_out_type; /* primary digital out PCM type */ unsigned int mixer_assigned; /* codec addr for mixer name */ --- a/sound/pci/hda/hda_intel.c +++ b/sound/pci/hda/hda_intel.c @@ -2100,6 +2100,7 @@ static int azx_probe_continue(struct azx int val; int err; + to_hda_bus(bus)->bus_probing = 1; hda->probe_continued = 1; /* Request display power well for the HDA controller or codec. For @@ -2200,6 +2201,7 @@ i915_power_fail: if (err < 0) hda->init_failed = 1; complete_all(&hda->probe_wait); + to_hda_bus(bus)->bus_probing = 0; return err; }