Skip to content

Commit

Permalink
techpack: checkout main
Browse files Browse the repository at this point in the history
  • Loading branch information
lateautumn233 committed Mar 8, 2022
1 parent 0553640 commit c36b13a
Show file tree
Hide file tree
Showing 195 changed files with 3,260 additions and 15,260 deletions.
4 changes: 1 addition & 3 deletions techpack/camera/drivers/cam_cdm/cam_cdm.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* SPDX-License-Identifier: GPL-2.0-only */
/*
* Copyright (c) 2017-2020, The Linux Foundation. All rights reserved.
* Copyright (c) 2017-2019, The Linux Foundation. All rights reserved.
*/

#ifndef _CAM_CDM_H_
Expand Down Expand Up @@ -52,7 +52,6 @@ enum cam_cdm_hw_process_intf_cmd {
CAM_CDM_HW_INTF_CMD_RELEASE,
CAM_CDM_HW_INTF_CMD_SUBMIT_BL,
CAM_CDM_HW_INTF_CMD_RESET_HW,
CAM_CDM_HW_INTF_CMD_HANG_DETECT,
CAM_CDM_HW_INTF_CMD_INVALID,
};

Expand Down Expand Up @@ -218,7 +217,6 @@ struct cam_cdm {
atomic_t bl_done;
struct cam_cdm_hw_mem gen_irq;
uint32_t cpas_handle;
atomic_t work_record;
};

/* struct cam_cdm_private_dt_data - CDM hw custom dt data */
Expand Down
42 changes: 8 additions & 34 deletions techpack/camera/drivers/cam_cdm/cam_cdm_core_common.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: GPL-2.0-only
/*
* Copyright (c) 2017-2021, The Linux Foundation. All rights reserved.
* Copyright (c) 2017-2019, The Linux Foundation. All rights reserved.
*/

#include <linux/delay.h>
Expand Down Expand Up @@ -201,7 +201,6 @@ void cam_cdm_notify_clients(struct cam_hw_info *cdm_hw,

for (i = 0; i < CAM_PER_CDM_MAX_REGISTERED_CLIENTS; i++) {
if (core->clients[i] != NULL) {
mutex_lock(&cdm_hw->hw_mutex);
client = core->clients[i];
mutex_lock(&client->lock);
CAM_DBG(CAM_CDM, "Found client slot %d", i);
Expand All @@ -222,7 +221,6 @@ void cam_cdm_notify_clients(struct cam_hw_info *cdm_hw,
client->handle);
}
mutex_unlock(&client->lock);
mutex_unlock(&cdm_hw->hw_mutex);
}
}
}
Expand All @@ -241,34 +239,35 @@ int cam_cdm_stream_ops_internal(void *hw_priv,
return -EINVAL;

core = (struct cam_cdm *)cdm_hw->core_info;
mutex_lock(&cdm_hw->hw_mutex);
client_idx = CAM_CDM_GET_CLIENT_IDX(*handle);
client = core->clients[client_idx];
if (!client) {
CAM_ERR(CAM_CDM, "Invalid client %pK hdl=%x", client, *handle);
mutex_unlock(&cdm_hw->hw_mutex);
return -EINVAL;
}
cam_cdm_get_client_refcount(client);
if (*handle != client->handle) {
CAM_ERR(CAM_CDM, "client id given handle=%x invalid", *handle);
rc = -EINVAL;
goto end;
cam_cdm_put_client_refcount(client);
return -EINVAL;
}
if (operation == true) {
if (true == client->stream_on) {
CAM_ERR(CAM_CDM,
"Invalid CDM client is already streamed ON");
goto end;
cam_cdm_put_client_refcount(client);
return rc;
}
} else {
if (client->stream_on == false) {
CAM_ERR(CAM_CDM,
"Invalid CDM client is already streamed Off");
goto end;
cam_cdm_put_client_refcount(client);
return rc;
}
}

mutex_lock(&cdm_hw->hw_mutex);
if (operation == true) {
if (!cdm_hw->open_count) {
struct cam_ahb_vote ahb_vote;
Expand Down Expand Up @@ -580,31 +579,6 @@ int cam_cdm_process_cmd(void *hw_priv,
*((uint32_t *)cmd_args));
break;
}
case CAM_CDM_HW_INTF_CMD_HANG_DETECT: {
uint32_t *handle = cmd_args;
int idx;
struct cam_cdm_client *client;

if (sizeof(uint32_t) != arg_size) {
CAM_ERR(CAM_CDM,
"Invalid CDM cmd %d size=%x for handle=%x",
cmd, arg_size, *handle);
return -EINVAL;
}

idx = CAM_CDM_GET_CLIENT_IDX(*handle);
mutex_lock(&cdm_hw->hw_mutex);
client = core->clients[idx];
if ((!client) || (*handle != client->handle)) {
CAM_ERR(CAM_CDM, "Invalid client %pK hdl=%x",
client, *handle);
mutex_unlock(&cdm_hw->hw_mutex);
break;
}
rc = cam_hw_cdm_hang_detect(cdm_hw, *handle);
mutex_unlock(&cdm_hw->hw_mutex);
break;
}
default:
CAM_ERR(CAM_CDM, "CDM HW intf command not valid =%d", cmd);
break;
Expand Down
3 changes: 1 addition & 2 deletions techpack/camera/drivers/cam_cdm/cam_cdm_core_common.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* SPDX-License-Identifier: GPL-2.0-only */
/*
* Copyright (c) 2017-2020, The Linux Foundation. All rights reserved.
* Copyright (c) 2017-2019, The Linux Foundation. All rights reserved.
*/

#ifndef _CAM_CDM_CORE_COMMON_H_
Expand Down Expand Up @@ -37,7 +37,6 @@ int cam_virtual_cdm_submit_bl(struct cam_hw_info *cdm_hw,
int cam_hw_cdm_submit_bl(struct cam_hw_info *cdm_hw,
struct cam_cdm_hw_intf_cmd_submit_bl *req,
struct cam_cdm_client *client);
int cam_hw_cdm_hang_detect(struct cam_hw_info *cdm_hw, uint32_t handle);
struct cam_cdm_bl_cb_request_entry *cam_cdm_find_request_by_bl_tag(
uint32_t tag, struct list_head *bl_list);
void cam_cdm_notify_clients(struct cam_hw_info *cdm_hw,
Expand Down
45 changes: 6 additions & 39 deletions techpack/camera/drivers/cam_cdm/cam_cdm_hw_core.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: GPL-2.0-only
/*
* Copyright (c) 2017-2020, The Linux Foundation. All rights reserved.
* Copyright (c) 2017-2019, The Linux Foundation. All rights reserved.
*/

#include <linux/delay.h>
Expand All @@ -19,7 +19,6 @@
#include "cam_cdm_soc.h"
#include "cam_io_util.h"
#include "cam_hw_cdm170_reg.h"
#include "cam_trace.h"

#define CAM_HW_CDM_CPAS_0_NAME "qcom,cam170-cpas-cdm0"
#define CAM_HW_CDM_IPE_0_NAME "qcom,cam170-ipe0-cdm"
Expand Down Expand Up @@ -381,8 +380,6 @@ int cam_hw_cdm_submit_gen_irq(struct cam_hw_info *cdm_hw,
rc = -EIO;
}

trace_cam_log_event("CDM_START", "CDM_START_IRQ", req->data->cookie, 0);

end:
return rc;
}
Expand Down Expand Up @@ -563,10 +560,6 @@ static void cam_hw_cdm_work(struct work_struct *work)
CAM_DBG(CAM_CDM, "inline IRQ data=0x%x",
payload->irq_data);
mutex_lock(&cdm_hw->hw_mutex);

if (atomic_read(&core->work_record))
atomic_dec(&core->work_record);

list_for_each_entry_safe(node, tnode,
&core->bl_request_list, entry) {
if (node->request_type ==
Expand Down Expand Up @@ -672,12 +665,6 @@ irqreturn_t cam_hw_cdm_irq(int irq_num, void *data)
kfree(payload);
return IRQ_HANDLED;
}
if (cam_cdm_write_hw_reg(cdm_hw, CDM_IRQ_CLEAR,
payload->irq_status))
CAM_ERR(CAM_CDM, "Failed to Write CDM HW IRQ Clear");
if (cam_cdm_write_hw_reg(cdm_hw, CDM_IRQ_CLEAR_CMD, 0x01))
CAM_ERR(CAM_CDM, "Failed to Write CDM HW IRQ cmd");

if (payload->irq_status &
CAM_CDM_IRQ_STATUS_INFO_INLINE_IRQ_MASK) {
if (cam_cdm_read_hw_reg(cdm_hw, CDM_IRQ_USR_DATA,
Expand All @@ -686,16 +673,15 @@ irqreturn_t cam_hw_cdm_irq(int irq_num, void *data)
"Failed to read CDM HW IRQ data");
}
}
trace_cam_log_event("CDM_DONE", "CDM_DONE_IRQ",
payload->irq_status,
cdm_hw->soc_info.index);
CAM_DBG(CAM_CDM, "Got payload=%d", payload->irq_status);
payload->hw = cdm_hw;
INIT_WORK((struct work_struct *)&payload->work,
cam_hw_cdm_work);
if (payload->irq_status &
CAM_CDM_IRQ_STATUS_INFO_INLINE_IRQ_MASK)
atomic_inc(&cdm_core->work_record);
if (cam_cdm_write_hw_reg(cdm_hw, CDM_IRQ_CLEAR,
payload->irq_status))
CAM_ERR(CAM_CDM, "Failed to Write CDM HW IRQ Clear");
if (cam_cdm_write_hw_reg(cdm_hw, CDM_IRQ_CLEAR_CMD, 0x01))
CAM_ERR(CAM_CDM, "Failed to Write CDM HW IRQ cmd");
work_status = queue_work(cdm_core->work_queue, &payload->work);
if (work_status == false) {
CAM_ERR(CAM_CDM, "Failed to queue work for irq=0x%x",
Expand All @@ -707,22 +693,6 @@ irqreturn_t cam_hw_cdm_irq(int irq_num, void *data)
return IRQ_HANDLED;
}

int cam_hw_cdm_hang_detect(struct cam_hw_info *cdm_hw, uint32_t handle)
{
struct cam_cdm *cdm_core = NULL;
int rc = -1;

cdm_core = (struct cam_cdm *)cdm_hw->core_info;

if (atomic_read(&cdm_core->work_record)) {
CAM_WARN(CAM_CDM,
"workqueue got delayed, work_record :%u",
atomic_read(&cdm_core->work_record));
rc = 0;
}
return rc;
}

int cam_hw_cdm_alloc_genirq_mem(void *hw_priv)
{
struct cam_hw_info *cdm_hw = hw_priv;
Expand Down Expand Up @@ -798,7 +768,6 @@ int cam_hw_cdm_init(void *hw_priv,
CAM_DBG(CAM_CDM, "Enable soc done");

/* Before triggering the reset to HW, clear the reset complete */
atomic_set(&cdm_core->work_record, 0);
atomic_set(&cdm_core->error, 0);
atomic_set(&cdm_core->bl_done, 0);
reinit_completion(&cdm_core->reset_complete);
Expand Down Expand Up @@ -848,7 +817,6 @@ int cam_hw_cdm_deinit(void *hw_priv,

soc_info = &cdm_hw->soc_info;
cdm_core = cdm_hw->core_info;
atomic_set(&cdm_core->work_record, 0);
rc = cam_soc_util_disable_platform_resource(soc_info, true, true);
if (rc) {
CAM_ERR(CAM_CDM, "disable platform failed");
Expand Down Expand Up @@ -913,7 +881,6 @@ int cam_hw_cdm_probe(struct platform_device *pdev)
cdm_core->flags = CAM_CDM_FLAG_PRIVATE_CDM;

cdm_core->bl_tag = 0;
atomic_set(&cdm_core->work_record, 0);
cdm_core->id = cam_hw_cdm_get_id_by_name(cdm_core->name);
if (cdm_core->id >= CAM_CDM_MAX) {
CAM_ERR(CAM_CDM, "Failed to get CDM HW name for %s",
Expand Down
29 changes: 1 addition & 28 deletions techpack/camera/drivers/cam_cdm/cam_cdm_intf.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: GPL-2.0-only
/*
* Copyright (c) 2017-2020, The Linux Foundation. All rights reserved.
* Copyright (c) 2017-2019, The Linux Foundation. All rights reserved.
*/

#include <linux/delay.h>
Expand Down Expand Up @@ -379,33 +379,6 @@ int cam_cdm_reset_hw(uint32_t handle)
}
EXPORT_SYMBOL(cam_cdm_reset_hw);

int cam_cdm_detect_hang_error(uint32_t handle)
{
uint32_t hw_index;
int rc = -EINVAL;
struct cam_hw_intf *hw;

if (get_cdm_mgr_refcount()) {
CAM_ERR(CAM_CDM, "CDM intf mgr get refcount failed");
rc = -EPERM;
return rc;
}

hw_index = CAM_CDM_GET_HW_IDX(handle);
if (hw_index < CAM_CDM_INTF_MGR_MAX_SUPPORTED_CDM) {
hw = cdm_mgr.nodes[hw_index].device;
if (hw && hw->hw_ops.process_cmd)
rc = hw->hw_ops.process_cmd(hw->hw_priv,
CAM_CDM_HW_INTF_CMD_HANG_DETECT,
&handle,
sizeof(handle));
}
put_cdm_mgr_refcount();

return rc;
}
EXPORT_SYMBOL(cam_cdm_detect_hang_error);

int cam_cdm_intf_register_hw_cdm(struct cam_hw_intf *hw,
struct cam_cdm_private_dt_data *data, enum cam_cdm_type type,
uint32_t *index)
Expand Down
11 changes: 1 addition & 10 deletions techpack/camera/drivers/cam_cdm/cam_cdm_intf_api.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* SPDX-License-Identifier: GPL-2.0-only */
/*
* Copyright (c) 2017-2020, The Linux Foundation. All rights reserved.
* Copyright (c) 2017-2018, The Linux Foundation. All rights reserved.
*/

#ifndef _CAM_CDM_API_H_
Expand Down Expand Up @@ -199,13 +199,4 @@ int cam_cdm_stream_off(uint32_t handle);
*/
int cam_cdm_reset_hw(uint32_t handle);

/**
* @brief : API to detect hang in previously acquired CDM,
* this should be only performed only if the CDM is private.
*
* @handle : Input handle of the CDM to detect hang
*
* @return 0 on success
*/
int cam_cdm_detect_hang_error(uint32_t handle);
#endif /* _CAM_CDM_API_H_ */
Loading

0 comments on commit c36b13a

Please sign in to comment.