[RFC PATCH 24/37] drm: mode: Use cached usermode representation
Daniel Stone
daniels at collabora.com
Wed Mar 18 21:33:23 PDT 2015
Instead of generating a new usermode every time we need to copy a mode
back to userspace, just use the cached one we already have.
Signed-off-by: Daniel Stone <daniels at collabora.com>
---
drivers/gpu/drm/drm_crtc.c | 15 +++++----------
drivers/gpu/drm/drm_modes.c | 4 ++--
include/drm/drm_modes.h | 2 --
3 files changed, 7 insertions(+), 14 deletions(-)
diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c
index 6a7f07f..af9628b 100644
--- a/drivers/gpu/drm/drm_crtc.c
+++ b/drivers/gpu/drm/drm_crtc.c
@@ -1936,8 +1936,8 @@ int drm_mode_getcrtc(struct drm_device *dev,
crtc_resp->x = crtc->primary->state->src_x >> 16;
crtc_resp->y = crtc->primary->state->src_y >> 16;
if (crtc->state->enable) {
- WARN_ON(!crtc->state->mode);
- drm_mode_convert_to_umode(&crtc_resp->mode, crtc->state->mode);
+ memcpy(&crtc_resp->mode, &crtc->mode->umode,
+ sizeof(crtc_resp->mode));
crtc_resp->mode_valid = 1;
} else {
@@ -1947,9 +1947,8 @@ int drm_mode_getcrtc(struct drm_device *dev,
crtc_resp->x = crtc->x;
crtc_resp->y = crtc->y;
if (crtc->enabled) {
- WARN_ON(!crtc->mode);
- drm_mode_convert_to_umode(&crtc_resp->mode,
- crtc->mode);
+ memcpy(&crtc_resp->mode, &crtc->mode->umode,
+ sizeof(crtc_resp->mode));
crtc_resp->mode_valid = 1;
} else {
@@ -2046,15 +2045,12 @@ int drm_mode_getconnector(struct drm_device *dev, void *data,
int ret = 0;
int copied = 0;
int i;
- struct drm_mode_modeinfo u_mode;
struct drm_mode_modeinfo __user *mode_ptr;
uint32_t __user *encoder_ptr;
if (!drm_core_check_feature(dev, DRIVER_MODESET))
return -EINVAL;
- memset(&u_mode, 0, sizeof(struct drm_mode_modeinfo));
-
DRM_DEBUG_KMS("[CONNECTOR:%d:?]\n", out_resp->connector_id);
mutex_lock(&dev->mode_config.mutex);
@@ -2106,9 +2102,8 @@ int drm_mode_getconnector(struct drm_device *dev, void *data,
if (!drm_mode_expose_to_userspace(mode, file_priv))
continue;
- drm_mode_convert_to_umode(&u_mode, mode);
if (copy_to_user(mode_ptr + copied,
- &u_mode, sizeof(u_mode))) {
+ &mode->umode, sizeof(mode->umode))) {
ret = -EFAULT;
goto out;
}
diff --git a/drivers/gpu/drm/drm_modes.c b/drivers/gpu/drm/drm_modes.c
index 803e00a..0883f64 100644
--- a/drivers/gpu/drm/drm_modes.c
+++ b/drivers/gpu/drm/drm_modes.c
@@ -899,8 +899,8 @@ EXPORT_SYMBOL(drm_mode_duplicate);
* Convert a drm_display_mode into a drm_mode_modeinfo structure to return to
* the user.
*/
-void drm_mode_convert_to_umode(struct drm_mode_modeinfo *out,
- const struct drm_display_mode *in)
+static void drm_mode_convert_to_umode(struct drm_mode_modeinfo *out,
+ const struct drm_display_mode *in)
{
WARN(in->hdisplay > USHRT_MAX || in->hsync_start > USHRT_MAX ||
in->hsync_end > USHRT_MAX || in->htotal > USHRT_MAX ||
diff --git a/include/drm/drm_modes.h b/include/drm/drm_modes.h
index e7eb727..46ed207 100644
--- a/include/drm/drm_modes.h
+++ b/include/drm/drm_modes.h
@@ -219,8 +219,6 @@ struct drm_display_mode *drm_mode_duplicate(struct drm_device *dev,
const struct drm_display_mode *mode);
struct drm_display_mode *drm_mode_new_from_umode(struct drm_device *dev,
const struct drm_mode_modeinfo *in);
-void drm_mode_convert_to_umode(struct drm_mode_modeinfo *out,
- const struct drm_display_mode *in);
bool drm_mode_equal(const struct drm_display_mode *mode1,
const struct drm_display_mode *mode2);
bool drm_mode_equal_no_clocks_no_stereo(const struct drm_display_mode *mode1,
--
2.3.2
More information about the dri-devel
mailing list