-
Notifications
You must be signed in to change notification settings - Fork 174
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
io: Add support for address translation from driver physical address to device physical address #322
base: main
Are you sure you want to change the base?
io: Add support for address translation from driver physical address to device physical address #322
Conversation
There are SoCs that have different memory maps for device and driver. Therefore the shared memory between them has different values and we need to convert the addresses. Add support to convert a driver physical address to device physical address. Signed-off-by: Iuliana Prodan <[email protected]>
41421df
to
35bb86c
Compare
@arnopo @edmooring The CI is failing because I've changed the signature of
OR A second solution would be to create a function that only sets the
and will be called after What do you think? LE: added second option |
@@ -205,6 +243,12 @@ metal_io_phys_to_offset(struct metal_io_region *io, metal_phys_addr_t phys) | |||
static inline void * | |||
metal_io_phys_to_virt(struct metal_io_region *io, metal_phys_addr_t phys) | |||
{ | |||
metal_phys_addr_t tmp_phys = metal_io_phys_drv_to_phys(io, phys); |
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.
Here you could create some regressions. This function is used to return a virtual address based on the physical address, not the remote physical address. This function is used for the buffers, but also the vrings (which use local physmap).
It seems that it would be better to provide a metal_io_ops::phys_to_offset
that would point to a metal_io_remote_phys_to_offset
or a platform specific function, ensuring that the same IO region is not used for your vrings and the buffers in the vrings.
@@ -11,6 +11,7 @@ | |||
|
|||
void metal_io_init(struct metal_io_region *io, void *virt, | |||
const metal_phys_addr_t *physmap, size_t size, | |||
const metal_phys_addr_t *physmap_drv, |
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.
This will break the existing API in the next release. When possible, we try to use a deprecation mechanism.
Here we also have the increase of th function parameters, which seems already quite significant to me. So perhaps it is a good time to rework this API.
I would create a metal_io_config
structure that would contain these parameters. Then, create a new function void metal_io_init_region(struct metal_io_region *io, const struct metal_io_config *cfg)
. Finally, I would update metal_io_init
to use metal_io_init_region
and tag metal_io_init_region
as deprecated.
But perhaps someone else as an alternative to propose?
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.
This looks like good idea. Advantage is we can extend structure as needed but keep API interface the same.
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.
@arnopo @tnmysh I've decided to add 2 new members: metal_io_ops::remote_phys_to_offset
and metal_io_ops::offset_to_remote_phys
.
The changes in libmetal will be similar to this commit: a90bbd8
For context see also this comment.
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.
Do you need to create 2 new ops? Or could you reuse phys_to_offset and offset_to_phys?
Look to me that based on the io address you could decide to apply or not the memory translation
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.
@@ -21,6 +22,7 @@ void metal_io_init(struct metal_io_region *io, void *virt, | |||
io->virt = virt; | |||
io->physmap = physmap; | |||
io->size = size; | |||
io->physmap_drv = physmap_drv; |
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 could be the device physmap if used on driver side. to rename (remote_physmap
?)
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.
The difference between io->physmap and io->physmap_drv (or new name) should be documented in comment.
I saw this comment only after my review. I proposed a solution in my comments, but regarding my comment in |
@@ -76,6 +76,9 @@ struct metal_io_region { | |||
of each of the pages in the I/O | |||
region */ | |||
size_t size; /**< size of the I/O region */ | |||
const metal_phys_addr_t *physmap_drv;/**< table of base physical address |
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.
this comment is same as above physmap. The difference should be stated in new comment.
There are SoCs that have different memory maps for device and driver. Therefore the shared memory between them has different values and we need to convert the addresses.
Add support to convert a driver physical address to device physical address.