From patchwork Thu Mar 19 04:33:23 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Stone X-Patchwork-Id: 6046001 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id D970B9FB96 for ; Thu, 19 Mar 2015 04:34:20 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id E6109204D9 for ; Thu, 19 Mar 2015 04:34:19 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id E74B9204C9 for ; Thu, 19 Mar 2015 04:34:18 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 293A56E96F; Wed, 18 Mar 2015 21:34:13 -0700 (PDT) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from bhuna.collabora.co.uk (bhuna.collabora.co.uk [93.93.135.160]) by gabe.freedesktop.org (Postfix) with ESMTP id 5DDC96E0E4 for ; Wed, 18 Mar 2015 21:33:59 -0700 (PDT) Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: daniels) with ESMTPSA id E940E6007B0 From: Daniel Stone To: dri-devel@lists.freedesktop.org Subject: [RFC PATCH 24/37] drm: mode: Use cached usermode representation Date: Thu, 19 Mar 2015 04:33:23 +0000 Message-Id: <1426739616-10635-24-git-send-email-daniels@collabora.com> X-Mailer: git-send-email 2.3.2 In-Reply-To: <1426739616-10635-1-git-send-email-daniels@collabora.com> References: <1426739556-10429-1-git-send-email-daniels@collabora.com> <1426739616-10635-1-git-send-email-daniels@collabora.com> X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- 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,