Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp436372rdg; Thu, 12 Oct 2023 09:43:55 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFmeaYD8fVyG/0Jp0nfdJCFhbREnxOk04UqIyj0+jIJclOqLGBHQ9lj50tpu12D5TrsikCX X-Received: by 2002:a05:6a20:7488:b0:161:2607:d815 with SMTP id p8-20020a056a20748800b001612607d815mr28499322pzd.24.1697129034953; Thu, 12 Oct 2023 09:43:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697129034; cv=none; d=google.com; s=arc-20160816; b=l5eMb4Zg4akYAf2Cg26g3ifNbox/lhqYVaydSTVELbbQEIgxN+xtz53W7baN+Q2hOU 0iMd6nhkGyOPrwjZqiexyi5WQ8uVJY/VofVUtR7HW1XL+FTinjZQpQlshqDNysEoCqBL eSvmskY4OA5qx0/5NEvuKDQoQPE+Yc9YsjhQ44DNDwEba9cvNAWa9FGu0l/ZeUmEAggq jj8P9ZYUDNemsZU9S/cV7Z+juXg/VQTos6m3eGl6AKMNDYwxsf/Tp7UjvH7vxzvdk/fE 9lUc6I8jGBqsxvwvIQg1WNva9+YUldGIekegQ+4H6DYs8IDmWPkRXcUCCIsTk0SSVrgC /f0Q== 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=mbmAaEHTj4uQwZJ5XO0QdfGZ2cuZ5n49j4iLECaLNWo=; fh=VjaTa46L7rSH/T9FytcxMNPnQ5ChtPnoE4/jPKMFI10=; b=wEM2U7Gy5qesh/Jr7c1pxGbRd44J8nn9OVie3BaaxZiSHyclsg3uWuDtzFvd7hmpt/ n0/6vlv6TX/AFc0faI2f6qUGQb3PP99UiqccugCTElT/gqqcBNrlS2Y4At0lw7hgflzw GEv4uZ24TaZvX9vxctEQ8bQeTAbjbMkhPbJCWCKAGJBfg4l69V/O2wtQE12QVmW+ZF1s nlqNKQm5x9+JjB8PzOuYIvWK4nwusjxg7yU1vpc/Tgj4/DFwGpg30A4Rr/qvnYfSd+Wv C4weVGWGu3LWDmyG1a4O5j0KYuNQ4BzT2ejaZqWZZsMM90cm6ovd0KrPLxJsdQl+Das4 pDww== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=gpYnHIXt; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 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 groat.vger.email (groat.vger.email. [2620:137:e000::3:5]) by mx.google.com with ESMTPS id i7-20020a639d07000000b00577f7bc56absi2598100pgd.100.2023.10.12.09.43.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Oct 2023 09:43:54 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) client-ip=2620:137:e000::3:5; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=gpYnHIXt; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 12AC58242F75; Thu, 12 Oct 2023 09:43:52 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235706AbjJLQnn (ORCPT + 99 others); Thu, 12 Oct 2023 12:43:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40368 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1379499AbjJLQnk (ORCPT ); Thu, 12 Oct 2023 12:43:40 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DDBE6CA; Thu, 12 Oct 2023 09:43:38 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1E58FC433C9; Thu, 12 Oct 2023 16:43:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1697129018; bh=kfDTZe6bHsXYEX/cMTdKPK0HJuuqElf7yFpIZAfZdrk=; h=Date:From:To:Cc:Subject:In-Reply-To:From; b=gpYnHIXtG/AI/50xVzbgYh9ZokHe+LC/HTuonFQ8uuofa9ptBdl+zXb+0i/ZAyT7A nnkuqvny8W8DYDl2GaQiS9Pmz1pjdOfpLilw2xnVdxn8waw8ZXkKiQN3vxRvjgZaEh PisSURAbi4YwOzw7LaMT+326xWgzSPAE91WS6p77Q4B0QLnvr8K3eI2hRrweV7K3qk r6d6B7wpgHFoqR6rdmmaqULxVKtPQ8tKxKzYud1GpmUvPlFYDJvIcNtnewv5Tr1oXp Riv7CkBMw6pspHVdC9vDShg5cUBCmrNw30jZ4j/JGqyFW98zghqXY2ZVYtwvriiIcL Pj3IZl871HUsg== Date: Thu, 12 Oct 2023 11:43:36 -0500 From: Bjorn Helgaas To: Siddharth Vadapalli Cc: lpieralisi@kernel.org, robh@kernel.org, kw@linux.com, bhelgaas@google.com, linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, r-gunasekaran@ti.com, srk@ti.com Subject: Re: [PATCH] PCI: keystone: Don't enable BAR0 if link is not detected Message-ID: <20231012164336.GA1072823@bhelgaas> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <4e1f574c-6b36-c6e1-9153-90d599e2aaa7@ti.com> X-Spam-Status: No, score=-1.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.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 (groat.vger.email [0.0.0.0]); Thu, 12 Oct 2023 09:43:52 -0700 (PDT) On Thu, Oct 12, 2023 at 10:15:09AM +0530, Siddharth Vadapalli wrote: > Hello Bjorn, > > Thank you for reviewing the patch. > > On 11/10/23 19:16, Bjorn Helgaas wrote: > > Hi Siddharth, > > > > On Wed, Oct 11, 2023 at 06:04:51PM +0530, Siddharth Vadapalli wrote: > >> Since the function dw_pcie_host_init() ignores the absence of link under > >> the assumption that link can come up later, it is possible that the > >> pci_host_probe(bridge) function is invoked even when no endpoint device > >> is connected. In such a situation, the ks_pcie_v3_65_add_bus() function > >> configures BAR0 when the link is not up, resulting in Completion Timeouts > >> during the MSI configuration performed later by the PCI Express Port driver > >> to setup AER, PME and other services. Thus, leave BAR0 disabled if link is > >> not yet detected when the ks_pcie_v3_65_add_bus() function is invoked. > > > > I'm trying to make sense of this. In this path: > > > > pci_host_probe > > pci_scan_root_bus_bridge > > pci_register_host_bridge > > bus = pci_alloc_bus(NULL) # root bus > > bus->ops->add_bus(bus) > > ks_pcie_v3_65_add_bus > > > > The BAR0 in question must belong to a Root Port. And it sounds like > > the issue must be related to MSI-X, since the original MSI doesn't > > involve any BARs. > > Yes, the issue is related to MSI-X. I will list down the exact set of function > calls below as well as the place where the completion timeout first occurs: > ks_pcie_probe > dw_pcie_host_init > pci_host_probe > pci_bus_add_devices > pci_bus_add_device > device_attach > __device_attach > bus_for_each_drv > __device_attach_driver (invoked using fn(drv, data)) > driver_probe_device > __driver_probe_device > really_probe > pci_device_probe > pcie_portdrv_probe > pcie_port_device_register > pcie_init_service_irqs > pcie_port_enable_irq_vec > pci_alloc_irq_vectors > pci_alloc_irq_vectors_affinity > __pci_enable_msix_range > msix_capability_init > msix_setup_interrupts > msix_setup_msi_descs > msix_prepare_msi_desc > In this function: msix_prepare_msi_desc, the following readl() > causes completion timeout: > desc->pci.msix_ctrl = readl(addr + PCI_MSIX_ENTRY_VECTOR_CTRL); > The completion timeout with the readl is only observed when the link > is down (No Endpoint device is actually connected to the PCIe > connector slot). Do you know the address ("addr")? From pci_msix_desc_addr(), it looks like it should be: desc->pci.mask_base + desc->msi_index * PCI_MSIX_ENTRY_SIZE and desc->pci.mask_base should be dev->msix_base, which we got from msix_map_region(), which ioremaps part of the BAR indicated by the MSI-X Table Offset/Table BIR register. I wonder if this readl() is being handled as an MMIO access to a downstream device instead of a Root Port BAR access because it's inside the Root Port's MMIO window. Could you dump out these values just before the readl()? phys_addr inside msix_map_region() dev->msix_base desc->pci.mask_base desc->msi_index addr call early_dump_pci_device() on the Root Port Bjorn