From patchwork Wed Apr 10 02:34:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bard Liao X-Patchwork-Id: 13623485 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.14]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C088A8F6C; Wed, 10 Apr 2024 02:34:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.14 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712716488; cv=none; b=d5SlACCQ5E1qPW9GkBg8ZnMf6sRlNoP2srSsLGzHQgmBrN/4QoT0l6frg2AzZSeSSwonOpG7+BltoUFWS6EDeeHBMZlL6IvMBFZlCw/LLxwW/3HGStftopGjZkSOnewIDNxTtlHvh8fC52xoYFgNPzV3BA4BPHg+ztYR0jfaXb8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712716488; c=relaxed/simple; bh=+bbMHOAF08ZcNLfeOm1aEmYLRv5ZcZsPcqoJH5RcMNE=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=TKrzx7c1rlcCN4iJ7rFAUmP9uTZJTipsCPAHYYpGIr1SYsaZPlf80dBbhtSNVRMpD+hWze8JdLxOBdoCTldAmGobOCjRUHalZ5hjQhpN3LafqAYg8PdhPNgvQxWhuIG9VXGoKGNQ5SjtHg1yBMGpaH3A1W1Er+utSStzeohUAe8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=NGhePdET; arc=none smtp.client-ip=198.175.65.14 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="NGhePdET" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1712716487; x=1744252487; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=+bbMHOAF08ZcNLfeOm1aEmYLRv5ZcZsPcqoJH5RcMNE=; b=NGhePdETB52Q6+hq2wJbHv0P0a/VFWoEJ2fX7AXtryZTuWHmJI/QWJSQ bSq7VVlUsASyvdYcA8A66ybCiQ4ZbrtX1Owlhrp3xP/1n7MLrJdflx3B5 lrN6nlso3tNYlFBOsRkSdQ6vJlzs1dyFXDcI4i367Qs3Goa1uBz09C/Xz BKGd1/PNpA8zO1aEdKHj9njqyI5oDGYePovD5QRX3ZQ6z0DI/O6lmesYH l2kM0wJyr/tDu/MamXx/IRCE4lA/DL24PmJxkCKpXthjHZ2BFvn/yXitV HMYWj56MwmvL+4jwAvOtx17zCuJHPs/BcypQgepHKa5yIgV0ZLwOLOWoU w==; X-CSE-ConnectionGUID: ecvsHdQ8SWmgoImVzW0W6w== X-CSE-MsgGUID: bA7xFgDjQ1iCM1yBvWof/g== X-IronPort-AV: E=McAfee;i="6600,9927,11039"; a="11900168" X-IronPort-AV: E=Sophos;i="6.07,190,1708416000"; d="scan'208";a="11900168" Received: from fmviesa002.fm.intel.com ([10.60.135.142]) by orvoesa106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Apr 2024 19:34:44 -0700 X-CSE-ConnectionGUID: qtxdygQ0SYaBgvkefi6Y/Q== X-CSE-MsgGUID: aqZN1BA0QMiVbMJYGmbyog== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,190,1708416000"; d="scan'208";a="43658574" Received: from yungchua-ws.ostc.intel.com (HELO yungchua-ws.intel.com) ([10.54.69.90]) by fmviesa002-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Apr 2024 19:34:43 -0700 From: Bard Liao To: linux-sound@vger.kernel.org, vkoul@kernel.org, broonie@kernel.org, tiwai@suse.de Cc: vinod.koul@linaro.org, linux-kernel@vger.kernel.org, pierre-louis.bossart@linux.intel.com, bard.liao@intel.com Subject: [PATCH 1/4] ASoC: SOF: Intel: hda: disable SoundWire interrupt later Date: Wed, 10 Apr 2024 02:34:35 +0000 Message-Id: <20240410023438.487017-2-yung-chuan.liao@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240410023438.487017-1-yung-chuan.liao@linux.intel.com> References: <20240410023438.487017-1-yung-chuan.liao@linux.intel.com> Precedence: bulk X-Mailing-List: linux-sound@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Pierre-Louis Bossart The SoundWire interrupts can be masked at two levels a) in the Cadence IP b) at the HDaudio controller level We have an existing mechanism with cancel_work_sync() and status flags to make sure all existing interrupts are handled in the Cadence IP, and likewise no new interrupts can be generated before turning off the links. However on remove we first use the higher-level mask at the controller level, which is a sledgehammer preventing interrupts from all links. This is very racy and not necessary. We can disable the SoundWire interrupts after all the cleanups are done without any loss of functionality. Signed-off-by: Pierre-Louis Bossart Signed-off-by: Bard Liao Acked-by: Mark Brown --- sound/soc/sof/intel/hda.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sound/soc/sof/intel/hda.c b/sound/soc/sof/intel/hda.c index 7fe72b065451..ecfdb8f882d2 100644 --- a/sound/soc/sof/intel/hda.c +++ b/sound/soc/sof/intel/hda.c @@ -384,12 +384,12 @@ static int hda_sdw_exit(struct snd_sof_dev *sdev) hdev = sdev->pdata->hw_pdata; - hda_sdw_int_enable(sdev, false); - if (hdev->sdw) sdw_intel_exit(hdev->sdw); hdev->sdw = NULL; + hda_sdw_int_enable(sdev, false); + return 0; } From patchwork Wed Apr 10 02:34:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bard Liao X-Patchwork-Id: 13623484 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.14]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 49A30443D; Wed, 10 Apr 2024 02:34:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.14 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712716487; cv=none; b=Gze6PmO+XzjTt68VGOM5/zllHQ8zyDhonVdoyDkiOgSndSRxDVSAiWT3HFKtjl9an/uGNqWrZzYTGv5oHz1n+kzqOkosf51vQnAKbpCwZCqRCSgXvhGYQY9Pv2XYOpmzWYgPalxXBKWe3bbkh4HRuIgNd7D7SO5vRpRwh9lk2mQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712716487; c=relaxed/simple; bh=obH8pri35IMIPHiw0rnrgYA4QrSMOsXif7LAyLVLGB0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=lXO0v2ib5oqBMR3zXtknkBqNXZQFVdoAYneP/AWVLKyuJ5cyiKAa7v2eQ9PSbWaTqv/SESC2Oqin4tnrFVES/UflaBdsxIVMjhSedlGQ9b/W/mm4W9Kj6xhq1ETzaRVLOv2++VMgcJAi6XHzgxVQhPibXXxSQLtIvGqPICBEChE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=j207AYj/; arc=none smtp.client-ip=198.175.65.14 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="j207AYj/" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1712716487; x=1744252487; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=obH8pri35IMIPHiw0rnrgYA4QrSMOsXif7LAyLVLGB0=; b=j207AYj/M9WDmWFONmDfypYTPio64PkH4M2pAzsmNlqLi7VpGZWVBY4Q YRGHxz+BVrly1qd8VB+El0Yar2to9Bj1+y0FjetbKZjXz5kguSY+NwTLR ll0N9HcdrJ3bPr+3POZeGnhe3ZybprORkSPdBZNDua/aQRRrfc9VWnq79 HMJtOBq/2cQTEywB+2VhrLj4Vx442ruHPpVhVvr+MEwmsgtqqAtna2+6/ 5gJLmQAdZSStbJ98CK40kUtGfpRLj74mJKGopGgI1scMbPqNIhUTewm3l qtodJTMTxSELbCq2T+WkUKHcwUqxGDH+9yBeVDsqyDckeHjDKUzJIdiRM A==; X-CSE-ConnectionGUID: Dcc+fXY4TG26QBT9RUsbWw== X-CSE-MsgGUID: UjlgGBg+RRC78/mgtAcjqA== X-IronPort-AV: E=McAfee;i="6600,9927,11039"; a="11900172" X-IronPort-AV: E=Sophos;i="6.07,190,1708416000"; d="scan'208";a="11900172" Received: from fmviesa002.fm.intel.com ([10.60.135.142]) by orvoesa106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Apr 2024 19:34:44 -0700 X-CSE-ConnectionGUID: foB0regWTUimANlQnBFcWQ== X-CSE-MsgGUID: yyTcIY9BQM2aAHkseN552A== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,190,1708416000"; d="scan'208";a="43658577" Received: from yungchua-ws.ostc.intel.com (HELO yungchua-ws.intel.com) ([10.54.69.90]) by fmviesa002-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Apr 2024 19:34:44 -0700 From: Bard Liao To: linux-sound@vger.kernel.org, vkoul@kernel.org, broonie@kernel.org, tiwai@suse.de Cc: vinod.koul@linaro.org, linux-kernel@vger.kernel.org, pierre-louis.bossart@linux.intel.com, bard.liao@intel.com Subject: [PATCH 2/4] soundwire: intel_auxdevice: use pm_runtime_resume() instead of pm_request_resume() Date: Wed, 10 Apr 2024 02:34:36 +0000 Message-Id: <20240410023438.487017-3-yung-chuan.liao@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240410023438.487017-1-yung-chuan.liao@linux.intel.com> References: <20240410023438.487017-1-yung-chuan.liao@linux.intel.com> Precedence: bulk X-Mailing-List: linux-sound@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 We need to wait for each child to fully resume. pm_request_resume() is asynchronous, what we need is to wait synchronously to avoid race conditions. Signed-off-by: Bard Liao --- drivers/soundwire/intel_auxdevice.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/soundwire/intel_auxdevice.c b/drivers/soundwire/intel_auxdevice.c index 95125cc2fc59..012232cfbf7f 100644 --- a/drivers/soundwire/intel_auxdevice.c +++ b/drivers/soundwire/intel_auxdevice.c @@ -454,9 +454,9 @@ static int intel_resume_child_device(struct device *dev, void *data) return 0; } - ret = pm_request_resume(dev); + ret = pm_runtime_resume(dev); if (ret < 0) { - dev_err(dev, "%s: pm_request_resume failed: %d\n", __func__, ret); + dev_err(dev, "%s: pm_runtime_resume failed: %d\n", __func__, ret); return ret; } @@ -499,9 +499,9 @@ static int __maybe_unused intel_pm_prepare(struct device *dev) * first resume the device for this link. This will also by construction * resume the PCI parent device. */ - ret = pm_request_resume(dev); + ret = pm_runtime_resume(dev); if (ret < 0) { - dev_err(dev, "%s: pm_request_resume failed: %d\n", __func__, ret); + dev_err(dev, "%s: pm_runtime_resume failed: %d\n", __func__, ret); return 0; } From patchwork Wed Apr 10 02:34:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bard Liao X-Patchwork-Id: 13623486 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.14]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CE745BA2E; Wed, 10 Apr 2024 02:34:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.14 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712716489; cv=none; b=P/IP8iejBbQ13zU2Cj5xvBZ1Vyflts0T7gl5sv6PLR2/xuq2r5N5P+sVFF0pncYPYacUZuJJ5MkNqf8eNMdp74O36VENtEtX/uU9/o7fRE5hUtsKlFyamJrySVl2+XkrFr26mo0fOiEav42HjCJjbvcNQapXcYsSTU7hG+sPGk8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712716489; c=relaxed/simple; bh=Rn0azuAjLZ3nmPsyZ9+vuDVhIZO652cxcna9Kq/oIgw=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=omHJYCLWZcUGau9fSEHOLTVV72GxGUbye/rlQjP2RG2kGOBr4XHnx2viqOrsjXrfQhOY5/95vwJFxV9lBV3u1PuxPpcZQAkmHwLmvfSZ+PBj7uEneLl8X91mQcE7E1GmuLp3hVvq+pw+pGVdfyMWylZ72UOMOXXRht3W7fDnUkI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=LDW7X7wk; arc=none smtp.client-ip=198.175.65.14 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="LDW7X7wk" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1712716488; x=1744252488; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Rn0azuAjLZ3nmPsyZ9+vuDVhIZO652cxcna9Kq/oIgw=; b=LDW7X7wkd4o/vPBKnfdfeaALPFvt4P5LlW3QZKILTVPlDZ4fobKwq5KJ uWB0n/B3NwqLbb3Kr4ZHxdmAAerH3urL4ApXAztDXb8j+QKAGM8FfgTDJ iQy3h8FIFjHb8y9cVD3Y6npKXb+lJ7+Z3ZcragtkzEGmCtDnAWa1cU5tC PHR8IrxRwx0boGtB5LCCit+ErkDQtr8jOO5p08NKVfygi5zmEha8JxcOI VRHiGdPcQKbOW49BEHkLaC9eCu+iCLA/zZpSv2eSQ/ZVgDk/UvK1JSrqd v4Z19AIWyMNSp7/r01G1HvIaei0hmEC2GmvtLetugiVphXgNfp4ve9R0M A==; X-CSE-ConnectionGUID: 0Jkws6lgTfaSfH5qLJX4Mg== X-CSE-MsgGUID: JwuZAkpjTpWR1X54wbE82g== X-IronPort-AV: E=McAfee;i="6600,9927,11039"; a="11900176" X-IronPort-AV: E=Sophos;i="6.07,190,1708416000"; d="scan'208";a="11900176" Received: from fmviesa002.fm.intel.com ([10.60.135.142]) by orvoesa106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Apr 2024 19:34:45 -0700 X-CSE-ConnectionGUID: uF1j9F4bTVG6DnxNTO799w== X-CSE-MsgGUID: Jfq8zdJ2QeODDczbAk7aMw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,190,1708416000"; d="scan'208";a="43658581" Received: from yungchua-ws.ostc.intel.com (HELO yungchua-ws.intel.com) ([10.54.69.90]) by fmviesa002-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Apr 2024 19:34:44 -0700 From: Bard Liao To: linux-sound@vger.kernel.org, vkoul@kernel.org, broonie@kernel.org, tiwai@suse.de Cc: vinod.koul@linaro.org, linux-kernel@vger.kernel.org, pierre-louis.bossart@linux.intel.com, bard.liao@intel.com Subject: [PATCH 3/4] soundwire: intel: export intel_resume_child_device Date: Wed, 10 Apr 2024 02:34:37 +0000 Message-Id: <20240410023438.487017-4-yung-chuan.liao@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240410023438.487017-1-yung-chuan.liao@linux.intel.com> References: <20240410023438.487017-1-yung-chuan.liao@linux.intel.com> Precedence: bulk X-Mailing-List: linux-sound@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 We will resume each child in the next patch, and intel_resume_child_device() will be used. Signed-off-by: Bard Liao --- drivers/soundwire/intel_auxdevice.c | 2 +- drivers/soundwire/intel_auxdevice.h | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/soundwire/intel_auxdevice.c b/drivers/soundwire/intel_auxdevice.c index 012232cfbf7f..296a470ce1e0 100644 --- a/drivers/soundwire/intel_auxdevice.c +++ b/drivers/soundwire/intel_auxdevice.c @@ -440,7 +440,7 @@ int intel_link_process_wakeen_event(struct auxiliary_device *auxdev) * PM calls */ -static int intel_resume_child_device(struct device *dev, void *data) +int intel_resume_child_device(struct device *dev, void *data) { int ret; struct sdw_slave *slave = dev_to_sdw_dev(dev); diff --git a/drivers/soundwire/intel_auxdevice.h b/drivers/soundwire/intel_auxdevice.h index a00ecde95563..acaae0bd6592 100644 --- a/drivers/soundwire/intel_auxdevice.h +++ b/drivers/soundwire/intel_auxdevice.h @@ -6,6 +6,7 @@ int intel_link_startup(struct auxiliary_device *auxdev); int intel_link_process_wakeen_event(struct auxiliary_device *auxdev); +int intel_resume_child_device(struct device *dev, void *data); struct sdw_intel_link_dev { struct auxiliary_device auxdev; From patchwork Wed Apr 10 02:34:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bard Liao X-Patchwork-Id: 13623487 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.14]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 60043BE62; Wed, 10 Apr 2024 02:34:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.14 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712716489; cv=none; b=bPI3jiWDSZlk7tByX2Fp6qE/F3rOy75mxqRyOGIZNcssYt2lFWq4T2v6m/otuvzIuUVN7h5peYu3602GRGPOo4tANApZ4d4z9aT4Ds05Owy4BKU5XRtUuroeow6yexZLAjvbuDUQiL8/J595L7JN/0RN7z43N3+rVizZW26P0cg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712716489; c=relaxed/simple; bh=97waEfdu4g/jn/zcy7Jw0obSybbX1Ba1zMABmsAkRe0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=l6xSvJNT5PZNg8FiHyQXkBeTD9mNI77DTvNmhsiug5+EntlJEulqKbKWzAt4k+S6FRVYL8zxKen46+fUrA3i3UqdMohVIj6Q59LT12BirC2D2Yur0M6x7rmsoXo2aXL8mvLgSNIKTniQclfxEUW66GH3LhhfjE0kTEf21HegFvM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=IKtPTZq/; arc=none smtp.client-ip=198.175.65.14 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="IKtPTZq/" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1712716489; x=1744252489; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=97waEfdu4g/jn/zcy7Jw0obSybbX1Ba1zMABmsAkRe0=; b=IKtPTZq/GO8UJKZ0y3F99sPupBomTAaYRkcTo4Pq2oQUE01m3A6msakE jHxyvXM3eePerAwNaUOOgdFdry3EXw/RfdPYJeYjPrcAVahq8hQzI2dpY tdJMCvL2siq4qlMH+gaW/dewrzwKLnzN3gaQ4zLQxgwanoFU2Ga4nkO8c MWb1jpEdLgrIfM+mm/3iKYLOPJg+wx9h4yFoRFMYJutIwB/d8Wq2nq50B InzGMJSMTPq5lkimD0c4dgTI+OH7iybOnDuFILdEy4Ft29mVteA3iyTJ+ Hgj3TjTvmzLJXwwus8I/qnCu7fYFNaniSQzp+CEiNRaUlZQxAwFdk+FJj A==; X-CSE-ConnectionGUID: YfQZkmRMQ9SrGgdx4nM6KA== X-CSE-MsgGUID: jzvd2IvLQUaF7Sgng1BLag== X-IronPort-AV: E=McAfee;i="6600,9927,11039"; a="11900180" X-IronPort-AV: E=Sophos;i="6.07,190,1708416000"; d="scan'208";a="11900180" Received: from fmviesa002.fm.intel.com ([10.60.135.142]) by orvoesa106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Apr 2024 19:34:45 -0700 X-CSE-ConnectionGUID: C0dh7/ybRy+ntOWUiALZEw== X-CSE-MsgGUID: V6jwpZppQZCusLJQQRHtzw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,190,1708416000"; d="scan'208";a="43658584" Received: from yungchua-ws.ostc.intel.com (HELO yungchua-ws.intel.com) ([10.54.69.90]) by fmviesa002-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Apr 2024 19:34:44 -0700 From: Bard Liao To: linux-sound@vger.kernel.org, vkoul@kernel.org, broonie@kernel.org, tiwai@suse.de Cc: vinod.koul@linaro.org, linux-kernel@vger.kernel.org, pierre-louis.bossart@linux.intel.com, bard.liao@intel.com Subject: [PATCH 4/4] soundwire: intel_init: resume all devices on exit. Date: Wed, 10 Apr 2024 02:34:38 +0000 Message-Id: <20240410023438.487017-5-yung-chuan.liao@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240410023438.487017-1-yung-chuan.liao@linux.intel.com> References: <20240410023438.487017-1-yung-chuan.liao@linux.intel.com> Precedence: bulk X-Mailing-List: linux-sound@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 When the manager becomes pm_runtime active in the remove procedure, peripherals will become attached, and do the initialization process. We have to wait until all the devices are fully resumed before the cleanup, otherwise there is a possible race condition where asynchronous workqueues initiate transfers on the bus that cannot complete. This will ensure there are no SoundWire registers accessed after the bus is powered-down. Signed-off-by: Bard Liao --- drivers/soundwire/intel_init.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/drivers/soundwire/intel_init.c b/drivers/soundwire/intel_init.c index 534c8795e7e8..a09134b97cd6 100644 --- a/drivers/soundwire/intel_init.c +++ b/drivers/soundwire/intel_init.c @@ -16,6 +16,7 @@ #include #include #include "cadence_master.h" +#include "bus.h" #include "intel.h" #include "intel_auxdevice.h" @@ -356,6 +357,19 @@ EXPORT_SYMBOL_NS(sdw_intel_startup, SOUNDWIRE_INTEL_INIT); */ void sdw_intel_exit(struct sdw_intel_ctx *ctx) { + struct sdw_intel_link_res *link; + + /* we first resume links and devices and wait synchronously before the cleanup */ + list_for_each_entry(link, &ctx->link_list, list) { + struct sdw_bus *bus = &link->cdns->bus; + int ret; + + ret = device_for_each_child(bus->dev, NULL, intel_resume_child_device); + if (ret < 0) + dev_err(bus->dev, "%s: intel_resume_child_device failed: %d\n", + __func__, ret); + } + sdw_intel_cleanup(ctx); kfree(ctx->ids); kfree(ctx->ldev);