Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp4238157rwr; Mon, 8 May 2023 05:10:18 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7Xy6a92j13dKCzFirOZuqsY5f2V8zM26pXRe5TC1RiQbPhKerU3BcM2qXffTWNQZQSXG0d X-Received: by 2002:a17:902:f68a:b0:1ac:788c:872a with SMTP id l10-20020a170902f68a00b001ac788c872amr3909753plg.1.1683547818021; Mon, 08 May 2023 05:10:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683547818; cv=none; d=google.com; s=arc-20160816; b=ZmyB8gpQxhTLTHIXmPC66Z6qx8Tf8M0vJl5ePNSTzLmagthZLm/Q+gZJDnoCB7Bapj QdEa6P+c180FiARoov0JBEsQ13D6Pq5rDsR1OXUb7DbQ9j1TFqJAvzBkLDKsKeo/EbP4 06JrQz9FEt3OG0TD0kDdr8Uaqzb7haR4adcbEHg9XiVH2wMdoCefY5UXVjIwK44zyPc7 HKh8fpHRI+OaXtOIvrZPWoZZ6TJbWWNWCRxGzuXDpy8R1DXaxdslLpG2ZRJaaVROxS16 2iP6+iPPkVVXGEsyEP5o52a5qJHY5zPz219NXRd/xOAQ4DIULnHmMNIEnmuSjTkY/Mzt 8uiQ== 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=eZQCF28s2fJHXNz90jvQbzAl+DGj2nH8hRbfViNsVBsT+An6nn20FRWChLQvepHKax vFUkfUNG08pBObJyam/gs5fyGWoGM2QHCFPIWK+WNqMATNLmgdN+AK+dXQ4SthH8QG/v E1aB6c37qYNdAIL6HLH/AFhiAZaQl7+p63/XM/2KXCzHDrHoPAsq08bmI0HmKG2l/5EB KRsoAu+rFQN+clLrzhfSO1rQtAl6A+GlfWG+C8dy+7bg2siZHfF+46J71SyrS9qvSYOK MmhA+UEotMDG3ZpLCNIIXhRuUOX1TqW6m4ZE6P9mcno3F0IZRSXjdnvb1w/fHcKsR7AL pskA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ventanamicro.com header.s=google header.b=JiQARQ4b; 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 k10-20020a170902c40a00b001ab1d1a6803si8667649plk.420.2023.05.08.05.09.54; Mon, 08 May 2023 05:10:17 -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=JiQARQ4b; 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 S232562AbjEHLzU (ORCPT + 99 others); Mon, 8 May 2023 07:55:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57110 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236422AbjEHLyj (ORCPT ); Mon, 8 May 2023 07:54:39 -0400 Received: from mail-pf1-x432.google.com (mail-pf1-x432.google.com [IPv6:2607:f8b0:4864:20::432]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8E30543B8F for ; Mon, 8 May 2023 04:53:53 -0700 (PDT) Received: by mail-pf1-x432.google.com with SMTP id d2e1a72fcca58-64115e652eeso33918887b3a.0 for ; Mon, 08 May 2023 04:53:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1683546833; x=1686138833; 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=JiQARQ4bGK+5crktw+7cwuQmByROt6U3e6Ck6CkUSKgq+vqqGrp7mRQkU3K4gb/AF/ 6cxIoSse+C4MjTlJVBg3QYSR7p7G6jCn/p44wxSYx9PQGwB6ZmnkIUPnpdgRvo6wMWqy 0L9UwtLh0lVesJVxEre1vDBtMHsou9/GN5Ik4Z0P6ry7rbfpq2Q2HaUlgMOYNF9QcwRK nAFdRlV2btCkQ0lEpoY0F7zVlss+e2rWgZqK9aKWX9zQpBqYxXfOEryFswqrQKMNMbto 4XSSp5d0l4YLXXnQgnJzURNzut2UPTZ2o1aQZ2v6QK7NmTkPtfXc7SmaUBiaVAwtQMy0 s+4Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683546833; x=1686138833; 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=LL1b3/AcLZrpD309nuJXLYiNnNZT83hnqtuiHmyhE8itNwNKqVm3lq+L1NtIkHcxlk CZ31fsSKLEr3PEw/SR8Kz6JH40kiBNicvp/R68dIi9eNRSR/pMvvUs20GBWEo3+gaZPK XfwQL0Rhh2D1zjpk7yn43V2aiz4G9z/CPSdeROdUFSEZ6z1mC5J4u6UwEmGvxoe+uHJv YzhoVvDzphtLMWQ+/xB1du6Odl+dtiykhKUKrmCp2yUSZs6Zw0rthC9AduQy7DJ91GMs lE0TouWjlTzIbTWFipkPJNxOXXGLUpJUyNqoac3oGgVLH35N2ZspBUxZLAhizmicXTXr SMzg== X-Gm-Message-State: AC+VfDzm2/4I6mLbJfD46nrK7TpvFXeDagK+FjdLHFfzTp6VNK+k60u4 iBqfQ3yrfyKRTV9GZXyL03JxWw== X-Received: by 2002:a17:902:e550:b0:1a6:e564:6044 with SMTP id n16-20020a170902e55000b001a6e5646044mr12623756plf.7.1683546833102; Mon, 08 May 2023 04:53:53 -0700 (PDT) Received: from sunil-laptop.. ([106.51.189.144]) by smtp.gmail.com with ESMTPSA id w9-20020a170902904900b001aaed524541sm7015149plz.227.2023.05.08.04.53.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 May 2023 04:53:52 -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 , "Rafael J . Wysocki" , Len Brown , Daniel Lezcano , Thomas Gleixner , Weili Qian , Zhou Wang , Herbert Xu , "David S . Miller" , Marc Zyngier , Maximilian Luz , Hans de Goede , Mark Gross , Nathan Chancellor , Nick Desaulniers , Tom Rix , Sunil V L , "Rafael J . Wysocki" , Andrew Jones Subject: [PATCH V5 07/21] ACPI: processor_core: RISC-V: Enable mapping processor to the hartid Date: Mon, 8 May 2023 17:22:23 +0530 Message-Id: <20230508115237.216337-8-sunilvl@ventanamicro.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230508115237.216337-1-sunilvl@ventanamicro.com> References: <20230508115237.216337-1-sunilvl@ventanamicro.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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,T_SCC_BODY_TEXT_LINE 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