svn commit: r234483 - in head/sys: kern ufs/ffs ufs/ufs

2012-04-20 Thread Kirk McKusick
Author: mckusick
Date: Fri Apr 20 07:00:28 2012
New Revision: 234483
URL: http://svn.freebsd.org/changeset/base/234483

Log:
  This update uses the MNT_VNODE_FOREACH_ACTIVE interface that loops
  over just the active vnodes associated with a mount point to replace
  MNT_VNODE_FOREACH_ALL in the vfs_msync, ffs_sync_lazy, and qsync
  routines.
  
  The vfs_msync routine is run every 30 seconds for every writably
  mounted filesystem. It ensures that any files mmap'ed from the
  filesystem with modified pages have those pages queued to be
  written back to the file from which they are mapped.
  
  The ffs_lazy_sync and qsync routines are run every 30 seconds for
  every writably mounted UFS/FFS filesystem. The ffs_lazy_sync routine
  ensures that any files that have been accessed in the previous
  30 seconds have had their access times queued for updating in the
  filesystem. The qsync routine ensures that any files with modified
  quotas have those quotas queued to be written back to their
  associated quota file.
  
  In a system configured with 250,000 vnodes, less than 1000 are
  typically active at any point in time. Prior to this change all
  250,000 vnodes would be locked and inspected twice every minute
  by the syncer. For UFS/FFS filesystems they would be locked and
  inspected six times every minute (twice by each of these three
  routines since each of these routines does its own pass over the
  vnodes associated with a mount point). With this change the syncer
  now locks and inspects only the tiny set of vnodes that are active.
  
  Reviewed by: kib
  Tested by:   Peter Holm
  MFC after:   2 weeks

Modified:
  head/sys/kern/vfs_subr.c
  head/sys/ufs/ffs/ffs_vfsops.c
  head/sys/ufs/ufs/quota.h
  head/sys/ufs/ufs/ufs_inode.c
  head/sys/ufs/ufs/ufs_quota.c

Modified: head/sys/kern/vfs_subr.c
==
--- head/sys/kern/vfs_subr.cFri Apr 20 06:50:44 2012(r234482)
+++ head/sys/kern/vfs_subr.cFri Apr 20 07:00:28 2012(r234483)
@@ -2484,6 +2484,7 @@ vdropl(struct vnode *vp)
 void
 vinactive(struct vnode *vp, struct thread *td)
 {
+   struct vm_object *obj;
 
ASSERT_VOP_ELOCKED(vp, "vinactive");
ASSERT_VI_LOCKED(vp, "vinactive");
@@ -2493,6 +2494,17 @@ vinactive(struct vnode *vp, struct threa
vp->v_iflag |= VI_DOINGINACT;
vp->v_iflag &= ~VI_OWEINACT;
VI_UNLOCK(vp);
+   /*
+* Before moving off the active list, we must be sure that any
+* modified pages are on the vnode's dirty list since these will
+* no longer be checked once the vnode is on the inactive list.
+*/
+   obj = vp->v_object;
+   if (obj != NULL && (obj->flags & OBJ_MIGHTBEDIRTY) != 0) {
+   VM_OBJECT_LOCK(obj);
+   vm_object_page_clean(obj, 0, 0, OBJPC_NOSYNC);
+   VM_OBJECT_UNLOCK(obj);
+   }
VOP_INACTIVE(vp, td);
VI_LOCK(vp);
VNASSERT(vp->v_iflag & VI_DOINGINACT, vp,
@@ -3362,7 +3374,7 @@ vfs_msync(struct mount *mp, int flags)
struct vm_object *obj;
 
CTR2(KTR_VFS, "%s: mp %p", __func__, mp);
-   MNT_VNODE_FOREACH_ALL(vp, mp, mvp) {
+   MNT_VNODE_FOREACH_ACTIVE(vp, mp, mvp) {
obj = vp->v_object;
if (obj != NULL && (obj->flags & OBJ_MIGHTBEDIRTY) != 0 &&
(flags == MNT_WAIT || VOP_ISLOCKED(vp) == 0)) {

Modified: head/sys/ufs/ffs/ffs_vfsops.c
==
--- head/sys/ufs/ffs/ffs_vfsops.c   Fri Apr 20 06:50:44 2012
(r234482)
+++ head/sys/ufs/ffs/ffs_vfsops.c   Fri Apr 20 07:00:28 2012
(r234483)
@@ -1432,7 +1432,7 @@ ffs_sync_lazy(mp)
td = curthread;
if ((mp->mnt_flag & MNT_NOATIME) != 0)
goto qupdate;
-   MNT_VNODE_FOREACH_ALL(vp, mp, mvp) {
+   MNT_VNODE_FOREACH_ACTIVE(vp, mp, mvp) {
if (vp->v_type == VNON) {
VI_UNLOCK(vp);
continue;

Modified: head/sys/ufs/ufs/quota.h
==
--- head/sys/ufs/ufs/quota.hFri Apr 20 06:50:44 2012(r234482)
+++ head/sys/ufs/ufs/quota.hFri Apr 20 07:00:28 2012(r234483)
@@ -227,9 +227,10 @@ void   dqinit(void);
 void   dqrele(struct vnode *, struct dquot *);
 void   dquninit(void);
 intgetinoquota(struct inode *);
-intqsync(struct mount *mp);
-intquotaoff(struct thread *td, struct mount *, int);
-intquotaon(struct thread *td, struct mount *, int, void *);
+intqsync(struct mount *);
+intqsyncvp(struct vnode *);
+intquotaoff(struct thread *, struct mount *, int);
+intquotaon(struct thread *, struct mount *, int, void *);
 intgetquota32(struct thread *, struct mount *, u_long, int, void *);
 intsetquota32(struct thread *, struct mount *, u_long, int, void *);
 intsetuse

svn commit: r234485 - head/sys/mips/atheros

2012-04-20 Thread Adrian Chadd
Author: adrian
Date: Fri Apr 20 08:26:05 2012
New Revision: 234485
URL: http://svn.freebsd.org/changeset/base/234485

Log:
  Introduce the matching PCI ath(4) fixup code from ar71xx_pci into
  ar724x_pci.c.
  
  * Move out the code which populates the firmware into ar71xx_fixup.c
  * Shuffle around the ar724x fixup code to match what the ar71xx fixup
code does.
  
  I've validated this on an AR7240 with AR9285 on-board NIC. It doesn't
  yet load, as the AR9285 EEPROM code needs to be made "flash aware."
  
  TODO:
  
  * Validate that I haven't broken AR71xx
  * Test AR9285/AR9287 onboard NICs, complete with EEPROM code changes
  * Port over the needed BAR hacks for AR7240, AR7241 and AR7242 from
Linux OpenWRT.  The current WAR has only been tested on the AR7240
and I'm not sure the way the BAR register is treated is "right".
The "fixup" method here is right when setting the BAR for local access -
ie, the BAR address is either 0x (AR7240) or 0x1000 (AR7241/AR7242),
but the ath9k-fixup.c code (Linux OpenWRT) does this when setting the
initial "fixup" BAR.  It then restores the original BAR.
I'll have to read the ar724x PCI bus glue to see what other special cases
await.

Added:
  head/sys/mips/atheros/ar71xx_fixup.c   (contents, props changed)
  head/sys/mips/atheros/ar71xx_fixup.h   (contents, props changed)
Modified:
  head/sys/mips/atheros/ar71xx_pci.c
  head/sys/mips/atheros/ar724x_pci.c
  head/sys/mips/atheros/files.ar71xx

Added: head/sys/mips/atheros/ar71xx_fixup.c
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/sys/mips/atheros/ar71xx_fixup.cFri Apr 20 08:26:05 2012
(r234485)
@@ -0,0 +1,153 @@
+/*-
+ * Copyright (c) 2009, Oleksandr Tymoshenko 
+ * All rights reserved.
+ *
+ * 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 unmodified, 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.
+ */
+
+#include 
+__FBSDID("$FreeBSD$");
+
+#include "opt_ar71xx.h"
+
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+
+#include 
+#include "pcib_if.h"
+
+#include 
+#include 
+
+#include 
+
+#include 
+#include 
+
+#include 
+
+/*
+ * Take a copy of the EEPROM contents and squirrel it away in a firmware.
+ * The SPI flash will eventually cease to be memory-mapped, so we need
+ * to take a copy of this before the SPI driver initialises.
+ */
+void
+ar71xx_pci_slot_create_eeprom_firmware(device_t dev, u_int bus, u_int slot,
+u_int func, long int flash_addr, int size)
+{
+   char buf[64];
+   uint16_t *cal_data = (uint16_t *) MIPS_PHYS_TO_KSEG1(flash_addr);
+   void *eeprom = NULL;
+   const struct firmware *fw = NULL;
+
+   device_printf(dev, "EEPROM firmware: 0x%lx @ %d bytes\n",
+   flash_addr, size);
+
+   eeprom = malloc(size, M_DEVBUF, M_WAITOK | M_ZERO);
+   if (! eeprom) {
+   device_printf(dev,
+   "%s: malloc failed for '%s', aborting EEPROM\n",
+   __func__, buf);
+   return;
+   }
+
+   memcpy(eeprom, cal_data, size);
+
+   /*
+* Generate a flash EEPROM 'firmware' from the given memory
+* region.  Since the SPI controller will eventually
+* go into port-IO mode instead of memory-mapped IO
+* mode, a copy of the EEPROM contents is required.
+*/
+   snprintf(buf, sizeof(buf), "%s.%d.bus.%d.%d.%d.eeprom_firmware",
+   device_get_name(dev), device_get_unit(dev), bus, slot, func);
+   fw = firmware_register(buf,

Re: svn commit: r233937 - in head/sys: kern net security/mac

2012-04-20 Thread Alexander V. Chernikov

On 17.04.2012 01:29, Adrian Chadd wrote:

On 15 April 2012 23:33, Alexander V. Chernikov  wrote:

On 16.04.2012 01:17, Adrian Chadd wrote:


Hi,

This has broken (at least) net80211 and bpf, with LOR:


Yes, it is. Please try the attached patch


Hi,

Hello!
Sorry for the late reply, answering for both letters.


This seems like a very, very complicated diff.




* You've removed BPF_LOCK_ASSERT() inside bpf_detachd_locked() - why'd
you do that?
* You removed a comment ("We're already protected by the global lock")
which is still relevant/valid

Both should be added back, thanks.

* There are lots of modifications to the read/write locks here - I'm
not sure whether they're at all relevant to my immediate problem and
may belong in separate commits
Most of the patch is not directly relevant to the problem. It solves 
several new problems and a bunch of very old bugs due to lack of locking.




Is there a document somewhere which describes what the "new" style BPF
locking should be?
Are there any other places (except src) where such documentation should 
reside?




I "just" added BPF_LOCK() / BPF_UNLOCK() around all the calls to
bpf_detachd() which weren't locked (there were a few.)
Unfortunately, this is not enough. There is possibility that bpf_setif() 
is called immediately before rw_destroy() in bpfdetach().
For example, you can easily trigger panic on any 8/9/current SMP system 
with 'while true; do ifconfig vlan222 create vlan 222 vlandev em0 up ; 
tcpdump -pi vlan222 & ; ifconfig vlan222 destroy ; done'


There is also possible use-after-free for bpfif structure (since we're 
freeing it _before_ interface routes are cleaned up). This is why 
delayed free is needed.




One final question - should the BPF global lock be recursive?

It seems it really should be recursive now.


thanks,



Adrian



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


svn commit: r234487 - head/sys/net

2012-04-20 Thread Andrew Thompson
Author: thompsa
Date: Fri Apr 20 09:55:50 2012
New Revision: 234487
URL: http://svn.freebsd.org/changeset/base/234487

Log:
  Add linkstate to bridge(4), set the link to up when at least one underlying
  interface is up, otherwise the link is down.
  
  This, among other things, allows carp to work on a bridge.
  
  Prodded by:   glebius
  Tested by:Alexander Lunev

Modified:
  head/sys/net/bridgestp.c
  head/sys/net/bridgestp.h
  head/sys/net/if.c
  head/sys/net/if_bridge.c

Modified: head/sys/net/bridgestp.c
==
--- head/sys/net/bridgestp.cFri Apr 20 09:43:42 2012(r234486)
+++ head/sys/net/bridgestp.cFri Apr 20 09:55:50 2012(r234487)
@@ -1767,28 +1767,16 @@ bstp_notify_rtage(void *arg, int pending
 }
 
 void
-bstp_linkstate(struct ifnet *ifp, int state)
+bstp_linkstate(struct bstp_port *bp)
 {
-   struct bstp_state *bs;
-   struct bstp_port *bp;
+   struct bstp_state *bs = bp->bp_bs;
 
-   /* search for the stp port */
-   mtx_lock(&bstp_list_mtx);
-   LIST_FOREACH(bs, &bstp_list, bs_list) {
-   BSTP_LOCK(bs);
-   LIST_FOREACH(bp, &bs->bs_bplist, bp_next) {
-   if (bp->bp_ifp == ifp) {
-   bstp_ifupdstatus(bs, bp);
-   bstp_update_state(bs, bp);
-   /* it only exists once so return */
-   BSTP_UNLOCK(bs);
-   mtx_unlock(&bstp_list_mtx);
-   return;
-   }
-   }
-   BSTP_UNLOCK(bs);
+   BSTP_LOCK(bs);
+   if (bp->bp_active) {
+   bstp_ifupdstatus(bs, bp);
+   bstp_update_state(bs, bp);
}
-   mtx_unlock(&bstp_list_mtx);
+   BSTP_UNLOCK(bs);
 }
 
 static void
@@ -2103,10 +2091,8 @@ bstp_modevent(module_t mod, int type, vo
case MOD_LOAD:
mtx_init(&bstp_list_mtx, "bridgestp list", NULL, MTX_DEF);
LIST_INIT(&bstp_list);
-   bstp_linkstate_p = bstp_linkstate;
break;
case MOD_UNLOAD:
-   bstp_linkstate_p = NULL;
mtx_destroy(&bstp_list_mtx);
break;
default:

Modified: head/sys/net/bridgestp.h
==
--- head/sys/net/bridgestp.hFri Apr 20 09:43:42 2012(r234486)
+++ head/sys/net/bridgestp.hFri Apr 20 09:55:50 2012(r234487)
@@ -369,8 +369,6 @@ struct bstp_state {
 
 extern const uint8_t bstp_etheraddr[];
 
-extern void (*bstp_linkstate_p)(struct ifnet *ifp, int state);
-
 void   bstp_attach(struct bstp_state *, struct bstp_cb_ops *);
 void   bstp_detach(struct bstp_state *);
 void   bstp_init(struct bstp_state *);
@@ -379,7 +377,7 @@ int bstp_create(struct bstp_state *, str
 intbstp_enable(struct bstp_port *);
 void   bstp_disable(struct bstp_port *);
 void   bstp_destroy(struct bstp_port *);
-void   bstp_linkstate(struct ifnet *, int);
+void   bstp_linkstate(struct bstp_port *);
 intbstp_set_htime(struct bstp_state *, int);
 intbstp_set_fdelay(struct bstp_state *, int);
 intbstp_set_maxage(struct bstp_state *, int);

Modified: head/sys/net/if.c
==
--- head/sys/net/if.c   Fri Apr 20 09:43:42 2012(r234486)
+++ head/sys/net/if.c   Fri Apr 20 09:55:50 2012(r234487)
@@ -124,7 +124,7 @@ static MALLOC_DEFINE(M_IFDESCR, "ifdescr
 static struct sx ifdescr_sx;
 SX_SYSINIT(ifdescr_sx, &ifdescr_sx, "ifnet descr");
 
-void   (*bstp_linkstate_p)(struct ifnet *ifp, int state);
+void   (*bridge_linkstate_p)(struct ifnet *ifp);
 void   (*ng_ether_link_state_p)(struct ifnet *ifp, int state);
 void   (*lagg_linkstate_p)(struct ifnet *ifp, int state);
 /* These are external hooks for CARP. */
@@ -1910,7 +1910,7 @@ do_link_state_change(void *arg, int pend
if (ifp->if_carp)
(*carp_linkstate_p)(ifp);
if (ifp->if_bridge)
-   (*bstp_linkstate_p)(ifp, link_state);
+   (*bridge_linkstate_p)(ifp);
if (ifp->if_lagg)
(*lagg_linkstate_p)(ifp, link_state);
 

Modified: head/sys/net/if_bridge.c
==
--- head/sys/net/if_bridge.cFri Apr 20 09:43:42 2012(r234486)
+++ head/sys/net/if_bridge.cFri Apr 20 09:55:50 2012(r234487)
@@ -333,6 +333,9 @@ static int  bridge_ip6_checkbasic(struct 
 #endif /* INET6 */
 static int bridge_fragment(struct ifnet *, struct mbuf *,
struct ether_header *, int, struct llc *);
+static voidbridge_linkstate(struct ifnet *ifp);
+
+extern void (*bridge_linkstate_p)(struct ifnet *ifp);
 
 /* The default bridge vlan is 1 (IEEE 802.1Q-2003 Table 9-2) */
 #defineVLANTAGOF(_

svn commit: r234488 - head/sys/net

2012-04-20 Thread Andrew Thompson
Author: thompsa
Date: Fri Apr 20 10:06:28 2012
New Revision: 234488
URL: http://svn.freebsd.org/changeset/base/234488

Log:
  Move the interface media check to a taskqueue, some interfaces (usb) sleep
  during SIOCGIFMEDIA and we were holding locks.

Modified:
  head/sys/net/bridgestp.c
  head/sys/net/bridgestp.h

Modified: head/sys/net/bridgestp.c
==
--- head/sys/net/bridgestp.cFri Apr 20 09:55:50 2012(r234487)
+++ head/sys/net/bridgestp.cFri Apr 20 10:06:28 2012(r234488)
@@ -127,7 +127,7 @@ static int  bstp_rerooted(struct bstp_sta
 static uint32_tbstp_calc_path_cost(struct bstp_port *);
 static voidbstp_notify_state(void *, int);
 static voidbstp_notify_rtage(void *, int);
-static voidbstp_ifupdstatus(struct bstp_state *, struct bstp_port *);
+static voidbstp_ifupdstatus(void *, int);
 static voidbstp_enable_port(struct bstp_state *, struct bstp_port *);
 static voidbstp_disable_port(struct bstp_state *, struct bstp_port *);
 static voidbstp_tick(void *);
@@ -1677,7 +1677,7 @@ bstp_set_autoptp(struct bstp_port *bp, i
if (set) {
bp->bp_flags |= BSTP_PORT_AUTOPTP;
if (bp->bp_role != BSTP_ROLE_DISABLED)
-   bstp_ifupdstatus(bs, bp);
+   taskqueue_enqueue(taskqueue_swi, &bp->bp_mediatask);
} else
bp->bp_flags &= ~BSTP_PORT_AUTOPTP;
BSTP_UNLOCK(bs);
@@ -1771,69 +1771,89 @@ bstp_linkstate(struct bstp_port *bp)
 {
struct bstp_state *bs = bp->bp_bs;
 
+   if (!bp->bp_active)
+   return;
+
+   bstp_ifupdstatus(bp, 0);
BSTP_LOCK(bs);
-   if (bp->bp_active) {
-   bstp_ifupdstatus(bs, bp);
-   bstp_update_state(bs, bp);
-   }
+   bstp_update_state(bs, bp);
BSTP_UNLOCK(bs);
 }
 
 static void
-bstp_ifupdstatus(struct bstp_state *bs, struct bstp_port *bp)
+bstp_ifupdstatus(void *arg, int pending)
 {
+   struct bstp_port *bp = (struct bstp_port *)arg;
+   struct bstp_state *bs = bp->bp_bs;
struct ifnet *ifp = bp->bp_ifp;
struct ifmediareq ifmr;
-   int error = 0;
+   int error, changed;
 
-   BSTP_LOCK_ASSERT(bs);
+   if (!bp->bp_active)
+   return;
 
bzero((char *)&ifmr, sizeof(ifmr));
error = (*ifp->if_ioctl)(ifp, SIOCGIFMEDIA, (caddr_t)&ifmr);
 
+   BSTP_LOCK(bs);
+   changed = 0;
if ((error == 0) && (ifp->if_flags & IFF_UP)) {
if (ifmr.ifm_status & IFM_ACTIVE) {
/* A full-duplex link is assumed to be point to point */
if (bp->bp_flags & BSTP_PORT_AUTOPTP) {
-   bp->bp_ptp_link =
-   ifmr.ifm_active & IFM_FDX ? 1 : 0;
+   int fdx;
+
+   fdx = ifmr.ifm_active & IFM_FDX ? 1 : 0;
+   if (bp->bp_ptp_link ^ fdx) {
+   bp->bp_ptp_link = fdx;
+   changed = 1;
+   }
}
 
/* Calc the cost if the link was down previously */
if (bp->bp_flags & BSTP_PORT_PNDCOST) {
-   bp->bp_path_cost = bstp_calc_path_cost(bp);
+   uint32_t cost;
+
+   cost = bstp_calc_path_cost(bp);
+   if (bp->bp_path_cost != cost) {
+   bp->bp_path_cost = cost;
+   changed = 1;
+   }
bp->bp_flags &= ~BSTP_PORT_PNDCOST;
}
 
-   if (bp->bp_role == BSTP_ROLE_DISABLED)
+   if (bp->bp_role == BSTP_ROLE_DISABLED) {
bstp_enable_port(bs, bp);
+   changed = 1;
+   }
} else {
if (bp->bp_role != BSTP_ROLE_DISABLED) {
bstp_disable_port(bs, bp);
+   changed = 1;
if ((bp->bp_flags & BSTP_PORT_ADMEDGE) &&
bp->bp_protover == BSTP_PROTO_RSTP)
bp->bp_operedge = 1;
}
}
-   return;
-   }
-
-   if (bp->bp_infois != BSTP_INFO_DISABLED)
+   } else if (bp->bp_infois != BSTP_INFO_DISABLED) {
bstp_disable_port(bs, bp);
+   changed = 1;
+   }
+   if (changed)
+   bstp_assign_roles(bs);
+   BSTP_UNLOCK(bs);
 }
 
 static void
 bstp_enable_port(struct bstp_state *bs, struct bstp_port *bp)
 {
bp->bp_infois

svn commit: r234489 - head/sys/kern

2012-04-20 Thread Jaakko Heinonen
Author: jh
Date: Fri Apr 20 10:08:30 2012
New Revision: 234489
URL: http://svn.freebsd.org/changeset/base/234489

Log:
  The value of flags matching VNOVAL can't be supported. Return EOPNOTSUPP
  from setfflags() in this case. This fixes the return value of
  chflags(path, -1).
  
  Discussed with:   bde
  MFC after:2 weeks

Modified:
  head/sys/kern/vfs_syscalls.c

Modified: head/sys/kern/vfs_syscalls.c
==
--- head/sys/kern/vfs_syscalls.cFri Apr 20 10:06:28 2012
(r234488)
+++ head/sys/kern/vfs_syscalls.cFri Apr 20 10:08:30 2012
(r234489)
@@ -2744,6 +2744,10 @@ setfflags(td, vp, flags)
struct mount *mp;
struct vattr vattr;
 
+   /* We can't support the value matching VNOVAL. */
+   if (flags == VNOVAL)
+   return (EOPNOTSUPP);
+
/*
 * Prevent non-root users from setting flags on devices.  When
 * a device is reused, users can retain ownership of the device
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r234491 - head/lib/libusb

2012-04-20 Thread Hans Petter Selasky
Author: hselasky
Date: Fri Apr 20 14:29:45 2012
New Revision: 234491
URL: http://svn.freebsd.org/changeset/base/234491

Log:
  Fix some compile warnings.
  
  MFC after:1 week

Modified:
  head/lib/libusb/libusb10.c
  head/lib/libusb/libusb10_desc.c
  head/lib/libusb/libusb10_io.c
  head/lib/libusb/libusb20.c
  head/lib/libusb/libusb20_desc.c
  head/lib/libusb/libusb20_ugen20.c

Modified: head/lib/libusb/libusb10.c
==
--- head/lib/libusb/libusb10.c  Fri Apr 20 13:47:22 2012(r234490)
+++ head/lib/libusb/libusb10.c  Fri Apr 20 14:29:45 2012(r234491)
@@ -651,17 +651,17 @@ libusb_set_interface_alt_setting(struct 
 
 static struct libusb20_transfer *
 libusb10_get_transfer(struct libusb20_device *pdev,
-uint8_t endpoint, uint8_t index)
+uint8_t endpoint, uint8_t xfer_index)
 {
-   index &= 1; /* double buffering */
+   xfer_index &= 1;/* double buffering */
 
-   index |= (endpoint & LIBUSB20_ENDPOINT_ADDRESS_MASK) * 4;
+   xfer_index |= (endpoint & LIBUSB20_ENDPOINT_ADDRESS_MASK) * 4;
 
if (endpoint & LIBUSB20_ENDPOINT_DIR_MASK) {
/* this is an IN endpoint */
-   index |= 2;
+   xfer_index |= 2;
}
-   return (libusb20_tr_get_pointer(pdev, index));
+   return (libusb20_tr_get_pointer(pdev, xfer_index));
 }
 
 int

Modified: head/lib/libusb/libusb10_desc.c
==
--- head/lib/libusb/libusb10_desc.c Fri Apr 20 13:47:22 2012
(r234490)
+++ head/lib/libusb/libusb10_desc.c Fri Apr 20 14:29:45 2012
(r234491)
@@ -390,8 +390,8 @@ libusb_parse_bos_descriptor(const void *
 struct libusb_bos_descriptor **bos)
 {
struct libusb_bos_descriptor *ptr;
-   struct libusb_usb_2_0_device_capability_descriptor *dcap_20;
-   struct libusb_ss_usb_device_capability_descriptor *ss_cap;
+   struct libusb_usb_2_0_device_capability_descriptor *dcap_20 = NULL;
+   struct libusb_ss_usb_device_capability_descriptor *ss_cap = NULL;
 
if (buf == NULL || bos == NULL || len < 1)
return (LIBUSB_ERROR_INVALID_PARAM);
@@ -438,7 +438,7 @@ libusb_parse_bos_descriptor(const void *
dtype == LIBUSB_DT_DEVICE_CAPABILITY) {
switch (((const uint8_t *)buf)[2]) {
case LIBUSB_USB_2_0_EXTENSION_DEVICE_CAPABILITY:
-   if (ptr->usb_2_0_ext_cap != NULL)
+   if (ptr->usb_2_0_ext_cap != NULL || dcap_20 == 
NULL)
break;
if (dlen < 
LIBUSB_USB_2_0_EXTENSION_DEVICE_CAPABILITY_SIZE)
break;
@@ -455,7 +455,7 @@ libusb_parse_bos_descriptor(const void *
break;
 
case LIBUSB_SS_USB_DEVICE_CAPABILITY:
-   if (ptr->ss_usb_cap != NULL)
+   if (ptr->ss_usb_cap != NULL || ss_cap == NULL)
break;
if (dlen < LIBUSB_SS_USB_DEVICE_CAPABILITY_SIZE)
break;

Modified: head/lib/libusb/libusb10_io.c
==
--- head/lib/libusb/libusb10_io.c   Fri Apr 20 13:47:22 2012
(r234490)
+++ head/lib/libusb/libusb10_io.c   Fri Apr 20 14:29:45 2012
(r234491)
@@ -481,7 +481,7 @@ libusb10_do_transfer(libusb_device_handl
 {
libusb_context *ctx;
struct libusb_transfer *xfer;
-   volatile int complet;
+   int done;
int ret;
 
if (devh == NULL)
@@ -502,15 +502,15 @@ libusb10_do_transfer(libusb_device_handl
xfer->timeout = timeout;
xfer->buffer = data;
xfer->length = length;
-   xfer->user_data = (void *)&complet;
+   xfer->user_data = (void *)&done;
xfer->callback = libusb10_do_transfer_cb;
-   complet = 0;
+   done = 0;
 
if ((ret = libusb_submit_transfer(xfer)) < 0) {
libusb_free_transfer(xfer);
return (ret);
}
-   while (complet == 0) {
+   while (done == 0) {
if ((ret = libusb_handle_events(ctx)) < 0) {
libusb_cancel_transfer(xfer);
usleep(1000);   /* nice it */
@@ -581,7 +581,7 @@ libusb_interrupt_transfer(libusb_device_
 }
 
 uint8_t *
-libusb_get_iso_packet_buffer(struct libusb_transfer *transfer, uint32_t index)
+libusb_get_iso_packet_buffer(struct libusb_transfer *transfer, uint32_t off)
 {
uint8_t *ptr;
uint32_t n;
@@ -589,35 +589,35 @@ libusb_get_iso_packet_buffer(struct libu
if (transfer->num_iso_packets < 0)
return (NULL);
 
-   if (index >= (uint32_

svn commit: r234493 - in head/sys/boot: efi i386/efi

2012-04-20 Thread Marcel Moolenaar
Author: marcel
Date: Fri Apr 20 15:01:23 2012
New Revision: 234493
URL: http://svn.freebsd.org/changeset/base/234493

Log:
  Build a 32-bit EFI loader on amd64. This to match the rest of the
  code that is used to construct a loader (e.g. libstand, ficl, etc).
  
  There is such a thing as a 64-bit EFI application, but it's not
  as standard as 32-bit is. Let's make the 32-bit functional (as in
  we can load and actualy boot a kernel) before solving the 64-bit
  loader problem.

Modified:
  head/sys/boot/efi/Makefile.inc
  head/sys/boot/i386/efi/Makefile

Modified: head/sys/boot/efi/Makefile.inc
==
--- head/sys/boot/efi/Makefile.inc  Fri Apr 20 14:45:57 2012
(r234492)
+++ head/sys/boot/efi/Makefile.inc  Fri Apr 20 15:01:23 2012
(r234493)
@@ -2,6 +2,13 @@
 
 BINDIR?=   /boot
 
+.if ${MACHINE_CPUARCH} == "amd64"
+CFLAGS+=-m32 -march=i386
+ACFLAGS+=   -m32
+LDFLAGS+=   -m elf_i386_fbsd
+AFLAGS+=--32
+.endif
+
 # Options used when building app-specific efi components
 CFLAGS+=   -ffreestanding -fshort-wchar -Wformat
 LDFLAGS+=  -nostdlib

Modified: head/sys/boot/i386/efi/Makefile
==
--- head/sys/boot/i386/efi/Makefile Fri Apr 20 14:45:57 2012
(r234492)
+++ head/sys/boot/i386/efi/Makefile Fri Apr 20 15:01:23 2012
(r234493)
@@ -35,7 +35,7 @@ CFLAGS+=  -I${.CURDIR}/../../common
 FILES= loader.efi
 FILESMODE_loader.efi=  ${BINMODE}
 
-LDSCRIPT=  ${.CURDIR}/ldscript.${MACHINE_ARCH}
+LDSCRIPT=  ${.CURDIR}/ldscript.i386
 LDFLAGS=   -Wl,-T${LDSCRIPT} -shared -symbolic
 
 ${PROG}:   ${LDSCRIPT}
@@ -64,6 +64,13 @@ CFLAGS+= -I${.CURDIR}/../libi386
 CFLAGS+=   -I${.CURDIR}/../btx/lib
 
 DPADD= ${LIBFICL} ${LIBEFI} ${LIBSTAND}
-LDADD= ${LIBFICL} ${LIBEFI} -lstand
+LDADD= ${LIBFICL} ${LIBEFI} ${LIBSTAND}
 
 .include 
+
+.if ${MACHINE_CPUARCH} == "amd64"
+CFLAGS+=-I.
+beforedepend ${OBJS}: machine
+machine:
+   ln -sf ${.CURDIR}/../../../i386/include machine
+.endif
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r234494 - in head: sys/kern sys/sys usr.bin/kdump

2012-04-20 Thread John Baldwin
Author: jhb
Date: Fri Apr 20 15:32:36 2012
New Revision: 234494
URL: http://svn.freebsd.org/changeset/base/234494

Log:
  Include the associated wait channel message for context switch ktrace
  records.  kdump supports both the old and new messages.
  
  Submitted by: Andrey Zonov  andrey zonov org
  MFC after:1 week

Modified:
  head/sys/kern/kern_condvar.c
  head/sys/kern/kern_ktrace.c
  head/sys/kern/kern_synch.c
  head/sys/kern/subr_trap.c
  head/sys/sys/ktrace.h
  head/usr.bin/kdump/kdump.1
  head/usr.bin/kdump/kdump.c

Modified: head/sys/kern/kern_condvar.c
==
--- head/sys/kern/kern_condvar.cFri Apr 20 15:01:23 2012
(r234493)
+++ head/sys/kern/kern_condvar.cFri Apr 20 15:32:36 2012
(r234494)
@@ -103,7 +103,7 @@ _cv_wait(struct cv *cvp, struct lock_obj
lock_state = 0;
 #ifdef KTRACE
if (KTRPOINT(td, KTR_CSW))
-   ktrcsw(1, 0);
+   ktrcsw(1, 0, cv_wmesg(cvp));
 #endif
CV_ASSERT(cvp, lock, td);
WITNESS_WARN(WARN_GIANTOK | WARN_SLEEPOK, lock,
@@ -140,7 +140,7 @@ _cv_wait(struct cv *cvp, struct lock_obj
 
 #ifdef KTRACE
if (KTRPOINT(td, KTR_CSW))
-   ktrcsw(0, 0);
+   ktrcsw(0, 0, cv_wmesg(cvp));
 #endif
PICKUP_GIANT();
if (lock != &Giant.lock_object) {
@@ -162,7 +162,7 @@ _cv_wait_unlock(struct cv *cvp, struct l
td = curthread;
 #ifdef KTRACE
if (KTRPOINT(td, KTR_CSW))
-   ktrcsw(1, 0);
+   ktrcsw(1, 0, cv_wmesg(cvp));
 #endif
CV_ASSERT(cvp, lock, td);
WITNESS_WARN(WARN_GIANTOK | WARN_SLEEPOK, lock,
@@ -197,7 +197,7 @@ _cv_wait_unlock(struct cv *cvp, struct l
 
 #ifdef KTRACE
if (KTRPOINT(td, KTR_CSW))
-   ktrcsw(0, 0);
+   ktrcsw(0, 0, cv_wmesg(cvp));
 #endif
PICKUP_GIANT();
 }
@@ -220,7 +220,7 @@ _cv_wait_sig(struct cv *cvp, struct lock
lock_state = 0;
 #ifdef KTRACE
if (KTRPOINT(td, KTR_CSW))
-   ktrcsw(1, 0);
+   ktrcsw(1, 0, cv_wmesg(cvp));
 #endif
CV_ASSERT(cvp, lock, td);
WITNESS_WARN(WARN_GIANTOK | WARN_SLEEPOK, lock,
@@ -258,7 +258,7 @@ _cv_wait_sig(struct cv *cvp, struct lock
 
 #ifdef KTRACE
if (KTRPOINT(td, KTR_CSW))
-   ktrcsw(0, 0);
+   ktrcsw(0, 0, cv_wmesg(cvp));
 #endif
PICKUP_GIANT();
if (lock != &Giant.lock_object) {
@@ -286,7 +286,7 @@ _cv_timedwait(struct cv *cvp, struct loc
lock_state = 0;
 #ifdef KTRACE
if (KTRPOINT(td, KTR_CSW))
-   ktrcsw(1, 0);
+   ktrcsw(1, 0, cv_wmesg(cvp));
 #endif
CV_ASSERT(cvp, lock, td);
WITNESS_WARN(WARN_GIANTOK | WARN_SLEEPOK, lock,
@@ -324,7 +324,7 @@ _cv_timedwait(struct cv *cvp, struct loc
 
 #ifdef KTRACE
if (KTRPOINT(td, KTR_CSW))
-   ktrcsw(0, 0);
+   ktrcsw(0, 0, cv_wmesg(cvp));
 #endif
PICKUP_GIANT();
if (lock != &Giant.lock_object) {
@@ -353,7 +353,7 @@ _cv_timedwait_sig(struct cv *cvp, struct
lock_state = 0;
 #ifdef KTRACE
if (KTRPOINT(td, KTR_CSW))
-   ktrcsw(1, 0);
+   ktrcsw(1, 0, cv_wmesg(cvp));
 #endif
CV_ASSERT(cvp, lock, td);
WITNESS_WARN(WARN_GIANTOK | WARN_SLEEPOK, lock,
@@ -392,7 +392,7 @@ _cv_timedwait_sig(struct cv *cvp, struct
 
 #ifdef KTRACE
if (KTRPOINT(td, KTR_CSW))
-   ktrcsw(0, 0);
+   ktrcsw(0, 0, cv_wmesg(cvp));
 #endif
PICKUP_GIANT();
if (lock != &Giant.lock_object) {

Modified: head/sys/kern/kern_ktrace.c
==
--- head/sys/kern/kern_ktrace.c Fri Apr 20 15:01:23 2012(r234493)
+++ head/sys/kern/kern_ktrace.c Fri Apr 20 15:32:36 2012(r234494)
@@ -733,8 +733,9 @@ ktrpsig(sig, action, mask, code)
 }
 
 void
-ktrcsw(out, user)
+ktrcsw(out, user, wmesg)
int out, user;
+   const char *wmesg;
 {
struct thread *td = curthread;
struct ktr_request *req;
@@ -746,6 +747,10 @@ ktrcsw(out, user)
kc = &req->ktr_data.ktr_csw;
kc->out = out;
kc->user = user;
+   if (wmesg != NULL)
+   strlcpy(kc->wmesg, wmesg, sizeof(kc->wmesg));
+   else
+   bzero(kc->wmesg, sizeof(kc->wmesg));
ktr_enqueuerequest(td, req);
ktrace_exit(td);
 }

Modified: head/sys/kern/kern_synch.c
==
--- head/sys/kern/kern_synch.c  Fri Apr 20 15:01:23 2012(r234493)
+++ head/sys/kern/kern_synch.c  Fri Apr 20 15:32:36 2012(r234494)
@@ -142,7 +142,7 @@ _sleep(void *ident, struct lock_object *
p = td->td_proc;
 #ifdef KTRACE
if (KTRPOINT(td, KTR_CSW))
-   ktrcsw(1, 0);
+   ktrcsw(1, 0, wmesg);
 #endif
WITNESS_WARN(WARN_GIANTOK | WARN_SLEEPOK,

svn commit: r234501 - head/sys/dev/amr

2012-04-20 Thread John Baldwin
Author: jhb
Date: Fri Apr 20 20:27:31 2012
New Revision: 234501
URL: http://svn.freebsd.org/changeset/base/234501

Log:
  The amr(4) firmware contains a rather dubious "feature" where it
  assumes for small buffers (< 64k) that the OS driver is actually using
  a buffer rounded up to the next power of 2.  It also assumes that the
  buffer is at least 4k in size.  Furthermore, there is at least one
  known instance of megarc sending a request with a 12k buffer where the
  firmware writes out a 24k-ish reply.
  
  To workaround the data corruption triggered by this "feature", ensure
  that buffers for user commands use a minimum size of 32k, and that
  buffers between 32k and 64k use a 64k buffer.
  
  PR:   kern/155658
  Submitted by: Andreas Longwitz  longwitz incore de
  Reviewed by:  scottl
  MFC after:1 week

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

Modified: head/sys/dev/amr/amr.c
==
--- head/sys/dev/amr/amr.c  Fri Apr 20 16:56:14 2012(r234500)
+++ head/sys/dev/amr/amr.c  Fri Apr 20 20:27:31 2012(r234501)
@@ -535,6 +535,31 @@ shutdown_out:
 amr_startup(sc);
 }
 
+/*
+ * Bug-for-bug compatibility with Linux!
+ * Some apps will send commands with inlen and outlen set to 0,
+ * even though they expect data to be transfered to them from the
+ * card.  Linux accidentally allows this by allocating a 4KB
+ * buffer for the transfer anyways, but it then throws it away
+ * without copying it back to the app.
+ * 
+ * The amr(4) firmware relies on this feature.  In fact, it assumes
+ * the buffer is always a power of 2 up to a max of 64k.  There is
+ * also at least one case where it assumes a buffer less than 16k is
+ * greater than 16k.  Force a minimum buffer size of 32k and round
+ * sizes between 32k and 64k up to 64k as a workaround.
+ */
+static unsigned long
+amr_ioctl_buffer_length(unsigned long len)
+{
+
+if (len <= 32 * 1024)
+   return (32 * 1024);
+if (len <= 64 * 1024)
+   return (64 * 1024);
+return (len);
+}
+
 int
 amr_linux_ioctl_int(struct cdev *dev, u_long cmd, caddr_t addr, int32_t flag,
 struct thread *td)
@@ -664,16 +689,7 @@ amr_linux_ioctl_int(struct cdev *dev, u_
error = ENOIOCTL;
break;
} else {
-   /*
-* Bug-for-bug compatibility with Linux!
-* Some apps will send commands with inlen and outlen set to 0,
-* even though they expect data to be transfered to them from the
-* card.  Linux accidentally allows this by allocating a 4KB
-* buffer for the transfer anyways, but it then throws it away
-* without copying it back to the app.
-*/
-   if (!len)
-   len = 4096;
+   len = amr_ioctl_buffer_length(imax(ali.inlen, ali.outlen));
 
dp = malloc(len, M_AMR, M_WAITOK | M_ZERO);
 
@@ -703,7 +719,7 @@ amr_linux_ioctl_int(struct cdev *dev, u_
status = ac->ac_status;
error = copyout(&status, &((struct amr_mailbox *)&((struct 
amr_linux_ioctl *)addr)->mbox[0])->mb_status, sizeof(status));
if (ali.outlen) {
-   error = copyout(dp, (void *)(uintptr_t)mb->mb_physaddr, len);
+   error = copyout(dp, (void *)(uintptr_t)mb->mb_physaddr, 
ali.outlen);
if (error)
break;
}
@@ -750,7 +766,7 @@ amr_ioctl(struct cdev *dev, u_long cmd, 
 struct amr_command *ac;
 struct amr_mailbox_ioctl   *mbi;
 void   *dp, *au_buffer;
-unsigned long  au_length;
+unsigned long  au_length, real_length;
 unsigned char  *au_cmd;
 int*au_statusp, au_direction;
 interror;
@@ -842,8 +858,9 @@ amr_ioctl(struct cdev *dev, u_long cmd, 
 }
 
 /* handle inbound data buffer */
+real_length = amr_ioctl_buffer_length(au_length);
 if (au_length != 0 && au_cmd[0] != 0x06) {
-   if ((dp = malloc(au_length, M_AMR, M_WAITOK|M_ZERO)) == NULL) {
+   if ((dp = malloc(real_length, M_AMR, M_WAITOK|M_ZERO)) == NULL) {
error = ENOMEM;
goto out;
}
@@ -902,7 +919,7 @@ amr_ioctl(struct cdev *dev, u_long cmd, 
 
 /* build the command */
 ac->ac_data = dp;
-ac->ac_length = au_length;
+ac->ac_length = real_length;
 ac->ac_flags |= AMR_CMD_DATAIN|AMR_CMD_DATAOUT;
 
 /* run the command */
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r234502 - in head/lib/csu: amd64 arm i386-elf ia64 mips powerpc powerpc64

2012-04-20 Thread Dimitry Andric
Author: dim
Date: Fri Apr 20 21:00:39 2012
New Revision: 234502
URL: http://svn.freebsd.org/changeset/base/234502

Log:
  After r217375, some startup objects under lib/csu are built in a special
  way: first they are compiled to assembly, then some sed'ing is done on
  the assembly, and lastly the assembly is compiled to an object file.
  
  This last step is done using ${CC}, and not ${AS}, because when the
  compiler is clang, it outputs directives that are too advanced for our
  old gas.  So we use clang's integrated assembler instead.  (When the
  compiler is gcc, it just calls gas, and nothing is different, except one
  extra fork.)
  
  However, in the .s to .o rules in lib/csu/$ARCH/Makefile, I still passed
  CFLAGS to the compiler, instead of ACFLAGS, which are specifically for
  compiling .s files.
  
  In case you are using '-g' for debug info anywhere in your CFLAGS, it
  causes the .s files to already contain debug information in the assembly
  itself.  In the next step, the .s files are also compiled using '-g',
  and if the compiler is clang, it complains: "error: input can't have
  .file dwarf directives when -g is used to generate dwarf debug info for
  assembly code".
  
  Fix this by using ${ACFLAGS} for compiling the .s files instead.
  
  Reported by:  jasone
  MFC after:1 week

Modified:
  head/lib/csu/amd64/Makefile
  head/lib/csu/arm/Makefile
  head/lib/csu/i386-elf/Makefile
  head/lib/csu/ia64/Makefile
  head/lib/csu/mips/Makefile
  head/lib/csu/powerpc/Makefile
  head/lib/csu/powerpc64/Makefile

Modified: head/lib/csu/amd64/Makefile
==
--- head/lib/csu/amd64/Makefile Fri Apr 20 20:27:31 2012(r234501)
+++ head/lib/csu/amd64/Makefile Fri Apr 20 21:00:39 2012(r234502)
@@ -22,21 +22,21 @@ crt1.s: crt1.c
sed ${SED_FIX_NOTE} ${.TARGET}
 
 crt1.o: crt1.s
-   ${CC} ${CFLAGS} -c -o ${.TARGET} crt1.s
+   ${CC} ${ACFLAGS} -c -o ${.TARGET} crt1.s
 
 gcrt1.s: crt1.c
${CC} ${CFLAGS} -DGCRT -S -o ${.TARGET} ${.CURDIR}/crt1.c
sed ${SED_FIX_NOTE} ${.TARGET}
 
 gcrt1.o: gcrt1.s
-   ${CC} ${CFLAGS} -c -o ${.TARGET} gcrt1.s
+   ${CC} ${ACFLAGS} -c -o ${.TARGET} gcrt1.s
 
 Scrt1.s: crt1.c
${CC} ${CFLAGS} -fPIC -DPIC -S -o ${.TARGET} ${.CURDIR}/crt1.c
sed ${SED_FIX_NOTE} ${.TARGET}
 
 Scrt1.o: Scrt1.s
-   ${CC} ${CFLAGS} -c -o ${.TARGET} Scrt1.s
+   ${CC} ${ACFLAGS} -c -o ${.TARGET} Scrt1.s
 
 realinstall:
${INSTALL} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \

Modified: head/lib/csu/arm/Makefile
==
--- head/lib/csu/arm/Makefile   Fri Apr 20 20:27:31 2012(r234501)
+++ head/lib/csu/arm/Makefile   Fri Apr 20 21:00:39 2012(r234502)
@@ -21,21 +21,21 @@ crt1.s: crt1.c
sed ${SED_FIX_NOTE} ${.TARGET}
 
 crt1.o: crt1.s
-   ${CC} ${CFLAGS} -c -o ${.TARGET} crt1.s
+   ${CC} ${ACFLAGS} -c -o ${.TARGET} crt1.s
 
 gcrt1.s: crt1.c
${CC} ${CFLAGS} -DGCRT -S -o ${.TARGET} ${.CURDIR}/crt1.c
sed ${SED_FIX_NOTE} ${.TARGET}
 
 gcrt1.o: gcrt1.s
-   ${CC} ${CFLAGS} -c -o ${.TARGET} gcrt1.s
+   ${CC} ${ACFLAGS} -c -o ${.TARGET} gcrt1.s
 
 Scrt1.s: crt1.c
${CC} ${CFLAGS} -fPIC -DPIC -S -o ${.TARGET} ${.CURDIR}/crt1.c
sed ${SED_FIX_NOTE} ${.TARGET}
 
 Scrt1.o: Scrt1.s
-   ${CC} ${CFLAGS} -c -o ${.TARGET} Scrt1.s
+   ${CC} ${ACFLAGS} -c -o ${.TARGET} Scrt1.s
 
 realinstall:
${INSTALL} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \

Modified: head/lib/csu/i386-elf/Makefile
==
--- head/lib/csu/i386-elf/Makefile  Fri Apr 20 20:27:31 2012
(r234501)
+++ head/lib/csu/i386-elf/Makefile  Fri Apr 20 21:00:39 2012
(r234502)
@@ -21,7 +21,7 @@ gcrt1_c.s: crt1_c.c
sed ${SED_FIX_NOTE} ${.TARGET}
 
 gcrt1_c.o: gcrt1_c.s
-   ${CC} ${CFLAGS} -c -o ${.TARGET} gcrt1_c.s
+   ${CC} ${ACFLAGS} -c -o ${.TARGET} gcrt1_c.s
 
 gcrt1.o: gcrt1_c.o crt1_s.o
${LD} ${LDFLAGS} -o gcrt1.o -r crt1_s.o gcrt1_c.o
@@ -31,7 +31,7 @@ crt1_c.s: crt1_c.c
sed ${SED_FIX_NOTE} ${.TARGET}
 
 crt1_c.o: crt1_c.s
-   ${CC} ${CFLAGS} -c -o ${.TARGET} crt1_c.s
+   ${CC} ${ACFLAGS} -c -o ${.TARGET} crt1_c.s
 
 crt1.o:crt1_c.o crt1_s.o
${LD} ${LDFLAGS} -o crt1.o -r crt1_s.o crt1_c.o
@@ -42,7 +42,7 @@ Scrt1_c.s: crt1_c.c
sed ${SED_FIX_NOTE} ${.TARGET}
 
 Scrt1_c.o: Scrt1_c.s
-   ${CC} ${CFLAGS} -c -o ${.TARGET} Scrt1_c.s
+   ${CC} ${ACFLAGS} -c -o ${.TARGET} Scrt1_c.s
 
 Scrt1.o: Scrt1_c.o crt1_s.o
${LD} ${LDFLAGS} -o Scrt1.o -r crt1_s.o Scrt1_c.o

Modified: head/lib/csu/ia64/Makefile
==
--- head/lib/csu/ia64/Makefile  Fri Apr 20 20:27:31 2012(r234501)
+++ head/lib/csu/ia64/Makefile  Fri Apr 20 21:00:39

svn commit: r234503 - head/sys/dev/asr

2012-04-20 Thread Dimitry Andric
Author: dim
Date: Fri Apr 20 21:17:33 2012
New Revision: 234503
URL: http://svn.freebsd.org/changeset/base/234503

Log:
  Replace homegrown list implementation in sys/dev/asr/asr.c with
  STAILQ().  While here, fix another clang warning about a switch which
  tests an enum type for a regular integer value.
  
  Submitted by: jhb
  MFC after:1 week

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

Modified: head/sys/dev/asr/asr.c
==
--- head/sys/dev/asr/asr.c  Fri Apr 20 21:00:39 2012(r234502)
+++ head/sys/dev/asr/asr.c  Fri Apr 20 21:17:33 2012(r234503)
@@ -378,11 +378,12 @@ typedef struct Asr_softc {
u_int16_t   ha_Msgs_Count;
 
/* Links into other parents and HBAs */
-   struct Asr_softc  * ha_next;   /* HBA list */
+   STAILQ_ENTRY(Asr_softc) ha_next;   /* HBA list */
struct cdev *ha_devt;
 } Asr_softc_t;
 
-static Asr_softc_t *Asr_softc_list;
+static STAILQ_HEAD(, Asr_softc) Asr_softc_list =
+   STAILQ_HEAD_INITIALIZER(Asr_softc_list);
 
 /*
  * Prototypes of the routines we have in this object.
@@ -1959,7 +1960,7 @@ ASR_setSysTab(Asr_softc_t *sc)
 {
PI2O_EXEC_SYS_TAB_SET_MESSAGE Message_Ptr;
PI2O_SET_SYSTAB_HEADERSystemTable;
-   Asr_softc_t * ha;
+   Asr_softc_t * ha, *next;
PI2O_SGE_SIMPLE_ELEMENT   sg;
int   retVal;
 
@@ -1967,7 +1968,7 @@ ASR_setSysTab(Asr_softc_t *sc)
  sizeof(I2O_SET_SYSTAB_HEADER), M_TEMP, M_WAITOK | M_ZERO)) == NULL) {
return (ENOMEM);
}
-   for (ha = Asr_softc_list; ha; ha = ha->ha_next) {
+   STAILQ_FOREACH(ha, &Asr_softc_list, ha_next) {
++SystemTable->NumberEntries;
}
if ((Message_Ptr = (PI2O_EXEC_SYS_TAB_SET_MESSAGE)malloc (
@@ -1998,9 +1999,9 @@ ASR_setSysTab(Asr_softc_t *sc)
  &(Message_Ptr->StdMessageFrame)) & 0xF0) >> 2));
SG(sg, 0, I2O_SGL_FLAGS_DIR, SystemTable, 
sizeof(I2O_SET_SYSTAB_HEADER));
++sg;
-   for (ha = Asr_softc_list; ha; ha = ha->ha_next) {
+   STAILQ_FOREACH_SAFE(ha, &Asr_softc_list, ha_next, next) {
SG(sg, 0,
- ((ha->ha_next)
+ ((next)
? (I2O_SGL_FLAGS_DIR)
: (I2O_SGL_FLAGS_DIR | I2O_SGL_FLAGS_END_OF_BUFFER)),
  &(ha->ha_SystemTable), sizeof(ha->ha_SystemTable));
@@ -2396,7 +2397,7 @@ asr_attach(device_t dev)
 {
PI2O_EXEC_STATUS_GET_REPLY status;
PI2O_LCT_ENTRY   Device;
-   Asr_softc_t  *sc, **ha;
+   Asr_softc_t  *sc;
struct scsi_inquiry_data *iq;
int  bus, size, unit;
int  error;
@@ -2405,7 +2406,7 @@ asr_attach(device_t dev)
unit = device_get_unit(dev);
sc->ha_dev = dev;
 
-   if (Asr_softc_list == NULL) {
+   if (STAILQ_EMPTY(&Asr_softc_list)) {
/*
 *  Fixup the OS revision as saved in the dptsig for the
 *  engine (dptioctl.h) to pick up.
@@ -2417,8 +2418,7 @@ asr_attach(device_t dev)
 */
LIST_INIT(&(sc->ha_ccb));
/* Link us into the HA list */
-   for (ha = &Asr_softc_list; *ha; ha = &((*ha)->ha_next));
-   *(ha) = sc;
+   STAILQ_INSERT_TAIL(&Asr_softc_list, sc, ha_next);
 
/*
 *  This is the real McCoy!
@@ -2700,7 +2700,7 @@ asr_action(struct cam_sim *sim, union cc
 
ccb->ccb_h.spriv_ptr0 = sc = (struct Asr_softc *)cam_sim_softc(sim);
 
-   switch (ccb->ccb_h.func_code) {
+   switch ((int)ccb->ccb_h.func_code) {
 
/* Common cases first */
case XPT_SCSI_IO:   /* Execute the requested I/O operation */
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r234504 - in head/sys: amd64/conf i386/conf

2012-04-20 Thread Brooks Davis
Author: brooks
Date: Fri Apr 20 21:37:42 2012
New Revision: 234504
URL: http://svn.freebsd.org/changeset/base/234504

Log:
  Enable DTrace hooks in GENERIC.
  
  Reviewed by:  gnn
  Approved by:  core (jhb, imp)
  Requested by: a cast of thousands
  MFC after:3 days

Modified:
  head/sys/amd64/conf/GENERIC
  head/sys/i386/conf/GENERIC

Modified: head/sys/amd64/conf/GENERIC
==
--- head/sys/amd64/conf/GENERIC Fri Apr 20 21:17:33 2012(r234503)
+++ head/sys/amd64/conf/GENERIC Fri Apr 20 21:37:42 2012(r234504)
@@ -22,6 +22,7 @@ cpu   HAMMER
 ident  GENERIC
 
 makeoptionsDEBUG=-g# Build kernel with gdb(1) debug symbols
+makeoptionsWITH_CTF=1  # Run ctfconvert(1) for DTrace support
 
 optionsSCHED_ULE   # ULE scheduler
 optionsPREEMPTION  # Enable kernel thread preemption
@@ -63,8 +64,8 @@ options   AUDIT   # Security event auditi
 optionsCAPABILITY_MODE # Capsicum capability mode
 optionsCAPABILITIES# Capsicum capabilities
 optionsMAC # TrustedBSD MAC Framework
-#options   KDTRACE_FRAME   # Ensure frames are compiled in
-#options   KDTRACE_HOOKS   # Kernel DTrace hooks
+optionsKDTRACE_FRAME   # Ensure frames are compiled in
+optionsKDTRACE_HOOKS   # Kernel DTrace hooks
 optionsINCLUDE_CONFIG_FILE # Include this file in kernel
 
 # Debugging support.  Always need this:
@@ -74,6 +75,7 @@ options   KDB # Enable kernel 
debugger 
 # For full debugger support use this instead:
 optionsDDB # Support DDB.
 optionsGDB # Support remote GDB.
+optionsDDB_CTF # kernel ELF linker loads CTF data
 optionsDEADLKRES   # Enable the deadlock resolver
 optionsINVARIANTS  # Enable calls of extra sanity checking
 optionsINVARIANT_SUPPORT   # Extra sanity checks of internal 
structures, required by INVARIANTS

Modified: head/sys/i386/conf/GENERIC
==
--- head/sys/i386/conf/GENERIC  Fri Apr 20 21:17:33 2012(r234503)
+++ head/sys/i386/conf/GENERIC  Fri Apr 20 21:37:42 2012(r234504)
@@ -24,6 +24,7 @@ cpu   I686_CPU
 ident  GENERIC
 
 makeoptionsDEBUG=-g# Build kernel with gdb(1) debug symbols
+makeoptionsWITH_CTF=1  # Run ctfconvert(1) for DTrace support
 
 optionsSCHED_ULE   # ULE scheduler
 optionsPREEMPTION  # Enable kernel thread preemption
@@ -64,7 +65,7 @@ options   AUDIT   # Security event auditi
 optionsCAPABILITY_MODE # Capsicum capability mode
 optionsCAPABILITIES# Capsicum capabilities
 optionsMAC # TrustedBSD MAC Framework
-#options   KDTRACE_HOOKS   # Kernel DTrace hooks
+optionsKDTRACE_HOOKS   # Kernel DTrace hooks
 optionsINCLUDE_CONFIG_FILE # Include this file in kernel
 
 # Debugging support.  Always need this:
@@ -74,6 +75,7 @@ options   KDB # Enable kernel 
debugger 
 # For full debugger support use this instead:
 optionsDDB # Support DDB.
 optionsGDB # Support remote GDB.
+optionsDDB_CTF # kernel ELF linker loads CTF data
 optionsDEADLKRES   # Enable the deadlock resolver
 optionsINVARIANTS  # Enable calls of extra sanity checking
 optionsINVARIANT_SUPPORT   # Extra sanity checks of internal 
structures, required by INVARIANTS
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r234506 - head/sys/dev/nxge

2012-04-20 Thread Dimitry Andric
Author: dim
Date: Fri Apr 20 21:43:19 2012
New Revision: 234506
URL: http://svn.freebsd.org/changeset/base/234506

Log:
  Fix the following compilation warnings in nxge(4):
  
sys/dev/nxge/if_nxge.c:1276:11: error: case value not in enumerated type 
'xge_hal_event_e' (aka 'enum xge_hal_event_e') [-Werror,-Wswitch]
  case XGE_LL_EVENT_TRY_XMIT_AGAIN:
   ^
sys/dev/nxge/if_nxge.c:1289:11: error: case value not in enumerated type 
'xge_hal_event_e' (aka 'enum xge_hal_event_e') [-Werror,-Wswitch]
  case XGE_LL_EVENT_DEVICE_RESETTING:
   ^
  
  This is because the switch uses xge_queue_item_t::event_type, which is
  an enum xge_hal_event_e, while the XGE_LL_EVENT_xx values are of the
  enum xge_event_e.
  
  Since messing around with the enum definitions is too disruptive, the
  simplest fix is to cast the argument of the switch to int.
  
  Reviewed by:  gnn
  MFC after:1 week

Modified:
  head/sys/dev/nxge/if_nxge.c

Modified: head/sys/dev/nxge/if_nxge.c
==
--- head/sys/dev/nxge/if_nxge.c Fri Apr 20 21:40:31 2012(r234505)
+++ head/sys/dev/nxge/if_nxge.c Fri Apr 20 21:43:19 2012(r234506)
@@ -1272,7 +1272,7 @@ xge_callback_event(xge_queue_item_t *ite
lldev  = xge_hal_device_private(hldev);
ifnetp = lldev->ifnetp;
 
-   switch(item->event_type) {
+   switch((int)item->event_type) {
case XGE_LL_EVENT_TRY_XMIT_AGAIN:
if(lldev->initialized) {
if(xge_hal_channel_dtr_count(lldev->fifo_channel[0]) > 0) {
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r234507 - head/sys/contrib/rdma

2012-04-20 Thread Dimitry Andric
Author: dim
Date: Fri Apr 20 21:52:57 2012
New Revision: 234507
URL: http://svn.freebsd.org/changeset/base/234507

Log:
  Fix the following compilation warnings in sys/contrib/rdma/rdma_cma.c:
  
sys/contrib/rdma/rdma_cma.c:1259:8: error: case value not in enumerated 
type 'enum iw_cm_event_status' [-Werror,-Wswitch]
  case ECONNRESET:
   ^
@/sys/errno.h:118:20: note: expanded from macro 'ECONNRESET'
#define ECONNRESET  54  /* Connection reset by peer */
  ^
sys/contrib/rdma/rdma_cma.c:1263:8: error: case value not in enumerated 
type 'enum iw_cm_event_status' [-Werror,-Wswitch]
  case ETIMEDOUT:
   ^
@/sys/errno.h:124:19: note: expanded from macro 'ETIMEDOUT'
#define ETIMEDOUT   60  /* Operation timed out */
  ^
sys/contrib/rdma/rdma_cma.c:1260:8: error: case value not in enumerated 
type 'enum iw_cm_event_status' [-Werror,-Wswitch]
  case ECONNREFUSED:
   ^
@/sys/errno.h:125:22: note: expanded from macro 'ECONNREFUSED'
#define ECONNREFUSED61  /* Connection refused */
  ^
  
  This is because the switch uses iw_cm_event::status, which is an enum
  iw_cm_event_status, while ECONNRESET, ETIMEDOUT and ECONNREFUSED are
  just plain defines from errno.h.
  
  It looks like there is only one use of any of the enumeration values of
  iw_cm_event_status, in:
  
sys/contrib/rdma/rdma_iwcm.c:   if (iw_event->status == 
IW_CM_EVENT_STATUS_ACCEPTED) {
  
  So messing around with the enum definitions to fix the warning seems too
  disruptive; the simplest fix is to cast the argument of the switch to
  int.
  
  Reviewed by:  kmacy
  MFC after:1 week

Modified:
  head/sys/contrib/rdma/rdma_cma.c

Modified: head/sys/contrib/rdma/rdma_cma.c
==
--- head/sys/contrib/rdma/rdma_cma.cFri Apr 20 21:43:19 2012
(r234506)
+++ head/sys/contrib/rdma/rdma_cma.cFri Apr 20 21:52:57 2012
(r234507)
@@ -1252,7 +1252,7 @@ static int cma_iw_handler(struct iw_cm_i
*sin = iw_event->local_addr;
sin = (struct sockaddr_in *) &id_priv->id.route.addr.dst_addr;
*sin = iw_event->remote_addr;
-   switch (iw_event->status) {
+   switch ((int)iw_event->status) {
case 0:
event.event = RDMA_CM_EVENT_ESTABLISHED;
break;
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r234508 - in head/sys/dev/ath/ath_hal: . ar9002

2012-04-20 Thread Adrian Chadd
Author: adrian
Date: Fri Apr 20 21:56:13 2012
New Revision: 234508
URL: http://svn.freebsd.org/changeset/base/234508

Log:
  "Upgrade" the AR9285 code to support PCI/ART EEPROM on flash.
  
  I've just verified that this boots on an Atheros AP91. I haven't verified
  it with traffic though, so YMMV.

Modified:
  head/sys/dev/ath/ath_hal/ah_eeprom_v4k.c
  head/sys/dev/ath/ath_hal/ar9002/ar9280_attach.c
  head/sys/dev/ath/ath_hal/ar9002/ar9285_attach.c

Modified: head/sys/dev/ath/ath_hal/ah_eeprom_v4k.c
==
--- head/sys/dev/ath/ath_hal/ah_eeprom_v4k.cFri Apr 20 21:52:57 2012
(r234507)
+++ head/sys/dev/ath/ath_hal/ah_eeprom_v4k.cFri Apr 20 21:56:13 2012
(r234508)
@@ -298,12 +298,12 @@ ath_hal_v4kEepromAttach(struct ath_hal *
"%s Error reading Eeprom MAGIC\n", __func__);
return HAL_EEREAD;
}
-   }
-   HALDEBUG(ah, HAL_DEBUG_ATTACH, "%s Eeprom Magic = 0x%x\n",
-   __func__, magic);
-   if (magic != AR5416_EEPROM_MAGIC) {
-   HALDEBUG(ah, HAL_DEBUG_ANY, "Bad magic number\n");
-   return HAL_EEMAGIC;
+   HALDEBUG(ah, HAL_DEBUG_ATTACH, "%s Eeprom Magic = 0x%x\n",
+   __func__, magic);
+   if (magic != AR5416_EEPROM_MAGIC) {
+   HALDEBUG(ah, HAL_DEBUG_ANY, "Bad magic number\n");
+   return HAL_EEMAGIC;
+   }
}
 
ee = ath_hal_malloc(sizeof(HAL_EEPROM_v4k));

Modified: head/sys/dev/ath/ath_hal/ar9002/ar9280_attach.c
==
--- head/sys/dev/ath/ath_hal/ar9002/ar9280_attach.c Fri Apr 20 21:52:57 
2012(r234507)
+++ head/sys/dev/ath/ath_hal/ar9002/ar9280_attach.c Fri Apr 20 21:56:13 
2012(r234508)
@@ -169,7 +169,6 @@ ar9280Attach(uint16_t devid, HAL_SOFTC s
 
ar5416InitState(AH5416(ah), devid, sc, st, sh, status);
 
-
/*
 * Use the "local" EEPROM data given to us by the higher layers.
 * This is a private copy out of system flash. The Linux ath9k
@@ -180,7 +179,6 @@ ar9280Attach(uint16_t devid, HAL_SOFTC s
AH_PRIVATE((ah))->ah_eepromRead = ath_hal_EepromDataRead;
AH_PRIVATE((ah))->ah_eepromWrite = NULL;
ah->ah_eepromdata = eepromdata;
-   }
 
/* XXX override with 9280 specific state */
/* override 5416 methods for our needs */

Modified: head/sys/dev/ath/ath_hal/ar9002/ar9285_attach.c
==
--- head/sys/dev/ath/ath_hal/ar9002/ar9285_attach.c Fri Apr 20 21:52:57 
2012(r234507)
+++ head/sys/dev/ath/ath_hal/ar9002/ar9285_attach.c Fri Apr 20 21:56:13 
2012(r234508)
@@ -134,6 +134,18 @@ ar9285Attach(uint16_t devid, HAL_SOFTC s
 
ar5416InitState(AH5416(ah), devid, sc, st, sh, status);
 
+   /*
+* Use the "local" EEPROM data given to us by the higher layers.
+* This is a private copy out of system flash. The Linux ath9k
+* commit for the initial AR9130 support mentions MMIO flash
+* access is "unreliable." -adrian
+*/
+   if (eepromdata != AH_NULL) {
+   AH_PRIVATE(ah)->ah_eepromRead = ath_hal_EepromDataRead;
+   AH_PRIVATE(ah)->ah_eepromWrite = NULL;
+   ah->ah_eepromdata = eepromdata;
+   }
+
/* XXX override with 9285 specific state */
/* override 5416 methods for our needs */
AH5416(ah)->ah_initPLL = ar9280InitPLL;
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r234510 - head/sys/dev/ath/ath_hal/ar9002

2012-04-20 Thread Adrian Chadd
Author: adrian
Date: Fri Apr 20 22:07:21 2012
New Revision: 234510
URL: http://svn.freebsd.org/changeset/base/234510

Log:
  .. oops.

Modified:
  head/sys/dev/ath/ath_hal/ar9002/ar9280_attach.c

Modified: head/sys/dev/ath/ath_hal/ar9002/ar9280_attach.c
==
--- head/sys/dev/ath/ath_hal/ar9002/ar9280_attach.c Fri Apr 20 22:01:12 
2012(r234509)
+++ head/sys/dev/ath/ath_hal/ar9002/ar9280_attach.c Fri Apr 20 22:07:21 
2012(r234510)
@@ -179,6 +179,7 @@ ar9280Attach(uint16_t devid, HAL_SOFTC s
AH_PRIVATE((ah))->ah_eepromRead = ath_hal_EepromDataRead;
AH_PRIVATE((ah))->ah_eepromWrite = NULL;
ah->ah_eepromdata = eepromdata;
+   }
 
/* XXX override with 9280 specific state */
/* override 5416 methods for our needs */
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r234515 - head/sys/mips/atheros

2012-04-20 Thread Adrian Chadd
Author: adrian
Date: Fri Apr 20 22:44:00 2012
New Revision: 234515
URL: http://svn.freebsd.org/changeset/base/234515

Log:
  Allow for a default GPIO pin "high", which is required for some boards
  which tie the USB device enable to a GPIO line.
  
  Submitted by: Stefan Bethke 

Modified:
  head/sys/mips/atheros/ar71xx_gpio.c

Modified: head/sys/mips/atheros/ar71xx_gpio.c
==
--- head/sys/mips/atheros/ar71xx_gpio.c Fri Apr 20 22:43:04 2012
(r234514)
+++ head/sys/mips/atheros/ar71xx_gpio.c Fri Apr 20 22:44:00 2012
(r234515)
@@ -329,7 +329,7 @@ ar71xx_gpio_attach(device_t dev)
struct ar71xx_gpio_softc *sc = device_get_softc(dev);
int error = 0;
int i, j, maxpin;
-   int mask;
+   int mask, pinon;
int old = 0;
 
KASSERT((device_get_unit(dev) == 0),
@@ -394,6 +394,9 @@ ar71xx_gpio_attach(device_t dev)
if (resource_int_value(device_get_name(dev), device_get_unit(dev),
"pinmask", &mask) != 0)
mask = 0;
+   if (resource_int_value(device_get_name(dev), device_get_unit(dev),
+   "pinon", &pinon) != 0)
+   pinon = 0;
device_printf(dev, "gpio pinmask=0x%x\n", mask);
for (i = 0, j = 0; j < maxpin; j++) {
if ((mask & (1 << j)) == 0)
@@ -407,6 +410,11 @@ ar71xx_gpio_attach(device_t dev)
i++;
}
sc->gpio_npins = i;
+   for (i = 0; i < sc->gpio_npins; i++) {
+   j = sc->gpio_pins[i].gp_pin;
+   if ((pinon & (1 << j)) != 0)
+   ar71xx_gpio_pin_set(dev, j, 1);
+   }
device_add_child(dev, "gpioc", device_get_unit(dev));
device_add_child(dev, "gpiobus", device_get_unit(dev));
return (bus_generic_attach(dev));
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r234517 - head/sys/powerpc/aim

2012-04-20 Thread Nathan Whitehorn
Author: nwhitehorn
Date: Fri Apr 20 23:01:36 2012
New Revision: 234517
URL: http://svn.freebsd.org/changeset/base/234517

Log:
  Make sure all pending operations have completed on the existing thread
  before (potentially) migrating it to a different CPU.
  
  MFC after:5 days

Modified:
  head/sys/powerpc/aim/swtch32.S
  head/sys/powerpc/aim/swtch64.S

Modified: head/sys/powerpc/aim/swtch32.S
==
--- head/sys/powerpc/aim/swtch32.S  Fri Apr 20 23:00:37 2012
(r234516)
+++ head/sys/powerpc/aim/swtch32.S  Fri Apr 20 23:01:36 2012
(r234517)
@@ -113,6 +113,7 @@ ENTRY(cpu_switch)
mr  %r3,%r14/* restore old thread ptr */
bl  pmap_deactivate /* Deactivate the current pmap */
 
+   sync/* Make sure all of that finished */
stw %r16,TD_LOCK(%r14)  /* ULE: update old thread's lock */
 
 cpu_switchin:

Modified: head/sys/powerpc/aim/swtch64.S
==
--- head/sys/powerpc/aim/swtch64.S  Fri Apr 20 23:00:37 2012
(r234516)
+++ head/sys/powerpc/aim/swtch64.S  Fri Apr 20 23:01:36 2012
(r234517)
@@ -139,6 +139,7 @@ ENTRY(cpu_switch)
 
addi%r1,%r1,48
 
+   sync/* Make sure all of that finished */
std %r16,TD_LOCK(%r14)  /* ULE: update old thread's lock */
 
 cpu_switchin:
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r234524 - in head/sys: dev/mmc modules/mmcsd

2012-04-20 Thread Marius Strobl
Author: marius
Date: Sat Apr 21 01:51:16 2012
New Revision: 234524
URL: http://svn.freebsd.org/changeset/base/234524

Log:
  o Fixes:
- When switching to 4-bit operation, send a SET_CLR_CARD_DETECT command
  to disconnect the card-detect pull-up resistor from the DAT3 line before
  sending the SET_BUS_WIDTH command.
- Add the missing "reserved" zero entry to the mantissa table used to
  decode various CSD fields. This was causing SD cards to report that they
  could run at 30 MHz instead of the maximum 25 MHz mandated in the spec.
  o Enhancements:
- At the MMC layer, format various info from the CID into a string that
  uniquely identifies the card instance (manufacturer number, serial
  number, product name and revision, etc). Export it as an instance
  variable.
- At the MMCSD layer, display the formatted card ID string, and also
  report the clock speed of the hardware (not the card's max speed), and
  the number of bits and number of blocks per transfer. It comes out like
  this now:
  mmcsd0: 968MB  at mmc0
  22.5MHz/4bit/128-block
  o Use DEVMETHOD_END.
  o Use NULL instead of 0 for pointers.
  
  PR:   156496
  Submitted by: Ian Lepore
  MFC after:1 week

Modified:
  head/sys/dev/mmc/mmc.c
  head/sys/dev/mmc/mmcbrvar.h
  head/sys/dev/mmc/mmcreg.h
  head/sys/dev/mmc/mmcsd.c
  head/sys/dev/mmc/mmcvar.h
  head/sys/modules/mmcsd/Makefile

Modified: head/sys/dev/mmc/mmc.c
==
--- head/sys/dev/mmc/mmc.c  Sat Apr 21 00:51:28 2012(r234523)
+++ head/sys/dev/mmc/mmc.c  Sat Apr 21 01:51:16 2012(r234524)
@@ -101,6 +101,7 @@ struct mmc_ivars {
uint32_t tran_speed;/* Max speed in normal mode */
uint32_t hs_tran_speed; /* Max speed in high speed mode */
uint32_t erase_sector;  /* Card native erase sector size */
+   char card_id_string[64];/* Formatted CID info (serial, MFG, etc) */
 };
 
 #define CMD_RETRIES3
@@ -140,6 +141,7 @@ static void mmc_app_decode_scr(uint32_t 
 static int mmc_send_ext_csd(struct mmc_softc *sc, uint8_t *rawextcsd);
 static void mmc_scan(struct mmc_softc *sc);
 static int mmc_delete_cards(struct mmc_softc *sc);
+static void mmc_format_card_id_string(struct mmc_ivars *ivar);
 
 static void
 mmc_ms_delay(int ms)
@@ -606,6 +608,13 @@ mmc_set_card_bus_width(struct mmc_softc 
 
if (mmcbr_get_mode(sc->dev) == mode_sd) {
memset(&cmd, 0, sizeof(struct mmc_command));
+   cmd.opcode = ACMD_SET_CLR_CARD_DETECT;
+   cmd.flags = MMC_RSP_R1 | MMC_CMD_AC;
+   cmd.arg = SD_CLR_CARD_DETECT;
+   err = mmc_wait_for_app_cmd(sc, rca, &cmd, CMD_RETRIES);
+   if (err != 0)
+   return (err);
+   memset(&cmd, 0, sizeof(struct mmc_command));
cmd.opcode = ACMD_SET_BUS_WIDTH;
cmd.flags = MMC_RSP_R1 | MMC_CMD_AC;
switch (width) {
@@ -788,15 +797,52 @@ mmc_decode_cid_mmc(uint32_t *raw_cid, st
cid->mdt_year = mmc_get_bits(raw_cid, 128, 8, 4) + 1997;
 }
 
+static void
+mmc_format_card_id_string(struct mmc_ivars *ivar)
+{
+   char oidstr[8];
+   uint8_t c1;
+   uint8_t c2;
+
+   /*
+* Format a card ID string for use by the mmcsd driver, it's what
+* appears between the <> in the following:
+* mmcsd0: 968MB  at mmc0
+* 22.5MHz/4bit/128-block
+*
+* The card_id_string in mmc_ivars is currently allocated as 64 bytes,
+* and our max formatted length is currently 55 bytes if every field
+* contains the largest value.
+*
+* Sometimes the oid is two printable ascii chars; when it's not,
+* format it as 0x instead.
+*/
+   c1 = (ivar->cid.oid >> 8) & 0x0ff;
+   c2 = ivar->cid.oid & 0x0ff;
+   if (c1 > 0x1f && c1 < 0x7f && c2 > 0x1f && c2 < 0x7f)
+   snprintf(oidstr, sizeof(oidstr), "%c%c", c1, c2);
+   else
+   snprintf(oidstr, sizeof(oidstr), "0x%04x", ivar->cid.oid);
+   snprintf(ivar->card_id_string, sizeof(ivar->card_id_string),
+   "%s%s %s %d.%d SN %d MFG %02d/%04d by %d %s",
+   ivar->mode == mode_sd ? "SD" : "MMC", ivar->high_cap ? "HC" : "",
+   ivar->cid.pnm, ivar->cid.prv >> 4, ivar->cid.prv & 0x0f,
+   ivar->cid.psn, ivar->cid.mdt_month, ivar->cid.mdt_year,
+   ivar->cid.mid, oidstr);
+}
+
 static const int exp[8] = {
1, 10, 100, 1000, 1, 10, 100, 1000
 };
+
 static const int mant[16] = {
-   10, 12, 13, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 70, 80
+   0, 10, 12, 13, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 70, 80
 };
+
 static const int cur_min[8] = {
500, 1000, 5000, 1, 25000, 35000, 6, 10
 };
+
 static const int cur_max[8] = {
1000, 5000, 1, 25000, 35000, 45000, 80, 20
 }

svn commit: r234525 - head/sys/mips/mips

2012-04-20 Thread Adrian Chadd
Author: adrian
Date: Sat Apr 21 04:17:30 2012
New Revision: 234525
URL: http://svn.freebsd.org/changeset/base/234525

Log:
  Allow for MIPS devices to have a specific probe/attach order.
  
  The default priority is now '1000' rather than '0'.  This may cause some
  unforseen regressions.
  
  Submitted by: Stefan Bethke 
  Reviewed by:  imp

Modified:
  head/sys/mips/mips/nexus.c

Modified: head/sys/mips/mips/nexus.c
==
--- head/sys/mips/mips/nexus.c  Sat Apr 21 01:51:16 2012(r234524)
+++ head/sys/mips/mips/nexus.c  Sat Apr 21 04:17:30 2012(r234525)
@@ -237,11 +237,14 @@ nexus_hinted_child(device_t bus, const c
device_t child;
longmaddr;
int msize;
+   int order;
int result;
int irq;
int mem_hints_count;
 
-   child = BUS_ADD_CHILD(bus, 0, dname, dunit);
+   if ((resource_int_value(dname, dunit, "order", &order)) != 0)
+   order = 1000;
+   child = BUS_ADD_CHILD(bus, order, dname, dunit);
if (child == NULL)
return;
 
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r234529 - head/lib/libc/stdio

2012-04-20 Thread David Schultz
Author: das
Date: Sat Apr 21 06:08:29 2012
New Revision: 234529
URL: http://svn.freebsd.org/changeset/base/234529

Log:
  Ensure that the {,v}swprintf functions always null-terminate the
  output string, even if an encoding error or malloc failure occurs.

Modified:
  head/lib/libc/stdio/vswprintf.c

Modified: head/lib/libc/stdio/vswprintf.c
==
--- head/lib/libc/stdio/vswprintf.c Sat Apr 21 06:08:02 2012
(r234528)
+++ head/lib/libc/stdio/vswprintf.c Sat Apr 21 06:08:29 2012
(r234529)
@@ -66,6 +66,7 @@ vswprintf_l(wchar_t * __restrict s, size
f._bf._base = f._p = (unsigned char *)malloc(128);
if (f._bf._base == NULL) {
errno = ENOMEM;
+   *s = L'\0';
return (-1);
}
f._bf._size = f._w = 127;   /* Leave room for the NUL */
@@ -74,6 +75,7 @@ vswprintf_l(wchar_t * __restrict s, size
sverrno = errno;
free(f._bf._base);
errno = sverrno;
+   *s = L'\0';
return (-1);
}
*f._p = '\0';
@@ -87,6 +89,7 @@ vswprintf_l(wchar_t * __restrict s, size
free(f._bf._base);
if (nwc == (size_t)-1) {
errno = EILSEQ;
+   *s = L'\0';
return (-1);
}
if (nwc == n) {
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r234530 - head/lib/libc/stdio

2012-04-20 Thread David Schultz
Author: das
Date: Sat Apr 21 06:09:09 2012
New Revision: 234530
URL: http://svn.freebsd.org/changeset/base/234530

Log:
  - Fix the claim that the output is always null-terminated. This isn't
true if the size is zero.
  - Fix a claim that sprintf() is the same as snprintf() with an
infinite size.  It's equivalent to snprintf() with a size of
INT_MAX + 1.
  - Document the return values in the return values section.
  - Document the possible errno value of EOVERFLOW.
  
  MFC after:2 weeks

Modified:
  head/lib/libc/stdio/printf.3

Modified: head/lib/libc/stdio/printf.3
==
--- head/lib/libc/stdio/printf.3Sat Apr 21 06:08:29 2012
(r234529)
+++ head/lib/libc/stdio/printf.3Sat Apr 21 06:09:09 2012
(r234530)
@@ -113,20 +113,6 @@ string that specifies how subsequent arg
 .Xr stdarg 3 )
 are converted for output.
 .Pp
-These functions return the number of characters printed
-(not including the trailing
-.Ql \e0
-used to end output to strings) or a negative value if an output error occurs,
-except for
-.Fn snprintf
-and
-.Fn vsnprintf ,
-which return the number of characters that would have been printed if the
-.Fa size
-were unlimited
-(again, not including the final
-.Ql \e0 ) .
-.Pp
 The
 .Fn asprintf
 and
@@ -164,15 +150,19 @@ if the return value is greater than or e
 .Fa size
 argument, the string was too short
 and some of the printed characters were discarded.
-The output is always null-terminated.
+The output is always null-terminated, unless
+.Fa size
+is 0.
 .Pp
 The
 .Fn sprintf
 and
 .Fn vsprintf
 functions
-effectively assume an infinite
-.Fa size .
+effectively assume a
+.Fa size
+of
+.Dv INT_MAX + 1.
 .Pp
 The format string is composed of zero or more directives:
 ordinary
@@ -670,6 +660,21 @@ In no case does a non-existent or small 
 a numeric field; if the result of a conversion is wider than the field
 width, the
 field is expanded to contain the conversion result.
+.Sh RETURN VALUES
+These functions return the number of characters printed
+(not including the trailing
+.Ql \e0
+used to end output to strings),
+except for
+.Fn snprintf
+and
+.Fn vsnprintf ,
+which return the number of characters that would have been printed if the
+.Fa size
+were unlimited
+(again, not including the final
+.Ql \e0 ) .
+These functions return a negative value if an error occurs.
 .Sh EXAMPLES
 To print a date and time in the form
 .Dq Li "Sunday, July 3, 10:02" ,
@@ -771,6 +776,13 @@ family of functions may fail if:
 An invalid wide character code was encountered.
 .It Bq Er ENOMEM
 Insufficient storage space is available.
+.It Bq Er EOVERFLOW
+The
+.Fa size
+argument exceeds
+.Dv INT_MAX + 1 ,
+or the return value would be too large to be represented by an
+.Vt int .
 .El
 .Sh SEE ALSO
 .Xr printf 1 ,
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r234528 - head/lib/libc/stdio

2012-04-20 Thread David Schultz
Author: das
Date: Sat Apr 21 06:08:02 2012
New Revision: 234528
URL: http://svn.freebsd.org/changeset/base/234528

Log:
  Fix a bug introduced in r187302 that was causing fputws() to enter an
  infinite loop pretty much unconditionally.  It's remarkable that the
  patch that introduced the bug was never tested, but even more
  remarkable that nobody noticed for over two years.
  
  PR:   167039
  MFC after:3 days

Modified:
  head/lib/libc/stdio/fputws.c

Modified: head/lib/libc/stdio/fputws.c
==
--- head/lib/libc/stdio/fputws.cSat Apr 21 05:26:02 2012
(r234527)
+++ head/lib/libc/stdio/fputws.cSat Apr 21 06:08:02 2012
(r234528)
@@ -70,7 +70,7 @@ fputws_l(const wchar_t * __restrict ws, 
iov.iov_len = uio.uio_resid = nbytes;
if (__sfvwrite(fp, &uio) != 0)
goto error;
-   } while (ws != NULL);
+   } while (wsp != NULL);
FUNLOCKFILE(fp);
return (0);
 
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r234531 - head/lib/libc/stdio

2012-04-20 Thread David Schultz
Author: das
Date: Sat Apr 21 06:10:18 2012
New Revision: 234531
URL: http://svn.freebsd.org/changeset/base/234531

Log:
  If the size passed to {,v}s{w,n}printf is larger than INT_MAX+1
  (i.e., the return value would overflow), set errno to EOVERFLOW
  and return an error.  This improves the chances that buggy
  applications -- for instance, ones that pass in a negative integer
  as the size due to a bogus calculation -- will fail in safe ways.
  Returning an error in these situations is specified by POSIX, but
  POSIX appears to have an off-by-one error that isn't duplicated in
  this change.
  
  Previously, some of these functions would silently cap the size at
  INT_MAX+1, and others would exit with an error after writing more
  than INT_MAX characters.
  
  PR:   39256
  MFC after:2 weeks

Modified:
  head/lib/libc/stdio/snprintf.c
  head/lib/libc/stdio/vfprintf.c
  head/lib/libc/stdio/vfwprintf.c
  head/lib/libc/stdio/vsnprintf.c
  head/lib/libc/stdio/vswprintf.c

Modified: head/lib/libc/stdio/snprintf.c
==
--- head/lib/libc/stdio/snprintf.c  Sat Apr 21 06:09:09 2012
(r234530)
+++ head/lib/libc/stdio/snprintf.c  Sat Apr 21 06:10:18 2012
(r234531)
@@ -41,6 +41,7 @@ static char sccsid[] = "@(#)snprintf.c8
 #include 
 __FBSDID("$FreeBSD$");
 
+#include 
 #include 
 #include 
 #include 
@@ -59,8 +60,11 @@ snprintf(char * __restrict str, size_t n
on = n;
if (n != 0)
n--;
-   if (n > INT_MAX)
-   n = INT_MAX;
+   if (n > INT_MAX) {
+   errno = EOVERFLOW;
+   *str = '\0';
+   return (EOF);
+   }
va_start(ap, fmt);
f._flags = __SWR | __SSTR;
f._bf._base = f._p = (unsigned char *)str;
@@ -84,8 +88,11 @@ snprintf_l(char * __restrict str, size_t
on = n;
if (n != 0)
n--;
-   if (n > INT_MAX)
-   n = INT_MAX;
+   if (n > INT_MAX) {
+   errno = EOVERFLOW;
+   *str = '\0';
+   return (EOF);
+   }
va_start(ap, fmt);
f._flags = __SWR | __SSTR;
f._bf._base = f._p = (unsigned char *)str;

Modified: head/lib/libc/stdio/vfprintf.c
==
--- head/lib/libc/stdio/vfprintf.c  Sat Apr 21 06:09:09 2012
(r234530)
+++ head/lib/libc/stdio/vfprintf.c  Sat Apr 21 06:10:18 2012
(r234531)
@@ -51,6 +51,7 @@ __FBSDID("$FreeBSD$");
 #include 
 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -480,6 +481,7 @@ __vfprintf(FILE *fp, locale_t locale, co
if ((n = fmt - cp) != 0) {
if ((unsigned)ret + n > INT_MAX) {
ret = EOF;
+   errno = EOVERFLOW;
goto error;
}
PRINT(cp, n);
@@ -935,6 +937,7 @@ number: if ((dprec = prec) >= 0)
prsize = width > realsz ? width : realsz;
if ((unsigned)ret + prsize > INT_MAX) {
ret = EOF;
+   errno = EOVERFLOW;
goto error;
}
 

Modified: head/lib/libc/stdio/vfwprintf.c
==
--- head/lib/libc/stdio/vfwprintf.c Sat Apr 21 06:09:09 2012
(r234530)
+++ head/lib/libc/stdio/vfwprintf.c Sat Apr 21 06:10:18 2012
(r234531)
@@ -54,6 +54,7 @@ __FBSDID("$FreeBSD$");
 #include 
 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -553,6 +554,7 @@ __vfwprintf(FILE *fp, locale_t locale, c
if ((n = fmt - cp) != 0) {
if ((unsigned)ret + n > INT_MAX) {
ret = EOF;
+   errno = EOVERFLOW;
goto error;
}
PRINT(cp, n);
@@ -1003,6 +1005,7 @@ number:   if ((dprec = prec) >= 0)
prsize = width > realsz ? width : realsz;
if ((unsigned)ret + prsize > INT_MAX) {
ret = EOF;
+   errno = EOVERFLOW;
goto error;
}
 

Modified: head/lib/libc/stdio/vsnprintf.c
==
--- head/lib/libc/stdio/vsnprintf.c Sat Apr 21 06:09:09 2012
(r234530)
+++ head/lib/libc/stdio/vsnprintf.c Sat Apr 21 06:10:18 2012
(r234531)
@@ -41,6 +41,7 @@ static char sccsid[] = "@(#)vsnprintf.c   
 #include 
 __FBSDID("$FreeBSD$");
 
+#include 
 #include 
 #include 
 #include "local.h"
@@ -59,8 +60,11 @@ vsnprintf_l(char * __restrict str, size_
on = n;
if (n != 0)
n--;
-   if (n