31 May, 2017

2 commits

  • After a Function-Level Reset, PCI states need to be restored. Save PASID
    features and PRI reqs cached.

    [bhelgaas: search for capability only if PRI/PASID were enabled]
    Signed-off-by: CQ Tang
    Signed-off-by: Ashok Raj
    Signed-off-by: Bjorn Helgaas
    Cc: Joerg Roedel
    Cc: Jean-Phillipe Brucker
    Cc: David Woodhouse

    CQ Tang
     
  • Device drivers need to check if an IOMMU enabled ATS, PRI and PASID in
    order to know when they can use the SVM API. Cache PRI and PASID bits in
    the pci_dev structure, similarly to what is currently done for ATS.

    Signed-off-by: Jean-Philippe Brucker
    Signed-off-by: Bjorn Helgaas

    Jean-Philippe Brucker
     

14 Aug, 2015

8 commits

  • Remove pci_ats_enabled(). There are no callers outside the ATS code
    itself. We don't need to check ats_cap, because if we don't find an ATS
    capability, we'll never set ats_enabled.

    Signed-off-by: Bjorn Helgaas
    Reviewed-by: Joerg Roedel

    Bjorn Helgaas
     
  • Stop caching the Invalidate Queue Depth in struct pci_dev.
    pci_ats_queue_depth() is typically called only once per device, and it
    returns a fixed value per-device, so callers who need the value frequently
    can cache it themselves.

    Signed-off-by: Bjorn Helgaas
    Reviewed-by: Joerg Roedel

    Bjorn Helgaas
     
  • There's no need to BUG() if we enable ATS when it's already enabled. We
    don't need to BUG() when disabling ATS on a device that doesn't support ATS
    or if it's already disabled. If ATS is enabled, certainly we found an ATS
    capability in the past, so it should still be there now.

    Clean up these error paths.

    Signed-off-by: Bjorn Helgaas
    Reviewed-by: Joerg Roedel

    Bjorn Helgaas
     
  • Use the pci_physfn() helper rather than looking up physfn by hand.
    No functional change.

    Signed-off-by: Bjorn Helgaas
    Reviewed-by: Joerg Roedel

    Bjorn Helgaas
     
  • The ATS setup code in ats_alloc_one() is only used by pci_ats_init(), so
    inline it there. No functional change.

    Signed-off-by: Bjorn Helgaas
    Reviewed-by: Joerg Roedel

    Bjorn Helgaas
     
  • We previously returned -ENODEV for devices that don't support ATS (except
    that we always returned 0 for VFs, whether or not they support ATS).

    For consistency, always return -EINVAL (not -ENODEV) if the device doesn't
    support ATS. Return zero for VFs that support ATS.

    Signed-off-by: Bjorn Helgaas
    Reviewed-by: Joerg Roedel

    Bjorn Helgaas
     
  • The pci_ats struct is small and will get smaller, so I don't think it's
    worth allocating it separately from the pci_dev struct.

    Embed the ATS fields directly into struct pci_dev.

    Signed-off-by: Bjorn Helgaas
    Reviewed-by: Joerg Roedel

    Bjorn Helgaas
     
  • Previously, we allocated pci_ats structures when an IOMMU driver called
    pci_enable_ats(). An SR-IOV VF shares the STU setting with its PF, so when
    enabling ATS on the VF, we allocated a pci_ats struct for the PF if it
    didn't already have one. We held the sriov->lock to serialize threads
    concurrently enabling ATS on several VFS so only one would allocate the PF
    pci_ats.

    Gregor reported a deadlock here:

    pci_enable_sriov
    sriov_enable
    virtfn_add
    mutex_lock(dev->sriov->lock) # acquire sriov->lock
    pci_device_add
    device_add
    BUS_NOTIFY_ADD_DEVICE notifier chain
    iommu_bus_notifier
    amd_iommu_add_device # iommu_ops.add_device
    init_iommu_group
    iommu_group_get_for_dev
    iommu_group_add_device
    __iommu_attach_device
    amd_iommu_attach_device # iommu_ops.attach_device
    attach_device
    pci_enable_ats
    mutex_lock(dev->sriov->lock) # deadlock

    There's no reason to delay allocating the pci_ats struct, and if we
    allocate it for each device at enumeration-time, there's no need for
    locking in pci_enable_ats().

    Allocate pci_ats struct during enumeration, when we initialize other
    capabilities.

    Note that this implementation requires ATS to be enabled on the PF first,
    before on any of the VFs because the PF controls the STU for all the VFs.

    Link: http://permalink.gmane.org/gmane.linux.kernel.iommu/9433
    Reported-by: Gregor Dick
    Signed-off-by: Bjorn Helgaas
    Reviewed-by: Joerg Roedel

    Bjorn Helgaas
     

11 Jan, 2014

1 commit

  • My philosophy is unused code is dead code. And dead code is subject to bit
    rot and is a likely source of bugs. Use it or lose it.

    This reverts parts of c320b976d783 ("PCI: Add implementation for PRI
    capability"), removing these interfaces:

    pci_pri_enabled()
    pci_pri_stopped()
    pci_pri_status()

    [bhelgaas: split to separate patch]
    Signed-off-by: Stephen Hemminger
    Signed-off-by: Bjorn Helgaas
    CC: Joerg Roedel

    Stephen Hemminger
     

15 Nov, 2013

1 commit


12 Jan, 2012

1 commit

  • * 'linux-next' of git://git.kernel.org/pub/scm/linux/kernel/git/jbarnes/pci: (80 commits)
    x86/PCI: Expand the x86_msi_ops to have a restore MSIs.
    PCI: Increase resource array mask bit size in pcim_iomap_regions()
    PCI: DEVICE_COUNT_RESOURCE should be equal to PCI_NUM_RESOURCES
    PCI: pci_ids: add device ids for STA2X11 device (aka ConneXT)
    PNP: work around Dell 1536/1546 BIOS MMCONFIG bug that breaks USB
    x86/PCI: amd: factor out MMCONFIG discovery
    PCI: Enable ATS at the device state restore
    PCI: msi: fix imbalanced refcount of msi irq sysfs objects
    PCI: kconfig: English typo in pci/pcie/Kconfig
    PCI/PM/Runtime: make PCI traces quieter
    PCI: remove pci_create_bus()
    xtensa/PCI: convert to pci_scan_root_bus() for correct root bus resources
    x86/PCI: convert to pci_create_root_bus() and pci_scan_root_bus()
    x86/PCI: use pci_scan_bus() instead of pci_scan_bus_parented()
    x86/PCI: read Broadcom CNB20LE host bridge info before PCI scan
    sparc32, leon/PCI: convert to pci_scan_root_bus() for correct root bus resources
    sparc/PCI: convert to pci_create_root_bus()
    sh/PCI: convert to pci_scan_root_bus() for correct root bus resources
    powerpc/PCI: convert to pci_create_root_bus()
    powerpc/PCI: split PHB part out of pcibios_map_io_space()
    ...

    Fix up conflicts in drivers/pci/msi.c and include/linux/pci_regs.h due
    to the same patches being applied in other branches.

    Linus Torvalds
     

09 Jan, 2012

1 commit


07 Jan, 2012

2 commits


06 Dec, 2011

4 commits

  • I get this compile failure on parisc:

    drivers/pci/ats.c: In function 'ats_alloc_one':
    drivers/pci/ats.c:29: error: implicit declaration of function 'kzalloc'
    drivers/pci/ats.c:29: warning: assignment makes pointer from integer without a cast
    drivers/pci/ats.c: In function 'ats_free_one':
    drivers/pci/ats.c:45: error: implicit declaration of function 'kfree'

    Because ats.c is missing linux/slab.h as an include. This patch fixes it

    Signed-off-by: James Bottomley
    Signed-off-by: Jesse Barnes

    James Bottomley
     
  • More consistency cleanups. Drop the _OFF, separate and indent
    CTRL/CAP/STATUS bit definitions. This helped find the previous
    mis-use of bit 0 in the PASID capability register.

    Reviewed-by: Joerg Roedel
    Tested-by: Joerg Roedel
    Signed-off-by: Alex Williamson
    Signed-off-by: Jesse Barnes

    Alex Williamson
     
  • The PASID ECN indicates bit 0 is reserved in the capability register.
    Switch pci_enable_pasid() to error if PASID is already enabled and
    don't expose enable as a feature in pci_pasid_features().

    Reviewed-by: Joerg Roedel
    Tested-by: Joerg Roedel
    Signed-off-by: Alex Williamson
    Signed-off-by: Jesse Barnes

    Alex Williamson
     
  • These are extended capabilities, rename and move to proper
    group for consistency.

    Signed-off-by: Alex Williamson
    Signed-off-by: Jesse Barnes

    Alex Williamson
     

01 Nov, 2011

1 commit


15 Oct, 2011

4 commits

  • Devices supporting Process Address Space Identifiers
    (PASIDs) can use an IOMMU to access multiple IO address
    spaces at the same time. A PCIe device indicates support for
    this feature by implementing the PASID capability. This
    patch adds support for the capability to the Linux kernel.

    Reviewed-by: Bjorn Helgaas
    Signed-off-by: Joerg Roedel
    Signed-off-by: Jesse Barnes

    Joerg Roedel
     
  • Implement the necessary functions to handle PRI capabilities
    on PCIe devices. With PRI devices behind an IOMMU can signal
    page fault conditions to software and recover from such
    faults.

    Reviewed-by: Bjorn Helgaas
    Signed-off-by: Joerg Roedel
    Signed-off-by: Jesse Barnes

    Joerg Roedel
     
  • This patch makes the ATS functions usable for modules.
    They will be used by a module implementing some advanced
    AMD IOMMU features.

    Reviewed-by: Bjorn Helgaas
    Signed-off-by: Joerg Roedel
    Signed-off-by: Jesse Barnes

    Joerg Roedel
     
  • ATS does not depend on IOV support, so move the code into
    its own file. This file will also include support for the
    PRI and PASID capabilities later.
    Also give ATS its own Kconfig variable to allow selecting it
    without IOV support.

    Reviewed-by: Bjorn Helgaas
    Signed-off-by: Joerg Roedel
    Signed-off-by: Jesse Barnes

    Joerg Roedel