[lkml]   [2017]   [Dec]   [6]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
Patch in this message
Subject[PATCH] uio: Allow to take irq bottom-half into irq_handler with additional dt-binding
Certain Kernel preemption models are using threaded interrupt handlers,
which is in general quite beneficial. However, threaded handlers
introducing additional scheduler overhead, when the bottom-half thread
should be woken up and scheduled for execution. This can result is
additional latency, which in certain cases is not desired.

UIO driver with Generic IRQ handler, that wraps a HW block might suffer
a small degradation when it's bottom half is executed, since it needs
its bottom half to be woken up by the scheduler every time INT is
delivered. For high rate INT signals, this also bring additional
undesired load on the scheduler itself.

Since the actual ACK is performed in the top-half, and bottom-half of
the UIO driver with Generic IRQ handler is relatively slick (only flag
is set based on the INT reception), it might be beneficial to move this
bottom-half to the irq_handler itself, rather than to have a separate
thread to service it.

This patch aims to address the task above, and in addition introduces
a new dt-binding which could be configured on a per-node basis. That
means developers utilizing the UIO driver could decide which UIO
instance is critical in terms of interrupt processing, and move their
corresponding bottom-halves to the irq_handler to fight additional
scheduling latency.

New DT binding:
- no-threaded-irq: when present, request_irq() is called with
IRQF_NO_THREAD flag set, effectively skipping threaded interrupt
handler and taking bottom-half into irq_handler

Signed-off-by: Andrey Zhizhikin <>

diff --git a/drivers/uio/uio_pdrv_genirq.c b/drivers/uio/uio_pdrv_genirq.c
index f598ecd..86427a4 100644
--- a/drivers/uio/uio_pdrv_genirq.c
+++ b/drivers/uio/uio_pdrv_genirq.c
@@ -108,6 +108,7 @@ static int uio_pdrv_genirq_probe(struct platform_device *pdev)
struct uio_pdrv_genirq_platdata *priv;
struct uio_mem *uiomem;
int ret = -EINVAL;
+ int no_threaded_irq = 0;
int i;

if (pdev->dev.of_node) {
@@ -121,6 +122,14 @@ static int uio_pdrv_genirq_probe(struct platform_device *pdev)
uioinfo->name = pdev->dev.of_node->name;
uioinfo->version = "devicetree";
/* Multiple IRQs are not supported */
+ /* read additional property (if exists) and decide whether
+ * to have IRQ bottom half to be executed in a separate
+ * thread, or to have it executed in the irq_handler
+ * context
+ */
+ if (of_property_read_bool(pdev->dev.of_node, "no-threaded-irq"))
+ no_threaded_irq = 1;

if (!uioinfo || !uioinfo->name || !uioinfo->version) {
@@ -134,6 +143,12 @@ static int uio_pdrv_genirq_probe(struct platform_device *pdev)
return ret;

+ /* execute BH in irq_handler if property set in FDT */
+ if ((no_threaded_irq > 0) && !(uioinfo->irq_flags & IRQF_NO_THREAD)) {
+ dev_info(&pdev->dev, "promoting INT with IRQF_NO_THREAD\n");
+ uioinfo->irq_flags |= IRQF_NO_THREAD;
+ }
priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL);
if (!priv) {
dev_err(&pdev->dev, "unable to kmalloc\n");
 \ /
  Last update: 2017-12-06 15:56    [W:0.091 / U:2.292 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site