From patchwork Wed Dec 20 10:34:56 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "He, Hongbo" X-Patchwork-Id: 10125415 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 37B826019C for ; Wed, 20 Dec 2017 10:35:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 21409205A8 for ; Wed, 20 Dec 2017 10:35:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 12C87289B3; Wed, 20 Dec 2017 10:35:37 +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=BAD_ENC_HEADER,BAYES_00, DKIM_SIGNED, 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 01C5F205A8 for ; Wed, 20 Dec 2017 10:35:36 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 92F4889BCD; Wed, 20 Dec 2017 10:35:35 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from NAM02-BL2-obe.outbound.protection.outlook.com (mail-bl2nam02on0055.outbound.protection.outlook.com [104.47.38.55]) by gabe.freedesktop.org (Postfix) with ESMTPS id D8D6589BAF; Wed, 20 Dec 2017 10:35:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amdcloud.onmicrosoft.com; s=selector1-amd-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=IFXE2gaMfruVcTd2/Oo9jAc/L6gMPPxFNSIf8UslGhk=; b=ieDDwDGoQOuWcY9G7ldnQkZTLbR5r30t2rg6R09XHmxEyKfVQI7czAK6PpUjwnkZlaPH81RhTg4RUuMmICGFWEQzMFdnCLJust0O1zoBOq42gT8BMT0nJuZ11zw0PJb1phN6qls3ceO2/FsNGiznaiAu9z0mt1lCLORuyfGlt0s= Received: from CY1PR12CA0048.namprd12.prod.outlook.com (10.163.230.16) by DM5PR1201MB0060.namprd12.prod.outlook.com (10.174.106.14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.323.15; Wed, 20 Dec 2017 10:35:31 +0000 Received: from CO1NAM03FT007.eop-NAM03.prod.protection.outlook.com (2a01:111:f400:7e48::205) by CY1PR12CA0048.outlook.office365.com (2a01:111:e400:c42b::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.345.14 via Frontend Transport; Wed, 20 Dec 2017 10:35:30 +0000 Authentication-Results: spf=none (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; lists.freedesktop.org; dkim=none (message not signed) header.d=none;lists.freedesktop.org; dmarc=permerror action=none header.from=amd.com; Received-SPF: None (protection.outlook.com: amd.com does not designate permitted sender hosts) Received: from SATLEXCHOV01.amd.com (165.204.84.17) by CO1NAM03FT007.mail.protection.outlook.com (10.152.80.117) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.20.302.6 via Frontend Transport; Wed, 20 Dec 2017 10:35:30 +0000 Received: from roger-build-server.amd.com (10.34.1.3) by SATLEXCHOV01.amd.com (10.181.40.71) with Microsoft SMTP Server id 14.3.361.1; Wed, 20 Dec 2017 04:35:29 -0600 From: Roger He To: , Subject: [PATCH 2/7] drm/ttm: use an operation ctx for ttm_mem_global_alloc Date: Wed, 20 Dec 2017 18:34:56 +0800 Message-ID: <1513766101-15993-2-git-send-email-Hongbo.He@amd.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1513766101-15993-1-git-send-email-Hongbo.He@amd.com> References: <1513766101-15993-1-git-send-email-Hongbo.He@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-HT: Tenant X-Forefront-Antispam-Report: CIP:165.204.84.17; IPV:NLI; CTRY:US; EFV:NLI; SFV:NSPM; SFS:(10009020)(39380400002)(396003)(376002)(39860400002)(346002)(2980300002)(428003)(199004)(189003)(7696005)(51416003)(76176011)(106466001)(105586002)(4326008)(59450400001)(68736007)(81156014)(5660300001)(8676002)(450100002)(81166006)(2950100002)(6666003)(8936002)(53936002)(50466002)(110136005)(316002)(48376002)(47776003)(36756003)(50226002)(478600001)(16586007)(72206003)(104016004)(53416004)(97736004)(575784001)(86362001)(77096006)(2906002)(356003)(305945005); DIR:OUT; SFP:1101; SCL:1; SRVR:DM5PR1201MB0060; H:SATLEXCHOV01.amd.com; FPR:; SPF:None; PTR:InfoDomainNonexistent; A:1; MX:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; CO1NAM03FT007; 1:78rqvY+vEAyyNwtOwnhOgxk/tsv4WlczeRaI+bhyVY/lDJiW8yDqrDoOKu8rsm7G64A/uAPQ9n2FEKfIWC2yqONHQlk/VbVNpONO1TWVueVroI59A+WV18e03UZH5FrG X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: f82b2bb8-2376-4e69-e589-08d5479564be X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(4534020)(4602075)(4627115)(201703031133081)(201702281549075)(5600026)(4604075)(2017052603307)(7153060); SRVR:DM5PR1201MB0060; X-Microsoft-Exchange-Diagnostics: 1; DM5PR1201MB0060; 3:oTZB2s6Rh0kQ5VowhCAH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x/PZ3L86xrmNOctTl4YCPWK8nm++m1P9Qdb/K1q1xf3Yxs9RXlKmLz+EtpiuL8vZi9RA4gzepdv4EPvJ43pFMQkIge1uiAtszCSOdVkFG4q62GlAX9Vx/R2xjU2fLQetV8Mj6WI+YNbufq/xZZi1MjNi4HWHnK8uyEP+F1S4/efbAQV5W6Y119bnwc70f+ofAlKCxBrftfVHSscPpHstj/b8gWCqAUuE6TFCjccZ5T37WB5a9/7lCVkAOllyZO0ghpHwWe5n24MHFjk20owuqHnL/3CxJqcQV4OVRE2ezHPEl/FfZbqMuN6IXkhqWhdddriklN9NlSwg/LBuOAncH32FVLGlsHsQM3R8S7/Z/lL6dPNK1iJZ+U0tP+XypZYzaEUEGWJC/CUK1avAGiS1iVeMC/oHY0pYaph+ATzNj9nok3XOlyagIvXx0DfUbm1esAymT5MTCFQz X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(767451399110); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040470)(2401047)(8121501046)(5005006)(93006095)(93003095)(3231023)(3002001)(10201501046)(6055026)(6041268)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(20161123562045)(20161123564045)(20161123560045)(6072148)(201708071742011); SRVR:DM5PR1201MB0060; BCL:0; PCL:0; RULEID:(100000803101)(100110400095); SRVR:DM5PR1201MB0060; X-Microsoft-Exchange-Diagnostics: 1; DM5PR1201MB0060; 4:IzreEfX3YPfV9pGd+bcQWBz21mm+6iNdiA+YTXnB7OjxVTvWHDLLDUCS3iRAwM+pqVu0qffvvLOh3tIcF5kk+wCfoz+yRdXo9jeY0/aaHJ7c85JYDZqiP5ibnrjHjKK3TkS6zSXrnqHruxGfL/M6i/v/xoJAXVUgMwBPAKmTz6CuBicG4Jfxzw3vMk9xCnce63ggZy/84TL1IjvWI+vju913mM7xgGRW2dILEgpa3HkSCVLoacRcNovAc34olV6JEGpYiDRc1UzO0Yadm/plO+PwV3tgvhYV0ZA3+nWyYnDAdo54MuYcOpP6XM9SEHCU X-Forefront-PRVS: 0527DFA348 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; DM5PR1201MB0060; 23:TVYKtNlRM1MDS2KI8+iJ5Yh5Bf92f1vzC1TFmh+?= =?us-ascii?Q?afL9nDgOkmddsJE6R54uke9ZERsE5gXX2R9//nUb5Vx4elE9Q9LfogvXlEWM?= =?us-ascii?Q?GhHzppvYbAEoE2iJdvVI93mFD+mK7e451nukc2QcOj2qCPmvNFYFZnvjMQ24?= =?us-ascii?Q?M8UA6+Xblu1eMS7jIeSN4ok5eg93qcZOM1rGuT2bIbsz8th7tIqtfO+5Wgza?= =?us-ascii?Q?ju0cmMRjiKiR2EcPYfW9kDJxwtdgwc5F8LsyaYxDf6rX/KugUHCFKsiIHZ7+?= =?us-ascii?Q?0TJxVfnUl0kQtcYRoyp6XuCmnylSzbsPZSrgFImDy9zu2bylGWFdTZE9UsJ4?= =?us-ascii?Q?qQYb/fAMWJYOcuewTvGgNCpm4Lx442BWZ/NlW9QezEIIqp4SabjFHUZzD2Ea?= =?us-ascii?Q?TpTUXrEVkMCNeNtb/4roKa8xNy+p0UbAgt/RoTEfYNyZtU8EIf7UjWE0K4JA?= =?us-ascii?Q?zLpJroevtxVB3YuKFcbmAFd9BQqbBiYT50arwdkDMR/FE1TvvawuUSSLTPWc?= =?us-ascii?Q?dAlARmn1a6FCbwSm1SQ3Vkht+AfruBFCPCsR5LEJ6eRMd7Q7lMRV9j2Pc8AD?= =?us-ascii?Q?TKehcGHR8LsOuDHctPVqfYKSbHJs5V3oYMQcmqRYXI+FmGsKX5sHdWI6gA1R?= =?us-ascii?Q?f0vjSOr65eSr68UjM2G6ajJpTvGNvouQwHSBC7oV/zJ+/TEgnSSl9QZyai38?= =?us-ascii?Q?AMi1WD32IbE4mNjxTV94n8upASzB/d49B6a7bzw7JjHKJI63QiL0cn+1tsm/?= =?us-ascii?Q?G9wxi29710Boj0RPhrNCIX6UM/m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yr3mRFvM70r85NwyAEE1O1udwIhnxDSX2w7qs8/O6d9dZ5BTJG4Izz8ENgd/rallo1dPsmn1249UUL9Fg7T78OqdxCiKTeaizqIGJA+TWX6v3NUAjEC7X0zA+vGjqoiWghGHik8IqCiXMQloZgGXYF2zWAkDjrPGK90fs+ck5taSH1vpXm1JsqpvvcngdoPjbpE5biMY9/6RGQR2hLrArsdolN22p1uGrhtm3gwDNfVCiRS9OVS50B SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; DM5PR1201MB0060; 20:lNx/W+muHWKIM52zBwG9Pju4BEHIfL7wNM6eSbRzcN4dGKhiqxaV8V9OegtXAJm15eZD2suQyb62lcrJ6AV4Tx1WKmYp77waxDf6VPMV/ThBgbmL12CVqmj73fwpqMdEUxuYAJWORha9S/9ytvyiT/YzBKfaLdrH1lCAtPKS1jwzsvVAOUv+bw5IyLiPVxYKdbGGntpZMLVQLlrW1HdJby+h7RSlqtlDsOJgzmrtCpmsFFdgVmtPyszziVp2BBVQ X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Dec 2017 10:35:30.6068 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f82b2bb8-2376-4e69-e589-08d5479564be X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d; Ip=[165.204.84.17]; Helo=[SATLEXCHOV01.amd.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR1201MB0060 Cc: Roger He 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 Change-Id: I5279b5cd3560c4082b00f822219575a5f9c3808a Signed-off-by: Roger He Reviewed-by: Thomas Hellstrom --- drivers/gpu/drm/ttm/ttm_bo.c | 2 +- drivers/gpu/drm/ttm/ttm_memory.c | 15 +++++++++------ drivers/gpu/drm/ttm/ttm_object.c | 13 ++++++++++--- drivers/gpu/drm/vmwgfx/vmwgfx_binding.c | 6 +++++- drivers/gpu/drm/vmwgfx/vmwgfx_buffer.c | 13 ++++++++++--- drivers/gpu/drm/vmwgfx/vmwgfx_context.c | 6 +++++- drivers/gpu/drm/vmwgfx/vmwgfx_cotable.c | 6 +++++- drivers/gpu/drm/vmwgfx/vmwgfx_fence.c | 6 +++++- drivers/gpu/drm/vmwgfx/vmwgfx_shader.c | 18 +++++++++++++++--- drivers/gpu/drm/vmwgfx/vmwgfx_simple_resource.c | 6 +++++- drivers/gpu/drm/vmwgfx/vmwgfx_so.c | 6 +++++- drivers/gpu/drm/vmwgfx/vmwgfx_surface.c | 12 ++++++++++-- include/drm/ttm/ttm_memory.h | 3 ++- 13 files changed, 87 insertions(+), 25 deletions(-) diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c index fa57aa8..c59f572 100644 --- a/drivers/gpu/drm/ttm/ttm_bo.c +++ b/drivers/gpu/drm/ttm/ttm_bo.c @@ -1133,7 +1133,7 @@ int ttm_bo_init_reserved(struct ttm_bo_device *bdev, struct ttm_mem_global *mem_glob = bdev->glob->mem_glob; bool locked; - ret = ttm_mem_global_alloc(mem_glob, acc_size, false, false); + ret = ttm_mem_global_alloc(mem_glob, acc_size, ctx); if (ret) { pr_err("Out of kernel memory\n"); if (destroy) diff --git a/drivers/gpu/drm/ttm/ttm_memory.c b/drivers/gpu/drm/ttm/ttm_memory.c index 9130bdf..525d3b6 100644 --- a/drivers/gpu/drm/ttm/ttm_memory.c +++ b/drivers/gpu/drm/ttm/ttm_memory.c @@ -508,7 +508,7 @@ static int ttm_mem_global_reserve(struct ttm_mem_global *glob, static int ttm_mem_global_alloc_zone(struct ttm_mem_global *glob, struct ttm_mem_zone *single_zone, uint64_t memory, - bool no_wait, bool interruptible) + struct ttm_operation_ctx *ctx) { int count = TTM_MEMORY_ALLOC_RETRIES; @@ -516,7 +516,7 @@ static int ttm_mem_global_alloc_zone(struct ttm_mem_global *glob, single_zone, memory, true) != 0)) { - if (no_wait) + if (ctx->no_wait_gpu) return -ENOMEM; if (unlikely(count-- == 0)) return -ENOMEM; @@ -527,15 +527,14 @@ static int ttm_mem_global_alloc_zone(struct ttm_mem_global *glob, } int ttm_mem_global_alloc(struct ttm_mem_global *glob, uint64_t memory, - bool no_wait, bool interruptible) + struct ttm_operation_ctx *ctx) { /** * Normal allocations of kernel memory are registered in * all zones. */ - return ttm_mem_global_alloc_zone(glob, NULL, memory, no_wait, - interruptible); + return ttm_mem_global_alloc_zone(glob, NULL, memory, ctx); } EXPORT_SYMBOL(ttm_mem_global_alloc); @@ -544,6 +543,10 @@ int ttm_mem_global_alloc_page(struct ttm_mem_global *glob, { struct ttm_mem_zone *zone = NULL; + struct ttm_operation_ctx ctx = { + .interruptible = false, + .no_wait_gpu = false + }; /** * Page allocations may be registed in a single zone @@ -557,7 +560,7 @@ int ttm_mem_global_alloc_page(struct ttm_mem_global *glob, if (glob->zone_dma32 && page_to_pfn(page) > 0x00100000UL) zone = glob->zone_kernel; #endif - return ttm_mem_global_alloc_zone(glob, zone, size, false, false); + return ttm_mem_global_alloc_zone(glob, zone, size, &ctx); } void ttm_mem_global_free_page(struct ttm_mem_global *glob, struct page *page, diff --git a/drivers/gpu/drm/ttm/ttm_object.c b/drivers/gpu/drm/ttm/ttm_object.c index 26a7ad0..1aa2baa 100644 --- a/drivers/gpu/drm/ttm/ttm_object.c +++ b/drivers/gpu/drm/ttm/ttm_object.c @@ -325,6 +325,10 @@ int ttm_ref_object_add(struct ttm_object_file *tfile, struct ttm_ref_object *ref; struct drm_hash_item *hash; struct ttm_mem_global *mem_glob = tfile->tdev->mem_glob; + struct ttm_operation_ctx ctx = { + .interruptible = false, + .no_wait_gpu = false + }; int ret = -EINVAL; if (base->tfile != tfile && !base->shareable) @@ -350,7 +354,7 @@ int ttm_ref_object_add(struct ttm_object_file *tfile, return -EPERM; ret = ttm_mem_global_alloc(mem_glob, sizeof(*ref), - false, false); + &ctx); if (unlikely(ret != 0)) return ret; ref = kmalloc(sizeof(*ref), GFP_KERNEL); @@ -686,7 +690,10 @@ int ttm_prime_handle_to_fd(struct ttm_object_file *tfile, dma_buf = prime->dma_buf; if (!dma_buf || !get_dma_buf_unless_doomed(dma_buf)) { DEFINE_DMA_BUF_EXPORT_INFO(exp_info); - + struct ttm_operation_ctx ctx = { + .interruptible = true, + .no_wait_gpu = false + }; exp_info.ops = &tdev->ops; exp_info.size = prime->size; exp_info.flags = flags; @@ -696,7 +703,7 @@ int ttm_prime_handle_to_fd(struct ttm_object_file *tfile, * Need to create a new dma_buf, with memory accounting. */ ret = ttm_mem_global_alloc(tdev->mem_glob, tdev->dma_buf_size, - false, true); + &ctx); if (unlikely(ret != 0)) { mutex_unlock(&prime->mutex); goto out_unref; diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_binding.c b/drivers/gpu/drm/vmwgfx/vmwgfx_binding.c index 9c42e96..55d32ae 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_binding.c +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_binding.c @@ -1202,10 +1202,14 @@ struct vmw_ctx_binding_state * vmw_binding_state_alloc(struct vmw_private *dev_priv) { struct vmw_ctx_binding_state *cbs; + struct ttm_operation_ctx ctx = { + .interruptible = false, + .no_wait_gpu = false + }; int ret; ret = ttm_mem_global_alloc(vmw_mem_glob(dev_priv), sizeof(*cbs), - false, false); + &ctx); if (ret) return ERR_PTR(ret); diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_buffer.c b/drivers/gpu/drm/vmwgfx/vmwgfx_buffer.c index c705632..ef97542 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_buffer.c +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_buffer.c @@ -394,6 +394,10 @@ static int vmw_ttm_map_dma(struct vmw_ttm_tt *vmw_tt) struct vmw_private *dev_priv = vmw_tt->dev_priv; struct ttm_mem_global *glob = vmw_mem_glob(dev_priv); struct vmw_sg_table *vsgt = &vmw_tt->vsgt; + struct ttm_operation_ctx ctx = { + .interruptible = true, + .no_wait_gpu = false + }; struct vmw_piter iter; dma_addr_t old; int ret = 0; @@ -417,8 +421,7 @@ static int vmw_ttm_map_dma(struct vmw_ttm_tt *vmw_tt) sgt_size = ttm_round_pot(sizeof(struct sg_table)); } vmw_tt->sg_alloc_size = sgt_size + sgl_size * vsgt->num_pages; - ret = ttm_mem_global_alloc(glob, vmw_tt->sg_alloc_size, false, - true); + ret = ttm_mem_global_alloc(glob, vmw_tt->sg_alloc_size, &ctx); if (unlikely(ret != 0)) return ret; @@ -638,6 +641,10 @@ static int vmw_ttm_populate(struct ttm_tt *ttm) container_of(ttm, struct vmw_ttm_tt, dma_ttm.ttm); struct vmw_private *dev_priv = vmw_tt->dev_priv; struct ttm_mem_global *glob = vmw_mem_glob(dev_priv); + struct ttm_operation_ctx ctx = { + .interruptible = true, + .no_wait_gpu = false + }; int ret; if (ttm->state != tt_unpopulated) @@ -646,7 +653,7 @@ static int vmw_ttm_populate(struct ttm_tt *ttm) if (dev_priv->map_mode == vmw_dma_alloc_coherent) { size_t size = ttm_round_pot(ttm->num_pages * sizeof(dma_addr_t)); - ret = ttm_mem_global_alloc(glob, size, false, true); + ret = ttm_mem_global_alloc(glob, size, &ctx); if (unlikely(ret != 0)) return ret; diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_context.c b/drivers/gpu/drm/vmwgfx/vmwgfx_context.c index 4212b3e..3767ac3 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_context.c +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_context.c @@ -746,6 +746,10 @@ static int vmw_context_define(struct drm_device *dev, void *data, struct vmw_resource *tmp; struct drm_vmw_context_arg *arg = (struct drm_vmw_context_arg *)data; struct ttm_object_file *tfile = vmw_fpriv(file_priv)->tfile; + struct ttm_operation_ctx ttm_opt_ctx = { + .interruptible = true, + .no_wait_gpu = false + }; int ret; if (!dev_priv->has_dx && dx) { @@ -768,7 +772,7 @@ static int vmw_context_define(struct drm_device *dev, void *data, ret = ttm_mem_global_alloc(vmw_mem_glob(dev_priv), vmw_user_context_size, - false, true); + &ttm_opt_ctx); if (unlikely(ret != 0)) { if (ret != -ERESTARTSYS) DRM_ERROR("Out of graphics memory for context" diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_cotable.c b/drivers/gpu/drm/vmwgfx/vmwgfx_cotable.c index 92df0b0..cbf54ea 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_cotable.c +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_cotable.c @@ -573,6 +573,10 @@ struct vmw_resource *vmw_cotable_alloc(struct vmw_private *dev_priv, u32 type) { struct vmw_cotable *vcotbl; + struct ttm_operation_ctx ttm_opt_ctx = { + .interruptible = true, + .no_wait_gpu = false + }; int ret; u32 num_entries; @@ -580,7 +584,7 @@ struct vmw_resource *vmw_cotable_alloc(struct vmw_private *dev_priv, cotable_acc_size = ttm_round_pot(sizeof(struct vmw_cotable)); ret = ttm_mem_global_alloc(vmw_mem_glob(dev_priv), - cotable_acc_size, false, true); + cotable_acc_size, &ttm_opt_ctx); if (unlikely(ret)) return ERR_PTR(ret); diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_fence.c b/drivers/gpu/drm/vmwgfx/vmwgfx_fence.c index d6b1c50..6c5c75c 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_fence.c +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_fence.c @@ -588,6 +588,10 @@ int vmw_user_fence_create(struct drm_file *file_priv, struct vmw_user_fence *ufence; struct vmw_fence_obj *tmp; struct ttm_mem_global *mem_glob = vmw_mem_glob(fman->dev_priv); + struct ttm_operation_ctx ctx = { + .interruptible = false, + .no_wait_gpu = false + }; int ret; /* @@ -596,7 +600,7 @@ int vmw_user_fence_create(struct drm_file *file_priv, */ ret = ttm_mem_global_alloc(mem_glob, fman->user_fence_size, - false, false); + &ctx); if (unlikely(ret != 0)) return ret; diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_shader.c b/drivers/gpu/drm/vmwgfx/vmwgfx_shader.c index 004e18b..73b8e9a 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_shader.c +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_shader.c @@ -607,6 +607,10 @@ int vmw_dx_shader_add(struct vmw_cmdbuf_res_manager *man, struct vmw_dx_shader *shader; struct vmw_resource *res; struct vmw_private *dev_priv = ctx->dev_priv; + struct ttm_operation_ctx ttm_opt_ctx = { + .interruptible = true, + .no_wait_gpu = false + }; int ret; if (!vmw_shader_dx_size) @@ -616,7 +620,7 @@ int vmw_dx_shader_add(struct vmw_cmdbuf_res_manager *man, return -EINVAL; ret = ttm_mem_global_alloc(vmw_mem_glob(dev_priv), vmw_shader_dx_size, - false, true); + &ttm_opt_ctx); if (ret) { if (ret != -ERESTARTSYS) DRM_ERROR("Out of graphics memory for shader " @@ -730,6 +734,10 @@ static int vmw_user_shader_alloc(struct vmw_private *dev_priv, { struct vmw_user_shader *ushader; struct vmw_resource *res, *tmp; + struct ttm_operation_ctx ctx = { + .interruptible = true, + .no_wait_gpu = false + }; int ret; /* @@ -742,7 +750,7 @@ static int vmw_user_shader_alloc(struct vmw_private *dev_priv, ret = ttm_mem_global_alloc(vmw_mem_glob(dev_priv), vmw_user_shader_size, - false, true); + &ctx); if (unlikely(ret != 0)) { if (ret != -ERESTARTSYS) DRM_ERROR("Out of graphics memory for shader " @@ -800,6 +808,10 @@ static struct vmw_resource *vmw_shader_alloc(struct vmw_private *dev_priv, { struct vmw_shader *shader; struct vmw_resource *res; + struct ttm_operation_ctx ctx = { + .interruptible = true, + .no_wait_gpu = false + }; int ret; /* @@ -812,7 +824,7 @@ static struct vmw_resource *vmw_shader_alloc(struct vmw_private *dev_priv, ret = ttm_mem_global_alloc(vmw_mem_glob(dev_priv), vmw_shader_size, - false, true); + &ctx); if (unlikely(ret != 0)) { if (ret != -ERESTARTSYS) DRM_ERROR("Out of graphics memory for shader " diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_simple_resource.c b/drivers/gpu/drm/vmwgfx/vmwgfx_simple_resource.c index 051d3b3..a0cb310 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_simple_resource.c +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_simple_resource.c @@ -149,6 +149,10 @@ vmw_simple_resource_create_ioctl(struct drm_device *dev, void *data, struct vmw_resource *res; struct vmw_resource *tmp; struct ttm_object_file *tfile = vmw_fpriv(file_priv)->tfile; + struct ttm_operation_ctx ctx = { + .interruptible = true, + .no_wait_gpu = false + }; size_t alloc_size; size_t account_size; int ret; @@ -162,7 +166,7 @@ vmw_simple_resource_create_ioctl(struct drm_device *dev, void *data, return ret; ret = ttm_mem_global_alloc(vmw_mem_glob(dev_priv), account_size, - false, true); + &ctx); ttm_read_unlock(&dev_priv->reservation_sem); if (ret) { if (ret != -ERESTARTSYS) diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_so.c b/drivers/gpu/drm/vmwgfx/vmwgfx_so.c index 5a73eeb..d3573c3 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_so.c +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_so.c @@ -329,6 +329,10 @@ int vmw_view_add(struct vmw_cmdbuf_res_manager *man, struct vmw_private *dev_priv = ctx->dev_priv; struct vmw_resource *res; struct vmw_view *view; + struct ttm_operation_ctx ttm_opt_ctx = { + .interruptible = true, + .no_wait_gpu = false + }; size_t size; int ret; @@ -345,7 +349,7 @@ int vmw_view_add(struct vmw_cmdbuf_res_manager *man, size = offsetof(struct vmw_view, cmd) + cmd_size; - ret = ttm_mem_global_alloc(vmw_mem_glob(dev_priv), size, false, true); + ret = ttm_mem_global_alloc(vmw_mem_glob(dev_priv), size, &ttm_opt_ctx); if (ret) { if (ret != -ERESTARTSYS) DRM_ERROR("Out of graphics memory for view" diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_surface.c b/drivers/gpu/drm/vmwgfx/vmwgfx_surface.c index 6ac094e..db1bb16 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_surface.c +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_surface.c @@ -700,6 +700,10 @@ int vmw_surface_define_ioctl(struct drm_device *dev, void *data, struct drm_vmw_surface_create_req *req = &arg->req; struct drm_vmw_surface_arg *rep = &arg->rep; struct ttm_object_file *tfile = vmw_fpriv(file_priv)->tfile; + struct ttm_operation_ctx ctx = { + .interruptible = true, + .no_wait_gpu = false + }; int ret; int i, j; uint32_t cur_bo_offset; @@ -741,7 +745,7 @@ int vmw_surface_define_ioctl(struct drm_device *dev, void *data, return ret; ret = ttm_mem_global_alloc(vmw_mem_glob(dev_priv), - size, false, true); + size, &ctx); if (unlikely(ret != 0)) { if (ret != -ERESTARTSYS) DRM_ERROR("Out of graphics memory for surface" @@ -1479,6 +1483,10 @@ int vmw_surface_gb_priv_define(struct drm_device *dev, { struct vmw_private *dev_priv = vmw_priv(dev); struct vmw_user_surface *user_srf; + struct ttm_operation_ctx ctx = { + .interruptible = true, + .no_wait_gpu = false + }; struct vmw_surface *srf; int ret; u32 num_layers; @@ -1525,7 +1533,7 @@ int vmw_surface_gb_priv_define(struct drm_device *dev, return ret; ret = ttm_mem_global_alloc(vmw_mem_glob(dev_priv), - user_accounting_size, false, true); + user_accounting_size, &ctx); if (unlikely(ret != 0)) { if (ret != -ERESTARTSYS) DRM_ERROR("Out of graphics memory for surface" diff --git a/include/drm/ttm/ttm_memory.h b/include/drm/ttm/ttm_memory.h index 85f3ad6..755c107 100644 --- a/include/drm/ttm/ttm_memory.h +++ b/include/drm/ttm/ttm_memory.h @@ -35,6 +35,7 @@ #include #include #include +#include "ttm_bo_api.h" /** * struct ttm_mem_global - Global memory accounting structure. @@ -79,7 +80,7 @@ struct ttm_mem_global { extern int ttm_mem_global_init(struct ttm_mem_global *glob); extern void ttm_mem_global_release(struct ttm_mem_global *glob); extern int ttm_mem_global_alloc(struct ttm_mem_global *glob, uint64_t memory, - bool no_wait, bool interruptible); + struct ttm_operation_ctx *ctx); extern void ttm_mem_global_free(struct ttm_mem_global *glob, uint64_t amount); extern int ttm_mem_global_alloc_page(struct ttm_mem_global *glob,