VirtualBox

Changeset 84689 in vbox


Ignore:
Timestamp:
Jun 5, 2020 9:07:54 AM (5 years ago)
Author:
vboxsync
Message:

Devices/Serial/UartCore: Revert part of r137918 and switch the receive FIFO timeout timer back to just virtual because virtual sync timers, hoping that we don't require the precise timing in that path (OpenIndiana 2020 boot menu still works correctly). Also leave the device critical section before calling into the lower drivers pfnDataAvailWrNotify callback to avoid a possible deadlock

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/Serial/UartCore.cpp

    r84281 r84689  
    813813{
    814814    int rc = VINF_SUCCESS;
     815#ifdef IN_RING3
     816    bool fNotifyDrv = false;
     817#endif
    815818
    816819    if (pThis->uRegFcr & UART_REG_FCR_FIFO_EN)
     
    831834        uartIrqUpdate(pDevIns, pThis, pThisCC);
    832835        if (uartFifoUsedGet(&pThis->FifoXmit) == 1)
    833         {
    834             if (   pThisCC->pDrvSerial
    835                 && !(pThis->uRegMcr & UART_REG_MCR_LOOP))
    836             {
    837                 int rc2 = pThisCC->pDrvSerial->pfnDataAvailWrNotify(pThisCC->pDrvSerial);
    838                 if (RT_FAILURE(rc2))
    839                     LogRelMax(10, ("Serial#%d: Failed to send data with %Rrc\n", pDevIns->iInstance, rc2));
    840             }
    841             else
    842                 PDMDevHlpTimerSetRelative(pDevIns, pThis->hTimerTxUnconnected, pThis->cSymbolXferTicks, NULL);
    843         }
     836            fNotifyDrv = true;
    844837#endif
    845838    }
     
    856849            pThis->fThreEmptyPending = false;
    857850            uartIrqUpdate(pDevIns, pThis, pThisCC);
    858             if (   pThisCC->pDrvSerial
    859                 && !(pThis->uRegMcr & UART_REG_MCR_LOOP))
    860             {
    861                 int rc2 = pThisCC->pDrvSerial->pfnDataAvailWrNotify(pThisCC->pDrvSerial);
    862                 if (RT_FAILURE(rc2))
    863                     LogRelMax(10, ("Serial#%d: Failed to send data with %Rrc\n", pDevIns->iInstance, rc2));
    864             }
    865             else
    866                 PDMDevHlpTimerSetRelative(pDevIns, pThis->hTimerTxUnconnected, pThis->cSymbolXferTicks, NULL);
     851            fNotifyDrv = true;
    867852#endif
    868853        }
     
    870855            pThis->uRegThr = bVal;
    871856    }
     857
     858#ifdef IN_RING3
     859    if (fNotifyDrv)
     860    {
     861        if (   pThisCC->pDrvSerial
     862            && !(pThis->uRegMcr & UART_REG_MCR_LOOP))
     863        {
     864            /* Leave the device critical section before calling into the lower driver. */
     865            PDMDevHlpCritSectLeave(pDevIns, &pThis->CritSect);
     866            int rc2 = pThisCC->pDrvSerial->pfnDataAvailWrNotify(pThisCC->pDrvSerial);
     867            if (RT_FAILURE(rc2))
     868                LogRelMax(10, ("Serial#%d: Failed to send data with %Rrc\n", pDevIns->iInstance, rc2));
     869            PDMDevHlpCritSectEnter(pDevIns, &pThis->CritSect, VINF_SUCCESS);
     870        }
     871        else
     872            PDMDevHlpTimerSetRelative(pDevIns, pThis->hTimerTxUnconnected, pThis->cSymbolXferTicks, NULL);
     873    }
     874#endif
    872875
    873876    return rc;
     
    15011504    RT_NOREF(pTimer);
    15021505
    1503     VBOXSTRICTRC rc1 = PDMDevHlpTimerLockClock2(pDevIns, pThis->hTimerRcvFifoTimeout, &pThis->CritSect,
    1504                                                 VINF_SUCCESS /* must get it */);
    1505     AssertRCReturnVoid(VBOXSTRICTRC_VAL(rc1));
    1506 
    15071506    if (pThis->FifoRecv.cbUsed < pThis->FifoRecv.cbItl)
    15081507    {
     
    15101509        uartIrqUpdate(pDevIns, pThis, pThisCC);
    15111510    }
    1512 
    1513     PDMDevHlpTimerUnlockClock2(pDevIns, pThis->hTimerRcvFifoTimeout, &pThis->CritSect);
    15141511}
    15151512
     
    19401937            return VERR_PDM_MISSING_INTERFACE;
    19411938        }
     1939        PDMDevHlpCritSectEnter(pDevIns, &pThis->CritSect, VERR_IGNORED);
    19421940        uartR3XferReset(pDevIns, pThis, pThisCC);
     1941        PDMDevHlpCritSectLeave(pDevIns, &pThis->CritSect);
    19431942    }
    19441943    else if (rc == VERR_PDM_NO_ATTACHED_DRIVER)
     
    19471946        pThisCC->pDrvSerial = NULL;
    19481947        rc = VINF_SUCCESS;
     1948        PDMDevHlpCritSectEnter(pDevIns, &pThis->CritSect, VERR_IGNORED);
    19491949        uartR3XferReset(pDevIns, pThis, pThisCC);
     1950        PDMDevHlpCritSectLeave(pDevIns, &pThis->CritSect);
    19501951        LogRel(("Serial#%d: no unit\n", pDevIns->iInstance));
    19511952    }
     
    20602061     * Create the receive FIFO character timeout indicator timer.
    20612062     */
    2062     rc = PDMDevHlpTimerCreate(pDevIns, TMCLOCK_VIRTUAL_SYNC, uartR3RcvFifoTimeoutTimer, pThisCC,
     2063    rc = PDMDevHlpTimerCreate(pDevIns, TMCLOCK_VIRTUAL, uartR3RcvFifoTimeoutTimer, pThisCC,
    20632064                              TMTIMER_FLAGS_NO_CRIT_SECT, "UART Rcv FIFO Timer",
    20642065                              &pThis->hTimerRcvFifoTimeout);
     2066    AssertRCReturn(rc, rc);
     2067
     2068    rc = PDMDevHlpTimerSetCritSect(pDevIns, pThis->hTimerRcvFifoTimeout, &pThis->CritSect);
    20652069    AssertRCReturn(rc, rc);
    20662070
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette