Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

firmware: qcom_scm: fix bogous abuse of dma-direct internals

As far as the device is concerned the dma address is the physical
address. There is no need to convert it to a physical address,
especially not using dma-direct internals that are not available
to drivers and which will interact badly with IOMMUs. Last but not
least the commit introducing it claimed to just fix a type issue,
but actually changed behavior.

Fixes: 6e37ccf78a532 ("firmware: qcom_scm: Use proper types for dma mappings")
Reviewed-by: Bjorn Andersson <bjorn.andersson@linaro.org>
Signed-off-by: Christoph Hellwig <hch@lst.de>
Link: https://lore.kernel.org/r/20200414123136.441454-1-hch@lst.de
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>

authored by

Christoph Hellwig and committed by
Bjorn Andersson
459b1f86 f49176fb

+3 -6
+3 -6
drivers/firmware/qcom_scm.c
··· 6 6 #include <linux/init.h> 7 7 #include <linux/cpumask.h> 8 8 #include <linux/export.h> 9 - #include <linux/dma-direct.h> 10 9 #include <linux/dma-mapping.h> 11 10 #include <linux/module.h> 12 11 #include <linux/types.h> ··· 805 806 struct qcom_scm_mem_map_info *mem_to_map; 806 807 phys_addr_t mem_to_map_phys; 807 808 phys_addr_t dest_phys; 808 - phys_addr_t ptr_phys; 809 - dma_addr_t ptr_dma; 809 + dma_addr_t ptr_phys; 810 810 size_t mem_to_map_sz; 811 811 size_t dest_sz; 812 812 size_t src_sz; ··· 822 824 ptr_sz = ALIGN(src_sz, SZ_64) + ALIGN(mem_to_map_sz, SZ_64) + 823 825 ALIGN(dest_sz, SZ_64); 824 826 825 - ptr = dma_alloc_coherent(__scm->dev, ptr_sz, &ptr_dma, GFP_KERNEL); 827 + ptr = dma_alloc_coherent(__scm->dev, ptr_sz, &ptr_phys, GFP_KERNEL); 826 828 if (!ptr) 827 829 return -ENOMEM; 828 - ptr_phys = dma_to_phys(__scm->dev, ptr_dma); 829 830 830 831 /* Fill source vmid detail */ 831 832 src = ptr; ··· 852 855 853 856 ret = __qcom_scm_assign_mem(__scm->dev, mem_to_map_phys, mem_to_map_sz, 854 857 ptr_phys, src_sz, dest_phys, dest_sz); 855 - dma_free_coherent(__scm->dev, ptr_sz, ptr, ptr_dma); 858 + dma_free_coherent(__scm->dev, ptr_sz, ptr, ptr_phys); 856 859 if (ret) { 857 860 dev_err(__scm->dev, 858 861 "Assign memory protection call failed %d\n", ret);