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)
260 lines
6.7 KiB
C
260 lines
6.7 KiB
C
/* $Id: interrupt.c,v 1.4.8.3 2001/09/23 22:24:59 kai Exp $
|
|
*
|
|
* Copyright (C) 1996 SpellCaster Telecommunications Inc.
|
|
*
|
|
* This software may be used and distributed according to the terms
|
|
* of the GNU General Public License, incorporated herein by reference.
|
|
*
|
|
* For more information, please contact gpl-info@spellcast.com or write:
|
|
*
|
|
* SpellCaster Telecommunications Inc.
|
|
* 5621 Finch Avenue East, Unit #3
|
|
* Scarborough, Ontario Canada
|
|
* M1B 2T9
|
|
* +1 (416) 297-8565
|
|
* +1 (416) 297-6433 Facsimile
|
|
*/
|
|
|
|
#include "includes.h"
|
|
#include "hardware.h"
|
|
#include "message.h"
|
|
#include "card.h"
|
|
#include <linux/interrupt.h>
|
|
|
|
extern int indicate_status(int, int, ulong, char *);
|
|
extern void check_phystat(unsigned long);
|
|
extern int receivemessage(int, RspMessage *);
|
|
extern int sendmessage(int, unsigned int, unsigned int, unsigned int,
|
|
unsigned int, unsigned int, unsigned int, unsigned int *);
|
|
extern void rcvpkt(int, RspMessage *);
|
|
|
|
extern int cinst;
|
|
extern board *sc_adapter[];
|
|
|
|
static int get_card_from_irq(int irq)
|
|
{
|
|
int i;
|
|
|
|
for(i = 0 ; i < cinst ; i++) {
|
|
if(sc_adapter[i]->interrupt == irq)
|
|
return i;
|
|
}
|
|
return -1;
|
|
}
|
|
|
|
/*
|
|
*
|
|
*/
|
|
irqreturn_t interrupt_handler(int interrupt, void *cardptr)
|
|
{
|
|
|
|
RspMessage rcvmsg;
|
|
int channel;
|
|
int card;
|
|
|
|
card = get_card_from_irq(interrupt);
|
|
|
|
if(!IS_VALID_CARD(card)) {
|
|
pr_debug("Invalid param: %d is not a valid card id\n", card);
|
|
return IRQ_NONE;
|
|
}
|
|
|
|
pr_debug("%s: Entered Interrupt handler\n",
|
|
sc_adapter[card]->devicename);
|
|
|
|
/*
|
|
* Pull all of the waiting messages off the response queue
|
|
*/
|
|
while (!receivemessage(card, &rcvmsg)) {
|
|
/*
|
|
* Push the message to the adapter structure for
|
|
* send_and_receive to snoop
|
|
*/
|
|
if(sc_adapter[card]->want_async_messages)
|
|
memcpy(&(sc_adapter[card]->async_msg),
|
|
&rcvmsg, sizeof(RspMessage));
|
|
|
|
channel = (unsigned int) rcvmsg.phy_link_no;
|
|
|
|
/*
|
|
* Trap Invalid request messages
|
|
*/
|
|
if(IS_CM_MESSAGE(rcvmsg, 0, 0, Invalid)) {
|
|
pr_debug("%s: Invalid request Message, rsp_status = %d\n",
|
|
sc_adapter[card]->devicename,
|
|
rcvmsg.rsp_status);
|
|
break;
|
|
}
|
|
|
|
/*
|
|
* Check for a linkRead message
|
|
*/
|
|
if (IS_CE_MESSAGE(rcvmsg, Lnk, 1, Read))
|
|
{
|
|
pr_debug("%s: Received packet 0x%x bytes long at 0x%lx\n",
|
|
sc_adapter[card]->devicename,
|
|
rcvmsg.msg_data.response.msg_len,
|
|
rcvmsg.msg_data.response.buff_offset);
|
|
rcvpkt(card, &rcvmsg);
|
|
continue;
|
|
|
|
}
|
|
|
|
/*
|
|
* Handle a write acknoledgement
|
|
*/
|
|
if(IS_CE_MESSAGE(rcvmsg, Lnk, 1, Write)) {
|
|
pr_debug("%s: Packet Send ACK on channel %d\n",
|
|
sc_adapter[card]->devicename,
|
|
rcvmsg.phy_link_no);
|
|
sc_adapter[card]->channel[rcvmsg.phy_link_no-1].free_sendbufs++;
|
|
continue;
|
|
}
|
|
|
|
/*
|
|
* Handle a connection message
|
|
*/
|
|
if (IS_CE_MESSAGE(rcvmsg, Phy, 1, Connect))
|
|
{
|
|
unsigned int callid;
|
|
setup_parm setup;
|
|
pr_debug("%s: Connect message: line %d: status %d: cause 0x%x\n",
|
|
sc_adapter[card]->devicename,
|
|
rcvmsg.phy_link_no,
|
|
rcvmsg.rsp_status,
|
|
rcvmsg.msg_data.byte_array[2]);
|
|
|
|
memcpy(&callid,rcvmsg.msg_data.byte_array,sizeof(int));
|
|
if(callid>=0x8000 && callid<=0xFFFF)
|
|
{
|
|
pr_debug("%s: Got Dial-Out Rsp\n",
|
|
sc_adapter[card]->devicename);
|
|
indicate_status(card, ISDN_STAT_DCONN,
|
|
(unsigned long)rcvmsg.phy_link_no-1,NULL);
|
|
|
|
}
|
|
else if(callid>=0x0000 && callid<=0x7FFF)
|
|
{
|
|
pr_debug("%s: Got Incoming Call\n",
|
|
sc_adapter[card]->devicename);
|
|
strcpy(setup.phone,&(rcvmsg.msg_data.byte_array[4]));
|
|
strcpy(setup.eazmsn,
|
|
sc_adapter[card]->channel[rcvmsg.phy_link_no-1].dn);
|
|
setup.si1 = 7;
|
|
setup.si2 = 0;
|
|
setup.plan = 0;
|
|
setup.screen = 0;
|
|
|
|
indicate_status(card, ISDN_STAT_ICALL,(unsigned long)rcvmsg.phy_link_no-1,(char *)&setup);
|
|
indicate_status(card, ISDN_STAT_DCONN,(unsigned long)rcvmsg.phy_link_no-1,NULL);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
/*
|
|
* Handle a disconnection message
|
|
*/
|
|
if (IS_CE_MESSAGE(rcvmsg, Phy, 1, Disconnect))
|
|
{
|
|
pr_debug("%s: disconnect message: line %d: status %d: cause 0x%x\n",
|
|
sc_adapter[card]->devicename,
|
|
rcvmsg.phy_link_no,
|
|
rcvmsg.rsp_status,
|
|
rcvmsg.msg_data.byte_array[2]);
|
|
|
|
indicate_status(card, ISDN_STAT_BHUP,(unsigned long)rcvmsg.phy_link_no-1,NULL);
|
|
indicate_status(card, ISDN_STAT_DHUP,(unsigned long)rcvmsg.phy_link_no-1,NULL);
|
|
continue;
|
|
|
|
}
|
|
|
|
/*
|
|
* Handle a startProc engine up message
|
|
*/
|
|
if (IS_CM_MESSAGE(rcvmsg, 5, 0, MiscEngineUp)) {
|
|
pr_debug("%s: Received EngineUp message\n",
|
|
sc_adapter[card]->devicename);
|
|
sc_adapter[card]->EngineUp = 1;
|
|
sendmessage(card, CEPID,ceReqTypeCall,ceReqClass0,ceReqCallGetMyNumber,1,0,NULL);
|
|
sendmessage(card, CEPID,ceReqTypeCall,ceReqClass0,ceReqCallGetMyNumber,2,0,NULL);
|
|
init_timer(&sc_adapter[card]->stat_timer);
|
|
sc_adapter[card]->stat_timer.function = check_phystat;
|
|
sc_adapter[card]->stat_timer.data = card;
|
|
sc_adapter[card]->stat_timer.expires = jiffies + CHECKSTAT_TIME;
|
|
add_timer(&sc_adapter[card]->stat_timer);
|
|
continue;
|
|
}
|
|
|
|
/*
|
|
* Start proc response
|
|
*/
|
|
if (IS_CM_MESSAGE(rcvmsg, 2, 0, StartProc)) {
|
|
pr_debug("%s: StartProc Response Status %d\n",
|
|
sc_adapter[card]->devicename,
|
|
rcvmsg.rsp_status);
|
|
continue;
|
|
}
|
|
|
|
/*
|
|
* Handle a GetMyNumber Rsp
|
|
*/
|
|
if (IS_CE_MESSAGE(rcvmsg,Call,0,GetMyNumber)){
|
|
strcpy(sc_adapter[card]->channel[rcvmsg.phy_link_no-1].dn,rcvmsg.msg_data.byte_array);
|
|
continue;
|
|
}
|
|
|
|
/*
|
|
* PhyStatus response
|
|
*/
|
|
if(IS_CE_MESSAGE(rcvmsg, Phy, 2, Status)) {
|
|
unsigned int b1stat, b2stat;
|
|
|
|
/*
|
|
* Covert the message data to the adapter->phystat code
|
|
*/
|
|
b1stat = (unsigned int) rcvmsg.msg_data.byte_array[0];
|
|
b2stat = (unsigned int) rcvmsg.msg_data.byte_array[1];
|
|
|
|
sc_adapter[card]->nphystat = (b2stat >> 8) | b1stat; /* endian?? */
|
|
pr_debug("%s: PhyStat is 0x%2x\n",
|
|
sc_adapter[card]->devicename,
|
|
sc_adapter[card]->nphystat);
|
|
continue;
|
|
}
|
|
|
|
|
|
/*
|
|
* Handle a GetFramFormat
|
|
*/
|
|
if(IS_CE_MESSAGE(rcvmsg, Call, 0, GetFrameFormat)) {
|
|
if(rcvmsg.msg_data.byte_array[0] != HDLC_PROTO) {
|
|
unsigned int proto = HDLC_PROTO;
|
|
/*
|
|
* Set board format to HDLC if it wasn't already
|
|
*/
|
|
pr_debug("%s: current frame format: 0x%x, will change to HDLC\n",
|
|
sc_adapter[card]->devicename,
|
|
rcvmsg.msg_data.byte_array[0]);
|
|
sendmessage(card, CEPID, ceReqTypeCall,
|
|
ceReqClass0,
|
|
ceReqCallSetFrameFormat,
|
|
(unsigned char) channel +1,
|
|
1,&proto);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
/*
|
|
* Hmm...
|
|
*/
|
|
pr_debug("%s: Received unhandled message (%d,%d,%d) link %d\n",
|
|
sc_adapter[card]->devicename,
|
|
rcvmsg.type, rcvmsg.class, rcvmsg.code,
|
|
rcvmsg.phy_link_no);
|
|
|
|
} /* while */
|
|
|
|
pr_debug("%s: Exiting Interrupt Handler\n",
|
|
sc_adapter[card]->devicename);
|
|
return IRQ_HANDLED;
|
|
}
|