diff mbox series

[Resend] fpga: support debug access to memory-mapped afu regions

Message ID 20200304061406.98865-1-d.c.ddcc@gmail.com (mailing list archive)
State Superseded, archived
Headers show
Series [Resend] fpga: support debug access to memory-mapped afu regions | expand

Commit Message

Dominic Chen March 4, 2020, 6:14 a.m. UTC
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(+)

Comments

Wu, Hao March 4, 2020, 10:38 a.m. UTC | #1
Hi Dominic,

Thanks a lot for this patch. Please see my comments inline.

On Wed, Mar 04, 2020 at 01:14:06AM -0500, Dominic Chen wrote:
> Allow debug access to memory-mapped regions using e.g. gdb.

Do you mind improving the title to something like

   "fpga: dfl: afu: ...."

> 
> 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 = {

let's add "static" for afu_vma_ops here.

> +	.access = generic_access_phys,
> +};
> +#endif /* CONFIG_HAVE_IOREMAP_PROT */
> +

What about

  static const struct vm_operations_struct afu_vma_ops = {
  #ifdef CONFIG_HAVE_IOREMAP_PROT
  	.access = generic_access_phys,
  #endif
  };

Then we just need one line below.

  vma->vm_ops = &afu_vma_ops;


Thanks
Hao

>  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
Dominic Chen March 4, 2020, 1:38 p.m. UTC | #2
Sure, I will send out a v2.

Thanks,

Dominic

On 3/4/2020 5:38 AM, Wu Hao wrote:
> Hi Dominic,
>
> Thanks a lot for this patch. Please see my comments inline.
>
> On Wed, Mar 04, 2020 at 01:14:06AM -0500, Dominic Chen wrote:
>> Allow debug access to memory-mapped regions using e.g. gdb.
> Do you mind improving the title to something like
>
>    "fpga: dfl: afu: ...."
>
>> 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 = {
> let's add "static" for afu_vma_ops here.
>
>> +	.access = generic_access_phys,
>> +};
>> +#endif /* CONFIG_HAVE_IOREMAP_PROT */
>> +
> What about
>
>   static const struct vm_operations_struct afu_vma_ops = {
>   #ifdef CONFIG_HAVE_IOREMAP_PROT
>   	.access = generic_access_phys,
>   #endif
>   };
>
> Then we just need one line below.
>
>   vma->vm_ops = &afu_vma_ops;
>
>
> Thanks
> Hao
>
>>  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
diff mbox series

Patch

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,