From patchwork Thu Feb 16 18:20:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sunil V L X-Patchwork-Id: 58189 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp456979wrn; Thu, 16 Feb 2023 10:23:23 -0800 (PST) X-Google-Smtp-Source: AK7set8c6soR6oir113K1hUHXayADT8Ox9YUb+RMNr8WYb0SyqsTFL9ethkicefea7OnBBE/WTb0 X-Received: by 2002:a17:90b:4c8f:b0:234:84ca:7f7f with SMTP id my15-20020a17090b4c8f00b0023484ca7f7fmr3847494pjb.19.1676571803078; Thu, 16 Feb 2023 10:23:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676571803; cv=none; d=google.com; s=arc-20160816; b=oe1Z6R4WJT/E/IL4YjKReVAE2Jk0bsrp/uCiGGz0kpdimE7yMpcLmqhD5m7GhTNs+P 8bcq6D5P9bmqJEXXE4GscTu0BUJhK7ZO/tjxG4kGXg+usyS30ZXT8oKhvopCj8p4mYzA osrbym1etBYRXK2maGrWUFKZsvmJsYJIGYf8WcXfOyDJoCyfB8lDjgIGqBrgOKG7+jxp MWkUECzK5N7O5XfuHLECKywoTOACO9Y2VIBt4VBVt7t2Qwv8m3hRZEK/snwmuEpt8pcJ ZqoCSVF22hOqKD+F7Yw8G7fN+HQHNRqy2/NAbuMaaLaQqAul99/fsWl/sguMBKXVXHyM U2sw== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=BcT4AtxywBaHPbxQbaGHDpYZBRDu3wCeHMqaXv1EYt0=; b=AsVcyl3Ef9dGuYiWxdh34QJrp6HTL544BKT5G/3kGgBQ82hL96jD0vBRIx24rkiqEB V1q2Brnz0WlSk8ZfB+Y7WLbuJmRJNtaZJFqoQSEgmHPn8HwEhCsuvQ8jGnpt8dIxGJuB bffAkXiqXUCTJkZiio5+he0oKdYIXAYIwUG+XhNkc6X1pnAiNBL+j/w/nFqJA5SzDwRa rdVnhNpw8uALDN83Ibu8WT0U8Akv5SlOhZBuCjI4h9j7QTrSQa3Eui+aCwwkoJeC4vve ZH+riV8esi2L705tIHdzCw1I9YyIXEoLfUs0MskZAK7GaB9dCZysEpxXFX/Wol/Ms/49 HrfQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ventanamicro.com header.s=google header.b=DBvjTCZI; 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 g5-20020a636b05000000b004d184dbf598si2421493pgc.519.2023.02.16.10.23.10; Thu, 16 Feb 2023 10:23:23 -0800 (PST) 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; dkim=pass header.i=@ventanamicro.com header.s=google header.b=DBvjTCZI; 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 S230096AbjBPSWM (ORCPT + 99 others); Thu, 16 Feb 2023 13:22:12 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56030 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230190AbjBPSWE (ORCPT ); Thu, 16 Feb 2023 13:22:04 -0500 Received: from mail-pl1-x62e.google.com (mail-pl1-x62e.google.com [IPv6:2607:f8b0:4864:20::62e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 173365037E for ; Thu, 16 Feb 2023 10:21:29 -0800 (PST) Received: by mail-pl1-x62e.google.com with SMTP id c11so2165430ple.9 for ; Thu, 16 Feb 2023 10:21:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=BcT4AtxywBaHPbxQbaGHDpYZBRDu3wCeHMqaXv1EYt0=; b=DBvjTCZIk+vcPUW8htmerk0xAsi1O8tw5BcDSym3jNNFaZhhj3sFESEoaQ0Yhv+703 j8AYTC/u7Z/JO44B/X+ZAXpYgAeZo6CliuHuUiaI2SCgIHy08Vso71L7TFcQ5jrXVdXU +8DDEuVrWcKm2wX9Z65//j6ETTkMzUIUCeacXa28ze6Z91EQ+V9RcPVlcirQdwLHMQ7L Tb3icHXPx7r/fuy+GHWyv6oMBMJ0RbQNMBQT1CGYvHYJA9xXnvOHefF7BG38Ka/VjJj6 dzyVpCKn22c8RKIuz91QYGwKHayKz4n9RlwrYMCMj1lzUiRCr7SMicUmQQmj7eXcCd2B 6kkg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=BcT4AtxywBaHPbxQbaGHDpYZBRDu3wCeHMqaXv1EYt0=; b=brHfB+UmOAOVEEMQU6DiOlkpafNJ7VtNX35mjYqlyjH39kgYUgbL2IZnzbqxnIfbFa 5TasFhetfvMqWPhUOf/n1jguUc9l0Tp4D+tUtgpIKd8A6bBIb2frCDmWbqWdqv9ncrhV KLxP+IFlLt6zoyUzz3FiWGa3czzzfccgchpOZFPTn5sStSXM7zl6g7otaZjNiPIGAEIZ jwzkKQ3OE0XW1taxb6QRdJ1JnWRGgzaHG+lREvXtX0biu7Mo7RcXhUPo0xCS1SjCV2R0 FZjuEXYA5Fy5KAoXFoNt7drvnlxrDr6Be3Kx0YaBruQfIzCVcIzWDS9fQ2Z9PmtDRet1 bO0Q== X-Gm-Message-State: AO0yUKWB8CEg7RSuiYefleTH1U7JTh2v/Mv10o1ZfmPVaLD+trX8AoXM XpJXTgDIkB+RWJ3Wr2etg1sQkw== X-Received: by 2002:a17:902:f312:b0:19a:a647:1880 with SMTP id c18-20020a170902f31200b0019aa6471880mr5075210ple.24.1676571686430; Thu, 16 Feb 2023 10:21:26 -0800 (PST) Received: from kerodi.Dlink ([49.206.14.226]) by smtp.gmail.com with ESMTPSA id n21-20020a637215000000b004dff15fc121sm1517574pgc.36.2023.02.16.10.21.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Feb 2023 10:21:26 -0800 (PST) From: Sunil V L To: Palmer Dabbelt , Albert Ou , Paul Walmsley , "Rafael J . Wysocki" , Len Brown , Thomas Gleixner , Marc Zyngier , Jonathan Corbet Cc: linux-riscv@lists.infradead.org, linux-acpi@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, Conor Dooley , Andrew Jones , Anup Patel , Atish Patra , Sunil V L , "Rafael J . Wysocki" Subject: [PATCH V2 07/21] ACPI: processor_core: RISC-V: Enable mapping processor to the hartid Date: Thu, 16 Feb 2023 23:50:29 +0530 Message-Id: <20230216182043.1946553-8-sunilvl@ventanamicro.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230216182043.1946553-1-sunilvl@ventanamicro.com> References: <20230216182043.1946553-1-sunilvl@ventanamicro.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS 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: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1758012954783096320?= X-GMAIL-MSGID: =?utf-8?q?1758012954783096320?= processor_core needs arch-specific functions to map the ACPI ID to the physical ID. In RISC-V platforms, hartid is the physical id and RINTC structure in MADT provides this mapping. Add arch-specific function to get this mapping from RINTC. Signed-off-by: Sunil V L Acked-by: Rafael J. Wysocki Reviewed-by: Andrew Jones --- arch/riscv/include/asm/acpi.h | 3 +++ drivers/acpi/processor_core.c | 29 +++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/arch/riscv/include/asm/acpi.h b/arch/riscv/include/asm/acpi.h index 7f9dce3c39d0..4a3622b38159 100644 --- a/arch/riscv/include/asm/acpi.h +++ b/arch/riscv/include/asm/acpi.h @@ -15,6 +15,9 @@ /* Basic configuration for ACPI */ #ifdef CONFIG_ACPI +typedef u64 phys_cpuid_t; +#define PHYS_CPUID_INVALID INVALID_HARTID + /* ACPI table mapping after acpi_permanent_mmap is set */ void *acpi_os_ioremap(acpi_physical_address phys, acpi_size size); #define acpi_os_ioremap acpi_os_ioremap diff --git a/drivers/acpi/processor_core.c b/drivers/acpi/processor_core.c index 2ac48cda5b20..d6606a9f2da6 100644 --- a/drivers/acpi/processor_core.c +++ b/drivers/acpi/processor_core.c @@ -106,6 +106,32 @@ static int map_gicc_mpidr(struct acpi_subtable_header *entry, return -EINVAL; } +/* + * Retrieve the RISC-V hartid for the processor + */ +static int map_rintc_hartid(struct acpi_subtable_header *entry, + int device_declaration, u32 acpi_id, + phys_cpuid_t *hartid) +{ + struct acpi_madt_rintc *rintc = + container_of(entry, struct acpi_madt_rintc, header); + + if (!(rintc->flags & ACPI_MADT_ENABLED)) + return -ENODEV; + + /* device_declaration means Device object in DSDT, in the + * RISC-V, logical processors are required to + * have a Processor Device object in the DSDT, so we should + * check device_declaration here + */ + if (device_declaration && rintc->uid == acpi_id) { + *hartid = rintc->hart_id; + return 0; + } + + return -EINVAL; +} + static phys_cpuid_t map_madt_entry(struct acpi_table_madt *madt, int type, u32 acpi_id) { @@ -136,6 +162,9 @@ static phys_cpuid_t map_madt_entry(struct acpi_table_madt *madt, } else if (header->type == ACPI_MADT_TYPE_GENERIC_INTERRUPT) { if (!map_gicc_mpidr(header, type, acpi_id, &phys_id)) break; + } else if (header->type == ACPI_MADT_TYPE_RINTC) { + if (!map_rintc_hartid(header, type, acpi_id, &phys_id)) + break; } entry += header->length; }