Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 19 Sep 2001 16:42:31 -0700
From:      "mike varga" <mike.varga@cavium.com>
To:        <freebsd-arch@freebsd.org>
Subject:   kevent hangs 
Message-ID:  <00dd01c14164$c54b3560$4a10a8c0@stcla1.sfba.home.com>

next in thread | raw e-mail | index | archive | help
This is a multi-part message in MIME format.

------=_NextPart_000_00DA_01C1412A.137AA080
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

I opted to break the changelist=20
and eventlist into 2 seperate calls.

When I make the first call to add the=20
changelist, the call to kevent hangs.

Does anyone know what is wrong?

/*****APPLICATION CODE****/
 {
 struct timespec to;
 int n;
 struct kevent ke;
 int data, udata;

  PKP_kq_handle =3D kqueue();
 =20
  to.tv_sec =3D 2;         /* seconds */
         to.tv_nsec =3D 10000;        /* and microseconds */

  EV_SET(&ke, PKP_driver_handle, EVFILT_READ, EV_ADD,
   0,NULL,NULL);
=20
/******* HANGS ON THIS CALL *********/
  if (kevent(PKP_kq_handle,&ke,1,NULL,0,&to) <=3D 0)
  {
   close(PKP_kq_handle);
   PKP_kq_handle =3D -1;
   return errno;
  }
  else
   cond_code =3D 0;
=20




/******DRIVER CODE*****/

static struct filterops cavium_filtops =3D {
 1,
 NULL,
 kqdetach,
 kqfilter
};

static int kqfilter(struct knote* kn, long hint)
{
 cavium_softc* sc;
 DEBUG_PRINT(("CAVIUM kqfilter: 1 called\n"));
=20
 sc =3D (cavium_softc*)kn->kn_hook;

 return 1;
}

static void kqdetach(struct knote* kn)
{
 cavium_softc* sc;
=20
 DEBUG_PRINT(("CAVIUM kqdetach: 1 called\n"));

 sc =3D (cavium_softc*)kn->kn_hook;
=20
 LOCK(sc->cache_lock,sc->cache_slock);
 SLIST_REMOVE(&sc->klist,kn,knote,kn_selnext);
 UNLOCK(sc->cache_lock,sc->cache_slock);
}

int cavium_kqueue(dev_t dev, struct knote* kn)
{
 int unit;
 cavium_softc* sc;
=20
 DEBUG_PRINT(("CAVIUM cavium_kqfilter: 1 called\n"));
=20
 unit =3D UNIT(dev);

 if (!(sc=3DGET_SOFTC(unit)))
 {
  DEBUG_PRINT(("CAVIUM cavium_open: failed\n"));
  return 1;
 }

 switch(kn->kn_filter)
 {
  case EVFILT_READ:
   kn->kn_fop =3D &cavium_filtops;
   break;
  default:
   return 1;
 }
=20
 DEBUG_PRINT(("CAVIUM cavium_kqfilter: 2 called\n"));
=20
 kn->kn_hook =3D (caddr_t)sc;=20

 LOCK(sc->cache_lock,sc->cache_slock);
 SLIST_INSERT_HEAD(&sc->klist,kn,kn_selnext);
 UNLOCK(sc->cache_lock,sc->cache_slock);
=20
 DEBUG_PRINT(("CAVIUM cavium_kqfilter: 3 called\n"));
 return 0;
}

------=_NextPart_000_00DA_01C1412A.137AA080
Content-Type: text/html;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 5.50.4522.1800" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>
<DIV><FONT face=3DArial size=3D2>I opted to </FONT><FONT face=3DArial =
size=3D2>break the=20
changelist </FONT></DIV>
<DIV><FONT face=3DArial size=3D2>and eventlist </FONT><FONT face=3DArial =
size=3D2>into 2=20
seperate calls.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>When I make the first call to add the =
</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>changelist, the call to kevent =
hangs.</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV>Does anyone know what is wrong?</DIV>
<DIV>&nbsp;</DIV>
<DIV>/*****APPLICATION CODE****/</DIV>
<DIV>&nbsp;{<BR>&nbsp;struct timespec to;<BR>&nbsp;int =
n;<BR>&nbsp;struct kevent=20
ke;<BR>&nbsp;int data, udata;</DIV>
<DIV><BR>&nbsp;&nbsp;PKP_kq_handle =3D=20
kqueue();<BR>&nbsp;&nbsp;<BR>&nbsp;&nbsp;to.tv_sec =3D=20
2;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /* seconds=20
*/<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;to.tv_nsec =3D=20
10000;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /* and microseconds =
*/</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;&nbsp;EV_SET(&amp;ke, PKP_driver_handle, EVFILT_READ,=20
EV_ADD,<BR>&nbsp;&nbsp;&nbsp;0,NULL,NULL);<BR>&nbsp;</DIV>
<DIV>/******* HANGS ON THIS CALL *********/<BR>&nbsp;&nbsp;if=20
(kevent(PKP_kq_handle,&amp;ke,1,NULL,0,&amp;to) &lt;=3D=20
0)<BR>&nbsp;&nbsp;{<BR>&nbsp;&nbsp;&nbsp;close(PKP_kq_handle);<BR>&nbsp;&=
nbsp;&nbsp;PKP_kq_handle=20
=3D -1;<BR>&nbsp;&nbsp;&nbsp;return=20
errno;<BR>&nbsp;&nbsp;}<BR>&nbsp;&nbsp;else<BR>&nbsp;&nbsp;&nbsp;cond_cod=
e =3D=20
0;<BR>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV>/******DRIVER CODE*****/</DIV>
<DIV>&nbsp;</DIV>
<DIV>static struct filterops cavium_filtops =3D=20
{<BR>&nbsp;1,<BR>&nbsp;NULL,<BR>&nbsp;kqdetach,<BR>&nbsp;kqfilter<BR>};</=
DIV>
<DIV>&nbsp;</DIV>
<DIV>static int kqfilter(struct knote* kn, long=20
hint)<BR>{<BR>&nbsp;cavium_softc* sc;<BR>&nbsp;DEBUG_PRINT(("CAVIUM =
kqfilter: 1=20
called\n"));<BR>&nbsp;<BR>&nbsp;sc =3D =
(cavium_softc*)kn-&gt;kn_hook;</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;return 1;<BR>}</DIV>
<DIV>&nbsp;</DIV>
<DIV>static void kqdetach(struct knote* kn)<BR>{<BR>&nbsp;cavium_softc*=20
sc;<BR>&nbsp;<BR>&nbsp;DEBUG_PRINT(("CAVIUM kqdetach: 1 =
called\n"));</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;sc =3D=20
(cavium_softc*)kn-&gt;kn_hook;<BR>&nbsp;<BR>&nbsp;LOCK(sc-&gt;cache_lock,=
sc-&gt;cache_slock);<BR>&nbsp;SLIST_REMOVE(&amp;sc-&gt;klist,kn,knote,kn_=
selnext);<BR>&nbsp;UNLOCK(sc-&gt;cache_lock,sc-&gt;cache_slock);<BR>}</DI=
V>
<DIV>&nbsp;</DIV>
<DIV>int cavium_kqueue(dev_t dev, struct knote* kn)<BR>{<BR>&nbsp;int=20
unit;<BR>&nbsp;cavium_softc* sc;<BR>&nbsp;<BR>&nbsp;DEBUG_PRINT(("CAVIUM =

cavium_kqfilter: 1 called\n"));<BR>&nbsp;<BR>&nbsp;unit =3D =
UNIT(dev);</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;if=20
(!(sc=3DGET_SOFTC(unit)))<BR>&nbsp;{<BR>&nbsp;&nbsp;DEBUG_PRINT(("CAVIUM =

cavium_open: failed\n"));<BR>&nbsp;&nbsp;return 1;<BR>&nbsp;}</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;switch(kn-&gt;kn_filter)<BR>&nbsp;{<BR>&nbsp;&nbsp;case=20
EVFILT_READ:<BR>&nbsp;&nbsp;&nbsp;kn-&gt;kn_fop =3D=20
&amp;cavium_filtops;<BR>&nbsp;&nbsp;&nbsp;break;<BR>&nbsp;&nbsp;default:<=
BR>&nbsp;&nbsp;&nbsp;return=20
1;<BR>&nbsp;}<BR>&nbsp;<BR>&nbsp;DEBUG_PRINT(("CAVIUM cavium_kqfilter: 2 =

called\n"));<BR>&nbsp;<BR>&nbsp;kn-&gt;kn_hook =3D =
(caddr_t)sc;&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;LOCK(sc-&gt;cache_lock,sc-&gt;cache_slock);<BR>&nbsp;SLIST_INS=
ERT_HEAD(&amp;sc-&gt;klist,kn,kn_selnext);<BR>&nbsp;UNLOCK(sc-&gt;cache_l=
ock,sc-&gt;cache_slock);<BR>&nbsp;<BR>&nbsp;DEBUG_PRINT(("CAVIUM=20
cavium_kqfilter: 3 called\n"));<BR>&nbsp;return=20
0;<BR>}</DIV></FONT></DIV></BODY></HTML>

------=_NextPart_000_00DA_01C1412A.137AA080--


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-arch" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?00dd01c14164$c54b3560$4a10a8c0>