From mboxrd@z Thu Jan 1 00:00:00 1970 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 05B45ECAAD4 for ; Wed, 31 Aug 2022 11:00:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229877AbiHaLAg (ORCPT ); Wed, 31 Aug 2022 07:00:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34098 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229556AbiHaLAc (ORCPT ); Wed, 31 Aug 2022 07:00:32 -0400 Received: from frasgout.his.huawei.com (frasgout.his.huawei.com [185.176.79.56]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7A0826BD65; Wed, 31 Aug 2022 04:00:31 -0700 (PDT) Received: from fraeml738-chm.china.huawei.com (unknown [172.18.147.200]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4MHh5g2jxVz67QPl; Wed, 31 Aug 2022 18:59:51 +0800 (CST) Received: from lhrpeml500005.china.huawei.com (7.191.163.240) by fraeml738-chm.china.huawei.com (10.206.15.219) 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:00:29 +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:00:29 +0100 Date: Wed, 31 Aug 2022 12:00:27 +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 09/15] cxl/acpi: Determine PCI host bridge's ACPI UID Message-ID: <20220831120027.000017b3@huawei.com> In-Reply-To: <20220831081603.3415-10-rrichter@amd.com> References: <20220831081603.3415-1-rrichter@amd.com> <20220831081603.3415-10-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: lhrpeml500002.china.huawei.com (7.191.160.78) To lhrpeml500005.china.huawei.com (7.191.163.240) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 31 Aug 2022 10:15:57 +0200 Robert Richter wrote: > The UID is needed to read the RCH's CEDT entry with the RCRB base > address. Determine the host's UID from its ACPI fw node. > > Signed-off-by: Robert Richter > --- > drivers/cxl/acpi.c | 12 ++++++++++++ > 1 file changed, 12 insertions(+) > > diff --git a/drivers/cxl/acpi.c b/drivers/cxl/acpi.c > index f9cdf23a91a8..b3146b7ae922 100644 > --- a/drivers/cxl/acpi.c > +++ b/drivers/cxl/acpi.c > @@ -368,8 +368,20 @@ struct pci_host_bridge *cxl_find_next_rch(struct pci_host_bridge *host) > 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; > > while ((host = cxl_find_next_rch(host)) != NULL) { > + adev = ACPI_COMPANION(&host->dev); > + if (!adev || !adev->pnp.unique_id || > + (kstrtoull(adev->pnp.unique_id, 10, &uid) < 0)) There is an acpi_device_uid() accessor function that should probably be used here. Also, should a fialure to convert to an integer (or one within limits) be something we paper over? Feels like we should fail hard if that happens. Admittedly I can't immediately find any spec that states that the _UID should be either integer or under 32 bits... ACPI allows a string and CXL just says it's 4 bytes long. > + continue; > + > + dev_dbg(&adev->dev, "host uid: %llu\n", uid); > + > + if (uid > U32_MAX) > + continue; > + > dev_info(&host->dev, "host supports CXL\n"); > } >