Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

drivers: dma: intel_adsp_hda: fix intel_adsp_hda_unused() check #77805

Merged
merged 1 commit into from
Sep 4, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 13 additions & 13 deletions soc/intel/intel_adsp/common/include/intel_adsp_hda.h
Original file line number Diff line number Diff line change
Expand Up @@ -266,24 +266,24 @@ static inline bool intel_adsp_hda_is_enabled(uint32_t base, uint32_t regblock_si
*/
static inline uint32_t intel_adsp_hda_unused(uint32_t base, uint32_t regblock_size, uint32_t sid)
{
uint32_t dgcs = *DGCS(base, regblock_size, sid);
uint32_t dgbs = *DGBS(base, regblock_size, sid);

/* Check if buffer is empty */
if ((dgcs & DGCS_BNE) == 0) {
return dgbs;
}

/* Check if the buffer is full */
if (dgcs & DGCS_BF) {
return 0;
}

int32_t rp = *DGBRP(base, regblock_size, sid);
int32_t wp = *DGBWP(base, regblock_size, sid);
int32_t size = rp - wp;

if (size <= 0) {
if (size == 0) {
uint32_t dgcs = *DGCS(base, regblock_size, sid);

/* Check if buffer is empty */
if ((dgcs & DGCS_BNE) == 0) {
return dgbs;
}

/*
* Buffer is not empty and pointers equal, it can
* only be full, no need to check the DGCS_BF flag
*/
} else if (size < 0) {
size += dgbs;
}

Expand Down
Loading