Re: pipex fails to send ack-only GRE message from npppd

2010-09-29 Thread Claudio Jeker
On Mon, Sep 27, 2010 at 11:31:30AM +0900, Hiroki Suenaga wrote:
 Can we assume m0 have at least sizeof(struct pipex_gre_header) bytes?
 If m0 is too short, m_coypdata() will cause panic.
 
 I'm not sure, but to check m_pktlen is safe.

It is save because pipex_pptp_userland_lookup_session() is called
previously and there is a check to ensure that sizeof(struct
pipex_gre_header) bytes are available.

 
 2010/9/27 YASUOKA Masahiko yasu...@openbsd.org
 
 
  pipex_pptp_userland_output() calls always m_pullup() 16 bytes to the
  GRE message.  But when npppd send a ack-only GRE message, the message
  will be only 12 bytes, so the m_pullup() will fail.  call m_pullup()
  with proper length.
 
  ok?
 
  --- pipex.c-ORIGMon Sep 27 09:32:16 2010
  +++ pipex.c Mon Sep 27 09:46:54 2010
  @@ -1808,22 +1808,30 @@ pipex_pptp_userland_lookup_session(struct mbuf *m0,
  st
   struct mbuf *
   pipex_pptp_userland_output(struct mbuf *m0, struct pipex_session *session)
   {
  -   struct pipex_gre_header *gre;
  +   int len;
  +   struct pipex_gre_header *gre, gre0;
 uint16_t flags;
 u_char *cp, *cp0;
 uint32_t val32;
 
  +   len = sizeof(struct pipex_gre_header);
  +   m_copydata(m0, 0, len, (caddr_t)gre0);
  +   gre = gre0;
  +   flags = ntohs(gre-flags);
  +   if ((flags  PIPEX_GRE_SFLAG) != 0)
  +   len += 4;
  +   if ((flags  PIPEX_GRE_AFLAG) != 0)
  +   len += 4;
  +
 /* check length */
  -   PIPEX_PULLUP(m0, sizeof(struct pipex_gre_header) + 8);
  +   PIPEX_PULLUP(m0, len);
 if (m0 == NULL) {
  -   PIPEX_DBG((session, LOG_DEBUG,
  -   gre header is too short.));
  +   PIPEX_DBG((session, LOG_DEBUG, gre header is too
  short.));
 return (NULL);
 }
 
 gre = mtod(m0, struct pipex_gre_header *);
 cp = PIPEX_SEEK_NEXTHDR(gre, sizeof(struct pipex_gre_header), u_char
  *);
  -   flags = ntohs(gre-flags);
 
 /*
  * overwrite sequence numbers to adjust a gap between pipex and
 
 
 
 
 -- 
 -
 SUENAGA Hiroki
 hsuen...@openbsd.org
 

-- 
:wq Claudio



missing include in init.c

2010-09-29 Thread David Coppa
/usr/src/sbin/init/init.c: In function 'new_session':
/usr/src/sbin/init/init.c:867: warning: implicit declaration of function 'err'

Trivial diff following: 

Index: init.c
===
RCS file: /cvs/src/sbin/init/init.c,v
retrieving revision 1.42
diff -u -p -r1.42 init.c
--- init.c  7 Aug 2010 10:22:28 -   1.42
+++ init.c  29 Sep 2010 09:03:58 -
@@ -39,6 +39,7 @@
 #include sys/reboot.h
 
 #include db.h
+#include err.h
 #include errno.h
 #include fcntl.h
 #include signal.h



softraid cleanup

2010-09-29 Thread Marco Peereboom
I have been running with this for months and would like to revive the
idea.  This adds a workq for all IO handling in softraid crypto and raid
1.  This fixes the violation of VOP_STRATEGY being called from interrupt
context.

I plan on doing something more sophisticated at a later point that would
handle rebuild/scrub/md IO through the same path but I think it is worth
it to get the workq stuff in and then cut the individual pieces in one
at at a time.

I am looking for test reports and oks.  If I don't get any I am going to
move forward with it and everyone gets to test it.

Index: softraid.c
===
RCS file: /cvs/src/sys/dev/softraid.c,v
retrieving revision 1.214
diff -u -p -r1.214 softraid.c
--- softraid.c  23 Sep 2010 18:49:39 -  1.214
+++ softraid.c  27 Sep 2010 22:13:55 -
@@ -126,6 +126,7 @@ voidsr_rebuild(void *);
 void   sr_rebuild_thread(void *);
 void   sr_roam_chunks(struct sr_discipline *);
 intsr_chunk_in_use(struct sr_softc *, dev_t);
+void   sr_startwu_callback(void *, void *);
 
 /* don't include these on RAMDISK */
 #ifndef SMALL_KERNEL
@@ -1806,6 +1807,8 @@ sr_wu_put(struct sr_workunit *wu)
wu-swu_fake = 0;
wu-swu_flags = 0;
 
+   if (wu-swu_cb_active == 1)
+   panic(%s: sr_wu_put, DEVNAME(sd-sd_sc));
while ((ccb = TAILQ_FIRST(wu-swu_ccb)) != NULL) {
TAILQ_REMOVE(wu-swu_ccb, ccb, ccb_link);
sr_ccb_put(ccb);
@@ -2563,6 +2566,9 @@ sr_hotspare_rebuild(struct sr_discipline
busy = 0;
 
s = splbio();
+   if (wu-swu_cb_active == 1)
+   panic(%s: sr_hotspare_rebuild,
+   DEVNAME(sd-sd_sc));
TAILQ_FOREACH(wu, sd-sd_wu_pendq, swu_link) {
TAILQ_FOREACH(ccb, wu-swu_ccb, ccb_link) {
if (ccb-ccb_target == chunk_no)
@@ -2816,6 +2822,11 @@ sr_ioctl_createraid(struct sr_softc *sc,
sd = malloc(sizeof(struct sr_discipline), M_DEVBUF, M_WAITOK | M_ZERO);
sd-sd_sc = sc;
SLIST_INIT(sd-sd_meta_opt);
+   sd-sd_workq = workq_create(srdis, 1, IPL_BIO);
+   if (sd-sd_workq == NULL) {
+   printf(%s: could not create workq\n);
+   goto unwind;
+   }
if (sr_discipline_init(sd, bc-bc_level)) {
printf(%s: could not initialize discipline\n, DEVNAME(sc));
goto unwind;
@@ -3407,6 +3418,9 @@ sr_discipline_shutdown(struct sr_discipl
 
sr_chunks_unwind(sc, sd-sd_vol.sv_chunk_list);
 
+   if (sd-sd_workq)
+   workq_destroy(sd-sd_workq);
+
if (sd)
sr_discipline_free(sd);
 
@@ -3624,10 +3638,26 @@ sr_raid_sync(struct sr_workunit *wu)
 }
 
 void
+sr_startwu_callback(void *arg1, void *arg2)
+{
+   struct sr_discipline*sd = arg1;
+   struct sr_workunit  *wu = arg2;
+   struct sr_ccb   *ccb;
+
+   if (wu-swu_cb_active == 1)
+   panic(%s: sr_startwu_callback, DEVNAME(sd-sd_sc));
+   wu-swu_cb_active = 1;
+
+   TAILQ_FOREACH(ccb, wu-swu_ccb, ccb_link)
+   VOP_STRATEGY(ccb-ccb_buf);
+
+   wu-swu_cb_active = 0;
+}
+
+void
 sr_raid_startwu(struct sr_workunit *wu)
 {
struct sr_discipline*sd = wu-swu_dis;
-   struct sr_ccb   *ccb;
 
splassert(IPL_BIO);
 
@@ -3641,10 +3671,9 @@ sr_raid_startwu(struct sr_workunit *wu)
/* move wu to pending queue */
TAILQ_INSERT_TAIL(sd-sd_wu_pendq, wu, swu_link);
 
-   /* start all individual ios */
-   TAILQ_FOREACH(ccb, wu-swu_ccb, ccb_link) {
-   VOP_STRATEGY(ccb-ccb_buf);
-   }
+   /* start all individual ios */
+   workq_queue_task(sd-sd_workq, wu-swu_wqt, 0, sr_startwu_callback,
+   sd, wu);
 }
 
 void
Index: softraid_crypto.c
===
RCS file: /cvs/src/sys/dev/softraid_crypto.c,v
retrieving revision 1.57
diff -u -p -r1.57 softraid_crypto.c
--- softraid_crypto.c   27 Sep 2010 19:49:43 -  1.57
+++ softraid_crypto.c   27 Sep 2010 22:13:55 -
@@ -164,11 +164,11 @@ sr_crypto_create(struct sr_discipline *s
 
} else if (sr_crypto_get_kdf(bc, sd))
goto done;
- 
+
/* Passphrase volumes cannot be automatically assembled. */
if (!(bc-bc_flags  BIOC_SCNOAUTOASSEMBLE)  bc-bc_key_disk == NODEV)
goto done;
- 
+
strlcpy(sd-sd_name, CRYPTO, sizeof(sd-sd_name));
sd-sd_meta-ssdi.ssd_size = coerced_size;
 
@@ -194,15 +194,12 @@ sr_crypto_assemble(struct sr_discipline 
goto done;
 
if (bc-bc_key_disk != NODEV) {
-
/* Read the mask key from the key disk. */

Još samo 2 dana za septembarske povoljnosti i iznenađenja!

2010-09-29 Thread Top Shop
Poštovani,

Top-Shop.rs super ponude za zdraviji Eivot vaEe još samo 2 dana.
PoEurite da iskoristite povoljnosti koje vaEe do 1. oktobra - veEbajte
i hranite se zdravo... Jednostavno - brinite o sebi!

•

Proverite koja iznenaDenja smo Vam pripremili uz Ab Tronic X2 i Cardio
Twister- samo do 1. oktobra!

•

Kuvajte zdravije: jedini originalni Dry Cooker - uz uštedu!

•

PronaDite pravu meru svakog obroka i pripremajte ih lakše sa kuhinjskom
vagom: Kitchen Scale od 5kg - uz 10% popusta!

•

Pratite savete za zdraviju ishranu i veEbanje u ekskluzivnoj knjizi Dr.
Feelgooda: '505 - Å ifra za zdrav Eivot' - uz popust od 5%!

Prvi saznajte koji su to najnoviji hit proizvodi iz našeg kataloga!

Proverite Quelle super ponudu garderobe uz 40% popusta, kao i Å¡ta je
trenutno najpopularnije u Top Shop e-prodavnici!

Vaš
Top Shop

Ovu elektronsku poštu primate, ukoliko ste svojevoljno ostavili svoju
e-mail adresu na nekom od sajtova Top Shop-a, uD
estvovali u našoj poklon
igri ili nagradnom kvizu ili se prijavili za e-D
asopis Top Shop-a ili
nekog od nasih brendova.

Ponude date u ovom e-mailu vaEe iskljuD
ivo za porudEbine upuDene
putem Interneta ili broja telefona 021 489 26 60.

Ukoliko ne Eelite više da primate naše elektronske poruke, za
odjavljivanje sa naše e-mailing liste, kliknite ovde.

Studio Moderna d.o.o., Bulevar vojvode Stepe 30, 21000 Novi Sad, Tel: 021
489 26 60, Fax: 021 489 29 08,
E-mail: i...@news.top-shop.rs

[IMAGE]If you would no longer like to receive our emails please
unsubscribe by clicking here.



Re: diff: nuke a redundant check for cpu_unidle() (i386)

2010-09-29 Thread Thomas de Grivel

First: double checking is far from bad,
second: a test is much faster than a function call.

On 09/28/10 13:40, Vladimir Kirillov wrote:

Hello, t...@!

Subj, cpu_unidle() does that check itself.

Index: i386/machdep.c
===
RCS file: /cvs/src/sys/arch/i386/i386/machdep.c,v
retrieving revision 1.481
diff -u -p -r1.481 machdep.c
--- i386/machdep.c  5 Aug 2010 21:10:09 -   1.481
+++ i386/machdep.c  28 Sep 2010 11:39:14 -
@@ -3303,8 +3303,7 @@ need_resched(struct cpu_info *ci)
/* There's a risk we'll be called before the idle threads start */
if (ci-ci_curproc) {
aston(ci-ci_curproc);
-   if (ci != curcpu())
-   cpu_unidle(ci);
+   cpu_unidle(ci);
}
  }




Re: merge pms and pmsi + added support for some of mouse

2010-09-29 Thread Alexandr Shadchin
On Mon, Sep 27, 2010 at 11:42:35PM +0600, Alexandr Shadchin wrote:
 On Fri, Sep 24, 2010 at 05:40:37PM +0400, Alexandr Shadchin wrote:
  Hi!
  
  Paul Irofti proposed to split the diff in a few easy steps.
  Step 1 - merge drivers pms and pmsi.
  
 
 Step 2 - cleanup, standardization of interfaces and preparation
 for easy addition of new devices. Now the resume of work in polling mode.
 

Regen for -current.  Also small improvements:
1) add function pms_dev_reset()
2) in struct pms_protocol add function sync() - for check synchronization,
   proc () - for processing packet.
 
-- 
Alexandr Shadchin


Index: pms.c
===
RCS file: /cvs/src/sys/dev/pckbc/pms.c,v
retrieving revision 1.5
diff -u -p -r1.5 pms.c
--- pms.c   27 Sep 2010 18:16:25 -  1.5
+++ pms.c   29 Sep 2010 14:41:51 -
@@ -38,41 +38,100 @@
 #include dev/wscons/wsconsio.h
 #include dev/wscons/wsmousevar.h
 
+#ifdef PMS_DEBUG
+#define DPRINTF(...) do { if (pmsdebug) printf(__VA_ARGS__); } while(0)
+#define DPRINTFN(n, ...) do {  \
+   if (pmsdebug  (n)) printf(__VA_ARGS__);\
+} while(0)
+int pmsdebug = 1;
+#else
+#define DPRINTF(...)
+#define DPRINTFN(n, ...)
+#endif
+
+#define DEVNAME(sc) ((sc)-sc_dev.dv_xname)
+
+/* PS/2 mouse data packet */
+#define PMS_PS2_BUTTONSMASK0x07
+#define PMS_PS2_BUTTON10x01/* left */
+#define PMS_PS2_BUTTON20x04/* middle */
+#define PMS_PS2_BUTTON30x02/* right */
+#define PMS_PS2_XNEG   0x10
+#define PMS_PS2_YNEG   0x20
+
+#define PMS_BUTTON1DOWN0x01/* left */
+#define PMS_BUTTON2DOWN0x02/* middle */
+#define PMS_BUTTON3DOWN0x04/* right */
+
+struct pms_softc;
+
+struct pms_protocol {
+   int type;
+#define PMS_STANDARD   0
+#define PMS_INTELLI1
+   int packetsize;
+   int syncmask;
+   int syncval;
+   int (*enable)(struct pms_softc *);
+   int (*sync)(struct pms_softc *, int);
+   void (*proc)(struct pms_softc *, int *, int *, int *, u_int *);
+};
+
 struct pms_softc { /* driver status information */
struct device sc_dev;
 
pckbc_tag_t sc_kbctag;
int sc_kbcslot;
 
+   int poll;
int sc_state;
 #define PMS_STATE_DISABLED 0
 #define PMS_STATE_ENABLED  1
 #define PMS_STATE_SUSPENDED2
 
-   int intelli;
+   struct pms_protocol protocol;
+   unsigned char packet[8];
+
int inputstate;
-   u_int buttons, oldbuttons;  /* mouse button status */
-   signed char dx, dy;
+   u_int buttons;  /* mouse button status */
 
struct device *sc_wsmousedev;
 };
 
-int pmsprobe(struct device *, void *, void *);
-void pmsattach(struct device *, struct device *, void *);
-int pmsactivate(struct device *, int);
-void pmsinput(void *, int);
+intpmsprobe(struct device *, void *, void *);
+void   pmsattach(struct device *, struct device *, void *);
+intpmsactivate(struct device *, int);
 
-struct cfattach pms_ca = {
-   sizeof(struct pms_softc), pmsprobe, pmsattach, NULL,
-   pmsactivate
-};
+void   pmsinput(void *, int);
 
 intpms_change_state(struct pms_softc *, int);
 intpms_ioctl(void *, u_long, caddr_t, int, struct proc *);
 intpms_enable(void *);
 void   pms_disable(void *);
 
-intpms_setintellimode(pckbc_tag_t, pckbc_slot_t);
+intpms_cmd(struct pms_softc *, u_char *, int, u_char *, int);
+intpms_get_devid(struct pms_softc *, u_char *);
+intpms_get_status(struct pms_softc *, u_char *);
+intpms_set_rate(struct pms_softc *, int);
+intpms_set_resolution(struct pms_softc *, int);
+intpms_set_scaling(struct pms_softc *, int);
+void   pms_dev_reset(struct pms_softc *);
+void   pms_dev_disable(struct pms_softc *);
+void   pms_dev_enable(struct pms_softc *);
+
+intpms_enable_intelli(struct pms_softc *);
+
+intpms_sync_generic(struct pms_softc *, int);
+void   pms_proc_generic(struct pms_softc *, int *, int *, int *, u_int *);
+
+struct cfattach pms_ca = {
+   sizeof(struct pms_softc), pmsprobe, pmsattach, NULL,
+   pmsactivate
+};
+
+struct cfdriver pms_cd = {
+   NULL, pms, DV_DULL
+};
 
 const struct wsmouse_accessops pms_accessops = {
pms_enable,
@@ -80,104 +139,54 @@ const struct wsmouse_accessops pms_acces
pms_disable,
 };
 
-int
-pms_setintellimode(pckbc_tag_t tag, pckbc_slot_t slot)
-{
-   u_char cmd[2], resp[1];
-   int i, res;
-   static const u_char rates[] = {200, 100, 80};
-
-   cmd[0] = PMS_SET_SAMPLE;
-   for (i = 0; i  3; i++) {
-   cmd[1] = rates[i];
-   res = pckbc_enqueue_cmd(tag, slot, cmd, 2, 0, 0, NULL);
-   if (res)
-   return (0);
-   }
-
-   cmd[0] = PMS_SEND_DEV_ID;
-   res = pckbc_enqueue_cmd(tag, slot, cmd, 1, 1, 1, 

Re: merge pms and pmsi + added support for some of mouse

2010-09-29 Thread Alexandr Shadchin
On Thu, Sep 30, 2010 at 02:50:54AM +0600, Alexandr Shadchin wrote:
 On Mon, Sep 27, 2010 at 11:42:35PM +0600, Alexandr Shadchin wrote:
  On Fri, Sep 24, 2010 at 05:40:37PM +0400, Alexandr Shadchin wrote:
   Hi!
   
   Paul Irofti proposed to split the diff in a few easy steps.
   Step 1 - merge drivers pms and pmsi.
   
  
  Step 2 - cleanup, standardization of interfaces and preparation
  for easy addition of new devices. Now the resume of work in polling mode.
  
 
 Regen for -current.  Also small improvements:
 1) add function pms_dev_reset()
 2) in struct pms_protocol add function sync() - for check synchronization,
proc () - for processing packet.
  

That diff is way too big to commit in one piece. I'll try to split it into 
several pieces.

Pieces 1 - cleanup code

-- 
Alexandr Shadchin


Index: pms.c
===
RCS file: /cvs/src/sys/dev/pckbc/pms.c,v
retrieving revision 1.5
diff -u -p -r1.5 pms.c
--- pms.c   27 Sep 2010 18:16:25 -  1.5
+++ pms.c   29 Sep 2010 16:05:58 -
@@ -57,15 +57,11 @@ struct pms_softc {  /* driver status inf
struct device *sc_wsmousedev;
 };
 
-int pmsprobe(struct device *, void *, void *);
-void pmsattach(struct device *, struct device *, void *);
-int pmsactivate(struct device *, int);
-void pmsinput(void *, int);
+intpmsprobe(struct device *, void *, void *);
+void   pmsattach(struct device *, struct device *, void *);
+intpmsactivate(struct device *, int);
 
-struct cfattach pms_ca = {
-   sizeof(struct pms_softc), pmsprobe, pmsattach, NULL,
-   pmsactivate
-};
+void   pmsinput(void *, int);
 
 intpms_change_state(struct pms_softc *, int);
 intpms_ioctl(void *, u_long, caddr_t, int, struct proc *);
@@ -74,6 +70,15 @@ void pms_disable(void *);
 
 intpms_setintellimode(pckbc_tag_t, pckbc_slot_t);
 
+struct cfattach pms_ca = {
+   sizeof(struct pms_softc), pmsprobe, pmsattach, NULL,
+   pmsactivate
+};
+
+struct cfdriver pms_cd = {
+   NULL, pms, DV_DULL
+};
+
 const struct wsmouse_accessops pms_accessops = {
pms_enable,
pms_ioctl,
@@ -92,31 +97,28 @@ pms_setintellimode(pckbc_tag_t tag, pckb
cmd[1] = rates[i];
res = pckbc_enqueue_cmd(tag, slot, cmd, 2, 0, 0, NULL);
if (res)
-   return (0);
+   return 0;
}
 
cmd[0] = PMS_SEND_DEV_ID;
res = pckbc_enqueue_cmd(tag, slot, cmd, 1, 1, 1, resp);
if (res || resp[0] != 3)
-   return (0);
+   return 0;
 
-   return (1);
+   return 1;
 }
 
 int
-pmsprobe(parent, match, aux)
-   struct device *parent;
-   void *match;
-   void *aux;
+pmsprobe(struct device *parent, void *match, void *aux)
 {
struct pckbc_attach_args *pa = aux;
u_char cmd[1], resp[2];
int res;
 
if (pa-pa_slot != PCKBC_AUX_SLOT)
-   return (0);
+   return 0;
 
-   /* Flush any garbage. */
+   /* flush any garbage */
pckbc_flush(pa-pa_tag, pa-pa_slot);
 
/* reset the device */
@@ -126,11 +128,11 @@ pmsprobe(parent, match, aux)
 #ifdef DEBUG
printf(pmsprobe: reset error %d\n, res);
 #endif
-   return (0);
+   return 0;
}
if (resp[0] != PMS_RSTDONE) {
printf(pmsprobe: reset response 0x%x\n, resp[0]);
-   return (0);
+   return 0;
}
 
/* get type number (0 = mouse) */
@@ -138,21 +140,19 @@ pmsprobe(parent, match, aux)
 #ifdef DEBUG
printf(pmsprobe: type 0x%x\n, resp[1]);
 #endif
-   return (0);
+   return 0;
}
 
-   return (10);
+   return 1;
 }
 
 void
-pmsattach(parent, self, aux)
-   struct device *parent, *self;
-   void *aux;
+pmsattach(struct device *parent, struct device *self, void *aux)
 {
struct pms_softc *sc = (void *)self;
struct pckbc_attach_args *pa = aux;
struct wsmousedev_attach_args a;
-   u_char cmd[1], resp[2];
+   u_char cmd[1];
int res;
 
sc-sc_kbctag = pa-pa_tag;
@@ -160,24 +160,8 @@ pmsattach(parent, self, aux)
 
printf(\n);
 
-   /* Flush any garbage. */
-   pckbc_flush(pa-pa_tag, pa-pa_slot);
-
-   /* reset the device */
-   cmd[0] = PMS_RESET;
-   res = pckbc_poll_cmd(pa-pa_tag, pa-pa_slot, cmd, 1, 2, resp, 1);
-#ifdef DEBUG
-   if (res || resp[0] != PMS_RSTDONE || resp[1] != 0) {
-   printf(pmsattach: reset error\n);
-   return;
-   }
-#endif
-
-   sc-inputstate = 0;
-   sc-oldbuttons = 0;
-
pckbc_set_inputhandler(sc-sc_kbctag, sc-sc_kbcslot,
-  pmsinput, sc, sc-sc_dev.dv_xname);
+   pmsinput, sc, sc-sc_dev.dv_xname);
 
a.accessops = pms_accessops;
a.accesscookie = sc;
@@ -213,7 +197,7 @@ pmsactivate(struct device 

Re: merge pms and pmsi + added support for some of mouse

2010-09-29 Thread Nicholas Marriott
this reads fine and works fine for me

although i don't really agree with all this return () and comment
changing.. if everyone did that there would be tons of unnecessary
changes, the existing style is fine... but anyway, meh, the diff works

cheers


On Thu, Sep 30, 2010 at 04:12:20AM +0600, Alexandr Shadchin wrote:
 On Thu, Sep 30, 2010 at 02:50:54AM +0600, Alexandr Shadchin wrote:
  On Mon, Sep 27, 2010 at 11:42:35PM +0600, Alexandr Shadchin wrote:
   On Fri, Sep 24, 2010 at 05:40:37PM +0400, Alexandr Shadchin wrote:
Hi!

Paul Irofti proposed to split the diff in a few easy steps.
Step 1 - merge drivers pms and pmsi.

   
   Step 2 - cleanup, standardization of interfaces and preparation
   for easy addition of new devices. Now the resume of work in polling mode.
   
  
  Regen for -current.  Also small improvements:
  1) add function pms_dev_reset()
  2) in struct pms_protocol add function sync() - for check synchronization,
 proc () - for processing packet.
   
 
 That diff is way too big to commit in one piece. I'll try to split it into 
 several pieces.
 
 Pieces 1 - cleanup code
 
 -- 
 Alexandr Shadchin
 
 
 Index: pms.c
 ===
 RCS file: /cvs/src/sys/dev/pckbc/pms.c,v
 retrieving revision 1.5
 diff -u -p -r1.5 pms.c
 --- pms.c 27 Sep 2010 18:16:25 -  1.5
 +++ pms.c 29 Sep 2010 16:05:58 -
 @@ -57,15 +57,11 @@ struct pms_softc {/* driver status inf
   struct device *sc_wsmousedev;
  };
  
 -int pmsprobe(struct device *, void *, void *);
 -void pmsattach(struct device *, struct device *, void *);
 -int pmsactivate(struct device *, int);
 -void pmsinput(void *, int);
 +int  pmsprobe(struct device *, void *, void *);
 +void pmsattach(struct device *, struct device *, void *);
 +int  pmsactivate(struct device *, int);
  
 -struct cfattach pms_ca = {
 - sizeof(struct pms_softc), pmsprobe, pmsattach, NULL,
 - pmsactivate
 -};
 +void pmsinput(void *, int);
  
  int  pms_change_state(struct pms_softc *, int);
  int  pms_ioctl(void *, u_long, caddr_t, int, struct proc *);
 @@ -74,6 +70,15 @@ void   pms_disable(void *);
  
  int  pms_setintellimode(pckbc_tag_t, pckbc_slot_t);
  
 +struct cfattach pms_ca = {
 + sizeof(struct pms_softc), pmsprobe, pmsattach, NULL,
 + pmsactivate
 +};
 +
 +struct cfdriver pms_cd = {
 + NULL, pms, DV_DULL
 +};
 +
  const struct wsmouse_accessops pms_accessops = {
   pms_enable,
   pms_ioctl,
 @@ -92,31 +97,28 @@ pms_setintellimode(pckbc_tag_t tag, pckb
   cmd[1] = rates[i];
   res = pckbc_enqueue_cmd(tag, slot, cmd, 2, 0, 0, NULL);
   if (res)
 - return (0);
 + return 0;
   }
  
   cmd[0] = PMS_SEND_DEV_ID;
   res = pckbc_enqueue_cmd(tag, slot, cmd, 1, 1, 1, resp);
   if (res || resp[0] != 3)
 - return (0);
 + return 0;
  
 - return (1);
 + return 1;
  }
  
  int
 -pmsprobe(parent, match, aux)
 - struct device *parent;
 - void *match;
 - void *aux;
 +pmsprobe(struct device *parent, void *match, void *aux)
  {
   struct pckbc_attach_args *pa = aux;
   u_char cmd[1], resp[2];
   int res;
  
   if (pa-pa_slot != PCKBC_AUX_SLOT)
 - return (0);
 + return 0;
  
 - /* Flush any garbage. */
 + /* flush any garbage */
   pckbc_flush(pa-pa_tag, pa-pa_slot);
  
   /* reset the device */
 @@ -126,11 +128,11 @@ pmsprobe(parent, match, aux)
  #ifdef DEBUG
   printf(pmsprobe: reset error %d\n, res);
  #endif
 - return (0);
 + return 0;
   }
   if (resp[0] != PMS_RSTDONE) {
   printf(pmsprobe: reset response 0x%x\n, resp[0]);
 - return (0);
 + return 0;
   }
  
   /* get type number (0 = mouse) */
 @@ -138,21 +140,19 @@ pmsprobe(parent, match, aux)
  #ifdef DEBUG
   printf(pmsprobe: type 0x%x\n, resp[1]);
  #endif
 - return (0);
 + return 0;
   }
  
 - return (10);
 + return 1;
  }
  
  void
 -pmsattach(parent, self, aux)
 - struct device *parent, *self;
 - void *aux;
 +pmsattach(struct device *parent, struct device *self, void *aux)
  {
   struct pms_softc *sc = (void *)self;
   struct pckbc_attach_args *pa = aux;
   struct wsmousedev_attach_args a;
 - u_char cmd[1], resp[2];
 + u_char cmd[1];
   int res;
  
   sc-sc_kbctag = pa-pa_tag;
 @@ -160,24 +160,8 @@ pmsattach(parent, self, aux)
  
   printf(\n);
  
 - /* Flush any garbage. */
 - pckbc_flush(pa-pa_tag, pa-pa_slot);
 -
 - /* reset the device */
 - cmd[0] = PMS_RESET;
 - res = pckbc_poll_cmd(pa-pa_tag, pa-pa_slot, cmd, 1, 2, resp, 1);
 -#ifdef DEBUG
 - if (res || resp[0] != PMS_RSTDONE || resp[1] != 0) {
 - printf(pmsattach: reset error\n);
 - return;
 - }
 -#endif
 -
 

Re: merge pms and pmsi + added support for some of mouse

2010-09-29 Thread Landry Breuil
On Wed, Sep 29, 2010 at 06:53:33PM +0100, Nicholas Marriott wrote:
 this reads fine and works fine for me
 
 although i don't really agree with all this return () and comment
 changing.. if everyone did that there would be tons of unnecessary
 changes, the existing style is fine... but anyway, meh, the diff works

Speaking of that...

  -   return (10);
  +   return 1;

is this really intended or correct ?

Landry



Re: merge pms and pmsi + added support for some of mouse

2010-09-29 Thread Brad
On Wednesday 29 September 2010 15:10:56 Landry Breuil wrote:
 On Wed, Sep 29, 2010 at 06:53:33PM +0100, Nicholas Marriott wrote:
  this reads fine and works fine for me
 
  although i don't really agree with all this return () and comment
  changing.. if everyone did that there would be tons of unnecessary
  changes, the existing style is fine... but anyway, meh, the diff works

 Speaking of that...

   - return (10);
   + return 1;

 is this really intended or correct ?

 Landry

Looks like it was intended and is correct. pmsi(4) used to have a higher 
priority over pms(4) when probing for the appropriate device driver but 
that's no longer necessary now that pmsi(4) is gone.

-- 
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.



more assertwaitok() love

2010-09-29 Thread Thordur Bjornsson
Hi.

Try to catch more places where we sleep and are not allowed.

One thing of note, msleep() is missing in this diff, but there
it is needed to call to sleep_setup routines with the mutex
held, and after we release it we _will_ sleep so a sleep there
with another mutex held will be caught by the assertwaitok()
in mi_switch().

Also, define assertwaitok() out for !DIAGNOSTIC kernels.

Comments/OKs?
Index: kern/kern_rwlock.c
===
RCS file: /home/cvs/src/sys/kern/kern_rwlock.c,v
retrieving revision 1.16
diff -u -p -r1.16 kern_rwlock.c
--- kern/kern_rwlock.c  24 Sep 2010 13:21:30 -  1.16
+++ kern/kern_rwlock.c  30 Sep 2010 00:12:12 -
@@ -87,6 +87,8 @@ rw_enter_read(struct rwlock *rwl)
 {
unsigned long owner = rwl-rwl_owner;
 
+   assertwaitok();
+
if (__predict_false((owner  RWLOCK_WRLOCK) ||
rw_cas(rwl-rwl_owner, owner, owner + RWLOCK_READ_INCR)))
rw_enter(rwl, RW_READ);
@@ -97,6 +99,8 @@ rw_enter_write(struct rwlock *rwl)
 {
struct proc *p = curproc;
 
+   assertwaitok();
+
if (__predict_false(rw_cas(rwl-rwl_owner, 0,
RW_PROC(p) | RWLOCK_WRLOCK)))
rw_enter(rwl, RW_WRITE);
@@ -190,6 +194,9 @@ rw_enter(struct rwlock *rwl, int flags)
struct sleep_state sls;
unsigned long inc, o;
int error;
+
+   if (!(flags  RW_NOSLEEP))
+   assertwaitok();
 
op = rw_ops[flags  RW_OPMASK];
 
Index: kern/kern_synch.c
===
RCS file: /home/cvs/src/sys/kern/kern_synch.c,v
retrieving revision 1.95
diff -u -p -r1.95 kern_synch.c
--- kern/kern_synch.c   29 Jun 2010 00:28:14 -  1.95
+++ kern/kern_synch.c   29 Sep 2010 21:55:58 -
@@ -121,6 +121,8 @@ tsleep(const volatile void *ident, int p
return (0);
}
 
+   assertwaitok();
+
sleep_setup(sls, ident, priority, wmesg);
sleep_setup_timeout(sls, timo);
sleep_setup_signal(sls, priority);
Index: kern/subr_pool.c
===
RCS file: /home/cvs/src/sys/kern/subr_pool.c,v
retrieving revision 1.98
diff -u -p -r1.98 subr_pool.c
--- kern/subr_pool.c26 Sep 2010 21:03:57 -  1.98
+++ kern/subr_pool.c30 Sep 2010 00:03:15 -
@@ -455,10 +455,8 @@ pool_get(struct pool *pp, int flags)
 
KASSERT(flags  (PR_WAITOK | PR_NOWAIT));
 
-#ifdef DIAGNOSTIC
if ((flags  PR_WAITOK) != 0)
assertwaitok();
-#endif /* DIAGNOSTIC */
 
mtx_enter(pp-pr_mtx);
v = pool_do_get(pp, flags);
Index: kern/subr_xxx.c
===
RCS file: /home/cvs/src/sys/kern/subr_xxx.c,v
retrieving revision 1.12
diff -u -p -r1.12 subr_xxx.c
--- kern/subr_xxx.c 28 Sep 2010 20:27:56 -  1.12
+++ kern/subr_xxx.c 29 Sep 2010 21:55:03 -
@@ -156,13 +156,15 @@ blktochr(dev_t dev)
 /*
  * Check that we're in a context where it's okay to sleep.
  */
+
+#ifdef DIAGNOSTIC
 void
 assertwaitok(void)
 {
splassert(IPL_NONE);
-#ifdef DIAGNOSTIC
+
if (curcpu()-ci_mutex_level != 0)
panic(assertwaitok: non-zero mutex count: %d,
curcpu()-ci_mutex_level);
-#endif
 }
+#endif
Index: sys/systm.h
===
RCS file: /home/cvs/src/sys/sys/systm.h,v
retrieving revision 1.86
diff -u -p -r1.86 systm.h
--- sys/systm.h 21 Sep 2010 01:09:10 -  1.86
+++ sys/systm.h 30 Sep 2010 00:02:51 -
@@ -179,7 +179,11 @@ void   ttyprintf(struct tty *, const char 
 void   splassert_fail(int, int, const char *);
 extern int splassert_ctl;
 
+#ifdef DIAGNOSTIC
 void   assertwaitok(void);
+#else
+#defineassertwaitok()  do { /* nothing */ } while (0)
+#endif
 
 void   tablefull(const char *);



Re: softraid cleanup

2010-09-29 Thread Tobias Ulmer
I got this after a while:

panic: softraid0: sr_crypto_finish_io

No serial, so there's no more info. You know where to find me



Re: softraid cleanup

2010-09-29 Thread Dan Harnett
On Thu, Sep 30, 2010 at 03:35:33AM +0200, Tobias Ulmer wrote:
 I got this after a while:
 
 panic: softraid0: sr_crypto_finish_io

I see the same panic in the latest amd64 snapshot.

panic: softraid0: sr_crypto_finish_io
Stopped at  Debugger+0x5:   leave
ddb{0} trace
Debugger() at Debugger+0x5
panic() at panic+0xe4
sr_crypto_finish_io() at sr_crypto_finish_io+0xc7
sr_crypto_intr() at sr_crypto_intr+0x15d
sd_buf_done() at sd_buf_done+0x76
ahci_port_intr() at ahci_port_intr+0x183
ahci_intr() at ahci_intr+0x5c
Xintr_ioapic_level10() at Xintr_ioapic_level10+0xec
--- interrupt ---
Bad frame pointer: 0x800025c16df8
end trace frame: 0x800025c16df8, count: -8
spllower+0x35:
ddb{0}



Re: merge pms and pmsi + added support for some of mouse

2010-09-29 Thread Alexandr Shadchin
On Wed, Sep 29, 2010 at 08:45:48PM -0400, Kenneth R Westerback wrote:
 On Thu, Sep 30, 2010 at 04:12:20AM +0600, Alexandr Shadchin wrote:
  On Thu, Sep 30, 2010 at 02:50:54AM +0600, Alexandr Shadchin wrote:
   On Mon, Sep 27, 2010 at 11:42:35PM +0600, Alexandr Shadchin wrote:
On Fri, Sep 24, 2010 at 05:40:37PM +0400, Alexandr Shadchin wrote:
 Hi!
 
 Paul Irofti proposed to split the diff in a few easy steps.
 Step 1 - merge drivers pms and pmsi.
 

Step 2 - cleanup, standardization of interfaces and preparation
for easy addition of new devices. Now the resume of work in polling 
mode.

   
   Regen for -current.  Also small improvements:
   1) add function pms_dev_reset()
   2) in struct pms_protocol add function sync() - for check synchronization,
  proc () - for processing packet.

  
  That diff is way too big to commit in one piece. I'll try to split it into 
  several pieces.
  
  Pieces 1 - cleanup code
  
  -- 
  Alexandr Shadchin
 
 All the return (); - return ; just clutters the diff up. I don't
 see the point since both are considered valid style. I think the
 ansification is a valid change but that should be an easy separate
 diff. Many of the other changes seem to be whitespace because I
 can't see any real changes. I would recommend avoiding such changes
 while you are attempting to make functional changes, unless the
 code is really hard to read. I don't see that here.
 
 The smaller and more focused the diff, the easier to read and more
 likely to get commentary. We like single purpose diffs. :-).
 
  Ken
 

Ok. I'll try to make small diff, which will not include unrelated changes.

-- 
Alexandr Shadchin