All of lore.kernel.org
 help / color / mirror / Atom feed
From: Matthias Schwarzott <zzam@gentoo.org>
To: Alan Stern <stern@rowland.harvard.edu>
Cc: linux-usb@vger.kernel.org, usb-storage@lists.one-eyed-alien.net,
	hirofumi@mail.parknet.co.jp
Subject: Re: [usb-storage] Re: Amazon Kindle disconnect after Synchronize Cache
Date: Thu, 11 Mar 2021 07:05:00 +0100	[thread overview]
Message-ID: <841a9a54-78ee-ffaa-fc3c-12defcf43b36@gentoo.org> (raw)
In-Reply-To: <20210310214648.GA236329@rowland.harvard.edu>

Am 10.03.21 um 22:46 schrieb Alan Stern:
> On Wed, Mar 10, 2021 at 09:56:04PM +0100, Matthias Schwarzott wrote:
>>> What happens if you set the value to 1000 before running the test?
>>>
>> I tested different values. At 1000 it still disconnects. At lower values it
>> no longer does this.
>> I tested 200 up to 900. Even 900 ms is good enough to keep it connected.
>>
>> Btw. it is not a USB disconnect, but it just seems to plays medium ejected.
>>
>> Out of interest I called "sg_start -v -l /dev/sde" after one of the failing
>> experiments. That made the Kindle go back to connected state.
>>
>> To me the above experiments show that enough TEST UNIT READY commands are
>> needed in the 2 s after a SYNCHRONIZE CACHE.
> 
> So you have found the solution to your problem.  Congratulations!
> 
Thank you for your support.

For longterm I think it should work automatically.
Some options I can think of (ordered by my preference):

1. Kernel sends one or more TEST UNIT READY commands after every 
SYNCHRONIZE CACHE to a Kindle device. Regardless of triggered by kernel 
or by some user code via ioctl.

2. Kernel automatically chooses a low enough value for events_poll_msecs 
if it detects kindle.

3. udev rule is added that matches the Kindle and sets events_poll_msecs.
   3a) SUBSYSTEM=="block", ACTION=="add", ENV{DEVTYPE}=="disk", 
ATTRS{product}=="Amazon Kindle", ATTR{events_poll_msecs}="900"

   3b) SUBSYSTEM=="block", ACTION=="add", ENV{DEVTYPE}=="disk", 
ATTRS{idVendor}=="1949", ATTRS{idProduct}=="0004", 
ATTR{events_poll_msecs}="900"

4. Kernel sends one or more TEST UNIT READY commands after every 
SYNCHRONIZE CACHE to a device (without matching).


I guess options 1 and 2 require a new entry in unusual_devs together 
with a (new?) quirk.
Option 3 requires to get a new rule into udev.
And option 4 is ugly as it changes behaviour for usb-storage or scsi 
disk device.

I would prefer option 1 or 2.

Do you know how high the overhead of having more TEST UNIT READY 
commands is? (=How much better option 1 is compared to option 2?)

Matthias

  reply	other threads:[~2021-03-11  6:05 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-05 16:54 Amazon Kindle disconnect after Synchronize Cache Matthias Schwarzott
2021-03-05 19:14 ` Alan Stern
     [not found]   ` <CAL411-qf+c_CB4cL=2349QqCCYimOBCYxXbsOfLbvVYOg0294g@mail.gmail.com>
2021-03-06 16:07     ` Alan Stern
2021-03-07  5:58   ` Matthias Schwarzott
2021-03-07 15:52     ` Alan Stern
2021-03-07 16:52       ` Matthias Schwarzott
2021-03-07 16:58         ` Alan Stern
2021-03-08 21:59           ` Matthias Schwarzott
2021-03-09 15:50             ` [usb-storage] " Alan Stern
2021-03-10 20:56               ` Matthias Schwarzott
2021-03-10 21:46                 ` Alan Stern
2021-03-11  6:05                   ` Matthias Schwarzott [this message]
2021-03-11 14:39                     ` Alan Stern
2021-03-16  5:26                       ` Matthias Schwarzott
2021-03-16 16:26                         ` Alan Stern
2021-03-16 16:43                           ` [systemd-devel] " Hans de Goede
2021-03-16 17:04                             ` Alan Stern
2021-03-16 21:52                               ` Matthias Schwarzott
2021-03-17 12:21                               ` Hans de Goede
2021-03-17 15:17                                 ` Alan Stern
2021-03-17 16:47                                   ` Lennart Poettering
     [not found]                                     ` <F279F9BC020000F5AE14D9EC@gwsmtp.uni-regensburg.de>
     [not found]                                       ` <C63C44570200006665972EEF@gwsmtp.uni-regensburg.de>
     [not found]                                         ` <B960C12A020000A667ECE9F9@gwsmtp.uni-regensburg.de>
     [not found]                                           ` <B72C58530200001565972EEF@gwsmtp.uni-regensburg.de>
     [not found]                                             ` <0F2319EB020000F567ECE9F9@gwsmtp.uni-regensburg.de>
     [not found]                                               ` <DE3F57520200009E65972EEF@gwsmtp.uni-regensburg.de>
     [not found]                                                 ` <52CC0074020000A3D68BC3D5@gwsmtp.uni-regensburg.de>
2021-03-18  7:03                                                   ` Antw: [EXT] " Ulrich Windl
2021-03-18 14:59                                                     ` Alan Stern
     [not found]                                                 ` <474C42CD02000091AE14D9EC@gwsmtp.uni-regensburg.de>
2021-03-18  7:04                                                   ` Ulrich Windl
     [not found]                                                   ` <D43A6F56020000F865972EEF@gwsmtp.uni-regensburg.de>
2021-03-18  7:10                                                     ` Antw: [EXT] [systemd-devel] [PATCH] usb-storage: Add quirk to defeat Kindle's automatic unload Ulrich Windl
2021-03-18 15:03                                                       ` Alan Stern
2021-03-17 17:56                                   ` [systemd-devel] [usb-storage] Re: Amazon Kindle disconnect after Synchronize Cache Matthias Schwarzott
2021-03-17 18:31                                     ` Hans de Goede
2021-03-17 19:06                                     ` [PATCH] usb-storage: Add quirk to defeat Kindle's automatic unload Alan Stern
2021-03-18 11:39                                       ` Hans de Goede
2021-03-18 13:50                                       ` [systemd-devel] " Tomasz Torcz
2021-03-18 15:07                                         ` Alan Stern
2021-03-16 21:43                           ` [usb-storage] Re: Amazon Kindle disconnect after Synchronize Cache Matthias Schwarzott

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=841a9a54-78ee-ffaa-fc3c-12defcf43b36@gentoo.org \
    --to=zzam@gentoo.org \
    --cc=hirofumi@mail.parknet.co.jp \
    --cc=linux-usb@vger.kernel.org \
    --cc=stern@rowland.harvard.edu \
    --cc=usb-storage@lists.one-eyed-alien.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.