From a2b9d4eadb7727772698d06e4cbeb1a1e2538675 Mon Sep 17 00:00:00 2001
From: Dominic Chen <d.c.ddcc@gmail.com>
Date: Mon, 9 Mar 2020 14:53:23 -0400
Subject: [PATCH] fpga: dfl: afu: support debug access to memory-mapped afu
regions
Git-commit: a2b9d4eadb7727772698d06e4cbeb1a1e2538675
References: jsc#SLE-13441
Patch-mainline: v5.8-rc1
Allow debug access to memory-mapped regions using e.g. gdb.
Signed-off-by: Dominic Chen <d.c.ddcc@gmail.com>
Acked-by: Wu Hao <hao.wu@intel.com>
Signed-off-by: Moritz Fischer <mdf@kernel.org>
Signed-off-by: Oliver Neukum <oneukum@suse.com>
---
drivers/fpga/dfl-afu-main.c | 9 +++++++++
drivers/fpga/dfl.h | 1 +
2 files changed, 10 insertions(+)
--- a/drivers/fpga/dfl-afu-main.c
+++ b/drivers/fpga/dfl-afu-main.c
@@ -637,6 +637,12 @@ static long afu_ioctl(struct file *filp,
return -EINVAL;
}
+static const struct vm_operations_struct afu_vma_ops = {
+#ifdef CONFIG_HAVE_IOREMAP_PROT
+ .access = generic_access_phys,
+#endif
+};
+
static int afu_mmap(struct file *filp, struct vm_area_struct *vma)
{
struct platform_device *pdev = filp->private_data;
@@ -666,6 +672,9 @@ static int afu_mmap(struct file *filp, s
!(region.flags & DFL_PORT_REGION_WRITE))
return -EPERM;
+ /* Support debug access to the mapping */
+ vma->vm_ops = &afu_vma_ops;
+
vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
return remap_pfn_range(vma, vma->vm_start,
--- a/drivers/fpga/dfl.h
+++ b/drivers/fpga/dfl.h
@@ -182,6 +182,7 @@ struct dfl_feature_id {
struct dfl_feature_driver {
const struct dfl_feature_id *id_table;
const struct dfl_feature_ops *ops;
+ void *priv;
};
/**