Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp723541pxb; Mon, 25 Oct 2021 17:29:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJysiiY5RjMRYriHRR21GhThwjUjKat1dpADkHUSbLNeswxmjnu6F/t/CTaHW5eEa4rkCejc X-Received: by 2002:a17:902:b616:b0:13f:7983:21b6 with SMTP id b22-20020a170902b61600b0013f798321b6mr19797173pls.42.1635208148386; Mon, 25 Oct 2021 17:29:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1635208148; cv=none; d=google.com; s=arc-20160816; b=0WpQXXNyKbkVpVPws94wsXzU/IKoTuOpEh8ZHrh3sWQOVZLfWsiBsVD/ZOsOq879Hn oVZCcOzl4xP8Ip3X56EAE0MKl/UcE3IxDyGt6MiLnnC23tCKJpQCrF5NldPFZg2Lur9U sR+rwzh03SfYhHBpskd2Jd3JAHqpJ6U9X2GLHY+gWtceglJj8GRnaarCCvMs/Idl43eb Ey7lpel8hdY8WZIPY0eatMUzBF/1qp+thkBYaurlq85q2CxGUNCIObo/iwkj3ncKsG4P iwzbB7roA0xWX6S8vdBhSBM1xW8ehzN3N7kYGQGyv97Ratomwz+HoNUal/mWbgemmwkU 10BA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=ogOxN6jZleO2N/fVexiEHhfkvf8UUWFfAtrWnhu1x9Y=; b=iA62M1MTheeKFyPuWTr9xfsZY28ZUVkFZWHVBFEgd+lpwPpppPUd8oCfK/A/YCEWDh XsPPX2190IcGjE2PtsUhrJHP6pssjgJghKlcfLXTgAorRFVE0DTd0T7a4iYkUBvo5LUs ZXmMxcrXcjqao5f4mhz0nKWTbVCpL8UcZt6qp5FmO26rRnaMu80voA9iiqyYaYl4guNB jJZ12NxZY00PR43wS8KkGyFaglDn01Fcmp6NKCTnKgolSUx739/vI1L1RIaJUuD8sASb YxSIYWa8cIXATy6G0+AbkRy6SVe+/ZPo3mPeBp3mZ+EjG4MdpaGMC7/Su183ZIjlQcqK kuzA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Ru2FbenV; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h17si20478477plf.222.2021.10.25.17.28.55; Mon, 25 Oct 2021 17:29:08 -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=@linuxfoundation.org header.s=korg header.b=Ru2FbenV; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234592AbhJYTw3 (ORCPT + 99 others); Mon, 25 Oct 2021 15:52:29 -0400 Received: from mail.kernel.org ([198.145.29.99]:37366 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237745AbhJYTpx (ORCPT ); Mon, 25 Oct 2021 15:45:53 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id BCD14610A5; Mon, 25 Oct 2021 19:39:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1635190770; bh=JnaI4lkbgv/2+UqoKUFx3Vhe76YHhHmi6aXdFod3FRs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Ru2FbenVe0GOWC7ALKGi8hrDm7KYkILJeb2HTdV2KTQpOv35bYZDMtWO3XLjkdY/h tjnNo2NLe62KqtW704CDoszVHgs6Ta4G+2OfWYw07rDASr5OTcH/AIoD1DdI3im/Mj Z7YMKIl2kFeKBfH7wFhQirT8Wjo1MvLHxy/ICEVA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Yunsheng Lin , Guangbin Huang , "David S. Miller" , Sasha Levin Subject: [PATCH 5.14 047/169] net: hns3: schedule the polling again when allocation fails Date: Mon, 25 Oct 2021 21:13:48 +0200 Message-Id: <20211025191023.732781976@linuxfoundation.org> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211025191017.756020307@linuxfoundation.org> References: <20211025191017.756020307@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Yunsheng Lin [ Upstream commit 68752b24f51a71d4f350a764d890b670f59062c5 ] Currently when there is a rx page allocation failure, it is possible that polling may be stopped if there is no more packet to be reveiced, which may cause queue stall problem under memory pressure. This patch makes sure polling is scheduled again when there is any rx page allocation failure, and polling will try to allocate receive buffers until it succeeds. Now the allocation retry is added, it is unnecessary to do the rx page allocation at the end of rx cleaning, so remove it. And reset the unused_count to zero after calling hns3_nic_alloc_rx_buffers() to avoid calling hns3_nic_alloc_rx_buffers() repeatedly under memory pressure. Fixes: 76ad4f0ee747 ("net: hns3: Add support of HNS3 Ethernet Driver for hip08 SoC") Signed-off-by: Yunsheng Lin Signed-off-by: Guangbin Huang Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- .../net/ethernet/hisilicon/hns3/hns3_enet.c | 22 ++++++++++--------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c index 114692c4f797..796886b112c7 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c @@ -3488,7 +3488,8 @@ static int hns3_desc_unused(struct hns3_enet_ring *ring) return ((ntc >= ntu) ? 0 : ring->desc_num) + ntc - ntu; } -static void hns3_nic_alloc_rx_buffers(struct hns3_enet_ring *ring, +/* Return true if there is any allocation failure */ +static bool hns3_nic_alloc_rx_buffers(struct hns3_enet_ring *ring, int cleand_count) { struct hns3_desc_cb *desc_cb; @@ -3513,7 +3514,10 @@ static void hns3_nic_alloc_rx_buffers(struct hns3_enet_ring *ring, hns3_rl_err(ring_to_netdev(ring), "alloc rx buffer failed: %d\n", ret); - break; + + writel(i, ring->tqp->io_base + + HNS3_RING_RX_RING_HEAD_REG); + return true; } hns3_replace_buffer(ring, ring->next_to_use, &res_cbs); @@ -3526,6 +3530,7 @@ static void hns3_nic_alloc_rx_buffers(struct hns3_enet_ring *ring, } writel(i, ring->tqp->io_base + HNS3_RING_RX_RING_HEAD_REG); + return false; } static bool hns3_can_reuse_page(struct hns3_desc_cb *cb) @@ -4159,6 +4164,7 @@ int hns3_clean_rx_ring(struct hns3_enet_ring *ring, int budget, { #define RCB_NOF_ALLOC_RX_BUFF_ONCE 16 int unused_count = hns3_desc_unused(ring); + bool failure = false; int recv_pkts = 0; int err; @@ -4167,9 +4173,9 @@ int hns3_clean_rx_ring(struct hns3_enet_ring *ring, int budget, while (recv_pkts < budget) { /* Reuse or realloc buffers */ if (unused_count >= RCB_NOF_ALLOC_RX_BUFF_ONCE) { - hns3_nic_alloc_rx_buffers(ring, unused_count); - unused_count = hns3_desc_unused(ring) - - ring->pending_buf; + failure = failure || + hns3_nic_alloc_rx_buffers(ring, unused_count); + unused_count = 0; } /* Poll one pkt */ @@ -4188,11 +4194,7 @@ int hns3_clean_rx_ring(struct hns3_enet_ring *ring, int budget, } out: - /* Make all data has been write before submit */ - if (unused_count > 0) - hns3_nic_alloc_rx_buffers(ring, unused_count); - - return recv_pkts; + return failure ? budget : recv_pkts; } static void hns3_update_rx_int_coalesce(struct hns3_enet_tqp_vector *tqp_vector) -- 2.33.0