svn commit: r309728 - head/sys/dev/hyperv/storvsc

2016-12-08 Thread Sepherosa Ziehau
Author: sephe
Date: Fri Dec  9 06:18:12 2016
New Revision: 309728
URL: https://svnweb.freebsd.org/changeset/base/309728

Log:
  hyperv/storvsc: Minor style changes; no functional changes.
  
  Reported by:  rpokala
  MFC after:1 week
  Sponsored by: Microsoft

Modified:
  head/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c

Modified: head/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c
==
--- head/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.cFri Dec  9 
04:35:07 2016(r309727)
+++ head/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.cFri Dec  9 
06:18:12 2016(r309728)
@@ -2057,6 +2057,7 @@ static uint32_t
 is_scsi_valid(const struct scsi_inquiry_data *inq_data)
 {
u_int8_t type;
+
type = SID_TYPE(inq_data);
if (type == T_NODEVICE)
return (0);
@@ -2064,6 +2065,7 @@ is_scsi_valid(const struct scsi_inquiry_
return (0);
return (1);
 }
+
 /**
  * @brief completion function before returning to CAM
  *
@@ -2082,6 +2084,7 @@ storvsc_io_done(struct hv_storvsc_reques
struct vmscsi_req *vm_srb = >vstor_packet.u.vm_srb;
bus_dma_segment_t *ori_sglist = NULL;
int ori_sg_count = 0;
+
/* destroy bounce buffer if it is used */
if (reqp->bounce_sgl_count) {
ori_sglist = (bus_dma_segment_t *)ccb->csio.data_ptr;
@@ -2136,6 +2139,7 @@ storvsc_io_done(struct hv_storvsc_reques
ccb->ccb_h.status &= ~CAM_STATUS_MASK;
if (vm_srb->scsi_status == SCSI_STATUS_OK) {
const struct scsi_generic *cmd;
+
cmd = (const struct scsi_generic *)
((ccb->ccb_h.flags & CAM_CDB_POINTER) ?
 csio->cdb_io.cdb_ptr : csio->cdb_io.cdb_bytes);
@@ -2178,11 +2182,12 @@ storvsc_io_done(struct hv_storvsc_reques
if (cmd->opcode == INQUIRY &&
vm_srb->srb_status == SRB_STATUS_SUCCESS) {
int resp_xfer_len, resp_buf_len, data_len;
+   uint8_t *resp_buf = (uint8_t *)csio->data_ptr;
struct scsi_inquiry_data *inq_data =
(struct scsi_inquiry_data *)csio->data_ptr;
+
/* Get the buffer length reported by host */
resp_xfer_len = vm_srb->transfer_len;
-   uint8_t *resp_buf = (uint8_t *)csio->data_ptr;
 
/* Get the available buffer length */
resp_buf_len = resp_xfer_len >= 5 ? resp_buf[4] + 5 : 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: r309726 - head/sys/dev/hyperv/storvsc

2016-12-08 Thread Sepherosa Ziehau
Author: sephe
Date: Fri Dec  9 03:16:36 2016
New Revision: 309726
URL: https://svnweb.freebsd.org/changeset/base/309726

Log:
  hyperv/storvsc: Fix the SCSI disk attachment issue.
  
  On pre-WS2016 Hyper-V, if the only LUNs > 7 are used, then all disks
  fails to attach.  Mainly because those versions of Hyper-V do not set
  SRB_STATUS properly and deliver junky INQUERY responses.
  
  Submitted by: Hongjiang Zhang 
  Reported by:  Hongxiong Xian 
  MFC after:1 week
  Sponsored by: Microsoft
  Differential Revision:https://reviews.freebsd.org/D8724

Modified:
  head/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c

Modified: head/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c
==
--- head/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.cFri Dec  9 
02:21:27 2016(r309725)
+++ head/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.cFri Dec  9 
03:16:36 2016(r309726)
@@ -2053,6 +2053,17 @@ create_storvsc_request(union ccb *ccb, s
return(0);
 }
 
+static uint32_t
+is_scsi_valid(const struct scsi_inquiry_data *inq_data)
+{
+   u_int8_t type;
+   type = SID_TYPE(inq_data);
+   if (type == T_NODEVICE)
+   return (0);
+   if (SID_QUAL(inq_data) == SID_QUAL_BAD_LU)
+   return (0);
+   return (1);
+}
 /**
  * @brief completion function before returning to CAM
  *
@@ -2164,32 +2175,46 @@ storvsc_io_done(struct hv_storvsc_reques
ccb->ccb_h.status |= CAM_REQ_CMP;
}
 
-   if (cmd->opcode == INQUIRY) {
+   if (cmd->opcode == INQUIRY &&
+   vm_srb->srb_status == SRB_STATUS_SUCCESS) {
+   int resp_xfer_len, resp_buf_len, data_len;
struct scsi_inquiry_data *inq_data =
(struct scsi_inquiry_data *)csio->data_ptr;
-   uint8_t *resp_buf = (uint8_t *)csio->data_ptr;
-   int resp_xfer_len, resp_buf_len, data_len;
-
/* Get the buffer length reported by host */
resp_xfer_len = vm_srb->transfer_len;
+   uint8_t *resp_buf = (uint8_t *)csio->data_ptr;
+
/* Get the available buffer length */
resp_buf_len = resp_xfer_len >= 5 ? resp_buf[4] + 5 : 0;
data_len = (resp_buf_len < resp_xfer_len) ?
resp_buf_len : resp_xfer_len;
-
if (bootverbose && data_len >= 5) {
xpt_print(ccb->ccb_h.path, "storvsc inquiry "
"(%d) [%x %x %x %x %x ... ]\n", data_len,
resp_buf[0], resp_buf[1], resp_buf[2],
resp_buf[3], resp_buf[4]);
}
-   if (vm_srb->srb_status == SRB_STATUS_SUCCESS &&
-   data_len >= SHORT_INQUIRY_LENGTH) {
+   /*
+* XXX: Manually fix the wrong response returned from 
WS2012
+*/
+   if (!is_scsi_valid(inq_data) &&
+   (vmstor_proto_version == 
VMSTOR_PROTOCOL_VERSION_WIN8_1 ||
+   vmstor_proto_version == 
VMSTOR_PROTOCOL_VERSION_WIN8 ||
+   vmstor_proto_version == 
VMSTOR_PROTOCOL_VERSION_WIN7)) {
+   if (data_len >= 4 &&
+   (resp_buf[2] == 0 || resp_buf[3] == 0)) {
+   resp_buf[2] = 5; // verion=5 means SPC-3
+   resp_buf[3] = 2; // resp fmt must be 2
+   if (bootverbose)
+   xpt_print(ccb->ccb_h.path,
+   "fix version and resp fmt 
for 0x%x\n",
+   vmstor_proto_version);
+   }
+   } else if (data_len >= SHORT_INQUIRY_LENGTH) {
char vendor[16];
 
cam_strvis(vendor, inq_data->vendor,
sizeof(inq_data->vendor), sizeof(vendor));
-
/*
 * XXX: Upgrade SPC2 to SPC3 if host is WIN8 or
 * WIN2012 R2 in order to support UNMAP feature.
___
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: r309725 - head/sys/dev/cxgbe

2016-12-08 Thread Navdeep Parhar
Author: np
Date: Fri Dec  9 02:21:27 2016
New Revision: 309725
URL: https://svnweb.freebsd.org/changeset/base/309725

Log:
  cxgbe(4): netmap does not set IFCAP_NETMAP in an ifnet's if_capabilities
  any more (since r307394).  Do it in the driver instead.
  
  MFC after:1 week

Modified:
  head/sys/dev/cxgbe/t4_main.c
  head/sys/dev/cxgbe/t4_netmap.c

Modified: head/sys/dev/cxgbe/t4_main.c
==
--- head/sys/dev/cxgbe/t4_main.cFri Dec  9 01:44:26 2016
(r309724)
+++ head/sys/dev/cxgbe/t4_main.cFri Dec  9 02:21:27 2016
(r309725)
@@ -1417,6 +1417,10 @@ cxgbe_vi_attach(device_t dev, struct vi_
if (vi->nofldrxq != 0)
ifp->if_capabilities |= IFCAP_TOE;
 #endif
+#ifdef DEV_NETMAP
+   if (vi->nnmrxq != 0)
+   ifp->if_capabilities |= IFCAP_NETMAP;
+#endif
ifp->if_capenable = T4_CAP_ENABLE;
ifp->if_hwassist = CSUM_TCP | CSUM_UDP | CSUM_IP | CSUM_TSO |
CSUM_UDP_IPV6 | CSUM_TCP_IPV6;
@@ -1435,7 +1439,7 @@ cxgbe_vi_attach(device_t dev, struct vi_
 
ether_ifattach(ifp, vi->hw_addr);
 #ifdef DEV_NETMAP
-   if (vi->nnmrxq != 0)
+   if (ifp->if_capabilities & IFCAP_NETMAP)
cxgbe_nm_attach(vi);
 #endif
sb = sbuf_new_auto();

Modified: head/sys/dev/cxgbe/t4_netmap.c
==
--- head/sys/dev/cxgbe/t4_netmap.c  Fri Dec  9 01:44:26 2016
(r309724)
+++ head/sys/dev/cxgbe/t4_netmap.c  Fri Dec  9 02:21:27 2016
(r309725)
@@ -870,7 +870,7 @@ cxgbe_nm_attach(struct vi_info *vi)
na.nm_register = cxgbe_netmap_reg;
na.num_tx_rings = vi->nnmtxq;
na.num_rx_rings = vi->nnmrxq;
-   netmap_attach(); /* This adds IFCAP_NETMAP to if_capabilities */
+   netmap_attach();
 }
 
 void
___
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: r309723 - head/usr.sbin/nfsd

2016-12-08 Thread Rick Macklem
Author: rmacklem
Date: Thu Dec  8 23:29:56 2016
New Revision: 309723
URL: https://svnweb.freebsd.org/changeset/base/309723

Log:
  Patch the nfsd so that it doesn't register with rpcbind for an NFSv4 only
  server.
  
  This patch uses the sysctl vfs.nfsd.server_min_nfsvers to determine
  if/what versions of NFS service should be registered with rpcbind.
  For NFSv4 only, it does not register at all, since NFSv4 always uses 2049
  and does not require rpcbind.
  For NFSv3 minimum, it registers NFSv3 but not NFSv2.
  
  Tested by:jmad...@gmu.edu
  Submitted by: jmad...@gmu.edu (earlier version)
  MFC after:2 weeks
  Differential Revision:https://reviews.freebsd.org/D8696

Modified:
  head/usr.sbin/nfsd/nfsd.c

Modified: head/usr.sbin/nfsd/nfsd.c
==
--- head/usr.sbin/nfsd/nfsd.c   Thu Dec  8 21:02:34 2016(r309722)
+++ head/usr.sbin/nfsd/nfsd.c   Thu Dec  8 23:29:56 2016(r309723)
@@ -82,6 +82,9 @@ static intdebug = 0;
 #defineNFSD_STABLEBACKUP   "/var/db/nfs-stablerestart.bak"
 #defineMAXNFSDCNT  256
 #defineDEFNFSDCNT   4
+#defineNFS_VER2 2
+#define NFS_VER33
+#define NFS_VER44
 static pid_t children[MAXNFSDCNT]; /* PIDs of children */
 static int nfsdcnt;/* number of children */
 static int nfsdcnt_set;
@@ -158,6 +161,8 @@ main(int argc, char **argv)
int bindhostc, bindanyflag, rpcbreg, rpcbregcnt;
int nfssvc_addsock;
int longindex = 0;
+   int nfs_minvers = NFS_VER2;
+   size_t nfs_minvers_size;
const char *lopt;
char **bindhost = NULL;
pid_t pid;
@@ -266,6 +271,15 @@ main(int argc, char **argv)
errx(1, "Out of memory");
}
 
+   nfs_minvers_size = sizeof(nfs_minvers);
+   error = sysctlbyname("vfs.nfsd.server_min_nfsvers", _minvers,
+   _minvers_size, NULL, 0);
+   if (error != 0 || nfs_minvers < NFS_VER2 || nfs_minvers > NFS_VER4) {
+   warnx("sysctlbyname(vfs.nfsd.server_min_nfsvers) failed,"
+   " defaulting to NFSv2");
+   nfs_minvers = NFS_VER2;
+   }
+
if (unregister) {
unregistration();
exit (0);
@@ -285,9 +299,14 @@ main(int argc, char **argv)
err(1, "getnetconfigent udp failed");
nb_udp.buf = ai_udp->ai_addr;
nb_udp.len = nb_udp.maxlen = ai_udp->ai_addrlen;
-   if ((!rpcb_set(NFS_PROGRAM, 2, nconf_udp, _udp)) ||
-   (!rpcb_set(NFS_PROGRAM, 3, nconf_udp, _udp)))
-   err(1, "rpcb_set udp failed");
+   if (nfs_minvers == NFS_VER2)
+   if (!rpcb_set(NFS_PROGRAM, 2, nconf_udp,
+   _udp))
+   err(1, "rpcb_set udp failed");
+   if (nfs_minvers <= NFS_VER3)
+   if (!rpcb_set(NFS_PROGRAM, 3, nconf_udp,
+   _udp))
+   err(1, "rpcb_set udp failed");
freeaddrinfo(ai_udp);
}
if (udpflag && ip6flag) {
@@ -304,9 +323,14 @@ main(int argc, char **argv)
err(1, "getnetconfigent udp6 failed");
nb_udp6.buf = ai_udp6->ai_addr;
nb_udp6.len = nb_udp6.maxlen = ai_udp6->ai_addrlen;
-   if ((!rpcb_set(NFS_PROGRAM, 2, nconf_udp6, _udp6)) ||
-   (!rpcb_set(NFS_PROGRAM, 3, nconf_udp6, _udp6)))
-   err(1, "rpcb_set udp6 failed");
+   if (nfs_minvers == NFS_VER2)
+   if (!rpcb_set(NFS_PROGRAM, 2, nconf_udp6,
+   _udp6))
+   err(1, "rpcb_set udp6 failed");
+   if (nfs_minvers <= NFS_VER3)
+   if (!rpcb_set(NFS_PROGRAM, 3, nconf_udp6,
+   _udp6))
+   err(1, "rpcb_set udp6 failed");
freeaddrinfo(ai_udp6);
}
if (tcpflag) {
@@ -323,9 +347,14 @@ main(int argc, char **argv)
err(1, "getnetconfigent tcp failed");
nb_tcp.buf = ai_tcp->ai_addr;
nb_tcp.len = nb_tcp.maxlen = ai_tcp->ai_addrlen;
-   if ((!rpcb_set(NFS_PROGRAM, 2, nconf_tcp, _tcp)) ||
-   (!rpcb_set(NFS_PROGRAM, 3, nconf_tcp, _tcp)))
-   err(1, "rpcb_set tcp failed");
+   if (nfs_minvers == NFS_VER2)
+   if (!rpcb_set(NFS_PROGRAM, 2, 

Re: svn commit: r309658 - head/sys/vm

2016-12-08 Thread Mark Johnston
On Thu, Dec 08, 2016 at 07:50:17AM -0800, John Baldwin wrote:
> On Wednesday, December 07, 2016 02:15:49 PM Mark Johnston wrote:
> > On Wed, Dec 07, 2016 at 01:26:47PM -0800, Gleb Smirnoff wrote:
> > > On Tue, Dec 06, 2016 at 10:52:45PM +, Mark Johnston wrote:
> > > M> Author: markj
> > > M> Date: Tue Dec  6 22:52:45 2016
> > > M> New Revision: 309658
> > > M> URL: https://svnweb.freebsd.org/changeset/base/309658
> > > M> 
> > > M> Log:
> > > M>   Provide dummy sysctls for v_cache_count and v_tcached.
> > > M>   
> > > M>   Some utilities (notably top(1)) exit if any of their input sysctls 
> > > don't
> > > M>   exist, and the removal of the above-mentioned PG_CACHE-related 
> > > sysctls
> > > M>   makes it difficult to run such utilities on different versions of the
> > > M>   kernel without recompiling.
> > > M>   
> > > M>   Requested by:bde
> > > M> 
> > > M> Modified:
> > > M>   head/sys/vm/vm_meter.c
> > > M> 
> > > M> Modified: head/sys/vm/vm_meter.c
> > > M> 
> > > ==
> > > M> --- head/sys/vm/vm_meter.c Tue Dec  6 22:48:28 2016
> > > (r309657)
> > > M> +++ head/sys/vm/vm_meter.c Tue Dec  6 22:52:45 2016
> > > (r309658)
> > > M> @@ -314,3 +314,14 @@ VM_STATS_VM(v_forkpages, "VM pages affec
> > > M>  VM_STATS_VM(v_vforkpages, "VM pages affected by vfork()");
> > > M>  VM_STATS_VM(v_rforkpages, "VM pages affected by rfork()");
> > > M>  VM_STATS_VM(v_kthreadpages, "VM pages affected by fork() by kernel");
> > > M> +
> > > M> +#ifndef BURN_BRIDGES
> > > M> +/*
> > > M> + * Provide compatibility sysctls for the benefit of old utilities 
> > > which exit
> > > M> + * with an error if they cannot be found.
> > > M> + */
> > > M> +SYSCTL_UINT(_vm_stats_vm, OID_AUTO, v_cache_count, CTLFLAG_RD,
> > > M> +(u_int *)NULL, 0, "Dummy for compatibility");
> > > M> +SYSCTL_UINT(_vm_stats_vm, OID_AUTO, v_tcached, CTLFLAG_RD,
> > > M> +(u_int *)NULL, 0, "Dummy for compatibility");
> > > M> +#endif
> > > 
> > > IMHO, there should be some garbage collecting timeout for them. I'd 
> > > suggest to
> > > delete them from head after stable/12 branch is forked.
> > 
> > The intent was to improve compatibility with old userlands, not just to
> > help bridge the transition from 11.0 to 12.0. In general I'm all for
> > removing cruft, but these sysctls are unobtrusive and I don't see any
> > reason to remove them in a specific time frame provided that nothing
> > else breaks compatibility for top(1) (and vmstat(8)). Please feel free
> > to add a timeout if you still disagree, though.
> 
> I would suggest sticking them under COMPAT_FREEBSD11 then.  That would give
> users control via the COMPAT_FREEBSD options the way we do with other
> compat shims.  The only nit is you need to add the COMPAT_FREEBSD11 option
> first (probably in a separate commit).

Ok. I've put up a CR here if anyone would like to take a look first:
https://reviews.freebsd.org/D8736
___
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: r309394 - head/sys/netpfil/pf

2016-12-08 Thread Gleb Smirnoff
  Marcel,

On Wed, Dec 07, 2016 at 05:06:08PM -0800, Marcel Moolenaar wrote:
M> >  thanks for the fixes. While the problem with the first chunk
M> > in pfsync_sendout() is obvious, the problem you are fixing in th
M> > second chunk in the pfsync_delete_state() is not clear to me.
M> > Can you please explain what scenario are you fixing there?
M> 
M> State updates may be pending for state being deleted. This
M> means that the state is still sitting on either the PFSYNC_S_UPD
M> or PFSYNC_S_UPD_C queues. What pfsync(4) does in that case is
M> simply remove the state from those queues and add it to the
M> PFSYNC_S_DEL queue.
M> 
M> But, pf(4) has already dropped the reference count for state
M> that’s deleted and the only reference is by pfsync(4) by virtue
M> of being on the PFSYNC_S_UPD or PFSYNC_S_UPD_C queues. When the
M> state gets dequeued from those queues, the reference count drops
M> to 0 and the state is deleted (read: memory freed). But the same
M> state is subsequently added to the PFSYNC_S_DEL queue — i.e.
M> after the memory was freed.

Thanks for explanation, Marcel! Potentially this problem also exists
in pfsync_update_state() and in pfsync_update_state_req().

Your patch introduces extra unnecessary atomic operations, so let
me suggest another patch. It should be applied on top of yours, and
it also addresses pfsync_update_state() and in pfsync_update_state_req().

It isn't tested, but is pretty straightforward. 

-- 
Totus tuus, Glebius.
Index: sys/netpfil/pf/if_pfsync.c
===
--- sys/netpfil/pf/if_pfsync.c	(revision 309722)
+++ sys/netpfil/pf/if_pfsync.c	(working copy)
@@ -161,8 +161,8 @@ static struct pfsync_q pfsync_qs[] = {
 	{ pfsync_out_del,   sizeof(struct pfsync_del_c),   PFSYNC_ACT_DEL_C }
 };
 
-static void	pfsync_q_ins(struct pf_state *, int);
-static void	pfsync_q_del(struct pf_state *);
+static void	pfsync_q_ins(struct pf_state *, int, bool);
+static void	pfsync_q_del(struct pf_state *, bool);
 
 static void	pfsync_update_state(struct pf_state *);
 
@@ -542,7 +542,7 @@ pfsync_state_import(struct pfsync_state *sp, u_int
 	if (!(flags & PFSYNC_SI_IOCTL)) {
 		st->state_flags &= ~PFSTATE_NOSYNC;
 		if (st->state_flags & PFSTATE_ACK) {
-			pfsync_q_ins(st, PFSYNC_S_IACK);
+			pfsync_q_ins(st, PFSYNC_S_IACK, true);
 			pfsync_push(sc);
 		}
 	}
@@ -1668,7 +1668,7 @@ pfsync_insert_state(struct pf_state *st)
 	if (sc->sc_len == PFSYNC_MINPKT)
 		callout_reset(>sc_tmo, 1 * hz, pfsync_timeout, V_pfsyncif);
 
-	pfsync_q_ins(st, PFSYNC_S_INS);
+	pfsync_q_ins(st, PFSYNC_S_INS, true);
 	PFSYNC_UNLOCK(sc);
 
 	st->sync_updates = 0;
@@ -1789,7 +1789,7 @@ static void
 pfsync_update_state(struct pf_state *st)
 {
 	struct pfsync_softc *sc = V_pfsyncif;
-	int sync = 0;
+	bool sync = false, ref = true;
 
 	PF_STATE_LOCK_ASSERT(st);
 	PFSYNC_LOCK(sc);
@@ -1798,7 +1798,7 @@ pfsync_update_state(struct pf_state *st)
 		pfsync_undefer_state(st, 0);
 	if (st->state_flags & PFSTATE_NOSYNC) {
 		if (st->sync_state != PFSYNC_S_NONE)
-			pfsync_q_del(st);
+			pfsync_q_del(st, true);
 		PFSYNC_UNLOCK(sc);
 		return;
 	}
@@ -1815,14 +1815,17 @@ pfsync_update_state(struct pf_state *st)
 		if (st->key[PF_SK_WIRE]->proto == IPPROTO_TCP) {
 			st->sync_updates++;
 			if (st->sync_updates >= sc->sc_maxupdates)
-sync = 1;
+sync = true;
 		}
 		break;
 
 	case PFSYNC_S_IACK:
-		pfsync_q_del(st);
+		pfsync_q_del(st, false);
+		ref = false;
+		/* FALLTHROUGH */
+
 	case PFSYNC_S_NONE:
-		pfsync_q_ins(st, PFSYNC_S_UPD_C);
+		pfsync_q_ins(st, PFSYNC_S_UPD_C, ref);
 		st->sync_updates = 0;
 		break;
 
@@ -1880,6 +1883,7 @@ static void
 pfsync_update_state_req(struct pf_state *st)
 {
 	struct pfsync_softc *sc = V_pfsyncif;
+	bool ref = true;
 
 	PF_STATE_LOCK_ASSERT(st);
 	PFSYNC_LOCK(sc);
@@ -1886,7 +1890,7 @@ pfsync_update_state_req(struct pf_state *st)
 
 	if (st->state_flags & PFSTATE_NOSYNC) {
 		if (st->sync_state != PFSYNC_S_NONE)
-			pfsync_q_del(st);
+			pfsync_q_del(st, true);
 		PFSYNC_UNLOCK(sc);
 		return;
 	}
@@ -1894,9 +1898,12 @@ pfsync_update_state_req(struct pf_state *st)
 	switch (st->sync_state) {
 	case PFSYNC_S_UPD_C:
 	case PFSYNC_S_IACK:
-		pfsync_q_del(st);
+		pfsync_q_del(st, false);
+		ref = false;
+		/* FALLTHROUGH */
+
 	case PFSYNC_S_NONE:
-		pfsync_q_ins(st, PFSYNC_S_UPD);
+		pfsync_q_ins(st, PFSYNC_S_UPD, true);
 		pfsync_push(sc);
 		break;
 
@@ -1917,6 +1924,7 @@ static void
 pfsync_delete_state(struct pf_state *st)
 {
 	struct pfsync_softc *sc = V_pfsyncif;
+	bool ref = true;
 
 	PFSYNC_LOCK(sc);
 	if (st->state_flags & PFSTATE_ACK)
@@ -1923,7 +1931,7 @@ pfsync_delete_state(struct pf_state *st)
 		pfsync_undefer_state(st, 1);
 	if (st->state_flags & PFSTATE_NOSYNC) {
 		if (st->sync_state != PFSYNC_S_NONE)
-			pfsync_q_del(st);
+			pfsync_q_del(st, true);
 		PFSYNC_UNLOCK(sc);
 		return;
 	}
@@ -1931,22 +1939,21 @@ pfsync_delete_state(struct pf_state *st)
 	if (sc->sc_len == PFSYNC_MINPKT)
 		callout_reset(>sc_tmo, 1 * 

svn commit: r309722 - head/contrib/llvm/lib/Analysis

2016-12-08 Thread Dimitry Andric
Author: dim
Date: Thu Dec  8 21:02:34 2016
New Revision: 309722
URL: https://svnweb.freebsd.org/changeset/base/309722

Log:
  Pull in r281586 from upstream llvm trunk (by Wei Mi):
  
Add some shortcuts in LazyValueInfo to reduce compile time of
Correlated Value Propagation.
  
The patch is to partially fix PR10584. Correlated Value Propagation
queries LVI to check non-null for pointer params of each callsite. If
we know the def of param is an alloca instruction, we know it is
non-null and can return early from LVI. Similarly, CVP queries LVI to
check whether pointer for each mem access is constant. If the def of
the pointer is an alloca instruction, we know it is not a constant
pointer. These shortcuts can reduce the cost of CVP significantly.
  
Differential Revision: https://reviews.llvm.org/D18066
  
  This significantly reduces memory usage and compilation time when
  compiling a particular C++ source file of the graphics/colmap port.
  
  PR:   215136
  MFC after:3 days

Modified:
  head/contrib/llvm/lib/Analysis/LazyValueInfo.cpp

Modified: head/contrib/llvm/lib/Analysis/LazyValueInfo.cpp
==
--- head/contrib/llvm/lib/Analysis/LazyValueInfo.cppThu Dec  8 20:54:54 
2016(r309721)
+++ head/contrib/llvm/lib/Analysis/LazyValueInfo.cppThu Dec  8 21:02:34 
2016(r309722)
@@ -1479,8 +1479,27 @@ LazyValueInfo LazyValueAnalysis::run(Fun
   return LazyValueInfo(, , DT);
 }
 
+ 
+/// Returns true if we can statically tell that this value will never be a
+/// "useful" constant.  In practice, this means we've got something like an
+/// alloca or a malloc call for which a comparison against a constant can
+/// only be guarding dead code.  Note that we are potentially giving up some
+/// precision in dead code (a constant result) in favour of avoiding a
+/// expensive search for a easily answered common query.
+static bool isKnownNonConstant(Value *V) {
+  V = V->stripPointerCasts();
+  // The return val of alloc cannot be a Constant.
+  if (isa(V))
+return true;
+  return false;
+}
+
 Constant *LazyValueInfo::getConstant(Value *V, BasicBlock *BB,
  Instruction *CxtI) {
+  // Bail out early if V is known not to be a Constant.
+  if (isKnownNonConstant(V))
+return nullptr;
+
   const DataLayout  = BB->getModule()->getDataLayout();
   LVILatticeVal Result =
   getCache(PImpl, AC, , DT).getValueInBlock(V, BB, CxtI);
@@ -1613,6 +1632,17 @@ LazyValueInfo::getPredicateOnEdge(unsign
 LazyValueInfo::Tristate
 LazyValueInfo::getPredicateAt(unsigned Pred, Value *V, Constant *C,
   Instruction *CxtI) {
+  // Is or is not NonNull are common predicates being queried. If
+  // isKnownNonNull can tell us the result of the predicate, we can
+  // return it quickly. But this is only a fastpath, and falling
+  // through would still be correct.
+  if (V->getType()->isPointerTy() && C->isNullValue() &&
+  isKnownNonNull(V->stripPointerCasts())) {
+if (Pred == ICmpInst::ICMP_EQ)
+  return LazyValueInfo::False;
+else if (Pred == ICmpInst::ICMP_NE)
+  return LazyValueInfo::True;
+  }
   const DataLayout  = CxtI->getModule()->getDataLayout();
   LVILatticeVal Result = getCache(PImpl, AC, , DT).getValueAt(V, CxtI);
   Tristate Ret = getPredicateResult(Pred, C, Result, DL, TLI);
___
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: r309721 - head/sys/dev/usb/wlan

2016-12-08 Thread Andriy Voskoboinyk
Author: avos
Date: Thu Dec  8 20:54:54 2016
New Revision: 309721
URL: https://svnweb.freebsd.org/changeset/base/309721

Log:
  rsu: fix incorrect register addresses.

Modified:
  head/sys/dev/usb/wlan/if_rsureg.h

Modified: head/sys/dev/usb/wlan/if_rsureg.h
==
--- head/sys/dev/usb/wlan/if_rsureg.h   Thu Dec  8 19:28:12 2016
(r309720)
+++ head/sys/dev/usb/wlan/if_rsureg.h   Thu Dec  8 20:54:54 2016
(r309721)
@@ -51,16 +51,16 @@
 #define R92S_MACID (R92S_MACIDSETTING + 0x000)
 #define R92S_MAR   (R92S_MACIDSETTING + 0x010)
 
-#define R92S_GP0x01e0
-#define R92S_GPIO_CTRL (R92S_GP + 0x00c)
-#define R92S_GPIO_IO_SEL   (R92S_GP + 0x00e)
-#define R92S_MAC_PINMUX_CTRL   (R92S_GP + 0x011)
-
 #define R92S_SECURITY  0x0240
 #define R92S_CAMCMD(R92S_SECURITY + 0x000)
 #define R92S_CAMWRITE  (R92S_SECURITY + 0x004)
 #define R92S_CAMREAD   (R92S_SECURITY + 0x008)
 
+#define R92S_GP0x02e0
+#define R92S_GPIO_CTRL (R92S_GP + 0x00c)
+#define R92S_GPIO_IO_SEL   (R92S_GP + 0x00e)
+#define R92S_MAC_PINMUX_CTRL   (R92S_GP + 0x011)
+
 #define R92S_IOCMD_CTRL0x0370
 #define R92S_IOCMD_DATA0x0374
 
___
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: r309720 - head/usr.sbin/bsdinstall/scripts

2016-12-08 Thread Devin Teske
Author: dteske
Date: Thu Dec  8 19:28:12 2016
New Revision: 309720
URL: https://svnweb.freebsd.org/changeset/base/309720

Log:
  Functions in their own section

Modified:
  head/usr.sbin/bsdinstall/scripts/wlanconfig

Modified: head/usr.sbin/bsdinstall/scripts/wlanconfig
==
--- head/usr.sbin/bsdinstall/scripts/wlanconfig Thu Dec  8 19:26:22 2016
(r309719)
+++ head/usr.sbin/bsdinstall/scripts/wlanconfig Thu Dec  8 19:28:12 2016
(r309720)
@@ -1,7 +1,7 @@
 #!/bin/sh
 #-
 # Copyright (c) 2011 Nathan Whitehorn
-# Copyright (c) 2013-2015 Devin Teske
+# Copyright (c) 2013-2016 Devin Teske
 # All rights reserved.
 #
 # Redistribution and use in source and binary forms, with or without
@@ -33,31 +33,7 @@ BSDCFG_SHARE="/usr/share/bsdconfig"
 . $BSDCFG_SHARE/common.subr || exit 1
 f_include $BSDCFG_SHARE/dialog.subr
 
- MAIN
-
-echo -n > $BSDINSTALL_TMPETC/wpa_supplicant.conf
-chmod 0600 $BSDINSTALL_TMPETC/wpa_supplicant.conf
-
-echo "ctrl_interface=/var/run/wpa_supplicant" >> 
$BSDINSTALL_TMPETC/wpa_supplicant.conf
-echo "eapol_version=2" >> $BSDINSTALL_TMPETC/wpa_supplicant.conf
-echo "ap_scan=1" >> $BSDINSTALL_TMPETC/wpa_supplicant.conf
-echo "fast_reauth=1" >> $BSDINSTALL_TMPETC/wpa_supplicant.conf
-echo >> $BSDINSTALL_TMPETC/wpa_supplicant.conf
-
-# Try to reach wpa_supplicant. If it isn't running and we can modify the
-# existing system, start it. Otherwise, fail.
-(wpa_cli ping >/dev/null 2>/dev/null || ([ ! -z $BSDINSTALL_CONFIGCURRENT ] &&
-   wpa_supplicant -B -i $1 -c $BSDINSTALL_TMPETC/wpa_supplicant.conf)) ||
-   (dialog --backtitle "FreeBSD Installer" --title "Error" --msgbox \
-   "Could not start wpa_supplicant!" 0 0; exit 1) || exit 1
-
-# See if we succeeded
-wpa_cli ping >/dev/null 2>/dev/null
-if [ $? -ne 0 -a -z $BSDINSTALL_CONFIGCURRENT ]; then
-   dialog --backtitle "FreeBSD Installer" --title "Error" --msgbox \
-   "Wireless cannot be configured without making changes to the local 
system!" \ 0 0
-   exit 1
-fi
+ FUNCTIONS
 
 country_set()
 {
@@ -177,6 +153,32 @@ dialog_country_select()
return $?
 }
 
+ MAIN
+
+echo -n > $BSDINSTALL_TMPETC/wpa_supplicant.conf
+chmod 0600 $BSDINSTALL_TMPETC/wpa_supplicant.conf
+
+echo "ctrl_interface=/var/run/wpa_supplicant" >> 
$BSDINSTALL_TMPETC/wpa_supplicant.conf
+echo "eapol_version=2" >> $BSDINSTALL_TMPETC/wpa_supplicant.conf
+echo "ap_scan=1" >> $BSDINSTALL_TMPETC/wpa_supplicant.conf
+echo "fast_reauth=1" >> $BSDINSTALL_TMPETC/wpa_supplicant.conf
+echo >> $BSDINSTALL_TMPETC/wpa_supplicant.conf
+
+# Try to reach wpa_supplicant. If it isn't running and we can modify the
+# existing system, start it. Otherwise, fail.
+(wpa_cli ping >/dev/null 2>/dev/null || ([ ! -z $BSDINSTALL_CONFIGCURRENT ] &&
+   wpa_supplicant -B -i $1 -c $BSDINSTALL_TMPETC/wpa_supplicant.conf)) ||
+   (dialog --backtitle "FreeBSD Installer" --title "Error" --msgbox \
+   "Could not start wpa_supplicant!" 0 0; exit 1) || exit 1
+
+# See if we succeeded
+wpa_cli ping >/dev/null 2>/dev/null
+if [ $? -ne 0 -a -z $BSDINSTALL_CONFIGCURRENT ]; then
+   dialog --backtitle "FreeBSD Installer" --title "Error" --msgbox \
+   "Wireless cannot be configured without making changes to the local 
system!" \ 0 0
+   exit 1
+fi
+
 # There is no way to check country/regdomain without (possible)
 # interface state modification
 if [ ! -z $BSDINSTALL_CONFIGCURRENT ]; then
___
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: r309719 - head/usr.sbin/bsdinstall/scripts

2016-12-08 Thread Devin Teske
Author: dteske
Date: Thu Dec  8 19:26:22 2016
New Revision: 309719
URL: https://svnweb.freebsd.org/changeset/base/309719

Log:
  Remove unnecessary trailing backslashes

Modified:
  head/usr.sbin/bsdinstall/scripts/wlanconfig

Modified: head/usr.sbin/bsdinstall/scripts/wlanconfig
==
--- head/usr.sbin/bsdinstall/scripts/wlanconfig Thu Dec  8 18:56:35 2016
(r309718)
+++ head/usr.sbin/bsdinstall/scripts/wlanconfig Thu Dec  8 19:26:22 2016
(r309719)
@@ -46,8 +46,8 @@ echo >> $BSDINSTALL_TMPETC/wpa_supplican
 
 # Try to reach wpa_supplicant. If it isn't running and we can modify the
 # existing system, start it. Otherwise, fail.
-(wpa_cli ping >/dev/null 2>/dev/null || ([ ! -z $BSDINSTALL_CONFIGCURRENT ] && 
\
-   wpa_supplicant -B -i $1 -c $BSDINSTALL_TMPETC/wpa_supplicant.conf)) || \
+(wpa_cli ping >/dev/null 2>/dev/null || ([ ! -z $BSDINSTALL_CONFIGCURRENT ] &&
+   wpa_supplicant -B -i $1 -c $BSDINSTALL_TMPETC/wpa_supplicant.conf)) ||
(dialog --backtitle "FreeBSD Installer" --title "Error" --msgbox \
"Could not start wpa_supplicant!" 0 0; exit 1) || exit 1
 
@@ -86,7 +86,7 @@ country_set()
if [ ! -z "$iface_up" ]; then
ifconfig $WLAN_IFACE down
fi
-   error_str=`ifconfig $WLAN_IFACE $ifconfig_args 2>&1 | \
+   error_str=`ifconfig $WLAN_IFACE $ifconfig_args 2>&1 |
sed 's/ifconfig: //'`
if [ ! -z "$iface_up" ]; then
# Restart wpa_supplicant(8) (should not fail).
@@ -123,9 +123,9 @@ dialog_country_select()
 
# Parse available countries/regdomains
input=`ifconfig $WLAN_IFACE list countries | sed 's/DEBUG//gi'`
-   regdomains=`echo $input | sed 's/.*domains://' | tr ' ' '\n' | \
+   regdomains=`echo $input | sed 's/.*domains://' | tr ' ' '\n' |
sort | tr '\n' ' '`
-   countries=`echo $input | sed 's/Country codes://' | \
+   countries=`echo $input | sed 's/Country codes://' |
sed 's/Regulatory.*//' | awk '{
for (i = 1; i <= NF; i++) {
printf "%s", $i
@@ -222,7 +222,7 @@ do
 
if [ -z "$NETWORKS" ]; then
dialog --backtitle "FreeBSD Installer" --title "Error" \
-   --yesno "No wireless networks were found. Rescan?" 0 0 && \
+   --yesno "No wireless networks were found. Rescan?" 0 0 &&
continue
exit 1
fi
___
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: r309718 - head/cddl/usr.sbin/dtrace/tests/tools

2016-12-08 Thread Mark Johnston
Author: markj
Date: Thu Dec  8 18:56:35 2016
New Revision: 309718
URL: https://svnweb.freebsd.org/changeset/base/309718

Log:
  err.D_PROC_CREATEFAIL.many.d passes, so remove the EFAIL annotation.
  
  MFC after:1 week
  Sponsored by: Dell EMC Isilon

Modified:
  head/cddl/usr.sbin/dtrace/tests/tools/exclude.sh

Modified: head/cddl/usr.sbin/dtrace/tests/tools/exclude.sh
==
--- head/cddl/usr.sbin/dtrace/tests/tools/exclude.shThu Dec  8 18:18:48 
2016(r309717)
+++ head/cddl/usr.sbin/dtrace/tests/tools/exclude.shThu Dec  8 18:56:35 
2016(r309718)
@@ -128,9 +128,6 @@ exclude EXFAIL common/ip/tst.ipv4remotei
 exclude EXFAIL common/ip/tst.localtcpstate.ksh
 exclude EXFAIL common/ip/tst.remotetcpstate.ksh
 
-# Depends on the number of probes in /bin/sh and the current DOF limit.
-exclude EXFAIL common/pid/err.D_PROC_CREATEFAIL.many.d
-
 # Tries to enable pid$target:libc::entry, though there's no "libc" module.
 # Currently unsure as to whether this might be a libproc bug.
 exclude EXFAIL common/pid/tst.probemod.ksh
___
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: r309717 - head/sys/net

2016-12-08 Thread Luiz Otavio O Souza
Author: loos
Date: Thu Dec  8 18:18:48 2016
New Revision: 309717
URL: https://svnweb.freebsd.org/changeset/base/309717

Log:
  Fix the typos and style(9) in comment.
  
  MFC after:2 weeks
  Sponsored by: Rubicon Communications, LLC (Netgate)

Modified:
  head/sys/net/route.c

Modified: head/sys/net/route.c
==
--- head/sys/net/route.cThu Dec  8 16:41:18 2016(r309716)
+++ head/sys/net/route.cThu Dec  8 18:18:48 2016(r309717)
@@ -467,9 +467,8 @@ rtalloc1_fib(struct sockaddr *dst, int r
RIB_RUNLOCK(rh);

/*
-* Either we hit the root or couldn't find any match,
-* Which basically means
-* "caint get there frm here"
+* Either we hit the root or could not find any match,
+* which basically means: "cannot get there from here".
 */
 miss:
V_rtstat.rts_unreach++;
___
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: r309716 - head/usr.sbin/bsdinstall/scripts

2016-12-08 Thread Devin Teske
Author: dteske
Date: Thu Dec  8 16:41:18 2016
New Revision: 309716
URL: https://svnweb.freebsd.org/changeset/base/309716

Log:
  Add support for "hidden" Wi-Fi networks
  
  PR:   bin/214933
  Submitted by: Maxim Filimonov 
  Reviewed by:  dteske, allanjude, adrian
  MFC after:6 days
  X-MFC-with:   Follow-up commit for style

Modified:
  head/usr.sbin/bsdinstall/scripts/wlanconfig

Modified: head/usr.sbin/bsdinstall/scripts/wlanconfig
==
--- head/usr.sbin/bsdinstall/scripts/wlanconfig Thu Dec  8 16:28:34 2016
(r309715)
+++ head/usr.sbin/bsdinstall/scripts/wlanconfig Thu Dec  8 16:41:18 2016
(r309716)
@@ -207,6 +207,7 @@ fi
 
 while :
 do
+   SCANSSID=0
output=$( wpa_cli scan 2>&1 )
f_dprintf "%s" "$output"
dialog --backtitle "FreeBSD Installer" --title "Scanning" \
@@ -236,7 +237,19 @@ do
break
;;
1)  # Cancel
-   exit 1
+   # here we ask if the user wants to select the network manually
+   f_dialog_title "Network Selection"
+   f_dialog_yesno "Do you want to select the network manually?" || 
exit 1
+   # and take the manual input
+   # first, take the ssid
+   f_dialog_input NETWORK "Enter SSID" || exit 1
+   # then, the encryption
+   ENCRYPTION=$( dialog --backtitle "$DIALOG_BACKTITLE" --title \
+   "$DIALOG_TITLE" --menu "Select encryption type" 0 0 0 \
+   "1 WPA/WPA2 PSK" "" "2 WPA/WPA2 EAP" "" "3 WEP" "" "0 
None" "" 2>&1 1>&3 ) || exit 1
+   SCANSSID=1
+   f_dialog_title_restore
+   break
;;
3)  # Rescan
;;
@@ -244,7 +257,7 @@ do
exec 3>&-
 done
 
-ENCRYPTION=`echo "$NETWORKS" | awk -F '\t' \
+[ -z "$ENCRYPTION" ] && ENCRYPTION=`echo "$NETWORKS" | awk -F '\t' \
 "/^\"$NETWORK\"\t/ {printf(\"%s\n\", \\\$2 );}"`
 
 if echo $ENCRYPTION | grep -q 'PSK'; then
@@ -258,6 +271,7 @@ if echo $ENCRYPTION | grep -q 'PSK'; the
exec 3>&-
 echo "network={
ssid=\"$NETWORK\"
+   scan_ssid=$SCANSSID
psk=\"$PASS\"
priority=5
 }" >> $BSDINSTALL_TMPETC/wpa_supplicant.conf
@@ -273,6 +287,7 @@ elif echo $ENCRYPTION | grep -q EAP; the
exec 3>&-
 echo "network={
ssid=\"$NETWORK\"
+   scan_ssid=$SCANSSID
key_mgmt=WPA-EAP" >> $BSDINSTALL_TMPETC/wpa_supplicant.conf
 echo "$USERPASS" | awk '
 {
@@ -294,6 +309,7 @@ elif echo $ENCRYPTION | grep -q WEP; the
|| exec $0 $@
 echo "network={
ssid=\"$NETWORK\"
+   scan_ssid=$SCANSSID
key_mgmt=NONE
wep_key0=\"$WEPKEY\"
wep_tx_keyidx=0
@@ -302,6 +318,7 @@ echo "network={
 else   # Open
 echo "network={
ssid=\"$NETWORK\"
+   scan_ssid=$SCANSSID
key_mgmt=NONE
priority=5
 }" >> $BSDINSTALL_TMPETC/wpa_supplicant.conf
___
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: r309703 - in head/sys: amd64/amd64 arm64/arm64 i386/i386 vm

2016-12-08 Thread Alan Cox
On 12/08/2016 07:01, Slawa Olhovchenkov wrote:
> On Thu, Dec 08, 2016 at 04:29:29AM +, Alan Cox wrote:
>
>> Author: alc
>> Date: Thu Dec  8 04:29:29 2016
>> New Revision: 309703
>> URL: https://svnweb.freebsd.org/changeset/base/309703
>>
>> Log:
>>   Previously, vm_radix_remove() would panic if the radix trie didn't
>>   contain a vm_page_t at the specified index.  However, with this
>>   change, vm_radix_remove() no longer panics.  Instead, it returns NULL
>>   if there is no vm_page_t at the specified index.  Otherwise, it
>>   returns the vm_page_t.  The motivation for this change is that it
>>   simplifies the use of radix tries in the amd64, arm64, and i386 pmap
>>   implementations.  Instead of performing a lookup before every remove,
>>   the pmap can simply perform the remove.
> Is this performance improvement?
>
>

In that it reduces the number of radix trie operations performed by the
pmap, yes.  However, radix tries are only used in the pmap to store page
table pages that were formerly used by now promoted superpages, so the
net effect is going to be small.


___
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: r309715 - head/sys/mips/ingenic

2016-12-08 Thread Ruslan Bukin
Author: br
Date: Thu Dec  8 16:28:34 2016
New Revision: 309715
URL: https://svnweb.freebsd.org/changeset/base/309715

Log:
  Add jz4780 internal codec initialization driver.
  
  Sponsored by: DARPA, AFRL

Added:
  head/sys/mips/ingenic/jz4780_codec.c   (contents, props changed)
  head/sys/mips/ingenic/jz4780_codec.h   (contents, props changed)
  head/sys/mips/ingenic/jz4780_common.h   (contents, props changed)

Added: head/sys/mips/ingenic/jz4780_codec.c
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/sys/mips/ingenic/jz4780_codec.cThu Dec  8 16:28:34 2016
(r309715)
@@ -0,0 +1,242 @@
+/*-
+ * Copyright (c) 2016 Ruslan Bukin 
+ * All rights reserved.
+ *
+ * This software was developed by SRI International and the University of
+ * Cambridge Computer Laboratory under DARPA/AFRL contract FA8750-10-C-0237
+ * ("CTSRD"), as part of the DARPA CRASH research programme.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/* Ingenic JZ4780 CODEC. */
+
+#include 
+__FBSDID("$FreeBSD$");
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+
+#include 
+#include 
+#include 
+
+#include 
+#include 
+
+struct codec_softc {
+   device_tdev;
+   struct resource *res[1];
+   bus_space_tag_t bst;
+   bus_space_handle_t  bsh;
+};
+
+static struct resource_spec codec_spec[] = {
+   { SYS_RES_MEMORY,   0,  RF_ACTIVE },
+   { -1, 0 }
+};
+
+static int codec_probe(device_t dev);
+static int codec_attach(device_t dev);
+static int codec_detach(device_t dev);
+void codec_print_registers(struct codec_softc *sc);
+
+static int
+codec_write(struct codec_softc *sc, uint32_t reg, uint32_t val)
+{
+   uint32_t tmp;
+
+   tmp = (reg << RGADW_RGADDR_S);
+   tmp |= (val << RGADW_RGDIN_S);
+   tmp |= RGADW_RGWR;
+
+   WRITE4(sc, CODEC_RGADW, tmp);
+
+   while(READ4(sc, CODEC_RGADW) & RGADW_RGWR)
+   ;
+
+   return (0);
+}
+
+static int
+codec_read(struct codec_softc *sc, uint32_t reg)
+{
+   uint32_t tmp;
+
+   tmp = (reg << RGADW_RGADDR_S);
+   WRITE4(sc, CODEC_RGADW, tmp);
+
+   tmp = READ4(sc, CODEC_RGDATA);
+
+   return (tmp);
+}
+
+void
+codec_print_registers(struct codec_softc *sc)
+{
+
+   printf("codec SR %x\n", codec_read(sc, SR));
+   printf("codec SR2 %x\n", codec_read(sc, SR2));
+   printf("codec MR %x\n", codec_read(sc, MR));
+   printf("codec AICR_DAC %x\n", codec_read(sc, AICR_DAC));
+   printf("codec AICR_ADC %x\n", codec_read(sc, AICR_ADC));
+   printf("codec CR_LO %x\n", codec_read(sc, CR_LO));
+   printf("codec CR_HP %x\n", codec_read(sc, CR_HP));
+   printf("codec CR_DMIC %x\n", codec_read(sc, CR_DMIC));
+   printf("codec CR_MIC1 %x\n", codec_read(sc, CR_MIC1));
+   printf("codec CR_MIC2 %x\n", codec_read(sc, CR_MIC2));
+   printf("codec CR_LI1 %x\n", codec_read(sc, CR_LI1));
+   printf("codec CR_LI2 %x\n", codec_read(sc, CR_LI2));
+   printf("codec CR_DAC %x\n", codec_read(sc, CR_DAC));
+   printf("codec CR_ADC %x\n", codec_read(sc, CR_ADC));
+   printf("codec CR_MIX %x\n", codec_read(sc, CR_MIX));
+   printf("codec DR_MIX %x\n", codec_read(sc, DR_MIX));
+   printf("codec CR_VIC %x\n", codec_read(sc, CR_VIC));
+   printf("codec CR_CK %x\n", codec_read(sc, CR_CK));
+   printf("codec FCR_DAC %x\n", codec_read(sc, FCR_DAC));
+   printf("codec FCR_ADC %x\n", codec_read(sc, FCR_ADC));
+   printf("codec CR_TIMER_MSB %x\n", codec_read(sc, CR_TIMER_MSB));
+   

svn commit: r309714 - head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs

2016-12-08 Thread Alexander Motin
Author: mav
Date: Thu Dec  8 15:58:03 2016
New Revision: 309714
URL: https://svnweb.freebsd.org/changeset/base/309714

Log:
  Fix spa_alloc_tree sorting by offset in r305331.
  
  Original commit "7090 zfs should improve allocation order" declares alloc
  queue sorted by time and offset.  But in practice io_offset is always zero,
  so sorting happened only by time, while order of writes with equal time was
  completely random.  On Illumos this did not affected much thanks to using
  high resolution timestamps.  On FreeBSD due to using much faster but low
  resolution timestamps it caused bad data placement on disks, affecting
  further read performance.
  
  This change switches zio_timestamp_compare() from comparing uninitialized
  io_offset to really populated io_bookmark values.  I haven't decided yet
  what to do with timestampts, but on simple tests this change gives the
  same peformance results by just making code to work as declared.
  
  MFC after:1 week

Modified:
  head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zio.c

Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zio.c
==
--- head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zio.c   Thu Dec  8 
12:42:36 2016(r309713)
+++ head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zio.c   Thu Dec  8 
15:58:03 2016(r309714)
@@ -563,9 +563,24 @@ zio_timestamp_compare(const void *x1, co
if (z1->io_queued_timestamp > z2->io_queued_timestamp)
return (1);
 
-   if (z1->io_offset < z2->io_offset)
+   if (z1->io_bookmark.zb_objset < z2->io_bookmark.zb_objset)
return (-1);
-   if (z1->io_offset > z2->io_offset)
+   if (z1->io_bookmark.zb_objset > z2->io_bookmark.zb_objset)
+   return (1);
+
+   if (z1->io_bookmark.zb_object < z2->io_bookmark.zb_object)
+   return (-1);
+   if (z1->io_bookmark.zb_object > z2->io_bookmark.zb_object)
+   return (1);
+
+   if (z1->io_bookmark.zb_level < z2->io_bookmark.zb_level)
+   return (-1);
+   if (z1->io_bookmark.zb_level > z2->io_bookmark.zb_level)
+   return (1);
+
+   if (z1->io_bookmark.zb_blkid < z2->io_bookmark.zb_blkid)
+   return (-1);
+   if (z1->io_bookmark.zb_blkid > z2->io_bookmark.zb_blkid)
return (1);
 
if (z1 < z2)
___
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: r309658 - head/sys/vm

2016-12-08 Thread John Baldwin
On Wednesday, December 07, 2016 02:15:49 PM Mark Johnston wrote:
> On Wed, Dec 07, 2016 at 01:26:47PM -0800, Gleb Smirnoff wrote:
> > On Tue, Dec 06, 2016 at 10:52:45PM +, Mark Johnston wrote:
> > M> Author: markj
> > M> Date: Tue Dec  6 22:52:45 2016
> > M> New Revision: 309658
> > M> URL: https://svnweb.freebsd.org/changeset/base/309658
> > M> 
> > M> Log:
> > M>   Provide dummy sysctls for v_cache_count and v_tcached.
> > M>   
> > M>   Some utilities (notably top(1)) exit if any of their input sysctls 
> > don't
> > M>   exist, and the removal of the above-mentioned PG_CACHE-related sysctls
> > M>   makes it difficult to run such utilities on different versions of the
> > M>   kernel without recompiling.
> > M>   
> > M>   Requested by:  bde
> > M> 
> > M> Modified:
> > M>   head/sys/vm/vm_meter.c
> > M> 
> > M> Modified: head/sys/vm/vm_meter.c
> > M> 
> > ==
> > M> --- head/sys/vm/vm_meter.c   Tue Dec  6 22:48:28 2016
> > (r309657)
> > M> +++ head/sys/vm/vm_meter.c   Tue Dec  6 22:52:45 2016
> > (r309658)
> > M> @@ -314,3 +314,14 @@ VM_STATS_VM(v_forkpages, "VM pages affec
> > M>  VM_STATS_VM(v_vforkpages, "VM pages affected by vfork()");
> > M>  VM_STATS_VM(v_rforkpages, "VM pages affected by rfork()");
> > M>  VM_STATS_VM(v_kthreadpages, "VM pages affected by fork() by kernel");
> > M> +
> > M> +#ifndef BURN_BRIDGES
> > M> +/*
> > M> + * Provide compatibility sysctls for the benefit of old utilities which 
> > exit
> > M> + * with an error if they cannot be found.
> > M> + */
> > M> +SYSCTL_UINT(_vm_stats_vm, OID_AUTO, v_cache_count, CTLFLAG_RD,
> > M> +(u_int *)NULL, 0, "Dummy for compatibility");
> > M> +SYSCTL_UINT(_vm_stats_vm, OID_AUTO, v_tcached, CTLFLAG_RD,
> > M> +(u_int *)NULL, 0, "Dummy for compatibility");
> > M> +#endif
> > 
> > IMHO, there should be some garbage collecting timeout for them. I'd suggest 
> > to
> > delete them from head after stable/12 branch is forked.
> 
> The intent was to improve compatibility with old userlands, not just to
> help bridge the transition from 11.0 to 12.0. In general I'm all for
> removing cruft, but these sysctls are unobtrusive and I don't see any
> reason to remove them in a specific time frame provided that nothing
> else breaks compatibility for top(1) (and vmstat(8)). Please feel free
> to add a timeout if you still disagree, though.

I would suggest sticking them under COMPAT_FREEBSD11 then.  That would give
users control via the COMPAT_FREEBSD options the way we do with other
compat shims.  The only nit is you need to add the COMPAT_FREEBSD11 option
first (probably in a separate commit).

-- 
John Baldwin
___
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: r309703 - in head/sys: amd64/amd64 arm64/arm64 i386/i386 vm

2016-12-08 Thread Slawa Olhovchenkov
On Thu, Dec 08, 2016 at 04:29:29AM +, Alan Cox wrote:

> Author: alc
> Date: Thu Dec  8 04:29:29 2016
> New Revision: 309703
> URL: https://svnweb.freebsd.org/changeset/base/309703
> 
> Log:
>   Previously, vm_radix_remove() would panic if the radix trie didn't
>   contain a vm_page_t at the specified index.  However, with this
>   change, vm_radix_remove() no longer panics.  Instead, it returns NULL
>   if there is no vm_page_t at the specified index.  Otherwise, it
>   returns the vm_page_t.  The motivation for this change is that it
>   simplifies the use of radix tries in the amd64, arm64, and i386 pmap
>   implementations.  Instead of performing a lookup before every remove,
>   the pmap can simply perform the remove.

Is this performance improvement?
___
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: r309712 - head/sys/dev/drm2/i915

2016-12-08 Thread Konstantin Belousov
Author: kib
Date: Thu Dec  8 11:39:08 2016
New Revision: 309712
URL: https://svnweb.freebsd.org/changeset/base/309712

Log:
  Use the populate() driver paging method for i915 driver.
  
  In particular, the fault access type is accounted for when the
  aperture page is moved to GTT domain.  On the other hand, the current
  pager structure is left intact, most important, only one page is
  instantiated per populate call.
  
  Reviewed by:  alc
  Sponsored by: The FreeBSD Foundation
  MFC after:3 weeks

Modified:
  head/sys/dev/drm2/i915/i915_gem.c

Modified: head/sys/dev/drm2/i915/i915_gem.c
==
--- head/sys/dev/drm2/i915/i915_gem.c   Thu Dec  8 11:35:53 2016
(r309711)
+++ head/sys/dev/drm2/i915/i915_gem.c   Thu Dec  8 11:39:08 2016
(r309712)
@@ -1474,8 +1474,8 @@ i915_gem_pager_ctor(void *handle, vm_oof
 int i915_intr_pf;
 
 static int
-i915_gem_pager_fault(vm_object_t vm_obj, vm_ooffset_t offset, int prot,
-vm_page_t *mres)
+i915_gem_pager_populate(vm_object_t vm_obj, vm_pindex_t pidx, int fault_type,
+vm_prot_t max_prot, vm_pindex_t *first, vm_pindex_t *last)
 {
struct drm_gem_object *gem_obj = vm_obj->handle;
struct drm_i915_gem_object *obj = to_intel_bo(gem_obj);
@@ -1483,31 +1483,9 @@ i915_gem_pager_fault(vm_object_t vm_obj,
drm_i915_private_t *dev_priv = dev->dev_private;
vm_page_t page;
int ret = 0;
-#ifdef FREEBSD_WIP
-   bool write = (prot & VM_PROT_WRITE) != 0;
-#else
-   bool write = true;
-#endif /* FREEBSD_WIP */
+   bool write = (max_prot & VM_PROT_WRITE) != 0;
bool pinned;
 
-   vm_object_pip_add(vm_obj, 1);
-
-   /*
-* Remove the placeholder page inserted by vm_fault() from the
-* object before dropping the object lock. If
-* i915_gem_release_mmap() is active in parallel on this gem
-* object, then it owns the drm device sx and might find the
-* placeholder already. Then, since the page is busy,
-* i915_gem_release_mmap() sleeps waiting for the busy state
-* of the page cleared. We will be unable to acquire drm
-* device lock until i915_gem_release_mmap() is able to make a
-* progress.
-*/
-   if (*mres != NULL) {
-   vm_page_lock(*mres);
-   vm_page_remove(*mres);
-   vm_page_unlock(*mres);
-   }
VM_OBJECT_WUNLOCK(vm_obj);
 retry:
ret = 0;
@@ -1527,7 +1505,7 @@ retry:
 * mapping for the page.  Recheck.
 */
VM_OBJECT_WLOCK(vm_obj);
-   page = vm_page_lookup(vm_obj, OFF_TO_IDX(offset));
+   page = vm_page_lookup(vm_obj, pidx);
if (page != NULL) {
if (vm_page_busied(page)) {
DRM_UNLOCK(dev);
@@ -1543,7 +1521,7 @@ retry:
/* Now bind it into the GTT if needed */
ret = i915_gem_object_pin(obj, 0, true, false);
if (ret)
-   goto unlock;
+   goto unpin;
pinned = 1;
 
ret = i915_gem_object_set_to_gtt_domain(obj, write);
@@ -1556,20 +1534,19 @@ retry:
 
obj->fault_mappable = true;
 
-   VM_OBJECT_WLOCK(vm_obj);
-   page = PHYS_TO_VM_PAGE(dev_priv->mm.gtt_base_addr + obj->gtt_offset + 
offset);
-   KASSERT((page->flags & PG_FICTITIOUS) != 0,
-   ("physical address %#jx not fictitious",
-   (uintmax_t)(dev_priv->mm.gtt_base_addr + obj->gtt_offset + 
offset)));
+   page = PHYS_TO_VM_PAGE(dev_priv->mm.gtt_base_addr + obj->gtt_offset +
+   IDX_TO_OFF(pidx));
if (page == NULL) {
-   VM_OBJECT_WUNLOCK(vm_obj);
ret = -EFAULT;
goto unpin;
}
KASSERT((page->flags & PG_FICTITIOUS) != 0,
-   ("not fictitious %p", page));
+   ("physical address %#jx not fictitious, page %p",
+   (uintmax_t)(dev_priv->mm.gtt_base_addr + obj->gtt_offset +
+   IDX_TO_OFF(pidx)), page));
KASSERT(page->wire_count == 1, ("wire_count not 1 %p", page));
 
+   VM_OBJECT_WLOCK(vm_obj);
if (vm_page_busied(page)) {
i915_gem_object_unpin(obj);
DRM_UNLOCK(dev);
@@ -1578,7 +1555,7 @@ retry:
vm_page_busy_sleep(page, "915pbs", false);
goto retry;
}
-   if (vm_page_insert(page, vm_obj, OFF_TO_IDX(offset))) {
+   if (vm_page_insert(page, vm_obj, pidx)) {
i915_gem_object_unpin(obj);
DRM_UNLOCK(dev);
VM_OBJECT_WUNLOCK(vm_obj);
@@ -1589,33 +1566,24 @@ retry:
 have_page:
vm_page_xbusy(page);
 
-   CTR4(KTR_DRM, "fault %p %jx %x phys %x", gem_obj, offset, prot,
+   CTR4(KTR_DRM, "fault %p %jx %x phys %x", gem_obj, pidx, fault_type,
page->phys_addr);
if (pinned) {
/*
 * We may have not pinned the object if the page was
-* found by the 

svn commit: r309711 - head/sys/vm

2016-12-08 Thread Konstantin Belousov
Author: kib
Date: Thu Dec  8 11:35:53 2016
New Revision: 309711
URL: https://svnweb.freebsd.org/changeset/base/309711

Log:
  Implement the populate() pager method for phys pager.
  
  It allows to provide configurable agressive prefaulting and useful
  hints to page daemon about memory allocations, on faults for pages
  managed by phys pager.  In fact, this implementation is superior to
  the MAP_SHARED_PHYS hack from my Postgresql paper, while giving
  similar benefits of reducing the page faults numbers on SysV shared
  memory mappings.
  
  Reviewed by:  alc
  Tested by:pho
  Sponsored by: The FreeBSD Foundation
  MFC after:3 weeks

Modified:
  head/sys/vm/phys_pager.c

Modified: head/sys/vm/phys_pager.c
==
--- head/sys/vm/phys_pager.cThu Dec  8 11:26:11 2016(r309710)
+++ head/sys/vm/phys_pager.cThu Dec  8 11:35:53 2016(r309711)
@@ -41,6 +41,7 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
+#include 
 #include 
 
 /* list of phys pager objects */
@@ -98,6 +99,7 @@ phys_pager_alloc(void *handle, vm_ooffse
object = object1;
object1 = NULL;
object->handle = handle;
+   vm_object_set_flag(object, OBJ_POPULATE);
TAILQ_INSERT_TAIL(_pager_object_list,
object, pager_object_list);
}
@@ -109,6 +111,7 @@ phys_pager_alloc(void *handle, vm_ooffse
vm_object_deallocate(object1);
} else {
object = vm_object_allocate(OBJT_PHYS, pindex);
+   vm_object_set_flag(object, OBJ_POPULATE);
}
 
return (object);
@@ -157,32 +160,101 @@ phys_pager_getpages(vm_object_t object, 
return (VM_PAGER_OK);
 }
 
-static void
-phys_pager_putpages(vm_object_t object, vm_page_t *m, int count, boolean_t 
sync,
-int *rtvals)
-{
-
-   panic("phys_pager_putpage called");
-}
-
 /*
  * Implement a pretty aggressive clustered getpages strategy.  Hint that
  * everything in an entire 4MB window should be prefaulted at once.
  *
- * XXX 4MB (1024 slots per page table page) is convenient for x86,
+ * 4MB (1024 slots per page table page) is convenient for x86,
  * but may not be for other arches.
  */
 #ifndef PHYSCLUSTER
 #define PHYSCLUSTER 1024
 #endif
+static int phys_pager_cluster = PHYSCLUSTER;
+SYSCTL_INT(_vm, OID_AUTO, phys_pager_cluster, CTLFLAG_RWTUN,
+_pager_cluster, 0,
+"prefault window size for phys pager");
+
+/*
+ * Max hint to vm_page_alloc() about the further allocation needs
+ * inside the phys_pager_populate() loop.  The number of bits used to
+ * implement VM_ALLOC_COUNT() determines the hard limit on this value.
+ * That limit is currently 65535.
+ */
+#definePHYSALLOC   16
+
+static int
+phys_pager_populate(vm_object_t object, vm_pindex_t pidx,
+int fault_type __unused, vm_prot_t max_prot __unused, vm_pindex_t *first,
+vm_pindex_t *last)
+{
+   vm_page_t m;
+   vm_pindex_t base, end, i;
+   int ahead;
+
+   base = rounddown(pidx, phys_pager_cluster);
+   end = base + phys_pager_cluster - 1;
+   if (end >= object->size)
+   end = object->size - 1;
+   if (*first > base)
+   base = *first;
+   if (end > *last)
+   end = *last;
+   *first = base;
+   *last = end;
+
+   for (i = base; i <= end; i++) {
+retry:
+   m = vm_page_lookup(object, i);
+   if (m == NULL) {
+   ahead = MIN(end - i, PHYSALLOC);
+   m = vm_page_alloc(object, i, VM_ALLOC_NORMAL |
+   VM_ALLOC_ZERO | VM_ALLOC_COUNT(ahead));
+   if (m == NULL) {
+   VM_OBJECT_WUNLOCK(object);
+   VM_WAIT;
+   VM_OBJECT_WLOCK(object);
+   goto retry;
+   }
+   if ((m->flags & PG_ZERO) == 0)
+   pmap_zero_page(m);
+   m->valid = VM_PAGE_BITS_ALL;
+   } else if (vm_page_xbusied(m)) {
+   vm_page_lock(m);
+   VM_OBJECT_WUNLOCK(object);
+   vm_page_busy_sleep(m, "physb", true);
+   VM_OBJECT_WLOCK(object);
+   goto retry;
+   } else {
+   vm_page_xbusy(m);
+   if (m->valid != VM_PAGE_BITS_ALL)
+   vm_page_zero_invalid(m, TRUE);
+   }
+
+   KASSERT(m->valid == VM_PAGE_BITS_ALL,
+   ("phys_pager_populate: partially valid page %p", m));
+   KASSERT(m->dirty == 0,
+   ("phys_pager_populate: dirty page %p", m));
+ 

svn commit: r309710 - head/sys/vm

2016-12-08 Thread Konstantin Belousov
Author: kib
Date: Thu Dec  8 11:26:11 2016
New Revision: 309710
URL: https://svnweb.freebsd.org/changeset/base/309710

Log:
  Add a new populate() pager method and extend device pager ops vector
  with cdev_pg_populate() to provide device drivers access to it.  It
  gives drivers fine control of the pages ownership and allows drivers
  to implement arbitrary prefault policies.
  
  The populate method is called on a page fault and is supposed to
  populate the vm object with the page at the fault location and some
  amount of pages around it, at pager's discretion.  VM provides the
  pager with the hints about current range of the object mapping, to
  avoid instantiation of immediately unused pages, if pager decides so.
  Also, VM passes the fault type and map entry protection to the pager,
  allowing it to force the optimal required ownership of the mapped
  pages.
  
  Installed pages must contiguously fill the returned region, be fully
  valid and exclusively busied.  Of course, the pages must be compatible
  with the object' type.
  
  After populate() successfully returned, VM fault handler installs as
  many instantiated pages into the process page tables as it sees
  reasonable, while still obeying the correct semantic for COW and vm
  map locking.
  
  The method is opt-in, pager sets OBJ_POPULATE flag to indicate that
  the method can be called.  If pager' vm objects can be shadowed, pager
  must implement the traditional getpages() method in addition to the
  populate().  Populate() might fall back to the getpages() on per-call
  basis as well, by returning VM_PAGER_BAD error code.
  
  For now for device pagers, the populate() method is only allowed to be
  used by the managed device pagers, but the limitation is only made
  because there is no unmanaged fault handlers which could use it right
  now.
  
  KPI designed together with, and reviewed by:  alc
  Tested by:pho
  Sponsored by: The FreeBSD Foundation
  MFC after:3 weeks

Modified:
  head/sys/vm/device_pager.c
  head/sys/vm/vm_fault.c
  head/sys/vm/vm_object.h
  head/sys/vm/vm_pager.h

Modified: head/sys/vm/device_pager.c
==
--- head/sys/vm/device_pager.c  Thu Dec  8 10:29:41 2016(r309709)
+++ head/sys/vm/device_pager.c  Thu Dec  8 11:26:11 2016(r309710)
@@ -63,6 +63,8 @@ static int dev_pager_getpages(vm_object_
 static void dev_pager_putpages(vm_object_t, vm_page_t *, int, int, int *);
 static boolean_t dev_pager_haspage(vm_object_t, vm_pindex_t, int *, int *);
 static void dev_pager_free_page(vm_object_t object, vm_page_t m);
+static int dev_pager_populate(vm_object_t object, vm_pindex_t pidx,
+int fault_type, vm_prot_t, vm_pindex_t *first, vm_pindex_t *last);
 
 /* list of device pager objects */
 static struct pagerlst dev_pager_object_list;
@@ -84,6 +86,7 @@ struct pagerops mgtdevicepagerops = {
.pgo_getpages = dev_pager_getpages,
.pgo_putpages = dev_pager_putpages,
.pgo_haspage =  dev_pager_haspage,
+   .pgo_populate = dev_pager_populate,
 };
 
 static int old_dev_pager_ctor(void *handle, vm_ooffset_t size, vm_prot_t prot,
@@ -127,6 +130,8 @@ cdev_pager_allocate(void *handle, enum o
 
if (tp != OBJT_DEVICE && tp != OBJT_MGTDEVICE)
return (NULL);
+   KASSERT(tp == OBJT_MGTDEVICE || ops->cdev_pg_populate == NULL,
+   ("populate on unmanaged device pager"));
 
/*
 * Offset should be page aligned.
@@ -179,6 +184,8 @@ cdev_pager_allocate(void *handle, enum o
object->handle = handle;
TAILQ_INSERT_TAIL(_pager_object_list, object,
pager_object_list);
+   if (ops->cdev_pg_populate != NULL)
+   vm_object_set_flag(object, OBJ_POPULATE);
}
} else {
if (pindex > object->size)
@@ -268,6 +275,8 @@ dev_pager_getpages(vm_object_t object, v
/* Since our haspage reports zero after/before, the count is 1. */
KASSERT(count == 1, ("%s: count %d", __func__, count));
VM_OBJECT_ASSERT_WLOCKED(object);
+   if (object->un_pager.devp.ops->cdev_pg_fault == NULL)
+   return (VM_PAGER_FAIL);
error = object->un_pager.devp.ops->cdev_pg_fault(object,
IDX_TO_OFF(ma[0]->pindex), PROT_READ, [0]);
 
@@ -293,6 +302,18 @@ dev_pager_getpages(vm_object_t object, v
 }
 
 static int
+dev_pager_populate(vm_object_t object, vm_pindex_t pidx, int fault_type,
+vm_prot_t max_prot, vm_pindex_t *first, vm_pindex_t *last)
+{
+
+   VM_OBJECT_ASSERT_WLOCKED(object);
+   if (object->un_pager.devp.ops->cdev_pg_populate == NULL)
+   return (VM_PAGER_FAIL);
+   return (object->un_pager.devp.ops->cdev_pg_populate(object, pidx,
+   fault_type, max_prot, first, last));
+}
+
+static int
 old_dev_pager_fault(vm_object_t object, vm_ooffset_t offset, int prot,

svn commit: r309709 - head/sys/vm

2016-12-08 Thread Konstantin Belousov
Author: kib
Date: Thu Dec  8 10:29:41 2016
New Revision: 309709
URL: https://svnweb.freebsd.org/changeset/base/309709

Log:
  Move map_generation snapshot value into struct faultstate.
  
  Reviewed by:  alc
  Tested by:pho
  Sponsored by: The FreeBSD Foundation
  MFC after:1 week

Modified:
  head/sys/vm/vm_fault.c

Modified: head/sys/vm/vm_fault.c
==
--- head/sys/vm/vm_fault.c  Thu Dec  8 10:28:51 2016(r309708)
+++ head/sys/vm/vm_fault.c  Thu Dec  8 10:29:41 2016(r309709)
@@ -122,6 +122,7 @@ struct faultstate {
vm_pindex_t first_pindex;
vm_map_t map;
vm_map_entry_t entry;
+   int map_generation;
bool lookup_still_valid;
struct vnode *vp;
 };
@@ -339,7 +340,7 @@ vm_fault_hold(vm_map_t map, vm_offset_t 
vm_pindex_t retry_pindex;
vm_prot_t prot, retry_prot;
int ahead, alloc_req, behind, cluster_offset, error, era, faultcount;
-   int locked, map_generation, nera, result, rv;
+   int locked, nera, result, rv;
u_char behavior;
boolean_t wired;/* Passed by reference. */
bool dead, growstack, hardfault, is_first_object_locked;
@@ -373,7 +374,7 @@ RetryFault:;
return (result);
}
 
-   map_generation = fs.map->timestamp;
+   fs.map_generation = fs.map->timestamp;
 
if (fs.entry->eflags & MAP_ENTRY_NOFAULT) {
panic("vm_fault: fault on nofault entry, addr: %lx",
@@ -972,7 +973,7 @@ readrest:
goto RetryFault;
}
fs.lookup_still_valid = true;
-   if (fs.map->timestamp != map_generation) {
+   if (fs.map->timestamp != fs.map_generation) {
result = vm_map_lookup_locked(, vaddr, 
fault_type,
, _object, _pindex, 
_prot, );
 
___
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: r309708 - head/sys/vm

2016-12-08 Thread Konstantin Belousov
Author: kib
Date: Thu Dec  8 10:28:51 2016
New Revision: 309708
URL: https://svnweb.freebsd.org/changeset/base/309708

Log:
  Style.
  
  Reviewed by:  alc
  Sponsored by: The FreeBSD Foundation
  MFC after:1 week

Modified:
  head/sys/vm/phys_pager.c

Modified: head/sys/vm/phys_pager.c
==
--- head/sys/vm/phys_pager.cThu Dec  8 07:57:16 2016(r309707)
+++ head/sys/vm/phys_pager.cThu Dec  8 10:28:51 2016(r309708)
@@ -56,9 +56,6 @@ phys_pager_init(void)
mtx_init(_pager_mtx, "phys_pager list", NULL, MTX_DEF);
 }
 
-/*
- * MPSAFE
- */
 static vm_object_t
 phys_pager_alloc(void *handle, vm_ooffset_t size, vm_prot_t prot,
 vm_ooffset_t foff, struct ucred *cred)
@@ -101,8 +98,8 @@ phys_pager_alloc(void *handle, vm_ooffse
object = object1;
object1 = NULL;
object->handle = handle;
-   TAILQ_INSERT_TAIL(_pager_object_list, 
object,
-   pager_object_list);
+   TAILQ_INSERT_TAIL(_pager_object_list,
+   object, pager_object_list);
}
} else {
if (pindex > object->size)
@@ -117,9 +114,6 @@ phys_pager_alloc(void *handle, vm_ooffse
return (object);
 }
 
-/*
- * MPSAFE
- */
 static void
 phys_pager_dealloc(vm_object_t object)
 {
@@ -165,7 +159,7 @@ phys_pager_getpages(vm_object_t object, 
 
 static void
 phys_pager_putpages(vm_object_t object, vm_page_t *m, int count, boolean_t 
sync,
-   int *rtvals)
+int *rtvals)
 {
 
panic("phys_pager_putpage called");
@@ -183,7 +177,7 @@ phys_pager_putpages(vm_object_t object, 
 #endif
 static boolean_t
 phys_pager_haspage(vm_object_t object, vm_pindex_t pindex, int *before,
-  int *after)
+int *after)
 {
vm_pindex_t base, end;
 
___
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"