Skip to content

ASoC: SOF: Intel: HDA: correct ROM status mask - #1089

Merged
plbossart merged 1 commit into
thesofproject:topic/sof-devfrom
keyonjie:cavs18_boot
Jul 22, 2019
Merged

plbossart merged 1 commit into
thesofproject:topic/sof-devfrom
keyonjie:cavs18_boot

Conversation

@keyonjie

Copy link
Copy Markdown

We are using the lowest 2 digits of the ROM status register to denote
the status code, so the mask for it should be 0xff, here correct it.

Signed-off-by: Keyon Jie yang.jie@linux.intel.com

@keyonjie

keyonjie commented Jul 17, 2019 •

Copy link
Copy Markdown
Author

@ClarexZhou can you help try if this PR can fix #969 please?

@xiulipan as discussed, may be helpful for your boot failure also.

xiulipan
xiulipan previously approved these changes Jul 17, 2019

@xiulipan xiulipan left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

@keyonjie
Some comments issue:
lowest 2 digits => lowest 2 bytes

And maybe you can mentioned the error we meet here to treat 0x600021 as 0x500001 when use 0xf as mask.

Other looks fine

@kv2019i

kv2019i commented Jul 17, 2019

Copy link
Copy Markdown
Collaborator

@xiulipan wrote:

Some comments issue:
lowest 2 digits => lowest 2 bytes

Hmm, the mask (0xff) in patch is for one byte still, which is right, description or patch? @keyonjie ?

@keyonjie
keyonjie force-pushed the cavs18_boot branch 2 times, most recently from 20bae87 to 62e9cb6 Compare July 17, 2019 10:35
@keyonjie

Copy link
Copy Markdown
Author

@xiulipan wrote:

Some comments issue:
lowest 2 digits => lowest 2 bytes

Hmm, the mask (0xff) in patch is for one byte still, which is right, description or patch? @keyonjie ?

yes, it is 8 bits = 2 digits(in hex) = 1 bytes, let me use "bits" to make it clearer.

RanderWang
RanderWang previously approved these changes Jul 17, 2019

@RanderWang RanderWang left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

LGTM

kv2019i
kv2019i previously approved these changes Jul 17, 2019

@kv2019i kv2019i 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.

Thanks, looks good now!

@plbossart plbossart 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.

the commit message can be improved.

"Without this change, we treated status like 0x6000021 (0x1 as the lowest
4 bits) as HDA_DSP_ROM_INIT (0x1 as the lowest 4 bits)"

This value 0x6000021 is not listed as a valid code in the defines, so this looks like a work-around without fixing the root cause. Or you have to explain what this code is and what using the full 8 bits will do.

While we are at it, it's very odd to have a mix of hex and decimal values as error codes. this is ugly and should be fixed.

Also you have a grammar error, it's "downloading too early", not "too earlier"

@kv2019i

kv2019i commented Jul 17, 2019

Copy link
Copy Markdown
Collaborator

@plbossart @keyonjie wrote:

"Without this change, we treated status like 0x6000021 (0x1 as the lowest
4 bits) as HDA_DSP_ROM_INIT (0x1 as the lowest 4 bits)"

This value 0x6000021 is not listed as a valid code in the defines, so this looks like a work-around
without fixing the root cause. Or you have to explain what this code is and what using the full 8 bits
will do.
[...]
While we are at it, it's very odd to have a mix of hex and decimal values as error codes. this is
ugly and should be fixed.

I was trying earlier today to find a good reference for this when reviewing. Probably this is best:
https://thesofproject.github.io/latest/architectures/dsp/intel/cavs-boot/apollolake/apl-boot-rom.html

ROM_STATUS has values larger than 0xf, so the patch seems correct. And if this indeed helps with #969 , this is a very nice find (given the difficult of reproducing the problem).

But yeah, some background on 0x6000021 would be good. I believe ROM uses similar approach as FW_STATUS to use upper 24bit to report state while processing is ongoing (documented in above link). @keyonjie can you confirm this?

@ranj063

ranj063 commented Jul 17, 2019

Copy link
Copy Markdown
Collaborator

I am also a bit confused about the commit message. I agree that 0xff is the right status mask but then the INIT_DONE status is only 0x1. So do you mean to say that 0x21 isnt the right status and should be ignored until the 0x01 is read?

@keyonjie

Copy link
Copy Markdown
Author

I am also a bit confused about the commit message. I agree that 0xff is the right status mask but then the INIT_DONE status is only 0x1. So do you mean to say that 0x21 isnt the right status and should be ignored until the 0x01 is read?

yes.

@keyonjie

Copy link
Copy Markdown
Author

@plbossart @keyonjie wrote:

"Without this change, we treated status like 0x6000021 (0x1 as the lowest
4 bits) as HDA_DSP_ROM_INIT (0x1 as the lowest 4 bits)"
This value 0x6000021 is not listed as a valid code in the defines, so this looks like a work-around
without fixing the root cause. Or you have to explain what this code is and what using the full 8 bits
will do.
[...]
While we are at it, it's very odd to have a mix of hex and decimal values as error codes. this is
ugly and should be fixed.

I was trying earlier today to find a good reference for this when reviewing. Probably this is best:
https://thesofproject.github.io/latest/architectures/dsp/intel/cavs-boot/apollolake/apl-boot-rom.html

ROM_STATUS has values larger than 0xf, so the patch seems correct. And if this indeed helps with #969 , this is a very nice find (given the difficult of reproducing the problem).

But yeah, some background on 0x6000021 would be good. I believe ROM uses similar approach as FW_STATUS to use upper 24bit to report state while processing is ongoing (documented in above link). @keyonjie can you confirm this?

Yes, the above link you provided is for APL, for 1.8, I believe they have extended the state that's why we are seeing 0x21 on CNL/WHL/TGL. Maybe a new page in the document for 1.8 will be helpful, @jajanusz can you help on that?

union fw_status_reg
{
        int32_t full;
        struct Bits
        {
                uint32_t state      : 24;
                uint32_t wait_state : 4;
                uint32_t module     : 3;
                uint32_t running    : 1;
        } bits;
};

@ranj063

ranj063 commented Jul 18, 2019

Copy link
Copy Markdown
Collaborator

@keyonjie how about something like this:
"ROM status is represented by the 8 LSB bits in the status register. So the status mask should be 0xff instead of 0xf. Without this change, status such as 0x6000021 (0x1 as the lowest 4 bits) could be treated as as HDA_DSP_ROM_INIT (0x1 as the lowest 4 bits) and FW loading could end up getting started too soon resulting in failures."

@keyonjie

Copy link
Copy Markdown
Author

the commit message can be improved.

"Without this change, we treated status like 0x6000021 (0x1 as the lowest
4 bits) as HDA_DSP_ROM_INIT (0x1 as the lowest 4 bits)"

This value 0x6000021 is not listed as a valid code in the defines, so this looks like a work-around without fixing the root cause. Or you have to explain what this code is and what using the full 8 bits will do.

As I just replied to @kv2019i, the 0x21 is new extended in cAVS 1.8, that's why we don't see it the document for APL.

Ideally we should use 24 bits according the definition of fw_status_reg, I chose 8 bits only as what ROM used until now has not exceed 8 bits yet.

union fw_status_reg
{
        int32_t full;
        struct Bits
        {
                uint32_t state      : 24;
                uint32_t wait_state : 4;
                uint32_t module     : 3;
                uint32_t running    : 1;
        } bits;
};

While we are at it, it's very odd to have a mix of hex and decimal values as error codes. this is ugly and should be fixed.

I think they are defining state macros in hex and error code in decimal in ROM header file.

Also you have a grammar error, it's "downloading too early", not "too earlier"

Thanks, change it now.

@keyonjie

keyonjie commented Jul 18, 2019 •

Copy link
Copy Markdown
Author

@keyonjie how about something like this:
"ROM status is represented by the 8 LSB bits in the status register. So the status mask should be 0xff instead of 0xf. Without this change, status such as 0x6000021 (0x1 as the lowest 4 bits) could be treated as as HDA_DSP_ROM_INIT (0x1 as the lowest 4 bits) and FW loading could end up getting started too soon resulting in failures."

Thanks, but this still not addressing @plbossart's comment about what 0x6000021 is, and why it is the 8 LSB bits.

I am considering to drop this description about 0x6000021, and change the mask to lowest 24 bits, any comment? @ranj063 @plbossart @kv2019i

@keyonjie
keyonjie dismissed stale reviews from kv2019i and RanderWang via 6e8fd7c July 18, 2019 02:02
@ranj063

ranj063 commented Jul 18, 2019

Copy link
Copy Markdown
Collaborator

I am considering to drop this description about 0x6000021, and change the mask to lowest 24 bits, any comment? @ranj063 @plbossart @kv2019i

@keyonjie yes, I think it is the right thing to do.

xiulipan
xiulipan previously approved these changes Jul 18, 2019

@xiulipan xiulipan left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

LGTM.

@ranj063

ranj063 commented Jul 18, 2019

Copy link
Copy Markdown
Collaborator

@keyonjie pointing to the APL ROM documentation will make people wonder if it applies to all platforms. Can you please clarify it in the commit message?

@keyonjie

Copy link
Copy Markdown
Author

@keyonjie pointing to the APL ROM documentation will make people wonder if it applies to all platforms. Can you please clarify it in the commit message?

@ranj063 The 24 bits mask apply to all platforms.

@keyonjie
keyonjie requested a review from plbossart July 18, 2019 05:31
@ClarexZhou

ClarexZhou commented Jul 18, 2019 •

Copy link
Copy Markdown

Error #969 not occurred with #1089 after run 2k interactions s3 without playback stress test on both ICL HD-A RVP and CFL HD-A notebook.
Kernel: topic/sof-dev: 04b9bfe + PR#1089

@jajanusz

Copy link
Copy Markdown

Yes, the above link you provided is for APL, for 1.8, I believe they have extended the state that's why we are seeing 0x21 on CNL/WHL/TGL. Maybe a new page in the document for 1.8 will be helpful, @jajanusz can you help on that?

What do you mean by extended the state?
The fact that you see f.e. something like this for cnl rom code:

uint32_t state      : 28;
uint32_t module     : 3;
uint32_t running    : 1;

vs what is in docs:

uint32_t state      : 24;
uint32_t wait_state : 4;
uint32_t module     : 3;
uint32_t running    : 1;

doesn't change the fact that it works as it is in docs, these 4 bits (noted as wait_state) are handled in the same way anyway.

It depends on how you look at state overall, usually 24 later bits are changing less often as it is some bigger part f.e. CSE verification, while wait_state will change often meantime, f.e. for every ipc (wait/busy/done/etc)

@keyonjie

Copy link
Copy Markdown
Author

Yes, the above link you provided is for APL, for 1.8, I believe they have extended the state that's why we are seeing 0x21 on CNL/WHL/TGL. Maybe a new page in the document for 1.8 will be helpful, @jajanusz can you help on that?

What do you mean by extended the state?

I meant new 0x21(xx_IPC_RESET_PHASE_1) added for 1.8 only.

The fact that you see f.e. something like this for cnl rom code:

uint32_t state      : 28;
uint32_t module     : 3;
uint32_t running    : 1;

vs what is in docs:

uint32_t state      : 24;
uint32_t wait_state : 4;
uint32_t module     : 3;
uint32_t running    : 1;

doesn't change the fact that it works as it is in docs, these 4 bits (noted as wait_state) are handled in the same way anyway.

It depends on how you look at state overall, usually 24 later bits are changing less often as it is some bigger part f.e. CSE verification, while wait_state will change often meantime, f.e. for every ipc (wait/busy/done/etc)

Thanks for explaining @jajanusz , yes, that's true, previously we only used the LSB 4 bits of the state, here we are correcting it to use the whole LSB 24 bits.

kv2019i
kv2019i previously approved these changes Jul 18, 2019
@kv2019i

kv2019i commented Jul 18, 2019

Copy link
Copy Markdown
Collaborator
uint32_t state      : 24;
uint32_t wait_state : 4;
uint32_t module     : 3;
uint32_t running    : 1;

A pedantic note @jajanusz @keyonjie : bitfields in C are highly compiler and platform dependent, so in documenting binary interfaces (seen by multiple CPUs), better to simply use plain ol' bitmasks and document endianess.

Here also mismatch between use of "state" and "status" is confusing.

Anyways, patch looks good!

@jajanusz

Copy link
Copy Markdown
uint32_t state      : 24;
uint32_t wait_state : 4;
uint32_t module     : 3;
uint32_t running    : 1;

A pedantic note @jajanusz @keyonjie : bitfields in C are highly compiler and platform dependent, so in documenting binary interfaces (seen by multiple CPUs), better to simply use plain ol' bitmasks and document endianess.

Here also mismatch between use of "state" and "status" is confusing.

Anyways, patch looks good!

We don't use them in FW code, these bitfields are from rom code that we don't develop ;)

ranj063
ranj063 previously approved these changes Jul 18, 2019

@plbossart plbossart 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.

nit-pick below

Comment thread sound/soc/sof/intel/hda.h Outdated

/* ROM status/error values */
#define HDA_DSP_ROM_STS_MASK 0xf
#define HDA_DSP_ROM_STS_MASK 0xffffff

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.

GENMASK(23, 0)?
this will be an upstream comment so might as well fix it now.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

yes, changing it now.

@kv2019i

kv2019i commented Jul 18, 2019

Copy link
Copy Markdown
Collaborator

A pedantic note @jajanusz @keyonjie : bitfields in C are highly compiler and platform dependent, so >
We don't use them in FW code, these bitfields are from rom code that we don't develop ;)

@jajanusz Ok good, just checking :)

@keyonjie
keyonjie dismissed stale reviews from ranj063 and kv2019i via ee7fcb6 July 22, 2019 01:20
@keyonjie
keyonjie requested a review from plbossart July 22, 2019 01:21
The ROM state is represented by the 24 LSB bits in the ROM status
register, so the mask should be 0xffffff instead of 0xf.

Signed-off-by: Keyon Jie <yang.jie@linux.intel.com>

@plbossart plbossart 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.

Thanks @keyonjie

@plbossart
plbossart merged commit f745362 into thesofproject:topic/sof-dev Jul 22, 2019
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.

8 participants