[vbox-dev] vbox-dev at virtualbox.org

Andreas Löffler andreas.loeffler at oracle.com
Tue Jan 5 15:23:29 UTC 2016


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

Hi Lin,

your patch seems to be for VBox 4.3, right? Please note that in this
version we still had the old audio architecture -- starting with 5.0
we have a new architecture which changed a lot when it comes to data flo
w.

A couple of further questions:

- - Can you point me to the Android version (+ game) you're running to
reproduce this problem? A download link would be also appreciated.
- - Can you please supply a VBox.log when running that particular guest?

Thanks!

Kind regards / Mit freundlichen Grüßen

******************************************************************
Andreas Löffler          | VirtualBox Engineering
Senior Software Engineer | Oracle Virtualization

ORACLE Deutschland B.V. & Co. KG
Hauptverwaltung: Riesstraße 25, D-80992 München
Registergericht: Amtsgericht München, HRA 95603

Komplementärin: ORACLE Deutschland Verwaltung B.V.
Hertogswetering 163/167, 3543 AS Utrecht, Niederlande
Handelsregister der Handelskammer Midden-Niederlande, Nr. 30143697
Geschäftsführer: Alexander van der Ven, Astrid Kepper, Val Maher

Green Oracle <http://www.oracle.com/commitment>
Oracle is committed to developing practices and products that
help protect the environment


On 25.12.2015 08:44, lin zuojian wrote:
> Hi friends, I find my vbox will hanging after a short while playing
> Android games. Then I use debugger and figure out linux kernel
> driver of intel ac97 is dead looping. And this is result from the 
> multithreading data inconsistency. So I use my patch: diff --git
> a/include/iprt/AutoLock.h b/include/iprt/AutoLock.h new file mode
> 100644 index 0000000..c15a19b --- /dev/null +++
> b/include/iprt/AutoLock.h @@ -0,0 +1,48 @@ +#ifndef
> __XX_AUTOLOCK__ +#define __XX_AUTOLOCK__ +#include
> <iprt/critsect.h> + +class CLock +{ +public: +	CLock(void){ +
> Init(); +	} +	~CLock(){ +		Close(); +	} +	void Lock(){ +
> RTCritSectEnter(&m_lock); +	} +	void UnLock(){ +
> RTCritSectLeave(&m_lock); +	} +private: +	RTCRITSECT m_lock; +	void
> Init(){ +		RTCritSectInit(&m_lock); +	} +	void Close(){ +
> RTCritSectDelete(&m_lock); +	} +}; + +class CAutoLock{ +public: +
> CAutoLock(CLock *pLock){ +		m_pLock=pLock; +		if (NULL!=m_pLock) +
> { +			m_pLock->Lock(); +		} +	} +	~CAutoLock(){ +		if
> (NULL!=m_pLock) +		{ +			m_pLock->UnLock(); +		} +	} +private: +
> CLock * m_pLock; +}; +#endif \ No newline at end of file diff --git
> a/src/VBox/Devices/Audio/DevIchAc97.cpp
> b/src/VBox/Devices/Audio/DevIchAc97.cpp index 84ac678..ddc199b
> 100644 --- a/src/VBox/Devices/Audio/DevIchAc97.cpp +++
> b/src/VBox/Devices/Audio/DevIchAc97.cpp @@ -24,6 +24,8 @@ #include
> <iprt/uuid.h> #include <iprt/string.h>
> 
> +#include <iprt/AutoLock.h> + #include "VBoxDD.h"
> 
> extern "C" { @@ -186,7 +188,7 @@ typedef struct AC97BusMasterRegs }
> AC97BusMasterRegs; /** Pointer to a AC97 bus master register. */ 
> typedef AC97BusMasterRegs *PAC97BMREG; - +static CLock g_alock; 
> typedef struct AC97STATE { /** The PCI device state. */ @@ -743,6
> +745,7 @@ static int read_audio(PAC97STATE pThis, PAC97BMREG pReg,
> int max, int *stop)
> 
> static void transfer_audio(PAC97STATE pThis, int index, int
> elapsed) { +	CAutoLock alock(&g_alock); PAC97BMREG pReg =
> &pThis->bm_regs[index]; int written = 0; int stop = 0; @@ -853,6
> +856,7 @@ static void po_callback(void *opaque, int free) */ static
> DECLCALLBACK(int) ichac97IOPortNABMRead(PPDMDEVINS pDevIns, void
> *pvUser, RTIOPORT Port, uint32_t *pu32, unsigned cb) { +	CAutoLock
> alock(&g_alock); PAC97STATE pThis = (PAC97STATE)pvUser;
> 
> switch (cb) @@ -1013,6 +1017,7 @@ static DECLCALLBACK(int)
> ichac97IOPortNABMRead(PPDMDEVINS pDevIns, void *pvUser, */ static
> DECLCALLBACK(int) ichac97IOPortNABMWrite(PPDMDEVINS pDevIns, void
> *pvUser, RTIOPORT Port, uint32_t u32, unsigned cb) { +	CAutoLock
> alock(&g_alock); PAC97STATE pThis = (PAC97STATE)pvUser;
> 
> switch (cb) @@ -1151,6 +1156,7 @@ static DECLCALLBACK(int)
> ichac97IOPortNABMWrite(PPDMDEVINS pDevIns, void *pvUser */ static
> DECLCALLBACK(int) ichac97IOPortNAMRead(PPDMDEVINS pDevIns, void
> *pvUser, RTIOPORT Port, uint32_t *pu32, unsigned cb) { +	CAutoLock
> alock(&g_alock); PAC97STATE pThis = (PAC97STATE)pvUser;
> 
> switch (cb) @@ -1197,6 +1203,7 @@ static DECLCALLBACK(int)
> ichac97IOPortNAMRead(PPDMDEVINS pDevIns, void *pvUser, */ static
> DECLCALLBACK(int) ichac97IOPortNAMWrite(PPDMDEVINS pDevIns, void
> *pvUser, RTIOPORT Port, uint32_t u32, unsigned cb) { +	CAutoLock
> alock(&g_alock); PAC97STATE pThis = (PAC97STATE)pvUser;
> 
> switch (cb) @@ -1457,6 +1464,7 @@ static DECLCALLBACK(void *)
> ichac97QueryInterface(struct PDMIBASE *pInterface, c */ static
> DECLCALLBACK(void)  ac97Reset(PPDMDEVINS pDevIns) { +	CAutoLock
> alock(&g_alock); PAC97STATE pThis = PDMINS_2_DATA(pDevIns,
> AC97STATE *);
> 
> /*
> 
> The patch is mean to protect the data accessing from different 
> thread between CPU thread which is invoking timer and the CPU
> thread which is runing Linux intel ac97 drivers. -- Lin Zuojian
> 
> _______________________________________________ vbox-dev mailing
> list vbox-dev at virtualbox.org 
> https://www.virtualbox.org/mailman/listinfo/vbox-dev
> 
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2

iQIcBAEBCAAGBQJWi9/xAAoJEDL4unptxHjP4NkQAIK4SdXUtbWRw48c+USHpocz
xUZI1Dz5BfzsjUsvVW1yMFqSOYvFOacx+eFsTJYu324ISH5vJrsktndxz0YENywb
SrbL7lksp/1Fu6Jk1iVAUnLEZA/o8TS688EHnGhcSbeSLAJ/Q9WmJlUf83sTOsBq
dPbk/+yF/yR8eqOF3riOGpKN3cg2Gtx32bwsztbGOiJRigX7STNZJIB92+EBPKwx
9IdiBaPhQIisIMV6EVrZ1KR3Bm863EcsdFgF+6gWGVLkP1Ndm149JS0Tc1CM1C1i
vSGtbN/igzBkviLfoHHzIWV16DuIHlrka7XFE0Hu5QwwGd74K+4+/4hid67t2BJF
Thtsw4y9njq8zgG7qeRnOkgisxmA/gQA79OQVLz8NatR7TnEDmQtdQwD/8X81+h5
/TCrdpNAExKB/wqbbmuxXB9eylFOoVjDu3Tvt5dyjVQAEqIQ8Op2RE2YfqPoZVm4
tBtx1R+7YJnKAvG7X5R0dPolINENEuL6rJkZezUhrxEm1eLo9s5IbIdT20z48Ucv
oAjoAV7tzsVilb/zwMRgrHTvHJIg82g80cg3/AdYYX6FoJd+iynoruPOgHIHCW4Y
epTRKANCp/8CQN24BFeIn3Di1Y8Zt1TYXoQIeRfyyT2IrBxYNZEe5oZ3mLuuNPNO
k1cbA3UF53F15ZWWR7Qo
=WLTm
-----END PGP SIGNATURE-----
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0x6DC478CF.asc
Type: application/pgp-keys
Size: 3124 bytes
Desc: not available
Url : http://www.virtualbox.org/pipermail/vbox-dev/attachments/20160105/3faee785/attachment.bin 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0x6DC478CF.asc.sig
Type: application/octet-stream
Size: 543 bytes
Desc: not available
Url : http://www.virtualbox.org/pipermail/vbox-dev/attachments/20160105/3faee785/attachment.obj 


More information about the vbox-dev mailing list