Skip to content

Commit

Permalink
Merge tag 'LA.UM.9.1.r1-13900-SMxxx0.QSSI13.0' of msm-4.14 into thirteen
Browse files Browse the repository at this point in the history
"LA.UM.9.1.r1-13900-SMxxx0.QSSI13.0"
  • Loading branch information
tejas101k committed Aug 31, 2023
2 parents 31612b2 + 696b4a4 commit 71c2e3c
Show file tree
Hide file tree
Showing 11 changed files with 379 additions and 134 deletions.
6 changes: 6 additions & 0 deletions drivers/bus/mhi/core/mhi_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -809,6 +809,12 @@ static inline void mhi_trigger_resume(struct mhi_controller *mhi_cntrl)
pm_wakeup_event(&mhi_cntrl->mhi_dev->dev, 0);
}

static inline bool is_valid_ring_ptr(struct mhi_ring *ring, dma_addr_t addr)
{
return ((addr >= ring->iommu_base &&
addr < ring->iommu_base + ring->len) && (addr % 16 == 0));
}

/* queue transfer buffer */
int mhi_gen_tre(struct mhi_controller *mhi_cntrl, struct mhi_chan *mhi_chan,
void *buf, void *cb, size_t buf_len, enum MHI_FLAGS flags);
Expand Down
16 changes: 15 additions & 1 deletion drivers/bus/mhi/core/mhi_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -1358,6 +1358,13 @@ int mhi_process_tsync_ev_ring(struct mhi_controller *mhi_cntrl,
int ret = 0;

spin_lock_bh(&mhi_event->lock);
if (!is_valid_ring_ptr(ev_ring, er_ctxt->rp)) {
MHI_ERR(
"Event ring rp points outside of the event ring or unalign rp %llx\n",
er_ctxt->rp);
spin_unlock_bh(&mhi_event->lock);
return 0;
}
dev_rp = mhi_to_virtual(ev_ring, er_ctxt->rp);
if (ev_ring->rp == dev_rp) {
spin_unlock_bh(&mhi_event->lock);
Expand Down Expand Up @@ -1450,8 +1457,15 @@ int mhi_process_bw_scale_ev_ring(struct mhi_controller *mhi_cntrl,
int result, ret = 0;

spin_lock_bh(&mhi_event->lock);
dev_rp = mhi_to_virtual(ev_ring, er_ctxt->rp);
if (!is_valid_ring_ptr(ev_ring, er_ctxt->rp)) {
MHI_ERR(
"Event ring rp points outside of the event ring or unalign rp %llx\n",
er_ctxt->rp);
spin_unlock_bh(&mhi_event->lock);
return 0;
}

dev_rp = mhi_to_virtual(ev_ring, er_ctxt->rp);
if (ev_ring->rp == dev_rp) {
spin_unlock_bh(&mhi_event->lock);
goto exit_bw_scale_process;
Expand Down
2 changes: 2 additions & 0 deletions drivers/crypto/msm/qcedev.c
Original file line number Diff line number Diff line change
Expand Up @@ -2162,8 +2162,10 @@ static int qcedev_remove(struct platform_device *pdev)
if (msm_bus_scale_client_update_request(podev->bus_scale_handle, 1))
pr_err("%s Unable to set high bandwidth\n", __func__);

qcedev_ce_high_bw_req(podev, true);
if (podev->qce)
qce_close(podev->qce);
qcedev_ce_high_bw_req(podev, false);

if (msm_bus_scale_client_update_request(podev->bus_scale_handle, 0))
pr_err("%s Unable to set low bandwidth\n", __func__);
Expand Down
20 changes: 7 additions & 13 deletions drivers/media/platform/msm/ais/cam_req_mgr/cam_mem_mgr.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/* Copyright (c) 2016-2021, The Linux Foundation. All rights reserved.
* Copyright (c) 2022-2023 Qualcomm Innovation Center, Inc. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 and
Expand Down Expand Up @@ -476,7 +477,6 @@ static int cam_mem_util_get_dma_buf_fd(size_t len,
struct dma_buf **buf,
int *fd)
{
struct dma_buf *dmabuf = NULL;
int rc = 0;

if (!buf || !fd) {
Expand All @@ -487,25 +487,19 @@ static int cam_mem_util_get_dma_buf_fd(size_t len,
*buf = ion_alloc(len, heap_id_mask, flags);
if (IS_ERR_OR_NULL(*buf))
return -ENOMEM;

*fd = dma_buf_fd(*buf, O_CLOEXEC);
if (*fd < 0) {
CAM_ERR(CAM_MEM, "get fd fail, *fd=%d", *fd);
rc = -EINVAL;
goto get_fd_fail;
}

/*
* increment the ref count so that ref count becomes 2 here
* when we close fd, refcount becomes 1 and when we do
* dmap_put_buf, ref count becomes 0 and memory will be freed.
*/
dmabuf = dma_buf_get(*fd);
if (IS_ERR_OR_NULL(dmabuf)) {
CAM_ERR(CAM_MEM, "dma_buf_get failed, *fd=%d", *fd);
get_dma_buf(*buf);

*fd = dma_buf_fd(*buf, O_CLOEXEC);
if (*fd < 0) {
CAM_ERR(CAM_MEM, "get fd fail, *fd=%d", *fd);
rc = -EINVAL;
goto get_fd_fail;
}

return rc;

get_fd_fail:
Expand Down
62 changes: 25 additions & 37 deletions drivers/media/platform/msm/ais/cam_req_mgr/cam_req_mgr_core.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* Copyright (c) 2016-2020, The Linux Foundation. All rights reserved.
* Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved.
* Copyright (c) 2022-2023 Qualcomm Innovation Center, Inc. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 and
Expand Down Expand Up @@ -2405,8 +2405,7 @@ static int cam_req_mgr_cb_add_req(struct cam_req_mgr_add_request *add_req)
return -EINVAL;
}

link = (struct cam_req_mgr_core_link *)
cam_get_device_priv(add_req->link_hdl);
link = cam_get_link_priv(add_req->link_hdl);

if (!link) {
CAM_DBG(CAM_CRM, "link ptr NULL %x", add_req->link_hdl);
Expand Down Expand Up @@ -2484,8 +2483,7 @@ static int cam_req_mgr_cb_notify_err(
goto end;
}

link = (struct cam_req_mgr_core_link *)
cam_get_device_priv(err_info->link_hdl);
link = cam_get_link_priv(err_info->link_hdl);
if (!link) {
CAM_DBG(CAM_CRM, "link ptr NULL %x", err_info->link_hdl);
rc = -EINVAL;
Expand Down Expand Up @@ -2547,8 +2545,7 @@ static int cam_req_mgr_cb_notify_trigger(
goto end;
}

link = (struct cam_req_mgr_core_link *)
cam_get_device_priv(trigger_data->link_hdl);
link = cam_get_link_priv(trigger_data->link_hdl);
if (!link) {
CAM_DBG(CAM_CRM, "link ptr NULL %x", trigger_data->link_hdl);
rc = -EINVAL;
Expand Down Expand Up @@ -2860,7 +2857,7 @@ static int __cam_req_mgr_unlink(struct cam_req_mgr_core_link *link)
__cam_req_mgr_destroy_subdev(&link->l_dev);

/* Destroy the link handle */
rc = cam_destroy_device_hdl(link->link_hdl);
rc = cam_destroy_link_hdl(link->link_hdl);
if (rc < 0) {
CAM_ERR(CAM_CRM, "error destroying link hdl %x rc %d",
link->link_hdl, rc);
Expand All @@ -2885,8 +2882,7 @@ int cam_req_mgr_destroy_session(
}

mutex_lock(&g_crm_core_dev->crm_lock);
cam_session = (struct cam_req_mgr_core_session *)
cam_get_device_priv(ses_info->session_hdl);
cam_session = cam_get_session_priv(ses_info->session_hdl);
if (!cam_session) {
CAM_ERR(CAM_CRM, "failed to get session priv");
rc = -ENOENT;
Expand Down Expand Up @@ -2945,8 +2941,8 @@ int cam_req_mgr_link(struct cam_req_mgr_ver_info *link_info)
mutex_lock(&g_crm_core_dev->crm_lock);

/* session hdl's priv data is cam session struct */
cam_session = (struct cam_req_mgr_core_session *)
cam_get_device_priv(link_info->u.link_info_v1.session_hdl);
cam_session = cam_get_session_priv(
link_info->u.link_info_v1.session_hdl);
if (!cam_session) {
CAM_DBG(CAM_CRM, "NULL pointer");
mutex_unlock(&g_crm_core_dev->crm_lock);
Expand All @@ -2968,7 +2964,7 @@ int cam_req_mgr_link(struct cam_req_mgr_ver_info *link_info)
root_dev.dev_id = CAM_CRM;
mutex_lock(&link->lock);
/* Create unique dev handle for link */
link->link_hdl = cam_create_device_hdl(&root_dev);
link->link_hdl = cam_create_link_hdl(&root_dev);
if (link->link_hdl < 0) {
CAM_ERR(CAM_CRM,
"Insufficient memory to create new device handle");
Expand Down Expand Up @@ -3022,7 +3018,7 @@ int cam_req_mgr_link(struct cam_req_mgr_ver_info *link_info)
setup_failed:
__cam_req_mgr_destroy_subdev(&link->l_dev);
create_subdev_failed:
cam_destroy_device_hdl(link->link_hdl);
cam_destroy_link_hdl(link->link_hdl);
link_info->u.link_info_v1.link_hdl = -1;
link_hdl_fail:
mutex_unlock(&link->lock);
Expand Down Expand Up @@ -3054,8 +3050,8 @@ int cam_req_mgr_link_v2(struct cam_req_mgr_ver_info *link_info)
mutex_lock(&g_crm_core_dev->crm_lock);

/* session hdl's priv data is cam session struct */
cam_session = (struct cam_req_mgr_core_session *)
cam_get_device_priv(link_info->u.link_info_v2.session_hdl);
cam_session = cam_get_session_priv(
link_info->u.link_info_v2.session_hdl);
if (!cam_session) {
CAM_DBG(CAM_CRM, "NULL pointer");
mutex_unlock(&g_crm_core_dev->crm_lock);
Expand All @@ -3077,7 +3073,7 @@ int cam_req_mgr_link_v2(struct cam_req_mgr_ver_info *link_info)

mutex_lock(&link->lock);
/* Create unique dev handle for link */
link->link_hdl = cam_create_device_hdl(&root_dev);
link->link_hdl = cam_create_link_hdl(&root_dev);
if (link->link_hdl < 0) {
CAM_ERR(CAM_CRM,
"Insufficient memory to create new device handle");
Expand Down Expand Up @@ -3131,7 +3127,7 @@ int cam_req_mgr_link_v2(struct cam_req_mgr_ver_info *link_info)
setup_failed:
__cam_req_mgr_destroy_subdev(&link->l_dev);
create_subdev_failed:
cam_destroy_device_hdl(link->link_hdl);
cam_destroy_link_hdl(link->link_hdl);
link_info->u.link_info_v2.link_hdl = -1;
link_hdl_fail:
mutex_unlock(&link->lock);
Expand All @@ -3156,16 +3152,15 @@ int cam_req_mgr_unlink(struct cam_req_mgr_unlink_info *unlink_info)
CAM_DBG(CAM_CRM, "link_hdl %x", unlink_info->link_hdl);

/* session hdl's priv data is cam session struct */
cam_session = (struct cam_req_mgr_core_session *)
cam_get_device_priv(unlink_info->session_hdl);
cam_session = cam_get_session_priv(unlink_info->session_hdl);
if (!cam_session) {
CAM_ERR(CAM_CRM, "NULL pointer");
mutex_unlock(&g_crm_core_dev->crm_lock);
return -EINVAL;
}

/* link hdl's priv data is core_link struct */
link = cam_get_device_priv(unlink_info->link_hdl);
link = cam_get_link_priv(unlink_info->link_hdl);
if (!link) {
CAM_ERR(CAM_CRM, "NULL pointer");
rc = -EINVAL;
Expand Down Expand Up @@ -3197,8 +3192,7 @@ int cam_req_mgr_schedule_request(
}

mutex_lock(&g_crm_core_dev->crm_lock);
link = (struct cam_req_mgr_core_link *)
cam_get_device_priv(sched_req->link_hdl);
link = cam_get_link_priv(sched_req->link_hdl);
if (!link) {
CAM_DBG(CAM_CRM, "link ptr NULL %x", sched_req->link_hdl);
rc = -EINVAL;
Expand Down Expand Up @@ -3308,8 +3302,7 @@ int cam_req_mgr_sync_config(

mutex_lock(&g_crm_core_dev->crm_lock);
/* session hdl's priv data is cam session struct */
cam_session = (struct cam_req_mgr_core_session *)
cam_get_device_priv(sync_info->session_hdl);
cam_session = cam_get_session_priv(sync_info->session_hdl);
if (!cam_session) {
CAM_ERR(CAM_CRM, "NULL pointer");
mutex_unlock(&g_crm_core_dev->crm_lock);
Expand All @@ -3322,14 +3315,14 @@ int cam_req_mgr_sync_config(
sync_info->link_hdls[0], sync_info->link_hdls[1]);

/* only two links existing per session in dual cam use case*/
link1 = cam_get_device_priv(sync_info->link_hdls[0]);
link1 = cam_get_link_priv(sync_info->link_hdls[0]);
if (!link1) {
CAM_ERR(CAM_CRM, "link1 NULL pointer");
rc = -EINVAL;
goto done;
}

link2 = cam_get_device_priv(sync_info->link_hdls[1]);
link2 = cam_get_link_priv(sync_info->link_hdls[1]);
if (!link2) {
CAM_ERR(CAM_CRM, "link2 NULL pointer");
rc = -EINVAL;
Expand Down Expand Up @@ -3401,8 +3394,7 @@ int cam_req_mgr_flush_requests(

mutex_lock(&g_crm_core_dev->crm_lock);
/* session hdl's priv data is cam session struct */
session = (struct cam_req_mgr_core_session *)
cam_get_device_priv(flush_info->session_hdl);
session = cam_get_session_priv(flush_info->session_hdl);
if (!session) {
CAM_ERR(CAM_CRM, "Invalid session %x", flush_info->session_hdl);
rc = -EINVAL;
Expand All @@ -3414,8 +3406,7 @@ int cam_req_mgr_flush_requests(
goto end;
}

link = (struct cam_req_mgr_core_link *)
cam_get_device_priv(flush_info->link_hdl);
link = cam_get_link_priv(flush_info->link_hdl);
if (!link) {
CAM_DBG(CAM_CRM, "link ptr NULL %x", flush_info->link_hdl);
rc = -EINVAL;
Expand Down Expand Up @@ -3483,8 +3474,7 @@ int cam_req_mgr_link_control(struct cam_req_mgr_link_control *control)

mutex_lock(&g_crm_core_dev->crm_lock);
for (i = 0; i < control->num_links; i++) {
link = (struct cam_req_mgr_core_link *)
cam_get_device_priv(control->link_hdls[i]);
link = cam_get_link_priv(control->link_hdls[i]);
if (!link) {
CAM_ERR(CAM_CRM, "Link(%d) is NULL on session 0x%x",
i, control->session_hdl);
Expand Down Expand Up @@ -3558,8 +3548,7 @@ int cam_req_mgr_dump_request(struct cam_dump_req_cmd *dump_req)

mutex_lock(&g_crm_core_dev->crm_lock);
/* session hdl's priv data is cam session struct */
session = (struct cam_req_mgr_core_session *)
cam_get_device_priv(dump_req->session_handle);
session = cam_get_session_priv(dump_req->session_handle);
if (!session) {
CAM_ERR(CAM_CRM, "Invalid session %x",
dump_req->session_handle);
Expand All @@ -3572,8 +3561,7 @@ int cam_req_mgr_dump_request(struct cam_dump_req_cmd *dump_req)
goto end;
}

link = (struct cam_req_mgr_core_link *)
cam_get_device_priv(dump_req->link_hdl);
link = cam_get_link_priv(dump_req->link_hdl);
if (!link) {
CAM_DBG(CAM_CRM, "link ptr NULL %x", dump_req->link_hdl);
rc = -EINVAL;
Expand Down
Loading

0 comments on commit 71c2e3c

Please sign in to comment.