Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp395499rwe; Wed, 31 Aug 2022 04:53:32 -0700 (PDT) X-Google-Smtp-Source: AA6agR6kfqo1FiWG8eKazDt+QJHRIbZxtIqqF+1WEhQOvaGQBHWbSDQi0q+4vLHPv3BchQ5z1EEA X-Received: by 2002:a17:902:7296:b0:173:a75b:6539 with SMTP id d22-20020a170902729600b00173a75b6539mr25886035pll.127.1661946812235; Wed, 31 Aug 2022 04:53:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661946812; cv=none; d=google.com; s=arc-20160816; b=VtCAsw28/J6L3tZpqjEaOzcOG5IMAHTgurpjL60KIwYU6bVk0mVyouoB0P8hMFKj8+ ANjRam1OVj9XWY08N4qWONEdl4M5/eEjUFgRnCeN01AKmCosgKo6iDH/kJvj5NXDU2X+ CVvBkQlCfNazDnxk+5FjyDEogXdC/JaKzhYe0OHU+wlvozkaNy8NLQiVp5kNPWIDPaKB Y3hELXh5QcI2E/dEWUGJgZ19+RzvMWyeV67jIFoZP3dnSsgpMADGuDElaeWnh899oLL1 e3vl7sz0ypZ2CQ7mIXe0HzpheFKlJAKVWM5UFLfoeAwW3OQhKk8yY5dmJcU2VUdYxN1z 2bUg== 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=VwgK5BRTqgLwu/CKyMRAoDKn0mhYZyFhHXghUCTSCJg=; b=SJr56LKPC7aNK6JuUb3lenOTqnl8uHQjm8Sxmqd+l8JT+JV7PR9MsBhwA2LyhekSKR 4/Bmnjxz6eedKUauhVUdCKXQBhkdZKtL0tWrXIEMin4dA2xl42w32/cvteaXrnhbL4gD 6h7QSE9jpqledcOjggXs2orsr63Ba/15r9ufpNp9a3e8Cw0bCAogMJxhrKBvuyQTt0se P88j9W1zdv7HJ7kLeRIHA6aA+5t5SAKUm4OXJLd57c/XSfAnzWCtecvEmGhAFK6evrGK SsHTfo++dSvbbrYVzOgdJXQBZYkQGyygaJYezXuBwQqB5F7DEH/C5OPFZQIhD2IVZfpy os/Q== 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 t185-20020a6381c2000000b0042a37db75f6si4562252pgd.535.2022.08.31.04.53.21; Wed, 31 Aug 2022 04:53:32 -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 S230434AbiHaLM2 (ORCPT + 99 others); Wed, 31 Aug 2022 07:12:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51736 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230313AbiHaLM0 (ORCPT ); Wed, 31 Aug 2022 07:12:26 -0400 Received: from frasgout.his.huawei.com (frasgout.his.huawei.com [185.176.79.56]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9FE8CD0235; Wed, 31 Aug 2022 04:12:25 -0700 (PDT) Received: from fraeml709-chm.china.huawei.com (unknown [172.18.147.226]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4MHhMV0yCZz67xg5; Wed, 31 Aug 2022 19:11:50 +0800 (CST) Received: from lhrpeml500005.china.huawei.com (7.191.163.240) by fraeml709-chm.china.huawei.com (10.206.15.37) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Wed, 31 Aug 2022 13:12:23 +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:12:23 +0100 Date: Wed, 31 Aug 2022 12:12:22 +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 08/15] cxl/acpi: Check RCH's CXL DVSEC capabilities Message-ID: <20220831121222.00000977@huawei.com> In-Reply-To: <20220831115224.00003afd@huawei.com> References: <20220831081603.3415-1-rrichter@amd.com> <20220831081603.3415-9-rrichter@amd.com> <20220831115224.00003afd@huawei.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 11:52:24 +0100 Jonathan Cameron wrote: > On Wed, 31 Aug 2022 10:15:56 +0200 > Robert Richter wrote: > > > An RCH has an RCiEP connected to it with CXL DVSEC capabilities > > present and the CXL PCIe DVSEC included. Check this. > > > > Signed-off-by: Robert Richter > One comment inline. This looks good to me. > > Reviewed-by: Jonathan Cameron > > > --- > > drivers/cxl/acpi.c | 17 +++++++++++++++++ > > 1 file changed, 17 insertions(+) > > > > diff --git a/drivers/cxl/acpi.c b/drivers/cxl/acpi.c > > index ffdf439adb87..f9cdf23a91a8 100644 > > --- a/drivers/cxl/acpi.c > > +++ b/drivers/cxl/acpi.c > > @@ -322,6 +322,8 @@ struct pci_host_bridge *cxl_find_next_rch(struct pci_host_bridge *host) > > { > > struct pci_bus *bus = host ? host->bus : NULL; > > struct acpi_device *adev; > > + struct pci_dev *pdev; > > + bool is_restricted_host; > > > > while ((bus = pci_find_next_bus(bus)) != NULL) { > > host = bus ? to_pci_host_bridge(bus->bridge) : NULL; > > @@ -343,6 +345,20 @@ struct pci_host_bridge *cxl_find_next_rch(struct pci_host_bridge *host) > > dev_dbg(&host->dev, "PCI ACPI host found: %s\n", > > acpi_dev_name(adev)); > > > > + /* Check CXL DVSEC of dev 0 func 0 */ > > So assumption here is that the hostbridge has a one or more RCiEPs. > The spec (r3.0 9.11.4) allows for the EP to appear behind a root port > - that case always felt odd to me, so I'm fine with not supporting it until > we see a user. > > > + pdev = pci_get_slot(bus, PCI_DEVFN(0, 0)); > > + is_restricted_host = pdev > > + && (pci_pcie_type(pdev) == PCI_EXP_TYPE_RC_END) > > + && pci_find_dvsec_capability(pdev, > > + PCI_DVSEC_VENDOR_ID_CXL, > > + CXL_DVSEC_PCIE_DEVICE); Thinking a bit more on this. I'm not sure this is sufficient. Nothing in CXL 2.0 or later prevents true RCiEP devices (there are a few references in CXL 3.0 e.g. 9.12.1 has RCDs or CXL RCiEPs - so just detecting that there is one on the host bridge might not be sufficient to distinguish this from a non RCH / RCB. > > + pci_dev_put(pdev); > > + > > + if (!is_restricted_host) > > + continue; > > + > > + dev_dbg(&host->dev, "CXL restricted host found\n"); > > + > > return host; > > } > > > > @@ -354,6 +370,7 @@ static int __init cxl_restricted_host_probe(struct platform_device *pdev) > > struct pci_host_bridge *host = NULL; > > > > while ((host = cxl_find_next_rch(host)) != NULL) { > > + dev_info(&host->dev, "host supports CXL\n"); > > } > > > > return 0; >