From e1068c8a902c66da91d5609c4422f2e5bd308449 Mon Sep 17 00:00:00 2001 From: Carlo Caione Date: Wed, 25 Aug 2021 15:20:44 +0200 Subject: [PATCH 1/2] ipc: Call ipm_set_enabled() also for dual IPM support The IPC drivers rpmsg_service and rpmsg_multi_instance are not explicitly enabling the IPM channels when two different devices are used for TX and RX. While this could be redundant for some IPM drivers, in some cases the hardware needs to be enabled before using it. Add the missing calls to ipm_set_enabled() for both the devices. Signed-off-by: Carlo Caione --- .../ipc/rpmsg_multi_instance/rpmsg_multi_instance.c | 12 ++++++++++++ subsys/ipc/rpmsg_service/rpmsg_backend.c | 13 +++++++++++++ 2 files changed, 25 insertions(+) diff --git a/subsys/ipc/rpmsg_multi_instance/rpmsg_multi_instance.c b/subsys/ipc/rpmsg_multi_instance/rpmsg_multi_instance.c index f21f93d0971a04..7b18b54b6b2c45 100644 --- a/subsys/ipc/rpmsg_multi_instance/rpmsg_multi_instance.c +++ b/subsys/ipc/rpmsg_multi_instance/rpmsg_multi_instance.c @@ -267,6 +267,18 @@ int rpmsg_mi_ctx_init(struct rpmsg_mi_ctx *ctx, const struct rpmsg_mi_ctx_cfg *c /* Register IPM callback. This cb executes when msg has come. */ ipm_register_callback(ctx->ipm_rx_handle, ipm_callback, ctx); + err = ipm_set_enabled(ctx->ipm_tx_handle, 1); + if (err != 0) { + LOG_ERR("Could not enable IPM interrupts and callbacks for TX"); + return err; + } + + err = ipm_set_enabled(ctx->ipm_rx_handle, 1); + if (err != 0) { + LOG_ERR("Could not enable IPM interrupts and callbacks for RX"); + return err; + } + ctx->vq[RPMSG_VQ_0] = virtqueue_allocate(vring_size); if (!ctx->vq[RPMSG_VQ_0]) { LOG_ERR("virtqueue_allocate failed to alloc vq[RPMSG_VQ_0]"); diff --git a/subsys/ipc/rpmsg_service/rpmsg_backend.c b/subsys/ipc/rpmsg_service/rpmsg_backend.c index 07902811f80b09..ccc65b854174d6 100644 --- a/subsys/ipc/rpmsg_service/rpmsg_backend.c +++ b/subsys/ipc/rpmsg_service/rpmsg_backend.c @@ -229,6 +229,19 @@ int rpmsg_backend_init(struct metal_io_region **io, struct virtio_device *vdev) } ipm_register_callback(ipm_rx_handle, ipm_callback, NULL); + + err = ipm_set_enabled(ipm_tx_handle, 1); + if (err != 0) { + LOG_ERR("Could not enable IPM interrupts and callbacks for TX"); + return err; + } + + err = ipm_set_enabled(ipm_rx_handle, 1); + if (err != 0) { + LOG_ERR("Could not enable IPM interrupts and callbacks for RX"); + return err; + } + #elif defined(CONFIG_RPMSG_SERVICE_SINGLE_IPM_SUPPORT) ipm_handle = device_get_binding(CONFIG_RPMSG_SERVICE_IPM_NAME); From cb803e82fa61c3906a951dbbcf06f821bd4a1925 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hubert=20Mi=C5=9B?= Date: Wed, 25 Aug 2021 16:44:28 +0200 Subject: [PATCH 2/2] drivers: ipm: fix in nrfx multi instance enabling procedure MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Enabling procedure of IPM in nrfx multi instance implementation verified if given instance is configure as RX. If not it returned an error. Configuring an instance as TX is correct and enabling procedure should work for such configuration. This patch allows enabling IPM channels configured as TX. Signed-off-by: Hubert Miś --- drivers/ipm/ipm_nrfx_ipc.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/ipm/ipm_nrfx_ipc.c b/drivers/ipm/ipm_nrfx_ipc.c index b3143f9898290b..7b1e88e6ddb68a 100644 --- a/drivers/ipm/ipm_nrfx_ipc.c +++ b/drivers/ipm/ipm_nrfx_ipc.c @@ -205,7 +205,8 @@ static void vipm_nrf_##_idx##_register_callback(const struct device *dev, \ \ static int vipm_nrf_##_idx##_set_enabled(const struct device *dev, int enable)\ { \ - if (!IS_ENABLED(CONFIG_IPM_MSG_CH_##_idx##_RX)) { \ + if (!(IS_ENABLED(CONFIG_IPM_MSG_CH_##_idx##_RX) || \ + IS_ENABLED(CONFIG_IPM_MSG_CH_##_idx##_TX))) { \ LOG_ERR("IPM_" #_idx " is TX message channel"); \ return -EINVAL; \ } else if (enable) { \