From patchwork Fri May 15 02:09:03 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suravee Suthikulpanit X-Patchwork-Id: 6410661 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id C8BBFC0432 for ; Fri, 15 May 2015 02:12:23 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id CEEBE2047D for ; Fri, 15 May 2015 02:12:22 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id E26C020454 for ; Fri, 15 May 2015 02:12:21 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1Yt54V-0007Os-KY; Fri, 15 May 2015 02:09:55 +0000 Received: from mail-bn1bon0142.outbound.protection.outlook.com ([157.56.111.142] helo=na01-bn1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1Yt54Q-0007Et-Db for linux-arm-kernel@lists.infradead.org; Fri, 15 May 2015 02:09:51 +0000 Received: from BY2PR02CA0084.namprd02.prod.outlook.com (10.242.32.42) by CY1PR02MB1117.namprd02.prod.outlook.com (25.163.15.143) with Microsoft SMTP Server (TLS) id 15.1.160.19; Fri, 15 May 2015 02:09:26 +0000 Received: from BL2FFO11FD039.protection.gbl (2a01:111:f400:7c09::162) by BY2PR02CA0084.outlook.office365.com (2a01:111:e400:2c2a::42) with Microsoft SMTP Server (TLS) id 15.1.160.19 via Frontend Transport; Fri, 15 May 2015 02:09:20 +0000 Authentication-Results: spf=none (sender IP is 165.204.84.222) smtp.mailfrom=amd.com; apm.com; dkim=none (message not signed) header.d=none; Received-SPF: None (protection.outlook.com: amd.com does not designate permitted sender hosts) Received: from atltwp02.amd.com (165.204.84.222) by BL2FFO11FD039.mail.protection.outlook.com (10.173.161.135) with Microsoft SMTP Server id 15.1.160.8 via Frontend Transport; Fri, 15 May 2015 02:09:19 +0000 X-WSS-ID: 0NODCNG-08-6EK-02 X-M-MSG: Received: from satlvexedge01.amd.com (satlvexedge01.amd.com [10.177.96.28]) (using TLSv1 with cipher AES128-SHA (128/128 bits)) (No client certificate requested) by atltwp02.amd.com (Axway MailGate 5.3.1) with ESMTPS id 24DF4D2201B; Thu, 14 May 2015 22:09:16 -0400 (EDT) Received: from SATLEXDAG05.amd.com (10.181.40.11) by satlvexedge01.amd.com (10.177.96.28) with Microsoft SMTP Server (TLS) id 14.3.195.1; Thu, 14 May 2015 21:09:23 -0500 Received: from [127.0.0.1] (10.180.168.240) by satlexdag05.amd.com (10.181.40.11) with Microsoft SMTP Server id 14.3.195.1; Thu, 14 May 2015 22:09:16 -0400 Message-ID: <5555553F.9070608@amd.com> Date: Thu, 14 May 2015 21:09:03 -0500 From: Suravee Suthikulanit User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.6.0 MIME-Version: 1.0 To: Lorenzo Pieralisi , , , "Bjorn Helgaas" Subject: Re: [RFC/RFT PATCH 2/2] ARM64: kernel: pci: implement PCI device resources claiming References: <1431614537-16136-1-git-send-email-lorenzo.pieralisi@arm.com> <1431614537-16136-2-git-send-email-lorenzo.pieralisi@arm.com> In-Reply-To: <1431614537-16136-2-git-send-email-lorenzo.pieralisi@arm.com> X-EOPAttributedMessage: 0 X-Microsoft-Exchange-Diagnostics: 1; BL2FFO11FD039; 1:gh5/ourrnv7T8UFzB7qqxp8QI7wmRjdkx3y4XgGsp7EXy8qFOrNR7ldmAEaqw8gEdlFWcy7GZqLuyZ9d0YKs7UyhLtZaKi3R7EHB01mzCta7jDup278scfOtKX3L9SoHTpl8awnhPVPk0+MysduxBTTPFfO7XANoOn7VaYGR3jOnWHqfvwBOtU0LqgU0c1T4D1ejtw/gnTxgOyhqaooMG5OMhKJ4q/DRSidNAFsDCg/BYhOSGaWXkZr8LHh0M4GZGw1nMOASCWXlzDLC5DcUByOI6qqVLgKB+LDfD69TsQzIiHQuxTZYDYxfJ//HlafEGXSU63Sar/SupbZyWzX78Q== X-Forefront-Antispam-Report: CIP:165.204.84.222; CTRY:US; IPV:NLI; EFV:NLI; SFV:NSPM; SFS:(10019020)(6009001)(428002)(189002)(51704005)(377454003)(24454002)(479174004)(199003)(164054003)(36756003)(86362001)(50466002)(65816999)(19580405001)(80316001)(19580395003)(2950100001)(83506001)(50986999)(59896002)(87266999)(575784001)(54356999)(76176999)(77156002)(62966003)(77096005)(15975445007)(189998001)(5001770100001)(99136001)(33656002)(65956001)(23746002)(120886001)(87936001)(106466001)(46102003)(2201001)(4001350100001)(47776003)(92566002)(101416001)(105586002)(7059030)(2101003)(217873001); DIR:OUT; SFP:1102; SCL:1; SRVR:CY1PR02MB1117; H:atltwp02.amd.com; FPR:; SPF:None; MLV:sfv; MX:1; A:1; LANG:en; X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:CY1PR02MB1117; X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(5005006)(3002001); SRVR:CY1PR02MB1117; BCL:0; PCL:0; RULEID:; SRVR:CY1PR02MB1117; X-Forefront-PRVS: 0577AD41D6 X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 May 2015 02:09:19.5598 (UTC) X-MS-Exchange-CrossTenant-Id: fde4dada-be84-483f-92cc-e026cbee8e96 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=fde4dada-be84-483f-92cc-e026cbee8e96; Ip=[165.204.84.222]; Helo=[atltwp02.amd.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY1PR02MB1117 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150514_190950_724218_4AC16897 X-CRM114-Status: GOOD ( 23.22 ) X-Spam-Score: -0.0 (/) Cc: Thomas Petazzoni , Phil Edworthy , Russell King , Arnd Bergmann , Will Deacon , Jingoo Han , Liviu Dudau , Jayachandran C , Kishon Vijay Abraham I , Jason Gunthorpe , Minghuan Lian , Simon Horman , Krzysztof Halasa , Murali Karicheri , Thierry Reding , Tanmay Inamdar , Lucas Stach X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On 5/14/2015 9:42 AM, Lorenzo Pieralisi wrote: > When a device is scanned and added to the PCI bus, its resources > should be claimed to validate the BARs configuration and to assign > them a parent resource so that the resource hierarchy can be sanity > checked. > > This patch adds code that carries out PCI device resources claiming to > the ARM64 pcibios_add_device implementation so that device resources > are claimed by the core PCI layer upon PCI device initialization on > ARM64 systems. > > Signed-off-by: Lorenzo Pieralisi > Cc: Arnd Bergmann > Cc: Will Deacon > Cc: Liviu Dudau > Cc: Bjorn Helgaas > --- > arch/arm64/kernel/pci.c | 10 ++++++++++ > 1 file changed, 10 insertions(+) > > diff --git a/arch/arm64/kernel/pci.c b/arch/arm64/kernel/pci.c > index 4095379..c0a88ca 100644 > --- a/arch/arm64/kernel/pci.c > +++ b/arch/arm64/kernel/pci.c > @@ -43,8 +43,18 @@ resource_size_t pcibios_align_resource(void *data, const struct resource *res, > */ > int pcibios_add_device(struct pci_dev *dev) > { > + struct resource *res; > + int i; > + > dev->irq = of_irq_parse_and_map_pci(dev, 0, 0); > > + for (i = 0; i < PCI_NUM_RESOURCES; i++) { > + res = &dev->resource[i]; > + if (res->parent || !res->flags) > + continue; > + pci_claim_resource(dev, i); > + } > + > return 0; > } > > Lorenzo/Bjorn, I have tested this patch on top of Jayachandran's V2 patch series (http://www.spinics.net/lists/linux-pci/msg40811.html) on AMD Seattle (w/ PROBE_ONLY and non-PROBE_ONLY mode), and your changes here works with additional changes below. It seems that when booting w/ PROBE_ONLY case, we need to call pci_read_bridge_bases() at some point before claiming the resources of devices underneath the bridge. This is needed to determine the bridge bases (i.e. bridge io, mmio and mmio_pref bases), and update bridge resources accordingly. ---- BEGIN PATCH ----- u8 pci_swizzle_interrupt_pin(const struct pci_dev *dev, u8 pin); ---- END PATCH ----- I'm not sure if this is the best place to be reading the bridge bases. I guess we should be able to do this when adding bridge devices. Thanks, Suravee diff --git a/arch/arm64/kernel/pci.c b/arch/arm64/kernel/pci.c index c0a88ca..57be6aa 100644 --- a/arch/arm64/kernel/pci.c +++ b/arch/arm64/kernel/pci.c @@ -48,6 +48,11 @@ int pcibios_add_device(struct pci_dev *dev) dev->irq = of_irq_parse_and_map_pci(dev, 0, 0); + if (pci_has_flag(PCI_PROBE_ONLY) && + !pci_is_root_bus(dev->bus) && + !pci_bridge_bases_is_read(dev->bus)) + pci_read_bridge_bases(dev->bus); + for (i = 0; i < PCI_NUM_RESOURCES; i++) { res = &dev->resource[i]; if (res->parent || !res->flags) diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c index 6675a7a..6cab8be 100644 --- a/drivers/pci/probe.c +++ b/drivers/pci/probe.c @@ -447,6 +447,13 @@ static void pci_read_bridge_mmio_pref(struct pci_bus *child) } } +bool pci_bridge_bases_is_read(struct pci_bus *bus) +{ + return (bus->resource[0]->start || + bus->resource[1]->start || + bus->resource[2]->start); +} + void pci_read_bridge_bases(struct pci_bus *child) { struct pci_dev *dev = child->self; diff --git a/include/linux/pci.h b/include/linux/pci.h index 353db8d..11c674d 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -798,6 +798,7 @@ void pci_device_add(struct pci_dev *dev, struct pci_bus *bus); unsigned int pci_scan_child_bus(struct pci_bus *bus); void pci_bus_add_device(struct pci_dev *dev); void pci_read_bridge_bases(struct pci_bus *child); +bool pci_bridge_bases_is_read(struct pci_bus *bus); struct resource *pci_find_parent_resource(const struct pci_dev *dev, struct resource *res);