From patchwork Thu Sep 6 09:18:50 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stanislaw Gruszka X-Patchwork-Id: 10590333 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B13DB14BD for ; Thu, 6 Sep 2018 09:23:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8ACED27F2B for ; Thu, 6 Sep 2018 09:23:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7C8592A520; Thu, 6 Sep 2018 09:23:11 +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=-2.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 1E30027F2B for ; Thu, 6 Sep 2018 09:23:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=2tJ5XqZ4jLyiUuFIczf4LAqB0+04L478eqJ8LT4MLzU=; b=mWAn+YUBalLv6e8d+ZHngL7tC8 U9V4MOy1XT3GQJua5Xcl2C+AkuBn/ep03TDQllG9OhaqAUwBVwxsHSwhvx34hizM8OVvzV+ZOadI6 w10+2VJhTp9sbVUjZ+R/NJka7xZa2LLn/sJN3y+TKfl3qlYZdE2+OANoenFa4/1LOLfbGoOfbPByb SKeuNfGhnTr3kgh1VjYb2A2UUxJdmbCfP8Zy7h94R00yWaBuBpw+jGRKurjeCGxXKaIAt8joeTO1/ hVK9mKJBVgmU2+x7jdX2KNExz+wH0akRjzMeW1xu7+icMWhj1gm4ARH5c6Ri+bSx9oC7Cinvyffb0 4AE0WfUg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1fxqVH-0008Iq-Jp for patchwork-linux-mediatek@patchwork.kernel.org; Thu, 06 Sep 2018 09:23:07 +0000 Received: from mx3-rdu2.redhat.com ([66.187.233.73] helo=mx1.redhat.com) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fxqSq-0006Yl-3M for linux-mediatek@lists.infradead.org; Thu, 06 Sep 2018 09:20:43 +0000 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 40EC080823E3; Thu, 6 Sep 2018 09:20:26 +0000 (UTC) Received: from localhost (unknown [10.40.205.33]) by smtp.corp.redhat.com (Postfix) with ESMTP id B251D200A4B5; Thu, 6 Sep 2018 09:20:25 +0000 (UTC) From: Stanislaw Gruszka To: linux-wireless@vger.kernel.org Subject: [PATCH 34/42] mt76x0: do not free/alloc buffers during suspend/resume Date: Thu, 6 Sep 2018 11:18:50 +0200 Message-Id: <1536225538-16454-35-git-send-email-sgruszka@redhat.com> In-Reply-To: <1536225538-16454-1-git-send-email-sgruszka@redhat.com> References: <1536225538-16454-1-git-send-email-sgruszka@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Thu, 06 Sep 2018 09:20:26 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Thu, 06 Sep 2018 09:20:26 +0000 (UTC) for IP:'10.11.54.4' DOMAIN:'int-mx04.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'sgruszka@redhat.com' RCPT:'' X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180906_022036_346786_74D4181A X-CRM114-Status: GOOD ( 12.78 ) X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Lorenzo Bianconi , linux-mediatek@lists.infradead.org, Felix Fietkau MIME-Version: 1.0 Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+patchwork-linux-mediatek=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP From: Lorenzo Bianconi Do not free/alloc {tx,rx} buffers during suspend/resume phases but use the ones previously allocated during hw probe. Move {tx,rx}/mcu buffers allocation from mt76x0_init_hardware routine to mt76x0_register_device Signed-off-by: Lorenzo Bianconi Signed-off-by: Stanislaw Gruszka --- drivers/net/wireless/mediatek/mt76/mt76x0/init.c | 12 +++++--- drivers/net/wireless/mediatek/mt76/mt76x0/mcu.c | 6 ---- drivers/net/wireless/mediatek/mt76/mt76x0/usb.c | 38 ++++++++++++++++++------ 3 files changed, 37 insertions(+), 19 deletions(-) diff --git a/drivers/net/wireless/mediatek/mt76/mt76x0/init.c b/drivers/net/wireless/mediatek/mt76/mt76x0/init.c index deceece52492..8f4b3197ab95 100644 --- a/drivers/net/wireless/mediatek/mt76/mt76x0/init.c +++ b/drivers/net/wireless/mediatek/mt76/mt76x0/init.c @@ -408,10 +408,6 @@ int mt76x0_init_hardware(struct mt76x0_dev *dev) if (ret) return ret; - ret = mt76u_alloc_queues(&dev->mt76); - if (ret < 0) - return ret; - mt76x0_init_mac_registers(dev); if (!mt76_poll_msec(dev, MT_MAC_STATUS, @@ -614,6 +610,14 @@ int mt76x0_register_device(struct mt76x0_dev *dev) struct wiphy *wiphy = hw->wiphy; int ret; + ret = mt76u_mcu_init_rx(mdev); + if (ret < 0) + return ret; + + ret = mt76u_alloc_queues(mdev); + if (ret < 0) + return ret; + ret = mt76x0_init_hardware(dev); if (ret) return ret; diff --git a/drivers/net/wireless/mediatek/mt76/mt76x0/mcu.c b/drivers/net/wireless/mediatek/mt76/mt76x0/mcu.c index 7be2835f3b4f..29c0b3978af7 100644 --- a/drivers/net/wireless/mediatek/mt76/mt76x0/mcu.c +++ b/drivers/net/wireless/mediatek/mt76/mt76x0/mcu.c @@ -387,11 +387,5 @@ int mt76x0_mcu_init(struct mt76x0_dev *dev) int mt76x0_mcu_cmd_init(struct mt76x0_dev *dev) { - int ret; - - ret = mt76u_mcu_init_rx(&dev->mt76); - if (ret) - return ret; - return mt76x0_mcu_function_select(dev, Q_SELECT, 1); } diff --git a/drivers/net/wireless/mediatek/mt76/mt76x0/usb.c b/drivers/net/wireless/mediatek/mt76/mt76x0/usb.c index 09b544890450..fc8884c38f7e 100644 --- a/drivers/net/wireless/mediatek/mt76/mt76x0/usb.c +++ b/drivers/net/wireless/mediatek/mt76/mt76x0/usb.c @@ -124,29 +124,49 @@ static void mt76x0_disconnect(struct usb_interface *usb_intf) ieee80211_free_hw(dev->mt76.hw); } -static int mt76x0_suspend(struct usb_interface *usb_intf, pm_message_t state) +static int __maybe_unused mt76x0_suspend(struct usb_interface *usb_intf, + pm_message_t state) { struct mt76x0_dev *dev = usb_get_intfdata(usb_intf); + struct mt76_usb *usb = &dev->mt76.usb; - mt76x0_cleanup(dev); + mt76u_stop_queues(&dev->mt76); + mt76x0_mac_stop(dev); + usb_kill_urb(usb->mcu.res.urb); return 0; } -static int mt76x0_resume(struct usb_interface *usb_intf) +static int __maybe_unused mt76x0_resume(struct usb_interface *usb_intf) { struct mt76x0_dev *dev = usb_get_intfdata(usb_intf); + struct mt76_usb *usb = &dev->mt76.usb; int ret; - ret = mt76x0_init_hardware(dev); - if (ret) { - mt76x0_cleanup(dev); - return ret; - } + reinit_completion(&usb->mcu.cmpl); + ret = mt76u_submit_buf(&dev->mt76, USB_DIR_IN, + MT_EP_IN_CMD_RESP, + &usb->mcu.res, GFP_KERNEL, + mt76u_mcu_complete_urb, + &usb->mcu.cmpl); + if (ret < 0) + goto err; - set_bit(MT76_STATE_INITIALIZED, &dev->mt76.state); + ret = mt76u_submit_rx_buffers(&dev->mt76); + if (ret < 0) + goto err; + + tasklet_enable(&usb->rx_tasklet); + tasklet_enable(&usb->tx_tasklet); + + ret = mt76x0_init_hardware(dev); + if (ret) + goto err; return 0; +err: + mt76x0_cleanup(dev); + return ret; } MODULE_DEVICE_TABLE(usb, mt76x0_device_table);