Skip to content

dw-dma: fix regression - #1357

Merged
tlauda merged 1 commit into
thesofproject:masterfrom
lyakh:dwdma-20190502
May 7, 2019
Merged

dw-dma: fix regression#1357
tlauda merged 1 commit into
thesofproject:masterfrom
lyakh:dwdma-20190502

Conversation

@lyakh

@lyakh lyakh commented May 2, 2019

Copy link
Copy Markdown
Collaborator

Commit e2b994e ("dw-dma: cleanup the whole driver") introduced
bugs in bit-field calculations. This patch fixes them.
I think we want to have this for 1.3

@lyakh
lyakh requested a review from tlauda May 2, 2019 12:47
@lgirdwood lgirdwood added this to the 1.3 milestone May 2, 2019

@lgirdwood lgirdwood left a comment

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 assume these bits are only used on CAVS 1.8+ ?

@lyakh

lyakh commented May 2, 2019

Copy link
Copy Markdown
Collaborator Author

I assume these bits are only used on CAVS 1.8+ ?

At least I didn't change their use, I only fixed their definition. Looking at the sources those fields are only used for SPI and dai.c, where they are initialised from FIFO handshakes. As far as I understand that code is used on all platforms. But as long as handshakes are <= 15, that change has no effect.

@tlauda tlauda May 3, 2019

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why do they overlap? It doesn't seem correct.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

they don't overlap. x above has its low 4 bits = 0. So it's 0 or in the range 0x10 <= x <= 0x30 When you shift it by 24 bits you get bits 27..24 unaffected and bits 29..28 set. When you shift it by 26 bits you get bits 29..26 unaffected and only bits 31..30 set.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

But doing it this way makes it look weird and not right. Register definitions should be aligned with the real hardware. Better way would be to change DW_CFGH_DST and DW_CFGH_SRC macros:
(DW_CFGH_DST_PER_EXT(((x) & 0x30) >> 4) | DW_CFGH_DST_PER((x) & 0xF))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I agreed with @tlauda
If the only valid bits is 31,30, we should change the X value but not the definition here.
If we need some X value with low 4 bit is 0, you should add some comments here to explain.

@lyakh lyakh May 6, 2019

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

@tlauda sure, I agree, that this way the code is working around the definition. But it was your patch to begin using SET_BITS() here, so, I didn't want to change that. As for your proposed new definition, it's equivalent to mine, but it adds redundancy. It first shifts right by four bits to then shift left by 30 bits, which is in this case equivalent to just shifting left by 26 bits, which is exactly what my patch does. We can add a comment as @xiulipan has suggested, sure.

@tlauda tlauda May 6, 2019

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@lyakh Yes, it's redundant, but at least the definition is aligned with the hardware register definition. It doesn't seem right to modify it just to avoid redundancy. That's why the DW_CFGH_DST and DW_CFGH_SRC macros were introduced - to hide the internal logic of programming x value.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@lyakh @tlauda
Then let make the definition here map to hardware and add comment or change the logic in DW_CFGH_DST and DW_CFGH_SRC

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I think I've got a better version of the patch now.

Commit e2b994e ("dw-dma: cleanup the whole driver") introduced
bugs in bit-field calculations. This patch fixes them.

Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
@lyakh
lyakh force-pushed the dwdma-20190502 branch from 71b912b to 22e345d Compare May 6, 2019 14:56
@xiulipan

xiulipan commented May 6, 2019

Copy link
Copy Markdown
Contributor

Maybe add some inline comment to explain the >>4 is better.

@tlauda
tlauda merged commit a11aef2 into thesofproject:master May 7, 2019
@lyakh
lyakh deleted the dwdma-20190502 branch May 7, 2019 06:12
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.

4 participants