Skip to contentSkip to conversation

of: Drop reserved mem dependency on DMA_DECLARE_COHERENT and DMA_CMA

PATCH In review Rob Herring 2 participants 4 messages May 27, 2021 – Jun 1, 2021 Device tree

lore
Share & tools
lore

Rob Herring

author maintainer
#0 lore raw

PATCH 1/1 of: Drop reserved mem dependency on DMA_DECLARE_COHERENT and DMA_CMA

Reserved memory regions can be used for more than just DMA regions, so only enabling on DMA_DECLARE_COHERENT (via HAS_DMA) or DMA_CMA is wrong. This effectively doesn't matter except for the few cases arches select NO_DMA.

At least, these users of RESERVEDMEM_OF_DECLARE depend on reserved memory support:

arch/riscv/mm/init.c:RESERVEDMEM_OF_DECLARE(elfcorehdr, "linux,elfcorehdr", elfcore_hdr_setup); drivers/memory/tegra/tegra210-emc-table.c:RESERVEDMEM_OF_DECLARE(tegra210_emc_table, "nvidia,tegra210-emc-table", drivers/soc/fsl/qbman/bman_ccsr.c:RESERVEDMEM_OF_DECLARE(bman_fbpr, "fsl,bman-fbpr", bman_fbpr); drivers/soc/fsl/qbman/qman_ccsr.c:RESERVEDMEM_OF_DECLARE(qman_fqd, "fsl,qman-fqd", qman_fqd); drivers/soc/fsl/qbman/qman_ccsr.c:RESERVEDMEM_OF_DECLARE(qman_pfdr, "fsl,qman-pfdr", qman_pfdr);

Let's simplify things and enable OF_RESERVED_MEM when OF_EARLY_FLATTREE is enabled.

Cc Christoph Hellwig <[email protected]>

---
This is needed to prevent build break on UML with this patch:

https://lore.kernel.org/lkml/[email protected]/

 drivers/of/Kconfig | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/of/Kconfig +1 -3
index 18450437d5d5..3dfeae8912df 100644
@@ -75,9 +75,7 @@ config OF_NET
 	def_bool y
 
 config OF_RESERVED_MEM
-	bool
-	depends on OF_EARLY_FLATTREE
-	default y if DMA_DECLARE_COHERENT || DMA_CMA
+	def_bool OF_EARLY_FLATTREE
 
 config OF_RESOLVE
 	bool
Signature · 1 line
2.27.0
#1 lore raw
Quoted 14 lines · Rob Herring

Reserved memory regions can be used for more than just DMA regions, so only enabling on DMA_DECLARE_COHERENT (via HAS_DMA) or DMA_CMA is wrong. This effectively doesn't matter except for the few cases arches select NO_DMA.

At least, these users of RESERVEDMEM_OF_DECLARE depend on reserved memory support:

arch/riscv/mm/init.c:RESERVEDMEM_OF_DECLARE(elfcorehdr, "linux,elfcorehdr", elfcore_hdr_setup); drivers/memory/tegra/tegra210-emc-table.c:RESERVEDMEM_OF_DECLARE(tegra210_emc_table, "nvidia,tegra210-emc-table", drivers/soc/fsl/qbman/bman_ccsr.c:RESERVEDMEM_OF_DECLARE(bman_fbpr, "fsl,bman-fbpr", bman_fbpr); drivers/soc/fsl/qbman/qman_ccsr.c:RESERVEDMEM_OF_DECLARE(qman_fqd, "fsl,qman-fqd", qman_fqd); drivers/soc/fsl/qbman/qman_ccsr.c:RESERVEDMEM_OF_DECLARE(qman_pfdr, "fsl,qman-pfdr", qman_pfdr);

Quoted 5 lines

Let's simplify things and enable OF_RESERVED_MEM when OF_EARLY_FLATTREE is enabled.

Cc Christoph Hellwig <[email protected]>

Hi Rob,

I'm OK with this patch, but with or without this patch, compiling kernel/dma/coherent.c without HAS_IOMEM (!) has build errors:

s390-linux-ld: kernel/dma/coherent.o: in function `dma_init_coherent_memory':
coherent.c:(.text+0x5ae): undefined reference to `memremap'
s390-linux-ld: coherent.c:(.text+0x7a4): undefined reference to `memunmap'
s390-linux-ld: kernel/dma/coherent.o: in function `dma_declare_coherent_memory':
coherent.c:(.text+0xd84): undefined reference to `memunmap'

along with a slew of other build errors (arch/s390/, CONFIG_PCI is not set, CONFIG_HAS_IOMEM is not set):

s390-linux-ld: drivers/irqchip/irq-al-fic.o: in function `al_fic_init_dt':
irq-al-fic.c:(.init.text+0x6a0): undefined reference to `iounmap'
s390-linux-ld: drivers/char/xillybus/xillybus_of.o: in function `xilly_drv_probe':
xillybus_of.c:(.text+0x2c8): undefined reference to `devm_platform_ioremap_resource'
s390-linux-ld: drivers/pcmcia/cistpl.o: in function `set_cis_map':
cistpl.c:(.text+0x87a): undefined reference to `ioremap'
s390-linux-ld: cistpl.c:(.text+0x99a): undefined reference to `iounmap'
s390-linux-ld: cistpl.c:(.text+0xa34): undefined reference to `iounmap'
s390-linux-ld: cistpl.c:(.text+0xaa6): undefined reference to `ioremap'
s390-linux-ld: drivers/pcmcia/cistpl.o: in function `release_cis_mem':
cistpl.c:(.text+0x2976): undefined reference to `iounmap'
s390-linux-ld: drivers/of/address.o: in function `of_iomap':
address.c:(.text+0x1f02): undefined reference to `ioremap'
s390-linux-ld: drivers/of/address.o: in function `of_io_request_and_map':
address.c:(.text+0x2030): undefined reference to `ioremap'

Quoted 24 lines

---
This is needed to prevent build break on UML with this patch:

https://lore.kernel.org/lkml/[email protected]/

 drivers/of/Kconfig | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/of/Kconfig +1 -3
index 18450437d5d5..3dfeae8912df 100644
@@ -75,9 +75,7 @@ config OF_NET
 	def_bool y
 
 config OF_RESERVED_MEM
-	bool
-	depends on OF_EARLY_FLATTREE
-	default y if DMA_DECLARE_COHERENT || DMA_CMA
+	def_bool OF_EARLY_FLATTREE
 
 config OF_RESOLVE
 	bool
Signature · 1 line
~Randy
#2 lore raw
Quoted 37 lines · Randy Dunlap
Quoted 14 lines · Rob Herring

Reserved memory regions can be used for more than just DMA regions, so only enabling on DMA_DECLARE_COHERENT (via HAS_DMA) or DMA_CMA is wrong. This effectively doesn't matter except for the few cases arches select NO_DMA.

At least, these users of RESERVEDMEM_OF_DECLARE depend on reserved memory support:

arch/riscv/mm/init.c:RESERVEDMEM_OF_DECLARE(elfcorehdr, "linux,elfcorehdr", elfcore_hdr_setup); drivers/memory/tegra/tegra210-emc-table.c:RESERVEDMEM_OF_DECLARE(tegra210_emc_table, "nvidia,tegra210-emc-table", drivers/soc/fsl/qbman/bman_ccsr.c:RESERVEDMEM_OF_DECLARE(bman_fbpr, "fsl,bman-fbpr", bman_fbpr); drivers/soc/fsl/qbman/qman_ccsr.c:RESERVEDMEM_OF_DECLARE(qman_fqd, "fsl,qman-fqd", qman_fqd); drivers/soc/fsl/qbman/qman_ccsr.c:RESERVEDMEM_OF_DECLARE(qman_pfdr, "fsl,qman-pfdr", qman_pfdr);

Quoted 5 lines

Let's simplify things and enable OF_RESERVED_MEM when OF_EARLY_FLATTREE is enabled.

Cc Christoph Hellwig <[email protected]>

Hi Rob,

I'm OK with this patch, but with or without this patch, compiling kernel/dma/coherent.c without HAS_IOMEM (!) has build errors:

s390-linux-ld: kernel/dma/coherent.o: in function `dma_init_coherent_memory':
coherent.c:(.text+0x5ae): undefined reference to `memremap'
s390-linux-ld: coherent.c:(.text+0x7a4): undefined reference to `memunmap'
s390-linux-ld: kernel/dma/coherent.o: in function `dma_declare_coherent_memory':
coherent.c:(.text+0xd84): undefined reference to `memunmap'

along with a slew of other build errors (arch/s390/, CONFIG_PCI is not set, CONFIG_HAS_IOMEM is not set):

Quoted 16 lines

s390-linux-ld: drivers/irqchip/irq-al-fic.o: in function `al_fic_init_dt':
irq-al-fic.c:(.init.text+0x6a0): undefined reference to `iounmap'
s390-linux-ld: drivers/char/xillybus/xillybus_of.o: in function `xilly_drv_probe':
xillybus_of.c:(.text+0x2c8): undefined reference to `devm_platform_ioremap_resource'
s390-linux-ld: drivers/pcmcia/cistpl.o: in function `set_cis_map':
cistpl.c:(.text+0x87a): undefined reference to `ioremap'
s390-linux-ld: cistpl.c:(.text+0x99a): undefined reference to `iounmap'
s390-linux-ld: cistpl.c:(.text+0xa34): undefined reference to `iounmap'
s390-linux-ld: cistpl.c:(.text+0xaa6): undefined reference to `ioremap'
s390-linux-ld: drivers/pcmcia/cistpl.o: in function `release_cis_mem':
cistpl.c:(.text+0x2976): undefined reference to `iounmap'
s390-linux-ld: drivers/of/address.o: in function `of_iomap':
address.c:(.text+0x1f02): undefined reference to `ioremap'
s390-linux-ld: drivers/of/address.o: in function `of_io_request_and_map':
address.c:(.text+0x2030): undefined reference to `ioremap'

Oops, sorry. I should have said that this is also with my experimental path that I thought you suggested earlier this week (although I could have misunderstood you):

drivers/of/Kconfig +1 -1
@@ -64,7 +64,7 @@ config OF_DYNAMIC
 
 config OF_ADDRESS
 	def_bool y
-	depends on !SPARC && (HAS_IOMEM || UML)
+	depends on !SPARC
 
 config OF_IRQ
 	def_bool y

[rebuild]

OK, even without this small patch, the result is about the same (just a few different function names):

s390-linux-ld: kernel/dma/coherent.o: in function `dma_init_coherent_memory':
coherent.c:(.text+0x5ae): undefined reference to `memremap'
s390-linux-ld: coherent.c:(.text+0x7a4): undefined reference to `memunmap'
s390-linux-ld: kernel/dma/coherent.o: in function `dma_declare_coherent_memory':
coherent.c:(.text+0xd84): undefined reference to `memunmap'

s390-linux-ld: drivers/irqchip/irq-al-fic.o: in function `al_fic_init_dt':
irq-al-fic.c:(.init.text+0x64): undefined reference to `of_iomap'
s390-linux-ld: irq-al-fic.c:(.init.text+0x6a0): undefined reference to `iounmap'
s390-linux-ld: drivers/char/xillybus/xillybus_of.o: in function `xilly_drv_probe':
xillybus_of.c:(.text+0x2c8): undefined reference to `devm_platform_ioremap_resource'
s390-linux-ld: drivers/pcmcia/cistpl.o: in function `set_cis_map':
cistpl.c:(.text+0x87a): undefined reference to `ioremap'
s390-linux-ld: cistpl.c:(.text+0x99a): undefined reference to `iounmap'
s390-linux-ld: cistpl.c:(.text+0xa34): undefined reference to `iounmap'
s390-linux-ld: cistpl.c:(.text+0xaa6): undefined reference to `ioremap'
s390-linux-ld: drivers/pcmcia/cistpl.o: in function `release_cis_mem':
cistpl.c:(.text+0x2976): undefined reference to `iounmap'

Quoted 26 lines
Quoted 24 lines

---
This is needed to prevent build break on UML with this patch:

https://lore.kernel.org/lkml/[email protected]/

 drivers/of/Kconfig | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/of/Kconfig +1 -3
index 18450437d5d5..3dfeae8912df 100644
@@ -75,9 +75,7 @@ config OF_NET
 	def_bool y
 
 config OF_RESERVED_MEM
-	bool
-	depends on OF_EARLY_FLATTREE
-	default y if DMA_DECLARE_COHERENT || DMA_CMA
+	def_bool OF_EARLY_FLATTREE
 
 config OF_RESOLVE
 	bool
Signature · 1 line
~Randy
author maintainer
#3 lore raw
Quoted 56 lines · Randy Dunlap
Quoted 37 lines · Randy Dunlap
Quoted 14 lines · Rob Herring

Reserved memory regions can be used for more than just DMA regions, so only enabling on DMA_DECLARE_COHERENT (via HAS_DMA) or DMA_CMA is wrong. This effectively doesn't matter except for the few cases arches select NO_DMA.

At least, these users of RESERVEDMEM_OF_DECLARE depend on reserved memory support:

arch/riscv/mm/init.c:RESERVEDMEM_OF_DECLARE(elfcorehdr, "linux,elfcorehdr", elfcore_hdr_setup); drivers/memory/tegra/tegra210-emc-table.c:RESERVEDMEM_OF_DECLARE(tegra210_emc_table, "nvidia,tegra210-emc-table", drivers/soc/fsl/qbman/bman_ccsr.c:RESERVEDMEM_OF_DECLARE(bman_fbpr, "fsl,bman-fbpr", bman_fbpr); drivers/soc/fsl/qbman/qman_ccsr.c:RESERVEDMEM_OF_DECLARE(qman_fqd, "fsl,qman-fqd", qman_fqd); drivers/soc/fsl/qbman/qman_ccsr.c:RESERVEDMEM_OF_DECLARE(qman_pfdr, "fsl,qman-pfdr", qman_pfdr);

Quoted 5 lines

Let's simplify things and enable OF_RESERVED_MEM when OF_EARLY_FLATTREE is enabled.

Cc Christoph Hellwig <[email protected]>

Hi Rob,

I'm OK with this patch, but with or without this patch, compiling kernel/dma/coherent.c without HAS_IOMEM (!) has build errors:

s390-linux-ld: kernel/dma/coherent.o: in function `dma_init_coherent_memory':
coherent.c:(.text+0x5ae): undefined reference to `memremap'
s390-linux-ld: coherent.c:(.text+0x7a4): undefined reference to `memunmap'
s390-linux-ld: kernel/dma/coherent.o: in function `dma_declare_coherent_memory':
coherent.c:(.text+0xd84): undefined reference to `memunmap'

along with a slew of other build errors (arch/s390/, CONFIG_PCI is not set, CONFIG_HAS_IOMEM is not set):

Quoted 16 lines

s390-linux-ld: drivers/irqchip/irq-al-fic.o: in function `al_fic_init_dt':
irq-al-fic.c:(.init.text+0x6a0): undefined reference to `iounmap'
s390-linux-ld: drivers/char/xillybus/xillybus_of.o: in function `xilly_drv_probe':
xillybus_of.c:(.text+0x2c8): undefined reference to `devm_platform_ioremap_resource'
s390-linux-ld: drivers/pcmcia/cistpl.o: in function `set_cis_map':
cistpl.c:(.text+0x87a): undefined reference to `ioremap'
s390-linux-ld: cistpl.c:(.text+0x99a): undefined reference to `iounmap'
s390-linux-ld: cistpl.c:(.text+0xa34): undefined reference to `iounmap'
s390-linux-ld: cistpl.c:(.text+0xaa6): undefined reference to `ioremap'
s390-linux-ld: drivers/pcmcia/cistpl.o: in function `release_cis_mem':
cistpl.c:(.text+0x2976): undefined reference to `iounmap'
s390-linux-ld: drivers/of/address.o: in function `of_iomap':
address.c:(.text+0x1f02): undefined reference to `ioremap'
s390-linux-ld: drivers/of/address.o: in function `of_io_request_and_map':
address.c:(.text+0x2030): undefined reference to `ioremap'

Quoted 3 lines

Oops, sorry. I should have said that this is also with my experimental path that I thought you suggested earlier this week (although I could have misunderstood you):

Yes, that's what I'd like, but no doubt that change alone will make things worse.

Quoted 23 lines
drivers/of/Kconfig +1 -1
@@ -64,7 +64,7 @@ config OF_DYNAMIC
 
 config OF_ADDRESS
        def_bool y
-       depends on !SPARC && (HAS_IOMEM || UML)
+       depends on !SPARC
 
 config OF_IRQ
        def_bool y

[rebuild]

OK, even without this small patch, the result is about the same (just a few different function names):

s390-linux-ld: kernel/dma/coherent.o: in function `dma_init_coherent_memory':
coherent.c:(.text+0x5ae): undefined reference to `memremap'
s390-linux-ld: coherent.c:(.text+0x7a4): undefined reference to `memunmap'
s390-linux-ld: kernel/dma/coherent.o: in function `dma_declare_coherent_memory':
coherent.c:(.text+0xd84): undefined reference to `memunmap'

Quoted 12 lines

s390-linux-ld: drivers/irqchip/irq-al-fic.o: in function `al_fic_init_dt':
irq-al-fic.c:(.init.text+0x64): undefined reference to `of_iomap'
s390-linux-ld: irq-al-fic.c:(.init.text+0x6a0): undefined reference to `iounmap'
s390-linux-ld: drivers/char/xillybus/xillybus_of.o: in function `xilly_drv_probe':
xillybus_of.c:(.text+0x2c8): undefined reference to `devm_platform_ioremap_resource'
s390-linux-ld: drivers/pcmcia/cistpl.o: in function `set_cis_map':
cistpl.c:(.text+0x87a): undefined reference to `ioremap'
s390-linux-ld: cistpl.c:(.text+0x99a): undefined reference to `iounmap'
s390-linux-ld: cistpl.c:(.text+0xa34): undefined reference to `iounmap'
s390-linux-ld: cistpl.c:(.text+0xaa6): undefined reference to `ioremap'
s390-linux-ld: drivers/pcmcia/cistpl.o: in function `release_cis_mem':
cistpl.c:(.text+0x2976): undefined reference to `iounmap'

Empty stubs for ioremap, iounmap, memremap, and memunmap would fix all these, right? Though maybe adding stubs is more complicated than I'm thinking given all the architecture specifics.

Rob