From patchwork Wed Feb 12 22:24:14 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Gunthorpe X-Patchwork-Id: 3641281 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.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id A0AE9BF13A for ; Wed, 12 Feb 2014 22:24:54 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B9F4220158 for ; Wed, 12 Feb 2014 22:24:53 +0000 (UTC) Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (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 B60AD20149 for ; Wed, 12 Feb 2014 22:24:52 +0000 (UTC) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1WDiEW-0005o4-HH; Wed, 12 Feb 2014 22:24:44 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1WDiEU-0003VD-3j; Wed, 12 Feb 2014 22:24:42 +0000 Received: from quartz.orcorp.ca ([184.70.90.242]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1WDiEQ-0003UV-UG for linux-arm-kernel@lists.infradead.org; Wed, 12 Feb 2014 22:24:39 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=obsidianresearch.com; s=rsa1; h=In-Reply-To:Content-Type:MIME-Version:References:Message-ID:Subject:Cc:To:From:Date; bh=zyBCxeRHM4NHh+/1iPSvRlYI+m7jmFGO/yiYtIxJt2E=; b=OEJqLtzGGsEZg3x1JXscHzsbNh+yXy2b7gm5yoh5ufMPR96zrwE5CDhCJldRmfzIYDrr3CkspLAjSyHLrG1TwiAaSpld0bU2PDUvye7Z5grJjaEj7OpDwIodUBKgQJv57J1agClx5YLHx8nvG8s6lDqqmha3c0dKg04saNckUEU=; Received: from [10.0.0.161] (helo=jggl.edm.orcorp.ca) by quartz.orcorp.ca with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.72) (envelope-from ) id 1WDiE3-0007RS-2s; Wed, 12 Feb 2014 15:24:15 -0700 Received: from jgg by jggl.edm.orcorp.ca with local (Exim 4.80) (envelope-from ) id 1WDiE2-0005qw-Mp; Wed, 12 Feb 2014 15:24:14 -0700 Date: Wed, 12 Feb 2014 15:24:14 -0700 From: Jason Gunthorpe To: Thomas Petazzoni Subject: Re: [PATCH 2/3] PCI: ARM: add support for virtual PCI host controller Message-ID: <20140212222414.GB17248@obsidianresearch.com> References: <1391532784-1953-1-git-send-email-will.deacon@arm.com> <201402092130.25615.arnd@arndb.de> <20140210173450.GA5554@obsidianresearch.com> <2006726.HhIT01YuXY@wuerfel> <20140212194313.GA17248@obsidianresearch.com> <20140212221526.60fd7f8b@skate> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20140212221526.60fd7f8b@skate> User-Agent: Mutt/1.5.21 (2010-09-15) X-Broken-Reverse-DNS: no host name found for IP address 10.0.0.161 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140212_172439_095254_EA3F42F3 X-CRM114-Status: GOOD ( 14.45 ) X-Spam-Score: -2.0 (--) Cc: "linux-pci@vger.kernel.org" , linux-arm-kernel@lists.infradead.org, Arnd Bergmann X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 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.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,RP_MATCHES_RCVD,T_DKIM_INVALID,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 Wed, Feb 12, 2014 at 10:15:26PM +0100, Thomas Petazzoni wrote: > > +#ifdef CONFIG_PCI_DOMAINS > > + domain = sys->domain; > > +#endif > > + > > + snprintf(pcie->mem_name, sizeof(pcie->mem_name), "PCI MEM %04x", domain); > > + pcie->mem.name = pcie->mem_name; > > + > > + snprintf(pcie->io_name, sizeof(pcie->io_name), "PCI I/O %04x", domain); > > + pcie->realio.name = pcie->io_name; > > I honestly don't know what PCI domains are, but this change looks > fairly harmless to me. I would however use kasprintf() instead maybe. I > can submit patches for those two changes if you want. For this purpose imagine that each PCI host controller driver gets a unique domain, and every domain has a unique aperture. domain:bus:device:function is the full unique path to a PCI device. So when you look at the resource hierarchy it makes some logical sense: e0000000-efffffff : PCI MEM 0000 e0000000-e00fffff : PCI Bus 0000:01 e0000000-e001ffff : 0000:01:00.0 PCI Domain -> domain + subordinate bus # -> domain:bus:device:function, bar # The ARM PCI BIOS code used bus number, and Will's version ended up using the DT path to the PCI node. Would be nice to see an agreement/common code :) > > Still missing release_region.. > > To match which request_region? Ah, sorry, Arnd added one: Which is why I didn't use kasprintf, that would complicate freeing further. Ideally we'd be able to use a devm_request_region someday. Jason diff --git a/drivers/pci/host/pci-mvebu.c b/drivers/pci/host/pci-mvebu.c index 13478ec..b55e9a6 100644 --- a/drivers/pci/host/pci-mvebu.c +++ b/drivers/pci/host/pci-mvebu.c @@ -680,9 +680,17 @@ static int mvebu_pcie_setup(int nr, struct pci_sys_data *sys) struct mvebu_pcie *pcie = sys_to_pcie(sys); int i; - if (resource_size(&pcie->realio) != 0) + if (request_resource(&iomem_resource, &pcie->mem)) + return 0; + + if (resource_size(&pcie->realio) != 0) { + if (request_resource(&ioport_resource, &pcie->realio)) { + release_resource(&pcie->mem); + return 0; + } pci_add_resource_offset(&sys->resources, &pcie->realio, sys->io_offset); + } pci_add_resource_offset(&sys->resources, &pcie->mem, sys->mem_offset); pci_add_resource(&sys->resources, &pcie->busn);