1. 17 4月, 2017 3 次提交
    • H
      i2c: core: Allow drivers to disable i2c-core irq mapping · d1d84bb9
      Hans de Goede 提交于
      By default the i2c-core will try to get an irq with index 0 on ACPI / of
      instantiated devices. This is troublesome on some ACPI systems where the
      irq info at index 0 in the CRS table may contain nonsense and/or point
      to an irqchip for which there is no Linux driver.
      
      If this happens then before this commit the driver's probe method would
      never get called because i2c_device_probe will try to get an irq by
      calling acpi_dev_gpio_irq_get which will always return -EPROBE in this
      case, as it waits for a matching irqchip driver to load. Thus causing
      the driver to not get a chance to bind.
      
      This commit adds a new disable_i2c_core_irq_mapping flag to struct
      i2c_driver which a driver can set to tell the core to skip irq mapping.
      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>
      d1d84bb9
    • H
      i2c: core: Add new i2c_acpi_new_device helper function · 605f8fc2
      Hans de Goede 提交于
      By default the i2c subsys creates an i2c-client for the first I2cSerialBus
      resource of an acpi_device, but some acpi_devices have multiple
      I2cSerialBus resources and we may want to instantiate i2c-clients for
      the others.
      
      This commit adds a new i2c_acpi_new_device function which can be used to
      create an i2c-client for any I2cSerialBus resource of an acpi_device.
      
      Note that the other resources may even be on a different i2c bus, so just
      retrieving the client address is not enough.
      
      Here is an example DSDT excerpt from such a device:
      
      Device (WIDR)
      {
          Name (_HID, "INT33FE" /* XPOWER Battery Device */)
          Name (_CID, "INT33FE" /* XPOWER Battery Device */)
          Name (_DDN, "WC PMIC Battery Device")
      <snip>
          Name (RBUF, ResourceTemplate ()
          {
              I2cSerialBusV2 (0x005E, ControllerInitiated, 0x000186A0,
                  AddressingMode7Bit, "\\_SB.PCI0.I2C7",
                  0x00, ResourceConsumer, , Exclusive,
                  )
              I2cSerialBusV2 (0x0036, ControllerInitiated, 0x000186A0,
                  AddressingMode7Bit, "\\_SB.PCI0.I2C1",
                  0x00, ResourceConsumer, , Exclusive,
                  )
              I2cSerialBusV2 (0x0022, ControllerInitiated, 0x00061A80,
                  AddressingMode7Bit, "\\_SB.PCI0.I2C1",
                  0x00, ResourceConsumer, , Exclusive,
                  )
              I2cSerialBusV2 (0x0054, ControllerInitiated, 0x00061A80,
                  AddressingMode7Bit, "\\_SB.PCI0.I2C1",
                  0x00, ResourceConsumer, , Exclusive,
                  )
              GpioInt (Level, ActiveLow, Exclusive, PullNone, 0x0000,
                  "\\_SB.PCI0.I2C7.PMI5", 0x00, ResourceConsumer, ,
                  )
                  {   // Pin list
              0x0012
                  }
              GpioInt (Edge, ActiveLow, ExclusiveAndWake, PullNone, 0x0000,
                  "\\_SB.GPO1", 0x00, ResourceConsumer, ,
                  )
                  {   // Pin list
              0x0005
                  }
              GpioInt (Level, ActiveLow, Exclusive, PullNone, 0x0000,
                  "\\_SB.PCI0.I2C7.PMI5", 0x00, ResourceConsumer, ,
                  )
                  {   // Pin list
              0x0013
                  }
          })
          Method (_CRS, 0, NotSerialized)  // _CRS: Current Resource Settings
          {
              Return (RBUF) /* \_SB_.PCI0.I2C7.WIDR.RBUF */
          }
      <snip>
      }
      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>
      605f8fc2
    • H
      i2c: core: Allow getting ACPI info by index · 417f7843
      Hans de Goede 提交于
      Modify struct i2c_acpi_lookup and i2c_acpi_fill_info() to allow
      using them to get the info from a certain index in the ACPI-resource
      list rather then taking the first I2cSerialBus resource.
      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>
      417f7843
  2. 08 2月, 2017 1 次提交
  3. 07 2月, 2017 1 次提交
  4. 29 1月, 2017 1 次提交
  5. 13 1月, 2017 3 次提交
  6. 25 12月, 2016 1 次提交
  7. 09 12月, 2016 1 次提交
    • S
      tracing: Have the reg function allow to fail · 8cf868af
      Steven Rostedt (Red Hat) 提交于
      Some tracepoints have a registration function that gets enabled when the
      tracepoint is enabled. There may be cases that the registraction function
      must fail (for example, can't allocate enough memory). In this case, the
      tracepoint should also fail to register, otherwise the user would not know
      why the tracepoint is not working.
      
      Cc: David Howells <dhowells@redhat.com>
      Cc: Seiji Aguchi <seiji.aguchi@hds.com>
      Cc: Anton Blanchard <anton@samba.org>
      Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
      Signed-off-by: NSteven Rostedt <rostedt@goodmis.org>
      8cf868af
  8. 24 11月, 2016 1 次提交
    • B
      i2c: use an IRQ to report Host Notify events, not alert · 4d5538f5
      Benjamin Tissoires 提交于
      The current SMBus Host Notify implementation relies on .alert() to
      relay its notifications. However, the use cases where SMBus Host
      Notify is needed currently is to signal data ready on touchpads.
      
      This is closer to an IRQ than a custom API through .alert().
      Given that the 2 touchpad manufacturers (Synaptics and Elan) that
      use SMBus Host Notify don't put any data in the SMBus payload, the
      concept actually matches one to one.
      
      Benefits are multiple:
      - simpler code and API: the client will just have an IRQ, and
        nothing needs to be added in the adapter beside internally
        enabling it.
      - no more specific workqueue, the threading is handled by IRQ core
        directly (when required)
      - no more races when removing the device (the drivers are already
        required to disable irq on remove)
      - simpler handling for drivers: use plain regular IRQs
      - no more dependency on i2c-smbus for i2c-i801 (and any other adapter)
      - the IRQ domain is created automatically when the adapter exports
        the Host Notify capability
      - the IRQ are assign only if ACPI, OF and the caller did not assign
        one already
      - the domain is automatically destroyed on remove
      - fewer lines of code (minus 20, yeah!)
      Signed-off-by: NBenjamin Tissoires <benjamin.tissoires@redhat.com>
      Signed-off-by: NWolfram Sang <wsa@the-dreams.de>
      4d5538f5
  9. 17 11月, 2016 5 次提交
  10. 14 11月, 2016 1 次提交
  11. 05 11月, 2016 1 次提交
    • V
      i2c: core: fix NULL pointer dereference under race condition · 147b36d5
      Vladimir Zapolskiy 提交于
      Race condition between registering an I2C device driver and
      deregistering an I2C adapter device which is assumed to manage that
      I2C device may lead to a NULL pointer dereference due to the
      uninitialized list head of driver clients.
      
      The root cause of the issue is that the I2C bus may know about the
      registered device driver and thus it is matched by bus_for_each_drv(),
      but the list of clients is not initialized and commonly it is NULL,
      because I2C device drivers define struct i2c_driver as static and
      clients field is expected to be initialized by I2C core:
      
        i2c_register_driver()             i2c_del_adapter()
          driver_register()                 ...
            bus_add_driver()                ...
              ...                           bus_for_each_drv(..., __process_removed_adapter)
            ...                               i2c_do_del_adapter()
          ...                                   list_for_each_entry_safe(..., &driver->clients, ...)
          INIT_LIST_HEAD(&driver->clients);
      
      To solve the problem it is sufficient to do clients list head
      initialization before calling driver_register().
      
      The problem was found while using an I2C device driver with a sluggish
      registration routine on a bus provided by a physically detachable I2C
      master controller, but practically the oops may be reproduced under
      the race between arbitraty I2C device driver registration and managing
      I2C bus device removal e.g. by unbinding the latter over sysfs:
      
      % echo 21a4000.i2c > /sys/bus/platform/drivers/imx-i2c/unbind
        Unable to handle kernel NULL pointer dereference at virtual address 00000000
        Internal error: Oops: 17 [#1] SMP ARM
        CPU: 2 PID: 533 Comm: sh Not tainted 4.9.0-rc3+ #61
        Hardware name: Freescale i.MX6 Quad/DualLite (Device Tree)
        task: e5ada400 task.stack: e4936000
        PC is at i2c_do_del_adapter+0x20/0xcc
        LR is at __process_removed_adapter+0x14/0x1c
        Flags: NzCv  IRQs on  FIQs on  Mode SVC_32  ISA ARM  Segment none
        Control: 10c5387d  Table: 35bd004a  DAC: 00000051
        Process sh (pid: 533, stack limit = 0xe4936210)
        Stack: (0xe4937d28 to 0xe4938000)
        Backtrace:
        [<c0667be0>] (i2c_do_del_adapter) from [<c0667cc0>] (__process_removed_adapter+0x14/0x1c)
        [<c0667cac>] (__process_removed_adapter) from [<c0516998>] (bus_for_each_drv+0x6c/0xa0)
        [<c051692c>] (bus_for_each_drv) from [<c06685ec>] (i2c_del_adapter+0xbc/0x284)
        [<c0668530>] (i2c_del_adapter) from [<bf0110ec>] (i2c_imx_remove+0x44/0x164 [i2c_imx])
        [<bf0110a8>] (i2c_imx_remove [i2c_imx]) from [<c051a838>] (platform_drv_remove+0x2c/0x44)
        [<c051a80c>] (platform_drv_remove) from [<c05183d8>] (__device_release_driver+0x90/0x12c)
        [<c0518348>] (__device_release_driver) from [<c051849c>] (device_release_driver+0x28/0x34)
        [<c0518474>] (device_release_driver) from [<c0517150>] (unbind_store+0x80/0x104)
        [<c05170d0>] (unbind_store) from [<c0516520>] (drv_attr_store+0x28/0x34)
        [<c05164f8>] (drv_attr_store) from [<c0298acc>] (sysfs_kf_write+0x50/0x54)
        [<c0298a7c>] (sysfs_kf_write) from [<c029801c>] (kernfs_fop_write+0x100/0x214)
        [<c0297f1c>] (kernfs_fop_write) from [<c0220130>] (__vfs_write+0x34/0x120)
        [<c02200fc>] (__vfs_write) from [<c0221088>] (vfs_write+0xa8/0x170)
        [<c0220fe0>] (vfs_write) from [<c0221e74>] (SyS_write+0x4c/0xa8)
        [<c0221e28>] (SyS_write) from [<c0108a20>] (ret_fast_syscall+0x0/0x1c)
      Signed-off-by: NVladimir Zapolskiy <vladimir_zapolskiy@mentor.com>
      Signed-off-by: NWolfram Sang <wsa@the-dreams.de>
      Cc: stable@kernel.org
      147b36d5
  12. 25 10月, 2016 1 次提交
  13. 24 9月, 2016 2 次提交
  14. 23 9月, 2016 1 次提交
    • M
      i2c / ACPI: Do not touch an I2C device if it belongs to another adapter · 318ce278
      Mika Westerberg 提交于
      When enumerating I2C devices connected to an I2C adapter we scan the whole
      namespace (as it is possible to have devices anywhere in that namespace,
      not just below the I2C adapter device) and add each found device to the I2C
      bus in question.
      
      Now after commit 525e6fab ("i2c / ACPI: add support for ACPI
      reconfigure notifications") checking of the adapter handle to the one found
      in the I2cSerialBus() resource was moved to happen after resources of the
      I2C device has been parsed. This means that if the I2cSerialBus() resource
      points to an adapter that does not exists in the system we still parse
      those resources. This is problematic in particular because
      acpi_dev_resource_interrupt() tries to configure GSI if the device also has
      an Interrupt() resource. Failing to do that results errrors like this to be
      printed on the console:
      
        [   10.409490] ERROR: Unable to locate IOAPIC for GSI 37
      
      To fix this we pass the I2C adapter to i2c_acpi_get_info() and make sure
      the handle matches the one in the I2cSerialBus() resource before doing
      anything else to the device.
      Reported-by: NNicolai Stange <nicstange@gmail.com>
      Signed-off-by: NMika Westerberg <mika.westerberg@linux.intel.com>
      Reviewed-by: NNicolai Stange <nicstange@gmail.com>
      Signed-off-by: NWolfram Sang <wsa@the-dreams.de>
      318ce278
  15. 31 8月, 2016 2 次提交
  16. 26 8月, 2016 3 次提交
    • J
      i2c: core: Add function for finding the bus speed from ACPI, take 2 · 5853b22d
      Jarkko Nikula 提交于
      ACPI 5 specification doesn't have property for the I2C bus speed but
      I2cSerialBus resource descriptor which define each controller-slave
      connection define the maximum speed supported by that connection.
      
      Thus finding the maximum safe speed for the bus is to walk through all
      I2cSerialBus resources that are associated to I2C controller and use the
      speed of slowest connection.
      
      Add function i2c_acpi_find_bus_speed() to the i2c-core that adapter
      drivers can call prior registering itself to core.
      
      This implies two-step walk through the I2cSerialBus resources: call to
      i2c_acpi_find_bus_speed() does the first scan and finds the safe bus
      speed that adapter drivers can set up. Adapter driver registration does
      the second scan when i2c-core creates the I2C slaves by calling the
      i2c_acpi_register_devices(). In that way the bus speed is set in case
      slave device probe gets called during registration and does communication.
      
      Previous version commit 55d38d06 ("i2c: core: Add function for finding
      the bus speed from ACPI") got reverted due merge conflicts from
      commit 525e6fab ("i2c / ACPI: add support for ACPI reconfigure
      notifications").
      
      This version is a bit bigger than previous version but is still sharing
      the lowest and complicated part of I2cSerialBus lookup routines with the
      existing code.
      Signed-off-by: NJarkko Nikula <jarkko.nikula@linux.intel.com>
      Reviewed-by: NAndy Shevchenko <andriy.shevchenko@linux.intel.com>
      Signed-off-by: NWolfram Sang <wsa@the-dreams.de>
      5853b22d
    • J
      i2c: core: Cleanup I2C ACPI namespace, take 2 · aec809fc
      Jarkko Nikula 提交于
      I2C ACPI enumeration was originally implemented in another module under
      drivers/acpi/ but was later moved into i2c-core with added support for
      I2C ACPI operation region.
      
      Rename these acpi_i2c_ prefixed functions, structures and defines in
      i2c-core to i2c_acpi_ in order to have more consistent name space.
      
      This is updated version from commit a7003b65 ("i2c: core: Cleanup I2C
      ACPI namespace") that got reverted due merge conflicts from
      commit 525e6fab ("i2c / ACPI: add support for ACPI reconfigure
      notifications").
      Signed-off-by: NJarkko Nikula <jarkko.nikula@linux.intel.com>
      Reviewed-by: NAndy Shevchenko <andriy.shevchenko@linux.intel.com>
      Signed-off-by: NWolfram Sang <wsa@the-dreams.de>
      aec809fc
    • P
      i2c: add i2c_trylock_bus wrapper, use it · fb79e09a
      Peter Rosin 提交于
      This unifies usage with i2c_lock_bus and i2c_unlock_bus, and paves the
      way for the next patch which looks a bit saner with this preparatory
      work taken care of beforehand.
      Signed-off-by: NPeter Rosin <peda@axentia.se>
      Signed-off-by: NWolfram Sang <wsa@the-dreams.de>
      fb79e09a
  17. 19 7月, 2016 2 次提交
  18. 14 7月, 2016 9 次提交
  19. 09 7月, 2016 1 次提交
    • O
      i2c / ACPI: add support for ACPI reconfigure notifications · 525e6fab
      Octavian Purdila 提交于
      This patch adds supports for I2C device enumeration and removal via
      ACPI reconfiguration notifications that are send as a result of an
      ACPI table load or unload operation.
      
      The code is very similar with the device tree reconfiguration code
      with only small differences in the way we test and set the enumerated
      state of the device:
      
       * the equivalent of device tree's OF_POPULATED flag is the
         flags.visited field in the ACPI device and the following
         wrappers are used to manipulate it: acpi_device_enumerated(),
         acpi_device_set_enumerated() and acpi_device_clear_enumerated()
      
       * the device tree code checks of status of the OF_POPULATED flag to
         avoid trying to create duplicate Linux devices in two places: once
         when the controller is probed, and once when the reconfigure event
         is received; in the ACPI code the check is performed only once when
         the ACPI namespace is searched because this code path is invoked in
         both of the two mentioned cases
      
      The rest of the enumeration handling is similar with device tree: when
      the Linux device is unregistered the ACPI device is marked as not
      enumerated; also, when a device remove notification is received we
      check that the device is in the enumerated state before continuing
      with the removal of the Linux device.
      Signed-off-by: NOctavian Purdila <octavian.purdila@intel.com>
      Reviewed-by: NMika Westerberg <mika.westerberg@linux.intel.com>
      Acked-by: NWolfram Sang <wsa@the-dreams.de>
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      525e6fab