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

CR-1156386 Default and Backup FPT sysfs nodes impl #7715

Conversation

prapulkrishnamurthy
Copy link
Collaborator

Problem solved by the commit

Bug / issue (if any) fixed, which PR introduced the bug, how it was discovered

This is an implementation of sysfs nodes for debug purposes. Sysfs nodes for reading raw meta data from Default FPT and Backup FPT through VMR.

How problem was solved, alternative solutions (if any) and why they were rejected

Added changes in both XRT and corresponding VMR compatible changes.

Risks (if any) associated the changes in the commit

What has been tested and how, request additional testing if necessary

Tested on V70 base 3 2023.2 and found the hexdump to be matching between default and backup dumps
Test results are attached in the VMR PR here:- https://github.com/Xilinx/VMR/pull/335

Documentation impact (if any)

@gbuildx
Copy link
Collaborator

gbuildx commented Sep 20, 2023

Can one of the admins verify this patch?

XGQ_CMD_LOG_PLM_LOG = 0x8,
XGQ_CMD_LOG_APU_LOG = 0x9,
XGQ_CMD_LOG_SHELL_INTERFACE_UUID = 0xa,
XGQ_CMD_LOG_DEFAULT_FPT = 0xb,
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

alignment changes made to keep consistency with vmr common header file

Copy link
Collaborator

Choose a reason for hiding this comment

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

look ok as long as the vmr changes made in vmr.

Copy link
Collaborator

@xdavidz xdavidz left a comment

Choose a reason for hiding this comment

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

This looks ok, but I realized that there is a potential bug in our driver, that every log_page request might return a big size back. We need to valid the size before call vmalloc.

I think just add a code to make sure the returned size should be within request size. Does this make sense?

@stsoe stsoe removed their request for review September 20, 2023 22:03
@prapulkrishnamurthy prapulkrishnamurthy changed the title Default and Backup FPT sysfs nodes impl CR-1156386 Default and Backup FPT sysfs nodes impl Sep 20, 2023
@xdavidz
Copy link
Collaborator

xdavidz commented Sep 20, 2023

This looks ok, but I realized that there is a potential bug in our driver, that every log_page request might return a big size back. We need to valid the size before call vmalloc.

I think just add a code to make sure the returned size should be within request size. Does this make sense?

Adjust my request a little bit. Actually, we did have checking code in the log_page request for each set of data.
But given the request off might be not zero. Thus, I don't think we should cache those data unless we have to.

Can you please take a look at the vmr_apu_log_read as an example?
aka. We only temporary copy data to buf and free the memory. We don't cache those in the driver.

Including fpt, system dtb, fw_log, plm_log, apu_log. The shell interface uuid is special, this one can be cached.

@xdavidz
Copy link
Collaborator

xdavidz commented Sep 21, 2023

ok to test

Comment on lines 3109 to 3087

mutex_lock(&xgq->xgq_lock);

blob = xgq->xgq_vmr_backup_fpt;
size = xgq->xgq_vmr_backup_fpt_size;

if (off >= size)
goto out;

if (off + count > size)
count = size - off;
memcpy(buf, blob + off, count);

ret = count;
out:
mutex_unlock(&xgq->xgq_lock);
return ret;
Copy link
Collaborator

Choose a reason for hiding this comment

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

worth creating a function for here and L3062-3078?

Copy link
Collaborator

Choose a reason for hiding this comment

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

there are indeed 3+ places dup code. could prapul fix this?

@xdavidz
Copy link
Collaborator

xdavidz commented Sep 23, 2023

reset this please

@prapulkrishnamurthy
Copy link
Collaborator Author

prapulkrishnamurthy commented Sep 26, 2023

The commit 87af11f involves eliminating the need for caching sysfs read data for plm, system dtb, default and backup fpt data in driver as per @xdavidz suggested.

*/
if (off == 0)
ret = xgq_refresh_system_dtb(xgq);
if (off > 0)
Copy link
Collaborator

Choose a reason for hiding this comment

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

this looks incorrect. why off cannot be bigger than 0? It might be more than 4096 per linux sysfs request for the blob data. we are also able to return data with any offset.

Copy link
Collaborator Author

@prapulkrishnamurthy prapulkrishnamurthy Sep 26, 2023

Choose a reason for hiding this comment

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

Non-zero offset means there is some data returned per read request. This is more like a boundary check to avoid infinite looping of this API call because, after read and return, the offset seeks back to zero and automatically keeps calling this API by the behavior of sysfs.

Copy link
Collaborator

@xdavidz xdavidz left a comment

Choose a reason for hiding this comment

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

overall look ok to me, those nits are optional.
But the memory leak has to be fixed in all 4 places.

@prapulkrishnamurthy prapulkrishnamurthy force-pushed the CR-1156386_default_FPT_backup_FPT_sync branch from 82814d3 to 8b9ef21 Compare September 27, 2023 23:10
ret = count;
done:
vfree(log_buf);
XGQ_INFO(xgq,"Offset = %d, count = %d, ret = %d\n",(int)off,(int)count,(int)ret);
Copy link
Collaborator

Choose a reason for hiding this comment

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

nits: to avoid compiling warning, the more cleaner way: offset and count is %ld, ret is %d

Signed-off-by: Prapul Krishnamurthy <[email protected]>
@prapulkrishnamurthy prapulkrishnamurthy force-pushed the CR-1156386_default_FPT_backup_FPT_sync branch from 8b9ef21 to c19308c Compare September 27, 2023 23:49
@manikandan-xilinx
Copy link
Collaborator

retest this please.

@gbuildx
Copy link
Collaborator

gbuildx commented Sep 29, 2023

Build Passed!

@maxzhen maxzhen merged commit 5833de0 into Xilinx:master Sep 29, 2023
3 checks passed
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