From patchwork Sat Dec 22 01:56:57 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tejun Heo X-Patchwork-Id: 1905261 Return-Path: X-Original-To: patchwork-linux-wireless@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id 590EDDFAC4 for ; Sat, 22 Dec 2012 02:03:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752333Ab2LVB6M (ORCPT ); Fri, 21 Dec 2012 20:58:12 -0500 Received: from mail-ia0-f175.google.com ([209.85.210.175]:57975 "EHLO mail-ia0-f175.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752303Ab2LVB6J (ORCPT ); Fri, 21 Dec 2012 20:58:09 -0500 Received: by mail-ia0-f175.google.com with SMTP id z3so4400628iad.20 for ; Fri, 21 Dec 2012 17:58:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:sender:from:to:cc:subject:date:message-id:x-mailer :in-reply-to:references; bh=7Ml9AiZe45wdGrAIokkC8lisXh4QYR3bQNwXxE076EU=; b=o5P5Th3iRkiBPfQsjf7KWpMVqKUnpjQyWovfjTyK73N6pp2+Nax7BntVfUUMXIUAfU cmFAe5geA6VmmFYL+wF9sA4Xrb4YFHBIYAKEi453FclRfclOjcfM2EG4hkXuarO/16k0 CuCtn/HWlI3r5oRXACCaDsyHI1aj66vIoUWev4JCk7ca+zZRbQivFhjH6yTs/HInOEZO IqI6EAxhiZgR9mx/Be4GOGkQ4J4ZkIXt4yUg3e3Ua6bKaabPBBO5zXvUhFVtNfy/ubL8 +1giY1YEwJNUqMNZhKMBLJ+fXhV8tbLVwtwamUtKsu1JZaAhiBtX7EVzyKtlTzj1Vgi2 dvwA== X-Received: by 10.50.17.132 with SMTP id o4mr10389695igd.83.1356141488779; Fri, 21 Dec 2012 17:58:08 -0800 (PST) Received: from htj.dyndns.org.com (c-69-181-251-227.hsd1.ca.comcast.net. [69.181.251.227]) by mx.google.com with ESMTPS id v12sm10975374igv.3.2012.12.21.17.58.05 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 21 Dec 2012 17:58:08 -0800 (PST) From: Tejun Heo To: linux-kernel@vger.kernel.org Cc: Tejun Heo , Bing Zhao , linux-wireless@vger.kernel.org Subject: [PATCH 07/25] mwifiex: don't use [delayed_]work_pending() Date: Fri, 21 Dec 2012 17:56:57 -0800 Message-Id: <1356141435-17340-8-git-send-email-tj@kernel.org> X-Mailer: git-send-email 1.8.0.2 In-Reply-To: <1356141435-17340-1-git-send-email-tj@kernel.org> References: <1356141435-17340-1-git-send-email-tj@kernel.org> Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org Drop work_pending() test from mwifiex_sdio_card_reset(). As work_pending() becomes %false before sdio_card_reset_worker() starts executing, it doesn't really protect anything. reset_host may change between mmc_remove_host() and mmc_add_host(). Make sdio_card_reset_worker() cache the target mmc_host so that it isn't affected by mwifiex_sdio_card_reset() racing with it. Only compile tested. Signed-off-by: Tejun Heo Cc: Bing Zhao Cc: linux-wireless@vger.kernel.org Acked-by: Bing Zhao --- Please let me know how this patch should be routed. I can take it through the workqueue tree if necessary. Thanks. drivers/net/wireless/mwifiex/sdio.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/drivers/net/wireless/mwifiex/sdio.c b/drivers/net/wireless/mwifiex/sdio.c index 5a1c1d0..f2874c3 100644 --- a/drivers/net/wireless/mwifiex/sdio.c +++ b/drivers/net/wireless/mwifiex/sdio.c @@ -1752,6 +1752,8 @@ mwifiex_update_mp_end_port(struct mwifiex_adapter *adapter, u16 port) static struct mmc_host *reset_host; static void sdio_card_reset_worker(struct work_struct *work) { + struct mmc_host *target = reset_host; + /* The actual reset operation must be run outside of driver thread. * This is because mmc_remove_host() will cause the device to be * instantly destroyed, and the driver then needs to end its thread, @@ -1761,10 +1763,10 @@ static void sdio_card_reset_worker(struct work_struct *work) */ pr_err("Resetting card...\n"); - mmc_remove_host(reset_host); + mmc_remove_host(target); /* 20ms delay is based on experiment with sdhci controller */ mdelay(20); - mmc_add_host(reset_host); + mmc_add_host(target); } static DECLARE_WORK(card_reset_work, sdio_card_reset_worker); @@ -1773,9 +1775,6 @@ static void mwifiex_sdio_card_reset(struct mwifiex_adapter *adapter) { struct sdio_mmc_card *card = adapter->card; - if (work_pending(&card_reset_work)) - return; - reset_host = card->func->card->host; schedule_work(&card_reset_work); }