From patchwork Fri May 6 20:59:24 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Alex Deucher X-Patchwork-Id: 9036221 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 3CA9CBF29F for ; Fri, 6 May 2016 20:59:40 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 21AA3203B4 for ; Fri, 6 May 2016 20:59:37 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 398CB20219 for ; Fri, 6 May 2016 20:59:36 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 6BCFE6E169; Fri, 6 May 2016 20:59:35 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-qg0-x236.google.com (mail-qg0-x236.google.com [IPv6:2607:f8b0:400d:c04::236]) by gabe.freedesktop.org (Postfix) with ESMTPS id C2A4C6E169 for ; Fri, 6 May 2016 20:59:33 +0000 (UTC) Received: by mail-qg0-x236.google.com with SMTP id w36so62833242qge.3 for ; Fri, 06 May 2016 13:59:33 -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:mime-version :content-transfer-encoding; bh=YTXvWe11hIDfEcMMob8G2HA/2bS5dk5Xw8qiNLvVEe0=; b=SbY3O/f7g2JLW5naKGaSDsYB06+TT3zEMAOFuBNG6Ojb//qac/bQs0M4dAylplDv65 SJkv0MpSfkmJfUpPETmou40Ypa2fcYlS23VGnpVtnlkDzZkBCbOXUdUPzC8FQpHvpmUG JACTNoqKDVUyYmy+FOiurxnbHe4ao9IS6VK064G60ioeiyJMCaODJuTRF2l0ieUMXeWj UYG//9OKM1C3gFifi4yb2qiDWFWOl7t/j9MqEMPYuz5Ndxpburbc61sJqXHMD+4JRPpc +ql4koTHxs3lDrQ+CSTWgR0C9IMt24xj2GBG1Kx2yuGtMedm6KJmDaTox+qmHZALBF55 WaYA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=YTXvWe11hIDfEcMMob8G2HA/2bS5dk5Xw8qiNLvVEe0=; b=NxINkabVlZkal2w7XG2vtLle93fjvi+j4O47DfqOmIwnLRPGNQs7NaEJr6dKHKQI7O RORxuZ0Fa3l1PzHUoB4k8fl/wS5lGM1Iuw3dYpkRU7nkJZqywqDOdwY5XvE+UlIjPoAu cuoF3/emHDhPgTqfYCyy12suJhPtRdjUBtCkEhB78pZXFRPSG2hIyZ8m7cJoDH76tKGX 8bw3beo4hqAVMkcNEWCvy9ghJiPLOzhWs0ESruAgO+zkaP+vGJjlNLu2eRf8McLICYlN OFcnKPgn5YC5GJLtsV50kCRjZHfGHH+n6YeGUL5rVwK5GW7PsjWMkUKQDsmlZCsWh0EO Wjrg== X-Gm-Message-State: AOPr4FV6pmlQSjdcjDnzqOIA/4Di6Cu3DW5WvyNrP4uyCvM7mI+TZxYSlcaQG/ALRj8NtA== X-Received: by 10.140.37.35 with SMTP id q32mr22175855qgq.17.1462568372812; Fri, 06 May 2016 13:59:32 -0700 (PDT) Received: from cm.localdomain (static-74-96-105-49.washdc.fios.verizon.net. [74.96.105.49]) by smtp.gmail.com with ESMTPSA id b18sm6561222qkc.9.2016.05.06.13.59.31 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 06 May 2016 13:59:32 -0700 (PDT) From: Alex Deucher X-Google-Original-From: Alex Deucher To: dri-devel@lists.freedesktop.org Subject: [PATCH] drm/amdgpu: use fence_context to judge ctx switch v2 Date: Fri, 6 May 2016 16:59:24 -0400 Message-Id: <1462568365-13734-1-git-send-email-alexander.deucher@amd.com> X-Mailer: git-send-email 2.5.5 MIME-Version: 1.0 Cc: Alex Deucher , =?UTF-8?q?Christian=20K=C3=B6nig?= 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=-6.2 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, T_DKIM_INVALID, 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: Christian König Use of the ctx pointer is not safe, because they are likely already be assigned to another ctx when doing comparing. v2: recreate from scratch, avoid all unnecessary changes. Signed-off-by: Christian König Reviewed-by: Monk.Liu Signed-off-by: Alex Deucher --- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 4 ++-- drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 2 +- drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h b/drivers/gpu/drm/amd/amdgpu/amdgpu.h index 1a3ad8f..ed952f5 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h @@ -743,7 +743,7 @@ struct amdgpu_ib { struct amdgpu_user_fence *user; unsigned vm_id; uint64_t vm_pd_addr; - struct amdgpu_ctx *ctx; + uint64_t ctx; uint32_t gds_base, gds_size; uint32_t gws_base, gws_size; uint32_t oa_base, oa_size; @@ -806,7 +806,7 @@ struct amdgpu_ring { unsigned wptr_offs; unsigned next_rptr_offs; unsigned fence_offs; - struct amdgpu_ctx *current_ctx; + uint64_t current_ctx; enum amdgpu_ring_type type; char name[16]; unsigned cond_exe_offs; diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c index 1a06596..87ec113 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c @@ -741,7 +741,7 @@ static int amdgpu_cs_ib_fill(struct amdgpu_device *adev, ib->length_dw = chunk_ib->ib_bytes / 4; ib->flags = chunk_ib->flags; - ib->ctx = parser->ctx; + ib->ctx = parser->ctx->rings[ring->idx].entity.fence_context; j++; } diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c index 9105561..f670519 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c @@ -121,7 +121,7 @@ int amdgpu_ib_schedule(struct amdgpu_ring *ring, unsigned num_ibs, { struct amdgpu_device *adev = ring->adev; struct amdgpu_ib *ib = &ibs[0]; - struct amdgpu_ctx *ctx, *old_ctx; + uint64_t ctx, old_ctx; struct fence *hwf; struct amdgpu_vm *vm = NULL; unsigned i, patch_offset = ~0;