diff mbox

[net-next,16/20] fm10k: check if PCIe link is restored

Message ID 1469053438-85381-17-git-send-email-jeffrey.t.kirsher@intel.com
State Accepted, archived
Delegated to: David Miller
Headers show

Commit Message

Kirsher, Jeffrey T July 20, 2016, 10:23 p.m. UTC
From: Jacob Keller <jacob.e.keller@intel.com>

Sometimes, a VF driver will lose PCIe address access, such as due to
a PF FLR event. In fm10k_detach_subtask, poll and check whether the
PCIe register space is active again and restore the device when it has.

Signed-off-by: Jacob Keller <jacob.e.keller@intel.com>
Tested-by: Krishneil Singh <Krishneil.k.singh@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
---
 drivers/net/ethernet/intel/fm10k/fm10k_pci.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

Comments

Sergei Shtylyov July 21, 2016, 10:51 a.m. UTC | #1
Hello.

On 7/21/2016 1:23 AM, Jeff Kirsher wrote:

> From: Jacob Keller <jacob.e.keller@intel.com>
>
> Sometimes, a VF driver will lose PCIe address access, such as due to
> a PF FLR event. In fm10k_detach_subtask, poll and check whether the
> PCIe register space is active again and restore the device when it has.
>
> Signed-off-by: Jacob Keller <jacob.e.keller@intel.com>
> Tested-by: Krishneil Singh <Krishneil.k.singh@intel.com>
> Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
> ---
>  drivers/net/ethernet/intel/fm10k/fm10k_pci.c | 13 +++++++++++++
>  1 file changed, 13 insertions(+)
>
> diff --git a/drivers/net/ethernet/intel/fm10k/fm10k_pci.c b/drivers/net/ethernet/intel/fm10k/fm10k_pci.c
> index 5e40460..d4ccb2a 100644
> --- a/drivers/net/ethernet/intel/fm10k/fm10k_pci.c
> +++ b/drivers/net/ethernet/intel/fm10k/fm10k_pci.c
> @@ -123,11 +123,24 @@ static void fm10k_service_timer(unsigned long data)
>  static void fm10k_detach_subtask(struct fm10k_intfc *interface)
>  {
>  	struct net_device *netdev = interface->netdev;
> +	u32 __iomem *hw_addr;
> +	u32 value;
>
>  	/* do nothing if device is still present or hw_addr is set */
>  	if (netif_device_present(netdev) || interface->hw.hw_addr)
>  		return;
>
> +	/* check the real address space to see if we've recovered */
> +	hw_addr = READ_ONCE(interface->uc_addr);
> +	value = readl(hw_addr);
> +	if ((~value)) {

    Why these double parens?

[...]

MBR, Sergei
Jacob Keller July 21, 2016, 8:13 p.m. UTC | #2
On Thu, 2016-07-21 at 13:51 +0300, Sergei Shtylyov wrote:
> Hello.

> 

> On 7/21/2016 1:23 AM, Jeff Kirsher wrote:

> 

> > From: Jacob Keller <jacob.e.keller@intel.com>

> > 

> > Sometimes, a VF driver will lose PCIe address access, such as due

> > to

> > a PF FLR event. In fm10k_detach_subtask, poll and check whether the

> > PCIe register space is active again and restore the device when it

> > has.

> > 

> > Signed-off-by: Jacob Keller <jacob.e.keller@intel.com>

> > Tested-by: Krishneil Singh <Krishneil.k.singh@intel.com>

> > Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>

> > ---

> >  drivers/net/ethernet/intel/fm10k/fm10k_pci.c | 13 +++++++++++++

> >  1 file changed, 13 insertions(+)

> > 

> > diff --git a/drivers/net/ethernet/intel/fm10k/fm10k_pci.c

> > b/drivers/net/ethernet/intel/fm10k/fm10k_pci.c

> > index 5e40460..d4ccb2a 100644

> > --- a/drivers/net/ethernet/intel/fm10k/fm10k_pci.c

> > +++ b/drivers/net/ethernet/intel/fm10k/fm10k_pci.c

> > @@ -123,11 +123,24 @@ static void fm10k_service_timer(unsigned long

> > data)

> >  static void fm10k_detach_subtask(struct fm10k_intfc *interface)

> >  {

> >  	struct net_device *netdev = interface->netdev;

> > +	u32 __iomem *hw_addr;

> > +	u32 value;

> > 

> >  	/* do nothing if device is still present or hw_addr is set

> > */

> >  	if (netif_device_present(netdev) || interface->hw.hw_addr)

> >  		return;

> > 

> > +	/* check the real address space to see if we've recovered

> > */

> > +	hw_addr = READ_ONCE(interface->uc_addr);

> > +	value = readl(hw_addr);

> > +	if ((~value)) {

> 

>     Why these double parens?

> 


You're right it doesn't need them. I think at one point the check was
"!(~value)" in some other portion of code, and likely got copied by
mistake.

Thanks,
Jake

> [...]

> 

> MBR, Sergei

>
diff mbox

Patch

diff --git a/drivers/net/ethernet/intel/fm10k/fm10k_pci.c b/drivers/net/ethernet/intel/fm10k/fm10k_pci.c
index 5e40460..d4ccb2a 100644
--- a/drivers/net/ethernet/intel/fm10k/fm10k_pci.c
+++ b/drivers/net/ethernet/intel/fm10k/fm10k_pci.c
@@ -123,11 +123,24 @@  static void fm10k_service_timer(unsigned long data)
 static void fm10k_detach_subtask(struct fm10k_intfc *interface)
 {
 	struct net_device *netdev = interface->netdev;
+	u32 __iomem *hw_addr;
+	u32 value;
 
 	/* do nothing if device is still present or hw_addr is set */
 	if (netif_device_present(netdev) || interface->hw.hw_addr)
 		return;
 
+	/* check the real address space to see if we've recovered */
+	hw_addr = READ_ONCE(interface->uc_addr);
+	value = readl(hw_addr);
+	if ((~value)) {
+		interface->hw.hw_addr = interface->uc_addr;
+		netif_device_attach(netdev);
+		interface->flags |= FM10K_FLAG_RESET_REQUESTED;
+		netdev_warn(netdev, "PCIe link restored, device now attached\n");
+		return;
+	}
+
 	rtnl_lock();
 
 	if (netif_running(netdev))