From patchwork Thu Jun 22 21:39: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: 13289860 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 6635AEB64DC for ; Thu, 22 Jun 2023 21:39:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230096AbjFVVjg (ORCPT ); Thu, 22 Jun 2023 17:39:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40816 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229643AbjFVVjf (ORCPT ); Thu, 22 Jun 2023 17:39:35 -0400 Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B96F21FED; Thu, 22 Jun 2023 14:39: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=1687469974; x=1719005974; h=subject:from:to:cc:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=5RkrpnEslnIHArEq4KtW+ePeGuapp92/gzx81tLhXAU=; b=iITmdlEmdSxF7D7vgNf4lMjOk/H+y6foZKBmxqEg7jbszBx2B9slwUTO JrRzH83Br+0XiRm9O0AKHWzihgdaV9papBBKrh0S5Poe+v49aIXQJm3tJ Pj57btn4bkQyjCZ8ptzHDnyFnr0eOs0O6Q+nq8goF6YvpLT6UnMwJPVzO LHoTtFQFXLstR0pHKq7E902O8zO3OGYE/XTXoZDUZC/IyRLQs5GmQ+Zg8 w8Pini/Vvdf4smVifBPRpw5v34gmgI4oPl+WlX63zhZdsdGBN907h3MIg 2tS9d5gh261vfz7J/oesqT8xETia81Kpma/B+eStG7a0BfLFN0glsdGF5 g==; X-IronPort-AV: E=McAfee;i="6600,9927,10749"; a="345381219" X-IronPort-AV: E=Sophos;i="6.01,150,1684825200"; d="scan'208";a="345381219" Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Jun 2023 14:39:34 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10749"; a="715088854" X-IronPort-AV: E=Sophos;i="6.01,150,1684825200"; d="scan'208";a="715088854" Received: from djiang5-mobl3.amr.corp.intel.com (HELO [192.168.1.177]) ([10.212.53.238]) by orsmga002-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Jun 2023 14:39:33 -0700 Subject: [PATCH v4 1/6] 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: Thu, 22 Jun 2023 14:39:32 -0700 Message-ID: <168746997272.4115467.12889336174992481226.stgit@djiang5-mobl3> In-Reply-To: <168746993412.4115467.1442857478644914777.stgit@djiang5-mobl3> References: <168746993412.4115467.1442857478644914777.stgit@djiang5-mobl3> User-Agent: StGit/1.5 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-cxl@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 Thu Jun 22 21:39:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Jiang X-Patchwork-Id: 13289861 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 52FFDEB64DD for ; Thu, 22 Jun 2023 21:39:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230381AbjFVVjm (ORCPT ); Thu, 22 Jun 2023 17:39:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40832 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229643AbjFVVjl (ORCPT ); Thu, 22 Jun 2023 17:39:41 -0400 Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ABE5B1FED; Thu, 22 Jun 2023 14:39:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1687469980; x=1719005980; h=subject:from:to:cc:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=KkhMEzxXU8CC/Aa+3udHBagC72rArqsW6CT+7tfGKec=; b=WOTludKkcaW2XGRuALxpnher/mdoNF2O9WuaUXj1T63eKr/bTuvkrP7x IAjrvX5k6DNa3W+/vJfBunul9+4/+5Hb3j1AekXSXzr+XwXXg3bQ2gD7X gAE5ni58BwqWsj4SsovE7gxNGBO3R4x1K4yiLqTiOQEi/rF2rE5n/adJq +KADuqmlSop6ZOg2qOZSpirV3/kZLex06+5ji3sxWBMtLItglj4x/C/Zd gpuBSTrNSrs0oSS5yLOumBAUbBOnAqBkJx6E3zA9Fbmk4z23uNkBw9tV5 9jBn0qhWnv6jUyz68Vok8OAPjAvwIzAQsNz4T/nXGXUguMvE1wNh7wbrf Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10749"; a="345381272" X-IronPort-AV: E=Sophos;i="6.01,150,1684825200"; d="scan'208";a="345381272" Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Jun 2023 14:39:40 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10749"; a="715088897" X-IronPort-AV: E=Sophos;i="6.01,150,1684825200"; d="scan'208";a="715088897" Received: from djiang5-mobl3.amr.corp.intel.com (HELO [192.168.1.177]) ([10.212.53.238]) by orsmga002-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Jun 2023 14:39:39 -0700 Subject: [PATCH v4 2/6] ACPICA: Add a define for size of acpi_srat_generic_affinity DeviceHandle 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: Thu, 22 Jun 2023 14:39:39 -0700 Message-ID: <168746997931.4115467.47140094903948157.stgit@djiang5-mobl3> In-Reply-To: <168746993412.4115467.1442857478644914777.stgit@djiang5-mobl3> References: <168746993412.4115467.1442857478644914777.stgit@djiang5-mobl3> User-Agent: StGit/1.5 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-cxl@vger.kernel.org ACPICA commit be56820b03d8aeabfa6709c4d99bf1711afe7ef1 Replace magic number with a define. Linux kernel code will utilize this define. Link: https://github.com/acpica/acpica/commit/be56820b Link: https://github.com/acpica/acpica/pull/876 Signed-off-by: Dave Jiang Reviewed-by: Ira Weiny --- include/acpi/actbl3.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/include/acpi/actbl3.h b/include/acpi/actbl3.h index f51c46f4e3e4..1838e5cb313a 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 Thu Jun 22 21:39: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: 13289862 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 94E70EB64DA for ; Thu, 22 Jun 2023 21:39:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229916AbjFVVjs (ORCPT ); Thu, 22 Jun 2023 17:39:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40874 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231215AbjFVVjr (ORCPT ); Thu, 22 Jun 2023 17:39:47 -0400 Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E6B851FED; Thu, 22 Jun 2023 14:39:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1687469986; x=1719005986; h=subject:from:to:cc:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=AYLiZYGdftgLM1Eaps6D1D/RWBD4n+7xxQ4qYlfvBy4=; b=dlvVNnE5pcSRaNsWblr7lCs7hPz1Tddb/dGX1SiAP7hcjXVX/vr3foda YSN9b9NAmZgAzlWBxvOYZMo+Ilet19+Nh4DUE+G+dIXo7HMKYhpN6DqUj i2SQYrV68HOGCclbNMNcoO1oDM54Am3uRsg2Lvf4WyArznJ/PJbWlJWcj hbj+WWsP+2eOe1bDZ/Pk3OBVewVVycpXDo2GI0INOnfSwRWlGVQk/lvXM VOsJFHlTy02CZ+kyBOKjFavV0m0oh3c5nS8LPKR9zkzQI9OdzaCBdyroA eq0XiyhVwaKoroYaYRkjh41ndkEibpZiM9xIvbXctuiYk5ljYNI/RZ0cI g==; X-IronPort-AV: E=McAfee;i="6600,9927,10749"; a="345381326" X-IronPort-AV: E=Sophos;i="6.01,150,1684825200"; d="scan'208";a="345381326" Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Jun 2023 14:39:46 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10749"; a="715088930" X-IronPort-AV: E=Sophos;i="6.01,150,1684825200"; d="scan'208";a="715088930" Received: from djiang5-mobl3.amr.corp.intel.com (HELO [192.168.1.177]) ([10.212.53.238]) by orsmga002-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Jun 2023 14:39:46 -0700 Subject: [PATCH v4 3/6] 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: Thu, 22 Jun 2023 14:39:45 -0700 Message-ID: <168746998555.4115467.4761183239980221269.stgit@djiang5-mobl3> In-Reply-To: <168746993412.4115467.1442857478644914777.stgit@djiang5-mobl3> References: <168746993412.4115467.1442857478644914777.stgit@djiang5-mobl3> User-Agent: StGit/1.5 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-cxl@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 --- v4: - Rename device_handle to gen_port_device_handle. (Jonathan) v3: - Move ACPI_SRAT_DEVICE_HANDLE_SIZE to separate patch for ACPICA --- drivers/acpi/numa/hmat.c | 55 +++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 52 insertions(+), 3 deletions(-) diff --git a/drivers/acpi/numa/hmat.c b/drivers/acpi/numa/hmat.c index abed728bf09d..8380460cfee2 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 gen_port_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,18 @@ 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->gen_port_device_handle, handle, + ACPI_SRAT_DEVICE_HANDLE_SIZE); +} + static __init const char *hmat_data_type(u8 type) { switch (type) { @@ -498,6 +523,23 @@ 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 +890,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); From patchwork Thu Jun 22 21:39:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Jiang X-Patchwork-Id: 13289863 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 77D5AEB64DA for ; Thu, 22 Jun 2023 21:39:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230470AbjFVVj4 (ORCPT ); Thu, 22 Jun 2023 17:39:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40926 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230444AbjFVVj4 (ORCPT ); Thu, 22 Jun 2023 17:39:56 -0400 Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 555921FF9; Thu, 22 Jun 2023 14:39:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1687469993; x=1719005993; h=subject:from:to:cc:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=bY2gOLUmvznxH+TixmfijqEv/4Bid4wIyFOTxxQQmPc=; b=SGgN4aKzTzD6bX5UR+jzdIOl/QOj6iHqacFLTWx8lSLED67KVJLd9LYw YnGIhK3y0zh+Srz+BVSTr3m98pSYAT81641+LbaUEjOImdBvA7tAxvqhV iQjAkZA3s+gm+oqX0j92595ggjn5vWVbXcqltBdB1nfU8sEl8gF/uxjZM YhYNOwFriJZhmuQCUG4+Jpi6YGpxMAYirdcU2CbvU7QfD9xAlB/Pbnlbf vf4ysKrMnG7bFVrLyX5K9+GvMT0TPzjPNoKYzlBaaUbDVzCEWrPmFFpzV 0Tn8a+9OwwwKULIq0pPGhoDrvOHmFogzOeWA8y9CjoqkSzXptzQMBrx2Z w==; X-IronPort-AV: E=McAfee;i="6600,9927,10749"; a="345381352" X-IronPort-AV: E=Sophos;i="6.01,150,1684825200"; d="scan'208";a="345381352" Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Jun 2023 14:39:52 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10749"; a="715088952" X-IronPort-AV: E=Sophos;i="6.01,150,1684825200"; d="scan'208";a="715088952" Received: from djiang5-mobl3.amr.corp.intel.com (HELO [192.168.1.177]) ([10.212.53.238]) by orsmga002-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Jun 2023 14:39:52 -0700 Subject: [PATCH v4 4/6] acpi: Break out nesting for hmat_parse_locality() From: Dave Jiang To: linux-acpi@vger.kernel.org, linux-cxl@vger.kernel.org Cc: Jonathan Cameron , 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: Thu, 22 Jun 2023 14:39:51 -0700 Message-ID: <168746999176.4115467.17754893275430962012.stgit@djiang5-mobl3> In-Reply-To: <168746993412.4115467.1442857478644914777.stgit@djiang5-mobl3> References: <168746993412.4115467.1442857478644914777.stgit@djiang5-mobl3> User-Agent: StGit/1.5 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-cxl@vger.kernel.org Refactor hmat_parse_locality() to break up the deep nesting of the function. Suggested-by: Jonathan Cameron Reviewed-by: Jonathan Cameron Signed-off-by: Dave Jiang --- drivers/acpi/numa/hmat.c | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/drivers/acpi/numa/hmat.c b/drivers/acpi/numa/hmat.c index 8380460cfee2..957a38137c7e 100644 --- a/drivers/acpi/numa/hmat.c +++ b/drivers/acpi/numa/hmat.c @@ -321,11 +321,28 @@ static __init void hmat_add_locality(struct acpi_hmat_locality *hmat_loc) } } +static __init void hmat_update_target(unsigned int tgt_pxm, unsigned int init_pxm, + u8 mem_hier, u8 type, u32 value) +{ + struct memory_target *target = find_mem_target(tgt_pxm); + + if (mem_hier != ACPI_HMAT_MEMORY) + return; + + if (target && target->processor_pxm == init_pxm) { + 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(init_pxm), N_CPU)) + hmat_update_target_access(target, type, value, + NODE_ACCESS_CLASS_1); + } +} + static __init int hmat_parse_locality(union acpi_subtable_headers *header, const unsigned long end) { struct acpi_hmat_locality *hmat_loc = (void *)header; - struct memory_target *target; unsigned int init, targ, total_size, ipds, tpds; u32 *inits, *targs, value; u16 *entries; @@ -366,17 +383,8 @@ static __init int hmat_parse_locality(union acpi_subtable_headers *header, inits[init], targs[targ], value, hmat_data_type_suffix(type)); - 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, - 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, - NODE_ACCESS_CLASS_1); - } - } + hmat_update_target(targs[targ], inits[init], + mem_hier, type, value); } } From patchwork Thu Jun 22 21:39:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Jiang X-Patchwork-Id: 13289864 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 E082CEB64DA for ; Thu, 22 Jun 2023 21:40:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230500AbjFVVkB (ORCPT ); Thu, 22 Jun 2023 17:40:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40970 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231169AbjFVVkB (ORCPT ); Thu, 22 Jun 2023 17:40:01 -0400 Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 498D01FF2; Thu, 22 Jun 2023 14:39:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1687470000; x=1719006000; h=subject:from:to:cc:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=sHZ5t/CJlDxQ/VhbS29ah3TXA7eqcxmJ8g8pBXfnY08=; b=bTEeWgG2nHofz0QuHQZdM1hB0WuDnE8BOeT6K9DXOqPaxqAzXysNeVK7 qmqfQTgAqF2I5DcfHepTDS92FwjO0EPx8KigQC/QHXIOKxM1wRQzMrj2+ DyIujsYGIGQAl2bi7UGOlwwlExdKAdezkFmNxHakfDwEu+2OZa5+EeXU6 lA/lDxJwP7hN5a9bFfARU9OLg/Is4z8+HpqlOxKjYB53g6bBv+3aQzzXo itSpT2Uvuqy30xLMvHh+iU1jN2MBCVgttAROqLNT9OeNfqFwFgVHTlhUy op3ef8XT2q2Y1ss+caNtGgQoG3zAEkPxVPBhYI2G1HZO6XxVjGdziyq6S A==; X-IronPort-AV: E=McAfee;i="6600,9927,10749"; a="350383075" X-IronPort-AV: E=Sophos;i="6.01,150,1684825200"; d="scan'208";a="350383075" Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Jun 2023 14:39:59 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10749"; a="785080668" X-IronPort-AV: E=Sophos;i="6.01,150,1684825200"; d="scan'208";a="785080668" Received: from djiang5-mobl3.amr.corp.intel.com (HELO [192.168.1.177]) ([10.212.53.238]) by fmsmga004-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Jun 2023 14:39:58 -0700 Subject: [PATCH v4 5/6] 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: 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: Thu, 22 Jun 2023 14:39:58 -0700 Message-ID: <168746999799.4115467.1487303283396718524.stgit@djiang5-mobl3> In-Reply-To: <168746993412.4115467.1442857478644914777.stgit@djiang5-mobl3> References: <168746993412.4115467.1442857478644914777.stgit@djiang5-mobl3> User-Agent: StGit/1.5 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-cxl@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. Reviewed-by: Jonathan Cameron Signed-off-by: Dave Jiang --- v4: - Update device_handle to gen_port_device_handle. (Jonathan) - Reorder setting of access. (Jonathan) v3: - Drop continue after setting gen target access data. (Jonathan) 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 | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/acpi/numa/hmat.c b/drivers/acpi/numa/hmat.c index 957a38137c7e..aabd89c79e26 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, }; @@ -336,6 +337,10 @@ static __init void hmat_update_target(unsigned int tgt_pxm, unsigned int init_px if (node_state(pxm_to_node(init_pxm), N_CPU)) hmat_update_target_access(target, type, value, NODE_ACCESS_CLASS_1); + /* Update access from generic port target */ + if (*target->gen_port_device_handle) + hmat_update_target_access(target, type, value, + NODE_ACCESS_CLASS_GENPORT_SINK); } } From patchwork Thu Jun 22 21:40:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Jiang X-Patchwork-Id: 13289865 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 12AAFEB64DA for ; Thu, 22 Jun 2023 21:40:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231130AbjFVVkH (ORCPT ); Thu, 22 Jun 2023 17:40:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40994 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230262AbjFVVkG (ORCPT ); Thu, 22 Jun 2023 17:40:06 -0400 Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3FBE21FF1; Thu, 22 Jun 2023 14:40:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1687470005; x=1719006005; h=subject:from:to:cc:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=VReebXOV4skZQO6tXnZMZWd0m1aKAuLopzyT9MLDleI=; b=S6Et/bucu8RAYdDRjc0nOuSj7DU5pAmv2QfIwQ0p1cjUH6jNqpOo1ler NXnXoeB0/mVP6JlU1ViL0wJWuaglxKSquOyrFXiI4Jhp27czgWfgr4pC5 /VsBAK8weMEbLDqRRoabKGRdQjOvwy8rFXc7DmRS6UoMj5M55xezn7unJ m85nQ4+KgNeXLVrTppTLC67Kniwt2lmhu4/30RLAy48Va0Y2NvVo7lk8p 5vRMTsn60mnz3eEEY0suntysVSNvb5FFsu9++2vFx8MK6/GpvApVwrFyl uM4XlFhmxOGp0q5KfhtzsLP9NR0/S0tZ8Gcx5fl3XMaFwGS/AjjLBjsHf A==; X-IronPort-AV: E=McAfee;i="6600,9927,10749"; a="350383091" X-IronPort-AV: E=Sophos;i="6.01,150,1684825200"; d="scan'208";a="350383091" Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Jun 2023 14:40:04 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10749"; a="785080721" X-IronPort-AV: E=Sophos;i="6.01,150,1684825200"; d="scan'208";a="785080721" Received: from djiang5-mobl3.amr.corp.intel.com (HELO [192.168.1.177]) ([10.212.53.238]) by fmsmga004-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Jun 2023 14:40:04 -0700 Subject: [PATCH v4 6/6] 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: Thu, 22 Jun 2023 14:40:04 -0700 Message-ID: <168747000399.4115467.8583559086999809735.stgit@djiang5-mobl3> In-Reply-To: <168746993412.4115467.1442857478644914777.stgit@djiang5-mobl3> References: <168746993412.4115467.1442857478644914777.stgit@djiang5-mobl3> User-Agent: StGit/1.5 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-cxl@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 --- v4: - Update device_handle to gen_port_device_handle. (Jonathan) 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 aabd89c79e26..e3a29ddacbca 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->gen_port_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 bf3433747495..9f4ac0a39ab6 100644 --- a/include/linux/acpi.h +++ b/include/linux/acpi.h @@ -16,6 +16,7 @@ #include #include #include +#include struct irq_domain; struct irq_domain_ops; @@ -430,6 +431,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);