compat: pending compat patches
cover compat: pending compat patches
From: "Luis R. Rodriguez" <[email protected]>
Johannes,
this brings the compat module in backports up to date with what we had in compat as an independent project. I'll next work on testing the DRM drivers and then try adding the media stuff.
This has been test compiled with ckmake on your backports tree.
Luis R. Rodriguez (2):
compat: backport dma-buf
compat: add HDMI library support
backport/compat/Kconfig | 19 ++ backport/compat/Makefile | 2 + backport/compat/dma-buf.c | 575 ++++++++++++++++++++++++++++++++++++++ backport/compat/hdmi.c | 308 ++++++++++++++++++++ backport/include/linux/dma-buf.h | 211 ++++++++++++++ backport/include/linux/hdmi.h | 240 ++++++++++++++++ 6 files changed, 1355 insertions(+) create mode 100644 backport/compat/dma-buf.c create mode 100644 backport/compat/hdmi.c create mode 100644 backport/include/linux/dma-buf.h create mode 100644 backport/include/linux/hdmi.h
Signature · 1 line
1.7.10.4
PATCH 1/2 compat: backport dma-buf
From: "Luis R. Rodriguez" <[email protected]>
dma-buf was added via commit d15bd7ee on v3.3 but completed in a more sound fassion in later kernels, you should preferably be at v3.5 a least, so we take the latest dma-buf implementation and port it for usage on kernels [3.0-3.4]. We take the implementation as of next-20130328.
This is implemented as a non modular solution upstream but we can carry the implementation into our compat module.
Note that although commit f23513e8d was added on v2.6.23 that allowed the kernel to call get_unused_fd_flags(flags) for O_CLOEXEC setting, this routine was not exported until v3.7. dma-buf makes use of it, and since our backported dma-buf implementation is modular it means we have to work around the lack of get_unused_fd_flags() exported symbol on older kernels. Due to the security concerns noted by Ulrich on f23513e8 we need to ensure the operatin is atomic so we fix this on our port of dma-buf for older kernels by adding our own dma_buf_fd_set_flag() to be called when dma_buf_fd() is used. This implementation is available for usage on kernels >= 3.0. We disable it for v3.5 as we're happy with that implementation.
mcgrof@frijol ~/linux-next (git::master)$ git describe --contains \ d15bd7ee445d0702ad801fdaece348fdb79e6581
v3.3-rc1~161^2~2
mcgrof@frijol ~/linux-next (git::master)$ git describe --contains \ f23513e8d96cf5e6cf8d2ff0cb5dd6bbc33995e4
v2.6.23-rc1~894
mcgrof@frijol ~/linux-stable (git::linux-3.2.y)$ git describe --contains \ 1a7bd226
v3.7-rc1~134^2~69
Carried over the implementation from linux-next next-20130328
commit d15bd7ee445d0702ad801fdaece348fdb79e6581
Author: Sumit Semwal <[email protected]> Date: Mon Dec 26 14:53:15 2011 +0530
dma-buf: Introduce dma buffer sharing mechanism
This is the first step in defining a dma buffer sharing mechanism.
A new buffer object dma_buf is added, with operations and API to allow easy sharing of this buffer object across devices.
The framework allows:
- creation of a buffer object, its association with a file pointer, and associated allocator-defined operations on that buffer. This operation is called the 'export' operation.
- different devices to 'attach' themselves to this exported buffer object, to facilitate backing storage negotiation, using dma_buf_attach() API.
- the exported buffer object to be shared with the other entity by asking for its 'file-descriptor (fd)', and sharing the fd across.
- a received fd to get the buffer object back, where it can be accessed using the associated exporter-defined operations.
- the exporter and user to share the scatterlist associated with this buffer object using map_dma_buf and unmap_dma_buf operations.
Atleast one 'attach()' call is required to be made prior to calling the map_dma_buf() operation.
Couple of building blocks in map_dma_buf() are added to ease introduction of sync'ing across exporter and users, and late allocation by the exporter.
For this first version, this framework will work with certain conditions:
- *ONLY* exporter will be allowed to mmap to userspace (outside of this framework - mmap is not a buffer object operation),
- currently, *ONLY* users that do not need CPU access to the buffer are allowed.
More details are there in the documentation patch.
This is based on design suggestions from many people at the mini-summits[1], most notably from Arnd Bergmann <[email protected]>, Rob Clark <[email protected]> and Daniel Vetter <[email protected]>.
The implementation is inspired from proof-of-concept patch-set from Tomasz Stanislawski <[email protected]>, who demonstrated buffer sharing between two v4l2 devices. [2]
[1]: https://wiki.linaro.org/OfficeofCTO/MemoryManagement
[2]: http://lwn.net/Articles/454389
--- backport/compat/Kconfig | 9 + backport/compat/Makefile | 1 + backport/compat/dma-buf.c | 575 ++++++++++++++++++++++++++++++++++++++ backport/include/linux/dma-buf.h | 211 ++++++++++++++ 4 files changed, 796 insertions(+) create mode 100644 backport/compat/dma-buf.c create mode 100644 backport/include/linux/dma-buf.h
backport/compat/Kconfig +9 -0
@@ -107,7 +107,16 @@ config BACKPORT_OPTION_USB_URB_THREAD_FIX config BACKPORT_MII bool +config BACKPORT_BUILD_DMA_SHARED_BUFFER + bool + depends on ANON_INODES + depends on !BACKPORT_KERNEL_3_0 + depends on !DMA_SHARED_BUFFER || BACKPORT_KERNEL_3_5 + default y if BACKPORT_DMA_SHARED_BUFFER + default y if BACKPORT_USERSEL_BUILD_ALL +config BACKPORT_DMA_SHARED_BUFFER + bool config BACKPORT_USERSEL_BUILD_ALL bool "Build all compat code"
backport/compat/Makefile +1 -0
@@ -4,6 +4,7 @@ ccflags-y += -DBACKPORTED_KERNEL_VERSION=\"$(BACKPORTED_KERNEL_VERSION)\" ccflags-y += -DBACKPORTED_KERNEL_NAME=\"$(BACKPORTED_KERNEL_NAME)\" obj-m += compat.o compat-y += main.o +compat-$(CPTCFG_BACKPORT_BUILD_DMA_SHARED_BUFFER) += dma-buf.o obj-$(CPTCFG_BACKPORT_BUILD_FW_LOADER) += compat_firmware_class.o
backport/compat/dma-buf.c new file +575 -0
575 lines not on this page · raw message
backport/include/linux/dma-buf.h new file +211 -0
211 lines not on this page · raw message
Signature · 1 line
1.7.10.4
PATCH 2/2 compat: add HDMI library support
In reply to Luis R. RodriguezFrom: "Luis R. Rodriguez" <[email protected]>
HDMI was being carried over through compat but that was a mistake as all its doing is providing helper routines. It was also defining it as a module which was tainting the kernel! This fixes that.
mcgrof@frijol ~/linux-stable (git::master)$ git describe --contains \ f142d3bd556c5e82e9bb3d33d07d6708702ea4ce
v3.9-rc1~83^2~1^2~4
commit f142d3bd556c5e82e9bb3d33d07d6708702ea4ce
Author: Thierry Reding <[email protected]> Date: Wed Nov 21 15:29:29 2012 +0100
video: Add generic HDMI infoframe helpers
Add generic helpers to pack HDMI infoframes into binary buffers.
1 2.6.24 [ OK ] 2 2.6.25 [ OK ] 3 2.6.26 [ OK ] 4 2.6.27 [ OK ] 5 2.6.28 [ OK ] 6 2.6.29 [ OK ] 7 2.6.30 [ OK ] 8 2.6.31 [ OK ] 9 2.6.32 [ OK ] 10 2.6.33 [ OK ] 11 2.6.34 [ OK ] 12 2.6.35 [ OK ] 13 2.6.36 [ OK ] 14 2.6.37 [ OK ] 15 2.6.38 [ OK ] 16 2.6.39 [ OK ] 17 3.0.65 [ OK ] 18 3.1.10 [ OK ] 19 3.2.38 [ OK ] 20 3.3.8 [ OK ] 21 3.4.32 [ OK ] 22 3.5.7 [ OK ] 23 3.6.11 [ OK ] 24 3.7.9 [ OK ] 25 3.8.0 [ OK ] 26 3.9-rc1 [ OK ]
--- backport/compat/Kconfig | 10 ++ backport/compat/Makefile | 1 + backport/compat/hdmi.c | 308 +++++++++++++++++++++++++++++++++++++++++ backport/include/linux/hdmi.h | 240 ++++++++++++++++++++++++++++++++ 4 files changed, 559 insertions(+) create mode 100644 backport/compat/hdmi.c create mode 100644 backport/include/linux/hdmi.h
backport/compat/Kconfig +10 -0
@@ -118,6 +118,16 @@ config BACKPORT_BUILD_DMA_SHARED_BUFFER config BACKPORT_DMA_SHARED_BUFFER bool +config BACKPORT_BUILD_HDMI + bool + depends on !BACKPORT_KERNEL_3_0 + default y if BACKPORT_KERNEL_3_9 + default y if BACKPORT_USERSEL_BUILD_ALL + default y if !HDMI && BACKPORT_HDMI + +config BACKPORT_HDMI + bool + config BACKPORT_USERSEL_BUILD_ALL bool "Build all compat code" help
backport/compat/Makefile +1 -0
@@ -5,6 +5,7 @@ ccflags-y += -DBACKPORTED_KERNEL_NAME=\"$(BACKPORTED_KERNEL_NAME)\" obj-m += compat.o compat-y += main.o compat-$(CPTCFG_BACKPORT_BUILD_DMA_SHARED_BUFFER) += dma-buf.o +compat-$(CPTCFG_BACKPORT_BUILD_HDMI) += hdmi.o obj-$(CPTCFG_BACKPORT_BUILD_FW_LOADER) += compat_firmware_class.o
backport/compat/hdmi.c new file +308 -0
308 lines not on this page · raw message
backport/include/linux/hdmi.h new file +240 -0
240 lines not on this page · raw message
Signature · 1 line
1.7.10.4
Re: [PATCH 2/2] compat: add HDMI library support
backport/compat/Kconfig config BACKPORT_BUILD_DMA_SHARED_BUFFER · line 126
Quoted 12 lines · Luis R. Rodriguez
backport/compat/Kconfig +6
-0@@ -118,6 +118,16 @@ config BACKPORT_BUILD_DMA_SHARED_BUFFER config BACKPORT_DMA_SHARED_BUFFER bool +config BACKPORT_BUILD_HDMI + bool + depends on !BACKPORT_KERNEL_3_0 + default y if BACKPORT_KERNEL_3_9 + default y if BACKPORT_USERSEL_BUILD_ALL + default y if !HDMI && BACKPORT_HDMI
You enable this if HDMI wasn't supported in the base kernel and if it's needed (or build-all selected), but why also if the kernel is < 3.9? It seems it should be something like
default y if (!HDMI || BACKPORT_KERNEL_3_9) && BACKPORT_HDMI
to basically make it ignore the HDMI symbol in kernels < 3.9?
Btw, I had an idea for doing things like this automatically -- we actually know which symbols need to be changed to LINUX_BACKPORT(symbol): all the ones that are exported of course, so grep for "EXPORT_SYMBOL(_GPL)?" in the sources. It's still tricky, but we could consider trying it next time.
johannes
Re: [PATCH 2/2] compat: add HDMI library support
Quoted 19 lines · Johannes Berg
backport/compat/Kconfig config BACKPORT_BUILD_DMA_SHARED_BUFFER · line 126
Quoted 12 lines · Luis R. Rodriguez
backport/compat/Kconfig +6
-0@@ -118,6 +118,16 @@ config BACKPORT_BUILD_DMA_SHARED_BUFFER config BACKPORT_DMA_SHARED_BUFFER bool +config BACKPORT_BUILD_HDMI + bool + depends on !BACKPORT_KERNEL_3_0 + default y if BACKPORT_KERNEL_3_9 + default y if BACKPORT_USERSEL_BUILD_ALL + default y if !HDMI && BACKPORT_HDMIYou enable this if HDMI wasn't supported in the base kernel and if it's needed (or build-all selected), but why also if the kernel is < 3.9? It seems it should be something like
Quoted 3 lines
default y if (!HDMI ||
BACKPORT_KERNEL_3_9) &&BACKPORT_HDMIto basically make it ignore the HDMI symbol in kernels < 3.9?
Or like for the dmabuf stuff:
config BACKPORT_BUILD_HDMI
bool
# not possible on kernel < 3.0
depends on !BACKPORT_KERNEL_3_0
# don't build if base kernel has it, except on kernel < 3.9 depends on !HDMI || BACKPORT_KERNEL_3_9
# build for testing
default y if BACKPORT_USERSEL_BUILDALL
# build if a driver needs it
default y if BACKPORT_HDMI
I think that's more expressive as to what we want here?
(maybe we should actually have the comments in there)
johannes