From patchwork Mon Jul 23 20:16:31 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 10540905 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 48050112B for ; Mon, 23 Jul 2018 20:30:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 37E76283EE for ; Mon, 23 Jul 2018 20:30:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2CA3F28492; Mon, 23 Jul 2018 20:30:37 +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.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id B3A5A283EE for ; Mon, 23 Jul 2018 20:30:36 +0000 (UTC) Received: from localhost ([::1]:36397 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhhTX-0004Cn-Rw for patchwork-qemu-devel@patchwork.kernel.org; Mon, 23 Jul 2018 16:30:35 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40958) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhhIY-0001fU-0P for qemu-devel@nongnu.org; Mon, 23 Jul 2018 16:19:15 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fhhIW-0002uc-S5 for qemu-devel@nongnu.org; Mon, 23 Jul 2018 16:19:13 -0400 Received: from mail-oi0-x22c.google.com ([2607:f8b0:4003:c06::22c]:44622) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fhhIW-0002sK-L4; Mon, 23 Jul 2018 16:19:12 -0400 Received: by mail-oi0-x22c.google.com with SMTP id s198-v6so3457170oih.11; Mon, 23 Jul 2018 13:19:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=5HEaxBnYUa+eZPrZp0pDfk4ZGK07fx16EkXrj/q8N18=; b=BMOoNEdEVce1Zyv/iupeRN1sq3F4U0HPuSovKh7DzW/ROJM7nyWrLdbV4h8sSZ5Scr smL+7iMfx1OQVIUHNiYXBVkAZ2B5ebQ+V6Rs3I0j9L9d0oyc33U5MUvXTBSCSoyF3PzU nPA14fav/bEz1fzPxBy1aXuXWwDZK4/yvVcE3HH7jD0PW3MthncGxdl/SL6OyU70ew1x SLnRoT7v0yz7VcK1b9HBOBenu372joax+NxcH5WSBOk16eVja0sCkKlPcmlIgnP17+t4 ri2qid/Qckncxxn43Eo53m1pmGsqnMI5mzx3OTpUbnCTfd/rX8Q3gMqKRxs92P7AMjdO Bbkg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=5HEaxBnYUa+eZPrZp0pDfk4ZGK07fx16EkXrj/q8N18=; b=GBQMm2xeU4B2grXaXkNkZc9WsCez/CvxjIDURv6Fbj54IFeWA5grKPPAdTkg66XIZu gF920VkMRumK9jRrij5iV8Jei/oXwLFtWsKQaj+tVSw0dQslx/dCbOYYvGjHrXsvRZGy 5V4thXbTwz738PD640/1D9vlsQu9l/zG+iSn+BEnt1wPM8ptVDmSC9L0Y+4X7mtmV2Iu zX23BFQHHfCuax05LPl0CUafKvpCmsyG1QpygbIKJZ0TfCp6mAI8dJrVKGI4RwDilI7e nw39NEy8bNTD8wc7UrID5PbwKpKP5dADze+ny5q1XZB/8djfACu4zg8q0VaJOP/8aJqb q5zw== X-Gm-Message-State: AOUpUlHJaJb8AKxcjYC6XEo1fXmNUIrPlujj1GLAZ8HlYiUe5CsEjFFe EGTQZL1uGh5du87jmyPJX16ez/Is9TA= X-Google-Smtp-Source: AAOMgpfRpHNGokPN+mZhjEkw05iSQ1xenUKtHuur4oPNMr9TR9V2tUs7rBW+JdgQy1SVZ9w48F+xJA== X-Received: by 2002:aca:cdc2:: with SMTP id d185-v6mr319085oig.350.1532377151483; Mon, 23 Jul 2018 13:19:11 -0700 (PDT) Received: from localhost (76-251-165-188.lightspeed.austtx.sbcglobal.net. [76.251.165.188]) by smtp.gmail.com with ESMTPSA id d191-v6sm11783282oig.16.2018.07.23.13.19.10 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 23 Jul 2018 13:19:10 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 23 Jul 2018 15:16:31 -0500 Message-Id: <20180723201748.25573-23-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180723201748.25573-1-mdroth@linux.vnet.ibm.com> References: <20180723201748.25573-1-mdroth@linux.vnet.ibm.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4003:c06::22c Subject: [Qemu-devel] [PATCH 22/99] s390x/ccw: make sure all ccw devices are properly reset 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: , Cc: Cornelia Huck , qemu-stable@nongnu.org Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Cornelia Huck Thomas reported that the subchannel for a 3270 device that ended up in a broken state (status pending even though not enabled) did not get out of that state even after a reboot (which involves a subsytem reset). The reason for this is that the 3270 device did not define a reset handler. Let's fix this by introducing a base reset handler (set up for all ccw devices) that resets the subchannel and have virtio-ccw call its virtio-specific reset procedure in addition to that. CC: qemu-stable@nongnu.org Reported-by: Thomas Huth Suggested-by: Christian Borntraeger Reviewed-by: Thomas Huth Tested-by: Thomas Huth Acked-by: Christian Borntraeger Reviewed-by: Halil Pasic Signed-off-by: Cornelia Huck (cherry picked from commit 838fb84f83c84f00d15b1bede5e080b495644458) Signed-off-by: Michael Roth --- hw/s390x/ccw-device.c | 8 ++++++++ hw/s390x/virtio-ccw.c | 9 ++++++--- hw/s390x/virtio-ccw.h | 1 + 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/hw/s390x/ccw-device.c b/hw/s390x/ccw-device.c index f9bfa154d6..7cd73df4aa 100644 --- a/hw/s390x/ccw-device.c +++ b/hw/s390x/ccw-device.c @@ -40,6 +40,13 @@ static Property ccw_device_properties[] = { DEFINE_PROP_END_OF_LIST(), }; +static void ccw_device_reset(DeviceState *d) +{ + CcwDevice *ccw_dev = CCW_DEVICE(d); + + css_reset_sch(ccw_dev->sch); +} + static void ccw_device_class_init(ObjectClass *klass, void *data) { DeviceClass *dc = DEVICE_CLASS(klass); @@ -48,6 +55,7 @@ static void ccw_device_class_init(ObjectClass *klass, void *data) k->realize = ccw_device_realize; k->refill_ids = ccw_device_refill_ids; dc->props = ccw_device_properties; + dc->reset = ccw_device_reset; } const VMStateDescription vmstate_ccw_dev = { diff --git a/hw/s390x/virtio-ccw.c b/hw/s390x/virtio-ccw.c index 40a33302a7..22df33b509 100644 --- a/hw/s390x/virtio-ccw.c +++ b/hw/s390x/virtio-ccw.c @@ -1058,10 +1058,12 @@ static void virtio_ccw_reset(DeviceState *d) { VirtioCcwDevice *dev = VIRTIO_CCW_DEVICE(d); VirtIODevice *vdev = virtio_bus_get_device(&dev->bus); - CcwDevice *ccw_dev = CCW_DEVICE(d); + VirtIOCCWDeviceClass *vdc = VIRTIO_CCW_DEVICE_GET_CLASS(dev); virtio_ccw_reset_virtio(dev, vdev); - css_reset_sch(ccw_dev->sch); + if (vdc->parent_reset) { + vdc->parent_reset(d); + } } static void virtio_ccw_vmstate_change(DeviceState *d, bool running) @@ -1715,12 +1717,13 @@ static void virtio_ccw_device_class_init(ObjectClass *klass, void *data) { DeviceClass *dc = DEVICE_CLASS(klass); CCWDeviceClass *k = CCW_DEVICE_CLASS(dc); + VirtIOCCWDeviceClass *vdc = VIRTIO_CCW_DEVICE_CLASS(klass); k->unplug = virtio_ccw_busdev_unplug; dc->realize = virtio_ccw_busdev_realize; dc->unrealize = virtio_ccw_busdev_unrealize; dc->bus_type = TYPE_VIRTUAL_CSS_BUS; - dc->reset = virtio_ccw_reset; + device_class_set_parent_reset(dc, virtio_ccw_reset, &vdc->parent_reset); } static const TypeInfo virtio_ccw_device_info = { diff --git a/hw/s390x/virtio-ccw.h b/hw/s390x/virtio-ccw.h index 2fc513001e..3453aa1f98 100644 --- a/hw/s390x/virtio-ccw.h +++ b/hw/s390x/virtio-ccw.h @@ -77,6 +77,7 @@ typedef struct VirtIOCCWDeviceClass { CCWDeviceClass parent_class; void (*realize)(VirtioCcwDevice *dev, Error **errp); void (*unrealize)(VirtioCcwDevice *dev, Error **errp); + void (*parent_reset)(DeviceState *dev); } VirtIOCCWDeviceClass; /* Performance improves when virtqueue kick processing is decoupled from the