From patchwork Fri Nov 17 10:49:29 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Christian_K=C3=B6nig?= X-Patchwork-Id: 10062637 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 762CC6023A for ; Fri, 17 Nov 2017 10:49:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6D3752A847 for ; Fri, 17 Nov 2017 10:49:48 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5EA932A845; Fri, 17 Nov 2017 10:49:48 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id F06972A845 for ; Fri, 17 Nov 2017 10:49:47 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 24BE76E2F9; Fri, 17 Nov 2017 10:49:45 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wr0-x244.google.com (mail-wr0-x244.google.com [IPv6:2a00:1450:400c:c0c::244]) by gabe.freedesktop.org (Postfix) with ESMTPS id 415456E30C; Fri, 17 Nov 2017 10:49:44 +0000 (UTC) Received: by mail-wr0-x244.google.com with SMTP id w95so1743765wrc.2; Fri, 17 Nov 2017 02:49:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=ykxoXC+kG2bfAsp3HMaBO2vDfAxm/NiyS8XOVoqcYqc=; b=jHIWu9rUPCIidl+fYMg0bP9qIumFcr6LwGuIqpwYb761HSgSYGiiUG8n054A5nPgEy RzbHyv3YG15wq+gkDB2/yq9K1eUmLfkeunlf449A5e/b0cbEkI5dq3t5I/Jey+1GfAEr JZQQdyDZ9w+b33e4jwbb15e2qT952PLRNsyu3qlY/I/C+nkpH/PrpshMx54nkGEgasms E0tk8KEC5i1n/L9Hmz/98fH38NM9PqrnGqF6zgQyeiRwZRmlccj5eAD61a1i6iGUbQMk qoymt5JzJY+b1IJOguY6HJqhSRDhmsiscVE5w52+lGfGCVheLikTnNjVTeZ2GYwJ87ET pDKQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ykxoXC+kG2bfAsp3HMaBO2vDfAxm/NiyS8XOVoqcYqc=; b=G28NIVyGdWsT/lXFsbZQEsSECl8+kM/2QtBQzl9pC+MsTDCnmpc4eL+sEl7WK2ffzy PzNL2TbFfOv22QbKfCeqYsUUf/Yae/OoY++OhO9vIzyYUyF3Zxpuzdu2LlmvIHDkkcNw 61ftgjY3IzWIbtSJKLtDEl9yJO7yYCGURNOw+EUL+ttAHZKYok06WEgy2mvm6V3B4IEb q0iDEJEf96WLomK/ca7CZgM2AUdg4OOx7uxSx/yxGZDK/lvZzzKP3zekdaXDHFsLJUXg +aeG9FC2xi/iL5KDKq5O+HLZ2qWL+GddSEUPIw4b/g04L0KwETRuxwXxKVWyo5dWIaAO YWxA== X-Gm-Message-State: AJaThX6+do2KZkG8x711g5/YFR+FHux5QYMPbIjyH2pmC9xGMOGv2u7s aNInnKE1ll5kJIlSqt1y/q/pAA== X-Google-Smtp-Source: AGs4zMYONZnOZ+Y9nACATLB0k7kE9E4qVLg6w9GQ+GFDFTLJaD+P885rApQKCC/ACGjeftoMqezFSQ== X-Received: by 10.223.162.199 with SMTP id t7mr3878438wra.163.1510915782625; Fri, 17 Nov 2017 02:49:42 -0800 (PST) Received: from localhost.localdomain ([2a02:908:1251:7981:4ce1:a38d:11ca:a5]) by smtp.gmail.com with ESMTPSA id 186sm2884009wmm.47.2017.11.17.02.49.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 17 Nov 2017 02:49:42 -0800 (PST) From: "=?UTF-8?q?Christian=20K=C3=B6nig?=" X-Google-Original-From: =?UTF-8?q?Christian=20K=C3=B6nig?= To: amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org Subject: [PATCH 2/8] drm/ttm: use an operation ctx for ttm_bo_init_reserved Date: Fri, 17 Nov 2017 11:49:29 +0100 Message-Id: <20171117104935.4150-3-christian.koenig@amd.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20171117104935.4150-1-christian.koenig@amd.com> References: <20171117104935.4150-1-christian.koenig@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-Virus-Scanned: ClamAV using ClamSMTP Instead of specifying if sleeping should be interruptible. Signed-off-by: Christian König Reviewed-by: Michel Dänzer --- drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 3 ++- drivers/gpu/drm/ttm/ttm_bo.c | 12 +++++------- include/drm/ttm/ttm_bo_api.h | 5 ++--- 3 files changed, 9 insertions(+), 11 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c index c2419bc6b3df..15027f751e07 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c @@ -327,6 +327,7 @@ static int amdgpu_bo_do_create(struct amdgpu_device *adev, uint64_t init_value, struct amdgpu_bo **bo_ptr) { + struct ttm_operation_ctx ctx = { !kernel, false }; struct amdgpu_bo *bo; enum ttm_bo_type type; unsigned long page_align; @@ -408,7 +409,7 @@ static int amdgpu_bo_do_create(struct amdgpu_device *adev, initial_bytes_moved = atomic64_read(&adev->num_bytes_moved); /* Kernel allocation are uninterruptible */ r = ttm_bo_init_reserved(&adev->mman.bdev, &bo->tbo, size, type, - &bo->placement, page_align, !kernel, NULL, + &bo->placement, page_align, &ctx, NULL, acc_size, sg, resv, &amdgpu_ttm_bo_destroy); if (unlikely(r != 0)) return r; diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c index 5347c3f3e2f4..1f6957adc19e 100644 --- a/drivers/gpu/drm/ttm/ttm_bo.c +++ b/drivers/gpu/drm/ttm/ttm_bo.c @@ -1132,7 +1132,7 @@ int ttm_bo_init_reserved(struct ttm_bo_device *bdev, enum ttm_bo_type type, struct ttm_placement *placement, uint32_t page_alignment, - bool interruptible, + struct ttm_operation_ctx *ctx, struct file *persistent_swap_storage, size_t acc_size, struct sg_table *sg, @@ -1218,11 +1218,8 @@ int ttm_bo_init_reserved(struct ttm_bo_device *bdev, WARN_ON(!locked); } - if (likely(!ret)) { - struct ttm_operation_ctx ctx = { interruptible, false }; - - ret = ttm_bo_validate(bo, placement, &ctx); - } + if (likely(!ret)) + ret = ttm_bo_validate(bo, placement, ctx); if (unlikely(ret)) { if (!resv) @@ -1255,10 +1252,11 @@ int ttm_bo_init(struct ttm_bo_device *bdev, struct reservation_object *resv, void (*destroy) (struct ttm_buffer_object *)) { + struct ttm_operation_ctx ctx = { interruptible, false }; int ret; ret = ttm_bo_init_reserved(bdev, bo, size, type, placement, - page_alignment, interruptible, + page_alignment, &ctx, persistent_swap_storage, acc_size, sg, resv, destroy); if (ret) diff --git a/include/drm/ttm/ttm_bo_api.h b/include/drm/ttm/ttm_bo_api.h index 097951e999bc..d0164d131982 100644 --- a/include/drm/ttm/ttm_bo_api.h +++ b/include/drm/ttm/ttm_bo_api.h @@ -455,8 +455,7 @@ size_t ttm_bo_dma_acc_size(struct ttm_bo_device *bdev, * @type: Requested type of buffer object. * @flags: Initial placement flags. * @page_alignment: Data alignment in pages. - * @interruptible: If needing to sleep to wait for GPU resources, - * sleep interruptible. + * @ctx: TTM operation context for memory allocation. * @persistent_swap_storage: Usually the swap storage is deleted for buffers * pinned in physical memory. If this behaviour is not desired, this member * holds a pointer to a persistent shmem object. Typically, this would @@ -493,7 +492,7 @@ int ttm_bo_init_reserved(struct ttm_bo_device *bdev, enum ttm_bo_type type, struct ttm_placement *placement, uint32_t page_alignment, - bool interrubtible, + struct ttm_operation_ctx *ctx, struct file *persistent_swap_storage, size_t acc_size, struct sg_table *sg,