svn commit: r314375 - head/sys/dev/firewire

2017-02-27 Thread Alexander Motin
Author: mav
Date: Tue Feb 28 05:24:06 2017
New Revision: 314375
URL: https://svnweb.freebsd.org/changeset/base/314375

Log:
  Remove some locking not needed for modern CAM.
  
  This driver is full of LORs.  This change allows to reduce deadlock chance
  from 100% to level that allows some tests to be done.
  
  MFC after:2 weeks

Modified:
  head/sys/dev/firewire/sbp_targ.c

Modified: head/sys/dev/firewire/sbp_targ.c
==
--- head/sys/dev/firewire/sbp_targ.cTue Feb 28 05:17:50 2017
(r314374)
+++ head/sys/dev/firewire/sbp_targ.cTue Feb 28 05:24:06 2017
(r314375)
@@ -317,10 +317,8 @@ sbp_targ_post_busreset(void *arg)
unit = >unit;
 
if ((sc->flags & F_FREEZED) == 0) {
-   SBP_LOCK(sc);
sc->flags |= F_FREEZED;
xpt_freeze_simq(sc->sim, /*count*/1);
-   SBP_UNLOCK(sc);
} else {
printf("%s: already freezed\n", __func__);
}
@@ -367,10 +365,8 @@ sbp_targ_post_explore(void *arg)
struct sbp_targ_softc *sc;
 
sc = (struct sbp_targ_softc *)arg;
-   SBP_LOCK(sc);
sc->flags &= ~F_FREEZED;
xpt_release_simq(sc->sim, /*run queue*/TRUE);
-   SBP_UNLOCK(sc);
return;
 }
 
@@ -869,18 +865,14 @@ sbp_targ_cam_done(struct fw_xfer *xfer)
printf("%s: CAM_SEND_STATUS not set 
%0x\n", __func__, ccb->ccb_h.flags);
ccb->ccb_h.status = CAM_REQ_CMP;
}
-   SBP_LOCK(orbi->sc);
xpt_done(ccb);
-   SBP_UNLOCK(orbi->sc);
} else {
orbi->status.len = 1;
sbp_targ_status_FIFO(orbi,
orbi->login->fifo_hi, orbi->login->fifo_lo,
/*dequeue*/1);
ccb->ccb_h.status = CAM_REQ_ABORTED;
-   SBP_LOCK(orbi->sc);
xpt_done(ccb);
-   SBP_UNLOCK(orbi->sc);
}
}
 
@@ -1456,9 +1448,7 @@ sbp_targ_cmd_handler(struct fw_xfer *xfe
sbp_targ_remove_orb_info(orbi->login, orbi);
free(orbi, M_SBP_TARG);
atio->ccb_h.status = CAM_REQ_ABORTED;
-   SBP_LOCK(orbi->sc);
xpt_done((union ccb*)atio);
-   SBP_UNLOCK(orbi->sc);
goto done0;
}
orbi->state = ORBI_STATUS_ATIO;
@@ -1530,9 +1520,7 @@ sbp_targ_cmd_handler(struct fw_xfer *xfe
orbi->data_lo = orb[3];
orbi->orb4 = *orb4;
 
-   SBP_LOCK(orbi->sc);
xpt_done((union ccb*)atio);
-   SBP_UNLOCK(orbi->sc);
 done0:
fw_xfer_free(xfer);
return;
@@ -2023,8 +2011,8 @@ sbp_targ_detach(device_t dev)
SBP_LOCK(sc);
xpt_free_path(sc->path);
xpt_bus_deregister(cam_sim_path(sc->sim));
-   SBP_UNLOCK(sc);
cam_sim_free(sc->sim, /*free_devq*/TRUE);
+   SBP_UNLOCK(sc);
 
for (i = 0; i < MAX_LUN; i++) {
lstate = sc->lstate[i];
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r314374 - head/sys/dev/firewire

2017-02-27 Thread Alexander Motin
Author: mav
Date: Tue Feb 28 05:17:50 2017
New Revision: 314374
URL: https://svnweb.freebsd.org/changeset/base/314374

Log:
  Add safety check against too long CDB.
  
  SBP-2 specification defined maximum CDB length as 12 bytes.  Newer SBP-3
  specification allows CDB of any size, but this driver is too old.  Proper
  solution would be to look on maximal ORB size supported by the target.
  
  MFC after:1 week

Modified:
  head/sys/dev/firewire/sbp.c

Modified: head/sys/dev/firewire/sbp.c
==
--- head/sys/dev/firewire/sbp.c Tue Feb 28 05:14:42 2017(r314373)
+++ head/sys/dev/firewire/sbp.c Tue Feb 28 05:17:50 2017(r314374)
@@ -2367,6 +2367,11 @@ END_DEBUG
xpt_done(ccb);
return;
}
+   if (csio->cdb_len > sizeof(ocb->orb) - 5 * sizeof(uint32_t)) {
+   ccb->ccb_h.status = CAM_REQ_INVALID;
+   xpt_done(ccb);
+   return;
+   }
 #if 0
/* if we are in probe stage, pass only probe commands */
if (sdev->status == SBP_DEV_PROBE) {
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r314373 - in head: . etc/defaults etc/rc.d lib/libc/regex share/man/man4/man4.i386 share/man/man5 sys/amd64/conf sys/boot/forth sys/compat/svr4 sys/conf sys/dev/streams sys/i386/conf sy...

2017-02-27 Thread Gleb Smirnoff
Author: glebius
Date: Tue Feb 28 05:14:42 2017
New Revision: 314373
URL: https://svnweb.freebsd.org/changeset/base/314373

Log:
  Remove SVR4 (System V Release 4) binary compatibility support.
  
  UNIX System V Release 4 is operating system released in 1988. It ceased
  to exist in early 2000-s.

Deleted:
  head/share/man/man4/man4.i386/streams.4
  head/share/man/man4/man4.i386/svr4.4
  head/sys/compat/svr4/
  head/sys/dev/streams/
  head/sys/i386/svr4/
  head/sys/modules/streams/
  head/sys/modules/svr4/
Modified:
  head/ObsoleteFiles.inc
  head/etc/defaults/rc.conf
  head/etc/rc.d/abi
  head/lib/libc/regex/re_format.7
  head/share/man/man4/man4.i386/Makefile
  head/share/man/man5/rc.conf.5
  head/sys/amd64/conf/NOTES
  head/sys/boot/forth/loader.conf
  head/sys/conf/files
  head/sys/conf/files.i386
  head/sys/conf/options.amd64
  head/sys/conf/options.i386
  head/sys/i386/conf/NOTES
  head/sys/kern/makesyscalls.sh
  head/sys/modules/Makefile
  head/sys/net/if.c
  head/usr.sbin/bsdconfig/startup/include/messages.subr
  head/usr.sbin/bsdconfig/startup/misc

Modified: head/ObsoleteFiles.inc
==
--- head/ObsoleteFiles.inc  Tue Feb 28 04:48:30 2017(r314372)
+++ head/ObsoleteFiles.inc  Tue Feb 28 05:14:42 2017(r314373)
@@ -38,6 +38,11 @@
 #   xargs -n1 | sort | uniq -d;
 # done
 
+# 20170226: SVR4 compatibility removed
+.if ${TARGET_ARCH} == "amd64" || ${TARGET_ARCH} == "i386"
+OLD_FILES+=usr/share/man/man4/streams.4
+OLD_FILES+=usr/share/man/man4/svr4.4
+.endif
 # 20170219: OpenPAM RADULA upgrade removed the libpam tests
 OLD_FILES+=usr/tests/lib/libpam/Kyuafile
 OLD_FILES+=usr/tests/lib/libpam/t_openpam_ctype

Modified: head/etc/defaults/rc.conf
==
--- head/etc/defaults/rc.conf   Tue Feb 28 04:48:30 2017(r314372)
+++ head/etc/defaults/rc.conf   Tue Feb 28 05:14:42 2017(r314373)
@@ -630,7 +630,6 @@ firstboot_sentinel="/firstboot" # Script
 # Emulation/compatibility services provided by /etc/rc.d/abi
 sysvipc_enable="NO"# Load System V IPC primitives at startup (or NO).
 linux_enable="NO"  # Linux binary compatibility loaded at startup (or NO).
-svr4_enable="NO"   # SysVR4 emulation loaded at startup (or NO).
 clear_tmp_enable="NO"  # Clear /tmp at startup.
 clear_tmp_X="YES"  # Clear and recreate X11-related directories in /tmp
 ldconfig_insecure="NO" # Set to YES to disable ldconfig security checks

Modified: head/etc/rc.d/abi
==
--- head/etc/rc.d/abi   Tue Feb 28 04:48:30 2017(r314372)
+++ head/etc/rc.d/abi   Tue Feb 28 05:14:42 2017(r314373)
@@ -43,25 +43,18 @@ linux_start()
fi
 }
 
-svr4_start()
-{
-   echo -n ' svr4'
-   load_kld -m svr4elf svr4
-}
-
 abi_start()
 {
local _echostop
 
_echostop=
-   if checkyesno sysvipc_enable || checkyesno linux_enable || checkyesno 
svr4_enable; then
+   if checkyesno sysvipc_enable || checkyesno linux_enable; then
echo -n 'Additional ABI support:'
_echostop=yes
fi
 
checkyesno sysvipc_enable && sysv_start
checkyesno linux_enable && linux_start
-   checkyesno svr4_enable && svr4_start
 
[ -n "${_echostop}" ] && echo '.'
 }

Modified: head/lib/libc/regex/re_format.7
==
--- head/lib/libc/regex/re_format.7 Tue Feb 28 04:48:30 2017
(r314372)
+++ head/lib/libc/regex/re_format.7 Tue Feb 28 05:14:42 2017
(r314373)
@@ -319,7 +319,7 @@ The additional word delimiters
 and
 .Ql \e>
 are provided to ease compatibility with traditional
-.Xr svr4 4
+SVR4
 systems but are not portable and should be avoided.
 .Pp
 In the event that an RE could match more than one substring of a given

Modified: head/share/man/man4/man4.i386/Makefile
==
--- head/share/man/man4/man4.i386/Makefile  Tue Feb 28 04:48:30 2017
(r314372)
+++ head/share/man/man4/man4.i386/Makefile  Tue Feb 28 05:14:42 2017
(r314373)
@@ -25,8 +25,6 @@ MAN=  aic.4 \
pnpbios.4 \
sbni.4 \
smapi.4 \
-   streams.4 \
-   svr4.4 \
vpd.4 \
vx.4
 

Modified: head/share/man/man5/rc.conf.5
==
--- head/share/man/man5/rc.conf.5   Tue Feb 28 04:48:30 2017
(r314372)
+++ head/share/man/man5/rc.conf.5   Tue Feb 28 05:14:42 2017
(r314373)
@@ -24,7 +24,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd December 10, 2016
+.Dd February 26, 2017
 .Dt RC.CONF 5
 .Os
 .Sh NAME
@@ -3631,11 +3631,6 @@ Set to
 .Dq Li YES
 to enable Linux/ELF binary emulation at system initial
 boot time.
-.It Va svr4_enable
-.Pq Vt bool
-If 

svn commit: r314372 - head/sys/conf

2017-02-27 Thread Ngie Cooper
Author: ngie
Date: Tue Feb 28 04:48:30 2017
New Revision: 314372
URL: https://svnweb.freebsd.org/changeset/base/314372

Log:
  Use "build" instead of "all" when building ports modules
  
  "all" in ports currently means "stage the ports", which requires root today,
  and brings to light other potential issues, like ENAMETOOLONG with staged
  directories (bug 161481, etc).
  
  This fixes buildkernel for me when run as a non-root user, assuming all
  of the prerequisites have been installed beforehand and are up-to-date.
  
  MFC after:1 month
  Discussed with:   swills (IRC)
  Sponsored by: Dell EMC Isilon

Modified:
  head/sys/conf/kern.post.mk

Modified: head/sys/conf/kern.post.mk
==
--- head/sys/conf/kern.post.mk  Tue Feb 28 04:31:28 2017(r314371)
+++ head/sys/conf/kern.post.mk  Tue Feb 28 04:48:30 2017(r314372)
@@ -79,7 +79,7 @@ PORTSMODULESENV=\
 all:
 .for __i in ${PORTS_MODULES}
@${ECHO} "===> Ports module ${__i} (all)"
-   cd $${PORTSDIR:-/usr/ports}/${__i}; ${PORTSMODULESENV} ${MAKE} -B clean 
all
+   cd $${PORTSDIR:-/usr/ports}/${__i}; ${PORTSMODULESENV} ${MAKE} -B clean 
build
 .endfor
 
 .for __target in install reinstall clean
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r314371 - head/sys/powerpc/powerpc

2017-02-27 Thread Justin Hibbits
Author: jhibbits
Date: Tue Feb 28 04:31:28 2017
New Revision: 314371
URL: https://svnweb.freebsd.org/changeset/base/314371

Log:
  Make kernel breakpoints work for book-e
  
  Add the necessary bits to enable kernel breakpoints for Book-E.  The 
entrypoint
  for program exception is very trivial, so rather than expand it to be similar 
to
  AIM, add it into the standard trap handler.
  
  This wasn't blocked out as Book-E specific because it is only a minor 
redundancy
  over AIM, which should have already called db_trap_glue() at this point.  If
  it's going to panic with a fatal trap anywya, it doesn't matter if it goes
  through this path again.

Modified:
  head/sys/powerpc/powerpc/trap.c

Modified: head/sys/powerpc/powerpc/trap.c
==
--- head/sys/powerpc/powerpc/trap.c Tue Feb 28 04:13:20 2017
(r314370)
+++ head/sys/powerpc/powerpc/trap.c Tue Feb 28 04:31:28 2017
(r314371)
@@ -97,6 +97,10 @@ static int   handle_user_slb_spill(pmap_t 
 extern int n_slbs;
 #endif
 
+#ifdef KDB
+int db_trap_glue(struct trapframe *);  /* Called from trap_subr.S */
+#endif
+
 struct powerpc_exception {
u_int   vector;
char*name;
@@ -338,9 +342,13 @@ trap(struct trapframe *frame)
KASSERT(cold || td->td_ucred != NULL,
("kernel trap doesn't have ucred"));
switch (type) {
-#ifdef KDTRACE_HOOKS
case EXC_PGM:
+#ifdef KDTRACE_HOOKS
+#ifdef AIM
if (frame->srr1 & EXC_PGM_TRAP) {
+#else
+   if (frame->cpu.booke.esr & ESR_PTR) {
+#endif
if (*(uint32_t *)frame->srr0 == EXC_DTRACE) {
if (dtrace_invop_jump_addr != NULL) {
dtrace_invop_jump_addr(frame);
@@ -348,8 +356,12 @@ trap(struct trapframe *frame)
}
}
}
-   break;
 #endif
+#ifdef KDB
+   if (db_trap_glue(frame))
+   return;
+#endif
+   break;
 #if defined(__powerpc64__) && defined(AIM)
case EXC_DSE:
if ((frame->dar & SEGMENT_MASK) == USER_ADDR) {
@@ -833,11 +845,10 @@ fix_unaligned(struct thread *td, struct 
 }
 
 #ifdef KDB
-int db_trap_glue(struct trapframe *);  /* Called from trap_subr.S */
-
 int
 db_trap_glue(struct trapframe *frame)
 {
+
if (!(frame->srr1 & PSL_PR)
&& (frame->exc == EXC_TRC || frame->exc == EXC_RUNMODETRC
 #ifdef AIM
@@ -845,6 +856,7 @@ db_trap_glue(struct trapframe *frame)
&& (frame->srr1 & EXC_PGM_TRAP))
 #else
|| (frame->exc == EXC_DEBUG)
+   || (frame->cpu.booke.esr & ESR_PTR)
 #endif
|| frame->exc == EXC_BPT
|| frame->exc == EXC_DSI)) {
@@ -856,7 +868,8 @@ db_trap_glue(struct trapframe *frame)
 #ifdef AIM
if (type == EXC_PGM && (frame->srr1 & EXC_PGM_TRAP)) {
 #else
-   if (frame->cpu.booke.esr & ESR_PTR) {
+   if (type == EXC_DEBUG ||
+   (frame->cpu.booke.esr & ESR_PTR)) {
 #endif
type = T_BREAKPOINT;
}
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r314370 - head/sys/powerpc/include

2017-02-27 Thread Justin Hibbits
Author: jhibbits
Date: Tue Feb 28 04:13:20 2017
New Revision: 314370
URL: https://svnweb.freebsd.org/changeset/base/314370

Log:
  Unbreak kernel breakpoints, broken for ~4 years now
  
  When committing DTrace in 2012/2013 era I inadvertently broke breakpoints, by
  setting EXC_DTRACE to the same value as BKPT_INST.  Change EXC_DTRACE to a
  different, yet logically identical, trap (tw ,31,31).
  
  MFC after:2 weeks

Modified:
  head/sys/powerpc/include/trap.h

Modified: head/sys/powerpc/include/trap.h
==
--- head/sys/powerpc/include/trap.h Tue Feb 28 02:27:51 2017
(r314369)
+++ head/sys/powerpc/include/trap.h Tue Feb 28 04:13:20 2017
(r314370)
@@ -126,7 +126,7 @@
 #defineEXC_PGM_TRAP(1UL << 17)
 
 /* DTrace trap opcode. */
-#define EXC_DTRACE 0x7c810808
+#define EXC_DTRACE 0x7808
 
 /* Magic pointer to store TOC base and other info for trap handlers on ppc64 */
 #define TRAP_GENTRAP   0x1f0
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r314369 - head/sys/dev/bnxt

2017-02-27 Thread Sepherosa Ziehau
On Tue, Feb 28, 2017 at 10:27 AM, Stephen Hurd  wrote:
> Modified: head/sys/dev/bnxt/bnxt_txrx.c
> ==
> --- head/sys/dev/bnxt/bnxt_txrx.c   Tue Feb 28 00:58:16 2017
> (r314368)
> +++ head/sys/dev/bnxt/bnxt_txrx.c   Tue Feb 28 02:27:51 2017
> (r314369)
> @@ -412,6 +412,37 @@ cmpl_invalid:
> return avail;
>  }
>
> +static void
> +bnxt_set_rsstype(if_rxd_info_t ri, uint8_t rss_hash_type)
> +{
> +   uint8_t rss_profile_id;
> +
> +   rss_profile_id = BNXT_GET_RSS_PROFILE_ID(rss_hash_type);
> +   switch (rss_profile_id) {
> +   default:
> +   ri->iri_rsstype = M_HASHTYPE_OPAQUE;
> +   break;

Is it a hash value or just ring index?  If its a hash value, you
should set it to M_HASHTYPE_OPAQUE_HASH here.

Thanks,
sephe
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r313006 - in head: sys/conf sys/libkern sys/libkern/x86 sys/sys tests/sys/kern

2017-02-27 Thread Bruce Evans

On Mon, 27 Feb 2017, Conrad Meyer wrote:


On Thu, Feb 2, 2017 at 12:29 PM, Bruce Evans  wrote:

I've almost finished fixing and optimizing this.  I didn't manage to fix
all the compiler pessimizations, but the result is within 5% of optimal
for buffers larger than a few K.


Did you ever get to a final patch that you are satisfied with?  It
would be good to get this improvement into the tree.


I'm happy with this version (attached and partly enclosed).  You need to
test it in the kernel and commit it (I on;y did simple correctness tests
in userland).

X Index: conf/files.amd64
X ===
X --- conf/files.amd64  (revision 314363)
X +++ conf/files.amd64  (working copy)
X @@ -545,6 +545,9 @@
X  isa/vga_isa.coptionalvga
X  kern/kern_clocksource.c  standard
X  kern/link_elf_obj.c  standard
X +libkern/x86/crc32_sse42.cstandard
X +libkern/memmove.cstandard
X +libkern/memset.c standard

Also fix some nearby disorder.

X ...
X Index: libkern/x86/crc32_sse42.c
X ===
X --- libkern/x86/crc32_sse42.c (revision 314363)
X +++ libkern/x86/crc32_sse42.c (working copy)
X @@ -31,15 +31,41 @@
X   */
X  #ifdef USERSPACE_TESTING
X  #include 
X +#include 
X  #else
X  #include 
X +#include 
X  #include 
X -#include 
X -#include 
X  #endif

Also fix minor #include errors.

X 
X -#include 

X +static __inline uint32_t
X +_mm_crc32_u8(uint32_t x, uint8_t y)
X +{
X + /*
X +  * clang (at least 3.9.[0-1]) pessimizes "rm" (y) and "m" (y)
X +  * significantly and "r" (y) a lot by copying y to a different
X +  * local variable (on the stack or in a register), so only use
X +  * the latter.  This costs a register and an instruction but
X +  * not a uop.
X +  */
X + __asm("crc32b %1,%0" : "+r" (x) : "r" (y));
X + return (x);
X +}

Using intrinsics avoids the silly copying via the stack, and allows more
unrolling.  Old gcc does more unrolling with just asms.  Unrolling is
almost useless (some details below).

X @@ -47,12 +73,14 @@
X   * Block sizes for three-way parallel crc computation.  LONG and SHORT must
X   * both be powers of two.
X   */
X -#define LONG 8192
X -#define SHORT256
X +#define LONG 128
X +#define SHORT64

These are aggressively low.

Note that small buffers aren't handled very well.  SHORT = 64 means that
a buffer of size 3 * 64 = 192 is handled entirely by the "SHORT" loop.
192 is not very small, but any smaller than that and overheads for
adjustment at the end of the loop are too large for the "SHORT" loop
to be worth doing.  Almost any value of LONG larger than 128 works OK
now, but if LONG is large then it gives too much work for the "SHORT"
loop, since normal buffer sizes are not a multiple of 3.  E.g., with
the old LONG and SHORT, a buffer of size 128 was decomposed as 5 * 24K
(done almost optimally by the "LONG" loop) + 10 * 768 (done a bit less
optimally by the "SHORT" loop) + 10 * 768 + 64 * 8 (done pessimally).

I didn't get around to ifdefing this for i386.  On i386, the loops take
twice as many crc32 instructions for a given byte count, so the timing
is satisfed by a byte count half as large, so SHORT and LONG can be
reduced by a factor of 2 to give faster handling for small buffers without
affecting the speed for large buffers significantly.

X 
X  /* Tables for hardware crc that shift a crc by LONG and SHORT zeros. */

X  static uint32_t crc32c_long[4][256];
X +static uint32_t crc32c_2long[4][256];
X  static uint32_t crc32c_short[4][256];
X +static uint32_t crc32c_2short[4][256];

I didn't get around to updating the comment.  2long shifts by 2*LONG zeros,
etc.

Shifts by 3N are done by adding shifts by 1N and 2N in parallel.  I couldn't
get the direct 3N shift to run any faster.

X @@ -190,7 +220,11 @@
X   const size_t align = 4;
X  #endif
X   const unsigned char *next, *end;
X - uint64_t crc0, crc1, crc2;  /* need to be 64 bits for crc32q */
X +#ifdef __amd64__
X + uint64_t crc0, crc1, crc2;
X +#else
X + uint32_t crc0, crc1, crc2;
X +#endif
X 
X  	next = buf;

X   crc0 = crc;

64 bits of course isn't needed for i386.  It isn't needed for amd64 either.
I think the crc32 instruction zeros the top 32 bits so they can be ignored.
However, when I modified the asm to return 32 bits to tell the compiler about
this (which the intrinsic wouldn't be able to do) and used 32 bits here,
this was just slightly slower.

For some intermediate crc calculations, only 32 bits are used, and the
compiler can see this.  clang on amd64 optimizes this better than gcc,
starting with all the intermediate crc variables declared as 64 bits.
gcc generates worst code when some of the intermediates are declared as
32 bits.  So keep using 64 bits on amd64 here.

X @@ -202,6 +236,7 @@
X   len--;
X   }
X 
X +#if LONG > 

svn commit: r314369 - head/sys/dev/bnxt

2017-02-27 Thread Stephen Hurd
Author: shurd (ports committer)
Date: Tue Feb 28 02:27:51 2017
New Revision: 314369
URL: https://svnweb.freebsd.org/changeset/base/314369

Log:
  bnxt: propagate RSS hash type to the network stack.
  
  RSS hash type will be used to identify the CPU on to which, a receive packet
  will be queued.  This patch extracts the "RSS hash type" from the receive
  completion and sends it to the stack.
  
  Submitted by: Venkatkumar Duvvuru 
  Reviewed by:  shurd
  Approved by:  sbruno
  MFC after:1 week
  Sponsored by: Broadcom Limited
  Differential Revision:https://reviews.freebsd.org/D9685

Modified:
  head/sys/dev/bnxt/bnxt.h
  head/sys/dev/bnxt/bnxt_txrx.c

Modified: head/sys/dev/bnxt/bnxt.h
==
--- head/sys/dev/bnxt/bnxt.hTue Feb 28 00:58:16 2017(r314368)
+++ head/sys/dev/bnxt/bnxt.hTue Feb 28 02:27:51 2017(r314369)
@@ -92,6 +92,14 @@ __FBSDID("$FreeBSD$");
 
 #define BNXT_MAX_MTU   9000
 
+#define BNXT_RSS_HASH_TYPE_TCPV4   0
+#define BNXT_RSS_HASH_TYPE_UDPV4   1
+#define BNXT_RSS_HASH_TYPE_IPV42
+#define BNXT_RSS_HASH_TYPE_TCPV6   3
+#define BNXT_RSS_HASH_TYPE_UDPV6   4
+#define BNXT_RSS_HASH_TYPE_IPV65
+#define BNXT_GET_RSS_PROFILE_ID(rss_hash_type) ((rss_hash_type >> 1) & 0x1F)
+
 /* Completion related defines */
 #define CMP_VALID(cmp, v_bit) \
((!!(((struct cmpl_base *)(cmp))->info3_v & htole32(CMPL_BASE_V))) == 
!!(v_bit) )

Modified: head/sys/dev/bnxt/bnxt_txrx.c
==
--- head/sys/dev/bnxt/bnxt_txrx.c   Tue Feb 28 00:58:16 2017
(r314368)
+++ head/sys/dev/bnxt/bnxt_txrx.c   Tue Feb 28 02:27:51 2017
(r314369)
@@ -412,6 +412,37 @@ cmpl_invalid:
return avail;
 }
 
+static void
+bnxt_set_rsstype(if_rxd_info_t ri, uint8_t rss_hash_type)
+{
+   uint8_t rss_profile_id;
+
+   rss_profile_id = BNXT_GET_RSS_PROFILE_ID(rss_hash_type);
+   switch (rss_profile_id) {
+   case BNXT_RSS_HASH_TYPE_TCPV4:
+   ri->iri_rsstype = M_HASHTYPE_RSS_TCP_IPV4;
+   break;
+   case BNXT_RSS_HASH_TYPE_UDPV4:
+   ri->iri_rsstype = M_HASHTYPE_RSS_UDP_IPV4;
+   break;
+   case BNXT_RSS_HASH_TYPE_IPV4:
+   ri->iri_rsstype = M_HASHTYPE_RSS_IPV4;
+   break;
+   case BNXT_RSS_HASH_TYPE_TCPV6:
+   ri->iri_rsstype = M_HASHTYPE_RSS_TCP_IPV6;
+   break;
+   case BNXT_RSS_HASH_TYPE_UDPV6:
+   ri->iri_rsstype = M_HASHTYPE_RSS_UDP_IPV6;
+   break;
+   case BNXT_RSS_HASH_TYPE_IPV6:
+   ri->iri_rsstype = M_HASHTYPE_RSS_IPV6;
+   break;
+   default:
+   ri->iri_rsstype = M_HASHTYPE_OPAQUE;
+   break;
+   }
+}
+
 static int
 bnxt_pkt_get_l2(struct bnxt_softc *softc, if_rxd_info_t ri,
 struct bnxt_cp_ring *cpr, uint16_t flags_type)
@@ -429,13 +460,7 @@ bnxt_pkt_get_l2(struct bnxt_softc *softc
/* Extract from the first 16-byte BD */
if (flags_type & RX_PKT_CMPL_FLAGS_RSS_VALID) {
ri->iri_flowid = le32toh(rcp->rss_hash);
-   /*
-* TODO: Extract something useful from rcp->rss_hash_type
-* (undocumented)
-* May be documented in the "LSI ES"
-* also check the firmware code.
-*/
-   ri->iri_rsstype = M_HASHTYPE_OPAQUE;
+   bnxt_set_rsstype(ri, rcp->rss_hash_type);
}
else {
ri->iri_rsstype = M_HASHTYPE_NONE;
@@ -515,13 +540,7 @@ bnxt_pkt_get_tpa(struct bnxt_softc *soft
/* Extract from the first 16-byte BD */
if (le16toh(tpas->low.flags_type) & RX_TPA_START_CMPL_FLAGS_RSS_VALID) {
ri->iri_flowid = le32toh(tpas->low.rss_hash);
-   /*
-* TODO: Extract something useful from tpas->low.rss_hash_type
-* (undocumented)
-* May be documented in the "LSI ES"
-* also check the firmware code.
-*/
-   ri->iri_rsstype = M_HASHTYPE_OPAQUE;
+   bnxt_set_rsstype(ri, tpas->low.rss_hash_type);
}
else {
ri->iri_rsstype = M_HASHTYPE_NONE;
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r314365 - head/sys/dev/bxe

2017-02-27 Thread David C Somayajulu
Author: davidcs
Date: Mon Feb 27 23:38:51 2017
New Revision: 314365
URL: https://svnweb.freebsd.org/changeset/base/314365

Log:
  1. state checks in bxe_tx_mq_start_locked() and bxe_tx_mq_start() to sync 
threads during interface down or detach.
  2. add sysctl to set pause frame parameters
  3. increase max segs for TSO packets to BXE_TSO_MAX_SEGMENTS (32)
  4. add debug messages for PHY
  5. HW LRO support restricted to FreeBSD versions 8.x and above.
  
  Submitted by:vaishali.kulka...@cavium.com
  MFC after:5 days

Modified:
  head/sys/dev/bxe/bxe.c
  head/sys/dev/bxe/bxe.h
  head/sys/dev/bxe/bxe_elink.c
  head/sys/dev/bxe/bxe_stats.c
  head/sys/dev/bxe/bxe_stats.h

Modified: head/sys/dev/bxe/bxe.c
==
--- head/sys/dev/bxe/bxe.c  Mon Feb 27 22:53:25 2017(r314364)
+++ head/sys/dev/bxe/bxe.c  Mon Feb 27 23:38:51 2017(r314365)
@@ -27,7 +27,7 @@
 #include 
 __FBSDID("$FreeBSD$");
 
-#define BXE_DRIVER_VERSION "1.78.89"
+#define BXE_DRIVER_VERSION "1.78.90"
 
 #include "bxe.h"
 #include "ecore_sp.h"
@@ -496,12 +496,19 @@ static const struct {
 4, STATS_FLAGS_FUNC, "mbuf_alloc_tpa"},
 { STATS_OFFSET32(tx_queue_full_return),
 4, STATS_FLAGS_FUNC, "tx_queue_full_return"},
+{ STATS_OFFSET32(bxe_tx_mq_sc_state_failures),
+4, STATS_FLAGS_FUNC, "bxe_tx_mq_sc_state_failures"},
 { STATS_OFFSET32(tx_request_link_down_failures),
 4, STATS_FLAGS_FUNC, "tx_request_link_down_failures"},
 { STATS_OFFSET32(bd_avail_too_less_failures),
 4, STATS_FLAGS_FUNC, "bd_avail_too_less_failures"},
 { STATS_OFFSET32(tx_mq_not_empty),
-4, STATS_FLAGS_FUNC, "tx_mq_not_empty"}
+4, STATS_FLAGS_FUNC, "tx_mq_not_empty"},
+{ STATS_OFFSET32(nsegs_path1_errors),
+4, STATS_FLAGS_FUNC, "nsegs_path1_errors"},
+{ STATS_OFFSET32(nsegs_path2_errors),
+4, STATS_FLAGS_FUNC, "nsegs_path2_errors"}
+
 
 };
 
@@ -616,12 +623,19 @@ static const struct {
 4, "mbuf_alloc_tpa"},
 { Q_STATS_OFFSET32(tx_queue_full_return),
 4, "tx_queue_full_return"},
+{ Q_STATS_OFFSET32(bxe_tx_mq_sc_state_failures),
+4, "bxe_tx_mq_sc_state_failures"},
 { Q_STATS_OFFSET32(tx_request_link_down_failures),
 4, "tx_request_link_down_failures"},
 { Q_STATS_OFFSET32(bd_avail_too_less_failures),
 4, "bd_avail_too_less_failures"},
 { Q_STATS_OFFSET32(tx_mq_not_empty),
-4, "tx_mq_not_empty"}
+4, "tx_mq_not_empty"},
+{ Q_STATS_OFFSET32(nsegs_path1_errors),
+4, "nsegs_path1_errors"},
+{ Q_STATS_OFFSET32(nsegs_path2_errors),
+4, "nsegs_path2_errors"}
+
 
 };
 
@@ -692,6 +706,7 @@ static void bxe_handle_fp_tq(void *conte
 
 static int bxe_add_cdev(struct bxe_softc *sc);
 static void bxe_del_cdev(struct bxe_softc *sc);
+int bxe_grc_dump(struct bxe_softc *sc);
 static int bxe_alloc_buf_rings(struct bxe_softc *sc);
 static void bxe_free_buf_rings(struct bxe_softc *sc);
 
@@ -5231,12 +5246,24 @@ bxe_tx_encap(struct bxe_fastpath *fp, st
 fp->eth_q_stats.tx_dma_mapping_failure++;
 /* No sense in trying to defrag/copy chain, drop it. :( */
 rc = error;
-}
-else {
-/* if the chain is still too long then drop it */
-if (__predict_false(nsegs > BXE_MAX_SEGMENTS)) {
-bus_dmamap_unload(fp->tx_mbuf_tag, tx_buf->m_map);
-rc = ENODEV;
+} else {
+   /* if the chain is still too long then drop it */
+if(m0->m_pkthdr.csum_flags & CSUM_TSO) {
+/*
+ * in case TSO is enabled nsegs should be checked against
+ * BXE_TSO_MAX_SEGMENTS
+ */
+if (__predict_false(nsegs > BXE_TSO_MAX_SEGMENTS)) {
+bus_dmamap_unload(fp->tx_mbuf_tag, tx_buf->m_map);
+fp->eth_q_stats.nsegs_path1_errors++;
+rc = ENODEV;
+}
+} else {
+if (__predict_false(nsegs > BXE_MAX_SEGMENTS)) {
+bus_dmamap_unload(fp->tx_mbuf_tag, tx_buf->m_map);
+fp->eth_q_stats.nsegs_path2_errors++;
+rc = ENODEV;
+}
 }
 }
 }
@@ -5636,6 +5663,11 @@ bxe_tx_mq_start_locked(struct bxe_softc 
 
 BXE_FP_TX_LOCK_ASSERT(fp);
 
+if (sc->state != BXE_STATE_OPEN)  {
+fp->eth_q_stats.bxe_tx_mq_sc_state_failures++;
+return ENETDOWN;
+}
+
 if (!tx_br) {
 BLOGE(sc, "Multiqueue TX and no buf_ring!\n");
 return (EINVAL);
@@ -5757,6 +5789,11 @@ bxe_tx_mq_start(struct ifnet 

Re: svn commit: r313006 - in head: sys/conf sys/libkern sys/libkern/x86 sys/sys tests/sys/kern

2017-02-27 Thread Conrad Meyer
On Thu, Feb 2, 2017 at 12:29 PM, Bruce Evans  wrote:
> I've almost finished fixing and optimizing this.  I didn't manage to fix
> all the compiler pessimizations, but the result is within 5% of optimal
> for buffers larger than a few K.

Hi Bruce,

Did you ever get to a final patch that you are satisfied with?  It
would be good to get this improvement into the tree.

Thanks,
Conrad
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r314362 - in head/sys: arm/at91 arm/cavium/cns11xx arm/nvidia arm/xscale/i8134x arm/xscale/ixp425 arm/xscale/pxa dev/uart mips/adm5120 mips/alchemy mips/atheros mips/atheros/ar531x mips...

2017-02-27 Thread Ruslan Bukin
Author: br
Date: Mon Feb 27 20:08:42 2017
New Revision: 314362
URL: https://svnweb.freebsd.org/changeset/base/314362

Log:
  Allow setting access-width for UART registers.
  
  This is required for FDT's standard "reg-io-width" property
  (similar to "reg-shift" property) found in many DTS files.
  
  This fixes operation on Altera Arria 10 SOC Development Kit,
  where standard ns8250 uart allows 4-byte access only.
  
  Reviewed by:  kan, marcel
  Sponsored by: DARPA, AFRL
  Differential Revision:https://reviews.freebsd.org/D9785

Modified:
  head/sys/arm/at91/uart_bus_at91usart.c
  head/sys/arm/cavium/cns11xx/uart_bus_ec.c
  head/sys/arm/nvidia/tegra_uart.c
  head/sys/arm/xscale/i8134x/uart_bus_i81342.c
  head/sys/arm/xscale/ixp425/uart_bus_ixp425.c
  head/sys/arm/xscale/pxa/uart_bus_pxa.c
  head/sys/dev/uart/uart.h
  head/sys/dev/uart/uart_bus.h
  head/sys/dev/uart/uart_bus_acpi.c
  head/sys/dev/uart/uart_bus_ebus.c
  head/sys/dev/uart/uart_bus_fdt.c
  head/sys/dev/uart/uart_bus_isa.c
  head/sys/dev/uart/uart_bus_pccard.c
  head/sys/dev/uart/uart_bus_pci.c
  head/sys/dev/uart/uart_bus_puc.c
  head/sys/dev/uart/uart_bus_scc.c
  head/sys/dev/uart/uart_core.c
  head/sys/dev/uart/uart_cpu.h
  head/sys/dev/uart/uart_cpu_arm64.c
  head/sys/dev/uart/uart_cpu_fdt.c
  head/sys/dev/uart/uart_cpu_fdt.h
  head/sys/dev/uart/uart_dev_snps.c
  head/sys/mips/adm5120/uart_bus_adm5120.c
  head/sys/mips/alchemy/uart_bus_alchemy.c
  head/sys/mips/atheros/ar531x/uart_bus_ar5315.c
  head/sys/mips/atheros/uart_bus_ar71xx.c
  head/sys/mips/atheros/uart_bus_ar933x.c
  head/sys/mips/broadcom/uart_bus_chipc.c
  head/sys/mips/cavium/uart_bus_octeonusart.c
  head/sys/mips/idt/uart_bus_rc32434.c
  head/sys/mips/ingenic/jz4780_uart.c
  head/sys/mips/malta/uart_bus_maltausart.c
  head/sys/mips/rmi/uart_bus_xlr_iodi.c
  head/sys/mips/rt305x/uart_bus_rt305x.c
  head/sys/powerpc/psim/uart_iobus.c
  head/sys/sparc64/pci/sbbc.c

Modified: head/sys/arm/at91/uart_bus_at91usart.c
==
--- head/sys/arm/at91/uart_bus_at91usart.c  Mon Feb 27 19:51:27 2017
(r314361)
+++ head/sys/arm/at91/uart_bus_at91usart.c  Mon Feb 27 20:08:42 2017
(r314362)
@@ -104,7 +104,7 @@ usart_at91_probe(device_t dev)
sc->sc_class = _usart_class;
if (sc->sc_class->uc_rclk == 0)
sc->sc_class->uc_rclk = at91_master_clock;
-   return (uart_bus_probe(dev, 0, 0, 0, device_get_unit(dev)));
+   return (uart_bus_probe(dev, 0, 0, 0, 0, device_get_unit(dev)));
 }
 
 

Modified: head/sys/arm/cavium/cns11xx/uart_bus_ec.c
==
--- head/sys/arm/cavium/cns11xx/uart_bus_ec.c   Mon Feb 27 19:51:27 2017
(r314361)
+++ head/sys/arm/cavium/cns11xx/uart_bus_ec.c   Mon Feb 27 20:08:42 2017
(r314362)
@@ -69,7 +69,7 @@ uart_ec_probe(device_t dev)
 
sc = device_get_softc(dev);
sc->sc_class = _ns8250_class;
-   status = uart_bus_probe(dev, EC_UART_REGSHIFT, EC_UART_CLOCK, 0, 0);
+   status = uart_bus_probe(dev, EC_UART_REGSHIFT, 0, EC_UART_CLOCK, 0, 0);
return (status);
 }
 

Modified: head/sys/arm/nvidia/tegra_uart.c
==
--- head/sys/arm/nvidia/tegra_uart.cMon Feb 27 19:51:27 2017
(r314361)
+++ head/sys/arm/nvidia/tegra_uart.cMon Feb 27 20:08:42 2017
(r314362)
@@ -216,7 +216,7 @@ tegra_uart_probe(device_t dev)
device_printf(dev, "Cannot enable UART clock: %d\n", rv);
return (ENXIO);
}
-   return (uart_bus_probe(dev, shift, (int)freq, 0, 0));
+   return (uart_bus_probe(dev, shift, 0, (int)freq, 0, 0));
 }
 
 static int

Modified: head/sys/arm/xscale/i8134x/uart_bus_i81342.c
==
--- head/sys/arm/xscale/i8134x/uart_bus_i81342.cMon Feb 27 19:51:27 
2017(r314361)
+++ head/sys/arm/xscale/i8134x/uart_bus_i81342.cMon Feb 27 20:08:42 
2017(r314362)
@@ -83,7 +83,7 @@ uart_i81342_probe(device_t dev)
0x40 | 0x10);
 bus_release_resource(dev, sc->sc_rtype, sc->sc_rrid, sc->sc_rres);
 
-   err = uart_bus_probe(dev, 2, 4000, 0, device_get_unit(dev));
+   err = uart_bus_probe(dev, 2, 0, 4000, 0, device_get_unit(dev));
sc->sc_rxfifosz = sc->sc_txfifosz = 1;
return (err);
 }

Modified: head/sys/arm/xscale/ixp425/uart_bus_ixp425.c
==
--- head/sys/arm/xscale/ixp425/uart_bus_ixp425.cMon Feb 27 19:51:27 
2017(r314361)
+++ head/sys/arm/xscale/ixp425/uart_bus_ixp425.cMon Feb 27 20:08:42 
2017(r314362)
@@ -78,5 +78,5 @@ uart_ixp425_probe(device_t dev)
if (bootverbose)
device_printf(dev, "rclk %u\n", rclk);
 
-   return 

svn commit: r314360 - head/sys/dev/uart

2017-02-27 Thread Ruslan Bukin
Author: br
Date: Mon Feb 27 19:46:27 2017
New Revision: 314360
URL: https://svnweb.freebsd.org/changeset/base/314360

Log:
  Revert r314212 as it break Allwinner boards.
  
  Reported by:  manu

Modified:
  head/sys/dev/uart/uart_dev_snps.c

Modified: head/sys/dev/uart/uart_dev_snps.c
==
--- head/sys/dev/uart/uart_dev_snps.c   Mon Feb 27 17:54:01 2017
(r314359)
+++ head/sys/dev/uart/uart_dev_snps.c   Mon Feb 27 19:46:27 2017
(r314360)
@@ -104,7 +104,7 @@ static struct ofw_compat_data compat_dat
{ "snps,dw-apb-uart",   (uintptr_t)_snps_class },
{ NULL, (uintptr_t)NULL }
 };
-UART_FDT_CLASS_AND_DEVICE(compat_data);
+UART_FDT_CLASS(compat_data);
 
 #ifdef EXT_RESOURCES
 static int
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r314359 - in head: sbin/geom/class/part sys/geom/part

2017-02-27 Thread Mariusz Zaborski
On Mon, Feb 27, 2017 at 05:54:01PM +, Mariusz Zaborski wrote:
> Author: oshogbo
> Date: Mon Feb 27 17:54:01 2017
> New Revision: 314359
> URL: https://svnweb.freebsd.org/changeset/base/314359
> 
> Log:
>   Add sysctl to control auto resize of the GEOM metadata.
>   
>   Reviewed by:AllanJude
>   Differential Revision:  https://reviews.freebsd.org/D9603
Sorry, I think I should add:
Discussed with: ae

Sorry about that,
Mariusz Zaborski
> 
> Modified:
>   head/sbin/geom/class/part/gpart.8
>   head/sys/geom/part/g_part.c
> 
> Modified: head/sbin/geom/class/part/gpart.8
> ==
> --- head/sbin/geom/class/part/gpart.8 Mon Feb 27 17:50:38 2017
> (r314358)
> +++ head/sbin/geom/class/part/gpart.8 Mon Feb 27 17:54:01 2017
> (r314359)
> @@ -1146,6 +1146,18 @@ variables can be used to control the beh
>  GEOM class.
>  The default value is shown next to each variable.
>  .Bl -tag -width indent
> +.It Va kern.geom.part.auto_resize: No 1
> +This variable controls automatic resize behavior of
> +.Nm
> +GEOM class.
> +When this variable is enable and new size of provider is detected, the schema
> +metadata is resized but all changes are not saved to disk, until
> +.Cm gpart commit
> +is run to confirm changes.
> +This behavior is also reported with diagnostic message:
> +.Sy "GEOM_PART: (provider) was automatically resized."
> +.Sy "Use `gpart commit (provider)` to save changes or `gpart undo 
> (provider)`"
> +.Sy "to revert them."
>  .It Va kern.geom.part.check_integrity : No 1
>  This variable controls the behaviour of metadata integrity checks.
>  When integrity checks are enabled, the
> 
> Modified: head/sys/geom/part/g_part.c
> ==
> --- head/sys/geom/part/g_part.c   Mon Feb 27 17:50:38 2017
> (r314358)
> +++ head/sys/geom/part/g_part.c   Mon Feb 27 17:54:01 2017
> (r314359)
> @@ -135,6 +135,10 @@ static u_int check_integrity = 1;
>  SYSCTL_UINT(_kern_geom_part, OID_AUTO, check_integrity,
>  CTLFLAG_RWTUN, _integrity, 1,
>  "Enable integrity checking");
> +static u_int auto_resize = 1;
> +SYSCTL_UINT(_kern_geom_part, OID_AUTO, auto_resize,
> +CTLFLAG_RW, _resize, 1,
> +"Enable auto resize");
>  
>  /*
>   * The GEOM partitioning class.
> @@ -2095,6 +2099,9 @@ g_part_resize(struct g_consumer *cp)
>   G_PART_TRACE((G_T_TOPOLOGY, "%s(%s)", __func__, cp->provider->name));
>   g_topology_assert();
>  
> + if (auto_resize == 0)
> + return;
> +
>   table = cp->geom->softc;
>   if (table->gpt_opened == 0) {
>   if (g_access(cp, 1, 1, 1) != 0)
> ___
> svn-src-head@freebsd.org mailing list
> https://lists.freebsd.org/mailman/listinfo/svn-src-head
> To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


signature.asc
Description: PGP signature


svn commit: r314359 - in head: sbin/geom/class/part sys/geom/part

2017-02-27 Thread Mariusz Zaborski
Author: oshogbo
Date: Mon Feb 27 17:54:01 2017
New Revision: 314359
URL: https://svnweb.freebsd.org/changeset/base/314359

Log:
  Add sysctl to control auto resize of the GEOM metadata.
  
  Reviewed by:  AllanJude
  Differential Revision:https://reviews.freebsd.org/D9603

Modified:
  head/sbin/geom/class/part/gpart.8
  head/sys/geom/part/g_part.c

Modified: head/sbin/geom/class/part/gpart.8
==
--- head/sbin/geom/class/part/gpart.8   Mon Feb 27 17:50:38 2017
(r314358)
+++ head/sbin/geom/class/part/gpart.8   Mon Feb 27 17:54:01 2017
(r314359)
@@ -1146,6 +1146,18 @@ variables can be used to control the beh
 GEOM class.
 The default value is shown next to each variable.
 .Bl -tag -width indent
+.It Va kern.geom.part.auto_resize: No 1
+This variable controls automatic resize behavior of
+.Nm
+GEOM class.
+When this variable is enable and new size of provider is detected, the schema
+metadata is resized but all changes are not saved to disk, until
+.Cm gpart commit
+is run to confirm changes.
+This behavior is also reported with diagnostic message:
+.Sy "GEOM_PART: (provider) was automatically resized."
+.Sy "Use `gpart commit (provider)` to save changes or `gpart undo (provider)`"
+.Sy "to revert them."
 .It Va kern.geom.part.check_integrity : No 1
 This variable controls the behaviour of metadata integrity checks.
 When integrity checks are enabled, the

Modified: head/sys/geom/part/g_part.c
==
--- head/sys/geom/part/g_part.c Mon Feb 27 17:50:38 2017(r314358)
+++ head/sys/geom/part/g_part.c Mon Feb 27 17:54:01 2017(r314359)
@@ -135,6 +135,10 @@ static u_int check_integrity = 1;
 SYSCTL_UINT(_kern_geom_part, OID_AUTO, check_integrity,
 CTLFLAG_RWTUN, _integrity, 1,
 "Enable integrity checking");
+static u_int auto_resize = 1;
+SYSCTL_UINT(_kern_geom_part, OID_AUTO, auto_resize,
+CTLFLAG_RW, _resize, 1,
+"Enable auto resize");
 
 /*
  * The GEOM partitioning class.
@@ -2095,6 +2099,9 @@ g_part_resize(struct g_consumer *cp)
G_PART_TRACE((G_T_TOPOLOGY, "%s(%s)", __func__, cp->provider->name));
g_topology_assert();
 
+   if (auto_resize == 0)
+   return;
+
table = cp->geom->softc;
if (table->gpt_opened == 0) {
if (g_access(cp, 1, 1, 1) != 0)
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r314358 - head/sys/dev/firewire

2017-02-27 Thread Alexander Motin
Author: mav
Date: Mon Feb 27 17:50:38 2017
New Revision: 314358
URL: https://svnweb.freebsd.org/changeset/base/314358

Log:
  Announce that sbp_targ(4) does not support initiator mode.
  
  MFC after:1 week

Modified:
  head/sys/dev/firewire/sbp_targ.c

Modified: head/sys/dev/firewire/sbp_targ.c
==
--- head/sys/dev/firewire/sbp_targ.cMon Feb 27 17:36:31 2017
(r314357)
+++ head/sys/dev/firewire/sbp_targ.cMon Feb 27 17:50:38 2017
(r314358)
@@ -1324,7 +1324,8 @@ sbp_targ_action1(struct cam_sim *sim, un
 | PIT_DISCONNECT
 | PIT_TERM_IO;
cpi->transport = XPORT_SPI; /* FIXME add XPORT_FW type to cam */
-   cpi->hba_misc = PIM_NOBUSRESET | PIM_NO_6_BYTE;
+   cpi->hba_misc = PIM_NOINITIATOR | PIM_NOBUSRESET |
+   PIM_NO_6_BYTE;
cpi->hba_eng_cnt = 0;
cpi->max_target = 7; /* XXX */
cpi->max_lun = MAX_LUN - 1;
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r314357 - head/sys/x86/x86

2017-02-27 Thread Andriy Gapon
Author: avg
Date: Mon Feb 27 17:36:31 2017
New Revision: 314357
URL: https://svnweb.freebsd.org/changeset/base/314357

Log:
  fix lvt_mode: edge-triggered interrupt mode is set by clearing APIC_LVT_TM
  
  The fixed is used only to fix up buggy MPTable information and the
  trigger mode is probably ignored for the relevant interrupt types
  anyway.  Still, it's better to be standards compliant and have the code
  do what it says it does.
  
  Discussed with:   jhb
  MFC after:5 days

Modified:
  head/sys/x86/x86/local_apic.c

Modified: head/sys/x86/x86/local_apic.c
==
--- head/sys/x86/x86/local_apic.c   Mon Feb 27 17:27:42 2017
(r314356)
+++ head/sys/x86/x86/local_apic.c   Mon Feb 27 17:36:31 2017
(r314357)
@@ -398,7 +398,7 @@ lvt_mode(struct lapic *la, u_int pin, ui
if (!lvt->lvt_edgetrigger && bootverbose) {
printf("lapic%u: Forcing LINT%u to edge trigger\n",
la->la_id, pin);
-   value |= APIC_LVT_TM;
+   value &= ~APIC_LVT_TM;
}
/* Use a vector of 0. */
break;
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r314346 - head/sys/arm/allwinner/clkng

2017-02-27 Thread Emmanuel Vadot
Author: manu
Date: Mon Feb 27 17:12:17 2017
New Revision: 314346
URL: https://svnweb.freebsd.org/changeset/base/314346

Log:
  allwinner: Correct some clocks name for H3 CCU.

Modified:
  head/sys/arm/allwinner/clkng/ccu_h3.c

Modified: head/sys/arm/allwinner/clkng/ccu_h3.c
==
--- head/sys/arm/allwinner/clkng/ccu_h3.c   Mon Feb 27 17:04:35 2017
(r314345)
+++ head/sys/arm/allwinner/clkng/ccu_h3.c   Mon Feb 27 17:12:17 2017
(r314346)
@@ -147,9 +147,9 @@ static struct aw_ccung_gate h3_ccu_gates
CCU_GATE(H3_CLK_BUS_SPDIF, "bus-spdif", "apb1", 0x68, 1)
CCU_GATE(H3_CLK_BUS_PIO, "bus-pio", "apb1", 0x68, 5)
CCU_GATE(H3_CLK_BUS_THS, "bus-ths", "apb1", 0x68, 8)
-   CCU_GATE(H3_CLK_BUS_I2S0, "bus-i2c0", "apb1", 0x68, 12)
-   CCU_GATE(H3_CLK_BUS_I2S1, "bus-i2c1", "apb1", 0x68, 13)
-   CCU_GATE(H3_CLK_BUS_I2S2, "bus-i2c2", "apb1", 0x68, 14)
+   CCU_GATE(H3_CLK_BUS_I2S0, "bus-i2s0", "apb1", 0x68, 12)
+   CCU_GATE(H3_CLK_BUS_I2S1, "bus-i2s1", "apb1", 0x68, 13)
+   CCU_GATE(H3_CLK_BUS_I2S2, "bus-i2s2", "apb1", 0x68, 14)
 
CCU_GATE(H3_CLK_BUS_I2C0, "bus-i2c0", "apb2", 0x6c, 0)
CCU_GATE(H3_CLK_BUS_I2C1, "bus-i2c1", "apb2", 0x6c, 1)
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r314345 - head/sys/dev/usb/controller

2017-02-27 Thread Bruce M Simpson
Author: bms
Date: Mon Feb 27 17:04:35 2017
New Revision: 314345
URL: https://svnweb.freebsd.org/changeset/base/314345

Log:
  Add ID for NEC uPD720202 xHCI controller.
  
  MFC after:1 month

Modified:
  head/sys/dev/usb/controller/xhci_pci.c

Modified: head/sys/dev/usb/controller/xhci_pci.c
==
--- head/sys/dev/usb/controller/xhci_pci.c  Mon Feb 27 16:55:09 2017
(r314344)
+++ head/sys/dev/usb/controller/xhci_pci.c  Mon Feb 27 17:04:35 2017
(r314345)
@@ -100,6 +100,8 @@ xhci_pci_match(device_t self)
 
case 0x01941033:
return ("NEC uPD720200 USB 3.0 controller");
+   case 0x00151912:
+   return ("NEC uPD720202 USB 3.0 controller");
 
case 0x10001b73:
return ("Fresco Logic FL1000G USB 3.0 controller");
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r314344 - head/sys/compat/linux

2017-02-27 Thread Dmitry Chagin
Author: dchagin
Date: Mon Feb 27 16:55:09 2017
New Revision: 314344
URL: https://svnweb.freebsd.org/changeset/base/314344

Log:
  Return EINVAL when an invalid file descriptor specified.
  
  MFC after:1 month

Modified:
  head/sys/compat/linux/linux_event.c

Modified: head/sys/compat/linux/linux_event.c
==
--- head/sys/compat/linux/linux_event.c Mon Feb 27 16:53:52 2017
(r314343)
+++ head/sys/compat/linux/linux_event.c Mon Feb 27 16:55:09 2017
(r314344)
@@ -729,7 +729,7 @@ eventfd_close(struct file *fp, struct th
 
efd = fp->f_data;
if (fp->f_type != DTYPE_LINUXEFD || efd == NULL)
-   return (EBADF);
+   return (EINVAL);
 
seldrain(>efd_sel);
knlist_destroy(>efd_sel.si_note);
@@ -751,7 +751,7 @@ eventfd_read(struct file *fp, struct uio
 
efd = fp->f_data;
if (fp->f_type != DTYPE_LINUXEFD || efd == NULL)
-   return (EBADF);
+   return (EINVAL);
 
if (uio->uio_resid < sizeof(eventfd_t))
return (EINVAL);
@@ -797,7 +797,7 @@ eventfd_write(struct file *fp, struct ui
 
efd = fp->f_data;
if (fp->f_type != DTYPE_LINUXEFD || efd == NULL)
-   return (EBADF);
+   return (EINVAL);
 
if (uio->uio_resid < sizeof(eventfd_t))
return (EINVAL);
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r314343 - head/sys/compat/linux

2017-02-27 Thread Dmitry Chagin
Author: dchagin
Date: Mon Feb 27 16:53:52 2017
New Revision: 314343
URL: https://svnweb.freebsd.org/changeset/base/314343

Log:
  Unify eventfd ioctl method and use it for other similar interfaces.
  
  MFC after:1 month

Modified:
  head/sys/compat/linux/linux_event.c

Modified: head/sys/compat/linux/linux_event.c
==
--- head/sys/compat/linux/linux_event.c Mon Feb 27 15:37:38 2017
(r314342)
+++ head/sys/compat/linux/linux_event.c Mon Feb 27 16:53:52 2017
(r314343)
@@ -177,7 +177,7 @@ static struct fileops timerfdops = {
.fo_read = timerfd_read,
.fo_write = invfo_rdwr,
.fo_truncate = invfo_truncate,
-   .fo_ioctl = invfo_ioctl,
+   .fo_ioctl = eventfd_ioctl,
.fo_poll = timerfd_poll,
.fo_kqfilter = timerfd_kqfilter,
.fo_stat = timerfd_stat,
@@ -760,7 +760,7 @@ eventfd_read(struct file *fp, struct uio
mtx_lock(>efd_lock);
 retry:
if (efd->efd_count == 0) {
-   if ((efd->efd_flags & LINUX_O_NONBLOCK) != 0) {
+   if ((fp->f_flag & FNONBLOCK) != 0) {
mtx_unlock(>efd_lock);
return (EAGAIN);
}
@@ -811,7 +811,7 @@ eventfd_write(struct file *fp, struct ui
mtx_lock(>efd_lock);
 retry:
if (UINT64_MAX - efd->efd_count <= count) {
-   if ((efd->efd_flags & LINUX_O_NONBLOCK) != 0) {
+   if ((fp->f_flag & FNONBLOCK) != 0) {
mtx_unlock(>efd_lock);
/* Do not not return the number of bytes written */
uio->uio_resid += sizeof(eventfd_t);
@@ -927,19 +927,18 @@ static int
 eventfd_ioctl(struct file *fp, u_long cmd, void *data,
 struct ucred *active_cred, struct thread *td)
 {
-   struct eventfd *efd;
 
-   efd = fp->f_data;
-   if (fp->f_type != DTYPE_LINUXEFD || efd == NULL)
+   if (fp->f_data == NULL || (fp->f_type != DTYPE_LINUXEFD &&
+   fp->f_type != DTYPE_LINUXTFD))
return (EINVAL);
 
switch (cmd)
{
case FIONBIO:
-   if (*(int *)data)
-   efd->efd_flags |= LINUX_O_NONBLOCK;
+   if ((*(int *)data))
+   atomic_set_int(>f_flag, FNONBLOCK);
else
-   efd->efd_flags &= ~LINUX_O_NONBLOCK;
+   atomic_clear_int(>f_flag, FNONBLOCK);
case FIOASYNC:
return (0);
default:
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r314342 - head/usr.sbin/bhyve

2017-02-27 Thread Roman Bogorodskiy
Author: novel (ports committer)
Date: Mon Feb 27 15:37:38 2017
New Revision: 314342
URL: https://svnweb.freebsd.org/changeset/base/314342

Log:
  bhyve: document virtio-console in the manpage
  
  Reviewed by:  bcr, wblock, jceel
  Approved by:  grehan
  Differential Revision:https://reviews.freebsd.org/D9564

Modified:
  head/usr.sbin/bhyve/bhyve.8

Modified: head/usr.sbin/bhyve/bhyve.8
==
--- head/usr.sbin/bhyve/bhyve.8 Mon Feb 27 15:32:56 2017(r314341)
+++ head/usr.sbin/bhyve/bhyve.8 Mon Feb 27 15:37:38 2017(r314342)
@@ -24,7 +24,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd July 9, 2016
+.Dd February 27, 2017
 .Dt BHYVE 8
 .Os
 .Sh NAME
@@ -171,6 +171,10 @@ Virtio network interface.
 Virtio block storage interface.
 .It Li virtio-rnd
 Virtio RNG interface.
+.It Li virtio-console
+Virtio console interface, which exposes multiple ports
+to the guest in the form of simple char devices for simple IO
+between the guest and host userspaces.
 .It Li ahci
 AHCI controller attached to arbitrary devices.
 .It Li ahci-cd
@@ -270,6 +274,31 @@ The host device must have been reserved 
 .Va pptdev
 loader variable as described in
 .Xr vmm 4 .
+.Pp
+Virtio console devices:
+.Bl -tag -width 10n
+.It Li port1= Ns Pa /path/to/port1.sock Ns ,anotherport= Ns Pa ...
+A maximum of 16 ports per device can be created.
+Every port is named and corresponds to a Unix domain socket created by
+.Nm .
+.Nm
+accepts at most one connection per port at a time.
+.Pp
+Limitations:
+.Bl -bullet -offset 2n
+.It
+Due to lack of destructors in
+.Nm ,
+sockets on the filesystem must be cleaned up manually after
+.Nm
+exits.
+.It
+There is no way to use the "console port" feature, nor the console port
+resize as of now.
+.It
+Emergency write is advertised, but no-op as of now.
+.El
+.El
 .El
 .It Fl S
 Wire guest memory.
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r314341 - head/etc

2017-02-27 Thread Alan Somers
Author: asomers
Date: Mon Feb 27 15:32:56 2017
New Revision: 314341
URL: https://svnweb.freebsd.org/changeset/base/314341

Log:
  Update devd.conf for ports change 421360
  
  Ports change 421360 changed the name and UID of the postgres user
  
  Reviewed by:  trasz, imp, girgen
  MFC after:3 weeks
  Sponsored by: Spectra Logic Corp
  Differential Revision:https://reviews.freebsd.org/D9746

Modified:
  head/etc/devd.conf

Modified: head/etc/devd.conf
==
--- head/etc/devd.conf  Mon Feb 27 15:31:15 2017(r314340)
+++ head/etc/devd.conf  Mon Feb 27 15:32:56 2017(r314341)
@@ -312,10 +312,10 @@ notify 10 {
 };
 
 # This example works around a memory leak in PostgreSQL, restarting
-# it when the "user:pgsql:swap:devctl=1G" rctl(8) rule gets triggered.
+# it when the "user:postgres:swap:devctl=1G" rctl(8) rule gets triggered.
 notify 0 {
match "system"  "RCTL";
-   match "rule""user:70:swap:.*";
+   match "rule""user:770:swap:.*";
action  "/usr/local/etc/rc.d/postgresql restart";
 };
 
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r314340 - head/sys/dev/xen/gntdev

2017-02-27 Thread Roger Pau Monné
Author: royger
Date: Mon Feb 27 15:31:15 2017
New Revision: 314340
URL: https://svnweb.freebsd.org/changeset/base/314340

Log:
  xen/gntdev: prevent unsynchronized accesses to the map entry
  
  vm_map_lookup_done should only be called when the gntdev has finished poking 
at
  the entry.
  
  Reported by:  alc
  Reviewed by:  alc
  MFC after:1 week
  Sponsored by: Citrix Systems R

Modified:
  head/sys/dev/xen/gntdev/gntdev.c

Modified: head/sys/dev/xen/gntdev/gntdev.c
==
--- head/sys/dev/xen/gntdev/gntdev.cMon Feb 27 15:30:27 2017
(r314339)
+++ head/sys/dev/xen/gntdev/gntdev.cMon Feb 27 15:31:15 2017
(r314340)
@@ -743,26 +743,34 @@ gntdev_get_offset_for_vaddr(struct ioctl
vm_prot_t prot;
boolean_t wired;
struct gntdev_gmap *gmap;
+   int rc;
 
map = >td_proc->p_vmspace->vm_map;
error = vm_map_lookup(, arg->vaddr, VM_PROT_NONE, ,
, , , );
if (error != KERN_SUCCESS)
return (EINVAL);
-   vm_map_lookup_done(map, entry);
 
if ((mem->type != OBJT_MGTDEVICE) ||
-   (mem->un_pager.devp.ops != _gmap_pg_ops))
-   return (EINVAL);
+   (mem->un_pager.devp.ops != _gmap_pg_ops)) {
+   rc = EINVAL;
+   goto out;
+   }
 
gmap = mem->handle;
if (gmap == NULL ||
-   (entry->end - entry->start) != (gmap->count * PAGE_SIZE))
-   return (EINVAL);
+   (entry->end - entry->start) != (gmap->count * PAGE_SIZE)) {
+   rc = EINVAL;
+   goto out;
+   }
 
arg->count = gmap->count;
arg->offset = gmap->file_index;
-   return (0);
+   rc = 0;
+
+out:
+   vm_map_lookup_done(map, entry);
+   return (rc);
 }
 
 /* Grant Mapping Pager  
--*/
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r314339 - head/sbin/setkey

2017-02-27 Thread Andrey V. Elsukov
Author: ae
Date: Mon Feb 27 15:30:27 2017
New Revision: 314339
URL: https://svnweb.freebsd.org/changeset/base/314339

Log:
  Document that the size of AH ICV for HMAC-SHA2-NNN should be half of
  NNN bits as described in RFC4868.
  
  PR:   215978

Modified:
  head/sbin/setkey/setkey.8

Modified: head/sbin/setkey/setkey.8
==
--- head/sbin/setkey/setkey.8   Mon Feb 27 14:59:00 2017(r314338)
+++ head/sbin/setkey/setkey.8   Mon Feb 27 15:30:27 2017(r314339)
@@ -29,7 +29,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd February 6, 2017
+.Dd February 27, 2017
 .Dt SETKEY 8
 .Os
 .\"
@@ -593,12 +593,11 @@ keyed-md5 128 ah: 96bit ICV (no documen
 keyed-sha1 160 ah: 96bit ICV (no document)
160 ah-old: 128bit ICV (no document)
 null   0 to 2048   for debugging
-hmac-sha2-256  256 ah: 96bit ICV
-   (draft-ietf-ipsec-ciph-sha-256-00)
+hmac-sha2-256  256 ah: 128bit ICV (RFC4868)
256 ah-old: 128bit ICV (no document)
-hmac-sha2-384  384 ah: 96bit ICV (no document)
+hmac-sha2-384  384 ah: 192bit ICV (RFC4868)
384 ah-old: 128bit ICV (no document)
-hmac-sha2-512  512 ah: 96bit ICV (no document)
+hmac-sha2-512  512 ah: 256bit ICV (RFC4868)
512 ah-old: 128bit ICV (no document)
 hmac-ripemd160 160 ah: 96bit ICV (RFC2857)
ah-old: 128bit ICV (no document)
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r314338 - head/sys/cam/ctl

2017-02-27 Thread Alexander Motin
Author: mav
Date: Mon Feb 27 14:59:00 2017
New Revision: 314338
URL: https://svnweb.freebsd.org/changeset/base/314338

Log:
  Polish handling of different reset flavours.
  
  The biggest change is that ctl_remove_initiator() now generates I_T NEXUS
  LOSS event, cleaning part of LUs state related to the initiator.
  
  MFC after:2 weeks

Modified:
  head/sys/cam/ctl/ctl.c
  head/sys/cam/ctl/ctl_private.h
  head/sys/cam/ctl/ctl_tpc.c

Modified: head/sys/cam/ctl/ctl.c
==
--- head/sys/cam/ctl/ctl.c  Mon Feb 27 14:38:17 2017(r314337)
+++ head/sys/cam/ctl/ctl.c  Mon Feb 27 14:59:00 2017(r314338)
@@ -478,15 +478,15 @@ static int ctl_scsiio_precheck(struct ct
   struct ctl_scsiio *ctsio);
 static int ctl_scsiio(struct ctl_scsiio *ctsio);
 
-static int ctl_bus_reset(struct ctl_softc *ctl_softc, union ctl_io *io);
-static int ctl_target_reset(struct ctl_softc *ctl_softc, union ctl_io *io,
-   ctl_ua_type ua_type);
-static int ctl_do_lun_reset(struct ctl_lun *lun, union ctl_io *io,
+static int ctl_target_reset(union ctl_io *io);
+static void ctl_do_lun_reset(struct ctl_lun *lun, uint32_t initidx,
 ctl_ua_type ua_type);
-static int ctl_lun_reset(struct ctl_softc *ctl_softc, union ctl_io *io);
+static int ctl_lun_reset(union ctl_io *io);
 static int ctl_abort_task(union ctl_io *io);
 static int ctl_abort_task_set(union ctl_io *io);
 static int ctl_query_task(union ctl_io *io, int task_set);
+static void ctl_i_t_nexus_loss(struct ctl_softc *softc, uint32_t initidx,
+ ctl_ua_type ua_type);
 static int ctl_i_t_nexus_reset(union ctl_io *io);
 static int ctl_query_async_event(union ctl_io *io);
 static void ctl_run_task(union ctl_io *io);
@@ -1288,6 +1288,9 @@ ctl_isc_iid_sync(struct ctl_softc *softc
return;
}
iid = msg->hdr.nexus.initid;
+   if (port->wwpn_iid[iid].in_use != 0 &&
+   msg->iid.in_use == 0)
+   ctl_i_t_nexus_loss(softc, iid, CTL_UA_POWERON);
port->wwpn_iid[iid].in_use = msg->iid.in_use;
port->wwpn_iid[iid].wwpn = msg->iid.wwpn;
free(port->wwpn_iid[iid].name, M_CTL);
@@ -2027,6 +2030,7 @@ int
 ctl_remove_initiator(struct ctl_port *port, int iid)
 {
struct ctl_softc *softc = port->ctl_softc;
+   int last;
 
mtx_assert(>ctl_lock, MA_NOTOWNED);
 
@@ -2037,9 +2041,11 @@ ctl_remove_initiator(struct ctl_port *po
}
 
mtx_lock(>ctl_lock);
-   port->wwpn_iid[iid].in_use--;
+   last = (--port->wwpn_iid[iid].in_use == 0);
port->wwpn_iid[iid].last_use = time_uptime;
mtx_unlock(>ctl_lock);
+   if (last)
+   ctl_i_t_nexus_loss(softc, iid, CTL_UA_POWERON);
ctl_isc_announce_iid(port, iid);
 
return (0);
@@ -2144,11 +2150,6 @@ ctl_add_initiator(struct ctl_port *port,
__func__, port->targ_port, iid, wwpn, name,
(uintmax_t)port->wwpn_iid[iid].wwpn,
port->wwpn_iid[iid].name);
-
-   /*
-* XXX KDM clear pending_sense and pending_ua on each LUN
-* for this initiator.
-*/
}
 take:
free(port->wwpn_iid[iid].name, M_CTL);
@@ -11603,50 +11604,42 @@ bailout:
return (retval);
 }
 
-/*
- * Since we only implement one target right now, a bus reset simply resets
- * our single target.
- */
 static int
-ctl_bus_reset(struct ctl_softc *softc, union ctl_io *io)
-{
-   return(ctl_target_reset(softc, io, CTL_UA_BUS_RESET));
-}
-
-static int
-ctl_target_reset(struct ctl_softc *softc, union ctl_io *io,
-ctl_ua_type ua_type)
+ctl_target_reset(union ctl_io *io)
 {
+   struct ctl_softc *softc = CTL_SOFTC(io);
struct ctl_port *port = CTL_PORT(io);
struct ctl_lun *lun;
-   int retval;
+   uint32_t initidx;
+   ctl_ua_type ua_type;
 
if (!(io->io_hdr.flags & CTL_FLAG_FROM_OTHER_SC)) {
union ctl_ha_msg msg_info;
 
msg_info.hdr.nexus = io->io_hdr.nexus;
-   if (ua_type==CTL_UA_TARG_RESET)
-   msg_info.task.task_action = CTL_TASK_TARGET_RESET;
-   else
-   msg_info.task.task_action = CTL_TASK_BUS_RESET;
+   msg_info.task.task_action = io->taskio.task_action;
msg_info.hdr.msg_type = CTL_MSG_MANAGE_TASKS;
msg_info.hdr.original_sc = NULL;
msg_info.hdr.serializing_sc = NULL;
ctl_ha_msg_send(CTL_HA_CHAN_CTL, _info,
sizeof(msg_info.task), M_WAITOK);
}
-   retval = 0;
 
+   initidx = ctl_get_initindex(>io_hdr.nexus);
+   if (io->taskio.task_action == CTL_TASK_TARGET_RESET)
+   ua_type = CTL_UA_TARG_RESET;
+   else
+   ua_type = CTL_UA_BUS_RESET;

svn commit: r314337 - head/sys/compat/linuxkpi/common/include/linux

2017-02-27 Thread Hans Petter Selasky
Author: hselasky
Date: Mon Feb 27 14:38:17 2017
New Revision: 314337
URL: https://svnweb.freebsd.org/changeset/base/314337

Log:
  Implement more bit operation functions in the LinuxKPI.
  Some minor whitespace nits while at it.
  
  Obtained from:kmacy @
  MFC after:1 week
  Sponsored by: Mellanox Technologies

Modified:
  head/sys/compat/linuxkpi/common/include/linux/bitops.h

Modified: head/sys/compat/linuxkpi/common/include/linux/bitops.h
==
--- head/sys/compat/linuxkpi/common/include/linux/bitops.h  Mon Feb 27 
13:59:02 2017(r314336)
+++ head/sys/compat/linuxkpi/common/include/linux/bitops.h  Mon Feb 27 
14:38:17 2017(r314337)
@@ -35,6 +35,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #defineBIT(nr) (1UL << (nr))
 #defineBIT_ULL(nr) (1ULL << (nr))
@@ -43,6 +44,7 @@
 #else
 #defineBITS_PER_LONG   32
 #endif
+
 #defineBITMAP_FIRST_WORD_MASK(start)   (~0UL << ((start) % 
BITS_PER_LONG))
 #defineBITMAP_LAST_WORD_MASK(n)(~0UL >> (BITS_PER_LONG - (n)))
 #defineBITS_TO_LONGS(n)howmany((n), BITS_PER_LONG)
@@ -51,6 +53,12 @@
 #defineGENMASK(h, l)   (((~0UL) >> (BITS_PER_LONG - (h) - 1)) 
& ((~0UL) << (l)))
 #define BITS_PER_BYTE   8
 
+#definehweight8(x) bitcount((uint8_t)(x))
+#definehweight16(x)bitcount16(x)
+#definehweight32(x)bitcount32(x)
+#definehweight64(x)bitcount64(x)
+#definehweight_long(x) bitcountl(x)
+
 static inline int
 __ffs(int mask)
 {
@@ -75,10 +83,15 @@ __flsl(long mask)
return (flsl(mask) - 1);
 }
 
+static inline int
+fls64(uint64_t mask)
+{
+   return (flsll(mask));
+}
+
 static inline uint32_t
 ror32(uint32_t word, unsigned int shift)
 {
-
return ((word >> shift) | (word << (32 - shift)));
 }
 
@@ -542,4 +555,12 @@ bitmap_equal(const unsigned long *pa,
return (1);
 }
 
+static inline uint64_t
+sign_extend64(uint64_t value, int index)
+{
+   uint8_t shift = 63 - index;
+
+   return ((int64_t)(value << shift) >> shift);
+}
+
 #endif /* _LINUX_BITOPS_H_ */
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r314336 - head/sys/compat/linuxkpi/common/include/linux

2017-02-27 Thread Hans Petter Selasky
Author: hselasky
Date: Mon Feb 27 13:59:02 2017
New Revision: 314336
URL: https://svnweb.freebsd.org/changeset/base/314336

Log:
  Define __sum16 type in the LinuxKPI.
  
  MFC after:1 week
  Sponsored by: Mellanox Technologies

Modified:
  head/sys/compat/linuxkpi/common/include/linux/types.h

Modified: head/sys/compat/linuxkpi/common/include/linux/types.h
==
--- head/sys/compat/linuxkpi/common/include/linux/types.h   Mon Feb 27 
13:05:17 2017(r314335)
+++ head/sys/compat/linuxkpi/common/include/linux/types.h   Mon Feb 27 
13:59:02 2017(r314336)
@@ -57,6 +57,7 @@ typedef unsigned intuint;
 typedef unsigned gfp_t;
 typedef uint64_t loff_t;
 typedef vm_paddr_t resource_size_t;
+typedef uint16_t __bitwise__ __sum16;
 
 typedef u64 phys_addr_t;
 
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r314333 - head/sys/arm/allwinner/clkng

2017-02-27 Thread Emmanuel Vadot
Author: manu
Date: Mon Feb 27 11:10:36 2017
New Revision: 314333
URL: https://svnweb.freebsd.org/changeset/base/314333

Log:
  allwinner: Order clocks by offset rather than by type for H3 ccu.
  
  Also add a few more supported gates and add comments for which clocks
  are missing.

Modified:
  head/sys/arm/allwinner/clkng/aw_clk.h
  head/sys/arm/allwinner/clkng/ccu_h3.c
  head/sys/arm/allwinner/clkng/ccu_h3.h

Modified: head/sys/arm/allwinner/clkng/aw_clk.h
==
--- head/sys/arm/allwinner/clkng/aw_clk.h   Mon Feb 27 10:40:39 2017
(r314332)
+++ head/sys/arm/allwinner/clkng/aw_clk.h   Mon Feb 27 11:10:36 2017
(r314333)
@@ -179,7 +179,7 @@ aw_clk_factor_get_value(struct aw_clk_fa
.shift = s, \
},
 
-#define NKMP_CLK(_id, _name, _pnames,  \
+#define NKMP_CLK(_clkname, _id, _name, _pnames,\
   _offset, \
   _n_shift, _n_width, _n_value, _n_flags,  \
   _k_shift, _k_width, _k_value, _k_flags,  \
@@ -188,7 +188,7 @@ aw_clk_factor_get_value(struct aw_clk_fa
   _gate,   \
   _lock, _lock_retries,\
   _flags)  \
-   {   \
+   static struct aw_clk_nkmp_def _clkname = {  \
.clkdef = { \
.id = _id,  \
.name = _name,  \
@@ -216,16 +216,16 @@ aw_clk_factor_get_value(struct aw_clk_fa
.lock_shift = _lock,\
.lock_retries = _lock_retries,  \
.flags = _flags,\
-   },
+   }
 
-#define NM_CLK(_id, _name, _pnames,\
+#define NM_CLK(_clkname, _id, _name, _pnames,  \
  _offset,  \
  _nshift, _nwidth, _nvalue, _nflags,   \
  _mshift, _mwidth, _mvalue, _mflags,   \
 _mux_shift, _mux_width,\
 _gate_shift,   \
 _flags)\
-   {   \
+   static struct aw_clk_nm_def _clkname =  {   \
.clkdef = { \
.id = _id,  \
.name = _name,  \
@@ -244,15 +244,15 @@ aw_clk_factor_get_value(struct aw_clk_fa
.m.flags = _mflags, \
.mux_width = _mux_width,\
.flags = _flags,\
-   },
+   }
 
-#define NM_CLK_WITH_FRAC(_id, _name, _pnames,  \
+#define NM_CLK_WITH_FRAC(_clkname, _id, _name, _pnames,\
  _offset,  \
  _nshift, _nwidth, _nvalue, _nflags,   \
  _mshift, _mwidth, _mvalue, _mflags,   \
  _gate_shift, _lock_shift,_lock_retries,   \
 _flags, _freq0, _freq1, _mode_sel, _freq_sel)  \
-   {   \
+   static struct aw_clk_nm_def _clkname =  {   \
.clkdef = { \
.id = _id,  \
.name = _name,  \
@@ -276,15 +276,15 @@ aw_clk_factor_get_value(struct aw_clk_fa
.frac.freq1 = _freq1,   \
.frac.mode_sel = _mode_sel, \
.frac.freq_sel = _freq_sel, \
-   },
+   }
 
-#define PREDIV_CLK(_id, _name, _pnames,\
+#define PREDIV_CLK(_clkname, _id, _name, _pnames,  \
   _offset, \
   _mux_shift, _mux_width,  \
   _div_shift, _div_width, _div_value, _div_flags,  \
   _prediv_shift, _prediv_width, _prediv_value, _prediv_flags,  \
   _prediv_cond_shift, _prediv_cond_width, _prediv_cond_value)  \
-   {   \
+   static struct aw_clk_prediv_mux_def _clkname = {\
.clkdef = { \
.id = _id,  \
.name = _name,  \
@@ -305,11 +305,11 @@ aw_clk_factor_get_value(struct aw_clk_fa
.prediv.cond_shift = _prediv_cond_shift,\
.prediv.cond_width = _prediv_cond_width,\
.prediv.cond_value = _prediv_cond_value,\
-   },
+   }
 
-#define MUX_CLK(_id, _name, _pnames,   \
+#define MUX_CLK(_clkname, _id, _name, _pnames, 

svn commit: r314329 - head/sys/arm/allwinner/clkng

2017-02-27 Thread Emmanuel Vadot
Author: manu
Date: Mon Feb 27 08:58:27 2017
New Revision: 314329
URL: https://svnweb.freebsd.org/changeset/base/314329

Log:
  allwinner: Add support for lock and fractional mode on NM clock
  
  Some PLL have a fractional mode and a lock bit.
  Add support for it on the NM clock and export the clocks in the clkdom.

Modified:
  head/sys/arm/allwinner/clkng/aw_clk.h
  head/sys/arm/allwinner/clkng/aw_clk_nm.c
  head/sys/arm/allwinner/clkng/aw_clk_nm.h
  head/sys/arm/allwinner/clkng/ccu_h3.c

Modified: head/sys/arm/allwinner/clkng/aw_clk.h
==
--- head/sys/arm/allwinner/clkng/aw_clk.h   Mon Feb 27 08:36:51 2017
(r314328)
+++ head/sys/arm/allwinner/clkng/aw_clk.h   Mon Feb 27 08:58:27 2017
(r314329)
@@ -63,6 +63,7 @@ struct aw_clk_init {
 #defineAW_CLK_HAS_MUX  0x0004
 #defineAW_CLK_REPARENT 0x0008
 #defineAW_CLK_SCALE_CHANGE 0x0010
+#defineAW_CLK_HAS_FRAC 0x0020
 
 #defineAW_CLK_FACTOR_POWER_OF_TWO  0x0001
 #defineAW_CLK_FACTOR_ZERO_BASED0x0002
@@ -83,6 +84,13 @@ struct aw_clk_factor {
uint32_tflags;  /* Flags */
 };
 
+struct aw_clk_frac {
+   uint64_tfreq0;
+   uint64_tfreq1;
+   uint32_tmode_sel;
+   uint32_tfreq_sel;
+};
+
 static inline uint32_t
 aw_clk_get_factor(uint32_t val, struct aw_clk_factor *factor)
 {
@@ -238,6 +246,38 @@ aw_clk_factor_get_value(struct aw_clk_fa
.flags = _flags,\
},
 
+#define NM_CLK_WITH_FRAC(_id, _name, _pnames,  \
+ _offset,  \
+ _nshift, _nwidth, _nvalue, _nflags,   \
+ _mshift, _mwidth, _mvalue, _mflags,   \
+ _gate_shift, _lock_shift,_lock_retries,   \
+_flags, _freq0, _freq1, _mode_sel, _freq_sel)  \
+   {   \
+   .clkdef = { \
+   .id = _id,  \
+   .name = _name,  \
+   .parent_names = _pnames,\
+   .parent_cnt = nitems(_pnames),  \
+   },  \
+   .offset = _offset,  \
+   .n.shift = _nshift, \
+   .n.width = _nwidth, \
+   .n.value = _nvalue, \
+   .n.flags = _nflags, \
+   .m.shift = _mshift, \
+   .m.width = _mwidth, \
+   .m.value = _mvalue, \
+   .m.flags = _mflags, \
+   .gate_shift = _gate_shift,  \
+   .lock_shift = _lock_shift,  \
+   .lock_retries = _lock_retries,  \
+   .flags = _flags | AW_CLK_HAS_FRAC,  \
+   .frac.freq0 = _freq0,   \
+   .frac.freq1 = _freq1,   \
+   .frac.mode_sel = _mode_sel, \
+   .frac.freq_sel = _freq_sel, \
+   },
+
 #define PREDIV_CLK(_id, _name, _pnames,\
   _offset, \
   _mux_shift, _mux_width,  \

Modified: head/sys/arm/allwinner/clkng/aw_clk_nm.c
==
--- head/sys/arm/allwinner/clkng/aw_clk_nm.cMon Feb 27 08:36:51 2017
(r314328)
+++ head/sys/arm/allwinner/clkng/aw_clk_nm.cMon Feb 27 08:58:27 2017
(r314329)
@@ -52,10 +52,13 @@ struct aw_clk_nm_sc {
 
struct aw_clk_factorm;
struct aw_clk_factorn;
+   struct aw_clk_frac  frac;
 
uint32_tmux_shift;
uint32_tmux_mask;
uint32_tgate_shift;
+   uint32_tlock_shift;
+   uint32_tlock_retries;
 
uint32_tflags;
 };
@@ -178,13 +181,13 @@ aw_clk_nm_set_freq(struct clknode *clk, 
struct aw_clk_nm_sc *sc;
struct clknode *p_clk;
const char **p_names;
-   uint64_t cur, best;
+   uint64_t cur, best, best_frac;
uint32_t val, m, n, best_m, best_n;
-   int p_idx, best_parent;
+   int p_idx, best_parent, retry;
 
sc = clknode_get_softc(clk);
 
-   best = cur = 0;
+   best = best_frac = cur = 0;
best_parent = 0;
 
if ((sc->flags & AW_CLK_REPARENT) != 0) {
@@ -205,8 +208,15 @@ aw_clk_nm_set_freq(struct clknode *clk, 
p_idx = clknode_get_parent_idx(clk);
p_clk = clknode_get_parent(clk);
clknode_get_freq(p_clk, );
-   } else
-   best = aw_clk_nm_find_best(sc, fparent, fout, _n, _m);
+   } else {

svn commit: r314328 - head/sys/dev/acpica

2017-02-27 Thread Hans Petter Selasky
Author: hselasky
Date: Mon Feb 27 08:36:51 2017
New Revision: 314328
URL: https://svnweb.freebsd.org/changeset/base/314328

Log:
  Fix startup race initialising ACPI CM battery structures on MacBookPro.
  
  During acpi_cmbat_attach() the acpi_cmbat_init_battery() notification
  handler is registered. It has been observed this notification handler
  can be called instantly, before the attach routine has returned. In
  the notification handler there is a call to device_is_attached() which
  returns false. Because the softc is set we know an attach is in
  progress and the fix is simply to wait and try again in this case.
  
  Reviewed by:  avg @
  MFC after:1 week

Modified:
  head/sys/dev/acpica/acpi_cmbat.c

Modified: head/sys/dev/acpica/acpi_cmbat.c
==
--- head/sys/dev/acpica/acpi_cmbat.cMon Feb 27 08:27:38 2017
(r314327)
+++ head/sys/dev/acpica/acpi_cmbat.cMon Feb 27 08:36:51 2017
(r314328)
@@ -164,6 +164,16 @@ acpi_cmbat_detach(device_t dev)
 handle = acpi_get_handle(dev);
 AcpiRemoveNotifyHandler(handle, ACPI_ALL_NOTIFY, 
acpi_cmbat_notify_handler);
 acpi_battery_remove(dev);
+
+/*
+ * Force any pending notification handler calls to complete by
+ * requesting cmbat serialisation while freeing and clearing the
+ * softc pointer:
+ */
+ACPI_SERIAL_BEGIN(cmbat);
+device_set_softc(dev, NULL);
+ACPI_SERIAL_END(cmbat);
+
 return (0);
 }
 
@@ -436,7 +446,6 @@ acpi_cmbat_init_battery(void *arg)
 device_t   dev;
 
 dev = (device_t)arg;
-sc = device_get_softc(dev);
 ACPI_VPRINT(dev, acpi_device_get_parent_softc(dev),
"battery initialization start\n");
 
@@ -446,18 +455,33 @@ acpi_cmbat_init_battery(void *arg)
  * to wait a while.
  */
 for (retry = 0; retry < ACPI_CMBAT_RETRY_MAX; retry++, AcpiOsSleep(1)) 
{
-   /* batteries on DOCK can be ejected w/ DOCK during retrying */
-   if (!device_is_attached(dev))
+   /*
+* Batteries on DOCK can be ejected w/ DOCK during retrying.
+*
+* If there is a valid softc pointer the device may be in
+* attaching, attached or detaching state. If the state is
+* different from attached retry getting the device state
+* until it becomes stable. This solves a race if the ACPI
+* notification handler is called during attach, because
+* device_is_attached() doesn't return non-zero until after
+* the attach code has been executed.
+*/
+   ACPI_SERIAL_BEGIN(cmbat);
+   sc = device_get_softc(dev);
+   if (sc == NULL) {
+   ACPI_SERIAL_END(cmbat);
return;
+   }
 
-   if (!acpi_BatteryIsPresent(dev))
+   if (!acpi_BatteryIsPresent(dev) || !device_is_attached(dev)) {
+   ACPI_SERIAL_END(cmbat);
continue;
+   }
 
/*
 * Only query the battery if this is the first try or the specific
 * type of info is still invalid.
 */
-   ACPI_SERIAL_BEGIN(cmbat);
if (retry == 0 || !acpi_battery_bst_valid(>bst)) {
timespecclear(>bst_lastupdated);
acpi_cmbat_get_bst(dev);
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r314326 - head/sys/dev/isp

2017-02-27 Thread Alexander Motin
Author: mav
Date: Mon Feb 27 08:20:28 2017
New Revision: 314326
URL: https://svnweb.freebsd.org/changeset/base/314326

Log:
  Send TERMINATE to firmware when aborting active ATIO.
  
  MFC after:2 weeks

Modified:
  head/sys/dev/isp/isp.c
  head/sys/dev/isp/isp_freebsd.c
  head/sys/dev/isp/isp_freebsd.h

Modified: head/sys/dev/isp/isp.c
==
--- head/sys/dev/isp/isp.c  Mon Feb 27 04:08:08 2017(r314325)
+++ head/sys/dev/isp/isp.c  Mon Feb 27 08:20:28 2017(r314326)
@@ -7133,7 +7133,7 @@ static const uint32_t mbpfc[] = {
ISP_FC_OPMAP(0x00, 0x00),   /* 0x3f: */
ISP_FC_OPMAP(0x03, 0x01),   /* 0x40: MBOX_LOOP_PORT_BYPASS */
ISP_FC_OPMAP(0x03, 0x01),   /* 0x41: MBOX_LOOP_PORT_ENABLE */
-   ISP_FC_OPMAP_HALF(0x0, 0x01, 0x3, 0xcf),/* 0x42: 
MBOX_GET_RESOURCE_COUNT */
+   ISP_FC_OPMAP_HALF(0x0, 0x01, 0x1f, 0xcf),   /* 0x42: 
MBOX_GET_RESOURCE_COUNT */
ISP_FC_OPMAP(0x01, 0x01),   /* 0x43: MBOX_REQUEST_OFFLINE_MODE */
ISP_FC_OPMAP(0x00, 0x00),   /* 0x44: */
ISP_FC_OPMAP(0x00, 0x00),   /* 0x45: */

Modified: head/sys/dev/isp/isp_freebsd.c
==
--- head/sys/dev/isp/isp_freebsd.c  Mon Feb 27 04:08:08 2017
(r314325)
+++ head/sys/dev/isp/isp_freebsd.c  Mon Feb 27 08:20:28 2017
(r314326)
@@ -1011,7 +1011,7 @@ isp_dump_atpd(ispsoftc_t *isp, int chan)
if (atp->state == ATPD_STATE_FREE)
continue;
isp_prt(isp, ISP_LOGALL, "Chan %d ATP [0x%x] origdlen %u 
bytes_xfrd %u lun %jx nphdl 0x%04x s_id 0x%06x d_id 0x%06x oxid 0x%04x state 
%s",
-   chan, atp->tag, atp->orig_datalen, atp->bytes_xfered, 
(uintmax_t)atp->lun, atp->nphdl, atp->sid, atp->portid, atp->oxid, 
states[atp->state & 0x7]);
+   chan, atp->tag, atp->orig_datalen, atp->bytes_xfered, 
(uintmax_t)atp->lun, atp->nphdl, atp->sid, atp->did, atp->oxid, 
states[atp->state & 0x7]);
}
 }
 
@@ -1344,8 +1344,8 @@ isp_target_start_ctio(ispsoftc_t *isp, u
ATPD_SET_SEQNO(cto, atp);
cto->ct_nphdl = atp->nphdl;
cto->ct_rxid = atp->tag;
-   cto->ct_iid_lo = atp->portid;
-   cto->ct_iid_hi = atp->portid >> 16;
+   cto->ct_iid_lo = atp->sid;
+   cto->ct_iid_hi = atp->sid >> 16;
cto->ct_oxid = atp->oxid;
cto->ct_vpidx = ISP_GET_VPIDX(isp, XS_CHANNEL(ccb));
cto->ct_timeout = (XS_TIME(ccb) + 999) / 1000;
@@ -2088,7 +2088,8 @@ isp_handle_platform_atio7(ispsoftc_t *is
atp->bytes_xfered = 0;
atp->lun = lun;
atp->nphdl = nphdl;
-   atp->portid = sid;
+   atp->sid = sid;
+   atp->did = did;
atp->oxid = aep->at_hdr.ox_id;
atp->rxid = aep->at_hdr.rx_id;
atp->cdb0 = atiop->cdb_io.cdb_bytes[0];
@@ -3269,7 +3270,23 @@ isp_abort_atio(ispsoftc_t *isp, union cc
/* Search for the ATIO among running. */
atp = isp_find_atpd(isp, XS_CHANNEL(accb), accb->atio.tag_id);
if (atp != NULL) {
-   /* XXX Send TERMINATE to firmware here. */
+   /* Send TERMINATE to firmware. */
+   if (!atp->dead && IS_24XX(isp)) {
+   uint8_t storage[QENTRY_LEN];
+   ct7_entry_t *cto = (ct7_entry_t *) storage;
+
+   ISP_MEMZERO(cto, sizeof (ct7_entry_t));
+   cto->ct_header.rqs_entry_type = RQSTYPE_CTIO7;
+   cto->ct_header.rqs_entry_count = 1;
+   cto->ct_nphdl = atp->nphdl;
+   cto->ct_rxid = atp->tag;
+   cto->ct_iid_lo = atp->sid;
+   cto->ct_iid_hi = atp->sid >> 16;
+   cto->ct_oxid = atp->oxid;
+   cto->ct_vpidx = XS_CHANNEL(accb);
+   cto->ct_flags = CT7_NOACK|CT7_TERMINATE;
+   isp_target_put_entry(isp, cto);
+   }
isp_put_atpd(isp, XS_CHANNEL(accb), atp);
ccb->ccb_h.status = CAM_REQ_CMP;
} else {

Modified: head/sys/dev/isp/isp_freebsd.h
==
--- head/sys/dev/isp/isp_freebsd.h  Mon Feb 27 04:08:08 2017
(r314325)
+++ head/sys/dev/isp/isp_freebsd.h  Mon Feb 27 08:20:28 2017
(r314326)
@@ -103,7 +103,7 @@ typedef struct atio_private_data {
lun_id_tlun;
uint32_tnphdl;
uint32_tsid;
-   uint32_tportid;
+   uint32_tdid;
uint16_trxid;   /* wire rxid */
uint16_toxid;   /* wire oxid */
uint16_t