Print this page
8634 epoll fails to wake on certain edge-triggered conditions
8635 epoll should not emit POLLNVAL
8636 recursive epoll should emit EPOLLRDNORM
Reviewed by: Jerry Jelinek <jerry.jelinek@joyent.com>
Reviewed by: Robert Mustacchi <rm@joyent.com>
Reviewed by: Toomas Soome <tsoome@me.com>
Reviewed by: Igor Kozhukhov <igor@dilos.org>


   5  * Common Development and Distribution License (the "License").
   6  * You may not use this file except in compliance with the License.
   7  *
   8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 
  22 /*
  23  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
  24  * Use is subject to license terms.

  25  */
  26 
  27 
  28 /*
  29  * evtchn.c
  30  *
  31  * Driver for receiving and demuxing event-channel signals.
  32  *
  33  * Copyright (c) 2004-2005, K A Fraser
  34  * Multi-process extensions Copyright (c) 2004, Steven Smith
  35  *
  36  * This file may be distributed separately from the Linux kernel, or
  37  * incorporated into other software packages, subject to the following license:
  38  *
  39  * Permission is hereby granted, free of charge, to any person obtaining a copy
  40  * of this source file (the "Software"), to deal in the Software without
  41  * restriction, including without limitation the rights to use, copy, modify,
  42  * merge, publish, distribute, sublicense, and/or sell copies of the Software,
  43  * and to permit persons to whom the Software is furnished to do so, subject to
  44  * the following conditions:


 433                         ec_notify_via_evtchn(notify.port);
 434                 }
 435                 break;
 436         }
 437 
 438         default:
 439                 err = ENOSYS;
 440         }
 441 
 442         return (err);
 443 }
 444 
 445 static int
 446 evtchndrv_poll(dev_t dev, short ev, int anyyet, short *revp, pollhead_t **phpp)
 447 {
 448         struct evtsoftdata *ep;
 449         minor_t minor = getminor(dev);
 450         short mask = 0;
 451 
 452         ep = EVTCHNDRV_INST2SOFTS(EVTCHNDRV_MINOR2INST(minor));
 453         *phpp = (struct pollhead *)NULL;
 454 
 455         if (ev & POLLOUT)
 456                 mask |= POLLOUT;
 457         if (ep->ring_overflow)
 458                 mask |= POLLERR;
 459         if (ev & (POLLIN | POLLRDNORM)) {
 460                 mutex_enter(&ep->evtchn_lock);
 461                 if (ep->ring_cons != ep->ring_prod)
 462                         mask |= (POLLIN | POLLRDNORM) & ev;
 463                 else
 464                         if (mask == 0 && !anyyet)
 465                                 *phpp = &ep->evtchn_pollhead;
 466                 mutex_exit(&ep->evtchn_lock);
 467         }



 468         *revp = mask;
 469         return (0);
 470 }
 471 
 472 
 473 /* ARGSUSED */
 474 static int
 475 evtchndrv_open(dev_t *devp, int flag, int otyp, cred_t *credp)
 476 {
 477         struct evtsoftdata *ep;
 478         minor_t minor = getminor(*devp);
 479 
 480         if (otyp == OTYP_BLK)
 481                 return (ENXIO);
 482 
 483         /*
 484          * only allow open on minor = 0 - the clone device
 485          */
 486         if (minor != 0)
 487                 return (ENXIO);




   5  * Common Development and Distribution License (the "License").
   6  * You may not use this file except in compliance with the License.
   7  *
   8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 
  22 /*
  23  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
  24  * Use is subject to license terms.
  25  * Copyright 2017 Joyent, Inc.
  26  */
  27 
  28 
  29 /*
  30  * evtchn.c
  31  *
  32  * Driver for receiving and demuxing event-channel signals.
  33  *
  34  * Copyright (c) 2004-2005, K A Fraser
  35  * Multi-process extensions Copyright (c) 2004, Steven Smith
  36  *
  37  * This file may be distributed separately from the Linux kernel, or
  38  * incorporated into other software packages, subject to the following license:
  39  *
  40  * Permission is hereby granted, free of charge, to any person obtaining a copy
  41  * of this source file (the "Software"), to deal in the Software without
  42  * restriction, including without limitation the rights to use, copy, modify,
  43  * merge, publish, distribute, sublicense, and/or sell copies of the Software,
  44  * and to permit persons to whom the Software is furnished to do so, subject to
  45  * the following conditions:


 434                         ec_notify_via_evtchn(notify.port);
 435                 }
 436                 break;
 437         }
 438 
 439         default:
 440                 err = ENOSYS;
 441         }
 442 
 443         return (err);
 444 }
 445 
 446 static int
 447 evtchndrv_poll(dev_t dev, short ev, int anyyet, short *revp, pollhead_t **phpp)
 448 {
 449         struct evtsoftdata *ep;
 450         minor_t minor = getminor(dev);
 451         short mask = 0;
 452 
 453         ep = EVTCHNDRV_INST2SOFTS(EVTCHNDRV_MINOR2INST(minor));

 454 
 455         if (ev & POLLOUT)
 456                 mask |= POLLOUT;
 457         if (ep->ring_overflow)
 458                 mask |= POLLERR;
 459         if (ev & (POLLIN | POLLRDNORM)) {
 460                 mutex_enter(&ep->evtchn_lock);
 461                 if (ep->ring_cons != ep->ring_prod) {
 462                         mask |= (POLLIN | POLLRDNORM) & ev;
 463                 }


 464                 mutex_exit(&ep->evtchn_lock);
 465         }
 466         if ((mask == 0 && !anyyet) || (ev & POLLET)) {
 467                 *phpp = &ep->evtchn_pollhead;
 468         }
 469         *revp = mask;
 470         return (0);
 471 }
 472 
 473 
 474 /* ARGSUSED */
 475 static int
 476 evtchndrv_open(dev_t *devp, int flag, int otyp, cred_t *credp)
 477 {
 478         struct evtsoftdata *ep;
 479         minor_t minor = getminor(*devp);
 480 
 481         if (otyp == OTYP_BLK)
 482                 return (ENXIO);
 483 
 484         /*
 485          * only allow open on minor = 0 - the clone device
 486          */
 487         if (minor != 0)
 488                 return (ENXIO);