From patchwork Mon Jul 10 06:33:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: maobibo X-Patchwork-Id: 117650 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9f45:0:b0:3ea:f831:8777 with SMTP id v5csp4829658vqx; Sun, 9 Jul 2023 23:55:43 -0700 (PDT) X-Google-Smtp-Source: APBJJlHkc7w4qXciMZgPI/D2l57yFUXPEjOT7IrPzUAXvB5zsHCF723N5fWyCRvNWF02g3QGzGyZ X-Received: by 2002:a05:620a:271c:b0:767:c572:ab11 with SMTP id b28-20020a05620a271c00b00767c572ab11mr6126340qkp.4.1688972143398; Sun, 09 Jul 2023 23:55:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688972143; cv=none; d=google.com; s=arc-20160816; b=O67pNxUD8Va3H+7K/0gFsagSlD8MPYyxTZp/EtNtOxGewf9Ox1hdILqxo6sDGhXSGA vSgf28d4BMAbK+akfOsHhVEU3k4dLuSi6zELj0/2CQo8jylaX/J86K1xqvu+OcvHCpzz aeJRGCdlRO6oFrtLZ1qdgOA5z1XMzC8GiW+q31wfW5xeZ+PLbeY1hYPbxC16XyVd0Rwm Ckeq6vm27CApsaaITDqlQ3pGa1MJgjKMbrqgwiL5DpYhZygfwO6ejfLwnQpHIrHPca7/ vG2x0gWmxpjnk24iP95EYFSCB8N1GrHRABpA+xkIlyQVq6dIWaAekJQue/6UbeQAMYq3 7FiA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=9x5IjeoAUHYNwusdAd/L0e/eAVu/uE3noFM1cgqEZGM=; fh=M5kSo9ySbUJE7dV+oWarcV9HVmjZyGV8Bp7zQFNunD0=; b=xuF7GhQ6PeflRQ1sSztBECmLs2YXB7/CWDbJq3YdStZStsMHXa2p2hGc1XCBeUaQI7 l7sYAQa7mjsGzVlF79nFdUX8gJHXgJ/faRvznrcPSb3vn8CkDdkxtY8VI97F8lzq9Xz/ 9s4IRul2l2YxK/NR1sKz0t8tSiJswrrqfPaM0b5YHWXE9ORIjAOmDDKxPA+knBa6s8Xg 0AD7SZxbxBrumMy0Xj5vNkIxO07xTRAm0yVGelYDGcE7pZEbE58QbOjPCO00c0Wuh4ek rtbZ/XZAxsPLJeiJbQ65smIzqYXT0FNjl7hgfD59mgm5qts292KNuQ1hzgzVxnG3Vbsv 3MWA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f14-20020a63554e000000b0053490e8df50si8044269pgm.223.2023.07.09.23.55.30; Sun, 09 Jul 2023 23:55:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230224AbjGJGd6 (ORCPT + 99 others); Mon, 10 Jul 2023 02:33:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38560 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230049AbjGJGdw (ORCPT ); Mon, 10 Jul 2023 02:33:52 -0400 Received: from mail.loongson.cn (mail.loongson.cn [114.242.206.163]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 961A512A; Sun, 9 Jul 2023 23:33:45 -0700 (PDT) Received: from loongson.cn (unknown [10.2.9.158]) by gateway (Coremail) with SMTP id _____8BxY_BFpqtkavkCAA--.8714S3; Mon, 10 Jul 2023 14:33:41 +0800 (CST) Received: from kvm-1-158.loongson.cn (unknown [10.2.9.158]) by localhost.localdomain (Coremail) with SMTP id AQAAf8Ax8uREpqtk9NkmAA--.45300S2; Mon, 10 Jul 2023 14:33:40 +0800 (CST) From: Bibo Mao To: "Rafael J . Wysocki" Cc: Len Brown , linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] ACPI: processor_core: LoongArch: Get physical id from MADT table Date: Mon, 10 Jul 2023 14:33:40 +0800 Message-Id: <20230710063340.1716007-1-maobibo@loongson.cn> X-Mailer: git-send-email 2.27.0 MIME-Version: 1.0 X-CM-TRANSID: AQAAf8Ax8uREpqtk9NkmAA--.45300S2 X-CM-SenderInfo: xpdruxter6z05rqj20fqof0/ X-Coremail-Antispam: 1Uk129KBj93XoW7tF1DZr47Jw45XryktrWUGFX_yoW8uryfpF y8K345K3WUWFnIq3WfJayrJFWYq3y8ua4SgFZ3C3sxtF4rGr1rZFW8JFyagFyDCF48K3y7 Zr48tay8Gay8ZFbCm3ZEXasCq-sJn29KB7ZKAUJUUUU8529EdanIXcx71UUUUU7KY7ZEXa sCq-sGcSsGvfJ3Ic02F40EFcxC0VAKzVAqx4xG6I80ebIjqfuFe4nvWSU5nxnvy29KBjDU 0xBIdaVrnRJUUUk0b4IE77IF4wAFF20E14v26r1j6r4UM7CY07I20VC2zVCF04k26cxKx2 IYs7xG6rWj6s0DM7CIcVAFz4kK6r1j6r18M28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48v e4kI8wA2z4x0Y4vE2Ix0cI8IcVAFwI0_JFI_Gr1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI 0_Gr0_Cr1l84ACjcxK6I8E87Iv67AKxVWxJVW8Jr1l84ACjcxK6I8E87Iv6xkF7I0E14v2 6r4j6r4UJwAS0I0E0xvYzxvE52x082IY62kv0487Mc804VCY07AIYIkI8VC2zVCFFI0UMc 02F40EFcxC0VAKzVAqx4xG6I80ewAv7VC0I7IYx2IY67AKxVWUGVWUXwAv7VC2z280aVAF wI0_Jr0_Gr1lOx8S6xCaFVCjc4AY6r1j6r4UM4x0Y48IcxkI7VAKI48JMxAIw28IcxkI7V AKI48JMxC20s026xCaFVCjc4AY6r1j6r4UMI8I3I0E5I8CrVAFwI0_Jr0_Jr4lx2IqxVCj r7xvwVAFwI0_JrI_JrWlx4CE17CEb7AF67AKxVWUAVWUtwCIc40Y0x0EwIxGrwCI42IY6x IIjxv20xvE14v26r1j6r1xMIIF0xvE2Ix0cI8IcVCY1x0267AKxVWUJVW8JwCI42IY6xAI w20EY4v20xvaj40_Jr0_JF4lIxAIcVC2z280aVAFwI0_Jr0_Gr1lIxAIcVC2z280aVCY1x 0267AKxVWUJVW8JbIYCTnIWIevJa73UjIFyTuYvjxUrNtxDUUUU X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1771015654400241524 X-GMAIL-MSGID: 1771015654400241524 With ACPI Spec 6.5 physical id can be parsed from MADT table for LoongArch system, also it can be used in MAT table for cpu hotplug stage. This patch adds physical id parsing for LoongArch system. Signed-off-by: Bibo Mao --- drivers/acpi/processor_core.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/drivers/acpi/processor_core.c b/drivers/acpi/processor_core.c index d6606a9f2da6..51239cd2a485 100644 --- a/drivers/acpi/processor_core.c +++ b/drivers/acpi/processor_core.c @@ -132,6 +132,26 @@ static int map_rintc_hartid(struct acpi_subtable_header *entry, return -EINVAL; } +/* + * Retrieve LoongArch CPU physical id + */ +static int map_core_pic_id(struct acpi_subtable_header *entry, + int device_declaration, u32 acpi_id, phys_cpuid_t *apic_id) +{ + struct acpi_madt_core_pic *core_pic = + container_of(entry, struct acpi_madt_core_pic, header); + + if (!(core_pic->flags & ACPI_MADT_ENABLED)) + return -ENODEV; + + if (device_declaration && (core_pic->processor_id == acpi_id)) { + *apic_id = core_pic->core_id; + return 0; + } + + return -EINVAL; +} + static phys_cpuid_t map_madt_entry(struct acpi_table_madt *madt, int type, u32 acpi_id) { @@ -165,6 +185,9 @@ static phys_cpuid_t map_madt_entry(struct acpi_table_madt *madt, } else if (header->type == ACPI_MADT_TYPE_RINTC) { if (!map_rintc_hartid(header, type, acpi_id, &phys_id)) break; + } else if (header->type == ACPI_MADT_TYPE_CORE_PIC) { + if (!map_core_pic_id(header, type, acpi_id, &phys_id)) + break; } entry += header->length; } @@ -216,6 +239,8 @@ static phys_cpuid_t map_mat_entry(acpi_handle handle, int type, u32 acpi_id) map_x2apic_id(header, type, acpi_id, &phys_id); else if (header->type == ACPI_MADT_TYPE_GENERIC_INTERRUPT) map_gicc_mpidr(header, type, acpi_id, &phys_id); + else if (header->type == ACPI_MADT_TYPE_CORE_PIC) + map_core_pic_id(header, type, acpi_id, &phys_id); exit: kfree(buffer.pointer);