From c6ea5adf32030126f5bb4362c1ca4c908b57d77a Mon Sep 17 00:00:00 2001 From: CoolStar Date: Wed, 29 Nov 2023 00:33:13 -0800 Subject: [PATCH 1/8] Use x_REGISTER_NOFENCE_ULONG --- drivers/audio/csaudiork3x/Source/Utilities/hw.cpp | 4 ++-- drivers/dma/pl330dma/pl330.c | 4 ++-- drivers/gpio/rk3xgpio/rk3xgpio.c | 4 ++-- drivers/i2c/rk3xi2c/rk3xi2c.c | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/audio/csaudiork3x/Source/Utilities/hw.cpp b/drivers/audio/csaudiork3x/Source/Utilities/hw.cpp index 7d8ad40..5e39028 100644 --- a/drivers/audio/csaudiork3x/Source/Utilities/hw.cpp +++ b/drivers/audio/csaudiork3x/Source/Utilities/hw.cpp @@ -103,13 +103,13 @@ CCsAudioRk3xHW::~CCsAudioRk3xHW() { #if USERKHW static UINT32 read32(PVOID addr) { - UINT32 ret = *(UINT32*)addr; + UINT32 ret = READ_REGISTER_NOFENCE_ULONG((ULONG *)addr); //DbgPrint("Read from %p: 0x%x\n", addr, ret); return ret; } static void write32(PVOID addr, UINT32 data) { - *(UINT32*)addr = data; + WRITE_REGISTER_NOFENCE_ULONG((ULONG *)addr, data); //DbgPrint("Write to %p: 0x%x\n", addr, data); } diff --git a/drivers/dma/pl330dma/pl330.c b/drivers/dma/pl330dma/pl330.c index 42773f8..6dd18a5 100644 --- a/drivers/dma/pl330dma/pl330.c +++ b/drivers/dma/pl330dma/pl330.c @@ -15,11 +15,11 @@ void udelay(ULONG usec) { UINT32 read32(PPL330DMA_CONTEXT pDevice, UINT32 reg) { - return *(UINT32 *)((CHAR *)pDevice->MMIOAddress + reg); + return READ_REGISTER_NOFENCE_ULONG((ULONG *)((CHAR*)pDevice->MMIOAddress + reg)); } void write32(PPL330DMA_CONTEXT pDevice, UINT32 reg, UINT32 val) { - *(UINT32 *)((CHAR *)pDevice->MMIOAddress + reg) = val; + WRITE_REGISTER_NOFENCE_ULONG((ULONG *)((CHAR*)pDevice->MMIOAddress + reg), val); } NTSTATUS diff --git a/drivers/gpio/rk3xgpio/rk3xgpio.c b/drivers/gpio/rk3xgpio/rk3xgpio.c index f8410b2..1cdeb79 100644 --- a/drivers/gpio/rk3xgpio/rk3xgpio.c +++ b/drivers/gpio/rk3xgpio/rk3xgpio.c @@ -185,11 +185,11 @@ typedef struct _SIM_GPIO_CONTEXT { UINT32 read32(PROCKCHIP_GPIO_BANK pBank, UINT32 reg) { - return *(UINT32*)((CHAR*)pBank->VirtualBaseAddress + reg); + return READ_REGISTER_NOFENCE_ULONG((ULONG *)((CHAR*)pBank->VirtualBaseAddress + reg)); } void write32(PROCKCHIP_GPIO_BANK pBank, UINT32 reg, UINT32 val) { - *(UINT32*)((CHAR*)pBank->VirtualBaseAddress + reg) = val; + WRITE_REGISTER_NOFENCE_ULONG((ULONG *)((CHAR*)pBank->VirtualBaseAddress + reg), val); } void gpio_write32_v2(PROCKCHIP_GPIO_BANK pBank, UINT32 reg, UINT32 val) { diff --git a/drivers/i2c/rk3xi2c/rk3xi2c.c b/drivers/i2c/rk3xi2c/rk3xi2c.c index a9f5dc8..1bff06b 100644 --- a/drivers/i2c/rk3xi2c/rk3xi2c.c +++ b/drivers/i2c/rk3xi2c/rk3xi2c.c @@ -9,11 +9,11 @@ static ULONG Rk3xI2CDebugCatagories = DBG_INIT || DBG_PNP || DBG_IOCTL; UINT32 read32(PRK3XI2C_CONTEXT pDevice, UINT32 reg) { - return *(UINT32 *)((CHAR *)pDevice->MMIOAddress + reg); + return READ_REGISTER_NOFENCE_ULONG((ULONG *)((CHAR*)pDevice->MMIOAddress + reg)); } void write32(PRK3XI2C_CONTEXT pDevice, UINT32 reg, UINT32 val) { - *(UINT32 *)((CHAR *)pDevice->MMIOAddress + reg) = val; + WRITE_REGISTER_NOFENCE_ULONG((ULONG *)((CHAR*)pDevice->MMIOAddress + reg), val); } NTSTATUS From 8508423eac73808f158d3d46974936d804d4e08a Mon Sep 17 00:00:00 2001 From: CoolStar Date: Wed, 29 Nov 2023 00:42:54 -0800 Subject: [PATCH 2/8] Use built-in _BitScanForward instead of porting _ffs from Linux --- drivers/dma/pl330dma/bitops.h | 36 ---------------------- drivers/dma/pl330dma/driver.h | 1 - drivers/dma/pl330dma/insn.c | 3 +- drivers/dma/pl330dma/pl330.vcxproj | 1 - drivers/dma/pl330dma/pl330.vcxproj.Filters | 3 -- 5 files changed, 2 insertions(+), 42 deletions(-) delete mode 100644 drivers/dma/pl330dma/bitops.h diff --git a/drivers/dma/pl330dma/bitops.h b/drivers/dma/pl330dma/bitops.h deleted file mode 100644 index 5616cd6..0000000 --- a/drivers/dma/pl330dma/bitops.h +++ /dev/null @@ -1,36 +0,0 @@ -/** - * __ffs - find first bit in word. - * @word: The word to search - * - * Undefined if no bit exists, so code should check against 0 first. - */ -static unsigned long __ffs(unsigned long word) -{ - int num = 0; - -#if BITS_PER_LONG == 64 - if ((word & 0xffffffff) == 0) { - num += 32; - word >>= 32; - } -#endif - if ((word & 0xffff) == 0) { - num += 16; - word >>= 16; - } - if ((word & 0xff) == 0) { - num += 8; - word >>= 8; - } - if ((word & 0xf) == 0) { - num += 4; - word >>= 4; - } - if ((word & 0x3) == 0) { - num += 2; - word >>= 2; - } - if ((word & 0x1) == 0) - num += 1; - return num; -} \ No newline at end of file diff --git a/drivers/dma/pl330dma/driver.h b/drivers/dma/pl330dma/driver.h index 94036c5..2602067 100644 --- a/drivers/dma/pl330dma/driver.h +++ b/drivers/dma/pl330dma/driver.h @@ -15,7 +15,6 @@ #include #include -#include "bitops.h" #include "pl330.h" #include diff --git a/drivers/dma/pl330dma/insn.c b/drivers/dma/pl330dma/insn.c index a442154..dd3e398 100644 --- a/drivers/dma/pl330dma/insn.c +++ b/drivers/dma/pl330dma/insn.c @@ -263,7 +263,8 @@ NTSTATUS SubmitAudioDMA( ccr |= ((maxBurst - 1) << CC_SRCBRSTLEN_SHFT); ccr |= ((maxBurst - 1) << CC_DSTBRSTLEN_SHFT); - UINT32 burstSz = __ffs(addrWidth); //bus width = 4 bytes + ULONG burstSz = 0; + _BitScanForward(&burstSz, addrWidth); ccr |= (burstSz << CC_SRCBRSTSIZE_SHFT); ccr |= (burstSz << CC_DSTBRSTSIZE_SHFT); ccr |= (CCTRL0 << CC_SRCCCTRL_SHFT); diff --git a/drivers/dma/pl330dma/pl330.vcxproj b/drivers/dma/pl330dma/pl330.vcxproj index 267af96..18dce36 100644 --- a/drivers/dma/pl330dma/pl330.vcxproj +++ b/drivers/dma/pl330dma/pl330.vcxproj @@ -95,7 +95,6 @@ - diff --git a/drivers/dma/pl330dma/pl330.vcxproj.Filters b/drivers/dma/pl330dma/pl330.vcxproj.Filters index 4308396..cc4e780 100644 --- a/drivers/dma/pl330dma/pl330.vcxproj.Filters +++ b/drivers/dma/pl330dma/pl330.vcxproj.Filters @@ -52,9 +52,6 @@ Header Files - - Header Files - Header Files From efcb025e5c60f008a8b84fea0fead7b813791de6 Mon Sep 17 00:00:00 2001 From: CoolStar Date: Wed, 29 Nov 2023 00:45:23 -0800 Subject: [PATCH 3/8] Don't re-read the same register multiple times --- drivers/dma/pl330dma/dmacontroller.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/drivers/dma/pl330dma/dmacontroller.c b/drivers/dma/pl330dma/dmacontroller.c index cfd4f06..267758a 100644 --- a/drivers/dma/pl330dma/dmacontroller.c +++ b/drivers/dma/pl330dma/dmacontroller.c @@ -4,22 +4,24 @@ static ULONG Pl330DmaDebugLevel = 100; static ULONG Pl330DmaDebugCatagories = DBG_INIT || DBG_PNP || DBG_IOCTL; void ReadDmacConfiguration(PPL330DMA_CONTEXT pDevice) { + const UINT32 crd = read32(pDevice, CRD); + const UINT32 cr0 = read32(pDevice, CR0); UINT32 val; - val = read32(pDevice, CRD) >> CRD_DATA_WIDTH_SHIFT; + val = crd >> CRD_DATA_WIDTH_SHIFT; val &= CRD_DATA_WIDTH_MASK; pDevice->Config.DataBusWidth = 8 * (1 << val); - val = read32(pDevice, CRD) >> CRD_DATA_BUFF_SHIFT; + val = crd >> CRD_DATA_BUFF_SHIFT; val &= CRD_DATA_BUFF_MASK; pDevice->Config.DataBufDepth = val + 1; - val = read32(pDevice, CRD) >> CR0_NUM_CHANS_SHIFT; + val = crd >> CR0_NUM_CHANS_SHIFT; val &= CR0_NUM_CHANS_MASK; val += 1; pDevice->Config.NumChan = val; - val = read32(pDevice, CR0); + val = cr0; if (val & CR0_PERIPH_REQ_SET) { val = (val >> CR0_NUM_PERIPH_SHIFT) & CR0_NUM_PERIPH_MASK; val += 1; @@ -30,13 +32,13 @@ void ReadDmacConfiguration(PPL330DMA_CONTEXT pDevice) { pDevice->Config.NumPeripherals = 0; } - val = read32(pDevice, CR0); + val = cr0; if (val & CR0_BOOT_MAN_NS) pDevice->Config.Mode |= DMAC_MODE_NS; else pDevice->Config.Mode &= ~DMAC_MODE_NS; - val = read32(pDevice, CR0) >> CR0_NUM_EVENTS_SHIFT; + val = cr0 >> CR0_NUM_EVENTS_SHIFT; val &= CR0_NUM_EVENTS_MASK; val += 1; pDevice->Config.NumEvents = val; From 58d072ee1cf11c221b569a572d8f2206f84174ec Mon Sep 17 00:00:00 2001 From: CoolStar Date: Wed, 29 Nov 2023 01:28:57 -0800 Subject: [PATCH 4/8] Disable WPP tracing in DMA and I2C driver --- drivers/dma/pl330dma/pl330.vcxproj | 5 +-- drivers/dma/pl330dma/pl330.vcxproj.Filters | 3 -- drivers/dma/pl330dma/trace.h | 43 --------------------- drivers/i2c/rk3xi2c/rk3xi2c.vcxproj | 5 +-- drivers/i2c/rk3xi2c/rk3xi2c.vcxproj.Filters | 3 -- drivers/i2c/rk3xi2c/trace.h | 43 --------------------- 6 files changed, 4 insertions(+), 98 deletions(-) delete mode 100644 drivers/dma/pl330dma/trace.h delete mode 100644 drivers/i2c/rk3xi2c/trace.h diff --git a/drivers/dma/pl330dma/pl330.vcxproj b/drivers/dma/pl330dma/pl330.vcxproj index 18dce36..8f50900 100644 --- a/drivers/dma/pl330dma/pl330.vcxproj +++ b/drivers/dma/pl330dma/pl330.vcxproj @@ -53,11 +53,11 @@ - true trace.h true false ..\..\include;%(AdditionalIncludeDirectories) + false 1.0.0 @@ -71,11 +71,11 @@ - true trace.h true false ..\..\include;%(AdditionalIncludeDirectories) + false 1.0.0 @@ -98,7 +98,6 @@ - diff --git a/drivers/dma/pl330dma/pl330.vcxproj.Filters b/drivers/dma/pl330dma/pl330.vcxproj.Filters index cc4e780..34a7b23 100644 --- a/drivers/dma/pl330dma/pl330.vcxproj.Filters +++ b/drivers/dma/pl330dma/pl330.vcxproj.Filters @@ -46,9 +46,6 @@ Header Files - - Header Files - Header Files diff --git a/drivers/dma/pl330dma/trace.h b/drivers/dma/pl330dma/trace.h deleted file mode 100644 index 19b0bdf..0000000 --- a/drivers/dma/pl330dma/trace.h +++ /dev/null @@ -1,43 +0,0 @@ -#include - -#ifndef _TRACE_H_ -#define _TRACE_H_ - -extern "C" -{ - // - // Tracing Definitions: - // - // Control GUID: - // {73e3b785-f5fb-423e-94a9-56627fea9053} - // - -#define WPP_CONTROL_GUIDS \ - WPP_DEFINE_CONTROL_GUID( \ - SpbTestToolTraceGuid, \ - (73e3b785,f5fb,423e,94a9,56627fea9053), \ - WPP_DEFINE_BIT(TRACE_FLAG_WDFLOADING) \ - WPP_DEFINE_BIT(TRACE_FLAG_SPBAPI) \ - WPP_DEFINE_BIT(TRACE_FLAG_OTHER) \ - ) -} - -#define WPP_LEVEL_FLAGS_LOGGER(level,flags) WPP_LEVEL_LOGGER(flags) -#define WPP_LEVEL_FLAGS_ENABLED(level, flags) (WPP_LEVEL_ENABLED(flags) && WPP_CONTROL(WPP_BIT_ ## flags).Level >= level) - -#define Trace CyapaPrint -#define FuncEntry -#define FuncExit -#define WPP_INIT_TRACING -#define WPP_CLEANUP -#define TRACE_FLAG_SPBAPI 0 -#define TRACE_FLAG_WDFLOADING 0 - -// begin_wpp config -// FUNC FuncEntry{LEVEL=TRACE_LEVEL_VERBOSE}(FLAGS); -// FUNC FuncExit{LEVEL=TRACE_LEVEL_VERBOSE}(FLAGS); -// USEPREFIX(FuncEntry, "%!STDPREFIX! [%!FUNC!] --> entry"); -// USEPREFIX(FuncExit, "%!STDPREFIX! [%!FUNC!] <--"); -// end_wpp - -#endif _TRACE_H_ diff --git a/drivers/i2c/rk3xi2c/rk3xi2c.vcxproj b/drivers/i2c/rk3xi2c/rk3xi2c.vcxproj index 60c22da..48304cd 100644 --- a/drivers/i2c/rk3xi2c/rk3xi2c.vcxproj +++ b/drivers/i2c/rk3xi2c/rk3xi2c.vcxproj @@ -53,7 +53,7 @@ - true + false trace.h true false @@ -71,7 +71,7 @@ - true + false trace.h true false @@ -97,7 +97,6 @@ - diff --git a/drivers/i2c/rk3xi2c/rk3xi2c.vcxproj.Filters b/drivers/i2c/rk3xi2c/rk3xi2c.vcxproj.Filters index 3fe3ecf..6404e2a 100644 --- a/drivers/i2c/rk3xi2c/rk3xi2c.vcxproj.Filters +++ b/drivers/i2c/rk3xi2c/rk3xi2c.vcxproj.Filters @@ -49,8 +49,5 @@ Header Files - - Header Files - \ No newline at end of file diff --git a/drivers/i2c/rk3xi2c/trace.h b/drivers/i2c/rk3xi2c/trace.h deleted file mode 100644 index 19b0bdf..0000000 --- a/drivers/i2c/rk3xi2c/trace.h +++ /dev/null @@ -1,43 +0,0 @@ -#include - -#ifndef _TRACE_H_ -#define _TRACE_H_ - -extern "C" -{ - // - // Tracing Definitions: - // - // Control GUID: - // {73e3b785-f5fb-423e-94a9-56627fea9053} - // - -#define WPP_CONTROL_GUIDS \ - WPP_DEFINE_CONTROL_GUID( \ - SpbTestToolTraceGuid, \ - (73e3b785,f5fb,423e,94a9,56627fea9053), \ - WPP_DEFINE_BIT(TRACE_FLAG_WDFLOADING) \ - WPP_DEFINE_BIT(TRACE_FLAG_SPBAPI) \ - WPP_DEFINE_BIT(TRACE_FLAG_OTHER) \ - ) -} - -#define WPP_LEVEL_FLAGS_LOGGER(level,flags) WPP_LEVEL_LOGGER(flags) -#define WPP_LEVEL_FLAGS_ENABLED(level, flags) (WPP_LEVEL_ENABLED(flags) && WPP_CONTROL(WPP_BIT_ ## flags).Level >= level) - -#define Trace CyapaPrint -#define FuncEntry -#define FuncExit -#define WPP_INIT_TRACING -#define WPP_CLEANUP -#define TRACE_FLAG_SPBAPI 0 -#define TRACE_FLAG_WDFLOADING 0 - -// begin_wpp config -// FUNC FuncEntry{LEVEL=TRACE_LEVEL_VERBOSE}(FLAGS); -// FUNC FuncExit{LEVEL=TRACE_LEVEL_VERBOSE}(FLAGS); -// USEPREFIX(FuncEntry, "%!STDPREFIX! [%!FUNC!] --> entry"); -// USEPREFIX(FuncExit, "%!STDPREFIX! [%!FUNC!] <--"); -// end_wpp - -#endif _TRACE_H_ From cce1bdd1387b48fb24a9e47655d3840946bfe321 Mon Sep 17 00:00:00 2001 From: CoolStar Date: Wed, 29 Nov 2023 01:30:47 -0800 Subject: [PATCH 5/8] Cleanup DriverVer from inx's as StampINF is being used --- drivers/audio/rk3xi2sbus/rk3xi2sbus.inx | 1 - drivers/dma/pl330dma/pl330dma.inx | 1 - drivers/gpio/rk3xgpio/rk3xgpio.inx | 1 - drivers/i2c/rk3xi2c/rk3xi2c.inx | 1 - 4 files changed, 4 deletions(-) diff --git a/drivers/audio/rk3xi2sbus/rk3xi2sbus.inx b/drivers/audio/rk3xi2sbus/rk3xi2sbus.inx index 71e024f..468ed96 100644 --- a/drivers/audio/rk3xi2sbus/rk3xi2sbus.inx +++ b/drivers/audio/rk3xi2sbus/rk3xi2sbus.inx @@ -16,7 +16,6 @@ Signature = "$WINDOWS NT$" Class = System ClassGuid = {4d36e97d-e325-11ce-bfc1-08002be10318} Provider = CoolStar -DriverVer = 8/15/2022,1.0.0 CatalogFile = rk3xi2sbus.cat PnpLockdown = 1 diff --git a/drivers/dma/pl330dma/pl330dma.inx b/drivers/dma/pl330dma/pl330dma.inx index 9d8d5c9..3813f89 100644 --- a/drivers/dma/pl330dma/pl330dma.inx +++ b/drivers/dma/pl330dma/pl330dma.inx @@ -16,7 +16,6 @@ Signature = "$WINDOWS NT$" Class = System ClassGuid = {4d36e97d-e325-11ce-bfc1-08002be10318} Provider = CoolStar -DriverVer = 6/30/2023,1.0.0 CatalogFile = pl330dma.cat PnpLockdown = 1 diff --git a/drivers/gpio/rk3xgpio/rk3xgpio.inx b/drivers/gpio/rk3xgpio/rk3xgpio.inx index 639deae..0a3f1ed 100644 --- a/drivers/gpio/rk3xgpio/rk3xgpio.inx +++ b/drivers/gpio/rk3xgpio/rk3xgpio.inx @@ -16,7 +16,6 @@ Signature = "$WINDOWS NT$" Class = System ClassGuid = {4d36e97d-e325-11ce-bfc1-08002be10318} Provider = CoolStar -DriverVer = 6/30/2023,1.0.0 CatalogFile = rk3xgpio.cat PnpLockdown = 1 diff --git a/drivers/i2c/rk3xi2c/rk3xi2c.inx b/drivers/i2c/rk3xi2c/rk3xi2c.inx index c09aab8..b490f91 100644 --- a/drivers/i2c/rk3xi2c/rk3xi2c.inx +++ b/drivers/i2c/rk3xi2c/rk3xi2c.inx @@ -16,7 +16,6 @@ Signature = "$WINDOWS NT$" Class = System ClassGuid = {4d36e97d-e325-11ce-bfc1-08002be10318} Provider = CoolStar -DriverVer = 6/30/2023,1.0.0 CatalogFile = rk3xi2c.cat PnpLockdown = 1 From 869583069692f47453085ee9f42b6e33d07575ef Mon Sep 17 00:00:00 2001 From: CoolStar Date: Wed, 29 Nov 2023 01:33:54 -0800 Subject: [PATCH 6/8] Move LICESNSE and README into respective driver folders for i2c, dma, gpio --- drivers/dma/{ => pl330dma}/LICENSE.txt | 0 drivers/dma/{ => pl330dma}/README.md | 0 drivers/gpio/{ => rk3xgpio}/LICENSE.txt | 0 drivers/gpio/{ => rk3xgpio}/README.md | 0 drivers/i2c/{ => rk3xi2c}/LICENSE.txt | 0 drivers/i2c/{ => rk3xi2c}/README.md | 0 6 files changed, 0 insertions(+), 0 deletions(-) rename drivers/dma/{ => pl330dma}/LICENSE.txt (100%) rename drivers/dma/{ => pl330dma}/README.md (100%) rename drivers/gpio/{ => rk3xgpio}/LICENSE.txt (100%) rename drivers/gpio/{ => rk3xgpio}/README.md (100%) rename drivers/i2c/{ => rk3xi2c}/LICENSE.txt (100%) rename drivers/i2c/{ => rk3xi2c}/README.md (100%) diff --git a/drivers/dma/LICENSE.txt b/drivers/dma/pl330dma/LICENSE.txt similarity index 100% rename from drivers/dma/LICENSE.txt rename to drivers/dma/pl330dma/LICENSE.txt diff --git a/drivers/dma/README.md b/drivers/dma/pl330dma/README.md similarity index 100% rename from drivers/dma/README.md rename to drivers/dma/pl330dma/README.md diff --git a/drivers/gpio/LICENSE.txt b/drivers/gpio/rk3xgpio/LICENSE.txt similarity index 100% rename from drivers/gpio/LICENSE.txt rename to drivers/gpio/rk3xgpio/LICENSE.txt diff --git a/drivers/gpio/README.md b/drivers/gpio/rk3xgpio/README.md similarity index 100% rename from drivers/gpio/README.md rename to drivers/gpio/rk3xgpio/README.md diff --git a/drivers/i2c/LICENSE.txt b/drivers/i2c/rk3xi2c/LICENSE.txt similarity index 100% rename from drivers/i2c/LICENSE.txt rename to drivers/i2c/rk3xi2c/LICENSE.txt diff --git a/drivers/i2c/README.md b/drivers/i2c/rk3xi2c/README.md similarity index 100% rename from drivers/i2c/README.md rename to drivers/i2c/rk3xi2c/README.md From 5031f46e574d2a9e8b2e50c8450363b1eb504fa0 Mon Sep 17 00:00:00 2001 From: CoolStar Date: Wed, 29 Nov 2023 02:02:19 -0800 Subject: [PATCH 7/8] Use fence on I2S driver since it seems to slightly improve input --- drivers/audio/csaudiork3x/Source/Utilities/hw.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/audio/csaudiork3x/Source/Utilities/hw.cpp b/drivers/audio/csaudiork3x/Source/Utilities/hw.cpp index 5e39028..4e02a5d 100644 --- a/drivers/audio/csaudiork3x/Source/Utilities/hw.cpp +++ b/drivers/audio/csaudiork3x/Source/Utilities/hw.cpp @@ -103,13 +103,13 @@ CCsAudioRk3xHW::~CCsAudioRk3xHW() { #if USERKHW static UINT32 read32(PVOID addr) { - UINT32 ret = READ_REGISTER_NOFENCE_ULONG((ULONG *)addr); + UINT32 ret = READ_REGISTER_ULONG((ULONG *)addr); //DbgPrint("Read from %p: 0x%x\n", addr, ret); return ret; } static void write32(PVOID addr, UINT32 data) { - WRITE_REGISTER_NOFENCE_ULONG((ULONG *)addr, data); + WRITE_REGISTER_ULONG((ULONG *)addr, data); //DbgPrint("Write to %p: 0x%x\n", addr, data); } From 594a74c22259d5236b3c5ca41f6ce30a78133dab Mon Sep 17 00:00:00 2001 From: CoolStar Date: Wed, 29 Nov 2023 02:05:25 -0800 Subject: [PATCH 8/8] Use YieldProcessor in DMA driver --- drivers/dma/pl330dma/dmacontroller.c | 2 +- drivers/dma/pl330dma/pl330.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/dma/pl330dma/dmacontroller.c b/drivers/dma/pl330dma/dmacontroller.c index 267758a..106d0e2 100644 --- a/drivers/dma/pl330dma/dmacontroller.c +++ b/drivers/dma/pl330dma/dmacontroller.c @@ -120,7 +120,7 @@ static NTSTATUS UntilDmacIdle(PPL330DMA_THREAD Thread) if (!(read32(pDevice, DBGSTATUS) & DBG_BUSY)) return STATUS_SUCCESS; - __yield(); + YieldProcessor(); LARGE_INTEGER CurrentTime; KeQuerySystemTimePrecise(&CurrentTime); diff --git a/drivers/dma/pl330dma/pl330.h b/drivers/dma/pl330dma/pl330.h index b8451e7..d914fd4 100644 --- a/drivers/dma/pl330dma/pl330.h +++ b/drivers/dma/pl330dma/pl330.h @@ -222,7 +222,7 @@ enum pl330_byteswap { #define MCODE_BUFF_PER_REQ 256 /* Use this _only_ to wait on transient states */ -#define UNTIL(t, s) while (!(_state(t) & (s))) __yield(); +#define UNTIL(t, s) while (!(_state(t) & (s))) YieldProcessor(); /* The number of default descriptors */