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

Linux system internal refactoring #288

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

glneo
Copy link
Contributor

@glneo glneo commented Mar 18, 2024

Set of interface cleanups for the Linux system. Mostly removing dead code. Should result in no functional change.

@arnopo
Copy link
Contributor

arnopo commented Apr 2, 2024

This code is legacy code. some of the APIs can be used by AMD on using the libmetal in Linux user space
Need to be approved by @tnmysh

@tnmysh
Copy link
Collaborator

tnmysh commented Apr 4, 2024

OpenAMP is one of the client of Libmetal library but not only client of libmetal library. Libmetal can be used by other userspace drivers as well. I see usage of libmetal here on github wide search: https://github.com/Xilinx/embeddedsw/blob/c9a0ee31b2a14cbcfcb56ca369037319b4ad4847/XilinxProcessorIPLib/drivers/rfdc/src/xrfdc_sinit.c#L150

While I agree metal_linux_get_device_property is specific to linux, removing it as it is will break backward compatibility for userspace drivers that are using them (may be not OpenAMP). Ideally "metal_device_get_property" should be provided, and metal_linux_get_device_property could be its linux implementation. Then proper deprecation method need to be followed where users should be given enough time to switch to new API and then linux_get_device_property can be deprecated.

I am on leave right now, but this can be discussed once I am back.
For other APIs same, can be discussed individually.

Copy link

This pull request has been marked as a stale pull request because it has been open (more than) 45 days with no activity.

@github-actions github-actions bot added the Stale label May 20, 2024
glneo added 6 commits May 20, 2024 09:09
These functions are labeled METAL_INTERNAL so should have no external
users, but they are not used internally either. Remove these functions.

Signed-off-by: Andrew Davis <[email protected]>
This return code is for system calls only, and checkpatch warns about the
same. Remove the use of this return code.

Signed-off-by: Andrew Davis <[email protected]>
This function is only used by shmem. Move it to where it is used to
reduce internal-only "API" functions.

Signed-off-by: Andrew Davis <[email protected]>
This is a one-line one user internal function, just use mlock directly.

Signed-off-by: Andrew Davis <[email protected]>
This is not used, remove to prevent failures related to getting a
path that is not needed.

Signed-off-by: Andrew Davis <[email protected]>
The declaration metal_linux_bus_close() is not needed, it is already
defined at this point.

Signed-off-by: Andrew Davis <[email protected]>
@glneo
Copy link
Contributor Author

glneo commented May 20, 2024

I'll drop the patch that removes metal_linux_get_device_property from this series for now. But we should circle back to it later, perhaps if that XilinxProcessorIPLib project you linked makes use of it still then it could be moved into that project so we can deprecate it out of here. That way libmetal doesn't turn into a dumping ground for miscellaneous helper functions, instead keeping it a more focused and generic HAL.

Copy link
Contributor

@edmooring edmooring left a comment

Choose a reason for hiding this comment

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

My big concern is that there are users of libmetal outside of the OpenAMP library. There are several within Xilinx/AMD, and potentially more that we don't know about.

I would prefer to see these API changes go through the deprecation process, so potential outside users have at least some warning.

@glneo
Copy link
Contributor Author

glneo commented Jun 27, 2024

I would prefer to see these API changes go through the deprecation process, so potential outside users have at least some warning.

These functions are not exposed externally as they are wrapped in an ifdef check for METAL_INTERNAL. This is only to be defined when building libmetal. If anyone defines that in their build to get access to these lib internal-only function then they are abusing the API this library provides. So external user already have a warning not to use these function, it is METAL_INTERNAL.

Copy link

This pull request has been marked as a stale pull request because it has been open (more than) 45 days with no activity.

@github-actions github-actions bot added the Stale label Aug 12, 2024
@wmamills
Copy link
Contributor

wmamills commented Sep 5, 2024

Discussed 2024/09/05: Need to move this stuff to a legacy header and mark it obsolete.
Legacy header & code will only be used if a LEGACY define is defined at build time.
The default for LEGACY is debatable but if enabled by default the developer should get deprecation warnings

@glneo
Copy link
Contributor Author

glneo commented Sep 5, 2024

As stated in the above comment (2 months ago): These functions are not exposed externally as they are wrapped in an ifdef check for METAL_INTERNAL.

There is nothing to add to this deprecation file as no external facing API is being deprecated. We are only removing internal use only code. This is a completely internal refactor/cleanup.

@github-actions github-actions bot removed the Stale label Sep 6, 2024
@arnopo
Copy link
Contributor

arnopo commented Sep 6, 2024

As stated in the above comment (2 months ago): These functions are not exposed externally as they are wrapped in an ifdef check for METAL_INTERNAL.

There is nothing to add to this deprecation file as no external facing API is being deprecated. We are only removing internal use only code. This is a completely internal refactor/cleanup.

I mainly agree with @glneo's analysis. However, I suppose that these functions were initially added by AMD for a reason. This point should be clarified to determine if the functions can be removed or if they are not truly internal.

@tnmysh
Copy link
Collaborator

tnmysh commented Sep 6, 2024

As stated in the above comment (2 months ago): These functions are not exposed externally as they are wrapped in an ifdef check for METAL_INTERNAL.
There is nothing to add to this deprecation file as no external facing API is being deprecated. We are only removing internal use only code. This is a completely internal refactor/cleanup.

I mainly agree with @glneo's analysis. However, I suppose that these functions were initially added by AMD for a reason. This point should be clarified to determine if the functions can be removed or if they are not truly internal.

Correct. I am not sure why they were exported, it is pretty old code. Just for reference, libmetal is not only used for OpenAMP backend, but also used in a standalone fashion. I agree with commits presented in this PR. However, I see functions are exported via sys.h header, and it's not really possible to know how these are being used by users. Hence, as per code of conduct, we should follow deprecation process.

From next time, we can make sure not to export functions that are internal to libmetal. Once functions are exported, it is assumed that users are using them.
That is why we should provide option to enable this functionality, and later it can be removed at once.

@arnopo
Copy link
Contributor

arnopo commented Sep 6, 2024

As stated in the above comment (2 months ago): These functions are not exposed externally as they are wrapped in an ifdef check for METAL_INTERNAL.
There is nothing to add to this deprecation file as no external facing API is being deprecated. We are only removing internal use only code. This is a completely internal refactor/cleanup.

I mainly agree with @glneo's analysis. However, I suppose that these functions were initially added by AMD for a reason. This point should be clarified to determine if the functions can be removed or if they are not truly internal.

Correct. I am not sure why they were exported, it is pretty old code. Just for reference, libmetal is not only used for OpenAMP backend, but also used in a standalone fashion. I agree with commits presented in this PR. However, I see functions are exported via sys.h header, and it's not really possible to know how these are being used by users. Hence, as per code of conduct, we should follow deprecation process.

From next time, we can make sure not to export functions that are internal to libmetal. Once functions are exported, it is assumed that users are using them. That is why we should provide option to enable this functionality, and later it can be removed at once.

The point highlighted by @glneo is that these functions are under the specific METAL_INTERNAL condition, so we should consider them as "non-exported." I would be in favor of first confirming whether AMD uses them outside of libmetal (as they are the owners of this part of the legacy code).

  • If AMD uses them, we have to move them out of the METAL_INTERNAL condition.
  • If not used, we should consider them as they are and remove the useless functions. I would also suggest that we create internal_xxx.h files to separate internal and exported APIs.

@glneo
Copy link
Contributor Author

glneo commented Sep 6, 2024

I would also suggest that we create internal_xxx.h files to separate internal and exported APIs.

That is what I was originally working on when I came across these unused functions, moving the remaining used internal functions out of the exported headers is the next PR in my queue :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants