From patchwork Thu Mar 26 10:32:43 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kurz X-Patchwork-Id: 1261929 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 48p1cc3VpNz9sRN for ; Thu, 26 Mar 2020 21:36:32 +1100 (AEDT) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=kaod.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 48p1cc377qzDqXL for ; Thu, 26 Mar 2020 21:36:32 +1100 (AEDT) X-Original-To: slof@lists.ozlabs.org Delivered-To: slof@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=softfail (domain owner discourages use of this host) smtp.mailfrom=kaod.org (client-ip=148.163.156.1; helo=mx0a-001b2d01.pphosted.com; envelope-from=groug@kaod.org; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=kaod.org Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 48p1cZ13nXzDqX1 for ; Thu, 26 Mar 2020 21:36:28 +1100 (AEDT) Received: from pps.filterd (m0187473.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 02QAaMSE193606 for ; Thu, 26 Mar 2020 06:36:25 -0400 Received: from e06smtp05.uk.ibm.com (e06smtp05.uk.ibm.com [195.75.94.101]) by mx0a-001b2d01.pphosted.com with ESMTP id 2ywejymf4d-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Thu, 26 Mar 2020 06:36:22 -0400 Received: from localhost by e06smtp05.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 26 Mar 2020 10:32:42 -0000 Received: from b06avi18626390.portsmouth.uk.ibm.com (9.149.26.192) by e06smtp05.uk.ibm.com (192.168.101.135) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Thu, 26 Mar 2020 10:32:39 -0000 Received: from d06av23.portsmouth.uk.ibm.com (d06av23.portsmouth.uk.ibm.com [9.149.105.59]) by b06avi18626390.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 02QAVfNS43581914 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 26 Mar 2020 10:31:41 GMT Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 0E65AA4053; Thu, 26 Mar 2020 10:32:44 +0000 (GMT) Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id D2F6DA4055; Thu, 26 Mar 2020 10:32:43 +0000 (GMT) Received: from bahia.lan (unknown [9.145.41.106]) by d06av23.portsmouth.uk.ibm.com (Postfix) with ESMTP; Thu, 26 Mar 2020 10:32:43 +0000 (GMT) From: Greg Kurz To: Alexey Kardashevskiy Date: Thu, 26 Mar 2020 11:32:43 +0100 User-Agent: StGit/unknown-version MIME-Version: 1.0 X-TM-AS-GCONF: 00 x-cbid: 20032610-0020-0000-0000-000003BBB7D1 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 20032610-0021-0000-0000-0000221441E1 Message-Id: <158521876305.519948.15878142591918776304.stgit@bahia.lan> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.138, 18.0.645 definitions=2020-03-26_02:2020-03-26, 2020-03-26 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 clxscore=1034 suspectscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 bulkscore=0 phishscore=0 lowpriorityscore=0 priorityscore=1501 impostorscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2003260080 Subject: [SLOF] [PATCH] slof: Only close stdout for virtio-serial devices X-BeenThere: slof@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Patches for https://github.com/aik/SLOF" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: slof@lists.ozlabs.org Errors-To: slof-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "SLOF" Recent commit cf28264196e5 fixed an issue where a virtio-serial device wouldn't shutdown properly during quiesce. The fix is to close stdout just before quiesce. As expected this causes some messages to not appear anymore, like the well known ones from prom_init(): Quiescing Open Firmware ... Booting Linux via __start() @ 0x0000000002000000 ... Actually all messages are discarded until the OS driver finally takes control of the device, which may represent a fair amount of logging. This is suboptimal but this still better than hanging in SLOF. The hammer is a bit too big though because the change also affects spapr-vty based consoles, which have no reason to stop working after quiesce. Move the hack from the common code to the virtio-serial code so that it doesn't affect other device types anymore. Register a quiesce hook that closes stdout in virtio-serial.fs. While here, as suggested by Segher, bring back some robustness in the shutdown method. Reported-by: Fabiano Rosas Fixes: cf28264196e5 "virtio-serial: Rework shutdown sequence" Signed-off-by: Greg Kurz --- David, Loosing so much output with spapr-vty is an annoying regression IMHO. I really thing we should have this fixed in QEMU 5.0. --- board-qemu/slof/virtio-serial.fs | 14 +++++++++++--- slof/fs/client.fs | 5 ----- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/board-qemu/slof/virtio-serial.fs b/board-qemu/slof/virtio-serial.fs index ac55ffcc8ebb..06bfe762b105 100644 --- a/board-qemu/slof/virtio-serial.fs +++ b/board-qemu/slof/virtio-serial.fs @@ -19,9 +19,11 @@ virtio-setup-vd VALUE virtiodev \ Quiescence the virtqueue of this device so that no more background \ transactions can be pending. : shutdown ( -- ) - virtiodev virtio-serial-shutdown - FALSE to initialized? - 0 to virtiodev + initialized? IF + virtiodev virtio-serial-shutdown + FALSE to initialized? + 0 to virtiodev + THEN ; : virtio-serial-term-emit @@ -31,10 +33,16 @@ virtio-setup-vd VALUE virtiodev : virtio-serial-term-key? virtiodev virtio-serial-haschar ; : virtio-serial-term-key BEGIN virtio-serial-term-key? UNTIL virtiodev virtio-serial-getchar ; +: virtio-serial-close-stdout s" stdout" get-chosen IF decode-int nip nip close-dev THEN ; + \ Basic device initialization - which has only to be done once : init ( -- ) virtiodev virtio-serial-init drop TRUE to initialized? + \ Linux closes stdin at some point in prom_init(). This internally triggers a + \ quiesce in SLOF. We must ensure stdout gets closed as well otherwise the + \ device cannot be reset properly and the boot will hang. + ['] virtio-serial-close-stdout add-quiesce-xt ; 0 VALUE open-count diff --git a/slof/fs/client.fs b/slof/fs/client.fs index 76231f9aef75..db7a1925792c 100644 --- a/slof/fs/client.fs +++ b/slof/fs/client.fs @@ -203,11 +203,6 @@ ALSO client-voc DEFINITIONS \ End of life of SLOF now, call platform quiesce as quiesce \ is an undocumented extension and not everybody supports it close-dev - \ Some device, eg. virtio-serial, need all instances to be - \ closed in order to be reset properly - s" stdout" get-chosen IF - decode-int nip nip close-dev - THEN quiesce ELSE close-dev