From nobody Sat Apr 27 13:46:38 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.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 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1560766314; cv=none; d=zoho.com; s=zohoarc; b=RMbvJajvZuh4YmvYDKX0qB1PcGhhgN9+OwfktjacJez5XG0mT64tenqz8Rm71PaCnNn9MZuY9D0lzAZFY8ZnRZDAN1FusZfGYenQlXxYVgwOJtnKhb89xZ27NRr4OF3HtZp1VQE527DQAdDV20hJ6CRp+XUyqVosfa7A3fKQuLI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1560766314; h=Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To:ARC-Authentication-Results; bh=JdepKVjAKjSfZo7p14X/3K/wMtXwl/gN3K0M/iuMiyg=; b=JR5HRo+WSg1FK+OjAnTToZmKIDakS+584p1l6ZFncXbCAgd/y0tgRsG4zfWuot+c3HgQvkWlnMr/uhRzX0LDISiE02+oeDA3bRTkvWTmY2HXrZOIb+W4iWALU7wJbmqltiOvpsDltScpKfgHea6CILazX67qBehougbefrnqOq8= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 15607663148341012.535933734926; Mon, 17 Jun 2019 03:11:54 -0700 (PDT) Received: from localhost ([::1]:45756 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hcocB-000230-1q for importer@patchew.org; Mon, 17 Jun 2019 06:11:51 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36088) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hcob7-000194-1w for qemu-devel@nongnu.org; Mon, 17 Jun 2019 06:10:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hcob5-0005FG-VN for qemu-devel@nongnu.org; Mon, 17 Jun 2019 06:10:45 -0400 Received: from mx1.redhat.com ([209.132.183.28]:49798) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hcob5-0005ER-Me; Mon, 17 Jun 2019 06:10:43 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 87D2AC05091A; Mon, 17 Jun 2019 10:10:42 +0000 (UTC) Received: from localhost (dhcp-192-192.str.redhat.com [10.33.192.192]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 0E7AF66069; Mon, 17 Jun 2019 10:10:39 +0000 (UTC) From: Cornelia Huck To: Eric Farman , Farhan Ali Date: Mon, 17 Jun 2019 12:10:36 +0200 Message-Id: <20190617101036.4087-1-cohuck@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Mon, 17 Jun 2019 10:10:42 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v2] vfio-ccw: use vfio_set_irq_signaling X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Eric Auger , qemu-s390x@nongnu.org, Cornelia Huck , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" Use the new helper. Signed-off-by: Cornelia Huck Reviewed-by: Eric Auger Reviewed-by: Eric Farman --- v1->v2: - Don't go overboard with deleting, and keep the get_irq_info part. --- hw/vfio/ccw.c | 51 +++++++++++++-------------------------------------- 1 file changed, 13 insertions(+), 38 deletions(-) diff --git a/hw/vfio/ccw.c b/hw/vfio/ccw.c index 03a2becb3ec9..a18bbd33b055 100644 --- a/hw/vfio/ccw.c +++ b/hw/vfio/ccw.c @@ -198,9 +198,8 @@ static void vfio_ccw_register_io_notifier(VFIOCCWDevice= *vcdev, Error **errp) { VFIODevice *vdev =3D &vcdev->vdev; struct vfio_irq_info *irq_info; - struct vfio_irq_set *irq_set; size_t argsz; - int32_t *pfd; + int fd; =20 if (vdev->num_irqs < VFIO_CCW_IO_IRQ_INDEX + 1) { error_setg(errp, "vfio: unexpected number of io irqs %u", @@ -224,56 +223,32 @@ static void vfio_ccw_register_io_notifier(VFIOCCWDevi= ce *vcdev, Error **errp) goto out_free_info; } =20 - argsz =3D sizeof(*irq_set) + sizeof(*pfd); - irq_set =3D g_malloc0(argsz); - irq_set->argsz =3D argsz; - irq_set->flags =3D VFIO_IRQ_SET_DATA_EVENTFD | - VFIO_IRQ_SET_ACTION_TRIGGER; - irq_set->index =3D VFIO_CCW_IO_IRQ_INDEX; - irq_set->start =3D 0; - irq_set->count =3D 1; - pfd =3D (int32_t *) &irq_set->data; - - *pfd =3D event_notifier_get_fd(&vcdev->io_notifier); - qemu_set_fd_handler(*pfd, vfio_ccw_io_notifier_handler, NULL, vcdev); - if (ioctl(vdev->fd, VFIO_DEVICE_SET_IRQS, irq_set)) { - error_setg(errp, "vfio: Failed to set up io notification"); - qemu_set_fd_handler(*pfd, NULL, NULL, vcdev); + fd =3D event_notifier_get_fd(&vcdev->io_notifier); + qemu_set_fd_handler(fd, vfio_ccw_io_notifier_handler, NULL, vcdev); + + if (vfio_set_irq_signaling(vdev, VFIO_CCW_IO_IRQ_INDEX, 0, + VFIO_IRQ_SET_ACTION_TRIGGER, fd, errp)) { + qemu_set_fd_handler(fd, NULL, NULL, vcdev); event_notifier_cleanup(&vcdev->io_notifier); } =20 - g_free(irq_set); - out_free_info: g_free(irq_info); } =20 static void vfio_ccw_unregister_io_notifier(VFIOCCWDevice *vcdev) { - struct vfio_irq_set *irq_set; - size_t argsz; - int32_t *pfd; - - argsz =3D sizeof(*irq_set) + sizeof(*pfd); - irq_set =3D g_malloc0(argsz); - irq_set->argsz =3D argsz; - irq_set->flags =3D VFIO_IRQ_SET_DATA_EVENTFD | - VFIO_IRQ_SET_ACTION_TRIGGER; - irq_set->index =3D VFIO_CCW_IO_IRQ_INDEX; - irq_set->start =3D 0; - irq_set->count =3D 1; - pfd =3D (int32_t *) &irq_set->data; - *pfd =3D -1; - - if (ioctl(vcdev->vdev.fd, VFIO_DEVICE_SET_IRQS, irq_set)) { - error_report("vfio: Failed to de-assign device io fd: %m"); + Error *err =3D NULL; + + vfio_set_irq_signaling(&vcdev->vdev, VFIO_CCW_IO_IRQ_INDEX, 0, + VFIO_IRQ_SET_ACTION_TRIGGER, -1, &err); + if (err) { + error_reportf_err(err, VFIO_MSG_PREFIX, vcdev->vdev.name); } =20 qemu_set_fd_handler(event_notifier_get_fd(&vcdev->io_notifier), NULL, NULL, vcdev); event_notifier_cleanup(&vcdev->io_notifier); - - g_free(irq_set); } =20 static void vfio_ccw_get_region(VFIOCCWDevice *vcdev, Error **errp) --=20 2.20.1