From nobody Sat May 18 10:57:25 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1676484992; cv=none; d=zohomail.com; s=zohoarc; b=ih3EEalMLke+QL91fZgsHqJ6Q0DNMxk9Jl0UX5Hmp/ERKnOKXle5Wm6n5cm3rx57/x4eZKbxwa8SPNN40BlKyKHKLOs6suMvBMcCQhgnpMrbLkjB//BrRQR1zTZ26c2UWBsP1uxqs8EZcZbzorUUfTz2XtXp7f0GJAl/HOx6uIc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1676484992; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=heFm5UqUphDjJpVI7Qv+ZKuvoLHrfHy/aAGqW6xSVEo=; b=aP3qwqy5/Wc+lv4043vk09pqEOp7PyJk6titK99g4qz7Fh7rRhmiM8BOmssdbZ2jKSECupL1Y5f6ChAHClhtP6xwOrMi0FTTth45MG/bDZHj0rP8SUWkLb08SvMoiM08xfG1sA/nkHjymblpxZ6eQo3kmBCnaMzuXGP2w3Co5so= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1676484992245875.8243003513555; Wed, 15 Feb 2023 10:16:32 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pSLp8-0000bE-5H; Wed, 15 Feb 2023 12:44:06 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pSLp6-0000ak-6l for qemu-devel@nongnu.org; Wed, 15 Feb 2023 12:44:04 -0500 Received: from mail-wr1-x434.google.com ([2a00:1450:4864:20::434]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pSLp4-0008D3-O5 for qemu-devel@nongnu.org; Wed, 15 Feb 2023 12:44:03 -0500 Received: by mail-wr1-x434.google.com with SMTP id k3so12340688wrv.5 for ; Wed, 15 Feb 2023 09:44:02 -0800 (PST) Received: from localhost.localdomain ([81.0.6.76]) by smtp.gmail.com with ESMTPSA id u13-20020a5d468d000000b002c54c92e125sm12669586wrq.46.2023.02.15.09.43.59 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Wed, 15 Feb 2023 09:44:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=heFm5UqUphDjJpVI7Qv+ZKuvoLHrfHy/aAGqW6xSVEo=; b=w8OC715+aOMsi5OmhZ3/3915Wpmr4UaBPw/l9+UT6ZztgIO7uB/Cf1zJS51Erm39On M37AHEy0UPw6phGdnh8GuDzIiBqrVEvTrzrvJ31eX/0EcYLw39AR7GePTiNRgC4nVqZz Ng7qjUBYwlDO1Am7qbCjsaOJ9pYi5LOqB3rRz9qn0/72BR5PzypZRWcWZcjoZO4/wF8E j9ZrUM1nah63GXuse1P2N+h5+F39qljWEglEOYEu6L0t59OJH5G/7LW7XYJpLtNcLuTh R8N0vw6iS3jHRMrkxypkswbcI41eSWwNLObPQ+p+e8DMd1pwiuICQ+VyZ3jea78dtV0R Pp+A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=heFm5UqUphDjJpVI7Qv+ZKuvoLHrfHy/aAGqW6xSVEo=; b=ft0XGn/PnxmnDFmjmzUmON8thrHSAQhB2wFoML4LIvZsMwHX5PLyHbjCJSIp+T7wRV VyQNEYImXQVTOQtA4t6OMC4PDhaKr5Wn48w8Sf40Wi9EH2ktV9xhA7YS217nEoGyrcAa F9wFN48RKP6wp1E6mtYe/kDA/mpishGlPQvpdlqgamcywEXl6syhTIJVUpLtX+vcByvo zIP+5uH8zoTVmxjsLtgAY1tTd/Q2xep03gJxLZXfqArXF+Way64YXXhvXINb40m+dhwO TCZdM1BBB0ZxNT4+iEhBG6bQVkn8iJE0y/LoDJKu4F+JMO+5tl+ROFORFSW2xIpD4dii PpTg== X-Gm-Message-State: AO0yUKXLFrmkU/+J0wbXEuXbQAFec1EWHuXngomd6lEKaas8wxQdqVY0 EwGVYyKEll32aKJed1P5bbpACQ4XDfNf7PYv X-Google-Smtp-Source: AK7set9QBzatX+iyzVMoe6/2+9iCbBIcnZ+Nl4ZdjUTu/yelgqHueAFwPIoLUgQyYvb7peWPRbfvPg== X-Received: by 2002:adf:ce02:0:b0:2c5:50f2:fcbc with SMTP id p2-20020adfce02000000b002c550f2fcbcmr2514670wrn.21.1676483040963; Wed, 15 Feb 2023 09:44:00 -0800 (PST) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Marcelo Tosatti , Sergio Lopez , Paolo Bonzini , Richard Henderson , kvm@vger.kernel.org, "Michael S. Tsirkin" , Eduardo Habkost , qemu-ppc@nongnu.org, Marcel Apfelbaum , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH 1/5] hw/timer/hpet: Include missing 'hw/qdev-properties.h' header Date: Wed, 15 Feb 2023 18:43:49 +0100 Message-Id: <20230215174353.37097-2-philmd@linaro.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230215174353.37097-1-philmd@linaro.org> References: <20230215174353.37097-1-philmd@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.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; Received-SPF: pass client-ip=2a00:1450:4864:20::434; envelope-from=philmd@linaro.org; helo=mail-wr1-x434.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1676484992712100001 Avoid when refactoring unrelated headers: hw/timer/hpet.c:776:39: error: array has incomplete element type 'Propert= y' (aka 'struct Property') static Property hpet_device_properties[] =3D { ^ hw/timer/hpet.c:777:5: error: implicit declaration of function 'DEFINE_PR= OP_UINT8' is invalid in C99 [-Werror,-Wimplicit-function-declaration] DEFINE_PROP_UINT8("timers", HPETState, num_timers, HPET_MIN_TIMERS), ^ Signed-off-by: Philippe Mathieu-Daud=C3=A9 Acked-by: Michael S. Tsirkin Acked-by: Richard Henderson --- hw/timer/hpet.c | 1 + 1 file changed, 1 insertion(+) diff --git a/hw/timer/hpet.c b/hw/timer/hpet.c index 9520471be2..214d6a0501 100644 --- a/hw/timer/hpet.c +++ b/hw/timer/hpet.c @@ -30,6 +30,7 @@ #include "qapi/error.h" #include "qemu/error-report.h" #include "qemu/timer.h" +#include "hw/qdev-properties.h" #include "hw/timer/hpet.h" #include "hw/sysbus.h" #include "hw/rtc/mc146818rtc.h" --=20 2.38.1 From nobody Sat May 18 10:57:25 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1676484701; cv=none; d=zohomail.com; s=zohoarc; b=dh8JN1JytCobkhzc32onYSoRI1GD84KiDvvFNXJCmqxzREcT0bl5HyRFqshhPKYhPL6eKIK6G5UJT1iVAeFCER8VErW/GwS53i+MNPD9yopfgPkcmWrPbdeh7nu2Es+hoaB24GoXV8hO4ys5pGcahIJz42stf1l8MkcdcSkLE/g= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1676484701; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=4xWeqx5C/Xjzaw1eQA4/F7uZTIcR+NwJk/0kJcEYTAY=; b=Itv29H1aIW45OUMmv8tV3UgvFe0p6beasqCJ52nOY6Ts53K/aVdSqTs6ESjWGf8H0PccKQNXzkS1/lvq0n+Pmi23QIys/+KDHZbsQzfHxB6Ud57dB9Hdjsle8qR20RRIPcODtgrWReJiz0RqMJA8kozMVPata82e0spLMW4xSZU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1676484701277448.78749217047437; Wed, 15 Feb 2023 10:11:41 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pSLpD-0000en-JQ; Wed, 15 Feb 2023 12:44:11 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pSLpC-0000eD-9t for qemu-devel@nongnu.org; Wed, 15 Feb 2023 12:44:10 -0500 Received: from mail-wm1-x32e.google.com ([2a00:1450:4864:20::32e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pSLpA-0008DY-OX for qemu-devel@nongnu.org; Wed, 15 Feb 2023 12:44:10 -0500 Received: by mail-wm1-x32e.google.com with SMTP id k8-20020a05600c1c8800b003dc57ea0dfeso2223587wms.0 for ; Wed, 15 Feb 2023 09:44:08 -0800 (PST) Received: from localhost.localdomain ([81.0.6.76]) by smtp.gmail.com with ESMTPSA id p17-20020a05600c469100b003dd1b00bd9asm3004147wmo.32.2023.02.15.09.44.05 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Wed, 15 Feb 2023 09:44:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=4xWeqx5C/Xjzaw1eQA4/F7uZTIcR+NwJk/0kJcEYTAY=; b=IUZDYPUxoTz64E5CsADb59dPUZIMb31X/tgySvrGmDuEdvmFEsEv6OOqEoawQhASpG Y0xqT/osOWB55zfb8IVlEB3g1aB1GWTupU2lQyzgeNtSNKaamuxhw3iYy0SkzEe+R46g LprJCLeEklZ/81t+bixRziYVDcy8+TFCsuLS68X/58n36lUeUl4xu/x2G4XKQUl8fqVY yNKqf6iZbq4hyHOBsdePvt3k/ANFx5oTSnBcPRL/EC69r53YA1fJkxV7+LKweyPxFsGg WeiA/cxycScza3jopc7RZxjZuDuqUm4iRm95y714NBpoKGuOhQM+TjlWakSBXG9WHd9x P6Nw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=4xWeqx5C/Xjzaw1eQA4/F7uZTIcR+NwJk/0kJcEYTAY=; b=CdnMLCWh5EmtHRFeBmN1ENa9NADNcyvvaHOeUTk6Yeq22OpZi595+YgaetbMW0/Gd1 UMulCmp3ps7YIgR2oKa4ndC9jamfeXp2xLL0pISVIlyUpE0CuShoISrtL5n89vgWA7RI PNDkzR1yjF386owBgbHMwx+VeIQPR1gDjYgmpopkpwWMpe27960jYW2jP41D/WvhqGNA 7Ip+nL/8z/PHY1YrqmNx5WOUdMBKf2Fhz3VyqpGCA0nhr13FbE8ig3fJ/l9JPdSaUTyE mqQCUH5izw/4v6qCeVHLngBVsd2lHLolz7/qngHoqBkHIKj/JZ3eIVwoi9QKN+Rg2Jq0 dNww== X-Gm-Message-State: AO0yUKUkf0t3d7smhvM1LDY9ZBVMyvplCPawy/rl44dP3ubYRdgrdKSZ P4x4g0cY1tzRwII22avKmN06j0jYVPDRaQSh X-Google-Smtp-Source: AK7set/7lvshecTiyDKvaOH/yA+UWKADLvy67Z5P7A4WG491XE/W3jOetrh7ZzUU8Z/Vc4P2Um29/A== X-Received: by 2002:a05:600c:46c6:b0:3e0:14a:697a with SMTP id q6-20020a05600c46c600b003e0014a697amr2921374wmo.6.1676483046880; Wed, 15 Feb 2023 09:44:06 -0800 (PST) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Marcelo Tosatti , Sergio Lopez , Paolo Bonzini , Richard Henderson , kvm@vger.kernel.org, "Michael S. Tsirkin" , Eduardo Habkost , qemu-ppc@nongnu.org, Marcel Apfelbaum , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH 2/5] hw/timer/i8254: Factor i8254_pit_create() out and document Date: Wed, 15 Feb 2023 18:43:50 +0100 Message-Id: <20230215174353.37097-3-philmd@linaro.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230215174353.37097-1-philmd@linaro.org> References: <20230215174353.37097-1-philmd@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.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; Received-SPF: pass client-ip=2a00:1450:4864:20::32e; envelope-from=philmd@linaro.org; helo=mail-wm1-x32e.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1676484703220100001 Signed-off-by: Philippe Mathieu-Daud=C3=A9 Acked-by: Michael S. Tsirkin Reviewed-by: Richard Henderson --- hw/timer/i8254.c | 16 ++++++++++++++++ include/hw/timer/i8254.h | 24 +++++++++++++----------- 2 files changed, 29 insertions(+), 11 deletions(-) diff --git a/hw/timer/i8254.c b/hw/timer/i8254.c index c8388ea432..9b6932ab08 100644 --- a/hw/timer/i8254.c +++ b/hw/timer/i8254.c @@ -26,9 +26,11 @@ #include "hw/irq.h" #include "qemu/module.h" #include "qemu/timer.h" +#include "hw/qdev-properties.h" #include "hw/timer/i8254.h" #include "hw/timer/i8254_internal.h" #include "qom/object.h" +#include "qapi/error.h" =20 //#define DEBUG_PIT =20 @@ -47,6 +49,20 @@ struct PITClass { DeviceRealize parent_realize; }; =20 +ISADevice *i8254_pit_create(ISABus *bus, int iobase, qemu_irq irq_in) +{ + DeviceState *dev; + ISADevice *d; + + d =3D isa_new(TYPE_I8254); + dev =3D DEVICE(d); + qdev_prop_set_uint32(dev, "iobase", iobase); + isa_realize_and_unref(d, bus, &error_fatal); + qdev_connect_gpio_out(dev, 0, irq_in); + + return d; +} + static void pit_irq_timer_update(PITChannelState *s, int64_t current_time); =20 static int pit_get_count(PITChannelState *s) diff --git a/include/hw/timer/i8254.h b/include/hw/timer/i8254.h index 8402caad30..a0843cae07 100644 --- a/include/hw/timer/i8254.h +++ b/include/hw/timer/i8254.h @@ -45,21 +45,23 @@ OBJECT_DECLARE_TYPE(PITCommonState, PITCommonClass, PIT= _COMMON) #define TYPE_I8254 "isa-pit" #define TYPE_KVM_I8254 "kvm-pit" =20 +/** + * Create and realize a I8254 PIT device on the heap. + * @bus: the #ISABus to put it on. + * @iobase: the base I/O port. + * @irq_in: qemu_irq to connect the PIT output IRQ to. + * + * Create the device state structure, initialize it, put it on the + * specified ISA @bus, and drop the reference to it (the device is realize= d). + */ +ISADevice *i8254_pit_create(ISABus *bus, int iobase, qemu_irq irq_in); + static inline ISADevice *i8254_pit_init(ISABus *bus, int base, int isa_irq, qemu_irq alt_irq) { - DeviceState *dev; - ISADevice *d; - - d =3D isa_new(TYPE_I8254); - dev =3D DEVICE(d); - qdev_prop_set_uint32(dev, "iobase", base); - isa_realize_and_unref(d, bus, &error_fatal); - qdev_connect_gpio_out(dev, 0, - isa_irq >=3D 0 ? isa_bus_get_irq(bus, isa_irq) + return i8254_pit_create(bus, base, isa_irq >=3D 0 + ? isa_bus_get_irq(bus, isa_irq) : alt_irq); - - return d; } =20 static inline ISADevice *kvm_pit_init(ISABus *bus, int base) --=20 2.38.1 From nobody Sat May 18 10:57:25 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1676485123; cv=none; d=zohomail.com; s=zohoarc; b=SlI3rgdTGq1d84jwnbJz02sqA8J0j7KloqZz5Ich68fuetpudlHnkeIVgdYQnwi4g3z/GDdSZAd/4SJyYQN2kTa5J+2rtv6BnYfRp+E1NVrKcZakZtHVuwlTFa1GYXrbhmmsCzV958VmGKTTeohHed0NX+Mzt06AauY6UoqnLVk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1676485123; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=vz35UX4luoMUaqbzTcDDIbvcjgeBkxbh135cUjhEHMo=; b=hM1z8dYQTFLk6c5TuuMPg+z6D7lnqEbL+Tv38N7nycc2y6kXRzW74N2VGbi50o7vO0ZIFkRXd7HaIrUuM/OiJuFWUZvGogcB8rKHmMDhviGtOSP+UqJUqem0G7DC5fUbWyXoY+CNVSvLF5qAiANGsFz4tKlVNrhcHF5eS5Wc4L0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1676485123776323.15875608891247; Wed, 15 Feb 2023 10:18:43 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pSLpI-0000fT-6Z; Wed, 15 Feb 2023 12:44:16 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pSLpH-0000fA-1Y for qemu-devel@nongnu.org; Wed, 15 Feb 2023 12:44:15 -0500 Received: from mail-wr1-x42b.google.com ([2a00:1450:4864:20::42b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pSLpF-0008Dy-HD for qemu-devel@nongnu.org; Wed, 15 Feb 2023 12:44:14 -0500 Received: by mail-wr1-x42b.google.com with SMTP id by3so18659946wrb.10 for ; Wed, 15 Feb 2023 09:44:13 -0800 (PST) Received: from localhost.localdomain ([81.0.6.76]) by smtp.gmail.com with ESMTPSA id s9-20020a5d4ec9000000b002c567881dbcsm4363915wrv.48.2023.02.15.09.44.10 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Wed, 15 Feb 2023 09:44:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=vz35UX4luoMUaqbzTcDDIbvcjgeBkxbh135cUjhEHMo=; b=yowuVGL7oMXH61gQZvS6cQqkgZm8BocUdDiMLffKX5wVEPHygVvBzk8k0YGLyjZ0NI bQlOVBLDdtlQRPbUP5QQAT6ldo1lLIHrMbFA3uT5qVxOGCeLADLn/cxXLDqql2CVYdmJ FqVGuQLxjAbAKvb4wAKxWcTCv31Ivp+ASPsR3Z0HZTzUuF+OjeJbg66Gy79h8HSaYVKx wfQd/3YIxgXU6DMsp08+5QEJt5IWOgJLjS8+dFXzRMLwidPwif6Ax+A3QSC+6r8ejNxP RpoklAoNBnE4Lq3buUfJgPxJ9K4fB9XUfaEY9jqjb3lAo06ZFQ9gtaOvd3Qk/ryDqYdw 5Fow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=vz35UX4luoMUaqbzTcDDIbvcjgeBkxbh135cUjhEHMo=; b=qD00VXZCp3wbdiwN3u6o5cMl56baFH/YkYloxUVHNWQmj1+qyo04wSYDamt7Z/DahD YFa8MUFY6Yd5osAKP5oursQx30pmapJoKwaK0s9kzY1XA+/zvmXDPbhf2k51eXiAyTm5 hk1TlYpOHkSe6mfRo81RjSxbKcWUedntCfLmwnmS7TOXjFc5GyrHqJrSq92ZuJKNS8q3 S5L2XQi1oBtLLCGNv5E1Pm1nGma9dh0/KR5eBmOerCMtRAY/1ATIiCst8I1LXQgatbu+ nvc5rt7Np8FGgHLqLfknbsLbmth2QpC16isPLs7/Ilpkg9hsVc976tw4CDEfwBzm242o wqaQ== X-Gm-Message-State: AO0yUKXcBSjZhm0xwWfoYE4LTGi95maNNuklaguXMVdU8WArcurTgf44 trPZtZ/3CPsgbIdauzbeg7mW/bMfsPLl7zNG X-Google-Smtp-Source: AK7set/xn5Ccsu5wveg0hA8LklsQ+9ymklxMsebESI86/qV1Z+xqiOKNeIuLLMvRjwl0dPZDKqPv8Q== X-Received: by 2002:a5d:4b06:0:b0:2c5:4b93:ee44 with SMTP id v6-20020a5d4b06000000b002c54b93ee44mr2256030wrq.60.1676483052008; Wed, 15 Feb 2023 09:44:12 -0800 (PST) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Marcelo Tosatti , Sergio Lopez , Paolo Bonzini , Richard Henderson , kvm@vger.kernel.org, "Michael S. Tsirkin" , Eduardo Habkost , qemu-ppc@nongnu.org, Marcel Apfelbaum , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH 3/5] hw/i386/pc: Un-inline i8254_pit_init() Date: Wed, 15 Feb 2023 18:43:51 +0100 Message-Id: <20230215174353.37097-4-philmd@linaro.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230215174353.37097-1-philmd@linaro.org> References: <20230215174353.37097-1-philmd@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.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; Received-SPF: pass client-ip=2a00:1450:4864:20::42b; envelope-from=philmd@linaro.org; helo=mail-wr1-x42b.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1676485125519100001 pc_basic_device_init() is the single caller of i8254_pit_init() with a non-NULL 'alt_irq' argument. Open-code i8254_pit_init() by direclty calling i8254_pit_create(). To confirm all other callers pass a NULL 'alt_irq', add an assertion in i8254_pit_init(). Signed-off-by: Philippe Mathieu-Daud=C3=A9 Acked-by: Michael S. Tsirkin Reviewed-by: Richard Henderson --- hw/i386/pc.c | 10 +++++----- include/hw/timer/i8254.h | 5 ++--- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/hw/i386/pc.c b/hw/i386/pc.c index 79297a6ecd..fe95f6e9f2 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -1258,8 +1258,7 @@ void pc_basic_device_init(struct PCMachineState *pcms, { int i; DeviceState *hpet =3D NULL; - int pit_isa_irq =3D 0; - qemu_irq pit_alt_irq =3D NULL; + qemu_irq pit_irq; qemu_irq rtc_irq =3D NULL; ISADevice *pit =3D NULL; MemoryRegion *ioport80_io =3D g_new(MemoryRegion, 1); @@ -1301,9 +1300,10 @@ void pc_basic_device_init(struct PCMachineState *pcm= s, for (i =3D 0; i < GSI_NUM_PINS; i++) { sysbus_connect_irq(SYS_BUS_DEVICE(hpet), i, gsi[i]); } - pit_isa_irq =3D -1; - pit_alt_irq =3D qdev_get_gpio_in(hpet, HPET_LEGACY_PIT_INT); + pit_irq =3D qdev_get_gpio_in(hpet, HPET_LEGACY_PIT_INT); rtc_irq =3D qdev_get_gpio_in(hpet, HPET_LEGACY_RTC_INT); + } else { + pit_irq =3D isa_bus_get_irq(isa_bus, 0); } *rtc_state =3D mc146818_rtc_init(isa_bus, 2000, rtc_irq); =20 @@ -1314,7 +1314,7 @@ void pc_basic_device_init(struct PCMachineState *pcms, if (kvm_pit_in_kernel()) { pit =3D kvm_pit_init(isa_bus, 0x40); } else { - pit =3D i8254_pit_init(isa_bus, 0x40, pit_isa_irq, pit_alt_irq= ); + pit =3D i8254_pit_create(isa_bus, 0x40, pit_irq); } if (hpet) { /* connect PIT to output control line of the HPET */ diff --git a/include/hw/timer/i8254.h b/include/hw/timer/i8254.h index a0843cae07..0d837f3f41 100644 --- a/include/hw/timer/i8254.h +++ b/include/hw/timer/i8254.h @@ -59,9 +59,8 @@ ISADevice *i8254_pit_create(ISABus *bus, int iobase, qemu= _irq irq_in); static inline ISADevice *i8254_pit_init(ISABus *bus, int base, int isa_irq, qemu_irq alt_irq) { - return i8254_pit_create(bus, base, isa_irq >=3D 0 - ? isa_bus_get_irq(bus, isa_irq) - : alt_irq); + assert(isa_irq =3D=3D 0 && alt_irq =3D=3D NULL); + return i8254_pit_create(bus, base, isa_bus_get_irq(bus, 0)); } =20 static inline ISADevice *kvm_pit_init(ISABus *bus, int base) --=20 2.38.1 From nobody Sat May 18 10:57:25 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1676483918; cv=none; d=zohomail.com; s=zohoarc; b=Fw7Nx9tMAIyw180QNOwsBVu48e7SR1VQseYIMdFS0j3yALk57x3PAz24riLy8HN+fBWo9xGjyUrKietfWfgO6Vl2ZgDFmhFb6JbSnftZDGlhRwpL2sV7Jg0XlKyte/lN+F1MhcOJoKmLSGbe+stnIiEfrN5T4FuXePRLD9s9ENs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1676483918; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=zRiYpacq2buGtsbzdt2U4edvI0iODkUmTaRGtL8ovas=; b=Bv4kX1sVNV8XqUvlsG35RTHSpkUdmtg/pOy3O+Y1ugQh/UnTxxePQL9Drk5O/2tgzzXqeFbhcIDPc4gH/G9ZupWJYk7COxlRZzHEldjeUzn9hk9ZzXc68j6bsXnbQ+9jzcuR+OeoLbsK5QeWciZ5C7YrjXPZQH6J98i2F4iQnXo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 16764839185322.508626761635128; Wed, 15 Feb 2023 09:58:38 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pSLpO-0000hA-Uu; Wed, 15 Feb 2023 12:44:22 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pSLpN-0000gj-MN for qemu-devel@nongnu.org; Wed, 15 Feb 2023 12:44:21 -0500 Received: from mail-wm1-x331.google.com ([2a00:1450:4864:20::331]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pSLpL-0008EX-Ia for qemu-devel@nongnu.org; Wed, 15 Feb 2023 12:44:21 -0500 Received: by mail-wm1-x331.google.com with SMTP id l21-20020a05600c1d1500b003dfe462b7e4so2951230wms.0 for ; Wed, 15 Feb 2023 09:44:19 -0800 (PST) Received: from localhost.localdomain ([81.0.6.76]) by smtp.gmail.com with ESMTPSA id 21-20020a05600c021500b003e209186c07sm414427wmi.19.2023.02.15.09.44.16 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Wed, 15 Feb 2023 09:44:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=zRiYpacq2buGtsbzdt2U4edvI0iODkUmTaRGtL8ovas=; b=jDsZJRQLERfeLQ490jpStffMhiCHc+0Rwb7tmTYaJq0Kw6f+YIzHKeqnuJALZNPbAJ URQiKJ1Jgt4qncCRdljh3VUryyaUxWLFWFTt21xdoaz80sQlE1IArzmcK6mpuxHwqhDb ZOBcfs8MLY0rzQPRd9oHW2MVOm10HmIgfQ5tVRi9Qm1nHOWniVqlMJzjPEfq0GqVFEiD XmB7L3HDZoWo46KvkoyBicrBZ+xPsjAnYdi3OQiKxuvZKTlI4+3sZp+MN+LjvG98sSpB iuzEddUN4npG0E5L37O6WRfVOt3789FjxMaTxqx4YekzlaHL5ebxC6mC/eHo6c0ENmVn BH3g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=zRiYpacq2buGtsbzdt2U4edvI0iODkUmTaRGtL8ovas=; b=Pxx+ZzEyvsWXNBUpq4cSxGQkZ2T+rrT/14dPMgBZEowoqo+wxv9hjp4rGGooRLIfuo JhP9OTAohHQW81BzMOTD7Ule2dlnfuK8dnRi0Y3i37wsgVm6gvYBYFjmxtqz8uUkHgKG 8H3b9MP5TJF+ubmSwKCo6ooozdxw5tBce0MZnUHG82aqXlyfwnU++cjoA8YCKVcTWiJW RHNEb1gW4OYgBm2zXi1+zipWQKj6Y/XDsb6pfxKlplTX1uF/Lpm/UgjL5Mlho/LjEzFI FsNBiy66jrGetGJfpdd/Lj0+9BZtgEycYyTOESM1dqmkNVjqOvNi2/N4kj5l3G9WiiIx 0OhQ== X-Gm-Message-State: AO0yUKVJQAcxFzCnijAtMkQCCftYn0G3z49HHCpdLQAq6u3uHBf8pPVK Q9tqbpXgmd2GeNhwuNUfYvmFE/ufM0t76mNH X-Google-Smtp-Source: AK7set8jnVvjneWIxfxH9Bn5U/pjoZeBdZs+qd4MTX4M47EdU+EutDCEiNwQ6TNvB3qvIVBBMpJe7w== X-Received: by 2002:a05:600c:318a:b0:3db:5f1:53a5 with SMTP id s10-20020a05600c318a00b003db05f153a5mr2757152wmp.20.1676483058010; Wed, 15 Feb 2023 09:44:18 -0800 (PST) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Marcelo Tosatti , Sergio Lopez , Paolo Bonzini , Richard Henderson , kvm@vger.kernel.org, "Michael S. Tsirkin" , Eduardo Habkost , qemu-ppc@nongnu.org, Marcel Apfelbaum , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , =?UTF-8?q?Herv=C3=A9=20Poussineau?= , Aurelien Jarno , Huacai Chen , Jiaxun Yang , Aleksandar Rikalo Subject: [PATCH 4/5] hw/timer/i8254: Really inline i8254_pit_init() Date: Wed, 15 Feb 2023 18:43:52 +0100 Message-Id: <20230215174353.37097-5-philmd@linaro.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230215174353.37097-1-philmd@linaro.org> References: <20230215174353.37097-1-philmd@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.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; Received-SPF: pass client-ip=2a00:1450:4864:20::331; envelope-from=philmd@linaro.org; helo=mail-wm1-x331.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1676483920190100001 In-line the one-line i8254_pit_create() call. Signed-off-by: Philippe Mathieu-Daud=C3=A9 Acked-by: Michael S. Tsirkin Reviewed-by: Richard Henderson --- hw/i386/microvm.c | 2 +- hw/isa/i82378.c | 2 +- hw/isa/piix4.c | 4 ++-- hw/isa/vt82c686.c | 2 +- hw/mips/jazz.c | 2 +- include/hw/timer/i8254.h | 7 ------- 6 files changed, 6 insertions(+), 13 deletions(-) diff --git a/hw/i386/microvm.c b/hw/i386/microvm.c index 29f30dd6d3..9204bb4ff2 100644 --- a/hw/i386/microvm.c +++ b/hw/i386/microvm.c @@ -261,7 +261,7 @@ static void microvm_devices_init(MicrovmMachineState *m= ms) if (kvm_pit_in_kernel()) { kvm_pit_init(isa_bus, 0x40); } else { - i8254_pit_init(isa_bus, 0x40, 0, NULL); + i8254_pit_create(isa_bus, 0x40, isa_bus_get_irq(isa_bus, 0)); } } =20 diff --git a/hw/isa/i82378.c b/hw/isa/i82378.c index e3322e03bf..f75f5a23ba 100644 --- a/hw/isa/i82378.c +++ b/hw/isa/i82378.c @@ -99,7 +99,7 @@ static void i82378_realize(PCIDevice *pci, Error **errp) isa_bus_irqs(isabus, s->i8259); =20 /* 1 82C54 (pit) */ - pit =3D i8254_pit_init(isabus, 0x40, 0, NULL); + pit =3D i8254_pit_create(isabus, 0x40, isa_bus_get_irq(isabus, 0)); =20 /* speaker */ pcspk_init(isa_new(TYPE_PC_SPEAKER), isabus, pit); diff --git a/hw/isa/piix4.c b/hw/isa/piix4.c index 94e5dc7825..8ff118445f 100644 --- a/hw/isa/piix4.c +++ b/hw/isa/piix4.c @@ -214,8 +214,8 @@ static void piix4_realize(PCIDevice *dev, Error **errp) /* initialize ISA irqs */ isa_bus_irqs(isa_bus, s->isa); =20 - /* initialize pit */ - i8254_pit_init(isa_bus, 0x40, 0, NULL); + /* PIT */ + i8254_pit_create(isa_bus, 0x40, isa_bus_get_irq(isa_bus, 0)); =20 /* DMA */ i8257_dma_init(isa_bus, 0); diff --git a/hw/isa/vt82c686.c b/hw/isa/vt82c686.c index 3f9bd0c04d..297bcda420 100644 --- a/hw/isa/vt82c686.c +++ b/hw/isa/vt82c686.c @@ -624,7 +624,7 @@ static void via_isa_realize(PCIDevice *d, Error **errp) =20 s->isa_irqs =3D i8259_init(isa_bus, *isa_irq); isa_bus_irqs(isa_bus, s->isa_irqs); - i8254_pit_init(isa_bus, 0x40, 0, NULL); + i8254_pit_create(isa_bus, 0x40, isa_bus_get_irq(isa_bus, 0)); i8257_dma_init(isa_bus, 0); =20 /* RTC */ diff --git a/hw/mips/jazz.c b/hw/mips/jazz.c index 6aefe9a61b..856acfe2a7 100644 --- a/hw/mips/jazz.c +++ b/hw/mips/jazz.c @@ -251,7 +251,7 @@ static void mips_jazz_init(MachineState *machine, i8259 =3D i8259_init(isa_bus, env->irq[4]); isa_bus_irqs(isa_bus, i8259); i8257_dma_init(isa_bus, 0); - pit =3D i8254_pit_init(isa_bus, 0x40, 0, NULL); + pit =3D i8254_pit_create(isa_bus, 0x40, isa_bus_get_irq(isa_bus, 0)); pcspk_init(isa_new(TYPE_PC_SPEAKER), isa_bus, pit); =20 /* Video card */ diff --git a/include/hw/timer/i8254.h b/include/hw/timer/i8254.h index 0d837f3f41..aa48c44d39 100644 --- a/include/hw/timer/i8254.h +++ b/include/hw/timer/i8254.h @@ -56,13 +56,6 @@ OBJECT_DECLARE_TYPE(PITCommonState, PITCommonClass, PIT_= COMMON) */ ISADevice *i8254_pit_create(ISABus *bus, int iobase, qemu_irq irq_in); =20 -static inline ISADevice *i8254_pit_init(ISABus *bus, int base, int isa_irq, - qemu_irq alt_irq) -{ - assert(isa_irq =3D=3D 0 && alt_irq =3D=3D NULL); - return i8254_pit_create(bus, base, isa_bus_get_irq(bus, 0)); -} - static inline ISADevice *kvm_pit_init(ISABus *bus, int base) { DeviceState *dev; --=20 2.38.1 From nobody Sat May 18 10:57:25 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1676485327; cv=none; d=zohomail.com; s=zohoarc; b=KTP6WnKmIcMCTXaMLjPTLYCYjH6Mp3tRaI+fBAve+SUbXlVC7S5kkUuiP6IuKnXKyGnRWCJhmhqaOHvwJFTkCaKiZV98v0KXi2DG0ZM74LqnWzaep63unHoPEjFpeB7YyEMHyE30DXe4aXtkM/qAtSXm8byKJmIcL1PZ/RX1eH8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1676485327; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=IWNxqquWLNXTTocLvUxsoGH+JCmIcd1Q1kcJ09WY8/Y=; b=PEI34wVmB7gjwkK4HHVNB0nVU3F8O/vxeH2PN9MzVgb9roXK8PCZKsq1hk4qigIt12M3AHArf0rJ7jnjAnZ1ctNvRFAP7MGexp5mF/v7xn1i0YTc3OYXLAbcxD5MQnPIqdMqSDQPNgTmvD+w8L0Xuu3BiX40WYYexTrSMzgzvzo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1676485327114543.2175210129591; Wed, 15 Feb 2023 10:22:07 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pSLpV-00018v-2j; Wed, 15 Feb 2023 12:44:29 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pSLpT-00012H-Tv for qemu-devel@nongnu.org; Wed, 15 Feb 2023 12:44:27 -0500 Received: from mail-wr1-x435.google.com ([2a00:1450:4864:20::435]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pSLpR-0008Fi-GP for qemu-devel@nongnu.org; Wed, 15 Feb 2023 12:44:27 -0500 Received: by mail-wr1-x435.google.com with SMTP id s13so2252145wrw.3 for ; Wed, 15 Feb 2023 09:44:25 -0800 (PST) Received: from localhost.localdomain ([81.0.6.76]) by smtp.gmail.com with ESMTPSA id f15-20020adff98f000000b002c5583ab017sm8580863wrr.15.2023.02.15.09.44.22 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Wed, 15 Feb 2023 09:44:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=IWNxqquWLNXTTocLvUxsoGH+JCmIcd1Q1kcJ09WY8/Y=; b=sFTIywSyT5+Gm4JtVTiPy8pocwC8NLizi+OnGXa0F8gxS+pw88AJbAHk8HZ7sMb/FI 96175WS+payrqFe8IfpT4VJY+oPZRbvrGyBnOF8Uqmsn6iQhZzPnmM8IIAY9peP0Rvb3 KmGaMCMDxADFPMYBVs414xcyLurQUmdISGtc2hXzlzGGjaWuKPBxBCbVpt1qA1Ey6/7d GrXiarGGH9FGWJ+Z/diMir38jMpVosC8m/8Bc1owB+ohPRD7/4E6z6f8dQ3O7wGgPp7J wmJ2lUOCWMb98RpgxN+xQiLQl2T/CmNOhPQrbsRtwqGuL+pmikV9vmZVVYh/tKAU8uc+ u1Vg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=IWNxqquWLNXTTocLvUxsoGH+JCmIcd1Q1kcJ09WY8/Y=; b=eQASOu7vJHUsrizIWeNHizb3Y6Z1vjvfbXu7jFwIQs57t7rYgdU8HVcBmO0KGEflCI NjvwndW+cuAfZPSvPU2Ohi1ep0et3JLzNTTcEr6FO2uSTDDsMzfxqqb9SBk0UPnn71O+ 3ZPxYlQ6JkPzs0Ewb/PbOcLneoyzdY8JZAk8AgxkTW+OuS5CUiFi291unEMHUGfcpWf9 UEI77ClNTPRIVfeTVIn/Dep8juNCCbtFbr5Qdk6OetmKWqY3CyVNm6qdK6vEC3z2/8gH 3WsfwH5uIs4eKs33ljaoXAeMttVUPPIIJRhc79PrLcAEA66O3TEcJ6ll5dsnyoUEj7m4 HDYA== X-Gm-Message-State: AO0yUKXMT+dGXM2KdEWzF1AEmVDH6hWReuNqFynBNQyEnKHZnf7vO+vj 6R81nrmTSl3+XpG5z+1EPJwryi7aS+rn7jHV X-Google-Smtp-Source: AK7set/dBoQ8bwhtu/KAQyOrlfuHEmIHSM2Ph1ygizmQiCsBZ4rAct1OR5ti0L9UZGbe4LmrE3eiEQ== X-Received: by 2002:a05:6000:3c7:b0:2c5:4c07:9593 with SMTP id b7-20020a05600003c700b002c54c079593mr135627wrg.16.1676483063919; Wed, 15 Feb 2023 09:44:23 -0800 (PST) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Marcelo Tosatti , Sergio Lopez , Paolo Bonzini , Richard Henderson , kvm@vger.kernel.org, "Michael S. Tsirkin" , Eduardo Habkost , qemu-ppc@nongnu.org, Marcel Apfelbaum , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH 5/5] hw/i386/kvm: Factor i8254_pit_create_try_kvm() out Date: Wed, 15 Feb 2023 18:43:53 +0100 Message-Id: <20230215174353.37097-6-philmd@linaro.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230215174353.37097-1-philmd@linaro.org> References: <20230215174353.37097-1-philmd@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.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; Received-SPF: pass client-ip=2a00:1450:4864:20::435; envelope-from=philmd@linaro.org; helo=mail-wr1-x435.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1676485328621100001 Factor a new i8254_pit_create_try_kvm() helper out of the following patter: if (kvm_pit_in_kernel()) { kvm_pit_init(...); } else } i8254_pit_create(...); } (adding a stub for non-KVM builds). Since kvm_pit_init() is only used once, un-inline it and remove the now unused headers from "hw/timer/i8254.h". Signed-off-by: Philippe Mathieu-Daud=C3=A9 Acked-by: Michael S. Tsirkin Reviewed-by: Richard Henderson --- hw/i386/kvm/i8254.c | 18 ++++++++++++++++++ hw/i386/microvm.c | 6 +----- hw/i386/pc.c | 7 ++----- include/hw/timer/i8254.h | 22 ++++++---------------- target/i386/kvm/kvm-stub.c | 6 ++++++ 5 files changed, 33 insertions(+), 26 deletions(-) diff --git a/hw/i386/kvm/i8254.c b/hw/i386/kvm/i8254.c index 191a26fa57..9520c98c76 100644 --- a/hw/i386/kvm/i8254.c +++ b/hw/i386/kvm/i8254.c @@ -35,6 +35,7 @@ #include "hw/qdev-properties-system.h" #include "sysemu/kvm.h" #include "qom/object.h" +#include "kvm/kvm_i386.h" =20 #define KVM_PIT_REINJECT_BIT 0 =20 @@ -59,6 +60,23 @@ struct KVMPITClass { DeviceRealize parent_realize; }; =20 +ISADevice *i8254_pit_create_try_kvm(ISABus *bus, int iobase, qemu_irq irq_= in) +{ + DeviceState *dev; + ISADevice *d; + + if (!kvm_pit_in_kernel()) { + return i8254_pit_create(bus, iobase, irq_in); + } + + d =3D isa_new(TYPE_KVM_I8254); + dev =3D DEVICE(d); + qdev_prop_set_uint32(dev, "iobase", iobase); + isa_realize_and_unref(d, bus, &error_fatal); + + return d; +} + static void kvm_pit_update_clock_offset(KVMPITState *s) { int64_t offset, clock_offset; diff --git a/hw/i386/microvm.c b/hw/i386/microvm.c index 9204bb4ff2..d93dc8a263 100644 --- a/hw/i386/microvm.c +++ b/hw/i386/microvm.c @@ -258,11 +258,7 @@ static void microvm_devices_init(MicrovmMachineState *= mms) } =20 if (x86ms->pit =3D=3D ON_OFF_AUTO_ON || x86ms->pit =3D=3D ON_OFF_AUTO_= AUTO) { - if (kvm_pit_in_kernel()) { - kvm_pit_init(isa_bus, 0x40); - } else { - i8254_pit_create(isa_bus, 0x40, isa_bus_get_irq(isa_bus, 0)); - } + i8254_pit_create_try_kvm(isa_bus, 0x40, isa_bus_get_irq(isa_bus, 0= )); } =20 if (mms->rtc =3D=3D ON_OFF_AUTO_ON || diff --git a/hw/i386/pc.c b/hw/i386/pc.c index fe95f6e9f2..7d9f57c695 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -1311,11 +1311,8 @@ void pc_basic_device_init(struct PCMachineState *pcm= s, =20 if (!xen_enabled() && (x86ms->pit =3D=3D ON_OFF_AUTO_AUTO || x86ms->pit =3D=3D ON_OFF_AU= TO_ON)) { - if (kvm_pit_in_kernel()) { - pit =3D kvm_pit_init(isa_bus, 0x40); - } else { - pit =3D i8254_pit_create(isa_bus, 0x40, pit_irq); - } + pit =3D i8254_pit_create_try_kvm(isa_bus, 0x40, pit_irq); + if (hpet) { /* connect PIT to output control line of the HPET */ qdev_connect_gpio_out(hpet, 0, qdev_get_gpio_in(DEVICE(pit), 0= )); diff --git a/include/hw/timer/i8254.h b/include/hw/timer/i8254.h index aa48c44d39..9fb18c4ff4 100644 --- a/include/hw/timer/i8254.h +++ b/include/hw/timer/i8254.h @@ -25,9 +25,6 @@ #ifndef HW_I8254_H #define HW_I8254_H =20 -#include "hw/qdev-properties.h" -#include "hw/isa/isa.h" -#include "qapi/error.h" #include "qom/object.h" =20 #define PIT_FREQ 1193182 @@ -55,19 +52,12 @@ OBJECT_DECLARE_TYPE(PITCommonState, PITCommonClass, PIT= _COMMON) * specified ISA @bus, and drop the reference to it (the device is realize= d). */ ISADevice *i8254_pit_create(ISABus *bus, int iobase, qemu_irq irq_in); - -static inline ISADevice *kvm_pit_init(ISABus *bus, int base) -{ - DeviceState *dev; - ISADevice *d; - - d =3D isa_new(TYPE_KVM_I8254); - dev =3D DEVICE(d); - qdev_prop_set_uint32(dev, "iobase", base); - isa_realize_and_unref(d, bus, &error_fatal); - - return d; -} +/** + * Try to create and realize a in-kernel I8254 PIT device on the heap. + * If KVM is not available or doesn't have in-kernel PIT support, a + * emulated PIT is used. See i8254_pit_create. + */ +ISADevice *i8254_pit_create_try_kvm(ISABus *bus, int iobase, qemu_irq irq_= in); =20 void pit_set_gate(ISADevice *dev, int channel, int val); void pit_get_channel_info(ISADevice *dev, int channel, PITChannelInfo *inf= o); diff --git a/target/i386/kvm/kvm-stub.c b/target/i386/kvm/kvm-stub.c index e052f1c7b0..396da89f55 100644 --- a/target/i386/kvm/kvm-stub.c +++ b/target/i386/kvm/kvm-stub.c @@ -10,6 +10,7 @@ * */ #include "qemu/osdep.h" +#include "hw/timer/i8254.h" #include "cpu.h" #include "kvm_i386.h" =20 @@ -49,3 +50,8 @@ void kvm_set_max_apic_id(uint32_t max_apic_id) { return; } + +ISADevice *i8254_pit_create_try_kvm(ISABus *bus, int iobase, qemu_irq irq_= in) +{ + return i8254_pit_create(bus, iobase, irq_in); +} --=20 2.38.1