Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp589390rwe; Thu, 1 Sep 2022 04:56:02 -0700 (PDT) X-Google-Smtp-Source: AA6agR7m0ZH1uElabJV52VDbZFY9O9hEO0vjoWuHJeCwYzFVPPZzRj8lFpz0Rvu1ZSJX4BX1os7C X-Received: by 2002:a17:902:aa49:b0:172:f8ed:1b27 with SMTP id c9-20020a170902aa4900b00172f8ed1b27mr31197088plr.52.1662033362595; Thu, 01 Sep 2022 04:56:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662033362; cv=none; d=google.com; s=arc-20160816; b=CGzY52ha+Kc6fU1lb2+Ar1pKMknUeAbWq7JqxIzYXxsHh3il2yZepZIqN/JSQ6cB10 n/usrxcKs8nU+sHu+gE85Zhosgr+Fa+aJF7fVVUHWBRQ78R3pZ+Rhn3s3DKmheGbWsYb bySo4DrJRF5IZJA0Y74LLSd9TTA9sVKwfd3mXxH4ZBO7SWHNLr8f80IEWliwcIp5Www5 FHl8SQlidyNq5HR6jAEK4R/IVZPPfYOw3Ze8Rz49ErKD+ybys/fZE+JIhOTsjZ+3A1wP lkXF20ZnigiM6z5rH/QF/QplR4VoJFU+JM+NAbSijR3Muq2TaBzWotHr3sLE1oX2IZdg idNw== 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=DKM1SR8G4hQJ3PhqzZjEkLgvQQNJbfr6XjNwRsx3Ct0=; b=mbKWSdmoHlTQxIO5t9KweyNL63KLyW1/UouqSrG2LojH0S1d7JO9eKoWluREzkwsxn IZB7ExzCg6jV14zWu5bJpcDENooF1lqakJN2xN0WzK8lOeA9I2IRJUC6cFjLMwmV65cQ TQS4Uo9qXaitz/B7LrR5UYsPXkzumW8tIsA8KLUA97MmWLoVbPmqeS4kO7lCSUIGnwd8 yNlR4oH0hOW1IACHqFyBPL9wSSCPCzeNAt8azpkVqjfy7cMEfESoX+QLhTcGnA2Mi0xu fH5sw+Jt8UkR9w8kXW0BSTrvSErIA51ign/Ourabtbs1JxwjvAgu7gcGdQ1dztstYS8K Rh3Q== 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 on13-20020a17090b1d0d00b001f4d705dbdcsi4625415pjb.80.2022.09.01.04.55.49; Thu, 01 Sep 2022 04:56:02 -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 S234352AbiIAKmP (ORCPT + 99 others); Thu, 1 Sep 2022 06:42:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55486 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234363AbiIAKlm (ORCPT ); Thu, 1 Sep 2022 06:41:42 -0400 Received: from frasgout.his.huawei.com (frasgout.his.huawei.com [185.176.79.56]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D52CC12C3FA; Thu, 1 Sep 2022 03:41:37 -0700 (PDT) Received: from fraeml735-chm.china.huawei.com (unknown [172.18.147.226]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4MJHYm0cVWz67yhg; Thu, 1 Sep 2022 18:37:48 +0800 (CST) Received: from lhrpeml500005.china.huawei.com (7.191.163.240) by fraeml735-chm.china.huawei.com (10.206.15.216) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Thu, 1 Sep 2022 12:41:35 +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; Thu, 1 Sep 2022 11:41:34 +0100 Date: Thu, 1 Sep 2022 11:41:33 +0100 From: Jonathan Cameron To: Robert Richter , Dan Williams CC: Alison Schofield , Vishal Verma , Ira Weiny , Ben Widawsky , , , Bjorn Helgaas , "Rafael J. Wysocki" , Len Brown Subject: Re: [PATCH 09/15] cxl/acpi: Determine PCI host bridge's ACPI UID Message-ID: <20220901114133.0000540c@huawei.com> In-Reply-To: References: <20220831081603.3415-1-rrichter@amd.com> <20220831081603.3415-10-rrichter@amd.com> <20220831120027.000017b3@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: lhrpeml100005.china.huawei.com (7.191.160.25) 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 Thu, 1 Sep 2022 08:53:36 +0200 Robert Richter wrote: > On 31.08.22 12:00:27, Jonathan Cameron wrote: > > 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. > > That accessor actually does not help really, there is no null pointer > check for adev. Using it actually adds more complexity since another > variable is introduced plus you need to look at the function's > implementation anyway. > > The adev->pnp.unique_id access pattern is widely used in the kernel, I > don't expect changes in the data struct here. Ok. > > > 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. > > This is a real corner case and close to a broken firmware > implementation. I think current dbg messages are good to find where > the detection stops. Hmm. I don't like papering over such bugs as it leads to people not fixing their bios as early as they otherwise would, but fair enough I guess. > > > 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. > > IIRC the UID can be implemented as string or 8 bytes, there is no > limitation then. That's why the range check below. Ok. All queries answered so Reviewed-by: Jonathan Cameron > > -Robert > > > > > > + continue; > > > + > > > + dev_dbg(&adev->dev, "host uid: %llu\n", uid); > > > + > > > + if (uid > U32_MAX) > > > + continue; > > > + > > > dev_info(&host->dev, "host supports CXL\n"); > > > } > > > > >