Skip to contentSkip to conversation

swiotlb: Add missing __init annotations

PATCH Applied Roland Dreier 3 participants 7 messages Dec 31, 2008 – Jan 2, 2009

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

The current kernel build warns:

WARNING: vmlinux.o(.text+0x11458): Section mismatch in reference from the function swiotlb_alloc_boot() to the function .init.text:__alloc_bootmem_low() The function swiotlb_alloc_boot() references
the function __init __alloc_bootmem_low().
This is often because swiotlb_alloc_boot lacks a __init
annotation or the annotation of __alloc_bootmem_low is wrong.

WARNING: vmlinux.o(.text+0x1011f2): Section mismatch in reference from the function swiotlb_late_init_with_default_size() to the function .init.text:__alloc_bootmem_low() The function swiotlb_late_init_with_default_size() references
the function __init __alloc_bootmem_low().
This is often because swiotlb_late_init_with_default_size lacks a __init
annotation or the annotation of __alloc_bootmem_low is wrong.

and indeed the functions calling __alloc_bootmem_low() can be marked __init as well.

---
Not 100% sure if this is the correct fix but it seems OK for me.

 arch/x86/kernel/pci-swiotlb_64.c |    2 +-
 lib/swiotlb.c                    |    4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)
arch/x86/kernel/pci-swiotlb_64.c +1 -1
index 242c344..8cba374 100644
@@ -13,7 +13,7 @@
 
 int swiotlb __read_mostly;
 
-void *swiotlb_alloc_boot(size_t size, unsigned long nslabs)
+void * __init swiotlb_alloc_boot(size_t size, unsigned long nslabs)
 {
 	return alloc_bootmem_low_pages(size);
 }
lib/swiotlb.c +2 -2
index fa2dc4e..1b76f78 100644
@@ -116,7 +116,7 @@ setup_io_tlb_npages(char *str)
 __setup("swiotlb=", setup_io_tlb_npages);
 /* make io_tlb_overflow tunable too? */
 
-void * __weak swiotlb_alloc_boot(size_t size, unsigned long nslabs)
+void * __weak __init swiotlb_alloc_boot(size_t size, unsigned long nslabs)
 {
 	return alloc_bootmem_low_pages(size);
 }
@@ -186,7 +186,7 @@ static void swiotlb_print_info(unsigned long bytes)
  * Statically reserve bounce buffer space and initialize bounce buffer data
  * structures for the software IO TLB used to implement the DMA API.
  */
-void __init
+void __init __weak
 swiotlb_init_with_default_size(size_t default_size)
 {
 	unsigned long i, bytes;
#1 lore raw
Quoted 52 lines · Roland Dreier

The current kernel build warns:

WARNING: vmlinux.o(.text+0x11458): Section mismatch in reference from the function swiotlb_alloc_boot() to the function .init.text:__alloc_bootmem_low() The function swiotlb_alloc_boot() references
the function __init __alloc_bootmem_low().
This is often because swiotlb_alloc_boot lacks a __init
annotation or the annotation of __alloc_bootmem_low is wrong.

WARNING: vmlinux.o(.text+0x1011f2): Section mismatch in reference from the function swiotlb_late_init_with_default_size() to the function .init.text:__alloc_bootmem_low() The function swiotlb_late_init_with_default_size() references
the function __init __alloc_bootmem_low().
This is often because swiotlb_late_init_with_default_size lacks a __init
annotation or the annotation of __alloc_bootmem_low is wrong.

and indeed the functions calling __alloc_bootmem_low() can be marked __init as well.

---
Not 100% sure if this is the correct fix but it seems OK for me.

 arch/x86/kernel/pci-swiotlb_64.c |    2 +-
 lib/swiotlb.c                    |    4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)
arch/x86/kernel/pci-swiotlb_64.c +1 -1
index 242c344..8cba374 100644
@@ -13,7 +13,7 @@
 
 int swiotlb __read_mostly;
 
-void *swiotlb_alloc_boot(size_t size, unsigned long nslabs)
+void * __init swiotlb_alloc_boot(size_t size, unsigned long nslabs)
 {
 	return alloc_bootmem_low_pages(size);
 }
lib/swiotlb.c +1 -1
index fa2dc4e..1b76f78 100644
@@ -116,7 +116,7 @@ setup_io_tlb_npages(char *str)
 __setup("swiotlb=", setup_io_tlb_npages);
 /* make io_tlb_overflow tunable too? */
 
-void * __weak swiotlb_alloc_boot(size_t size, unsigned long nslabs)
+void * __weak __init swiotlb_alloc_boot(size_t size, unsigned long nslabs)
 {
 	return alloc_bootmem_low_pages(size);
 }

lib/swiotlb.c static void swiotlb_print_info(unsigned long bytes) · line 190

Quoted 6 lines
lib/swiotlb.c +1 -1
@@ -186,7 +186,7 @@ static void swiotlb_print_info(unsigned long bytes)
  * Statically reserve bounce buffer space and initialize bounce buffer data
  * structures for the software IO TLB used to implement the DMA API.
  */
-void __init
+void __init __weak
 swiotlb_init_with_default_size(size_t default_size)

This change looks unrealted to __init annotation described in the changelog. Was it intentional?

Sam

#2 lore raw
Quoted 47 lines · Sam Ravnborg
Quoted 46 lines · Roland Dreier

The current kernel build warns:

WARNING: vmlinux.o(.text+0x11458): Section mismatch in reference from the function swiotlb_alloc_boot() to the function .init.text:__alloc_bootmem_low() The function swiotlb_alloc_boot() references
the function __init __alloc_bootmem_low().
This is often because swiotlb_alloc_boot lacks a __init
annotation or the annotation of __alloc_bootmem_low is wrong.

WARNING: vmlinux.o(.text+0x1011f2): Section mismatch in reference from the function swiotlb_late_init_with_default_size() to the function .init.text:__alloc_bootmem_low() The function swiotlb_late_init_with_default_size() references
the function __init __alloc_bootmem_low().
This is often because swiotlb_late_init_with_default_size lacks a __init
annotation or the annotation of __alloc_bootmem_low is wrong.

and indeed the functions calling __alloc_bootmem_low() can be marked __init as well.

---
Not 100% sure if this is the correct fix but it seems OK for me.

 arch/x86/kernel/pci-swiotlb_64.c |    2 +-
 lib/swiotlb.c                    |    4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)
arch/x86/kernel/pci-swiotlb_64.c +1 -1
index 242c344..8cba374 100644
@@ -13,7 +13,7 @@
 
 int swiotlb __read_mostly;
 
-void *swiotlb_alloc_boot(size_t size, unsigned long nslabs)
+void * __init swiotlb_alloc_boot(size_t size, unsigned long nslabs)
 {
 	return alloc_bootmem_low_pages(size);
 }
lib/swiotlb.c +0 -0
index fa2dc4e..1b76f78 100644
@@ -116,7 +116,7 @@ setup_io_tlb_npages(char *str)
 __setup("swiotlb=", setup_io_tlb_npages);
 /* make io_tlb_overflow tunable too? */
 
Quoted 15 lines

lib/swiotlb.c static void swiotlb_print_info(unsigned long bytes) · line 190

Quoted 12 lines
lib/swiotlb.c +2 -2
-void * __weak swiotlb_alloc_boot(size_t size, unsigned long nslabs)
+void * __weak __init swiotlb_alloc_boot(size_t size, unsigned long nslabs)
 {
 	return alloc_bootmem_low_pages(size);
 }
@@ -186,7 +186,7 @@ static void swiotlb_print_info(unsigned long bytes)
  * Statically reserve bounce buffer space and initialize bounce buffer data
  * structures for the software IO TLB used to implement the DMA API.
  */
-void __init
+void __init __weak
 swiotlb_init_with_default_size(size_t default_size)

This change looks unrealted to __init annotation described in the changelog. Was it intentional?

that hunk definitely looks wrong.

Ingo

#3 lore raw
Quoted 10 lines

lib/swiotlb.c static void swiotlb_print_info(unsigned long bytes) · line 190

Quoted 7 lines
lib/swiotlb.c +1 -1
@@ -186,7 +186,7 @@ static void swiotlb_print_info(unsigned long bytes)
  * Statically reserve bounce buffer space and initialize bounce buffer data
  * structures for the software IO TLB used to implement the DMA API.
  */
-void __init
+void __init __weak
 swiotlb_init_with_default_size(size_t default_size)

This change looks unrealted to __init annotation described in the changelog. Was it intentional?

Yes, that was a thinko -- somehow while reading it I saw the __init without __weak as being missing an annotation. Should I resend a fixed patch?

- R.

#4 lore raw
Quoted 11 lines · Roland Dreier
Quoted 10 lines

lib/swiotlb.c static void swiotlb_print_info(unsigned long bytes) · line 190

Quoted 7 lines
lib/swiotlb.c +1 -1
@@ -186,7 +186,7 @@ static void swiotlb_print_info(unsigned long bytes)
  * Statically reserve bounce buffer space and initialize bounce buffer data
  * structures for the software IO TLB used to implement the DMA API.
  */
-void __init
+void __init __weak
 swiotlb_init_with_default_size(size_t default_size)

This change looks unrealted to __init annotation described in the changelog. Was it intentional?

Quoted 3 lines

Yes, that was a thinko -- somehow while reading it I saw the __init without __weak as being missing an annotation. Should I resend a fixed patch?

no need - so it wasnt needed to make a section warning go away - i.e. your patch sans the last hunk is tested to solve the problem, right?

Ingo

#5 lore raw
Quoted 2 lines

no need - so it wasnt needed to make a section warning go away - i.e. your patch sans the last hunk is tested to solve the problem, right?

I hadn't tested without that hunk... so I just redid it. For simplicity, here's the exact patch I just tested to solve the warnings:

===

The current kernel build warns:

WARNING: vmlinux.o(.text+0x11458): Section mismatch in reference from the function swiotlb_alloc_boot() to the function .init.text:__alloc_bootmem_low() The function swiotlb_alloc_boot() references
the function __init __alloc_bootmem_low().
This is often because swiotlb_alloc_boot lacks a __init
annotation or the annotation of __alloc_bootmem_low is wrong.

WARNING: vmlinux.o(.text+0x1011f2): Section mismatch in reference from the function swiotlb_late_init_with_default_size() to the function .init.text:__alloc_bootmem_low() The function swiotlb_late_init_with_default_size() references
the function __init __alloc_bootmem_low().
This is often because swiotlb_late_init_with_default_size lacks a __init
annotation or the annotation of __alloc_bootmem_low is wrong.

and indeed the functions calling __alloc_bootmem_low() can be marked __init as well.

---
 arch/x86/kernel/pci-swiotlb_64.c |    2 +-
 lib/swiotlb.c                    |    4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)
arch/x86/kernel/pci-swiotlb_64.c +1 -1
index 242c344..8cba374 100644
@@ -13,7 +13,7 @@
 
 int swiotlb __read_mostly;
 
-void *swiotlb_alloc_boot(size_t size, unsigned long nslabs)
+void * __init swiotlb_alloc_boot(size_t size, unsigned long nslabs)
 {
 	return alloc_bootmem_low_pages(size);
 }
lib/swiotlb.c +2 -2
index fa2dc4e..f684d55 100644
@@ -116,7 +116,7 @@ setup_io_tlb_npages(char *str)
 __setup("swiotlb=", setup_io_tlb_npages);
 /* make io_tlb_overflow tunable too? */
 
-void * __weak swiotlb_alloc_boot(size_t size, unsigned long nslabs)
+void * __weak __init swiotlb_alloc_boot(size_t size, unsigned long nslabs)
 {
 	return alloc_bootmem_low_pages(size);
 }
@@ -238,7 +238,7 @@ swiotlb_init(void)
  * initialize the swiotlb later using the slab allocator if needed.
  * This should be just like above, but with some error catching.
  */
-int
+int __init
 swiotlb_late_init_with_default_size(size_t default_size)
 {
 	unsigned long i, bytes, req_nslabs = io_tlb_nslabs;
Applied
#6 lore raw
Quoted 5 lines · Roland Dreier
Quoted 2 lines

no need - so it wasnt needed to make a section warning go away - i.e. your patch sans the last hunk is tested to solve the problem, right?

I hadn't tested without that hunk... so I just redid it. For simplicity, here's the exact patch I just tested to solve the warnings:

applied to tip/core/urgent, thanks Roland!

Ingo