Bug 215194

Summary: [PATCH] Fix Raspberry Pi 1 no sound
Product: Base System Reporter: ` <iequoph>
Component: armAssignee: Oleksandr Tymoshenko <gonzo>
Status: Closed FIXED    
Severity: Affects Many People CC: gonzo
Priority: --- Keywords: patch
Version: CURRENT   
Hardware: arm   
OS: Any   
Attachments:
Description Flags
Fix raspberry pi 1 no sound. none

Description ` 2016-12-10 09:00:17 UTC
Created attachment 177847 [details]
Fix raspberry pi 1 no sound.

Hi,

cat /dev/urandom > /dev/dsp

The noise is gone after about 1 second and Control-C not working.
The attachment is a patch.

Regards!
Comment 1 Oleksandr Tymoshenko freebsd_committer freebsd_triage 2016-12-20 02:29:53 UTC
Audio driver is being reworked. WIP patch can be found in bug #205979. Could you give a try to that patch? Thank you
Comment 2 commit-hook freebsd_committer freebsd_triage 2016-12-27 19:08:34 UTC
A commit references this bug:

Author: gonzo
Date: Tue Dec 27 19:08:08 UTC 2016
New revision: 310636
URL: https://svnweb.freebsd.org/changeset/base/310636

Log:
  [rpi] Fix bcm2835_audio locking and samples starvation

  Rework general approach to locking and working with audio worker thread:

  - Use flags to signal requested worker action
  - Fix submitted buffer calculations to avoid samples starvation
  - Protect buffer pointers with locks to fix race condition between callback
    and audio worker thread
  - Remove unnecessary vchi_service_use
  - Do not use lock to serialize VCHI requests since only one thread issues them now
  - Fix unloading signaling per hselasky@ suggestion
  - Add output to detect inconsistent callback data caused by possible firmware bug
    https://github.com/raspberrypi/firmware/issues/696
  - Add stats/debug sysctls to troubleshoot possible bugs

  PR:		213687, 205979, 215194
  MFC after:	1 week

Changes:
  head/sys/arm/broadcom/bcm2835/bcm2835_audio.c
Comment 3 Oleksandr Tymoshenko freebsd_committer freebsd_triage 2016-12-27 21:44:17 UTC
According to my test this issue is fixed in new version of the driver. Thanks for reporting it.
Comment 4 commit-hook freebsd_committer freebsd_triage 2017-05-08 19:58:46 UTC
A commit references this bug:

Author: gonzo
Date: Mon May  8 19:57:16 UTC 2017
New revision: 317974
URL: https://svnweb.freebsd.org/changeset/base/317974

Log:
  MFC r308424, r310636

  r308424:
  Fix locking in bcm2835_audio driver

  - Move all VCHI activity to worker thread: channel methods are called with
      non-sleepable lock held and VCHI uses sleepable lock.

  - In worker thread use sx(9) lock instead of mutex(9) for the same reason.

  PR:		213801, 205979

  r310636:
  [rpi] Fix bcm2835_audio locking and samples starvation

  Rework general approach to locking and working with audio worker thread:

  - Use flags to signal requested worker action
  - Fix submitted buffer calculations to avoid samples starvation
  - Protect buffer pointers with locks to fix race condition between callback
    and audio worker thread
  - Remove unnecessary vchi_service_use
  - Do not use lock to serialize VCHI requests since only one thread issues them now
  - Fix unloading signaling per hselasky@ suggestion
  - Add output to detect inconsistent callback data caused by possible firmware bug
    https://github.com/raspberrypi/firmware/issues/696
  - Add stats/debug sysctls to troubleshoot possible bugs

  PR:		213687, 205979, 215194

Changes:
_U  stable/11/
  stable/11/sys/arm/broadcom/bcm2835/bcm2835_audio.c