|
@@ -23,6 +23,8 @@
|
|
#include "cam_smmu_api.h"
|
|
#include "cam_smmu_api.h"
|
|
#include "cam_debug_util.h"
|
|
#include "cam_debug_util.h"
|
|
#include "camera_main.h"
|
|
#include "camera_main.h"
|
|
|
|
+#include "cam_trace.h"
|
|
|
|
+#include "cam_common_util.h"
|
|
|
|
|
|
#define SHARED_MEM_POOL_GRANULARITY 16
|
|
#define SHARED_MEM_POOL_GRANULARITY 16
|
|
|
|
|
|
@@ -147,6 +149,7 @@ struct cam_iommu_cb_set {
|
|
u32 non_fatal_fault;
|
|
u32 non_fatal_fault;
|
|
struct dentry *dentry;
|
|
struct dentry *dentry;
|
|
bool cb_dump_enable;
|
|
bool cb_dump_enable;
|
|
|
|
+ bool map_profile_enable;
|
|
};
|
|
};
|
|
|
|
|
|
static const struct of_device_id msm_cam_smmu_dt_match[] = {
|
|
static const struct of_device_id msm_cam_smmu_dt_match[] = {
|
|
@@ -1718,6 +1721,8 @@ static int cam_smmu_map_buffer_validate(struct dma_buf *buf,
|
|
size_t size = 0;
|
|
size_t size = 0;
|
|
uint32_t iova = 0;
|
|
uint32_t iova = 0;
|
|
int rc = 0;
|
|
int rc = 0;
|
|
|
|
+ struct timespec64 ts1, ts2;
|
|
|
|
+ long microsec = 0;
|
|
|
|
|
|
if (IS_ERR_OR_NULL(buf)) {
|
|
if (IS_ERR_OR_NULL(buf)) {
|
|
rc = PTR_ERR(buf);
|
|
rc = PTR_ERR(buf);
|
|
@@ -1732,6 +1737,9 @@ static int cam_smmu_map_buffer_validate(struct dma_buf *buf,
|
|
goto err_out;
|
|
goto err_out;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ if (iommu_cb_set.map_profile_enable)
|
|
|
|
+ CAM_GET_TIMESTAMP(ts1);
|
|
|
|
+
|
|
attach = dma_buf_attach(buf, iommu_cb_set.cb_info[idx].dev);
|
|
attach = dma_buf_attach(buf, iommu_cb_set.cb_info[idx].dev);
|
|
if (IS_ERR_OR_NULL(attach)) {
|
|
if (IS_ERR_OR_NULL(attach)) {
|
|
rc = PTR_ERR(attach);
|
|
rc = PTR_ERR(attach);
|
|
@@ -1791,7 +1799,9 @@ static int cam_smmu_map_buffer_validate(struct dma_buf *buf,
|
|
table = dma_buf_map_attachment(attach, dma_dir);
|
|
table = dma_buf_map_attachment(attach, dma_dir);
|
|
if (IS_ERR_OR_NULL(table)) {
|
|
if (IS_ERR_OR_NULL(table)) {
|
|
rc = PTR_ERR(table);
|
|
rc = PTR_ERR(table);
|
|
- CAM_ERR(CAM_SMMU, "Error: dma map attachment failed");
|
|
|
|
|
|
+ CAM_ERR(CAM_SMMU,
|
|
|
|
+ "Error: dma map attachment failed, size=%zu",
|
|
|
|
+ buf->size);
|
|
goto err_detach;
|
|
goto err_detach;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -1808,6 +1818,13 @@ static int cam_smmu_map_buffer_validate(struct dma_buf *buf,
|
|
"iova=%pK, region_id=%d, paddr=%pK, len=%d, dma_map_attrs=%d",
|
|
"iova=%pK, region_id=%d, paddr=%pK, len=%d, dma_map_attrs=%d",
|
|
iova, region_id, *paddr_ptr, *len_ptr, attach->dma_map_attrs);
|
|
iova, region_id, *paddr_ptr, *len_ptr, attach->dma_map_attrs);
|
|
|
|
|
|
|
|
+ if (iommu_cb_set.map_profile_enable) {
|
|
|
|
+ CAM_GET_TIMESTAMP(ts2);
|
|
|
|
+ CAM_GET_TIMESTAMP_DIFF_IN_MICRO(ts1, ts2, microsec);
|
|
|
|
+ trace_cam_log_event("SMMUMapProfile", "size and time in micro",
|
|
|
|
+ *len_ptr, microsec);
|
|
|
|
+ }
|
|
|
|
+
|
|
if (table->sgl) {
|
|
if (table->sgl) {
|
|
CAM_DBG(CAM_SMMU,
|
|
CAM_DBG(CAM_SMMU,
|
|
"DMA buf: %pK, device: %pK, attach: %pK, table: %pK",
|
|
"DMA buf: %pK, device: %pK, attach: %pK, table: %pK",
|
|
@@ -1934,6 +1951,8 @@ static int cam_smmu_unmap_buf_and_remove_from_list(
|
|
int rc;
|
|
int rc;
|
|
size_t size;
|
|
size_t size;
|
|
struct iommu_domain *domain;
|
|
struct iommu_domain *domain;
|
|
|
|
+ struct timespec64 ts1, ts2;
|
|
|
|
+ long microsec = 0;
|
|
|
|
|
|
if ((!mapping_info->buf) || (!mapping_info->table) ||
|
|
if ((!mapping_info->buf) || (!mapping_info->table) ||
|
|
(!mapping_info->attach)) {
|
|
(!mapping_info->attach)) {
|
|
@@ -1952,6 +1971,9 @@ static int cam_smmu_unmap_buf_and_remove_from_list(
|
|
mapping_info->region_id, mapping_info->paddr, mapping_info->len,
|
|
mapping_info->region_id, mapping_info->paddr, mapping_info->len,
|
|
mapping_info->attach->dma_map_attrs);
|
|
mapping_info->attach->dma_map_attrs);
|
|
|
|
|
|
|
|
+ if (iommu_cb_set.map_profile_enable)
|
|
|
|
+ CAM_GET_TIMESTAMP(ts1);
|
|
|
|
+
|
|
if (mapping_info->region_id == CAM_SMMU_REGION_SHARED) {
|
|
if (mapping_info->region_id == CAM_SMMU_REGION_SHARED) {
|
|
CAM_DBG(CAM_SMMU,
|
|
CAM_DBG(CAM_SMMU,
|
|
"Removing SHARED buffer paddr = %pK, len = %zu",
|
|
"Removing SHARED buffer paddr = %pK, len = %zu",
|
|
@@ -1988,6 +2010,13 @@ static int cam_smmu_unmap_buf_and_remove_from_list(
|
|
dma_buf_detach(mapping_info->buf, mapping_info->attach);
|
|
dma_buf_detach(mapping_info->buf, mapping_info->attach);
|
|
dma_buf_put(mapping_info->buf);
|
|
dma_buf_put(mapping_info->buf);
|
|
|
|
|
|
|
|
+ if (iommu_cb_set.map_profile_enable) {
|
|
|
|
+ CAM_GET_TIMESTAMP(ts2);
|
|
|
|
+ CAM_GET_TIMESTAMP_DIFF_IN_MICRO(ts1, ts2, microsec);
|
|
|
|
+ trace_cam_log_event("SMMUUnmapProfile",
|
|
|
|
+ "size and time in micro", mapping_info->len, microsec);
|
|
|
|
+ }
|
|
|
|
+
|
|
mapping_info->buf = NULL;
|
|
mapping_info->buf = NULL;
|
|
|
|
|
|
list_del_init(&mapping_info->list);
|
|
list_del_init(&mapping_info->list);
|
|
@@ -3633,6 +3662,15 @@ static int cam_smmu_create_debug_fs(void)
|
|
goto err;
|
|
goto err;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ if (!debugfs_create_bool("map_profile_enable",
|
|
|
|
+ 0644,
|
|
|
|
+ iommu_cb_set.dentry,
|
|
|
|
+ &iommu_cb_set.map_profile_enable)) {
|
|
|
|
+ CAM_ERR(CAM_SMMU,
|
|
|
|
+ "failed to create map_profile_enable");
|
|
|
|
+ goto err;
|
|
|
|
+ }
|
|
|
|
+
|
|
return 0;
|
|
return 0;
|
|
err:
|
|
err:
|
|
debugfs_remove_recursive(iommu_cb_set.dentry);
|
|
debugfs_remove_recursive(iommu_cb_set.dentry);
|