media: ipu6: use PFN_UP() and sg_virt() for code simplicity
authorBingbu Cao <bingbu.cao@intel.com>
Wed, 16 Oct 2024 07:53:05 +0000 (15:53 +0800)
committerHans Verkuil <hverkuil@xs4all.nl>
Thu, 7 Nov 2024 08:05:56 +0000 (09:05 +0100)
Use PFN_UP() and sg_virt() can be used to simplify the code.

Signed-off-by: Bingbu Cao <bingbu.cao@intel.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
drivers/media/pci/intel/ipu6/ipu6-buttress.c
drivers/media/pci/intel/ipu6/ipu6-dma.c
drivers/media/pci/intel/ipu6/ipu6-mmu.c

index d66db537be4a6678227e2867e53aeaba8b46c9b2..2cb828c8796131306337353e0328e303766c8d1d 100644 (file)
@@ -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)
index b71f66bd8c1fdbaf0d2c2ce2c833e3fe1fa02e2b..287b77a6aeab153a5b36a98f64a599de2119f5bb 100644 (file)
@@ -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);
@@ -422,7 +422,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);
@@ -481,7 +481,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);
index 57298ac73d0722d2cbf9e3896bd12b9909e9fcb4..11d69a64ad6764db2238326c46c9cf78e368e529 100644 (file)
@@ -389,7 +389,7 @@ static size_t __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;