From patchwork Wed Jun 8 11:02:40 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cornelia Huck X-Patchwork-Id: 9164279 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 9C6A760572 for ; Wed, 8 Jun 2016 11:03:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8D5542521F for ; Wed, 8 Jun 2016 11:03:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 823DC25D91; Wed, 8 Jun 2016 11:03:39 +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=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI 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 AD1A92521F for ; Wed, 8 Jun 2016 11:03:37 +0000 (UTC) Received: from localhost ([::1]:56021 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bAbGq-0004Vq-Q4 for patchwork-qemu-devel@patchwork.kernel.org; Wed, 08 Jun 2016 07:03:36 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55374) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bAbGK-0004T2-Fi for qemu-devel@nongnu.org; Wed, 08 Jun 2016 07:03:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bAbGD-0002Qv-Om for qemu-devel@nongnu.org; Wed, 08 Jun 2016 07:03:03 -0400 Received: from e33.co.us.ibm.com ([32.97.110.151]:36053) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bAbGD-0002Ql-GN for qemu-devel@nongnu.org; Wed, 08 Jun 2016 07:02:57 -0400 Received: from localhost by e33.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 8 Jun 2016 05:02:56 -0600 Received: from d03dlp03.boulder.ibm.com (9.17.202.179) by e33.co.us.ibm.com (192.168.1.133) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Wed, 8 Jun 2016 05:02:55 -0600 X-IBM-Helo: d03dlp03.boulder.ibm.com X-IBM-MailFrom: cornelia.huck@de.ibm.com X-IBM-RcptTo: qemu-devel@nongnu.org;agraf@suse.de Received: from b01cxnp23033.gho.pok.ibm.com (b01cxnp23033.gho.pok.ibm.com [9.57.198.28]) by d03dlp03.boulder.ibm.com (Postfix) with ESMTP id 9568119D8040; Wed, 8 Jun 2016 05:02:34 -0600 (MDT) Received: from b01ledav006.gho.pok.ibm.com (b01ledav006.gho.pok.ibm.com [9.57.199.111]) by b01cxnp23033.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id u58B2rYa39976962; Wed, 8 Jun 2016 11:02:53 GMT Received: from b01ledav006.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 4E850AC046; Wed, 8 Jun 2016 07:02:53 -0400 (EDT) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.152.85.9]) by b01ledav006.gho.pok.ibm.com (Postfix) with ESMTPS id 5EF07AC03C; Wed, 8 Jun 2016 07:02:52 -0400 (EDT) From: Cornelia Huck To: qemu-devel@nongnu.org Date: Wed, 8 Jun 2016 13:02:40 +0200 Message-Id: <1465383765-18754-3-git-send-email-cornelia.huck@de.ibm.com> X-Mailer: git-send-email 2.6.6 In-Reply-To: <1465383765-18754-1-git-send-email-cornelia.huck@de.ibm.com> References: <1465383765-18754-1-git-send-email-cornelia.huck@de.ibm.com> X-TM-AS-GCONF: 00 X-Content-Scanned: Fidelis XPS MAILER x-cbid: 16060811-0009-0000-0000-0000382BEFC1 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 32.97.110.151 Subject: [Qemu-devel] [PATCH 2/7] s390x/kvm: add interface for clearing IO irqs 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 , borntraeger@de.ibm.com, jfrei@linux.vnet.ibm.com, Halil Pasic , agraf@suse.de Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Halil Pasic According to the platform specification, under certain conditions, pending IO interruptions have to be cleared. Let's add an interface for that. Signed-off-by: Halil Pasic Reviewed-by: Cornelia Huck Signed-off-by: Cornelia Huck --- hw/intc/s390_flic.c | 8 ++++++++ hw/intc/s390_flic_kvm.c | 26 ++++++++++++++++++++++++++ include/hw/s390x/s390_flic.h | 2 ++ 3 files changed, 36 insertions(+) diff --git a/hw/intc/s390_flic.c b/hw/intc/s390_flic.c index bc75fa7..6ab29ef 100644 --- a/hw/intc/s390_flic.c +++ b/hw/intc/s390_flic.c @@ -67,6 +67,13 @@ static void qemu_s390_release_adapter_routes(S390FLICState *fs, { } +static int qemu_s390_clear_io_flic(S390FLICState *fs, uint16_t subchannel_id, + uint16_t subchannel_nr) +{ + /* Fixme TCG */ + return -ENOSYS; +} + static void qemu_s390_flic_class_init(ObjectClass *oc, void *data) { S390FLICStateClass *fsc = S390_FLIC_COMMON_CLASS(oc); @@ -75,6 +82,7 @@ static void qemu_s390_flic_class_init(ObjectClass *oc, void *data) fsc->io_adapter_map = qemu_s390_io_adapter_map; fsc->add_adapter_routes = qemu_s390_add_adapter_routes; fsc->release_adapter_routes = qemu_s390_release_adapter_routes; + fsc->clear_io_irq = qemu_s390_clear_io_flic; } static const TypeInfo qemu_s390_flic_info = { diff --git a/hw/intc/s390_flic_kvm.c b/hw/intc/s390_flic_kvm.c index eed6325..680857f 100644 --- a/hw/intc/s390_flic_kvm.c +++ b/hw/intc/s390_flic_kvm.c @@ -30,6 +30,7 @@ typedef struct KVMS390FLICState { S390FLICState parent_obj; uint32_t fd; + bool clear_io_supported; } KVMS390FLICState; DeviceState *s390_flic_kvm_create(void) @@ -130,6 +131,24 @@ int kvm_s390_inject_flic(struct kvm_s390_irq *irq) return flic_enqueue_irqs(irq, sizeof(*irq), flic); } +static int kvm_s390_clear_io_flic(S390FLICState *fs, uint16_t subchannel_id, + uint16_t subchannel_nr) +{ + KVMS390FLICState *flic = KVM_S390_FLIC(fs); + int rc; + uint32_t sid = subchannel_id << 16 | subchannel_nr; + struct kvm_device_attr attr = { + .group = KVM_DEV_FLIC_CLEAR_IO_IRQ, + .addr = (uint64_t) &sid, + .attr = sizeof(sid), + }; + if (unlikely(!flic->clear_io_supported)) { + return -ENOSYS; + } + rc = ioctl(flic->fd, KVM_SET_DEVICE_ATTR, &attr); + return rc ? -errno : 0; +} + /** * __get_all_irqs - store all pending irqs in buffer * @flic: pointer to flic device state @@ -358,6 +377,7 @@ static void kvm_s390_flic_realize(DeviceState *dev, Error **errp) { KVMS390FLICState *flic_state = KVM_S390_FLIC(dev); struct kvm_create_device cd = {0}; + struct kvm_device_attr test_attr = {0}; int ret; flic_state->fd = -1; @@ -374,6 +394,11 @@ static void kvm_s390_flic_realize(DeviceState *dev, Error **errp) } flic_state->fd = cd.fd; + /* Check clear_io_irq support */ + test_attr.group = KVM_DEV_FLIC_CLEAR_IO_IRQ; + flic_state->clear_io_supported = !ioctl(flic_state->fd, + KVM_HAS_DEVICE_ATTR, test_attr); + /* Register savevm handler for floating interrupts */ register_savevm(NULL, "s390-flic", 0, 1, kvm_flic_save, kvm_flic_load, (void *) flic_state); @@ -420,6 +445,7 @@ static void kvm_s390_flic_class_init(ObjectClass *oc, void *data) fsc->io_adapter_map = kvm_s390_io_adapter_map; fsc->add_adapter_routes = kvm_s390_add_adapter_routes; fsc->release_adapter_routes = kvm_s390_release_adapter_routes; + fsc->clear_io_irq = kvm_s390_clear_io_flic; } static const TypeInfo kvm_s390_flic_info = { diff --git a/include/hw/s390x/s390_flic.h b/include/hw/s390x/s390_flic.h index 200e7e9..1dac2ee 100644 --- a/include/hw/s390x/s390_flic.h +++ b/include/hw/s390x/s390_flic.h @@ -49,6 +49,8 @@ typedef struct S390FLICStateClass { bool do_map); int (*add_adapter_routes)(S390FLICState *fs, AdapterRoutes *routes); void (*release_adapter_routes)(S390FLICState *fs, AdapterRoutes *routes); + int (*clear_io_irq)(S390FLICState *fs, uint16_t subchannel_id, + uint16_t subchannel_nr); } S390FLICStateClass; #define TYPE_KVM_S390_FLIC "s390-flic-kvm"