Re: svn commit: r205090 - head/sys/dev/bge

2010-03-16 Thread Pyun YongHyeon
On Mon, Mar 15, 2010 at 09:31:52PM -0600, Scott Long wrote:
 On Mar 12, 2010, at 11:18 AM, Pyun YongHyeon wrote:
  Author: yongari
  Date: Fri Mar 12 18:18:04 2010
  New Revision: 205090
  URL: http://svn.freebsd.org/changeset/base/205090
  
  Log:
  Reorder interrupt handler a bit such that producer/consumer
  index of status block is read first before acknowledging the
  interrupts. Otherwise bge(4) may get stale status block as
  acknowledging an interrupt may yield another status block update.
  
 
 I'm starting a new sub-thread because it quickly became impossible to keep 
 context straight in the conversation between you and Bruce.
 
 The previous rev did this:
 
 1. Write an ACK word to the hardware
 2. perform the memory coherency protocol
 3  Cache the status descriptors
 4. Execute the interrupt handlers for the descriptors
 
 I think that your concern was that after performing step 1, the BGE hardware 
 would be free to assert a new interrupt and/or update memory in a way that 
 would interfere with steps 2-4, yes?  I don't believe that this is a valid 
 concern.  By performing the ACK first, the driver is guaranteeing that any 
 new updates done by the BGE hardware will generate a follow-on interrupt that 
 will be seen and trigger a new run through the interrupt handle.  No matter 
 where an unexpected update happens from the hardware, a new interrupt will be 
 generated and will be guaranteed to be serviced, ensuring that the update is 
 seen.  Also, the status descriptors are designed to be immune to interference 
 of this nature; they can go stale, but that can't be corrupted.  Again, going 
 stale is not bad.
 
 The previous version affirms that a race exists, but guarantees that it won't 
 be forgotten.  There's nothing wrong with this, in my opinion.  Whether 
 you're using MSI or INTx (obviously assuming that there are no hardware bugs 
 here), the race will be caught.
 
 I don't like your change because it leaves the ACK step incoherent.  By 
 deferring that write to be after the read, there's no guaranteed of when that 
 write will actually get flushed to the hardware.  It will eventually, but 
 maybe not as soon as we'd like.
 

This is valid concern and I seem to missed this. I still think
tagged status would be better way to handle interrupts but it still
does not solve the issue you mentioned. I also can see a couple of
complex code path in Linux which indicates needing of forced flush
for mail box register. Old code was safe in this regard.
I'll back out the change.
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org


svn commit: r205221 - head/sys/dev/bge

2010-03-16 Thread Pyun YongHyeon
Author: yongari
Date: Tue Mar 16 17:45:16 2010
New Revision: 205221
URL: http://svn.freebsd.org/changeset/base/205221

Log:
  Revert r205090.
  It's hard to know when the mail box register write will get flushed to
  the hardware and it may take longer.
  
  Pointed out by:   scottl

Modified:
  head/sys/dev/bge/if_bge.c

Modified: head/sys/dev/bge/if_bge.c
==
--- head/sys/dev/bge/if_bge.c   Tue Mar 16 16:55:12 2010(r205220)
+++ head/sys/dev/bge/if_bge.c   Tue Mar 16 17:45:16 2010(r205221)
@@ -3654,22 +3654,6 @@ bge_intr(void *xsc)
 #endif
 
/*
-* Do the mandatory PCI flush as well as get the link status.
-*/
-   statusword = CSR_READ_4(sc, BGE_MAC_STS)  BGE_MACSTAT_LINK_CHANGED;
-
-   /* Make sure the descriptor ring indexes are coherent. */
-   bus_dmamap_sync(sc-bge_cdata.bge_status_tag,
-   sc-bge_cdata.bge_status_map,
-   BUS_DMASYNC_POSTREAD | BUS_DMASYNC_POSTWRITE);
-   rx_prod = sc-bge_ldata.bge_status_block-bge_idx[0].bge_rx_prod_idx;
-   tx_cons = sc-bge_ldata.bge_status_block-bge_idx[0].bge_tx_cons_idx;
-   sc-bge_ldata.bge_status_block-bge_status = 0;
-   bus_dmamap_sync(sc-bge_cdata.bge_status_tag,
-   sc-bge_cdata.bge_status_map,
-   BUS_DMASYNC_PREREAD | BUS_DMASYNC_PREWRITE);
-
-   /*
 * Ack the interrupt by writing something to BGE_MBX_IRQ0_LO.  Don't
 * disable interrupts by writing nonzero like we used to, since with
 * our current organization this just gives complications and
@@ -3691,6 +3675,22 @@ bge_intr(void *xsc)
 */
bge_writembx(sc, BGE_MBX_IRQ0_LO, 0);
 
+   /*
+* Do the mandatory PCI flush as well as get the link status.
+*/
+   statusword = CSR_READ_4(sc, BGE_MAC_STS)  BGE_MACSTAT_LINK_CHANGED;
+
+   /* Make sure the descriptor ring indexes are coherent. */
+   bus_dmamap_sync(sc-bge_cdata.bge_status_tag,
+   sc-bge_cdata.bge_status_map,
+   BUS_DMASYNC_POSTREAD | BUS_DMASYNC_POSTWRITE);
+   rx_prod = sc-bge_ldata.bge_status_block-bge_idx[0].bge_rx_prod_idx;
+   tx_cons = sc-bge_ldata.bge_status_block-bge_idx[0].bge_tx_cons_idx;
+   sc-bge_ldata.bge_status_block-bge_status = 0;
+   bus_dmamap_sync(sc-bge_cdata.bge_status_tag,
+   sc-bge_cdata.bge_status_map,
+   BUS_DMASYNC_PREREAD | BUS_DMASYNC_PREWRITE);
+
if ((sc-bge_asicrev == BGE_ASICREV_BCM5700 
sc-bge_chipid != BGE_CHIPID_BCM5700_B2) ||
statusword || sc-bge_link_evt)
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org


Re: svn commit: r205165 - head/lib/libc/gen

2010-03-16 Thread Bruce Evans

On Mon, 15 Mar 2010, Poul-Henning Kamp wrote:


In message 20100316024446.a24...@delplex.bde.org, Bruce Evans writes:

On Tue, 16 Mar 2010, Bruce Evans wrote:



Due to the way that daemon() works, it is really an error to have any
open streams when it is called.  This is also undocumented, except
implicitly.  The errors are:
- unflushed output on stdout and stderr won't get flushed normally by

 

  the child.  stdout and stderr are redirected so it will go there if
  the child erroneously (?) uses these streams or simply calls exit()
  which will give the default flush.


The in-core FILE buffers are copied in the child process, so they
should most certainly not be flushed, but rather, as they correctly
are, discarded, so that when the child causes the flush, the content
is only output once.


Nope.

Even if the child causes the flush, the content of stdout and stderr
is not flushed normally since it is redirected to /dev/null.  Unflushed
input in stdin is handled more brokenly: although stdin is redirected
to /dev/null, input on it can still be read via stdin's buffer.
Inheriting unflushed input on other streams is a feature (unless these
streams are open on fd's 0-2; then these streams will have the same
corruption as std* streams open on their normal fd's 0-2).

As described in the unquoted part of my reply above, all streams should
be flushed by the parent before the fork(), so that they are flushed
normally.

daemon(3) has a lot to say about problems with open fd's 0-2, but it
says nothing about the extra problems with open streams on these
descriptors.  It documents as a feature that fd's above 2 are inherited
normally.  It also says too little about the implementation always
using fork() (it cross-references fork() but doesn't say that the
context is always a child context on successful completion).

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


svn commit: r205222 - in head: sbin/ifconfig sys/net

2010-03-16 Thread Qing Li
Author: qingli
Date: Tue Mar 16 17:59:12 2010
New Revision: 205222
URL: http://svn.freebsd.org/changeset/base/205222

Log:
  Verify interface up status using its link state only
  if the interface has such capability. The interface
  capability flag indicates whether such capability
  exists. This approach is much more backward compatible.
  Physical device driver changes will be part of another
  commit.
  
  Also updated the ifconfig utility to show the LINKSTATE
  capability if present.
  
  Reviewed by:  rwatson, imp, juli
  MFC after:3 days

Modified:
  head/sbin/ifconfig/ifconfig.c
  head/sys/net/if.h
  head/sys/net/if_tap.c
  head/sys/net/if_tun.c
  head/sys/net/route.h

Modified: head/sbin/ifconfig/ifconfig.c
==
--- head/sbin/ifconfig/ifconfig.c   Tue Mar 16 17:45:16 2010
(r205221)
+++ head/sbin/ifconfig/ifconfig.c   Tue Mar 16 17:59:12 2010
(r205222)
@@ -881,7 +881,7 @@ unsetifdescr(const char *val, int value,
 #defineIFCAPBITS \
 \020\1RXCSUM\2TXCSUM\3NETCONS\4VLAN_MTU\5VLAN_HWTAGGING\6JUMBO_MTU\7POLLING \
 \10VLAN_HWCSUM\11TSO4\12TSO6\13LRO\14WOL_UCAST\15WOL_MCAST\16WOL_MAGIC \
-\21VLAN_HWFILTER\23VLAN_HWTSO
+\21VLAN_HWFILTER\23VLAN_HWTSO\24LINKSTATE
 
 /*
  * Print the status of the interface.  If an address family was

Modified: head/sys/net/if.h
==
--- head/sys/net/if.h   Tue Mar 16 17:45:16 2010(r205221)
+++ head/sys/net/if.h   Tue Mar 16 17:59:12 2010(r205222)
@@ -219,6 +219,7 @@ struct if_data {
 #defineIFCAP_VLAN_HWFILTER 0x1 /* interface hw can filter vlan 
tag */
 #defineIFCAP_POLLING_NOCOUNT   0x2 /* polling ticks cannot be 
fragmented */
 #defineIFCAP_VLAN_HWTSO0x4 /* can do IFCAP_TSO on VLANs */
+#defineIFCAP_LINKSTATE 0x8 /* the runtime link state is 
dynamic */
 
 #define IFCAP_HWCSUM   (IFCAP_RXCSUM | IFCAP_TXCSUM)
 #defineIFCAP_TSO   (IFCAP_TSO4 | IFCAP_TSO6)

Modified: head/sys/net/if_tap.c
==
--- head/sys/net/if_tap.c   Tue Mar 16 17:45:16 2010(r205221)
+++ head/sys/net/if_tap.c   Tue Mar 16 17:59:12 2010(r205222)
@@ -443,6 +443,8 @@ tapcreate(struct cdev *dev)
ifp-if_mtu = ETHERMTU;
ifp-if_flags = (IFF_BROADCAST|IFF_SIMPLEX|IFF_MULTICAST);
ifp-if_snd.ifq_maxlen = ifqmaxlen;
+   ifp-if_capabilities |= IFCAP_LINKSTATE;
+   ifp-if_capenable |= IFCAP_LINKSTATE;
 
dev-si_drv1 = tp;
tp-tap_dev = dev;

Modified: head/sys/net/if_tun.c
==
--- head/sys/net/if_tun.c   Tue Mar 16 17:45:16 2010(r205221)
+++ head/sys/net/if_tun.c   Tue Mar 16 17:59:12 2010(r205222)
@@ -386,6 +386,8 @@ tuncreate(const char *name, struct cdev 
ifp-if_snd.ifq_drv_maxlen = 0;
IFQ_SET_READY(ifp-if_snd);
knlist_init_mtx(sc-tun_rsel.si_note, NULL);
+   ifp-if_capabilities |= IFCAP_LINKSTATE;
+   ifp-if_capenable |= IFCAP_LINKSTATE;
 
if_attach(ifp);
bpfattach(ifp, DLT_NULL, sizeof(u_int32_t));

Modified: head/sys/net/route.h
==
--- head/sys/net/route.hTue Mar 16 17:45:16 2010(r205221)
+++ head/sys/net/route.hTue Mar 16 17:59:12 2010(r205222)
@@ -319,8 +319,7 @@ struct rt_addrinfo {
 
 #ifdef _KERNEL
 
-#define RT_LINK_IS_UP(ifp) (((ifp)-if_flags  \
- (IFF_LOOPBACK | IFF_POINTOPOINT)) \
+#define RT_LINK_IS_UP(ifp) (!((ifp)-if_capabilities  IFCAP_LINKSTATE) \
 || (ifp)-if_link_state == LINK_STATE_UP)
 
 #defineRT_LOCK_INIT(_rt) \
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org


Re: svn commit: r205221 - head/sys/dev/bge

2010-03-16 Thread Matthew Jacob




   Pointed out by:  scottl

   


1st bde

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


Re: svn commit: r205221 - head/sys/dev/bge

2010-03-16 Thread Pyun YongHyeon
On Tue, Mar 16, 2010 at 10:59:50AM -0700, Matthew Jacob wrote:
 
 
Pointed out by:   scottl
 

 
 1st bde
 

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


svn commit: r205223 - head/sys/fs/fdescfs

2010-03-16 Thread Jung-uk Kim
Author: jkim
Date: Tue Mar 16 19:59:14 2010
New Revision: 205223
URL: http://svn.freebsd.org/changeset/base/205223

Log:
  Fix a long standing regression of readdir(3) in fdescfs(5) introduced
  in r1.48.  We were stopping at the first null pointer when multiple file
  descriptors were opened and one in the middle was closed.  This restores
  traditional behaviour of fdescfs.
  
  MFC after:3 days

Modified:
  head/sys/fs/fdescfs/fdesc_vnops.c

Modified: head/sys/fs/fdescfs/fdesc_vnops.c
==
--- head/sys/fs/fdescfs/fdesc_vnops.c   Tue Mar 16 17:59:12 2010
(r205222)
+++ head/sys/fs/fdescfs/fdesc_vnops.c   Tue Mar 16 19:59:14 2010
(r205223)
@@ -522,11 +522,10 @@ fdesc_readdir(ap)
 
FILEDESC_SLOCK(fdp);
while (i  fdp-fd_nfiles + 2  uio-uio_resid = UIO_MX) {
+   bzero((caddr_t)dp, UIO_MX);
switch (i) {
case 0: /* `.' */
case 1: /* `..' */
-   bzero((caddr_t)dp, UIO_MX);
-
dp-d_fileno = i + FD_ROOT;
dp-d_namlen = i + 1;
dp-d_reclen = UIO_MX;
@@ -535,26 +534,24 @@ fdesc_readdir(ap)
dp-d_type = DT_DIR;
break;
default:
-   if (fdp-fd_ofiles[fcnt] == NULL) {
-   FILEDESC_SUNLOCK(fdp);
-   goto done;
-   }
-
-   bzero((caddr_t) dp, UIO_MX);
+   if (fdp-fd_ofiles[fcnt] == NULL)
+   break;
dp-d_namlen = sprintf(dp-d_name, %d, fcnt);
dp-d_reclen = UIO_MX;
dp-d_type = DT_UNKNOWN;
dp-d_fileno = i + FD_DESC;
break;
}
-   /*
-* And ship to userland
-*/
-   FILEDESC_SUNLOCK(fdp);
-   error = uiomove(dp, UIO_MX, uio);
-   if (error)
-   goto done;
-   FILEDESC_SLOCK(fdp);
+   if (dp-d_namlen != 0) {
+   /*
+* And ship to userland
+*/
+   FILEDESC_SUNLOCK(fdp);
+   error = uiomove(dp, UIO_MX, uio);
+   if (error)
+   goto done;
+   FILEDESC_SLOCK(fdp);
+   }
i++;
fcnt++;
}
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org


svn commit: r205233 - head/usr.bin/find

2010-03-16 Thread Pawel Jakub Dawidek
Author: pjd
Date: Tue Mar 16 23:19:55 2010
New Revision: 205233
URL: http://svn.freebsd.org/changeset/base/205233

Log:
  Better way to find out available file system types is to use lsvfs(1).
  Using 'sysctl vfs' is not only ugly, but is also not reliable - not all
  file system types create entries in vfs sysctl tree.
  
  Reviewed by:  imp
  MFC after:1 week

Modified:
  head/usr.bin/find/find.1

Modified: head/usr.bin/find/find.1
==
--- head/usr.bin/find/find.1Tue Mar 16 22:28:07 2010(r205232)
+++ head/usr.bin/find/find.1Tue Mar 16 23:19:55 2010(r205233)
@@ -35,7 +35,7 @@
 .\@(#)find.1  8.7 (Berkeley) 5/9/95
 .\ $FreeBSD$
 .\
-.Dd February 24, 2008
+.Dd March 17, 2010
 .Dt FIND 1
 .Os
 .Sh NAME
@@ -429,12 +429,9 @@ bits match those of
 True if the file is contained in a file system of type
 .Ar type .
 The
-.Xr sysctl 8
+.Xr lsvfs 1
 command can be used to find out the types of file systems
-that are available on the system:
-.Pp
-.Dl sysctl vfs
-.Pp
+that are available on the system.
 In addition, there are two pseudo-types,
 .Dq Li local
 and
@@ -947,6 +944,7 @@ section below for details.
 .Xr chmod 1 ,
 .Xr cvs 1 ,
 .Xr locate 1 ,
+.Xr lsvfs 1 ,
 .Xr whereis 1 ,
 .Xr which 1 ,
 .Xr xargs 1 ,
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org


svn commit: r205239 - vendor/bind9/9.6.2-P1

2010-03-16 Thread Doug Barton
Author: dougb
Date: Wed Mar 17 05:54:46 2010
New Revision: 205239
URL: http://svn.freebsd.org/changeset/base/205239

Log:
  Tag the 9.6.2-P1 release

Added:
  vendor/bind9/9.6.2-P1/
 - copied from r205238, vendor/bind9/dist/
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org