{"id":237,"url":"http://patchwork.ozlabs.org/api/1.1/patches/237/?format=json","web_url":"http://patchwork.ozlabs.org/project/linuxppc-dev/patch/1221140080-9853-3-git-send-email-sebastien.dugue@bull.net/","project":{"id":2,"url":"http://patchwork.ozlabs.org/api/1.1/projects/2/?format=json","name":"Linux PPC development","link_name":"linuxppc-dev","list_id":"linuxppc-dev.lists.ozlabs.org","list_email":"linuxppc-dev@lists.ozlabs.org","web_url":"https://github.com/linuxppc/wiki/wiki","scm_url":"https://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git","webscm_url":"https://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git/"},"msgid":"<1221140080-9853-3-git-send-email-sebastien.dugue@bull.net>","date":"2008-09-11T13:34:40","name":"ehea: fix mutex and spinlock use","commit_ref":"2eefbd63d0c85daa1317636474c226e236beba81","pull_url":null,"state":"accepted","archived":true,"hash":"7126cf1e924552eb14ce0bf31bf93270fd1c99db","submitter":{"id":101,"url":"http://patchwork.ozlabs.org/api/1.1/people/101/?format=json","name":"Sebastien Dugue","email":"sebastien.dugue@bull.net"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/linuxppc-dev/patch/1221140080-9853-3-git-send-email-sebastien.dugue@bull.net/mbox/","series":[],"comments":"http://patchwork.ozlabs.org/api/patches/237/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/237/checks/","tags":{},"headers":{"Return-Path":"<linuxppc-dev-bounces+patchwork=ozlabs.org@ozlabs.org>","X-Original-To":["patchwork@ozlabs.org","linuxppc-dev@ozlabs.org"],"Delivered-To":["patchwork@ozlabs.org","linuxppc-dev@ozlabs.org"],"Received":["from ozlabs.org (localhost [127.0.0.1])\n\tby ozlabs.org (Postfix) with ESMTP id 7D199DE02A\n\tfor <patchwork@ozlabs.org>; Thu, 11 Sep 2008 23:36:35 +1000 (EST)","from ecfrec.frec.bull.fr (ecfrec.frec.bull.fr [129.183.4.8])\n\tby ozlabs.org (Postfix) with ESMTP id 84112DDF81\n\tfor <linuxppc-dev@ozlabs.org>; Thu, 11 Sep 2008 23:35:00 +1000 (EST)","from localhost (localhost [127.0.0.1])\n\tby ecfrec.frec.bull.fr (Postfix) with ESMTP\n\tid 84AD519FDD8; Thu, 11 Sep 2008 15:34:52 +0200 (CEST)","from ecfrec.frec.bull.fr ([127.0.0.1])\n\tby localhost (ecfrec.frec.bull.fr [127.0.0.1]) (amavisd-new,\n\tport 10024)\n\twith ESMTP id 32640-02; Thu, 11 Sep 2008 15:34:49 +0200 (CEST)","from cyclope.frec.bull.fr (cyclope.frec.bull.fr [129.183.4.9])\n\tby ecfrec.frec.bull.fr (Postfix) with ESMTP\n\tid CB52F19FD7A; Thu, 11 Sep 2008 15:34:46 +0200 (CEST)","from localhost (frecb000686.frec.bull.fr [129.183.101.139])\n\tby cyclope.frec.bull.fr (Postfix) with ESMTP id 8D56427291;\n\tThu, 11 Sep 2008 15:34:45 +0200 (CEST)","from dugues by localhost with local (Exim 4.68)\n\t(envelope-from <sebastien.dugue@bull.net>)\n\tid 1KdmJp-0002ZO-Li; Thu, 11 Sep 2008 15:34:45 +0200"],"From":"Sebastien Dugue <sebastien.dugue@bull.net>","To":"linuxppc-dev@ozlabs.org","Subject":"[PATCH 2/2] ehea: fix mutex and spinlock use","Date":"Thu, 11 Sep 2008 15:34:40 +0200","Message-Id":"<1221140080-9853-3-git-send-email-sebastien.dugue@bull.net>","X-Mailer":"git-send-email 1.5.5.rc2.1.gc953.dirty","In-Reply-To":"<1221140080-9853-1-git-send-email-sebastien.dugue@bull.net>","References":"<1221140080-9853-1-git-send-email-sebastien.dugue@bull.net>","X-Virus-Scanned":"by amavisd-new at frec.bull.fr","Cc":"tklein@de.ibm.com, tinytim@us.ibm.com, jeff@garzik.org,\n\tthemann@de.ibm.com, \n\tnetdev@vger.kernel.org, linux-kernel@vger.kernel.org,\n\tjean-pierre.dion@bull.net, sebastien.dugue@bull.net,\n\traisch@de.ibm.com, gilles.carry@ext.bull.net","X-BeenThere":"linuxppc-dev@ozlabs.org","X-Mailman-Version":"2.1.11","Precedence":"list","List-Id":"Linux on PowerPC Developers Mail List <linuxppc-dev.ozlabs.org>","List-Unsubscribe":"<https://ozlabs.org/mailman/options/linuxppc-dev>,\n\t<mailto:linuxppc-dev-request@ozlabs.org?subject=unsubscribe>","List-Archive":"<http://ozlabs.org/pipermail/linuxppc-dev>","List-Post":"<mailto:linuxppc-dev@ozlabs.org>","List-Help":"<mailto:linuxppc-dev-request@ozlabs.org?subject=help>","List-Subscribe":"<https://ozlabs.org/mailman/listinfo/linuxppc-dev>,\n\t<mailto:linuxppc-dev-request@ozlabs.org?subject=subscribe>","MIME-Version":"1.0","Content-Type":"text/plain; charset=\"us-ascii\"","Content-Transfer-Encoding":"7bit","Sender":"linuxppc-dev-bounces+patchwork=ozlabs.org@ozlabs.org","Errors-To":"linuxppc-dev-bounces+patchwork=ozlabs.org@ozlabs.org"},"content":"Looks like to me that the ehea_fw_handles.lock mutex and the\nehea_bcmc_regs.lock spinlock are taken much longer than necessary and could\nas well be pushed inside the functions that need them\n(ehea_update_firmware_handles() and ehea_update_bcmc_registrations())\nrather than at each callsite.\n\nSigned-off-by: Sebastien Dugue <sebastien.dugue@bull.net>","diff":"diff --git a/drivers/net/ehea/ehea_main.c b/drivers/net/ehea/ehea_main.c\nindex b70c531..c765ec6 100644\n--- a/drivers/net/ehea/ehea_main.c\n+++ b/drivers/net/ehea/ehea_main.c\n@@ -219,9 +219,11 @@ static void ehea_update_firmware_handles(void)\n \t}\n \n out_update:\n+\tmutex_lock(&ehea_fw_handles.lock);\n \tkfree(ehea_fw_handles.arr);\n \tehea_fw_handles.arr = arr;\n \tehea_fw_handles.num_entries = i;\n+\tmutex_unlock(&ehea_fw_handles.lock);\n }\n \n static void ehea_update_bcmc_registrations(void)\n@@ -293,9 +295,11 @@ static void ehea_update_bcmc_registrations(void)\n \t}\n \n out_update:\n+\tspin_lock(&ehea_bcmc_regs.lock);\n \tkfree(ehea_bcmc_regs.arr);\n \tehea_bcmc_regs.arr = arr;\n \tehea_bcmc_regs.num_entries = i;\n+\tspin_unlock(&ehea_bcmc_regs.lock);\n }\n \n static struct net_device_stats *ehea_get_stats(struct net_device *dev)\n@@ -1770,8 +1774,6 @@ static int ehea_set_mac_addr(struct net_device *dev, void *sa)\n \n \tmemcpy(dev->dev_addr, mac_addr->sa_data, dev->addr_len);\n \n-\tspin_lock(&ehea_bcmc_regs.lock);\n-\n \t/* Deregister old MAC in pHYP */\n \tif (port->state == EHEA_PORT_UP) {\n \t\tret = ehea_broadcast_reg_helper(port, H_DEREG_BCMC);\n@@ -1792,7 +1794,6 @@ static int ehea_set_mac_addr(struct net_device *dev, void *sa)\n \n out_upregs:\n \tehea_update_bcmc_registrations();\n-\tspin_unlock(&ehea_bcmc_regs.lock);\n out_free:\n \tkfree(cb0);\n out:\n@@ -1954,8 +1955,6 @@ static void ehea_set_multicast_list(struct net_device *dev)\n \t}\n \tehea_promiscuous(dev, 0);\n \n-\tspin_lock(&ehea_bcmc_regs.lock);\n-\n \tif (dev->flags & IFF_ALLMULTI) {\n \t\tehea_allmulti(dev, 1);\n \t\tgoto out;\n@@ -1985,7 +1984,6 @@ static void ehea_set_multicast_list(struct net_device *dev)\n \t}\n out:\n \tehea_update_bcmc_registrations();\n-\tspin_unlock(&ehea_bcmc_regs.lock);\n \treturn;\n }\n \n@@ -2466,8 +2464,6 @@ static int ehea_up(struct net_device *dev)\n \tif (port->state == EHEA_PORT_UP)\n \t\treturn 0;\n \n-\tmutex_lock(&ehea_fw_handles.lock);\n-\n \tret = ehea_port_res_setup(port, port->num_def_qps,\n \t\t\t\t  port->num_add_tx_qps);\n \tif (ret) {\n@@ -2504,8 +2500,6 @@ static int ehea_up(struct net_device *dev)\n \t\t}\n \t}\n \n-\tspin_lock(&ehea_bcmc_regs.lock);\n-\n \tret = ehea_broadcast_reg_helper(port, H_REG_BCMC);\n \tif (ret) {\n \t\tret = -EIO;\n@@ -2527,10 +2521,8 @@ out:\n \t\tehea_info(\"Failed starting %s. ret=%i\", dev->name, ret);\n \n \tehea_update_bcmc_registrations();\n-\tspin_unlock(&ehea_bcmc_regs.lock);\n \n \tehea_update_firmware_handles();\n-\tmutex_unlock(&ehea_fw_handles.lock);\n \n \treturn ret;\n }\n@@ -2580,9 +2572,6 @@ static int ehea_down(struct net_device *dev)\n \tif (port->state == EHEA_PORT_DOWN)\n \t\treturn 0;\n \n-\tmutex_lock(&ehea_fw_handles.lock);\n-\n-\tspin_lock(&ehea_bcmc_regs.lock);\n \tehea_drop_multicast_list(dev);\n \tehea_broadcast_reg_helper(port, H_DEREG_BCMC);\n \n@@ -2591,7 +2580,6 @@ static int ehea_down(struct net_device *dev)\n \tport->state = EHEA_PORT_DOWN;\n \n \tehea_update_bcmc_registrations();\n-\tspin_unlock(&ehea_bcmc_regs.lock);\n \n \tret = ehea_clean_all_portres(port);\n \tif (ret)\n@@ -2599,7 +2587,6 @@ static int ehea_down(struct net_device *dev)\n \t\t\t  dev->name, ret);\n \n \tehea_update_firmware_handles();\n-\tmutex_unlock(&ehea_fw_handles.lock);\n \n \treturn ret;\n }\n@@ -3378,7 +3365,6 @@ static int __devinit ehea_probe_adapter(struct of_device *dev,\n \t\tehea_error(\"Invalid ibmebus device probed\");\n \t\treturn -EINVAL;\n \t}\n-\tmutex_lock(&ehea_fw_handles.lock);\n \n \tadapter = kzalloc(sizeof(*adapter), GFP_KERNEL);\n \tif (!adapter) {\n@@ -3462,7 +3448,6 @@ out_free_ad:\n \n out:\n \tehea_update_firmware_handles();\n-\tmutex_unlock(&ehea_fw_handles.lock);\n \treturn ret;\n }\n \n@@ -3481,8 +3466,6 @@ static int __devexit ehea_remove(struct of_device *dev)\n \n \tflush_scheduled_work();\n \n-\tmutex_lock(&ehea_fw_handles.lock);\n-\n \tibmebus_free_irq(adapter->neq->attr.ist1, adapter);\n \ttasklet_kill(&adapter->neq_tasklet);\n \n@@ -3492,7 +3475,6 @@ static int __devexit ehea_remove(struct of_device *dev)\n \tkfree(adapter);\n \n \tehea_update_firmware_handles();\n-\tmutex_unlock(&ehea_fw_handles.lock);\n \n \treturn 0;\n }\n","prefixes":[]}