iommu/iova: revert downstream debug codes
Since there is no iova bug currently, revert the debug codes to sync with upstream, including: Revert commitaf9e6b8f04("iommu/iova: fix cpu from 'unsigned long' to 'unsigned int' for for_each_online_cpu") Revert commit0373c12d82("iommu/iova: drop codes about rcache from iova_dump") Revert commit3c9526f479("iommu/iova: remove a iova procfs if existed") Revert commit4fe55239b3("iommu/iova: add iova procfs for each dma iommu") Revert commit0c51523b06("iommu/iova: dump iova when alloc failed") Change-Id: If78564d81a9b77e2dd5bef7abd69fc14cd28f864 Signed-off-by: Jianqun Xu <jay.xu@rock-chips.com>
This commit is contained in:
@@ -1267,13 +1267,6 @@ void iommu_setup_dma_ops(struct device *dev, u64 dma_base, u64 size)
|
||||
dev->dma_ops = &iommu_dma_ops;
|
||||
}
|
||||
|
||||
if (domain->type == IOMMU_DOMAIN_DMA) {
|
||||
struct iommu_dma_cookie *cookie = domain->iova_cookie;
|
||||
struct iova_domain *iovad = &cookie->iovad;
|
||||
|
||||
init_iova_domain_procfs(iovad, dev_name(dev));
|
||||
}
|
||||
|
||||
return;
|
||||
out_err:
|
||||
pr_warn("Failed to set up IOMMU for device %s; retaining platform DMA ops\n",
|
||||
|
||||
+1
-91
@@ -11,8 +11,6 @@
|
||||
#include <linux/smp.h>
|
||||
#include <linux/bitops.h>
|
||||
#include <linux/cpu.h>
|
||||
#include <linux/proc_fs.h>
|
||||
#include <linux/seq_file.h>
|
||||
|
||||
/* The anchor node sits above the top of the usable address space */
|
||||
#define IOVA_ANCHOR ~0UL
|
||||
@@ -27,66 +25,6 @@ static void init_iova_rcaches(struct iova_domain *iovad);
|
||||
static void free_iova_rcaches(struct iova_domain *iovad);
|
||||
static void fq_destroy_all_entries(struct iova_domain *iovad);
|
||||
static void fq_flush_timeout(struct timer_list *t);
|
||||
static void iova_dump(struct iova_domain *iovad);
|
||||
|
||||
static int iova_used_show(struct seq_file *s, void *v)
|
||||
{
|
||||
struct iova_domain *iovad = s->private;
|
||||
struct iova *iova, *t;
|
||||
unsigned long flags;
|
||||
unsigned long used_pfn = 0;
|
||||
unsigned int cpu;
|
||||
int i = 0;
|
||||
|
||||
for_each_online_cpu(cpu)
|
||||
free_cpu_cached_iovas(cpu, iovad);
|
||||
free_global_cached_iovas(iovad);
|
||||
|
||||
spin_lock_irqsave(&iovad->iova_rbtree_lock, flags);
|
||||
rbtree_postorder_for_each_entry_safe(iova, t, &iovad->rbroot, node) {
|
||||
dma_addr_t start = iova->pfn_lo << iova_shift(iovad);
|
||||
dma_addr_t end = iova->pfn_hi << iova_shift(iovad);
|
||||
unsigned long pfn = iova->pfn_hi + 1 - iova->pfn_lo;
|
||||
|
||||
if ((iova->pfn_hi == IOVA_ANCHOR) || (iova->pfn_lo == IOVA_ANCHOR))
|
||||
continue;
|
||||
|
||||
seq_printf(s, "%4d: [%pad..%pad] %6luKiB (%4lu - %4lu)MiB\n",
|
||||
i++, &start, &end,
|
||||
pfn << (PAGE_SHIFT - 10),
|
||||
iova->pfn_lo >> (20 - PAGE_SHIFT),
|
||||
(iova->pfn_hi + 1) >> (20 - PAGE_SHIFT));
|
||||
used_pfn += pfn;
|
||||
}
|
||||
spin_unlock_irqrestore(&iovad->iova_rbtree_lock, flags);
|
||||
seq_printf(s, "used: %lu MiB\n", used_pfn >> (20 - PAGE_SHIFT));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static struct proc_dir_entry *iova_dir;
|
||||
|
||||
void init_iova_domain_procfs(struct iova_domain *iovad, const char *name)
|
||||
{
|
||||
struct proc_dir_entry *root;
|
||||
|
||||
remove_proc_subtree(name, iova_dir);
|
||||
root = proc_mkdir(name, iova_dir);
|
||||
if (!root)
|
||||
return;
|
||||
|
||||
proc_create_single_data("used", 0, root, iova_used_show, iovad);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(init_iova_domain_procfs);
|
||||
|
||||
static int __init iova_procfs_create(void)
|
||||
{
|
||||
if (!iova_dir)
|
||||
iova_dir = proc_mkdir("iova", NULL);
|
||||
|
||||
return 0;
|
||||
}
|
||||
subsys_initcall(iova_procfs_create);
|
||||
|
||||
void
|
||||
init_iova_domain(struct iova_domain *iovad, unsigned long granule,
|
||||
@@ -585,10 +523,8 @@ retry:
|
||||
if (!new_iova) {
|
||||
unsigned int cpu;
|
||||
|
||||
if (!flush_rcache) {
|
||||
iova_dump(iovad);
|
||||
if (!flush_rcache)
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Try replenishing IOVAs by flushing rcache. */
|
||||
flush_rcache = false;
|
||||
@@ -951,32 +887,6 @@ struct iova_cpu_rcache {
|
||||
struct iova_magazine *prev;
|
||||
};
|
||||
|
||||
static void iova_dump(struct iova_domain *iovad)
|
||||
{
|
||||
struct iova *iova, *t;
|
||||
unsigned long flags;
|
||||
unsigned long used_pfn = 0;
|
||||
int i = 0;
|
||||
|
||||
spin_lock_irqsave(&iovad->iova_rbtree_lock, flags);
|
||||
rbtree_postorder_for_each_entry_safe(iova, t, &iovad->rbroot, node) {
|
||||
dma_addr_t start = iova->pfn_lo << iova_shift(iovad);
|
||||
dma_addr_t end = iova->pfn_hi << iova_shift(iovad);
|
||||
unsigned long pfn = iova->pfn_hi + 1 - iova->pfn_lo;
|
||||
|
||||
if (iova->pfn_lo == IOVA_ANCHOR)
|
||||
continue;
|
||||
|
||||
pr_info("%4d: [%pad..%pad] (%4lu - %4lu)MiB\n",
|
||||
i++, &start, &end,
|
||||
iova->pfn_lo >> (20 - PAGE_SHIFT),
|
||||
iova->pfn_hi >> (20 - PAGE_SHIFT));
|
||||
used_pfn += pfn;
|
||||
}
|
||||
spin_unlock_irqrestore(&iovad->iova_rbtree_lock, flags);
|
||||
pr_info("used: %lu MiB\n", used_pfn >> (20 - PAGE_SHIFT));
|
||||
}
|
||||
|
||||
static struct iova_magazine *iova_magazine_alloc(gfp_t flags)
|
||||
{
|
||||
return kzalloc(sizeof(struct iova_magazine), flags);
|
||||
|
||||
@@ -156,7 +156,6 @@ struct iova *reserve_iova(struct iova_domain *iovad, unsigned long pfn_lo,
|
||||
void copy_reserved_iova(struct iova_domain *from, struct iova_domain *to);
|
||||
void init_iova_domain(struct iova_domain *iovad, unsigned long granule,
|
||||
unsigned long start_pfn);
|
||||
void init_iova_domain_procfs(struct iova_domain *iovad, const char *name);
|
||||
bool has_iova_flush_queue(struct iova_domain *iovad);
|
||||
int init_iova_flush_queue(struct iova_domain *iovad,
|
||||
iova_flush_cb flush_cb, iova_entry_dtor entry_dtor);
|
||||
@@ -239,11 +238,6 @@ static inline void init_iova_domain(struct iova_domain *iovad,
|
||||
{
|
||||
}
|
||||
|
||||
static inline void
|
||||
init_iova_domain_procfs(struct iova_domain *iovad, const char *name)
|
||||
{
|
||||
}
|
||||
|
||||
static inline bool has_iova_flush_queue(struct iova_domain *iovad)
|
||||
{
|
||||
return false;
|
||||
|
||||
Reference in New Issue
Block a user