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

Alsa over HDMI goes async or gives crackling #320

Closed
10robinho opened this issue Jul 2, 2013 · 44 comments
Closed

Alsa over HDMI goes async or gives crackling #320

10robinho opened this issue Jul 2, 2013 · 44 comments

Comments

@10robinho
Copy link

I've posted on forum about this bug: http://www.raspberrypi.org/phpBB3/viewtopic.php?f=28&t=48769

After I talked to some gstreamer guys, it seams that this bug is related to alsa drives for Raspberry Pi.

Long story in short, changing "buffer-time" property of gstreamer alsasink makes sound late (if buffer-time is high) or makes crackling noise (if buffer-time is lower).

On other platforms, there is no need to change "buffer-time" property and there are no issues with gstreamer alsasink (this bug can be reproduced only with Raspberry).

Is there any chance someone can reproduce this, give an explanation or even fix?

@popcornmix
Copy link
Collaborator

The Pi has to send audio to the GPU, so and requires a larger buffer to avoid underrun than a processor that cam dma audio directly.

If the units for:
g_object_set(GST_OBJECT(alsasink), "buffer-time", 50000, NULL);
are microseconds, then it's quite possible that 50ms is the minimum buffer size that can be supported without risking underrun (and hence the crackles).

If this causes out of sync audio, then that sounds like a gstreamer bug, where it is not adjusting the audio/video delay by the audio buffer size.

@10robinho
Copy link
Author

Yes, values are in microseconds. Default value is 200ms and there is no crackling when using it.

But, strange thing is that Raspberry is only platform that is having this desyncronisation with alsasink.

So, as far as I know now, several items are candidates for bug source: alsa drivers, alsa sink, egl sink or some internal Gstreamer.

I think that it is hardly possible that Gstreamer has internal problem as it is widely used and tested.

I'll try to see if I will get any feedback from people who are familiar with alsasink.

Anyways, it would be really pity that Gstreamer don't work properly on Raspberry.

@popcornmix
Copy link
Collaborator

I'm sure gstreamer has an option to specify the delay between video and audio.
You probably just need to set this to 200ms.

@10robinho
Copy link
Author

That would be great if delay is really 200ms. But problem is that delay is 0ms on start (sync is working) and it is increasing proportional to number of play-pause events.

@popcornmix
Copy link
Collaborator

I don't think anything will be done about this without some evidence of where the problem is.
The crackles when buffer size is too low is expected behaviour.

Going out of sync could easily be a gstreamer problem.
If there is an alsa problem, you really need a small program that provokes the problem without gstreamer/egl etc.

@10robinho
Copy link
Author

OK, I will report back when I debug Gstreamer more, to find out possible source of bug.

It would be great if anyone can try to compile samples I attached on bug report and to confirm this.

Here is bug report https://bugzilla.gnome.org/show_bug.cgi?id=703330

@10robinho
Copy link
Author

I've found exactly the same problem with mplayer using alsa sink.

There are steps how to reproduce it easily:

  1. Here is video I used http://goo.gl/W4p6v. Note that is super-small because I had to make sure Raspberry can properly reproduce it without any GPU help. But still, it is h264 + AAC in mp4 format. I used ffmpeg to reduce original Simpsons movie trailer that can be found here http://goo.gl/HXXvX.
    I find it good for testing audio because Homer slaps those wolfs in start and it is easy to see is audio is synced :)
  2. Install mplayer :) I used Arch packages
  3. Start X
  4. Run: mplayer -va x11 -ao alsa video.mp4
  5. Hit space couple of times until you realize that sound is late

It would be great if someone could confirm this bug.

@10robinho
Copy link
Author

@popcornmix have you tried to reproduce this bug?

Is there anything I can do to help fixing this?

@julianscheel
Copy link
Contributor

We're just stumbling into the same/similiar issue with our VLC implementation. Actually from our current understanding it looks as if snd_pcm_drop is not behaving correctly. Whenever VLC thinks that audio is way too late and tries to flush the audio output, the audio delay compared to video grows.
Analysing this we are currently thinking about the workqueue implementation of the snd_bcm2835 driver.
@popcornmix Could it be that the workqueue behaves as an in fact unlimited buffer, because snd_pcm_write calls are pushed to the workqueue asynchronously from actual tranfer to videocore? And then if a stop with snd_pcm_drop is executed this is just pushed onto the same workqueue, so it will only get executed after all previous write calls have been finished?
We are trying to find an easy test-case for this...

@dennis-hamester
Copy link

MPD is also affected by issues regarding snd_pcm_drop and they implemented a workaround. See this commit.

@10robinho
Copy link
Author

@dennis-hamester
Copy link

Great, thanks! We will try that patch

@10robinho
Copy link
Author

@dennishamester we tried to adopt that patch to Kernel from github.com/raspberrypi/ and we have found out that it works only for Kernel 3.9 and that it resets alsa settings after call (ei. that means sound jumps on 100% every time).

It would be nice to have fix for this, now when root of problem is known.

@popcornmix
Copy link
Collaborator

@julianscheel a simple test case of the problem would be very helpful.

Assuming the problem described is fixed by the kernel patch, it looks like a stop message with alsa_stream->draining==0 is the problem case. Agreed?

There is a queue of audio data on GPU side. Is the desired behaviour for that queue to be flushed when a stop message comes through with alsa_stream->draining==0 ?
I assume I report the samples have been played (just taking no time), so dma read_ptr==write_ptr after this?

@dennis-hamester
Copy link

@popcornmix yes, the problem appears when stop messages with draining==0 are generated. These come from snd_pcm_drop, which expects playback to stop immediately, with all pending buffers being discarded.

@popcornmix
Copy link
Collaborator

@dennishamester
I'll try implementing that, but it would be useful if someone could provide a script that provokes the failure, and explain what the desired behaviour is.
The simpler the test, the better.

@dennis-hamester
Copy link

We're working on it

@10robinho The patch seems to work for us. Thanks again

@dennis-hamester
Copy link

Here's a tool to debug this issue:
Source: https://gist.github.com/dennishamester/7600799
Binary: https://dl.dropboxusercontent.com/u/52834708/alsa-playback

The tool queues sound for 1 second, then drops. this cycle is repeated 10 times. On my host machine, I hear nothing, a slight crack at most. On the rpi, there is audio output for several seconds.

Might be useful:
The issue did not trigger when queuing much less than 1 second, like e.g. 250ms. I believe the alsa buffer (~300ms for this tool) must be exceeded to actually see the problem.

@popcornmix
Copy link
Collaborator

@dennishamester
How are you running alsa-playback?

/alsa-playback default
rate: 48000 -- frequency: 750.000000
cannot set parameters (Invalid argument)

@dennis-hamester
Copy link

@popcornmix
Try with hw:0. I'm looking into this

@popcornmix
Copy link
Collaborator

Can you try this build:
https://dl.dropboxusercontent.com/u/3669512/temp/start.elf

Note: this is test build with a fixed 256M/256M gpu/arm memory split.

It should drop queued audio data when requested.

I don't know if I agree that there shouldn't be any audio played while data is being submitted.
As the alsa driver is handled by a separate processor with queued messages, then it takes some time for those messages to arrive during which time we are suposed to be outputting audio.
Just because a different alsa card with a local dma buffer is able to fill and halt its buffer almost instantly doesn't mean that's the correct behaviour.

I would agree that no samples should be output after the final:

snd_pcm_drop(playback_handle);

but I'm not sure if they were before my update.

@10robinho
Copy link
Author

I've tested new start.elf and it is good in 95% of time.

In other 5% I hear strange noise, like crackling. I've recorded it with phone, you can get it here http://goo.gl/j6AlhC

@popcornmix
Copy link
Collaborator

@10robinho
is the recorded noise something new?
is the updated start.elf preferable to default one?
What can I do to reproduce the noise you heard? hdmi or analogue output?
Do you hear noise from aplay?

@julianscheel
Copy link
Contributor

I will try to test the new image tomorrow, but it might be that I can make it on wednesday only. Will let you know the results with VLC then.

@10robinho
Copy link
Author

@popcornmix

is the recorded noise something new?

No, but before your fix, it was much much more ofter, like 8/10 times.

is the updated start.elf preferable to default one?

Yes, I just replaced them.

What can I do to reproduce the noise you heard?

I've used Gstreamer program and paused->play->pause->play-> ... video from disk.

I believe same thing can be see with VLC, but I haven't tried.

hdmi or analogue output?

HDMI

Do you hear noise from aplay?

I didn't test it much, as I don't know how can I reproduce it with aplay.

Now, I will try to reproduce it with dennishamester's program and report if I managed to do it.

BTW, sorry for closing and reopening issue, I'm clumsy :)

@10robinho 10robinho reopened this Nov 25, 2013
@julianscheel
Copy link
Contributor

@10robinho Before you spend too much time with the test program: We are not very sure that this is a good testcase anymore...

popcornmix pushed a commit to raspberrypi/firmware that referenced this issue Nov 27, 2013
See: http://forum.xbmc.org/showthread.php?tid=169674&pid=1560992#pid1560992

firmware: fix for emmc_pll_core combined with avoid_pwm_pll getting wrong emmc freq

firmware: alsa drop samples on stop when requested
See: raspberrypi/linux#320

firmware: camera: fix for long exposure times causing lockup
See: raspberrypi/userland#33
See: raspberrypi/userland#76

userland: raspivid: Segmentation option for multiple files generated from a stream
See: raspberrypi/userland#123
popcornmix pushed a commit to Hexxeh/rpi-firmware that referenced this issue Nov 27, 2013
See: http://forum.xbmc.org/showthread.php?tid=169674&pid=1560992#pid1560992

firmware: fix for emmc_pll_core combined with avoid_pwm_pll getting wrong emmc freq

firmware: alsa drop samples on stop when requested
See: raspberrypi/linux#320

firmware: camera: fix for long exposure times causing lockup
See: raspberrypi/userland#33
See: raspberrypi/userland#76

userland: raspivid: Segmentation option for multiple files generated from a stream
See: raspberrypi/userland#123
@popcornmix
Copy link
Collaborator

The drain fix from the test build is now in latest rpi-update firmware.

Is there still a problem, and is there a test case to show the problem?

@giszo
Copy link

giszo commented Jan 16, 2014

I am developing my own audio player application for the Raspberry Pi and I faced the exact same problem that is described in this issue. Doing a lot of play-pause-play-pause-... operations sometimes cause periodic crackling in the audio output.

My pause implementation simply calls snd_pcm_drop() on the ALSA handle to drop everything from the output buffer to stop playing. Removing the snd_pcm_drop() call from my sources fixes the problem perfectly.

One more addition to the report is that I have the same problem on the analog output of the Pi as well.

I am using a recent Pi firmware but if you need more information about it feel free to ask me.

@popcornmix
Copy link
Collaborator

@giszo
If you can produce a simple test program that clearly does something wrong, then I'd like to see it.

@giszo
Copy link

giszo commented Jan 16, 2014

It took a little bit of time but I was able to reproduce the issue with the following application: http://minimaldiff.hu/zeppelin/test.c
Be warned that the source of the given test application is just a quickly hacked application. :)
The interesting parts:

  • init_alsa() function -> ALSA library initialization
  • handle_input function() line 155 & 157 -> playback is stopped here
  • main() function line 192 & 215 -> decoded audio is played here.

You will need libmpg123 to be able to compile the application with something like this: "gcc -O2 -lasound -lmpg123 test.c -o test"
An mp3 file with 44100Hz sampling rate and 2 channels is also needed. To start the application simply do "./test your_music.mp3"

By pressing space multiple times the tester will start and stop playing of the specified file. Escape can be used to quit from the application.
My test scenario is something like this:

  • press space -> playback starts
  • wait a few (~3-5 seconds) -> make sure played audio is fine
  • press space -> playback pauses
  • wait a sec
  • repeat from the beginning ...

Sometimes the issue pops up right after the second try, sometimes it requires a lot of pressing on space, but I can reproduce it aytime on my Pi. When I hear the periodic glitches in the audio its period is somewhere between 500ms and 1s.

Let me know if you need further assistance.

@popcornmix
Copy link
Collaborator

@giszo
I could compile your code, and after a few pause/unpause cycles I got the glitches.
I'll look into it.

@giszo
Copy link

giszo commented Jan 17, 2014

One more observation I did yesterday that may help, but I am not totally sure about it: if I moved the snd_pcm_prepare() call to be executed only when playback is started, the problem didn't show up ... or I was not trying it hard enough. :)

So I would think that the problem is caused by calling snd_pcm_drop() and snd_pcm_prepare() right after each other.

@giszo
Copy link

giszo commented Jan 20, 2014

@popcornmix did you have time to look into this issue?

@popcornmix
Copy link
Collaborator

I've been looking at this for the last few hours, and not getting very far.
The samples always look plausible all the way through the chain.
If you send silence rather than music the noise doesn't seem to occur (although as the test is intermittent, I've frequently been drawing incorrect conclusions).
I'd deciding the reporting of how many samples were consumed was probably causing the problem, and calculating them different ways seemed to help, but it was just chance...

I've finally found a smoking gun. Just before the noise I get a buffer with an odd number of bytes. That's pretty surprising - I'd assume that alsa deals in 2 bytes per sample and 2 channels, so I'd always see multiples of 4. I think after the odd byte buffer, we play that buffer endian reversed causing the noise. The next buffer is off too, which flips it back causing the noise/good cycles.

It's too late now, but I've got something concrete to debug in the next day or so, so hopefully will have a fix soon.

@giszo
Copy link

giszo commented Jan 31, 2014

It is nice to hear that there is some promising progress. :)

@popcornmix
Copy link
Collaborator

I've got a test build for you to try:
https://dl.dropboxusercontent.com/u/3669512/temp/start_alsa.elf

This has a fixed memory split of 128M/128M.

Can you test if it seems okay, and if so I'll make a new official firmware.

@giszo
Copy link

giszo commented Feb 1, 2014

The link does not seem to work as I get 404.

@popcornmix
Copy link
Collaborator

Sorry, should be there now.

@giszo
Copy link

giszo commented Feb 1, 2014

Tested it and the problem is fixed as far as I can tell.

popcornmix pushed a commit to raspberrypi/firmware that referenced this issue Feb 2, 2014
See: raspberrypi/linux#463

firmware: vdec3: h264: Changed scaling lists don't force a new sequence
See: http://openelec.tv/forum/124-raspberry-pi/68526-openelec-rbej-version-frodo-12-3?start=45#96106

firmware: audioserv: handle odd buffer sizes and only submit multiples of pitch
See: raspberrypi/linux#320
@popcornmix
Copy link
Collaborator

rpi-update firmware should now have this fix.
@10robinho Does this help your issue?

popcornmix pushed a commit to Hexxeh/rpi-firmware that referenced this issue Feb 2, 2014
See: raspberrypi/linux#463

firmware: vdec3: h264: Changed scaling lists don't force a new sequence
See: http://openelec.tv/forum/124-raspberry-pi/68526-openelec-rbej-version-frodo-12-3?start=45#96106

firmware: audioserv: handle odd buffer sizes and only submit multiples of pitch
See: raspberrypi/linux#320
@popcornmix
Copy link
Collaborator

Any reamaining issue here or is it okay to close?

@giszo
Copy link

giszo commented Feb 12, 2014

For me it is fine to close the issue.

@julianscheel
Copy link
Contributor

From our side it can be closed.

@10robinho
Copy link
Author

I'm sorry not to respond earlier.
Looks like problem is solved, I'm closing the issue.
Thanks @popcornmix :)

popcornmix pushed a commit that referenced this issue Nov 22, 2016
Andrey reported this kernel warning:

  WARNING: CPU: 0 PID: 4608 at kernel/sched/core.c:7724
  __might_sleep+0x14c/0x1a0 kernel/sched/core.c:7719
  do not call blocking ops when !TASK_RUNNING; state=1 set at
  [<ffffffff811f5a5c>] prepare_to_wait+0xbc/0x210
  kernel/sched/wait.c:178
  Modules linked in:
  CPU: 0 PID: 4608 Comm: syz-executor Not tainted 4.9.0-rc2+ #320
  Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS Bochs 01/01/2011
   ffff88006625f7a0 ffffffff81b46914 ffff88006625f818 0000000000000000
   ffffffff84052960 0000000000000000 ffff88006625f7e8 ffffffff81111237
   ffff88006aceac00 ffffffff00001e2c ffffed000cc4beff ffffffff84052960
  Call Trace:
   [<     inline     >] __dump_stack lib/dump_stack.c:15
   [<ffffffff81b46914>] dump_stack+0xb3/0x10f lib/dump_stack.c:51
   [<ffffffff81111237>] __warn+0x1a7/0x1f0 kernel/panic.c:550
   [<ffffffff8111132c>] warn_slowpath_fmt+0xac/0xd0 kernel/panic.c:565
   [<ffffffff811922fc>] __might_sleep+0x14c/0x1a0 kernel/sched/core.c:7719
   [<     inline     >] slab_pre_alloc_hook mm/slab.h:393
   [<     inline     >] slab_alloc_node mm/slub.c:2634
   [<     inline     >] slab_alloc mm/slub.c:2716
   [<ffffffff81508da0>] __kmalloc_track_caller+0x150/0x2a0 mm/slub.c:4240
   [<ffffffff8146be14>] kmemdup+0x24/0x50 mm/util.c:113
   [<ffffffff8388b2cf>] dccp_feat_clone_sp_val.part.5+0x4f/0xe0 net/dccp/feat.c:374
   [<     inline     >] dccp_feat_clone_sp_val net/dccp/feat.c:1141
   [<     inline     >] dccp_feat_change_recv net/dccp/feat.c:1141
   [<ffffffff8388d491>] dccp_feat_parse_options+0xaa1/0x13d0 net/dccp/feat.c:1411
   [<ffffffff83894f01>] dccp_parse_options+0x721/0x1010 net/dccp/options.c:128
   [<ffffffff83891280>] dccp_rcv_state_process+0x200/0x15b0 net/dccp/input.c:644
   [<ffffffff838b8a94>] dccp_v4_do_rcv+0xf4/0x1a0 net/dccp/ipv4.c:681
   [<     inline     >] sk_backlog_rcv ./include/net/sock.h:872
   [<ffffffff82b7ceb6>] __release_sock+0x126/0x3a0 net/core/sock.c:2044
   [<ffffffff82b7d189>] release_sock+0x59/0x1c0 net/core/sock.c:2502
   [<     inline     >] inet_wait_for_connect net/ipv4/af_inet.c:547
   [<ffffffff8316b2a2>] __inet_stream_connect+0x5d2/0xbb0 net/ipv4/af_inet.c:617
   [<ffffffff8316b8d5>] inet_stream_connect+0x55/0xa0 net/ipv4/af_inet.c:656
   [<ffffffff82b705e4>] SYSC_connect+0x244/0x2f0 net/socket.c:1533
   [<ffffffff82b72dd4>] SyS_connect+0x24/0x30 net/socket.c:1514
   [<ffffffff83fbf701>] entry_SYSCALL_64_fastpath+0x1f/0xc2
  arch/x86/entry/entry_64.S:209

Unlike commit 26cabd3
("sched, net: Clean up sk_wait_event() vs. might_sleep()"), the
sleeping function is called before schedule_timeout(), this is indeed
a bug. Fix this by moving the wait logic to the new API, it is similar
to commit ff960a7
("netdev, sched/wait: Fix sleeping inside wait event").

Reported-by: Andrey Konovalov <andreyknvl@google.com>
Cc: Andrey Konovalov <andreyknvl@google.com>
Cc: Eric Dumazet <eric.dumazet@gmail.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
neuschaefer pushed a commit to neuschaefer/raspi-binary-firmware that referenced this issue Feb 27, 2017
See: http://forum.xbmc.org/showthread.php?tid=169674&pid=1560992#pid1560992

firmware: fix for emmc_pll_core combined with avoid_pwm_pll getting wrong emmc freq

firmware: alsa drop samples on stop when requested
See: raspberrypi/linux#320

firmware: camera: fix for long exposure times causing lockup
See: raspberrypi/userland#33
See: raspberrypi/userland#76

userland: raspivid: Segmentation option for multiple files generated from a stream
See: raspberrypi/userland#123
neuschaefer pushed a commit to neuschaefer/raspi-binary-firmware that referenced this issue Feb 27, 2017
See: raspberrypi/linux#463

firmware: vdec3: h264: Changed scaling lists don't force a new sequence
See: http://openelec.tv/forum/124-raspberry-pi/68526-openelec-rbej-version-frodo-12-3?start=45#96106

firmware: audioserv: handle odd buffer sizes and only submit multiples of pitch
See: raspberrypi/linux#320
popcornmix pushed a commit that referenced this issue Jul 21, 2021
…format

[ Upstream commit 06d213d ]

For incoming SCO connection with transparent coding format, alt setting
of CVSD is getting applied instead of Transparent.

Before fix:
< HCI Command: Accept Synchron.. (0x01|0x0029) plen 21  #2196 [hci0] 321.342548
        Address: 1C:CC:D6:E2:EA:80 (Xiaomi Communications Co Ltd)
        Transmit bandwidth: 8000
        Receive bandwidth: 8000
        Max latency: 13
        Setting: 0x0003
          Input Coding: Linear
          Input Data Format: 1's complement
          Input Sample Size: 8-bit
          # of bits padding at MSB: 0
          Air Coding Format: Transparent Data
        Retransmission effort: Optimize for link quality (0x02)
        Packet type: 0x003f
          HV1 may be used
          HV2 may be used
          HV3 may be used
          EV3 may be used
          EV4 may be used
          EV5 may be used
> HCI Event: Command Status (0x0f) plen 4               #2197 [hci0] 321.343585
      Accept Synchronous Connection Request (0x01|0x0029) ncmd 1
        Status: Success (0x00)
> HCI Event: Synchronous Connect Comp.. (0x2c) plen 17  #2198 [hci0] 321.351666
        Status: Success (0x00)
        Handle: 257
        Address: 1C:CC:D6:E2:EA:80 (Xiaomi Communications Co Ltd)
        Link type: eSCO (0x02)
        Transmission interval: 0x0c
        Retransmission window: 0x04
        RX packet length: 60
        TX packet length: 60
        Air mode: Transparent (0x03)
........
> SCO Data RX: Handle 257 flags 0x00 dlen 48            #2336 [hci0] 321.383655
< SCO Data TX: Handle 257 flags 0x00 dlen 60            #2337 [hci0] 321.389558
> SCO Data RX: Handle 257 flags 0x00 dlen 48            #2338 [hci0] 321.393615
> SCO Data RX: Handle 257 flags 0x00 dlen 48            #2339 [hci0] 321.393618
> SCO Data RX: Handle 257 flags 0x00 dlen 48            #2340 [hci0] 321.393618
< SCO Data TX: Handle 257 flags 0x00 dlen 60            #2341 [hci0] 321.397070
> SCO Data RX: Handle 257 flags 0x00 dlen 48            #2342 [hci0] 321.403622
> SCO Data RX: Handle 257 flags 0x00 dlen 48            #2343 [hci0] 321.403625
> SCO Data RX: Handle 257 flags 0x00 dlen 48            #2344 [hci0] 321.403625
> SCO Data RX: Handle 257 flags 0x00 dlen 48            #2345 [hci0] 321.403625
< SCO Data TX: Handle 257 flags 0x00 dlen 60            #2346 [hci0] 321.404569
< SCO Data TX: Handle 257 flags 0x00 dlen 60            #2347 [hci0] 321.412091
> SCO Data RX: Handle 257 flags 0x00 dlen 48            #2348 [hci0] 321.413626
> SCO Data RX: Handle 257 flags 0x00 dlen 48            #2349 [hci0] 321.413630
> SCO Data RX: Handle 257 flags 0x00 dlen 48            #2350 [hci0] 321.413630
< SCO Data TX: Handle 257 flags 0x00 dlen 60            #2351 [hci0] 321.419674

After fix:

< HCI Command: Accept Synchronou.. (0x01|0x0029) plen 21  #309 [hci0] 49.439693
        Address: 1C:CC:D6:E2:EA:80 (Xiaomi Communications Co Ltd)
        Transmit bandwidth: 8000
        Receive bandwidth: 8000
        Max latency: 13
        Setting: 0x0003
          Input Coding: Linear
          Input Data Format: 1's complement
          Input Sample Size: 8-bit
          # of bits padding at MSB: 0
          Air Coding Format: Transparent Data
        Retransmission effort: Optimize for link quality (0x02)
        Packet type: 0x003f
          HV1 may be used
          HV2 may be used
          HV3 may be used
          EV3 may be used
          EV4 may be used
          EV5 may be used
> HCI Event: Command Status (0x0f) plen 4                 #310 [hci0] 49.440308
      Accept Synchronous Connection Request (0x01|0x0029) ncmd 1
        Status: Success (0x00)
> HCI Event: Synchronous Connect Complete (0x2c) plen 17  #311 [hci0] 49.449308
        Status: Success (0x00)
        Handle: 257
        Address: 1C:CC:D6:E2:EA:80 (Xiaomi Communications Co Ltd)
        Link type: eSCO (0x02)
        Transmission interval: 0x0c
        Retransmission window: 0x04
        RX packet length: 60
        TX packet length: 60
        Air mode: Transparent (0x03)
< SCO Data TX: Handle 257 flags 0x00 dlen 60              #312 [hci0] 49.450421
< SCO Data TX: Handle 257 flags 0x00 dlen 60              #313 [hci0] 49.457927
> HCI Event: Max Slots Change (0x1b) plen 3               #314 [hci0] 49.460345
        Handle: 256
        Max slots: 5
< SCO Data TX: Handle 257 flags 0x00 dlen 60              #315 [hci0] 49.465453
> SCO Data RX: Handle 257 flags 0x00 dlen 60              #316 [hci0] 49.470502
> SCO Data RX: Handle 257 flags 0x00 dlen 60              #317 [hci0] 49.470519
< SCO Data TX: Handle 257 flags 0x00 dlen 60              #318 [hci0] 49.472996
> SCO Data RX: Handle 257 flags 0x00 dlen 60              #319 [hci0] 49.480412
< SCO Data TX: Handle 257 flags 0x00 dlen 60              #320 [hci0] 49.480492
< SCO Data TX: Handle 257 flags 0x00 dlen 60              #321 [hci0] 49.487989
> SCO Data RX: Handle 257 flags 0x00 dlen 60              #322 [hci0] 49.490303
< SCO Data TX: Handle 257 flags 0x00 dlen 60              #323 [hci0] 49.495496
> SCO Data RX: Handle 257 flags 0x00 dlen 60              #324 [hci0] 49.500304
> SCO Data RX: Handle 257 flags 0x00 dlen 60              #325 [hci0] 49.500311

Signed-off-by: Kiran K <kiran.k@intel.com>
Signed-off-by: Lokendra Singh <lokendra.singh@intel.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
popcornmix pushed a commit that referenced this issue Jul 22, 2021
…format

[ Upstream commit 06d213d ]

For incoming SCO connection with transparent coding format, alt setting
of CVSD is getting applied instead of Transparent.

Before fix:
< HCI Command: Accept Synchron.. (0x01|0x0029) plen 21  #2196 [hci0] 321.342548
        Address: 1C:CC:D6:E2:EA:80 (Xiaomi Communications Co Ltd)
        Transmit bandwidth: 8000
        Receive bandwidth: 8000
        Max latency: 13
        Setting: 0x0003
          Input Coding: Linear
          Input Data Format: 1's complement
          Input Sample Size: 8-bit
          # of bits padding at MSB: 0
          Air Coding Format: Transparent Data
        Retransmission effort: Optimize for link quality (0x02)
        Packet type: 0x003f
          HV1 may be used
          HV2 may be used
          HV3 may be used
          EV3 may be used
          EV4 may be used
          EV5 may be used
> HCI Event: Command Status (0x0f) plen 4               #2197 [hci0] 321.343585
      Accept Synchronous Connection Request (0x01|0x0029) ncmd 1
        Status: Success (0x00)
> HCI Event: Synchronous Connect Comp.. (0x2c) plen 17  #2198 [hci0] 321.351666
        Status: Success (0x00)
        Handle: 257
        Address: 1C:CC:D6:E2:EA:80 (Xiaomi Communications Co Ltd)
        Link type: eSCO (0x02)
        Transmission interval: 0x0c
        Retransmission window: 0x04
        RX packet length: 60
        TX packet length: 60
        Air mode: Transparent (0x03)
........
> SCO Data RX: Handle 257 flags 0x00 dlen 48            #2336 [hci0] 321.383655
< SCO Data TX: Handle 257 flags 0x00 dlen 60            #2337 [hci0] 321.389558
> SCO Data RX: Handle 257 flags 0x00 dlen 48            #2338 [hci0] 321.393615
> SCO Data RX: Handle 257 flags 0x00 dlen 48            #2339 [hci0] 321.393618
> SCO Data RX: Handle 257 flags 0x00 dlen 48            #2340 [hci0] 321.393618
< SCO Data TX: Handle 257 flags 0x00 dlen 60            #2341 [hci0] 321.397070
> SCO Data RX: Handle 257 flags 0x00 dlen 48            #2342 [hci0] 321.403622
> SCO Data RX: Handle 257 flags 0x00 dlen 48            #2343 [hci0] 321.403625
> SCO Data RX: Handle 257 flags 0x00 dlen 48            #2344 [hci0] 321.403625
> SCO Data RX: Handle 257 flags 0x00 dlen 48            #2345 [hci0] 321.403625
< SCO Data TX: Handle 257 flags 0x00 dlen 60            #2346 [hci0] 321.404569
< SCO Data TX: Handle 257 flags 0x00 dlen 60            #2347 [hci0] 321.412091
> SCO Data RX: Handle 257 flags 0x00 dlen 48            #2348 [hci0] 321.413626
> SCO Data RX: Handle 257 flags 0x00 dlen 48            #2349 [hci0] 321.413630
> SCO Data RX: Handle 257 flags 0x00 dlen 48            #2350 [hci0] 321.413630
< SCO Data TX: Handle 257 flags 0x00 dlen 60            #2351 [hci0] 321.419674

After fix:

< HCI Command: Accept Synchronou.. (0x01|0x0029) plen 21  #309 [hci0] 49.439693
        Address: 1C:CC:D6:E2:EA:80 (Xiaomi Communications Co Ltd)
        Transmit bandwidth: 8000
        Receive bandwidth: 8000
        Max latency: 13
        Setting: 0x0003
          Input Coding: Linear
          Input Data Format: 1's complement
          Input Sample Size: 8-bit
          # of bits padding at MSB: 0
          Air Coding Format: Transparent Data
        Retransmission effort: Optimize for link quality (0x02)
        Packet type: 0x003f
          HV1 may be used
          HV2 may be used
          HV3 may be used
          EV3 may be used
          EV4 may be used
          EV5 may be used
> HCI Event: Command Status (0x0f) plen 4                 #310 [hci0] 49.440308
      Accept Synchronous Connection Request (0x01|0x0029) ncmd 1
        Status: Success (0x00)
> HCI Event: Synchronous Connect Complete (0x2c) plen 17  #311 [hci0] 49.449308
        Status: Success (0x00)
        Handle: 257
        Address: 1C:CC:D6:E2:EA:80 (Xiaomi Communications Co Ltd)
        Link type: eSCO (0x02)
        Transmission interval: 0x0c
        Retransmission window: 0x04
        RX packet length: 60
        TX packet length: 60
        Air mode: Transparent (0x03)
< SCO Data TX: Handle 257 flags 0x00 dlen 60              #312 [hci0] 49.450421
< SCO Data TX: Handle 257 flags 0x00 dlen 60              #313 [hci0] 49.457927
> HCI Event: Max Slots Change (0x1b) plen 3               #314 [hci0] 49.460345
        Handle: 256
        Max slots: 5
< SCO Data TX: Handle 257 flags 0x00 dlen 60              #315 [hci0] 49.465453
> SCO Data RX: Handle 257 flags 0x00 dlen 60              #316 [hci0] 49.470502
> SCO Data RX: Handle 257 flags 0x00 dlen 60              #317 [hci0] 49.470519
< SCO Data TX: Handle 257 flags 0x00 dlen 60              #318 [hci0] 49.472996
> SCO Data RX: Handle 257 flags 0x00 dlen 60              #319 [hci0] 49.480412
< SCO Data TX: Handle 257 flags 0x00 dlen 60              #320 [hci0] 49.480492
< SCO Data TX: Handle 257 flags 0x00 dlen 60              #321 [hci0] 49.487989
> SCO Data RX: Handle 257 flags 0x00 dlen 60              #322 [hci0] 49.490303
< SCO Data TX: Handle 257 flags 0x00 dlen 60              #323 [hci0] 49.495496
> SCO Data RX: Handle 257 flags 0x00 dlen 60              #324 [hci0] 49.500304
> SCO Data RX: Handle 257 flags 0x00 dlen 60              #325 [hci0] 49.500311

Signed-off-by: Kiran K <kiran.k@intel.com>
Signed-off-by: Lokendra Singh <lokendra.singh@intel.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
popcornmix pushed a commit that referenced this issue Jul 27, 2021
…format

[ Upstream commit 06d213d ]

For incoming SCO connection with transparent coding format, alt setting
of CVSD is getting applied instead of Transparent.

Before fix:
< HCI Command: Accept Synchron.. (0x01|0x0029) plen 21  #2196 [hci0] 321.342548
        Address: 1C:CC:D6:E2:EA:80 (Xiaomi Communications Co Ltd)
        Transmit bandwidth: 8000
        Receive bandwidth: 8000
        Max latency: 13
        Setting: 0x0003
          Input Coding: Linear
          Input Data Format: 1's complement
          Input Sample Size: 8-bit
          # of bits padding at MSB: 0
          Air Coding Format: Transparent Data
        Retransmission effort: Optimize for link quality (0x02)
        Packet type: 0x003f
          HV1 may be used
          HV2 may be used
          HV3 may be used
          EV3 may be used
          EV4 may be used
          EV5 may be used
> HCI Event: Command Status (0x0f) plen 4               #2197 [hci0] 321.343585
      Accept Synchronous Connection Request (0x01|0x0029) ncmd 1
        Status: Success (0x00)
> HCI Event: Synchronous Connect Comp.. (0x2c) plen 17  #2198 [hci0] 321.351666
        Status: Success (0x00)
        Handle: 257
        Address: 1C:CC:D6:E2:EA:80 (Xiaomi Communications Co Ltd)
        Link type: eSCO (0x02)
        Transmission interval: 0x0c
        Retransmission window: 0x04
        RX packet length: 60
        TX packet length: 60
        Air mode: Transparent (0x03)
........
> SCO Data RX: Handle 257 flags 0x00 dlen 48            #2336 [hci0] 321.383655
< SCO Data TX: Handle 257 flags 0x00 dlen 60            #2337 [hci0] 321.389558
> SCO Data RX: Handle 257 flags 0x00 dlen 48            #2338 [hci0] 321.393615
> SCO Data RX: Handle 257 flags 0x00 dlen 48            #2339 [hci0] 321.393618
> SCO Data RX: Handle 257 flags 0x00 dlen 48            #2340 [hci0] 321.393618
< SCO Data TX: Handle 257 flags 0x00 dlen 60            #2341 [hci0] 321.397070
> SCO Data RX: Handle 257 flags 0x00 dlen 48            #2342 [hci0] 321.403622
> SCO Data RX: Handle 257 flags 0x00 dlen 48            #2343 [hci0] 321.403625
> SCO Data RX: Handle 257 flags 0x00 dlen 48            #2344 [hci0] 321.403625
> SCO Data RX: Handle 257 flags 0x00 dlen 48            #2345 [hci0] 321.403625
< SCO Data TX: Handle 257 flags 0x00 dlen 60            #2346 [hci0] 321.404569
< SCO Data TX: Handle 257 flags 0x00 dlen 60            #2347 [hci0] 321.412091
> SCO Data RX: Handle 257 flags 0x00 dlen 48            #2348 [hci0] 321.413626
> SCO Data RX: Handle 257 flags 0x00 dlen 48            #2349 [hci0] 321.413630
> SCO Data RX: Handle 257 flags 0x00 dlen 48            #2350 [hci0] 321.413630
< SCO Data TX: Handle 257 flags 0x00 dlen 60            #2351 [hci0] 321.419674

After fix:

< HCI Command: Accept Synchronou.. (0x01|0x0029) plen 21  #309 [hci0] 49.439693
        Address: 1C:CC:D6:E2:EA:80 (Xiaomi Communications Co Ltd)
        Transmit bandwidth: 8000
        Receive bandwidth: 8000
        Max latency: 13
        Setting: 0x0003
          Input Coding: Linear
          Input Data Format: 1's complement
          Input Sample Size: 8-bit
          # of bits padding at MSB: 0
          Air Coding Format: Transparent Data
        Retransmission effort: Optimize for link quality (0x02)
        Packet type: 0x003f
          HV1 may be used
          HV2 may be used
          HV3 may be used
          EV3 may be used
          EV4 may be used
          EV5 may be used
> HCI Event: Command Status (0x0f) plen 4                 #310 [hci0] 49.440308
      Accept Synchronous Connection Request (0x01|0x0029) ncmd 1
        Status: Success (0x00)
> HCI Event: Synchronous Connect Complete (0x2c) plen 17  #311 [hci0] 49.449308
        Status: Success (0x00)
        Handle: 257
        Address: 1C:CC:D6:E2:EA:80 (Xiaomi Communications Co Ltd)
        Link type: eSCO (0x02)
        Transmission interval: 0x0c
        Retransmission window: 0x04
        RX packet length: 60
        TX packet length: 60
        Air mode: Transparent (0x03)
< SCO Data TX: Handle 257 flags 0x00 dlen 60              #312 [hci0] 49.450421
< SCO Data TX: Handle 257 flags 0x00 dlen 60              #313 [hci0] 49.457927
> HCI Event: Max Slots Change (0x1b) plen 3               #314 [hci0] 49.460345
        Handle: 256
        Max slots: 5
< SCO Data TX: Handle 257 flags 0x00 dlen 60              #315 [hci0] 49.465453
> SCO Data RX: Handle 257 flags 0x00 dlen 60              #316 [hci0] 49.470502
> SCO Data RX: Handle 257 flags 0x00 dlen 60              #317 [hci0] 49.470519
< SCO Data TX: Handle 257 flags 0x00 dlen 60              #318 [hci0] 49.472996
> SCO Data RX: Handle 257 flags 0x00 dlen 60              #319 [hci0] 49.480412
< SCO Data TX: Handle 257 flags 0x00 dlen 60              #320 [hci0] 49.480492
< SCO Data TX: Handle 257 flags 0x00 dlen 60              #321 [hci0] 49.487989
> SCO Data RX: Handle 257 flags 0x00 dlen 60              #322 [hci0] 49.490303
< SCO Data TX: Handle 257 flags 0x00 dlen 60              #323 [hci0] 49.495496
> SCO Data RX: Handle 257 flags 0x00 dlen 60              #324 [hci0] 49.500304
> SCO Data RX: Handle 257 flags 0x00 dlen 60              #325 [hci0] 49.500311

Signed-off-by: Kiran K <kiran.k@intel.com>
Signed-off-by: Lokendra Singh <lokendra.singh@intel.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
popcornmix pushed a commit that referenced this issue Jun 12, 2024
[ Upstream commit 8ecf3c1 ]

Recent additions in BPF like cpu v4 instructions, test_bpf module
exhibits the following failures:

  test_bpf: #82 ALU_MOVSX | BPF_B jited:1 ret 2 != 1 (0x2 != 0x1)FAIL (1 times)
  test_bpf: #83 ALU_MOVSX | BPF_H jited:1 ret 2 != 1 (0x2 != 0x1)FAIL (1 times)
  test_bpf: #84 ALU64_MOVSX | BPF_B jited:1 ret 2 != 1 (0x2 != 0x1)FAIL (1 times)
  test_bpf: #85 ALU64_MOVSX | BPF_H jited:1 ret 2 != 1 (0x2 != 0x1)FAIL (1 times)
  test_bpf: #86 ALU64_MOVSX | BPF_W jited:1 ret 2 != 1 (0x2 != 0x1)FAIL (1 times)

  test_bpf: #165 ALU_SDIV_X: -6 / 2 = -3 jited:1 ret 2147483645 != -3 (0x7ffffffd != 0xfffffffd)FAIL (1 times)
  test_bpf: #166 ALU_SDIV_K: -6 / 2 = -3 jited:1 ret 2147483645 != -3 (0x7ffffffd != 0xfffffffd)FAIL (1 times)

  test_bpf: #169 ALU_SMOD_X: -7 % 2 = -1 jited:1 ret 1 != -1 (0x1 != 0xffffffff)FAIL (1 times)
  test_bpf: #170 ALU_SMOD_K: -7 % 2 = -1 jited:1 ret 1 != -1 (0x1 != 0xffffffff)FAIL (1 times)

  test_bpf: #172 ALU64_SMOD_K: -7 % 2 = -1 jited:1 ret 1 != -1 (0x1 != 0xffffffff)FAIL (1 times)

  test_bpf: #313 BSWAP 16: 0x0123456789abcdef -> 0xefcd
  eBPF filter opcode 00d7 (@2) unsupported
  jited:0 301 PASS
  test_bpf: #314 BSWAP 32: 0x0123456789abcdef -> 0xefcdab89
  eBPF filter opcode 00d7 (@2) unsupported
  jited:0 555 PASS
  test_bpf: #315 BSWAP 64: 0x0123456789abcdef -> 0x67452301
  eBPF filter opcode 00d7 (@2) unsupported
  jited:0 268 PASS
  test_bpf: #316 BSWAP 64: 0x0123456789abcdef >> 32 -> 0xefcdab89
  eBPF filter opcode 00d7 (@2) unsupported
  jited:0 269 PASS
  test_bpf: #317 BSWAP 16: 0xfedcba9876543210 -> 0x1032
  eBPF filter opcode 00d7 (@2) unsupported
  jited:0 460 PASS
  test_bpf: #318 BSWAP 32: 0xfedcba9876543210 -> 0x10325476
  eBPF filter opcode 00d7 (@2) unsupported
  jited:0 320 PASS
  test_bpf: #319 BSWAP 64: 0xfedcba9876543210 -> 0x98badcfe
  eBPF filter opcode 00d7 (@2) unsupported
  jited:0 222 PASS
  test_bpf: #320 BSWAP 64: 0xfedcba9876543210 >> 32 -> 0x10325476
  eBPF filter opcode 00d7 (@2) unsupported
  jited:0 273 PASS

  test_bpf: #344 BPF_LDX_MEMSX | BPF_B
  eBPF filter opcode 0091 (@5) unsupported
  jited:0 432 PASS
  test_bpf: #345 BPF_LDX_MEMSX | BPF_H
  eBPF filter opcode 0089 (@5) unsupported
  jited:0 381 PASS
  test_bpf: #346 BPF_LDX_MEMSX | BPF_W
  eBPF filter opcode 0081 (@5) unsupported
  jited:0 505 PASS

  test_bpf: #490 JMP32_JA: Unconditional jump: if (true) return 1
  eBPF filter opcode 0006 (@1) unsupported
  jited:0 261 PASS

  test_bpf: Summary: 1040 PASSED, 10 FAILED, [924/1038 JIT'ed]

Fix them by adding missing processing.

Fixes: daabb2b ("bpf/tests: add tests for cpuv4 instructions")
Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://msgid.link/91de862dda99d170697eb79ffb478678af7e0b27.1709652689.git.christophe.leroy@csgroup.eu
Signed-off-by: Sasha Levin <sashal@kernel.org>
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

No branches or pull requests

5 participants