Re: remove redundant information from mmap.2

2012-10-06 Thread Philip Guenther
On Sat, Oct 6, 2012 at 12:40 PM, Dawe  wrote:
> I think this information is already given in the sentences before.

No, it isn't.  The previous sentences say that MAP_FAILED is returned
on error; this one says that MAP_FAILED is *only* returned on error.
Contrast this to strtoul(), where ULONG_MAX is returned on error, but
can also be returned on success, meaning you have to do extra steps
(clear errno before, test it afterwards) to detect failure.  This
sentence is the one that makes it clear that that isn't the case with
mmap().


Philip Guenther



Re: Scheduler improvements

2012-10-06 Thread Gregor Best
Hi Alexandre,

> [...]
> This change is unclear for me; AFAIU, it removes the mechanism
> which makes processes wake up with a priority depending on what  
> they are blocked on.
> [...]

Where do you see that? The code I removed/changed simply calulated the queue 
from
which to remove `p` and removed it from there (similar for insertion). That 
needed
to be changed to modify the RB tree used as a new runqueue.

> [...]
> For instance processes waking up from poll(2) or audio read/write
> won't be prioritized any longer. If so, this would hurt audio and
> other interactive processes but would improve cpu-intesive
> bloatware.
> [...]

They weren't prioritised with the old version of this code either.

> [...]
> this change is unrelated to the rest isn't it?
> [...]

Yes, it is. I changed it because 100ms time slices felt a bit too large,
but the rest of the patch will of course work without this bit.

Thanks for taking your time to look at this :)

-- 
Gregor Best



Re: Training Course Announcement: FIDIC Conditions

2012-10-06 Thread MRE Academy
The FIDIC Conditions of Contract 1999



remove redundant information from mmap.2

2012-10-06 Thread Dawe
I think this information is already given in the sentences before.

Index: mmap.2
===
RCS file: /cvs/src/lib/libc/sys/mmap.2,v
retrieving revision 1.39
diff -u -p -u -p -r1.39 mmap.2
--- mmap.2  12 Apr 2012 12:53:27 -  1.39
+++ mmap.2  6 Oct 2012 19:35:32 -
@@ -188,10 +188,6 @@ The symbol
 .Dv MAP_FAILED
 is defined in the header
 .Ao Pa sys/mman.h Ac .
-No successful return from
-.Fn mmap
-will return the value
-.Dv MAP_FAILED .
 .Sh ERRORS
 .Fn mmap
 will fail if:



if_vr diff again, now with less bugs

2012-10-06 Thread Chris Cappuccio
i exercised the vr_encap error path by setting the TX ring size to 4, and 
discovered an unnecessary bus_dmamap_unload, also figured out that pointing the 
ring member to an mbuf before vr_encap is committed is a bad idea. also brad 
pointed out that there is no need to setup VR_MAXFRAGS * MCLBYTES dma transfer 
size for each list member. 

please test.

the end result of this diff should be lower CPU utliizaton for userland traffic 
on newer vr chips (Rhine II-2 and above, the ones that don't NEEDALIGN as you 
can easily see in the driver's quirk table) because we can get rid of buffer 
data copying by using scatter gather, and do less intensive work to pack 
segments into descriptors. 

Index: if_vr.c
===
RCS file: /cvs/src/sys/dev/pci/if_vr.c,v
retrieving revision 1.115
diff -u -r1.115 if_vr.c
--- if_vr.c 18 Sep 2012 14:49:44 -  1.115
+++ if_vr.c 6 Oct 2012 15:30:55 -
@@ -113,13 +113,16 @@
NULL, "vr", DV_IFNET
 };
 
-int vr_encap(struct vr_softc *, struct vr_chain *, struct mbuf *);
+int vr_encap(struct vr_softc *, struct vr_chain **, struct mbuf *);
 void vr_rxeof(struct vr_softc *);
 void vr_rxeoc(struct vr_softc *);
 void vr_txeof(struct vr_softc *);
 void vr_tick(void *);
 void vr_rxtick(void *);
 int vr_intr(void *);
+int vr_dmamem_alloc(struct vr_softc *, struct vr_dmamem *,
+bus_size_t, u_int);
+void vr_dmamem_free(struct vr_softc *, struct vr_dmamem *);
 void vr_start(struct ifnet *);
 int vr_ioctl(struct ifnet *, u_long, caddr_t);
 void vr_chipinit(struct vr_softc *);
@@ -481,6 +484,46 @@
return(0);
 }
 
+int
+vr_dmamem_alloc(struct vr_softc *sc, struct vr_dmamem *vrm,
+bus_size_t size, u_int align)
+{
+   vrm->vrm_size = size;
+
+   if (bus_dmamap_create(sc->sc_dmat, vrm->vrm_size, 1,
+   vrm->vrm_size, 0, BUS_DMA_WAITOK | BUS_DMA_ALLOCNOW,
+   &vrm->vrm_map) != 0)
+   return (1);
+   if (bus_dmamem_alloc(sc->sc_dmat, vrm->vrm_size,
+   align, 0, &vrm->vrm_seg, 1, &vrm->vrm_nsegs,
+   BUS_DMA_WAITOK | BUS_DMA_ZERO) != 0)
+   goto destroy;
+   if (bus_dmamem_map(sc->sc_dmat, &vrm->vrm_seg, vrm->vrm_nsegs,
+   vrm->vrm_size, &vrm->vrm_kva, BUS_DMA_WAITOK) != 0)
+   goto free;
+   if (bus_dmamap_load(sc->sc_dmat, vrm->vrm_map, vrm->vrm_kva,
+   vrm->vrm_size, NULL, BUS_DMA_WAITOK) != 0)
+   goto unmap;
+
+   return (0);
+ unmap:
+   bus_dmamem_unmap(sc->sc_dmat, vrm->vrm_kva, vrm->vrm_size);
+ free:
+   bus_dmamem_free(sc->sc_dmat, &vrm->vrm_seg, 1);
+ destroy:
+   bus_dmamap_destroy(sc->sc_dmat, vrm->vrm_map);
+   return (1);
+}
+
+void
+vr_dmamem_free(struct vr_softc *sc, struct vr_dmamem *vrm)
+{
+   bus_dmamap_unload(sc->sc_dmat, vrm->vrm_map);
+   bus_dmamem_unmap(sc->sc_dmat, vrm->vrm_kva, vrm->vrm_size);
+   bus_dmamem_free(sc->sc_dmat, &vrm->vrm_seg, 1);
+   bus_dmamap_destroy(sc->sc_dmat, vrm->vrm_map);
+}
+
 /*
  * Attach the interface. Allocate softc structures, do ifmedia
  * setup and ethernet/BPF attach.
@@ -497,8 +540,6 @@
const char  *intrstr = NULL;
struct ifnet*ifp = &sc->arpcom.ac_if;
bus_size_t  size;
-   int rseg;
-   caddr_t kva;
 
/*
 * Handle power management nonsense.
@@ -555,7 +596,7 @@
/* Allocate interrupt */
if (pci_intr_map(pa, &ih)) {
printf(": can't map interrupt\n");
-   goto fail_1;
+   goto fail;
}
intrstr = pci_intr_string(pc, ih);
sc->sc_ih = pci_intr_establish(pc, ih, IPL_NET, vr_intr, sc,
@@ -565,7 +606,7 @@
if (intrstr != NULL)
printf(" at %s", intrstr);
printf("\n");
-   goto fail_1;
+   goto fail;
}
printf(": %s", intrstr);
 
@@ -593,29 +634,20 @@
printf(", address %s\n", ether_sprintf(sc->arpcom.ac_enaddr));
 
sc->sc_dmat = pa->pa_dmat;
-   if (bus_dmamem_alloc(sc->sc_dmat, sizeof(struct vr_list_data),
-   PAGE_SIZE, 0, &sc->sc_listseg, 1, &rseg,
-   BUS_DMA_NOWAIT | BUS_DMA_ZERO)) {
-   printf(": can't alloc list\n");
-   goto fail_2;
-   }
-   if (bus_dmamem_map(sc->sc_dmat, &sc->sc_listseg, rseg,
-   sizeof(struct vr_list_data), &kva, BUS_DMA_NOWAIT)) {
-   printf(": can't map dma buffers (%d bytes)\n",
-   sizeof(struct vr_list_data));
-   goto fail_3;
-   }
-   if (bus_dmamap_create(sc->sc_dmat, sizeof(struct vr_list_data), 1,
-   sizeof(struct vr_list_data), 0, BUS_DMA_NOWAIT, &sc->sc_listmap)) {
-   printf(": can't create dma map\n");
-   goto fail_4;
-   }
-   if (bus_dmamap_load(sc->sc_dmat, sc->sc_listmap, kva,
-   sizeof(struct vr_list_data), NULL, BUS_DMA_NOWAIT))

Re: gem(4) flow control support

2012-10-06 Thread Mark Kettenis
> Date: Wed, 26 Sep 2012 00:46:29 -0400
> From: Brad Smith 
> 
> On Sat, Jul 25, 2009 at 07:14:42AM -0400, Brad wrote:
> > Please test the following diff which adds flow control support
> > with any gem(4) adapter.
> > 
> > Please provide a dmesg and "ifconfig gemX" output.
>  
> No one ever reported any issues with this so I'd like to get this
> in.
> 
> OK?

What hardware did this get tested on that actually supports flow control?

> > Index: gem.c
> > ===
> > RCS file: /cvs/src/sys/dev/ic/gem.c,v
> > retrieving revision 1.92
> > diff -u -p -r1.92 gem.c
> > --- gem.c   18 Jul 2009 14:42:47 -  1.92
> > +++ gem.c   25 Jul 2009 10:22:23 -
> > @@ -134,7 +134,7 @@ gem_config(struct gem_softc *sc)
> > struct ifnet *ifp = &sc->sc_arpcom.ac_if;
> > struct mii_data *mii = &sc->sc_mii;
> > struct mii_softc *child;
> > -   int i, error, phyad;
> > +   int i, error, mii_flags, phyad;
> > struct ifmedia_entry *ifm;
> >  
> > /* Make sure the chip is stopped. */
> > @@ -248,6 +248,8 @@ gem_config(struct gem_softc *sc)
> >  
> > gem_mifinit(sc);
> >  
> > +   mii_flags = MIIF_DOPAUSE;
> > +
> > /* 
> >  * Look for an external PHY.
> >  */
> > @@ -266,7 +268,7 @@ gem_config(struct gem_softc *sc)
> > }
> >  
> > mii_attach(&sc->sc_dev, mii, 0x, phyad,
> > -   MII_OFFSET_ANY, 0);
> > +   MII_OFFSET_ANY, mii_flags);
> > }
> >  
> > /* 
> > @@ -292,7 +294,7 @@ gem_config(struct gem_softc *sc)
> > }
> >  
> > mii_attach(&sc->sc_dev, mii, 0x, phyad,
> > -   MII_OFFSET_ANY, 0);
> > +   MII_OFFSET_ANY, mii_flags);
> > }
> >  
> > /* 
> > @@ -314,8 +316,10 @@ gem_config(struct gem_softc *sc)
> > mii->mii_readreg = gem_pcs_readreg;
> > mii->mii_writereg = gem_pcs_writereg;
> >  
> > +   mii_flags |= MIIF_NOISOLATE;
> > +
> > mii_attach(&sc->sc_dev, mii, 0x, MII_PHY_ANY,
> > -   MII_OFFSET_ANY, MIIF_NOISOLATE);
> > +   MII_OFFSET_ANY, mii_flags);
> > }
> >  
> > child = LIST_FIRST(&mii->mii_phys);
> > @@ -873,8 +877,8 @@ gem_init_regs(struct gem_softc *sc)
> > bus_space_write_4(t, h, GEM_MAC_RX_CRC_ERR_CNT, 0);
> > bus_space_write_4(t, h, GEM_MAC_RX_CODE_VIOL, 0);
> >  
> > -   /* Un-pause stuff */
> > -   bus_space_write_4(t, h, GEM_MAC_SEND_PAUSE_CMD, 0);
> > +   /* Set XOFF PAUSE time */
> > +   bus_space_write_4(t, h, GEM_MAC_SEND_PAUSE_CMD, 0x1BF0);
> >  
> > /*
> >  * Set the internal arbitration to "infinite" bursts of the
> > @@ -1331,6 +1335,17 @@ gem_mii_statchg(struct device *dev)
> > v &= ~GEM_MAC_XIF_GMII_MODE;
> > }
> > bus_space_write_4(t, mac, GEM_MAC_XIF_CONFIG, v);
> > +
> > +   /*
> > +* 802.3x flow control
> > +*/
> > +   v = bus_space_read_4(t, mac, GEM_MAC_CONTROL_CONFIG);
> > +   v &= ~(GEM_MAC_CC_RX_PAUSE | GEM_MAC_CC_TX_PAUSE);
> > +   if ((IFM_OPTIONS(sc->sc_mii.mii_media_active) & IFM_ETH_RXPAUSE) != 0)
> > +   v |= GEM_MAC_CC_RX_PAUSE;
> > +   if ((IFM_OPTIONS(sc->sc_mii.mii_media_active) & IFM_ETH_TXPAUSE) != 0)
> > +   v |= GEM_MAC_CC_TX_PAUSE;
> > +   bus_space_write_4(t, mac, GEM_MAC_CONTROL_CONFIG, v);
> >  }
> >  
> >  int
> > 
> > -- 
> > This message has been scanned for viruses and
> > dangerous content by MailScanner, and is
> > believed to be clean.
> > 
> 
> -- 
> This message has been scanned for viruses and
> dangerous content by MailScanner, and is
> believed to be clean.