Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 31 Aug 2017 10:59:39 +0000 (UTC)
From:      Alexander Motin <mav@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r323047 - head/sys/dev/ntb
Message-ID:  <201708311059.v7VAxdWX071994@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: mav
Date: Thu Aug 31 10:59:39 2017
New Revision: 323047
URL: https://svnweb.freebsd.org/changeset/base/323047

Log:
  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.
  
  MFC after:	1 week
  Sponsored by:	iXsystems, Inc.

Modified:
  head/sys/dev/ntb/ntb.c

Modified: head/sys/dev/ntb/ntb.c
==============================================================================
--- head/sys/dev/ntb/ntb.c	Thu Aug 31 10:53:10 2017	(r323046)
+++ head/sys/dev/ntb/ntb.c	Thu Aug 31 10:59:39 2017	(r323047)
@@ -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);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201708311059.v7VAxdWX071994>