From patchwork Fri Sep 13 05:28:29 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Ben Widawsky X-Patchwork-Id: 2881561 Return-Path: X-Original-To: patchwork-intel-gfx@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id C65A2BFF05 for ; Fri, 13 Sep 2013 05:31:28 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id EF0D020134 for ; Fri, 13 Sep 2013 05:31:27 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 08D6F20117 for ; Fri, 13 Sep 2013 05:31:27 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 0CCA8E63D8 for ; Thu, 12 Sep 2013 22:31:27 -0700 (PDT) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mail.bwidawsk.net (bwidawsk.net [166.78.191.112]) by gabe.freedesktop.org (Postfix) with ESMTP id 959B1E613F for ; Thu, 12 Sep 2013 22:28:53 -0700 (PDT) Received: by mail.bwidawsk.net (Postfix, from userid 5001) id A7FB259D17; Thu, 12 Sep 2013 22:28:52 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Level: X-Spam-Status: No, score=-5.1 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 Received: from lundgren.intel.com (c-24-21-100-90.hsd1.or.comcast.net [24.21.100.90]) by mail.bwidawsk.net (Postfix) with ESMTPSA id A126A59D0D; Thu, 12 Sep 2013 22:28:48 -0700 (PDT) From: Ben Widawsky To: intel-gfx@lists.freedesktop.org Date: Thu, 12 Sep 2013 22:28:29 -0700 Message-Id: <1379050122-12774-4-git-send-email-benjamin.widawsky@intel.com> X-Mailer: git-send-email 1.8.4 In-Reply-To: <1379050122-12774-1-git-send-email-benjamin.widawsky@intel.com> References: <1379050122-12774-1-git-send-email-benjamin.widawsky@intel.com> MIME-Version: 1.0 Cc: bryan.j.bell@intel.com, Ben Widawsky , Ben Widawsky , vishnu.venkatesh@intel.com Subject: [Intel-gfx] [PATCH 3/8] drm/i915: Fix l3 parity user buffer offset X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: intel-gfx-bounces+patchwork-intel-gfx=patchwork.kernel.org@lists.freedesktop.org Errors-To: intel-gfx-bounces+patchwork-intel-gfx=patchwork.kernel.org@lists.freedesktop.org X-Virus-Scanned: ClamAV using ClamSMTP The buf pointer used during l3_write is just char *, therefore it does not require the silly any addition of offset. v2: Also fix i915_l3_read with a suggested logic from Ville Cc: Ville Syrjälä Signed-off-by: Ben Widawsky --- drivers/gpu/drm/i915/i915_sysfs.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/gpu/drm/i915/i915_sysfs.c b/drivers/gpu/drm/i915/i915_sysfs.c index 9070f50..d572435 100644 --- a/drivers/gpu/drm/i915/i915_sysfs.c +++ b/drivers/gpu/drm/i915/i915_sysfs.c @@ -127,6 +127,8 @@ i915_l3_read(struct file *filp, struct kobject *kobj, if (ret) return ret; + count = min_t(int, GEN7_L3LOG_SIZE-offset, count); + ret = i915_mutex_lock_interruptible(drm_dev); if (ret) return ret; @@ -134,14 +136,14 @@ i915_l3_read(struct file *filp, struct kobject *kobj, misccpctl = I915_READ(GEN7_MISCCPCTL); I915_WRITE(GEN7_MISCCPCTL, misccpctl & ~GEN7_DOP_CLOCK_GATE_ENABLE); - for (i = offset; count >= 4 && i < GEN7_L3LOG_SIZE; i += 4, count -= 4) - *((uint32_t *)(&buf[i])) = I915_READ(GEN7_L3LOG_BASE + i); + for (i = 0; i < count; i += 4) + *((uint32_t *)(&buf[i])) = I915_READ(GEN7_L3LOG_BASE + offset + i); I915_WRITE(GEN7_MISCCPCTL, misccpctl); mutex_unlock(&drm_dev->struct_mutex); - return i - offset; + return i; } static ssize_t @@ -186,9 +188,7 @@ i915_l3_write(struct file *filp, struct kobject *kobj, if (temp) dev_priv->l3_parity.remap_info = temp; - memcpy(dev_priv->l3_parity.remap_info + (offset/4), - buf + (offset/4), - count); + memcpy(dev_priv->l3_parity.remap_info + (offset/4), buf, count); i915_gem_l3_remap(drm_dev);