Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 4e8e56c6 authored by Peter Oberparleiter's avatar Peter Oberparleiter Committed by Martin Schwidefsky
Browse files

[S390] cio: Extend adapter interrupt interface.



From: Cornelia Huck <cornelia.huck@de.ibm.com>

Change the adapter interrupt interface in order to allow multiple
adapter interrupt handlers to be registered. Indicators are now
allocated by cio instead of the device driver.

The qdio parts have been
Acked-by: default avatarUrsula Braun <ubraun@linux.vnet.ibm.com>

Signed-off-by: default avatarPeter Oberparleiter <peter.oberparleiter@de.ibm.com>
Signed-off-by: default avatarCornelia Huck <cornelia.huck@de.ibm.com>
Signed-off-by: default avatarMartin Schwidefsky <schwidefsky@de.ibm.com>
parent cd6b4f27
Loading
Loading
Loading
Loading
+1 −0
Original line number Original line Diff line number Diff line
@@ -116,6 +116,7 @@
!Iinclude/asm-s390/ccwdev.h
!Iinclude/asm-s390/ccwdev.h
!Edrivers/s390/cio/device.c
!Edrivers/s390/cio/device.c
!Edrivers/s390/cio/device_ops.c
!Edrivers/s390/cio/device_ops.c
!Edrivers/s390/cio/airq.c
    </sect1>
    </sect1>
    <sect1 id="cmf">
    <sect1 id="cmf">
     <title>The channel-measurement facility</title>
     <title>The channel-measurement facility</title>
+115 −56
Original line number Original line Diff line number Diff line
/*
/*
 *  drivers/s390/cio/airq.c
 *  drivers/s390/cio/airq.c
 *   S/390 common I/O routines -- support for adapter interruptions
 *    Support for adapter interruptions
 *
 *
 *    Copyright (C) 1999-2002 IBM Deutschland Entwicklung GmbH,
 *    Copyright IBM Corp. 1999,2007
 *			      IBM Corporation
 *    Author(s): Ingo Adlung <adlung@de.ibm.com>
 *    Author(s): Ingo Adlung (adlung@de.ibm.com)
 *		 Cornelia Huck <cornelia.huck@de.ibm.com>
 *		 Cornelia Huck (cornelia.huck@de.ibm.com)
 *		 Arnd Bergmann <arndb@de.ibm.com>
 *		 Arnd Bergmann (arndb@de.ibm.com)
 *		 Peter Oberparleiter <peter.oberparleiter@de.ibm.com>
 */
 */


#include <linux/init.h>
#include <linux/init.h>
@@ -14,72 +14,131 @@
#include <linux/slab.h>
#include <linux/slab.h>
#include <linux/rcupdate.h>
#include <linux/rcupdate.h>


#include <asm/airq.h>

#include "cio.h"
#include "cio_debug.h"
#include "cio_debug.h"
#include "airq.h"


static adapter_int_handler_t adapter_handler;
#define NR_AIRQS		32
#define NR_AIRQS_PER_WORD	sizeof(unsigned long)
#define NR_AIRQ_WORDS		(NR_AIRQS / NR_AIRQS_PER_WORD)


/*
union indicator_t {
 * register for adapter interrupts
	unsigned long word[NR_AIRQ_WORDS];
 *
	unsigned char byte[NR_AIRQS];
 * With HiperSockets the zSeries architecture provides for
} __attribute__((packed));
 *  means of adapter interrups, pseudo I/O interrupts that are
 *  not tied to an I/O subchannel, but to an adapter. However,
 *  it doesn't disclose the info how to enable/disable them, but
 *  to recognize them only. Perhaps we should consider them
 *  being shared interrupts, and thus build a linked list
 *  of adapter handlers ... to be evaluated ...
 */
int
s390_register_adapter_interrupt (adapter_int_handler_t handler)
{
	int ret;
	char dbf_txt[15];


	CIO_TRACE_EVENT (4, "rgaint");
struct airq_t {
	adapter_int_handler_t handler;
	void *drv_data;
};


	if (handler == NULL)
static union indicator_t indicators;
		ret = -EINVAL;
static struct airq_t *airqs[NR_AIRQS];
	else
		ret = (cmpxchg(&adapter_handler, NULL, handler) ? -EBUSY : 0);
	if (!ret)
		synchronize_sched();  /* Allow interrupts to complete. */


	sprintf (dbf_txt, "ret:%d", ret);
static int register_airq(struct airq_t *airq)
	CIO_TRACE_EVENT (4, dbf_txt);
{
	int i;


	return ret;
	for (i = 0; i < NR_AIRQS; i++)
		if (!cmpxchg(&airqs[i], NULL, airq))
			return i;
	return -ENOMEM;
}
}


int
/**
s390_unregister_adapter_interrupt (adapter_int_handler_t handler)
 * s390_register_adapter_interrupt() - register adapter interrupt handler
 * @handler: adapter handler to be registered
 * @drv_data: driver data passed with each call to the handler
 *
 * Returns:
 *  Pointer to the indicator to be used on success
 *  ERR_PTR() if registration failed
 */
void *s390_register_adapter_interrupt(adapter_int_handler_t handler,
				      void *drv_data)
{
{
	struct airq_t *airq;
	char dbf_txt[16];
	int ret;
	int ret;
	char dbf_txt[15];

	CIO_TRACE_EVENT (4, "urgaint");


	if (handler == NULL)
	airq = kmalloc(sizeof(struct airq_t), GFP_KERNEL);
		ret = -EINVAL;
	if (!airq) {
	else {
		ret = -ENOMEM;
		adapter_handler = NULL;
		goto out;
		synchronize_sched();  /* Allow interrupts to complete. */
		ret = 0;
	}
	}
	sprintf (dbf_txt, "ret:%d", ret);
	airq->handler = handler;
	airq->drv_data = drv_data;
	ret = register_airq(airq);
	if (ret < 0)
		kfree(airq);
out:
	snprintf(dbf_txt, sizeof(dbf_txt), "rairq:%d", ret);
	CIO_TRACE_EVENT(4, dbf_txt);
	CIO_TRACE_EVENT(4, dbf_txt);

	if (ret < 0)
	return ret;
		return ERR_PTR(ret);
	else
		return &indicators.byte[ret];
}
}
EXPORT_SYMBOL(s390_register_adapter_interrupt);


void
/**
do_adapter_IO (void)
 * s390_unregister_adapter_interrupt - unregister adapter interrupt handler
 * @ind: indicator for which the handler is to be unregistered
 */
void s390_unregister_adapter_interrupt(void *ind)
{
{
	CIO_TRACE_EVENT (6, "doaio");
	struct airq_t *airq;
	char dbf_txt[16];
	int i;


	if (adapter_handler)
	i = (int) ((addr_t) ind) - ((addr_t) &indicators.byte[0]);
		(*adapter_handler) ();
	snprintf(dbf_txt, sizeof(dbf_txt), "urairq:%d", i);
	CIO_TRACE_EVENT(4, dbf_txt);
	indicators.byte[i] = 0;
	airq = xchg(&airqs[i], NULL);
	/*
	 * Allow interrupts to complete. This will ensure that the airq handle
	 * is no longer referenced by any interrupt handler.
	 */
	synchronize_sched();
	kfree(airq);
}
}

EXPORT_SYMBOL (s390_register_adapter_interrupt);
EXPORT_SYMBOL(s390_unregister_adapter_interrupt);
EXPORT_SYMBOL(s390_unregister_adapter_interrupt);

#define INDICATOR_MASK	(0xffUL << ((NR_AIRQS_PER_WORD - 1) * 8))

void do_adapter_IO(void)
{
	int w;
	int i;
	unsigned long word;
	struct airq_t *airq;

	/*
	 * Access indicator array in word-sized chunks to minimize storage
	 * fetch operations.
	 */
	for (w = 0; w < NR_AIRQ_WORDS; w++) {
		word = indicators.word[w];
		i = w * NR_AIRQS_PER_WORD;
		/*
		 * Check bytes within word for active indicators.
		 */
		while (word) {
			if (word & INDICATOR_MASK) {
				airq = airqs[i];
				if (likely(airq))
					airq->handler(&indicators.byte[i],
						      airq->drv_data);
				else
					/*
					 * Reset ill-behaved indicator.
					 */
					indicators.byte[i] = 0;
			}
			word <<= 8;
			i++;
		}
	}
}

drivers/s390/cio/airq.h

deleted100644 → 0
+0 −10
Original line number Original line Diff line number Diff line
#ifndef S390_AINTERRUPT_H
#define S390_AINTERRUPT_H

typedef	int (*adapter_int_handler_t)(void);

extern int s390_register_adapter_interrupt(adapter_int_handler_t handler);
extern int s390_unregister_adapter_interrupt(adapter_int_handler_t handler);
extern void do_adapter_IO (void);

#endif
+1 −1
Original line number Original line Diff line number Diff line
@@ -23,7 +23,7 @@
#include <asm/reset.h>
#include <asm/reset.h>
#include <asm/ipl.h>
#include <asm/ipl.h>
#include <asm/chpid.h>
#include <asm/chpid.h>
#include "airq.h"
#include <asm/airq.h>
#include "cio.h"
#include "cio.h"
#include "css.h"
#include "css.h"
#include "chsc.h"
#include "chsc.h"
+1 −0
Original line number Original line Diff line number Diff line
@@ -99,6 +99,7 @@ extern int cio_get_options (struct subchannel *);
extern int cio_modify (struct subchannel *);
extern int cio_modify (struct subchannel *);


int cio_create_sch_lock(struct subchannel *);
int cio_create_sch_lock(struct subchannel *);
void do_adapter_IO(void);


/* Use with care. */
/* Use with care. */
#ifdef CONFIG_CCW_CONSOLE
#ifdef CONFIG_CCW_CONSOLE
Loading