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

Add ipm driver for AMD-Xilinx platforms. #61008

Merged
merged 2 commits into from
Aug 15, 2023

Conversation

tnmysh
Copy link
Contributor

@tnmysh tnmysh commented Jul 31, 2023

This PR introduces new IPM driver for AMD-Xilinx platforms.

The sample demo is available in openamp-system-reference repository here that is using this driver to communicate with host processor: https://github.com/OpenAMP/openamp-system-reference/tree/main/examples/zephyr/rpmsg_multi_services

This PR also extends MPU SRAM_PRIV region from 64M to 2G for this demo to work.

openamp shared memory regions can be anywhere in DDR memory
withing 2G range. Current SRAM_PRIV region is 64M which
prevents access of shared memory (vrings) by RPU (cortex-r5)
if it is out of 64M range. This patch allows vrings to be in DDR within
2G address space.

Developed-by: Dan Millea
Commited by: Tanmay Shah

Signed-off-by: Dan Milea <dan.milea@windriver.com>
Signed-off-by: Tanmay Shah <tanmay.shah@amd.com>
@tnmysh tnmysh changed the title Add AMD-Xilinx Platforms ipm driver Add AMD-Xilinx platforms ipm driver Jul 31, 2023
@zephyrbot zephyrbot added area: Devicetree Binding PR modifies or adds a Device Tree binding area: IPM Inter-Processor Mailbox platform: Xilinx Xilinx labels Jul 31, 2023
@tnmysh tnmysh changed the title Add AMD-Xilinx platforms ipm driver Add ipm driver for AMD-Xilinx platforms. Jul 31, 2023
Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello @TanmayShah-xilinx, and thank you very much for your first pull request to the Zephyr project!

A project maintainer just triggered our CI pipeline to run it against your PR and ensure it's compliant and doesn't cause any issues. You might want to take this opportunity to review the project's Contributor Expectations and make any updates to your pull request if necessary. 😊

Copy link
Collaborator

@uLipe uLipe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have some question and initial minor nitpicks here.

drivers/ipm/Kconfig Show resolved Hide resolved
drivers/ipm/ipm_xlnx_ipi.c Show resolved Hide resolved
drivers/ipm/ipm_xlnx_ipi.c Outdated Show resolved Hide resolved
drivers/ipm/ipm_xlnx_ipi.c Show resolved Hide resolved
drivers/ipm/ipm_xlnx_ipi.c Show resolved Hide resolved
drivers/ipm/ipm_xlnx_ipi.c Outdated Show resolved Hide resolved
@tnmysh
Copy link
Contributor Author

tnmysh commented Aug 7, 2023

@carlocaione @uLipe requesting reviews.

@uLipe uLipe requested a review from carlocaione August 7, 2023 16:11
@tnmysh
Copy link
Contributor Author

tnmysh commented Aug 7, 2023

@uLipe I agree to all the comments, but I will wait for more comments before addressing them. Please let me know explicitly once you are done reviewing this patch set, so I can start working on all the comments at the same time.

Copy link
Collaborator

@carlocaione carlocaione left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not using the MBOX API instead that is supporting multiple channels out-of-the-box instead of having to tweak the IPM API?

Comment on lines 39 to 40
#define READ8_REG(reg, offset) sys_read8((reg) + (offset))
#define WRITE8_REG(reg, offset, val) sys_write8(val, (reg) + (offset))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

useless macros, remove those.

uint32_t remote_ipi_ch_bit;
};

static ALWAYS_INLINE void set_bit(const uint32_t addr, uint32_t offset, uint8_t bit)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please, use sys_set_bit & co. Same for clear and test.

@uLipe
Copy link
Collaborator

uLipe commented Aug 8, 2023

@carlocaione , I talked to @tnmysh , and the reason of providing the IPM first is to avoid breaking changes on the zephyr system reference applications from openAMP, the samples consumes the IPM driver in the same way the current openamp in-tree samples does ( excluding the new static vrings based, that already use mbox).

Can we move forward with this last one driver? And put the mbox driver on the backlog as we did for the IVSHMEM IPM?

Thanks :)

@carlocaione
Copy link
Collaborator

Can we move forward with this last one driver? And put the mbox driver on the backlog as we did for the IVSHMEM IPM?

Alright, but something still needs to be addressed in this driver (see my comments).

@uLipe
Copy link
Collaborator

uLipe commented Aug 8, 2023

Got it, thank you!

@tnmysh
Copy link
Contributor Author

tnmysh commented Aug 8, 2023

Thanks @carlocaione and @uLipe for reviews. If you are done reviewing this patchset, I will address all the comments. If you need more time for reviews please let me know.

@uLipe
Copy link
Collaborator

uLipe commented Aug 11, 2023

@tnmysh I'm done with my review for now :)

@carlocaione
Copy link
Collaborator

Thanks @carlocaione and @uLipe for reviews. If you are done reviewing this patchset, I will address all the comments. If you need more time for reviews please let me know.

yup, waiting for the new revision.

@tnmysh
Copy link
Contributor Author

tnmysh commented Aug 14, 2023

@carlocaione, @uLipe

Changes in v2:

  • use DT_HAS_XLNX_ZYNQMP_IPI_MAILBOX_ENABLED as dependency
    in Kconfig
  • move platform info to private header
  • remove redundant macros to access registers
  • use sys_write* and sys_read* APIS to read and write register.
  • use sys_set_bit, sys_test_bit to set and test bit.
  • add critical section when sending ipi data

Add ipm driver to use Inter Processor Interrupts
on Xilinx ZynqMP platform. This patch also adds sample
application that shows use of xlnx ipm driver.

This driver uses default arm gic interrupt controller
and works only for lockstep mode of cortex-r5f
cluster for now.

In split mode the cortex-r5 cluster will
have two r5f cores and they are expected to work in AMP
mode. If both r5f cores run simultaneouly, only one of
the core is able to receive IPI interrupts at this time
and it will be the one that started later. In future
this limitation shall be removed.

Signed-off-by: Tanmay Shah <tanmay.shah@amd.com>
@tnmysh
Copy link
Contributor Author

tnmysh commented Aug 14, 2023

Added header xlnx_ipi_ipm.h file in latest push.

#include <zephyr/logging/log.h>

#include "ipm_xlnx_ipi.h"
LOG_MODULE_REGISTER(ipm_xlnx_ipi, CONFIG_IPM_LOG_LEVEL);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nitpick: please group the log include files with LOG_MODULE_REGISTER macro.

Copy link
Collaborator

@uLipe uLipe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just left a minor comment, overall LGTM

Copy link
Collaborator

@carlocaione carlocaione left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM just a couple of comments

Comment on lines +115 to +117
const struct xlnx_ipi_child_config *cdev_conf;

cdev_conf = dev->config;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

useless?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I need to remove this. Since, this PR is merged, I will create separate change Thanks.

return -EMSGSIZE;
}

key = irq_lock();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

any reason to use irq_lock over something SMP safe like using a spinlock?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi Carlo, Thanks for reviews.

Actually this driver can be used in SMP mode or AMP mode.
For AMP mode, we may not need spinlocks. For SMP mode we will need spinlocks. I will add that support in separate patch.

Thanks.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@carlocaione @uLipe

I tried added spinlocks, but didn't work as expected. ipi_send can be called from interrupt context. Instead I will have to add workqueue support for each child's callback that are currently being called from ISR. This will be taken care later when SMP use cases are enabled. For now would like to go ahead with simple irq_lock();

@fabiobaltieri fabiobaltieri merged commit 09e2a4e into zephyrproject-rtos:main Aug 15, 2023
17 checks passed
Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @tnmysh!
Congratulations on getting your very first Zephyr pull request merged 🎉🥳. This is a fantastic achievement, and we're thrilled to have you as part of our community!

To celebrate this milestone and showcase your contribution, we'd love to award you the Zephyr Technical Contributor badge. If you're interested, please claim your badge by filling out this form: Claim Your Zephyr Badge.

Thank you for your valuable input, and we look forward to seeing more of your contributions in the future! 🪁

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: Devicetree Binding PR modifies or adds a Device Tree binding area: IPM Inter-Processor Mailbox platform: Xilinx Xilinx
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants