From patchwork Fri Mar 3 13:36:34 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: 63924 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp412438wrd; Fri, 3 Mar 2023 05:39:23 -0800 (PST) X-Google-Smtp-Source: AK7set8LlETgbFI2s6QF1dQVKCld5YYLzhrS5te0JG3xqNng32BG2yHJnH6AFAS70gFDCpvvH04X X-Received: by 2002:a17:90b:3ec2:b0:237:a500:eca6 with SMTP id rm2-20020a17090b3ec200b00237a500eca6mr5766508pjb.22.1677850763091; Fri, 03 Mar 2023 05:39:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677850763; cv=none; d=google.com; s=arc-20160816; b=onaoFcwaLYLrnYxZQRJQgD/WylGtoBvcPZBCFHvRVDQPBkpmfMpDpBAAsx4dTKtpgg ahpbep8nNQmgQRpOYn4jO7qsxjlUlUCl/YjN+xBdbQg8KUIAPktGL2XML+XanLYWGDpM zhSqTPtdzm+zStSjer5UUpeJyN7ZUc/RlVu8+Tax4DVaJRFC2sU6qsk/x6Muri7T8xqd SUHD8M7AEUXkbzmJYEzWM7xneG36kNbAAXzVYtljmSXHCJm2QrH5e/dxCIevODVPtnuW ARt+elmNcLcNtePqGjHsrxbmOhsutcKZuJCxA/wucDngzrlZ6mjlvU9y6+yuubmM3++4 w8yA== 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=mBemuZ+2YkCjmi93Yb84bL6oYK/bVtvUR58SW7DcwbA=; b=wUIaE4Iue2ypBKYqPO4gDcU/5oBJDXws03zb6bz3PrVu1g1DWQbPvRINz54f1CDxWG aht7Ga0eTE4HxoNZqwxmFTDgCSE5zV1XuIg3yOss//vPXUHJE6i93E4wCg39lamqXx/X EC+0Yz3fVLNQPoUkt+PXUZk/5lbW4q4uhZksCHcbZZySi6Jb9G1jW/Gan00YnZelsatg cPiMic021bUeFFo5XtmdUcQfKCvuN31KWeUFH19W7uUqD/J16oKBx+Cn6BYoOjGoSEGt RbuXYs2i4UetjM6e4TBurm2rs1yWgpsESGwvz6EqJkqWQFudKopkNwjbGAz9ktZYDiVj Or7A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ventanamicro.com header.s=google header.b=eYfH8EfF; 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 b3-20020a17090a9bc300b002192eb3532bsi5173433pjw.116.2023.03.03.05.38.40; Fri, 03 Mar 2023 05:39: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=eYfH8EfF; 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 S231237AbjCCNiL (ORCPT + 99 others); Fri, 3 Mar 2023 08:38:11 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47374 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231154AbjCCNhu (ORCPT ); Fri, 3 Mar 2023 08:37:50 -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 D799462D99 for ; Fri, 3 Mar 2023 05:37:29 -0800 (PST) Received: by mail-pl1-x62e.google.com with SMTP id p6so2742223plf.0 for ; Fri, 03 Mar 2023 05:37:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1677850649; 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=mBemuZ+2YkCjmi93Yb84bL6oYK/bVtvUR58SW7DcwbA=; b=eYfH8EfFgcshApQyiD3xCOf6+OIvUW8qg/k65nzJniZ/k9eVqQDqG4PbYKxUTWA/9W Auo7twOv5LJOHiXqBtC8Ig76Sh/WrEIqXL0PV4G2LCXte845FsmbU+aJK9gn2RTneuw+ 3KmPv1uXHl3IhytdLToTKGF6DqkpUKH8RpMVMn5FWXldGuUrRVv8mJ4+W4rPVlgs4ymw C6GwEmhJsRMjpGxHk29vSP72+mRzMZhTomILvoRtKDfsOQarwqiewo3PZ2m5s3njvp6w P1v+7XeYAu8kBDoikWbO3+jIBxxJrYOzyGCCBkA+AroMdTv3B2FvCRGth7xpdO+A0/ca YN2w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1677850649; 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=mBemuZ+2YkCjmi93Yb84bL6oYK/bVtvUR58SW7DcwbA=; b=i5kfFeRoadmuTUUzWJr9U5r2AD//mo13DugFa7zg81C3sw5hh9t5CEX23Qs2b+gkGV G6a+Kk5Ow0eH65BAhjwvH0XmH1QZbmbpoleBQHbEegkI9c6UuEvbhtVHDEqPmPvv0R9N nJI3sbi9dXMSnVXVGCkFkgi3+vzktyDxiObeLf8f1xxZFL0LRXbnBj+V1D+f4HYSA12r raOjqXAzFxyF3yyceixzrQknE7EuENlkujhBIgwlq2A8ziXIFpMCRVG+D+3L7SN0oMJT Wt6cM3ByCIq6mpHLAco1T03iejegg57ivdD7LsGg4U6x7oFEQkuSM7g+kv+r97jGPzRm Bwbw== X-Gm-Message-State: AO0yUKWLpwyntBRcmvLo9duRaN4QW8oVQLOsKk1tfG0qI7hayar9wsV7 DwKIUnItEBo81pAoP1JAiAxEpA== X-Received: by 2002:a17:902:d2c9:b0:19a:7d0e:ceea with SMTP id n9-20020a170902d2c900b0019a7d0eceeamr1996033plc.25.1677850649367; Fri, 03 Mar 2023 05:37:29 -0800 (PST) Received: from localhost.localdomain ([49.206.14.226]) by smtp.gmail.com with ESMTPSA id m9-20020a170902768900b0019ac5d3ee9dsm1533125pll.157.2023.03.03.05.37.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Mar 2023 05:37:29 -0800 (PST) From: Sunil V L To: linux-riscv@lists.infradead.org, linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org Cc: Palmer Dabbelt , Albert Ou , "Rafael J . Wysocki" , Len Brown , Thomas Gleixner , Marc Zyngier , Daniel Lezcano , Jonathan Corbet , Anup Patel , Andrew Jones , Atish Patra , 'Conor Dooley ' , Sunil V L , "Rafael J . Wysocki" Subject: [PATCH V3 07/20] ACPI: processor_core: RISC-V: Enable mapping processor to the hartid Date: Fri, 3 Mar 2023 19:06:34 +0530 Message-Id: <20230303133647.845095-8-sunilvl@ventanamicro.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230303133647.845095-1-sunilvl@ventanamicro.com> References: <20230303133647.845095-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=unavailable 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?1759354041518302179?= X-GMAIL-MSGID: =?utf-8?q?1759354041518302179?= 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 0b52a190f71a..7671c401f4ec 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; }