Merge "msm: cvp: Add debug node control power collapse"

This commit is contained in:
qctecmdr 2020-02-04 03:48:05 -08:00 • committed by Gerrit - the friendly Code Review server
commit ba0579037e
21 changed files with 109 additions and 44 deletions

View file

@ -1,6 +1,6 @@
// SPDX-License-Identifier: GPL-2.0-only
/*
* Copyright (c) 2018-2019, The Linux Foundation. All rights reserved.
* Copyright (c) 2018-2020, The Linux Foundation. All rights reserved.
*/
#include <linux/slab.h>

View file

@ -1131,6 +1131,26 @@ static inline int __boot_firmware(struct iris_hfi_device *device)
return rc;
}
static int iris_hfi_resume(void *dev)
{
int rc = 0;
struct iris_hfi_device *device = (struct iris_hfi_device *) dev;
if (!device) {
dprintk(CVP_ERR, "%s invalid device\n", __func__);
return -EINVAL;
}
dprintk(CVP_DBG, "Resuming Iris\n");
mutex_lock(&device->lock);
rc = __resume(device);
mutex_unlock(&device->lock);
return rc;
}
static int iris_hfi_suspend(void *dev)
{
int rc = 0;
@ -1231,7 +1251,6 @@ static int __set_clocks(struct iris_hfi_device *device, u32 freq)
return rc;
}
trace_msm_cvp_perf_clock_scale(cl->name, freq);
dprintk(CVP_DBG, "Scaling clock %s to %u\n",
cl->name, freq);
}
@ -4213,7 +4232,6 @@ static int __load_fw(struct iris_hfi_device *device)
dprintk(CVP_ERR, "Failed to initialize packetization\n");
goto fail_init_pkt;
}
trace_msm_v4l2_cvp_fw_load_start("msm_cvp cvp fw load start");
rc = __iris_power_on(device);
if (rc) {
@ -4243,7 +4261,6 @@ static int __load_fw(struct iris_hfi_device *device)
goto fail_protect_mem;
}
}
trace_msm_v4l2_cvp_fw_load_end("msm_cvp cvp fw load end");
return rc;
fail_protect_mem:
if (device->resources.fw.cookie)
@ -4255,7 +4272,6 @@ fail_iris_power_on:
fail_init_pkt:
__deinit_resources(device);
fail_init_res:
trace_msm_v4l2_cvp_fw_load_end("msm_cvp cvp fw load end");
return rc;
}
@ -4577,6 +4593,7 @@ static void iris_init_hfi_callbacks(struct cvp_hfi_device *hdev)
hdev->get_fw_info = iris_hfi_get_fw_info;
hdev->get_core_capabilities = iris_hfi_get_core_capabilities;
hdev->suspend = iris_hfi_suspend;
hdev->resume = iris_hfi_resume;
hdev->flush_debug_queue = iris_hfi_flush_debug_queue;
hdev->noc_error_info = iris_hfi_noc_error_info;
hdev->validate_session = iris_hfi_validate_session;

View file

@ -406,6 +406,7 @@ struct cvp_hfi_device {
int (*session_clean)(void *sess);
int (*get_core_capabilities)(void *dev);
int (*suspend)(void *dev);
int (*resume)(void *dev);
int (*flush_debug_queue)(void *dev);
int (*noc_error_info)(void *dev);
int (*validate_session)(void *sess, const char *func);

View file

@ -1,6 +1,6 @@
/* SPDX-License-Identifier: GPL-2.0-only */
/*
* Copyright (c) 2018-2019, The Linux Foundation. All rights reserved.
* Copyright (c) 2018-2020, The Linux Foundation. All rights reserved.
*/
#ifndef __CVP_HFI_IO_H__

View file

@ -1,6 +1,6 @@
/* SPDX-License-Identifier: GPL-2.0-only */
/*
* Copyright (c) 2018-2019, The Linux Foundation. All rights reserved.
* Copyright (c) 2018-2020, The Linux Foundation. All rights reserved.
*/
#ifndef _MSM_V4L2_PRIVATE_H_

View file

@ -1,6 +1,6 @@
/* SPDX-License-Identifier: GPL-2.0-only */
/*
* Copyright (c) 2018-2019, The Linux Foundation. All rights reserved.
* Copyright (c) 2018-2020, The Linux Foundation. All rights reserved.
*/
#ifndef __HFI_PACKETIZATION__
#define __HFI_PACKETIZATION__

View file

@ -1,6 +1,6 @@
/* SPDX-License-Identifier: GPL-2.0-only */
/*
* Copyright (c) 2018-2019, The Linux Foundation. All rights reserved.
* Copyright (c) 2018-2020, The Linux Foundation. All rights reserved.
*/
#ifndef _MSM_CVP_H_

View file

@ -1,6 +1,6 @@
// SPDX-License-Identifier: GPL-2.0-only
/*
* Copyright (c) 2018-2019, The Linux Foundation. All rights reserved.
* Copyright (c) 2018-2020, The Linux Foundation. All rights reserved.
*/
#include "msm_cvp_common.h"

View file

@ -1,6 +1,6 @@
/* SPDX-License-Identifier: GPL-2.0-only */
/*
* Copyright (c) 2018-2019, The Linux Foundation. All rights reserved.
* Copyright (c) 2018-2020, The Linux Foundation. All rights reserved.
*/

View file

@ -1301,9 +1301,6 @@ int msm_cvp_comm_try_state(struct msm_cvp_inst *inst, int state)
"Failed to move from state: %d to %d\n",
inst->state, state);
msm_cvp_comm_kill_session(inst);
} else {
trace_msm_cvp_common_state_change((void *)inst,
inst->state, state);
}
return rc;
}

View file

@ -1,6 +1,6 @@
/* SPDX-License-Identifier: GPL-2.0-only */
/*
* Copyright (c) 2018-2019, The Linux Foundation. All rights reserved.
* Copyright (c) 2018-2020, The Linux Foundation. All rights reserved.
*/

View file

@ -1,6 +1,6 @@
// SPDX-License-Identifier: GPL-2.0-only
/*
* Copyright (c) 2018-2019, The Linux Foundation. All rights reserved.
* Copyright (c) 2018-2020, The Linux Foundation. All rights reserved.
*/
#include <linux/dma-direction.h>

View file

@ -1,6 +1,6 @@
/* SPDX-License-Identifier: GPL-2.0-only */
/*
* Copyright (c) 2018-2019, The Linux Foundation. All rights reserved.
* Copyright (c) 2018-2020, The Linux Foundation. All rights reserved.
*/
#ifndef _MSM_CVP_CORE_H_

View file

@ -3,12 +3,14 @@
* Copyright (c) 2018-2020, The Linux Foundation. All rights reserved.
*/
#define CREATE_TRACE_POINTS
#define MAX_SSR_STRING_LEN 10
#include <linux/debugfs.h>
#include "msm_cvp_debug.h"
#include "msm_cvp_common.h"
#include "cvp_core_hfi.h"
#include "cvp_hfi_api.h"
#define CREATE_TRACE_POINTS
#define MAX_SSR_STRING_LEN 10
int msm_cvp_debug = CVP_ERR | CVP_WARN | CVP_FW | CVP_DBG;
EXPORT_SYMBOL(msm_cvp_debug);
@ -160,6 +162,70 @@ static const struct file_operations ssr_fops = {
.write = trigger_ssr_write,
};
static int cvp_power_get(void *data, u64 *val)
{
struct cvp_hfi_device *hfi_ops;
struct msm_cvp_core *core;
struct iris_hfi_device *hfi_device;
core = list_first_entry(&cvp_driver->cores, struct msm_cvp_core, list);
if (!core)
return 0;
hfi_ops = core->device;
if (!hfi_ops)
return 0;
hfi_device = hfi_ops->hfi_device_data;
if (!hfi_device)
return 0;
*val = hfi_device->power_enabled;
return 0;
}
#define MIN_PC_INTERVAL 1000
#define MAX_PC_INTERVAL 1000000
static int cvp_power_set(void *data, u64 val)
{
struct cvp_hfi_device *hfi_ops;
struct msm_cvp_core *core;
struct iris_hfi_device *hfi_device;
int rc = 0;
core = list_first_entry(&cvp_driver->cores, struct msm_cvp_core, list);
if (!core)
return -EINVAL;
hfi_ops = core->device;
if (!hfi_ops)
return -EINVAL;
hfi_device = hfi_ops->hfi_device_data;
if (!hfi_device)
return -EINVAL;
if (val >= MAX_PC_INTERVAL) {
hfi_device->res->sw_power_collapsible = 0;
} else if (val > MIN_PC_INTERVAL) {
hfi_device->res->sw_power_collapsible = 1;
hfi_device->res->msm_cvp_pwr_collapse_delay =
(unsigned int)val;
}
if (core->state == CVP_CORE_UNINIT)
return -EINVAL;
if (val > 0) {
rc = call_hfi_op(hfi_ops, resume, hfi_ops->hfi_device_data);
if (rc)
dprintk(CVP_ERR, "debugfs fail to power on cvp\n");
}
return rc;
}
DEFINE_DEBUGFS_ATTRIBUTE(cvp_pwr_fops, cvp_power_get, cvp_power_set, "%llu\n");
struct dentry *msm_cvp_debugfs_init_drv(void)
{
bool ok = false;
@ -200,6 +266,8 @@ struct dentry *msm_cvp_debugfs_init_drv(void)
if (!ok)
goto failed_create_dir;
debugfs_create_file("cvp_power", 0644, dir, NULL, &cvp_pwr_fops);
return dir;
failed_create_dir:

View file

@ -1,6 +1,6 @@
/* SPDX-License-Identifier: GPL-2.0-only */
/*
* Copyright (c) 2018-2019, The Linux Foundation. All rights reserved.
* Copyright (c) 2018-2020, The Linux Foundation. All rights reserved.
*/
#ifndef __MSM_CVP_DEBUG__

View file

@ -1,6 +1,6 @@
// SPDX-License-Identifier: GPL-2.0-only
/*
* Copyright (c) 2018-2019, The Linux Foundation. All rights reserved.
* Copyright (c) 2018-2020, The Linux Foundation. All rights reserved.
*/
#include "cvp_private.h"

View file

@ -1,6 +1,6 @@
// SPDX-License-Identifier: GPL-2.0-only
/*
* Copyright (c) 2018-2019, The Linux Foundation. All rights reserved.
* Copyright (c) 2018-2020, The Linux Foundation. All rights reserved.
*/
#include <linux/debugfs.h>

View file

@ -1,6 +1,6 @@
// SPDX-License-Identifier: GPL-2.0-only
/*
* Copyright (c) 2018-2019, The Linux Foundation. All rights reserved.
* Copyright (c) 2018-2020, The Linux Foundation. All rights reserved.
*/
#include <linux/iommu.h>

View file

@ -1,6 +1,6 @@
/* SPDX-License-Identifier: GPL-2.0-only */
/*
* Copyright (c) 2018-2019, The Linux Foundation. All rights reserved.
* Copyright (c) 2018-2020, The Linux Foundation. All rights reserved.
*/
#ifndef __MSM_CVP_RES_PARSE_H__

View file

@ -1,6 +1,6 @@
/* SPDX-License-Identifier: GPL-2.0-only */
/*
* Copyright (c) 2018-2019, The Linux Foundation. All rights reserved.
* Copyright (c) 2018-2020, The Linux Foundation. All rights reserved.
*/
#ifndef __MSM_CVP_RESOURCES_H__

View file

@ -1,6 +1,6 @@
// SPDX-License-Identifier: GPL-2.0-only
/*
* Copyright (c) 2018-2019, The Linux Foundation. All rights reserved.
* Copyright (c) 2018-2020, The Linux Foundation. All rights reserved.
*/
#include <linux/dma-buf.h>
@ -86,10 +86,6 @@ static int msm_dma_get_device_address(struct dma_buf *dbuf, u32 align,
goto mem_map_table_failed;
}
/* debug trace's need to be updated later */
trace_msm_cvp_smem_buffer_iommu_op_start("MAP", 0, 0,
align, *iova, *buffer_size);
if (table->sgl) {
*iova = table->sgl->dma_address;
*buffer_size = table->sgl->dma_length;
@ -106,8 +102,6 @@ static int msm_dma_get_device_address(struct dma_buf *dbuf, u32 align,
mapping_info->buf = dbuf;
mapping_info->cb_info = (void *)cb;
trace_msm_cvp_smem_buffer_iommu_op_end("MAP", 0, 0,
align, *iova, *buffer_size);
} else {
dprintk(CVP_DBG, "iommu not present, use phys mem addr\n");
}
@ -140,11 +134,9 @@ static int msm_dma_put_device_address(u32 flags,
return -EINVAL;
}
trace_msm_cvp_smem_buffer_iommu_op_start("UNMAP", 0, 0, 0, 0, 0);
dma_buf_unmap_attachment(mapping_info->attach,
mapping_info->table, DMA_BIDIRECTIONAL);
dma_buf_detach(mapping_info->buf, mapping_info->attach);
trace_msm_cvp_smem_buffer_iommu_op_end("UNMAP", 0, 0, 0, 0, 0);
mapping_info->dev = NULL;
mapping_info->domain = NULL;
@ -346,8 +338,6 @@ static int alloc_dma_mem(size_t size, u32 align, u32 flags, int map_kernel,
heap_mask = ION_HEAP(ION_SECURE_HEAP_ID);
}
trace_msm_cvp_smem_buffer_dma_op_start("ALLOC", (u32)ion_flags,
heap_mask, size, align, flags, map_kernel);
dbuf = ion_alloc(size, heap_mask, ion_flags);
if (IS_ERR_OR_NULL(dbuf)) {
dprintk(CVP_ERR,
@ -356,8 +346,6 @@ static int alloc_dma_mem(size_t size, u32 align, u32 flags, int map_kernel,
rc = -ENOMEM;
goto fail_shared_mem_alloc;
}
trace_msm_cvp_smem_buffer_dma_op_end("ALLOC", (u32)ion_flags,
heap_mask, size, align, flags, map_kernel);
mem->flags = flags;
mem->buffer_type = ion_flags;
@ -425,14 +413,8 @@ static int free_dma_mem(struct msm_cvp_smem *mem)
}
if (mem->dma_buf) {
trace_msm_cvp_smem_buffer_dma_op_start("FREE",
(u32)mem->buffer_type, -1, mem->size, -1,
mem->flags, -1);
dma_buf_put(mem->dma_buf);
mem->dma_buf = NULL;
trace_msm_cvp_smem_buffer_dma_op_end(
"FREE", (u32)mem->buffer_type,
-1, mem->size, -1, mem->flags, -1);
}
return 0;