From patchwork Mon Nov 26 05:29:58 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yuanquan Chen X-Patchwork-Id: 201627 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 959822C0385 for ; Mon, 26 Nov 2012 16:30:11 +1100 (EST) Received: from co1outboundpool.messaging.microsoft.com (co1ehsobe006.messaging.microsoft.com [216.32.180.189]) (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 8EC862C007C for ; Mon, 26 Nov 2012 16:29:38 +1100 (EST) Received: from mail24-co1-R.bigfish.com (10.243.78.239) by CO1EHSOBE010.bigfish.com (10.243.66.73) with Microsoft SMTP Server id 14.1.225.23; Mon, 26 Nov 2012 05:29:34 +0000 Received: from mail24-co1 (localhost [127.0.0.1]) by mail24-co1-R.bigfish.com (Postfix) with ESMTP id 16C3290005C; Mon, 26 Nov 2012 05:29:34 +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: -5 X-BigFish: VS-5(zzbb2dI98dI9371I1432I4015Izz1de0h1202h1d1ah1d2ahzz8275bh8275dhz2dh2a8h668h839hd25he5bhf0ah1288h12a5h12a9h12bdh137ah13b6h1441h1504h1537h153bh162dh1631h1155h) Received: from mail24-co1 (localhost.localdomain [127.0.0.1]) by mail24-co1 (MessageSwitch) id 1353907771952904_3172; Mon, 26 Nov 2012 05:29:31 +0000 (UTC) Received: from CO1EHSMHS003.bigfish.com (unknown [10.243.78.231]) by mail24-co1.bigfish.com (Postfix) with ESMTP id E41A1A8005F; Mon, 26 Nov 2012 05:29:31 +0000 (UTC) Received: from mail.freescale.net (70.37.183.190) by CO1EHSMHS003.bigfish.com (10.243.66.13) with Microsoft SMTP Server (TLS) id 14.1.225.23; Mon, 26 Nov 2012 05:29:30 +0000 Received: from tx30smr01.am.freescale.net (10.81.153.31) by 039-SN1MMR1-004.039d.mgd.msft.net (10.84.1.14) with Microsoft SMTP Server (TLS) id 14.2.318.3; Mon, 26 Nov 2012 05:29:29 +0000 Received: from [10.193.20.25] (ubuntu-010193020025.ap.freescale.net [10.193.20.25]) by tx30smr01.am.freescale.net (8.14.3/8.14.0) with ESMTP id qAQ5TPiq012263; Sun, 25 Nov 2012 22:29:28 -0700 Message-ID: <50B2FE56.4080605@freescale.com> Date: Mon, 26 Nov 2012 13:29:58 +0800 From: Chen Yuanquan-B41889 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:14.0) Gecko/20120714 Thunderbird/14.0 MIME-Version: 1.0 To: Kumar Gala Subject: Re: [PATCH] powerpc/pci-hotplug: fix the rescanned pci device's dma_set_mask issue References: <1353644968-29469-1-git-send-email-B41889@freescale.com> <455E76A9-ABB3-4FF6-A19E-612E43223C4A@kernel.crashing.org> In-Reply-To: <455E76A9-ABB3-4FF6-A19E-612E43223C4A@kernel.crashing.org> X-OriginatorOrg: freescale.com Cc: linuxppc-dev@lists.ozlabs.org, 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 11/25/2012 08:41 PM, Kumar Gala wrote: > On Nov 22, 2012, at 10:29 PM, Yuanquan Chen wrote: > >> On powerpc arch, dma_ops of rescanned pci device after system's booting up won't be >> initialized by system, so it will fail to execute the dma_set_mask in the device's >> driver. Initialize it to solve this issue. >> >> Signed-off-by: Yuanquan Chen >> --- >> arch/powerpc/include/asm/dma-mapping.h | 7 +++++-- >> 1 file changed, 5 insertions(+), 2 deletions(-) > This is not the right way to get the dma_ops setup. You need to find some other point for the hotplug scenario to get the dma_ops setup. > > - k Hi Kumar, I read the code about pci bus scan and rescan. Only the pcibios_fixup_bus in pci_scan_child_bus and pcibios_enable_device in pci_rescan_bus are arch related code. The pcibios_fixup_bus won't be called for the rescanned PCI devices due to the bus->is_added has been set for the first scanning at boot time. So I think it's more reasonable to do the same work as pcibios_fixup_bus for rescanned PCI device in pcibios_enable_device. The patch code is a copy of pcibios_setup_bus_devices called by pcibios_fixup_bus, It can solve the dma_set_mask and irq related issues of rescanned PCI device on powerpc arch. What's your opinion? Thanks, yuanquan >> diff --git a/arch/powerpc/include/asm/dma-mapping.h b/arch/powerpc/include/asm/dma-mapping.h >> index 7816087..22eae53 100644 >> --- a/arch/powerpc/include/asm/dma-mapping.h >> +++ b/arch/powerpc/include/asm/dma-mapping.h >> @@ -126,8 +126,11 @@ static inline int dma_supported(struct device *dev, u64 mask) >> { >> struct dma_map_ops *dma_ops = get_dma_ops(dev); >> >> - if (unlikely(dma_ops == NULL)) >> - return 0; >> + if (unlikely(dma_ops == NULL)) { >> + set_dma_ops(dev, &dma_direct_ops); >> + set_dma_offset(dev, PCI_DRAM_OFFSET); >> + dma_ops = &dma_direct_ops; >> + } >> if (dma_ops->dma_supported == NULL) >> return 1; >> return dma_ops->dma_supported(dev, mask); >> -- >> 1.7.9.5 >> >> >> _______________________________________________ >> Linuxppc-dev mailing list >> Linuxppc-dev@lists.ozlabs.org >> https://lists.ozlabs.org/listinfo/linuxppc-dev > > > diff --git a/arch/powerpc/kernel/pci-common.c b/arch/powerpc/kernel/pci-common.c index 7f94f76..30f7d61 100644 --- a/arch/powerpc/kernel/pci-common.c +++ b/arch/powerpc/kernel/pci-common.c @@ -1496,6 +1496,23 @@ int pcibios_enable_device(struct pci_dev *dev, int mask) if (ppc_md.pcibios_enable_device_hook(dev)) return -EINVAL; + if (!dev->is_added) { + 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); }