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

[tone] [kagura] MTP: Crashes when transferring files with Windows #432

Closed
ix5 opened this issue Jun 25, 2019 · 9 comments
Closed

[tone] [kagura] MTP: Crashes when transferring files with Windows #432

ix5 opened this issue Jun 25, 2019 · 9 comments

Comments

@ix5
Copy link
Contributor

ix5 commented Jun 25, 2019

Platform: Tone
Device: Kagura
Kernel version: 4.9.182
Android version: 9.0 Pie

Description
Device crashes when attempting to transfer files via MTP from a Windows host.
Possibly related:
[loire] mtp is broken for large files [2/2]
[loire] mtp is broken for large files [1/2]
Discovery: copying files using MTP or PTP reboots phone #273

Symptoms
Hard crash from kernel panic

dwc3 6a00000.dwc3: swiotlb buffer is full (sz: 1048576 bytes)
DMA: Out of SW-IOMMU space for 1048576 bytes at device 6a00000.dwc3
Kernel panic - not syncing: DMA: Random memory could be DMA written
ipa ipa2_active_clients_panic_notifier:309 
---- Active Clients Table ----
IPA_CLIENT_APPS_WAN_CONS                 1378 ENDPOINT
SPS_RESOURCE                             -1378 SPECIAL
Total active clients count: 0
Kernel Offset: disabled
CPU features: 0x112008
Memory Limit: none
Rebooting in 5 seconds..
Going down for restart now
qcom,qpnp-power-on 400f000.qcom,spmi:pmi8994@2:qcom,power-on@800: PMIC@SID2: configuring PON for reset
msm_restart_prepare : cmd is NULL, set to reboot mode

How to reproduce
Attempt to transfer files from a Windows host via MTP. You will have to transfer a large amount of files, crashes seem to happen with large files as well.


Unrelated: We might need to investigate our init.rc files for adb/functionfs stuff, maybe some wrong attrs/ids?

@oshmoun
Copy link

oshmoun commented Jul 27, 2019

a bit impractical not having a call trace don't you think? :)
https://github.com/sonyxperiadev/kernel/blob/aosp/LE.UM.2.3.2.r1.4/lib/swiotlb.c#L735-L740
changing these to BUG should give us that

@chris42
Copy link

chris42 commented Jul 28, 2019

Could it be, that the MTP overall is a bit whacky?
Using it during system time, always (since I own Xperia X Compact) ends for me in libmtp error: Could not get file from device. under Linux. Windows just stops copying.
I always hat to switch to TWRP to copy files from the device. Maybe this is also a hint on solving the configuration?

@oshmoun
Copy link

oshmoun commented Aug 4, 2019

applying the linked patch works around the issue by limiting the mtp request length
https://del.dog/ugayaselar.cc
I am not familiar enough with these things to deem this solution passable. however, should that be the case, we could simply adjust the sizes in init by writing to /sys/module/usb_f_mtp/parameters/{mtp_rx_req_len,mtp_tx_req_len}

ix5 added a commit to ix5/device-sony-tone that referenced this issue Aug 12, 2019
Limit MTP_RX_BUFFER_INIT_SIZE and MTP_TX_BUFFER_INIT_SIZE
from 1048576 to 16384

Should fix swiotlb running OOM with large file transfers.

See sonyxperiadev/bug_tracker#432 (comment)

Needs accompanying sepolicy.
ix5 added a commit to ix5/device-sony-sepolicy that referenced this issue Sep 7, 2019
ix5 added a commit to ix5/device-sony-loire that referenced this issue Sep 7, 2019
Limit MTP_RX_BUFFER_INIT_SIZE and MTP_TX_BUFFER_INIT_SIZE
from 1048576 to 16384

Should fix swiotlb running OOM with large file transfers.

See sonyxperiadev/bug_tracker#432 (comment)

Needs accompanying sepolicy.
@Haxk20
Copy link
Contributor

Haxk20 commented Sep 12, 2019

This is issue on ganges as well and on Linux host too.

@Haxk20
Copy link
Contributor

Haxk20 commented Sep 12, 2019

@ix5 I will limit rx/tx on my build on ganges and if it fixes the issue as well could you make PR with the changes ? Thank you

@bartcubbins
Copy link
Contributor

bartcubbins commented Sep 14, 2019

@Haxk20 please test with this PR sonyxperiadev/kernel@aa5ff38
I see that this problem is common for at least three platforms and I think that we should fix this at the kernel level

@Haxk20
Copy link
Contributor

Haxk20 commented Sep 14, 2019

I have made a new build. Cant test at this point due to laptop fastboot issues. Will do once i get on PC

@bartcubbins
Copy link
Contributor

Don't test it, we will fix this in userspace

@Haxk20
Copy link
Contributor

Haxk20 commented Sep 14, 2019

Don't test it, we will fix this in userspace

Yes i read the PR. I mean i will test the userspace fix (limiting rx/tx)

@ix5 ix5 closed this as completed Dec 29, 2019
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

No branches or pull requests

5 participants