Received: by 2002:a25:b323:0:0:0:0:0 with SMTP id l35csp3092134ybj; Mon, 23 Sep 2019 14:42:23 -0700 (PDT) X-Google-Smtp-Source: APXvYqztqLEpFVXU0eLDojb3NOO8OjnyJhDlYVYvv8YKe4IxVpnZPQZVDZv28l0820YdcoWHMv/C X-Received: by 2002:a17:906:4554:: with SMTP id s20mr1673321ejq.257.1569274943781; Mon, 23 Sep 2019 14:42:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1569274943; cv=none; d=google.com; s=arc-20160816; b=rkppF6SE8+9pLfJAs7Yfjh4Oyutka+5+rL/XJFqCvo9ZQOTKqhgdXvF555Eai+TRxN JApONrUz7pd3kwZOvDaP0YKLH1ArHXcAAr5FRWm73uqIkQ1Yzlb8iiFNLsIZhru2bjRe 4dXR8invT+/p0dCTqcPAyj6+vUlcitJ0k2JwmRWVhoA6AB+K33Pbx636mUwgsMO5Ktgi pUdpuSetQB9uQq/FCHG6iu2DLJF8X/6p5+eqJgz1cYsbJ5fc9NT7JKX51xUCx5uVdOtN 7Yfe+Ao9HWO6HCg4LwOr0hTMH/8zQQ87QQ02aSQesqSyTgQM6rqaa9GdvLt55CHaCudu uvyQ== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=i6/6G7/6PV+IQWVgFHn5JvCQ0ndf0XuF3M4nq82WFWQ=; b=S5d0fJ1S1+AZ+SbRqe4VPpAPHzB8IUok8ptM6ZpAiQuRCUpsCbKqvTaICu+7IXreit NGGgifPDiodWiDxIpkK2hNKQ+akecnNAJDQsO4Zt/iw3BG7FM31+g9I1cJiBPYAW2//0 aLmw+TvH25oE1BEGqYok+9mN8iTsmznF22oh/nMusHtxuesFuh/0/yzw1DUGkhiArDod eEahiuXgXHjKsAGi0TB7Q/mSGhomoOvGDKfyr5KMPyB2QJ8cXscdnhPb8ynqEWKVdack I0Bksosgk9yKzhQLHT/rm09kIRZoGzZfk9S1UxuSrLUTrCwER4uz2PtFTE3FSttxJXP1 +APw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=NCiHBYmd; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h19si7055457edv.393.2019.09.23.14.42.00; Mon, 23 Sep 2019 14:42:23 -0700 (PDT) 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=NCiHBYmd; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390008AbfIVSqa (ORCPT + 99 others); Sun, 22 Sep 2019 14:46:30 -0400 Received: from mail.kernel.org ([198.145.29.99]:42588 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389973AbfIVSq3 (ORCPT ); Sun, 22 Sep 2019 14:46:29 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 2404420882; Sun, 22 Sep 2019 18:46:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1569177988; bh=iI2WbB/rCnOHq0Uw2puFP3RXiZkcf6+ZTzmBSTYmT9c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NCiHBYmdEaM9quja4FI4eNrMSBUulkKHZV+LHioechVUauHOBS5KIQFKna9QqKB8+ o1vGQ5zL7J1KkywONfLXYkKA+EIF7IvYoJsLa/n2OjT1AYYa9+jy5+XmKyhi0RRewU ur+LHD9ufLGrb0mirEmpSon9Mf0lyn76OIbiPN/0= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Takashi Iwai , Sasha Levin Subject: [PATCH AUTOSEL 5.3 081/203] ALSA: hda: Add codec on bus address table lately Date: Sun, 22 Sep 2019 14:41:47 -0400 Message-Id: <20190922184350.30563-81-sashal@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190922184350.30563-1-sashal@kernel.org> References: <20190922184350.30563-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Takashi Iwai [ Upstream commit ee5f85d9290fe25d460bd320b7fe073075d72d33 ] The call of snd_hdac_bus_add_device() is needed only for registering the codec onto the bus caddr_tbl[] that is referred essentially only in the unsol event handler. That is, the reason of this call and the release by the counter-part function snd_hdac_bus_remove_device() is just to assure that the unsol event gets notified to the codec. But the current implementation of the unsol notification wouldn't work properly when the codec is still in a premature init state. So this patch tries to work around it by delaying the caddr_tbl[] registration at the point of snd_hdac_device_register(). Also, the order of snd_hdac_bus_remove_device() and device_del() calls are shuffled to make sure that the unsol event is masked before deleting the device. BugLink: https://bugzilla.kernel.org/show_bug.cgi?id=204565 Signed-off-by: Takashi Iwai Signed-off-by: Sasha Levin --- sound/hda/hdac_device.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/sound/hda/hdac_device.c b/sound/hda/hdac_device.c index b26cc93e7e103..033bcef8751a8 100644 --- a/sound/hda/hdac_device.c +++ b/sound/hda/hdac_device.c @@ -61,10 +61,6 @@ int snd_hdac_device_init(struct hdac_device *codec, struct hdac_bus *bus, pm_runtime_get_noresume(&codec->dev); atomic_set(&codec->in_pm, 0); - err = snd_hdac_bus_add_device(bus, codec); - if (err < 0) - goto error; - /* fill parameters */ codec->vendor_id = snd_hdac_read_parm(codec, AC_NODE_ROOT, AC_PAR_VENDOR_ID); @@ -143,15 +139,22 @@ int snd_hdac_device_register(struct hdac_device *codec) err = device_add(&codec->dev); if (err < 0) return err; + err = snd_hdac_bus_add_device(codec->bus, codec); + if (err < 0) + goto error; mutex_lock(&codec->widget_lock); err = hda_widget_sysfs_init(codec); mutex_unlock(&codec->widget_lock); - if (err < 0) { - device_del(&codec->dev); - return err; - } + if (err < 0) + goto error_remove; return 0; + + error_remove: + snd_hdac_bus_remove_device(codec->bus, codec); + error: + device_del(&codec->dev); + return err; } EXPORT_SYMBOL_GPL(snd_hdac_device_register); @@ -165,8 +168,8 @@ void snd_hdac_device_unregister(struct hdac_device *codec) mutex_lock(&codec->widget_lock); hda_widget_sysfs_exit(codec); mutex_unlock(&codec->widget_lock); - device_del(&codec->dev); snd_hdac_bus_remove_device(codec->bus, codec); + device_del(&codec->dev); } } EXPORT_SYMBOL_GPL(snd_hdac_device_unregister); -- 2.20.1