Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3115544imu; Sun, 6 Jan 2019 19:21:26 -0800 (PST) X-Google-Smtp-Source: ALg8bN7EjLi204qBmoBthOarg9+v2kScfdqREpdtoum489QQvFP7RuED86dDrxddpDdp39DqMS9Q X-Received: by 2002:a17:902:34a:: with SMTP id 68mr60684755pld.268.1546831286793; Sun, 06 Jan 2019 19:21:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1546831286; cv=none; d=google.com; s=arc-20160816; b=ObEEM3XbsAycq/tw2M8ddNZk7lpMIOvmSpCu8/JmofxPasDgZ0lm3ep8nqcP4/0iTd Gjrkr1GD79oi+CGhzNBVihVje0rxAmVESRVEc/NToe2QJzISWBVUNyFlT6E7UfqiAwf4 YUhHm7cOrpR4oTT1NNassAooFz0JckEnmCO1founTEv5vMHmO3LvZkGVskimn/0wa8o2 AFJr+c8hN4gMhGag/kht9cCfS5MTlTmhwvyT9bcx2GNCAZ0EOCYFSDHKVLBpVwXSYsLl dMPqMN8VnInKwr92J0qV0iTYkxSjnJGRUfWZqE43vpRxyVIyls21+jgGY11WaHF7Syq2 DflQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:subject:cc :to:from; bh=/pgiWT5uRY5EEGZNBCEkXUwypiUf2LzUkCRLh5LeelE=; b=GO5gj20QuOgWNFIgWke0FdERfnl0E7kfbzE4okbTZjVisCSHPWfAu8747DsCXLMdeu CehUuI8GBnUjZLH9srpCt5GME3efmoCeYCLy4ZSkx/P5LRHuJnkjc9qa47haEH4lMGbN fMy09Vc1ASzkSrqfaH1howFyg9SbOIvP2Ug3j5qwonSNM0DiMd2Ora6Nd4zTa633vouX fCg2nZ6kmruKjcZNATAznUpO696q8nVpVR3CwnpsUlUKIFF3b+RJ8I+vHh1VOgq0wBAg WLe10oq2lMCRaQweHWdsS+o/ohC8OR6FZ3Z/YIdFfQ+hpXCdxXSd/Jmv2bkkIuxznHmh dUxg== ARC-Authentication-Results: i=1; mx.google.com; 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 n33si1767839pgl.336.2019.01.06.19.21.11; Sun, 06 Jan 2019 19:21:26 -0800 (PST) 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; 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 S1726278AbfAGDTf (ORCPT + 99 others); Sun, 6 Jan 2019 22:19:35 -0500 Received: from esa3.microchip.iphmx.com ([68.232.153.233]:35930 "EHLO esa3.microchip.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726074AbfAGDTf (ORCPT ); Sun, 6 Jan 2019 22:19:35 -0500 X-IronPort-AV: E=Sophos;i="5.56,449,1539673200"; d="scan'208";a="25169875" Received: from smtpout.microchip.com (HELO email.microchip.com) ([198.175.253.82]) by esa3.microchip.iphmx.com with ESMTP/TLS/DHE-RSA-AES256-SHA; 06 Jan 2019 20:19:35 -0700 Received: from localhost (10.10.76.4) by chn-sv-exch06.mchp-main.com (10.10.76.107) with Microsoft SMTP Server id 14.3.352.0; Sun, 6 Jan 2019 20:20:10 -0700 From: Joey Zhang To: , , , , CC: Joey Zhang Subject: [PATCH] NTB: ntb_transport: Free MWs in ntb_transport_link_cleanup() Date: Mon, 7 Jan 2019 11:12:56 +0800 Message-ID: <1546830776-3138-1-git-send-email-joey.zhang@microchip.com> X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 Content-Type: text/plain Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org If NTB peer host crashes or reboots, the NTB transport link will be down and the MWs of NTB transport will be invalid. But the ntb_transport_link_cleanup() does not free these invalid MWs. When the NTB peer host is recovered later, NTB transport link will be up and the ntb_set_mw() will not reset up MWs. Because the MWs of NTB transport are invalid, the NTB transport will not work. We can fix it by freeing MWs when NTB transport link is down, then the ntb_set_mw() will reset up MWs when NTB transport link is up. Signed-off-by: Joey Zhang --- drivers/ntb/ntb_transport.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/ntb/ntb_transport.c b/drivers/ntb/ntb_transport.c index 3bfdb45..6e8902d 100644 --- a/drivers/ntb/ntb_transport.c +++ b/drivers/ntb/ntb_transport.c @@ -862,6 +862,9 @@ static void ntb_transport_link_cleanup(struct ntb_transport_ctx *nt) if (!nt->link_is_up) cancel_delayed_work_sync(&nt->link_work); + for (i = 0; i < nt->mw_count; i++) + ntb_free_mw(nt, i); + /* The scratchpad registers keep the values if the remote side * goes down, blast them now to give them a sane value the next * time they are accessed -- 2.7.4