Skip to contentSkip to conversation

snd_usb_caiaq bug?

DISCUSSION Marco Santamaria 4 participants 21 messages Jan 4, 2009 – Jan 12, 2009

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

Hi,

it's about one year that I'm using my Native Instruments Audio Kontrol 1 (USB2 audio/MIDI interface) only with audio applications and it has been working well so far.
Now I'm trying to use it with Rosegarden (MIDI) and, as soon as I start Rosegarden, JACK crashes, the process jackd becomes "uninterruptible" and with the command dmesg I find the following new lines

[ 1935.173876] BUG: unable to handle kernel NULL pointer dereference at
virtual address 00000044
[ 1935.173885] printing eip: f8a5f6fd *pde = 00000000
[ 1935.173891] Oops: 0000 [#1] PREEMPT SMP
[ 1935.173896] Modules linked in: isofs udf ipv6 af_packet i915 drm rfcomm

l2cap bluetooth ppdev acpi_cpufreq cpufreq_ondemand cpufreq_conservative cpufreq_stats freq_table cpufreq_userspace cpufreq_powersave dock container sbs sbshc iptable_filter ip_tables x_tables sbp2 parport_pc lp parport snd_hda_intel snd_usb_caiaq snd_hwdep snd_pcm_oss snd_mixer_oss arc4 snd_seq_oss snd_pcm ecb blkcipher snd_seq_midi snd_page_alloc joydev snd_rawmidi snd_seq_midi_event snd_seq iwl3945 sdhci serio_raw mmc_core iwlwifi_mac80211 video output cfg80211 battery led_class ac snd_timer snd_seq_device wmi_acer button snd evdev dcdbas iTCO_wdt iTCO_vendor_support intel_agp shpchp pci_hotplug pcspkr soundcore agpgart psmouse ext3 jbd mbcache sg sr_mod cdrom sd_mod b44 ata_generic ssb mii ohci1394 ieee1394 ata_piix pata_acpi libata scsi_mod ehci_hcd uhci_hcd usbcore thermal processor fan fuse

[ 1935.173964]
[ 1935.173967] Pid: 1421, comm: IRQ-18 Not tainted (2.6.24-19-rt #1)
[ 1935.173970] EIP: 0060:[<f8a5f6fd>] EFLAGS: 00010292 CPU: 1
[ 1935.173979] EIP is at snd_rawmidi_transmit_peek+0x1d/0x100 [snd_rawmidi]
[ 1935.173982] EAX: 00000000 EBX: f7106264 ECX: 0000003d EDX: f7106407
[ 1935.173985] ESI: ffffffea EDI: 00000000 EBP: f7106407 ESP: df85be38
[ 1935.173988]  DS: 007b ES: 007b FS: 00d8 GS: 0000 SS: 0068
preempt:00000001
[ 1935.173991] Process IRQ-18 (pid: 1421, ti=df85a000 task=f7d45320
task.ti=df85a000)
[ 1935.173993] Stack: 0000003d 00000000 f7106264 00000000 00000000 df83fc00
f8b8cc09 00000000
[ 1935.174000]        f7106264 f710630c 00000000 df83fc00 df83fc00 f710630c
f888c888 00000008
[ 1935.174007]        df83fd08 00000000 f710630c f8870770 f728a0c0 f728a0c0
ffffff8d f721e180
[ 1935.174014] Call Trace:
[ 1935.174021]  [<f8b8cc09>] snd_usb_caiaq_midi_send+0x29/0x80
[snd_usb_caiaq]
[ 1935.174034]  [<f888c888>] usb_hcd_giveback_urb+0x48/0xc0 [usbcore]
[ 1935.174064]  [<f8870770>] ehci_urb_done+0x70/0xb0 [ehci_hcd]
[ 1935.174075]  [<f887153f>] qh_completions+0x24f/0x430 [ehci_hcd]
[ 1935.174087]  [<f8870770>] ehci_urb_done+0x70/0xb0 [ehci_hcd]
[ 1935.174096]  [<f887293e>] ehci_work+0x51e/0x810 [ehci_hcd]
[ 1935.174103]  [<c010b1e3>] sched_clock+0x13/0x40
[ 1935.174116]  [<c0129199>] dequeue_task_rt+0xb9/0x1c0
[ 1935.174129]  [<f8875498>] ehci_irq+0x158/0x1c0 [ehci_hcd]
[ 1935.174142]  [<f888cb7b>] usb_hcd_irq+0x2b/0x60 [usbcore]
[ 1935.174166]  [<c016a9cc>] handle_IRQ_event+0x5c/0x100
[ 1935.174178]  [<c016b00a>] thread_simple_irq+0x4a/0x90
[ 1935.174185]  [<c016b959>] do_irqd+0x229/0x290
[ 1935.174194]  [<c016b730>] do_irqd+0x0/0x290
[ 1935.174199]  [<c0141fc2>] kthread+0x42/0x70
[ 1935.174203]  [<c0141f80>] kthread+0x0/0x70
[ 1935.174209]  [<c0105857>] kernel_thread_helper+0x7/0x10
[ 1935.174217]  =======================
[ 1935.174219] Code: 24 10 83 c4 14 c3 bf ea ff ff ff eb e3 90 83 ec 18 89
74 24 0c be ea ff ff ff 89 6c 24 14 89 d5 89 5c 24 08 89 7c 24 10 89 0c 24
<8b> 58 44 8b 7b 04 85 ff 0f 84 8e 00 00 00 8d 43 20 31 f6 89 44
[ 1935.174256] EIP: [<f8a5f6fd>] snd_rawmidi_transmit_peek+0x1d/0x100
[snd_rawmidi] SS:ESP 0068:df85be38
[ 1935.174265] ---[ end trace 9090d02b798b5496 ]---

I already asked to the Rosegarden and JACK people, but they couldn't help
me: it seems to be a driver related problem, as I can happily use Rosegarden if I run JACK with the internal Intel sound card.

The program versions I'm using are: jackd 0.116.1, rosegarden 1.7.2.

Here's some other outputs:

$ uname -a
Linux din6400 2.6.24-19-rt #1 SMP PREEMPT RT Thu Aug 21 02:08:03 UTC 2008
i686 GNU/Linux
$ cat /proc/asound/version
Advanced Linux Sound Architecture Driver Version 1.0.17.
Compiled on Jan  3 2009 for kernel 2.6.24-19-rt (SMP).
$ grep VERSION_STR /usr/include/alsa/version.h
#define SND_LIB_VERSION_STR    "1.0.17a"
$ aplay -l
**** Lista di PLAYBACK dispositivi hardware ****
scheda 0: Intel [HDA Intel], dispositivo 0: STAC92xx Analog [STAC92xx
Analog]
  Sottoperiferiche: 1/1
  Sottoperiferica #0: subdevice #0
scheda 0: Intel [HDA Intel], dispositivo 1: STAC92xx Digital [STAC92xx
Digital]
  Sottoperiferiche: 1/1
  Sottoperiferica #0: subdevice #0
scheda 1: A1 [Audio Kontrol 1], dispositivo 0: Audio Kontrol 1 [Audio
Kontrol 1]
  Sottoperiferiche: 1/2
  Sottoperiferica #0: subdevice #0
  Sottoperiferica #1: subdevice #1
$ cat /proc/interrupts
           CPU0       CPU1
  0:    5438968          0   IO-APIC-edge      timer
  1:       5123          0   IO-APIC-edge      i8042
  8:          7          0   IO-APIC-edge      rtc
  9:          2          0   IO-APIC-fasteoi   acpi
 12:     570309          0   IO-APIC-edge      i8042
 14:      16584          0   IO-APIC-edge      libata
 15:       7712          0   IO-APIC-edge      libata
 16:     312032          0   IO-APIC-fasteoi   i915@pci:0000:00:02.0
 17:          2          0   IO-APIC-fasteoi   ohci1394
 18:     269358          0   IO-APIC-fasteoi   uhci_hcd:usb1, ehci_hcd:usb5
 19:       3999          0   IO-APIC-fasteoi   uhci_hcd:usb2, HDA Intel
 20:          0          0   IO-APIC-fasteoi   uhci_hcd:usb3
 21:          0          0   IO-APIC-fasteoi   uhci_hcd:usb4
 22:       7638          0   IO-APIC-fasteoi   eth0
 23:          0          0   IO-APIC-fasteoi   sdhci:slot0
221:      31667          0   PCI-MSI-edge      iwl3945
NMI:          0          0   Non-maskable interrupts
LOC:     266694    2894868   Local timer interrupts
RES:    1091345    1871342   Rescheduling interrupts
CAL:      12287      11042   function call interrupts
TLB:       1395       1581   TLB shootdowns
TRM:          0          0   Thermal event interrupts
SPU:          0          0   Spurious interrupts
ERR:          0
MIS:          0

I do not include the jackd and rosegarden outputs becouse they are quite long, but, if you think they are useful to understand what is going on, I can send them too.

Any ideas?

Thank you

Marco

#1 lore raw

At Sun, 4 Jan 2009 17:29:47 +0100,

Quoted 70 lines · Marco Santamaria

Hi,

it's about one year that I'm using my Native Instruments Audio Kontrol 1 (USB2 audio/MIDI interface) only with audio applications and it has been working well so far.
Now I'm trying to use it with Rosegarden (MIDI) and, as soon as I start Rosegarden, JACK crashes, the process jackd becomes "uninterruptible" and with the command dmesg I find the following new lines

[ 1935.173876] BUG: unable to handle kernel NULL pointer dereference at
virtual address 00000044
[ 1935.173885] printing eip: f8a5f6fd *pde = 00000000
[ 1935.173891] Oops: 0000 [#1] PREEMPT SMP
[ 1935.173896] Modules linked in: isofs udf ipv6 af_packet i915 drm rfcomm

l2cap bluetooth ppdev acpi_cpufreq cpufreq_ondemand cpufreq_conservative cpufreq_stats freq_table cpufreq_userspace cpufreq_powersave dock container sbs sbshc iptable_filter ip_tables x_tables sbp2 parport_pc lp parport snd_hda_intel snd_usb_caiaq snd_hwdep snd_pcm_oss snd_mixer_oss arc4 snd_seq_oss snd_pcm ecb blkcipher snd_seq_midi snd_page_alloc joydev snd_rawmidi snd_seq_midi_event snd_seq iwl3945 sdhci serio_raw mmc_core iwlwifi_mac80211 video output cfg80211 battery led_class ac snd_timer snd_seq_device wmi_acer button snd evdev dcdbas iTCO_wdt iTCO_vendor_support intel_agp shpchp pci_hotplug pcspkr soundcore agpgart psmouse ext3 jbd mbcache sg sr_mod cdrom sd_mod b44 ata_generic ssb mii ohci1394 ieee1394 ata_piix pata_acpi libata scsi_mod ehci_hcd uhci_hcd usbcore thermal processor fan fuse

[ 1935.173964]
[ 1935.173967] Pid: 1421, comm: IRQ-18 Not tainted (2.6.24-19-rt #1)
[ 1935.173970] EIP: 0060:[<f8a5f6fd>] EFLAGS: 00010292 CPU: 1
[ 1935.173979] EIP is at snd_rawmidi_transmit_peek+0x1d/0x100 [snd_rawmidi]
[ 1935.173982] EAX: 00000000 EBX: f7106264 ECX: 0000003d EDX: f7106407
[ 1935.173985] ESI: ffffffea EDI: 00000000 EBP: f7106407 ESP: df85be38
[ 1935.173988]  DS: 007b ES: 007b FS: 00d8 GS: 0000 SS: 0068
preempt:00000001
[ 1935.173991] Process IRQ-18 (pid: 1421, ti=df85a000 task=f7d45320
task.ti=df85a000)
[ 1935.173993] Stack: 0000003d 00000000 f7106264 00000000 00000000 df83fc00
f8b8cc09 00000000
[ 1935.174000]        f7106264 f710630c 00000000 df83fc00 df83fc00 f710630c
f888c888 00000008
[ 1935.174007]        df83fd08 00000000 f710630c f8870770 f728a0c0 f728a0c0
ffffff8d f721e180
[ 1935.174014] Call Trace:
[ 1935.174021]  [<f8b8cc09>] snd_usb_caiaq_midi_send+0x29/0x80
[snd_usb_caiaq]
[ 1935.174034]  [<f888c888>] usb_hcd_giveback_urb+0x48/0xc0 [usbcore]
[ 1935.174064]  [<f8870770>] ehci_urb_done+0x70/0xb0 [ehci_hcd]
[ 1935.174075]  [<f887153f>] qh_completions+0x24f/0x430 [ehci_hcd]
[ 1935.174087]  [<f8870770>] ehci_urb_done+0x70/0xb0 [ehci_hcd]
[ 1935.174096]  [<f887293e>] ehci_work+0x51e/0x810 [ehci_hcd]
[ 1935.174103]  [<c010b1e3>] sched_clock+0x13/0x40
[ 1935.174116]  [<c0129199>] dequeue_task_rt+0xb9/0x1c0
[ 1935.174129]  [<f8875498>] ehci_irq+0x158/0x1c0 [ehci_hcd]
[ 1935.174142]  [<f888cb7b>] usb_hcd_irq+0x2b/0x60 [usbcore]
[ 1935.174166]  [<c016a9cc>] handle_IRQ_event+0x5c/0x100
[ 1935.174178]  [<c016b00a>] thread_simple_irq+0x4a/0x90
[ 1935.174185]  [<c016b959>] do_irqd+0x229/0x290
[ 1935.174194]  [<c016b730>] do_irqd+0x0/0x290
[ 1935.174199]  [<c0141fc2>] kthread+0x42/0x70
[ 1935.174203]  [<c0141f80>] kthread+0x0/0x70
[ 1935.174209]  [<c0105857>] kernel_thread_helper+0x7/0x10
[ 1935.174217]  =======================
[ 1935.174219] Code: 24 10 83 c4 14 c3 bf ea ff ff ff eb e3 90 83 ec 18 89
74 24 0c be ea ff ff ff 89 6c 24 14 89 d5 89 5c 24 08 89 7c 24 10 89 0c 24
<8b> 58 44 8b 7b 04 85 ff 0f 84 8e 00 00 00 8d 43 20 31 f6 89 44
[ 1935.174256] EIP: [<f8a5f6fd>] snd_rawmidi_transmit_peek+0x1d/0x100
[snd_rawmidi] SS:ESP 0068:df85be38
[ 1935.174265] ---[ end trace 9090d02b798b5496 ]---
Quoted 3 lines

I already asked to the Rosegarden and JACK people, but they couldn't help
me: it seems to be a driver related problem, as I can happily use Rosegarden if I run JACK with the internal Intel sound card.

How about the patch below?

thanks,

Takashi

---

sound/usb/caiaq/caiaq-midi.c +0 -1
index 30b57f9..89a29f0 100644
@@ -170,7 +170,6 @@ void snd_usb_caiaq_midi_output_done(struct urb* urb)
 		return;
 
 	snd_rawmidi_transmit_ack(dev->midi_out_substream, buf[2]);
-	dev->midi_out_substream = NULL;
 	snd_usb_caiaq_midi_send(dev, dev->midi_out_substream);
 }
#2 lore raw

I applied the patch (or I think so...). I just removed the line:

dev->midi_out_substream = NULL;

from the function snd_usb_caiaq_midi_output_done in the file caiaq-midi.c. Then I recompiled the driver.

The main issue is sorted out: I can start and shut down jackd without big problems.

But with dmesg I still have the following message:

ALSA /home/marco/build/linux-2.6.24-19-rt/alsa-1.0.17/driver-patched/alsa-driver-1.0.17/acore/rawmidi.c:196:
rawmidi drain error (avail = 4095, buffer_size = 4096)

Not sure if it is safe to ignore it.

Marco

2009/1/7 Takashi Iwai <[email protected]>

Quoted 106 lines

At Sun, 4 Jan 2009 17:29:47 +0100,

Quoted 10 lines · Marco Santamaria

Hi,

it's about one year that I'm using my Native Instruments Audio Kontrol 1 (USB2 audio/MIDI interface) only with audio applications and it has been working well so far.
Now I'm trying to use it with Rosegarden (MIDI) and, as soon as I start Rosegarden, JACK crashes, the process jackd becomes "uninterruptible" and with the command dmesg I find the following new lines

Quoted 5 lines
[ 1935.173876] BUG: unable to handle kernel NULL pointer dereference at
virtual address 00000044
[ 1935.173885] printing eip: f8a5f6fd *pde = 00000000
[ 1935.173891] Oops: 0000 [#1] PREEMPT SMP
[ 1935.173896] Modules linked in: isofs udf ipv6 af_packet i915 drm

rfcomm

Quoted 2 lines

l2cap bluetooth ppdev acpi_cpufreq cpufreq_ondemand cpufreq_conservative cpufreq_stats freq_table cpufreq_userspace cpufreq_powersave dock

container

Quoted 6 lines

sbs sbshc iptable_filter ip_tables x_tables sbp2 parport_pc lp parport snd_hda_intel snd_usb_caiaq snd_hwdep snd_pcm_oss snd_mixer_oss arc4 snd_seq_oss snd_pcm ecb blkcipher snd_seq_midi snd_page_alloc joydev snd_rawmidi snd_seq_midi_event snd_seq iwl3945 sdhci serio_raw mmc_core iwlwifi_mac80211 video output cfg80211 battery led_class ac snd_timer snd_seq_device wmi_acer button snd evdev dcdbas iTCO_wdt

iTCO_vendor_support

Quoted 8 lines

intel_agp shpchp pci_hotplug pcspkr soundcore agpgart psmouse ext3 jbd mbcache sg sr_mod cdrom sd_mod b44 ata_generic ssb mii ohci1394 ieee1394 ata_piix pata_acpi libata scsi_mod ehci_hcd uhci_hcd usbcore thermal processor fan fuse

[ 1935.173964]
[ 1935.173967] Pid: 1421, comm: IRQ-18 Not tainted (2.6.24-19-rt #1)
[ 1935.173970] EIP: 0060:[<f8a5f6fd>] EFLAGS: 00010292 CPU: 1
[ 1935.173979] EIP is at snd_rawmidi_transmit_peek+0x1d/0x100

[snd_rawmidi]

Quoted 7 lines
[ 1935.173982] EAX: 00000000 EBX: f7106264 ECX: 0000003d EDX: f7106407
[ 1935.173985] ESI: ffffffea EDI: 00000000 EBP: f7106407 ESP: df85be38
[ 1935.173988]  DS: 007b ES: 007b FS: 00d8 GS: 0000 SS: 0068
preempt:00000001
[ 1935.173991] Process IRQ-18 (pid: 1421, ti=df85a000 task=f7d45320
task.ti=df85a000)
[ 1935.173993] Stack: 0000003d 00000000 f7106264 00000000 00000000

df83fc00

Quoted 2 lines

f8b8cc09 00000000

[ 1935.174000]        f7106264 f710630c 00000000 df83fc00 df83fc00

f710630c

Quoted 2 lines

f888c888 00000008

[ 1935.174007]        df83fd08 00000000 f710630c f8870770 f728a0c0

f728a0c0

Quoted 14 lines

ffffff8d f721e180

[ 1935.174014] Call Trace:
[ 1935.174021]  [<f8b8cc09>] snd_usb_caiaq_midi_send+0x29/0x80
[snd_usb_caiaq]
[ 1935.174034]  [<f888c888>] usb_hcd_giveback_urb+0x48/0xc0 [usbcore]
[ 1935.174064]  [<f8870770>] ehci_urb_done+0x70/0xb0 [ehci_hcd]
[ 1935.174075]  [<f887153f>] qh_completions+0x24f/0x430 [ehci_hcd]
[ 1935.174087]  [<f8870770>] ehci_urb_done+0x70/0xb0 [ehci_hcd]
[ 1935.174096]  [<f887293e>] ehci_work+0x51e/0x810 [ehci_hcd]
[ 1935.174103]  [<c010b1e3>] sched_clock+0x13/0x40
[ 1935.174116]  [<c0129199>] dequeue_task_rt+0xb9/0x1c0
[ 1935.174129]  [<f8875498>] ehci_irq+0x158/0x1c0 [ehci_hcd]
[ 1935.174142]  [<f888cb7b>] usb_hcd_irq+0x2b/0x60 [usbcore]
[ 1935.174166]  [<c016a9cc>] handle_IRQ_event+0x5c/0x100
Quoted 8 lines
[ 1935.174178]  [<c016b00a>] thread_simple_irq+0x4a/0x90
[ 1935.174185]  [<c016b959>] do_irqd+0x229/0x290
[ 1935.174194]  [<c016b730>] do_irqd+0x0/0x290
[ 1935.174199]  [<c0141fc2>] kthread+0x42/0x70
[ 1935.174203]  [<c0141f80>] kthread+0x0/0x70
[ 1935.174209]  [<c0105857>] kernel_thread_helper+0x7/0x10
[ 1935.174217]  =======================
[ 1935.174219] Code: 24 10 83 c4 14 c3 bf ea ff ff ff eb e3 90 83 ec 18

89

Quoted 1 line

74 24 0c be ea ff ff ff 89 6c 24 14 89 d5 89 5c 24 08 89 7c 24 10 89 0c

24

Quoted 8 lines

<8b> 58 44 8b 7b 04 85 ff 0f 84 8e 00 00 00 8d 43 20 31 f6 89 44

[ 1935.174256] EIP: [<f8a5f6fd>] snd_rawmidi_transmit_peek+0x1d/0x100
[snd_rawmidi] SS:ESP 0068:df85be38
[ 1935.174265] ---[ end trace 9090d02b798b5496 ]---

I already asked to the Rosegarden and JACK people, but they couldn't help
me: it seems to be a driver related problem, as I can happily use Rosegarden if I run JACK with the internal Intel sound card.

How about the patch below?

thanks,

Takashi

---

sound/usb/caiaq/caiaq-midi.c +0 -1
index 30b57f9..89a29f0 100644
@@ -170,7 +170,6 @@ void snd_usb_caiaq_midi_output_done(struct urb* urb)
               return;
 
       snd_rawmidi_transmit_ack(dev->midi_out_substream, buf[2]);
-       dev->midi_out_substream = NULL;
       snd_usb_caiaq_midi_send(dev, dev->midi_out_substream);
 }
 
#3 lore raw

At Wed, 7 Jan 2009 16:41:21 +0100,

Quoted 11 lines · Marco Santamaria

I applied the patch (or I think so...). I just removed the line:

dev->midi_out_substream = NULL;

from the function snd_usb_caiaq_midi_output_done in the file caiaq-midi.c. Then I recompiled the driver.

The main issue is sorted out: I can start and shut down jackd without big problems.

Quoted 7 lines

But with dmesg I still have the following message:

ALSA /home/marco/build/linux-2.6.24-19-rt/alsa-1.0.17/driver-patched/ alsa-driver-1.0.17/acore/rawmidi.c:196: rawmidi drain error (avail = 4095, buffer_size = 4096)

Not sure if it is safe to ignore it.

Hmm, what about the patch below?

Takashi

---

sound/usb/caiaq/caiaq-midi.c +6 -11
index 30b57f9..9557635 100644
@@ -69,7 +69,8 @@ static void snd_usb_caiaq_midi_send(struct snd_usb_caiaqdev *dev,
 	
 	dev->midi_out_buf[0] = EP1_CMD_MIDI_WRITE;
 	dev->midi_out_buf[1] = 0; /* port */
-	len = snd_rawmidi_transmit_peek(substream, dev->midi_out_buf+3, EP1_BUFSIZE-3);
+	len = snd_rawmidi_transmit(substream, dev->midi_out_buf + 3,
+				   EP1_BUFSIZE - 3);
 	
 	if (len <= 0)
 		return;
@@ -87,16 +88,12 @@ static void snd_usb_caiaq_midi_output_trigger(struct snd_rawmidi_substream *subs
 {
 	struct snd_usb_caiaqdev *dev = substream->rmidi->private_data;
 	
-	if (dev->midi_out_substream != NULL)
-		return;
-	
-	if (!up) {
+	if (up) {
+		dev->midi_out_substream = substream;
+		snd_usb_caiaq_midi_send(dev, substream);
+	} else {
 		dev->midi_out_substream = NULL;
-		return;
 	}
-	
-	dev->midi_out_substream = substream;
-	snd_usb_caiaq_midi_send(dev, substream);
 }
 
 
@@ -169,8 +166,6 @@ void snd_usb_caiaq_midi_output_done(struct urb* urb)
 	if (!dev->midi_out_substream)
 		return;
 
-	snd_rawmidi_transmit_ack(dev->midi_out_substream, buf[2]);
-	dev->midi_out_substream = NULL;
 	snd_usb_caiaq_midi_send(dev, dev->midi_out_substream);
 }
#4 lore raw

The "rawmidi drain error" went away.
Now if I start and shut down jackd nothing bad happens. But when I launch Rosegarden there are several lines containing the following new message:

[  455.025168] ALSA

/home/marco/build/linux-2.6.24-19-rt/alsa-1.0.17/driver-patched/alsa-driver-1.0.17/usb/caiaq/../../alsa-kernel/usb/caiaq/caiaq-midi.c:84:
snd-usb-caiaq log: snd_usb_caiaq_midi_send(f76a5ac0): usb_submit_urb()
failed, -22

Furthermore the first time I rebooted my system, it freezed during the startup procedure (loading hardware drivers), but it didn't happen again.

Marco

2009/1/7 Takashi Iwai <[email protected]>

Quoted 77 lines

At Wed, 7 Jan 2009 16:41:21 +0100,

Quoted 6 lines · Marco Santamaria

I applied the patch (or I think so...). I just removed the line:

dev->midi_out_substream = NULL;

from the function snd_usb_caiaq_midi_output_done in the file

caiaq-midi.c.

Quoted 9 lines

Then I recompiled the driver.

The main issue is sorted out: I can start and shut down jackd without big problems.

But with dmesg I still have the following message:

ALSA /home/marco/build/linux-2.6.24-19-rt/alsa-1.0.17/driver-patched/ alsa-driver-1.0.17/acore/rawmidi.c:196: rawmidi drain error (avail =

4095,

Quoted 3 lines

buffer_size = 4096)

Not sure if it is safe to ignore it.

Hmm, what about the patch below?

Takashi

---

sound/usb/caiaq/caiaq-midi.c +2 -1
index 30b57f9..9557635 100644
@@ -69,7 +69,8 @@ static void snd_usb_caiaq_midi_send(struct
 snd_usb_caiaqdev *dev,
 
       dev->midi_out_buf[0] = EP1_CMD_MIDI_WRITE;
       dev->midi_out_buf[1] = 0; /* port */
-       len = snd_rawmidi_transmit_peek(substream, dev->midi_out_buf+3,
 EP1_BUFSIZE-3);
+       len = snd_rawmidi_transmit(substream, dev->midi_out_buf + 3,
+                                  EP1_BUFSIZE - 3);
 
       if (len <= 0)
               return;
sound/usb/caiaq/caiaq-midi.c +0 -0
@@ -87,16 +88,12 @@ static void snd_usb_caiaq_midi_output_trigger(struct

snd_rawmidi_substream *subs

 {
       struct snd_usb_caiaqdev *dev = substream->rmidi->private_data;
sound/usb/caiaq/caiaq-midi.c +4 -10
-       if (dev->midi_out_substream != NULL)
-               return;
-
-       if (!up) {
+       if (up) {
+               dev->midi_out_substream = substream;
+               snd_usb_caiaq_midi_send(dev, substream);
+       } else {
                dev->midi_out_substream = NULL;
-               return;
       }
-
-       dev->midi_out_substream = substream;
-       snd_usb_caiaq_midi_send(dev, substream);
 }
@@ -169,8 +166,6 @@ void snd_usb_caiaq_midi_output_done(struct urb* urb)
       if (!dev->midi_out_substream)
                return;
 
-       snd_rawmidi_transmit_ack(dev->midi_out_substream, buf[2]);
-       dev->midi_out_substream = NULL;
       snd_usb_caiaq_midi_send(dev, dev->midi_out_substream);
 }
 
#5 lore raw

Hi Takashi,

I have almost the same problem as Marco. (that is why Marco forwarded me this message).

Well, Now it seems to be almost perfect. Just to explain to you :

I had a problem with Pure data, each time I wanted to enable the alsa midi (in pure data). Then I had some problem opening some of my patch, making pd zombified and Jack output tons of "delay of 1666.000 usecs exceeds estimated spare time of 1140.000; restart ..." until I stop it and run it again.

Now pd works perfectly. I made some others jackd settings, and the "xruns" messages seems to gone away.

But like Marco I got this message in the output of dmesg :

[ 20.269196] Adding 530136k swap on /dev/sda3. Priority:-1 extents:1
across:530136k
[ 445.142031] snd-usb-caiaq log: snd_usb_caiaq_midi_send(ffff81007f9380c0):
usb_submit_urb() failed, -22
[ 445.393030] snd-usb-caiaq log: snd_usb_caiaq_midi_send(ffff81007f9380c0):
usb_submit_urb() failed, -22
[ 445.640986] snd-usb-caiaq log: snd_usb_caiaq_midi_send(ffff81007f9380c0):
usb_submit_urb() failed, -22
[ 445.892008] snd-usb-caiaq log: snd_usb_caiaq_midi_send(ffff81007f9380c0):
usb_submit_urb() failed, -22
[ 446.141982] snd-usb-caiaq log: snd_usb_caiaq_midi_send(ffff81007f9380c0):
usb_submit_urb() failed, -22
[ 446.392962] snd-usb-caiaq log: snd_usb_caiaq_midi_send(ffff81007f9380c0):
usb_submit_urb() failed, -22
[ 446.640967] snd-usb-caiaq log: snd_usb_caiaq_midi_send(ffff81007f9380c0):
usb_submit_urb() failed, -22
[ 446.891986] snd-usb-caiaq log: snd_usb_caiaq_midi_send(ffff81007f9380c0):
usb_submit_urb() failed, -22
[ 461.651199] CPU0: Temperature/speed normal

infos :
kernel : 2.6.26.8-rt12 (with the last patch solving alsa midi problems).
OS : Gentoo 64bits.
Sounds card : NI Audio Kontrol 1
alsa : 1.0.16 (with your patchs now.)

Thank you for your help and your great job. I can use pd now, my main software to make music. So I am very happy :)

Just a thing, when I press the buttons on the top of the Audio Kontrol 1 I got qbc (azerty keyboard). but When I move the jog, the system log out.

Did anyone find a way to change the assignation of these buttons ?

Kind regards,

Mysth-R

2009/1/7 Marco Santamaria <[email protected]>

Quoted 97 lines

The "rawmidi drain error" went away.
Now if I start and shut down jackd nothing bad happens. But when I launch Rosegarden there are several lines containing the following new message:

[  455.025168] ALSA

/home/marco/build/linux-2.6.24-19-rt/alsa-1.0.17/driver-patched/alsa-driver-1.0.17/usb/caiaq/../../alsa-kernel/usb/caiaq/caiaq-midi.c:84:
snd-usb-caiaq log: snd_usb_caiaq_midi_send(f76a5ac0): usb_submit_urb()
failed, -22

Furthermore the first time I rebooted my system, it freezed during the startup procedure (loading hardware drivers), but it didn't happen again.

Marco

2009/1/7 Takashi Iwai <[email protected]>

Quoted 78 lines

At Wed, 7 Jan 2009 16:41:21 +0100,

Quoted 6 lines · Marco Santamaria

I applied the patch (or I think so...). I just removed the line:

dev->midi_out_substream = NULL;

from the function snd_usb_caiaq_midi_output_done in the file

caiaq-midi.c.

Quoted 3 lines

Then I recompiled the driver.

The main issue is sorted out: I can start and shut down jackd without

big

Quoted 6 lines

problems.

But with dmesg I still have the following message:

ALSA /home/marco/build/linux-2.6.24-19-rt/alsa-1.0.17/driver-patched/ alsa-driver-1.0.17/acore/rawmidi.c:196: rawmidi drain error (avail =

4095,

Quoted 3 lines

buffer_size = 4096)

Not sure if it is safe to ignore it.

Hmm, what about the patch below?

Takashi

---

sound/usb/caiaq/caiaq-midi.c +2 -1
index 30b57f9..9557635 100644
@@ -69,7 +69,8 @@ static void snd_usb_caiaq_midi_send(struct
 snd_usb_caiaqdev *dev,
 
       dev->midi_out_buf[0] = EP1_CMD_MIDI_WRITE;
       dev->midi_out_buf[1] = 0; /* port */
-       len = snd_rawmidi_transmit_peek(substream, dev->midi_out_buf+3,
 EP1_BUFSIZE-3);
+       len = snd_rawmidi_transmit(substream, dev->midi_out_buf + 3,
+                                  EP1_BUFSIZE - 3);
 
       if (len <= 0)
               return;
sound/usb/caiaq/caiaq-midi.c +0 -0
@@ -87,16 +88,12 @@ static void snd_usb_caiaq_midi_output_trigger(struct

snd_rawmidi_substream *subs

 {
       struct snd_usb_caiaqdev *dev = substream->rmidi->private_data;
sound/usb/caiaq/caiaq-midi.c +4 -10
-       if (dev->midi_out_substream != NULL)
-               return;
-
-       if (!up) {
+       if (up) {
+               dev->midi_out_substream = substream;
+               snd_usb_caiaq_midi_send(dev, substream);
+       } else {
                dev->midi_out_substream = NULL;
-               return;
       }
-
-       dev->midi_out_substream = substream;
-       snd_usb_caiaq_midi_send(dev, substream);
 }
@@ -169,8 +166,6 @@ void snd_usb_caiaq_midi_output_done(struct urb* urb)
       if (!dev->midi_out_substream)
                return;
 
-       snd_rawmidi_transmit_ack(dev->midi_out_substream, buf[2]);
-       dev->midi_out_substream = NULL;
       snd_usb_caiaq_midi_send(dev, dev->midi_out_substream);
 }
 
Signature · 11 lines
*
***************************************************************************************
*  {^_^} Mysth-R {^_^}
*  <= Aide Auditive =>
*
* http://myspace.com/mysthr
* http://myspace.com/aideauditive
* http://mysthr.free.fr/Joomla  => Site dédié à l'audio sous
Fedora/PlanetCCRMA.
*
***************************************************************************************
#6 lore raw

At Wed, 7 Jan 2009 21:06:23 +0100,

Quoted 35 lines · Mysth-R

Hi Takashi,

I have almost the same problem as Marco. (that is why Marco forwarded me this message).

Well, Now it seems to be almost perfect. Just to explain to you :

I had a problem with Pure data, each time I wanted to enable the alsa midi (in pure data). Then I had some problem opening some of my patch, making pd zombified and Jack output tons of "delay of 1666.000 usecs exceeds estimated spare time of 1140.000; restart ..." until I stop it and run it again.

Now pd works perfectly. I made some others jackd settings, and the "xruns" messages seems to gone away.

But like Marco I got this message in the output of dmesg :

[ 20.269196] Adding 530136k swap on /dev/sda3. Priority:-1 extents:1
across:530136k
[ 445.142031] snd-usb-caiaq log: snd_usb_caiaq_midi_send(ffff81007f9380c0):
usb_submit_urb() failed, -22
[ 445.393030] snd-usb-caiaq log: snd_usb_caiaq_midi_send(ffff81007f9380c0):
usb_submit_urb() failed, -22
[ 445.640986] snd-usb-caiaq log: snd_usb_caiaq_midi_send(ffff81007f9380c0):
usb_submit_urb() failed, -22
[ 445.892008] snd-usb-caiaq log: snd_usb_caiaq_midi_send(ffff81007f9380c0):
usb_submit_urb() failed, -22
[ 446.141982] snd-usb-caiaq log: snd_usb_caiaq_midi_send(ffff81007f9380c0):
usb_submit_urb() failed, -22
[ 446.392962] snd-usb-caiaq log: snd_usb_caiaq_midi_send(ffff81007f9380c0):
usb_submit_urb() failed, -22
[ 446.640967] snd-usb-caiaq log: snd_usb_caiaq_midi_send(ffff81007f9380c0):
usb_submit_urb() failed, -22
[ 446.891986] snd-usb-caiaq log: snd_usb_caiaq_midi_send(ffff81007f9380c0):
Quoted 1 line

usb_submit_urb() failed, -22

OK, what about this patch? Now it checks the URB existence before submission.

thanks,

Takashi

---

sound/usb/caiaq/caiaq-device.h +1 -0
index f9fbdba..ab56e73 100644
@@ -75,6 +75,7 @@ struct snd_usb_caiaqdev {
 	wait_queue_head_t ep1_wait_queue;
 	wait_queue_head_t prepare_wait_queue;
 	int spec_received, audio_parm_answer;
+	int midi_out_active;
 
 	char vendor_name[CAIAQ_USB_STR_LEN];
 	char product_name[CAIAQ_USB_STR_LEN];
sound/usb/caiaq/caiaq-midi.c +10 -11
index 30b57f9..6b76f7f 100644
@@ -69,7 +69,8 @@ static void snd_usb_caiaq_midi_send(struct snd_usb_caiaqdev *dev,
 	
 	dev->midi_out_buf[0] = EP1_CMD_MIDI_WRITE;
 	dev->midi_out_buf[1] = 0; /* port */
-	len = snd_rawmidi_transmit_peek(substream, dev->midi_out_buf+3, EP1_BUFSIZE-3);
+	len = snd_rawmidi_transmit(substream, dev->midi_out_buf + 3,
+				   EP1_BUFSIZE - 3);
 	
 	if (len <= 0)
 		return;
@@ -81,22 +82,21 @@ static void snd_usb_caiaq_midi_send(struct snd_usb_caiaqdev *dev,
 	if (ret < 0)
 		log("snd_usb_caiaq_midi_send(%p): usb_submit_urb() failed, %d\n",
 				substream, ret);
+	else
+		dev->midi_out_active = 1;
 }
 
 static void snd_usb_caiaq_midi_output_trigger(struct snd_rawmidi_substream *substream, int up)
 {
 	struct snd_usb_caiaqdev *dev = substream->rmidi->private_data;
 	
-	if (dev->midi_out_substream != NULL)
-		return;
-	
-	if (!up) {
+	if (up) {
+		dev->midi_out_substream = substream;
+		if (!dev->midi_out_active)
+			snd_usb_caiaq_midi_send(dev, substream);
+	} else {
 		dev->midi_out_substream = NULL;
-		return;
 	}
-	
-	dev->midi_out_substream = substream;
-	snd_usb_caiaq_midi_send(dev, substream);
 }
 
 
@@ -163,14 +163,13 @@ void snd_usb_caiaq_midi_output_done(struct urb* urb)
 	struct snd_usb_caiaqdev *dev = urb->context;
       	char *buf = urb->transfer_buffer;
 	
+	dev->midi_out_active = 0;
 	if (urb->status != 0)
 		return;
 
 	if (!dev->midi_out_substream)
 		return;
 
-	snd_rawmidi_transmit_ack(dev->midi_out_substream, buf[2]);
-	dev->midi_out_substream = NULL;
 	snd_usb_caiaq_midi_send(dev, dev->midi_out_substream);
 }
#7 lore raw

No more errors in dmesg this time. Tomorrow I will apply the patch to the latest stable version of the alsa-driver (1.0.18).

Please let me know if there are more tests I can do with JACK, Rosegarden, Ardour or something else.

Do you think that this patch will go in the next version of the alsa-driver?

Thank you very much for your help,
Marco

2009/1/7 Takashi Iwai <[email protected]>

Quoted 139 lines

At Wed, 7 Jan 2009 21:06:23 +0100,

Quoted 4 lines · Mysth-R

Hi Takashi,

I have almost the same problem as Marco. (that is why Marco forwarded me

this

Quoted 5 lines

message).

Well, Now it seems to be almost perfect. Just to explain to you :

I had a problem with Pure data, each time I wanted to enable the alsa

midi (in

Quoted 2 lines

pure data). Then I had some problem opening some of my patch, making pd zombified and Jack output tons of "delay of 1666.000 usecs exceeds

estimated

Quoted 3 lines

spare time of 1140.000; restart ..." until I stop it and run it again.

Now pd works perfectly. I made some others jackd settings, and the

"xruns"

Quoted 7 lines

messages seems to gone away.

But like Marco I got this message in the output of dmesg :

[ 20.269196] Adding 530136k swap on /dev/sda3. Priority:-1 extents:1
across:530136k
[ 445.142031] snd-usb-caiaq log:

snd_usb_caiaq_midi_send(ffff81007f9380c0):

Quoted 2 lines

usb_submit_urb() failed, -22

[ 445.393030] snd-usb-caiaq log:

snd_usb_caiaq_midi_send(ffff81007f9380c0):

Quoted 2 lines

usb_submit_urb() failed, -22

[ 445.640986] snd-usb-caiaq log:

snd_usb_caiaq_midi_send(ffff81007f9380c0):

Quoted 2 lines

usb_submit_urb() failed, -22

[ 445.892008] snd-usb-caiaq log:

snd_usb_caiaq_midi_send(ffff81007f9380c0):

Quoted 2 lines

usb_submit_urb() failed, -22

[ 446.141982] snd-usb-caiaq log:

snd_usb_caiaq_midi_send(ffff81007f9380c0):

Quoted 2 lines

usb_submit_urb() failed, -22

[ 446.392962] snd-usb-caiaq log:

snd_usb_caiaq_midi_send(ffff81007f9380c0):

Quoted 2 lines

usb_submit_urb() failed, -22

[ 446.640967] snd-usb-caiaq log:

snd_usb_caiaq_midi_send(ffff81007f9380c0):

Quoted 2 lines

usb_submit_urb() failed, -22

[ 446.891986] snd-usb-caiaq log:

snd_usb_caiaq_midi_send(ffff81007f9380c0):

Quoted 1 line

usb_submit_urb() failed, -22

OK, what about this patch? Now it checks the URB existence before submission.

thanks,

Takashi

---

sound/usb/caiaq/caiaq-device.h +1 -0
index f9fbdba..ab56e73 100644
@@ -75,6 +75,7 @@ struct snd_usb_caiaqdev {
       wait_queue_head_t ep1_wait_queue;
       wait_queue_head_t prepare_wait_queue;
       int spec_received, audio_parm_answer;
+       int midi_out_active;
 
       char vendor_name[CAIAQ_USB_STR_LEN];
       char product_name[CAIAQ_USB_STR_LEN];
sound/usb/caiaq/caiaq-midi.c +2 -1
index 30b57f9..6b76f7f 100644
@@ -69,7 +69,8 @@ static void snd_usb_caiaq_midi_send(struct
 snd_usb_caiaqdev *dev,
 
       dev->midi_out_buf[0] = EP1_CMD_MIDI_WRITE;
       dev->midi_out_buf[1] = 0; /* port */
-       len = snd_rawmidi_transmit_peek(substream, dev->midi_out_buf+3,
 EP1_BUFSIZE-3);
+       len = snd_rawmidi_transmit(substream, dev->midi_out_buf + 3,
+                                  EP1_BUFSIZE - 3);
 
       if (len <= 0)
               return;
sound/usb/caiaq/caiaq-midi.c +7 -8
@@ -81,22 +82,21 @@ static void snd_usb_caiaq_midi_send(struct
 snd_usb_caiaqdev *dev,
       if (ret < 0)
               log("snd_usb_caiaq_midi_send(%p): usb_submit_urb() failed,
 %d\n",
                               substream, ret);
+       else
+               dev->midi_out_active = 1;
 }
 
 static void snd_usb_caiaq_midi_output_trigger(struct snd_rawmidi_substream
 *substream, int up)
 {
       struct snd_usb_caiaqdev *dev = substream->rmidi->private_data;
 
-       if (dev->midi_out_substream != NULL)
-               return;
-
-       if (!up) {
+       if (up) {
+               dev->midi_out_substream = substream;
+               if (!dev->midi_out_active)
+                       snd_usb_caiaq_midi_send(dev, substream);
+       } else {
               dev->midi_out_substream = NULL;
-               return;
       }
-
-       dev->midi_out_substream = substream;
-       snd_usb_caiaq_midi_send(dev, substream);

}

sound/usb/caiaq/caiaq-midi.c +1 -2
@@ -163,14 +163,13 @@ void snd_usb_caiaq_midi_output_done(struct urb* urb)
       struct snd_usb_caiaqdev *dev = urb->context;
       char *buf = urb->transfer_buffer;
 
+       dev->midi_out_active = 0;
       if (urb->status != 0)
               return;
 
       if (!dev->midi_out_substream)
               return;
 
-       snd_rawmidi_transmit_ack(dev->midi_out_substream, buf[2]);
-       dev->midi_out_substream = NULL;
       snd_usb_caiaq_midi_send(dev, dev->midi_out_substream);
 }
 
#8 lore raw

Unfortunately I have to correct my previous message.

After a load test with jack + qsynth + rosegarden (sample rate=88200, frames/period=256, periods/buffer=3), using a 16 tracks midi file and a 29MB sound font, the following message appeared:

[ 1098.445807] ALSA

/home/marco/build/linux-2.6.24-19-rt/alsa-1.0.17/driver-patched/alsa-driver-1.0.17/usb/caiaq/../../alsa-kernel/usb/caiaq/caiaq-midi.c:84:
snd-usb-caiaq log: snd_usb_caiaq_midi_send(f64c66c0): usb_submit_urb()
failed, -22

Cheers,
Marco

2009/1/8 Marco Santamaria <[email protected]>

Quoted 156 lines

No more errors in dmesg this time. Tomorrow I will apply the patch to the latest stable version of the alsa-driver (1.0.18).

Please let me know if there are more tests I can do with JACK, Rosegarden, Ardour or something else.

Do you think that this patch will go in the next version of the alsa-driver?

Thank you very much for your help,
Marco

2009/1/7 Takashi Iwai <[email protected]>

Quoted 140 lines

At Wed, 7 Jan 2009 21:06:23 +0100,

Quoted 4 lines · Mysth-R

Hi Takashi,

I have almost the same problem as Marco. (that is why Marco forwarded me

this

Quoted 5 lines

message).

Well, Now it seems to be almost perfect. Just to explain to you :

I had a problem with Pure data, each time I wanted to enable the alsa

midi (in

Quoted 2 lines

pure data). Then I had some problem opening some of my patch, making pd zombified and Jack output tons of "delay of 1666.000 usecs exceeds

estimated

Quoted 3 lines

spare time of 1140.000; restart ..." until I stop it and run it again.

Now pd works perfectly. I made some others jackd settings, and the

"xruns"

Quoted 7 lines

messages seems to gone away.

But like Marco I got this message in the output of dmesg :

[ 20.269196] Adding 530136k swap on /dev/sda3. Priority:-1 extents:1
across:530136k
[ 445.142031] snd-usb-caiaq log:

snd_usb_caiaq_midi_send(ffff81007f9380c0):

Quoted 2 lines

usb_submit_urb() failed, -22

[ 445.393030] snd-usb-caiaq log:

snd_usb_caiaq_midi_send(ffff81007f9380c0):

Quoted 2 lines

usb_submit_urb() failed, -22

[ 445.640986] snd-usb-caiaq log:

snd_usb_caiaq_midi_send(ffff81007f9380c0):

Quoted 2 lines

usb_submit_urb() failed, -22

[ 445.892008] snd-usb-caiaq log:

snd_usb_caiaq_midi_send(ffff81007f9380c0):

Quoted 2 lines

usb_submit_urb() failed, -22

[ 446.141982] snd-usb-caiaq log:

snd_usb_caiaq_midi_send(ffff81007f9380c0):

Quoted 2 lines

usb_submit_urb() failed, -22

[ 446.392962] snd-usb-caiaq log:

snd_usb_caiaq_midi_send(ffff81007f9380c0):

Quoted 2 lines

usb_submit_urb() failed, -22

[ 446.640967] snd-usb-caiaq log:

snd_usb_caiaq_midi_send(ffff81007f9380c0):

Quoted 2 lines

usb_submit_urb() failed, -22

[ 446.891986] snd-usb-caiaq log:

snd_usb_caiaq_midi_send(ffff81007f9380c0):

Quoted 1 line

usb_submit_urb() failed, -22

OK, what about this patch? Now it checks the URB existence before submission.

thanks,

Takashi

---

sound/usb/caiaq/caiaq-device.h +1 -0
index f9fbdba..ab56e73 100644
@@ -75,6 +75,7 @@ struct snd_usb_caiaqdev {
       wait_queue_head_t ep1_wait_queue;
       wait_queue_head_t prepare_wait_queue;
       int spec_received, audio_parm_answer;
+       int midi_out_active;
 
       char vendor_name[CAIAQ_USB_STR_LEN];
       char product_name[CAIAQ_USB_STR_LEN];
sound/usb/caiaq/caiaq-midi.c +2 -1
index 30b57f9..6b76f7f 100644
@@ -69,7 +69,8 @@ static void snd_usb_caiaq_midi_send(struct
 snd_usb_caiaqdev *dev,
 
       dev->midi_out_buf[0] = EP1_CMD_MIDI_WRITE;
       dev->midi_out_buf[1] = 0; /* port */
-       len = snd_rawmidi_transmit_peek(substream, dev->midi_out_buf+3,
 EP1_BUFSIZE-3);
+       len = snd_rawmidi_transmit(substream, dev->midi_out_buf + 3,
+                                  EP1_BUFSIZE - 3);
 
       if (len <= 0)
               return;
sound/usb/caiaq/caiaq-midi.c +7 -8
@@ -81,22 +82,21 @@ static void snd_usb_caiaq_midi_send(struct
 snd_usb_caiaqdev *dev,
       if (ret < 0)
               log("snd_usb_caiaq_midi_send(%p): usb_submit_urb() failed,
 %d\n",
                               substream, ret);
+       else
+               dev->midi_out_active = 1;
 }
 
 static void snd_usb_caiaq_midi_output_trigger(struct
 snd_rawmidi_substream *substream, int up)
 {
       struct snd_usb_caiaqdev *dev = substream->rmidi->private_data;
 
-       if (dev->midi_out_substream != NULL)
-               return;
-
-       if (!up) {
+       if (up) {
+               dev->midi_out_substream = substream;
+               if (!dev->midi_out_active)
+                       snd_usb_caiaq_midi_send(dev, substream);
+       } else {
               dev->midi_out_substream = NULL;
-               return;
       }
-
-       dev->midi_out_substream = substream;
-       snd_usb_caiaq_midi_send(dev, substream);

}

sound/usb/caiaq/caiaq-midi.c +1 -2
@@ -163,14 +163,13 @@ void snd_usb_caiaq_midi_output_done(struct urb* urb)
       struct snd_usb_caiaqdev *dev = urb->context;
       char *buf = urb->transfer_buffer;
 
+       dev->midi_out_active = 0;
       if (urb->status != 0)
               return;
 
       if (!dev->midi_out_substream)
               return;
 
-       snd_rawmidi_transmit_ack(dev->midi_out_substream, buf[2]);
-       dev->midi_out_substream = NULL;
       snd_usb_caiaq_midi_send(dev, dev->midi_out_substream);
 }
 
#9 lore raw

At Thu, 8 Jan 2009 02:34:46 +0100,

Quoted 11 lines · Marco Santamaria

Unfortunately I have to correct my previous message.

After a load test with jack + qsynth + rosegarden (sample rate=88200, frames/ period=256, periods/buffer=3), using a 16 tracks midi file and a 29MB sound font, the following message appeared:

[ 1098.445807] ALSA /home/marco/build/linux-2.6.24-19-rt/alsa-1.0.17/

driver-patched/alsa-driver-1.0.17/usb/caiaq/../../alsa-kernel/usb/caiaq/ caiaq-midi.c:84: snd-usb-caiaq log: snd_usb_caiaq_midi_send(f64c66c0):
usb_submit_urb() failed, -22

Hmm... what about this version?

Takashi

---

sound/usb/caiaq/caiaq-device.h +1 -0
index f9fbdba..ab56e73 100644
@@ -75,6 +75,7 @@ struct snd_usb_caiaqdev {
 	wait_queue_head_t ep1_wait_queue;
 	wait_queue_head_t prepare_wait_queue;
 	int spec_received, audio_parm_answer;
+	int midi_out_active;
 
 	char vendor_name[CAIAQ_USB_STR_LEN];
 	char product_name[CAIAQ_USB_STR_LEN];
sound/usb/caiaq/caiaq-midi.c +18 -13
index 30b57f9..18bbe38 100644
@@ -59,6 +59,11 @@ static int snd_usb_caiaq_midi_output_open(struct snd_rawmidi_substream *substrea
 
 static int snd_usb_caiaq_midi_output_close(struct snd_rawmidi_substream *substream)
 {
+	struct snd_usb_caiaqdev *dev = substream->rmidi->private_data;
+	if (dev->midi_out_active) {
+		usb_kill_urb(&dev->midi_out_urb);
+		dev->midi_out_active = 0;
+	}
 	return 0;
 }
 
@@ -69,7 +74,8 @@ static void snd_usb_caiaq_midi_send(struct snd_usb_caiaqdev *dev,
 	
 	dev->midi_out_buf[0] = EP1_CMD_MIDI_WRITE;
 	dev->midi_out_buf[1] = 0; /* port */
-	len = snd_rawmidi_transmit_peek(substream, dev->midi_out_buf+3, EP1_BUFSIZE-3);
+	len = snd_rawmidi_transmit(substream, dev->midi_out_buf + 3,
+				   EP1_BUFSIZE - 3);
 	
 	if (len <= 0)
 		return;
@@ -79,24 +85,24 @@ static void snd_usb_caiaq_midi_send(struct snd_usb_caiaqdev *dev,
 	
 	ret = usb_submit_urb(&dev->midi_out_urb, GFP_ATOMIC);
 	if (ret < 0)
-		log("snd_usb_caiaq_midi_send(%p): usb_submit_urb() failed, %d\n",
-				substream, ret);
+		log("snd_usb_caiaq_midi_send(%p): usb_submit_urb() failed,"
+		    "ret=%d, len=%d\n",
+		    substream, ret, len);
+	else
+		dev->midi_out_active = 1;
 }
 
 static void snd_usb_caiaq_midi_output_trigger(struct snd_rawmidi_substream *substream, int up)
 {
 	struct snd_usb_caiaqdev *dev = substream->rmidi->private_data;
 	
-	if (dev->midi_out_substream != NULL)
-		return;
-	
-	if (!up) {
+	if (up) {
+		dev->midi_out_substream = substream;
+		if (!dev->midi_out_active)
+			snd_usb_caiaq_midi_send(dev, substream);
+	} else {
 		dev->midi_out_substream = NULL;
-		return;
 	}
-	
-	dev->midi_out_substream = substream;
-	snd_usb_caiaq_midi_send(dev, substream);
 }
 
 
@@ -163,14 +169,13 @@ void snd_usb_caiaq_midi_output_done(struct urb* urb)
 	struct snd_usb_caiaqdev *dev = urb->context;
       	char *buf = urb->transfer_buffer;
 	
+	dev->midi_out_active = 0;
 	if (urb->status != 0)
 		return;
 
 	if (!dev->midi_out_substream)
 		return;
 
-	snd_rawmidi_transmit_ack(dev->midi_out_substream, buf[2]);
-	dev->midi_out_substream = NULL;
 	snd_usb_caiaq_midi_send(dev, dev->midi_out_substream);
 }
#10 lore raw

Hi,

I tried the last patch, and I think we got it. I made some few tests, and every thing is Ok for me now. No more crash, no more messages in dmesg. I just had a warning during compilation, but I think this is not really important :

sound/usb/caiaq/caiaq-midi.c: In function \u2018snd_usb_caiaq_midi_output_done\u2019:
sound/usb/caiaq/caiaq-midi.c:170: attention : unused variable \u2018buf\u2019

Perhaps this is not the same line (170) as you but, in my file, it concerns the last function.

Thank you very much for your help !

Cheers,

Mysth-R
2009/1/8 Takashi Iwai <[email protected]>

Quoted 120 lines

At Thu, 8 Jan 2009 02:34:46 +0100,

Quoted 4 lines · Marco Santamaria

Unfortunately I have to correct my previous message.

After a load test with jack + qsynth + rosegarden (sample rate=88200,

frames/

Quoted 1 line

period=256, periods/buffer=3), using a 16 tracks midi file and a 29MB

sound

Quoted 6 lines

font, the following message appeared:

[ 1098.445807] ALSA /home/marco/build/linux-2.6.24-19-rt/alsa-1.0.17/

driver-patched/alsa-driver-1.0.17/usb/caiaq/../../alsa-kernel/usb/caiaq/ caiaq-midi.c:84: snd-usb-caiaq log: snd_usb_caiaq_midi_send(f64c66c0):
usb_submit_urb() failed, -22

Hmm... what about this version?

Takashi

---

sound/usb/caiaq/caiaq-device.h +1 -0
index f9fbdba..ab56e73 100644
@@ -75,6 +75,7 @@ struct snd_usb_caiaqdev {
       wait_queue_head_t ep1_wait_queue;
       wait_queue_head_t prepare_wait_queue;
       int spec_received, audio_parm_answer;
+       int midi_out_active;
 
       char vendor_name[CAIAQ_USB_STR_LEN];
       char product_name[CAIAQ_USB_STR_LEN];
sound/usb/caiaq/caiaq-midi.c +0 -0
index 30b57f9..18bbe38 100644
@@ -59,6 +59,11 @@ static int snd_usb_caiaq_midi_output_open(struct

snd_rawmidi_substream *substrea

static int snd_usb_caiaq_midi_output_close(struct snd_rawmidi_substream
*substream)
{

sound/usb/caiaq/caiaq-midi.c +7 -1
+       struct snd_usb_caiaqdev *dev = substream->rmidi->private_data;
+       if (dev->midi_out_active) {
+               usb_kill_urb(&dev->midi_out_urb);
+               dev->midi_out_active = 0;
+       }
       return 0;
 }
@@ -69,7 +74,8 @@ static void snd_usb_caiaq_midi_send(struct
 snd_usb_caiaqdev *dev,
 
       dev->midi_out_buf[0] = EP1_CMD_MIDI_WRITE;
       dev->midi_out_buf[1] = 0; /* port */
-       len = snd_rawmidi_transmit_peek(substream, dev->midi_out_buf+3,
 EP1_BUFSIZE-3);
+       len = snd_rawmidi_transmit(substream, dev->midi_out_buf + 3,
+                                  EP1_BUFSIZE - 3);
 
       if (len <= 0)
               return;
sound/usb/caiaq/caiaq-midi.c +10 -10
@@ -79,24 +85,24 @@ static void snd_usb_caiaq_midi_send(struct
 snd_usb_caiaqdev *dev,
 
       ret = usb_submit_urb(&dev->midi_out_urb, GFP_ATOMIC);
        if (ret < 0)
-               log("snd_usb_caiaq_midi_send(%p): usb_submit_urb() failed,
 %d\n",
-                               substream, ret);
+               log("snd_usb_caiaq_midi_send(%p): usb_submit_urb() failed,"
+                   "ret=%d, len=%d\n",
+                   substream, ret, len);
+       else
+               dev->midi_out_active = 1;
 }
 
 static void snd_usb_caiaq_midi_output_trigger(struct snd_rawmidi_substream
 *substream, int up)
 {
       struct snd_usb_caiaqdev *dev = substream->rmidi->private_data;
 
-       if (dev->midi_out_substream != NULL)
-               return;
-
-       if (!up) {
+       if (up) {
+               dev->midi_out_substream = substream;
+               if (!dev->midi_out_active)
+                       snd_usb_caiaq_midi_send(dev, substream);
+       } else {
               dev->midi_out_substream = NULL;
-               return;
       }
-
-       dev->midi_out_substream = substream;
-       snd_usb_caiaq_midi_send(dev, substream);

}

sound/usb/caiaq/caiaq-midi.c +1 -2
@@ -163,14 +169,13 @@ void snd_usb_caiaq_midi_output_done(struct urb* urb)
        struct snd_usb_caiaqdev *dev = urb->context;
       char *buf = urb->transfer_buffer;
 
+       dev->midi_out_active = 0;
       if (urb->status != 0)
               return;
 
       if (!dev->midi_out_substream)
               return;
 
-       snd_rawmidi_transmit_ack(dev->midi_out_substream, buf[2]);
-       dev->midi_out_substream = NULL;
       snd_usb_caiaq_midi_send(dev, dev->midi_out_substream);
 }
 
Signature · 11 lines
*
***************************************************************************************
*  {^_^} Mysth-R {^_^}
*  <= Aide Auditive =>
*
* http://myspace.com/mysthr
* http://myspace.com/aideauditive
* http://mysthr.free.fr/Joomla  => Site dédié à l'audio sous
Fedora/PlanetCCRMA.
*
***************************************************************************************
#11 lore raw

At Thu, 8 Jan 2009 15:26:39 +0100,

Quoted 8 lines · Mysth-R

Hi,

I tried the last patch, and I think we got it. I made some few tests, and every thing is Ok for me now. No more crash, no more messages in dmesg. I just had a warning during compilation, but I think this is not really important :

Quoted 6 lines

sound/usb/caiaq/caiaq-midi.c: In function \u2018snd_usb_caiaq_midi_output_done \u2019:
sound/usb/caiaq/caiaq-midi.c:170: attention : unused variable \u2018buf\u2019

Perhaps this is not the same line (170) as you but, in my file, it concerns the last function.

OK, it's simple to fix.
The below is the latest version I committed now to sound git tree. It'll be pushed to 2.6.29 (and stable kernels) later.

Please let me know if you still encounter relevant problems.

thanks,

Takashi

---

sound/usb/caiaq/caiaq-device.h +1 -0
index f9fbdba..ab56e73 100644
@@ -75,6 +75,7 @@ struct snd_usb_caiaqdev {
 	wait_queue_head_t ep1_wait_queue;
 	wait_queue_head_t prepare_wait_queue;
 	int spec_received, audio_parm_answer;
+	int midi_out_active;
 
 	char vendor_name[CAIAQ_USB_STR_LEN];
 	char product_name[CAIAQ_USB_STR_LEN];
sound/usb/caiaq/caiaq-midi.c +18 -14
index 30b57f9..f19fd36 100644
@@ -59,6 +59,11 @@ static int snd_usb_caiaq_midi_output_open(struct snd_rawmidi_substream *substrea
 
 static int snd_usb_caiaq_midi_output_close(struct snd_rawmidi_substream *substream)
 {
+	struct snd_usb_caiaqdev *dev = substream->rmidi->private_data;
+	if (dev->midi_out_active) {
+		usb_kill_urb(&dev->midi_out_urb);
+		dev->midi_out_active = 0;
+	}
 	return 0;
 }
 
@@ -69,7 +74,8 @@ static void snd_usb_caiaq_midi_send(struct snd_usb_caiaqdev *dev,
 	
 	dev->midi_out_buf[0] = EP1_CMD_MIDI_WRITE;
 	dev->midi_out_buf[1] = 0; /* port */
-	len = snd_rawmidi_transmit_peek(substream, dev->midi_out_buf+3, EP1_BUFSIZE-3);
+	len = snd_rawmidi_transmit(substream, dev->midi_out_buf + 3,
+				   EP1_BUFSIZE - 3);
 	
 	if (len <= 0)
 		return;
@@ -79,24 +85,24 @@ static void snd_usb_caiaq_midi_send(struct snd_usb_caiaqdev *dev,
 	
 	ret = usb_submit_urb(&dev->midi_out_urb, GFP_ATOMIC);
 	if (ret < 0)
-		log("snd_usb_caiaq_midi_send(%p): usb_submit_urb() failed, %d\n",
-				substream, ret);
+		log("snd_usb_caiaq_midi_send(%p): usb_submit_urb() failed,"
+		    "ret=%d, len=%d\n",
+		    substream, ret, len);
+	else
+		dev->midi_out_active = 1;
 }
 
 static void snd_usb_caiaq_midi_output_trigger(struct snd_rawmidi_substream *substream, int up)
 {
 	struct snd_usb_caiaqdev *dev = substream->rmidi->private_data;
 	
-	if (dev->midi_out_substream != NULL)
-		return;
-	
-	if (!up) {
+	if (up) {
+		dev->midi_out_substream = substream;
+		if (!dev->midi_out_active)
+			snd_usb_caiaq_midi_send(dev, substream);
+	} else {
 		dev->midi_out_substream = NULL;
-		return;
 	}
-	
-	dev->midi_out_substream = substream;
-	snd_usb_caiaq_midi_send(dev, substream);
 }
 
 
@@ -161,16 +167,14 @@ int snd_usb_caiaq_midi_init(struct snd_usb_caiaqdev *device)
 void snd_usb_caiaq_midi_output_done(struct urb* urb)
 {
 	struct snd_usb_caiaqdev *dev = urb->context;
-      	char *buf = urb->transfer_buffer;
 	
+	dev->midi_out_active = 0;
 	if (urb->status != 0)
 		return;
 
 	if (!dev->midi_out_substream)
 		return;
 
-	snd_rawmidi_transmit_ack(dev->midi_out_substream, buf[2]);
-	dev->midi_out_substream = NULL;
 	snd_usb_caiaq_midi_send(dev, dev->midi_out_substream);
 }
#12 lore raw
Quoted 4 lines

OK, it's simple to fix.
The below is the latest version I committed now to sound git tree. It'll be pushed to 2.6.29 (and stable kernels) later.

Ok cool !

Quoted 3 lines

Please let me know if you still encounter relevant problems.

No problem... Thank you again for your help.

By the way is there any plan to make buttons and lights to work on the Audio Kontrol 1 ? It could be a really cool feature.
Cheers,
Mysth-R

---

sound/usb/caiaq/caiaq-device.h +1 -0
index f9fbdba..ab56e73 100644
@@ -75,6 +75,7 @@ struct snd_usb_caiaqdev {
       wait_queue_head_t ep1_wait_queue;
       wait_queue_head_t prepare_wait_queue;
       int spec_received, audio_parm_answer;
+       int midi_out_active;
 
       char vendor_name[CAIAQ_USB_STR_LEN];
       char product_name[CAIAQ_USB_STR_LEN];
sound/usb/caiaq/caiaq-midi.c +0 -0
Quoted 87 lines

index 30b57f9..f19fd36 100644

sound/usb/caiaq/caiaq-midi.c +0 -0
@@ -59,6 +59,11 @@ static int snd_usb_caiaq_midi_output_open(struct

snd_rawmidi_substream *substrea

static int snd_usb_caiaq_midi_output_close(struct snd_rawmidi_substream
*substream)
{

sound/usb/caiaq/caiaq-midi.c +7 -1
+       struct snd_usb_caiaqdev *dev = substream->rmidi->private_data;
+       if (dev->midi_out_active) {
+               usb_kill_urb(&dev->midi_out_urb);
+               dev->midi_out_active = 0;
+       }
       return 0;
 }
@@ -69,7 +74,8 @@ static void snd_usb_caiaq_midi_send(struct
 snd_usb_caiaqdev *dev,
 
       dev->midi_out_buf[0] = EP1_CMD_MIDI_WRITE;
       dev->midi_out_buf[1] = 0; /* port */
-       len = snd_rawmidi_transmit_peek(substream, dev->midi_out_buf+3,
 EP1_BUFSIZE-3);
+       len = snd_rawmidi_transmit(substream, dev->midi_out_buf + 3,
+                                  EP1_BUFSIZE - 3);
 
       if (len <= 0)
               return;
sound/usb/caiaq/caiaq-midi.c +10 -10
@@ -79,24 +85,24 @@ static void snd_usb_caiaq_midi_send(struct
 snd_usb_caiaqdev *dev,
 
       ret = usb_submit_urb(&dev->midi_out_urb, GFP_ATOMIC);
       if (ret < 0)
-               log("snd_usb_caiaq_midi_send(%p): usb_submit_urb() failed,
 %d\n",
-                               substream, ret);
+               log("snd_usb_caiaq_midi_send(%p): usb_submit_urb() failed,"
+                   "ret=%d, len=%d\n",
+                   substream, ret, len);
+       else
+               dev->midi_out_active = 1;
 }
 
 static void snd_usb_caiaq_midi_output_trigger(struct snd_rawmidi_substream
 *substream, int up)
 {
       struct snd_usb_caiaqdev *dev = substream->rmidi->private_data;
 
-       if (dev->midi_out_substream != NULL)
-               return;
-
-       if (!up) {
+       if (up) {
+               dev->midi_out_substream = substream;
+               if (!dev->midi_out_active)
+                       snd_usb_caiaq_midi_send(dev, substream);
+       } else {
               dev->midi_out_substream = NULL;
-               return;
       }
-
-       dev->midi_out_substream = substream;
-       snd_usb_caiaq_midi_send(dev, substream);

}

sound/usb/caiaq/caiaq-midi.c +1 -3
@@ -161,16 +167,14 @@ int snd_usb_caiaq_midi_init(struct snd_usb_caiaqdev
 *device)
 void snd_usb_caiaq_midi_output_done(struct urb* urb)
 {
       struct snd_usb_caiaqdev *dev = urb->context;
-       char *buf = urb->transfer_buffer;
 
+       dev->midi_out_active = 0;
       if (urb->status != 0)
               return;
 
       if (!dev->midi_out_substream)
               return;
 
-       snd_rawmidi_transmit_ack(dev->midi_out_substream, buf[2]);
-       dev->midi_out_substream = NULL;
       snd_usb_caiaq_midi_send(dev, dev->midi_out_substream);
 }
Signature · 11 lines
*
***************************************************************************************
*  {^_^} Mysth-R {^_^}
*  <= Aide Auditive =>
*
* http://myspace.com/mysthr
* http://myspace.com/aideauditive
* http://mysthr.free.fr/Joomla  => Site dédié à l'audio sous
Fedora/PlanetCCRMA.
*
***************************************************************************************
#13 lore raw

At Thu, 8 Jan 2009 15:43:22 +0100,

Quoted 5 lines · Mysth-R

OK, it's simple to fix.
The below is the latest version I committed now to sound git tree. It'll be pushed to 2.6.29 (and stable kernels) later.

Quoted 7 lines

Ok cool !

Please let me know if you still encounter relevant problems.

No problem... Thank you again for your help.
By the way is there any plan to make buttons and lights to work on the Audio Kontrol 1 ? It could be a really cool feature.

This is rather a question to Daniel... :)

Takashi

#14 lore raw
In reply to Mysth-R
Quoted 5 lines · Mysth-R
Quoted 3 lines

Please let me know if you still encounter relevant problems.

No problem... Thank you again for your help.

By the way is there any plan to make buttons and lights to work on the Audio Kontrol 1 ? It could be a really cool feature.

That's done already: Buttons are exported as Linux input device (if enabled in kernel config) and LEDs can be controlled using the ALSA controllers API (amixer and friends). Did you try that?

Best regards,
Daniel

#15 lore raw
In reply to Takashi Iwai

I can confirm, after another load test with midi applications (that caused rosegarden and jack to crash several times...), that the last patch works without error messages.

Which version of alsa corresponds to kernel 2.6.29?

Thanks again,

Marco

2009/1/8 Takashi Iwai <[email protected]>

Quoted 133 lines

At Thu, 8 Jan 2009 15:26:39 +0100,

Quoted 9 lines · Mysth-R

Hi,

I tried the last patch, and I think we got it. I made some few tests, and every thing is Ok for me now. No more crash, no more messages in dmesg. I just had a warning during compilation, but I think this is not really important :

sound/usb/caiaq/caiaq-midi.c: In function

\u2018snd_usb_caiaq_midi_output_done

Quoted 2 lines

\u2019:
sound/usb/caiaq/caiaq-midi.c:170: attention : unused variable

\u2018buf\u2019

Quoted 2 lines

Perhaps this is not the same line (170) as you but, in my file, it

concerns

Quoted 1 line

the last function.

OK, it's simple to fix.
The below is the latest version I committed now to sound git tree. It'll be pushed to 2.6.29 (and stable kernels) later.

Please let me know if you still encounter relevant problems.

thanks,

Takashi

---

sound/usb/caiaq/caiaq-device.h +1 -0
index f9fbdba..ab56e73 100644
@@ -75,6 +75,7 @@ struct snd_usb_caiaqdev {
       wait_queue_head_t ep1_wait_queue;
       wait_queue_head_t prepare_wait_queue;
       int spec_received, audio_parm_answer;
+       int midi_out_active;
 
       char vendor_name[CAIAQ_USB_STR_LEN];
       char product_name[CAIAQ_USB_STR_LEN];
sound/usb/caiaq/caiaq-midi.c +0 -0
index 30b57f9..f19fd36 100644
@@ -59,6 +59,11 @@ static int snd_usb_caiaq_midi_output_open(struct

snd_rawmidi_substream *substrea

static int snd_usb_caiaq_midi_output_close(struct snd_rawmidi_substream
*substream)
{

sound/usb/caiaq/caiaq-midi.c +7 -1
+       struct snd_usb_caiaqdev *dev = substream->rmidi->private_data;
+       if (dev->midi_out_active) {
+               usb_kill_urb(&dev->midi_out_urb);
+               dev->midi_out_active = 0;
+       }
       return 0;
 }
@@ -69,7 +74,8 @@ static void snd_usb_caiaq_midi_send(struct
 snd_usb_caiaqdev *dev,
 
       dev->midi_out_buf[0] = EP1_CMD_MIDI_WRITE;
       dev->midi_out_buf[1] = 0; /* port */
-       len = snd_rawmidi_transmit_peek(substream, dev->midi_out_buf+3,
 EP1_BUFSIZE-3);
+       len = snd_rawmidi_transmit(substream, dev->midi_out_buf + 3,
+                                  EP1_BUFSIZE - 3);
 
       if (len <= 0)
               return;
sound/usb/caiaq/caiaq-midi.c +10 -10
@@ -79,24 +85,24 @@ static void snd_usb_caiaq_midi_send(struct
 snd_usb_caiaqdev *dev,
 
       ret = usb_submit_urb(&dev->midi_out_urb, GFP_ATOMIC);
       if (ret < 0)
-               log("snd_usb_caiaq_midi_send(%p): usb_submit_urb() failed,
 %d\n",
-                               substream, ret);
+               log("snd_usb_caiaq_midi_send(%p): usb_submit_urb() failed,"
+                   "ret=%d, len=%d\n",
+                   substream, ret, len);
+       else
+               dev->midi_out_active = 1;
 }
 
 static void snd_usb_caiaq_midi_output_trigger(struct snd_rawmidi_substream
 *substream, int up)
 {
       struct snd_usb_caiaqdev *dev = substream->rmidi->private_data;
 
-       if (dev->midi_out_substream != NULL)
-               return;
-
-       if (!up) {
+       if (up) {
+               dev->midi_out_substream = substream;
+               if (!dev->midi_out_active)
+                       snd_usb_caiaq_midi_send(dev, substream);
+       } else {
               dev->midi_out_substream = NULL;
-               return;
       }
-
-       dev->midi_out_substream = substream;
-       snd_usb_caiaq_midi_send(dev, substream);

}

sound/usb/caiaq/caiaq-midi.c +1 -3
@@ -161,16 +167,14 @@ int snd_usb_caiaq_midi_init(struct snd_usb_caiaqdev
 *device)
 void snd_usb_caiaq_midi_output_done(struct urb* urb)
 {
       struct snd_usb_caiaqdev *dev = urb->context;
-       char *buf = urb->transfer_buffer;
 
+       dev->midi_out_active = 0;
       if (urb->status != 0)
               return;
 
       if (!dev->midi_out_substream)
               return;
 
-       snd_rawmidi_transmit_ack(dev->midi_out_substream, buf[2]);
-       dev->midi_out_substream = NULL;
       snd_usb_caiaq_midi_send(dev, dev->midi_out_substream);
 }
Acked-by
#16 lore raw
In reply to Takashi Iwai

Hi Takashi,

Quoted 8 lines · Takashi Iwai
Quoted 8 lines

every thing is Ok for me now. No more crash, no more messages in dmesg. I just had a warning during compilation, but I think this is not really important :

sound/usb/caiaq/caiaq-midi.c: In function \u2018snd_usb_caiaq_midi_output_done \u2019:
sound/usb/caiaq/caiaq-midi.c:170: attention : unused variable \u2018buf\u2019

Quoted 6 lines
Quoted 2 lines

Perhaps this is not the same line (170) as you but, in my file, it concerns the last function.

OK, it's simple to fix.
The below is the latest version I committed now to sound git tree. It'll be pushed to 2.6.29 (and stable kernels) later.

Thanks a lot for your help - I was on vacation until now and had very limited ways to follow that thread. I would, however, apprectiate the driver version number would be increased for this change, as it makes tracking of user error reports better trackable.

Do you want me to send in a patch for that or is it easier if you do it yourself?

Thanks and best regards,
Daniel

Quoted 82 lines

---

sound/usb/caiaq/caiaq-device.h +1 -0
index f9fbdba..ab56e73 100644
@@ -75,6 +75,7 @@ struct snd_usb_caiaqdev {
 	wait_queue_head_t ep1_wait_queue;
 	wait_queue_head_t prepare_wait_queue;
 	int spec_received, audio_parm_answer;
+	int midi_out_active;
 
 	char vendor_name[CAIAQ_USB_STR_LEN];
 	char product_name[CAIAQ_USB_STR_LEN];
sound/usb/caiaq/caiaq-midi.c +18 -12
index 30b57f9..f19fd36 100644
@@ -59,6 +59,11 @@ static int snd_usb_caiaq_midi_output_open(struct snd_rawmidi_substream *substrea
 
 static int snd_usb_caiaq_midi_output_close(struct snd_rawmidi_substream *substream)
 {
+	struct snd_usb_caiaqdev *dev = substream->rmidi->private_data;
+	if (dev->midi_out_active) {
+		usb_kill_urb(&dev->midi_out_urb);
+		dev->midi_out_active = 0;
+	}
 	return 0;
 }
 
@@ -69,7 +74,8 @@ static void snd_usb_caiaq_midi_send(struct snd_usb_caiaqdev *dev,
 
 	dev->midi_out_buf[0] = EP1_CMD_MIDI_WRITE;
 	dev->midi_out_buf[1] = 0; /* port */
-	len = snd_rawmidi_transmit_peek(substream, dev->midi_out_buf+3, EP1_BUFSIZE-3);
+	len = snd_rawmidi_transmit(substream, dev->midi_out_buf + 3,
+				   EP1_BUFSIZE - 3);
 
 	if (len <= 0)
 		return;
@@ -79,24 +85,24 @@ static void snd_usb_caiaq_midi_send(struct snd_usb_caiaqdev *dev,
 
 	ret = usb_submit_urb(&dev->midi_out_urb, GFP_ATOMIC);
 	if (ret < 0)
-		log("snd_usb_caiaq_midi_send(%p): usb_submit_urb() failed, %d\n",
-				substream, ret);
+		log("snd_usb_caiaq_midi_send(%p): usb_submit_urb() failed,"
+		    "ret=%d, len=%d\n",
+		    substream, ret, len);
+	else
+		dev->midi_out_active = 1;
 }
 
 static void snd_usb_caiaq_midi_output_trigger(struct snd_rawmidi_substream *substream, int up)
 {
 	struct snd_usb_caiaqdev *dev = substream->rmidi->private_data;
 
-	if (dev->midi_out_substream != NULL)
-		return;
-	
-	if (!up) {
+	if (up) {
+		dev->midi_out_substream = substream;
+		if (!dev->midi_out_active)
+			snd_usb_caiaq_midi_send(dev, substream);
+	} else {
 		dev->midi_out_substream = NULL;
-		return;
 	}
-	
-	dev->midi_out_substream = substream;
-	snd_usb_caiaq_midi_send(dev, substream);
 }
 
 
@@ -161,16 +167,14 @@ int snd_usb_caiaq_midi_init(struct snd_usb_caiaqdev *device)
 void snd_usb_caiaq_midi_output_done(struct urb* urb)
 {
 	struct snd_usb_caiaqdev *dev = urb->context;
-      	char *buf = urb->transfer_buffer;
 
+	dev->midi_out_active = 0;
 	if (urb->status != 0)

sound/usb/caiaq/caiaq-midi.c int snd_usb_caiaq_midi_init(struct snd_usb_caiaqdev *device) · line 180

Quoted 10 lines
sound/usb/caiaq/caiaq-midi.c +0 -2
 		return;
 
 	if (!dev->midi_out_substream)
 		return;
 
-	snd_rawmidi_transmit_ack(dev->midi_out_substream, buf[2]);
-	dev->midi_out_substream = NULL;
 	snd_usb_caiaq_midi_send(dev, dev->midi_out_substream);
 }
 
#17 lore raw

At Thu, 8 Jan 2009 23:11:53 +0100,

Quoted 19 lines · Daniel Mack

Hi Takashi,

Quoted 8 lines · Takashi Iwai
Quoted 8 lines

every thing is Ok for me now. No more crash, no more messages in dmesg. I just had a warning during compilation, but I think this is not really important :

sound/usb/caiaq/caiaq-midi.c: In function \u2018snd_usb_caiaq_midi_output_done \u2019:
sound/usb/caiaq/caiaq-midi.c:170: attention : unused variable \u2018buf\u2019

Quoted 6 lines
Quoted 2 lines

Perhaps this is not the same line (170) as you but, in my file, it concerns the last function.

OK, it's simple to fix.
The below is the latest version I committed now to sound git tree. It'll be pushed to 2.6.29 (and stable kernels) later.

Quoted 7 lines

Thanks a lot for your help - I was on vacation until now and had very limited ways to follow that thread. I would, however, apprectiate the driver version number would be increased for this change, as it makes tracking of user error reports better trackable.

Do you want me to send in a patch for that or is it easier if you do it yourself?

I increased the version to 1.3.10 now.

thanks,

Takashi

#18 lore raw

During a Rosegarden session a qsampler crash caused the following output in dmesg:

[11530.642970] qsampler[22794]: segfault at 00000008 eip b73f52c5 esp
bfe77e20 error 4
[13278.161113] ALSA
/home/marco/build/alsa-1.0.17/linux-2.6.24-23-rt/driver/alsa-driver-1.0.17/usb/caiaq/../../alsa-kernel/usb/caiaq/caiaq-midi.c:90:
snd-usb-caiaq log: snd_usb_caiaq_midi_send(f6d52b40): usb_submit_urb()
failed,ret=-22, len=61
[13720.859888] qjackctl.bin[22273]: segfault at 00000314 eip b7b07a7f esp

bfbe8f54 error 4

There are segmentation fault errors from qsampler and qjackctl, but perhaps there's also a problem in caiaq-midi.c .

Regards,
Marco

2009/1/9 Takashi Iwai <[email protected]>

Quoted 41 lines

At Thu, 8 Jan 2009 23:11:53 +0100,

Quoted 5 lines · Daniel Mack

Hi Takashi,

Quoted 1 line · Takashi Iwai
Quoted 1 line

every thing is Ok for me now. No more crash, no more messages in

dmesg.

Quoted 1 line
Quoted 1 line
Quoted 1 line

I just had a warning during compilation, but I think this is not

really

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

important :

sound/usb/caiaq/caiaq-midi.c: In function

\u2018snd_usb_caiaq_midi_output_done

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

\u2019:
sound/usb/caiaq/caiaq-midi.c:170: attention : unused variable

\u2018buf\u2019

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

Perhaps this is not the same line (170) as you but, in my file, it

concerns

Quoted 6 lines
Quoted 5 lines
Quoted 1 line

the last function.

OK, it's simple to fix.
The below is the latest version I committed now to sound git tree. It'll be pushed to 2.6.29 (and stable kernels) later.

Quoted 7 lines

Thanks a lot for your help - I was on vacation until now and had very limited ways to follow that thread. I would, however, apprectiate the driver version number would be increased for this change, as it makes tracking of user error reports better trackable.

Do you want me to send in a patch for that or is it easier if you do it yourself?

I increased the version to 1.3.10 now.

thanks,

Takashi

#19 lore raw

At Sat, 10 Jan 2009 13:53:24 +0100,

Quoted 11 lines · Marco Santamaria

During a Rosegarden session a qsampler crash caused the following output in dmesg:

[11530.642970] qsampler[22794]: segfault at 00000008 eip b73f52c5 esp bfe77e20
error 4
[13278.161113] ALSA /home/marco/build/alsa-1.0.17/linux-2.6.24-23-rt/driver/
alsa-driver-1.0.17/usb/caiaq/../../alsa-kernel/usb/caiaq/caiaq-midi.c:90:
snd-usb-caiaq log: snd_usb_caiaq_midi_send(f6d52b40): usb_submit_urb()
failed,ret=-22, len=61
[13720.859888] qjackctl.bin[22273]: segfault at 00000314 eip b7b07a7f esp
Quoted 4 lines

bfbe8f54 error 4

There are segmentation fault errors from qsampler and qjackctl, but perhaps there's also a problem in caiaq-midi.c .

Might be, but difficult to judge as now since the error seems happening after qsampler, and the urb error itself seems non-critical.

Takashi

Quoted 47 lines

Regards,
Marco

2009/1/9 Takashi Iwai <[email protected]>

At Thu, 8 Jan 2009 23:11:53 +0100,
Daniel Mack wrote:
>
> Hi Takashi,
>
> On Thu, Jan 08, 2009 at 03:37:30PM +0100, Takashi Iwai wrote:
> > > every thing is Ok for me now. No more crash, no more messages in dmesg.
> > > I just had a warning during compilation, but I think this is not really
> > > important :
> > >
> > > sound/usb/caiaq/caiaq-midi.c: In function \
u2018snd_usb_caiaq_midi_output_done
> > > \u2019:
> > > sound/usb/caiaq/caiaq-midi.c:170: attention : unused variable \
u2018buf\u2019
> > >
> > > Perhaps this is not the same line (170) as you but, in my file, it concerns
> > > the last function.
> >
> > OK, it's simple to fix.
> > The below is the latest version I committed now to sound git tree. > > It'll be pushed to 2.6.29 (and stable kernels) later.
>
> Thanks a lot for your help - I was on vacation until now and had very > limited ways to follow that thread. I would, however, apprectiate the > driver version number would be increased for this change, as it makes > tracking of user error reports better trackable.
>
> Do you want me to send in a patch for that or is it easier if you do > it yourself?

I increased the version to 1.3.10 now.

thanks,

Takashi

#20 lore raw

I wanted to report this, just in case it was related to the patch you made to solve our problem.

Thank you very much,

Marco

2009/1/11 Takashi Iwai <[email protected]>

Quoted 85 lines

At Sat, 10 Jan 2009 13:53:24 +0100,

Quoted 2 lines · Marco Santamaria

During a Rosegarden session a qsampler crash caused the following output

in

Quoted 3 lines

dmesg:

[11530.642970] qsampler[22794]: segfault at 00000008 eip b73f52c5 esp

bfe77e20

Quoted 2 lines

error 4

[13278.161113] ALSA

/home/marco/build/alsa-1.0.17/linux-2.6.24-23-rt/driver/

Quoted 7 lines

alsa-driver-1.0.17/usb/caiaq/../../alsa-kernel/usb/caiaq/caiaq-midi.c:90:
snd-usb-caiaq log: snd_usb_caiaq_midi_send(f6d52b40): usb_submit_urb() failed,ret=-22, len=61

[13720.859888] qjackctl.bin[22273]: segfault at 00000314 eip b7b07a7f esp

bfbe8f54 error 4

There are segmentation fault errors from qsampler and qjackctl, but

perhaps

Quoted 1 line

there's also a problem in caiaq-midi.c .

Might be, but difficult to judge as now since the error seems happening after qsampler, and the urb error itself seems non-critical.

Takashi

Quoted 6 lines

Regards,
Marco

2009/1/9 Takashi Iwai <[email protected]>

Quoted 7 lines
    At Thu, 8 Jan 2009 23:11:53 +0100,
    Daniel Mack wrote:
    >
    > Hi Takashi,
    >
    > On Thu, Jan 08, 2009 at 03:37:30PM +0100, Takashi Iwai wrote:
    > > > every thing is Ok for me now. No more crash, no more messages

in

Quoted 2 lines

dmesg.
> > > I just had a warning during compilation, but I think this is

not

Quoted 10 lines
    really
    > > > important :
    > > >
    > > > sound/usb/caiaq/caiaq-midi.c: In function \
    u2018snd_usb_caiaq_midi_output_done
    > > > \u2019:
    > > > sound/usb/caiaq/caiaq-midi.c:170: attention : unused variable \
    u2018buf\u2019
    > > >
    > > > Perhaps this is not the same line (170) as you but, in my file,

it

Quoted 5 lines

concerns
> > > the last function.
> >
> > OK, it's simple to fix.
> > The below is the latest version I committed now to sound git

tree.

Quoted 3 lines
Quoted 3 lines
Quoted 1 line

It'll be pushed to 2.6.29 (and stable kernels) later.

Thanks a lot for your help - I was on vacation until now and had

very

Quoted 1 line
Quoted 1 line

limited ways to follow that thread. I would, however, apprectiate

the

Quoted 1 line
Quoted 1 line

driver version number would be increased for this change, as it

makes

Quoted 3 lines
Quoted 3 lines

tracking of user error reports better trackable.

Do you want me to send in a patch for that or is it easier if you

do

Quoted 9 lines
Quoted 1 line

it yourself?

I increased the version to 1.3.10 now.

thanks,

Takashi