media: merge some bugfix from 3.14

PD#146178: codec_mm: fixed scatter inc check bug
PD#148029: fixed codec_mm tvp aligned bug.
PD#148029 codec_mm: fixed 2 bugs [1/1]
	fixed scatter memory check bug.
	fixed codec_mm tvp alloc aligned bug.
PD#147242: amports: add protect for video keepr.
	if not memory may free on keeping.

Change-Id: I7ebe0d3fb3caac3849dea558d91129123f8147ad
Signed-off-by: Zhi Zhou <zhi.zhou@amlogic.com>
This commit is contained in:
Zhi Zhou
2017-07-21 14:45:41 +08:00
committed by Victor Wan
parent cdd6d7c4f1
commit 64d6b11ab3
5 changed files with 77 additions and 52 deletions

View File

@@ -617,9 +617,10 @@ struct codec_mm_s *codec_mm_alloc(const char *owner, int size,
spin_unlock_irqrestore(&mgt->lock, flags);
mem->alloced_jiffies = get_jiffies_64();
if (debug_mode & 0x20)
pr_err("%s alloc mem size %d at %lx from %d,flags:%d\n",
pr_err("%s alloc size %d at %lx from %d,2n:%d,flags:%d\n",
owner, size, mem->phy_addr,
mem->from_flags,
align2n,
memflags);
return mem;
}
@@ -840,7 +841,7 @@ int codec_mm_extpool_pool_alloc(
size - alloced_size, try_alloced_size);
mem = codec_mm_alloc(TVP_POOL_NAME,
try_alloced_size,
0,
RESERVE_MM_ALIGNED_2N,
CODEC_MM_FLAGS_FOR_LOCAL_MGR |
CODEC_MM_FLAGS_RESERVED);
@@ -872,7 +873,7 @@ int codec_mm_extpool_pool_alloc(
TVP_POOL_NAME :
CMA_RES_POOL_NAME,
try_alloced_size,
0,
RESERVE_MM_ALIGNED_2N,
CODEC_MM_FLAGS_FOR_LOCAL_MGR |
CODEC_MM_FLAGS_CMA);

View File

@@ -29,7 +29,7 @@
#include "codec_mm_priv.h"
#include "codec_mm_scatter_priv.h"
#define KEEP_NAME "keeper"
#define MAX_KEEP_FRAME 8
#define MAX_KEEP_FRAME 16
#define START_KEEP_ID 0x9
#define MAX_KEEP_ID (INT_MAX - 1)

View File

@@ -1342,18 +1342,14 @@ static int codec_mm_scatter_free_on_nouser(
/*
*mask for other use it.
*/
static int codec_mm_scatter_inc_user_in(struct codec_mm_scatter *mms,
static int codec_mm_scatter_inc_user_in1(
struct codec_mm_scatter_mgt *smgt,
struct codec_mm_scatter *mms,
int cnt)
{
struct codec_mm_scatter_mgt *smgt;
int ret = -1;
int old_user;
if (!mms)
return -1;
smgt = (struct codec_mm_scatter_mgt *)mms->manager;
if (smgt->tag != SMGT_IDENTIFY_TAG)
return -2;/*not valid tag*/
codec_mm_list_lock(smgt);
if (!codec_mm_scatter_valid_locked(smgt, mms)) {
codec_mm_list_unlock(smgt);
@@ -1369,19 +1365,35 @@ static int codec_mm_scatter_inc_user_in(struct codec_mm_scatter *mms,
return ret <= 0 ? ret : 0; /*must add before user cnt >= 0 */
}
/*mask scatter's to free.*/
static int codec_mm_scatter_dec_user_in(
struct codec_mm_scatter *mms,
int delay_free_ms, int cnt)
static int codec_mm_scatter_inc_user_in(
struct codec_mm_scatter *mms,
int cnt)
{
struct codec_mm_scatter_mgt *smgt;
int after_users = 1;
int ret;
if (!mms)
return -1;
smgt = (struct codec_mm_scatter_mgt *)mms->manager;
if (smgt->tag != SMGT_IDENTIFY_TAG)
return -2;/*not valid tag*/
smgt = codec_mm_get_scatter_mgt(0);
ret = codec_mm_scatter_inc_user_in1(smgt,
mms,
cnt);
if (ret < 0) {
smgt = codec_mm_get_scatter_mgt(1);
ret = codec_mm_scatter_inc_user_in1(smgt,
mms,
cnt);
}
return ret;
}
/*mask scatter's to free.*/
static int codec_mm_scatter_dec_user_in1(
struct codec_mm_scatter_mgt *smgt,
struct codec_mm_scatter *mms,
int delay_free_ms, int cnt)
{
int after_users = 1;
codec_mm_list_lock(smgt);
if (!codec_mm_scatter_valid_locked(smgt, mms)) {
codec_mm_list_unlock(smgt);
@@ -1390,10 +1402,10 @@ static int codec_mm_scatter_dec_user_in(
if (atomic_read(&mms->user_cnt) >= 1) {
after_users = atomic_sub_return(cnt, &mms->user_cnt);
if (after_users == 0) {
/*is free time */
/*is free time*/
if (delay_free_ms > 0)
mms->tofree_jiffies = jiffies +
delay_free_ms * HZ / 1000;
mms->tofree_jiffies = jiffies +
delay_free_ms * HZ/1000;
else {
mms->page_used = 0;
mms->tofree_jiffies = 0;
@@ -1405,7 +1417,29 @@ static int codec_mm_scatter_dec_user_in(
codec_mm_schedule_delay_work(smgt, 0, 1);
return 0;
}
/*mask scatter's to free.*/
static int codec_mm_scatter_dec_user_in(
struct codec_mm_scatter *mms,
int delay_free_ms, int cnt)
{
struct codec_mm_scatter_mgt *smgt;
int ret;
if (!mms)
return -1;
smgt = codec_mm_get_scatter_mgt(0);
ret = codec_mm_scatter_dec_user_in1(smgt,
mms,
delay_free_ms,
cnt);
if (ret < 0) {
smgt = codec_mm_get_scatter_mgt(1);
ret = codec_mm_scatter_dec_user_in1(smgt,
mms,
delay_free_ms,
cnt);
}
return ret;
}
/*
*maybe a render/sink.video/osd/
*/

View File

@@ -5583,11 +5583,6 @@ static void video_vf_unreg_provider(void)
to_notify_trick_wait = false;
}
if (blackout | force_blackout) {
safe_disble_videolayer();
try_free_keep_video(1);
}
vsync_pts_100 = 0;
vsync_pts_112 = 0;
vsync_pts_125 = 0;
@@ -5595,6 +5590,11 @@ static void video_vf_unreg_provider(void)
video_prot.video_started = 0;
spin_unlock_irqrestore(&lock, flags);
if (blackout | force_blackout) {
safe_disble_videolayer();
try_free_keep_video(1);
}
#ifdef CONFIG_GE2D_KEEP_FRAME
if (cur_dispbuf) {
/* TODO: mod gate */

View File

@@ -60,6 +60,7 @@
#include <linux/amlogic/media/utils/vdec_reg.h>
#define MEM_NAME "video-keeper"
static DEFINE_MUTEX(video_keeper_mutex);
static unsigned long keep_y_addr, keep_u_addr, keep_v_addr;
static int keep_video_on;
@@ -710,35 +711,15 @@ void try_free_keep_video(int flags)
codec_mm_keeper_unmask_keeper(keep_head_id, 0);
keep_head_id = -1;
}
mutex_lock(&video_keeper_mutex);
free_alloced_keep_buffer();
mutex_unlock(&video_keeper_mutex);
}
EXPORT_SYMBOL(try_free_keep_video);
#endif
void get_video_keep_buffer(ulong *addr, ulong *phys_addr)
{
#if 1
if (addr) {
addr[0] = (ulong) 0;
addr[1] = (ulong) 0;
addr[2] = (ulong) 0;
}
if (phys_addr) {
if (!keep_y_addr || !keep_u_addr || !keep_v_addr)
alloc_keep_buffer();
phys_addr[0] = keep_y_addr;
phys_addr[1] = keep_u_addr;
phys_addr[2] = keep_v_addr;
}
#endif
if (get_video_debug_flags() & DEBUG_FLAG_BLACKOUT) {
pr_info("%s: y=%lx u=%lx v=%lx\n", __func__, phys_addr[0],
phys_addr[1], phys_addr[2]);
}
}
void video_keeper_new_frame_notify(void)
{
if (keep_video_on) {
@@ -759,7 +740,7 @@ void video_keeper_new_frame_notify(void)
}
return;
}
unsigned int vf_keep_current(struct vframe_s *cur_dispbuf)
static unsigned int vf_keep_current_locked(struct vframe_s *cur_dispbuf)
{
u32 cur_index;
u32 y_index, u_index, v_index;
@@ -1018,6 +999,15 @@ unsigned int vf_keep_current(struct vframe_s *cur_dispbuf)
return 0;
}
unsigned int vf_keep_current(struct vframe_s *cur_dispbuf)
{
unsigned int ret;
mutex_lock(&video_keeper_mutex);
ret = vf_keep_current_locked(cur_dispbuf);
mutex_unlock(&video_keeper_mutex);
return ret;
}
int __init video_keeper_init(void)
{