From patchwork Wed May 23 22:37:05 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bjorn Helgaas X-Patchwork-Id: 161045 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 1F297B6F6E for ; Thu, 24 May 2012 08:44:11 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752329Ab2EWWoJ (ORCPT ); Wed, 23 May 2012 18:44:09 -0400 Received: from mail-vb0-f74.google.com ([209.85.212.74]:52064 "EHLO mail-vb0-f74.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751527Ab2EWWoI (ORCPT ); Wed, 23 May 2012 18:44:08 -0400 X-Greylist: delayed 421 seconds by postgrey-1.27 at vger.kernel.org; Wed, 23 May 2012 18:44:08 EDT Received: by vbnl22 with SMTP id l22so947883vbn.1 for ; Wed, 23 May 2012 15:44:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=subject:to:from:cc:date:message-id:in-reply-to:references :user-agent:mime-version:content-type:content-transfer-encoding; bh=y5Uy7Zq3N6Q4xpIaaEE381WFGervTjLRXPrl752Gjqs=; b=Vd/LeNm09ZHufMTNMSe8YUHWCb+DnoKHQeOysoMNoIc/GlB8GUZPmRNTeT7V3AwvjI 80cXHKTnlm/t5PlcHwHC9YDlSGNf66s1ipmmAg1QkhStfNUBEa6diDyMKS0GhL9JWuFZ 3V4wCmz0Eiea2Y9o+pkmxqI4NaYZNzOEbkjVOrr4HZXN98ROM7zyle07x9dkoOmyIXn1 WNqx/Fp6Qs1+5XfC0Yj7drQo7hhZfx0UerolOz/IDz/OQTerwDJvzZpOMTONr19KHUUR LjavhtuNs6kGNxAAgkQk8tvOxybR2yiSh4x5N8OwXvQtf5N3oHDLVMdm8vy/41c3eAPM 1pJg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=subject:to:from:cc:date:message-id:in-reply-to:references :user-agent:mime-version:content-type:content-transfer-encoding :x-gm-message-state; bh=y5Uy7Zq3N6Q4xpIaaEE381WFGervTjLRXPrl752Gjqs=; b=HCZfioGAVI1QoT9MNOadZxkXXw/eBVk2Fn9HATzKem1WCBr12yzt8zQn3dsksm8sET vwGkYjAEwy58Lb5T/F0yCcJqEXHOuT8Z++5rCD0O66Uaa6mrKmn5V99P8QyG1NWq46hY uetJafWik8xGYw5K5FHk4XVRLZQ0XOJrNzucq1nz5LgqGBmxWaZxNv6VACyybbsjfNFO bNTP/tYnrm7zUATEYIgz5NK5IMxVzLp+jzMfK5/JOvhESa5bghqJRUG5nakaJ028ITLP 5OJsA/rFxSLdkAkIjYuiml7ReTqgYEwtzzKWkB0I5MupLkgY8L4XCdbiqcDRDB/JUpYp nA/g== Received: by 10.100.86.20 with SMTP id j20mr14173566anb.14.1337812626550; Wed, 23 May 2012 15:37:06 -0700 (PDT) Received: by 10.100.86.20 with SMTP id j20mr14173549anb.14.1337812626395; Wed, 23 May 2012 15:37:06 -0700 (PDT) Received: from wpzn4.hot.corp.google.com (216-239-44-65.google.com [216.239.44.65]) by gmr-mx.google.com with ESMTPS id k35si156130yhb.3.2012.05.23.15.37.06 (version=TLSv1/SSLv3 cipher=AES128-SHA); Wed, 23 May 2012 15:37:06 -0700 (PDT) Received: from bhelgaas.mtv.corp.google.com (bhelgaas.mtv.corp.google.com [172.18.96.155]) by wpzn4.hot.corp.google.com (Postfix) with ESMTP id 32E271E02BC; Wed, 23 May 2012 15:37:06 -0700 (PDT) Received: from bhelgaas.mtv.corp.google.com (unknown [IPv6:::1]) by bhelgaas.mtv.corp.google.com (Postfix) with ESMTP id DDF1D18016D; Wed, 23 May 2012 15:37:05 -0700 (PDT) Subject: [PATCH v3 2/2] microblaze/PCI: move DMA & IRQ init to device_add() notification path To: Hiroo Matsumoto From: Bjorn Helgaas Cc: Michal Simek , benh@kernel.crashing.org, microblaze-uclinux@itee.uq.edu.au, linux-pci@vger.kernel.org, Jesse Larrew , jbarnes@virtuousgeek.org, Kenji Kaneshige , linuxppc-dev@lists.ozlabs.org Date: Wed, 23 May 2012 16:37:05 -0600 Message-ID: <20120523223705.24276.20161.stgit@bhelgaas.mtv.corp.google.com> In-Reply-To: <20120523222635.24276.80023.stgit@bhelgaas.mtv.corp.google.com> References: <20120523222635.24276.80023.stgit@bhelgaas.mtv.corp.google.com> User-Agent: StGit/0.15 MIME-Version: 1.0 X-Gm-Message-State: ALoCoQmr3SQGeo+irj1M3n4gP9Z+vMrCI2/IfKhZdpZ4ZSch7yY0wm7mAGOiFf9ynsBxapX6bMwltPzGN6JgIwlX1i1g4UxKWqm7fSLdstXCodIMdkZzzz44xHOqs5OMnSsOU5BUZgf1yPdUpQYvzabwM1Tlz13uJQ== Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org From: Hiroo Matsumoto Microblaze initialized DMA and IRQ information in the pci_scan_child_bus() -> pcibios_fixup_bus() path. Some hotplug drivers use that path, but others don't, e.g., pciehp, so sometimes hot-added devices are only partly initialized. This patch moves that initialization from pcibios_fixup_bus() to a new pci_bus_notify() called in the pci_bus_add_device() -> device_add() path. That means the initialization happens the same way for all PCI devices, whether they are present at boot or hot-added later. [bhelgaas: changelog, notifier name, inline registration] Signed-off-by: Hiroo MATSUMOTO Signed-off-by: Bjorn Helgaas --- arch/microblaze/include/asm/pci.h | 1 - arch/microblaze/pci/pci-common.c | 62 ++++++++++++++++++++----------------- 2 files changed, 34 insertions(+), 29 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe linux-pci" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/arch/microblaze/include/asm/pci.h b/arch/microblaze/include/asm/pci.h index a0da88b..2aa97fd 100644 --- a/arch/microblaze/include/asm/pci.h +++ b/arch/microblaze/include/asm/pci.h @@ -141,7 +141,6 @@ extern void pci_resource_to_user(const struct pci_dev *dev, int bar, const struct resource *rsrc, resource_size_t *start, resource_size_t *end); -extern void pcibios_setup_bus_devices(struct pci_bus *bus); extern void pcibios_setup_bus_self(struct pci_bus *bus); /* This part of code was originally in xilinx-pci.h */ diff --git a/arch/microblaze/pci/pci-common.c b/arch/microblaze/pci/pci-common.c index 9b32483..6487ed0 100644 --- a/arch/microblaze/pci/pci-common.c +++ b/arch/microblaze/pci/pci-common.c @@ -983,31 +983,6 @@ void __devinit pcibios_setup_bus_self(struct pci_bus *bus) pcibios_fixup_bridge(bus); } -void __devinit pcibios_setup_bus_devices(struct pci_bus *bus) -{ - struct pci_dev *dev; - - pr_debug("PCI: Fixup bus devices %d (%s)\n", - bus->number, bus->self ? pci_name(bus->self) : "PHB"); - - list_for_each_entry(dev, &bus->devices, bus_list) { - /* Setup OF node pointer in archdata */ - dev->dev.of_node = pci_device_to_OF_node(dev); - - /* Fixup NUMA node as it may not be setup yet by the generic - * code and is needed by the DMA init - */ - set_dev_node(&dev->dev, pcibus_to_node(dev->bus)); - - /* Hook up default DMA ops */ - set_dma_ops(&dev->dev, pci_dma_ops); - dev->dev.archdata.dma_data = (void *)PCI_DRAM_OFFSET; - - /* Read default IRQs and fixup if necessary */ - pci_read_irq_line(dev); - } -} - void __devinit pcibios_fixup_bus(struct pci_bus *bus) { /* When called from the generic PCI probe, read PCI<->PCI bridge @@ -1019,9 +994,6 @@ void __devinit pcibios_fixup_bus(struct pci_bus *bus) /* Now fixup the bus bus */ pcibios_setup_bus_self(bus); - - /* Now fixup devices on that bus */ - pcibios_setup_bus_devices(bus); } EXPORT_SYMBOL(pcibios_fixup_bus); @@ -1512,6 +1484,38 @@ static void __devinit pcibios_scan_phb(struct pci_controller *hose) hose->last_busno = bus->busn_res.end; } +static int pci_bus_notify(struct notifier_block *nb, unsigned long action, + void *data) +{ + struct pci_dev *dev = to_pci_dev(data); + + switch (action) { + case BUS_NOTIFY_ADD_DEVICE: + /* Setup OF node pointer in archdata */ + dev->dev.of_node = pci_device_to_OF_node(dev); + + /* Fixup NUMA node as it may not be setup yet by the generic + * code and is needed by the DMA init + */ + set_dev_node(&dev->dev, pcibus_to_node(dev->bus)); + + /* Hook up default DMA ops */ + set_dma_ops(&dev->dev, pci_dma_ops); + dev->dev.archdata.dma_data = (void *)PCI_DRAM_OFFSET; + + /* Read default IRQs and fixup if necessary */ + pci_read_irq_line(dev); + + break; + } + + return 0; +} + +static struct notifier_block device_nb = { + .notifier_call = pci_bus_notify, +}; + static int __init pcibios_init(void) { struct pci_controller *hose, *tmp; @@ -1519,6 +1523,8 @@ static int __init pcibios_init(void) printk(KERN_INFO "PCI: Probing PCI hardware\n"); + bus_register_notifier(&pci_bus_type, &device_nb); + /* Scan all of the recorded PCI controllers. */ list_for_each_entry_safe(hose, tmp, &hose_list, list_node) { hose->last_busno = 0xff;