From patchwork Mon May 1 19:37:00 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brian Norris X-Patchwork-Id: 9706855 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 D9E0B60385 for ; Mon, 1 May 2017 19:37:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C968E209CD for ; Mon, 1 May 2017 19:37:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BE668280FC; Mon, 1 May 2017 19:37:31 +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 7A6E9209CD for ; Mon, 1 May 2017 19:37:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751512AbdEAThG (ORCPT ); Mon, 1 May 2017 15:37:06 -0400 Received: from mail-pf0-f170.google.com ([209.85.192.170]:36067 "EHLO mail-pf0-f170.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751224AbdEAThE (ORCPT ); Mon, 1 May 2017 15:37:04 -0400 Received: by mail-pf0-f170.google.com with SMTP id q66so34237785pfi.3 for ; Mon, 01 May 2017 12:37:04 -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:in-reply-to:references; bh=+hp/IyKmA9whjNFLjkiA9MPsgMEeZObQLk7xxLlgWDQ=; b=CVsv7mHwdq8ia8PlCORHqeHnKsJAhjNFYV/TL+E/MjR6lRuVDiqBcg9aNRUwFjFxZ+ g9SGkPmPVwWdy1IyvbtBPzgp54JrRK5m305dwKE5LRrAyPHRN7Ln7Rz+3QZvNz4HXS6K /CxquVBow4q/JY4qzejapIVI0bx43DcvFfTb0= 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:in-reply-to :references; bh=+hp/IyKmA9whjNFLjkiA9MPsgMEeZObQLk7xxLlgWDQ=; b=re61tulA8GX2Nu25PlTPWbGqBbRDelvELgcEnpBXWEybK0oXVkUQIn1WHxZqy7lVYK PsLcd2dq6O4W/U7ShfxAFMQ8170dKCrejc/TSYj0WUXQ7Dpef9cZDM3KEMxHklg1h1YL SMDvbtLYAd2p65VGXCsuwB/9PgFVkXDn1A3X++bqJu53psAe4yhmB/a15mua116kOJuF RFKInLwZTYMDRkTwfeT2Hfe3rpCS9ANRHP7CuA0fSKzXHlSLSiW4UVdT6FjpKmNEvIE1 q+sd0/+UC/M5/MneNvyjDociMP7Qon5+4HZtRNaOvhWd1t/9N5s2CxmaUntZ6LWTt4nd AE2Q== X-Gm-Message-State: AN3rC/5ORLWWGfVSgI7a8K8gFEnEhw2hN6Nv8gAGciE6LGPkuhyQHwMo 7acCne4cHanKzKcG X-Received: by 10.98.15.73 with SMTP id x70mr28300478pfi.86.1493667424076; Mon, 01 May 2017 12:37:04 -0700 (PDT) Received: from ban.mtv.corp.google.com ([172.22.64.120]) by smtp.gmail.com with ESMTPSA id n85sm32642715pfi.101.2017.05.01.12.37.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 01 May 2017 12:37:03 -0700 (PDT) From: Brian Norris To: Ganapathi Bhat , Nishant Sarmukadam Cc: , Dmitry Torokhov , Kalle Valo , linux-wireless@vger.kernel.org, Brian Norris Subject: [PATCH v3 2/2] mwifiex: pcie: add card_reset() support Date: Mon, 1 May 2017 12:37:00 -0700 Message-Id: <20170501193700.89264-2-briannorris@chromium.org> X-Mailer: git-send-email 2.13.0.rc0.306.g87b477812d-goog In-Reply-To: <20170501193700.89264-1-briannorris@chromium.org> References: <20170501193700.89264-1-briannorris@chromium.org> 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 Similar to the SDIO driver, we should implement this so that we will automatically reset the device whenever there's a command timeout or similar. Signed-off-by: Brian Norris Reviewed-by: Dmitry Torokhov --- v3: keep all the new reset code in patch 2, not patch 1 v2: use atomic test/set, based on Dmitry's suggestion --- drivers/net/wireless/marvell/mwifiex/pcie.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/drivers/net/wireless/marvell/mwifiex/pcie.c b/drivers/net/wireless/marvell/mwifiex/pcie.c index 5f56e8e6d612..78688ff6ecd0 100644 --- a/drivers/net/wireless/marvell/mwifiex/pcie.c +++ b/drivers/net/wireless/marvell/mwifiex/pcie.c @@ -2822,6 +2822,13 @@ static void mwifiex_pcie_device_dump_work(struct mwifiex_adapter *adapter) mwifiex_upload_device_dump(adapter, drv_info, drv_info_size); } +static void mwifiex_pcie_card_reset_work(struct mwifiex_adapter *adapter) +{ + struct pcie_service_card *card = adapter->card; + + pci_reset_function(card->dev); +} + static void mwifiex_pcie_work(struct work_struct *work) { struct pcie_service_card *card = @@ -2830,6 +2837,9 @@ static void mwifiex_pcie_work(struct work_struct *work) if (test_and_clear_bit(MWIFIEX_IFACE_WORK_DEVICE_DUMP, &card->work_flags)) mwifiex_pcie_device_dump_work(card->adapter); + if (test_and_clear_bit(MWIFIEX_IFACE_WORK_CARD_RESET, + &card->work_flags)) + mwifiex_pcie_card_reset_work(card->adapter); } /* This function dumps FW information */ @@ -2842,6 +2852,14 @@ static void mwifiex_pcie_device_dump(struct mwifiex_adapter *adapter) schedule_work(&card->work); } +static void mwifiex_pcie_card_reset(struct mwifiex_adapter *adapter) +{ + struct pcie_service_card *card = adapter->card; + + 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) { struct pcie_service_card *card = adapter->card; @@ -3271,6 +3289,7 @@ static struct mwifiex_if_ops pcie_ops = { .cleanup_mpa_buf = NULL, .init_fw_port = mwifiex_pcie_init_fw_port, .clean_pcie_ring = mwifiex_clean_pcie_ring_buf, + .card_reset = mwifiex_pcie_card_reset, .reg_dump = mwifiex_pcie_reg_dump, .device_dump = mwifiex_pcie_device_dump, .down_dev = mwifiex_pcie_down_dev,