[kvm-unit-tests PATCH v1 4/5] s390x: firq: avoid hardcoded CPU addresses

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Use the recently introduced smp_cpu_addr_from_idx to discover the
addresses of the CPUs to use in the test, instead of using hardcoded
values. This makes the test more portable.

Signed-off-by: Claudio Imbrenda <imbrenda@xxxxxxxxxxxxx>
---
 s390x/firq.c | 17 ++++++++---------
 1 file changed, 8 insertions(+), 9 deletions(-)

diff --git a/s390x/firq.c b/s390x/firq.c
index fb9a2906..14d0d102 100644
--- a/s390x/firq.c
+++ b/s390x/firq.c
@@ -33,6 +33,7 @@ static void wait_for_sclp_int(void)
  */
 static void test_wait_state_delivery(void)
 {
+	uint16_t cpu1, cpu2;
 	struct psw psw;
 	SCCBHeader *h;
 	int ret;
@@ -44,16 +45,14 @@ static void test_wait_state_delivery(void)
 		goto out;
 	}
 
-	if (stap()) {
-		report_skip("need to start on CPU #0");
-		goto out;
-	}
+	cpu1 = smp_cpu_addr_from_idx(1);
+	cpu2 = smp_cpu_addr_from_idx(2);
 
 	/*
 	 * We want CPU #2 to be stopped. This should be the case at this
 	 * point, however, we want to sense if it even exists as well.
 	 */
-	ret = smp_cpu_stop(2);
+	ret = smp_cpu_stop(cpu2);
 	if (ret) {
 		report_skip("CPU #2 not found");
 		goto out;
@@ -68,10 +67,10 @@ static void test_wait_state_delivery(void)
 	/* Start CPU #1 and let it wait for the interrupt. */
 	psw.mask = extract_psw_mask();
 	psw.addr = (unsigned long)wait_for_sclp_int;
-	ret = smp_cpu_setup(1, psw);
+	ret = smp_cpu_setup(cpu1, psw);
 	if (ret) {
 		sclp_clear_busy();
-		report_skip("cpu #1 not found");
+		report_skip("CPU #1 not found");
 		goto out;
 	}
 
@@ -85,7 +84,7 @@ static void test_wait_state_delivery(void)
 	 * will take some time as well and smp_cpu_setup() returns when we're
 	 * either already in wait_for_sclp_int() or just about to execute it.
 	 */
-	while(smp_sense_running_status(1));
+	while(smp_sense_running_status(cpu1));
 
 	h = alloc_pages_flags(0, AREA_DMA31);
 	h->length = 4096;
@@ -106,7 +105,7 @@ static void test_wait_state_delivery(void)
 
 out_destroy:
 	free_page(h);
-	smp_cpu_destroy(1);
+	smp_cpu_destroy(cpu1);
 out:
 	report_prefix_pop();
 }
-- 
2.34.1




[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux