From patchwork Wed May 27 03:19:55 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Alex Deucher X-Patchwork-Id: 6486701 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id BA43BC0020 for ; Wed, 27 May 2015 03:20:56 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id E1FE4206FF for ; Wed, 27 May 2015 03:20:55 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id ED0C620705 for ; Wed, 27 May 2015 03:20:54 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 6E3B16E8DF; Tue, 26 May 2015 20:20:52 -0700 (PDT) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-qg0-f42.google.com (mail-qg0-f42.google.com [209.85.192.42]) by gabe.freedesktop.org (Postfix) with ESMTP id 44C126E8D8 for ; Tue, 26 May 2015 20:20:51 -0700 (PDT) Received: by qgf2 with SMTP id 2so40272562qgf.3 for ; Tue, 26 May 2015 20:20:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-type:content-transfer-encoding; bh=5XdcFeHQf5mmhDsLLEW+pQ9UZplGn+sDlwETyxN+pOo=; b=FtmMeX+X+z0WOtLLZyzCLxBOMz0zRjYTcUQr3I8/GXB0xnEZTUaYH8e91RyBdSzODS Mvsk5b0K/+v6HVu2ok7btqk426DU0BBoYzJLhHWfunztDzQIQUIqJtX3OGHHc8npUxmC GkRCaWcDmqs5hW39hxDVawpeL/H1CCkdjPEY00nXVJCVIg4Q+vmnv/kSx4Bspb0iWvfx g5dCoDk5U0OluNElBS1rKSbtiEoW8bzeSldk7BGqHs7y2Rhn9Kbh7XlTzR8U9wy563dZ b3Al3FNIqOs8y73yicO5EuQMwIASaqJEOVa1NnnlMwxtK+bfFfKo6CfOYojic6z55xQI FTIw== X-Received: by 10.55.24.167 with SMTP id 39mr61869665qky.43.1432696850987; Tue, 26 May 2015 20:20:50 -0700 (PDT) Received: from localhost.localdomain (static-74-96-105-49.washdc.fios.verizon.net. [74.96.105.49]) by mx.google.com with ESMTPSA id 20sm9629127qhf.14.2015.05.26.20.20.50 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 26 May 2015 20:20:50 -0700 (PDT) From: Alex Deucher X-Google-Original-From: Alex Deucher To: dri-devel@lists.freedesktop.org Subject: [PATCH 56/88] drm/amdgpu: check context id for context switching (v2) Date: Tue, 26 May 2015 23:19:55 -0400 Message-Id: <1432696827-3752-26-git-send-email-alexander.deucher@amd.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1432696827-3752-1-git-send-email-alexander.deucher@amd.com> References: <1432696827-3752-1-git-send-email-alexander.deucher@amd.com> MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Spam-Status: No, score=-4.1 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, T_DKIM_INVALID, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Jammy Zhou check the filp is not robust, and sometimes different contexts may have same filp value. v2: check both filp and ctx_id Signed-off-by: Jammy Zhou Reviewed-by: Christian König --- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 1 + drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h b/drivers/gpu/drm/amd/amdgpu/amdgpu.h index bf0c607..a88302c 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h @@ -945,6 +945,7 @@ struct amdgpu_ring { unsigned next_rptr_offs; unsigned fence_offs; struct drm_file *current_filp; + unsigned current_ctx; bool need_ctx_switch; enum amdgpu_ring_type type; char name[16]; diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c index 86b9324..1035e44 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c @@ -642,8 +642,10 @@ static int amdgpu_cs_ib_fill(struct amdgpu_device *adev, ib->is_const_ib = true; if (chunk_ib->flags & AMDGPU_IB_FLAG_GDS) ib->gds_needed = true; - if (ib->ring->current_filp != parser->filp) { + if ((ib->ring->current_filp != parser->filp) || + (ib->ring->current_ctx != parser->ctx_id)) { ib->ring->need_ctx_switch = true; + ib->ring->current_ctx = parser->ctx_id; ib->ring->current_filp = parser->filp; }