Changes in 4.9.232 pinctrl: amd: fix npins for uart0 in kerncz_groups mac80211: allow rx of mesh eapol frames with default rx key scsi: scsi_transport_spi: Fix function pointer check xtensa: fix __sync_fetch_and_{and,or}_4 declarations xtensa: update *pos in cpuinfo_op.next drivers/net/wan/lapbether: Fixed the value of hard_header_len net: sky2: initialize return of gm_phy_read drm/nouveau/i2c/g94-: increase NV_PMGR_DP_AUXCTL_TRANSACTREQ timeout SUNRPC reverting d03727b248d0 ("NFSv4 fix CLOSE not waiting for direct IO compeletion") uprobes: Change handle_swbp() to send SIGTRAP with si_code=SI_KERNEL, to fix GDB regression ALSA: info: Drop WARN_ON() from buffer NULL sanity check ASoC: rt5670: Correct RT5670_LDO_SEL_MASK btrfs: fix double free on ulist after backref resolution failure btrfs: fix mount failure caused by race with umount bnxt_en: Fix race when modifying pause settings. hippi: Fix a size used in a 'pci_free_consistent()' in an error handling path ax88172a: fix ax88172a_unbind() failures net: dp83640: fix SIOCSHWTSTAMP to update the struct with actual configuration net: smc91x: Fix possible memory leak in smc_drv_probe() scripts/decode_stacktrace: strip basepath from all paths HID: i2c-hid: add Mediacom FlexBook edge13 to descriptor override HID: apple: Disable Fn-key key-re-mapping on clone keyboards dmaengine: tegra210-adma: Fix runtime PM imbalance on error regmap: dev_get_regmap_match(): fix string comparison dmaengine: ioat setting ioat timeout as module parameter usb: gadget: udc: gr_udc: fix memleak on error handling path in gr_ep_init() arm64: Use test_tsk_thread_flag() for checking TIF_SINGLESTEP x86: math-emu: Fix up 'cmp' insn for clang ias usb: xhci-mtk: fix the failure of bandwidth allocation usb: xhci: Fix ASM2142/ASM3142 DMA addressing Revert "cifs: Fix the target file was deleted when rename failed." staging: wlan-ng: properly check endpoint types staging: comedi: addi_apci_1032: check INSN_CONFIG_DIGITAL_TRIG shift staging: comedi: ni_6527: fix INSN_CONFIG_DIGITAL_TRIG support staging: comedi: addi_apci_1500: check INSN_CONFIG_DIGITAL_TRIG shift staging: comedi: addi_apci_1564: check INSN_CONFIG_DIGITAL_TRIG shift serial: 8250: fix null-ptr-deref in serial8250_start_tx() serial: 8250_mtk: Fix high-speed baud rates clamping vt: Reject zero-sized screen buffer size. Makefile: Fix GCC_TOOLCHAIN_DIR prefix for Clang cross compilation mm/memcg: fix refcount error while moving and swapping io-mapping: indicate mapping failure parisc: Add atomic64_set_release() define to avoid CPU soft lockups ath9k: Fix general protection fault in ath9k_hif_usb_rx_cb ath9k: Fix regression with Atheros 9271 AX.25: Fix out-of-bounds read in ax25_connect() AX.25: Prevent out-of-bounds read in ax25_sendmsg() dev: Defer free of skbs in flush_backlog net-sysfs: add a newline when printing 'tx_timeout' by sysfs net: udp: Fix wrong clean up for IS_UDPLITE macro rxrpc: Fix sendmsg() returning EPIPE due to recvmsg() returning ENODATA AX.25: Prevent integer overflows in connect and sendmsg tcp: allow at most one TLP probe per flight ip6_gre: fix null-ptr-deref in ip6gre_init_net() drivers/net/wan/x25_asy: Fix to make it work regmap: debugfs: check count when read regmap file xfs: set format back to extents if xfs_bmap_extents_to_btree perf probe: Fix to check blacklist address correctly perf annotate: Use asprintf when formatting objdump command line perf tools: Fix snprint warnings for gcc 8 perf: Make perf able to build with latest libbfd Linux 4.9.232 Signed-off-by: Greg Kroah-Hartman <gregkh@google.com> Change-Id: Iae57e72dbaebe67399c6756146f30762e5f25b2e
206 lines
4.4 KiB
C
206 lines
4.4 KiB
C
/*
|
|
* Copyright © 2008 Keith Packard <keithp@keithp.com>
|
|
*
|
|
* This file is free software; you can redistribute it and/or modify
|
|
* it under the terms of version 2 of the GNU General Public License
|
|
* as published by the Free Software Foundation.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with this program; if not, write to the Free Software Foundation,
|
|
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
*/
|
|
|
|
#ifndef _LINUX_IO_MAPPING_H
|
|
#define _LINUX_IO_MAPPING_H
|
|
|
|
#include <linux/types.h>
|
|
#include <linux/slab.h>
|
|
#include <linux/bug.h>
|
|
#include <linux/io.h>
|
|
#include <asm/page.h>
|
|
|
|
/*
|
|
* The io_mapping mechanism provides an abstraction for mapping
|
|
* individual pages from an io device to the CPU in an efficient fashion.
|
|
*
|
|
* See Documentation/io-mapping.txt
|
|
*/
|
|
|
|
struct io_mapping {
|
|
resource_size_t base;
|
|
unsigned long size;
|
|
pgprot_t prot;
|
|
void __iomem *iomem;
|
|
};
|
|
|
|
#ifdef CONFIG_HAVE_ATOMIC_IOMAP
|
|
|
|
#include <asm/iomap.h>
|
|
/*
|
|
* For small address space machines, mapping large objects
|
|
* into the kernel virtual space isn't practical. Where
|
|
* available, use fixmap support to dynamically map pages
|
|
* of the object at run time.
|
|
*/
|
|
|
|
static inline struct io_mapping *
|
|
io_mapping_init_wc(struct io_mapping *iomap,
|
|
resource_size_t base,
|
|
unsigned long size)
|
|
{
|
|
pgprot_t prot;
|
|
|
|
if (iomap_create_wc(base, size, &prot))
|
|
return NULL;
|
|
|
|
iomap->base = base;
|
|
iomap->size = size;
|
|
iomap->prot = prot;
|
|
return iomap;
|
|
}
|
|
|
|
static inline void
|
|
io_mapping_fini(struct io_mapping *mapping)
|
|
{
|
|
iomap_free(mapping->base, mapping->size);
|
|
}
|
|
|
|
/* Atomic map/unmap */
|
|
static inline void __iomem *
|
|
io_mapping_map_atomic_wc(struct io_mapping *mapping,
|
|
unsigned long offset)
|
|
{
|
|
resource_size_t phys_addr;
|
|
unsigned long pfn;
|
|
|
|
BUG_ON(offset >= mapping->size);
|
|
phys_addr = mapping->base + offset;
|
|
pfn = (unsigned long) (phys_addr >> PAGE_SHIFT);
|
|
return iomap_atomic_prot_pfn(pfn, mapping->prot);
|
|
}
|
|
|
|
static inline void
|
|
io_mapping_unmap_atomic(void __iomem *vaddr)
|
|
{
|
|
iounmap_atomic(vaddr);
|
|
}
|
|
|
|
static inline void __iomem *
|
|
io_mapping_map_wc(struct io_mapping *mapping,
|
|
unsigned long offset,
|
|
unsigned long size)
|
|
{
|
|
resource_size_t phys_addr;
|
|
|
|
BUG_ON(offset >= mapping->size);
|
|
phys_addr = mapping->base + offset;
|
|
|
|
return ioremap_wc(phys_addr, size);
|
|
}
|
|
|
|
static inline void
|
|
io_mapping_unmap(void __iomem *vaddr)
|
|
{
|
|
iounmap(vaddr);
|
|
}
|
|
|
|
#else
|
|
|
|
#include <linux/uaccess.h>
|
|
#include <asm/pgtable.h>
|
|
|
|
/* Create the io_mapping object*/
|
|
static inline struct io_mapping *
|
|
io_mapping_init_wc(struct io_mapping *iomap,
|
|
resource_size_t base,
|
|
unsigned long size)
|
|
{
|
|
iomap->iomem = ioremap_wc(base, size);
|
|
if (!iomap->iomem)
|
|
return NULL;
|
|
|
|
iomap->base = base;
|
|
iomap->size = size;
|
|
#if defined(pgprot_noncached_wc) /* archs can't agree on a name ... */
|
|
iomap->prot = pgprot_noncached_wc(PAGE_KERNEL);
|
|
#elif defined(pgprot_writecombine)
|
|
iomap->prot = pgprot_writecombine(PAGE_KERNEL);
|
|
#else
|
|
iomap->prot = pgprot_noncached(PAGE_KERNEL);
|
|
#endif
|
|
|
|
return iomap;
|
|
}
|
|
|
|
static inline void
|
|
io_mapping_fini(struct io_mapping *mapping)
|
|
{
|
|
iounmap(mapping->iomem);
|
|
}
|
|
|
|
/* Non-atomic map/unmap */
|
|
static inline void __iomem *
|
|
io_mapping_map_wc(struct io_mapping *mapping,
|
|
unsigned long offset,
|
|
unsigned long size)
|
|
{
|
|
return mapping->iomem + offset;
|
|
}
|
|
|
|
static inline void
|
|
io_mapping_unmap(void __iomem *vaddr)
|
|
{
|
|
}
|
|
|
|
/* Atomic map/unmap */
|
|
static inline void __iomem *
|
|
io_mapping_map_atomic_wc(struct io_mapping *mapping,
|
|
unsigned long offset)
|
|
{
|
|
preempt_disable();
|
|
pagefault_disable();
|
|
return io_mapping_map_wc(mapping, offset, PAGE_SIZE);
|
|
}
|
|
|
|
static inline void
|
|
io_mapping_unmap_atomic(void __iomem *vaddr)
|
|
{
|
|
io_mapping_unmap(vaddr);
|
|
pagefault_enable();
|
|
preempt_enable();
|
|
}
|
|
|
|
#endif /* HAVE_ATOMIC_IOMAP */
|
|
|
|
static inline struct io_mapping *
|
|
io_mapping_create_wc(resource_size_t base,
|
|
unsigned long size)
|
|
{
|
|
struct io_mapping *iomap;
|
|
|
|
iomap = kmalloc(sizeof(*iomap), GFP_KERNEL);
|
|
if (!iomap)
|
|
return NULL;
|
|
|
|
if (!io_mapping_init_wc(iomap, base, size)) {
|
|
kfree(iomap);
|
|
return NULL;
|
|
}
|
|
|
|
return iomap;
|
|
}
|
|
|
|
static inline void
|
|
io_mapping_free(struct io_mapping *iomap)
|
|
{
|
|
io_mapping_fini(iomap);
|
|
kfree(iomap);
|
|
}
|
|
|
|
#endif /* _LINUX_IO_MAPPING_H */
|