From patchwork Fri May 19 16:24:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Jiang X-Patchwork-Id: 683958 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 51F15C77B7A for ; Fri, 19 May 2023 16:24:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230357AbjESQYw (ORCPT ); Fri, 19 May 2023 12:24:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51514 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230469AbjESQYu (ORCPT ); Fri, 19 May 2023 12:24:50 -0400 Received: from mga06.intel.com (mga06b.intel.com [134.134.136.31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E189C107; Fri, 19 May 2023 09:24:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1684513488; x=1716049488; h=subject:from:to:cc:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=sUbNuG3GZYsRg+Z0hAbGSwm0VsJYcJclFRNoWEtbnho=; b=BbkDVZUMr8wRycr18BWR8D21A207lU5k7nJEfLN74YewPLzIUuHMAJ1s oFfr4FFsRK0SQGosPpK/G92vHEk6ZWkwwbVMKu676lmia5JsNG608UuGC 7G5RijgXJNlOT0xhZK1ft+Z7sVH2L+8X4kRIxhtRggqaS6P7hi7+Qwr2J Re831AoG0PGC6wT7+vJtaKhRl/KiSVy1ixVGlWfJLbExs8CCAzV7YXkeZ 7gwokTFf8AOfCE/N3RFx9zATsVFItmTTBkGIhfThtSVlxIFp9At+V0McA GuyQ8OM3o6GtiBTeD0ksGrtlOzrVyTvEwNYHsMvJIsaNVCmMKwkXEEXAI w==; X-IronPort-AV: E=McAfee;i="6600,9927,10715"; a="415878713" X-IronPort-AV: E=Sophos;i="6.00,177,1681196400"; d="scan'208";a="415878713" Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 May 2023 09:24:47 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10715"; a="949171324" X-IronPort-AV: E=Sophos;i="6.00,177,1681196400"; d="scan'208";a="949171324" Received: from djiang5-mobl3.amr.corp.intel.com (HELO [192.168.1.177]) ([10.212.29.189]) by fmsmga006-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 May 2023 09:24:45 -0700 Subject: [PATCH v2 4/4] acpi: numa: Add helper function to retrieve the performance attributes From: Dave Jiang To: linux-acpi@vger.kernel.org, linux-cxl@vger.kernel.org Cc: Jonathan Cameron , rafael@kernel.org, lenb@kernel.org, dan.j.williams@intel.com, ira.weiny@intel.com, vishal.l.verma@intel.com, alison.schofield@intel.com, lukas@wunner.de, Jonathan.Cameron@huawei.com Date: Fri, 19 May 2023 09:24:45 -0700 Message-ID: <168451348545.3465146.16987968181376551174.stgit@djiang5-mobl3> In-Reply-To: <168451341624.3465146.15355962690295941676.stgit@djiang5-mobl3> References: <168451341624.3465146.15355962690295941676.stgit@djiang5-mobl3> User-Agent: StGit/1.5 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org Add helper to retrieve the performance attributes based on the device handle. The helper function is exported so the CXL driver can use that to acquire the performance data between the CPU and the CXL host bridge. Reviewed-by: Jonathan Cameron Signed-off-by: Dave Jiang --- v2: - Change strncmp to memcmp. (Jonathan) --- drivers/acpi/numa/hmat.c | 35 +++++++++++++++++++++++++++++++++++ include/linux/acpi.h | 12 ++++++++++++ 2 files changed, 47 insertions(+) diff --git a/drivers/acpi/numa/hmat.c b/drivers/acpi/numa/hmat.c index 82320c92abed..940d2a838598 100644 --- a/drivers/acpi/numa/hmat.c +++ b/drivers/acpi/numa/hmat.c @@ -107,6 +107,41 @@ static struct memory_target *find_mem_target(unsigned int mem_pxm) return NULL; } +static struct memory_target *acpi_find_genport_target(u8 *device_handle) +{ + struct memory_target *target; + + list_for_each_entry(target, &targets, node) { + if (!memcmp(target->device_handle, device_handle, + ACPI_SRAT_DEVICE_HANDLE_SIZE)) + return target; + } + + return NULL; +} + +/** + * acpi_get_genport_coordinates - Retrieve the access coordinates for a generic port + * @device_handle: Device handle string (ACPI or PCI) to match up to the gen port + * @coord: The access coordinates written back out for the generic port + * + * Return: 0 on success. Errno on failure. + */ +int acpi_get_genport_coordinates(u8 *device_handle, + struct access_coordinate *coord) +{ + struct memory_target *target; + + target = acpi_find_genport_target(device_handle); + if (!target) + return -ENOENT; + + *coord = target->coord[NODE_ACCESS_CLASS_GENPORT_SINK]; + + return 0; +} +EXPORT_SYMBOL_NS_GPL(acpi_get_genport_coordinates, CXL); + static __init void alloc_memory_initiator(unsigned int cpu_pxm) { struct memory_initiator *initiator; diff --git a/include/linux/acpi.h b/include/linux/acpi.h index dcaaaffff318..56c30791318f 100644 --- a/include/linux/acpi.h +++ b/include/linux/acpi.h @@ -15,6 +15,7 @@ #include #include #include +#include struct irq_domain; struct irq_domain_ops; @@ -456,6 +457,17 @@ extern int acpi_blacklisted(void); extern void acpi_osi_setup(char *str); extern bool acpi_osi_is_win8(void); +#ifdef CONFIG_ACPI_HMAT +int acpi_get_genport_coordinates(u8 *device_handle, + struct access_coordinate *coord); +#else +static inline int acpi_get_genport_coordinates(u8 *device_handle, + struct access_coordinate *coord) +{ + return -EOPNOTSUPP; +} +#endif + #ifdef CONFIG_ACPI_NUMA int acpi_map_pxm_to_node(int pxm); int acpi_get_node(acpi_handle handle);