Pārlūkot izejas kodu

msm: camera: smmu: Reorganization of context bank for nested support

Add support to have multiple same regions, and each region can
now support different subregions.

CRs-Fixed: 3351015
Change-Id: I733cce9c2c571ff21860871c5efdb19e833b1238
Signed-off-by: Karthik Anantha Ram <[email protected]>
Karthik Anantha Ram 2 gadi atpakaļ
vecāks
revīzija
0745a9ea41

+ 4 - 4
drivers/cam_icp/icp_hw/icp_hw_mgr/cam_icp_hw_mgr.c

@@ -3103,7 +3103,7 @@ static void cam_icp_free_hfi_mem(void)
 		cam_mem_mgr_release_mem(&icp_hw_mgr.hfi_mem.sfr_buf);
 	}
 
-	cam_smmu_dealloc_qdss(icp_hw_mgr.iommu_hdl);
+	cam_smmu_unmap_phy_mem_region(icp_hw_mgr.iommu_hdl, CAM_SMMU_REGION_QDSS, 0);
 }
 
 static int cam_icp_alloc_secheap_mem(struct cam_mem_mgr_memory_desc *secheap)
@@ -3221,8 +3221,8 @@ static int cam_icp_allocate_qdss_mem(void)
 	size_t len;
 	dma_addr_t iova;
 
-	rc = cam_smmu_alloc_qdss(icp_hw_mgr.iommu_hdl,
-		&iova, &len);
+	rc = cam_smmu_map_phy_mem_region(icp_hw_mgr.iommu_hdl,
+		CAM_SMMU_REGION_QDSS, 0, &iova, &len);
 	if (rc) {
 		CAM_ERR(CAM_ICP, "Failed in alloc qdss mem rc %d", rc);
 		return rc;
@@ -3472,7 +3472,7 @@ msg_q_alloc_failed:
 cmd_q_alloc_failed:
 	cam_mem_mgr_release_mem(&icp_hw_mgr.hfi_mem.qtbl);
 qtbl_alloc_failed:
-	cam_smmu_dealloc_qdss(icp_hw_mgr.iommu_hdl);
+	cam_smmu_unmap_phy_mem_region(icp_hw_mgr.iommu_hdl, CAM_SMMU_REGION_QDSS, 0);
 fw_alloc_failed:
 	cam_icp_free_fw_mem();
 	return rc;

Failā izmaiņas netiks attēlotas, jo tās ir par lielu
+ 478 - 107
drivers/cam_smmu/cam_smmu_api.c


+ 35 - 6
drivers/cam_smmu/cam_smmu_api.h

@@ -47,6 +47,14 @@ enum cam_smmu_region_id {
 	CAM_SMMU_REGION_SECHEAP,
 	CAM_SMMU_REGION_QDSS,
 	CAM_SMMU_REGION_FWUNCACHED,
+	CAM_SMMU_REGION_DEVICE,
+};
+
+enum cam_smmu_subregion_id {
+	CAM_SMMU_SUBREGION_GENERIC,
+	CAM_SMMU_SUBREGION_HWMUTEX,
+	CAM_SMMU_SUBREGION_GLOBAL_SYNC_MEM,
+	CAM_SMMU_SUBREGION_MAX,
 };
 
 /**
@@ -79,6 +87,19 @@ struct cam_smmu_pf_info {
 	bool                  in_map_region;
 };
 
+/**
+ * @brief            : Structure to store dma buf information
+ *
+ * @param buf    : dma buffer
+ * @param attach : attachment info between dma buf and device
+ * @param table  : scattered list
+ */
+struct region_buf_info {
+	struct dma_buf *buf;
+	struct dma_buf_attachment *attach;
+	struct sg_table *table;
+};
+
 /**
  * @brief            : Structure to store region information
  *
@@ -86,12 +107,15 @@ struct cam_smmu_pf_info {
  * @param iova_len           : length of region
  * @param discard_iova_start : iova addr start from where should not be used
  * @param discard_iova_len   : length of discard iova region
+ * @param phy_addr           : pa to which this va is mapped to
  */
 struct cam_smmu_region_info {
 	dma_addr_t iova_start;
 	size_t iova_len;
 	dma_addr_t discard_iova_start;
 	size_t discard_iova_len;
+	dma_addr_t phy_addr;
+	struct region_buf_info buf_info;
 };
 
 /**
@@ -399,26 +423,31 @@ int cam_smmu_release_buf_region(enum cam_smmu_region_id region,
 	int32_t smmu_hdl);
 
 /**
- * @brief Allocates qdss for context bank
+ * @brief Map va for phy addr range for a given context bank
  *
  * @param smmu_hdl: SMMU handle identifying context bank
+ * @param region_id: Region ID
+ * @optional param subregion_id: Subregion ID
  * @param iova: IOVA address of allocated qdss
  * @param len: Length of allocated qdss memory
  *
  * @return Status of operation. Negative in case of error. Zero otherwise.
  */
-int cam_smmu_alloc_qdss(int32_t smmu_hdl,
-	dma_addr_t *iova,
-	size_t *len);
+int cam_smmu_map_phy_mem_region(int32_t smmu_hdl,
+	uint32_t region_id, uint32_t subregion_id,
+	dma_addr_t *iova, size_t *len);
 
 /**
- * @brief Deallocates qdss memory for context bank
+ * @brief Unmap call for map_phy_mem for given context bank
  *
  * @param smmu_hdl: SMMU handle identifying the context bank
+ * @param region_id: Region ID
+ * @optional param subregion_id: Subregion ID
  *
  * @return Status of operation. Negative in case of error. Zero otherwise.
  */
-int cam_smmu_dealloc_qdss(int32_t smmu_hdl);
+int cam_smmu_unmap_phy_mem_region(int32_t smmu_hdl,
+	uint32_t region_id, uint32_t subregion_id);
 
 /**
  * @brief Get start addr & len of I/O region for a given cb

Daži faili netika attēloti, jo izmaiņu fails ir pārāk liels