From patchwork Mon May 1 18:45:48 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brian Norris X-Patchwork-Id: 9706831 X-Patchwork-Delegate: kvalo@adurom.com Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 8EFB860387 for ; Mon, 1 May 2017 18:46:09 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 857F127F95 for ; Mon, 1 May 2017 18:46:09 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7A7AA28111; Mon, 1 May 2017 18:46:09 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EAC7327F95 for ; Mon, 1 May 2017 18:46:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751459AbdEASpz (ORCPT ); Mon, 1 May 2017 14:45:55 -0400 Received: from mail-pf0-f173.google.com ([209.85.192.173]:35400 "EHLO mail-pf0-f173.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750794AbdEASpy (ORCPT ); Mon, 1 May 2017 14:45:54 -0400 Received: by mail-pf0-f173.google.com with SMTP id v14so77891218pfd.2 for ; Mon, 01 May 2017 11:45:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id; bh=TGemSf4jSrIVmkKA8ZV7Q8+qVPcBlFGudt8OB2cwT10=; b=Kc4ofEDLAi8fpzKs3Ul1m3mh8/b1xYUP6W3VI4HATfrIzzPGJ0RYBrm85uywkC//Ge pq2btKwoOvAIrgJvTjWunaM08HYNK76EBBVLZUL7mNeLWoD3C+k5vw5D8ERQNZ3yZbLG uET65I/MJCO05kx6I6zLWEeqoAH3dAMyElmcM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=TGemSf4jSrIVmkKA8ZV7Q8+qVPcBlFGudt8OB2cwT10=; b=aEElFPm4XCDelMvqIwCssyoZ6lMQG5mGvmEBDIT2fR4dey6t+fheHYbtymScYeDqeP 8iho5caARZvpZS+X508xbjS3agzL7pYTKNrJpKMw58eEIqXyawEzBKt1W/Rq6zf3sIxv 7v1xCagDyunwhx11onBuLY2PzWoCoW58dxdvr5Wja7ONpM11OUpvhy3/eKg8NSdF42I4 4NzAUXlBiavqdmQxVqnWhCiNOw8F7GAv4Us3RcUv34fC45hHwJ4qaPEmmwN8jr6Xhx2v MDur8SI4lhDgdjHdbI8Ji5b4PyRyXKI6bHsTlMsGS0IRRoa5S8aRtvyUXP0jmH0dmkIt KsBw== X-Gm-Message-State: AN3rC/5qY0O+4Jz+bLg9DJmwv1F3aIcXycKpXpKr175eynZ9Tz5SosHV 4Ckqh8ijIMlsrkQ4 X-Received: by 10.84.196.164 with SMTP id l33mr36188891pld.0.1493664353503; Mon, 01 May 2017 11:45:53 -0700 (PDT) Received: from ban.mtv.corp.google.com ([172.22.64.120]) by smtp.gmail.com with ESMTPSA id x1sm23646250pgb.43.2017.05.01.11.45.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 01 May 2017 11:45:52 -0700 (PDT) From: Brian Norris To: Ganapathi Bhat , Nishant Sarmukadam Cc: , Dmitry Torokhov , Kalle Valo , linux-wireless@vger.kernel.org, Brian Norris Subject: [PATCH v2 1/2] mwifiex: initiate card-specific work atomically Date: Mon, 1 May 2017 11:45:48 -0700 Message-Id: <20170501184549.52896-1-briannorris@chromium.org> X-Mailer: git-send-email 2.13.0.rc0.306.g87b477812d-goog Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The non-atomic test + set is a little awkward here, and it technically means we might double-schedule work unnecessarily. AFAICT, this is not really a problem, since the extra "work" will be a no-op (the flag(s) will be cleared by then), but it's still an anti-pattern. Rewrite this to use the atomic test_and_set_bit() helper instead. Signed-off-by: Brian Norris --- new in v2 --- drivers/net/wireless/marvell/mwifiex/pcie.c | 13 +++++++++---- drivers/net/wireless/marvell/mwifiex/sdio.c | 16 +++++----------- 2 files changed, 14 insertions(+), 15 deletions(-) diff --git a/drivers/net/wireless/marvell/mwifiex/pcie.c b/drivers/net/wireless/marvell/mwifiex/pcie.c index ac62bce50e96..8e7d6f41a952 100644 --- a/drivers/net/wireless/marvell/mwifiex/pcie.c +++ b/drivers/net/wireless/marvell/mwifiex/pcie.c @@ -2837,12 +2837,17 @@ static void mwifiex_pcie_device_dump(struct mwifiex_adapter *adapter) { struct pcie_service_card *card = adapter->card; - if (test_bit(MWIFIEX_IFACE_WORK_DEVICE_DUMP, &card->work_flags)) - return; + if (!test_and_set_bit(MWIFIEX_IFACE_WORK_DEVICE_DUMP, + &card->work_flags)) + schedule_work(&card->work); +} - set_bit(MWIFIEX_IFACE_WORK_DEVICE_DUMP, &card->work_flags); +static void mwifiex_pcie_card_reset(struct mwifiex_adapter *adapter) +{ + struct pcie_service_card *card = adapter->card; - schedule_work(&card->work); + if (!test_and_set_bit(MWIFIEX_IFACE_WORK_CARD_RESET, &card->work_flags)) + schedule_work(&card->work); } static void mwifiex_pcie_free_buffers(struct mwifiex_adapter *adapter) diff --git a/drivers/net/wireless/marvell/mwifiex/sdio.c b/drivers/net/wireless/marvell/mwifiex/sdio.c index 0af1c6733c92..d38d31bb9b79 100644 --- a/drivers/net/wireless/marvell/mwifiex/sdio.c +++ b/drivers/net/wireless/marvell/mwifiex/sdio.c @@ -2533,12 +2533,8 @@ static void mwifiex_sdio_card_reset(struct mwifiex_adapter *adapter) { struct sdio_mmc_card *card = adapter->card; - if (test_bit(MWIFIEX_IFACE_WORK_CARD_RESET, &card->work_flags)) - return; - - set_bit(MWIFIEX_IFACE_WORK_CARD_RESET, &card->work_flags); - - schedule_work(&card->work); + if (!test_and_set_bit(MWIFIEX_IFACE_WORK_CARD_RESET, &card->work_flags)) + schedule_work(&card->work); } /* This function dumps FW information */ @@ -2546,11 +2542,9 @@ static void mwifiex_sdio_device_dump(struct mwifiex_adapter *adapter) { struct sdio_mmc_card *card = adapter->card; - if (test_bit(MWIFIEX_IFACE_WORK_DEVICE_DUMP, &card->work_flags)) - return; - - set_bit(MWIFIEX_IFACE_WORK_DEVICE_DUMP, &card->work_flags); - schedule_work(&card->work); + if (!test_and_set_bit(MWIFIEX_IFACE_WORK_DEVICE_DUMP, + &card->work_flags)) + schedule_work(&card->work); } /* Function to dump SDIO function registers and SDIO scratch registers in case