snd-usb-usx2y 0.8.0 against alsa-kernel cvshead: OHCI doesn't crash anymore
PATCH 1/1 snd-usb-usx2y 0.8.0 against alsa-kernel cvshead: OHCI doesn't crash anymore
Summary: Prevents crashes when communicating over ohci usb-hcds.
Work on this started, when rumors spread that ohci equipped machines would crash.
This was due to me missing two facts:
1) Ohci has a bigger usb frame number wrap around.
2) It only supports URB_ISO_ASAP when submitting iso urbs. Fixed now.
Usb-traffic for playback starts now in the prepare callback, like it previously only did for capture.
As a side effect code became simpler and smaller.
At Thu, 30 Sep 2004 20:46:29 +0200,
Quoted 13 lines · Karsten Wiese
Summary: Prevents crashes when communicating over ohci usb-hcds.
Work on this started, when rumors spread that ohci equipped machines would crash.
This was due to me missing two facts:
1) Ohci has a bigger usb frame number wrap around.
2) It only supportsURB_ISO_ASAPwhen submitting iso urbs. Fixed now.
Usb-traffic for playback starts now in the prepare callback, like it previously only did for capture.
As a side effect code became simpler and smaller.
Quoted 1 line
Signed-off-by Karsten Wiese <[email protected]>
Thanks for the patch.
What is the purpose of the replacement with USX2Y_STATIC?
One thing I'm not sure is that the possible race of usX2Y_urbs_start() and usX2Y_subs_startup_finish(). Better to use complete handler?
Takashi
-------------------------------------------------------
This SF.net email is sponsored by: IT Product Guide on ITManagersJournal Use IT products in your business? Tell us what you think of them. Give us Your Opinions, Get Free ThinkGeek Gift Certificates! Click to find out more
http://productguide.itmanagersjournal.com/guidepromo.tmpl
Am Freitag 01 Oktober 2004 15:50 schrieb Takashi Iwai:
Quoted 3 lines
What is the purpose of the replacement with
USX2Y_STATIC?
Its for easier appliance of the patch, I sent a little later yesterday 22:01:50:
"[Alsa-devel] [PATCH]hwdep addon for raw usb mmap from userspace against snd-usb-usx2y 0.8.0 in alsa-kernel tree"
The addon needs the functions with the USX2Y_STATIC.
So the addon patch only needs to change
#define USX2Y_STATIC static to #define USX2Y_STATIC
.
Quoted 3 lines
One thing I'm not sure is that the possible race of
usX2Y_urbs_start()andusX2Y_subs_startup_finish(). Better to use complete handler?
Thanks for the hint. Will look at it again.
Karsten
-------------------------------------------------------
This SF.net email is sponsored by: IT Product Guide on ITManagersJournal Use IT products in your business? Tell us what you think of them. Give us Your Opinions, Get Free ThinkGeek Gift Certificates! Click to find out more
http://productguide.itmanagersjournal.com/guidepromo.tmpl
At Fri, 1 Oct 2004 18:28:32 +0200,
Quoted 11 lines · Karsten Wiese
Am Freitag 01 Oktober 2004 15:50 schrieb Takashi Iwai:
Quoted 3 lines
What is the purpose of the replacement with
USX2Y_STATIC?Its for easier appliance of the patch, I sent a little later yesterday 22:01:50:
"[Alsa-devel] [PATCH]hwdep addon for raw usb mmap from userspace against snd-usb-usx2y 0.8.0 in alsa-kernel tree"
The addon needs the functions with theUSX2Y_STATIC.
So the addon patch only needs to change
Quoted 4 lines
#define USX2Y_STATIC static to #define USX2Y_STATIC.
Well, this won't make the patch applicance easier at all.
If the second patch weren't accepted, it's because the patch does really bad indeed (e.g. written too dirty or conceptually wrong). Then USX2Y_STATIC in the first patch would be useless, anyway.
If the second patch were accepted, you can include static -> extern conversion in this patch without problems. Thus, having USX2Y_STATIC in the first patch isn't necessary, too.
In sort: You shouldn't sacrifice the right patch just because of others :)
Takashi
-------------------------------------------------------
This SF.net email is sponsored by: IT Product Guide on ITManagersJournal Use IT products in your business? Tell us what you think of them. Give us Your Opinions, Get Free ThinkGeek Gift Certificates! Click to find out more
http://productguide.itmanagersjournal.com/guidepromo.tmpl
PATCH 1/1 snd-usb-usx2y 0.8.1 against alsa-kernel cvshead: OHCI doesn't crash anymore
In reply to Takashi IwaiAm Freitag 01 Oktober 2004 15:50 schrieben Sie:
Quoted 1 line
What is the purpose of the replacement with
USX2Y_STATIC?
gone now.
Quoted 3 lines
One thing I'm not sure is that the possible race of
usX2Y_urbs_start()andusX2Y_subs_startup_finish(). Better to use complete handler?
did I care for any possible racing now?
Best,
Karsten
patch header:
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Summary: Prevents crashes when communicating over ohci usb-hcds.
Work on this started, when rumors spread that ohci equipped machines would crash.
This was due to me missing two facts:
1) Ohci has a bigger usb frame number wrap around.
2) It only supports URB_ISO_ASAP when submitting iso urbs. Fixed now.
Usb-traffic for playback starts now in the prepare callback, like it previously only did for capture.
As a side effect code became simpler and smaller.
<<<<
Re: [PATCH]snd-usb-usx2y 0.8.1 against alsa-kernel cvshead: OHCI doesn't crash anymore
At Sun, 3 Oct 2004 00:38:04 +0200,
Quoted 5 lines · Karsten Wiese
Quoted 3 lines
One thing I'm not sure is that the possible race of
usX2Y_urbs_start()andusX2Y_subs_startup_finish(). Better to use complete handler?did I care for any possible racing now?
You need to call spin_lock(&usX2Y->prepare_lock) before checking subs->prepared in usX2Y_urbs_start(). In this kind of implementation, all the access to subs->prepared should be protected in the spinlock to avoid races.
Also, the spin_lock(&usX2Y->prepare_lock) in usX2Y_urbs_start() may cause deadlock. Use spin_lock_irq(&usX2y->prepare_lock) instead.
Thanks,
Takashi
-------------------------------------------------------
This SF.net email is sponsored by: IT Product Guide on ITManagersJournal Use IT products in your business? Tell us what you think of them. Give us Your Opinions, Get Free ThinkGeek Gift Certificates! Click to find out more
http://productguide.itmanagersjournal.com/guidepromo.tmpl
Re: [PATCH]snd-usb-usx2y 0.8.1 against alsa-kernel cvshead: OHCI doesn't crash anymore
Am Montag 04 Oktober 2004 18:22 schrieb Takashi Iwai:
Quoted 8 lines
At Sun, 3 Oct 2004 00:38:04 +0200,
Quoted 4 lines · Karsten Wiese
Quoted 2 lines
One thing I'm not sure is that the possible race of
usX2Y_urbs_start()andusX2Y_subs_startup_finish(). Better to use complete handler?did I care for any possible racing now?
Quoted 8 lines
You need to call
spin_lock(&usX2Y->prepare_lock)before checkingsubs->preparedinusX2Y_urbs_start(). In this kind of implementation, all the access tosubs->preparedshould be protected in the spinlock to avoid races.Also, the
spin_lock(&usX2Y->prepare_lock)inusX2Y_urbs_start()may cause deadlock. Usespin_lock_irq(&usX2y->prepare_lock)instead.
Hi Takashi
No spinlock no more. atomic_t instead. Please check.
Rui, the error in your dmesg log: "Debug: sleeping function called from invalid context .... " should be gone with this.
thanks,
Karsten
patch header:
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Summary: Fixes crashes that occured when communicating over ohci usb-hcds.
Work on this started, when rumors spread that ohci equipped machines would crash.
This was due to me missing two facts:
1) Ohci has a bigger usb frame number wrap around.
2) It only supports URB_ISO_ASAP when submitting iso urbs. Fixed now.
<<<<
Re: [PATCH]snd-usb-usx2y 0.8.1 against alsa-kernel cvshead: OHCI doesn't crash anymore
At Mon, 18 Oct 2004 14:06:43 +0200,
Quoted 16 lines · Karsten Wiese
[1 <text/plain; iso-8859-1 (7bit)>]
Am Montag 04 Oktober 2004 18:22 schrieb Takashi Iwai:Quoted 13 lines
At Sun, 3 Oct 2004 00:38:04 +0200,
Quoted 4 lines · Karsten Wiese
Quoted 2 lines
One thing I'm not sure is that the possible race of
usX2Y_urbs_start()andusX2Y_subs_startup_finish(). Better to use complete handler?did I care for any possible racing now?
You need to call
spin_lock(&usX2Y->prepare_lock)before checkingsubs->preparedinusX2Y_urbs_start(). In this kind of implementation, all the access tosubs->preparedshould be protected in the spinlock to avoid races.
Quoted 6 lines
Quoted 3 lines
Also, the
spin_lock(&usX2Y->prepare_lock)inusX2Y_urbs_start()may cause deadlock. Usespin_lock_irq(&usX2y->prepare_lock)instead.Hi Takashi
No spinlock no more.
atomic_tinstead. Please check.
I'm afraid it's still racy.
In usX2Y_urbs_start(), the complete callback may be called between usb_submit_urb() and the loop of schedule_timeout().
So, the loop should check at first the condition before sleeping like below:
while (atomic_read(&subs->state) != state_PREPARED) {
timeout = schedule_timeout(timeout);
if (signal_pending(current))
...
if (! timeout)
...
}Regarding the new config stuff:
Let's kill CONFIG_SND_USB_USX2Y_NRPACKS_VARIABLE option. No one will want to disable such a module option.
Also, please avoid the Kconfig int value as much as possible if you want to support the driver for 2.2/2.4 kernels, too. I believe it's ok to put a hardcoded value 4 like usbaudio.c if you describe the module option properly in the document.
Takashi
-------------------------------------------------------
This SF.net email is sponsored by: IT Product Guide on ITManagersJournal Use IT products in your business? Tell us what you think of them. Give us Your Opinions, Get Free ThinkGeek Gift Certificates! Click to find out more
http://productguide.itmanagersjournal.com/guidepromo.tmpl
Re: [PATCH]snd-usb-usx2y 0.8.1 against alsa-kernel cvshead: OHCI doesn't crash anymore
Am Dienstag 19 Oktober 2004 15:33 schrieb Takashi Iwai:
Quoted 7 lines
I'm afraid it's still racy.
InusX2Y_urbs_start(), the complete callback may be called betweenusb_submit_urb()and the loop ofschedule_timeout().
So, the loop should check at first the condition before sleeping like below:
Quoted 8 lines
while (atomic_read(&subs->state) != state_PREPARED) {
timeout = schedule_timeout(timeout);
if (signal_pending(current))
...
if (! timeout)
...
}<click, beep, ring> ok, thanks!
But there is still a small race window between
while (atomic_read(&subs->state) != state_PREPARED) {
and /* right here the complete callback may be called */
timeout = schedule_timeout(timeout);no?
Is there a trick to avoid even this small race window?
Quoted 5 lines
Regarding the new config stuff:
Let's killCONFIG_SND_USB_USX2Y_NRPACKS_VARIABLEoption. No one will want to disable such a module option.
Well, me wants to disable it as it works best with nrpacks=1 here and I'd like the machine code to not contain the unneeded loops then...
(gcc optimizes those loops away if it reads "#define nrpacks 1") Can I keep some (commented out?) define switch inside the source (invisible to KConfig) to suit my needs?
Quoted 5 lines
Also, please avoid the
Kconfigint value as much as possible if you want to support the driver for 2.2/2.4 kernels, too. I believe it's ok to put a hardcoded value 4 likeusbaudio.cif you describe the module option properly in the document.
Erm, which document?
And I'm not too keen to do the driver (sup/back)port for 2.2/2.4 kernels myself. I'll avoid the Kconfig int value, making it simpler for volunteers.
Karsten
-------------------------------------------------------
This SF.net email is sponsored by: IT Product Guide on ITManagersJournal Use IT products in your business? Tell us what you think of them. Give us Your Opinions, Get Free ThinkGeek Gift Certificates! Click to find out more
http://productguide.itmanagersjournal.com/guidepromo.tmpl
Re: [PATCH]snd-usb-usx2y 0.8.1 against alsa-kernel cvshead: OHCI doesn't crash anymore
At Wed, 20 Oct 2004 02:28:15 +0200,
Quoted 17 lines · Karsten Wiese
Am Dienstag 19 Oktober 2004 15:33 schrieb Takashi Iwai:
Quoted 7 lines
I'm afraid it's still racy.
InusX2Y_urbs_start(), the complete callback may be called betweenusb_submit_urb()and the loop ofschedule_timeout().
So, the loop should check at first the condition before sleeping like below:Quoted 8 lines
while (atomic_read(&subs->state) != state_PREPARED) { timeout = schedule_timeout(timeout); if (signal_pending(current)) ... if (! timeout) ... }
Quoted 6 lines
<click, beep, ring> ok, thanks!
But there is still a small race window betweenwhile (atomic_read(&subs->state) != state_PREPARED) { and /* right here the complete callback may be called */ timeout = schedule_timeout(timeout);no?
Oh yes, sure.
Quoted 1 line
Is there a trick to avoid even this small race window?
As I wrote before, use spinlock around it or completion. The latter might be easier although it's UNINTERRUPTIBLE only.
Quoted 9 lines
Quoted 4 lines
Regarding the new config stuff:
Let's killCONFIG_SND_USB_USX2Y_NRPACKS_VARIABLEoption. No one will want to disable such a module option.Well, me wants to disable it as it works best with nrpacks=1 here and I'd like the machine code to not contain the unneeded loops then...
(gcc optimizes those loops away if it reads "#define nrpacks 1") Can I keep some (commented out?) define switch inside the source (invisible to KConfig) to suit my needs?
Then it's ok. Having a new stuff in Kconfig would make it difficult to build for older systems.
Quoted 6 lines
Quoted 5 lines
Also, please avoid the
Kconfigint value as much as possible if you want to support the driver for 2.2/2.4 kernels, too. I believe it's ok to put a hardcoded value 4 likeusbaudio.cif you describe the module option properly in the document.Erm, which document?
Create a new one for your driver ;)
Quoted 2 lines
And I'm not too keen to do the driver (sup/back)port for 2.2/2.4 kernels myself. I'll avoid the
Kconfigint value, making it simpler for volunteers.
Ok, thanks.
Takashi
-------------------------------------------------------
This SF.net email is sponsored by: IT Product Guide on ITManagersJournal Use IT products in your business? Tell us what you think of them. Give us Your Opinions, Get Free ThinkGeek Gift Certificates! Click to find out more
http://productguide.itmanagersjournal.com/guidepromo.tmpl
Re: [PATCH]snd-usb-usx2y 0.8.1 against alsa-kernel cvshead: OHCI doesn't crash anymore
Am Mittwoch 20 Oktober 2004 11:35 schrieb Takashi Iwai:
Quoted 25 lines
At Wed, 20 Oct 2004 02:28:15 +0200,
Quoted 15 lines · Karsten Wiese
Am Dienstag 19 Oktober 2004 15:33 schrieb Takashi Iwai:
Quoted 6 lines
I'm afraid it's still racy.
InusX2Y_urbs_start(), the complete callback may be called betweenusb_submit_urb()and the loop ofschedule_timeout().
So, the loop should check at first the condition before sleeping like below:Quoted 7 lines
while (atomic_read(&subs->state) != state_PREPARED) { timeout = schedule_timeout(timeout); if (signal_pending(current)) ... if (! timeout) ... }Quoted 6 lines
<click, beep, ring> ok, thanks!
But there is still a small race window betweenwhile (atomic_read(&subs->state) != state_PREPARED) { and /* right here the complete callback may be called */ timeout = schedule_timeout(timeout);no?
Quoted 7 lines
Oh yes, sure.
Quoted 1 line
Is there a trick to avoid even this small race window?
As I wrote before, use spinlock around it or completion. The latter might be easier although it's UNINTERRUPTIBLE only.
I used the wait_event macro in this version. Its also used in snd_card_free(), so I hope stuff is not too hard to port to 2.4 and 2.2 kernels.
Quoted 20 lines
Quoted 9 lines
Quoted 3 lines
Regarding the new config stuff:
Let's killCONFIG_SND_USB_USX2Y_NRPACKS_VARIABLEoption. No one will want to disable such a module option.Well, me wants to disable it as it works best with nrpacks=1 here and I'd like the machine code to not contain the unneeded loops then... (gcc optimizes those loops away if it reads "#define nrpacks 1") Can I keep some (commented out?) define switch inside the source (invisible to KConfig) to suit my needs?
Then it's ok. Having a new stuff in
Kconfigwould make it difficult to build for older systems.Quoted 6 lines
Quoted 4 lines
Also, please avoid the
Kconfigint value as much as possible if you want to support the driver for 2.2/2.4 kernels, too. I believe it's ok to put a hardcoded value 4 likeusbaudio.cif you describe the module option properly in the document.Erm, which document?
Quoted 8 lines
Create a new one for your driver ;)
Quoted 3 lines
And I'm not too keen to do the driver (sup/back)port for 2.2/2.4 kernels myself. I'll avoid the
Kconfigint value, making it simpler for volunteers.Ok, thanks.
version 0.8.5 patch is attached.
thanks,
Karsten
patch header:
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Summary: Fixes crashes that occured when communicating over ohci usb-hcds.
Work on this started, when rumors spread that ohci equipped machines would crash.
This was due to me missing two facts:
1) Ohci has a bigger usb frame number wrap around.
2) It only supports URB_ISO_ASAP when submitting iso urbs. Fixed now.
<<<<
snd-usb-usx2y 0.8.5 against alsa-kernel cvshead: OHCI doesn't crash anymore
Quoted 12 lines · Karsten Wiese
Summary: Fixes crashes that occured when communicating over ohci usb-hcds.
Work on this started, when rumors spread that ohci equipped machines would crash.
This was due to me missing two facts:
1) Ohci has a bigger usb frame number wrap around.
2) It only supportsURB_ISO_ASAPwhen submitting iso urbs. Fixed now.Signed-off-by Karsten Wiese <[email protected]>
May I ask what's the status of this, wrt.including snd-usb-usx2y version 0.8.5 on the official alsa-kernel tree?
People seem to be happy with it, specially the OHCI owners, for whom the current alsa-driver-1.0.7rc2/CVS is badly broken and causes a serious kernel oops (bug #0000425).
I hope it makes into 1.0.7 release :)
Cheers.
Signature · 11 lines
rncbc aka Rui Nuno Capela [email protected] ------------------------------------------------------- This SF.net email is sponsored by: IT Product Guide on ITManagersJournal Use IT products in your business? Tell us what you think of them. Give us Your Opinions, Get Free ThinkGeek Gift Certificates! Click to find out more http://productguide.itmanagersjournal.com/guidepromo.tmpl
Re: snd-usb-usx2y 0.8.5 against alsa-kernel cvshead: OHCI doesn't crash anymore
Quoted 2 lines · Rui Nuno Capela
May I ask what's the status of this, wrt.including snd-usb-usx2y version 0.8.5 on the official alsa-kernel tree?
Could you resend this patch?
Jaroslav
-----
Jaroslav Kysela <[email protected]>
-------------------------------------------------------
This SF.net email is sponsored by: IT Product Guide on ITManagersJournal Use IT products in your business? Tell us what you think of them. Give us Your Opinions, Get Free ThinkGeek Gift Certificates! Click to find out more
http://productguide.itmanagersjournal.com/guidepromo.tmpl
Re: snd-usb-usx2y 0.8.5 against alsa-kernel cvshead: OHCI doesn't crash anymore
Quoted 8 lines · --- Jaroslav Kysela
Quoted 1 line · Rui Nuno Capela
May I ask what's the status of this, wrt.including
snd-usb-usx2y version
Quoted 1 line
0.8.5 on the official alsa-kernel tree?
Could you resend this patch?
wait some minutes, then I'll send the newest Version
Karsten
___________________________________________________________
Gesendet von Yahoo! Mail - Jetzt mit 100MB Speicher kostenlos - Hier anmelden: http://mail.yahoo.de
-------------------------------------------------------
This SF.net email is sponsored by: IT Product Guide on ITManagersJournal Use IT products in your business? Tell us what you think of them. Give us Your Opinions, Get Free ThinkGeek Gift Certificates! Click to find out more
http://productguide.itmanagersjournal.com/guidepromo.tmpl
Re: snd-usb-usx2y 0.8.5 against alsa-kernel cvshead: OHCI doesn't crash anymore
In reply to Jaroslav KyselaQuoted 7 lines · Jaroslav Kysela
Quoted 2 lines · Rui Nuno Capela
May I ask what's the status of this, wrt.including snd-usb-usx2y version 0.8.5 on the official alsa-kernel tree?
Could you resend this patch?
Sure. On behalf of Karten's :)
Quoted 1 line
Quoted 1 line
Quoted 1 line
Summary: Fixes crashes that occured when communicating over ohci usb-hcds.
Work on this started, when rumors spread that ohci equipped machines would crash.
This was due to me missing two facts:
1) Ohci has a bigger usb frame number wrap around.
2) It only supports URB_ISO_ASAP when submitting iso urbs. Fixed now.
<<<
Re: snd-usb-usx2y 0.8.5 against alsa-kernel cvshead: OHCI doesn't crash anymore
Am Dienstag 26 Oktober 2004 11:13 schrieb Rui Nuno Capela:
Quoted 8 lines
Quoted 5 lines · Jaroslav Kysela
Quoted 2 lines · Rui Nuno Capela
May I ask what's the status of this, wrt.including snd-usb-usx2y version 0.8.5 on the official alsa-kernel tree?
Could you resend this patch?
Sure. On behalf of Karten's :)
attached 0.8.6 has on more bug fixed ;-)
Karsten
*************
Summary: Fixes crashes that occurred when communicating over ohci usb-hcds.
Version: 0.8.6
Work on this started, when rumors spread that ohci equipped machines would crash.
This was due to me missing two facts:
1) Ohci has a bigger usb frame number wrap around.
2) It only supports URB_ISO_ASAP when submitting iso urbs. Fixed.