Commit 3fb43eb2 authored by Yuval Mintz's avatar Yuval Mintz Committed by David S. Miller

bnx2x: Change to D3hot only on removal

This changes the PCI power management scheme of the bnx2x driver to be similar
to those of most network drivers - the driver will now changes the power state
into D3hot whenever the driver will be removed, instead of whenever an
interface is unloaded.

This change enables the driver to access its eeprom via ethtool callbacks
even when interfaces are unloaded (such access requires the function to be
in D0active).
Signed-off-by: default avatarYuval Mintz <yuvalmin@broadcom.com>
Signed-off-by: default avatarAriel Elior <ariele@broadcom.com>
Signed-off-by: default avatarEilon Greenstein <eilong@broadcom.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent b030ed2f
...@@ -1381,12 +1381,28 @@ static int bnx2x_nvram_read32(struct bnx2x *bp, u32 offset, u32 *buf, ...@@ -1381,12 +1381,28 @@ static int bnx2x_nvram_read32(struct bnx2x *bp, u32 offset, u32 *buf,
return rc; return rc;
} }
static bool bnx2x_is_nvm_accessible(struct bnx2x *bp)
{
int rc = 1;
u16 pm = 0;
struct net_device *dev = pci_get_drvdata(bp->pdev);
if (bp->pm_cap)
rc = pci_read_config_word(bp->pdev,
bp->pm_cap + PCI_PM_CTRL, &pm);
if ((rc && !netif_running(dev)) || (!rc && ((pm & PCI_D0) != PCI_D0)))
return false;
return true;
}
static int bnx2x_get_eeprom(struct net_device *dev, static int bnx2x_get_eeprom(struct net_device *dev,
struct ethtool_eeprom *eeprom, u8 *eebuf) struct ethtool_eeprom *eeprom, u8 *eebuf)
{ {
struct bnx2x *bp = netdev_priv(dev); struct bnx2x *bp = netdev_priv(dev);
if (!netif_running(dev)) { if (!bnx2x_is_nvm_accessible(bp)) {
DP(BNX2X_MSG_ETHTOOL | BNX2X_MSG_NVM, DP(BNX2X_MSG_ETHTOOL | BNX2X_MSG_NVM,
"cannot access eeprom when the interface is down\n"); "cannot access eeprom when the interface is down\n");
return -EAGAIN; return -EAGAIN;
...@@ -1411,7 +1427,7 @@ static int bnx2x_get_module_eeprom(struct net_device *dev, ...@@ -1411,7 +1427,7 @@ static int bnx2x_get_module_eeprom(struct net_device *dev,
u8 *user_data = data; u8 *user_data = data;
unsigned int start_addr = ee->offset, xfer_size = 0; unsigned int start_addr = ee->offset, xfer_size = 0;
if (!netif_running(dev)) { if (!bnx2x_is_nvm_accessible(bp)) {
DP(BNX2X_MSG_ETHTOOL | BNX2X_MSG_NVM, DP(BNX2X_MSG_ETHTOOL | BNX2X_MSG_NVM,
"cannot access eeprom when the interface is down\n"); "cannot access eeprom when the interface is down\n");
return -EAGAIN; return -EAGAIN;
...@@ -1474,7 +1490,7 @@ static int bnx2x_get_module_info(struct net_device *dev, ...@@ -1474,7 +1490,7 @@ static int bnx2x_get_module_info(struct net_device *dev,
int phy_idx, rc; int phy_idx, rc;
u8 sff8472_comp, diag_type; u8 sff8472_comp, diag_type;
if (!netif_running(dev)) { if (!bnx2x_is_nvm_accessible(bp)) {
DP(BNX2X_MSG_ETHTOOL | BNX2X_MSG_NVM, DP(BNX2X_MSG_ETHTOOL | BNX2X_MSG_NVM,
"cannot access eeprom when the interface is down\n"); "cannot access eeprom when the interface is down\n");
return -EAGAIN; return -EAGAIN;
...@@ -1676,7 +1692,8 @@ static int bnx2x_set_eeprom(struct net_device *dev, ...@@ -1676,7 +1692,8 @@ static int bnx2x_set_eeprom(struct net_device *dev,
int port = BP_PORT(bp); int port = BP_PORT(bp);
int rc = 0; int rc = 0;
u32 ext_phy_config; u32 ext_phy_config;
if (!netif_running(dev)) {
if (!bnx2x_is_nvm_accessible(bp)) {
DP(BNX2X_MSG_ETHTOOL | BNX2X_MSG_NVM, DP(BNX2X_MSG_ETHTOOL | BNX2X_MSG_NVM,
"cannot access eeprom when the interface is down\n"); "cannot access eeprom when the interface is down\n");
return -EAGAIN; return -EAGAIN;
...@@ -2173,7 +2190,7 @@ static int bnx2x_test_registers(struct bnx2x *bp) ...@@ -2173,7 +2190,7 @@ static int bnx2x_test_registers(struct bnx2x *bp)
{ BNX2X_CHIP_MASK_ALL, 0xffffffff, 0, 0x00000000 } { BNX2X_CHIP_MASK_ALL, 0xffffffff, 0, 0x00000000 }
}; };
if (!netif_running(bp->dev)) { if (!bnx2x_is_nvm_accessible(bp)) {
DP(BNX2X_MSG_ETHTOOL | BNX2X_MSG_NVM, DP(BNX2X_MSG_ETHTOOL | BNX2X_MSG_NVM,
"cannot access eeprom when the interface is down\n"); "cannot access eeprom when the interface is down\n");
return rc; return rc;
...@@ -2277,7 +2294,7 @@ static int bnx2x_test_memory(struct bnx2x *bp) ...@@ -2277,7 +2294,7 @@ static int bnx2x_test_memory(struct bnx2x *bp)
{ NULL, 0xffffffff, {0, 0, 0, 0} } { NULL, 0xffffffff, {0, 0, 0, 0} }
}; };
if (!netif_running(bp->dev)) { if (!bnx2x_is_nvm_accessible(bp)) {
DP(BNX2X_MSG_ETHTOOL | BNX2X_MSG_NVM, DP(BNX2X_MSG_ETHTOOL | BNX2X_MSG_NVM,
"cannot access eeprom when the interface is down\n"); "cannot access eeprom when the interface is down\n");
return rc; return rc;
...@@ -3140,7 +3157,7 @@ static int bnx2x_set_phys_id(struct net_device *dev, ...@@ -3140,7 +3157,7 @@ static int bnx2x_set_phys_id(struct net_device *dev,
{ {
struct bnx2x *bp = netdev_priv(dev); struct bnx2x *bp = netdev_priv(dev);
if (!netif_running(dev)) { if (!bnx2x_is_nvm_accessible(bp)) {
DP(BNX2X_MSG_ETHTOOL | BNX2X_MSG_NVM, DP(BNX2X_MSG_ETHTOOL | BNX2X_MSG_NVM,
"cannot access eeprom when the interface is down\n"); "cannot access eeprom when the interface is down\n");
return -EAGAIN; return -EAGAIN;
......
...@@ -11643,9 +11643,6 @@ static int bnx2x_close(struct net_device *dev) ...@@ -11643,9 +11643,6 @@ static int bnx2x_close(struct net_device *dev)
/* Unload the driver, release IRQs */ /* Unload the driver, release IRQs */
bnx2x_nic_unload(bp, UNLOAD_CLOSE, false); bnx2x_nic_unload(bp, UNLOAD_CLOSE, false);
/* Power off */
bnx2x_set_power_state(bp, PCI_D3hot);
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment