[dpdk-dev,RFC] igb_uio: issue FLR during open and release of device file

Message ID 1496228966-18573-1-git-send-email-shijith.thotton@caviumnetworks.com (mailing list archive)
State Superseded, archived
Delegated to: Thomas Monjalon
Headers

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK

Commit Message

Shijith Thotton May 31, 2017, 11:09 a.m. UTC
  Set UIO info device file operations open and release. Call pci reset
function inside open and release to clear device state at start and
end. Copied this behaviour from vfio_pci kernel module code. With this
change, it is not mandatory to issue FLR by PMD's during init and close.

Signed-off-by: Shijith Thotton <shijith.thotton@caviumnetworks.com>
---
 lib/librte_eal/linuxapp/igb_uio/igb_uio.c | 30 ++++++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)
  

Comments

Ferruh Yigit May 31, 2017, 12:20 p.m. UTC | #1
On 5/31/2017 12:09 PM, Shijith Thotton wrote:
> Set UIO info device file operations open and release. Call pci reset
> function inside open and release to clear device state at start and
> end. Copied this behaviour from vfio_pci kernel module code. With this
> change, it is not mandatory to issue FLR by PMD's during init and close.

Cc: Jianfeng Tan <jianfeng.tan@intel.com>

Jianfeng also implemented following patch:
http://dpdk.org/dev/patchwork/patch/17495/

Which also implements release and open ops, for slightly different
reason (prevent DMA access after app exit), but mainly both are to
gracefully handle application exit status.

btw, for Jianfeng's case, can adding pci_clear_master() in release and
moving pci_set_master() to open help preventing unwanted DMA?


Gregory,

Can you please check if this patch fixes your issue?

Thanks,
ferruh

> 
> Signed-off-by: Shijith Thotton <shijith.thotton@caviumnetworks.com>
> ---
>  lib/librte_eal/linuxapp/igb_uio/igb_uio.c | 30 ++++++++++++++++++++++++++++++
>  1 file changed, 30 insertions(+)
> 
> diff --git a/lib/librte_eal/linuxapp/igb_uio/igb_uio.c b/lib/librte_eal/linuxapp/igb_uio/igb_uio.c
> index b9d427c..5bc58d2 100644
> --- a/lib/librte_eal/linuxapp/igb_uio/igb_uio.c
> +++ b/lib/librte_eal/linuxapp/igb_uio/igb_uio.c
> @@ -170,6 +170,34 @@ struct rte_uio_pci_dev {
>  	return IRQ_HANDLED;
>  }
>  
> +/**
> + * This gets called while opening uio device file. It clears any previous state
> + * associated with the pci device.
> + */
> +static int
> +igbuio_pci_open(struct uio_info *info, struct inode *inode)
> +{
> +	struct rte_uio_pci_dev *udev = info->priv;
> +	struct pci_dev *dev = udev->pdev;
> +
> +	/* reset the pci device */
> +	pci_reset_function(dev);
> +
> +	return 0;
> +}
> +
> +static int
> +igbuio_pci_release(struct uio_info *info, struct inode *inode)
> +{
> +	struct rte_uio_pci_dev *udev = info->priv;
> +	struct pci_dev *dev = udev->pdev;
> +
> +	/* try to reset the pci device */
> +	pci_try_reset_function(dev);
> +
> +	return 0;
> +}
> +
>  #ifdef CONFIG_XEN_DOM0
>  static int
>  igbuio_dom0_mmap_phys(struct uio_info *info, struct vm_area_struct *vma)
> @@ -372,6 +400,8 @@ struct rte_uio_pci_dev {
>  	udev->info.version = "0.1";
>  	udev->info.handler = igbuio_pci_irqhandler;
>  	udev->info.irqcontrol = igbuio_pci_irqcontrol;
> +	udev->info.open = igbuio_pci_open;
> +	udev->info.release = igbuio_pci_release;
>  #ifdef CONFIG_XEN_DOM0
>  	/* check if the driver run on Xen Dom0 */
>  	if (xen_initial_domain())
>
  
Stephen Hemminger May 31, 2017, 3:29 p.m. UTC | #2
On Wed, 31 May 2017 16:39:26 +0530
Shijith Thotton <shijith.thotton@caviumnetworks.com> wrote:

> +	/* reset the pci device */
> +	pci_reset_function(dev);

It is not considered best practice to comment the obvious.
This comment borders on being the classic /* add one to i */
  
Stephen Hemminger May 31, 2017, 3:30 p.m. UTC | #3
On Wed, 31 May 2017 13:20:08 +0100
Ferruh Yigit <ferruh.yigit@intel.com> wrote:

> On 5/31/2017 12:09 PM, Shijith Thotton wrote:
> > Set UIO info device file operations open and release. Call pci reset
> > function inside open and release to clear device state at start and
> > end. Copied this behaviour from vfio_pci kernel module code. With this
> > change, it is not mandatory to issue FLR by PMD's during init and close.  
> 
> Cc: Jianfeng Tan <jianfeng.tan@intel.com>
> 
> Jianfeng also implemented following patch:
> http://dpdk.org/dev/patchwork/patch/17495/
> 
> Which also implements release and open ops, for slightly different
> reason (prevent DMA access after app exit), but mainly both are to
> gracefully handle application exit status.
> 
> btw, for Jianfeng's case, can adding pci_clear_master() in release and
> moving pci_set_master() to open help preventing unwanted DMA?
> 
> 
> Gregory,
> 
> Can you please check if this patch fixes your issue?
> 
> Thanks,
> ferruh

pci_reset should stop all DMA. It also clears master status.
  
Ferruh Yigit May 31, 2017, 5:11 p.m. UTC | #4
On 5/31/2017 4:30 PM, Stephen Hemminger wrote:
> On Wed, 31 May 2017 13:20:08 +0100
> Ferruh Yigit <ferruh.yigit@intel.com> wrote:
> 
>> On 5/31/2017 12:09 PM, Shijith Thotton wrote:
>>> Set UIO info device file operations open and release. Call pci reset
>>> function inside open and release to clear device state at start and
>>> end. Copied this behaviour from vfio_pci kernel module code. With this
>>> change, it is not mandatory to issue FLR by PMD's during init and close.  
>>
>> Cc: Jianfeng Tan <jianfeng.tan@intel.com>
>>
>> Jianfeng also implemented following patch:
>> http://dpdk.org/dev/patchwork/patch/17495/
>>
>> Which also implements release and open ops, for slightly different
>> reason (prevent DMA access after app exit), but mainly both are to
>> gracefully handle application exit status.
>>
>> btw, for Jianfeng's case, can adding pci_clear_master() in release and
>> moving pci_set_master() to open help preventing unwanted DMA?
>>
>>
>> Gregory,
>>
>> Can you please check if this patch fixes your issue?
>>
>> Thanks,
>> ferruh
> 
> pci_reset should stop all DMA. It also clears master status.

If so, should open() call pci_set_master(), currently it has been only
called by igbuio_pci_probe() once?
  
Gregory Etelson June 1, 2017, 11:14 a.m. UTC | #5
On Wednesday, 31 May 2017 15:20:08 IDT Ferruh Yigit wrote:
> On 5/31/2017 12:09 PM, Shijith Thotton wrote:
> > Set UIO info device file operations open and release. Call pci reset
> > function inside open and release to clear device state at start and
> > end. Copied this behaviour from vfio_pci kernel module code. With this
> > change, it is not mandatory to issue FLR by PMD's during init and close.
> 
> Cc: Jianfeng Tan <jianfeng.tan@intel.com>
> 
> Jianfeng also implemented following patch:
> http://dpdk.org/dev/patchwork/patch/17495/
> 
> Which also implements release and open ops, for slightly different
> reason (prevent DMA access after app exit), but mainly both are to
> gracefully handle application exit status.
> 
> btw, for Jianfeng's case, can adding pci_clear_master() in release and
> moving pci_set_master() to open help preventing unwanted DMA?
> 
> 
> Gregory,
> 
> Can you please check if this patch fixes your issue?
> 
> Thanks,
> ferruh

The tests are running.
I'll update you on completion.

Regards,
Gregory


> 
> > 
> > Signed-off-by: Shijith Thotton <shijith.thotton@caviumnetworks.com>
> > ---
> >  lib/librte_eal/linuxapp/igb_uio/igb_uio.c | 30 ++++++++++++++++++++++++++++++
> >  1 file changed, 30 insertions(+)
> > 
> > diff --git a/lib/librte_eal/linuxapp/igb_uio/igb_uio.c b/lib/librte_eal/linuxapp/igb_uio/igb_uio.c
> > index b9d427c..5bc58d2 100644
> > --- a/lib/librte_eal/linuxapp/igb_uio/igb_uio.c
> > +++ b/lib/librte_eal/linuxapp/igb_uio/igb_uio.c
> > @@ -170,6 +170,34 @@ struct rte_uio_pci_dev {
> >  	return IRQ_HANDLED;
> >  }
> >  
> > +/**
> > + * This gets called while opening uio device file. It clears any previous state
> > + * associated with the pci device.
> > + */
> > +static int
> > +igbuio_pci_open(struct uio_info *info, struct inode *inode)
> > +{
> > +	struct rte_uio_pci_dev *udev = info->priv;
> > +	struct pci_dev *dev = udev->pdev;
> > +
> > +	/* reset the pci device */
> > +	pci_reset_function(dev);
> > +
> > +	return 0;
> > +}
> > +
> > +static int
> > +igbuio_pci_release(struct uio_info *info, struct inode *inode)
> > +{
> > +	struct rte_uio_pci_dev *udev = info->priv;
> > +	struct pci_dev *dev = udev->pdev;
> > +
> > +	/* try to reset the pci device */
> > +	pci_try_reset_function(dev);
> > +
> > +	return 0;
> > +}
> > +
> >  #ifdef CONFIG_XEN_DOM0
> >  static int
> >  igbuio_dom0_mmap_phys(struct uio_info *info, struct vm_area_struct *vma)
> > @@ -372,6 +400,8 @@ struct rte_uio_pci_dev {
> >  	udev->info.version = "0.1";
> >  	udev->info.handler = igbuio_pci_irqhandler;
> >  	udev->info.irqcontrol = igbuio_pci_irqcontrol;
> > +	udev->info.open = igbuio_pci_open;
> > +	udev->info.release = igbuio_pci_release;
> >  #ifdef CONFIG_XEN_DOM0
> >  	/* check if the driver run on Xen Dom0 */
> >  	if (xen_initial_domain())
> > 
> 
>
  
Shijith Thotton June 1, 2017, 11:35 a.m. UTC | #6
On Wed, May 31, 2017 at 06:11:40PM +0100, Ferruh Yigit wrote:
> On 5/31/2017 4:30 PM, Stephen Hemminger wrote:
> > On Wed, 31 May 2017 13:20:08 +0100
> > Ferruh Yigit <ferruh.yigit@intel.com> wrote:
> > 
> >> On 5/31/2017 12:09 PM, Shijith Thotton wrote:
> >>> Set UIO info device file operations open and release. Call pci reset
> >>> function inside open and release to clear device state at start and
> >>> end. Copied this behaviour from vfio_pci kernel module code. With this
> >>> change, it is not mandatory to issue FLR by PMD's during init and close.  
> >>
> >> Cc: Jianfeng Tan <jianfeng.tan@intel.com>
> >>
> >> Jianfeng also implemented following patch:
> >> http://dpdk.org/dev/patchwork/patch/17495/
> >>
> >> Which also implements release and open ops, for slightly different
> >> reason (prevent DMA access after app exit), but mainly both are to
> >> gracefully handle application exit status.
> >>
> >> btw, for Jianfeng's case, can adding pci_clear_master() in release and
> >> moving pci_set_master() to open help preventing unwanted DMA?
> >>
> >>
> >> Gregory,
> >>
> >> Can you please check if this patch fixes your issue?
> >>
> >> Thanks,
> >> ferruh
> > 
> > pci_reset should stop all DMA. It also clears master status.

Per Alex Williamson[1], bus master will be disabled after FLR. But a disable is
preferred after reset, since all device won't behave as per spec.

1. http://www.spinics.net/lists/kvm/msg115715.html

> 
> If so, should open() call pci_set_master(), currently it has been only
> called by igbuio_pci_probe() once?

DPDK has pci_uio_set_bus_master/pci_vfio_set_bus_master to set bus master.
Can we leave it to the application ? vfio leaves the device with bus master
disabled after open.
  
Gregory Etelson June 4, 2017, 7:22 a.m. UTC | #7
In my environment I could reproduce server crash 
after applying the patch

Regards,
Gregory


On Wednesday, 31 May 2017 15:20:08 IDT Ferruh Yigit wrote:
> On 5/31/2017 12:09 PM, Shijith Thotton wrote:
> > Set UIO info device file operations open and release. Call pci reset
> > function inside open and release to clear device state at start and
> > end. Copied this behaviour from vfio_pci kernel module code. With this
> > change, it is not mandatory to issue FLR by PMD's during init and close.
> 
> Cc: Jianfeng Tan <jianfeng.tan@intel.com>
> 
> Jianfeng also implemented following patch:
> http://dpdk.org/dev/patchwork/patch/17495/
> 
> Which also implements release and open ops, for slightly different
> reason (prevent DMA access after app exit), but mainly both are to
> gracefully handle application exit status.
> 
> btw, for Jianfeng's case, can adding pci_clear_master() in release and
> moving pci_set_master() to open help preventing unwanted DMA?
> 
> 
> Gregory,
> 
> Can you please check if this patch fixes your issue?
> 
> Thanks,
> ferruh
> 
> > 
> > Signed-off-by: Shijith Thotton <shijith.thotton@caviumnetworks.com>
> > ---
> >  lib/librte_eal/linuxapp/igb_uio/igb_uio.c | 30 ++++++++++++++++++++++++++++++
> >  1 file changed, 30 insertions(+)
> > 
> > diff --git a/lib/librte_eal/linuxapp/igb_uio/igb_uio.c b/lib/librte_eal/linuxapp/igb_uio/igb_uio.c
> > index b9d427c..5bc58d2 100644
> > --- a/lib/librte_eal/linuxapp/igb_uio/igb_uio.c
> > +++ b/lib/librte_eal/linuxapp/igb_uio/igb_uio.c
> > @@ -170,6 +170,34 @@ struct rte_uio_pci_dev {
> >  	return IRQ_HANDLED;
> >  }
> >  
> > +/**
> > + * This gets called while opening uio device file. It clears any previous state
> > + * associated with the pci device.
> > + */
> > +static int
> > +igbuio_pci_open(struct uio_info *info, struct inode *inode)
> > +{
> > +	struct rte_uio_pci_dev *udev = info->priv;
> > +	struct pci_dev *dev = udev->pdev;
> > +
> > +	/* reset the pci device */
> > +	pci_reset_function(dev);
> > +
> > +	return 0;
> > +}
> > +
> > +static int
> > +igbuio_pci_release(struct uio_info *info, struct inode *inode)
> > +{
> > +	struct rte_uio_pci_dev *udev = info->priv;
> > +	struct pci_dev *dev = udev->pdev;
> > +
> > +	/* try to reset the pci device */
> > +	pci_try_reset_function(dev);
> > +
> > +	return 0;
> > +}
> > +
> >  #ifdef CONFIG_XEN_DOM0
> >  static int
> >  igbuio_dom0_mmap_phys(struct uio_info *info, struct vm_area_struct *vma)
> > @@ -372,6 +400,8 @@ struct rte_uio_pci_dev {
> >  	udev->info.version = "0.1";
> >  	udev->info.handler = igbuio_pci_irqhandler;
> >  	udev->info.irqcontrol = igbuio_pci_irqcontrol;
> > +	udev->info.open = igbuio_pci_open;
> > +	udev->info.release = igbuio_pci_release;
> >  #ifdef CONFIG_XEN_DOM0
> >  	/* check if the driver run on Xen Dom0 */
> >  	if (xen_initial_domain())
> > 
> 
>
  
Jianfeng Tan June 5, 2017, 2:29 a.m. UTC | #8
Hi Gregory,


On 6/4/2017 3:22 PM, Gregory Etelson wrote:
>
> In my environment I could reproduce server crash
>
> after applying the patch
>

Different from your patch, my patch calls 
pci_enable_device()/pci_disable_device() instead of 
pci_reset_function()/pci_try_reset_function() separately in open() and 
release(). Could you check if that's the reason?

vfio_pci actually calls both pci_try_reset_function() and 
pci_disable_device() in release().

Thanks,
Jianfeng

> Regards,
>
> Gregory
>
> On Wednesday, 31 May 2017 15:20:08 IDT Ferruh Yigit wrote:
>
> > On 5/31/2017 12:09 PM, Shijith Thotton wrote:
>
> > > Set UIO info device file operations open and release. Call pci reset
>
> > > function inside open and release to clear device state at start and
>
> > > end. Copied this behaviour from vfio_pci kernel module code. With this
>
> > > change, it is not mandatory to issue FLR by PMD's during init and 
> close.
>
> >
>
> > Cc: Jianfeng Tan <jianfeng.tan@intel.com>
>
> >
>
> > Jianfeng also implemented following patch:
>
> > http://dpdk.org/dev/patchwork/patch/17495/
>
> >
>
> > Which also implements release and open ops, for slightly different
>
> > reason (prevent DMA access after app exit), but mainly both are to
>
> > gracefully handle application exit status.
>
> >
>
> > btw, for Jianfeng's case, can adding pci_clear_master() in release and
>
> > moving pci_set_master() to open help preventing unwanted DMA?
>
> >
>
> >
>
> > Gregory,
>
> >
>
> > Can you please check if this patch fixes your issue?
>
> >
>
> > Thanks,
>
> > ferruh
>
> >
>
> > >
>
> > > Signed-off-by: Shijith Thotton <shijith.thotton@caviumnetworks.com>
>
> > > ---
>
> > > lib/librte_eal/linuxapp/igb_uio/igb_uio.c | 30 
> ++++++++++++++++++++++++++++++
>
> > > 1 file changed, 30 insertions(+)
>
> > >
>
> > > diff --git a/lib/librte_eal/linuxapp/igb_uio/igb_uio.c 
> b/lib/librte_eal/linuxapp/igb_uio/igb_uio.c
>
> > > index b9d427c..5bc58d2 100644
>
> > > --- a/lib/librte_eal/linuxapp/igb_uio/igb_uio.c
>
> > > +++ b/lib/librte_eal/linuxapp/igb_uio/igb_uio.c
>
> > > @@ -170,6 +170,34 @@ struct rte_uio_pci_dev {
>
> > > return IRQ_HANDLED;
>
> > > }
>
> > >
>
> > > +/**
>
> > > + * This gets called while opening uio device file. It clears any 
> previous state
>
> > > + * associated with the pci device.
>
> > > + */
>
> > > +static int
>
> > > +igbuio_pci_open(struct uio_info *info, struct inode *inode)
>
> > > +{
>
> > > + struct rte_uio_pci_dev *udev = info->priv;
>
> > > + struct pci_dev *dev = udev->pdev;
>
> > > +
>
> > > + /* reset the pci device */
>
> > > + pci_reset_function(dev);
>
> > > +
>
> > > + return 0;
>
> > > +}
>
> > > +
>
> > > +static int
>
> > > +igbuio_pci_release(struct uio_info *info, struct inode *inode)
>
> > > +{
>
> > > + struct rte_uio_pci_dev *udev = info->priv;
>
> > > + struct pci_dev *dev = udev->pdev;
>
> > > +
>
> > > + /* try to reset the pci device */
>
> > > + pci_try_reset_function(dev);
>
> > > +
>
> > > + return 0;
>
> > > +}
>
> > > +
>
> > > #ifdef CONFIG_XEN_DOM0
>
> > > static int
>
> > > igbuio_dom0_mmap_phys(struct uio_info *info, struct vm_area_struct 
> *vma)
>
> > > @@ -372,6 +400,8 @@ struct rte_uio_pci_dev {
>
> > > udev->info.version = "0.1";
>
> > > udev->info.handler = igbuio_pci_irqhandler;
>
> > > udev->info.irqcontrol = igbuio_pci_irqcontrol;
>
> > > + udev->info.open = igbuio_pci_open;
>
> > > + udev->info.release = igbuio_pci_release;
>
> > > #ifdef CONFIG_XEN_DOM0
>
> > > /* check if the driver run on Xen Dom0 */
>
> > > if (xen_initial_domain())
>
> > >
>
> >
>
> >
>
  
Gregory Etelson June 5, 2017, 5:57 a.m. UTC | #9
Hello Jianfeng,

I was experimenting with pci_disable_device() in release
Tests running on Intel 82599 VF crashed server after process down,
before a new instance was started.
Tests running on Intel XL710 VF did not crash server, but could not send / receive Ethernet frames
although all DPDK initialization routines completed without errors

Regards,
Gregory



    
Hi Gregory,        
On 6/4/2017 3:22 PM, Gregory Etelson      wrote:        
                        
In my environment I could reproduce server crash       
after applying the patch            Different from your patch, my patch calls    pci_enable_device()/pci_disable_device() instead of    pci_reset_function()/pci_try_reset_function() separately in open()    and release(). Could you check if that's the reason?        vfio_pci actually calls both pci_try_reset_function() and    pci_disable_device() in release().        Thanks,    Jianfeng        
      
      
Regards,      
Gregory      
      
      
On Wednesday, 31 May 2017 15:20:08 IDT Ferruh Yigit wrote:      
> On 5/31/2017 12:09 PM, Shijith Thotton wrote:      
> > Set UIO info device file operations open and release. Call pci reset      
> > function inside open and release to clear device state at start and      
> > end. Copied this behaviour from vfio_pci kernel module code. With this      
> > change, it is not mandatory to issue FLR by PMD's during init and close.      
>       
> Cc: Jianfeng Tan <jianfeng.tan@intel.com>[1]      
>       
> Jianfeng also implemented following patch:      
> http://dpdk.org/dev/patchwork/patch/17495/[2]      
>       
> Which also implements release and open ops, for slightly different      
> reason (prevent DMA access after app exit), but mainly both are to      
> gracefully handle application exit status.      
>       
> btw, for Jianfeng's case, can adding pci_clear_master() in release and      
> moving pci_set_master() to open help preventing unwanted DMA?      
>       
>       
> Gregory,      
>       
> Can you please check if this patch fixes your issue?      
>       
> Thanks,      
> ferruh      
>       
> >       
> > Signed-off-by: Shijith Thotton <shijith.thotton@caviumnetworks.com>[3]      
> > ---      
> >  lib/librte_eal/linuxapp/igb_uio/igb_uio.c | 30 ++++++++++++++++++++++++++++++      
> >  1 file changed, 30 insertions(+)      
> >       
> > diff --git a/lib/librte_eal/linuxapp/igb_uio/igb_uio.c b/lib/librte_eal/linuxapp/igb_uio/igb_uio.c      
> > index b9d427c..5bc58d2 100644      
> > --- a/lib/librte_eal/linuxapp/igb_uio/igb_uio.c      
> > +++ b/lib/librte_eal/linuxapp/igb_uio/igb_uio.c      
> > @@ -170,6 +170,34 @@ struct rte_uio_pci_dev {      
> >  	return IRQ_HANDLED;      
> >  }      
> >        
> > +/**      
> > + * This gets called while opening uio device file. It clears any previous state      
> > + * associated with the pci device.      
> > + */      
> > +static int      
> > +igbuio_pci_open(struct uio_info *info, struct inode *inode)      
> > +{      
> > +	struct rte_uio_pci_dev *udev = info->priv;      
> > +	struct pci_dev *dev = udev->pdev;      
> > +      
> > +	/* reset the pci device */      
> > +	pci_reset_function(dev);      
> > +      
> > +	return 0;      
> > +}      
> > +      
> > +static int      
> > +igbuio_pci_release(struct uio_info *info, struct inode *inode)      
> > +{      
> > +	struct rte_uio_pci_dev *udev = info->priv;      
> > +	struct pci_dev *dev = udev->pdev;      
> > +      
> > +	/* try to reset the pci device */      
> > +	pci_try_reset_function(dev);      
> > +      
> > +	return 0;      
> > +}      
> > +      
> >  #ifdef CONFIG_XEN_DOM0      
> >  static int      
> >  igbuio_dom0_mmap_phys(struct uio_info *info, struct vm_area_struct *vma)      
> > @@ -372,6 +400,8 @@ struct rte_uio_pci_dev {      
> >  	udev->info.version = "0.1";      
> >  	udev->info.handler = igbuio_pci_irqhandler;      
> >  	udev->info.irqcontrol = igbuio_pci_irqcontrol;      
> > +	udev->info.open = igbuio_pci_open;      
> > +	udev->info.release = igbuio_pci_release;      
> >  #ifdef CONFIG_XEN_DOM0      
> >  	/* check if the driver run on Xen Dom0 */      
> >  	if (xen_initial_domain())      
> >       
>       
>       
          



--------
[1] mailto:jianfeng.tan@intel.com
[2] http://dpdk.org/dev/patchwork/patch/17495/
[3] mailto:shijith.thotton@caviumnetworks.com
  

Patch

diff --git a/lib/librte_eal/linuxapp/igb_uio/igb_uio.c b/lib/librte_eal/linuxapp/igb_uio/igb_uio.c
index b9d427c..5bc58d2 100644
--- a/lib/librte_eal/linuxapp/igb_uio/igb_uio.c
+++ b/lib/librte_eal/linuxapp/igb_uio/igb_uio.c
@@ -170,6 +170,34 @@  struct rte_uio_pci_dev {
 	return IRQ_HANDLED;
 }
 
+/**
+ * This gets called while opening uio device file. It clears any previous state
+ * associated with the pci device.
+ */
+static int
+igbuio_pci_open(struct uio_info *info, struct inode *inode)
+{
+	struct rte_uio_pci_dev *udev = info->priv;
+	struct pci_dev *dev = udev->pdev;
+
+	/* reset the pci device */
+	pci_reset_function(dev);
+
+	return 0;
+}
+
+static int
+igbuio_pci_release(struct uio_info *info, struct inode *inode)
+{
+	struct rte_uio_pci_dev *udev = info->priv;
+	struct pci_dev *dev = udev->pdev;
+
+	/* try to reset the pci device */
+	pci_try_reset_function(dev);
+
+	return 0;
+}
+
 #ifdef CONFIG_XEN_DOM0
 static int
 igbuio_dom0_mmap_phys(struct uio_info *info, struct vm_area_struct *vma)
@@ -372,6 +400,8 @@  struct rte_uio_pci_dev {
 	udev->info.version = "0.1";
 	udev->info.handler = igbuio_pci_irqhandler;
 	udev->info.irqcontrol = igbuio_pci_irqcontrol;
+	udev->info.open = igbuio_pci_open;
+	udev->info.release = igbuio_pci_release;
 #ifdef CONFIG_XEN_DOM0
 	/* check if the driver run on Xen Dom0 */
 	if (xen_initial_domain())