-
Notifications
You must be signed in to change notification settings - Fork 10
Ubuntu Core enablement changes #12
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
base: xlnx_rel_v2025.2
Are you sure you want to change the base?
Conversation
|
@artiepoole We’ll check this and get back in a week. |
83fd6da to
9095844
Compare
|
@tjaysukh, Thank you for the haste! I created this as a draft. There have been some tweaks since creation, so please take these into account during assessment. I have now tested it more thoroughly and have marked this as "ready for review" |
9095844 to
740ac2f
Compare
|
@artiepoole, Please let me know your thoughts. |
|
Thanks for the feedback. On point 1), yes, I am happy to implement the direct I/O. I'll do in a follow-up commit. I will also adopt that for libdfx as well, if the responsible team agrees. I also agree with point 3) about waiting for libdfx before merging. I'll mark this PR as draft until the direct IO is implemented and update you here when I think it is ready for review. Best, |
|
Hey @tjaysukh Please see the latest commit for changes regarding removing system calls. Please note that I did not touch any parts of the repository which I am not familiar with (e.g. contents of Edit: If I am to remove the state.txt from libdfx, several of these functions could be moved to libdfx to reduce duplication. This got me thinking - why are they separate projects - are there other projects also using libdfx?
|
|
@artiepoole , I think libdfx should only expose dfx related symbols not the generic utility functions, any further change to ABI of those functions would(should) trigger a library transition for the tools depending libdfx. Ideally I would like to see those common utility functions sourced somewhere common for both libdfx and dfx-mgr but not tied to the library itself. |
src/daemon_helper.c
Outdated
| * Strips trailing needle from haystack - e.g. `\n` from file read | ||
| * results or `/` from paths before concatenating. | ||
| */ | ||
| void strip_trailing(char *haystack, const char needle) |
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.
can we make this static as well?
src/daemon_helper.c
Outdated
| * Return: 0 if the overlay status "applied" and path matches requested_path, | ||
| * -1 on error or if either assertion is false | ||
| */ | ||
| static int check_overlay_was_applied(char *overlay_dir, char *requested_path) |
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 function modifies overlay_dir so it is not just a check. can we make it so it doesnt do that and use const in arguments to indicate this.
or at worst document this in function header so people are aware that this will change the arguments sent.
For requested_path, I think we are safe to add const easily.
src/daemon_helper.c
Outdated
| char read_buf[128]; | ||
| const char *state_applied = "applied"; | ||
|
|
||
| strip_trailing(overlay_dir, '/'); |
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.
we might not need this at all, it is best to verify behaviour for //path though
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.
I will test. usually works for bash cmds otherwise I will copy the buf before modifying
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.
I decided to make a copy into full_path. strip trailing and assemble the full path in 3 steps instead. This functionality is now moving into libdfx, however, so have made those changes there
src/daemon_helper.c
Outdated
| * Return: 0 on success, | ||
| * -1 on error (e.g., failed to open, write, or close the file) | ||
| */ | ||
| static int write_path_to_overlay(char *overlay_dir, const char *requested_path) |
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.
const overlay_dir
src/daemon_helper.c
Outdated
| // ignore bits >= 1, only care about partial or full. | ||
| if (write_to_fpga_flags(flag & 1)) { | ||
| DFX_ERR("Failed to set flags"); | ||
| goto ret; | ||
| } |
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.
I dont see it errors and jumps to the ret on the original file, it could be missed in the original implementation but just wanted to point out the behaviour change here
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.
Ah thanks!
|
I see DFX_ERR already handles strerror so please ignore my comments about strerror: https://github.com/Xilinx/dfx-mgr/blob/master/src/print.h#L43-L47 |
…ting location Use `/sys/kernel/config/device-tree/overlays/` instead of remounting Signed-off-by: Artie Poole <stuart.poole@canonical.com>
Note: The implementation for controlling firmware is implemented in libdfx.h/.c to avoid code duplication. The kernel provides a mechanism to set where firmware loads will look to match filenames during probe events. This file is located at `/sys/module/firmware_class/parameters/path`. These changes remove the need for copying firmware files into /lib/firmware. The /lib/firmware location is still probed if the file is not found in the custom location. See https://docs.kernel.org/driver-api/firmware/fw_search_path.html for more information. Signed-off-by: Artie Poole <stuart.poole@canonical.com>
This also removes the need for a `state.txt` file, so we stop creating the `/run/dfx-mgrd` directory because it is no longer necessary Signed-off-by: Artie Poole <stuart.poole@canonical.com>
1753fb4 to
feb69d2
Compare
Signed-off-by: Artie Poole <stuart.poole@canonical.com>
Signed-off-by: Artie Poole <stuart.poole@canonical.com>
c3a460a to
0a3a47c
Compare
|
Hey @tjaysukh, I have removed the need for Just fyi, the whitespace is a mess in daemon_helper.c - a mix of spaces, 4-width tabs and8-width tabs, all within the same functions and sometimes the same lines. It was very difficult to make changes and maintain these whitespaces. For this reason, I suggest looking through the changes with "ignore whitespace" on at first, and then enabling whitespace differences after understanding the functional changes. It may be worth enforcing a clantidy and clangformat style for consistency. p.s. I tacked on Talha's suggest const changes, but only for the functions I touched. I also added on newline to a load error print which has been annoying me for ages. Let me know if you'd prefer those/anything else here separately. |
|
Thanks again for the changes and your efforts. I’ll review and test everything, then get back to you
I need to discuss this with the stakeholders. As of now, in the lightweight use-case flow, dfx-mgr is not dependent on libdfx, but with this change, as you mentioned it will become heavily dependent on libdfx. I want to ensure everyone is aligned before we proceed. |
|
Hi @tjaysukh,
If necessary, it would not be difficult to recreate the functionality in dfx-mgr standalone. I was not aware of the need for this mode :) Just let me know what the ultimate decision is. |
|
Hey @tjaysukh, I'm just bumping to ask if has there been any update? Best, |
|
@artiepoole, |
In an ongoing attempt to enable fpga device functionality in Ubuntu Core, three issues have arisen in relation to the requirement for snaps to be strictly confined. In our case, we are attempting to redistribute dfx-mgr (and libdfx) as part of FPGAd. Once the concept of "softeners" is in place, this snap will enable downstream customers to use dfx-mgr as they expect to be able to, but with the caveat that FPGAd will be the gatekeeper for accessing the FPGA subsystems.
In these efforts, we found three challenges in the way dfx-mgr and libdfx operate:
state.txt. In real operation, this file is created at/state.txtwhich is not allowed in a strictly confined snap, and no layout can be applied to files in the root directory, except as files inside known pre-defined directories./configfs. This mount call requires strong permissions, which the store team can't/wont to grant to the fpgad snap.In order to tackle these three problems, I have edited dfx-mgr and libdfx with the following solutions:
/etc/dfx-mgrd/state.txt/run/dfx-mgrd/state.txt. I would actually prefer to remove the "system(command)" calls to mitigate the need for this file at all, but that is out of scope here./sys/module/firmware_class/parameters/pathinstead. The implementation is in libdfx.c/.h to avoid code duplication./configfsare removed, and all paths pointing to "/configfs/" are replaced by/sys/kernel/config/Please see Xilinx/libdfx#6 for the libdfx changes
Please do not hesitate to suggest changes or ask for clarification.