Skip to content

Commit b54290e

Browse files
author
Nicolas Pitre
committed
ARM: simplify and fix linker script for TCM
Let's put the TCM stuff in the __init section directly. No need for a separately freed memory area. Remove redundant linker sections, as well as comments that were more confusing than no comments at all. Finally make it XIP compatible by using LOAD_OFFSET in the section LMA specification. Signed-off-by: Nicolas Pitre <[email protected]> Tested-by: Chris Brandt <[email protected]>
1 parent c3146c4 commit b54290e

File tree

4 files changed

+14
-65
lines changed

4 files changed

+14
-65
lines changed

arch/arm/kernel/vmlinux-xip.lds.S

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,10 @@ SECTIONS
132132
PERCPU_SECTION(L1_CACHE_BYTES)
133133
#endif
134134

135+
#ifdef CONFIG_HAVE_TCM
136+
ARM_TCM
137+
#endif
138+
135139
/*
136140
* End of copied data. We need a dummy section to get its LMA.
137141
* Also located before final ALIGN() as trailing padding is not stored
@@ -143,10 +147,6 @@ SECTIONS
143147
. = ALIGN(PAGE_SIZE);
144148
__init_end = .;
145149

146-
#ifdef CONFIG_HAVE_TCM
147-
ARM_TCM
148-
#endif
149-
150150
BSS_SECTION(0, 0, 8)
151151
_end = .;
152152

arch/arm/kernel/vmlinux.lds.S

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,10 @@ SECTIONS
127127
PERCPU_SECTION(L1_CACHE_BYTES)
128128
#endif
129129

130+
#ifdef CONFIG_HAVE_TCM
131+
ARM_TCM
132+
#endif
133+
130134
#ifdef CONFIG_STRICT_KERNEL_RWX
131135
. = ALIGN(1<<SECTION_SHIFT);
132136
#else
@@ -138,10 +142,6 @@ SECTIONS
138142
RW_DATA_SECTION(L1_CACHE_BYTES, PAGE_SIZE, THREAD_SIZE)
139143
_edata = .;
140144

141-
#ifdef CONFIG_HAVE_TCM
142-
ARM_TCM
143-
#endif
144-
145145
BSS_SECTION(0, 0, 0)
146146
_end = .;
147147

arch/arm/kernel/vmlinux.lds.h

Lines changed: 6 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -115,61 +115,21 @@
115115
PROVIDE(vector_fiq_offset = vector_fiq - ADDR(.vectors));
116116

117117
#define ARM_TCM \
118-
/* \
119-
* We align everything to a page boundary so we can \
120-
* free it after init has commenced and TCM contents have \
121-
* been copied to its destination. \
122-
*/ \
123-
.tcm_start : { \
124-
. = ALIGN(PAGE_SIZE); \
125-
__tcm_start = .; \
126-
__itcm_start = .; \
127-
} \
128-
\
129-
/* \
130-
* Link these to the ITCM RAM \
131-
* \
132-
* Put VMA to the TCM address and LMA to the common RAM \
133-
* and we'll upload the contents from RAM to TCM and free \
134-
* the used RAM after that. \
135-
*/ \
136-
.text_itcm ITCM_OFFSET : AT(__itcm_start) \
137-
{ \
118+
__itcm_start = ALIGN(4); \
119+
.text_itcm ITCM_OFFSET : AT(__itcm_start - LOAD_OFFSET) { \
138120
__sitcm_text = .; \
139121
*(.tcm.text) \
140122
*(.tcm.rodata) \
141123
. = ALIGN(4); \
142124
__eitcm_text = .; \
143125
} \
126+
. = __itcm_start + SIZEOF(.text_itcm); \
144127
\
145-
/* \
146-
* Reset the dot pointer, this is needed to create the \
147-
* relative __dtcm_start below (to be used as extern in code). \
148-
*/ \
149-
. = ADDR(.tcm_start) + SIZEOF(.tcm_start) + SIZEOF(.text_itcm); \
150-
\
151-
.dtcm_start : { \
152-
__dtcm_start = .; \
153-
} \
154-
\
155-
/* \
156-
* TODO: add remainder of ITCM as well, \
157-
* that can be used for data! \
158-
*/ \
159-
.data_dtcm DTCM_OFFSET : AT(__dtcm_start) \
160-
{ \
161-
. = ALIGN(4); \
128+
__dtcm_start = .; \
129+
.data_dtcm DTCM_OFFSET : AT(__dtcm_start - LOAD_OFFSET) { \
162130
__sdtcm_data = .; \
163131
*(.tcm.data) \
164132
. = ALIGN(4); \
165133
__edtcm_data = .; \
166134
} \
167-
\
168-
/* Reset the dot pointer or the linker gets confused */ \
169-
. = ADDR(.dtcm_start) + SIZEOF(.data_dtcm); \
170-
\
171-
/* End marker for freeing TCM copy in linked object */ \
172-
.tcm_end : AT(ADDR(.dtcm_start) + SIZEOF(.data_dtcm)){ \
173-
. = ALIGN(PAGE_SIZE); \
174-
__tcm_end = .; \
175-
}
135+
. = __dtcm_start + SIZEOF(.data_dtcm);

arch/arm/mm/init.c

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -758,20 +758,9 @@ void set_kernel_text_ro(void)
758758
static inline void fix_kernmem_perms(void) { }
759759
#endif /* CONFIG_STRICT_KERNEL_RWX */
760760

761-
void free_tcmmem(void)
762-
{
763-
#ifdef CONFIG_HAVE_TCM
764-
extern char __tcm_start, __tcm_end;
765-
766-
poison_init_mem(&__tcm_start, &__tcm_end - &__tcm_start);
767-
free_reserved_area(&__tcm_start, &__tcm_end, -1, "TCM link");
768-
#endif
769-
}
770-
771761
void free_initmem(void)
772762
{
773763
fix_kernmem_perms();
774-
free_tcmmem();
775764

776765
poison_init_mem(__init_begin, __init_end - __init_begin);
777766
if (!machine_is_integrator() && !machine_is_cintegrator())

0 commit comments

Comments
 (0)