History log of /linux-master/sound/firewire/tascam/tascam-transaction.c
Revision Date Author Comments
# 9f65df9c 11-Jan-2021 Geert Uytterhoeven <geert+renesas@glider.be>

ALSA: firewire-tascam: Fix integer overflow in midi_port_work()

As snd_fw_async_midi_port.consume_bytes is unsigned int, and
NSEC_PER_SEC is 1000000000L, the second multiplication in

port->consume_bytes * 8 * NSEC_PER_SEC / 31250

always overflows on 32-bit platforms, truncating the result. Fix this
by precalculating "NSEC_PER_SEC / 31250", which is an integer constant.

Note that this assumes port->consume_bytes <= 16777.

Fixes: 531f471834227d03 ("ALSA: firewire-lib/firewire-tascam: localize async midi port")
Reviewed-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Link: https://lore.kernel.org/r/20210111130251.361335-3-geert+renesas@glider.be
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# da607e19 29-May-2019 Thomas Gleixner <tglx@linutronix.de>

treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 345

Based on 1 normalized pattern(s):

licensed under the terms of the gnu general public license version 2

extracted by the scancode license scanner the SPDX license identifier

GPL-2.0-only

has been chosen to replace the boilerplate/reference in 88 file(s).

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Alexios Zavras <alexios.zavras@intel.com>
Reviewed-by: Allison Randal <allison@lohutok.net>
Cc: linux-spdx@vger.kernel.org
Link: https://lkml.kernel.org/r/20190530000437.521539229@linutronix.de
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 6aa7de05 23-Oct-2017 Mark Rutland <mark.rutland@arm.com>

locking/atomics: COCCINELLE/treewide: Convert trivial ACCESS_ONCE() patterns to READ_ONCE()/WRITE_ONCE()

Please do not apply this to mainline directly, instead please re-run the
coccinelle script shown below and apply its output.

For several reasons, it is desirable to use {READ,WRITE}_ONCE() in
preference to ACCESS_ONCE(), and new code is expected to use one of the
former. So far, there's been no reason to change most existing uses of
ACCESS_ONCE(), as these aren't harmful, and changing them results in
churn.

However, for some features, the read/write distinction is critical to
correct operation. To distinguish these cases, separate read/write
accessors must be used. This patch migrates (most) remaining
ACCESS_ONCE() instances to {READ,WRITE}_ONCE(), using the following
coccinelle script:

----
// Convert trivial ACCESS_ONCE() uses to equivalent READ_ONCE() and
// WRITE_ONCE()

// $ make coccicheck COCCI=/home/mark/once.cocci SPFLAGS="--include-headers" MODE=patch

virtual patch

@ depends on patch @
expression E1, E2;
@@

- ACCESS_ONCE(E1) = E2
+ WRITE_ONCE(E1, E2)

@ depends on patch @
expression E;
@@

- ACCESS_ONCE(E)
+ READ_ONCE(E)
----

Signed-off-by: Mark Rutland <mark.rutland@arm.com>
Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: davem@davemloft.net
Cc: linux-arch@vger.kernel.org
Cc: mpe@ellerman.id.au
Cc: shuah@kernel.org
Cc: snitzer@redhat.com
Cc: thor.thayer@linux.intel.com
Cc: tj@kernel.org
Cc: viro@zeniv.linux.org.uk
Cc: will.deacon@arm.com
Link: http://lkml.kernel.org/r/1508792849-3115-19-git-send-email-paulmck@linux.vnet.ibm.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>


# 1f94205d 14-Apr-2017 Takashi Sakamoto <o-takashi@sakamocchi.jp>

ALSA: firewire-tascam: move message parameters for async midi port

Units on TASCAM FireWire series handle MIDI messages with support for
running status. Drivers for the series should remember current running
status and transfer valid MIDI messages. For this purpose, current
ALSA driver for the series has some members in its top-level structure.
This is due to better abstraction of async midi port. Nowadays, the
abstraction was localized just for the driver.

This commit moves the members to structure for async midi port.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 3e7dc65c 14-Apr-2017 Takashi Sakamoto <o-takashi@sakamocchi.jp>

ALSA: firewire-tascam: initialize parameters at open of rawmidi character devices

In current design of ALSA driver for TASCAM FireWire series, initialization
of members in asymc midi port structure is done at device probing. Some of
the members should be initialized every time to use rawmidi devices because
they're changed in sequence of transmission for MIDI messages.

This commit adds a new function to initialize them. Invariant parameters
during object lifetime are kept as is.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 98a00d36 14-Apr-2017 Takashi Sakamoto <o-takashi@sakamocchi.jp>

ALSA: firewire-tascam: use fixed-length array for message cache to async midi port

ALSA driver for TASCAM FireWire series internally allocates 4 byte buffer
for asynchronous transaction to transfer MIDI messages. However, the buffer
can be allocated with memory object of parent structure.

This commit adds 4 byte array as a member of the structure and obsoletes
the redundant allocation. This is deallocated with memory object of parent
structure.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 27badc4c 14-Apr-2017 Takashi Sakamoto <o-takashi@sakamocchi.jp>

ALSA: firewire-tascam: use the same address for asynchronous transaction for MIDI message

Units on TASCAM FireWire series receive MIDI messages by asynchronous
transactions on IEEE 1394 bus. Although the transaction is sent to a
certain register, current ALSA driver for this series has a redundant design.

This commit use the same address for the transaction.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 38d58261 14-Apr-2017 Takashi Sakamoto <o-takashi@sakamocchi.jp>

ALSA: firewire-tascam: send fixed-length transaction for async midi port

TASCAM FireWire series uses asynchronous transactions with fixed length
payload for MIDI messaging. On the other hand, ALSA driver for the series
has a redundant design to handle different length of payload.

This commit removes the redundant abstraction.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 9bae2150 14-Apr-2017 Takashi Sakamoto <o-takashi@sakamocchi.jp>

ALSA: firewire-tascam: remove callback function from async midi port

As a result of localization of async midi port, ALSA driver for TASCAM
FireWire series can call helper function directly instead of callback
registration.

This commit removes the redundant design.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 531f4718 14-Apr-2017 Takashi Sakamoto <o-takashi@sakamocchi.jp>

ALSA: firewire-lib/firewire-tascam: localize async midi port

In Linux kernel 4.4, firewire-lib got a feature called as 'async midi port'
for transmission of MIDI message via IEEE 1394 asynchronous communication,
however actual consumer of this feature is ALSA driver for TASCAM FireWire
series only. When adding this feature, I assumed that ALSA driver for
Digi00x might also be a consumer, actually it's not.

This commit moves the feature from firewire-lib to firewire-tascam module.
Two minor kernel APIs are removed.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 5d2560a4 04-Feb-2016 Takashi Sakamoto <o-takashi@sakamocchi.jp>

ALSA: firewire-tascam: fix NULL pointer dereference when model identification fails

When unsupported models are connected, snd-firewire-tascam module causes
NULL pointer dereference in fw_core_remove_address_handler() (due to
list_del_rcu()).

This commit prevents this bug.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# f937b43d 20-Oct-2015 Takashi Sakamoto <o-takashi@sakamocchi.jp>

ALSA: firewire-tascam: clear extra MIDI bytes in an asynchronous transaction

When MIDI buffer stores two or more MIDI messages, TASCAM driver
transfers asynchronous transactions including one MIDI message and
extra bytes from second MIDI message.

This commit fixes this bug by clearing needless bytes in the buffer. The
consumed bytes are already calculated correctly, thus the sequence of
transactions is already correct.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 123990e9 20-Oct-2015 Takashi Sakamoto <o-takashi@sakamocchi.jp>

ALSA: firewire-tascam: fix loop condition with some readable variables

In transactions for MIDI messages, the first byte is used for label and
the rest is for MIDI bytes. In current code, these are handled correctly,
while there's a small mistake for loop condition to include meaningless
statement.

This commit adds two local variables for them and improve the loop
condition.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# b7ab614f 20-Oct-2015 Takashi Sakamoto <o-takashi@sakamocchi.jp>

ALSA: firewire-tascam: use better name for local variables to describe their intension

In the callback function of asynchronous MIDI port, the intension of some
local variables are not clear.

This commit improves them. The 'len' variable is used to calculate the
number of MIDI bytes including in the transaction. The 'consume' variable
is used to return the actual number of consumed bytes in ALSA MIDI buffer.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 516a3061 20-Oct-2015 Takashi Sakamoto <o-takashi@sakamocchi.jp>

ALSA: firewire-tascam: change type of valiables according to function prototype

In the callback function of asynchronous MIDI port, some local variables
are declared 'unsigned int', while they're assigned to int value of return
from snd_rawmidi_transmit_peek().

This commit fixes the type.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 9f9c5617 20-Oct-2015 Takashi Sakamoto <o-takashi@sakamocchi.jp>

ALSA: firewire-tascam: remove buffer initialization in driver side

The given buffer to callback function is cleared in caller side.

This commit removes buffer initialization in callee side.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 72409705 15-Oct-2015 Dan Carpenter <dan.carpenter@oracle.com>

ALSA: firewire-tascam: off by one in handle_midi_tx()

My static checker complains because tscm->spec->midi_capture_ports is
either 2 or 4 but the tscm->tx_midi_substreams[] array has 4 elements so
this is possibly off by one. I have looked at the code and I think it
should be >= instead of > as well.

Fixes: 107cc0129a68 ('ALSA: firewire-tascam: add support for incoming MIDI messages by asynchronous transaction')
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 69ec98d7 15-Oct-2015 Dan Carpenter <dan.carpenter@oracle.com>

ALSA: firewire-tascam: fix an LED bug

We recently tried to add some new code to support turning the LED on and
off but the code in snd_tscm_transaction_reregister() is unreachable.

Fixes: e65e2cb99e44 ('ALSA: firewire-tascam: Turn on/off FireWire LED')
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# e65e2cb9 12-Oct-2015 Takashi Sakamoto <o-takashi@sakamocchi.jp>

ALSA: firewire-tascam: Turn on/off FireWire LED

TASCAM FireWire series has some LEDs on its surface. These LEDs can be
turned on/off by receiving asynchronous transactions to a certain
address. One of the LEDs is labels as 'FireWire'. It's better to light it
up when this driver starts to work. Besides, the LED for 'FireWire' is
turned off at bus reset.

This commit implements this idea.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 3beab0f8 12-Oct-2015 Takashi Sakamoto <o-takashi@sakamocchi.jp>

ALSA: firewire-tascam: add support for outgoing MIDI messages by asynchronous transaction

TASCAM FireWire series use asynchronous transaction to receive MIDI
messages. The transaction should be sent to a certain address.

This commit supports the outgoing MIDI messages. The messages in the
transaction includes some quirks:
* One MIDI message is transferred in one quadlet transaction, except for
system exclusives.
* MIDI running status is not allowed, thus transactions always include
status byte.
* The basic data format is the same as transferring MIDI messages
supported in previous commit.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 107cc012 12-Oct-2015 Takashi Sakamoto <o-takashi@sakamocchi.jp>

ALSA: firewire-tascam: add support for incoming MIDI messages by asynchronous transaction

TASCAM FireWire series use asynchronous transaction to transfer MIDI
messages. The transaction is sent to a registered address.

This commit supports the incoming MIDI messages. The messages in the
transaction include some quirks:
* Two quadlets are used for one MIDI message and one timestamp.
* Usually, the first byte of the first quadlet includes MIDI port and MSB
4 bit of MIDI status. For system exclusive message, the first byte
includes MIDI port and 0x04, or 0x07 in the end of the message.
* The rest of the first quadlet includes MIDI bytes up to 3.
* Several set of MIDI messages and timestamp can be transferred in one
block transaction, up to 8 sets.

I note that TASCAM FireWire series ignores ID bytes of system exclusive
message. When receiving system exclusive messages with ID bytes on physical
MIDI bus, the series transfers the messages without ID bytes on IEEE 1394
bus, and vice versa.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>