From nobody Tue Oct 28 01:48:50 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.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 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1516211849554826.3809871675566; Wed, 17 Jan 2018 09:57:29 -0800 (PST) Received: from localhost ([::1]:51676 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ebrxo-00063b-Sa for importer@patchew.org; Wed, 17 Jan 2018 12:57:28 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47323) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ebrj4-0000lq-Bf for qemu-devel@nongnu.org; Wed, 17 Jan 2018 12:42:15 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ebrj3-0000K0-EB for qemu-devel@nongnu.org; Wed, 17 Jan 2018 12:42:14 -0500 Received: from mx1.redhat.com ([209.132.183.28]:60414) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ebrj3-0000J1-62; Wed, 17 Jan 2018 12:42:13 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 4F78D2D1EFB; Wed, 17 Jan 2018 17:42:07 +0000 (UTC) Received: from t460s.redhat.com (ovpn-117-185.ams2.redhat.com [10.36.117.185]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5FCAA61F2A; Wed, 17 Jan 2018 17:42:05 +0000 (UTC) From: David Hildenbrand To: qemu-s390x@nongnu.org, qemu-devel@nongnu.org Date: Wed, 17 Jan 2018 18:40:46 +0100 Message-Id: <20180117174047.6382-18-david@redhat.com> In-Reply-To: <20180117174047.6382-1-david@redhat.com> References: <20180117174047.6382-1-david@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Wed, 17 Jan 2018 17:42:12 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v2 17/18] s390x/kvm: cache the kvm flic in a central function 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: Thomas Huth , David Hildenbrand , Cornelia Huck , Alexander Graf , Christian Borntraeger , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" This avoids tons of conversions when handling interrupts. Signed-off-by: David Hildenbrand Acked-by: Christian Borntraeger --- hw/intc/s390_flic_kvm.c | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/hw/intc/s390_flic_kvm.c b/hw/intc/s390_flic_kvm.c index d277ffdd2e..3f804ad52e 100644 --- a/hw/intc/s390_flic_kvm.c +++ b/hw/intc/s390_flic_kvm.c @@ -35,6 +35,17 @@ typedef struct KVMS390FLICState { bool clear_io_supported; } KVMS390FLICState; =20 +static KVMS390FLICState *s390_get_kvm_flic(S390FLICState *fs) +{ + static KVMS390FLICState *flic; + + if (!flic) { + /* we only have one flic device, so this is fine to cache */ + flic =3D KVM_S390_FLIC(fs); + } + return flic; +} + /** * flic_get_all_irqs - store all pending irqs in buffer * @buf: pointer to buffer which is passed to kernel @@ -117,7 +128,7 @@ static void kvm_s390_inject_flic(S390FLICState *fs, str= uct kvm_s390_irq *irq) int r; =20 if (use_flic) { - r =3D flic_enqueue_irqs(irq, sizeof(*irq), KVM_S390_FLIC(fs)); + r =3D flic_enqueue_irqs(irq, sizeof(*irq), s390_get_kvm_flic(fs)); if (r =3D=3D -ENOSYS) { use_flic =3D false; } @@ -174,7 +185,7 @@ static void kvm_s390_inject_crw_mchk(S390FLICState *fs) static int kvm_s390_clear_io_flic(S390FLICState *fs, uint16_t subchannel_i= d, uint16_t subchannel_nr) { - KVMS390FLICState *flic =3D KVM_S390_FLIC(fs); + KVMS390FLICState *flic =3D s390_get_kvm_flic(fs); int rc; uint32_t sid =3D subchannel_id << 16 | subchannel_nr; struct kvm_device_attr attr =3D { @@ -192,7 +203,7 @@ static int kvm_s390_clear_io_flic(S390FLICState *fs, ui= nt16_t subchannel_id, static int kvm_s390_modify_ais_mode(S390FLICState *fs, uint8_t isc, uint16_t mode) { - KVMS390FLICState *flic =3D KVM_S390_FLIC(fs); + KVMS390FLICState *flic =3D s390_get_kvm_flic(fs); struct kvm_s390_ais_req req =3D { .isc =3D isc, .mode =3D mode, @@ -212,7 +223,7 @@ static int kvm_s390_modify_ais_mode(S390FLICState *fs, = uint8_t isc, static int kvm_s390_inject_airq(S390FLICState *fs, uint8_t type, uint8_t isc, uint8_t flags) { - KVMS390FLICState *flic =3D KVM_S390_FLIC(fs); + KVMS390FLICState *flic =3D s390_get_kvm_flic(fs); uint32_t id =3D css_get_adapter_id(type, isc); struct kvm_device_attr attr =3D { .group =3D KVM_DEV_FLIC_AIRQ_INJECT, @@ -301,7 +312,7 @@ static int kvm_s390_io_adapter_map(S390FLICState *fs, u= int32_t id, .group =3D KVM_DEV_FLIC_ADAPTER_MODIFY, .addr =3D (uint64_t)&req, }; - KVMS390FLICState *flic =3D KVM_S390_FLIC(fs); + KVMS390FLICState *flic =3D s390_get_kvm_flic(fs); int r; =20 if (!kvm_gsi_routing_enabled()) { --=20 2.14.3