Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp4011087ybl; Mon, 3 Feb 2020 10:48:10 -0800 (PST) X-Google-Smtp-Source: APXvYqz7TEB55ajqIXwn+oJhQvwNN++JypaHfqZP63QSRbU+cSSRToe3n7jAVwFTAKOlO2fVhVce X-Received: by 2002:a9d:5885:: with SMTP id x5mr18484094otg.132.1580755690559; Mon, 03 Feb 2020 10:48:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1580755690; cv=none; d=google.com; s=arc-20160816; b=sxpMBaX29zg5gQ1mrkrQOBQVtWZ2FeDos+PtBwReiJ+6TAHa1b+zNVETegbdNuqfax lqy2m38hSgwMdiEbfu4g5FIIl8CVB1wkPbld6oEasXG7qXrv6BLxVtyyr+PXfdMpvhc8 edLrEB6z5lz/cxOS34OTjBBHQrcviJRKS+OJXYwyDsZT50Vrp88WpWbzHP7weY1jZpXP 9y8Vin6ra5b2/IYxTAxe09OEG0CnEolc3iofbal3kzCGmFDWIY9FnOX+qV1unPvEyIjS 8QMQCfNOWHbGA5smGrkIOgOZDQTV54v/pp9mob23R7fddrvGGDI2QRWqqZT/egyQE9Qk C/HA== 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=lkCVT6MPfdJ+M1VSQw0QbgADj0Eit+AU7mT0bRkI2oQ=; b=jn5KocXsYN/HBm8KPb9M4dqDxBxjWhB6L2MTF07Qcq0Jz5ltzkn8emCUB7DlFDd62R mvwHLwzqQN4S1eCba3wG51h1uBXRIPosMpLSz3DXHfyGotemQQyDzS/lt6r0Uuk4Gr6W 4AsQX7QyKa2C0R4+P24yHRibZ3vOwXeux/v1EOOALF7B0k1Wh60K9Oqwe0iUKqQz6RbE bL/daIPvtXPmka4E6wGT2t9cfTG/8ECM/4CzgRh6KE0k9gqRbrnBUgWxf7FXyqSBGN+H f5Ne/+SPsGPXoGFWfn9YTSMKhsWCiYVhvtim/Ej9rDvilbyCzkpUiTeS1njnUQQhp+rD ewyA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="COp8Fg/H"; 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 l14si9322084otk.225.2020.02.03.10.47.57; Mon, 03 Feb 2020 10:48: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="COp8Fg/H"; 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 S1730982AbgBCQff (ORCPT + 99 others); Mon, 3 Feb 2020 11:35:35 -0500 Received: from mail.kernel.org ([198.145.29.99]:50398 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731058AbgBCQfc (ORCPT ); Mon, 3 Feb 2020 11:35:32 -0500 Received: from localhost (unknown [104.132.45.99]) (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 53C4F2051A; Mon, 3 Feb 2020 16:35:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1580747731; bh=VliAeT8Po/eV+MTczlUWIup6JgY6fmjh0jhjULFIku0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=COp8Fg/H+MrDBis/u1I5Al6CMYpxWHI84guu2o/oQhFHxExIQe5NNy9NLlHUHIU7C bo8M3T19BfdDEJrHqaFuh9nxRX4f9PdEWhFAOjFd/WX/3FvPy+DIuTQXqNEsgbsCKt kNqRU74K8J9EMryPJTaOmyxG8RTPH2fq/REFLmQA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Kai Vehmanen , Pierre-Louis Bossart , Mark Brown , Sasha Levin Subject: [PATCH 5.4 45/90] ASoC: SOF: Intel: fix HDA codec driver probe with multiple controllers Date: Mon, 3 Feb 2020 16:19:48 +0000 Message-Id: <20200203161923.547205729@linuxfoundation.org> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200203161917.612554987@linuxfoundation.org> References: <20200203161917.612554987@linuxfoundation.org> User-Agent: quilt/0.66 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 From: Kai Vehmanen [ Upstream commit 2c63bea714780f8e1fc9cb7bc10deda26fada25b ] In case system has multiple HDA controllers, it can happen that same HDA codec driver is used for codecs of multiple controllers. In this case, SOF may fail to probe the HDA driver and SOF initialization fails. SOF HDA code currently relies that a call to request_module() will also run device matching logic to attach driver to the codec instance. However if driver for another HDA controller was already loaded and it already loaded the HDA codec driver, this breaks current logic in SOF. In this case the request_module() SOF does becomes a no-op and HDA Codec driver is not attached to the codec instance sitting on the HDA bus SOF is controlling. Typical scenario would be a system with both external and internal GPUs, with driver of the external GPU loaded first. Fix this by adding similar logic as is used in legacy HDA driver where an explicit device_attach() call is done after request_module(). Also add logic to propagate errors reported by device_attach() back to caller. This also works in the case where drivers are not built as modules. Signed-off-by: Kai Vehmanen Signed-off-by: Pierre-Louis Bossart Link: https://lore.kernel.org/r/20200110235751.3404-8-pierre-louis.bossart@linux.intel.com Signed-off-by: Mark Brown Signed-off-by: Sasha Levin --- sound/soc/sof/intel/hda-codec.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/sound/soc/sof/intel/hda-codec.c b/sound/soc/sof/intel/hda-codec.c index 3ca6795a89ba3..9e8233c10d860 100644 --- a/sound/soc/sof/intel/hda-codec.c +++ b/sound/soc/sof/intel/hda-codec.c @@ -24,19 +24,18 @@ #define IDISP_VID_INTEL 0x80860000 /* load the legacy HDA codec driver */ -#ifdef MODULE -static void hda_codec_load_module(struct hda_codec *codec) +static int hda_codec_load_module(struct hda_codec *codec) { +#ifdef MODULE char alias[MODULE_NAME_LEN]; const char *module = alias; snd_hdac_codec_modalias(&codec->core, alias, sizeof(alias)); dev_dbg(&codec->core.dev, "loading codec module: %s\n", module); request_module(module); -} -#else -static void hda_codec_load_module(struct hda_codec *codec) {} #endif + return device_attach(hda_codec_dev(codec)); +} /* enable controller wake up event for all codecs with jack connectors */ void hda_codec_jack_wake_enable(struct snd_sof_dev *sdev) @@ -116,10 +115,16 @@ static int hda_codec_probe(struct snd_sof_dev *sdev, int address) /* use legacy bus only for HDA codecs, idisp uses ext bus */ if ((resp & 0xFFFF0000) != IDISP_VID_INTEL) { hdev->type = HDA_DEV_LEGACY; - hda_codec_load_module(&hda_priv->codec); + ret = hda_codec_load_module(&hda_priv->codec); + /* + * handle ret==0 (no driver bound) as an error, but pass + * other return codes without modification + */ + if (ret == 0) + ret = -ENOENT; } - return 0; + return ret; #else hdev = devm_kzalloc(sdev->dev, sizeof(*hdev), GFP_KERNEL); if (!hdev) -- 2.20.1