]> rtime.felk.cvut.cz Git - linux-imx.git/commitdiff
Merge branch 'pm-assorted'
authorRafael J. Wysocki <rafael.j.wysocki@intel.com>
Fri, 28 Jun 2013 11:01:40 +0000 (13:01 +0200)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Fri, 28 Jun 2013 11:01:40 +0000 (13:01 +0200)
* pm-assorted:
  PM / QoS: Add pm_qos and dev_pm_qos to events-power.txt
  PM / QoS: Add dev_pm_qos_request tracepoints
  PM / QoS: Add pm_qos_request tracepoints
  PM / QoS: Add pm_qos_update_target/flags tracepoints
  PM / QoS: Update Documentation/power/pm_qos_interface.txt
  PM / Sleep: Print last wakeup source on failed wakeup_count write
  PM / QoS: correct the valid range of pm_qos_class
  PM / wakeup: Adjust messaging for wake events during suspend
  PM / Runtime: Update .runtime_idle() callback documentation
  PM / Runtime: Rework the "runtime idle" helper routine
  PM / Hibernate: print physical addresses consistently with other parts of kernel

1  2 
drivers/acpi/device_pm.c
drivers/ata/libata-core.c

diff --combined drivers/acpi/device_pm.c
index 5f3597b87f276dc9744090674c0bce0bde9360fc,1eb8b6258786e7972f7c57dbb26f4323e288bb94..67624d4d5aefc84d3a15b998a6e52ccc3608f0e6
@@@ -278,38 -278,16 +278,38 @@@ int acpi_bus_init_power(struct acpi_dev
                if (result)
                        return result;
        } else if (state == ACPI_STATE_UNKNOWN) {
 -              /* No power resources and missing _PSC? Try to force D0. */
 +              /*
 +               * No power resources and missing _PSC?  Cross fingers and make
 +               * it D0 in hope that this is what the BIOS put the device into.
 +               * [We tried to force D0 here by executing _PS0, but that broke
 +               * Toshiba P870-303 in a nasty way.]
 +               */
                state = ACPI_STATE_D0;
 -              result = acpi_dev_pm_explicit_set(device, state);
 -              if (result)
 -                      return result;
        }
        device->power.state = state;
        return 0;
  }
  
 +/**
 + * acpi_device_fix_up_power - Force device with missing _PSC into D0.
 + * @device: Device object whose power state is to be fixed up.
 + *
 + * Devices without power resources and _PSC, but having _PS0 and _PS3 defined,
 + * are assumed to be put into D0 by the BIOS.  However, in some cases that may
 + * not be the case and this function should be used then.
 + */
 +int acpi_device_fix_up_power(struct acpi_device *device)
 +{
 +      int ret = 0;
 +
 +      if (!device->power.flags.power_resources
 +          && !device->power.flags.explicit_get
 +          && device->power.state == ACPI_STATE_D0)
 +              ret = acpi_dev_pm_explicit_set(device, ACPI_STATE_D0);
 +
 +      return ret;
 +}
 +
  int acpi_bus_update_power(acpi_handle handle, int *state_p)
  {
        struct acpi_device *device;
@@@ -419,73 -397,62 +419,73 @@@ bool acpi_bus_can_wakeup(acpi_handle ha
  EXPORT_SYMBOL(acpi_bus_can_wakeup);
  
  /**
 - * acpi_device_power_state - Get preferred power state of ACPI device.
 + * acpi_dev_pm_get_state - Get preferred power state of ACPI device.
   * @dev: Device whose preferred target power state to return.
   * @adev: ACPI device node corresponding to @dev.
   * @target_state: System state to match the resultant device state.
 - * @d_max_in: Deepest low-power state to take into consideration.
 - * @d_min_p: Location to store the upper limit of the allowed states range.
 - * Return value: Preferred power state of the device on success, -ENODEV
 - * (if there's no 'struct acpi_device' for @dev) or -EINVAL on failure
 + * @d_min_p: Location to store the highest power state available to the device.
 + * @d_max_p: Location to store the lowest power state available to the device.
   *
 - * Find the lowest power (highest number) ACPI device power state that the
 - * device can be in while the system is in the state represented by
 - * @target_state.  If @d_min_p is set, the highest power (lowest number) device
 - * power state that @dev can be in for the given system sleep state is stored
 - * at the location pointed to by it.
 + * Find the lowest power (highest number) and highest power (lowest number) ACPI
 + * device power states that the device can be in while the system is in the
 + * state represented by @target_state.  Store the integer numbers representing
 + * those stats in the memory locations pointed to by @d_max_p and @d_min_p,
 + * respectively.
   *
   * Callers must ensure that @dev and @adev are valid pointers and that @adev
   * actually corresponds to @dev before using this function.
 + *
 + * Returns 0 on success or -ENODATA when one of the ACPI methods fails or
 + * returns a value that doesn't make sense.  The memory locations pointed to by
 + * @d_max_p and @d_min_p are only modified on success.
   */
 -int acpi_device_power_state(struct device *dev, struct acpi_device *adev,
 -                          u32 target_state, int d_max_in, int *d_min_p)
 +static int acpi_dev_pm_get_state(struct device *dev, struct acpi_device *adev,
 +                               u32 target_state, int *d_min_p, int *d_max_p)
  {
 -      char acpi_method[] = "_SxD";
 -      unsigned long long d_min, d_max;
 +      char method[] = { '_', 'S', '0' + target_state, 'D', '\0' };
 +      acpi_handle handle = adev->handle;
 +      unsigned long long ret;
 +      int d_min, d_max;
        bool wakeup = false;
 +      acpi_status status;
  
 -      if (d_max_in < ACPI_STATE_D0 || d_max_in > ACPI_STATE_D3)
 -              return -EINVAL;
 -
 -      if (d_max_in > ACPI_STATE_D3_HOT) {
 -              enum pm_qos_flags_status stat;
 -
 -              stat = dev_pm_qos_flags(dev, PM_QOS_FLAG_NO_POWER_OFF);
 -              if (stat == PM_QOS_FLAGS_ALL)
 -                      d_max_in = ACPI_STATE_D3_HOT;
 -      }
 -
 -      acpi_method[2] = '0' + target_state;
        /*
 -       * If the sleep state is S0, the lowest limit from ACPI is D3,
 -       * but if the device has _S0W, we will use the value from _S0W
 -       * as the lowest limit from ACPI.  Finally, we will constrain
 -       * the lowest limit with the specified one.
 +       * If the system state is S0, the lowest power state the device can be
 +       * in is D3cold, unless the device has _S0W and is supposed to signal
 +       * wakeup, in which case the return value of _S0W has to be used as the
 +       * lowest power state available to the device.
         */
        d_min = ACPI_STATE_D0;
 -      d_max = ACPI_STATE_D3;
 +      d_max = ACPI_STATE_D3_COLD;
  
        /*
         * If present, _SxD methods return the minimum D-state (highest power
         * state) we can use for the corresponding S-states.  Otherwise, the
         * minimum D-state is D0 (ACPI 3.x).
 -       *
 -       * NOTE: We rely on acpi_evaluate_integer() not clobbering the integer
 -       * provided -- that's our fault recovery, we ignore retval.
         */
        if (target_state > ACPI_STATE_S0) {
 -              acpi_evaluate_integer(adev->handle, acpi_method, NULL, &d_min);
 +              /*
 +               * We rely on acpi_evaluate_integer() not clobbering the integer
 +               * provided if AE_NOT_FOUND is returned.
 +               */
 +              ret = d_min;
 +              status = acpi_evaluate_integer(handle, method, NULL, &ret);
 +              if ((ACPI_FAILURE(status) && status != AE_NOT_FOUND)
 +                  || ret > ACPI_STATE_D3_COLD)
 +                      return -ENODATA;
 +
 +              /*
 +               * We need to handle legacy systems where D3hot and D3cold are
 +               * the same and 3 is returned in both cases, so fall back to
 +               * D3cold if D3hot is not a valid state.
 +               */
 +              if (!adev->power.states[ret].flags.valid) {
 +                      if (ret == ACPI_STATE_D3_HOT)
 +                              ret = ACPI_STATE_D3_COLD;
 +                      else
 +                              return -ENODATA;
 +              }
 +              d_min = ret;
                wakeup = device_may_wakeup(dev) && adev->wakeup.flags.valid
                        && adev->wakeup.sleep_state >= target_state;
        } else if (dev_pm_qos_flags(dev, PM_QOS_FLAG_REMOTE_WAKEUP) !=
         * can wake the system.  _S0W may be valid, too.
         */
        if (wakeup) {
 -              acpi_status status;
 -
 -              acpi_method[3] = 'W';
 -              status = acpi_evaluate_integer(adev->handle, acpi_method, NULL,
 -                                              &d_max);
 -              if (ACPI_FAILURE(status)) {
 -                      if (target_state != ACPI_STATE_S0 ||
 -                          status != AE_NOT_FOUND)
 +              method[3] = 'W';
 +              status = acpi_evaluate_integer(handle, method, NULL, &ret);
 +              if (status == AE_NOT_FOUND) {
 +                      if (target_state > ACPI_STATE_S0)
                                d_max = d_min;
 -              } else if (d_max < d_min) {
 -                      /* Warn the user of the broken DSDT */
 -                      printk(KERN_WARNING "ACPI: Wrong value from %s\n",
 -                              acpi_method);
 -                      /* Sanitize it */
 -                      d_min = d_max;
 +              } else if (ACPI_SUCCESS(status) && ret <= ACPI_STATE_D3_COLD) {
 +                      /* Fall back to D3cold if ret is not a valid state. */
 +                      if (!adev->power.states[ret].flags.valid)
 +                              ret = ACPI_STATE_D3_COLD;
 +
 +                      d_max = ret > d_min ? ret : d_min;
 +              } else {
 +                      return -ENODATA;
                }
        }
  
 -      if (d_max_in < d_min)
 -              return -EINVAL;
        if (d_min_p)
                *d_min_p = d_min;
 -      /* constrain d_max with specified lowest limit (max number) */
 -      if (d_max > d_max_in) {
 -              for (d_max = d_max_in; d_max > d_min; d_max--) {
 -                      if (adev->power.states[d_max].flags.valid)
 -                              break;
 -              }
 -      }
 -      return d_max;
 +
 +      if (d_max_p)
 +              *d_max_p = d_max;
 +
 +      return 0;
  }
 -EXPORT_SYMBOL_GPL(acpi_device_power_state);
  
  /**
   * acpi_pm_device_sleep_state - Get preferred power state of ACPI device.
   * @d_min_p: Location to store the upper limit of the allowed states range.
   * @d_max_in: Deepest low-power state to take into consideration.
   * Return value: Preferred power state of the device on success, -ENODEV
 - * (if there's no 'struct acpi_device' for @dev) or -EINVAL on failure
 + * if there's no 'struct acpi_device' for @dev, -EINVAL if @d_max_in is
 + * incorrect, or -ENODATA on ACPI method failure.
   *
   * The caller must ensure that @dev is valid before using this function.
   */
@@@ -541,39 -515,14 +541,39 @@@ int acpi_pm_device_sleep_state(struct d
  {
        acpi_handle handle = DEVICE_ACPI_HANDLE(dev);
        struct acpi_device *adev;
 +      int ret, d_max;
 +
 +      if (d_max_in < ACPI_STATE_D0 || d_max_in > ACPI_STATE_D3_COLD)
 +              return -EINVAL;
 +
 +      if (d_max_in > ACPI_STATE_D3_HOT) {
 +              enum pm_qos_flags_status stat;
 +
 +              stat = dev_pm_qos_flags(dev, PM_QOS_FLAG_NO_POWER_OFF);
 +              if (stat == PM_QOS_FLAGS_ALL)
 +                      d_max_in = ACPI_STATE_D3_HOT;
 +      }
  
        if (!handle || acpi_bus_get_device(handle, &adev)) {
                dev_dbg(dev, "ACPI handle without context in %s!\n", __func__);
                return -ENODEV;
        }
  
 -      return acpi_device_power_state(dev, adev, acpi_target_system_state(),
 -                                     d_max_in, d_min_p);
 +      ret = acpi_dev_pm_get_state(dev, adev, acpi_target_system_state(),
 +                                  d_min_p, &d_max);
 +      if (ret)
 +              return ret;
 +
 +      if (d_max_in < *d_min_p)
 +              return -EINVAL;
 +
 +      if (d_max > d_max_in) {
 +              for (d_max = d_max_in; d_max > *d_min_p; d_max--) {
 +                      if (adev->power.states[d_max].flags.valid)
 +                              break;
 +              }
 +      }
 +      return d_max;
  }
  EXPORT_SYMBOL(acpi_pm_device_sleep_state);
  
@@@ -724,13 -673,17 +724,13 @@@ struct acpi_device *acpi_dev_pm_get_nod
  static int acpi_dev_pm_low_power(struct device *dev, struct acpi_device *adev,
                                 u32 system_state)
  {
 -      int power_state;
 +      int ret, state;
  
        if (!acpi_device_power_manageable(adev))
                return 0;
  
 -      power_state = acpi_device_power_state(dev, adev, system_state,
 -                                            ACPI_STATE_D3, NULL);
 -      if (power_state < ACPI_STATE_D0 || power_state > ACPI_STATE_D3)
 -              return -EIO;
 -
 -      return acpi_device_set_power(adev, power_state);
 +      ret = acpi_dev_pm_get_state(dev, adev, system_state, NULL, &state);
 +      return ret ? ret : acpi_device_set_power(adev, state);
  }
  
  /**
@@@ -933,7 -886,6 +933,6 @@@ static struct dev_pm_domain acpi_genera
  #ifdef CONFIG_PM_RUNTIME
                .runtime_suspend = acpi_subsys_runtime_suspend,
                .runtime_resume = acpi_subsys_runtime_resume,
-               .runtime_idle = pm_generic_runtime_idle,
  #endif
  #ifdef CONFIG_PM_SLEEP
                .prepare = acpi_subsys_prepare,
index adf002a3c584b3d2bd7fb27357df040a381f3b82,84e3b62aa36890b77ff61d1148960a26645649cc..6e458a40a93bd36d03378af8aa54ac3df23f4183
@@@ -1,7 -1,7 +1,7 @@@
  /*
   *  libata-core.c - helper library for ATA
   *
 - *  Maintained by:  Jeff Garzik <jgarzik@pobox.com>
 + *  Maintained by:  Tejun Heo <tj@kernel.org>
   *                        Please ALWAYS copy linux-ide@vger.kernel.org
   *                on emails.
   *
@@@ -1602,12 -1602,6 +1602,12 @@@ unsigned ata_exec_internal_sg(struct at
        qc->tf = *tf;
        if (cdb)
                memcpy(qc->cdb, cdb, ATAPI_CDB_LEN);
 +
 +      /* some SATA bridges need us to indicate data xfer direction */
 +      if (tf->protocol == ATAPI_PROT_DMA && (dev->flags & ATA_DFLAG_DMADIR) &&
 +          dma_dir == DMA_FROM_DEVICE)
 +              qc->tf.feature |= ATAPI_DMADIR;
 +
        qc->flags |= ATA_QCFLAG_RESULT_TF;
        qc->dma_dir = dma_dir;
        if (dma_dir != DMA_NONE) {
@@@ -5436,7 -5430,7 +5436,7 @@@ static int ata_port_runtime_idle(struc
                                return -EBUSY;
        }
  
-       return pm_runtime_suspend(dev);
+       return 0;
  }
  
  static int ata_port_runtime_suspend(struct device *dev)
@@@ -6148,8 -6142,6 +6148,8 @@@ int ata_host_register(struct ata_host *
        if (rc)
                goto err_tadd;
  
 +      ata_acpi_hotplug_init(host);
 +
        /* set cable, sata_spd_limit and report */
        for (i = 0; i < host->n_ports; i++) {
                struct ata_port *ap = host->ports[i];