License cleanup: add SPDX GPL-2.0 license identifier to files with no license
Many source files in the tree are missing licensing information, which
makes it harder for compliance tools to determine the correct license.
By default all files without license information are under the default
license of the kernel, which is GPL version 2.
Update the files which contain no license information with the 'GPL-2.0'
SPDX license identifier. The SPDX identifier is a legally binding
shorthand, which can be used instead of the full boiler plate text.
This patch is based on work done by Thomas Gleixner and Kate Stewart and
Philippe Ombredanne.
How this work was done:
Patches were generated and checked against linux-4.14-rc6 for a subset of
the use cases:
- file had no licensing information it it.
- file was a */uapi/* one with no licensing information in it,
- file was a */uapi/* one with existing licensing information,
Further patches will be generated in subsequent months to fix up cases
where non-standard license headers were used, and references to license
had to be inferred by heuristics based on keywords.
The analysis to determine which SPDX License Identifier to be applied to
a file was done in a spreadsheet of side by side results from of the
output of two independent scanners (ScanCode & Windriver) producing SPDX
tag:value files created by Philippe Ombredanne. Philippe prepared the
base worksheet, and did an initial spot review of a few 1000 files.
The 4.13 kernel was the starting point of the analysis with 60,537 files
assessed. Kate Stewart did a file by file comparison of the scanner
results in the spreadsheet to determine which SPDX license identifier(s)
to be applied to the file. She confirmed any determination that was not
immediately clear with lawyers working with the Linux Foundation.
Criteria used to select files for SPDX license identifier tagging was:
- Files considered eligible had to be source code files.
- Make and config files were included as candidates if they contained >5
lines of source
- File already had some variant of a license header in it (even if <5
lines).
All documentation files were explicitly excluded.
The following heuristics were used to determine which SPDX license
identifiers to apply.
- when both scanners couldn't find any license traces, file was
considered to have no license information in it, and the top level
COPYING file license applied.
For non */uapi/* files that summary was:
SPDX license identifier # files
---------------------------------------------------|-------
GPL-2.0 11139
and resulted in the first patch in this series.
If that file was a */uapi/* path one, it was "GPL-2.0 WITH
Linux-syscall-note" otherwise it was "GPL-2.0". Results of that was:
SPDX license identifier # files
---------------------------------------------------|-------
GPL-2.0 WITH Linux-syscall-note 930
and resulted in the second patch in this series.
- if a file had some form of licensing information in it, and was one
of the */uapi/* ones, it was denoted with the Linux-syscall-note if
any GPL family license was found in the file or had no licensing in
it (per prior point). Results summary:
SPDX license identifier # files
---------------------------------------------------|------
GPL-2.0 WITH Linux-syscall-note 270
GPL-2.0+ WITH Linux-syscall-note 169
((GPL-2.0 WITH Linux-syscall-note) OR BSD-2-Clause) 21
((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause) 17
LGPL-2.1+ WITH Linux-syscall-note 15
GPL-1.0+ WITH Linux-syscall-note 14
((GPL-2.0+ WITH Linux-syscall-note) OR BSD-3-Clause) 5
LGPL-2.0+ WITH Linux-syscall-note 4
LGPL-2.1 WITH Linux-syscall-note 3
((GPL-2.0 WITH Linux-syscall-note) OR MIT) 3
((GPL-2.0 WITH Linux-syscall-note) AND MIT) 1
and that resulted in the third patch in this series.
- when the two scanners agreed on the detected license(s), that became
the concluded license(s).
- when there was disagreement between the two scanners (one detected a
license but the other didn't, or they both detected different
licenses) a manual inspection of the file occurred.
- In most cases a manual inspection of the information in the file
resulted in a clear resolution of the license that should apply (and
which scanner probably needed to revisit its heuristics).
- When it was not immediately clear, the license identifier was
confirmed with lawyers working with the Linux Foundation.
- If there was any question as to the appropriate license identifier,
the file was flagged for further research and to be revisited later
in time.
In total, over 70 hours of logged manual review was done on the
spreadsheet to determine the SPDX license identifiers to apply to the
source files by Kate, Philippe, Thomas and, in some cases, confirmation
by lawyers working with the Linux Foundation.
Kate also obtained a third independent scan of the 4.13 code base from
FOSSology, and compared selected files where the other two scanners
disagreed against that SPDX file, to see if there was new insights. The
Windriver scanner is based on an older version of FOSSology in part, so
they are related.
Thomas did random spot checks in about 500 files from the spreadsheets
for the uapi headers and agreed with SPDX license identifier in the
files he inspected. For the non-uapi files Thomas did random spot checks
in about 15000 files.
In initial set of patches against 4.14-rc6, 3 files were found to have
copy/paste license identifier errors, and have been fixed to reflect the
correct identifier.
Additionally Philippe spent 10 hours this week doing a detailed manual
inspection and review of the 12,461 patched files from the initial patch
version early this week with:
- a full scancode scan run, collecting the matched texts, detected
license ids and scores
- reviewing anything where there was a license detected (about 500+
files) to ensure that the applied SPDX license was correct
- reviewing anything where there was no detection but the patch license
was not GPL-2.0 WITH Linux-syscall-note to ensure that the applied
SPDX license was correct
This produced a worksheet with 20 files needing minor correction. This
worksheet was then exported into 3 different .csv files for the
different types of files to be modified.
These .csv files were then reviewed by Greg. Thomas wrote a script to
parse the csv files and add the proper SPDX tag to the file, in the
format that the file expected. This script was further refined by Greg
based on the output to detect more types of files automatically and to
distinguish between header and source .c files (which need different
comment types.) Finally Greg ran the script using the .csv files to
generate the patches.
Reviewed-by: Kate Stewart <kstewart@linuxfoundation.org>
Reviewed-by: Philippe Ombredanne <pombredanne@nexb.com>
Reviewed-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-11-01 14:07:57 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0
|
2013-01-15 09:20:58 +00:00
|
|
|
#include <linux/libata.h>
|
|
|
|
#include <linux/cdrom.h>
|
2013-01-15 09:20:59 +00:00
|
|
|
#include <linux/pm_runtime.h>
|
libata: check zero power ready status for ZPODD
Per the Mount Fuji spec, the ODD is considered zero power ready when:
- For slot type ODD, no media inside;
- For tray type ODD, no media inside and tray closed.
The information can be retrieved by either the returned information of
command GET_EVENT_STATUS_NOTIFICATION(the command is used to poll for
media event) or sense code.
The information provided by the media status byte is not accurate, it
is possible that after a new disc is just inserted, the status byte
still returns media not present. So this information can not be used as
the deciding factor, we use sense code to decide if zpready status is
true.
When we first sensed the ODD in the zero power ready state, the
zp_sampled will be set and timestamp will be recoreded. And after ODD
stayed in this state for some pre-defined period, the ODD is considered
as power off ready and the zp_ready flag will be set. The zp_ready flag
serves as the deciding factor other code will use to see if power off is
OK for the ODD.
The Mount Fuji spec suggests a delay should be used here, to avoid the
case user ejects the ODD and then instantly inserts a new one again, so
that we can avoid a power transition. And some ODDs may be slow to place
its head to the home position after disc is ejected, so a delay here is
generally a good idea. And the delay time can be changed via the module
param zpodd_poweroff_delay.
The zero power ready status check is performed in the ata port's runtime
suspend code path, when port is not frozen yet, as we need to issue some
IOs to the ODD.
Signed-off-by: Aaron Lu <aaron.lu@intel.com>
Signed-off-by: Jeff Garzik <jgarzik@redhat.com>
2013-01-15 09:21:00 +00:00
|
|
|
#include <linux/module.h>
|
ata: acpi: rework the ata acpi bind support
Binding ACPI handle to SCSI device has several drawbacks, namely:
1 During ATA device initialization time, ACPI handle will be needed
while SCSI devices are not created yet. So each time ACPI handle is
needed, instead of retrieving the handle by ACPI_HANDLE macro,
a namespace scan is performed to find the handle for the corresponding
ATA device. This is inefficient, and also expose a restriction on
calling path not holding any lock.
2 The binding to SCSI device tree makes code complex, while at the same
time doesn't bring us any benefit. All ACPI handlings are still done
in ATA module, not in SCSI.
Rework the ATA ACPI binding code to bind ACPI handle to ATA transport
devices(ATA port and ATA device). The binding needs to be done only once,
since the ATA transport devices do not go away with hotplug. And due to
this, the flush_work call in hotplug handler for ATA bay is no longer
needed.
Tested on an Intel test platform for binding and runtime power off for
ODD(ZPODD) and hard disk; on an ASUS S400C for binding and normal boot
and S3, where its SATA port node has _SDD and _GTF control methods when
configured as an AHCI controller and its PATA device node has _GTF
control method when configured as an IDE controller. SATA PMP binding
and ATA hotplug is not tested.
Signed-off-by: Aaron Lu <aaron.lu@intel.com>
Tested-by: Dirk Griesbach <spamthis@freenet.de>
Signed-off-by: Tejun Heo <tj@kernel.org>
2013-08-23 02:17:54 +00:00
|
|
|
#include <linux/pm_qos.h>
|
2013-01-15 09:20:59 +00:00
|
|
|
#include <scsi/scsi_device.h>
|
2013-01-15 09:20:58 +00:00
|
|
|
|
|
|
|
#include "libata.h"
|
|
|
|
|
libata: check zero power ready status for ZPODD
Per the Mount Fuji spec, the ODD is considered zero power ready when:
- For slot type ODD, no media inside;
- For tray type ODD, no media inside and tray closed.
The information can be retrieved by either the returned information of
command GET_EVENT_STATUS_NOTIFICATION(the command is used to poll for
media event) or sense code.
The information provided by the media status byte is not accurate, it
is possible that after a new disc is just inserted, the status byte
still returns media not present. So this information can not be used as
the deciding factor, we use sense code to decide if zpready status is
true.
When we first sensed the ODD in the zero power ready state, the
zp_sampled will be set and timestamp will be recoreded. And after ODD
stayed in this state for some pre-defined period, the ODD is considered
as power off ready and the zp_ready flag will be set. The zp_ready flag
serves as the deciding factor other code will use to see if power off is
OK for the ODD.
The Mount Fuji spec suggests a delay should be used here, to avoid the
case user ejects the ODD and then instantly inserts a new one again, so
that we can avoid a power transition. And some ODDs may be slow to place
its head to the home position after disc is ejected, so a delay here is
generally a good idea. And the delay time can be changed via the module
param zpodd_poweroff_delay.
The zero power ready status check is performed in the ata port's runtime
suspend code path, when port is not frozen yet, as we need to issue some
IOs to the ODD.
Signed-off-by: Aaron Lu <aaron.lu@intel.com>
Signed-off-by: Jeff Garzik <jgarzik@redhat.com>
2013-01-15 09:21:00 +00:00
|
|
|
static int zpodd_poweroff_delay = 30; /* 30 seconds for power off delay */
|
|
|
|
module_param(zpodd_poweroff_delay, int, 0644);
|
|
|
|
MODULE_PARM_DESC(zpodd_poweroff_delay, "Poweroff delay for ZPODD in seconds");
|
|
|
|
|
2013-01-15 09:20:58 +00:00
|
|
|
enum odd_mech_type {
|
|
|
|
ODD_MECH_TYPE_SLOT,
|
|
|
|
ODD_MECH_TYPE_DRAWER,
|
|
|
|
ODD_MECH_TYPE_UNSUPPORTED,
|
|
|
|
};
|
|
|
|
|
|
|
|
struct zpodd {
|
|
|
|
enum odd_mech_type mech_type; /* init during probe, RO afterwards */
|
|
|
|
struct ata_device *dev;
|
2013-01-15 09:20:59 +00:00
|
|
|
|
|
|
|
/* The following fields are synchronized by PM core. */
|
|
|
|
bool from_notify; /* resumed as a result of
|
|
|
|
* acpi wake notification */
|
libata: check zero power ready status for ZPODD
Per the Mount Fuji spec, the ODD is considered zero power ready when:
- For slot type ODD, no media inside;
- For tray type ODD, no media inside and tray closed.
The information can be retrieved by either the returned information of
command GET_EVENT_STATUS_NOTIFICATION(the command is used to poll for
media event) or sense code.
The information provided by the media status byte is not accurate, it
is possible that after a new disc is just inserted, the status byte
still returns media not present. So this information can not be used as
the deciding factor, we use sense code to decide if zpready status is
true.
When we first sensed the ODD in the zero power ready state, the
zp_sampled will be set and timestamp will be recoreded. And after ODD
stayed in this state for some pre-defined period, the ODD is considered
as power off ready and the zp_ready flag will be set. The zp_ready flag
serves as the deciding factor other code will use to see if power off is
OK for the ODD.
The Mount Fuji spec suggests a delay should be used here, to avoid the
case user ejects the ODD and then instantly inserts a new one again, so
that we can avoid a power transition. And some ODDs may be slow to place
its head to the home position after disc is ejected, so a delay here is
generally a good idea. And the delay time can be changed via the module
param zpodd_poweroff_delay.
The zero power ready status check is performed in the ata port's runtime
suspend code path, when port is not frozen yet, as we need to issue some
IOs to the ODD.
Signed-off-by: Aaron Lu <aaron.lu@intel.com>
Signed-off-by: Jeff Garzik <jgarzik@redhat.com>
2013-01-15 09:21:00 +00:00
|
|
|
bool zp_ready; /* ZP ready state */
|
|
|
|
unsigned long last_ready; /* last ZP ready timestamp */
|
|
|
|
bool zp_sampled; /* ZP ready state sampled */
|
2013-01-15 09:21:01 +00:00
|
|
|
bool powered_off; /* ODD is powered off
|
|
|
|
* during suspend */
|
2013-01-15 09:20:58 +00:00
|
|
|
};
|
|
|
|
|
2013-01-15 09:21:01 +00:00
|
|
|
static int eject_tray(struct ata_device *dev)
|
|
|
|
{
|
2013-06-23 19:25:04 +00:00
|
|
|
struct ata_taskfile tf;
|
2017-09-06 08:56:29 +00:00
|
|
|
static const char cdb[] = { GPCMD_START_STOP_UNIT,
|
2013-01-15 09:21:01 +00:00
|
|
|
0, 0, 0,
|
|
|
|
0x02, /* LoEj */
|
|
|
|
0, 0, 0, 0, 0, 0, 0,
|
|
|
|
};
|
|
|
|
|
2013-06-23 19:25:04 +00:00
|
|
|
ata_tf_init(dev, &tf);
|
2013-01-15 09:21:01 +00:00
|
|
|
tf.flags = ATA_TFLAG_ISADDR | ATA_TFLAG_DEVICE;
|
|
|
|
tf.command = ATA_CMD_PACKET;
|
|
|
|
tf.protocol = ATAPI_PROT_NODATA;
|
|
|
|
|
|
|
|
return ata_exec_internal(dev, &tf, cdb, DMA_NONE, NULL, 0, 0);
|
|
|
|
}
|
|
|
|
|
2013-01-15 09:20:58 +00:00
|
|
|
/* Per the spec, only slot type and drawer type ODD can be supported */
|
|
|
|
static enum odd_mech_type zpodd_get_mech_type(struct ata_device *dev)
|
|
|
|
{
|
|
|
|
char buf[16];
|
|
|
|
unsigned int ret;
|
|
|
|
struct rm_feature_desc *desc = (void *)(buf + 8);
|
2013-06-23 19:25:04 +00:00
|
|
|
struct ata_taskfile tf;
|
2017-09-06 08:56:29 +00:00
|
|
|
static const char cdb[] = { GPCMD_GET_CONFIGURATION,
|
2013-01-15 09:20:58 +00:00
|
|
|
2, /* only 1 feature descriptor requested */
|
|
|
|
0, 3, /* 3, removable medium feature */
|
|
|
|
0, 0, 0,/* reserved */
|
|
|
|
0, sizeof(buf),
|
|
|
|
0, 0, 0,
|
|
|
|
};
|
|
|
|
|
2013-06-23 19:25:04 +00:00
|
|
|
ata_tf_init(dev, &tf);
|
2013-01-15 09:20:58 +00:00
|
|
|
tf.flags = ATA_TFLAG_ISADDR | ATA_TFLAG_DEVICE;
|
|
|
|
tf.command = ATA_CMD_PACKET;
|
|
|
|
tf.protocol = ATAPI_PROT_PIO;
|
|
|
|
tf.lbam = sizeof(buf);
|
|
|
|
|
|
|
|
ret = ata_exec_internal(dev, &tf, cdb, DMA_FROM_DEVICE,
|
|
|
|
buf, sizeof(buf), 0);
|
|
|
|
if (ret)
|
|
|
|
return ODD_MECH_TYPE_UNSUPPORTED;
|
|
|
|
|
|
|
|
if (be16_to_cpu(desc->feature_code) != 3)
|
|
|
|
return ODD_MECH_TYPE_UNSUPPORTED;
|
|
|
|
|
|
|
|
if (desc->mech_type == 0 && desc->load == 0 && desc->eject == 1)
|
|
|
|
return ODD_MECH_TYPE_SLOT;
|
|
|
|
else if (desc->mech_type == 1 && desc->load == 0 && desc->eject == 1)
|
|
|
|
return ODD_MECH_TYPE_DRAWER;
|
|
|
|
else
|
|
|
|
return ODD_MECH_TYPE_UNSUPPORTED;
|
|
|
|
}
|
|
|
|
|
libata: check zero power ready status for ZPODD
Per the Mount Fuji spec, the ODD is considered zero power ready when:
- For slot type ODD, no media inside;
- For tray type ODD, no media inside and tray closed.
The information can be retrieved by either the returned information of
command GET_EVENT_STATUS_NOTIFICATION(the command is used to poll for
media event) or sense code.
The information provided by the media status byte is not accurate, it
is possible that after a new disc is just inserted, the status byte
still returns media not present. So this information can not be used as
the deciding factor, we use sense code to decide if zpready status is
true.
When we first sensed the ODD in the zero power ready state, the
zp_sampled will be set and timestamp will be recoreded. And after ODD
stayed in this state for some pre-defined period, the ODD is considered
as power off ready and the zp_ready flag will be set. The zp_ready flag
serves as the deciding factor other code will use to see if power off is
OK for the ODD.
The Mount Fuji spec suggests a delay should be used here, to avoid the
case user ejects the ODD and then instantly inserts a new one again, so
that we can avoid a power transition. And some ODDs may be slow to place
its head to the home position after disc is ejected, so a delay here is
generally a good idea. And the delay time can be changed via the module
param zpodd_poweroff_delay.
The zero power ready status check is performed in the ata port's runtime
suspend code path, when port is not frozen yet, as we need to issue some
IOs to the ODD.
Signed-off-by: Aaron Lu <aaron.lu@intel.com>
Signed-off-by: Jeff Garzik <jgarzik@redhat.com>
2013-01-15 09:21:00 +00:00
|
|
|
/* Test if ODD is zero power ready by sense code */
|
|
|
|
static bool zpready(struct ata_device *dev)
|
|
|
|
{
|
|
|
|
u8 sense_key, *sense_buf;
|
|
|
|
unsigned int ret, asc, ascq, add_len;
|
|
|
|
struct zpodd *zpodd = dev->zpodd;
|
|
|
|
|
|
|
|
ret = atapi_eh_tur(dev, &sense_key);
|
|
|
|
|
|
|
|
if (!ret || sense_key != NOT_READY)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
sense_buf = dev->link->ap->sector_buf;
|
|
|
|
ret = atapi_eh_request_sense(dev, sense_buf, sense_key);
|
|
|
|
if (ret)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
/* sense valid */
|
|
|
|
if ((sense_buf[0] & 0x7f) != 0x70)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
add_len = sense_buf[7];
|
|
|
|
/* has asc and ascq */
|
|
|
|
if (add_len < 6)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
asc = sense_buf[12];
|
|
|
|
ascq = sense_buf[13];
|
|
|
|
|
|
|
|
if (zpodd->mech_type == ODD_MECH_TYPE_SLOT)
|
|
|
|
/* no media inside */
|
|
|
|
return asc == 0x3a;
|
|
|
|
else
|
|
|
|
/* no media inside and door closed */
|
|
|
|
return asc == 0x3a && ascq == 0x01;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Update the zpodd->zp_ready field. This field will only be set
|
|
|
|
* if the ODD has stayed in ZP ready state for zpodd_poweroff_delay
|
|
|
|
* time, and will be used to decide if power off is allowed. If it
|
|
|
|
* is set, it will be cleared during resume from powered off state.
|
|
|
|
*/
|
|
|
|
void zpodd_on_suspend(struct ata_device *dev)
|
|
|
|
{
|
|
|
|
struct zpodd *zpodd = dev->zpodd;
|
|
|
|
unsigned long expires;
|
|
|
|
|
|
|
|
if (!zpready(dev)) {
|
|
|
|
zpodd->zp_sampled = false;
|
2013-01-15 09:21:02 +00:00
|
|
|
zpodd->zp_ready = false;
|
libata: check zero power ready status for ZPODD
Per the Mount Fuji spec, the ODD is considered zero power ready when:
- For slot type ODD, no media inside;
- For tray type ODD, no media inside and tray closed.
The information can be retrieved by either the returned information of
command GET_EVENT_STATUS_NOTIFICATION(the command is used to poll for
media event) or sense code.
The information provided by the media status byte is not accurate, it
is possible that after a new disc is just inserted, the status byte
still returns media not present. So this information can not be used as
the deciding factor, we use sense code to decide if zpready status is
true.
When we first sensed the ODD in the zero power ready state, the
zp_sampled will be set and timestamp will be recoreded. And after ODD
stayed in this state for some pre-defined period, the ODD is considered
as power off ready and the zp_ready flag will be set. The zp_ready flag
serves as the deciding factor other code will use to see if power off is
OK for the ODD.
The Mount Fuji spec suggests a delay should be used here, to avoid the
case user ejects the ODD and then instantly inserts a new one again, so
that we can avoid a power transition. And some ODDs may be slow to place
its head to the home position after disc is ejected, so a delay here is
generally a good idea. And the delay time can be changed via the module
param zpodd_poweroff_delay.
The zero power ready status check is performed in the ata port's runtime
suspend code path, when port is not frozen yet, as we need to issue some
IOs to the ODD.
Signed-off-by: Aaron Lu <aaron.lu@intel.com>
Signed-off-by: Jeff Garzik <jgarzik@redhat.com>
2013-01-15 09:21:00 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!zpodd->zp_sampled) {
|
|
|
|
zpodd->zp_sampled = true;
|
|
|
|
zpodd->last_ready = jiffies;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
expires = zpodd->last_ready +
|
|
|
|
msecs_to_jiffies(zpodd_poweroff_delay * 1000);
|
|
|
|
if (time_before(jiffies, expires))
|
|
|
|
return;
|
|
|
|
|
|
|
|
zpodd->zp_ready = true;
|
|
|
|
}
|
|
|
|
|
2013-01-15 09:21:01 +00:00
|
|
|
bool zpodd_zpready(struct ata_device *dev)
|
|
|
|
{
|
|
|
|
struct zpodd *zpodd = dev->zpodd;
|
|
|
|
return zpodd->zp_ready;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Enable runtime wake capability through ACPI and set the powered_off flag,
|
|
|
|
* this flag will be used during resume to decide what operations are needed
|
|
|
|
* to take.
|
2013-01-23 07:09:32 +00:00
|
|
|
*
|
|
|
|
* Also, media poll needs to be silenced, so that it doesn't bring the ODD
|
|
|
|
* back to full power state every few seconds.
|
2013-01-15 09:21:01 +00:00
|
|
|
*/
|
|
|
|
void zpodd_enable_run_wake(struct ata_device *dev)
|
|
|
|
{
|
|
|
|
struct zpodd *zpodd = dev->zpodd;
|
|
|
|
|
2013-01-23 07:09:32 +00:00
|
|
|
sdev_disable_disk_events(dev->sdev);
|
|
|
|
|
2013-01-15 09:21:01 +00:00
|
|
|
zpodd->powered_off = true;
|
2017-06-23 23:54:39 +00:00
|
|
|
acpi_pm_set_device_wakeup(&dev->tdev, true);
|
2013-01-15 09:21:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Disable runtime wake capability if it is enabled */
|
|
|
|
void zpodd_disable_run_wake(struct ata_device *dev)
|
|
|
|
{
|
|
|
|
struct zpodd *zpodd = dev->zpodd;
|
|
|
|
|
2017-06-23 23:54:39 +00:00
|
|
|
if (zpodd->powered_off)
|
|
|
|
acpi_pm_set_device_wakeup(&dev->tdev, false);
|
2013-01-15 09:21:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Post power on processing after the ODD has been recovered. If the
|
|
|
|
* ODD wasn't powered off during suspend, it doesn't do anything.
|
|
|
|
*
|
|
|
|
* For drawer type ODD, if it is powered on due to user pressed the
|
|
|
|
* eject button, the tray needs to be ejected. This can only be done
|
|
|
|
* after the ODD has been recovered, i.e. link is initialized and
|
|
|
|
* device is able to process NON_DATA PIO command, as eject needs to
|
|
|
|
* send command for the ODD to process.
|
|
|
|
*
|
|
|
|
* The from_notify flag set in wake notification handler function
|
|
|
|
* zpodd_wake_dev represents if power on is due to user's action.
|
|
|
|
*
|
|
|
|
* For both types of ODD, several fields need to be reset.
|
|
|
|
*/
|
|
|
|
void zpodd_post_poweron(struct ata_device *dev)
|
|
|
|
{
|
|
|
|
struct zpodd *zpodd = dev->zpodd;
|
|
|
|
|
|
|
|
if (!zpodd->powered_off)
|
|
|
|
return;
|
|
|
|
|
|
|
|
zpodd->powered_off = false;
|
|
|
|
|
|
|
|
if (zpodd->from_notify) {
|
|
|
|
zpodd->from_notify = false;
|
|
|
|
if (zpodd->mech_type == ODD_MECH_TYPE_DRAWER)
|
|
|
|
eject_tray(dev);
|
|
|
|
}
|
|
|
|
|
|
|
|
zpodd->zp_sampled = false;
|
|
|
|
zpodd->zp_ready = false;
|
2013-01-23 07:09:32 +00:00
|
|
|
|
|
|
|
sdev_enable_disk_events(dev->sdev);
|
2013-01-15 09:21:01 +00:00
|
|
|
}
|
|
|
|
|
2013-01-15 09:20:59 +00:00
|
|
|
static void zpodd_wake_dev(acpi_handle handle, u32 event, void *context)
|
|
|
|
{
|
|
|
|
struct ata_device *ata_dev = context;
|
|
|
|
struct zpodd *zpodd = ata_dev->zpodd;
|
|
|
|
struct device *dev = &ata_dev->sdev->sdev_gendev;
|
|
|
|
|
2013-01-28 05:08:02 +00:00
|
|
|
if (event == ACPI_NOTIFY_DEVICE_WAKE && pm_runtime_suspended(dev)) {
|
2013-01-15 09:20:59 +00:00
|
|
|
zpodd->from_notify = true;
|
|
|
|
pm_runtime_resume(dev);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void ata_acpi_add_pm_notifier(struct ata_device *dev)
|
|
|
|
{
|
|
|
|
acpi_handle handle = ata_dev_acpi_handle(dev);
|
|
|
|
acpi_install_notify_handler(handle, ACPI_SYSTEM_NOTIFY,
|
|
|
|
zpodd_wake_dev, dev);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void ata_acpi_remove_pm_notifier(struct ata_device *dev)
|
|
|
|
{
|
ata: acpi: rework the ata acpi bind support
Binding ACPI handle to SCSI device has several drawbacks, namely:
1 During ATA device initialization time, ACPI handle will be needed
while SCSI devices are not created yet. So each time ACPI handle is
needed, instead of retrieving the handle by ACPI_HANDLE macro,
a namespace scan is performed to find the handle for the corresponding
ATA device. This is inefficient, and also expose a restriction on
calling path not holding any lock.
2 The binding to SCSI device tree makes code complex, while at the same
time doesn't bring us any benefit. All ACPI handlings are still done
in ATA module, not in SCSI.
Rework the ATA ACPI binding code to bind ACPI handle to ATA transport
devices(ATA port and ATA device). The binding needs to be done only once,
since the ATA transport devices do not go away with hotplug. And due to
this, the flush_work call in hotplug handler for ATA bay is no longer
needed.
Tested on an Intel test platform for binding and runtime power off for
ODD(ZPODD) and hard disk; on an ASUS S400C for binding and normal boot
and S3, where its SATA port node has _SDD and _GTF control methods when
configured as an AHCI controller and its PATA device node has _GTF
control method when configured as an IDE controller. SATA PMP binding
and ATA hotplug is not tested.
Signed-off-by: Aaron Lu <aaron.lu@intel.com>
Tested-by: Dirk Griesbach <spamthis@freenet.de>
Signed-off-by: Tejun Heo <tj@kernel.org>
2013-08-23 02:17:54 +00:00
|
|
|
acpi_handle handle = ata_dev_acpi_handle(dev);
|
2013-01-15 09:20:59 +00:00
|
|
|
acpi_remove_notify_handler(handle, ACPI_SYSTEM_NOTIFY, zpodd_wake_dev);
|
|
|
|
}
|
|
|
|
|
2013-01-15 09:20:58 +00:00
|
|
|
void zpodd_init(struct ata_device *dev)
|
|
|
|
{
|
2014-03-14 05:46:10 +00:00
|
|
|
struct acpi_device *adev = ACPI_COMPANION(&dev->tdev);
|
2013-01-15 09:20:58 +00:00
|
|
|
enum odd_mech_type mech_type;
|
|
|
|
struct zpodd *zpodd;
|
|
|
|
|
2014-03-14 05:46:10 +00:00
|
|
|
if (dev->zpodd || !adev || !acpi_device_can_poweroff(adev))
|
2013-01-15 09:20:58 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
mech_type = zpodd_get_mech_type(dev);
|
|
|
|
if (mech_type == ODD_MECH_TYPE_UNSUPPORTED)
|
|
|
|
return;
|
|
|
|
|
|
|
|
zpodd = kzalloc(sizeof(struct zpodd), GFP_KERNEL);
|
|
|
|
if (!zpodd)
|
|
|
|
return;
|
|
|
|
|
|
|
|
zpodd->mech_type = mech_type;
|
|
|
|
|
2013-01-15 09:20:59 +00:00
|
|
|
ata_acpi_add_pm_notifier(dev);
|
2013-01-15 09:20:58 +00:00
|
|
|
zpodd->dev = dev;
|
|
|
|
dev->zpodd = zpodd;
|
ata: acpi: rework the ata acpi bind support
Binding ACPI handle to SCSI device has several drawbacks, namely:
1 During ATA device initialization time, ACPI handle will be needed
while SCSI devices are not created yet. So each time ACPI handle is
needed, instead of retrieving the handle by ACPI_HANDLE macro,
a namespace scan is performed to find the handle for the corresponding
ATA device. This is inefficient, and also expose a restriction on
calling path not holding any lock.
2 The binding to SCSI device tree makes code complex, while at the same
time doesn't bring us any benefit. All ACPI handlings are still done
in ATA module, not in SCSI.
Rework the ATA ACPI binding code to bind ACPI handle to ATA transport
devices(ATA port and ATA device). The binding needs to be done only once,
since the ATA transport devices do not go away with hotplug. And due to
this, the flush_work call in hotplug handler for ATA bay is no longer
needed.
Tested on an Intel test platform for binding and runtime power off for
ODD(ZPODD) and hard disk; on an ASUS S400C for binding and normal boot
and S3, where its SATA port node has _SDD and _GTF control methods when
configured as an AHCI controller and its PATA device node has _GTF
control method when configured as an IDE controller. SATA PMP binding
and ATA hotplug is not tested.
Signed-off-by: Aaron Lu <aaron.lu@intel.com>
Tested-by: Dirk Griesbach <spamthis@freenet.de>
Signed-off-by: Tejun Heo <tj@kernel.org>
2013-08-23 02:17:54 +00:00
|
|
|
dev_pm_qos_expose_flags(&dev->tdev, 0);
|
2013-01-15 09:20:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void zpodd_exit(struct ata_device *dev)
|
|
|
|
{
|
2013-01-15 09:20:59 +00:00
|
|
|
ata_acpi_remove_pm_notifier(dev);
|
2013-01-15 09:20:58 +00:00
|
|
|
kfree(dev->zpodd);
|
|
|
|
dev->zpodd = NULL;
|
|
|
|
}
|