From mboxrd@z Thu Jan 1 00:00:00 1970 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 4A97EFED2EE for ; Thu, 12 Mar 2026 08:27:07 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1w0bNc-0001S5-5J; Thu, 12 Mar 2026 04:26:52 -0400 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 1w0bNZ-0001RD-F9 for qemu-devel@nongnu.org; Thu, 12 Mar 2026 04:26:49 -0400 Received: from mail.loongson.cn ([114.242.206.163]) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1w0bNW-000142-Eo for qemu-devel@nongnu.org; Thu, 12 Mar 2026 04:26:49 -0400 Received: from loongson.cn (unknown [10.20.42.126]) by gateway (Coremail) with SMTP id _____8DxAfG_eLJp0EIaAA--.11536S3; Thu, 12 Mar 2026 16:26:40 +0800 (CST) Received: from [10.20.42.126] (unknown [10.20.42.126]) by front1 (Coremail) with SMTP id qMiowJDxaeC6eLJpXLtTAA--.29547S3; Thu, 12 Mar 2026 16:26:36 +0800 (CST) Subject: Re: [PATCH V2] hw/loongarch: add rtc acpi table To: gaosong , qemu-devel@nongnu.org Cc: Bibo Mao , Jiaxun Yang References: <20260312021350.1052791-1-lixianglai@loongson.cn> From: lixianglai Message-ID: <097005eb-f027-a57a-bb36-c025e519c7f6@loongson.cn> Date: Thu, 12 Mar 2026 16:19:18 +0800 User-Agent: Mozilla/5.0 (X11; Linux loongarch64; rv:68.0) Gecko/20100101 Thunderbird/68.7.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US X-CM-TRANSID: qMiowJDxaeC6eLJpXLtTAA--.29547S3 X-CM-SenderInfo: 5ol0xt5qjotxo6or00hjvr0hdfq/ X-Coremail-Antispam: 1Uk129KBj93XoW3Xr1fKry7GryxurWDJr4UZFc_yoW7Aw4rpr s7CryUtryUXrn3Jw17JryUWFy5Ar1UJ3Wqqr1xXF18GrWDGr1jqr1UWryqgF1UAw48JF1j qF1jqr9xuF1UJrcCm3ZEXasCq-sJn29KB7ZKAUJUUUU8529EdanIXcx71UUUUU7KY7ZEXa sCq-sGcSsGvfJ3Ic02F40EFcxC0VAKzVAqx4xG6I80ebIjqfuFe4nvWSU5nxnvy29KBjDU 0xBIdaVrnRJUUUv2b4IE77IF4wAFF20E14v26r1j6r4UM7CY07I20VC2zVCF04k26cxKx2 IYs7xG6rWj6s0DM7CIcVAFz4kK6r106r15M28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48v e4kI8wA2z4x0Y4vE2Ix0cI8IcVAFwI0_Jr0_JF4l84ACjcxK6xIIjxv20xvEc7CjxVAFwI 0_Gr0_Cr1l84ACjcxK6I8E87Iv67AKxVW8Jr0_Cr1UM28EF7xvwVC2z280aVCY1x0267AK xVW8Jr0_Cr1UM2AIxVAIcxkEcVAq07x20xvEncxIr21l57IF6xkI12xvs2x26I8E6xACxx 1l5I8CrVACY4xI64kE6c02F40Ex7xfMcIj6xIIjxv20xvE14v26r106r15McIj6I8E87Iv 67AKxVWUJVW8JwAm72CE4IkC6x0Yz7v_Jr0_Gr1lF7xvr2IY64vIr41lc7I2V7IY0VAS07 AlzVAYIcxG8wCF04k20xvY0x0EwIxGrwCFx2IqxVCFs4IE7xkEbVWUJVW8JwC20s026c02 F40E14v26r1j6r18MI8I3I0E7480Y4vE14v26r106r1rMI8E67AF67kF1VAFwI0_JF0_Jw 1lIxkGc2Ij64vIr41lIxAIcVC0I7IYx2IY67AKxVWUJVWUCwCI42IY6xIIjxv20xvEc7Cj xVAFwI0_Jr0_Gr1lIxAIcVCF04k26cxKx2IYs7xG6r1j6r1xMIIF0xvEx4A2jsIE14v26r 1j6r4UMIIF0xvEx4A2jsIEc7CjxVAFwI0_Jr0_GrUvcSsGvfC2KfnxnUUI43ZEXa7IU1Ek sDUUUUU== Received-SPF: pass client-ip=114.242.206.163; envelope-from=lixianglai@loongson.cn; helo=mail.loongson.cn X-Spam_score_int: -22 X-Spam_score: -2.3 X-Spam_bar: -- X-Spam_report: (-2.3 / 5.0 requ) BAYES_00=-1.9, NICE_REPLY_A=-2.101, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.819, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.903, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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: qemu development 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 Hi gaosong: > 在 2026/3/12 上午10:13, Xianglai Li 写道: >> Add the acpi table to the loongson rtc hardware so that the virtual >> machine >> kernel can use the loongson RTC-related drivers. >> >> Delete the interrupt information in the rtc fdt table. >> >> Signed-off-by: Xianglai Li >> --- >> Cc: Song Gao >> Cc: Bibo Mao >> Cc: Jiaxun Yang >> >> change: >> V1->V2: >> 1.Add a comment to explain why the acpi table no longer provides >> interrupt numbers >> 2.Delete the interrupt number from the rtc fdt table > > It would be better to move point 2 to the new patch. > Ok!!! > Thanks. > Song Gao > >>   hw/loongarch/virt-acpi-build.c | 25 +++++++++++++++++++++++++ >>   hw/loongarch/virt-fdt-build.c  | 16 ++++++++-------- >>   2 files changed, 33 insertions(+), 8 deletions(-) >> >> diff --git a/hw/loongarch/virt-acpi-build.c >> b/hw/loongarch/virt-acpi-build.c >> index 3e34bedcd6..42820001d7 100644 >> --- a/hw/loongarch/virt-acpi-build.c >> +++ b/hw/loongarch/virt-acpi-build.c >> @@ -460,6 +460,30 @@ static void acpi_dsdt_add_tpm(Aml *scope, >> LoongArchVirtMachineState *vms) >>   } >>   #endif >>   +static void acpi_dsdt_add_rtc(Aml *scope) >> +{ >> +    Aml *dev = aml_device("RTC"); >> + >> +    aml_append(dev, aml_name_decl("_HID", aml_string("LOON0001"))); >> +    aml_append(dev, aml_name_decl("_UID", aml_int(0))); >> + >> +    Aml *crs = aml_resource_template(); >> +    aml_append(crs, >> +        aml_qword_memory(AML_POS_DECODE, AML_MIN_FIXED, AML_MAX_FIXED, >> +                         AML_NON_CACHEABLE, AML_READ_WRITE, >> +                         0, VIRT_RTC_REG_BASE, >> +                         VIRT_RTC_REG_BASE + VIRT_RTC_LEN - 1, >> +                         0, VIRT_RTC_LEN)); >> +    /* >> +     * The virtual machine model does not support suspend and wake-up, >> +     * and rtc is no longer the wake-up source. Therefore, the current >> +     * rtc table no longer provides the rtc alarm interrupt number to >> +     * avoid the software initializing alarm. >> +     */ >> +    aml_append(dev, aml_name_decl("_CRS", crs)); >> +    aml_append(scope, dev); >> +} >> + >>   /* build DSDT */ >>   static void >>   build_dsdt(GArray *table_data, BIOSLinker *linker, MachineState >> *machine) >> @@ -475,6 +499,7 @@ build_dsdt(GArray *table_data, BIOSLinker >> *linker, MachineState *machine) >>       for (i = 0; i < VIRT_UART_COUNT; i++) { >>           build_uart_device_aml(dsdt, i); >>       } >> +    acpi_dsdt_add_rtc(dsdt); >>       build_pci_device_aml(dsdt, lvms); >>       build_la_ged_aml(dsdt, machine); >>       build_flash_aml(dsdt, lvms); >> diff --git a/hw/loongarch/virt-fdt-build.c >> b/hw/loongarch/virt-fdt-build.c >> index 6c06b36fca..42f014a7bd 100644 >> --- a/hw/loongarch/virt-fdt-build.c >> +++ b/hw/loongarch/virt-fdt-build.c >> @@ -458,8 +458,7 @@ static void >> fdt_add_uart_node(LoongArchVirtMachineState *lvms, >>       g_free(nodename); >>   } >>   -static void fdt_add_rtc_node(LoongArchVirtMachineState *lvms, >> -                             uint32_t *pch_pic_phandle) >> +static void fdt_add_rtc_node(LoongArchVirtMachineState *lvms) >>   { >>       char *nodename; >>       hwaddr base = VIRT_RTC_REG_BASE; >> @@ -470,12 +469,13 @@ static void >> fdt_add_rtc_node(LoongArchVirtMachineState *lvms, >>       qemu_fdt_add_subnode(ms->fdt, nodename); >>       qemu_fdt_setprop_string(ms->fdt, nodename, "compatible", >>                               "loongson,ls7a-rtc"); >> +    /* >> +     * The virtual machine model does not support suspend and wake-up, >> +     * and rtc is no longer the wake-up source. Therefore, the current >> +     * rtc table no longer provides the rtc alarm interrupt number to >> +     * avoid the software initializing alarm. >> +     */ >>       qemu_fdt_setprop_sized_cells(ms->fdt, nodename, "reg", 2, base, >> 2, size); >> -    qemu_fdt_setprop_cells(ms->fdt, nodename, "interrupts", >> -                           VIRT_RTC_IRQ - VIRT_GSI_BASE , >> -                           FDT_IRQ_TYPE_LEVEL_HIGH); >> -    qemu_fdt_setprop_cell(ms->fdt, nodename, "interrupt-parent", >> -                          *pch_pic_phandle); >>       g_free(nodename); >>   } >>   @@ -550,7 +550,7 @@ void virt_fdt_setup(LoongArchVirtMachineState >> *lvms) >>           fdt_add_uart_node(lvms, &pch_pic_phandle, base, irq, i == 0); >>       } >>   -    fdt_add_rtc_node(lvms, &pch_pic_phandle); >> +    fdt_add_rtc_node(lvms); >>       fdt_add_ged_reset(lvms); >>       platform_bus_add_all_fdt_nodes(machine->fdt, "/platic", >> VIRT_PLATFORM_BUS_BASEADDRESS,