[PATCH] powerpc/pci-hotplug: fix the rescanned pci device's dma_set_mask issue

Subsystems: linux for powerpc (32-bit and 64-bit), the rest

STALE4989d

6 messages, 2 authors, 2012-12-04 · open the first message on its own page

[PATCH] powerpc/pci-hotplug: fix the rescanned pci device's dma_set_mask issue

From: Yuanquan Chen <hidden>
Date: 2012-11-23 04:29:16

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 <redacted>
---
 arch/powerpc/include/asm/dma-mapping.h |    7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
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

Re: [PATCH] powerpc/pci-hotplug: fix the rescanned pci device's dma_set_mask issue

From: Kumar Gala <hidden>
Date: 2012-11-25 12:41:11

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.
=20
Signed-off-by: Yuanquan Chen <redacted>
---
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
quoted hunk
=20
diff --git a/arch/powerpc/include/asm/dma-mapping.h =
b/arch/powerpc/include/asm/dma-mapping.h
quoted hunk
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 =3D get_dma_ops(dev);
=20
-	if (unlikely(dma_ops =3D=3D NULL))
-		return 0;
+	if (unlikely(dma_ops =3D=3D NULL)) {
+		set_dma_ops(dev, &dma_direct_ops);
+		set_dma_offset(dev, PCI_DRAM_OFFSET);
+		dma_ops =3D &dma_direct_ops;
+	}
	if (dma_ops->dma_supported =3D=3D NULL)
		return 1;
	return dma_ops->dma_supported(dev, mask);
--=20
1.7.9.5
=20
=20
_______________________________________________
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

Re: [PATCH] powerpc/pci-hotplug: fix the rescanned pci device's dma_set_mask issue

From: Chen Yuanquan-B41889 <hidden>
Date: 2012-11-26 05:29:38

On 11/25/2012 08:41 PM, Kumar Gala wrote:
On Nov 22, 2012, at 10:29 PM, Yuanquan Chen wrote:
quoted
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 <redacted>
---
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/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);
  }
quoted
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

Re: [PATCH] powerpc/pci-hotplug: fix the rescanned pci device's dma_set_mask issue

From: Chen Yuanquan-B41889 <hidden>
Date: 2012-11-28 02:34:05

On 11/25/2012 08:41 PM, Kumar Gala wrote:
On Nov 22, 2012, at 10:29 PM, Yuanquan Chen wrote:
quoted
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 <redacted>
---
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/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);
  }
quoted
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

Re: [PATCH] powerpc/pci-hotplug: fix the rescanned pci device's dma_set_mask issue

From: Kumar Gala <hidden>
Date: 2012-11-29 13:05:02

On Nov 27, 2012, at 8:34 PM, Chen Yuanquan-B41889 wrote:
On 11/25/2012 08:41 PM, Kumar Gala wrote:
quoted
On Nov 22, 2012, at 10:29 PM, Yuanquan Chen wrote:
=20
quoted
On powerpc arch, dma_ops of rescanned pci device after system's =
booting up won't be
quoted
quoted
initialized by system, so it will fail to execute the dma_set_mask =
in the device's
quoted
quoted
driver. Initialize it to solve this issue.
=20
Signed-off-by: Yuanquan Chen <redacted>
---
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.
quoted
=20
- k
=20
Hi Kumar,
=20
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
quoted hunk
your opinion?
=20
Thanks,
yuanquan
=20
diff --git a/arch/powerpc/kernel/pci-common.c =
b/arch/powerpc/kernel/pci-common.c
quoted hunk
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;
=20
+       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);
}
=20
This looks better than the first patch..  I'm surprised that the IBM =
guys don't run into a similar issue with their hotplug support.

Maybe Ben or someone else will comment.

- k
quoted
quoted
diff --git a/arch/powerpc/include/asm/dma-mapping.h =
b/arch/powerpc/include/asm/dma-mapping.h
quoted
quoted
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)
quoted
quoted
{
	struct dma_map_ops *dma_ops =3D get_dma_ops(dev);
=20
-	if (unlikely(dma_ops =3D=3D NULL))
-		return 0;
+	if (unlikely(dma_ops =3D=3D NULL)) {
+		set_dma_ops(dev, &dma_direct_ops);
+		set_dma_offset(dev, PCI_DRAM_OFFSET);
+		dma_ops =3D &dma_direct_ops;
+	}
	if (dma_ops->dma_supported =3D=3D NULL)
		return 1;
	return dma_ops->dma_supported(dev, mask);
--=20
1.7.9.5
=20
=20
_______________________________________________
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev
=20
=20
=20
=20

Re: [PATCH] powerpc/pci-hotplug: fix the rescanned pci device's dma_set_mask issue

From: Kumar Gala <hidden>
Date: 2012-12-04 14:33:07

On Nov 28, 2012, at 11:34 AM, Kumar Gala wrote:
=20
On Nov 27, 2012, at 8:34 PM, Chen Yuanquan-B41889 wrote:
=20
quoted
On 11/25/2012 08:41 PM, Kumar Gala wrote:
quoted
On Nov 22, 2012, at 10:29 PM, Yuanquan Chen wrote:
=20
quoted
On powerpc arch, dma_ops of rescanned pci device after system's =
booting up won't be
quoted
quoted
quoted
initialized by system, so it will fail to execute the dma_set_mask =
in the device's
quoted
quoted
quoted
driver. Initialize it to solve this issue.
=20
Signed-off-by: Yuanquan Chen <redacted>
---
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.
quoted
quoted
=20
- k
=20
Hi Kumar,
=20
I read the code about pci bus scan and rescan. Only the =
pcibios_fixup_bus in pci_scan_child_bus and
quoted
pcibios_enable_device in pci_rescan_bus are arch related code. The =
pcibios_fixup_bus won't be called
quoted
for the rescanned PCI devices due to the bus->is_added has been set =
for the first scanning at boot time.
quoted
So I think it's more reasonable to do the same work as =
pcibios_fixup_bus for rescanned PCI device in
quoted
pcibios_enable_device. The patch code is a copy of =
pcibios_setup_bus_devices called by pcibios_fixup_bus,
quoted
It can solve the dma_set_mask and irq related issues of rescanned PCI =
device on powerpc arch. What's
quoted
your opinion?
=20
Thanks,
yuanquan
=20
diff --git a/arch/powerpc/kernel/pci-common.c =
b/arch/powerpc/kernel/pci-common.c
quoted
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)
quoted
              if (ppc_md.pcibios_enable_device_hook(dev))
                      return -EINVAL;
=20
+       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);
}
=20
=20
This looks better than the first patch..  I'm surprised that the IBM =
guys don't run into a similar issue with their hotplug support.
=20
Maybe Ben or someone else will comment.
=20
- k
How about you post this as a clean patch, will be easier to get Ben to =
comment on that.

- k=
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help