From patchwork Thu Nov 15 15:53:58 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Vetter X-Patchwork-Id: 1750571 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 810F6DFE80 for ; Thu, 15 Nov 2012 16:00:00 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 4F8DFA08E2 for ; Thu, 15 Nov 2012 08:00:00 -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 5BBF6A08DF for ; Thu, 15 Nov 2012 07:52:46 -0800 (PST) Received: by mail-ee0-f49.google.com with SMTP id c1so1040408eek.36 for ; Thu, 15 Nov 2012 07:52:45 -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=q2M9yftkqS02QojgQvFjkZkDK/PJorCfkNnlK/pY13I=; b=EvYjndrb94spce2eWNfYJI3o6Tqz0UcJvxk8CVyz8riea9AXfd5PeZZ9Xz96n0bS64 sYfBLpLMT52GB8CVgQFNkO2ewy70XmbMg6tCvT4Z6HdK/++3U/bvEjoZKlwNCB13Z0lN dEB6BeQX/19fuaG9OEg1pCe65euXszLy9dW8Q= 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=q2M9yftkqS02QojgQvFjkZkDK/PJorCfkNnlK/pY13I=; b=IzVRUrCI1qypA7w+ukq+hoavInoxfKP4PTM5uYixDn5ALjbTWvLQxGDIbXyAiat8HO KmRScFqiq1hbkciuQeVY6OFP4n22R1Ij0vwmT7a4kXTybBqSwpsXAKNbTzaEGFrM9+Zr t7ZmiXGyS0cC77tjFom8DpLsEUf8DyB0++PMxaUC5zJ+xh82DoOzXROXJwbp9qYHHa4C wfj+BZLMgjQsvYut6MiRH30q0EeBFdXO8wwyNlNDj8/jDosSzA7+5EWgLlmo9z8U7CXx kIwmOlyDge8v61LhA2imamSWY8IzxCmZeeLXQh0d8wkUKB24KQxoPQAyuoyv6vnfQaQc pIYw== Received: by 10.14.194.72 with SMTP id l48mr5145167een.9.1352994765463; Thu, 15 Nov 2012 07:52:45 -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 a44sm36876975eeo.7.2012.11.15.07.52.44 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 15 Nov 2012 07:52:44 -0800 (PST) From: Daniel Vetter To: Intel Graphics Development Date: Thu, 15 Nov 2012 16:53:58 +0100 Message-Id: <1352994838-15156-1-git-send-email-daniel.vetter@ffwll.ch> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <453bf0$6g3v6k@azsmga001.ch.intel.com> References: <453bf0$6g3v6k@azsmga001.ch.intel.com> X-Gm-Message-State: ALoCoQkau6DvHejF0C+z7nYNXYIh4WRdWRn8T54xeMLiRM0FgvSUOPQQ7G4DO9wonumxtsTtvonk Cc: Daniel Vetter Subject: [Intel-gfx] [PATCH] 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. v2: i915_gem_clflush_object already checks whether the object is coherent and if so, drops the flushing. Hence we don't need to check that ourselves, simplifying the condition. v3: Reorder the checks for better clarify (and adjust the comment accordingly), suggested by Chris Wilson. Signed-off-by: Daniel Vetter Reviewed-by: Chris Wilson --- drivers/gpu/drm/i915/i915_gem.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c index eaaf095..851f787 100644 --- a/drivers/gpu/drm/i915/i915_gem.c +++ b/drivers/gpu/drm/i915/i915_gem.c @@ -830,9 +830,13 @@ out: i915_gem_object_unpin_pages(obj); 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) { + /* + * Fixup: Flush cpu caches in case we didn't flush the dirty + * cachelines in-line while writing and the object moved + * out of the cpu write domain while we've dropped the lock. + */ + if (!needs_clflush_after && + obj->base.write_domain != I915_GEM_DOMAIN_CPU) { i915_gem_clflush_object(obj); i915_gem_chipset_flush(dev); }