Commit aefaab5d authored by Philippe Gerum's avatar Philippe Gerum
Browse files

cobalt/intr: introduce IRQ disabled state

With the IRQ line enable/disable operations restricted to the root
domain, interrupt handlers may not invoke xnintr_disable() directly to
shut down the interrupt line.

To support this requirement, we add an explicit disabled state to the
interrupt descriptor, which the handler may turn on by returning the
new XN_IRQ_DISABLE operation status. In response, the core disables
the descriptor, shutting down the interrupt line in the same move
instead of unmasking it on return from the interrupt context.

XN_IRQ_DISABLE is exposed by RTDM as RTDM_IRQ_DISABLE.

As a consequence of this change, XN_ISR_NOENABLE was dropped as we
have no in-tree client which need such semantics anymore.

At this chance, various naming and documentation fixes have been
applied.
parent ea7147d0
......@@ -19,6 +19,7 @@
#ifndef _COBALT_KERNEL_INTR_H
#define _COBALT_KERNEL_INTR_H
#include <linux/spinlock.h>
#include <cobalt/kernel/stat.h>
/**
......@@ -26,20 +27,22 @@
* @{
*/
/* Possible return values of ISR. */
#define XN_ISR_NONE 0x1
#define XN_ISR_HANDLED 0x2
/* Additional bits. */
#define XN_ISR_PROPAGATE 0x100
#define XN_ISR_NOENABLE 0x200
#define XN_ISR_BITMASK (~0xff)
/* Possible return values of a handler. */
#define XN_IRQ_NONE 0x1
#define XN_IRQ_HANDLED 0x2
#define XN_IRQ_STATMASK (XN_IRQ_NONE|XN_IRQ_HANDLED)
#define XN_IRQ_PROPAGATE 0x100
#define XN_IRQ_DISABLE 0x200
/* Creation flags. */
#define XN_ISR_SHARED 0x1
#define XN_ISR_EDGE 0x2
/* Init flags. */
#define XN_IRQTYPE_SHARED 0x1
#define XN_IRQTYPE_EDGE 0x2
/* Operational flags. */
#define XN_ISR_ATTACHED 0x10000
/* Status bits. */
#define XN_IRQSTAT_ATTACHED 0
#define _XN_IRQSTAT_ATTACHED (1 << XN_IRQSTAT_ATTACHED)
#define XN_IRQSTAT_DISABLED 1
#define _XN_IRQSTAT_DISABLED (1 << XN_IRQSTAT_DISABLED)
struct xnintr;
struct xnsched;
......@@ -49,47 +52,51 @@ typedef int (*xnisr_t)(struct xnintr *intr);
typedef void (*xniack_t)(unsigned irq, void *arg);
struct xnirqstat {
/* !< Number of handled receipts since attachment. */
/** Number of handled receipts since attachment. */
xnstat_counter_t hits;
/* !< Runtime accounting entity */
/** Runtime accounting entity */
xnstat_exectime_t account;
/* !< Accumulated accounting entity */
/** Accumulated accounting entity */
xnstat_exectime_t sum;
};
struct xnintr {
#ifdef CONFIG_XENO_OPT_SHIRQ
/* !< Next object in the IRQ-sharing chain. */
/** Next object in the IRQ-sharing chain. */
struct xnintr *next;
#endif
/* !< Number of consequent unhandled interrupts */
/** Number of consequent unhandled interrupts */
unsigned int unhandled;
/* !< Interrupt service routine. */
/** Interrupt service routine. */
xnisr_t isr;
/* !< User-defined cookie value. */
/** User-defined cookie value. */
void *cookie;
/* !< Creation flags. */
/** runtime status */
unsigned long status;
/** Creation flags. */
int flags;
/* !< IRQ number. */
/** IRQ number. */
unsigned int irq;
/* !< Interrupt acknowledge routine. */
/** Interrupt acknowledge routine. */
xniack_t iack;
/* !< Symbolic name. */
/** Symbolic name. */
const char *name;
/** Descriptor maintenance lock. */
raw_spinlock_t lock;
#ifdef CONFIG_XENO_OPT_STATS
/* !< Statistics. */
/** Statistics. */
struct xnirqstat *stats;
#endif
};
struct xnintr_iterator {
int cpu; /* !< Current CPU in iteration. */
unsigned long hits; /* !< Current hit counter. */
xnticks_t exectime_period; /* !< Used CPU time in current accounting period. */
xnticks_t account_period; /* !< Length of accounting period. */
xnticks_t exectime_total; /* !< Overall CPU time consumed. */
int list_rev; /* !< System-wide xnintr list revision (internal use). */
struct xnintr *prev; /* !< Previously visited xnintr object (internal use). */
int cpu; /** Current CPU in iteration. */
unsigned long hits; /** Current hit counter. */
xnticks_t exectime_period; /** Used CPU time in current accounting period. */
xnticks_t account_period; /** Length of accounting period. */
xnticks_t exectime_total; /** Overall CPU time consumed. */
int list_rev; /** System-wide xnintr list revision (internal use). */
struct xnintr *prev; /** Previously visited xnintr object (internal use). */
};
extern struct xnintr nktimer;
......
......@@ -765,10 +765,10 @@ typedef struct xnintr rtdm_irq_t;
* @{
*/
/** Enable IRQ-sharing with other real-time drivers */
#define RTDM_IRQTYPE_SHARED XN_ISR_SHARED
#define RTDM_IRQTYPE_SHARED XN_IRQTYPE_SHARED
/** Mark IRQ as edge-triggered, relevant for correct handling of shared
* edge-triggered IRQs */
#define RTDM_IRQTYPE_EDGE XN_ISR_EDGE
#define RTDM_IRQTYPE_EDGE XN_IRQTYPE_EDGE
/** @} RTDM_IRQTYPE_xxx */
/**
......@@ -786,9 +786,11 @@ typedef int (*rtdm_irq_handler_t)(rtdm_irq_t *irq_handle);
* @{
*/
/** Unhandled interrupt */
#define RTDM_IRQ_NONE XN_ISR_NONE
#define RTDM_IRQ_NONE XN_IRQ_NONE
/** Denote handled interrupt */
#define RTDM_IRQ_HANDLED XN_ISR_HANDLED
#define RTDM_IRQ_HANDLED XN_IRQ_HANDLED
/** Request interrupt disabling on exit */
#define RTDM_IRQ_DISABLE XN_IRQ_DISABLE
/** @} RTDM_IRQ_xxx */
/**
......
......@@ -382,9 +382,12 @@ config XENO_OPT_DEBUG_LOCKING
This option activates runtime assertions, and measurements of
spinlocks spinning time and duration in the Cobalt kernel. It
normally has a low overhead, and helps finding latency spots
due to interrupt masked sections. Statistics about the longest
masked section can be found in /proc/xenomai/lock.
helps finding latency spots due to interrupt masked
sections. Statistics about the longest masked section can be
found in /proc/xenomai/lock.
This option may induce a measurable overhead on low end
machines.
config XENO_OPT_DEBUG_SYNCH_RELAX
bool "Detect mutexes held in relaxed sections"
......
This diff is collapsed.
......@@ -512,6 +512,16 @@ DEFINE_EVENT(irq_event, cobalt_irq_exit,
TP_ARGS(irq)
);
DEFINE_EVENT(irq_event, cobalt_irq_attach,
TP_PROTO(unsigned int irq),
TP_ARGS(irq)
);
DEFINE_EVENT(irq_event, cobalt_irq_detach,
TP_PROTO(unsigned int irq),
TP_ARGS(irq)
);
DEFINE_EVENT(irq_event, cobalt_irq_enable,
TP_PROTO(unsigned int irq),
TP_ARGS(irq)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment