From owner-svn-src-all@freebsd.org Thu Sep 7 12:51:40 2017 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 7E027E1CC77; Thu, 7 Sep 2017 12:51:40 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4A68C669AD; Thu, 7 Sep 2017 12:51:40 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v87CpdJ2038462; Thu, 7 Sep 2017 12:51:39 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v87CpdvX038461; Thu, 7 Sep 2017 12:51:39 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201709071251.v87CpdvX038461@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Thu, 7 Sep 2017 12:51:39 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r323265 - stable/11/sys/dev/ntb X-SVN-Group: stable-11 X-SVN-Commit-Author: mav X-SVN-Commit-Paths: stable/11/sys/dev/ntb X-SVN-Commit-Revision: 323265 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 07 Sep 2017 12:51:40 -0000 Author: mav Date: Thu Sep 7 12:51:39 2017 New Revision: 323265 URL: https://svnweb.freebsd.org/changeset/base/323265 Log: MFC r323046: Make ntb_transport(4) ready receive early link events. Those events may be reported as soon as callback is registered, if the link is enabled by hardware or some other application. While there, clean link_is_up variable on link down event. Modified: stable/11/sys/dev/ntb/ntb_transport.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/dev/ntb/ntb_transport.c ============================================================================== --- stable/11/sys/dev/ntb/ntb_transport.c Thu Sep 7 12:50:21 2017 (r323264) +++ stable/11/sys/dev/ntb/ntb_transport.c Thu Sep 7 12:51:39 2017 (r323265) @@ -442,12 +442,12 @@ ntb_transport_attach(device_t dev) callout_init(&nt->link_work, 0); callout_init(&nt->link_watchdog, 0); TASK_INIT(&nt->link_cleanup, 0, ntb_transport_link_cleanup_work, nt); + nt->link_is_up = false; rc = ntb_set_ctx(dev, nt, &ntb_transport_ops); if (rc != 0) goto err; - nt->link_is_up = false; ntb_link_enable(dev, NTB_SPEED_AUTO, NTB_WIDTH_AUTO); if (enable_xeon_watchdog != 0) @@ -1274,6 +1274,9 @@ ntb_transport_link_cleanup(struct ntb_transport_ctx *n struct ntb_transport_qp *qp; int i; + callout_drain(&nt->link_work); + nt->link_is_up = 0; + /* Pass along the info to any clients */ for (i = 0; i < nt->qp_count; i++) { if ((nt->qp_bitmap & (1 << i)) != 0) { @@ -1282,9 +1285,6 @@ ntb_transport_link_cleanup(struct ntb_transport_ctx *n callout_drain(&qp->link_work); } } - - if (!nt->link_is_up) - callout_drain(&nt->link_work); /* * The scratchpad registers keep the values if the remote side