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

ps3disk.c: Rewrite ps3disk_transfer #1414

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

Conversation

aomsin2526
Copy link
Contributor

This function is bugged since the beginning, but it never hit because its variable doesn't allow.

However, since commit a77e1f0 it happen now.

First, it assume that ds_len will always equal to real user requested size. So it being used for sector count calculation.

This is no longer true, and will fail if attempt to read last few sectors.

Use bp->bio_length instead.

Second, this being a loop is pointless because nsegs will never be > 1 as specified at bus_dma_tag_create() call.

And all it doing is to repeat very same command again but with different ds_addr. Since bio_driver2 tag ident pointer are being reused, the result will be discarded at ps3disk_intr().

This function is bugged since the beginning, but it never hit because its variable doesn't allow.

However, since commit a77e1f0 it happen now.

First, it assume that ds_len will always equal to real user requested size.
So it being used for sector count calculation.

This is no longer true, and will fail if attempt to read last few sectors.

Use bp->bio_length instead.

Second, this being a loop is pointless because nsegs will never be > 1
as specified at bus_dma_tag_create() call.

And all it doing is to repeat very same command again but with different ds_addr.
Since bio_driver2 tag ident pointer are being reused, the result will be discarded at ps3disk_intr().

Signed-off-by: Chattrapat Sangmanee <[email protected]>
@pkubaj
Copy link
Contributor

pkubaj commented Sep 11, 2024

While I'm not sure about the contents of the patch, permissions seem to change from 644 to 755. C source files should definitely be 644.

@aomsin2526
Copy link
Contributor Author

Fixed, thanks.

Comment on lines +599 to 604
KASSERT(error == 0,
("DMA Error %d", error));

if (error) {
bp->bio_error = error;
bp->bio_flags |= BIO_ERROR;
Copy link
Member

Choose a reason for hiding this comment

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

Does the KASSERT() before normal error recovery makes some sense, or it is a leak of debug code?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Latter, to me, this error should never hit at anytime.

should i remove?

Copy link
Member

@amotin amotin Sep 11, 2024

Choose a reason for hiding this comment

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

I am not sure why it should never happen. I am generally not sure how can you guarantee that data buffer will not cross a physical page boundary and so won't have more than one segment. Limiting d_maxsize to PAGE_SIZE does not guarantee that if I/O goes from user-space. May be there is some magic in bouncing buffer code of that platform to handle it, but I don't know about that. I see previous code asserts (segs[i].ds_len % sc->sc_blksize) == 0, which is a bit softer, and I guess could be partial workaround would busdma be allowed of more than one segment, but only very partial. I know nothing about this platform, and I can only hope it is not that crippled and it is just some misunderstanding.

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.

3 participants