From patchwork Thu Nov 27 10:09:38 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Kazior X-Patchwork-Id: 5394511 Return-Path: X-Original-To: patchwork-ath10k@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 66816C11AC for ; Thu, 27 Nov 2014 10:23:28 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 73105201ED for ; Thu, 27 Nov 2014 10:23:27 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id D315B201C0 for ; Thu, 27 Nov 2014 10:23:25 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1XtwEG-0001oD-7L; Thu, 27 Nov 2014 10:23:16 +0000 Received: from mail-wi0-x234.google.com ([2a00:1450:400c:c05::234]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1XtwDn-0001RD-TC for ath10k@lists.infradead.org; Thu, 27 Nov 2014 10:22:49 +0000 Received: by mail-wi0-f180.google.com with SMTP id n3so7806885wiv.1 for ; Thu, 27 Nov 2014 02:22:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tieto.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=PO8uF3w+LLeCnShWbzAtfCuN2gEA+hQGL7YgSaaw5GI=; b=INtKUQ+ci0a1bawpCdJoPRy40NiEb4C4JqTqRoennHtyg6Gr27qXnV49qTVp5pH/Ak N8vka9jOtNjXAn5JNdRc1mvttmSORVBETJHOyd87F124wPZmYS2zMn/qVn3/bi6IUcgW xaktqQpN395gxbOSvdhp284zc5qkBGic7OQ/Q= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=PO8uF3w+LLeCnShWbzAtfCuN2gEA+hQGL7YgSaaw5GI=; b=c7txpx6Q7WHjL1J9P+Fp+oGtWKZZqtd/3QpKSE4e2Xnq4Mq211bdaGcHFCUEanXUw9 /yu9mpErTEnhZuuHPGcIG/q6k3QDjYoASl2wh9G8smT591f1hwYrzc41TkDsfGNTzf4g 9Q4swjpXN6PKScHDm6Hciz1Mgnpt7WEWJWi4JYLj2YOXcAzb+q/p2564yuImAwICbcq3 0e80Vl8ZF+tyUbRipV2ixPm/+kxuKU9fV9RkojSz6i/kPhx9zE7ovwNiEfQvUUhWmylc /jLfHlbDbsVbBqtzZJilW85nlSOBVO2NBE/MB3ksXr9qptpIvgfqHs0EfL9wvsiS1Q86 5JUg== X-Gm-Message-State: ALoCoQm4yHD1Ivo74aumRPMXtAOhpTG6i2P2/W20XD378OArdKxKzQuj1N3QEbbfmA1/OqGu0xBWXjNnnU9bmdc8lz/Yx3Y+dVpx0U4n7vsrDdJOD4lZPX4XAKQ0xeoxP0wEDL9AhHsncB6LOty5IIuF1GSFq9AKADXBuRQTQtzMfp+CV4axD5w= X-Received: by 10.180.186.40 with SMTP id fh8mr49832176wic.40.1417083745687; Thu, 27 Nov 2014 02:22:25 -0800 (PST) Received: from localhost.localdomain ([91.198.246.8]) by mx.google.com with ESMTPSA id wx3sm10056383wjc.19.2014.11.27.02.22.24 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 27 Nov 2014 02:22:25 -0800 (PST) From: Michal Kazior To: ath10k@lists.infradead.org Subject: [PATCH 3/3] ath10k: prevent pci tx/rx starvation Date: Thu, 27 Nov 2014 11:09:38 +0100 Message-Id: <1417082978-1701-3-git-send-email-michal.kazior@tieto.com> X-Mailer: git-send-email 1.8.5.3 In-Reply-To: <1417082978-1701-1-git-send-email-michal.kazior@tieto.com> References: <1417082978-1701-1-git-send-email-michal.kazior@tieto.com> X-DomainID: tieto.com X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20141127_022248_209891_CD788128 X-CRM114-Status: GOOD ( 11.52 ) X-Spam-Score: -0.8 (/) Cc: linux-wireless@vger.kernel.org, Michal Kazior X-BeenThere: ath10k@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "ath10k" Errors-To: ath10k-bounces+patchwork-ath10k=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-2.5 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_LOW, T_DKIM_INVALID, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP In theory it was possible to starve the system if a tx/rx handler could implicitly trigger more tx/rx pci events. Signed-off-by: Michal Kazior --- drivers/net/wireless/ath/ath10k/pci.c | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/drivers/net/wireless/ath/ath10k/pci.c b/drivers/net/wireless/ath/ath10k/pci.c index 95e9066..7abb836 100644 --- a/drivers/net/wireless/ath/ath10k/pci.c +++ b/drivers/net/wireless/ath/ath10k/pci.c @@ -823,20 +823,24 @@ static void ath10k_pci_ce_send_done(struct ath10k_ce_pipe *ce_state) struct ath10k *ar = ce_state->ar; struct ath10k_pci *ar_pci = ath10k_pci_priv(ar); struct ath10k_hif_cb *cb = &ar_pci->msg_callbacks_current; - void *transfer_context; + struct sk_buff_head list; + struct sk_buff *skb; u32 ce_data; unsigned int nbytes; unsigned int transfer_id; - while (ath10k_ce_completed_send_next(ce_state, &transfer_context, - &ce_data, &nbytes, - &transfer_id) == 0) { + __skb_queue_head_init(&list); + while (ath10k_ce_completed_send_next(ce_state, (void **)&skb, &ce_data, + &nbytes, &transfer_id) == 0) { /* no need to call tx completion for NULL pointers */ - if (transfer_context == NULL) + if (skb == NULL) continue; - cb->tx_completion(ar, transfer_context); + __skb_queue_tail(&list, skb); } + + while ((skb = __skb_dequeue(&list))) + cb->tx_completion(ar, skb); } /* Called by lower (CE) layer when data is received from the Target. */ @@ -847,12 +851,14 @@ static void ath10k_pci_ce_recv_data(struct ath10k_ce_pipe *ce_state) struct ath10k_pci_pipe *pipe_info = &ar_pci->pipe_info[ce_state->id]; struct ath10k_hif_cb *cb = &ar_pci->msg_callbacks_current; struct sk_buff *skb; + struct sk_buff_head list; void *transfer_context; u32 ce_data; unsigned int nbytes, max_nbytes; unsigned int transfer_id; unsigned int flags; + __skb_queue_head_init(&list); while (ath10k_ce_completed_recv_next(ce_state, &transfer_context, &ce_data, &nbytes, &transfer_id, &flags) == 0) { @@ -869,7 +875,10 @@ static void ath10k_pci_ce_recv_data(struct ath10k_ce_pipe *ce_state) } skb_put(skb, nbytes); + __skb_queue_tail(&list, skb); + } + while ((skb = __skb_dequeue(&list))) { ath10k_dbg(ar, ATH10K_DBG_PCI, "pci rx ce pipe %d len %d\n", ce_state->id, skb->len); ath10k_dbg_dump(ar, ATH10K_DBG_PCI_DUMP, NULL, "pci rx: ",