From patchwork Thu Nov 15 14:40:06 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Vetter X-Patchwork-Id: 1749811 Return-Path: X-Original-To: patchwork-intel-gfx@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by patchwork2.kernel.org (Postfix) with ESMTP id 0B349DF230 for ; Thu, 15 Nov 2012 14:39:33 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id DEA1BA01F9 for ; Thu, 15 Nov 2012 06:39:32 -0800 (PST) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mail-ee0-f49.google.com (mail-ee0-f49.google.com [74.125.83.49]) by gabe.freedesktop.org (Postfix) with ESMTP id EB3F99E930 for ; Thu, 15 Nov 2012 06:38:53 -0800 (PST) Received: by mail-ee0-f49.google.com with SMTP id c1so994634eek.36 for ; Thu, 15 Nov 2012 06:38:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ffwll.ch; s=google; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; bh=fotU3pFNJxXPDzG62xtJgkdU0nlFDw/cixaE3oQfmes=; b=IbrbXBepS+pOj6rlRN22jMK0Sgz/tVWRKK/Tr+vRy62a9iKGbQEGpbUyt3zMZQZbgj wks0qGlPUikX3zqXcluLh83YnhNsTIekbW2WU3W9o8CUVq8kArEUVZmhQy9PqsjEW7Vg GnKAMVHomY8RSm5VfJ4ZHRRb7yVaFI59/Fge8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references :x-gm-message-state; bh=fotU3pFNJxXPDzG62xtJgkdU0nlFDw/cixaE3oQfmes=; b=B4pf1MsCqswGa5o/3PIjxYnl5+IpwPQvV6Jfjj1jSnuP8zc+OV7di+bp6of2lk8EsB STnIF78QnFbP4BP/9OJR9SxxMN93txyWUOeQfNvbTr38Hc/vtKNH8ln7plfftF5tG/Gy TC1qvUfguTYFPtuo/6EpxIXsbyg/cI6at4dVvnxd8aL3nOt4izJ/MJqTD4aWa+J1LPK2 3Zpj1Fk86ZTirGAD0nrShJpCK1eFEIsGG9fGSyqGinqDGJZLyqjBO2rtGzMXVGhjglWH JO6VkjjqtvfgvqjsYlXbvnkcJRzWKFaQGvUmMng79+GBqhhi1MBUrj1O7639vDTvanKo UPmQ== Received: by 10.14.184.1 with SMTP id r1mr4524662eem.4.1352990333183; Thu, 15 Nov 2012 06:38:53 -0800 (PST) Received: from phenom.ffwll.local (178-83-130-250.dynamic.hispeed.ch. [178.83.130.250]) by mx.google.com with ESMTPS id 2sm24199983eef.17.2012.11.15.06.38.51 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 15 Nov 2012 06:38:52 -0800 (PST) From: Daniel Vetter To: Intel Graphics Development Date: Thu, 15 Nov 2012 15:40:06 +0100 Message-Id: <1352990406-3039-2-git-send-email-daniel.vetter@ffwll.ch> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1352990406-3039-1-git-send-email-daniel.vetter@ffwll.ch> References: <1352990406-3039-1-git-send-email-daniel.vetter@ffwll.ch> X-Gm-Message-State: ALoCoQnwvvM/JZgC/k9RmfYKGhT3zOQ+YesLMJy06D+pEu3Byj8rtLVqDIpoWRfc/jkNcB8tpNwX Cc: Daniel Vetter Subject: [Intel-gfx] [PATCH 2/2] drm/i915: optimize the shmem_pwrite slowpath handling 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: , MIME-Version: 1.0 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 Since we drop dev->struct_mutex when going through the slowpath, the object might have been moved out of the cpu domain. Hence we need to clflush the entire object to ensure that after the ioctl returns, everything is coherent again (interwoven writes are ill-defined anyway). But we only need to do this if we start in the cpu domain and the object requires flushing for coherency. So don't do the flushing if the object is coherent anyway or if we've done in-line clfushing already. Signed-off-by: Daniel Vetter Reviewed-by: Chris Wilson --- drivers/gpu/drm/i915/i915_gem.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c index eaaf095..feb0b0c 100644 --- a/drivers/gpu/drm/i915/i915_gem.c +++ b/drivers/gpu/drm/i915/i915_gem.c @@ -831,8 +831,9 @@ out: if (hit_slowpath) { /* Fixup: Flush dirty cachelines in case the object isn't in the - * cpu write domain anymore. */ - if (obj->base.write_domain != I915_GEM_DOMAIN_CPU) { + * cpu write domain anymore, and we haven't flushed it manually. */ + if (obj->base.write_domain != I915_GEM_DOMAIN_CPU && + !needs_clflush_after && obj->cache_level == I915_CACHE_NONE) { i915_gem_clflush_object(obj); i915_gem_chipset_flush(dev); }