Message ID | 20241014034732.3109440-5-bingbu.cao@intel.com (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | [1/5] media: ipu6: not override the dma_ops of device in driver | expand |
On Mon, Oct 14, 2024 at 11:47:32AM +0800, bingbu.cao@intel.com wrote: > +++ b/drivers/media/pci/intel/ipu6/ipu6-dma.c > @@ -139,7 +139,7 @@ void ipu6_dma_sync_sg(struct ipu6_bus_device *sys, struct scatterlist *sglist, > int i; > > for_each_sg(sglist, sg, nents, i) > - clflush_cache_range(page_to_virt(sg_page(sg)), sg->length); > + clflush_cache_range(sg_virt(sg), sg->length); Not new in this code, but what guarantees that this driver never sees highmem?
Christoph, On 10/14/24 1:54 PM, Christoph Hellwig wrote: > On Mon, Oct 14, 2024 at 11:47:32AM +0800, bingbu.cao@intel.com wrote: >> +++ b/drivers/media/pci/intel/ipu6/ipu6-dma.c >> @@ -139,7 +139,7 @@ void ipu6_dma_sync_sg(struct ipu6_bus_device *sys, struct scatterlist *sglist, >> int i; >> >> for_each_sg(sglist, sg, nents, i) >> - clflush_cache_range(page_to_virt(sg_page(sg)), sg->length); >> + clflush_cache_range(sg_virt(sg), sg->length); > > Not new in this code, but what guarantees that this driver never sees > highmem? > > The hardware is only in Intel 64-bit SoCs. And it is likely the driver working with 64-bit kernel. I am not sure driver should handle highmem. Any suggestions?
On Mon, Oct 14, 2024 at 06:31:35PM +0800, Bingbu Cao wrote: > > Not new in this code, but what guarantees that this driver never sees > > highmem? > > > > > > The hardware is only in Intel 64-bit SoCs. And it is likely the driver > working with 64-bit kernel. I am not sure driver should handle highmem. Yes, that should be fine. Unless people bring back the unmapping user memory from the direct map thing.
diff --git a/drivers/media/pci/intel/ipu6/ipu6-buttress.c b/drivers/media/pci/intel/ipu6/ipu6-buttress.c index d66db537be4a..2cb828c87961 100644 --- a/drivers/media/pci/intel/ipu6/ipu6-buttress.c +++ b/drivers/media/pci/intel/ipu6/ipu6-buttress.c @@ -564,7 +564,7 @@ int ipu6_buttress_map_fw_image(struct ipu6_bus_device *sys, if (!is_vmalloc && !virt_addr_valid(fw->data)) return -EDOM; - n_pages = PHYS_PFN(PAGE_ALIGN(fw->size)); + n_pages = PFN_UP(fw->size); pages = kmalloc_array(n_pages, sizeof(*pages), GFP_KERNEL); if (!pages) diff --git a/drivers/media/pci/intel/ipu6/ipu6-dma.c b/drivers/media/pci/intel/ipu6/ipu6-dma.c index d03803e58881..207f67cd2b0c 100644 --- a/drivers/media/pci/intel/ipu6/ipu6-dma.c +++ b/drivers/media/pci/intel/ipu6/ipu6-dma.c @@ -139,7 +139,7 @@ void ipu6_dma_sync_sg(struct ipu6_bus_device *sys, struct scatterlist *sglist, int i; for_each_sg(sglist, sg, nents, i) - clflush_cache_range(page_to_virt(sg_page(sg)), sg->length); + clflush_cache_range(sg_virt(sg), sg->length); } EXPORT_SYMBOL_NS_GPL(ipu6_dma_sync_sg, INTEL_IPU6); @@ -392,7 +392,7 @@ int ipu6_dma_map_sg(struct ipu6_bus_device *sys, struct scatterlist *sglist, } for_each_sg(sglist, sg, nents, i) - npages += PHYS_PFN(PAGE_ALIGN(sg_dma_len(sg))); + npages += PFN_UP(sg_dma_len(sg)); dev_dbg(dev, "dmamap trying to map %d ents %zu pages\n", nents, npages); @@ -421,7 +421,7 @@ int ipu6_dma_map_sg(struct ipu6_bus_device *sys, struct scatterlist *sglist, sg_dma_address(sg) = PFN_PHYS(iova_addr); - iova_addr += PHYS_PFN(PAGE_ALIGN(sg_dma_len(sg))); + iova_addr += PFN_UP(sg_dma_len(sg)); } dev_dbg(dev, "dmamap %d ents %zu pages mapped\n", nents, npages); @@ -480,7 +480,7 @@ int ipu6_dma_get_sgtable(struct ipu6_bus_device *sys, struct sg_table *sgt, if (WARN_ON(!info->pages)) return -ENOMEM; - n_pages = PHYS_PFN(PAGE_ALIGN(size)); + n_pages = PFN_UP(size); ret = sg_alloc_table_from_pages(sgt, info->pages, n_pages, 0, size, GFP_KERNEL); diff --git a/drivers/media/pci/intel/ipu6/ipu6-mmu.c b/drivers/media/pci/intel/ipu6/ipu6-mmu.c index 2d9c6fbd5da2..07935350bb0e 100644 --- a/drivers/media/pci/intel/ipu6/ipu6-mmu.c +++ b/drivers/media/pci/intel/ipu6/ipu6-mmu.c @@ -409,7 +409,7 @@ static void __ipu6_mmu_unmap(struct ipu6_mmu_info *mmu_info, static int allocate_trash_buffer(struct ipu6_mmu *mmu) { - unsigned int n_pages = PHYS_PFN(PAGE_ALIGN(IPU6_MMUV2_TRASH_RANGE)); + unsigned int n_pages = PFN_UP(IPU6_MMUV2_TRASH_RANGE); struct iova *iova; unsigned int i; dma_addr_t dma;