public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Magnus Damm <magnus.damm@gmail.com>
To: linux-kernel@vger.kernel.org
Cc: Uwe.Kleine-Koenig@digi.com, gregkh@suse.de,
	akpm@linux-foundation.org, hjk@linutronix.de,
	lethal@linux-sh.org, Magnus Damm <magnus.damm@gmail.com>,
	tglx@linutronix.de, alan@lxorguk.ukuu.org.uk
Subject: [PATCH] uio: User IRQ Mode V2
Date: Sat, 05 Jul 2008 13:21:21 +0900	[thread overview]
Message-ID: <20080705042121.4647.29429.sendpatchset@rx1.opensource.se> (raw)

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 2490 bytes --]

This is V2 of the UIO "User IRQ Mode" patch.

In User IRQ Mode the kernel space interrupt handler simply disables
the serviced interrupt in the interrupt controller and makes the
user space driver responsible for acknowledging the interrupt in
the device and reenabling the interrupt in the interrupt controller.

Shared interrupts are not supported by the User IRQ Mode since the
generic in-kernel interrupt handler will disable the shared interrupt
in the interrupt controller, and in a shared interrupt configuration
this will stop other devices from delivering interrupts.

Signed-off-by: Magnus Damm <damm@igel.co.jp>
Signed-off-by: Uwe Kleine-König <Uwe.Kleine-Koenig@digi.com>
---

 Changes since V1
  - use disable_irq_nosync() in interrupt handler, thanks Alan!

 Changes since Uwe's last version:
  - flags should be unsigned long
  - simplify uio_userirq_handler()

 Similar code has been posted some time ago as:
 "[PATCH] uio_pdrv: Unique IRQ Mode"
 "[PATCH 00/03][RFC] Reusable UIO Platform Driver".

 Needs "[PATCH 0/1] UIO: Add a write() function to enable/disable interrupts"

 include/linux/uio_driver.h |   26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)

--- 0001/include/linux/uio_driver.h
+++ work/include/linux/uio_driver.h	2008-07-05 12:46:09.000000000 +0900
@@ -17,6 +17,7 @@
 #include <linux/module.h>
 #include <linux/fs.h>
 #include <linux/interrupt.h>
+#include <linux/bitops.h>
 
 struct uio_map;
 
@@ -63,6 +64,7 @@ struct uio_info {
 	long			irq;
 	unsigned long		irq_flags;
 	void			*priv;
+	unsigned long		flags;
 	irqreturn_t (*handler)(int irq, struct uio_info *dev_info);
 	int (*mmap)(struct uio_info *info, struct vm_area_struct *vma);
 	int (*open)(struct uio_info *info, struct inode *inode);
@@ -92,4 +94,28 @@ extern void uio_event_notify(struct uio_
 #define UIO_MEM_LOGICAL	2
 #define UIO_MEM_VIRTUAL 3
 
+/* defines for uio_info->flags */
+#define UIO_FLAGS_IRQDISABLED 0
+
+static inline irqreturn_t uio_userirq_handler(int irq, struct uio_info *info)
+{
+	if (!test_and_set_bit(UIO_FLAGS_IRQDISABLED, &info->flags))
+		disable_irq_nosync(info->irq);
+
+	return IRQ_HANDLED;
+}
+
+static inline int uio_userirq_irqcontrol(struct uio_info *info, s32 irq_on)
+{
+	if (irq_on) {
+		if (test_and_clear_bit(UIO_FLAGS_IRQDISABLED, &info->flags))
+			enable_irq(info->irq);
+	} else {
+		if (!test_and_set_bit(UIO_FLAGS_IRQDISABLED, &info->flags))
+			disable_irq(info->irq);
+	}
+
+	return 0;
+}
+
 #endif /* _LINUX_UIO_DRIVER_H_ */

             reply	other threads:[~2008-07-05  4:21 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-07-05  4:21 Magnus Damm [this message]
2008-07-06 12:27 ` [PATCH] uio: User IRQ Mode V2 Hans J. Koch
2008-07-07  1:36   ` Magnus Damm

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20080705042121.4647.29429.sendpatchset@rx1.opensource.se \
    --to=magnus.damm@gmail.com \
    --cc=Uwe.Kleine-Koenig@digi.com \
    --cc=akpm@linux-foundation.org \
    --cc=alan@lxorguk.ukuu.org.uk \
    --cc=gregkh@suse.de \
    --cc=hjk@linutronix.de \
    --cc=lethal@linux-sh.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tglx@linutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox