From patchwork Mon Mar 9 22:43:12 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kurz X-Patchwork-Id: 1251854 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 48btYH39Mrz9sPJ for ; Tue, 10 Mar 2020 09:43:31 +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 48btYH27P7zDqRk for ; Tue, 10 Mar 2020 09:43:31 +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.158.5; 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 (mx0b-001b2d01.pphosted.com [148.163.158.5]) (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 48btY43qlczDqLG for ; Tue, 10 Mar 2020 09:43:20 +1100 (AEDT) Received: from pps.filterd (m0098420.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 029MURpn020489 for ; Mon, 9 Mar 2020 18:43:18 -0400 Received: from e06smtp03.uk.ibm.com (e06smtp03.uk.ibm.com [195.75.94.99]) by mx0b-001b2d01.pphosted.com with ESMTP id 2ynww8hk9g-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Mon, 09 Mar 2020 18:43:18 -0400 Received: from localhost by e06smtp03.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 9 Mar 2020 22:43:16 -0000 Received: from b06cxnps3074.portsmouth.uk.ibm.com (9.149.109.194) by e06smtp03.uk.ibm.com (192.168.101.133) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Mon, 9 Mar 2020 22:43:13 -0000 Received: from d06av26.portsmouth.uk.ibm.com (d06av26.portsmouth.uk.ibm.com [9.149.105.62]) by b06cxnps3074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 029MhCjN37290188 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 9 Mar 2020 22:43:12 GMT Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id A375CAE077; Mon, 9 Mar 2020 22:43:12 +0000 (GMT) Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 83488AE076; Mon, 9 Mar 2020 22:43:12 +0000 (GMT) Received: from bahia.lan (unknown [9.145.41.106]) by d06av26.portsmouth.uk.ibm.com (Postfix) with ESMTP; Mon, 9 Mar 2020 22:43:12 +0000 (GMT) From: Greg Kurz To: slof@lists.ozlabs.org Date: Mon, 09 Mar 2020 23:43:12 +0100 In-Reply-To: <158379377926.1643521.5206856271270861535.stgit@bahia.lan> References: <158379377926.1643521.5206856271270861535.stgit@bahia.lan> User-Agent: StGit/unknown-version MIME-Version: 1.0 X-TM-AS-GCONF: 00 x-cbid: 20030922-0012-0000-0000-0000038EC434 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 20030922-0013-0000-0000-000021CB8D81 Message-Id: <158379379177.1643521.631344932643277192.stgit@bahia.lan> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.138, 18.0.572 definitions=2020-03-09_11:2020-03-09, 2020-03-09 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 lowpriorityscore=0 malwarescore=0 spamscore=0 priorityscore=1501 suspectscore=1 bulkscore=0 impostorscore=0 adultscore=0 mlxscore=0 clxscore=1034 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2001150001 definitions=main-2003090136 Subject: [SLOF] [PATCH 2/3] virtio-serial: Rework shutdown sequence 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: , Errors-To: slof-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "SLOF" The "io" word of term-io.fs opens two separate instances of the device for stdin and stdout. The prom_init() function in Linux closes stdin at some point, which internally calls quiesce and shuts the device down through a quiesce hook. When the "open-count" variable in virtio-serial.fs reaches 0, ie. when closing the last instance, we call "close" two times, which is clearly wrong. This never hits however because the stdout instance is never closed which prevents "open-count" to reach 0. It would make more sense to shutdown the device when closing the last instance, for symmetry with the first open that initializes the device. Change the shutdown sequence to do that rather than relying on a quiesce hook. Have quiesce to explicitly close stdout, which is supposedly the last instance, and shutdown the device. Signed-off-by: Greg Kurz --- board-qemu/slof/virtio-serial.fs | 12 +++--------- slof/fs/client.fs | 5 +++++ 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/board-qemu/slof/virtio-serial.fs b/board-qemu/slof/virtio-serial.fs index a99293f6ef77..e307231ed0dc 100644 --- a/board-qemu/slof/virtio-serial.fs +++ b/board-qemu/slof/virtio-serial.fs @@ -19,13 +19,8 @@ virtio-setup-vd VALUE virtiodev \ Quiescence the virtqueue of this device so that no more background \ transactions can be pending. : shutdown ( -- ) - initialized? IF - my-phandle node>path open-dev ?dup IF - virtiodev virtio-serial-shutdown - close-dev - THEN - FALSE to initialized? - THEN + virtiodev virtio-serial-shutdown + FALSE to initialized? ; : virtio-serial-term-emit @@ -39,7 +34,6 @@ virtio-setup-vd VALUE virtiodev : init ( -- ) virtiodev virtio-serial-init drop TRUE to initialized? - ['] shutdown add-quiesce-xt ; 0 VALUE open-count @@ -58,7 +52,7 @@ virtiodev virtio-serial-init drop : close open-count 0> IF open-count 1 - dup to open-count - 0= IF close THEN + 0= IF shutdown THEN THEN close ; diff --git a/slof/fs/client.fs b/slof/fs/client.fs index db7a1925792c..76231f9aef75 100644 --- a/slof/fs/client.fs +++ b/slof/fs/client.fs @@ -203,6 +203,11 @@ 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