From patchwork Thu Jul 18 04:24:15 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vasanthakumar Thiagarajan X-Patchwork-Id: 11048493 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-2.web.codeaurora.org (Postfix) with ESMTP id 07A2A746 for ; Thu, 18 Jul 2019 04:24:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CE5112879D for ; Thu, 18 Jul 2019 04:24:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C020F287BA; Thu, 18 Jul 2019 04:24:35 +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=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham 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 51A932879D for ; Thu, 18 Jul 2019 04:24:35 +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:List-Subscribe:List-Help: List-Post:List-Archive:List-Unsubscribe:List-Id:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Cc:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=00zVew6gKvK0shwF6lFn/XD4B88YniOZYoxzuR+IZDQ=; b=gbx+63CnsOajGU CItBR4/FRzhCb8JjsI9oqWc+7MbZHJf9BNYS4PFWvvWFjMgew+Vart62UMhkJRJ2OMv4Wv471hmlU QvfB7o0MsNiihCKP0xkilIGXwe30oEwFGb8SLLLmDMfQ9CSaxxfcc7LScbTuugh1m7Sz05tavTtg9 CkaNohk1sWkkGyM5iKsgsn9Ps/NLiqkEZIrLmMCazgdH6/R3XcU6xXNDCfMFGG13JbXFV46hLJl0Y 3UcvxA9vgHSjVPE6JMk+ew9IuOd/NXwLvvZlEvedJNoBr9TmskbpnK6ssULn+oHzsL4DbyAcUb1V8 kT4j+lE1h4Lly6V8rP6w==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92 #3 (Red Hat Linux)) id 1hnxy6-0006MQ-GH; Thu, 18 Jul 2019 04:24:34 +0000 Received: from smtp.codeaurora.org ([198.145.29.96]) by bombadil.infradead.org with esmtps (Exim 4.92 #3 (Red Hat Linux)) id 1hnxy3-0006LY-8H for ath11k@lists.infradead.org; Thu, 18 Jul 2019 04:24:32 +0000 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 9480A60F37; Thu, 18 Jul 2019 04:24:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1563423870; bh=3HOmuo5t5BXMm96LeldEbUl3CGflN7hbhRdZGS3fLQo=; h=From:To:Subject:Date:In-Reply-To:References:From; b=DLPt0lfG1e29tBfGCJ/It10gJeuNK9IxOZWapA1CwX3N8McrwAU0/BOzvYQ7z8cFS slX8Bka5AwWjAmc60yCnRiTgwjvLPhDSwVyZ2okSCxG7qIHsRmKIoe+g74V7/K+hds 5J3G95ImUdRX6eelVG1ncOpaN89YH7KNd/8S4CEE= Received: from vasanth-lnx.qca.qualcomm.com (blr-c-bdr-fw-01_globalnat_allzones-outside.qualcomm.com [103.229.19.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: vthiagar@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id B71A660E42 for ; Thu, 18 Jul 2019 04:24:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1563423870; bh=3HOmuo5t5BXMm96LeldEbUl3CGflN7hbhRdZGS3fLQo=; h=From:To:Subject:Date:In-Reply-To:References:From; b=DLPt0lfG1e29tBfGCJ/It10gJeuNK9IxOZWapA1CwX3N8McrwAU0/BOzvYQ7z8cFS slX8Bka5AwWjAmc60yCnRiTgwjvLPhDSwVyZ2okSCxG7qIHsRmKIoe+g74V7/K+hds 5J3G95ImUdRX6eelVG1ncOpaN89YH7KNd/8S4CEE= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org B71A660E42 Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=none smtp.mailfrom=vthiagar@codeaurora.org From: Vasanthakumar Thiagarajan To: ath11k@lists.infradead.org Subject: [PATCH 2/2] ath11k/dp_rx: Fix possible REO ring desc overwrite Date: Thu, 18 Jul 2019 09:54:15 +0530 Message-Id: <1563423855-32397-2-git-send-email-vthiagar@codeaurora.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1563423855-32397-1-git-send-email-vthiagar@codeaurora.org> References: <1563423855-32397-1-git-send-email-vthiagar@codeaurora.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190717_212431_325442_66391664 X-CRM114-Status: GOOD ( 12.25 ) X-BeenThere: ath11k@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "ath11k" Errors-To: ath11k-bounces+patchwork-ath11k=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP When we find there is not desc available in REO ring based on the cached hp (head pointer), we again try to read the REO ting with the latest hp that hw might have just updated. In this case we update the tp (tail pointer) before the corresponding desc is completely processed by the driver. This would lead to a scenario where hw will be overwriting the desc which is still not completely prcoessed. Make sure tp is not updated to hw before the residing desc is completely processed. Signed-off-by: Vasanthakumar Thiagarajan --- drivers/net/wireless/ath/ath11k/dp_rx.c | 45 +++++++++++++-------------------- 1 file changed, 17 insertions(+), 28 deletions(-) diff --git a/drivers/net/wireless/ath/ath11k/dp_rx.c b/drivers/net/wireless/ath/ath11k/dp_rx.c index 686b140..63b7275 100644 --- a/drivers/net/wireless/ath/ath11k/dp_rx.c +++ b/drivers/net/wireless/ath/ath11k/dp_rx.c @@ -2104,32 +2104,6 @@ static void ath11k_dp_rx_pre_deliver_amsdu(struct ath11k *ar, } } -static u32 *ath11k_dp_rx_get_reo_desc(struct ath11k_base *ab, - struct hal_srng *srng) -{ - u32 *rx_desc; - - lockdep_assert_held(&srng->lock); - - rx_desc = ath11k_hal_srng_dst_get_next_entry(ab, srng); - - /* Hw might have updated the head pointer after we cached it. - * In this case, even though there are entries in the ring we'll - * get rx_desc NULL. Give the read another try with updated cached - * head pointer so that we can reap complete MPDU in the current - * rx processing. - */ - if (!rx_desc) { - ath11k_hal_srng_access_begin(ab, srng); - rx_desc = ath11k_hal_srng_dst_get_next_entry(ab, srng); - if (!rx_desc) - return NULL; - ath11k_hal_srng_access_end(ab, srng); - } - - return rx_desc; -} - static void ath11k_dp_rx_process_pending_packets(struct ath11k_base *ab, struct napi_struct *napi, struct sk_buff_head *pending_q, @@ -2178,6 +2152,7 @@ int ath11k_dp_process_rx(struct ath11k_base *ab, int mac_id, int num_buffs_reaped = 0; int quota = budget; int ret; + bool done = false; /* Process any pending packets from the previous napi poll. * Note: All msdu's in this pending_q corresponds to the same mac id @@ -2201,7 +2176,8 @@ int ath11k_dp_process_rx(struct ath11k_base *ab, int mac_id, ath11k_hal_srng_access_begin(ab, srng); - while ((rx_desc = ath11k_dp_rx_get_reo_desc(ab, srng))) { +try_again: + while ((rx_desc = ath11k_hal_srng_dst_get_next_entry(ab, srng))) { memset(&meta_info, 0, sizeof(meta_info)); ath11k_hal_rx_parse_dst_ring_desc(ab, rx_desc, &meta_info); @@ -2250,8 +2226,21 @@ int ath11k_dp_process_rx(struct ath11k_base *ab, int mac_id, * and how use of budget instead of remaining quota affects it. */ if (num_buffs_reaped >= quota && rxcb->is_last_msdu && - !rxcb->is_continuation) + !rxcb->is_continuation) { + done = true; break; + } + } + + /* Hw might have updated the head pointer after we cached it. + * In this case, even though there are entries in the ring we'll + * get rx_desc NULL. Give the read another try with updated cached + * head pointer so that we can reap complete MPDU in the current + * rx processing. + */ + if (!done && ath11k_hal_srng_dst_num_free(ab, srng, true)) { + ath11k_hal_srng_access_end(ab, srng); + goto try_again; } ath11k_hal_srng_access_end(ab, srng);