aboutsummaryrefslogtreecommitdiffstats
path: root/sound
diff options
context:
space:
mode:
authorJie Yang <yang.jie@intel.com>2015-01-03 20:15:04 -0500
committerMark Brown <broonie@kernel.org>2015-01-05 15:00:20 -0500
commitd83901e82010cb3b25e69a9bbe991e9fbd940725 (patch)
treeb0b8e91a4a08d75f2b03d95a488a950a453ef7eb /sound
parent25f97549b5a19a373922e07c3e0f0b0b56a49148 (diff)
ASoC: Intel: Don't change offset of block allocator during fixed allocate
The offset of block allocator, ba->offset, should not be changed during fixed address allocating, for the caller may treat it as the offset of allocated memory and use it. In the case that we allocate more than 1 blocks, we should make sure this offset is correct. Here introduces a temp allocator for the later continuous allocating. Signed-off-by: Jie Yang <yang.jie@intel.com> Signed-off-by: Mark Brown <broonie@kernel.org>
Diffstat (limited to 'sound')
-rw-r--r--sound/soc/intel/sst-firmware.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/sound/soc/intel/sst-firmware.c b/sound/soc/intel/sst-firmware.c
index ef2e8b5766a1..b3f9489794a6 100644
--- a/sound/soc/intel/sst-firmware.c
+++ b/sound/soc/intel/sst-firmware.c
@@ -706,6 +706,7 @@ static int block_alloc_fixed(struct sst_dsp *dsp, struct sst_block_allocator *ba
706 struct list_head *block_list) 706 struct list_head *block_list)
707{ 707{
708 struct sst_mem_block *block, *tmp; 708 struct sst_mem_block *block, *tmp;
709 struct sst_block_allocator ba_tmp = *ba;
709 u32 end = ba->offset + ba->size, block_end; 710 u32 end = ba->offset + ba->size, block_end;
710 int err; 711 int err;
711 712
@@ -730,9 +731,9 @@ static int block_alloc_fixed(struct sst_dsp *dsp, struct sst_block_allocator *ba
730 if (ba->offset >= block->offset && ba->offset < block_end) { 731 if (ba->offset >= block->offset && ba->offset < block_end) {
731 732
732 /* align ba to block boundary */ 733 /* align ba to block boundary */
733 ba->size -= block_end - ba->offset; 734 ba_tmp.size -= block_end - ba->offset;
734 ba->offset = block_end; 735 ba_tmp.offset = block_end;
735 err = block_alloc_contiguous(dsp, ba, block_list); 736 err = block_alloc_contiguous(dsp, &ba_tmp, block_list);
736 if (err < 0) 737 if (err < 0)
737 return -ENOMEM; 738 return -ENOMEM;
738 739
@@ -767,10 +768,10 @@ static int block_alloc_fixed(struct sst_dsp *dsp, struct sst_block_allocator *ba
767 list_move(&block->list, &dsp->used_block_list); 768 list_move(&block->list, &dsp->used_block_list);
768 list_add(&block->module_list, block_list); 769 list_add(&block->module_list, block_list);
769 /* align ba to block boundary */ 770 /* align ba to block boundary */
770 ba->size -= block_end - ba->offset; 771 ba_tmp.size -= block_end - ba->offset;
771 ba->offset = block_end; 772 ba_tmp.offset = block_end;
772 773
773 err = block_alloc_contiguous(dsp, ba, block_list); 774 err = block_alloc_contiguous(dsp, &ba_tmp, block_list);
774 if (err < 0) 775 if (err < 0)
775 return -ENOMEM; 776 return -ENOMEM;
776 777