linux-fpga.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [Resend] [PATCH] fpga: support debug access to memory-mapped afu regions
@ 2020-03-04  6:14 Dominic Chen
  2020-03-04 10:38 ` Wu Hao
  0 siblings, 1 reply; 3+ messages in thread
From: Dominic Chen @ 2020-03-04  6:14 UTC (permalink / raw)
  To: hao.wu, mdf, linux-fpga; +Cc: Dominic Chen

Allow debug access to memory-mapped regions using e.g. gdb.

Signed-off-by: Dominic Chen <d.c.ddcc@gmail.com>
---
 drivers/fpga/dfl-afu-main.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/drivers/fpga/dfl-afu-main.c b/drivers/fpga/dfl-afu-main.c
index 02baa6a227c0..38983f9dde98 100644
--- a/drivers/fpga/dfl-afu-main.c
+++ b/drivers/fpga/dfl-afu-main.c
@@ -459,6 +459,12 @@ static long afu_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
 	return -EINVAL;
 }
 
+#ifdef CONFIG_HAVE_IOREMAP_PROT
+const struct vm_operations_struct afu_vma_ops = {
+	.access = generic_access_phys,
+};
+#endif /* CONFIG_HAVE_IOREMAP_PROT */
+
 static int afu_mmap(struct file *filp, struct vm_area_struct *vma)
 {
 	struct platform_device *pdev = filp->private_data;
@@ -488,6 +494,11 @@ static int afu_mmap(struct file *filp, struct vm_area_struct *vma)
 	    !(region.flags & DFL_PORT_REGION_WRITE))
 		return -EPERM;
 
+	// Support debug access to the mapping
+#ifdef CONFIG_HAVE_IOREMAP_PROT
+	vma->vm_ops = &afu_vma_ops;
+#endif /* CONFIG_HAVE_IOREMAP_PROT */
+
 	vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
 
 	return remap_pfn_range(vma, vma->vm_start,
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-03-04 13:38 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-03-04  6:14 [Resend] [PATCH] fpga: support debug access to memory-mapped afu regions Dominic Chen
2020-03-04 10:38 ` Wu Hao
2020-03-04 13:38   ` Dominic Chen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).