* [PATCH] generic hardirq type setting
@ 2006-01-19 1:17 Paul Mundt
2006-01-19 1:32 ` Paul Mundt
0 siblings, 1 reply; 2+ messages in thread
From: Paul Mundt @ 2006-01-19 1:17 UTC (permalink / raw)
To: linux-arch
[-- Attachment #1: Type: text/plain, Size: 3495 bytes --]
Now that Russell's SA_TRIGGER_* changes went in, I've been updating some
of the SH code to support it. ARM supports a ->set_type() through its
struct irqchip so doesn't have to deal with this, but this requires a bit
more work for architectures that are using generic hardirqs.
I've added a ->set_type() to struct hw_interrupt_type to deal with this,
which seems like the least invasive solution. dhowells made a note about
handling and returning errors for invalid type configurations when
Russell's initial patch was posted, so I've implemented this as well.
Any comments?
Signed-off-by: Paul Mundt <lethal@linux-sh.org>
---
arch/sh/kernel/cpu/irq/pint.c | 19 +++++++++++++++++++
include/linux/irq.h | 1 +
kernel/irq/manage.c | 19 +++++++++++++++++--
3 files changed, 37 insertions(+), 2 deletions(-)
diff --git a/arch/sh/kernel/cpu/irq/pint.c b/arch/sh/kernel/cpu/irq/pint.c
index 95d6024..ca4bb94 100644
--- a/arch/sh/kernel/cpu/irq/pint.c
+++ b/arch/sh/kernel/cpu/irq/pint.c
@@ -37,9 +37,28 @@ static unsigned int startup_pint_irq(uns
return 0; /* never anything pending */
}
+static int set_type_pint_irq(unsigned int irq, unsigned int type)
+{
+ unsigned int val;
+
+ /* Only level detection is possible */
+ if (unlikely(!(type & (SA_TRIGGER_HIGH | SA_TRIGGER_LOW))))
+ return -EINVAL;
+
+ val = ctrl_inw(INTC_ICR2);
+ if (type & SA_TRIGGER_HIGH)
+ val |= (1 << (irq - PINT_IRQ_BASE));
+ else
+ val &= ~(1 << (irq - PINT_IRQ_BASE));
+ ctrl_outw(val, INTC_ICR2);
+
+ return 0;
+}
+
static struct hw_interrupt_type pint_irq_type = {
.typename = "PINT-IRQ",
.startup = startup_pint_irq,
+ .set_type = set_type_pint_irq,
.shutdown = shutdown_pint_irq,
.enable = enable_pint_irq,
.disable = disable_pint_irq,
diff --git a/include/linux/irq.h b/include/linux/irq.h
index 6c5d4c8..904cffa 100644
--- a/include/linux/irq.h
+++ b/include/linux/irq.h
@@ -53,6 +53,7 @@ struct hw_interrupt_type {
void (*ack)(unsigned int irq);
void (*end)(unsigned int irq);
void (*set_affinity)(unsigned int irq, cpumask_t dest);
+ int (*set_type)(unsigned int irq, unsigned int type);
/* Currently used only by UML, might disappear one day.*/
#ifdef CONFIG_IRQ_RELEASE_METHOD
void (*release)(unsigned int irq, void *dev_id);
diff --git a/kernel/irq/manage.c b/kernel/irq/manage.c
index 97d5559..4ec7c9a 100644
--- a/kernel/irq/manage.c
+++ b/kernel/irq/manage.c
@@ -203,8 +203,12 @@ int setup_irq(unsigned int irq, struct i
spin_lock_irqsave(&desc->lock,flags);
p = &desc->action;
if ((old = *p) != NULL) {
- /* Can't share interrupts unless both agree to */
- if (!(old->flags & new->flags & SA_SHIRQ)) {
+ /*
+ * Can't share interrupts unless both agree to and are
+ * the same type.
+ */
+ if (!(old->flags & new->flags & SA_SHIRQ) ||
+ (~old->flags & new->flags & SA_TRIGGER_MASK)) {
spin_unlock_irqrestore(&desc->lock,flags);
return -EBUSY;
}
@@ -220,6 +224,17 @@ int setup_irq(unsigned int irq, struct i
*p = new;
if (!shared) {
+ if (desc->handler->set_type) {
+ unsigned int type = new->flags & SA_TRIGGER_MASK;
+ int ret;
+
+ ret = desc->handler->set_type(irq, type);
+ if (unlikely(ret != 0)) {
+ spin_unlock_irqrestore(&desc->lock, flags);
+ return ret;
+ }
+ }
+
desc->depth = 0;
desc->status &= ~(IRQ_DISABLED | IRQ_AUTODETECT |
IRQ_WAITING | IRQ_INPROGRESS);
[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] generic hardirq type setting
2006-01-19 1:17 [PATCH] generic hardirq type setting Paul Mundt
@ 2006-01-19 1:32 ` Paul Mundt
0 siblings, 0 replies; 2+ messages in thread
From: Paul Mundt @ 2006-01-19 1:32 UTC (permalink / raw)
To: linux-arch
[-- Attachment #1: Type: text/plain, Size: 3585 bytes --]
On Thu, Jan 19, 2006 at 03:17:37AM +0200, Paul Mundt wrote:
> Now that Russell's SA_TRIGGER_* changes went in, I've been updating some
> of the SH code to support it. ARM supports a ->set_type() through its
> struct irqchip so doesn't have to deal with this, but this requires a bit
> more work for architectures that are using generic hardirqs.
>
> I've added a ->set_type() to struct hw_interrupt_type to deal with this,
> which seems like the least invasive solution. dhowells made a note about
> handling and returning errors for invalid type configurations when
> Russell's initial patch was posted, so I've implemented this as well.
>
And here's the right patch without the misplaced ).. Sorry for the noise.
---
arch/sh/kernel/cpu/irq/pint.c | 19 +++++++++++++++++++
include/linux/irq.h | 1 +
kernel/irq/manage.c | 19 +++++++++++++++++--
3 files changed, 37 insertions(+), 2 deletions(-)
diff --git a/arch/sh/kernel/cpu/irq/pint.c b/arch/sh/kernel/cpu/irq/pint.c
index 95d6024..ca4bb94 100644
--- a/arch/sh/kernel/cpu/irq/pint.c
+++ b/arch/sh/kernel/cpu/irq/pint.c
@@ -37,9 +37,28 @@ static unsigned int startup_pint_irq(uns
return 0; /* never anything pending */
}
+static int set_type_pint_irq(unsigned int irq, unsigned int type)
+{
+ unsigned int val;
+
+ /* Only level detection is possible */
+ if (unlikely(!(type & (SA_TRIGGER_HIGH | SA_TRIGGER_LOW))))
+ return -EINVAL;
+
+ val = ctrl_inw(INTC_ICR2);
+ if (type & SA_TRIGGER_HIGH)
+ val |= (1 << (irq - PINT_IRQ_BASE));
+ else
+ val &= ~(1 << (irq - PINT_IRQ_BASE));
+ ctrl_outw(val, INTC_ICR2);
+
+ return 0;
+}
+
static struct hw_interrupt_type pint_irq_type = {
.typename = "PINT-IRQ",
.startup = startup_pint_irq,
+ .set_type = set_type_pint_irq,
.shutdown = shutdown_pint_irq,
.enable = enable_pint_irq,
.disable = disable_pint_irq,
diff --git a/include/linux/irq.h b/include/linux/irq.h
index 6c5d4c8..904cffa 100644
--- a/include/linux/irq.h
+++ b/include/linux/irq.h
@@ -53,6 +53,7 @@ struct hw_interrupt_type {
void (*ack)(unsigned int irq);
void (*end)(unsigned int irq);
void (*set_affinity)(unsigned int irq, cpumask_t dest);
+ int (*set_type)(unsigned int irq, unsigned int type);
/* Currently used only by UML, might disappear one day.*/
#ifdef CONFIG_IRQ_RELEASE_METHOD
void (*release)(unsigned int irq, void *dev_id);
diff --git a/kernel/irq/manage.c b/kernel/irq/manage.c
index 97d5559..4ec7c9a 100644
--- a/kernel/irq/manage.c
+++ b/kernel/irq/manage.c
@@ -203,8 +203,12 @@ int setup_irq(unsigned int irq, struct i
spin_lock_irqsave(&desc->lock,flags);
p = &desc->action;
if ((old = *p) != NULL) {
- /* Can't share interrupts unless both agree to */
- if (!(old->flags & new->flags & SA_SHIRQ)) {
+ /*
+ * Can't share interrupts unless both agree to and are
+ * the same type.
+ */
+ if (!(old->flags & new->flags & SA_SHIRQ) ||
+ (~old->flags & new->flags) & SA_TRIGGER_MASK) {
spin_unlock_irqrestore(&desc->lock,flags);
return -EBUSY;
}
@@ -220,6 +224,17 @@ int setup_irq(unsigned int irq, struct i
*p = new;
if (!shared) {
+ if (desc->handler->set_type) {
+ unsigned int type = new->flags & SA_TRIGGER_MASK;
+ int ret;
+
+ ret = desc->handler->set_type(irq, type);
+ if (unlikely(ret != 0)) {
+ spin_unlock_irqrestore(&desc->lock, flags);
+ return ret;
+ }
+ }
+
desc->depth = 0;
desc->status &= ~(IRQ_DISABLED | IRQ_AUTODETECT |
IRQ_WAITING | IRQ_INPROGRESS);
[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2006-01-19 1:33 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-01-19 1:17 [PATCH] generic hardirq type setting Paul Mundt
2006-01-19 1:32 ` Paul Mundt
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox