From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=210.61.82.184 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796459651; b=AwxyBs9g/IrePOTES0dQa+cBr9DQNpD26Gn14E37PLwzREzom2LDZCjTj20Vmp1yTjZI iZ0rbTFc3w23BNPp/kt1c4kpHB86zlu0SwKP5j8s8FVJyVnV+g5i1PQ/mrYLNhaSlbfup iNRxkMAk+Luhzh5/1zESuGNfT45EkSAhZNXcPCxH+r8lflTaenUx/A8p4Tta618VDtLNZ dgh4/ys1dEux3/Y/bkIGF9EJEqmfcyNiSnKfb5sHQicorJDax0lud1PKEzAP2PWKywSI/ eL2yBJjNUHSymny1/E0bXMfIHA2DtstUEJdcEh4P9oGompYZSO9kL6c4NN/IiQgCU8w== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796459651; h=DMARC-Filter:X-UUID:DKIM-Signature:X-CID-P-RULE:X-CID-O-INFO: X-CID-META:X-CID-BVR:X-CID-BAS:X-CID-FACTOR:X-CID-RHF:X-UUID:Received: Received:Received:From:To:CC:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:MIME-Version:Content-Transfer-Encoding: Content-Type:X-MTK; bh=FnG+JQAz/GNo6VMsAhqZB2xtCe5hmgXPsula1ftDGxs=; b=hpuXDewRIOu077F0wXSkUCNqmoFr+Zzqmbo6iLlwu++MGdUWGz0MeupnmSJe8HdzG44o 0cSIJ9NyyV5aXlcEav5KFmwG8Fl4hBcs8okUDmgHvQext6rlRglQSaLa4LpYVVDDHyXod H5zy7xWSjR5ZiUJ1fKaNcQnlX0+GNMyi5yEqUyOJbIQNpX6PL04/HR54I3CZysSnlfYQ5 5kdRRDDaECH8qqBFh0RcQWYK08pUAA/HU9z9cNa6FTr0jPzkz2Gi6ywMvCfRKOaJX2GfA G5AHaW7Y/AvfSmBDXq+UJJd+6TK4/j/B5X4BObVZaQQnKxEXD2eruD6xosoqpAK0vGg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=mediatek.com; spf=pass smtp.mailfrom=mediatek.com; dkim=pass header.d=mediatek.com header.i=@mediatek.com header.a=rsa-sha256 header.s=dk header.b=YujtxrJR; arc=none smtp.remote-ip=210.61.82.184 Received: from mailgw02.mediatek.com (unknown [210.61.82.184]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E10A0606A334; Sat, 5 Dec 2026 08:34:09 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org E10A0606A334 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=mediatek.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=mediatek.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=mediatek.com header.i=@mediatek.com header.a=rsa-sha256 header.s=dk header.b=YujtxrJR X-UUID: a0078b62f08611f1a7aecdb2598be72c-20261205 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Type:Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:CC:To:From; bh=FnG+JQAz/GNo6VMsAhqZB2xtCe5hmgXPsula1ftDGxs=; b=YujtxrJRDrnb7wUii25CvPTKZjn/47yoUp4Z+wUhHlGgonw+UH8AFrwUCyx68P3inKT6w4+pqJVezmdc9+e7Nnz8eQdch0IOAThELF/0988+xU8FPr7FdCwFKO7kYOCp6mcfbwt12DJaUK2E+glvn3M63HRtHc2uCdPWzBcWBa4=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.3.22,REQID:339cf46d-f925-4b04-86f0-112d0adb2855,IP:0,U RL:0,TC:0,Content:0,EDM:0,RT:0,SF:0,FILE:0,BULK:0,RULE:Release_Ham,ACTION: release,TS:0 X-CID-META: VersionHash:d36851b,CLOUDID:ec017e1a-ae4c-4a2b-b1c4-72e411efd0c9,B ulkID:nil,BulkQuantity:0,SF:81|82|102|836|865|888|898,TC:-5,Content:0|15|5 0|99,EDM:-3,IP:nil,URL:0,File:130,RT:0,Bulk:nil,QS:nil,BEC:nil,COL:0,OSI:0 ,OSA:0,AV:0,LES:1,SPR:NO,DKR:0,DKP:0,BRR:0,BRE:0,ARC:0 X-CID-BVR: 2,SSN|SDN X-CID-BAS: 2,SSN|SDN,0,_ X-CID-FACTOR: TF_CID_SPAM_SNR X-CID-RHF: D41D8CD98F00B204E9800998ECF8427E X-UUID: a0078b62f08611f1a7aecdb2598be72c-20261205 Received: from mtkmbs14n1.mediatek.inc [(172.21.101.75)] by mailgw02.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 12137716; Sat, 05 Dec 2026 16:34:02 +0800 Received: from mtkmbs13n1.mediatek.inc (172.21.101.193) by mtkmbs10n1.mediatek.inc (172.21.101.34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.56; Sat, 5 Dec 2026 16:34:01 +0800 Received: from gcnsap21.gcn.mediatek.inc (10.17.81.22) by mtkmbs13n1.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.2.2562.56 via Frontend Transport; Sat, 5 Dec 2026 16:34:00 +0800 From: Chunfeng Yun To: Mika Westerberg CC: Andreas Noever , Konrad Dybcio , Sven Peter , Yehezkel Bernat , Matthias Brugger , Greg Kroah-Hartman , AngeloGioacchino Del Regno , , , , , Chunfeng Yun Subject: [PATCH v4 05/14] thunderbolt: Move rpm_complete bus walk to domain.c Date: Sat, 5 Dec 2026 16:33:30 +0800 Message-ID: <20261205083342.4009278-6-chunfeng.yun@mediatek.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20261205083342.4009278-1-chunfeng.yun@mediatek.com> References: <20261205083342.4009278-1-chunfeng.yun@mediatek.com> X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-MTK: N Currently, remove_unplugged_switch() in icm.c traverses all devices on the bus using bus_for_each_dev(&tb_bus_type, ...) to signal rpm_complete before calling tb_switch_remove(). This creates a direct dependency on the internal struct bus_type tb_bus_type in icm.c. When icm.c is modularized, this would require exporting tb_bus_type to other modules, leaking subsystem core internals. Encapsulate this bus traversal inside domain.c as tb_domain_complete_rpm(). This keeps tb_bus_type private to domain.c and eliminates the need to export the bus structure. Signed-off-by: Chunfeng Yun --- new patch --- drivers/thunderbolt/domain.c | 24 ++++++++++++++++++++++++ drivers/thunderbolt/icm.c | 17 +---------------- drivers/thunderbolt/tb.h | 1 + 3 files changed, 26 insertions(+), 16 deletions(-) diff --git a/drivers/thunderbolt/domain.c b/drivers/thunderbolt/domain.c index 24611f05b3cd..075e0f8af1e8 100644 --- a/drivers/thunderbolt/domain.c +++ b/drivers/thunderbolt/domain.c @@ -881,6 +881,30 @@ int tb_domain_unregister_unplugged_xdomains(struct tb *tb) return ctx.n; } +static int complete_rpm(struct device *dev, void *data) +{ + struct tb_switch *sw = tb_to_switch(dev); + + if (sw && sw->tb == data) + complete(&sw->rpm_complete); + + return 0; +} + +/** + * tb_domain_complete_rpm() - Signal runtime resume completion for router and below + * @tb: Domain the router belongs to + * @sw: Router to complete runtime resume + * + * Signal @sw and routers below for rpm_complete because + * tb_switch_remove() calls pm_runtime_get_sync() that then waits for it. + */ +void tb_domain_complete_rpm(struct tb *tb, struct tb_switch *sw) +{ + complete_rpm(&sw->dev, tb); + bus_for_each_dev(&tb_bus_type, &sw->dev, tb, complete_rpm); +} + int tb_domain_init(void) { int ret; diff --git a/drivers/thunderbolt/icm.c b/drivers/thunderbolt/icm.c index a295a5e6cc9c..f2c387d226f0 100644 --- a/drivers/thunderbolt/icm.c +++ b/drivers/thunderbolt/icm.c @@ -2068,28 +2068,13 @@ static void icm_unplug_children(struct tb_switch *sw) } } -static int complete_rpm(struct device *dev, void *data) -{ - struct tb_switch *sw = tb_to_switch(dev); - - if (sw && sw->tb == data) - complete(&sw->rpm_complete); - return 0; -} - static void remove_unplugged_switch(struct tb_switch *sw) { struct device *parent = get_device(sw->dev.parent); pm_runtime_get_sync(parent); - /* - * Signal this and switches below for rpm_complete because - * tb_switch_remove() calls pm_runtime_get_sync() that then waits - * for it. - */ - complete_rpm(&sw->dev, sw->tb); - bus_for_each_dev(&tb_bus_type, &sw->dev, sw->tb, complete_rpm); + tb_domain_complete_rpm(sw->tb, sw); tb_switch_remove(sw); pm_runtime_mark_last_busy(parent); diff --git a/drivers/thunderbolt/tb.h b/drivers/thunderbolt/tb.h index 9158b8f3580f..d6c188922ca1 100644 --- a/drivers/thunderbolt/tb.h +++ b/drivers/thunderbolt/tb.h @@ -797,6 +797,7 @@ int tb_domain_disconnect_xdomain_paths(struct tb *tb, struct tb_xdomain *xd, int receive_path, int receive_ring); int tb_domain_disconnect_all_paths(struct tb *tb); int tb_domain_unregister_unplugged_xdomains(struct tb *tb); +void tb_domain_complete_rpm(struct tb *tb, struct tb_switch *sw); static inline struct tb *tb_domain_get(struct tb *tb) { -- 2.45.2