diff mbox series

[kvm-unit-tests,PULL,02/10] s390x: try !FORCE SCLP read SCP info if FORCED is unknown

Message ID 1548067555-15766-3-git-send-email-thuth@redhat.com (mailing list archive)
State New, archived
Headers show
Series [kvm-unit-tests,PULL,01/10] s390x: cleanup and add SCLP defines | expand

Commit Message

Thomas Huth Jan. 21, 2019, 10:45 a.m. UTC
From: David Hildenbrand <david@redhat.com>

Looking at what the kernel does, looks like we should
- Check for more errors
- Try to execute !FORCED read if the FORCED one is unknown

The kernel sets the function code to 0x80 (SCLP_FC_DUMP_INDICATOR). We
don't need that. Also, the control_mask[2] is set to 0x80
(SCLP_CM2_VARIABLE_LENGTH_RESPONSE), something we also don't need as
4k SCCB should be sufficient for the amount of CPUs we expect to be
called with. If this ever changes, we can extend it.

Tested-by: Janosch Frank <frankja@linux.ibm.com>
Reviewed-by: Janosch Frank <frankja@linux.ibm.com>
Signed-off-by: David Hildenbrand <david@redhat.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
---
 lib/s390x/sclp.c | 23 +++++++++++++++++++++--
 1 file changed, 21 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/lib/s390x/sclp.c b/lib/s390x/sclp.c
index 1d4a010..cccfdc2 100644
--- a/lib/s390x/sclp.c
+++ b/lib/s390x/sclp.c
@@ -30,14 +30,33 @@  static void mem_init(phys_addr_t mem_end)
 	phys_alloc_init(freemem_start, mem_end - freemem_start);
 }
 
+static void sclp_read_scp_info(ReadInfo *ri, int length)
+{
+	unsigned int commands[] = { SCLP_CMDW_READ_SCP_INFO_FORCED,
+				    SCLP_CMDW_READ_SCP_INFO };
+	int i;
+
+	for (i = 0; i < ARRAY_SIZE(commands); i++) {
+		memset(&ri->h, 0, sizeof(ri->h));
+		ri->h.length = length;
+
+		if (sclp_service_call(commands[i], ri))
+			break;
+		if (ri->h.response_code == SCLP_RC_NORMAL_READ_COMPLETION)
+			return;
+		if (ri->h.response_code != SCLP_RC_INVALID_SCLP_COMMAND)
+			break;
+	}
+	report_abort("READ_SCP_INFO failed");
+}
+
 void sclp_memory_setup(void)
 {
 	ReadInfo *ri = (void *)_sccb;
 	uint64_t rnmax, rnsize;
 	int cc;
 
-	ri->h.length = SCCB_SIZE;
-	sclp_service_call(SCLP_CMDW_READ_SCP_INFO_FORCED, ri);
+	sclp_read_scp_info(ri, SCCB_SIZE);
 
 	/* calculate the storage increment size */
 	rnsize = ri->rnsize;