1. 20 8月, 2017 1 次提交
    • S
      iio: hid-sensor-trigger: Fix the race with user space powering up sensors · f1664eaa
      Srinivas Pandruvada 提交于
      It has been reported for a while that with iio-sensor-proxy service the
      rotation only works after one suspend/resume cycle. This required a wait
      in the systemd unit file to avoid race. I found a Yoga 900 where I could
      reproduce this.
      
      The problem scenerio is:
      - During sensor driver init, enable run time PM and also set a
        auto-suspend for 3 seconds.
      	This result in one runtime resume. But there is a check to avoid
      a powerup in this sequence, but rpm is active
      - User space iio-sensor-proxy tries to power up the sensor. Since rpm is
        active it will simply return. But sensors were not actually
      powered up in the prior sequence, so actaully the sensors will not work
      - After 3 seconds the auto suspend kicks
      
      If we add a wait in systemd service file to fire iio-sensor-proxy after
      3 seconds, then now everything will work as the runtime resume will
      actually powerup the sensor as this is a user request.
      
      To avoid this:
      - Remove the check to match user requested state, this will cause a
        brief powerup, but if the iio-sensor-proxy starts immediately it will
      still work as the sensors are ON.
      - Also move the autosuspend delay to place when user requested turn off
        of sensors, like after user finished raw read or buffer disable
      Signed-off-by: NSrinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
      Tested-by: NBastien Nocera <hadess@hadess.net>
      Cc: <Stable@vger.kernel.org>
      Signed-off-by: NJonathan Cameron <Jonathan.Cameron@huawei.com>
      f1664eaa
  2. 17 5月, 2017 1 次提交
    • S
      iio: hid-sensor-hub: Implement batch mode · 138bc796
      Srinivas Pandruvada 提交于
      HID sensor hubs using Integrated Senor Hub (ISH) has added capability to
      support batch mode. This allows host processor to go to sleep for extended
      duration, while the sensor hub is storing samples in its internal buffers.
      
      'Commit f4f4673b ("iio: add support for hardware fifo")' implements
      feature in IIO core to implement such feature. This feature is used in
      bmc150-accel-core.c to implement batch mode. This implementation allows
      software device buffer watermark to be used as a hint to adjust hardware
      FIFO.
      
      But HID sensor hubs don't allow to change internal buffer size of FIFOs.
      Instead an additional usage id to set "maximum report latency" is defined.
      This allows host to go to sleep upto this latency period without getting
      any report. Since there is no ABI to set this latency, a new attribute
      "hwfifo_timeout" is added so that user mode can specify a latency.
      
      This change checks presence of usage id to get/set maximum report latency
      and if present, it will expose hwfifo_timeout.
      Signed-off-by: NSrinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
      Signed-off-by: NJonathan Cameron <jic23@kernel.org>
      138bc796
  3. 08 4月, 2017 2 次提交
  4. 05 3月, 2017 1 次提交
    • S
      iio: hid-sensor-trigger: Change get poll value function order to avoid sensor... · 3bec2474
      Song Hongyan 提交于
      iio: hid-sensor-trigger: Change get poll value function order to avoid sensor properties losing after resume from S3
      
      In function _hid_sensor_power_state(), when hid_sensor_read_poll_value()
      is called, sensor's all properties will be updated by the value from
      sensor hardware/firmware.
      In some implementation, sensor hardware/firmware will do a power cycle
      during S3. In this case, after resume, once hid_sensor_read_poll_value()
      is called, sensor's all properties which are kept by driver during S3
      will be changed to default value.
      But instead, if a set feature function is called first, sensor
      hardware/firmware will be recovered to the last status. So change the
      sensor_hub_set_feature() calling order to behind of set feature function
      to avoid sensor properties lose.
      Signed-off-by: NSong Hongyan <hongyan.song@intel.com>
      Acked-by: NSrinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
      Cc: <Stable@vger.kernel.org>
      Signed-off-by: NJonathan Cameron <jic23@kernel.org>
      3bec2474
  5. 30 8月, 2016 1 次提交
    • A
      iio: hid-sensors: avoid unused function warning · 2e1f44d8
      Arnd Bergmann 提交于
      A small rework of the PM code in this driver introduced a harmless
      warning when CONFIG_PM_SLEEP is not set:
      
      drivers/iio/common/hid-sensors/hid-sensor-trigger.c:212:12: error: 'hid_sensor_resume' defined but not used [-Werror=unused-function]
      
      This removes the #ifdef and instead marks all three PM functions
      as __maybe_unused, which covers all possible cases and is harder
      to get wrong.
      Signed-off-by: NArnd Bergmann <arnd@arndb.de>
      Fixes: 7f6cf741 ("iio: hid-sensors: use asynchronous resume")
      Signed-off-by: NJonathan Cameron <jic23@kernel.org>
      2e1f44d8
  6. 22 8月, 2016 1 次提交
  7. 16 4月, 2016 1 次提交
  8. 19 7月, 2015 1 次提交
    • S
      hid-sensor: Fix suspend/resume delay · 88cc7b4e
      Srinivas Pandruvada 提交于
      By default all the sensors are runtime suspended state (lowest power
      state). During Linux suspend process, all the run time suspended
      devices are resumed and then suspended. This caused all sensors to
      power up and introduced delay in suspend time, when we introduced
      runtime PM for HID sensors. The opposite process happens during resume
      process.
      
      To fix this, we do powerup process of the sensors only when the request
      is issued from user (raw or tiggerred). In this way when runtime,
      resume calls for powerup it will simply return as this will not match
      user requested state.
      
      Note this is a regression fix as the increase in suspend / resume
      times can be substantial (report of 8 seconds on Len's laptop!)
      Signed-off-by: NSrinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
      Tested-by: NLen Brown <len.brown@intel.com>
      Cc: <Stable@vger.kernel.org>
      Signed-off-by: NJonathan Cameron <jic23@kernel.org>
      88cc7b4e
  9. 03 6月, 2015 1 次提交
    • S
      hid-sensor: Fix suspend/resume delay · 1e25aa96
      Srinivas Pandruvada 提交于
      By default all the sensors are runtime suspended state (lowest power
      state). During Linux suspend process, all the run time suspended
      devices are resumed and then suspended. This caused all sensors to
      power up and introduced delay in suspend time, when we introduced
      runtime PM for HID sensors. The opposite process happens during resume
      process.
      
      To fix this, we do powerup process of the sensors only when the request
      is issued from user (raw or tiggerred). In this way when runtime,
      resume calls for powerup it will simply return as this will not match
      user requested state.
      
      Note this is a regression fix as the increase in suspend / resume
      times can be substantial (report of 8 seconds on Len's laptop!)
      Signed-off-by: NSrinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
      Tested-by: NLen Brown <len.brown@intel.com>
      Cc: <Stable@vger.kernel.org>
      Signed-off-by: NJonathan Cameron <jic23@kernel.org>
      1e25aa96
  10. 23 2月, 2015 2 次提交
  11. 26 1月, 2015 1 次提交
  12. 26 8月, 2014 1 次提交
  13. 30 5月, 2014 1 次提交
  14. 05 5月, 2014 1 次提交
  15. 17 2月, 2014 1 次提交
  16. 03 12月, 2013 1 次提交
    • S
      iio: hid-sensors: Fix power and report state · 751d17e2
      Srinivas Pandruvada 提交于
      In the original HID sensor hub firmwares all Named array enums were
      to 0-based. But the most recent hub implemented as 1-based,
      because of the implementation by one of the major OS vendor.
      Using logical minimum for the field as the base of enum. So we add
      logical minimum to the selector values before setting those fields.
      Some sensor hub FWs already changed logical minimum from 0 to 1
      to reflect this and hope every other vendor will follow.
      There is no easy way to add a common HID quirk for NAry elements,
      even if the standard specifies these field as NAry, the collection
      used to describe selectors is still just "logical".
      Signed-off-by: NSrinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
      Signed-off-by: NJonathan Cameron <jic23@kernel.org>
      751d17e2
  17. 03 11月, 2013 1 次提交
  18. 01 10月, 2013 1 次提交
  19. 26 3月, 2013 1 次提交
    • L
      iio:trigger: Introduce iio_tigger_{set,get}_drvdata · 1e9663c6
      Lars-Peter Clausen 提交于
      Introduce iio_tigger_{set,get}_drvdata which allows to attach driver specific
      data to a trigger. The functions wrap access to the triggers private_data field
      and all current users are updated to use iio_tigger_{set,get}_drvdata instead of
      directly accessing the private_data field. This is the first step towards
      removing the private_data field from the iio_trigger struct.
      
      The following coccinelle script has been used to update the drivers:
      <smpl>
      @@
      struct iio_trigger *trigger;
      expression priv;
      @@
      -trigger->private_data = priv
      +iio_trigger_set_drv_data(trigger, priv)
      
      @@
      struct iio_trigger *trigger;
      @@
      -trigger->private_data
      +iio_trigger_get_drv_data(trigger)
      </smpl>
      Signed-off-by: NLars-Peter Clausen <lars@metafoo.de>
      Signed-off-by: NJonathan Cameron <jic23@kernel.org>
      1e9663c6
  20. 06 1月, 2013 2 次提交
  21. 17 11月, 2012 1 次提交
  22. 22 9月, 2012 1 次提交
    • S
      iio: hid-sensors: Prevent crash during hot-unplug · f07b60b7
      Srinivas Pandruvada 提交于
      When hid sensor hub is unplugged, there is a crash in
      iio_device_unregister_trigger_consumer.
      In a typical IIO driver when remove is called, it will unregister and free
      trigger and then it will call iio_device_free.
      The function iio_trigger_free() will free the allocated memory for trigger.
      If this trigger was assigned to iio_dev->trig, then it should be set to NULL.
      Othewise when iio_device_free() is called later, it finally calls
      iio_device_unregsister_trigger(), which checks for
             if (indio_dev->trig)
                      iio_trigger_put(indio_dev->trig);
      If indio_dev->trig is not set to NULL, it calls iio_trigger_put on a bad
      pointer causing crash.
      This scenerio can happen in any driver, which is storing trigger pointer in
      iio_dev structure and following current procedure during remove.
      Signed-off-by: NSrinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
      Signed-off-by: NJonathan Cameron <jic23@kernel.org>
      f07b60b7
  23. 07 9月, 2012 1 次提交