msm: eva: Merge Lahaina changes

changes from gerrits: 3302597 3292606 3313485 3315054 3303642

Change-Id: I7d481ced38963396255435ddb968017f79bfbe12
Signed-off-by: George Shen <sqiao@codeaurora.org>
This commit is contained in:
George Shen
2020-09-02 22:47:56 -07:00
parent 0c218a6148
commit 16527cad45
8 changed files with 90 additions and 37 deletions

View File

@@ -115,7 +115,6 @@ static void init_cycle_info(struct cvp_cycle_info *info)
memset(info->cycle, 0, memset(info->cycle, 0,
HFI_MAX_HW_THREADS*sizeof(struct cvp_cycle_stat)); HFI_MAX_HW_THREADS*sizeof(struct cvp_cycle_stat));
info->conf_freq = 0; info->conf_freq = 0;
mutex_init(&info->lock);
} }
static int msm_cvp_initialize_core(struct platform_device *pdev, static int msm_cvp_initialize_core(struct platform_device *pdev,
@@ -134,6 +133,7 @@ static int msm_cvp_initialize_core(struct platform_device *pdev,
INIT_LIST_HEAD(&core->instances); INIT_LIST_HEAD(&core->instances);
mutex_init(&core->lock); mutex_init(&core->lock);
mutex_init(&core->clk_lock);
core->state = CVP_CORE_UNINIT; core->state = CVP_CORE_UNINIT;
for (i = SYS_MSG_INDEX(SYS_MSG_START); for (i = SYS_MSG_INDEX(SYS_MSG_START);
@@ -502,7 +502,7 @@ static int msm_cvp_remove(struct platform_device *pdev)
sysfs_remove_group(&pdev->dev.kobj, &msm_cvp_core_attr_group); sysfs_remove_group(&pdev->dev.kobj, &msm_cvp_core_attr_group);
dev_set_drvdata(&pdev->dev, NULL); dev_set_drvdata(&pdev->dev, NULL);
mutex_destroy(&core->lock); mutex_destroy(&core->lock);
mutex_destroy(&core->dyn_clk.lock); mutex_destroy(&core->clk_lock);
kfree(core); kfree(core);
return rc; return rc;
} }

View File

@@ -4379,6 +4379,35 @@ static int iris_hfi_get_core_capabilities(void *dev)
static u32 cvp_arp_test_regs[16]; static u32 cvp_arp_test_regs[16];
static u32 cvp_dma_test_regs[512]; static u32 cvp_dma_test_regs[512];
static const char * const mid_names[16] = {
"CVP_FW",
"ARP_DATA",
"CVP_OD_NON_PIXEL",
"CVP_OD_ORIG_PIXEL",
"CVP_OD_WR_PIXEL",
"CVP_MPU_ORIG_PIXEL",
"CVP_MPU_REF_PIXEL",
"CVP_MPU_NON_PIXEL",
"CVP_MPU_DFS",
"CVP_FDU_NON_PIXEL",
"CVP_FDU_PIXEL",
"CVP_ICA_PIXEL",
"Invalid",
"Invalid",
"Invalid",
"Invalid"
};
static void __print_reg_details(u32 val)
{
u32 mid, sid;
mid = (val >> 5) & 0xF;
sid = (val >> 2) & 0x7;
dprintk(CVP_ERR, "CVP_NOC_CORE_ERL_MAIN_ERRLOG3_LOW: %#x\n", val);
dprintk(CVP_ERR, "Sub-client:%s, SID: %d\n", mid_names[mid], sid);
}
static void __noc_error_info_iris2(struct iris_hfi_device *device) static void __noc_error_info_iris2(struct iris_hfi_device *device)
{ {
u32 val = 0, regi, i; u32 val = 0, regi, i;
@@ -4433,7 +4462,7 @@ static void __noc_error_info_iris2(struct iris_hfi_device *device)
val = __read_register(device, CVP_NOC_CORE_ERR_ERRLOG2_HIGH_OFFS); val = __read_register(device, CVP_NOC_CORE_ERR_ERRLOG2_HIGH_OFFS);
dprintk(CVP_ERR, "CVP_NOC_CORE_ERL_MAIN_ERRLOG2_HIGH: %#x\n", val); dprintk(CVP_ERR, "CVP_NOC_CORE_ERL_MAIN_ERRLOG2_HIGH: %#x\n", val);
val = __read_register(device, CVP_NOC_CORE_ERR_ERRLOG3_LOW_OFFS); val = __read_register(device, CVP_NOC_CORE_ERR_ERRLOG3_LOW_OFFS);
dprintk(CVP_ERR, "CVP_NOC_CORE_ERL_MAIN_ERRLOG3_LOW: %#x\n", val); __print_reg_details(val);
val = __read_register(device, CVP_NOC_CORE_ERR_ERRLOG3_HIGH_OFFS); val = __read_register(device, CVP_NOC_CORE_ERR_ERRLOG3_HIGH_OFFS);
dprintk(CVP_ERR, "CVP_NOC_CORE_ERL_MAIN_ERRLOG3_HIGH: %#x\n", val); dprintk(CVP_ERR, "CVP_NOC_CORE_ERL_MAIN_ERRLOG3_HIGH: %#x\n", val);
#define CVP_SS_CLK_HALT 0x8 #define CVP_SS_CLK_HALT 0x8

View File

@@ -182,9 +182,7 @@ static int msm_cvp_session_process_hfi(
dprintk(CVP_ERR, "%s incorrect packet %d, %x\n", __func__, dprintk(CVP_ERR, "%s incorrect packet %d, %x\n", __func__,
in_pkt->pkt_data[0], in_pkt->pkt_data[0],
in_pkt->pkt_data[1]); in_pkt->pkt_data[1]);
offset = in_offset; goto exit;
buf_num = in_buf_num;
signal = HAL_NO_RESP;
} else { } else {
offset = cvp_hfi_defs[pkt_idx].buf_offset; offset = cvp_hfi_defs[pkt_idx].buf_offset;
buf_num = cvp_hfi_defs[pkt_idx].buf_num; buf_num = cvp_hfi_defs[pkt_idx].buf_num;
@@ -376,7 +374,7 @@ static int cvp_check_clock(struct msm_cvp_inst *inst,
__func__, fw_cycles, hw_cycles[0], __func__, fw_cycles, hw_cycles[0],
hw_cycles[1], hw_cycles[2], hw_cycles[3]); hw_cycles[1], hw_cycles[2], hw_cycles[3]);
mutex_lock(&core->dyn_clk.lock); mutex_lock(&core->clk_lock);
for (i = 0; i < HFI_MAX_HW_THREADS; ++i) { for (i = 0; i < HFI_MAX_HW_THREADS; ++i) {
dprintk(CVP_PWR, "%s - %d: hw_cycles %u, tens_thresh %u\n", dprintk(CVP_PWR, "%s - %d: hw_cycles %u, tens_thresh %u\n",
__func__, i, hw_cycles[i], __func__, i, hw_cycles[i],
@@ -437,7 +435,7 @@ static int cvp_check_clock(struct msm_cvp_inst *inst,
} }
} }
} }
mutex_unlock(&core->dyn_clk.lock); mutex_unlock(&core->clk_lock);
return rc; return rc;
} }
@@ -861,6 +859,8 @@ static void aggregate_power_update(struct msm_cvp_core *core,
* Clock vote from realtime session will be hard request. If aggregated * Clock vote from realtime session will be hard request. If aggregated
* session clock request exceeds max limit, the function will return * session clock request exceeds max limit, the function will return
* error. * error.
*
* Ensure caller acquires clk_lock!
*/ */
static int adjust_bw_freqs(void) static int adjust_bw_freqs(void)
{ {
@@ -943,7 +943,6 @@ static int adjust_bw_freqs(void)
} }
ctrl_freq = (core->curr_freq*3)>>1; ctrl_freq = (core->curr_freq*3)>>1;
mutex_lock(&core->dyn_clk.lock);
core->dyn_clk.conf_freq = core->curr_freq; core->dyn_clk.conf_freq = core->curr_freq;
for (i = 0; i < HFI_MAX_HW_THREADS; ++i) { for (i = 0; i < HFI_MAX_HW_THREADS; ++i) {
core->dyn_clk.hi_ctrl_lim[i] = core->dyn_clk.sum_fps[i] ? core->dyn_clk.hi_ctrl_lim[i] = core->dyn_clk.sum_fps[i] ?
@@ -951,7 +950,6 @@ static int adjust_bw_freqs(void)
core->dyn_clk.lo_ctrl_lim[i] = core->dyn_clk.lo_ctrl_lim[i] =
core->dyn_clk.hi_ctrl_lim[i]; core->dyn_clk.hi_ctrl_lim[i];
} }
mutex_unlock(&core->dyn_clk.lock);
hdev->clk_freq = core->curr_freq; hdev->clk_freq = core->curr_freq;
rc = icc_set_bw(bus->client, bw_sum, 0); rc = icc_set_bw(bus->client, bw_sum, 0);
@@ -980,9 +978,9 @@ static int msm_cvp_update_power(struct msm_cvp_inst *inst)
inst->cur_cmd_type = CVP_KMD_UPDATE_POWER; inst->cur_cmd_type = CVP_KMD_UPDATE_POWER;
core = inst->core; core = inst->core;
mutex_lock(&core->lock); mutex_lock(&core->clk_lock);
rc = adjust_bw_freqs(); rc = adjust_bw_freqs();
mutex_unlock(&core->lock); mutex_unlock(&core->clk_lock);
inst->cur_cmd_type = 0; inst->cur_cmd_type = 0;
cvp_put_inst(s); cvp_put_inst(s);

View File

@@ -9,6 +9,23 @@
#include "msm_cvp_core.h" #include "msm_cvp_core.h"
#include "msm_cvp_dsp.h" #include "msm_cvp_dsp.h"
#define CLEAR_USE_BITMAP(idx, inst) \
do { \
clear_bit(idx, &inst->dma_cache.usage_bitmap); \
dprintk(CVP_MEM, "clear %x bit %d dma_cache bitmap 0x%llx\n", \
hash32_ptr(inst->session), smem->bitmap_index, \
inst->dma_cache.usage_bitmap); \
} while (0)
#define SET_USE_BITMAP(idx, inst) \
do { \
set_bit(idx, &inst->dma_cache.usage_bitmap); \
dprintk(CVP_MEM, "Set %x bit %d dma_cache bitmap 0x%llx\n", \
hash32_ptr(inst->session), idx, \
inst->dma_cache.usage_bitmap); \
} while (0)
void print_smem(u32 tag, const char *str, struct msm_cvp_inst *inst, void print_smem(u32 tag, const char *str, struct msm_cvp_inst *inst,
struct msm_cvp_smem *smem) struct msm_cvp_smem *smem)
{ {
@@ -16,9 +33,11 @@ void print_smem(u32 tag, const char *str, struct msm_cvp_inst *inst,
return; return;
if (smem->dma_buf) { if (smem->dma_buf) {
dprintk(tag, "%s: %x : %s size %d flags %#x iova %#x", str, dprintk(tag,
hash32_ptr(inst->session), smem->dma_buf->name, "%s: %x : %s size %d flags %#x iova %#x idx %d ref %d",
smem->size, smem->flags, smem->device_addr); str, hash32_ptr(inst->session), smem->dma_buf->name,
smem->size, smem->flags, smem->device_addr,
smem->bitmap_index, smem->refcount);
} }
} }
@@ -126,7 +145,7 @@ int msm_cvp_map_buf_dsp(struct msm_cvp_inst *inst, struct cvp_kmd_buffer *buf)
smem->dma_buf = dma_buf; smem->dma_buf = dma_buf;
smem->bitmap_index = MAX_DMABUF_NUMS; smem->bitmap_index = MAX_DMABUF_NUMS;
dprintk(CVP_DSP, "%s: dma_buf = %llx\n", __func__, dma_buf); dprintk(CVP_MEM, "%s: dma_buf = %llx\n", __func__, dma_buf);
rc = msm_cvp_map_smem(inst, smem, "map dsp"); rc = msm_cvp_map_smem(inst, smem, "map dsp");
if (rc) { if (rc) {
print_client_buffer(CVP_ERR, "map failed", inst, buf); print_client_buffer(CVP_ERR, "map failed", inst, buf);
@@ -274,7 +293,7 @@ static struct msm_cvp_smem *msm_cvp_session_find_smem(struct msm_cvp_inst *inst,
mutex_lock(&inst->dma_cache.lock); mutex_lock(&inst->dma_cache.lock);
for (i = 0; i < inst->dma_cache.nr; i++) for (i = 0; i < inst->dma_cache.nr; i++)
if (inst->dma_cache.entries[i]->dma_buf == dma_buf) { if (inst->dma_cache.entries[i]->dma_buf == dma_buf) {
set_bit(i, &inst->dma_cache.usage_bitmap); SET_USE_BITMAP(i, inst);
smem = inst->dma_cache.entries[i]; smem = inst->dma_cache.entries[i];
smem->bitmap_index = i; smem->bitmap_index = i;
atomic_inc(&smem->refcount); atomic_inc(&smem->refcount);
@@ -303,7 +322,7 @@ static int msm_cvp_session_add_smem(struct msm_cvp_inst *inst,
mutex_lock(&inst->dma_cache.lock); mutex_lock(&inst->dma_cache.lock);
if (inst->dma_cache.nr < MAX_DMABUF_NUMS) { if (inst->dma_cache.nr < MAX_DMABUF_NUMS) {
inst->dma_cache.entries[inst->dma_cache.nr] = smem; inst->dma_cache.entries[inst->dma_cache.nr] = smem;
set_bit(inst->dma_cache.nr, &inst->dma_cache.usage_bitmap); SET_USE_BITMAP(inst->dma_cache.nr, inst);
smem->bitmap_index = inst->dma_cache.nr; smem->bitmap_index = inst->dma_cache.nr;
inst->dma_cache.nr++; inst->dma_cache.nr++;
i = smem->bitmap_index; i = smem->bitmap_index;
@@ -318,7 +337,7 @@ static int msm_cvp_session_add_smem(struct msm_cvp_inst *inst,
inst->dma_cache.entries[i] = smem; inst->dma_cache.entries[i] = smem;
smem->bitmap_index = i; smem->bitmap_index = i;
set_bit(i, &inst->dma_cache.usage_bitmap); SET_USE_BITMAP(i, inst);
} else { } else {
dprintk(CVP_WARN, "%s: not enough memory\n", __func__); dprintk(CVP_WARN, "%s: not enough memory\n", __func__);
mutex_unlock(&inst->dma_cache.lock); mutex_unlock(&inst->dma_cache.lock);
@@ -495,13 +514,14 @@ static void msm_cvp_unmap_frame_buf(struct msm_cvp_inst *inst,
dma_buf_put(smem->dma_buf); dma_buf_put(smem->dma_buf);
kmem_cache_free(cvp_driver->smem_cache, smem); kmem_cache_free(cvp_driver->smem_cache, smem);
buf->smem = NULL; buf->smem = NULL;
} else if (atomic_dec_and_test(&smem->refcount)) { } else {
clear_bit(smem->bitmap_index, mutex_lock(&inst->dma_cache.lock);
&inst->dma_cache.usage_bitmap); if (atomic_dec_and_test(&smem->refcount)) {
dprintk(CVP_MEM, "smem %x %d iova %#x to be reused\n", CLEAR_USE_BITMAP(smem->bitmap_index, inst);
hash32_ptr(inst->session), print_smem(CVP_MEM, "Map dereference",
smem->size, inst, smem);
smem->device_addr); }
mutex_unlock(&inst->dma_cache.lock);
} }
} }
@@ -550,7 +570,7 @@ int msm_cvp_unmap_user_persist(struct msm_cvp_inst *inst,
struct msm_cvp_smem *smem = NULL; struct msm_cvp_smem *smem = NULL;
if (!offset || !buf_num) if (!offset || !buf_num)
return 0; return rc;
cmd_hdr = (struct cvp_hfi_cmd_session_hdr *)in_pkt; cmd_hdr = (struct cvp_hfi_cmd_session_hdr *)in_pkt;
ktid = cmd_hdr->client_data.kdata & (FENCE_BIT - 1); ktid = cmd_hdr->client_data.kdata & (FENCE_BIT - 1);
@@ -574,10 +594,13 @@ int msm_cvp_unmap_user_persist(struct msm_cvp_inst *inst,
cvp_driver->smem_cache, cvp_driver->smem_cache,
smem); smem);
pbuf->smem = NULL; pbuf->smem = NULL;
} else if (atomic_dec_and_test( } else {
&smem->refcount)) { mutex_lock(&inst->dma_cache.lock);
clear_bit(smem->bitmap_index, if (atomic_dec_and_test(&smem->refcount))
&inst->dma_cache.usage_bitmap); CLEAR_USE_BITMAP(
smem->bitmap_index,
inst);
mutex_unlock(&inst->dma_cache.lock);
} }
kmem_cache_free(cvp_driver->buf_cache, pbuf); kmem_cache_free(cvp_driver->buf_cache, pbuf);

View File

@@ -1611,7 +1611,8 @@ int cvp_comm_set_arp_buffers(struct msm_cvp_inst *inst)
return rc; return rc;
error: error:
cvp_release_arp_buffers(inst); if (rc != -ENOMEM)
cvp_release_arp_buffers(inst);
return rc; return rc;
} }

View File

@@ -22,7 +22,7 @@ int msm_cvp_fw_debug_mode = 1;
int msm_cvp_fw_low_power_mode = 1; int msm_cvp_fw_low_power_mode = 1;
bool msm_cvp_fw_coverage = !true; bool msm_cvp_fw_coverage = !true;
bool msm_cvp_thermal_mitigation_disabled = !true; bool msm_cvp_thermal_mitigation_disabled = !true;
bool msm_cvp_cacheop_disabled = true; bool msm_cvp_cacheop_disabled = !true;
int msm_cvp_clock_voting = !1; int msm_cvp_clock_voting = !1;
bool msm_cvp_syscache_disable = !true; bool msm_cvp_syscache_disable = !true;
bool msm_cvp_dsp_disable = !true; bool msm_cvp_dsp_disable = !true;

View File

@@ -218,7 +218,6 @@ struct cvp_cycle_info {
u32 lo_ctrl_lim[HFI_MAX_HW_THREADS]; u32 lo_ctrl_lim[HFI_MAX_HW_THREADS];
struct cvp_cycle_stat cycle[HFI_MAX_HW_THREADS]; struct cvp_cycle_stat cycle[HFI_MAX_HW_THREADS];
unsigned long conf_freq; unsigned long conf_freq;
struct mutex lock;
}; };
struct cvp_session_prop { struct cvp_session_prop {
@@ -263,6 +262,7 @@ struct cvp_session_event {
struct msm_cvp_core { struct msm_cvp_core {
struct list_head list; struct list_head list;
struct mutex lock; struct mutex lock;
struct mutex clk_lock;
int id; int id;
dev_t dev_num; dev_t dev_num;
struct cdev cdev; struct cdev cdev;

View File

@@ -215,7 +215,7 @@ void *cvp_get_drv_data(struct device *dev)
driver_data = (struct msm_cvp_platform_data *)match->data; driver_data = (struct msm_cvp_platform_data *)match->data;
if (!strcmp(match->compatible, "qcom,kona-cvp")) { if (!strcmp(match->compatible, "qcom,lahaina-cvp")) {
ddr_type = of_fdt_get_ddrtype(); ddr_type = of_fdt_get_ddrtype();
if (ddr_type == -ENOENT) { if (ddr_type == -ENOENT) {
dprintk(CVP_ERR, dprintk(CVP_ERR,
@@ -224,9 +224,11 @@ void *cvp_get_drv_data(struct device *dev)
if (driver_data->ubwc_config && if (driver_data->ubwc_config &&
(ddr_type == DDR_TYPE_LPDDR4 || (ddr_type == DDR_TYPE_LPDDR4 ||
ddr_type == DDR_TYPE_LPDDR4X || ddr_type == DDR_TYPE_LPDDR4X))
ddr_type == DDR_TYPE_LPDDR4Y))
driver_data->ubwc_config->highest_bank_bit = 15; driver_data->ubwc_config->highest_bank_bit = 15;
dprintk(CVP_CORE, "DDR Type 0x%x hbb 0x%x\n",
ddr_type, driver_data->ubwc_config ?
driver_data->ubwc_config->highest_bank_bit : -1);
} }
exit: exit:
return driver_data; return driver_data;