From patchwork Mon May 21 20:43:59 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Niklas Cassel X-Patchwork-Id: 136502 Delivered-To: patch@linaro.org Received: by 2002:a50:ec09:0:0:0:0:0 with SMTP id g9-v6csp728904edr; Mon, 21 May 2018 13:44:15 -0700 (PDT) X-Google-Smtp-Source: AB8JxZoLdXuYxwwJnin18S+CC21wk6D/LUQiCtsOgTIYAtp2ltCyt4u/Jfr87rway5MumgG0VZzY X-Received: by 2002:a63:ac1a:: with SMTP id v26-v6mr17160887pge.105.1526935455549; Mon, 21 May 2018 13:44:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526935455; cv=none; d=google.com; s=arc-20160816; b=qfoZCGCukx+ssRczzmLX4zyVpjnuERh5ry2z68iEQIwHeuFID80+gzo4RlEMDYPRmr 2l1EIqrt9ftPAvsVF0VwS/Nm1MEqLLiArlm+CVAb+MTfHKqX+jtX0Y1b485IOkVyLwmz +0KagnrUOser9nw4HJ8DqCokiDhMoB04mKeIb7IJIQFccwHshFuWRiROsRdNP/SNGYeb GuBOBW+NBJOVhrie0/Smpx4wO6UqlyNylSiP/yUxfZ3iJIIqw9HAA4tOkb44K0z3G9ed Vm/3MvAqPGTSrgnoJ4MnCQ5J9nTfESxZV7k8lw8ByPBB8TTFENdM3t0XRtrZ6iyczF2w 79Bw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=bHVcNdmFIIAIu2uug9YIcw/g+DLQaXmXVrR7NA4ECEI=; b=kuAszNw2h/agEAiQhxhtw9MrAaI6JunfXi/FDgFpp//+l5wZwbHZ8cIKCvzkl1vxY6 OOhaY/jl7C75sMGBcJ1esR+rULcZuVC8JT/55plpRKVcNrj4yYMI1ZPCsYIYNJla6cu7 YBuZ5+UZCMfOuJate8k1YLln4YGRvC0pQAeGcLKpJpZvK7J/6GhGxgGQ0MWyqQuWwPSM ZL/HF6ONeD+SwzUC31rw7ho17MAAaMnXVlGsKE9tvK80u6+s2VkNysxhW9KP27hLlyuq 7cBmQDW811LpY51kpPHAN/iK76RTt70un7bC3k+ulPVhqtrOG8KxLeyTknKhBCJdVX+t rTsw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=K5ZlMja1; spf=pass (google.com: best guess record for domain of netdev-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h10-v6si11712955pgp.496.2018.05.21.13.44.14; Mon, 21 May 2018 13:44:15 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of netdev-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=K5ZlMja1; spf=pass (google.com: best guess record for domain of netdev-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751286AbeEUUoM (ORCPT + 9 others); Mon, 21 May 2018 16:44:12 -0400 Received: from mail-lf0-f68.google.com ([209.85.215.68]:46950 "EHLO mail-lf0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750977AbeEUUoJ (ORCPT ); Mon, 21 May 2018 16:44:09 -0400 Received: by mail-lf0-f68.google.com with SMTP id t22-v6so6625200lff.13 for ; Mon, 21 May 2018 13:44:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=bHVcNdmFIIAIu2uug9YIcw/g+DLQaXmXVrR7NA4ECEI=; b=K5ZlMja1d4ix1f9Ms5TP+C75Fv6VRcATpSJn9+g+NdV2PjgMJIPOiZ0PwfIi43e/kb feju90siko7rtrS/qd3ovMAFrT5mzXhbY8FOHu/rHPHsuTs0cRYcH3qQ+ZH9Wy5Ovzs4 WK5h5dJFAOsiFycOdSNFv+2xQQ3QPq47BnOfU= 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:mime-version :content-transfer-encoding; bh=bHVcNdmFIIAIu2uug9YIcw/g+DLQaXmXVrR7NA4ECEI=; b=qSGKzogmfdxtawnEejtVcGN+lW3Nl1O32xW143grD4KK8hGcyEg+WMZI1tNzeof83T W5vnVRAN3gKnJXp5gcgxsauZihGApONi9m3kL/c/Zi/5u8SwH1fl7B/LjBWx5fb4n4Ae HAzX2agxfqXKBER1VDqdGCSkpIDxnJ2vA9hPGF/37wY6/RdumpXakfcP6K73w2fgbrSW p0KPktZZjoLHVdiBbdQHv3d3HQU8Y8epKrWCqYzkZAni7lATYPzhfpOI0fhLxjS8EvXS L2ptt/U1SVTGFA/PH965Y7vE87gnyAu5ze1LuhWKYDLxHWgdzUyb66H7Xu4y3GI/D6q1 9A8Q== X-Gm-Message-State: ALKqPwfqzpWnI4nPg79vXWlrnvzDg+TwaDiJwPCMiCsPiOszv6OUj+zl U2iZ6s0gHUMtLRMaAa7uLDNEjQ== X-Received: by 2002:a2e:8993:: with SMTP id c19-v6mr13549272lji.123.1526935448310; Mon, 21 May 2018 13:44:08 -0700 (PDT) Received: from localhost.lan (h-229-118.A785.priv.bahnhof.se. [5.150.229.118]) by smtp.gmail.com with ESMTPSA id a21-v6sm3630660lfl.84.2018.05.21.13.44.07 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 21 May 2018 13:44:07 -0700 (PDT) From: Niklas Cassel To: Kalle Valo , "David S. Miller" Cc: Niklas Cassel , ath10k@lists.infradead.org, linux-wireless@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2] ath10k: transmit queued frames after waking queues Date: Mon, 21 May 2018 22:43:59 +0200 Message-Id: <20180521204359.23884-1-niklas.cassel@linaro.org> X-Mailer: git-send-email 2.17.0 MIME-Version: 1.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org The following problem was observed when running iperf: [ 3] 0.0- 1.0 sec 2.00 MBytes 16.8 Mbits/sec [ 3] 1.0- 2.0 sec 3.12 MBytes 26.2 Mbits/sec [ 3] 2.0- 3.0 sec 3.25 MBytes 27.3 Mbits/sec [ 3] 3.0- 4.0 sec 655 KBytes 5.36 Mbits/sec [ 3] 4.0- 5.0 sec 0.00 Bytes 0.00 bits/sec [ 3] 5.0- 6.0 sec 0.00 Bytes 0.00 bits/sec [ 3] 6.0- 7.0 sec 0.00 Bytes 0.00 bits/sec [ 3] 7.0- 8.0 sec 0.00 Bytes 0.00 bits/sec [ 3] 8.0- 9.0 sec 0.00 Bytes 0.00 bits/sec [ 3] 9.0-10.0 sec 0.00 Bytes 0.00 bits/sec [ 3] 0.0-10.3 sec 9.01 MBytes 7.32 Mbits/sec There are frames in the ieee80211_txq and there are frames that have been removed from from this queue, but haven't yet been sent on the wire (num_pending_tx). When num_pending_tx reaches max_num_pending_tx, we will stop the queues by calling ieee80211_stop_queues(). As frames that have previously been sent for transmission (num_pending_tx) are completed, we will decrease num_pending_tx and wake the queues by calling ieee80211_wake_queue(). ieee80211_wake_queue() does not call wake_tx_queue, so we might still have frames in the queue at this point. While the queues were stopped, the socket buffer might have filled up, and in order for user space to write more, we need to free the frames in the queue, since they are accounted to the socket. In order to free them, we first need to transmit them. In order to avoid trying to flush the queue every time we free a frame, only do this when there are 3 or less frames pending, and while we actually have frames in the queue. This logic was copied from mt76_txq_schedule (mt76), one of few other drivers that are actually using wake_tx_queue. Suggested-by: Toke Høiland-Jørgensen Signed-off-by: Niklas Cassel --- Changes since V1: use READ_ONCE() to disallow the compiler optimizing things in undesirable ways. drivers/net/wireless/ath/ath10k/txrx.c | 3 +++ 1 file changed, 3 insertions(+) -- 2.17.0 diff --git a/drivers/net/wireless/ath/ath10k/txrx.c b/drivers/net/wireless/ath/ath10k/txrx.c index cda164f6e9f6..264cf0bd5c00 100644 --- a/drivers/net/wireless/ath/ath10k/txrx.c +++ b/drivers/net/wireless/ath/ath10k/txrx.c @@ -95,6 +95,9 @@ int ath10k_txrx_tx_unref(struct ath10k_htt *htt, wake_up(&htt->empty_tx_wq); spin_unlock_bh(&htt->tx_lock); + if (READ_ONCE(htt->num_pending_tx) <= 3 && !list_empty(&ar->txqs)) + ath10k_mac_tx_push_pending(ar); + dma_unmap_single(dev, skb_cb->paddr, msdu->len, DMA_TO_DEVICE); ath10k_report_offchan_tx(htt->ar, msdu);