[PATCH 1/5] net: ehea: semaphore to mutex - Kernel

This is a discussion on [PATCH 1/5] net: ehea: semaphore to mutex - Kernel ; -- Content-Disposition: inline; filename=net-ehea-dlpar_mem_lock-semaphore-to-mutex.patch Converted the dlpar_mem_lock. With a bit of cleanup, I converted to DEFINE_MUTEX() instead of a runtime init. I also made the lock static. Signed-off-by: Daniel Walker --- drivers/net/ehea/ehea_main.c | 8 ++++---- 1 file changed, 4 insertions(+), ...

+ Reply to Thread
Results 1 to 4 of 4

Thread: [PATCH 1/5] net: ehea: semaphore to mutex

  1. [PATCH 1/5] net: ehea: semaphore to mutex

    --
    Content-Disposition: inline; filename=net-ehea-dlpar_mem_lock-semaphore-to-mutex.patch

    Converted the dlpar_mem_lock. With a bit of cleanup, I converted to
    DEFINE_MUTEX() instead of a runtime init. I also made the lock static.

    Signed-off-by: Daniel Walker

    ---
    drivers/net/ehea/ehea_main.c | 8 ++++----
    1 file changed, 4 insertions(+), 4 deletions(-)

    Index: linux-2.6.24/drivers/net/ehea/ehea_main.c
    ================================================== =================
    --- linux-2.6.24.orig/drivers/net/ehea/ehea_main.c
    +++ linux-2.6.24/drivers/net/ehea/ehea_main.c
    @@ -36,6 +36,7 @@
    #include
    #include
    #include
    +#include

    #include

    @@ -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;

    @@ -2830,7 +2831,7 @@ static void ehea_rereg_mrs(struct work_s
    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)
    @@ -2902,7 +2903,7 @@ static void ehea_rereg_mrs(struct work_s
    }
    }
    }
    - up(&dlpar_mem_lock);
    + mutex_unlock(&dlpar_mem_lock);
    ehea_info("re-initializing driver complete");
    out:
    return;
    @@ -3543,7 +3544,6 @@ 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);


    --
    --
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/

  2. [PATCH 2/5] net: ehea: ehea_fw_handles semaphore to mutex

    --
    Content-Disposition: inline; filename=net-ehea-fw_handles-semaphore-to-mutex.patch

    Converted the ehea_fw_handles.lock to a mutex.

    Signed-off-by: Daniel Walker

    ---
    drivers/net/ehea/ehea.h | 2 +-
    drivers/net/ehea/ehea_main.c | 18 +++++++++---------
    2 files changed, 10 insertions(+), 10 deletions(-)

    Index: linux-2.6.24/drivers/net/ehea/ehea.h
    ================================================== =================
    --- linux-2.6.24.orig/drivers/net/ehea/ehea.h
    +++ linux-2.6.24/drivers/net/ehea/ehea.h
    @@ -421,7 +421,7 @@ struct ehea_fw_handle_entry {
    struct ehea_fw_handle_array {
    struct ehea_fw_handle_entry *arr;
    int num_entries;
    - struct semaphore lock;
    + struct mutex lock;
    };

    struct ehea_bcmc_reg_entry {
    Index: linux-2.6.24/drivers/net/ehea/ehea_main.c
    ================================================== =================
    --- linux-2.6.24.orig/drivers/net/ehea/ehea_main.c
    +++ linux-2.6.24/drivers/net/ehea/ehea_main.c
    @@ -2453,7 +2453,7 @@ static int ehea_up(struct net_device *de
    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);
    @@ -2517,7 +2517,7 @@ out:
    up(&ehea_bcmc_regs.lock);

    ehea_update_firmware_handles();
    - up(&ehea_fw_handles.lock);
    + mutex_unlock(&ehea_fw_handles.lock);

    return ret;
    }
    @@ -2573,7 +2573,7 @@ static int ehea_down(struct net_device *

    ehea_free_interrupts(dev);

    - down(&ehea_fw_handles.lock);
    + mutex_lock(&ehea_fw_handles.lock);

    port->state = EHEA_PORT_DOWN;

    @@ -2586,7 +2586,7 @@ static int ehea_down(struct net_device *
    dev->name, ret);

    ehea_update_firmware_handles();
    - up(&ehea_fw_handles.lock);
    + mutex_unlock(&ehea_fw_handles.lock);

    return ret;
    }
    @@ -3343,7 +3343,7 @@ static int __devinit ehea_probe_adapter(
    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) {
    @@ -3427,7 +3427,7 @@ out_free_ad:

    out:
    ehea_update_firmware_handles();
    - up(&ehea_fw_handles.lock);
    + mutex_unlock(&ehea_fw_handles.lock);
    return ret;
    }

    @@ -3446,7 +3446,7 @@ static int __devexit ehea_remove(struct

    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);
    @@ -3457,7 +3457,7 @@ static int __devexit ehea_remove(struct
    kfree(adapter);

    ehea_update_firmware_handles();
    - up(&ehea_fw_handles.lock);
    + mutex_unlock(&ehea_fw_handles.lock);

    return 0;
    }
    @@ -3544,7 +3544,7 @@ 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(&ehea_fw_handles.lock, 1);
    + mutex_init(&ehea_fw_handles.lock);
    sema_init(&ehea_bcmc_regs.lock, 1);

    ret = check_module_parm();

    --
    --
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/

  3. [PATCH 4/5] net: ehea: bcmc_regs semaphore to mutex

    --
    Content-Disposition: inline; filename=net-ehea-bcmc_regs-semaphore-to-mutex.patch

    Convert the ehea_bcmb_regs.lock to a mutex.

    Signed-off-by: Daniel Walker

    ---
    drivers/net/ehea/ehea.h | 2 +-
    drivers/net/ehea/ehea_main.c | 18 +++++++++---------
    2 files changed, 10 insertions(+), 10 deletions(-)

    Index: linux-2.6.24/drivers/net/ehea/ehea.h
    ================================================== =================
    --- linux-2.6.24.orig/drivers/net/ehea/ehea.h
    +++ linux-2.6.24/drivers/net/ehea/ehea.h
    @@ -434,7 +434,7 @@ struct ehea_bcmc_reg_entry {
    struct ehea_bcmc_reg_array {
    struct ehea_bcmc_reg_entry *arr;
    int num_entries;
    - struct semaphore lock;
    + struct mutex lock;
    };

    #define EHEA_PORT_UP 1
    Index: linux-2.6.24/drivers/net/ehea/ehea_main.c
    ================================================== =================
    --- linux-2.6.24.orig/drivers/net/ehea/ehea_main.c
    +++ linux-2.6.24/drivers/net/ehea/ehea_main.c
    @@ -1759,7 +1759,7 @@ static int ehea_set_mac_addr(struct net_

    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);
    @@ -1777,7 +1777,7 @@ static int ehea_set_mac_addr(struct net_

    out_upregs:
    ehea_update_bcmc_registrations();
    - up(&ehea_bcmc_regs.lock);
    + mutex_unlock(&ehea_bcmc_regs.lock);
    out_free:
    kfree(cb0);
    out:
    @@ -1939,7 +1939,7 @@ static void ehea_set_multicast_list(stru
    }
    ehea_promiscuous(dev, 0);

    - down(&ehea_bcmc_regs.lock);
    + mutex_lock(&ehea_bcmc_regs.lock);

    if (dev->flags & IFF_ALLMULTI) {
    ehea_allmulti(dev, 1);
    @@ -1970,7 +1970,7 @@ static void ehea_set_multicast_list(stru
    }
    out:
    ehea_update_bcmc_registrations();
    - up(&ehea_bcmc_regs.lock);
    + mutex_unlock(&ehea_bcmc_regs.lock);
    return;
    }

    @@ -2491,7 +2491,7 @@ static int ehea_up(struct net_device *de
    }
    }

    - down(&ehea_bcmc_regs.lock);
    + mutex_lock(&ehea_bcmc_regs.lock);

    ret = ehea_broadcast_reg_helper(port, H_REG_BCMC);
    if (ret) {
    @@ -2514,7 +2514,7 @@ 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();
    mutex_unlock(&ehea_fw_handles.lock);
    @@ -2569,7 +2569,7 @@ static int ehea_down(struct net_device *

    mutex_lock(&ehea_fw_handles.lock);

    - down(&ehea_bcmc_regs.lock);
    + mutex_lock(&ehea_bcmc_regs.lock);
    ehea_drop_multicast_list(dev);
    ehea_broadcast_reg_helper(port, H_DEREG_BCMC);

    @@ -2578,7 +2578,7 @@ static int ehea_down(struct net_device *
    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)
    @@ -3545,7 +3545,7 @@ int __init ehea_module_init(void)
    memset(&ehea_bcmc_regs, 0, sizeof(ehea_bcmc_regs));

    mutex_init(&ehea_fw_handles.lock);
    - sema_init(&ehea_bcmc_regs.lock, 1);
    + mutex_init(&ehea_bcmc_regs.lock);

    ret = check_module_parm();
    if (ret)

    --
    --
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/

  4. Re: [PATCH 1/5] net: ehea: semaphore to mutex

    ACK from Jan-Bernd, Thomas, others?

    --
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/

+ Reply to Thread