Received: by 2002:ab2:687:0:b0:1f4:6588:b3a7 with SMTP id s7csp171822lqe; Tue, 9 Apr 2024 20:00:07 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUvbfL02Up27zMrFXzPGtGWMXdmotmYCgMWLZ8osjD7y7Oc0ZDlmgLxC649cowjQvFs9n3ti8129rO2xMiKqFmEUc5xmnev3pY2rGQh+g== X-Google-Smtp-Source: AGHT+IEdXv1WAfp+tAw9Lt+2R2rsBc0UGRsFUysd27togvhiWMurmiTlnSlr9aOmQgSxq66Yb0MV X-Received: by 2002:a05:6a20:dca8:b0:1a7:502:23e8 with SMTP id ky40-20020a056a20dca800b001a7050223e8mr1648842pzb.35.1712718007323; Tue, 09 Apr 2024 20:00:07 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712718007; cv=pass; d=google.com; s=arc-20160816; b=qfXg2nilV84E6cgwG0WVayAEH7p5ZvoVLhbjpKzf9MMll9pkejleJFg9P70AXa2xe/ nZjhfMC/YXB/W3A1xUXmpeu4oAND+VXGbIuP46AIKs0irvuBeS0KNQoyMslRBXiQFcgs L8/1d0kXr/nJQCYxxhJyEkz9jmY/lWPcVL2uN9C89WV9GqXk9ZB2T3nnA53AQE/rxESv M/LMtbeEx37/PY3RufvWh808rsrxZGENd/JlJAnw6ZEOisj/YtFpx20rSVCa9S92U5ez N0KbyDolGIDqTAnb518lZv958YhG2MSnpevWqatECLAgXDl3wcNnBEv5vwrLOW2itkSv gsPw== 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=CkydZV6n6UWi1nKCeU/MYgYEjqn0DMPGDhmbt5LTDWk=; fh=adk3EaFw7eFV07wvCPF33gGd3eJUi4dewVzMXztrQfc=; b=Tyl4XByPwqbe/wkKeLfH76I2m357GInSopbeTMRrxnNIrEZPu6yYVKGlH+k8qrNiFd InBBAA+yUgoTFBBxbjIV7Xjn8ydcYebzrixG9Zb6LrE+jaHMxFI0tLEQwF5MdftFXl02 cBRzde8s8I14ms57bsWRQ8zIdX/8A1c1J4NTk7IGfud/ihepVC078YMdAyLwlKbY4stE MPWZ8Z/Lx9tb3KsUe7aZ0Klhk6gbUfx6spisiA7e+Q+EuFV8talzCMG85/GyjU9KS0km nB8guKoElY4mc2AIMAeWFjQ7VLRCxs90FaELSGzwZrzF81fpCsv2ANF0sH9t1DyGdK12 Zb/Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="IKtPTZq/"; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-137850-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-137850-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id o7-20020a170902d4c700b001e3e6ebfae3si7071979plg.260.2024.04.09.20.00.06 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Apr 2024 20:00:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-137850-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=@intel.com header.s=Intel header.b="IKtPTZq/"; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-137850-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-137850-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.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 C8AD4288EF5 for ; Wed, 10 Apr 2024 02:35:29 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A2521134DE; Wed, 10 Apr 2024 02:34:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="IKtPTZq/" 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 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-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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); -- 2.34.1