Merge "msm: cvp: Fix for kernel address exposure vulnerability to user"

This commit is contained in:
QCTECMDR Service 2025-11-02 22:58:57 -08:00 • committed by Gerrit - the friendly Code Review server
commit 8288da0e9f
11 changed files with 172 additions and 63 deletions

View file

@ -1,7 +1,7 @@
// SPDX-License-Identifier: GPL-2.0-only
/*
* Copyright (c) 2018-2020, The Linux Foundation. All rights reserved.
* Copyright (c) 2024 Qualcomm Innovation Center, Inc. All rights reserved.
* Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
*/
#include <linux/debugfs.h>
@ -135,6 +135,8 @@ static int msm_cvp_initialize_core(struct platform_device *pdev,
INIT_LIST_HEAD(&core->instances);
mutex_init(&core->lock);
mutex_init(&core->clk_lock);
mutex_init(&core->idr_mtx);
idr_init(&core->sess_idr);
core->state = CVP_CORE_UNINIT;
for (i = SYS_MSG_INDEX(SYS_MSG_START);
@ -506,6 +508,8 @@ static int msm_cvp_remove(struct platform_device *pdev)
msm_cvp_free_platform_resources(&core->resources);
sysfs_remove_group(&pdev->dev.kobj, &msm_cvp_core_attr_group);
dev_set_drvdata(&pdev->dev, NULL);
idr_destroy(&core->sess_idr);
mutex_destroy(&core->idr_mtx);
mutex_destroy(&core->lock);
mutex_destroy(&core->clk_lock);
kfree(core);

View file

@ -1,6 +1,7 @@
// SPDX-License-Identifier: GPL-2.0-only
/*
* Copyright (c) 2018-2021, The Linux Foundation. All rights reserved.
* Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
*/
#include <asm/memory.h>
@ -29,6 +30,7 @@
#include "cvp_hfi_helper.h"
#include "cvp_hfi_io.h"
#include "msm_cvp_dsp.h"
#include "msm_cvp.h"
#define FIRMWARE_SIZE 0X00A00000
#define REG_ADDR_OFFSET_BITMASK 0x000FFFFF
@ -469,6 +471,7 @@ static int __dsp_suspend(struct iris_hfi_device *device, bool force, u32 flags)
{
int rc;
struct cvp_hal_session *temp;
struct msm_cvp_inst *inst = NULL;
if (msm_cvp_dsp_disable)
return 0;
@ -480,9 +483,10 @@ static int __dsp_suspend(struct iris_hfi_device *device, bool force, u32 flags)
/* don't suspend if cvp session is not paused */
if (!(temp->flags & SESSION_PAUSE)) {
inst = (struct msm_cvp_inst *)temp->session_id;
dprintk(CVP_DSP,
"%s: cvp session %x not paused\n",
__func__, hash32_ptr(temp));
__func__, inst->sess_id);
return -EBUSY;
}
}
@ -2224,12 +2228,17 @@ static void __session_clean(struct cvp_hal_session *session)
{
struct cvp_hal_session *temp, *next;
struct iris_hfi_device *device;
struct msm_cvp_core *core = NULL;
struct msm_cvp_inst *inst = NULL;
void *tmp = NULL;
if (!session || !session->device) {
dprintk(CVP_WARN, "%s: invalid params\n", __func__);
return;
}
device = session->device;
core = list_first_entry(&cvp_driver->cores, struct msm_cvp_core, list);
inst = (struct msm_cvp_inst *) session->session_id;
dprintk(CVP_SESS, "deleted the session: %pK\n", session);
/*
* session might have been removed from the device list in
@ -2241,6 +2250,13 @@ static void __session_clean(struct cvp_hal_session *session)
break;
}
}
/* Remove the IDR id assigned to this session */
mutex_lock(&core->idr_mtx);
tmp = idr_remove(&core->sess_idr, inst->sess_id);
if (tmp != session)
dprintk(CVP_WARN, "%s: session\n", __func__);
mutex_unlock(&core->idr_mtx);
/* Poison the session handle with zeros */
*session = (struct cvp_hal_session){ {0} };
kfree(session);
@ -2278,6 +2294,9 @@ static int iris_hfi_session_init(void *device, void *session_id,
struct cvp_hfi_cmd_sys_session_init_packet pkt;
struct iris_hfi_device *dev;
struct cvp_hal_session *s;
struct msm_cvp_core *core;
struct msm_cvp_inst *inst;
int id = 0;
if (!device || !new_session) {
dprintk(CVP_ERR, "%s - invalid input\n", __func__);
@ -2285,6 +2304,8 @@ static int iris_hfi_session_init(void *device, void *session_id,
}
dev = device;
core = list_first_entry(&cvp_driver->cores, struct msm_cvp_core, list);
inst = session_id;
mutex_lock(&dev->lock);
s = kzalloc(sizeof(*s), GFP_KERNEL);
@ -2295,15 +2316,35 @@ static int iris_hfi_session_init(void *device, void *session_id,
s->session_id = session_id;
s->device = dev;
mutex_lock(&core->idr_mtx);
idr_preload(GFP_KERNEL);
/* Need to think if we can use core->lock or dev->lock or need a
* different new lock for this?
*/
id = idr_alloc(&core->sess_idr, (void *)s, 0x7FFF0000, INT_MAX, GFP_NOWAIT);
idr_preload_end();
mutex_unlock(&core->idr_mtx);
if (id < 0) {
dprintk(CVP_ERR,
"%s: idr allocation failed for session %pK of inst %pK\n",
__func__, s, session_id);
goto err_session_init_fail;
}
dprintk(CVP_SESS,
"%s: inst %pK, session %pK\n", __func__, session_id, s);
"%s: inst %pK, session %pK, idr_id = 0x%x\n", __func__, session_id, s, id);
list_add_tail(&s->list, &dev->sess_head);
__set_default_sys_properties(device);
inst->sess_id = id;
if (call_hfi_pkt_op(dev, session_init, &pkt, s)) {
dprintk(CVP_ERR, "session_init: failed to create packet\n");
inst->sess_id = 0x0000DEAD;
goto err_session_init_fail;
}
@ -2317,6 +2358,7 @@ static int iris_hfi_session_init(void *device, void *session_id,
err_session_init_fail:
if (s)
__session_clean(s);
inst->sess_id = 0;
*new_session = NULL;
mutex_unlock(&dev->lock);
return -EINVAL;
@ -2878,9 +2920,11 @@ static struct cvp_hal_session *__get_session(struct iris_hfi_device *device,
u32 session_id)
{
struct cvp_hal_session *temp = NULL;
struct msm_cvp_inst *inst = NULL;
list_for_each_entry(temp, &device->sess_head, list) {
if (session_id == hash32_ptr(temp))
inst = (struct msm_cvp_inst *)temp->session_id;
if (session_id == inst->sess_id)
return temp;
}
@ -3059,6 +3103,7 @@ static int __response_handler(struct iris_hfi_device *device)
/* Process the packet types that we're interested in */
process_system_msg(info, device, raw_packet);
/* This session_id is a double pointer to the idr_id of session */
session_id = get_session_id(info);
/*
* hfi_process_msg_packet provides a session_id that's a hashed
@ -3070,11 +3115,6 @@ static int __response_handler(struct iris_hfi_device *device)
if (session_id) {
struct cvp_hal_session *session = NULL;
if (upper_32_bits((uintptr_t)*session_id) != 0) {
dprintk(CVP_ERR,
"Upper 32-bits != 0 for sess_id=%pK\n",
*session_id);
}
session = __get_session(device,
(u32)(uintptr_t)*session_id);
if (!session) {

View file

@ -1,6 +1,7 @@
// SPDX-License-Identifier: GPL-2.0-only
/*
* Copyright (c) 2018-2020, The Linux Foundation. All rights reserved.
* Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
*/
#include "hfi_packetization.h"
@ -208,7 +209,7 @@ inline int cvp_create_pkt_cmd_sys_session_init(
pkt->size = sizeof(struct cvp_hfi_cmd_sys_session_init_packet);
pkt->packet_type = HFI_CMD_SYS_SESSION_INIT;
pkt->session_id = hash32_ptr(session);
pkt->session_id = inst->sess_id;
pkt->session_type = inst->prop.type;
pkt->session_kmask = inst->prop.kernel_mask;
pkt->session_prio = inst->prop.priority;
@ -266,13 +267,14 @@ int cvp_create_pkt_cmd_session_cmd(struct cvp_hal_session_cmd_pkt *pkt,
int pkt_type, struct cvp_hal_session *session)
{
int rc = 0;
struct msm_cvp_inst *inst = session->session_id;
if (!pkt)
return -EINVAL;
pkt->size = sizeof(struct cvp_hal_session_cmd_pkt);
pkt->packet_type = pkt_type;
pkt->session_id = hash32_ptr(session);
pkt->session_id = inst->sess_id;
return rc;
}
@ -305,13 +307,14 @@ int cvp_create_pkt_cmd_session_set_buffers(
{
int rc = 0;
struct cvp_hfi_cmd_session_set_buffers_packet *pkt;
struct msm_cvp_inst *inst = session->session_id;
if (!cmd || !session)
if (!cmd || !session || !inst)
return -EINVAL;
pkt = (struct cvp_hfi_cmd_session_set_buffers_packet *)cmd;
pkt->packet_type = HFI_CMD_SESSION_CVP_SET_BUFFERS;
pkt->session_id = hash32_ptr(session);
pkt->session_id = inst->sess_id;
pkt->buf_type.iova = iova;
pkt->buf_type.size = size;
pkt->size = sizeof(struct cvp_hfi_cmd_session_set_buffers_packet);
@ -324,13 +327,14 @@ int cvp_create_pkt_cmd_session_release_buffers(
struct cvp_hal_session *session)
{
struct cvp_session_release_buffers_packet *pkt;
struct msm_cvp_inst *inst = session->session_id;
if (!cmd || !session)
if (!cmd || !session || !inst)
return -EINVAL;
pkt = (struct cvp_session_release_buffers_packet *)cmd;
pkt->packet_type = HFI_CMD_SESSION_CVP_RELEASE_BUFFERS;
pkt->session_id = hash32_ptr(session);
pkt->session_id = inst->sess_id;
pkt->num_buffers = 1;
pkt->buffer_type = 0;
pkt->size = sizeof(struct cvp_session_release_buffers_packet) +
@ -347,6 +351,7 @@ int cvp_create_pkt_cmd_session_send(
int def_idx;
struct cvp_hal_session_cmd_pkt *ptr =
(struct cvp_hal_session_cmd_pkt *)in_pkt;
struct msm_cvp_inst *inst = session->session_id;
if (!out_pkt || !in_pkt || !session)
return -EINVAL;
@ -354,7 +359,7 @@ int cvp_create_pkt_cmd_session_send(
if (ptr->size > MAX_HFI_PKT_SIZE * sizeof(unsigned int))
goto error_hfi_packet;
if (ptr->session_id != hash32_ptr(session))
if (ptr->session_id != inst->sess_id)
goto error_hfi_packet;
def_idx = get_pkt_index(ptr);

View file

@ -1,7 +1,7 @@
// SPDX-License-Identifier: GPL-2.0-only
/*
* Copyright (c) 2018-2021, The Linux Foundation. All rights reserved.
* Copyright (c) 2022-2024, Qualcomm Innovation Center, Inc. All rights reserved.
* Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
*/
#include <linux/bitops.h>
@ -462,7 +462,7 @@ static struct msm_cvp_inst *cvp_get_inst_from_id(struct msm_cvp_core *core,
retry:
if (mutex_trylock(&core->lock)) {
list_for_each_entry(inst, &core->instances, list) {
if (hash32_ptr(inst->session) == session_id) {
if (inst->sess_id == session_id) {
match = true;
break;
}

View file

@ -1,6 +1,7 @@
// SPDX-License-Identifier: GPL-2.0-only
/*
* Copyright (c) 2018-2021, The Linux Foundation. All rights reserved.
* Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
*/
#include "msm_cvp.h"
@ -14,6 +15,47 @@ struct cvp_power_level {
unsigned long bw_sum;
};
void *get_sessObj_from_idr(struct msm_cvp_inst *inst)
{
void *sessObj = NULL;
struct msm_cvp_core *core = NULL;
if (!inst || !inst->core) {
dprintk(CVP_ERR, "%s: invalid params\n", __func__);
return NULL;
}
core = inst->core;
mutex_lock(&core->idr_mtx);
sessObj = idr_find(&core->sess_idr, inst->sess_id);
mutex_unlock(&core->idr_mtx);
if (!sessObj)
dprintk(CVP_ERR, "%s: Could not find the sess obj for given idr id\n",
__func__);
return sessObj;
}
u32 get_sessId_from_idr(void *session)
{
void *ptr = NULL;
u32 sess_id = -1;
struct msm_cvp_core *core = NULL;
core = list_first_entry(&cvp_driver->cores, struct msm_cvp_core, list);
if (!session || !core)
return -EINVAL;
mutex_lock(&core->idr_mtx);
idr_for_each_entry(&core->sess_idr, ptr, sess_id) {
if (ptr == session) {
mutex_unlock(&core->idr_mtx);
return sess_id;
}
}
mutex_unlock(&core->idr_mtx);
return sess_id;
}
static int msm_cvp_get_session_info(struct msm_cvp_inst *inst,
struct cvp_kmd_session_info *session)
{
@ -30,7 +72,7 @@ static int msm_cvp_get_session_info(struct msm_cvp_inst *inst,
return -ECONNRESET;
s->cur_cmd_type = CVP_KMD_GET_SESSION_INFO;
session->session_id = hash32_ptr(inst->session);
session->session_id = inst->sess_id;
dprintk(CVP_SESS, "%s: id 0x%x\n", __func__, session->session_id);
s->cur_cmd_type = 0;
@ -1227,7 +1269,7 @@ static int msm_cvp_session_stop(struct msm_cvp_inst *inst,
sq->state = QUEUE_STOP;
pr_info(CVP_DBG_TAG "Stop session: %pK session_id = %d\n",
"sess", inst, hash32_ptr(inst->session));
"sess", inst, inst->sess_id);
spin_unlock(&sq->lock);
wake_up_all(&inst->session_queue.wq);
@ -1251,7 +1293,7 @@ int msm_cvp_session_queue_stop(struct msm_cvp_inst *inst)
sq->state = QUEUE_STOP;
dprintk(CVP_SESS, "Stop session queue: %pK session_id = %d\n",
inst, hash32_ptr(inst->session));
inst, inst->sess_id);
spin_unlock(&sq->lock);
wake_up_all(&inst->session_queue.wq);
@ -1551,7 +1593,7 @@ static void cvp_clean_fence_queue(struct msm_cvp_inst *inst, int synx_state)
ktid = f->pkt->client_data.kdata & (FENCE_BIT - 1);
dprintk(CVP_SYNX, "%s: (%#x) flush frame %llu %llu wait_list\n",
__func__, hash32_ptr(inst->session), ktid, f->frame_id);
__func__, inst->sess_id, ktid, f->frame_id);
list_del_init(&f->list);
msm_cvp_unmap_frame(inst, f->pkt->client_data.kdata);
@ -1564,7 +1606,7 @@ static void cvp_clean_fence_queue(struct msm_cvp_inst *inst, int synx_state)
ktid = f->pkt->client_data.kdata & (FENCE_BIT - 1);
dprintk(CVP_SYNX, "%s: (%#x)flush frame %llu %llu sched_list\n",
__func__, hash32_ptr(inst->session), ktid, f->frame_id);
__func__, inst->sess_id, ktid, f->frame_id);
cvp_cancel_synx(inst, CVP_INPUT_SYNX, f, synx_state);
}
@ -1612,14 +1654,14 @@ static int cvp_flush_all(struct msm_cvp_inst *inst)
return -ECONNRESET;
dprintk(CVP_SESS, "session %llx (%#x)flush all starts\n",
inst, hash32_ptr(inst->session));
inst, inst->sess_id);
q = &inst->fence_cmd_queue;
hdev = inst->core->device;
cvp_clean_fence_queue(inst, SYNX_STATE_SIGNALED_CANCEL);
dprintk(CVP_SESS, "%s: (%#x) send flush to fw\n",
__func__, hash32_ptr(inst->session));
__func__, inst->sess_id);
/* Send flush to FW */
rc = call_hfi_op(hdev, session_flush, (void *)inst->session);
@ -1636,7 +1678,7 @@ static int cvp_flush_all(struct msm_cvp_inst *inst)
__func__, rc);
dprintk(CVP_SESS, "%s: (%#x) received flush from fw\n",
__func__, hash32_ptr(inst->session));
__func__, inst->sess_id);
exit:
rc = cvp_drain_fence_sched_list(inst);
@ -1859,10 +1901,10 @@ int msm_cvp_session_deinit(struct msm_cvp_inst *inst)
return -EINVAL;
}
dprintk(CVP_SESS, "%s: inst %pK (%#x)\n", __func__,
inst, hash32_ptr(inst->session));
inst, inst->sess_id);
session = (struct cvp_hal_session *)inst->session;
if (!session)
session = (struct cvp_hal_session *)get_sessObj_from_idr(inst);
if (!session || session != inst->session)
return rc;
rc = msm_cvp_comm_try_state(inst, MSM_CVP_CLOSE_DONE);
@ -1883,7 +1925,7 @@ int msm_cvp_session_init(struct msm_cvp_inst *inst)
}
dprintk(CVP_SESS, "%s: inst %pK (%#x)\n", __func__,
inst, hash32_ptr(inst->session));
inst, inst->sess_id);
/* set default frequency */
inst->clk_data.core_id = 0;

View file

@ -1,6 +1,7 @@
/* SPDX-License-Identifier: GPL-2.0-only */
/*
* Copyright (c) 2018-2020, The Linux Foundation. All rights reserved.
* Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
*/
#ifndef _MSM_CVP_H_
@ -34,4 +35,6 @@ int msm_cvp_session_init(struct msm_cvp_inst *inst);
int msm_cvp_session_deinit(struct msm_cvp_inst *inst);
int msm_cvp_session_queue_stop(struct msm_cvp_inst *inst);
int cvp_stop_clean_fence_queue(struct msm_cvp_inst *inst);
void *get_sessObj_from_idr(struct msm_cvp_inst *inst);
u32 get_sessId_from_idr(void *session);
#endif

View file

@ -1,7 +1,7 @@
// SPDX-License-Identifier: GPL-2.0-only
/*
* Copyright (c) 2020, The Linux Foundation. All rights reserved.
* Copyright (c) 2024 Qualcomm Innovation Center, Inc. All rights reserved.
* Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
*/
#include "msm_cvp_common.h"
@ -14,7 +14,7 @@
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->sess_id, smem->bitmap_index, \
inst->dma_cache.usage_bitmap); \
} while (0)
@ -22,7 +22,7 @@
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->sess_id, idx, \
inst->dma_cache.usage_bitmap); \
} while (0)
@ -36,7 +36,7 @@ void print_smem(u32 tag, const char *str, struct msm_cvp_inst *inst,
if (smem->dma_buf) {
dprintk(tag,
"%s: %x : %s size %d flags %#x iova %#x idx %d ref %d",
str, hash32_ptr(inst->session), smem->dma_buf->name,
str, inst->sess_id, smem->dma_buf->name,
smem->size, smem->flags, smem->device_addr,
smem->bitmap_index, smem->refcount);
}
@ -51,13 +51,13 @@ static void print_internal_buffer(u32 tag, const char *str,
if (cbuf->smem->dma_buf) {
dprintk(tag,
"%s: %x : fd %d off %d %s size %d iova %#x",
str, hash32_ptr(inst->session), cbuf->fd,
str, inst->sess_id, cbuf->fd,
cbuf->offset, cbuf->smem->dma_buf->name, cbuf->size,
cbuf->smem->device_addr);
} else {
dprintk(tag,
"%s: %x : idx %2d fd %d off %d size %d iova %#x",
str, hash32_ptr(inst->session), cbuf->fd,
str, inst->sess_id, cbuf->fd,
cbuf->offset, cbuf->size, cbuf->smem->device_addr);
}
}
@ -77,7 +77,7 @@ void print_client_buffer(u32 tag, const char *str,
dprintk(tag,
"%s: %x : idx %2d fd %d off %d size %d type %d flags 0x%x\n",
str, hash32_ptr(inst->session), cbuf->index, cbuf->fd,
str, inst->sess_id, cbuf->index, cbuf->fd,
cbuf->offset, cbuf->size, cbuf->type, cbuf->flags);
}
@ -154,7 +154,7 @@ int msm_cvp_map_buf_dsp(struct msm_cvp_inst *inst, struct cvp_kmd_buffer *buf)
}
if (buf->index) {
rc = cvp_dsp_register_buffer(hash32_ptr(session), buf->fd,
rc = cvp_dsp_register_buffer(inst->sess_id, buf->fd,
smem->dma_buf->size, buf->size, buf->offset,
buf->index, (uint32_t)smem->device_addr);
if (rc) {
@ -227,7 +227,7 @@ int msm_cvp_unmap_buf_dsp(struct msm_cvp_inst *inst, struct cvp_kmd_buffer *buf)
}
if (buf->index) {
rc = cvp_dsp_deregister_buffer(hash32_ptr(session), buf->fd,
rc = cvp_dsp_deregister_buffer(inst->sess_id, buf->fd,
cbuf->smem->dma_buf->size, buf->size, buf->offset,
buf->index, (uint32_t)cbuf->smem->device_addr);
if (rc) {
@ -545,7 +545,7 @@ void msm_cvp_unmap_frame(struct msm_cvp_inst *inst, u64 ktid)
ktid &= (FENCE_BIT - 1);
dprintk(CVP_MEM, "%s: (%#x) unmap frame %llu\n",
__func__, hash32_ptr(inst->session), ktid);
__func__, inst->sess_id, ktid);
found = false;
mutex_lock(&inst->frames.lock);
@ -587,7 +587,7 @@ int msm_cvp_unmap_user_persist(struct msm_cvp_inst *inst,
smem = pbuf->smem;
dprintk(CVP_MEM, "unmap persist: %x %d %d %#x",
hash32_ptr(inst->session), pbuf->fd,
inst->sess_id, pbuf->fd,
pbuf->size, smem->device_addr);
if (smem->bitmap_index >= MAX_DMABUF_NUMS) {
@ -785,7 +785,7 @@ int msm_cvp_session_deinit_buffers(struct msm_cvp_inst *inst)
list_for_each_entry_safe(cbuf, dummy, &inst->cvpdspbufs.list,
list) {
print_internal_buffer(CVP_MEM, "remove dspbufs", inst, cbuf);
rc = cvp_dsp_deregister_buffer(hash32_ptr(session),
rc = cvp_dsp_deregister_buffer(inst->sess_id,
cbuf->fd, cbuf->smem->dma_buf->size, cbuf->size,
cbuf->offset, cbuf->index,
(uint32_t)cbuf->smem->device_addr);
@ -955,7 +955,7 @@ int cvp_release_arp_buffers(struct msm_cvp_inst *inst)
if (buf->ownership == DRIVER) {
dprintk(CVP_MEM,
"%s: %x : fd %d %s size %d",
"free arp", hash32_ptr(inst->session), buf->fd,
"free arp", inst->sess_id, buf->fd,
smem->dma_buf->name, buf->size);
msm_cvp_smem_free(smem);
kmem_cache_free(cvp_driver->smem_cache, smem);

View file

@ -1,6 +1,7 @@
// SPDX-License-Identifier: GPL-2.0-only
/*
* Copyright (c) 2018-2021, The Linux Foundation. All rights reserved.
* Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
*/
#include <linux/jiffies.h>
@ -195,23 +196,31 @@ struct msm_cvp_inst *cvp_get_inst_validate(struct msm_cvp_core *core,
{
int rc = 0;
struct cvp_hfi_device *hdev;
struct msm_cvp_inst *s;
struct msm_cvp_inst *inst;
void *sessObj = NULL;
s = cvp_get_inst(core, session_id);
if (!s) {
dprintk(CVP_ERR, "%s session doesn't exit\n",
inst = cvp_get_inst(core, session_id);
if (!inst) {
dprintk(CVP_ERR, "%s Inst doesn't exit\n",
__builtin_return_address(0));
return NULL;
}
hdev = s->core->device;
rc = call_hfi_op(hdev, validate_session, s->session, __func__);
if (rc) {
cvp_put_inst(s);
s = NULL;
sessObj = get_sessObj_from_idr(inst);
if (!sessObj || sessObj != inst->session) {
dprintk(CVP_ERR,
"Either sessionObj is null or not matching with inst->session\n");
return NULL;
}
return s;
hdev = inst->core->device;
rc = call_hfi_op(hdev, validate_session, sessObj, __func__);
if (rc) {
cvp_put_inst(inst);
inst = NULL;
}
return inst;
}
static void cvp_handle_session_cmd_done(enum hal_command_response cmd,
@ -486,7 +495,7 @@ static void handle_session_init_done(enum hal_command_response cmd, void *data)
}
dprintk(CVP_SESS, "%s: cvp session %#x\n", __func__,
hash32_ptr(inst->session));
inst->sess_id);
signal_session_msg_receipt(cmd, inst);
cvp_put_inst(inst);
@ -568,7 +577,7 @@ static void handle_session_error(enum hal_command_response cmd, void *data)
hdev = inst->core->device;
dprintk(CVP_ERR, "Session error received for inst %pK session %x\n",
inst, hash32_ptr(inst->session));
inst, inst->sess_id);
if (response->status == CVP_ERR_MAX_CLIENTS) {
dprintk(CVP_WARN, "Too many clients, rejecting %pK", inst);
@ -901,7 +910,7 @@ static int msm_comm_session_abort(struct msm_cvp_inst *inst)
abort_completion = SESSION_MSG_INDEX(HAL_SESSION_ABORT_DONE);
dprintk(CVP_WARN, "%s: inst %pK session %x\n", __func__,
inst, hash32_ptr(inst->session));
inst, inst->sess_id);
rc = call_hfi_op(hdev, session_abort, (void *)inst->session);
if (rc) {
dprintk(CVP_ERR,
@ -914,7 +923,7 @@ static int msm_comm_session_abort(struct msm_cvp_inst *inst)
inst->core->resources.msm_cvp_hw_rsp_timeout));
if (!rc) {
dprintk(CVP_ERR, "%s: inst %pK session %x abort timed out\n",
__func__, inst, hash32_ptr(inst->session));
__func__, inst, inst->sess_id);
call_hfi_op(hdev, flush_debug_queue, hdev->hfi_device_data);
dump_hfi_queue(hdev->hfi_device_data);
msm_cvp_comm_generate_sys_error(inst);
@ -1268,7 +1277,7 @@ int msm_cvp_comm_try_state(struct msm_cvp_inst *inst, int state)
}
dprintk(CVP_SESS,
"Trying to move inst: %pK (%#x) from: %#x to %#x\n",
inst, hash32_ptr(inst->session), inst->state, state);
inst, inst->sess_id, inst->state, state);
mutex_lock(&inst->sync_lock);
if (inst->state == MSM_CVP_CORE_INVALID) {
@ -1281,7 +1290,7 @@ int msm_cvp_comm_try_state(struct msm_cvp_inst *inst, int state)
flipped_state = get_flipped_state(inst->state, state);
dprintk(CVP_SESS,
"inst: %pK (%#x) flipped_state = %#x %x\n",
inst, hash32_ptr(inst->session), flipped_state, state);
inst, inst->sess_id, flipped_state, state);
switch (flipped_state) {
case MSM_CVP_CORE_UNINIT_DONE:
case MSM_CVP_CORE_INIT:
@ -1491,7 +1500,7 @@ int msm_cvp_comm_kill_session(struct msm_cvp_inst *inst)
return 0;
}
dprintk(CVP_WARN, "%s: inst %pK, session %x state %d\n", __func__,
inst, hash32_ptr(inst->session), inst->state);
inst, inst->sess_id, inst->state);
/*
* We're internally forcibly killing the session, if fw is aware of
* the session send session_abort to firmware to clean up and release
@ -1503,7 +1512,7 @@ int msm_cvp_comm_kill_session(struct msm_cvp_inst *inst)
if (rc) {
dprintk(CVP_ERR,
"%s: inst %pK session %x abort failed\n",
__func__, inst, hash32_ptr(inst->session));
__func__, inst, inst->sess_id);
change_cvp_inst_state(inst, MSM_CVP_CORE_INVALID);
} else {
change_cvp_inst_state(inst, MSM_CVP_CORE_UNINIT);

View file

@ -1,6 +1,7 @@
// SPDX-License-Identifier: GPL-2.0-only
/*
* Copyright (c) 2018-2020, The Linux Foundation. All rights reserved.
* Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
*/
#include <linux/dma-direction.h>
@ -165,7 +166,7 @@ void *msm_cvp_open(int core_id, int session_type)
list_for_each_entry(inst, &core->instances, list)
dprintk(CVP_ERR, "inst %pK, cmd %d id %d\n",
inst, inst->cur_cmd_type,
hash32_ptr(inst->session));
inst->sess_id);
mutex_unlock(&core->lock);
return NULL;
@ -369,7 +370,7 @@ int msm_cvp_destroy(struct msm_cvp_inst *inst)
synx_uninitialize(inst->synx_session_id);
pr_info(CVP_DBG_TAG "Closed cvp instance: %pK session_id = %d\n",
"sess", inst, hash32_ptr(inst->session));
"sess", inst, inst->sess_id);
if (inst->cur_cmd_type)
dprintk(CVP_ERR, "deleted instance has pending cmd %d\n",
inst->cur_cmd_type);

View file

@ -1,6 +1,7 @@
/* SPDX-License-Identifier: GPL-2.0-only */
/*
* Copyright (c) 2018-2020, The Linux Foundation. All rights reserved.
* Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
*/
#ifndef _MSM_CVP_INTERNAL_H_
@ -290,6 +291,8 @@ struct msm_cvp_core {
unsigned long curr_freq;
struct cvp_cycle_info dyn_clk;
atomic64_t kernel_trans_id;
struct idr sess_idr;
struct mutex idr_mtx;
};
struct msm_cvp_inst {
@ -301,6 +304,7 @@ struct msm_cvp_inst {
struct cvp_session_queue session_queue_fence;
struct cvp_session_event event_handler;
void *session;
u32 sess_id;
enum instance_state state;
struct msm_cvp_list freqs;
struct msm_cvp_list persistbufs;

View file

@ -1,6 +1,7 @@
// SPDX-License-Identifier: GPL-2.0-only
/*
* Copyright (c) 2020, The Linux Foundation. All rights reserved.
* Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
*/
#include "msm_cvp_common.h"
@ -20,7 +21,7 @@ void cvp_dump_fence_queue(struct msm_cvp_inst *inst)
ssid = inst->synx_session_id;
mutex_lock(&q->lock);
dprintk(CVP_WARN, "inst %x fence q mode %d, ssid %d\n",
hash32_ptr(inst->session), q->mode, ssid.client_id);
inst->sess_id, q->mode, ssid.client_id);
dprintk(CVP_WARN, "fence cmdq wait list:\n");
list_for_each_entry(f, &q->wait_list, list) {