From nobody Sun May 19 09:08:42 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1662631201367850.7550134265271; Thu, 8 Sep 2022 03:00:01 -0700 (PDT) Received: from localhost ([::1]:48832 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oWEKF-0007hP-TO for importer@patchew.org; Thu, 08 Sep 2022 05:59:59 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49216) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oWE7I-0005Eg-Ti for qemu-devel@nongnu.org; Thu, 08 Sep 2022 05:46:37 -0400 Received: from mail.loongson.cn ([114.242.206.163]:43708 helo=loongson.cn) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oWE7D-0004yx-JG for qemu-devel@nongnu.org; Thu, 08 Sep 2022 05:46:35 -0400 Received: from localhost.localdomain (unknown [10.2.5.185]) by localhost.localdomain (Coremail) with SMTP id AQAAf8CxYOLwuRljGFYUAA--.17873S3; Thu, 08 Sep 2022 17:46:24 +0800 (CST) From: Xiaojuan Yang To: qemu-devel@nongnu.org Cc: richard.henderson@linaro.org, gaosong@loongson.cn, maobibo@loongson.cn, imammedo@redhat.com Subject: [PATCH v1 1/9] hw/loongarch: Remove vga device when loongarch init Date: Thu, 8 Sep 2022 17:46:15 +0800 Message-Id: <20220908094623.73051-2-yangxiaojuan@loongson.cn> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220908094623.73051-1-yangxiaojuan@loongson.cn> References: <20220908094623.73051-1-yangxiaojuan@loongson.cn> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-CM-TRANSID: AQAAf8CxYOLwuRljGFYUAA--.17873S3 X-Coremail-Antispam: 1UD129KBjvdXoWrKFWkZFyDJw1fuF1kXw13Arb_yoWDtwb_Wa 43Aw48Wr45ua45W3ZFqw1rAw1UAa1IqFn3AFZrtws7Z3W3Wry3JrW2qw13Zr12g3yUZFsx ZrW0vr1Yyr48ujkaLaAFLSUrUUUUUb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUIcSsGvfJ3UbIYCTnIWIevJa73UjIFyTuYvj4RJUUUUUUUU X-CM-SenderInfo: p1dqw5xldry3tdq6z05rqj20fqof0/ Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=114.242.206.163; envelope-from=yangxiaojuan@loongson.cn; helo=loongson.cn X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_PASS=-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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZM-MESSAGEID: 1662631203675100003 Content-Type: text/plain; charset="utf-8" Remove the vga device when loongarch machine init and we will support other display device in the future. Signed-off-by: Xiaojuan Yang Acked-by: Song Gao --- hw/loongarch/Kconfig | 1 - hw/loongarch/virt.c | 3 --- 2 files changed, 4 deletions(-) diff --git a/hw/loongarch/Kconfig b/hw/loongarch/Kconfig index a99aa387c3..73c52b093e 100644 --- a/hw/loongarch/Kconfig +++ b/hw/loongarch/Kconfig @@ -2,7 +2,6 @@ config LOONGARCH_VIRT bool select PCI select PCI_EXPRESS_GENERIC_BRIDGE - imply VGA_PCI imply VIRTIO_VGA imply PCI_DEVICES select ISA_BUS diff --git a/hw/loongarch/virt.c b/hw/loongarch/virt.c index 5cc0b05538..b56820ecda 100644 --- a/hw/loongarch/virt.c +++ b/hw/loongarch/virt.c @@ -378,9 +378,6 @@ static void loongarch_devices_init(DeviceState *pch_pic= , LoongArchMachineState * pci_nic_init_nofail(nd, pci_bus, nd->model, NULL); } =20 - /* VGA setup */ - pci_vga_init(pci_bus); - /* * There are some invalid guest memory access. * Create some unimplemented devices to emulate this. --=20 2.31.1 From nobody Sun May 19 09:08:42 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1662630982438875.1638525926124; Thu, 8 Sep 2022 02:56:22 -0700 (PDT) Received: from localhost ([::1]:51642 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oWEGj-0000vW-GA for importer@patchew.org; Thu, 08 Sep 2022 05:56:21 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49214) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oWE7I-0005Ef-Tp for qemu-devel@nongnu.org; Thu, 08 Sep 2022 05:46:37 -0400 Received: from mail.loongson.cn ([114.242.206.163]:43710 helo=loongson.cn) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oWE7D-0004yv-JG for qemu-devel@nongnu.org; Thu, 08 Sep 2022 05:46:35 -0400 Received: from localhost.localdomain (unknown [10.2.5.185]) by localhost.localdomain (Coremail) with SMTP id AQAAf8CxYOLwuRljGFYUAA--.17873S4; Thu, 08 Sep 2022 17:46:24 +0800 (CST) From: Xiaojuan Yang To: qemu-devel@nongnu.org Cc: richard.henderson@linaro.org, gaosong@loongson.cn, maobibo@loongson.cn, imammedo@redhat.com Subject: [PATCH v1 2/9] hw/loongarch: Support fw_cfg dma function Date: Thu, 8 Sep 2022 17:46:16 +0800 Message-Id: <20220908094623.73051-3-yangxiaojuan@loongson.cn> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220908094623.73051-1-yangxiaojuan@loongson.cn> References: <20220908094623.73051-1-yangxiaojuan@loongson.cn> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-CM-TRANSID: AQAAf8CxYOLwuRljGFYUAA--.17873S4 X-Coremail-Antispam: 1UD129KBjvJXoW7KryUuw17WrW7uFWxtryxKrg_yoW8CrW8pF y7ZFykJr48JrsxtrZaq345W3WxXrs7KrW29a12yw40ka47Xw1UZr1Iy39IyFyUX34kJFyF vFZ5K3y5X3W0qaDanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnUUvcSsGvfC2KfnxnUUI43ZEXa7xR_UUUUUUUUU== X-CM-SenderInfo: p1dqw5xldry3tdq6z05rqj20fqof0/ Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=114.242.206.163; envelope-from=yangxiaojuan@loongson.cn; helo=loongson.cn X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_PASS=-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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZM-MESSAGEID: 1662630984252100003 Content-Type: text/plain; charset="utf-8" Support fw_cfg dma function for LoongArch virt machine. Signed-off-by: Xiaojuan Yang Acked-by: Song Gao --- hw/loongarch/Kconfig | 1 + hw/loongarch/fw_cfg.c | 3 ++- hw/loongarch/virt.c | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/hw/loongarch/Kconfig b/hw/loongarch/Kconfig index 73c52b093e..1deea83626 100644 --- a/hw/loongarch/Kconfig +++ b/hw/loongarch/Kconfig @@ -16,3 +16,4 @@ config LOONGARCH_VIRT select SMBIOS select ACPI_PCI select ACPI_HW_REDUCED + select FW_CFG_DMA diff --git a/hw/loongarch/fw_cfg.c b/hw/loongarch/fw_cfg.c index f6503d5607..f15a17416c 100644 --- a/hw/loongarch/fw_cfg.c +++ b/hw/loongarch/fw_cfg.c @@ -23,7 +23,8 @@ FWCfgState *loongarch_fw_cfg_init(ram_addr_t ram_size, Ma= chineState *ms) int max_cpus =3D ms->smp.max_cpus; int smp_cpus =3D ms->smp.cpus; =20 - fw_cfg =3D fw_cfg_init_mem_wide(VIRT_FWCFG_BASE + 8, VIRT_FWCFG_BASE, = 8, 0, NULL); + fw_cfg =3D fw_cfg_init_mem_wide(VIRT_FWCFG_BASE + 8, VIRT_FWCFG_BASE, = 8, + VIRT_FWCFG_BASE + 16, &address_space_mem= ory); fw_cfg_add_i16(fw_cfg, FW_CFG_MAX_CPUS, (uint16_t)max_cpus); fw_cfg_add_i64(fw_cfg, FW_CFG_RAM_SIZE, (uint64_t)ram_size); fw_cfg_add_i16(fw_cfg, FW_CFG_NB_CPUS, (uint16_t)smp_cpus); diff --git a/hw/loongarch/virt.c b/hw/loongarch/virt.c index b56820ecda..4f833a2044 100644 --- a/hw/loongarch/virt.c +++ b/hw/loongarch/virt.c @@ -118,7 +118,7 @@ static void fdt_add_fw_cfg_node(const LoongArchMachineS= tate *lams) qemu_fdt_setprop_string(ms->fdt, nodename, "compatible", "qemu,fw-cfg-mmio"); qemu_fdt_setprop_sized_cells(ms->fdt, nodename, "reg", - 2, base, 2, 0x8); + 2, base, 2, 0x18); qemu_fdt_setprop(ms->fdt, nodename, "dma-coherent", NULL, 0); g_free(nodename); } --=20 2.31.1 From nobody Sun May 19 09:08:42 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1662631071427672.5865330902716; Thu, 8 Sep 2022 02:57:51 -0700 (PDT) Received: from localhost ([::1]:53158 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oWEI9-0004sA-Bo for importer@patchew.org; Thu, 08 Sep 2022 05:57:49 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58280) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oWE7H-0005EA-QO for qemu-devel@nongnu.org; Thu, 08 Sep 2022 05:46:37 -0400 Received: from mail.loongson.cn ([114.242.206.163]:43702 helo=loongson.cn) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oWE7D-0004yy-J4 for qemu-devel@nongnu.org; Thu, 08 Sep 2022 05:46:35 -0400 Received: from localhost.localdomain (unknown [10.2.5.185]) by localhost.localdomain (Coremail) with SMTP id AQAAf8CxYOLwuRljGFYUAA--.17873S5; Thu, 08 Sep 2022 17:46:24 +0800 (CST) From: Xiaojuan Yang To: qemu-devel@nongnu.org Cc: richard.henderson@linaro.org, gaosong@loongson.cn, maobibo@loongson.cn, imammedo@redhat.com Subject: [PATCH v1 3/9] hw/loongarch: Add interrupt information to FDT table Date: Thu, 8 Sep 2022 17:46:17 +0800 Message-Id: <20220908094623.73051-4-yangxiaojuan@loongson.cn> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220908094623.73051-1-yangxiaojuan@loongson.cn> References: <20220908094623.73051-1-yangxiaojuan@loongson.cn> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-CM-TRANSID: AQAAf8CxYOLwuRljGFYUAA--.17873S5 X-Coremail-Antispam: 1UD129KBjvJXoW7uFy3Ar47uF47KFykArW8JFb_yoW8urWUpF W7Aa90grWxXrn7WFZav345uwsxAr1fAFW2qw1Igr4Sya4DXw17WrWxC34fAF1UW348Xa4Y vF4FqFyxW3WIgF7anT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnUUvcSsGvfC2KfnxnUUI43ZEXa7xR_UUUUUUUUU== X-CM-SenderInfo: p1dqw5xldry3tdq6z05rqj20fqof0/ Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=114.242.206.163; envelope-from=yangxiaojuan@loongson.cn; helo=loongson.cn X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_PASS=-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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZM-MESSAGEID: 1662631072738100001 Content-Type: text/plain; charset="utf-8" Add interrupt information to FDT table, such as interrupt controller info, compatiable info, etc. Signed-off-by: Xiaojuan Yang Acked-by: Song Gao --- hw/loongarch/virt.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/hw/loongarch/virt.c b/hw/loongarch/virt.c index 4f833a2044..561b05d404 100644 --- a/hw/loongarch/virt.c +++ b/hw/loongarch/virt.c @@ -158,6 +158,34 @@ static void fdt_add_pcie_node(const LoongArchMachineSt= ate *lams) qemu_fdt_dumpdtb(ms->fdt, lams->fdt_size); } =20 +static void fdt_add_irqchip_node(LoongArchMachineState *lams) +{ + MachineState *ms =3D MACHINE(lams); + char *nodename; + uint32_t irqchip_phandle; + + irqchip_phandle =3D qemu_fdt_alloc_phandle(ms->fdt); + qemu_fdt_setprop_cell(ms->fdt, "/", "interrupt-parent", irqchip_phandl= e); + + nodename =3D g_strdup_printf("/intc@%" PRIx64, + VIRT_IOAPIC_REG_BASE); + qemu_fdt_add_subnode(ms->fdt, nodename); + qemu_fdt_setprop_cell(ms->fdt, nodename, "#interrupt-cells", 3); + qemu_fdt_setprop(ms->fdt, nodename, "interrupt-controller", NULL, 0); + qemu_fdt_setprop_cell(ms->fdt, nodename, "#address-cells", 0x2); + qemu_fdt_setprop_cell(ms->fdt, nodename, "#size-cells", 0x2); + qemu_fdt_setprop(ms->fdt, nodename, "ranges", NULL, 0); + + qemu_fdt_setprop_string(ms->fdt, nodename, "compatible", + "loongarch,ls7a"); + + qemu_fdt_setprop_sized_cells(ms->fdt, nodename, "reg", + 2, VIRT_IOAPIC_REG_BASE, + 2, PCH_PIC_ROUTE_ENTRY_OFFSET); + + qemu_fdt_setprop_cell(ms->fdt, nodename, "phandle", irqchip_phandle); + g_free(nodename); +} =20 #define PM_BASE 0x10080000 #define PM_SIZE 0x100 @@ -697,6 +725,7 @@ static void loongarch_init(MachineState *machine) } /* Initialize the IO interrupt subsystem */ loongarch_irq_init(lams); + fdt_add_irqchip_node(lams); lams->machine_done.notify =3D virt_machine_done; qemu_add_machine_init_done_notifier(&lams->machine_done); fdt_add_pcie_node(lams); --=20 2.31.1 From nobody Sun May 19 09:08:42 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1662630981838480.6586611258682; Thu, 8 Sep 2022 02:56:21 -0700 (PDT) Received: from localhost ([::1]:51640 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oWEGi-0000tw-Nm for importer@patchew.org; Thu, 08 Sep 2022 05:56:20 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58276) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oWE7F-0005Dt-N4 for qemu-devel@nongnu.org; Thu, 08 Sep 2022 05:46:35 -0400 Received: from mail.loongson.cn ([114.242.206.163]:43704 helo=loongson.cn) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oWE7B-0004z1-Mh for qemu-devel@nongnu.org; Thu, 08 Sep 2022 05:46:32 -0400 Received: from localhost.localdomain (unknown [10.2.5.185]) by localhost.localdomain (Coremail) with SMTP id AQAAf8CxYOLwuRljGFYUAA--.17873S6; Thu, 08 Sep 2022 17:46:24 +0800 (CST) From: Xiaojuan Yang To: qemu-devel@nongnu.org Cc: richard.henderson@linaro.org, gaosong@loongson.cn, maobibo@loongson.cn, imammedo@redhat.com Subject: [PATCH v1 4/9] hw/loongarch: Add platform bus support Date: Thu, 8 Sep 2022 17:46:18 +0800 Message-Id: <20220908094623.73051-5-yangxiaojuan@loongson.cn> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220908094623.73051-1-yangxiaojuan@loongson.cn> References: <20220908094623.73051-1-yangxiaojuan@loongson.cn> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-CM-TRANSID: AQAAf8CxYOLwuRljGFYUAA--.17873S6 X-Coremail-Antispam: 1UD129KBjvJXoWxZrWkZryfXryUCw1fXFykGrg_yoWrAr1fpF WUuF93GF48WF47Gr93Z34fury5Awn7G3y2gF1xArn2kFnrGryUZrykC3yqyFyUJ3ykJa4F qFyvq34xWF4UZrJanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnUUvcSsGvfC2KfnxnUUI43ZEXa7xR_UUUUUUUUU== X-CM-SenderInfo: p1dqw5xldry3tdq6z05rqj20fqof0/ Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=114.242.206.163; envelope-from=yangxiaojuan@loongson.cn; helo=loongson.cn X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_PASS=-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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZM-MESSAGEID: 1662630982312100001 Content-Type: text/plain; charset="utf-8" Add platform bus support and add the bus information such as address, size, irq number to FDT table. Signed-off-by: Xiaojuan Yang Acked-by: Song Gao --- hw/loongarch/Kconfig | 1 + hw/loongarch/virt.c | 33 +++++++++++++++++++++++++++++++++ include/hw/loongarch/virt.h | 1 + include/hw/pci-host/ls7a.h | 5 +++++ 4 files changed, 40 insertions(+) diff --git a/hw/loongarch/Kconfig b/hw/loongarch/Kconfig index 1deea83626..fef55c5638 100644 --- a/hw/loongarch/Kconfig +++ b/hw/loongarch/Kconfig @@ -8,6 +8,7 @@ config LOONGARCH_VIRT select SERIAL select SERIAL_ISA select VIRTIO_PCI + select PLATFORM_BUS select LOONGARCH_IPI select LOONGARCH_PCH_PIC select LOONGARCH_PCH_MSI diff --git a/hw/loongarch/virt.c b/hw/loongarch/virt.c index 561b05d404..3976e8a058 100644 --- a/hw/loongarch/virt.c +++ b/hw/loongarch/virt.c @@ -37,6 +37,8 @@ #include "hw/mem/nvdimm.h" #include "sysemu/device_tree.h" #include +#include "hw/core/sysbus-fdt.h" +#include "hw/platform-bus.h" =20 static void create_fdt(LoongArchMachineState *lams) { @@ -346,6 +348,31 @@ static DeviceState *create_acpi_ged(DeviceState *pch_p= ic, LoongArchMachineState return dev; } =20 +static DeviceState *create_platform_bus(DeviceState *pch_pic) +{ + DeviceState *dev; + SysBusDevice *sysbus; + int i, irq; + MemoryRegion *sysmem =3D get_system_memory(); + + dev =3D qdev_new(TYPE_PLATFORM_BUS_DEVICE); + dev->id =3D g_strdup(TYPE_PLATFORM_BUS_DEVICE); + qdev_prop_set_uint32(dev, "num_irqs", VIRT_PLATFORM_BUS_NUM_IRQS); + qdev_prop_set_uint32(dev, "mmio_size", VIRT_PLATFORM_BUS_SIZE); + sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal); + + sysbus =3D SYS_BUS_DEVICE(dev); + for (i =3D 0; i < VIRT_PLATFORM_BUS_NUM_IRQS; i++) { + irq =3D VIRT_PLATFORM_BUS_IRQ - PCH_PIC_IRQ_OFFSET + i; + sysbus_connect_irq(sysbus, i, qdev_get_gpio_in(pch_pic, irq)); + } + + memory_region_add_subregion(sysmem, + VIRT_PLATFORM_BUS_BASEADDRESS, + sysbus_mmio_get_region(sysbus, 0)); + return dev; +} + static void loongarch_devices_init(DeviceState *pch_pic, LoongArchMachineS= tate *lams) { DeviceState *gpex_dev; @@ -421,6 +448,8 @@ static void loongarch_devices_init(DeviceState *pch_pic= , LoongArchMachineState * memory_region_add_subregion(get_system_memory(), PM_BASE, pm_mem); /* acpi ged */ lams->acpi_ged =3D create_acpi_ged(pch_pic, lams); + /* platform bus */ + lams->platform_bus_dev =3D create_platform_bus(pch_pic); } =20 static void loongarch_irq_init(LoongArchMachineState *lams) @@ -726,6 +755,10 @@ static void loongarch_init(MachineState *machine) /* Initialize the IO interrupt subsystem */ loongarch_irq_init(lams); fdt_add_irqchip_node(lams); + platform_bus_add_all_fdt_nodes(machine->fdt, "/intc", + VIRT_PLATFORM_BUS_BASEADDRESS, + VIRT_PLATFORM_BUS_SIZE, + VIRT_PLATFORM_BUS_IRQ); lams->machine_done.notify =3D virt_machine_done; qemu_add_machine_init_done_notifier(&lams->machine_done); fdt_add_pcie_node(lams); diff --git a/include/hw/loongarch/virt.h b/include/hw/loongarch/virt.h index 92b84de1c5..64c90b80d2 100644 --- a/include/hw/loongarch/virt.h +++ b/include/hw/loongarch/virt.h @@ -49,6 +49,7 @@ struct LoongArchMachineState { char *oem_table_id; DeviceState *acpi_ged; int fdt_size; + DeviceState *platform_bus_dev; }; =20 #define TYPE_LOONGARCH_MACHINE MACHINE_TYPE_NAME("virt") diff --git a/include/hw/pci-host/ls7a.h b/include/hw/pci-host/ls7a.h index cdde0af1f8..9bd875ca8b 100644 --- a/include/hw/pci-host/ls7a.h +++ b/include/hw/pci-host/ls7a.h @@ -42,4 +42,9 @@ #define VIRT_RTC_REG_BASE (VIRT_MISC_REG_BASE + 0x00050100) #define VIRT_RTC_LEN 0x100 #define VIRT_SCI_IRQ (PCH_PIC_IRQ_OFFSET + 4) + +#define VIRT_PLATFORM_BUS_BASEADDRESS 0x16000000 +#define VIRT_PLATFORM_BUS_SIZE 0x2000000 +#define VIRT_PLATFORM_BUS_NUM_IRQS 2 +#define VIRT_PLATFORM_BUS_IRQ 69 #endif --=20 2.31.1 From nobody Sun May 19 09:08:42 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1662631067746499.8409360303831; Thu, 8 Sep 2022 02:57:47 -0700 (PDT) Received: from localhost ([::1]:53154 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oWEI6-0004oI-Fo for importer@patchew.org; Thu, 08 Sep 2022 05:57:46 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58290) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oWE7H-0005EM-JD for qemu-devel@nongnu.org; Thu, 08 Sep 2022 05:46:37 -0400 Received: from mail.loongson.cn ([114.242.206.163]:43698 helo=loongson.cn) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oWE7D-0004yw-JI for qemu-devel@nongnu.org; Thu, 08 Sep 2022 05:46:35 -0400 Received: from localhost.localdomain (unknown [10.2.5.185]) by localhost.localdomain (Coremail) with SMTP id AQAAf8CxYOLwuRljGFYUAA--.17873S7; Thu, 08 Sep 2022 17:46:25 +0800 (CST) From: Xiaojuan Yang To: qemu-devel@nongnu.org Cc: richard.henderson@linaro.org, gaosong@loongson.cn, maobibo@loongson.cn, imammedo@redhat.com Subject: [PATCH v1 5/9] hw/loongarch: Add hotplug handler for machine Date: Thu, 8 Sep 2022 17:46:19 +0800 Message-Id: <20220908094623.73051-6-yangxiaojuan@loongson.cn> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220908094623.73051-1-yangxiaojuan@loongson.cn> References: <20220908094623.73051-1-yangxiaojuan@loongson.cn> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-CM-TRANSID: AQAAf8CxYOLwuRljGFYUAA--.17873S7 X-Coremail-Antispam: 1UD129KBjvJXoW7AFW3JF13GFW5Cw4kuFyfJFb_yoW8tF47pF y7ZFyFyr48WFs2ga9xA3s8WF15Crs3uay2qFs2yrsaka4DWr98Wry8A34qvay8J3yDJF1F qrn5Jay7Wa15Kw7anT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnUUvcSsGvfC2KfnxnUUI43ZEXa7xR_UUUUUUUUU== X-CM-SenderInfo: p1dqw5xldry3tdq6z05rqj20fqof0/ Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=114.242.206.163; envelope-from=yangxiaojuan@loongson.cn; helo=loongson.cn X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_PASS=-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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZM-MESSAGEID: 1662631069015100001 Content-Type: text/plain; charset="utf-8" Add hotplug handler for LoongArch virt machine and now only support the dynamic sysbus device. Signed-off-by: Xiaojuan Yang Acked-by: Song Gao --- hw/loongarch/virt.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/hw/loongarch/virt.c b/hw/loongarch/virt.c index 3976e8a058..a3dd35d579 100644 --- a/hw/loongarch/virt.c +++ b/hw/loongarch/virt.c @@ -804,9 +804,35 @@ static void loongarch_machine_initfn(Object *obj) lams->oem_table_id =3D g_strndup(ACPI_BUILD_APPNAME8, 8); } =20 +static void loongarch_machine_device_plug_cb(HotplugHandler *hotplug_dev, + DeviceState *dev, Error **errp) +{ + LoongArchMachineState *lams =3D LOONGARCH_MACHINE(hotplug_dev); + MachineClass *mc =3D MACHINE_GET_CLASS(lams); + + if (device_is_dynamic_sysbus(mc, dev)) { + if (lams->platform_bus_dev) { + platform_bus_link_device(PLATFORM_BUS_DEVICE(lams->platform_bu= s_dev), + SYS_BUS_DEVICE(dev)); + } + } +} + +static HotplugHandler *virt_machine_get_hotplug_handler(MachineState *mach= ine, + DeviceState *dev) +{ + MachineClass *mc =3D MACHINE_GET_CLASS(machine); + + if (device_is_dynamic_sysbus(mc, dev)) { + return HOTPLUG_HANDLER(machine); + } + return NULL; +} + static void loongarch_class_init(ObjectClass *oc, void *data) { MachineClass *mc =3D MACHINE_CLASS(oc); + HotplugHandlerClass *hc =3D HOTPLUG_HANDLER_CLASS(oc); =20 mc->desc =3D "Loongson-3A5000 LS7A1000 machine"; mc->init =3D loongarch_init; @@ -819,6 +845,8 @@ static void loongarch_class_init(ObjectClass *oc, void = *data) mc->block_default_type =3D IF_VIRTIO; mc->default_boot_order =3D "c"; mc->no_cdrom =3D 1; + mc->get_hotplug_handler =3D virt_machine_get_hotplug_handler; + hc->plug =3D loongarch_machine_device_plug_cb; =20 object_class_property_add(oc, "acpi", "OnOffAuto", loongarch_get_acpi, loongarch_set_acpi, @@ -834,6 +862,10 @@ static const TypeInfo loongarch_machine_types[] =3D { .instance_size =3D sizeof(LoongArchMachineState), .class_init =3D loongarch_class_init, .instance_init =3D loongarch_machine_initfn, + .interfaces =3D (InterfaceInfo[]) { + { TYPE_HOTPLUG_HANDLER }, + { } + }, } }; =20 --=20 2.31.1 From nobody Sun May 19 09:08:42 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1662630686451749.6910974116691; Thu, 8 Sep 2022 02:51:26 -0700 (PDT) Received: from localhost ([::1]:58388 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oWEBx-00086n-GV for importer@patchew.org; Thu, 08 Sep 2022 05:51:25 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58278) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oWE7H-0005E5-Ns for qemu-devel@nongnu.org; Thu, 08 Sep 2022 05:46:37 -0400 Received: from mail.loongson.cn ([114.242.206.163]:43700 helo=loongson.cn) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oWE7B-0004yz-Lz for qemu-devel@nongnu.org; Thu, 08 Sep 2022 05:46:33 -0400 Received: from localhost.localdomain (unknown [10.2.5.185]) by localhost.localdomain (Coremail) with SMTP id AQAAf8CxYOLwuRljGFYUAA--.17873S8; Thu, 08 Sep 2022 17:46:25 +0800 (CST) From: Xiaojuan Yang To: qemu-devel@nongnu.org Cc: richard.henderson@linaro.org, gaosong@loongson.cn, maobibo@loongson.cn, imammedo@redhat.com Subject: [PATCH v1 6/9] hw/loongarch: Add RAMFB to dynamic_sysbus_devices list Date: Thu, 8 Sep 2022 17:46:20 +0800 Message-Id: <20220908094623.73051-7-yangxiaojuan@loongson.cn> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220908094623.73051-1-yangxiaojuan@loongson.cn> References: <20220908094623.73051-1-yangxiaojuan@loongson.cn> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-CM-TRANSID: AQAAf8CxYOLwuRljGFYUAA--.17873S8 X-Coremail-Antispam: 1UD129KBjvdXoW7JFyrtry8ZF13Zw43Zw4ruFg_yoWfArX_uF 13Ar4xurW8A3W0g3W2qa15Jr12k3W7JFs5CFsIgan7Z34UJw15KFW2ywn8Zr12gw4j9r43 Jw40gry5CryagjkaLaAFLSUrUUUUUb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUIcSsGvfJ3UbIYCTnIWIevJa73UjIFyTuYvj4RJUUUUUUUU X-CM-SenderInfo: p1dqw5xldry3tdq6z05rqj20fqof0/ Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=114.242.206.163; envelope-from=yangxiaojuan@loongson.cn; helo=loongson.cn X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_PASS=-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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZM-MESSAGEID: 1662630688988100001 Content-Type: text/plain; charset="utf-8" Add RAMFB device to dynamic_sysbus_devices list so that it can be hotpluged to the machine. Signed-off-by: Xiaojuan Yang Acked-by: Song Gao --- hw/loongarch/virt.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/hw/loongarch/virt.c b/hw/loongarch/virt.c index a3dd35d579..1e1dc699ef 100644 --- a/hw/loongarch/virt.c +++ b/hw/loongarch/virt.c @@ -39,6 +39,7 @@ #include #include "hw/core/sysbus-fdt.h" #include "hw/platform-bus.h" +#include "hw/display/ramfb.h" =20 static void create_fdt(LoongArchMachineState *lams) { @@ -853,6 +854,7 @@ static void loongarch_class_init(ObjectClass *oc, void = *data) NULL, NULL); object_class_property_set_description(oc, "acpi", "Enable ACPI"); + machine_class_allow_dynamic_sysbus_dev(mc, TYPE_RAMFB_DEVICE); } =20 static const TypeInfo loongarch_machine_types[] =3D { --=20 2.31.1 From nobody Sun May 19 09:08:42 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 16626312025846.133414137522664; Thu, 8 Sep 2022 03:00:02 -0700 (PDT) Received: from localhost ([::1]:58946 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oWEKH-0007lh-Bq for importer@patchew.org; Thu, 08 Sep 2022 06:00:01 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58288) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oWE7H-0005EK-Po for qemu-devel@nongnu.org; Thu, 08 Sep 2022 05:46:37 -0400 Received: from mail.loongson.cn ([114.242.206.163]:43714 helo=loongson.cn) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oWE7B-0004z2-Lq for qemu-devel@nongnu.org; Thu, 08 Sep 2022 05:46:33 -0400 Received: from localhost.localdomain (unknown [10.2.5.185]) by localhost.localdomain (Coremail) with SMTP id AQAAf8CxYOLwuRljGFYUAA--.17873S9; Thu, 08 Sep 2022 17:46:25 +0800 (CST) From: Xiaojuan Yang To: qemu-devel@nongnu.org Cc: richard.henderson@linaro.org, gaosong@loongson.cn, maobibo@loongson.cn, imammedo@redhat.com Subject: [PATCH v1 7/9] hw/loongarch: Fix acpi ged irq number in dsdt table Date: Thu, 8 Sep 2022 17:46:21 +0800 Message-Id: <20220908094623.73051-8-yangxiaojuan@loongson.cn> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220908094623.73051-1-yangxiaojuan@loongson.cn> References: <20220908094623.73051-1-yangxiaojuan@loongson.cn> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-CM-TRANSID: AQAAf8CxYOLwuRljGFYUAA--.17873S9 X-Coremail-Antispam: 1UD129KBjvdXoWrKr1fuw4UCry5uF13AF15XFb_yoW3XFcEka s3GFnrG3y8Ja4jvw1Iv34fAr1UX3WIkF1SkF1DX3yDZa1ktw45GFs7twnxZr1aqr4Uu3yf J34Yqrs5Ar1UAjkaLaAFLSUrUUUUUb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUIcSsGvfJ3UbIYCTnIWIevJa73UjIFyTuYvj4RJUUUUUUUU X-CM-SenderInfo: p1dqw5xldry3tdq6z05rqj20fqof0/ Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=114.242.206.163; envelope-from=yangxiaojuan@loongson.cn; helo=loongson.cn X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_PASS=-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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZM-MESSAGEID: 1662631203641100001 Content-Type: text/plain; charset="utf-8" In dsdt, acpi ged irq should use gsi number, and the VIRT_SCI_IRQ means it. Signed-off-by: Xiaojuan Yang Acked-by: Song Gao --- hw/loongarch/acpi-build.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/loongarch/acpi-build.c b/hw/loongarch/acpi-build.c index d0f01a6485..95e30975a8 100644 --- a/hw/loongarch/acpi-build.c +++ b/hw/loongarch/acpi-build.c @@ -367,7 +367,7 @@ build_dsdt(GArray *table_data, BIOSLinker *linker, Mach= ineState *machine) if (lams->acpi_ged) { build_ged_aml(dsdt, "\\_SB."GED_DEVICE, HOTPLUG_HANDLER(lams->acpi_ged), - VIRT_SCI_IRQ - PCH_PIC_IRQ_OFFSET, AML_SYSTEM_MEMORY, + VIRT_SCI_IRQ, AML_SYSTEM_MEMORY, VIRT_GED_EVT_ADDR); } =20 --=20 2.31.1 From nobody Sun May 19 09:08:42 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1662630849768882.3690027034818; Thu, 8 Sep 2022 02:54:09 -0700 (PDT) Received: from localhost ([::1]:54028 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oWEEa-0004sw-Or for importer@patchew.org; Thu, 08 Sep 2022 05:54:08 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58284) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oWE7H-0005EC-Pv for qemu-devel@nongnu.org; Thu, 08 Sep 2022 05:46:37 -0400 Received: from mail.loongson.cn ([114.242.206.163]:43720 helo=loongson.cn) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oWE7B-0004z4-LF for qemu-devel@nongnu.org; Thu, 08 Sep 2022 05:46:34 -0400 Received: from localhost.localdomain (unknown [10.2.5.185]) by localhost.localdomain (Coremail) with SMTP id AQAAf8CxYOLwuRljGFYUAA--.17873S10; Thu, 08 Sep 2022 17:46:25 +0800 (CST) From: Xiaojuan Yang To: qemu-devel@nongnu.org Cc: richard.henderson@linaro.org, gaosong@loongson.cn, maobibo@loongson.cn, imammedo@redhat.com Subject: [PATCH v1 8/9] hw/loongarch: Support memory hotplug Date: Thu, 8 Sep 2022 17:46:22 +0800 Message-Id: <20220908094623.73051-9-yangxiaojuan@loongson.cn> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220908094623.73051-1-yangxiaojuan@loongson.cn> References: <20220908094623.73051-1-yangxiaojuan@loongson.cn> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-CM-TRANSID: AQAAf8CxYOLwuRljGFYUAA--.17873S10 X-Coremail-Antispam: 1UD129KBjvJXoW3JryUCr1Dtr4fWFW5Gw4DArb_yoW3Zr4rpa 1UZF90vr4UWFnxZ3s3tr98WF1rAr4Ika4jqF1IyrWkKFnrWryDAryFk34Yga4UJ34kXF15 u3s8Ja12ga13JrJanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnUUvcSsGvfC2KfnxnUUI43ZEXa7xR_UUUUUUUUU== X-CM-SenderInfo: p1dqw5xldry3tdq6z05rqj20fqof0/ Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=114.242.206.163; envelope-from=yangxiaojuan@loongson.cn; helo=loongson.cn X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_PASS=-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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZM-MESSAGEID: 1662630851608100001 Content-Type: text/plain; charset="utf-8" Add hotplug/unplug interface for memory device. Signed-off-by: Xiaojuan Yang Acked-by: Song Gao --- hw/loongarch/Kconfig | 2 + hw/loongarch/acpi-build.c | 32 +++++++++--- hw/loongarch/virt.c | 105 +++++++++++++++++++++++++++++++++++++- 3 files changed, 132 insertions(+), 7 deletions(-) diff --git a/hw/loongarch/Kconfig b/hw/loongarch/Kconfig index fef55c5638..17d15b6c90 100644 --- a/hw/loongarch/Kconfig +++ b/hw/loongarch/Kconfig @@ -4,6 +4,7 @@ config LOONGARCH_VIRT select PCI_EXPRESS_GENERIC_BRIDGE imply VIRTIO_VGA imply PCI_DEVICES + imply NVDIMM select ISA_BUS select SERIAL select SERIAL_ISA @@ -18,3 +19,4 @@ config LOONGARCH_VIRT select ACPI_PCI select ACPI_HW_REDUCED select FW_CFG_DMA + select DIMM diff --git a/hw/loongarch/acpi-build.c b/hw/loongarch/acpi-build.c index 95e30975a8..92ee62c11a 100644 --- a/hw/loongarch/acpi-build.c +++ b/hw/loongarch/acpi-build.c @@ -186,6 +186,12 @@ build_srat(GArray *table_data, BIOSLinker *linker, Mac= hineState *machine) build_srat_memory(table_data, VIRT_HIGHMEM_BASE, machine->ram_size - V= IRT_LOWMEM_SIZE, 0, MEM_AFFINITY_ENABLED); =20 + if (ms->device_memory) { + build_srat_memory(table_data, ms->device_memory->base, + memory_region_size(&ms->device_memory->mr), + 0, MEM_AFFINITY_HOTPLUGGABLE | MEM_AFFINITY_ENAB= LED); + } + acpi_table_end(linker, &table); } =20 @@ -335,6 +341,25 @@ static void build_uart_device_aml(Aml *table) aml_append(table, scope); } =20 +static void +build_la_ged_aml(Aml *dsdt, MachineState *machine) +{ + uint32_t event; + LoongArchMachineState *lams =3D LOONGARCH_MACHINE(machine); + + build_ged_aml(dsdt, "\\_SB."GED_DEVICE, + HOTPLUG_HANDLER(lams->acpi_ged), + VIRT_SCI_IRQ, AML_SYSTEM_MEMORY, + VIRT_GED_EVT_ADDR); + event =3D object_property_get_uint(OBJECT(lams->acpi_ged), + "ged-event", &error_abort); + if (event & ACPI_GED_MEM_HOTPLUG_EVT) { + build_memory_hotplug_aml(dsdt, machine->ram_slots, "\\_SB", NULL, + AML_SYSTEM_MEMORY, + VIRT_GED_MEM_ADDR); + } +} + /* build DSDT */ static void build_dsdt(GArray *table_data, BIOSLinker *linker, MachineState *machine) @@ -364,12 +389,7 @@ build_dsdt(GArray *table_data, BIOSLinker *linker, Mac= hineState *machine) =20 build_gpex_pci0_int(dsdt); build_uart_device_aml(dsdt); - if (lams->acpi_ged) { - build_ged_aml(dsdt, "\\_SB."GED_DEVICE, - HOTPLUG_HANDLER(lams->acpi_ged), - VIRT_SCI_IRQ, AML_SYSTEM_MEMORY, - VIRT_GED_EVT_ADDR); - } + build_la_ged_aml(dsdt, machine); =20 scope =3D aml_scope("\\_SB.PCI0"); /* Build PCI0._CRS */ diff --git a/hw/loongarch/virt.c b/hw/loongarch/virt.c index 1e1dc699ef..a81db29384 100644 --- a/hw/loongarch/virt.c +++ b/hw/loongarch/virt.c @@ -40,6 +40,7 @@ #include "hw/core/sysbus-fdt.h" #include "hw/platform-bus.h" #include "hw/display/ramfb.h" +#include "hw/mem/pc-dimm.h" =20 static void create_fdt(LoongArchMachineState *lams) { @@ -719,6 +720,35 @@ static void loongarch_init(MachineState *machine) machine->ram, offset, highram_size); memory_region_add_subregion(address_space_mem, 0x90000000, &lams->high= mem); memmap_add_entry(0x90000000, highram_size, 1); + + /* initialize device memory address space */ + if (machine->ram_size < machine->maxram_size) { + machine->device_memory =3D g_malloc0(sizeof(*machine->device_memor= y)); + ram_addr_t device_mem_size =3D machine->maxram_size - machine->ram= _size; + + if (machine->ram_slots > ACPI_MAX_RAM_SLOTS) { + error_report("unsupported amount of memory slots: %"PRIu64, + machine->ram_slots); + exit(EXIT_FAILURE); + } + + if (QEMU_ALIGN_UP(machine->maxram_size, + TARGET_PAGE_SIZE) !=3D machine->maxram_size) { + error_report("maximum memory size must by aligned to multiple = of " + "%d bytes", TARGET_PAGE_SIZE); + exit(EXIT_FAILURE); + } + /* device memory base is the top of high memory address. */ + machine->device_memory->base =3D 0x90000000 + highram_size; + machine->device_memory->base =3D + ROUND_UP(machine->device_memory->base, 1 * GiB); + + memory_region_init(&machine->device_memory->mr, OBJECT(lams), + "device-memory", device_mem_size); + memory_region_add_subregion(address_space_mem, machine->device_mem= ory->base, + &machine->device_memory->mr); + } + /* Add isa io region */ memory_region_init_alias(&lams->isa_io, NULL, "isa-io", get_system_io(), 0, VIRT_ISA_IO_SIZE); @@ -805,6 +835,73 @@ static void loongarch_machine_initfn(Object *obj) lams->oem_table_id =3D g_strndup(ACPI_BUILD_APPNAME8, 8); } =20 +static bool memhp_type_supported(DeviceState *dev) +{ + /* we only support pc dimm now */ + return object_dynamic_cast(OBJECT(dev), TYPE_PC_DIMM) && + !object_dynamic_cast(OBJECT(dev), TYPE_NVDIMM); +} + +static void virt_mem_pre_plug(HotplugHandler *hotplug_dev, DeviceState *de= v, + Error **errp) +{ + pc_dimm_pre_plug(PC_DIMM(dev), MACHINE(hotplug_dev), NULL, errp); +} + +static void virt_machine_device_pre_plug(HotplugHandler *hotplug_dev, + DeviceState *dev, Error **errp) +{ + if (memhp_type_supported(dev)) { + virt_mem_pre_plug(hotplug_dev, dev, errp); + } +} + +static void virt_mem_unplug_request(HotplugHandler *hotplug_dev, + DeviceState *dev, Error **errp) +{ + LoongArchMachineState *lams =3D LOONGARCH_MACHINE(hotplug_dev); + + /* the acpi ged is always exist */ + hotplug_handler_unplug_request(HOTPLUG_HANDLER(lams->acpi_ged), dev, + errp); +} + +static void virt_machine_device_unplug_request(HotplugHandler *hotplug_dev, + DeviceState *dev, Error **errp) +{ + if (memhp_type_supported(dev)) { + virt_mem_unplug_request(hotplug_dev, dev, errp); + } +} + +static void virt_mem_unplug(HotplugHandler *hotplug_dev, + DeviceState *dev, Error **errp) +{ + LoongArchMachineState *lams =3D LOONGARCH_MACHINE(hotplug_dev); + + hotplug_handler_unplug(HOTPLUG_HANDLER(lams->acpi_ged), dev, errp); + pc_dimm_unplug(PC_DIMM(dev), MACHINE(lams)); + qdev_unrealize(dev); +} + +static void virt_machine_device_unplug(HotplugHandler *hotplug_dev, + DeviceState *dev, Error **errp) +{ + if (memhp_type_supported(dev)) { + virt_mem_unplug(hotplug_dev, dev, errp); + } +} + +static void virt_mem_plug(HotplugHandler *hotplug_dev, + DeviceState *dev, Error **errp) +{ + LoongArchMachineState *lams =3D LOONGARCH_MACHINE(hotplug_dev); + + pc_dimm_plug(PC_DIMM(dev), MACHINE(lams)); + hotplug_handler_plug(HOTPLUG_HANDLER(lams->acpi_ged), + dev, &error_abort); +} + static void loongarch_machine_device_plug_cb(HotplugHandler *hotplug_dev, DeviceState *dev, Error **errp) { @@ -816,6 +913,8 @@ static void loongarch_machine_device_plug_cb(HotplugHan= dler *hotplug_dev, platform_bus_link_device(PLATFORM_BUS_DEVICE(lams->platform_bu= s_dev), SYS_BUS_DEVICE(dev)); } + } else if (memhp_type_supported(dev)) { + virt_mem_plug(hotplug_dev, dev, errp); } } =20 @@ -824,7 +923,8 @@ static HotplugHandler *virt_machine_get_hotplug_handler= (MachineState *machine, { MachineClass *mc =3D MACHINE_GET_CLASS(machine); =20 - if (device_is_dynamic_sysbus(mc, dev)) { + if (device_is_dynamic_sysbus(mc, dev) || + memhp_type_supported(dev)) { return HOTPLUG_HANDLER(machine); } return NULL; @@ -848,6 +948,9 @@ static void loongarch_class_init(ObjectClass *oc, void = *data) mc->no_cdrom =3D 1; mc->get_hotplug_handler =3D virt_machine_get_hotplug_handler; hc->plug =3D loongarch_machine_device_plug_cb; + hc->pre_plug =3D virt_machine_device_pre_plug; + hc->unplug_request =3D virt_machine_device_unplug_request; + hc->unplug =3D virt_machine_device_unplug; =20 object_class_property_add(oc, "acpi", "OnOffAuto", loongarch_get_acpi, loongarch_set_acpi, --=20 2.31.1 From nobody Sun May 19 09:08:42 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1662630977301983.3981779704048; Thu, 8 Sep 2022 02:56:17 -0700 (PDT) Received: from localhost ([::1]:54400 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oWEGe-0000ej-93 for importer@patchew.org; Thu, 08 Sep 2022 05:56:16 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58286) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oWE7H-0005EE-JR for qemu-devel@nongnu.org; Thu, 08 Sep 2022 05:46:37 -0400 Received: from mail.loongson.cn ([114.242.206.163]:43740 helo=loongson.cn) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oWE7D-0004zD-J3 for qemu-devel@nongnu.org; Thu, 08 Sep 2022 05:46:34 -0400 Received: from localhost.localdomain (unknown [10.2.5.185]) by localhost.localdomain (Coremail) with SMTP id AQAAf8CxYOLwuRljGFYUAA--.17873S11; Thu, 08 Sep 2022 17:46:25 +0800 (CST) From: Xiaojuan Yang To: qemu-devel@nongnu.org Cc: richard.henderson@linaro.org, gaosong@loongson.cn, maobibo@loongson.cn, imammedo@redhat.com Subject: [PATCH v1 9/9] hw/loongarch: Improve acpi dsdt table Date: Thu, 8 Sep 2022 17:46:23 +0800 Message-Id: <20220908094623.73051-10-yangxiaojuan@loongson.cn> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220908094623.73051-1-yangxiaojuan@loongson.cn> References: <20220908094623.73051-1-yangxiaojuan@loongson.cn> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-CM-TRANSID: AQAAf8CxYOLwuRljGFYUAA--.17873S11 X-Coremail-Antispam: 1UD129KBjvJXoW3ArW3tF4UuFW3Gr4rZFy7Jrb_yoW3AFWxp3 ya9FWYvr15GrnFq3yfA3W5WF1UArn7G34qqasxArs2kFZFkr10qry8C393WF1Yy3s3tFWU XrZY934UCw4kJr7anT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnUUvcSsGvfC2KfnxnUUI43ZEXa7xR_UUUUUUUUU== X-CM-SenderInfo: p1dqw5xldry3tdq6z05rqj20fqof0/ Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=114.242.206.163; envelope-from=yangxiaojuan@loongson.cn; helo=loongson.cn X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_PASS=-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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZM-MESSAGEID: 1662630979081100001 Content-Type: text/plain; charset="utf-8" Cleanup the previous pci information in acpi dsdt table. And using the common acpi_dsdt_add_gpex function to build the gpex and pci information. Signed-off-by: Xiaojuan Yang Acked-by: Song Gao --- hw/loongarch/acpi-build.c | 159 +++++------------------------------- hw/loongarch/virt.c | 1 + include/hw/loongarch/virt.h | 1 + 3 files changed, 21 insertions(+), 140 deletions(-) diff --git a/hw/loongarch/acpi-build.c b/hw/loongarch/acpi-build.c index 92ee62c11a..378a6d9d38 100644 --- a/hw/loongarch/acpi-build.c +++ b/hw/loongarch/acpi-build.c @@ -30,6 +30,7 @@ #include "qom/qom-qobject.h" =20 #include "hw/acpi/generic_event_device.h" +#include "hw/pci-host/gpex.h" =20 #define ACPI_BUILD_ALIGN_SIZE 0x1000 #define ACPI_BUILD_TABLE_SIZE 0x20000 @@ -206,108 +207,6 @@ struct AcpiBuildState { MemoryRegion *linker_mr; } AcpiBuildState; =20 -static void build_gpex_pci0_int(Aml *table) -{ - Aml *sb_scope =3D aml_scope("_SB"); - Aml *pci0_scope =3D aml_scope("PCI0"); - Aml *prt_pkg =3D aml_varpackage(128); - int slot, pin; - - for (slot =3D 0; slot < PCI_SLOT_MAX; slot++) { - for (pin =3D 0; pin < PCI_NUM_PINS; pin++) { - Aml *pkg =3D aml_package(4); - aml_append(pkg, aml_int((slot << 16) | 0xFFFF)); - aml_append(pkg, aml_int(pin)); - aml_append(pkg, aml_int(0)); - aml_append(pkg, aml_int(80 + (slot + pin) % 4)); - aml_append(prt_pkg, pkg); - } - } - aml_append(pci0_scope, aml_name_decl("_PRT", prt_pkg)); - aml_append(sb_scope, pci0_scope); - aml_append(table, sb_scope); -} - -static void build_dbg_aml(Aml *table) -{ - Aml *field; - Aml *method; - Aml *while_ctx; - Aml *scope =3D aml_scope("\\"); - Aml *buf =3D aml_local(0); - Aml *len =3D aml_local(1); - Aml *idx =3D aml_local(2); - - aml_append(scope, - aml_operation_region("DBG", AML_SYSTEM_IO, aml_int(0x0402), 0x01)); - field =3D aml_field("DBG", AML_BYTE_ACC, AML_NOLOCK, AML_PRESERVE); - aml_append(field, aml_named_field("DBGB", 8)); - aml_append(scope, field); - - method =3D aml_method("DBUG", 1, AML_NOTSERIALIZED); - - aml_append(method, aml_to_hexstring(aml_arg(0), buf)); - aml_append(method, aml_to_buffer(buf, buf)); - aml_append(method, aml_subtract(aml_sizeof(buf), aml_int(1), len)); - aml_append(method, aml_store(aml_int(0), idx)); - - while_ctx =3D aml_while(aml_lless(idx, len)); - aml_append(while_ctx, - aml_store(aml_derefof(aml_index(buf, idx)), aml_name("DBGB"))); - aml_append(while_ctx, aml_increment(idx)); - aml_append(method, while_ctx); - aml_append(method, aml_store(aml_int(0x0A), aml_name("DBGB"))); - aml_append(scope, method); - aml_append(table, scope); -} - -static Aml *build_osc_method(void) -{ - Aml *if_ctx; - Aml *if_ctx2; - Aml *else_ctx; - Aml *method; - Aml *a_cwd1 =3D aml_name("CDW1"); - Aml *a_ctrl =3D aml_local(0); - - method =3D aml_method("_OSC", 4, AML_NOTSERIALIZED); - aml_append(method, aml_create_dword_field(aml_arg(3), aml_int(0), "CDW= 1")); - - if_ctx =3D aml_if(aml_equal( - aml_arg(0), aml_touuid("33DB4D5B-1FF7-401C-9657-7441C03DD766"))); - aml_append(if_ctx, aml_create_dword_field(aml_arg(3), aml_int(4), "CDW= 2")); - aml_append(if_ctx, aml_create_dword_field(aml_arg(3), aml_int(8), "CDW= 3")); - aml_append(if_ctx, aml_store(aml_name("CDW3"), a_ctrl)); - - /* - * Always allow native PME, AER (no dependencies) - * Allow SHPC (PCI bridges can have SHPC controller) - */ - aml_append(if_ctx, aml_and(a_ctrl, aml_int(0x1F), a_ctrl)); - - if_ctx2 =3D aml_if(aml_lnot(aml_equal(aml_arg(1), aml_int(1)))); - /* Unknown revision */ - aml_append(if_ctx2, aml_or(a_cwd1, aml_int(0x08), a_cwd1)); - aml_append(if_ctx, if_ctx2); - - if_ctx2 =3D aml_if(aml_lnot(aml_equal(aml_name("CDW3"), a_ctrl))); - /* Capabilities bits were masked */ - aml_append(if_ctx2, aml_or(a_cwd1, aml_int(0x10), a_cwd1)); - aml_append(if_ctx, if_ctx2); - - /* Update DWORD3 in the buffer */ - aml_append(if_ctx, aml_store(a_ctrl, aml_name("CDW3"))); - aml_append(method, if_ctx); - - else_ctx =3D aml_else(); - /* Unrecognized UUID */ - aml_append(else_ctx, aml_or(a_cwd1, aml_int(4), a_cwd1)); - aml_append(method, else_ctx); - - aml_append(method, aml_return(aml_arg(3))); - return method; -} - static void build_uart_device_aml(Aml *table) { Aml *dev; @@ -360,57 +259,37 @@ build_la_ged_aml(Aml *dsdt, MachineState *machine) } } =20 +static void build_pci_device_aml(Aml *scope, LoongArchMachineState *lams) +{ + struct GPEXConfig cfg =3D { + .mmio64.base =3D VIRT_PCI_MEM_BASE, + .mmio64.size =3D VIRT_PCI_MEM_SIZE, + .pio.base =3D VIRT_PCI_IO_BASE, + .pio.size =3D VIRT_PCI_IO_SIZE, + .ecam.base =3D VIRT_PCI_CFG_BASE, + .ecam.size =3D VIRT_PCI_CFG_SIZE, + .irq =3D PCH_PIC_IRQ_OFFSET + VIRT_DEVICE_IRQS, + .bus =3D lams->pci_bus, + }; + + acpi_dsdt_add_gpex(scope, &cfg); +} + /* build DSDT */ static void build_dsdt(GArray *table_data, BIOSLinker *linker, MachineState *machine) { - Aml *dsdt, *sb_scope, *scope, *dev, *crs, *pkg; - int root_bus_limit =3D 0x7F; + Aml *dsdt, *scope, *pkg; LoongArchMachineState *lams =3D LOONGARCH_MACHINE(machine); AcpiTable table =3D { .sig =3D "DSDT", .rev =3D 1, .oem_id =3D lams->o= em_id, .oem_table_id =3D lams->oem_table_id }; =20 acpi_table_begin(&table, table_data); - dsdt =3D init_aml_allocator(); - - build_dbg_aml(dsdt); - - sb_scope =3D aml_scope("_SB"); - dev =3D aml_device("PCI0"); - aml_append(dev, aml_name_decl("_HID", aml_eisaid("PNP0A08"))); - aml_append(dev, aml_name_decl("_CID", aml_eisaid("PNP0A03"))); - aml_append(dev, aml_name_decl("_ADR", aml_int(0))); - aml_append(dev, aml_name_decl("_BBN", aml_int(0))); - aml_append(dev, aml_name_decl("_UID", aml_int(1))); - aml_append(dev, build_osc_method()); - aml_append(sb_scope, dev); - aml_append(dsdt, sb_scope); - - build_gpex_pci0_int(dsdt); build_uart_device_aml(dsdt); + build_pci_device_aml(dsdt, lams); build_la_ged_aml(dsdt, machine); =20 - scope =3D aml_scope("\\_SB.PCI0"); - /* Build PCI0._CRS */ - crs =3D aml_resource_template(); - aml_append(crs, - aml_word_bus_number(AML_MIN_FIXED, AML_MAX_FIXED, AML_POS_DECODE, - 0x0000, 0x0, root_bus_limit, - 0x0000, root_bus_limit + 1)); - aml_append(crs, - aml_dword_io(AML_MIN_FIXED, AML_MAX_FIXED, - AML_POS_DECODE, AML_ENTIRE_RANGE, - 0x0000, 0x0000, 0xFFFF, 0x18000000, 0x10000)); - aml_append(crs, - aml_dword_memory(AML_POS_DECODE, AML_MIN_FIXED, AML_MAX_FIXED, - AML_CACHEABLE, AML_READ_WRITE, - 0, VIRT_PCI_MEM_BASE, - VIRT_PCI_MEM_BASE + VIRT_PCI_MEM_SIZE - 1, - 0, VIRT_PCI_MEM_BASE)); - aml_append(scope, aml_name_decl("_CRS", crs)); - aml_append(dsdt, scope); - /* System State Package */ scope =3D aml_scope("\\"); pkg =3D aml_package(4); diff --git a/hw/loongarch/virt.c b/hw/loongarch/virt.c index a81db29384..e90f9fccf3 100644 --- a/hw/loongarch/virt.c +++ b/hw/loongarch/virt.c @@ -388,6 +388,7 @@ static void loongarch_devices_init(DeviceState *pch_pic= , LoongArchMachineState * d =3D SYS_BUS_DEVICE(gpex_dev); sysbus_realize_and_unref(d, &error_fatal); pci_bus =3D PCI_HOST_BRIDGE(gpex_dev)->bus; + lams->pci_bus =3D pci_bus; =20 /* Map only part size_ecam bytes of ECAM space */ ecam_alias =3D g_new0(MemoryRegion, 1); diff --git a/include/hw/loongarch/virt.h b/include/hw/loongarch/virt.h index 64c90b80d2..09f1c88ee5 100644 --- a/include/hw/loongarch/virt.h +++ b/include/hw/loongarch/virt.h @@ -50,6 +50,7 @@ struct LoongArchMachineState { DeviceState *acpi_ged; int fdt_size; DeviceState *platform_bus_dev; + PCIBus *pci_bus; }; =20 #define TYPE_LOONGARCH_MACHINE MACHINE_TYPE_NAME("virt") --=20 2.31.1