Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp920942pxa; Wed, 5 Aug 2020 16:31:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJydbeaaOxUr4SW2frsQhzpQRCpb7wIe1SAQEdcDBvnaDsB3BLcYdgyzmc4QynJkJ54kEyL2 X-Received: by 2002:a05:6402:2033:: with SMTP id ay19mr1516919edb.361.1596670298819; Wed, 05 Aug 2020 16:31:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1596670298; cv=none; d=google.com; s=arc-20160816; b=O8sSqeTV59i4cDQlMMWNKJW5eBUWtzv7wOQTvho8trDWDJbxtIISCKk+6Wjr+MBcSU r31atvbwAR9P11RV1vmTUiU0ADIZZDDpHV0IukHg/VigbSuw+HqLA3mSQ18675VNavBc quqkRuHKuxkBlY1zvqqaxN3wtRl143Io+0W8fny0Yu/vvukX9oADprM1PnydAeX1+3hS q7GgUVSl6WWG9VodFMyBq6xzl/dDLNirWR+H/J6QZmI4XG+mK7OMDx4GPLCC76JyWHkf c/GWQLQ0bdcyTcsZYSqu7yboQ6gPgB6hZU/X7WpcsZFhqg+g2kVtD2oHVja6l83ikfg+ tmaw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:message-id:subject:cc:to:from:date:dkim-signature; bh=nckp3KrZF+cW7t2SLp+5M/9KdgnQhptacATEX/rXfcs=; b=VPUj7DG0MeA9ZkwxQj3Z4/1kl5Rc6KE5T89wVdhGhueIUH7LCtpwjfTRHLN9iOSivc 2QieJk75CQXS7hodWVaDkGl1L2cAchtt7vG7xXzXh7GxR9vQ3bYylDMGZoQRk9GwcfSV +KtafjwfGGkFDCx/EO0m0YLkBULtdGUbOpsPuw1svnGWi9480W/zKWwloz/zBWVmwjqR 0EEs65qmrjGJHSRSnpsGiB8aHA3qJLA8wFLao8UqOIheaeoaWlDBPcpKY7YjQ6/EICkE fLC7Ca2wO5A7D359gTwlKhONWnQ6mwfhNfMVSFWXc/7FVZcCMPw2rxt/VNQRcw6V3cLO usRA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=2Pl3YCSz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t3si2103147edq.511.2020.08.05.16.31.15; Wed, 05 Aug 2020 16:31:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=2Pl3YCSz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S1726005AbgHEXay (ORCPT + 99 others); Wed, 5 Aug 2020 19:30:54 -0400 Received: from mail.kernel.org ([198.145.29.99]:59048 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725779AbgHEXax (ORCPT ); Wed, 5 Aug 2020 19:30:53 -0400 Received: from localhost (mobile-166-175-186-42.mycingular.net [166.175.186.42]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 1831B2250E; Wed, 5 Aug 2020 23:30:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1596670252; bh=vHaH0yhs28g9JbXiqhAOY+aM/CzSEYyMbl4nOxNGsk0=; h=Date:From:To:Cc:Subject:In-Reply-To:From; b=2Pl3YCSzugL2WX3PfDEFCgYDQqAuubaNgW3z9pH4peyvNNb1+cV+blRPqEhCUWhgW 0GoxPz2Ot430E/QMGPb1ULvXq2iWxBZM1D9XIPXjr6DVSZlvPAN3sLqkBkOlf5eypv 9Ze3K1TUlg89eboch6gfx0uQZLtxuZxv1GJA9esc= Date: Wed, 5 Aug 2020 18:30:50 -0500 From: Bjorn Helgaas To: Lorenzo Pieralisi Cc: Bharat Kumar Gogada , linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, bhelgaas@google.com, robh@kernel.org, maz@kernel.org Subject: Re: [PATCH v9 2/2] PCI: xilinx-cpm: Add Versal CPM Root Port driver Message-ID: <20200805233050.GA607207@bjorn-Precision-5520> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200805220326.GA550962@bjorn-Precision-5520> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Aug 05, 2020 at 05:03:26PM -0500, Bjorn Helgaas wrote: > On Wed, Aug 05, 2020 at 10:39:28PM +0100, Lorenzo Pieralisi wrote: > > On Wed, Aug 05, 2020 at 03:43:58PM -0500, Bjorn Helgaas wrote: > > > On Tue, Jun 16, 2020 at 06:26:54PM +0530, Bharat Kumar Gogada wrote: > > > > - Add support for Versal CPM as Root Port. > > > > - The Versal ACAP devices include CCIX-PCIe Module (CPM). The integrated > > > > block for CPM along with the integrated bridge can function > > > > as PCIe Root Port. > > > > - Bridge error and legacy interrupts in Versal CPM are handled using > > > > Versal CPM specific interrupt line. > > > > > > > +static void xilinx_cpm_pcie_init_port(struct xilinx_cpm_pcie_port *port) > > > > +{ > > > > + if (cpm_pcie_link_up(port)) > > > > + dev_info(port->dev, "PCIe Link is UP\n"); > > > > + else > > > > + dev_info(port->dev, "PCIe Link is DOWN\n"); > > > > + > > > > + /* Disable all interrupts */ > > > > + pcie_write(port, ~XILINX_CPM_PCIE_IDR_ALL_MASK, > > > > + XILINX_CPM_PCIE_REG_IMR); > > > > + > > > > + /* Clear pending interrupts */ > > > > + pcie_write(port, pcie_read(port, XILINX_CPM_PCIE_REG_IDR) & > > > > + XILINX_CPM_PCIE_IMR_ALL_MASK, > > > > + XILINX_CPM_PCIE_REG_IDR); > > > > + > > > > + /* > > > > + * XILINX_CPM_PCIE_MISC_IR_ENABLE register is mapped to > > > > + * CPM SLCR block. > > > > + */ > > > > + writel(XILINX_CPM_PCIE_MISC_IR_LOCAL, > > > > + port->cpm_base + XILINX_CPM_PCIE_MISC_IR_ENABLE); > > > > + /* Enable the Bridge enable bit */ > > > > + pcie_write(port, pcie_read(port, XILINX_CPM_PCIE_REG_RPSC) | > > > > + XILINX_CPM_PCIE_REG_RPSC_BEN, > > > > + XILINX_CPM_PCIE_REG_RPSC); > > > > +} > > > > + > > > > +/** > > > > + * xilinx_cpm_pcie_parse_dt - Parse Device tree > > > > + * @port: PCIe port information > > > > + * @bus_range: Bus resource > > > > + * > > > > + * Return: '0' on success and error value on failure > > > > + */ > > > > +static int xilinx_cpm_pcie_parse_dt(struct xilinx_cpm_pcie_port *port, > > > > + struct resource *bus_range) > > > > +{ > > > > + struct device *dev = port->dev; > > > > + struct platform_device *pdev = to_platform_device(dev); > > > > + struct resource *res; > > > > + > > > > + port->cpm_base = devm_platform_ioremap_resource_byname(pdev, > > > > + "cpm_slcr"); > > > > + if (IS_ERR(port->cpm_base)) > > > > + return PTR_ERR(port->cpm_base); > > > > + > > > > + res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "cfg"); > > > > + if (!res) > > > > + return -ENXIO; > > > > + > > > > + port->cfg = pci_ecam_create(dev, res, bus_range, > > > > + &pci_generic_ecam_ops); > > > > > > Aren't we passing an uninitialized pointer (bus_range) here? This > > > looks broken to me. > > > > > > The kernelci build warns about it: > > > https://kernelci.org/build/next/branch/master/kernel/next-20200805/ > > > > > > /scratch/linux/drivers/pci/controller/pcie-xilinx-cpm.c:557:39: warning: variable 'bus_range' is uninitialized when used here [-Wuninitialized] > > > > > > I'm dropping this for now. I can't believe this actually works. > > > > It is caused by my rebase to fix -next after the rework in pci/misc > > (I had to drop the call to pci_parse_request_of_pci_ranges()). > > > > I will look into this tomorrow if Rob does not beat me to it. > > > > Apologies, it is a new driver that was based on an interface > > that is being reworked, for good reasons, in pci/misc. > > Oh, yep, I think I see what happened. I'll try to fix this in hopes > of making linux-next tonight. OK, I think I fixed it. Man, that was a lot of work for a git novice like me ;) Current head: 6f119ec8d9c8 ("Merge branch 'pci/irq-error'") Diff from yesterday's "next" branch (a231039775c4 ("Merge branch 'pci/irq-error'")): diff --git a/drivers/pci/controller/pcie-xilinx-cpm.c b/drivers/pci/controller/pcie-xilinx-cpm.c index 5f9b9fc12500..f3082de44e8a 100644 --- a/drivers/pci/controller/pcie-xilinx-cpm.c +++ b/drivers/pci/controller/pcie-xilinx-cpm.c @@ -539,7 +539,7 @@ static int xilinx_cpm_pcie_probe(struct platform_device *pdev) struct xilinx_cpm_pcie_port *port; struct device *dev = &pdev->dev; struct pci_host_bridge *bridge; - struct resource *bus_range; + struct resource_entry *bus; int err; bridge = devm_pci_alloc_host_bridge(dev, sizeof(*port)); @@ -554,7 +554,11 @@ static int xilinx_cpm_pcie_probe(struct platform_device *pdev) if (err) return err; - err = xilinx_cpm_pcie_parse_dt(port, bus_range); + bus = resource_list_first_type(&bridge->windows, IORESOURCE_BUS); + if (!bus) + return -ENODEV; + + err = xilinx_cpm_pcie_parse_dt(port, bus->res); if (err) { dev_err(dev, "Parsing DT failed\n"); goto err_parse_dt;