Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(ipc_interrupt): enable ipc delivery via interrupt in Linux #36

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion demos/linux+freertos/devicetrees/fvp-a-aarch32/linux.dts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@
reg = <0x0 0xf0000000 0x0 0x00010000>;
read-channel = <0x0 0x2000>;
write-channel = <0x2000 0x2000>;
interrupts = <0 52 1>;
interrupts = <0 20 1>;
id = <0>;
};

Expand Down
2 changes: 1 addition & 1 deletion demos/linux+freertos/devicetrees/fvp-a/linux.dts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@
reg = <0x0 0xf0000000 0x0 0x00010000>;
read-channel = <0x0 0x2000>;
write-channel = <0x2000 0x2000>;
interrupts = <0 52 1>;
interrupts = <0 20 1>;
id = <0>;
};

Expand Down
2 changes: 1 addition & 1 deletion demos/linux+freertos/devicetrees/fvp-r/linux.dts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@
reg = <0x0 0x70000000 0x0 0x00010000>;
read-channel = <0x0 0x2000>;
write-channel = <0x2000 0x2000>;
interrupts = <0 52 1>;
interrupts = <0 20 1>;
id = <0>;
};

Expand Down
2 changes: 1 addition & 1 deletion demos/linux+freertos/devicetrees/imx8qm/linux.dts
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@
reg = <0x0 0xf0000000 0x0 0x00010000>;
read-channel = <0x0 0x2000>;
write-channel = <0x2000 0x2000>;
interrupts = <0 52 1>;
interrupts = <0 20 1>;
interrupt-parent = <&gic>;
id = <0>;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@
reg = <0x0 0xf0000000 0x0 0x00010000>;
read-channel = <0x0 0x2000>;
write-channel = <0x2000 0x2000>;
interrupts = <0 52 1>;
interrupts = <0 20 1>;
id = <0>;
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@
read-channel = <0x0 0x2000>;
write-channel = <0x2000 0x2000>;
interrupt-parent = <&plic>;
interrupts = <52>;
interrupts = <20>;
id = <0>;
};

Expand Down
2 changes: 1 addition & 1 deletion demos/linux+freertos/devicetrees/rpi4/linux.dts
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@
reg = <0x0 0xf0000000 0x0 0x00010000>;
read-channel = <0x0 0x2000>;
write-channel = <0x2000 0x2000>;
interrupts = <0 52 1>;
interrupts = <0 20 1>;
id = <0>;
};

Expand Down
4 changes: 2 additions & 2 deletions demos/linux+freertos/devicetrees/tx2/linux.dts
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@
reg = <0x0 0xf0000000 0x0 0x00010000>;
read-channel = <0x0 0x2000>;
write-channel = <0x2000 0x2000>;
interrupts = <0 52 1>;
interrupts = <0 20 1>;
id = <0>;
};

Expand All @@ -195,4 +195,4 @@
bootargs = "clk_ignore_unused ip=192.168.42.15 carrier_timeout=0";
};

};
};
2 changes: 1 addition & 1 deletion demos/linux+freertos/devicetrees/zcu104/linux.dts
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@
reg = <0x0 0xf0000000 0x0 0x00010000>;
read-channel = <0x0 0x2000>;
write-channel = <0x2000 0x2000>;
interrupts = <0 52 1>;
interrupts = <0 20 1>;
id = <0>;
};

Expand Down
2 changes: 1 addition & 1 deletion demos/linux+zephyr/devicetrees/fvp-a-aarch32/linux.dts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@
reg = <0x0 0xf0000000 0x0 0x00010000>;
read-channel = <0x0 0x2000>;
write-channel = <0x2000 0x2000>;
interrupts = <0 52 1>;
interrupts = <0 20 1>;
id = <0>;
};

Expand Down
2 changes: 1 addition & 1 deletion demos/linux+zephyr/devicetrees/fvp-a/linux.dts
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
reg = <0x0 0xf0000000 0x0 0x00010000>;
read-channel = <0x0 0x2000>;
write-channel = <0x2000 0x2000>;
interrupts = <0 52 1>;
interrupts = <0 20 1>;
id = <0>;
};

Expand Down
2 changes: 1 addition & 1 deletion demos/linux+zephyr/devicetrees/fvp-r/linux.dts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
reg = <0x0 0x70000000 0x0 0x00010000>;
read-channel = <0x0 0x2000>;
write-channel = <0x2000 0x2000>;
interrupts = <0 52 1>;
interrupts = <0 20 1>;
id = <0>;
};

Expand Down
2 changes: 1 addition & 1 deletion demos/linux+zephyr/devicetrees/imx8qm/linux.dts
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@
reg = <0x0 0xf0000000 0x0 0x00010000>;
read-channel = <0x0 0x2000>;
write-channel = <0x2000 0x2000>;
interrupts = <0 52 1>;
interrupts = <0 20 1>;
interrupt-parent = <&gic>;
id = <0>;
};
Expand Down
2 changes: 1 addition & 1 deletion demos/linux+zephyr/devicetrees/qemu-aarch64-virt/linux.dts
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@
reg = <0x0 0xf0000000 0x0 0x00010000>;
read-channel = <0x0 0x2000>;
write-channel = <0x2000 0x2000>;
interrupts = <0 52 1>;
interrupts = <0 20 1>;
id = <0>;
};

Expand Down
2 changes: 1 addition & 1 deletion demos/linux+zephyr/devicetrees/rpi4/linux.dts
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@
reg = <0x0 0xf0000000 0x0 0x00010000>;
read-channel = <0x0 0x2000>;
write-channel = <0x2000 0x2000>;
interrupts = <0 52 1>;
interrupts = <0 20 1>;
id = <0>;
};

Expand Down
4 changes: 2 additions & 2 deletions demos/linux+zephyr/devicetrees/tx2/linux.dts
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@
reg = <0x0 0xf0000000 0x0 0x00010000>;
read-channel = <0x0 0x2000>;
write-channel = <0x2000 0x2000>;
interrupts = <0 52 1>;
interrupts = <0 20 1>;
id = <0>;
};

Expand All @@ -195,4 +195,4 @@
bootargs = "clk_ignore_unused ip=192.168.42.15 carrier_timeout=0";
};

};
};
2 changes: 1 addition & 1 deletion demos/linux+zephyr/devicetrees/zcu104/linux.dts
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@
reg = <0x0 0xf0000000 0x0 0x00010000>;
read-channel = <0x0 0x2000>;
write-channel = <0x2000 0x2000>;
interrupts = <0 52 1>;
interrupts = <0 20 1>;
id = <0>;
};

Expand Down
1 change: 1 addition & 0 deletions demos/linux+zephyr/zephyr/app/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ void uart_rx_handler() {
snprintf(msg, MSG_SIZE,
"zephyr has received %ld uart interrupts!\n", irq_count);
bao_ipcshmem_write(shmem, msg, strnlen(msg, MSG_SIZE)+1);
bao_ipcshmem_notify(shmem);
}

void shmem_irq_handler(const struct device *dev) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
From be0d07b654e3e1011e87df84709155683120acd3 Mon Sep 17 00:00:00 2001
From: Clay Chang <[email protected]>
Date: Mon, 17 Jul 2023 18:49:55 +0800
Subject: [PATCH 3/3] bao-ipcshmem: receive ipc message from ipc interrupt

---
drivers/bao/bao-ipcshmem.c | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)

diff --git a/drivers/bao/bao-ipcshmem.c b/drivers/bao/bao-ipcshmem.c
index e9cc304ea..9af4f6e37 100644
--- a/drivers/bao/bao-ipcshmem.c
+++ b/drivers/bao/bao-ipcshmem.c
@@ -181,6 +181,15 @@ static struct file_operations bao_ipcshmem_fops = {
.release = bao_ipcshmem_release_fops
};

+static irqreturn_t ipc_message_handler(int irq, void *data)
+{
+ struct bao_ipcshmem *bao = (struct bao_ipcshmem *)data;
+
+ pr_info("ipc message: %s", (char *)bao->read_base);
+
+ return IRQ_HANDLED;
+}
+
int bao_ipcshmem_register(struct platform_device *pdev)
{
int ret = 0;
@@ -194,6 +203,7 @@ int bao_ipcshmem_register(struct platform_device *pdev)
bool rd_in_range, wr_in_range, disjoint;
void* shmem_base_addr = NULL;
int id = -1;
+ unsigned int irq;
struct bao_ipcshmem *bao;

r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
@@ -241,6 +251,13 @@ int bao_ipcshmem_register(struct platform_device *pdev)
bao->write_base = shmem_base_addr + write_offset;
bao->physical_base = (void *)r->start;

+ irq = platform_get_irq(pdev, 0);
+ ret = devm_request_irq(&pdev->dev, irq, ipc_message_handler, IRQF_TRIGGER_RISING, bao->label, (void *)bao);
+ if (ret != 0) {
+ pr_err("failed to request irq: ret=%d\n", ret);
+ goto err_unmap;
+ }
+
cdev_init(&bao->cdev, &bao_ipcshmem_fops);
bao->cdev.owner = owner;

@@ -322,4 +339,5 @@ module_exit(bao_ipcshmem_exit);
MODULE_LICENSE("GPL");
MODULE_AUTHOR("David Cerdeira");
MODULE_AUTHOR("José Martins");
+MODULE_AUTHOR("Clay Chang");
MODULE_DESCRIPTION("bao ipc through shared-memory sample driver");
--
2.34.1