From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2096AC31E57 for ; Mon, 17 Jun 2019 11:36:34 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id ECC262084A for ; Mon, 17 Jun 2019 11:36:33 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org ECC262084A Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.ibm.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:46242 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hcpw9-0001tN-9R for qemu-devel@archiver.kernel.org; Mon, 17 Jun 2019 07:36:33 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53744) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hcpsu-0008KN-Ke for qemu-devel@nongnu.org; Mon, 17 Jun 2019 07:33:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hcpst-00043f-EQ for qemu-devel@nongnu.org; Mon, 17 Jun 2019 07:33:12 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:38416 helo=mx0a-001b2d01.pphosted.com) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hcpsq-0003sf-9H; Mon, 17 Jun 2019 07:33:08 -0400 Received: from pps.filterd (m0098417.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x5HBWFrC048164; Mon, 17 Jun 2019 07:33:02 -0400 Received: from ppma04dal.us.ibm.com (7a.29.35a9.ip4.static.sl-reverse.com [169.53.41.122]) by mx0a-001b2d01.pphosted.com with ESMTP id 2t68yju00u-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 17 Jun 2019 07:33:02 -0400 Received: from pps.filterd (ppma04dal.us.ibm.com [127.0.0.1]) by ppma04dal.us.ibm.com (8.16.0.27/8.16.0.27) with SMTP id x5HBWTqq032337; Mon, 17 Jun 2019 11:33:01 GMT Received: from b03cxnp08025.gho.boulder.ibm.com (b03cxnp08025.gho.boulder.ibm.com [9.17.130.17]) by ppma04dal.us.ibm.com with ESMTP id 2t4ra62bwg-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 17 Jun 2019 11:33:01 +0000 Received: from b03ledav003.gho.boulder.ibm.com (b03ledav003.gho.boulder.ibm.com [9.17.130.234]) by b03cxnp08025.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id x5HBX0mh30343598 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 17 Jun 2019 11:33:00 GMT Received: from b03ledav003.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 827AC6A054; Mon, 17 Jun 2019 11:33:00 +0000 (GMT) Received: from b03ledav003.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id E6BEF6A047; Mon, 17 Jun 2019 11:32:59 +0000 (GMT) Received: from [9.85.182.89] (unknown [9.85.182.89]) by b03ledav003.gho.boulder.ibm.com (Postfix) with ESMTP; Mon, 17 Jun 2019 11:32:59 +0000 (GMT) To: Cornelia Huck , Farhan Ali References: <20190617101036.4087-1-cohuck@redhat.com> From: Eric Farman Message-ID: <79b6da2e-0f93-0f55-c8e2-94ff57bbd909@linux.ibm.com> Date: Mon, 17 Jun 2019 07:32:59 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1 MIME-Version: 1.0 In-Reply-To: <20190617101036.4087-1-cohuck@redhat.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-TM-AS-GCONF: 00 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2019-06-17_06:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=2 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1906170108 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] X-Received-From: 148.163.158.5 Subject: Re: [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, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" On 6/17/19 6:10 AM, Cornelia Huck wrote: > Use the new helper. > > Signed-off-by: Cornelia Huck Nice simplification! Reviewed-by: Eric Farman > --- > v1->v2: > - Don't go overboard with deleting, and keep the get_irq_info part. (Sorry about that. :) > --- > 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 = &vcdev->vdev; > struct vfio_irq_info *irq_info; > - struct vfio_irq_set *irq_set; > size_t argsz; > - int32_t *pfd; > + int fd; > > 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(VFIOCCWDevice *vcdev, Error **errp) > goto out_free_info; > } > > - argsz = sizeof(*irq_set) + sizeof(*pfd); > - irq_set = g_malloc0(argsz); > - irq_set->argsz = argsz; > - irq_set->flags = VFIO_IRQ_SET_DATA_EVENTFD | > - VFIO_IRQ_SET_ACTION_TRIGGER; > - irq_set->index = VFIO_CCW_IO_IRQ_INDEX; > - irq_set->start = 0; > - irq_set->count = 1; > - pfd = (int32_t *) &irq_set->data; > - > - *pfd = 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 = 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); > } > > static void vfio_ccw_unregister_io_notifier(VFIOCCWDevice *vcdev) > { > - struct vfio_irq_set *irq_set; > - size_t argsz; > - int32_t *pfd; > - > - argsz = sizeof(*irq_set) + sizeof(*pfd); > - irq_set = g_malloc0(argsz); > - irq_set->argsz = argsz; > - irq_set->flags = VFIO_IRQ_SET_DATA_EVENTFD | > - VFIO_IRQ_SET_ACTION_TRIGGER; > - irq_set->index = VFIO_CCW_IO_IRQ_INDEX; > - irq_set->start = 0; > - irq_set->count = 1; > - pfd = (int32_t *) &irq_set->data; > - *pfd = -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 = 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); > } > > qemu_set_fd_handler(event_notifier_get_fd(&vcdev->io_notifier), > NULL, NULL, vcdev); > event_notifier_cleanup(&vcdev->io_notifier); > - > - g_free(irq_set); > } > > static void vfio_ccw_get_region(VFIOCCWDevice *vcdev, Error **errp) >