aboutsummaryrefslogtreecommitdiff
path: root/drivers/net/ehea/ehea_main.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/ehea/ehea_main.c')
-rw-r--r--drivers/net/ehea/ehea_main.c114
1 files changed, 68 insertions, 46 deletions
diff --git a/drivers/net/ehea/ehea_main.c b/drivers/net/ehea/ehea_main.c
index 07c742dd3f0..9ff7538b759 100644
--- a/drivers/net/ehea/ehea_main.c
+++ b/drivers/net/ehea/ehea_main.c
@@ -36,6 +36,7 @@
#include <linux/notifier.h>
#include <linux/reboot.h>
#include <asm/kexec.h>
+#include <linux/mutex.h>
#include <net/ip.h>
@@ -99,7 +100,7 @@ static int port_name_cnt;
static LIST_HEAD(adapter_list);
u64 ehea_driver_flags;
struct work_struct ehea_rereg_mr_task;
-struct semaphore dlpar_mem_lock;
+static DEFINE_MUTEX(dlpar_mem_lock);
struct ehea_fw_handle_array ehea_fw_handles;
struct ehea_bcmc_reg_array ehea_bcmc_regs;
@@ -349,7 +350,8 @@ static void ehea_refill_rq1(struct ehea_port_res *pr, int index, int nr_of_wqes)
pr->rq1_skba.os_skbs = 0;
if (unlikely(test_bit(__EHEA_STOP_XFER, &ehea_driver_flags))) {
- pr->rq1_skba.index = index;
+ if (nr_of_wqes > 0)
+ pr->rq1_skba.index = index;
pr->rq1_skba.os_skbs = fill_wqes;
return;
}
@@ -1464,7 +1466,9 @@ static int ehea_init_port_res(struct ehea_port *port, struct ehea_port_res *pr,
init_attr->act_nr_rwqes_rq2,
init_attr->act_nr_rwqes_rq3);
- ret = ehea_init_q_skba(&pr->sq_skba, init_attr->act_nr_send_wqes + 1);
+ pr->sq_skba_size = init_attr->act_nr_send_wqes + 1;
+
+ ret = ehea_init_q_skba(&pr->sq_skba, pr->sq_skba_size);
ret |= ehea_init_q_skba(&pr->rq1_skba, init_attr->act_nr_rwqes_rq1 + 1);
ret |= ehea_init_q_skba(&pr->rq2_skba, init_attr->act_nr_rwqes_rq2 + 1);
ret |= ehea_init_q_skba(&pr->rq3_skba, init_attr->act_nr_rwqes_rq3 + 1);
@@ -1758,7 +1762,7 @@ static int ehea_set_mac_addr(struct net_device *dev, void *sa)
memcpy(dev->dev_addr, mac_addr->sa_data, dev->addr_len);
- down(&ehea_bcmc_regs.lock);
+ mutex_lock(&ehea_bcmc_regs.lock);
/* Deregister old MAC in pHYP */
ret = ehea_broadcast_reg_helper(port, H_DEREG_BCMC);
@@ -1776,7 +1780,7 @@ static int ehea_set_mac_addr(struct net_device *dev, void *sa)
out_upregs:
ehea_update_bcmc_registrations();
- up(&ehea_bcmc_regs.lock);
+ mutex_unlock(&ehea_bcmc_regs.lock);
out_free:
kfree(cb0);
out:
@@ -1938,7 +1942,7 @@ static void ehea_set_multicast_list(struct net_device *dev)
}
ehea_promiscuous(dev, 0);
- down(&ehea_bcmc_regs.lock);
+ mutex_lock(&ehea_bcmc_regs.lock);
if (dev->flags & IFF_ALLMULTI) {
ehea_allmulti(dev, 1);
@@ -1969,7 +1973,7 @@ static void ehea_set_multicast_list(struct net_device *dev)
}
out:
ehea_update_bcmc_registrations();
- up(&ehea_bcmc_regs.lock);
+ mutex_unlock(&ehea_bcmc_regs.lock);
return;
}
@@ -2452,7 +2456,7 @@ static int ehea_up(struct net_device *dev)
if (port->state == EHEA_PORT_UP)
return 0;
- down(&ehea_fw_handles.lock);
+ mutex_lock(&ehea_fw_handles.lock);
ret = ehea_port_res_setup(port, port->num_def_qps,
port->num_add_tx_qps);
@@ -2490,7 +2494,7 @@ static int ehea_up(struct net_device *dev)
}
}
- down(&ehea_bcmc_regs.lock);
+ mutex_lock(&ehea_bcmc_regs.lock);
ret = ehea_broadcast_reg_helper(port, H_REG_BCMC);
if (ret) {
@@ -2513,10 +2517,10 @@ out:
ehea_info("Failed starting %s. ret=%i", dev->name, ret);
ehea_update_bcmc_registrations();
- up(&ehea_bcmc_regs.lock);
+ mutex_unlock(&ehea_bcmc_regs.lock);
ehea_update_firmware_handles();
- up(&ehea_fw_handles.lock);
+ mutex_unlock(&ehea_fw_handles.lock);
return ret;
}
@@ -2542,7 +2546,7 @@ static int ehea_open(struct net_device *dev)
int ret;
struct ehea_port *port = netdev_priv(dev);
- down(&port->port_lock);
+ mutex_lock(&port->port_lock);
if (netif_msg_ifup(port))
ehea_info("enabling port %s", dev->name);
@@ -2553,7 +2557,7 @@ static int ehea_open(struct net_device *dev)
netif_start_queue(dev);
}
- up(&port->port_lock);
+ mutex_unlock(&port->port_lock);
return ret;
}
@@ -2566,18 +2570,18 @@ static int ehea_down(struct net_device *dev)
if (port->state == EHEA_PORT_DOWN)
return 0;
- down(&ehea_bcmc_regs.lock);
+ mutex_lock(&ehea_fw_handles.lock);
+
+ mutex_lock(&ehea_bcmc_regs.lock);
ehea_drop_multicast_list(dev);
ehea_broadcast_reg_helper(port, H_DEREG_BCMC);
ehea_free_interrupts(dev);
- down(&ehea_fw_handles.lock);
-
port->state = EHEA_PORT_DOWN;
ehea_update_bcmc_registrations();
- up(&ehea_bcmc_regs.lock);
+ mutex_unlock(&ehea_bcmc_regs.lock);
ret = ehea_clean_all_portres(port);
if (ret)
@@ -2585,7 +2589,7 @@ static int ehea_down(struct net_device *dev)
dev->name, ret);
ehea_update_firmware_handles();
- up(&ehea_fw_handles.lock);
+ mutex_unlock(&ehea_fw_handles.lock);
return ret;
}
@@ -2599,11 +2603,11 @@ static int ehea_stop(struct net_device *dev)
ehea_info("disabling port %s", dev->name);
flush_scheduled_work();
- down(&port->port_lock);
+ mutex_lock(&port->port_lock);
netif_stop_queue(dev);
port_napi_disable(port);
ret = ehea_down(dev);
- up(&port->port_lock);
+ mutex_unlock(&port->port_lock);
return ret;
}
@@ -2621,6 +2625,22 @@ void ehea_purge_sq(struct ehea_qp *orig_qp)
}
}
+void ehea_flush_sq(struct ehea_port *port)
+{
+ int i;
+
+ for (i = 0; i < port->num_def_qps + port->num_add_tx_qps; i++) {
+ struct ehea_port_res *pr = &port->port_res[i];
+ int swqe_max = pr->sq_skba_size - 2 - pr->swqe_ll_count;
+ int k = 0;
+ while (atomic_read(&pr->swqe_avail) < swqe_max) {
+ msleep(5);
+ if (++k == 20)
+ break;
+ }
+ }
+}
+
int ehea_stop_qps(struct net_device *dev)
{
struct ehea_port *port = netdev_priv(dev);
@@ -2801,7 +2821,7 @@ static void ehea_reset_port(struct work_struct *work)
struct net_device *dev = port->netdev;
port->resets++;
- down(&port->port_lock);
+ mutex_lock(&port->port_lock);
netif_stop_queue(dev);
port_napi_disable(port);
@@ -2821,7 +2841,7 @@ static void ehea_reset_port(struct work_struct *work)
netif_wake_queue(dev);
out:
- up(&port->port_lock);
+ mutex_unlock(&port->port_lock);
return;
}
@@ -2830,7 +2850,7 @@ static void ehea_rereg_mrs(struct work_struct *work)
int ret, i;
struct ehea_adapter *adapter;
- down(&dlpar_mem_lock);
+ mutex_lock(&dlpar_mem_lock);
ehea_info("LPAR memory enlarged - re-initializing driver");
list_for_each_entry(adapter, &adapter_list, list)
@@ -2838,21 +2858,24 @@ static void ehea_rereg_mrs(struct work_struct *work)
/* Shutdown all ports */
for (i = 0; i < EHEA_MAX_PORTS; i++) {
struct ehea_port *port = adapter->port[i];
+ struct net_device *dev;
- if (port) {
- struct net_device *dev = port->netdev;
+ if (!port)
+ continue;
- if (dev->flags & IFF_UP) {
- down(&port->port_lock);
- netif_stop_queue(dev);
- ret = ehea_stop_qps(dev);
- if (ret) {
- up(&port->port_lock);
- goto out;
- }
- port_napi_disable(port);
- up(&port->port_lock);
+ dev = port->netdev;
+
+ if (dev->flags & IFF_UP) {
+ mutex_lock(&port->port_lock);
+ netif_stop_queue(dev);
+ ehea_flush_sq(port);
+ ret = ehea_stop_qps(dev);
+ if (ret) {
+ mutex_unlock(&port->port_lock);
+ goto out;
}
+ port_napi_disable(port);
+ mutex_unlock(&port->port_lock);
}
}
@@ -2892,17 +2915,17 @@ static void ehea_rereg_mrs(struct work_struct *work)
struct net_device *dev = port->netdev;
if (dev->flags & IFF_UP) {
- down(&port->port_lock);
+ mutex_lock(&port->port_lock);
port_napi_enable(port);
ret = ehea_restart_qps(dev);
if (!ret)
netif_wake_queue(dev);
- up(&port->port_lock);
+ mutex_unlock(&port->port_lock);
}
}
}
}
- up(&dlpar_mem_lock);
+ mutex_unlock(&dlpar_mem_lock);
ehea_info("re-initializing driver complete");
out:
return;
@@ -3063,7 +3086,7 @@ struct ehea_port *ehea_setup_single_port(struct ehea_adapter *adapter,
port = netdev_priv(dev);
- sema_init(&port->port_lock, 1);
+ mutex_init(&port->port_lock);
port->state = EHEA_PORT_DOWN;
port->sig_comp_iv = sq_entries / 10;
@@ -3342,7 +3365,7 @@ static int __devinit ehea_probe_adapter(struct of_device *dev,
ehea_error("Invalid ibmebus device probed");
return -EINVAL;
}
- down(&ehea_fw_handles.lock);
+ mutex_lock(&ehea_fw_handles.lock);
adapter = kzalloc(sizeof(*adapter), GFP_KERNEL);
if (!adapter) {
@@ -3426,7 +3449,7 @@ out_free_ad:
out:
ehea_update_firmware_handles();
- up(&ehea_fw_handles.lock);
+ mutex_unlock(&ehea_fw_handles.lock);
return ret;
}
@@ -3445,7 +3468,7 @@ static int __devexit ehea_remove(struct of_device *dev)
flush_scheduled_work();
- down(&ehea_fw_handles.lock);
+ mutex_lock(&ehea_fw_handles.lock);
ibmebus_free_irq(adapter->neq->attr.ist1, adapter);
tasklet_kill(&adapter->neq_tasklet);
@@ -3456,7 +3479,7 @@ static int __devexit ehea_remove(struct of_device *dev)
kfree(adapter);
ehea_update_firmware_handles();
- up(&ehea_fw_handles.lock);
+ mutex_unlock(&ehea_fw_handles.lock);
return 0;
}
@@ -3543,9 +3566,8 @@ int __init ehea_module_init(void)
memset(&ehea_fw_handles, 0, sizeof(ehea_fw_handles));
memset(&ehea_bcmc_regs, 0, sizeof(ehea_bcmc_regs));
- sema_init(&dlpar_mem_lock, 1);
- sema_init(&ehea_fw_handles.lock, 1);
- sema_init(&ehea_bcmc_regs.lock, 1);
+ mutex_init(&ehea_fw_handles.lock);
+ mutex_init(&ehea_bcmc_regs.lock);
ret = check_module_parm();
if (ret)