Received: by 2002:a05:7412:b10a:b0:f3:1519:9f41 with SMTP id az10csp2785475rdb; Mon, 4 Dec 2023 07:30:48 -0800 (PST) X-Google-Smtp-Source: AGHT+IFETIuLxX0GxEhWRWDjMsnqhu562s9KG/hVR4dPqgQOhLiZeSdWrvqKSCvjFDz2oX45s2hb X-Received: by 2002:a05:6a00:4294:b0:6ce:6265:fc0d with SMTP id bx20-20020a056a00429400b006ce6265fc0dmr521226pfb.6.1701703848181; Mon, 04 Dec 2023 07:30:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701703848; cv=none; d=google.com; s=arc-20160816; b=ZdOR96W9z+M0sVZq6Br59K/6vLEH6mWXdNflSq5XXk+WwFSb6s8qFdfH3IxhTlxo+b Y20CmHt272SHuaOkLUpbK6Jf5P9akQZOmdWTE/+N1vQewhPZCb2M9RRwYuwph+n1YAYh 880IAYCFHdoIxkeODah7jWZA9RbdCO1E+AMUwsGV1lubjEP+VWNASBo+S+ivfH+cD/yY fugvWArMusV67BerxwVs1fSKiz05/8XtN2umWQcOUG607tK8QHNWSQ1RatUdo0N0ExoW 5cvxswDO/SwnCTY1Yk62h+UyXFJyGeLPPV8axHpTMbvp/rW86hnO1TntjPZ+CA1TXxtU Mn8A== 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 :organization:references:in-reply-to:message-id:subject:cc:to:from :date:dkim-signature; bh=lC9iyWjs9SLEvLAN2a3GzP/PTmAJHX40lkoy38ZLB0k=; fh=2oHfka1RMTQTF84mb7T46ycwVNzrlTi9XMjBcTPHQ7o=; b=EhE97dQdp73phlx/sS3jg8Btfpw4BH/MbD6ue7NjV5A8wrXCGEzTx7SzZ2cD31deJG s18jciWWMUBcFe1PYiGG/iPUqTS3SVNa/FO93P+aLW6r5VWH3LGhynaRqrLL4p0KpQou f5qeb5MX9mdA0+T+j2/OqWeAcfj8FfyLt9021x0SJVhNsur9upyl50fmzEOSNKgClfQD E6LjCmgtisa6imN2f7ACuBkr5ShpIEt008mWZINnXBiuJHdPz+e54EM8fMvXQYTY92el 0hPBX/BnrjNeerLbXMdYyemJWVYiZCqWiCFZJU0sqJ9aSYrMuF76U/LvcgfoW9y+YT+N ed0w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=bfXoqu1S; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Return-Path: Received: from fry.vger.email (fry.vger.email. [2620:137:e000::3:8]) by mx.google.com with ESMTPS id e5-20020a636905000000b005bdf596188asi7749056pgc.667.2023.12.04.07.30.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Dec 2023 07:30:48 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) client-ip=2620:137:e000::3:8; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=bfXoqu1S; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id D4984807780F; Mon, 4 Dec 2023 07:30:29 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234622AbjLDPaO (ORCPT + 99 others); Mon, 4 Dec 2023 10:30:14 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51610 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234432AbjLDPaN (ORCPT ); Mon, 4 Dec 2023 10:30:13 -0500 Received: from relay6-d.mail.gandi.net (relay6-d.mail.gandi.net [IPv6:2001:4b98:dc4:8::226]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 625F0B0; Mon, 4 Dec 2023 07:30:19 -0800 (PST) Received: by mail.gandi.net (Postfix) with ESMTPSA id A7344C0002; Mon, 4 Dec 2023 15:30:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1701703818; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=lC9iyWjs9SLEvLAN2a3GzP/PTmAJHX40lkoy38ZLB0k=; b=bfXoqu1SHr+oH1qgM13BQ42PmdEr/OrtXWgYNyd4mi0IvjPKxdaXM34KEWtWo2ZPDDOaNN 2aVnMnk3QAOsLzzljcSKG1BwvrSt8QFxEFnvdpGstNTny56/CtegMepgR6P5DbgsDkTxE3 U3hIxUH+Na9u6pEOwjEZ7Iapj6uZ7fi9fpDVcHvTd1PkHItobDD4/Z94fhF8qYF4YivGEW 8W6UEkCcCdLnW/88B1GPkQMNac7/XPvL11hI+nGeWh3Kof7ZjAegaV9lHL0u/DJ9Cb9qwL 26suZIke97jSjH1eMR2uy7yugCsBW2JIkP6o9CbX713c9oVGJYR3Rd8CzYg6rw== Date: Mon, 4 Dec 2023 16:30:14 +0100 From: Herve Codina To: Rob Herring Cc: Greg Kroah-Hartman , "Rafael J. Wysocki" , Bjorn Helgaas , Lizhi Hou , Max Zhen , Sonal Santan , Stefano Stabellini , Jonathan Cameron , "linux-kernel@vger.kernel.org" , PCI , Allan Nielsen , Horatiu Vultur , Steen Hegelund , Thomas Petazzoni Subject: Re: [PATCH v2 0/2] Attach DT nodes to existing PCI devices Message-ID: <20231204163014.4da383f2@bootlin.com> In-Reply-To: References: <20231130165700.685764-1-herve.codina@bootlin.com> <20231204134335.3ded3d46@bootlin.com> Organization: Bootlin X-Mailer: Claws Mail 4.1.1 (GTK 3.24.38; x86_64-redhat-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-GND-Sasl: herve.codina@bootlin.com X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Mon, 04 Dec 2023 07:30:31 -0800 (PST) Hi Rob, On Mon, 4 Dec 2023 07:59:09 -0600 Rob Herring wrote: [...] > > > diff --git a/drivers/pci/bus.c b/drivers/pci/bus.c > > > index 9c2137dae429..46b252bbe500 100644 > > > --- a/drivers/pci/bus.c > > > +++ b/drivers/pci/bus.c > > > @@ -342,8 +342,6 @@ void pci_bus_add_device(struct pci_dev *dev) > > > */ > > > pcibios_bus_add_device(dev); > > > pci_fixup_device(pci_fixup_final, dev); > > > - if (pci_is_bridge(dev)) > > > - of_pci_make_dev_node(dev); > > > pci_create_sysfs_dev_files(dev); > > > pci_proc_attach_device(dev); > > > pci_bridge_d3_update(dev); > > > diff --git a/drivers/pci/of.c b/drivers/pci/of.c > > > index 51e3dd0ea5ab..e15eaf0127fc 100644 > > > --- a/drivers/pci/of.c > > > +++ b/drivers/pci/of.c > > > @@ -31,6 +31,8 @@ int pci_set_of_node(struct pci_dev *dev) > > > return 0; > > > > > > node = of_pci_find_child_device(dev->bus->dev.of_node, dev->devfn); > > > + if (!node && pci_is_bridge(dev)) > > > + of_pci_make_dev_node(dev); > > > if (!node) > > > return 0; > > > > Maybe it is too early. > > of_pci_make_dev_node() creates a node and fills some properties based on > > some already set values available in the PCI device such as its struct resource > > values. > > We need to have some values set by the PCI infra in order to create our DT node > > with correct values. > > Indeed, that's probably the issue I'm having. In that case, > DECLARE_PCI_FIXUP_HEADER should work. That's later, but still before > device_add(). > > I think modifying sysfs after device_add() is going to race with > userspace. Userspace is notified of a new device, and then the of_node > link may or may not be there when it reads sysfs. Also, not sure if > we'll need DT modaliases with PCI devices, but they won't work if the > DT node is not set before device_add(). Ok, we can try using DECLARE_PCI_FIXUP_HEADER. On your side, is moving from DECLARE_PCI_FIXUP_EARLY to DECLARE_PCI_FIXUP_HEADER fix your QEMU unittest ? We have to note that between the pci_fixup_device(pci_fixup_header, dev) call and the device_add() call, the call to pci_set_msi_domain() is present. MSIs are not supported currently but in the future ... Related to DT modaliases, I don't think they are needed. All drivers related to PCI device should be declared as pci_driver. Correct me if I am wrong but I think that the core PCI will load the correct module without any DT modalias. Best regards, Hervé -- Hervé Codina, Bootlin Embedded Linux and Kernel engineering https://bootlin.com