From patchwork Tue Aug 22 21:44:02 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: ryanhsu@qti.qualcomm.com X-Patchwork-Id: 9916211 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 1B402603F9 for ; Tue, 22 Aug 2017 21:44:49 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0CC39288AA for ; Tue, 22 Aug 2017 21:44:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 018EC288FA; Tue, 22 Aug 2017 21:44:48 +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.6 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_LOW autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.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 800FA288B1 for ; Tue, 22 Aug 2017 21:44:48 +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:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version: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:In-Reply-To:References: List-Owner; bh=nnYdsnUxMpE0a3LoQqgqwVg4Zcapf04xD/16C+kaeX4=; b=rUsHE/NUAc2GJb c1r/qhpnyLwo5ZE6YPB/vtQp+xBr8TcvR0faUt6Lna1ZbEZmRPHOmbVUEZYweHstCMiFUsoQfaiig 6rZfWl8yAu+12isiN5/p+rBszUDjiHkMP5IVn5AS6baIhx/1S99yz1WGV4u7/yGRFPcBOKRMmJ5jz USxwdBYerAobJs6sW6ggMX+eneCPQdDasy5BShEsA/kBfeKLdNIkzQ7hCMvQNl4qfKa1e179L3P78 B7+ixfR/mTcmctV81JFRJpNQULexa+W/bnOQG9uvBAvCOb0dTMWO5jWiYonUfQC6iKHjYRmyplS+K deiHdDrIO956/6REM6fA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1dkGyZ-0008Nx-FU; Tue, 22 Aug 2017 21:44:43 +0000 Received: from alexa-out.qualcomm.com ([129.46.98.28] helo=alexa-out-lv-02.qualcomm.com) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1dkGyW-00088R-87 for ath10k@lists.infradead.org; Tue, 22 Aug 2017 21:44:42 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=qti.qualcomm.com; i=@qti.qualcomm.com; q=dns/txt; s=qcdkim; t=1503438280; x=1534974280; h=from:to:cc:subject:date:message-id:mime-version; bh=0ynAopMWtl8TIt5xuhxhS3KR1dtijYKHjx2+gRYJ5iQ=; b=xaVrW3crfHX8MUBfNHPBBF8wgWxxVEgnKADMuSrPcRr1bUK4ZwI5MQCR mlvUcnXf/ENKqTNl4lv0vSKPEisdmnU4Dnolumc3CgE8viAJLLIAKogwJ 7+VfremBpWTIdekIN6NvpYvOzVhSIKLyWOmWsAFB/RFnOHupxRs1rnmGr g=; X-IronPort-AV: E=Sophos;i="5.41,414,1498546800"; d="scan'208";a="3688985" Received: from ironmsg03-lv.qualcomm.com ([10.47.202.181]) by alexa-out-lv-02.qualcomm.com with ESMTP; 22 Aug 2017 14:44:19 -0700 X-IronPort-AV: E=McAfee;i="5900,7806,8631"; a="29902411" X-MGA-submission: =?us-ascii?q?MDG9Ir2QHhJt9pvxsxJAbWmdAVIHzsWJWDcPe8?= =?us-ascii?q?NBXvKyVs0/ZBImwOgbTkSHWU+GMEuAhgNokdV0ASs1xhdr2ssRbqgfLn?= =?us-ascii?q?aXm6O/IQ0AzPr4dD7POPICWfWsBFaPHd6mpqcgVny2l1UfR7Tyo674Ii?= =?us-ascii?q?PK?= Received: from nalasexr01g.na.qualcomm.com ([10.49.56.53]) by ironmsg03-lv.qualcomm.com with ESMTP/TLS/RC4-SHA; 22 Aug 2017 14:43:33 -0700 Received: from ryanhsu-linux2.qualcomm.com (10.80.80.8) by NALASEXR01G.na.qualcomm.com (10.49.56.53) with Microsoft SMTP Server (TLS) id 15.0.1178.4; Tue, 22 Aug 2017 14:43:33 -0700 From: To: , Subject: [PATCH] ath10k: fix napi_poll budget overflow Date: Tue, 22 Aug 2017 14:44:02 -0700 Message-ID: <1503438242-5657-1-git-send-email-ryanhsu@qti.qualcomm.com> X-Mailer: git-send-email 1.9.1 MIME-Version: 1.0 X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: NASANEXM01E.na.qualcomm.com (10.85.0.31) To NALASEXR01G.na.qualcomm.com (10.49.56.53) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170822_144440_416318_AE9C4CA9 X-CRM114-Status: GOOD ( 10.19 ) X-BeenThere: ath10k@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: ryanhsu@qti.qualcomm.com Sender: "ath10k" Errors-To: ath10k-bounces+patchwork-ath10k=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP From: Ryan Hsu In napi_poll, the budget number is used to control the amount of packets we should handle per poll to balance the resource in the system. In the list of the amsdu packets reception, we check if there is budget count left and handle the complete list of the packets, that it will have chances the very last list will over the budget leftover. So adding one more parameter - budget_left, this would help while traversing the list to avoid handling more than the budget given. Reported-by: Andrey Ryabinin Fix-suggested-by: Igor Mitsyanko Signed-off-by: Ryan Hsu --- drivers/net/wireless/ath/ath10k/htt_rx.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/drivers/net/wireless/ath/ath10k/htt_rx.c b/drivers/net/wireless/ath/ath10k/htt_rx.c index 0b4c156..95a5a18 100644 --- a/drivers/net/wireless/ath/ath10k/htt_rx.c +++ b/drivers/net/wireless/ath/ath10k/htt_rx.c @@ -1718,7 +1718,8 @@ static void ath10k_htt_rx_delba(struct ath10k *ar, struct htt_resp *resp) } static int ath10k_htt_rx_extract_amsdu(struct sk_buff_head *list, - struct sk_buff_head *amsdu) + struct sk_buff_head *amsdu, + int budget_left) { struct sk_buff *msdu; struct htt_rx_desc *rxd; @@ -1729,8 +1730,9 @@ static int ath10k_htt_rx_extract_amsdu(struct sk_buff_head *list, if (WARN_ON(!skb_queue_empty(amsdu))) return -EINVAL; - while ((msdu = __skb_dequeue(list))) { + while ((msdu = __skb_dequeue(list)) && budget_left) { __skb_queue_tail(amsdu, msdu); + budget_left--; rxd = (void *)msdu->data - sizeof(*rxd); if (rxd->msdu_end.common.info0 & @@ -1821,7 +1823,8 @@ static int ath10k_htt_rx_h_rx_offload(struct ath10k *ar, return num_msdu; } -static int ath10k_htt_rx_in_ord_ind(struct ath10k *ar, struct sk_buff *skb) +static int ath10k_htt_rx_in_ord_ind(struct ath10k *ar, struct sk_buff *skb, + int budget_left) { struct ath10k_htt *htt = &ar->htt; struct htt_resp *resp = (void *)skb->data; @@ -1878,9 +1881,9 @@ static int ath10k_htt_rx_in_ord_ind(struct ath10k *ar, struct sk_buff *skb) if (offload) num_msdus = ath10k_htt_rx_h_rx_offload(ar, &list); - while (!skb_queue_empty(&list)) { + while (!skb_queue_empty(&list) && budget_left) { __skb_queue_head_init(&amsdu); - ret = ath10k_htt_rx_extract_amsdu(&list, &amsdu); + ret = ath10k_htt_rx_extract_amsdu(&list, &amsdu, budget_left); switch (ret) { case 0: /* Note: The in-order indication may report interleaved @@ -1890,6 +1893,7 @@ static int ath10k_htt_rx_in_ord_ind(struct ath10k *ar, struct sk_buff *skb) * should still give an idea about rx rate to the user. */ num_msdus += skb_queue_len(&amsdu); + budget_left -= skb_queue_len(&amsdu); ath10k_htt_rx_h_ppdu(ar, &amsdu, status, vdev_id); ath10k_htt_rx_h_filter(ar, &amsdu, status); ath10k_htt_rx_h_mpdu(ar, &amsdu, status); @@ -2400,7 +2404,8 @@ int ath10k_htt_txrx_compl_task(struct ath10k *ar, int budget) } spin_lock_bh(&htt->rx_ring.lock); - num_rx_msdus = ath10k_htt_rx_in_ord_ind(ar, skb); + num_rx_msdus = ath10k_htt_rx_in_ord_ind(ar, skb, + (budget - quota)); spin_unlock_bh(&htt->rx_ring.lock); if (num_rx_msdus < 0) { resched_napi = true;