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

Force ejected after wake from sleep and can't initialize disk #12

Open
juanjullian opened this issue Jun 20, 2020 · 12 comments
Open

Force ejected after wake from sleep and can't initialize disk #12

juanjullian opened this issue Jun 20, 2020 · 12 comments
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@juanjullian
Copy link

Elitebook 840 g4, 522a version.

Works perfectly after boot or reboot, but when wake after sleep, the sdcard ejects itself and when physically ejected and reinserted there's a message of "can't read the disk"

image

@juanjullian
Copy link
Author

This is the console log about:


error	17:10:27.625794-0400	kernel	rtsx:	              sdmmc_dump_command    : sdmmc: cmd 18 (MMC_READ_BLOCK_MULTIPLE) arg=0 data=<private> dlen=4096 flags=0x1c51 proc="" (error 60)
error	17:10:27.625823-0400	kernel	rtsx:	      SDDisk::read_task_impl_       : Returning an Error! (READ block = 0 nblks = 8 blksize = 512 physSectSize = 512 error = 60)

@Sniki
Copy link

Sniki commented Jun 22, 2020

I have the same problem, my card is 5227 model

@cholonam
Copy link
Owner

Card ejection on sleep is the expected behavior, and it comes from the OpenBSD code (see comment here) which this kext is a port of.

The card not being recognized after wakeup is a different issue. As far as I know (I do not use sleep), after sleep/wakeup and card eject/insert, the card is being recognized and mounted, at least for chip RTS525A, with the -rtsx_mimic_linux boot option enabled. The errors you show are timeouts, meaning that the chip is probably not responding to commands after sleep/wakeup. Other chips (like 5227 or 522A) probably need a more proper initialization after wake, which is what -rtsx_mimic_linux does for 525A. You can try using this boot parameter and see if it also works for your chip, although I doubt it.

I cannot support any chip other than 525A (lack of time + impossibility to test), but if anyone is willing to take the task of adding support for other chips, I'll be happy to accept pull requests.

@cholonam cholonam added enhancement New feature or request help wanted Extra attention is needed labels Jun 24, 2020
@Sniki
Copy link

Sniki commented Jun 24, 2020

Will do a test with that boot-arg tonight and let you know

@juanjullian
Copy link
Author

tested with that boot-arg with no results, is the same.

I can do many many code test, but i need to see clearly where to start, as a hobby coder, i need help to start with it. I can do local tests and the pull requests.

What i need is the initialization code on BSD driver (point me where) and the exact same instructions on this port.

Thanks in advance

@juanjullian
Copy link
Author

Or maybe we can unload and reload kext after wake from sleep?

@cholonam
Copy link
Owner

I can do many many code test, but i need to see clearly where to start, as a hobby coder, i need help to start with it. I can do local tests and the pull requests.

What i need is the initialization code on BSD driver (point me where) and the exact same instructions on this port.

You need to understand the BSD driver, but most importantly, you need to study the Linux driver.

  1. The BSD driver is already incorporated into this kext almost verbatim (under 3rdParty/openbsd), but it seems this driver only supports a few of the chips (originally made for RTS5209 with some support added later RTS5229 and RTS525A, you can blame this file for details).
  2. The Linux driver is the key. This is the only complete, well supported driver available and covers all the Realtek chips (had I known before, I would have just ported the Linux driver, but now it's too late). What I did (with -rtsx_mimic_linux) was to add some initialization that Linux does for my chip and BSD doesn't, so that stability improved (it certainly did, although still not perfect). You should basically do the same for your your chip. The main files you have to study are:

Studying these two files and this kext's source (including the BSD driver of course), should give you an idea on what's beeing done by Linux and not by BSD, particularly regarding the initialization.

Regarding unloading/loading the kext on sleep/wake, I'm afraid the result would be basically the same, since on every wake, the chip is initialized as if the kext was just loaded.

Thanks in advance

Good luck!

@Sniki
Copy link

Sniki commented Jul 12, 2020

@cholonam thanks, yes, the boot-arg -rtsx_mimic_linux did fix the problem on 5229 card and now you can use the sd card after wake from sleep without problems.
Yes it does give the message of card not ejected properly but a unplug and replug fixes and card loads fine.

However after wake from sleep, ejecting the card won't work until you wait for the message for force eject to appear and then you press on force eject, then the card will eject fine.

I was wondering if removing that part of the code for suspending related so the driver stops on suspend, will that make any change to the driver, will the card remain mounted after wake from sleep ?

@cholonam
Copy link
Owner

I was wondering if removing that part of the code for suspending related so the driver stops on suspend, will that make any change to the driver, will the card remain mounted after wake from sleep ?

I'll try to take a look at it when I have some time. However I must warn you that sleep/wake support is not on my high priority list (I'm happy just with the kext not crashing on sleep since I never sleep my system).

Maybe using a program like Sleepwatcher to unmount/unload the kext on sleep and load the kext on wake works for you?

@Sniki
Copy link

Sniki commented Jul 20, 2020

@cholonam the latest kext release 2.3 causes a kernel panic / instant reboot during Apple Boot Logo progress bar reaching around 75%.
The issue occurs when using the -rtsx_mimic_linux boot-arg

That didn't happen on previous release, how would be the best way to collect logs:

  • Debug version used
  • Any special boot-arg or configuration to get logs ?

@cholonam
Copy link
Owner

cholonam commented Jul 20, 2020

What if you boot without the kext and load the kext once booted? What's yous OS version? I can boot with the debug kext without problem. Maybe try to boot in text mode (-v) and see if any message gives you a hint.

@Sniki
Copy link

Sniki commented Jul 21, 2020

What if you boot without the kext and load the kext once booted? What's yous OS version? I can boot with the debug kext without problem. Maybe try to boot in text mode (-v) and see if any message gives you a hint.

Sorry, turned out something else (other kext) was causing the issue.

The kext has actually improved a lot, if i eject the card physically before sleep, then after i wake the laptop and i plug the SD Card, it will work without a problem.

Force eject problem has been fixed i believe.

However, sleeping with card plugged in does cause some issues.

Will do a deep testing tomorrow with logs included as well and give more precise and clear, well described problems.

But for now with the mimic linux boot arg, it is working fine, as soon as i finish the job with the card, there is no reason to keep it plugged in for no reason.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants