1. 12 11月, 2022 1 次提交
    • M
      PCI: Fix pci_device_is_present() for VFs by checking PF · 98b04dd0
      Michael S. Tsirkin 提交于
      pci_device_is_present() previously didn't work for VFs because it reads the
      Vendor and Device ID, which are 0xffff for VFs, which looks like they
      aren't present.  Check the PF instead.
      
      Wei Gong reported that if virtio I/O is in progress when the driver is
      unbound or "0" is written to /sys/.../sriov_numvfs, the virtio I/O
      operation hangs, which may result in output like this:
      
        task:bash state:D stack:    0 pid: 1773 ppid:  1241 flags:0x00004002
        Call Trace:
         schedule+0x4f/0xc0
         blk_mq_freeze_queue_wait+0x69/0xa0
         blk_mq_freeze_queue+0x1b/0x20
         blk_cleanup_queue+0x3d/0xd0
         virtblk_remove+0x3c/0xb0 [virtio_blk]
         virtio_dev_remove+0x4b/0x80
         ...
         device_unregister+0x1b/0x60
         unregister_virtio_device+0x18/0x30
         virtio_pci_remove+0x41/0x80
         pci_device_remove+0x3e/0xb0
      
      This happened because pci_device_is_present(VF) returned "false" in
      virtio_pci_remove(), so it called virtio_break_device().  The broken vq
      meant that vring_interrupt() skipped the vq.callback() that would have
      completed the virtio I/O operation via virtblk_done().
      
      [bhelgaas: commit log, simplify to always use pci_physfn(), add stable tag]
      Link: https://lore.kernel.org/r/20221026060912.173250-1-mst@redhat.comReported-by: NWei Gong <gongwei833x@gmail.com>
      Tested-by: NWei Gong <gongwei833x@gmail.com>
      Signed-off-by: NMichael S. Tsirkin <mst@redhat.com>
      Signed-off-by: NBjorn Helgaas <bhelgaas@google.com>
      Cc: stable@vger.kernel.org
      98b04dd0
  2. 09 11月, 2022 1 次提交
  3. 05 10月, 2022 1 次提交
  4. 30 9月, 2022 1 次提交
  5. 13 9月, 2022 2 次提交
    • B
      PCI/PM: Always disable PTM for all devices during suspend · c01163db
      Bjorn Helgaas 提交于
      We want to disable PTM on Root Ports because that allows some chips, e.g.,
      Intel mobile chips since Coffee Lake, to enter a lower-power PM state.
      
      That means we also have to disable PTM on downstream devices.  PCIe r6.0,
      sec 2.2.8, recommends that functions support generation of messages in
      non-D0 states, so we have to assume Switch Upstream Ports or Endpoints may
      send PTM Requests while in D1, D2, and D3hot.  A PTM message received by a
      Downstream Port (including a Root Port) with PTM disabled must be treated
      as an Unsupported Request (sec 6.21.3).
      
      PTM was previously disabled only for Root Ports, and it was disabled in
      pci_prepare_to_sleep(), which is not called at all if a driver supports
      legacy PM or does its own state saving.
      
      Instead, disable PTM early in pci_pm_suspend() and pci_pm_runtime_suspend()
      so we do it in all cases.
      
      Previously PTM was disabled *after* saving device state, so the state
      restore on resume automatically re-enabled it.  Since we now disable PTM
      *before* saving state, we must explicitly re-enable it in pci_pm_resume()
      and pci_pm_runtime_resume().
      
      Here's a sample of errors that occur when PTM is disabled only on the Root
      Port.  With this topology:
      
        0000:00:1d.0 Root Port            to [bus 08-71]
        0000:08:00.0 Switch Upstream Port to [bus 09-71]
      
      Kai-Heng reported errors like this:
      
        pcieport 0000:00:1d.0:    [20] UnsupReq               (First)
        pcieport 0000:00:1d.0: AER:   TLP Header: 34000000 08000052 00000000 00000000
      
      Decoding TLP header 0x34...... (0011 0100b) and 0x08000052:
      
        Fmt                         001b  4 DW header, no data
        Type                     1 0100b  Msg (Local - Terminate at Receiver)
        Requester ID  0x0800              Bus 08 Devfn 00.0
        Message Code    0x52  0101 0010b  PTM Request
      
      The 00:1d.0 Root Port logged an Unsupported Request error when it received
      a PTM Request with Requester ID 08:00.0.
      
      Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=215453
      Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=216210
      Fixes: a697f072 ("PCI: Disable PTM during suspend to save power")
      Link: https://lore.kernel.org/r/20220909202505.314195-10-helgaas@kernel.orgReported-by: NKai-Heng Feng <kai.heng.feng@canonical.com>
      Tested-by: NRajvi Jingar <rajvi.jingar@linux.intel.com>
      Signed-off-by: NBjorn Helgaas <bhelgaas@google.com>
      Reviewed-by: NMika Westerberg <mika.westerberg@linux.intel.com>
      c01163db
    • B
      PCI/PTM: Add pci_suspend_ptm() and pci_resume_ptm() · e8bdc5ea
      Bjorn Helgaas 提交于
      We disable PTM during suspend because that allows some Root Ports to enter
      lower-power PM states, which means we also need to disable PTM for all
      downstream devices.  Add pci_suspend_ptm() and pci_resume_ptm() for this
      purpose.
      
      pci_enable_ptm() and pci_disable_ptm() are for drivers to use to enable or
      disable PTM.  They use dev->ptm_enabled to keep track of whether PTM should
      be enabled.
      
      pci_suspend_ptm() and pci_resume_ptm() are PCI core-internal functions to
      temporarily disable PTM during suspend and (depending on dev->ptm_enabled)
      re-enable PTM during resume.
      
      Enable/disable/suspend/resume all use internal __pci_enable_ptm() and
      __pci_disable_ptm() functions that only update the PTM Control register.
      Outline:
      
        pci_enable_ptm(struct pci_dev *dev)
        {
           __pci_enable_ptm(dev);
           dev->ptm_enabled = 1;
           pci_ptm_info(dev);
        }
      
        pci_disable_ptm(struct pci_dev *dev)
        {
           if (dev->ptm_enabled) {
             __pci_disable_ptm(dev);
             dev->ptm_enabled = 0;
           }
        }
      
        pci_suspend_ptm(struct pci_dev *dev)
        {
           if (dev->ptm_enabled)
             __pci_disable_ptm(dev);
        }
      
        pci_resume_ptm(struct pci_dev *dev)
        {
           if (dev->ptm_enabled)
             __pci_enable_ptm(dev);
        }
      
      Nothing currently calls pci_resume_ptm(); the suspend path saves the PTM
      state before disabling PTM, so the PTM state restore in the resume path
      implicitly re-enables it.  A future change will use pci_resume_ptm() to fix
      some problems with this approach.
      
      Link: https://lore.kernel.org/r/20220909202505.314195-5-helgaas@kernel.orgTested-by: NRajvi Jingar <rajvi.jingar@linux.intel.com>
      Signed-off-by: NBjorn Helgaas <bhelgaas@google.com>
      Reviewed-by: NMika Westerberg <mika.westerberg@linux.intel.com>
      e8bdc5ea
  6. 23 7月, 2022 1 次提交
  7. 12 7月, 2022 1 次提交
  8. 01 6月, 2022 1 次提交
  9. 12 5月, 2022 1 次提交
  10. 06 5月, 2022 13 次提交
  11. 12 4月, 2022 1 次提交
  12. 12 1月, 2022 1 次提交
  13. 17 12月, 2021 1 次提交
  14. 19 11月, 2021 1 次提交
  15. 12 11月, 2021 1 次提交
  16. 08 11月, 2021 1 次提交
  17. 05 11月, 2021 1 次提交
    • S
      PCI: Do not enable AtomicOps on VFs · 5ec0a6fc
      Selvin Xavier 提交于
      Host crashes when pci_enable_atomic_ops_to_root() is called for VFs with
      virtual buses. The virtual buses added to SR-IOV have bus->self set to NULL
      and host crashes due to this.
      
        PID: 4481   TASK: ffff89c6941b0000  CPU: 53  COMMAND: "bash"
        ...
         #3 [ffff9a9481713808] oops_end at ffffffffb9025cd6
         #4 [ffff9a9481713828] page_fault_oops at ffffffffb906e417
         #5 [ffff9a9481713888] exc_page_fault at ffffffffb9a0ad14
         #6 [ffff9a94817138b0] asm_exc_page_fault at ffffffffb9c00ace
            [exception RIP: pcie_capability_read_dword+28]
            RIP: ffffffffb952fd5c  RSP: ffff9a9481713960  RFLAGS: 00010246
            RAX: 0000000000000001  RBX: ffff89c6b1096000  RCX: 0000000000000000
            RDX: ffff9a9481713990  RSI: 0000000000000024  RDI: 0000000000000000
            RBP: 0000000000000080   R8: 0000000000000008   R9: ffff89c64341a2f8
            R10: 0000000000000002  R11: 0000000000000000  R12: ffff89c648bab000
            R13: 0000000000000000  R14: 0000000000000000  R15: ffff89c648bab0c8
            ORIG_RAX: ffffffffffffffff  CS: 0010  SS: 0018
         #7 [ffff9a9481713988] pci_enable_atomic_ops_to_root at ffffffffb95359a6
         #8 [ffff9a94817139c0] bnxt_qplib_determine_atomics at ffffffffc08c1a33 [bnxt_re]
         #9 [ffff9a94817139d0] bnxt_re_dev_init at ffffffffc08ba2d1 [bnxt_re]
      
      Per PCIe r5.0, sec 9.3.5.10, the AtomicOp Requester Enable bit in Device
      Control 2 is reserved for VFs.  The PF value applies to all associated VFs.
      
      Return -EINVAL if pci_enable_atomic_ops_to_root() is called for a VF.
      
      Link: https://lore.kernel.org/r/1631354585-16597-1-git-send-email-selvin.xavier@broadcom.com
      Fixes: 35f5ace5 ("RDMA/bnxt_re: Enable global atomic ops if platform supports")
      Fixes: 430a2368 ("PCI: Add pci_enable_atomic_ops_to_root()")
      Signed-off-by: NSelvin Xavier <selvin.xavier@broadcom.com>
      Signed-off-by: NBjorn Helgaas <bhelgaas@google.com>
      Reviewed-by: NAndy Gospodarek <gospo@broadcom.com>
      5ec0a6fc
  18. 30 10月, 2021 1 次提交
  19. 28 10月, 2021 1 次提交
  20. 27 10月, 2021 1 次提交
  21. 21 10月, 2021 1 次提交
  22. 20 10月, 2021 1 次提交
    • M
      PCI: Re-enable Downstream Port LTR after reset or hotplug · e1b0d0bb
      Mingchuang Qiao 提交于
      Per PCIe r5.0, sec 7.5.3.16, Downstream Ports must disable LTR if the link
      goes down (the Port goes DL_Down status).  This is a problem because the
      Downstream Port's dev->ltr_path is still set, so we think LTR is still
      enabled, and we enable LTR in the Endpoint.  When it sends LTR messages,
      they cause Unsupported Request errors at the Downstream Port.
      
      This happens in the reset path, where we may enable LTR in
      pci_restore_pcie_state() even though the Downstream Port disabled LTR
      because the reset caused a link down event.
      
      It also happens in the hot-remove and hot-add path, where we may enable LTR
      in pci_configure_ltr() even though the Downstream Port disabled LTR when
      the hot-remove took the link down.
      
      In these two scenarios, check the upstream bridge and restore its LTR
      enable if appropriate.
      
      The Unsupported Request may be logged by AER as follows:
      
        pcieport 0000:00:1d.0: AER: Uncorrected (Non-Fatal) error received: id=00e8
        pcieport 0000:00:1d.0: PCIe Bus Error: severity=Uncorrected (Non-Fatal), type=Transaction Layer, id=00e8(Requester ID)
        pcieport 0000:00:1d.0:   device [8086:9d18] error status/mask=00100000/00010000
        pcieport 0000:00:1d.0:    [20] Unsupported Request    (First)
      
      In addition, if LTR is not configured correctly, the link cannot enter the
      L1.2 state, which prevents some machines from entering the S0ix low power
      state.
      
      [bhelgaas: commit log]
      Link: https://lore.kernel.org/r/20211012075614.54576-1-mingchuang.qiao@mediatek.comReported-by: NUtkarsh H Patel <utkarsh.h.patel@intel.com>
      Signed-off-by: NMingchuang Qiao <mingchuang.qiao@mediatek.com>
      Signed-off-by: NBjorn Helgaas <bhelgaas@google.com>
      Reviewed-by: NMika Westerberg <mika.westerberg@linux.intel.com>
      e1b0d0bb
  23. 18 10月, 2021 1 次提交
  24. 16 10月, 2021 1 次提交
  25. 13 10月, 2021 1 次提交
  26. 05 10月, 2021 2 次提交