Commit 0b8d6761 authored by Alex Elder's avatar Alex Elder Committed by Jakub Kicinski

net: ipa: request GSI IRQ later

Introduce gsi_irq_init() and gsi_irq_exit(), to encapsulate looking
up the GSI IRQ and registering its handler.  Call gsi_irq_init() a
little later in gsi_init(), and initialize the completion earlier.
The IRQ handler accesses both the GSI virtual memory pointer and the
completion, and this way these things will have been initialized
before the gsi_irq() can ever be called.
Signed-off-by: default avatarAlex Elder <elder@linaro.org>
Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent 4a04d65c
...@@ -1170,6 +1170,34 @@ static irqreturn_t gsi_isr(int irq, void *dev_id) ...@@ -1170,6 +1170,34 @@ static irqreturn_t gsi_isr(int irq, void *dev_id)
return IRQ_HANDLED; return IRQ_HANDLED;
} }
static int gsi_irq_init(struct gsi *gsi, struct platform_device *pdev)
{
struct device *dev = &pdev->dev;
unsigned int irq;
int ret;
ret = platform_get_irq_byname(pdev, "gsi");
if (ret <= 0) {
dev_err(dev, "DT error %d getting \"gsi\" IRQ property\n", ret);
return ret ? : -EINVAL;
}
irq = ret;
ret = request_irq(irq, gsi_isr, 0, "gsi", gsi);
if (ret) {
dev_err(dev, "error %d requesting \"gsi\" IRQ\n", ret);
return ret;
}
gsi->irq = irq;
return 0;
}
static void gsi_irq_exit(struct gsi *gsi)
{
free_irq(gsi->irq, gsi);
}
/* Return the transaction associated with a transfer completion event */ /* Return the transaction associated with a transfer completion event */
static struct gsi_trans *gsi_event_trans(struct gsi_channel *channel, static struct gsi_trans *gsi_event_trans(struct gsi_channel *channel,
struct gsi_event *event) struct gsi_event *event)
...@@ -1962,7 +1990,6 @@ int gsi_init(struct gsi *gsi, struct platform_device *pdev, ...@@ -1962,7 +1990,6 @@ int gsi_init(struct gsi *gsi, struct platform_device *pdev,
struct device *dev = &pdev->dev; struct device *dev = &pdev->dev;
struct resource *res; struct resource *res;
resource_size_t size; resource_size_t size;
unsigned int irq;
int ret; int ret;
gsi_validate_build(); gsi_validate_build();
...@@ -1976,55 +2003,43 @@ int gsi_init(struct gsi *gsi, struct platform_device *pdev, ...@@ -1976,55 +2003,43 @@ int gsi_init(struct gsi *gsi, struct platform_device *pdev,
*/ */
init_dummy_netdev(&gsi->dummy_dev); init_dummy_netdev(&gsi->dummy_dev);
ret = platform_get_irq_byname(pdev, "gsi");
if (ret <= 0) {
dev_err(dev, "DT error %d getting \"gsi\" IRQ property\n", ret);
return ret ? : -EINVAL;
}
irq = ret;
ret = request_irq(irq, gsi_isr, 0, "gsi", gsi);
if (ret) {
dev_err(dev, "error %d requesting \"gsi\" IRQ\n", ret);
return ret;
}
gsi->irq = irq;
/* Get GSI memory range and map it */ /* Get GSI memory range and map it */
res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "gsi"); res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "gsi");
if (!res) { if (!res) {
dev_err(dev, "DT error getting \"gsi\" memory property\n"); dev_err(dev, "DT error getting \"gsi\" memory property\n");
ret = -ENODEV; return -ENODEV;
goto err_free_irq;
} }
size = resource_size(res); size = resource_size(res);
if (res->start > U32_MAX || size > U32_MAX - res->start) { if (res->start > U32_MAX || size > U32_MAX - res->start) {
dev_err(dev, "DT memory resource \"gsi\" out of range\n"); dev_err(dev, "DT memory resource \"gsi\" out of range\n");
ret = -EINVAL; return -EINVAL;
goto err_free_irq;
} }
gsi->virt = ioremap(res->start, size); gsi->virt = ioremap(res->start, size);
if (!gsi->virt) { if (!gsi->virt) {
dev_err(dev, "unable to remap \"gsi\" memory\n"); dev_err(dev, "unable to remap \"gsi\" memory\n");
ret = -ENOMEM; return -ENOMEM;
goto err_free_irq;
} }
ret = gsi_channel_init(gsi, count, data); init_completion(&gsi->completion);
ret = gsi_irq_init(gsi, pdev);
if (ret) if (ret)
goto err_iounmap; goto err_iounmap;
ret = gsi_channel_init(gsi, count, data);
if (ret)
goto err_irq_exit;
mutex_init(&gsi->mutex); mutex_init(&gsi->mutex);
init_completion(&gsi->completion);
return 0; return 0;
err_irq_exit:
gsi_irq_exit(gsi);
err_iounmap: err_iounmap:
iounmap(gsi->virt); iounmap(gsi->virt);
err_free_irq:
free_irq(gsi->irq, gsi);
return ret; return ret;
} }
...@@ -2034,7 +2049,7 @@ void gsi_exit(struct gsi *gsi) ...@@ -2034,7 +2049,7 @@ void gsi_exit(struct gsi *gsi)
{ {
mutex_destroy(&gsi->mutex); mutex_destroy(&gsi->mutex);
gsi_channel_exit(gsi); gsi_channel_exit(gsi);
free_irq(gsi->irq, gsi); gsi_irq_exit(gsi);
iounmap(gsi->virt); iounmap(gsi->virt);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment