From patchwork Fri May 19 16:24:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Jiang X-Patchwork-Id: 684749 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 D6655C7EE29 for ; Fri, 19 May 2023 16:24:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229851AbjESQYg (ORCPT ); Fri, 19 May 2023 12:24:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51398 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229571AbjESQYf (ORCPT ); Fri, 19 May 2023 12:24:35 -0400 Received: from mga06.intel.com (mga06b.intel.com [134.134.136.31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8E1C08F; Fri, 19 May 2023 09:24:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1684513474; x=1716049474; h=subject:from:to:cc:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=5RkrpnEslnIHArEq4KtW+ePeGuapp92/gzx81tLhXAU=; b=fQt3YhMMQ3MCAHelbDqtD/R/cQOGDa/Zl1WN3fPWuP6NyixFf6BXnRmG gyozvilZCFk50bAJy1yoO2amkc5QX/d6v29TIfCifCQUIgPwPg0JEXv3h h5nFuOvj5+KVZf4WpDTM7+eJa8vzRLW5QJIGFIozxslQ7DhATmIEbNj1l Y9xkthX/7ACXEw9N+WCL0zFmU0IkZA3bBd1stCZcyVKa7FPEYDufndUel UCA7q2K1OtSBr2Vnx0LWLH9G1iuAaB/OwrBci2cqNAWOyzbuvsCs4crLV OxJVmQOMbmhhsNL9DZPPwSsolysbDlZ50l2qlo+59f505KRfWX15QMNtn g==; X-IronPort-AV: E=McAfee;i="6600,9927,10715"; a="415878666" X-IronPort-AV: E=Sophos;i="6.00,177,1681196400"; d="scan'208";a="415878666" 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:34 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10715"; a="949171231" X-IronPort-AV: E=Sophos;i="6.00,177,1681196400"; d="scan'208";a="949171231" 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:27 -0700 Subject: [PATCH v2 1/4] acpi: numa: Create enum for memory_target access coordinates indexing 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:26 -0700 Message-ID: <168451346601.3465146.10185750453901715133.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 Create enums to provide named indexing for the access coordinate array. This is in preparation for adding generic port support which will add a third index in the array to keep the generic port attributes separate from the memory attributes. Reviewed-by: Jonathan Cameron Signed-off-by: Dave Jiang --- drivers/acpi/numa/hmat.c | 35 ++++++++++++++++++++++++----------- 1 file changed, 24 insertions(+), 11 deletions(-) diff --git a/drivers/acpi/numa/hmat.c b/drivers/acpi/numa/hmat.c index f9ff992038fa..abed728bf09d 100644 --- a/drivers/acpi/numa/hmat.c +++ b/drivers/acpi/numa/hmat.c @@ -57,12 +57,18 @@ struct target_cache { struct node_cache_attrs cache_attrs; }; +enum { + NODE_ACCESS_CLASS_0 = 0, + NODE_ACCESS_CLASS_1, + NODE_ACCESS_CLASS_MAX, +}; + struct memory_target { struct list_head node; unsigned int memory_pxm; unsigned int processor_pxm; struct resource memregions; - struct access_coordinate coord[2]; + struct access_coordinate coord[NODE_ACCESS_CLASS_MAX]; struct list_head caches; struct node_cache_attrs cache_attrs; bool registered; @@ -338,10 +344,12 @@ static __init int hmat_parse_locality(union acpi_subtable_headers *header, if (mem_hier == ACPI_HMAT_MEMORY) { target = find_mem_target(targs[targ]); if (target && target->processor_pxm == inits[init]) { - hmat_update_target_access(target, type, value, 0); + hmat_update_target_access(target, type, value, + NODE_ACCESS_CLASS_0); /* If the node has a CPU, update access 1 */ if (node_state(pxm_to_node(inits[init]), N_CPU)) - hmat_update_target_access(target, type, value, 1); + hmat_update_target_access(target, type, value, + NODE_ACCESS_CLASS_1); } } } @@ -600,10 +608,12 @@ static void hmat_register_target_initiators(struct memory_target *target) */ if (target->processor_pxm != PXM_INVAL) { cpu_nid = pxm_to_node(target->processor_pxm); - register_memory_node_under_compute_node(mem_nid, cpu_nid, 0); + register_memory_node_under_compute_node(mem_nid, cpu_nid, + NODE_ACCESS_CLASS_0); access0done = true; if (node_state(cpu_nid, N_CPU)) { - register_memory_node_under_compute_node(mem_nid, cpu_nid, 1); + register_memory_node_under_compute_node(mem_nid, cpu_nid, + NODE_ACCESS_CLASS_1); return; } } @@ -644,12 +654,13 @@ static void hmat_register_target_initiators(struct memory_target *target) } if (best) hmat_update_target_access(target, loc->hmat_loc->data_type, - best, 0); + best, NODE_ACCESS_CLASS_0); } for_each_set_bit(i, p_nodes, MAX_NUMNODES) { cpu_nid = pxm_to_node(i); - register_memory_node_under_compute_node(mem_nid, cpu_nid, 0); + register_memory_node_under_compute_node(mem_nid, cpu_nid, + NODE_ACCESS_CLASS_0); } } @@ -681,11 +692,13 @@ static void hmat_register_target_initiators(struct memory_target *target) clear_bit(initiator->processor_pxm, p_nodes); } if (best) - hmat_update_target_access(target, loc->hmat_loc->data_type, best, 1); + hmat_update_target_access(target, loc->hmat_loc->data_type, best, + NODE_ACCESS_CLASS_1); } for_each_set_bit(i, p_nodes, MAX_NUMNODES) { cpu_nid = pxm_to_node(i); - register_memory_node_under_compute_node(mem_nid, cpu_nid, 1); + register_memory_node_under_compute_node(mem_nid, cpu_nid, + NODE_ACCESS_CLASS_1); } } @@ -746,8 +759,8 @@ static void hmat_register_target(struct memory_target *target) if (!target->registered) { hmat_register_target_initiators(target); hmat_register_target_cache(target); - hmat_register_target_perf(target, 0); - hmat_register_target_perf(target, 1); + hmat_register_target_perf(target, NODE_ACCESS_CLASS_0); + hmat_register_target_perf(target, NODE_ACCESS_CLASS_1); target->registered = true; } mutex_unlock(&target_lock); From patchwork Fri May 19 16:24:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Jiang X-Patchwork-Id: 683959 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 27312C7EE2A for ; Fri, 19 May 2023 16:24:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229480AbjESQYi (ORCPT ); Fri, 19 May 2023 12:24:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51408 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229571AbjESQYh (ORCPT ); Fri, 19 May 2023 12:24:37 -0400 Received: from mga06.intel.com (mga06b.intel.com [134.134.136.31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4CC3390; Fri, 19 May 2023 09:24:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1684513476; x=1716049476; h=subject:from:to:cc:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=ZROn1rHO/ja09swrLJPTGvhq5bcsXg4BuoD36PGk1CA=; b=cE/l7UBULvW3IzLwEc0aUJ+4DdfVfDI+waS5R7/Lf+xClIMdBEGGjeOI YrcxIZip3dcMWX43UQZUXw8IfYcKLNZ1679qgXbFBJP9AWuqBn8mtatqb zKi8ESyAi+CVn4lnR705GicjGGwJFCdkOnVaV3bEnLsDo+DOod5lBu4Pm c8JjIxYWG4o6dJ3x9+f+cUPpVGqAKAwxcTYkrSBciPhu468qosjh9zV44 Mtn4RDAckq2CGSDm1cr8RDEGZcsGg0yOBIFjQRChG1dOmlDCvRyguEKMn OCiJbwoxEtnfXjbAAgH7FjF1uf9hjA/Not2QGcdOvy0HLiPItpnYDYeGb g==; X-IronPort-AV: E=McAfee;i="6600,9927,10715"; a="415878671" X-IronPort-AV: E=Sophos;i="6.00,177,1681196400"; d="scan'208";a="415878671" 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:34 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10715"; a="949171266" X-IronPort-AV: E=Sophos;i="6.00,177,1681196400"; d="scan'208";a="949171266" 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:33 -0700 Subject: [PATCH v2 2/4] acpi: numa: Add genport target allocation to the HMAT parsing 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:32 -0700 Message-ID: <168451347268.3465146.4639692025002595572.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 SRAT parsing for the HMAT init in order to collect the device handle from the Generic Port Affinity Structure. The device handle will serve as the key to search for target data. Consoliate the common code with alloc_memory_target() in a helper function alloc_target(). Reviewed-by: Jonathan Cameron Signed-off-by: Dave Jiang --- drivers/acpi/numa/hmat.c | 53 +++++++++++++++++++++++++++++++++++++++++++--- include/acpi/actbl3.h | 4 +++ 2 files changed, 53 insertions(+), 4 deletions(-) diff --git a/drivers/acpi/numa/hmat.c b/drivers/acpi/numa/hmat.c index abed728bf09d..e2ab1cce0add 100644 --- a/drivers/acpi/numa/hmat.c +++ b/drivers/acpi/numa/hmat.c @@ -71,6 +71,7 @@ struct memory_target { struct access_coordinate coord[NODE_ACCESS_CLASS_MAX]; struct list_head caches; struct node_cache_attrs cache_attrs; + u8 device_handle[ACPI_SRAT_DEVICE_HANDLE_SIZE]; bool registered; }; @@ -125,8 +126,7 @@ static __init void alloc_memory_initiator(unsigned int cpu_pxm) list_add_tail(&initiator->node, &initiators); } -static __init void alloc_memory_target(unsigned int mem_pxm, - resource_size_t start, resource_size_t len) +static __init struct memory_target *alloc_target(unsigned int mem_pxm) { struct memory_target *target; @@ -134,7 +134,7 @@ static __init void alloc_memory_target(unsigned int mem_pxm, if (!target) { target = kzalloc(sizeof(*target), GFP_KERNEL); if (!target) - return; + return NULL; target->memory_pxm = mem_pxm; target->processor_pxm = PXM_INVAL; target->memregions = (struct resource) { @@ -147,6 +147,19 @@ static __init void alloc_memory_target(unsigned int mem_pxm, INIT_LIST_HEAD(&target->caches); } + return target; +} + +static __init void alloc_memory_target(unsigned int mem_pxm, + resource_size_t start, + resource_size_t len) +{ + struct memory_target *target; + + target = alloc_target(mem_pxm); + if (!target) + return; + /* * There are potentially multiple ranges per PXM, so record each * in the per-target memregions resource tree. @@ -157,6 +170,17 @@ static __init void alloc_memory_target(unsigned int mem_pxm, start, start + len, mem_pxm); } +static __init void alloc_genport_target(unsigned int mem_pxm, u8 *handle) +{ + struct memory_target *target; + + target = alloc_target(mem_pxm); + if (!target) + return; + + memcpy(target->device_handle, handle, ACPI_SRAT_DEVICE_HANDLE_SIZE); +} + static __init const char *hmat_data_type(u8 type) { switch (type) { @@ -498,6 +522,22 @@ static __init int srat_parse_mem_affinity(union acpi_subtable_headers *header, return 0; } +static __init int srat_parse_genport_affinity(union acpi_subtable_headers *header, + const unsigned long end) +{ + struct acpi_srat_generic_affinity *ga = (void *)header; + + if (!ga) + return -EINVAL; + + if (!(ga->flags & ACPI_SRAT_GENERIC_AFFINITY_ENABLED)) + return 0; + + alloc_genport_target(ga->proximity_domain, (u8 *)ga->device_handle); + + return 0; +} + static u32 hmat_initiator_perf(struct memory_target *target, struct memory_initiator *initiator, struct acpi_hmat_locality *hmat_loc) @@ -848,6 +888,13 @@ static __init int hmat_init(void) ACPI_SRAT_TYPE_MEMORY_AFFINITY, srat_parse_mem_affinity, 0) < 0) goto out_put; + + if (acpi_table_parse_entries(ACPI_SIG_SRAT, + sizeof(struct acpi_table_srat), + ACPI_SRAT_TYPE_GENERIC_PORT_AFFINITY, + srat_parse_genport_affinity, 0) < 0) + goto out_put; + acpi_put_table(tbl); status = acpi_get_table(ACPI_SIG_HMAT, 0, &tbl); diff --git a/include/acpi/actbl3.h b/include/acpi/actbl3.h index f51c46f4e3e4..5772185a54b2 100644 --- a/include/acpi/actbl3.h +++ b/include/acpi/actbl3.h @@ -279,12 +279,14 @@ struct acpi_srat_gic_its_affinity { * 6: ACPI_SRAT_TYPE_GENERIC_PORT_AFFINITY */ +#define ACPI_SRAT_DEVICE_HANDLE_SIZE 16 + struct acpi_srat_generic_affinity { struct acpi_subtable_header header; u8 reserved; u8 device_handle_type; u32 proximity_domain; - u8 device_handle[16]; + u8 device_handle[ACPI_SRAT_DEVICE_HANDLE_SIZE]; u32 flags; u32 reserved1; }; From patchwork Fri May 19 16:24:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Jiang X-Patchwork-Id: 684748 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 22293C7EE29 for ; Fri, 19 May 2023 16:24:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229571AbjESQYv (ORCPT ); Fri, 19 May 2023 12:24:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51550 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230450AbjESQYs (ORCPT ); Fri, 19 May 2023 12:24:48 -0400 Received: from mga06.intel.com (mga06b.intel.com [134.134.136.31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BFC858F; Fri, 19 May 2023 09:24:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1684513487; x=1716049487; h=subject:from:to:cc:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=nOX1pXIcJVFKfYATZ1eoWbPglDzG33/gwY/u+oUeM0M=; b=GoX++jcztCU/C9VikiGqg9d0IXWyGgBvDVC39iPul8vLqR+rhZh/7UVI fQqXpTjFdzJI6NDm3ZL92c7LuJW6eyuCGiRnB1EfZEN42IjzPhjildRJE krEOKnnIpFaJfFUzrSTeXuMQCW3i5cRve8Pdd3dnjjkWqrtSr1UFrbI+Q klU+I5A8MUZnzPNipRYPhBBUtGEsnBcgKriMNx13TWAnvHDxEE8aNWTRe +sN1HNkWKL4EsLVldYsPTbbpd/12Ol7y3wgggNmfctvXs1b8FpIyxUis6 RfXsnlqY8eXXkyJ3epgJaNrQ9s+KHGFl0xNu3L9KM9sk5MRrudQBC50rZ A==; X-IronPort-AV: E=McAfee;i="6600,9927,10715"; a="415878707" X-IronPort-AV: E=Sophos;i="6.00,177,1681196400"; d="scan'208";a="415878707" 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="949171295" X-IronPort-AV: E=Sophos;i="6.00,177,1681196400"; d="scan'208";a="949171295" 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:39 -0700 Subject: [PATCH v2 3/4] acpi: numa: Add setting of generic port system locality attributes From: Dave Jiang To: linux-acpi@vger.kernel.org, linux-cxl@vger.kernel.org Cc: 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:38 -0700 Message-ID: <168451347867.3465146.10428399827479313906.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 generic port support for the parsing of HMAT system locality sub-table. The attributes will be added to the third array member of the access coordinates in order to not mix with the existing memory attributes. It only provides the system locality attributes from initator to the generic port targets and is missing the rest of the data to the actual memory device. The complete attributes will be updated when a memory device is attached and the system locality information is calculated end to end. Signed-off-by: Dave Jiang v2: - Fix commit log runon sentence. (Jonathan) - Add a check for memory type for skipping other access levels. (Jonathan) - NODE_ACCESS_CLASS_GENPORT to NODE_ACCESS_CLASS_GENPORT_SINK. (Jonathan) --- drivers/acpi/numa/hmat.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/drivers/acpi/numa/hmat.c b/drivers/acpi/numa/hmat.c index e2ab1cce0add..82320c92abed 100644 --- a/drivers/acpi/numa/hmat.c +++ b/drivers/acpi/numa/hmat.c @@ -60,6 +60,7 @@ struct target_cache { enum { NODE_ACCESS_CLASS_0 = 0, NODE_ACCESS_CLASS_1, + NODE_ACCESS_CLASS_GENPORT_SINK, NODE_ACCESS_CLASS_MAX, }; @@ -368,6 +369,15 @@ static __init int hmat_parse_locality(union acpi_subtable_headers *header, if (mem_hier == ACPI_HMAT_MEMORY) { target = find_mem_target(targs[targ]); if (target && target->processor_pxm == inits[init]) { + if (*target->device_handle) { + hmat_update_target_access(target, type, value, + NODE_ACCESS_CLASS_GENPORT_SINK); + if ((hmat_loc->flags & + ACPI_HMAT_MEMORY_HIERARCHY) == + ACPI_HMAT_MEMORY) + continue; + } + hmat_update_target_access(target, type, value, NODE_ACCESS_CLASS_0); /* If the node has a CPU, update access 1 */ 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);