Received: by 2002:a17:90b:8d0:0:0:0:0 with SMTP id ds16csp4881677pjb; Mon, 27 Jul 2020 07:30:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzO/i9ngy9wK0FIzqaw9NaLkJ5gzIbseerJ2pSHHRqLimwVRuUALsHR+y14S2cfo/wbsu+y X-Received: by 2002:a05:6402:1606:: with SMTP id f6mr2398986edv.328.1595860228856; Mon, 27 Jul 2020 07:30:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595860228; cv=none; d=google.com; s=arc-20160816; b=CYt5Bn6iDGEOR1p5GNafDiphqCpZy1YpmOnDOdk1LV49llvraLpKef0z1FnE1vS2ws sMTmiMVP8SA600uw/ik/CmbVMvbShcDbD/y6A9wZWtTiNRYzX5Ym91gsrYX82iRPFLma VY7WHqiFy66Zb6O0ahdTIHCRDzKvKFX9HqM1vFi6vMjTlGbFYuxhb66hZtfFlJHSi9je nXyd8nCxprmsJ0LPIEkXnoiT5pctryMFwO+wPHQuSC2mW8pERMKEKM8thsbEDFOss0at ZauY5aJcF2ngG8Qh0ObjFNgRmawKztFifSxIHL8SoMtFXs7ULla33Xqeqf99/B5Nreki YVhQ== 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=8LaSAwbLrdH2Ib+Cmwth+xk7FZ00FZ+MYAA4G9IHI/o=; b=OVxXwy7SXE5/HWOAZzdW0QDHEgB3/zEn8yS3Ara3+HXTC97B6+WDgY5hdEBS0ApNG0 1V1B69cvRl0EHkYjmnHFlD9TOd6+ybrpi4MwzmHbagdZWumrGivJDNDQY7XB2bEPEDow k4o653RMGDGv8x84urIjMtP0KJ16O9oGAqglpkwIVvwy/IVlzUOHDcU6z/toqWk3VMDE fZbSvm9Il4+5cjxlopTYURGNSgVUOFuvguPNxCLP36QYpjxbI4q3sYYynX+kpLvv/6Ab I/Pfytp11UDFyLtvEFG7Jr0p3k+RrRSKCGI8rqWhsputnrIbuLGkIIF7DD5f9lwAyP5o p2VQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=OX4Fxisv; 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 gl25si2792418ejb.424.2020.07.27.07.30.06; Mon, 27 Jul 2020 07:30:28 -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=OX4Fxisv; 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 S1731569AbgG0OYB (ORCPT + 99 others); Mon, 27 Jul 2020 10:24:01 -0400 Received: from mail.kernel.org ([198.145.29.99]:53376 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731505AbgG0OYA (ORCPT ); Mon, 27 Jul 2020 10:24:00 -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 464832083E; Mon, 27 Jul 2020 14:23:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1595859839; bh=/r7CpAbdOGh79gtbW0/Th7l8+bvwG0+jXqRwWEGze1g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OX4FxisvemN5XOKTiH/s0A/hlJZ9hxVu/JLVk/V5JTkbu7lDL/JBRdfGYyBVgnf2j jgxZjHg+Poh7862qamRlG166jhlIMm4xzuz8crPKu7plQQ1JPgkLtWxi5iqa2A++Am ZpsYWenvGe1XiP22N+IXPBRbCmDAdrFEjQZ2Tu4M= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jack Xiao , Hawking Zhang , Alex Deucher , Sasha Levin Subject: [PATCH 5.7 126/179] drm/amdgpu: fix preemption unit test Date: Mon, 27 Jul 2020 16:05:01 +0200 Message-Id: <20200727134938.786732517@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 d845a2051b6b673fab4229b920ea04c7c4352b51 ] Remove signaled jobs from job list and ensure the job was indeed preempted. Signed-off-by: Jack Xiao Reviewed-by: Hawking Zhang Signed-off-by: Alex Deucher Signed-off-by: Sasha Levin --- drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c index c0f9a651dc067..92b18c4760e55 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c @@ -1156,27 +1156,37 @@ static void amdgpu_ib_preempt_job_recovery(struct drm_gpu_scheduler *sched) static void amdgpu_ib_preempt_mark_partial_job(struct amdgpu_ring *ring) { struct amdgpu_job *job; - struct drm_sched_job *s_job; + struct drm_sched_job *s_job, *tmp; uint32_t preempt_seq; struct dma_fence *fence, **ptr; struct amdgpu_fence_driver *drv = &ring->fence_drv; struct drm_gpu_scheduler *sched = &ring->sched; + bool preempted = true; if (ring->funcs->type != AMDGPU_RING_TYPE_GFX) return; preempt_seq = le32_to_cpu(*(drv->cpu_addr + 2)); - if (preempt_seq <= atomic_read(&drv->last_seq)) - return; + if (preempt_seq <= atomic_read(&drv->last_seq)) { + preempted = false; + goto no_preempt; + } preempt_seq &= drv->num_fences_mask; ptr = &drv->fences[preempt_seq]; fence = rcu_dereference_protected(*ptr, 1); +no_preempt: spin_lock(&sched->job_list_lock); - list_for_each_entry(s_job, &sched->ring_mirror_list, node) { + list_for_each_entry_safe(s_job, tmp, &sched->ring_mirror_list, node) { + if (dma_fence_is_signaled(&s_job->s_fence->finished)) { + /* remove job from ring_mirror_list */ + list_del_init(&s_job->node); + sched->ops->free_job(s_job); + continue; + } job = to_amdgpu_job(s_job); - if (job->fence == fence) + if (preempted && job->fence == fence) /* mark the job as preempted */ job->preemption_status |= AMDGPU_IB_PREEMPTED; } -- 2.25.1