media: ipu6: use PFN_UP() and sg_virt() for code simplicity

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>
This commit is contained in:
Bingbu Cao 2024-10-16 15:53:05 +08:00 committed by Hans Verkuil
parent 30dc78138d
commit 940ff4b41b
3 changed files with 6 additions and 6 deletions

View 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)

View 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);

View 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;