From patchwork Wed Feb 15 17:43:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 653732 Delivered-To: patch@linaro.org Received: by 2002:adf:f90f:0:0:0:0:0 with SMTP id b15csp476985wrr; Wed, 15 Feb 2023 09:45:29 -0800 (PST) X-Google-Smtp-Source: AK7set/sxVpZWJpNhzfC47ralwlbal26BBT1OKUZMz+iDrydTMhIoaXAmGE9JE/bVi9biRxecVVl X-Received: by 2002:a05:6214:e69:b0:56b:f061:c3c6 with SMTP id jz9-20020a0562140e6900b0056bf061c3c6mr6035632qvb.33.1676483129164; Wed, 15 Feb 2023 09:45:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676483129; cv=none; d=google.com; s=arc-20160816; b=TA69jfqzPXHDDfK/u00GWNRjiRaRjVIfpisxsVlYSzF3naKZ6k9RYjQkhjV9SXNe7i ArM/92L6WJx5qfwq9Ng7X2qx81wCYL5EOusYSdhLERe2xB9/gTxkMLU8cmJFsBTYbMpn eY+nShjZeGHX2soyBossuU1e5/K/emn/+i6j+DLysG3Czktv2QI9uK8mBkJuRGH8eWrT gJI0RaVdpvnEJp/s5CQefAs6JomOj3TlTYBEsrtck0p8hi4kSVQGgXGvPh7Fo4xgZHSj ugV6w73Q2kWORTD/L9nOimTK3tQo37iTOxCuELTGZx6/eRC8viwFlqI6GZSUVWuvHG9e dR8g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=heFm5UqUphDjJpVI7Qv+ZKuvoLHrfHy/aAGqW6xSVEo=; b=naAu+Qxig/6Qb9Vd57yJ1YSvQIEIggJbNIpAZRBV7qB6u2j62KEQ5MVAPrIGzsPn+N pKt9OS0CLUVpxl31ta9BMet8cJRJd9L3H4oGtxIGCSsYqOH1Y30rRJQeeWrVrcfaifeV dbWnkYLFTkqf98NrieTSjbXMYoPmr71/nmW98PZKOsgzeCqW8LQCyQRo77vGZ28cgdpB UPyKMCSR17bciXVr/3r2pxO3qtgr6bhUmxBf7HjuwFoFZWRGeASOD+9xEZZ951St6Dh3 rVF304VByeAkwoWWgU6+6NkUE1YqquxfrG/NaImao9Kg5HsPBRFElRK1DPS8mi13DgRs JpBQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=w8OC715+; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id k11-20020a0cabcb000000b0056ec162350csi332017qvb.340.2023.02.15.09.45.29 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 15 Feb 2023 09:45:29 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=w8OC715+; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org 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) 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-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) 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) From: =?utf-8?q?Philippe_Mathieu-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_Mathieu-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 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Avoid when refactoring unrelated headers: hw/timer/hpet.c:776:39: error: array has incomplete element type 'Property' (aka 'struct Property') static Property hpet_device_properties[] = { ^ hw/timer/hpet.c:777:5: error: implicit declaration of function 'DEFINE_PROP_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é 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" From patchwork Wed Feb 15 17:43:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 653731 Delivered-To: patch@linaro.org Received: by 2002:adf:f90f:0:0:0:0:0 with SMTP id b15csp476885wrr; Wed, 15 Feb 2023 09:45:15 -0800 (PST) X-Google-Smtp-Source: AK7set9mYLdCknLkl38F45UOYCqoc/RMysr4+YOultCFld1RttA0JYGNgjVn8spCQMnFkJ/2P16S X-Received: by 2002:a05:622a:178e:b0:3b8:118d:ad86 with SMTP id s14-20020a05622a178e00b003b8118dad86mr4703340qtk.21.1676483115241; Wed, 15 Feb 2023 09:45:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676483115; cv=none; d=google.com; s=arc-20160816; b=U6VPDGkcFx0lu9CiVjjxOPmHvwyeCbmFhUyhhA4G/3tyGVXOvfR/VjI31uuZxk/Qbi CeKnVpUopwck8k9ca3QGI5Qtp/eqxM6leyTXwIYKcSGgdwT2ruDwh2xibaXGnt7clHSF kSChbPLp6aobsh5QMXezqGVwhij3MYLzCdIfvZqSMPt+dzY6lYRme0AyO/HrZGxKi/+f smhH81vG6yhsURhO17yToDq1/TrJV+X+ry0+vH/UrzrJTnqd1yfcsxlkzPbGsR/rUYIa yDdgOC19J/lUHf+wpi6nsB3cDKK2yELlp9N9etbNJN8ebCLWA1x0uq88gHhW4flkuCKq 4ymQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=4xWeqx5C/Xjzaw1eQA4/F7uZTIcR+NwJk/0kJcEYTAY=; b=lXQPBPzF6PZOPiD8m70RVqXONvamixC/fFgCCJzjVdIEi7lfxuA7JZ3kVYRmxz8bgM v+vTHDsnK3WjGrEkIUPLSdNfAn8PLwj1ewOhEczsF1udjVXOaq6Jd0UbKxqjCXbkHjyT Fes+B9JOSa3Pozj7AmKWGPOlmWBSLLb6S/KrhKnIDnZvLrbdiv6Hbm+bQDbcKA287tVR sErQmtC9/a3M7cWNMgNR7YvhvJ4OAN/29XdGwukKnV8it7brzTwtO9TszWuJWVUZJS1i MXsHFS00HbnLo5ofVOwzKNsdd8nRI2NjtNERG3SpCi2gtOZVVKy2eRfI9SAbrWHhkk1Z yMuA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=IUZDYPUx; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id j17-20020a05620a411100b00706c837aeecsi15950129qko.148.2023.02.15.09.45.15 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 15 Feb 2023 09:45:15 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=IUZDYPUx; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org 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) 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-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) 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) From: =?utf-8?q?Philippe_Mathieu-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_Mathieu-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 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Signed-off-by: Philippe Mathieu-Daudé 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" //#define DEBUG_PIT @@ -47,6 +49,20 @@ struct PITClass { DeviceRealize parent_realize; }; +ISADevice *i8254_pit_create(ISABus *bus, int iobase, qemu_irq irq_in) +{ + DeviceState *dev; + ISADevice *d; + + d = isa_new(TYPE_I8254); + dev = 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); 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" +/** + * 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 realized). + */ +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 = isa_new(TYPE_I8254); - dev = 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 >= 0 ? isa_bus_get_irq(bus, isa_irq) + return i8254_pit_create(bus, base, isa_irq >= 0 + ? isa_bus_get_irq(bus, isa_irq) : alt_irq); - - return d; } static inline ISADevice *kvm_pit_init(ISABus *bus, int base) From patchwork Wed Feb 15 17:43:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 653735 Delivered-To: patch@linaro.org Received: by 2002:adf:f90f:0:0:0:0:0 with SMTP id b15csp477114wrr; Wed, 15 Feb 2023 09:45:42 -0800 (PST) X-Google-Smtp-Source: AK7set8MacKrafu0PdOTFBsej6kQaksbSLWh/005wZiIwjKgInBkYyz80Lq4x/WYrHM37xi30pr4 X-Received: by 2002:a05:622a:493:b0:3b7:ebb2:a4bf with SMTP id p19-20020a05622a049300b003b7ebb2a4bfmr5108204qtx.24.1676483142443; Wed, 15 Feb 2023 09:45:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676483142; cv=none; d=google.com; s=arc-20160816; b=RUqGFHzeHWgdRyVCUGaIeaksdosh74wLZilv6w2994+y9zNBi6gsCbdW2CBdH7r8a7 inkRNT3vJC3RUodsun9ahzi84+ZLkPKcgw6pYQr6CkKkp/UaIuWVY5y+LJIKYLfUvgdj faD5j9YTXTWQFszuGyYEwn/7NWFlggkR30rH8jEsBLpOqQgABNPv2V7BIgK3kTHcK8n2 bEyudel+VD7UslV16Yoz5czex5xEMOmQc6gmVgNYonzJFizSeGGoMdUdUQCX7wsioehb ZPaEOJLHyY7aaAhwjRut7rNuQysRCCDfgBFYFCoNopY3vqprwedY003ftOIU4dtQ9kfC lMKA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=vz35UX4luoMUaqbzTcDDIbvcjgeBkxbh135cUjhEHMo=; b=AOY71xXSj356DcBbBBuxNRsfkjdrENUEGkRw6mVYnfFz+g+AjxZbu0GwUIrz1Wo/k4 fe5n/iDbBxX8O5mcys8cz2bjeNxFKkfQFS2f1pnOg7oAEGc7UR+9v/ydAKPmhJ+wSZ18 /vTodkXPVsHWOgoRUHRq4/ug2SgUFAGTZgix6WYP4ZkftfCpKvyBqwIKfK8/pDpGTXWm 8XfUq22q+9putkVeD/ncXhji7qlvExT5VmAD5Ui3fqccZyBTWIjGps0cmMhpcUr1mVzD k+6/4UgKjjJ0wm4VulWSq3lSbf4fv7bT0Htj8LkodoHcGQkmYkZKIrTZ94VMsjgmSXTt 2ngA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=yowuVGL7; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id 10-20020ac8574a000000b003b86b161424si14382301qtx.469.2023.02.15.09.45.42 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 15 Feb 2023 09:45:42 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=yowuVGL7; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org 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) 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-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) 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) From: =?utf-8?q?Philippe_Mathieu-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_Mathieu-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 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org 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é 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 = NULL; - int pit_isa_irq = 0; - qemu_irq pit_alt_irq = NULL; + qemu_irq pit_irq; qemu_irq rtc_irq = NULL; ISADevice *pit = NULL; MemoryRegion *ioport80_io = g_new(MemoryRegion, 1); @@ -1301,9 +1300,10 @@ void pc_basic_device_init(struct PCMachineState *pcms, for (i = 0; i < GSI_NUM_PINS; i++) { sysbus_connect_irq(SYS_BUS_DEVICE(hpet), i, gsi[i]); } - pit_isa_irq = -1; - pit_alt_irq = qdev_get_gpio_in(hpet, HPET_LEGACY_PIT_INT); + pit_irq = qdev_get_gpio_in(hpet, HPET_LEGACY_PIT_INT); rtc_irq = qdev_get_gpio_in(hpet, HPET_LEGACY_RTC_INT); + } else { + pit_irq = isa_bus_get_irq(isa_bus, 0); } *rtc_state = mc146818_rtc_init(isa_bus, 2000, rtc_irq); @@ -1314,7 +1314,7 @@ void pc_basic_device_init(struct PCMachineState *pcms, if (kvm_pit_in_kernel()) { pit = kvm_pit_init(isa_bus, 0x40); } else { - pit = i8254_pit_init(isa_bus, 0x40, pit_isa_irq, pit_alt_irq); + pit = 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 >= 0 - ? isa_bus_get_irq(bus, isa_irq) - : alt_irq); + assert(isa_irq == 0 && alt_irq == NULL); + return i8254_pit_create(bus, base, isa_bus_get_irq(bus, 0)); } static inline ISADevice *kvm_pit_init(ISABus *bus, int base) From patchwork Wed Feb 15 17:43:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 653733 Delivered-To: patch@linaro.org Received: by 2002:adf:f90f:0:0:0:0:0 with SMTP id b15csp477046wrr; Wed, 15 Feb 2023 09:45:35 -0800 (PST) X-Google-Smtp-Source: AK7set/MSlHQztvE6PXimuZWKWP3AwSEt5b0y14eO26zdnP8SIbXLBAYK/1Z3AOgakCl4Bj3CDFw X-Received: by 2002:a05:622a:188c:b0:3ab:2a7f:83e4 with SMTP id v12-20020a05622a188c00b003ab2a7f83e4mr4413654qtc.35.1676483135619; Wed, 15 Feb 2023 09:45:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676483135; cv=none; d=google.com; s=arc-20160816; b=dz2camPl489euBv/4rLAG+ZilXn2ywzX9uIPOe65gtcoyVOYZ1HY/ujxxlTh/llcyU avnitC6THXv0hpDHLDAkBG4IASv5Fbqjc9l9t/ZtC6xHst5p9B/WbMS+Fwg58NTISzVJ 55jYjmYIi5nl182lScU5pArtO1QQ8VEO94aVrAUKuNm8zeBqlvU1XPaTCzR3+4xgVIKd Ull3g/th41UxLxydC1w6FOkJi7pCL0MnIuhubWpUl9dgPWndl5cT0+aIrwD3DTqvqTSM VldP/kTjwaPxWPJ4+hbUDO2x+e2OvLkGMAHod4rjjAJIoi0YsOcV0DSXgge65aiHsQly +W/w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=zRiYpacq2buGtsbzdt2U4edvI0iODkUmTaRGtL8ovas=; b=vCdMhDikJifzjuG9pAIseKLTSIj1iXT3njBVbCtKCWv7WCeEh5O2W+aDiegBftlqH/ V2kVNpOJDy8v/XhC8FU5Jzc5Se7IuTzFLrM+Bq8/Q154rBqGCo+1ep6BHImMWDQe7DRt KIoR/be4z/AW8yuFesz6wjGCkIpdMEdFrA4rw/CCfidWv2fyWCSEKKcETdP1YL8Uh3XT APZcBE8gDvkurb/LOyYYdapAm0H3rSq3fwFtCHrvF/LI2tK71oU2AEj52dHGkQC+6Aa/ BN11RcLrJtaMugRsgEF0KYfEzG8fJgngh78LzHuSUVDlhFk113/wYY9Ey/huLeZaPZVR 4GoA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=jDsZJRQL; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id q18-20020a05622a031200b003b86db881f3si15468894qtw.125.2023.02.15.09.45.35 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 15 Feb 2023 09:45:35 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=jDsZJRQL; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org 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) 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-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) 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) From: =?utf-8?q?Philippe_Mathieu-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_Mathieu-Daud=C3=A9?= , =?utf-8?q?Herv?= =?utf-8?q?=C3=A9_Poussineau?= , 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 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org In-line the one-line i8254_pit_create() call. Signed-off-by: Philippe Mathieu-Daudé 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 *mms) 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)); } } 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); /* 1 82C54 (pit) */ - pit = i8254_pit_init(isabus, 0x40, 0, NULL); + pit = i8254_pit_create(isabus, 0x40, isa_bus_get_irq(isabus, 0)); /* 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); - /* initialize pit */ - i8254_pit_init(isa_bus, 0x40, 0, NULL); + /* PIT */ + i8254_pit_create(isa_bus, 0x40, isa_bus_get_irq(isa_bus, 0)); /* 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) s->isa_irqs = 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); /* 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 = i8259_init(isa_bus, env->irq[4]); isa_bus_irqs(isa_bus, i8259); i8257_dma_init(isa_bus, 0); - pit = i8254_pit_init(isa_bus, 0x40, 0, NULL); + pit = i8254_pit_create(isa_bus, 0x40, isa_bus_get_irq(isa_bus, 0)); pcspk_init(isa_new(TYPE_PC_SPEAKER), isa_bus, pit); /* 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); -static inline ISADevice *i8254_pit_init(ISABus *bus, int base, int isa_irq, - qemu_irq alt_irq) -{ - assert(isa_irq == 0 && alt_irq == 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; From patchwork Wed Feb 15 17:43:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 653734 Delivered-To: patch@linaro.org Received: by 2002:adf:f90f:0:0:0:0:0 with SMTP id b15csp477089wrr; Wed, 15 Feb 2023 09:45:40 -0800 (PST) X-Google-Smtp-Source: AK7set9YUTN+fjJ/bhgUYtofpOI7Oh1UyYnm5XS4Wr4647bTfv+F6nxnuYxjlFZVPgDfLHfWGHm0 X-Received: by 2002:a05:622a:294:b0:3a8:11ab:c537 with SMTP id z20-20020a05622a029400b003a811abc537mr4515320qtw.63.1676483139375; Wed, 15 Feb 2023 09:45:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676483139; cv=none; d=google.com; s=arc-20160816; b=aHN74FHwy1ffKO9HwnjU5PG7TQX1kiYQFZr5sP3/QxGmB2EviNOMaMODq6MebIWhPI eruXGMVLa6IH4LA7q3iJSiKDRTfNjsaE+JPIjAWt34FGofIKQDySl8uCTxDxxgHOpd71 VuJnv40nWouUf85rzwm4K062EWU83Ald8P/BZBDNpE59gdTk8PyGAJ4p+haf5bCuPIgq AgNybP1dElrQ0B+Siofe12DIddistqMF5IzPSUt0XICE6tep+L/IKRlrupkcX3/01Cj6 Ceh+W6EUil3setpb5v4/uFl4V7mW0FTznqMxlZqGhoC86dEvdDMd5zSEnKy9dBk/Se9i X6oA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=IWNxqquWLNXTTocLvUxsoGH+JCmIcd1Q1kcJ09WY8/Y=; b=viFzgfQJO1j7oHeqLtzX8FX5VXNdj003xxGBfzprheiok67wdozvsE8vSsbmj56j3M 19HiXL9Vg42LazVECxgFgaFkqQ75EPqNQF/TmfoZ+uyTnXtKm5M7WC0nYoE5BVHCD2/X hfJ9btH/KLPjV1/N5yO50bjwHqe8YI5AA71Bgts2flM06zqGJ9p/wS/vRAmXDTPw+R48 Fn04WLuy1aX8hH8xOpRgCq/NE37nCyvekA6ef3Y5g1FVzq8YN81iGvXiwijVQsjpIQxU JN3ih/H5LqHoD1Ro8gz1DcHu3gAdOCs9m5XGzko5FAaj99cXS6+XDziBR3uE75JQNrzd gE7A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=sFTIywSy; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id q16-20020a05622a04d000b003bb8a14baf6si13015974qtx.595.2023.02.15.09.45.39 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 15 Feb 2023 09:45:39 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=sFTIywSy; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org 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) 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-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) 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) From: =?utf-8?q?Philippe_Mathieu-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_Mathieu-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 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org 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é 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" #define KVM_PIT_REINJECT_BIT 0 @@ -59,6 +60,23 @@ struct KVMPITClass { DeviceRealize parent_realize; }; +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 = isa_new(TYPE_KVM_I8254); + dev = 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) } if (x86ms->pit == ON_OFF_AUTO_ON || x86ms->pit == 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)); } if (mms->rtc == 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 *pcms, if (!xen_enabled() && (x86ms->pit == ON_OFF_AUTO_AUTO || x86ms->pit == ON_OFF_AUTO_ON)) { - if (kvm_pit_in_kernel()) { - pit = kvm_pit_init(isa_bus, 0x40); - } else { - pit = i8254_pit_create(isa_bus, 0x40, pit_irq); - } + pit = 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 -#include "hw/qdev-properties.h" -#include "hw/isa/isa.h" -#include "qapi/error.h" #include "qom/object.h" #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 realized). */ 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 = isa_new(TYPE_KVM_I8254); - dev = 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); void pit_set_gate(ISADevice *dev, int channel, int val); void pit_get_channel_info(ISADevice *dev, int channel, PITChannelInfo *info); 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" @@ -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); +}