Skip to content

ssp: fix the RX FIFO flushing logic - #3476

Merged
lgirdwood merged 1 commit into
thesofproject:masterfrom
keyonjie:ssp_rx_flush
Oct 2, 2020
Merged

lgirdwood merged 1 commit into
thesofproject:masterfrom
keyonjie:ssp_rx_flush

Conversation

@keyonjie

Copy link
Copy Markdown
Contributor

To make sure all the RX FIFO entries are read out for the flushing, we
need wait until the SSSR_RNE is cleared after the SSP is disabled (the
SSSR_BSY is cleared, otherwise, there might be obsoleted entry remained
in the FIFO which will impact the next run with the SSP RX and lead to
sample mismatched issue.

BugLink: #3428
Cc: Bartosz Kokoszko bartoszx.kokoszko@linux.intel.com
Signed-off-by: Keyon Jie yang.jie@linux.intel.com

@paulstelian97 paulstelian97 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm gonna have to make similar fixes on NXP DAIs, so guess I'll take this as inspiration...

Comment thread src/drivers/intel/ssp/ssp.c Outdated
Comment thread src/drivers/intel/ssp/ssp.c Outdated
Comment thread src/drivers/intel/ssp/ssp.c Outdated
Comment thread src/drivers/intel/ssp/ssp.c Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I find this code absolutely horrible. The last ssp_read doesn't seem necessary and the inner loop with no limit looks like a bug.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I find this code absolutely horrible. The last ssp_read doesn't seem necessary and the inner loop with no limit looks like a bug.

@plbossart are you mean that this 'sssr = ssp_read(dai, SSSR)' is not necessary? It was original there, what's your point here?

For the inner loop with no limit, @ktrzcinx questioned about that above and I had answered above, the Linux kernel reference is here: https://github.com/torvalds/linux/blob/a1b8638ba1320e6684aa98233c15255eb803fac7/drivers/spi/spi-pxa2xx.c#L480

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My point exactly:

do {
		while (pxa2xx_spi_read(drv_data, SSSR) & SSSR_RNE)
			pxa2xx_spi_read(drv_data, SSDR);
	} while ((pxa2xx_spi_read(drv_data, SSSR) & SSSR_BSY) && --limit);
	write_SSSR_CS(drv_data, SSSR_ROR);

Why would you need another read after the 'while'?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My point exactly:

do {
		while (pxa2xx_spi_read(drv_data, SSSR) & SSSR_RNE)
			pxa2xx_spi_read(drv_data, SSDR);
	} while ((pxa2xx_spi_read(drv_data, SSSR) & SSSR_BSY) && --limit);
	write_SSSR_CS(drv_data, SSSR_ROR);

Why would you need another read after the 'while'?

Oh, makes sense, let me align it to kernel one and just clear the interrupt bit blindly.

done.

@lgirdwood lgirdwood added this to the v1.6 milestone Sep 30, 2020
@keyonjie
keyonjie requested a review from lgirdwood October 1, 2020 15:15
@fredoh9

fredoh9 commented Oct 1, 2020

Copy link
Copy Markdown
Contributor

SOFCI TEST

To make sure all the RX FIFO entries are read out for the flushing, we
need wait until the SSSR_RNE is cleared after the SSP is disabled (the
SSSR_BSY is cleared, otherwise, there might be obsoleted entry remained
in the FIFO which will impact the next run with the SSP RX and lead to
sample mismatched issue.

BugLink: thesofproject#3428
Cc: Bartosz Kokoszko <bartoszx.kokoszko@linux.intel.com>
Signed-off-by: Keyon Jie <yang.jie@linux.intel.com>
@lgirdwood
lgirdwood merged commit 242be34 into thesofproject:master Oct 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants