Page MenuHomeFreeBSD

sound: Get rid of pnum and max variables in chn_init()
AcceptedPublic

Authored by christos on Tue, Sep 3, 3:52 PM.
Tags
None
Referenced Files
F94213432: D46521.diff
Mon, Sep 16, 10:08 AM
F94181433: D46521.id142819.diff
Mon, Sep 16, 3:46 AM
Unknown Object (File)
Sat, Sep 14, 2:03 AM
Unknown Object (File)
Thu, Sep 12, 2:35 AM
Unknown Object (File)
Wed, Sep 11, 10:53 PM
Unknown Object (File)
Wed, Sep 11, 10:26 PM
Unknown Object (File)
Tue, Sep 10, 10:36 PM
Unknown Object (File)
Mon, Sep 9, 9:34 AM
Subscribers

Details

Summary

The VCHAN count is checked in vchan_setnew(), and there is no reason to
cap the hardware channels in the first place.

This is part of a series of follow-up patches.

Sponsored by: The FreeBSD Foundation
MFC after: 2 days

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped
Build Status
Buildable 59290
Build 56177: arc lint + arc unit

Event Timeline

sys/dev/sound/pcm/channel.c
1205

Not related to this patch, but to the overall topic of vchan_setnew(): I suppose the unit number should be unique, right? Are we sure this is the case when somebody lowers the vchan sysctls and vchan_setnew() garbage collects some of the intermediate vchans?

sys/dev/sound/pcm/channel.c
1205

If I understand correctly, what you are asking is the following. Suppose we have the following state:

vp0 -> unused
vp1 -> unused
vp2 -> someapp

If we lower the VCHAN amount to 1, we'll get the following:

vp2 -> someapp

Then, we set them to 4, and spawn 3 VCHANs:

vp0 -> foo
vp1 -> bar
vp2 -> someapp?
vp3 -> baz?

Apparently, after some testing now, I found out that in this scenario we'll override vp2 and essentially break things. Currently chn_init() does not make sure the unit doesn't already exist and instead just picks the length of the channel list (for a given direction) as the new unit number, which, as demonstrated in this example, can result in picking a unit number that already exists, when creating the 3rd channel.

What we should be doing in this loop is checking that c->unit != unit.

sys/dev/sound/pcm/channel.c
1205

Bingo! ;-)
Didn't have time to test it yesterday before I had to leave.

Any comment related to the patch?

sys/dev/sound/pcm/channel.c
1205

I will fix this ASAP, as it currently hangs sound(4). I think we end up in some infinite loop in either vchan_setnew() or something. Will have to investigate...

christos added inline comments.
sys/dev/sound/pcm/channel.c
1205

@dev_submerge.ch D46548 fixes the actual hang (although, as mentioned in the commit message) I am not completely sure which part exactly caused it, and D46550 fixes the unique unit problem. D46549 is needed in order to simplify the unit assignment (easier to work with a sorted list).

This revision is now accepted and ready to land.Fri, Sep 13, 6:33 PM