diff options
author | Kitae Kim <kt920.kim@samsung.com> | 2013-11-28 16:27:00 +0900 |
---|---|---|
committer | Kitae Kim <kt920.kim@samsung.com> | 2013-11-28 16:27:00 +0900 |
commit | 3fa7e8df4795cb9daa1125c5f2c5abe6988be001 (patch) | |
tree | bf4c0d33c24e13f458e1a0b45489dbb262609341 | |
parent | 485b266e41abeb16175e177f235a8f0a47bde5a4 (diff) | |
download | emulator-kernel-3fa7e8df4795cb9daa1125c5f2c5abe6988be001.tar.gz emulator-kernel-3fa7e8df4795cb9daa1125c5f2c5abe6988be001.tar.bz2 emulator-kernel-3fa7e8df4795cb9daa1125c5f2c5abe6988be001.zip |
brillcodec: fix release memory routine.
If release memory occurs twice with the same memory offset,
it might cause an error.
semaphore for memory block should be increased in the if-statement.
Change-Id: Ic332eec1e64d5b134b8671b38552b470196e01a0
Signed-off-by: Kitae Kim <kt920.kim@samsung.com>
-rw-r--r-- | drivers/maru/maru_brillcodec.c | 28 |
1 files changed, 17 insertions, 11 deletions
diff --git a/drivers/maru/maru_brillcodec.c b/drivers/maru/maru_brillcodec.c index 555797d505de..70ce8775c060 100644 --- a/drivers/maru/maru_brillcodec.c +++ b/drivers/maru/maru_brillcodec.c @@ -337,6 +337,7 @@ static void release_device_memory(uint32_t mem_offset) struct device_mem *unit = NULL; enum block_size index = SMALL; struct memory_block *block = NULL; + bool found = false; struct list_head *pos, *temp; @@ -360,25 +361,30 @@ static void release_device_memory(uint32_t mem_offset) unit->blk_id = 0; list_move_tail(&unit->entry, &block->available); + if (block->last_buf_secured) { + block->last_buf_secured = 0; + up(&block->last_buf_semaphore); + DEBUG("unlock last buffer semaphore.\n"); + } else { + up(&block->semaphore); + DEBUG("unlock semaphore: %d.\n", block->semaphore.count); + } + + found = true; + break; } } + if (!found) { + // can not enter here... + ERROR("there is no used memory block. offset = 0x%x.\n", (uint32_t)mem_offset); + } } else { // can not enter here... ERROR("there is no used memory block.\n"); } - if (block->last_buf_secured) { - block->last_buf_secured = 0; - up(&block->last_buf_semaphore); - DEBUG("unlock last buffer semaphore.\n"); - } else { - up(&block->semaphore); - DEBUG("unlock semaphore: %d.\n", block->semaphore.count); - } - mutex_unlock(&block->access_mutex); - } static void maru_brill_codec_info_cache(void) @@ -953,7 +959,7 @@ static int __devinit maru_brill_codec_probe(struct pci_dev *pci_dev, maru_brill_codec->dev = pci_dev; - INIT_LIST_HEAD(&maru_brill_codec->user_pid_mgr); + INIT_LIST_HEAD(&maru_brill_codec->user_pid_mgr); // initialize memory block structures maru_brill_codec->memory_blocks[0].unit_size = CODEC_S_DEVICE_MEM_SIZE; |