Skip to content

Add CHT fixes to CML release - #1862

Closed
cujomalainey wants to merge 4 commits into
thesofproject:cml-007-drop-stablefrom
cujomalainey:cml-007-drop-stable
Closed

cujomalainey wants to merge 4 commits into
thesofproject:cml-007-drop-stablefrom
cujomalainey:cml-007-drop-stable

Conversation

@cujomalainey

Copy link
Copy Markdown
Contributor

CHT and CML share the same kernel, therefore the fixes need to be instep on the same branches. This will allow strago boards to start using SOF for their uprev.

Notes: "topology: sof-cht-max98090: fix media pipeline" and "topology: sof-cht-max98090 move dai definition above media pipeline" did not apply cleanly and the HACK commit will be replaced once the final solution for disabling the CHT dmac has been merged into master

Need to add the SCHED_COMP name so pipeline will properly load

Signed-off-by: Curtis Malainey <cujomalainey@google.com>
Topology will fail to probe without these widgets

Signed-off-by: Curtis Malainey <cujomalainey@google.com>
The DAI definition needs to come first otherwise the media pipeline with
be parsed incorrectly resulting in a failure to load the topology

Signed-off-by: Curtis Malainey <cujomalainey@google.com>
The 3rd DMAC that CHT has seems to be causing issues. Since it is not
needed lets make it optional so the platform can be usable.

Signed-off-by: Curtis Malainey <cujomalainey@google.com>
@cujomalainey

Copy link
Copy Markdown
Contributor Author

Waiting on kernel driver release before I can fully test this

@lgirdwood

Copy link
Copy Markdown
Member

SOFCI TEST

@lgirdwood

Copy link
Copy Markdown
Member

@cujomalainey let me know how kernel test goes.

@cujomalainey

Copy link
Copy Markdown
Contributor Author

I got audio working but it is occasionally heavily distorted, playing a 440Hz Sine wave generates peaks at 164, 220, 270, 574, etc.

DMA also occasionally fails if playback through speaker-test is run without -D

    0      2          DMA          83057226.666667      8138.020996 src/drivers/dw/dma.c:1297   dw_dma_avail_data_size() size is 0! Channel enable = 0.                                                                                                                                    
    0      1      unknown          97154260.937500  14097034.000000 rc/trace/dma-trace.c:401    dtrace_add_event() error: number of dropped logs = 16730                                                                                                                                   
    0      2          IPC          97154259.739583              nan    src/ipc/handler.c:221    ipc: comp 1 -> params                                                                                                                                                                      
    0      2          DMA          97154270.052083        10.312500 src/drivers/dw/dma.c:192    dw_dma_channel_get(): dma 0 request channel 0                                                                                                                                              
    0      2          DMA          97154450.260417       180.208328 src/drivers/dw/dma.c:259    dw_dma_channel_put(): dma 0 channel 1 put                                                                                                                                                  
    0      2         PIPE 1.10     97154461.197917        10.937500 src/audio/pipeline.c:315    pipeline_params()                                                                                                                                                                          
    0      2         HOST          97154463.697917         2.500000     src/audio/host.c:511    host_params()                                                                                                                                                                              
    0      2          DMA          97154469.531250         5.833333 src/drivers/dw/dma.c:192    dw_dma_channel_get(): dma 1 request channel 65535                                                                                                                                          
    0      2       VOLUME          97154476.875000         7.343750 udio/volume/volume.c:247    volume_params()                                                                                                                                                                            
    0      2        MIXER          97154479.843750         2.968750    src/audio/mixer.c:160    mixer_params()                                                                                                                                                                             
    0      2       VOLUME          97154483.125000         3.281250 udio/volume/volume.c:247    volume_params()                                                                                                                                                                            
    0      2          DAI 1.9      97154486.093750         2.968750      src/audio/dai.c:356    dai_params()                                                                                                                                                                               
    0      2         PIPE 1.10     97154492.031250         5.937500 src/audio/pipeline.c:379    pipeline_prepare()                                                                                                                                                                         
    0      2         HOST          97154494.218750         2.187500     src/audio/host.c:641    host_prepare()                                                                                                                                                                             
    0      2       VOLUME          97154504.739583        10.520833 udio/volume/volume.c:593    volume_prepare()                                                                                                                                                                           
    0      2        MIXER          97154515.937500        11.197917    src/audio/mixer.c:341    mixer_prepare()                                                                                                                                                                            
    0      2       VOLUME          97154526.614583        10.677083 udio/volume/volume.c:593    volume_prepare()                                                                                                                                                                           
    0      2          DAI 1.9      97154537.708333        11.093750      src/audio/dai.c:420    dai_prepare()                                                                                                                                                                              
    0      2          IPC          97210858.750000     56321.042969    src/ipc/handler.c:450    ipc: comp 1 -> trigger cmd 0x40000                                                                                                                                                         
    0      2         PIPE 1.10     97210860.833333         2.083333 src/audio/pipeline.c:608    pipeline_trigger()                                                                                                                                                                         
    0      2         HOST          97210863.072917         2.239583     src/audio/host.c:291    host_trigger()                                                                                                                                                                             
    0      2       VOLUME          97210865.677083         2.604167 udio/volume/volume.c:533    volume_trigger()                                                                                                                                                                           
    0      2        MIXER          97210868.281250         2.604167    src/audio/mixer.c:211    mixer_trigger()                                                                                                                                                                            
    0      2       VOLUME          97210870.937500         2.656250 udio/volume/volume.c:533    volume_trigger()                                                                                                                                                                           
    0      2          DAI 1.9      97210873.489583         2.552083      src/audio/dai.c:483    dai_comp_trigger(), command = 1                                                                                                                                                            
    0      2          DAI 1.9      97210875.677083         2.187500      src/audio/dai.c:494    dai_comp_trigger(), START                                                                                                                                                                  
    0      2       BUFFER          97210892.343750        16.666666   src/audio/buffer.c:146    comp_update_buffer_produce(), no bytes to produce, source->comp.id = 2, source->comp.type = 5, sink->comp.id = 4, sink->comp.type = 6                                                      
    0      2       BUFFER          97210894.479167         2.135417   src/audio/buffer.c:223    comp_update_buffer_consume(), no bytes to consume, source->comp.id = 1, source->comp.type = 1, sink->comp.id = 2, sink->comp.type = 5                                                      
    0      2       BUFFER          97210901.041667         6.562500   src/audio/buffer.c:223    comp_update_buffer_consume(), no bytes to consume, source->comp.id = 2, source->comp.type = 5, sink->comp.id = 4, sink->comp.type = 6                                                      
    0      2       BUFFER          97210903.177083         2.135417   src/audio/buffer.c:146    comp_update_buffer_produce(), no bytes to produce, source->comp.id = 4, source->comp.type = 6, sink->comp.id = 3, sink->comp.type = 5                                                      
    0      2       BUFFER          97210906.302083         3.125000   src/audio/buffer.c:146    comp_update_buffer_produce(), no bytes to produce, source->comp.id = 3, source->comp.type = 5, sink->comp.id = 9, sink->comp.type = 2                                                      
    0      2       BUFFER          97210908.437500         2.135417   src/audio/buffer.c:223    comp_update_buffer_consume(), no bytes to consume, source->comp.id = 4, source->comp.type = 6, sink->comp.id = 3, sink->comp.type = 5                                                      
    0      2          SSP          97210910.989583         2.552083 intel/baytrail/ssp.c:576    ssp_trigger()                                                                                                                                                                              
    0      2          SSP          97210913.593750         2.604167 intel/baytrail/ssp.c:525    ssp_start()                                                                                                                                                                                
    0      1          DMA          97210916.927083         3.333333 src/drivers/dw/dma.c:296    dw_dma_start() error: dma 1 channel 0 not ready ena 0x1 status 0x3                                                                                                                         
    0      1         PIPE          97210928.750000        11.822917 src/audio/pipeline.c:785    pipeline_copy() error: ret = -16, start->comp.id = 9, dir = 1                                                                                                                              
    0      1         PIPE 1.10     97210938.802083        10.052083 src/audio/pipeline.c:977    pipeline_task(): xrun recover failed! pipeline will be stopped!                                                                                                                            
    0      2          IPC          98219049.843750   1008111.062500    src/ipc/handler.c:450    ipc: comp 1 -> trigger cmd 0x50000                                                                                                                                                         
    0      2         PIPE 1.10     98219051.979167         2.135417 src/audio/pipeline.c:608    pipeline_trigger()                                                                                                                                                                         
    0      2         HOST          98219058.697917         6.718750     src/audio/host.c:291    host_trigger()                                                                                                                                                                             
    0      2       VOLUME          98219061.302083         2.604167 udio/volume/volume.c:533    volume_trigger()                                                                                                                                                                           
    0      2        MIXER          98219063.906250         2.604167    src/audio/mixer.c:211    mixer_trigger()                                                                                                                                                                            
    0      2       VOLUME          98219066.614583         2.708333 udio/volume/volume.c:533    volume_trigger()                                                                                                                                                                           
    0      2          DAI 1.9      98219069.218750         2.604167      src/audio/dai.c:483    dai_comp_trigger(), command = 0                                                                                                                                                            
    0      2          DAI 1.9      98219071.354167         2.135417      src/audio/dai.c:547    dai_comp_trigger(), PAUSE/STOP                                                                                                                                                             
    0      2          DMA          98219073.333333         1.979167 src/drivers/dw/dma.c:451    dw_dma_stop(): dma 1 channel 0 stop                                                                                                                                                        
    0      1         WAIT          98220417.656250      1344.322876       src/lib/wait.c:89     ewt                                                                                                                                                                                        
    0      1          DMA          98220424.427083         6.770833 src/drivers/dw/dma.c:469    dw_dma_stop() error: dma 1 channel 0 timeout 

@cujomalainey

Copy link
Copy Markdown
Contributor Author

The issues appear to be tied to the boot beep. If the boot beep is bypassed then everything is fine. If it is not bypassed then everything breaks

@plbossart

plbossart commented Sep 30, 2019 via email

Copy link
Copy Markdown
Member

@cujomalainey

Copy link
Copy Markdown
Contributor Author

That appears to be the conclusion we are forming here as well. I am going to dive into the coreboot code to see what is happening on cht.

@cujomalainey

cujomalainey commented Sep 30, 2019 •

Copy link
Copy Markdown
Contributor Author

It looks like the boot beep driver has no reset sequence (which appears to be the standard).
https://chromium-review.googlesource.com/c/chromiumos/platform/depthcharge/+/271242/
My guess is it is the SSP interface that needs resetting since resetting the codec on probe from the kernel did not resolve the issue, is there a register write I can add to the platform init to reset the SSP interface as a test?

@cujomalainey

Copy link
Copy Markdown
Contributor Author

Hmm, it looks like this could be tied to the incompleteness of the reset sequence for the baytrail ssp driver https://github.com/thesofproject/sof/blob/master/src/drivers/intel/baytrail/ssp.c#L131

@plbossart

Copy link
Copy Markdown
Member

At one time I had a busybox based script to just dump all SSP register values. Maybe we should use this to check what is different with and without beep tone.

@cujomalainey

Copy link
Copy Markdown
Contributor Author

Sounds like a good plan to me, if you can't find it I can just dump them manually using logger

@plbossart

Copy link
Copy Markdown
Member

This is the only thing I can find. If you can trace what the SSP base is in your device this should help

#!/bin/bash

#define SSCR0           0x00                                                     
#define SSCR1           0x04                                                     
#define SSSR            0x08                                                     
#define SSITR           0x0C                                                     
#define SSDR            0x10                                                     
#define SSTO            0x28                                                     
#define SSPSP           0x2C                                                     
#define SSTSA           0x30                                                     
#define SSRSA           0x34                                                     
#define SSTSS           0x38                                                     
#define SSCR2           0x40                                                     
#define SFIFOTT         0x6C                                                     
#define SSCR3           0x70                                                     
#define SSCR4           0x74                                                     
#define SSCR5           0x78                                                     
#SSP base address 0x90ca2000                                                     

echo -e "SSCR0 \t" `busybox devmem 0x90ca2000`
echo -e "SSCR1 \t" `busybox devmem 0x90ca2004`
echo -e "SSSR \t"  `busybox devmem 0x90ca2008`
echo -e "SSITR \t" `busybox devmem 0x90ca200C`
echo -e "SSDR \t"  `busybox devmem 0x90ca2010`
echo -e "SSTO \t"  `busybox devmem 0x90ca2028`
echo -e "SSPSP \t" `busybox devmem 0x90ca202C`
echo -e "SSTSA \t" `busybox devmem 0x90ca2030`
echo -e "SSRSA \t" `busybox devmem 0x90ca2034`
echo -e "SSRSS \t" `busybox devmem 0x90ca2038`
echo -e "SSCR2 \t" `busybox devmem 0x90ca2040`
echo -e "SFIFOTT\t" `busybox devmem 0x90ca206C`
echo -e "SSCR3 \t" `busybox devmem 0x90ca2070`
echo -e "SSCR4 \t" `busybox devmem 0x90ca2074`
echo -e "SSCR5 \t" `busybox devmem 0x90ca2078`

@lgirdwood

Copy link
Copy Markdown
Member

@cujomalainey maybe also worth checking DMA reset state for PC beep too (although I'm not sure if coreboot will use the DMA for beep).

@plbossart

Copy link
Copy Markdown
Member

@cujomalainey maybe also worth checking DMA reset state for PC beep too (although I'm not sure if coreboot will use the DMA for beep).

my understanding is that it's a pure PIO operation, without any DMA, with direct access to SSP FIFOs

@cujomalainey

Copy link
Copy Markdown
Contributor Author

@plbossart yep I have heard the same thing, I saw no references to DMA when browsing the code generating the audio

@lgirdwood

Copy link
Copy Markdown
Member

ok great, one more thing we may need to manually clear all PIO SSP status IRQ sources in the status register before switching SSP into DMA handshake mode. There may also be stale data in the Tx/Rx FIFO too (that can be flushed using PIO).

@cujomalainey

Copy link
Copy Markdown
Contributor Author

Did a diff on the registers in SOF after the initial write, the is only difference I found, would this cause the behaviour observed?

diff --git a/bad_after_long.txt b/good_after_long.txt
index 9e45f81..bc2b1ab 100644
--- a/bad_after_long.txt
+++ b/good_after_long.txt
@@ -12,5 +12,5 @@ intel/baytrail/ssp.c:513    SSSR: f004
 intel/baytrail/ssp.c:514    SSITR: 0
 intel/baytrail/ssp.c:515    SSDR: 0
 intel/baytrail/ssp.c:516    SSTO: 0
-intel/baytrail/ssp.c:517    SSTSS: 1
+intel/baytrail/ssp.c:517    SSTSS: 0
 intel/baytrail/ssp.c:518    SFIFOL: 1f0000

@cujomalainey

Copy link
Copy Markdown
Contributor Author

answered my own question by writing the good value first in the bad case, did not fix the hardware. Here is the diff of the register state before the driver does its initial writes, does something maybe need to be reset?

diff --git a/bad_before_long.txt b/good_before_long.txt
index bb57b4b..fed81fc 100644
--- a/bad_before_long.txt
+++ b/good_before_long.txt
@@ -1,16 +1,16 @@
-intel/baytrail/ssp.c:492    SSCR0: 81c0003f
-intel/baytrail/ssp.c:493    SSCR1: 21001dc0
-intel/baytrail/ssp.c:494    SSCR2: 0
-intel/baytrail/ssp.c:495    SSCR3: 3c01f
-intel/baytrail/ssp.c:496    SSCR4: 2000
-intel/baytrail/ssp.c:497    SSCR5: 3e
-intel/baytrail/ssp.c:498    SSPSP: 10084
-intel/baytrail/ssp.c:499    SFIFOTT: 70007
-intel/baytrail/ssp.c:500    SSTSA: 3
-intel/baytrail/ssp.c:501    SSRSA: 3
+intel/baytrail/ssp.c:492    SSCR0: 0
+intel/baytrail/ssp.c:493    SSCR1: 43000000
+intel/baytrail/ssp.c:494    SSCR2: 800
+intel/baytrail/ssp.c:495    SSCR3: 2c604
+intel/baytrail/ssp.c:496    SSCR4: 0
+intel/baytrail/ssp.c:497    SSCR5: 0
+intel/baytrail/ssp.c:498    SSPSP: 0
+intel/baytrail/ssp.c:499    SFIFOTT: 0
+intel/baytrail/ssp.c:500    SSTSA: 0
+intel/baytrail/ssp.c:501    SSRSA: 0
 intel/baytrail/ssp.c:502    SSSR: f004
 intel/baytrail/ssp.c:503    SSITR: 0
 intel/baytrail/ssp.c:504    SSDR: 0
 intel/baytrail/ssp.c:505    SSTO: 0
-intel/baytrail/ssp.c:506    SSTSS: 1
+intel/baytrail/ssp.c:506    SSTSS: 0
 intel/baytrail/ssp.c:507    SFIFOL: 1f0000

@cujomalainey

Copy link
Copy Markdown
Contributor Author

@lgirdwood how would I go about clearing the PIO SSP status?

@lgirdwood

Copy link
Copy Markdown
Member

@cujomalainey I've sent you some infomation on the SSP bits, this is interesting as I would have assumed resetting the values would have worked. It's the occasional breakage that's interesting. Btw, can you capture when it breaks, that might help us root cause if DMA is somehow getiing misaligned between R/W periods. The SSSR register is R1C, so may need to be forced to reset state when switching from PIO to DMA mode.

Btw, can we merge this PR ?

@cujomalainey

Copy link
Copy Markdown
Contributor Author

Ok thanks, I will get to it in a bit, yes let's merge and move this discussion to an issue. Since the root cause appears to be independent of the changes made I see no issue merging this.

@plbossart

Copy link
Copy Markdown
Member

are all these changes in the master branch?

@cujomalainey

Copy link
Copy Markdown
Contributor Author

Yes, some are backported but they are all present on master

@lgirdwood

Copy link
Copy Markdown
Member

SOFCI TEST

@cujomalainey

Copy link
Copy Markdown
Contributor Author

abandoning and moving to next release if all bugs are fixed

@cujomalainey
cujomalainey deleted the cml-007-drop-stable branch December 3, 2020 23:32
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.

3 participants