06 Jan, 2020

1 commit


12 Nov, 2019

4 commits

  • A lot of architectures reuse the same simple ioremap implementation, so
    start lifting the most simple variant to lib/ioremap.c. It provides
    ioremap_prot and iounmap, plus a default ioremap that uses prot_noncached,
    although that can be overridden by asm/io.h.

    Signed-off-by: Christoph Hellwig
    Reviewed-by: Arnd Bergmann
    Reviewed-by: Palmer Dabbelt

    Christoph Hellwig
     
  • Various architectures that use asm-generic/io.h still defined their
    own default versions of ioremap_nocache, ioremap_wt and ioremap_wc
    that point back to plain ioremap directly or indirectly. Remove these
    definitions and rely on asm-generic/io.h instead. For this to work
    the backup ioremap_* defintions needs to be changed to purely cpp
    macros instea of inlines to cover for architectures like openrisc
    that only define ioremap after including .

    Signed-off-by: Christoph Hellwig
    Reviewed-by: Arnd Bergmann
    Reviewed-by: Palmer Dabbelt

    Christoph Hellwig
     
  • All MMU-enabled ports have a non-trivial ioremap and should thus provide
    the prototype for their implementation instead of providing a generic
    one unless a different symbol is not defined. Note that this only
    affects sparc32 nds32 as all others do provide their own version.

    Also update the kerneldoc comments in asm-generic/io.h to explain the
    situation around the default ioremap* implementations correctly.

    Signed-off-by: Christoph Hellwig
    Reviewed-by: Arnd Bergmann

    Christoph Hellwig
     
  • Whatever reason there is for the existence of ioremap_uc, and the fact
    that it returns NULL by default on architectures with an MMU applies
    equally to nommu architectures, so don't provide different defaults.

    In practice the difference is meaningless as the only portable driver
    that uses ioremap_uc is atyfb which probably doesn't show up on nommu
    devices.

    Signed-off-by: Christoph Hellwig
    Reviewed-by: Arnd Bergmann
    Reviewed-by: Palmer Dabbelt

    Christoph Hellwig
     

31 Aug, 2019

1 commit

  • __ioremap is not a kernel API, but used for helpers with differing
    semantics in arch code. We should not provide it in as-generic.

    Signed-off-by: Christoph Hellwig
    Reviewed-by: Paul Walmsley
    Tested-by: Paul Walmsley # rv32, rv64 boot
    Acked-by: Paul Walmsley # arch/riscv
    Signed-off-by: Arnd Bergmann

    Christoph Hellwig
     

24 May, 2019

1 commit

  • Based on 1 normalized pattern(s):

    this program is free software you can redistribute it and or modify
    it under the terms of the gnu general public licence as published by
    the free software foundation either version 2 of the licence or at
    your option any later version

    extracted by the scancode license scanner the SPDX license identifier

    GPL-2.0-or-later

    has been chosen to replace the boilerplate/reference in 114 file(s).

    Signed-off-by: Thomas Gleixner
    Reviewed-by: Allison Randal
    Reviewed-by: Kate Stewart
    Cc: linux-spdx@vger.kernel.org
    Link: https://lkml.kernel.org/r/20190520170857.552531963@linutronix.de
    Signed-off-by: Greg Kroah-Hartman

    Thomas Gleixner
     

08 Apr, 2019

2 commits


01 Mar, 2019

1 commit

  • The inX() and readX() I/O accessors must enforce ordering against
    subsequent calls to the delay() routines, so that a read-back from a
    device can be used to postpone a subsequent write to the same device.

    On some architectures, including arm64, this ordering can only be
    achieved by creating a dependency on the value returned by the I/O
    accessor operation, so we need to pass the value we read to the
    __io_par() and __io_ar() macros in these cases.

    Acked-by: Arnd Bergmann
    Reported-by: Andrew Murray
    Reviewed-by: Palmer Dabbelt
    Signed-off-by: Will Deacon
    Signed-off-by: Catalin Marinas

    Will Deacon
     

14 Sep, 2018

1 commit

  • The !CONFIG_GENERIC_IOMAP version of ioport_map uses MMIO_UPPER_LIMIT to
    prevent users from making I/O accesses outside the expected I/O range -
    however it erroneously treats MMIO_UPPER_LIMIT as a mask which is
    contradictory to its other users.

    The introduction of CONFIG_INDIRECT_PIO, which subtracts an arbitrary
    amount from IO_SPACE_LIMIT to form MMIO_UPPER_LIMIT, results in ioport_map
    mangling the given port rather than capping it.

    We address this by aligning more closely with the CONFIG_GENERIC_IOMAP
    implementation of ioport_map by using the comparison operator and
    returning NULL where the port exceeds MMIO_UPPER_LIMIT. Though note that
    we preserve the existing behavior of masking with IO_SPACE_LIMIT such that
    we don't break existing buggy drivers that somehow rely on this masking.

    Fixes: 5745392e0c2b ("PCI: Apply the new generic I/O management on PCI IO hosts")
    Reported-by: Will Deacon
    Reviewed-by: Arnd Bergmann
    Signed-off-by: Andrew Murray
    Signed-off-by: Will Deacon

    Andrew Murray
     

13 Apr, 2018

1 commit

  • Pull asm-generic fixes from Arnd Bergmann:
    "I have one regression fix for a minor build problem after the
    architecture removal series, plus a rework of the barriers in the
    readl/writel functions, thanks to work by Sinan Kaya:

    This started from a discussion on the linuxpcc and rdma mailing
    lists[1]. To summarize, we decided that architectures are responsible
    to serialize readl() and writel() accesses on a device MMIO space
    relative to DMA performed by that device.

    This series provides a pessimistic implementation of that behavior for
    asm-generic/io.h, which is in turn used by a number of architectures
    (h8300, microblaze, nios2, openrisc, s390, sparc, um, unicore32, and
    xtensa). Some of those presumably need no extra barriers, or something
    weaker than rmb()/wmb(), and they are advised to override the new
    default for better performance.

    For inb()/outb(), the same barriers are used, but architectures might
    want to add another barrier to outb() here if that can guarantee
    non-posted behavior (some architectures can, others cannot do that).

    The readl_relaxed()/writel_relaxed() family of functions retains the
    existing behavior with no extra barriers"

    [1] https://lists.ozlabs.org/pipermail/linuxppc-dev/2018-March/170481.html

    * tag 'asm-generic' of git://git.kernel.org/pub/scm/linux/kernel/git/arnd/asm-generic:
    io: change writeX_relaxed() to remove barriers
    io: change readX_relaxed() to remove barriers
    dts: remove cris & metag dts hard link file
    io: change inX() to have their own IO barrier overrides
    io: change outX() to have their own IO barrier overrides
    io: define stronger ordering for the default writeX() implementation
    io: define stronger ordering for the default readX() implementation
    io: define several IO & PIO barrier types for the asm-generic version

    Linus Torvalds
     

10 Apr, 2018

2 commits

  • Now that we hardened writeX() API in asm-generic version, writeX_relaxed()
    API is violating the rules when writeX_relaxed() == writeX() in the default
    implementation.

    The relaxed API shouldn't have any barriers in it and it doesn't provide
    any ordering with respect to the memory transactions. The only requirement
    is for writes to be ordered with respect to each other. This is achieved
    by the volatile in the __raw_writeX() API.

    Open code the relaxed API and remove any barriers in it.

    Signed-off-by: Sinan Kaya
    Signed-off-by: Arnd Bergmann

    Sinan Kaya
     
  • Now that we hardened readX() API in asm-generic version, readX_relaxed()
    API is violating the rules when readX_relaxed() == readX() in the default
    implementation.

    The relaxed API shouldn't have any barriers in it and it doesn't provide
    any ordering with respect to the memory transactions. The only requirement
    is for reads to be ordered with respect to each other. This is achieved
    by the volatile in the __raw_readX() API.

    Open code the relaxed API and remove any barriers in it.

    Signed-off-by: Sinan Kaya
    Signed-off-by: Arnd Bergmann

    Sinan Kaya
     

07 Apr, 2018

1 commit

  • Pull PCI updates from Bjorn Helgaas:

    - move pci_uevent_ers() out of pci.h (Michael Ellerman)

    - skip ASPM common clock warning if BIOS already configured it (Sinan
    Kaya)

    - fix ASPM Coverity warning about threshold_ns (Gustavo A. R. Silva)

    - remove last user of pci_get_bus_and_slot() and the function itself
    (Sinan Kaya)

    - add decoding for 16 GT/s link speed (Jay Fang)

    - add interfaces to get max link speed and width (Tal Gilboa)

    - add pcie_bandwidth_capable() to compute max supported link bandwidth
    (Tal Gilboa)

    - add pcie_bandwidth_available() to compute bandwidth available to
    device (Tal Gilboa)

    - add pcie_print_link_status() to log link speed and whether it's
    limited (Tal Gilboa)

    - use PCI core interfaces to report when device performance may be
    limited by its slot instead of doing it in each driver (Tal Gilboa)

    - fix possible cpqphp NULL pointer dereference (Shawn Lin)

    - rescan more of the hierarchy on ACPI hotplug to fix Thunderbolt/xHCI
    hotplug (Mika Westerberg)

    - add support for PCI I/O port space that's neither directly accessible
    via CPU in/out instructions nor directly mapped into CPU physical
    memory space. This is fairly intrusive and includes minor changes to
    interfaces used for I/O space on most platforms (Zhichang Yuan, John
    Garry)

    - add support for HiSilicon Hip06/Hip07 LPC I/O space (Zhichang Yuan,
    John Garry)

    - use PCI_EXP_DEVCTL2_COMP_TIMEOUT in rapidio/tsi721 (Bjorn Helgaas)

    - remove possible NULL pointer dereference in of_pci_bus_find_domain_nr()
    (Shawn Lin)

    - report quirk timings with dev_info (Bjorn Helgaas)

    - report quirks that take longer than 10ms (Bjorn Helgaas)

    - add and use Altera Vendor ID (Johannes Thumshirn)

    - tidy Makefiles and comments (Bjorn Helgaas)

    - don't set up INTx if MSI or MSI-X is enabled to align cris, frv,
    ia64, and mn10300 with x86 (Bjorn Helgaas)

    - move pcieport_if.h to drivers/pci/pcie/ to encapsulate it (Frederick
    Lawler)

    - merge pcieport_if.h into portdrv.h (Bjorn Helgaas)

    - move workaround for BIOS PME issue from portdrv to PCI core (Bjorn
    Helgaas)

    - completely disable portdrv with "pcie_ports=compat" (Bjorn Helgaas)

    - remove portdrv link order dependency (Bjorn Helgaas)

    - remove support for unused VC portdrv service (Bjorn Helgaas)

    - simplify portdrv feature permission checking (Bjorn Helgaas)

    - remove "pcie_hp=nomsi" parameter (use "pci=nomsi" instead) (Bjorn
    Helgaas)

    - remove unnecessary "pcie_ports=auto" parameter (Bjorn Helgaas)

    - use cached AER capability offset (Frederick Lawler)

    - don't enable DPC if BIOS hasn't granted AER control (Mika Westerberg)

    - rename pcie-dpc.c to dpc.c (Bjorn Helgaas)

    - use generic pci_mmap_resource_range() instead of powerpc and xtensa
    arch-specific versions (David Woodhouse)

    - support arbitrary PCI host bridge offsets on sparc (Yinghai Lu)

    - remove System and Video ROM reservations on sparc (Bjorn Helgaas)

    - probe for device reset support during enumeration instead of runtime
    (Bjorn Helgaas)

    - add ACS quirk for Ampere (née APM) root ports (Feng Kan)

    - add function 1 DMA alias quirk for Marvell 88SE9220 (Thomas
    Vincent-Cross)

    - protect device restore with device lock (Sinan Kaya)

    - handle failure of FLR gracefully (Sinan Kaya)

    - handle CRS (config retry status) after device resets (Sinan Kaya)

    - skip various config reads for SR-IOV VFs as an optimization
    (KarimAllah Ahmed)

    - consolidate VPD code in vpd.c (Bjorn Helgaas)

    - add Tegra dependency on PCI_MSI_IRQ_DOMAIN (Arnd Bergmann)

    - add DT support for R-Car r8a7743 (Biju Das)

    - fix a PCI_EJECT vs PCI_BUS_RELATIONS race condition in Hyper-V host
    bridge driver that causes a general protection fault (Dexuan Cui)

    - fix Hyper-V host bridge hang in MSI setup on 1-vCPU VMs with SR-IOV
    (Dexuan Cui)

    - fix Hyper-V host bridge hang when ejecting a VF before setting up MSI
    (Dexuan Cui)

    - make several structures static (Fengguang Wu)

    - increase number of MSI IRQs supported by Synopsys DesignWare bridges
    from 32 to 256 (Gustavo Pimentel)

    - implemented multiplexed IRQ domain API and remove obsolete MSI IRQ
    API from DesignWare drivers (Gustavo Pimentel)

    - add Tegra power management support (Manikanta Maddireddy)

    - add Tegra loadable module support (Manikanta Maddireddy)

    - handle 64-bit BARs correctly in endpoint support (Niklas Cassel)

    - support optional regulator for HiSilicon STB (Shawn Guo)

    - use regulator bulk API for Qualcomm apq8064 (Srinivas Kandagatla)

    - support power supplies for Qualcomm msm8996 (Srinivas Kandagatla)

    * tag 'pci-v4.17-changes' of git://git.kernel.org/pub/scm/linux/kernel/git/helgaas/pci: (123 commits)
    MAINTAINERS: Add John Garry as maintainer for HiSilicon LPC driver
    HISI LPC: Add ACPI support
    ACPI / scan: Do not enumerate Indirect IO host children
    ACPI / scan: Rename acpi_is_serial_bus_slave() for more general use
    HISI LPC: Support the LPC host on Hip06/Hip07 with DT bindings
    of: Add missing I/O range exception for indirect-IO devices
    PCI: Apply the new generic I/O management on PCI IO hosts
    PCI: Add fwnode handler as input param of pci_register_io_range()
    PCI: Remove __weak tag from pci_register_io_range()
    MAINTAINERS: Add missing /drivers/pci/cadence directory entry
    fm10k: Report PCIe link properties with pcie_print_link_status()
    net/mlx5e: Use pcie_bandwidth_available() to compute bandwidth
    net/mlx5: Report PCIe link properties with pcie_print_link_status()
    net/mlx4_core: Report PCIe link properties with pcie_print_link_status()
    PCI: Add pcie_print_link_status() to log link speed and whether it's limited
    PCI: Add pcie_bandwidth_available() to compute bandwidth available to device
    misc: pci_endpoint_test: Handle 64-bit BARs properly
    PCI: designware-ep: Make dw_pcie_ep_reset_bar() handle 64-bit BARs properly
    PCI: endpoint: Make sure that BAR_5 does not have 64-bit flag set when clearing
    PCI: endpoint: Make epc->ops->clear_bar()/pci_epc_clear_bar() take struct *epf_bar
    ...

    Linus Torvalds
     

06 Apr, 2018

5 commits

  • Open code readX() inside inX() so that inX() variants have their own
    overrideable Port IO barrier combinations as __io_pbr() and __io_par() for
    actions to be taken before port IO and after port IO read.

    Signed-off-by: Sinan Kaya
    Signed-off-by: Arnd Bergmann

    Sinan Kaya
     
  • Open code writeX() inside outX() so that outX() variants have their own
    overrideable Port IO barrier combinations as __io_pbw() and __io_paw() for
    actions to be taken before port IO and after port IO write.

    Signed-off-by: Sinan Kaya
    Signed-off-by: Arnd Bergmann

    Sinan Kaya
     
  • The default implementation of mapping writeX() to __raw_writeX() is wrong.
    writeX() has stronger ordering semantics. Compiler is allowed to reorder
    memory writes against __raw_writeX().

    Use the previously defined __io_aw() and __io_bw() macros to harden
    code generation according to architecture support.

    Signed-off-by: Sinan Kaya
    Signed-off-by: Arnd Bergmann

    Sinan Kaya
     
  • The default implementation of mapping readX() to __raw_readX() is wrong.
    readX() has stronger ordering semantics. Compiler is allowed to reorder
    __raw_readX() against the memory accesses following register read.

    Use the previously defined __io_ar() and __io_br() macros to harden
    code generation according to architecture support.

    Signed-off-by: Sinan Kaya
    Signed-off-by: Arnd Bergmann

    Sinan Kaya
     
  • Getting ready to harden readX()/writeX() and inX()/outX() semantics for the
    generic implementation.

    Defining two set of macros as __io_br() and __io_ar() to indicate actions
    to be taken before and after MMIO read.

    Defining two set of macros as __io_bw() and __io_aw() to indicate actions
    to be taken before and after MMIO write.

    Defining two set of macros as __io_pbw() and __io_paw() to indicate actions
    to be taken before and after Port IO write.

    Defining two set of macros as __io_pbr() and __io_par() to indicate actions
    to be taken before and after Port IO read.

    If rmb() is available for the architecture, prefer rmb() as the default
    implementation of __io_ar()/__io_par().

    If wmb() is available for the architecture, prefer wmb() as the default
    implementation of __io_bw()/__io_pbw().

    Signed-off-by: Sinan Kaya
    Signed-off-by: Arnd Bergmann

    Sinan Kaya
     

04 Apr, 2018

1 commit

  • After introducing the new generic I/O space management (Logical PIO), the
    original PCI MMIO relevant helpers need to be updated based on the new
    interfaces defined in logical PIO.

    Adapt the corresponding code to match the changes introduced by logical
    PIO.

    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

    Zhichang Yuan
     

03 Apr, 2018

1 commit

  • Pul removal of obsolete architecture ports from Arnd Bergmann:
    "This removes the entire architecture code for blackfin, cris, frv,
    m32r, metag, mn10300, score, and tile, including the associated device
    drivers.

    I have been working with the (former) maintainers for each one to
    ensure that my interpretation was right and the code is definitely
    unused in mainline kernels. Many had fond memories of working on the
    respective ports to start with and getting them included in upstream,
    but also saw no point in keeping the port alive without any users.

    In the end, it seems that while the eight architectures are extremely
    different, they all suffered the same fate: There was one company in
    charge of an SoC line, a CPU microarchitecture and a software
    ecosystem, which was more costly than licensing newer off-the-shelf
    CPU cores from a third party (typically ARM, MIPS, or RISC-V). It
    seems that all the SoC product lines are still around, but have not
    used the custom CPU architectures for several years at this point. In
    contrast, CPU instruction sets that remain popular and have actively
    maintained kernel ports tend to all be used across multiple licensees.

    [ See the new nds32 port merged in the previous commit for the next
    generation of "one company in charge of an SoC line, a CPU
    microarchitecture and a software ecosystem" - Linus ]

    The removal came out of a discussion that is now documented at
    https://lwn.net/Articles/748074/. Unlike the original plans, I'm not
    marking any ports as deprecated but remove them all at once after I
    made sure that they are all unused. Some architectures (notably tile,
    mn10300, and blackfin) are still being shipped in products with old
    kernels, but those products will never be updated to newer kernel
    releases.

    After this series, we still have a few architectures without mainline
    gcc support:

    - unicore32 and hexagon both have very outdated gcc releases, but the
    maintainers promised to work on providing something newer. At least
    in case of hexagon, this will only be llvm, not gcc.

    - openrisc, risc-v and nds32 are still in the process of finishing
    their support or getting it added to mainline gcc in the first
    place. They all have patched gcc-7.3 ports that work to some
    degree, but complete upstream support won't happen before gcc-8.1.
    Csky posted their first kernel patch set last week, their situation
    will be similar

    [ Palmer Dabbelt points out that RISC-V support is in mainline gcc
    since gcc-7, although gcc-7.3.0 is the recommended minimum - Linus ]"

    This really says it all:

    2498 files changed, 95 insertions(+), 467668 deletions(-)

    * tag 'arch-removal' of git://git.kernel.org/pub/scm/linux/kernel/git/arnd/asm-generic: (74 commits)
    MAINTAINERS: UNICORE32: Change email account
    staging: iio: remove iio-trig-bfin-timer driver
    tty: hvc: remove tile driver
    tty: remove bfin_jtag_comm and hvc_bfin_jtag drivers
    serial: remove tile uart driver
    serial: remove m32r_sio driver
    serial: remove blackfin drivers
    serial: remove cris/etrax uart drivers
    usb: Remove Blackfin references in USB support
    usb: isp1362: remove blackfin arch glue
    usb: musb: remove blackfin port
    usb: host: remove tilegx platform glue
    pwm: remove pwm-bfin driver
    i2c: remove bfin-twi driver
    spi: remove blackfin related host drivers
    watchdog: remove bfin_wdt driver
    can: remove bfin_can driver
    mmc: remove bfin_sdh driver
    input: misc: remove blackfin rotary driver
    input: keyboard: remove bf54x driver
    ...

    Linus Torvalds
     

22 Mar, 2018

1 commit

  • 41f8bba7f555 ("of/pci: Add pci_register_io_range() and
    pci_pio_to_address()") added support for PCI I/O space mapped into CPU
    physical memory space. With that support, the I/O ranges configured for
    PCI/PCIe hosts on some architectures can be mapped to logical PIO and
    converted easily between CPU address and the corresponding logical PIO.
    Based on this, PCI I/O port space can be accessed via in/out accessors that
    use memory read/write.

    But on some platforms, there are bus hosts that access I/O port space with
    host-local I/O port addresses rather than memory addresses.

    Add a more generic I/O mapping method to support those devices. With this
    patch, both the CPU addresses and the host-local port can be mapped into
    the logical PIO space with different logical/fake PIOs. After this, all
    the I/O accesses to either PCI MMIO devices or host-local I/O peripherals
    can be unified into the existing I/O accessors defined in asm-generic/io.h
    and be redirected to the right device-specific hooks based on the input
    logical PIO.

    Tested-by: dann frazier
    Signed-off-by: Zhichang Yuan
    Signed-off-by: Gabriele Paoloni
    Signed-off-by: John Garry
    [bhelgaas: remove -EFAULT return from logic_pio_register_range() per
    https://lkml.kernel.org/r/20180403143909.GA21171@ulmo, fix NULL pointer
    checking per https://lkml.kernel.org/r/20180403211505.GA29612@embeddedor.com]
    Signed-off-by: Bjorn Helgaas
    Reviewed-by: Andy Shevchenko

    Zhichang Yuan
     

10 Mar, 2018

1 commit


22 Feb, 2018

1 commit

  • It allows some architectures to use this generic macro instead of
    defining theirs.

    sparc: io: To use the define of ioremap_[nocache|wc|wb] in asm-generic/io.h
    It will move the ioremap_nocache out of the CONFIG_MMU ifdef. This means that
    in order to suppress re-definition errors we need to remove the #define
    in arch/sparc/include/asm/io_32.h. Also, the change adds a prototype for
    ioremap where size is size_t and offset is phys_addr_t so fix that as well.

    Signed-off-by: Greentime Hu

    Greentime Hu
     

24 Jul, 2017

2 commits

  • Generic header defines xlate_dev_kmem_ptr().

    Reuse it from generic header and remove in x86 code.
    Move a description to the generic header as well.

    Signed-off-by: Andy Shevchenko
    Cc: Baolin Wang
    Cc: Linus Torvalds
    Cc: Mika Westerberg
    Cc: Peter Zijlstra
    Cc: Thomas Gleixner
    Cc: intel-gfx@lists.freedesktop.org
    Cc: linux-i2c@vger.kernel.org
    Cc: wsa@the-dreams.de
    Link: http://lkml.kernel.org/r/20170630170934.83028-5-andriy.shevchenko@linux.intel.com
    Signed-off-by: Ingo Molnar

    Andy Shevchenko
     
  • Generic header defines memset_io, memcpy_fromio(). and memcpy_toio().

    Reuse them from generic header and remove in x86 code.
    Move the descriptions to the generic header as well.

    Signed-off-by: Andy Shevchenko
    Cc: Baolin Wang
    Cc: Linus Torvalds
    Cc: Mika Westerberg
    Cc: Peter Zijlstra
    Cc: Thomas Gleixner
    Cc: intel-gfx@lists.freedesktop.org
    Cc: linux-i2c@vger.kernel.org
    Cc: wsa@the-dreams.de
    Link: http://lkml.kernel.org/r/20170630170934.83028-4-andriy.shevchenko@linux.intel.com
    Signed-off-by: Ingo Molnar

    Andy Shevchenko
     

31 May, 2016

2 commits

  • This will allow device drivers to consistently use io{read,write}XX
    also for 64-bit accesses.

    Acked-by: Arnd Bergmann
    Signed-off-by: Horia Geantă
    Signed-off-by: Herbert Xu

    Horia Geantă
     
  • While reviewing the addition of io{read,write}64be accessors, Arnd

    -finds a potential problem:
    "If an architecture overrides readq/writeq to have barriers but does
    not override ioread64be/iowrite64be, this will lack the barriers and
    behave differently from the little-endian version. I think the only
    affected architecture is ARC, since ARM and ARM64 both override the
    big-endian accessors to have the correct barriers, and all others
    don't use barriers at all."

    -suggests a fix for the same problem in existing code (16/32-bit
    accessors); the fix leads "to a double-swap on architectures that
    don't override the io{read,write}{16,32}be accessors, but it will
    work correctly on all architectures without them having to override
    these accessors."

    Suggested-by: Arnd Bergmann
    Acked-by: Arnd Bergmann
    Signed-off-by: Horia Geantă
    Signed-off-by: Herbert Xu

    Horia Geantă
     

04 May, 2016

1 commit

  • Whilst commit 9439eb3ab9d1 ("asm-generic: io: implement relaxed
    accessor macros as conditional wrappers") makes the *_relaxed forms of
    I/O accessors universally available to drivers, in cases where writeq()
    is implemented via the io-64-nonatomic helpers, writeq_relaxed() will
    end up falling back to writel() regardless of whether writel_relaxed()
    is available (identically for s/write/read/).

    Add corresponding relaxed forms of the nonatomic helpers to delegate
    to the equivalent 32-bit accessors as appropriate. We also need to fix
    io.h to avoid defining default relaxed variants if the basic accessors
    themselves don't exist.

    CC: Christoph Hellwig
    CC: Darren Hart
    CC: Hitoshi Mitake
    Acked-by: Arnd Bergmann
    Signed-off-by: Robin Murphy
    Signed-off-by: Will Deacon

    Robin Murphy
     

21 Jul, 2015

1 commit

  • We currently have no safe way of currently defining architecture
    agnostic IOMMU ioremap_*() variants. The trend is for folks to
    *assume* that ioremap_nocache() should be the default everywhere
    and then add this mapping on each architectures -- this is not
    correct today for a variety of reasons.

    We have two options:

    1) Sit and wait for every architecture in Linux to get a
    an ioremap_*() variant defined before including it upstream.

    2) Gather consensus on a safe architecture agnostic ioremap_*()
    default.

    Approach 1) introduces development latencies, and since 2) will
    take time and work on clarifying semantics the only remaining
    sensible thing to do to avoid issues is returning NULL on
    ioremap_*() variants.

    In order for this to work we must have all architectures declare
    their own ioremap_*() variants as defined. This will take some
    work, do this for ioremp_uc() to set the example as its only
    currently implemented on x86. Document all this.

    We only provide implementation support for ioremap_uc() as the
    other ioremap_*() variants are well defined all over the kernel
    for other architectures already.

    Signed-off-by: Luis R. Rodriguez
    Cc: Linus Torvalds
    Cc: Peter Zijlstra
    Cc: Thomas Gleixner
    Cc: arnd@arndb.de
    Cc: benh@kernel.crashing.org
    Cc: bp@suse.de
    Cc: dan.j.williams@intel.com
    Cc: geert@linux-m68k.org
    Cc: hch@lst.de
    Cc: hmh@hmh.eng.br
    Cc: jgross@suse.com
    Cc: linux-mm@kvack.org
    Cc: luto@amacapital.net
    Cc: mpe@ellerman.id.au
    Cc: mst@redhat.com
    Cc: ralf@linux-mips.org
    Cc: ross.zwisler@linux.intel.com
    Cc: stefan.bader@canonical.com
    Cc: tj@kernel.org
    Cc: tomi.valkeinen@ti.com
    Cc: toshi.kani@hp.com
    Link: http://lkml.kernel.org/r/1436488096-3165-1-git-send-email-mcgrof@do-not-panic.com
    Signed-off-by: Ingo Molnar

    Luis R. Rodriguez
     

07 Jun, 2015

1 commit

  • Add ioremap_wt() for creating Write-Through mappings on x86. It
    follows the same model as ioremap_wc() for multi-arch support.
    Define ARCH_HAS_IOREMAP_WT in the x86 version of io.h to
    indicate that ioremap_wt() is implemented on x86.

    Also update the PAT documentation file to cover ioremap_wt().

    Signed-off-by: Toshi Kani
    Signed-off-by: Borislav Petkov
    Cc: Andrew Morton
    Cc: Andy Lutomirski
    Cc: Elliott@hp.com
    Cc: H. Peter Anvin
    Cc: Linus Torvalds
    Cc: Luis R. Rodriguez
    Cc: Peter Zijlstra
    Cc: Thomas Gleixner
    Cc: arnd@arndb.de
    Cc: hch@lst.de
    Cc: hmh@hmh.eng.br
    Cc: jgross@suse.com
    Cc: konrad.wilk@oracle.com
    Cc: linux-mm
    Cc: linux-nvdimm@lists.01.org
    Cc: stefan.bader@canonical.com
    Cc: yigal@plexistor.com
    Link: http://lkml.kernel.org/r/1433436928-31903-8-git-send-email-bp@alien8.de
    Signed-off-by: Ingo Molnar

    Toshi Kani
     

11 May, 2015

1 commit

  • ioremap_nocache() currently uses UC- by default. Our goal is to
    eventually make UC the default. Linux maps UC- to PCD=1, PWT=0
    page attributes on non-PAT systems. Linux maps UC to PCD=1,
    PWT=1 page attributes on non-PAT systems. On non-PAT and PAT
    systems a WC MTRR has different effects on pages with either of
    these attributes. In order to help with a smooth transition its
    best to enable use of UC (PCD,1, PWT=1) on a region as that
    ensures a WC MTRR will have no effect on a region, this however
    requires us to have an way to declare a region as UC and we
    currently do not have a way to do this.

    WC MTRR on non-PAT system with PCD=1, PWT=0 (UC-) yields WC.
    WC MTRR on non-PAT system with PCD=1, PWT=1 (UC) yields UC.

    WC MTRR on PAT system with PCD=1, PWT=0 (UC-) yields WC.
    WC MTRR on PAT system with PCD=1, PWT=1 (UC) yields UC.

    A flip of the default ioremap_nocache() behaviour from UC- to UC
    can therefore regress a memory region from effective memory type
    WC to UC if MTRRs are used. Use of MTRRs should be phased out
    and in the best case only arch_phys_wc_add() use will remain,
    even if this happens arch_phys_wc_add() will have an effect on
    non-PAT systems and changes to default ioremap_nocache()
    behaviour could regress drivers.

    Now, ideally we'd use ioremap_nocache() on the regions in which
    we'd need uncachable memory types and avoid any MTRRs on those
    regions. There are however some restrictions on MTRRs use, such
    as the requirement of having the base and size of variable sized
    MTRRs to be powers of two, which could mean having to use a WC
    MTRR over a large area which includes a region in which
    write-combining effects are undesirable.

    Add ioremap_uc() to help with the both phasing out of MTRR use
    and also provide a way to blacklist small WC undesirable regions
    in devices with mixed regions which are size-implicated to use
    large WC MTRRs. Use of ioremap_uc() helps phase out MTRR use by
    avoiding regressions with an eventual flip of default behaviour
    or ioremap_nocache() from UC- to UC.

    Drivers working with WC MTRRs can use the below table to review
    and consider the use of ioremap*() and similar helpers to ensure
    appropriate behaviour long term even if default
    ioremap_nocache() behaviour changes from UC- to UC.

    Although ioremap_uc() is being added we leave set_memory_uc() to
    use UC- as only initial memory type setup is required to be able
    to accommodate existing device drivers and phase out MTRR use.
    It should also be clarified that set_memory_uc() cannot be used
    with IO memory, even though its use will not return any errors,
    it really has no effect.

    ----------------------------------------------------------------------
    MTRR Non-PAT PAT Linux ioremap value Effective memory type
    ----------------------------------------------------------------------
    Non-PAT | PAT
    PAT
    |PCD
    ||PWT
    |||
    WC 000 WB _PAGE_CACHE_MODE_WB WC | WC
    WC 001 WC _PAGE_CACHE_MODE_WC WC* | WC
    WC 010 UC- _PAGE_CACHE_MODE_UC_MINUS WC* | WC
    WC 011 UC _PAGE_CACHE_MODE_UC UC | UC
    ----------------------------------------------------------------------

    Signed-off-by: Luis R. Rodriguez
    Signed-off-by: Borislav Petkov
    Acked-by: H. Peter Anvin
    Cc: Andy Lutomirski
    Cc: Antonino Daplas
    Cc: Bjorn Helgaas
    Cc: Borislav Petkov
    Cc: Brian Gerst
    Cc: Daniel Vetter
    Cc: Dave Airlie
    Cc: Davidlohr Bueso
    Cc: Denys Vlasenko
    Cc: Jean-Christophe Plagniol-Villard
    Cc: Juergen Gross
    Cc: Linus Torvalds
    Cc: Mel Gorman
    Cc: Mike Travis
    Cc: Peter Zijlstra
    Cc: Suresh Siddha
    Cc: Thierry Reding
    Cc: Thomas Gleixner
    Cc: Tomi Valkeinen
    Cc: Toshi Kani
    Cc: Ville Syrjälä
    Cc: Vlastimil Babka
    Cc: Will Deacon
    Cc: linux-fbdev@vger.kernel.org
    Link: http://lkml.kernel.org/r/1430343851-967-2-git-send-email-mcgrof@do-not-panic.com
    Link: http://lkml.kernel.org/r/1431332153-18566-9-git-send-email-bp@alien8.de
    Signed-off-by: Ingo Molnar

    Luis R. Rodriguez
     

12 Nov, 2014

1 commit

  • * 'io' of git://git.kernel.org/pub/scm/linux/kernel/git/will/linux:
    documentation: memory-barriers: clarify relaxed io accessor semantics
    x86: io: implement dummy relaxed accessor macros for writes
    tile: io: implement dummy relaxed accessor macros for writes
    sparc: io: implement dummy relaxed accessor macros for writes
    powerpc: io: implement dummy relaxed accessor macros for writes
    parisc: io: implement dummy relaxed accessor macros for writes
    mn10300: io: implement dummy relaxed accessor macros for writes
    m68k: io: implement dummy relaxed accessor macros for writes
    m32r: io: implement dummy relaxed accessor macros for writes
    ia64: io: implement dummy relaxed accessor macros for writes
    cris: io: implement dummy relaxed accessor macros for writes
    frv: io: implement dummy relaxed accessor macros for writes
    xtensa: io: remove dummy relaxed accessor macros for reads
    s390: io: remove dummy relaxed accessor macros for reads
    microblaze: io: remove dummy relaxed accessor macros
    asm-generic: io: implement relaxed accessor macros as conditional wrappers

    Conflicts:
    include/asm-generic/io.h

    Signed-off-by: Arnd Bergmann

    Arnd Bergmann
     

10 Nov, 2014

2 commits

  • Currently driver writers need to use io{read,write}{8,16,32}_rep() when
    accessing FIFO registers portably. This is bad for two reasons: it is
    inconsistent with how other registers are accessed using the standard
    {read,write}{b,w,l}() functions, which can lead to confusion. On some
    architectures the io{read,write}*() functions also need to perform some
    extra checks to determine whether an address is memory-mapped or refers
    to I/O space. Drivers which can be expected to never use I/O can safely
    use the {read,write}s{b,w,l,q}(), just like they use their non-string
    variants and there's no need for these extra checks.

    This patch implements generic versions of readsb(), readsw(), readsl(),
    readsq(), writesb(), writesw(), writesl() and writesq(). Variants of
    these string functions for I/O accesses (ins*() and outs*() as well as
    ioread*_rep() and iowrite*_rep()) are now implemented in terms of the
    new functions.

    Going forward, {read,write}{,s}{b,w,l,q}() should be used consistently
    by drivers for devices that will only ever be memory-mapped and hence
    don't need to access I/O space, whereas io{read,write}{8,16,32}_rep()
    should be used by drivers for devices that can be either memory-mapped
    or I/O-mapped.

    Signed-off-by: Thierry Reding

    Thierry Reding
     
  • Overriding I/O accessors and helpers is currently very inconsistent.
    This commit introduces a homogeneous way to override functions by
    checking for the existence of a macro with the same of the function.
    Architectures can provide their own implementations and communicate this
    to the generic header by defining the appropriate macro. Doing this will
    also help prevent the implementations from being subsequently
    overridden.

    While at it, also turn a lot of macros into static inline functions for
    better type checking and to provide a canonical signature for overriding
    architectures to copy. Also reorder functions by logical groups.

    Signed-off-by: Thierry Reding

    Thierry Reding
     

21 Oct, 2014

1 commit

  • {read,write}{b,w,l,q}_relaxed are implemented by some architectures in
    order to permit memory-mapped I/O accesses with weaker barrier semantics
    than the non-relaxed variants.

    This patch adds wrappers to asm-generic so that drivers can rely on the
    relaxed accessors being available, even if they don't always provide
    weaker ordering guarantees. Since some architectures both include
    asm-generic/io.h and define some relaxed accessors, the definitions here
    are conditional for the time being.

    Cc: Arnd Bergmann
    Signed-off-by: Will Deacon

    Will Deacon
     

30 Sep, 2014

1 commit

  • The !CONFIG_GENERIC_IOMAP version of ioport_map() is wrong. It returns a
    mapped, i.e., virtual, address that can start from zero and completely
    ignores the PCI_IOBASE and IO_SPACE_LIMIT that most architectures that use
    !CONFIG_GENERIC_MAP define.

    Tested-by: Tanmay Inamdar
    Signed-off-by: Liviu Dudau
    Signed-off-by: Bjorn Helgaas
    Reviewed-by: Catalin Marinas
    Acked-by: Arnd Bergmann

    Liviu Dudau
     

08 Apr, 2014

1 commit

  • If the renamed symbol is defined lib/iomap.c implements ioport_map and
    ioport_unmap and currently (nearly) all platforms define the port
    accessor functions outb/inb and friend unconditionally. So
    HAS_IOPORT_MAP is the better name for this.

    Consequently NO_IOPORT is renamed to NO_IOPORT_MAP.

    The motivation for this change is to reintroduce a symbol HAS_IOPORT
    that signals if outb/int et al are available. I will address that at
    least one merge window later though to keep surprises to a minimum and
    catch new introductions of (HAS|NO)_IOPORT.

    The changes in this commit were done using:

    $ git grep -l -E '(NO|HAS)_IOPORT' | xargs perl -p -i -e 's/\b((?:CONFIG_)?(?:NO|HAS)_IOPORT)\b/$1_MAP/'

    Signed-off-by: Uwe Kleine-König
    Acked-by: Arnd Bergmann
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Uwe Kleine-König
     

22 May, 2013

1 commit

  • On s390 the prefix page and absolute zero pages are not correctly
    returned when reading /dev/mem. The reason is that the s390 asm/io.h
    file includes the asm-generic/io.h file which then defines
    xlate_dev_mem_ptr() and therefore overwrites the s390 specific
    version that does the correct swap operation for prefix and absolute
    zero pages. The problem is a regression that was introduced with git
    commit cd248341 (s390/pci: base support).

    To fix the problem add "#ifndef xlate_dev_mem_ptr" in asm-generic/io.h
    and "#define xlate_dev_mem_ptr" in asm/io.h. This ensures that the
    s390 version is used. For completeness also add the "#ifndef"
    construct for xlate_dev_kmem_ptr().

    Signed-off-by: Michael Holzheu
    Signed-off-by: Martin Schwidefsky

    Michael Holzheu