Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp687785imu; Fri, 21 Dec 2018 05:56:19 -0800 (PST) X-Google-Smtp-Source: ALg8bN66Sz1hO3C4FLKTHr/aCSmA0Mv4VEK0bxMVOWO6IQSsbF2MLqFckNo+g92TQwTfJlVJrdXd X-Received: by 2002:a17:902:c85:: with SMTP id 5mr2655260plt.339.1545400579428; Fri, 21 Dec 2018 05:56:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1545400579; cv=none; d=google.com; s=arc-20160816; b=o9ssebKDXmUDc8r5iNAlfB96m1L9xKFbxW66DyUqThtcRQySRCB/DADH4YwQN4QOKK D7FHfhlv+EM9tkBWUvjb96CB7L6+vf5shlX98gLO7aP4QHcFai0RvJ6Fl+qSz79CG8Sa tbsNvdToobs3aO4O9PTfJbccrlsG/W5UJgV4gjCRGbFjCO5DLLRE8VkryqKuVsPExG4M GsXnx+sTTgGgjfQhiGfM24mIIHg6YTtjRh64tQXdMKshUXVzF6sLyepmJTxdK+dAWMF0 S9K59731G3PJE1A4jqi9625NgsTw7UAIA/LK4b/qxKzk4bK9Vee9V8C7twU90GgUEBNv F43A== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=X+xX+MqEK7IDeX3e/VhfbhjprkZLCa8jN8mKsj/JF/w=; b=JrHqVWvYf7lrRKPeAqpcOc5gS1Tf7VEFUA3qC6lU+F4ANkai+0C1eTrqPCzD1DL2vl 0qG8OJnn613MY7tbRjabPDWv2qzEnCrzVPklP7HvyFAzP1CDbhqPeYXumXxaY4Q7uuxb Y/p5P46m5z9py0oPBhnbb7wVMQY/AXM53i2fiWFKNMdkAcvFFJ6lZkrhheq1Fzr8p8/s 2mkJqrz0uEbb9M6WqgRst3jFqai/B0+vp38+MmmHWn/Kvh1vDKXOxg2mfHuhHmBt3N3p qYMvavXrR2pwsoAGSFS2LDaUAWOk85iHt1LCNPRVOtW0vA2oZOsVp1CdliqKYesqB36k HXSQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=WyXMgn5N; 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=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k13si4982832pgb.343.2018.12.21.05.56.01; Fri, 21 Dec 2018 05:56:19 -0800 (PST) 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; dkim=pass header.i=@google.com header.s=20161025 header.b=WyXMgn5N; 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=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388940AbeLUDLL (ORCPT + 99 others); Thu, 20 Dec 2018 22:11:11 -0500 Received: from mail-io1-f67.google.com ([209.85.166.67]:35552 "EHLO mail-io1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732778AbeLUDLL (ORCPT ); Thu, 20 Dec 2018 22:11:11 -0500 Received: by mail-io1-f67.google.com with SMTP id o13so1166634ioh.2 for ; Thu, 20 Dec 2018 19:11:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=X+xX+MqEK7IDeX3e/VhfbhjprkZLCa8jN8mKsj/JF/w=; b=WyXMgn5NZ+K2ZjWD10DVqJiPu2XwUjEteRFhxG65cWSK7Qb10P1sb41EZE+uN4MGbQ 4BQIlnTrPh/X6XdnfIuvjcfNvLeIIAXs3XxsdBzqwHx1iDFjHCrwN+5ekOoaQrOTy1vl jiECzWGgUOwUaNP/PWX3XlVNSHMKIAcIP9tAtCZdb7hIwx/mN/HrwehaIiZn2/Oxf84y fFsGqUqe9qVDG37f6vNT7e5r96GfotD+kk+7kwLnfaH7ONw+EaIFCrLUdqcfCZTnqdfp DgHNOplrWFbFTAcDsf/G3yr4+CuBR40/HLtuM6KLOHhGTDLNU+5+9lDxfYGnzYN9qQPf R4EA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=X+xX+MqEK7IDeX3e/VhfbhjprkZLCa8jN8mKsj/JF/w=; b=P5b7vrFxQ66SqOTHnJHeWUSeARnq+ccxc9dtk0i55AvKLjjM+WMHFkqPjO1WzGJGCr TRMJfs2yhZoOVilMHF2UrNvFASQZjqTZau9SPLNmz2zUdZIk7V4l0/e1YcOS9x6HY+ya KeK6UaiSEWdDJlIiEZexaPXUen2DUylNBE/JY/mfLBDUhgkbitNtvY0we9So5sXpMOMu DXGEZZ7Z8t0sZpzH9H7cjA29DD+QOjL3qCruL9ViAm9IgFh5aUcw5g6QNnTWkWlcpXir nacEGRaR/8ajCxBEYMGCHYs81pM1O2cNVWmZyBG4j6Mv2PlbMP/J5Y+tVT4U0WALZ6p5 zMTg== X-Gm-Message-State: AJcUukfGxsy147uND6EOCH5rgjfXSN57RAr3yRzciD5dsnz5u95Lh7T+ 8kc0V0LcJPszvhmyAf3qE0PtuA== X-Received: by 2002:a6b:ca04:: with SMTP id a4mr620646iog.254.1545361869102; Thu, 20 Dec 2018 19:11:09 -0800 (PST) Received: from yuzhao.bld.corp.google.com ([2620:15c:183:0:a0c3:519e:9276:fc96]) by smtp.gmail.com with ESMTPSA id d133sm5425783itd.1.2018.12.20.19.11.08 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 20 Dec 2018 19:11:08 -0800 (PST) From: Yu Zhao To: David Airlie , Daniel Vetter , =?UTF-8?q?Christian=20K=C3=B6nig?= , Alex Deucher Cc: David Zhou , Samuel Li , Harry Wentland , Junwei Zhang , Daniel Stone , amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Yu Zhao Subject: [PATCH 1/3] drm/amd: fix race in page flip job Date: Thu, 20 Dec 2018 20:10:51 -0700 Message-Id: <20181221031053.240161-1-yuzhao@google.com> X-Mailer: git-send-email 2.20.1.415.g653613c723-goog 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 Fix race between page flip job submission and completion. We invoke page_flip callback to submit page flip job to GPU first and then set pflip_status. If GPU fires page flip done irq in between, its handler won't see the correct pflip_status thus will refuse to notify the job completion. The job will eventually times out. Reverse the order of calling page_flip and setting pflip_status to fix the race. Signed-off-by: Yu Zhao --- drivers/gpu/drm/amd/amdgpu/amdgpu_display.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c index 686a26de50f9..e309d26170db 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c @@ -105,11 +105,11 @@ static void amdgpu_display_flip_work_func(struct work_struct *__work) /* We borrow the event spin lock for protecting flip_status */ spin_lock_irqsave(&crtc->dev->event_lock, flags); + /* Set the flip status */ + amdgpu_crtc->pflip_status = AMDGPU_FLIP_SUBMITTED; /* Do the flip (mmio) */ adev->mode_info.funcs->page_flip(adev, work->crtc_id, work->base, work->async); - /* Set the flip status */ - amdgpu_crtc->pflip_status = AMDGPU_FLIP_SUBMITTED; spin_unlock_irqrestore(&crtc->dev->event_lock, flags); -- 2.20.1.415.g653613c723-goog