staging: add omapdrm DRM/KMS driver for TI OMAP platforms
A DRM display driver for TI OMAP platform. Similar to omapfb (fbdev)
and omap_vout (v4l2 display) drivers in the past, this driver uses the
DSS2 driver to access the display hardware, including support for
HDMI, DVI, and various types of LCD panels. And it implements GEM
support for buffer allocation (for KMS as well as offscreen buffers
used by the xf86-video-omap userspace xorg driver).
The driver maps CRTCs to overlays, encoders to overlay-managers, and
connectors to dssdev's. Note that this arrangement might change slightly
when support for drm_plane overlays is added.
For GEM support, non-scanout buffers are using the shmem backed pages
provided by GEM core (In drm_gem_object_init()). In the case of scanout
buffers, which need to be physically contiguous, those are allocated
with CMA and use drm_gem_private_object_init().
See userspace xorg driver:
git://github.com/robclark/xf86-video-omap.git
Refer to this link for CMA (Continuous Memory Allocator):
http://lkml.org/lkml/2011/8/19/302
Links to previous versions of the patch:
v1: http://lwn.net/Articles/458137/
v2: http://patches.linaro.org/4156/
v3: http://patches.linaro.org/4688/
v4: http://patches.linaro.org/4791/
History:
v5: move headers from include/drm at Greg KH's request, minor rebasing
on 3.2-rc1, pull in private copies of drm_gem_{get,put}_pages()
because "drm/gem: add functions to get/put pages" patch is not
merged yet
v4: bit of rework of encoder/connector _dpms() code, modeset_init()
rework to not use nested functions, update TODO.txt
v3: minor cleanups, improved error handling for dev_load(), some minor
API changes that will be needed later for tiled buffer support
v2: replace omap_vram with CMA for scanout buffer allocation, remove
unneeded functions, use dma_addr_t for physical addresses, error
handling cleanup, refactor attach/detach pages into common drm
functions, split non-userspace-facing API into omap_priv.h, remove
plugin API
v1: original
Signed-off-by: Rob Clark <rob@ti.com>
Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-11-13 02:09:40 +08:00
|
|
|
/*
|
2017-12-06 04:29:31 +08:00
|
|
|
* Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
|
staging: add omapdrm DRM/KMS driver for TI OMAP platforms
A DRM display driver for TI OMAP platform. Similar to omapfb (fbdev)
and omap_vout (v4l2 display) drivers in the past, this driver uses the
DSS2 driver to access the display hardware, including support for
HDMI, DVI, and various types of LCD panels. And it implements GEM
support for buffer allocation (for KMS as well as offscreen buffers
used by the xf86-video-omap userspace xorg driver).
The driver maps CRTCs to overlays, encoders to overlay-managers, and
connectors to dssdev's. Note that this arrangement might change slightly
when support for drm_plane overlays is added.
For GEM support, non-scanout buffers are using the shmem backed pages
provided by GEM core (In drm_gem_object_init()). In the case of scanout
buffers, which need to be physically contiguous, those are allocated
with CMA and use drm_gem_private_object_init().
See userspace xorg driver:
git://github.com/robclark/xf86-video-omap.git
Refer to this link for CMA (Continuous Memory Allocator):
http://lkml.org/lkml/2011/8/19/302
Links to previous versions of the patch:
v1: http://lwn.net/Articles/458137/
v2: http://patches.linaro.org/4156/
v3: http://patches.linaro.org/4688/
v4: http://patches.linaro.org/4791/
History:
v5: move headers from include/drm at Greg KH's request, minor rebasing
on 3.2-rc1, pull in private copies of drm_gem_{get,put}_pages()
because "drm/gem: add functions to get/put pages" patch is not
merged yet
v4: bit of rework of encoder/connector _dpms() code, modeset_init()
rework to not use nested functions, update TODO.txt
v3: minor cleanups, improved error handling for dev_load(), some minor
API changes that will be needed later for tiled buffer support
v2: replace omap_vram with CMA for scanout buffer allocation, remove
unneeded functions, use dma_addr_t for physical addresses, error
handling cleanup, refactor attach/detach pages into common drm
functions, split non-userspace-facing API into omap_priv.h, remove
plugin API
v1: original
Signed-off-by: Rob Clark <rob@ti.com>
Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-11-13 02:09:40 +08:00
|
|
|
* Author: Rob Clark <rob.clark@linaro.org>
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify it
|
|
|
|
* under the terms of the GNU General Public License version 2 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, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2016-05-12 00:01:45 +08:00
|
|
|
#include <linux/seq_file.h>
|
staging: add omapdrm DRM/KMS driver for TI OMAP platforms
A DRM display driver for TI OMAP platform. Similar to omapfb (fbdev)
and omap_vout (v4l2 display) drivers in the past, this driver uses the
DSS2 driver to access the display hardware, including support for
HDMI, DVI, and various types of LCD panels. And it implements GEM
support for buffer allocation (for KMS as well as offscreen buffers
used by the xf86-video-omap userspace xorg driver).
The driver maps CRTCs to overlays, encoders to overlay-managers, and
connectors to dssdev's. Note that this arrangement might change slightly
when support for drm_plane overlays is added.
For GEM support, non-scanout buffers are using the shmem backed pages
provided by GEM core (In drm_gem_object_init()). In the case of scanout
buffers, which need to be physically contiguous, those are allocated
with CMA and use drm_gem_private_object_init().
See userspace xorg driver:
git://github.com/robclark/xf86-video-omap.git
Refer to this link for CMA (Continuous Memory Allocator):
http://lkml.org/lkml/2011/8/19/302
Links to previous versions of the patch:
v1: http://lwn.net/Articles/458137/
v2: http://patches.linaro.org/4156/
v3: http://patches.linaro.org/4688/
v4: http://patches.linaro.org/4791/
History:
v5: move headers from include/drm at Greg KH's request, minor rebasing
on 3.2-rc1, pull in private copies of drm_gem_{get,put}_pages()
because "drm/gem: add functions to get/put pages" patch is not
merged yet
v4: bit of rework of encoder/connector _dpms() code, modeset_init()
rework to not use nested functions, update TODO.txt
v3: minor cleanups, improved error handling for dev_load(), some minor
API changes that will be needed later for tiled buffer support
v2: replace omap_vram with CMA for scanout buffer allocation, remove
unneeded functions, use dma_addr_t for physical addresses, error
handling cleanup, refactor attach/detach pages into common drm
functions, split non-userspace-facing API into omap_priv.h, remove
plugin API
v1: original
Signed-off-by: Rob Clark <rob@ti.com>
Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-11-13 02:09:40 +08:00
|
|
|
#include <linux/shmem_fs.h>
|
2015-03-06 03:31:37 +08:00
|
|
|
#include <linux/spinlock.h>
|
2016-01-16 08:56:40 +08:00
|
|
|
#include <linux/pfn_t.h>
|
2015-03-06 03:31:37 +08:00
|
|
|
|
2013-07-25 03:07:52 +08:00
|
|
|
#include <drm/drm_vma_manager.h>
|
staging: add omapdrm DRM/KMS driver for TI OMAP platforms
A DRM display driver for TI OMAP platform. Similar to omapfb (fbdev)
and omap_vout (v4l2 display) drivers in the past, this driver uses the
DSS2 driver to access the display hardware, including support for
HDMI, DVI, and various types of LCD panels. And it implements GEM
support for buffer allocation (for KMS as well as offscreen buffers
used by the xf86-video-omap userspace xorg driver).
The driver maps CRTCs to overlays, encoders to overlay-managers, and
connectors to dssdev's. Note that this arrangement might change slightly
when support for drm_plane overlays is added.
For GEM support, non-scanout buffers are using the shmem backed pages
provided by GEM core (In drm_gem_object_init()). In the case of scanout
buffers, which need to be physically contiguous, those are allocated
with CMA and use drm_gem_private_object_init().
See userspace xorg driver:
git://github.com/robclark/xf86-video-omap.git
Refer to this link for CMA (Continuous Memory Allocator):
http://lkml.org/lkml/2011/8/19/302
Links to previous versions of the patch:
v1: http://lwn.net/Articles/458137/
v2: http://patches.linaro.org/4156/
v3: http://patches.linaro.org/4688/
v4: http://patches.linaro.org/4791/
History:
v5: move headers from include/drm at Greg KH's request, minor rebasing
on 3.2-rc1, pull in private copies of drm_gem_{get,put}_pages()
because "drm/gem: add functions to get/put pages" patch is not
merged yet
v4: bit of rework of encoder/connector _dpms() code, modeset_init()
rework to not use nested functions, update TODO.txt
v3: minor cleanups, improved error handling for dev_load(), some minor
API changes that will be needed later for tiled buffer support
v2: replace omap_vram with CMA for scanout buffer allocation, remove
unneeded functions, use dma_addr_t for physical addresses, error
handling cleanup, refactor attach/detach pages into common drm
functions, split non-userspace-facing API into omap_priv.h, remove
plugin API
v1: original
Signed-off-by: Rob Clark <rob@ti.com>
Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-11-13 02:09:40 +08:00
|
|
|
|
|
|
|
#include "omap_drv.h"
|
2011-12-06 09:19:22 +08:00
|
|
|
#include "omap_dmm_tiler.h"
|
staging: add omapdrm DRM/KMS driver for TI OMAP platforms
A DRM display driver for TI OMAP platform. Similar to omapfb (fbdev)
and omap_vout (v4l2 display) drivers in the past, this driver uses the
DSS2 driver to access the display hardware, including support for
HDMI, DVI, and various types of LCD panels. And it implements GEM
support for buffer allocation (for KMS as well as offscreen buffers
used by the xf86-video-omap userspace xorg driver).
The driver maps CRTCs to overlays, encoders to overlay-managers, and
connectors to dssdev's. Note that this arrangement might change slightly
when support for drm_plane overlays is added.
For GEM support, non-scanout buffers are using the shmem backed pages
provided by GEM core (In drm_gem_object_init()). In the case of scanout
buffers, which need to be physically contiguous, those are allocated
with CMA and use drm_gem_private_object_init().
See userspace xorg driver:
git://github.com/robclark/xf86-video-omap.git
Refer to this link for CMA (Continuous Memory Allocator):
http://lkml.org/lkml/2011/8/19/302
Links to previous versions of the patch:
v1: http://lwn.net/Articles/458137/
v2: http://patches.linaro.org/4156/
v3: http://patches.linaro.org/4688/
v4: http://patches.linaro.org/4791/
History:
v5: move headers from include/drm at Greg KH's request, minor rebasing
on 3.2-rc1, pull in private copies of drm_gem_{get,put}_pages()
because "drm/gem: add functions to get/put pages" patch is not
merged yet
v4: bit of rework of encoder/connector _dpms() code, modeset_init()
rework to not use nested functions, update TODO.txt
v3: minor cleanups, improved error handling for dev_load(), some minor
API changes that will be needed later for tiled buffer support
v2: replace omap_vram with CMA for scanout buffer allocation, remove
unneeded functions, use dma_addr_t for physical addresses, error
handling cleanup, refactor attach/detach pages into common drm
functions, split non-userspace-facing API into omap_priv.h, remove
plugin API
v1: original
Signed-off-by: Rob Clark <rob@ti.com>
Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-11-13 02:09:40 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* GEM buffer object implementation.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* note: we use upper 8 bits of flags for driver-internal flags: */
|
2015-12-15 04:39:37 +08:00
|
|
|
#define OMAP_BO_MEM_DMA_API 0x01000000 /* memory allocated with the dma_alloc_* API */
|
|
|
|
#define OMAP_BO_MEM_SHMEM 0x02000000 /* memory allocated through shmem backing */
|
2015-12-15 04:39:44 +08:00
|
|
|
#define OMAP_BO_MEM_DMABUF 0x08000000 /* memory imported from a dmabuf */
|
staging: add omapdrm DRM/KMS driver for TI OMAP platforms
A DRM display driver for TI OMAP platform. Similar to omapfb (fbdev)
and omap_vout (v4l2 display) drivers in the past, this driver uses the
DSS2 driver to access the display hardware, including support for
HDMI, DVI, and various types of LCD panels. And it implements GEM
support for buffer allocation (for KMS as well as offscreen buffers
used by the xf86-video-omap userspace xorg driver).
The driver maps CRTCs to overlays, encoders to overlay-managers, and
connectors to dssdev's. Note that this arrangement might change slightly
when support for drm_plane overlays is added.
For GEM support, non-scanout buffers are using the shmem backed pages
provided by GEM core (In drm_gem_object_init()). In the case of scanout
buffers, which need to be physically contiguous, those are allocated
with CMA and use drm_gem_private_object_init().
See userspace xorg driver:
git://github.com/robclark/xf86-video-omap.git
Refer to this link for CMA (Continuous Memory Allocator):
http://lkml.org/lkml/2011/8/19/302
Links to previous versions of the patch:
v1: http://lwn.net/Articles/458137/
v2: http://patches.linaro.org/4156/
v3: http://patches.linaro.org/4688/
v4: http://patches.linaro.org/4791/
History:
v5: move headers from include/drm at Greg KH's request, minor rebasing
on 3.2-rc1, pull in private copies of drm_gem_{get,put}_pages()
because "drm/gem: add functions to get/put pages" patch is not
merged yet
v4: bit of rework of encoder/connector _dpms() code, modeset_init()
rework to not use nested functions, update TODO.txt
v3: minor cleanups, improved error handling for dev_load(), some minor
API changes that will be needed later for tiled buffer support
v2: replace omap_vram with CMA for scanout buffer allocation, remove
unneeded functions, use dma_addr_t for physical addresses, error
handling cleanup, refactor attach/detach pages into common drm
functions, split non-userspace-facing API into omap_priv.h, remove
plugin API
v1: original
Signed-off-by: Rob Clark <rob@ti.com>
Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-11-13 02:09:40 +08:00
|
|
|
|
|
|
|
struct omap_gem_object {
|
|
|
|
struct drm_gem_object base;
|
|
|
|
|
2012-03-06 00:48:36 +08:00
|
|
|
struct list_head mm_list;
|
|
|
|
|
2018-02-11 21:07:33 +08:00
|
|
|
u32 flags;
|
staging: add omapdrm DRM/KMS driver for TI OMAP platforms
A DRM display driver for TI OMAP platform. Similar to omapfb (fbdev)
and omap_vout (v4l2 display) drivers in the past, this driver uses the
DSS2 driver to access the display hardware, including support for
HDMI, DVI, and various types of LCD panels. And it implements GEM
support for buffer allocation (for KMS as well as offscreen buffers
used by the xf86-video-omap userspace xorg driver).
The driver maps CRTCs to overlays, encoders to overlay-managers, and
connectors to dssdev's. Note that this arrangement might change slightly
when support for drm_plane overlays is added.
For GEM support, non-scanout buffers are using the shmem backed pages
provided by GEM core (In drm_gem_object_init()). In the case of scanout
buffers, which need to be physically contiguous, those are allocated
with CMA and use drm_gem_private_object_init().
See userspace xorg driver:
git://github.com/robclark/xf86-video-omap.git
Refer to this link for CMA (Continuous Memory Allocator):
http://lkml.org/lkml/2011/8/19/302
Links to previous versions of the patch:
v1: http://lwn.net/Articles/458137/
v2: http://patches.linaro.org/4156/
v3: http://patches.linaro.org/4688/
v4: http://patches.linaro.org/4791/
History:
v5: move headers from include/drm at Greg KH's request, minor rebasing
on 3.2-rc1, pull in private copies of drm_gem_{get,put}_pages()
because "drm/gem: add functions to get/put pages" patch is not
merged yet
v4: bit of rework of encoder/connector _dpms() code, modeset_init()
rework to not use nested functions, update TODO.txt
v3: minor cleanups, improved error handling for dev_load(), some minor
API changes that will be needed later for tiled buffer support
v2: replace omap_vram with CMA for scanout buffer allocation, remove
unneeded functions, use dma_addr_t for physical addresses, error
handling cleanup, refactor attach/detach pages into common drm
functions, split non-userspace-facing API into omap_priv.h, remove
plugin API
v1: original
Signed-off-by: Rob Clark <rob@ti.com>
Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-11-13 02:09:40 +08:00
|
|
|
|
2011-12-06 09:19:22 +08:00
|
|
|
/** width/height for tiled formats (rounded up to slot boundaries) */
|
2018-02-11 21:07:33 +08:00
|
|
|
u16 width, height;
|
2011-12-06 09:19:22 +08:00
|
|
|
|
2011-12-10 13:26:08 +08:00
|
|
|
/** roll applied when mapping to DMM */
|
2018-02-11 21:07:33 +08:00
|
|
|
u32 roll;
|
2011-12-10 13:26:08 +08:00
|
|
|
|
2018-05-27 00:54:33 +08:00
|
|
|
/** protects dma_addr_cnt, block, pages, dma_addrs and vaddr */
|
|
|
|
struct mutex lock;
|
|
|
|
|
staging: add omapdrm DRM/KMS driver for TI OMAP platforms
A DRM display driver for TI OMAP platform. Similar to omapfb (fbdev)
and omap_vout (v4l2 display) drivers in the past, this driver uses the
DSS2 driver to access the display hardware, including support for
HDMI, DVI, and various types of LCD panels. And it implements GEM
support for buffer allocation (for KMS as well as offscreen buffers
used by the xf86-video-omap userspace xorg driver).
The driver maps CRTCs to overlays, encoders to overlay-managers, and
connectors to dssdev's. Note that this arrangement might change slightly
when support for drm_plane overlays is added.
For GEM support, non-scanout buffers are using the shmem backed pages
provided by GEM core (In drm_gem_object_init()). In the case of scanout
buffers, which need to be physically contiguous, those are allocated
with CMA and use drm_gem_private_object_init().
See userspace xorg driver:
git://github.com/robclark/xf86-video-omap.git
Refer to this link for CMA (Continuous Memory Allocator):
http://lkml.org/lkml/2011/8/19/302
Links to previous versions of the patch:
v1: http://lwn.net/Articles/458137/
v2: http://patches.linaro.org/4156/
v3: http://patches.linaro.org/4688/
v4: http://patches.linaro.org/4791/
History:
v5: move headers from include/drm at Greg KH's request, minor rebasing
on 3.2-rc1, pull in private copies of drm_gem_{get,put}_pages()
because "drm/gem: add functions to get/put pages" patch is not
merged yet
v4: bit of rework of encoder/connector _dpms() code, modeset_init()
rework to not use nested functions, update TODO.txt
v3: minor cleanups, improved error handling for dev_load(), some minor
API changes that will be needed later for tiled buffer support
v2: replace omap_vram with CMA for scanout buffer allocation, remove
unneeded functions, use dma_addr_t for physical addresses, error
handling cleanup, refactor attach/detach pages into common drm
functions, split non-userspace-facing API into omap_priv.h, remove
plugin API
v1: original
Signed-off-by: Rob Clark <rob@ti.com>
Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-11-13 02:09:40 +08:00
|
|
|
/**
|
2017-04-21 05:33:51 +08:00
|
|
|
* dma_addr contains the buffer DMA address. It is valid for
|
staging: add omapdrm DRM/KMS driver for TI OMAP platforms
A DRM display driver for TI OMAP platform. Similar to omapfb (fbdev)
and omap_vout (v4l2 display) drivers in the past, this driver uses the
DSS2 driver to access the display hardware, including support for
HDMI, DVI, and various types of LCD panels. And it implements GEM
support for buffer allocation (for KMS as well as offscreen buffers
used by the xf86-video-omap userspace xorg driver).
The driver maps CRTCs to overlays, encoders to overlay-managers, and
connectors to dssdev's. Note that this arrangement might change slightly
when support for drm_plane overlays is added.
For GEM support, non-scanout buffers are using the shmem backed pages
provided by GEM core (In drm_gem_object_init()). In the case of scanout
buffers, which need to be physically contiguous, those are allocated
with CMA and use drm_gem_private_object_init().
See userspace xorg driver:
git://github.com/robclark/xf86-video-omap.git
Refer to this link for CMA (Continuous Memory Allocator):
http://lkml.org/lkml/2011/8/19/302
Links to previous versions of the patch:
v1: http://lwn.net/Articles/458137/
v2: http://patches.linaro.org/4156/
v3: http://patches.linaro.org/4688/
v4: http://patches.linaro.org/4791/
History:
v5: move headers from include/drm at Greg KH's request, minor rebasing
on 3.2-rc1, pull in private copies of drm_gem_{get,put}_pages()
because "drm/gem: add functions to get/put pages" patch is not
merged yet
v4: bit of rework of encoder/connector _dpms() code, modeset_init()
rework to not use nested functions, update TODO.txt
v3: minor cleanups, improved error handling for dev_load(), some minor
API changes that will be needed later for tiled buffer support
v2: replace omap_vram with CMA for scanout buffer allocation, remove
unneeded functions, use dma_addr_t for physical addresses, error
handling cleanup, refactor attach/detach pages into common drm
functions, split non-userspace-facing API into omap_priv.h, remove
plugin API
v1: original
Signed-off-by: Rob Clark <rob@ti.com>
Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-11-13 02:09:40 +08:00
|
|
|
*
|
2015-12-15 04:39:44 +08:00
|
|
|
* - buffers allocated through the DMA mapping API (with the
|
|
|
|
* OMAP_BO_MEM_DMA_API flag set)
|
|
|
|
*
|
|
|
|
* - buffers imported from dmabuf (with the OMAP_BO_MEM_DMABUF flag set)
|
|
|
|
* if they are physically contiguous (when sgt->orig_nents == 1)
|
|
|
|
*
|
2017-04-21 05:33:51 +08:00
|
|
|
* - buffers mapped through the TILER when dma_addr_cnt is not zero, in
|
2015-12-15 04:39:44 +08:00
|
|
|
* which case the DMA address points to the TILER aperture
|
|
|
|
*
|
|
|
|
* Physically contiguous buffers have their DMA address equal to the
|
|
|
|
* physical address as we don't remap those buffers through the TILER.
|
|
|
|
*
|
|
|
|
* Buffers mapped to the TILER have their DMA address pointing to the
|
2017-04-21 05:33:51 +08:00
|
|
|
* TILER aperture. As TILER mappings are refcounted (through
|
2017-04-21 05:33:52 +08:00
|
|
|
* dma_addr_cnt) the DMA address must be accessed through omap_gem_pin()
|
|
|
|
* to ensure that the mapping won't disappear unexpectedly. References
|
|
|
|
* must be released with omap_gem_unpin().
|
staging: add omapdrm DRM/KMS driver for TI OMAP platforms
A DRM display driver for TI OMAP platform. Similar to omapfb (fbdev)
and omap_vout (v4l2 display) drivers in the past, this driver uses the
DSS2 driver to access the display hardware, including support for
HDMI, DVI, and various types of LCD panels. And it implements GEM
support for buffer allocation (for KMS as well as offscreen buffers
used by the xf86-video-omap userspace xorg driver).
The driver maps CRTCs to overlays, encoders to overlay-managers, and
connectors to dssdev's. Note that this arrangement might change slightly
when support for drm_plane overlays is added.
For GEM support, non-scanout buffers are using the shmem backed pages
provided by GEM core (In drm_gem_object_init()). In the case of scanout
buffers, which need to be physically contiguous, those are allocated
with CMA and use drm_gem_private_object_init().
See userspace xorg driver:
git://github.com/robclark/xf86-video-omap.git
Refer to this link for CMA (Continuous Memory Allocator):
http://lkml.org/lkml/2011/8/19/302
Links to previous versions of the patch:
v1: http://lwn.net/Articles/458137/
v2: http://patches.linaro.org/4156/
v3: http://patches.linaro.org/4688/
v4: http://patches.linaro.org/4791/
History:
v5: move headers from include/drm at Greg KH's request, minor rebasing
on 3.2-rc1, pull in private copies of drm_gem_{get,put}_pages()
because "drm/gem: add functions to get/put pages" patch is not
merged yet
v4: bit of rework of encoder/connector _dpms() code, modeset_init()
rework to not use nested functions, update TODO.txt
v3: minor cleanups, improved error handling for dev_load(), some minor
API changes that will be needed later for tiled buffer support
v2: replace omap_vram with CMA for scanout buffer allocation, remove
unneeded functions, use dma_addr_t for physical addresses, error
handling cleanup, refactor attach/detach pages into common drm
functions, split non-userspace-facing API into omap_priv.h, remove
plugin API
v1: original
Signed-off-by: Rob Clark <rob@ti.com>
Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-11-13 02:09:40 +08:00
|
|
|
*/
|
2017-04-21 05:33:51 +08:00
|
|
|
dma_addr_t dma_addr;
|
staging: add omapdrm DRM/KMS driver for TI OMAP platforms
A DRM display driver for TI OMAP platform. Similar to omapfb (fbdev)
and omap_vout (v4l2 display) drivers in the past, this driver uses the
DSS2 driver to access the display hardware, including support for
HDMI, DVI, and various types of LCD panels. And it implements GEM
support for buffer allocation (for KMS as well as offscreen buffers
used by the xf86-video-omap userspace xorg driver).
The driver maps CRTCs to overlays, encoders to overlay-managers, and
connectors to dssdev's. Note that this arrangement might change slightly
when support for drm_plane overlays is added.
For GEM support, non-scanout buffers are using the shmem backed pages
provided by GEM core (In drm_gem_object_init()). In the case of scanout
buffers, which need to be physically contiguous, those are allocated
with CMA and use drm_gem_private_object_init().
See userspace xorg driver:
git://github.com/robclark/xf86-video-omap.git
Refer to this link for CMA (Continuous Memory Allocator):
http://lkml.org/lkml/2011/8/19/302
Links to previous versions of the patch:
v1: http://lwn.net/Articles/458137/
v2: http://patches.linaro.org/4156/
v3: http://patches.linaro.org/4688/
v4: http://patches.linaro.org/4791/
History:
v5: move headers from include/drm at Greg KH's request, minor rebasing
on 3.2-rc1, pull in private copies of drm_gem_{get,put}_pages()
because "drm/gem: add functions to get/put pages" patch is not
merged yet
v4: bit of rework of encoder/connector _dpms() code, modeset_init()
rework to not use nested functions, update TODO.txt
v3: minor cleanups, improved error handling for dev_load(), some minor
API changes that will be needed later for tiled buffer support
v2: replace omap_vram with CMA for scanout buffer allocation, remove
unneeded functions, use dma_addr_t for physical addresses, error
handling cleanup, refactor attach/detach pages into common drm
functions, split non-userspace-facing API into omap_priv.h, remove
plugin API
v1: original
Signed-off-by: Rob Clark <rob@ti.com>
Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-11-13 02:09:40 +08:00
|
|
|
|
2011-12-06 09:19:22 +08:00
|
|
|
/**
|
2017-04-21 05:33:51 +08:00
|
|
|
* # of users of dma_addr
|
2011-12-06 09:19:22 +08:00
|
|
|
*/
|
2018-02-11 21:07:33 +08:00
|
|
|
u32 dma_addr_cnt;
|
2011-12-06 09:19:22 +08:00
|
|
|
|
2015-12-15 04:39:44 +08:00
|
|
|
/**
|
|
|
|
* If the buffer has been imported from a dmabuf the OMAP_DB_DMABUF flag
|
|
|
|
* is set and the sgt field is valid.
|
|
|
|
*/
|
|
|
|
struct sg_table *sgt;
|
|
|
|
|
2011-12-06 09:19:22 +08:00
|
|
|
/**
|
|
|
|
* tiler block used when buffer is remapped in DMM/TILER.
|
|
|
|
*/
|
|
|
|
struct tiler_block *block;
|
|
|
|
|
staging: add omapdrm DRM/KMS driver for TI OMAP platforms
A DRM display driver for TI OMAP platform. Similar to omapfb (fbdev)
and omap_vout (v4l2 display) drivers in the past, this driver uses the
DSS2 driver to access the display hardware, including support for
HDMI, DVI, and various types of LCD panels. And it implements GEM
support for buffer allocation (for KMS as well as offscreen buffers
used by the xf86-video-omap userspace xorg driver).
The driver maps CRTCs to overlays, encoders to overlay-managers, and
connectors to dssdev's. Note that this arrangement might change slightly
when support for drm_plane overlays is added.
For GEM support, non-scanout buffers are using the shmem backed pages
provided by GEM core (In drm_gem_object_init()). In the case of scanout
buffers, which need to be physically contiguous, those are allocated
with CMA and use drm_gem_private_object_init().
See userspace xorg driver:
git://github.com/robclark/xf86-video-omap.git
Refer to this link for CMA (Continuous Memory Allocator):
http://lkml.org/lkml/2011/8/19/302
Links to previous versions of the patch:
v1: http://lwn.net/Articles/458137/
v2: http://patches.linaro.org/4156/
v3: http://patches.linaro.org/4688/
v4: http://patches.linaro.org/4791/
History:
v5: move headers from include/drm at Greg KH's request, minor rebasing
on 3.2-rc1, pull in private copies of drm_gem_{get,put}_pages()
because "drm/gem: add functions to get/put pages" patch is not
merged yet
v4: bit of rework of encoder/connector _dpms() code, modeset_init()
rework to not use nested functions, update TODO.txt
v3: minor cleanups, improved error handling for dev_load(), some minor
API changes that will be needed later for tiled buffer support
v2: replace omap_vram with CMA for scanout buffer allocation, remove
unneeded functions, use dma_addr_t for physical addresses, error
handling cleanup, refactor attach/detach pages into common drm
functions, split non-userspace-facing API into omap_priv.h, remove
plugin API
v1: original
Signed-off-by: Rob Clark <rob@ti.com>
Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-11-13 02:09:40 +08:00
|
|
|
/**
|
|
|
|
* Array of backing pages, if allocated. Note that pages are never
|
|
|
|
* allocated for buffers originally allocated from contiguous memory
|
|
|
|
*/
|
|
|
|
struct page **pages;
|
|
|
|
|
2011-12-21 06:54:28 +08:00
|
|
|
/** addresses corresponding to pages in above array */
|
2017-04-21 05:33:54 +08:00
|
|
|
dma_addr_t *dma_addrs;
|
2011-12-21 06:54:28 +08:00
|
|
|
|
staging: add omapdrm DRM/KMS driver for TI OMAP platforms
A DRM display driver for TI OMAP platform. Similar to omapfb (fbdev)
and omap_vout (v4l2 display) drivers in the past, this driver uses the
DSS2 driver to access the display hardware, including support for
HDMI, DVI, and various types of LCD panels. And it implements GEM
support for buffer allocation (for KMS as well as offscreen buffers
used by the xf86-video-omap userspace xorg driver).
The driver maps CRTCs to overlays, encoders to overlay-managers, and
connectors to dssdev's. Note that this arrangement might change slightly
when support for drm_plane overlays is added.
For GEM support, non-scanout buffers are using the shmem backed pages
provided by GEM core (In drm_gem_object_init()). In the case of scanout
buffers, which need to be physically contiguous, those are allocated
with CMA and use drm_gem_private_object_init().
See userspace xorg driver:
git://github.com/robclark/xf86-video-omap.git
Refer to this link for CMA (Continuous Memory Allocator):
http://lkml.org/lkml/2011/8/19/302
Links to previous versions of the patch:
v1: http://lwn.net/Articles/458137/
v2: http://patches.linaro.org/4156/
v3: http://patches.linaro.org/4688/
v4: http://patches.linaro.org/4791/
History:
v5: move headers from include/drm at Greg KH's request, minor rebasing
on 3.2-rc1, pull in private copies of drm_gem_{get,put}_pages()
because "drm/gem: add functions to get/put pages" patch is not
merged yet
v4: bit of rework of encoder/connector _dpms() code, modeset_init()
rework to not use nested functions, update TODO.txt
v3: minor cleanups, improved error handling for dev_load(), some minor
API changes that will be needed later for tiled buffer support
v2: replace omap_vram with CMA for scanout buffer allocation, remove
unneeded functions, use dma_addr_t for physical addresses, error
handling cleanup, refactor attach/detach pages into common drm
functions, split non-userspace-facing API into omap_priv.h, remove
plugin API
v1: original
Signed-off-by: Rob Clark <rob@ti.com>
Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-11-13 02:09:40 +08:00
|
|
|
/**
|
|
|
|
* Virtual address, if mapped.
|
|
|
|
*/
|
|
|
|
void *vaddr;
|
|
|
|
};
|
|
|
|
|
2015-12-15 04:39:33 +08:00
|
|
|
#define to_omap_bo(x) container_of(x, struct omap_gem_object, base)
|
2012-01-19 08:33:02 +08:00
|
|
|
|
2011-12-06 09:19:22 +08:00
|
|
|
/* To deal with userspace mmap'ings of 2d tiled buffers, which (a) are
|
|
|
|
* not necessarily pinned in TILER all the time, and (b) when they are
|
|
|
|
* they are not necessarily page aligned, we reserve one or more small
|
|
|
|
* regions in each of the 2d containers to use as a user-GART where we
|
|
|
|
* can create a second page-aligned mapping of parts of the buffer
|
|
|
|
* being accessed from userspace.
|
|
|
|
*
|
|
|
|
* Note that we could optimize slightly when we know that multiple
|
|
|
|
* tiler containers are backed by the same PAT.. but I'll leave that
|
|
|
|
* for later..
|
|
|
|
*/
|
|
|
|
#define NUM_USERGART_ENTRIES 2
|
2015-12-15 04:39:34 +08:00
|
|
|
struct omap_drm_usergart_entry {
|
2011-12-06 09:19:22 +08:00
|
|
|
struct tiler_block *block; /* the reserved tiler block */
|
2017-04-21 05:33:51 +08:00
|
|
|
dma_addr_t dma_addr;
|
2011-12-06 09:19:22 +08:00
|
|
|
struct drm_gem_object *obj; /* the current pinned obj */
|
|
|
|
pgoff_t obj_pgoff; /* page offset of obj currently
|
|
|
|
mapped in */
|
|
|
|
};
|
2015-12-15 04:39:34 +08:00
|
|
|
|
|
|
|
struct omap_drm_usergart {
|
|
|
|
struct omap_drm_usergart_entry entry[NUM_USERGART_ENTRIES];
|
2011-12-06 09:19:22 +08:00
|
|
|
int height; /* height in rows */
|
|
|
|
int height_shift; /* ilog2(height in rows) */
|
|
|
|
int slot_shift; /* ilog2(width per slot) */
|
|
|
|
int stride_pfn; /* stride in pages */
|
|
|
|
int last; /* index of last used entry */
|
2015-12-15 04:39:34 +08:00
|
|
|
};
|
2011-12-06 09:19:22 +08:00
|
|
|
|
2015-12-15 04:39:32 +08:00
|
|
|
/* -----------------------------------------------------------------------------
|
|
|
|
* Helpers
|
|
|
|
*/
|
|
|
|
|
|
|
|
/** get mmap offset */
|
2018-05-26 00:39:22 +08:00
|
|
|
u64 omap_gem_mmap_offset(struct drm_gem_object *obj)
|
2015-12-15 04:39:32 +08:00
|
|
|
{
|
|
|
|
struct drm_device *dev = obj->dev;
|
|
|
|
int ret;
|
|
|
|
size_t size;
|
|
|
|
|
|
|
|
/* Make it mmapable */
|
|
|
|
size = omap_gem_mmap_size(obj);
|
|
|
|
ret = drm_gem_create_mmap_offset_size(obj, size);
|
|
|
|
if (ret) {
|
|
|
|
dev_err(dev->dev, "could not allocate mmap offset\n");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
return drm_vma_node_offset_addr(&obj->vma_node);
|
|
|
|
}
|
|
|
|
|
2018-05-26 00:39:20 +08:00
|
|
|
static bool omap_gem_is_contiguous(struct omap_gem_object *omap_obj)
|
2015-12-15 04:39:33 +08:00
|
|
|
{
|
2015-12-15 04:39:44 +08:00
|
|
|
if (omap_obj->flags & OMAP_BO_MEM_DMA_API)
|
|
|
|
return true;
|
|
|
|
|
|
|
|
if ((omap_obj->flags & OMAP_BO_MEM_DMABUF) && omap_obj->sgt->nents == 1)
|
|
|
|
return true;
|
|
|
|
|
|
|
|
return false;
|
2015-12-15 04:39:33 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* -----------------------------------------------------------------------------
|
|
|
|
* Eviction
|
|
|
|
*/
|
2011-12-06 09:19:22 +08:00
|
|
|
|
2018-05-26 00:39:20 +08:00
|
|
|
static void omap_gem_evict_entry(struct drm_gem_object *obj,
|
2015-12-15 04:39:34 +08:00
|
|
|
enum tiler_fmt fmt, struct omap_drm_usergart_entry *entry)
|
2011-12-06 09:19:22 +08:00
|
|
|
{
|
2014-01-03 21:24:19 +08:00
|
|
|
struct omap_gem_object *omap_obj = to_omap_bo(obj);
|
2015-12-15 04:39:34 +08:00
|
|
|
struct omap_drm_private *priv = obj->dev->dev_private;
|
|
|
|
int n = priv->usergart[fmt].height;
|
2014-01-03 21:24:19 +08:00
|
|
|
size_t size = PAGE_SIZE * n;
|
2018-05-26 00:39:22 +08:00
|
|
|
loff_t off = omap_gem_mmap_offset(obj) +
|
2014-01-03 21:24:19 +08:00
|
|
|
(entry->obj_pgoff << PAGE_SHIFT);
|
2017-05-18 16:51:51 +08:00
|
|
|
const int m = DIV_ROUND_UP(omap_obj->width << fmt, PAGE_SIZE);
|
2014-01-03 21:24:19 +08:00
|
|
|
|
|
|
|
if (m > 1) {
|
|
|
|
int i;
|
|
|
|
/* if stride > than PAGE_SIZE then sparse mapping: */
|
|
|
|
for (i = n; i > 0; i--) {
|
|
|
|
unmap_mapping_range(obj->dev->anon_inode->i_mapping,
|
|
|
|
off, PAGE_SIZE, 1);
|
|
|
|
off += PAGE_SIZE * m;
|
2012-03-06 00:48:40 +08:00
|
|
|
}
|
2014-01-03 21:24:19 +08:00
|
|
|
} else {
|
|
|
|
unmap_mapping_range(obj->dev->anon_inode->i_mapping,
|
|
|
|
off, size, 1);
|
2011-12-06 09:19:22 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
entry->obj = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Evict a buffer from usergart, if it is mapped there */
|
2018-05-26 00:39:20 +08:00
|
|
|
static void omap_gem_evict(struct drm_gem_object *obj)
|
2011-12-06 09:19:22 +08:00
|
|
|
{
|
|
|
|
struct omap_gem_object *omap_obj = to_omap_bo(obj);
|
2015-12-15 04:39:34 +08:00
|
|
|
struct omap_drm_private *priv = obj->dev->dev_private;
|
2011-12-06 09:19:22 +08:00
|
|
|
|
|
|
|
if (omap_obj->flags & OMAP_BO_TILED) {
|
|
|
|
enum tiler_fmt fmt = gem2fmt(omap_obj->flags);
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < NUM_USERGART_ENTRIES; i++) {
|
2015-12-15 04:39:34 +08:00
|
|
|
struct omap_drm_usergart_entry *entry =
|
|
|
|
&priv->usergart[fmt].entry[i];
|
|
|
|
|
2011-12-06 09:19:22 +08:00
|
|
|
if (entry->obj == obj)
|
2018-05-26 00:39:20 +08:00
|
|
|
omap_gem_evict_entry(obj, fmt, entry);
|
2011-12-06 09:19:22 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-12-15 04:39:33 +08:00
|
|
|
/* -----------------------------------------------------------------------------
|
|
|
|
* Page Management
|
2012-05-17 16:37:25 +08:00
|
|
|
*/
|
staging: add omapdrm DRM/KMS driver for TI OMAP platforms
A DRM display driver for TI OMAP platform. Similar to omapfb (fbdev)
and omap_vout (v4l2 display) drivers in the past, this driver uses the
DSS2 driver to access the display hardware, including support for
HDMI, DVI, and various types of LCD panels. And it implements GEM
support for buffer allocation (for KMS as well as offscreen buffers
used by the xf86-video-omap userspace xorg driver).
The driver maps CRTCs to overlays, encoders to overlay-managers, and
connectors to dssdev's. Note that this arrangement might change slightly
when support for drm_plane overlays is added.
For GEM support, non-scanout buffers are using the shmem backed pages
provided by GEM core (In drm_gem_object_init()). In the case of scanout
buffers, which need to be physically contiguous, those are allocated
with CMA and use drm_gem_private_object_init().
See userspace xorg driver:
git://github.com/robclark/xf86-video-omap.git
Refer to this link for CMA (Continuous Memory Allocator):
http://lkml.org/lkml/2011/8/19/302
Links to previous versions of the patch:
v1: http://lwn.net/Articles/458137/
v2: http://patches.linaro.org/4156/
v3: http://patches.linaro.org/4688/
v4: http://patches.linaro.org/4791/
History:
v5: move headers from include/drm at Greg KH's request, minor rebasing
on 3.2-rc1, pull in private copies of drm_gem_{get,put}_pages()
because "drm/gem: add functions to get/put pages" patch is not
merged yet
v4: bit of rework of encoder/connector _dpms() code, modeset_init()
rework to not use nested functions, update TODO.txt
v3: minor cleanups, improved error handling for dev_load(), some minor
API changes that will be needed later for tiled buffer support
v2: replace omap_vram with CMA for scanout buffer allocation, remove
unneeded functions, use dma_addr_t for physical addresses, error
handling cleanup, refactor attach/detach pages into common drm
functions, split non-userspace-facing API into omap_priv.h, remove
plugin API
v1: original
Signed-off-by: Rob Clark <rob@ti.com>
Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-11-13 02:09:40 +08:00
|
|
|
|
2018-05-27 00:54:33 +08:00
|
|
|
/*
|
|
|
|
* Ensure backing pages are allocated. Must be called with the omap_obj.lock
|
|
|
|
* held.
|
|
|
|
*/
|
staging: add omapdrm DRM/KMS driver for TI OMAP platforms
A DRM display driver for TI OMAP platform. Similar to omapfb (fbdev)
and omap_vout (v4l2 display) drivers in the past, this driver uses the
DSS2 driver to access the display hardware, including support for
HDMI, DVI, and various types of LCD panels. And it implements GEM
support for buffer allocation (for KMS as well as offscreen buffers
used by the xf86-video-omap userspace xorg driver).
The driver maps CRTCs to overlays, encoders to overlay-managers, and
connectors to dssdev's. Note that this arrangement might change slightly
when support for drm_plane overlays is added.
For GEM support, non-scanout buffers are using the shmem backed pages
provided by GEM core (In drm_gem_object_init()). In the case of scanout
buffers, which need to be physically contiguous, those are allocated
with CMA and use drm_gem_private_object_init().
See userspace xorg driver:
git://github.com/robclark/xf86-video-omap.git
Refer to this link for CMA (Continuous Memory Allocator):
http://lkml.org/lkml/2011/8/19/302
Links to previous versions of the patch:
v1: http://lwn.net/Articles/458137/
v2: http://patches.linaro.org/4156/
v3: http://patches.linaro.org/4688/
v4: http://patches.linaro.org/4791/
History:
v5: move headers from include/drm at Greg KH's request, minor rebasing
on 3.2-rc1, pull in private copies of drm_gem_{get,put}_pages()
because "drm/gem: add functions to get/put pages" patch is not
merged yet
v4: bit of rework of encoder/connector _dpms() code, modeset_init()
rework to not use nested functions, update TODO.txt
v3: minor cleanups, improved error handling for dev_load(), some minor
API changes that will be needed later for tiled buffer support
v2: replace omap_vram with CMA for scanout buffer allocation, remove
unneeded functions, use dma_addr_t for physical addresses, error
handling cleanup, refactor attach/detach pages into common drm
functions, split non-userspace-facing API into omap_priv.h, remove
plugin API
v1: original
Signed-off-by: Rob Clark <rob@ti.com>
Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-11-13 02:09:40 +08:00
|
|
|
static int omap_gem_attach_pages(struct drm_gem_object *obj)
|
|
|
|
{
|
2012-05-17 16:37:25 +08:00
|
|
|
struct drm_device *dev = obj->dev;
|
staging: add omapdrm DRM/KMS driver for TI OMAP platforms
A DRM display driver for TI OMAP platform. Similar to omapfb (fbdev)
and omap_vout (v4l2 display) drivers in the past, this driver uses the
DSS2 driver to access the display hardware, including support for
HDMI, DVI, and various types of LCD panels. And it implements GEM
support for buffer allocation (for KMS as well as offscreen buffers
used by the xf86-video-omap userspace xorg driver).
The driver maps CRTCs to overlays, encoders to overlay-managers, and
connectors to dssdev's. Note that this arrangement might change slightly
when support for drm_plane overlays is added.
For GEM support, non-scanout buffers are using the shmem backed pages
provided by GEM core (In drm_gem_object_init()). In the case of scanout
buffers, which need to be physically contiguous, those are allocated
with CMA and use drm_gem_private_object_init().
See userspace xorg driver:
git://github.com/robclark/xf86-video-omap.git
Refer to this link for CMA (Continuous Memory Allocator):
http://lkml.org/lkml/2011/8/19/302
Links to previous versions of the patch:
v1: http://lwn.net/Articles/458137/
v2: http://patches.linaro.org/4156/
v3: http://patches.linaro.org/4688/
v4: http://patches.linaro.org/4791/
History:
v5: move headers from include/drm at Greg KH's request, minor rebasing
on 3.2-rc1, pull in private copies of drm_gem_{get,put}_pages()
because "drm/gem: add functions to get/put pages" patch is not
merged yet
v4: bit of rework of encoder/connector _dpms() code, modeset_init()
rework to not use nested functions, update TODO.txt
v3: minor cleanups, improved error handling for dev_load(), some minor
API changes that will be needed later for tiled buffer support
v2: replace omap_vram with CMA for scanout buffer allocation, remove
unneeded functions, use dma_addr_t for physical addresses, error
handling cleanup, refactor attach/detach pages into common drm
functions, split non-userspace-facing API into omap_priv.h, remove
plugin API
v1: original
Signed-off-by: Rob Clark <rob@ti.com>
Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-11-13 02:09:40 +08:00
|
|
|
struct omap_gem_object *omap_obj = to_omap_bo(obj);
|
|
|
|
struct page **pages;
|
2012-08-18 00:53:26 +08:00
|
|
|
int npages = obj->size >> PAGE_SHIFT;
|
|
|
|
int i, ret;
|
2012-05-17 16:37:25 +08:00
|
|
|
dma_addr_t *addrs;
|
staging: add omapdrm DRM/KMS driver for TI OMAP platforms
A DRM display driver for TI OMAP platform. Similar to omapfb (fbdev)
and omap_vout (v4l2 display) drivers in the past, this driver uses the
DSS2 driver to access the display hardware, including support for
HDMI, DVI, and various types of LCD panels. And it implements GEM
support for buffer allocation (for KMS as well as offscreen buffers
used by the xf86-video-omap userspace xorg driver).
The driver maps CRTCs to overlays, encoders to overlay-managers, and
connectors to dssdev's. Note that this arrangement might change slightly
when support for drm_plane overlays is added.
For GEM support, non-scanout buffers are using the shmem backed pages
provided by GEM core (In drm_gem_object_init()). In the case of scanout
buffers, which need to be physically contiguous, those are allocated
with CMA and use drm_gem_private_object_init().
See userspace xorg driver:
git://github.com/robclark/xf86-video-omap.git
Refer to this link for CMA (Continuous Memory Allocator):
http://lkml.org/lkml/2011/8/19/302
Links to previous versions of the patch:
v1: http://lwn.net/Articles/458137/
v2: http://patches.linaro.org/4156/
v3: http://patches.linaro.org/4688/
v4: http://patches.linaro.org/4791/
History:
v5: move headers from include/drm at Greg KH's request, minor rebasing
on 3.2-rc1, pull in private copies of drm_gem_{get,put}_pages()
because "drm/gem: add functions to get/put pages" patch is not
merged yet
v4: bit of rework of encoder/connector _dpms() code, modeset_init()
rework to not use nested functions, update TODO.txt
v3: minor cleanups, improved error handling for dev_load(), some minor
API changes that will be needed later for tiled buffer support
v2: replace omap_vram with CMA for scanout buffer allocation, remove
unneeded functions, use dma_addr_t for physical addresses, error
handling cleanup, refactor attach/detach pages into common drm
functions, split non-userspace-facing API into omap_priv.h, remove
plugin API
v1: original
Signed-off-by: Rob Clark <rob@ti.com>
Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-11-13 02:09:40 +08:00
|
|
|
|
2018-05-27 00:54:33 +08:00
|
|
|
lockdep_assert_held(&omap_obj->lock);
|
|
|
|
|
2018-05-26 00:39:21 +08:00
|
|
|
/*
|
|
|
|
* If not using shmem (in which case backing pages don't need to be
|
|
|
|
* allocated) or if pages are already allocated we're done.
|
|
|
|
*/
|
|
|
|
if (!(omap_obj->flags & OMAP_BO_MEM_SHMEM) || omap_obj->pages)
|
|
|
|
return 0;
|
staging: add omapdrm DRM/KMS driver for TI OMAP platforms
A DRM display driver for TI OMAP platform. Similar to omapfb (fbdev)
and omap_vout (v4l2 display) drivers in the past, this driver uses the
DSS2 driver to access the display hardware, including support for
HDMI, DVI, and various types of LCD panels. And it implements GEM
support for buffer allocation (for KMS as well as offscreen buffers
used by the xf86-video-omap userspace xorg driver).
The driver maps CRTCs to overlays, encoders to overlay-managers, and
connectors to dssdev's. Note that this arrangement might change slightly
when support for drm_plane overlays is added.
For GEM support, non-scanout buffers are using the shmem backed pages
provided by GEM core (In drm_gem_object_init()). In the case of scanout
buffers, which need to be physically contiguous, those are allocated
with CMA and use drm_gem_private_object_init().
See userspace xorg driver:
git://github.com/robclark/xf86-video-omap.git
Refer to this link for CMA (Continuous Memory Allocator):
http://lkml.org/lkml/2011/8/19/302
Links to previous versions of the patch:
v1: http://lwn.net/Articles/458137/
v2: http://patches.linaro.org/4156/
v3: http://patches.linaro.org/4688/
v4: http://patches.linaro.org/4791/
History:
v5: move headers from include/drm at Greg KH's request, minor rebasing
on 3.2-rc1, pull in private copies of drm_gem_{get,put}_pages()
because "drm/gem: add functions to get/put pages" patch is not
merged yet
v4: bit of rework of encoder/connector _dpms() code, modeset_init()
rework to not use nested functions, update TODO.txt
v3: minor cleanups, improved error handling for dev_load(), some minor
API changes that will be needed later for tiled buffer support
v2: replace omap_vram with CMA for scanout buffer allocation, remove
unneeded functions, use dma_addr_t for physical addresses, error
handling cleanup, refactor attach/detach pages into common drm
functions, split non-userspace-facing API into omap_priv.h, remove
plugin API
v1: original
Signed-off-by: Rob Clark <rob@ti.com>
Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-11-13 02:09:40 +08:00
|
|
|
|
drm/gem: remove misleading gfp parameter to get_pages()
drm_gem_get_pages() currently allows passing a 'gfp' parameter that is
passed to shmem combined with mapping_gfp_mask(). Given that the default
mapping_gfp_mask() is GFP_HIGHUSER, it is _very_ unlikely that anyone will
ever make use of that parameter. In fact, all drivers currently pass
redundant flags or 0.
This patch removes the 'gfp' parameter. The only reason to keep it is to
remove flags like __GFP_WAIT. But in its current form, it can only be used
to add flags. So to remove __GFP_WAIT, you'd have to drop it from the
mapping_gfp_mask, which again is stupid as this mask is used by shmem-core
for other allocations, too.
If any driver ever requires that parameter, we can introduce a new helper
that takes the raw 'gfp' parameter. The caller'd be responsible to combine
it with mapping_gfp_mask() in a suitable way. The current
drm_gem_get_pages() helper would then simply use mapping_gfp_mask() and
call the new helper. This is what shmem_read_mapping_pages{_gfp,} does
right now.
Moreover, the gfp-zone flag-usage is not obvious: If you pass a modified
zone, shmem core will WARN() or even BUG(). In other words, the following
must be true for 'gfp' passed to shmem_read_mapping_pages_gfp():
gfp_zone(mapping_gfp_mask(mapping)) == gfp_zone(gfp)
Add a comment to drm_gem_read_pages() explaining that constraint.
Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
2014-05-25 18:59:47 +08:00
|
|
|
pages = drm_gem_get_pages(obj);
|
staging: add omapdrm DRM/KMS driver for TI OMAP platforms
A DRM display driver for TI OMAP platform. Similar to omapfb (fbdev)
and omap_vout (v4l2 display) drivers in the past, this driver uses the
DSS2 driver to access the display hardware, including support for
HDMI, DVI, and various types of LCD panels. And it implements GEM
support for buffer allocation (for KMS as well as offscreen buffers
used by the xf86-video-omap userspace xorg driver).
The driver maps CRTCs to overlays, encoders to overlay-managers, and
connectors to dssdev's. Note that this arrangement might change slightly
when support for drm_plane overlays is added.
For GEM support, non-scanout buffers are using the shmem backed pages
provided by GEM core (In drm_gem_object_init()). In the case of scanout
buffers, which need to be physically contiguous, those are allocated
with CMA and use drm_gem_private_object_init().
See userspace xorg driver:
git://github.com/robclark/xf86-video-omap.git
Refer to this link for CMA (Continuous Memory Allocator):
http://lkml.org/lkml/2011/8/19/302
Links to previous versions of the patch:
v1: http://lwn.net/Articles/458137/
v2: http://patches.linaro.org/4156/
v3: http://patches.linaro.org/4688/
v4: http://patches.linaro.org/4791/
History:
v5: move headers from include/drm at Greg KH's request, minor rebasing
on 3.2-rc1, pull in private copies of drm_gem_{get,put}_pages()
because "drm/gem: add functions to get/put pages" patch is not
merged yet
v4: bit of rework of encoder/connector _dpms() code, modeset_init()
rework to not use nested functions, update TODO.txt
v3: minor cleanups, improved error handling for dev_load(), some minor
API changes that will be needed later for tiled buffer support
v2: replace omap_vram with CMA for scanout buffer allocation, remove
unneeded functions, use dma_addr_t for physical addresses, error
handling cleanup, refactor attach/detach pages into common drm
functions, split non-userspace-facing API into omap_priv.h, remove
plugin API
v1: original
Signed-off-by: Rob Clark <rob@ti.com>
Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-11-13 02:09:40 +08:00
|
|
|
if (IS_ERR(pages)) {
|
|
|
|
dev_err(obj->dev->dev, "could not get pages: %ld\n", PTR_ERR(pages));
|
|
|
|
return PTR_ERR(pages);
|
|
|
|
}
|
|
|
|
|
2011-12-21 06:54:28 +08:00
|
|
|
/* for non-cached buffers, ensure the new pages are clean because
|
|
|
|
* DSS, GPU, etc. are not cache coherent:
|
|
|
|
*/
|
|
|
|
if (omap_obj->flags & (OMAP_BO_WC|OMAP_BO_UNCACHED)) {
|
treewide: kmalloc() -> kmalloc_array()
The kmalloc() function has a 2-factor argument form, kmalloc_array(). This
patch replaces cases of:
kmalloc(a * b, gfp)
with:
kmalloc_array(a * b, gfp)
as well as handling cases of:
kmalloc(a * b * c, gfp)
with:
kmalloc(array3_size(a, b, c), gfp)
as it's slightly less ugly than:
kmalloc_array(array_size(a, b), c, gfp)
This does, however, attempt to ignore constant size factors like:
kmalloc(4 * 1024, gfp)
though any constants defined via macros get caught up in the conversion.
Any factors with a sizeof() of "unsigned char", "char", and "u8" were
dropped, since they're redundant.
The tools/ directory was manually excluded, since it has its own
implementation of kmalloc().
The Coccinelle script used for this was:
// Fix redundant parens around sizeof().
@@
type TYPE;
expression THING, E;
@@
(
kmalloc(
- (sizeof(TYPE)) * E
+ sizeof(TYPE) * E
, ...)
|
kmalloc(
- (sizeof(THING)) * E
+ sizeof(THING) * E
, ...)
)
// Drop single-byte sizes and redundant parens.
@@
expression COUNT;
typedef u8;
typedef __u8;
@@
(
kmalloc(
- sizeof(u8) * (COUNT)
+ COUNT
, ...)
|
kmalloc(
- sizeof(__u8) * (COUNT)
+ COUNT
, ...)
|
kmalloc(
- sizeof(char) * (COUNT)
+ COUNT
, ...)
|
kmalloc(
- sizeof(unsigned char) * (COUNT)
+ COUNT
, ...)
|
kmalloc(
- sizeof(u8) * COUNT
+ COUNT
, ...)
|
kmalloc(
- sizeof(__u8) * COUNT
+ COUNT
, ...)
|
kmalloc(
- sizeof(char) * COUNT
+ COUNT
, ...)
|
kmalloc(
- sizeof(unsigned char) * COUNT
+ COUNT
, ...)
)
// 2-factor product with sizeof(type/expression) and identifier or constant.
@@
type TYPE;
expression THING;
identifier COUNT_ID;
constant COUNT_CONST;
@@
(
- kmalloc
+ kmalloc_array
(
- sizeof(TYPE) * (COUNT_ID)
+ COUNT_ID, sizeof(TYPE)
, ...)
|
- kmalloc
+ kmalloc_array
(
- sizeof(TYPE) * COUNT_ID
+ COUNT_ID, sizeof(TYPE)
, ...)
|
- kmalloc
+ kmalloc_array
(
- sizeof(TYPE) * (COUNT_CONST)
+ COUNT_CONST, sizeof(TYPE)
, ...)
|
- kmalloc
+ kmalloc_array
(
- sizeof(TYPE) * COUNT_CONST
+ COUNT_CONST, sizeof(TYPE)
, ...)
|
- kmalloc
+ kmalloc_array
(
- sizeof(THING) * (COUNT_ID)
+ COUNT_ID, sizeof(THING)
, ...)
|
- kmalloc
+ kmalloc_array
(
- sizeof(THING) * COUNT_ID
+ COUNT_ID, sizeof(THING)
, ...)
|
- kmalloc
+ kmalloc_array
(
- sizeof(THING) * (COUNT_CONST)
+ COUNT_CONST, sizeof(THING)
, ...)
|
- kmalloc
+ kmalloc_array
(
- sizeof(THING) * COUNT_CONST
+ COUNT_CONST, sizeof(THING)
, ...)
)
// 2-factor product, only identifiers.
@@
identifier SIZE, COUNT;
@@
- kmalloc
+ kmalloc_array
(
- SIZE * COUNT
+ COUNT, SIZE
, ...)
// 3-factor product with 1 sizeof(type) or sizeof(expression), with
// redundant parens removed.
@@
expression THING;
identifier STRIDE, COUNT;
type TYPE;
@@
(
kmalloc(
- sizeof(TYPE) * (COUNT) * (STRIDE)
+ array3_size(COUNT, STRIDE, sizeof(TYPE))
, ...)
|
kmalloc(
- sizeof(TYPE) * (COUNT) * STRIDE
+ array3_size(COUNT, STRIDE, sizeof(TYPE))
, ...)
|
kmalloc(
- sizeof(TYPE) * COUNT * (STRIDE)
+ array3_size(COUNT, STRIDE, sizeof(TYPE))
, ...)
|
kmalloc(
- sizeof(TYPE) * COUNT * STRIDE
+ array3_size(COUNT, STRIDE, sizeof(TYPE))
, ...)
|
kmalloc(
- sizeof(THING) * (COUNT) * (STRIDE)
+ array3_size(COUNT, STRIDE, sizeof(THING))
, ...)
|
kmalloc(
- sizeof(THING) * (COUNT) * STRIDE
+ array3_size(COUNT, STRIDE, sizeof(THING))
, ...)
|
kmalloc(
- sizeof(THING) * COUNT * (STRIDE)
+ array3_size(COUNT, STRIDE, sizeof(THING))
, ...)
|
kmalloc(
- sizeof(THING) * COUNT * STRIDE
+ array3_size(COUNT, STRIDE, sizeof(THING))
, ...)
)
// 3-factor product with 2 sizeof(variable), with redundant parens removed.
@@
expression THING1, THING2;
identifier COUNT;
type TYPE1, TYPE2;
@@
(
kmalloc(
- sizeof(TYPE1) * sizeof(TYPE2) * COUNT
+ array3_size(COUNT, sizeof(TYPE1), sizeof(TYPE2))
, ...)
|
kmalloc(
- sizeof(TYPE1) * sizeof(THING2) * (COUNT)
+ array3_size(COUNT, sizeof(TYPE1), sizeof(TYPE2))
, ...)
|
kmalloc(
- sizeof(THING1) * sizeof(THING2) * COUNT
+ array3_size(COUNT, sizeof(THING1), sizeof(THING2))
, ...)
|
kmalloc(
- sizeof(THING1) * sizeof(THING2) * (COUNT)
+ array3_size(COUNT, sizeof(THING1), sizeof(THING2))
, ...)
|
kmalloc(
- sizeof(TYPE1) * sizeof(THING2) * COUNT
+ array3_size(COUNT, sizeof(TYPE1), sizeof(THING2))
, ...)
|
kmalloc(
- sizeof(TYPE1) * sizeof(THING2) * (COUNT)
+ array3_size(COUNT, sizeof(TYPE1), sizeof(THING2))
, ...)
)
// 3-factor product, only identifiers, with redundant parens removed.
@@
identifier STRIDE, SIZE, COUNT;
@@
(
kmalloc(
- (COUNT) * STRIDE * SIZE
+ array3_size(COUNT, STRIDE, SIZE)
, ...)
|
kmalloc(
- COUNT * (STRIDE) * SIZE
+ array3_size(COUNT, STRIDE, SIZE)
, ...)
|
kmalloc(
- COUNT * STRIDE * (SIZE)
+ array3_size(COUNT, STRIDE, SIZE)
, ...)
|
kmalloc(
- (COUNT) * (STRIDE) * SIZE
+ array3_size(COUNT, STRIDE, SIZE)
, ...)
|
kmalloc(
- COUNT * (STRIDE) * (SIZE)
+ array3_size(COUNT, STRIDE, SIZE)
, ...)
|
kmalloc(
- (COUNT) * STRIDE * (SIZE)
+ array3_size(COUNT, STRIDE, SIZE)
, ...)
|
kmalloc(
- (COUNT) * (STRIDE) * (SIZE)
+ array3_size(COUNT, STRIDE, SIZE)
, ...)
|
kmalloc(
- COUNT * STRIDE * SIZE
+ array3_size(COUNT, STRIDE, SIZE)
, ...)
)
// Any remaining multi-factor products, first at least 3-factor products,
// when they're not all constants...
@@
expression E1, E2, E3;
constant C1, C2, C3;
@@
(
kmalloc(C1 * C2 * C3, ...)
|
kmalloc(
- (E1) * E2 * E3
+ array3_size(E1, E2, E3)
, ...)
|
kmalloc(
- (E1) * (E2) * E3
+ array3_size(E1, E2, E3)
, ...)
|
kmalloc(
- (E1) * (E2) * (E3)
+ array3_size(E1, E2, E3)
, ...)
|
kmalloc(
- E1 * E2 * E3
+ array3_size(E1, E2, E3)
, ...)
)
// And then all remaining 2 factors products when they're not all constants,
// keeping sizeof() as the second factor argument.
@@
expression THING, E1, E2;
type TYPE;
constant C1, C2, C3;
@@
(
kmalloc(sizeof(THING) * C2, ...)
|
kmalloc(sizeof(TYPE) * C2, ...)
|
kmalloc(C1 * C2 * C3, ...)
|
kmalloc(C1 * C2, ...)
|
- kmalloc
+ kmalloc_array
(
- sizeof(TYPE) * (E2)
+ E2, sizeof(TYPE)
, ...)
|
- kmalloc
+ kmalloc_array
(
- sizeof(TYPE) * E2
+ E2, sizeof(TYPE)
, ...)
|
- kmalloc
+ kmalloc_array
(
- sizeof(THING) * (E2)
+ E2, sizeof(THING)
, ...)
|
- kmalloc
+ kmalloc_array
(
- sizeof(THING) * E2
+ E2, sizeof(THING)
, ...)
|
- kmalloc
+ kmalloc_array
(
- (E1) * E2
+ E1, E2
, ...)
|
- kmalloc
+ kmalloc_array
(
- (E1) * (E2)
+ E1, E2
, ...)
|
- kmalloc
+ kmalloc_array
(
- E1 * E2
+ E1, E2
, ...)
)
Signed-off-by: Kees Cook <keescook@chromium.org>
2018-06-13 04:55:00 +08:00
|
|
|
addrs = kmalloc_array(npages, sizeof(*addrs), GFP_KERNEL);
|
2012-08-18 00:53:26 +08:00
|
|
|
if (!addrs) {
|
|
|
|
ret = -ENOMEM;
|
|
|
|
goto free_pages;
|
|
|
|
}
|
|
|
|
|
2011-12-21 06:54:28 +08:00
|
|
|
for (i = 0; i < npages; i++) {
|
2012-05-17 16:37:25 +08:00
|
|
|
addrs[i] = dma_map_page(dev->dev, pages[i],
|
2017-04-21 05:33:58 +08:00
|
|
|
0, PAGE_SIZE, DMA_TO_DEVICE);
|
2016-01-05 17:43:14 +08:00
|
|
|
|
|
|
|
if (dma_mapping_error(dev->dev, addrs[i])) {
|
|
|
|
dev_warn(dev->dev,
|
|
|
|
"%s: failed to map page\n", __func__);
|
|
|
|
|
|
|
|
for (i = i - 1; i >= 0; --i) {
|
|
|
|
dma_unmap_page(dev->dev, addrs[i],
|
2017-04-21 05:33:58 +08:00
|
|
|
PAGE_SIZE, DMA_TO_DEVICE);
|
2016-01-05 17:43:14 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
ret = -ENOMEM;
|
|
|
|
goto free_addrs;
|
|
|
|
}
|
2011-12-21 06:54:28 +08:00
|
|
|
}
|
2012-05-17 16:37:25 +08:00
|
|
|
} else {
|
treewide: kzalloc() -> kcalloc()
The kzalloc() function has a 2-factor argument form, kcalloc(). This
patch replaces cases of:
kzalloc(a * b, gfp)
with:
kcalloc(a * b, gfp)
as well as handling cases of:
kzalloc(a * b * c, gfp)
with:
kzalloc(array3_size(a, b, c), gfp)
as it's slightly less ugly than:
kzalloc_array(array_size(a, b), c, gfp)
This does, however, attempt to ignore constant size factors like:
kzalloc(4 * 1024, gfp)
though any constants defined via macros get caught up in the conversion.
Any factors with a sizeof() of "unsigned char", "char", and "u8" were
dropped, since they're redundant.
The Coccinelle script used for this was:
// Fix redundant parens around sizeof().
@@
type TYPE;
expression THING, E;
@@
(
kzalloc(
- (sizeof(TYPE)) * E
+ sizeof(TYPE) * E
, ...)
|
kzalloc(
- (sizeof(THING)) * E
+ sizeof(THING) * E
, ...)
)
// Drop single-byte sizes and redundant parens.
@@
expression COUNT;
typedef u8;
typedef __u8;
@@
(
kzalloc(
- sizeof(u8) * (COUNT)
+ COUNT
, ...)
|
kzalloc(
- sizeof(__u8) * (COUNT)
+ COUNT
, ...)
|
kzalloc(
- sizeof(char) * (COUNT)
+ COUNT
, ...)
|
kzalloc(
- sizeof(unsigned char) * (COUNT)
+ COUNT
, ...)
|
kzalloc(
- sizeof(u8) * COUNT
+ COUNT
, ...)
|
kzalloc(
- sizeof(__u8) * COUNT
+ COUNT
, ...)
|
kzalloc(
- sizeof(char) * COUNT
+ COUNT
, ...)
|
kzalloc(
- sizeof(unsigned char) * COUNT
+ COUNT
, ...)
)
// 2-factor product with sizeof(type/expression) and identifier or constant.
@@
type TYPE;
expression THING;
identifier COUNT_ID;
constant COUNT_CONST;
@@
(
- kzalloc
+ kcalloc
(
- sizeof(TYPE) * (COUNT_ID)
+ COUNT_ID, sizeof(TYPE)
, ...)
|
- kzalloc
+ kcalloc
(
- sizeof(TYPE) * COUNT_ID
+ COUNT_ID, sizeof(TYPE)
, ...)
|
- kzalloc
+ kcalloc
(
- sizeof(TYPE) * (COUNT_CONST)
+ COUNT_CONST, sizeof(TYPE)
, ...)
|
- kzalloc
+ kcalloc
(
- sizeof(TYPE) * COUNT_CONST
+ COUNT_CONST, sizeof(TYPE)
, ...)
|
- kzalloc
+ kcalloc
(
- sizeof(THING) * (COUNT_ID)
+ COUNT_ID, sizeof(THING)
, ...)
|
- kzalloc
+ kcalloc
(
- sizeof(THING) * COUNT_ID
+ COUNT_ID, sizeof(THING)
, ...)
|
- kzalloc
+ kcalloc
(
- sizeof(THING) * (COUNT_CONST)
+ COUNT_CONST, sizeof(THING)
, ...)
|
- kzalloc
+ kcalloc
(
- sizeof(THING) * COUNT_CONST
+ COUNT_CONST, sizeof(THING)
, ...)
)
// 2-factor product, only identifiers.
@@
identifier SIZE, COUNT;
@@
- kzalloc
+ kcalloc
(
- SIZE * COUNT
+ COUNT, SIZE
, ...)
// 3-factor product with 1 sizeof(type) or sizeof(expression), with
// redundant parens removed.
@@
expression THING;
identifier STRIDE, COUNT;
type TYPE;
@@
(
kzalloc(
- sizeof(TYPE) * (COUNT) * (STRIDE)
+ array3_size(COUNT, STRIDE, sizeof(TYPE))
, ...)
|
kzalloc(
- sizeof(TYPE) * (COUNT) * STRIDE
+ array3_size(COUNT, STRIDE, sizeof(TYPE))
, ...)
|
kzalloc(
- sizeof(TYPE) * COUNT * (STRIDE)
+ array3_size(COUNT, STRIDE, sizeof(TYPE))
, ...)
|
kzalloc(
- sizeof(TYPE) * COUNT * STRIDE
+ array3_size(COUNT, STRIDE, sizeof(TYPE))
, ...)
|
kzalloc(
- sizeof(THING) * (COUNT) * (STRIDE)
+ array3_size(COUNT, STRIDE, sizeof(THING))
, ...)
|
kzalloc(
- sizeof(THING) * (COUNT) * STRIDE
+ array3_size(COUNT, STRIDE, sizeof(THING))
, ...)
|
kzalloc(
- sizeof(THING) * COUNT * (STRIDE)
+ array3_size(COUNT, STRIDE, sizeof(THING))
, ...)
|
kzalloc(
- sizeof(THING) * COUNT * STRIDE
+ array3_size(COUNT, STRIDE, sizeof(THING))
, ...)
)
// 3-factor product with 2 sizeof(variable), with redundant parens removed.
@@
expression THING1, THING2;
identifier COUNT;
type TYPE1, TYPE2;
@@
(
kzalloc(
- sizeof(TYPE1) * sizeof(TYPE2) * COUNT
+ array3_size(COUNT, sizeof(TYPE1), sizeof(TYPE2))
, ...)
|
kzalloc(
- sizeof(TYPE1) * sizeof(THING2) * (COUNT)
+ array3_size(COUNT, sizeof(TYPE1), sizeof(TYPE2))
, ...)
|
kzalloc(
- sizeof(THING1) * sizeof(THING2) * COUNT
+ array3_size(COUNT, sizeof(THING1), sizeof(THING2))
, ...)
|
kzalloc(
- sizeof(THING1) * sizeof(THING2) * (COUNT)
+ array3_size(COUNT, sizeof(THING1), sizeof(THING2))
, ...)
|
kzalloc(
- sizeof(TYPE1) * sizeof(THING2) * COUNT
+ array3_size(COUNT, sizeof(TYPE1), sizeof(THING2))
, ...)
|
kzalloc(
- sizeof(TYPE1) * sizeof(THING2) * (COUNT)
+ array3_size(COUNT, sizeof(TYPE1), sizeof(THING2))
, ...)
)
// 3-factor product, only identifiers, with redundant parens removed.
@@
identifier STRIDE, SIZE, COUNT;
@@
(
kzalloc(
- (COUNT) * STRIDE * SIZE
+ array3_size(COUNT, STRIDE, SIZE)
, ...)
|
kzalloc(
- COUNT * (STRIDE) * SIZE
+ array3_size(COUNT, STRIDE, SIZE)
, ...)
|
kzalloc(
- COUNT * STRIDE * (SIZE)
+ array3_size(COUNT, STRIDE, SIZE)
, ...)
|
kzalloc(
- (COUNT) * (STRIDE) * SIZE
+ array3_size(COUNT, STRIDE, SIZE)
, ...)
|
kzalloc(
- COUNT * (STRIDE) * (SIZE)
+ array3_size(COUNT, STRIDE, SIZE)
, ...)
|
kzalloc(
- (COUNT) * STRIDE * (SIZE)
+ array3_size(COUNT, STRIDE, SIZE)
, ...)
|
kzalloc(
- (COUNT) * (STRIDE) * (SIZE)
+ array3_size(COUNT, STRIDE, SIZE)
, ...)
|
kzalloc(
- COUNT * STRIDE * SIZE
+ array3_size(COUNT, STRIDE, SIZE)
, ...)
)
// Any remaining multi-factor products, first at least 3-factor products,
// when they're not all constants...
@@
expression E1, E2, E3;
constant C1, C2, C3;
@@
(
kzalloc(C1 * C2 * C3, ...)
|
kzalloc(
- (E1) * E2 * E3
+ array3_size(E1, E2, E3)
, ...)
|
kzalloc(
- (E1) * (E2) * E3
+ array3_size(E1, E2, E3)
, ...)
|
kzalloc(
- (E1) * (E2) * (E3)
+ array3_size(E1, E2, E3)
, ...)
|
kzalloc(
- E1 * E2 * E3
+ array3_size(E1, E2, E3)
, ...)
)
// And then all remaining 2 factors products when they're not all constants,
// keeping sizeof() as the second factor argument.
@@
expression THING, E1, E2;
type TYPE;
constant C1, C2, C3;
@@
(
kzalloc(sizeof(THING) * C2, ...)
|
kzalloc(sizeof(TYPE) * C2, ...)
|
kzalloc(C1 * C2 * C3, ...)
|
kzalloc(C1 * C2, ...)
|
- kzalloc
+ kcalloc
(
- sizeof(TYPE) * (E2)
+ E2, sizeof(TYPE)
, ...)
|
- kzalloc
+ kcalloc
(
- sizeof(TYPE) * E2
+ E2, sizeof(TYPE)
, ...)
|
- kzalloc
+ kcalloc
(
- sizeof(THING) * (E2)
+ E2, sizeof(THING)
, ...)
|
- kzalloc
+ kcalloc
(
- sizeof(THING) * E2
+ E2, sizeof(THING)
, ...)
|
- kzalloc
+ kcalloc
(
- (E1) * E2
+ E1, E2
, ...)
|
- kzalloc
+ kcalloc
(
- (E1) * (E2)
+ E1, E2
, ...)
|
- kzalloc
+ kcalloc
(
- E1 * E2
+ E1, E2
, ...)
)
Signed-off-by: Kees Cook <keescook@chromium.org>
2018-06-13 05:03:40 +08:00
|
|
|
addrs = kcalloc(npages, sizeof(*addrs), GFP_KERNEL);
|
2012-08-18 00:53:26 +08:00
|
|
|
if (!addrs) {
|
|
|
|
ret = -ENOMEM;
|
|
|
|
goto free_pages;
|
|
|
|
}
|
2011-12-21 06:54:28 +08:00
|
|
|
}
|
|
|
|
|
2017-04-21 05:33:54 +08:00
|
|
|
omap_obj->dma_addrs = addrs;
|
staging: add omapdrm DRM/KMS driver for TI OMAP platforms
A DRM display driver for TI OMAP platform. Similar to omapfb (fbdev)
and omap_vout (v4l2 display) drivers in the past, this driver uses the
DSS2 driver to access the display hardware, including support for
HDMI, DVI, and various types of LCD panels. And it implements GEM
support for buffer allocation (for KMS as well as offscreen buffers
used by the xf86-video-omap userspace xorg driver).
The driver maps CRTCs to overlays, encoders to overlay-managers, and
connectors to dssdev's. Note that this arrangement might change slightly
when support for drm_plane overlays is added.
For GEM support, non-scanout buffers are using the shmem backed pages
provided by GEM core (In drm_gem_object_init()). In the case of scanout
buffers, which need to be physically contiguous, those are allocated
with CMA and use drm_gem_private_object_init().
See userspace xorg driver:
git://github.com/robclark/xf86-video-omap.git
Refer to this link for CMA (Continuous Memory Allocator):
http://lkml.org/lkml/2011/8/19/302
Links to previous versions of the patch:
v1: http://lwn.net/Articles/458137/
v2: http://patches.linaro.org/4156/
v3: http://patches.linaro.org/4688/
v4: http://patches.linaro.org/4791/
History:
v5: move headers from include/drm at Greg KH's request, minor rebasing
on 3.2-rc1, pull in private copies of drm_gem_{get,put}_pages()
because "drm/gem: add functions to get/put pages" patch is not
merged yet
v4: bit of rework of encoder/connector _dpms() code, modeset_init()
rework to not use nested functions, update TODO.txt
v3: minor cleanups, improved error handling for dev_load(), some minor
API changes that will be needed later for tiled buffer support
v2: replace omap_vram with CMA for scanout buffer allocation, remove
unneeded functions, use dma_addr_t for physical addresses, error
handling cleanup, refactor attach/detach pages into common drm
functions, split non-userspace-facing API into omap_priv.h, remove
plugin API
v1: original
Signed-off-by: Rob Clark <rob@ti.com>
Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-11-13 02:09:40 +08:00
|
|
|
omap_obj->pages = pages;
|
2012-05-17 16:37:25 +08:00
|
|
|
|
staging: add omapdrm DRM/KMS driver for TI OMAP platforms
A DRM display driver for TI OMAP platform. Similar to omapfb (fbdev)
and omap_vout (v4l2 display) drivers in the past, this driver uses the
DSS2 driver to access the display hardware, including support for
HDMI, DVI, and various types of LCD panels. And it implements GEM
support for buffer allocation (for KMS as well as offscreen buffers
used by the xf86-video-omap userspace xorg driver).
The driver maps CRTCs to overlays, encoders to overlay-managers, and
connectors to dssdev's. Note that this arrangement might change slightly
when support for drm_plane overlays is added.
For GEM support, non-scanout buffers are using the shmem backed pages
provided by GEM core (In drm_gem_object_init()). In the case of scanout
buffers, which need to be physically contiguous, those are allocated
with CMA and use drm_gem_private_object_init().
See userspace xorg driver:
git://github.com/robclark/xf86-video-omap.git
Refer to this link for CMA (Continuous Memory Allocator):
http://lkml.org/lkml/2011/8/19/302
Links to previous versions of the patch:
v1: http://lwn.net/Articles/458137/
v2: http://patches.linaro.org/4156/
v3: http://patches.linaro.org/4688/
v4: http://patches.linaro.org/4791/
History:
v5: move headers from include/drm at Greg KH's request, minor rebasing
on 3.2-rc1, pull in private copies of drm_gem_{get,put}_pages()
because "drm/gem: add functions to get/put pages" patch is not
merged yet
v4: bit of rework of encoder/connector _dpms() code, modeset_init()
rework to not use nested functions, update TODO.txt
v3: minor cleanups, improved error handling for dev_load(), some minor
API changes that will be needed later for tiled buffer support
v2: replace omap_vram with CMA for scanout buffer allocation, remove
unneeded functions, use dma_addr_t for physical addresses, error
handling cleanup, refactor attach/detach pages into common drm
functions, split non-userspace-facing API into omap_priv.h, remove
plugin API
v1: original
Signed-off-by: Rob Clark <rob@ti.com>
Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-11-13 02:09:40 +08:00
|
|
|
return 0;
|
2012-08-18 00:53:26 +08:00
|
|
|
|
2016-01-05 17:43:14 +08:00
|
|
|
free_addrs:
|
|
|
|
kfree(addrs);
|
2012-08-18 00:53:26 +08:00
|
|
|
free_pages:
|
2013-08-08 01:41:27 +08:00
|
|
|
drm_gem_put_pages(obj, pages, true, false);
|
2012-08-18 00:53:26 +08:00
|
|
|
|
|
|
|
return ret;
|
staging: add omapdrm DRM/KMS driver for TI OMAP platforms
A DRM display driver for TI OMAP platform. Similar to omapfb (fbdev)
and omap_vout (v4l2 display) drivers in the past, this driver uses the
DSS2 driver to access the display hardware, including support for
HDMI, DVI, and various types of LCD panels. And it implements GEM
support for buffer allocation (for KMS as well as offscreen buffers
used by the xf86-video-omap userspace xorg driver).
The driver maps CRTCs to overlays, encoders to overlay-managers, and
connectors to dssdev's. Note that this arrangement might change slightly
when support for drm_plane overlays is added.
For GEM support, non-scanout buffers are using the shmem backed pages
provided by GEM core (In drm_gem_object_init()). In the case of scanout
buffers, which need to be physically contiguous, those are allocated
with CMA and use drm_gem_private_object_init().
See userspace xorg driver:
git://github.com/robclark/xf86-video-omap.git
Refer to this link for CMA (Continuous Memory Allocator):
http://lkml.org/lkml/2011/8/19/302
Links to previous versions of the patch:
v1: http://lwn.net/Articles/458137/
v2: http://patches.linaro.org/4156/
v3: http://patches.linaro.org/4688/
v4: http://patches.linaro.org/4791/
History:
v5: move headers from include/drm at Greg KH's request, minor rebasing
on 3.2-rc1, pull in private copies of drm_gem_{get,put}_pages()
because "drm/gem: add functions to get/put pages" patch is not
merged yet
v4: bit of rework of encoder/connector _dpms() code, modeset_init()
rework to not use nested functions, update TODO.txt
v3: minor cleanups, improved error handling for dev_load(), some minor
API changes that will be needed later for tiled buffer support
v2: replace omap_vram with CMA for scanout buffer allocation, remove
unneeded functions, use dma_addr_t for physical addresses, error
handling cleanup, refactor attach/detach pages into common drm
functions, split non-userspace-facing API into omap_priv.h, remove
plugin API
v1: original
Signed-off-by: Rob Clark <rob@ti.com>
Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-11-13 02:09:40 +08:00
|
|
|
}
|
|
|
|
|
2018-05-27 00:54:33 +08:00
|
|
|
/* Release backing pages. Must be called with the omap_obj.lock held. */
|
staging: add omapdrm DRM/KMS driver for TI OMAP platforms
A DRM display driver for TI OMAP platform. Similar to omapfb (fbdev)
and omap_vout (v4l2 display) drivers in the past, this driver uses the
DSS2 driver to access the display hardware, including support for
HDMI, DVI, and various types of LCD panels. And it implements GEM
support for buffer allocation (for KMS as well as offscreen buffers
used by the xf86-video-omap userspace xorg driver).
The driver maps CRTCs to overlays, encoders to overlay-managers, and
connectors to dssdev's. Note that this arrangement might change slightly
when support for drm_plane overlays is added.
For GEM support, non-scanout buffers are using the shmem backed pages
provided by GEM core (In drm_gem_object_init()). In the case of scanout
buffers, which need to be physically contiguous, those are allocated
with CMA and use drm_gem_private_object_init().
See userspace xorg driver:
git://github.com/robclark/xf86-video-omap.git
Refer to this link for CMA (Continuous Memory Allocator):
http://lkml.org/lkml/2011/8/19/302
Links to previous versions of the patch:
v1: http://lwn.net/Articles/458137/
v2: http://patches.linaro.org/4156/
v3: http://patches.linaro.org/4688/
v4: http://patches.linaro.org/4791/
History:
v5: move headers from include/drm at Greg KH's request, minor rebasing
on 3.2-rc1, pull in private copies of drm_gem_{get,put}_pages()
because "drm/gem: add functions to get/put pages" patch is not
merged yet
v4: bit of rework of encoder/connector _dpms() code, modeset_init()
rework to not use nested functions, update TODO.txt
v3: minor cleanups, improved error handling for dev_load(), some minor
API changes that will be needed later for tiled buffer support
v2: replace omap_vram with CMA for scanout buffer allocation, remove
unneeded functions, use dma_addr_t for physical addresses, error
handling cleanup, refactor attach/detach pages into common drm
functions, split non-userspace-facing API into omap_priv.h, remove
plugin API
v1: original
Signed-off-by: Rob Clark <rob@ti.com>
Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-11-13 02:09:40 +08:00
|
|
|
static void omap_gem_detach_pages(struct drm_gem_object *obj)
|
|
|
|
{
|
|
|
|
struct omap_gem_object *omap_obj = to_omap_bo(obj);
|
2017-04-21 05:33:57 +08:00
|
|
|
unsigned int npages = obj->size >> PAGE_SHIFT;
|
|
|
|
unsigned int i;
|
2011-12-21 06:54:28 +08:00
|
|
|
|
2018-05-27 00:54:33 +08:00
|
|
|
lockdep_assert_held(&omap_obj->lock);
|
|
|
|
|
2017-04-21 05:33:57 +08:00
|
|
|
for (i = 0; i < npages; i++) {
|
|
|
|
if (omap_obj->dma_addrs[i])
|
|
|
|
dma_unmap_page(obj->dev->dev, omap_obj->dma_addrs[i],
|
2017-04-21 05:33:58 +08:00
|
|
|
PAGE_SIZE, DMA_TO_DEVICE);
|
2011-12-21 06:54:28 +08:00
|
|
|
}
|
|
|
|
|
2017-04-21 05:33:54 +08:00
|
|
|
kfree(omap_obj->dma_addrs);
|
|
|
|
omap_obj->dma_addrs = NULL;
|
2012-05-17 16:37:25 +08:00
|
|
|
|
2013-08-08 01:41:27 +08:00
|
|
|
drm_gem_put_pages(obj, omap_obj->pages, true, false);
|
staging: add omapdrm DRM/KMS driver for TI OMAP platforms
A DRM display driver for TI OMAP platform. Similar to omapfb (fbdev)
and omap_vout (v4l2 display) drivers in the past, this driver uses the
DSS2 driver to access the display hardware, including support for
HDMI, DVI, and various types of LCD panels. And it implements GEM
support for buffer allocation (for KMS as well as offscreen buffers
used by the xf86-video-omap userspace xorg driver).
The driver maps CRTCs to overlays, encoders to overlay-managers, and
connectors to dssdev's. Note that this arrangement might change slightly
when support for drm_plane overlays is added.
For GEM support, non-scanout buffers are using the shmem backed pages
provided by GEM core (In drm_gem_object_init()). In the case of scanout
buffers, which need to be physically contiguous, those are allocated
with CMA and use drm_gem_private_object_init().
See userspace xorg driver:
git://github.com/robclark/xf86-video-omap.git
Refer to this link for CMA (Continuous Memory Allocator):
http://lkml.org/lkml/2011/8/19/302
Links to previous versions of the patch:
v1: http://lwn.net/Articles/458137/
v2: http://patches.linaro.org/4156/
v3: http://patches.linaro.org/4688/
v4: http://patches.linaro.org/4791/
History:
v5: move headers from include/drm at Greg KH's request, minor rebasing
on 3.2-rc1, pull in private copies of drm_gem_{get,put}_pages()
because "drm/gem: add functions to get/put pages" patch is not
merged yet
v4: bit of rework of encoder/connector _dpms() code, modeset_init()
rework to not use nested functions, update TODO.txt
v3: minor cleanups, improved error handling for dev_load(), some minor
API changes that will be needed later for tiled buffer support
v2: replace omap_vram with CMA for scanout buffer allocation, remove
unneeded functions, use dma_addr_t for physical addresses, error
handling cleanup, refactor attach/detach pages into common drm
functions, split non-userspace-facing API into omap_priv.h, remove
plugin API
v1: original
Signed-off-by: Rob Clark <rob@ti.com>
Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-11-13 02:09:40 +08:00
|
|
|
omap_obj->pages = NULL;
|
|
|
|
}
|
|
|
|
|
2012-04-11 02:19:55 +08:00
|
|
|
/* get buffer flags */
|
2018-02-11 21:07:33 +08:00
|
|
|
u32 omap_gem_flags(struct drm_gem_object *obj)
|
2012-04-11 02:19:55 +08:00
|
|
|
{
|
|
|
|
return to_omap_bo(obj)->flags;
|
|
|
|
}
|
|
|
|
|
2011-12-06 09:19:22 +08:00
|
|
|
/** get mmap size */
|
|
|
|
size_t omap_gem_mmap_size(struct drm_gem_object *obj)
|
|
|
|
{
|
|
|
|
struct omap_gem_object *omap_obj = to_omap_bo(obj);
|
|
|
|
size_t size = obj->size;
|
|
|
|
|
|
|
|
if (omap_obj->flags & OMAP_BO_TILED) {
|
|
|
|
/* for tiled buffers, the virtual size has stride rounded up
|
|
|
|
* to 4kb.. (to hide the fact that row n+1 might start 16kb or
|
|
|
|
* 32kb later!). But we don't back the entire buffer with
|
|
|
|
* pages, only the valid picture part.. so need to adjust for
|
|
|
|
* this in the size used to mmap and generate mmap offset
|
|
|
|
*/
|
|
|
|
size = tiler_vsize(gem2fmt(omap_obj->flags),
|
|
|
|
omap_obj->width, omap_obj->height);
|
|
|
|
}
|
|
|
|
|
|
|
|
return size;
|
|
|
|
}
|
|
|
|
|
2015-12-15 04:39:33 +08:00
|
|
|
/* -----------------------------------------------------------------------------
|
|
|
|
* Fault Handling
|
|
|
|
*/
|
|
|
|
|
2011-12-06 09:19:22 +08:00
|
|
|
/* Normal handling for the case of faulting in non-tiled buffers */
|
2018-05-26 00:39:20 +08:00
|
|
|
static vm_fault_t omap_gem_fault_1d(struct drm_gem_object *obj,
|
2011-12-06 09:19:22 +08:00
|
|
|
struct vm_area_struct *vma, struct vm_fault *vmf)
|
|
|
|
{
|
|
|
|
struct omap_gem_object *omap_obj = to_omap_bo(obj);
|
|
|
|
unsigned long pfn;
|
|
|
|
pgoff_t pgoff;
|
|
|
|
|
|
|
|
/* We don't use vmf->pgoff since that has the fake offset: */
|
2016-12-15 07:07:01 +08:00
|
|
|
pgoff = (vmf->address - vma->vm_start) >> PAGE_SHIFT;
|
2011-12-06 09:19:22 +08:00
|
|
|
|
|
|
|
if (omap_obj->pages) {
|
2017-04-21 05:33:55 +08:00
|
|
|
omap_gem_cpu_sync_page(obj, pgoff);
|
2011-12-06 09:19:22 +08:00
|
|
|
pfn = page_to_pfn(omap_obj->pages[pgoff]);
|
|
|
|
} else {
|
2018-05-26 00:39:20 +08:00
|
|
|
BUG_ON(!omap_gem_is_contiguous(omap_obj));
|
2017-04-21 05:33:51 +08:00
|
|
|
pfn = (omap_obj->dma_addr >> PAGE_SHIFT) + pgoff;
|
2011-12-06 09:19:22 +08:00
|
|
|
}
|
|
|
|
|
2016-12-15 07:07:01 +08:00
|
|
|
VERB("Inserting %p pfn %lx, pa %lx", (void *)vmf->address,
|
2011-12-06 09:19:22 +08:00
|
|
|
pfn, pfn << PAGE_SHIFT);
|
|
|
|
|
2018-05-23 02:13:57 +08:00
|
|
|
return vmf_insert_mixed(vma, vmf->address,
|
|
|
|
__pfn_to_pfn_t(pfn, PFN_DEV));
|
2011-12-06 09:19:22 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Special handling for the case of faulting in 2d tiled buffers */
|
2018-05-26 00:39:20 +08:00
|
|
|
static vm_fault_t omap_gem_fault_2d(struct drm_gem_object *obj,
|
2011-12-06 09:19:22 +08:00
|
|
|
struct vm_area_struct *vma, struct vm_fault *vmf)
|
|
|
|
{
|
|
|
|
struct omap_gem_object *omap_obj = to_omap_bo(obj);
|
2015-12-15 04:39:34 +08:00
|
|
|
struct omap_drm_private *priv = obj->dev->dev_private;
|
|
|
|
struct omap_drm_usergart_entry *entry;
|
2011-12-06 09:19:22 +08:00
|
|
|
enum tiler_fmt fmt = gem2fmt(omap_obj->flags);
|
|
|
|
struct page *pages[64]; /* XXX is this too much to have on stack? */
|
|
|
|
unsigned long pfn;
|
|
|
|
pgoff_t pgoff, base_pgoff;
|
2016-12-15 07:07:01 +08:00
|
|
|
unsigned long vaddr;
|
2018-05-23 02:13:57 +08:00
|
|
|
int i, err, slots;
|
|
|
|
vm_fault_t ret = VM_FAULT_NOPAGE;
|
2011-12-06 09:19:22 +08:00
|
|
|
|
2012-03-06 00:48:40 +08:00
|
|
|
/*
|
|
|
|
* Note the height of the slot is also equal to the number of pages
|
|
|
|
* that need to be mapped in to fill 4kb wide CPU page. If the slot
|
|
|
|
* height is 64, then 64 pages fill a 4kb wide by 64 row region.
|
|
|
|
*/
|
2015-12-15 04:39:34 +08:00
|
|
|
const int n = priv->usergart[fmt].height;
|
|
|
|
const int n_shift = priv->usergart[fmt].height_shift;
|
2012-03-06 00:48:40 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* If buffer width in bytes > PAGE_SIZE then the virtual stride is
|
|
|
|
* rounded up to next multiple of PAGE_SIZE.. this need to be taken
|
|
|
|
* into account in some of the math, so figure out virtual stride
|
|
|
|
* in pages
|
2011-12-06 09:19:22 +08:00
|
|
|
*/
|
2017-05-18 16:51:51 +08:00
|
|
|
const int m = DIV_ROUND_UP(omap_obj->width << fmt, PAGE_SIZE);
|
2011-12-06 09:19:22 +08:00
|
|
|
|
|
|
|
/* We don't use vmf->pgoff since that has the fake offset: */
|
2016-12-15 07:07:01 +08:00
|
|
|
pgoff = (vmf->address - vma->vm_start) >> PAGE_SHIFT;
|
2011-12-06 09:19:22 +08:00
|
|
|
|
2012-03-06 00:48:40 +08:00
|
|
|
/*
|
|
|
|
* Actual address we start mapping at is rounded down to previous slot
|
2011-12-06 09:19:22 +08:00
|
|
|
* boundary in the y direction:
|
|
|
|
*/
|
2012-03-06 00:48:40 +08:00
|
|
|
base_pgoff = round_down(pgoff, m << n_shift);
|
2011-12-06 09:19:22 +08:00
|
|
|
|
2012-03-06 00:48:40 +08:00
|
|
|
/* figure out buffer width in slots */
|
2015-12-15 04:39:34 +08:00
|
|
|
slots = omap_obj->width >> priv->usergart[fmt].slot_shift;
|
2011-12-06 09:19:22 +08:00
|
|
|
|
2016-12-15 07:07:01 +08:00
|
|
|
vaddr = vmf->address - ((pgoff - base_pgoff) << PAGE_SHIFT);
|
2012-03-06 00:48:40 +08:00
|
|
|
|
2015-12-15 04:39:34 +08:00
|
|
|
entry = &priv->usergart[fmt].entry[priv->usergart[fmt].last];
|
2012-03-06 00:48:40 +08:00
|
|
|
|
2011-12-06 09:19:22 +08:00
|
|
|
/* evict previous buffer using this usergart entry, if any: */
|
|
|
|
if (entry->obj)
|
2018-05-26 00:39:20 +08:00
|
|
|
omap_gem_evict_entry(entry->obj, fmt, entry);
|
2011-12-06 09:19:22 +08:00
|
|
|
|
|
|
|
entry->obj = obj;
|
|
|
|
entry->obj_pgoff = base_pgoff;
|
|
|
|
|
2012-03-06 00:48:40 +08:00
|
|
|
/* now convert base_pgoff to phys offset from virt offset: */
|
|
|
|
base_pgoff = (base_pgoff >> n_shift) * slots;
|
|
|
|
|
|
|
|
/* for wider-than 4k.. figure out which part of the slot-row we want: */
|
|
|
|
if (m > 1) {
|
|
|
|
int off = pgoff % m;
|
|
|
|
entry->obj_pgoff += off;
|
|
|
|
base_pgoff /= m;
|
|
|
|
slots = min(slots - (off << n_shift), n);
|
|
|
|
base_pgoff += off << n_shift;
|
|
|
|
vaddr += off << PAGE_SHIFT;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Map in pages. Beyond the valid pixel part of the buffer, we set
|
|
|
|
* pages[i] to NULL to get a dummy page mapped in.. if someone
|
|
|
|
* reads/writes it they will get random/undefined content, but at
|
|
|
|
* least it won't be corrupting whatever other random page used to
|
|
|
|
* be mapped in, or other undefined behavior.
|
2011-12-06 09:19:22 +08:00
|
|
|
*/
|
|
|
|
memcpy(pages, &omap_obj->pages[base_pgoff],
|
|
|
|
sizeof(struct page *) * slots);
|
|
|
|
memset(pages + slots, 0,
|
2012-03-06 00:48:40 +08:00
|
|
|
sizeof(struct page *) * (n - slots));
|
2011-12-06 09:19:22 +08:00
|
|
|
|
2018-05-23 02:13:57 +08:00
|
|
|
err = tiler_pin(entry->block, pages, ARRAY_SIZE(pages), 0, true);
|
|
|
|
if (err) {
|
|
|
|
ret = vmf_error(err);
|
|
|
|
dev_err(obj->dev->dev, "failed to pin: %d\n", err);
|
2011-12-06 09:19:22 +08:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2017-04-21 05:33:51 +08:00
|
|
|
pfn = entry->dma_addr >> PAGE_SHIFT;
|
2011-12-06 09:19:22 +08:00
|
|
|
|
2016-12-15 07:07:01 +08:00
|
|
|
VERB("Inserting %p pfn %lx, pa %lx", (void *)vmf->address,
|
2011-12-06 09:19:22 +08:00
|
|
|
pfn, pfn << PAGE_SHIFT);
|
|
|
|
|
2012-03-06 00:48:40 +08:00
|
|
|
for (i = n; i > 0; i--) {
|
2018-05-23 02:13:57 +08:00
|
|
|
ret = vmf_insert_mixed(vma,
|
|
|
|
vaddr, __pfn_to_pfn_t(pfn, PFN_DEV));
|
|
|
|
if (ret & VM_FAULT_ERROR)
|
|
|
|
break;
|
2015-12-15 04:39:34 +08:00
|
|
|
pfn += priv->usergart[fmt].stride_pfn;
|
2012-03-06 00:48:40 +08:00
|
|
|
vaddr += PAGE_SIZE * m;
|
2011-12-06 09:19:22 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* simple round-robin: */
|
2015-12-15 04:39:34 +08:00
|
|
|
priv->usergart[fmt].last = (priv->usergart[fmt].last + 1)
|
|
|
|
% NUM_USERGART_ENTRIES;
|
2011-12-06 09:19:22 +08:00
|
|
|
|
2018-05-23 02:13:57 +08:00
|
|
|
return ret;
|
2011-12-06 09:19:22 +08:00
|
|
|
}
|
|
|
|
|
staging: add omapdrm DRM/KMS driver for TI OMAP platforms
A DRM display driver for TI OMAP platform. Similar to omapfb (fbdev)
and omap_vout (v4l2 display) drivers in the past, this driver uses the
DSS2 driver to access the display hardware, including support for
HDMI, DVI, and various types of LCD panels. And it implements GEM
support for buffer allocation (for KMS as well as offscreen buffers
used by the xf86-video-omap userspace xorg driver).
The driver maps CRTCs to overlays, encoders to overlay-managers, and
connectors to dssdev's. Note that this arrangement might change slightly
when support for drm_plane overlays is added.
For GEM support, non-scanout buffers are using the shmem backed pages
provided by GEM core (In drm_gem_object_init()). In the case of scanout
buffers, which need to be physically contiguous, those are allocated
with CMA and use drm_gem_private_object_init().
See userspace xorg driver:
git://github.com/robclark/xf86-video-omap.git
Refer to this link for CMA (Continuous Memory Allocator):
http://lkml.org/lkml/2011/8/19/302
Links to previous versions of the patch:
v1: http://lwn.net/Articles/458137/
v2: http://patches.linaro.org/4156/
v3: http://patches.linaro.org/4688/
v4: http://patches.linaro.org/4791/
History:
v5: move headers from include/drm at Greg KH's request, minor rebasing
on 3.2-rc1, pull in private copies of drm_gem_{get,put}_pages()
because "drm/gem: add functions to get/put pages" patch is not
merged yet
v4: bit of rework of encoder/connector _dpms() code, modeset_init()
rework to not use nested functions, update TODO.txt
v3: minor cleanups, improved error handling for dev_load(), some minor
API changes that will be needed later for tiled buffer support
v2: replace omap_vram with CMA for scanout buffer allocation, remove
unneeded functions, use dma_addr_t for physical addresses, error
handling cleanup, refactor attach/detach pages into common drm
functions, split non-userspace-facing API into omap_priv.h, remove
plugin API
v1: original
Signed-off-by: Rob Clark <rob@ti.com>
Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-11-13 02:09:40 +08:00
|
|
|
/**
|
|
|
|
* omap_gem_fault - pagefault handler for GEM objects
|
|
|
|
* @vmf: fault detail
|
|
|
|
*
|
|
|
|
* Invoked when a fault occurs on an mmap of a GEM managed area. GEM
|
|
|
|
* does most of the work for us including the actual map/unmap calls
|
|
|
|
* but we need to do the actual page work.
|
|
|
|
*
|
|
|
|
* The VMA was set up by GEM. In doing so it also ensured that the
|
|
|
|
* vma->vm_private_data points to the GEM object that is backing this
|
|
|
|
* mapping.
|
|
|
|
*/
|
2018-05-23 02:13:57 +08:00
|
|
|
vm_fault_t omap_gem_fault(struct vm_fault *vmf)
|
staging: add omapdrm DRM/KMS driver for TI OMAP platforms
A DRM display driver for TI OMAP platform. Similar to omapfb (fbdev)
and omap_vout (v4l2 display) drivers in the past, this driver uses the
DSS2 driver to access the display hardware, including support for
HDMI, DVI, and various types of LCD panels. And it implements GEM
support for buffer allocation (for KMS as well as offscreen buffers
used by the xf86-video-omap userspace xorg driver).
The driver maps CRTCs to overlays, encoders to overlay-managers, and
connectors to dssdev's. Note that this arrangement might change slightly
when support for drm_plane overlays is added.
For GEM support, non-scanout buffers are using the shmem backed pages
provided by GEM core (In drm_gem_object_init()). In the case of scanout
buffers, which need to be physically contiguous, those are allocated
with CMA and use drm_gem_private_object_init().
See userspace xorg driver:
git://github.com/robclark/xf86-video-omap.git
Refer to this link for CMA (Continuous Memory Allocator):
http://lkml.org/lkml/2011/8/19/302
Links to previous versions of the patch:
v1: http://lwn.net/Articles/458137/
v2: http://patches.linaro.org/4156/
v3: http://patches.linaro.org/4688/
v4: http://patches.linaro.org/4791/
History:
v5: move headers from include/drm at Greg KH's request, minor rebasing
on 3.2-rc1, pull in private copies of drm_gem_{get,put}_pages()
because "drm/gem: add functions to get/put pages" patch is not
merged yet
v4: bit of rework of encoder/connector _dpms() code, modeset_init()
rework to not use nested functions, update TODO.txt
v3: minor cleanups, improved error handling for dev_load(), some minor
API changes that will be needed later for tiled buffer support
v2: replace omap_vram with CMA for scanout buffer allocation, remove
unneeded functions, use dma_addr_t for physical addresses, error
handling cleanup, refactor attach/detach pages into common drm
functions, split non-userspace-facing API into omap_priv.h, remove
plugin API
v1: original
Signed-off-by: Rob Clark <rob@ti.com>
Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-11-13 02:09:40 +08:00
|
|
|
{
|
2017-02-25 06:56:41 +08:00
|
|
|
struct vm_area_struct *vma = vmf->vma;
|
staging: add omapdrm DRM/KMS driver for TI OMAP platforms
A DRM display driver for TI OMAP platform. Similar to omapfb (fbdev)
and omap_vout (v4l2 display) drivers in the past, this driver uses the
DSS2 driver to access the display hardware, including support for
HDMI, DVI, and various types of LCD panels. And it implements GEM
support for buffer allocation (for KMS as well as offscreen buffers
used by the xf86-video-omap userspace xorg driver).
The driver maps CRTCs to overlays, encoders to overlay-managers, and
connectors to dssdev's. Note that this arrangement might change slightly
when support for drm_plane overlays is added.
For GEM support, non-scanout buffers are using the shmem backed pages
provided by GEM core (In drm_gem_object_init()). In the case of scanout
buffers, which need to be physically contiguous, those are allocated
with CMA and use drm_gem_private_object_init().
See userspace xorg driver:
git://github.com/robclark/xf86-video-omap.git
Refer to this link for CMA (Continuous Memory Allocator):
http://lkml.org/lkml/2011/8/19/302
Links to previous versions of the patch:
v1: http://lwn.net/Articles/458137/
v2: http://patches.linaro.org/4156/
v3: http://patches.linaro.org/4688/
v4: http://patches.linaro.org/4791/
History:
v5: move headers from include/drm at Greg KH's request, minor rebasing
on 3.2-rc1, pull in private copies of drm_gem_{get,put}_pages()
because "drm/gem: add functions to get/put pages" patch is not
merged yet
v4: bit of rework of encoder/connector _dpms() code, modeset_init()
rework to not use nested functions, update TODO.txt
v3: minor cleanups, improved error handling for dev_load(), some minor
API changes that will be needed later for tiled buffer support
v2: replace omap_vram with CMA for scanout buffer allocation, remove
unneeded functions, use dma_addr_t for physical addresses, error
handling cleanup, refactor attach/detach pages into common drm
functions, split non-userspace-facing API into omap_priv.h, remove
plugin API
v1: original
Signed-off-by: Rob Clark <rob@ti.com>
Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-11-13 02:09:40 +08:00
|
|
|
struct drm_gem_object *obj = vma->vm_private_data;
|
|
|
|
struct omap_gem_object *omap_obj = to_omap_bo(obj);
|
2018-05-23 02:13:57 +08:00
|
|
|
int err;
|
|
|
|
vm_fault_t ret;
|
staging: add omapdrm DRM/KMS driver for TI OMAP platforms
A DRM display driver for TI OMAP platform. Similar to omapfb (fbdev)
and omap_vout (v4l2 display) drivers in the past, this driver uses the
DSS2 driver to access the display hardware, including support for
HDMI, DVI, and various types of LCD panels. And it implements GEM
support for buffer allocation (for KMS as well as offscreen buffers
used by the xf86-video-omap userspace xorg driver).
The driver maps CRTCs to overlays, encoders to overlay-managers, and
connectors to dssdev's. Note that this arrangement might change slightly
when support for drm_plane overlays is added.
For GEM support, non-scanout buffers are using the shmem backed pages
provided by GEM core (In drm_gem_object_init()). In the case of scanout
buffers, which need to be physically contiguous, those are allocated
with CMA and use drm_gem_private_object_init().
See userspace xorg driver:
git://github.com/robclark/xf86-video-omap.git
Refer to this link for CMA (Continuous Memory Allocator):
http://lkml.org/lkml/2011/8/19/302
Links to previous versions of the patch:
v1: http://lwn.net/Articles/458137/
v2: http://patches.linaro.org/4156/
v3: http://patches.linaro.org/4688/
v4: http://patches.linaro.org/4791/
History:
v5: move headers from include/drm at Greg KH's request, minor rebasing
on 3.2-rc1, pull in private copies of drm_gem_{get,put}_pages()
because "drm/gem: add functions to get/put pages" patch is not
merged yet
v4: bit of rework of encoder/connector _dpms() code, modeset_init()
rework to not use nested functions, update TODO.txt
v3: minor cleanups, improved error handling for dev_load(), some minor
API changes that will be needed later for tiled buffer support
v2: replace omap_vram with CMA for scanout buffer allocation, remove
unneeded functions, use dma_addr_t for physical addresses, error
handling cleanup, refactor attach/detach pages into common drm
functions, split non-userspace-facing API into omap_priv.h, remove
plugin API
v1: original
Signed-off-by: Rob Clark <rob@ti.com>
Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-11-13 02:09:40 +08:00
|
|
|
|
|
|
|
/* Make sure we don't parallel update on a fault, nor move or remove
|
|
|
|
* something from beneath our feet
|
|
|
|
*/
|
2018-05-27 00:54:33 +08:00
|
|
|
mutex_lock(&omap_obj->lock);
|
staging: add omapdrm DRM/KMS driver for TI OMAP platforms
A DRM display driver for TI OMAP platform. Similar to omapfb (fbdev)
and omap_vout (v4l2 display) drivers in the past, this driver uses the
DSS2 driver to access the display hardware, including support for
HDMI, DVI, and various types of LCD panels. And it implements GEM
support for buffer allocation (for KMS as well as offscreen buffers
used by the xf86-video-omap userspace xorg driver).
The driver maps CRTCs to overlays, encoders to overlay-managers, and
connectors to dssdev's. Note that this arrangement might change slightly
when support for drm_plane overlays is added.
For GEM support, non-scanout buffers are using the shmem backed pages
provided by GEM core (In drm_gem_object_init()). In the case of scanout
buffers, which need to be physically contiguous, those are allocated
with CMA and use drm_gem_private_object_init().
See userspace xorg driver:
git://github.com/robclark/xf86-video-omap.git
Refer to this link for CMA (Continuous Memory Allocator):
http://lkml.org/lkml/2011/8/19/302
Links to previous versions of the patch:
v1: http://lwn.net/Articles/458137/
v2: http://patches.linaro.org/4156/
v3: http://patches.linaro.org/4688/
v4: http://patches.linaro.org/4791/
History:
v5: move headers from include/drm at Greg KH's request, minor rebasing
on 3.2-rc1, pull in private copies of drm_gem_{get,put}_pages()
because "drm/gem: add functions to get/put pages" patch is not
merged yet
v4: bit of rework of encoder/connector _dpms() code, modeset_init()
rework to not use nested functions, update TODO.txt
v3: minor cleanups, improved error handling for dev_load(), some minor
API changes that will be needed later for tiled buffer support
v2: replace omap_vram with CMA for scanout buffer allocation, remove
unneeded functions, use dma_addr_t for physical addresses, error
handling cleanup, refactor attach/detach pages into common drm
functions, split non-userspace-facing API into omap_priv.h, remove
plugin API
v1: original
Signed-off-by: Rob Clark <rob@ti.com>
Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-11-13 02:09:40 +08:00
|
|
|
|
|
|
|
/* if a shmem backed object, make sure we have pages attached now */
|
2018-05-26 00:39:21 +08:00
|
|
|
err = omap_gem_attach_pages(obj);
|
2018-05-23 02:13:57 +08:00
|
|
|
if (err) {
|
|
|
|
ret = vmf_error(err);
|
staging: add omapdrm DRM/KMS driver for TI OMAP platforms
A DRM display driver for TI OMAP platform. Similar to omapfb (fbdev)
and omap_vout (v4l2 display) drivers in the past, this driver uses the
DSS2 driver to access the display hardware, including support for
HDMI, DVI, and various types of LCD panels. And it implements GEM
support for buffer allocation (for KMS as well as offscreen buffers
used by the xf86-video-omap userspace xorg driver).
The driver maps CRTCs to overlays, encoders to overlay-managers, and
connectors to dssdev's. Note that this arrangement might change slightly
when support for drm_plane overlays is added.
For GEM support, non-scanout buffers are using the shmem backed pages
provided by GEM core (In drm_gem_object_init()). In the case of scanout
buffers, which need to be physically contiguous, those are allocated
with CMA and use drm_gem_private_object_init().
See userspace xorg driver:
git://github.com/robclark/xf86-video-omap.git
Refer to this link for CMA (Continuous Memory Allocator):
http://lkml.org/lkml/2011/8/19/302
Links to previous versions of the patch:
v1: http://lwn.net/Articles/458137/
v2: http://patches.linaro.org/4156/
v3: http://patches.linaro.org/4688/
v4: http://patches.linaro.org/4791/
History:
v5: move headers from include/drm at Greg KH's request, minor rebasing
on 3.2-rc1, pull in private copies of drm_gem_{get,put}_pages()
because "drm/gem: add functions to get/put pages" patch is not
merged yet
v4: bit of rework of encoder/connector _dpms() code, modeset_init()
rework to not use nested functions, update TODO.txt
v3: minor cleanups, improved error handling for dev_load(), some minor
API changes that will be needed later for tiled buffer support
v2: replace omap_vram with CMA for scanout buffer allocation, remove
unneeded functions, use dma_addr_t for physical addresses, error
handling cleanup, refactor attach/detach pages into common drm
functions, split non-userspace-facing API into omap_priv.h, remove
plugin API
v1: original
Signed-off-by: Rob Clark <rob@ti.com>
Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-11-13 02:09:40 +08:00
|
|
|
goto fail;
|
2018-05-23 02:13:57 +08:00
|
|
|
}
|
staging: add omapdrm DRM/KMS driver for TI OMAP platforms
A DRM display driver for TI OMAP platform. Similar to omapfb (fbdev)
and omap_vout (v4l2 display) drivers in the past, this driver uses the
DSS2 driver to access the display hardware, including support for
HDMI, DVI, and various types of LCD panels. And it implements GEM
support for buffer allocation (for KMS as well as offscreen buffers
used by the xf86-video-omap userspace xorg driver).
The driver maps CRTCs to overlays, encoders to overlay-managers, and
connectors to dssdev's. Note that this arrangement might change slightly
when support for drm_plane overlays is added.
For GEM support, non-scanout buffers are using the shmem backed pages
provided by GEM core (In drm_gem_object_init()). In the case of scanout
buffers, which need to be physically contiguous, those are allocated
with CMA and use drm_gem_private_object_init().
See userspace xorg driver:
git://github.com/robclark/xf86-video-omap.git
Refer to this link for CMA (Continuous Memory Allocator):
http://lkml.org/lkml/2011/8/19/302
Links to previous versions of the patch:
v1: http://lwn.net/Articles/458137/
v2: http://patches.linaro.org/4156/
v3: http://patches.linaro.org/4688/
v4: http://patches.linaro.org/4791/
History:
v5: move headers from include/drm at Greg KH's request, minor rebasing
on 3.2-rc1, pull in private copies of drm_gem_{get,put}_pages()
because "drm/gem: add functions to get/put pages" patch is not
merged yet
v4: bit of rework of encoder/connector _dpms() code, modeset_init()
rework to not use nested functions, update TODO.txt
v3: minor cleanups, improved error handling for dev_load(), some minor
API changes that will be needed later for tiled buffer support
v2: replace omap_vram with CMA for scanout buffer allocation, remove
unneeded functions, use dma_addr_t for physical addresses, error
handling cleanup, refactor attach/detach pages into common drm
functions, split non-userspace-facing API into omap_priv.h, remove
plugin API
v1: original
Signed-off-by: Rob Clark <rob@ti.com>
Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-11-13 02:09:40 +08:00
|
|
|
|
|
|
|
/* where should we do corresponding put_pages().. we are mapping
|
|
|
|
* the original page, rather than thru a GART, so we can't rely
|
|
|
|
* on eviction to trigger this. But munmap() or all mappings should
|
|
|
|
* probably trigger put_pages()?
|
|
|
|
*/
|
|
|
|
|
2011-12-06 09:19:22 +08:00
|
|
|
if (omap_obj->flags & OMAP_BO_TILED)
|
2018-05-26 00:39:20 +08:00
|
|
|
ret = omap_gem_fault_2d(obj, vma, vmf);
|
2011-12-06 09:19:22 +08:00
|
|
|
else
|
2018-05-26 00:39:20 +08:00
|
|
|
ret = omap_gem_fault_1d(obj, vma, vmf);
|
staging: add omapdrm DRM/KMS driver for TI OMAP platforms
A DRM display driver for TI OMAP platform. Similar to omapfb (fbdev)
and omap_vout (v4l2 display) drivers in the past, this driver uses the
DSS2 driver to access the display hardware, including support for
HDMI, DVI, and various types of LCD panels. And it implements GEM
support for buffer allocation (for KMS as well as offscreen buffers
used by the xf86-video-omap userspace xorg driver).
The driver maps CRTCs to overlays, encoders to overlay-managers, and
connectors to dssdev's. Note that this arrangement might change slightly
when support for drm_plane overlays is added.
For GEM support, non-scanout buffers are using the shmem backed pages
provided by GEM core (In drm_gem_object_init()). In the case of scanout
buffers, which need to be physically contiguous, those are allocated
with CMA and use drm_gem_private_object_init().
See userspace xorg driver:
git://github.com/robclark/xf86-video-omap.git
Refer to this link for CMA (Continuous Memory Allocator):
http://lkml.org/lkml/2011/8/19/302
Links to previous versions of the patch:
v1: http://lwn.net/Articles/458137/
v2: http://patches.linaro.org/4156/
v3: http://patches.linaro.org/4688/
v4: http://patches.linaro.org/4791/
History:
v5: move headers from include/drm at Greg KH's request, minor rebasing
on 3.2-rc1, pull in private copies of drm_gem_{get,put}_pages()
because "drm/gem: add functions to get/put pages" patch is not
merged yet
v4: bit of rework of encoder/connector _dpms() code, modeset_init()
rework to not use nested functions, update TODO.txt
v3: minor cleanups, improved error handling for dev_load(), some minor
API changes that will be needed later for tiled buffer support
v2: replace omap_vram with CMA for scanout buffer allocation, remove
unneeded functions, use dma_addr_t for physical addresses, error
handling cleanup, refactor attach/detach pages into common drm
functions, split non-userspace-facing API into omap_priv.h, remove
plugin API
v1: original
Signed-off-by: Rob Clark <rob@ti.com>
Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-11-13 02:09:40 +08:00
|
|
|
|
|
|
|
|
|
|
|
fail:
|
2018-05-27 00:54:33 +08:00
|
|
|
mutex_unlock(&omap_obj->lock);
|
2018-05-23 02:13:57 +08:00
|
|
|
return ret;
|
staging: add omapdrm DRM/KMS driver for TI OMAP platforms
A DRM display driver for TI OMAP platform. Similar to omapfb (fbdev)
and omap_vout (v4l2 display) drivers in the past, this driver uses the
DSS2 driver to access the display hardware, including support for
HDMI, DVI, and various types of LCD panels. And it implements GEM
support for buffer allocation (for KMS as well as offscreen buffers
used by the xf86-video-omap userspace xorg driver).
The driver maps CRTCs to overlays, encoders to overlay-managers, and
connectors to dssdev's. Note that this arrangement might change slightly
when support for drm_plane overlays is added.
For GEM support, non-scanout buffers are using the shmem backed pages
provided by GEM core (In drm_gem_object_init()). In the case of scanout
buffers, which need to be physically contiguous, those are allocated
with CMA and use drm_gem_private_object_init().
See userspace xorg driver:
git://github.com/robclark/xf86-video-omap.git
Refer to this link for CMA (Continuous Memory Allocator):
http://lkml.org/lkml/2011/8/19/302
Links to previous versions of the patch:
v1: http://lwn.net/Articles/458137/
v2: http://patches.linaro.org/4156/
v3: http://patches.linaro.org/4688/
v4: http://patches.linaro.org/4791/
History:
v5: move headers from include/drm at Greg KH's request, minor rebasing
on 3.2-rc1, pull in private copies of drm_gem_{get,put}_pages()
because "drm/gem: add functions to get/put pages" patch is not
merged yet
v4: bit of rework of encoder/connector _dpms() code, modeset_init()
rework to not use nested functions, update TODO.txt
v3: minor cleanups, improved error handling for dev_load(), some minor
API changes that will be needed later for tiled buffer support
v2: replace omap_vram with CMA for scanout buffer allocation, remove
unneeded functions, use dma_addr_t for physical addresses, error
handling cleanup, refactor attach/detach pages into common drm
functions, split non-userspace-facing API into omap_priv.h, remove
plugin API
v1: original
Signed-off-by: Rob Clark <rob@ti.com>
Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-11-13 02:09:40 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/** We override mainly to fix up some of the vm mapping flags.. */
|
|
|
|
int omap_gem_mmap(struct file *filp, struct vm_area_struct *vma)
|
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
ret = drm_gem_mmap(filp, vma);
|
|
|
|
if (ret) {
|
|
|
|
DBG("mmap failed: %d", ret);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2012-05-17 16:37:25 +08:00
|
|
|
return omap_gem_mmap_obj(vma->vm_private_data, vma);
|
|
|
|
}
|
|
|
|
|
|
|
|
int omap_gem_mmap_obj(struct drm_gem_object *obj,
|
|
|
|
struct vm_area_struct *vma)
|
|
|
|
{
|
|
|
|
struct omap_gem_object *omap_obj = to_omap_bo(obj);
|
staging: add omapdrm DRM/KMS driver for TI OMAP platforms
A DRM display driver for TI OMAP platform. Similar to omapfb (fbdev)
and omap_vout (v4l2 display) drivers in the past, this driver uses the
DSS2 driver to access the display hardware, including support for
HDMI, DVI, and various types of LCD panels. And it implements GEM
support for buffer allocation (for KMS as well as offscreen buffers
used by the xf86-video-omap userspace xorg driver).
The driver maps CRTCs to overlays, encoders to overlay-managers, and
connectors to dssdev's. Note that this arrangement might change slightly
when support for drm_plane overlays is added.
For GEM support, non-scanout buffers are using the shmem backed pages
provided by GEM core (In drm_gem_object_init()). In the case of scanout
buffers, which need to be physically contiguous, those are allocated
with CMA and use drm_gem_private_object_init().
See userspace xorg driver:
git://github.com/robclark/xf86-video-omap.git
Refer to this link for CMA (Continuous Memory Allocator):
http://lkml.org/lkml/2011/8/19/302
Links to previous versions of the patch:
v1: http://lwn.net/Articles/458137/
v2: http://patches.linaro.org/4156/
v3: http://patches.linaro.org/4688/
v4: http://patches.linaro.org/4791/
History:
v5: move headers from include/drm at Greg KH's request, minor rebasing
on 3.2-rc1, pull in private copies of drm_gem_{get,put}_pages()
because "drm/gem: add functions to get/put pages" patch is not
merged yet
v4: bit of rework of encoder/connector _dpms() code, modeset_init()
rework to not use nested functions, update TODO.txt
v3: minor cleanups, improved error handling for dev_load(), some minor
API changes that will be needed later for tiled buffer support
v2: replace omap_vram with CMA for scanout buffer allocation, remove
unneeded functions, use dma_addr_t for physical addresses, error
handling cleanup, refactor attach/detach pages into common drm
functions, split non-userspace-facing API into omap_priv.h, remove
plugin API
v1: original
Signed-off-by: Rob Clark <rob@ti.com>
Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-11-13 02:09:40 +08:00
|
|
|
|
|
|
|
vma->vm_flags &= ~VM_PFNMAP;
|
|
|
|
vma->vm_flags |= VM_MIXEDMAP;
|
|
|
|
|
|
|
|
if (omap_obj->flags & OMAP_BO_WC) {
|
|
|
|
vma->vm_page_prot = pgprot_writecombine(vm_get_page_prot(vma->vm_flags));
|
|
|
|
} else if (omap_obj->flags & OMAP_BO_UNCACHED) {
|
|
|
|
vma->vm_page_prot = pgprot_noncached(vm_get_page_prot(vma->vm_flags));
|
|
|
|
} else {
|
2012-05-17 16:37:25 +08:00
|
|
|
/*
|
|
|
|
* We do have some private objects, at least for scanout buffers
|
|
|
|
* on hardware without DMM/TILER. But these are allocated write-
|
|
|
|
* combine
|
|
|
|
*/
|
|
|
|
if (WARN_ON(!obj->filp))
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Shunt off cached objs to shmem file so they have their own
|
|
|
|
* address_space (so unmap_mapping_range does what we want,
|
|
|
|
* in particular in the case of mmap'd dmabufs)
|
|
|
|
*/
|
|
|
|
fput(vma->vm_file);
|
|
|
|
vma->vm_pgoff = 0;
|
2012-08-28 02:48:26 +08:00
|
|
|
vma->vm_file = get_file(obj->filp);
|
2012-05-17 16:37:25 +08:00
|
|
|
|
staging: add omapdrm DRM/KMS driver for TI OMAP platforms
A DRM display driver for TI OMAP platform. Similar to omapfb (fbdev)
and omap_vout (v4l2 display) drivers in the past, this driver uses the
DSS2 driver to access the display hardware, including support for
HDMI, DVI, and various types of LCD panels. And it implements GEM
support for buffer allocation (for KMS as well as offscreen buffers
used by the xf86-video-omap userspace xorg driver).
The driver maps CRTCs to overlays, encoders to overlay-managers, and
connectors to dssdev's. Note that this arrangement might change slightly
when support for drm_plane overlays is added.
For GEM support, non-scanout buffers are using the shmem backed pages
provided by GEM core (In drm_gem_object_init()). In the case of scanout
buffers, which need to be physically contiguous, those are allocated
with CMA and use drm_gem_private_object_init().
See userspace xorg driver:
git://github.com/robclark/xf86-video-omap.git
Refer to this link for CMA (Continuous Memory Allocator):
http://lkml.org/lkml/2011/8/19/302
Links to previous versions of the patch:
v1: http://lwn.net/Articles/458137/
v2: http://patches.linaro.org/4156/
v3: http://patches.linaro.org/4688/
v4: http://patches.linaro.org/4791/
History:
v5: move headers from include/drm at Greg KH's request, minor rebasing
on 3.2-rc1, pull in private copies of drm_gem_{get,put}_pages()
because "drm/gem: add functions to get/put pages" patch is not
merged yet
v4: bit of rework of encoder/connector _dpms() code, modeset_init()
rework to not use nested functions, update TODO.txt
v3: minor cleanups, improved error handling for dev_load(), some minor
API changes that will be needed later for tiled buffer support
v2: replace omap_vram with CMA for scanout buffer allocation, remove
unneeded functions, use dma_addr_t for physical addresses, error
handling cleanup, refactor attach/detach pages into common drm
functions, split non-userspace-facing API into omap_priv.h, remove
plugin API
v1: original
Signed-off-by: Rob Clark <rob@ti.com>
Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-11-13 02:09:40 +08:00
|
|
|
vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
|
|
|
|
}
|
|
|
|
|
2012-05-17 16:37:25 +08:00
|
|
|
return 0;
|
staging: add omapdrm DRM/KMS driver for TI OMAP platforms
A DRM display driver for TI OMAP platform. Similar to omapfb (fbdev)
and omap_vout (v4l2 display) drivers in the past, this driver uses the
DSS2 driver to access the display hardware, including support for
HDMI, DVI, and various types of LCD panels. And it implements GEM
support for buffer allocation (for KMS as well as offscreen buffers
used by the xf86-video-omap userspace xorg driver).
The driver maps CRTCs to overlays, encoders to overlay-managers, and
connectors to dssdev's. Note that this arrangement might change slightly
when support for drm_plane overlays is added.
For GEM support, non-scanout buffers are using the shmem backed pages
provided by GEM core (In drm_gem_object_init()). In the case of scanout
buffers, which need to be physically contiguous, those are allocated
with CMA and use drm_gem_private_object_init().
See userspace xorg driver:
git://github.com/robclark/xf86-video-omap.git
Refer to this link for CMA (Continuous Memory Allocator):
http://lkml.org/lkml/2011/8/19/302
Links to previous versions of the patch:
v1: http://lwn.net/Articles/458137/
v2: http://patches.linaro.org/4156/
v3: http://patches.linaro.org/4688/
v4: http://patches.linaro.org/4791/
History:
v5: move headers from include/drm at Greg KH's request, minor rebasing
on 3.2-rc1, pull in private copies of drm_gem_{get,put}_pages()
because "drm/gem: add functions to get/put pages" patch is not
merged yet
v4: bit of rework of encoder/connector _dpms() code, modeset_init()
rework to not use nested functions, update TODO.txt
v3: minor cleanups, improved error handling for dev_load(), some minor
API changes that will be needed later for tiled buffer support
v2: replace omap_vram with CMA for scanout buffer allocation, remove
unneeded functions, use dma_addr_t for physical addresses, error
handling cleanup, refactor attach/detach pages into common drm
functions, split non-userspace-facing API into omap_priv.h, remove
plugin API
v1: original
Signed-off-by: Rob Clark <rob@ti.com>
Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-11-13 02:09:40 +08:00
|
|
|
}
|
|
|
|
|
2015-12-15 04:39:33 +08:00
|
|
|
/* -----------------------------------------------------------------------------
|
|
|
|
* Dumb Buffers
|
|
|
|
*/
|
2012-05-17 16:37:25 +08:00
|
|
|
|
staging: add omapdrm DRM/KMS driver for TI OMAP platforms
A DRM display driver for TI OMAP platform. Similar to omapfb (fbdev)
and omap_vout (v4l2 display) drivers in the past, this driver uses the
DSS2 driver to access the display hardware, including support for
HDMI, DVI, and various types of LCD panels. And it implements GEM
support for buffer allocation (for KMS as well as offscreen buffers
used by the xf86-video-omap userspace xorg driver).
The driver maps CRTCs to overlays, encoders to overlay-managers, and
connectors to dssdev's. Note that this arrangement might change slightly
when support for drm_plane overlays is added.
For GEM support, non-scanout buffers are using the shmem backed pages
provided by GEM core (In drm_gem_object_init()). In the case of scanout
buffers, which need to be physically contiguous, those are allocated
with CMA and use drm_gem_private_object_init().
See userspace xorg driver:
git://github.com/robclark/xf86-video-omap.git
Refer to this link for CMA (Continuous Memory Allocator):
http://lkml.org/lkml/2011/8/19/302
Links to previous versions of the patch:
v1: http://lwn.net/Articles/458137/
v2: http://patches.linaro.org/4156/
v3: http://patches.linaro.org/4688/
v4: http://patches.linaro.org/4791/
History:
v5: move headers from include/drm at Greg KH's request, minor rebasing
on 3.2-rc1, pull in private copies of drm_gem_{get,put}_pages()
because "drm/gem: add functions to get/put pages" patch is not
merged yet
v4: bit of rework of encoder/connector _dpms() code, modeset_init()
rework to not use nested functions, update TODO.txt
v3: minor cleanups, improved error handling for dev_load(), some minor
API changes that will be needed later for tiled buffer support
v2: replace omap_vram with CMA for scanout buffer allocation, remove
unneeded functions, use dma_addr_t for physical addresses, error
handling cleanup, refactor attach/detach pages into common drm
functions, split non-userspace-facing API into omap_priv.h, remove
plugin API
v1: original
Signed-off-by: Rob Clark <rob@ti.com>
Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-11-13 02:09:40 +08:00
|
|
|
/**
|
|
|
|
* omap_gem_dumb_create - create a dumb buffer
|
|
|
|
* @drm_file: our client file
|
|
|
|
* @dev: our device
|
|
|
|
* @args: the requested arguments copied from userspace
|
|
|
|
*
|
|
|
|
* Allocate a buffer suitable for use for a frame buffer of the
|
|
|
|
* form described by user space. Give userspace a handle by which
|
|
|
|
* to reference it.
|
|
|
|
*/
|
|
|
|
int omap_gem_dumb_create(struct drm_file *file, struct drm_device *dev,
|
|
|
|
struct drm_mode_create_dumb *args)
|
|
|
|
{
|
|
|
|
union omap_gem_size gsize;
|
|
|
|
|
2016-04-19 14:06:32 +08:00
|
|
|
args->pitch = DIV_ROUND_UP(args->width * args->bpp, 8);
|
2016-04-18 23:18:37 +08:00
|
|
|
|
staging: add omapdrm DRM/KMS driver for TI OMAP platforms
A DRM display driver for TI OMAP platform. Similar to omapfb (fbdev)
and omap_vout (v4l2 display) drivers in the past, this driver uses the
DSS2 driver to access the display hardware, including support for
HDMI, DVI, and various types of LCD panels. And it implements GEM
support for buffer allocation (for KMS as well as offscreen buffers
used by the xf86-video-omap userspace xorg driver).
The driver maps CRTCs to overlays, encoders to overlay-managers, and
connectors to dssdev's. Note that this arrangement might change slightly
when support for drm_plane overlays is added.
For GEM support, non-scanout buffers are using the shmem backed pages
provided by GEM core (In drm_gem_object_init()). In the case of scanout
buffers, which need to be physically contiguous, those are allocated
with CMA and use drm_gem_private_object_init().
See userspace xorg driver:
git://github.com/robclark/xf86-video-omap.git
Refer to this link for CMA (Continuous Memory Allocator):
http://lkml.org/lkml/2011/8/19/302
Links to previous versions of the patch:
v1: http://lwn.net/Articles/458137/
v2: http://patches.linaro.org/4156/
v3: http://patches.linaro.org/4688/
v4: http://patches.linaro.org/4791/
History:
v5: move headers from include/drm at Greg KH's request, minor rebasing
on 3.2-rc1, pull in private copies of drm_gem_{get,put}_pages()
because "drm/gem: add functions to get/put pages" patch is not
merged yet
v4: bit of rework of encoder/connector _dpms() code, modeset_init()
rework to not use nested functions, update TODO.txt
v3: minor cleanups, improved error handling for dev_load(), some minor
API changes that will be needed later for tiled buffer support
v2: replace omap_vram with CMA for scanout buffer allocation, remove
unneeded functions, use dma_addr_t for physical addresses, error
handling cleanup, refactor attach/detach pages into common drm
functions, split non-userspace-facing API into omap_priv.h, remove
plugin API
v1: original
Signed-off-by: Rob Clark <rob@ti.com>
Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-11-13 02:09:40 +08:00
|
|
|
args->size = PAGE_ALIGN(args->pitch * args->height);
|
|
|
|
|
|
|
|
gsize = (union omap_gem_size){
|
|
|
|
.bytes = args->size,
|
|
|
|
};
|
|
|
|
|
|
|
|
return omap_gem_new_handle(dev, file, gsize,
|
|
|
|
OMAP_BO_SCANOUT | OMAP_BO_WC, &args->handle);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* omap_gem_dumb_map - buffer mapping for dumb interface
|
|
|
|
* @file: our drm client file
|
|
|
|
* @dev: drm device
|
|
|
|
* @handle: GEM handle to the object (from dumb_create)
|
|
|
|
*
|
|
|
|
* Do the necessary setup to allow the mapping of the frame buffer
|
|
|
|
* into user memory. We don't have to do much here at the moment.
|
|
|
|
*/
|
|
|
|
int omap_gem_dumb_map_offset(struct drm_file *file, struct drm_device *dev,
|
2018-02-11 21:07:33 +08:00
|
|
|
u32 handle, u64 *offset)
|
staging: add omapdrm DRM/KMS driver for TI OMAP platforms
A DRM display driver for TI OMAP platform. Similar to omapfb (fbdev)
and omap_vout (v4l2 display) drivers in the past, this driver uses the
DSS2 driver to access the display hardware, including support for
HDMI, DVI, and various types of LCD panels. And it implements GEM
support for buffer allocation (for KMS as well as offscreen buffers
used by the xf86-video-omap userspace xorg driver).
The driver maps CRTCs to overlays, encoders to overlay-managers, and
connectors to dssdev's. Note that this arrangement might change slightly
when support for drm_plane overlays is added.
For GEM support, non-scanout buffers are using the shmem backed pages
provided by GEM core (In drm_gem_object_init()). In the case of scanout
buffers, which need to be physically contiguous, those are allocated
with CMA and use drm_gem_private_object_init().
See userspace xorg driver:
git://github.com/robclark/xf86-video-omap.git
Refer to this link for CMA (Continuous Memory Allocator):
http://lkml.org/lkml/2011/8/19/302
Links to previous versions of the patch:
v1: http://lwn.net/Articles/458137/
v2: http://patches.linaro.org/4156/
v3: http://patches.linaro.org/4688/
v4: http://patches.linaro.org/4791/
History:
v5: move headers from include/drm at Greg KH's request, minor rebasing
on 3.2-rc1, pull in private copies of drm_gem_{get,put}_pages()
because "drm/gem: add functions to get/put pages" patch is not
merged yet
v4: bit of rework of encoder/connector _dpms() code, modeset_init()
rework to not use nested functions, update TODO.txt
v3: minor cleanups, improved error handling for dev_load(), some minor
API changes that will be needed later for tiled buffer support
v2: replace omap_vram with CMA for scanout buffer allocation, remove
unneeded functions, use dma_addr_t for physical addresses, error
handling cleanup, refactor attach/detach pages into common drm
functions, split non-userspace-facing API into omap_priv.h, remove
plugin API
v1: original
Signed-off-by: Rob Clark <rob@ti.com>
Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-11-13 02:09:40 +08:00
|
|
|
{
|
|
|
|
struct drm_gem_object *obj;
|
|
|
|
int ret = 0;
|
|
|
|
|
|
|
|
/* GEM does all our handle to object mapping */
|
2016-05-09 18:04:54 +08:00
|
|
|
obj = drm_gem_object_lookup(file, handle);
|
staging: add omapdrm DRM/KMS driver for TI OMAP platforms
A DRM display driver for TI OMAP platform. Similar to omapfb (fbdev)
and omap_vout (v4l2 display) drivers in the past, this driver uses the
DSS2 driver to access the display hardware, including support for
HDMI, DVI, and various types of LCD panels. And it implements GEM
support for buffer allocation (for KMS as well as offscreen buffers
used by the xf86-video-omap userspace xorg driver).
The driver maps CRTCs to overlays, encoders to overlay-managers, and
connectors to dssdev's. Note that this arrangement might change slightly
when support for drm_plane overlays is added.
For GEM support, non-scanout buffers are using the shmem backed pages
provided by GEM core (In drm_gem_object_init()). In the case of scanout
buffers, which need to be physically contiguous, those are allocated
with CMA and use drm_gem_private_object_init().
See userspace xorg driver:
git://github.com/robclark/xf86-video-omap.git
Refer to this link for CMA (Continuous Memory Allocator):
http://lkml.org/lkml/2011/8/19/302
Links to previous versions of the patch:
v1: http://lwn.net/Articles/458137/
v2: http://patches.linaro.org/4156/
v3: http://patches.linaro.org/4688/
v4: http://patches.linaro.org/4791/
History:
v5: move headers from include/drm at Greg KH's request, minor rebasing
on 3.2-rc1, pull in private copies of drm_gem_{get,put}_pages()
because "drm/gem: add functions to get/put pages" patch is not
merged yet
v4: bit of rework of encoder/connector _dpms() code, modeset_init()
rework to not use nested functions, update TODO.txt
v3: minor cleanups, improved error handling for dev_load(), some minor
API changes that will be needed later for tiled buffer support
v2: replace omap_vram with CMA for scanout buffer allocation, remove
unneeded functions, use dma_addr_t for physical addresses, error
handling cleanup, refactor attach/detach pages into common drm
functions, split non-userspace-facing API into omap_priv.h, remove
plugin API
v1: original
Signed-off-by: Rob Clark <rob@ti.com>
Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-11-13 02:09:40 +08:00
|
|
|
if (obj == NULL) {
|
|
|
|
ret = -ENOENT;
|
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
|
|
|
|
*offset = omap_gem_mmap_offset(obj);
|
|
|
|
|
|
|
|
drm_gem_object_unreference_unlocked(obj);
|
|
|
|
|
|
|
|
fail:
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2015-12-15 04:39:30 +08:00
|
|
|
#ifdef CONFIG_DRM_FBDEV_EMULATION
|
2011-12-10 13:26:08 +08:00
|
|
|
/* Set scrolling position. This allows us to implement fast scrolling
|
|
|
|
* for console.
|
2012-03-06 00:48:33 +08:00
|
|
|
*
|
|
|
|
* Call only from non-atomic contexts.
|
2011-12-10 13:26:08 +08:00
|
|
|
*/
|
2018-02-11 21:07:33 +08:00
|
|
|
int omap_gem_roll(struct drm_gem_object *obj, u32 roll)
|
2011-12-10 13:26:08 +08:00
|
|
|
{
|
|
|
|
struct omap_gem_object *omap_obj = to_omap_bo(obj);
|
2018-02-11 21:07:33 +08:00
|
|
|
u32 npages = obj->size >> PAGE_SHIFT;
|
2011-12-10 13:26:08 +08:00
|
|
|
int ret = 0;
|
|
|
|
|
|
|
|
if (roll > npages) {
|
|
|
|
dev_err(obj->dev->dev, "invalid roll: %d\n", roll);
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
omap_obj->roll = roll;
|
|
|
|
|
2018-05-27 00:54:33 +08:00
|
|
|
mutex_lock(&omap_obj->lock);
|
2011-12-17 01:34:34 +08:00
|
|
|
|
2011-12-10 13:26:08 +08:00
|
|
|
/* if we aren't mapped yet, we don't need to do anything */
|
|
|
|
if (omap_obj->block) {
|
2018-05-26 00:39:21 +08:00
|
|
|
ret = omap_gem_attach_pages(obj);
|
2011-12-10 13:26:08 +08:00
|
|
|
if (ret)
|
|
|
|
goto fail;
|
2018-05-26 00:39:21 +08:00
|
|
|
|
|
|
|
ret = tiler_pin(omap_obj->block, omap_obj->pages, npages,
|
|
|
|
roll, true);
|
2011-12-10 13:26:08 +08:00
|
|
|
if (ret)
|
|
|
|
dev_err(obj->dev->dev, "could not repin: %d\n", ret);
|
|
|
|
}
|
|
|
|
|
|
|
|
fail:
|
2018-05-27 00:54:33 +08:00
|
|
|
mutex_unlock(&omap_obj->lock);
|
2011-12-10 13:26:08 +08:00
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
2015-12-15 04:39:30 +08:00
|
|
|
#endif
|
2011-12-10 13:26:08 +08:00
|
|
|
|
2015-12-15 04:39:33 +08:00
|
|
|
/* -----------------------------------------------------------------------------
|
|
|
|
* Memory Management & DMA Sync
|
|
|
|
*/
|
|
|
|
|
2017-04-21 05:33:56 +08:00
|
|
|
/*
|
|
|
|
* shmem buffers that are mapped cached are not coherent.
|
|
|
|
*
|
|
|
|
* We keep track of dirty pages using page faulting to perform cache management.
|
|
|
|
* When a page is mapped to the CPU in read/write mode the device can't access
|
|
|
|
* it and omap_obj->dma_addrs[i] is NULL. When a page is mapped to the device
|
|
|
|
* the omap_obj->dma_addrs[i] is set to the DMA address, and the page is
|
|
|
|
* unmapped from the CPU.
|
2015-12-15 04:39:33 +08:00
|
|
|
*/
|
2018-05-26 00:39:20 +08:00
|
|
|
static inline bool omap_gem_is_cached_coherent(struct drm_gem_object *obj)
|
2015-12-15 04:39:33 +08:00
|
|
|
{
|
|
|
|
struct omap_gem_object *omap_obj = to_omap_bo(obj);
|
2015-12-15 04:39:37 +08:00
|
|
|
|
2017-04-21 05:33:56 +08:00
|
|
|
return !((omap_obj->flags & OMAP_BO_MEM_SHMEM) &&
|
|
|
|
((omap_obj->flags & OMAP_BO_CACHE_MASK) == OMAP_BO_CACHED));
|
2015-12-15 04:39:33 +08:00
|
|
|
}
|
2011-12-10 13:26:08 +08:00
|
|
|
|
2012-05-17 16:37:25 +08:00
|
|
|
/* Sync the buffer for CPU access.. note pages should already be
|
|
|
|
* attached, ie. omap_gem_get_pages()
|
|
|
|
*/
|
2017-04-21 05:33:55 +08:00
|
|
|
void omap_gem_cpu_sync_page(struct drm_gem_object *obj, int pgoff)
|
2012-05-17 16:37:25 +08:00
|
|
|
{
|
|
|
|
struct drm_device *dev = obj->dev;
|
|
|
|
struct omap_gem_object *omap_obj = to_omap_bo(obj);
|
|
|
|
|
2018-05-26 00:39:20 +08:00
|
|
|
if (omap_gem_is_cached_coherent(obj))
|
2017-04-21 05:33:56 +08:00
|
|
|
return;
|
|
|
|
|
|
|
|
if (omap_obj->dma_addrs[pgoff]) {
|
2017-04-21 05:33:54 +08:00
|
|
|
dma_unmap_page(dev->dev, omap_obj->dma_addrs[pgoff],
|
2017-04-21 05:33:58 +08:00
|
|
|
PAGE_SIZE, DMA_TO_DEVICE);
|
2017-04-21 05:33:54 +08:00
|
|
|
omap_obj->dma_addrs[pgoff] = 0;
|
2012-05-17 16:37:25 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* sync the buffer for DMA access */
|
2017-04-21 05:33:55 +08:00
|
|
|
void omap_gem_dma_sync_buffer(struct drm_gem_object *obj,
|
2012-05-17 16:37:25 +08:00
|
|
|
enum dma_data_direction dir)
|
|
|
|
{
|
|
|
|
struct drm_device *dev = obj->dev;
|
|
|
|
struct omap_gem_object *omap_obj = to_omap_bo(obj);
|
2017-04-21 05:33:53 +08:00
|
|
|
int i, npages = obj->size >> PAGE_SHIFT;
|
|
|
|
struct page **pages = omap_obj->pages;
|
|
|
|
bool dirty = false;
|
2012-05-17 16:37:25 +08:00
|
|
|
|
2018-05-26 00:39:20 +08:00
|
|
|
if (omap_gem_is_cached_coherent(obj))
|
2017-04-21 05:33:53 +08:00
|
|
|
return;
|
2016-01-05 17:43:15 +08:00
|
|
|
|
2017-04-21 05:33:53 +08:00
|
|
|
for (i = 0; i < npages; i++) {
|
2017-04-21 05:33:54 +08:00
|
|
|
if (!omap_obj->dma_addrs[i]) {
|
2017-04-21 05:33:53 +08:00
|
|
|
dma_addr_t addr;
|
2016-01-05 17:43:15 +08:00
|
|
|
|
2017-04-21 05:33:53 +08:00
|
|
|
addr = dma_map_page(dev->dev, pages[i], 0,
|
2017-04-21 05:33:58 +08:00
|
|
|
PAGE_SIZE, dir);
|
2017-04-21 05:33:53 +08:00
|
|
|
if (dma_mapping_error(dev->dev, addr)) {
|
|
|
|
dev_warn(dev->dev, "%s: failed to map page\n",
|
|
|
|
__func__);
|
|
|
|
break;
|
2012-05-17 16:37:25 +08:00
|
|
|
}
|
|
|
|
|
2017-04-21 05:33:53 +08:00
|
|
|
dirty = true;
|
2017-04-21 05:33:54 +08:00
|
|
|
omap_obj->dma_addrs[i] = addr;
|
2012-05-17 16:37:25 +08:00
|
|
|
}
|
|
|
|
}
|
2017-04-21 05:33:53 +08:00
|
|
|
|
|
|
|
if (dirty) {
|
|
|
|
unmap_mapping_range(obj->filp->f_mapping, 0,
|
|
|
|
omap_gem_mmap_size(obj), 1);
|
|
|
|
}
|
2012-05-17 16:37:25 +08:00
|
|
|
}
|
|
|
|
|
2017-04-21 05:33:52 +08:00
|
|
|
/**
|
|
|
|
* omap_gem_pin() - Pin a GEM object in memory
|
|
|
|
* @obj: the GEM object
|
|
|
|
* @dma_addr: the DMA address
|
|
|
|
*
|
|
|
|
* Pin the given GEM object in memory and fill the dma_addr pointer with the
|
|
|
|
* object's DMA address. If the buffer is not physically contiguous it will be
|
|
|
|
* remapped through the TILER to provide a contiguous view.
|
|
|
|
*
|
|
|
|
* Pins are reference-counted, calling this function multiple times is allowed
|
|
|
|
* as long the corresponding omap_gem_unpin() calls are balanced.
|
|
|
|
*
|
|
|
|
* Return 0 on success or a negative error code otherwise.
|
staging: add omapdrm DRM/KMS driver for TI OMAP platforms
A DRM display driver for TI OMAP platform. Similar to omapfb (fbdev)
and omap_vout (v4l2 display) drivers in the past, this driver uses the
DSS2 driver to access the display hardware, including support for
HDMI, DVI, and various types of LCD panels. And it implements GEM
support for buffer allocation (for KMS as well as offscreen buffers
used by the xf86-video-omap userspace xorg driver).
The driver maps CRTCs to overlays, encoders to overlay-managers, and
connectors to dssdev's. Note that this arrangement might change slightly
when support for drm_plane overlays is added.
For GEM support, non-scanout buffers are using the shmem backed pages
provided by GEM core (In drm_gem_object_init()). In the case of scanout
buffers, which need to be physically contiguous, those are allocated
with CMA and use drm_gem_private_object_init().
See userspace xorg driver:
git://github.com/robclark/xf86-video-omap.git
Refer to this link for CMA (Continuous Memory Allocator):
http://lkml.org/lkml/2011/8/19/302
Links to previous versions of the patch:
v1: http://lwn.net/Articles/458137/
v2: http://patches.linaro.org/4156/
v3: http://patches.linaro.org/4688/
v4: http://patches.linaro.org/4791/
History:
v5: move headers from include/drm at Greg KH's request, minor rebasing
on 3.2-rc1, pull in private copies of drm_gem_{get,put}_pages()
because "drm/gem: add functions to get/put pages" patch is not
merged yet
v4: bit of rework of encoder/connector _dpms() code, modeset_init()
rework to not use nested functions, update TODO.txt
v3: minor cleanups, improved error handling for dev_load(), some minor
API changes that will be needed later for tiled buffer support
v2: replace omap_vram with CMA for scanout buffer allocation, remove
unneeded functions, use dma_addr_t for physical addresses, error
handling cleanup, refactor attach/detach pages into common drm
functions, split non-userspace-facing API into omap_priv.h, remove
plugin API
v1: original
Signed-off-by: Rob Clark <rob@ti.com>
Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-11-13 02:09:40 +08:00
|
|
|
*/
|
2017-04-21 05:33:52 +08:00
|
|
|
int omap_gem_pin(struct drm_gem_object *obj, dma_addr_t *dma_addr)
|
staging: add omapdrm DRM/KMS driver for TI OMAP platforms
A DRM display driver for TI OMAP platform. Similar to omapfb (fbdev)
and omap_vout (v4l2 display) drivers in the past, this driver uses the
DSS2 driver to access the display hardware, including support for
HDMI, DVI, and various types of LCD panels. And it implements GEM
support for buffer allocation (for KMS as well as offscreen buffers
used by the xf86-video-omap userspace xorg driver).
The driver maps CRTCs to overlays, encoders to overlay-managers, and
connectors to dssdev's. Note that this arrangement might change slightly
when support for drm_plane overlays is added.
For GEM support, non-scanout buffers are using the shmem backed pages
provided by GEM core (In drm_gem_object_init()). In the case of scanout
buffers, which need to be physically contiguous, those are allocated
with CMA and use drm_gem_private_object_init().
See userspace xorg driver:
git://github.com/robclark/xf86-video-omap.git
Refer to this link for CMA (Continuous Memory Allocator):
http://lkml.org/lkml/2011/8/19/302
Links to previous versions of the patch:
v1: http://lwn.net/Articles/458137/
v2: http://patches.linaro.org/4156/
v3: http://patches.linaro.org/4688/
v4: http://patches.linaro.org/4791/
History:
v5: move headers from include/drm at Greg KH's request, minor rebasing
on 3.2-rc1, pull in private copies of drm_gem_{get,put}_pages()
because "drm/gem: add functions to get/put pages" patch is not
merged yet
v4: bit of rework of encoder/connector _dpms() code, modeset_init()
rework to not use nested functions, update TODO.txt
v3: minor cleanups, improved error handling for dev_load(), some minor
API changes that will be needed later for tiled buffer support
v2: replace omap_vram with CMA for scanout buffer allocation, remove
unneeded functions, use dma_addr_t for physical addresses, error
handling cleanup, refactor attach/detach pages into common drm
functions, split non-userspace-facing API into omap_priv.h, remove
plugin API
v1: original
Signed-off-by: Rob Clark <rob@ti.com>
Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-11-13 02:09:40 +08:00
|
|
|
{
|
2011-12-10 13:26:08 +08:00
|
|
|
struct omap_drm_private *priv = obj->dev->dev_private;
|
staging: add omapdrm DRM/KMS driver for TI OMAP platforms
A DRM display driver for TI OMAP platform. Similar to omapfb (fbdev)
and omap_vout (v4l2 display) drivers in the past, this driver uses the
DSS2 driver to access the display hardware, including support for
HDMI, DVI, and various types of LCD panels. And it implements GEM
support for buffer allocation (for KMS as well as offscreen buffers
used by the xf86-video-omap userspace xorg driver).
The driver maps CRTCs to overlays, encoders to overlay-managers, and
connectors to dssdev's. Note that this arrangement might change slightly
when support for drm_plane overlays is added.
For GEM support, non-scanout buffers are using the shmem backed pages
provided by GEM core (In drm_gem_object_init()). In the case of scanout
buffers, which need to be physically contiguous, those are allocated
with CMA and use drm_gem_private_object_init().
See userspace xorg driver:
git://github.com/robclark/xf86-video-omap.git
Refer to this link for CMA (Continuous Memory Allocator):
http://lkml.org/lkml/2011/8/19/302
Links to previous versions of the patch:
v1: http://lwn.net/Articles/458137/
v2: http://patches.linaro.org/4156/
v3: http://patches.linaro.org/4688/
v4: http://patches.linaro.org/4791/
History:
v5: move headers from include/drm at Greg KH's request, minor rebasing
on 3.2-rc1, pull in private copies of drm_gem_{get,put}_pages()
because "drm/gem: add functions to get/put pages" patch is not
merged yet
v4: bit of rework of encoder/connector _dpms() code, modeset_init()
rework to not use nested functions, update TODO.txt
v3: minor cleanups, improved error handling for dev_load(), some minor
API changes that will be needed later for tiled buffer support
v2: replace omap_vram with CMA for scanout buffer allocation, remove
unneeded functions, use dma_addr_t for physical addresses, error
handling cleanup, refactor attach/detach pages into common drm
functions, split non-userspace-facing API into omap_priv.h, remove
plugin API
v1: original
Signed-off-by: Rob Clark <rob@ti.com>
Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-11-13 02:09:40 +08:00
|
|
|
struct omap_gem_object *omap_obj = to_omap_bo(obj);
|
|
|
|
int ret = 0;
|
|
|
|
|
2018-05-27 00:54:33 +08:00
|
|
|
mutex_lock(&omap_obj->lock);
|
2011-12-06 09:19:22 +08:00
|
|
|
|
2018-05-26 00:39:20 +08:00
|
|
|
if (!omap_gem_is_contiguous(omap_obj) && priv->has_dmm) {
|
2017-04-21 05:33:51 +08:00
|
|
|
if (omap_obj->dma_addr_cnt == 0) {
|
2018-02-11 21:07:33 +08:00
|
|
|
u32 npages = obj->size >> PAGE_SHIFT;
|
2011-12-06 09:19:22 +08:00
|
|
|
enum tiler_fmt fmt = gem2fmt(omap_obj->flags);
|
|
|
|
struct tiler_block *block;
|
2011-12-10 13:26:08 +08:00
|
|
|
|
2011-12-06 09:19:22 +08:00
|
|
|
BUG_ON(omap_obj->block);
|
|
|
|
|
2018-05-26 00:39:21 +08:00
|
|
|
ret = omap_gem_attach_pages(obj);
|
2011-12-06 09:19:22 +08:00
|
|
|
if (ret)
|
|
|
|
goto fail;
|
|
|
|
|
|
|
|
if (omap_obj->flags & OMAP_BO_TILED) {
|
|
|
|
block = tiler_reserve_2d(fmt,
|
|
|
|
omap_obj->width,
|
|
|
|
omap_obj->height, 0);
|
|
|
|
} else {
|
|
|
|
block = tiler_reserve_1d(obj->size);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (IS_ERR(block)) {
|
|
|
|
ret = PTR_ERR(block);
|
|
|
|
dev_err(obj->dev->dev,
|
|
|
|
"could not remap: %d (%d)\n", ret, fmt);
|
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* TODO: enable async refill.. */
|
2018-05-26 00:39:21 +08:00
|
|
|
ret = tiler_pin(block, omap_obj->pages, npages,
|
2011-12-10 13:26:08 +08:00
|
|
|
omap_obj->roll, true);
|
2011-12-06 09:19:22 +08:00
|
|
|
if (ret) {
|
|
|
|
tiler_release(block);
|
|
|
|
dev_err(obj->dev->dev,
|
|
|
|
"could not pin: %d\n", ret);
|
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
|
2017-04-21 05:33:51 +08:00
|
|
|
omap_obj->dma_addr = tiler_ssptr(block);
|
2011-12-06 09:19:22 +08:00
|
|
|
omap_obj->block = block;
|
|
|
|
|
2017-04-21 05:33:51 +08:00
|
|
|
DBG("got dma address: %pad", &omap_obj->dma_addr);
|
2011-12-06 09:19:22 +08:00
|
|
|
}
|
|
|
|
|
2017-04-21 05:33:51 +08:00
|
|
|
omap_obj->dma_addr_cnt++;
|
2011-12-06 09:19:22 +08:00
|
|
|
|
2017-04-21 05:33:51 +08:00
|
|
|
*dma_addr = omap_obj->dma_addr;
|
2018-05-26 00:39:20 +08:00
|
|
|
} else if (omap_gem_is_contiguous(omap_obj)) {
|
2017-04-21 05:33:51 +08:00
|
|
|
*dma_addr = omap_obj->dma_addr;
|
2011-12-06 09:19:22 +08:00
|
|
|
} else {
|
|
|
|
ret = -EINVAL;
|
2012-05-17 16:37:25 +08:00
|
|
|
goto fail;
|
staging: add omapdrm DRM/KMS driver for TI OMAP platforms
A DRM display driver for TI OMAP platform. Similar to omapfb (fbdev)
and omap_vout (v4l2 display) drivers in the past, this driver uses the
DSS2 driver to access the display hardware, including support for
HDMI, DVI, and various types of LCD panels. And it implements GEM
support for buffer allocation (for KMS as well as offscreen buffers
used by the xf86-video-omap userspace xorg driver).
The driver maps CRTCs to overlays, encoders to overlay-managers, and
connectors to dssdev's. Note that this arrangement might change slightly
when support for drm_plane overlays is added.
For GEM support, non-scanout buffers are using the shmem backed pages
provided by GEM core (In drm_gem_object_init()). In the case of scanout
buffers, which need to be physically contiguous, those are allocated
with CMA and use drm_gem_private_object_init().
See userspace xorg driver:
git://github.com/robclark/xf86-video-omap.git
Refer to this link for CMA (Continuous Memory Allocator):
http://lkml.org/lkml/2011/8/19/302
Links to previous versions of the patch:
v1: http://lwn.net/Articles/458137/
v2: http://patches.linaro.org/4156/
v3: http://patches.linaro.org/4688/
v4: http://patches.linaro.org/4791/
History:
v5: move headers from include/drm at Greg KH's request, minor rebasing
on 3.2-rc1, pull in private copies of drm_gem_{get,put}_pages()
because "drm/gem: add functions to get/put pages" patch is not
merged yet
v4: bit of rework of encoder/connector _dpms() code, modeset_init()
rework to not use nested functions, update TODO.txt
v3: minor cleanups, improved error handling for dev_load(), some minor
API changes that will be needed later for tiled buffer support
v2: replace omap_vram with CMA for scanout buffer allocation, remove
unneeded functions, use dma_addr_t for physical addresses, error
handling cleanup, refactor attach/detach pages into common drm
functions, split non-userspace-facing API into omap_priv.h, remove
plugin API
v1: original
Signed-off-by: Rob Clark <rob@ti.com>
Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-11-13 02:09:40 +08:00
|
|
|
}
|
|
|
|
|
2011-12-06 09:19:22 +08:00
|
|
|
fail:
|
2018-05-27 00:54:33 +08:00
|
|
|
mutex_unlock(&omap_obj->lock);
|
staging: add omapdrm DRM/KMS driver for TI OMAP platforms
A DRM display driver for TI OMAP platform. Similar to omapfb (fbdev)
and omap_vout (v4l2 display) drivers in the past, this driver uses the
DSS2 driver to access the display hardware, including support for
HDMI, DVI, and various types of LCD panels. And it implements GEM
support for buffer allocation (for KMS as well as offscreen buffers
used by the xf86-video-omap userspace xorg driver).
The driver maps CRTCs to overlays, encoders to overlay-managers, and
connectors to dssdev's. Note that this arrangement might change slightly
when support for drm_plane overlays is added.
For GEM support, non-scanout buffers are using the shmem backed pages
provided by GEM core (In drm_gem_object_init()). In the case of scanout
buffers, which need to be physically contiguous, those are allocated
with CMA and use drm_gem_private_object_init().
See userspace xorg driver:
git://github.com/robclark/xf86-video-omap.git
Refer to this link for CMA (Continuous Memory Allocator):
http://lkml.org/lkml/2011/8/19/302
Links to previous versions of the patch:
v1: http://lwn.net/Articles/458137/
v2: http://patches.linaro.org/4156/
v3: http://patches.linaro.org/4688/
v4: http://patches.linaro.org/4791/
History:
v5: move headers from include/drm at Greg KH's request, minor rebasing
on 3.2-rc1, pull in private copies of drm_gem_{get,put}_pages()
because "drm/gem: add functions to get/put pages" patch is not
merged yet
v4: bit of rework of encoder/connector _dpms() code, modeset_init()
rework to not use nested functions, update TODO.txt
v3: minor cleanups, improved error handling for dev_load(), some minor
API changes that will be needed later for tiled buffer support
v2: replace omap_vram with CMA for scanout buffer allocation, remove
unneeded functions, use dma_addr_t for physical addresses, error
handling cleanup, refactor attach/detach pages into common drm
functions, split non-userspace-facing API into omap_priv.h, remove
plugin API
v1: original
Signed-off-by: Rob Clark <rob@ti.com>
Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-11-13 02:09:40 +08:00
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2017-04-21 05:33:52 +08:00
|
|
|
/**
|
|
|
|
* omap_gem_unpin() - Unpin a GEM object from memory
|
|
|
|
* @obj: the GEM object
|
|
|
|
*
|
|
|
|
* Unpin the given GEM object previously pinned with omap_gem_pin(). Pins are
|
|
|
|
* reference-counted, the actualy unpin will only be performed when the number
|
|
|
|
* of calls to this function matches the number of calls to omap_gem_pin().
|
staging: add omapdrm DRM/KMS driver for TI OMAP platforms
A DRM display driver for TI OMAP platform. Similar to omapfb (fbdev)
and omap_vout (v4l2 display) drivers in the past, this driver uses the
DSS2 driver to access the display hardware, including support for
HDMI, DVI, and various types of LCD panels. And it implements GEM
support for buffer allocation (for KMS as well as offscreen buffers
used by the xf86-video-omap userspace xorg driver).
The driver maps CRTCs to overlays, encoders to overlay-managers, and
connectors to dssdev's. Note that this arrangement might change slightly
when support for drm_plane overlays is added.
For GEM support, non-scanout buffers are using the shmem backed pages
provided by GEM core (In drm_gem_object_init()). In the case of scanout
buffers, which need to be physically contiguous, those are allocated
with CMA and use drm_gem_private_object_init().
See userspace xorg driver:
git://github.com/robclark/xf86-video-omap.git
Refer to this link for CMA (Continuous Memory Allocator):
http://lkml.org/lkml/2011/8/19/302
Links to previous versions of the patch:
v1: http://lwn.net/Articles/458137/
v2: http://patches.linaro.org/4156/
v3: http://patches.linaro.org/4688/
v4: http://patches.linaro.org/4791/
History:
v5: move headers from include/drm at Greg KH's request, minor rebasing
on 3.2-rc1, pull in private copies of drm_gem_{get,put}_pages()
because "drm/gem: add functions to get/put pages" patch is not
merged yet
v4: bit of rework of encoder/connector _dpms() code, modeset_init()
rework to not use nested functions, update TODO.txt
v3: minor cleanups, improved error handling for dev_load(), some minor
API changes that will be needed later for tiled buffer support
v2: replace omap_vram with CMA for scanout buffer allocation, remove
unneeded functions, use dma_addr_t for physical addresses, error
handling cleanup, refactor attach/detach pages into common drm
functions, split non-userspace-facing API into omap_priv.h, remove
plugin API
v1: original
Signed-off-by: Rob Clark <rob@ti.com>
Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-11-13 02:09:40 +08:00
|
|
|
*/
|
2017-04-21 05:33:52 +08:00
|
|
|
void omap_gem_unpin(struct drm_gem_object *obj)
|
staging: add omapdrm DRM/KMS driver for TI OMAP platforms
A DRM display driver for TI OMAP platform. Similar to omapfb (fbdev)
and omap_vout (v4l2 display) drivers in the past, this driver uses the
DSS2 driver to access the display hardware, including support for
HDMI, DVI, and various types of LCD panels. And it implements GEM
support for buffer allocation (for KMS as well as offscreen buffers
used by the xf86-video-omap userspace xorg driver).
The driver maps CRTCs to overlays, encoders to overlay-managers, and
connectors to dssdev's. Note that this arrangement might change slightly
when support for drm_plane overlays is added.
For GEM support, non-scanout buffers are using the shmem backed pages
provided by GEM core (In drm_gem_object_init()). In the case of scanout
buffers, which need to be physically contiguous, those are allocated
with CMA and use drm_gem_private_object_init().
See userspace xorg driver:
git://github.com/robclark/xf86-video-omap.git
Refer to this link for CMA (Continuous Memory Allocator):
http://lkml.org/lkml/2011/8/19/302
Links to previous versions of the patch:
v1: http://lwn.net/Articles/458137/
v2: http://patches.linaro.org/4156/
v3: http://patches.linaro.org/4688/
v4: http://patches.linaro.org/4791/
History:
v5: move headers from include/drm at Greg KH's request, minor rebasing
on 3.2-rc1, pull in private copies of drm_gem_{get,put}_pages()
because "drm/gem: add functions to get/put pages" patch is not
merged yet
v4: bit of rework of encoder/connector _dpms() code, modeset_init()
rework to not use nested functions, update TODO.txt
v3: minor cleanups, improved error handling for dev_load(), some minor
API changes that will be needed later for tiled buffer support
v2: replace omap_vram with CMA for scanout buffer allocation, remove
unneeded functions, use dma_addr_t for physical addresses, error
handling cleanup, refactor attach/detach pages into common drm
functions, split non-userspace-facing API into omap_priv.h, remove
plugin API
v1: original
Signed-off-by: Rob Clark <rob@ti.com>
Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-11-13 02:09:40 +08:00
|
|
|
{
|
2011-12-06 09:19:22 +08:00
|
|
|
struct omap_gem_object *omap_obj = to_omap_bo(obj);
|
2015-04-28 19:01:36 +08:00
|
|
|
int ret;
|
2011-12-06 09:19:22 +08:00
|
|
|
|
2018-05-27 00:54:33 +08:00
|
|
|
mutex_lock(&omap_obj->lock);
|
|
|
|
|
2017-04-21 05:33:51 +08:00
|
|
|
if (omap_obj->dma_addr_cnt > 0) {
|
|
|
|
omap_obj->dma_addr_cnt--;
|
|
|
|
if (omap_obj->dma_addr_cnt == 0) {
|
2011-12-06 09:19:22 +08:00
|
|
|
ret = tiler_unpin(omap_obj->block);
|
|
|
|
if (ret) {
|
|
|
|
dev_err(obj->dev->dev,
|
|
|
|
"could not unpin pages: %d\n", ret);
|
|
|
|
}
|
|
|
|
ret = tiler_release(omap_obj->block);
|
|
|
|
if (ret) {
|
|
|
|
dev_err(obj->dev->dev,
|
|
|
|
"could not release unmap: %d\n", ret);
|
|
|
|
}
|
2017-04-21 05:33:51 +08:00
|
|
|
omap_obj->dma_addr = 0;
|
2011-12-06 09:19:22 +08:00
|
|
|
omap_obj->block = NULL;
|
|
|
|
}
|
|
|
|
}
|
2015-04-28 19:01:36 +08:00
|
|
|
|
2018-05-27 00:54:33 +08:00
|
|
|
mutex_unlock(&omap_obj->lock);
|
staging: add omapdrm DRM/KMS driver for TI OMAP platforms
A DRM display driver for TI OMAP platform. Similar to omapfb (fbdev)
and omap_vout (v4l2 display) drivers in the past, this driver uses the
DSS2 driver to access the display hardware, including support for
HDMI, DVI, and various types of LCD panels. And it implements GEM
support for buffer allocation (for KMS as well as offscreen buffers
used by the xf86-video-omap userspace xorg driver).
The driver maps CRTCs to overlays, encoders to overlay-managers, and
connectors to dssdev's. Note that this arrangement might change slightly
when support for drm_plane overlays is added.
For GEM support, non-scanout buffers are using the shmem backed pages
provided by GEM core (In drm_gem_object_init()). In the case of scanout
buffers, which need to be physically contiguous, those are allocated
with CMA and use drm_gem_private_object_init().
See userspace xorg driver:
git://github.com/robclark/xf86-video-omap.git
Refer to this link for CMA (Continuous Memory Allocator):
http://lkml.org/lkml/2011/8/19/302
Links to previous versions of the patch:
v1: http://lwn.net/Articles/458137/
v2: http://patches.linaro.org/4156/
v3: http://patches.linaro.org/4688/
v4: http://patches.linaro.org/4791/
History:
v5: move headers from include/drm at Greg KH's request, minor rebasing
on 3.2-rc1, pull in private copies of drm_gem_{get,put}_pages()
because "drm/gem: add functions to get/put pages" patch is not
merged yet
v4: bit of rework of encoder/connector _dpms() code, modeset_init()
rework to not use nested functions, update TODO.txt
v3: minor cleanups, improved error handling for dev_load(), some minor
API changes that will be needed later for tiled buffer support
v2: replace omap_vram with CMA for scanout buffer allocation, remove
unneeded functions, use dma_addr_t for physical addresses, error
handling cleanup, refactor attach/detach pages into common drm
functions, split non-userspace-facing API into omap_priv.h, remove
plugin API
v1: original
Signed-off-by: Rob Clark <rob@ti.com>
Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-11-13 02:09:40 +08:00
|
|
|
}
|
|
|
|
|
2012-08-16 04:18:01 +08:00
|
|
|
/* Get rotated scanout address (only valid if already pinned), at the
|
|
|
|
* specified orientation and x,y offset from top-left corner of buffer
|
|
|
|
* (only valid for tiled 2d buffers)
|
|
|
|
*/
|
2018-02-11 21:07:33 +08:00
|
|
|
int omap_gem_rotated_dma_addr(struct drm_gem_object *obj, u32 orient,
|
2017-04-21 05:33:51 +08:00
|
|
|
int x, int y, dma_addr_t *dma_addr)
|
2012-08-16 04:18:01 +08:00
|
|
|
{
|
|
|
|
struct omap_gem_object *omap_obj = to_omap_bo(obj);
|
|
|
|
int ret = -EINVAL;
|
|
|
|
|
2018-05-27 00:54:33 +08:00
|
|
|
mutex_lock(&omap_obj->lock);
|
|
|
|
|
2017-04-21 05:33:51 +08:00
|
|
|
if ((omap_obj->dma_addr_cnt > 0) && omap_obj->block &&
|
2012-08-16 04:18:01 +08:00
|
|
|
(omap_obj->flags & OMAP_BO_TILED)) {
|
2017-04-21 05:33:51 +08:00
|
|
|
*dma_addr = tiler_tsptr(omap_obj->block, orient, x, y);
|
2012-08-16 04:18:01 +08:00
|
|
|
ret = 0;
|
|
|
|
}
|
2018-05-27 00:54:33 +08:00
|
|
|
|
|
|
|
mutex_unlock(&omap_obj->lock);
|
|
|
|
|
2012-08-16 04:18:01 +08:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Get tiler stride for the buffer (only valid for 2d tiled buffers) */
|
2018-02-11 21:07:33 +08:00
|
|
|
int omap_gem_tiled_stride(struct drm_gem_object *obj, u32 orient)
|
2012-08-16 04:18:01 +08:00
|
|
|
{
|
|
|
|
struct omap_gem_object *omap_obj = to_omap_bo(obj);
|
|
|
|
int ret = -EINVAL;
|
|
|
|
if (omap_obj->flags & OMAP_BO_TILED)
|
|
|
|
ret = tiler_stride(gem2fmt(omap_obj->flags), orient);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2012-04-11 02:19:55 +08:00
|
|
|
/* if !remap, and we don't have pages backing, then fail, rather than
|
|
|
|
* increasing the pin count (which we don't really do yet anyways,
|
|
|
|
* because we don't support swapping pages back out). And 'remap'
|
|
|
|
* might not be quite the right name, but I wanted to keep it working
|
2017-04-21 05:33:52 +08:00
|
|
|
* similarly to omap_gem_pin(). Note though that mutex is not
|
2012-04-11 02:19:55 +08:00
|
|
|
* aquired if !remap (because this can be called in atomic ctxt),
|
2017-04-21 05:33:52 +08:00
|
|
|
* but probably omap_gem_unpin() should be changed to work in the
|
2012-04-11 02:19:55 +08:00
|
|
|
* same way. If !remap, a matching omap_gem_put_pages() call is not
|
|
|
|
* required (and should not be made).
|
|
|
|
*/
|
|
|
|
int omap_gem_get_pages(struct drm_gem_object *obj, struct page ***pages,
|
|
|
|
bool remap)
|
staging: add omapdrm DRM/KMS driver for TI OMAP platforms
A DRM display driver for TI OMAP platform. Similar to omapfb (fbdev)
and omap_vout (v4l2 display) drivers in the past, this driver uses the
DSS2 driver to access the display hardware, including support for
HDMI, DVI, and various types of LCD panels. And it implements GEM
support for buffer allocation (for KMS as well as offscreen buffers
used by the xf86-video-omap userspace xorg driver).
The driver maps CRTCs to overlays, encoders to overlay-managers, and
connectors to dssdev's. Note that this arrangement might change slightly
when support for drm_plane overlays is added.
For GEM support, non-scanout buffers are using the shmem backed pages
provided by GEM core (In drm_gem_object_init()). In the case of scanout
buffers, which need to be physically contiguous, those are allocated
with CMA and use drm_gem_private_object_init().
See userspace xorg driver:
git://github.com/robclark/xf86-video-omap.git
Refer to this link for CMA (Continuous Memory Allocator):
http://lkml.org/lkml/2011/8/19/302
Links to previous versions of the patch:
v1: http://lwn.net/Articles/458137/
v2: http://patches.linaro.org/4156/
v3: http://patches.linaro.org/4688/
v4: http://patches.linaro.org/4791/
History:
v5: move headers from include/drm at Greg KH's request, minor rebasing
on 3.2-rc1, pull in private copies of drm_gem_{get,put}_pages()
because "drm/gem: add functions to get/put pages" patch is not
merged yet
v4: bit of rework of encoder/connector _dpms() code, modeset_init()
rework to not use nested functions, update TODO.txt
v3: minor cleanups, improved error handling for dev_load(), some minor
API changes that will be needed later for tiled buffer support
v2: replace omap_vram with CMA for scanout buffer allocation, remove
unneeded functions, use dma_addr_t for physical addresses, error
handling cleanup, refactor attach/detach pages into common drm
functions, split non-userspace-facing API into omap_priv.h, remove
plugin API
v1: original
Signed-off-by: Rob Clark <rob@ti.com>
Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-11-13 02:09:40 +08:00
|
|
|
{
|
2018-05-26 00:39:21 +08:00
|
|
|
struct omap_gem_object *omap_obj = to_omap_bo(obj);
|
2018-05-27 00:54:33 +08:00
|
|
|
int ret = 0;
|
2018-05-26 00:39:21 +08:00
|
|
|
|
2018-05-27 00:54:33 +08:00
|
|
|
mutex_lock(&omap_obj->lock);
|
|
|
|
|
|
|
|
if (remap) {
|
|
|
|
ret = omap_gem_attach_pages(obj);
|
|
|
|
if (ret)
|
|
|
|
goto unlock;
|
2012-04-11 02:19:55 +08:00
|
|
|
}
|
2018-05-27 00:54:33 +08:00
|
|
|
|
|
|
|
if (!omap_obj->pages) {
|
|
|
|
ret = -ENOMEM;
|
|
|
|
goto unlock;
|
|
|
|
}
|
|
|
|
|
2018-05-26 00:39:21 +08:00
|
|
|
*pages = omap_obj->pages;
|
2018-05-27 00:54:33 +08:00
|
|
|
|
|
|
|
unlock:
|
|
|
|
mutex_unlock(&omap_obj->lock);
|
|
|
|
|
staging: add omapdrm DRM/KMS driver for TI OMAP platforms
A DRM display driver for TI OMAP platform. Similar to omapfb (fbdev)
and omap_vout (v4l2 display) drivers in the past, this driver uses the
DSS2 driver to access the display hardware, including support for
HDMI, DVI, and various types of LCD panels. And it implements GEM
support for buffer allocation (for KMS as well as offscreen buffers
used by the xf86-video-omap userspace xorg driver).
The driver maps CRTCs to overlays, encoders to overlay-managers, and
connectors to dssdev's. Note that this arrangement might change slightly
when support for drm_plane overlays is added.
For GEM support, non-scanout buffers are using the shmem backed pages
provided by GEM core (In drm_gem_object_init()). In the case of scanout
buffers, which need to be physically contiguous, those are allocated
with CMA and use drm_gem_private_object_init().
See userspace xorg driver:
git://github.com/robclark/xf86-video-omap.git
Refer to this link for CMA (Continuous Memory Allocator):
http://lkml.org/lkml/2011/8/19/302
Links to previous versions of the patch:
v1: http://lwn.net/Articles/458137/
v2: http://patches.linaro.org/4156/
v3: http://patches.linaro.org/4688/
v4: http://patches.linaro.org/4791/
History:
v5: move headers from include/drm at Greg KH's request, minor rebasing
on 3.2-rc1, pull in private copies of drm_gem_{get,put}_pages()
because "drm/gem: add functions to get/put pages" patch is not
merged yet
v4: bit of rework of encoder/connector _dpms() code, modeset_init()
rework to not use nested functions, update TODO.txt
v3: minor cleanups, improved error handling for dev_load(), some minor
API changes that will be needed later for tiled buffer support
v2: replace omap_vram with CMA for scanout buffer allocation, remove
unneeded functions, use dma_addr_t for physical addresses, error
handling cleanup, refactor attach/detach pages into common drm
functions, split non-userspace-facing API into omap_priv.h, remove
plugin API
v1: original
Signed-off-by: Rob Clark <rob@ti.com>
Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-11-13 02:09:40 +08:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* release pages when DMA no longer being performed */
|
|
|
|
int omap_gem_put_pages(struct drm_gem_object *obj)
|
|
|
|
{
|
|
|
|
/* do something here if we dynamically attach/detach pages.. at
|
|
|
|
* least they would no longer need to be pinned if everyone has
|
|
|
|
* released the pages..
|
|
|
|
*/
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2015-12-15 04:39:30 +08:00
|
|
|
#ifdef CONFIG_DRM_FBDEV_EMULATION
|
2018-05-27 00:54:33 +08:00
|
|
|
/*
|
|
|
|
* Get kernel virtual address for CPU access.. this more or less only
|
|
|
|
* exists for omap_fbdev.
|
staging: add omapdrm DRM/KMS driver for TI OMAP platforms
A DRM display driver for TI OMAP platform. Similar to omapfb (fbdev)
and omap_vout (v4l2 display) drivers in the past, this driver uses the
DSS2 driver to access the display hardware, including support for
HDMI, DVI, and various types of LCD panels. And it implements GEM
support for buffer allocation (for KMS as well as offscreen buffers
used by the xf86-video-omap userspace xorg driver).
The driver maps CRTCs to overlays, encoders to overlay-managers, and
connectors to dssdev's. Note that this arrangement might change slightly
when support for drm_plane overlays is added.
For GEM support, non-scanout buffers are using the shmem backed pages
provided by GEM core (In drm_gem_object_init()). In the case of scanout
buffers, which need to be physically contiguous, those are allocated
with CMA and use drm_gem_private_object_init().
See userspace xorg driver:
git://github.com/robclark/xf86-video-omap.git
Refer to this link for CMA (Continuous Memory Allocator):
http://lkml.org/lkml/2011/8/19/302
Links to previous versions of the patch:
v1: http://lwn.net/Articles/458137/
v2: http://patches.linaro.org/4156/
v3: http://patches.linaro.org/4688/
v4: http://patches.linaro.org/4791/
History:
v5: move headers from include/drm at Greg KH's request, minor rebasing
on 3.2-rc1, pull in private copies of drm_gem_{get,put}_pages()
because "drm/gem: add functions to get/put pages" patch is not
merged yet
v4: bit of rework of encoder/connector _dpms() code, modeset_init()
rework to not use nested functions, update TODO.txt
v3: minor cleanups, improved error handling for dev_load(), some minor
API changes that will be needed later for tiled buffer support
v2: replace omap_vram with CMA for scanout buffer allocation, remove
unneeded functions, use dma_addr_t for physical addresses, error
handling cleanup, refactor attach/detach pages into common drm
functions, split non-userspace-facing API into omap_priv.h, remove
plugin API
v1: original
Signed-off-by: Rob Clark <rob@ti.com>
Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-11-13 02:09:40 +08:00
|
|
|
*/
|
|
|
|
void *omap_gem_vaddr(struct drm_gem_object *obj)
|
|
|
|
{
|
|
|
|
struct omap_gem_object *omap_obj = to_omap_bo(obj);
|
2018-05-27 00:54:33 +08:00
|
|
|
void *vaddr;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
mutex_lock(&omap_obj->lock);
|
2018-05-26 00:39:20 +08:00
|
|
|
|
2018-05-27 00:54:33 +08:00
|
|
|
if (!omap_obj->vaddr) {
|
2018-05-26 00:39:21 +08:00
|
|
|
ret = omap_gem_attach_pages(obj);
|
2018-05-27 00:54:33 +08:00
|
|
|
if (ret) {
|
|
|
|
vaddr = ERR_PTR(ret);
|
|
|
|
goto unlock;
|
|
|
|
}
|
|
|
|
|
2018-05-26 00:39:21 +08:00
|
|
|
omap_obj->vaddr = vmap(omap_obj->pages, obj->size >> PAGE_SHIFT,
|
2011-12-06 09:19:22 +08:00
|
|
|
VM_MAP, pgprot_writecombine(PAGE_KERNEL));
|
|
|
|
}
|
2018-05-27 00:54:33 +08:00
|
|
|
|
|
|
|
vaddr = omap_obj->vaddr;
|
|
|
|
|
|
|
|
unlock:
|
|
|
|
mutex_unlock(&omap_obj->lock);
|
|
|
|
return vaddr;
|
staging: add omapdrm DRM/KMS driver for TI OMAP platforms
A DRM display driver for TI OMAP platform. Similar to omapfb (fbdev)
and omap_vout (v4l2 display) drivers in the past, this driver uses the
DSS2 driver to access the display hardware, including support for
HDMI, DVI, and various types of LCD panels. And it implements GEM
support for buffer allocation (for KMS as well as offscreen buffers
used by the xf86-video-omap userspace xorg driver).
The driver maps CRTCs to overlays, encoders to overlay-managers, and
connectors to dssdev's. Note that this arrangement might change slightly
when support for drm_plane overlays is added.
For GEM support, non-scanout buffers are using the shmem backed pages
provided by GEM core (In drm_gem_object_init()). In the case of scanout
buffers, which need to be physically contiguous, those are allocated
with CMA and use drm_gem_private_object_init().
See userspace xorg driver:
git://github.com/robclark/xf86-video-omap.git
Refer to this link for CMA (Continuous Memory Allocator):
http://lkml.org/lkml/2011/8/19/302
Links to previous versions of the patch:
v1: http://lwn.net/Articles/458137/
v2: http://patches.linaro.org/4156/
v3: http://patches.linaro.org/4688/
v4: http://patches.linaro.org/4791/
History:
v5: move headers from include/drm at Greg KH's request, minor rebasing
on 3.2-rc1, pull in private copies of drm_gem_{get,put}_pages()
because "drm/gem: add functions to get/put pages" patch is not
merged yet
v4: bit of rework of encoder/connector _dpms() code, modeset_init()
rework to not use nested functions, update TODO.txt
v3: minor cleanups, improved error handling for dev_load(), some minor
API changes that will be needed later for tiled buffer support
v2: replace omap_vram with CMA for scanout buffer allocation, remove
unneeded functions, use dma_addr_t for physical addresses, error
handling cleanup, refactor attach/detach pages into common drm
functions, split non-userspace-facing API into omap_priv.h, remove
plugin API
v1: original
Signed-off-by: Rob Clark <rob@ti.com>
Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-11-13 02:09:40 +08:00
|
|
|
}
|
2015-12-15 04:39:30 +08:00
|
|
|
#endif
|
staging: add omapdrm DRM/KMS driver for TI OMAP platforms
A DRM display driver for TI OMAP platform. Similar to omapfb (fbdev)
and omap_vout (v4l2 display) drivers in the past, this driver uses the
DSS2 driver to access the display hardware, including support for
HDMI, DVI, and various types of LCD panels. And it implements GEM
support for buffer allocation (for KMS as well as offscreen buffers
used by the xf86-video-omap userspace xorg driver).
The driver maps CRTCs to overlays, encoders to overlay-managers, and
connectors to dssdev's. Note that this arrangement might change slightly
when support for drm_plane overlays is added.
For GEM support, non-scanout buffers are using the shmem backed pages
provided by GEM core (In drm_gem_object_init()). In the case of scanout
buffers, which need to be physically contiguous, those are allocated
with CMA and use drm_gem_private_object_init().
See userspace xorg driver:
git://github.com/robclark/xf86-video-omap.git
Refer to this link for CMA (Continuous Memory Allocator):
http://lkml.org/lkml/2011/8/19/302
Links to previous versions of the patch:
v1: http://lwn.net/Articles/458137/
v2: http://patches.linaro.org/4156/
v3: http://patches.linaro.org/4688/
v4: http://patches.linaro.org/4791/
History:
v5: move headers from include/drm at Greg KH's request, minor rebasing
on 3.2-rc1, pull in private copies of drm_gem_{get,put}_pages()
because "drm/gem: add functions to get/put pages" patch is not
merged yet
v4: bit of rework of encoder/connector _dpms() code, modeset_init()
rework to not use nested functions, update TODO.txt
v3: minor cleanups, improved error handling for dev_load(), some minor
API changes that will be needed later for tiled buffer support
v2: replace omap_vram with CMA for scanout buffer allocation, remove
unneeded functions, use dma_addr_t for physical addresses, error
handling cleanup, refactor attach/detach pages into common drm
functions, split non-userspace-facing API into omap_priv.h, remove
plugin API
v1: original
Signed-off-by: Rob Clark <rob@ti.com>
Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-11-13 02:09:40 +08:00
|
|
|
|
2015-12-15 04:39:33 +08:00
|
|
|
/* -----------------------------------------------------------------------------
|
|
|
|
* Power Management
|
|
|
|
*/
|
staging: add omapdrm DRM/KMS driver for TI OMAP platforms
A DRM display driver for TI OMAP platform. Similar to omapfb (fbdev)
and omap_vout (v4l2 display) drivers in the past, this driver uses the
DSS2 driver to access the display hardware, including support for
HDMI, DVI, and various types of LCD panels. And it implements GEM
support for buffer allocation (for KMS as well as offscreen buffers
used by the xf86-video-omap userspace xorg driver).
The driver maps CRTCs to overlays, encoders to overlay-managers, and
connectors to dssdev's. Note that this arrangement might change slightly
when support for drm_plane overlays is added.
For GEM support, non-scanout buffers are using the shmem backed pages
provided by GEM core (In drm_gem_object_init()). In the case of scanout
buffers, which need to be physically contiguous, those are allocated
with CMA and use drm_gem_private_object_init().
See userspace xorg driver:
git://github.com/robclark/xf86-video-omap.git
Refer to this link for CMA (Continuous Memory Allocator):
http://lkml.org/lkml/2011/8/19/302
Links to previous versions of the patch:
v1: http://lwn.net/Articles/458137/
v2: http://patches.linaro.org/4156/
v3: http://patches.linaro.org/4688/
v4: http://patches.linaro.org/4791/
History:
v5: move headers from include/drm at Greg KH's request, minor rebasing
on 3.2-rc1, pull in private copies of drm_gem_{get,put}_pages()
because "drm/gem: add functions to get/put pages" patch is not
merged yet
v4: bit of rework of encoder/connector _dpms() code, modeset_init()
rework to not use nested functions, update TODO.txt
v3: minor cleanups, improved error handling for dev_load(), some minor
API changes that will be needed later for tiled buffer support
v2: replace omap_vram with CMA for scanout buffer allocation, remove
unneeded functions, use dma_addr_t for physical addresses, error
handling cleanup, refactor attach/detach pages into common drm
functions, split non-userspace-facing API into omap_priv.h, remove
plugin API
v1: original
Signed-off-by: Rob Clark <rob@ti.com>
Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-11-13 02:09:40 +08:00
|
|
|
|
2012-12-20 04:53:37 +08:00
|
|
|
#ifdef CONFIG_PM
|
|
|
|
/* re-pin objects in DMM in resume path: */
|
2017-10-13 22:58:58 +08:00
|
|
|
int omap_gem_resume(struct drm_device *dev)
|
2012-12-20 04:53:37 +08:00
|
|
|
{
|
2017-10-13 22:58:58 +08:00
|
|
|
struct omap_drm_private *priv = dev->dev_private;
|
2012-12-20 04:53:37 +08:00
|
|
|
struct omap_gem_object *omap_obj;
|
|
|
|
int ret = 0;
|
|
|
|
|
2018-05-26 00:39:24 +08:00
|
|
|
mutex_lock(&priv->list_lock);
|
2012-12-20 04:53:37 +08:00
|
|
|
list_for_each_entry(omap_obj, &priv->obj_list, mm_list) {
|
|
|
|
if (omap_obj->block) {
|
|
|
|
struct drm_gem_object *obj = &omap_obj->base;
|
2018-02-11 21:07:33 +08:00
|
|
|
u32 npages = obj->size >> PAGE_SHIFT;
|
|
|
|
|
2012-12-20 04:53:37 +08:00
|
|
|
WARN_ON(!omap_obj->pages); /* this can't happen */
|
|
|
|
ret = tiler_pin(omap_obj->block,
|
|
|
|
omap_obj->pages, npages,
|
|
|
|
omap_obj->roll, true);
|
|
|
|
if (ret) {
|
2017-10-13 22:58:58 +08:00
|
|
|
dev_err(dev->dev, "could not repin: %d\n", ret);
|
2018-05-26 00:39:24 +08:00
|
|
|
goto done;
|
2012-12-20 04:53:37 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-05-26 00:39:24 +08:00
|
|
|
done:
|
|
|
|
mutex_unlock(&priv->list_lock);
|
|
|
|
return ret;
|
2012-12-20 04:53:37 +08:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2015-12-15 04:39:33 +08:00
|
|
|
/* -----------------------------------------------------------------------------
|
|
|
|
* DebugFS
|
|
|
|
*/
|
|
|
|
|
2012-03-06 00:48:36 +08:00
|
|
|
#ifdef CONFIG_DEBUG_FS
|
|
|
|
void omap_gem_describe(struct drm_gem_object *obj, struct seq_file *m)
|
|
|
|
{
|
|
|
|
struct omap_gem_object *omap_obj = to_omap_bo(obj);
|
2018-02-11 21:07:33 +08:00
|
|
|
u64 off;
|
2012-03-06 00:48:36 +08:00
|
|
|
|
2013-07-25 03:07:52 +08:00
|
|
|
off = drm_vma_node_start(&obj->vma_node);
|
2012-03-06 00:48:36 +08:00
|
|
|
|
2018-05-27 00:54:33 +08:00
|
|
|
mutex_lock(&omap_obj->lock);
|
|
|
|
|
2014-07-12 17:53:41 +08:00
|
|
|
seq_printf(m, "%08x: %2d (%2d) %08llx %pad (%2d) %p %4d",
|
2016-11-15 00:29:48 +08:00
|
|
|
omap_obj->flags, obj->name, kref_read(&obj->refcount),
|
2017-04-21 05:33:51 +08:00
|
|
|
off, &omap_obj->dma_addr, omap_obj->dma_addr_cnt,
|
2012-03-06 00:48:36 +08:00
|
|
|
omap_obj->vaddr, omap_obj->roll);
|
|
|
|
|
|
|
|
if (omap_obj->flags & OMAP_BO_TILED) {
|
|
|
|
seq_printf(m, " %dx%d", omap_obj->width, omap_obj->height);
|
|
|
|
if (omap_obj->block) {
|
|
|
|
struct tcm_area *area = &omap_obj->block->area;
|
|
|
|
seq_printf(m, " (%dx%d, %dx%d)",
|
|
|
|
area->p0.x, area->p0.y,
|
|
|
|
area->p1.x, area->p1.y);
|
|
|
|
}
|
|
|
|
} else {
|
2017-02-21 15:57:12 +08:00
|
|
|
seq_printf(m, " %zu", obj->size);
|
2012-03-06 00:48:36 +08:00
|
|
|
}
|
|
|
|
|
2018-05-27 00:54:33 +08:00
|
|
|
mutex_unlock(&omap_obj->lock);
|
|
|
|
|
2012-03-06 00:48:36 +08:00
|
|
|
seq_printf(m, "\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
void omap_gem_describe_objects(struct list_head *list, struct seq_file *m)
|
|
|
|
{
|
|
|
|
struct omap_gem_object *omap_obj;
|
|
|
|
int count = 0;
|
|
|
|
size_t size = 0;
|
|
|
|
|
|
|
|
list_for_each_entry(omap_obj, list, mm_list) {
|
|
|
|
struct drm_gem_object *obj = &omap_obj->base;
|
|
|
|
seq_printf(m, " ");
|
|
|
|
omap_gem_describe(obj, m);
|
|
|
|
count++;
|
|
|
|
size += obj->size;
|
|
|
|
}
|
|
|
|
|
|
|
|
seq_printf(m, "Total %d objects, %zu bytes\n", count, size);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2015-12-15 04:39:33 +08:00
|
|
|
/* -----------------------------------------------------------------------------
|
|
|
|
* Constructor & Destructor
|
|
|
|
*/
|
|
|
|
|
staging: add omapdrm DRM/KMS driver for TI OMAP platforms
A DRM display driver for TI OMAP platform. Similar to omapfb (fbdev)
and omap_vout (v4l2 display) drivers in the past, this driver uses the
DSS2 driver to access the display hardware, including support for
HDMI, DVI, and various types of LCD panels. And it implements GEM
support for buffer allocation (for KMS as well as offscreen buffers
used by the xf86-video-omap userspace xorg driver).
The driver maps CRTCs to overlays, encoders to overlay-managers, and
connectors to dssdev's. Note that this arrangement might change slightly
when support for drm_plane overlays is added.
For GEM support, non-scanout buffers are using the shmem backed pages
provided by GEM core (In drm_gem_object_init()). In the case of scanout
buffers, which need to be physically contiguous, those are allocated
with CMA and use drm_gem_private_object_init().
See userspace xorg driver:
git://github.com/robclark/xf86-video-omap.git
Refer to this link for CMA (Continuous Memory Allocator):
http://lkml.org/lkml/2011/8/19/302
Links to previous versions of the patch:
v1: http://lwn.net/Articles/458137/
v2: http://patches.linaro.org/4156/
v3: http://patches.linaro.org/4688/
v4: http://patches.linaro.org/4791/
History:
v5: move headers from include/drm at Greg KH's request, minor rebasing
on 3.2-rc1, pull in private copies of drm_gem_{get,put}_pages()
because "drm/gem: add functions to get/put pages" patch is not
merged yet
v4: bit of rework of encoder/connector _dpms() code, modeset_init()
rework to not use nested functions, update TODO.txt
v3: minor cleanups, improved error handling for dev_load(), some minor
API changes that will be needed later for tiled buffer support
v2: replace omap_vram with CMA for scanout buffer allocation, remove
unneeded functions, use dma_addr_t for physical addresses, error
handling cleanup, refactor attach/detach pages into common drm
functions, split non-userspace-facing API into omap_priv.h, remove
plugin API
v1: original
Signed-off-by: Rob Clark <rob@ti.com>
Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-11-13 02:09:40 +08:00
|
|
|
void omap_gem_free_object(struct drm_gem_object *obj)
|
|
|
|
{
|
|
|
|
struct drm_device *dev = obj->dev;
|
2014-12-17 20:34:22 +08:00
|
|
|
struct omap_drm_private *priv = dev->dev_private;
|
staging: add omapdrm DRM/KMS driver for TI OMAP platforms
A DRM display driver for TI OMAP platform. Similar to omapfb (fbdev)
and omap_vout (v4l2 display) drivers in the past, this driver uses the
DSS2 driver to access the display hardware, including support for
HDMI, DVI, and various types of LCD panels. And it implements GEM
support for buffer allocation (for KMS as well as offscreen buffers
used by the xf86-video-omap userspace xorg driver).
The driver maps CRTCs to overlays, encoders to overlay-managers, and
connectors to dssdev's. Note that this arrangement might change slightly
when support for drm_plane overlays is added.
For GEM support, non-scanout buffers are using the shmem backed pages
provided by GEM core (In drm_gem_object_init()). In the case of scanout
buffers, which need to be physically contiguous, those are allocated
with CMA and use drm_gem_private_object_init().
See userspace xorg driver:
git://github.com/robclark/xf86-video-omap.git
Refer to this link for CMA (Continuous Memory Allocator):
http://lkml.org/lkml/2011/8/19/302
Links to previous versions of the patch:
v1: http://lwn.net/Articles/458137/
v2: http://patches.linaro.org/4156/
v3: http://patches.linaro.org/4688/
v4: http://patches.linaro.org/4791/
History:
v5: move headers from include/drm at Greg KH's request, minor rebasing
on 3.2-rc1, pull in private copies of drm_gem_{get,put}_pages()
because "drm/gem: add functions to get/put pages" patch is not
merged yet
v4: bit of rework of encoder/connector _dpms() code, modeset_init()
rework to not use nested functions, update TODO.txt
v3: minor cleanups, improved error handling for dev_load(), some minor
API changes that will be needed later for tiled buffer support
v2: replace omap_vram with CMA for scanout buffer allocation, remove
unneeded functions, use dma_addr_t for physical addresses, error
handling cleanup, refactor attach/detach pages into common drm
functions, split non-userspace-facing API into omap_priv.h, remove
plugin API
v1: original
Signed-off-by: Rob Clark <rob@ti.com>
Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-11-13 02:09:40 +08:00
|
|
|
struct omap_gem_object *omap_obj = to_omap_bo(obj);
|
|
|
|
|
2018-05-26 00:39:20 +08:00
|
|
|
omap_gem_evict(obj);
|
2011-12-06 09:19:22 +08:00
|
|
|
|
2018-05-26 00:39:24 +08:00
|
|
|
mutex_lock(&priv->list_lock);
|
2012-03-06 00:48:36 +08:00
|
|
|
list_del(&omap_obj->mm_list);
|
2018-05-26 00:39:24 +08:00
|
|
|
mutex_unlock(&priv->list_lock);
|
2012-03-06 00:48:36 +08:00
|
|
|
|
2018-05-27 00:54:33 +08:00
|
|
|
/*
|
|
|
|
* We own the sole reference to the object at this point, but to keep
|
|
|
|
* lockdep happy, we must still take the omap_obj_lock to call
|
|
|
|
* omap_gem_detach_pages(). This should hardly make any difference as
|
|
|
|
* there can't be any lock contention.
|
2012-01-17 02:51:17 +08:00
|
|
|
*/
|
2018-05-27 00:54:33 +08:00
|
|
|
mutex_lock(&omap_obj->lock);
|
|
|
|
|
|
|
|
/* The object should not be pinned. */
|
2017-04-21 05:33:51 +08:00
|
|
|
WARN_ON(omap_obj->dma_addr_cnt > 0);
|
2012-01-17 02:51:17 +08:00
|
|
|
|
2016-01-27 16:58:43 +08:00
|
|
|
if (omap_obj->pages) {
|
|
|
|
if (omap_obj->flags & OMAP_BO_MEM_DMABUF)
|
|
|
|
kfree(omap_obj->pages);
|
|
|
|
else
|
staging: add omapdrm DRM/KMS driver for TI OMAP platforms
A DRM display driver for TI OMAP platform. Similar to omapfb (fbdev)
and omap_vout (v4l2 display) drivers in the past, this driver uses the
DSS2 driver to access the display hardware, including support for
HDMI, DVI, and various types of LCD panels. And it implements GEM
support for buffer allocation (for KMS as well as offscreen buffers
used by the xf86-video-omap userspace xorg driver).
The driver maps CRTCs to overlays, encoders to overlay-managers, and
connectors to dssdev's. Note that this arrangement might change slightly
when support for drm_plane overlays is added.
For GEM support, non-scanout buffers are using the shmem backed pages
provided by GEM core (In drm_gem_object_init()). In the case of scanout
buffers, which need to be physically contiguous, those are allocated
with CMA and use drm_gem_private_object_init().
See userspace xorg driver:
git://github.com/robclark/xf86-video-omap.git
Refer to this link for CMA (Continuous Memory Allocator):
http://lkml.org/lkml/2011/8/19/302
Links to previous versions of the patch:
v1: http://lwn.net/Articles/458137/
v2: http://patches.linaro.org/4156/
v3: http://patches.linaro.org/4688/
v4: http://patches.linaro.org/4791/
History:
v5: move headers from include/drm at Greg KH's request, minor rebasing
on 3.2-rc1, pull in private copies of drm_gem_{get,put}_pages()
because "drm/gem: add functions to get/put pages" patch is not
merged yet
v4: bit of rework of encoder/connector _dpms() code, modeset_init()
rework to not use nested functions, update TODO.txt
v3: minor cleanups, improved error handling for dev_load(), some minor
API changes that will be needed later for tiled buffer support
v2: replace omap_vram with CMA for scanout buffer allocation, remove
unneeded functions, use dma_addr_t for physical addresses, error
handling cleanup, refactor attach/detach pages into common drm
functions, split non-userspace-facing API into omap_priv.h, remove
plugin API
v1: original
Signed-off-by: Rob Clark <rob@ti.com>
Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-11-13 02:09:40 +08:00
|
|
|
omap_gem_detach_pages(obj);
|
2016-01-27 16:58:43 +08:00
|
|
|
}
|
2012-11-14 18:33:17 +08:00
|
|
|
|
2016-01-27 16:58:43 +08:00
|
|
|
if (omap_obj->flags & OMAP_BO_MEM_DMA_API) {
|
2016-03-22 04:48:00 +08:00
|
|
|
dma_free_wc(dev->dev, obj->size, omap_obj->vaddr,
|
2017-04-21 05:33:51 +08:00
|
|
|
omap_obj->dma_addr);
|
2016-01-27 16:58:43 +08:00
|
|
|
} else if (omap_obj->vaddr) {
|
|
|
|
vunmap(omap_obj->vaddr);
|
|
|
|
} else if (obj->import_attach) {
|
|
|
|
drm_prime_gem_destroy(obj, omap_obj->sgt);
|
staging: add omapdrm DRM/KMS driver for TI OMAP platforms
A DRM display driver for TI OMAP platform. Similar to omapfb (fbdev)
and omap_vout (v4l2 display) drivers in the past, this driver uses the
DSS2 driver to access the display hardware, including support for
HDMI, DVI, and various types of LCD panels. And it implements GEM
support for buffer allocation (for KMS as well as offscreen buffers
used by the xf86-video-omap userspace xorg driver).
The driver maps CRTCs to overlays, encoders to overlay-managers, and
connectors to dssdev's. Note that this arrangement might change slightly
when support for drm_plane overlays is added.
For GEM support, non-scanout buffers are using the shmem backed pages
provided by GEM core (In drm_gem_object_init()). In the case of scanout
buffers, which need to be physically contiguous, those are allocated
with CMA and use drm_gem_private_object_init().
See userspace xorg driver:
git://github.com/robclark/xf86-video-omap.git
Refer to this link for CMA (Continuous Memory Allocator):
http://lkml.org/lkml/2011/8/19/302
Links to previous versions of the patch:
v1: http://lwn.net/Articles/458137/
v2: http://patches.linaro.org/4156/
v3: http://patches.linaro.org/4688/
v4: http://patches.linaro.org/4791/
History:
v5: move headers from include/drm at Greg KH's request, minor rebasing
on 3.2-rc1, pull in private copies of drm_gem_{get,put}_pages()
because "drm/gem: add functions to get/put pages" patch is not
merged yet
v4: bit of rework of encoder/connector _dpms() code, modeset_init()
rework to not use nested functions, update TODO.txt
v3: minor cleanups, improved error handling for dev_load(), some minor
API changes that will be needed later for tiled buffer support
v2: replace omap_vram with CMA for scanout buffer allocation, remove
unneeded functions, use dma_addr_t for physical addresses, error
handling cleanup, refactor attach/detach pages into common drm
functions, split non-userspace-facing API into omap_priv.h, remove
plugin API
v1: original
Signed-off-by: Rob Clark <rob@ti.com>
Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-11-13 02:09:40 +08:00
|
|
|
}
|
|
|
|
|
2018-05-27 00:54:33 +08:00
|
|
|
mutex_unlock(&omap_obj->lock);
|
|
|
|
|
staging: add omapdrm DRM/KMS driver for TI OMAP platforms
A DRM display driver for TI OMAP platform. Similar to omapfb (fbdev)
and omap_vout (v4l2 display) drivers in the past, this driver uses the
DSS2 driver to access the display hardware, including support for
HDMI, DVI, and various types of LCD panels. And it implements GEM
support for buffer allocation (for KMS as well as offscreen buffers
used by the xf86-video-omap userspace xorg driver).
The driver maps CRTCs to overlays, encoders to overlay-managers, and
connectors to dssdev's. Note that this arrangement might change slightly
when support for drm_plane overlays is added.
For GEM support, non-scanout buffers are using the shmem backed pages
provided by GEM core (In drm_gem_object_init()). In the case of scanout
buffers, which need to be physically contiguous, those are allocated
with CMA and use drm_gem_private_object_init().
See userspace xorg driver:
git://github.com/robclark/xf86-video-omap.git
Refer to this link for CMA (Continuous Memory Allocator):
http://lkml.org/lkml/2011/8/19/302
Links to previous versions of the patch:
v1: http://lwn.net/Articles/458137/
v2: http://patches.linaro.org/4156/
v3: http://patches.linaro.org/4688/
v4: http://patches.linaro.org/4791/
History:
v5: move headers from include/drm at Greg KH's request, minor rebasing
on 3.2-rc1, pull in private copies of drm_gem_{get,put}_pages()
because "drm/gem: add functions to get/put pages" patch is not
merged yet
v4: bit of rework of encoder/connector _dpms() code, modeset_init()
rework to not use nested functions, update TODO.txt
v3: minor cleanups, improved error handling for dev_load(), some minor
API changes that will be needed later for tiled buffer support
v2: replace omap_vram with CMA for scanout buffer allocation, remove
unneeded functions, use dma_addr_t for physical addresses, error
handling cleanup, refactor attach/detach pages into common drm
functions, split non-userspace-facing API into omap_priv.h, remove
plugin API
v1: original
Signed-off-by: Rob Clark <rob@ti.com>
Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-11-13 02:09:40 +08:00
|
|
|
drm_gem_object_release(obj);
|
|
|
|
|
2018-05-27 00:54:33 +08:00
|
|
|
mutex_destroy(&omap_obj->lock);
|
|
|
|
|
2015-12-15 04:39:38 +08:00
|
|
|
kfree(omap_obj);
|
staging: add omapdrm DRM/KMS driver for TI OMAP platforms
A DRM display driver for TI OMAP platform. Similar to omapfb (fbdev)
and omap_vout (v4l2 display) drivers in the past, this driver uses the
DSS2 driver to access the display hardware, including support for
HDMI, DVI, and various types of LCD panels. And it implements GEM
support for buffer allocation (for KMS as well as offscreen buffers
used by the xf86-video-omap userspace xorg driver).
The driver maps CRTCs to overlays, encoders to overlay-managers, and
connectors to dssdev's. Note that this arrangement might change slightly
when support for drm_plane overlays is added.
For GEM support, non-scanout buffers are using the shmem backed pages
provided by GEM core (In drm_gem_object_init()). In the case of scanout
buffers, which need to be physically contiguous, those are allocated
with CMA and use drm_gem_private_object_init().
See userspace xorg driver:
git://github.com/robclark/xf86-video-omap.git
Refer to this link for CMA (Continuous Memory Allocator):
http://lkml.org/lkml/2011/8/19/302
Links to previous versions of the patch:
v1: http://lwn.net/Articles/458137/
v2: http://patches.linaro.org/4156/
v3: http://patches.linaro.org/4688/
v4: http://patches.linaro.org/4791/
History:
v5: move headers from include/drm at Greg KH's request, minor rebasing
on 3.2-rc1, pull in private copies of drm_gem_{get,put}_pages()
because "drm/gem: add functions to get/put pages" patch is not
merged yet
v4: bit of rework of encoder/connector _dpms() code, modeset_init()
rework to not use nested functions, update TODO.txt
v3: minor cleanups, improved error handling for dev_load(), some minor
API changes that will be needed later for tiled buffer support
v2: replace omap_vram with CMA for scanout buffer allocation, remove
unneeded functions, use dma_addr_t for physical addresses, error
handling cleanup, refactor attach/detach pages into common drm
functions, split non-userspace-facing API into omap_priv.h, remove
plugin API
v1: original
Signed-off-by: Rob Clark <rob@ti.com>
Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-11-13 02:09:40 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* GEM buffer object constructor */
|
|
|
|
struct drm_gem_object *omap_gem_new(struct drm_device *dev,
|
2018-02-11 21:07:33 +08:00
|
|
|
union omap_gem_size gsize, u32 flags)
|
staging: add omapdrm DRM/KMS driver for TI OMAP platforms
A DRM display driver for TI OMAP platform. Similar to omapfb (fbdev)
and omap_vout (v4l2 display) drivers in the past, this driver uses the
DSS2 driver to access the display hardware, including support for
HDMI, DVI, and various types of LCD panels. And it implements GEM
support for buffer allocation (for KMS as well as offscreen buffers
used by the xf86-video-omap userspace xorg driver).
The driver maps CRTCs to overlays, encoders to overlay-managers, and
connectors to dssdev's. Note that this arrangement might change slightly
when support for drm_plane overlays is added.
For GEM support, non-scanout buffers are using the shmem backed pages
provided by GEM core (In drm_gem_object_init()). In the case of scanout
buffers, which need to be physically contiguous, those are allocated
with CMA and use drm_gem_private_object_init().
See userspace xorg driver:
git://github.com/robclark/xf86-video-omap.git
Refer to this link for CMA (Continuous Memory Allocator):
http://lkml.org/lkml/2011/8/19/302
Links to previous versions of the patch:
v1: http://lwn.net/Articles/458137/
v2: http://patches.linaro.org/4156/
v3: http://patches.linaro.org/4688/
v4: http://patches.linaro.org/4791/
History:
v5: move headers from include/drm at Greg KH's request, minor rebasing
on 3.2-rc1, pull in private copies of drm_gem_{get,put}_pages()
because "drm/gem: add functions to get/put pages" patch is not
merged yet
v4: bit of rework of encoder/connector _dpms() code, modeset_init()
rework to not use nested functions, update TODO.txt
v3: minor cleanups, improved error handling for dev_load(), some minor
API changes that will be needed later for tiled buffer support
v2: replace omap_vram with CMA for scanout buffer allocation, remove
unneeded functions, use dma_addr_t for physical addresses, error
handling cleanup, refactor attach/detach pages into common drm
functions, split non-userspace-facing API into omap_priv.h, remove
plugin API
v1: original
Signed-off-by: Rob Clark <rob@ti.com>
Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-11-13 02:09:40 +08:00
|
|
|
{
|
2011-12-10 13:26:08 +08:00
|
|
|
struct omap_drm_private *priv = dev->dev_private;
|
staging: add omapdrm DRM/KMS driver for TI OMAP platforms
A DRM display driver for TI OMAP platform. Similar to omapfb (fbdev)
and omap_vout (v4l2 display) drivers in the past, this driver uses the
DSS2 driver to access the display hardware, including support for
HDMI, DVI, and various types of LCD panels. And it implements GEM
support for buffer allocation (for KMS as well as offscreen buffers
used by the xf86-video-omap userspace xorg driver).
The driver maps CRTCs to overlays, encoders to overlay-managers, and
connectors to dssdev's. Note that this arrangement might change slightly
when support for drm_plane overlays is added.
For GEM support, non-scanout buffers are using the shmem backed pages
provided by GEM core (In drm_gem_object_init()). In the case of scanout
buffers, which need to be physically contiguous, those are allocated
with CMA and use drm_gem_private_object_init().
See userspace xorg driver:
git://github.com/robclark/xf86-video-omap.git
Refer to this link for CMA (Continuous Memory Allocator):
http://lkml.org/lkml/2011/8/19/302
Links to previous versions of the patch:
v1: http://lwn.net/Articles/458137/
v2: http://patches.linaro.org/4156/
v3: http://patches.linaro.org/4688/
v4: http://patches.linaro.org/4791/
History:
v5: move headers from include/drm at Greg KH's request, minor rebasing
on 3.2-rc1, pull in private copies of drm_gem_{get,put}_pages()
because "drm/gem: add functions to get/put pages" patch is not
merged yet
v4: bit of rework of encoder/connector _dpms() code, modeset_init()
rework to not use nested functions, update TODO.txt
v3: minor cleanups, improved error handling for dev_load(), some minor
API changes that will be needed later for tiled buffer support
v2: replace omap_vram with CMA for scanout buffer allocation, remove
unneeded functions, use dma_addr_t for physical addresses, error
handling cleanup, refactor attach/detach pages into common drm
functions, split non-userspace-facing API into omap_priv.h, remove
plugin API
v1: original
Signed-off-by: Rob Clark <rob@ti.com>
Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-11-13 02:09:40 +08:00
|
|
|
struct omap_gem_object *omap_obj;
|
2015-12-15 04:39:41 +08:00
|
|
|
struct drm_gem_object *obj;
|
2014-05-25 18:45:39 +08:00
|
|
|
struct address_space *mapping;
|
staging: add omapdrm DRM/KMS driver for TI OMAP platforms
A DRM display driver for TI OMAP platform. Similar to omapfb (fbdev)
and omap_vout (v4l2 display) drivers in the past, this driver uses the
DSS2 driver to access the display hardware, including support for
HDMI, DVI, and various types of LCD panels. And it implements GEM
support for buffer allocation (for KMS as well as offscreen buffers
used by the xf86-video-omap userspace xorg driver).
The driver maps CRTCs to overlays, encoders to overlay-managers, and
connectors to dssdev's. Note that this arrangement might change slightly
when support for drm_plane overlays is added.
For GEM support, non-scanout buffers are using the shmem backed pages
provided by GEM core (In drm_gem_object_init()). In the case of scanout
buffers, which need to be physically contiguous, those are allocated
with CMA and use drm_gem_private_object_init().
See userspace xorg driver:
git://github.com/robclark/xf86-video-omap.git
Refer to this link for CMA (Continuous Memory Allocator):
http://lkml.org/lkml/2011/8/19/302
Links to previous versions of the patch:
v1: http://lwn.net/Articles/458137/
v2: http://patches.linaro.org/4156/
v3: http://patches.linaro.org/4688/
v4: http://patches.linaro.org/4791/
History:
v5: move headers from include/drm at Greg KH's request, minor rebasing
on 3.2-rc1, pull in private copies of drm_gem_{get,put}_pages()
because "drm/gem: add functions to get/put pages" patch is not
merged yet
v4: bit of rework of encoder/connector _dpms() code, modeset_init()
rework to not use nested functions, update TODO.txt
v3: minor cleanups, improved error handling for dev_load(), some minor
API changes that will be needed later for tiled buffer support
v2: replace omap_vram with CMA for scanout buffer allocation, remove
unneeded functions, use dma_addr_t for physical addresses, error
handling cleanup, refactor attach/detach pages into common drm
functions, split non-userspace-facing API into omap_priv.h, remove
plugin API
v1: original
Signed-off-by: Rob Clark <rob@ti.com>
Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-11-13 02:09:40 +08:00
|
|
|
size_t size;
|
|
|
|
int ret;
|
|
|
|
|
2015-12-15 04:39:43 +08:00
|
|
|
/* Validate the flags and compute the memory and cache flags. */
|
staging: add omapdrm DRM/KMS driver for TI OMAP platforms
A DRM display driver for TI OMAP platform. Similar to omapfb (fbdev)
and omap_vout (v4l2 display) drivers in the past, this driver uses the
DSS2 driver to access the display hardware, including support for
HDMI, DVI, and various types of LCD panels. And it implements GEM
support for buffer allocation (for KMS as well as offscreen buffers
used by the xf86-video-omap userspace xorg driver).
The driver maps CRTCs to overlays, encoders to overlay-managers, and
connectors to dssdev's. Note that this arrangement might change slightly
when support for drm_plane overlays is added.
For GEM support, non-scanout buffers are using the shmem backed pages
provided by GEM core (In drm_gem_object_init()). In the case of scanout
buffers, which need to be physically contiguous, those are allocated
with CMA and use drm_gem_private_object_init().
See userspace xorg driver:
git://github.com/robclark/xf86-video-omap.git
Refer to this link for CMA (Continuous Memory Allocator):
http://lkml.org/lkml/2011/8/19/302
Links to previous versions of the patch:
v1: http://lwn.net/Articles/458137/
v2: http://patches.linaro.org/4156/
v3: http://patches.linaro.org/4688/
v4: http://patches.linaro.org/4791/
History:
v5: move headers from include/drm at Greg KH's request, minor rebasing
on 3.2-rc1, pull in private copies of drm_gem_{get,put}_pages()
because "drm/gem: add functions to get/put pages" patch is not
merged yet
v4: bit of rework of encoder/connector _dpms() code, modeset_init()
rework to not use nested functions, update TODO.txt
v3: minor cleanups, improved error handling for dev_load(), some minor
API changes that will be needed later for tiled buffer support
v2: replace omap_vram with CMA for scanout buffer allocation, remove
unneeded functions, use dma_addr_t for physical addresses, error
handling cleanup, refactor attach/detach pages into common drm
functions, split non-userspace-facing API into omap_priv.h, remove
plugin API
v1: original
Signed-off-by: Rob Clark <rob@ti.com>
Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-11-13 02:09:40 +08:00
|
|
|
if (flags & OMAP_BO_TILED) {
|
2015-12-15 04:39:34 +08:00
|
|
|
if (!priv->usergart) {
|
2011-12-06 09:19:22 +08:00
|
|
|
dev_err(dev->dev, "Tiled buffers require DMM\n");
|
2015-12-15 04:39:41 +08:00
|
|
|
return NULL;
|
2011-12-06 09:19:22 +08:00
|
|
|
}
|
|
|
|
|
2015-12-15 04:39:43 +08:00
|
|
|
/*
|
|
|
|
* Tiled buffers are always shmem paged backed. When they are
|
|
|
|
* scanned out, they are remapped into DMM/TILER.
|
2011-12-06 09:19:22 +08:00
|
|
|
*/
|
|
|
|
flags &= ~OMAP_BO_SCANOUT;
|
2015-12-15 04:39:43 +08:00
|
|
|
flags |= OMAP_BO_MEM_SHMEM;
|
2011-12-06 09:19:22 +08:00
|
|
|
|
2015-12-15 04:39:43 +08:00
|
|
|
/*
|
|
|
|
* Currently don't allow cached buffers. There is some caching
|
|
|
|
* stuff that needs to be handled better.
|
2011-12-06 09:19:22 +08:00
|
|
|
*/
|
2014-09-26 03:24:29 +08:00
|
|
|
flags &= ~(OMAP_BO_CACHED|OMAP_BO_WC|OMAP_BO_UNCACHED);
|
|
|
|
flags |= tiler_get_cpu_cache_flags();
|
2015-12-15 04:39:43 +08:00
|
|
|
} else if ((flags & OMAP_BO_SCANOUT) && !priv->has_dmm) {
|
|
|
|
/*
|
2015-12-15 04:39:44 +08:00
|
|
|
* OMAP_BO_SCANOUT hints that the buffer doesn't need to be
|
|
|
|
* tiled. However, to lower the pressure on memory allocation,
|
|
|
|
* use contiguous memory only if no TILER is available.
|
2015-12-15 04:39:43 +08:00
|
|
|
*/
|
|
|
|
flags |= OMAP_BO_MEM_DMA_API;
|
2016-01-27 16:58:43 +08:00
|
|
|
} else if (!(flags & OMAP_BO_MEM_DMABUF)) {
|
2015-12-15 04:39:43 +08:00
|
|
|
/*
|
2016-01-27 16:58:43 +08:00
|
|
|
* All other buffers not backed by dma_buf are shmem-backed.
|
2015-12-15 04:39:43 +08:00
|
|
|
*/
|
|
|
|
flags |= OMAP_BO_MEM_SHMEM;
|
2011-12-06 09:19:22 +08:00
|
|
|
}
|
staging: add omapdrm DRM/KMS driver for TI OMAP platforms
A DRM display driver for TI OMAP platform. Similar to omapfb (fbdev)
and omap_vout (v4l2 display) drivers in the past, this driver uses the
DSS2 driver to access the display hardware, including support for
HDMI, DVI, and various types of LCD panels. And it implements GEM
support for buffer allocation (for KMS as well as offscreen buffers
used by the xf86-video-omap userspace xorg driver).
The driver maps CRTCs to overlays, encoders to overlay-managers, and
connectors to dssdev's. Note that this arrangement might change slightly
when support for drm_plane overlays is added.
For GEM support, non-scanout buffers are using the shmem backed pages
provided by GEM core (In drm_gem_object_init()). In the case of scanout
buffers, which need to be physically contiguous, those are allocated
with CMA and use drm_gem_private_object_init().
See userspace xorg driver:
git://github.com/robclark/xf86-video-omap.git
Refer to this link for CMA (Continuous Memory Allocator):
http://lkml.org/lkml/2011/8/19/302
Links to previous versions of the patch:
v1: http://lwn.net/Articles/458137/
v2: http://patches.linaro.org/4156/
v3: http://patches.linaro.org/4688/
v4: http://patches.linaro.org/4791/
History:
v5: move headers from include/drm at Greg KH's request, minor rebasing
on 3.2-rc1, pull in private copies of drm_gem_{get,put}_pages()
because "drm/gem: add functions to get/put pages" patch is not
merged yet
v4: bit of rework of encoder/connector _dpms() code, modeset_init()
rework to not use nested functions, update TODO.txt
v3: minor cleanups, improved error handling for dev_load(), some minor
API changes that will be needed later for tiled buffer support
v2: replace omap_vram with CMA for scanout buffer allocation, remove
unneeded functions, use dma_addr_t for physical addresses, error
handling cleanup, refactor attach/detach pages into common drm
functions, split non-userspace-facing API into omap_priv.h, remove
plugin API
v1: original
Signed-off-by: Rob Clark <rob@ti.com>
Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-11-13 02:09:40 +08:00
|
|
|
|
2015-12-15 04:39:43 +08:00
|
|
|
/* Allocate the initialize the OMAP GEM object. */
|
staging: add omapdrm DRM/KMS driver for TI OMAP platforms
A DRM display driver for TI OMAP platform. Similar to omapfb (fbdev)
and omap_vout (v4l2 display) drivers in the past, this driver uses the
DSS2 driver to access the display hardware, including support for
HDMI, DVI, and various types of LCD panels. And it implements GEM
support for buffer allocation (for KMS as well as offscreen buffers
used by the xf86-video-omap userspace xorg driver).
The driver maps CRTCs to overlays, encoders to overlay-managers, and
connectors to dssdev's. Note that this arrangement might change slightly
when support for drm_plane overlays is added.
For GEM support, non-scanout buffers are using the shmem backed pages
provided by GEM core (In drm_gem_object_init()). In the case of scanout
buffers, which need to be physically contiguous, those are allocated
with CMA and use drm_gem_private_object_init().
See userspace xorg driver:
git://github.com/robclark/xf86-video-omap.git
Refer to this link for CMA (Continuous Memory Allocator):
http://lkml.org/lkml/2011/8/19/302
Links to previous versions of the patch:
v1: http://lwn.net/Articles/458137/
v2: http://patches.linaro.org/4156/
v3: http://patches.linaro.org/4688/
v4: http://patches.linaro.org/4791/
History:
v5: move headers from include/drm at Greg KH's request, minor rebasing
on 3.2-rc1, pull in private copies of drm_gem_{get,put}_pages()
because "drm/gem: add functions to get/put pages" patch is not
merged yet
v4: bit of rework of encoder/connector _dpms() code, modeset_init()
rework to not use nested functions, update TODO.txt
v3: minor cleanups, improved error handling for dev_load(), some minor
API changes that will be needed later for tiled buffer support
v2: replace omap_vram with CMA for scanout buffer allocation, remove
unneeded functions, use dma_addr_t for physical addresses, error
handling cleanup, refactor attach/detach pages into common drm
functions, split non-userspace-facing API into omap_priv.h, remove
plugin API
v1: original
Signed-off-by: Rob Clark <rob@ti.com>
Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-11-13 02:09:40 +08:00
|
|
|
omap_obj = kzalloc(sizeof(*omap_obj), GFP_KERNEL);
|
2013-02-12 01:41:29 +08:00
|
|
|
if (!omap_obj)
|
2015-03-17 21:31:11 +08:00
|
|
|
return NULL;
|
2012-03-06 00:48:36 +08:00
|
|
|
|
staging: add omapdrm DRM/KMS driver for TI OMAP platforms
A DRM display driver for TI OMAP platform. Similar to omapfb (fbdev)
and omap_vout (v4l2 display) drivers in the past, this driver uses the
DSS2 driver to access the display hardware, including support for
HDMI, DVI, and various types of LCD panels. And it implements GEM
support for buffer allocation (for KMS as well as offscreen buffers
used by the xf86-video-omap userspace xorg driver).
The driver maps CRTCs to overlays, encoders to overlay-managers, and
connectors to dssdev's. Note that this arrangement might change slightly
when support for drm_plane overlays is added.
For GEM support, non-scanout buffers are using the shmem backed pages
provided by GEM core (In drm_gem_object_init()). In the case of scanout
buffers, which need to be physically contiguous, those are allocated
with CMA and use drm_gem_private_object_init().
See userspace xorg driver:
git://github.com/robclark/xf86-video-omap.git
Refer to this link for CMA (Continuous Memory Allocator):
http://lkml.org/lkml/2011/8/19/302
Links to previous versions of the patch:
v1: http://lwn.net/Articles/458137/
v2: http://patches.linaro.org/4156/
v3: http://patches.linaro.org/4688/
v4: http://patches.linaro.org/4791/
History:
v5: move headers from include/drm at Greg KH's request, minor rebasing
on 3.2-rc1, pull in private copies of drm_gem_{get,put}_pages()
because "drm/gem: add functions to get/put pages" patch is not
merged yet
v4: bit of rework of encoder/connector _dpms() code, modeset_init()
rework to not use nested functions, update TODO.txt
v3: minor cleanups, improved error handling for dev_load(), some minor
API changes that will be needed later for tiled buffer support
v2: replace omap_vram with CMA for scanout buffer allocation, remove
unneeded functions, use dma_addr_t for physical addresses, error
handling cleanup, refactor attach/detach pages into common drm
functions, split non-userspace-facing API into omap_priv.h, remove
plugin API
v1: original
Signed-off-by: Rob Clark <rob@ti.com>
Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-11-13 02:09:40 +08:00
|
|
|
obj = &omap_obj->base;
|
2015-12-15 04:39:43 +08:00
|
|
|
omap_obj->flags = flags;
|
2018-05-27 00:54:33 +08:00
|
|
|
mutex_init(&omap_obj->lock);
|
staging: add omapdrm DRM/KMS driver for TI OMAP platforms
A DRM display driver for TI OMAP platform. Similar to omapfb (fbdev)
and omap_vout (v4l2 display) drivers in the past, this driver uses the
DSS2 driver to access the display hardware, including support for
HDMI, DVI, and various types of LCD panels. And it implements GEM
support for buffer allocation (for KMS as well as offscreen buffers
used by the xf86-video-omap userspace xorg driver).
The driver maps CRTCs to overlays, encoders to overlay-managers, and
connectors to dssdev's. Note that this arrangement might change slightly
when support for drm_plane overlays is added.
For GEM support, non-scanout buffers are using the shmem backed pages
provided by GEM core (In drm_gem_object_init()). In the case of scanout
buffers, which need to be physically contiguous, those are allocated
with CMA and use drm_gem_private_object_init().
See userspace xorg driver:
git://github.com/robclark/xf86-video-omap.git
Refer to this link for CMA (Continuous Memory Allocator):
http://lkml.org/lkml/2011/8/19/302
Links to previous versions of the patch:
v1: http://lwn.net/Articles/458137/
v2: http://patches.linaro.org/4156/
v3: http://patches.linaro.org/4688/
v4: http://patches.linaro.org/4791/
History:
v5: move headers from include/drm at Greg KH's request, minor rebasing
on 3.2-rc1, pull in private copies of drm_gem_{get,put}_pages()
because "drm/gem: add functions to get/put pages" patch is not
merged yet
v4: bit of rework of encoder/connector _dpms() code, modeset_init()
rework to not use nested functions, update TODO.txt
v3: minor cleanups, improved error handling for dev_load(), some minor
API changes that will be needed later for tiled buffer support
v2: replace omap_vram with CMA for scanout buffer allocation, remove
unneeded functions, use dma_addr_t for physical addresses, error
handling cleanup, refactor attach/detach pages into common drm
functions, split non-userspace-facing API into omap_priv.h, remove
plugin API
v1: original
Signed-off-by: Rob Clark <rob@ti.com>
Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-11-13 02:09:40 +08:00
|
|
|
|
2015-12-15 04:39:43 +08:00
|
|
|
if (flags & OMAP_BO_TILED) {
|
|
|
|
/*
|
|
|
|
* For tiled buffers align dimensions to slot boundaries and
|
|
|
|
* calculate size based on aligned dimensions.
|
2011-12-10 13:26:08 +08:00
|
|
|
*/
|
2015-12-15 04:39:43 +08:00
|
|
|
tiler_align(gem2fmt(flags), &gsize.tiled.width,
|
|
|
|
&gsize.tiled.height);
|
2012-11-14 18:33:17 +08:00
|
|
|
|
2015-12-15 04:39:43 +08:00
|
|
|
size = tiler_size(gem2fmt(flags), gsize.tiled.width,
|
|
|
|
gsize.tiled.height);
|
staging: add omapdrm DRM/KMS driver for TI OMAP platforms
A DRM display driver for TI OMAP platform. Similar to omapfb (fbdev)
and omap_vout (v4l2 display) drivers in the past, this driver uses the
DSS2 driver to access the display hardware, including support for
HDMI, DVI, and various types of LCD panels. And it implements GEM
support for buffer allocation (for KMS as well as offscreen buffers
used by the xf86-video-omap userspace xorg driver).
The driver maps CRTCs to overlays, encoders to overlay-managers, and
connectors to dssdev's. Note that this arrangement might change slightly
when support for drm_plane overlays is added.
For GEM support, non-scanout buffers are using the shmem backed pages
provided by GEM core (In drm_gem_object_init()). In the case of scanout
buffers, which need to be physically contiguous, those are allocated
with CMA and use drm_gem_private_object_init().
See userspace xorg driver:
git://github.com/robclark/xf86-video-omap.git
Refer to this link for CMA (Continuous Memory Allocator):
http://lkml.org/lkml/2011/8/19/302
Links to previous versions of the patch:
v1: http://lwn.net/Articles/458137/
v2: http://patches.linaro.org/4156/
v3: http://patches.linaro.org/4688/
v4: http://patches.linaro.org/4791/
History:
v5: move headers from include/drm at Greg KH's request, minor rebasing
on 3.2-rc1, pull in private copies of drm_gem_{get,put}_pages()
because "drm/gem: add functions to get/put pages" patch is not
merged yet
v4: bit of rework of encoder/connector _dpms() code, modeset_init()
rework to not use nested functions, update TODO.txt
v3: minor cleanups, improved error handling for dev_load(), some minor
API changes that will be needed later for tiled buffer support
v2: replace omap_vram with CMA for scanout buffer allocation, remove
unneeded functions, use dma_addr_t for physical addresses, error
handling cleanup, refactor attach/detach pages into common drm
functions, split non-userspace-facing API into omap_priv.h, remove
plugin API
v1: original
Signed-off-by: Rob Clark <rob@ti.com>
Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-11-13 02:09:40 +08:00
|
|
|
|
2011-12-06 09:19:22 +08:00
|
|
|
omap_obj->width = gsize.tiled.width;
|
|
|
|
omap_obj->height = gsize.tiled.height;
|
2015-12-15 04:39:43 +08:00
|
|
|
} else {
|
|
|
|
size = PAGE_ALIGN(gsize.bytes);
|
2011-12-06 09:19:22 +08:00
|
|
|
}
|
|
|
|
|
2015-12-15 04:39:43 +08:00
|
|
|
/* Initialize the GEM object. */
|
|
|
|
if (!(flags & OMAP_BO_MEM_SHMEM)) {
|
2013-07-11 17:56:32 +08:00
|
|
|
drm_gem_private_object_init(dev, obj, size);
|
2014-05-25 18:45:39 +08:00
|
|
|
} else {
|
staging: add omapdrm DRM/KMS driver for TI OMAP platforms
A DRM display driver for TI OMAP platform. Similar to omapfb (fbdev)
and omap_vout (v4l2 display) drivers in the past, this driver uses the
DSS2 driver to access the display hardware, including support for
HDMI, DVI, and various types of LCD panels. And it implements GEM
support for buffer allocation (for KMS as well as offscreen buffers
used by the xf86-video-omap userspace xorg driver).
The driver maps CRTCs to overlays, encoders to overlay-managers, and
connectors to dssdev's. Note that this arrangement might change slightly
when support for drm_plane overlays is added.
For GEM support, non-scanout buffers are using the shmem backed pages
provided by GEM core (In drm_gem_object_init()). In the case of scanout
buffers, which need to be physically contiguous, those are allocated
with CMA and use drm_gem_private_object_init().
See userspace xorg driver:
git://github.com/robclark/xf86-video-omap.git
Refer to this link for CMA (Continuous Memory Allocator):
http://lkml.org/lkml/2011/8/19/302
Links to previous versions of the patch:
v1: http://lwn.net/Articles/458137/
v2: http://patches.linaro.org/4156/
v3: http://patches.linaro.org/4688/
v4: http://patches.linaro.org/4791/
History:
v5: move headers from include/drm at Greg KH's request, minor rebasing
on 3.2-rc1, pull in private copies of drm_gem_{get,put}_pages()
because "drm/gem: add functions to get/put pages" patch is not
merged yet
v4: bit of rework of encoder/connector _dpms() code, modeset_init()
rework to not use nested functions, update TODO.txt
v3: minor cleanups, improved error handling for dev_load(), some minor
API changes that will be needed later for tiled buffer support
v2: replace omap_vram with CMA for scanout buffer allocation, remove
unneeded functions, use dma_addr_t for physical addresses, error
handling cleanup, refactor attach/detach pages into common drm
functions, split non-userspace-facing API into omap_priv.h, remove
plugin API
v1: original
Signed-off-by: Rob Clark <rob@ti.com>
Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-11-13 02:09:40 +08:00
|
|
|
ret = drm_gem_object_init(dev, obj, size);
|
2014-05-25 18:45:39 +08:00
|
|
|
if (ret)
|
2016-03-02 18:51:19 +08:00
|
|
|
goto err_free;
|
staging: add omapdrm DRM/KMS driver for TI OMAP platforms
A DRM display driver for TI OMAP platform. Similar to omapfb (fbdev)
and omap_vout (v4l2 display) drivers in the past, this driver uses the
DSS2 driver to access the display hardware, including support for
HDMI, DVI, and various types of LCD panels. And it implements GEM
support for buffer allocation (for KMS as well as offscreen buffers
used by the xf86-video-omap userspace xorg driver).
The driver maps CRTCs to overlays, encoders to overlay-managers, and
connectors to dssdev's. Note that this arrangement might change slightly
when support for drm_plane overlays is added.
For GEM support, non-scanout buffers are using the shmem backed pages
provided by GEM core (In drm_gem_object_init()). In the case of scanout
buffers, which need to be physically contiguous, those are allocated
with CMA and use drm_gem_private_object_init().
See userspace xorg driver:
git://github.com/robclark/xf86-video-omap.git
Refer to this link for CMA (Continuous Memory Allocator):
http://lkml.org/lkml/2011/8/19/302
Links to previous versions of the patch:
v1: http://lwn.net/Articles/458137/
v2: http://patches.linaro.org/4156/
v3: http://patches.linaro.org/4688/
v4: http://patches.linaro.org/4791/
History:
v5: move headers from include/drm at Greg KH's request, minor rebasing
on 3.2-rc1, pull in private copies of drm_gem_{get,put}_pages()
because "drm/gem: add functions to get/put pages" patch is not
merged yet
v4: bit of rework of encoder/connector _dpms() code, modeset_init()
rework to not use nested functions, update TODO.txt
v3: minor cleanups, improved error handling for dev_load(), some minor
API changes that will be needed later for tiled buffer support
v2: replace omap_vram with CMA for scanout buffer allocation, remove
unneeded functions, use dma_addr_t for physical addresses, error
handling cleanup, refactor attach/detach pages into common drm
functions, split non-userspace-facing API into omap_priv.h, remove
plugin API
v1: original
Signed-off-by: Rob Clark <rob@ti.com>
Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-11-13 02:09:40 +08:00
|
|
|
|
2015-12-05 12:45:44 +08:00
|
|
|
mapping = obj->filp->f_mapping;
|
2014-05-25 18:45:39 +08:00
|
|
|
mapping_set_gfp_mask(mapping, GFP_USER | __GFP_DMA32);
|
|
|
|
}
|
staging: add omapdrm DRM/KMS driver for TI OMAP platforms
A DRM display driver for TI OMAP platform. Similar to omapfb (fbdev)
and omap_vout (v4l2 display) drivers in the past, this driver uses the
DSS2 driver to access the display hardware, including support for
HDMI, DVI, and various types of LCD panels. And it implements GEM
support for buffer allocation (for KMS as well as offscreen buffers
used by the xf86-video-omap userspace xorg driver).
The driver maps CRTCs to overlays, encoders to overlay-managers, and
connectors to dssdev's. Note that this arrangement might change slightly
when support for drm_plane overlays is added.
For GEM support, non-scanout buffers are using the shmem backed pages
provided by GEM core (In drm_gem_object_init()). In the case of scanout
buffers, which need to be physically contiguous, those are allocated
with CMA and use drm_gem_private_object_init().
See userspace xorg driver:
git://github.com/robclark/xf86-video-omap.git
Refer to this link for CMA (Continuous Memory Allocator):
http://lkml.org/lkml/2011/8/19/302
Links to previous versions of the patch:
v1: http://lwn.net/Articles/458137/
v2: http://patches.linaro.org/4156/
v3: http://patches.linaro.org/4688/
v4: http://patches.linaro.org/4791/
History:
v5: move headers from include/drm at Greg KH's request, minor rebasing
on 3.2-rc1, pull in private copies of drm_gem_{get,put}_pages()
because "drm/gem: add functions to get/put pages" patch is not
merged yet
v4: bit of rework of encoder/connector _dpms() code, modeset_init()
rework to not use nested functions, update TODO.txt
v3: minor cleanups, improved error handling for dev_load(), some minor
API changes that will be needed later for tiled buffer support
v2: replace omap_vram with CMA for scanout buffer allocation, remove
unneeded functions, use dma_addr_t for physical addresses, error
handling cleanup, refactor attach/detach pages into common drm
functions, split non-userspace-facing API into omap_priv.h, remove
plugin API
v1: original
Signed-off-by: Rob Clark <rob@ti.com>
Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-11-13 02:09:40 +08:00
|
|
|
|
2016-03-02 18:51:19 +08:00
|
|
|
/* Allocate memory if needed. */
|
|
|
|
if (flags & OMAP_BO_MEM_DMA_API) {
|
2016-03-22 04:48:00 +08:00
|
|
|
omap_obj->vaddr = dma_alloc_wc(dev->dev, size,
|
2017-04-21 05:33:51 +08:00
|
|
|
&omap_obj->dma_addr,
|
2016-03-22 04:48:00 +08:00
|
|
|
GFP_KERNEL);
|
2016-03-02 18:51:19 +08:00
|
|
|
if (!omap_obj->vaddr)
|
|
|
|
goto err_release;
|
|
|
|
}
|
|
|
|
|
2018-05-26 00:39:24 +08:00
|
|
|
mutex_lock(&priv->list_lock);
|
2016-03-02 18:51:19 +08:00
|
|
|
list_add(&omap_obj->mm_list, &priv->obj_list);
|
2018-05-26 00:39:24 +08:00
|
|
|
mutex_unlock(&priv->list_lock);
|
2016-03-02 18:51:19 +08:00
|
|
|
|
staging: add omapdrm DRM/KMS driver for TI OMAP platforms
A DRM display driver for TI OMAP platform. Similar to omapfb (fbdev)
and omap_vout (v4l2 display) drivers in the past, this driver uses the
DSS2 driver to access the display hardware, including support for
HDMI, DVI, and various types of LCD panels. And it implements GEM
support for buffer allocation (for KMS as well as offscreen buffers
used by the xf86-video-omap userspace xorg driver).
The driver maps CRTCs to overlays, encoders to overlay-managers, and
connectors to dssdev's. Note that this arrangement might change slightly
when support for drm_plane overlays is added.
For GEM support, non-scanout buffers are using the shmem backed pages
provided by GEM core (In drm_gem_object_init()). In the case of scanout
buffers, which need to be physically contiguous, those are allocated
with CMA and use drm_gem_private_object_init().
See userspace xorg driver:
git://github.com/robclark/xf86-video-omap.git
Refer to this link for CMA (Continuous Memory Allocator):
http://lkml.org/lkml/2011/8/19/302
Links to previous versions of the patch:
v1: http://lwn.net/Articles/458137/
v2: http://patches.linaro.org/4156/
v3: http://patches.linaro.org/4688/
v4: http://patches.linaro.org/4791/
History:
v5: move headers from include/drm at Greg KH's request, minor rebasing
on 3.2-rc1, pull in private copies of drm_gem_{get,put}_pages()
because "drm/gem: add functions to get/put pages" patch is not
merged yet
v4: bit of rework of encoder/connector _dpms() code, modeset_init()
rework to not use nested functions, update TODO.txt
v3: minor cleanups, improved error handling for dev_load(), some minor
API changes that will be needed later for tiled buffer support
v2: replace omap_vram with CMA for scanout buffer allocation, remove
unneeded functions, use dma_addr_t for physical addresses, error
handling cleanup, refactor attach/detach pages into common drm
functions, split non-userspace-facing API into omap_priv.h, remove
plugin API
v1: original
Signed-off-by: Rob Clark <rob@ti.com>
Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-11-13 02:09:40 +08:00
|
|
|
return obj;
|
|
|
|
|
2016-03-02 18:51:19 +08:00
|
|
|
err_release:
|
|
|
|
drm_gem_object_release(obj);
|
|
|
|
err_free:
|
|
|
|
kfree(omap_obj);
|
staging: add omapdrm DRM/KMS driver for TI OMAP platforms
A DRM display driver for TI OMAP platform. Similar to omapfb (fbdev)
and omap_vout (v4l2 display) drivers in the past, this driver uses the
DSS2 driver to access the display hardware, including support for
HDMI, DVI, and various types of LCD panels. And it implements GEM
support for buffer allocation (for KMS as well as offscreen buffers
used by the xf86-video-omap userspace xorg driver).
The driver maps CRTCs to overlays, encoders to overlay-managers, and
connectors to dssdev's. Note that this arrangement might change slightly
when support for drm_plane overlays is added.
For GEM support, non-scanout buffers are using the shmem backed pages
provided by GEM core (In drm_gem_object_init()). In the case of scanout
buffers, which need to be physically contiguous, those are allocated
with CMA and use drm_gem_private_object_init().
See userspace xorg driver:
git://github.com/robclark/xf86-video-omap.git
Refer to this link for CMA (Continuous Memory Allocator):
http://lkml.org/lkml/2011/8/19/302
Links to previous versions of the patch:
v1: http://lwn.net/Articles/458137/
v2: http://patches.linaro.org/4156/
v3: http://patches.linaro.org/4688/
v4: http://patches.linaro.org/4791/
History:
v5: move headers from include/drm at Greg KH's request, minor rebasing
on 3.2-rc1, pull in private copies of drm_gem_{get,put}_pages()
because "drm/gem: add functions to get/put pages" patch is not
merged yet
v4: bit of rework of encoder/connector _dpms() code, modeset_init()
rework to not use nested functions, update TODO.txt
v3: minor cleanups, improved error handling for dev_load(), some minor
API changes that will be needed later for tiled buffer support
v2: replace omap_vram with CMA for scanout buffer allocation, remove
unneeded functions, use dma_addr_t for physical addresses, error
handling cleanup, refactor attach/detach pages into common drm
functions, split non-userspace-facing API into omap_priv.h, remove
plugin API
v1: original
Signed-off-by: Rob Clark <rob@ti.com>
Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-11-13 02:09:40 +08:00
|
|
|
return NULL;
|
|
|
|
}
|
2011-12-06 09:19:22 +08:00
|
|
|
|
2015-12-15 04:39:44 +08:00
|
|
|
struct drm_gem_object *omap_gem_new_dmabuf(struct drm_device *dev, size_t size,
|
|
|
|
struct sg_table *sgt)
|
|
|
|
{
|
|
|
|
struct omap_drm_private *priv = dev->dev_private;
|
|
|
|
struct omap_gem_object *omap_obj;
|
|
|
|
struct drm_gem_object *obj;
|
|
|
|
union omap_gem_size gsize;
|
|
|
|
|
|
|
|
/* Without a DMM only physically contiguous buffers can be supported. */
|
|
|
|
if (sgt->orig_nents != 1 && !priv->has_dmm)
|
|
|
|
return ERR_PTR(-EINVAL);
|
|
|
|
|
|
|
|
gsize.bytes = PAGE_ALIGN(size);
|
|
|
|
obj = omap_gem_new(dev, gsize, OMAP_BO_MEM_DMABUF | OMAP_BO_WC);
|
2018-05-27 00:54:33 +08:00
|
|
|
if (!obj)
|
|
|
|
return ERR_PTR(-ENOMEM);
|
2015-12-15 04:39:44 +08:00
|
|
|
|
|
|
|
omap_obj = to_omap_bo(obj);
|
2018-05-27 00:54:33 +08:00
|
|
|
|
|
|
|
mutex_lock(&omap_obj->lock);
|
|
|
|
|
2015-12-15 04:39:44 +08:00
|
|
|
omap_obj->sgt = sgt;
|
|
|
|
|
|
|
|
if (sgt->orig_nents == 1) {
|
2017-04-21 05:33:51 +08:00
|
|
|
omap_obj->dma_addr = sg_dma_address(sgt->sgl);
|
2015-12-15 04:39:44 +08:00
|
|
|
} else {
|
|
|
|
/* Create pages list from sgt */
|
|
|
|
struct sg_page_iter iter;
|
|
|
|
struct page **pages;
|
|
|
|
unsigned int npages;
|
|
|
|
unsigned int i = 0;
|
|
|
|
|
|
|
|
npages = DIV_ROUND_UP(size, PAGE_SIZE);
|
|
|
|
pages = kcalloc(npages, sizeof(*pages), GFP_KERNEL);
|
|
|
|
if (!pages) {
|
|
|
|
omap_gem_free_object(obj);
|
|
|
|
obj = ERR_PTR(-ENOMEM);
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
|
|
|
|
omap_obj->pages = pages;
|
|
|
|
|
|
|
|
for_each_sg_page(sgt->sgl, &iter, sgt->orig_nents, 0) {
|
|
|
|
pages[i++] = sg_page_iter_page(&iter);
|
|
|
|
if (i > npages)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (WARN_ON(i != npages)) {
|
|
|
|
omap_gem_free_object(obj);
|
|
|
|
obj = ERR_PTR(-ENOMEM);
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
done:
|
2018-05-27 00:54:33 +08:00
|
|
|
mutex_unlock(&omap_obj->lock);
|
2015-12-15 04:39:44 +08:00
|
|
|
return obj;
|
|
|
|
}
|
|
|
|
|
2015-12-15 04:39:33 +08:00
|
|
|
/* convenience method to construct a GEM buffer object, and userspace handle */
|
|
|
|
int omap_gem_new_handle(struct drm_device *dev, struct drm_file *file,
|
2018-02-11 21:07:33 +08:00
|
|
|
union omap_gem_size gsize, u32 flags, u32 *handle)
|
2015-12-15 04:39:33 +08:00
|
|
|
{
|
|
|
|
struct drm_gem_object *obj;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
obj = omap_gem_new(dev, gsize, flags);
|
|
|
|
if (!obj)
|
|
|
|
return -ENOMEM;
|
|
|
|
|
|
|
|
ret = drm_gem_handle_create(file, obj, handle);
|
|
|
|
if (ret) {
|
staging: add omapdrm DRM/KMS driver for TI OMAP platforms
A DRM display driver for TI OMAP platform. Similar to omapfb (fbdev)
and omap_vout (v4l2 display) drivers in the past, this driver uses the
DSS2 driver to access the display hardware, including support for
HDMI, DVI, and various types of LCD panels. And it implements GEM
support for buffer allocation (for KMS as well as offscreen buffers
used by the xf86-video-omap userspace xorg driver).
The driver maps CRTCs to overlays, encoders to overlay-managers, and
connectors to dssdev's. Note that this arrangement might change slightly
when support for drm_plane overlays is added.
For GEM support, non-scanout buffers are using the shmem backed pages
provided by GEM core (In drm_gem_object_init()). In the case of scanout
buffers, which need to be physically contiguous, those are allocated
with CMA and use drm_gem_private_object_init().
See userspace xorg driver:
git://github.com/robclark/xf86-video-omap.git
Refer to this link for CMA (Continuous Memory Allocator):
http://lkml.org/lkml/2011/8/19/302
Links to previous versions of the patch:
v1: http://lwn.net/Articles/458137/
v2: http://patches.linaro.org/4156/
v3: http://patches.linaro.org/4688/
v4: http://patches.linaro.org/4791/
History:
v5: move headers from include/drm at Greg KH's request, minor rebasing
on 3.2-rc1, pull in private copies of drm_gem_{get,put}_pages()
because "drm/gem: add functions to get/put pages" patch is not
merged yet
v4: bit of rework of encoder/connector _dpms() code, modeset_init()
rework to not use nested functions, update TODO.txt
v3: minor cleanups, improved error handling for dev_load(), some minor
API changes that will be needed later for tiled buffer support
v2: replace omap_vram with CMA for scanout buffer allocation, remove
unneeded functions, use dma_addr_t for physical addresses, error
handling cleanup, refactor attach/detach pages into common drm
functions, split non-userspace-facing API into omap_priv.h, remove
plugin API
v1: original
Signed-off-by: Rob Clark <rob@ti.com>
Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-11-13 02:09:40 +08:00
|
|
|
omap_gem_free_object(obj);
|
2015-12-15 04:39:33 +08:00
|
|
|
return ret;
|
|
|
|
}
|
2012-11-14 18:33:17 +08:00
|
|
|
|
2015-12-15 04:39:33 +08:00
|
|
|
/* drop reference from allocate - handle holds it now */
|
|
|
|
drm_gem_object_unreference_unlocked(obj);
|
|
|
|
|
|
|
|
return 0;
|
staging: add omapdrm DRM/KMS driver for TI OMAP platforms
A DRM display driver for TI OMAP platform. Similar to omapfb (fbdev)
and omap_vout (v4l2 display) drivers in the past, this driver uses the
DSS2 driver to access the display hardware, including support for
HDMI, DVI, and various types of LCD panels. And it implements GEM
support for buffer allocation (for KMS as well as offscreen buffers
used by the xf86-video-omap userspace xorg driver).
The driver maps CRTCs to overlays, encoders to overlay-managers, and
connectors to dssdev's. Note that this arrangement might change slightly
when support for drm_plane overlays is added.
For GEM support, non-scanout buffers are using the shmem backed pages
provided by GEM core (In drm_gem_object_init()). In the case of scanout
buffers, which need to be physically contiguous, those are allocated
with CMA and use drm_gem_private_object_init().
See userspace xorg driver:
git://github.com/robclark/xf86-video-omap.git
Refer to this link for CMA (Continuous Memory Allocator):
http://lkml.org/lkml/2011/8/19/302
Links to previous versions of the patch:
v1: http://lwn.net/Articles/458137/
v2: http://patches.linaro.org/4156/
v3: http://patches.linaro.org/4688/
v4: http://patches.linaro.org/4791/
History:
v5: move headers from include/drm at Greg KH's request, minor rebasing
on 3.2-rc1, pull in private copies of drm_gem_{get,put}_pages()
because "drm/gem: add functions to get/put pages" patch is not
merged yet
v4: bit of rework of encoder/connector _dpms() code, modeset_init()
rework to not use nested functions, update TODO.txt
v3: minor cleanups, improved error handling for dev_load(), some minor
API changes that will be needed later for tiled buffer support
v2: replace omap_vram with CMA for scanout buffer allocation, remove
unneeded functions, use dma_addr_t for physical addresses, error
handling cleanup, refactor attach/detach pages into common drm
functions, split non-userspace-facing API into omap_priv.h, remove
plugin API
v1: original
Signed-off-by: Rob Clark <rob@ti.com>
Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-11-13 02:09:40 +08:00
|
|
|
}
|
2011-12-06 09:19:22 +08:00
|
|
|
|
2015-12-15 04:39:33 +08:00
|
|
|
/* -----------------------------------------------------------------------------
|
|
|
|
* Init & Cleanup
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* If DMM is used, we need to set some stuff up.. */
|
2011-12-06 09:19:22 +08:00
|
|
|
void omap_gem_init(struct drm_device *dev)
|
|
|
|
{
|
2011-12-10 13:26:08 +08:00
|
|
|
struct omap_drm_private *priv = dev->dev_private;
|
2015-12-15 04:39:34 +08:00
|
|
|
struct omap_drm_usergart *usergart;
|
2011-12-06 09:19:22 +08:00
|
|
|
const enum tiler_fmt fmts[] = {
|
|
|
|
TILFMT_8BIT, TILFMT_16BIT, TILFMT_32BIT
|
|
|
|
};
|
2012-03-06 00:48:39 +08:00
|
|
|
int i, j;
|
2011-12-06 09:19:22 +08:00
|
|
|
|
2012-10-17 13:30:03 +08:00
|
|
|
if (!dmm_is_available()) {
|
2011-12-06 09:19:22 +08:00
|
|
|
/* DMM only supported on OMAP4 and later, so this isn't fatal */
|
2012-03-06 00:48:39 +08:00
|
|
|
dev_warn(dev->dev, "DMM not available, disable DMM support\n");
|
2011-12-06 09:19:22 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-02-12 01:41:29 +08:00
|
|
|
usergart = kcalloc(3, sizeof(*usergart), GFP_KERNEL);
|
|
|
|
if (!usergart)
|
2011-12-10 13:26:06 +08:00
|
|
|
return;
|
2011-12-06 09:19:22 +08:00
|
|
|
|
|
|
|
/* reserve 4k aligned/wide regions for userspace mappings: */
|
|
|
|
for (i = 0; i < ARRAY_SIZE(fmts); i++) {
|
2018-02-11 21:07:33 +08:00
|
|
|
u16 h = 1, w = PAGE_SIZE >> i;
|
|
|
|
|
2011-12-06 09:19:22 +08:00
|
|
|
tiler_align(fmts[i], &w, &h);
|
|
|
|
/* note: since each region is 1 4kb page wide, and minimum
|
|
|
|
* number of rows, the height ends up being the same as the
|
|
|
|
* # of pages in the region
|
|
|
|
*/
|
|
|
|
usergart[i].height = h;
|
|
|
|
usergart[i].height_shift = ilog2(h);
|
2012-08-16 04:18:01 +08:00
|
|
|
usergart[i].stride_pfn = tiler_stride(fmts[i], 0) >> PAGE_SHIFT;
|
2011-12-06 09:19:22 +08:00
|
|
|
usergart[i].slot_shift = ilog2((PAGE_SIZE / h) >> i);
|
|
|
|
for (j = 0; j < NUM_USERGART_ENTRIES; j++) {
|
2015-12-15 04:39:34 +08:00
|
|
|
struct omap_drm_usergart_entry *entry;
|
|
|
|
struct tiler_block *block;
|
|
|
|
|
|
|
|
entry = &usergart[i].entry[j];
|
|
|
|
block = tiler_reserve_2d(fmts[i], w, h, PAGE_SIZE);
|
2011-12-06 09:19:22 +08:00
|
|
|
if (IS_ERR(block)) {
|
|
|
|
dev_err(dev->dev,
|
|
|
|
"reserve failed: %d, %d, %ld\n",
|
|
|
|
i, j, PTR_ERR(block));
|
|
|
|
return;
|
|
|
|
}
|
2017-04-21 05:33:51 +08:00
|
|
|
entry->dma_addr = tiler_ssptr(block);
|
2011-12-06 09:19:22 +08:00
|
|
|
entry->block = block;
|
|
|
|
|
2017-04-21 05:33:51 +08:00
|
|
|
DBG("%d:%d: %dx%d: dma_addr=%pad stride=%d", i, j, w, h,
|
|
|
|
&entry->dma_addr,
|
2011-12-06 09:19:22 +08:00
|
|
|
usergart[i].stride_pfn << PAGE_SHIFT);
|
|
|
|
}
|
|
|
|
}
|
2011-12-10 13:26:08 +08:00
|
|
|
|
2015-12-15 04:39:34 +08:00
|
|
|
priv->usergart = usergart;
|
2011-12-10 13:26:08 +08:00
|
|
|
priv->has_dmm = true;
|
2011-12-06 09:19:22 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void omap_gem_deinit(struct drm_device *dev)
|
|
|
|
{
|
2015-12-15 04:39:34 +08:00
|
|
|
struct omap_drm_private *priv = dev->dev_private;
|
|
|
|
|
2011-12-06 09:19:22 +08:00
|
|
|
/* I believe we can rely on there being no more outstanding GEM
|
|
|
|
* objects which could depend on usergart/dmm at this point.
|
|
|
|
*/
|
2015-12-15 04:39:34 +08:00
|
|
|
kfree(priv->usergart);
|
2011-12-06 09:19:22 +08:00
|
|
|
}
|