Merge 981b2405f2 on remote branch

Change-Id: Ie64f322e8f58a030507cd09761872ea5586454ee
This commit is contained in:
Linux Build Service Account 2021-10-24 02:19:02 -07:00
commit 39204283f8
11 changed files with 154 additions and 66 deletions

View file

@ -457,6 +457,9 @@ int32_t cam_context_prepare_dev_to_hw(struct cam_context *ctx,
rc = cam_sync_check_valid(
req->in_map_entries[j].sync_id);
if (rc) {
spin_lock(&ctx->lock);
list_del_init(&req->list);
spin_unlock(&ctx->lock);
CAM_ERR(CAM_CTXT,
"invalid in map sync object %d",
req->in_map_entries[j].sync_id);

View file

@ -20,6 +20,7 @@
#include <media/cam_req_mgr.h>
#include <media/cam_defs.h>
#include <media/cam_icp.h>
#include "cam_mem_mgr.h"
#include "cam_req_mgr_dev.h"
#include "cam_subdev.h"
#include "cam_node.h"
@ -86,10 +87,18 @@ static int cam_icp_subdev_open(struct v4l2_subdev *sd,
goto end;
}
rc = cam_mem_mgr_init();
if (rc) {
CAM_ERR(CAM_CRM, "mem mgr init failed");
goto end;
}
hw_mgr_intf = &node->hw_mgr_intf;
rc = hw_mgr_intf->hw_open(hw_mgr_intf->hw_mgr_priv, NULL);
if (rc < 0) {
CAM_ERR(CAM_ICP, "FW download failed");
cam_mem_mgr_deinit();
goto end;
}
g_icp_dev.open_cnt++;
@ -130,6 +139,7 @@ int cam_icp_subdev_close_internal(struct v4l2_subdev *sd,
goto end;
}
cam_mem_mgr_deinit();
end:
mutex_unlock(&g_icp_dev.icp_lock);
return rc;

View file

@ -3541,6 +3541,19 @@ hw_dump:
return rc;
}
static int __cam_isp_ctx_flush_req_in_flushed_state(
struct cam_context *ctx,
struct cam_req_mgr_flush_request *flush_req)
{
if (flush_req->type == CAM_REQ_MGR_FLUSH_TYPE_ALL) {
CAM_INFO(CAM_ISP, "Flush in flushed state req id %lld ctx_id:%d",
flush_req->req_id, ctx->ctx_id);
ctx->last_flush_req = flush_req->req_id;
}
return 0;
}
static int __cam_isp_ctx_flush_req(struct cam_context *ctx,
struct list_head *req_list, struct cam_req_mgr_flush_request *flush_req)
{
@ -4637,6 +4650,14 @@ static int __cam_isp_ctx_config_dev_in_top_state(
packet->header.request_id);
rc = -EBADR;
goto free_req;
} else if ((packet_opcode == CAM_ISP_PACKET_INIT_DEV)
&& (packet->header.request_id <= ctx->last_flush_req)
&& ctx->last_flush_req && packet->header.request_id) {
CAM_WARN(CAM_ISP,
"last flushed req is %lld, config dev(init) for req %lld",
ctx->last_flush_req, packet->header.request_id);
rc = -EBADR;
goto free_req;
}
cfg.packet = packet;
@ -5927,6 +5948,7 @@ static struct cam_ctx_ops
.crm_ops = {
.unlink = __cam_isp_ctx_unlink_in_ready,
.process_evt = __cam_isp_ctx_process_evt,
.flush_req = __cam_isp_ctx_flush_req_in_flushed_state,
},
.irq_ops = NULL,
.pagefault_ops = cam_isp_context_dump_requests,

View file

@ -761,10 +761,11 @@ static int cam_jpeg_mgr_prepare_hw_update(void *hw_mgr_priv,
}
if ((packet->num_cmd_buf > 5) || !packet->num_patches ||
!packet->num_io_configs) {
CAM_ERR(CAM_JPEG, "wrong number of cmd/patch info: %u %u",
packet->num_cmd_buf,
packet->num_patches);
!packet->num_io_configs ||
(packet->num_io_configs > CAM_JPEG_IMAGE_MAX)) {
CAM_ERR(CAM_JPEG,
"wrong number of cmd/patch/io_configs info: %u %u %u",
packet->num_cmd_buf, packet->num_patches, packet->num_io_configs);
return -EINVAL;
}

View file

@ -19,8 +19,11 @@
#include "cam_trace.h"
#include "cam_common_util.h"
static struct cam_mem_table tbl;
static atomic_t cam_mem_mgr_state = ATOMIC_INIT(CAM_MEM_MGR_UNINITIALIZED);
static struct cam_mem_table tbl = {
.m_lock = __MUTEX_INITIALIZER(tbl.m_lock),
};
static atomic_t cam_mem_mgr_refcnt = ATOMIC_INIT(0);
static void cam_mem_mgr_print_tbl(void)
{
@ -164,6 +167,16 @@ int cam_mem_mgr_init(void)
int i;
int bitmap_size;
mutex_lock(&tbl.m_lock);
if (atomic_inc_return(&cam_mem_mgr_refcnt) > 1) {
CAM_DBG(CAM_MEM,
"Mem mgr refcnt: %d",
atomic_read(&cam_mem_mgr_refcnt));
mutex_unlock(&tbl.m_lock);
return 0;
}
memset(tbl.bufq, 0, sizeof(tbl.bufq));
if (cam_smmu_need_force_alloc_cached(&tbl.force_cache_allocs)) {
@ -173,8 +186,13 @@ int cam_mem_mgr_init(void)
bitmap_size = BITS_TO_LONGS(CAM_MEM_BUFQ_MAX) * sizeof(long);
tbl.bitmap = kzalloc(bitmap_size, GFP_KERNEL);
if (!tbl.bitmap)
if (!tbl.bitmap) {
atomic_dec(&cam_mem_mgr_refcnt);
CAM_DBG(CAM_MEM, "Mem mgr refcnt: %d",
atomic_read(&cam_mem_mgr_refcnt));
mutex_unlock(&tbl.m_lock);
return -ENOMEM;
}
tbl.bits = bitmap_size * BITS_PER_BYTE;
bitmap_zero(tbl.bitmap, tbl.bits);
@ -185,9 +203,8 @@ int cam_mem_mgr_init(void)
tbl.bufq[i].fd = -1;
tbl.bufq[i].buf_handle = -1;
}
mutex_init(&tbl.m_lock);
atomic_set(&cam_mem_mgr_state, CAM_MEM_MGR_INITIALIZED);
mutex_unlock(&tbl.m_lock);
cam_mem_mgr_create_debug_fs();
@ -234,7 +251,7 @@ int cam_mem_get_io_buf(int32_t buf_handle, int32_t mmu_handle,
*len_ptr = 0;
if (!atomic_read(&cam_mem_mgr_state)) {
if (!atomic_read(&cam_mem_mgr_refcnt)) {
CAM_ERR(CAM_MEM, "failed. mem_mgr not initialized");
return -EINVAL;
}
@ -285,12 +302,7 @@ int cam_mem_get_cpu_buf(int32_t buf_handle, uintptr_t *vaddr_ptr, size_t *len)
{
int idx;
if (!atomic_read(&cam_mem_mgr_state)) {
CAM_ERR(CAM_MEM, "failed. mem_mgr not initialized");
return -EINVAL;
}
if (!atomic_read(&cam_mem_mgr_state)) {
if (!atomic_read(&cam_mem_mgr_refcnt)) {
CAM_ERR(CAM_MEM, "failed. mem_mgr not initialized");
return -EINVAL;
}
@ -333,7 +345,7 @@ int cam_mem_mgr_cache_ops(struct cam_mem_cache_ops_cmd *cmd)
uint32_t cache_dir;
unsigned long dmabuf_flag = 0;
if (!atomic_read(&cam_mem_mgr_state)) {
if (!atomic_read(&cam_mem_mgr_refcnt)) {
CAM_ERR(CAM_MEM, "failed. mem_mgr not initialized");
return -EINVAL;
}
@ -659,7 +671,7 @@ int cam_mem_mgr_alloc_and_map(struct cam_mem_mgr_alloc_cmd *cmd)
uintptr_t kvaddr = 0;
size_t klen;
if (!atomic_read(&cam_mem_mgr_state)) {
if (!atomic_read(&cam_mem_mgr_refcnt)) {
CAM_ERR(CAM_MEM, "failed. mem_mgr not initialized");
return -EINVAL;
}
@ -811,7 +823,7 @@ int cam_mem_mgr_map(struct cam_mem_mgr_map_cmd *cmd)
size_t len = 0;
bool is_internal = false;
if (!atomic_read(&cam_mem_mgr_state)) {
if (!atomic_read(&cam_mem_mgr_refcnt)) {
CAM_ERR(CAM_MEM, "failed. mem_mgr not initialized");
return -EINVAL;
}
@ -998,7 +1010,6 @@ static int cam_mem_mgr_cleanup_table(void)
{
int i;
mutex_lock(&tbl.m_lock);
for (i = 1; i < CAM_MEM_BUFQ_MAX; i++) {
if (!tbl.bufq[i].active) {
CAM_DBG(CAM_MEM,
@ -1034,23 +1045,27 @@ static int cam_mem_mgr_cleanup_table(void)
bitmap_zero(tbl.bitmap, tbl.bits);
/* We need to reserve slot 0 because 0 is invalid */
set_bit(0, tbl.bitmap);
mutex_unlock(&tbl.m_lock);
return 0;
}
void cam_mem_mgr_deinit(void)
{
atomic_set(&cam_mem_mgr_state, CAM_MEM_MGR_UNINITIALIZED);
mutex_lock(&tbl.m_lock);
if (!atomic_dec_and_test(&cam_mem_mgr_refcnt)) {
CAM_DBG(CAM_MEM, "Mem mgr refcnt: %d",
atomic_read(&cam_mem_mgr_refcnt));
mutex_unlock(&tbl.m_lock);
return;
}
cam_mem_mgr_cleanup_table();
debugfs_remove_recursive(tbl.dentry);
mutex_lock(&tbl.m_lock);
bitmap_zero(tbl.bitmap, tbl.bits);
kfree(tbl.bitmap);
tbl.bitmap = NULL;
tbl.dbg_buf_idx = -1;
mutex_unlock(&tbl.m_lock);
mutex_destroy(&tbl.m_lock);
}
static int cam_mem_util_unmap(int32_t idx,
@ -1148,7 +1163,7 @@ int cam_mem_mgr_release(struct cam_mem_mgr_release_cmd *cmd)
int idx;
int rc;
if (!atomic_read(&cam_mem_mgr_state)) {
if (!atomic_read(&cam_mem_mgr_refcnt)) {
CAM_ERR(CAM_MEM, "failed. mem_mgr not initialized");
return -EINVAL;
}
@ -1201,7 +1216,7 @@ int cam_mem_mgr_request_mem(struct cam_mem_mgr_request_desc *inp,
enum cam_smmu_region_id region = CAM_SMMU_REGION_SHARED;
if (!atomic_read(&cam_mem_mgr_state)) {
if (!atomic_read(&cam_mem_mgr_refcnt)) {
CAM_ERR(CAM_MEM, "failed. mem_mgr not initialized");
return -EINVAL;
}
@ -1327,7 +1342,7 @@ int cam_mem_mgr_release_mem(struct cam_mem_mgr_memory_desc *inp)
int32_t idx;
int rc;
if (!atomic_read(&cam_mem_mgr_state)) {
if (!atomic_read(&cam_mem_mgr_refcnt)) {
CAM_ERR(CAM_MEM, "failed. mem_mgr not initialized");
return -EINVAL;
}
@ -1380,7 +1395,7 @@ int cam_mem_mgr_reserve_memory_region(struct cam_mem_mgr_request_desc *inp,
int32_t smmu_hdl = 0;
int32_t num_hdl = 0;
if (!atomic_read(&cam_mem_mgr_state)) {
if (!atomic_read(&cam_mem_mgr_refcnt)) {
CAM_ERR(CAM_MEM, "failed. mem_mgr not initialized");
return -EINVAL;
}
@ -1475,7 +1490,7 @@ int cam_mem_mgr_free_memory_region(struct cam_mem_mgr_memory_desc *inp)
int rc;
int32_t smmu_hdl;
if (!atomic_read(&cam_mem_mgr_state)) {
if (!atomic_read(&cam_mem_mgr_refcnt)) {
CAM_ERR(CAM_MEM, "failed. mem_mgr not initialized");
return -EINVAL;
}

View file

@ -11,12 +11,6 @@
#include <media/cam_req_mgr.h>
#include "cam_mem_mgr_api.h"
/* Enum for possible mem mgr states */
enum cam_mem_mgr_state {
CAM_MEM_MGR_UNINITIALIZED,
CAM_MEM_MGR_INITIALIZED,
};
/*Enum for possible SMMU operations */
enum cam_smmu_mapping_client {
CAM_SMMU_MAPPING_USER,

View file

@ -115,7 +115,7 @@ static int32_t cam_get_free_handle_index(void)
idx = find_first_zero_bit(hdl_tbl->bitmap, hdl_tbl->bits);
if (idx >= CAM_REQ_MGR_MAX_HANDLES_V2 || idx < 0) {
CAM_DBG(CAM_CRM, "idx: %d", idx);
CAM_ERR(CAM_CRM, "No free index found idx: %d", idx);
return -ENOSR;
}
@ -124,20 +124,6 @@ static int32_t cam_get_free_handle_index(void)
return idx;
}
void cam_dump_tbl_info(void)
{
int i;
for (i = 0; i < CAM_REQ_MGR_MAX_HANDLES_V2; i++)
CAM_INFO(CAM_CRM,
"i: %d session_hdl=0x%x hdl_value=0x%x type=%d state=%d dev_id=0x%llx",
i, hdl_tbl->hdl[i].session_hdl,
hdl_tbl->hdl[i].hdl_value,
hdl_tbl->hdl[i].type,
hdl_tbl->hdl[i].state,
hdl_tbl->hdl[i].dev_id);
}
int32_t cam_create_session_hdl(void *priv)
{
int idx;
@ -154,7 +140,6 @@ int32_t cam_create_session_hdl(void *priv)
idx = cam_get_free_handle_index();
if (idx < 0) {
CAM_ERR(CAM_CRM, "Unable to create session handle");
cam_dump_tbl_info();
spin_unlock_bh(&hdl_tbl_lock);
return idx;
}
@ -190,7 +175,6 @@ int32_t cam_create_device_hdl(struct cam_create_dev_hdl *hdl_data)
if (idx < 0) {
CAM_ERR(CAM_CRM,
"Unable to create device handle(idx= %d)", idx);
cam_dump_tbl_info();
spin_unlock_bh(&hdl_tbl_lock);
return idx;
}

View file

@ -429,6 +429,7 @@ static int cam_flash_component_bind(struct device *dev,
return -ENOMEM;
fctrl->pdev = pdev;
fctrl->of_node = pdev->dev.of_node;
fctrl->soc_info.pdev = pdev;
fctrl->soc_info.dev = &pdev->dev;
fctrl->soc_info.dev_name = pdev->name;
@ -600,13 +601,18 @@ static int32_t cam_flash_i2c_driver_probe(struct i2c_client *client,
{
int32_t rc = 0, i = 0;
struct cam_flash_ctrl *fctrl;
struct cam_hw_soc_info *soc_info = NULL;
if (client == NULL || id == NULL) {
CAM_ERR(CAM_FLASH, "Invalid Args client: %pK id: %pK",
client, id);
if (client == NULL) {
CAM_ERR(CAM_FLASH, "Invalid Args client: %pK",
client);
return -EINVAL;
}
if (id == NULL) {
CAM_DBG(CAM_FLASH, "device id is Null");
}
if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) {
CAM_ERR(CAM_FLASH, "%s :: i2c_check_functionality failed",
client->name);
@ -618,9 +624,9 @@ static int32_t cam_flash_i2c_driver_probe(struct i2c_client *client,
if (!fctrl)
return -ENOMEM;
i2c_set_clientdata(client, fctrl);
client->dev.driver_data = fctrl;
fctrl->io_master_info.client = client;
fctrl->of_node = client->dev.of_node;
fctrl->soc_info.dev = &client->dev;
fctrl->soc_info.dev_name = client->name;
fctrl->io_master_info.master_type = I2C_MASTER;
@ -631,6 +637,40 @@ static int32_t cam_flash_i2c_driver_probe(struct i2c_client *client,
goto free_ctrl;
}
rc = cam_flash_init_default_params(fctrl);
if (rc) {
CAM_ERR(CAM_FLASH,
"failed: cam_flash_init_default_params rc %d",
rc);
goto free_ctrl;
}
soc_info = &fctrl->soc_info;
rc = cam_sensor_util_regulator_powerup(soc_info);
if (rc < 0) {
CAM_ERR(CAM_FLASH, "regulator power up for flash failed %d",
rc);
goto free_ctrl;
}
if (!soc_info->gpio_data) {
CAM_DBG(CAM_FLASH, "No GPIO found");
rc = 0;
return rc;
}
if (!soc_info->gpio_data->cam_gpio_common_tbl_size) {
CAM_DBG(CAM_FLASH, "No GPIO found");
return -EINVAL;
}
rc = cam_sensor_util_init_gpio_pin_tbl(soc_info,
&fctrl->power_info.gpio_num_info);
if ((rc < 0) || (!fctrl->power_info.gpio_num_info)) {
CAM_ERR(CAM_FLASH, "No/Error Flash GPIOs");
goto free_ctrl;
}
rc = cam_flash_init_subdev(fctrl);
if (rc)
goto free_ctrl;
@ -699,6 +739,7 @@ static struct i2c_driver cam_flash_i2c_driver = {
.remove = cam_flash_i2c_driver_remove,
.driver = {
.name = FLASH_DRIVER_I2C,
.of_match_table = cam_flash_dt_match,
},
};
@ -713,8 +754,9 @@ int32_t cam_flash_init_module(void)
}
rc = i2c_add_driver(&cam_flash_i2c_driver);
if (rc)
if (rc < 0)
CAM_ERR(CAM_FLASH, "i2c_add_driver failed rc: %d", rc);
return rc;
}

View file

@ -293,7 +293,14 @@ int cam_flash_get_dt_data(struct cam_flash_ctrl *fctrl,
rc = -ENOMEM;
goto release_soc_res;
}
of_node = fctrl->pdev->dev.of_node;
if (fctrl->of_node == NULL) {
CAM_ERR(CAM_FLASH, "device node is NULL");
rc = -EINVAL;
goto free_soc_private;
}
of_node = fctrl->of_node;
rc = cam_soc_util_get_dt_properties(soc_info);
if (rc) {

View file

@ -1,6 +1,6 @@
// SPDX-License-Identifier: GPL-2.0-only
/*
* Copyright (c) 2017-2020, The Linux Foundation. All rights reserved.
* Copyright (c) 2017-2021, The Linux Foundation. All rights reserved.
*/
#include "cam_sensor_cmn_header.h"
@ -31,9 +31,14 @@ static int32_t cam_qup_i2c_rxdata(
},
};
rc = i2c_transfer(dev_client->adapter, msgs, 2);
if (rc < 0)
if (rc < 0) {
CAM_ERR(CAM_SENSOR, "failed 0x%x", saddr);
return rc;
return rc;
}
/* Returns negative errno */
/* else the number of messages executed. */
/* So positive values are not errors. */
return 0;
}
@ -52,9 +57,14 @@ static int32_t cam_qup_i2c_txdata(
},
};
rc = i2c_transfer(dev_client->client->adapter, msg, 1);
if (rc < 0)
if (rc < 0) {
CAM_ERR(CAM_SENSOR, "failed 0x%x", saddr);
return rc;
return rc;
}
/* Returns negative errno, */
/* else the number of messages executed. */
/* So positive values are not errors. */
return 0;
}
int32_t cam_qup_i2c_read(struct i2c_client *client,

View file

@ -74,11 +74,11 @@ int32_t cam_sensor_util_regulator_powerup(struct cam_hw_soc_info *soc_info)
if (IS_ERR_OR_NULL(soc_info->rgltr[i])) {
rc = PTR_ERR(soc_info->rgltr[i]);
rc = rc ? rc : -EINVAL;
CAM_ERR(CAM_ACTUATOR, "get failed for regulator %s %d",
CAM_ERR(CAM_SENSOR, "get failed for regulator %s %d",
soc_info->rgltr_name[i], rc);
return rc;
}
CAM_DBG(CAM_ACTUATOR, "get for regulator %s",
CAM_DBG(CAM_SENSOR, "get for regulator %s",
soc_info->rgltr_name[i]);
}