From owner-svn-src-stable-11@freebsd.org Thu Sep 7 12:50:23 2017 Return-Path: Delivered-To: svn-src-stable-11@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 47AF0E1CB6F; Thu, 7 Sep 2017 12:50:23 +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 8FDA466547; Thu, 7 Sep 2017 12:50:22 +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 v87CoLpN036741; Thu, 7 Sep 2017 12:50:21 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v87CoLEd036740; Thu, 7 Sep 2017 12:50:21 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201709071250.v87CoLEd036740@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:50:21 +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: r323264 - 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: 323264 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 07 Sep 2017 12:50:23 -0000 Author: mav Date: Thu Sep 7 12:50:21 2017 New Revision: 323264 URL: https://svnweb.freebsd.org/changeset/base/323264 Log: MFC r323047: Make ntb_set_ctx() always generate fake link event. It allows application driver get initial link state without racing with hardware interrupts, thanks to the context rmlock held here. Modified: stable/11/sys/dev/ntb/ntb.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/dev/ntb/ntb.c ============================================================================== --- stable/11/sys/dev/ntb/ntb.c Thu Sep 7 10:56:50 2017 (r323263) +++ stable/11/sys/dev/ntb/ntb.c Thu Sep 7 12:50:21 2017 (r323264) @@ -264,6 +264,13 @@ ntb_set_ctx(device_t ntb, void *ctx, const struct ntb_ } nc->ctx = ctx; nc->ctx_ops = ctx_ops; + + /* + * If applicaiton driver asks for link events, generate fake one now + * to let it update link state without races while we hold the lock. + */ + if (ctx_ops->link_event != NULL) + ctx_ops->link_event(ctx); rm_wunlock(&nc->ctx_lock); return (0);