Thread (27 messages) 27 messages, 5 authors, 2021-03-18

Re: Amazon Kindle disconnect after Synchronize Cache

From: Matthias Schwarzott <zzam@gentoo.org>
Date: 2021-03-08 22:00:37

Am 07.03.21 um 17:58 schrieb Alan Stern:
On Sun, Mar 07, 2021 at 05:52:19PM +0100, Matthias Schwarzott wrote:
quoted
This time Kindle is sde again:

# dmesg |tail
[83709.973141] usb-storage 3-4:1.0: USB Mass Storage device detected
[83709.973226] scsi host8: usb-storage 3-4:1.0
[83711.028665] scsi 8:0:0:0: Direct-Access     Kindle   Internal Storage
0100 PQ: 0 ANSI: 2
[83711.028792] sd 8:0:0:0: Attached scsi generic sg5 type 0
[83711.031536] sd 8:0:0:0: Power-on or device reset occurred
[83711.046604] sd 8:0:0:0: [sde] Attached SCSI removable disk
[83713.145467] sd 8:0:0:0: [sde] 6688768 512-byte logical blocks: (3.42
GB/3.19 GiB)
[83713.364900] sd 8:0:0:0: [sde] Write cache: enabled, read cache: enabled,
doesn't support DPO or FUA
[83713.364906] sde: detected capacity change from 0 to 6688768
[83713.368036]  sde: sde1
# cat /sys/block/sde/device/power/control
on

power/control reports the same value for all sd? devices on this system.
Okay.  Can you collect a usbmon trace showing the events leading up to
and including a disconnection?
The easiest reproducer is by calling sync while having a file/the device 
open (and keeping it open afterwards).

1. I recorded usbmon trace like this:
# cat /sys/kernel/debug/usb/usbmon/3u > 
/tmp/connect-python-sync-disconnect-usbmon.out

2. Connect Kindle device

3. Then trigger sync with python:
# python -c "import time; import os; f = open('/dev/sde', 'r+b'); 
time.sleep(1); os.fsync(f); time.sleep(5)"

4. After 2 seconds Kindle disconnects (does no longer show USB-Mode screen).

5. Ctrl+c the recording

When the final sleep in the python-command is missing, the Kindle does 
not disconnect.
Alan Stern

PS: I suspect the SYNCHRONIZE CACHE commands are correlated with the
disconnections but don't cause them.  That is, I suspect the
disconnections happen when the device has been idle -- and generally the
host computer sends a SYNCHRONIZE CACHE command before idling a
removable drive.
I cannot read the usbmon trace, but wireshark displayed a command "SCSI: 
Prevent/Allow Medium Removal LUN: 0x00  ALLOW" when closing the file.
So I suspect this command also counts as activity (!idle).

Matthias

Attachments

Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help