VirtualBox

Changeset 89849 in vbox for trunk/src/VBox/Devices/Audio


Ignore:
Timestamp:
Jun 23, 2021 9:18:30 AM (4 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
145306
Message:

DevHda: Redid the locking in hdaMmioWrite, so that we take the lock before calling hdaWriteReg and hold it while supply missing bits for partial writes. bugref:9890

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/Audio/DevHda.cpp

    r89848 r89849  
    30493049DECLINLINE(VBOXSTRICTRC) hdaWriteReg(PPDMDEVINS pDevIns, PHDASTATE pThis, int idxRegDsc, uint32_t u32Value, char const *pszLog)
    30503050{
    3051     DEVHDA_LOCK_RETURN(pDevIns, pThis, VINF_IOM_R3_MMIO_WRITE);
    3052 
    30533051    if (   (HDA_REG(pThis, GCTL) & HDA_GCTL_CRST)
    30543052        || idxRegDsc == HDA_REG_GCTL)
     
    30603058                 g_aHdaRegMap[idxRegDsc].abbrev));
    30613059        STAM_COUNTER_INC(&pThis->StatRegWritesBlockedByReset);
    3062 
    3063         DEVHDA_UNLOCK(pDevIns, pThis);
    30643060        return VINF_SUCCESS;
    30653061    }
     
    30863082                     g_aHdaRegMap[idxRegDsc].abbrev));
    30873083            STAM_COUNTER_INC(&pThis->StatRegWritesBlockedByRun);
    3088 
    3089             DEVHDA_UNLOCK(pDevIns, pThis);
    30903084            return VINF_SUCCESS;
    30913085        }
     
    31063100        STAM_COUNTER_INC(&pThis->aStatRegWrites[idxRegDsc]);
    31073101
    3108     DEVHDA_UNLOCK(pDevIns, pThis);
    31093102    RT_NOREF(pszLog);
    31103103    return rc;
     
    31623155    if (idxRegDsc >= 0 && g_aHdaRegMap[idxRegDsc].size == cb)
    31633156    {
     3157        DEVHDA_LOCK_RETURN(pDevIns, pThis, VINF_IOM_R3_MMIO_WRITE);
     3158
    31643159        Log3Func(("@%#05x u%u=%#0*RX64 %s\n", (uint32_t)off, cb * 8, 2 + cb * 2, u64Value, g_aHdaRegMap[idxRegDsc].abbrev));
    31653160        rc = hdaWriteReg(pDevIns, pThis, idxRegDsc, u64Value, "");
    31663161        Log3Func(("  %#x -> %#x\n", u32LogOldValue, idxRegMem != UINT32_MAX ? pThis->au32Regs[idxRegMem] : UINT32_MAX));
     3162
     3163        DEVHDA_UNLOCK(pDevIns, pThis);
    31673164    }
    31683165    /*
     
    31723169             && cb < g_aHdaRegMap[idxRegDsc].size)
    31733170    {
    3174         /** @todo r=bird: This is not correctly serialized!  Also we're not gaining
    3175          *        any advantage by not entering the critsect here already, because
    3176          *        hdaWriteReg will enter it! */
     3171        DEVHDA_LOCK_RETURN(pDevIns, pThis, VINF_IOM_R3_MMIO_WRITE);
     3172
    31773173        u64Value |=   pThis->au32Regs[g_aHdaRegMap[idxRegDsc].mem_idx]
    31783174                    & g_afMasks[g_aHdaRegMap[idxRegDsc].size]
     
    31853181        Log4Func(("  %#x -> %#x\n", u32LogOldValue, idxRegMem != UINT32_MAX ? pThis->au32Regs[idxRegMem] : UINT32_MAX));
    31863182        STAM_COUNTER_INC(&pThis->CTX_SUFF_Z(StatRegSubWrite));
     3183
     3184        DEVHDA_UNLOCK(pDevIns, pThis);
    31873185    }
    31883186    /*
     
    31923190    {
    31933191#ifdef IN_RING3
    3194         /** @todo r=bird: This is not correctly serialized!  Also we're not gaining
    3195          *        much of an advantage by not entering the critsect here already,
    3196          *        becuase hdaWriteReg will eventually enter it, possibly multiple
    3197          *        times!   The only would be unknown wrights, which should be rare
    3198          *        and not something we need to optimize for. */
     3192        DEVHDA_LOCK_RETURN(pDevIns, pThis, VINF_IOM_R3_MMIO_WRITE);
     3193
    31993194        if (idxRegDsc == -1)
    32003195            Log4Func(("@%#05x u32=%#010x cb=%d\n", (uint32_t)off, *(uint32_t const *)pv, cb));
     
    32803275            }
    32813276        }
     3277
     3278        DEVHDA_UNLOCK(pDevIns, pThis);
    32823279
    32833280#else  /* !IN_RING3 */
Note: See TracChangeset for help on using the changeset viewer.

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