From patchwork Mon Jan 21 10:45:47 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Huth X-Patchwork-Id: 10773533 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C55A413B4 for ; Mon, 21 Jan 2019 10:46:09 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B52CA29E32 for ; Mon, 21 Jan 2019 10:46:09 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A904E29E35; Mon, 21 Jan 2019 10:46:09 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4BE2329E32 for ; Mon, 21 Jan 2019 10:46:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727680AbfAUKqI (ORCPT ); Mon, 21 Jan 2019 05:46:08 -0500 Received: from mx1.redhat.com ([209.132.183.28]:33542 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727302AbfAUKqH (ORCPT ); Mon, 21 Jan 2019 05:46:07 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id CA3581F8C5; Mon, 21 Jan 2019 10:46:07 +0000 (UTC) Received: from thuth.com (ovpn-116-152.ams2.redhat.com [10.36.116.152]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7A76A5D961; Mon, 21 Jan 2019 10:46:06 +0000 (UTC) From: Thomas Huth To: kvm@vger.kernel.org, Paolo Bonzini , =?utf-8?b?UmFk?= =?utf-8?b?aW0gS3LEjW3DocWZ?= Cc: David Hildenbrand , Janosch Frank Subject: [kvm-unit-tests PULL 02/10] s390x: try !FORCE SCLP read SCP info if FORCED is unknown Date: Mon, 21 Jan 2019 11:45:47 +0100 Message-Id: <1548067555-15766-3-git-send-email-thuth@redhat.com> In-Reply-To: <1548067555-15766-1-git-send-email-thuth@redhat.com> References: <1548067555-15766-1-git-send-email-thuth@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Mon, 21 Jan 2019 10:46:07 +0000 (UTC) Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: David Hildenbrand 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 Reviewed-by: Janosch Frank Signed-off-by: David Hildenbrand Signed-off-by: Thomas Huth --- lib/s390x/sclp.c | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) 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;