diff --git a/drivers/cam_smmu/cam_smmu_api.c b/drivers/cam_smmu/cam_smmu_api.c index f66ac2c25b..40adb3560b 100644 --- a/drivers/cam_smmu/cam_smmu_api.c +++ b/drivers/cam_smmu/cam_smmu_api.c @@ -3863,11 +3863,9 @@ static int cam_smmu_setup_cb(struct cam_context_bank_info *cb, goto end; } - iommu_dma_enable_best_fit_algo(dev); - - if (cb->discard_iova_start) - iommu_dma_reserve_iova(dev, cb->discard_iova_start, - cb->discard_iova_len); + /* Enable custom iommu features, if applicable */ + cam_smmu_util_iommu_custom(dev, cb->discard_iova_start, + cb->discard_iova_len); cb->state = CAM_SMMU_ATTACH; } else { diff --git a/drivers/cam_utils/cam_compat.c b/drivers/cam_utils/cam_compat.c index 096ea21c02..c33e0fce09 100644 --- a/drivers/cam_utils/cam_compat.c +++ b/drivers/cam_utils/cam_compat.c @@ -294,6 +294,12 @@ static int inline cam_subdev_list_cmp(struct cam_subdev *entry_1, struct cam_sub } #if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 15, 0) +void cam_smmu_util_iommu_custom(struct device *dev, + dma_addr_t discard_start, size_t discard_length) +{ + return; +} + int cam_req_mgr_ordered_list_cmp(void *priv, const struct list_head *head_1, const struct list_head *head_2) { @@ -323,6 +329,17 @@ int cam_get_ddr_type(void) return DDR_TYPE_LPDDR5; } #else +void cam_smmu_util_iommu_custom(struct device *dev, + dma_addr_t discard_start, size_t discard_length) +{ + iommu_dma_enable_best_fit_algo(dev); + + if (discard_start) + iommu_dma_reserve_iova(dev, discard_start, discard_length); + + return; +} + int cam_req_mgr_ordered_list_cmp(void *priv, struct list_head *head_1, struct list_head *head_2) { diff --git a/drivers/cam_utils/cam_compat.h b/drivers/cam_utils/cam_compat.h index 1b8112ff8f..0b28894847 100644 --- a/drivers/cam_utils/cam_compat.h +++ b/drivers/cam_utils/cam_compat.h @@ -12,6 +12,7 @@ #include #include #include +#include #include "cam_csiphy_dev.h" #include "cam_cpastop_hw.h" @@ -48,6 +49,8 @@ void cam_check_iommu_faults(struct iommu_domain *domain, struct cam_smmu_pf_info *pf_info); int cam_get_ddr_type(void); int cam_compat_util_get_dmabuf_va(struct dma_buf *dmabuf, uintptr_t *vaddr); +void cam_smmu_util_iommu_custom(struct device *dev, + dma_addr_t discard_start, size_t discard_length); #if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 15, 0) int cam_req_mgr_ordered_list_cmp(void *priv,