1. 14 3月, 2019 3 次提交
    • H
      i2c: i2c-designware-platdrv: Always use a dynamic adapter number · cd86d140
      Hans de Goede 提交于
      Before this commit the i2c-designware-platdrv assumes that if the pdev
      has an apci-companion it should use a dynamic adapter-nr and it sets
      adapter->nr to -1, otherwise it will use pdev->id as adapter->nr.
      
      There are 3 ways how platform_device-s to which i2c-designware-platdrv
      will bind can be instantiated:
      
      1) Through of / devicetree
      2) Through ACPI enumeration
      3) Explicitly instantiated through platform_device_create + add
      
      1) In case of devicetree-instantiation the drivers/of code always sets
      pdev->id to PLATFORM_DEVID_NONE, which is -1 so in this case both paths
      to set adapter->nr end up doing the same thing.
      
      2) In case of ACPI instantiation the device will always have an
      ACPI-companion, so we are already using dynamic adapter-nrs.
      
      3) There are 2 places manually instantiating a designware_i2c platform_dev:
      drivers/mfd/intel_quark_i2c_gpio.c
      drivers/mfd/intel-lpss.c
      
      In the intel_quark_i2c_gpio.c case pdev->id is always 0, so switching to
      dynamic adapter-nrs here could lead to the bus-number no longer being
      stable, but the quark X1000 only has 1 i2c-controller, which will also
      be assigned bus-number 0 when using dynamic adapter-nrs.
      
      In the intel-lpss.c case intel_lpss_probe() is called from either
      intel-lpss-acpi.c in which case there always is an ACPI-companion, or
      from intel-lpss-pci.c. In most cases devices handled by intel-lpss-pci.c
      also have an ACPI-companion, so we use a dynamic adapter-nr. But in some
      cases the ACPI-companion is missing and we would use pdev->id (allocated
      from intel_lpss_devid_ida). Devices which use the intel-lpss-pci.c code
      typically have many i2c busses, so using pdev->id in this case may lead
      to a bus-number conflict, triggering a WARN(id < 0, "couldn't get idr")
      in i2c-core-base.c causing an oops an the adapter registration to fail.
      So in this case using non dynamic adapter-nrs is actually undesirable.
      
      One machine on which this oops was triggering is the Apollo Lake based
      Acer TravelMate Spin B118.
      
      TL;DR: Switching to always using dynamic adapter-numbers does not make
      any difference in most cases and in the one case where it does make a
      difference the behavior change is desirable because the old behavior
      caused an oops.
      
      BugLink: https://bugzilla.redhat.com/show_bug.cgi?id=1687065Signed-off-by: NHans de Goede <hdegoede@redhat.com>
      Acked-by: NAndy Shevchenko <andriy.shevchenko@linux.intel.com>
      Acked-by: NJarkko Nikula <jarkko.nikula@linux.intel.com>
      Signed-off-by: NWolfram Sang <wsa@the-dreams.de>
      cd86d140
    • H
      i2c: i2c-designware-platdrv: Cleanup setting of the adapter number · 77f3381a
      Hans de Goede 提交于
      i2c-designware-platdrv assumes that if the pdev has an apci-companion
      it should use a dynamic adapter-nr and otherwise it will use pdev->id
      as adapter-nr.
      
      Before this commit the setting of the adapter.nr was somewhat convoluted,
      in the acpi_companion case it was set from dw_i2c_acpi_configure, in the
      non acpi_companion case it was set from dw_i2c_set_fifo_size based on
      tx_fifo_depth not being set yet indicating that dw_i2c_acpi_configure was
      not executed.
      
      This cleans this up, directly setting the adapter-nr from
      dw_i2c_plat_probe for both cases.
      Signed-off-by: NHans de Goede <hdegoede@redhat.com>
      Reviewed-by: NAndy Shevchenko <andriy.shevchenko@linux.intel.com>
      Acked-by: NJarkko Nikula <jarkko.nikula@linux.intel.com>
      Signed-off-by: NWolfram Sang <wsa@the-dreams.de>
      77f3381a
    • W
      i2c: add extra check to safe DMA buffer helper · bf263c35
      Wolfram Sang 提交于
      Make sure we report 'no buffer' for 0-length messages. This can only
      happen if threshold is set to 0 which is kind of bogus but we should
      still handle this situation. Update the docs and add a debug message
      to educate callers of this function.
      Reported-by: NHsin-Yi Wang <hsinyi@chromium.org>
      Fixes: e94bc5d1 ("i2c: add helpers to ease DMA handling")
      Signed-off-by: NWolfram Sang <wsa+renesas@sang-engineering.com>
      Reviewed-by: NHsin-Yi Wang <hsinyi@chromium.org>
      Signed-off-by: NWolfram Sang <wsa@the-dreams.de>
      bf263c35
  2. 12 3月, 2019 5 次提交
  3. 24 2月, 2019 2 次提交
  4. 23 2月, 2019 6 次提交
    • H
      i2c: designware: Do not allow i2c_dw_xfer() calls while suspended · 27515415
      Hans de Goede 提交于
      On most Intel Bay- and Cherry-Trail systems the PMIC is connected over I2C
      and the PMIC is accessed through various means by the _PS0 and _PS3 ACPI
      methods (power on / off methods) of various devices.
      
      This leads to suspend/resume ordering problems where a device may be
      resumed and get its _PS0 method executed before the I2C controller is
      resumed. On Cherry Trail this leads to errors like these:
      
           i2c_designware 808622C1:06: controller timed out
           ACPI Error: AE_ERROR, Returned by Handler for [UserDefinedRegion]
           ACPI Error: Method parse/execution failed \_SB.P18W._ON, AE_ERROR
           video LNXVIDEO:00: Failed to change power state to D0
      
      But on Bay Trail this caused I2C reads to seem to succeed, but they end
      up returning wrong data, which ends up getting written back by the typical
      read-modify-write cycle done to turn on various power-resources.
      
      Debugging the problems caused by this silent data corruption is quite
      nasty. This commit adds a check which disallows i2c_dw_xfer() calls to
      happen until the controller's resume method has completed.
      
      Which turns the silent data corruption into getting these errors in
      dmesg instead:
      
          i2c_designware 80860F41:04: Error i2c_dw_xfer call while suspended
          ACPI Error: AE_ERROR, Returned by Handler for [UserDefinedRegion]
          ACPI Error: Method parse/execution failed \_SB.PCI0.GFX0._PS0, AE_ERROR
      
      Which is much better.
      
      Note the above errors are an example of issues which this patch will
      help to debug, the actual fix requires fixing the suspend order and
      this has been fixed by a different commit.
      
      Note the setting / clearing of the suspended flag in the suspend / resume
      methods is NOT protected by i2c_lock_bus(). This is intentional as these
      methods get called from i2c_dw_xfer() (through pm_runtime_get/put) a nd
      i2c_dw_xfer() is called with the i2c_bus_lock held, so otherwise we would
      deadlock. This means that there is a theoretical race between a non runtime
      suspend and the suspended check in i2c_dw_xfer(), this is not a problem
      since normally we should not hit the race and this check is primarily a
      debugging tool so hitting the check if there are suspend/resume ordering
      problems does not need to be 100% reliable.
      Signed-off-by: NHans de Goede <hdegoede@redhat.com>
      Reviewed-by: NAndy Shevchenko <andriy.shevchenko@linux.intel.com>
      Signed-off-by: NWolfram Sang <wsa@the-dreams.de>
      27515415
    • J
      i2c: tegra: Only display error messages if DMA setup fails · 89328b1b
      Jonathan Hunter 提交于
      Commit 86c92b99 ("i2c: tegra: Add DMA support") added DMA support
      to the Tegra I2C driver for Tegra devices that support the APB DMA
      controller. One side-effect of this change is that even for Tegra
      devices that do not have an APB DMA controller and hence, cannot
      support DMA tranfers for I2C transactions, the following error messages
      are still displayed ...
      
       ERR KERN tegra-i2c 31c0000.i2c: cannot use DMA: -19
       ERR KERN tegra-i2c 31c0000.i2c: falling back to PIO
      
      There is no point displaying the above messages for devices that do not
      have an APB DMA controller and so fix this by returning from the
      tegra_i2c_init_dma() function if 'has_apb_dma' is not true.
      
      Furthermore, if CONFIG_TEGRA20_APB_DMA is not set, then rather than
      printing an error message, print an debug message as for whatever reason
      this could be intentional.
      
      Fixes: 86c92b99 ("i2c: tegra: Add DMA support")
      Signed-off-by: NJonathan Hunter <jonathanh@nvidia.com>
      Reviewed-by: NDmitry Osipenko <digetx@gmail.com>
      Acked-by: NThierry Reding <treding@nvidia.com>
      Signed-off-by: NWolfram Sang <wsa@the-dreams.de>
      89328b1b
    • W
      i2c: gpio: fault-injector: add 'inject_panic' injector · bb6bdd51
      Wolfram Sang 提交于
      Add a fault injector simulating a Kernel panic happening after starting
      a transfer. Read the docs for its usage.
      Signed-off-by: NWolfram Sang <wsa+renesas@sang-engineering.com>
      Signed-off-by: NWolfram Sang <wsa@the-dreams.de>
      bb6bdd51
    • W
      i2c: gpio: fault-injector: add 'lose_arbitration' injector · 63e57b6f
      Wolfram Sang 提交于
      Add a fault injector simulating 'arbitration lost' from multi-master
      setups. Read the docs for its usage.
      
      A helper function for future fault injectors using SCL interrupts is
      created to achieve this.
      Signed-off-by: NWolfram Sang <wsa+renesas@sang-engineering.com>
      Signed-off-by: NWolfram Sang <wsa@the-dreams.de>
      63e57b6f
    • S
      i2c: tegra: remove multi-master support · 6b9932bc
      Sowjanya Komatineni 提交于
      Multi-master support is defeatured on Tegra210 and Tegra186 due to
      known bugs.
      
      This patch removes multi-master support for Tegra210 and Tegra186
      I2C HW feature.
      Acked-by: NThierry Reding <treding@nvidia.com>
      Signed-off-by: NSowjanya Komatineni <skomatineni@nvidia.com>
      Signed-off-by: NWolfram Sang <wsa@the-dreams.de>
      6b9932bc
    • S
      i2c: tegra: remove master fifo support on tegra186 · 9ffc125c
      Sowjanya Komatineni 提交于
      Tegra186 does not have master FIFO  control register and instead
      uses FIFO control register like prior Tegra chipset.
      
      This patch fixes this and prevents crashing during boot when
      accessing FIFO control registers.
      Acked-by: NThierry Reding <treding@nvidia.com>
      Signed-off-by: NSowjanya Komatineni <skomatineni@nvidia.com>
      Signed-off-by: NWolfram Sang <wsa@the-dreams.de>
      9ffc125c
  5. 16 2月, 2019 1 次提交
  6. 15 2月, 2019 19 次提交
  7. 09 2月, 2019 4 次提交