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>

Split Close
Expand all
Collapse all
          --- old/usr/src/uts/common/io/1394/targets/dcam1394/dcam.c
          +++ new/usr/src/uts/common/io/1394/targets/dcam1394/dcam.c
↓ open down ↓ 13 lines elided ↑ open up ↑
  14   14   * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15   15   * If applicable, add the following below this CDDL HEADER, with the
  16   16   * fields enclosed by brackets "[]" replaced with your own identifying
  17   17   * information: Portions Copyright [yyyy] [name of copyright owner]
  18   18   *
  19   19   * CDDL HEADER END
  20   20   */
  21   21  /*
  22   22   * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
  23   23   * Use is subject to license terms.
       24 + * Copyright 2017 Joyent, Inc.
  24   25   */
  25   26  
  26   27  
  27   28  /*
  28   29   * dcam.c
  29   30   *
  30   31   * dcam1394 driver. Controls IIDC compliant devices attached through a
  31   32   * IEEE-1394 bus.
  32   33   */
  33   34  
↓ open down ↓ 999 lines elided ↑ open up ↑
1033 1034          }
1034 1035  
1035 1036  done:
1036 1037          if (param_list)
1037 1038                  kmem_free(param_list, sizeof (dcam1394_param_list_t));
1038 1039  
1039 1040          return (rc);
1040 1041  }
1041 1042  
1042 1043  
1043      -/*
1044      - * dcam_chpoll
1045      - */
1046 1044  /* ARGSUSED */
1047 1045  int
1048 1046  dcam_chpoll(dev_t dev, short events, int anyyet, short *reventsp,
1049 1047      struct pollhead **phpp)
1050 1048  {
1051 1049          dcam_state_t    *softc_p;
1052      -        int              instance, ring_buff_has_data, read_ptr_id;
1053      -        size_t           read_ptr_pos, write_ptr_pos;
1054      -        short            revent;
     1050 +        int             instance;
     1051 +        short           revent = 0;
1055 1052  
1056      -        instance = DEV_TO_INSTANCE(dev);
     1053 +        /*
     1054 +         * Without the logic to perform wakeups (see comment below), reject
     1055 +         * attempts at edge-triggered polling.
     1056 +         */
     1057 +        if (events & POLLET) {
     1058 +                return (EPERM);
     1059 +        }
1057 1060  
     1061 +        instance = DEV_TO_INSTANCE(dev);
1058 1062          softc_p = (dcam_state_t *)ddi_get_soft_state(dcam_state_p, instance);
1059 1063          if (softc_p == NULL) {
1060 1064                  return (ENXIO);
1061 1065          }
1062 1066  
1063      -        read_ptr_id     = 0;
1064      -        revent          = 0;
     1067 +        if (softc_p->ring_buff_p != NULL) {
     1068 +                size_t read_ptr_pos, write_ptr_pos;
1065 1069  
1066      -        if (softc_p->ring_buff_p == NULL) {
1067      -                ring_buff_has_data = 0;
1068      -        } else {
1069 1070                  mutex_enter(&softc_p->dcam_frame_is_done_mutex);
1070      -
1071 1071                  read_ptr_pos =
1072      -                    ring_buff_read_ptr_pos_get(softc_p->ring_buff_p,
1073      -                    read_ptr_id);
1074      -
     1072 +                    ring_buff_read_ptr_pos_get(softc_p->ring_buff_p, 0);
1075 1073                  write_ptr_pos =
1076 1074                      ring_buff_write_ptr_pos_get(softc_p->ring_buff_p);
     1075 +                mutex_exit(&softc_p->dcam_frame_is_done_mutex);
1077 1076  
1078      -                if (read_ptr_pos != write_ptr_pos) {
1079      -                        ring_buff_has_data = 1;
1080      -                } else {
1081      -                        ring_buff_has_data = 0;
     1077 +                if ((events & POLLRDNORM) && read_ptr_pos != write_ptr_pos) {
     1078 +                        revent |= POLLRDNORM;
1082 1079                  }
1083      -
1084      -                mutex_exit(&softc_p->dcam_frame_is_done_mutex);
1085 1080          }
1086 1081  
1087      -        /*
1088      -         * now check for events
1089      -         */
1090      -        if ((events & POLLRDNORM) && ring_buff_has_data) {
1091      -                revent |= POLLRDNORM;
1092      -        }
1093      -
1094 1082          if ((events & POLLPRI) && softc_p->param_status) {
1095 1083                  revent |= POLLPRI;
1096 1084          }
1097 1085  
1098      -        /* if no events have occurred */
1099      -        if (revent == 0) {
1100      -                if (!anyyet) {
1101      -                        *phpp = &softc_p->dcam_pollhead;
1102      -                }
1103      -        }
1104      -
     1086 +        /*
     1087 +         * No portion of this driver was ever wired up to perform a
     1088 +         * pollwakeup() on an associated pollhead.  The lack of an emitted
     1089 +         * pollhead informs poll/devpoll that the event status of this resource
     1090 +         * is not cacheable.
     1091 +         */
1105 1092          *reventsp = revent;
1106 1093  
1107 1094          return (0);
1108 1095  }
1109 1096  
1110 1097  
1111 1098  /*
1112 1099   * dcam_bus_reset_notify
1113 1100   */
1114 1101  /* ARGSUSED */
↓ open down ↓ 147 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX