Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp2503313rwb; Mon, 7 Nov 2022 14:12:13 -0800 (PST) X-Google-Smtp-Source: AMsMyM6Lm1s/GiMwmGWy6lWCXHLPYCA+k0nQ5O+qe1cuohFhEqy2j5XAoImTd39sDU8Y+VOgbYZ6 X-Received: by 2002:a17:907:78b:b0:741:3d29:33d2 with SMTP id xd11-20020a170907078b00b007413d2933d2mr51804384ejb.103.1667859133333; Mon, 07 Nov 2022 14:12:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1667859133; cv=none; d=google.com; s=arc-20160816; b=PmK7vdhS1vawhyEEU+Ywv3M4DhDoxkRubB4zQKUpyCQ3fQG1ZkuZQP6N+TN8NprL9/ vJbwBDsT63+bMZSJEKQxn9pr3Xz7LENqQAjoWbmS1qSAeRhaYMuEU5rYrldGOXtvl9MK 8z/edOwv+OXb4U03w70WsMCeZn7POuabNPQ2qkBztJwvbm8AV8sWcweYqghSVsqFzxxG vv3PBzqCqANhHo3YbpF7gnO+TWzdG+fUSeYltqGxsQETvmQxbpAp0z62u+OBNG2JxFRn 9cxtUDjGbjxKj9KUPV7PugXACEFfXgMxkN1BiSjvUYZl9GboONSRpE3/Ll85WWUQToWb Rgtw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :message-id:subject:cc:to:from:date:dkim-signature; bh=DfIy73sSaTxyPsANQujblHMltOTmozcKlaSnGWxWddg=; b=tR52N5Gwg982KD6EFZSyaKlWMl6IdS3+vH36rn8lUtAhhd4VZmbHDqzThZw5FSFqmO PGkOAyPdm4fWuMhemV8/qCMCXiDNxBahxKSjZwLkW7tMJ9duGgDL8M6qxR6XlpzzRIbf 3bYSIQaNKom2ha8SEPyN4+PzpP19VozzjbXQiMydaQRSdiR6pPXvjeZY91QIjVUr6s8p fNRfGJdn9S8Hyo1e+takvaxYmoGd8mxM04HECoAFxFECTlU5zj+kafPjMaG5uDFkf377 q3mvXf3mzwfeQr7Vzdl6L+ixRSNRwtJJj261JIHrku5Sh/6f5GDfUrx8p601F5BZyMsM CbQA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=fQ2aOX8n; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id go35-20020a1709070da300b0078d44c5da0esi11010004ejc.667.2022.11.07.14.11.51; Mon, 07 Nov 2022 14:12:13 -0800 (PST) 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; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=fQ2aOX8n; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233315AbiKGVJm (ORCPT + 91 others); Mon, 7 Nov 2022 16:09:42 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53562 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233289AbiKGVJD (ORCPT ); Mon, 7 Nov 2022 16:09:03 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DB9352CE28; Mon, 7 Nov 2022 13:06:46 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 52F0EB81699; Mon, 7 Nov 2022 21:06:02 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A3213C433B5; Mon, 7 Nov 2022 21:06:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1667855160; bh=pefoyR60rzhiUzFe5oioggk7k8lK8qb9L2ld/HDcRMw=; h=Date:From:To:Cc:Subject:In-Reply-To:From; b=fQ2aOX8nSDqYl9NL4OWckKxCqwu3HAkOdLfXKF6hsZ5pakk6YrtrGhOmpnEHVRjqx qfdWef6vd7kZpf0Q/2EwV+nPZTjIXMzOPSX4VAeCqAw0o+A8iqcKbXnP5Vy3lNM64G 7h3T6YLgN6wPiKlix2S81DT2H6wuN8FmYZPMhy+HJovfjM16qP/nhV8XWoP4TKBu5P w/FJ3t0dkRo4T6T3YUAGdRAGuNuNiBulAaX/zU5ATLHia7/Z7suNuK5d14QJ4IXOjk UxeIbAUy5JDW+s8SenQv9DAgoxnl28T0mGrYCouAHoy9a1W6KRRpELWOWImCcrxYML ZCrYl25BiRVXw== Date: Mon, 7 Nov 2022 15:05:59 -0600 From: Bjorn Helgaas To: Lizhi Hou Cc: linux-pci@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, robh@kernel.org, frowand.list@gmail.com, clement.leger@bootlin.com, max.zhen@amd.com, sonal.santan@amd.com, larry.liu@amd.com, brian.xu@amd.com, stefano.stabellini@xilinx.com, trix@redhat.com Subject: Re: [PATCH RFC V3 2/2] PCI: Create device tree node for selected devices Message-ID: <20221107210559.GA419452@bhelgaas> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1667575454-18706-3-git-send-email-lizhi.hou@amd.com> X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS 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 Fri, Nov 04, 2022 at 08:24:14AM -0700, Lizhi Hou wrote: > The PCIe endpoint device such as Xilinx Alveo PCIe card maps the register > spaces from multiple hardware peripherals to its PCIe BAR. Normally, > the PCI core discovers devices and BARs using the PCI enumeration process. > There is no infrastructure to discover the hardware peripherals that are > present in a PCI device, and which can be accessed through the PCI BARs. > > For Alveo PCIe card, the card firmware provides a flattened device tree to > describe the hardware peripherals on its BARs. The Alveo card driver can > load this flattened device tree and leverage device tree framework to > generate platform devices for the hardware peripherals eventually. > > Apparently, the device tree framework requires a device tree node for the > PCIe device. Thus, it can generate the device tree nodes for hardware > peripherals underneath. Because PCIe is self discoverable bus, there might > not be a device tree node created for PCIe devices. This patch is to add > support to generate device tree node for PCIe devices. It introduces a > kernel option. When the option is turned on, the kernel will generate Specify the kernel option here. These last two sentences should probably be a separate paragraph because they say specifically what this patch does. > device tree nodes for PCI bridges unconditionally. > It will also generate > a device tree node for Xilinx Alveo U50 by using PCI quirks. I think I would split the Xilinx Alveo U50 quirk to a separate patch from the infrastructure and make this patch more generic. > +config PCI_DYNAMIC_OF_NODES > + bool "Device tree node for PCI devices" > + depends on OF > + select OF_DYNAMIC > + help > + This option enables support for generating device tree nodes for some > + PCI devices. Thus, the driver of this kind can load and overlay > + flattened device tree for its downstream devices. > + > + Once this option is selected, the device tree nodes will be generated > + for all PCI/PCIE bridges. PCI/PCIe Actually, in this context (and in the commit log), you should just say "PCI" because there's nothing PCIe-specific here. > +void of_pci_make_dev_node(struct pci_dev *pdev) > +{ > + struct device_node *parent, *dt_node = NULL; > + const char *pci_type = "dev"; > + struct of_changeset *cset; > + const char *full_name; > + int ret; > + > + /* > + * if there is already a device tree node linked to this device, > + * return immediately. s/if there/If there/ > + */ > + if (pci_device_to_OF_node(pdev)) > + return; > + > + /* check if there is device tree node for parent device */ s/check/Check/ Follow the style of the file, which is "capitalize English sentences."