25 Jun, 2013

1 commit

  • There are some SATA controllers which have both devices 0 and 1 but this module
    just zeroes out taskfile and sets then ATA_TFLAG_DEVICE (not sure that's needed)
    which could lead to a wrong device being selected just before issuing command.
    Thus we should call ata_tf_init() which sets up the device register value
    properly, like all other users of ata_exec_internal() do...

    Signed-off-by: Sergei Shtylyov
    Signed-off-by: Tejun Heo
    Cc: stable@vger.kernel.org

    Sergei Shtylyov
     

21 Feb, 2013

1 commit

  • Fix a smatch warning caused by an useless pointer check.
    The context parameter (aka. ata_dev) will never be NULL until we remove
    the acpi notification handler, so it is pointless to check it for NULL.

    Reported-by: Dan Carpenter
    Signed-off-by: Aaron Lu
    Signed-off-by: Jeff Garzik

    Aaron Lu
     

26 Jan, 2013

1 commit

  • When the ODD is powered off, any action the user did to the ODD that
    would generate a media event will trigger an ACPI interrupt, so the
    poll for media event is no longer necessary. And the poll will also
    cause a runtime status change, which will stop the ODD from staying in
    powered off state, so the poll should better be stopped.

    But since we don't have access to the gendisk structure in LLDs, here
    comes the disk_events_disable_depth for scsi device. This field is a
    hint set by LLDs to convey information to upper layer drivers. A value
    of 0 means media poll is necessary for the device, while values above 0
    means media poll is not needed and should better be skipped. So we can
    increase its value when we are to power off the ODD in ATA layer and
    decrease its value when the ODD is powered on, effectively silence the
    media events poll.

    Signed-off-by: Aaron Lu
    Signed-off-by: Jeff Garzik

    Aaron Lu
     

22 Jan, 2013

5 commits

  • Expose pm qos flags to user space so that user has a chance to disable
    ZPODD feature, if he/she has a broken platform or devices or simply does
    not like this feature.

    This flag is exposed to user space only for ZPODD devices.

    Due to this flag, it is possible the ODD is ZP ready but we didn't power
    it off. So the zp_ready flag will need to be cleared whenever we found
    the ODD is not in ZP ready state. Previously, once zp_ready is set, the
    ODD will always be powered off and the flag will be cleared in
    post_poweron. But this is no longer the case now.

    Signed-off-by: Aaron Lu
    Signed-off-by: Jeff Garzik

    Aaron Lu
     
  • When ata port is runtime suspended, it will check if the ODD attched to
    it is a zero power(ZP) capable ODD and if the ZP capable ODD is in zero
    power ready state. And if this is not the case, the highest acpi state
    will be limited to ACPI_STATE_D3_HOT to avoid powering off the ODD. And
    if the ODD can be powered off, runtime wake capability needs to be
    enabled and powered_off flag will be set to let resume code knows that
    the ODD was in powered off state.

    And on resume, before it is powered on, if it was powered off during
    suspend, runtime wake capability needs to be disabled. After it is
    recovered, the ODD is considered functional, post power on processing
    like eject tray if the ODD is drawer type is done, and several ZPODD
    related fields will also be reset.

    Signed-off-by: Aaron Lu
    Acked-by: Tejun Heo
    Signed-off-by: Jeff Garzik

    Aaron Lu
     
  • 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
    Signed-off-by: Jeff Garzik

    Aaron Lu
     
  • Since the ata acpi notification code introduced in commit
    3bd46600a7a7e938c54df8cdbac9910668c7dfb0 is solely for ZPODD, and we
    now have a dedicated place for it, move these code there.

    And the ata_acpi_add_pm_notifier code is changed a little bit in that it
    is now invoked when scsi device is not bound with ACPI yet, so the way
    to get the acpi handle is different with the previous version. And the
    ata_acpi_add/remove_pm_notifier is also simplified a little bit in that
    it doesn't check if the acpi_device for the handle exists or not as the
    odd_can_poweroff function already checked that.

    Signed-off-by: Aaron Lu
    Acked-by: Tejun Heo
    Signed-off-by: Jeff Garzik

    Aaron Lu
     
  • The ODD can be enabled for ZPODD if the following three conditions are
    satisfied:
    1 The ODD supports device attention;
    2 The platform can runtime power off the ODD through ACPI;
    3 The ODD is either slot type or drawer type.
    For such ODDs, zpodd_init is called and a new structure is allocated for
    it to store ZPODD related stuffs.

    And the zpodd_dev_enabled function is used to test if ZPODD is currently
    enabled for this ODD.

    A new config CONFIG_SATA_ZPODD is added to selectively build ZPODD code.

    Signed-off-by: Aaron Lu
    Acked-by: Tejun Heo
    Signed-off-by: Jeff Garzik

    Aaron Lu