From patchwork Wed Dec 5 02:31:57 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yuanquan Chen X-Patchwork-Id: 203771 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from ozlabs.org (localhost [IPv6:::1]) by ozlabs.org (Postfix) with ESMTP id 316492C03A2 for ; Wed, 5 Dec 2012 13:32:23 +1100 (EST) Received: from co1outboundpool.messaging.microsoft.com (co1ehsobe005.messaging.microsoft.com [216.32.180.188]) (using TLSv1 with cipher AES128-SHA (128/128 bits)) (Client CN "mail.global.frontbridge.com", Issuer "Microsoft Secure Server Authority" (not verified)) by ozlabs.org (Postfix) with ESMTPS id E23C62C009B for ; Wed, 5 Dec 2012 13:31:57 +1100 (EST) Received: from mail14-co1-R.bigfish.com (10.243.78.238) by CO1EHSOBE005.bigfish.com (10.243.66.68) with Microsoft SMTP Server id 14.1.225.23; Wed, 5 Dec 2012 02:31:52 +0000 Received: from mail14-co1 (localhost [127.0.0.1]) by mail14-co1-R.bigfish.com (Postfix) with ESMTP id 9F52E9C02FF; Wed, 5 Dec 2012 02:31:52 +0000 (UTC) X-Forefront-Antispam-Report: CIP:70.37.183.190; KIP:(null); UIP:(null); IPV:NLI; H:mail.freescale.net; RD:none; EFVD:NLI X-SpamScore: 3 X-BigFish: VS3(zzzz1de0h1202h1d1ah1d2ah1082kzz8275bhz2dh2a8h668h839he5bhf0ah1288h12a5h12a9h12bdh12e5h137ah139eh13b6h1441h1504h1537h162dh1631h1155h) Received: from mail14-co1 (localhost.localdomain [127.0.0.1]) by mail14-co1 (MessageSwitch) id 1354674711240042_5571; Wed, 5 Dec 2012 02:31:51 +0000 (UTC) Received: from CO1EHSMHS017.bigfish.com (unknown [10.243.78.230]) by mail14-co1.bigfish.com (Postfix) with ESMTP id 3842B46009A; Wed, 5 Dec 2012 02:31:51 +0000 (UTC) Received: from mail.freescale.net (70.37.183.190) by CO1EHSMHS017.bigfish.com (10.243.66.27) with Microsoft SMTP Server (TLS) id 14.1.225.23; Wed, 5 Dec 2012 02:31:51 +0000 Received: from az84smr01.freescale.net (10.64.34.197) by 039-SN1MMR1-004.039d.mgd.msft.net (10.84.1.14) with Microsoft SMTP Server (TLS) id 14.2.318.3; Wed, 5 Dec 2012 02:31:49 +0000 Received: from ubuntu.ap.freescale.net ([10.193.20.25]) by az84smr01.freescale.net (8.14.3/8.14.0) with ESMTP id qB52Vjbo026210; Tue, 4 Dec 2012 19:31:46 -0700 From: Yuanquan Chen To: Subject: [linuxppc-release][PATCH] powerpc/pci-hotplug: fix init issue of rescanned pci device Date: Wed, 5 Dec 2012 10:31:57 +0800 Message-ID: <1354674717-14426-1-git-send-email-B41889@freescale.com> X-Mailer: git-send-email 1.7.9.5 MIME-Version: 1.0 X-OriginatorOrg: freescale.com Cc: Yuanquan Chen , r61911@freescale.com X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" On powerpc arch, some fixup work of PCI/PCI-e device is just done during the first scan at booting time. For the PCI/PCI-e device rescanned after linux OS booting up, the fixup work won't be done, which leads to dma_set_mask error or irq related issue in rescanned PCI/PCI-e device's driver. So, it does the same fixup work for the rescanned device to avoid this issue. Signed-off-by: Yuanquan Chen --- arch/powerpc/kernel/pci-common.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/arch/powerpc/kernel/pci-common.c b/arch/powerpc/kernel/pci-common.c index 7f94f76..f0fb070 100644 --- a/arch/powerpc/kernel/pci-common.c +++ b/arch/powerpc/kernel/pci-common.c @@ -1496,6 +1496,26 @@ int pcibios_enable_device(struct pci_dev *dev, int mask) if (ppc_md.pcibios_enable_device_hook(dev)) return -EINVAL; + if (!dev->is_added) { + /* + * 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); + set_dma_offset(&dev->dev, PCI_DRAM_OFFSET); + + /* Additional platform DMA/iommu setup */ + if (ppc_md.pci_dma_dev_setup) + ppc_md.pci_dma_dev_setup(dev); + + /* Read default IRQs and fixup if necessary */ + pci_read_irq_line(dev); + if (ppc_md.pci_irq_fixup) + ppc_md.pci_irq_fixup(dev); + } return pci_enable_resources(dev, mask); }