Re: requests for perl XS code

2010-10-17 Thread Marc Espie
On Sat, Oct 16, 2010 at 03:54:50PM -0700, Philip Guenther wrote:
 On 10/16/10, Marc Espie es...@nerim.net wrote:
  I could use bundled code to do the following:
  1/ direct interface to mkstemp
  so that we don't have to use the atrocious File::Temp big monstrosity.
 
 I've sent Marc a tiny mkdtemp/mkstemp/mkstemps-via-XS module, so
 unless he barfs all over it this one is done.
 
 
  2/ file descriptor passing over sockets
  means redoing the stuff described in socket/recv/CMSG_DATA
  so that we could have a simple interface to grab stuff in perl.
 
 Marc, do you have an API in mind that someone working on this should aim for?

Mostly some XS wrapper around the recvmsg/CMSG_DATA part.
Then some perl glue that would allow one to grab those data, and gets
the fds from it.

It should probably only extract the msgs, let normal stuff grab non 
out-of-band data IO, and create an array of those, with level/type/data.

If you want to do the send part as well, it should be reversed.

What I'm talking about is mostly wrapping around recvmsg/sendmsg
and CMSG_DATA pack/unpack type routines.



Re: update pms driver

2010-10-17 Thread Alexandr Shadchin
On Sun, Oct 17, 2010 at 06:34:23AM -0400, Kenneth R Westerback wrote:
 On Sat, Oct 16, 2010 at 09:00:43PM +0600, Alexandr Shadchin wrote:
  On Sat, Oct 16, 2010 at 03:42:10PM +0100, Nicholas Marriott wrote:
   pmsinput could have a newline after the return type like the rest,
   otherwise looks good for me.
   
  
  I agree, did not notice :)
  Fixed
  
  -- 
  Alexandr Shadchin
 
 The diff diddn't compile due to ';' in pmsprobe(). Make sure you at least
 compile diffs, lest we start trusting you and committing without compiling
 ourselves!

Right now wanted to write about this error.
I have two laptops. Second forgot to sync. I'll try to be more attentive.

 
 Done. Next? :-).
 
  Ken

Simplified pmsprobe(), no functional change.

-- 
Alexandr Shadchin

Index: pms.c
===
RCS file: /cvs/src/sys/dev/pckbc/pms.c,v
retrieving revision 1.10
diff -u -p -r1.10 pms.c
--- pms.c   17 Oct 2010 10:32:00 -  1.10
+++ pms.c   17 Oct 2010 11:30:24 -
@@ -134,21 +134,10 @@ pmsprobe(struct device *parent, void *ma
/* reset the device */
cmd[0] = PMS_RESET;
res = pckbc_poll_cmd(pa-pa_tag, pa-pa_slot, cmd, 1, 2, resp, 1);
-   if (res) {
+   if (res || resp[0] != PMS_RSTDONE || resp[1] != 0) {
 #ifdef DEBUG
-   printf(pmsprobe: reset error %d\n, res);
-#endif
-   return (0);
-   }
-   if (resp[0] != PMS_RSTDONE) {
-   printf(pmsprobe: reset response 0x%x\n, resp[0]);
-   return (0);
-   }
-
-   /* get type number (0 = mouse) */
-   if (resp[1] != 0) {
-#ifdef DEBUG
-   printf(pmsprobe: type 0x%x\n, resp[1]);
+   printf(pms: reset error %d (response 0x%02x, type 0x%02x)\n,
+   res, resp[0], resp[1]);
 #endif
return (0);
}



aucat: remove few useless macros

2010-10-17 Thread Alexandre Ratchov
this diff is to slightly clean up aucat headers and shouldn't change
its behavior. Since there are a lot of changes, it's worth testing it,
imo.

-- Alexandre

Index: lib/libsndio/aucat.c
===
RCS file: /cvs/src/lib/libsndio/aucat.c,v
retrieving revision 1.41
diff -u -p -r1.41 aucat.c
--- lib/libsndio/aucat.c5 Jun 2010 16:00:52 -   1.41
+++ lib/libsndio/aucat.c17 Oct 2010 12:03:03 -
@@ -261,11 +261,7 @@ sio_open_aucat(const char *str, unsigned
AMSG_INIT(hdl-wmsg);
hdl-wmsg.cmd = AMSG_HELLO;
hdl-wmsg.u.hello.version = AMSG_VERSION;
-   hdl-wmsg.u.hello.proto = 0;
-   if (mode  SIO_PLAY)
-   hdl-wmsg.u.hello.proto |= AMSG_PLAY;
-   if (mode  SIO_REC)
-   hdl-wmsg.u.hello.proto |= AMSG_REC;
+   hdl-wmsg.u.hello.mode = mode;
strlcpy(hdl-wmsg.u.hello.who, __progname,
sizeof(hdl-wmsg.u.hello.who));
strlcpy(hdl-wmsg.u.hello.opt, opt,
Index: lib/libsndio/mio_thru.c
===
RCS file: /cvs/src/lib/libsndio/mio_thru.c,v
retrieving revision 1.10
diff -u -p -r1.10 mio_thru.c
--- lib/libsndio/mio_thru.c 21 Jul 2010 23:00:16 -  1.10
+++ lib/libsndio/mio_thru.c 17 Oct 2010 12:03:03 -
@@ -119,11 +119,7 @@ thru_open(const char *str, char *sock, u
AMSG_INIT(msg);
msg.cmd = AMSG_HELLO;
msg.u.hello.version = AMSG_VERSION;
-   msg.u.hello.proto = 0;
-   if (mode  MIO_IN)
-   msg.u.hello.proto |= AMSG_MIDIIN;
-   if (mode  MIO_OUT)
-   msg.u.hello.proto |= AMSG_MIDIOUT;
+   msg.u.hello.mode = mode;
strlcpy(msg.u.hello.opt, opt, sizeof(msg.u.hello.opt));
strlcpy(msg.u.hello.who, __progname, sizeof(msg.u.hello.who));
n = write(s, msg, sizeof(struct amsg));
Index: usr.bin/aucat/abuf.h
===
RCS file: /cvs/src/usr.bin/aucat/abuf.h,v
retrieving revision 1.22
diff -u -p -r1.22 abuf.h
--- usr.bin/aucat/abuf.h6 Apr 2010 20:07:01 -   1.22
+++ usr.bin/aucat/abuf.h17 Oct 2010 12:03:03 -
@@ -19,11 +19,6 @@
 
 #include sys/queue.h
 
-#define XRUN_IGNORE0   /* on xrun silently insert/discard samples */
-#define XRUN_SYNC  1   /* catchup to sync to the mix/sub */
-#define XRUN_ERROR 2   /* xruns are errors, eof/hup buffer */
-#define MIDI_MSGMAX16  /* max size of MIDI messaage */
-
 struct aproc;
 struct aparams;
 
@@ -62,6 +57,7 @@ struct abuf {
unsigned used;  /* bytes used from ``msg'' */
unsigned idx;   /* actual MIDI message size */
unsigned len;   /* MIDI message length */
+#define MIDI_MSGMAX16  /* max size of MIDI messaage */
unsigned char msg[MIDI_MSGMAX];
} midi;
} r;
@@ -75,7 +71,7 @@ struct abuf {
} mix;
struct {
unsigned done;  /* frames copied */
-   unsigned xrun;  /* overrun policy */
+   unsigned xrun;  /* overrun policy, one of XRUN_XXX */
int silence;/* silence to add on next write */
} sub;
} w;
Index: usr.bin/aucat/amsg.h
===
RCS file: /cvs/src/usr.bin/aucat/amsg.h,v
retrieving revision 1.17
diff -u -p -r1.17 amsg.h
--- usr.bin/aucat/amsg.h5 Jun 2010 12:45:48 -   1.17
+++ usr.bin/aucat/amsg.h17 Oct 2010 12:03:03 -
@@ -18,6 +18,7 @@
 #define AMSG_H
 
 #include stdint.h
+#include conf.h
 
 /*
  * WARNING: since the protocol may be simultaneously used by static
@@ -46,9 +47,6 @@ struct amsg {
union {
struct amsg_par {
uint8_t legacy_mode;/* compat for old libs */
-#define AMSG_IGNORE0   /* loose sync */
-#define AMSG_SYNC  1   /* resync after xrun */
-#define AMSG_ERROR 2   /* kill the stream */
uint8_t xrun;   /* one of above */
uint8_t bps;/* bytes per sample */
uint8_t bits;   /* actually used bits */
@@ -84,13 +82,7 @@ struct amsg {
uint32_t ctl;
} vol;
struct amsg_hello {
-#define AMSG_PLAY  0x1 /* audio playback */
-#define AMSG_REC   0x2 /* audio recording */
-#define AMSG_MIDIIN0x4 /* MIDI thru input */
-#define AMSG_MIDIOUT   0x8 /* MIDI thru output */
-#define AMSG_MON   0x10/* audio monitoring */
-#define AMSG_RECMASK   (AMSG_REC | AMSG_MON)   /* can record ? */
-   

Re: vfprintf.c: use ssize_t for ssizearg

2010-10-17 Thread Philip Guenther
On Sat, Oct 16, 2010 at 6:41 PM, Claus Assmann
ca+openbsd_t...@esmtp.org wrote:
 Should the type of ssizearg be ssize_t?

Yep, at least as long as it exists as a distinct member in that union.
 I see FreeBSD at least has tossed it and uses the size_t member to
store ssize_t values, which is indeed guaranteed to be safe, but
there's no reason not to make the quick fix now.  Committed.


Philip Guenther



usb xfer timeout issue

2010-10-17 Thread Jacob Meuser
when a usb transfer (xfer) is started, the underlying hci driver
adds a timeout that adds a usb task that aborts the xfer.

if an xfer is synchronous, the upper usb layer sleeps waiting for
the xfer to complete.  it will also be woken up by the above mentioned
abort task if the xfer times out.

but what happens if a synchronous xfer run in the task thread stalls?
it can't be aborted by the abort task, because that won't run until
after the xfer wakes up!

I'm pretty sure this is what's causing the boot hangs in PR 6491 and
the one reported on m...@.

afaics, this issue is not new, but now that we're using the task
thread for attach/detach, we're more likely to hit it.

the patch below solves the issue by running another task thread that
is to be used ONLY for abort tasks.  I first looked at making the
upper usb layer timeout on it's own, but that's not possible without
major redesign.  I also thought about making the abort tasks workq
tasks, but that doesn't work because there is more than one way to
abort an xfer, and we may need to abort the abort task.  workqs have
no way to remove tasks from the queue but this is possible with
usb tasks.

it's not terribly easy to trigger an xfer timeout, but I did get at
least two, and things did recover.

unless someone sees a problem, or has a better solution, I think this
should go in soon.

yes, I had to hit each driver that uses usb tasks, but I think it's
also better to be explicit, now that we have 3 different types of
usb tasks ...

-- 
jake...@sdf.lonestar.org
SDF Public Access UNIX System - http://sdf.lonestar.org

Index: ehci.c
===
RCS file: /cvs/src/sys/dev/usb/ehci.c,v
retrieving revision 1.112
diff -u -p ehci.c
--- ehci.c  29 Sep 2010 20:06:38 -  1.112
+++ ehci.c  17 Oct 2010 22:12:50 -
@@ -1221,7 +1221,7 @@ ehci_allocx(struct usbd_bus *bus)
if (xfer != NULL) {
memset(xfer, 0, sizeof(struct ehci_xfer));
usb_init_task(EXFER(xfer)-abort_task, ehci_timeout_task,
-   xfer);
+   xfer, USB_TASK_TYPE_ABORT);
EXFER(xfer)-ehci_xfer_flags = 0;
 #ifdef DIAGNOSTIC
EXFER(xfer)-isdone = 1;
Index: if_atu.c
===
RCS file: /cvs/src/sys/dev/usb/if_atu.c,v
retrieving revision 1.94
diff -u -p if_atu.c
--- if_atu.c21 Nov 2009 14:18:34 -  1.94
+++ if_atu.c17 Oct 2010 22:12:51 -
@@ -1467,7 +1467,7 @@ atu_complete_attach(struct atu_softc *sc)
/* setup ifmedia interface */
ieee80211_media_init(ifp, atu_media_change, atu_media_status);
 
-   usb_init_task(sc-sc_task, atu_task, sc);
+   usb_init_task(sc-sc_task, atu_task, sc, USB_TASK_TYPE_GENERIC);
 
 #if NBPFILTER  0
bpfattach(sc-sc_radiobpf, sc-sc_ic.ic_if, DLT_IEEE802_11_RADIO,
Index: if_aue.c
===
RCS file: /cvs/src/sys/dev/usb/if_aue.c,v
retrieving revision 1.79
diff -u -p if_aue.c
--- if_aue.c24 Sep 2010 08:33:58 -  1.79
+++ if_aue.c17 Oct 2010 22:12:51 -
@@ -734,8 +734,10 @@ aue_attach(struct device *parent, struct device *self,
return;
}
 
-   usb_init_task(sc-aue_tick_task, aue_tick_task, sc);
-   usb_init_task(sc-aue_stop_task, (void (*)(void *))aue_stop, sc);
+   usb_init_task(sc-aue_tick_task, aue_tick_task, sc,
+   USB_TASK_TYPE_GENERIC);
+   usb_init_task(sc-aue_stop_task, (void (*)(void *))aue_stop, sc,
+   USB_TASK_TYPE_GENERIC);
rw_init(sc-aue_mii_lock, auemii);
 
err = usbd_device2interface_handle(dev, AUE_IFACE_IDX, iface);
Index: if_axe.c
===
RCS file: /cvs/src/sys/dev/usb/if_axe.c,v
retrieving revision 1.99
diff -u -p if_axe.c
--- if_axe.c24 Sep 2010 03:21:21 -  1.99
+++ if_axe.c17 Oct 2010 22:12:51 -
@@ -676,9 +676,11 @@ axe_attach(struct device *parent, struct device *self,
 
sc-axe_flags = axe_lookup(uaa-vendor, uaa-product)-axe_flags;
 
-   usb_init_task(sc-axe_tick_task, axe_tick_task, sc);
+   usb_init_task(sc-axe_tick_task, axe_tick_task, sc,
+   USB_TASK_TYPE_GENERIC);
rw_init(sc-axe_mii_lock, axemii);
-   usb_init_task(sc-axe_stop_task, (void (*)(void *))axe_stop, sc);
+   usb_init_task(sc-axe_stop_task, (void (*)(void *))axe_stop, sc,
+   USB_TASK_TYPE_GENERIC);
 
err = usbd_device2interface_handle(dev, AXE_IFACE_IDX, sc-axe_iface);
if (err) {
Index: if_cue.c
===
RCS file: /cvs/src/sys/dev/usb/if_cue.c,v
retrieving revision 1.53
diff -u -p if_cue.c
--- if_cue.c24 Sep 2010 08:33:58 -  1.53
+++ if_cue.c17 Oct 2010 22:12:51 -
@@ -470,8 +470,10 @@ cue_attach(struct device *parent, struct device *self,
sc-cue_product = 

pflog alignment fix

2010-10-17 Thread Henning Brauer
so just pad the header to be a mutiple of 8 bytes, makes pflogd happy
on 64bit archs

Index: if_pflog.h
===
RCS file: /cvs/src/sys/net/if_pflog.h,v
retrieving revision 1.17
diff -u -p -r1.17 if_pflog.h
--- if_pflog.h  21 Sep 2010 11:05:10 -  1.17
+++ if_pflog.h  17 Oct 2010 22:02:47 -
@@ -59,6 +59,7 @@ struct pfloghdr {
struct pf_addr  daddr;
u_int16_t   sport;
u_int16_t   dport;
+   u_int8_tpad2[4];
 };
 
 #define PFLOG_HDRLEN   sizeof(struct pfloghdr)



Re: requests for perl XS code

2010-10-17 Thread Damien Miller
On Sun, 17 Oct 2010, Marc Espie wrote:

 Mostly some XS wrapper around the recvmsg/CMSG_DATA part.
 Then some perl glue that would allow one to grab those data, and gets
 the fds from it.
 
 It should probably only extract the msgs, let normal stuff grab non 
 out-of-band data IO, and create an array of those, with level/type/data.
 
 If you want to do the send part as well, it should be reversed.
 
 What I'm talking about is mostly wrapping around recvmsg/sendmsg
 and CMSG_DATA pack/unpack type routines.

We had talked about putting fdpassing functions into libutil at one
stage. IMO it would be better to go ahead with this and then wrap
the result.

-d