From: Aaron Lu <aaron.lu@intel.com>
To: Tejun Heo <tj@kernel.org>
Cc: Jeff Garzik <jgarzik@pobox.com>,
James Bottomley <James.Bottomley@hansenpartnership.com>,
"Rafael J. Wysocki" <rjw@sisk.pl>,
Alan Stern <stern@rowland.harvard.edu>, Jeff Wu <jeff.wu@amd.com>,
Aaron Lu <aaron.lwe@gmail.com>,
linux-ide@vger.kernel.org, linux-pm@vger.kernel.org,
linux-scsi@vger.kernel.org, linux-acpi@vger.kernel.org
Subject: Re: [PATCH v9 06/10] ata: zpodd: check zero power ready status
Date: Mon, 19 Nov 2012 11:09:40 +0800 [thread overview]
Message-ID: <50A9A2F4.3020006@intel.com> (raw)
In-Reply-To: <20121118150004.GJ7306@mtj.dyndns.org>
On 11/18/2012 11:00 PM, Tejun Heo wrote:
> Hello, Aaron.
Hi,
>
> On Wed, Nov 14, 2012 at 10:18:23AM +0800, Aaron Lu wrote:
>> On 11/13/2012 03:13 AM, Tejun Heo wrote:
>>> Hello,
>>>
>>> On Fri, Nov 09, 2012 at 02:51:58PM +0800, Aaron Lu wrote:
>>>> +#define POWEROFF_DELAY (30 * 1000) /* 30 seconds for power off delay */
>>>> +
>>>> struct zpodd {
>>>> bool slot:1;
>>>> bool drawer:1;
>>>> bool from_notify:1; /* resumed as a result of acpi notification */
>>>> + bool status_ready:1; /* ready status derived from media event poll,
>>>> + it is not accurate, but serves as a hint */
>>>> + bool zp_ready:1; /* zero power ready state */
>>>> +
>>>> + unsigned long last_ready; /* last zero power ready timestamp */
>>>>
>>>> struct ata_device *dev;
>>>> };
>>>
>>> How are accesses to the bit fields synchronized?
>>
>> They are synchronized by PM core.
>> PM core ensures that no two suspend or resume callback run concurrently.
>> And when ODD is executing a command, it is in active state, no PM
>> callback will run.
>
> Care to add short comment for that? Flag and bitfield updates aren't
> atomic to each other, so I find it usually helpful to clearly state
> the synchronization rules for them. More so if locking is inherited
> from upprer layer and not immediately obvious.
OK.
>
>>> Hmmm... so, the "full" check only happens when autopm kicks in, right?
>>> Is it really worth avoiding an extra TUR on autopm events? That's not
>>> really a hot path. It seems a bit over-engineered to me.
>>
>> A little more information about this:
>> When there is disc inside and no program mounted the drive, the ODD will
>> be runtime suspended/resumed every 2 seconds along with the event poll.
>
> Is that a desirable behavior? I haven't been following autopm and am
> a bit fuzzy about how autopm works and what it does.
>
> If there isn't any user of the device autopm kicks in. If zpodd is
> enabled and there's no media, the device goes off power. If the user
> initiates an event which may change media status, the driver is
> notified via acpi and autopm backs out restoring power to the device.
> Am I understanding it correctly?
Yes.
>
> What I'm confused about is what autopm does for devices w/o zpodd.
> What happens then? Is it gonna leave power on for the device and,
> say, go on to suspend the controller? But, how would that work for,
> say, future devices with async notification for media events?
Maybe we shouldn't allow autopm for such devices?
>
> Also, if autopm is enabled, an optical device would go in and out of
> suspend every two seconds?
>
>> I'm not sure if the above situation can happen often. Normal desktop
>> environment should automatically mount the ODD once they got uevent, and
>> for console users, they will probably manually mount the drive after
>> they have inserted a disc. The way I did it this way is to deal with the
>> worst possible case. But if this is deemed as not necessary, I think I
>> can remove the snoop hint thing and use TUR directly.
>
> The problem with issuing TUR regularly is that some ODDs lock up after
> getting hit by frequent TURs. That's the reason why sr event check
> routine is being careful with TUR and only issue
> GET_EVENT_STATUS_NOTIFICATION. Windows does about the same thing and
> some vendors somehow screwed up TUR.
>
> That said, I can't say the snooping is pretty. It's a rather nasty
> thing to do. So, libata now wants information from the event polling
> in block layer, but reaching for block_device from ata_devices is
> nasty too. Hmmm... but aren't you already doing that to block polling
> on a powered down device?
I was feeling brain damaged by this for some time :-)
Basically, only ATA layer is aware of the power off thing, and sr knows
nothing about this(or it is not supposed to know this, at least, this is
what SCSI people think) and once powered off, I do not want the poll to
disturb the device, so I need to block the poll. I can't come up with
another way to achieve this except this nasty way.
James suggests me to keep the poll, but emulate the command. The problem
with this is, the autopm for resume will kick in on each poll, so I'll
need to decide if power up the ODD for this time's resume is needed in
port's runtime resume callback. This made things complex and it also put
too much logic in the resume callback, which is not desired. And even if
I keep the ODD in powered off state by emulating this poll command, its
ancestor devices will still be resumed, and I may need to do some trick
in their resume callback to avoid needless power/state transitions. This
doesn't feel like an elegant way to solve this either.
So yes, I'm still using this _nasty_ way to make the ODD stay in powered
off state as long as possible. But if there is other elegant ways to
solve this, I would appreciate it and happily using it. Personally, I
hope we can make sr aware of ZPODD, that would make the pain gone.
Thanks,
Aaron
next prev parent reply other threads:[~2012-11-19 3:09 UTC|newest]
Thread overview: 85+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-11-09 6:51 [PATCH v9 00/10] ZPODD Patches Aaron Lu
2012-11-09 6:51 ` [PATCH v9 01/10] scsi: sr: support runtime pm Aaron Lu
2012-11-09 6:51 ` [PATCH v9 02/10] ata: zpodd: Add CONFIG_SATA_ZPODD Aaron Lu
2012-11-09 6:51 ` [PATCH v9 03/10] ata: zpodd: identify and init ZPODD devices Aaron Lu
2012-11-12 18:53 ` Tejun Heo
2012-11-14 1:32 ` Aaron Lu
2012-11-18 14:38 ` Tejun Heo
2012-11-19 2:15 ` Aaron Lu
2012-11-09 6:51 ` [PATCH v9 04/10] libata: acpi: move acpi notification code to zpodd Aaron Lu
2012-11-12 18:55 ` Tejun Heo
2012-11-14 1:36 ` Aaron Lu
2012-11-09 6:51 ` [PATCH v9 05/10] libata: separate ATAPI code Aaron Lu
2012-11-12 18:57 ` Tejun Heo
2012-11-13 12:49 ` Aaron Lu
2012-11-18 15:01 ` Tejun Heo
2012-11-19 2:21 ` Aaron Lu
2012-11-19 14:51 ` Tejun Heo
2012-11-09 6:51 ` [PATCH v9 06/10] ata: zpodd: check zero power ready status Aaron Lu
2012-11-12 19:13 ` Tejun Heo
2012-11-13 13:20 ` Aaron Lu
2012-11-14 2:18 ` Aaron Lu
2012-11-18 15:00 ` Tejun Heo
2012-11-19 3:09 ` Aaron Lu [this message]
2012-11-19 14:56 ` Tejun Heo
2012-11-19 15:06 ` James Bottomley
2012-11-26 0:33 ` Rafael J. Wysocki
2012-11-26 0:45 ` Aaron Lu
2012-11-26 5:03 ` James Bottomley
2012-11-26 5:09 ` Aaron Lu
2012-11-26 7:32 ` James Bottomley
2012-11-26 8:27 ` Aaron Lu
2012-11-26 13:17 ` James Bottomley
2012-11-26 16:21 ` Alan Stern
2012-11-26 19:15 ` James Bottomley
2012-11-27 1:41 ` Aaron Lu
2012-11-28 0:51 ` Rafael J. Wysocki
2012-11-28 1:39 ` Tejun Heo
2012-11-28 2:24 ` Aaron Lu
2012-11-28 8:56 ` James Bottomley
2012-12-03 8:13 ` Aaron Lu
2012-12-03 8:25 ` James Bottomley
2012-12-03 8:59 ` Aaron Lu
2012-12-03 16:23 ` Tejun Heo
2012-12-03 18:56 ` Jeff Garzik
2012-12-04 5:04 ` Aaron Lu
2012-12-04 12:11 ` James Bottomley
2012-12-07 6:13 ` Aaron Lu
2012-12-10 3:26 ` Aaron Lu
2012-12-11 5:10 ` Tejun Heo
2012-12-18 8:30 ` Aaron Lu
2012-12-20 6:07 ` Aaron Lu
2012-12-25 17:17 ` Tejun Heo
2012-12-26 1:42 ` Aaron Lu
2012-12-28 21:16 ` Tejun Heo
2013-01-04 1:04 ` Aaron Lu
2012-11-30 8:55 ` Aaron Lu
2012-11-30 11:15 ` Rafael J. Wysocki
2012-11-20 6:00 ` Aaron Lu
2012-11-20 8:59 ` Aaron Lu
2012-11-26 0:50 ` Rafael J. Wysocki
2012-11-26 0:48 ` Aaron Lu
2012-11-26 1:03 ` Rafael J. Wysocki
2012-11-26 1:05 ` Aaron Lu
2012-11-26 1:11 ` Rafael J. Wysocki
2012-11-26 1:09 ` Aaron Lu
2012-11-26 1:22 ` Rafael J. Wysocki
2012-11-26 1:22 ` Aaron Lu
2012-11-26 1:17 ` Aaron Lu
2012-11-09 6:51 ` [PATCH v9 07/10] block: add a new interface to block events Aaron Lu
2012-11-12 19:14 ` Tejun Heo
2012-11-12 19:18 ` Alan Stern
2012-11-12 19:21 ` Tejun Heo
2012-11-12 19:34 ` Alan Stern
2012-11-18 15:05 ` Tejun Heo
2012-11-18 17:41 ` Alan Stern
2012-11-18 21:56 ` Tejun Heo
2012-11-18 21:58 ` Tejun Heo
2012-11-18 23:28 ` Alan Stern
2012-11-18 23:35 ` Tejun Heo
2012-11-19 2:07 ` Alan Stern
2012-11-19 3:21 ` Aaron Lu
2012-11-19 14:50 ` Tejun Heo
2012-11-09 6:52 ` [PATCH v9 08/10] scsi: sr: support (un)block events Aaron Lu
2012-11-09 6:52 ` [PATCH v9 09/10] ata: zpodd: handle power transition of ODD Aaron Lu
2012-11-09 6:52 ` [PATCH v9 10/10] ata: expose pm qos flags to user space for ata device Aaron Lu
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=50A9A2F4.3020006@intel.com \
--to=aaron.lu@intel.com \
--cc=James.Bottomley@hansenpartnership.com \
--cc=aaron.lwe@gmail.com \
--cc=jeff.wu@amd.com \
--cc=jgarzik@pobox.com \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-ide@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=rjw@sisk.pl \
--cc=stern@rowland.harvard.edu \
--cc=tj@kernel.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).