All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3 0/2] uio: pdrv_gen_irq and threaded intrerrupts
@ 2024-04-12  4:55 Chris Packham
  2024-04-12  4:55 ` [PATCH v3 1/2] uio_pdrv_genirq: convert to use device_property APIs Chris Packham
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Chris Packham @ 2024-04-12  4:55 UTC (permalink / raw)
  To: gregkh, guanghuifeng, cleech, njavali; +Cc: linux-kernel, Chris Packham

I've combined these two commits submitted separatedly [1][2] into a small
series. They can be applied separately as they are not dependent on each other.

[1] - https://lore.kernel.org/lkml/20240325015045.778718-1-chris.packham@alliedtelesis.co.nz/
[2] - https://lore.kernel.org/lkml/20240325015045.778718-1-chris.packham@alliedtelesis.co.nz/

Chris Packham (2):
  uio_pdrv_genirq: convert to use device_property APIs
  uio: use threaded interrupts

 drivers/uio/uio.c             | 24 +++++++++++++++++++-----
 drivers/uio/uio_pdrv_genirq.c | 10 +++++-----
 2 files changed, 24 insertions(+), 10 deletions(-)

-- 
2.43.2


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH v3 1/2] uio_pdrv_genirq: convert to use device_property APIs
  2024-04-12  4:55 [PATCH v3 0/2] uio: pdrv_gen_irq and threaded intrerrupts Chris Packham
@ 2024-04-12  4:55 ` Chris Packham
  2024-04-12  4:55 ` [PATCH v3 2/2] uio: use threaded interrupts Chris Packham
  2024-04-12  7:49 ` [PATCH v3 0/2] uio: pdrv_gen_irq and threaded intrerrupts Greg KH
  2 siblings, 0 replies; 4+ messages in thread
From: Chris Packham @ 2024-04-12  4:55 UTC (permalink / raw)
  To: gregkh, guanghuifeng, cleech, njavali; +Cc: linux-kernel, Chris Packham

Convert the uio_pdrv_genirq driver to use the device_property_* APIs
instead of the of_property_* ones. This allows UIO interrupts to be
defined via an ACPI overlay using the Device Tree namespace linkage.

Signed-off-by: Chris Packham <chris.packham@alliedtelesis.co.nz>
---

Notes:
    Changes in v3:
    - None
    Changes in v2:
    - Remove extraneous newline

 drivers/uio/uio_pdrv_genirq.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/uio/uio_pdrv_genirq.c b/drivers/uio/uio_pdrv_genirq.c
index 63258b6accc4..796f5be0a086 100644
--- a/drivers/uio/uio_pdrv_genirq.c
+++ b/drivers/uio/uio_pdrv_genirq.c
@@ -23,8 +23,8 @@
 #include <linux/irq.h>
 
 #include <linux/of.h>
-#include <linux/of_platform.h>
-#include <linux/of_address.h>
+#include <linux/mod_devicetable.h>
+#include <linux/property.h>
 
 #define DRIVER_NAME "uio_pdrv_genirq"
 
@@ -110,7 +110,7 @@ static void uio_pdrv_genirq_cleanup(void *data)
 static int uio_pdrv_genirq_probe(struct platform_device *pdev)
 {
 	struct uio_info *uioinfo = dev_get_platdata(&pdev->dev);
-	struct device_node *node = pdev->dev.of_node;
+	struct fwnode_handle *node = dev_fwnode(&pdev->dev);
 	struct uio_pdrv_genirq_platdata *priv;
 	struct uio_mem *uiomem;
 	int ret = -EINVAL;
@@ -127,11 +127,11 @@ static int uio_pdrv_genirq_probe(struct platform_device *pdev)
 			return -ENOMEM;
 		}
 
-		if (!of_property_read_string(node, "linux,uio-name", &name))
+		if (!device_property_read_string(&pdev->dev, "linux,uio-name", &name))
 			uioinfo->name = devm_kstrdup(&pdev->dev, name, GFP_KERNEL);
 		else
 			uioinfo->name = devm_kasprintf(&pdev->dev, GFP_KERNEL,
-						       "%pOFn", node);
+						       "%pfwP", node);
 
 		uioinfo->version = "devicetree";
 		/* Multiple IRQs are not supported */
-- 
2.43.2


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH v3 2/2] uio: use threaded interrupts
  2024-04-12  4:55 [PATCH v3 0/2] uio: pdrv_gen_irq and threaded intrerrupts Chris Packham
  2024-04-12  4:55 ` [PATCH v3 1/2] uio_pdrv_genirq: convert to use device_property APIs Chris Packham
@ 2024-04-12  4:55 ` Chris Packham
  2024-04-12  7:49 ` [PATCH v3 0/2] uio: pdrv_gen_irq and threaded intrerrupts Greg KH
  2 siblings, 0 replies; 4+ messages in thread
From: Chris Packham @ 2024-04-12  4:55 UTC (permalink / raw)
  To: gregkh, guanghuifeng, cleech, njavali; +Cc: linux-kernel, Chris Packham

Split the existing uio_interrupt into a hardirq handler and a thread
function. The hardirq handler deals with the interrupt source in
hardware, the thread function notifies userspace that there is an event
to be handled.

Signed-off-by: Chris Packham <chris.packham@alliedtelesis.co.nz>
---

Notes:
    I find myself needing to have a UIO interrupt associated with an
    interrupt pin on a PCA9539 (yes I know, it's a terrible chip but HW
    engineers love it because it's cheap).
    
    Prior to this the UIO registration fails with:
    
      [    6.484699] uio_pdrv_genirq detect-gpio-9: unable to register uio device
      [    6.484722] uio_pdrv_genirq detect-gpio-9: probe with driver uio_pdrv_genirq failed with error -22
    
    The -EINVAL ultimately comes from __setup_irq() where it knows the
    interrupt descriptor is nested but we haven't provided a thread_fn.
    
    Changes in v3:
    - Update kerneldoc comment for uio_interrupt_handler()
    - Add kerneldoc comment for uio_interrupt_thread()
    Changes in v2:
    - None

 drivers/uio/uio.c | 24 +++++++++++++++++++-----
 1 file changed, 19 insertions(+), 5 deletions(-)

diff --git a/drivers/uio/uio.c b/drivers/uio/uio.c
index bb77de6fa067..b424f004404f 100644
--- a/drivers/uio/uio.c
+++ b/drivers/uio/uio.c
@@ -438,22 +438,36 @@ void uio_event_notify(struct uio_info *info)
 EXPORT_SYMBOL_GPL(uio_event_notify);
 
 /**
- * uio_interrupt - hardware interrupt handler
+ * uio_interrupt_handler - hardware interrupt handler
  * @irq: IRQ number, can be UIO_IRQ_CYCLIC for cyclic timer
  * @dev_id: Pointer to the devices uio_device structure
  */
-static irqreturn_t uio_interrupt(int irq, void *dev_id)
+static irqreturn_t uio_interrupt_handler(int irq, void *dev_id)
 {
 	struct uio_device *idev = (struct uio_device *)dev_id;
 	irqreturn_t ret;
 
 	ret = idev->info->handler(irq, idev->info);
 	if (ret == IRQ_HANDLED)
-		uio_event_notify(idev->info);
+		ret = IRQ_WAKE_THREAD;
 
 	return ret;
 }
 
+/**
+ * uio_interrupt_thread - irq thread handler
+ * @irq: IRQ number
+ * @dev_id: Pointer to the devices uio_device structure
+ */
+static irqreturn_t uio_interrupt_thread(int irq, void *dev_id)
+{
+	struct uio_device *idev = (struct uio_device *)dev_id;
+
+	uio_event_notify(idev->info);
+
+	return IRQ_HANDLED;
+}
+
 struct uio_listener {
 	struct uio_device *dev;
 	s32 event_count;
@@ -1024,8 +1038,8 @@ int __uio_register_device(struct module *owner,
 		 * FDs at the time of unregister and therefore may not be
 		 * freed until they are released.
 		 */
-		ret = request_irq(info->irq, uio_interrupt,
-				  info->irq_flags, info->name, idev);
+		ret = request_threaded_irq(info->irq, uio_interrupt_handler, uio_interrupt_thread,
+					   info->irq_flags, info->name, idev);
 		if (ret) {
 			info->uio_dev = NULL;
 			goto err_request_irq;
-- 
2.43.2


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH v3 0/2] uio: pdrv_gen_irq and threaded intrerrupts
  2024-04-12  4:55 [PATCH v3 0/2] uio: pdrv_gen_irq and threaded intrerrupts Chris Packham
  2024-04-12  4:55 ` [PATCH v3 1/2] uio_pdrv_genirq: convert to use device_property APIs Chris Packham
  2024-04-12  4:55 ` [PATCH v3 2/2] uio: use threaded interrupts Chris Packham
@ 2024-04-12  7:49 ` Greg KH
  2 siblings, 0 replies; 4+ messages in thread
From: Greg KH @ 2024-04-12  7:49 UTC (permalink / raw)
  To: Chris Packham; +Cc: guanghuifeng, cleech, njavali, linux-kernel

On Fri, Apr 12, 2024 at 04:55:34PM +1200, Chris Packham wrote:
> I've combined these two commits submitted separatedly [1][2] into a small
> series. They can be applied separately as they are not dependent on each other.
> 
> [1] - https://lore.kernel.org/lkml/20240325015045.778718-1-chris.packham@alliedtelesis.co.nz/
> [2] - https://lore.kernel.org/lkml/20240325015045.778718-1-chris.packham@alliedtelesis.co.nz/
> 
> Chris Packham (2):
>   uio_pdrv_genirq: convert to use device_property APIs
>   uio: use threaded interrupts
> 
>  drivers/uio/uio.c             | 24 +++++++++++++++++++-----
>  drivers/uio/uio_pdrv_genirq.c | 10 +++++-----
>  2 files changed, 24 insertions(+), 10 deletions(-)
> 
> -- 
> 2.43.2
> 

Can you just send a fix-up patch instead?

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2024-04-12  7:49 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-04-12  4:55 [PATCH v3 0/2] uio: pdrv_gen_irq and threaded intrerrupts Chris Packham
2024-04-12  4:55 ` [PATCH v3 1/2] uio_pdrv_genirq: convert to use device_property APIs Chris Packham
2024-04-12  4:55 ` [PATCH v3 2/2] uio: use threaded interrupts Chris Packham
2024-04-12  7:49 ` [PATCH v3 0/2] uio: pdrv_gen_irq and threaded intrerrupts Greg KH

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.