Currently, when asynchronous transactions finish in error state and
retries, work scheduling and work running also continues. This
should be canceled at fatal error because it can cause endless loop.
This commit enables to cancel transferring MIDI messages when transactions
encounter fatal errors. This is achieved by setting error state.
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
else if (!rcode_is_permanent_error(rcode))
/* To start next transaction immediately for recovery. */
port->next_ktime = ktime_set(0, 0);
else if (!rcode_is_permanent_error(rcode))
/* To start next transaction immediately for recovery. */
port->next_ktime = ktime_set(0, 0);
+ else
+ /* Don't continue processing. */
+ port->error = true;
int generation;
int type;
int generation;
int type;
- /* Under transacting. */
- if (!port->idling)
+ /* Under transacting or error state. */
+ if (!port->idling || port->error)
return;
/* Nothing to do. */
return;
/* Nothing to do. */
if (port->consume_bytes == 0) {
port->next_ktime = ktime_set(0, 0);
schedule_work(&port->work);
if (port->consume_bytes == 0) {
port->next_ktime = ktime_set(0, 0);
schedule_work(&port->work);
+ } else {
+ /* Fatal error. */
+ port->error = true;
port->fill = fill;
port->idling = true;
port->next_ktime = ktime_set(0, 0);
port->fill = fill;
port->idling = true;
port->next_ktime = ktime_set(0, 0);
INIT_WORK(&port->work, midi_port_work);
INIT_WORK(&port->work, midi_port_work);
struct work_struct work;
bool idling;
ktime_t next_ktime;
struct work_struct work;
bool idling;
ktime_t next_ktime;
u64 addr;
struct fw_transaction transaction;
u64 addr;
struct fw_transaction transaction;
snd_fw_async_midi_port_run(struct snd_fw_async_midi_port *port,
struct snd_rawmidi_substream *substream)
{
snd_fw_async_midi_port_run(struct snd_fw_async_midi_port *port,
struct snd_rawmidi_substream *substream)
{
- port->substream = substream;
- schedule_work(&port->work);
+ if (!port->error) {
+ port->substream = substream;
+ schedule_work(&port->work);
+ }
snd_fw_async_midi_port_finish(struct snd_fw_async_midi_port *port)
{
port->substream = NULL;
snd_fw_async_midi_port_finish(struct snd_fw_async_midi_port *port)
{
port->substream = NULL;