mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-11-18 09:44:18 +08:00
7d12e780e0
Maintain a per-CPU global "struct pt_regs *" variable which can be used instead of passing regs around manually through all ~1800 interrupt handlers in the Linux kernel. The regs pointer is used in few places, but it potentially costs both stack space and code to pass it around. On the FRV arch, removing the regs parameter from all the genirq function results in a 20% speed up of the IRQ exit path (ie: from leaving timer_interrupt() to leaving do_IRQ()). Where appropriate, an arch may override the generic storage facility and do something different with the variable. On FRV, for instance, the address is maintained in GR28 at all times inside the kernel as part of general exception handling. Having looked over the code, it appears that the parameter may be handed down through up to twenty or so layers of functions. Consider a USB character device attached to a USB hub, attached to a USB controller that posts its interrupts through a cascaded auxiliary interrupt controller. A character device driver may want to pass regs to the sysrq handler through the input layer which adds another few layers of parameter passing. I've build this code with allyesconfig for x86_64 and i386. I've runtested the main part of the code on FRV and i386, though I can't test most of the drivers. I've also done partial conversion for powerpc and MIPS - these at least compile with minimal configurations. This will affect all archs. Mostly the changes should be relatively easy. Take do_IRQ(), store the regs pointer at the beginning, saving the old one: struct pt_regs *old_regs = set_irq_regs(regs); And put the old one back at the end: set_irq_regs(old_regs); Don't pass regs through to generic_handle_irq() or __do_IRQ(). In timer_interrupt(), this sort of change will be necessary: - update_process_times(user_mode(regs)); - profile_tick(CPU_PROFILING, regs); + update_process_times(user_mode(get_irq_regs())); + profile_tick(CPU_PROFILING); I'd like to move update_process_times()'s use of get_irq_regs() into itself, except that i386, alone of the archs, uses something other than user_mode(). Some notes on the interrupt handling in the drivers: (*) input_dev() is now gone entirely. The regs pointer is no longer stored in the input_dev struct. (*) finish_unlinks() in drivers/usb/host/ohci-q.c needs checking. It does something different depending on whether it's been supplied with a regs pointer or not. (*) Various IRQ handler function pointers have been moved to type irq_handler_t. Signed-Off-By: David Howells <dhowells@redhat.com> (cherry picked from 1b16e7ac850969f38b375e511e3fa2f474a33867 commit)
143 lines
4.4 KiB
C
143 lines
4.4 KiB
C
/*
|
|
* Routine for IRQ handling from GF1/InterWave chip
|
|
* Copyright (c) by Jaroslav Kysela <perex@suse.cz>
|
|
*
|
|
*
|
|
* This program is free software; you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with this program; if not, write to the Free Software
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
*
|
|
*/
|
|
|
|
#include <sound/driver.h>
|
|
#include <sound/core.h>
|
|
#include <sound/info.h>
|
|
#include <sound/gus.h>
|
|
|
|
#ifdef CONFIG_SND_DEBUG
|
|
#define STAT_ADD(x) ((x)++)
|
|
#else
|
|
#define STAT_ADD(x) while (0) { ; }
|
|
#endif
|
|
|
|
irqreturn_t snd_gus_interrupt(int irq, void *dev_id)
|
|
{
|
|
struct snd_gus_card * gus = dev_id;
|
|
unsigned char status;
|
|
int loop = 100;
|
|
int handled = 0;
|
|
|
|
__again:
|
|
status = inb(gus->gf1.reg_irqstat);
|
|
if (status == 0)
|
|
return IRQ_RETVAL(handled);
|
|
handled = 1;
|
|
// snd_printk("IRQ: status = 0x%x\n", status);
|
|
if (status & 0x02) {
|
|
STAT_ADD(gus->gf1.interrupt_stat_midi_in);
|
|
gus->gf1.interrupt_handler_midi_in(gus);
|
|
}
|
|
if (status & 0x01) {
|
|
STAT_ADD(gus->gf1.interrupt_stat_midi_out);
|
|
gus->gf1.interrupt_handler_midi_out(gus);
|
|
}
|
|
if (status & (0x20 | 0x40)) {
|
|
unsigned int already, _current_;
|
|
unsigned char voice_status, voice;
|
|
struct snd_gus_voice *pvoice;
|
|
|
|
already = 0;
|
|
while (((voice_status = snd_gf1_i_read8(gus, SNDRV_GF1_GB_VOICES_IRQ)) & 0xc0) != 0xc0) {
|
|
voice = voice_status & 0x1f;
|
|
_current_ = 1 << voice;
|
|
if (already & _current_)
|
|
continue; /* multi request */
|
|
already |= _current_; /* mark request */
|
|
#if 0
|
|
printk("voice = %i, voice_status = 0x%x, voice_verify = %i\n", voice, voice_status, inb(GUSP(gus, GF1PAGE)));
|
|
#endif
|
|
pvoice = &gus->gf1.voices[voice];
|
|
if (pvoice->use) {
|
|
if (!(voice_status & 0x80)) { /* voice position IRQ */
|
|
STAT_ADD(pvoice->interrupt_stat_wave);
|
|
pvoice->handler_wave(gus, pvoice);
|
|
}
|
|
if (!(voice_status & 0x40)) { /* volume ramp IRQ */
|
|
STAT_ADD(pvoice->interrupt_stat_volume);
|
|
pvoice->handler_volume(gus, pvoice);
|
|
}
|
|
} else {
|
|
STAT_ADD(gus->gf1.interrupt_stat_voice_lost);
|
|
snd_gf1_i_ctrl_stop(gus, SNDRV_GF1_VB_ADDRESS_CONTROL);
|
|
snd_gf1_i_ctrl_stop(gus, SNDRV_GF1_VB_VOLUME_CONTROL);
|
|
}
|
|
}
|
|
}
|
|
if (status & 0x04) {
|
|
STAT_ADD(gus->gf1.interrupt_stat_timer1);
|
|
gus->gf1.interrupt_handler_timer1(gus);
|
|
}
|
|
if (status & 0x08) {
|
|
STAT_ADD(gus->gf1.interrupt_stat_timer2);
|
|
gus->gf1.interrupt_handler_timer2(gus);
|
|
}
|
|
if (status & 0x80) {
|
|
if (snd_gf1_i_look8(gus, SNDRV_GF1_GB_DRAM_DMA_CONTROL) & 0x40) {
|
|
STAT_ADD(gus->gf1.interrupt_stat_dma_write);
|
|
gus->gf1.interrupt_handler_dma_write(gus);
|
|
}
|
|
if (snd_gf1_i_look8(gus, SNDRV_GF1_GB_REC_DMA_CONTROL) & 0x40) {
|
|
STAT_ADD(gus->gf1.interrupt_stat_dma_read);
|
|
gus->gf1.interrupt_handler_dma_read(gus);
|
|
}
|
|
}
|
|
if (--loop > 0)
|
|
goto __again;
|
|
return IRQ_NONE;
|
|
}
|
|
|
|
#ifdef CONFIG_SND_DEBUG
|
|
static void snd_gus_irq_info_read(struct snd_info_entry *entry,
|
|
struct snd_info_buffer *buffer)
|
|
{
|
|
struct snd_gus_card *gus;
|
|
struct snd_gus_voice *pvoice;
|
|
int idx;
|
|
|
|
gus = entry->private_data;
|
|
snd_iprintf(buffer, "midi out = %u\n", gus->gf1.interrupt_stat_midi_out);
|
|
snd_iprintf(buffer, "midi in = %u\n", gus->gf1.interrupt_stat_midi_in);
|
|
snd_iprintf(buffer, "timer1 = %u\n", gus->gf1.interrupt_stat_timer1);
|
|
snd_iprintf(buffer, "timer2 = %u\n", gus->gf1.interrupt_stat_timer2);
|
|
snd_iprintf(buffer, "dma write = %u\n", gus->gf1.interrupt_stat_dma_write);
|
|
snd_iprintf(buffer, "dma read = %u\n", gus->gf1.interrupt_stat_dma_read);
|
|
snd_iprintf(buffer, "voice lost = %u\n", gus->gf1.interrupt_stat_voice_lost);
|
|
for (idx = 0; idx < 32; idx++) {
|
|
pvoice = &gus->gf1.voices[idx];
|
|
snd_iprintf(buffer, "voice %i: wave = %u, volume = %u\n",
|
|
idx,
|
|
pvoice->interrupt_stat_wave,
|
|
pvoice->interrupt_stat_volume);
|
|
}
|
|
}
|
|
|
|
void snd_gus_irq_profile_init(struct snd_gus_card *gus)
|
|
{
|
|
struct snd_info_entry *entry;
|
|
|
|
if (! snd_card_proc_new(gus->card, "gusirq", &entry))
|
|
snd_info_set_text_ops(entry, gus, snd_gus_irq_info_read);
|
|
}
|
|
|
|
#endif
|