@@ -31,6 +31,7 @@
#include <linux/slab.h>
#include <drm/drm_auth.h>
+#include <drm/drm_crtc.h>
#include <drm/drm_drv.h>
#include <drm/drm_file.h>
#include <drm/drm_lease.h>
@@ -335,6 +336,9 @@ void drm_master_release(struct drm_file *file_priv)
drm_lease_revoke(master);
}
+ if (drm_core_check_feature(dev, DRIVER_ATOMIC) && file_priv->is_master)
+ drm_crtc_set_sched_mode(dev, DRM_CLIENT_CAP_SCHED_NORMAL);
+
/* drop the master reference held by the file priv */
if (file_priv->master)
drm_master_put(&file_priv->master);
@@ -93,6 +93,32 @@ struct drm_crtc *drm_crtc_from_index(struct drm_device *dev, int idx)
}
EXPORT_SYMBOL(drm_crtc_from_index);
+/**
+ * drm_crtc_set_sched_mode:
+ * @dev: DRM device
+ * @mode: one of DRM_CLIENT_CAP_SCHED_x
+ *
+ * Set the scheduling mode for per-CRTC kthread workers. This controls
+ * whether nonblocking atomic commits will run with SCHED_NORMAL or
+ * SCHED_FIFO (rt) priority.
+ */
+void drm_crtc_set_sched_mode(struct drm_device *dev, int mode)
+{
+ struct drm_crtc *crtc;
+
+ drm_for_each_crtc(crtc, dev) {
+ switch (mode) {
+ case DRM_CLIENT_CAP_SCHED_NORMAL:
+ /* zero is default nice value for kthreads: */
+ sched_set_normal(crtc->worker->task, 0);
+ break;
+ case DRM_CLIENT_CAP_SCHED_FIFO:
+ sched_set_fifo(crtc->worker->task);
+ break;
+ }
+ }
+}
+
int drm_crtc_force_disable(struct drm_crtc *crtc)
{
struct drm_mode_set set = {
@@ -362,6 +362,19 @@ drm_setclientcap(struct drm_device *dev, void *data, struct drm_file *file_priv)
return -EINVAL;
file_priv->writeback_connectors = req->value;
break;
+ case DRM_CLIENT_CAP_SCHED_MODE:
+ if (!file_priv->is_master)
+ return -EPERM;
+ if (!file_priv->atomic)
+ return -EOPNOTSUPP;
+ switch (req->value) {
+ case DRM_CLIENT_CAP_SCHED_NORMAL:
+ case DRM_CLIENT_CAP_SCHED_FIFO:
+ drm_crtc_set_sched_mode(dev, req->value);
+ return 0;
+ default:
+ return -EINVAL;
+ }
default:
return -EINVAL;
}
@@ -1245,6 +1245,8 @@ static inline uint32_t drm_crtc_mask(const struct drm_crtc *crtc)
int drm_mode_set_config_internal(struct drm_mode_set *set);
struct drm_crtc *drm_crtc_from_index(struct drm_device *dev, int idx);
+void drm_crtc_set_sched_mode(struct drm_device *dev, int mode);
+
/**
* drm_crtc_find - look up a CRTC object from its ID
* @dev: DRM device
@@ -698,6 +698,19 @@ struct drm_get_cap {
*/
#define DRM_CLIENT_CAP_WRITEBACK_CONNECTORS 5
+/**
+ * DRM_CLIENT_CAP_SCHED_MODE
+ *
+ * Allow userspace to control the scheduling parameters for nonblocking
+ * commit. The default is SCHED_NORMAL/CFS. Userspace using SCHED_FIFO
+ * in the rendering/display pipeline should use DRM_CLIENT_CAP_SCHED_FIFO
+ * to prevent userspace portions of the display pipeline from preempting
+ * nonblocking commit_work.
+ */
+#define DRM_CLIENT_CAP_SCHED_MODE 6
+# define DRM_CLIENT_CAP_SCHED_NORMAL 0
+# define DRM_CLIENT_CAP_SCHED_FIFO 1
+
/** DRM_IOCTL_SET_CLIENT_CAP ioctl argument type */
struct drm_set_client_cap {
__u64 capability;