1
0
Fork 0
Commit Graph

25 Commits (244b7f4324895e7c796cc94e8a8f70288ed20bdc)

Author SHA1 Message Date
Takashi Iwai 4d0e677523 ALSA: line6: Fix -EBUSY error during active monitoring
When a monitor stream is active, the next PCM stream access results in
EBUSY error because of the check in line6_stream_start().  Fix this by
just skipping the submission of pending URBs when the stream is
already running instead.

Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=101431
Cc: <stable@vger.kernel.org> # v4.0+
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-07-14 15:19:37 +02:00
Takashi Iwai 247d95ee6d ALSA: line6: Handle error from line6_pcm_acquire()
Tested-by: Chris Rorvick <chris@rorvick.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-01-28 07:22:57 +01:00
Takashi Iwai 2954f914f2 ALSA: line6: Make common PCM pointer callback
Both playback and capture callbacks are identical, so let's merge
them.

Tested-by: Chris Rorvick <chris@rorvick.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-01-28 07:22:45 +01:00
Takashi Iwai 63e20df1e5 ALSA: line6: Reorganize PCM stream handling
The current code deals with the stream start / stop solely via
line6_pcm_acquire() and line6_pcm_release().  This was (supposedly)
intended to avoid the races, but it doesn't work as expected.  The
concurrent acquire and release calls can be performed without proper
protections, thus this might result in memory corruption.
Furthermore, we can't take a mutex to protect the whole function
because it can be called from the PCM trigger callback that is an
atomic context.  Also spinlock isn't appropriate because the function
allocates with kmalloc with GFP_KERNEL.  That is, these function just
lead to singular problems.

This is an attempt to reduce the existing races.  First off, separate
both the stream buffer management and the stream URB management.  The
former is protected via a newly introduced state_mutex while the
latter is protected via each line6_pcm_stream lock.

Secondly, the stream state are now managed in opened and running bit
flags of each line6_pcm_stream.  Not only this a bit clearer than
previous combined bit flags, this also gives a better abstraction.
These rewrites allows us to make common hw_params and hw_free
callbacks for both playback and capture directions.

For the monitor and impulse operations, still line6_pcm_acquire() and
line6_pcm_release() are used.  They call internally the corresponding
functions for both playback and capture streams with proper lock or
mutex.  Unlike the previous versions, these function don't take the
bit masks but the only single type value.  Also they are supposed to
be applied only as duplex operations.

Tested-by: Chris Rorvick <chris@rorvick.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-01-28 07:22:36 +01:00
Takashi Iwai f2bb614bb6 ALSA: line6: Clear prev_fbuf and prev_fsize properly
Clearing prev_fsize in line6_pcm_acquire() is pretty racy.
This can be called at any time while the stream is being played.
Rather better to clear prev_fbuf and prev_fsize at the proper place
like the stream stop for capture, and just after copying the monitor /
impulse data inside the spinlock.

Tested-by: Chris Rorvick <chris@rorvick.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-01-28 07:22:30 +01:00
Takashi Iwai e90576c595 ALSA: line6: Consolidate PCM stream buffer allocation and free
The PCM stream buffer allocation and free are identical for both
playback and capture streams.  Provide single helper functions.
These are used only in pcm.c, thus they can be even static.

Tested-by: Chris Rorvick <chris@rorvick.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-01-28 07:21:39 +01:00
Takashi Iwai ccaac9ed79 ALSA: line6: Use dev_err()
This is the last remaining snd_printk() usage in this driver.

Tested-by: Chris Rorvick <chris@rorvick.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-01-28 07:21:33 +01:00
Takashi Iwai d8131e67f0 ALSA: line6: Consolidate URB unlink and sync helpers
The codes to unlink and sync URBs are identical for both playback and
capture streams.  Consolidate to single helper functions.

Tested-by: Chris Rorvick <chris@rorvick.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-01-28 07:21:27 +01:00
Takashi Iwai ad0119abe2 ALSA: line6: Rearrange PCM structure
Introduce a new line6_pcm_stream structure and group individual
fields of snd_line6_pcm struct to playback and capture groups.

This patch itself just does rename and nothing else.  More
meaningful cleanups based on these fields shuffling will follow.

Tested-by: Chris Rorvick <chris@rorvick.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-01-28 07:21:18 +01:00
Takashi Iwai 9fb754b79e ALSA: line6: Use incremental loop
Using a decremental loop without particular reasons worsens the
readability a lot.  Use incremental loops instead.

Tested-by: Chris Rorvick <chris@rorvick.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-01-28 07:21:06 +01:00
Takashi Iwai f2a76225b9 ALSA: line6: Drop superfluous spinlock for trigger
The trigger callback is already spinlocked, so we need no more lock
here (even for the linked substreams).  Let's drop it.

Tested-by: Chris Rorvick <chris@rorvick.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-01-28 07:21:00 +01:00
Takashi Iwai 5343ecf4e5 ALSA: line6: Fix the error recovery in line6_pcm_acquire()
line6_pcm_acquire() tries to restore the newly obtained resources at
the error path.  But some flags aren't recorded and released properly
when the corresponding buffer is already present.  These bits have to
be cleared in the error recovery, too.

Also, "flags_final" can be initialized to zero since we pass only the
subset of "channels" bits.

Tested-by: Chris Rorvick <chris@rorvick.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-01-28 07:20:53 +01:00
Takashi Iwai 6aa7f8ef29 ALSA: line6: Use logical OR
Fixed a few places using bits OR wrongly for condition checks.

Tested-by: Chris Rorvick <chris@rorvick.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-01-28 07:20:46 +01:00
Takashi Iwai eab22e4053 ALSA: line6: Fix missing error handling in line6_pcm_acquire()
Tested-by: Chris Rorvick <chris@rorvick.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-01-28 07:20:40 +01:00
Chris Rorvick c078a4aac2 ALSA: line6: Remove driver version from header comment
The driver version string was removed in an ealier commit for being
useless.  These are equally useless.

Signed-off-by: Chris Rorvick <chris@rorvick.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-01-20 09:52:40 +01:00
Chris Rorvick c6fffce92e ALSA: line6: Refer to manufacturer as "Line 6"
The correct spelling includes the space.  Fix this in strings and
comments that refer to the manufacturer.

Signed-off-by: Chris Rorvick <chris@rorvick.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-01-20 09:52:30 +01:00
Takashi Iwai 5a4753112a ALSA: line6: Sync PCM stop at disconnect
Call line6_pcm_disconnect() at disconnect to make sure that all URBs
are cleared.  Also reduce the superfluous snd_pcm_stop() calls from
the function (and remove the unused function) since the streams are
guaranteed to be stopped at this point via snd_card_disconnect().

Tested-by: Chris Rorvick <chris@rorvick.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-01-20 08:18:44 +01:00
Takashi Iwai 10e3a023c9 ALSA: line6: Drop MISSING_CASE macro
Such a debug is needed in the core code, not in each lowlevel driver.

Tested-by: Chris Rorvick <chris@rorvick.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-01-20 08:18:20 +01:00
Takashi Iwai 85a9339bec ALSA: line6: Reorganize card resource handling
This is a fairly big rewrite regarding the card resource management in
line6 drivers:

- The card creation is moved into line6_probe().  This adds the global
  destructor to private_free, so that each driver doesn't have to call
  it any longer.

- The USB disconnect callback handles the card release, thus each
  driver needs to concentrate on only its own resources.  No need to
  snd_card_*() call in the destructor.

- Fix the potential stall in disconnection by removing
  snd_card_free().   It's replaced with snd_card_free_when_closed()
  for asynchronous release.

- The only remaining operation for the card in each driver is the call
  of snd_card_register().  All the rest are dealt in the common module
  by itself.

- These ended up with removal of audio.[ch] as a result of a reduction
  of one layer.  Each driver just needs to call line6_probe().

Tested-by: Chris Rorvick <chris@rorvick.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-01-20 08:17:16 +01:00
Takashi Iwai 84ac9bb12e ALSA: line6: Drop superfluous irqsave/irqrestore in PCM trigger callback
The PCM trigger callback is guaranteed to be called already in
spinlock / irq-disabled context.

Tested-by: Chris Rorvick <chris@rorvick.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-01-20 08:16:18 +01:00
Takashi Iwai 7d70c81cca ALSA: line6: Don't handle PCM trigger for other cards
Otherwise it oopses.

Tested-by: Chris Rorvick <chris@rorvick.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-01-20 08:16:10 +01:00
Takashi Iwai b45a7c5654 ALSA: line6: Drop superfluous snd_device for PCM
Instead of handling the card-specific resource in snd_device, attach
it into pcm->private_data and release it directly in private_free.
This simplifies the code and structure.

Tested-by: Chris Rorvick <chris@rorvick.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-01-20 08:14:55 +01:00
Takashi Iwai 075587b723 ALSA: line6: Handle impulse response via control API
Instead of sysfs and the conditional build with Kconfig, implement the
handling of the impulse response controls via control API, and always
enable the build.  Two new controls, "Impulse Response Volume" and
"Impulse Response Period" are added as a replacement for the former
sysfs files.

Tested-by: Chris Rorvick <chris@rorvick.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-01-20 08:14:36 +01:00
Takashi Iwai ccddbe4a99 ALSA: line6: Split to each driver
Split to each individual driver for POD, PODHD, TonePort and Variax
with a core LINE6 helper module.  The new modules follow the standard
ALSA naming rule with snd prefix: snd-usb-pod, snd-usb-podhd,
snd-usb-toneport and snd-usb-variax, together with the corresponding
CONFIG_SND_USB_* Kconfig items.

Tested-by: Chris Rorvick <chris@rorvick.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-01-20 08:14:17 +01:00
Takashi Iwai 61864d844c ALSA: move line6 usb driver into sound/usb
Promote line6 driver from staging to sound/usb/line6 directory, and
maintain through sound subsystem tree.

This commit just moves the code and adapts Makefile / Kconfig.
The further renames and misc cleanups will follow.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-01-12 22:29:57 +01:00