Commit 83ac51fa authored by Dhananjay Phadke's avatar Dhananjay Phadke Committed by David S. Miller

netxen: annotate dma watchdog setup

o remove superfluous code to setup PCI dma watchdog for NX2031.
o disable dma watchdog completely for NX3031 (not required).
Signed-off-by: default avatarDhananjay Phadke <dhananjay@netxen.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent ca2ef330
...@@ -1324,24 +1324,6 @@ struct netxen_adapter { ...@@ -1324,24 +1324,6 @@ struct netxen_adapter {
const struct firmware *fw; const struct firmware *fw;
}; };
/*
* NetXen dma watchdog control structure
*
* Bit 0 : enabled => R/O: 1 watchdog active, 0 inactive
* Bit 1 : disable_request => 1 req disable dma watchdog
* Bit 2 : enable_request => 1 req enable dma watchdog
* Bit 3-31 : unused
*/
#define netxen_set_dma_watchdog_disable_req(config_word) \
_netxen_set_bits(config_word, 1, 1, 1)
#define netxen_set_dma_watchdog_enable_req(config_word) \
_netxen_set_bits(config_word, 2, 1, 1)
#define netxen_get_dma_watchdog_enabled(config_word) \
((config_word) & 0x1)
#define netxen_get_dma_watchdog_disabled(config_word) \
(((config_word) >> 1) & 0x1)
int netxen_niu_xgbe_enable_phy_interrupts(struct netxen_adapter *adapter); int netxen_niu_xgbe_enable_phy_interrupts(struct netxen_adapter *adapter);
int netxen_niu_gbe_enable_phy_interrupts(struct netxen_adapter *adapter); int netxen_niu_gbe_enable_phy_interrupts(struct netxen_adapter *adapter);
int netxen_niu_xgbe_disable_phy_interrupts(struct netxen_adapter *adapter); int netxen_niu_xgbe_disable_phy_interrupts(struct netxen_adapter *adapter);
...@@ -1402,8 +1384,9 @@ unsigned long netxen_nic_pci_set_window_2M(struct netxen_adapter *adapter, ...@@ -1402,8 +1384,9 @@ unsigned long netxen_nic_pci_set_window_2M(struct netxen_adapter *adapter,
unsigned long long addr); unsigned long long addr);
/* Functions from netxen_nic_init.c */ /* Functions from netxen_nic_init.c */
void netxen_free_adapter_offload(struct netxen_adapter *adapter); int netxen_init_dummy_dma(struct netxen_adapter *adapter);
int netxen_initialize_adapter_offload(struct netxen_adapter *adapter); void netxen_free_dummy_dma(struct netxen_adapter *adapter);
int netxen_phantom_init(struct netxen_adapter *adapter, int pegtune_val); int netxen_phantom_init(struct netxen_adapter *adapter, int pegtune_val);
int netxen_load_firmware(struct netxen_adapter *adapter); int netxen_load_firmware(struct netxen_adapter *adapter);
int netxen_need_fw_reset(struct netxen_adapter *adapter); int netxen_need_fw_reset(struct netxen_adapter *adapter);
...@@ -1510,56 +1493,6 @@ static inline void get_brd_name_by_type(u32 type, char *name) ...@@ -1510,56 +1493,6 @@ static inline void get_brd_name_by_type(u32 type, char *name)
name = "Unknown"; name = "Unknown";
} }
static inline int
dma_watchdog_shutdown_request(struct netxen_adapter *adapter)
{
u32 ctrl;
/* check if already inactive */
ctrl = adapter->hw_read_wx(adapter,
NETXEN_CAM_RAM(NETXEN_CAM_RAM_DMA_WATCHDOG_CTRL));
if (netxen_get_dma_watchdog_enabled(ctrl) == 0)
return 1;
/* Send the disable request */
netxen_set_dma_watchdog_disable_req(ctrl);
NXWR32(adapter, NETXEN_CAM_RAM(NETXEN_CAM_RAM_DMA_WATCHDOG_CTRL), ctrl);
return 0;
}
static inline int
dma_watchdog_shutdown_poll_result(struct netxen_adapter *adapter)
{
u32 ctrl;
ctrl = adapter->hw_read_wx(adapter,
NETXEN_CAM_RAM(NETXEN_CAM_RAM_DMA_WATCHDOG_CTRL));
return (netxen_get_dma_watchdog_enabled(ctrl) == 0);
}
static inline int
dma_watchdog_wakeup(struct netxen_adapter *adapter)
{
u32 ctrl;
ctrl = adapter->hw_read_wx(adapter,
NETXEN_CAM_RAM(NETXEN_CAM_RAM_DMA_WATCHDOG_CTRL));
if (netxen_get_dma_watchdog_enabled(ctrl))
return 1;
/* send the wakeup request */
netxen_set_dma_watchdog_enable_req(ctrl);
NXWR32(adapter, NETXEN_CAM_RAM(NETXEN_CAM_RAM_DMA_WATCHDOG_CTRL), ctrl);
return 0;
}
static inline u32 netxen_tx_avail(struct nx_host_tx_ring *tx_ring) static inline u32 netxen_tx_avail(struct nx_host_tx_ring *tx_ring)
{ {
smp_mb(); smp_mb();
......
...@@ -852,7 +852,7 @@ enum { ...@@ -852,7 +852,7 @@ enum {
#define NX_PEG_TUNE_MN_PRESENT 0x1 #define NX_PEG_TUNE_MN_PRESENT 0x1
#define NX_PEG_TUNE_CAPABILITY (NETXEN_CAM_RAM(0x02c)) #define NX_PEG_TUNE_CAPABILITY (NETXEN_CAM_RAM(0x02c))
#define NETXEN_CAM_RAM_DMA_WATCHDOG_CTRL (0x14) #define NETXEN_DMA_WATCHDOG_CTRL (NETXEN_CAM_RAM(0x14))
#define NETXEN_PEG_ALIVE_COUNTER (NETXEN_CAM_RAM(0xb0)) #define NETXEN_PEG_ALIVE_COUNTER (NETXEN_CAM_RAM(0xb0))
#define ISR_MSI_INT_TRIGGER(FUNC) (NETXEN_PCIX_PS_REG(PCIX_MSI_F(FUNC))) #define ISR_MSI_INT_TRIGGER(FUNC) (NETXEN_PCIX_PS_REG(PCIX_MSI_F(FUNC)))
......
...@@ -954,19 +954,20 @@ netxen_release_firmware(struct netxen_adapter *adapter) ...@@ -954,19 +954,20 @@ netxen_release_firmware(struct netxen_adapter *adapter)
release_firmware(adapter->fw); release_firmware(adapter->fw);
} }
int netxen_initialize_adapter_offload(struct netxen_adapter *adapter) int netxen_init_dummy_dma(struct netxen_adapter *adapter)
{ {
uint64_t addr; u64 addr;
uint32_t hi; u32 hi, lo;
uint32_t lo;
adapter->dummy_dma.addr = if (!NX_IS_REVISION_P2(adapter->ahw.revision_id))
pci_alloc_consistent(adapter->pdev, return 0;
adapter->dummy_dma.addr = pci_alloc_consistent(adapter->pdev,
NETXEN_HOST_DUMMY_DMA_SIZE, NETXEN_HOST_DUMMY_DMA_SIZE,
&adapter->dummy_dma.phys_addr); &adapter->dummy_dma.phys_addr);
if (adapter->dummy_dma.addr == NULL) { if (adapter->dummy_dma.addr == NULL) {
printk("%s: ERROR: Could not allocate dummy DMA memory\n", dev_err(&adapter->pdev->dev,
__func__); "ERROR: Could not allocate dummy DMA memory\n");
return -ENOMEM; return -ENOMEM;
} }
...@@ -977,29 +978,41 @@ int netxen_initialize_adapter_offload(struct netxen_adapter *adapter) ...@@ -977,29 +978,41 @@ int netxen_initialize_adapter_offload(struct netxen_adapter *adapter)
NXWR32(adapter, CRB_HOST_DUMMY_BUF_ADDR_HI, hi); NXWR32(adapter, CRB_HOST_DUMMY_BUF_ADDR_HI, hi);
NXWR32(adapter, CRB_HOST_DUMMY_BUF_ADDR_LO, lo); NXWR32(adapter, CRB_HOST_DUMMY_BUF_ADDR_LO, lo);
if (NX_IS_REVISION_P3(adapter->ahw.revision_id)) {
uint32_t temp = 0;
NXWR32(adapter, CRB_HOST_DUMMY_BUF, temp);
}
return 0; return 0;
} }
void netxen_free_adapter_offload(struct netxen_adapter *adapter) /*
* NetXen DMA watchdog control:
*
* Bit 0 : enabled => R/O: 1 watchdog active, 0 inactive
* Bit 1 : disable_request => 1 req disable dma watchdog
* Bit 2 : enable_request => 1 req enable dma watchdog
* Bit 3-31 : unused
*/
void netxen_free_dummy_dma(struct netxen_adapter *adapter)
{ {
int i = 100; int i = 100;
u32 ctrl;
if (!NX_IS_REVISION_P2(adapter->ahw.revision_id))
return;
if (!adapter->dummy_dma.addr) if (!adapter->dummy_dma.addr)
return; return;
if (NX_IS_REVISION_P2(adapter->ahw.revision_id)) { ctrl = NXRD32(adapter, NETXEN_DMA_WATCHDOG_CTRL);
do { if ((ctrl & 0x1) != 0) {
if (dma_watchdog_shutdown_request(adapter) == 1) NXWR32(adapter, NETXEN_DMA_WATCHDOG_CTRL, (ctrl | 0x2));
break;
while ((ctrl & 0x1) != 0) {
msleep(50); msleep(50);
if (dma_watchdog_shutdown_poll_result(adapter) == 1)
ctrl = NXRD32(adapter, NETXEN_DMA_WATCHDOG_CTRL);
if (--i == 0)
break; break;
} while (--i); };
} }
if (i) { if (i) {
...@@ -1008,10 +1021,8 @@ void netxen_free_adapter_offload(struct netxen_adapter *adapter) ...@@ -1008,10 +1021,8 @@ void netxen_free_adapter_offload(struct netxen_adapter *adapter)
adapter->dummy_dma.addr, adapter->dummy_dma.addr,
adapter->dummy_dma.phys_addr); adapter->dummy_dma.phys_addr);
adapter->dummy_dma.addr = NULL; adapter->dummy_dma.addr = NULL;
} else { } else
printk(KERN_ERR "%s: dma_watchdog_shutdown failed\n", dev_err(&adapter->pdev->dev, "dma_watchdog_shutdown failed\n");
adapter->netdev->name);
}
} }
int netxen_phantom_init(struct netxen_adapter *adapter, int pegtune_val) int netxen_phantom_init(struct netxen_adapter *adapter, int pegtune_val)
......
...@@ -745,7 +745,7 @@ netxen_start_firmware(struct netxen_adapter *adapter, int request_fw) ...@@ -745,7 +745,7 @@ netxen_start_firmware(struct netxen_adapter *adapter, int request_fw)
} }
err = netxen_initialize_adapter_offload(adapter); err = netxen_init_dummy_dma(adapter);
if (err) if (err)
return err; return err;
...@@ -761,7 +761,7 @@ netxen_start_firmware(struct netxen_adapter *adapter, int request_fw) ...@@ -761,7 +761,7 @@ netxen_start_firmware(struct netxen_adapter *adapter, int request_fw)
/* Handshake with the card before we register the devices. */ /* Handshake with the card before we register the devices. */
err = netxen_phantom_init(adapter, NETXEN_NIC_PEG_TUNE); err = netxen_phantom_init(adapter, NETXEN_NIC_PEG_TUNE);
if (err) { if (err) {
netxen_free_adapter_offload(adapter); netxen_free_dummy_dma(adapter);
return err; return err;
} }
...@@ -1154,7 +1154,7 @@ netxen_nic_probe(struct pci_dev *pdev, const struct pci_device_id *ent) ...@@ -1154,7 +1154,7 @@ netxen_nic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
err_out_disable_msi: err_out_disable_msi:
netxen_teardown_intr(adapter); netxen_teardown_intr(adapter);
netxen_free_adapter_offload(adapter); netxen_free_dummy_dma(adapter);
err_out_iounmap: err_out_iounmap:
netxen_cleanup_pci_map(adapter); netxen_cleanup_pci_map(adapter);
...@@ -1189,7 +1189,7 @@ static void __devexit netxen_nic_remove(struct pci_dev *pdev) ...@@ -1189,7 +1189,7 @@ static void __devexit netxen_nic_remove(struct pci_dev *pdev)
} }
if (adapter->portnum == 0) if (adapter->portnum == 0)
netxen_free_adapter_offload(adapter); netxen_free_dummy_dma(adapter);
netxen_teardown_intr(adapter); netxen_teardown_intr(adapter);
netxen_free_sds_rings(&adapter->recv_ctx); netxen_free_sds_rings(&adapter->recv_ctx);
......
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