mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2024-12-29 09:13:38 +00:00
ALSA: caiaq: Use snd_card_free_when_closed() at disconnection
The USB disconnect callback is supposed to be short and not too-long
waiting. OTOH, the current code uses snd_card_free() at
disconnection, but this waits for the close of all used fds, hence it
can take long. It eventually blocks the upper layer USB ioctls, which
may trigger a soft lockup.
An easy workaround is to replace snd_card_free() with
snd_card_free_when_closed(). This variant returns immediately while
the release of resources is done asynchronously by the card device
release at the last close.
This patch also splits the code to the disconnect and the free phases;
the former is called immediately at the USB disconnect callback while
the latter is called from the card destructor.
Fixes: 523f1dce37
("[ALSA] Add Native Instrument usb audio device support")
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Link: https://patch.msgid.link/20241113111042.15058-5-tiwai@suse.de
This commit is contained in:
parent
f86af06306
commit
b04dcbb7f7
@ -858,14 +858,20 @@ int snd_usb_caiaq_audio_init(struct snd_usb_caiaqdev *cdev)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void snd_usb_caiaq_audio_free(struct snd_usb_caiaqdev *cdev)
|
void snd_usb_caiaq_audio_disconnect(struct snd_usb_caiaqdev *cdev)
|
||||||
{
|
{
|
||||||
struct device *dev = caiaqdev_to_dev(cdev);
|
struct device *dev = caiaqdev_to_dev(cdev);
|
||||||
|
|
||||||
dev_dbg(dev, "%s(%p)\n", __func__, cdev);
|
dev_dbg(dev, "%s(%p)\n", __func__, cdev);
|
||||||
stream_stop(cdev);
|
stream_stop(cdev);
|
||||||
|
}
|
||||||
|
|
||||||
|
void snd_usb_caiaq_audio_free(struct snd_usb_caiaqdev *cdev)
|
||||||
|
{
|
||||||
|
struct device *dev = caiaqdev_to_dev(cdev);
|
||||||
|
|
||||||
|
dev_dbg(dev, "%s(%p)\n", __func__, cdev);
|
||||||
free_urbs(cdev->data_urbs_in);
|
free_urbs(cdev->data_urbs_in);
|
||||||
free_urbs(cdev->data_urbs_out);
|
free_urbs(cdev->data_urbs_out);
|
||||||
kfree(cdev->data_cb_info);
|
kfree(cdev->data_cb_info);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
#define CAIAQ_AUDIO_H
|
#define CAIAQ_AUDIO_H
|
||||||
|
|
||||||
int snd_usb_caiaq_audio_init(struct snd_usb_caiaqdev *cdev);
|
int snd_usb_caiaq_audio_init(struct snd_usb_caiaqdev *cdev);
|
||||||
|
void snd_usb_caiaq_audio_disconnect(struct snd_usb_caiaqdev *cdev);
|
||||||
void snd_usb_caiaq_audio_free(struct snd_usb_caiaqdev *cdev);
|
void snd_usb_caiaq_audio_free(struct snd_usb_caiaqdev *cdev);
|
||||||
|
|
||||||
#endif /* CAIAQ_AUDIO_H */
|
#endif /* CAIAQ_AUDIO_H */
|
||||||
|
@ -376,6 +376,17 @@ static void setup_card(struct snd_usb_caiaqdev *cdev)
|
|||||||
dev_err(dev, "Unable to set up control system (ret=%d)\n", ret);
|
dev_err(dev, "Unable to set up control system (ret=%d)\n", ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void card_free(struct snd_card *card)
|
||||||
|
{
|
||||||
|
struct snd_usb_caiaqdev *cdev = caiaqdev(card);
|
||||||
|
|
||||||
|
#ifdef CONFIG_SND_USB_CAIAQ_INPUT
|
||||||
|
snd_usb_caiaq_input_free(cdev);
|
||||||
|
#endif
|
||||||
|
snd_usb_caiaq_audio_free(cdev);
|
||||||
|
usb_reset_device(cdev->chip.dev);
|
||||||
|
}
|
||||||
|
|
||||||
static int create_card(struct usb_device *usb_dev,
|
static int create_card(struct usb_device *usb_dev,
|
||||||
struct usb_interface *intf,
|
struct usb_interface *intf,
|
||||||
struct snd_card **cardp)
|
struct snd_card **cardp)
|
||||||
@ -489,6 +500,7 @@ static int init_card(struct snd_usb_caiaqdev *cdev)
|
|||||||
cdev->vendor_name, cdev->product_name, usbpath);
|
cdev->vendor_name, cdev->product_name, usbpath);
|
||||||
|
|
||||||
setup_card(cdev);
|
setup_card(cdev);
|
||||||
|
card->private_free = card_free;
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
err_kill_urb:
|
err_kill_urb:
|
||||||
@ -534,15 +546,14 @@ static void snd_disconnect(struct usb_interface *intf)
|
|||||||
snd_card_disconnect(card);
|
snd_card_disconnect(card);
|
||||||
|
|
||||||
#ifdef CONFIG_SND_USB_CAIAQ_INPUT
|
#ifdef CONFIG_SND_USB_CAIAQ_INPUT
|
||||||
snd_usb_caiaq_input_free(cdev);
|
snd_usb_caiaq_input_disconnect(cdev);
|
||||||
#endif
|
#endif
|
||||||
snd_usb_caiaq_audio_free(cdev);
|
snd_usb_caiaq_audio_disconnect(cdev);
|
||||||
|
|
||||||
usb_kill_urb(&cdev->ep1_in_urb);
|
usb_kill_urb(&cdev->ep1_in_urb);
|
||||||
usb_kill_urb(&cdev->midi_out_urb);
|
usb_kill_urb(&cdev->midi_out_urb);
|
||||||
|
|
||||||
snd_card_free(card);
|
snd_card_free_when_closed(card);
|
||||||
usb_reset_device(interface_to_usbdev(intf));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -829,15 +829,21 @@ int snd_usb_caiaq_input_init(struct snd_usb_caiaqdev *cdev)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
void snd_usb_caiaq_input_free(struct snd_usb_caiaqdev *cdev)
|
void snd_usb_caiaq_input_disconnect(struct snd_usb_caiaqdev *cdev)
|
||||||
{
|
{
|
||||||
if (!cdev || !cdev->input_dev)
|
if (!cdev || !cdev->input_dev)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
usb_kill_urb(cdev->ep4_in_urb);
|
usb_kill_urb(cdev->ep4_in_urb);
|
||||||
|
input_unregister_device(cdev->input_dev);
|
||||||
|
}
|
||||||
|
|
||||||
|
void snd_usb_caiaq_input_free(struct snd_usb_caiaqdev *cdev)
|
||||||
|
{
|
||||||
|
if (!cdev || !cdev->input_dev)
|
||||||
|
return;
|
||||||
|
|
||||||
usb_free_urb(cdev->ep4_in_urb);
|
usb_free_urb(cdev->ep4_in_urb);
|
||||||
cdev->ep4_in_urb = NULL;
|
cdev->ep4_in_urb = NULL;
|
||||||
|
|
||||||
input_unregister_device(cdev->input_dev);
|
|
||||||
cdev->input_dev = NULL;
|
cdev->input_dev = NULL;
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
void snd_usb_caiaq_input_dispatch(struct snd_usb_caiaqdev *cdev, char *buf, unsigned int len);
|
void snd_usb_caiaq_input_dispatch(struct snd_usb_caiaqdev *cdev, char *buf, unsigned int len);
|
||||||
int snd_usb_caiaq_input_init(struct snd_usb_caiaqdev *cdev);
|
int snd_usb_caiaq_input_init(struct snd_usb_caiaqdev *cdev);
|
||||||
|
void snd_usb_caiaq_input_disconnect(struct snd_usb_caiaqdev *cdev);
|
||||||
void snd_usb_caiaq_input_free(struct snd_usb_caiaqdev *cdev);
|
void snd_usb_caiaq_input_free(struct snd_usb_caiaqdev *cdev);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user