Received: by 2002:a25:b323:0:0:0:0:0 with SMTP id l35csp918790ybj; Fri, 20 Sep 2019 02:05:07 -0700 (PDT) X-Google-Smtp-Source: APXvYqymktbjLqMjlDkC4co+x2bMgrsYRX4Vm2ATKvqB6tr3hPNTWVniEJ6/E6ELxXiFNchwnoaC X-Received: by 2002:a17:906:944b:: with SMTP id z11mr17635943ejx.46.1568970306864; Fri, 20 Sep 2019 02:05:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1568970306; cv=none; d=google.com; s=arc-20160816; b=VeYb8uye06ZK9qBCOHBeQem5BAnYx3BZZ9WSIAcHCDZmywhvfc1r98+DRX4FcNeYhc X2fgIPe6M8jG6a2n0fU2qeLOwuZ20gBcn5J8GxL9RhEAlvjuhFBWjDBmnQRAu2/u8Ke7 L7ibKe1HKmdEWRB1KwKwcYhVeAdvXm7dZ1b4DxzfL5F+7+IrZ4oWODzFUCjOPH3SFjsn pM3KFM66hApbsIOHHiF7hphl3PTMB9ZNSJhSHmzUOCNNVoaFUSROaDeK1skpvqOS6xD8 M2ZfO8K+v8/ewiJqZ6g5fZKAhOkFab0kevCigs6hbB8z7ntMt2A4HXZUdpJ5+Nm61QWT B6HA== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=BDdCF+0Y2l+0ilivfFiu3BFsKgQMtvHkEu1eg1Ha2ms=; b=iYb2DaWNhozBtbf4ZkMv1yvnughrU2Z2jHC0GbeNNhtU3bL+5LEYX6CwduJ8UKu2DE +8NMYlLEeW1TXRIjnQmlKkcPger1BEfUmGtNoYZjkHCZQlRXmS7tnjhQxCXAfQIoMMFX bVITlHqr9OYdhfq6Sx0AxkEWShzHp6Zi2MXMu8b+OVSSFsIdzW1+LqziFnVNa+vpn7Xf rvAYizAJZQJrMY+BQTl8enQMDN9W8JAicDIWUviHy+vAmD3XeMXLcMFDalZ32CVRrWny j1qSy8ESHuPH+6JVyRI2eSZgLLhxeqzv3q/ZNc2BJhys2GLdOw3tozn+DlCdxqiIwF9D Uabg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=cvKeejTT; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u3si718735ejj.47.2019.09.20.02.04.43; Fri, 20 Sep 2019 02:05:06 -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; dkim=pass header.i=@kernel.org header.s=default header.b=cvKeejTT; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2405541AbfISWJy (ORCPT + 99 others); Thu, 19 Sep 2019 18:09:54 -0400 Received: from mail.kernel.org ([198.145.29.99]:48138 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2405493AbfISWJt (ORCPT ); Thu, 19 Sep 2019 18:09:49 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 5D8B221920; Thu, 19 Sep 2019 22:09:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1568930989; bh=0dd297o4/giydwwbHGYujD6FY22aEiS50RVYkQurEz0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cvKeejTT6lrGGyaGwh7J//EflkC81YARduYZo4E1NlndZPda8uXrcauoQRWs+EQUs DUliRSa5AkBpQIEWUsev3u3cI+BskwBKohDPxVL8dL11YS9DMSgMFHIDwrEHr+WwrX dmPVcGyUfPSOVHuFpaXYoGgPogbDhlrwGv7pMf3Y= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, =?UTF-8?q?Christian=20K=C3=B6nig?= , Chunming Zhou , Alex Deucher , Sasha Levin Subject: [PATCH 5.2 070/124] drm/amdgpu: fix dma_fence_wait without reference Date: Fri, 20 Sep 2019 00:02:38 +0200 Message-Id: <20190919214821.543026211@linuxfoundation.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20190919214819.198419517@linuxfoundation.org> References: <20190919214819.198419517@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Christian König [ Upstream commit 42068e1ef961c719f967dbbb4ddcb394a0ba7917 ] We need to grab a reference to the fence we wait for. Signed-off-by: Christian König Reviewed-by: Chunming Zhou Signed-off-by: Alex Deucher Signed-off-by: Sasha Levin --- drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c | 27 ++++++++++++++----------- 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c index a28a3d722ba29..62298ae5c81c0 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c @@ -535,21 +535,24 @@ int amdgpu_ctx_wait_prev_fence(struct amdgpu_ctx *ctx, struct drm_sched_entity *entity) { struct amdgpu_ctx_entity *centity = to_amdgpu_ctx_entity(entity); - unsigned idx = centity->sequence & (amdgpu_sched_jobs - 1); - struct dma_fence *other = centity->fences[idx]; + struct dma_fence *other; + unsigned idx; + long r; - if (other) { - signed long r; - r = dma_fence_wait(other, true); - if (r < 0) { - if (r != -ERESTARTSYS) - DRM_ERROR("Error (%ld) waiting for fence!\n", r); + spin_lock(&ctx->ring_lock); + idx = centity->sequence & (amdgpu_sched_jobs - 1); + other = dma_fence_get(centity->fences[idx]); + spin_unlock(&ctx->ring_lock); - return r; - } - } + if (!other) + return 0; - return 0; + r = dma_fence_wait(other, true); + if (r < 0 && r != -ERESTARTSYS) + DRM_ERROR("Error (%ld) waiting for fence!\n", r); + + dma_fence_put(other); + return r; } void amdgpu_ctx_mgr_init(struct amdgpu_ctx_mgr *mgr) -- 2.20.1