drm/msm: basic KMS driver for snapdragon
The snapdragon chips have multiple different display controllers,
depending on which chip variant/version. (As far as I can tell, current
devices have either MDP3 or MDP4, and upcoming devices have MDSS.) And
then external to the display controller are HDMI, DSI, etc. blocks which
may be shared across devices which have different display controller
blocks.
To more easily add support for different display controller blocks, the
display controller specific bits are split out into a "kms" module,
which provides the kms plane/crtc/encoder objects.
The external HDMI, DSI, etc. blocks are part encoder, and part connector
currently. But I think I will pull in the drm_bridge patches from
chromeos tree, and split them into a bridge+connector, with the
registers that need to be set in modeset handled by the bridge. This
would remove the 'msm_connector' base class. But some things need to be
double checked to make sure I could get the correct ON/OFF sequencing..
This patch adds support for mdp4 crtc (including hw cursor), dtv encoder
(part of MDP4 block), and hdmi.
Signed-off-by: Rob Clark <robdclark@gmail.com>
2013-06-26 23:44:06 +07:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2013 Red Hat
|
|
|
|
* Author: Rob Clark <robdclark@gmail.com>
|
|
|
|
*
|
|
|
|
* 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/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __MSM_GEM_H__
|
|
|
|
#define __MSM_GEM_H__
|
|
|
|
|
2017-03-08 00:02:52 +07:00
|
|
|
#include <linux/kref.h>
|
2013-07-19 23:59:32 +07:00
|
|
|
#include <linux/reservation.h>
|
drm/msm: basic KMS driver for snapdragon
The snapdragon chips have multiple different display controllers,
depending on which chip variant/version. (As far as I can tell, current
devices have either MDP3 or MDP4, and upcoming devices have MDSS.) And
then external to the display controller are HDMI, DSI, etc. blocks which
may be shared across devices which have different display controller
blocks.
To more easily add support for different display controller blocks, the
display controller specific bits are split out into a "kms" module,
which provides the kms plane/crtc/encoder objects.
The external HDMI, DSI, etc. blocks are part encoder, and part connector
currently. But I think I will pull in the drm_bridge patches from
chromeos tree, and split them into a bridge+connector, with the
registers that need to be set in modeset handled by the bridge. This
would remove the 'msm_connector' base class. But some things need to be
double checked to make sure I could get the correct ON/OFF sequencing..
This patch adds support for mdp4 crtc (including hw cursor), dtv encoder
(part of MDP4 block), and hdmi.
Signed-off-by: Rob Clark <robdclark@gmail.com>
2013-06-26 23:44:06 +07:00
|
|
|
#include "msm_drv.h"
|
|
|
|
|
2015-03-04 03:04:25 +07:00
|
|
|
/* Additional internal-use only BO flags: */
|
|
|
|
#define MSM_BO_STOLEN 0x10000000 /* try to use stolen/splash memory */
|
|
|
|
|
2016-09-29 06:58:32 +07:00
|
|
|
struct msm_gem_address_space {
|
|
|
|
const char *name;
|
|
|
|
/* NOTE: mm managed at the page level, size is in # of pages
|
|
|
|
* and position mm_node->start is in # of pages:
|
|
|
|
*/
|
|
|
|
struct drm_mm mm;
|
2017-06-14 05:52:54 +07:00
|
|
|
spinlock_t lock; /* Protects drm_mm node allocation/removal */
|
2016-09-29 06:58:32 +07:00
|
|
|
struct msm_mmu *mmu;
|
2017-03-08 00:02:52 +07:00
|
|
|
struct kref kref;
|
2016-09-29 06:58:32 +07:00
|
|
|
};
|
|
|
|
|
|
|
|
struct msm_gem_vma {
|
|
|
|
struct drm_mm_node node;
|
|
|
|
uint64_t iova;
|
2017-06-14 00:54:13 +07:00
|
|
|
struct msm_gem_address_space *aspace;
|
|
|
|
struct list_head list; /* node in msm_gem_object::vmas */
|
2016-09-29 06:58:32 +07:00
|
|
|
};
|
|
|
|
|
drm/msm: basic KMS driver for snapdragon
The snapdragon chips have multiple different display controllers,
depending on which chip variant/version. (As far as I can tell, current
devices have either MDP3 or MDP4, and upcoming devices have MDSS.) And
then external to the display controller are HDMI, DSI, etc. blocks which
may be shared across devices which have different display controller
blocks.
To more easily add support for different display controller blocks, the
display controller specific bits are split out into a "kms" module,
which provides the kms plane/crtc/encoder objects.
The external HDMI, DSI, etc. blocks are part encoder, and part connector
currently. But I think I will pull in the drm_bridge patches from
chromeos tree, and split them into a bridge+connector, with the
registers that need to be set in modeset handled by the bridge. This
would remove the 'msm_connector' base class. But some things need to be
double checked to make sure I could get the correct ON/OFF sequencing..
This patch adds support for mdp4 crtc (including hw cursor), dtv encoder
(part of MDP4 block), and hdmi.
Signed-off-by: Rob Clark <robdclark@gmail.com>
2013-06-26 23:44:06 +07:00
|
|
|
struct msm_gem_object {
|
|
|
|
struct drm_gem_object base;
|
|
|
|
|
|
|
|
uint32_t flags;
|
|
|
|
|
2016-05-18 02:44:49 +07:00
|
|
|
/**
|
|
|
|
* Advice: are the backing pages purgeable?
|
|
|
|
*/
|
|
|
|
uint8_t madv;
|
|
|
|
|
2016-05-27 22:16:28 +07:00
|
|
|
/**
|
|
|
|
* count of active vmap'ing
|
|
|
|
*/
|
|
|
|
uint8_t vmap_count;
|
|
|
|
|
2013-07-19 23:59:32 +07:00
|
|
|
/* And object is either:
|
|
|
|
* inactive - on priv->inactive_list
|
|
|
|
* active - on one one of the gpu's active_list.. well, at
|
|
|
|
* least for now we don't have (I don't think) hw sync between
|
|
|
|
* 2d and 3d one devices which have both, meaning we need to
|
|
|
|
* block on submit if a bo is already on other ring
|
|
|
|
*
|
|
|
|
*/
|
drm/msm: basic KMS driver for snapdragon
The snapdragon chips have multiple different display controllers,
depending on which chip variant/version. (As far as I can tell, current
devices have either MDP3 or MDP4, and upcoming devices have MDSS.) And
then external to the display controller are HDMI, DSI, etc. blocks which
may be shared across devices which have different display controller
blocks.
To more easily add support for different display controller blocks, the
display controller specific bits are split out into a "kms" module,
which provides the kms plane/crtc/encoder objects.
The external HDMI, DSI, etc. blocks are part encoder, and part connector
currently. But I think I will pull in the drm_bridge patches from
chromeos tree, and split them into a bridge+connector, with the
registers that need to be set in modeset handled by the bridge. This
would remove the 'msm_connector' base class. But some things need to be
double checked to make sure I could get the correct ON/OFF sequencing..
This patch adds support for mdp4 crtc (including hw cursor), dtv encoder
(part of MDP4 block), and hdmi.
Signed-off-by: Rob Clark <robdclark@gmail.com>
2013-06-26 23:44:06 +07:00
|
|
|
struct list_head mm_list;
|
2013-07-19 23:59:32 +07:00
|
|
|
struct msm_gpu *gpu; /* non-null if active */
|
|
|
|
|
|
|
|
/* Transiently in the process of submit ioctl, objects associated
|
|
|
|
* with the submit are on submit->bo_list.. this only lasts for
|
|
|
|
* the duration of the ioctl, so one bo can never be on multiple
|
|
|
|
* submit lists.
|
|
|
|
*/
|
|
|
|
struct list_head submit_entry;
|
|
|
|
|
drm/msm: basic KMS driver for snapdragon
The snapdragon chips have multiple different display controllers,
depending on which chip variant/version. (As far as I can tell, current
devices have either MDP3 or MDP4, and upcoming devices have MDSS.) And
then external to the display controller are HDMI, DSI, etc. blocks which
may be shared across devices which have different display controller
blocks.
To more easily add support for different display controller blocks, the
display controller specific bits are split out into a "kms" module,
which provides the kms plane/crtc/encoder objects.
The external HDMI, DSI, etc. blocks are part encoder, and part connector
currently. But I think I will pull in the drm_bridge patches from
chromeos tree, and split them into a bridge+connector, with the
registers that need to be set in modeset handled by the bridge. This
would remove the 'msm_connector' base class. But some things need to be
double checked to make sure I could get the correct ON/OFF sequencing..
This patch adds support for mdp4 crtc (including hw cursor), dtv encoder
(part of MDP4 block), and hdmi.
Signed-off-by: Rob Clark <robdclark@gmail.com>
2013-06-26 23:44:06 +07:00
|
|
|
struct page **pages;
|
|
|
|
struct sg_table *sgt;
|
|
|
|
void *vaddr;
|
|
|
|
|
2017-06-14 00:54:13 +07:00
|
|
|
struct list_head vmas; /* list of msm_gem_vma */
|
2013-07-19 23:59:32 +07:00
|
|
|
|
|
|
|
/* normally (resv == &_resv) except for imported bo's */
|
|
|
|
struct reservation_object *resv;
|
|
|
|
struct reservation_object _resv;
|
2013-11-17 00:56:06 +07:00
|
|
|
|
|
|
|
/* For physically contiguous buffers. Used when we don't have
|
2015-03-04 03:04:25 +07:00
|
|
|
* an IOMMU. Also used for stolen/splashscreen buffer.
|
2013-11-17 00:56:06 +07:00
|
|
|
*/
|
|
|
|
struct drm_mm_node *vram_node;
|
2017-06-14 05:52:54 +07:00
|
|
|
struct mutex lock; /* Protects resources associated with bo */
|
drm/msm: basic KMS driver for snapdragon
The snapdragon chips have multiple different display controllers,
depending on which chip variant/version. (As far as I can tell, current
devices have either MDP3 or MDP4, and upcoming devices have MDSS.) And
then external to the display controller are HDMI, DSI, etc. blocks which
may be shared across devices which have different display controller
blocks.
To more easily add support for different display controller blocks, the
display controller specific bits are split out into a "kms" module,
which provides the kms plane/crtc/encoder objects.
The external HDMI, DSI, etc. blocks are part encoder, and part connector
currently. But I think I will pull in the drm_bridge patches from
chromeos tree, and split them into a bridge+connector, with the
registers that need to be set in modeset handled by the bridge. This
would remove the 'msm_connector' base class. But some things need to be
double checked to make sure I could get the correct ON/OFF sequencing..
This patch adds support for mdp4 crtc (including hw cursor), dtv encoder
(part of MDP4 block), and hdmi.
Signed-off-by: Rob Clark <robdclark@gmail.com>
2013-06-26 23:44:06 +07:00
|
|
|
};
|
|
|
|
#define to_msm_bo(x) container_of(x, struct msm_gem_object, base)
|
|
|
|
|
2013-07-19 23:59:32 +07:00
|
|
|
static inline bool is_active(struct msm_gem_object *msm_obj)
|
|
|
|
{
|
|
|
|
return msm_obj->gpu != NULL;
|
|
|
|
}
|
|
|
|
|
2016-05-18 03:19:32 +07:00
|
|
|
static inline bool is_purgeable(struct msm_gem_object *msm_obj)
|
|
|
|
{
|
2017-06-14 05:52:54 +07:00
|
|
|
WARN_ON(!mutex_is_locked(&msm_obj->base.dev->struct_mutex));
|
2016-05-18 03:19:32 +07:00
|
|
|
return (msm_obj->madv == MSM_MADV_DONTNEED) && msm_obj->sgt &&
|
|
|
|
!msm_obj->base.dma_buf && !msm_obj->base.import_attach;
|
|
|
|
}
|
|
|
|
|
2016-05-27 22:16:28 +07:00
|
|
|
static inline bool is_vunmapable(struct msm_gem_object *msm_obj)
|
|
|
|
{
|
|
|
|
return (msm_obj->vmap_count == 0) && msm_obj->vaddr;
|
|
|
|
}
|
|
|
|
|
2017-06-14 05:52:54 +07:00
|
|
|
/* The shrinker can be triggered while we hold objA->lock, and need
|
|
|
|
* to grab objB->lock to purge it. Lockdep just sees these as a single
|
|
|
|
* class of lock, so we use subclasses to teach it the difference.
|
|
|
|
*
|
|
|
|
* OBJ_LOCK_NORMAL is implicit (ie. normal mutex_lock() call), and
|
|
|
|
* OBJ_LOCK_SHRINKER is used by shrinker.
|
|
|
|
*
|
|
|
|
* It is *essential* that we never go down paths that could trigger the
|
|
|
|
* shrinker for a purgable object. This is ensured by checking that
|
|
|
|
* msm_obj->madv == MSM_MADV_WILLNEED.
|
|
|
|
*/
|
|
|
|
enum msm_gem_lock {
|
|
|
|
OBJ_LOCK_NORMAL,
|
|
|
|
OBJ_LOCK_SHRINKER,
|
|
|
|
};
|
|
|
|
|
|
|
|
void msm_gem_purge(struct drm_gem_object *obj, enum msm_gem_lock subclass);
|
|
|
|
void msm_gem_vunmap(struct drm_gem_object *obj, enum msm_gem_lock subclass);
|
|
|
|
|
2013-07-19 23:59:32 +07:00
|
|
|
/* Created per submit-ioctl, to track bo's and cmdstream bufs, etc,
|
|
|
|
* associated with the cmdstream submission for synchronization (and
|
|
|
|
* make it easier to unwind when things go wrong, etc). This only
|
|
|
|
* lasts for the duration of the submit-ioctl.
|
|
|
|
*/
|
|
|
|
struct msm_gem_submit {
|
|
|
|
struct drm_device *dev;
|
|
|
|
struct msm_gpu *gpu;
|
2017-10-21 00:06:57 +07:00
|
|
|
struct list_head node; /* node in ring submit list */
|
2013-07-19 23:59:32 +07:00
|
|
|
struct list_head bo_list;
|
|
|
|
struct ww_acquire_ctx ticket;
|
2017-10-21 00:06:57 +07:00
|
|
|
uint32_t seqno; /* Sequence number of the submit on the ring */
|
2016-10-25 19:00:45 +07:00
|
|
|
struct dma_fence *fence;
|
2017-10-21 00:06:55 +07:00
|
|
|
struct msm_gpu_submitqueue *queue;
|
2016-05-03 21:10:15 +07:00
|
|
|
struct pid *pid; /* submitting process */
|
2016-03-15 00:56:37 +07:00
|
|
|
bool valid; /* true if no cmdstream patching needed */
|
2017-12-14 03:12:57 +07:00
|
|
|
bool in_rb; /* "sudo" mode, copy cmds into RB */
|
2017-10-21 00:06:57 +07:00
|
|
|
struct msm_ringbuffer *ring;
|
2013-07-19 23:59:32 +07:00
|
|
|
unsigned int nr_cmds;
|
|
|
|
unsigned int nr_bos;
|
|
|
|
struct {
|
|
|
|
uint32_t type;
|
|
|
|
uint32_t size; /* in dwords */
|
2016-11-12 00:06:46 +07:00
|
|
|
uint64_t iova;
|
2014-05-31 01:47:38 +07:00
|
|
|
uint32_t idx; /* cmdstream buffer idx in bos[] */
|
2016-06-02 01:17:40 +07:00
|
|
|
} *cmd; /* array of size nr_cmds */
|
2013-07-19 23:59:32 +07:00
|
|
|
struct {
|
|
|
|
uint32_t flags;
|
|
|
|
struct msm_gem_object *obj;
|
2016-11-12 00:06:46 +07:00
|
|
|
uint64_t iova;
|
2013-07-19 23:59:32 +07:00
|
|
|
} bos[0];
|
|
|
|
};
|
|
|
|
|
drm/msm: basic KMS driver for snapdragon
The snapdragon chips have multiple different display controllers,
depending on which chip variant/version. (As far as I can tell, current
devices have either MDP3 or MDP4, and upcoming devices have MDSS.) And
then external to the display controller are HDMI, DSI, etc. blocks which
may be shared across devices which have different display controller
blocks.
To more easily add support for different display controller blocks, the
display controller specific bits are split out into a "kms" module,
which provides the kms plane/crtc/encoder objects.
The external HDMI, DSI, etc. blocks are part encoder, and part connector
currently. But I think I will pull in the drm_bridge patches from
chromeos tree, and split them into a bridge+connector, with the
registers that need to be set in modeset handled by the bridge. This
would remove the 'msm_connector' base class. But some things need to be
double checked to make sure I could get the correct ON/OFF sequencing..
This patch adds support for mdp4 crtc (including hw cursor), dtv encoder
(part of MDP4 block), and hdmi.
Signed-off-by: Rob Clark <robdclark@gmail.com>
2013-06-26 23:44:06 +07:00
|
|
|
#endif /* __MSM_GEM_H__ */
|