Merge "iommu/io-pgtable: Add support for io-pgtable accounting"

This commit is contained in:
qctecmdr 2020-09-01 03:34:50 -07:00 • committed by Gerrit - the friendly Code Review server
commit 0cdc4fc71c
3 changed files with 13 additions and 3 deletions

View file

@ -2,6 +2,7 @@ CONFIG_LOCALVERSION="-qgki-consolidate"
CONFIG_IOMMU_TLBSYNC_DEBUG=y
CONFIG_IOMMU_DEBUG=y
CONFIG_IOMMU_TESTS=y
CONFIG_IO_PGTABLE_PAGE_ACCOUNTING=y
CONFIG_CMA_DEBUGFS=y
CONFIG_CMA_DEBUG=y
CONFIG_DEBUG_PAGEALLOC=y

View file

@ -1,6 +1,5 @@
CONFIG_LOCALVERSION="-qgki-debug"
CONFIG_SLUB_DEBUG_PANIC_ON=y
CONFIG_IO_PGTABLE_PAGE_ACCOUNTING=y
CONFIG_SLUB_DEBUG_ON=y
CONFIG_DEBUG_KMEMLEAK=y
CONFIG_DEBUG_KMEMLEAK_EARLY_LOG_SIZE=4000

View file

@ -149,19 +149,27 @@ void *io_pgtable_alloc_pages(struct io_pgtable_cfg *cfg, void *cookie,
{
struct device *dev;
struct page *p;
void *page_addr;
if (!cfg)
return NULL;
if (cfg->iommu_pgtable_ops && cfg->iommu_pgtable_ops->alloc_pgtable)
return cfg->iommu_pgtable_ops->alloc_pgtable(cookie, order,
if (cfg->iommu_pgtable_ops && cfg->iommu_pgtable_ops->alloc_pgtable) {
page_addr = cfg->iommu_pgtable_ops->alloc_pgtable(cookie, order,
gfp_mask);
if (likely(page_addr))
mod_pages_allocated(1 << order);
return page_addr;
}
dev = cfg->iommu_dev;
p = alloc_pages_node(dev ? dev_to_node(dev) : NUMA_NO_NODE,
gfp_mask, order);
if (!p)
return NULL;
mod_pages_allocated(1 << order);
return page_address(p);
}
@ -175,4 +183,6 @@ void io_pgtable_free_pages(struct io_pgtable_cfg *cfg, void *cookie, void *virt,
cfg->iommu_pgtable_ops->free_pgtable(cookie, virt, order);
else
free_pages((unsigned long)virt, order);
mod_pages_allocated(-(1 << order));
}