From nobody Tue Nov 4 21:38:27 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linux.ibm.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1530814706150342.9195709780364; Thu, 5 Jul 2018 11:18:26 -0700 (PDT) Received: from localhost ([::1]:54248 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fb8pj-0002to-B4 for importer@patchew.org; Thu, 05 Jul 2018 14:18:23 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48860) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fb81F-0000Jb-2N for qemu-devel@nongnu.org; Thu, 05 Jul 2018 13:26:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fb81C-0001pB-0A for qemu-devel@nongnu.org; Thu, 05 Jul 2018 13:26:13 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:44786) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fb81B-0001mY-Lt for qemu-devel@nongnu.org; Thu, 05 Jul 2018 13:26:09 -0400 Received: from pps.filterd (m0098410.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w65HNx5M082180 for ; Thu, 5 Jul 2018 13:26:08 -0400 Received: from e16.ny.us.ibm.com (e16.ny.us.ibm.com [129.33.205.206]) by mx0a-001b2d01.pphosted.com with ESMTP id 2k1p3243wf-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Thu, 05 Jul 2018 13:26:08 -0400 Received: from localhost by e16.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 5 Jul 2018 13:26:07 -0400 Received: from b01cxnp22033.gho.pok.ibm.com (9.57.198.23) by e16.ny.us.ibm.com (146.89.104.203) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Thu, 5 Jul 2018 13:26:03 -0400 Received: from b01ledav005.gho.pok.ibm.com (b01ledav005.gho.pok.ibm.com [9.57.199.110]) by b01cxnp22033.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w65HQ2YC9175322 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 5 Jul 2018 17:26:02 GMT Received: from b01ledav005.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 4C429AE063; Thu, 5 Jul 2018 13:25:42 -0400 (EDT) Received: from b01ledav005.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 209ADAE062; Thu, 5 Jul 2018 13:25:42 -0400 (EDT) Received: from jason-laptop.endicott.ibm.com (unknown [9.60.75.201]) by b01ledav005.gho.pok.ibm.com (Postfix) with ESMTP; Thu, 5 Jul 2018 13:25:42 -0400 (EDT) From: "Jason J. Herne" To: qemu-devel@nongnu.org, qemu-s390x@nongnu.org, cohuck@redhat.com, pasic@linux.ibm.com, bjsdjshi@linux.ibm.com, borntraeger@de.ibm.com Date: Thu, 5 Jul 2018 13:25:43 -0400 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1530811543-6881-1-git-send-email-jjherne@linux.ibm.com> References: <1530811543-6881-1-git-send-email-jjherne@linux.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 18070517-0072-0000-0000-0000037A8A8C X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00009314; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000266; SDB=6.01056994; UDB=6.00542264; IPR=6.00834914; MB=3.00022012; MTD=3.00000008; XFM=3.00000015; UTC=2018-07-05 17:26:05 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18070517-0073-0000-0000-0000489A78BA Message-Id: <1530811543-6881-16-git-send-email-jjherne@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2018-07-05_06:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=915 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1806210000 definitions=main-1807050196 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.156.1 X-Mailman-Approved-At: Thu, 05 Jul 2018 14:03:14 -0400 Subject: [Qemu-devel] [RFC 15/15] s390-bios: Use sense ccw to ensure consistent device state at boot time X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" If a vfio-ccw device is left in an error state (example: pending unit check) then it is possible for that state to persist for a vfio-ccw device = even after the enable subchannel that we do to bring the device online. If this = state is allowed to persist then even simple I/O operations will needlessly fail.= A basic sense ccw is used to clear this error state for the boot device. Signed-off-by: Jason J. Herne --- pc-bios/s390-ccw/cio.c | 13 +++++++++++++ pc-bios/s390-ccw/cio.h | 13 +++++++++++++ pc-bios/s390-ccw/main.c | 5 +++++ 3 files changed, 31 insertions(+) diff --git a/pc-bios/s390-ccw/cio.c b/pc-bios/s390-ccw/cio.c index f440380..e77ec94 100644 --- a/pc-bios/s390-ccw/cio.c +++ b/pc-bios/s390-ccw/cio.c @@ -57,6 +57,19 @@ __u16 cu_type(SubChannelId schid) return senseData.cu_type; } =20 +void basic_sense(SubChannelId schid, SenseData *sd) +{ + Ccw1 senseCcw; + + senseCcw.cmd_code =3D CCW_CMD_BASIC_SENSE; + senseCcw.cda =3D ptr2u32(sd); + senseCcw.count =3D sizeof(*sd); + + if (do_cio(schid, ptr2u32(&senseCcw), CCW_FMT1)) { + panic("Failed to run Basic Sense CCW\n"); + } +} + static bool irb_error(Irb *irb) { /* We have to ignore Incorrect Length (cstat =3D=3D 0x40) indicators b= ecause diff --git a/pc-bios/s390-ccw/cio.h b/pc-bios/s390-ccw/cio.h index b5c9fd7..003524e 100644 --- a/pc-bios/s390-ccw/cio.h +++ b/pc-bios/s390-ccw/cio.h @@ -234,6 +234,18 @@ typedef struct senseid { struct ciw ciw[62]; } __attribute__ ((packed, aligned(4))) SenseId; =20 +/* basic sense response buffer layout */ +typedef struct senseData { + uint8_t status[3]; + uint8_t res_count; + uint8_t phys_drive_id; + uint8_t low_cyl_addr; + uint8_t head_high_cyl_addr; + uint8_t fmt_msg; + uint8_t reserved[16]; + uint8_t reserved2[8]; +} __attribute__ ((packed, aligned(4))) SenseData; + /* interruption response block */ typedef struct irb { struct scsw scsw; @@ -260,6 +272,7 @@ int enable_mss_facility(void); void enable_subchannel(SubChannelId schid); __u16 cu_type(SubChannelId schid); void await_io_int(uint16_t sch_no); +void basic_sense(SubChannelId schid, SenseData *sd); int do_cio(SubChannelId schid, uint32_t ccw_addr, int fmt); =20 /* diff --git a/pc-bios/s390-ccw/main.c b/pc-bios/s390-ccw/main.c index 2bccfa7..e0ce59b 100644 --- a/pc-bios/s390-ccw/main.c +++ b/pc-bios/s390-ccw/main.c @@ -201,12 +201,17 @@ static void virtio_setup(void) =20 int main(void) { + SenseData sd; + sclp_setup(); cio_setup(); boot_setup(); find_boot_device(); enable_subchannel(blk_schid); =20 + /* Clear any outstanding device error conditions */ + basic_sense(blk_schid, &sd); + switch (cu_type(blk_schid)) { case 0x3990: /* Real DASD device */ dasd_ipl(blk_schid); /* no return */ --=20 2.7.4