From patchwork Mon Apr 19 12:08:47 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Klein X-Patchwork-Id: 50461 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from bilbo.ozlabs.org (localhost [127.0.0.1]) by ozlabs.org (Postfix) with ESMTP id 71CACB8287 for ; Mon, 19 Apr 2010 22:08:58 +1000 (EST) Received: by ozlabs.org (Postfix) id 342CDB7D1F; Mon, 19 Apr 2010 22:08:52 +1000 (EST) Delivered-To: linuxppc-dev@ozlabs.org Received: from mtagate2.de.ibm.com (mtagate2.de.ibm.com [195.212.17.162]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "mtagate2.de.ibm.com", Issuer "Equifax" (verified OK)) by ozlabs.org (Postfix) with ESMTPS id 79AC6B7D18 for ; Mon, 19 Apr 2010 22:08:51 +1000 (EST) Received: from d12nrmr1607.megacenter.de.ibm.com (d12nrmr1607.megacenter.de.ibm.com [9.149.167.49]) by mtagate2.de.ibm.com (8.13.1/8.13.1) with ESMTP id o3JC8mkB007037 for ; Mon, 19 Apr 2010 12:08:48 GMT Received: from d12av03.megacenter.de.ibm.com (d12av03.megacenter.de.ibm.com [9.149.165.213]) by d12nrmr1607.megacenter.de.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id o3JC8lPw1605728 for ; Mon, 19 Apr 2010 14:08:47 +0200 Received: from d12av03.megacenter.de.ibm.com (loopback [127.0.0.1]) by d12av03.megacenter.de.ibm.com (8.12.11.20060308/8.13.3) with ESMTP id o3JC8lKc021550 for ; Mon, 19 Apr 2010 14:08:47 +0200 Received: from [9.152.241.108] (dyn-9-152-241-108.boeblingen.de.ibm.com [9.152.241.108]) by d12av03.megacenter.de.ibm.com (8.12.11.20060308/8.12.11) with ESMTP id o3JC8lM4021544; Mon, 19 Apr 2010 14:08:47 +0200 Message-ID: <4BCC47CF.8060107@de.ibm.com> Date: Mon, 19 Apr 2010 14:08:47 +0200 From: Thomas Klein User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.5) Gecko/20091204 Thunderbird/3.0 MIME-Version: 1.0 To: "David S. Miller" Subject: [PATCH 2/2] ehea: fix possible DLPAR/mem deadlock References: <1221140080-9853-1-git-send-email-sebastien.dugue@bull.net> <1221140080-9853-3-git-send-email-sebastien.dugue@bull.net> <48CE7CC3.8040902@de.ibm.com> <20080916085746.194c1510@bull.net> In-Reply-To: <20080916085746.194c1510@bull.net> Cc: linux-ppc , netdev , Christoph Raisch , linux-kernel , Jan-Bernd Themann X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Force serialization of userspace-triggered DLPAR/mem operations Signed-off-by: Thomas Klein --- Patch created against 2.6.34-rc4 diff -Nurp linux-2.6.34-rc4.orig//drivers/net/ehea/ehea.h linux-2.6.34-rc4//drivers/net/ehea/ehea.h --- linux-2.6.34-rc4.orig//drivers/net/ehea/ehea.h 2010-04-19 11:54:07.000000000 +0200 +++ linux-2.6.34-rc4//drivers/net/ehea/ehea.h 2010-04-19 12:00:14.000000000 +0200 @@ -40,7 +40,7 @@ #include #define DRV_NAME "ehea" -#define DRV_VERSION "EHEA_0102" +#define DRV_VERSION "EHEA_0103" /* eHEA capability flags */ #define DLPAR_PORT_ADD_REM 1 diff -Nurp linux-2.6.34-rc4.orig//drivers/net/ehea/ehea_main.c linux-2.6.34-rc4//drivers/net/ehea/ehea_main.c --- linux-2.6.34-rc4.orig//drivers/net/ehea/ehea_main.c 2010-04-19 11:59:11.000000000 +0200 +++ linux-2.6.34-rc4//drivers/net/ehea/ehea_main.c 2010-04-19 11:59:50.000000000 +0200 @@ -2889,7 +2889,6 @@ static void ehea_rereg_mrs(struct work_s int ret, i; struct ehea_adapter *adapter; - mutex_lock(&dlpar_mem_lock); ehea_info("LPAR memory changed - re-initializing driver"); list_for_each_entry(adapter, &adapter_list, list) @@ -2959,7 +2958,6 @@ static void ehea_rereg_mrs(struct work_s } ehea_info("re-initializing driver complete"); out: - mutex_unlock(&dlpar_mem_lock); return; } @@ -3542,7 +3540,14 @@ void ehea_crash_handler(void) static int ehea_mem_notifier(struct notifier_block *nb, unsigned long action, void *data) { + int ret = NOTIFY_BAD; struct memory_notify *arg = data; + + if (!mutex_trylock(&dlpar_mem_lock)) { + ehea_info("ehea_mem_notifier must not be called parallelized"); + goto out; + } + switch (action) { case MEM_CANCEL_OFFLINE: ehea_info("memory offlining canceled"); @@ -3551,14 +3556,14 @@ static int ehea_mem_notifier(struct noti ehea_info("memory is going online"); set_bit(__EHEA_STOP_XFER, &ehea_driver_flags); if (ehea_add_sect_bmap(arg->start_pfn, arg->nr_pages)) - return NOTIFY_BAD; + goto out_unlock; ehea_rereg_mrs(NULL); break; case MEM_GOING_OFFLINE: ehea_info("memory is going offline"); set_bit(__EHEA_STOP_XFER, &ehea_driver_flags); if (ehea_rem_sect_bmap(arg->start_pfn, arg->nr_pages)) - return NOTIFY_BAD; + goto out_unlock; ehea_rereg_mrs(NULL); break; default: @@ -3566,8 +3571,12 @@ static int ehea_mem_notifier(struct noti } ehea_update_firmware_handles(); + ret = NOTIFY_OK; - return NOTIFY_OK; +out_unlock: + mutex_unlock(&dlpar_mem_lock); +out: + return ret; } static struct notifier_block ehea_mem_nb = {