From: Jeff Garzik <jeff@garzik.org>
To: Sebastien Dugue <sebastien.dugue@bull.net>
Cc: tklein@de.ibm.com, tinytim@us.ibm.com, themann@de.ibm.com,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
jean-pierre.dion@bull.net, linuxppc-dev@ozlabs.org,
raisch@de.ibm.com, gilles.carry@ext.bull.net
Subject: Re: [PATCH 2/2] ehea: fix mutex and spinlock use
Date: Sat, 13 Sep 2008 15:30:54 -0400 [thread overview]
Message-ID: <48CC14EE.3070400@garzik.org> (raw)
In-Reply-To: <1221140080-9853-3-git-send-email-sebastien.dugue@bull.net>
Sebastien Dugue wrote:
> Looks like to me that the ehea_fw_handles.lock mutex and the
> ehea_bcmc_regs.lock spinlock are taken much longer than necessary and could
> as well be pushed inside the functions that need them
> (ehea_update_firmware_handles() and ehea_update_bcmc_registrations())
> rather than at each callsite.
>
> Signed-off-by: Sebastien Dugue <sebastien.dugue@bull.net>
> ---
> drivers/net/ehea/ehea_main.c | 26 ++++----------------------
> 1 files changed, 4 insertions(+), 22 deletions(-)
>
> diff --git a/drivers/net/ehea/ehea_main.c b/drivers/net/ehea/ehea_main.c
> index b70c531..c765ec6 100644
> --- a/drivers/net/ehea/ehea_main.c
> +++ b/drivers/net/ehea/ehea_main.c
> @@ -219,9 +219,11 @@ static void ehea_update_firmware_handles(void)
> }
>
> out_update:
> + mutex_lock(&ehea_fw_handles.lock);
> kfree(ehea_fw_handles.arr);
> ehea_fw_handles.arr = arr;
> ehea_fw_handles.num_entries = i;
> + mutex_unlock(&ehea_fw_handles.lock);
> }
>
> static void ehea_update_bcmc_registrations(void)
> @@ -293,9 +295,11 @@ static void ehea_update_bcmc_registrations(void)
> }
>
> out_update:
> + spin_lock(&ehea_bcmc_regs.lock);
> kfree(ehea_bcmc_regs.arr);
> ehea_bcmc_regs.arr = arr;
> ehea_bcmc_regs.num_entries = i;
> + spin_unlock(&ehea_bcmc_regs.lock);
> }
>
> static struct net_device_stats *ehea_get_stats(struct net_device *dev)
> @@ -1770,8 +1774,6 @@ static int ehea_set_mac_addr(struct net_device *dev, void *sa)
>
> memcpy(dev->dev_addr, mac_addr->sa_data, dev->addr_len);
>
> - spin_lock(&ehea_bcmc_regs.lock);
> -
> /* Deregister old MAC in pHYP */
> if (port->state == EHEA_PORT_UP) {
> ret = ehea_broadcast_reg_helper(port, H_DEREG_BCMC);
> @@ -1792,7 +1794,6 @@ static int ehea_set_mac_addr(struct net_device *dev, void *sa)
>
> out_upregs:
> ehea_update_bcmc_registrations();
> - spin_unlock(&ehea_bcmc_regs.lock);
> out_free:
> kfree(cb0);
> out:
> @@ -1954,8 +1955,6 @@ static void ehea_set_multicast_list(struct net_device *dev)
> }
> ehea_promiscuous(dev, 0);
>
> - spin_lock(&ehea_bcmc_regs.lock);
> -
> if (dev->flags & IFF_ALLMULTI) {
> ehea_allmulti(dev, 1);
> goto out;
> @@ -1985,7 +1984,6 @@ static void ehea_set_multicast_list(struct net_device *dev)
> }
> out:
> ehea_update_bcmc_registrations();
> - spin_unlock(&ehea_bcmc_regs.lock);
> return;
> }
>
> @@ -2466,8 +2464,6 @@ static int ehea_up(struct net_device *dev)
> if (port->state == EHEA_PORT_UP)
> return 0;
>
> - mutex_lock(&ehea_fw_handles.lock);
> -
> ret = ehea_port_res_setup(port, port->num_def_qps,
> port->num_add_tx_qps);
> if (ret) {
> @@ -2504,8 +2500,6 @@ static int ehea_up(struct net_device *dev)
> }
> }
>
> - spin_lock(&ehea_bcmc_regs.lock);
> -
> ret = ehea_broadcast_reg_helper(port, H_REG_BCMC);
> if (ret) {
> ret = -EIO;
> @@ -2527,10 +2521,8 @@ out:
> ehea_info("Failed starting %s. ret=%i", dev->name, ret);
>
> ehea_update_bcmc_registrations();
> - spin_unlock(&ehea_bcmc_regs.lock);
>
> ehea_update_firmware_handles();
> - mutex_unlock(&ehea_fw_handles.lock);
>
> return ret;
> }
> @@ -2580,9 +2572,6 @@ static int ehea_down(struct net_device *dev)
> if (port->state == EHEA_PORT_DOWN)
> return 0;
>
> - mutex_lock(&ehea_fw_handles.lock);
> -
> - spin_lock(&ehea_bcmc_regs.lock);
> ehea_drop_multicast_list(dev);
> ehea_broadcast_reg_helper(port, H_DEREG_BCMC);
>
> @@ -2591,7 +2580,6 @@ static int ehea_down(struct net_device *dev)
> port->state = EHEA_PORT_DOWN;
>
> ehea_update_bcmc_registrations();
> - spin_unlock(&ehea_bcmc_regs.lock);
>
> ret = ehea_clean_all_portres(port);
> if (ret)
> @@ -2599,7 +2587,6 @@ static int ehea_down(struct net_device *dev)
> dev->name, ret);
>
> ehea_update_firmware_handles();
> - mutex_unlock(&ehea_fw_handles.lock);
>
> return ret;
> }
> @@ -3378,7 +3365,6 @@ static int __devinit ehea_probe_adapter(struct of_device *dev,
> ehea_error("Invalid ibmebus device probed");
> return -EINVAL;
> }
> - mutex_lock(&ehea_fw_handles.lock);
>
> adapter = kzalloc(sizeof(*adapter), GFP_KERNEL);
> if (!adapter) {
> @@ -3462,7 +3448,6 @@ out_free_ad:
>
> out:
> ehea_update_firmware_handles();
> - mutex_unlock(&ehea_fw_handles.lock);
> return ret;
> }
>
> @@ -3481,8 +3466,6 @@ static int __devexit ehea_remove(struct of_device *dev)
>
> flush_scheduled_work();
>
> - mutex_lock(&ehea_fw_handles.lock);
> -
> ibmebus_free_irq(adapter->neq->attr.ist1, adapter);
> tasklet_kill(&adapter->neq_tasklet);
applied
WARNING: multiple messages have this Message-ID (diff)
From: Jeff Garzik <jeff@garzik.org>
To: Sebastien Dugue <sebastien.dugue@bull.net>
Cc: linuxppc-dev@ozlabs.org, linux-kernel@vger.kernel.org,
netdev@vger.kernel.org, themann@de.ibm.com, tklein@de.ibm.com,
raisch@de.ibm.com, jean-pierre.dion@bull.net,
gilles.carry@ext.bull.net, tinytim@us.ibm.com
Subject: Re: [PATCH 2/2] ehea: fix mutex and spinlock use
Date: Sat, 13 Sep 2008 15:30:54 -0400 [thread overview]
Message-ID: <48CC14EE.3070400@garzik.org> (raw)
In-Reply-To: <1221140080-9853-3-git-send-email-sebastien.dugue@bull.net>
Sebastien Dugue wrote:
> Looks like to me that the ehea_fw_handles.lock mutex and the
> ehea_bcmc_regs.lock spinlock are taken much longer than necessary and could
> as well be pushed inside the functions that need them
> (ehea_update_firmware_handles() and ehea_update_bcmc_registrations())
> rather than at each callsite.
>
> Signed-off-by: Sebastien Dugue <sebastien.dugue@bull.net>
> ---
> drivers/net/ehea/ehea_main.c | 26 ++++----------------------
> 1 files changed, 4 insertions(+), 22 deletions(-)
>
> diff --git a/drivers/net/ehea/ehea_main.c b/drivers/net/ehea/ehea_main.c
> index b70c531..c765ec6 100644
> --- a/drivers/net/ehea/ehea_main.c
> +++ b/drivers/net/ehea/ehea_main.c
> @@ -219,9 +219,11 @@ static void ehea_update_firmware_handles(void)
> }
>
> out_update:
> + mutex_lock(&ehea_fw_handles.lock);
> kfree(ehea_fw_handles.arr);
> ehea_fw_handles.arr = arr;
> ehea_fw_handles.num_entries = i;
> + mutex_unlock(&ehea_fw_handles.lock);
> }
>
> static void ehea_update_bcmc_registrations(void)
> @@ -293,9 +295,11 @@ static void ehea_update_bcmc_registrations(void)
> }
>
> out_update:
> + spin_lock(&ehea_bcmc_regs.lock);
> kfree(ehea_bcmc_regs.arr);
> ehea_bcmc_regs.arr = arr;
> ehea_bcmc_regs.num_entries = i;
> + spin_unlock(&ehea_bcmc_regs.lock);
> }
>
> static struct net_device_stats *ehea_get_stats(struct net_device *dev)
> @@ -1770,8 +1774,6 @@ static int ehea_set_mac_addr(struct net_device *dev, void *sa)
>
> memcpy(dev->dev_addr, mac_addr->sa_data, dev->addr_len);
>
> - spin_lock(&ehea_bcmc_regs.lock);
> -
> /* Deregister old MAC in pHYP */
> if (port->state == EHEA_PORT_UP) {
> ret = ehea_broadcast_reg_helper(port, H_DEREG_BCMC);
> @@ -1792,7 +1794,6 @@ static int ehea_set_mac_addr(struct net_device *dev, void *sa)
>
> out_upregs:
> ehea_update_bcmc_registrations();
> - spin_unlock(&ehea_bcmc_regs.lock);
> out_free:
> kfree(cb0);
> out:
> @@ -1954,8 +1955,6 @@ static void ehea_set_multicast_list(struct net_device *dev)
> }
> ehea_promiscuous(dev, 0);
>
> - spin_lock(&ehea_bcmc_regs.lock);
> -
> if (dev->flags & IFF_ALLMULTI) {
> ehea_allmulti(dev, 1);
> goto out;
> @@ -1985,7 +1984,6 @@ static void ehea_set_multicast_list(struct net_device *dev)
> }
> out:
> ehea_update_bcmc_registrations();
> - spin_unlock(&ehea_bcmc_regs.lock);
> return;
> }
>
> @@ -2466,8 +2464,6 @@ static int ehea_up(struct net_device *dev)
> if (port->state == EHEA_PORT_UP)
> return 0;
>
> - mutex_lock(&ehea_fw_handles.lock);
> -
> ret = ehea_port_res_setup(port, port->num_def_qps,
> port->num_add_tx_qps);
> if (ret) {
> @@ -2504,8 +2500,6 @@ static int ehea_up(struct net_device *dev)
> }
> }
>
> - spin_lock(&ehea_bcmc_regs.lock);
> -
> ret = ehea_broadcast_reg_helper(port, H_REG_BCMC);
> if (ret) {
> ret = -EIO;
> @@ -2527,10 +2521,8 @@ out:
> ehea_info("Failed starting %s. ret=%i", dev->name, ret);
>
> ehea_update_bcmc_registrations();
> - spin_unlock(&ehea_bcmc_regs.lock);
>
> ehea_update_firmware_handles();
> - mutex_unlock(&ehea_fw_handles.lock);
>
> return ret;
> }
> @@ -2580,9 +2572,6 @@ static int ehea_down(struct net_device *dev)
> if (port->state == EHEA_PORT_DOWN)
> return 0;
>
> - mutex_lock(&ehea_fw_handles.lock);
> -
> - spin_lock(&ehea_bcmc_regs.lock);
> ehea_drop_multicast_list(dev);
> ehea_broadcast_reg_helper(port, H_DEREG_BCMC);
>
> @@ -2591,7 +2580,6 @@ static int ehea_down(struct net_device *dev)
> port->state = EHEA_PORT_DOWN;
>
> ehea_update_bcmc_registrations();
> - spin_unlock(&ehea_bcmc_regs.lock);
>
> ret = ehea_clean_all_portres(port);
> if (ret)
> @@ -2599,7 +2587,6 @@ static int ehea_down(struct net_device *dev)
> dev->name, ret);
>
> ehea_update_firmware_handles();
> - mutex_unlock(&ehea_fw_handles.lock);
>
> return ret;
> }
> @@ -3378,7 +3365,6 @@ static int __devinit ehea_probe_adapter(struct of_device *dev,
> ehea_error("Invalid ibmebus device probed");
> return -EINVAL;
> }
> - mutex_lock(&ehea_fw_handles.lock);
>
> adapter = kzalloc(sizeof(*adapter), GFP_KERNEL);
> if (!adapter) {
> @@ -3462,7 +3448,6 @@ out_free_ad:
>
> out:
> ehea_update_firmware_handles();
> - mutex_unlock(&ehea_fw_handles.lock);
> return ret;
> }
>
> @@ -3481,8 +3466,6 @@ static int __devexit ehea_remove(struct of_device *dev)
>
> flush_scheduled_work();
>
> - mutex_lock(&ehea_fw_handles.lock);
> -
> ibmebus_free_irq(adapter->neq->attr.ist1, adapter);
> tasklet_kill(&adapter->neq_tasklet);
applied
next prev parent reply other threads:[~2008-09-13 19:31 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-09-11 13:34 [PATCH 0/2] powerpc - EHEA fixes Sebastien Dugue
2008-09-11 13:34 ` Sebastien Dugue
2008-09-11 13:34 ` [PATCH 1/2] ehea: fix phyp debugging typo Sebastien Dugue
2008-09-11 13:34 ` Sebastien Dugue
2008-09-13 19:12 ` Jeff Garzik
2008-09-13 19:12 ` Jeff Garzik
2008-09-11 13:34 ` [PATCH 2/2] ehea: fix mutex and spinlock use Sebastien Dugue
2008-09-11 13:34 ` Sebastien Dugue
2008-09-13 19:30 ` Jeff Garzik [this message]
2008-09-13 19:30 ` Jeff Garzik
2008-09-15 15:18 ` Thomas Klein
2008-09-15 15:18 ` Thomas Klein
2008-09-16 6:57 ` Sebastien Dugue
2008-09-16 6:57 ` Sebastien Dugue
2008-09-16 9:13 ` Thomas Klein
2008-09-16 9:13 ` Thomas Klein
2008-09-16 10:38 ` Sebastien Dugue
2008-09-16 10:38 ` Sebastien Dugue
2010-04-19 12:08 ` [PATCH 2/2] ehea: fix possible DLPAR/mem deadlock Thomas Klein
2010-04-19 12:08 ` Thomas Klein
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=48CC14EE.3070400@garzik.org \
--to=jeff@garzik.org \
--cc=gilles.carry@ext.bull.net \
--cc=jean-pierre.dion@bull.net \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxppc-dev@ozlabs.org \
--cc=netdev@vger.kernel.org \
--cc=raisch@de.ibm.com \
--cc=sebastien.dugue@bull.net \
--cc=themann@de.ibm.com \
--cc=tinytim@us.ibm.com \
--cc=tklein@de.ibm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.