linux/drivers
Daniel Vetter 4c78513e45 dma-buf: mmap support
Compared to Rob Clark's RFC I've ditched the prepare/finish hooks
and corresponding ioctls on the dma_buf file. The major reason for
that is that many people seem to be under the impression that this is
also for synchronization with outstanding asynchronous processsing.
I'm pretty massively opposed to this because:

- It boils down reinventing a new rather general-purpose userspace
  synchronization interface. If we look at things like futexes, this
  is hard to get right.
- Furthermore a lot of kernel code has to interact with this
  synchronization primitive. This smells a look like the dri1 hw_lock,
  a horror show I prefer not to reinvent.
- Even more fun is that multiple different subsystems would interact
  here, so we have plenty of opportunities to create funny deadlock
  scenarios.

I think synchronization is a wholesale different problem from data
sharing and should be tackled as an orthogonal problem.

Now we could demand that prepare/finish may only ensure cache
coherency (as Rob intended), but that runs up into the next problem:
We not only need mmap support to facilitate sw-only processing nodes
in a pipeline (without jumping through hoops by importing the dma_buf
into some sw-access only importer), which allows for a nicer
ION->dma-buf upgrade path for existing Android userspace. We also need
mmap support for existing importing subsystems to support existing
userspace libraries. And a loot of these subsystems are expected to
export coherent userspace mappings.

So prepare/finish can only ever be optional and the exporter /needs/
to support coherent mappings. Given that mmap access is always
somewhat fallback-y in nature I've decided to drop this optimization,
instead of just making it optional. If we demonstrate a clear need for
this, supported by benchmark results, we can always add it in again
later as an optional extension.

Other differences compared to Rob's RFC is the above mentioned support
for mapping a dma-buf through facilities provided by the importer.
Which results in mmap support no longer being optional.

Note that this dma-buf mmap patch does _not_ support every possible
insanity an existing subsystem could pull of with mmap: Because it
does not allow to intercept pagefaults and shoot down ptes importing
subsystems can't add some magic of their own at these points (e.g. to
automatically synchronize with outstanding rendering or set up some
special resources). I've done a cursory read through a few mmap
implementions of various subsytems and I'm hopeful that we can avoid
this (and the complexity it'd bring with it).

Additonally I've extended the documentation a bit to explain the hows
and whys of this mmap extension.

In case we ever want to add support for explicitly cache maneged
userspace mmap with a prepare/finish ioctl pair, we could specify that
userspace needs to mmap a different part of the dma_buf, e.g. the
range starting at dma_buf->size up to dma_buf->size*2. This works
because the size of a dma_buf is invariant over it's lifetime. The
exporter would obviously need to fall back to coherent mappings for
both ranges if a legacy clients maps the coherent range and the
architecture cannot suppor conflicting caching policies. Also, this
would obviously be optional and userspace needs to be able to fall
back to coherent mappings.

v2:
- Spelling fixes from Rob Clark.
- Compile fix for !DMA_BUF from Rob Clark.
- Extend commit message to explain how explicitly cache managed mmap
  support could be added later.
- Extend the documentation with implementations notes for exporters
  that need to manually fake coherency.

v3:
- dma_buf pointer initialization goof-up noticed by Rebecca Schultz
  Zavin.

Cc: Rob Clark <rob.clark@linaro.org>
Cc: Rebecca Schultz Zavin <rebecca@android.com>
Acked-by: Rob Clark <rob.clark@linaro.org>
Signed-Off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Sumit Semwal <sumit.semwal@linaro.org>
2012-05-25 12:35:24 +05:30
..
accessibility
acpi ACPI / PCI / PM: Fix device PM regression related to D3hot/D3cold 2012-05-17 16:16:16 -07:00
amba
ata Change summary: 2012-05-03 17:16:52 -07:00
atm
auxdisplay
base dma-buf: mmap support 2012-05-25 12:35:24 +05:30
bcma
block Merge branch 'for-linus' of git://git.kernel.dk/linux-block 2012-05-19 10:12:17 -07:00
bluetooth Merge branch 'for-upstream' of git://git.kernel.org/pub/scm/linux/kernel/git/bluetooth/bluetooth 2012-04-27 15:16:43 -04:00
cdrom
char virtio: console: tell host of open ports after resume from s3/s4 2012-05-17 12:14:33 +03:00
clk
clocksource
connector
cpufreq
cpuidle
crypto crypto: mv_cesa requires on CRYPTO_HASH to build 2012-05-15 01:10:06 +00:00
dca
devfreq
dio
dma Merge branch 'fixes' of git://git.infradead.org/users/vkoul/slave-dma 2012-05-17 09:57:13 -07:00
edac
eisa
firewire
firmware efivars: Improve variable validation 2012-05-03 17:19:19 -07:00
gpio gpio/exynos: Fix compiler warnings when non-exynos machines are selected 2012-05-11 18:25:53 -06:00
gpu drm/nouveau/i2c: resume use of i2c-algo-bit, rather than custom stack 2012-05-07 11:02:38 +01:00
hid
hsi HSI: hsi_char: Remove max_data_size from sysfs 2012-04-23 14:23:32 +03:00
hv
hwmon hwmon: (coretemp) Increase CPU core limit 2012-05-01 09:16:14 -07:00
hwspinlock
i2c i2c: mxs: disable QUEUE when sending is done 2012-04-27 16:13:29 +02:00
ide
idle
ieee802154
infiniband A few fixes for regressions introduced in 3.4-rc1: 2012-04-26 15:35:35 -07:00
input Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input 2012-04-30 10:13:48 -07:00
iommu
isdn
leds drivers/leds: correct __devexit annotations 2012-05-10 15:06:44 -07:00
lguest
macintosh
mca
md A fix to the thin provisioning userspace interface. 2012-05-18 18:22:45 -07:00
media Merge branch 'v4l_for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-media 2012-05-14 11:23:37 -07:00
memstick
message
mfd mfd: Fix build breakage in omap-usb-host.c 2012-05-01 11:55:04 +02:00
misc
mmc Merge branch 'fixes' of git://git.infradead.org/users/vkoul/slave-dma 2012-04-26 15:33:36 -07:00
mtd Three fixes for 3.4: 2012-05-13 11:33:09 -07:00
net e1000: Prevent reset task killing itself. 2012-05-17 18:32:41 -04:00
nfc
nubus
of
oprofile
parisc parisc: move definition of PAGE0 to asm/page.h 2012-05-10 15:12:08 -07:00
parport
pci ACPI / PCI / PM: Fix device PM regression related to D3hot/D3cold 2012-05-17 16:16:16 -07:00
pcmcia
pinctrl
platform Merge branch 'x86-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip 2012-05-06 12:19:38 -07:00
pnp
power
pps
ps3
ptp ptp_pch: Add missing #include <linux/slab.h> 2012-05-16 14:44:44 -04:00
rapidio
regulator regulator: Actually free the regulator in devm_regulator_put() 2012-05-07 13:14:44 +01:00
remoteproc remoteproc: fix off-by-one bug in __rproc_free_vrings 2012-05-13 23:15:42 +03:00
rpmsg
rtc drivers/rtc/rtc-pl031.c: configure correct wday for 2000-01-01 2012-05-17 18:00:51 -07:00
s390 qeth: Use blkt defaults for OSA Express 4 2012-04-24 00:33:17 -04:00
sbus
scsi [SCSI] virtio_scsi: fix TMF use-after-free 2012-05-10 08:27:06 +01:00
sfi
sh
sn
spi spi/spi-bfin5xx: Fix flush of last bit after each spi transfer 2012-04-27 12:20:39 -06:00
ssb
staging staging: ozwpan: Fix bug where kfree is called twice. 2012-04-26 12:40:53 -07:00
target target: Fix bug in handling of FILEIO + block_device resize ops 2012-05-17 12:02:43 -07:00
tc
thermal
tty tty: Fix LED error return 2012-05-14 10:43:24 -07:00
uio
usb USB: ehci-tegra: remove redundant gpio_set_value 2012-05-01 14:11:51 -04:00
uwb
vhost vhost-net: fix handle_rx buffer size 2012-05-11 18:16:57 -04:00
video Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net 2012-05-12 12:57:01 -07:00
virt
virtio virtio: balloon: let host know of updated balloon size before module removal 2012-05-17 12:14:34 +03:00
vlynq
w1
watchdog hpwdt: Only BYTE reads/writes to WD Timer port 0x72 2012-04-26 14:38:07 +02:00
xen xen/Kconfig: fix Kconfig layout 2012-05-07 12:26:28 -04:00
zorro
Kconfig
Makefile