From patchwork Tue Jan 12 21:23:47 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?TWFyZWsgT2zFocOhaw==?= X-Patchwork-Id: 8020991 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 93E169F859 for ; Tue, 12 Jan 2016 21:24:09 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B6DFF20412 for ; Tue, 12 Jan 2016 21:24:08 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 7C9F820416 for ; Tue, 12 Jan 2016 21:24:07 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 172AD72005; Tue, 12 Jan 2016 13:24:06 -0800 (PST) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wm0-f66.google.com (mail-wm0-f66.google.com [74.125.82.66]) by gabe.freedesktop.org (Postfix) with ESMTPS id 7590D6E42E for ; Tue, 12 Jan 2016 13:24:04 -0800 (PST) Received: by mail-wm0-f66.google.com with SMTP id f206so33460945wmf.2 for ; Tue, 12 Jan 2016 13:24:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-type:content-transfer-encoding; bh=c0UaLCVKYyVs+gSUy7YhxzoqkBQrW4z0ZLTemHVznx0=; b=K9/oFH2EQcIVCN+AZvVjx7BTTqpA3A+tDDPnUVtZNgRRI/nx9l7tAjE375TFOsvmfI sD+LhMBorjtsqQTZOhhyU7TRgyz8fudMtmpuO5ea2xqqecmdAK7RHaNDwCK0wMqce4og RBjCt4AqROmmsMIdviScgi5C2g4BInO8Xpl6O81LfOS9atUcnsBClTLCHhuqZLm//QKW 8TsWrNiPB5T5EUCuxLH+5FcEPKmwaAJw9R/NCWwoaJl3f1IPG5lGK05twK3Ii+U/GsPT AlG4PkcEDUtSCv0zcm4sD8fRACUM9lO/Hg5HO4nY+ndYHmncOyZF7lvwuAGR8j4kQZqZ rlpA== X-Received: by 10.194.90.50 with SMTP id bt18mr141914871wjb.118.1452633842926; Tue, 12 Jan 2016 13:24:02 -0800 (PST) Received: from heaven.amd.com (ip-89-103-110-3.net.upcbroadband.cz. [89.103.110.3]) by smtp.gmail.com with ESMTPSA id n5sm19291001wmf.3.2016.01.12.13.24.02 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 12 Jan 2016 13:24:02 -0800 (PST) From: =?UTF-8?q?Marek=20Ol=C5=A1=C3=A1k?= To: dri-devel@lists.freedesktop.org Subject: [PATCH 01/10] Revert "amdgpu: remove sequence mutex" Date: Tue, 12 Jan 2016 22:23:47 +0100 Message-Id: <1452633836-26855-2-git-send-email-maraeo@gmail.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1452633836-26855-1-git-send-email-maraeo@gmail.com> References: <1452633836-26855-1-git-send-email-maraeo@gmail.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, 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: Marek Olšák This reverts commit f6f25d67a9c0d26be9b8021a45f2acf3a4042ade. Required by the new semaphore patches. --- amdgpu/amdgpu_cs.c | 10 ++++++++++ amdgpu/amdgpu_internal.h | 3 +++ 2 files changed, 13 insertions(+) diff --git a/amdgpu/amdgpu_cs.c b/amdgpu/amdgpu_cs.c index 6747158..511d53f 100644 --- a/amdgpu/amdgpu_cs.c +++ b/amdgpu/amdgpu_cs.c @@ -66,6 +66,10 @@ int amdgpu_cs_ctx_create(amdgpu_device_handle dev, gpu_context->dev = dev; + r = pthread_mutex_init(&gpu_context->sequence_mutex, NULL); + if (r) + goto error; + /* Create the context */ memset(&args, 0, sizeof(args)); args.in.op = AMDGPU_CTX_OP_ALLOC_CTX; @@ -79,6 +83,7 @@ int amdgpu_cs_ctx_create(amdgpu_device_handle dev, return 0; error: + pthread_mutex_destroy(&gpu_context->sequence_mutex); free(gpu_context); return r; } @@ -99,6 +104,8 @@ int amdgpu_cs_ctx_free(amdgpu_context_handle context) if (NULL == context) return -EINVAL; + pthread_mutex_destroy(&context->sequence_mutex); + /* now deal with kernel side */ memset(&args, 0, sizeof(args)); args.in.op = AMDGPU_CTX_OP_FREE_CTX; @@ -196,6 +203,8 @@ static int amdgpu_cs_submit_one(amdgpu_context_handle context, chunk_data[i].ib_data.flags = ib->flags; } + pthread_mutex_lock(&context->sequence_mutex); + if (user_fence) { i = cs.in.num_chunks++; @@ -248,6 +257,7 @@ static int amdgpu_cs_submit_one(amdgpu_context_handle context, ibs_request->seq_no = cs.out.handle; error_unlock: + pthread_mutex_unlock(&context->sequence_mutex); free(dependencies); return r; } diff --git a/amdgpu/amdgpu_internal.h b/amdgpu/amdgpu_internal.h index 7dd5c1c..5d86603 100644 --- a/amdgpu/amdgpu_internal.h +++ b/amdgpu/amdgpu_internal.h @@ -111,6 +111,9 @@ struct amdgpu_bo_list { struct amdgpu_context { struct amdgpu_device *dev; + /** Mutex for accessing fences and to maintain command submissions + in good sequence. */ + pthread_mutex_t sequence_mutex; /* context id*/ uint32_t id; };