Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp1998979ybb; Thu, 2 Apr 2020 11:09:53 -0700 (PDT) X-Google-Smtp-Source: APiQypK5t8rGQcEQgxEAW61iyEUPQvER472dB83Ukfwd7tbZw9ukXCx9MAhjjI02E7zBLpn/D9kF X-Received: by 2002:a9d:4102:: with SMTP id o2mr3301162ote.98.1585850993766; Thu, 02 Apr 2020 11:09:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585850993; cv=none; d=google.com; s=arc-20160816; b=aVyj80eJhowPToIp7Cgyonu0a4+jgZ4xTj5SWUDkeftEJJR2J6zNm23Aldw8DA6w6G qbqUS/Dj+xC69/IssZek9MuzaQ4ODnpyJFrR8VELyCMzGDl32LnaO7KkyhGoX9U4v71l mL6+c4uQvLaraqCqksEzGyoNJ6HKoupIxS47uYTdOhGa0hw+nMU3Pr4To0lQCiquVBon lqRUnGCd1K5VB4niPt5aAif82u3pZhp01rVXi8rAfMWPjXlXtW3Fm9rOb8BZD4J+Pcfa 4RUyIpHkL+jsJfod5eX/jRD7hfUyiEJBpyVccWqna3riMAPQmE3/kbiuhmZwlHgzCjrP j28A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :reply-to:message-id:date:subject:cc:to:from; bh=JgWb3fwRSkYZgSmv3x/TqgRgJ7cqTJl8q+i+JVKr2eU=; b=Mn4Xa+SvwGqLvQGY7aV/1JGhdrAxD00wx7UB7ljHxvlmS/OeqAj/jObmZZ1Cr+SLtn D31/JknxjsOwJT8jWqNiivTVXhx287uZiwsJkqes1kG6+PtqXWg/6d29UPVkMFKJ9f73 13LJoL06N1mJq9beIT+Og3J/xQsFE5L+5it6/9QZdrHvoorubsQT6rKv98KpkHxe/Ccs oFlAUdn1g1ra6w8vUqrd6dUfLS2EhyEk9aN02taXWwEzactpx2R8ngabkk88cR9a7D5G 85Gpd6+oLTEjbDibalXVR1eK/Hoh/yVH1SaRNY8J7FCTylnso8Q9syW05qbqM8dO5uZn X5pw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=collabora.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 66si2585969otx.151.2020.04.02.11.09.40; Thu, 02 Apr 2020 11:09:53 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388484AbgDBRIZ (ORCPT + 99 others); Thu, 2 Apr 2020 13:08:25 -0400 Received: from bhuna.collabora.co.uk ([46.235.227.227]:45112 "EHLO bhuna.collabora.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731608AbgDBRIY (ORCPT ); Thu, 2 Apr 2020 13:08:24 -0400 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: bbeckett) with ESMTPSA id 5C6E3297E43 From: Robert Beckett To: Lucas Stach , Russell King , Christian Gmeiner , David Airlie Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: [PATCH v4.19.y, v4.14.y, v4.9.y] drm/etnaviv: Backport fix for mmu flushing Date: Thu, 2 Apr 2020 18:07:55 +0100 Message-Id: <20200402170758.8315-1-bob.beckett@collabora.com> X-Mailer: git-send-email 2.20.1 Reply-To: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org commit 4900dda90af2cb13bc1d4c12ce94b98acc8fe64e upstream Due to async need_flush updating via other buffer mapping, checking gpu->need_flush in 3 places within etnaviv_buffer_queue can cause GPU hangs. This occurs due to need_flush being false for the first 2 checks in that function, so that the extra dword does not get accounted for, but by the time we come to check for the third time, gpu->mmu->need_flish is true, which outputs the flush instruction. This causes the prefetch during the final link to be off by 1. This causes GPU hangs. It causes the ring to contain patterns like this: 0x40000005, /* LINK (8) PREFETCH=0x5,OP=LINK */ 0x70040010, /* ADDRESS *0x70040010 */ 0x40000002, /* LINK (8) PREFETCH=0x2,OP=LINK */ 0x70040000, /* ADDRESS *0x70040000 */ 0x08010e04, /* LOAD_STATE (1) Base: 0x03810 Size: 1 Fixp: 0 */ 0x0000001f, /* GL.FLUSH_MMU := FLUSH_FEMMU=1,FLUSH_UNK1=1,FLUSH_UNK2=1,FLUSH_PEMMU=1,FLUSH_UNK4=1 */ 0x08010e03, /* LOAD_STATE (1) Base: 0x0380C Size: 1 Fixp: 0 */ 0x00000000, /* GL.FLUSH_CACHE := DEPTH=0,COLOR=0,TEXTURE=0,PE2D=0,TEXTUREVS=0,SHADER_L1=0,SHADER_L2=0,UNK10=0,UNK11=0,DESCRIPTOR_UNK12=0,DESCRIPTOR_UNK13=0 */ 0x08010e02, /* LOAD_STATE (1) Base: 0x03808 Size: 1 Fixp: 0 */ 0x00000701, /* GL.SEMAPHORE_TOKEN := FROM=FE,TO=PE,UNK28=0x0 */ 0x48000000, /* STALL (9) OP=STALL */ 0x00000701, /* TOKEN FROM=FE,TO=PE,UNK28=0x0 */ 0x08010e00, /* LOAD_STATE (1) Base: 0x03800 Size: 1 Fixp: 0 */ 0x00000000, /* GL.PIPE_SELECT := PIPE=PIPE_3D */ 0x40000035, /* LINK (8) PREFETCH=0x35,OP=LINK */ 0x70041000, /* ADDRESS *0x70041000 */ Here we see a link with prefetch of 5 dwords starting with the 3rd instruction. It only loads the 5 dwords up and including the final LOAD_STATE. It needs to include the final LINK instruction. This was seen on imx6q, and the fix is confirmed to stop the GPU hangs. The commit referenced inadvertently fixed this issue by checking gpu->mmu->need_flush once at the start of the function. Given that this commit is independant, and useful for all version, it seems sensible to backport it to the stable branches.