Loading drivers/media/platform/msm/vidc/msm_smem.c +2 −2 Original line number Diff line number Diff line Loading @@ -102,7 +102,7 @@ static int msm_dma_get_device_address(struct dma_buf *dbuf, unsigned long align, } mapping_info->dev = cb->dev; mapping_info->mapping = cb->mapping; mapping_info->domain = cb->domain; mapping_info->table = table; mapping_info->attach = attach; mapping_info->buf = dbuf; Loading Loading @@ -150,7 +150,7 @@ static int msm_dma_put_device_address(u32 flags, trace_msm_smem_buffer_iommu_op_end("UNMAP", 0, 0, 0, 0, 0); mapping_info->dev = NULL; mapping_info->mapping = NULL; mapping_info->domain = NULL; mapping_info->table = NULL; mapping_info->attach = NULL; mapping_info->buf = NULL; Loading drivers/media/platform/msm/vidc/msm_vidc.h +1 −1 Original line number Diff line number Diff line Loading @@ -56,7 +56,7 @@ enum hal_buffer { struct dma_mapping_info { struct device *dev; struct dma_iommu_mapping *mapping; struct iommu_domain *domain; struct sg_table *table; struct dma_buf_attachment *attach; struct dma_buf *buf; Loading drivers/media/platform/msm/vidc/msm_vidc_res_parse.c +5 −77 Original line number Diff line number Diff line Loading @@ -888,25 +888,10 @@ return rc; return rc; } static int get_secure_vmid(struct context_bank_info *cb) { if (!strcasecmp(cb->name, "venus_sec_bitstream")) return VMID_CP_BITSTREAM; else if (!strcasecmp(cb->name, "venus_sec_pixel")) return VMID_CP_PIXEL; else if (!strcasecmp(cb->name, "venus_sec_non_pixel")) return VMID_CP_NON_PIXEL; WARN(1, "No matching secure vmid for cb name: %s\n", cb->name); return VMID_INVAL; } static int msm_vidc_setup_context_bank(struct msm_vidc_platform_resources *res, struct context_bank_info *cb, struct device *dev) { int rc = 0; int secure_vmid = VMID_INVAL; struct bus_type *bus; if (!dev || !cb || !res) { Loading @@ -923,45 +908,7 @@ static int msm_vidc_setup_context_bank(struct msm_vidc_platform_resources *res, goto remove_cb; } cb->mapping = arm_iommu_create_mapping(bus, cb->addr_range.start, cb->addr_range.size); if (IS_ERR_OR_NULL(cb->mapping)) { dprintk(VIDC_ERR, "%s - failed to create mapping\n", __func__); rc = PTR_ERR(cb->mapping) ? PTR_ERR(cb->mapping) : -ENODEV; goto remove_cb; } if (cb->is_secure) { secure_vmid = get_secure_vmid(cb); rc = iommu_domain_set_attr(cb->mapping->domain, DOMAIN_ATTR_SECURE_VMID, &secure_vmid); if (rc) { dprintk(VIDC_ERR, "%s - programming secure vmid failed: %s %d\n", __func__, dev_name(dev), rc); goto release_mapping; } } if (res->cache_pagetables) { int cache_pagetables = 1; rc = iommu_domain_set_attr(cb->mapping->domain, DOMAIN_ATTR_USE_UPSTREAM_HINT, &cache_pagetables); if (rc) { WARN_ONCE(rc, "%s: failed to set cache pagetables attribute, %d\n", __func__, rc); rc = 0; } } rc = arm_iommu_attach_device(cb->dev, cb->mapping); if (rc) { dprintk(VIDC_ERR, "%s - Couldn't arm_iommu_attach_device\n", __func__); goto release_mapping; } cb->domain = iommu_get_domain_for_dev(cb->dev); /* * configure device segment size and segment boundary to ensure Loading @@ -976,14 +923,10 @@ static int msm_vidc_setup_context_bank(struct msm_vidc_platform_resources *res, dprintk(VIDC_DBG, "Attached %s and created mapping\n", dev_name(dev)); dprintk(VIDC_DBG, "Context bank name:%s, buffer_type: %#x, is_secure: %d, address range start: %#x, size: %#x, dev: %pK, mapping: %pK", "Context bank name:%s, buffer_type: %#x, is_secure: %d, address range start: %#x, size: %#x, dev: %pK, domain: %pK", cb->name, cb->buffer_type, cb->is_secure, cb->addr_range.start, cb->addr_range.size, cb->dev, cb->mapping); cb->addr_range.size, cb->dev, cb->domain); return rc; release_mapping: arm_iommu_release_mapping(cb->mapping); remove_cb: return rc; } Loading Loading @@ -1087,22 +1030,7 @@ static int msm_vidc_populate_context_bank(struct device *dev, goto err_setup_cb; } if (core->resources.non_fatal_pagefaults) { int data = 1; dprintk(VIDC_DBG, "set non-fatal-faults attribute on %s\n", dev_name(dev)); rc = iommu_domain_set_attr(cb->mapping->domain, DOMAIN_ATTR_NON_FATAL_FAULTS, &data); if (rc) { dprintk(VIDC_WARN, "%s: set non fatal attribute failed: %s %d\n", __func__, dev_name(dev), rc); /* ignore the error */ } } iommu_set_fault_handler(cb->mapping->domain, iommu_set_fault_handler(cb->domain, msm_vidc_smmu_fault_handler, (void *)core); return 0; Loading drivers/media/platform/msm/vidc/msm_vidc_resources.h +1 −1 Original line number Diff line number Diff line Loading @@ -52,7 +52,7 @@ struct context_bank_info { bool is_secure; struct addr_range addr_range; struct device *dev; struct dma_iommu_mapping *mapping; struct iommu_domain *domain; }; struct buffer_usage_table { Loading drivers/media/platform/msm/vidc/venus_hfi.c +10 −31 Original line number Diff line number Diff line Loading @@ -1006,23 +1006,6 @@ static void __set_threshold_registers(struct venus_hfi_device *device) dprintk(VIDC_ERR, "Failed to restore threshold values\n"); } static void __iommu_detach(struct venus_hfi_device *device) { struct context_bank_info *cb; if (!device || !device->res) { dprintk(VIDC_ERR, "Invalid parameter: %pK\n", device); return; } list_for_each_entry(cb, &device->res->context_banks, list) { if (cb->dev) arm_iommu_detach_device(cb->dev); if (cb->mapping) arm_iommu_release_mapping(cb->mapping); } } static int __devfreq_target(struct device *devfreq_dev, unsigned long *freq, u32 flags) { Loading Loading @@ -1514,7 +1497,7 @@ static int __iface_cmdq_write(struct venus_hfi_device *device, void *pkt) /* Consumer of cmdq prefers that we raise an interrupt */ rc = 0; __write_register(device, VIDC_CPU_IC_SOFTINT, 1 << VIDC_CPU_IC_SOFTINT_H2A_SHFT); VIDC_CPU_IC_SOFTINT_H2A_SHFT); } return rc; Loading Loading @@ -1550,7 +1533,7 @@ static int __iface_msgq_read(struct venus_hfi_device *device, void *pkt) __hal_sim_modify_msg_packet((u8 *)pkt, device); if (tx_req_is_set) __write_register(device, VIDC_CPU_IC_SOFTINT, 1 << VIDC_CPU_IC_SOFTINT_H2A_SHFT); VIDC_CPU_IC_SOFTINT_H2A_SHFT); rc = 0; } else rc = -ENODATA; Loading Loading @@ -1582,7 +1565,7 @@ static int __iface_dbgq_read(struct venus_hfi_device *device, void *pkt) if (!__read_queue(q_info, (u8 *)pkt, &tx_req_is_set)) { if (tx_req_is_set) __write_register(device, VIDC_CPU_IC_SOFTINT, 1 << VIDC_CPU_IC_SOFTINT_H2A_SHFT); VIDC_CPU_IC_SOFTINT_H2A_SHFT); rc = 0; } else rc = -ENODATA; Loading Loading @@ -1771,7 +1754,7 @@ static void __interface_queues_release(struct venus_hfi_device *device) false, device->res, HAL_BUFFER_INTERNAL_CMD_QUEUE); for (i = 0; cb && i < num_entries; i++) { iommu_unmap(cb->mapping->domain, iommu_unmap(cb->domain, mem_map[i].virtual_addr, mem_map[i].size); } Loading Loading @@ -1805,7 +1788,7 @@ static void __interface_queues_release(struct venus_hfi_device *device) } static int __get_qdss_iommu_virtual_addr(struct venus_hfi_device *dev, struct hfi_mem_map *mem_map, struct dma_iommu_mapping *mapping) struct hfi_mem_map *mem_map, struct iommu_domain *domain) { int i; int rc = 0; Loading @@ -1817,8 +1800,8 @@ static int __get_qdss_iommu_virtual_addr(struct venus_hfi_device *dev, return -ENODATA; for (i = 0; i < num_entries; i++) { if (mapping) { rc = iommu_map(mapping->domain, iova, if (domain) { rc = iommu_map(domain, iova, qdss_addr_tbl[i].start, qdss_addr_tbl[i].size, IOMMU_READ | IOMMU_WRITE); Loading Loading @@ -1846,8 +1829,8 @@ static int __get_qdss_iommu_virtual_addr(struct venus_hfi_device *dev, dprintk(VIDC_ERR, "QDSS mapping failed, Freeing other entries %d\n", i); for (--i; mapping && i >= 0; i--) { iommu_unmap(mapping->domain, for (--i; domain && i >= 0; i--) { iommu_unmap(domain, mem_map[i].virtual_addr, mem_map[i].size); } Loading Loading @@ -2001,7 +1984,7 @@ static int __interface_queues_init(struct venus_hfi_device *dev) return -EINVAL; } rc = __get_qdss_iommu_virtual_addr(dev, mem_map, cb->mapping); rc = __get_qdss_iommu_virtual_addr(dev, mem_map, cb->domain); if (rc) { dprintk(VIDC_ERR, "IOMMU mapping failed, Freeing qdss memdata\n"); Loading Loading @@ -5152,10 +5135,6 @@ void venus_hfi_delete_device(void *device) dev = (struct venus_hfi_device *) device; mutex_lock(&dev->lock); __iommu_detach(dev); mutex_unlock(&dev->lock); list_for_each_entry_safe(close, tmp, &hal_ctxt.dev_head, list) { if (close->hal_data->irq == dev->hal_data->irq) { hal_ctxt.dev_count--; Loading Loading
drivers/media/platform/msm/vidc/msm_smem.c +2 −2 Original line number Diff line number Diff line Loading @@ -102,7 +102,7 @@ static int msm_dma_get_device_address(struct dma_buf *dbuf, unsigned long align, } mapping_info->dev = cb->dev; mapping_info->mapping = cb->mapping; mapping_info->domain = cb->domain; mapping_info->table = table; mapping_info->attach = attach; mapping_info->buf = dbuf; Loading Loading @@ -150,7 +150,7 @@ static int msm_dma_put_device_address(u32 flags, trace_msm_smem_buffer_iommu_op_end("UNMAP", 0, 0, 0, 0, 0); mapping_info->dev = NULL; mapping_info->mapping = NULL; mapping_info->domain = NULL; mapping_info->table = NULL; mapping_info->attach = NULL; mapping_info->buf = NULL; Loading
drivers/media/platform/msm/vidc/msm_vidc.h +1 −1 Original line number Diff line number Diff line Loading @@ -56,7 +56,7 @@ enum hal_buffer { struct dma_mapping_info { struct device *dev; struct dma_iommu_mapping *mapping; struct iommu_domain *domain; struct sg_table *table; struct dma_buf_attachment *attach; struct dma_buf *buf; Loading
drivers/media/platform/msm/vidc/msm_vidc_res_parse.c +5 −77 Original line number Diff line number Diff line Loading @@ -888,25 +888,10 @@ return rc; return rc; } static int get_secure_vmid(struct context_bank_info *cb) { if (!strcasecmp(cb->name, "venus_sec_bitstream")) return VMID_CP_BITSTREAM; else if (!strcasecmp(cb->name, "venus_sec_pixel")) return VMID_CP_PIXEL; else if (!strcasecmp(cb->name, "venus_sec_non_pixel")) return VMID_CP_NON_PIXEL; WARN(1, "No matching secure vmid for cb name: %s\n", cb->name); return VMID_INVAL; } static int msm_vidc_setup_context_bank(struct msm_vidc_platform_resources *res, struct context_bank_info *cb, struct device *dev) { int rc = 0; int secure_vmid = VMID_INVAL; struct bus_type *bus; if (!dev || !cb || !res) { Loading @@ -923,45 +908,7 @@ static int msm_vidc_setup_context_bank(struct msm_vidc_platform_resources *res, goto remove_cb; } cb->mapping = arm_iommu_create_mapping(bus, cb->addr_range.start, cb->addr_range.size); if (IS_ERR_OR_NULL(cb->mapping)) { dprintk(VIDC_ERR, "%s - failed to create mapping\n", __func__); rc = PTR_ERR(cb->mapping) ? PTR_ERR(cb->mapping) : -ENODEV; goto remove_cb; } if (cb->is_secure) { secure_vmid = get_secure_vmid(cb); rc = iommu_domain_set_attr(cb->mapping->domain, DOMAIN_ATTR_SECURE_VMID, &secure_vmid); if (rc) { dprintk(VIDC_ERR, "%s - programming secure vmid failed: %s %d\n", __func__, dev_name(dev), rc); goto release_mapping; } } if (res->cache_pagetables) { int cache_pagetables = 1; rc = iommu_domain_set_attr(cb->mapping->domain, DOMAIN_ATTR_USE_UPSTREAM_HINT, &cache_pagetables); if (rc) { WARN_ONCE(rc, "%s: failed to set cache pagetables attribute, %d\n", __func__, rc); rc = 0; } } rc = arm_iommu_attach_device(cb->dev, cb->mapping); if (rc) { dprintk(VIDC_ERR, "%s - Couldn't arm_iommu_attach_device\n", __func__); goto release_mapping; } cb->domain = iommu_get_domain_for_dev(cb->dev); /* * configure device segment size and segment boundary to ensure Loading @@ -976,14 +923,10 @@ static int msm_vidc_setup_context_bank(struct msm_vidc_platform_resources *res, dprintk(VIDC_DBG, "Attached %s and created mapping\n", dev_name(dev)); dprintk(VIDC_DBG, "Context bank name:%s, buffer_type: %#x, is_secure: %d, address range start: %#x, size: %#x, dev: %pK, mapping: %pK", "Context bank name:%s, buffer_type: %#x, is_secure: %d, address range start: %#x, size: %#x, dev: %pK, domain: %pK", cb->name, cb->buffer_type, cb->is_secure, cb->addr_range.start, cb->addr_range.size, cb->dev, cb->mapping); cb->addr_range.size, cb->dev, cb->domain); return rc; release_mapping: arm_iommu_release_mapping(cb->mapping); remove_cb: return rc; } Loading Loading @@ -1087,22 +1030,7 @@ static int msm_vidc_populate_context_bank(struct device *dev, goto err_setup_cb; } if (core->resources.non_fatal_pagefaults) { int data = 1; dprintk(VIDC_DBG, "set non-fatal-faults attribute on %s\n", dev_name(dev)); rc = iommu_domain_set_attr(cb->mapping->domain, DOMAIN_ATTR_NON_FATAL_FAULTS, &data); if (rc) { dprintk(VIDC_WARN, "%s: set non fatal attribute failed: %s %d\n", __func__, dev_name(dev), rc); /* ignore the error */ } } iommu_set_fault_handler(cb->mapping->domain, iommu_set_fault_handler(cb->domain, msm_vidc_smmu_fault_handler, (void *)core); return 0; Loading
drivers/media/platform/msm/vidc/msm_vidc_resources.h +1 −1 Original line number Diff line number Diff line Loading @@ -52,7 +52,7 @@ struct context_bank_info { bool is_secure; struct addr_range addr_range; struct device *dev; struct dma_iommu_mapping *mapping; struct iommu_domain *domain; }; struct buffer_usage_table { Loading
drivers/media/platform/msm/vidc/venus_hfi.c +10 −31 Original line number Diff line number Diff line Loading @@ -1006,23 +1006,6 @@ static void __set_threshold_registers(struct venus_hfi_device *device) dprintk(VIDC_ERR, "Failed to restore threshold values\n"); } static void __iommu_detach(struct venus_hfi_device *device) { struct context_bank_info *cb; if (!device || !device->res) { dprintk(VIDC_ERR, "Invalid parameter: %pK\n", device); return; } list_for_each_entry(cb, &device->res->context_banks, list) { if (cb->dev) arm_iommu_detach_device(cb->dev); if (cb->mapping) arm_iommu_release_mapping(cb->mapping); } } static int __devfreq_target(struct device *devfreq_dev, unsigned long *freq, u32 flags) { Loading Loading @@ -1514,7 +1497,7 @@ static int __iface_cmdq_write(struct venus_hfi_device *device, void *pkt) /* Consumer of cmdq prefers that we raise an interrupt */ rc = 0; __write_register(device, VIDC_CPU_IC_SOFTINT, 1 << VIDC_CPU_IC_SOFTINT_H2A_SHFT); VIDC_CPU_IC_SOFTINT_H2A_SHFT); } return rc; Loading Loading @@ -1550,7 +1533,7 @@ static int __iface_msgq_read(struct venus_hfi_device *device, void *pkt) __hal_sim_modify_msg_packet((u8 *)pkt, device); if (tx_req_is_set) __write_register(device, VIDC_CPU_IC_SOFTINT, 1 << VIDC_CPU_IC_SOFTINT_H2A_SHFT); VIDC_CPU_IC_SOFTINT_H2A_SHFT); rc = 0; } else rc = -ENODATA; Loading Loading @@ -1582,7 +1565,7 @@ static int __iface_dbgq_read(struct venus_hfi_device *device, void *pkt) if (!__read_queue(q_info, (u8 *)pkt, &tx_req_is_set)) { if (tx_req_is_set) __write_register(device, VIDC_CPU_IC_SOFTINT, 1 << VIDC_CPU_IC_SOFTINT_H2A_SHFT); VIDC_CPU_IC_SOFTINT_H2A_SHFT); rc = 0; } else rc = -ENODATA; Loading Loading @@ -1771,7 +1754,7 @@ static void __interface_queues_release(struct venus_hfi_device *device) false, device->res, HAL_BUFFER_INTERNAL_CMD_QUEUE); for (i = 0; cb && i < num_entries; i++) { iommu_unmap(cb->mapping->domain, iommu_unmap(cb->domain, mem_map[i].virtual_addr, mem_map[i].size); } Loading Loading @@ -1805,7 +1788,7 @@ static void __interface_queues_release(struct venus_hfi_device *device) } static int __get_qdss_iommu_virtual_addr(struct venus_hfi_device *dev, struct hfi_mem_map *mem_map, struct dma_iommu_mapping *mapping) struct hfi_mem_map *mem_map, struct iommu_domain *domain) { int i; int rc = 0; Loading @@ -1817,8 +1800,8 @@ static int __get_qdss_iommu_virtual_addr(struct venus_hfi_device *dev, return -ENODATA; for (i = 0; i < num_entries; i++) { if (mapping) { rc = iommu_map(mapping->domain, iova, if (domain) { rc = iommu_map(domain, iova, qdss_addr_tbl[i].start, qdss_addr_tbl[i].size, IOMMU_READ | IOMMU_WRITE); Loading Loading @@ -1846,8 +1829,8 @@ static int __get_qdss_iommu_virtual_addr(struct venus_hfi_device *dev, dprintk(VIDC_ERR, "QDSS mapping failed, Freeing other entries %d\n", i); for (--i; mapping && i >= 0; i--) { iommu_unmap(mapping->domain, for (--i; domain && i >= 0; i--) { iommu_unmap(domain, mem_map[i].virtual_addr, mem_map[i].size); } Loading Loading @@ -2001,7 +1984,7 @@ static int __interface_queues_init(struct venus_hfi_device *dev) return -EINVAL; } rc = __get_qdss_iommu_virtual_addr(dev, mem_map, cb->mapping); rc = __get_qdss_iommu_virtual_addr(dev, mem_map, cb->domain); if (rc) { dprintk(VIDC_ERR, "IOMMU mapping failed, Freeing qdss memdata\n"); Loading Loading @@ -5152,10 +5135,6 @@ void venus_hfi_delete_device(void *device) dev = (struct venus_hfi_device *) device; mutex_lock(&dev->lock); __iommu_detach(dev); mutex_unlock(&dev->lock); list_for_each_entry_safe(close, tmp, &hal_ctxt.dev_head, list) { if (close->hal_data->irq == dev->hal_data->irq) { hal_ctxt.dev_count--; Loading