From nobody Mon Feb 9 17:24:07 2026 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; dkim=fail; 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 1513791770541347.5917902985939; Wed, 20 Dec 2017 09:42:50 -0800 (PST) Received: from localhost ([::1]:60603 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eRiOE-0002AI-7f for importer@patchew.org; Wed, 20 Dec 2017 12:42:46 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56609) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eRhyb-0004tQ-Nc for qemu-devel@nongnu.org; Wed, 20 Dec 2017 12:16:18 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eRhya-0007MK-LI for qemu-devel@nongnu.org; Wed, 20 Dec 2017 12:16:17 -0500 Received: from mail-wr0-x242.google.com ([2a00:1450:400c:c0c::242]:33599) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eRhya-0007Lw-C2 for qemu-devel@nongnu.org; Wed, 20 Dec 2017 12:16:16 -0500 Received: by mail-wr0-x242.google.com with SMTP id v21so12207285wrc.0 for ; Wed, 20 Dec 2017 09:16:16 -0800 (PST) Received: from 640k.lan (dynamic-adsl-78-12-251-125.clienti.tiscali.it. [78.12.251.125]) by smtp.gmail.com with ESMTPSA id f125sm2751101wme.45.2017.12.20.09.16.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 20 Dec 2017 09:16:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=2ueVkr8ziMa0J22/4fyoMQZsBnGsZxhZ/mofjwRJ2Dw=; b=VF0TcRA4/zJ6J5T1FVKlPw0fHoW75lK0OI46H4U17StiJgMJW9KELd0nOhrgV9gwV/ BKyk3rKAFIFqqaW3AJQrSefs/J5GLQZunAeJ42gyMRhGLEwMar+q+cN/rk673bcxJnns DuOF8ZDqQJ3cyVUZJdnO4Dbs9ZrTtrSKz41UbnvY3Po7alveZBY7zaXK2e2VaCXEBHr7 ABv2NqtRCo+6w+3WPdlm06bIEd0khwcfsvIRJsQQ8z1BrXdxMqkZhl8pM35JAPnTErSe RM8twx/WJHnR77HLcCrZHDzuDlfHB6zkSrKCS6anAWOnxuHckMqeggXWEeQMPOB8vB8e F5qA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=2ueVkr8ziMa0J22/4fyoMQZsBnGsZxhZ/mofjwRJ2Dw=; b=Z0mjmW2DwOUklJV3+BpA7ZoJvXWmHFTGwg3Yc47L/MfbWUNtRMno2sBGKXkHGFsbX8 hnbEnPCOz+LX1HfHvtaAHKiumNM7w7zgEq1fZtghizsCTbKcP5yPIoG0M1T9GLges1g6 He7on3D4dlLIOnYwYKbuo+jkL84hTsrP9tU9T+GUoQrdE6GsukqhtIXC97F1Ql8Qd0+g Hw1O1A1s+F93HF+wS3yoOPSmjSoUhtYLfZca5O71eRr4c8x0YAmOLkEmjimI0KerERkR gZfv/3ZRvDD6VMYfR0Ngl/klChguNgkEgIPv4dSdKim/Hk3/5RrsCJnmm4gw6kXiaaQ3 7twA== X-Gm-Message-State: AKGB3mK7eoggTEa5e+bCNjP75o4wz3LeFU655GPx1Sao9H5xynn2e4mK zxRJsBMnRMQIKa3w3H6X6dGGvbgY X-Google-Smtp-Source: ACJfBotMUG+6A32BiW8minANzMCJ/VdE4jLagW/Xm4N4Ua4c9MMsrFV1zTyQiZAg7YuBMjoIQ6hApw== X-Received: by 10.223.172.120 with SMTP id v111mr9381860wrc.195.1513790175070; Wed, 20 Dec 2017 09:16:15 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Wed, 20 Dec 2017 18:14:49 +0100 Message-Id: <1513790098-9815-38-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1513790098-9815-1-git-send-email-pbonzini@redhat.com> References: <1513790098-9815-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c0c::242 Subject: [Qemu-devel] [PULL 37/46] i8259: generalize statistics into common code 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: Peter Xu Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Peter Xu It was only for userspace i8259. Move it to general code so that kvm-i8259 can also use it in the future. Signed-off-by: Peter Xu Message-Id: <20171210063819.14892-4-peterx@redhat.com> Signed-off-by: Paolo Bonzini --- hw/intc/i8259.c | 37 +------------------------------------ hw/intc/i8259_common.c | 41 +++++++++++++++++++++++++++++++++++++= ++++ include/hw/isa/i8259_internal.h | 7 +++++-- 3 files changed, 47 insertions(+), 38 deletions(-) diff --git a/hw/intc/i8259.c b/hw/intc/i8259.c index 20c9d0a..d9b9666 100644 --- a/hw/intc/i8259.c +++ b/hw/intc/i8259.c @@ -25,11 +25,9 @@ #include "hw/hw.h" #include "hw/i386/pc.h" #include "hw/isa/isa.h" -#include "monitor/monitor.h" #include "qemu/timer.h" #include "qemu/log.h" #include "hw/isa/i8259_internal.h" -#include "hw/intc/intc.h" #include "trace.h" =20 /* debug PIC */ @@ -51,8 +49,6 @@ typedef struct PICClass { DeviceRealize parent_realize; } PICClass; =20 -static int irq_level[16]; -static uint64_t irq_count[16]; #ifdef DEBUG_IRQ_LATENCY static int64_t irq_time[16]; #endif @@ -126,13 +122,7 @@ static void pic_set_irq(void *opaque, int irq, int lev= el) int irq_index =3D s->master ? irq : irq + 8; =20 trace_pic_set_irq(s->master, irq, level); - - if (level !=3D irq_level[irq_index]) { - irq_level[irq_index] =3D level; - if (level =3D=3D 1) { - irq_count[irq_index]++; - } - } + pic_stat_update_irq(irq_index, level); =20 #ifdef DEBUG_IRQ_LATENCY if (level) { @@ -235,31 +225,6 @@ static void pic_reset(DeviceState *dev) pic_init_reset(s); } =20 -static bool pic_get_statistics(InterruptStatsProvider *obj, - uint64_t **irq_counts, unsigned int *nb_irq= s) -{ - PICCommonState *s =3D PIC_COMMON(obj); - - if (s->master) { - *irq_counts =3D irq_count; - *nb_irqs =3D ARRAY_SIZE(irq_count); - } else { - *irq_counts =3D NULL; - *nb_irqs =3D 0; - } - return true; -} - -static void pic_print_info(InterruptStatsProvider *obj, Monitor *mon) -{ - PICCommonState *s =3D PIC_COMMON(obj); - monitor_printf(mon, "pic%d: irr=3D%02x imr=3D%02x isr=3D%02x hprio=3D%= d " - "irq_base=3D%02x rr_sel=3D%d elcr=3D%02x fnm=3D%d\n", - s->master ? 0 : 1, s->irr, s->imr, s->isr, s->priority_= add, - s->irq_base, s->read_reg_select, s->elcr, - s->special_fully_nested_mode); -} - static void pic_ioport_write(void *opaque, hwaddr addr64, uint64_t val64, unsigned size) { diff --git a/hw/intc/i8259_common.c b/hw/intc/i8259_common.c index 18427b4..a3cadde 100644 --- a/hw/intc/i8259_common.c +++ b/hw/intc/i8259_common.c @@ -25,6 +25,10 @@ #include "qemu/osdep.h" #include "hw/i386/pc.h" #include "hw/isa/i8259_internal.h" +#include "monitor/monitor.h" + +static int irq_level[16]; +static uint64_t irq_count[16]; =20 void pic_reset_common(PICCommonState *s) { @@ -98,6 +102,43 @@ ISADevice *i8259_init_chip(const char *name, ISABus *bu= s, bool master) return isadev; } =20 +void pic_stat_update_irq(int irq, int level) +{ + if (level !=3D irq_level[irq]) { + irq_level[irq] =3D level; + if (level =3D=3D 1) { + irq_count[irq]++; + } + } +} + +bool pic_get_statistics(InterruptStatsProvider *obj, + uint64_t **irq_counts, unsigned int *nb_irqs) +{ + PICCommonState *s =3D PIC_COMMON(obj); + + if (s->master) { + *irq_counts =3D irq_count; + *nb_irqs =3D ARRAY_SIZE(irq_count); + } else { + *irq_counts =3D NULL; + *nb_irqs =3D 0; + } + + return true; +} + +void pic_print_info(InterruptStatsProvider *obj, Monitor *mon) +{ + PICCommonState *s =3D PIC_COMMON(obj); + + monitor_printf(mon, "pic%d: irr=3D%02x imr=3D%02x isr=3D%02x hprio=3D%= d " + "irq_base=3D%02x rr_sel=3D%d elcr=3D%02x fnm=3D%d\n", + s->master ? 0 : 1, s->irr, s->imr, s->isr, s->priority_= add, + s->irq_base, s->read_reg_select, s->elcr, + s->special_fully_nested_mode); +} + static const VMStateDescription vmstate_pic_common =3D { .name =3D "i8259", .version_id =3D 1, diff --git a/include/hw/isa/i8259_internal.h b/include/hw/isa/i8259_interna= l.h index 6954b6e..f742c2a 100644 --- a/include/hw/isa/i8259_internal.h +++ b/include/hw/isa/i8259_internal.h @@ -28,6 +28,7 @@ #include "hw/hw.h" #include "hw/i386/pc.h" #include "hw/isa/isa.h" +#include "hw/intc/intc.h" =20 typedef struct PICCommonState PICCommonState; =20 @@ -76,8 +77,10 @@ struct PICCommonState { }; =20 void pic_reset_common(PICCommonState *s); - ISADevice *i8259_init_chip(const char *name, ISABus *bus, bool master); - +void pic_stat_update_irq(int irq, int level); +bool pic_get_statistics(InterruptStatsProvider *obj, + uint64_t **irq_counts, unsigned int *nb_irqs); +void pic_print_info(InterruptStatsProvider *obj, Monitor *mon); =20 #endif /* QEMU_I8259_INTERNAL_H */ --=20 1.8.3.1