Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp10410005ybi; Wed, 24 Jul 2019 22:42:56 -0700 (PDT) X-Google-Smtp-Source: APXvYqxy7A5+rPhkGe5qHPoupIm7/fiAdRFo2D40JYMB7fVglxs5C/vJ31DLuBaf8ebqDkacD5kz X-Received: by 2002:a17:902:b603:: with SMTP id b3mr90580712pls.9.1564033375903; Wed, 24 Jul 2019 22:42:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564033375; cv=none; d=google.com; s=arc-20160816; b=mOLNlxpn3Ld3DU7KppvgfWGrrpzlhfr3dLXIaamPy/NEOlgK75K/0L9IQX5rnmgm4Y VvoI4UeG1VOk1uzg4HyyiiYBGRBX9KzmnGUOOzTEg815RYz0ca+4Iu11gs3M75YO0ZVw cNxhChLjtverYZq9i++MN2HtMlXwqIL4zA0mWmJ9b2+1RpUmj5j0GVJliGID3iOE6QF1 rnjk7LYgSjnhAlDw7mUVGA+0836nH+9Qdd4I0DRcfBl7aJ67jOipLBrECYT+QDLg1nS9 d6W61PeFfyxlGO0ObEfME8JDfiS2wnlV0W6q6hCL2kFEG21rd9+laNo3gkEr8siwPlC7 sn9A== 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=uO4pSnLtDI3a6NwQcUVp8p1qJrMHGWC/M3Ipqz8jer4=; b=Fq6Lh3tlXr14ahgbJ+3kkPP+GUrRALYgRdPK7H8rL/VLIyHL9mTRBEIo/D18XTBRtt 0zkfwjKy3K4YCL5SuBs3pCkmgT0BpbkgMVFAlmgq0QpO092uuyznmQMaxLPzhFRC7C84 gBlZ5dyQ9yAvcegEq1a1m0Zjxmvp//l2lTN/zYiOM4WckKT1baMo1HiK7Oz/l/+jyTkI hg0nzikPyYRtBNZsWkXqZIGrgNjl88ELkT1TUzhZ7a45EjKXFC2NfrERPYdI2qbtLxm1 hp6eVV4LlL4WJVTm3/xNr8yDiigDk7nlkfU2Y2TWNShwza3ufbR6Ta7JXrCxzD4goDVy 0AyQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=d7oGicoa; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v16si16917949pjb.91.2019.07.24.22.42.41; Wed, 24 Jul 2019 22:42:55 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=d7oGicoa; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2403883AbfGXUTn (ORCPT + 99 others); Wed, 24 Jul 2019 16:19:43 -0400 Received: from mail.kernel.org ([198.145.29.99]:54184 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391253AbfGXTr2 (ORCPT ); Wed, 24 Jul 2019 15:47:28 -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 4DC8022ADF; Wed, 24 Jul 2019 19:47:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1563997647; bh=s4j3znAHQSb74ZAzQTuLPhO4osgwDYcDc+vpVhZJa/c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=d7oGicoabhv2+URqdqk07pNbhKN/RQ+wdy7/eShA0a8GoAPCuM/xpI0iHuha98plI B2hW/9KmEd1jYuoovxaKPOvAc3TBQEq4WeoJvsUEKFOWEIeuy4tIa1wYFRDdH4C3+m v3tJM0T6fUaLbRbqs1LhGpDMchhvMSD6Axqg96Rg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Yunsheng Lin , Peng Li , Huazhong Tan , "David S. Miller" , Sasha Levin Subject: [PATCH 5.1 096/371] net: hns3: delay ring buffer clearing during reset Date: Wed, 24 Jul 2019 21:17:28 +0200 Message-Id: <20190724191732.061027864@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190724191724.382593077@linuxfoundation.org> References: <20190724191724.382593077@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 [ Upstream commit 3a30964a2eef6aabd3ab18b979ea0eacf1147731 ] The driver may not be able to disable the ring through firmware when downing the netdev during reset process, which may cause hardware accessing freed buffer problem. This patch delays the ring buffer clearing to reset uninit process because hardware will not access the ring buffer after hardware reset is completed. Fixes: bb6b94a896d4 ("net: hns3: Add reset interface implementation in client") Signed-off-by: Yunsheng Lin Signed-off-by: Peng Li Signed-off-by: Huazhong Tan Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- .../net/ethernet/hisilicon/hns3/hns3_enet.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c index 6afdd376bc03..7e7c10513d2c 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c @@ -28,7 +28,7 @@ #define hns3_tx_bd_count(S) DIV_ROUND_UP(S, HNS3_MAX_BD_SIZE) static void hns3_clear_all_ring(struct hnae3_handle *h); -static void hns3_force_clear_all_rx_ring(struct hnae3_handle *h); +static void hns3_force_clear_all_ring(struct hnae3_handle *h); static void hns3_remove_hw_addr(struct net_device *netdev); static const char hns3_driver_name[] = "hns3"; @@ -484,7 +484,12 @@ static void hns3_nic_net_down(struct net_device *netdev) /* free irq resources */ hns3_nic_uninit_irq(priv); - hns3_clear_all_ring(priv->ae_handle); + /* delay ring buffer clearing to hns3_reset_notify_uninit_enet + * during reset process, because driver may not be able + * to disable the ring through firmware when downing the netdev. + */ + if (!hns3_nic_resetting(netdev)) + hns3_clear_all_ring(priv->ae_handle); } static int hns3_nic_net_stop(struct net_device *netdev) @@ -3737,7 +3742,7 @@ static void hns3_client_uninit(struct hnae3_handle *handle, bool reset) hns3_del_all_fd_rules(netdev, true); - hns3_force_clear_all_rx_ring(handle); + hns3_force_clear_all_ring(handle); hns3_uninit_phy(netdev); @@ -3909,7 +3914,7 @@ static void hns3_force_clear_rx_ring(struct hns3_enet_ring *ring) } } -static void hns3_force_clear_all_rx_ring(struct hnae3_handle *h) +static void hns3_force_clear_all_ring(struct hnae3_handle *h) { struct net_device *ndev = h->kinfo.netdev; struct hns3_nic_priv *priv = netdev_priv(ndev); @@ -3917,6 +3922,9 @@ static void hns3_force_clear_all_rx_ring(struct hnae3_handle *h) u32 i; for (i = 0; i < h->kinfo.num_tqps; i++) { + ring = priv->ring_data[i].ring; + hns3_clear_tx_ring(ring); + ring = priv->ring_data[i + h->kinfo.num_tqps].ring; hns3_force_clear_rx_ring(ring); } @@ -4145,7 +4153,8 @@ static int hns3_reset_notify_uninit_enet(struct hnae3_handle *handle) return 0; } - hns3_force_clear_all_rx_ring(handle); + hns3_clear_all_ring(handle); + hns3_force_clear_all_ring(handle); hns3_nic_uninit_vector_data(priv); -- 2.20.1