Received: by 2002:a17:90b:8d0:0:0:0:0 with SMTP id ds16csp4883362pjb; Mon, 27 Jul 2020 07:32:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy7qgrGmsAE4WJdKoIQ7whXVvj3POFvwaXnjwct6znNo1tioxEPs9YdYbuyxTjSwzgFygV+ X-Received: by 2002:a17:906:4341:: with SMTP id z1mr20884841ejm.392.1595860353196; Mon, 27 Jul 2020 07:32:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595860353; cv=none; d=google.com; s=arc-20160816; b=KZmpa3bcwVYM55KU0NVPtK1fXAqOcC/tTLyD5BGuXAV3HlsF9eVBWT+gFuGBKjR1fS GLpCKQYm/ykbn6rQNSRSVmrD77x+Of/Va7lRUbgd3KrPc3NiFb/WtePXi7skwdKdORHE XF0t0CB787z5XYKcaPb2FqRIBRM9/leXly1J3+q0y/lEYcTqFTgddTqTyPHioR23oKd7 WDGITOb8cygRpJ6p/Ft0Uwtbtmr/fm4pZUKL4WJqzuDZw3hgd/u7QrWiwNupKb1RBDzM +QhlagCxl6uyajYV3Y3vhEXMURKjKGIo4+1uNwJ1qAppiOpbLsfHfOXGHgC4waF2cZLP V4rQ== 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=D8bYjLifNtpwzoHHPK7vbNLXeUxwRfEHPxvildK918o=; b=gCx7a8VKydA6YlC+/y26VwBig3evkJsR15+VOFIU0tPop/XNsTLpXQog3bdJj0mBGL 5jjW79yVBoNr5IuGSWsYqyR2/KV55d3Z/q2s8s0JgtzvPggyDs54M2cKCoHo/wO6ZCMR pIhfwi0+mkKhEfsNcHXU0RhSRfBWDonpjgLOKpFaqzLBZKiwdJGjfLKoZQjvAyZJReVB RME3eM697khPkNcgBFOE0GIXdOX+HcFnHumPt+n17n5GiYcymktGieqdbuwZy23fXIsS JqqibYsnfguo0EwS+B5M21yKsbZft2VhLTYHW4bf89R+XVpB0tFB088CIyfIdUmnO/2P FLiQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Ge2B4eU9; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id o29si1434030edz.62.2020.07.27.07.32.11; Mon, 27 Jul 2020 07:32:33 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Ge2B4eU9; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729376AbgG0O27 (ORCPT + 99 others); Mon, 27 Jul 2020 10:28:59 -0400 Received: from mail.kernel.org ([198.145.29.99]:53354 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732183AbgG0OX5 (ORCPT ); Mon, 27 Jul 2020 10:23:57 -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 B544D21D95; Mon, 27 Jul 2020 14:23:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1595859837; bh=0EJWnODGD4TNz5brZBkLw/E00QZ4S2pmfWX1+6zrt28=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Ge2B4eU90kbtnj3jOzAv4ISvjwbun1d3AXkQUHDQUDjUT5L58WdehQBssvaDfMvT8 JDIPwmdSEsx0WM8zcMuvgHd0+oD8o9ueX7MFSsaA2bpEGN5Q+lmxGCALHdVV2G41Pq FG9YJeKQ9wJ/VId5jk4K5GsSf5HO+VOxrhX8EaKY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jack Xiao , Hawking Zhang , =?UTF-8?q?Christian=20K=C3=B6nig?= , Alex Deucher , Sasha Levin Subject: [PATCH 5.7 125/179] drm/amdgpu/gfx10: fix race condition for kiq Date: Mon, 27 Jul 2020 16:05:00 +0200 Message-Id: <20200727134938.739260444@linuxfoundation.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200727134932.659499757@linuxfoundation.org> References: <20200727134932.659499757@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: Jack Xiao [ Upstream commit 7d65a577bb58d4f27a3398a4c0cb0b00ab7d0511 ] During preemption test for gfx10, it uses kiq to trigger gfx preemption, which would result in race condition with flushing TLB for kiq. Signed-off-by: Jack Xiao Reviewed-by: Hawking Zhang Acked-by: Christian König Signed-off-by: Alex Deucher Signed-off-by: Sasha Levin --- drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c b/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c index 0e0daf0021b60..ff94f756978d5 100644 --- a/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c +++ b/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c @@ -4746,12 +4746,17 @@ static int gfx_v10_0_ring_preempt_ib(struct amdgpu_ring *ring) struct amdgpu_device *adev = ring->adev; struct amdgpu_kiq *kiq = &adev->gfx.kiq; struct amdgpu_ring *kiq_ring = &kiq->ring; + unsigned long flags; if (!kiq->pmf || !kiq->pmf->kiq_unmap_queues) return -EINVAL; - if (amdgpu_ring_alloc(kiq_ring, kiq->pmf->unmap_queues_size)) + spin_lock_irqsave(&kiq->ring_lock, flags); + + if (amdgpu_ring_alloc(kiq_ring, kiq->pmf->unmap_queues_size)) { + spin_unlock_irqrestore(&kiq->ring_lock, flags); return -ENOMEM; + } /* assert preemption condition */ amdgpu_ring_set_preempt_cond_exec(ring, false); @@ -4762,6 +4767,8 @@ static int gfx_v10_0_ring_preempt_ib(struct amdgpu_ring *ring) ++ring->trail_seq); amdgpu_ring_commit(kiq_ring); + spin_unlock_irqrestore(&kiq->ring_lock, flags); + /* poll the trailing fence */ for (i = 0; i < adev->usec_timeout; i++) { if (ring->trail_seq == -- 2.25.1