Yisheng Xie [Mon, 21 May 2018 11:58:06 +0000 (19:58 +0800)]
ALSA: oxfw: use match_string() helper
match_string() returns the index of an array for a matching string,
which can be used intead of open coded variant.
Signed-off-by: Yisheng Xie <xieyisheng1@huawei.com>
Reviewed-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Takashi Iwai [Mon, 21 May 2018 20:21:50 +0000 (22:21 +0200)]
Merge branch 'topic/xen' into for-next
Merge Xen para-virtualized frontend driver from Oleksandr Andrushchenko.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Takashi Sakamoto [Sun, 20 May 2018 05:40:44 +0000 (14:40 +0900)]
ALSA: dice: add stream format parameters for TC Electronic Digital Konnekt x32
TC Electronic Digital Konnekt x32 is an application of WaveFront DiceII STD
and doesn't support TCAT extended application protocol. For such devices,
ALSA dice driver needs to have hard-coded parameters for stream formats.
This commit adds stream format parameters for this model. Unfortunately, at
sampling transmission frequencies of 88.2/96.0kHz, I confirmed that current
ALSA dice driver doesn't drive the device appropriately due to detecting
packet discontinuities.
$ journalctl
kernel: snd_dice fw1.0: Detect discontinuity of CIP: 90 80
At the frequencies, the device transfers 16 data blocks per packet and 16
data channels per data block, as a result one packet includes 1032 bytes
if it's not NODATA. However, as long as I checked, the device often
postpone packet transmission and continue with truncated payload than
metadata in isochronous packet header. Below is a sample of sequence I got.
sec cycle bytes CIP1 CIP2
37 3314 1032 0x01100090 0x900449E2
37 3315 8 0x011000A0 0x9004FFFF
37 3316 1032 0x011000A0 0x900461E2
37 3317 1032 0x011000B0 0x900475E2
37 3318 1032 0x011000C0 0x900489E2
37 3319 8 0x011000D0 0x9004FFFF
37 3320 1032 0x011000D0 0x9004A1E2
37 3321 1032 0x011000E0 0x9004B5E2
37 3322 1032 0x011000F0 0x9004C9E2
37 3323 8 0x01100000 0x9004FFFF
37 3324 1032 0x01100000 0x9004E1E2
37 3325 1032 0x01100010 0x9004F5E2
37 3326 1032 0x01100020 0x900409E2
37 3327 8 0x01100030 0x9004FFFF
37 3328 1032 0x01100030 0x900421E2
37 3329 1032 0x01100040 0x900435E2
37 3330 (skip)
37 3331 (skip)
37 3332 (skip)
37 3333 (skip)
37 3334 (skip)
37 3335 (skip)
37 3336 (skip)
37 3337 (skip)
37 3338 (skip)
37 3339 (skip)
37 3340 (skip)
37 3341 (skip)
37 3342 (skip)
37 3343 (skip)
37 3344 (skip)
37 3345 (skip)
37 3346 (skip)
37 3347 (skip)
37 3348 (skip)
37 3349 (skip)
37 3350 (skip)
37 3351 (skip)
37 3352 (skip)
37 3353 (skip)
37 3354 (skip)
37 3355 (skip)
37 3356 (skip)
37 3357 (skip)
37 3358 (skip)
37 3359 (skip)
37 3360 (skip)
37 3361 (skip)
37 3362 (skip)
37 3363 (skip)
37 3364 (skip)
37 3365 (skip)
37 3366 (skip)
37 3367 1032 0x01100050 0x900461E1
37 3368 1032 0x01100060 0x900475E1
37 3369 1032 0x01100070 0x9004A1E1
37 3370 1032 0x01100080 0x9004A1E1 but content of payload is truncated.
37 3371 (skip)
37 3371 1032 0x01100080 0x9004B5E0 detect discontinuity
37 3372 1032 0x01100090 0x9004C9E0
37 3373 1032 0x011000A0 0x9004E1E0
37 3374 1032 0x011000B0 0x9004F5E0
37 3375 1032 0x011000C0 0x900409E0
37 3376 1032 0x011000D0 0x900421E0
37 3377 1032 0x011000E0 0x900435E0
37 3378 1032 0x011000F0 0x900449DF
37 3379 8 0x01100000 0x9004FFFF
37 3380 1032 0x01100000 0x900461DF
37 3381 1032 0x01100010 0x900475DF
37 3382 1032 0x01100020 0x900489DF
37 3383 8 0x01100030 0x9004FFFF
37 3384 1032 0x01100030 0x9004A1DF
37 3385 1032 0x01100040 0x9004B5DF
37 3386 1032 0x01100050 0x9004C9DF
37 3387 8 0x01100060 0x9004FFFF
I cannot confirm this quirks with Windows driver. ALSA dice driver has a
cause if assumed differences between these two drivers are ways of
timestampling to RX packets from the drivers to the device. I've already
reported timestamping quirk of Dice-based devices and this might bring
this issue.
[alsa-devel] Dice packet sequence quirk and ALSA firewire stack in Linux 4.6
http://mailman.alsa-project.org/pipermail/alsa-devel/2016-May/107715.html
Well, nevertheless, I enable ALSA dice driver to work at the frequencies.
This may brings inconvenience to users but I expect developers and users
to fix it.
$ cd linux-firewire-utils/src
$ python2 crpp < /sys/bus/firewire/devices/fw1/config_rom
ROM header and bus information block
-----------------------------------------------------------------
400
040423bb bus_info_length 4, crc_length 4, crc 9147
404
31333934 bus_name "1394"
408
e0ff8112 irmc 1, cmc 1, isc 1, bmc 0, pmc 0, cyc_clk_acc 255,
max_rec 8 (512), max_rom 1, gen 1, spd 2 (S400)
40c
00016604 company_id 000166 |
410
0c232c28 device_id
040c232c28 | EUI-64
000166040c232c28
root directory
-----------------------------------------------------------------
414
0006b6cb directory_length 6, crc 46795
418
03000166 vendor
41c
8100000a --> descriptor leaf at 444
420
17000030 model
424
8100000f --> descriptor leaf at 460
428
0c0087c0 node capabilities per IEEE 1394
42c
d1000001 --> unit directory at 430
unit directory at 430
-----------------------------------------------------------------
430
000476c2 directory_length 4, crc 30402
434
12000166 specifier id
438
13000001 version
43c
17000030 model
440
81000010 --> descriptor leaf at 480
descriptor leaf at 444
-----------------------------------------------------------------
444
0006c490 leaf_length 6, crc 50320
448
00000000 textual descriptor
44c
00000000 minimal ASCII
450
54432045 "TC E"
454
6c656374 "lect"
458
726f6e69 "roni"
45c
63000000 "c"
descriptor leaf at 460
-----------------------------------------------------------------
460
000772b4 leaf_length 7, crc 29364
464
00000000 textual descriptor
468
00000000 minimal ASCII
46c
44696769 "Digi"
470
74616c4b "talK"
474
6f6e6e65 "onne"
478
6b747833 "ktx3"
47c
32000000 "2"
descriptor leaf at 480
-----------------------------------------------------------------
480
000772b4 leaf_length 7, crc 29364
484
00000000 textual descriptor
488
00000000 minimal ASCII
48c
44696769 "Digi"
490
74616c4b "talK"
494
6f6e6e65 "onne"
498
6b747833 "ktx3"
49c
32000000 "2"
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Dan Carpenter [Fri, 18 May 2018 09:16:07 +0000 (12:16 +0300)]
ALSA: dice: fix a bounds check in snd_dice_detect_tcelectronic_formats()
The "entry" pointer is always non-NULL so this test for out of bounds
won't work.
Fixes:
f1f0f330b1d0 ("ALSA: dice: add parameters of stream formats for models produced by TC Electronic")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Reviewed-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Takashi Iwai [Fri, 18 May 2018 06:50:40 +0000 (08:50 +0200)]
Merge branch 'topic/timer-fixes' into for-next
Pull the fixes for possible races in the resolution callback.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Melvin Vermeeren [Thu, 17 May 2018 19:00:00 +0000 (21:00 +0200)]
ALSA: dice: add stream format parameters for Mytek devices
--nextPart3916812.EicPReet6m
Content-Transfer-Encoding: 7Bit
Content-Type: text/plain; charset="us-ascii"
Mytek manufactures some equipment with DICE-based firewire ports. These
devices contain old versions of DICE firmware which lacks detailed
stream format reporting for all sampling clock modes.
Building upon the recent work by Takashi Sakamoto, hard-coded parameters
are added for the Stereo 192 DSD-DAC. When the device vendor and model
match the coded parameters are copied into the stream format cache.
Signed-off-by: Melvin Vermeeren <mail@mel.vin>
Reviewed-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Takashi Iwai [Wed, 16 May 2018 21:52:42 +0000 (23:52 +0200)]
ALSA: timer: Assure timer resolution access always locked
There are still many places calling the timer's hw.c_resolution
callback without lock, and this may lead to some races, as we faced in
the commit
a820ccbe21e8 ("ALSA: pcm: Fix UAF at PCM release via PCM
timer access").
This patch changes snd_timer_resolution() to take the timer->lock for
avoiding the races. A place calling this function already inside the
lock (from the notifier) is replaced with the
snd_timer_hw_resolution() accordingly, as well as wrapping with the
lock around another place calling snd_timer_hw_resolution(), too.
Reported-by: Ben Hutchings <ben.hutchings@codethink.co.uk>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Takashi Iwai [Thu, 17 May 2018 08:43:16 +0000 (10:43 +0200)]
ALSA: seq: Avoid open-code for getting timer resolution
Instead of open-coding for getting the timer resolution, use the
standard snd_timer_resolution() helper.
The original code falls back to the callback function when the
resolution is zero, but it must be always so when the callback
function is defined. So this should be no functional change.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Takashi Iwai [Wed, 16 May 2018 21:45:33 +0000 (23:45 +0200)]
ALSA: timer: Simplify timer hw resolution calls
There multiple open-codes to get the hardware timer resolution.
Make a local helper function snd_timer_hw_resolution() and call it
from all relevant places.
There is no functional change by this, just a preliminary work for the
following timer resolution hardening patch.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Ben Hutchings [Thu, 17 May 2018 21:34:39 +0000 (22:34 +0100)]
ALSA: timer: Fix pause event notification
Commit
f65e0d299807 ("ALSA: timer: Call notifier in the same spinlock")
combined the start/continue and stop/pause functions, and in doing so
changed the event code for the pause case to SNDRV_TIMER_EVENT_CONTINUE.
Change it back to SNDRV_TIMER_EVENT_PAUSE.
Fixes:
f65e0d299807 ("ALSA: timer: Call notifier in the same spinlock")
Signed-off-by: Ben Hutchings <ben.hutchings@codethink.co.uk>
Cc: stable@vger.kernel.org
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Ruslan Bilovol [Thu, 17 May 2018 22:08:59 +0000 (01:08 +0300)]
ALSA: usb: stream: fix potential memory leak during uac3 interface parsing
UAC3 channel map is created during interface parsing,
and in some cases was not freed in failure paths.
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Ruslan Bilovol <ruslan.bilovol@gmail.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Takashi Iwai [Thu, 17 May 2018 18:02:23 +0000 (20:02 +0200)]
ALSA: emu10k1: Rate-limit error messages about page errors
The error messages at sanity checks of memory pages tend to repeat too
many times once when it hits, and without the rate limit, it may flood
and become unreadable. Replace such messages with the *_ratelimited()
variant.
Bugzilla: http://bugzilla.opensuse.org/show_bug.cgi?id=1093027
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Colin Ian King [Thu, 17 May 2018 08:04:20 +0000 (09:04 +0100)]
ALSA: emu10k1: fix spelling mistake: "Caputre" -> "Capture"
Trivial fix to spelling mistakes in audigy_outs arrays.
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Takashi Iwai [Tue, 15 May 2018 18:25:29 +0000 (20:25 +0200)]
ALSA: core: Assure control device to be registered at last
The commit
289ca025ee1d ("ALSA: Use priority list for managing device
list") changed the way to register/disconnect/free devices via a
single priority list. This helped to make behavior consistent, but it
also changed a slight behavior change: namely, the control device is
registered earlier than others, while it was supposed to be the very
last one.
I've put SNDRV_DEV_CONTROL in the current position as the release of
ctl elements often conflict with the private ctl elements some PCM or
other components may create, which often leads to a double-free.
But, the order of register and disconnect should be indeed fixed as
expected in the early days: the control device gets registered at
last, and disconnected at first.
This patch changes the priority list order to move SNDRV_DEV_CONTROL
as the last guy to assure the register / disconnect order. Meanwhile,
for keeping the messy resource release order, manually treat the
control and lowlevel devices as last freed one.
Additional note:
The lowlevel device is the device where a card driver creates at
probe. And, we still keep the release order control -> lowlevel, as
there might be link from a control element back to a lowlevel object.
Fixes:
289ca025ee1d ("ALSA: Use priority list for managing device list")
Reported-by: Tzung-Bi Shih <tzungbi@google.com>
Tested-by: Tzung-Bi Shih <tzungbi@google.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Takashi Iwai [Wed, 16 May 2018 18:07:18 +0000 (20:07 +0200)]
ALSA: usb-audio: Apply rate limit to warning messages in URB complete callback
retire_capture_urb() may print warning messages when the given URB
doesn't align, and this may flood the system log easily.
Put the rate limit to the message for avoiding it.
Bugzilla: https://bugzilla.suse.com/show_bug.cgi?id=1093485
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Oleksandr Andrushchenko [Mon, 14 May 2018 06:27:42 +0000 (09:27 +0300)]
MAINTAINERS: Add ALSA: xen-front: maintainer entry
Add myself as sound/xen maintainer.
Signed-off-by: Oleksandr Andrushchenko <oleksandr_andrushchenko@epam.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Oleksandr Andrushchenko [Mon, 14 May 2018 06:27:41 +0000 (09:27 +0300)]
ALSA: xen-front: Implement ALSA virtual sound driver
Implement essential initialization of the sound driver:
- introduce required data structures
- handle driver registration
- handle sound card registration
- register sound driver on backend connection
- remove sound driver on backend disconnect
Initialize virtual sound card with streams according to the
Xen store configuration.
Implement ALSA driver operations including:
- manage frontend/backend shared buffers
- manage Xen bus event channel states
Implement requests from front to back for ALSA
PCM operations.
- report ALSA period elapsed event: handle XENSND_EVT_CUR_POS
notifications from the backend when stream position advances
during playback/capture. The event carries a value of how
many octets were played/captured at the time of the event.
- implement explicit stream parameter negotiation between
backend and frontend: handle XENSND_OP_HW_PARAM_QUERY request
to read/update configuration space for the parameter given:
request passes desired parameter interval and the response to
this request returns min/max interval for the parameter to be used.
Signed-off-by: Oleksandr Andrushchenko <oleksandr_andrushchenko@epam.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Oleksandr Andrushchenko [Mon, 14 May 2018 06:27:40 +0000 (09:27 +0300)]
ALSA: xen-front: Implement handling of shared buffers
Implement shared buffer handling according to the
para-virtualized sound device protocol at xen/interface/io/sndif.h:
- manage buffer memory
- handle granted references
- handle page directories
[ Fixed missing linux/kernel.h inclusion -- tiwai ]
Signed-off-by: Oleksandr Andrushchenko <oleksandr_andrushchenko@epam.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Oleksandr Andrushchenko [Mon, 14 May 2018 06:27:39 +0000 (09:27 +0300)]
ALSA: xen-front: Implement Xen event channel handling
Handle Xen event channels:
- create for all configured streams and publish
corresponding ring references and event channels in Xen store,
so backend can connect
- implement event channels interrupt handlers
- create and destroy event channels with respect to Xen bus state
Signed-off-by: Oleksandr Andrushchenko <oleksandr_andrushchenko@epam.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Oleksandr Andrushchenko [Mon, 14 May 2018 06:27:38 +0000 (09:27 +0300)]
ALSA: xen-front: Read sound driver configuration from Xen store
Read configuration values from Xen store according
to xen/interface/io/sndif.h protocol:
- introduce configuration structures for different
components, e.g. sound card, device, stream
- read PCM HW parameters, e.g rate, format etc.
- detect stream type (capture/playback)
- read device and card parameters
Signed-off-by: Oleksandr Andrushchenko <oleksandr_andrushchenko@epam.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Oleksandr Andrushchenko [Mon, 14 May 2018 06:27:37 +0000 (09:27 +0300)]
ALSA: xen-front: Introduce Xen para-virtualized sound frontend driver
Introduce skeleton of the para-virtualized Xen sound
frontend driver.
Initial handling for Xen bus states: implement
Xen bus state machine for the frontend driver according to
the state diagram and recovery flow from sound para-virtualized
protocol: xen/interface/io/sndif.h.
Signed-off-by: Oleksandr Andrushchenko <oleksandr_andrushchenko@epam.com>
Reviewed-by: Juergen Gross <jgross@suse.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Takashi Sakamoto [Tue, 15 May 2018 13:13:00 +0000 (22:13 +0900)]
ALSA: hda/ca0132: constify parameter table for effects
This module has a table for parameters of each effects. This table is
read-only and can have 'const' qualifier.
This commit adds this optimization.
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Takashi Sakamoto [Tue, 15 May 2018 13:12:59 +0000 (22:12 +0900)]
ALSA: hda/ca0132: merge strings just for printk
This module has some function-local strings just for printk therefore
it can be merged into format string.
This commit applies this optimization.
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Takashi Sakamoto [Tue, 15 May 2018 13:12:58 +0000 (22:12 +0900)]
ALSA: hda/ca0132: constify read-only members of string array
This module has some strings just for printk therefore they can be
read-only.
This commit applies this optimization.
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Takashi Sakamoto [Tue, 15 May 2018 13:12:57 +0000 (22:12 +0900)]
ALSA: hda/ca0132: constify templates for control element set
An array of templates for control element set is passed as an
argument for snd_hda_add_new_ctls(). This argument has 'const'
qualifier therefore the passed array can have the qualifier.
This commit adds this optimization.
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Jorge Sanjuan [Mon, 14 May 2018 11:03:42 +0000 (12:03 +0100)]
ALSA: usb-audio: UAC3: Parse Input Terminal number of channels.
Obtain the number of channels for the Input Terminal from the
Logical Cluster Descriptor. This achieves a useful minimal parsing
of this unit so it can be used in other units in the topology.
Signed-off-by: Jorge Sanjuan <jorge.sanjuan@codethink.co.uk>
Reviewed-by: Ruslan Bilovol <ruslan.bilovol@gmail.com>
Tested-by: Ruslan Bilovol <ruslan.bilovol@gmail.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Jorge Sanjuan [Fri, 11 May 2018 15:25:36 +0000 (16:25 +0100)]
ALSA: usb-audio: UAC3 Add support for connector insertion.
This adds support for the UAC3 insertion controls. The status
is reported as a boolean value in the same way it used to do
for UAC2. Hence, the presence of any connector in the response
will make the control saying the jack is connected.
The UAC2 support for this control has been moved to a dedicated
control for connectors as both UAC2 and UAC3 follow a specific
Control Request Parameter Block for this control. This parameter
block for UAC3 could not be read in the same simplistic
manner as in UAC2.
This implementation is not requesting additional information
from the HIGH CAPABILITY Connectors descriptor.
Tested with an UAC3 device with UAC2 as legacy configuration.
The connector status can be read with `amixer` and the interrupt
is also caught with `alsactl monitor`.
Signed-off-by: Jorge Sanjuan <jorge.sanjuan@codethink.co.uk>
Reviewed-by: Ruslan Bilovol <ruslan.bilovol@gmail.com>
Tested-by: Ruslan Bilovol <ruslan.bilovol@gmail.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Jorge Sanjuan [Fri, 11 May 2018 15:25:34 +0000 (16:25 +0100)]
ALSA: usb-audio: UAC3. Add support for mixer unit.
This adds support for the MIXER UNIT in UAC3. All the information
is obtained from the (HIGH CAPABILITY) Cluster's header. We don't
read the rest of the logical cluster to obtain the channel config
as that wont make any difference in the current mixer behaviour.
The name of the mixer unit is not yet requested as there is not
support for the UAC3 Class Specific String requests.
Tested in an UAC3 device working as a HEADSET with a basic mixer
unit (same as the one in the BADD spec) with no controls.
Signed-off-by: Jorge Sanjuan <jorge.sanjuan@codethink.co.uk>
Reviewed-by: Ruslan Bilovol <ruslan.bilovol@gmail.com>
Tested-by: Ruslan Bilovol <ruslan.bilovol@gmail.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Takashi Iwai [Tue, 15 May 2018 05:30:23 +0000 (07:30 +0200)]
Merge branch 'for-linus' into for-next
Back-merge of UAC3 fixes for applying further enhancements.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Jorge Sanjuan [Fri, 11 May 2018 15:25:35 +0000 (16:25 +0100)]
ALSA: usb-audio: Use Class Specific EP for UAC3 devices.
bmAtributes offset doesn't exist in the UAC3 CS_EP descriptor.
Hence, checking for pitch control as if it was UAC2 doesn't make
any sense. Use the defined UAC3 offsets instead.
Fixes:
9a2fe9b801f5 ("ALSA: usb: initial USB Audio Device Class 3.0 support")
Signed-off-by: Jorge Sanjuan <jorge.sanjuan@codethink.co.uk>
Reviewed-by: Ruslan Bilovol <ruslan.bilovol@gmail.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Fengguang Wu [Mon, 14 May 2018 19:02:14 +0000 (03:02 +0800)]
ALSA: hda/ca0132: fix array_size.cocci warnings
sound/pci/hda/patch_ca0132.c:5062:50-51: WARNING: Use ARRAY_SIZE
sound/pci/hda/patch_ca0132.c:5092:50-51: WARNING: Use ARRAY_SIZE
Use ARRAY_SIZE instead of dividing sizeof array with sizeof an element
Semantic patch information:
This makes an effort to find cases where ARRAY_SIZE can be used such as
where there is a division of sizeof the array by the sizeof its first
element or by any indexed element or the element type. It replaces the
division of the two sizeofs by ARRAY_SIZE.
Generated by: scripts/coccinelle/misc/array_size.cocci
Fixes:
47cdf76e44e8 ("ALSA: hda/ca0132: Add new control changes for SBZ + R3Di")
CC: Connor McAdams <conmanx360@gmail.com>
Signed-off-by: Fengguang Wu <fengguang.wu@intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Takashi Sakamoto [Sun, 13 May 2018 22:09:53 +0000 (07:09 +0900)]
ALSA: isight: use position offset macro of TLV data
A series of SNDRV_CTL_TLVO_XXX macro was introduced for position offset
of TLV data. This commit applies a code optimization.
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Acked-by: Clemens Ladisch <clemens@ladisch.de>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Takashi Sakamoto [Sun, 13 May 2018 22:09:52 +0000 (07:09 +0900)]
ALSA: hda: use position offset macro of TLV data
A series of SNDRV_CTL_TLVO_XXX macro was introduced for position offset
of TLV data. This commit applies a code optimization.
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Takashi Sakamoto [Sun, 13 May 2018 22:09:51 +0000 (07:09 +0900)]
ALSA: vmaster: use position offset macro of TLV data
A series of SNDRV_CTL_TLVO_XXX macro was introduced for position offset
of TLV data. This commit applies a code optimization.
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Takashi Sakamoto [Sun, 13 May 2018 22:09:50 +0000 (07:09 +0900)]
ALSA: control: complement TLV macro for db-minmax and db-linear types
A commit
08f9f4485f21 ('ALSA: core api: define offsets for TLV items')
introduced a series of macro for offset of db-scale type of TLV, however
there are some types of TLV to add similar macros.
This commit complements macros for offset of db-minmax and db-linear types
of TLV data.
Cc: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Jeremy Soller [Mon, 7 May 2018 15:28:45 +0000 (09:28 -0600)]
ALSA: hda/realtek - Clevo P950ER ALC1220 Fixup
This adds support for the P950ER, which has the same required fixup as
the P950HR, but has a different PCI ID.
Signed-off-by: Jeremy Soller <jeremy@system76.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Federico Cuello [Tue, 8 May 2018 22:13:38 +0000 (00:13 +0200)]
ALSA: usb: mixer: volume quirk for CM102-A+/102S+
Currently it's not possible to set volume lower than 26% (it just mutes).
Also fixes this warning:
Warning! Unlikely big volume range (=9472), cval->res is probably wrong.
[13] FU [PCM Playback Volume] ch = 2, val = -9473/-1/1
, and volume works fine for full range.
Signed-off-by: Federico Cuello <fedux@fedux.com.ar>
Cc: <stable@vger.kernel.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Hans de Goede [Tue, 8 May 2018 07:27:46 +0000 (09:27 +0200)]
ALSA: hda: Add Lenovo C50 All in one to the power_save blacklist
Power-saving is causing loud plops on the Lenovo C50 All in one, add it
to the blacklist.
BugLink: https://bugzilla.redhat.com/show_bug.cgi?id=1572975
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Alberto Aguirre [Tue, 8 May 2018 22:14:13 +0000 (17:14 -0500)]
ALSA: usb-audio: add boot quirk for Axe-Fx III
Wait for Axe-Fx III to fully bootup before initializing card.
Signed-off-by: Alberto Aguirre <albaguirre@gmail.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Ranjani Sridharan [Thu, 10 May 2018 00:53:04 +0000 (17:53 -0700)]
ALSA: core api: define offsets for TLV items
Currently, there are no pre-defined accessors for the elements
in topology TLV data. In the absence of such offsets, the
tlv data will have to be decoded using hardwired offset
numbers 0-N depending on the type of TLV. This patch defines
accessor offsets for the type, length, min and mute/step items
in TLV data for DB_SCALE type tlv's. These will be used by drivers to
decode the TLV data while loading topology thereby improving
code readability. The type and len offsets are common for all TLV
types. The min and step/mute offsets are specific to DB_SCALE tlv type.
Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Reviewed-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Connor McAdams [Tue, 8 May 2018 17:20:13 +0000 (13:20 -0400)]
ALSA: hda/ca0132: Add new control changes for SBZ + R3Di
This patch adds new controls to set the effect levels on the R3Di and
SBZ. It also adds vmaster controls to control all surround sound
channels. So that Surround effect switch doesn't conflict with Surround
volume, FX: prefix added to all effect related switches.
Tested-by: Mariusz Ceier <mceier+kernel@gmail.com>
Signed-off-by: Connor McAdams <conmanx360@gmail.com>
Reviewed-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Connor McAdams [Tue, 8 May 2018 17:20:12 +0000 (13:20 -0400)]
ALSA: hda/ca0132: add ca0132_alt_set_vipsource
Add function to set vipsource on cards that use_alt_controls. Different
sequence. Also, add cvoice_switch_set at end of ca0132_select_in so that
when switching between inputs cvoice state is maintained.
Signed-off-by: Connor McAdams <conmanx360@gmail.com>
Reviewed-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Connor McAdams [Tue, 8 May 2018 17:20:11 +0000 (13:20 -0400)]
ALSA: hda/ca0132: Add DSP Volume set and New mixers for SBZ + R3Di
Adds lookup table for floating point decibel volume, and new functions
to allow for setting the decibel level on the DSP.
Signed-off-by: Connor McAdams <conmanx360@gmail.com>
Reviewed-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Connor McAdams [Tue, 8 May 2018 17:20:10 +0000 (13:20 -0400)]
ALSA: hda/ca0132: add alt_select_in/out for R3Di + SBZ
Add functions ca0132_alt_select_out and ca0132_alt_select_in for
switching outputs and inputs for r3di and sbz. Also, add enumerated
controls for selecting output and input source.
Signed-off-by: Connor McAdams <conmanx360@gmail.com>
Reviewed-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Connor McAdams [Tue, 8 May 2018 17:20:09 +0000 (13:20 -0400)]
ALSA: hda/ca0132: add the ability to set src_id on scp commands
This patch adds the ability to change the src_id on scp commands, which
is used in the dsp setup of the Recon3Di and the Sound Blaster Z. It
also makes sure to maintain backwards compatibility with the older
dspio_set_uint_param function, and sets it's src to the default 0x20.
Signed-off-by: Connor McAdams <conmanx360@gmail.com>
Reviewed-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Connor McAdams [Tue, 8 May 2018 17:20:08 +0000 (13:20 -0400)]
ALSA: hda/ca0132: Add dsp setup + gpio functions for r3di
Adds dsp setup functions for Recon3Di as well as the GPIO functions
specific to it.
Signed-off-by: Connor McAdams <conmanx360@gmail.com>
Reviewed-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Connor McAdams [Tue, 8 May 2018 17:20:07 +0000 (13:20 -0400)]
ALSA: hda/ca0132: add dsp setup related commands for the sbz
Add dsp setup related functions for the Sound Blaster Z, along with
other helper functions.
Also, add sbz_dsp_startup_check, which fixes a bug where the card
sometimes starts up and has no sound.
Signed-off-by: Connor McAdams <conmanx360@gmail.com>
Reviewed-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Connor McAdams [Tue, 8 May 2018 17:20:06 +0000 (13:20 -0400)]
ALSA: hda/ca0132: update core functions for sbz + r3di
This patch updates core functions to accommodate the Sound Blaster Z and
Recon3Di by changing which functions they use. It also adds the ability
to enable/disable streams.
Signed-off-by: Connor McAdams <conmanx360@gmail.com>
Reviewed-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Connor McAdams [Tue, 8 May 2018 17:20:05 +0000 (13:20 -0400)]
ALSA: hda/ca0132: add extra init functions for r3di + sbz
This patch adds extra init functions for the Sound Blaster Z and
Recon3Di. It also adds more checks to make sure that the DSP isn't
downloaded twice on startup, by checking if the dsp_state is already set
to DSP_DOWNLOADED. It also adds the ability to re-download the DSP on a
resume.
It also changes the init verbs table to apply to all codecs, and takes
the two specific end verbs and puts them into a separate function in
ca0132_init instead.
GPIO functions are also added.
Signed-off-by: Connor McAdams <conmanx360@gmail.com>
Reviewed-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Connor McAdams [Tue, 8 May 2018 17:20:04 +0000 (13:20 -0400)]
ALSA: hda/ca0132: Add extra exit functions for R3Di and SBZ
This patch adds extra functions for shutdown on the Sound Blaster Z and
Recon3Di. The Recon3Di only has one specific functions, which sets the
GPIO data pins to 0 to prevent a popping noise.
The Sound Blaster Z exit sequence was taken from Windows. Without this
exit function, the card will not reload properly unless the PC has been
shutdown to clear the onboard memory. There are commented out functions
currently in the sbz_exit_chip function that are added in a later patch.
Also, a reboot notify function has been added, to make sure these
functions are ran before a reboot. This helps when using the card
through VFIO in a virtual machine, to make sure the card reloads the DSP
properly.
Signed-off-by: Connor McAdams <conmanx360@gmail.com>
Reviewed-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Connor McAdams [Tue, 8 May 2018 17:20:03 +0000 (13:20 -0400)]
ALSA: hda/ca0132: Add PCI region2 iomap for SBZ
This patch adds iomapping for the region2 section of memory on the SBZ.
This memory region is used in later patches for setting inputs and
outputs. If the mapping fails, the quirk is changed back to QUIRK_NONE
to avoid attempts to write to uninitialized memory.
It also adds a new exit sequence to unmap the iomem for the SBZ.
[ Reordered linux/*.h inclusion in the patch by tiwai ]
Signed-off-by: Connor McAdams <conmanx360@gmail.com>
Reviewed-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Connor McAdams [Tue, 8 May 2018 17:20:02 +0000 (13:20 -0400)]
ALSA: hda/ca0132: Add pincfg for SBZ + R3Di, add fp hp auto-detect
This patch adds an unsolicited response tag for the front headphone
panel which uses the same hp_callback as the rear headphone detection.
This patch also adds pincfgs for the R3Di and SBZ which were taken from
the Windows driver. The pins are also defined in the function
ca0132_config. Both the R3Di and SBZ are also given a max out channel
value of 6 to handle 5.1 surround sound in later patches.
Signed-off-by: Connor McAdams <conmanx360@gmail.com>
Reviewed-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Connor McAdams [Tue, 8 May 2018 17:20:01 +0000 (13:20 -0400)]
ALSA: hda/ca0132: R3Di and SBZ quirk entires + alt firmware loading
This patch adds PCI quirk ID's for the Sound Blaster Z and Recon3Di.
Only the currently tested ID's have been added.
This patch also adds the ability to load alternative firmwares for each
card, the firmwares can be obtained from within the Windows driver.
The Recon3Di uses "ctefx-r3di.bin" and the Sound Blaster Z uses
"ctefx-sbz.bin". If the alternative firmware for the given quirk is not
found, the original ctefx.bin will be used. This has been confirmed to
work for both the R3Di and the SBZ.
This patch also makes the character array *dirstr a const.
Signed-off-by: Connor McAdams <conmanx360@gmail.com>
Reviewed-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Wenwen Wang [Sat, 5 May 2018 18:38:03 +0000 (13:38 -0500)]
ALSA: control: fix a redundant-copy issue
In snd_ctl_elem_add_compat(), the fields of the struct 'data' need to be
copied from the corresponding fields of the struct 'data32' in userspace.
This is achieved by invoking copy_from_user() and get_user() functions. The
problem here is that the 'type' field is copied twice. One is by
copy_from_user() and one is by get_user(). Given that the 'type' field is
not used between the two copies, the second copy is *completely* redundant
and should be removed for better performance and cleanup. Also, these two
copies can cause inconsistent data: as the struct 'data32' resides in
userspace and a malicious userspace process can race to change the 'type'
field between the two copies to cause inconsistent data. Depending on how
the data is used in the future, such an inconsistency may cause potential
security risks.
For above reasons, we should take out the second copy.
Signed-off-by: Wenwen Wang <wang6495@umn.edu>
Cc: <stable@vger.kernel.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Ruslan Bilovol [Fri, 4 May 2018 01:24:04 +0000 (04:24 +0300)]
ALSA: usb: add UAC3 BADD profiles support
Recently released USB Audio Class 3.0 specification
contains BADD (Basic Audio Device Definition) document
which describes pre-defined UAC3 configurations.
BADD support is mandatory for UAC3 devices, it should be
implemented as a separate USB device configuration.
As per BADD document, class-specific descriptors
shall not be included in the Device’s Configuration
descriptor ("inferred"), but host can guess them
from BADD profile number, number of endpoints and
their max packed sizes.
This patch adds support of all BADD profiles from the spec
Signed-off-by: Ruslan Bilovol <ruslan.bilovol@gmail.com>
Tested-by: Jorge Sanjuan <jorge.sanjuan@codethink.co.uk>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Anna-Maria Gleixner [Fri, 4 May 2018 15:28:10 +0000 (17:28 +0200)]
ALSA: pcm: Hide local_irq_disable/enable() and local_irqsave/restore()
The snd_pcm_stream_lock_irq*() functions decouple disabling interrupts
from the actual locking process. This does not work as expected if the
locking primitives are replaced like on preempt-rt.
Provide one function for locking which uses correct locking primitives.
Signed-off-by: Anna-Maria Gleixner <anna-maria@linutronix.de>
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Ruslan Bilovol [Fri, 4 May 2018 01:24:03 +0000 (04:24 +0300)]
include: usb: audio-v3: add BADD-specific values
Add BADD-specific predefined values to audio-v3
so usb-audio in ALSA and UAC3 gadget can use them
Signed-off-by: Ruslan Bilovol <ruslan.bilovol@gmail.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Ruslan Bilovol [Fri, 4 May 2018 01:24:02 +0000 (04:24 +0300)]
ALSA: usb: mixer: make string parsing independent of mixer_build state
Functions like snd_usb_copy_string_desc() or
get_term_name() don't actually need mixer_build
state but can use snd_usb_audio structure instead
to get usb device.
This patch has no functional change but prepares
to future UAC3 BADD profiles support which don't
have class-specific descriptors so won't have
mixer_build state.
Signed-off-by: Ruslan Bilovol <ruslan.bilovol@gmail.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Jorge Sanjuan [Fri, 4 May 2018 01:24:01 +0000 (04:24 +0300)]
ALSA: usb: Only get AudioControl header for UAC1 class.
The control header needs to be read from buffer at this point only
in the case of UAC1 protocol. Move it inside the switch case as other
protocols such as the Basic Audio Device spec will have an empty buffer
that is latter filled as inferred.
Signed-off-by: Jorge Sanjuan <jorge.sanjuan@codethink.co.uk>
[Ruslan: updated with recently added sanity checks]
Signed-off-by: Ruslan Bilovol <ruslan.bilovol@gmail.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Ruslan Bilovol [Fri, 4 May 2018 01:24:00 +0000 (04:24 +0300)]
ALSA: usb: stream: refactor uac3 audio interface parsing
Offload snd_usb_parse_audio_interface() function
which became quite long after adding UAC3 spec support.
Move class-specific parts of uac3 parsing to separate
function which now produce audioformat structure that
is ready to be fed to snd_usb_add_audio_stream().
Signed-off-by: Ruslan Bilovol <ruslan.bilovol@gmail.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Ruslan Bilovol [Fri, 4 May 2018 01:23:59 +0000 (04:23 +0300)]
ALSA: usb: stream: refactor uac1/2 audio interface parsing
Offload snd_usb_parse_audio_interface() function
which became quite long after adding UAC3 spec support.
Move class-specific parts of uac1/2 parsing to separate
function which now produce audioformat structure that
is ready to be fed to snd_usb_add_audio_stream().
This also broke Blue Microphones workaround (which
relies on audioformat decoded from previous altsetting)
into two parts: prepare quirk flag analyzing previous
altsetting then use it with current altsetting.
Signed-off-by: Ruslan Bilovol <ruslan.bilovol@gmail.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Ruslan Bilovol [Fri, 4 May 2018 01:23:58 +0000 (04:23 +0300)]
ALSA: usb: stream: move audioformat alloc/init into separate function
Offload snd_usb_parse_audio_interface() function which
became quite long after adding UAC3 spec support.
Move audioformat allocation and initialization
into separate function, this will make easier
future refactoring.
Attributes left in the original func because it'll
be used for UAC3 BADD profiles suport in the future
There is no functional change.
Signed-off-by: Ruslan Bilovol <ruslan.bilovol@gmail.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Takashi Iwai [Thu, 3 May 2018 10:33:32 +0000 (12:33 +0200)]
ALSA: usb-audio: Clean up mixer element list traverse
Introduce a new macro for iterating over mixer element list for
avoiding the open codes in many places. Also the open-coded
container_of() and the forced cast to struct usb_mixer_elem_info are
replaced with another simple macro, too.
No functional changes but just readability improvement.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Takashi Iwai [Thu, 3 May 2018 08:51:41 +0000 (10:51 +0200)]
ALSA: sparc: Use GFP_KERNEL for non-atomic allocation
dbri driver allocates a resource with GFP_ATOMIC unnecessarily in its
probe function. Replace it with the standard GFP_KERNEL for avoiding
the bogus allocation failures.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Takashi Iwai [Wed, 2 May 2018 12:28:38 +0000 (14:28 +0200)]
ALSA: usb-audio: Give proper vendor/product name for Dell WD15 Dock
Dell WD15 Dock with 0bda:4014 doesn't give any useful strings for the
vendor and the product names. Name them more specifically via quirk,
as well as the UCM profile name.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Takashi Iwai [Wed, 2 May 2018 12:45:37 +0000 (14:45 +0200)]
ALSA: usb-audio: Allow to override the longname string
Historically USB-audio driver sets the card's longname field with the
details of the device and the bus information. It's good per se, but
not preferable when it's referred as the identifier for UCM profile.
This patch adds a quirk profile_name field to override the card's
longname string to a pre-defined one, so that one can create a unique
and consistent ID string for the specific USB device via a quirk table
to be used as a UCM profile name.
The patch does a slight code refactoring to split out the functions to
set shortname and longname fields as well.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Takashi Iwai [Wed, 2 May 2018 09:52:55 +0000 (11:52 +0200)]
ALSA: usb-audio: Add "Keep Interface" control
This patch adds "Keep Interface" control for each USB-audio device.
The control element is with SND_CTL_IFACE_CARD, so that it won't
appear on any sane mixer applications. For a device that is confirmed
to work well with "keep-interface" mode, user can flip the control via
amixer, e.g.
% amixer -c1 cset iface=CARD,name='Keep Interface' on
and save/restore the state via alsactl.
The reason to provide this via control API is that the behavior must
be pretty depending on the device (and the firmware in it), so it's
not ideal to apply via module option.
For a device that certainly works, we may set it statically via a
quirk table entry. But a device like Dell WD15 dock behaves so
differently depending on the firmware, and we can't set it
statically. So leave this as a dynamic switch each user can adjust
freely.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Takashi Iwai [Wed, 2 May 2018 08:04:27 +0000 (10:04 +0200)]
ALSA: usb-audio: Add keep_iface flag
Introduce a new flag to struct snd_usb_audio for allowing the device
to skip usb_set_interface() calls at changing or closing the stream.
As of this patch, the flag is nowhere set, so it's just a place
holder. The dynamic switching will be added in the following patch.
A background information for this change:
Dell WD15 dock with Realtek chip gives a very long pause at each time
the driver changes the altset, which eventually happens at every PCM
stream open/close and parameter change. As the long pause happens in
each usb_set_interface() call, there is nothing we can do as long as
it's called. The workaround is to reduce calling it as much as
possible, and this flag indicates that behavior.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Takashi Iwai [Wed, 2 May 2018 07:36:28 +0000 (09:36 +0200)]
ALSA: usb-audio: Avoid superfluous usb_set_interface() calls
This is a preliminary change for the upcoming quirk implementation.
Currently USB-audio driver tries to call usb_set_interface() whenever
the format change with interface/altset modification happens. In this
patch, the check is replaced with the comparison of cur_altsetting and
the targeted altsetting pointer, so that the driver may skip the
unnecessary function calls.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Takashi Iwai [Fri, 27 Apr 2018 12:23:37 +0000 (14:23 +0200)]
ALSA: usb-audio: Initialize Dell Dock playback volumes
In the early commit
adcdd0d5a1cb ("ALSA: usb-audio: Skip volume
controls triggers hangup on Dell USB Dock"), we add the mixer quirks
for Dell dock to skip two mixer FU's for playback. This supposed that
the device has always the proper initial volume, but it doesn't seem
always correct.
This patch adds the explicit initialization of the volumes to the
fixed 0dB at the device probe time. Also, such a fixup is needed
after the resume, so a new function is hooked to the resume callback
as well.
Bugzilla: http://bugzilla.suse.com/show_bug.cgi?id=1089467
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Takashi Sakamoto [Wed, 2 May 2018 10:16:51 +0000 (19:16 +0900)]
ALSA: dice: remove local frag of force_two_pcms
At present, to add PCM substreams for each of available tx/rx streams,
this driver uses a condition based on model-name. This is not enough
to support unknown models.
In former commits, this driver gains cache of stream formats. For models
which support protocol extension, all of available steam formats are
cached. For known models, hard-coded stream formats are used to generate
the cache. For unknown models, stream formats at current mode of sampling
transmission frequency is cached.
Anyway, at least, the cached formats are used to expose constrains of PCM
substreams for userspace applications. Thus, The cached data can be also
used to add PCM substreams themselves, instead of the name-based
conditions.
This commit obsoletes local frag of force_two_pcms.
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Takashi Sakamoto [Wed, 2 May 2018 10:16:50 +0000 (19:16 +0900)]
ALSA: dice: use cache for PCM constraints and rules
In former commits, proxy structure gets members for cache of stream
formats. The cache allows to apply correct constraints and rules to
runtime of PCM substream. They allows userspace applications to change
current sampling transmission frequency.
This commit uses the cacher for the PCM constraints and rules.
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Takashi Sakamoto [Wed, 2 May 2018 10:16:49 +0000 (19:16 +0900)]
ALSA: dice: use stream formats to add MIDI substreams
In former commits, proxy structure gets members for cache of stream
formats. The cache can be used to count the number of MIDI substreams
to add.
This commit uses the cache for this purpose.
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Takashi Sakamoto [Wed, 2 May 2018 10:16:48 +0000 (19:16 +0900)]
ALSA: dice: enable to change current sampling transmission frequency
This is a preparation for userspace applications to change current sampling
transmission frequency via ALSA PCM interface.
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Takashi Sakamoto [Wed, 2 May 2018 10:16:47 +0000 (19:16 +0900)]
ALSA: dice: add a helper function to restart all of available streams
This commit is a small refactoring for better readability.
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Takashi Sakamoto [Wed, 2 May 2018 10:16:46 +0000 (19:16 +0900)]
ALSA: dice: use cache of stream format to check running stream
At present, to check running stream, available stream formats are used
at current sampling transmission frequency (stf). But when changing stf,
it's convenient to use cache of stream formats.
This commit applies this idea.
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Takashi Sakamoto [Wed, 2 May 2018 10:16:45 +0000 (19:16 +0900)]
ALSA: dice: use extended protocol to detect available stream formats
TC Applied Technologies (TCAT) have added extension to DICE protocol. This
protocol extension is called as Extended Application Protocol, a.k.a. EAP.
In this protocol extension, units get additional 9 address spaces. One of
it is for current configuration. In this address space, a pair of router
and stream formats are exposed per mode of three sampling transmission
frequencies.
This commit adds support the protocol extension for address space of the
current configuration to generate cache of stream formats.
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Takashi Sakamoto [Wed, 2 May 2018 10:16:44 +0000 (19:16 +0900)]
ALSA: dice: add parameters of stream formats for models produced by Alesis
Alesis shipped some models with DICE ASICs. All of them just support
DICE original protocol and drivers can't retrieve all of available stream
formats without changing status of sampling transmission frequency
actually.
This commit puts some hard-coded parameters for the models. When detecting
the models, the corresponding parameters are copied as cache of stream
formats.
I note that each of pair of iO14/iO26 and MultiMix 8/12/16 has the same
model ID on their configuration ROM. The MultiMix 8/12/16 just support
one mode for sampling transmission frequency and ALSA dice driver already
handles them correctly. The iO14/iO26 support three modes and need
hard-coded parameters. To distinguish these two models, this commit let
the driver to retrieve current stream formats and compare it to known
parameters, then decide it.
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Takashi Sakamoto [Wed, 2 May 2018 10:16:43 +0000 (19:16 +0900)]
ALSA: dice: add parameters of stream formats for models produced by TC Electronic
TC Electronic shipped some models with DICE ASICs. All of them just support
DICE original protocol and drivers can't retrieve all of available stream
formats without changing status of sampling transmission frequency
actually.
This commit puts some hard-coded parameters for the models. When detecting
the models, the corresponding parameters are copied as cache of stream
formats.
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Takashi Sakamoto [Wed, 2 May 2018 10:16:42 +0000 (19:16 +0900)]
ALSA: dice: cache stream formats at current mode of sampling transmission frequency
In former commits, proxy structure get members for cache of stream
formats. This commit fills the cache with stream formats at current mode
of sampling transmission frequency.
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Takashi Sakamoto [Wed, 2 May 2018 10:16:41 +0000 (19:16 +0900)]
ALSA: dice: add proc node for stream formation
Products with DICE interface in market can support variable stream
formats for three levels of sampling transmission frequencies. To
record these formats, a proxy structure got several fields in former
commit.
This commit adds a proc node to output the stream formats for debugging
purpose.
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Takashi Sakamoto [Wed, 2 May 2018 10:16:40 +0000 (19:16 +0900)]
ALSA: dice: add 'firewire' directory for proc nodes
Unlike the other drivers in ALSA firewire stack, ALSA dice driver does't
create 'firewire' directory for proc nodes because it has 'dice' node
only. But this is inconvenient because I have a plan to add another proc
node to output available stream formats from cache.
This commit let the driver to create the directory and put 'dice' node
into it.
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Takashi Sakamoto [Wed, 2 May 2018 10:16:39 +0000 (19:16 +0900)]
ALSA: dice: add cache of stream formats
A previous commit
6f688268b3f4 ('ALSA: dice: purge generating channel
cache') purged cache of stream formats. DICE interface originally has
no feature to assist drivers to retrieve available formats for all of
supported sampling transmission frequencies, without changing the
frequency actually.
For later release of Dice ASICs such as TCD2210, Dice interface has
extended protocol and can support the feature. This assists drivers
to retrieve available stream formats.
This commit is a first step to regain the cache to generate PCM rules
for all of supported sampling transmission frequencies.
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Colin Ian King [Wed, 2 May 2018 13:59:40 +0000 (14:59 +0100)]
ALSA: sc6000: fix spelling mistake: "iomaped" -> "iomapped"
Trivial fix to spelling mistake in KERN_ERR error messages
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Takashi Sakamoto [Wed, 2 May 2018 13:48:16 +0000 (22:48 +0900)]
ALSA: hda/ca0132: fix build failure when a local macro is defined
DECLARE_TLV_DB_SCALE (alias of SNDRV_CTL_TLVD_DECLARE_DB_SCALE) is used but
tlv.h is not included. This causes build failure when local macro is
defined by comment-out.
This commit fixes the bug. At the same time, the alias macro is replaced
with a destination macro added at a commit
46e860f76804 ("ALSA: rename
TLV-related macros so that they're friendly to user applications")
Reported-by: Connor McAdams <conmanx360@gmail.com>
Fixes:
44f0c9782cc6 ('ALSA: hda/ca0132: Add tuning controls')
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Takashi Iwai [Wed, 2 May 2018 07:03:26 +0000 (09:03 +0200)]
ALSA: hda - Enforce CONFIG_SND_DYNAMIC_MINORS for HDMI/DP codec
The DP-MST support requires more PCM streams than usual, hence
CONFIG_SND_DYNAMIC_MINORS is almost mandatory. Currently the driver
just warns and continues even if streams are missing, but it doesn't
seem to enough convince users to switch to the modern setup.
This patch adds the enforced selection of CONFIG_SND_DYNAMIC_MINORS
from CONFIG_SND_HDA_CODEC_HDMI for covering that.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Takashi Iwai [Wed, 2 May 2018 06:48:46 +0000 (08:48 +0200)]
ALSA: pcm: Check PCM state at xfern compat ioctl
Since snd_pcm_ioctl_xfern_compat() has no PCM state check, it may go
further and hit the sanity check pcm_sanity_check() when the ioctl is
called right after open. It may eventually spew a kernel warning, as
triggered by syzbot, depending on kconfig.
The lack of PCM state check there was just an oversight. Although
it's no real crash, the spurious kernel warning is annoying, so let's
add the proper check.
Reported-by: syzbot+1dac3a4f6bc9c1c675d4@syzkaller.appspotmail.com
Cc: <stable@vger.kernel.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Takashi Iwai [Mon, 30 Apr 2018 08:06:48 +0000 (10:06 +0200)]
ALSA: aloop: Add missing cable lock to ctl API callbacks
Some control API callbacks in aloop driver are too lazy to take the
loopback->cable_lock and it results in possible races of cable access
while it's being freed. It eventually lead to a UAF, as reported by
fuzzer recently.
This patch covers such control API callbacks and add the proper mutex
locks.
Reported-by: DaeRyong Jeong <threeearcat@gmail.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Takashi Sakamoto [Sun, 29 Apr 2018 06:01:46 +0000 (15:01 +0900)]
ALSA: dice: fix kernel NULL pointer dereference due to invalid calculation for array index
At a commit
f91c9d7610a ('ALSA: firewire-lib: cache maximum length of
payload to reduce function calls'), maximum size of payload for tx
isochronous packet is cached to reduce the number of function calls.
This cache was programmed to updated at a first callback of ohci1394 IR
context. However, the maximum size is required to queueing packets before
starting the isochronous context.
As a result, the cached value is reused to queue packets in next time to
starting the isochronous context. Then the cache is updated in a first
callback of the isochronous context. This can cause kernel NULL pointer
dereference in a below call graph:
(sound/firewire/amdtp-stream.c)
amdtp_stream_start()
->queue_in_packet()
->queue_packet()
(drivers/firewire/core-iso.c)
->fw_iso_context_queue()
->struct fw_card_driver.queue_iso()
(drivers/firewire/ohci.c)
= ohci_queue_iso()
->queue_iso_packet_per_buffer()
buffer->pages[page]
The issued dereference occurs in a case that:
- target unit supports different stream formats for sampling transmission
frequency.
- maximum length of payload for tx stream in a first trial is bigger
than the length in a second trial.
In this case, correct number of pages are allocated for DMA and the 'pages'
array has enough elements, while index of the element is wrongly calculated
according to the old value of length of payload in a call of
'queue_in_packet()'. Then it causes the issue.
This commit fixes the critical bug. This affects all of drivers in ALSA
firewire stack in Linux kernel v4.12 or later.
[12665.302360] BUG: unable to handle kernel NULL pointer dereference at
0000000000000030
[12665.302415] IP: ohci_queue_iso+0x47c/0x800 [firewire_ohci]
[12665.302439] PGD 0
[12665.302440] P4D 0
[12665.302450]
[12665.302470] Oops: 0000 [#1] SMP PTI
[12665.302487] Modules linked in: ...
[12665.303096] CPU: 1 PID: 12760 Comm: jackd Tainted: P OE 4.13.0-38-generic #43-Ubuntu
[12665.303154] Hardware name: /DH77DF, BIOS KCH7710H.86A.0069.2012.0224.1825 02/24/2012
[12665.303215] task:
ffff9ce87da2ae80 task.stack:
ffffb5b8823d0000
[12665.303258] RIP: 0010:ohci_queue_iso+0x47c/0x800 [firewire_ohci]
[12665.303301] RSP: 0018:
ffffb5b8823d3ab8 EFLAGS:
00010086
[12665.303337] RAX:
ffff9ce4f4876930 RBX:
0000000000000008 RCX:
ffff9ce88a3955e0
[12665.303384] RDX:
0000000000000000 RSI:
0000000034877f00 RDI:
0000000000000000
[12665.303427] RBP:
ffffb5b8823d3b68 R08:
ffff9ce8ccb390a0 R09:
ffff9ce877639ab0
[12665.303475] R10:
0000000000000108 R11:
0000000000000000 R12:
0000000000000003
[12665.303513] R13:
0000000000000000 R14:
ffff9ce4f4876950 R15:
0000000000000000
[12665.303554] FS:
00007f2ec467f8c0(0000) GS:
ffff9ce8df280000(0000) knlGS:
0000000000000000
[12665.303600] CS: 0010 DS: 0000 ES: 0000 CR0:
0000000080050033
[12665.303633] CR2:
0000000000000030 CR3:
00000002dcf90004 CR4:
00000000000606e0
[12665.303674] Call Trace:
[12665.303698] fw_iso_context_queue+0x18/0x20 [firewire_core]
[12665.303735] queue_packet+0x88/0xe0 [snd_firewire_lib]
[12665.303770] amdtp_stream_start+0x19b/0x270 [snd_firewire_lib]
[12665.303811] start_streams+0x276/0x3c0 [snd_dice]
[12665.303840] snd_dice_stream_start_duplex+0x1bf/0x480 [snd_dice]
[12665.303882] ? vma_gap_callbacks_rotate+0x1e/0x30
[12665.303914] ? __rb_insert_augmented+0xab/0x240
[12665.303936] capture_prepare+0x3c/0x70 [snd_dice]
[12665.303961] snd_pcm_do_prepare+0x1d/0x30 [snd_pcm]
[12665.303985] snd_pcm_action_single+0x3b/0x90 [snd_pcm]
[12665.304009] snd_pcm_action_nonatomic+0x68/0x70 [snd_pcm]
[12665.304035] snd_pcm_prepare+0x68/0x90 [snd_pcm]
[12665.304058] snd_pcm_common_ioctl1+0x4c0/0x940 [snd_pcm]
[12665.304083] snd_pcm_capture_ioctl1+0x19b/0x250 [snd_pcm]
[12665.304108] snd_pcm_capture_ioctl+0x27/0x40 [snd_pcm]
[12665.304131] do_vfs_ioctl+0xa8/0x630
[12665.304148] ? entry_SYSCALL_64_after_hwframe+0xe9/0x139
[12665.304172] ? entry_SYSCALL_64_after_hwframe+0xe2/0x139
[12665.304195] ? entry_SYSCALL_64_after_hwframe+0xdb/0x139
[12665.304218] ? entry_SYSCALL_64_after_hwframe+0xd4/0x139
[12665.304242] ? entry_SYSCALL_64_after_hwframe+0xcd/0x139
[12665.304265] ? entry_SYSCALL_64_after_hwframe+0xc6/0x139
[12665.304288] ? entry_SYSCALL_64_after_hwframe+0xbf/0x139
[12665.304312] ? entry_SYSCALL_64_after_hwframe+0xb8/0x139
[12665.304335] ? entry_SYSCALL_64_after_hwframe+0xb1/0x139
[12665.304358] SyS_ioctl+0x79/0x90
[12665.304374] ? entry_SYSCALL_64_after_hwframe+0x72/0x139
[12665.304397] entry_SYSCALL_64_fastpath+0x24/0xab
[12665.304417] RIP: 0033:0x7f2ec3750ef7
[12665.304433] RSP: 002b:
00007fff99e31388 EFLAGS:
00000246 ORIG_RAX:
0000000000000010
[12665.304465] RAX:
ffffffffffffffda RBX:
00007fff99e312f0 RCX:
00007f2ec3750ef7
[12665.304494] RDX:
0000000000000000 RSI:
0000000000004140 RDI:
0000000000000007
[12665.304522] RBP:
0000556ebc63fd60 R08:
0000556ebc640560 R09:
0000000000000000
[12665.304553] R10:
0000000000000001 R11:
0000000000000246 R12:
0000556ebc63fcf0
[12665.304584] R13:
0000000000000000 R14:
0000000000000007 R15:
0000000000000000
[12665.304612] Code: 01 00 00 44 89 eb 45 31 ed 45 31 db 66 41 89 1e 66 41 89 5e 0c 66 45 89 5e 0e 49 8b 49 08 49 63 d4 4d 85 c0 49 63 ff 48 8b 14 d1 <48> 8b 72 30 41 8d 14 37 41 89 56 04 48 63 d3 0f 84 ce 00 00 00
[12665.304713] RIP: ohci_queue_iso+0x47c/0x800 [firewire_ohci] RSP:
ffffb5b8823d3ab8
[12665.304743] CR2:
0000000000000030
[12665.317701] ---[ end trace
9d55b056dd52a19f ]---
Fixes:
f91c9d7610a ('ALSA: firewire-lib: cache maximum length of payload to reduce function calls')
Cc: <stable@vger.kernel.org> # v4.12+
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Colin Ian King [Fri, 27 Apr 2018 19:02:45 +0000 (20:02 +0100)]
ALSA: cs46xx: fix spelling mistake: "amplifer" -> "amplifier"
Trivial fix to spelling mistake in module parameter description text
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Takashi Iwai [Thu, 26 Apr 2018 07:17:45 +0000 (09:17 +0200)]
ALSA: seq: Fix races at MIDI encoding in snd_virmidi_output_trigger()
The sequencer virmidi code has an open race at its output trigger
callback: namely, virmidi keeps only one event packet for processing
while it doesn't protect for concurrent output trigger calls.
snd_virmidi_output_trigger() tries to process the previously
unfinished event before starting encoding the given MIDI stream, but
this is done without any lock. Meanwhile, if another rawmidi stream
starts the output trigger, this proceeds further, and overwrites the
event package that is being processed in another thread. This
eventually corrupts and may lead to the invalid memory access if the
event type is like SYSEX.
The fix is just to move the spinlock to cover both the pending event
and the new stream.
The bug was spotted by a new fuzzer, RaceFuzzer.
BugLink: http://lkml.kernel.org/r/20180426045223.GA15307@dragonet.kaist.ac.kr
Reported-by: DaeRyong Jeong <threeearcat@gmail.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Takashi Iwai [Fri, 27 Apr 2018 15:17:35 +0000 (17:17 +0200)]
ALSA: hda - Fix incorrect usage of IS_REACHABLE()
The commit
c469652bb5e8 ("ALSA: hda - Use IS_REACHABLE() for
dependency on input") simplified the dependencies with IS_REACHABLE()
macro, but it broke due to its incorrect usage: it should have been
IS_REACHABLE(CONFIG_INPUT) instead of IS_REACHABLE(INPUT).
Fixes:
c469652bb5e8 ("ALSA: hda - Use IS_REACHABLE() for dependency on input")
Cc: <stable@vger.kernel.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Takashi Sakamoto [Thu, 26 Apr 2018 13:00:29 +0000 (22:00 +0900)]
ALSA: dice: fix error path to destroy initialized stream data
In error path of snd_dice_stream_init_duplex(), stream data for incoming
packet can be left to be initialized.
This commit fixes it.
Fixes:
436b5abe2224 ('ALSA: dice: handle whole available isochronous streams')
Cc: <stable@vger.kernel.org> # v4.6+
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Takashi Iwai [Wed, 25 Apr 2018 08:41:08 +0000 (10:41 +0200)]
Merge branch 'for-linus' into for-next
Back-merge 4.17-rc3 fixes for further development.
This will bump the base to 4.17-rc2, too.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Takashi Iwai [Wed, 25 Apr 2018 14:19:13 +0000 (16:19 +0200)]
ALSA: hda - Skip jack and others for non-existing PCM streams
When CONFIG_SND_DYNAMIC_MINORS isn't set, there are only limited
number of devices available, and HD-audio, especially with HDMI/DP
codec, will fail to create more than two devices.
The driver warns about the lack of such devices and skips the PCM
device creations, but the HDMI driver still tries to create the
corresponding JACK, SPDIF and ELD controls even for the non-existing
PCM substreams. This results in confusion on user-space, and even may
break the operation.
Similarly, Intel HDMI/DP codec builds the ELD notification from i915
graphics driver, and this may be broken if a notification is sent for
the non-existing PCM stream.
This patch adds the check of the existence of the assigned PCM
substream in the both scenarios above, and skips the further operation
if the PCM substream is not assigned.
Fixes:
9152085defb6 ("ALSA: hda - add DP MST audio support")
Cc: <stable@vger.kernel.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Takashi Iwai [Wed, 25 Apr 2018 10:22:20 +0000 (12:22 +0200)]
Merge tag 'asoc-fix-4.17-rc2' of https://git./linux/kernel/git/broonie/sound into for-linus
ASoC: Fixes for v4.17
A small batch of fixes collected since the merge window, none of which
are particularly large or remarkable. They've all been cooking in -next
for a while.
Kailang Yang [Wed, 25 Apr 2018 09:07:27 +0000 (17:07 +0800)]
ALSA: hda/realtek - change the location for one of two front mics
On this Lenovo ThinkCentre machine. There are two front mics,
we change the location for one of them.
Relation:
f33f79f3d0e5 ("ALSA: hda/realtek - change the location for
one of two front microphones")
Signed-off-by: Kailang Yang <kailang@realtek.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Takashi Iwai [Tue, 24 Apr 2018 06:04:41 +0000 (08:04 +0200)]
ALSA: rme9652: Hardening for potential Spectre v1
As recently Smatch suggested, one place in RME9652 driver may expand
the array directly from the user-space value with speculation:
sound/pci/rme9652/rme9652.c:2074 snd_rme9652_channel_info() warn: potential spectre issue 'rme9652->channel_map' (local cap)
This patch puts array_index_nospec() for hardening against it.
BugLink: https://marc.info/?l=linux-kernel&m=152411496503418&w=2
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Takashi Iwai [Tue, 24 Apr 2018 06:03:14 +0000 (08:03 +0200)]
ALSA: hdspm: Hardening for potential Spectre v1
As recently Smatch suggested, a couple of places in HDSP MADI driver
may expand the array directly from the user-space value with
speculation:
sound/pci/rme9652/hdspm.c:5717 snd_hdspm_channel_info() warn: potential spectre issue 'hdspm->channel_map_out' (local cap)
sound/pci/rme9652/hdspm.c:5734 snd_hdspm_channel_info() warn: potential spectre issue 'hdspm->channel_map_in' (local cap)
This patch puts array_index_nospec() for hardening against them.
BugLink: https://marc.info/?l=linux-kernel&m=152411496503418&w=2
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Takashi Iwai [Tue, 24 Apr 2018 06:01:48 +0000 (08:01 +0200)]
ALSA: asihpi: Hardening for potential Spectre v1
As recently Smatch suggested, a couple of places in ASIHPI driver may
expand the array directly from the user-space value with speculation:
sound/pci/asihpi/hpimsginit.c:70 hpi_init_response() warn: potential spectre issue 'res_size' (local cap)
sound/pci/asihpi/hpioctl.c:189 asihpi_hpi_ioctl() warn: potential spectre issue 'adapters'
This patch puts array_index_nospec() for hardening against them.
BugLink: https://marc.info/?l=linux-kernel&m=152411496503418&w=2
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>