From patchwork Fri Feb 2 19:09:47 2018 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: 10198029 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 0BA6660388 for ; Fri, 2 Feb 2018 19:10:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id ED32028F55 for ; Fri, 2 Feb 2018 19:10:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DF58D28F59; Fri, 2 Feb 2018 19:10:02 +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 B8E0F28F55 for ; Fri, 2 Feb 2018 19:10:01 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 440D96F0D1; Fri, 2 Feb 2018 19:09:56 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wr0-x241.google.com (mail-wr0-x241.google.com [IPv6:2a00:1450:400c:c0c::241]) by gabe.freedesktop.org (Postfix) with ESMTPS id C05D96F00D; Fri, 2 Feb 2018 19:09:53 +0000 (UTC) Received: by mail-wr0-x241.google.com with SMTP id w50so23550605wrc.2; Fri, 02 Feb 2018 11:09:53 -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=OTQfcYRwPGI5sr+lMfyomZOSsMcC9TKeQtLvukxyOAc=; b=soYUNEocQXXw+jT7BO46AfUiPNxhI5YEbXt+ihTg2vpsW/yJHUTj+1ePSHyyBjYjZi uCPnE2YDLzB8taiqNiirmW1IGBtdkaTdibW7DSFyh8Rcy6SO2cDrvtGsXBCx9W6oqTxo k8GnX7SEScPQq9mmwmGvOM9LBcxNjyn5fK3hlr+e6PZWPNHEm4n/LUrwYLiV1E0V7psf CNePKpsJyI3bksoHpSQUEGa3UgkyS+x/qIyYV6vf8MKomNGFmqh4dKVPmzRVnQiEPn6I WlJn4mHlC8XOsdopP/HOLOxZKfnIE9OdP1EumuzFhX9DJmBmFy9KfzFZOegw6NlGja6a 4wRQ== 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=OTQfcYRwPGI5sr+lMfyomZOSsMcC9TKeQtLvukxyOAc=; b=twSyBQ+/CFkYP7eoMXpdvVBOC67VV1vm1+wKoqJS4ipAoTrv3osMbs6dM7cf9sGx10 E8HcgmdZO/HuNrtuUBADuBXBsd7toaA/sqyQIE8gWQbJriQCDR/xfoaRsR4TqLbpzEE4 3CIfkYA1FPTwyBJtYuxqlPQmxfo2/zBm8nlxaE+wHmS0wre+rAufVWXm5RZ/YoHS8iwu 0GxgZQFWo6ocMH6P9nwJryORsn83KYxAesR3ID5VPeQQO9NZQprmz8+O/OqWZ4dHMuWE E7vwfKfruJnxbz2CUrHe+/un+kYQEcX2TirLq+rm0tRcPIzUZaZAO1viG9sGrTpDDJLc icUw== X-Gm-Message-State: AKwxytfABcJO5Mc6EhXREpVZCvICwCw1t3rZ/2miMTkzfOn/+EmH0u9J RNjn7ol8N0cKZ6AueJRBkbxd+Q== X-Google-Smtp-Source: AH8x226TeuS4XsB1JlphGsgum2l9Vh0SVDERcj4CIJL+yPkW+lrkIuI7BK5QCJ+OwFxnWcbY5+L53Q== X-Received: by 10.223.136.197 with SMTP id g5mr19566557wrg.3.1517598592123; Fri, 02 Feb 2018 11:09:52 -0800 (PST) Received: from baker.fritz.box ([2a02:908:1251:8fc0:ad10:3711:be7c:8502]) by smtp.gmail.com with ESMTPSA id j132sm3917316wmd.38.2018.02.02.11.09.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 02 Feb 2018 11:09:51 -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 4/5] drm/ttm: set page mapping during allocation Date: Fri, 2 Feb 2018 20:09:47 +0100 Message-Id: <20180202190948.2654-4-christian.koenig@amd.com> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20180202190948.2654-1-christian.koenig@amd.com> References: <20180202190948.2654-1-christian.koenig@amd.com> MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 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 To aid debugging set the page mapping during allocation instead of during VM faults. Signed-off-by: Christian König --- drivers/gpu/drm/ttm/ttm_bo_vm.c | 1 - drivers/gpu/drm/ttm/ttm_tt.c | 18 +++++++++++++++++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/ttm/ttm_bo_vm.c b/drivers/gpu/drm/ttm/ttm_bo_vm.c index 610d6714042a..121f017ac7ca 100644 --- a/drivers/gpu/drm/ttm/ttm_bo_vm.c +++ b/drivers/gpu/drm/ttm/ttm_bo_vm.c @@ -257,7 +257,6 @@ static int ttm_bo_vm_fault(struct vm_fault *vmf) } else if (unlikely(!page)) { break; } - page->mapping = vma->vm_file->f_mapping; page->index = drm_vma_node_start(&bo->vma_node) + page_offset; pfn = page_to_pfn(page); diff --git a/drivers/gpu/drm/ttm/ttm_tt.c b/drivers/gpu/drm/ttm/ttm_tt.c index 39c44e301c72..9fd7115a013a 100644 --- a/drivers/gpu/drm/ttm/ttm_tt.c +++ b/drivers/gpu/drm/ttm/ttm_tt.c @@ -392,12 +392,28 @@ int ttm_tt_swapout(struct ttm_tt *ttm, struct file *persistent_swap_storage) return ret; } +static void ttm_tt_add_mapping(struct ttm_tt *ttm) +{ + pgoff_t i; + + if (ttm->page_flags & TTM_PAGE_FLAG_SG) + return; + + for (i = 0; i < ttm->num_pages; ++i) + ttm->pages[i]->mapping = ttm->bdev->dev_mapping; +} + int ttm_tt_populate(struct ttm_tt *ttm, struct ttm_operation_ctx *ctx) { + int ret; + if (ttm->state != tt_unpopulated) return 0; - return ttm->bdev->driver->ttm_tt_populate(ttm, ctx); + ret = ttm->bdev->driver->ttm_tt_populate(ttm, ctx); + if (!ret) + ttm_tt_add_mapping(ttm); + return ret; } static void ttm_tt_clear_mapping(struct ttm_tt *ttm)