dmabuf: always map dmabuf with PROT_WRITE

This is to enable zero copy inference on dmabufs. Gasket kernel driver
requires all user pointers passed to it to be writable in
drivers/staging/gasket/gasket_page_table.c gasket_perform_mapping
even if it's not actually writing to the buffer. If we map a buffer
with GST_MAP_READ it'll be mmapped with PROT_READ and gasket will
error out with -EFAULT.

While a more correct solution is to fix the gasket driver the needed
linux/mm APIs aren't there in the current version of the kernel.
We'd need
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=73b0140bf0fe9df90fb267c00673c4b9bf285430
which is for a much later kernel version.

This change may look dangerous but what it really does is to make
dmabuf protection equal to buffers allocated by the system memory
allocator; i.e. even if you map a buffer with GST_MAP_READ only
you can, but should not, write to it.

BUG: 142164990
BUG: 148226798
BUG: 148221549
Change-Id: Ie7f7cbce212fd6851e9047e05245b9f634c5e5fd
1 file changed