1. 25 10月, 2018 2 次提交
    • H
      i2c: designware: Cleanup bus lock handling · 8afb4680
      Hans de Goede 提交于
      Now that most of the special Bay- / Cherry-Trail bus lock handling has
      been moved to the iosf_mbi code we can simplify the remaining code a bit.
      Signed-off-by: NHans de Goede <hdegoede@redhat.com>
      Acked-by: NJarkko Nikula <jarkko.nikula@linux.intel.com>
      Tested-by: NJarkko Nikula <jarkko.nikula@linux.intel.com>
      Acked-by: NWolfram Sang <wsa@the-dreams.de>
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      8afb4680
    • H
      x86: baytrail/cherrytrail: Rework and move P-Unit PMIC bus semaphore code · e09db3d2
      Hans de Goede 提交于
      On some BYT/CHT systems the SoC's P-Unit shares the I2C bus with the
      kernel. The P-Unit has a semaphore for the PMIC bus which we can take to
      block it from accessing the shared bus while the kernel wants to access it.
      
      Currently we have the I2C-controller driver acquiring and releasing the
      semaphore around each I2C transfer. There are 2 problems with this:
      
      1) PMIC accesses often come in the form of a read-modify-write on one of
      the PMIC registers, we currently release the P-Unit's PMIC bus semaphore
      between the read and the write. If the P-Unit modifies the register during
      this window?, then we end up overwriting the P-Unit's changes.
      I believe that this is mostly an academic problem, but I'm not sure.
      
      2) To safely access the shared I2C bus, we need to do 3 things:
      a) Notify the GPU driver that we are starting a window in which it may not
      access the P-Unit, since the P-Unit seems to ignore the semaphore for
      explicit power-level requests made by the GPU driver
      b) Make a pm_qos request to force all CPU cores out of C6/C7 since entering
      C6/C7 while we hold the semaphore hangs the SoC
      c) Finally take the P-Unit's PMIC bus semaphore
      All 3 these steps together are somewhat expensive, so ideally if we have
      a bunch of i2c transfers grouped together we only do this once for the
      entire group.
      
      Taking the read-modify-write on a PMIC register as example then ideally we
      would only do all 3 steps once at the beginning and undo all 3 steps once
      at the end.
      
      For this we need to be able to take the semaphore from within e.g. the PMIC
      opregion driver, yet we do not want to remove the taking of the semaphore
      from the I2C-controller driver, as that is still necessary to protect many
      other code-paths leading to accessing the shared I2C bus.
      
      This means that we first have the PMIC driver acquire the semaphore and
      then have the I2C controller driver trying to acquire it again.
      
      To make this possible this commit does the following:
      
      1) Move the semaphore code from being private to the I2C controller driver
      into the generic iosf_mbi code, which already has other code to deal with
      the shared bus so that it can be accessed outside of the I2C bus driver.
      
      2) Rework the code so that it can be called multiple times nested, while
      still blocking I2C accesses while e.g. the GPU driver has indicated the
      P-Unit needs the bus through a iosf_mbi_punit_acquire() call.
      Signed-off-by: NHans de Goede <hdegoede@redhat.com>
      Acked-by: NJarkko Nikula <jarkko.nikula@linux.intel.com>
      Tested-by: NJarkko Nikula <jarkko.nikula@linux.intel.com>
      Acked-by: NWolfram Sang <wsa@the-dreams.de>
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      e09db3d2
  2. 20 10月, 2018 1 次提交
  3. 05 10月, 2018 1 次提交
  4. 01 10月, 2018 1 次提交
    • E
      i2c: i2c-scmi: fix for i2c_smbus_write_block_data · 08d9db00
      Edgar Cherkasov 提交于
      The i2c-scmi driver crashes when the SMBus Write Block transaction is
      executed:
      
      WARNING: CPU: 9 PID: 2194 at mm/page_alloc.c:3931 __alloc_pages_slowpath+0x9db/0xec0
       Call Trace:
        ? get_page_from_freelist+0x49d/0x11f0
        ? alloc_pages_current+0x6a/0xe0
        ? new_slab+0x499/0x690
        __alloc_pages_nodemask+0x265/0x280
        alloc_pages_current+0x6a/0xe0
        kmalloc_order+0x18/0x40
        kmalloc_order_trace+0x24/0xb0
        ? acpi_ut_allocate_object_desc_dbg+0x62/0x10c
        __kmalloc+0x203/0x220
        acpi_os_allocate_zeroed+0x34/0x36
        acpi_ut_copy_eobject_to_iobject+0x266/0x31e
        acpi_evaluate_object+0x166/0x3b2
        acpi_smbus_cmi_access+0x144/0x530 [i2c_scmi]
        i2c_smbus_xfer+0xda/0x370
        i2cdev_ioctl_smbus+0x1bd/0x270
        i2cdev_ioctl+0xaa/0x250
        do_vfs_ioctl+0xa4/0x600
        SyS_ioctl+0x79/0x90
        do_syscall_64+0x73/0x130
        entry_SYSCALL_64_after_hwframe+0x3d/0xa2
      ACPI Error: Evaluating _SBW: 4 (20170831/smbus_cmi-185)
      
      This problem occurs because the length of ACPI Buffer object is not
      defined/initialized in the code before a corresponding ACPI method is
      called. The obvious patch below fixes this issue.
      Signed-off-by: NEdgar Cherkasov <echerkasov@dev.rtsoft.ru>
      Acked-by: NViktor Krasnov <vkrasnov@dev.rtsoft.ru>
      Acked-by: NMichael Brunner <Michael.Brunner@kontron.com>
      Signed-off-by: NWolfram Sang <wsa@the-dreams.de>
      08d9db00
  5. 25 9月, 2018 2 次提交
  6. 07 9月, 2018 1 次提交
  7. 05 9月, 2018 1 次提交
  8. 03 9月, 2018 3 次提交
  9. 31 8月, 2018 5 次提交
    • W
      i2c: sh_mobile: fix leak when using DMA bounce buffer · cebc07d8
      Wolfram Sang 提交于
      We only freed the bounce buffer after successful DMA, missing the cases
      where DMA setup may have gone wrong. Use a better location which always
      gets called after each message and use 'stop_after_dma' as a flag for a
      successful transfer.
      Signed-off-by: NWolfram Sang <wsa+renesas@sang-engineering.com>
      Reviewed-by: NNiklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
      Signed-off-by: NWolfram Sang <wsa@the-dreams.de>
      cebc07d8
    • W
      i2c: sh_mobile: define start_ch() void as it only returns 0 anyhow · 531db501
      Wolfram Sang 提交于
      After various refactoring over the years, start_ch() doesn't return
      errno anymore, so make the function return void. This saves the error
      handling when calling it which in turn eases cleanup of resources of a
      future patch.
      Signed-off-by: NWolfram Sang <wsa+renesas@sang-engineering.com>
      Reviewed-by: NNiklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
      Signed-off-by: NWolfram Sang <wsa@the-dreams.de>
      531db501
    • W
      i2c: refactor function to release a DMA safe buffer · 82fe39a6
      Wolfram Sang 提交于
      a) rename to 'put' instead of 'release' to match 'get' when obtaining
         the buffer
      b) change the argument order to have the buffer as first argument
      c) add a new argument telling the function if the message was
         transferred. This allows the function to be used also in cases
         where setting up DMA failed, so the buffer needs to be freed without
         syncing to the message buffer.
      
      Also convert the only user.
      Signed-off-by: NWolfram Sang <wsa+renesas@sang-engineering.com>
      Reviewed-by: NNiklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
      Signed-off-by: NWolfram Sang <wsa@the-dreams.de>
      82fe39a6
    • H
      i2c: designware: Re-init controllers with pm_disabled set on resume · 9d9a152e
      Hans de Goede 提交于
      On Bay Trail and Cherry Trail devices we set the pm_disabled flag for I2C
      busses which the OS shares with the PUNIT as these need special handling.
      Until now we called dev_pm_syscore_device(dev, true) for I2C controllers
      with this flag set to keep these I2C controllers always on.
      
      After commit 12864ff8 ("ACPI / LPSS: Avoid PM quirks on suspend and
      resume from hibernation"), this no longer works. This commit modifies
      lpss_iosf_exit_d3_state() to only run if lpss_iosf_enter_d3_state() has ran
      before it, so that it does not run on a resume from hibernate (or from S3).
      
      On these systems the conditions for lpss_iosf_enter_d3_state() to run
      never become true, so lpss_iosf_exit_d3_state() never gets called and
      the 2 LPSS DMA controllers never get forced into D0 mode, instead they
      are left in their default automatic power-on when needed mode.
      
      The not forcing of D0 mode for the DMA controllers enables these systems
      to properly enter S0ix modes, which is a good thing.
      
      But after entering S0ix modes the I2C controller connected to the PMIC
      no longer works, leading to e.g. broken battery monitoring.
      
      The _PS3 method for this I2C controller looks like this:
      
                  Method (_PS3, 0, NotSerialized)  // _PS3: Power State 3
                  {
                      If ((((PMID == 0x04) || (PMID == 0x05)) || (PMID == 0x06)))
                      {
                          Return (Zero)
                      }
      
                      PSAT |= 0x03
                      Local0 = PSAT /* \_SB_.I2C5.PSAT */
                  }
      
      Where PMID = 0x05, so we enter the Return (Zero) path on these systems.
      
      So even if we were to not call dev_pm_syscore_device(dev, true) the
      I2C controller will be left in D0 rather then be switched to D3.
      
      Yet on other Bay and Cherry Trail devices S0ix is not entered unless *all*
      I2C controllers are in D3 mode. This combined with the I2C controller no
      longer working now that we reach S0ix states on these systems leads to me
      believing that the PUNIT itself puts the I2C controller in D3 when all
      other conditions for entering S0ix states are true.
      
      Since now the I2C controller is put in D3 over a suspend/resume we must
      re-initialize it afterwards and that does indeed fix it no longer working.
      
      This commit implements this fix by:
      
      1) Making the suspend_late callback a no-op if pm_disabled is set and
      making the resume_early callback skip the clock re-enable (since it now was
      not disabled) while still doing the necessary I2C controller re-init.
      
      2) Removing the dev_pm_syscore_device(dev, true) call, so that the suspend
      and resume callbacks are actually called. Normally this would cause the
      ACPI pm code to call _PS3 putting the I2C controller in D3, wreaking havoc
      since it is shared with the PUNIT, but in this special case the _PS3 method
      is a no-op so we can safely allow a "fake" suspend / resume.
      
      Fixes: 12864ff8 ("ACPI / LPSS: Avoid PM quirks on suspend and resume ...")
      Link: https://bugzilla.kernel.org/show_bug.cgi?id=200861
      Cc: 4.15+ <stable@vger.kernel.org> # 4.15+
      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>
      9d9a152e
    • M
      i2c: i801: Allow ACPI AML access I/O ports not reserved for SMBus · 7fd6d98b
      Mika Westerberg 提交于
      Commit 7ae81952cda ("i2c: i801: Allow ACPI SystemIO OpRegion to conflict
      with PCI BAR") made it possible for AML code to access SMBus I/O ports
      by installing custom SystemIO OpRegion handler and blocking i80i driver
      access upon first AML read/write to this OpRegion.
      
      However, while ThinkPad T560 does have SystemIO OpRegion declared under
      the SMBus device, it does not access any of the SMBus registers:
      
          Device (SMBU)
          {
              ...
      
              OperationRegion (SMBP, PCI_Config, 0x50, 0x04)
              Field (SMBP, DWordAcc, NoLock, Preserve)
              {
                  ,   5,
                  TCOB,   11,
                  Offset (0x04)
              }
      
              Name (TCBV, 0x00)
              Method (TCBS, 0, NotSerialized)
              {
                  If ((TCBV == 0x00))
                  {
                  TCBV = (\_SB.PCI0.SMBU.TCOB << 0x05)
                  }
      
                  Return (TCBV) /* \_SB_.PCI0.SMBU.TCBV */
              }
      
              OperationRegion (TCBA, SystemIO, TCBS (), 0x10)
              Field (TCBA, ByteAcc, NoLock, Preserve)
              {
                  Offset (0x04),
                  ,   9,
                  CPSC,   1
              }
          }
      
      Problem with the current approach is that it blocks all I/O port access
      and because this system has touchpad connected to the SMBus controller
      after first AML access (happens during suspend/resume cycle) the
      touchpad fails to work anymore.
      
      Fix this so that we allow ACPI AML I/O port access if it does not touch
      the region reserved for the SMBus.
      
      Fixes: 7ae81952cda ("i2c: i801: Allow ACPI SystemIO OpRegion to conflict with PCI BAR")
      Link: https://bugzilla.kernel.org/show_bug.cgi?id=200737Reported-by: NYussuf Khalil <dev@pp3345.net>
      Signed-off-by: NMika Westerberg <mika.westerberg@linux.intel.com>
      Reviewed-by: NJean Delvare <jdelvare@suse.de>
      Signed-off-by: NWolfram Sang <wsa@the-dreams.de>
      7fd6d98b
  10. 24 8月, 2018 2 次提交
  11. 20 8月, 2018 6 次提交
  12. 09 8月, 2018 4 次提交
  13. 05 8月, 2018 9 次提交
  14. 01 8月, 2018 1 次提交
  15. 24 7月, 2018 1 次提交