Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp501826rwe; Thu, 1 Sep 2022 03:18:52 -0700 (PDT) X-Google-Smtp-Source: AA6agR6/t2eBaB1iABUOsjglUiXAcSl6GA3CC5XqL/X+lnHdNzfugR1kjFg+tMjUjvmxf3NQcdj1 X-Received: by 2002:a63:5b16:0:b0:42a:8c1b:819a with SMTP id p22-20020a635b16000000b0042a8c1b819amr24962997pgb.424.1662027531912; Thu, 01 Sep 2022 03:18:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662027531; cv=none; d=google.com; s=arc-20160816; b=M93v9foKWrh86ACKSY09WvMUesrEqWRY90f632H+7BYo/crmW3KEE5nLHzKcD063Fv ueqf62AMH/C5R8jNdsnsYaYrOaB/x3R6c6X6E7n4axdTJX36NGNwEj6DyhNbtzS99O3B DjFyWUWZems4wqlLKfqhmENddt6YTYgMsh/IEB286x/yqACk25tHSdght2b3+FNoUJLc ffNj6hL5vawM5PO+C8X5slFJuqexaQUxTT81/b6q9ARa8kbkXthmugSnLPppwQ7VcGD7 Fz12ZrQmPOKYmjHj58NOOEAf/dPD5U99zCgkMbMyiLy+SkxD2VjkwhT5b+3GU9NLf7c8 IeXA== 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=0a+IR5F7xlCyeCxbL6OKAmNVUiTZUo9d6+gelV0wE9s=; b=ONrx0ThDXa3+XPkOEPYgV+rH3zehIP8syUu5wBj/N5+N0QbG9dYd/VgxdxmlwdKObR EYaIjS/bcex8tRDoUu3SSZ7tmlAbWl4eaTmOTM13qm/wlAbi/Bcdadx3tEg2L4ywawco Eo/92lLe/L1w5BuzupHgZa+kWfQfDNyg3QTbcrYl5UOSKyWJcpzSxIqNULPVbX5xr1NE YgAie7SWxPs4PKJGPfyJr0drZPb4OSMp3Z+YHf3d7uXOAgWgRzSD6bFtve7tFllxFSpY KbmYkgjlqfvY1+/E7WvIyT2kqgtqPV1v8yLYMwa/6wZjPhGxe8JyvrTpq14aSNtqGOFk Tyag== 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 m12-20020a170902f64c00b00172e131ab77si16844688plg.491.2022.09.01.03.18.40; Thu, 01 Sep 2022 03:18:51 -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 S233685AbiIAKKv (ORCPT + 99 others); Thu, 1 Sep 2022 06:10:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53642 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233326AbiIAKKq (ORCPT ); Thu, 1 Sep 2022 06:10:46 -0400 Received: from frasgout.his.huawei.com (frasgout.his.huawei.com [185.176.79.56]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DCBAAAA3FF; Thu, 1 Sep 2022 03:10:42 -0700 (PDT) Received: from fraeml704-chm.china.huawei.com (unknown [172.18.147.206]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4MJGxg5Qz1z67xt4; Thu, 1 Sep 2022 18:09:59 +0800 (CST) Received: from lhrpeml500005.china.huawei.com (7.191.163.240) by fraeml704-chm.china.huawei.com (10.206.15.53) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2375.31; Thu, 1 Sep 2022 12:10:40 +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:10:40 +0100 Date: Thu, 1 Sep 2022 11:10:38 +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 05/15] cxl/acpi: Add probe function to detect restricted CXL hosts in RCD mode Message-ID: <20220901111038.00002e00@huawei.com> In-Reply-To: References: <20220831081603.3415-1-rrichter@amd.com> <20220831081603.3415-6-rrichter@amd.com> <20220831110804.00003812@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: lhrpeml500006.china.huawei.com (7.191.161.198) 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:01:05 +0200 Robert Richter wrote: > On 31.08.22 11:08:04, Jonathan Cameron wrote: > > On Wed, 31 Aug 2022 10:15:53 +0200 > > > Robert Richter wrote: > > > > > Restricted CXL device (RCD) mode (formerly CXL 1.1) uses a different > > > enumeration scheme other than CXL VH (formerly CXL 2.0). In RCD mode a > > > host/device (RCH-RCD) pair shows up as a legal PCIe hierarchy with an > > > ACPI host bridge ("PNP0A08" or "ACPI0016" HID) and RCiEP connected to > > > it with a description of the CXL device. > > > > > > Add function cxl_restricted_host_probe() to probe RCD enumerated > > > devices. The function implements a loop that detects all CXL capable > > > ACPI PCI root bridges in the system (RCD mode only). The iterator > > > function cxl_find_next_rch() is introduced to walk through all of the > > > CXL hosts. The loop will then enable all CXL devices connected to the > > > host. For now, only implement an empty loop with an iterator that > > > returns all pci host bridges in the system. > > > > > > The probe function is triggered by adding an own root device for RCHs. > > > This is different to CXL VH where an ACPI "ACPI0017" root device > > > exists. Its detection starts the CXL host detection. In RCD mode such > > > a device does not necessarily exists, so solve this by creating a > > > plain platform device that is not an ACPI device and is root only for > > > RCHs. > > > > If I read this correctly that platform device is created whether or not > > there are any cxl devices in the system? > > > > Can we create it only if we find some devices that will be placed > > under it later? > > This would move the host detection from probe to init which I wanted > to avoid to better control driver init order dependencies. It's a bit nasty either way. I can see your reasoning, but definitely not keen on it if there is a plausible way to avoid. > > I could add a put_device() at the end of a probe so that it will be > released in case no other references use it. This implies the refcount > is maintained for parent devices. Or this needs to be added to. So if > there are no children (hosts) attached to the root device after probe, > it will disappear. Unless there is precedence for that, it'll be weird enough to be hard to maintain. I guess I can live with the ugliness if we can't add something new to ACPI to base this off. > > > > @@ -531,7 +566,41 @@ static struct platform_driver cxl_acpi_driver = { > > > .id_table = cxl_test_ids, > > > }; > > > > > > -module_platform_driver(cxl_acpi_driver); > > > +static void cxl_acpi_device_release(struct device *dev) { } > > > > Why the empty release? Perhaps introduce this only when it > > does something. > > The core device driver requires this in device_release() to be setup. > > There is nothing to do as the device is kept in a static struct. > That's why it's empty. Ah got it. I'd failed to register the static structure. > > -Robert