Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp370700rwe; Wed, 31 Aug 2022 04:25:42 -0700 (PDT) X-Google-Smtp-Source: AA6agR5pApGA4IU2AO2uJEnPoB2ZD7t98s+jSUY9b42Zw1TH2I5SYO4VmUqJ5eds8yTmtu9kIgXh X-Received: by 2002:a17:903:514:b0:172:dab0:b228 with SMTP id jn20-20020a170903051400b00172dab0b228mr24980957plb.170.1661945142503; Wed, 31 Aug 2022 04:25:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661945142; cv=none; d=google.com; s=arc-20160816; b=Mz6CBUCN95o4UpWJHl0j4WvOz+LXB0+kd8tH8vZ+2LF0PcVZKbEOLwaqpyeeRKcf7f gcnOShu6jMr1J0htdCrGu/sHkUgIaVCYp0QRR2ttUzZadX2VSTgeR7mBvp+v4gKIlkd4 IUKJpyutx6g5nbRxrdTnHegPquo4g61RLmaBj8AFFUe17Z5DMDXjjXaAOQhV3aceOyIH i5Bd+v5khJVlxbj1MwtEDQfguZe4KvvgdUEpmuEHHyLDKtj7m9mkICMwyLH/WC1hvhqO yJI0W3sOlt2ZA5rGvu0zd5CityQ+wYV+SLtX2Q/EH6RPBP3s3Mh56wZnmzbH9gnh7iqS farQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date; bh=+bQTwmVE/Ir9k7oPdpZqvOrmw7pJjxecxzmJWx+S7Gs=; b=NKKYoYaSmhkGEg72rdYFyUZDbOISmnT6mnOeV1WGEUNRwKPXK0OI3kGcTzfGWWuoo7 RGfB3S4YHikyqxRZUcuhnqaMiSETyjQCEeSA1uP1TH4+nRPdIAHFfnHUJspBce9iJEXs fxhWe/lFn4eljMnuzD3+rnx6rpdHoA8rZKe5B9cTGzSHEDNqTkG5oB3LUXWnATJ+jaMy 6xi/amZ3B/ERlmvbuC02F3hNOSBv10eIDDuHb6GZYI4QtaYiOx6I7FEV79KX4fTVdKgj nudtQn7F29MSCCZ3FW1jp6BybKL3MkXz8Qb9IO7Ix0dds1oDLBvT3+e/aiKlKb7k8qTc z/7g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h12-20020a056a00218c00b0052d939cdf27si5205590pfi.232.2022.08.31.04.25.30; Wed, 31 Aug 2022 04:25:42 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229882AbiHaLJR (ORCPT + 99 others); Wed, 31 Aug 2022 07:09:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45954 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229751AbiHaLJO (ORCPT ); Wed, 31 Aug 2022 07:09:14 -0400 Received: from frasgout.his.huawei.com (frasgout.his.huawei.com [185.176.79.56]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1A386CE33C; Wed, 31 Aug 2022 04:09:13 -0700 (PDT) Received: from fraeml703-chm.china.huawei.com (unknown [172.18.147.206]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4MHhHh25zkz6896k; Wed, 31 Aug 2022 19:08:32 +0800 (CST) Received: from lhrpeml500005.china.huawei.com (7.191.163.240) by fraeml703-chm.china.huawei.com (10.206.15.52) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2375.31; Wed, 31 Aug 2022 13:09:10 +0200 Received: from localhost (10.202.226.42) by lhrpeml500005.china.huawei.com (7.191.163.240) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Wed, 31 Aug 2022 12:09:10 +0100 Date: Wed, 31 Aug 2022 12:09:09 +0100 From: Jonathan Cameron To: Robert Richter CC: Alison Schofield , Vishal Verma , Ira Weiny , Ben Widawsky , Dan Williams , , , Bjorn Helgaas , "Rafael J. Wysocki" , Len Brown Subject: Re: [PATCH 10/15] cxl/acpi: Extract the RCH's RCRB base address from CEDT Message-ID: <20220831120909.00004e49@huawei.com> In-Reply-To: <20220831081603.3415-11-rrichter@amd.com> References: <20220831081603.3415-1-rrichter@amd.com> <20220831081603.3415-11-rrichter@amd.com> X-Mailer: Claws Mail 4.0.0 (GTK+ 3.24.29; i686-w64-mingw32) MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.202.226.42] X-ClientProxiedBy: lhrpeml100001.china.huawei.com (7.191.160.183) To lhrpeml500005.china.huawei.com (7.191.163.240) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 31 Aug 2022 10:15:58 +0200 Robert Richter wrote: > The downstream and upstream port Root Complex Register Blocks (RCRBs) > are needed to control the ports and CXL devices connected to it. It > also includes the location of the RCH/RCD downstream and upstream port > component registers in MEMBAR0. Extract the RCRB from the host's CEDT > entry. > > Signed-off-by: Robert Richter Hi Robert, One trivial comment inline. Reviewed-by: Jonathan Cameron > --- > drivers/cxl/acpi.c | 43 +++++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 43 insertions(+) > > diff --git a/drivers/cxl/acpi.c b/drivers/cxl/acpi.c > index b3146b7ae922..439df9df2741 100644 > --- a/drivers/cxl/acpi.c > +++ b/drivers/cxl/acpi.c > @@ -365,11 +365,48 @@ struct pci_host_bridge *cxl_find_next_rch(struct pci_host_bridge *host) > return NULL; > } > > +static int __cxl_get_rcrb(union acpi_subtable_headers *header, void *arg, > + const unsigned long end) > +{ > + struct cxl_chbs_context *ctx = arg; > + struct acpi_cedt_chbs *chbs; > + > + if (ctx->chbcr) > + return 0; > + > + chbs = (struct acpi_cedt_chbs *)header; > + > + if (ctx->uid != chbs->uid) > + return 0; > + > + if (chbs->cxl_version != ACPI_CEDT_CHBS_VERSION_CXL11) > + return 0; > + > + if (chbs->length != SZ_8K) > + return 0; > + > + ctx->chbcr = chbs->base; > + > + return 0; > +} > + > +static resource_size_t cxl_get_rcrb(u32 uid) > +{ > + struct cxl_chbs_context ctx = { > + .uid = uid, > + }; > + > + acpi_table_parse_cedt(ACPI_CEDT_TYPE_CHBS, __cxl_get_rcrb, &ctx); > + > + return ctx.chbcr; > +} > + > static int __init cxl_restricted_host_probe(struct platform_device *pdev) > { > struct pci_host_bridge *host = NULL; > struct acpi_device *adev; > unsigned long long uid = ~0; > + resource_size_t rcrb; Some of these could be made local to the while loop to reduce their scope. > > while ((host = cxl_find_next_rch(host)) != NULL) { > adev = ACPI_COMPANION(&host->dev); > @@ -382,6 +419,12 @@ static int __init cxl_restricted_host_probe(struct platform_device *pdev) > if (uid > U32_MAX) > continue; > > + rcrb = cxl_get_rcrb(uid); > + if (!rcrb) > + continue; > + > + dev_dbg(&host->dev, "RCRB found: 0x%08llx\n", (u64)rcrb); > + > dev_info(&host->dev, "host supports CXL\n"); > } >