summaryrefslogtreecommitdiffstats
path: root/drivers/uio
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-08-07 13:18:06 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-08-07 13:18:06 +0000
commit638a9e433ecd61e64761352dbec1fa4f5874c941 (patch)
treefdbff74a238d7a5a7d1cef071b7230bc064b9f25 /drivers/uio
parentReleasing progress-linux version 6.9.12-1~progress7.99u1. (diff)
downloadlinux-638a9e433ecd61e64761352dbec1fa4f5874c941.tar.xz
linux-638a9e433ecd61e64761352dbec1fa4f5874c941.zip
Merging upstream version 6.10.3.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r--drivers/uio/Kconfig18
-rw-r--r--drivers/uio/Makefile1
-rw-r--r--drivers/uio/uio.c24
-rw-r--r--drivers/uio/uio_fsl_elbc_gpcm.c6
-rw-r--r--drivers/uio/uio_hv_generic.c19
-rw-r--r--drivers/uio/uio_pdrv_genirq.c10
-rw-r--r--drivers/uio/uio_pruss.c255
7 files changed, 35 insertions, 298 deletions
diff --git a/drivers/uio/Kconfig b/drivers/uio/Kconfig
index 2e16c5338e..b060dcd7c6 100644
--- a/drivers/uio/Kconfig
+++ b/drivers/uio/Kconfig
@@ -125,24 +125,6 @@ config UIO_FSL_ELBC_GPCM_NETX5152
Information about this hardware can be found at:
http://www.hilscher.com/netx
-config UIO_PRUSS
- tristate "Texas Instruments PRUSS driver"
- select GENERIC_ALLOCATOR
- depends on HAS_IOMEM && HAS_DMA
- help
- PRUSS driver for OMAPL138/DA850/AM18XX devices
- PRUSS driver requires user space components, examples and user space
- driver is available from below SVN repo - you may use anonymous login
-
- https://gforge.ti.com/gf/project/pru_sw/
-
- More info on API is available at below wiki
-
- http://processors.wiki.ti.com/index.php/PRU_Linux_Application_Loader
-
- To compile this driver as a module, choose M here: the module
- will be called uio_pruss.
-
config UIO_MF624
tristate "Humusoft MF624 DAQ PCI card driver"
depends on PCI
diff --git a/drivers/uio/Makefile b/drivers/uio/Makefile
index f2f416a142..1c5f3b5a95 100644
--- a/drivers/uio/Makefile
+++ b/drivers/uio/Makefile
@@ -7,7 +7,6 @@ obj-$(CONFIG_UIO_AEC) += uio_aec.o
obj-$(CONFIG_UIO_SERCOS3) += uio_sercos3.o
obj-$(CONFIG_UIO_PCI_GENERIC) += uio_pci_generic.o
obj-$(CONFIG_UIO_NETX) += uio_netx.o
-obj-$(CONFIG_UIO_PRUSS) += uio_pruss.o
obj-$(CONFIG_UIO_MF624) += uio_mf624.o
obj-$(CONFIG_UIO_FSL_ELBC_GPCM) += uio_fsl_elbc_gpcm.o
obj-$(CONFIG_UIO_HV_GENERIC) += uio_hv_generic.o
diff --git a/drivers/uio/uio.c b/drivers/uio/uio.c
index 009158fef2..5ce429286a 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;
diff --git a/drivers/uio/uio_fsl_elbc_gpcm.c b/drivers/uio/uio_fsl_elbc_gpcm.c
index 82dda799f3..496caff66e 100644
--- a/drivers/uio/uio_fsl_elbc_gpcm.c
+++ b/drivers/uio/uio_fsl_elbc_gpcm.c
@@ -427,7 +427,7 @@ out_err2:
return ret;
}
-static int uio_fsl_elbc_gpcm_remove(struct platform_device *pdev)
+static void uio_fsl_elbc_gpcm_remove(struct platform_device *pdev)
{
struct uio_info *info = platform_get_drvdata(pdev);
struct fsl_elbc_gpcm *priv = info->priv;
@@ -438,8 +438,6 @@ static int uio_fsl_elbc_gpcm_remove(struct platform_device *pdev)
priv->shutdown(info, false);
iounmap(info->mem[0].internal_addr);
- return 0;
-
}
static const struct of_device_id uio_fsl_elbc_gpcm_match[] = {
@@ -455,7 +453,7 @@ static struct platform_driver uio_fsl_elbc_gpcm_driver = {
.dev_groups = uio_fsl_elbc_gpcm_groups,
},
.probe = uio_fsl_elbc_gpcm_probe,
- .remove = uio_fsl_elbc_gpcm_remove,
+ .remove_new = uio_fsl_elbc_gpcm_remove,
};
module_platform_driver(uio_fsl_elbc_gpcm_driver);
diff --git a/drivers/uio/uio_hv_generic.c b/drivers/uio/uio_hv_generic.c
index 6be3462b10..b456537523 100644
--- a/drivers/uio/uio_hv_generic.c
+++ b/drivers/uio/uio_hv_generic.c
@@ -36,7 +36,6 @@
#define DRIVER_AUTHOR "Stephen Hemminger <sthemmin at microsoft.com>"
#define DRIVER_DESC "Generic UIO driver for VMBus devices"
-#define HV_RING_SIZE 512 /* pages */
#define SEND_BUFFER_SIZE (16 * 1024 * 1024)
#define RECV_BUFFER_SIZE (31 * 1024 * 1024)
@@ -84,6 +83,9 @@ hv_uio_irqcontrol(struct uio_info *info, s32 irq_state)
dev->channel->inbound.ring_buffer->interrupt_mask = !irq_state;
virt_mb();
+ if (!dev->channel->offermsg.monitor_allocated && irq_state)
+ vmbus_setevent(dev->channel);
+
return 0;
}
@@ -143,7 +145,7 @@ static const struct bin_attribute ring_buffer_bin_attr = {
.name = "ring",
.mode = 0600,
},
- .size = 2 * HV_RING_SIZE * PAGE_SIZE,
+ .size = 2 * SZ_2M,
.mmap = hv_uio_ring_mmap,
};
@@ -153,7 +155,7 @@ hv_uio_new_channel(struct vmbus_channel *new_sc)
{
struct hv_device *hv_dev = new_sc->primary_channel->device_obj;
struct device *device = &hv_dev->device;
- const size_t ring_bytes = HV_RING_SIZE * PAGE_SIZE;
+ const size_t ring_bytes = SZ_2M;
int ret;
/* Create host communication ring */
@@ -240,19 +242,16 @@ hv_uio_probe(struct hv_device *dev,
struct hv_uio_private_data *pdata;
void *ring_buffer;
int ret;
+ size_t ring_size = hv_dev_ring_size(channel);
- /* Communicating with host has to be via shared memory not hypercall */
- if (!channel->offermsg.monitor_allocated) {
- dev_err(&dev->device, "vmbus channel requires hypercall\n");
- return -ENOTSUPP;
- }
+ if (!ring_size)
+ ring_size = SZ_2M;
pdata = devm_kzalloc(&dev->device, sizeof(*pdata), GFP_KERNEL);
if (!pdata)
return -ENOMEM;
- ret = vmbus_alloc_ring(channel, HV_RING_SIZE * PAGE_SIZE,
- HV_RING_SIZE * PAGE_SIZE);
+ ret = vmbus_alloc_ring(channel, ring_size, ring_size);
if (ret)
return ret;
diff --git a/drivers/uio/uio_pdrv_genirq.c b/drivers/uio/uio_pdrv_genirq.c
index 63258b6acc..796f5be0a0 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 */
diff --git a/drivers/uio/uio_pruss.c b/drivers/uio/uio_pruss.c
deleted file mode 100644
index f67881cba6..0000000000
--- a/drivers/uio/uio_pruss.c
+++ /dev/null
@@ -1,255 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0-only
-/*
- * Programmable Real-Time Unit Sub System (PRUSS) UIO driver (uio_pruss)
- *
- * This driver exports PRUSS host event out interrupts and PRUSS, L3 RAM,
- * and DDR RAM to user space for applications interacting with PRUSS firmware
- *
- * Copyright (C) 2010-11 Texas Instruments Incorporated - http://www.ti.com/
- */
-#include <linux/device.h>
-#include <linux/module.h>
-#include <linux/moduleparam.h>
-#include <linux/platform_device.h>
-#include <linux/uio_driver.h>
-#include <linux/platform_data/uio_pruss.h>
-#include <linux/io.h>
-#include <linux/clk.h>
-#include <linux/dma-mapping.h>
-#include <linux/sizes.h>
-#include <linux/slab.h>
-#include <linux/genalloc.h>
-
-#define DRV_NAME "pruss_uio"
-#define DRV_VERSION "1.0"
-
-static int sram_pool_sz = SZ_16K;
-module_param(sram_pool_sz, int, 0);
-MODULE_PARM_DESC(sram_pool_sz, "sram pool size to allocate ");
-
-static int extram_pool_sz = SZ_256K;
-module_param(extram_pool_sz, int, 0);
-MODULE_PARM_DESC(extram_pool_sz, "external ram pool size to allocate");
-
-/*
- * Host event IRQ numbers from PRUSS - PRUSS can generate up to 8 interrupt
- * events to AINTC of ARM host processor - which can be used for IPC b/w PRUSS
- * firmware and user space application, async notification from PRU firmware
- * to user space application
- * 3 PRU_EVTOUT0
- * 4 PRU_EVTOUT1
- * 5 PRU_EVTOUT2
- * 6 PRU_EVTOUT3
- * 7 PRU_EVTOUT4
- * 8 PRU_EVTOUT5
- * 9 PRU_EVTOUT6
- * 10 PRU_EVTOUT7
-*/
-#define MAX_PRUSS_EVT 8
-
-#define PINTC_HIDISR 0x0038
-#define PINTC_HIPIR 0x0900
-#define HIPIR_NOPEND 0x80000000
-#define PINTC_HIER 0x1500
-
-struct uio_pruss_dev {
- struct uio_info *info;
- struct clk *pruss_clk;
- dma_addr_t sram_paddr;
- dma_addr_t ddr_paddr;
- void __iomem *prussio_vaddr;
- unsigned long sram_vaddr;
- void *ddr_vaddr;
- unsigned int hostirq_start;
- unsigned int pintc_base;
- struct gen_pool *sram_pool;
-};
-
-static irqreturn_t pruss_handler(int irq, struct uio_info *info)
-{
- struct uio_pruss_dev *gdev = info->priv;
- int intr_bit = (irq - gdev->hostirq_start + 2);
- int val, intr_mask = (1 << intr_bit);
- void __iomem *base = gdev->prussio_vaddr + gdev->pintc_base;
- void __iomem *intren_reg = base + PINTC_HIER;
- void __iomem *intrdis_reg = base + PINTC_HIDISR;
- void __iomem *intrstat_reg = base + PINTC_HIPIR + (intr_bit << 2);
-
- val = ioread32(intren_reg);
- /* Is interrupt enabled and active ? */
- if (!(val & intr_mask) && (ioread32(intrstat_reg) & HIPIR_NOPEND))
- return IRQ_NONE;
- /* Disable interrupt */
- iowrite32(intr_bit, intrdis_reg);
- return IRQ_HANDLED;
-}
-
-static void pruss_cleanup(struct device *dev, struct uio_pruss_dev *gdev)
-{
- int cnt;
- struct uio_info *p = gdev->info;
-
- for (cnt = 0; cnt < MAX_PRUSS_EVT; cnt++, p++) {
- uio_unregister_device(p);
- }
- iounmap(gdev->prussio_vaddr);
- if (gdev->ddr_vaddr) {
- dma_free_coherent(dev, extram_pool_sz, gdev->ddr_vaddr,
- gdev->ddr_paddr);
- }
- if (gdev->sram_vaddr)
- gen_pool_free(gdev->sram_pool,
- gdev->sram_vaddr,
- sram_pool_sz);
- clk_disable(gdev->pruss_clk);
-}
-
-static int pruss_probe(struct platform_device *pdev)
-{
- struct uio_info *p;
- struct uio_pruss_dev *gdev;
- struct resource *regs_prussio;
- struct device *dev = &pdev->dev;
- int ret, cnt, i, len;
- struct uio_pruss_pdata *pdata = dev_get_platdata(dev);
-
- gdev = devm_kzalloc(dev, sizeof(struct uio_pruss_dev), GFP_KERNEL);
- if (!gdev)
- return -ENOMEM;
-
- gdev->info = devm_kcalloc(dev, MAX_PRUSS_EVT, sizeof(*p), GFP_KERNEL);
- if (!gdev->info)
- return -ENOMEM;
-
- /* Power on PRU in case its not done as part of boot-loader */
- gdev->pruss_clk = devm_clk_get(dev, "pruss");
- if (IS_ERR(gdev->pruss_clk)) {
- dev_err(dev, "Failed to get clock\n");
- return PTR_ERR(gdev->pruss_clk);
- }
-
- ret = clk_enable(gdev->pruss_clk);
- if (ret) {
- dev_err(dev, "Failed to enable clock\n");
- return ret;
- }
-
- regs_prussio = platform_get_resource(pdev, IORESOURCE_MEM, 0);
- if (!regs_prussio) {
- dev_err(dev, "No PRUSS I/O resource specified\n");
- ret = -EIO;
- goto err_clk_disable;
- }
-
- if (!regs_prussio->start) {
- dev_err(dev, "Invalid memory resource\n");
- ret = -EIO;
- goto err_clk_disable;
- }
-
- if (pdata->sram_pool) {
- gdev->sram_pool = pdata->sram_pool;
- gdev->sram_vaddr =
- (unsigned long)gen_pool_dma_alloc(gdev->sram_pool,
- sram_pool_sz, &gdev->sram_paddr);
- if (!gdev->sram_vaddr) {
- dev_err(dev, "Could not allocate SRAM pool\n");
- ret = -ENOMEM;
- goto err_clk_disable;
- }
- }
-
- gdev->ddr_vaddr = dma_alloc_coherent(dev, extram_pool_sz,
- &(gdev->ddr_paddr), GFP_KERNEL | GFP_DMA);
- if (!gdev->ddr_vaddr) {
- dev_err(dev, "Could not allocate external memory\n");
- ret = -ENOMEM;
- goto err_free_sram;
- }
-
- len = resource_size(regs_prussio);
- gdev->prussio_vaddr = ioremap(regs_prussio->start, len);
- if (!gdev->prussio_vaddr) {
- dev_err(dev, "Can't remap PRUSS I/O address range\n");
- ret = -ENOMEM;
- goto err_free_ddr_vaddr;
- }
-
- ret = platform_get_irq(pdev, 0);
- if (ret < 0)
- goto err_unmap;
-
- gdev->hostirq_start = ret;
- gdev->pintc_base = pdata->pintc_base;
-
- for (cnt = 0, p = gdev->info; cnt < MAX_PRUSS_EVT; cnt++, p++) {
- p->mem[0].addr = regs_prussio->start;
- p->mem[0].size = resource_size(regs_prussio);
- p->mem[0].memtype = UIO_MEM_PHYS;
-
- p->mem[1].addr = gdev->sram_paddr;
- p->mem[1].size = sram_pool_sz;
- p->mem[1].memtype = UIO_MEM_PHYS;
-
- p->mem[2].addr = (uintptr_t) gdev->ddr_vaddr;
- p->mem[2].dma_addr = gdev->ddr_paddr;
- p->mem[2].size = extram_pool_sz;
- p->mem[2].memtype = UIO_MEM_DMA_COHERENT;
- p->mem[2].dma_device = dev;
-
- p->name = devm_kasprintf(dev, GFP_KERNEL, "pruss_evt%d", cnt);
- p->version = DRV_VERSION;
-
- /* Register PRUSS IRQ lines */
- p->irq = gdev->hostirq_start + cnt;
- p->handler = pruss_handler;
- p->priv = gdev;
-
- ret = uio_register_device(dev, p);
- if (ret < 0)
- goto err_unloop;
- }
-
- platform_set_drvdata(pdev, gdev);
- return 0;
-
-err_unloop:
- for (i = 0, p = gdev->info; i < cnt; i++, p++) {
- uio_unregister_device(p);
- }
-err_unmap:
- iounmap(gdev->prussio_vaddr);
-err_free_ddr_vaddr:
- dma_free_coherent(dev, extram_pool_sz, gdev->ddr_vaddr,
- gdev->ddr_paddr);
-err_free_sram:
- if (pdata->sram_pool)
- gen_pool_free(gdev->sram_pool, gdev->sram_vaddr, sram_pool_sz);
-err_clk_disable:
- clk_disable(gdev->pruss_clk);
-
- return ret;
-}
-
-static int pruss_remove(struct platform_device *dev)
-{
- struct uio_pruss_dev *gdev = platform_get_drvdata(dev);
-
- pruss_cleanup(&dev->dev, gdev);
- return 0;
-}
-
-static struct platform_driver pruss_driver = {
- .probe = pruss_probe,
- .remove = pruss_remove,
- .driver = {
- .name = DRV_NAME,
- },
-};
-
-module_platform_driver(pruss_driver);
-
-MODULE_LICENSE("GPL v2");
-MODULE_VERSION(DRV_VERSION);
-MODULE_AUTHOR("Amit Chatterjee <amit.chatterjee@ti.com>");
-MODULE_AUTHOR("Pratheesh Gangadhar <pratheesh@ti.com>");