Received: by 2002:ab2:1689:0:b0:1f7:5705:b850 with SMTP id d9csp2153250lqa; Tue, 30 Apr 2024 09:23:34 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWdIVVaAS899O7ZcxnseNb1h9T3HJTifWjaaXseklrcnQj2XDo+7guLzhHi1lFpjXT/44BfOsSKbls14udMqfiyc7xprAWXzAh4R9eZjw== X-Google-Smtp-Source: AGHT+IGo1fzwXVaAYNzjm/x2QTr4q1kpefGJ/nr11bNdg4+39Mf50wH0oyopPy/4nHr7AidHXBD6 X-Received: by 2002:a17:902:eb91:b0:1ec:5104:c75a with SMTP id q17-20020a170902eb9100b001ec5104c75amr1913281plg.41.1714494214539; Tue, 30 Apr 2024 09:23:34 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714494214; cv=pass; d=google.com; s=arc-20160816; b=yApl063fO2wd7e3GggYEXKSqphsu/Y+smeK+cYbHTRp9CpjtYj18AXiNNamWRUQGur JlzGZ2pEhoy4im9uHNSLd0OzHEtB8G3coawoPcUS0G7MFRMweV5Iypd+WGkquAdMAfqC fJiia0uOe+4IBjieHqQGneaTpxOxf3nJOW9mSW+YNMIIbHHVv1wyzBjDOVDbCS7nhMAO v0zCxXg8j9Nx03UXtk7yd+Puzd20/cGCspzE4WK1AeymQ7GXOssqcSKIShkN3Cp9Awes tD1Q2B4y7GFhaDCNOio/36uwk/HZ30iKoiAzg7GRBdPhHtit8SCOBMkJg6OsUB8vOthN w8ag== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:organization:references :in-reply-to:message-id:subject:cc:to:from:date; bh=Tnb7Hxbv0JuWJgy3RS0TOwGs31zjwDdH2zxuoW6hbOI=; fh=v+uN1CX8SIW6cfZxUDO9MwNXhddyjxsxfYwsLYtZ00I=; b=MJJwbJerx+c8ttJV/ZfCQ0z4lNFt51MSvsgsFJ8dGOrTKt+cDk8JrTkFnActvyCpSg lXw0SNNHuqGXh3lNCFnrzabxPUtvLTQPdLsiZibMp4EfZ92fftC4de27y4b0lGBXJ350 Avah9451iWW9mHqbgINCvl1pnJmOGpU/j66Mx5c4fbE8CtQrBDBtppsURWAcJSNsvUVt wZ7oiVF16f3BckTmbb4+UibLSQdeT9vX6ZSJVxbQ6RTs68O5+jEOlmw4KzzTUY8QjpUG DxIM7j8aTMxj1R+lHYxBestQeLHxnXZEsoc2suW3To6juU4RPiCwN1cgns5FLhYasZq1 0MwQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=huawei.com dmarc=pass fromdomain=huawei.com); spf=pass (google.com: domain of linux-kernel+bounces-164360-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-164360-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id lv15-20020a1709032a8f00b001ec2cfa6b27si2144378plb.266.2024.04.30.09.23.34 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Apr 2024 09:23:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-164360-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=huawei.com dmarc=pass fromdomain=huawei.com); spf=pass (google.com: domain of linux-kernel+bounces-164360-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-164360-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 25992285AAA for ; Tue, 30 Apr 2024 16:22:57 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1D48F179658; Tue, 30 Apr 2024 16:22:42 +0000 (UTC) Received: from frasgout.his.huawei.com (frasgout.his.huawei.com [185.176.79.56]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4140B176FB2; Tue, 30 Apr 2024 16:22:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.176.79.56 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714494161; cv=none; b=JDvzAarAcbfLK6AtenPLVEgVR3ofCnh6wqQER/ytjEUzeaibk0PyLVRrV6zV3k00L4KHMow2QlVgAN8MUvc/Vr5dDpVOTBwCwTVYnIv3rTCaC7R2YPCmNwSJ0i6B8IIoU3cmoN9RmSQW+bPpAWw0GVg4RHMadB07+FGcYT31l4o= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714494161; c=relaxed/simple; bh=nHIY0JruljXXmK/rAV01B+Ul74H6SRPBbc8c8KF2kxg=; h=Date:From:To:CC:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=GUf05fOq+FIIvrL+fwrzcW4VO49aIKtkoi0oycTWKLO3rh6lp+o/JCEuQGE9rqkVBHqORQyAuzjCgqNS89hMFESj6/SXbWiIJW18GYyFeMGR4RY7KM8FN3ASIGupCfNDRe5suKJ7noAWbBwZ4a2NNfsxMxMIE8WZtRpcpACf4Q0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=Huawei.com; spf=pass smtp.mailfrom=huawei.com; arc=none smtp.client-ip=185.176.79.56 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=Huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Received: from mail.maildlp.com (unknown [172.18.186.231]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4VTQQM6t17z6GCjQ; Wed, 1 May 2024 00:19:55 +0800 (CST) Received: from lhrpeml500005.china.huawei.com (unknown [7.191.163.240]) by mail.maildlp.com (Postfix) with ESMTPS id 69784140B55; Wed, 1 May 2024 00:22:33 +0800 (CST) Received: from localhost (10.202.227.76) by lhrpeml500005.china.huawei.com (7.191.163.240) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.35; Tue, 30 Apr 2024 17:22:32 +0100 Date: Tue, 30 Apr 2024 17:22:31 +0100 From: Jonathan Cameron To: Robert Richter CC: "Rafael J. Wysocki" , Dave Hansen , Dan Williams , Alison Schofield , , , , Len Brown Subject: Re: [PATCH v6 7/7] ACPI/NUMA: Print CXL Early Discovery Table (CEDT) Message-ID: <20240430172231.00002bd5@Huawei.com> In-Reply-To: <20240430092200.2335887-8-rrichter@amd.com> References: <20240430092200.2335887-1-rrichter@amd.com> <20240430092200.2335887-8-rrichter@amd.com> Organization: Huawei Technologies Research and Development (UK) Ltd. X-Mailer: Claws Mail 4.1.0 (GTK 3.24.33; x86_64-w64-mingw32) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit X-ClientProxiedBy: lhrpeml100004.china.huawei.com (7.191.162.219) To lhrpeml500005.china.huawei.com (7.191.163.240) On Tue, 30 Apr 2024 11:22:00 +0200 Robert Richter wrote: > The CEDT contains similar entries as the SRAT. For diagnostic reasons > print the CEDT same style as the SRAT. > > Signed-off-by: Robert Richter I'm fairly sure the interleave ways conversion is wrong. Otherwise all trivial stuff. Jonathan > --- > drivers/acpi/numa/srat.c | 111 +++++++++++++++++++++++++++++++++++++++ > 1 file changed, 111 insertions(+) > > diff --git a/drivers/acpi/numa/srat.c b/drivers/acpi/numa/srat.c > index 34ecf2dc912f..fa21d4d5fccf 100644 > --- a/drivers/acpi/numa/srat.c > +++ b/drivers/acpi/numa/srat.c > @@ -320,6 +320,114 @@ acpi_parse_memory_affinity(union acpi_subtable_headers *header, > return 0; > } > > +static int __init > +__acpi_table_print_cedt_entry(union acpi_subtable_headers *__header, > + void *arg, const unsigned long table_end) > +{ > + struct acpi_cedt_header *header = (struct acpi_cedt_header *)__header; > + > + switch (header->type) { > + case ACPI_CEDT_TYPE_CHBS: > + { > + struct acpi_cedt_chbs *p = > + (struct acpi_cedt_chbs *)header; > + > + if (header->length < sizeof(struct acpi_cedt_chbs)) { > + pr_warn("CEDT: unsupported CHBS entry: size %d\n", > + header->length); > + break; Might as well return. > + } > + > + pr_debug("CEDT: CHBS (0x%llx length 0x%llx uid %lu) %s (%d)\n", > + (unsigned long long)p->base, > + (unsigned long long)p->length, The printk docs https://docs.kernel.org/core-api/printk-formats.html suggest you shouldn't need the casts though I appreciate other functions in here are doing this. > + (unsigned long)p->uid, > + (p->cxl_version == ACPI_CEDT_CHBS_VERSION_CXL11) ? > + "cxl11" : > + (p->cxl_version == ACPI_CEDT_CHBS_VERSION_CXL20) ? > + "cxl20" : > + "unsupported version", That seems harsh. Like all ACPI tables, these should be backwards compatible. So not so much unsupported as "newer version". Breakage happens, but it is rare and for the rest of the kernel I don' think we check this. Also can we switch to the 3.1 spec terms. RCH etc. Though the term for 2.0+ in the table definition for CHBS is the nasty: "Host Bridge that is associated with one or more CXL root ports." > + p->cxl_version); > + } > + break; Trivial but I love early returns as they tend to avoid lots of scrolling to see where the break goes and it is unlikely there will ever be anything to do after this. > + case ACPI_CEDT_TYPE_CFMWS: > + { > + struct acpi_cedt_cfmws *p = > + (struct acpi_cedt_cfmws *)header; > + int eiw_to_ways[] = {1, 2, 4, 8, 16, 3, 6, 12}; > + int targets = -1; > + > + if (header->length < sizeof(struct acpi_cedt_cfmws)) { > + pr_warn("CEDT: unsupported CFMWS entry: size %d\n", > + header->length); > + break; Might as well return. > + } > + > + if (p->interleave_ways < ARRAY_SIZE(eiw_to_ways)) > + targets = eiw_to_ways[p->interleave_ways]; That looks wrong for 3, 6, 12 as index is 0x8, 0x9, 0xA not 5 6 7 Don't we have a function to decode this somewhere than can be reused? > + if (header->length < struct_size( > + p, interleave_targets, targets)) > + targets = -1; > + > + pr_debug("CEDT: CFMWS (0x%llx length 0x%llx) with %d target%s", > + (unsigned long long)p->base_hpa, > + (unsigned long long)p->window_size, > + targets, targets > 1 ? "s" : ""); > + for (int i = 0; i < targets; i++) > + pr_cont("%s%lu", i ? ", " : " (", > + (unsigned long)p->interleave_targets[i]); > + pr_cont("%s%s%s%s%s%s\n", > + targets > 0 ? ")" : "", > + (p->restrictions & ACPI_CEDT_CFMWS_RESTRICT_TYPE2) ? > + " type2" : "", > + (p->restrictions & ACPI_CEDT_CFMWS_RESTRICT_TYPE3) ? > + " type3" : "", > + (p->restrictions & ACPI_CEDT_CFMWS_RESTRICT_VOLATILE) ? > + " volatile" : "", > + (p->restrictions & ACPI_CEDT_CFMWS_RESTRICT_PMEM) ? > + " pmem" : "", > + (p->restrictions & ACPI_CEDT_CFMWS_RESTRICT_FIXED) ? > + " fixed" : ""); > + } > + break; return > + case ACPI_CEDT_TYPE_CXIMS: > + { > + struct acpi_cedt_cxims *p = > + (struct acpi_cedt_cxims *)header; > + > + if (header->length < sizeof(struct acpi_cedt_cxims)) { > + pr_warn("CEDT: unsupported CXIMS entry: size %d\n", > + header->length); > + break; return > + } > + > + pr_debug("CEDT: CXIMS (hbig %u nr_xormaps %u)\n", > + (unsigned int)p->hbig, > + (unsigned int)p->nr_xormaps); > + } > + break; return > + default: > + pr_warn("CEDT: Found unsupported entry (type = 0x%x)\n", > + header->type); > + break; return > + } > + > + return 0; > +} > + > +static void __init acpi_table_print_cedt_entry(enum acpi_cedt_type id) > +{ > + acpi_table_parse_cedt(id, __acpi_table_print_cedt_entry, NULL); > +} > + > +static void __init acpi_table_print_cedt(void) > +{ > + /* Print only implemented CEDT types */ > + acpi_table_print_cedt_entry(ACPI_CEDT_TYPE_CHBS); > + acpi_table_print_cedt_entry(ACPI_CEDT_TYPE_CFMWS); > + acpi_table_print_cedt_entry(ACPI_CEDT_TYPE_CXIMS); > +} > + > static int __init acpi_parse_cfmws(union acpi_subtable_headers *header, > void *arg, const unsigned long table_end) > { > @@ -518,6 +626,9 @@ int __init acpi_numa_init(void) > /* SLIT: System Locality Information Table */ > acpi_table_parse(ACPI_SIG_SLIT, acpi_parse_slit); > > + /* CEDT: CXL Early Discovery Table */ > + acpi_table_print_cedt(); > + > /* > * CXL Fixed Memory Window Structures (CFMWS) must be parsed > * after the SRAT. Create NUMA Nodes for CXL memory ranges that