Print this page
XXXX introduce drv_sectohz


1752 }
1753 
1754 
1755 /*
1756  * during close, wait until pending data is gone or the signal is sent
1757  */
1758 static void
1759 usbser_close_drain(usbser_port_t *pp)
1760 {
1761         int     need_drain;
1762         clock_t until;
1763         int     rval = USB_SUCCESS;
1764 
1765         /*
1766          * port_wq_data_cnt indicates amount of data on the write queue,
1767          * which becomes zero when all data is submitted to DSD. But usbser
1768          * stays busy until it gets tx callback from DSD, signalling that
1769          * data has been sent over USB. To be continued in the next comment...
1770          */
1771         until = ddi_get_lbolt() +
1772             drv_usectohz(USBSER_WQ_DRAIN_TIMEOUT * 1000000);
1773 
1774         while ((pp->port_wq_data_cnt > 0) && USBSER_PORT_IS_BUSY(pp)) {
1775                 if ((rval = cv_timedwait_sig(&pp->port_act_cv, &pp->port_mutex,
1776                     until)) <= 0) {
1777 
1778                         break;
1779                 }
1780         }
1781 
1782         /* don't drain if timed out or received a signal */
1783         need_drain = (pp->port_wq_data_cnt == 0) || !USBSER_PORT_IS_BUSY(pp) ||
1784             (rval != USB_SUCCESS);
1785 
1786         mutex_exit(&pp->port_mutex);
1787         /*
1788          * Once the data reaches USB serial box, it may still be stored in its
1789          * internal output buffer (FIFO). We call DSD drain to ensure that all
1790          * the data is transmitted transmitted over the serial line.
1791          */
1792         if (need_drain) {




1752 }
1753 
1754 
1755 /*
1756  * during close, wait until pending data is gone or the signal is sent
1757  */
1758 static void
1759 usbser_close_drain(usbser_port_t *pp)
1760 {
1761         int     need_drain;
1762         clock_t until;
1763         int     rval = USB_SUCCESS;
1764 
1765         /*
1766          * port_wq_data_cnt indicates amount of data on the write queue,
1767          * which becomes zero when all data is submitted to DSD. But usbser
1768          * stays busy until it gets tx callback from DSD, signalling that
1769          * data has been sent over USB. To be continued in the next comment...
1770          */
1771         until = ddi_get_lbolt() +
1772             drv_sectohz(USBSER_WQ_DRAIN_TIMEOUT);
1773 
1774         while ((pp->port_wq_data_cnt > 0) && USBSER_PORT_IS_BUSY(pp)) {
1775                 if ((rval = cv_timedwait_sig(&pp->port_act_cv, &pp->port_mutex,
1776                     until)) <= 0) {
1777 
1778                         break;
1779                 }
1780         }
1781 
1782         /* don't drain if timed out or received a signal */
1783         need_drain = (pp->port_wq_data_cnt == 0) || !USBSER_PORT_IS_BUSY(pp) ||
1784             (rval != USB_SUCCESS);
1785 
1786         mutex_exit(&pp->port_mutex);
1787         /*
1788          * Once the data reaches USB serial box, it may still be stored in its
1789          * internal output buffer (FIFO). We call DSD drain to ensure that all
1790          * the data is transmitted transmitted over the serial line.
1791          */
1792         if (need_drain) {