16 Dec, 2020

1 commit

  • Introduce of_dma_get_max_cpu_address(), which provides the highest CPU
    physical address addressable by all DMA masters in the system. It's
    specially useful for setting memory zones sizes at early boot time.

    Signed-off-by: Nicolas Saenz Julienne
    Reviewed-by: Rob Herring
    Link: https://lore.kernel.org/r/20201119175400.9995-4-nsaenzjulienne@suse.de
    Signed-off-by: Catalin Marinas

    Nicolas Saenz Julienne
     

12 Nov, 2020

1 commit

  • Commit dabf6b36b83a ("of: Add OF_DMA_DEFAULT_COHERENT & select it on
    powerpc") added a check to of_dma_is_coherent which returns early
    if OF_DMA_DEFAULT_COHERENT is enabled. This results in the of_node_put()
    being skipped causing a memory leak. Moved the of_node_get() below this
    check so we now we only get the node if OF_DMA_DEFAULT_COHERENT is not
    enabled.

    Fixes: dabf6b36b83a ("of: Add OF_DMA_DEFAULT_COHERENT & select it on powerpc")
    Signed-off-by: Evan Nimmo
    Link: https://lore.kernel.org/r/20201110022825.30895-1-evan.nimmo@alliedtelesis.co.nz
    Signed-off-by: Rob Herring

    Evan Nimmo
     

18 Sep, 2020

1 commit

  • The new field 'dma_range_map' in struct device is used to facilitate the
    use of single or multiple offsets between mapping regions of cpu addrs and
    dma addrs. It subsumes the role of "dev->dma_pfn_offset" which was only
    capable of holding a single uniform offset and had no region bounds
    checking.

    The function of_dma_get_range() has been modified so that it takes a single
    argument -- the device node -- and returns a map, NULL, or an error code.
    The map is an array that holds the information regarding the DMA regions.
    Each range entry contains the address offset, the cpu_start address, the
    dma_start address, and the size of the region.

    of_dma_configure() is the typical manner to set range offsets but there are
    a number of ad hoc assignments to "dev->dma_pfn_offset" in the kernel
    driver code. These cases now invoke the function
    dma_direct_set_offset(dev, cpu_addr, dma_addr, size).

    Signed-off-by: Jim Quinlan
    [hch: various interface cleanups]
    Signed-off-by: Christoph Hellwig
    Reviewed-by: Mathieu Poirier
    Tested-by: Mathieu Poirier
    Tested-by: Nathan Chancellor

    Jim Quinlan
     

20 Aug, 2020

1 commit

  • Recent changes to the DT PCI bus parsing made it mandatory for
    device tree nodes describing a PCI controller to have the
    'device_type = "pci"' property for the node to be matched.

    Although this follows the letter of the specification, it
    breaks existing device-trees that have been working fine
    for years. Rockchip rk3399-based systems are a prime example
    of such collateral damage, and have stopped discovering their
    PCI bus.

    In order to paper over it, let's add a workaround to the code
    matching the device type, and accept as PCI any node that is
    named "pcie",

    A warning will hopefully nudge the user into updating their
    DT to a fixed version if they can, but the incentive is
    obviously pretty small.

    Fixes: 2f96593ecc37 ("of_address: Add bus type match for pci ranges parser")
    Suggested-by: Rob Herring
    Signed-off-by: Marc Zyngier
    Link: https://lore.kernel.org/r/20200819094255.474565-1-maz@kernel.org
    Signed-off-by: Rob Herring

    Marc Zyngier
     

18 Aug, 2020

1 commit

  • Currently invalid CPU addresses are not being sanity checked resulting in
    SATA setup failure on a SynQuacer SC2A11 development machine. The original
    check was removed by and earlier commit, so add a sanity check back in
    to avoid this regression.

    Fixes: 7a8b64d17e35 ("of/address: use range parser for of_dma_get_range")
    Signed-off-by: Colin Ian King
    Link: https://lore.kernel.org/r/20200817113208.523805-1-colin.king@canonical.com
    Signed-off-by: Rob Herring

    Colin Ian King
     

07 Aug, 2020

1 commit

  • Pull MIPS upates from Thomas Bogendoerfer:

    - improvements for Loongson64

    - extended ingenic support

    - removal of not maintained paravirt system type

    - cleanups and fixes

    * tag 'mips_5.9' of git://git.kernel.org/pub/scm/linux/kernel/git/mips/linux: (81 commits)
    MIPS: SGI-IP27: always enable NUMA in Kconfig
    MAINTAINERS: Update KVM/MIPS maintainers
    MIPS: Update default config file for Loongson-3
    MIPS: KVM: Add kvm guest support for Loongson-3
    dt-bindings: mips: Document Loongson kvm guest board
    MIPS: handle Loongson-specific GSExc exception
    MIPS: add definitions for Loongson-specific CP0.Diag1 register
    MIPS: only register FTLBPar exception handler for supported models
    MIPS: ingenic: Hardcode mem size for qi,lb60 board
    MIPS: DTS: ingenic/qi,lb60: Add model and memory node
    MIPS: ingenic: Use fw_passed_dtb even if CONFIG_BUILTIN_DTB
    MIPS: head.S: Init fw_passed_dtb to builtin DTB
    of: address: Fix parser address/size cells initialization
    of_address: Guard of_bus_pci_get_flags with CONFIG_PCI
    MIPS: DTS: Fix number of msi vectors for Loongson64G
    MIPS: Loongson64: Add ISA node for LS7A PCH
    MIPS: Loongson64: DTS: Fix ISA and PCI I/O ranges for RS780E PCH
    MIPS: Loongson64: Enlarge IO_SPACE_LIMIT
    MIPS: Loongson64: Process ISA Node in DeviceTree
    of_address: Add bus type match for pci ranges parser
    ...

    Linus Torvalds
     

31 Jul, 2020

2 commits

  • bus->count_cells() parses cells starting from the node's parent. This is
    not good enough for parser_init() which is generally parsing a bus node.

    Revert to previous behavior using of_bus_n_*_cells().

    Fixes: 2f96593ecc37 ("of_address: Add bus type match for pci ranges parser")
    Reported-by: Nathan Chancellor
    Signed-off-by: Nicolas Saenz Julienne
    Acked-by: Rob Herring
    Signed-off-by: Thomas Bogendoerfer

    Nicolas Saenz Julienne
     
  • After 2f96593ecc37 ("of_address: Add bus type match for pci ranges parser"),
    the last user of of_bus_pci_get_flags when CONFIG_PCI is disabled had gone.

    This caused unused function warning when compiling without CONFIG_PCI.
    Fix by guarding it with CONFIG_PCI.

    Signed-off-by: Jiaxun Yang
    Reported-by: Stephen Rothwell
    Fixes: 2f96593ecc37 ("of_address: Add bus type match for pci ranges parser")
    Acked-by: Rob Herring
    Signed-off-by: Thomas Bogendoerfer

    Jiaxun Yang
     

29 Jul, 2020

1 commit


16 Jul, 2020

1 commit


15 Feb, 2020

4 commits

  • Currently, the DMA offset and mask for a device are set based only on the
    first 'dma-ranges' entry. We should really be using all the entries. The
    kernel doesn't yet support multiple offsets and sizes, so the best we can
    do is to find the biggest size for a single offset. The algorithm is
    copied from acpi_dma_get_range().

    If there's different offsets from the first entry, then we warn and
    continue. It really should be an error, but this will likely break
    existing DTs.

    Signed-off-by: Rob Herring

    Rob Herring
     
  • of_dma_get_range() does the same ranges parsing as
    of_pci_range_parser_one(), so let's refactor of_dma_get_range() to use
    it instead.

    This commit is no functional change. Subsequent commits will parse more
    than the 1st dma-ranges entry.

    Signed-off-by: Rob Herring

    Rob Herring
     
  • The only PCI specific part of of_pci_range_parser_one() is the handling
    of the 3rd address cell. Rework it to work on regular 1 and 2 cell
    addresses.

    Use defines and a union to avoid a treewide renaming of the parsing
    helpers and struct.

    Signed-off-by: Rob Herring

    Rob Herring
     
  • There's no more users of struct of_pci_range.pci_space field, so remove it.

    Signed-off-by: Rob Herring

    Rob Herring
     

14 Feb, 2020

1 commit


28 Jan, 2020

1 commit

  • There's an OF helper called of_dma_is_coherent(), which checks if a
    device has a "dma-coherent" property to see if the device is coherent
    for DMA.

    But on some platforms devices are coherent by default, and on some
    platforms it's not possible to update existing device trees to add the
    "dma-coherent" property.

    So add a Kconfig symbol to allow arch code to tell
    of_dma_is_coherent() that devices are coherent by default, regardless
    of the presence of the property.

    Select that symbol on powerpc when NOT_COHERENT_CACHE is not set, ie.
    when the system has a coherent cache.

    Fixes: 92ea637edea3 ("of: introduce of_dma_is_coherent() helper")
    Cc: stable@vger.kernel.org # v3.16+
    Reported-by: Christian Zigotzky
    Tested-by: Christian Zigotzky
    Signed-off-by: Michael Ellerman
    Reviewed-by: Ulf Hansson
    Signed-off-by: Rob Herring

    Michael Ellerman
     

10 Oct, 2019

1 commit

  • Since the "dma-ranges" property is only valid for a node representing a
    bus, of_dma_get_range() currently assumes the node passed in is a leaf
    representing a device, and starts the walk from its parent. In cases
    like PCI host controllers on typical FDT systems, however, where the PCI
    endpoints are probed dynamically the initial leaf node represents the
    'bus' itself, and this logic means we fail to consider any "dma-ranges"
    describing the host bridge itself. Rework the logic such that
    of_dma_get_range() also works correctly starting from a bus node
    containing "dma-ranges".

    While this does mean "dma-ranges" could incorrectly be in a device leaf
    node, there isn't really any way in this function to ensure that a leaf
    node is or isn't a bus node.

    Signed-off-by: Robin Murphy
    [robh: Allow for the bus child node to still be passed in]
    Signed-off-by: Rob Herring
    Reviewed-by: Robin Murphy
    Reviewed-by: Nicolas Saenz Julienne
    Tested-by: Nicolas Saenz Julienne

    Robin Murphy
     

09 Oct, 2019

8 commits

  • of_pci_range_parser_one() has a bug when parsing dma-ranges. When it
    translates the parent address (aka cpu address in the code), 'ranges' is
    always being used. This happens to work because most users are just 1:1
    translation.

    Cc: Robin Murphy
    Tested-by: Nicolas Saenz Julienne
    Reviewed-by: Nicolas Saenz Julienne
    Signed-off-by: Rob Herring

    Rob Herring
     
  • 'dma-ranges' frequently exists without parent nodes having 'dma-ranges'.
    While this is an error for 'ranges', this is fine because DMA capable
    devices always have a translatable DMA address. Also, with no
    'dma-ranges' at all, the assumption is that DMA addresses are 1:1 with
    no restrictions unless perhaps the device itself has implicit
    restrictions.

    Cc: Robin Murphy
    Tested-by: Nicolas Saenz Julienne
    Reviewed-by: Nicolas Saenz Julienne
    Signed-off-by: Rob Herring

    Rob Herring
     
  • In some cases such as PCI host controllers, we may have a "parent bus"
    which is an OF leaf node, but still need to correctly parse ranges from
    the point of view of that bus. For that, factor out variants of the
    "#addr-cells" and "#size-cells" parsers which do not assume they have a
    device node and thus immediately traverse upwards before reading the
    relevant property.

    Signed-off-by: Robin Murphy
    [robh: don't make of_bus_n_{addr,size}_cells() public]
    Reviewed-by: Geert Uytterhoeven
    Tested-by: Nicolas Saenz Julienne
    Reviewed-by: Nicolas Saenz Julienne
    Signed-off-by: Rob Herring

    Robin Murphy
     
  • Much like for address translation, when checking for DMA coherence we
    should be sure to walk up the DMA hierarchy, rather than the MMIO one,
    now that we can accommodate them being different.

    Signed-off-by: Robin Murphy
    Tested-by: Nicolas Saenz Julienne
    Reviewed-by: Nicolas Saenz Julienne
    Signed-off-by: Rob Herring

    Robin Murphy
     
  • Add of_get_next_dma_parent() helper which is similar to
    __of_get_dma_parent(), but can be used in iterators and decrements the
    ref count on the prior parent.

    Signed-off-by: Robin Murphy
    Reviewed-by: Geert Uytterhoeven
    Tested-by: Nicolas Saenz Julienne
    Reviewed-by: Nicolas Saenz Julienne
    Signed-off-by: Rob Herring

    Robin Murphy
     
  • If we failed to translate a DMA address, at least show the offending
    address rather than the uninitialised contents of the destination
    argument.

    Signed-off-by: Robin Murphy
    Reviewed-by: Geert Uytterhoeven
    Tested-by: Nicolas Saenz Julienne
    Reviewed-by: Nicolas Saenz Julienne
    Reviewed-by: Christoph Hellwig
    Signed-off-by: Rob Herring

    Robin Murphy
     
  • of_dma_get_range() is only used within the DT core code, so remove the
    export and move the header declaration to the private header.

    Cc: Robin Murphy
    Reviewed-by: Geert Uytterhoeven
    Tested-by: Nicolas Saenz Julienne
    Reviewed-by: Nicolas Saenz Julienne
    Reviewed-by: Christoph Hellwig
    Signed-off-by: Rob Herring

    Rob Herring
     
  • of_find_matching_node_by_address() is unused, so remove it.

    Cc: Robin Murphy
    Reviewed-by: Geert Uytterhoeven
    Reviewed-by: Christoph Hellwig
    Tested-by: Nicolas Saenz Julienne
    Reviewed-by: Nicolas Saenz Julienne
    Signed-off-by: Rob Herring

    Rob Herring
     

11 Apr, 2019

2 commits

  • Some SoCs have devices that are using a separate bus from the main bus to
    perform DMA.

    These buses might have some restrictions and/or different mapping than from
    the CPU side, so we'd need to express those using the usual dma-ranges, but
    using a different DT node than the node's parent.

    Now that the generic interconnect bindings are available, we can model an
    interconnect with the reserved name "dma-mem" for those use-cases.

    Reviewed-by: Robin Murphy
    Signed-off-by: Maxime Ripard
    Signed-off-by: Rob Herring

    Maxime Ripard
     
  • The __of_translate_address function is used to translate the device tree
    addresses to physical addresses using the various ranges property to create
    the offset.

    However, it's shared between the CPU addresses (based on the ranges
    property) and the DMA addresses (based on dma-ranges). Since we're going to
    add support for a DMA parent node that is not the DT parent node, we need
    to change the logic a bit to have a callback function that will retrieve
    the parent node we should use.

    Reviewed-by: Robin Murphy
    Signed-off-by: Maxime Ripard
    Signed-off-by: Rob Herring

    Maxime Ripard
     

06 Dec, 2018

1 commit


28 Nov, 2018

1 commit


10 Jul, 2018

1 commit


04 Apr, 2018

2 commits

  • There are some special ISA/LPC devices that work on a specific I/O range
    where it is not correct to specify a 'ranges' property in the DTS parent
    node as CPU addresses translated from DTS node are only for memory space on
    some architectures, such as ARM64. Without the parent 'ranges' property,
    of_translate_address() returns an error.

    Here we add special handling for this case.

    During the OF address translation, some checking will be performed to
    identify whether the device node is registered as indirect-IO. If it is,
    the I/O translation will be done in a different way from that one of PCI
    MMIO. In this way, the I/O 'reg' property of the special ISA/LPC devices
    will be parsed correctly.

    Tested-by: dann frazier
    Signed-off-by: Zhichang Yuan
    Signed-off-by: Gabriele Paoloni
    Signed-off-by: Arnd Bergmann # earlier draft
    Signed-off-by: Bjorn Helgaas
    Reviewed-by: Andy Shevchenko
    Acked-by: Rob Herring

    Zhichang Yuan
     
  • In preparation for having the PCI MMIO helpers use the new generic I/O
    space management (logical PIO) we need to add the fwnode handler as an
    extra input parameter.

    Changes the signature of pci_register_io_range() and its callers as
    needed.

    Tested-by: dann frazier
    Signed-off-by: Gabriele Paoloni
    Signed-off-by: Bjorn Helgaas
    Reviewed-by: Andy Shevchenko
    Acked-by: Rob Herring

    Gabriele Paoloni
     

07 Feb, 2018

1 commit

  • Pull PCI updates from Bjorn Helgaas:

    - skip AER driver error recovery callbacks for correctable errors
    reported via ACPI APEI, as we already do for errors reported via the
    native path (Tyler Baicar)

    - fix DPC shared interrupt handling (Alex Williamson)

    - print full DPC interrupt number (Keith Busch)

    - enable DPC only if AER is available (Keith Busch)

    - simplify DPC code (Bjorn Helgaas)

    - calculate ASPM L1 substate parameter instead of hardcoding it (Bjorn
    Helgaas)

    - enable Latency Tolerance Reporting for ASPM L1 substates (Bjorn
    Helgaas)

    - move ASPM internal interfaces out of public header (Bjorn Helgaas)

    - allow hot-removal of VGA devices (Mika Westerberg)

    - speed up unplug and shutdown by assuming Thunderbolt controllers
    don't support Command Completed events (Lukas Wunner)

    - add AtomicOps support for GPU and Infiniband drivers (Felix Kuehling,
    Jay Cornwall)

    - expose "ari_enabled" in sysfs to help NIC naming (Stuart Hayes)

    - clean up PCI DMA interface usage (Christoph Hellwig)

    - remove PCI pool API (replaced with DMA pool) (Romain Perier)

    - deprecate pci_get_bus_and_slot(), which assumed PCI domain 0 (Sinan
    Kaya)

    - move DT PCI code from drivers/of/ to drivers/pci/ (Rob Herring)

    - add PCI-specific wrappers for dev_info(), etc (Frederick Lawler)

    - remove warnings on sysfs mmap failure (Bjorn Helgaas)

    - quiet ROM validation messages (Alex Deucher)

    - remove redundant memory alloc failure messages (Markus Elfring)

    - fill in types for compile-time VGA and other I/O port resources
    (Bjorn Helgaas)

    - make "pci=pcie_scan_all" work for Root Ports as well as Downstream
    Ports to help AmigaOne X1000 (Bjorn Helgaas)

    - add SPDX tags to all PCI files (Bjorn Helgaas)

    - quirk Marvell 9128 DMA aliases (Alex Williamson)

    - quirk broken INTx disable on Ceton InfiniTV4 (Bjorn Helgaas)

    - fix CONFIG_PCI=n build by adding dummy pci_irqd_intx_xlate() (Niklas
    Cassel)

    - use DMA API to get MSI address for DesignWare IP (Niklas Cassel)

    - fix endpoint-mode DMA mask configuration (Kishon Vijay Abraham I)

    - fix ARTPEC-6 incorrect IS_ERR() usage (Wei Yongjun)

    - add support for ARTPEC-7 SoC (Niklas Cassel)

    - add endpoint-mode support for ARTPEC (Niklas Cassel)

    - add Cadence PCIe host and endpoint controller driver (Cyrille
    Pitchen)

    - handle multiple INTx status bits being set in dra7xx (Vignesh R)

    - translate dra7xx hwirq range to fix INTD handling (Vignesh R)

    - remove deprecated Exynos PHY initialization code (Jaehoon Chung)

    - fix MSI erratum workaround for HiSilicon Hip06/Hip07 (Dongdong Liu)

    - fix NULL pointer dereference in iProc BCMA driver (Ray Jui)

    - fix Keystone interrupt-controller-node lookup (Johan Hovold)

    - constify qcom driver structures (Julia Lawall)

    - rework Tegra config space mapping to increase space available for
    endpoints (Vidya Sagar)

    - simplify Tegra driver by using bus->sysdata (Manikanta Maddireddy)

    - remove PCI_REASSIGN_ALL_BUS usage on Tegra (Manikanta Maddireddy)

    - add support for Global Fabric Manager Server (GFMS) event to
    Microsemi Switchtec switch driver (Logan Gunthorpe)

    - add IDs for Switchtec PSX 24xG3 and PSX 48xG3 (Kelvin Cao)

    * tag 'pci-v4.16-changes' of git://git.kernel.org/pub/scm/linux/kernel/git/helgaas/pci: (140 commits)
    PCI: cadence: Add EndPoint Controller driver for Cadence PCIe controller
    dt-bindings: PCI: cadence: Add DT bindings for Cadence PCIe endpoint controller
    PCI: endpoint: Fix EPF device name to support multi-function devices
    PCI: endpoint: Add the function number as argument to EPC ops
    PCI: cadence: Add host driver for Cadence PCIe controller
    dt-bindings: PCI: cadence: Add DT bindings for Cadence PCIe host controller
    PCI: Add vendor ID for Cadence
    PCI: Add generic function to probe PCI host controllers
    PCI: generic: fix missing call of pci_free_resource_list()
    PCI: OF: Add generic function to parse and allocate PCI resources
    PCI: Regroup all PCI related entries into drivers/pci/Makefile
    PCI/DPC: Reformat DPC register definitions
    PCI/DPC: Add and use DPC Status register field definitions
    PCI/DPC: Squash dpc_rp_pio_get_info() into dpc_process_rp_pio_error()
    PCI/DPC: Remove unnecessary RP PIO register structs
    PCI/DPC: Push dpc->rp_pio_status assignment into dpc_rp_pio_get_info()
    PCI/DPC: Squash dpc_rp_pio_print_error() into dpc_rp_pio_get_info()
    PCI/DPC: Make RP PIO log size check more generic
    PCI/DPC: Rename local "status" to "dpc_status"
    PCI/DPC: Squash dpc_rp_pio_print_tlp_header() into dpc_rp_pio_print_error()
    ...

    Linus Torvalds
     

02 Feb, 2018

1 commit


18 Jan, 2018

1 commit

  • Following what has been done for other subsystems, move the remaining PCI
    related code out of drivers/of/ and into drivers/pci/of.c

    With this, we can kill a few kconfig symbols.

    Signed-off-by: Rob Herring
    [bhelgaas: minor whitespace, comment cleanups]
    Signed-off-by: Bjorn Helgaas
    Cc: Frank Rowand

    Rob Herring
     

16 Jan, 2018

1 commit

  • Some PCIe host drivers parse of_pci_range from device tree and convert
    it to resources. Export of_pci_range_to_resource() to allow PCIe host
    drivers to be compiled as loadable kernel module.

    Signed-off-by: Manikanta Maddireddy
    [lorenzo.pieralisi@arm.com: rewrote commit log]
    Signed-off-by: Lorenzo Pieralisi
    Acked-by: Rob Herring

    Manikanta Maddireddy
     

08 Jan, 2018

1 commit

  • Convert remaining DT files to use SPDX-License-Identifier tags.

    Cc: Benjamin Herrenschmidt
    Cc: Guennadi Liakhovetski
    Cc: Paul Mackerras
    Cc: Pantelis Antoniou
    Reviewed-by: Frank Rowand
    Reviewed-by: Philippe Ombredanne
    Signed-off-by: Rob Herring

    Rob Herring
     

06 Oct, 2017

1 commit


21 Jul, 2017

1 commit

  • It was never used and could be removed, otherwise
    we could see a warning:

    drivers/of/address.c: In function 'of_pci_range_parser_one':
    drivers/of/address.c:277:14: warning: variable 'pci_space' set but not
    used [-Wunused-but-set-variable]

    Signed-off-by: Shawn Lin
    Signed-off-by: Rob Herring

    Shawn Lin
     

19 Jul, 2017

1 commit