Comments (8)
Isn't it a way that remote is waiting for 1 and master for 0? And compiled start value is 0?
Then it doesn't matter who will init first If master it will put 0 to 1 and wait for 0. If remote it will wait for 1 and then put to 0... Just guessing, i didn't saw this part of code...
from rpmsg-lite.
Do you mean that rpmsg_lite_master_init
and rpmsg_lite_remote_init
can be invoked in any order? This link_state
is that in heap memory or shared memory? Looks like it ends up in heap, so how is it used then?
from rpmsg-lite.
Do you mean that
rpmsg_lite_master_init
andrpmsg_lite_remote_init
can be invoked in any order? Thislink_state
is that in heap memory or shared memory? Looks like it ends up in heap, so how is it used then?
I will let owner to respond. We did some changes. I think link id is id of synchronizing mechanizm to synchronize init of master and remote. So it can be in heap or stack (same for mechanism) but there will be something in shared memory which will be used for synchronization. Again better to explain from owner @MichalPrincNXP
from rpmsg-lite.
Hello @infn-ke
master side is responsible for all shared memory buffers (VirtIO) initialization, so until the master init is done the remote can't send any message. To ensure that, the link_state is introduced in rpmsg_lite context data. It is set to 0 on remote side during the initialization and once interrupts are enabled on the remote side and the virtqueue kick ISR is serviced the rpmsg_lite_tx_callback() is invoked and the link_state is set to 1. (Note, the virtqueue kick from the master side is done at the end of the rpmsg_lite_master_init function, at the time all VirtIO structures in shared memory are already initialized). To avoid busy loop implementations on the remote side, waiting for the link_state==1, the rpmsg_lite_wait_for_link_up() can be used in the remote application. It's implementation depends on the used env. layer, in case of baremetal the busy loop has to be used, but in case of an RTOS env., the event sync. mechanism is used in waiting for the virtqueue kick interrupt service and the link_state up state).
from rpmsg-lite.
About the link_state, it seems not work well in my environment.
My enviroment : linux is the master and R52 with rpmsg lite is the remote. The mailbox we used is arm pl320.
When linux side driver uses "virtqueue_nofity" function to notify the remote side the vdev init is ready, the remote rpmsg lite size just do nothing, didn't run the rpmsg_lite_tx_callback. Because virtqueue_notify send message with vqid0(svq in the linux) will use mailbox0, the mailbox0 channel in the linux is a RX channel. so virtqueue_nofity will have no action(mailbox framwork only init TX mailbox channels).
linux code in virtio_rpmsg_bus.c:
if (notify)
virtqueue_notify(vrp->rvq); //here is rvq, not svq.
code in my rproc driver to kick mailbox:
`static void xp5_rproc_kick(struct rproc *rproc, int vqid)
{
struct xp5_rproc *kproc = rproc->priv;
struct device *dev = rproc->dev.parent;
mbox_msg_t msg = (mbox_msg_t)vqid;
int ret;
printk("in xp5_rproc_kick, vqid=%d\n", vqid);
ret = mbox_send_message(kproc->mbox[vqid], (void *)msg);
if (ret < 0)
dev_err(dev, "failed to send mailbox message, status = %d\n", ret);
}`
As the code above, svq with vqid0 will use mailbox0 to send data, but in linux side , mailbox0 not work as a tx channel.
if we have any other way to set the link_state other than the tx callback, if possiable to use the the vdev's status in the resource table just like openamp did?
from rpmsg-lite.
linux side virtio device ready call:
`static inline
void virtio_device_ready(struct virtio_device *dev)
{
unsigned status = dev->config->get_status(dev);
if (dev->config->enable_cbs)
dev->config->enable_cbs(dev);
BUG_ON(status & VIRTIO_CONFIG_S_DRIVER_OK);
dev->config->set_status(dev, status | VIRTIO_CONFIG_S_DRIVER_OK);
}`
from rpmsg-lite.
linux side virtio device ready call: `static inline void virtio_device_ready(struct virtio_device *dev) { unsigned status = dev->config->get_status(dev);
if (dev->config->enable_cbs) dev->config->enable_cbs(dev); BUG_ON(status & VIRTIO_CONFIG_S_DRIVER_OK); dev->config->set_status(dev, status | VIRTIO_CONFIG_S_DRIVER_OK);
}`
modified my code to suit the link_state setting flow:
static void xp5_rproc_kick(struct rproc *rproc, int vqid)
{
struct xp5_rproc *kproc = rproc->priv;
struct device *dev = rproc->dev.parent;
mbox_msg_t msg = (mbox_msg_t)vqid;
int ret;
printk("in xp5_rproc_kick, vqid=%d\n", vqid);
if (vqid % 2 == 0) {
vqid += 1;
}
ret = mbox_send_message(kproc->mbox[vqid], (void *)msg);
if (ret < 0)
dev_err(dev, "failed to send mailbox message, status = %d\n", ret);
}
the tx callback can be triggered . So fixed.
from rpmsg-lite.
Hi @zhangjk2752 , thanks for sharing your approach / Linux adoption on link_state mechanism that is specific to rpmsg_lite component.
from rpmsg-lite.
Related Issues (20)
- Required shared memory size? HOT 19
- Wrong comment or macro? HOT 2
- rpmsg_lite_wait_for_link_up should be extended with timeout HOT 4
- Message framentation? HOT 3
- Can rpmsg lite work well as master and remote at the same time? HOT 2
- use env_rmb() is for what? HOT 4
- How to use the rpmsg-lite HOT 2
- master and remote ping each other in freertos HOT 2
- Communicating with QNX HOT 6
- who will set rpmsg_lite_dev->link_state to 1 HOT 4
- who will set rpmsg_lite_dev->link_state to 1 HOT 1
- [QUESTION]: Erpc and rpmsg port to embOS HOT 1
- [QUESTION]: Remote and master on the same core? HOT 1
- [QUESTION] Environment porting unit-tests HOT 3
- Can I run rpmsg-lite with Yocto Hardkott Or Kirkstone Or Only with NXP downstream kernel? HOT 5
- RPMsg-Lite Bare Metal Example HOT 4
- [QUESTION] virtio VIRTIO_F_EVENT_IDX HOT 1
- [QUESTION] Does rpmsg_lite_send require carriage returns? HOT 2
- I need rpmsg_env_specific.h to user rpmsg-lite (new version) with Yocto Kirkstone and Zephyr upstream HOT 9
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rpmsg-lite.