2019-05-27 14:55:01 +08:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
2011-10-04 18:19:01 +08:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2011 Samsung Electronics Co., Ltd.
|
|
|
|
* Authors:
|
|
|
|
* Inki Dae <inki.dae@samsung.com>
|
|
|
|
* Joonyoung Shim <jy0922.shim@samsung.com>
|
|
|
|
* Seung-Woo Kim <sw0312.kim@samsung.com>
|
|
|
|
*/
|
|
|
|
|
2019-06-24 21:06:28 +08:00
|
|
|
#include <linux/component.h>
|
2019-08-21 19:28:43 +08:00
|
|
|
#include <linux/dma-mapping.h>
|
|
|
|
#include <linux/platform_device.h>
|
2014-01-31 05:19:27 +08:00
|
|
|
#include <linux/pm_runtime.h>
|
2019-08-21 19:28:43 +08:00
|
|
|
#include <linux/uaccess.h>
|
2019-06-24 21:06:28 +08:00
|
|
|
|
2015-08-16 00:26:17 +08:00
|
|
|
#include <drm/drm_atomic.h>
|
|
|
|
#include <drm/drm_atomic_helper.h>
|
2019-08-21 19:28:43 +08:00
|
|
|
#include <drm/drm_drv.h>
|
2017-12-06 02:24:57 +08:00
|
|
|
#include <drm/drm_fb_helper.h>
|
2019-08-21 19:28:43 +08:00
|
|
|
#include <drm/drm_file.h>
|
|
|
|
#include <drm/drm_fourcc.h>
|
|
|
|
#include <drm/drm_ioctl.h>
|
2019-01-18 05:03:34 +08:00
|
|
|
#include <drm/drm_probe_helper.h>
|
2019-08-21 19:28:43 +08:00
|
|
|
#include <drm/drm_vblank.h>
|
2011-10-04 18:19:01 +08:00
|
|
|
#include <drm/exynos_drm.h>
|
|
|
|
|
|
|
|
#include "exynos_drm_drv.h"
|
|
|
|
#include "exynos_drm_fb.h"
|
2019-06-24 21:06:28 +08:00
|
|
|
#include "exynos_drm_fbdev.h"
|
|
|
|
#include "exynos_drm_g2d.h"
|
2011-10-04 18:19:01 +08:00
|
|
|
#include "exynos_drm_gem.h"
|
drm/exynos: ipp: Add IPP v2 framework
This patch adds Exynos IPP v2 subsystem and userspace API.
New userspace API is focused ONLY on memory-to-memory image processing.
The two remainging operation modes of obsolete IPP v1 API (framebuffer
writeback and local-path output with image processing) can be implemented
using standard DRM features: writeback connectors and additional DRM planes
with scaling features.
V2 IPP userspace API is based on stateless approach, which much better fits
to memory-to-memory image processing model. It also provides support for
all image formats, which are both already defined in DRM API and supported
by the existing IPP hardware modules.
The API consists of the following ioctls:
- DRM_IOCTL_EXYNOS_IPP_GET_RESOURCES: to enumerate all available image
processing modules,
- DRM_IOCTL_EXYNOS_IPP_GET_CAPS: to query capabilities and supported image
formats of given IPP module,
- DRM_IOCTL_EXYNOS_IPP_GET_LIMITS: to query hardware limitiations for
selected image format of given IPP module,
- DRM_IOCTL_EXYNOS_IPP_COMMIT: to perform operation described by the
provided structures (source and destination buffers, operation rectangle,
transformation, etc).
The proposed userspace API is extensible. In the future more advanced image
processing operations can be defined to support for example blending.
Userspace API is fully functional also on DRM render nodes, so it is not
limited to the root/privileged client.
Internal driver API also has been completely rewritten. New IPP core
performs all possible input validation, checks and object life-time
control. The drivers can focus only on writing configuration to hardware
registers. Stateless nature of DRM_IOCTL_EXYNOS_IPP_COMMIT ioctl simplifies
the driver API. Minimal driver needs to provide a single callback for
starting processing and an array with supported image formats.
Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
Tested-by: Hoegeun Kwon <hoegeun.kwon@samsung.com>
Merge conflict so merged manually.
Signed-off-by: Inki Dae <inki.dae@samsung.com>
2018-05-10 07:46:36 +08:00
|
|
|
#include "exynos_drm_ipp.h"
|
2019-06-24 21:06:28 +08:00
|
|
|
#include "exynos_drm_plane.h"
|
2012-03-21 09:55:26 +08:00
|
|
|
#include "exynos_drm_vidi.h"
|
2011-10-04 18:19:01 +08:00
|
|
|
|
2011-12-15 16:31:24 +08:00
|
|
|
#define DRIVER_NAME "exynos"
|
2011-10-04 18:19:01 +08:00
|
|
|
#define DRIVER_DESC "Samsung SoC DRM"
|
drm/exynos: ipp: Add IPP v2 framework
This patch adds Exynos IPP v2 subsystem and userspace API.
New userspace API is focused ONLY on memory-to-memory image processing.
The two remainging operation modes of obsolete IPP v1 API (framebuffer
writeback and local-path output with image processing) can be implemented
using standard DRM features: writeback connectors and additional DRM planes
with scaling features.
V2 IPP userspace API is based on stateless approach, which much better fits
to memory-to-memory image processing model. It also provides support for
all image formats, which are both already defined in DRM API and supported
by the existing IPP hardware modules.
The API consists of the following ioctls:
- DRM_IOCTL_EXYNOS_IPP_GET_RESOURCES: to enumerate all available image
processing modules,
- DRM_IOCTL_EXYNOS_IPP_GET_CAPS: to query capabilities and supported image
formats of given IPP module,
- DRM_IOCTL_EXYNOS_IPP_GET_LIMITS: to query hardware limitiations for
selected image format of given IPP module,
- DRM_IOCTL_EXYNOS_IPP_COMMIT: to perform operation described by the
provided structures (source and destination buffers, operation rectangle,
transformation, etc).
The proposed userspace API is extensible. In the future more advanced image
processing operations can be defined to support for example blending.
Userspace API is fully functional also on DRM render nodes, so it is not
limited to the root/privileged client.
Internal driver API also has been completely rewritten. New IPP core
performs all possible input validation, checks and object life-time
control. The drivers can focus only on writing configuration to hardware
registers. Stateless nature of DRM_IOCTL_EXYNOS_IPP_COMMIT ioctl simplifies
the driver API. Minimal driver needs to provide a single callback for
starting processing and an array with supported image formats.
Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
Tested-by: Hoegeun Kwon <hoegeun.kwon@samsung.com>
Merge conflict so merged manually.
Signed-off-by: Inki Dae <inki.dae@samsung.com>
2018-05-10 07:46:36 +08:00
|
|
|
#define DRIVER_DATE "20180330"
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Interface history:
|
|
|
|
*
|
|
|
|
* 1.0 - Original version
|
|
|
|
* 1.1 - Upgrade IPP driver to version 2.0
|
|
|
|
*/
|
2011-10-04 18:19:01 +08:00
|
|
|
#define DRIVER_MAJOR 1
|
drm/exynos: ipp: Add IPP v2 framework
This patch adds Exynos IPP v2 subsystem and userspace API.
New userspace API is focused ONLY on memory-to-memory image processing.
The two remainging operation modes of obsolete IPP v1 API (framebuffer
writeback and local-path output with image processing) can be implemented
using standard DRM features: writeback connectors and additional DRM planes
with scaling features.
V2 IPP userspace API is based on stateless approach, which much better fits
to memory-to-memory image processing model. It also provides support for
all image formats, which are both already defined in DRM API and supported
by the existing IPP hardware modules.
The API consists of the following ioctls:
- DRM_IOCTL_EXYNOS_IPP_GET_RESOURCES: to enumerate all available image
processing modules,
- DRM_IOCTL_EXYNOS_IPP_GET_CAPS: to query capabilities and supported image
formats of given IPP module,
- DRM_IOCTL_EXYNOS_IPP_GET_LIMITS: to query hardware limitiations for
selected image format of given IPP module,
- DRM_IOCTL_EXYNOS_IPP_COMMIT: to perform operation described by the
provided structures (source and destination buffers, operation rectangle,
transformation, etc).
The proposed userspace API is extensible. In the future more advanced image
processing operations can be defined to support for example blending.
Userspace API is fully functional also on DRM render nodes, so it is not
limited to the root/privileged client.
Internal driver API also has been completely rewritten. New IPP core
performs all possible input validation, checks and object life-time
control. The drivers can focus only on writing configuration to hardware
registers. Stateless nature of DRM_IOCTL_EXYNOS_IPP_COMMIT ioctl simplifies
the driver API. Minimal driver needs to provide a single callback for
starting processing and an array with supported image formats.
Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
Tested-by: Hoegeun Kwon <hoegeun.kwon@samsung.com>
Merge conflict so merged manually.
Signed-off-by: Inki Dae <inki.dae@samsung.com>
2018-05-10 07:46:36 +08:00
|
|
|
#define DRIVER_MINOR 1
|
2011-10-04 18:19:01 +08:00
|
|
|
|
2012-03-16 17:47:09 +08:00
|
|
|
static int exynos_drm_open(struct drm_device *dev, struct drm_file *file)
|
|
|
|
{
|
2012-05-17 19:06:32 +08:00
|
|
|
struct drm_exynos_file_private *file_priv;
|
2013-07-01 16:00:47 +08:00
|
|
|
int ret;
|
2012-05-17 19:06:32 +08:00
|
|
|
|
|
|
|
file_priv = kzalloc(sizeof(*file_priv), GFP_KERNEL);
|
|
|
|
if (!file_priv)
|
|
|
|
return -ENOMEM;
|
|
|
|
|
|
|
|
file->driver_priv = file_priv;
|
2018-07-09 21:44:30 +08:00
|
|
|
ret = g2d_open(dev, file);
|
2014-01-16 14:01:26 +08:00
|
|
|
if (ret)
|
2014-03-17 11:28:06 +08:00
|
|
|
goto err_file_priv_free;
|
2013-07-01 16:00:47 +08:00
|
|
|
|
2014-01-16 14:01:26 +08:00
|
|
|
return ret;
|
2014-03-17 11:28:06 +08:00
|
|
|
|
|
|
|
err_file_priv_free:
|
2014-01-16 14:01:26 +08:00
|
|
|
kfree(file_priv);
|
|
|
|
file->driver_priv = NULL;
|
2013-07-01 16:00:47 +08:00
|
|
|
return ret;
|
2012-03-16 17:47:09 +08:00
|
|
|
}
|
|
|
|
|
2013-10-01 13:51:37 +08:00
|
|
|
static void exynos_drm_postclose(struct drm_device *dev, struct drm_file *file)
|
2011-10-14 12:29:51 +08:00
|
|
|
{
|
2018-07-09 21:44:30 +08:00
|
|
|
g2d_close(dev, file);
|
2012-02-15 10:25:22 +08:00
|
|
|
kfree(file->driver_priv);
|
|
|
|
file->driver_priv = NULL;
|
|
|
|
}
|
|
|
|
|
2012-05-17 19:27:22 +08:00
|
|
|
static const struct vm_operations_struct exynos_drm_gem_vm_ops = {
|
2011-10-04 18:19:01 +08:00
|
|
|
.fault = exynos_drm_gem_fault,
|
|
|
|
.open = drm_gem_vm_open,
|
|
|
|
.close = drm_gem_vm_close,
|
|
|
|
};
|
|
|
|
|
2013-08-03 01:27:49 +08:00
|
|
|
static const struct drm_ioctl_desc exynos_ioctls[] = {
|
2011-10-04 18:19:01 +08:00
|
|
|
DRM_IOCTL_DEF_DRV(EXYNOS_GEM_CREATE, exynos_drm_gem_create_ioctl,
|
2019-05-27 16:17:32 +08:00
|
|
|
DRM_RENDER_ALLOW),
|
2016-03-08 13:12:59 +08:00
|
|
|
DRM_IOCTL_DEF_DRV(EXYNOS_GEM_MAP, exynos_drm_gem_map_ioctl,
|
2019-05-27 16:17:32 +08:00
|
|
|
DRM_RENDER_ALLOW),
|
2015-08-30 23:45:56 +08:00
|
|
|
DRM_IOCTL_DEF_DRV(EXYNOS_GEM_GET, exynos_drm_gem_get_ioctl,
|
2015-09-08 19:56:30 +08:00
|
|
|
DRM_RENDER_ALLOW),
|
2015-08-30 23:45:56 +08:00
|
|
|
DRM_IOCTL_DEF_DRV(EXYNOS_VIDI_CONNECTION, vidi_connection_ioctl,
|
2015-09-08 19:56:30 +08:00
|
|
|
DRM_AUTH),
|
2015-08-30 23:45:56 +08:00
|
|
|
DRM_IOCTL_DEF_DRV(EXYNOS_G2D_GET_VER, exynos_g2d_get_ver_ioctl,
|
2019-05-27 16:17:32 +08:00
|
|
|
DRM_RENDER_ALLOW),
|
2015-08-30 23:45:56 +08:00
|
|
|
DRM_IOCTL_DEF_DRV(EXYNOS_G2D_SET_CMDLIST, exynos_g2d_set_cmdlist_ioctl,
|
2019-05-27 16:17:32 +08:00
|
|
|
DRM_RENDER_ALLOW),
|
2015-08-30 23:45:56 +08:00
|
|
|
DRM_IOCTL_DEF_DRV(EXYNOS_G2D_EXEC, exynos_g2d_exec_ioctl,
|
2019-05-27 16:17:32 +08:00
|
|
|
DRM_RENDER_ALLOW),
|
drm/exynos: ipp: Add IPP v2 framework
This patch adds Exynos IPP v2 subsystem and userspace API.
New userspace API is focused ONLY on memory-to-memory image processing.
The two remainging operation modes of obsolete IPP v1 API (framebuffer
writeback and local-path output with image processing) can be implemented
using standard DRM features: writeback connectors and additional DRM planes
with scaling features.
V2 IPP userspace API is based on stateless approach, which much better fits
to memory-to-memory image processing model. It also provides support for
all image formats, which are both already defined in DRM API and supported
by the existing IPP hardware modules.
The API consists of the following ioctls:
- DRM_IOCTL_EXYNOS_IPP_GET_RESOURCES: to enumerate all available image
processing modules,
- DRM_IOCTL_EXYNOS_IPP_GET_CAPS: to query capabilities and supported image
formats of given IPP module,
- DRM_IOCTL_EXYNOS_IPP_GET_LIMITS: to query hardware limitiations for
selected image format of given IPP module,
- DRM_IOCTL_EXYNOS_IPP_COMMIT: to perform operation described by the
provided structures (source and destination buffers, operation rectangle,
transformation, etc).
The proposed userspace API is extensible. In the future more advanced image
processing operations can be defined to support for example blending.
Userspace API is fully functional also on DRM render nodes, so it is not
limited to the root/privileged client.
Internal driver API also has been completely rewritten. New IPP core
performs all possible input validation, checks and object life-time
control. The drivers can focus only on writing configuration to hardware
registers. Stateless nature of DRM_IOCTL_EXYNOS_IPP_COMMIT ioctl simplifies
the driver API. Minimal driver needs to provide a single callback for
starting processing and an array with supported image formats.
Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
Tested-by: Hoegeun Kwon <hoegeun.kwon@samsung.com>
Merge conflict so merged manually.
Signed-off-by: Inki Dae <inki.dae@samsung.com>
2018-05-10 07:46:36 +08:00
|
|
|
DRM_IOCTL_DEF_DRV(EXYNOS_IPP_GET_RESOURCES,
|
|
|
|
exynos_drm_ipp_get_res_ioctl,
|
2019-05-27 16:17:32 +08:00
|
|
|
DRM_RENDER_ALLOW),
|
drm/exynos: ipp: Add IPP v2 framework
This patch adds Exynos IPP v2 subsystem and userspace API.
New userspace API is focused ONLY on memory-to-memory image processing.
The two remainging operation modes of obsolete IPP v1 API (framebuffer
writeback and local-path output with image processing) can be implemented
using standard DRM features: writeback connectors and additional DRM planes
with scaling features.
V2 IPP userspace API is based on stateless approach, which much better fits
to memory-to-memory image processing model. It also provides support for
all image formats, which are both already defined in DRM API and supported
by the existing IPP hardware modules.
The API consists of the following ioctls:
- DRM_IOCTL_EXYNOS_IPP_GET_RESOURCES: to enumerate all available image
processing modules,
- DRM_IOCTL_EXYNOS_IPP_GET_CAPS: to query capabilities and supported image
formats of given IPP module,
- DRM_IOCTL_EXYNOS_IPP_GET_LIMITS: to query hardware limitiations for
selected image format of given IPP module,
- DRM_IOCTL_EXYNOS_IPP_COMMIT: to perform operation described by the
provided structures (source and destination buffers, operation rectangle,
transformation, etc).
The proposed userspace API is extensible. In the future more advanced image
processing operations can be defined to support for example blending.
Userspace API is fully functional also on DRM render nodes, so it is not
limited to the root/privileged client.
Internal driver API also has been completely rewritten. New IPP core
performs all possible input validation, checks and object life-time
control. The drivers can focus only on writing configuration to hardware
registers. Stateless nature of DRM_IOCTL_EXYNOS_IPP_COMMIT ioctl simplifies
the driver API. Minimal driver needs to provide a single callback for
starting processing and an array with supported image formats.
Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
Tested-by: Hoegeun Kwon <hoegeun.kwon@samsung.com>
Merge conflict so merged manually.
Signed-off-by: Inki Dae <inki.dae@samsung.com>
2018-05-10 07:46:36 +08:00
|
|
|
DRM_IOCTL_DEF_DRV(EXYNOS_IPP_GET_CAPS, exynos_drm_ipp_get_caps_ioctl,
|
2019-05-27 16:17:32 +08:00
|
|
|
DRM_RENDER_ALLOW),
|
drm/exynos: ipp: Add IPP v2 framework
This patch adds Exynos IPP v2 subsystem and userspace API.
New userspace API is focused ONLY on memory-to-memory image processing.
The two remainging operation modes of obsolete IPP v1 API (framebuffer
writeback and local-path output with image processing) can be implemented
using standard DRM features: writeback connectors and additional DRM planes
with scaling features.
V2 IPP userspace API is based on stateless approach, which much better fits
to memory-to-memory image processing model. It also provides support for
all image formats, which are both already defined in DRM API and supported
by the existing IPP hardware modules.
The API consists of the following ioctls:
- DRM_IOCTL_EXYNOS_IPP_GET_RESOURCES: to enumerate all available image
processing modules,
- DRM_IOCTL_EXYNOS_IPP_GET_CAPS: to query capabilities and supported image
formats of given IPP module,
- DRM_IOCTL_EXYNOS_IPP_GET_LIMITS: to query hardware limitiations for
selected image format of given IPP module,
- DRM_IOCTL_EXYNOS_IPP_COMMIT: to perform operation described by the
provided structures (source and destination buffers, operation rectangle,
transformation, etc).
The proposed userspace API is extensible. In the future more advanced image
processing operations can be defined to support for example blending.
Userspace API is fully functional also on DRM render nodes, so it is not
limited to the root/privileged client.
Internal driver API also has been completely rewritten. New IPP core
performs all possible input validation, checks and object life-time
control. The drivers can focus only on writing configuration to hardware
registers. Stateless nature of DRM_IOCTL_EXYNOS_IPP_COMMIT ioctl simplifies
the driver API. Minimal driver needs to provide a single callback for
starting processing and an array with supported image formats.
Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
Tested-by: Hoegeun Kwon <hoegeun.kwon@samsung.com>
Merge conflict so merged manually.
Signed-off-by: Inki Dae <inki.dae@samsung.com>
2018-05-10 07:46:36 +08:00
|
|
|
DRM_IOCTL_DEF_DRV(EXYNOS_IPP_GET_LIMITS,
|
|
|
|
exynos_drm_ipp_get_limits_ioctl,
|
2019-05-27 16:17:32 +08:00
|
|
|
DRM_RENDER_ALLOW),
|
drm/exynos: ipp: Add IPP v2 framework
This patch adds Exynos IPP v2 subsystem and userspace API.
New userspace API is focused ONLY on memory-to-memory image processing.
The two remainging operation modes of obsolete IPP v1 API (framebuffer
writeback and local-path output with image processing) can be implemented
using standard DRM features: writeback connectors and additional DRM planes
with scaling features.
V2 IPP userspace API is based on stateless approach, which much better fits
to memory-to-memory image processing model. It also provides support for
all image formats, which are both already defined in DRM API and supported
by the existing IPP hardware modules.
The API consists of the following ioctls:
- DRM_IOCTL_EXYNOS_IPP_GET_RESOURCES: to enumerate all available image
processing modules,
- DRM_IOCTL_EXYNOS_IPP_GET_CAPS: to query capabilities and supported image
formats of given IPP module,
- DRM_IOCTL_EXYNOS_IPP_GET_LIMITS: to query hardware limitiations for
selected image format of given IPP module,
- DRM_IOCTL_EXYNOS_IPP_COMMIT: to perform operation described by the
provided structures (source and destination buffers, operation rectangle,
transformation, etc).
The proposed userspace API is extensible. In the future more advanced image
processing operations can be defined to support for example blending.
Userspace API is fully functional also on DRM render nodes, so it is not
limited to the root/privileged client.
Internal driver API also has been completely rewritten. New IPP core
performs all possible input validation, checks and object life-time
control. The drivers can focus only on writing configuration to hardware
registers. Stateless nature of DRM_IOCTL_EXYNOS_IPP_COMMIT ioctl simplifies
the driver API. Minimal driver needs to provide a single callback for
starting processing and an array with supported image formats.
Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
Tested-by: Hoegeun Kwon <hoegeun.kwon@samsung.com>
Merge conflict so merged manually.
Signed-off-by: Inki Dae <inki.dae@samsung.com>
2018-05-10 07:46:36 +08:00
|
|
|
DRM_IOCTL_DEF_DRV(EXYNOS_IPP_COMMIT, exynos_drm_ipp_commit_ioctl,
|
2019-05-27 16:17:32 +08:00
|
|
|
DRM_RENDER_ALLOW),
|
2011-10-04 18:19:01 +08:00
|
|
|
};
|
|
|
|
|
2011-12-08 14:00:20 +08:00
|
|
|
static const struct file_operations exynos_drm_driver_fops = {
|
|
|
|
.owner = THIS_MODULE,
|
|
|
|
.open = drm_open,
|
|
|
|
.mmap = exynos_drm_gem_mmap,
|
|
|
|
.poll = drm_poll,
|
|
|
|
.read = drm_read,
|
|
|
|
.unlocked_ioctl = drm_ioctl,
|
2012-07-10 06:40:07 +08:00
|
|
|
.compat_ioctl = drm_compat_ioctl,
|
2011-12-08 14:00:20 +08:00
|
|
|
.release = drm_release,
|
|
|
|
};
|
|
|
|
|
2011-10-04 18:19:01 +08:00
|
|
|
static struct drm_driver exynos_drm_driver = {
|
2019-06-17 23:39:24 +08:00
|
|
|
.driver_features = DRIVER_MODESET | DRIVER_GEM
|
2015-08-30 23:45:56 +08:00
|
|
|
| DRIVER_ATOMIC | DRIVER_RENDER,
|
2012-03-16 17:47:09 +08:00
|
|
|
.open = exynos_drm_open,
|
2017-12-06 02:24:57 +08:00
|
|
|
.lastclose = drm_fb_helper_lastclose,
|
2012-02-15 10:25:22 +08:00
|
|
|
.postclose = exynos_drm_postclose,
|
2016-04-27 01:29:50 +08:00
|
|
|
.gem_free_object_unlocked = exynos_drm_gem_free_object,
|
2011-10-04 18:19:01 +08:00
|
|
|
.gem_vm_ops = &exynos_drm_gem_vm_ops,
|
|
|
|
.dumb_create = exynos_drm_gem_dumb_create,
|
2012-04-23 20:01:28 +08:00
|
|
|
.prime_handle_to_fd = drm_gem_prime_handle_to_fd,
|
|
|
|
.prime_fd_to_handle = drm_gem_prime_fd_to_handle,
|
2017-10-30 15:28:09 +08:00
|
|
|
.gem_prime_import = exynos_drm_gem_prime_import,
|
2015-08-16 13:33:08 +08:00
|
|
|
.gem_prime_get_sg_table = exynos_drm_gem_prime_get_sg_table,
|
|
|
|
.gem_prime_import_sg_table = exynos_drm_gem_prime_import_sg_table,
|
|
|
|
.gem_prime_vmap = exynos_drm_gem_prime_vmap,
|
|
|
|
.gem_prime_vunmap = exynos_drm_gem_prime_vunmap,
|
2016-04-22 15:30:47 +08:00
|
|
|
.gem_prime_mmap = exynos_drm_gem_prime_mmap,
|
2011-10-04 18:19:01 +08:00
|
|
|
.ioctls = exynos_ioctls,
|
2013-08-03 01:27:49 +08:00
|
|
|
.num_ioctls = ARRAY_SIZE(exynos_ioctls),
|
2011-12-08 14:00:20 +08:00
|
|
|
.fops = &exynos_drm_driver_fops,
|
2011-10-04 18:19:01 +08:00
|
|
|
.name = DRIVER_NAME,
|
|
|
|
.desc = DRIVER_DESC,
|
|
|
|
.date = DRIVER_DATE,
|
|
|
|
.major = DRIVER_MAJOR,
|
|
|
|
.minor = DRIVER_MINOR,
|
|
|
|
};
|
|
|
|
|
2015-11-27 22:32:45 +08:00
|
|
|
static int exynos_drm_suspend(struct device *dev)
|
2014-01-31 05:19:27 +08:00
|
|
|
{
|
|
|
|
struct drm_device *drm_dev = dev_get_drvdata(dev);
|
|
|
|
|
2018-08-02 23:45:17 +08:00
|
|
|
return drm_mode_config_helper_suspend(drm_dev);
|
2014-01-31 05:19:27 +08:00
|
|
|
}
|
|
|
|
|
drm/exynos: Suspend/resume display pipeline as early/late as possible
In the current code, exynos_drm_suspend() function is called after all
real devices (CRTCs, Encoders, etc) are suspended, because Exynos DRM
virtual platform device is created as last device in the system (as
a part of DRM registration). None of the devices for real hardware
modules has its own system suspend/resume callbacks, so it doesn't
change any order of the executed code, but it has a side-effect:
runtime PM callbacks for real devices are not executed, because those
devices are considered by PM core as already suspended. This might
cause issues on boards with complex pipelines, where something
depends on the runtime PM state of the given device.
To ensure that exynos_drm_suspend() is called before any suspend
callback from the real devices, assign it to .prepare callback. Same
for exynos_drm_resume(), using .complete callback ensures that all
real devices have been resumed when calling it.
Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
Signed-off-by: Inki Dae <inki.dae@samsung.com>
2018-06-11 20:24:59 +08:00
|
|
|
static void exynos_drm_resume(struct device *dev)
|
2014-01-31 05:19:27 +08:00
|
|
|
{
|
|
|
|
struct drm_device *drm_dev = dev_get_drvdata(dev);
|
|
|
|
|
2018-08-02 23:45:17 +08:00
|
|
|
drm_mode_config_helper_resume(drm_dev);
|
2014-01-31 05:19:27 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static const struct dev_pm_ops exynos_drm_pm_ops = {
|
drm/exynos: Suspend/resume display pipeline as early/late as possible
In the current code, exynos_drm_suspend() function is called after all
real devices (CRTCs, Encoders, etc) are suspended, because Exynos DRM
virtual platform device is created as last device in the system (as
a part of DRM registration). None of the devices for real hardware
modules has its own system suspend/resume callbacks, so it doesn't
change any order of the executed code, but it has a side-effect:
runtime PM callbacks for real devices are not executed, because those
devices are considered by PM core as already suspended. This might
cause issues on boards with complex pipelines, where something
depends on the runtime PM state of the given device.
To ensure that exynos_drm_suspend() is called before any suspend
callback from the real devices, assign it to .prepare callback. Same
for exynos_drm_resume(), using .complete callback ensures that all
real devices have been resumed when calling it.
Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
Signed-off-by: Inki Dae <inki.dae@samsung.com>
2018-06-11 20:24:59 +08:00
|
|
|
.prepare = exynos_drm_suspend,
|
|
|
|
.complete = exynos_drm_resume,
|
2014-01-31 05:19:27 +08:00
|
|
|
};
|
|
|
|
|
2015-06-11 22:23:37 +08:00
|
|
|
/* forward declaration */
|
|
|
|
static struct platform_driver exynos_drm_platform_driver;
|
2014-05-09 13:25:20 +08:00
|
|
|
|
2016-02-18 21:34:16 +08:00
|
|
|
struct exynos_drm_driver_info {
|
|
|
|
struct platform_driver *driver;
|
|
|
|
unsigned int flags;
|
|
|
|
};
|
|
|
|
|
|
|
|
#define DRM_COMPONENT_DRIVER BIT(0) /* supports component framework */
|
|
|
|
#define DRM_VIRTUAL_DEVICE BIT(1) /* create virtual platform device */
|
2018-10-12 18:53:41 +08:00
|
|
|
#define DRM_FIMC_DEVICE BIT(2) /* devices shared with V4L2 subsystem */
|
2016-02-18 21:34:16 +08:00
|
|
|
|
|
|
|
#define DRV_PTR(drv, cond) (IS_ENABLED(cond) ? &drv : NULL)
|
|
|
|
|
2015-06-11 22:23:37 +08:00
|
|
|
/*
|
|
|
|
* Connector drivers should not be placed before associated crtc drivers,
|
|
|
|
* because connector requires pipe number of its crtc during initialization.
|
|
|
|
*/
|
2016-02-18 21:34:16 +08:00
|
|
|
static struct exynos_drm_driver_info exynos_drm_drivers[] = {
|
|
|
|
{
|
|
|
|
DRV_PTR(fimd_driver, CONFIG_DRM_EXYNOS_FIMD),
|
2018-10-12 18:53:41 +08:00
|
|
|
DRM_COMPONENT_DRIVER
|
2016-02-18 21:34:16 +08:00
|
|
|
}, {
|
|
|
|
DRV_PTR(exynos5433_decon_driver, CONFIG_DRM_EXYNOS5433_DECON),
|
2018-10-12 18:53:41 +08:00
|
|
|
DRM_COMPONENT_DRIVER
|
2016-02-18 21:34:16 +08:00
|
|
|
}, {
|
|
|
|
DRV_PTR(decon_driver, CONFIG_DRM_EXYNOS7_DECON),
|
2018-10-12 18:53:41 +08:00
|
|
|
DRM_COMPONENT_DRIVER
|
2016-02-18 21:34:16 +08:00
|
|
|
}, {
|
|
|
|
DRV_PTR(mixer_driver, CONFIG_DRM_EXYNOS_MIXER),
|
2018-10-12 18:53:41 +08:00
|
|
|
DRM_COMPONENT_DRIVER
|
2016-02-18 21:34:16 +08:00
|
|
|
}, {
|
|
|
|
DRV_PTR(mic_driver, CONFIG_DRM_EXYNOS_MIC),
|
|
|
|
DRM_COMPONENT_DRIVER
|
|
|
|
}, {
|
|
|
|
DRV_PTR(dp_driver, CONFIG_DRM_EXYNOS_DP),
|
|
|
|
DRM_COMPONENT_DRIVER
|
|
|
|
}, {
|
|
|
|
DRV_PTR(dsi_driver, CONFIG_DRM_EXYNOS_DSI),
|
|
|
|
DRM_COMPONENT_DRIVER
|
|
|
|
}, {
|
|
|
|
DRV_PTR(hdmi_driver, CONFIG_DRM_EXYNOS_HDMI),
|
|
|
|
DRM_COMPONENT_DRIVER
|
|
|
|
}, {
|
|
|
|
DRV_PTR(vidi_driver, CONFIG_DRM_EXYNOS_VIDI),
|
|
|
|
DRM_COMPONENT_DRIVER | DRM_VIRTUAL_DEVICE
|
|
|
|
}, {
|
|
|
|
DRV_PTR(g2d_driver, CONFIG_DRM_EXYNOS_G2D),
|
2018-07-09 21:44:30 +08:00
|
|
|
DRM_COMPONENT_DRIVER
|
2016-02-18 21:34:16 +08:00
|
|
|
}, {
|
|
|
|
DRV_PTR(fimc_driver, CONFIG_DRM_EXYNOS_FIMC),
|
2018-05-10 07:52:12 +08:00
|
|
|
DRM_COMPONENT_DRIVER | DRM_FIMC_DEVICE,
|
2016-02-18 21:34:16 +08:00
|
|
|
}, {
|
|
|
|
DRV_PTR(rotator_driver, CONFIG_DRM_EXYNOS_ROTATOR),
|
2018-05-09 16:59:23 +08:00
|
|
|
DRM_COMPONENT_DRIVER
|
2018-05-09 16:59:26 +08:00
|
|
|
}, {
|
|
|
|
DRV_PTR(scaler_driver, CONFIG_DRM_EXYNOS_SCALER),
|
|
|
|
DRM_COMPONENT_DRIVER
|
2016-02-18 21:34:16 +08:00
|
|
|
}, {
|
|
|
|
DRV_PTR(gsc_driver, CONFIG_DRM_EXYNOS_GSC),
|
2018-05-09 16:59:24 +08:00
|
|
|
DRM_COMPONENT_DRIVER
|
2016-02-18 21:34:16 +08:00
|
|
|
}, {
|
|
|
|
&exynos_drm_platform_driver,
|
|
|
|
DRM_VIRTUAL_DEVICE
|
|
|
|
}
|
2015-06-11 22:23:37 +08:00
|
|
|
};
|
2014-05-09 13:25:20 +08:00
|
|
|
|
2014-09-11 16:04:03 +08:00
|
|
|
static int compare_dev(struct device *dev, void *data)
|
2014-05-09 13:25:20 +08:00
|
|
|
{
|
|
|
|
return dev == (struct device *)data;
|
|
|
|
}
|
|
|
|
|
2014-09-11 16:04:03 +08:00
|
|
|
static struct component_match *exynos_drm_match_add(struct device *dev)
|
2014-05-09 13:25:20 +08:00
|
|
|
{
|
2014-09-11 16:04:03 +08:00
|
|
|
struct component_match *match = NULL;
|
2015-06-11 22:23:37 +08:00
|
|
|
int i;
|
2014-05-09 13:25:20 +08:00
|
|
|
|
2016-02-18 21:34:16 +08:00
|
|
|
for (i = 0; i < ARRAY_SIZE(exynos_drm_drivers); ++i) {
|
|
|
|
struct exynos_drm_driver_info *info = &exynos_drm_drivers[i];
|
2015-06-11 22:23:37 +08:00
|
|
|
struct device *p = NULL, *d;
|
2014-11-06 22:00:37 +08:00
|
|
|
|
2016-02-18 21:34:16 +08:00
|
|
|
if (!info->driver || !(info->flags & DRM_COMPONENT_DRIVER))
|
|
|
|
continue;
|
|
|
|
|
2019-07-24 06:18:38 +08:00
|
|
|
while ((d = platform_find_device_by_driver(p, &info->driver->driver))) {
|
2015-06-11 22:23:37 +08:00
|
|
|
put_device(p);
|
2018-05-10 07:52:12 +08:00
|
|
|
|
|
|
|
if (!(info->flags & DRM_FIMC_DEVICE) ||
|
|
|
|
exynos_drm_check_fimc_device(d) == 0)
|
|
|
|
component_match_add(dev, &match,
|
|
|
|
compare_dev, d);
|
2015-06-11 22:23:37 +08:00
|
|
|
p = d;
|
2014-05-29 17:28:02 +08:00
|
|
|
}
|
2015-06-11 22:23:37 +08:00
|
|
|
put_device(p);
|
2014-05-09 13:25:20 +08:00
|
|
|
}
|
|
|
|
|
2015-06-11 22:23:37 +08:00
|
|
|
return match ?: ERR_PTR(-ENODEV);
|
2014-05-09 13:25:20 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static int exynos_drm_bind(struct device *dev)
|
|
|
|
{
|
2016-12-12 17:28:47 +08:00
|
|
|
struct exynos_drm_private *private;
|
|
|
|
struct drm_encoder *encoder;
|
|
|
|
struct drm_device *drm;
|
|
|
|
unsigned int clone_mask;
|
|
|
|
int cnt, ret;
|
|
|
|
|
|
|
|
drm = drm_dev_alloc(&exynos_drm_driver, dev);
|
|
|
|
if (IS_ERR(drm))
|
|
|
|
return PTR_ERR(drm);
|
|
|
|
|
|
|
|
private = kzalloc(sizeof(struct exynos_drm_private), GFP_KERNEL);
|
|
|
|
if (!private) {
|
|
|
|
ret = -ENOMEM;
|
|
|
|
goto err_free_drm;
|
|
|
|
}
|
|
|
|
|
|
|
|
init_waitqueue_head(&private->wait);
|
|
|
|
spin_lock_init(&private->lock);
|
|
|
|
|
|
|
|
dev_set_drvdata(dev, drm);
|
|
|
|
drm->dev_private = (void *)private;
|
|
|
|
|
|
|
|
drm_mode_config_init(drm);
|
|
|
|
|
|
|
|
exynos_drm_mode_config_init(drm);
|
|
|
|
|
|
|
|
/* setup possible_clones. */
|
|
|
|
cnt = 0;
|
|
|
|
clone_mask = 0;
|
|
|
|
list_for_each_entry(encoder, &drm->mode_config.encoder_list, head)
|
|
|
|
clone_mask |= (1 << (cnt++));
|
|
|
|
|
|
|
|
list_for_each_entry(encoder, &drm->mode_config.encoder_list, head)
|
|
|
|
encoder->possible_clones = clone_mask;
|
|
|
|
|
|
|
|
/* Try to bind all sub drivers. */
|
|
|
|
ret = component_bind_all(drm->dev, drm);
|
|
|
|
if (ret)
|
|
|
|
goto err_mode_config_cleanup;
|
|
|
|
|
|
|
|
ret = drm_vblank_init(drm, drm->mode_config.num_crtc);
|
|
|
|
if (ret)
|
|
|
|
goto err_unbind_all;
|
|
|
|
|
|
|
|
drm_mode_config_reset(drm);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* enable drm irq mode.
|
|
|
|
* - with irq_enabled = true, we can use the vblank feature.
|
|
|
|
*
|
|
|
|
* P.S. note that we wouldn't use drm irq handler but
|
|
|
|
* just specific driver own one instead because
|
|
|
|
* drm framework supports only one irq handler.
|
|
|
|
*/
|
|
|
|
drm->irq_enabled = true;
|
|
|
|
|
|
|
|
/* init kms poll for handling hpd */
|
|
|
|
drm_kms_helper_poll_init(drm);
|
|
|
|
|
2017-07-06 21:00:22 +08:00
|
|
|
ret = exynos_drm_fbdev_init(drm);
|
|
|
|
if (ret)
|
|
|
|
goto err_cleanup_poll;
|
2016-12-12 17:28:47 +08:00
|
|
|
|
|
|
|
/* register the DRM device */
|
|
|
|
ret = drm_dev_register(drm, 0);
|
|
|
|
if (ret < 0)
|
|
|
|
goto err_cleanup_fbdev;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
err_cleanup_fbdev:
|
|
|
|
exynos_drm_fbdev_fini(drm);
|
2017-07-06 21:00:22 +08:00
|
|
|
err_cleanup_poll:
|
2016-12-12 17:28:47 +08:00
|
|
|
drm_kms_helper_poll_fini(drm);
|
|
|
|
err_unbind_all:
|
|
|
|
component_unbind_all(drm->dev, drm);
|
|
|
|
err_mode_config_cleanup:
|
|
|
|
drm_mode_config_cleanup(drm);
|
2018-10-12 18:53:43 +08:00
|
|
|
exynos_drm_cleanup_dma(drm);
|
2016-12-12 17:28:47 +08:00
|
|
|
kfree(private);
|
|
|
|
err_free_drm:
|
2018-06-18 21:17:39 +08:00
|
|
|
drm_dev_put(drm);
|
2016-12-12 17:28:47 +08:00
|
|
|
|
|
|
|
return ret;
|
2014-05-09 13:25:20 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void exynos_drm_unbind(struct device *dev)
|
|
|
|
{
|
2016-12-12 17:28:47 +08:00
|
|
|
struct drm_device *drm = dev_get_drvdata(dev);
|
|
|
|
|
|
|
|
drm_dev_unregister(drm);
|
|
|
|
|
|
|
|
exynos_drm_fbdev_fini(drm);
|
|
|
|
drm_kms_helper_poll_fini(drm);
|
|
|
|
|
|
|
|
component_unbind_all(drm->dev, drm);
|
|
|
|
drm_mode_config_cleanup(drm);
|
2018-10-12 18:53:43 +08:00
|
|
|
exynos_drm_cleanup_dma(drm);
|
2016-12-12 17:28:47 +08:00
|
|
|
|
|
|
|
kfree(drm->dev_private);
|
|
|
|
drm->dev_private = NULL;
|
2017-10-09 16:44:01 +08:00
|
|
|
dev_set_drvdata(dev, NULL);
|
2016-12-12 17:28:47 +08:00
|
|
|
|
2018-06-18 21:17:39 +08:00
|
|
|
drm_dev_put(drm);
|
2014-05-09 13:25:20 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static const struct component_master_ops exynos_drm_ops = {
|
|
|
|
.bind = exynos_drm_bind,
|
|
|
|
.unbind = exynos_drm_unbind,
|
2011-10-04 18:19:01 +08:00
|
|
|
};
|
|
|
|
|
2015-06-11 22:20:52 +08:00
|
|
|
static int exynos_drm_platform_probe(struct platform_device *pdev)
|
|
|
|
{
|
|
|
|
struct component_match *match;
|
|
|
|
|
|
|
|
pdev->dev.coherent_dma_mask = DMA_BIT_MASK(32);
|
|
|
|
|
|
|
|
match = exynos_drm_match_add(&pdev->dev);
|
|
|
|
if (IS_ERR(match))
|
|
|
|
return PTR_ERR(match);
|
|
|
|
|
|
|
|
return component_master_add_with_match(&pdev->dev, &exynos_drm_ops,
|
|
|
|
match);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int exynos_drm_platform_remove(struct platform_device *pdev)
|
|
|
|
{
|
|
|
|
component_master_del(&pdev->dev, &exynos_drm_ops);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct platform_driver exynos_drm_platform_driver = {
|
|
|
|
.probe = exynos_drm_platform_probe,
|
|
|
|
.remove = exynos_drm_platform_remove,
|
|
|
|
.driver = {
|
|
|
|
.name = "exynos-drm",
|
|
|
|
.pm = &exynos_drm_pm_ops,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
static void exynos_drm_unregister_devices(void)
|
2014-11-13 15:37:57 +08:00
|
|
|
{
|
2016-02-18 21:34:16 +08:00
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = ARRAY_SIZE(exynos_drm_drivers) - 1; i >= 0; --i) {
|
|
|
|
struct exynos_drm_driver_info *info = &exynos_drm_drivers[i];
|
|
|
|
struct device *dev;
|
2014-03-17 18:27:17 +08:00
|
|
|
|
2016-02-18 21:34:16 +08:00
|
|
|
if (!info->driver || !(info->flags & DRM_VIRTUAL_DEVICE))
|
|
|
|
continue;
|
|
|
|
|
2019-07-24 06:18:38 +08:00
|
|
|
while ((dev = platform_find_device_by_driver(NULL,
|
|
|
|
&info->driver->driver))) {
|
2016-02-18 21:34:16 +08:00
|
|
|
put_device(dev);
|
|
|
|
platform_device_unregister(to_platform_device(dev));
|
|
|
|
}
|
2015-06-11 22:20:52 +08:00
|
|
|
}
|
|
|
|
}
|
2014-04-04 00:19:56 +08:00
|
|
|
|
2015-06-11 22:20:52 +08:00
|
|
|
static int exynos_drm_register_devices(void)
|
|
|
|
{
|
2016-02-18 21:34:16 +08:00
|
|
|
struct platform_device *pdev;
|
2015-06-11 22:20:52 +08:00
|
|
|
int i;
|
|
|
|
|
2016-02-18 21:34:16 +08:00
|
|
|
for (i = 0; i < ARRAY_SIZE(exynos_drm_drivers); ++i) {
|
|
|
|
struct exynos_drm_driver_info *info = &exynos_drm_drivers[i];
|
2015-06-11 22:20:52 +08:00
|
|
|
|
2016-02-18 21:34:16 +08:00
|
|
|
if (!info->driver || !(info->flags & DRM_VIRTUAL_DEVICE))
|
2015-06-11 22:20:52 +08:00
|
|
|
continue;
|
|
|
|
|
2016-02-18 21:34:16 +08:00
|
|
|
pdev = platform_device_register_simple(
|
|
|
|
info->driver->driver.name, -1, NULL, 0);
|
|
|
|
if (IS_ERR(pdev))
|
|
|
|
goto fail;
|
2014-11-13 15:37:57 +08:00
|
|
|
}
|
2014-05-09 13:25:20 +08:00
|
|
|
|
2015-06-11 22:20:52 +08:00
|
|
|
return 0;
|
2016-02-18 21:34:16 +08:00
|
|
|
fail:
|
|
|
|
exynos_drm_unregister_devices();
|
|
|
|
return PTR_ERR(pdev);
|
2011-10-04 18:19:01 +08:00
|
|
|
}
|
|
|
|
|
2016-02-18 21:34:16 +08:00
|
|
|
static void exynos_drm_unregister_drivers(void)
|
2011-10-04 18:19:01 +08:00
|
|
|
{
|
2016-02-18 21:34:16 +08:00
|
|
|
int i;
|
2015-06-11 22:20:52 +08:00
|
|
|
|
2016-02-18 21:34:16 +08:00
|
|
|
for (i = ARRAY_SIZE(exynos_drm_drivers) - 1; i >= 0; --i) {
|
|
|
|
struct exynos_drm_driver_info *info = &exynos_drm_drivers[i];
|
2015-06-11 22:20:52 +08:00
|
|
|
|
2016-02-18 21:34:16 +08:00
|
|
|
if (!info->driver)
|
2015-06-11 22:20:52 +08:00
|
|
|
continue;
|
|
|
|
|
2016-02-18 21:34:16 +08:00
|
|
|
platform_driver_unregister(info->driver);
|
2015-06-11 22:20:52 +08:00
|
|
|
}
|
2014-05-09 13:25:20 +08:00
|
|
|
}
|
|
|
|
|
2016-02-18 21:34:16 +08:00
|
|
|
static int exynos_drm_register_drivers(void)
|
2015-06-11 22:20:52 +08:00
|
|
|
{
|
2016-02-18 21:34:16 +08:00
|
|
|
int i, ret;
|
2015-06-11 22:20:52 +08:00
|
|
|
|
2016-02-18 21:34:16 +08:00
|
|
|
for (i = 0; i < ARRAY_SIZE(exynos_drm_drivers); ++i) {
|
|
|
|
struct exynos_drm_driver_info *info = &exynos_drm_drivers[i];
|
2015-06-11 22:20:52 +08:00
|
|
|
|
2016-02-18 21:34:16 +08:00
|
|
|
if (!info->driver)
|
|
|
|
continue;
|
2015-06-11 22:20:52 +08:00
|
|
|
|
2016-02-18 21:34:16 +08:00
|
|
|
ret = platform_driver_register(info->driver);
|
|
|
|
if (ret)
|
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
fail:
|
|
|
|
exynos_drm_unregister_drivers();
|
|
|
|
return ret;
|
2015-06-11 22:20:52 +08:00
|
|
|
}
|
|
|
|
|
2014-05-09 13:25:20 +08:00
|
|
|
static int exynos_drm_init(void)
|
|
|
|
{
|
2015-06-08 18:15:42 +08:00
|
|
|
int ret;
|
2014-05-09 13:25:20 +08:00
|
|
|
|
2015-06-11 22:20:52 +08:00
|
|
|
ret = exynos_drm_register_devices();
|
|
|
|
if (ret)
|
|
|
|
return ret;
|
drm/exynos: move Exynos platform drivers registration to init
Registering the Exynos DRM subdevices platform drivers in the probe
function is causing an infinite loop. Fix this by moving it to the
exynos_drm_init() function to register the drivers on module init.
Registering drivers in the probe functions causes a deadlock in the parent
device lock. See Grant Likely explanation on the topic:
"I think the problem is that exynos_drm_init() is registering a normal
(non-OF) platform device, so the parent will be /sys/devices/platform.
It immediately gets bound against exynos_drm_platform_driver which
calls the exynos drm_platform_probe() hook. The driver core obtains
device_lock() on the device *and on the device parent*.
Inside the probe hook, additional platform_drivers get registered.
Each time one does, it tries to bind against every platform device in
the system, which includes the ones created by OF. When it attempts to
bind, it obtains device_lock() on the device *and on the device
parent*.
Before the change to move of-generated platform devices into
/sys/devices/platform, the devices had different parents. Now both
devices have /sys/devices/platform as the parent, so yes they are
going to deadlock.
The real problem is registering drivers from within a probe hook. That
is completely wrong for the above deadlock reason. __driver_attach()
will deadlock. Those registrations must be pulled out of .probe().
Registering devices in .probe() is okay because __device_attach()
doesn't try to obtain device_lock() on the parent."
INFO: task swapper/0:1 blocked for more than 120 seconds.
Not tainted 3.18.0-rc3-next-20141105 #794
"echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
swapper/0 D c052534c 0 1 0 0x00000000
[<c052534c>] (__schedule) from [<c0525b34>] (schedule_preempt_disabled+0x14/0x20)
[<c0525b34>] (schedule_preempt_disabled) from [<c0526d44>] (mutex_lock_nested+0x1c4/0x464
[<c0526d44>] (mutex_lock_nested) from [<c02be908>] (__driver_attach+0x48/0x98)
[<c02be908>] (__driver_attach) from [<c02bcc00>] (bus_for_each_dev+0x54/0x88)
[<c02bcc00>] (bus_for_each_dev) from [<c02bdce0>] (bus_add_driver+0xe4/0x200)
[<c02bdce0>] (bus_add_driver) from [<c02bef94>] (driver_register+0x78/0xf4)
[<c02bef94>] (driver_register) from [<c029e99c>] (exynos_drm_platform_probe+0x34/0x234)
[<c029e99c>] (exynos_drm_platform_probe) from [<c02bfcf0>] (platform_drv_probe+0x48/0xa4)
[<c02bfcf0>] (platform_drv_probe) from [<c02be680>] (driver_probe_device+0x13c/0x37c)
[<c02be680>] (driver_probe_device) from [<c02be954>] (__driver_attach+0x94/0x98)
[<c02be954>] (__driver_attach) from [<c02bcc00>] (bus_for_each_dev+0x54/0x88)
[<c02bcc00>] (bus_for_each_dev) from [<c02bdce0>] (bus_add_driver+0xe4/0x200)
[<c02bdce0>] (bus_add_driver) from [<c02bef94>] (driver_register+0x78/0xf4)
[<c02bef94>] (driver_register) from [<c029e938>] (exynos_drm_init+0x70/0xa0)
[<c029e938>] (exynos_drm_init) from [<c00089b0>] (do_one_initcall+0xac/0x1f0)
[<c00089b0>] (do_one_initcall) from [<c074bd90>] (kernel_init_freeable+0x10c/0x1d8)
[<c074bd90>] (kernel_init_freeable) from [<c051eabc>] (kernel_init+0x8/0xec)
[<c051eabc>] (kernel_init) from [<c000f268>] (ret_from_fork+0x14/0x2c)
3 locks held by swapper/0/1:
#0: (&dev->mutex){......}, at: [<c02be908>] __driver_attach+0x48/0x98
#1: (&dev->mutex){......}, at: [<c02be918>] __driver_attach+0x58/0x98
#2: (&dev->mutex){......}, at: [<c02be908>] __driver_attach+0x48/0x98
Changelog v2:
- call platform_driver_register after all kms and non kms drivers are
registered
- rebased it to exynos-drm-next
Signed-off-by: Javier Martinez Canillas <javier.martinez@collabora.co.uk>
Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
Signed-off-by: Inki Dae <inki.dae@samsung.com>
2014-11-24 15:37:26 +08:00
|
|
|
|
2016-02-18 21:34:16 +08:00
|
|
|
ret = exynos_drm_register_drivers();
|
2015-06-11 22:20:52 +08:00
|
|
|
if (ret)
|
|
|
|
goto err_unregister_pdevs;
|
2014-05-09 13:25:20 +08:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
2015-06-11 22:20:52 +08:00
|
|
|
err_unregister_pdevs:
|
|
|
|
exynos_drm_unregister_devices();
|
2014-05-09 13:25:20 +08:00
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void exynos_drm_exit(void)
|
|
|
|
{
|
2016-02-18 21:34:16 +08:00
|
|
|
exynos_drm_unregister_drivers();
|
2015-06-11 22:20:52 +08:00
|
|
|
exynos_drm_unregister_devices();
|
2011-10-04 18:19:01 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
module_init(exynos_drm_init);
|
|
|
|
module_exit(exynos_drm_exit);
|
|
|
|
|
|
|
|
MODULE_AUTHOR("Inki Dae <inki.dae@samsung.com>");
|
|
|
|
MODULE_AUTHOR("Joonyoung Shim <jy0922.shim@samsung.com>");
|
|
|
|
MODULE_AUTHOR("Seung-Woo Kim <sw0312.kim@samsung.com>");
|
|
|
|
MODULE_DESCRIPTION("Samsung SoC DRM Driver");
|
|
|
|
MODULE_LICENSE("GPL");
|