Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758426AbcLATRM (ORCPT ); Thu, 1 Dec 2016 14:17:12 -0500 Received: from mx1.redhat.com ([209.132.183.28]:52991 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752147AbcLATRK (ORCPT ); Thu, 1 Dec 2016 14:17:10 -0500 Subject: Re: [PATCH v3] PCI/ACPI: xgene: Add ECAM quirk for X-Gene PCIe controller To: Mark Salter , Duc Dang , Bjorn Helgaas References: <1480549373-2123-1-git-send-email-dhdang@apm.com> <1480604901.4751.17.camel@redhat.com> Cc: Rafael Wysocki , Lorenzo Pieralisi , Arnd Bergmann , linux-pci@vger.kernel.org, linux-arm , Linux Kernel Mailing List , Tomasz Nowicki , patches From: Jon Masters Message-ID: Date: Thu, 1 Dec 2016 14:17:04 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.0 MIME-Version: 1.0 In-Reply-To: <1480604901.4751.17.camel@redhat.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Thu, 01 Dec 2016 19:17:10 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1148 Lines: 31 On 12/01/2016 10:08 AM, Mark Salter wrote: > On Wed, 2016-11-30 at 15:42 -0800, Duc Dang wrote: >> +static int xgene_v1_pcie_ecam_init(struct pci_config_window *cfg) >> +{ >> + struct acpi_device *adev = to_acpi_device(cfg->parent); >> + struct acpi_pci_root *root = acpi_driver_data(adev); >> + struct device *dev = cfg->parent; >> + struct xgene_pcie_port *port; >> + struct resource *csr; >> + >> + port = devm_kzalloc(dev, sizeof(*port), GFP_KERNEL); >> + if (!port) >> + return -ENOMEM; >> + >> + csr = &xgene_v1_csr_res[root->segment]; > > This hard-coded assumption that segment N uses controller N breaks > for m400 where segment 0 is using controller 3. This seems very fragile. So in addition to Bjorn's comment about not trusting firmware provided data for the segment offset in the CSR list, you will want to also determine the controller from the ACPI tree. The existing code walks the ACPI hierarchy and finds the CSR that way. Obviously, the goal is to avoid that in the latest incarnation, but you could still determine which controller matches a given device. Jon. -- Computer Architect | Sent from my Fedora powered laptop