From patchwork Wed Dec 12 13:06:53 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Vetter X-Patchwork-Id: 1866841 Return-Path: X-Original-To: patchwork-dri-devel@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 7DC1EDF2EE for ; Wed, 12 Dec 2012 14:08:01 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id EF68EE65DC for ; Wed, 12 Dec 2012 06:08:00 -0800 (PST) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-ea0-f177.google.com (mail-ea0-f177.google.com [209.85.215.177]) by gabe.freedesktop.org (Postfix) with ESMTP id 46785E62AA for ; Wed, 12 Dec 2012 05:13:38 -0800 (PST) Received: by mail-ea0-f177.google.com with SMTP id c10so221624eaa.36 for ; Wed, 12 Dec 2012 05:13:37 -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=BhmI2bNDqnYQrh9GDc4tZYZn7iFA3jUP+glrsL11XQ8=; b=dQBkxxRZuLPrr90IUULEWpgTC2ymi9FMwEm5aiv5JLKhEwCDVF6GJYU1SgbwKTo783 M2ex4DjCwjTIiZC8i/z5F/eqgBKgxF8vcRWww4DGbtyIkDKAFDaEmZFEox6J5OOLfelD 4PD4cyGCx/8AUFSOIcYAXbFvZaanQqfq8CC+Q= 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=BhmI2bNDqnYQrh9GDc4tZYZn7iFA3jUP+glrsL11XQ8=; b=KvBinmg7uX9Epsxt+biNwWG+a0kkSdeJmjXQUIZCOkctKs4/qeQvhPDoFYjGTnsTtV RHqR0wLYEZuqCVii7UHDAX4lqOeronKMiEG+rl0+rvRUuNa1X2hH0V7Hy2Ek1FLi3a+I HFa1NWsuU7X4cOW/LEs7LeRpWA1T/dWnwJLXavKALVWSfDCc/BOmfjnJYzYjkV52kE+m 4sp2Ikidn7bGsXpDgxHcpAEdF2Q6IK78NiQv4KQ3M2gXbnkXDCoLjUMgk0F8Vklax6Sc /uO4ndWsSBuiu1/L+5fBEAegXVgI3QsWTOs5oo/NqU32qzwrDcm9GTKxQy73dieJCszo WMSg== Received: by 10.14.203.2 with SMTP id e2mr2693025eeo.20.1355317657272; Wed, 12 Dec 2012 05:07:37 -0800 (PST) Received: from biers.ffwll.local (178-83-130-250.dynamic.hispeed.ch. [178.83.130.250]) by mx.google.com with ESMTPS id r1sm55868541eeo.2.2012.12.12.05.07.36 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 12 Dec 2012 05:07:36 -0800 (PST) From: Daniel Vetter To: DRI Development Subject: [PATCH 13/37] drm/nouveau: protect evo_wait/evo_kick sections with a channel mutex Date: Wed, 12 Dec 2012 14:06:53 +0100 Message-Id: <1355317637-16742-14-git-send-email-daniel.vetter@ffwll.ch> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1355317637-16742-1-git-send-email-daniel.vetter@ffwll.ch> References: <1355317637-16742-1-git-send-email-daniel.vetter@ffwll.ch> X-Gm-Message-State: ALoCoQnR0PLMbkB17D3v6WMTPWn8ceuZXg+ezqYdg+rR0/6Por+RodaS/+OOB2t2OOkFm+c+JWEF Cc: Nouveau Dev , Intel Graphics Development , Radeon Dev , Daniel Vetter X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: dri-devel-bounces+patchwork-dri-devel=patchwork.kernel.org@lists.freedesktop.org Errors-To: dri-devel-bounces+patchwork-dri-devel=patchwork.kernel.org@lists.freedesktop.org With per-crtc locks modeset operations can run in parallel, and the cursor code uses the device-global evo master channel for hw frobbing. But the pageflip code can also sync with the master under some circumstances. Hence just wrap things up in a mutex to ensure that pushbuf access doesn't intermingle. The approach here is a bit overkill since the per-crtc channels used to schedule the pageflips could probably be used without this pushbuf locking, but I'm not familiar enough with the nouveau codebase to be sure of that. Signed-off-by: Daniel Vetter --- drivers/gpu/drm/nouveau/nv50_display.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/gpu/drm/nouveau/nv50_display.c b/drivers/gpu/drm/nouveau/nv50_display.c index 3587408..5751d63 100644 --- a/drivers/gpu/drm/nouveau/nv50_display.c +++ b/drivers/gpu/drm/nouveau/nv50_display.c @@ -128,6 +128,11 @@ struct nv50_dmac { struct nv50_chan base; dma_addr_t handle; u32 *ptr; + + /* Protects against concurrent pushbuf access to this channel, lock is + * grabbed by evo_wait (if the pushbuf reservation is successful) and + * dropped again by evo_kick. */ + struct mutex lock; }; static void @@ -395,11 +400,13 @@ evo_wait(void *evoc, int nr) struct nv50_dmac *dmac = evoc; u32 put = nv_ro32(dmac->base.user, 0x0000) / 4; + mutex_lock(&dmac->lock); if (put + nr >= (PAGE_SIZE / 4) - 8) { dmac->ptr[put] = 0x20000000; nv_wo32(dmac->base.user, 0x0000, 0x00000000); if (!nv_wait(dmac->base.user, 0x0004, ~0, 0x00000000)) { + mutex_unlock(&dmac->lock); NV_ERROR(dmac->base.user, "channel stalled\n"); return NULL; } @@ -415,6 +422,7 @@ evo_kick(u32 *push, void *evoc) { struct nv50_dmac *dmac = evoc; nv_wo32(dmac->base.user, 0x0000, (push - dmac->ptr) << 2); + mutex_unlock(&dmac->lock); } #define evo_mthd(p,m,s) *((p)++) = (((s) << 18) | (m))