Skip to contentSkip to conversation

uio: uio_pdrv_genirq: Fixes and support for non-page-aligned memory

PATCH New Esben Haabendal 1 participant 4 messages Jul 1, 2020

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover uio: uio_pdrv_genirq: Fixes and support for non-page-aligned memory

This series inlcudes two fixes for issues when using uio_pdrv_genirq without device tree, and support for using uio_pdrv_genirq with non-page-aligned memory resources.

Esben Haabendal (3):
uio_pdrv_genirq: Remove warning when irq is not specified
uio_pdrv_genirq: fix use without device tree and no interrupt
uio_pdrv_genirq: Allow use with non-page-aligned memory resources

 drivers/uio/uio_pdrv_genirq.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)
Signature · 1 line
2.4.11
#1 lore raw

PATCH 1/3 uio_pdrv_genirq: Remove warning when irq is not specified

Since e3a3c3a20555 ("UIO: fix uio_pdrv_genirq with device tree but no interrupt"), the uio_pdrv_genirq has supported use without interrupt, so the change in 7723f4c5ecdb ("driver core: platform: Add an error message to") added false warnings for those cases.

Fixes 7723f4c5ecdb ("driver core: platform: Add an error message to platform_get_irq*()")
---
 drivers/uio/uio_pdrv_genirq.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/uio/uio_pdrv_genirq.c +1 -1
index ae319ef3a832..1d69dd49c6d2 100644
@@ -159,7 +159,7 @@ static int uio_pdrv_genirq_probe(struct platform_device *pdev)
 	priv->pdev = pdev;
 
 	if (!uioinfo->irq) {
-		ret = platform_get_irq(pdev, 0);
+		ret = platform_get_irq_optional(pdev, 0);
 		uioinfo->irq = ret;
 		if (ret == -ENXIO && pdev->dev.of_node)
 			uioinfo->irq = UIO_IRQ_NONE;
Signature · 1 line
2.4.11
#2 lore raw

PATCH 2/3 uio_pdrv_genirq: fix use without device tree and no interrupt

In reply to Esben Haabendal

While e3a3c3a20555 ("UIO: fix uio_pdrv_genirq with device tree but no interrupt") added support for using uio_pdrv_genirq for devices without interrupt for device tree platforms, the removal of uio_pdrv in 26dac3c49d56 ("uio: Remove uio_pdrv and use uio_pdrv_genirq instead") broke the support for non device tree platforms.

This change fixes this, so that uio_pdrv_genirq can be used without interrupt on all platforms.

This still leaves the support that uio_pdrv had for custom interrupt handler lacking, as uio_pdrv_genirq does not handle it (yet).

Fixes 26dac3c49d56 ("uio: Remove uio_pdrv and use uio_pdrv_genirq instead")
---
 drivers/uio/uio_pdrv_genirq.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/uio/uio_pdrv_genirq.c +1 -1
index 1d69dd49c6d2..b60173bc93ce 100644
@@ -161,7 +161,7 @@ static int uio_pdrv_genirq_probe(struct platform_device *pdev)
 	if (!uioinfo->irq) {
 		ret = platform_get_irq_optional(pdev, 0);
 		uioinfo->irq = ret;
-		if (ret == -ENXIO && pdev->dev.of_node)
+		if (ret == -ENXIO)
 			uioinfo->irq = UIO_IRQ_NONE;
 		else if (ret == -EPROBE_DEFER)
 			return ret;
Signature · 1 line
2.4.11
#3 lore raw

PATCH 3/3 uio_pdrv_genirq: Allow use with non-page-aligned memory resources

In reply to Esben Haabendal

Similar to the changes made in 270579d95f82 ("uio_mf624: Align memory regions to page size and set correct offsets"), this will allow uio_pdrv_genirq devices to expose memory regions that is not page-aligned, requiring the users to respect the offset sysfs attribute (as implemented in libuio).

---
 drivers/uio/uio_pdrv_genirq.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/uio/uio_pdrv_genirq.c +4 -2
index b60173bc93ce..86f75a4fe0e3 100644
@@ -187,8 +187,10 @@ static int uio_pdrv_genirq_probe(struct platform_device *pdev)
 		}
 
 		uiomem->memtype = UIO_MEM_PHYS;
-		uiomem->addr = r->start;
-		uiomem->size = resource_size(r);
+		uiomem->addr = r->start & PAGE_MASK;
+		uiomem->offs = r->start & ~PAGE_MASK;
+		uiomem->size = (uiomem->offs + resource_size(r)
+				+ PAGE_SIZE - 1) & PAGE_MASK;
 		uiomem->name = r->name;
 		++uiomem;
 	}
Signature · 1 line
2.4.11