Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp6361989rwl; Tue, 4 Apr 2023 11:24:38 -0700 (PDT) X-Google-Smtp-Source: AKy350aG8ogIBAwJ7IvzNfLJY0F+R83tNMHqZQFUP111VeTLhvaVhkkwqZMjmsOSSWMcpG96cshP X-Received: by 2002:a17:902:f690:b0:1a0:563e:b0c4 with SMTP id l16-20020a170902f69000b001a0563eb0c4mr716497plg.2.1680632678651; Tue, 04 Apr 2023 11:24:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680632678; cv=none; d=google.com; s=arc-20160816; b=yBvSEqGHxsnVZTJQJAFb7geUwyBMBelPkKmxsL3jXNehm4eWlUAPeDEYzf9BYxA4cu adqCSpcxt7Ko6FWvxG5z1PPZPn4KUKezyWaG7FnMhOs6nYGxp37aY8KCa7PQJvauBkrI tpzCkZ0xzSfhYdSiJ2P5ENWey97k1UrRYSUsef3ShjbFlgEGhXQfAA0JzKaU/5O2+Ac0 wulRH+ZmQ5uATAyhfwHi5efe4cn9OjeRocTYfliBLXLXPIt6jCdeDdlho+LDnEnA54Ed 5tOQeUeMOoBmCcp/pxaTu2RskAzqxJu6Vn0TZk19DWj9RCUNAPmUO5fEg5+TjORWt0oe KhDg== 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=bvg+GJpfRbLLmDkZ0StW7roD1sWqDLKd1ZxLgpiB2U8=; b=04FuG6IJJldyrYfNFojxhPhR+SqGN0gQRoPiLBf/nAm8eF3aQ/FloT8kDlrW/RogMi swz6Q4WCz+rtmSE1oVkEE+MedV7wg6oI6/9Ib9VH9U8V/QXod8KQYFV0OIkpS6Qd6hRn nxWEcBPovDoTeZP9ux5vedpCsKX3OmyR1ftA2P/NKxDTsJ5TMMjjUCGE9eeQQvND52YL fnP4Vdl98rwWurslxyHuaREFAwGjZWj2Q0IwAa4MVE62Q+Q15NFSCFbQSeL4IIVFkJW4 nRxhZa+4NH4Ky7pvV0MhwdjjM/pNpBHODT3BXXYMfVjbnAx2i5o5ElYFPZXoIEV0HCAW hj3g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ventanamicro.com header.s=google header.b=I3YBhdL+; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id jb14-20020a170903258e00b001a1dc2b1e34si10388645plb.246.2023.04.04.11.24.26; Tue, 04 Apr 2023 11:24:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-crypto-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=I3YBhdL+; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236448AbjDDSXB (ORCPT + 99 others); Tue, 4 Apr 2023 14:23:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38778 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236443AbjDDSVz (ORCPT ); Tue, 4 Apr 2023 14:21:55 -0400 Received: from mail-pl1-x631.google.com (mail-pl1-x631.google.com [IPv6:2607:f8b0:4864:20::631]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AE7A259F2 for ; Tue, 4 Apr 2023 11:21:36 -0700 (PDT) Received: by mail-pl1-x631.google.com with SMTP id ja10so32144878plb.5 for ; Tue, 04 Apr 2023 11:21:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1680632496; 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=bvg+GJpfRbLLmDkZ0StW7roD1sWqDLKd1ZxLgpiB2U8=; b=I3YBhdL+3Xu+llKzrnwX1PUwlziaWfYZYAn6dc7RWq3v8qQ5bWdgGSvxCKmlXVBO6+ rekwV0s8mtQsUQ5+R5rntkObGS4DCiB67c5WHPJHjXpH1FI3ldw8JPXKTvadU94zPUEq 3MoSjz8vNOVFECLMc3b8PcTCxSp04tEPFOksmPgCMVu98oUh7zudU2b0dGhPvdMf3bq2 tb7nhujvFAJbspAzqq9BA4BbHp9YilY1deH4pMAEkoyBFSWtCg6cei+qkzWCtuWGEFrS n/PBi6qYsRJU3PlEGBXGHpmKo1j22/fKx1+DLBUi4RnXsud0TPYfOw6Od4r7sNSzRIGQ JbkA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680632496; 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=bvg+GJpfRbLLmDkZ0StW7roD1sWqDLKd1ZxLgpiB2U8=; b=xdDXpjdwMIQ30DQC2YQ1AN8vAbBGpGfCRsxDFMsO4Y9NE2TxKEM+uJ3csqdgILcxBG th+ncdwedyyDxAlsFkW5uW0Q/U4Cd9wqB7TP/r7XPNKQUuMxzuaCCKIsHZe4Pjyvm2IR Ib+VT7IVO4ZrU8SzJbtY2t/DFUsvMOqpAZsuSoBGA1UuF6AJEORLfyZyCg40i9Y73+P6 pRMl1g6O8savFI1Cm5pIMdFLStOBuDnSBx0T4PmqAuj2SquCZK+LyuLl05GnUo7YQqUm YlMuCdh+a4ah8YAMBhosTdSDT03xjP3FSRoGMW3fezUhHN1Za/IUTa38kVhPB2iZug8O 12sA== X-Gm-Message-State: AAQBX9eOoXINDXcCO5+s4tRrJ2QqKMr2ZfY2P4Vnnev7uPxqSV85r6Nq chkTaDfmdr9QfCXOAc+Cr46cQg== X-Received: by 2002:a05:6a20:cf63:b0:db:b7:fe3f with SMTP id hz35-20020a056a20cf6300b000db00b7fe3fmr3101830pzb.10.1680632496052; Tue, 04 Apr 2023 11:21:36 -0700 (PDT) Received: from localhost.localdomain ([106.51.184.50]) by smtp.gmail.com with ESMTPSA id o12-20020a056a001bcc00b0062dcf5c01f9sm9018524pfw.36.2023.04.04.11.21.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Apr 2023 11:21:35 -0700 (PDT) From: Sunil V L To: linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, linux-acpi@vger.kernel.org, linux-crypto@vger.kernel.org, platform-driver-x86@vger.kernel.org, llvm@lists.linux.dev Cc: Jonathan Corbet , Paul Walmsley , Palmer Dabbelt , Albert Ou , Len Brown , Daniel Lezcano , Thomas Gleixner , Weili Qian , Zhou Wang , Herbert Xu , Marc Zyngier , Maximilian Luz , Hans de Goede , Mark Gross , Nathan Chancellor , Nick Desaulniers , Tom Rix , "Rafael J . Wysocki" , "David S . Miller" , Sunil V L , "Rafael J . Wysocki" , Andrew Jones Subject: [PATCH V4 07/23] ACPI: processor_core: RISC-V: Enable mapping processor to the hartid Date: Tue, 4 Apr 2023 23:50:21 +0530 Message-Id: <20230404182037.863533-8-sunilvl@ventanamicro.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230404182037.863533-1-sunilvl@ventanamicro.com> References: <20230404182037.863533-1-sunilvl@ventanamicro.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.2 required=5.0 tests=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-crypto@vger.kernel.org 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 bcade255bd6e..9be52b6ffae1 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; } -- 2.34.1