Patchwork powerpc/pci-hotplug: fix the rescanned pci device's dma_set_mask issue

login
register
mail settings
Submitter Yuanquan Chen
Date Nov. 23, 2012, 4:29 a.m.
Message ID <1353644968-29469-1-git-send-email-B41889@freescale.com>
Download mbox | patch
Permalink /patch/201395/
State Changes Requested
Headers show

Comments

Yuanquan Chen - Nov. 23, 2012, 4:29 a.m.
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 <B41889@freescale.com>
---
 arch/powerpc/include/asm/dma-mapping.h |    7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
Kumar Gala - Nov. 25, 2012, 12:41 p.m.
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 <B41889@freescale.com>
> ---
> 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

> 
> 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

Patch

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);