All of lore.kernel.org
 help / color / mirror / Atom feed
From: David Matlack <dmatlack@google.com>
To: kexec@lists.infradead.org, linux-kernel@vger.kernel.org,
	 linux-kselftest@vger.kernel.org, linux-pci@vger.kernel.org,
	 linux-riscv@lists.infradead.org
Cc: Albert Ou <aou@eecs.berkeley.edu>,
	Alexandre Ghiti <alex@ghiti.fr>,
	 Alex Williamson <alex@shazbot.org>,
	Bjorn Helgaas <bhelgaas@google.com>,
	 David Matlack <dmatlack@google.com>,
	Jacob Pan <jacob.pan@linux.microsoft.com>,
	 Jason Gunthorpe <jgg@nvidia.com>,
	Josh Hilke <jrhilke@google.com>, Lukas Wunner <lukas@wunner.de>,
	 Mike Rapoport <rppt@kernel.org>,
	Palmer Dabbelt <palmer@dabbelt.com>,
	Parav Pandit <parav@nvidia.com>,
	 Pasha Tatashin <pasha.tatashin@soleen.com>,
	Paul Walmsley <pjw@kernel.org>,
	 Pranjal Shrivastava <praan@google.com>,
	Pratyush Yadav <pratyush@kernel.org>,
	 Samiullah Khawaja <skhawaja@google.com>,
	Shuah Khan <shuah@kernel.org>,  Vipin Sharma <vipinsh@google.com>
Subject: [PATCH 14/18] selftests/liveupdate: pci: Add a test with an endpoint below a switch
Date: Wed,  2 Dec 2026 00:39:51 +0000	[thread overview]
Message-ID: <20261202003955.3607156-15-dmatlack@google.com> (raw)
In-Reply-To: <20261202003955.3607156-1-dmatlack@google.com>

Add a PCI Live Update test that preserves an endpoint below a PCIe
switch, next to a control endpoint below another downstream port of the
same switch. The root port and the switch's upstream port are shared
between the preserved and the control endpoint, and so must be
preserved.

Add pci_switch to build switches, and pci_topology_switch for this
topology, which later tests reuse.

Signed-off-by: David Matlack <dmatlack@google.com>
---
 .../liveupdate/pci/pci_vmtest_lib.sh          | 29 +++++++++++++++++++
 .../selftests/liveupdate/pci/switch.vmtest.sh |  8 +++++
 2 files changed, 37 insertions(+)
 create mode 100644 tools/testing/selftests/liveupdate/pci/switch.vmtest.sh

diff --git a/tools/testing/selftests/liveupdate/pci/pci_vmtest_lib.sh b/tools/testing/selftests/liveupdate/pci/pci_vmtest_lib.sh
index 5babeb19fbc1..3038cc4ca53f 100644
--- a/tools/testing/selftests/liveupdate/pci/pci_vmtest_lib.sh
+++ b/tools/testing/selftests/liveupdate/pci/pci_vmtest_lib.sh
@@ -47,6 +47,22 @@ function pci_root_port() {
 	TEST_QEMU_ARGS+=(-device "pcie-root-port,id=$1,bus=pcie.0,addr=$2,chassis=$PCI_CHASSIS")
 }
 
+# pci_switch <id> <bus> <downstream_id>...
+#   Add a switch below <bus>, with one downstream port per <downstream_id>. The
+#   downstream ports are devices 0, 1, ... on the switch's internal bus.
+function pci_switch() {
+	local id=$1 bus=$2 i=0 dsp
+	shift 2
+
+	TEST_QEMU_ARGS+=(-device "x3130-upstream,id=$id,bus=$bus,addr=0")
+	for dsp in "$@"; do
+		PCI_CHASSIS=$((PCI_CHASSIS + 1))
+		TEST_QEMU_ARGS+=(-device
+			"xio3130-downstream,id=$dsp,bus=$id,addr=$i,chassis=$PCI_CHASSIS,slot=0")
+		i=$((i + 1))
+	done
+}
+
 # pci_igb <id> <bus> [<addr>]
 #   Add an IGB endpoint at device <addr> (default 0) on <bus>.
 function pci_igb() {
@@ -80,6 +96,19 @@ function pci_topology_root_ports() {
 	pci_control 0000:00:03.0/00.0
 }
 
+# pci_topology_switch
+#   A switch below a root port, with an endpoint to preserve and a control
+#   endpoint below different downstream ports.
+function pci_topology_switch() {
+	pci_root_port rp1 0x2
+	pci_switch sw1 rp1 dsp1 dsp2
+	pci_igb igb1 dsp1
+	pci_igb igb2 dsp2
+
+	pci_preserve 0000:00:02.0/00.0/00.0/00.0
+	pci_control 0000:00:02.0/00.0/01.0/00.0
+}
+
 function test_check() {
 	python3 "$test_dir/pci/check_cfg_trace.py" \
 		--serial "$workspace_dir/qemu.serial" --trace "$PCI_TRACE"
diff --git a/tools/testing/selftests/liveupdate/pci/switch.vmtest.sh b/tools/testing/selftests/liveupdate/pci/switch.vmtest.sh
new file mode 100644
index 000000000000..5b851ddf0b2b
--- /dev/null
+++ b/tools/testing/selftests/liveupdate/pci/switch.vmtest.sh
@@ -0,0 +1,8 @@
+# SPDX-License-Identifier: GPL-2.0
+#
+# Preserve an endpoint below a switch, next to a control endpoint below another
+# downstream port of the same switch.
+
+source "$test_dir/pci/pci_vmtest_lib.sh"
+
+pci_topology_switch
-- 
2.56.1.911.g883d8bcb20-goog


WARNING: multiple messages have this Message-ID (diff)
From: David Matlack <dmatlack@google.com>
To: kexec@lists.infradead.org, linux-kernel@vger.kernel.org,
	 linux-kselftest@vger.kernel.org, linux-pci@vger.kernel.org,
	 linux-riscv@lists.infradead.org
Cc: Albert Ou <aou@eecs.berkeley.edu>,
	Alexandre Ghiti <alex@ghiti.fr>,
	 Alex Williamson <alex@shazbot.org>,
	Bjorn Helgaas <bhelgaas@google.com>,
	 David Matlack <dmatlack@google.com>,
	Jacob Pan <jacob.pan@linux.microsoft.com>,
	 Jason Gunthorpe <jgg@nvidia.com>,
	Josh Hilke <jrhilke@google.com>, Lukas Wunner <lukas@wunner.de>,
	 Mike Rapoport <rppt@kernel.org>,
	Palmer Dabbelt <palmer@dabbelt.com>,
	Parav Pandit <parav@nvidia.com>,
	 Pasha Tatashin <pasha.tatashin@soleen.com>,
	Paul Walmsley <pjw@kernel.org>,
	 Pranjal Shrivastava <praan@google.com>,
	Pratyush Yadav <pratyush@kernel.org>,
	 Samiullah Khawaja <skhawaja@google.com>,
	Shuah Khan <shuah@kernel.org>,  Vipin Sharma <vipinsh@google.com>
Subject: [PATCH 14/18] selftests/liveupdate: pci: Add a test with an endpoint below a switch
Date: Wed,  2 Dec 2026 00:39:51 +0000	[thread overview]
Message-ID: <20261202003955.3607156-15-dmatlack@google.com> (raw)
In-Reply-To: <20261202003955.3607156-1-dmatlack@google.com>

Add a PCI Live Update test that preserves an endpoint below a PCIe
switch, next to a control endpoint below another downstream port of the
same switch. The root port and the switch's upstream port are shared
between the preserved and the control endpoint, and so must be
preserved.

Add pci_switch to build switches, and pci_topology_switch for this
topology, which later tests reuse.

Signed-off-by: David Matlack <dmatlack@google.com>
---
 .../liveupdate/pci/pci_vmtest_lib.sh          | 29 +++++++++++++++++++
 .../selftests/liveupdate/pci/switch.vmtest.sh |  8 +++++
 2 files changed, 37 insertions(+)
 create mode 100644 tools/testing/selftests/liveupdate/pci/switch.vmtest.sh

diff --git a/tools/testing/selftests/liveupdate/pci/pci_vmtest_lib.sh b/tools/testing/selftests/liveupdate/pci/pci_vmtest_lib.sh
index 5babeb19fbc1..3038cc4ca53f 100644
--- a/tools/testing/selftests/liveupdate/pci/pci_vmtest_lib.sh
+++ b/tools/testing/selftests/liveupdate/pci/pci_vmtest_lib.sh
@@ -47,6 +47,22 @@ function pci_root_port() {
 	TEST_QEMU_ARGS+=(-device "pcie-root-port,id=$1,bus=pcie.0,addr=$2,chassis=$PCI_CHASSIS")
 }
 
+# pci_switch <id> <bus> <downstream_id>...
+#   Add a switch below <bus>, with one downstream port per <downstream_id>. The
+#   downstream ports are devices 0, 1, ... on the switch's internal bus.
+function pci_switch() {
+	local id=$1 bus=$2 i=0 dsp
+	shift 2
+
+	TEST_QEMU_ARGS+=(-device "x3130-upstream,id=$id,bus=$bus,addr=0")
+	for dsp in "$@"; do
+		PCI_CHASSIS=$((PCI_CHASSIS + 1))
+		TEST_QEMU_ARGS+=(-device
+			"xio3130-downstream,id=$dsp,bus=$id,addr=$i,chassis=$PCI_CHASSIS,slot=0")
+		i=$((i + 1))
+	done
+}
+
 # pci_igb <id> <bus> [<addr>]
 #   Add an IGB endpoint at device <addr> (default 0) on <bus>.
 function pci_igb() {
@@ -80,6 +96,19 @@ function pci_topology_root_ports() {
 	pci_control 0000:00:03.0/00.0
 }
 
+# pci_topology_switch
+#   A switch below a root port, with an endpoint to preserve and a control
+#   endpoint below different downstream ports.
+function pci_topology_switch() {
+	pci_root_port rp1 0x2
+	pci_switch sw1 rp1 dsp1 dsp2
+	pci_igb igb1 dsp1
+	pci_igb igb2 dsp2
+
+	pci_preserve 0000:00:02.0/00.0/00.0/00.0
+	pci_control 0000:00:02.0/00.0/01.0/00.0
+}
+
 function test_check() {
 	python3 "$test_dir/pci/check_cfg_trace.py" \
 		--serial "$workspace_dir/qemu.serial" --trace "$PCI_TRACE"
diff --git a/tools/testing/selftests/liveupdate/pci/switch.vmtest.sh b/tools/testing/selftests/liveupdate/pci/switch.vmtest.sh
new file mode 100644
index 000000000000..5b851ddf0b2b
--- /dev/null
+++ b/tools/testing/selftests/liveupdate/pci/switch.vmtest.sh
@@ -0,0 +1,8 @@
+# SPDX-License-Identifier: GPL-2.0
+#
+# Preserve an endpoint below a switch, next to a control endpoint below another
+# downstream port of the same switch.
+
+source "$test_dir/pci/pci_vmtest_lib.sh"
+
+pci_topology_switch
-- 
2.56.1.911.g883d8bcb20-goog


_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

  parent reply	other threads:[~2026-12-02  0:40 UTC|newest]

Thread overview: 43+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-02  0:39 [PATCH 00/18] selftests/liveupdate: Add PCI Live Update selftests David Matlack
2026-12-02  0:39 ` David Matlack
2026-12-02  0:39 ` [PATCH 01/18] liveupdate: Export symbols needed by modules David Matlack
2026-12-02  0:39   ` David Matlack
2026-12-02  0:45   ` sashiko-bot
2026-12-02  7:18   ` Christoph Hellwig
2026-12-02  7:18     ` Christoph Hellwig
2026-12-02  0:39 ` [PATCH 02/18] selftests/liveupdate: Exit with KSFT_SKIP when vmtest.sh skips a test David Matlack
2026-12-02  0:39   ` David Matlack
2026-12-02  0:44   ` sashiko-bot
2026-12-02  0:39 ` [PATCH 03/18] selftests/liveupdate: Build objects in $(OUTPUT) David Matlack
2026-12-02  0:39   ` David Matlack
2026-12-02  0:39 ` [PATCH 04/18] selftests/liveupdate: Support building the kexec tests against nolibc David Matlack
2026-12-02  0:39   ` David Matlack
2026-12-02  0:39 ` [PATCH 05/18] selftests/liveupdate: Build vmtest.sh's binaries with the Makefile David Matlack
2026-12-02  0:39   ` David Matlack
2026-12-02  0:39 ` [PATCH 06/18] selftests/liveupdate: Support test definitions in vmtest.sh David Matlack
2026-12-02  0:39   ` David Matlack
2026-12-02  0:39 ` [PATCH 07/18] selftests/liveupdate: Support kernel modules " David Matlack
2026-12-02  0:39   ` David Matlack
2026-12-02  0:39 ` [PATCH 08/18] selftests/liveupdate: Support a different command line for each kernel David Matlack
2026-12-02  0:39   ` David Matlack
2026-12-02  0:39 ` [PATCH 09/18] selftests/liveupdate: Run tests in subdirectories from run-vmtests.sh David Matlack
2026-12-02  0:39   ` David Matlack
2026-12-02  0:39 ` [PATCH 10/18] selftests/liveupdate: Add a test driver for PCI Live Update David Matlack
2026-12-02  0:39   ` David Matlack
2026-12-02  0:39 ` [PATCH 11/18] selftests/liveupdate: pci: Add a test with an endpoint below a root port David Matlack
2026-12-02  0:39   ` David Matlack
2026-12-02  0:39 ` [PATCH 12/18] selftests/liveupdate: pci: Check PCI config writes with QEMU tracing David Matlack
2026-12-02  0:39   ` David Matlack
2026-12-02  0:39 ` [PATCH 13/18] selftests/liveupdate: pci: Add a test with an endpoint on the root bus David Matlack
2026-12-02  0:39   ` David Matlack
2026-12-02  0:39 ` David Matlack [this message]
2026-12-02  0:39   ` [PATCH 14/18] selftests/liveupdate: pci: Add a test with an endpoint below a switch David Matlack
2026-12-02  0:39 ` [PATCH 15/18] selftests/liveupdate: pci: Test bus numbers with pci=assign-busses David Matlack
2026-12-02  0:39   ` David Matlack
2026-12-02  0:39 ` [PATCH 16/18] selftests/liveupdate: pci: Test bus numbers with pci=hpbussize David Matlack
2026-12-02  0:39   ` David Matlack
2026-12-02  0:39 ` [PATCH 17/18] selftests/liveupdate: pci: Test ARI Forwarding with pci=noari David Matlack
2026-12-02  0:39   ` David Matlack
2026-12-02  0:39 ` [PATCH 18/18] selftests/liveupdate: pci: Test ACS with pci=config_acs David Matlack
2026-12-02  0:39   ` David Matlack
2026-12-02  0:50 ` [PATCH 00/18] selftests/liveupdate: Add PCI Live Update selftests sashiko-bot

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261202003955.3607156-15-dmatlack@google.com \
    --to=dmatlack@google.com \
    --cc=alex@ghiti.fr \
    --cc=alex@shazbot.org \
    --cc=aou@eecs.berkeley.edu \
    --cc=bhelgaas@google.com \
    --cc=jacob.pan@linux.microsoft.com \
    --cc=jgg@nvidia.com \
    --cc=jrhilke@google.com \
    --cc=kexec@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=linux-riscv@lists.infradead.org \
    --cc=lukas@wunner.de \
    --cc=palmer@dabbelt.com \
    --cc=parav@nvidia.com \
    --cc=pasha.tatashin@soleen.com \
    --cc=pjw@kernel.org \
    --cc=praan@google.com \
    --cc=pratyush@kernel.org \
    --cc=rppt@kernel.org \
    --cc=shuah@kernel.org \
    --cc=skhawaja@google.com \
    --cc=vipinsh@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.