From patchwork Mon Mar 27 21:45:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Jiang X-Patchwork-Id: 667482 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 94AF3C77B74 for ; Mon, 27 Mar 2023 21:45:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230386AbjC0Vpb (ORCPT ); Mon, 27 Mar 2023 17:45:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57786 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229492AbjC0VpZ (ORCPT ); Mon, 27 Mar 2023 17:45:25 -0400 Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 46BC32696; Mon, 27 Mar 2023 14:45:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1679953524; x=1711489524; h=subject:from:to:cc:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=AVA14HQNfCIA/61q7aYrlg12qAV568Fd3pbtDzEXaKQ=; b=NslgtMU9tc6s7h33YOsvO+9nF7HwJW9vhc9C36/6irjyR0t5T/yO7CQF PtE7wQ2DkqYHcKhz+3JBp0nGYI9rhZ7uSCpBDVchQ1Xa/n+GEKDzd7evN Dt6j0UWUcJ5ku15PwC5lHh+majWTiiGnDETRH9bHWVUi2faMv6q6bRj3C QPrIyIsZpAyBwLb8SGUTWbk7fhttZpTkuYUfnasozet0RiIKbfagz6k89 lVzsSgJRpBL4eA5wQPx5mvvUQvs5gkxGhz8U8W4yBlhXMc2aXU+omFwUq 7hdrPPaaqKJFVZHzYR+bxvcGCNKZsZ3pUc0GaC6Jyi6aEw0S5gyle2pue A==; X-IronPort-AV: E=McAfee;i="6600,9927,10662"; a="320799066" X-IronPort-AV: E=Sophos;i="5.98,295,1673942400"; d="scan'208";a="320799066" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Mar 2023 14:45:23 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10662"; a="660958485" X-IronPort-AV: E=Sophos;i="5.98,295,1673942400"; d="scan'208";a="660958485" Received: from spal2-desk3.gar.corp.intel.com (HELO [192.168.1.177]) ([10.212.91.66]) by orsmga006-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Mar 2023 14:45:23 -0700 Subject: [PATCH v2 13/21] ACPI: NUMA: Add genport target allocation to the HMAT parsing From: Dave Jiang To: linux-cxl@vger.kernel.org, linux-acpi@vger.kernel.org Cc: dan.j.williams@intel.com, ira.weiny@intel.com, vishal.l.verma@intel.com, alison.schofield@intel.com, rafael@kernel.org, lukas@wunner.de Date: Mon, 27 Mar 2023 14:45:22 -0700 Message-ID: <167995352251.2857312.3324792978023135511.stgit@djiang5-mobl3> In-Reply-To: <167995336797.2857312.539473939839316778.stgit@djiang5-mobl3> References: <167995336797.2857312.539473939839316778.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 devie handle will serve as the key to search for target data. Signed-off-by: Dave Jiang --- drivers/acpi/numa/hmat.c | 51 ++++++++++++++++++++++++++++++++++++++++++++++ include/acpi/actbl3.h | 2 ++ 2 files changed, 53 insertions(+) diff --git a/drivers/acpi/numa/hmat.c b/drivers/acpi/numa/hmat.c index bba268ecd802..8879c4576cf5 100644 --- a/drivers/acpi/numa/hmat.c +++ b/drivers/acpi/numa/hmat.c @@ -65,6 +65,7 @@ struct memory_target { struct node_hmem_attrs hmem_attrs[2]; struct list_head caches; struct node_cache_attrs cache_attrs; + u8 device_handle[ACPI_SRAT_DEVICE_HANDLE_SIZE]; bool registered; }; @@ -151,6 +152,33 @@ 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 = find_mem_target(mem_pxm); + if (!target) { + target = kzalloc(sizeof(*target), GFP_KERNEL); + if (!target) + return; + target->memory_pxm = mem_pxm; + target->processor_pxm = PXM_INVAL; + target->memregions = (struct resource) { + .name = "ACPI genport", + .start = 0, + .end = -1, + .flags = IORESOURCE_MEM, + }; + memcpy(target->device_handle, handle, + ACPI_SRAT_DEVICE_HANDLE_SIZE); + list_add_tail(&target->node, &targets); + INIT_LIST_HEAD(&target->caches); + } else { + memcpy(target->device_handle, handle, + ACPI_SRAT_DEVICE_HANDLE_SIZE); + } +} + static __init const char *hmat_data_type(u8 type) { switch (type) { @@ -490,6 +518,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) @@ -835,6 +879,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 832c6464f063..0daf5a94f08a 100644 --- a/include/acpi/actbl3.h +++ b/include/acpi/actbl3.h @@ -289,6 +289,8 @@ struct acpi_srat_generic_affinity { u32 reserved1; }; +#define ACPI_SRAT_DEVICE_HANDLE_SIZE 16 + /* Flags for struct acpi_srat_generic_affinity */ #define ACPI_SRAT_GENERIC_AFFINITY_ENABLED (1) /* 00: Use affinity structure */