ixgbe: make sure FCoE DDP user buffers are really released by the HW
authorYi Zou <yi.zou@intel.com>
Wed, 17 Nov 2010 03:27:14 +0000 (19:27 -0800)
committerJeff Kirsher <jeffrey.t.kirsher@intel.com>
Wed, 17 Nov 2010 03:27:14 +0000 (19:27 -0800)
When invalidating the DDP context is invalidated, the HW may not be done
with the user buffer right away. In which case, we poll the FCBUFF register
to check if the buffer valid bit is cleared or not, if not, we wait for max
100us that is guaranteed by the HW.

Signed-off-by: Yi Zou <yi.zou@intel.com>
Tested-by: Ross Brattain <ross.b.brattain@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
drivers/net/ixgbe/ixgbe_fcoe.c

index 26dd27479e2c6cc82cbca0317cae8b405653eb8d..6342d4859790804a83981f65175d7653bb3f19a5 100644 (file)
@@ -92,6 +92,7 @@ int ixgbe_fcoe_ddp_put(struct net_device *netdev, u16 xid)
        struct ixgbe_fcoe *fcoe;
        struct ixgbe_adapter *adapter;
        struct ixgbe_fcoe_ddp *ddp;
+       u32 fcbuff;
 
        if (!netdev)
                goto out_ddp_put;
@@ -115,7 +116,14 @@ int ixgbe_fcoe_ddp_put(struct net_device *netdev, u16 xid)
                IXGBE_WRITE_REG(&adapter->hw, IXGBE_FCBUFF, 0);
                IXGBE_WRITE_REG(&adapter->hw, IXGBE_FCDMARW,
                                (xid | IXGBE_FCDMARW_WE));
+
+               /* guaranteed to be invalidated after 100us */
+               IXGBE_WRITE_REG(&adapter->hw, IXGBE_FCDMARW,
+                               (xid | IXGBE_FCDMARW_RE));
+               fcbuff = IXGBE_READ_REG(&adapter->hw, IXGBE_FCBUFF);
                spin_unlock_bh(&fcoe->lock);
+               if (fcbuff & IXGBE_FCBUFF_VALID)
+                       udelay(100);
        }
        if (ddp->sgl)
                pci_unmap_sg(adapter->pdev, ddp->sgl, ddp->sgc,