提交 da7c5af8 编写于 作者: C Cornelia Huck 提交者: Heiko Carstens

[S390] cio: Allow adapter interrupt handlers per isc.

Enhance the adapter interruption API so that device drivers can
register a handler for a specific interruption subclass. This
will allow different device drivers to move to differently
prioritized subclasses in order to avoid congestion.
Signed-off-by: NCornelia Huck <cornelia.huck@de.ibm.com>
Signed-off-by: NMartin Schwidefsky <schwidefsky@de.ibm.com>
Signed-off-by: NHeiko Carstens <heiko.carstens@de.ibm.com>
上级 3a3fc29a
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
#include <linux/rcupdate.h> #include <linux/rcupdate.h>
#include <asm/airq.h> #include <asm/airq.h>
#include <asm/isc.h>
#include "cio.h" #include "cio.h"
#include "cio_debug.h" #include "cio_debug.h"
...@@ -33,15 +34,15 @@ struct airq_t { ...@@ -33,15 +34,15 @@ struct airq_t {
void *drv_data; void *drv_data;
}; };
static union indicator_t indicators; static union indicator_t indicators[MAX_ISC];
static struct airq_t *airqs[NR_AIRQS]; static struct airq_t *airqs[MAX_ISC][NR_AIRQS];
static int register_airq(struct airq_t *airq) static int register_airq(struct airq_t *airq, u8 isc)
{ {
int i; int i;
for (i = 0; i < NR_AIRQS; i++) for (i = 0; i < NR_AIRQS; i++)
if (!cmpxchg(&airqs[i], NULL, airq)) if (!cmpxchg(&airqs[isc][i], NULL, airq))
return i; return i;
return -ENOMEM; return -ENOMEM;
} }
...@@ -50,18 +51,21 @@ static int register_airq(struct airq_t *airq) ...@@ -50,18 +51,21 @@ static int register_airq(struct airq_t *airq)
* s390_register_adapter_interrupt() - register adapter interrupt handler * s390_register_adapter_interrupt() - register adapter interrupt handler
* @handler: adapter handler to be registered * @handler: adapter handler to be registered
* @drv_data: driver data passed with each call to the handler * @drv_data: driver data passed with each call to the handler
* @isc: isc for which the handler should be called
* *
* Returns: * Returns:
* Pointer to the indicator to be used on success * Pointer to the indicator to be used on success
* ERR_PTR() if registration failed * ERR_PTR() if registration failed
*/ */
void *s390_register_adapter_interrupt(adapter_int_handler_t handler, void *s390_register_adapter_interrupt(adapter_int_handler_t handler,
void *drv_data) void *drv_data, u8 isc)
{ {
struct airq_t *airq; struct airq_t *airq;
char dbf_txt[16]; char dbf_txt[16];
int ret; int ret;
if (isc > MAX_ISC)
return ERR_PTR(-EINVAL);
airq = kmalloc(sizeof(struct airq_t), GFP_KERNEL); airq = kmalloc(sizeof(struct airq_t), GFP_KERNEL);
if (!airq) { if (!airq) {
ret = -ENOMEM; ret = -ENOMEM;
...@@ -69,34 +73,35 @@ void *s390_register_adapter_interrupt(adapter_int_handler_t handler, ...@@ -69,34 +73,35 @@ void *s390_register_adapter_interrupt(adapter_int_handler_t handler,
} }
airq->handler = handler; airq->handler = handler;
airq->drv_data = drv_data; airq->drv_data = drv_data;
ret = register_airq(airq);
if (ret < 0) ret = register_airq(airq, isc);
kfree(airq);
out: out:
snprintf(dbf_txt, sizeof(dbf_txt), "rairq:%d", ret); snprintf(dbf_txt, sizeof(dbf_txt), "rairq:%d", ret);
CIO_TRACE_EVENT(4, dbf_txt); CIO_TRACE_EVENT(4, dbf_txt);
if (ret < 0) if (ret < 0) {
kfree(airq);
return ERR_PTR(ret); return ERR_PTR(ret);
else } else
return &indicators.byte[ret]; return &indicators[isc].byte[ret];
} }
EXPORT_SYMBOL(s390_register_adapter_interrupt); EXPORT_SYMBOL(s390_register_adapter_interrupt);
/** /**
* s390_unregister_adapter_interrupt - unregister adapter interrupt handler * s390_unregister_adapter_interrupt - unregister adapter interrupt handler
* @ind: indicator for which the handler is to be unregistered * @ind: indicator for which the handler is to be unregistered
* @isc: interruption subclass
*/ */
void s390_unregister_adapter_interrupt(void *ind) void s390_unregister_adapter_interrupt(void *ind, u8 isc)
{ {
struct airq_t *airq; struct airq_t *airq;
char dbf_txt[16]; char dbf_txt[16];
int i; int i;
i = (int) ((addr_t) ind) - ((addr_t) &indicators.byte[0]); i = (int) ((addr_t) ind) - ((addr_t) &indicators[isc].byte[0]);
snprintf(dbf_txt, sizeof(dbf_txt), "urairq:%d", i); snprintf(dbf_txt, sizeof(dbf_txt), "urairq:%d", i);
CIO_TRACE_EVENT(4, dbf_txt); CIO_TRACE_EVENT(4, dbf_txt);
indicators.byte[i] = 0; indicators[isc].byte[i] = 0;
airq = xchg(&airqs[i], NULL); airq = xchg(&airqs[isc][i], NULL);
/* /*
* Allow interrupts to complete. This will ensure that the airq handle * Allow interrupts to complete. This will ensure that the airq handle
* is no longer referenced by any interrupt handler. * is no longer referenced by any interrupt handler.
...@@ -108,7 +113,7 @@ EXPORT_SYMBOL(s390_unregister_adapter_interrupt); ...@@ -108,7 +113,7 @@ EXPORT_SYMBOL(s390_unregister_adapter_interrupt);
#define INDICATOR_MASK (0xffUL << ((NR_AIRQS_PER_WORD - 1) * 8)) #define INDICATOR_MASK (0xffUL << ((NR_AIRQS_PER_WORD - 1) * 8))
void do_adapter_IO(void) void do_adapter_IO(u8 isc)
{ {
int w; int w;
int i; int i;
...@@ -120,22 +125,22 @@ void do_adapter_IO(void) ...@@ -120,22 +125,22 @@ void do_adapter_IO(void)
* fetch operations. * fetch operations.
*/ */
for (w = 0; w < NR_AIRQ_WORDS; w++) { for (w = 0; w < NR_AIRQ_WORDS; w++) {
word = indicators.word[w]; word = indicators[isc].word[w];
i = w * NR_AIRQS_PER_WORD; i = w * NR_AIRQS_PER_WORD;
/* /*
* Check bytes within word for active indicators. * Check bytes within word for active indicators.
*/ */
while (word) { while (word) {
if (word & INDICATOR_MASK) { if (word & INDICATOR_MASK) {
airq = airqs[i]; airq = airqs[isc][i];
if (likely(airq)) if (likely(airq))
airq->handler(&indicators.byte[i], airq->handler(&indicators[isc].byte[i],
airq->drv_data); airq->drv_data);
else else
/* /*
* Reset ill-behaved indicator. * Reset ill-behaved indicator.
*/ */
indicators.byte[i] = 0; indicators[isc].byte[i] = 0;
} }
word <<= 8; word <<= 8;
i++; i++;
......
...@@ -641,7 +641,7 @@ do_IRQ (struct pt_regs *regs) ...@@ -641,7 +641,7 @@ do_IRQ (struct pt_regs *regs)
*/ */
if (tpi_info->adapter_IO == 1 && if (tpi_info->adapter_IO == 1 &&
tpi_info->int_type == IO_INTERRUPT_TYPE) { tpi_info->int_type == IO_INTERRUPT_TYPE) {
do_adapter_IO(); do_adapter_IO(tpi_info->isc);
continue; continue;
} }
sch = (struct subchannel *)(unsigned long)tpi_info->intparm; sch = (struct subchannel *)(unsigned long)tpi_info->intparm;
......
...@@ -106,7 +106,7 @@ int cio_tm_start_key(struct subchannel *sch, struct tcw *tcw, u8 lpm, u8 key); ...@@ -106,7 +106,7 @@ int cio_tm_start_key(struct subchannel *sch, struct tcw *tcw, u8 lpm, u8 key);
int cio_tm_intrg(struct subchannel *sch); int cio_tm_intrg(struct subchannel *sch);
int cio_create_sch_lock(struct subchannel *); int cio_create_sch_lock(struct subchannel *);
void do_adapter_IO(void); void do_adapter_IO(u8 isc);
void do_IRQ(struct pt_regs *); void do_IRQ(struct pt_regs *);
/* Use with care. */ /* Use with care. */
......
...@@ -3713,7 +3713,8 @@ tiqdio_register_thinints(void) ...@@ -3713,7 +3713,8 @@ tiqdio_register_thinints(void)
char dbf_text[20]; char dbf_text[20];
tiqdio_ind = tiqdio_ind =
s390_register_adapter_interrupt(&tiqdio_thinint_handler, NULL); s390_register_adapter_interrupt(&tiqdio_thinint_handler, NULL,
TIQDIO_THININT_ISC);
if (IS_ERR(tiqdio_ind)) { if (IS_ERR(tiqdio_ind)) {
sprintf(dbf_text, "regthn%lx", PTR_ERR(tiqdio_ind)); sprintf(dbf_text, "regthn%lx", PTR_ERR(tiqdio_ind));
QDIO_DBF_TEXT0(0,setup,dbf_text); QDIO_DBF_TEXT0(0,setup,dbf_text);
...@@ -3729,7 +3730,8 @@ static void ...@@ -3729,7 +3730,8 @@ static void
tiqdio_unregister_thinints(void) tiqdio_unregister_thinints(void)
{ {
if (tiqdio_ind) if (tiqdio_ind)
s390_unregister_adapter_interrupt(tiqdio_ind); s390_unregister_adapter_interrupt(tiqdio_ind,
TIQDIO_THININT_ISC);
} }
static int static int
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
typedef void (*adapter_int_handler_t)(void *, void *); typedef void (*adapter_int_handler_t)(void *, void *);
void *s390_register_adapter_interrupt(adapter_int_handler_t, void *); void *s390_register_adapter_interrupt(adapter_int_handler_t, void *, u8);
void s390_unregister_adapter_interrupt(void *); void s390_unregister_adapter_interrupt(void *, u8);
#endif /* _ASM_S390_AIRQ_H */ #endif /* _ASM_S390_AIRQ_H */
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册