From nobody Fri May 3 19:04:06 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=1560505800; cv=none; d=zoho.com; s=zohoarc; b=ZUUPHJ+24drl/fuQ2TwJZemaB/Q29Mb/j1XehqhJcCJuw77Irnr9TnOfU+k1I26m1I9J8agBPxkxkedKiVUlrJ/7/g+izCzsW3Bx4Sf1UifD3Xcsrg8kKrLQ1tmz4H7FogwCnhU6VAEsvKHHpy9Bna7kUzsMUvqcUMD0fIh0eKE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1560505800; 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=4by/lJ89jUNg47B4bezwAtyyHOUdN2RwiET478NMh3M=; b=LMykVnZXSgXpB6PuuOIAWRwa6T0YC+Q5d2/JlGEVgFIYfnNXeQP/6VXGVzWKCC/3rIYKB1gL+pry/3m+Jx9B62JHWObnO+XkDmr7YK1HmoOvFtOA+eKp3QngzAg9gSJP7aBdwHU7baRbThRM1Gj1NuPZkWLNnwvUtCgww0v8Ah4= 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 1560505800647598.403843818276; Fri, 14 Jun 2019 02:50:00 -0700 (PDT) Received: from localhost ([::1]:49674 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbiqL-0006pd-Kq for importer@patchew.org; Fri, 14 Jun 2019 05:49:57 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40783) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbieo-0004oG-3C for qemu-devel@nongnu.org; Fri, 14 Jun 2019 05:38:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hbiUO-000759-UA for qemu-devel@nongnu.org; Fri, 14 Jun 2019 05:27:18 -0400 Received: from mx1.redhat.com ([209.132.183.28]:49598) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hbiUO-00073b-M8; Fri, 14 Jun 2019 05:27:16 -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 99D22C049E23; Fri, 14 Jun 2019 09:27:10 +0000 (UTC) Received: from localhost (dhcp-192-222.str.redhat.com [10.33.192.222]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 188A978370; Fri, 14 Jun 2019 09:27:07 +0000 (UTC) From: Cornelia Huck To: Eric Farman , Farhan Ali Date: Fri, 14 Jun 2019 11:27:05 +0200 Message-Id: <20190614092705.11025-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]); Fri, 14 Jun 2019 09:27:12 +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] 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 --- hw/vfio/ccw.c | 68 +++++++++++---------------------------------------- 1 file changed, 14 insertions(+), 54 deletions(-) diff --git a/hw/vfio/ccw.c b/hw/vfio/ccw.c index 03a2becb3ec9..3dc08721a3db 100644 --- a/hw/vfio/ccw.c +++ b/hw/vfio/ccw.c @@ -197,10 +197,7 @@ read_err: static void vfio_ccw_register_io_notifier(VFIOCCWDevice *vcdev, Error **er= rp) { 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", @@ -208,72 +205,35 @@ static void vfio_ccw_register_io_notifier(VFIOCCWDevi= ce *vcdev, Error **errp) return; } =20 - argsz =3D sizeof(*irq_info); - irq_info =3D g_malloc0(argsz); - irq_info->index =3D VFIO_CCW_IO_IRQ_INDEX; - irq_info->argsz =3D argsz; - if (ioctl(vdev->fd, VFIO_DEVICE_GET_IRQ_INFO, - irq_info) < 0 || irq_info->count < 1) { - error_setg_errno(errp, errno, "vfio: Error getting irq info"); - goto out_free_info; - } - if (event_notifier_init(&vcdev->io_notifier, 0)) { error_setg_errno(errp, errno, "vfio: Unable to init event notifier for IO"); - goto out_free_info; + return; } =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); } - - 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