-
Notifications
You must be signed in to change notification settings - Fork 919
Staging/xlnx/jesd204 fsm #3057
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
Open
mhennerich
wants to merge
13
commits into
main
Choose a base branch
from
staging/xlnx/jesd204-fsm
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Staging/xlnx/jesd204 fsm #3057
+104
−15
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Initialize ret to 0 in jesd204_fsm_propagate_cb_top_level(). If num_links is 0, the for loop never executes and ret would be returned uninitialized, leading to undefined behavior. Fixes: f72853d ("jesd204: rework the state machine for top-device propagation") Signed-off-by: Michael Hennerich <[email protected]>
Add missing iter_idx++ in the list_for_each_entry loop when showing output connection attributes. Without this increment, only index 0 would ever match, making sysfs attributes for output connections beyond the first one inaccessible. Fixes: 1080c2e ("jesd204: sysfs: add initial version for sysfs") Signed-off-by: Michael Hennerich <[email protected]>
The str_cut_from_chr() function takes a character parameter 'c' but was hardcoded to always search for '_' instead of using the passed parameter. Fix by using strchr(s, c) instead of strchr(s, '_'). While all current callers pass '_', this fix ensures the function behaves as its signature indicates and prevents bugs if future callers use a different character. Fixes: 1080c2e ("jesd204: sysfs: add initial version for sysfs") Signed-off-by: Michael Hennerich <[email protected]>
The max variable was declared as 'int' but assigned 0xffffffff for 32-bit value validation, which overflows to -1 on most systems. This caused the comparison 'val1 > max' to incorrectly reject valid values when storing 32-bit attributes via sysfs. Fix by: - Changing max type from 'int' to 'u64' to hold all valid maximums - Using U8_MAX, U16_MAX, U32_MAX macros for clarity and correctness - Adding proper cast for kstrtoll() to avoid type mismatch warning Fixes: 1080c2e ("jesd204: sysfs: add initial version for sysfs") Signed-off-by: Michael Hennerich <[email protected]>
Add proper mutex serialization for FSM state transitions to prevent concurrent access to FSM state data. This addresses the FIXME comment in jesd204_fsm_table_single() about needing proper locking. Changes: - Add fsm_lock mutex to jesd204_dev_top structure - Initialize mutex in jesd204_dev_alloc() - Destroy mutex in jesd204_of_unregister_devices() - Lock/unlock mutex around FSM table transitions in jesd204_fsm_table() - Remove FIXME comment that was documenting this issue This ensures thread-safe FSM operations when multiple contexts might attempt state transitions simultaneously. Signed-off-by: Michael Hennerich <[email protected]>
Add jesd204_dev_free_links() function to properly free dynamically allocated lane_ids arrays when unregistering JESD204 devices. The lane_ids are allocated in jesd204_dev_init_link_lane_ids() for both active_links and staged_links, but were never freed on device removal. The function only frees lane_ids that were dynamically allocated (not provided statically via init_links) to avoid double-free issues. Fixes: 34b513c ("jesd204: init JESD204 links info from driver") Signed-off-by: Michael Hennerich <[email protected]>
Add validation in jesd204_dev_get_topology_top_dev() to detect and warn when a JESD204 device is found in multiple topologies. This addresses the FIXME comment about enforcing single-topology membership. The function now iterates through all topologies to check for multiple memberships, warns if detected, and returns the first topology found for consistent behavior. This helps identify misconfigured device trees where a device incorrectly spans multiple JESD204 topologies. Signed-off-by: Michael Hennerich <[email protected]>
Add missing of_node_put() call when jesd204_dev_alloc() fails during device tree node iteration. The for_each_node_with_property() macro takes a reference on each node, which must be released when breaking out of the loop early due to an error. Fixes: 98086f3 ("jesd204: collect all devices on framework init") Signed-off-by: Michael Hennerich <[email protected]>
Add defensive NULL check for jdev->dev_data before accessing state_ops array in jesd204_fsm_table_entry_cb(). While dev_data should always be set for registered devices, this check prevents potential NULL pointer dereference if the FSM callback is invoked on a partially initialized or corrupted device structure. Signed-off-by: Michael Hennerich <[email protected]>
Add documentation comment explaining the purpose and value choice of the EINVALID_STATE internal error code. This magic number is used to signal FSM state validation failures and is intentionally chosen to be outside the standard errno range to allow special handling during state transitions and resume operations. Signed-off-by: Michael Hennerich <[email protected]>
Add debug-level logging when FSM rollback operations are initiated. This helps with debugging FSM state transition failures by logging the source and target states during rollback, making it easier to trace the sequence of state changes when errors occur. Signed-off-by: Michael Hennerich <[email protected]>
Add kernel-doc documentation comments to the following functions that were previously undocumented: - jesd204_device_count_get(): Returns the count of registered devices - jesd204_dev_get_topology_top_dev(): Finds top-level device for a topology - jesd204_printk(): Prints kernel messages with JESD204 device context These functions are part of the JESD204 framework API and benefit from proper documentation for maintainability and developer reference. Signed-off-by: Michael Hennerich <[email protected]>
Add the sample_rate_div member of struct jesd204_link to the sysfs interface. This attribute was missing from the exported link parameters. The sample_rate_div is an optional sample rate divider where the final effective sample rate is calculated as: sample_rate / sample_rate_div. The new attribute will appear as linkX_sample_rate_div in sysfs for each JESD204 link. Signed-off-by: Michael Hennerich <[email protected]>
Collaborator
|
Linux Test Harness results now available here. |
nunojsa
approved these changes
Dec 19, 2025
| static char *str_cut_from_chr(char *s, char c) | ||
| { | ||
| char *ptr = strchr(s, '_'); | ||
| char *ptr = strchr(s, c); |
Collaborator
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.
nit: I would just argue about a fixes tag given that all callers use _
| if (!jdev_top) | ||
| return -EFAULT; | ||
|
|
||
| mutex_lock(&jdev_top->fsm_lock); |
Collaborator
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 could use guard(mutex)...
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
PR Description
Miscellaneous small fixes and updates
PR Type