From patchwork Mon Jul 13 15:55:55 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Cameron X-Patchwork-Id: 235474 Delivered-To: patch@linaro.org Received: by 2002:a92:d244:0:0:0:0:0 with SMTP id v4csp2959613ilg; Mon, 13 Jul 2020 08:58:04 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw+T3NIIpKxguPuBoUKJSoOkKdIkkdbPElplNxDAioAXK1beOZtWM66b8Yc9HIyH5jV3qa3 X-Received: by 2002:a17:906:c0da:: with SMTP id bn26mr382590ejb.359.1594655884768; Mon, 13 Jul 2020 08:58:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594655884; cv=none; d=google.com; s=arc-20160816; b=lTwUYqIvyt9NdwTW8LkVZFgruTFeVqcAaao+nhFH3TS4j8lnECNOzIxdcOe5aLJL7B lDsNiqs0zv4/jZyCPbjQQV5+/dKxrOAZ5EGo8IavSieZ2Mexs+GV77MIH5gZMzrM3y7O x/WZ9n51vFc9cKFC9Va/orWKpoXHarG4qKGInC7dvT6W4HJQZsXGjSC192r9fsyKi1Zt Q9wW9WYZxJJZf2OZcNPz1cuLVfvmXo3jQk/3AGdbVipLO4vd5cNAR7ztjjSOxOD+Nwlu 5DO4tY2pxuepGEqHSQuADplSePOxQPelzfbTCUSOx4qwiXINeExTKcNHPYIxrQ0be48h 4Clg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=n2/fVIoE54GGEgSGCV8EdDqxD5gvJhI7NL4dwFMJ9yY=; b=R0peH5OA+fDLICvH89HR488t9ITEh4HFMtz8jhtbeBxOSCsDZxNtKpUdhkAgcHFjEx /ZKJrU4/PpEhNbDXptYiktS6e3lnu4pZouIzLVQS6wpOmLgYoOF/ln1d0jVsLzPEVTWS T+y7+XtaAYFpaoPzd6rDX1Pd/55pnDfuK54KS6FhhMFACh+v9KvH0B+PnIgvTWKbzbR0 UZzM49Nd3m4yp8qMGzAs25Y1QF0Y9CELI16BQo0IoDOB9qIo8+DqVXp2O7LyQFtyc6Vu Y1U48fXbFYL07wUdEFay4TrsaoT+XtQCV3+w9BUOEZUjEtrKbDWgKLPwj/qYFLDmEpuH yUHA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-acpi-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-acpi-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id x70si10927380ede.405.2020.07.13.08.58.04; Mon, 13 Jul 2020 08:58:04 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-acpi-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-acpi-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-acpi-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729764AbgGMP6E (ORCPT + 7 others); Mon, 13 Jul 2020 11:58:04 -0400 Received: from lhrrgout.huawei.com ([185.176.76.210]:2464 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1729027AbgGMP6D (ORCPT ); Mon, 13 Jul 2020 11:58:03 -0400 Received: from lhreml710-chm.china.huawei.com (unknown [172.18.7.107]) by Forcepoint Email with ESMTP id A314B50C6533A0D59C42; Mon, 13 Jul 2020 16:58:02 +0100 (IST) Received: from lhrphicprd00229.huawei.com (10.123.41.22) by lhreml710-chm.china.huawei.com (10.201.108.61) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1913.5; Mon, 13 Jul 2020 16:58:02 +0100 From: Jonathan Cameron To: , , , CC: Lorenzo Pieralisi , Bjorn Helgaas , , , Ingo Molnar , Thomas Gleixner , , Dan Williams , Brice Goglin , Jonathan Cameron Subject: [PATCH v7 1/6] ACPI: Support Generic Initiator only domains Date: Mon, 13 Jul 2020 23:55:55 +0800 Message-ID: <20200713155600.2272743-2-Jonathan.Cameron@huawei.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20200713155600.2272743-1-Jonathan.Cameron@huawei.com> References: <20200713155600.2272743-1-Jonathan.Cameron@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.123.41.22] X-ClientProxiedBy: lhreml745-chm.china.huawei.com (10.201.108.195) To lhreml710-chm.china.huawei.com (10.201.108.61) X-CFilter-Loop: Reflected Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org Generic Initiators are a new ACPI concept that allows for the description of proximity domains that contain a device which performs memory access (such as a network card) but neither host CPU nor Memory. This patch has the parsing code and provides the infrastructure for an architecture to associate these new domains with their nearest memory processing node. Signed-off-by: Jonathan Cameron --- drivers/acpi/numa/srat.c | 60 +++++++++++++++++++++++++++++++++++++++- drivers/base/node.c | 3 ++ include/linux/nodemask.h | 1 + 3 files changed, 63 insertions(+), 1 deletion(-) -- 2.19.1 diff --git a/drivers/acpi/numa/srat.c b/drivers/acpi/numa/srat.c index ed7d31795f4d..b71941437326 100644 --- a/drivers/acpi/numa/srat.c +++ b/drivers/acpi/numa/srat.c @@ -130,6 +130,36 @@ acpi_table_print_srat_entry(struct acpi_subtable_header *header) } break; + case ACPI_SRAT_TYPE_GENERIC_AFFINITY: + { + struct acpi_srat_generic_affinity *p = + (struct acpi_srat_generic_affinity *)header; + + if (p->device_handle_type == 0) { + /* + * For pci devices this may be the only place they + * are assigned a proximity domain + */ + pr_debug("SRAT Generic Initiator(Seg:%u BDF:%u) in proximity domain %d %s\n", + *(u16 *)(&p->device_handle[0]), + *(u16 *)(&p->device_handle[2]), + p->proximity_domain, + (p->flags & ACPI_SRAT_GENERIC_AFFINITY_ENABLED) ? + "enabled" : "disabled"); + } else { + /* + * In this case we can rely on the device having a + * proximity domain reference + */ + pr_debug("SRAT Generic Initiator(HID=%.8s UID=%.4s) in proximity domain %d %s\n", + (char *)(&p->device_handle[0]), + (char *)(&p->device_handle[8]), + p->proximity_domain, + (p->flags & ACPI_SRAT_GENERIC_AFFINITY_ENABLED) ? + "enabled" : "disabled"); + } + } + break; default: pr_warn("Found unsupported SRAT entry (type = 0x%x)\n", header->type); @@ -338,6 +368,32 @@ acpi_parse_gicc_affinity(union acpi_subtable_headers *header, return 0; } +static int __init +acpi_parse_gi_affinity(union acpi_subtable_headers *header, + const unsigned long end) +{ + struct acpi_srat_generic_affinity *gi_affinity; + int node; + + gi_affinity = (struct acpi_srat_generic_affinity *)header; + if (!gi_affinity) + return -EINVAL; + acpi_table_print_srat_entry(&header->common); + + if (!(gi_affinity->flags & ACPI_SRAT_GENERIC_AFFINITY_ENABLED)) + return -EINVAL; + + node = acpi_map_pxm_to_node(gi_affinity->proximity_domain, true); + if (node == NUMA_NO_NODE || node >= MAX_NUMNODES) { + pr_err("SRAT: Too many proximity domains.\n"); + return -EINVAL; + } + node_set(node, numa_nodes_parsed); + node_set_state(node, N_GENERIC_INITIATOR); + + return 0; +} + static int __initdata parsed_numa_memblks; static int __init @@ -393,7 +449,7 @@ int __init acpi_numa_init(void) /* SRAT: System Resource Affinity Table */ if (!acpi_table_parse(ACPI_SIG_SRAT, acpi_parse_srat)) { - struct acpi_subtable_proc srat_proc[3]; + struct acpi_subtable_proc srat_proc[4]; memset(srat_proc, 0, sizeof(srat_proc)); srat_proc[0].id = ACPI_SRAT_TYPE_CPU_AFFINITY; @@ -402,6 +458,8 @@ int __init acpi_numa_init(void) srat_proc[1].handler = acpi_parse_x2apic_affinity; srat_proc[2].id = ACPI_SRAT_TYPE_GICC_AFFINITY; srat_proc[2].handler = acpi_parse_gicc_affinity; + srat_proc[3].id = ACPI_SRAT_TYPE_GENERIC_AFFINITY; + srat_proc[3].handler = acpi_parse_gi_affinity; acpi_table_parse_entries_array(ACPI_SIG_SRAT, sizeof(struct acpi_table_srat), diff --git a/drivers/base/node.c b/drivers/base/node.c index 5b02f69769e8..1a7bd5860f3c 100644 --- a/drivers/base/node.c +++ b/drivers/base/node.c @@ -980,6 +980,8 @@ static struct node_attr node_state_attr[] = { #endif [N_MEMORY] = _NODE_ATTR(has_memory, N_MEMORY), [N_CPU] = _NODE_ATTR(has_cpu, N_CPU), + [N_GENERIC_INITIATOR] = _NODE_ATTR(has_generic_initiator, + N_GENERIC_INITIATOR), }; static struct attribute *node_state_attrs[] = { @@ -991,6 +993,7 @@ static struct attribute *node_state_attrs[] = { #endif &node_state_attr[N_MEMORY].attr.attr, &node_state_attr[N_CPU].attr.attr, + &node_state_attr[N_GENERIC_INITIATOR].attr.attr, NULL }; diff --git a/include/linux/nodemask.h b/include/linux/nodemask.h index 27e7fa36f707..3334ce056335 100644 --- a/include/linux/nodemask.h +++ b/include/linux/nodemask.h @@ -399,6 +399,7 @@ enum node_states { #endif N_MEMORY, /* The node has memory(regular, high, movable) */ N_CPU, /* The node has one or more cpus */ + N_GENERIC_INITIATOR, /* The node has one or more Generic Initiators */ NR_NODE_STATES };