svn commit: r290323 - stable/10/sys/kern

2015-11-03 Thread Konstantin Belousov
Author: kib
Date: Tue Nov  3 08:28:47 2015
New Revision: 290323
URL: https://svnweb.freebsd.org/changeset/base/290323

Log:
  MFC r289658:
  No need to dereference struct proc to pids when comparing processes
  for equality.

Modified:
  stable/10/sys/kern/sys_process.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/kern/sys_process.c
==
--- stable/10/sys/kern/sys_process.cTue Nov  3 05:25:06 2015
(r290322)
+++ stable/10/sys/kern/sys_process.cTue Nov  3 08:28:47 2015
(r290323)
@@ -748,7 +748,7 @@ kern_ptrace(struct thread *td, int req, 
 
case PT_ATTACH:
/* Self */
-   if (p->p_pid == td->td_proc->p_pid) {
+   if (p == td->td_proc) {
error = EINVAL;
goto fail;
}
___
svn-src-stable-10@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-10
To unsubscribe, send any mail to "svn-src-stable-10-unsubscr...@freebsd.org"


svn commit: r290331 - stable/10/sys/dev/usb/controller

2015-11-03 Thread Hans Petter Selasky
Author: hselasky
Date: Tue Nov  3 10:24:54 2015
New Revision: 290331
URL: https://svnweb.freebsd.org/changeset/base/290331

Log:
  MFC r285914, r289029 and r289560:
  - Move the remainder of host controller capability registers reading from
xhci_start_controller() to xhci_init(). These values don't change at run-
time so there's no point of acquiring them on every USB_HW_POWER_RESUME
instead of only once during initialization. In r276717, reading the first
couple of registers in question already had been moved as a prerequisite
for the changes in that revision.
  - Identify ASMedia ASM1042A controllers.
  - Use NULL instead of 0 for pointers.
  - Add quirks for USB 3.0 PCI devices.
  
  PR:   203650

Modified:
  stable/10/sys/dev/usb/controller/xhci.c
  stable/10/sys/dev/usb/controller/xhci_pci.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/dev/usb/controller/xhci.c
==
--- stable/10/sys/dev/usb/controller/xhci.c Tue Nov  3 10:21:53 2015
(r290330)
+++ stable/10/sys/dev/usb/controller/xhci.c Tue Nov  3 10:24:54 2015
(r290331)
@@ -380,54 +380,12 @@ xhci_start_controller(struct xhci_softc 
return (USB_ERR_IOERROR);
}
 
-   if (!(XREAD4(sc, oper, XHCI_PAGESIZE) & XHCI_PAGESIZE_4K)) {
-   device_printf(sc->sc_bus.parent, "Controller does "
-   "not support 4K page size.\n");
-   return (USB_ERR_IOERROR);
-   }
-
-   temp = XREAD4(sc, capa, XHCI_HCSPARAMS1);
-
-   i = XHCI_HCS1_N_PORTS(temp);
-
-   if (i == 0) {
-   device_printf(sc->sc_bus.parent, "Invalid number "
-   "of ports: %u\n", i);
-   return (USB_ERR_IOERROR);
-   }
-
-   sc->sc_noport = i;
-   sc->sc_noslot = XHCI_HCS1_DEVSLOT_MAX(temp);
-
-   if (sc->sc_noslot > XHCI_MAX_DEVICES)
-   sc->sc_noslot = XHCI_MAX_DEVICES;
-
/* set up number of device slots */
-
DPRINTF("CONFIG=0x%08x -> 0x%08x\n",
XREAD4(sc, oper, XHCI_CONFIG), sc->sc_noslot);
 
XWRITE4(sc, oper, XHCI_CONFIG, sc->sc_noslot);
 
-   DPRINTF("Max slots: %u\n", sc->sc_noslot);
-
-   temp = XREAD4(sc, capa, XHCI_HCSPARAMS2);
-
-   sc->sc_noscratch = XHCI_HCS2_SPB_MAX(temp);
-
-   if (sc->sc_noscratch > XHCI_MAX_SCRATCHPADS) {
-   device_printf(sc->sc_bus.parent, "XHCI request "
-   "too many scratchpads\n");
-   return (USB_ERR_NOMEM);
-   }
-
-   DPRINTF("Max scratch: %u\n", sc->sc_noscratch);
-
-   temp = XREAD4(sc, capa, XHCI_HCSPARAMS3);
-
-   sc->sc_exit_lat_max = XHCI_HCS3_U1_DEL(temp) +
-   XHCI_HCS3_U2_DEL(temp) + 250 /* us */;
-
temp = XREAD4(sc, oper, XHCI_USBSTS);
 
/* clear interrupts */
@@ -459,29 +417,13 @@ xhci_start_controller(struct xhci_softc 
XWRITE4(sc, oper, XHCI_DCBAAP_LO, (uint32_t)addr);
XWRITE4(sc, oper, XHCI_DCBAAP_HI, (uint32_t)(addr >> 32));
 
-   /* Setup event table size */
-
-   temp = XREAD4(sc, capa, XHCI_HCSPARAMS2);
-
-   DPRINTF("HCS2=0x%08x\n", temp);
-
-   temp = XHCI_HCS2_ERST_MAX(temp);
-   temp = 1U << temp;
-   if (temp > XHCI_MAX_RSEG)
-   temp = XHCI_MAX_RSEG;
-
-   sc->sc_erst_max = temp;
-
+   /* set up event table size */
DPRINTF("ERSTSZ=0x%08x -> 0x%08x\n",
-   XREAD4(sc, runt, XHCI_ERSTSZ(0)), temp);
+   XREAD4(sc, runt, XHCI_ERSTSZ(0)), sc->sc_erst_max);
 
-   XWRITE4(sc, runt, XHCI_ERSTSZ(0), XHCI_ERSTS_SET(temp));
+   XWRITE4(sc, runt, XHCI_ERSTSZ(0), XHCI_ERSTS_SET(sc->sc_erst_max));
 
-   /* Check if we should use the default IMOD value */
-   if (sc->sc_imod_default == 0)
-   sc->sc_imod_default = XHCI_IMOD_DEFAULT;
-
-   /* Setup interrupt rate */
+   /* set up interrupt rate */
XWRITE4(sc, runt, XHCI_IMOD(0), sc->sc_imod_default);
 
usbd_get_page(>sc_hw.root_pc, 0, _res);
@@ -508,8 +450,7 @@ xhci_start_controller(struct xhci_softc 
XWRITE4(sc, runt, XHCI_ERSTBA_LO(0), (uint32_t)addr);
XWRITE4(sc, runt, XHCI_ERSTBA_HI(0), (uint32_t)(addr >> 32));
 
-   /* Setup interrupter registers */
-
+   /* set up interrupter registers */
temp = XREAD4(sc, runt, XHCI_IMAN(0));
temp |= XHCI_IMAN_INTR_ENA;
XWRITE4(sc, runt, XHCI_IMAN(0), temp);
@@ -620,6 +561,12 @@ xhci_init(struct xhci_softc *sc, device_
 
DPRINTF("xHCI version = 0x%04x\n", XREAD2(sc, capa, XHCI_HCIVERSION));
 
+   if (!(XREAD4(sc, oper, XHCI_PAGESIZE) & XHCI_PAGESIZE_4K)) {
+   device_printf(sc->sc_bus.parent, "Controller does "
+   "not support 4K page size.\n");
+   return (ENXIO);
+   }
+
temp = XREAD4(sc, capa, XHCI_HCSPARAMS0);
 
DPRINTF("HCS0 = 0x%08x\n", temp);
@@ -638,6 +585,55 @@ 

svn commit: r290348 - stable/10/sys/netinet6

2015-11-03 Thread Hiroki Sato
Author: hrs
Date: Wed Nov  4 01:00:42 2015
New Revision: 290348
URL: https://svnweb.freebsd.org/changeset/base/290348

Log:
  MFC r288600:
  
- Schedule DAD for IN6_IFF_TENTATIVE addresses in nd6_timer().  This
  catches cases that DAD probes cannot be sent because of
  IFF_UP && !IFF_DRV_RUNNING.
  
- nd6_dad_starttimer() now calls nd6_dad_ns_output(), instead of
  calling it before nd6_dad_starttimer().
  
- Do not release an entry in dadq when a duplicate entry is being
  added.

Modified:
  stable/10/sys/netinet6/nd6.c
  stable/10/sys/netinet6/nd6_nbr.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/netinet6/nd6.c
==
--- stable/10/sys/netinet6/nd6.cWed Nov  4 00:21:02 2015
(r290347)
+++ stable/10/sys/netinet6/nd6.cWed Nov  4 01:00:42 2015
(r290348)
@@ -687,8 +687,31 @@ nd6_timer(void *arg)
goto addrloop;
}
}
+   } else if ((ia6->ia6_flags & IN6_IFF_TENTATIVE) != 0) {
+   /*
+* Schedule DAD for a tentative address.  This happens
+* if the interface was down or not running
+* when the address was configured.
+*/
+   int delay;
+
+   delay = arc4random() %
+   (MAX_RTR_SOLICITATION_DELAY * hz);
+   nd6_dad_start((struct ifaddr *)ia6, delay);
} else {
/*
+* Check status of the interface.  If it is down,
+* mark the address as tentative for future DAD.
+*/
+   if ((ia6->ia_ifp->if_flags & IFF_UP) == 0 ||
+   (ia6->ia_ifp->if_drv_flags & IFF_DRV_RUNNING)
+   == 0 ||
+   (ND_IFINFO(ia6->ia_ifp)->flags &
+   ND6_IFF_IFDISABLED) != 0) {
+   ia6->ia6_flags &= ~IN6_IFF_DUPLICATED;
+   ia6->ia6_flags |= IN6_IFF_TENTATIVE;
+   }
+   /*
 * A new RA might have made a deprecated address
 * preferred.
 */
@@ -1341,7 +1364,8 @@ nd6_ioctl(u_long cmd, caddr_t data, stru
/* Mark all IPv6 address as tentative. */
 
ND_IFINFO(ifp)->flags |= ND6_IFF_IFDISABLED;
-   if ((ND_IFINFO(ifp)->flags & ND6_IFF_NO_DAD) == 0) {
+   if (V_ip6_dad_count > 0 &&
+   (ND_IFINFO(ifp)->flags & ND6_IFF_NO_DAD) == 0) {
IF_ADDR_RLOCK(ifp);
TAILQ_FOREACH(ifa, >if_addrhead,
ifa_link) {

Modified: stable/10/sys/netinet6/nd6_nbr.c
==
--- stable/10/sys/netinet6/nd6_nbr.cWed Nov  4 00:21:02 2015
(r290347)
+++ stable/10/sys/netinet6/nd6_nbr.cWed Nov  4 01:00:42 2015
(r290348)
@@ -86,11 +86,11 @@ static struct dadq *nd6_dad_find(struct 
 static void nd6_dad_add(struct dadq *dp);
 static void nd6_dad_del(struct dadq *dp);
 static void nd6_dad_rele(struct dadq *);
-static void nd6_dad_starttimer(struct dadq *, int);
+static void nd6_dad_starttimer(struct dadq *, int, int);
 static void nd6_dad_stoptimer(struct dadq *);
 static void nd6_dad_timer(struct dadq *);
 static void nd6_dad_duplicated(struct ifaddr *, struct dadq *);
-static void nd6_dad_ns_output(struct dadq *, struct ifaddr *);
+static void nd6_dad_ns_output(struct dadq *);
 static void nd6_dad_ns_input(struct ifaddr *, struct nd_opt_nonce *);
 static void nd6_dad_na_input(struct ifaddr *);
 static void nd6_na_output_fib(struct ifnet *, const struct in6_addr *,
@@ -1242,9 +1242,11 @@ nd6_dad_find(struct ifaddr *ifa, struct 
 }
 
 static void
-nd6_dad_starttimer(struct dadq *dp, int ticks)
+nd6_dad_starttimer(struct dadq *dp, int ticks, int send_ns)
 {
 
+   if (send_ns != 0)
+   nd6_dad_ns_output(dp);
callout_reset(>dad_timer_ch, ticks,
(void (*)(void *))nd6_dad_timer, (void *)dp);
 }
@@ -1283,6 +1285,7 @@ nd6_dad_start(struct ifaddr *ifa, int de
struct in6_ifaddr *ia = (struct in6_ifaddr *)ifa;
struct dadq *dp;
char ip6buf[INET6_ADDRSTRLEN];
+   int send_ns;
 
/*
 * If we don't need DAD, don't do it.
@@ -1319,8 +1322,10 @@ nd6_dad_start(struct ifaddr *ifa, int de
return;
}
if ((dp = nd6_dad_find(ifa, NULL)) != NULL) {
-   /* DAD already in progress */
-   nd6_dad_rele(dp);
+   /*
+ 

svn commit: r290347 - stable/10/sys/net

2015-11-03 Thread Hiroki Sato
Author: hrs
Date: Wed Nov  4 00:21:02 2015
New Revision: 290347
URL: https://svnweb.freebsd.org/changeset/base/290347

Log:
  MFC r288575:
  
   Add IFCAP_LINKSTATE support.

Modified:
  stable/10/sys/net/if_gif.c
  stable/10/sys/net/if_gre.c
  stable/10/sys/net/if_me.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/net/if_gif.c
==
--- stable/10/sys/net/if_gif.c  Tue Nov  3 22:24:02 2015(r290346)
+++ stable/10/sys/net/if_gif.c  Wed Nov  4 00:21:02 2015(r290347)
@@ -196,6 +196,8 @@ gif_clone_create(struct if_clone *ifc, i
GIF2IFP(sc)->if_transmit  = gif_transmit;
GIF2IFP(sc)->if_qflush  = gif_qflush;
GIF2IFP(sc)->if_output = gif_output;
+   GIF2IFP(sc)->if_capabilities |= IFCAP_LINKSTATE;
+   GIF2IFP(sc)->if_capenable |= IFCAP_LINKSTATE;
if_attach(GIF2IFP(sc));
bpfattach(GIF2IFP(sc), DLT_NULL, sizeof(u_int32_t));
if (ng_gif_attach_p != NULL)
@@ -1038,10 +1040,13 @@ gif_set_tunnel(struct ifnet *ifp, struct
 #if defined(INET) || defined(INET6)
 bad:
 #endif
-   if (error == 0 && sc->gif_family != 0)
+   if (error == 0 && sc->gif_family != 0) {
ifp->if_drv_flags |= IFF_DRV_RUNNING;
-   else
+   if_link_state_change(ifp, LINK_STATE_UP);
+   } else {
ifp->if_drv_flags &= ~IFF_DRV_RUNNING;
+   if_link_state_change(ifp, LINK_STATE_DOWN);
+   }
return (error);
 }
 
@@ -1063,4 +1068,5 @@ gif_delete_tunnel(struct ifnet *ifp)
free(sc->gif_hdr, M_GIF);
}
ifp->if_drv_flags &= ~IFF_DRV_RUNNING;
+   if_link_state_change(ifp, LINK_STATE_DOWN);
 }

Modified: stable/10/sys/net/if_gre.c
==
--- stable/10/sys/net/if_gre.c  Tue Nov  3 22:24:02 2015(r290346)
+++ stable/10/sys/net/if_gre.c  Wed Nov  4 00:21:02 2015(r290347)
@@ -179,6 +179,8 @@ gre_clone_create(struct if_clone *ifc, i
GRE2IFP(sc)->if_ioctl = gre_ioctl;
GRE2IFP(sc)->if_transmit = gre_transmit;
GRE2IFP(sc)->if_qflush = gre_qflush;
+   GRE2IFP(sc)->if_capabilities |= IFCAP_LINKSTATE;
+   GRE2IFP(sc)->if_capenable |= IFCAP_LINKSTATE;
if_attach(GRE2IFP(sc));
bpfattach(GRE2IFP(sc), DLT_NULL, sizeof(u_int32_t));
GRE_LIST_LOCK();
@@ -648,8 +650,10 @@ gre_set_tunnel(struct ifnet *ifp, struct
break;
 #endif
}
-   if (error == 0)
+   if (error == 0) {
ifp->if_drv_flags |= IFF_DRV_RUNNING;
+   if_link_state_change(ifp, LINK_STATE_UP);
+   }
return (error);
 }
 
@@ -668,6 +672,7 @@ gre_delete_tunnel(struct ifnet *ifp)
free(sc->gre_hdr, M_GRE);
}
ifp->if_drv_flags &= ~IFF_DRV_RUNNING;
+   if_link_state_change(ifp, LINK_STATE_DOWN);
 }
 
 int

Modified: stable/10/sys/net/if_me.c
==
--- stable/10/sys/net/if_me.c   Tue Nov  3 22:24:02 2015(r290346)
+++ stable/10/sys/net/if_me.c   Wed Nov  4 00:21:02 2015(r290347)
@@ -193,6 +193,8 @@ me_clone_create(struct if_clone *ifc, in
ME2IFP(sc)->if_ioctl = me_ioctl;
ME2IFP(sc)->if_transmit = me_transmit;
ME2IFP(sc)->if_qflush = me_qflush;
+   ME2IFP(sc)->if_capabilities |= IFCAP_LINKSTATE;
+   ME2IFP(sc)->if_capenable |= IFCAP_LINKSTATE;
if_attach(ME2IFP(sc));
bpfattach(ME2IFP(sc), DLT_NULL, sizeof(u_int32_t));
ME_LIST_LOCK();
@@ -377,8 +379,10 @@ me_set_tunnel(struct ifnet *ifp, struct 
if (sc->me_ecookie == NULL)
sc->me_ecookie = encap_attach_func(AF_INET, IPPROTO_MOBILE,
me_encapcheck, _mobile_protosw, sc);
-   if (sc->me_ecookie != NULL)
+   if (sc->me_ecookie != NULL) {
ifp->if_drv_flags |= IFF_DRV_RUNNING;
+   if_link_state_change(ifp, LINK_STATE_UP);
+   }
return (0);
 }
 
@@ -396,6 +400,7 @@ me_delete_tunnel(struct ifnet *ifp)
sc->me_dst.s_addr = 0;
ME_WUNLOCK(sc);
ifp->if_drv_flags &= ~IFF_DRV_RUNNING;
+   if_link_state_change(ifp, LINK_STATE_DOWN);
 }
 
 static uint16_t
___
svn-src-stable-10@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-10
To unsubscribe, send any mail to "svn-src-stable-10-unsubscr...@freebsd.org"