[Sound-open-firmware] [PATCH 1/2] apl: Add text size in module info
From: Pan Xiuli xiuli.pan@linux.intel.com
Add total text size we used in memory mapping into module info to help rimage build the right FW binary.
Signed-off-by: Pan Xiuli xiuli.pan@linux.intel.com
--- Test with: Mininow max rt5651 GP-MRB nocodec SOF master: 1693b66bb1d804ded975767cc1e5911e6ff9c93c SOF-Tool master: a02abb799405d0e4ad0d6bb46eacf6fbe958c06e https://github.com/plbossart/sound/tree/topic/sof-v4.14: 9513a73b981bc1917705671ec54402a7e21672eb --- src/include/uapi/manifest.h | 1 + src/platform/apollolake/base_module.c | 1 + 2 files changed, 2 insertions(+)
diff --git a/src/include/uapi/manifest.h b/src/include/uapi/manifest.h index ace9883..e83725b 100644 --- a/src/include/uapi/manifest.h +++ b/src/include/uapi/manifest.h @@ -102,6 +102,7 @@ struct sof_man_module { struct sof_man_module_type type; uint8_t hash[SOF_MAN_MOD_SHA256_LEN]; uint32_t entry_point; + uint32_t text_size; uint16_t cfg_offset; uint16_t cfg_count; uint32_t affinity_mask; diff --git a/src/platform/apollolake/base_module.c b/src/platform/apollolake/base_module.c index 2f4a6ee..56633c5 100644 --- a/src/platform/apollolake/base_module.c +++ b/src/platform/apollolake/base_module.c @@ -46,6 +46,7 @@ struct sof_man_module apl_manifest = { .domain_ll = 1, }, .affinity_mask = 3, + .text_size = REEF_TEXT_SIZE + L2_VECTOR_SIZE, };
/* not used, but stops linker complaining */
From: Pan Xiuli xiuli.pan@linux.intel.com
The actual text size will change and the hard code base_fw_text_size_fixup could not fit the changing size. We should get the fixup size from the module info just from the memory mapping.
Signed-off-by: Pan Xiuli xiuli.pan@linux.intel.com
--- Test with: Mininow max rt5651 GP-MRB nocodec SOF master: 1693b66bb1d804ded975767cc1e5911e6ff9c93c SOF-Tool master: a02abb799405d0e4ad0d6bb46eacf6fbe958c06e https://github.com/plbossart/sound/tree/topic/sof-v4.14: 9513a73b981bc1917705671ec54402a7e21672eb --- rimage/elf.c | 7 ------- rimage/manifest.c | 17 ++++++++++++++--- rimage/rimage.h | 4 +--- 3 files changed, 15 insertions(+), 13 deletions(-)
diff --git a/rimage/elf.c b/rimage/elf.c index b96222b..78f6d57 100644 --- a/rimage/elf.c +++ b/rimage/elf.c @@ -500,13 +500,6 @@ int elf_parse_module(struct image *image, int module_index, const char *name) if (rem) module->text_file_size += MAN_PAGE_SIZE - rem;
- - /* apply any base FW fixups */ - if (image->adsp->base_fw_text_size_fixup && - module->text_start == image->adsp->sram_base) { - module->text_file_size += image->adsp->base_fw_text_size_fixup; - } - /* data section */ module->data_file_size = module->data_end - module->data_start; rem = module->data_file_size % MAN_PAGE_SIZE; diff --git a/rimage/manifest.c b/rimage/manifest.c index b9848d0..337f82a 100644 --- a/rimage/manifest.c +++ b/rimage/manifest.c @@ -109,7 +109,7 @@ static uint32_t elf_to_file_offset(struct image *image, } else { /* rodata segment, append to text segment */ file_offset = elf_addr - module->data_start + - module->foffset + module->text_file_size; + module->foffset + module->text_fixup_size;
} } else if (section->sh_type == SHT_NOBITS) { @@ -233,6 +233,9 @@ static int man_get_module_manifest(struct image *image, struct module *module, man_module->type.domain_ll = sof_mod.type.domain_ll; man_module->type.load_type = sof_mod.type.load_type;
+ /* read out text_fixup_size from memory mapping */ + module->text_fixup_size = sof_mod.text_size; + /* text segment */ segment = &man_module->segment[SOF_MAN_SEGMENT_TEXT]; segment->flags.r.contents = 1; @@ -361,13 +364,22 @@ static int man_module_create(struct image *image, struct module *module, if (module->text_file_size % MAN_PAGE_SIZE) pages += 1;
+ if (module->text_fixup_size == 0) + module->text_fixup_size = module->text_file_size; + + /* check if text_file_size is bigger then text_fixup_size */ + if (module->text_file_size > module->text_fixup_size) { + fprintf(stderr, "error: too small text size assigned!\n"); + return -EINVAL; + } + man_module->segment[SOF_MAN_SEGMENT_TEXT].flags.r.length = pages;
/* data section */ man_module->segment[SOF_MAN_SEGMENT_RODATA].v_base_addr = module->data_start; man_module->segment[SOF_MAN_SEGMENT_RODATA].file_offset = - module->foffset + module->text_file_size; + module->foffset + module->text_fixup_size; pages = module->data_file_size / MAN_PAGE_SIZE; if (module->data_file_size % MAN_PAGE_SIZE) pages += 1; @@ -627,7 +639,6 @@ const struct adsp machine_apl = { .machine_id = MACHINE_APOLLOLAKE, .write_firmware = man_write_fw, .man = &apl_manifest, - .base_fw_text_size_fixup = 0xa000, };
const struct adsp machine_cnl = { diff --git a/rimage/rimage.h b/rimage/rimage.h index adcb8c5..654ba90 100644 --- a/rimage/rimage.h +++ b/rimage/rimage.h @@ -75,6 +75,7 @@ struct module { /* sizes do include gaps to nearest page */ int bss_file_size; int text_file_size; + int text_fixup_size; int data_file_size; };
@@ -135,9 +136,6 @@ struct adsp { enum machine_id machine_id; int (*write_firmware)(struct image *image); struct fw_image_manifest *man; - - /* fixups */ - uint32_t base_fw_text_size_fixup; /* added to BASEFW text size */ };
void module_sha256_create(struct image *image);
On Fri, 2018-03-02 at 15:55 +0800, Xiuli Pan wrote:
From: Pan Xiuli xiuli.pan@linux.intel.com
Add total text size we used in memory mapping into module info to help rimage build the right FW binary.
Signed-off-by: Pan Xiuli xiuli.pan@linux.intel.com
Both applied.
Thanks
Liam
On 3/2/2018 17:15, Liam Girdwood wrote:
On Fri, 2018-03-02 at 15:55 +0800, Xiuli Pan wrote:
From: Pan Xiuli xiuli.pan@linux.intel.com
Add total text size we used in memory mapping into module info to help rimage build the right FW binary.
Signed-off-by: Pan Xiuli xiuli.pan@linux.intel.com
Both applied.
Should we revert the increase REEF_TEXT_SIZE patch? Now we have pretty free space for text in memory mapping.
Thanks Xiuli
Thanks
Liam
On Fri, 2018-03-02 at 17:17 +0800, Pan, Xiuli wrote:
On 3/2/2018 17:15, Liam Girdwood wrote:
On Fri, 2018-03-02 at 15:55 +0800, Xiuli Pan wrote:
From: Pan Xiuli xiuli.pan@linux.intel.com
Add total text size we used in memory mapping into module info to help rimage build the right FW binary.
Signed-off-by: Pan Xiuli xiuli.pan@linux.intel.com
Both applied.
Should we revert the increase REEF_TEXT_SIZE patch? Now we have pretty free space for text in memory mapping.
Yes, this can be optimised.
Liam
participants (3)
-
Liam Girdwood
-
Pan, Xiuli
-
Xiuli Pan