From patchwork Thu Feb 8 22:03:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bernhard Beschow X-Patchwork-Id: 13550523 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id BC576C4828F for ; Thu, 8 Feb 2024 22:06:05 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rYCV2-0007F5-JP; Thu, 08 Feb 2024 17:04:04 -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 1rYCV1-0007Dz-3r for qemu-devel@nongnu.org; Thu, 08 Feb 2024 17:04:03 -0500 Received: from mail-lf1-x12a.google.com ([2a00:1450:4864:20::12a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rYCUy-0005DS-Qk for qemu-devel@nongnu.org; Thu, 08 Feb 2024 17:04:02 -0500 Received: by mail-lf1-x12a.google.com with SMTP id 2adb3069b0e04-5114b1e8819so437307e87.1 for ; Thu, 08 Feb 2024 14:04:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1707429838; x=1708034638; darn=nongnu.org; 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=0EMBB55jqpCJkBcQ1c0YyXXZsCM5p/S766dPr/hLwsk=; b=Ut5PICfQ6wqfCxT557qJF8DdFAcFFvR5K2t8Jf4hyXzG17BZLRYrzNhO5eXUMWc4wX eu/z3bsu+OGHiFJIaFvQwRwVCCaNCIW7EoEng0OonSVdFiJ7aV9LBa2fVw1s7JDEoSAT 0knPiNLbpwgZKZkjTxn9H/nqGHsVHYHM4BfAxruyeKzJoQla7H3V6mijzRoLY1K/WyE4 pgrYeaFXA6LxWt2XPvc6du4+U5yiV1IvMghp67osIUy6x1VcHurF5p8Losc9f96ZvhGZ IjawTK/4bn6qnbmOMGEojkcMMVmP6ldkIXCFApnRA+/9UvLGmSaQpzuOS8wusTvSpo4s 352g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707429838; x=1708034638; 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=0EMBB55jqpCJkBcQ1c0YyXXZsCM5p/S766dPr/hLwsk=; b=UEiFS2h9ymMeJdFtNoz2pmYxXlX/ykvbBSUKtsp7sNPpZ/v0QgekzsyTM0OyzEnRHY WArkmXW8xpqzlX4qfpHPEhpFjUkBq3iwmQdqPsG5x3gWf/XveGDhNNwhHcLEeHxm6F+f Q8LvZ46BYZcpdYn6MIxKhWkNzP5E+WYlEWvdX4yvTXPfGtuSxltwmWqVuYyHMHPqGiBb 0aLp/wUTe6YnYOLALeO33EvRxTS4nSrrwxwt9b9AKijjy2GK2gPEUfbWKD44Xm9vaJVg fFeUaBaV8TJaW+8OKDGpfXUgYIkqXM2a60liNvGYt+R4soGSIfeadHuJt26zR+qGFutg BpTA== X-Gm-Message-State: AOJu0YzhshkT9kqsyqmAfmucMRpBaOH+qIPSt6fpFObCUtuPl6d6QCbM B5z0Kttcaaaf6O/H8WHb+0azHWhZDiP8aJB4mNxeN2/mb++Q6U4faM0f3khs X-Google-Smtp-Source: AGHT+IFIc3rAWJLljLhw0OK9ZJ2YP7B18AdbGPz/q1iXnHP/fB1pfuiop1Zfv1Asevq+8hnkcWMXtg== X-Received: by 2002:ac2:465e:0:b0:511:5537:fb26 with SMTP id s30-20020ac2465e000000b005115537fb26mr369724lfo.39.1707429837900; Thu, 08 Feb 2024 14:03:57 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCU7bOUuVLV9JHzI1+sVnFJDlnciySTroAEBXgBjWPossKfVZrBLIugiscdfOieOF6YvqXy+K8Vtih09OKral58qf65IpOf+lILXq+k2/vVReYqk5ZLBlrjmIQ0do+/Ytj/WPS87rTr+UouqjDZhyGcAGh5fMROX1Htdax9s7cgJivxmdrAGjPRZTsxwmjvUV8vi5R+1iKCYgO4Dof0voU3atefTdI0HAqMKNGVUUbX+lVtScZ1C Received: from archlinux.. (pd95ed842.dip0.t-ipconnect.de. [217.94.216.66]) by smtp.gmail.com with ESMTPSA id ti9-20020a170907c20900b00a3109a492d4sm109753ejc.20.2024.02.08.14.03.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Feb 2024 14:03:57 -0800 (PST) From: Bernhard Beschow To: qemu-devel@nongnu.org Cc: "Michael S. Tsirkin" , Eduardo Habkost , Paolo Bonzini , Sergio Lopez , Richard Henderson , Marcel Apfelbaum , Bernhard Beschow Subject: [PATCH 1/9] hw/i386/x86: Let ioapic_init_gsi() take parent as pointer Date: Thu, 8 Feb 2024 23:03:41 +0100 Message-ID: <20240208220349.4948-2-shentey@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240208220349.4948-1-shentey@gmail.com> References: <20240208220349.4948-1-shentey@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::12a; envelope-from=shentey@gmail.com; helo=mail-lf1-x12a.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, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Rather than taking a QOM name which has to be resolved, let's pass the parent directly as pointer. This simplifies the code. Signed-off-by: Bernhard Beschow --- include/hw/i386/x86.h | 2 +- hw/i386/microvm.c | 2 +- hw/i386/pc_piix.c | 7 +++---- hw/i386/pc_q35.c | 4 ++-- hw/i386/x86.c | 7 +++---- 5 files changed, 10 insertions(+), 12 deletions(-) diff --git a/include/hw/i386/x86.h b/include/hw/i386/x86.h index da19ae1546..6fe29fbb87 100644 --- a/include/hw/i386/x86.h +++ b/include/hw/i386/x86.h @@ -138,7 +138,7 @@ typedef struct GSIState { qemu_irq x86_allocate_cpu_irq(void); void gsi_handler(void *opaque, int n, int level); -void ioapic_init_gsi(GSIState *gsi_state, const char *parent_name); +void ioapic_init_gsi(GSIState *gsi_state, Object *parent); DeviceState *ioapic_init_secondary(GSIState *gsi_state); /* pc_sysfw.c */ diff --git a/hw/i386/microvm.c b/hw/i386/microvm.c index ca55aecc3b..61a772dfe6 100644 --- a/hw/i386/microvm.c +++ b/hw/i386/microvm.c @@ -175,7 +175,7 @@ static void microvm_devices_init(MicrovmMachineState *mms) &error_abort); isa_bus_register_input_irqs(isa_bus, x86ms->gsi); - ioapic_init_gsi(gsi_state, "machine"); + ioapic_init_gsi(gsi_state, OBJECT(mms)); if (ioapics > 1) { x86ms->ioapic2 = ioapic_init_secondary(gsi_state); } diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c index 70d12bb1b5..5ed3d69181 100644 --- a/hw/i386/pc_piix.c +++ b/hw/i386/pc_piix.c @@ -109,6 +109,7 @@ static void pc_init1(MachineState *machine, X86MachineState *x86ms = X86_MACHINE(machine); MemoryRegion *system_memory = get_system_memory(); MemoryRegion *system_io = get_system_io(); + Object *phb = NULL; PCIBus *pci_bus = NULL; ISABus *isa_bus; Object *piix4_pm = NULL; @@ -192,8 +193,6 @@ static void pc_init1(MachineState *machine, } if (pcmc->pci_enabled) { - Object *phb; - pci_memory = g_new(MemoryRegion, 1); memory_region_init(pci_memory, NULL, "pci", UINT64_MAX); rom_memory = pci_memory; @@ -320,8 +319,8 @@ static void pc_init1(MachineState *machine, pc_i8259_create(isa_bus, gsi_state->i8259_irq); } - if (pcmc->pci_enabled) { - ioapic_init_gsi(gsi_state, "i440fx"); + if (phb) { + ioapic_init_gsi(gsi_state, phb); } if (tcg_enabled()) { diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c index 7ca3f465e0..53da8b552d 100644 --- a/hw/i386/pc_q35.c +++ b/hw/i386/pc_q35.c @@ -286,8 +286,8 @@ static void pc_q35_init(MachineState *machine) pc_i8259_create(isa_bus, gsi_state->i8259_irq); } - if (pcmc->pci_enabled) { - ioapic_init_gsi(gsi_state, "q35"); + if (phb) { + ioapic_init_gsi(gsi_state, OBJECT(phb)); } if (tcg_enabled()) { diff --git a/hw/i386/x86.c b/hw/i386/x86.c index 2b6291ad8d..3b33d09a53 100644 --- a/hw/i386/x86.c +++ b/hw/i386/x86.c @@ -636,20 +636,19 @@ void gsi_handler(void *opaque, int n, int level) } } -void ioapic_init_gsi(GSIState *gsi_state, const char *parent_name) +void ioapic_init_gsi(GSIState *gsi_state, Object *parent) { DeviceState *dev; SysBusDevice *d; unsigned int i; - assert(parent_name); + assert(parent); if (kvm_ioapic_in_kernel()) { dev = qdev_new(TYPE_KVM_IOAPIC); } else { dev = qdev_new(TYPE_IOAPIC); } - object_property_add_child(object_resolve_path(parent_name, NULL), - "ioapic", OBJECT(dev)); + object_property_add_child(parent, "ioapic", OBJECT(dev)); d = SYS_BUS_DEVICE(dev); sysbus_realize_and_unref(d, &error_fatal); sysbus_mmio_map(d, 0, IO_APIC_DEFAULT_ADDRESS); From patchwork Thu Feb 8 22:03:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Bernhard Beschow X-Patchwork-Id: 13550524 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id C3E29C48260 for ; Thu, 8 Feb 2024 22:06:13 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rYCV2-0007F0-EQ; Thu, 08 Feb 2024 17:04:04 -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 1rYCV0-0007Do-Ny for qemu-devel@nongnu.org; Thu, 08 Feb 2024 17:04:02 -0500 Received: from mail-ej1-x62e.google.com ([2a00:1450:4864:20::62e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rYCUy-0005DU-Kk for qemu-devel@nongnu.org; Thu, 08 Feb 2024 17:04:02 -0500 Received: by mail-ej1-x62e.google.com with SMTP id a640c23a62f3a-a3850ce741bso29483166b.3 for ; Thu, 08 Feb 2024 14:04:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1707429839; x=1708034639; darn=nongnu.org; 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=MksDv+yuTaWdPt4ciwdCyn21modyrve25TmwyGLNphs=; b=I6Rh3ciII8iiwgTKkbXPAUhqe3Nj9B49FqX8PtAzV7b9d8t20OpCjHbFYFfSTAy/jS C09g5imeeY+R3FSzUMg/bcYkpMOvdRGldKEbCeSRaWHes+dU8wzNHFD8EN/3MDgWMaTc B1t6ZZuD1TbQH09+l77afGXsd6f4/JbT++maazLg3qJTdpuxJ4/T/ITokF3n4z2eP5kl 4KecPWgcUpc7G3YIELvms+8+qMuuQO4EVJ35Mh0xWtr7jS4eEmbNHFK95q6092prfOXH WTY8g0yGXk3R7F3828UI1abA63ZHhFJ5n05ZikahhofLDMgHoRFyj1KYnkSs7/HsCIm8 PIwA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707429839; x=1708034639; 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=MksDv+yuTaWdPt4ciwdCyn21modyrve25TmwyGLNphs=; b=wX7sA6Z4LJbbrSRMpMR01GJKBWilrV1RkW0U0u2T7UVanCQPTNPvVz992LHK8Omr4L V8GYKytQeY/06aznpVst4wIM+XcGJfZtE3/iDGJ4m++NNenkW0D+nTR3uAlO2ZeXyG7E y61gZXPmAxrww7RF3fzFrXz6EIuxQ10m2SSdU68bbLIRVXx2mHNNRIrgrm2m7dORDndS NhQssufbqqYvSjHVzFowK6ZbcTMXnHfRFd11VkBZRn01ug4yLDC3bNHKyNTRrI7VWh8+ rZGSAFap4MEDC2nk/scYYqPjcavPyBrnGZu42fY8HVtYlEkmPYkmlaSdM1p2HurTpgu+ aLbQ== X-Gm-Message-State: AOJu0YwwEnHzFOaMEr96kbkECtfCrfLx4zwKOMUFdTv3hZiDRFmBHzgY yImsB2VjEtG0xFQZo6RK5PsEMumui9rKzgX1zmTLT3KPJZYUKnmiqq/zT8bg X-Google-Smtp-Source: AGHT+IF3doQBwPlTff1JBpCYhoMLchHMVBVk4rt4ky2Riv/YdYWSkSnlhaDdjAVao2YJ5T7cgOZT1A== X-Received: by 2002:a17:906:7fd9:b0:a3b:bf98:fa21 with SMTP id r25-20020a1709067fd900b00a3bbf98fa21mr427304ejs.76.1707429838541; Thu, 08 Feb 2024 14:03:58 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCX9qSaZ8dwYbfgen88Xox2C+UejbFs0Oo3Ic7Un1ytEaFvm36wu6mzlyJFlsor43/26FCv1kWwEJMNtQ5HFSwVatjbpY0+p8MZX5q1ASyJnL10UYg6ZQzzl3Ukm158OEKMs/Be+PYk99Djbn4/f7fCQZSHecmjcjSf7vP3qsyuPevwoTYJywWOe6jcZifJipemwLKnD9vY3XR2Y2GYXdg979A2pWAAKTvCprOn1uJAwARSbfjF3 Received: from archlinux.. (pd95ed842.dip0.t-ipconnect.de. [217.94.216.66]) by smtp.gmail.com with ESMTPSA id ti9-20020a170907c20900b00a3109a492d4sm109753ejc.20.2024.02.08.14.03.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Feb 2024 14:03:58 -0800 (PST) From: Bernhard Beschow To: qemu-devel@nongnu.org Cc: "Michael S. Tsirkin" , Eduardo Habkost , Paolo Bonzini , Sergio Lopez , Richard Henderson , Marcel Apfelbaum , Bernhard Beschow Subject: [PATCH 2/9] hw/i386/pc_piix: Share pc_cmos_init() invocation between pc and isapc machines Date: Thu, 8 Feb 2024 23:03:42 +0100 Message-ID: <20240208220349.4948-3-shentey@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240208220349.4948-1-shentey@gmail.com> References: <20240208220349.4948-1-shentey@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::62e; envelope-from=shentey@gmail.com; helo=mail-ej1-x62e.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, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Both invocations are the same and either one is always executed. Avoid this redundancy. Signed-off-by: Bernhard Beschow Reviewed-by: Philippe Mathieu-Daudé --- hw/i386/pc_piix.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c index 5ed3d69181..adb3b5ed43 100644 --- a/hw/i386/pc_piix.c +++ b/hw/i386/pc_piix.c @@ -340,11 +340,8 @@ static void pc_init1(MachineState *machine, pc_nic_init(pcmc, isa_bus, pci_bus); - if (pcmc->pci_enabled) { - pc_cmos_init(pcms, idebus[0], idebus[1], rtc_state); - } #ifdef CONFIG_IDE_ISA - else { + if (!pcmc->pci_enabled) { DriveInfo *hd[MAX_IDE_BUS * MAX_IDE_DEVS]; int i; @@ -362,10 +359,11 @@ static void pc_init1(MachineState *machine, busname[4] = '0' + i; idebus[i] = qdev_get_child_bus(DEVICE(dev), busname); } - pc_cmos_init(pcms, idebus[0], idebus[1], rtc_state); } #endif + pc_cmos_init(pcms, idebus[0], idebus[1], rtc_state); + if (piix4_pm) { smi_irq = qemu_allocate_irq(pc_acpi_smi_interrupt, first_cpu, 0); From patchwork Thu Feb 8 22:03:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Bernhard Beschow X-Patchwork-Id: 13550525 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id D957CC4828F for ; Thu, 8 Feb 2024 22:06:17 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rYCV3-0007Fw-6W; Thu, 08 Feb 2024 17:04:05 -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 1rYCV1-0007EK-DW for qemu-devel@nongnu.org; Thu, 08 Feb 2024 17:04:03 -0500 Received: from mail-ej1-x629.google.com ([2a00:1450:4864:20::629]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rYCUz-0005DZ-J8 for qemu-devel@nongnu.org; Thu, 08 Feb 2024 17:04:03 -0500 Received: by mail-ej1-x629.google.com with SMTP id a640c23a62f3a-a370e7e1e02so33473166b.0 for ; Thu, 08 Feb 2024 14:04:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1707429839; x=1708034639; darn=nongnu.org; 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=kGkMYPa+RTmey7fKt7GCaGAdkjjOt2z+kR77UOLngnA=; b=ErTRD+1sKzeCzmbNbeV/qYQL+tHjPB5a57hpe4MbDoUjUw/uKFUPwylN01Psrgx1BX INePWk0o51uRG8JjlUbPcaagC12toprgvW0B2v2fZskq93n1r9wfQ1uo4kneStNouLvD NUDFKhTNQ0QVayToaOuXJxAjmMCyT+EFMgRssf17Yx7WKD2W4eq+trVkgN5JPBn0c/PD xJj06i1GfDX0SvdLqCqlWGd0QZ8l4P1KJodrHXRKdGh/Yv/yuQfeC+yX1BIgoYYwErMq hCEEgXbctEpmA8DkIRGvrulsSB7FMaE3BmKSp8h+KXDIkVEgMXNUqN8bD3N7wXVuve2o xn0g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707429839; x=1708034639; 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=kGkMYPa+RTmey7fKt7GCaGAdkjjOt2z+kR77UOLngnA=; b=pfB+cR2IZF/6yPdNxn3CFGoTYYV2rrqzDKeJM+F2ktIUQHtnkVAuH4srkcm7t5II9v y8OkbK6HxtqX0bwSg7Jr1HsZ8l6+G34iQdqJhEK1UOjOoOgA/rGqGTBgSzjGuvPVbxjj PDXkwFjOo+uRGZL2uiv5Z6hMLOipDazeEg6Kk7HNdSlsHVaidFM834LM1tXpcH3ynDKJ Se33Ntf3QupVB8EQCenVCN91EUfFXMJ9Dp6rHWVSFGZtugGQD2OorMjIhl7a3sc7IIB3 1yFqL/HZC6ZSEzCKjD7z1/E07MyKW2Lus77ys6Xx0lz5+fubam2sdmEwN+WBaEE/JDS+ R30A== X-Gm-Message-State: AOJu0YzvxVzU4gCAapORQjgFnaRdLHU4Nm6ozX4PD2HLjEimZjS0hrdR dQuV1NXKmnG9EL++gr0bGItH2mDUM9AC9LrhEu2belB0VJnTbmycZA1moRS+ X-Google-Smtp-Source: AGHT+IE70RhJvm38m4K85ijmn6DrkCmTf5Z/Do+Ow2gedNT3DNH3MkJd9uJecMDbTP4tAdZ/ReuZ9w== X-Received: by 2002:a17:906:fc09:b0:a38:5cf1:b58 with SMTP id ov9-20020a170906fc0900b00a385cf10b58mr437105ejb.47.1707429839171; Thu, 08 Feb 2024 14:03:59 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCVTP5j4+eaVgRgr9gGGYsJplIhXQbB7Sc8/MO7oPlYuHJl0v/0bn8Z41U4wMNUvdQdwXQfPFgkHr6OdUkKKaWq/f73HAnkVNqDN4uP56en6uZ64QyLkBLzP3qzTP74aZCa2NQbBXyXbZGJZk9jbewVVOhRPi5wbcopDmDJ3hYr71ofZF9k0wnAeR5gt+gxb+TPSJCHHzaEMOneXBGGHvumF/Y5VuTkK1VdWKhNNexE/bJZTPj5S Received: from archlinux.. (pd95ed842.dip0.t-ipconnect.de. [217.94.216.66]) by smtp.gmail.com with ESMTPSA id ti9-20020a170907c20900b00a3109a492d4sm109753ejc.20.2024.02.08.14.03.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Feb 2024 14:03:58 -0800 (PST) From: Bernhard Beschow To: qemu-devel@nongnu.org Cc: "Michael S. Tsirkin" , Eduardo Habkost , Paolo Bonzini , Sergio Lopez , Richard Henderson , Marcel Apfelbaum , Bernhard Beschow Subject: [PATCH 3/9] hw/i386/x86: Turn apic_xrupt_override into class attribute Date: Thu, 8 Feb 2024 23:03:43 +0100 Message-ID: <20240208220349.4948-4-shentey@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240208220349.4948-1-shentey@gmail.com> References: <20240208220349.4948-1-shentey@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::629; envelope-from=shentey@gmail.com; helo=mail-ej1-x629.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, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org The attribute isn't user-changeable and only true for pc-based machines. Turn it into a class attribute which allows for inlining pc_guest_info_init() into pc_machine_initfn(). Signed-off-by: Bernhard Beschow Reviewed-by: Philippe Mathieu-Daudé --- include/hw/i386/x86.h | 3 ++- hw/i386/acpi-common.c | 3 ++- hw/i386/pc.c | 5 ++--- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/include/hw/i386/x86.h b/include/hw/i386/x86.h index 6fe29fbb87..4dc30dcb4d 100644 --- a/include/hw/i386/x86.h +++ b/include/hw/i386/x86.h @@ -34,6 +34,8 @@ struct X86MachineClass { bool save_tsc_khz; /* use DMA capable linuxboot option rom */ bool fwcfg_dma_enabled; + /* CPU and apic information: */ + bool apic_xrupt_override; }; struct X86MachineState { @@ -57,7 +59,6 @@ struct X86MachineState { uint64_t above_4g_mem_start; /* CPU and apic information: */ - bool apic_xrupt_override; unsigned pci_irq_mask; unsigned apic_id_limit; uint16_t boot_cpus; diff --git a/hw/i386/acpi-common.c b/hw/i386/acpi-common.c index 43dc23f7e0..cea4b3d71c 100644 --- a/hw/i386/acpi-common.c +++ b/hw/i386/acpi-common.c @@ -100,6 +100,7 @@ void acpi_build_madt(GArray *table_data, BIOSLinker *linker, int i; bool x2apic_mode = false; MachineClass *mc = MACHINE_GET_CLASS(x86ms); + X86MachineClass *x86mc = X86_MACHINE_GET_CLASS(x86ms); const CPUArchIdList *apic_ids = mc->possible_cpu_arch_ids(MACHINE(x86ms)); AcpiTable table = { .sig = "APIC", .rev = 3, .oem_id = oem_id, .oem_table_id = oem_table_id }; @@ -122,7 +123,7 @@ void acpi_build_madt(GArray *table_data, BIOSLinker *linker, IO_APIC_SECONDARY_ADDRESS, IO_APIC_SECONDARY_IRQBASE); } - if (x86ms->apic_xrupt_override) { + if (x86mc->apic_xrupt_override) { build_xrupt_override(table_data, 0, 2, 0 /* Flags: Conforms to the specifications of the bus */); } diff --git a/hw/i386/pc.c b/hw/i386/pc.c index 196827531a..12facf73b1 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -708,9 +708,6 @@ void pc_machine_done(Notifier *notifier, void *data) void pc_guest_info_init(PCMachineState *pcms) { - X86MachineState *x86ms = X86_MACHINE(pcms); - - x86ms->apic_xrupt_override = true; pcms->machine_done.notify = pc_machine_done; qemu_add_machine_init_done_notifier(&pcms->machine_done); } @@ -1807,6 +1804,7 @@ static bool pc_hotplug_allowed(MachineState *ms, DeviceState *dev, Error **errp) static void pc_machine_class_init(ObjectClass *oc, void *data) { MachineClass *mc = MACHINE_CLASS(oc); + X86MachineClass *x86mc = X86_MACHINE_CLASS(oc); PCMachineClass *pcmc = PC_MACHINE_CLASS(oc); HotplugHandlerClass *hc = HOTPLUG_HANDLER_CLASS(oc); @@ -1826,6 +1824,7 @@ static void pc_machine_class_init(ObjectClass *oc, void *data) pcmc->pvh_enabled = true; pcmc->kvmclock_create_always = true; pcmc->resizable_acpi_blob = true; + x86mc->apic_xrupt_override = true; assert(!mc->get_hotplug_handler); mc->get_hotplug_handler = pc_get_hotplug_handler; mc->hotplug_allowed = pc_hotplug_allowed; From patchwork Thu Feb 8 22:03:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Bernhard Beschow X-Patchwork-Id: 13550517 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 1CD89C4829E for ; Thu, 8 Feb 2024 22:05:13 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rYCV4-0007GR-7E; Thu, 08 Feb 2024 17:04: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 1rYCV2-0007FG-JE for qemu-devel@nongnu.org; Thu, 08 Feb 2024 17:04:04 -0500 Received: from mail-ed1-x530.google.com ([2a00:1450:4864:20::530]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rYCV0-0005Dn-JW for qemu-devel@nongnu.org; Thu, 08 Feb 2024 17:04:04 -0500 Received: by mail-ed1-x530.google.com with SMTP id 4fb4d7f45d1cf-5600c43caddso400373a12.2 for ; Thu, 08 Feb 2024 14:04:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1707429841; x=1708034641; darn=nongnu.org; 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=eDgGO5XlvY/PWkEjL5h/oDmPieaVe3A51Df6gEqV1oQ=; b=ScAJwdCeAlVE2L+bwrdhf8HcQMb9yeOxJdwBORZk3goGnKJTUVFpGkDt/AL8Wj7wpr rFdFioQ3eTSlOXvcd9NkNNrA+oME8clcFoNslnIiTW+vUmHd9csr1QHZSjE4L15oUJz5 rWpsx5KtF3UQZH5p89uqQY0LEOvsmttk3ZKU9TgkBpriLwWlPAeyTK1cJJVqODxbjDY2 DYMcTtieOxfcmj8wPoCKR62pkrmbOVlgyDqpaQraeNvKbHnXwVZaTkWTnBE5JjA1UFGi JOjFPpqIfButUOTMcXBbHvwtIm3p6+EZNu6ADhZQiigRwRR5F8f2kuRsJkO5CdB+RIT6 L3Tw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707429841; x=1708034641; 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=eDgGO5XlvY/PWkEjL5h/oDmPieaVe3A51Df6gEqV1oQ=; b=i8xUTNSudIK518mynQeA6hE2PugAVaxy/TvWaEQmZwCAbIK7LvdG7U3LzGPMhfkZsE V8jvz5DQaiKXJ2x60WQ5Mf2+284oyfnajLazg+nhqfX3omMa5XGlU7wASiXl4fC6ATKV zVsD9yOFmjn5MliUO16qjlLT7nn5p2JlSYTEcqFhxeDGYr7zpkS9MF4pc6E71ezXJYm2 yYvJBWnw6p+3bANWrsxwed2GWbMuimcFLb/yQcJD4+UvgBqOVKZOdlymeqeO3Abm6qLN UURM9+QyQgHQhDc/9aWNXee7mk5sq6O0DVz/EI7y//cxRzazSQ4im3V3CeXJbTKchkr5 NQ9Q== X-Gm-Message-State: AOJu0YyTUdE9MuUH6FK3Hdh/1dEMlITro5IqvdUDgzGo9AsOdfa8JCE3 VLHT/D8NQV4t9tvG3xDxsjCGNPx4FyNKpoyn0m6HhbJD7p9yzsYrm/RJ8ul6 X-Google-Smtp-Source: AGHT+IHI/kdOo0LEDtCo5dRoTOL3XaQbT2rQ9UH+MLCplGSd0WBActaQuqbImjNevZDeZGvMRkg7BQ== X-Received: by 2002:a17:906:80ca:b0:a36:fc15:c6b2 with SMTP id a10-20020a17090680ca00b00a36fc15c6b2mr388409ejx.35.1707429840597; Thu, 08 Feb 2024 14:04:00 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCU+UhKv+HDJlgJRBvuXodrKr9Zj7hyv0/SCgs5gCRA0tWW2D6F0HwkcOcuNXe+OjEVeULHaLQ4NG8tyQLDOY3Gc+ObQP7DEJDS47SQkM53B9NPjbNyfu2B/+31AvGPqcdCd5OUqE22Ix50/+IShHFJ0gCYpeoz0SpH0eT7rtmyvnNuDbbi53YpFy6/7ZbTyIkG+Ss2F+uDfb9dL7pcY1riHlKjwHHz/I1PqoNk1jmBbSJrTwahN Received: from archlinux.. (pd95ed842.dip0.t-ipconnect.de. [217.94.216.66]) by smtp.gmail.com with ESMTPSA id ti9-20020a170907c20900b00a3109a492d4sm109753ejc.20.2024.02.08.14.03.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Feb 2024 14:03:59 -0800 (PST) From: Bernhard Beschow To: qemu-devel@nongnu.org Cc: "Michael S. Tsirkin" , Eduardo Habkost , Paolo Bonzini , Sergio Lopez , Richard Henderson , Marcel Apfelbaum , Bernhard Beschow Subject: [PATCH 4/9] hw/i386/pc: Merge pc_guest_info_init() into pc_machine_initfn() Date: Thu, 8 Feb 2024 23:03:44 +0100 Message-ID: <20240208220349.4948-5-shentey@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240208220349.4948-1-shentey@gmail.com> References: <20240208220349.4948-1-shentey@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::530; envelope-from=shentey@gmail.com; helo=mail-ed1-x530.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, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Resolves redundant code in the piix and q35 machines. Signed-off-by: Bernhard Beschow Reviewed-by: Philippe Mathieu-Daudé --- include/hw/i386/pc.h | 2 -- hw/i386/pc.c | 9 +++------ hw/i386/pc_piix.c | 2 -- hw/i386/pc_q35.c | 2 -- 4 files changed, 3 insertions(+), 12 deletions(-) diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h index ec0e5efcb2..287f1ab553 100644 --- a/include/hw/i386/pc.h +++ b/include/hw/i386/pc.h @@ -151,8 +151,6 @@ extern int fd_bootchk; void pc_acpi_smi_interrupt(void *opaque, int irq, int level); -void pc_guest_info_init(PCMachineState *pcms); - #define PCI_HOST_PROP_RAM_MEM "ram-mem" #define PCI_HOST_PROP_PCI_MEM "pci-mem" #define PCI_HOST_PROP_SYSTEM_MEM "system-mem" diff --git a/hw/i386/pc.c b/hw/i386/pc.c index 12facf73b1..45738d8548 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -706,12 +706,6 @@ void pc_machine_done(Notifier *notifier, void *data) } } -void pc_guest_info_init(PCMachineState *pcms) -{ - pcms->machine_done.notify = pc_machine_done; - qemu_add_machine_init_done_notifier(&pcms->machine_done); -} - /* setup pci memory address space mapping into system address space */ void pc_pci_as_mapping_init(MemoryRegion *system_memory, MemoryRegion *pci_address_space) @@ -1751,6 +1745,9 @@ static void pc_machine_initfn(Object *obj) object_property_add_alias(OBJECT(pcms), "pcspk-audiodev", OBJECT(pcms->pcspk), "audiodev"); cxl_machine_init(obj, &pcms->cxl_devices_state); + + pcms->machine_done.notify = pc_machine_done; + qemu_add_machine_init_done_notifier(&pcms->machine_done); } int pc_machine_kvm_type(MachineState *machine, const char *kvm_type) diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c index adb3b5ed43..4ca2dc08e7 100644 --- a/hw/i386/pc_piix.c +++ b/hw/i386/pc_piix.c @@ -226,8 +226,6 @@ static void pc_init1(MachineState *machine, &error_abort); } - pc_guest_info_init(pcms); - if (pcmc->smbios_defaults) { MachineClass *mc = MACHINE_GET_CLASS(machine); /* These values are guest ABI, do not change */ diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c index 53da8b552d..fe0c2849fd 100644 --- a/hw/i386/pc_q35.c +++ b/hw/i386/pc_q35.c @@ -199,8 +199,6 @@ static void pc_q35_init(MachineState *machine) rom_memory = system_memory; } - pc_guest_info_init(pcms); - if (pcmc->smbios_defaults) { /* These values are guest ABI, do not change */ smbios_set_defaults("QEMU", mc->desc, From patchwork Thu Feb 8 22:03:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Bernhard Beschow X-Patchwork-Id: 13550518 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 174E4C4828F for ; Thu, 8 Feb 2024 22:05:14 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rYCVC-0007IC-71; Thu, 08 Feb 2024 17:04:14 -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 1rYCV9-0007HW-9I for qemu-devel@nongnu.org; Thu, 08 Feb 2024 17:04:11 -0500 Received: from mail-ej1-x62d.google.com ([2a00:1450:4864:20::62d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rYCV2-0005E5-GG for qemu-devel@nongnu.org; Thu, 08 Feb 2024 17:04:11 -0500 Received: by mail-ej1-x62d.google.com with SMTP id a640c23a62f3a-a3a77f27524so33791166b.1 for ; Thu, 08 Feb 2024 14:04:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1707429842; x=1708034642; darn=nongnu.org; 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=J+sbS1QwX/gsxCqYTOaBHcFunWzBKDsUd+myGLHH3IA=; b=kYp7wAR0wxRtq9z97lKL4ccDopjCA0YADnNfYkycILCuJfLigxbXFkK1gE8wNwKH2j 91azF/2yuDhrHmnGZVFnc8w8WYu7AkRUhztFpvr4eqV+U9FqdNv+cZjeAuykpj66ShPo 6mDUcc7Zg62BFMAeKgfN0B/1Fu78HWaiye/Zo87S05gQLm6rrAs9HrGPXdb3U/rL/wQn DOrjbAGzK6liJFhgl5//apWSqJciKVg9ed9aNHfhIIfDJoNnyjAKs6wGndty7wAOwk6D Ujh4c0FN16y49qdB0GpWvjVskSDEqzlKo6GYNJZMJxWXxHCZ4TuceZQcApid16Te9Yf9 ELoQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707429842; x=1708034642; 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=J+sbS1QwX/gsxCqYTOaBHcFunWzBKDsUd+myGLHH3IA=; b=uyztfdF5Y6c61sux1tZFn5d70f4BJovHA9zjVq7soBa8LtnWTNd51MXkZRYSKRtxuf RUVPCe1T/6Mo8BVxK8GDUhH9QEjp5RP8xMaLviNArkmiRMpt+8BL8UbbsLkWVJQIwgib dKRdRqKSvX0cQlkU7Rew/S+9+LIAaxyon3ewPa+f2r0v4PlhWmZ1kLkjft0AVq06N77E cyVbyebxCOQxsq0cdIY63QLc4MCOE9MOJkP1rYRmdVDKsbG7ffJuy2nORuDrgP0clYwi HHFToMFqHZ/5Lhfb8fXchxACLIPJ8i6IMPoBLwXtMJ50Dqvei2+Z27t2NXXEjEexU/gG HDmA== X-Gm-Message-State: AOJu0YwizgYUaD+sHabMkmG1E9CNxBAOKNG/2yvHn1PGzuMCmBXVdJgt +LI2BUSyx5BY+TiFBah3CaXqPmyhdyzAHtuSSw64K0wBckPejxO2uvcY+I6Q X-Google-Smtp-Source: AGHT+IHnLwWssXDQhYvd42Fg3tl3ZBvZmgVvUsGqnnMBpr9jvIhODvlj+038nJGJ4MYvT7+lc1A1DA== X-Received: by 2002:a17:906:bcf4:b0:a38:3f84:1a67 with SMTP id op20-20020a170906bcf400b00a383f841a67mr441121ejb.17.1707429841707; Thu, 08 Feb 2024 14:04:01 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCVu6RsUJhGgSWDiobHrZBqXUU3AoH/zy/nscoI8WVCMDIE0hVzx5Wv9sv+uQNb6bmkH6L++CgUUMo+ikkSdxaUutL9B7CyTnnuLwWcL+vGcJySqbG0Ki8AxNL3A8CyCXWpxu9l3RydCbSZYXeHIVs9PqvOIs74PxNVz9guTMhuDE8/uPm7WbklIShHDGNCcFEv7xnWJheBcui/rhkGIe1o5K+tkmJrMKmqSGV8ef8WtbTtbBOkB Received: from archlinux.. (pd95ed842.dip0.t-ipconnect.de. [217.94.216.66]) by smtp.gmail.com with ESMTPSA id ti9-20020a170907c20900b00a3109a492d4sm109753ejc.20.2024.02.08.14.04.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Feb 2024 14:04:01 -0800 (PST) From: Bernhard Beschow To: qemu-devel@nongnu.org Cc: "Michael S. Tsirkin" , Eduardo Habkost , Paolo Bonzini , Sergio Lopez , Richard Henderson , Marcel Apfelbaum , Bernhard Beschow Subject: [PATCH 5/9] hw/i386/pc: Defer smbios_set_defaults() to machine_done Date: Thu, 8 Feb 2024 23:03:45 +0100 Message-ID: <20240208220349.4948-6-shentey@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240208220349.4948-1-shentey@gmail.com> References: <20240208220349.4948-1-shentey@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::62d; envelope-from=shentey@gmail.com; helo=mail-ej1-x62d.google.com X-Spam_score_int: -2 X-Spam_score: -0.3 X-Spam_bar: / X-Spam_report: (-0.3 / 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, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, TVD_PH_BODY_ACCOUNTS_POST=0.001, TVD_PH_BODY_META_ALL=1.771, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Handling most of smbios data generation in the machine_done notifier is similar to how the ARM virt machine handles it which also calls smbios_set_defaults() there. The result is that all pc machines are freed from explicitly worrying about smbios setup. Signed-off-by: Bernhard Beschow Reviewed-by: Philippe Mathieu-Daudé --- hw/i386/fw_cfg.h | 3 ++- include/hw/i386/pc.h | 1 - hw/i386/fw_cfg.c | 12 +++++++++++- hw/i386/pc.c | 2 +- hw/i386/pc_piix.c | 10 ---------- hw/i386/pc_q35.c | 9 --------- 6 files changed, 14 insertions(+), 23 deletions(-) diff --git a/hw/i386/fw_cfg.h b/hw/i386/fw_cfg.h index 86ca7c1c0c..1e1de6b4a3 100644 --- a/hw/i386/fw_cfg.h +++ b/hw/i386/fw_cfg.h @@ -10,6 +10,7 @@ #define HW_I386_FW_CFG_H #include "hw/boards.h" +#include "hw/i386/pc.h" #include "hw/nvram/fw_cfg.h" #define FW_CFG_IO_BASE 0x510 @@ -22,7 +23,7 @@ FWCfgState *fw_cfg_arch_create(MachineState *ms, uint16_t boot_cpus, uint16_t apic_id_limit); -void fw_cfg_build_smbios(MachineState *ms, FWCfgState *fw_cfg); +void fw_cfg_build_smbios(PCMachineState *ms, FWCfgState *fw_cfg); void fw_cfg_build_feature_control(MachineState *ms, FWCfgState *fw_cfg); void fw_cfg_add_acpi_dsdt(Aml *scope, FWCfgState *fw_cfg); diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h index 287f1ab553..0e6c41e908 100644 --- a/include/hw/i386/pc.h +++ b/include/hw/i386/pc.h @@ -12,7 +12,6 @@ #include "hw/hotplug.h" #include "qom/object.h" #include "hw/i386/sgx-epc.h" -#include "hw/firmware/smbios.h" #include "hw/cxl/cxl.h" #define HPET_INTCAP "hpet-intcap" diff --git a/hw/i386/fw_cfg.c b/hw/i386/fw_cfg.c index 7362daa45a..98a478c276 100644 --- a/hw/i386/fw_cfg.c +++ b/hw/i386/fw_cfg.c @@ -48,15 +48,25 @@ const char *fw_cfg_arch_key_name(uint16_t key) return NULL; } -void fw_cfg_build_smbios(MachineState *ms, FWCfgState *fw_cfg) +void fw_cfg_build_smbios(PCMachineState *pcms, FWCfgState *fw_cfg) { #ifdef CONFIG_SMBIOS uint8_t *smbios_tables, *smbios_anchor; size_t smbios_tables_len, smbios_anchor_len; struct smbios_phys_mem_area *mem_array; unsigned i, array_count; + MachineState *ms = MACHINE(pcms); + PCMachineClass *pcmc = PC_MACHINE_GET_CLASS(pcms); + MachineClass *mc = MACHINE_GET_CLASS(pcms); X86CPU *cpu = X86_CPU(ms->possible_cpus->cpus[0].cpu); + if (pcmc->smbios_defaults) { + /* These values are guest ABI, do not change */ + smbios_set_defaults("QEMU", mc->desc, mc->name, + pcmc->smbios_legacy_mode, pcmc->smbios_uuid_encoded, + pcms->smbios_entry_point_type); + } + /* tell smbios about cpuid version and features */ smbios_set_cpuid(cpu->env.cpuid_version, cpu->env.features[FEAT_1_EDX]); diff --git a/hw/i386/pc.c b/hw/i386/pc.c index 45738d8548..369c21fb99 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -699,7 +699,7 @@ void pc_machine_done(Notifier *notifier, void *data) acpi_setup(); if (x86ms->fw_cfg) { - fw_cfg_build_smbios(MACHINE(pcms), x86ms->fw_cfg); + fw_cfg_build_smbios(pcms, x86ms->fw_cfg); fw_cfg_build_feature_control(MACHINE(pcms), x86ms->fw_cfg); /* update FW_CFG_NB_CPUS to account for -device added CPUs */ fw_cfg_modify_i16(x86ms->fw_cfg, FW_CFG_NB_CPUS, x86ms->boot_cpus); diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c index 4ca2dc08e7..5addaae978 100644 --- a/hw/i386/pc_piix.c +++ b/hw/i386/pc_piix.c @@ -36,7 +36,6 @@ #include "hw/rtc/mc146818rtc.h" #include "hw/southbridge/piix.h" #include "hw/display/ramfb.h" -#include "hw/firmware/smbios.h" #include "hw/pci/pci.h" #include "hw/pci/pci_ids.h" #include "hw/usb.h" @@ -226,15 +225,6 @@ static void pc_init1(MachineState *machine, &error_abort); } - if (pcmc->smbios_defaults) { - MachineClass *mc = MACHINE_GET_CLASS(machine); - /* These values are guest ABI, do not change */ - smbios_set_defaults("QEMU", mc->desc, - mc->name, pcmc->smbios_legacy_mode, - pcmc->smbios_uuid_encoded, - pcms->smbios_entry_point_type); - } - /* allocate ram and load rom/bios */ if (!xen_enabled()) { pc_memory_init(pcms, system_memory, rom_memory, hole64_size); diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c index fe0c2849fd..5184abda92 100644 --- a/hw/i386/pc_q35.c +++ b/hw/i386/pc_q35.c @@ -45,7 +45,6 @@ #include "hw/i386/amd_iommu.h" #include "hw/i386/intel_iommu.h" #include "hw/display/ramfb.h" -#include "hw/firmware/smbios.h" #include "hw/ide/pci.h" #include "hw/ide/ahci.h" #include "hw/intc/ioapic.h" @@ -199,14 +198,6 @@ static void pc_q35_init(MachineState *machine) rom_memory = system_memory; } - if (pcmc->smbios_defaults) { - /* These values are guest ABI, do not change */ - smbios_set_defaults("QEMU", mc->desc, - mc->name, pcmc->smbios_legacy_mode, - pcmc->smbios_uuid_encoded, - pcms->smbios_entry_point_type); - } - /* create pci host bus */ phb = OBJECT(qdev_new(TYPE_Q35_HOST_DEVICE)); From patchwork Thu Feb 8 22:03:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Bernhard Beschow X-Patchwork-Id: 13550526 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 1986FC4828F for ; Thu, 8 Feb 2024 22:06:22 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rYCV7-0007Gx-1G; Thu, 08 Feb 2024 17:04:09 -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 1rYCV5-0007GU-GL for qemu-devel@nongnu.org; Thu, 08 Feb 2024 17:04:07 -0500 Received: from mail-ej1-x633.google.com ([2a00:1450:4864:20::633]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rYCV3-0005EM-Rx for qemu-devel@nongnu.org; Thu, 08 Feb 2024 17:04:07 -0500 Received: by mail-ej1-x633.google.com with SMTP id a640c23a62f3a-a3850ce741bso29487566b.3 for ; Thu, 08 Feb 2024 14:04:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1707429843; x=1708034643; darn=nongnu.org; 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=uLRRI7JaWxueGy30xNOeOTuX8cbsB2oZVyCqXBekoKA=; b=Xuc+RoXJK+A8dKrWK8eZsAQKLc6NhpcAuKl90efpSuN5+B0aP28ARi3oBxHtAODJyQ /kptiWMoOIGvRsYYFF41dDaaS+P8qKRqZTJWgx1YX3xDsLGO+OrXasb15m7QvTh4pbcQ K8tL08YMgajbhMrw+O+NTM6moQHW0B26H2+Wvm01ABkpza+AGyumMT5jFqYwyCGAHsIS 8xmt1y4pjsms5+ncQVLfNpV1BDMjQoVVG/drhCsup/syaP2/+Y9ojDbanNM3Rh6kBon1 xd8IgXSYor4P4N3h01WAJZxJQakBJp4kpSE2DtoJNohnDzeDrk9S+m+cXrWb2qabM41q 2lSA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707429843; x=1708034643; 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=uLRRI7JaWxueGy30xNOeOTuX8cbsB2oZVyCqXBekoKA=; b=cNC4u5+z275BY0Qn6JfEAUeCFion6wSIs30pzHKHbxU6AhOGjAMWGIO1IZWeOy3Fmi Yo+eSObuQxFf5mAk5RuzFVliiJ9a0ca2P+sbKbinVb81udLp+RYumSqT0Grguzfm4hOw 9wX1Et73NGXqUNzzap0d1Lbm7lsxufDiI9+7uYq+sewwCPVFrUZ4wkYLNxBxhHogGO5s ncD41gnhKT1XMWVJ88eLWHpPcDl9ey0dCLNBE3mb6aV7pP+8NVulDIhileVJ+2WikeW4 cO8xvk7eBpWFTiOSbqdFzeAj7X7VlpuTM7+h6Q4O3JMZ4Q2EKJvUZhVl7MjnTq3BzElL HNKg== X-Gm-Message-State: AOJu0YwMqC8UpRP8TaXkeFzPrs3eNXyS+b8gN5cs/df8b34I2cMW/f9b qM7fvYrzT3ZaN9DYzl76g82ja2RbWJwq7JUWIejtLoaa2719ICnzf2LZxOwm X-Google-Smtp-Source: AGHT+IHM7+bDwhtPN8JRaFblhESriQEG63pRAgEs3bcOLucy4h6vswm/KolMmVtpw9eFYkEeX89cHg== X-Received: by 2002:a17:906:240b:b0:a38:174c:c985 with SMTP id z11-20020a170906240b00b00a38174cc985mr393327eja.63.1707429843306; Thu, 08 Feb 2024 14:04:03 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCVpl7cnf1xCI3cTOlfIoD2TzMKJGzsvRabKLL8tBxJD2akCLPyjkk05lDjhMGbdkxLop0Ba4BihCP25/3h5JWb0JxKl26R+gyVb6L4vzBEQ43L7VWkHf26E+Pc4ED+KKD65wiOWJSVOJ3BhRRNjCqPlyt9jL43u0v9K4SGCYEshiVFmiJ+8L8YFBn9UboBJpZ2JgISbe1514AdKTee7UD8vE7w1HSw/D+daZTeSVQaVlDfql5F+ Received: from archlinux.. (pd95ed842.dip0.t-ipconnect.de. [217.94.216.66]) by smtp.gmail.com with ESMTPSA id ti9-20020a170907c20900b00a3109a492d4sm109753ejc.20.2024.02.08.14.04.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Feb 2024 14:04:02 -0800 (PST) From: Bernhard Beschow To: qemu-devel@nongnu.org Cc: "Michael S. Tsirkin" , Eduardo Habkost , Paolo Bonzini , Sergio Lopez , Richard Henderson , Marcel Apfelbaum , Bernhard Beschow Subject: [PATCH 6/9] hw/i386/pc: Confine system flash handling to pc_sysfw Date: Thu, 8 Feb 2024 23:03:46 +0100 Message-ID: <20240208220349.4948-7-shentey@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240208220349.4948-1-shentey@gmail.com> References: <20240208220349.4948-1-shentey@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::633; envelope-from=shentey@gmail.com; helo=mail-ej1-x633.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, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Rather than distributing PC system flash handling across three files, let's confine it to one. Now, pc_system_firmware_init() creates, configures and cleans up the system flash which makes the code easier to understand. It also avoids the extra call to pc_system_flash_cleanup_unused() in the Xen case. Signed-off-by: Bernhard Beschow Reviewed-by: Philippe Mathieu-Daudé --- include/hw/i386/pc.h | 2 -- hw/i386/pc.c | 1 - hw/i386/pc_piix.c | 1 - hw/i386/pc_sysfw.c | 6 ++++-- 4 files changed, 4 insertions(+), 6 deletions(-) diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h index 0e6c41e908..77228822f5 100644 --- a/include/hw/i386/pc.h +++ b/include/hw/i386/pc.h @@ -191,8 +191,6 @@ void pc_i8259_create(ISABus *isa_bus, qemu_irq *i8259_irqs); #define TYPE_PORT92 "port92" /* pc_sysfw.c */ -void pc_system_flash_create(PCMachineState *pcms); -void pc_system_flash_cleanup_unused(PCMachineState *pcms); void pc_system_firmware_init(PCMachineState *pcms, MemoryRegion *rom_memory); bool pc_system_ovmf_table_find(const char *entry, uint8_t **data, int *data_len); diff --git a/hw/i386/pc.c b/hw/i386/pc.c index 369c21fb99..4e73cd8a3b 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -1740,7 +1740,6 @@ static void pc_machine_initfn(Object *obj) #endif pcms->default_bus_bypass_iommu = false; - pc_system_flash_create(pcms); pcms->pcspk = isa_new(TYPE_PC_SPEAKER); object_property_add_alias(OBJECT(pcms), "pcspk-audiodev", OBJECT(pcms->pcspk), "audiodev"); diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c index 5addaae978..5c928ac71b 100644 --- a/hw/i386/pc_piix.c +++ b/hw/i386/pc_piix.c @@ -232,7 +232,6 @@ static void pc_init1(MachineState *machine, assert(machine->ram_size == x86ms->below_4g_mem_size + x86ms->above_4g_mem_size); - pc_system_flash_cleanup_unused(pcms); if (machine->kernel_filename != NULL) { /* For xen HVM direct kernel boot, load linux here */ xen_load_linux(pcms); diff --git a/hw/i386/pc_sysfw.c b/hw/i386/pc_sysfw.c index c8d9e71b88..b4c3833352 100644 --- a/hw/i386/pc_sysfw.c +++ b/hw/i386/pc_sysfw.c @@ -91,7 +91,7 @@ static PFlashCFI01 *pc_pflash_create(PCMachineState *pcms, return PFLASH_CFI01(dev); } -void pc_system_flash_create(PCMachineState *pcms) +static void pc_system_flash_create(PCMachineState *pcms) { PCMachineClass *pcmc = PC_MACHINE_GET_CLASS(pcms); @@ -103,7 +103,7 @@ void pc_system_flash_create(PCMachineState *pcms) } } -void pc_system_flash_cleanup_unused(PCMachineState *pcms) +static void pc_system_flash_cleanup_unused(PCMachineState *pcms) { char *prop_name; int i; @@ -212,6 +212,8 @@ void pc_system_firmware_init(PCMachineState *pcms, return; } + pc_system_flash_create(pcms); + /* Map legacy -drive if=pflash to machine properties */ for (i = 0; i < ARRAY_SIZE(pcms->flash); i++) { pflash_cfi01_legacy_drive(pcms->flash[i], From patchwork Thu Feb 8 22:03:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Bernhard Beschow X-Patchwork-Id: 13550521 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 70813C48BC0 for ; Thu, 8 Feb 2024 22:05:14 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rYCV8-0007HV-US; Thu, 08 Feb 2024 17:04:10 -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 1rYCV6-0007Go-UJ for qemu-devel@nongnu.org; Thu, 08 Feb 2024 17:04:08 -0500 Received: from mail-lf1-x12d.google.com ([2a00:1450:4864:20::12d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rYCV5-0005EU-FN for qemu-devel@nongnu.org; Thu, 08 Feb 2024 17:04:08 -0500 Received: by mail-lf1-x12d.google.com with SMTP id 2adb3069b0e04-5114b2b3b73so404443e87.0 for ; Thu, 08 Feb 2024 14:04:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1707429845; x=1708034645; darn=nongnu.org; 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=0461Lk3WojhtHzTq9fxFfcBVmhnoqCjvYfBQDy5dsCI=; b=FXAquwsJ3XgkXq91/RIf3UnKjlhwcsddOQiOMfjzd4EEbbLh/I+EgwjdwoZghFTWDh tCezqsSSGt5J8ouEWsbfB2oePqNjcJr8DwOHsELllo3gRs4b+HJpHPtR1UDhtMfa+RTX v1R8AWmyhuJ5IvzYTm3wW2LLgrw5n/iaW5Z2ahadZEbCEGY3a4vmF0vAcMWm+HyygR6p g+ro3ON/cgYkpflv2Lg1cUdcpRIlCGHCxApYkrP7PVC110ugGTvlpnviVKdzgkvFtZJw xTUSg9EDIXB70uaSRUWSAcv0yg2Bpzn84RZmyDOSAnsOkwYsvR9+3ZFpo4DK79nKVnMQ MDyQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707429845; x=1708034645; 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=0461Lk3WojhtHzTq9fxFfcBVmhnoqCjvYfBQDy5dsCI=; b=hFM5vW+j04qSyW2Pr12jcz0+laizlqioNhBfyiA/6XLXe9EGnI/zBBZbQluKdx8aKH o+eHSvL1JA/P7qkGjKy+ofCrCGMNTk3XCaZoN1V0K5PeYuvuB5NsTld4pt7M+lELjcFU aeNrZ2u+BGVm+XcOYo0poGI1Y3ZWOJxSn7bwwXhA9R7us+5f4hfj9bPBIL0xitCeIfkr DiQsqJaI7OQOaWNaoMB/ApP6ip7GHsx3C/0Bs6Hs5m90gVV9ck4hbvVqzk1cM9WrC+qV xsOou52xFklTBTnw5jWyKlO/ycUBQRJItGlHjVs97xiQTDx3Zv+AlYm7TvzN9Pi0lLqb gF/Q== X-Gm-Message-State: AOJu0YxnTP9Cd203kvc6cwDGf6YzXtExh/mFDSXRbvOY90DkwZkDUmQ8 83k0mnjvyp0Y1O0IJLGy+tKxpckDSzx9dTlGLIV9ONKwQXrjS/QqJaHJrlzb X-Google-Smtp-Source: AGHT+IHv4/p5e0kYcy3x++Ne20LUzycxLgDY/PGpWo3UfT0MAT/+GS/k6BUCbC4ItPDe4oKXTO2A0g== X-Received: by 2002:a05:6512:2e8:b0:511:5711:4f35 with SMTP id m8-20020a05651202e800b0051157114f35mr380000lfq.23.1707429844818; Thu, 08 Feb 2024 14:04:04 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCVqW8cBDYNfBT+rbvCVUNgttSyKUoX1SVLMdHgBc+tx7zSlvshO5dIOjhN0Ot/nU9eTCHMXrUBBTha8u/90Hxm3fMnwSeACbyIQKn2Lu5tfV7OhQlAIYZBo2PVqugyvJZh7X6wp/YTmWFonzvg+OfzdpWcdWmL65bdiWPQtrldy7OYIrj2XK4mbOXDpBbnIrIHYjanCB8w+cvsxAAr1cYwzmt6GJWsNJ2beFZaNQS2TBewyT2lv Received: from archlinux.. (pd95ed842.dip0.t-ipconnect.de. [217.94.216.66]) by smtp.gmail.com with ESMTPSA id ti9-20020a170907c20900b00a3109a492d4sm109753ejc.20.2024.02.08.14.04.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Feb 2024 14:04:03 -0800 (PST) From: Bernhard Beschow To: qemu-devel@nongnu.org Cc: "Michael S. Tsirkin" , Eduardo Habkost , Paolo Bonzini , Sergio Lopez , Richard Henderson , Marcel Apfelbaum , Bernhard Beschow Subject: [PATCH 7/9] hw/i386/pc_sysfw: Inline pc_system_flash_create() and remove it Date: Thu, 8 Feb 2024 23:03:47 +0100 Message-ID: <20240208220349.4948-8-shentey@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240208220349.4948-1-shentey@gmail.com> References: <20240208220349.4948-1-shentey@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::12d; envelope-from=shentey@gmail.com; helo=mail-lf1-x12d.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, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org pc_system_flash_create() checked for pcmc->pci_enabled which is redundant since its caller already checked it. The method can be turned into just two lines, so inline and remove it. Signed-off-by: Bernhard Beschow Reviewed-by: Philippe Mathieu-Daudé --- hw/i386/pc_sysfw.c | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/hw/i386/pc_sysfw.c b/hw/i386/pc_sysfw.c index b4c3833352..2dcaa116ad 100644 --- a/hw/i386/pc_sysfw.c +++ b/hw/i386/pc_sysfw.c @@ -91,18 +91,6 @@ static PFlashCFI01 *pc_pflash_create(PCMachineState *pcms, return PFLASH_CFI01(dev); } -static void pc_system_flash_create(PCMachineState *pcms) -{ - PCMachineClass *pcmc = PC_MACHINE_GET_CLASS(pcms); - - if (pcmc->pci_enabled) { - pcms->flash[0] = pc_pflash_create(pcms, "system.flash0", - "pflash0"); - pcms->flash[1] = pc_pflash_create(pcms, "system.flash1", - "pflash1"); - } -} - static void pc_system_flash_cleanup_unused(PCMachineState *pcms) { char *prop_name; @@ -212,7 +200,8 @@ void pc_system_firmware_init(PCMachineState *pcms, return; } - pc_system_flash_create(pcms); + pcms->flash[0] = pc_pflash_create(pcms, "system.flash0", "pflash0"); + pcms->flash[1] = pc_pflash_create(pcms, "system.flash1", "pflash1"); /* Map legacy -drive if=pflash to machine properties */ for (i = 0; i < ARRAY_SIZE(pcms->flash); i++) { From patchwork Thu Feb 8 22:03:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bernhard Beschow X-Patchwork-Id: 13550520 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 3971FC48260 for ; Thu, 8 Feb 2024 22:05:14 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rYCV9-0007Hf-Nq; Thu, 08 Feb 2024 17:04:12 -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 1rYCV8-0007HM-GW for qemu-devel@nongnu.org; Thu, 08 Feb 2024 17:04:10 -0500 Received: from mail-ej1-x635.google.com ([2a00:1450:4864:20::635]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rYCV6-0005Ee-PJ for qemu-devel@nongnu.org; Thu, 08 Feb 2024 17:04:10 -0500 Received: by mail-ej1-x635.google.com with SMTP id a640c23a62f3a-a388c5542e9so255320066b.1 for ; Thu, 08 Feb 2024 14:04:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1707429846; x=1708034646; darn=nongnu.org; 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=yU73Jw0joItmcVHy5knFnwYnQ3AC3ly8jcec45Sfb1c=; b=ZW+Pd2vgcDA4JgG+VlALUISHwhYwDtB9BdGtVmjrYMUSeZC7/CycglYVreRJD325x+ Dt857Jv4cw17PytdVYzyIlnEOb6UjmU2mrmeZnmq5q1aQqEOZFpxZKklm4Y8SecyT8DV AY3llVtGgtNzr+4lxF4t57lGSLCYNQ8/LMtKgstElWP+7FP+Joo+1DQ3pe1sxnlYgdwB 3YwZIBHxE32sZo2N2goGntkKBOFyrh38d8BYjpJxSsw7Q8UiZ/yMDFf+6Bys4KzvKDzI 6+E5uL8vg33MbiA6aEOlX7Yw9CZqs1w16irN60FuZCTaGEeHZAyMCa8o+6xAV07BvoEA rBHQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707429846; x=1708034646; 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=yU73Jw0joItmcVHy5knFnwYnQ3AC3ly8jcec45Sfb1c=; b=eljKs9FD48wH44UIiGn6srG3tBsSmgZsxmc8/1eLkZOyU7hN9HIssT6+r5gnEf3T/k s1W6PDfRJF0kE50ne7ruUzH/EHJdqP58EcKPlpb1FC/JfQo8il+ck0HTwz+vPRTrcmve Pd+GSbj2DgjyHbttLE/s7GEaGulK0s7URgX4DPSjkT64zISuw0Go7CVao52uXi+NUL7/ Uy2Evx4cDmvroJNdXFi3anF6v1WwHULiSEp2DR0QyRG/PpDU1dznpTSMc3OOkZ24X2vf BT1etPyjt3Nj2KLetSbE798/OI4C0TN33sEZE9gFF7M6kVasaOeagv/acKzC4J67xUwz UNIg== X-Gm-Message-State: AOJu0Yw+pTOv24FFpfGkGzvCjGPEd4yD9RcdaAjphBRDk4Rz9tF/gTVg 3d8z+u26SLtm6WftW+xAySTYYEs9/2sxxoCIZ+8QHk5BHcfEXY+2ao1vEYPg X-Google-Smtp-Source: AGHT+IHo0vbWe7HrIHopYUHdEHBonRujcqmvjUEZCJcRzSjeMqVuavDYoeGQoTHYoA7gLruQ53F4Jw== X-Received: by 2002:a17:906:4087:b0:a38:2ba9:7f8c with SMTP id u7-20020a170906408700b00a382ba97f8cmr779721ejj.21.1707429846506; Thu, 08 Feb 2024 14:04:06 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCX0nZAQVZPe71j2rG7kcAIQTTKxtE2Q4Tg1y3L9J74KY02zLkWKVmYCu5UguRlY60c6iBt5mZP3b4UxuKkdIZ2djCWfLoqazoHwATcaq2eohUL1k/Dpekwzsn5cPX7f/m22YKYlfnRmw75GzFdp85RxdhxC8jAhSsm3ZnrGvz+QEgzBTU3jXKYJP2OLJC2aIqHo1oPAnrBRyWGxgSOFVTHBWL7AKkm3OseTt7H+0TTU2NyHqu2O Received: from archlinux.. (pd95ed842.dip0.t-ipconnect.de. [217.94.216.66]) by smtp.gmail.com with ESMTPSA id ti9-20020a170907c20900b00a3109a492d4sm109753ejc.20.2024.02.08.14.04.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Feb 2024 14:04:05 -0800 (PST) From: Bernhard Beschow To: qemu-devel@nongnu.org Cc: "Michael S. Tsirkin" , Eduardo Habkost , Paolo Bonzini , Sergio Lopez , Richard Henderson , Marcel Apfelbaum , Bernhard Beschow Subject: [PATCH 8/9] hw/i386/pc: Populate RTC attribute directly Date: Thu, 8 Feb 2024 23:03:48 +0100 Message-ID: <20240208220349.4948-9-shentey@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240208220349.4948-1-shentey@gmail.com> References: <20240208220349.4948-1-shentey@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::635; envelope-from=shentey@gmail.com; helo=mail-ej1-x635.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, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Both the piix and the q35 machines introduce an rtc_state variable and defer the initialization of the X86MachineState::rtc attribute to pc_cmos_init(). Resolve this complication which makes pc_cmos_init() do what it says on the tin. Signed-off-by: Bernhard Beschow --- hw/i386/pc.c | 8 -------- hw/i386/pc_piix.c | 15 +++++++-------- hw/i386/pc_q35.c | 7 +++---- 3 files changed, 10 insertions(+), 20 deletions(-) diff --git a/hw/i386/pc.c b/hw/i386/pc.c index 4e73cd8a3b..ca74c6fbae 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -617,14 +617,6 @@ void pc_cmos_init(PCMachineState *pcms, mc146818rtc_set_cmos_data(s, 0x5c, val >> 8); mc146818rtc_set_cmos_data(s, 0x5d, val >> 16); - object_property_add_link(OBJECT(pcms), "rtc_state", - TYPE_ISA_DEVICE, - (Object **)&x86ms->rtc, - object_property_allow_set_link, - OBJ_PROP_LINK_STRONG); - object_property_set_link(OBJECT(pcms), "rtc_state", OBJECT(s), - &error_abort); - set_boot_dev(s, MACHINE(pcms)->boot_config.order, &error_fatal); val = 0; diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c index 5c928ac71b..adb7926b2e 100644 --- a/hw/i386/pc_piix.c +++ b/hw/i386/pc_piix.c @@ -115,7 +115,6 @@ static void pc_init1(MachineState *machine, qemu_irq smi_irq; GSIState *gsi_state; BusState *idebus[MAX_IDE_BUS]; - ISADevice *rtc_state; MemoryRegion *ram_memory; MemoryRegion *pci_memory = NULL; MemoryRegion *rom_memory = system_memory; @@ -280,8 +279,8 @@ static void pc_init1(MachineState *machine, } isa_bus = ISA_BUS(qdev_get_child_bus(DEVICE(pci_dev), "isa.0")); - rtc_state = ISA_DEVICE(object_resolve_path_component(OBJECT(pci_dev), - "rtc")); + x86ms->rtc = ISA_DEVICE(object_resolve_path_component(OBJECT(pci_dev), + "rtc")); piix4_pm = object_resolve_path_component(OBJECT(pci_dev), "pm"); dev = DEVICE(object_resolve_path_component(OBJECT(pci_dev), "ide")); pci_ide_create_devs(PCI_DEVICE(dev)); @@ -292,9 +291,9 @@ static void pc_init1(MachineState *machine, &error_abort); isa_bus_register_input_irqs(isa_bus, x86ms->gsi); - rtc_state = isa_new(TYPE_MC146818_RTC); - qdev_prop_set_int32(DEVICE(rtc_state), "base_year", 2000); - isa_realize_and_unref(rtc_state, isa_bus, &error_fatal); + x86ms->rtc = isa_new(TYPE_MC146818_RTC); + qdev_prop_set_int32(DEVICE(x86ms->rtc), "base_year", 2000); + isa_realize_and_unref(x86ms->rtc, isa_bus, &error_fatal); i8257_dma_init(isa_bus, 0); pcms->hpet_enabled = false; @@ -322,7 +321,7 @@ static void pc_init1(MachineState *machine, } /* init basic PC hardware */ - pc_basic_device_init(pcms, isa_bus, x86ms->gsi, rtc_state, true, + pc_basic_device_init(pcms, isa_bus, x86ms->gsi, x86ms->rtc, true, 0x4); pc_nic_init(pcmc, isa_bus, pci_bus); @@ -349,7 +348,7 @@ static void pc_init1(MachineState *machine, } #endif - pc_cmos_init(pcms, idebus[0], idebus[1], rtc_state); + pc_cmos_init(pcms, idebus[0], idebus[1], x86ms->rtc); if (piix4_pm) { smi_irq = qemu_allocate_irq(pc_acpi_smi_interrupt, first_cpu, 0); diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c index 5184abda92..d313ba5509 100644 --- a/hw/i386/pc_q35.c +++ b/hw/i386/pc_q35.c @@ -126,7 +126,6 @@ static void pc_q35_init(MachineState *machine) PCIDevice *lpc; DeviceState *lpc_dev; BusState *idebus[MAX_SATA_PORTS]; - ISADevice *rtc_state; MemoryRegion *system_memory = get_system_memory(); MemoryRegion *system_io = get_system_io(); MemoryRegion *pci_memory; @@ -245,7 +244,7 @@ static void pc_q35_init(MachineState *machine) } pci_realize_and_unref(lpc, host_bus, &error_fatal); - rtc_state = ISA_DEVICE(object_resolve_path_component(OBJECT(lpc), "rtc")); + x86ms->rtc = ISA_DEVICE(object_resolve_path_component(OBJECT(lpc), "rtc")); object_property_add_link(OBJECT(machine), PC_MACHINE_ACPI_DEVICE_PROP, TYPE_HOTPLUG_HANDLER, @@ -289,7 +288,7 @@ static void pc_q35_init(MachineState *machine) } /* init basic PC hardware */ - pc_basic_device_init(pcms, isa_bus, x86ms->gsi, rtc_state, !mc->no_floppy, + pc_basic_device_init(pcms, isa_bus, x86ms->gsi, x86ms->rtc, !mc->no_floppy, 0xff0104); if (pcms->sata_enabled) { @@ -325,7 +324,7 @@ static void pc_q35_init(MachineState *machine) smbus_eeprom_init(pcms->smbus, 8, NULL, 0); } - pc_cmos_init(pcms, idebus[0], idebus[1], rtc_state); + pc_cmos_init(pcms, idebus[0], idebus[1], x86ms->rtc); /* the rest devices to which pci devfn is automatically assigned */ pc_vga_init(isa_bus, host_bus); From patchwork Thu Feb 8 22:03:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bernhard Beschow X-Patchwork-Id: 13550522 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id CAE86C48260 for ; Thu, 8 Feb 2024 22:05:39 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rYCVC-0007ID-6q; Thu, 08 Feb 2024 17:04:14 -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 1rYCVA-0007Hk-Dg for qemu-devel@nongnu.org; Thu, 08 Feb 2024 17:04:12 -0500 Received: from mail-ed1-x52b.google.com ([2a00:1450:4864:20::52b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rYCV8-0005Eo-8s for qemu-devel@nongnu.org; Thu, 08 Feb 2024 17:04:11 -0500 Received: by mail-ed1-x52b.google.com with SMTP id 4fb4d7f45d1cf-55f279dca99so609891a12.3 for ; Thu, 08 Feb 2024 14:04:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1707429848; x=1708034648; darn=nongnu.org; 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=Wa855J4F52XiMiTJ4ylFN2d4k/xaiIUVIXYd3X0jIL8=; b=ezPX8Fez9NeuL5oTUnibGsxm1NtdVOIbmtRMoDVG5V/Z1wopldQcfjbHE0WdqzNR1K +rQLz63mLEDxFyu83eHTrb/S0HKYc3oGKe4gcWxt7ZNcJdOdiy8P+JDXwHYX+vCffswO hu9qFrXu+6GDIyupepUT/fsep/15PFt+84D1hGrfB9hsy2wLk48rP71Xr4oD8Kd16a1S O84/JvrDFD5lb3MlPu0IcCRmgIBV/+Ui7WNNqvGExTIu2yJhr8H1gKVtynbmRqFWwtyj rH6bBR1hKOrxJSJJS61nOmy0UJHnACyawyN068rw8MHKpzEk0COhw2x/KxXAH2+XMB3F AaSw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707429848; x=1708034648; 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=Wa855J4F52XiMiTJ4ylFN2d4k/xaiIUVIXYd3X0jIL8=; b=PnjaV8/WdZjE1ataaGpN+W+OKZ+qp0qXyZoEOb540DhVH6UNlIZVMoy31Zyri45hwT F4SAHXqijJoi5EEktn83NZJQyN2lKprsQFQIDfz5lHEm2264FheHeKnNLp+7PHLCWnBl qylMo8URH0vd6yIDSjHyAjMbzgl7D7Yy7xiXMP5ycuUnndGMIbfdzUt34o97jmeVkK0z 1hG6QaBbaUx9+SnDRW9rOHZYQpxQtoXIs5K9NJFBp/Rh51SGnB2gvHRAoVzl8QAbRT3z gUBlnyalIc0YNjUnSi1biCYHWqnJf/e35u8qlbjx7Ft/pr4GOzoUpCc18GR/4iM31XoZ 1teg== X-Gm-Message-State: AOJu0YyB2QR6X88lUSC6AozncjXdQU2+yITNGMpcddD8i6rsnlOizFrS wDSVVcuW7RRifP3t80Ct0wDYfuDQrM6p64mU53nQL9IA6PxCErLV7zWfNcuH X-Google-Smtp-Source: AGHT+IGoPRJysr95h4BEDipVo452uMpheNw7x1rQKpYicu0iTzkcz7OvZjANg+53YDgetJaS65IE6w== X-Received: by 2002:a17:906:1694:b0:a38:9446:106 with SMTP id s20-20020a170906169400b00a3894460106mr420016ejd.51.1707429848010; Thu, 08 Feb 2024 14:04:08 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCWTFcWxTj4X11xfNufesgCfXw0Xt8p0GCak2ARi1q8IYDZpvbI0YdsKArN6Z3aiapM9UZwc4uRMt1tmU+JMuOTb1Uu6bulqlmCFDGtITl9h7259c+5LgZYGTnARmTkWf8fDTMScwCj2JpO53bjhVHgOrb00hqvKAgpRNNird78wFuc8ooQyOg7OW46sFeAnshNjUJnCAhpCsR6oHgCQjR/glHyGX3YjQAcTcfl/Uw7GKBzevPDz Received: from archlinux.. (pd95ed842.dip0.t-ipconnect.de. [217.94.216.66]) by smtp.gmail.com with ESMTPSA id ti9-20020a170907c20900b00a3109a492d4sm109753ejc.20.2024.02.08.14.04.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Feb 2024 14:04:06 -0800 (PST) From: Bernhard Beschow To: qemu-devel@nongnu.org Cc: "Michael S. Tsirkin" , Eduardo Habkost , Paolo Bonzini , Sergio Lopez , Richard Henderson , Marcel Apfelbaum , Bernhard Beschow Subject: [PATCH 9/9] hw/i386/pc_{piix, q35}: Eliminate local pci_bus/pci_host variables Date: Thu, 8 Feb 2024 23:03:49 +0100 Message-ID: <20240208220349.4948-10-shentey@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240208220349.4948-1-shentey@gmail.com> References: <20240208220349.4948-1-shentey@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::52b; envelope-from=shentey@gmail.com; helo=mail-ed1-x52b.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, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org There is no advantage in having these local variables which 1/ needlessly have different identifiers in both machines and 2/ which are redundant to pcms->bus which is almost as short. Signed-off-by: Bernhard Beschow --- hw/i386/pc_piix.c | 14 ++++++-------- hw/i386/pc_q35.c | 16 +++++++--------- 2 files changed, 13 insertions(+), 17 deletions(-) diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c index adb7926b2e..a9f0e255ad 100644 --- a/hw/i386/pc_piix.c +++ b/hw/i386/pc_piix.c @@ -109,7 +109,6 @@ static void pc_init1(MachineState *machine, MemoryRegion *system_memory = get_system_memory(); MemoryRegion *system_io = get_system_io(); Object *phb = NULL; - PCIBus *pci_bus = NULL; ISABus *isa_bus; Object *piix4_pm = NULL; qemu_irq smi_irq; @@ -213,11 +212,10 @@ static void pc_init1(MachineState *machine, &error_fatal); sysbus_realize_and_unref(SYS_BUS_DEVICE(phb), &error_fatal); - pci_bus = PCI_BUS(qdev_get_child_bus(DEVICE(phb), "pci.0")); - pci_bus_map_irqs(pci_bus, + pcms->bus = PCI_BUS(qdev_get_child_bus(DEVICE(phb), "pci.0")); + pci_bus_map_irqs(pcms->bus, xen_enabled() ? xen_pci_slot_get_pirq : pc_pci_slot_get_pirq); - pcms->bus = pci_bus; hole64_size = object_property_get_uint(phb, PCI_HOST_PROP_PCI_HOLE64_SIZE, @@ -262,7 +260,7 @@ static void pc_init1(MachineState *machine, for (i = 0; i < ISA_NUM_IRQS; i++) { qdev_connect_gpio_out_named(dev, "isa-irqs", i, x86ms->gsi[i]); } - pci_realize_and_unref(pci_dev, pci_bus, &error_fatal); + pci_realize_and_unref(pci_dev, pcms->bus, &error_fatal); if (xen_enabled()) { pci_device_set_intx_routing_notifier( @@ -274,7 +272,7 @@ static void pc_init1(MachineState *machine, * connected to the IOAPIC directly. * These additional routes can be discovered through ACPI. */ - pci_bus_irqs(pci_bus, xen_intx_set_irq, pci_dev, + pci_bus_irqs(pcms->bus, xen_intx_set_irq, pci_dev, XEN_IOAPIC_NUM_PIRQS); } @@ -313,7 +311,7 @@ static void pc_init1(MachineState *machine, x86_register_ferr_irq(x86ms->gsi[13]); } - pc_vga_init(isa_bus, pcmc->pci_enabled ? pci_bus : NULL); + pc_vga_init(isa_bus, pcmc->pci_enabled ? pcms->bus : NULL); assert(pcms->vmport != ON_OFF_AUTO__MAX); if (pcms->vmport == ON_OFF_AUTO_AUTO) { @@ -324,7 +322,7 @@ static void pc_init1(MachineState *machine, pc_basic_device_init(pcms, isa_bus, x86ms->gsi, x86ms->rtc, true, 0x4); - pc_nic_init(pcmc, isa_bus, pci_bus); + pc_nic_init(pcmc, isa_bus, pcms->bus); #ifdef CONFIG_IDE_ISA if (!pcmc->pci_enabled) { diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c index d313ba5509..0eef9e6ca1 100644 --- a/hw/i386/pc_q35.c +++ b/hw/i386/pc_q35.c @@ -122,7 +122,6 @@ static void pc_q35_init(MachineState *machine) PCMachineClass *pcmc = PC_MACHINE_GET_CLASS(pcms); X86MachineState *x86ms = X86_MACHINE(machine); Object *phb; - PCIBus *host_bus; PCIDevice *lpc; DeviceState *lpc_dev; BusState *idebus[MAX_SATA_PORTS]; @@ -227,8 +226,7 @@ static void pc_q35_init(MachineState *machine) sysbus_realize_and_unref(SYS_BUS_DEVICE(phb), &error_fatal); /* pci */ - host_bus = PCI_BUS(qdev_get_child_bus(DEVICE(phb), "pcie.0")); - pcms->bus = host_bus; + pcms->bus = PCI_BUS(qdev_get_child_bus(DEVICE(phb), "pcie.0")); /* irq lines */ gsi_state = pc_gsi_create(&x86ms->gsi, pcmc->pci_enabled); @@ -242,7 +240,7 @@ static void pc_q35_init(MachineState *machine) for (i = 0; i < IOAPIC_NUM_PINS; i++) { qdev_connect_gpio_out_named(lpc_dev, ICH9_GPIO_GSI, i, x86ms->gsi[i]); } - pci_realize_and_unref(lpc, host_bus, &error_fatal); + pci_realize_and_unref(lpc, pcms->bus, &error_fatal); x86ms->rtc = ISA_DEVICE(object_resolve_path_component(OBJECT(lpc), "rtc")); @@ -293,7 +291,7 @@ static void pc_q35_init(MachineState *machine) if (pcms->sata_enabled) { /* ahci and SATA device, for q35 1 ahci controller is built-in */ - ahci = pci_create_simple_multifunction(host_bus, + ahci = pci_create_simple_multifunction(pcms->bus, PCI_DEVFN(ICH9_SATA1_DEV, ICH9_SATA1_FUNC), "ich9-ahci"); @@ -308,14 +306,14 @@ static void pc_q35_init(MachineState *machine) if (machine_usb(machine)) { /* Should we create 6 UHCI according to ich9 spec? */ - ehci_create_ich9_with_companions(host_bus, 0x1d); + ehci_create_ich9_with_companions(pcms->bus, 0x1d); } if (pcms->smbus_enabled) { PCIDevice *smb; /* TODO: Populate SPD eeprom data. */ - smb = pci_create_simple_multifunction(host_bus, + smb = pci_create_simple_multifunction(pcms->bus, PCI_DEVFN(ICH9_SMB_DEV, ICH9_SMB_FUNC), TYPE_ICH9_SMB_DEVICE); @@ -327,8 +325,8 @@ static void pc_q35_init(MachineState *machine) pc_cmos_init(pcms, idebus[0], idebus[1], x86ms->rtc); /* the rest devices to which pci devfn is automatically assigned */ - pc_vga_init(isa_bus, host_bus); - pc_nic_init(pcmc, isa_bus, host_bus); + pc_vga_init(isa_bus, pcms->bus); + pc_nic_init(pcmc, isa_bus, pcms->bus); if (machine->nvdimms_state->is_enabled) { nvdimm_init_acpi_state(machine->nvdimms_state, system_io,