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

netxen: separate register and memory access lock

Since register and onboard memory access has separate
window registers, they need not be kept under same lock.

Also, memory is always accessed from process context
(mostly for firmware init and diagnostic tools).
Signed-off-by: default avatarDhananjay Phadke <dhananjay@netxen.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 907fa120
...@@ -551,6 +551,9 @@ struct netxen_hardware_context { ...@@ -551,6 +551,9 @@ struct netxen_hardware_context {
u32 ocm_win; u32 ocm_win;
u32 crb_win; u32 crb_win;
rwlock_t crb_lock;
spinlock_t mem_lock;
u8 cut_through; u8 cut_through;
u8 revision_id; u8 revision_id;
u8 pci_func; u8 pci_func;
...@@ -1115,8 +1118,6 @@ struct netxen_adapter { ...@@ -1115,8 +1118,6 @@ struct netxen_adapter {
struct pci_dev *pdev; struct pci_dev *pdev;
struct list_head mac_list; struct list_head mac_list;
rwlock_t adapter_lock;
spinlock_t tx_clean_lock; spinlock_t tx_clean_lock;
u16 num_txd; u16 num_txd;
......
...@@ -85,11 +85,9 @@ netxen_nic_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *drvinfo) ...@@ -85,11 +85,9 @@ netxen_nic_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *drvinfo)
strncpy(drvinfo->driver, netxen_nic_driver_name, 32); strncpy(drvinfo->driver, netxen_nic_driver_name, 32);
strncpy(drvinfo->version, NETXEN_NIC_LINUX_VERSIONID, 32); strncpy(drvinfo->version, NETXEN_NIC_LINUX_VERSIONID, 32);
read_lock(&adapter->adapter_lock);
fw_major = NXRD32(adapter, NETXEN_FW_VERSION_MAJOR); fw_major = NXRD32(adapter, NETXEN_FW_VERSION_MAJOR);
fw_minor = NXRD32(adapter, NETXEN_FW_VERSION_MINOR); fw_minor = NXRD32(adapter, NETXEN_FW_VERSION_MINOR);
fw_build = NXRD32(adapter, NETXEN_FW_VERSION_SUB); fw_build = NXRD32(adapter, NETXEN_FW_VERSION_SUB);
read_unlock(&adapter->adapter_lock);
sprintf(drvinfo->fw_version, "%d.%d.%d", fw_major, fw_minor, fw_build); sprintf(drvinfo->fw_version, "%d.%d.%d", fw_major, fw_minor, fw_build);
strncpy(drvinfo->bus_info, pci_name(adapter->pdev), 32); strncpy(drvinfo->bus_info, pci_name(adapter->pdev), 32);
......
...@@ -41,6 +41,11 @@ ...@@ -41,6 +41,11 @@
#define CRB_HI(off) ((crb_hub_agt[CRB_BLK(off)] << 20) | ((off) & 0xf0000)) #define CRB_HI(off) ((crb_hub_agt[CRB_BLK(off)] << 20) | ((off) & 0xf0000))
#define CRB_INDIRECT_2M (0x1e0000UL) #define CRB_INDIRECT_2M (0x1e0000UL)
static void netxen_nic_io_write_128M(struct netxen_adapter *adapter,
void __iomem *addr, u32 data);
static u32 netxen_nic_io_read_128M(struct netxen_adapter *adapter,
void __iomem *addr);
#ifndef readq #ifndef readq
static inline u64 readq(void __iomem *addr) static inline u64 readq(void __iomem *addr)
{ {
...@@ -1164,17 +1169,15 @@ netxen_nic_hw_write_wx_128M(struct netxen_adapter *adapter, ulong off, u32 data) ...@@ -1164,17 +1169,15 @@ netxen_nic_hw_write_wx_128M(struct netxen_adapter *adapter, ulong off, u32 data)
BUG_ON(!addr); BUG_ON(!addr);
if (ADDR_IN_WINDOW1(off)) { /* Window 1 */ if (ADDR_IN_WINDOW1(off)) { /* Window 1 */
read_lock(&adapter->adapter_lock); netxen_nic_io_write_128M(adapter, addr, data);
writel(data, addr);
read_unlock(&adapter->adapter_lock);
} else { /* Window 0 */ } else { /* Window 0 */
write_lock_irqsave(&adapter->adapter_lock, flags); write_lock_irqsave(&adapter->ahw.crb_lock, flags);
addr = pci_base_offset(adapter, off); addr = pci_base_offset(adapter, off);
netxen_nic_pci_set_crbwindow_128M(adapter, 0); netxen_nic_pci_set_crbwindow_128M(adapter, 0);
writel(data, addr); writel(data, addr);
netxen_nic_pci_set_crbwindow_128M(adapter, netxen_nic_pci_set_crbwindow_128M(adapter,
NETXEN_WINDOW_ONE); NETXEN_WINDOW_ONE);
write_unlock_irqrestore(&adapter->adapter_lock, flags); write_unlock_irqrestore(&adapter->ahw.crb_lock, flags);
} }
return 0; return 0;
...@@ -1195,16 +1198,14 @@ netxen_nic_hw_read_wx_128M(struct netxen_adapter *adapter, ulong off) ...@@ -1195,16 +1198,14 @@ netxen_nic_hw_read_wx_128M(struct netxen_adapter *adapter, ulong off)
BUG_ON(!addr); BUG_ON(!addr);
if (ADDR_IN_WINDOW1(off)) { /* Window 1 */ if (ADDR_IN_WINDOW1(off)) { /* Window 1 */
read_lock(&adapter->adapter_lock); data = netxen_nic_io_read_128M(adapter, addr);
data = readl(addr);
read_unlock(&adapter->adapter_lock);
} else { /* Window 0 */ } else { /* Window 0 */
write_lock_irqsave(&adapter->adapter_lock, flags); write_lock_irqsave(&adapter->ahw.crb_lock, flags);
netxen_nic_pci_set_crbwindow_128M(adapter, 0); netxen_nic_pci_set_crbwindow_128M(adapter, 0);
data = readl(addr); data = readl(addr);
netxen_nic_pci_set_crbwindow_128M(adapter, netxen_nic_pci_set_crbwindow_128M(adapter,
NETXEN_WINDOW_ONE); NETXEN_WINDOW_ONE);
write_unlock_irqrestore(&adapter->adapter_lock, flags); write_unlock_irqrestore(&adapter->ahw.crb_lock, flags);
} }
return data; return data;
...@@ -1226,12 +1227,12 @@ netxen_nic_hw_write_wx_2M(struct netxen_adapter *adapter, ulong off, u32 data) ...@@ -1226,12 +1227,12 @@ netxen_nic_hw_write_wx_2M(struct netxen_adapter *adapter, ulong off, u32 data)
} }
if (rv == 1) { if (rv == 1) {
write_lock_irqsave(&adapter->adapter_lock, flags); write_lock_irqsave(&adapter->ahw.crb_lock, flags);
crb_win_lock(adapter); crb_win_lock(adapter);
netxen_nic_pci_set_crbwindow_2M(adapter, &off); netxen_nic_pci_set_crbwindow_2M(adapter, &off);
writel(data, (void __iomem *)off); writel(data, (void __iomem *)off);
crb_win_unlock(adapter); crb_win_unlock(adapter);
write_unlock_irqrestore(&adapter->adapter_lock, flags); write_unlock_irqrestore(&adapter->ahw.crb_lock, flags);
} else } else
writel(data, (void __iomem *)off); writel(data, (void __iomem *)off);
...@@ -1256,12 +1257,12 @@ netxen_nic_hw_read_wx_2M(struct netxen_adapter *adapter, ulong off) ...@@ -1256,12 +1257,12 @@ netxen_nic_hw_read_wx_2M(struct netxen_adapter *adapter, ulong off)
} }
if (rv == 1) { if (rv == 1) {
write_lock_irqsave(&adapter->adapter_lock, flags); write_lock_irqsave(&adapter->ahw.crb_lock, flags);
crb_win_lock(adapter); crb_win_lock(adapter);
netxen_nic_pci_set_crbwindow_2M(adapter, &off); netxen_nic_pci_set_crbwindow_2M(adapter, &off);
data = readl((void __iomem *)off); data = readl((void __iomem *)off);
crb_win_unlock(adapter); crb_win_unlock(adapter);
write_unlock_irqrestore(&adapter->adapter_lock, flags); write_unlock_irqrestore(&adapter->ahw.crb_lock, flags);
} else } else
data = readl((void __iomem *)off); data = readl((void __iomem *)off);
...@@ -1272,9 +1273,9 @@ netxen_nic_hw_read_wx_2M(struct netxen_adapter *adapter, ulong off) ...@@ -1272,9 +1273,9 @@ netxen_nic_hw_read_wx_2M(struct netxen_adapter *adapter, ulong off)
static void netxen_nic_io_write_128M(struct netxen_adapter *adapter, static void netxen_nic_io_write_128M(struct netxen_adapter *adapter,
void __iomem *addr, u32 data) void __iomem *addr, u32 data)
{ {
read_lock(&adapter->adapter_lock); read_lock(&adapter->ahw.crb_lock);
writel(data, addr); writel(data, addr);
read_unlock(&adapter->adapter_lock); read_unlock(&adapter->ahw.crb_lock);
} }
static u32 netxen_nic_io_read_128M(struct netxen_adapter *adapter, static u32 netxen_nic_io_read_128M(struct netxen_adapter *adapter,
...@@ -1282,9 +1283,9 @@ static u32 netxen_nic_io_read_128M(struct netxen_adapter *adapter, ...@@ -1282,9 +1283,9 @@ static u32 netxen_nic_io_read_128M(struct netxen_adapter *adapter,
{ {
u32 val; u32 val;
read_lock(&adapter->adapter_lock); read_lock(&adapter->ahw.crb_lock);
val = readl(addr); val = readl(addr);
read_unlock(&adapter->adapter_lock); read_unlock(&adapter->ahw.crb_lock);
return val; return val;
} }
...@@ -1366,11 +1367,10 @@ netxen_nic_pci_mem_access_direct(struct netxen_adapter *adapter, u64 off, ...@@ -1366,11 +1367,10 @@ netxen_nic_pci_mem_access_direct(struct netxen_adapter *adapter, u64 off,
{ {
void __iomem *addr, *mem_ptr = NULL; void __iomem *addr, *mem_ptr = NULL;
resource_size_t mem_base; resource_size_t mem_base;
unsigned long flags;
int ret = -EIO; int ret = -EIO;
u32 start; u32 start;
write_lock_irqsave(&adapter->adapter_lock, flags); spin_lock(&adapter->ahw.mem_lock);
ret = adapter->pci_set_window(adapter, off, &start); ret = adapter->pci_set_window(adapter, off, &start);
if (ret != 0) if (ret != 0)
...@@ -1397,7 +1397,8 @@ netxen_nic_pci_mem_access_direct(struct netxen_adapter *adapter, u64 off, ...@@ -1397,7 +1397,8 @@ netxen_nic_pci_mem_access_direct(struct netxen_adapter *adapter, u64 off,
writeq(*data, addr); writeq(*data, addr);
unlock: unlock:
write_unlock_irqrestore(&adapter->adapter_lock, flags); spin_unlock(&adapter->ahw.mem_lock);
if (mem_ptr) if (mem_ptr)
iounmap(mem_ptr); iounmap(mem_ptr);
return ret; return ret;
...@@ -1409,7 +1410,6 @@ static int ...@@ -1409,7 +1410,6 @@ static int
netxen_nic_pci_mem_write_128M(struct netxen_adapter *adapter, netxen_nic_pci_mem_write_128M(struct netxen_adapter *adapter,
u64 off, u64 data) u64 off, u64 data)
{ {
unsigned long flags;
int j, ret; int j, ret;
u32 temp, off_lo, off_hi, addr_hi, data_hi, data_lo; u32 temp, off_lo, off_hi, addr_hi, data_hi, data_lo;
void __iomem *mem_crb; void __iomem *mem_crb;
...@@ -1453,7 +1453,7 @@ netxen_nic_pci_mem_write_128M(struct netxen_adapter *adapter, ...@@ -1453,7 +1453,7 @@ netxen_nic_pci_mem_write_128M(struct netxen_adapter *adapter,
return -EIO; return -EIO;
correct: correct:
write_lock_irqsave(&adapter->adapter_lock, flags); spin_lock(&adapter->ahw.mem_lock);
netxen_nic_pci_set_crbwindow_128M(adapter, 0); netxen_nic_pci_set_crbwindow_128M(adapter, 0);
writel(off_lo, (mem_crb + MIU_TEST_AGT_ADDR_LO)); writel(off_lo, (mem_crb + MIU_TEST_AGT_ADDR_LO));
...@@ -1479,7 +1479,7 @@ netxen_nic_pci_mem_write_128M(struct netxen_adapter *adapter, ...@@ -1479,7 +1479,7 @@ netxen_nic_pci_mem_write_128M(struct netxen_adapter *adapter,
ret = 0; ret = 0;
netxen_nic_pci_set_crbwindow_128M(adapter, NETXEN_WINDOW_ONE); netxen_nic_pci_set_crbwindow_128M(adapter, NETXEN_WINDOW_ONE);
write_unlock_irqrestore(&adapter->adapter_lock, flags); spin_unlock(&adapter->ahw.mem_lock);
return ret; return ret;
} }
...@@ -1487,7 +1487,6 @@ static int ...@@ -1487,7 +1487,6 @@ static int
netxen_nic_pci_mem_read_128M(struct netxen_adapter *adapter, netxen_nic_pci_mem_read_128M(struct netxen_adapter *adapter,
u64 off, u64 *data) u64 off, u64 *data)
{ {
unsigned long flags;
int j, ret; int j, ret;
u32 temp, off_lo, off_hi, addr_hi, data_hi, data_lo; u32 temp, off_lo, off_hi, addr_hi, data_hi, data_lo;
u64 val; u64 val;
...@@ -1532,7 +1531,7 @@ netxen_nic_pci_mem_read_128M(struct netxen_adapter *adapter, ...@@ -1532,7 +1531,7 @@ netxen_nic_pci_mem_read_128M(struct netxen_adapter *adapter,
return -EIO; return -EIO;
correct: correct:
write_lock_irqsave(&adapter->adapter_lock, flags); spin_lock(&adapter->ahw.mem_lock);
netxen_nic_pci_set_crbwindow_128M(adapter, 0); netxen_nic_pci_set_crbwindow_128M(adapter, 0);
writel(off_lo, (mem_crb + MIU_TEST_AGT_ADDR_LO)); writel(off_lo, (mem_crb + MIU_TEST_AGT_ADDR_LO));
...@@ -1561,7 +1560,7 @@ netxen_nic_pci_mem_read_128M(struct netxen_adapter *adapter, ...@@ -1561,7 +1560,7 @@ netxen_nic_pci_mem_read_128M(struct netxen_adapter *adapter,
} }
netxen_nic_pci_set_crbwindow_128M(adapter, NETXEN_WINDOW_ONE); netxen_nic_pci_set_crbwindow_128M(adapter, NETXEN_WINDOW_ONE);
write_unlock_irqrestore(&adapter->adapter_lock, flags); spin_unlock(&adapter->ahw.mem_lock);
return ret; return ret;
} }
...@@ -1570,7 +1569,6 @@ static int ...@@ -1570,7 +1569,6 @@ static int
netxen_nic_pci_mem_write_2M(struct netxen_adapter *adapter, netxen_nic_pci_mem_write_2M(struct netxen_adapter *adapter,
u64 off, u64 data) u64 off, u64 data)
{ {
unsigned long flags;
int j, ret; int j, ret;
u32 temp, off8; u32 temp, off8;
void __iomem *mem_crb; void __iomem *mem_crb;
...@@ -1601,7 +1599,7 @@ netxen_nic_pci_mem_write_2M(struct netxen_adapter *adapter, ...@@ -1601,7 +1599,7 @@ netxen_nic_pci_mem_write_2M(struct netxen_adapter *adapter,
correct: correct:
off8 = off & MIU_TEST_AGT_ADDR_MASK; off8 = off & MIU_TEST_AGT_ADDR_MASK;
write_lock_irqsave(&adapter->adapter_lock, flags); spin_lock(&adapter->ahw.mem_lock);
writel(off8, (mem_crb + MIU_TEST_AGT_ADDR_LO)); writel(off8, (mem_crb + MIU_TEST_AGT_ADDR_LO));
writel(0, (mem_crb + MIU_TEST_AGT_ADDR_HI)); writel(0, (mem_crb + MIU_TEST_AGT_ADDR_HI));
...@@ -1625,7 +1623,7 @@ netxen_nic_pci_mem_write_2M(struct netxen_adapter *adapter, ...@@ -1625,7 +1623,7 @@ netxen_nic_pci_mem_write_2M(struct netxen_adapter *adapter,
} else } else
ret = 0; ret = 0;
write_unlock_irqrestore(&adapter->adapter_lock, flags); spin_unlock(&adapter->ahw.mem_lock);
return ret; return ret;
} }
...@@ -1634,7 +1632,6 @@ static int ...@@ -1634,7 +1632,6 @@ static int
netxen_nic_pci_mem_read_2M(struct netxen_adapter *adapter, netxen_nic_pci_mem_read_2M(struct netxen_adapter *adapter,
u64 off, u64 *data) u64 off, u64 *data)
{ {
unsigned long flags;
int j, ret; int j, ret;
u32 temp, off8; u32 temp, off8;
u64 val; u64 val;
...@@ -1668,7 +1665,7 @@ netxen_nic_pci_mem_read_2M(struct netxen_adapter *adapter, ...@@ -1668,7 +1665,7 @@ netxen_nic_pci_mem_read_2M(struct netxen_adapter *adapter,
correct: correct:
off8 = off & MIU_TEST_AGT_ADDR_MASK; off8 = off & MIU_TEST_AGT_ADDR_MASK;
write_lock_irqsave(&adapter->adapter_lock, flags); spin_lock(&adapter->ahw.mem_lock);
writel(off8, (mem_crb + MIU_TEST_AGT_ADDR_LO)); writel(off8, (mem_crb + MIU_TEST_AGT_ADDR_LO));
writel(0, (mem_crb + MIU_TEST_AGT_ADDR_HI)); writel(0, (mem_crb + MIU_TEST_AGT_ADDR_HI));
...@@ -1694,7 +1691,7 @@ netxen_nic_pci_mem_read_2M(struct netxen_adapter *adapter, ...@@ -1694,7 +1691,7 @@ netxen_nic_pci_mem_read_2M(struct netxen_adapter *adapter,
ret = 0; ret = 0;
} }
write_unlock_irqrestore(&adapter->adapter_lock, flags); spin_unlock(&adapter->ahw.mem_lock);
return ret; return ret;
} }
......
...@@ -1513,10 +1513,8 @@ netxen_post_rx_buffers(struct netxen_adapter *adapter, u32 ringid, ...@@ -1513,10 +1513,8 @@ netxen_post_rx_buffers(struct netxen_adapter *adapter, u32 ringid,
(rds_ring->num_desc - 1))); (rds_ring->num_desc - 1)));
netxen_set_msg_ctxid(msg, adapter->portnum); netxen_set_msg_ctxid(msg, adapter->portnum);
netxen_set_msg_opcode(msg, NETXEN_RCV_PRODUCER(ringid)); netxen_set_msg_opcode(msg, NETXEN_RCV_PRODUCER(ringid));
read_lock(&adapter->adapter_lock); NXWRIO(adapter, DB_NORMALIZE(adapter,
writel(msg, DB_NORMALIZE(adapter, NETXEN_RCV_PRODUCER_OFFSET), msg);
NETXEN_RCV_PRODUCER_OFFSET));
read_unlock(&adapter->adapter_lock);
} }
} }
} }
......
...@@ -1240,7 +1240,9 @@ netxen_nic_probe(struct pci_dev *pdev, const struct pci_device_id *ent) ...@@ -1240,7 +1240,9 @@ netxen_nic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
revision_id = pdev->revision; revision_id = pdev->revision;
adapter->ahw.revision_id = revision_id; adapter->ahw.revision_id = revision_id;
rwlock_init(&adapter->adapter_lock); rwlock_init(&adapter->ahw.crb_lock);
spin_lock_init(&adapter->ahw.mem_lock);
spin_lock_init(&adapter->tx_clean_lock); spin_lock_init(&adapter->tx_clean_lock);
INIT_LIST_HEAD(&adapter->mac_list); INIT_LIST_HEAD(&adapter->mac_list);
......
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