Received: by 2002:a17:90b:8d0:0:0:0:0 with SMTP id ds16csp4876821pjb; Mon, 27 Jul 2020 07:23:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwGRhBiymFwyQbJtzVsUyO5EjDscVo51lVqdP+7MGOzQxPIvg/WyarVawJKHQ4/KOXMkQyJ X-Received: by 2002:a17:906:1ed3:: with SMTP id m19mr15260114ejj.396.1595859832132; Mon, 27 Jul 2020 07:23:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595859832; cv=none; d=google.com; s=arc-20160816; b=fDyPybqH9biqi5Pe3heM/7W0xXBAUPVm9YH3JG4ok/DmWFCz2HyMDWOR49oN/10wjg axzxIfHqYAEJP1Rnf6t1Mq7jLcLuyDCtr6UM3JUpUf7GSf8Xx2KQ0A6HtaUTx/n7bhVt Hj8OID4RVNjBnXX5QdEBjYlViHUvOk/i6Ag/e86XcVR6qZV4Hy9/Y/KSts16SrGV/QqZ 8U+bcplvN64pqTgINth02VAt8DKRbRTd6Hfa4R0PWYBqMl/ELfLcxxXJJAkos+bKG8jc WgAgknzgZcCyb8t/a1CStR3Txvjq7jzEzCSq10sL9epgjBFVupz1a7PIgU2VgauBHw9n sFFw== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=9QRC7nkAaxui62MY72gW3ZQ5ggCPrOy0p+USSQDlRv4=; b=dgnFprLkIVHpLkDg8oskuozRFHZxDtj+Ekw5d+iSa2WRbVNcwokyV3hRhKPGk52xeo pPeOsJw8i7DNgGihQpz9Nf0OTjnK6A9Qv+sPvlujvyVtTMkx6Pcyty1ePNPd4LlDiSUU EfABGXGTd5ulsWLfGYx8nDoqMOFCv554mAmkIwNJfzWMNee6vw1Kf8xlU7Eh6PIsRFDr lreDocktPBWUZWsYFxDcv5Clz1+1XBr3QIzd2U0IwEIEFJ8yW5yCM/9KcGNpgjM8/8EX 7aPih+XNoL8GEhzsN+DWFhVhGmRDGyvflyXQAbNGfGNA0Wg0Rksk1H6A6xK3gfPXpnCm /KiA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=LC4zaScf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a2si5753273edq.272.2020.07.27.07.23.29; Mon, 27 Jul 2020 07:23:52 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=LC4zaScf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731825AbgG0OWJ (ORCPT + 99 others); Mon, 27 Jul 2020 10:22:09 -0400 Received: from mail.kernel.org ([198.145.29.99]:50934 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731833AbgG0OWF (ORCPT ); Mon, 27 Jul 2020 10:22:05 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 3C9C721775; Mon, 27 Jul 2020 14:22:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1595859724; bh=UB1WFAH0LsvRP3pR4wMVX8K7pSEkfAz9uaGlQBD04b8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LC4zaScf3dgloaNBJ1HMfoaXusieb9iA1avXkfVSYaQUvBk1+yso08XiAnMUIHuLF +TKx3S3C9CidhXYgS751lKZanJioVHk2IXIeHIUaLqPwusPlodIVX3MElQPehMfMfN e8vwi/TcJu3Krls0P9rk/XCyskJ8+Gp794oq9xi4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Yunsheng Lin , Huazhong Tan , "David S. Miller" , Sasha Levin Subject: [PATCH 5.7 079/179] net: hns3: fix error handling for desc filling Date: Mon, 27 Jul 2020 16:04:14 +0200 Message-Id: <20200727134936.531272429@linuxfoundation.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200727134932.659499757@linuxfoundation.org> References: <20200727134932.659499757@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Yunsheng Lin [ Upstream commit 8ceca59fb3ed48a693171bd571c4fcbd555b7f1f ] The content of the TX desc is automatically cleared by the HW when the HW has sent out the packet to the wire. When desc filling fails in hns3_nic_net_xmit(), it will call hns3_clear_desc() to do the error handling, which miss zeroing of the TX desc and the checking if a unmapping is needed. So add the zeroing and checking in hns3_clear_desc() to avoid the above problem. Also add DESC_TYPE_UNKNOWN to indicate the info in desc_cb is not valid, because hns3_nic_reclaim_desc() may treat the desc_cb->type of zero as packet and add to the sent pkt statistics accordingly. Fixes: 76ad4f0ee747 ("net: hns3: Add support of HNS3 Ethernet Driver for hip08 SoC") Signed-off-by: Yunsheng Lin Signed-off-by: Huazhong Tan Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- drivers/net/ethernet/hisilicon/hns3/hnae3.h | 1 + drivers/net/ethernet/hisilicon/hns3/hns3_enet.c | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/drivers/net/ethernet/hisilicon/hns3/hnae3.h b/drivers/net/ethernet/hisilicon/hns3/hnae3.h index 5587605d6deb2..cc45662f77f04 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hnae3.h +++ b/drivers/net/ethernet/hisilicon/hns3/hnae3.h @@ -77,6 +77,7 @@ ((ring)->p = ((ring)->p - 1 + (ring)->desc_num) % (ring)->desc_num) enum hns_desc_type { + DESC_TYPE_UNKNOWN, DESC_TYPE_SKB, DESC_TYPE_FRAGLIST_SKB, DESC_TYPE_PAGE, diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c index 5dab84aa3afd5..df1cb0441183c 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c @@ -1351,6 +1351,10 @@ static void hns3_clear_desc(struct hns3_enet_ring *ring, int next_to_use_orig) unsigned int i; for (i = 0; i < ring->desc_num; i++) { + struct hns3_desc *desc = &ring->desc[ring->next_to_use]; + + memset(desc, 0, sizeof(*desc)); + /* check if this is where we started */ if (ring->next_to_use == next_to_use_orig) break; @@ -1358,6 +1362,9 @@ static void hns3_clear_desc(struct hns3_enet_ring *ring, int next_to_use_orig) /* rollback one */ ring_ptr_move_bw(ring, next_to_use); + if (!ring->desc_cb[ring->next_to_use].dma) + continue; + /* unmap the descriptor dma address */ if (ring->desc_cb[ring->next_to_use].type == DESC_TYPE_SKB || ring->desc_cb[ring->next_to_use].type == @@ -1374,6 +1381,7 @@ static void hns3_clear_desc(struct hns3_enet_ring *ring, int next_to_use_orig) ring->desc_cb[ring->next_to_use].length = 0; ring->desc_cb[ring->next_to_use].dma = 0; + ring->desc_cb[ring->next_to_use].type = DESC_TYPE_UNKNOWN; } } -- 2.25.1