Skip to content

Commit

Permalink
PD#137165: codec_mm: add cache limited for less memory system.
Browse files Browse the repository at this point in the history
Change-Id: I12fd55472718bf564e652cdcb29a1af370c1d9ca
Signed-off-by: Zhi Zhou <zhi.zhou@amlogic.com>
  • Loading branch information
Zeno-Zhou committed Jan 6, 2017
1 parent 8378377 commit ca80538
Showing 1 changed file with 30 additions and 2 deletions.
32 changes: 30 additions & 2 deletions drivers/amlogic/codec_mm/codec_mm_scatter.c
Expand Up @@ -36,6 +36,7 @@
#include <linux/amlogic/codec_mm/codec_mm_scatter.h>
#include <linux/workqueue.h>
#include <linux/delay.h>
#include <linux/mm.h>

#include "codec_mm_priv.h"
#include "codec_mm_scatter_priv.h"
Expand Down Expand Up @@ -123,6 +124,7 @@ struct codec_mm_scatter_mgt {
int try_alloc_in_sys_page_cnt_min;
int alloc_from_cma_first;
int enable_slot_from_sys;
int no_cache_size_M;
int support_from_slot_sys;
int one_page_cnt;
int scatters_cnt;
Expand Down Expand Up @@ -1559,7 +1561,7 @@ int codec_mm_scatter_info_dump(void *buf, int size)
(smgt->total_page_num << PAGE_SHIFT) / SZ_1M,
smgt->total_page_num << PAGE_SHIFT,
smgt->total_page_num);
n = smgt->alloced_page_num - smgt->cached_pages;
n = smgt->alloced_page_num;
BUFPRINT("\talloced size:%dM, %d Bypes,pages:%d\n",
(n << PAGE_SHIFT) / SZ_1M,
n << PAGE_SHIFT,
Expand All @@ -1570,6 +1572,11 @@ int codec_mm_scatter_info_dump(void *buf, int size)
BUFPRINT("\tscatter cached:%d M |%d pages\n",
(smgt->cached_pages << PAGE_SHIFT) / SZ_1M,
smgt->cached_pages);

BUFPRINT("\talloc from sys size:%d\n",
(smgt->alloc_from_sys_sc_cnt +
smgt->one_page_cnt) << PAGE_SHIFT);

BUFPRINT("\talloc from sys sc cnt:%d\n",
smgt->alloc_from_sys_sc_cnt);
BUFPRINT("\talloc from sys pages cnt:%d pages\n",
Expand Down Expand Up @@ -1862,6 +1869,7 @@ enum config_id {
ID3_MAX_SYS_PAGES,
ID4_MIN_SYS_PAGES,
ID5_SLOT_FROM_SYS,
ID6_NO_CACHE_SIZE,
IDX_MAX,
};
struct sc_configs sc_global_config[] = {
Expand All @@ -1871,6 +1879,7 @@ struct sc_configs sc_global_config[] = {
{ID3_MAX_SYS_PAGES, "max_sys_pages"},
{ID4_MIN_SYS_PAGES, "min_sys_pages"},
{ID5_SLOT_FROM_SYS, "enable_slot_from_sys"},
{ID6_NO_CACHE_SIZE, "no_cache_size_M"},
};

static int codec_mm_scatter_mgt_get_config_in(int id)
Expand All @@ -1890,6 +1899,8 @@ static int codec_mm_scatter_mgt_get_config_in(int id)
return smgt->try_alloc_in_sys_page_cnt_min;
case ID5_SLOT_FROM_SYS:
return smgt->enable_slot_from_sys;
case ID6_NO_CACHE_SIZE:
return smgt->no_cache_size_M;
default:
return 0;
}
Expand Down Expand Up @@ -1920,6 +1931,9 @@ static int codec_mm_scatter_mgt_set_config_in(int id, int newset)
smgt->enable_slot_from_sys = newset;
smgt->support_from_slot_sys = newset;
break;
case ID6_NO_CACHE_SIZE:
smgt->no_cache_size_M = newset;
break;
default:
return -1;
}
Expand Down Expand Up @@ -2021,7 +2035,15 @@ static void codec_mm_scatter_cache_manage(struct codec_mm_scatter_mgt *smgt)
int total_free_page = smgt->total_page_num -
smgt->alloced_page_num + smgt->cached_pages;
if (smgt->delay_free_on > 0 && smgt->keep_size_PAGE > 0) {
if ((smgt->cached_pages < smgt->keep_size_PAGE) ||
/*if alloc too much ,don't cache any more.*/
if (smgt->no_cache_size_M > 0 &&
(smgt->cached_pages <= smgt->keep_size_PAGE) &&
(smgt->total_page_num >=
(smgt->no_cache_size_M * (SZ_1M >> PAGE_SHIFT)))) {
/*have enough pages for most movies.
don't cache more.
*/
} else if ((smgt->cached_pages < smgt->keep_size_PAGE) ||
(smgt->force_cache_on &&/*on star cache*/
(smgt->cached_pages < smgt->force_cache_page_cnt))
) {/*first 500ms ,alloc double.*/
Expand Down Expand Up @@ -2288,6 +2310,12 @@ int codec_mm_scatter_mgt_init(void)
scatter_mgt->enable_slot_from_sys = 1;
scatter_mgt->support_from_slot_sys =
scatter_mgt->enable_slot_from_sys;
if ((totalram_pages << PAGE_SHIFT) < 800 * SZ_1M) {
/*less memory boards don't cache more,
after alloced many pages.*/
scatter_mgt->no_cache_size_M = 100;
} else
scatter_mgt->no_cache_size_M = 0;
INIT_LIST_HEAD(&scatter_mgt->free_list);
INIT_LIST_HEAD(&scatter_mgt->scatter_list);
mutex_init(&scatter_mgt->monitor_lock);
Expand Down

0 comments on commit ca80538

Please sign in to comment.