- 
                Notifications
    
You must be signed in to change notification settings  - Fork 8.2k
 
Add support to relocate open-amp resource table #44417
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
Conversation
| 
           uhm, are the addresses reflecting a real use-case scenario with the RSC table in the middle of the SHM?  | 
    
          
 To get an easily reproducible example, I tried to align with the NXP Linux reference demo for the i.MX8MP.  | 
    
          
 Right. In the zephyr case where is the SRAM mapped? I'm asking this because in your example you are basically writing directly in memory using pointers but there is nothing that guarantees you that you have exclusive access to that memory right? Or the SRAM is mapped somewhere else?  | 
    
          
 Good question. In the example setup the resource table is moved to the DDR region: I'm not sure if I understand you correctly, but since both processors need to read/write from the resource table area, it's not possible to grant exclusive access to this area. As far as I can see in the openamp_rsc_table example, there seem to be no mapping. It also looks likes that Zephyr libmetal port does not implement mapping at all. TLDR:  | 
    
| 
           My concern is slightly different. Let's say that you have only one SRAM area for Zephyr, so Zephyr is allowed to make use of this area as it pleases. If your regions for SHM and the resource table are directly pointing somewhere in the middle of this region, then it is possible that Zephyr will silently corrupt these regions writing on it. What you usually want to do is to define several regions: one for the SRAM area for zephyr, and then separate memory regions for SHM and resource table that are well far apart. Now, I'm not familiar with the memory map of this SoC so I was just wondering how did you choose the addresses and whether those are safe enough.  | 
    
| 
           Okay, let's see if I can get closer to your point. So Zepyhr uses the DDR area: In this case, these areas do not overlap. But since in these multiprocessor scenarios memory usage is quite flexible and many things have to fit together (Zepyhr DT, Linux DT, linker script), it's easy to configure a system where nasty things happen...  | 
    
| 
           Yup, that solves my issues. Thank you for putting up with me ;)  | 
    
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks to me that without this patch, resource table location can be configured in a linker script. With this patch we have two ways to configure resource table location in memory:
- In linker script, what might be silently overridden by
 - Device tree entry
 
I'm not sure if silent overriding linker script configuration by a device tree node is fine. Also I would like to understand why do we have two mechanisms with similar functionality, and if both of them are required.
        
          
                doc/reference/devicetree/api.rst
              
                Outdated
          
        
      There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is zephyr the correct vendor to use here? Resource table is more OpenAMP or Linux -defined than Zephyr
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since the two names 'zephyr,ipc' and 'zephyr,ipc_shm' are already used for open-amp, I thought it is consistent to use them for the resource table as well.
But if I'm wrong and there's a better suggestion, I'll be happy to use it.
          
 For the record, this is exactly what we do with   | 
    
| 
           If it's possible to place the resource table in a RAM segment at the address specified in the device tree by just controlling the linker, I think that would be fine and the explicit copying isn't necessary. Is such a system already being used for something comparable? Would that be the preferred option?  | 
    
          
 again, this is exactly what is done by using a node compatible with   | 
    
| 
           Yes, in theory I got your point. It was more about a request for practical help. [1] https://github.com/zephyrproject-rtos/zephyr/blob/main/soc/arm/nxp_imx/mimx8ml8_m7/linker.ld#L25 Should this work? Did I just do something wrong?  | 
    
          
 Try with  Maybe cherry-pick #44412 as well. Didn't that work for you?  | 
    
| 
           Hmm, after cherry-picking 'devicetree_regions: Fix fallback on token' and updating the DT node as suggested, the table is still not the desired location. The output of  And here the ouput with the DT node present: So it looks like the entry is somehow honored, but not quite as intended. If I replace '.resource_table' entirely with e.g. 'xresource_table' I'm at least able to control the location with a ROMABLE_REGION (as required by the linker script).  | 
    
          
 This looks correct to me. That says that you have a section at the correct address but you are simply failing to put the  Please consider that (as stated in the documentation) the  
 I'm not fully following you here. Can you check the test sample in #44412? That should give you a pretty good idea on how this is supposed to work.  | 
    
| 
           Unfortunately, it is not possible to change the name of the resource table section. When resource table relocation is not used and a remote processor is started by Linux, Linux searches the elf for a section called ".resource_table".  | 
    
          
 Well, this is really unfortunate. That would have been better discussed when we decided to sanitized the section names :(  | 
    
| 
           Well, looks like I'm running late :/ Assuming the section name behavior is set, what is the desired way to continue here?  | 
    
There are some remote processing scenarios where the resource table needs
to be moved to another location. This can be either because there is no
way to exchange the location of the resource table between the two
processors and they have to agree on a fixed predefined location, or
because the memory segment where the current resource table resides is not
is accessible/writable by the remote processor.
A real example of such a case can be found in the Linux rproc driver for
i.MX SoCs. A memory area containing the resource table can be specified
there in the device tree. Since this feature is application dependent, it
can optionally be configured in the device tree along with the other
open-amp related nodes.
This device tree snippet is intended to illustrate a possible use case:
[..]
chosen {
    zephyr,ipc_shm = &ipc_shm;
    zephyr,rsc_table = &rsc_table;
    zephyr,ipc = &mailbox0;
};
reserved-memory {
    #address-cells = <1>;
    #size-cells = <1>;
    ranges;
    ipc_shm: memory@55000000 {
        reg = <0x55000000 0x500000>;
    };
    rsc_table: rsc-table@550ff000 {
        reg = <0x550ff000 0x1000>;
    };
};
[..]
Signed-off-by: Matthias Fend <[email protected]>
    d76134b    to
    df67bc7      
    Compare
  
    | 
           As it turns out, simply copying the table may not be appropriate for all use cases. At least for the IMX platform, which I took a closer look at. See also this ML thread. So since it's unclear how and if this will be fixed in Linux, I'm currently using the updated commit from this RFC (which I just pushed). Now that there's a bit more logic, I'm not sure if hiding this magic in rsc_table_get() is still a good idea. What do you think?  | 
    
| 
           This pull request has been marked as stale because it has been open (more than) 60 days with no activity. Remove the stale label or add a comment saying that you would like to have the label removed otherwise this pull request will automatically be closed in 14 days. Note, that you can always re-open a closed pull request at any time.  | 
    
| 
           Hi @carlocaione @emfend, I'm using the CM7 of the IMX8MP and tried to run the openamp_rsc_table sample. I needed this patch to get the RPMSG communication functional. As well in my custom firmware.  | 
    
There are some remote processing scenarios where the resource table needs
to be moved to another location. This can be either because there is no
way to exchange the location of the resource table between the two
processors and they have to agree on a fixed predefined location, or
because the memory segment where the current resource table resides is not
is accessible/writable by the remote processor.
A real example of such a case can be found in the Linux rproc driver for
i.MX SoCs. A memory area containing the resource table can be specified
there in the device tree. Since this feature is application dependent, it
can optionally be configured in the device tree along with the other
open-amp related nodes.
This device tree snippet is intended to illustrate a possible use case: