Minor GFP_ATOMIC removal
cover Minor GFP_ATOMIC removal
Hi,
this is small fixes for the old PCI drivers that still used GFP_ATOMIC by some reason. It became a nice cleanup in the end.
Takashi
===
Takashi Iwai (2):
ALSA: cmipci: Allocate with GFP_KERNEL instead of GFP_ATOMIC
ALSA: emu10k1: Reduce GFP_ATOMIC allocation
include/sound/emu10k1.h | 4 ++-- sound/pci/cmipci.c | 2 +- sound/pci/emu10k1/emufx.c | 9 +-------- sound/pci/emu10k1/emupcm.c | 2 +- 4 files changed, 5 insertions(+), 12 deletions(-)
Signature · 1 line
2.16.3
PATCH 1/2 ALSA: cmipci: Allocate with GFP_KERNEL instead of GFP_ATOMIC
save_mixer_state() is called in a sleepable context, so it's safe to allocate with GFP_KERNEL instead of the current GFP_ATOMIC. The GFP_ATOMIC usage must have been based on an incorrect assumption in the very old code base.
--- sound/pci/cmipci.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/pci/cmipci.c +1 -1
@@ -1139,7 +1139,7 @@ static int save_mixer_state(struct cmipci *cm)struct snd_ctl_elem_value *val;unsigned int i; - val =kmalloc (sizeof (*val),GFP_ATOMIC ); + val =kmalloc (sizeof (*val),GFP_KERNEL );if (!val)return -ENOMEM ;for (i =0 ; i <CM_SAVED_MIXERS ; i++) {
Signature · 1 line
2.16.3
PATCH 2/2 ALSA: emu10k1: Reduce GFP_ATOMIC allocation
In reply to Takashi IwaiThe emu10k1 fx8010 code allocates each irq resource dynamically and links to the list at PCM trigger callback. Due to the nature of trigger callback, the allocation is done with GFP_ATOMIC, hence it may fail more often. Moreover, the irq resource isn't big at all, and using the kmalloc for this won't save many bytes, either.
This patch removes the dynamic allocation and embeds the irq resource into struct snd_emu10k1_fx8010_pcm.irq field instead of keeping a pointer. As a result, it simplifies the code and removes the unnecessary GFP_ATOMIC usage.
--- include/sound/emu10k1.h | 4 ++-- sound/pci/emu10k1/emufx.c | 9 +-------- sound/pci/emu10k1/emupcm.c | 2 +- 3 files changed, 4 insertions(+), 11 deletions(-)
include/sound/emu10k1.h +2 -2
@@ -1610,7 +1610,7 @@ struct snd_emu10k1_fx8010_pcm {struct snd_pcm_indirect pcm_rec;unsigned int tram_pos;unsigned int tram_shift; -struct snd_emu10k1_fx8010_irq *irq; +struct snd_emu10k1_fx8010_irq irq; };struct snd_emu10k1_fx8010 {
@@ -1902,7 +1902,7 @@ int snd_emu10k1_fx8010_register_irq_handler(struct snd_emu10k1 *emu,snd_fx8010_irq_handler_t *handler, unsigned char gpr_running, void *private_data, - struct snd_emu10k1_fx8010_irq **r_irq); + struct snd_emu10k1_fx8010_irq *irq);int snd_emu10k1_fx8010_unregister_irq_handler (struct snd_emu10k1 *emu,struct snd_emu10k1_fx8010_irq *irq);
sound/pci/emu10k1/emufx.c +1 -8
@@ -421,14 +421,10 @@ int snd_emu10k1_fx8010_register_irq_handler(struct snd_emu10k1 *emu,snd_fx8010_irq_handler_t *handler, unsigned char gpr_running, void *private_data, - struct snd_emu10k1_fx8010_irq **r_irq) + struct snd_emu10k1_fx8010_irq *irq) { - struct snd_emu10k1_fx8010_irq *irq; unsigned long flags; - irq =kmalloc (sizeof (*irq),GFP_ATOMIC ); -if (irq ==NULL ) -return -ENOMEM ; irq->handler = handler; irq->gpr_running = gpr_running; irq->private_data = private_data;
@@ -443,8 +439,6 @@ int snd_emu10k1_fx8010_register_irq_handler(struct snd_emu10k1 *emu, emu->fx8010.irq_handlers = irq; }spin_unlock_irqrestore (&emu->fx8010.irq_lock, flags); -if (r_irq) - *r_irq = irq;return 0 ; }
@@ -468,7 +462,6 @@ int snd_emu10k1_fx8010_unregister_irq_handler(struct snd_emu10k1 *emu, tmp->next = tmp->next->next; }spin_unlock_irqrestore (&emu->fx8010.irq_lock, flags); -kfree (irq);return 0 ; }
sound/pci/emu10k1/emupcm.c +1 -1
@@ -1724,7 +1724,7 @@ static int snd_emu10k1_fx8010_playback_trigger(struct snd_pcm_substream *substrecase SNDRV_PCM_TRIGGER_STOP :case SNDRV_PCM_TRIGGER_PAUSE_PUSH :case SNDRV_PCM_TRIGGER_SUSPEND : -snd_emu10k1_fx8010_unregister_irq_handler (emu, pcm->irq); pcm->irq =NULL ; +snd_emu10k1_fx8010_unregister_irq_handler (emu, &pcm->irq);snd_emu10k1_ptr_write (emu, emu->gpr_base + pcm->gpr_trigger,0 ,0 ); pcm->tram_pos =INITIAL_TRAM_POS (pcm->buffer_size); pcm->tram_shift =0 ;
Signature · 1 line
2.16.3