From patchwork Fri Jul 31 04:04:32 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Airlie X-Patchwork-Id: 11693967 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3344714B7 for ; Fri, 31 Jul 2020 04:05:46 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 1BB94206FA for ; Fri, 31 Jul 2020 04:05:46 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1BB94206FA Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id BD5F86E999; Fri, 31 Jul 2020 04:05:41 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from us-smtp-delivery-1.mimecast.com (us-smtp-2.mimecast.com [207.211.31.81]) by gabe.freedesktop.org (Postfix) with ESMTPS id 09BBE6E999 for ; Fri, 31 Jul 2020 04:05:38 +0000 (UTC) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-69-n27sVWY4MNyc1oXNOH3e4Q-1; Fri, 31 Jul 2020 00:05:31 -0400 X-MC-Unique: n27sVWY4MNyc1oXNOH3e4Q-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 5B9D58015CE; Fri, 31 Jul 2020 04:05:30 +0000 (UTC) Received: from tyrion-bne-redhat-com.redhat.com (vpn2-54-17.bne.redhat.com [10.64.54.17]) by smtp.corp.redhat.com (Postfix) with ESMTP id E2858100238C; Fri, 31 Jul 2020 04:05:28 +0000 (UTC) From: Dave Airlie To: dri-devel@lists.freedesktop.org Subject: [PATCH 01/49] drm/qxl/ttm: call ttm manager debug Date: Fri, 31 Jul 2020 14:04:32 +1000 Message-Id: <20200731040520.3701599-2-airlied@gmail.com> In-Reply-To: <20200731040520.3701599-1-airlied@gmail.com> References: <20200731040520.3701599-1-airlied@gmail.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=airlied@gmail.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: gmail.com X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: christian.koenig@amd.com, sroland@vmware.com, bskeggs@redhat.com, kraxel@redhat.com Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Dave Airlie This code was poking inside a struct and assuming it was a drm_mm at the start. Call the proper API. Signed-off-by: Dave Airlie --- drivers/gpu/drm/qxl/qxl_ttm.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/drivers/gpu/drm/qxl/qxl_ttm.c b/drivers/gpu/drm/qxl/qxl_ttm.c index 759c9d601072..59478761efe8 100644 --- a/drivers/gpu/drm/qxl/qxl_ttm.c +++ b/drivers/gpu/drm/qxl/qxl_ttm.c @@ -279,12 +279,10 @@ void qxl_ttm_fini(struct qxl_device *qdev) static int qxl_mm_dump_table(struct seq_file *m, void *data) { struct drm_info_node *node = (struct drm_info_node *)m->private; - struct drm_mm *mm = (struct drm_mm *)node->info_ent->data; + struct ttm_mem_type_manager *man = (struct ttm_mem_type_manager *)node->info_ent->data; struct drm_printer p = drm_seq_file_printer(m); - spin_lock(&ttm_bo_glob.lru_lock); - drm_mm_print(mm, &p); - spin_unlock(&ttm_bo_glob.lru_lock); + man->func->debug(man, &p); return 0; } #endif @@ -305,9 +303,9 @@ void qxl_ttm_debugfs_init(struct qxl_device *qdev) qxl_mem_types_list[i].show = &qxl_mm_dump_table; qxl_mem_types_list[i].driver_features = 0; if (i == 0) - qxl_mem_types_list[i].data = qdev->mman.bdev.man[TTM_PL_VRAM].priv; + qxl_mem_types_list[i].data = &qdev->mman.bdev.man[TTM_PL_VRAM]; else - qxl_mem_types_list[i].data = qdev->mman.bdev.man[TTM_PL_PRIV].priv; + qxl_mem_types_list[i].data = &qdev->mman.bdev.man[TTM_PL_PRIV]; } qxl_debugfs_add_files(qdev, qxl_mem_types_list, i); From patchwork Fri Jul 31 04:04:33 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Airlie X-Patchwork-Id: 11693965 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id AC9191746 for ; Fri, 31 Jul 2020 04:05:43 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 94F66206FA for ; Fri, 31 Jul 2020 04:05:43 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 94F66206FA Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 115E26E997; Fri, 31 Jul 2020 04:05:38 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from us-smtp-delivery-1.mimecast.com (us-smtp-2.mimecast.com [207.211.31.81]) by gabe.freedesktop.org (Postfix) with ESMTPS id 0B3266E997 for ; Fri, 31 Jul 2020 04:05:36 +0000 (UTC) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-61-iVI-tFBsMpajHVrqhsedxg-1; Fri, 31 Jul 2020 00:05:33 -0400 X-MC-Unique: iVI-tFBsMpajHVrqhsedxg-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 352E1106B244; Fri, 31 Jul 2020 04:05:32 +0000 (UTC) Received: from tyrion-bne-redhat-com.redhat.com (vpn2-54-17.bne.redhat.com [10.64.54.17]) by smtp.corp.redhat.com (Postfix) with ESMTP id BA5431001281; Fri, 31 Jul 2020 04:05:30 +0000 (UTC) From: Dave Airlie To: dri-devel@lists.freedesktop.org Subject: [PATCH 02/49] drm/vram-helper: call the ttm manager debug function Date: Fri, 31 Jul 2020 14:04:33 +1000 Message-Id: <20200731040520.3701599-3-airlied@gmail.com> In-Reply-To: <20200731040520.3701599-1-airlied@gmail.com> References: <20200731040520.3701599-1-airlied@gmail.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=airlied@gmail.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: gmail.com X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: christian.koenig@amd.com, sroland@vmware.com, bskeggs@redhat.com, kraxel@redhat.com Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Dave Airlie This code was assuming there was a drm_mm here, don't do that call the correct API. Signed-off-by: Dave Airlie Reviewed-by: Thomas Zimmermann --- drivers/gpu/drm/drm_gem_vram_helper.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/drm_gem_vram_helper.c b/drivers/gpu/drm/drm_gem_vram_helper.c index a93a00966f3a..b6f158ab0f5a 100644 --- a/drivers/gpu/drm/drm_gem_vram_helper.c +++ b/drivers/gpu/drm/drm_gem_vram_helper.c @@ -1075,12 +1075,10 @@ static int drm_vram_mm_debugfs(struct seq_file *m, void *data) { struct drm_info_node *node = (struct drm_info_node *) m->private; struct drm_vram_mm *vmm = node->minor->dev->vram_mm; - struct drm_mm *mm = vmm->bdev.man[TTM_PL_VRAM].priv; + struct ttm_mem_type_manager *man = &vmm->bdev.man[TTM_PL_VRAM]; struct drm_printer p = drm_seq_file_printer(m); - spin_lock(&ttm_bo_glob.lru_lock); - drm_mm_print(mm, &p); - spin_unlock(&ttm_bo_glob.lru_lock); + man->func->debug(man, &p); return 0; } From patchwork Fri Jul 31 04:04:34 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Airlie X-Patchwork-Id: 11693969 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 52BAB1746 for ; Fri, 31 Jul 2020 04:05:48 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 3A9FB208E4 for ; Fri, 31 Jul 2020 04:05:48 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3A9FB208E4 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id BD0936E998; Fri, 31 Jul 2020 04:05:41 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from us-smtp-delivery-1.mimecast.com (us-smtp-1.mimecast.com [205.139.110.61]) by gabe.freedesktop.org (Postfix) with ESMTPS id 47FEF6E998 for ; Fri, 31 Jul 2020 04:05:39 +0000 (UTC) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-96-eEostovOOAWtU2g8BYZ_ZA-1; Fri, 31 Jul 2020 00:05:35 -0400 X-MC-Unique: eEostovOOAWtU2g8BYZ_ZA-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 0E2BC1DE4; Fri, 31 Jul 2020 04:05:34 +0000 (UTC) Received: from tyrion-bne-redhat-com.redhat.com (vpn2-54-17.bne.redhat.com [10.64.54.17]) by smtp.corp.redhat.com (Postfix) with ESMTP id 942CF100238C; Fri, 31 Jul 2020 04:05:32 +0000 (UTC) From: Dave Airlie To: dri-devel@lists.freedesktop.org Subject: [PATCH 03/49] drm/ttm: split the mm manager init code Date: Fri, 31 Jul 2020 14:04:34 +1000 Message-Id: <20200731040520.3701599-4-airlied@gmail.com> In-Reply-To: <20200731040520.3701599-1-airlied@gmail.com> References: <20200731040520.3701599-1-airlied@gmail.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: gmail.com X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: christian.koenig@amd.com, sroland@vmware.com, bskeggs@redhat.com, kraxel@redhat.com Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Dave Airlie This will allow the driver to control the ordering here better. Eventually the old path will be removed. Signed-off-by: Dave Airlie --- drivers/gpu/drm/ttm/ttm_bo.c | 34 +++++++++++++++++++-------------- include/drm/ttm/ttm_bo_api.h | 4 ++++ include/drm/ttm/ttm_bo_driver.h | 6 ++++++ 3 files changed, 30 insertions(+), 14 deletions(-) diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c index 041a0e73cd1b..a658fd584c6d 100644 --- a/drivers/gpu/drm/ttm/ttm_bo.c +++ b/drivers/gpu/drm/ttm/ttm_bo.c @@ -1503,35 +1503,41 @@ int ttm_bo_evict_mm(struct ttm_bo_device *bdev, unsigned mem_type) } EXPORT_SYMBOL(ttm_bo_evict_mm); -int ttm_bo_init_mm(struct ttm_bo_device *bdev, unsigned type, - unsigned long p_size) +void ttm_bo_init_mm_base(struct ttm_bo_device *bdev, + struct ttm_mem_type_manager *man, + unsigned long p_size) { - int ret; - struct ttm_mem_type_manager *man; unsigned i; - BUG_ON(type >= TTM_NUM_MEM_TYPES); - man = &bdev->man[type]; BUG_ON(man->has_type); man->use_io_reserve_lru = false; mutex_init(&man->io_reserve_mutex); spin_lock_init(&man->move_lock); INIT_LIST_HEAD(&man->io_reserve_lru); man->bdev = bdev; - - if (type != TTM_PL_SYSTEM) { - ret = (*man->func->init)(man, p_size); - if (ret) - return ret; - } - man->has_type = true; - man->use_type = true; man->size = p_size; for (i = 0; i < TTM_MAX_BO_PRIORITY; ++i) INIT_LIST_HEAD(&man->lru[i]); man->move = NULL; +} +EXPORT_SYMBOL(ttm_bo_init_mm_base); +int ttm_bo_init_mm(struct ttm_bo_device *bdev, unsigned type, + unsigned long p_size) +{ + int ret; + struct ttm_mem_type_manager *man; + + BUG_ON(type >= TTM_NUM_MEM_TYPES); + ttm_bo_init_mm_base(bdev, &bdev->man[type], p_size); + + if (type != TTM_PL_SYSTEM) { + ret = (*man->func->init)(man, p_size); + if (ret) + return ret; + } + ttm_bo_use_mm(man); return 0; } EXPORT_SYMBOL(ttm_bo_init_mm); diff --git a/include/drm/ttm/ttm_bo_api.h b/include/drm/ttm/ttm_bo_api.h index a9e13b252820..0060925f507a 100644 --- a/include/drm/ttm/ttm_bo_api.h +++ b/include/drm/ttm/ttm_bo_api.h @@ -546,6 +546,10 @@ int ttm_bo_create(struct ttm_bo_device *bdev, unsigned long size, * -ENOMEM: Not enough memory. * May also return driver-specified errors. */ +struct ttm_mem_type_manager; +void ttm_bo_init_mm_base(struct ttm_bo_device *bdev, + struct ttm_mem_type_manager *man, + unsigned long p_size); int ttm_bo_init_mm(struct ttm_bo_device *bdev, unsigned type, unsigned long p_size); diff --git a/include/drm/ttm/ttm_bo_driver.h b/include/drm/ttm/ttm_bo_driver.h index 7958e411269a..68e75c3b8c7a 100644 --- a/include/drm/ttm/ttm_bo_driver.h +++ b/include/drm/ttm/ttm_bo_driver.h @@ -678,6 +678,12 @@ static inline void ttm_bo_unreserve(struct ttm_buffer_object *bo) dma_resv_unlock(bo->base.resv); } +static inline void ttm_bo_use_mm(struct ttm_mem_type_manager *man) +{ + man->has_type = true; + man->use_type = true; +} + /* * ttm_bo_util.c */ From patchwork Fri Jul 31 04:04:35 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Dave Airlie X-Patchwork-Id: 11693973 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 54242161F for ; Fri, 31 Jul 2020 04:05:52 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 3C81A2070B for ; Fri, 31 Jul 2020 04:05:52 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3C81A2070B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 6C93E6E99B; Fri, 31 Jul 2020 04:05:48 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) by gabe.freedesktop.org (Postfix) with ESMTPS id 086846E99A for ; Fri, 31 Jul 2020 04:05:42 +0000 (UTC) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-44-TgJYh5HKNIm0-cht0girwg-1; Fri, 31 Jul 2020 00:05:36 -0400 X-MC-Unique: TgJYh5HKNIm0-cht0girwg-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id DCA8F8015CE; Fri, 31 Jul 2020 04:05:35 +0000 (UTC) Received: from tyrion-bne-redhat-com.redhat.com (vpn2-54-17.bne.redhat.com [10.64.54.17]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6DC3A1001281; Fri, 31 Jul 2020 04:05:34 +0000 (UTC) From: Dave Airlie To: dri-devel@lists.freedesktop.org Subject: [PATCH 04/49] drm/ttm: provide a driver-led init path for generic mm manager. Date: Fri, 31 Jul 2020 14:04:35 +1000 Message-Id: <20200731040520.3701599-5-airlied@gmail.com> In-Reply-To: <20200731040520.3701599-1-airlied@gmail.com> References: <20200731040520.3701599-1-airlied@gmail.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=airlied@gmail.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: gmail.com X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: christian.koenig@amd.com, sroland@vmware.com, bskeggs@redhat.com, kraxel@redhat.com Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Dave Airlie This lets the generic mm manager be initialised by the driver. Signed-off-by: Dave Airlie Reviewed-by: Christian König --- drivers/gpu/drm/ttm/ttm_bo_manager.c | 23 ++++++++++++++++++++--- include/drm/ttm/ttm_bo_driver.h | 3 +++ 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/ttm/ttm_bo_manager.c b/drivers/gpu/drm/ttm/ttm_bo_manager.c index facd3049c3aa..64234e5caee3 100644 --- a/drivers/gpu/drm/ttm/ttm_bo_manager.c +++ b/drivers/gpu/drm/ttm/ttm_bo_manager.c @@ -104,8 +104,8 @@ static void ttm_bo_man_put_node(struct ttm_mem_type_manager *man, } } -static int ttm_bo_man_init(struct ttm_mem_type_manager *man, - unsigned long p_size) +static int ttm_bo_man_init_private(struct ttm_mem_type_manager *man, + unsigned long p_size) { struct ttm_range_manager *rman; @@ -119,6 +119,23 @@ static int ttm_bo_man_init(struct ttm_mem_type_manager *man, return 0; } +int ttm_bo_man_init(struct ttm_bo_device *bdev, + struct ttm_mem_type_manager *man, + unsigned long p_size) +{ + int ret; + + man->func = &ttm_bo_manager_func; + + ttm_bo_init_mm_base(bdev, man, p_size); + ret = ttm_bo_man_init_private(man, p_size); + if (ret) + return ret; + ttm_bo_use_mm(man); + return 0; +} +EXPORT_SYMBOL(ttm_bo_man_init); + static int ttm_bo_man_takedown(struct ttm_mem_type_manager *man) { struct ttm_range_manager *rman = (struct ttm_range_manager *) man->priv; @@ -147,7 +164,7 @@ static void ttm_bo_man_debug(struct ttm_mem_type_manager *man, } const struct ttm_mem_type_manager_func ttm_bo_manager_func = { - .init = ttm_bo_man_init, + .init = ttm_bo_man_init_private, .takedown = ttm_bo_man_takedown, .get_node = ttm_bo_man_get_node, .put_node = ttm_bo_man_put_node, diff --git a/include/drm/ttm/ttm_bo_driver.h b/include/drm/ttm/ttm_bo_driver.h index 68e75c3b8c7a..5c4ccefd5393 100644 --- a/include/drm/ttm/ttm_bo_driver.h +++ b/include/drm/ttm/ttm_bo_driver.h @@ -799,6 +799,9 @@ int ttm_bo_pipeline_gutting(struct ttm_buffer_object *bo); */ pgprot_t ttm_io_prot(uint32_t caching_flags, pgprot_t tmp); +int ttm_bo_man_init(struct ttm_bo_device *bdev, + struct ttm_mem_type_manager *man, + unsigned long p_size); extern const struct ttm_mem_type_manager_func ttm_bo_manager_func; #endif From patchwork Fri Jul 31 04:04:36 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Airlie X-Patchwork-Id: 11693971 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7CC0214B7 for ; Fri, 31 Jul 2020 04:05:50 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 6576C2070B for ; Fri, 31 Jul 2020 04:05:50 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6576C2070B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 102716E99A; Fri, 31 Jul 2020 04:05:48 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from us-smtp-delivery-1.mimecast.com (us-smtp-2.mimecast.com [207.211.31.81]) by gabe.freedesktop.org (Postfix) with ESMTPS id 796C66E99A for ; Fri, 31 Jul 2020 04:05:43 +0000 (UTC) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-197-16L6B0orM_KMkREyWIPjGw-1; Fri, 31 Jul 2020 00:05:38 -0400 X-MC-Unique: 16L6B0orM_KMkREyWIPjGw-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id B6A9F107ACCA; Fri, 31 Jul 2020 04:05:37 +0000 (UTC) Received: from tyrion-bne-redhat-com.redhat.com (vpn2-54-17.bne.redhat.com [10.64.54.17]) by smtp.corp.redhat.com (Postfix) with ESMTP id 47E6F100238C; Fri, 31 Jul 2020 04:05:36 +0000 (UTC) From: Dave Airlie To: dri-devel@lists.freedesktop.org Subject: [PATCH 05/49] drm/amdgpu/ttm: init managers from the driver side. Date: Fri, 31 Jul 2020 14:04:36 +1000 Message-Id: <20200731040520.3701599-6-airlied@gmail.com> In-Reply-To: <20200731040520.3701599-1-airlied@gmail.com> References: <20200731040520.3701599-1-airlied@gmail.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: gmail.com X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: christian.koenig@amd.com, sroland@vmware.com, bskeggs@redhat.com, kraxel@redhat.com Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Dave Airlie Use new init calls to unwrap manager init Signed-off-by: Dave Airlie --- drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c | 19 ++++++---- drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 37 +++----------------- drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h | 4 +-- drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c | 19 ++++++---- 4 files changed, 33 insertions(+), 46 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c index 77fae40197ab..5f58aa2eac4a 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c @@ -76,6 +76,7 @@ static DEVICE_ATTR(mem_info_gtt_total, S_IRUGO, static DEVICE_ATTR(mem_info_gtt_used, S_IRUGO, amdgpu_mem_info_gtt_used_show, NULL); +static const struct ttm_mem_type_manager_func amdgpu_gtt_mgr_func; /** * amdgpu_gtt_mgr_init - init GTT manager and DRM MM * @@ -84,14 +85,20 @@ static DEVICE_ATTR(mem_info_gtt_used, S_IRUGO, * * Allocate and initialize the GTT manager. */ -static int amdgpu_gtt_mgr_init(struct ttm_mem_type_manager *man, - unsigned long p_size) +int amdgpu_gtt_mgr_init(struct amdgpu_device *adev, uint64_t gtt_size) { - struct amdgpu_device *adev = amdgpu_ttm_adev(man->bdev); + struct ttm_mem_type_manager *man = &adev->mman.bdev.man[TTM_PL_TT]; struct amdgpu_gtt_mgr *mgr; uint64_t start, size; int ret; + man->use_tt = true; + man->func = &amdgpu_gtt_mgr_func; + man->available_caching = TTM_PL_MASK_CACHING; + man->default_caching = TTM_PL_FLAG_CACHED; + + ttm_bo_init_mm_base(&adev->mman.bdev, man, gtt_size >> PAGE_SHIFT); + mgr = kzalloc(sizeof(*mgr), GFP_KERNEL); if (!mgr) return -ENOMEM; @@ -100,7 +107,7 @@ static int amdgpu_gtt_mgr_init(struct ttm_mem_type_manager *man, size = (adev->gmc.gart_size >> PAGE_SHIFT) - start; drm_mm_init(&mgr->mm, start, size); spin_lock_init(&mgr->lock); - atomic64_set(&mgr->available, p_size); + atomic64_set(&mgr->available, gtt_size >> PAGE_SHIFT); man->priv = mgr; ret = device_create_file(adev->dev, &dev_attr_mem_info_gtt_total); @@ -114,6 +121,7 @@ static int amdgpu_gtt_mgr_init(struct ttm_mem_type_manager *man, return ret; } + ttm_bo_use_mm(man); return 0; } @@ -298,8 +306,7 @@ static void amdgpu_gtt_mgr_debug(struct ttm_mem_type_manager *man, amdgpu_gtt_mgr_usage(man) >> 20); } -const struct ttm_mem_type_manager_func amdgpu_gtt_mgr_func = { - .init = amdgpu_gtt_mgr_init, +static const struct ttm_mem_type_manager_func amdgpu_gtt_mgr_func = { .takedown = amdgpu_gtt_mgr_fini, .get_node = amdgpu_gtt_mgr_new, .put_node = amdgpu_gtt_mgr_del, diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c index d3e3cad4d0cb..f1bf86b8de14 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c @@ -63,43 +63,16 @@ #define AMDGPU_TTM_VRAM_MAX_DW_READ (size_t)128 -static int amdgpu_ttm_init_vram(struct amdgpu_device *adev) -{ - - struct ttm_mem_type_manager *man = &adev->mman.bdev.man[TTM_PL_VRAM]; - - man->func = &amdgpu_vram_mgr_func; - man->available_caching = TTM_PL_FLAG_UNCACHED | TTM_PL_FLAG_WC; - man->default_caching = TTM_PL_FLAG_WC; - - return ttm_bo_init_mm(&adev->mman.bdev, TTM_PL_VRAM, - adev->gmc.real_vram_size >> PAGE_SHIFT); -} - -static int amdgpu_ttm_init_gtt(struct amdgpu_device *adev, uint64_t gtt_size) -{ - struct ttm_mem_type_manager *man = &adev->mman.bdev.man[TTM_PL_TT]; - - man->use_tt = true; - man->func = &amdgpu_gtt_mgr_func; - man->available_caching = TTM_PL_MASK_CACHING; - man->default_caching = TTM_PL_FLAG_CACHED; - - return ttm_bo_init_mm(&adev->mman.bdev, TTM_PL_TT, - gtt_size >> PAGE_SHIFT); -} - static int amdgpu_ttm_init_on_chip(struct amdgpu_device *adev, - unsigned int type, - uint64_t size) + unsigned int type, + uint64_t size) { struct ttm_mem_type_manager *man = &adev->mman.bdev.man[type]; - man->func = &ttm_bo_manager_func; man->available_caching = TTM_PL_FLAG_UNCACHED; man->default_caching = TTM_PL_FLAG_UNCACHED; - return ttm_bo_init_mm(&adev->mman.bdev, type, size); + return ttm_bo_man_init(&adev->mman.bdev, man, size >> PAGE_SHIFT); } /** @@ -1915,7 +1888,7 @@ int amdgpu_ttm_init(struct amdgpu_device *adev) adev->mman.bdev.no_retry = true; /* Initialize VRAM pool with all of VRAM divided into pages */ - r = amdgpu_ttm_init_vram(adev); + r = amdgpu_vram_mgr_init(adev); if (r) { DRM_ERROR("Failed initializing VRAM heap.\n"); return r; @@ -1982,7 +1955,7 @@ int amdgpu_ttm_init(struct amdgpu_device *adev) gtt_size = (uint64_t)amdgpu_gtt_size << 20; /* Initialize GTT memory pool */ - r = amdgpu_ttm_init_gtt(adev, gtt_size); + r = amdgpu_gtt_mgr_init(adev, gtt_size); if (r) { DRM_ERROR("Failed initializing GTT heap.\n"); return r; diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h index 17c8d0d7bcc3..fb45c0a323b0 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h @@ -67,8 +67,8 @@ struct amdgpu_copy_mem { unsigned long offset; }; -extern const struct ttm_mem_type_manager_func amdgpu_gtt_mgr_func; -extern const struct ttm_mem_type_manager_func amdgpu_vram_mgr_func; +int amdgpu_gtt_mgr_init(struct amdgpu_device *adev, uint64_t gtt_size); +int amdgpu_vram_mgr_init(struct amdgpu_device *adev); bool amdgpu_gtt_mgr_has_gart_addr(struct ttm_mem_reg *mem); uint64_t amdgpu_gtt_mgr_usage(struct ttm_mem_type_manager *man); diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c index 134cc36e30c5..1bc04835c24f 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c @@ -158,6 +158,8 @@ static const struct attribute *amdgpu_vram_mgr_attributes[] = { NULL }; +static const struct ttm_mem_type_manager_func amdgpu_vram_mgr_func; + /** * amdgpu_vram_mgr_init - init VRAM manager and DRM MM * @@ -166,18 +168,23 @@ static const struct attribute *amdgpu_vram_mgr_attributes[] = { * * Allocate and initialize the VRAM manager. */ -static int amdgpu_vram_mgr_init(struct ttm_mem_type_manager *man, - unsigned long p_size) +int amdgpu_vram_mgr_init(struct amdgpu_device *adev) { - struct amdgpu_device *adev = amdgpu_ttm_adev(man->bdev); + struct ttm_mem_type_manager *man = &adev->mman.bdev.man[TTM_PL_VRAM]; struct amdgpu_vram_mgr *mgr; int ret; + man->available_caching = TTM_PL_FLAG_UNCACHED | TTM_PL_FLAG_WC; + man->default_caching = TTM_PL_FLAG_WC; + + ttm_bo_init_mm_base(&adev->mman.bdev, man, adev->gmc.real_vram_size >> PAGE_SHIFT); + + man->func = &amdgpu_vram_mgr_func; mgr = kzalloc(sizeof(*mgr), GFP_KERNEL); if (!mgr) return -ENOMEM; - drm_mm_init(&mgr->mm, 0, p_size); + drm_mm_init(&mgr->mm, 0, man->size); spin_lock_init(&mgr->lock); man->priv = mgr; @@ -186,6 +193,7 @@ static int amdgpu_vram_mgr_init(struct ttm_mem_type_manager *man, if (ret) DRM_ERROR("Failed to register sysfs\n"); + ttm_bo_use_mm(man); return 0; } @@ -587,8 +595,7 @@ static void amdgpu_vram_mgr_debug(struct ttm_mem_type_manager *man, amdgpu_vram_mgr_vis_usage(man) >> 20); } -const struct ttm_mem_type_manager_func amdgpu_vram_mgr_func = { - .init = amdgpu_vram_mgr_init, +static const struct ttm_mem_type_manager_func amdgpu_vram_mgr_func = { .takedown = amdgpu_vram_mgr_fini, .get_node = amdgpu_vram_mgr_new, .put_node = amdgpu_vram_mgr_del, From patchwork Fri Jul 31 04:04:37 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Airlie X-Patchwork-Id: 11693975 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id EA3F2161F for ; Fri, 31 Jul 2020 04:05:53 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id CE3822070B for ; Fri, 31 Jul 2020 04:05:53 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org CE3822070B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 0DF9A6E99C; Fri, 31 Jul 2020 04:05:49 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from us-smtp-delivery-1.mimecast.com (us-smtp-1.mimecast.com [207.211.31.81]) by gabe.freedesktop.org (Postfix) with ESMTPS id E300B6E99A for ; Fri, 31 Jul 2020 04:05:45 +0000 (UTC) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-315-5HGDgZpnPC6hDlxkeaahNA-1; Fri, 31 Jul 2020 00:05:40 -0400 X-MC-Unique: 5HGDgZpnPC6hDlxkeaahNA-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 91F7B106B243; Fri, 31 Jul 2020 04:05:39 +0000 (UTC) Received: from tyrion-bne-redhat-com.redhat.com (vpn2-54-17.bne.redhat.com [10.64.54.17]) by smtp.corp.redhat.com (Postfix) with ESMTP id 219EA100238C; Fri, 31 Jul 2020 04:05:37 +0000 (UTC) From: Dave Airlie To: dri-devel@lists.freedesktop.org Subject: [PATCH 06/49] drm/radeon: use new ttm man init path Date: Fri, 31 Jul 2020 14:04:37 +1000 Message-Id: <20200731040520.3701599-7-airlied@gmail.com> In-Reply-To: <20200731040520.3701599-1-airlied@gmail.com> References: <20200731040520.3701599-1-airlied@gmail.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: gmail.com X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: christian.koenig@amd.com, sroland@vmware.com, bskeggs@redhat.com, kraxel@redhat.com Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Dave Airlie Use the new common manager init path. Signed-off-by: Dave Airlie --- drivers/gpu/drm/radeon/radeon_ttm.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/drivers/gpu/drm/radeon/radeon_ttm.c b/drivers/gpu/drm/radeon/radeon_ttm.c index dbd1d2766279..a5043a5b7d89 100644 --- a/drivers/gpu/drm/radeon/radeon_ttm.c +++ b/drivers/gpu/drm/radeon/radeon_ttm.c @@ -70,19 +70,17 @@ static int radeon_ttm_init_vram(struct radeon_device *rdev) { struct ttm_mem_type_manager *man = &rdev->mman.bdev.man[TTM_PL_VRAM]; - man->func = &ttm_bo_manager_func; man->available_caching = TTM_PL_FLAG_UNCACHED | TTM_PL_FLAG_WC; man->default_caching = TTM_PL_FLAG_WC; - return ttm_bo_init_mm(&rdev->mman.bdev, TTM_PL_VRAM, - rdev->mc.real_vram_size >> PAGE_SHIFT); + return ttm_bo_man_init(&rdev->mman.bdev, man, + rdev->mc.real_vram_size >> PAGE_SHIFT); } static int radeon_ttm_init_gtt(struct radeon_device *rdev) { struct ttm_mem_type_manager *man = &rdev->mman.bdev.man[TTM_PL_TT]; - man->func = &ttm_bo_manager_func; man->available_caching = TTM_PL_MASK_CACHING; man->default_caching = TTM_PL_FLAG_CACHED; man->use_tt = true; @@ -98,7 +96,7 @@ static int radeon_ttm_init_gtt(struct radeon_device *rdev) } #endif - return ttm_bo_init_mm(&rdev->mman.bdev, TTM_PL_TT, + return ttm_bo_man_init(&rdev->mman.bdev, man, rdev->mc.gtt_size >> PAGE_SHIFT); } From patchwork Fri Jul 31 04:04:38 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Airlie X-Patchwork-Id: 11693977 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 41C8B161F for ; Fri, 31 Jul 2020 04:05:58 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 2A5472070B for ; Fri, 31 Jul 2020 04:05:58 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2A5472070B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 6068C6E99E; Fri, 31 Jul 2020 04:05:57 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) by gabe.freedesktop.org (Postfix) with ESMTPS id 4E4F86E99E for ; Fri, 31 Jul 2020 04:05:49 +0000 (UTC) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-223-Q7JYPOYlMNOCXBb_xkuyMA-1; Fri, 31 Jul 2020 00:05:42 -0400 X-MC-Unique: Q7JYPOYlMNOCXBb_xkuyMA-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 67E34106B242; Fri, 31 Jul 2020 04:05:41 +0000 (UTC) Received: from tyrion-bne-redhat-com.redhat.com (vpn2-54-17.bne.redhat.com [10.64.54.17]) by smtp.corp.redhat.com (Postfix) with ESMTP id EEAEC100238C; Fri, 31 Jul 2020 04:05:39 +0000 (UTC) From: Dave Airlie To: dri-devel@lists.freedesktop.org Subject: [PATCH 07/49] drm/qxl/ttm: use new init path for manager Date: Fri, 31 Jul 2020 14:04:38 +1000 Message-Id: <20200731040520.3701599-8-airlied@gmail.com> In-Reply-To: <20200731040520.3701599-1-airlied@gmail.com> References: <20200731040520.3701599-1-airlied@gmail.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: gmail.com X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: christian.koenig@amd.com, sroland@vmware.com, bskeggs@redhat.com, kraxel@redhat.com Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Dave Airlie Signed-off-by: Dave Airlie --- drivers/gpu/drm/qxl/qxl_ttm.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/gpu/drm/qxl/qxl_ttm.c b/drivers/gpu/drm/qxl/qxl_ttm.c index 59478761efe8..ac22971cd20b 100644 --- a/drivers/gpu/drm/qxl/qxl_ttm.c +++ b/drivers/gpu/drm/qxl/qxl_ttm.c @@ -221,11 +221,10 @@ static int qxl_ttm_init_mem_type(struct qxl_device *qdev, { struct ttm_mem_type_manager *man = &qdev->mman.bdev.man[type]; - man->func = &ttm_bo_manager_func; man->available_caching = TTM_PL_MASK_CACHING; man->default_caching = TTM_PL_FLAG_CACHED; - return ttm_bo_init_mm(&qdev->mman.bdev, type, size); + return ttm_bo_man_init(&qdev->mman.bdev, man, size); } int qxl_ttm_init(struct qxl_device *qdev) From patchwork Fri Jul 31 04:04:39 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Airlie X-Patchwork-Id: 11693979 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0AB9414B7 for ; Fri, 31 Jul 2020 04:06:00 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id E6A872070B for ; Fri, 31 Jul 2020 04:05:59 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E6A872070B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id C58476E99D; Fri, 31 Jul 2020 04:05:57 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) by gabe.freedesktop.org (Postfix) with ESMTPS id EBCAA6E99D for ; Fri, 31 Jul 2020 04:05:50 +0000 (UTC) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-474-B5t0dH_aPDmV826WtWdVbw-1; Fri, 31 Jul 2020 00:05:44 -0400 X-MC-Unique: B5t0dH_aPDmV826WtWdVbw-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 40405106B244; Fri, 31 Jul 2020 04:05:43 +0000 (UTC) Received: from tyrion-bne-redhat-com.redhat.com (vpn2-54-17.bne.redhat.com [10.64.54.17]) by smtp.corp.redhat.com (Postfix) with ESMTP id C6CA2100238C; Fri, 31 Jul 2020 04:05:41 +0000 (UTC) From: Dave Airlie To: dri-devel@lists.freedesktop.org Subject: [PATCH 08/49] drm/vram_helper: use new ttm manager init function Date: Fri, 31 Jul 2020 14:04:39 +1000 Message-Id: <20200731040520.3701599-9-airlied@gmail.com> In-Reply-To: <20200731040520.3701599-1-airlied@gmail.com> References: <20200731040520.3701599-1-airlied@gmail.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: gmail.com X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: christian.koenig@amd.com, sroland@vmware.com, bskeggs@redhat.com, kraxel@redhat.com Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Dave Airlie Signed-off-by: Dave Airlie --- drivers/gpu/drm/drm_gem_vram_helper.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/gpu/drm/drm_gem_vram_helper.c b/drivers/gpu/drm/drm_gem_vram_helper.c index b6f158ab0f5a..8a5d45a55ac7 100644 --- a/drivers/gpu/drm/drm_gem_vram_helper.c +++ b/drivers/gpu/drm/drm_gem_vram_helper.c @@ -1116,10 +1116,9 @@ static int drm_vram_mm_init(struct drm_vram_mm *vmm, struct drm_device *dev, if (ret) return ret; - man->func = &ttm_bo_manager_func; man->available_caching = TTM_PL_FLAG_UNCACHED | TTM_PL_FLAG_WC; man->default_caching = TTM_PL_FLAG_WC; - ret = ttm_bo_init_mm(&vmm->bdev, TTM_PL_VRAM, vram_size >> PAGE_SHIFT); + ret = ttm_bo_man_init(&vmm->bdev, man, vram_size >> PAGE_SHIFT); if (ret) return ret; From patchwork Fri Jul 31 04:04:40 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Airlie X-Patchwork-Id: 11693993 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0BA4414B7 for ; Fri, 31 Jul 2020 04:06:22 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id E8761208E4 for ; Fri, 31 Jul 2020 04:06:21 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E8761208E4 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 894786E9A7; Fri, 31 Jul 2020 04:06:19 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) by gabe.freedesktop.org (Postfix) with ESMTPS id 0BF0B6E99D for ; Fri, 31 Jul 2020 04:05:56 +0000 (UTC) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-378-laiUDazLMQaMe2vcagr-lw-1; Fri, 31 Jul 2020 00:05:49 -0400 X-MC-Unique: laiUDazLMQaMe2vcagr-lw-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id E09D618839CA; Fri, 31 Jul 2020 04:05:47 +0000 (UTC) Received: from tyrion-bne-redhat-com.redhat.com (vpn2-54-17.bne.redhat.com [10.64.54.17]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9EF4A100238C; Fri, 31 Jul 2020 04:05:43 +0000 (UTC) From: Dave Airlie To: dri-devel@lists.freedesktop.org Subject: [PATCH 09/49] drm/nouveau: use new memory manager init paths Date: Fri, 31 Jul 2020 14:04:40 +1000 Message-Id: <20200731040520.3701599-10-airlied@gmail.com> In-Reply-To: <20200731040520.3701599-1-airlied@gmail.com> References: <20200731040520.3701599-1-airlied@gmail.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: gmail.com X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: christian.koenig@amd.com, sroland@vmware.com, bskeggs@redhat.com, kraxel@redhat.com Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Dave Airlie Signed-off-by: Dave Airlie --- drivers/gpu/drm/nouveau/nouveau_ttm.c | 43 ++++++++++++--------------- 1 file changed, 19 insertions(+), 24 deletions(-) diff --git a/drivers/gpu/drm/nouveau/nouveau_ttm.c b/drivers/gpu/drm/nouveau/nouveau_ttm.c index b0012021ae12..e3c57c612765 100644 --- a/drivers/gpu/drm/nouveau/nouveau_ttm.c +++ b/drivers/gpu/drm/nouveau/nouveau_ttm.c @@ -31,12 +31,6 @@ #include -static int -nouveau_manager_init(struct ttm_mem_type_manager *man, unsigned long psize) -{ - return 0; -} - static int nouveau_manager_fini(struct ttm_mem_type_manager *man) { @@ -82,7 +76,6 @@ nouveau_vram_manager_new(struct ttm_mem_type_manager *man, } const struct ttm_mem_type_manager_func nouveau_vram_manager = { - .init = nouveau_manager_init, .takedown = nouveau_manager_fini, .get_node = nouveau_vram_manager_new, .put_node = nouveau_manager_del, @@ -108,7 +101,6 @@ nouveau_gart_manager_new(struct ttm_mem_type_manager *man, } const struct ttm_mem_type_manager_func nouveau_gart_manager = { - .init = nouveau_manager_init, .takedown = nouveau_manager_fini, .get_node = nouveau_gart_manager_new, .put_node = nouveau_manager_del, @@ -143,7 +135,6 @@ nv04_gart_manager_new(struct ttm_mem_type_manager *man, } const struct ttm_mem_type_manager_func nv04_gart_manager = { - .init = nouveau_manager_init, .takedown = nouveau_manager_fini, .get_node = nv04_gart_manager_new, .put_node = nouveau_manager_del, @@ -200,27 +191,21 @@ nouveau_ttm_init_vram(struct nouveau_drm *drm) man->func = &nouveau_vram_manager; man->use_io_reserve_lru = true; + ttm_bo_init_mm_base(&drm->ttm.bdev, man, + drm->gem.vram_available >> PAGE_SHIFT); + ttm_bo_use_mm(man); + return 0; } else { - man->func = &ttm_bo_manager_func; + return ttm_bo_man_init(&drm->ttm.bdev, man, + drm->gem.vram_available >> PAGE_SHIFT); } - - return ttm_bo_init_mm(&drm->ttm.bdev, TTM_PL_VRAM, - drm->gem.vram_available >> PAGE_SHIFT); } static int nouveau_ttm_init_gtt(struct nouveau_drm *drm) { struct ttm_mem_type_manager *man = &drm->ttm.bdev.man[TTM_PL_TT]; - - if (drm->client.device.info.family >= NV_DEVICE_INFO_V0_TESLA) - man->func = &nouveau_gart_manager; - else - if (!drm->agp.bridge) - man->func = &nv04_gart_manager; - else - man->func = &ttm_bo_manager_func; - + unsigned long size_pages = drm->gem.gart_available >> PAGE_SHIFT; man->use_tt = true; if (drm->agp.bridge) { man->available_caching = TTM_PL_FLAG_UNCACHED | @@ -231,8 +216,18 @@ nouveau_ttm_init_gtt(struct nouveau_drm *drm) man->default_caching = TTM_PL_FLAG_CACHED; } - return ttm_bo_init_mm(&drm->ttm.bdev, TTM_PL_TT, - drm->gem.gart_available >> PAGE_SHIFT); + if (drm->client.device.info.family >= NV_DEVICE_INFO_V0_TESLA) + man->func = &nouveau_gart_manager; + else if (!drm->agp.bridge) + man->func = &nv04_gart_manager; + else + return ttm_bo_man_init(&drm->ttm.bdev, man, + size_pages); + + ttm_bo_init_mm_base(&drm->ttm.bdev, man, + size_pages); + ttm_bo_use_mm(man); + return 0; } int From patchwork Fri Jul 31 04:04:41 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Airlie X-Patchwork-Id: 11693981 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id DF3521746 for ; Fri, 31 Jul 2020 04:06:04 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id C6AF1208E4 for ; Fri, 31 Jul 2020 04:06:04 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C6AF1208E4 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id EDEBE6E99F; Fri, 31 Jul 2020 04:06:03 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) by gabe.freedesktop.org (Postfix) with ESMTPS id 2122A6E99F for ; Fri, 31 Jul 2020 04:06:00 +0000 (UTC) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-267-VhPbuxtsPz2k7uMlEgVyIw-1; Fri, 31 Jul 2020 00:05:53 -0400 X-MC-Unique: VhPbuxtsPz2k7uMlEgVyIw-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 2610118839C0; Fri, 31 Jul 2020 04:05:52 +0000 (UTC) Received: from tyrion-bne-redhat-com.redhat.com (vpn2-54-17.bne.redhat.com [10.64.54.17]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4BDC6100238C; Fri, 31 Jul 2020 04:05:48 +0000 (UTC) From: Dave Airlie To: dri-devel@lists.freedesktop.org Subject: [PATCH 10/49] drm/vmwgfx/ttm: convert vram mm init to new code paths Date: Fri, 31 Jul 2020 14:04:41 +1000 Message-Id: <20200731040520.3701599-11-airlied@gmail.com> In-Reply-To: <20200731040520.3701599-1-airlied@gmail.com> References: <20200731040520.3701599-1-airlied@gmail.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: gmail.com X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: christian.koenig@amd.com, sroland@vmware.com, bskeggs@redhat.com, kraxel@redhat.com Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Dave Airlie Split out the vram thp init path vs the range manager init. Signed-off-by: Dave Airlie --- drivers/gpu/drm/vmwgfx/vmwgfx_drv.c | 25 +++++++++++++++++++------ drivers/gpu/drm/vmwgfx/vmwgfx_drv.h | 4 +--- drivers/gpu/drm/vmwgfx/vmwgfx_thp.c | 12 ++++++++---- 3 files changed, 28 insertions(+), 13 deletions(-) diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c index e43f887cafb5..e11c20150ff6 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c @@ -620,6 +620,23 @@ static int vmw_dma_masks(struct vmw_private *dev_priv) return ret; } +static int vmw_init_vram_manager(struct vmw_private *dev_priv) +{ + int ret; +#ifdef CONFIG_TRANSPARENT_HUGEPAGE + ret = vmw_thp_init(dev_priv); +#else + struct ttm_mem_type_manager *man = &dev_priv->bdev.man[TTM_PL_VRAM]; + + man->available_caching = TTM_PL_FLAG_CACHED; + man->default_caching = TTM_PL_FLAG_CACHED; + + ret = ttm_bo_man_init(&dev_priv->bdev, man, + dev_priv->vram_size >> PAGE_SHIFT); +#endif + dev_priv->bdev.man[TTM_PL_VRAM].use_type = false; + return ret; +} static int vmw_driver_load(struct drm_device *dev, unsigned long chipset) { struct vmw_private *dev_priv; @@ -864,16 +881,12 @@ static int vmw_driver_load(struct drm_device *dev, unsigned long chipset) * Enable VRAM, but initially don't use it until SVGA is enabled and * unhidden. */ - dev_priv->bdev.man[TTM_PL_VRAM].func = &vmw_thp_func; - dev_priv->bdev.man[TTM_PL_VRAM].available_caching = TTM_PL_FLAG_CACHED; - dev_priv->bdev.man[TTM_PL_VRAM].default_caching = TTM_PL_FLAG_CACHED; - ret = ttm_bo_init_mm(&dev_priv->bdev, TTM_PL_VRAM, - (dev_priv->vram_size >> PAGE_SHIFT)); + + ret = vmw_init_vram_manager(dev_priv); if (unlikely(ret != 0)) { DRM_ERROR("Failed initializing memory manager for VRAM.\n"); goto out_no_vram; } - dev_priv->bdev.man[TTM_PL_VRAM].use_type = false; /* * "Guest Memory Regions" is an aperture like feature with diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h index 65c414f119c0..10b681725a53 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h @@ -1520,9 +1520,7 @@ vm_fault_t vmw_bo_vm_huge_fault(struct vm_fault *vmf, /* Transparent hugepage support - vmwgfx_thp.c */ #ifdef CONFIG_TRANSPARENT_HUGEPAGE -extern const struct ttm_mem_type_manager_func vmw_thp_func; -#else -#define vmw_thp_func ttm_bo_manager_func +extern int vmw_thp_init(struct vmw_private *dev_priv); #endif /** diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_thp.c b/drivers/gpu/drm/vmwgfx/vmwgfx_thp.c index b7c816ba7166..c4a9bee932c9 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_thp.c +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_thp.c @@ -115,18 +115,23 @@ static void vmw_thp_put_node(struct ttm_mem_type_manager *man, } } -static int vmw_thp_init(struct ttm_mem_type_manager *man, - unsigned long p_size) +int vmw_thp_init(struct vmw_private *dev_priv) { + struct ttm_mem_type_manager *man = &dev_priv->bdev.man[TTM_PL_VRAM]; struct vmw_thp_manager *rman; + man->available_caching = TTM_PL_FLAG_CACHED; + man->default_caching = TTM_PL_FLAG_CACHED; + ttm_bo_init_mm_base(&dev_priv->bdev, man, + dev_priv->vram_size >> PAGE_SHIFT); rman = kzalloc(sizeof(*rman), GFP_KERNEL); if (!rman) return -ENOMEM; - drm_mm_init(&rman->mm, 0, p_size); + drm_mm_init(&rman->mm, 0, man->size); spin_lock_init(&rman->lock); man->priv = rman; + ttm_bo_use_mm(man); return 0; } @@ -158,7 +163,6 @@ static void vmw_thp_debug(struct ttm_mem_type_manager *man, } const struct ttm_mem_type_manager_func vmw_thp_func = { - .init = vmw_thp_init, .takedown = vmw_thp_takedown, .get_node = vmw_thp_get_node, .put_node = vmw_thp_put_node, From patchwork Fri Jul 31 04:04:42 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Airlie X-Patchwork-Id: 11693983 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id EB1F414B7 for ; Fri, 31 Jul 2020 04:06:07 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id D3755208E4 for ; Fri, 31 Jul 2020 04:06:07 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D3755208E4 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 079356E9A1; Fri, 31 Jul 2020 04:06:07 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) by gabe.freedesktop.org (Postfix) with ESMTPS id 86F376E9A1 for ; Fri, 31 Jul 2020 04:06:00 +0000 (UTC) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-503-f8pvF-TlNLarEeSVwFTvig-1; Fri, 31 Jul 2020 00:05:55 -0400 X-MC-Unique: f8pvF-TlNLarEeSVwFTvig-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id F244F107ACCA; Fri, 31 Jul 2020 04:05:53 +0000 (UTC) Received: from tyrion-bne-redhat-com.redhat.com (vpn2-54-17.bne.redhat.com [10.64.54.17]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8592B100238C; Fri, 31 Jul 2020 04:05:52 +0000 (UTC) From: Dave Airlie To: dri-devel@lists.freedesktop.org Subject: [PATCH 11/49] drm/vmwgfx/ttm: switch gmrid allocator to new init paths. Date: Fri, 31 Jul 2020 14:04:42 +1000 Message-Id: <20200731040520.3701599-12-airlied@gmail.com> In-Reply-To: <20200731040520.3701599-1-airlied@gmail.com> References: <20200731040520.3701599-1-airlied@gmail.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: gmail.com X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: christian.koenig@amd.com, sroland@vmware.com, bskeggs@redhat.com, kraxel@redhat.com Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Dave Airlie Signed-off-by: Dave Airlie --- drivers/gpu/drm/vmwgfx/vmwgfx_drv.c | 17 ++++------------- drivers/gpu/drm/vmwgfx/vmwgfx_drv.h | 2 +- drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c | 19 ++++++++++++------- 3 files changed, 17 insertions(+), 21 deletions(-) diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c index e11c20150ff6..5ee5aa0aaa6a 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c @@ -894,14 +894,10 @@ static int vmw_driver_load(struct drm_device *dev, unsigned long chipset) * slots as well as the bo size. */ dev_priv->has_gmr = true; - dev_priv->bdev.man[VMW_PL_GMR].func = &vmw_gmrid_manager_func; - dev_priv->bdev.man[VMW_PL_GMR].available_caching = TTM_PL_FLAG_CACHED; - dev_priv->bdev.man[VMW_PL_GMR].default_caching = TTM_PL_FLAG_CACHED; /* TODO: This is most likely not correct */ - dev_priv->bdev.man[VMW_PL_GMR].use_tt = true; if (((dev_priv->capabilities & (SVGA_CAP_GMR | SVGA_CAP_GMR2)) == 0) || - refuse_dma || ttm_bo_init_mm(&dev_priv->bdev, VMW_PL_GMR, - VMW_PL_GMR) != 0) { + refuse_dma || + vmw_gmrid_man_init(dev_priv, VMW_PL_GMR) != 0) { DRM_INFO("No GMR memory available. " "Graphics memory resources are very limited.\n"); dev_priv->has_gmr = false; @@ -909,13 +905,8 @@ static int vmw_driver_load(struct drm_device *dev, unsigned long chipset) if (dev_priv->capabilities & SVGA_CAP_GBOBJECTS && !refuse_dma) { dev_priv->has_mob = true; - dev_priv->bdev.man[VMW_PL_MOB].func = &vmw_gmrid_manager_func; - dev_priv->bdev.man[VMW_PL_MOB].available_caching = TTM_PL_FLAG_CACHED; - dev_priv->bdev.man[VMW_PL_MOB].default_caching = TTM_PL_FLAG_CACHED; - /* TODO: This is most likely not correct */ - dev_priv->bdev.man[VMW_PL_MOB].use_tt = true; - if (ttm_bo_init_mm(&dev_priv->bdev, VMW_PL_MOB, - VMW_PL_MOB) != 0) { + + if (vmw_gmrid_man_init(dev_priv, VMW_PL_MOB) != 0) { DRM_INFO("No MOB memory available. " "3D will be disabled.\n"); dev_priv->has_mob = false; diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h index 10b681725a53..8f319dd6cdb4 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h @@ -1221,7 +1221,7 @@ int vmw_overlay_num_free_overlays(struct vmw_private *dev_priv); * GMR Id manager */ -extern const struct ttm_mem_type_manager_func vmw_gmrid_manager_func; +int vmw_gmrid_man_init(struct vmw_private *dev_priv, int type); /** * Prime - vmwgfx_prime.c diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c b/drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c index 4a76fc7114ad..e79d2c8abad2 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c @@ -94,22 +94,28 @@ static void vmw_gmrid_man_put_node(struct ttm_mem_type_manager *man, } } -static int vmw_gmrid_man_init(struct ttm_mem_type_manager *man, - unsigned long p_size) +static const struct ttm_mem_type_manager_func vmw_gmrid_manager_func; + +int vmw_gmrid_man_init(struct vmw_private *dev_priv, int type) { - struct vmw_private *dev_priv = - container_of(man->bdev, struct vmw_private, bdev); + struct ttm_mem_type_manager *man = &dev_priv->bdev.man[type]; struct vmwgfx_gmrid_man *gman = kzalloc(sizeof(*gman), GFP_KERNEL); if (unlikely(!gman)) return -ENOMEM; + man->func = &vmw_gmrid_manager_func; + man->available_caching = TTM_PL_FLAG_CACHED; + man->default_caching = TTM_PL_FLAG_CACHED; + /* TODO: This is most likely not correct */ + man->use_tt = true; + ttm_bo_init_mm_base(&dev_priv->bdev, man, 0); spin_lock_init(&gman->lock); gman->used_gmr_pages = 0; ida_init(&gman->gmr_ida); - switch (p_size) { + switch (type) { case VMW_PL_GMR: gman->max_gmr_ids = dev_priv->max_gmr_ids; gman->max_gmr_pages = dev_priv->max_gmr_pages; @@ -143,8 +149,7 @@ static void vmw_gmrid_man_debug(struct ttm_mem_type_manager *man, drm_printf(printer, "No debug info available for the GMR id manager\n"); } -const struct ttm_mem_type_manager_func vmw_gmrid_manager_func = { - .init = vmw_gmrid_man_init, +static const struct ttm_mem_type_manager_func vmw_gmrid_manager_func = { .takedown = vmw_gmrid_man_takedown, .get_node = vmw_gmrid_man_get_node, .put_node = vmw_gmrid_man_put_node, From patchwork Fri Jul 31 04:04:43 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Dave Airlie X-Patchwork-Id: 11693985 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E8B0514B7 for ; Fri, 31 Jul 2020 04:06:09 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id D10582070B for ; Fri, 31 Jul 2020 04:06:09 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D10582070B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 8FA836E9A3; Fri, 31 Jul 2020 04:06:07 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from us-smtp-delivery-1.mimecast.com (us-smtp-1.mimecast.com [207.211.31.81]) by gabe.freedesktop.org (Postfix) with ESMTPS id 3423F6E9A2 for ; Fri, 31 Jul 2020 04:06:04 +0000 (UTC) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-463-5wq4EH1qNd-hAF1Nw1WGzg-1; Fri, 31 Jul 2020 00:05:56 -0400 X-MC-Unique: 5wq4EH1qNd-hAF1Nw1WGzg-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id CAFA28015F3; Fri, 31 Jul 2020 04:05:55 +0000 (UTC) Received: from tyrion-bne-redhat-com.redhat.com (vpn2-54-17.bne.redhat.com [10.64.54.17]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5CEC6100238C; Fri, 31 Jul 2020 04:05:54 +0000 (UTC) From: Dave Airlie To: dri-devel@lists.freedesktop.org Subject: [PATCH 12/49] drm/ttm: convert system manager init to new code. Date: Fri, 31 Jul 2020 14:04:43 +1000 Message-Id: <20200731040520.3701599-13-airlied@gmail.com> In-Reply-To: <20200731040520.3701599-1-airlied@gmail.com> References: <20200731040520.3701599-1-airlied@gmail.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: gmail.com X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: christian.koenig@amd.com, sroland@vmware.com, bskeggs@redhat.com, kraxel@redhat.com Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Dave Airlie Remove the exit path, since this can't fail now. Signed-off-by: Dave Airlie Reviewed-by: Christian König --- drivers/gpu/drm/ttm/ttm_bo.c | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c index a658fd584c6d..476e768c5bd2 100644 --- a/drivers/gpu/drm/ttm/ttm_bo.c +++ b/drivers/gpu/drm/ttm/ttm_bo.c @@ -1644,6 +1644,22 @@ int ttm_bo_device_release(struct ttm_bo_device *bdev) } EXPORT_SYMBOL(ttm_bo_device_release); +static void ttm_bo_init_sysman(struct ttm_bo_device *bdev) +{ + struct ttm_mem_type_manager *man = &bdev->man[TTM_PL_SYSTEM]; + + /* + * Initialize the system memory buffer type. + * Other types need to be driver / IOCTL initialized. + */ + man->use_tt = true; + man->available_caching = TTM_PL_MASK_CACHING; + man->default_caching = TTM_PL_FLAG_CACHED; + + ttm_bo_init_mm_base(bdev, man, 0); + ttm_bo_use_mm(man); +} + int ttm_bo_device_init(struct ttm_bo_device *bdev, struct ttm_bo_driver *driver, struct address_space *mapping, @@ -1664,16 +1680,7 @@ int ttm_bo_device_init(struct ttm_bo_device *bdev, memset(bdev->man, 0, sizeof(bdev->man)); - /* - * Initialize the system memory buffer type. - * Other types need to be driver / IOCTL initialized. - */ - bdev->man[TTM_PL_SYSTEM].use_tt = true; - bdev->man[TTM_PL_SYSTEM].available_caching = TTM_PL_MASK_CACHING; - bdev->man[TTM_PL_SYSTEM].default_caching = TTM_PL_FLAG_CACHED; - ret = ttm_bo_init_mm(bdev, TTM_PL_SYSTEM, 0); - if (unlikely(ret != 0)) - goto out_no_sys; + ttm_bo_init_sysman(bdev); bdev->vma_manager = vma_manager; INIT_DELAYED_WORK(&bdev->wq, ttm_bo_delayed_workqueue); @@ -1685,9 +1692,6 @@ int ttm_bo_device_init(struct ttm_bo_device *bdev, mutex_unlock(&ttm_global_mutex); return 0; -out_no_sys: - ttm_bo_global_release(); - return ret; } EXPORT_SYMBOL(ttm_bo_device_init); From patchwork Fri Jul 31 04:04:44 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Dave Airlie X-Patchwork-Id: 11693989 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A1AF014B7 for ; Fri, 31 Jul 2020 04:06:12 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 8A1B52070B for ; Fri, 31 Jul 2020 04:06:12 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8A1B52070B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 5D2116E9A6; Fri, 31 Jul 2020 04:06:08 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) by gabe.freedesktop.org (Postfix) with ESMTPS id 91C886E99F for ; Fri, 31 Jul 2020 04:06:03 +0000 (UTC) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-105-6LuUpo3DNJecYmzLDggpyQ-1; Fri, 31 Jul 2020 00:05:58 -0400 X-MC-Unique: 6LuUpo3DNJecYmzLDggpyQ-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id A5FA68015CE; Fri, 31 Jul 2020 04:05:57 +0000 (UTC) Received: from tyrion-bne-redhat-com.redhat.com (vpn2-54-17.bne.redhat.com [10.64.54.17]) by smtp.corp.redhat.com (Postfix) with ESMTP id 36BAC100238C; Fri, 31 Jul 2020 04:05:56 +0000 (UTC) From: Dave Airlie To: dri-devel@lists.freedesktop.org Subject: [PATCH 13/49] drm/ttm: purge old manager init path. Date: Fri, 31 Jul 2020 14:04:44 +1000 Message-Id: <20200731040520.3701599-14-airlied@gmail.com> In-Reply-To: <20200731040520.3701599-1-airlied@gmail.com> References: <20200731040520.3701599-1-airlied@gmail.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=airlied@gmail.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: gmail.com X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: christian.koenig@amd.com, sroland@vmware.com, bskeggs@redhat.com, kraxel@redhat.com Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Dave Airlie Signed-off-by: Dave Airlie Reviewed-by: Christian König --- drivers/gpu/drm/ttm/ttm_bo.c | 19 ------------------- drivers/gpu/drm/ttm/ttm_bo_manager.c | 27 +++++++++------------------ include/drm/ttm/ttm_bo_api.h | 2 -- include/drm/ttm/ttm_bo_driver.h | 14 -------------- 4 files changed, 9 insertions(+), 53 deletions(-) diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c index 476e768c5bd2..101a7910f9f7 100644 --- a/drivers/gpu/drm/ttm/ttm_bo.c +++ b/drivers/gpu/drm/ttm/ttm_bo.c @@ -1523,25 +1523,6 @@ void ttm_bo_init_mm_base(struct ttm_bo_device *bdev, } EXPORT_SYMBOL(ttm_bo_init_mm_base); -int ttm_bo_init_mm(struct ttm_bo_device *bdev, unsigned type, - unsigned long p_size) -{ - int ret; - struct ttm_mem_type_manager *man; - - BUG_ON(type >= TTM_NUM_MEM_TYPES); - ttm_bo_init_mm_base(bdev, &bdev->man[type], p_size); - - if (type != TTM_PL_SYSTEM) { - ret = (*man->func->init)(man, p_size); - if (ret) - return ret; - } - ttm_bo_use_mm(man); - return 0; -} -EXPORT_SYMBOL(ttm_bo_init_mm); - static void ttm_bo_global_kobj_release(struct kobject *kobj) { struct ttm_bo_global *glob = diff --git a/drivers/gpu/drm/ttm/ttm_bo_manager.c b/drivers/gpu/drm/ttm/ttm_bo_manager.c index 64234e5caee3..1877425abdf0 100644 --- a/drivers/gpu/drm/ttm/ttm_bo_manager.c +++ b/drivers/gpu/drm/ttm/ttm_bo_manager.c @@ -104,11 +104,18 @@ static void ttm_bo_man_put_node(struct ttm_mem_type_manager *man, } } -static int ttm_bo_man_init_private(struct ttm_mem_type_manager *man, +static const struct ttm_mem_type_manager_func ttm_bo_manager_func; + +int ttm_bo_man_init(struct ttm_bo_device *bdev, + struct ttm_mem_type_manager *man, unsigned long p_size) { struct ttm_range_manager *rman; + man->func = &ttm_bo_manager_func; + + ttm_bo_init_mm_base(bdev, man, p_size); + rman = kzalloc(sizeof(*rman), GFP_KERNEL); if (!rman) return -ENOMEM; @@ -116,21 +123,7 @@ static int ttm_bo_man_init_private(struct ttm_mem_type_manager *man, drm_mm_init(&rman->mm, 0, p_size); spin_lock_init(&rman->lock); man->priv = rman; - return 0; -} -int ttm_bo_man_init(struct ttm_bo_device *bdev, - struct ttm_mem_type_manager *man, - unsigned long p_size) -{ - int ret; - - man->func = &ttm_bo_manager_func; - - ttm_bo_init_mm_base(bdev, man, p_size); - ret = ttm_bo_man_init_private(man, p_size); - if (ret) - return ret; ttm_bo_use_mm(man); return 0; } @@ -163,11 +156,9 @@ static void ttm_bo_man_debug(struct ttm_mem_type_manager *man, spin_unlock(&rman->lock); } -const struct ttm_mem_type_manager_func ttm_bo_manager_func = { - .init = ttm_bo_man_init_private, +static const struct ttm_mem_type_manager_func ttm_bo_manager_func = { .takedown = ttm_bo_man_takedown, .get_node = ttm_bo_man_get_node, .put_node = ttm_bo_man_put_node, .debug = ttm_bo_man_debug }; -EXPORT_SYMBOL(ttm_bo_manager_func); diff --git a/include/drm/ttm/ttm_bo_api.h b/include/drm/ttm/ttm_bo_api.h index 0060925f507a..6562d1c5ac59 100644 --- a/include/drm/ttm/ttm_bo_api.h +++ b/include/drm/ttm/ttm_bo_api.h @@ -550,8 +550,6 @@ struct ttm_mem_type_manager; void ttm_bo_init_mm_base(struct ttm_bo_device *bdev, struct ttm_mem_type_manager *man, unsigned long p_size); -int ttm_bo_init_mm(struct ttm_bo_device *bdev, unsigned type, - unsigned long p_size); /** * ttm_bo_clean_mm diff --git a/include/drm/ttm/ttm_bo_driver.h b/include/drm/ttm/ttm_bo_driver.h index 5c4ccefd5393..d0f1a6cdfba7 100644 --- a/include/drm/ttm/ttm_bo_driver.h +++ b/include/drm/ttm/ttm_bo_driver.h @@ -48,19 +48,6 @@ struct ttm_mem_type_manager; struct ttm_mem_type_manager_func { - /** - * struct ttm_mem_type_manager member init - * - * @man: Pointer to a memory type manager. - * @p_size: Implementation dependent, but typically the size of the - * range to be managed in pages. - * - * Called to initialize a private range manager. The function is - * expected to initialize the man::priv member. - * Returns 0 on success, negative error code on failure. - */ - int (*init)(struct ttm_mem_type_manager *man, unsigned long p_size); - /** * struct ttm_mem_type_manager member takedown * @@ -802,6 +789,5 @@ pgprot_t ttm_io_prot(uint32_t caching_flags, pgprot_t tmp); int ttm_bo_man_init(struct ttm_bo_device *bdev, struct ttm_mem_type_manager *man, unsigned long p_size); -extern const struct ttm_mem_type_manager_func ttm_bo_manager_func; #endif From patchwork Fri Jul 31 04:04:45 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Dave Airlie X-Patchwork-Id: 11693987 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5965F14B7 for ; Fri, 31 Jul 2020 04:06:11 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 41A4C2070B for ; Fri, 31 Jul 2020 04:06:11 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 41A4C2070B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 969FA6E9A4; Fri, 31 Jul 2020 04:06:07 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from us-smtp-delivery-1.mimecast.com (us-smtp-2.mimecast.com [207.211.31.81]) by gabe.freedesktop.org (Postfix) with ESMTPS id DB8646E9A1 for ; Fri, 31 Jul 2020 04:06:03 +0000 (UTC) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-399-l2HgzxHcP_m2KOYyH8Eowg-1; Fri, 31 Jul 2020 00:06:00 -0400 X-MC-Unique: l2HgzxHcP_m2KOYyH8Eowg-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 80ABA805723; Fri, 31 Jul 2020 04:05:59 +0000 (UTC) Received: from tyrion-bne-redhat-com.redhat.com (vpn2-54-17.bne.redhat.com [10.64.54.17]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1090F1001281; Fri, 31 Jul 2020 04:05:57 +0000 (UTC) From: Dave Airlie To: dri-devel@lists.freedesktop.org Subject: [PATCH 14/49] drm/ttm: pass man around instead of mem_type in some places Date: Fri, 31 Jul 2020 14:04:45 +1000 Message-Id: <20200731040520.3701599-15-airlied@gmail.com> In-Reply-To: <20200731040520.3701599-1-airlied@gmail.com> References: <20200731040520.3701599-1-airlied@gmail.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: gmail.com X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: christian.koenig@amd.com, sroland@vmware.com, bskeggs@redhat.com, kraxel@redhat.com Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Dave Airlie This makes it easier to cleanup things Signed-off-by: Dave Airlie Reviewed-by: Christian König --- drivers/gpu/drm/ttm/ttm_bo.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c index 101a7910f9f7..84e399395e4f 100644 --- a/drivers/gpu/drm/ttm/ttm_bo.c +++ b/drivers/gpu/drm/ttm/ttm_bo.c @@ -763,13 +763,12 @@ static int ttm_mem_evict_wait_busy(struct ttm_buffer_object *busy_bo, } static int ttm_mem_evict_first(struct ttm_bo_device *bdev, - uint32_t mem_type, + struct ttm_mem_type_manager *man, const struct ttm_place *place, struct ttm_operation_ctx *ctx, struct ww_acquire_ctx *ticket) { struct ttm_buffer_object *bo = NULL, *busy_bo = NULL; - struct ttm_mem_type_manager *man = &bdev->man[mem_type]; bool locked = false; unsigned i; int ret; @@ -918,7 +917,7 @@ static int ttm_bo_mem_force_space(struct ttm_buffer_object *bo, break; if (unlikely(ret != -ENOSPC)) return ret; - ret = ttm_mem_evict_first(bdev, mem->mem_type, place, ctx, + ret = ttm_mem_evict_first(bdev, man, place, ctx, ticket); if (unlikely(ret != 0)) return ret; @@ -1403,14 +1402,13 @@ int ttm_bo_create(struct ttm_bo_device *bdev, EXPORT_SYMBOL(ttm_bo_create); static int ttm_bo_force_list_clean(struct ttm_bo_device *bdev, - unsigned mem_type) + struct ttm_mem_type_manager *man) { struct ttm_operation_ctx ctx = { .interruptible = false, .no_wait_gpu = false, .flags = TTM_OPT_FLAG_FORCE_ALLOC }; - struct ttm_mem_type_manager *man = &bdev->man[mem_type]; struct ttm_bo_global *glob = &ttm_bo_glob; struct dma_fence *fence; int ret; @@ -1424,7 +1422,7 @@ static int ttm_bo_force_list_clean(struct ttm_bo_device *bdev, for (i = 0; i < TTM_MAX_BO_PRIORITY; ++i) { while (!list_empty(&man->lru[i])) { spin_unlock(&glob->lru_lock); - ret = ttm_mem_evict_first(bdev, mem_type, NULL, &ctx, + ret = ttm_mem_evict_first(bdev, man, NULL, &ctx, NULL); if (ret) return ret; @@ -1469,7 +1467,7 @@ int ttm_bo_clean_mm(struct ttm_bo_device *bdev, unsigned mem_type) ret = 0; if (mem_type > 0) { - ret = ttm_bo_force_list_clean(bdev, mem_type); + ret = ttm_bo_force_list_clean(bdev, man); if (ret) { pr_err("Cleanup eviction failed\n"); return ret; @@ -1499,7 +1497,7 @@ int ttm_bo_evict_mm(struct ttm_bo_device *bdev, unsigned mem_type) return 0; } - return ttm_bo_force_list_clean(bdev, mem_type); + return ttm_bo_force_list_clean(bdev, man); } EXPORT_SYMBOL(ttm_bo_evict_mm); From patchwork Fri Jul 31 04:04:46 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Airlie X-Patchwork-Id: 11693991 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C2CD714B7 for ; Fri, 31 Jul 2020 04:06:20 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id AADCA21744 for ; Fri, 31 Jul 2020 04:06:20 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org AADCA21744 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 838BD6E9A5; Fri, 31 Jul 2020 04:06:19 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) by gabe.freedesktop.org (Postfix) with ESMTPS id D53606E9A5 for ; Fri, 31 Jul 2020 04:06:07 +0000 (UTC) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-486-Hd5Qud8hMl-Jpd6hs-lseQ-1; Fri, 31 Jul 2020 00:06:02 -0400 X-MC-Unique: Hd5Qud8hMl-Jpd6hs-lseQ-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 57AD91005510; Fri, 31 Jul 2020 04:06:01 +0000 (UTC) Received: from tyrion-bne-redhat-com.redhat.com (vpn2-54-17.bne.redhat.com [10.64.54.17]) by smtp.corp.redhat.com (Postfix) with ESMTP id DF2A0100238C; Fri, 31 Jul 2020 04:05:59 +0000 (UTC) From: Dave Airlie To: dri-devel@lists.freedesktop.org Subject: [PATCH 15/49] drm/ttm: make some inline helper functions for cleanup paths. Date: Fri, 31 Jul 2020 14:04:46 +1000 Message-Id: <20200731040520.3701599-16-airlied@gmail.com> In-Reply-To: <20200731040520.3701599-1-airlied@gmail.com> References: <20200731040520.3701599-1-airlied@gmail.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: gmail.com X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: christian.koenig@amd.com, sroland@vmware.com, bskeggs@redhat.com, kraxel@redhat.com Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Dave Airlie Signed-off-by: Dave Airlie --- drivers/gpu/drm/ttm/ttm_bo.c | 6 ++---- include/drm/ttm/ttm_bo_driver.h | 12 ++++++++++++ 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c index 84e399395e4f..f584e5e94383 100644 --- a/drivers/gpu/drm/ttm/ttm_bo.c +++ b/drivers/gpu/drm/ttm/ttm_bo.c @@ -1462,8 +1462,7 @@ int ttm_bo_clean_mm(struct ttm_bo_device *bdev, unsigned mem_type) return ret; } - man->use_type = false; - man->has_type = false; + ttm_bo_disable_mm(man); ret = 0; if (mem_type > 0) { @@ -1476,8 +1475,7 @@ int ttm_bo_clean_mm(struct ttm_bo_device *bdev, unsigned mem_type) ret = (*man->func->takedown)(man); } - dma_fence_put(man->move); - man->move = NULL; + ttm_bo_man_cleanup(man); return ret; } diff --git a/include/drm/ttm/ttm_bo_driver.h b/include/drm/ttm/ttm_bo_driver.h index d0f1a6cdfba7..92bb54cce633 100644 --- a/include/drm/ttm/ttm_bo_driver.h +++ b/include/drm/ttm/ttm_bo_driver.h @@ -671,6 +671,18 @@ static inline void ttm_bo_use_mm(struct ttm_mem_type_manager *man) man->use_type = true; } +static inline void ttm_bo_disable_mm(struct ttm_mem_type_manager *man) +{ + man->has_type = false; + man->use_type = false; +} + +static inline void ttm_bo_man_cleanup(struct ttm_mem_type_manager *man) +{ + dma_fence_put(man->move); + man->move = NULL; +} + /* * ttm_bo_util.c */ From patchwork Fri Jul 31 04:04:47 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Airlie X-Patchwork-Id: 11694043 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9C3BE13B1 for ; Fri, 31 Jul 2020 04:07:34 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 8303321775 for ; Fri, 31 Jul 2020 04:07:34 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8303321775 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id A7B856E9BD; Fri, 31 Jul 2020 04:07:33 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from us-smtp-delivery-1.mimecast.com (us-smtp-1.mimecast.com [205.139.110.61]) by gabe.freedesktop.org (Postfix) with ESMTPS id 50A056E9BD for ; Fri, 31 Jul 2020 04:07:22 +0000 (UTC) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-181-jkiC6XTJMBWr0_5ZPPMXCw-1; Fri, 31 Jul 2020 00:06:04 -0400 X-MC-Unique: jkiC6XTJMBWr0_5ZPPMXCw-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 30D2318839C0; Fri, 31 Jul 2020 04:06:03 +0000 (UTC) Received: from tyrion-bne-redhat-com.redhat.com (vpn2-54-17.bne.redhat.com [10.64.54.17]) by smtp.corp.redhat.com (Postfix) with ESMTP id B67A0100238C; Fri, 31 Jul 2020 04:06:01 +0000 (UTC) From: Dave Airlie To: dri-devel@lists.freedesktop.org Subject: [PATCH 16/49] drm/ttm: start allowing drivers to use new takedown path Date: Fri, 31 Jul 2020 14:04:47 +1000 Message-Id: <20200731040520.3701599-17-airlied@gmail.com> In-Reply-To: <20200731040520.3701599-1-airlied@gmail.com> References: <20200731040520.3701599-1-airlied@gmail.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: gmail.com X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: christian.koenig@amd.com, sroland@vmware.com, bskeggs@redhat.com, kraxel@redhat.com Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Dave Airlie Allow the takedown path callback to be optional as well. Signed-off-by: Dave Airlie --- drivers/gpu/drm/ttm/ttm_bo.c | 8 +++++--- drivers/gpu/drm/ttm/ttm_bo_manager.c | 21 +++++++++++++++++++-- include/drm/ttm/ttm_bo_driver.h | 5 ++++- 3 files changed, 28 insertions(+), 6 deletions(-) diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c index f584e5e94383..f0f0f3101bd1 100644 --- a/drivers/gpu/drm/ttm/ttm_bo.c +++ b/drivers/gpu/drm/ttm/ttm_bo.c @@ -1401,8 +1401,8 @@ int ttm_bo_create(struct ttm_bo_device *bdev, } EXPORT_SYMBOL(ttm_bo_create); -static int ttm_bo_force_list_clean(struct ttm_bo_device *bdev, - struct ttm_mem_type_manager *man) +int ttm_bo_force_list_clean(struct ttm_bo_device *bdev, + struct ttm_mem_type_manager *man) { struct ttm_operation_ctx ctx = { .interruptible = false, @@ -1444,6 +1444,7 @@ static int ttm_bo_force_list_clean(struct ttm_bo_device *bdev, return 0; } +EXPORT_SYMBOL(ttm_bo_force_list_clean); int ttm_bo_clean_mm(struct ttm_bo_device *bdev, unsigned mem_type) { @@ -1472,7 +1473,8 @@ int ttm_bo_clean_mm(struct ttm_bo_device *bdev, unsigned mem_type) return ret; } - ret = (*man->func->takedown)(man); + if (man->func->takedown) + ret = (*man->func->takedown)(man); } ttm_bo_man_cleanup(man); diff --git a/drivers/gpu/drm/ttm/ttm_bo_manager.c b/drivers/gpu/drm/ttm/ttm_bo_manager.c index 1877425abdf0..1127868274b3 100644 --- a/drivers/gpu/drm/ttm/ttm_bo_manager.c +++ b/drivers/gpu/drm/ttm/ttm_bo_manager.c @@ -129,7 +129,7 @@ int ttm_bo_man_init(struct ttm_bo_device *bdev, } EXPORT_SYMBOL(ttm_bo_man_init); -static int ttm_bo_man_takedown(struct ttm_mem_type_manager *man) +static int ttm_bo_man_takedown_private(struct ttm_mem_type_manager *man) { struct ttm_range_manager *rman = (struct ttm_range_manager *) man->priv; struct drm_mm *mm = &rman->mm; @@ -146,6 +146,23 @@ static int ttm_bo_man_takedown(struct ttm_mem_type_manager *man) return -EBUSY; } +int ttm_bo_man_takedown(struct ttm_bo_device *bdev, + struct ttm_mem_type_manager *man) +{ + int ret; + + ttm_bo_disable_mm(man); + + ret = ttm_bo_force_list_clean(bdev, man); + if (ret) + return ret; + + ttm_bo_man_takedown_private(man); + ttm_bo_man_cleanup(man); + return 0; +} +EXPORT_SYMBOL(ttm_bo_man_takedown); + static void ttm_bo_man_debug(struct ttm_mem_type_manager *man, struct drm_printer *printer) { @@ -157,7 +174,7 @@ static void ttm_bo_man_debug(struct ttm_mem_type_manager *man, } static const struct ttm_mem_type_manager_func ttm_bo_manager_func = { - .takedown = ttm_bo_man_takedown, + .takedown = ttm_bo_man_takedown_private, .get_node = ttm_bo_man_get_node, .put_node = ttm_bo_man_put_node, .debug = ttm_bo_man_debug diff --git a/include/drm/ttm/ttm_bo_driver.h b/include/drm/ttm/ttm_bo_driver.h index 92bb54cce633..2ef33b407167 100644 --- a/include/drm/ttm/ttm_bo_driver.h +++ b/include/drm/ttm/ttm_bo_driver.h @@ -683,6 +683,8 @@ static inline void ttm_bo_man_cleanup(struct ttm_mem_type_manager *man) man->move = NULL; } +int ttm_bo_force_list_clean(struct ttm_bo_device *bdev, + struct ttm_mem_type_manager *man); /* * ttm_bo_util.c */ @@ -801,5 +803,6 @@ pgprot_t ttm_io_prot(uint32_t caching_flags, pgprot_t tmp); int ttm_bo_man_init(struct ttm_bo_device *bdev, struct ttm_mem_type_manager *man, unsigned long p_size); - +int ttm_bo_man_takedown(struct ttm_bo_device *bdev, + struct ttm_mem_type_manager *man); #endif From patchwork Fri Jul 31 04:04:48 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Dave Airlie X-Patchwork-Id: 11693995 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7CD1C14B7 for ; Fri, 31 Jul 2020 04:06:23 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 656972070B for ; Fri, 31 Jul 2020 04:06:23 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 656972070B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id F32CF6E9AA; Fri, 31 Jul 2020 04:06:19 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) by gabe.freedesktop.org (Postfix) with ESMTPS id 20E3C6E9A5 for ; Fri, 31 Jul 2020 04:06:14 +0000 (UTC) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-282-lyYG9nJAMLe8vRG-jXy6bQ-1; Fri, 31 Jul 2020 00:06:09 -0400 X-MC-Unique: lyYG9nJAMLe8vRG-jXy6bQ-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id EFD9E10059A7; Fri, 31 Jul 2020 04:06:07 +0000 (UTC) Received: from tyrion-bne-redhat-com.redhat.com (vpn2-54-17.bne.redhat.com [10.64.54.17]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8FB75100238C; Fri, 31 Jul 2020 04:06:03 +0000 (UTC) From: Dave Airlie To: dri-devel@lists.freedesktop.org Subject: [PATCH 17/49] drm/amdgpu/ttm: use new takedown path Date: Fri, 31 Jul 2020 14:04:48 +1000 Message-Id: <20200731040520.3701599-18-airlied@gmail.com> In-Reply-To: <20200731040520.3701599-1-airlied@gmail.com> References: <20200731040520.3701599-1-airlied@gmail.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: gmail.com X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: christian.koenig@amd.com, sroland@vmware.com, bskeggs@redhat.com, kraxel@redhat.com Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Dave Airlie Signed-off-by: Dave Airlie Reviewed-by: Christian König --- drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c | 15 +++++++++++---- drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 10 +++++----- drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h | 2 ++ drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c | 15 +++++++++++---- 4 files changed, 29 insertions(+), 13 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c index 5f58aa2eac4a..f4c870b2f348 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c @@ -133,10 +133,18 @@ int amdgpu_gtt_mgr_init(struct amdgpu_device *adev, uint64_t gtt_size) * Destroy and free the GTT manager, returns -EBUSY if ranges are still * allocated inside it. */ -static int amdgpu_gtt_mgr_fini(struct ttm_mem_type_manager *man) +void amdgpu_gtt_mgr_fini(struct amdgpu_device *adev) { - struct amdgpu_device *adev = amdgpu_ttm_adev(man->bdev); + struct ttm_mem_type_manager *man = &adev->mman.bdev.man[TTM_PL_TT]; struct amdgpu_gtt_mgr *mgr = man->priv; + int ret; + + ttm_bo_disable_mm(man); + + ret = ttm_bo_force_list_clean(&adev->mman.bdev, man); + if (ret) + return; + spin_lock(&mgr->lock); drm_mm_takedown(&mgr->mm); spin_unlock(&mgr->lock); @@ -146,7 +154,7 @@ static int amdgpu_gtt_mgr_fini(struct ttm_mem_type_manager *man) device_remove_file(adev->dev, &dev_attr_mem_info_gtt_total); device_remove_file(adev->dev, &dev_attr_mem_info_gtt_used); - return 0; + ttm_bo_man_cleanup(man); } /** @@ -307,7 +315,6 @@ static void amdgpu_gtt_mgr_debug(struct ttm_mem_type_manager *man, } static const struct ttm_mem_type_manager_func amdgpu_gtt_mgr_func = { - .takedown = amdgpu_gtt_mgr_fini, .get_node = amdgpu_gtt_mgr_new, .put_node = amdgpu_gtt_mgr_del, .debug = amdgpu_gtt_mgr_debug diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c index f1bf86b8de14..b1452df8fce9 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c @@ -2012,11 +2012,11 @@ void amdgpu_ttm_fini(struct amdgpu_device *adev) iounmap(adev->mman.aper_base_kaddr); adev->mman.aper_base_kaddr = NULL; - ttm_bo_clean_mm(&adev->mman.bdev, TTM_PL_VRAM); - ttm_bo_clean_mm(&adev->mman.bdev, TTM_PL_TT); - ttm_bo_clean_mm(&adev->mman.bdev, AMDGPU_PL_GDS); - ttm_bo_clean_mm(&adev->mman.bdev, AMDGPU_PL_GWS); - ttm_bo_clean_mm(&adev->mman.bdev, AMDGPU_PL_OA); + amdgpu_vram_mgr_fini(adev); + amdgpu_gtt_mgr_fini(adev); + ttm_bo_man_takedown(&adev->mman.bdev, &adev->mman.bdev.man[AMDGPU_PL_GDS]); + ttm_bo_man_takedown(&adev->mman.bdev, &adev->mman.bdev.man[AMDGPU_PL_GWS]); + ttm_bo_man_takedown(&adev->mman.bdev, &adev->mman.bdev.man[AMDGPU_PL_OA]); ttm_bo_device_release(&adev->mman.bdev); adev->mman.initialized = false; DRM_INFO("amdgpu: ttm finalized\n"); diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h index fb45c0a323b0..c01fdb3f0458 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h @@ -68,7 +68,9 @@ struct amdgpu_copy_mem { }; int amdgpu_gtt_mgr_init(struct amdgpu_device *adev, uint64_t gtt_size); +void amdgpu_gtt_mgr_fini(struct amdgpu_device *adev); int amdgpu_vram_mgr_init(struct amdgpu_device *adev); +void amdgpu_vram_mgr_fini(struct amdgpu_device *adev); bool amdgpu_gtt_mgr_has_gart_addr(struct ttm_mem_reg *mem); uint64_t amdgpu_gtt_mgr_usage(struct ttm_mem_type_manager *man); diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c index 1bc04835c24f..cc45be8ccb0f 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c @@ -205,10 +205,17 @@ int amdgpu_vram_mgr_init(struct amdgpu_device *adev) * Destroy and free the VRAM manager, returns -EBUSY if ranges are still * allocated inside it. */ -static int amdgpu_vram_mgr_fini(struct ttm_mem_type_manager *man) +void amdgpu_vram_mgr_fini(struct amdgpu_device *adev) { - struct amdgpu_device *adev = amdgpu_ttm_adev(man->bdev); + struct ttm_mem_type_manager *man = &adev->mman.bdev.man[TTM_PL_VRAM]; struct amdgpu_vram_mgr *mgr = man->priv; + int ret; + + ttm_bo_disable_mm(man); + + ret = ttm_bo_force_list_clean(&adev->mman.bdev, man); + if (ret) + return; spin_lock(&mgr->lock); drm_mm_takedown(&mgr->mm); @@ -216,7 +223,8 @@ static int amdgpu_vram_mgr_fini(struct ttm_mem_type_manager *man) kfree(mgr); man->priv = NULL; sysfs_remove_files(&adev->dev->kobj, amdgpu_vram_mgr_attributes); - return 0; + + ttm_bo_man_cleanup(man); } /** @@ -596,7 +604,6 @@ static void amdgpu_vram_mgr_debug(struct ttm_mem_type_manager *man, } static const struct ttm_mem_type_manager_func amdgpu_vram_mgr_func = { - .takedown = amdgpu_vram_mgr_fini, .get_node = amdgpu_vram_mgr_new, .put_node = amdgpu_vram_mgr_del, .debug = amdgpu_vram_mgr_debug From patchwork Fri Jul 31 04:04:49 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Airlie X-Patchwork-Id: 11693997 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id ECAED14B7 for ; Fri, 31 Jul 2020 04:06:24 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id D52832070B for ; Fri, 31 Jul 2020 04:06:24 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D52832070B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id AF2AA6E9AF; Fri, 31 Jul 2020 04:06:20 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) by gabe.freedesktop.org (Postfix) with ESMTPS id 141236E9A5 for ; Fri, 31 Jul 2020 04:06:18 +0000 (UTC) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-188-wWJrdPTjMCypZi3oqxEIjw-1; Fri, 31 Jul 2020 00:06:11 -0400 X-MC-Unique: wWJrdPTjMCypZi3oqxEIjw-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id CA2F78015F3; Fri, 31 Jul 2020 04:06:09 +0000 (UTC) Received: from tyrion-bne-redhat-com.redhat.com (vpn2-54-17.bne.redhat.com [10.64.54.17]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5B0C41001281; Fri, 31 Jul 2020 04:06:08 +0000 (UTC) From: Dave Airlie To: dri-devel@lists.freedesktop.org Subject: [PATCH 18/49] drm/vmwgfx: takedown vram manager Date: Fri, 31 Jul 2020 14:04:49 +1000 Message-Id: <20200731040520.3701599-19-airlied@gmail.com> In-Reply-To: <20200731040520.3701599-1-airlied@gmail.com> References: <20200731040520.3701599-1-airlied@gmail.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: gmail.com X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: christian.koenig@amd.com, sroland@vmware.com, bskeggs@redhat.com, kraxel@redhat.com Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Dave Airlie Don't bother returning EBUSY, nobody cares enough, if the driver has a problem, it should deal with it. Signed-off-by: Dave Airlie --- drivers/gpu/drm/vmwgfx/vmwgfx_drv.c | 13 ++++++++++++- drivers/gpu/drm/vmwgfx/vmwgfx_drv.h | 1 + drivers/gpu/drm/vmwgfx/vmwgfx_thp.c | 23 +++++++++++++---------- 3 files changed, 26 insertions(+), 11 deletions(-) diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c index 5ee5aa0aaa6a..7d65f9121cd7 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c @@ -637,6 +637,17 @@ static int vmw_init_vram_manager(struct vmw_private *dev_priv) dev_priv->bdev.man[TTM_PL_VRAM].use_type = false; return ret; } + +static void vmw_takedown_vram_manager(struct vmw_private *dev_priv) +{ +#ifdef CONFIG_TRANSPARENT_HUGEPAGE + vmw_thp_takedown(dev_priv); +#else + ttm_bo_man_takedown(&dev_priv->bdev, + &dev_priv->bdev.man[TTM_PL_VRAM]); +#endif +} + static int vmw_driver_load(struct drm_device *dev, unsigned long chipset) { struct vmw_private *dev_priv; @@ -986,7 +997,7 @@ static int vmw_driver_load(struct drm_device *dev, unsigned long chipset) (void) ttm_bo_clean_mm(&dev_priv->bdev, VMW_PL_MOB); if (dev_priv->has_gmr) (void) ttm_bo_clean_mm(&dev_priv->bdev, VMW_PL_GMR); - (void)ttm_bo_clean_mm(&dev_priv->bdev, TTM_PL_VRAM); + vmw_takedown_vram_manager(dev_priv); out_no_vram: (void)ttm_bo_device_release(&dev_priv->bdev); out_no_bdev: diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h index 8f319dd6cdb4..b20056fdd042 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h @@ -1521,6 +1521,7 @@ vm_fault_t vmw_bo_vm_huge_fault(struct vm_fault *vmf, /* Transparent hugepage support - vmwgfx_thp.c */ #ifdef CONFIG_TRANSPARENT_HUGEPAGE extern int vmw_thp_init(struct vmw_private *dev_priv); +void vmw_thp_takedown(struct vmw_private *dev_priv); #endif /** diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_thp.c b/drivers/gpu/drm/vmwgfx/vmwgfx_thp.c index c4a9bee932c9..3591a93dad37 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_thp.c +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_thp.c @@ -135,21 +135,25 @@ int vmw_thp_init(struct vmw_private *dev_priv) return 0; } -static int vmw_thp_takedown(struct ttm_mem_type_manager *man) +void vmw_thp_takedown(struct vmw_private *dev_priv) { + struct ttm_mem_type_manager *man = &dev_priv->bdev.man[TTM_PL_VRAM]; struct vmw_thp_manager *rman = (struct vmw_thp_manager *) man->priv; struct drm_mm *mm = &rman->mm; + int ret; + + ttm_bo_disable_mm(man); + ret = ttm_bo_force_list_clean(&dev_priv->bdev, man); + if (ret) + return; spin_lock(&rman->lock); - if (drm_mm_clean(mm)) { - drm_mm_takedown(mm); - spin_unlock(&rman->lock); - kfree(rman); - man->priv = NULL; - return 0; - } + drm_mm_clean(mm); + drm_mm_takedown(mm); spin_unlock(&rman->lock); - return -EBUSY; + kfree(rman); + man->priv = NULL; + ttm_bo_man_cleanup(man); } static void vmw_thp_debug(struct ttm_mem_type_manager *man, @@ -163,7 +167,6 @@ static void vmw_thp_debug(struct ttm_mem_type_manager *man, } const struct ttm_mem_type_manager_func vmw_thp_func = { - .takedown = vmw_thp_takedown, .get_node = vmw_thp_get_node, .put_node = vmw_thp_put_node, .debug = vmw_thp_debug From patchwork Fri Jul 31 04:04:50 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Airlie X-Patchwork-Id: 11694005 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id CFCCF14B7 for ; Fri, 31 Jul 2020 04:06:39 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id B88AF2070B for ; Fri, 31 Jul 2020 04:06:39 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B88AF2070B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 674646E9AB; Fri, 31 Jul 2020 04:06:37 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from us-smtp-delivery-1.mimecast.com (us-smtp-2.mimecast.com [205.139.110.61]) by gabe.freedesktop.org (Postfix) with ESMTPS id 6F0C56E9AC for ; Fri, 31 Jul 2020 04:06:20 +0000 (UTC) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-184-GmtS_37nP8eGWLQ-BWvV6w-1; Fri, 31 Jul 2020 00:06:12 -0400 X-MC-Unique: GmtS_37nP8eGWLQ-BWvV6w-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id A35F310059B2; Fri, 31 Jul 2020 04:06:11 +0000 (UTC) Received: from tyrion-bne-redhat-com.redhat.com (vpn2-54-17.bne.redhat.com [10.64.54.17]) by smtp.corp.redhat.com (Postfix) with ESMTP id 34EBA100238C; Fri, 31 Jul 2020 04:06:10 +0000 (UTC) From: Dave Airlie To: dri-devel@lists.freedesktop.org Subject: [PATCH 19/49] drm/vram_helper: call explicit mm takedown Date: Fri, 31 Jul 2020 14:04:50 +1000 Message-Id: <20200731040520.3701599-20-airlied@gmail.com> In-Reply-To: <20200731040520.3701599-1-airlied@gmail.com> References: <20200731040520.3701599-1-airlied@gmail.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: gmail.com X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: christian.koenig@amd.com, sroland@vmware.com, bskeggs@redhat.com, kraxel@redhat.com Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Dave Airlie Signed-off-by: Dave Airlie --- drivers/gpu/drm/drm_gem_vram_helper.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/gpu/drm/drm_gem_vram_helper.c b/drivers/gpu/drm/drm_gem_vram_helper.c index 8a5d45a55ac7..c6cc90d42f56 100644 --- a/drivers/gpu/drm/drm_gem_vram_helper.c +++ b/drivers/gpu/drm/drm_gem_vram_helper.c @@ -1127,6 +1127,7 @@ static int drm_vram_mm_init(struct drm_vram_mm *vmm, struct drm_device *dev, static void drm_vram_mm_cleanup(struct drm_vram_mm *vmm) { + ttm_bo_man_takedown(&vmm->bdev, &vmm->bdev.man[TTM_PL_VRAM]); ttm_bo_device_release(&vmm->bdev); } From patchwork Fri Jul 31 04:04:51 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Airlie X-Patchwork-Id: 11693999 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8D26E14B7 for ; Fri, 31 Jul 2020 04:06:26 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 74D36208E4 for ; Fri, 31 Jul 2020 04:06:26 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 74D36208E4 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 7A4586E9A8; Fri, 31 Jul 2020 04:06:23 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from us-smtp-delivery-1.mimecast.com (us-smtp-2.mimecast.com [205.139.110.61]) by gabe.freedesktop.org (Postfix) with ESMTPS id A38C36E9A8 for ; Fri, 31 Jul 2020 04:06:19 +0000 (UTC) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-32-rntvlfxNMvC21UhlE-Hm2A-1; Fri, 31 Jul 2020 00:06:14 -0400 X-MC-Unique: rntvlfxNMvC21UhlE-Hm2A-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 7CE7880183C; Fri, 31 Jul 2020 04:06:13 +0000 (UTC) Received: from tyrion-bne-redhat-com.redhat.com (vpn2-54-17.bne.redhat.com [10.64.54.17]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0DD77100238C; Fri, 31 Jul 2020 04:06:11 +0000 (UTC) From: Dave Airlie To: dri-devel@lists.freedesktop.org Subject: [PATCH 20/49] drm/nouveau: use new cleanup paths Date: Fri, 31 Jul 2020 14:04:51 +1000 Message-Id: <20200731040520.3701599-21-airlied@gmail.com> In-Reply-To: <20200731040520.3701599-1-airlied@gmail.com> References: <20200731040520.3701599-1-airlied@gmail.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=airlied@gmail.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: gmail.com X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: christian.koenig@amd.com, sroland@vmware.com, bskeggs@redhat.com, kraxel@redhat.com Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Dave Airlie Signed-off-by: Dave Airlie --- drivers/gpu/drm/nouveau/nouveau_ttm.c | 41 ++++++++++++++++++++------- 1 file changed, 30 insertions(+), 11 deletions(-) diff --git a/drivers/gpu/drm/nouveau/nouveau_ttm.c b/drivers/gpu/drm/nouveau/nouveau_ttm.c index e3c57c612765..2ccfdf203c52 100644 --- a/drivers/gpu/drm/nouveau/nouveau_ttm.c +++ b/drivers/gpu/drm/nouveau/nouveau_ttm.c @@ -31,12 +31,6 @@ #include -static int -nouveau_manager_fini(struct ttm_mem_type_manager *man) -{ - return 0; -} - static void nouveau_manager_del(struct ttm_mem_type_manager *man, struct ttm_mem_reg *reg) { @@ -76,7 +70,6 @@ nouveau_vram_manager_new(struct ttm_mem_type_manager *man, } const struct ttm_mem_type_manager_func nouveau_vram_manager = { - .takedown = nouveau_manager_fini, .get_node = nouveau_vram_manager_new, .put_node = nouveau_manager_del, .debug = nouveau_manager_debug, @@ -101,7 +94,6 @@ nouveau_gart_manager_new(struct ttm_mem_type_manager *man, } const struct ttm_mem_type_manager_func nouveau_gart_manager = { - .takedown = nouveau_manager_fini, .get_node = nouveau_gart_manager_new, .put_node = nouveau_manager_del, .debug = nouveau_manager_debug @@ -135,7 +127,6 @@ nv04_gart_manager_new(struct ttm_mem_type_manager *man, } const struct ttm_mem_type_manager_func nv04_gart_manager = { - .takedown = nouveau_manager_fini, .get_node = nv04_gart_manager_new, .put_node = nouveau_manager_del, .debug = nouveau_manager_debug @@ -201,6 +192,19 @@ nouveau_ttm_init_vram(struct nouveau_drm *drm) } } +static void +nouveau_ttm_fini_vram(struct nouveau_drm *drm) +{ + struct ttm_mem_type_manager *man = &drm->ttm.bdev.man[TTM_PL_VRAM]; + + if (drm->client.device.info.family >= NV_DEVICE_INFO_V0_TESLA) { + ttm_bo_disable_mm(man); + ttm_bo_force_list_clean(&drm->ttm.bdev, man); + ttm_bo_man_cleanup(man); + } else + ttm_bo_man_takedown(&drm->ttm.bdev, man); +} + static int nouveau_ttm_init_gtt(struct nouveau_drm *drm) { @@ -230,6 +234,21 @@ nouveau_ttm_init_gtt(struct nouveau_drm *drm) return 0; } +static void +nouveau_ttm_fini_gtt(struct nouveau_drm *drm) +{ + struct ttm_mem_type_manager *man = &drm->ttm.bdev.man[TTM_PL_TT]; + + if (drm->client.device.info.family < NV_DEVICE_INFO_V0_TESLA && + drm->agp.bridge) + ttm_bo_man_takedown(&drm->ttm.bdev, man); + else { + ttm_bo_disable_mm(man); + ttm_bo_force_list_clean(&drm->ttm.bdev, man); + ttm_bo_man_cleanup(man); + } +} + int nouveau_ttm_init(struct nouveau_drm *drm) { @@ -319,8 +338,8 @@ nouveau_ttm_fini(struct nouveau_drm *drm) { struct nvkm_device *device = nvxx_device(&drm->client.device); - ttm_bo_clean_mm(&drm->ttm.bdev, TTM_PL_VRAM); - ttm_bo_clean_mm(&drm->ttm.bdev, TTM_PL_TT); + nouveau_ttm_fini_vram(drm); + nouveau_ttm_fini_gtt(drm); ttm_bo_device_release(&drm->ttm.bdev); From patchwork Fri Jul 31 04:04:52 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Dave Airlie X-Patchwork-Id: 11694001 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E1B9014B7 for ; Fri, 31 Jul 2020 04:06:27 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id CA6A12070B for ; Fri, 31 Jul 2020 04:06:27 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org CA6A12070B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 5E2B76E9AC; Fri, 31 Jul 2020 04:06:24 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) by gabe.freedesktop.org (Postfix) with ESMTPS id CF7206E9A9 for ; Fri, 31 Jul 2020 04:06:19 +0000 (UTC) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-275-K_OTRTArPvujC_OA9nJukQ-1; Fri, 31 Jul 2020 00:06:16 -0400 X-MC-Unique: K_OTRTArPvujC_OA9nJukQ-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 5B38E8015CE; Fri, 31 Jul 2020 04:06:15 +0000 (UTC) Received: from tyrion-bne-redhat-com.redhat.com (vpn2-54-17.bne.redhat.com [10.64.54.17]) by smtp.corp.redhat.com (Postfix) with ESMTP id DCECE100238C; Fri, 31 Jul 2020 04:06:13 +0000 (UTC) From: Dave Airlie To: dri-devel@lists.freedesktop.org Subject: [PATCH 21/49] drm/radeon/ttm: use new takedown paths Date: Fri, 31 Jul 2020 14:04:52 +1000 Message-Id: <20200731040520.3701599-22-airlied@gmail.com> In-Reply-To: <20200731040520.3701599-1-airlied@gmail.com> References: <20200731040520.3701599-1-airlied@gmail.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: gmail.com X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: christian.koenig@amd.com, sroland@vmware.com, bskeggs@redhat.com, kraxel@redhat.com Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Dave Airlie Signed-off-by: Dave Airlie Reviewed-by: Christian König --- drivers/gpu/drm/radeon/radeon_ttm.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/radeon/radeon_ttm.c b/drivers/gpu/drm/radeon/radeon_ttm.c index a5043a5b7d89..e65297b4b678 100644 --- a/drivers/gpu/drm/radeon/radeon_ttm.c +++ b/drivers/gpu/drm/radeon/radeon_ttm.c @@ -826,8 +826,8 @@ void radeon_ttm_fini(struct radeon_device *rdev) } radeon_bo_unref(&rdev->stolen_vga_memory); } - ttm_bo_clean_mm(&rdev->mman.bdev, TTM_PL_VRAM); - ttm_bo_clean_mm(&rdev->mman.bdev, TTM_PL_TT); + ttm_bo_man_takedown(&rdev->mman.bdev, &rdev->mman.bdev.man[TTM_PL_VRAM]); + ttm_bo_man_takedown(&rdev->mman.bdev, &rdev->mman.bdev.man[TTM_PL_TT]); ttm_bo_device_release(&rdev->mman.bdev); radeon_gart_fini(rdev); rdev->mman.initialized = false; From patchwork Fri Jul 31 04:04:53 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Airlie X-Patchwork-Id: 11694007 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A8BAA161F for ; Fri, 31 Jul 2020 04:06:41 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 918452070B for ; Fri, 31 Jul 2020 04:06:41 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 918452070B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id AC23E6E9B1; Fri, 31 Jul 2020 04:06:37 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from us-smtp-delivery-1.mimecast.com (us-smtp-2.mimecast.com [205.139.110.61]) by gabe.freedesktop.org (Postfix) with ESMTPS id A48C46E9A9 for ; Fri, 31 Jul 2020 04:06:23 +0000 (UTC) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-256-vCdtc8auOvaknygMYVuLzQ-1; Fri, 31 Jul 2020 00:06:18 -0400 X-MC-Unique: vCdtc8auOvaknygMYVuLzQ-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 32D8010059C0; Fri, 31 Jul 2020 04:06:17 +0000 (UTC) Received: from tyrion-bne-redhat-com.redhat.com (vpn2-54-17.bne.redhat.com [10.64.54.17]) by smtp.corp.redhat.com (Postfix) with ESMTP id BA1A71001281; Fri, 31 Jul 2020 04:06:15 +0000 (UTC) From: Dave Airlie To: dri-devel@lists.freedesktop.org Subject: [PATCH 22/49] drm/qxl/ttm: use new takedown path Date: Fri, 31 Jul 2020 14:04:53 +1000 Message-Id: <20200731040520.3701599-23-airlied@gmail.com> In-Reply-To: <20200731040520.3701599-1-airlied@gmail.com> References: <20200731040520.3701599-1-airlied@gmail.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: gmail.com X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: christian.koenig@amd.com, sroland@vmware.com, bskeggs@redhat.com, kraxel@redhat.com Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Dave Airlie Signed-off-by: Dave Airlie --- drivers/gpu/drm/qxl/qxl_ttm.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/qxl/qxl_ttm.c b/drivers/gpu/drm/qxl/qxl_ttm.c index ac22971cd20b..acc4497887a6 100644 --- a/drivers/gpu/drm/qxl/qxl_ttm.c +++ b/drivers/gpu/drm/qxl/qxl_ttm.c @@ -266,8 +266,8 @@ int qxl_ttm_init(struct qxl_device *qdev) void qxl_ttm_fini(struct qxl_device *qdev) { - ttm_bo_clean_mm(&qdev->mman.bdev, TTM_PL_VRAM); - ttm_bo_clean_mm(&qdev->mman.bdev, TTM_PL_PRIV); + ttm_bo_man_takedown(&qdev->mman.bdev, &qdev->mman.bdev.man[TTM_PL_VRAM]); + ttm_bo_man_takedown(&qdev->mman.bdev, &qdev->mman.bdev.man[TTM_PL_PRIV]); ttm_bo_device_release(&qdev->mman.bdev); DRM_INFO("qxl: ttm finalized\n"); } From patchwork Fri Jul 31 04:04:54 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Airlie X-Patchwork-Id: 11694041 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 20B1213B1 for ; Fri, 31 Jul 2020 04:07:19 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 095412070B for ; Fri, 31 Jul 2020 04:07:19 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 095412070B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 419106E9C5; Fri, 31 Jul 2020 04:07:06 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from us-smtp-delivery-1.mimecast.com (us-smtp-2.mimecast.com [205.139.110.61]) by gabe.freedesktop.org (Postfix) with ESMTPS id A58496E9AB for ; Fri, 31 Jul 2020 04:06:23 +0000 (UTC) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-164-z27GkXe5NMaQXQ6uRSY8Sw-1; Fri, 31 Jul 2020 00:06:20 -0400 X-MC-Unique: z27GkXe5NMaQXQ6uRSY8Sw-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 0D8B1107ACCA; Fri, 31 Jul 2020 04:06:19 +0000 (UTC) Received: from tyrion-bne-redhat-com.redhat.com (vpn2-54-17.bne.redhat.com [10.64.54.17]) by smtp.corp.redhat.com (Postfix) with ESMTP id 92178100238C; Fri, 31 Jul 2020 04:06:17 +0000 (UTC) From: Dave Airlie To: dri-devel@lists.freedesktop.org Subject: [PATCH 23/49] drm/vmwgfx: fix gmrid takedown paths to new interface Date: Fri, 31 Jul 2020 14:04:54 +1000 Message-Id: <20200731040520.3701599-24-airlied@gmail.com> In-Reply-To: <20200731040520.3701599-1-airlied@gmail.com> References: <20200731040520.3701599-1-airlied@gmail.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: gmail.com X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: christian.koenig@amd.com, sroland@vmware.com, bskeggs@redhat.com, kraxel@redhat.com Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Dave Airlie Signed-off-by: Dave Airlie --- drivers/gpu/drm/vmwgfx/vmwgfx_drv.c | 10 +++++----- drivers/gpu/drm/vmwgfx/vmwgfx_drv.h | 1 + drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c | 11 ++++++++--- 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c index 7d65f9121cd7..b27f8b3699cf 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c @@ -994,9 +994,9 @@ static int vmw_driver_load(struct drm_device *dev, unsigned long chipset) vmw_kms_close(dev_priv); out_no_kms: if (dev_priv->has_mob) - (void) ttm_bo_clean_mm(&dev_priv->bdev, VMW_PL_MOB); + vmw_gmrid_man_takedown(dev_priv, VMW_PL_MOB); if (dev_priv->has_gmr) - (void) ttm_bo_clean_mm(&dev_priv->bdev, VMW_PL_GMR); + vmw_gmrid_man_takedown(dev_priv, VMW_PL_GMR); vmw_takedown_vram_manager(dev_priv); out_no_vram: (void)ttm_bo_device_release(&dev_priv->bdev); @@ -1045,12 +1045,12 @@ static void vmw_driver_unload(struct drm_device *dev) vmw_overlay_close(dev_priv); if (dev_priv->has_gmr) - (void)ttm_bo_clean_mm(&dev_priv->bdev, VMW_PL_GMR); - (void)ttm_bo_clean_mm(&dev_priv->bdev, TTM_PL_VRAM); + vmw_gmrid_man_takedown(dev_priv, VMW_PL_GMR); + vmw_takedown_vram_manager(dev_priv); vmw_release_device_early(dev_priv); if (dev_priv->has_mob) - (void) ttm_bo_clean_mm(&dev_priv->bdev, VMW_PL_MOB); + vmw_gmrid_man_takedown(dev_priv, VMW_PL_MOB); (void) ttm_bo_device_release(&dev_priv->bdev); drm_vma_offset_manager_destroy(&dev_priv->vma_manager); vmw_release_device_late(dev_priv); diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h index b20056fdd042..d37af7929189 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h @@ -1222,6 +1222,7 @@ int vmw_overlay_num_free_overlays(struct vmw_private *dev_priv); */ int vmw_gmrid_man_init(struct vmw_private *dev_priv, int type); +void vmw_gmrid_man_takedown(struct vmw_private *dev_priv, int type); /** * Prime - vmwgfx_prime.c diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c b/drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c index e79d2c8abad2..2522927b75da 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c @@ -131,16 +131,22 @@ int vmw_gmrid_man_init(struct vmw_private *dev_priv, int type) return 0; } -static int vmw_gmrid_man_takedown(struct ttm_mem_type_manager *man) +void vmw_gmrid_man_takedown(struct vmw_private *dev_priv, int type) { + struct ttm_mem_type_manager *man = &dev_priv->bdev.man[type]; struct vmwgfx_gmrid_man *gman = (struct vmwgfx_gmrid_man *)man->priv; + ttm_bo_disable_mm(man); + + ttm_bo_force_list_clean(&dev_priv->bdev, man); + if (gman) { ida_destroy(&gman->gmr_ida); kfree(gman); } - return 0; + + ttm_bo_man_cleanup(man); } static void vmw_gmrid_man_debug(struct ttm_mem_type_manager *man, @@ -150,7 +156,6 @@ static void vmw_gmrid_man_debug(struct ttm_mem_type_manager *man, } static const struct ttm_mem_type_manager_func vmw_gmrid_manager_func = { - .takedown = vmw_gmrid_man_takedown, .get_node = vmw_gmrid_man_get_node, .put_node = vmw_gmrid_man_put_node, .debug = vmw_gmrid_man_debug From patchwork Fri Jul 31 04:04:55 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Airlie X-Patchwork-Id: 11694003 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 37646161F for ; Fri, 31 Jul 2020 04:06:38 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 2014B2070B for ; Fri, 31 Jul 2020 04:06:38 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2014B2070B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 1D8FD6E9A9; Fri, 31 Jul 2020 04:06:37 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) by gabe.freedesktop.org (Postfix) with ESMTPS id 4D16E6E9AB for ; Fri, 31 Jul 2020 04:06:26 +0000 (UTC) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-437-PuEIbH9wOkuHHuvBr59IYg-1; Fri, 31 Jul 2020 00:06:21 -0400 X-MC-Unique: PuEIbH9wOkuHHuvBr59IYg-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id DAE1D106B244; Fri, 31 Jul 2020 04:06:20 +0000 (UTC) Received: from tyrion-bne-redhat-com.redhat.com (vpn2-54-17.bne.redhat.com [10.64.54.17]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6CD5E100238C; Fri, 31 Jul 2020 04:06:19 +0000 (UTC) From: Dave Airlie To: dri-devel@lists.freedesktop.org Subject: [PATCH 24/49] drm/ttm: remove range manager legacy takedown path Date: Fri, 31 Jul 2020 14:04:55 +1000 Message-Id: <20200731040520.3701599-25-airlied@gmail.com> In-Reply-To: <20200731040520.3701599-1-airlied@gmail.com> References: <20200731040520.3701599-1-airlied@gmail.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: gmail.com X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: christian.koenig@amd.com, sroland@vmware.com, bskeggs@redhat.com, kraxel@redhat.com Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Dave Airlie Now no drivers have been converted, drop the non-driver path. Signed-off-by: Dave Airlie --- drivers/gpu/drm/ttm/ttm_bo_manager.c | 28 +++++++++------------------- 1 file changed, 9 insertions(+), 19 deletions(-) diff --git a/drivers/gpu/drm/ttm/ttm_bo_manager.c b/drivers/gpu/drm/ttm/ttm_bo_manager.c index 1127868274b3..f60a9a5d429d 100644 --- a/drivers/gpu/drm/ttm/ttm_bo_manager.c +++ b/drivers/gpu/drm/ttm/ttm_bo_manager.c @@ -129,26 +129,11 @@ int ttm_bo_man_init(struct ttm_bo_device *bdev, } EXPORT_SYMBOL(ttm_bo_man_init); -static int ttm_bo_man_takedown_private(struct ttm_mem_type_manager *man) -{ - struct ttm_range_manager *rman = (struct ttm_range_manager *) man->priv; - struct drm_mm *mm = &rman->mm; - - spin_lock(&rman->lock); - if (drm_mm_clean(mm)) { - drm_mm_takedown(mm); - spin_unlock(&rman->lock); - kfree(rman); - man->priv = NULL; - return 0; - } - spin_unlock(&rman->lock); - return -EBUSY; -} - int ttm_bo_man_takedown(struct ttm_bo_device *bdev, struct ttm_mem_type_manager *man) { + struct ttm_range_manager *rman = (struct ttm_range_manager *) man->priv; + struct drm_mm *mm = &rman->mm; int ret; ttm_bo_disable_mm(man); @@ -157,7 +142,13 @@ int ttm_bo_man_takedown(struct ttm_bo_device *bdev, if (ret) return ret; - ttm_bo_man_takedown_private(man); + spin_lock(&rman->lock); + drm_mm_clean(mm); + drm_mm_takedown(mm); + spin_unlock(&rman->lock); + kfree(rman); + man->priv = NULL; + ttm_bo_man_cleanup(man); return 0; } @@ -174,7 +165,6 @@ static void ttm_bo_man_debug(struct ttm_mem_type_manager *man, } static const struct ttm_mem_type_manager_func ttm_bo_manager_func = { - .takedown = ttm_bo_man_takedown_private, .get_node = ttm_bo_man_get_node, .put_node = ttm_bo_man_put_node, .debug = ttm_bo_man_debug From patchwork Fri Jul 31 04:04:56 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Dave Airlie X-Patchwork-Id: 11694009 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8E6BA161F for ; Fri, 31 Jul 2020 04:06:42 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 776732070B for ; Fri, 31 Jul 2020 04:06:42 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 776732070B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 2C5D26E9B0; Fri, 31 Jul 2020 04:06:38 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from us-smtp-delivery-1.mimecast.com (us-smtp-1.mimecast.com [207.211.31.81]) by gabe.freedesktop.org (Postfix) with ESMTPS id E78CC6E9A9 for ; Fri, 31 Jul 2020 04:06:28 +0000 (UTC) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-265-ujdKXnBHM0-iSABvGEPrNw-1; Fri, 31 Jul 2020 00:06:23 -0400 X-MC-Unique: ujdKXnBHM0-iSABvGEPrNw-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id B229410059A7; Fri, 31 Jul 2020 04:06:22 +0000 (UTC) Received: from tyrion-bne-redhat-com.redhat.com (vpn2-54-17.bne.redhat.com [10.64.54.17]) by smtp.corp.redhat.com (Postfix) with ESMTP id 44F6F100238C; Fri, 31 Jul 2020 04:06:21 +0000 (UTC) From: Dave Airlie To: dri-devel@lists.freedesktop.org Subject: [PATCH 25/49] drm/ttm: make TTM responsible for cleaning system only. Date: Fri, 31 Jul 2020 14:04:56 +1000 Message-Id: <20200731040520.3701599-26-airlied@gmail.com> In-Reply-To: <20200731040520.3701599-1-airlied@gmail.com> References: <20200731040520.3701599-1-airlied@gmail.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: gmail.com X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: christian.koenig@amd.com, sroland@vmware.com, bskeggs@redhat.com, kraxel@redhat.com Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Dave Airlie drivers should all be cleaning up their memory managers themselves now, so let the core just clean the system one up. Remove the legacy cleaning interface. Signed-off-by: Dave Airlie Reviewed-by: Christian König --- drivers/gpu/drm/ttm/ttm_bo.c | 55 +++------------------------------ include/drm/ttm/ttm_bo_api.h | 28 ----------------- include/drm/ttm/ttm_bo_driver.h | 10 ------ 3 files changed, 4 insertions(+), 89 deletions(-) diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c index f0f0f3101bd1..07c653374f15 100644 --- a/drivers/gpu/drm/ttm/ttm_bo.c +++ b/drivers/gpu/drm/ttm/ttm_bo.c @@ -1446,43 +1446,6 @@ int ttm_bo_force_list_clean(struct ttm_bo_device *bdev, } EXPORT_SYMBOL(ttm_bo_force_list_clean); -int ttm_bo_clean_mm(struct ttm_bo_device *bdev, unsigned mem_type) -{ - struct ttm_mem_type_manager *man; - int ret = -EINVAL; - - if (mem_type >= TTM_NUM_MEM_TYPES) { - pr_err("Illegal memory type %d\n", mem_type); - return ret; - } - man = &bdev->man[mem_type]; - - if (!man->has_type) { - pr_err("Trying to take down uninitialized memory manager type %u\n", - mem_type); - return ret; - } - - ttm_bo_disable_mm(man); - - ret = 0; - if (mem_type > 0) { - ret = ttm_bo_force_list_clean(bdev, man); - if (ret) { - pr_err("Cleanup eviction failed\n"); - return ret; - } - - if (man->func->takedown) - ret = (*man->func->takedown)(man); - } - - ttm_bo_man_cleanup(man); - - return ret; -} -EXPORT_SYMBOL(ttm_bo_clean_mm); - int ttm_bo_evict_mm(struct ttm_bo_device *bdev, unsigned mem_type) { struct ttm_mem_type_manager *man = &bdev->man[mem_type]; @@ -1585,21 +1548,11 @@ int ttm_bo_device_release(struct ttm_bo_device *bdev) { struct ttm_bo_global *glob = &ttm_bo_glob; int ret = 0; - unsigned i = TTM_NUM_MEM_TYPES; + unsigned i; struct ttm_mem_type_manager *man; - while (i--) { - man = &bdev->man[i]; - if (man->has_type) { - man->use_type = false; - if ((i != TTM_PL_SYSTEM) && ttm_bo_clean_mm(bdev, i)) { - ret = -EBUSY; - pr_err("DRM memory manager type %d is not clean\n", - i); - } - man->has_type = false; - } - } + man = &bdev->man[TTM_PL_SYSTEM]; + ttm_bo_disable_mm(man); mutex_lock(&ttm_global_mutex); list_del(&bdev->device_list); @@ -1612,7 +1565,7 @@ int ttm_bo_device_release(struct ttm_bo_device *bdev) spin_lock(&glob->lru_lock); for (i = 0; i < TTM_MAX_BO_PRIORITY; ++i) - if (list_empty(&bdev->man[0].lru[0])) + if (list_empty(&man->lru[0])) pr_debug("Swap list %d was clean\n", i); spin_unlock(&glob->lru_lock); diff --git a/include/drm/ttm/ttm_bo_api.h b/include/drm/ttm/ttm_bo_api.h index 6562d1c5ac59..27dde1371376 100644 --- a/include/drm/ttm/ttm_bo_api.h +++ b/include/drm/ttm/ttm_bo_api.h @@ -551,34 +551,6 @@ void ttm_bo_init_mm_base(struct ttm_bo_device *bdev, struct ttm_mem_type_manager *man, unsigned long p_size); -/** - * ttm_bo_clean_mm - * - * @bdev: Pointer to a ttm_bo_device struct. - * @mem_type: The memory type. - * - * Take down a manager for a given memory type after first walking - * the LRU list to evict any buffers left alive. - * - * Normally, this function is part of lastclose() or unload(), and at that - * point there shouldn't be any buffers left created by user-space, since - * there should've been removed by the file descriptor release() method. - * However, before this function is run, make sure to signal all sync objects, - * and verify that the delayed delete queue is empty. The driver must also - * make sure that there are no NO_EVICT buffers present in this memory type - * when the call is made. - * - * If this function is part of a VT switch, the caller must make sure that - * there are no appications currently validating buffers before this - * function is called. The caller can do that by first taking the - * struct ttm_bo_device::ttm_lock in write mode. - * - * Returns: - * -EINVAL: invalid or uninitialized memory type. - * -EBUSY: There are still buffers left in this memory type. - */ -int ttm_bo_clean_mm(struct ttm_bo_device *bdev, unsigned mem_type); - /** * ttm_bo_evict_mm * diff --git a/include/drm/ttm/ttm_bo_driver.h b/include/drm/ttm/ttm_bo_driver.h index 2ef33b407167..9d066529ca61 100644 --- a/include/drm/ttm/ttm_bo_driver.h +++ b/include/drm/ttm/ttm_bo_driver.h @@ -48,16 +48,6 @@ struct ttm_mem_type_manager; struct ttm_mem_type_manager_func { - /** - * struct ttm_mem_type_manager member takedown - * - * @man: Pointer to a memory type manager. - * - * Called to undo the setup done in init. All allocated resources - * should be freed. - */ - int (*takedown)(struct ttm_mem_type_manager *man); - /** * struct ttm_mem_type_manager member get_node * From patchwork Fri Jul 31 04:04:57 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Airlie X-Patchwork-Id: 11694029 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6652014E3 for ; Fri, 31 Jul 2020 04:07:11 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 4E9DF2070B for ; Fri, 31 Jul 2020 04:07:11 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4E9DF2070B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 9C26F6E9B6; Fri, 31 Jul 2020 04:07:04 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) by gabe.freedesktop.org (Postfix) with ESMTPS id EEB976E9A0 for ; Fri, 31 Jul 2020 04:06:42 +0000 (UTC) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-102-D4lwhKukNiy2x27eft3eUQ-1; Fri, 31 Jul 2020 00:06:28 -0400 X-MC-Unique: D4lwhKukNiy2x27eft3eUQ-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 62F678015CE; Fri, 31 Jul 2020 04:06:27 +0000 (UTC) Received: from tyrion-bne-redhat-com.redhat.com (vpn2-54-17.bne.redhat.com [10.64.54.17]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1D946100238C; Fri, 31 Jul 2020 04:06:22 +0000 (UTC) From: Dave Airlie To: dri-devel@lists.freedesktop.org Subject: [PATCH 26/49] drm/ttm: add wrapper to get manager from bdev. Date: Fri, 31 Jul 2020 14:04:57 +1000 Message-Id: <20200731040520.3701599-27-airlied@gmail.com> In-Reply-To: <20200731040520.3701599-1-airlied@gmail.com> References: <20200731040520.3701599-1-airlied@gmail.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: gmail.com X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: christian.koenig@amd.com, sroland@vmware.com, bskeggs@redhat.com, kraxel@redhat.com Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Dave Airlie This will allow different abstractions later. Signed-off-by: Dave Airlie --- drivers/gpu/drm/ttm/ttm_bo.c | 34 +++++++++++++++---------------- drivers/gpu/drm/ttm/ttm_bo_util.c | 20 +++++++++--------- drivers/gpu/drm/ttm/ttm_bo_vm.c | 2 +- include/drm/ttm/ttm_bo_driver.h | 6 ++++++ 4 files changed, 34 insertions(+), 28 deletions(-) diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c index 07c653374f15..7c6389ea067f 100644 --- a/drivers/gpu/drm/ttm/ttm_bo.c +++ b/drivers/gpu/drm/ttm/ttm_bo.c @@ -80,7 +80,7 @@ static inline int ttm_mem_type_from_place(const struct ttm_place *place, static void ttm_mem_type_debug(struct ttm_bo_device *bdev, struct drm_printer *p, int mem_type) { - struct ttm_mem_type_manager *man = &bdev->man[mem_type]; + struct ttm_mem_type_manager *man = ttm_manager_type(bdev, mem_type); drm_printf(p, " has_type: %d\n", man->has_type); drm_printf(p, " use_type: %d\n", man->use_type); @@ -156,7 +156,7 @@ static void ttm_bo_add_mem_to_lru(struct ttm_buffer_object *bo, if (mem->placement & TTM_PL_FLAG_NO_EVICT) return; - man = &bdev->man[mem->mem_type]; + man = ttm_manager_type(bdev, mem->mem_type); list_add_tail(&bo->lru, &man->lru[bo->priority]); if (man->use_tt && bo->ttm && @@ -231,7 +231,7 @@ void ttm_bo_bulk_move_lru_tail(struct ttm_lru_bulk_move *bulk) dma_resv_assert_held(pos->first->base.resv); dma_resv_assert_held(pos->last->base.resv); - man = &pos->first->bdev->man[TTM_PL_TT]; + man = ttm_manager_type(pos->first->bdev, TTM_PL_TT); list_bulk_move_tail(&man->lru[i], &pos->first->lru, &pos->last->lru); } @@ -246,7 +246,7 @@ void ttm_bo_bulk_move_lru_tail(struct ttm_lru_bulk_move *bulk) dma_resv_assert_held(pos->first->base.resv); dma_resv_assert_held(pos->last->base.resv); - man = &pos->first->bdev->man[TTM_PL_VRAM]; + man = ttm_manager_type(pos->first->bdev, TTM_PL_VRAM); list_bulk_move_tail(&man->lru[i], &pos->first->lru, &pos->last->lru); } @@ -272,8 +272,8 @@ static int ttm_bo_handle_move_mem(struct ttm_buffer_object *bo, struct ttm_operation_ctx *ctx) { struct ttm_bo_device *bdev = bo->bdev; - struct ttm_mem_type_manager *old_man = &bdev->man[bo->mem.mem_type]; - struct ttm_mem_type_manager *new_man = &bdev->man[mem->mem_type]; + struct ttm_mem_type_manager *old_man = ttm_manager_type(bdev, bo->mem.mem_type); + struct ttm_mem_type_manager *new_man = ttm_manager_type(bdev, mem->mem_type); int ret; ret = ttm_mem_io_lock(old_man, true); @@ -338,7 +338,7 @@ static int ttm_bo_handle_move_mem(struct ttm_buffer_object *bo, return 0; out_err: - new_man = &bdev->man[bo->mem.mem_type]; + new_man = ttm_manager_type(bdev, bo->mem.mem_type); if (!new_man->use_tt) { ttm_tt_destroy(bo->ttm); bo->ttm = NULL; @@ -550,7 +550,7 @@ static void ttm_bo_release(struct kref *kref) struct ttm_buffer_object *bo = container_of(kref, struct ttm_buffer_object, kref); struct ttm_bo_device *bdev = bo->bdev; - struct ttm_mem_type_manager *man = &bdev->man[bo->mem.mem_type]; + struct ttm_mem_type_manager *man = ttm_manager_type(bdev, bo->mem.mem_type); size_t acc_size = bo->acc_size; int ret; @@ -838,7 +838,7 @@ static int ttm_bo_mem_get(struct ttm_buffer_object *bo, const struct ttm_place *place, struct ttm_mem_reg *mem) { - struct ttm_mem_type_manager *man = &bo->bdev->man[mem->mem_type]; + struct ttm_mem_type_manager *man = ttm_manager_type(bo->bdev, mem->mem_type); mem->mm_node = NULL; if (!man->func || !man->func->get_node) @@ -849,7 +849,7 @@ static int ttm_bo_mem_get(struct ttm_buffer_object *bo, void ttm_bo_mem_put(struct ttm_buffer_object *bo, struct ttm_mem_reg *mem) { - struct ttm_mem_type_manager *man = &bo->bdev->man[mem->mem_type]; + struct ttm_mem_type_manager *man = ttm_manager_type(bo->bdev, mem->mem_type); if (!man->func || !man->func->put_node) return; @@ -906,7 +906,7 @@ static int ttm_bo_mem_force_space(struct ttm_buffer_object *bo, struct ttm_operation_ctx *ctx) { struct ttm_bo_device *bdev = bo->bdev; - struct ttm_mem_type_manager *man = &bdev->man[mem->mem_type]; + struct ttm_mem_type_manager *man = ttm_manager_type(bdev, mem->mem_type); struct ww_acquire_ctx *ticket; int ret; @@ -996,7 +996,7 @@ static int ttm_bo_mem_placement(struct ttm_buffer_object *bo, if (ret) return ret; - man = &bdev->man[mem_type]; + man = ttm_manager_type(bdev, mem_type); if (!man->has_type || !man->use_type) return -EBUSY; @@ -1059,7 +1059,7 @@ int ttm_bo_mem_space(struct ttm_buffer_object *bo, if (unlikely(ret)) goto error; - man = &bdev->man[mem->mem_type]; + man = ttm_manager_type(bdev, mem->mem_type); ret = ttm_bo_add_move_fence(bo, man, mem, ctx->no_wait_gpu); if (unlikely(ret)) { ttm_bo_mem_put(bo, mem); @@ -1448,7 +1448,7 @@ EXPORT_SYMBOL(ttm_bo_force_list_clean); int ttm_bo_evict_mm(struct ttm_bo_device *bdev, unsigned mem_type) { - struct ttm_mem_type_manager *man = &bdev->man[mem_type]; + struct ttm_mem_type_manager *man = ttm_manager_type(bdev, mem_type); if (mem_type == 0 || mem_type >= TTM_NUM_MEM_TYPES) { pr_err("Illegal memory manager memory type %u\n", mem_type); @@ -1551,7 +1551,7 @@ int ttm_bo_device_release(struct ttm_bo_device *bdev) unsigned i; struct ttm_mem_type_manager *man; - man = &bdev->man[TTM_PL_SYSTEM]; + man = ttm_manager_type(bdev, TTM_PL_SYSTEM); ttm_bo_disable_mm(man); mutex_lock(&ttm_global_mutex); @@ -1578,7 +1578,7 @@ EXPORT_SYMBOL(ttm_bo_device_release); static void ttm_bo_init_sysman(struct ttm_bo_device *bdev) { - struct ttm_mem_type_manager *man = &bdev->man[TTM_PL_SYSTEM]; + struct ttm_mem_type_manager *man = ttm_manager_type(bdev, TTM_PL_SYSTEM); /* * Initialize the system memory buffer type. @@ -1642,7 +1642,7 @@ void ttm_bo_unmap_virtual_locked(struct ttm_buffer_object *bo) void ttm_bo_unmap_virtual(struct ttm_buffer_object *bo) { struct ttm_bo_device *bdev = bo->bdev; - struct ttm_mem_type_manager *man = &bdev->man[bo->mem.mem_type]; + struct ttm_mem_type_manager *man = ttm_manager_type(bdev, bo->mem.mem_type); ttm_mem_io_lock(man, false); ttm_bo_unmap_virtual_locked(bo); diff --git a/drivers/gpu/drm/ttm/ttm_bo_util.c b/drivers/gpu/drm/ttm/ttm_bo_util.c index 1f502be0b646..879c8ded0cd8 100644 --- a/drivers/gpu/drm/ttm/ttm_bo_util.c +++ b/drivers/gpu/drm/ttm/ttm_bo_util.c @@ -129,7 +129,7 @@ static int ttm_mem_io_evict(struct ttm_mem_type_manager *man) int ttm_mem_io_reserve(struct ttm_bo_device *bdev, struct ttm_mem_reg *mem) { - struct ttm_mem_type_manager *man = &bdev->man[mem->mem_type]; + struct ttm_mem_type_manager *man = ttm_manager_type(bdev, mem->mem_type); int ret; if (mem->bus.io_reserved_count++) @@ -162,7 +162,7 @@ void ttm_mem_io_free(struct ttm_bo_device *bdev, int ttm_mem_io_reserve_vm(struct ttm_buffer_object *bo) { - struct ttm_mem_type_manager *man = &bo->bdev->man[bo->mem.mem_type]; + struct ttm_mem_type_manager *man = ttm_manager_type(bo->bdev, bo->mem.mem_type); struct ttm_mem_reg *mem = &bo->mem; int ret; @@ -195,7 +195,7 @@ static int ttm_mem_reg_ioremap(struct ttm_bo_device *bdev, struct ttm_mem_reg *mem, void **virtual) { - struct ttm_mem_type_manager *man = &bdev->man[mem->mem_type]; + struct ttm_mem_type_manager *man = ttm_manager_type(bdev, mem->mem_type); int ret; void *addr; @@ -232,7 +232,7 @@ static void ttm_mem_reg_iounmap(struct ttm_bo_device *bdev, { struct ttm_mem_type_manager *man; - man = &bdev->man[mem->mem_type]; + man = ttm_manager_type(bdev, mem->mem_type); if (virtual && mem->bus.addr == NULL) iounmap(virtual); @@ -303,7 +303,7 @@ int ttm_bo_move_memcpy(struct ttm_buffer_object *bo, struct ttm_mem_reg *new_mem) { struct ttm_bo_device *bdev = bo->bdev; - struct ttm_mem_type_manager *man = &bdev->man[new_mem->mem_type]; + struct ttm_mem_type_manager *man = ttm_manager_type(bdev, new_mem->mem_type); struct ttm_tt *ttm = bo->ttm; struct ttm_mem_reg *old_mem = &bo->mem; struct ttm_mem_reg old_copy = *old_mem; @@ -571,7 +571,7 @@ int ttm_bo_kmap(struct ttm_buffer_object *bo, struct ttm_bo_kmap_obj *map) { struct ttm_mem_type_manager *man = - &bo->bdev->man[bo->mem.mem_type]; + ttm_manager_type(bo->bdev, bo->mem.mem_type); unsigned long offset, size; int ret; @@ -601,7 +601,7 @@ void ttm_bo_kunmap(struct ttm_bo_kmap_obj *map) { struct ttm_buffer_object *bo = map->bo; struct ttm_mem_type_manager *man = - &bo->bdev->man[bo->mem.mem_type]; + ttm_manager_type(bo->bdev, bo->mem.mem_type); if (!map->virtual) return; @@ -634,7 +634,7 @@ int ttm_bo_move_accel_cleanup(struct ttm_buffer_object *bo, struct ttm_mem_reg *new_mem) { struct ttm_bo_device *bdev = bo->bdev; - struct ttm_mem_type_manager *man = &bdev->man[new_mem->mem_type]; + struct ttm_mem_type_manager *man = ttm_manager_type(bdev, new_mem->mem_type); struct ttm_mem_reg *old_mem = &bo->mem; int ret; struct ttm_buffer_object *ghost_obj; @@ -697,8 +697,8 @@ int ttm_bo_pipeline_move(struct ttm_buffer_object *bo, struct ttm_bo_device *bdev = bo->bdev; struct ttm_mem_reg *old_mem = &bo->mem; - struct ttm_mem_type_manager *from = &bdev->man[old_mem->mem_type]; - struct ttm_mem_type_manager *to = &bdev->man[new_mem->mem_type]; + struct ttm_mem_type_manager *from = ttm_manager_type(bdev, old_mem->mem_type); + struct ttm_mem_type_manager *to = ttm_manager_type(bdev, new_mem->mem_type); int ret; diff --git a/drivers/gpu/drm/ttm/ttm_bo_vm.c b/drivers/gpu/drm/ttm/ttm_bo_vm.c index 468a0eb9e632..5ae679184eb5 100644 --- a/drivers/gpu/drm/ttm/ttm_bo_vm.c +++ b/drivers/gpu/drm/ttm/ttm_bo_vm.c @@ -282,7 +282,7 @@ vm_fault_t ttm_bo_vm_fault_reserved(struct vm_fault *vmf, vm_fault_t ret = VM_FAULT_NOPAGE; unsigned long address = vmf->address; struct ttm_mem_type_manager *man = - &bdev->man[bo->mem.mem_type]; + ttm_manager_type(bdev, bo->mem.mem_type); /* * Refuse to fault imported pages. This should be handled diff --git a/include/drm/ttm/ttm_bo_driver.h b/include/drm/ttm/ttm_bo_driver.h index 9d066529ca61..ec25451b503f 100644 --- a/include/drm/ttm/ttm_bo_driver.h +++ b/include/drm/ttm/ttm_bo_driver.h @@ -444,6 +444,12 @@ struct ttm_bo_device { bool no_retry; }; +static inline struct ttm_mem_type_manager *ttm_manager_type(struct ttm_bo_device *bdev, + int mem_type) +{ + return &bdev->man[mem_type]; +} + /** * struct ttm_lru_bulk_move_pos * From patchwork Fri Jul 31 04:04:58 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Airlie X-Patchwork-Id: 11694019 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1515D13B1 for ; Fri, 31 Jul 2020 04:06:56 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id F180A2070B for ; Fri, 31 Jul 2020 04:06:55 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org F180A2070B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 00D556E9B2; Fri, 31 Jul 2020 04:06:51 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from us-smtp-delivery-1.mimecast.com (us-smtp-1.mimecast.com [205.139.110.61]) by gabe.freedesktop.org (Postfix) with ESMTPS id 8952E6E9AE for ; Fri, 31 Jul 2020 04:06:37 +0000 (UTC) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-112-K6CmWFv5M4SaQ-BoECRC-A-1; Fri, 31 Jul 2020 00:06:30 -0400 X-MC-Unique: K6CmWFv5M4SaQ-BoECRC-A-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 3ED831005510; Fri, 31 Jul 2020 04:06:29 +0000 (UTC) Received: from tyrion-bne-redhat-com.redhat.com (vpn2-54-17.bne.redhat.com [10.64.54.17]) by smtp.corp.redhat.com (Postfix) with ESMTP id C39261002393; Fri, 31 Jul 2020 04:06:27 +0000 (UTC) From: Dave Airlie To: dri-devel@lists.freedesktop.org Subject: [PATCH 27/49] drm/amdgfx/ttm: use wrapper to get ttm memory managers Date: Fri, 31 Jul 2020 14:04:58 +1000 Message-Id: <20200731040520.3701599-28-airlied@gmail.com> In-Reply-To: <20200731040520.3701599-1-airlied@gmail.com> References: <20200731040520.3701599-1-airlied@gmail.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: gmail.com X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: christian.koenig@amd.com, sroland@vmware.com, bskeggs@redhat.com, kraxel@redhat.com Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Dave Airlie Signed-off-by: Dave Airlie --- drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c | 3 ++- drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 6 +++--- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 5 ++--- drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c | 12 +++++------ drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c | 21 +++++++++++--------- drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 4 ++-- drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 12 +++++------ drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c | 12 +++++------ 8 files changed, 39 insertions(+), 36 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c index 1b865fed74ca..e24f421e5553 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c @@ -517,8 +517,9 @@ int amdgpu_amdkfd_get_dmabuf_info(struct kgd_dev *kgd, int dma_buf_fd, uint64_t amdgpu_amdkfd_get_vram_usage(struct kgd_dev *kgd) { struct amdgpu_device *adev = (struct amdgpu_device *)kgd; + struct ttm_mem_type_manager *vram_man = ttm_manager_type(&adev->mman.bdev, TTM_PL_VRAM); - return amdgpu_vram_mgr_usage(&adev->mman.bdev.man[TTM_PL_VRAM]); + return amdgpu_vram_mgr_usage(vram_man); } uint64_t amdgpu_amdkfd_get_hive_id(struct kgd_dev *kgd) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c index a512ccbc4dea..9829640e1769 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c @@ -299,7 +299,7 @@ static void amdgpu_cs_get_threshold_for_moves(struct amdgpu_device *adev, { s64 time_us, increment_us; u64 free_vram, total_vram, used_vram; - + struct ttm_mem_type_manager *vram_man = ttm_manager_type(&adev->mman.bdev, TTM_PL_VRAM); /* Allow a maximum of 200 accumulated ms. This is basically per-IB * throttling. * @@ -316,7 +316,7 @@ static void amdgpu_cs_get_threshold_for_moves(struct amdgpu_device *adev, } total_vram = adev->gmc.real_vram_size - atomic64_read(&adev->vram_pin_size); - used_vram = amdgpu_vram_mgr_usage(&adev->mman.bdev.man[TTM_PL_VRAM]); + used_vram = amdgpu_vram_mgr_usage(vram_man); free_vram = used_vram >= total_vram ? 0 : total_vram - used_vram; spin_lock(&adev->mm_stats.lock); @@ -363,7 +363,7 @@ static void amdgpu_cs_get_threshold_for_moves(struct amdgpu_device *adev, if (!amdgpu_gmc_vram_full_visible(&adev->gmc)) { u64 total_vis_vram = adev->gmc.visible_vram_size; u64 used_vis_vram = - amdgpu_vram_mgr_vis_usage(&adev->mman.bdev.man[TTM_PL_VRAM]); + amdgpu_vram_mgr_vis_usage(vram_man); if (used_vis_vram < total_vis_vram) { u64 free_vis_vram = total_vis_vram - used_vis_vram; diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c index aa5b54e5a1d7..d551e7c5e69d 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c @@ -3880,7 +3880,7 @@ static int amdgpu_device_reset_sriov(struct amdgpu_device *adev, amdgpu_virt_init_data_exchange(adev); /* we need recover gart prior to run SMC/CP/SDMA resume */ - amdgpu_gtt_mgr_recover(&adev->mman.bdev.man[TTM_PL_TT]); + amdgpu_gtt_mgr_recover(ttm_manager_type(&adev->mman.bdev, TTM_PL_TT)); r = amdgpu_device_fw_loading(adev); if (r) @@ -4079,8 +4079,7 @@ static int amdgpu_do_asic_reset(struct amdgpu_hive_info *hive, amdgpu_inc_vram_lost(tmp_adev); } - r = amdgpu_gtt_mgr_recover( - &tmp_adev->mman.bdev.man[TTM_PL_TT]); + r = amdgpu_gtt_mgr_recover(ttm_manager_type(&tmp_adev->mman.bdev, TTM_PL_TT)); if (r) goto out; diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c index f4c870b2f348..0b0d09d19b4f 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c @@ -48,9 +48,9 @@ static ssize_t amdgpu_mem_info_gtt_total_show(struct device *dev, { struct drm_device *ddev = dev_get_drvdata(dev); struct amdgpu_device *adev = ddev->dev_private; - + struct ttm_mem_type_manager *man = ttm_manager_type(&adev->mman.bdev, TTM_PL_TT); return snprintf(buf, PAGE_SIZE, "%llu\n", - (adev->mman.bdev.man[TTM_PL_TT].size) * PAGE_SIZE); + man->size * PAGE_SIZE); } /** @@ -66,9 +66,9 @@ static ssize_t amdgpu_mem_info_gtt_used_show(struct device *dev, { struct drm_device *ddev = dev_get_drvdata(dev); struct amdgpu_device *adev = ddev->dev_private; - + struct ttm_mem_type_manager *man = ttm_manager_type(&adev->mman.bdev, TTM_PL_TT); return snprintf(buf, PAGE_SIZE, "%llu\n", - amdgpu_gtt_mgr_usage(&adev->mman.bdev.man[TTM_PL_TT])); + amdgpu_gtt_mgr_usage(man)); } static DEVICE_ATTR(mem_info_gtt_total, S_IRUGO, @@ -87,7 +87,7 @@ static const struct ttm_mem_type_manager_func amdgpu_gtt_mgr_func; */ int amdgpu_gtt_mgr_init(struct amdgpu_device *adev, uint64_t gtt_size) { - struct ttm_mem_type_manager *man = &adev->mman.bdev.man[TTM_PL_TT]; + struct ttm_mem_type_manager *man = ttm_manager_type(&adev->mman.bdev, TTM_PL_TT); struct amdgpu_gtt_mgr *mgr; uint64_t start, size; int ret; @@ -135,7 +135,7 @@ int amdgpu_gtt_mgr_init(struct amdgpu_device *adev, uint64_t gtt_size) */ void amdgpu_gtt_mgr_fini(struct amdgpu_device *adev) { - struct ttm_mem_type_manager *man = &adev->mman.bdev.man[TTM_PL_TT]; + struct ttm_mem_type_manager *man = ttm_manager_type(&adev->mman.bdev, TTM_PL_TT); struct amdgpu_gtt_mgr *mgr = man->priv; int ret; diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c index a8c47aecd342..594687cc99ac 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c @@ -594,13 +594,13 @@ static int amdgpu_info_ioctl(struct drm_device *dev, void *data, struct drm_file ui64 = atomic64_read(&adev->num_vram_cpu_page_faults); return copy_to_user(out, &ui64, min(size, 8u)) ? -EFAULT : 0; case AMDGPU_INFO_VRAM_USAGE: - ui64 = amdgpu_vram_mgr_usage(&adev->mman.bdev.man[TTM_PL_VRAM]); + ui64 = amdgpu_vram_mgr_usage(ttm_manager_type(&adev->mman.bdev, TTM_PL_VRAM)); return copy_to_user(out, &ui64, min(size, 8u)) ? -EFAULT : 0; case AMDGPU_INFO_VIS_VRAM_USAGE: - ui64 = amdgpu_vram_mgr_vis_usage(&adev->mman.bdev.man[TTM_PL_VRAM]); + ui64 = amdgpu_vram_mgr_vis_usage(ttm_manager_type(&adev->mman.bdev, TTM_PL_VRAM)); return copy_to_user(out, &ui64, min(size, 8u)) ? -EFAULT : 0; case AMDGPU_INFO_GTT_USAGE: - ui64 = amdgpu_gtt_mgr_usage(&adev->mman.bdev.man[TTM_PL_TT]); + ui64 = amdgpu_gtt_mgr_usage(ttm_manager_type(&adev->mman.bdev, TTM_PL_TT)); return copy_to_user(out, &ui64, min(size, 8u)) ? -EFAULT : 0; case AMDGPU_INFO_GDS_CONFIG: { struct drm_amdgpu_info_gds gds_info; @@ -623,7 +623,7 @@ static int amdgpu_info_ioctl(struct drm_device *dev, void *data, struct drm_file min(adev->gmc.visible_vram_size - atomic64_read(&adev->visible_pin_size), vram_gtt.vram_size); - vram_gtt.gtt_size = adev->mman.bdev.man[TTM_PL_TT].size; + vram_gtt.gtt_size = ttm_manager_type(&adev->mman.bdev, TTM_PL_TT)->size; vram_gtt.gtt_size *= PAGE_SIZE; vram_gtt.gtt_size -= atomic64_read(&adev->gart_pin_size); return copy_to_user(out, &vram_gtt, @@ -631,14 +631,17 @@ static int amdgpu_info_ioctl(struct drm_device *dev, void *data, struct drm_file } case AMDGPU_INFO_MEMORY: { struct drm_amdgpu_memory_info mem; - + struct ttm_mem_type_manager *vram_man = + ttm_manager_type(&adev->mman.bdev, TTM_PL_VRAM); + struct ttm_mem_type_manager *gtt_man = + ttm_manager_type(&adev->mman.bdev, TTM_PL_TT); memset(&mem, 0, sizeof(mem)); mem.vram.total_heap_size = adev->gmc.real_vram_size; mem.vram.usable_heap_size = adev->gmc.real_vram_size - atomic64_read(&adev->vram_pin_size) - AMDGPU_VM_RESERVED_VRAM; mem.vram.heap_usage = - amdgpu_vram_mgr_usage(&adev->mman.bdev.man[TTM_PL_VRAM]); + amdgpu_vram_mgr_usage(vram_man); mem.vram.max_allocation = mem.vram.usable_heap_size * 3 / 4; mem.cpu_accessible_vram.total_heap_size = @@ -648,16 +651,16 @@ static int amdgpu_info_ioctl(struct drm_device *dev, void *data, struct drm_file atomic64_read(&adev->visible_pin_size), mem.vram.usable_heap_size); mem.cpu_accessible_vram.heap_usage = - amdgpu_vram_mgr_vis_usage(&adev->mman.bdev.man[TTM_PL_VRAM]); + amdgpu_vram_mgr_vis_usage(vram_man); mem.cpu_accessible_vram.max_allocation = mem.cpu_accessible_vram.usable_heap_size * 3 / 4; - mem.gtt.total_heap_size = adev->mman.bdev.man[TTM_PL_TT].size; + mem.gtt.total_heap_size = gtt_man->size; mem.gtt.total_heap_size *= PAGE_SIZE; mem.gtt.usable_heap_size = mem.gtt.total_heap_size - atomic64_read(&adev->gart_pin_size); mem.gtt.heap_usage = - amdgpu_gtt_mgr_usage(&adev->mman.bdev.man[TTM_PL_TT]); + amdgpu_gtt_mgr_usage(gtt_man); mem.gtt.max_allocation = mem.gtt.usable_heap_size * 3 / 4; return copy_to_user(out, &mem, diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c index 5ac7b5561475..ced418cba2f7 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c @@ -449,7 +449,7 @@ static bool amdgpu_bo_validate_size(struct amdgpu_device *adev, * allow fall back to GTT */ if (domain & AMDGPU_GEM_DOMAIN_GTT) { - man = &adev->mman.bdev.man[TTM_PL_TT]; + man = ttm_manager_type(&adev->mman.bdev, TTM_PL_TT); if (size < (man->size << PAGE_SHIFT)) return true; @@ -458,7 +458,7 @@ static bool amdgpu_bo_validate_size(struct amdgpu_device *adev, } if (domain & AMDGPU_GEM_DOMAIN_VRAM) { - man = &adev->mman.bdev.man[TTM_PL_VRAM]; + man = ttm_manager_type(&adev->mman.bdev, TTM_PL_VRAM); if (size < (man->size << PAGE_SHIFT)) return true; diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c index b1452df8fce9..4beec1c4e037 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c @@ -67,7 +67,7 @@ static int amdgpu_ttm_init_on_chip(struct amdgpu_device *adev, unsigned int type, uint64_t size) { - struct ttm_mem_type_manager *man = &adev->mman.bdev.man[type]; + struct ttm_mem_type_manager *man = ttm_manager_type(&adev->mman.bdev, type); man->available_caching = TTM_PL_FLAG_UNCACHED; man->default_caching = TTM_PL_FLAG_UNCACHED; @@ -2014,9 +2014,9 @@ void amdgpu_ttm_fini(struct amdgpu_device *adev) amdgpu_vram_mgr_fini(adev); amdgpu_gtt_mgr_fini(adev); - ttm_bo_man_takedown(&adev->mman.bdev, &adev->mman.bdev.man[AMDGPU_PL_GDS]); - ttm_bo_man_takedown(&adev->mman.bdev, &adev->mman.bdev.man[AMDGPU_PL_GWS]); - ttm_bo_man_takedown(&adev->mman.bdev, &adev->mman.bdev.man[AMDGPU_PL_OA]); + ttm_bo_man_takedown(&adev->mman.bdev, ttm_manager_type(&adev->mman.bdev, AMDGPU_PL_GDS)); + ttm_bo_man_takedown(&adev->mman.bdev, ttm_manager_type(&adev->mman.bdev, AMDGPU_PL_GWS)); + ttm_bo_man_takedown(&adev->mman.bdev, ttm_manager_type(&adev->mman.bdev, AMDGPU_PL_OA)); ttm_bo_device_release(&adev->mman.bdev); adev->mman.initialized = false; DRM_INFO("amdgpu: ttm finalized\n"); @@ -2033,7 +2033,7 @@ void amdgpu_ttm_fini(struct amdgpu_device *adev) */ void amdgpu_ttm_set_buffer_funcs_status(struct amdgpu_device *adev, bool enable) { - struct ttm_mem_type_manager *man = &adev->mman.bdev.man[TTM_PL_VRAM]; + struct ttm_mem_type_manager *man = ttm_manager_type(&adev->mman.bdev, TTM_PL_VRAM); uint64_t size; int r; @@ -2255,7 +2255,7 @@ static int amdgpu_mm_dump_table(struct seq_file *m, void *data) unsigned ttm_pl = (uintptr_t)node->info_ent->data; struct drm_device *dev = node->minor->dev; struct amdgpu_device *adev = dev->dev_private; - struct ttm_mem_type_manager *man = &adev->mman.bdev.man[ttm_pl]; + struct ttm_mem_type_manager *man = ttm_manager_type(&adev->mman.bdev, ttm_pl); struct drm_printer p = drm_seq_file_printer(m); man->func->debug(man, &p); diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c index cc45be8ccb0f..d33a750e07a8 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c @@ -82,9 +82,9 @@ static ssize_t amdgpu_mem_info_vram_used_show(struct device *dev, { struct drm_device *ddev = dev_get_drvdata(dev); struct amdgpu_device *adev = ddev->dev_private; - + struct ttm_mem_type_manager *man = ttm_manager_type(&adev->mman.bdev, TTM_PL_VRAM); return snprintf(buf, PAGE_SIZE, "%llu\n", - amdgpu_vram_mgr_usage(&adev->mman.bdev.man[TTM_PL_VRAM])); + amdgpu_vram_mgr_usage(man)); } /** @@ -100,9 +100,9 @@ static ssize_t amdgpu_mem_info_vis_vram_used_show(struct device *dev, { struct drm_device *ddev = dev_get_drvdata(dev); struct amdgpu_device *adev = ddev->dev_private; - + struct ttm_mem_type_manager *man = ttm_manager_type(&adev->mman.bdev, TTM_PL_VRAM); return snprintf(buf, PAGE_SIZE, "%llu\n", - amdgpu_vram_mgr_vis_usage(&adev->mman.bdev.man[TTM_PL_VRAM])); + amdgpu_vram_mgr_vis_usage(man)); } static ssize_t amdgpu_mem_info_vram_vendor(struct device *dev, @@ -170,7 +170,7 @@ static const struct ttm_mem_type_manager_func amdgpu_vram_mgr_func; */ int amdgpu_vram_mgr_init(struct amdgpu_device *adev) { - struct ttm_mem_type_manager *man = &adev->mman.bdev.man[TTM_PL_VRAM]; + struct ttm_mem_type_manager *man = ttm_manager_type(&adev->mman.bdev, TTM_PL_VRAM); struct amdgpu_vram_mgr *mgr; int ret; @@ -207,7 +207,7 @@ int amdgpu_vram_mgr_init(struct amdgpu_device *adev) */ void amdgpu_vram_mgr_fini(struct amdgpu_device *adev) { - struct ttm_mem_type_manager *man = &adev->mman.bdev.man[TTM_PL_VRAM]; + struct ttm_mem_type_manager *man = ttm_manager_type(&adev->mman.bdev, TTM_PL_VRAM); struct amdgpu_vram_mgr *mgr = man->priv; int ret; From patchwork Fri Jul 31 04:04:59 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Airlie X-Patchwork-Id: 11694011 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D7382161F for ; Fri, 31 Jul 2020 04:06:43 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id C00AB2070B for ; Fri, 31 Jul 2020 04:06:43 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C00AB2070B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 4CCF76E9AE; Fri, 31 Jul 2020 04:06:40 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from us-smtp-delivery-1.mimecast.com (us-smtp-2.mimecast.com [207.211.31.81]) by gabe.freedesktop.org (Postfix) with ESMTPS id 7036B6E9A9 for ; Fri, 31 Jul 2020 04:06:36 +0000 (UTC) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-23-vEaCvUjNNNGU5eO9JSr8OA-1; Fri, 31 Jul 2020 00:06:32 -0400 X-MC-Unique: vEaCvUjNNNGU5eO9JSr8OA-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 1850010059A8; Fri, 31 Jul 2020 04:06:31 +0000 (UTC) Received: from tyrion-bne-redhat-com.redhat.com (vpn2-54-17.bne.redhat.com [10.64.54.17]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9DE9B1002393; Fri, 31 Jul 2020 04:06:29 +0000 (UTC) From: Dave Airlie To: dri-devel@lists.freedesktop.org Subject: [PATCH 28/49] drm/vram-helper: use wrapper to access memory managers Date: Fri, 31 Jul 2020 14:04:59 +1000 Message-Id: <20200731040520.3701599-29-airlied@gmail.com> In-Reply-To: <20200731040520.3701599-1-airlied@gmail.com> References: <20200731040520.3701599-1-airlied@gmail.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=airlied@gmail.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: gmail.com X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: christian.koenig@amd.com, sroland@vmware.com, bskeggs@redhat.com, kraxel@redhat.com Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Dave Airlie Signed-off-by: Dave Airlie --- drivers/gpu/drm/drm_gem_vram_helper.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/drm_gem_vram_helper.c b/drivers/gpu/drm/drm_gem_vram_helper.c index c6cc90d42f56..08fbfa32540a 100644 --- a/drivers/gpu/drm/drm_gem_vram_helper.c +++ b/drivers/gpu/drm/drm_gem_vram_helper.c @@ -1075,7 +1075,7 @@ static int drm_vram_mm_debugfs(struct seq_file *m, void *data) { struct drm_info_node *node = (struct drm_info_node *) m->private; struct drm_vram_mm *vmm = node->minor->dev->vram_mm; - struct ttm_mem_type_manager *man = &vmm->bdev.man[TTM_PL_VRAM]; + struct ttm_mem_type_manager *man = ttm_manager_type(&vmm->bdev, TTM_PL_VRAM); struct drm_printer p = drm_seq_file_printer(m); man->func->debug(man, &p); @@ -1103,7 +1103,7 @@ EXPORT_SYMBOL(drm_vram_mm_debugfs_init); static int drm_vram_mm_init(struct drm_vram_mm *vmm, struct drm_device *dev, uint64_t vram_base, size_t vram_size) { - struct ttm_mem_type_manager *man = &vmm->bdev.man[TTM_PL_VRAM]; + struct ttm_mem_type_manager *man = ttm_manager_type(&vmm->bdev, TTM_PL_VRAM); int ret; vmm->vram_base = vram_base; @@ -1127,7 +1127,7 @@ static int drm_vram_mm_init(struct drm_vram_mm *vmm, struct drm_device *dev, static void drm_vram_mm_cleanup(struct drm_vram_mm *vmm) { - ttm_bo_man_takedown(&vmm->bdev, &vmm->bdev.man[TTM_PL_VRAM]); + ttm_bo_man_takedown(&vmm->bdev, ttm_manager_type(&vmm->bdev, TTM_PL_VRAM)); ttm_bo_device_release(&vmm->bdev); } From patchwork Fri Jul 31 04:05:00 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Airlie X-Patchwork-Id: 11694017 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id DE0BC13B1 for ; Fri, 31 Jul 2020 04:06:54 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id C68F02070B for ; Fri, 31 Jul 2020 04:06:54 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C68F02070B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 1DB4A6E9B3; Fri, 31 Jul 2020 04:06:51 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from us-smtp-delivery-1.mimecast.com (us-smtp-2.mimecast.com [207.211.31.81]) by gabe.freedesktop.org (Postfix) with ESMTPS id 3E7C26E9B4 for ; Fri, 31 Jul 2020 04:06:41 +0000 (UTC) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-493-172UrkfuNEOAjZGiMYMtmA-1; Fri, 31 Jul 2020 00:06:34 -0400 X-MC-Unique: 172UrkfuNEOAjZGiMYMtmA-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id E552D80183C; Fri, 31 Jul 2020 04:06:32 +0000 (UTC) Received: from tyrion-bne-redhat-com.redhat.com (vpn2-54-17.bne.redhat.com [10.64.54.17]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7898D100EBA4; Fri, 31 Jul 2020 04:06:31 +0000 (UTC) From: Dave Airlie To: dri-devel@lists.freedesktop.org Subject: [PATCH 29/49] drm/nouveau/ttm: use wrapper to access memory managers Date: Fri, 31 Jul 2020 14:05:00 +1000 Message-Id: <20200731040520.3701599-30-airlied@gmail.com> In-Reply-To: <20200731040520.3701599-1-airlied@gmail.com> References: <20200731040520.3701599-1-airlied@gmail.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: gmail.com X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: christian.koenig@amd.com, sroland@vmware.com, bskeggs@redhat.com, kraxel@redhat.com Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Dave Airlie Signed-off-by: Dave Airlie --- drivers/gpu/drm/nouveau/nouveau_ttm.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/nouveau/nouveau_ttm.c b/drivers/gpu/drm/nouveau/nouveau_ttm.c index 2ccfdf203c52..ed651d7679fe 100644 --- a/drivers/gpu/drm/nouveau/nouveau_ttm.c +++ b/drivers/gpu/drm/nouveau/nouveau_ttm.c @@ -165,7 +165,7 @@ nouveau_ttm_init_host(struct nouveau_drm *drm, u8 kind) static int nouveau_ttm_init_vram(struct nouveau_drm *drm) { - struct ttm_mem_type_manager *man = &drm->ttm.bdev.man[TTM_PL_VRAM]; + struct ttm_mem_type_manager *man = ttm_manager_type(&drm->ttm.bdev, TTM_PL_VRAM); struct nvif_mmu *mmu = &drm->client.mmu; man->available_caching = TTM_PL_FLAG_UNCACHED | TTM_PL_FLAG_WC; @@ -195,7 +195,7 @@ nouveau_ttm_init_vram(struct nouveau_drm *drm) static void nouveau_ttm_fini_vram(struct nouveau_drm *drm) { - struct ttm_mem_type_manager *man = &drm->ttm.bdev.man[TTM_PL_VRAM]; + struct ttm_mem_type_manager *man = ttm_manager_type(&drm->ttm.bdev, TTM_PL_VRAM); if (drm->client.device.info.family >= NV_DEVICE_INFO_V0_TESLA) { ttm_bo_disable_mm(man); @@ -208,7 +208,7 @@ nouveau_ttm_fini_vram(struct nouveau_drm *drm) static int nouveau_ttm_init_gtt(struct nouveau_drm *drm) { - struct ttm_mem_type_manager *man = &drm->ttm.bdev.man[TTM_PL_TT]; + struct ttm_mem_type_manager *man = ttm_manager_type(&drm->ttm.bdev, TTM_PL_TT); unsigned long size_pages = drm->gem.gart_available >> PAGE_SHIFT; man->use_tt = true; if (drm->agp.bridge) { @@ -237,7 +237,7 @@ nouveau_ttm_init_gtt(struct nouveau_drm *drm) static void nouveau_ttm_fini_gtt(struct nouveau_drm *drm) { - struct ttm_mem_type_manager *man = &drm->ttm.bdev.man[TTM_PL_TT]; + struct ttm_mem_type_manager *man = ttm_manager_type(&drm->ttm.bdev, TTM_PL_TT); if (drm->client.device.info.family < NV_DEVICE_INFO_V0_TESLA && drm->agp.bridge) From patchwork Fri Jul 31 04:05:01 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Airlie X-Patchwork-Id: 11694037 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A23C214E3 for ; Fri, 31 Jul 2020 04:07:16 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 8A90B2070B for ; Fri, 31 Jul 2020 04:07:16 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8A90B2070B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 5E3F96E9BA; Fri, 31 Jul 2020 04:07:05 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from us-smtp-delivery-1.mimecast.com (us-smtp-2.mimecast.com [205.139.110.61]) by gabe.freedesktop.org (Postfix) with ESMTPS id 7EAE46E9B3 for ; Fri, 31 Jul 2020 04:06:41 +0000 (UTC) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-60-iKBsP2kSO02l74nz4Twlqg-1; Fri, 31 Jul 2020 00:06:35 -0400 X-MC-Unique: iKBsP2kSO02l74nz4Twlqg-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id BFDA957; Fri, 31 Jul 2020 04:06:34 +0000 (UTC) Received: from tyrion-bne-redhat-com.redhat.com (vpn2-54-17.bne.redhat.com [10.64.54.17]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4F338100EBA7; Fri, 31 Jul 2020 04:06:33 +0000 (UTC) From: Dave Airlie To: dri-devel@lists.freedesktop.org Subject: [PATCH 30/49] drm/qxl/ttm: use wrapper to access memory manager Date: Fri, 31 Jul 2020 14:05:01 +1000 Message-Id: <20200731040520.3701599-31-airlied@gmail.com> In-Reply-To: <20200731040520.3701599-1-airlied@gmail.com> References: <20200731040520.3701599-1-airlied@gmail.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=airlied@gmail.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: gmail.com X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: christian.koenig@amd.com, sroland@vmware.com, bskeggs@redhat.com, kraxel@redhat.com Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Dave Airlie Signed-off-by: Dave Airlie --- drivers/gpu/drm/qxl/qxl_ttm.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/gpu/drm/qxl/qxl_ttm.c b/drivers/gpu/drm/qxl/qxl_ttm.c index acc4497887a6..9aea35a66e25 100644 --- a/drivers/gpu/drm/qxl/qxl_ttm.c +++ b/drivers/gpu/drm/qxl/qxl_ttm.c @@ -219,7 +219,7 @@ static int qxl_ttm_init_mem_type(struct qxl_device *qdev, unsigned int type, uint64_t size) { - struct ttm_mem_type_manager *man = &qdev->mman.bdev.man[type]; + struct ttm_mem_type_manager *man = ttm_manager_type(&qdev->mman.bdev, type); man->available_caching = TTM_PL_MASK_CACHING; man->default_caching = TTM_PL_FLAG_CACHED; @@ -266,8 +266,8 @@ int qxl_ttm_init(struct qxl_device *qdev) void qxl_ttm_fini(struct qxl_device *qdev) { - ttm_bo_man_takedown(&qdev->mman.bdev, &qdev->mman.bdev.man[TTM_PL_VRAM]); - ttm_bo_man_takedown(&qdev->mman.bdev, &qdev->mman.bdev.man[TTM_PL_PRIV]); + ttm_bo_man_takedown(&qdev->mman.bdev, ttm_manager_type(&qdev->mman.bdev, TTM_PL_VRAM)); + ttm_bo_man_takedown(&qdev->mman.bdev, ttm_manager_type(&qdev->mman.bdev, TTM_PL_PRIV)); ttm_bo_device_release(&qdev->mman.bdev); DRM_INFO("qxl: ttm finalized\n"); } @@ -302,9 +302,9 @@ void qxl_ttm_debugfs_init(struct qxl_device *qdev) qxl_mem_types_list[i].show = &qxl_mm_dump_table; qxl_mem_types_list[i].driver_features = 0; if (i == 0) - qxl_mem_types_list[i].data = &qdev->mman.bdev.man[TTM_PL_VRAM]; + qxl_mem_types_list[i].data = ttm_manager_type(&qdev->mman.bdev, TTM_PL_VRAM); else - qxl_mem_types_list[i].data = &qdev->mman.bdev.man[TTM_PL_PRIV]; + qxl_mem_types_list[i].data = ttm_manager_type(&qdev->mman.bdev, TTM_PL_PRIV); } qxl_debugfs_add_files(qdev, qxl_mem_types_list, i); From patchwork Fri Jul 31 04:05:02 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Airlie X-Patchwork-Id: 11694023 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id CF76C13B1 for ; Fri, 31 Jul 2020 04:07:07 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id B80502070B for ; Fri, 31 Jul 2020 04:07:07 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B80502070B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 776E46E9A2; Fri, 31 Jul 2020 04:07:04 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) by gabe.freedesktop.org (Postfix) with ESMTPS id D4BA46E9A0 for ; Fri, 31 Jul 2020 04:06:47 +0000 (UTC) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-15-k0SelrAAOHGHcVd3mGDj_Q-1; Fri, 31 Jul 2020 00:06:37 -0400 X-MC-Unique: k0SelrAAOHGHcVd3mGDj_Q-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 9910A1DE0; Fri, 31 Jul 2020 04:06:36 +0000 (UTC) Received: from tyrion-bne-redhat-com.redhat.com (vpn2-54-17.bne.redhat.com [10.64.54.17]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2B8361001281; Fri, 31 Jul 2020 04:06:34 +0000 (UTC) From: Dave Airlie To: dri-devel@lists.freedesktop.org Subject: [PATCH 31/49] drm/radeon/ttm: use wrapper to access memory manager Date: Fri, 31 Jul 2020 14:05:02 +1000 Message-Id: <20200731040520.3701599-32-airlied@gmail.com> In-Reply-To: <20200731040520.3701599-1-airlied@gmail.com> References: <20200731040520.3701599-1-airlied@gmail.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: gmail.com X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: christian.koenig@amd.com, sroland@vmware.com, bskeggs@redhat.com, kraxel@redhat.com Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Dave Airlie Signed-off-by: Dave Airlie --- drivers/gpu/drm/radeon/radeon_gem.c | 2 +- drivers/gpu/drm/radeon/radeon_ttm.c | 13 ++++++------- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/drivers/gpu/drm/radeon/radeon_gem.c b/drivers/gpu/drm/radeon/radeon_gem.c index 44157ada9b0e..3ec028dba739 100644 --- a/drivers/gpu/drm/radeon/radeon_gem.c +++ b/drivers/gpu/drm/radeon/radeon_gem.c @@ -226,7 +226,7 @@ int radeon_gem_info_ioctl(struct drm_device *dev, void *data, struct drm_radeon_gem_info *args = data; struct ttm_mem_type_manager *man; - man = &rdev->mman.bdev.man[TTM_PL_VRAM]; + man = ttm_manager_type(&rdev->mman.bdev, TTM_PL_VRAM); args->vram_size = (u64)man->size << PAGE_SHIFT; args->vram_visible = rdev->mc.visible_vram_size; diff --git a/drivers/gpu/drm/radeon/radeon_ttm.c b/drivers/gpu/drm/radeon/radeon_ttm.c index e65297b4b678..3849d0e852bc 100644 --- a/drivers/gpu/drm/radeon/radeon_ttm.c +++ b/drivers/gpu/drm/radeon/radeon_ttm.c @@ -68,7 +68,7 @@ struct radeon_device *radeon_get_rdev(struct ttm_bo_device *bdev) static int radeon_ttm_init_vram(struct radeon_device *rdev) { - struct ttm_mem_type_manager *man = &rdev->mman.bdev.man[TTM_PL_VRAM]; + struct ttm_mem_type_manager *man = ttm_manager_type(&rdev->mman.bdev, TTM_PL_VRAM); man->available_caching = TTM_PL_FLAG_UNCACHED | TTM_PL_FLAG_WC; man->default_caching = TTM_PL_FLAG_WC; @@ -79,7 +79,7 @@ static int radeon_ttm_init_vram(struct radeon_device *rdev) static int radeon_ttm_init_gtt(struct radeon_device *rdev) { - struct ttm_mem_type_manager *man = &rdev->mman.bdev.man[TTM_PL_TT]; + struct ttm_mem_type_manager *man = ttm_manager_type(&rdev->mman.bdev, TTM_PL_TT); man->available_caching = TTM_PL_MASK_CACHING; man->default_caching = TTM_PL_FLAG_CACHED; @@ -379,7 +379,6 @@ static int radeon_bo_move(struct ttm_buffer_object *bo, bool evict, static int radeon_ttm_io_mem_reserve(struct ttm_bo_device *bdev, struct ttm_mem_reg *mem) { - struct ttm_mem_type_manager *man = &bdev->man[mem->mem_type]; struct radeon_device *rdev = radeon_get_rdev(bdev); mem->bus.addr = NULL; @@ -826,8 +825,8 @@ void radeon_ttm_fini(struct radeon_device *rdev) } radeon_bo_unref(&rdev->stolen_vga_memory); } - ttm_bo_man_takedown(&rdev->mman.bdev, &rdev->mman.bdev.man[TTM_PL_VRAM]); - ttm_bo_man_takedown(&rdev->mman.bdev, &rdev->mman.bdev.man[TTM_PL_TT]); + ttm_bo_man_takedown(&rdev->mman.bdev, ttm_manager_type(&rdev->mman.bdev, TTM_PL_VRAM)); + ttm_bo_man_takedown(&rdev->mman.bdev, ttm_manager_type(&rdev->mman.bdev, TTM_PL_TT)); ttm_bo_device_release(&rdev->mman.bdev); radeon_gart_fini(rdev); rdev->mman.initialized = false; @@ -843,7 +842,7 @@ void radeon_ttm_set_active_vram_size(struct radeon_device *rdev, u64 size) if (!rdev->mman.initialized) return; - man = &rdev->mman.bdev.man[TTM_PL_VRAM]; + man = ttm_manager_type(&rdev->mman.bdev, TTM_PL_VRAM); /* this just adjusts TTM size idea, which sets lpfn to the correct value */ man->size = size >> PAGE_SHIFT; } @@ -897,7 +896,7 @@ static int radeon_mm_dump_table(struct seq_file *m, void *data) unsigned ttm_pl = *(int*)node->info_ent->data; struct drm_device *dev = node->minor->dev; struct radeon_device *rdev = dev->dev_private; - struct ttm_mem_type_manager *man = &rdev->mman.bdev.man[ttm_pl]; + struct ttm_mem_type_manager *man = ttm_manager_type(&rdev->mman.bdev, ttm_pl); struct drm_printer p = drm_seq_file_printer(m); man->func->debug(man, &p); From patchwork Fri Jul 31 04:05:03 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Airlie X-Patchwork-Id: 11694021 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 90D6E14E3 for ; Fri, 31 Jul 2020 04:06:57 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 797EF2070B for ; Fri, 31 Jul 2020 04:06:57 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 797EF2070B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 36AD16E9B5; Fri, 31 Jul 2020 04:06:51 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) by gabe.freedesktop.org (Postfix) with ESMTPS id 400906E9A0 for ; Fri, 31 Jul 2020 04:06:44 +0000 (UTC) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-296-OnOBxfHQP7mazKC7ys4iFg-1; Fri, 31 Jul 2020 00:06:39 -0400 X-MC-Unique: OnOBxfHQP7mazKC7ys4iFg-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 7021F10059AC; Fri, 31 Jul 2020 04:06:38 +0000 (UTC) Received: from tyrion-bne-redhat-com.redhat.com (vpn2-54-17.bne.redhat.com [10.64.54.17]) by smtp.corp.redhat.com (Postfix) with ESMTP id 03CBF100238C; Fri, 31 Jul 2020 04:06:36 +0000 (UTC) From: Dave Airlie To: dri-devel@lists.freedesktop.org Subject: [PATCH 32/49] drm/vmwgfx/ttm: use wrapper to access memory manager Date: Fri, 31 Jul 2020 14:05:03 +1000 Message-Id: <20200731040520.3701599-33-airlied@gmail.com> In-Reply-To: <20200731040520.3701599-1-airlied@gmail.com> References: <20200731040520.3701599-1-airlied@gmail.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: gmail.com X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: christian.koenig@amd.com, sroland@vmware.com, bskeggs@redhat.com, kraxel@redhat.com Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Dave Airlie Signed-off-by: Dave Airlie --- drivers/gpu/drm/vmwgfx/vmwgfx_drv.c | 21 ++++++++++++------- drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c | 4 ++-- drivers/gpu/drm/vmwgfx/vmwgfx_thp.c | 4 ++-- 3 files changed, 17 insertions(+), 12 deletions(-) diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c index b27f8b3699cf..dff6990ff9ed 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c @@ -634,7 +634,7 @@ static int vmw_init_vram_manager(struct vmw_private *dev_priv) ret = ttm_bo_man_init(&dev_priv->bdev, man, dev_priv->vram_size >> PAGE_SHIFT); #endif - dev_priv->bdev.man[TTM_PL_VRAM].use_type = false; + ttm_manager_type(&dev_priv->bdev, TTM_PL_VRAM)->use_type = false; return ret; } @@ -644,7 +644,7 @@ static void vmw_takedown_vram_manager(struct vmw_private *dev_priv) vmw_thp_takedown(dev_priv); #else ttm_bo_man_takedown(&dev_priv->bdev, - &dev_priv->bdev.man[TTM_PL_VRAM]); + ttm_manager_type(&dev_priv->bdev, TTM_PL_VRAM)); #endif } @@ -1192,10 +1192,12 @@ static void vmw_master_drop(struct drm_device *dev, */ static void __vmw_svga_enable(struct vmw_private *dev_priv) { + struct ttm_mem_type_manager *man = ttm_manager_type(&dev_priv->bdev, TTM_PL_VRAM); + spin_lock(&dev_priv->svga_lock); - if (!dev_priv->bdev.man[TTM_PL_VRAM].use_type) { + if (!man->use_type) { vmw_write(dev_priv, SVGA_REG_ENABLE, SVGA_REG_ENABLE); - dev_priv->bdev.man[TTM_PL_VRAM].use_type = true; + man->use_type = true; } spin_unlock(&dev_priv->svga_lock); } @@ -1221,9 +1223,11 @@ void vmw_svga_enable(struct vmw_private *dev_priv) */ static void __vmw_svga_disable(struct vmw_private *dev_priv) { + struct ttm_mem_type_manager *man = ttm_manager_type(&dev_priv->bdev, TTM_PL_VRAM); + spin_lock(&dev_priv->svga_lock); - if (dev_priv->bdev.man[TTM_PL_VRAM].use_type) { - dev_priv->bdev.man[TTM_PL_VRAM].use_type = false; + if (man->use_type) { + man->use_type = false; vmw_write(dev_priv, SVGA_REG_ENABLE, SVGA_REG_ENABLE_HIDE | SVGA_REG_ENABLE_ENABLE); @@ -1240,6 +1244,7 @@ static void __vmw_svga_disable(struct vmw_private *dev_priv) */ void vmw_svga_disable(struct vmw_private *dev_priv) { + struct ttm_mem_type_manager *man = ttm_manager_type(&dev_priv->bdev, TTM_PL_VRAM); /* * Disabling SVGA will turn off device modesetting capabilities, so * notify KMS about that so that it doesn't cache atomic state that @@ -1255,8 +1260,8 @@ void vmw_svga_disable(struct vmw_private *dev_priv) vmw_kms_lost_device(dev_priv->dev); ttm_write_lock(&dev_priv->reservation_sem, false); spin_lock(&dev_priv->svga_lock); - if (dev_priv->bdev.man[TTM_PL_VRAM].use_type) { - dev_priv->bdev.man[TTM_PL_VRAM].use_type = false; + if (man->use_type) { + man->use_type = false; spin_unlock(&dev_priv->svga_lock); if (ttm_bo_evict_mm(&dev_priv->bdev, TTM_PL_VRAM)) DRM_ERROR("Failed evicting VRAM buffers.\n"); diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c b/drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c index 2522927b75da..3fa809b5e3bd 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c @@ -98,7 +98,7 @@ static const struct ttm_mem_type_manager_func vmw_gmrid_manager_func; int vmw_gmrid_man_init(struct vmw_private *dev_priv, int type) { - struct ttm_mem_type_manager *man = &dev_priv->bdev.man[type]; + struct ttm_mem_type_manager *man = ttm_manager_type(&dev_priv->bdev, type); struct vmwgfx_gmrid_man *gman = kzalloc(sizeof(*gman), GFP_KERNEL); @@ -133,7 +133,7 @@ int vmw_gmrid_man_init(struct vmw_private *dev_priv, int type) void vmw_gmrid_man_takedown(struct vmw_private *dev_priv, int type) { - struct ttm_mem_type_manager *man = &dev_priv->bdev.man[type]; + struct ttm_mem_type_manager *man = ttm_manager_type(&dev_priv->bdev, type); struct vmwgfx_gmrid_man *gman = (struct vmwgfx_gmrid_man *)man->priv; diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_thp.c b/drivers/gpu/drm/vmwgfx/vmwgfx_thp.c index 3591a93dad37..0dd619c9d207 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_thp.c +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_thp.c @@ -117,7 +117,7 @@ static void vmw_thp_put_node(struct ttm_mem_type_manager *man, int vmw_thp_init(struct vmw_private *dev_priv) { - struct ttm_mem_type_manager *man = &dev_priv->bdev.man[TTM_PL_VRAM]; + struct ttm_mem_type_manager *man = ttm_manager_type(&dev_priv->bdev, TTM_PL_VRAM); struct vmw_thp_manager *rman; man->available_caching = TTM_PL_FLAG_CACHED; man->default_caching = TTM_PL_FLAG_CACHED; @@ -137,7 +137,7 @@ int vmw_thp_init(struct vmw_private *dev_priv) void vmw_thp_takedown(struct vmw_private *dev_priv) { - struct ttm_mem_type_manager *man = &dev_priv->bdev.man[TTM_PL_VRAM]; + struct ttm_mem_type_manager *man = ttm_manager_type(&dev_priv->bdev, TTM_PL_VRAM); struct vmw_thp_manager *rman = (struct vmw_thp_manager *) man->priv; struct drm_mm *mm = &rman->mm; int ret; From patchwork Fri Jul 31 04:05:04 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Airlie X-Patchwork-Id: 11694015 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B21C213B1 for ; Fri, 31 Jul 2020 04:06:53 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 9B6AF2070B for ; Fri, 31 Jul 2020 04:06:53 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9B6AF2070B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 23CB26E9B4; Fri, 31 Jul 2020 04:06:51 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) by gabe.freedesktop.org (Postfix) with ESMTPS id 8EB366E9B2 for ; Fri, 31 Jul 2020 04:06:44 +0000 (UTC) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-282-AJHOuCGbPoeUTfdc7WELGg-1; Fri, 31 Jul 2020 00:06:41 -0400 X-MC-Unique: AJHOuCGbPoeUTfdc7WELGg-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 4BBB4800471; Fri, 31 Jul 2020 04:06:40 +0000 (UTC) Received: from tyrion-bne-redhat-com.redhat.com (vpn2-54-17.bne.redhat.com [10.64.54.17]) by smtp.corp.redhat.com (Postfix) with ESMTP id CFDD71001281; Fri, 31 Jul 2020 04:06:38 +0000 (UTC) From: Dave Airlie To: dri-devel@lists.freedesktop.org Subject: [PATCH 33/49] drm/ttm: rename manager variable to make sure wrapper is used. Date: Fri, 31 Jul 2020 14:05:04 +1000 Message-Id: <20200731040520.3701599-34-airlied@gmail.com> In-Reply-To: <20200731040520.3701599-1-airlied@gmail.com> References: <20200731040520.3701599-1-airlied@gmail.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: gmail.com X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: christian.koenig@amd.com, sroland@vmware.com, bskeggs@redhat.com, kraxel@redhat.com Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Dave Airlie Other users of this should notice this change and switch to wrapper. Signed-off-by: Dave Airlie --- drivers/gpu/drm/ttm/ttm_bo.c | 2 +- include/drm/ttm/ttm_bo_driver.h | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c index 7c6389ea067f..92de8a6d7647 100644 --- a/drivers/gpu/drm/ttm/ttm_bo.c +++ b/drivers/gpu/drm/ttm/ttm_bo.c @@ -1610,7 +1610,7 @@ int ttm_bo_device_init(struct ttm_bo_device *bdev, bdev->driver = driver; - memset(bdev->man, 0, sizeof(bdev->man)); + memset(bdev->man_priv, 0, sizeof(bdev->man_priv)); ttm_bo_init_sysman(bdev); diff --git a/include/drm/ttm/ttm_bo_driver.h b/include/drm/ttm/ttm_bo_driver.h index ec25451b503f..419b088253cf 100644 --- a/include/drm/ttm/ttm_bo_driver.h +++ b/include/drm/ttm/ttm_bo_driver.h @@ -415,7 +415,10 @@ struct ttm_bo_device { */ struct list_head device_list; struct ttm_bo_driver *driver; - struct ttm_mem_type_manager man[TTM_NUM_MEM_TYPES]; + /* + * access via ttm_manager_type. + */ + struct ttm_mem_type_manager man_priv[TTM_NUM_MEM_TYPES]; /* * Protected by internal locks. @@ -447,7 +450,7 @@ struct ttm_bo_device { static inline struct ttm_mem_type_manager *ttm_manager_type(struct ttm_bo_device *bdev, int mem_type) { - return &bdev->man[mem_type]; + return &bdev->man_priv[mem_type]; } /** From patchwork Fri Jul 31 04:05:05 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Dave Airlie X-Patchwork-Id: 11694013 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5D74313B1 for ; Fri, 31 Jul 2020 04:06:52 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 465C92070B for ; Fri, 31 Jul 2020 04:06:52 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 465C92070B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id DCC666E9A0; Fri, 31 Jul 2020 04:06:50 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from us-smtp-delivery-1.mimecast.com (us-smtp-2.mimecast.com [205.139.110.61]) by gabe.freedesktop.org (Postfix) with ESMTPS id 33EFB6E9A0 for ; Fri, 31 Jul 2020 04:06:50 +0000 (UTC) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-314-Pr__o9t0Pe2ko5GU9iVI0Q-1; Fri, 31 Jul 2020 00:06:43 -0400 X-MC-Unique: Pr__o9t0Pe2ko5GU9iVI0Q-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 24805800685; Fri, 31 Jul 2020 04:06:42 +0000 (UTC) Received: from tyrion-bne-redhat-com.redhat.com (vpn2-54-17.bne.redhat.com [10.64.54.17]) by smtp.corp.redhat.com (Postfix) with ESMTP id AAFFD100238C; Fri, 31 Jul 2020 04:06:40 +0000 (UTC) From: Dave Airlie To: dri-devel@lists.freedesktop.org Subject: [PATCH 34/49] drm/ttm: make manager debug function optional Date: Fri, 31 Jul 2020 14:05:05 +1000 Message-Id: <20200731040520.3701599-35-airlied@gmail.com> In-Reply-To: <20200731040520.3701599-1-airlied@gmail.com> References: <20200731040520.3701599-1-airlied@gmail.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: gmail.com X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: christian.koenig@amd.com, sroland@vmware.com, bskeggs@redhat.com, kraxel@redhat.com Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Dave Airlie Signed-off-by: Dave Airlie Reviewed-by: Christian König --- drivers/gpu/drm/ttm/ttm_bo.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c index 92de8a6d7647..1e8fda1c9b3a 100644 --- a/drivers/gpu/drm/ttm/ttm_bo.c +++ b/drivers/gpu/drm/ttm/ttm_bo.c @@ -88,7 +88,7 @@ static void ttm_mem_type_debug(struct ttm_bo_device *bdev, struct drm_printer *p drm_printf(p, " size: %llu\n", man->size); drm_printf(p, " available_caching: 0x%08X\n", man->available_caching); drm_printf(p, " default_caching: 0x%08X\n", man->default_caching); - if (mem_type != TTM_PL_SYSTEM) + if (mem_type != TTM_PL_SYSTEM && man->func->debug) (*man->func->debug)(man, p); } From patchwork Fri Jul 31 04:05:06 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Dave Airlie X-Patchwork-Id: 11694025 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C899E13B1 for ; Fri, 31 Jul 2020 04:07:08 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id B15E92070B for ; Fri, 31 Jul 2020 04:07:08 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B15E92070B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 8643E6E9AD; Fri, 31 Jul 2020 04:07:04 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from us-smtp-delivery-1.mimecast.com (us-smtp-2.mimecast.com [207.211.31.81]) by gabe.freedesktop.org (Postfix) with ESMTPS id 37B4E6E9A2 for ; Fri, 31 Jul 2020 04:06:55 +0000 (UTC) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-189-dNmFyYFHNuqlQJq1MHcY2w-1; Fri, 31 Jul 2020 00:06:47 -0400 X-MC-Unique: dNmFyYFHNuqlQJq1MHcY2w-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id BA22410059A7; Fri, 31 Jul 2020 04:06:46 +0000 (UTC) Received: from tyrion-bne-redhat-com.redhat.com (vpn2-54-17.bne.redhat.com [10.64.54.17]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8389D100238C; Fri, 31 Jul 2020 04:06:42 +0000 (UTC) From: Dave Airlie To: dri-devel@lists.freedesktop.org Subject: [PATCH 35/49] drm/nouveau/ttm: don't fill in blank ttm debug callback Date: Fri, 31 Jul 2020 14:05:06 +1000 Message-Id: <20200731040520.3701599-36-airlied@gmail.com> In-Reply-To: <20200731040520.3701599-1-airlied@gmail.com> References: <20200731040520.3701599-1-airlied@gmail.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: gmail.com X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: christian.koenig@amd.com, sroland@vmware.com, bskeggs@redhat.com, kraxel@redhat.com Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Dave Airlie Signed-off-by: Dave Airlie Acked-by: Christian König --- drivers/gpu/drm/nouveau/nouveau_ttm.c | 9 --------- 1 file changed, 9 deletions(-) diff --git a/drivers/gpu/drm/nouveau/nouveau_ttm.c b/drivers/gpu/drm/nouveau/nouveau_ttm.c index ed651d7679fe..1b9d9362132d 100644 --- a/drivers/gpu/drm/nouveau/nouveau_ttm.c +++ b/drivers/gpu/drm/nouveau/nouveau_ttm.c @@ -37,12 +37,6 @@ nouveau_manager_del(struct ttm_mem_type_manager *man, struct ttm_mem_reg *reg) nouveau_mem_del(reg); } -static void -nouveau_manager_debug(struct ttm_mem_type_manager *man, - struct drm_printer *printer) -{ -} - static int nouveau_vram_manager_new(struct ttm_mem_type_manager *man, struct ttm_buffer_object *bo, @@ -72,7 +66,6 @@ nouveau_vram_manager_new(struct ttm_mem_type_manager *man, const struct ttm_mem_type_manager_func nouveau_vram_manager = { .get_node = nouveau_vram_manager_new, .put_node = nouveau_manager_del, - .debug = nouveau_manager_debug, }; static int @@ -96,7 +89,6 @@ nouveau_gart_manager_new(struct ttm_mem_type_manager *man, const struct ttm_mem_type_manager_func nouveau_gart_manager = { .get_node = nouveau_gart_manager_new, .put_node = nouveau_manager_del, - .debug = nouveau_manager_debug }; static int @@ -129,7 +121,6 @@ nv04_gart_manager_new(struct ttm_mem_type_manager *man, const struct ttm_mem_type_manager_func nv04_gart_manager = { .get_node = nv04_gart_manager_new, .put_node = nouveau_manager_del, - .debug = nouveau_manager_debug }; int From patchwork Fri Jul 31 04:05:07 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Dave Airlie X-Patchwork-Id: 11694039 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E2FFE14E3 for ; Fri, 31 Jul 2020 04:07:17 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id CB9982070B for ; Fri, 31 Jul 2020 04:07:17 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org CB9982070B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 22B746E9C4; Fri, 31 Jul 2020 04:07:06 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from us-smtp-delivery-1.mimecast.com (us-smtp-2.mimecast.com [205.139.110.61]) by gabe.freedesktop.org (Postfix) with ESMTPS id E7EEB6E9B6 for ; Fri, 31 Jul 2020 04:06:52 +0000 (UTC) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-342-72kcxMW7P7KJahouoGPgXQ-1; Fri, 31 Jul 2020 00:06:49 -0400 X-MC-Unique: 72kcxMW7P7KJahouoGPgXQ-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 93A25106B243; Fri, 31 Jul 2020 04:06:48 +0000 (UTC) Received: from tyrion-bne-redhat-com.redhat.com (vpn2-54-17.bne.redhat.com [10.64.54.17]) by smtp.corp.redhat.com (Postfix) with ESMTP id 255901001281; Fri, 31 Jul 2020 04:06:46 +0000 (UTC) From: Dave Airlie To: dri-devel@lists.freedesktop.org Subject: [PATCH 36/49] drm/vmwgfx/gmrid: don't provide pointless ttm debug callback Date: Fri, 31 Jul 2020 14:05:07 +1000 Message-Id: <20200731040520.3701599-37-airlied@gmail.com> In-Reply-To: <20200731040520.3701599-1-airlied@gmail.com> References: <20200731040520.3701599-1-airlied@gmail.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: gmail.com X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: christian.koenig@amd.com, sroland@vmware.com, bskeggs@redhat.com, kraxel@redhat.com Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Dave Airlie Signed-off-by: Dave Airlie Acked-by: Christian König --- drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c | 7 ------- 1 file changed, 7 deletions(-) diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c b/drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c index 3fa809b5e3bd..2db99f0449b0 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c @@ -149,14 +149,7 @@ void vmw_gmrid_man_takedown(struct vmw_private *dev_priv, int type) ttm_bo_man_cleanup(man); } -static void vmw_gmrid_man_debug(struct ttm_mem_type_manager *man, - struct drm_printer *printer) -{ - drm_printf(printer, "No debug info available for the GMR id manager\n"); -} - static const struct ttm_mem_type_manager_func vmw_gmrid_manager_func = { .get_node = vmw_gmrid_man_get_node, .put_node = vmw_gmrid_man_put_node, - .debug = vmw_gmrid_man_debug }; From patchwork Fri Jul 31 04:05:08 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Airlie X-Patchwork-Id: 11694035 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 62C4113B1 for ; Fri, 31 Jul 2020 04:07:15 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 4B616208E4 for ; Fri, 31 Jul 2020 04:07:15 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4B616208E4 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 4ADEC6E9B9; Fri, 31 Jul 2020 04:07:05 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from us-smtp-delivery-1.mimecast.com (us-smtp-2.mimecast.com [205.139.110.61]) by gabe.freedesktop.org (Postfix) with ESMTPS id B27F66E9B6 for ; Fri, 31 Jul 2020 04:06:55 +0000 (UTC) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-440-exeAjFD4Mvmr6vOA8w0wkQ-1; Fri, 31 Jul 2020 00:06:51 -0400 X-MC-Unique: exeAjFD4Mvmr6vOA8w0wkQ-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 6EDCB107ACCA; Fri, 31 Jul 2020 04:06:50 +0000 (UTC) Received: from tyrion-bne-redhat-com.redhat.com (vpn2-54-17.bne.redhat.com [10.64.54.17]) by smtp.corp.redhat.com (Postfix) with ESMTP id F28ED100238C; Fri, 31 Jul 2020 04:06:48 +0000 (UTC) From: Dave Airlie To: dri-devel@lists.freedesktop.org Subject: [PATCH 37/49] drm/ttm: allow drivers to provide their own manager subclasses Date: Fri, 31 Jul 2020 14:05:08 +1000 Message-Id: <20200731040520.3701599-38-airlied@gmail.com> In-Reply-To: <20200731040520.3701599-1-airlied@gmail.com> References: <20200731040520.3701599-1-airlied@gmail.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: gmail.com X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: christian.koenig@amd.com, sroland@vmware.com, bskeggs@redhat.com, kraxel@redhat.com Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Dave Airlie This will get removed eventually and all drivers will use this. Signed-off-by: Dave Airlie --- include/drm/ttm/ttm_bo_driver.h | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/include/drm/ttm/ttm_bo_driver.h b/include/drm/ttm/ttm_bo_driver.h index 419b088253cf..723171fd94da 100644 --- a/include/drm/ttm/ttm_bo_driver.h +++ b/include/drm/ttm/ttm_bo_driver.h @@ -419,7 +419,7 @@ struct ttm_bo_device { * access via ttm_manager_type. */ struct ttm_mem_type_manager man_priv[TTM_NUM_MEM_TYPES]; - + struct ttm_mem_type_manager *man_drv[TTM_NUM_MEM_TYPES]; /* * Protected by internal locks. */ @@ -450,9 +450,18 @@ struct ttm_bo_device { static inline struct ttm_mem_type_manager *ttm_manager_type(struct ttm_bo_device *bdev, int mem_type) { + if (bdev->man_drv[mem_type]) + return bdev->man_drv[mem_type]; return &bdev->man_priv[mem_type]; } +static inline void ttm_set_driver_manager(struct ttm_bo_device *bdev, + int type, + struct ttm_mem_type_manager *manager) +{ + bdev->man_drv[type] = manager; +} + /** * struct ttm_lru_bulk_move_pos * From patchwork Fri Jul 31 04:05:09 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Dave Airlie X-Patchwork-Id: 11694031 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id BE13B13B1 for ; Fri, 31 Jul 2020 04:07:12 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id A6D422070B for ; Fri, 31 Jul 2020 04:07:12 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A6D422070B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 424C46E9B8; Fri, 31 Jul 2020 04:07:05 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) by gabe.freedesktop.org (Postfix) with ESMTPS id 522836E9A2 for ; Fri, 31 Jul 2020 04:06:57 +0000 (UTC) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-466-fIs5qz0vMjCzyXdYZUvsVg-1; Fri, 31 Jul 2020 00:06:53 -0400 X-MC-Unique: fIs5qz0vMjCzyXdYZUvsVg-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 47AE818839C1; Fri, 31 Jul 2020 04:06:52 +0000 (UTC) Received: from tyrion-bne-redhat-com.redhat.com (vpn2-54-17.bne.redhat.com [10.64.54.17]) by smtp.corp.redhat.com (Postfix) with ESMTP id CE3D4100238C; Fri, 31 Jul 2020 04:06:50 +0000 (UTC) From: Dave Airlie To: dri-devel@lists.freedesktop.org Subject: [PATCH 38/49] drm/amdgpu/ttm: use bo manager subclassing for vram/gtt mgrs Date: Fri, 31 Jul 2020 14:05:09 +1000 Message-Id: <20200731040520.3701599-39-airlied@gmail.com> In-Reply-To: <20200731040520.3701599-1-airlied@gmail.com> References: <20200731040520.3701599-1-airlied@gmail.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: gmail.com X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: christian.koenig@amd.com, sroland@vmware.com, bskeggs@redhat.com, kraxel@redhat.com Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Dave Airlie Signed-off-by: Dave Airlie Reviewed-by: Christian König --- drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c | 35 +++++++++++-------- drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c | 36 +++++++++++++------- 2 files changed, 44 insertions(+), 27 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c index 0b0d09d19b4f..83d88ee73468 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c @@ -25,11 +25,17 @@ #include "amdgpu.h" struct amdgpu_gtt_mgr { + struct ttm_mem_type_manager manager; struct drm_mm mm; spinlock_t lock; atomic64_t available; }; +static inline struct amdgpu_gtt_mgr *to_gtt_mgr(struct ttm_mem_type_manager *man) +{ + return container_of(man, struct amdgpu_gtt_mgr, manager); +} + struct amdgpu_gtt_node { struct drm_mm_node node; struct ttm_buffer_object *tbo; @@ -87,11 +93,16 @@ static const struct ttm_mem_type_manager_func amdgpu_gtt_mgr_func; */ int amdgpu_gtt_mgr_init(struct amdgpu_device *adev, uint64_t gtt_size) { - struct ttm_mem_type_manager *man = ttm_manager_type(&adev->mman.bdev, TTM_PL_TT); + struct ttm_mem_type_manager *man; struct amdgpu_gtt_mgr *mgr; uint64_t start, size; int ret; + mgr = kzalloc(sizeof(*mgr), GFP_KERNEL); + if (!mgr) + return -ENOMEM; + + man = &mgr->manager; man->use_tt = true; man->func = &amdgpu_gtt_mgr_func; man->available_caching = TTM_PL_MASK_CACHING; @@ -99,16 +110,11 @@ int amdgpu_gtt_mgr_init(struct amdgpu_device *adev, uint64_t gtt_size) ttm_bo_init_mm_base(&adev->mman.bdev, man, gtt_size >> PAGE_SHIFT); - mgr = kzalloc(sizeof(*mgr), GFP_KERNEL); - if (!mgr) - return -ENOMEM; - start = AMDGPU_GTT_MAX_TRANSFER_SIZE * AMDGPU_GTT_NUM_TRANSFER_WINDOWS; size = (adev->gmc.gart_size >> PAGE_SHIFT) - start; drm_mm_init(&mgr->mm, start, size); spin_lock_init(&mgr->lock); atomic64_set(&mgr->available, gtt_size >> PAGE_SHIFT); - man->priv = mgr; ret = device_create_file(adev->dev, &dev_attr_mem_info_gtt_total); if (ret) { @@ -121,6 +127,7 @@ int amdgpu_gtt_mgr_init(struct amdgpu_device *adev, uint64_t gtt_size) return ret; } + ttm_set_driver_manager(&adev->mman.bdev, TTM_PL_TT, &mgr->manager); ttm_bo_use_mm(man); return 0; } @@ -136,7 +143,7 @@ int amdgpu_gtt_mgr_init(struct amdgpu_device *adev, uint64_t gtt_size) void amdgpu_gtt_mgr_fini(struct amdgpu_device *adev) { struct ttm_mem_type_manager *man = ttm_manager_type(&adev->mman.bdev, TTM_PL_TT); - struct amdgpu_gtt_mgr *mgr = man->priv; + struct amdgpu_gtt_mgr *mgr = to_gtt_mgr(man); int ret; ttm_bo_disable_mm(man); @@ -148,13 +155,13 @@ void amdgpu_gtt_mgr_fini(struct amdgpu_device *adev) spin_lock(&mgr->lock); drm_mm_takedown(&mgr->mm); spin_unlock(&mgr->lock); - kfree(mgr); - man->priv = NULL; device_remove_file(adev->dev, &dev_attr_mem_info_gtt_total); device_remove_file(adev->dev, &dev_attr_mem_info_gtt_used); ttm_bo_man_cleanup(man); + ttm_set_driver_manager(&adev->mman.bdev, TTM_PL_TT, NULL); + kfree(mgr); } /** @@ -184,7 +191,7 @@ static int amdgpu_gtt_mgr_new(struct ttm_mem_type_manager *man, const struct ttm_place *place, struct ttm_mem_reg *mem) { - struct amdgpu_gtt_mgr *mgr = man->priv; + struct amdgpu_gtt_mgr *mgr = to_gtt_mgr(man); struct amdgpu_gtt_node *node; int r; @@ -245,7 +252,7 @@ static int amdgpu_gtt_mgr_new(struct ttm_mem_type_manager *man, static void amdgpu_gtt_mgr_del(struct ttm_mem_type_manager *man, struct ttm_mem_reg *mem) { - struct amdgpu_gtt_mgr *mgr = man->priv; + struct amdgpu_gtt_mgr *mgr = to_gtt_mgr(man); struct amdgpu_gtt_node *node = mem->mm_node; if (node) { @@ -267,7 +274,7 @@ static void amdgpu_gtt_mgr_del(struct ttm_mem_type_manager *man, */ uint64_t amdgpu_gtt_mgr_usage(struct ttm_mem_type_manager *man) { - struct amdgpu_gtt_mgr *mgr = man->priv; + struct amdgpu_gtt_mgr *mgr = to_gtt_mgr(man); s64 result = man->size - atomic64_read(&mgr->available); return (result > 0 ? result : 0) * PAGE_SIZE; @@ -275,7 +282,7 @@ uint64_t amdgpu_gtt_mgr_usage(struct ttm_mem_type_manager *man) int amdgpu_gtt_mgr_recover(struct ttm_mem_type_manager *man) { - struct amdgpu_gtt_mgr *mgr = man->priv; + struct amdgpu_gtt_mgr *mgr = to_gtt_mgr(man); struct amdgpu_gtt_node *node; struct drm_mm_node *mm_node; int r = 0; @@ -303,7 +310,7 @@ int amdgpu_gtt_mgr_recover(struct ttm_mem_type_manager *man) static void amdgpu_gtt_mgr_debug(struct ttm_mem_type_manager *man, struct drm_printer *printer) { - struct amdgpu_gtt_mgr *mgr = man->priv; + struct amdgpu_gtt_mgr *mgr = to_gtt_mgr(man); spin_lock(&mgr->lock); drm_mm_print(&mgr->mm, printer); diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c index d33a750e07a8..9d4a13926b8c 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c @@ -29,12 +29,18 @@ #include "atom.h" struct amdgpu_vram_mgr { + struct ttm_mem_type_manager manager; struct drm_mm mm; spinlock_t lock; atomic64_t usage; atomic64_t vis_usage; }; +static inline struct amdgpu_vram_mgr *to_vram_mgr(struct ttm_mem_type_manager *man) +{ + return container_of(man, struct amdgpu_vram_mgr, manager); +} + /** * DOC: mem_info_vram_total * @@ -170,29 +176,32 @@ static const struct ttm_mem_type_manager_func amdgpu_vram_mgr_func; */ int amdgpu_vram_mgr_init(struct amdgpu_device *adev) { - struct ttm_mem_type_manager *man = ttm_manager_type(&adev->mman.bdev, TTM_PL_VRAM); + struct ttm_mem_type_manager *man; struct amdgpu_vram_mgr *mgr; int ret; + mgr = kzalloc(sizeof(*mgr), GFP_KERNEL); + if (!mgr) + return -ENOMEM; + + man = &mgr->manager; + man->available_caching = TTM_PL_FLAG_UNCACHED | TTM_PL_FLAG_WC; man->default_caching = TTM_PL_FLAG_WC; ttm_bo_init_mm_base(&adev->mman.bdev, man, adev->gmc.real_vram_size >> PAGE_SHIFT); man->func = &amdgpu_vram_mgr_func; - mgr = kzalloc(sizeof(*mgr), GFP_KERNEL); - if (!mgr) - return -ENOMEM; drm_mm_init(&mgr->mm, 0, man->size); spin_lock_init(&mgr->lock); - man->priv = mgr; /* Add the two VRAM-related sysfs files */ ret = sysfs_create_files(&adev->dev->kobj, amdgpu_vram_mgr_attributes); if (ret) DRM_ERROR("Failed to register sysfs\n"); + ttm_set_driver_manager(&adev->mman.bdev, TTM_PL_VRAM, &mgr->manager); ttm_bo_use_mm(man); return 0; } @@ -208,7 +217,7 @@ int amdgpu_vram_mgr_init(struct amdgpu_device *adev) void amdgpu_vram_mgr_fini(struct amdgpu_device *adev) { struct ttm_mem_type_manager *man = ttm_manager_type(&adev->mman.bdev, TTM_PL_VRAM); - struct amdgpu_vram_mgr *mgr = man->priv; + struct amdgpu_vram_mgr *mgr = to_vram_mgr(man); int ret; ttm_bo_disable_mm(man); @@ -220,11 +229,12 @@ void amdgpu_vram_mgr_fini(struct amdgpu_device *adev) spin_lock(&mgr->lock); drm_mm_takedown(&mgr->mm); spin_unlock(&mgr->lock); - kfree(mgr); - man->priv = NULL; + sysfs_remove_files(&adev->dev->kobj, amdgpu_vram_mgr_attributes); ttm_bo_man_cleanup(man); + ttm_set_driver_manager(&adev->mman.bdev, TTM_PL_VRAM, NULL); + kfree(mgr); } /** @@ -314,7 +324,7 @@ static int amdgpu_vram_mgr_new(struct ttm_mem_type_manager *man, struct ttm_mem_reg *mem) { struct amdgpu_device *adev = amdgpu_ttm_adev(man->bdev); - struct amdgpu_vram_mgr *mgr = man->priv; + struct amdgpu_vram_mgr *mgr = to_vram_mgr(man); struct drm_mm *mm = &mgr->mm; struct drm_mm_node *nodes; enum drm_mm_insert_mode mode; @@ -430,7 +440,7 @@ static void amdgpu_vram_mgr_del(struct ttm_mem_type_manager *man, struct ttm_mem_reg *mem) { struct amdgpu_device *adev = amdgpu_ttm_adev(man->bdev); - struct amdgpu_vram_mgr *mgr = man->priv; + struct amdgpu_vram_mgr *mgr = to_vram_mgr(man); struct drm_mm_node *nodes = mem->mm_node; uint64_t usage = 0, vis_usage = 0; unsigned pages = mem->num_pages; @@ -562,7 +572,7 @@ void amdgpu_vram_mgr_free_sgt(struct amdgpu_device *adev, */ uint64_t amdgpu_vram_mgr_usage(struct ttm_mem_type_manager *man) { - struct amdgpu_vram_mgr *mgr = man->priv; + struct amdgpu_vram_mgr *mgr = to_vram_mgr(man); return atomic64_read(&mgr->usage); } @@ -576,7 +586,7 @@ uint64_t amdgpu_vram_mgr_usage(struct ttm_mem_type_manager *man) */ uint64_t amdgpu_vram_mgr_vis_usage(struct ttm_mem_type_manager *man) { - struct amdgpu_vram_mgr *mgr = man->priv; + struct amdgpu_vram_mgr *mgr = to_vram_mgr(man); return atomic64_read(&mgr->vis_usage); } @@ -592,7 +602,7 @@ uint64_t amdgpu_vram_mgr_vis_usage(struct ttm_mem_type_manager *man) static void amdgpu_vram_mgr_debug(struct ttm_mem_type_manager *man, struct drm_printer *printer) { - struct amdgpu_vram_mgr *mgr = man->priv; + struct amdgpu_vram_mgr *mgr = to_vram_mgr(man); spin_lock(&mgr->lock); drm_mm_print(&mgr->mm, printer); From patchwork Fri Jul 31 04:05:10 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Airlie X-Patchwork-Id: 11694033 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 16E2814E3 for ; Fri, 31 Jul 2020 04:07:14 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id F28B0208E4 for ; Fri, 31 Jul 2020 04:07:13 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org F28B0208E4 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 665F86E9BB; Fri, 31 Jul 2020 04:07:05 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from us-smtp-delivery-1.mimecast.com (us-smtp-2.mimecast.com [205.139.110.61]) by gabe.freedesktop.org (Postfix) with ESMTPS id 5EDB76E9A2 for ; Fri, 31 Jul 2020 04:07:00 +0000 (UTC) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-436-wJMYTG9yMbuUv8VtoxVUiQ-1; Fri, 31 Jul 2020 00:06:55 -0400 X-MC-Unique: wJMYTG9yMbuUv8VtoxVUiQ-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 1F7F480183C; Fri, 31 Jul 2020 04:06:54 +0000 (UTC) Received: from tyrion-bne-redhat-com.redhat.com (vpn2-54-17.bne.redhat.com [10.64.54.17]) by smtp.corp.redhat.com (Postfix) with ESMTP id A75971001281; Fri, 31 Jul 2020 04:06:52 +0000 (UTC) From: Dave Airlie To: dri-devel@lists.freedesktop.org Subject: [PATCH 39/49] drm/ttm: make ttm_bo_man_init/takedown take type + args Date: Fri, 31 Jul 2020 14:05:10 +1000 Message-Id: <20200731040520.3701599-40-airlied@gmail.com> In-Reply-To: <20200731040520.3701599-1-airlied@gmail.com> References: <20200731040520.3701599-1-airlied@gmail.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: gmail.com X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: christian.koenig@amd.com, sroland@vmware.com, bskeggs@redhat.com, kraxel@redhat.com Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Dave Airlie This makes it easier to move these to a driver allocated system Signed-off-by: Dave Airlie --- drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 15 +++++------ drivers/gpu/drm/drm_gem_vram_helper.c | 10 ++++---- drivers/gpu/drm/nouveau/nouveau_ttm.c | 21 ++++++++++------ drivers/gpu/drm/qxl/qxl_ttm.c | 12 +++------ drivers/gpu/drm/radeon/radeon_ttm.c | 33 ++++++++++++------------- drivers/gpu/drm/ttm/ttm_bo_manager.c | 19 ++++++++++---- drivers/gpu/drm/vmwgfx/vmwgfx_drv.c | 13 +++------- include/drm/ttm/ttm_bo_driver.h | 7 ++++-- 8 files changed, 67 insertions(+), 63 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c index 4beec1c4e037..d4d81f808b01 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c @@ -67,12 +67,9 @@ static int amdgpu_ttm_init_on_chip(struct amdgpu_device *adev, unsigned int type, uint64_t size) { - struct ttm_mem_type_manager *man = ttm_manager_type(&adev->mman.bdev, type); - - man->available_caching = TTM_PL_FLAG_UNCACHED; - man->default_caching = TTM_PL_FLAG_UNCACHED; - - return ttm_bo_man_init(&adev->mman.bdev, man, size >> PAGE_SHIFT); + return ttm_bo_man_init(&adev->mman.bdev, type, + TTM_PL_FLAG_UNCACHED, TTM_PL_FLAG_UNCACHED, + false, size >> PAGE_SHIFT); } /** @@ -2014,9 +2011,9 @@ void amdgpu_ttm_fini(struct amdgpu_device *adev) amdgpu_vram_mgr_fini(adev); amdgpu_gtt_mgr_fini(adev); - ttm_bo_man_takedown(&adev->mman.bdev, ttm_manager_type(&adev->mman.bdev, AMDGPU_PL_GDS)); - ttm_bo_man_takedown(&adev->mman.bdev, ttm_manager_type(&adev->mman.bdev, AMDGPU_PL_GWS)); - ttm_bo_man_takedown(&adev->mman.bdev, ttm_manager_type(&adev->mman.bdev, AMDGPU_PL_OA)); + ttm_bo_man_takedown(&adev->mman.bdev, AMDGPU_PL_GDS); + ttm_bo_man_takedown(&adev->mman.bdev, AMDGPU_PL_GWS); + ttm_bo_man_takedown(&adev->mman.bdev, AMDGPU_PL_OA); ttm_bo_device_release(&adev->mman.bdev); adev->mman.initialized = false; DRM_INFO("amdgpu: ttm finalized\n"); diff --git a/drivers/gpu/drm/drm_gem_vram_helper.c b/drivers/gpu/drm/drm_gem_vram_helper.c index 08fbfa32540a..b98af8daa540 100644 --- a/drivers/gpu/drm/drm_gem_vram_helper.c +++ b/drivers/gpu/drm/drm_gem_vram_helper.c @@ -1103,7 +1103,6 @@ EXPORT_SYMBOL(drm_vram_mm_debugfs_init); static int drm_vram_mm_init(struct drm_vram_mm *vmm, struct drm_device *dev, uint64_t vram_base, size_t vram_size) { - struct ttm_mem_type_manager *man = ttm_manager_type(&vmm->bdev, TTM_PL_VRAM); int ret; vmm->vram_base = vram_base; @@ -1116,9 +1115,10 @@ static int drm_vram_mm_init(struct drm_vram_mm *vmm, struct drm_device *dev, if (ret) return ret; - man->available_caching = TTM_PL_FLAG_UNCACHED | TTM_PL_FLAG_WC; - man->default_caching = TTM_PL_FLAG_WC; - ret = ttm_bo_man_init(&vmm->bdev, man, vram_size >> PAGE_SHIFT); + ret = ttm_bo_man_init(&vmm->bdev, TTM_PL_VRAM, + TTM_PL_FLAG_UNCACHED | TTM_PL_FLAG_WC, + TTM_PL_FLAG_WC, false, + vram_size >> PAGE_SHIFT); if (ret) return ret; @@ -1127,7 +1127,7 @@ static int drm_vram_mm_init(struct drm_vram_mm *vmm, struct drm_device *dev, static void drm_vram_mm_cleanup(struct drm_vram_mm *vmm) { - ttm_bo_man_takedown(&vmm->bdev, ttm_manager_type(&vmm->bdev, TTM_PL_VRAM)); + ttm_bo_man_takedown(&vmm->bdev, TTM_PL_VRAM); ttm_bo_device_release(&vmm->bdev); } diff --git a/drivers/gpu/drm/nouveau/nouveau_ttm.c b/drivers/gpu/drm/nouveau/nouveau_ttm.c index 1b9d9362132d..225f9af2eaa1 100644 --- a/drivers/gpu/drm/nouveau/nouveau_ttm.c +++ b/drivers/gpu/drm/nouveau/nouveau_ttm.c @@ -156,16 +156,17 @@ nouveau_ttm_init_host(struct nouveau_drm *drm, u8 kind) static int nouveau_ttm_init_vram(struct nouveau_drm *drm) { - struct ttm_mem_type_manager *man = ttm_manager_type(&drm->ttm.bdev, TTM_PL_VRAM); struct nvif_mmu *mmu = &drm->client.mmu; - man->available_caching = TTM_PL_FLAG_UNCACHED | TTM_PL_FLAG_WC; - man->default_caching = TTM_PL_FLAG_WC; - if (drm->client.device.info.family >= NV_DEVICE_INFO_V0_TESLA) { + struct ttm_mem_type_manager *man = ttm_manager_type(&drm->ttm.bdev, TTM_PL_VRAM); + /* Some BARs do not support being ioremapped WC */ const u8 type = mmu->type[drm->ttm.type_vram].type; + man->available_caching = TTM_PL_FLAG_UNCACHED | TTM_PL_FLAG_WC; + man->default_caching = TTM_PL_FLAG_WC; + if (type & NVIF_MEM_UNCACHED) { man->available_caching = TTM_PL_FLAG_UNCACHED; man->default_caching = TTM_PL_FLAG_UNCACHED; @@ -178,7 +179,9 @@ nouveau_ttm_init_vram(struct nouveau_drm *drm) ttm_bo_use_mm(man); return 0; } else { - return ttm_bo_man_init(&drm->ttm.bdev, man, + return ttm_bo_man_init(&drm->ttm.bdev, TTM_PL_VRAM, + TTM_PL_FLAG_UNCACHED | TTM_PL_FLAG_WC, + TTM_PL_FLAG_WC, false, drm->gem.vram_available >> PAGE_SHIFT); } } @@ -193,7 +196,7 @@ nouveau_ttm_fini_vram(struct nouveau_drm *drm) ttm_bo_force_list_clean(&drm->ttm.bdev, man); ttm_bo_man_cleanup(man); } else - ttm_bo_man_takedown(&drm->ttm.bdev, man); + ttm_bo_man_takedown(&drm->ttm.bdev, TTM_PL_VRAM); } static int @@ -216,7 +219,9 @@ nouveau_ttm_init_gtt(struct nouveau_drm *drm) else if (!drm->agp.bridge) man->func = &nv04_gart_manager; else - return ttm_bo_man_init(&drm->ttm.bdev, man, + return ttm_bo_man_init(&drm->ttm.bdev, TTM_PL_TT, + TTM_PL_FLAG_UNCACHED | TTM_PL_FLAG_WC, + TTM_PL_FLAG_WC, true, size_pages); ttm_bo_init_mm_base(&drm->ttm.bdev, man, @@ -232,7 +237,7 @@ nouveau_ttm_fini_gtt(struct nouveau_drm *drm) if (drm->client.device.info.family < NV_DEVICE_INFO_V0_TESLA && drm->agp.bridge) - ttm_bo_man_takedown(&drm->ttm.bdev, man); + ttm_bo_man_takedown(&drm->ttm.bdev, TTM_PL_TT); else { ttm_bo_disable_mm(man); ttm_bo_force_list_clean(&drm->ttm.bdev, man); diff --git a/drivers/gpu/drm/qxl/qxl_ttm.c b/drivers/gpu/drm/qxl/qxl_ttm.c index 9aea35a66e25..5b569415854e 100644 --- a/drivers/gpu/drm/qxl/qxl_ttm.c +++ b/drivers/gpu/drm/qxl/qxl_ttm.c @@ -219,12 +219,8 @@ static int qxl_ttm_init_mem_type(struct qxl_device *qdev, unsigned int type, uint64_t size) { - struct ttm_mem_type_manager *man = ttm_manager_type(&qdev->mman.bdev, type); - - man->available_caching = TTM_PL_MASK_CACHING; - man->default_caching = TTM_PL_FLAG_CACHED; - - return ttm_bo_man_init(&qdev->mman.bdev, man, size); + return ttm_bo_man_init(&qdev->mman.bdev, type, TTM_PL_MASK_CACHING, + TTM_PL_FLAG_CACHED, false, size); } int qxl_ttm_init(struct qxl_device *qdev) @@ -266,8 +262,8 @@ int qxl_ttm_init(struct qxl_device *qdev) void qxl_ttm_fini(struct qxl_device *qdev) { - ttm_bo_man_takedown(&qdev->mman.bdev, ttm_manager_type(&qdev->mman.bdev, TTM_PL_VRAM)); - ttm_bo_man_takedown(&qdev->mman.bdev, ttm_manager_type(&qdev->mman.bdev, TTM_PL_PRIV)); + ttm_bo_man_takedown(&qdev->mman.bdev, TTM_PL_VRAM); + ttm_bo_man_takedown(&qdev->mman.bdev, TTM_PL_PRIV); ttm_bo_device_release(&qdev->mman.bdev); DRM_INFO("qxl: ttm finalized\n"); } diff --git a/drivers/gpu/drm/radeon/radeon_ttm.c b/drivers/gpu/drm/radeon/radeon_ttm.c index 3849d0e852bc..793031bb9bd2 100644 --- a/drivers/gpu/drm/radeon/radeon_ttm.c +++ b/drivers/gpu/drm/radeon/radeon_ttm.c @@ -68,36 +68,35 @@ struct radeon_device *radeon_get_rdev(struct ttm_bo_device *bdev) static int radeon_ttm_init_vram(struct radeon_device *rdev) { - struct ttm_mem_type_manager *man = ttm_manager_type(&rdev->mman.bdev, TTM_PL_VRAM); - - man->available_caching = TTM_PL_FLAG_UNCACHED | TTM_PL_FLAG_WC; - man->default_caching = TTM_PL_FLAG_WC; - - return ttm_bo_man_init(&rdev->mman.bdev, man, + return ttm_bo_man_init(&rdev->mman.bdev, TTM_PL_VRAM, + TTM_PL_FLAG_UNCACHED | TTM_PL_FLAG_WC, + TTM_PL_FLAG_WC, false, rdev->mc.real_vram_size >> PAGE_SHIFT); } static int radeon_ttm_init_gtt(struct radeon_device *rdev) { - struct ttm_mem_type_manager *man = ttm_manager_type(&rdev->mman.bdev, TTM_PL_TT); + uint32_t available_caching, default_caching; + + available_caching = TTM_PL_MASK_CACHING; + default_caching = TTM_PL_FLAG_CACHED; - man->available_caching = TTM_PL_MASK_CACHING; - man->default_caching = TTM_PL_FLAG_CACHED; - man->use_tt = true; #if IS_ENABLED(CONFIG_AGP) if (rdev->flags & RADEON_IS_AGP) { if (!rdev->ddev->agp) { DRM_ERROR("AGP is not enabled\n"); return -EINVAL; } - man->available_caching = TTM_PL_FLAG_UNCACHED | - TTM_PL_FLAG_WC; - man->default_caching = TTM_PL_FLAG_WC; + available_caching = TTM_PL_FLAG_UNCACHED | + TTM_PL_FLAG_WC; + default_caching = TTM_PL_FLAG_WC; } #endif - return ttm_bo_man_init(&rdev->mman.bdev, man, - rdev->mc.gtt_size >> PAGE_SHIFT); + return ttm_bo_man_init(&rdev->mman.bdev, TTM_PL_TT, + available_caching, + default_caching, true, + rdev->mc.gtt_size >> PAGE_SHIFT); } static void radeon_evict_flags(struct ttm_buffer_object *bo, @@ -825,8 +824,8 @@ void radeon_ttm_fini(struct radeon_device *rdev) } radeon_bo_unref(&rdev->stolen_vga_memory); } - ttm_bo_man_takedown(&rdev->mman.bdev, ttm_manager_type(&rdev->mman.bdev, TTM_PL_VRAM)); - ttm_bo_man_takedown(&rdev->mman.bdev, ttm_manager_type(&rdev->mman.bdev, TTM_PL_TT)); + ttm_bo_man_takedown(&rdev->mman.bdev, TTM_PL_VRAM); + ttm_bo_man_takedown(&rdev->mman.bdev, TTM_PL_TT); ttm_bo_device_release(&rdev->mman.bdev); radeon_gart_fini(rdev); rdev->mman.initialized = false; diff --git a/drivers/gpu/drm/ttm/ttm_bo_manager.c b/drivers/gpu/drm/ttm/ttm_bo_manager.c index f60a9a5d429d..2f5fa44b6474 100644 --- a/drivers/gpu/drm/ttm/ttm_bo_manager.c +++ b/drivers/gpu/drm/ttm/ttm_bo_manager.c @@ -107,19 +107,27 @@ static void ttm_bo_man_put_node(struct ttm_mem_type_manager *man, static const struct ttm_mem_type_manager_func ttm_bo_manager_func; int ttm_bo_man_init(struct ttm_bo_device *bdev, - struct ttm_mem_type_manager *man, + unsigned type, + uint32_t available_caching, + uint32_t default_caching, + bool use_tt, unsigned long p_size) { + struct ttm_mem_type_manager *man = ttm_manager_type(bdev, type); struct ttm_range_manager *rman; - man->func = &ttm_bo_manager_func; - - ttm_bo_init_mm_base(bdev, man, p_size); + man->available_caching = available_caching; + man->default_caching = default_caching; + man->use_tt = use_tt; rman = kzalloc(sizeof(*rman), GFP_KERNEL); if (!rman) return -ENOMEM; + man->func = &ttm_bo_manager_func; + + ttm_bo_init_mm_base(bdev, man, p_size); + drm_mm_init(&rman->mm, 0, p_size); spin_lock_init(&rman->lock); man->priv = rman; @@ -130,8 +138,9 @@ int ttm_bo_man_init(struct ttm_bo_device *bdev, EXPORT_SYMBOL(ttm_bo_man_init); int ttm_bo_man_takedown(struct ttm_bo_device *bdev, - struct ttm_mem_type_manager *man) + unsigned type) { + struct ttm_mem_type_manager *man = ttm_manager_type(bdev, type); struct ttm_range_manager *rman = (struct ttm_range_manager *) man->priv; struct drm_mm *mm = &rman->mm; int ret; diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c index dff6990ff9ed..1849d913d521 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c @@ -626,13 +626,9 @@ static int vmw_init_vram_manager(struct vmw_private *dev_priv) #ifdef CONFIG_TRANSPARENT_HUGEPAGE ret = vmw_thp_init(dev_priv); #else - struct ttm_mem_type_manager *man = &dev_priv->bdev.man[TTM_PL_VRAM]; - - man->available_caching = TTM_PL_FLAG_CACHED; - man->default_caching = TTM_PL_FLAG_CACHED; - - ret = ttm_bo_man_init(&dev_priv->bdev, man, - dev_priv->vram_size >> PAGE_SHIFT); + ret = ttm_bo_man_init(&dev_priv->bdev, TTM_PL_VRAM, + TTM_PL_FLAG_CACHED, TTM_PL_FLAG_CACHED, + false, dev_priv->vram_size >> PAGE_SHIFT); #endif ttm_manager_type(&dev_priv->bdev, TTM_PL_VRAM)->use_type = false; return ret; @@ -643,8 +639,7 @@ static void vmw_takedown_vram_manager(struct vmw_private *dev_priv) #ifdef CONFIG_TRANSPARENT_HUGEPAGE vmw_thp_takedown(dev_priv); #else - ttm_bo_man_takedown(&dev_priv->bdev, - ttm_manager_type(&dev_priv->bdev, TTM_PL_VRAM)); + ttm_bo_man_takedown(&dev_priv->bdev, TTM_PL_VRAM); #endif } diff --git a/include/drm/ttm/ttm_bo_driver.h b/include/drm/ttm/ttm_bo_driver.h index 723171fd94da..6319d85d7270 100644 --- a/include/drm/ttm/ttm_bo_driver.h +++ b/include/drm/ttm/ttm_bo_driver.h @@ -809,8 +809,11 @@ int ttm_bo_pipeline_gutting(struct ttm_buffer_object *bo); pgprot_t ttm_io_prot(uint32_t caching_flags, pgprot_t tmp); int ttm_bo_man_init(struct ttm_bo_device *bdev, - struct ttm_mem_type_manager *man, + unsigned type, + uint32_t available_caching, + uint32_t default_caching, + bool use_tt, unsigned long p_size); int ttm_bo_man_takedown(struct ttm_bo_device *bdev, - struct ttm_mem_type_manager *man); + unsigned type); #endif From patchwork Fri Jul 31 04:05:11 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Dave Airlie X-Patchwork-Id: 11694027 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1C03014E3 for ; Fri, 31 Jul 2020 04:07:10 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 042092070B for ; Fri, 31 Jul 2020 04:07:10 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 042092070B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id B468F6E9B7; Fri, 31 Jul 2020 04:07:04 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from us-smtp-delivery-1.mimecast.com (us-smtp-1.mimecast.com [207.211.31.81]) by gabe.freedesktop.org (Postfix) with ESMTPS id D22FD6E9A2 for ; Fri, 31 Jul 2020 04:07:03 +0000 (UTC) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-247-rvVL-GUnNYy9RO776ftsyg-1; Fri, 31 Jul 2020 00:06:57 -0400 X-MC-Unique: rvVL-GUnNYy9RO776ftsyg-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id EF7E480046A; Fri, 31 Jul 2020 04:06:55 +0000 (UTC) Received: from tyrion-bne-redhat-com.redhat.com (vpn2-54-17.bne.redhat.com [10.64.54.17]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7F55A100238C; Fri, 31 Jul 2020 04:06:54 +0000 (UTC) From: Dave Airlie To: dri-devel@lists.freedesktop.org Subject: [PATCH 40/49] drm/ttm: move range manager to subclassed driver allocation Date: Fri, 31 Jul 2020 14:05:11 +1000 Message-Id: <20200731040520.3701599-41-airlied@gmail.com> In-Reply-To: <20200731040520.3701599-1-airlied@gmail.com> References: <20200731040520.3701599-1-airlied@gmail.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: gmail.com X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: christian.koenig@amd.com, sroland@vmware.com, bskeggs@redhat.com, kraxel@redhat.com Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Dave Airlie Signed-off-by: Dave Airlie Reviewed-by: Christian König --- drivers/gpu/drm/ttm/ttm_bo_manager.c | 32 +++++++++++++++++----------- 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/drivers/gpu/drm/ttm/ttm_bo_manager.c b/drivers/gpu/drm/ttm/ttm_bo_manager.c index 2f5fa44b6474..2782ccff9b66 100644 --- a/drivers/gpu/drm/ttm/ttm_bo_manager.c +++ b/drivers/gpu/drm/ttm/ttm_bo_manager.c @@ -44,16 +44,22 @@ */ struct ttm_range_manager { + struct ttm_mem_type_manager manager; struct drm_mm mm; spinlock_t lock; }; +static inline struct ttm_range_manager *to_range_manager(struct ttm_mem_type_manager *man) +{ + return container_of(man, struct ttm_range_manager, manager); +} + static int ttm_bo_man_get_node(struct ttm_mem_type_manager *man, struct ttm_buffer_object *bo, const struct ttm_place *place, struct ttm_mem_reg *mem) { - struct ttm_range_manager *rman = (struct ttm_range_manager *) man->priv; + struct ttm_range_manager *rman = to_range_manager(man); struct drm_mm *mm = &rman->mm; struct drm_mm_node *node; enum drm_mm_insert_mode mode; @@ -92,7 +98,7 @@ static int ttm_bo_man_get_node(struct ttm_mem_type_manager *man, static void ttm_bo_man_put_node(struct ttm_mem_type_manager *man, struct ttm_mem_reg *mem) { - struct ttm_range_manager *rman = (struct ttm_range_manager *) man->priv; + struct ttm_range_manager *rman = to_range_manager(man); if (mem->mm_node) { spin_lock(&rman->lock); @@ -113,25 +119,26 @@ int ttm_bo_man_init(struct ttm_bo_device *bdev, bool use_tt, unsigned long p_size) { - struct ttm_mem_type_manager *man = ttm_manager_type(bdev, type); + struct ttm_mem_type_manager *man; struct ttm_range_manager *rman; - man->available_caching = available_caching; - man->default_caching = default_caching; - man->use_tt = use_tt; - rman = kzalloc(sizeof(*rman), GFP_KERNEL); if (!rman) return -ENOMEM; + man = &rman->manager; + man->available_caching = available_caching; + man->default_caching = default_caching; + man->use_tt = use_tt; + man->func = &ttm_bo_manager_func; ttm_bo_init_mm_base(bdev, man, p_size); drm_mm_init(&rman->mm, 0, p_size); spin_lock_init(&rman->lock); - man->priv = rman; + ttm_set_driver_manager(bdev, type, &rman->manager); ttm_bo_use_mm(man); return 0; } @@ -141,7 +148,7 @@ int ttm_bo_man_takedown(struct ttm_bo_device *bdev, unsigned type) { struct ttm_mem_type_manager *man = ttm_manager_type(bdev, type); - struct ttm_range_manager *rman = (struct ttm_range_manager *) man->priv; + struct ttm_range_manager *rman = to_range_manager(man); struct drm_mm *mm = &rman->mm; int ret; @@ -155,10 +162,11 @@ int ttm_bo_man_takedown(struct ttm_bo_device *bdev, drm_mm_clean(mm); drm_mm_takedown(mm); spin_unlock(&rman->lock); - kfree(rman); - man->priv = NULL; ttm_bo_man_cleanup(man); + ttm_set_driver_manager(bdev, type, NULL); + kfree(rman); + return 0; } EXPORT_SYMBOL(ttm_bo_man_takedown); @@ -166,7 +174,7 @@ EXPORT_SYMBOL(ttm_bo_man_takedown); static void ttm_bo_man_debug(struct ttm_mem_type_manager *man, struct drm_printer *printer) { - struct ttm_range_manager *rman = (struct ttm_range_manager *) man->priv; + struct ttm_range_manager *rman = to_range_manager(man); spin_lock(&rman->lock); drm_mm_print(&rman->mm, printer); From patchwork Fri Jul 31 04:05:12 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Airlie X-Patchwork-Id: 11694055 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 23C2713B1 for ; Fri, 31 Jul 2020 04:07:51 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 0C6A42070B for ; Fri, 31 Jul 2020 04:07:51 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0C6A42070B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 2E6616E9CD; Fri, 31 Jul 2020 04:07:47 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) by gabe.freedesktop.org (Postfix) with ESMTPS id 1AD3A6E9C1 for ; Fri, 31 Jul 2020 04:07:07 +0000 (UTC) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-496-o8TUky9yOrSfibbmK5uppQ-1; Fri, 31 Jul 2020 00:06:58 -0400 X-MC-Unique: o8TUky9yOrSfibbmK5uppQ-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id C85D5800685; Fri, 31 Jul 2020 04:06:57 +0000 (UTC) Received: from tyrion-bne-redhat-com.redhat.com (vpn2-54-17.bne.redhat.com [10.64.54.17]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5B3B1100238C; Fri, 31 Jul 2020 04:06:56 +0000 (UTC) From: Dave Airlie To: dri-devel@lists.freedesktop.org Subject: [PATCH 41/49] drm/vmwgfx/ttm: move thp to driver managed Date: Fri, 31 Jul 2020 14:05:12 +1000 Message-Id: <20200731040520.3701599-42-airlied@gmail.com> In-Reply-To: <20200731040520.3701599-1-airlied@gmail.com> References: <20200731040520.3701599-1-airlied@gmail.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: gmail.com X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: christian.koenig@amd.com, sroland@vmware.com, bskeggs@redhat.com, kraxel@redhat.com Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Dave Airlie Signed-off-by: Dave Airlie --- drivers/gpu/drm/vmwgfx/vmwgfx_thp.c | 33 +++++++++++++++++++---------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_thp.c b/drivers/gpu/drm/vmwgfx/vmwgfx_thp.c index 0dd619c9d207..d2dde8159c3d 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_thp.c +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_thp.c @@ -16,10 +16,16 @@ * @lock: Manager lock. */ struct vmw_thp_manager { + struct ttm_mem_type_manager manager; struct drm_mm mm; spinlock_t lock; }; +static struct vmw_thp_manager *to_thp_manager(struct ttm_mem_type_manager *man) +{ + return container_of(man, struct vmw_thp_manager, manager); +} + static int vmw_thp_insert_aligned(struct drm_mm *mm, struct drm_mm_node *node, unsigned long align_pages, const struct ttm_place *place, @@ -43,7 +49,7 @@ static int vmw_thp_get_node(struct ttm_mem_type_manager *man, const struct ttm_place *place, struct ttm_mem_reg *mem) { - struct vmw_thp_manager *rman = (struct vmw_thp_manager *) man->priv; + struct vmw_thp_manager *rman = to_thp_manager(man); struct drm_mm *mm = &rman->mm; struct drm_mm_node *node; unsigned long align_pages; @@ -103,7 +109,7 @@ static int vmw_thp_get_node(struct ttm_mem_type_manager *man, static void vmw_thp_put_node(struct ttm_mem_type_manager *man, struct ttm_mem_reg *mem) { - struct vmw_thp_manager *rman = (struct vmw_thp_manager *) man->priv; + struct vmw_thp_manager *rman = to_thp_manager(man); if (mem->mm_node) { spin_lock(&rman->lock); @@ -117,20 +123,25 @@ static void vmw_thp_put_node(struct ttm_mem_type_manager *man, int vmw_thp_init(struct vmw_private *dev_priv) { - struct ttm_mem_type_manager *man = ttm_manager_type(&dev_priv->bdev, TTM_PL_VRAM); + struct ttm_mem_type_manager *man; struct vmw_thp_manager *rman; + + rman = kzalloc(sizeof(*rman), GFP_KERNEL); + if (!rman) + return -ENOMEM; + + man = &rman->manager; man->available_caching = TTM_PL_FLAG_CACHED; man->default_caching = TTM_PL_FLAG_CACHED; ttm_bo_init_mm_base(&dev_priv->bdev, man, dev_priv->vram_size >> PAGE_SHIFT); - rman = kzalloc(sizeof(*rman), GFP_KERNEL); - if (!rman) - return -ENOMEM; + drm_mm_init(&rman->mm, 0, man->size); spin_lock_init(&rman->lock); - man->priv = rman; + + ttm_set_driver_manager(&dev_priv->bdev, TTM_PL_VRAM, &rman->manager); ttm_bo_use_mm(man); return 0; } @@ -138,7 +149,7 @@ int vmw_thp_init(struct vmw_private *dev_priv) void vmw_thp_takedown(struct vmw_private *dev_priv) { struct ttm_mem_type_manager *man = ttm_manager_type(&dev_priv->bdev, TTM_PL_VRAM); - struct vmw_thp_manager *rman = (struct vmw_thp_manager *) man->priv; + struct vmw_thp_manager *rman = to_thp_manager(man); struct drm_mm *mm = &rman->mm; int ret; @@ -151,15 +162,15 @@ void vmw_thp_takedown(struct vmw_private *dev_priv) drm_mm_clean(mm); drm_mm_takedown(mm); spin_unlock(&rman->lock); - kfree(rman); - man->priv = NULL; ttm_bo_man_cleanup(man); + ttm_set_driver_manager(&dev_priv->bdev, TTM_PL_VRAM, NULL); + kfree(rman); } static void vmw_thp_debug(struct ttm_mem_type_manager *man, struct drm_printer *printer) { - struct vmw_thp_manager *rman = (struct vmw_thp_manager *) man->priv; + struct vmw_thp_manager *rman = to_thp_manager(man); spin_lock(&rman->lock); drm_mm_print(&rman->mm, printer); From patchwork Fri Jul 31 04:05:13 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Airlie X-Patchwork-Id: 11694049 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B6A6D13B1 for ; Fri, 31 Jul 2020 04:07:42 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 9F4D82070B for ; Fri, 31 Jul 2020 04:07:42 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9F4D82070B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id C76CD6E9C2; Fri, 31 Jul 2020 04:07:40 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) by gabe.freedesktop.org (Postfix) with ESMTPS id D05156E9BD for ; Fri, 31 Jul 2020 04:07:08 +0000 (UTC) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-315--rfiGSrcPNy_I8nWSvPbKQ-1; Fri, 31 Jul 2020 00:07:00 -0400 X-MC-Unique: -rfiGSrcPNy_I8nWSvPbKQ-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id A33D6800471; Fri, 31 Jul 2020 04:06:59 +0000 (UTC) Received: from tyrion-bne-redhat-com.redhat.com (vpn2-54-17.bne.redhat.com [10.64.54.17]) by smtp.corp.redhat.com (Postfix) with ESMTP id 349EB1001281; Fri, 31 Jul 2020 04:06:58 +0000 (UTC) From: Dave Airlie To: dri-devel@lists.freedesktop.org Subject: [PATCH 42/49] drm/vmwgfx/gmrid: convert to driver controlled allocation. Date: Fri, 31 Jul 2020 14:05:13 +1000 Message-Id: <20200731040520.3701599-43-airlied@gmail.com> In-Reply-To: <20200731040520.3701599-1-airlied@gmail.com> References: <20200731040520.3701599-1-airlied@gmail.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: gmail.com X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: christian.koenig@amd.com, sroland@vmware.com, bskeggs@redhat.com, kraxel@redhat.com Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Dave Airlie Signed-off-by: Dave Airlie --- drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c | 33 +++++++++++-------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c b/drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c index 2db99f0449b0..14430c243ce5 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c @@ -37,6 +37,7 @@ #include struct vmwgfx_gmrid_man { + struct ttm_mem_type_manager manager; spinlock_t lock; struct ida gmr_ida; uint32_t max_gmr_ids; @@ -44,13 +45,17 @@ struct vmwgfx_gmrid_man { uint32_t used_gmr_pages; }; +static struct vmwgfx_gmrid_man *to_gmrid_manager(struct ttm_mem_type_manager *man) +{ + return container_of(man, struct vmwgfx_gmrid_man, manager); +} + static int vmw_gmrid_man_get_node(struct ttm_mem_type_manager *man, struct ttm_buffer_object *bo, const struct ttm_place *place, struct ttm_mem_reg *mem) { - struct vmwgfx_gmrid_man *gman = - (struct vmwgfx_gmrid_man *)man->priv; + struct vmwgfx_gmrid_man *gman = to_gmrid_manager(man); int id; id = ida_alloc_max(&gman->gmr_ida, gman->max_gmr_ids - 1, GFP_KERNEL); @@ -82,8 +87,7 @@ static int vmw_gmrid_man_get_node(struct ttm_mem_type_manager *man, static void vmw_gmrid_man_put_node(struct ttm_mem_type_manager *man, struct ttm_mem_reg *mem) { - struct vmwgfx_gmrid_man *gman = - (struct vmwgfx_gmrid_man *)man->priv; + struct vmwgfx_gmrid_man *gman = to_gmrid_manager(man); if (mem->mm_node) { ida_free(&gman->gmr_ida, mem->start); @@ -98,13 +102,15 @@ static const struct ttm_mem_type_manager_func vmw_gmrid_manager_func; int vmw_gmrid_man_init(struct vmw_private *dev_priv, int type) { - struct ttm_mem_type_manager *man = ttm_manager_type(&dev_priv->bdev, type); + struct ttm_mem_type_manager *man; struct vmwgfx_gmrid_man *gman = kzalloc(sizeof(*gman), GFP_KERNEL); if (unlikely(!gman)) return -ENOMEM; + man = &gman->manager; + man->func = &vmw_gmrid_manager_func; man->available_caching = TTM_PL_FLAG_CACHED; man->default_caching = TTM_PL_FLAG_CACHED; @@ -127,26 +133,27 @@ int vmw_gmrid_man_init(struct vmw_private *dev_priv, int type) default: BUG(); } - man->priv = (void *) gman; + + ttm_set_driver_manager(&dev_priv->bdev, type, &gman->manager); + ttm_bo_use_mm(man); return 0; } void vmw_gmrid_man_takedown(struct vmw_private *dev_priv, int type) { struct ttm_mem_type_manager *man = ttm_manager_type(&dev_priv->bdev, type); - struct vmwgfx_gmrid_man *gman = - (struct vmwgfx_gmrid_man *)man->priv; + struct vmwgfx_gmrid_man *gman = to_gmrid_manager(man); ttm_bo_disable_mm(man); ttm_bo_force_list_clean(&dev_priv->bdev, man); - if (gman) { - ida_destroy(&gman->gmr_ida); - kfree(gman); - } - ttm_bo_man_cleanup(man); + + ttm_set_driver_manager(&dev_priv->bdev, type, NULL); + ida_destroy(&gman->gmr_ida); + kfree(gman); + } static const struct ttm_mem_type_manager_func vmw_gmrid_manager_func = { From patchwork Fri Jul 31 04:05:14 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Airlie X-Patchwork-Id: 11694061 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6227214E3 for ; Fri, 31 Jul 2020 04:07:54 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 4B1A22070B for ; Fri, 31 Jul 2020 04:07:54 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4B1A22070B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 89B606E9D0; Fri, 31 Jul 2020 04:07:48 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from us-smtp-delivery-1.mimecast.com (us-smtp-2.mimecast.com [205.139.110.61]) by gabe.freedesktop.org (Postfix) with ESMTPS id 797666E9C0 for ; Fri, 31 Jul 2020 04:07:06 +0000 (UTC) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-28-G2iJat6BPRWpGMKZpzfbDw-1; Fri, 31 Jul 2020 00:07:03 -0400 X-MC-Unique: G2iJat6BPRWpGMKZpzfbDw-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 7CDD4106B249; Fri, 31 Jul 2020 04:07:01 +0000 (UTC) Received: from tyrion-bne-redhat-com.redhat.com (vpn2-54-17.bne.redhat.com [10.64.54.17]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0E87D100238C; Fri, 31 Jul 2020 04:06:59 +0000 (UTC) From: Dave Airlie To: dri-devel@lists.freedesktop.org Subject: [PATCH 43/49] drm/nouveau/ttm: move to driver allocated manager Date: Fri, 31 Jul 2020 14:05:14 +1000 Message-Id: <20200731040520.3701599-44-airlied@gmail.com> In-Reply-To: <20200731040520.3701599-1-airlied@gmail.com> References: <20200731040520.3701599-1-airlied@gmail.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=airlied@gmail.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: gmail.com X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: christian.koenig@amd.com, sroland@vmware.com, bskeggs@redhat.com, kraxel@redhat.com Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Dave Airlie Signed-off-by: Dave Airlie --- drivers/gpu/drm/nouveau/nouveau_ttm.c | 41 ++++++++++++++++++--------- 1 file changed, 28 insertions(+), 13 deletions(-) diff --git a/drivers/gpu/drm/nouveau/nouveau_ttm.c b/drivers/gpu/drm/nouveau/nouveau_ttm.c index 225f9af2eaa1..5b0af2065ad9 100644 --- a/drivers/gpu/drm/nouveau/nouveau_ttm.c +++ b/drivers/gpu/drm/nouveau/nouveau_ttm.c @@ -157,12 +157,12 @@ static int nouveau_ttm_init_vram(struct nouveau_drm *drm) { struct nvif_mmu *mmu = &drm->client.mmu; - if (drm->client.device.info.family >= NV_DEVICE_INFO_V0_TESLA) { - struct ttm_mem_type_manager *man = ttm_manager_type(&drm->ttm.bdev, TTM_PL_VRAM); - /* Some BARs do not support being ioremapped WC */ const u8 type = mmu->type[drm->ttm.type_vram].type; + struct ttm_mem_type_manager *man = kzalloc(sizeof(struct ttm_mem_type_manager), GFP_KERNEL); + if (!man) + return -ENOMEM; man->available_caching = TTM_PL_FLAG_UNCACHED | TTM_PL_FLAG_WC; man->default_caching = TTM_PL_FLAG_WC; @@ -176,6 +176,7 @@ nouveau_ttm_init_vram(struct nouveau_drm *drm) man->use_io_reserve_lru = true; ttm_bo_init_mm_base(&drm->ttm.bdev, man, drm->gem.vram_available >> PAGE_SHIFT); + ttm_set_driver_manager(&drm->ttm.bdev, TTM_PL_VRAM, man); ttm_bo_use_mm(man); return 0; } else { @@ -195,6 +196,8 @@ nouveau_ttm_fini_vram(struct nouveau_drm *drm) ttm_bo_disable_mm(man); ttm_bo_force_list_clean(&drm->ttm.bdev, man); ttm_bo_man_cleanup(man); + ttm_set_driver_manager(&drm->ttm.bdev, TTM_PL_VRAM, NULL); + kfree(man); } else ttm_bo_man_takedown(&drm->ttm.bdev, TTM_PL_VRAM); } @@ -202,30 +205,40 @@ nouveau_ttm_fini_vram(struct nouveau_drm *drm) static int nouveau_ttm_init_gtt(struct nouveau_drm *drm) { - struct ttm_mem_type_manager *man = ttm_manager_type(&drm->ttm.bdev, TTM_PL_TT); + struct ttm_mem_type_manager *man; unsigned long size_pages = drm->gem.gart_available >> PAGE_SHIFT; - man->use_tt = true; + unsigned available_caching, default_caching; + const struct ttm_mem_type_manager_func *func = NULL; if (drm->agp.bridge) { - man->available_caching = TTM_PL_FLAG_UNCACHED | + available_caching = TTM_PL_FLAG_UNCACHED | TTM_PL_FLAG_WC; - man->default_caching = TTM_PL_FLAG_WC; + default_caching = TTM_PL_FLAG_WC; } else { - man->available_caching = TTM_PL_MASK_CACHING; - man->default_caching = TTM_PL_FLAG_CACHED; + available_caching = TTM_PL_MASK_CACHING; + default_caching = TTM_PL_FLAG_CACHED; } if (drm->client.device.info.family >= NV_DEVICE_INFO_V0_TESLA) - man->func = &nouveau_gart_manager; + func = &nouveau_gart_manager; else if (!drm->agp.bridge) - man->func = &nv04_gart_manager; + func = &nv04_gart_manager; else return ttm_bo_man_init(&drm->ttm.bdev, TTM_PL_TT, - TTM_PL_FLAG_UNCACHED | TTM_PL_FLAG_WC, - TTM_PL_FLAG_WC, true, + available_caching, default_caching, + true, size_pages); + man = kzalloc(sizeof(struct ttm_mem_type_manager), GFP_KERNEL); + if (!man) + return -ENOMEM; + + man->func = func; + man->available_caching = available_caching; + man->default_caching = default_caching; + man->use_tt = true; ttm_bo_init_mm_base(&drm->ttm.bdev, man, size_pages); + ttm_set_driver_manager(&drm->ttm.bdev, TTM_PL_TT, man); ttm_bo_use_mm(man); return 0; } @@ -242,6 +255,8 @@ nouveau_ttm_fini_gtt(struct nouveau_drm *drm) ttm_bo_disable_mm(man); ttm_bo_force_list_clean(&drm->ttm.bdev, man); ttm_bo_man_cleanup(man); + ttm_set_driver_manager(&drm->ttm.bdev, TTM_PL_TT, NULL); + kfree(man); } } From patchwork Fri Jul 31 04:05:15 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Dave Airlie X-Patchwork-Id: 11694047 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1523714E3 for ; Fri, 31 Jul 2020 04:07:41 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id F204D208E4 for ; Fri, 31 Jul 2020 04:07:40 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org F204D208E4 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 31ECE6E9C0; Fri, 31 Jul 2020 04:07:40 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) by gabe.freedesktop.org (Postfix) with ESMTPS id 9714D6E9BD for ; Fri, 31 Jul 2020 04:07:11 +0000 (UTC) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-210-G5p97TIaPP2TQ9COQ1L_iw-1; Fri, 31 Jul 2020 00:07:07 -0400 X-MC-Unique: G5p97TIaPP2TQ9COQ1L_iw-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 52C08800461; Fri, 31 Jul 2020 04:07:06 +0000 (UTC) Received: from tyrion-bne-redhat-com.redhat.com (vpn2-54-17.bne.redhat.com [10.64.54.17]) by smtp.corp.redhat.com (Postfix) with ESMTP id DBCCC100238C; Fri, 31 Jul 2020 04:07:01 +0000 (UTC) From: Dave Airlie To: dri-devel@lists.freedesktop.org Subject: [PATCH 44/49] drm/ttm: drop priv pointer in memory manager Date: Fri, 31 Jul 2020 14:05:15 +1000 Message-Id: <20200731040520.3701599-45-airlied@gmail.com> In-Reply-To: <20200731040520.3701599-1-airlied@gmail.com> References: <20200731040520.3701599-1-airlied@gmail.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: gmail.com X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: christian.koenig@amd.com, sroland@vmware.com, bskeggs@redhat.com, kraxel@redhat.com Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Dave Airlie This isn't needed anymore by any drivers. Signed-off-by: Dave Airlie Reviewed-by: Christian König --- include/drm/ttm/ttm_bo_driver.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/include/drm/ttm/ttm_bo_driver.h b/include/drm/ttm/ttm_bo_driver.h index 6319d85d7270..a38704fe0737 100644 --- a/include/drm/ttm/ttm_bo_driver.h +++ b/include/drm/ttm/ttm_bo_driver.h @@ -123,7 +123,6 @@ struct ttm_mem_type_manager_func { * @default_caching: The default caching policy used for a buffer object * placed in this memory type if the user doesn't provide one. * @func: structure pointer implementing the range manager. See above - * @priv: Driver private closure for @func. * @io_reserve_mutex: Mutex optionally protecting shared io_reserve structures * @use_io_reserve_lru: Use an lru list to try to unreserve io_mem_regions * reserved by the TTM vm system. @@ -152,7 +151,6 @@ struct ttm_mem_type_manager { uint32_t available_caching; uint32_t default_caching; const struct ttm_mem_type_manager_func *func; - void *priv; struct mutex io_reserve_mutex; bool use_io_reserve_lru; spinlock_t move_lock; From patchwork Fri Jul 31 04:05:16 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Dave Airlie X-Patchwork-Id: 11694057 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 04BA613B1 for ; Fri, 31 Jul 2020 04:07:52 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id E167D2070B for ; Fri, 31 Jul 2020 04:07:51 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E167D2070B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 236B86E9CC; Fri, 31 Jul 2020 04:07:47 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from us-smtp-1.mimecast.com (us-smtp-1.mimecast.com [205.139.110.61]) by gabe.freedesktop.org (Postfix) with ESMTPS id AB6BD6E9BD for ; Fri, 31 Jul 2020 04:07:14 +0000 (UTC) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-22-BEaGIUm1MD2N936KpuPXjQ-1; Fri, 31 Jul 2020 00:07:09 -0400 X-MC-Unique: BEaGIUm1MD2N936KpuPXjQ-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 2C11A18839C0; Fri, 31 Jul 2020 04:07:08 +0000 (UTC) Received: from tyrion-bne-redhat-com.redhat.com (vpn2-54-17.bne.redhat.com [10.64.54.17]) by smtp.corp.redhat.com (Postfix) with ESMTP id B1AE01001281; Fri, 31 Jul 2020 04:07:06 +0000 (UTC) From: Dave Airlie To: dri-devel@lists.freedesktop.org Subject: [PATCH 45/49] drm/amdgpu/ttm: remove man->bdev references. Date: Fri, 31 Jul 2020 14:05:16 +1000 Message-Id: <20200731040520.3701599-46-airlied@gmail.com> In-Reply-To: <20200731040520.3701599-1-airlied@gmail.com> References: <20200731040520.3701599-1-airlied@gmail.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=airlied@gmail.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: gmail.com X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: christian.koenig@amd.com, sroland@vmware.com, bskeggs@redhat.com, kraxel@redhat.com Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Dave Airlie Just store the device in the private so the link can be removed from the manager Signed-off-by: Dave Airlie Reviewed-by: Christian König --- drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c index 9d4a13926b8c..d451851c8689 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c @@ -34,6 +34,7 @@ struct amdgpu_vram_mgr { spinlock_t lock; atomic64_t usage; atomic64_t vis_usage; + struct amdgpu_device *adev; }; static inline struct amdgpu_vram_mgr *to_vram_mgr(struct ttm_mem_type_manager *man) @@ -196,6 +197,8 @@ int amdgpu_vram_mgr_init(struct amdgpu_device *adev) drm_mm_init(&mgr->mm, 0, man->size); spin_lock_init(&mgr->lock); + mgr->adev = adev; + /* Add the two VRAM-related sysfs files */ ret = sysfs_create_files(&adev->dev->kobj, amdgpu_vram_mgr_attributes); if (ret) @@ -323,8 +326,8 @@ static int amdgpu_vram_mgr_new(struct ttm_mem_type_manager *man, const struct ttm_place *place, struct ttm_mem_reg *mem) { - struct amdgpu_device *adev = amdgpu_ttm_adev(man->bdev); struct amdgpu_vram_mgr *mgr = to_vram_mgr(man); + struct amdgpu_device *adev = mgr->adev; struct drm_mm *mm = &mgr->mm; struct drm_mm_node *nodes; enum drm_mm_insert_mode mode; @@ -439,8 +442,8 @@ static int amdgpu_vram_mgr_new(struct ttm_mem_type_manager *man, static void amdgpu_vram_mgr_del(struct ttm_mem_type_manager *man, struct ttm_mem_reg *mem) { - struct amdgpu_device *adev = amdgpu_ttm_adev(man->bdev); struct amdgpu_vram_mgr *mgr = to_vram_mgr(man); + struct amdgpu_device *adev = mgr->adev; struct drm_mm_node *nodes = mem->mm_node; uint64_t usage = 0, vis_usage = 0; unsigned pages = mem->num_pages; From patchwork Fri Jul 31 04:05:17 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Dave Airlie X-Patchwork-Id: 11694053 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5024714E3 for ; Fri, 31 Jul 2020 04:07:49 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 38D612070B for ; Fri, 31 Jul 2020 04:07:49 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 38D612070B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id C76D76E9C9; Fri, 31 Jul 2020 04:07:46 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from us-smtp-delivery-1.mimecast.com (us-smtp-1.mimecast.com [207.211.31.81]) by gabe.freedesktop.org (Postfix) with ESMTPS id 65AD06E9BD for ; Fri, 31 Jul 2020 04:07:17 +0000 (UTC) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-341-XHdIQGg0MBaWYgkPPAYQow-1; Fri, 31 Jul 2020 00:07:11 -0400 X-MC-Unique: XHdIQGg0MBaWYgkPPAYQow-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 05FC618839C1; Fri, 31 Jul 2020 04:07:10 +0000 (UTC) Received: from tyrion-bne-redhat-com.redhat.com (vpn2-54-17.bne.redhat.com [10.64.54.17]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8B146100238C; Fri, 31 Jul 2020 04:07:08 +0000 (UTC) From: Dave Airlie To: dri-devel@lists.freedesktop.org Subject: [PATCH 46/49] drm/ttm: drop man->bdev link. Date: Fri, 31 Jul 2020 14:05:17 +1000 Message-Id: <20200731040520.3701599-47-airlied@gmail.com> In-Reply-To: <20200731040520.3701599-1-airlied@gmail.com> References: <20200731040520.3701599-1-airlied@gmail.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: gmail.com X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: christian.koenig@amd.com, sroland@vmware.com, bskeggs@redhat.com, kraxel@redhat.com Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Dave Airlie This link isn't needed anymore, drop it from the init interface. Signed-off-by: Dave Airlie Reviewed-by: Christian König --- drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c | 2 +- drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c | 2 +- drivers/gpu/drm/nouveau/nouveau_ttm.c | 6 ++---- drivers/gpu/drm/ttm/ttm_bo.c | 6 ++---- drivers/gpu/drm/ttm/ttm_bo_manager.c | 2 +- drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c | 2 +- drivers/gpu/drm/vmwgfx/vmwgfx_thp.c | 2 +- include/drm/ttm/ttm_bo_api.h | 3 +-- include/drm/ttm/ttm_bo_driver.h | 2 -- 9 files changed, 10 insertions(+), 17 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c index 83d88ee73468..b4480ca30988 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c @@ -108,7 +108,7 @@ int amdgpu_gtt_mgr_init(struct amdgpu_device *adev, uint64_t gtt_size) man->available_caching = TTM_PL_MASK_CACHING; man->default_caching = TTM_PL_FLAG_CACHED; - ttm_bo_init_mm_base(&adev->mman.bdev, man, gtt_size >> PAGE_SHIFT); + ttm_bo_init_mm_base(man, gtt_size >> PAGE_SHIFT); start = AMDGPU_GTT_MAX_TRANSFER_SIZE * AMDGPU_GTT_NUM_TRANSFER_WINDOWS; size = (adev->gmc.gart_size >> PAGE_SHIFT) - start; diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c index d451851c8689..f0e65a6fdf88 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c @@ -190,7 +190,7 @@ int amdgpu_vram_mgr_init(struct amdgpu_device *adev) man->available_caching = TTM_PL_FLAG_UNCACHED | TTM_PL_FLAG_WC; man->default_caching = TTM_PL_FLAG_WC; - ttm_bo_init_mm_base(&adev->mman.bdev, man, adev->gmc.real_vram_size >> PAGE_SHIFT); + ttm_bo_init_mm_base(man, adev->gmc.real_vram_size >> PAGE_SHIFT); man->func = &amdgpu_vram_mgr_func; diff --git a/drivers/gpu/drm/nouveau/nouveau_ttm.c b/drivers/gpu/drm/nouveau/nouveau_ttm.c index 5b0af2065ad9..89521d3ed9da 100644 --- a/drivers/gpu/drm/nouveau/nouveau_ttm.c +++ b/drivers/gpu/drm/nouveau/nouveau_ttm.c @@ -174,8 +174,7 @@ nouveau_ttm_init_vram(struct nouveau_drm *drm) man->func = &nouveau_vram_manager; man->use_io_reserve_lru = true; - ttm_bo_init_mm_base(&drm->ttm.bdev, man, - drm->gem.vram_available >> PAGE_SHIFT); + ttm_bo_init_mm_base(man, drm->gem.vram_available >> PAGE_SHIFT); ttm_set_driver_manager(&drm->ttm.bdev, TTM_PL_VRAM, man); ttm_bo_use_mm(man); return 0; @@ -236,8 +235,7 @@ nouveau_ttm_init_gtt(struct nouveau_drm *drm) man->available_caching = available_caching; man->default_caching = default_caching; man->use_tt = true; - ttm_bo_init_mm_base(&drm->ttm.bdev, man, - size_pages); + ttm_bo_init_mm_base(man, size_pages); ttm_set_driver_manager(&drm->ttm.bdev, TTM_PL_TT, man); ttm_bo_use_mm(man); return 0; diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c index 1e8fda1c9b3a..f2b41c4d7d51 100644 --- a/drivers/gpu/drm/ttm/ttm_bo.c +++ b/drivers/gpu/drm/ttm/ttm_bo.c @@ -1464,8 +1464,7 @@ int ttm_bo_evict_mm(struct ttm_bo_device *bdev, unsigned mem_type) } EXPORT_SYMBOL(ttm_bo_evict_mm); -void ttm_bo_init_mm_base(struct ttm_bo_device *bdev, - struct ttm_mem_type_manager *man, +void ttm_bo_init_mm_base(struct ttm_mem_type_manager *man, unsigned long p_size) { unsigned i; @@ -1475,7 +1474,6 @@ void ttm_bo_init_mm_base(struct ttm_bo_device *bdev, mutex_init(&man->io_reserve_mutex); spin_lock_init(&man->move_lock); INIT_LIST_HEAD(&man->io_reserve_lru); - man->bdev = bdev; man->size = p_size; for (i = 0; i < TTM_MAX_BO_PRIORITY; ++i) @@ -1588,7 +1586,7 @@ static void ttm_bo_init_sysman(struct ttm_bo_device *bdev) man->available_caching = TTM_PL_MASK_CACHING; man->default_caching = TTM_PL_FLAG_CACHED; - ttm_bo_init_mm_base(bdev, man, 0); + ttm_bo_init_mm_base(man, 0); ttm_bo_use_mm(man); } diff --git a/drivers/gpu/drm/ttm/ttm_bo_manager.c b/drivers/gpu/drm/ttm/ttm_bo_manager.c index 2782ccff9b66..6c6eedf84ca6 100644 --- a/drivers/gpu/drm/ttm/ttm_bo_manager.c +++ b/drivers/gpu/drm/ttm/ttm_bo_manager.c @@ -133,7 +133,7 @@ int ttm_bo_man_init(struct ttm_bo_device *bdev, man->func = &ttm_bo_manager_func; - ttm_bo_init_mm_base(bdev, man, p_size); + ttm_bo_init_mm_base(man, p_size); drm_mm_init(&rman->mm, 0, p_size); spin_lock_init(&rman->lock); diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c b/drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c index 14430c243ce5..2b60957f7c4a 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c @@ -116,7 +116,7 @@ int vmw_gmrid_man_init(struct vmw_private *dev_priv, int type) man->default_caching = TTM_PL_FLAG_CACHED; /* TODO: This is most likely not correct */ man->use_tt = true; - ttm_bo_init_mm_base(&dev_priv->bdev, man, 0); + ttm_bo_init_mm_base(man, 0); spin_lock_init(&gman->lock); gman->used_gmr_pages = 0; ida_init(&gman->gmr_ida); diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_thp.c b/drivers/gpu/drm/vmwgfx/vmwgfx_thp.c index d2dde8159c3d..d5a3eb709384 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_thp.c +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_thp.c @@ -134,7 +134,7 @@ int vmw_thp_init(struct vmw_private *dev_priv) man->available_caching = TTM_PL_FLAG_CACHED; man->default_caching = TTM_PL_FLAG_CACHED; - ttm_bo_init_mm_base(&dev_priv->bdev, man, + ttm_bo_init_mm_base(man, dev_priv->vram_size >> PAGE_SHIFT); diff --git a/include/drm/ttm/ttm_bo_api.h b/include/drm/ttm/ttm_bo_api.h index 27dde1371376..d6938133535a 100644 --- a/include/drm/ttm/ttm_bo_api.h +++ b/include/drm/ttm/ttm_bo_api.h @@ -547,8 +547,7 @@ int ttm_bo_create(struct ttm_bo_device *bdev, unsigned long size, * May also return driver-specified errors. */ struct ttm_mem_type_manager; -void ttm_bo_init_mm_base(struct ttm_bo_device *bdev, - struct ttm_mem_type_manager *man, +void ttm_bo_init_mm_base(struct ttm_mem_type_manager *man, unsigned long p_size); /** diff --git a/include/drm/ttm/ttm_bo_driver.h b/include/drm/ttm/ttm_bo_driver.h index a38704fe0737..bfc549782775 100644 --- a/include/drm/ttm/ttm_bo_driver.h +++ b/include/drm/ttm/ttm_bo_driver.h @@ -138,8 +138,6 @@ struct ttm_mem_type_manager_func { struct ttm_mem_type_manager { - struct ttm_bo_device *bdev; - /* * No protection. Constant from start. */ From patchwork Fri Jul 31 04:05:18 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Airlie X-Patchwork-Id: 11694051 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id BB58614E3 for ; Fri, 31 Jul 2020 04:07:47 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id A431C2070B for ; Fri, 31 Jul 2020 04:07:47 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A431C2070B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 644106E9C3; Fri, 31 Jul 2020 04:07:46 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from us-smtp-delivery-1.mimecast.com (us-smtp-1.mimecast.com [207.211.31.81]) by gabe.freedesktop.org (Postfix) with ESMTPS id 7CADA6E9BD for ; Fri, 31 Jul 2020 04:07:18 +0000 (UTC) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-391-QoFxzx_ZPhu-2JMclL3vnw-1; Fri, 31 Jul 2020 00:07:13 -0400 X-MC-Unique: QoFxzx_ZPhu-2JMclL3vnw-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id D276557; Fri, 31 Jul 2020 04:07:11 +0000 (UTC) Received: from tyrion-bne-redhat-com.redhat.com (vpn2-54-17.bne.redhat.com [10.64.54.17]) by smtp.corp.redhat.com (Postfix) with ESMTP id 65AC5100238C; Fri, 31 Jul 2020 04:07:10 +0000 (UTC) From: Dave Airlie To: dri-devel@lists.freedesktop.org Subject: [PATCH 47/49] drm/ttm: drop list of memory managers from device. Date: Fri, 31 Jul 2020 14:05:18 +1000 Message-Id: <20200731040520.3701599-48-airlied@gmail.com> In-Reply-To: <20200731040520.3701599-1-airlied@gmail.com> References: <20200731040520.3701599-1-airlied@gmail.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: gmail.com X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: christian.koenig@amd.com, sroland@vmware.com, bskeggs@redhat.com, kraxel@redhat.com Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Dave Airlie The driver now controls these, the core just controls the system memory one. Signed-off-by: Dave Airlie --- drivers/gpu/drm/ttm/ttm_bo.c | 2 -- include/drm/ttm/ttm_bo_driver.h | 6 ++++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c index f2b41c4d7d51..f35548ff17e8 100644 --- a/drivers/gpu/drm/ttm/ttm_bo.c +++ b/drivers/gpu/drm/ttm/ttm_bo.c @@ -1608,8 +1608,6 @@ int ttm_bo_device_init(struct ttm_bo_device *bdev, bdev->driver = driver; - memset(bdev->man_priv, 0, sizeof(bdev->man_priv)); - ttm_bo_init_sysman(bdev); bdev->vma_manager = vma_manager; diff --git a/include/drm/ttm/ttm_bo_driver.h b/include/drm/ttm/ttm_bo_driver.h index bfc549782775..b2ffeaed94e7 100644 --- a/include/drm/ttm/ttm_bo_driver.h +++ b/include/drm/ttm/ttm_bo_driver.h @@ -414,7 +414,7 @@ struct ttm_bo_device { /* * access via ttm_manager_type. */ - struct ttm_mem_type_manager man_priv[TTM_NUM_MEM_TYPES]; + struct ttm_mem_type_manager sysman; /* move to global */ struct ttm_mem_type_manager *man_drv[TTM_NUM_MEM_TYPES]; /* * Protected by internal locks. @@ -446,9 +446,11 @@ struct ttm_bo_device { static inline struct ttm_mem_type_manager *ttm_manager_type(struct ttm_bo_device *bdev, int mem_type) { + if (mem_type == TTM_PL_SYSTEM) + return &bdev->sysman; if (bdev->man_drv[mem_type]) return bdev->man_drv[mem_type]; - return &bdev->man_priv[mem_type]; + return NULL; } static inline void ttm_set_driver_manager(struct ttm_bo_device *bdev, From patchwork Fri Jul 31 04:05:19 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Airlie X-Patchwork-Id: 11694059 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4DFFD14E3 for ; Fri, 31 Jul 2020 04:07:53 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 36BA82070B for ; Fri, 31 Jul 2020 04:07:53 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 36BA82070B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 0E74D6E9CB; Fri, 31 Jul 2020 04:07:47 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from us-smtp-delivery-1.mimecast.com (us-smtp-1.mimecast.com [205.139.110.61]) by gabe.freedesktop.org (Postfix) with ESMTPS id 470326E9BD for ; Fri, 31 Jul 2020 04:07:20 +0000 (UTC) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-480-c0xHUuuNMLK3N-S1FNsWyQ-1; Fri, 31 Jul 2020 00:07:14 -0400 X-MC-Unique: c0xHUuuNMLK3N-S1FNsWyQ-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id AA4AB8015CE; Fri, 31 Jul 2020 04:07:13 +0000 (UTC) Received: from tyrion-bne-redhat-com.redhat.com (vpn2-54-17.bne.redhat.com [10.64.54.17]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3D8B7100238C; Fri, 31 Jul 2020 04:07:12 +0000 (UTC) From: Dave Airlie To: dri-devel@lists.freedesktop.org Subject: [PATCH 48/49] drm/ttm: drop type manager has_type Date: Fri, 31 Jul 2020 14:05:19 +1000 Message-Id: <20200731040520.3701599-49-airlied@gmail.com> In-Reply-To: <20200731040520.3701599-1-airlied@gmail.com> References: <20200731040520.3701599-1-airlied@gmail.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: gmail.com X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: christian.koenig@amd.com, sroland@vmware.com, bskeggs@redhat.com, kraxel@redhat.com Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Dave Airlie under driver control, this flag isn't needed anymore Signed-off-by: Dave Airlie --- drivers/gpu/drm/ttm/ttm_bo.c | 6 ++---- include/drm/ttm/ttm_bo_driver.h | 5 ----- 2 files changed, 2 insertions(+), 9 deletions(-) diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c index f35548ff17e8..bfc20cb27ed6 100644 --- a/drivers/gpu/drm/ttm/ttm_bo.c +++ b/drivers/gpu/drm/ttm/ttm_bo.c @@ -82,7 +82,6 @@ static void ttm_mem_type_debug(struct ttm_bo_device *bdev, struct drm_printer *p { struct ttm_mem_type_manager *man = ttm_manager_type(bdev, mem_type); - drm_printf(p, " has_type: %d\n", man->has_type); drm_printf(p, " use_type: %d\n", man->use_type); drm_printf(p, " use_tt: %d\n", man->use_tt); drm_printf(p, " size: %llu\n", man->size); @@ -997,7 +996,7 @@ static int ttm_bo_mem_placement(struct ttm_buffer_object *bo, return ret; man = ttm_manager_type(bdev, mem_type); - if (!man->has_type || !man->use_type) + if (!man || !man->use_type) return -EBUSY; if (!ttm_bo_mt_compatible(man, mem_type, place, &cur_flags)) @@ -1455,7 +1454,7 @@ int ttm_bo_evict_mm(struct ttm_bo_device *bdev, unsigned mem_type) return -EINVAL; } - if (!man->has_type) { + if (!man) { pr_err("Memory type %u has not been initialized\n", mem_type); return 0; } @@ -1469,7 +1468,6 @@ void ttm_bo_init_mm_base(struct ttm_mem_type_manager *man, { unsigned i; - BUG_ON(man->has_type); man->use_io_reserve_lru = false; mutex_init(&man->io_reserve_mutex); spin_lock_init(&man->move_lock); diff --git a/include/drm/ttm/ttm_bo_driver.h b/include/drm/ttm/ttm_bo_driver.h index b2ffeaed94e7..702b3b056eda 100644 --- a/include/drm/ttm/ttm_bo_driver.h +++ b/include/drm/ttm/ttm_bo_driver.h @@ -111,7 +111,6 @@ struct ttm_mem_type_manager_func { /** * struct ttm_mem_type_manager * - * @has_type: The memory type has been initialized. * @use_type: The memory type is enabled. * @flags: TTM_MEMTYPE_XX flags identifying the traits of the memory * managed by this memory type. @@ -141,8 +140,6 @@ struct ttm_mem_type_manager { /* * No protection. Constant from start. */ - - bool has_type; bool use_type; bool use_tt; uint64_t size; @@ -673,13 +670,11 @@ static inline void ttm_bo_unreserve(struct ttm_buffer_object *bo) static inline void ttm_bo_use_mm(struct ttm_mem_type_manager *man) { - man->has_type = true; man->use_type = true; } static inline void ttm_bo_disable_mm(struct ttm_mem_type_manager *man) { - man->has_type = false; man->use_type = false; } From patchwork Fri Jul 31 04:05:20 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Airlie X-Patchwork-Id: 11694045 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 552A714E3 for ; Fri, 31 Jul 2020 04:07:35 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 3DC6621775 for ; Fri, 31 Jul 2020 04:07:35 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3DC6621775 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id E52366E9BE; Fri, 31 Jul 2020 04:07:33 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from us-smtp-delivery-1.mimecast.com (us-smtp-1.mimecast.com [205.139.110.61]) by gabe.freedesktop.org (Postfix) with ESMTPS id E1A236E9BE for ; Fri, 31 Jul 2020 04:07:22 +0000 (UTC) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-408-HwZVyl1yOJG1eKV88O42Qg-1; Fri, 31 Jul 2020 00:07:16 -0400 X-MC-Unique: HwZVyl1yOJG1eKV88O42Qg-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 83B6F8064AF; Fri, 31 Jul 2020 04:07:15 +0000 (UTC) Received: from tyrion-bne-redhat-com.redhat.com (vpn2-54-17.bne.redhat.com [10.64.54.17]) by smtp.corp.redhat.com (Postfix) with ESMTP id 159121001281; Fri, 31 Jul 2020 04:07:13 +0000 (UTC) From: Dave Airlie To: dri-devel@lists.freedesktop.org Subject: [PATCH 49/49] drm/ttm: consolidate manager used apis into a set and get. Date: Fri, 31 Jul 2020 14:05:20 +1000 Message-Id: <20200731040520.3701599-50-airlied@gmail.com> In-Reply-To: <20200731040520.3701599-1-airlied@gmail.com> References: <20200731040520.3701599-1-airlied@gmail.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: gmail.com X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: christian.koenig@amd.com, sroland@vmware.com, bskeggs@redhat.com, kraxel@redhat.com Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Dave Airlie This is probably something we could consider removing, vmwgfx is the only user, and we might be able to faciliate it another way but for now just consolidate it all into accessors. Signed-off-by: Dave Airlie --- drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c | 4 ++-- drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c | 4 ++-- drivers/gpu/drm/nouveau/nouveau_ttm.c | 8 ++++---- drivers/gpu/drm/ttm/ttm_bo.c | 6 +++--- drivers/gpu/drm/ttm/ttm_bo_manager.c | 4 ++-- drivers/gpu/drm/vmwgfx/vmwgfx_drv.c | 14 +++++++------- drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c | 4 ++-- drivers/gpu/drm/vmwgfx/vmwgfx_thp.c | 4 ++-- include/drm/ttm/ttm_bo_driver.h | 8 ++++---- 9 files changed, 28 insertions(+), 28 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c index b4480ca30988..7e84aa2c0064 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c @@ -128,7 +128,7 @@ int amdgpu_gtt_mgr_init(struct amdgpu_device *adev, uint64_t gtt_size) } ttm_set_driver_manager(&adev->mman.bdev, TTM_PL_TT, &mgr->manager); - ttm_bo_use_mm(man); + ttm_mm_set_use(man, true); return 0; } @@ -146,7 +146,7 @@ void amdgpu_gtt_mgr_fini(struct amdgpu_device *adev) struct amdgpu_gtt_mgr *mgr = to_gtt_mgr(man); int ret; - ttm_bo_disable_mm(man); + ttm_mm_set_use(man, false); ret = ttm_bo_force_list_clean(&adev->mman.bdev, man); if (ret) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c index f0e65a6fdf88..50949aa968fd 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c @@ -205,7 +205,7 @@ int amdgpu_vram_mgr_init(struct amdgpu_device *adev) DRM_ERROR("Failed to register sysfs\n"); ttm_set_driver_manager(&adev->mman.bdev, TTM_PL_VRAM, &mgr->manager); - ttm_bo_use_mm(man); + ttm_mm_set_use(man, true); return 0; } @@ -223,7 +223,7 @@ void amdgpu_vram_mgr_fini(struct amdgpu_device *adev) struct amdgpu_vram_mgr *mgr = to_vram_mgr(man); int ret; - ttm_bo_disable_mm(man); + ttm_mm_set_use(man, false); ret = ttm_bo_force_list_clean(&adev->mman.bdev, man); if (ret) diff --git a/drivers/gpu/drm/nouveau/nouveau_ttm.c b/drivers/gpu/drm/nouveau/nouveau_ttm.c index 89521d3ed9da..32ce930d1bd8 100644 --- a/drivers/gpu/drm/nouveau/nouveau_ttm.c +++ b/drivers/gpu/drm/nouveau/nouveau_ttm.c @@ -176,7 +176,7 @@ nouveau_ttm_init_vram(struct nouveau_drm *drm) man->use_io_reserve_lru = true; ttm_bo_init_mm_base(man, drm->gem.vram_available >> PAGE_SHIFT); ttm_set_driver_manager(&drm->ttm.bdev, TTM_PL_VRAM, man); - ttm_bo_use_mm(man); + ttm_mm_set_use(man, true); return 0; } else { return ttm_bo_man_init(&drm->ttm.bdev, TTM_PL_VRAM, @@ -192,7 +192,7 @@ nouveau_ttm_fini_vram(struct nouveau_drm *drm) struct ttm_mem_type_manager *man = ttm_manager_type(&drm->ttm.bdev, TTM_PL_VRAM); if (drm->client.device.info.family >= NV_DEVICE_INFO_V0_TESLA) { - ttm_bo_disable_mm(man); + ttm_mm_set_use(man, false); ttm_bo_force_list_clean(&drm->ttm.bdev, man); ttm_bo_man_cleanup(man); ttm_set_driver_manager(&drm->ttm.bdev, TTM_PL_VRAM, NULL); @@ -237,7 +237,7 @@ nouveau_ttm_init_gtt(struct nouveau_drm *drm) man->use_tt = true; ttm_bo_init_mm_base(man, size_pages); ttm_set_driver_manager(&drm->ttm.bdev, TTM_PL_TT, man); - ttm_bo_use_mm(man); + ttm_mm_set_use(man, true); return 0; } @@ -250,7 +250,7 @@ nouveau_ttm_fini_gtt(struct nouveau_drm *drm) drm->agp.bridge) ttm_bo_man_takedown(&drm->ttm.bdev, TTM_PL_TT); else { - ttm_bo_disable_mm(man); + ttm_mm_set_use(man, false); ttm_bo_force_list_clean(&drm->ttm.bdev, man); ttm_bo_man_cleanup(man); ttm_set_driver_manager(&drm->ttm.bdev, TTM_PL_TT, NULL); diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c index bfc20cb27ed6..3bec6e4bc87d 100644 --- a/drivers/gpu/drm/ttm/ttm_bo.c +++ b/drivers/gpu/drm/ttm/ttm_bo.c @@ -996,7 +996,7 @@ static int ttm_bo_mem_placement(struct ttm_buffer_object *bo, return ret; man = ttm_manager_type(bdev, mem_type); - if (!man || !man->use_type) + if (!man || !ttm_mm_used(man)) return -EBUSY; if (!ttm_bo_mt_compatible(man, mem_type, place, &cur_flags)) @@ -1548,7 +1548,7 @@ int ttm_bo_device_release(struct ttm_bo_device *bdev) struct ttm_mem_type_manager *man; man = ttm_manager_type(bdev, TTM_PL_SYSTEM); - ttm_bo_disable_mm(man); + ttm_mm_set_use(man, false); mutex_lock(&ttm_global_mutex); list_del(&bdev->device_list); @@ -1585,7 +1585,7 @@ static void ttm_bo_init_sysman(struct ttm_bo_device *bdev) man->default_caching = TTM_PL_FLAG_CACHED; ttm_bo_init_mm_base(man, 0); - ttm_bo_use_mm(man); + ttm_mm_set_use(man, true); } int ttm_bo_device_init(struct ttm_bo_device *bdev, diff --git a/drivers/gpu/drm/ttm/ttm_bo_manager.c b/drivers/gpu/drm/ttm/ttm_bo_manager.c index 6c6eedf84ca6..5ed4e4317789 100644 --- a/drivers/gpu/drm/ttm/ttm_bo_manager.c +++ b/drivers/gpu/drm/ttm/ttm_bo_manager.c @@ -139,7 +139,7 @@ int ttm_bo_man_init(struct ttm_bo_device *bdev, spin_lock_init(&rman->lock); ttm_set_driver_manager(bdev, type, &rman->manager); - ttm_bo_use_mm(man); + ttm_mm_set_use(man, true); return 0; } EXPORT_SYMBOL(ttm_bo_man_init); @@ -152,7 +152,7 @@ int ttm_bo_man_takedown(struct ttm_bo_device *bdev, struct drm_mm *mm = &rman->mm; int ret; - ttm_bo_disable_mm(man); + ttm_mm_set_use(man, false); ret = ttm_bo_force_list_clean(bdev, man); if (ret) diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c index 1849d913d521..9b9cc3b57a24 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c @@ -630,7 +630,7 @@ static int vmw_init_vram_manager(struct vmw_private *dev_priv) TTM_PL_FLAG_CACHED, TTM_PL_FLAG_CACHED, false, dev_priv->vram_size >> PAGE_SHIFT); #endif - ttm_manager_type(&dev_priv->bdev, TTM_PL_VRAM)->use_type = false; + ttm_mm_set_use(ttm_manager_type(&dev_priv->bdev, TTM_PL_VRAM), false); return ret; } @@ -1190,9 +1190,9 @@ static void __vmw_svga_enable(struct vmw_private *dev_priv) struct ttm_mem_type_manager *man = ttm_manager_type(&dev_priv->bdev, TTM_PL_VRAM); spin_lock(&dev_priv->svga_lock); - if (!man->use_type) { + if (!ttm_mm_used(man)) { vmw_write(dev_priv, SVGA_REG_ENABLE, SVGA_REG_ENABLE); - man->use_type = true; + ttm_mm_set_use(man, true); } spin_unlock(&dev_priv->svga_lock); } @@ -1221,8 +1221,8 @@ static void __vmw_svga_disable(struct vmw_private *dev_priv) struct ttm_mem_type_manager *man = ttm_manager_type(&dev_priv->bdev, TTM_PL_VRAM); spin_lock(&dev_priv->svga_lock); - if (man->use_type) { - man->use_type = false; + if (ttm_mm_used(man)) { + ttm_mm_set_use(man, false); vmw_write(dev_priv, SVGA_REG_ENABLE, SVGA_REG_ENABLE_HIDE | SVGA_REG_ENABLE_ENABLE); @@ -1255,8 +1255,8 @@ void vmw_svga_disable(struct vmw_private *dev_priv) vmw_kms_lost_device(dev_priv->dev); ttm_write_lock(&dev_priv->reservation_sem, false); spin_lock(&dev_priv->svga_lock); - if (man->use_type) { - man->use_type = false; + if (ttm_mm_used(man)) { + ttm_mm_set_use(man, false); spin_unlock(&dev_priv->svga_lock); if (ttm_bo_evict_mm(&dev_priv->bdev, TTM_PL_VRAM)) DRM_ERROR("Failed evicting VRAM buffers.\n"); diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c b/drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c index 2b60957f7c4a..aff7767762ed 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c @@ -135,7 +135,7 @@ int vmw_gmrid_man_init(struct vmw_private *dev_priv, int type) } ttm_set_driver_manager(&dev_priv->bdev, type, &gman->manager); - ttm_bo_use_mm(man); + ttm_mm_set_use(man, true); return 0; } @@ -144,7 +144,7 @@ void vmw_gmrid_man_takedown(struct vmw_private *dev_priv, int type) struct ttm_mem_type_manager *man = ttm_manager_type(&dev_priv->bdev, type); struct vmwgfx_gmrid_man *gman = to_gmrid_manager(man); - ttm_bo_disable_mm(man); + ttm_mm_set_use(man, false); ttm_bo_force_list_clean(&dev_priv->bdev, man); diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_thp.c b/drivers/gpu/drm/vmwgfx/vmwgfx_thp.c index d5a3eb709384..5a7b9b09785c 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_thp.c +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_thp.c @@ -142,7 +142,7 @@ int vmw_thp_init(struct vmw_private *dev_priv) spin_lock_init(&rman->lock); ttm_set_driver_manager(&dev_priv->bdev, TTM_PL_VRAM, &rman->manager); - ttm_bo_use_mm(man); + ttm_mm_set_use(man, true); return 0; } @@ -153,7 +153,7 @@ void vmw_thp_takedown(struct vmw_private *dev_priv) struct drm_mm *mm = &rman->mm; int ret; - ttm_bo_disable_mm(man); + ttm_mm_set_use(man, false); ret = ttm_bo_force_list_clean(&dev_priv->bdev, man); if (ret) diff --git a/include/drm/ttm/ttm_bo_driver.h b/include/drm/ttm/ttm_bo_driver.h index 702b3b056eda..6210acd5c651 100644 --- a/include/drm/ttm/ttm_bo_driver.h +++ b/include/drm/ttm/ttm_bo_driver.h @@ -668,14 +668,14 @@ static inline void ttm_bo_unreserve(struct ttm_buffer_object *bo) dma_resv_unlock(bo->base.resv); } -static inline void ttm_bo_use_mm(struct ttm_mem_type_manager *man) +static inline void ttm_mm_set_use(struct ttm_mem_type_manager *man, bool use) { - man->use_type = true; + man->use_type = use; } -static inline void ttm_bo_disable_mm(struct ttm_mem_type_manager *man) +static inline bool ttm_mm_used(struct ttm_mem_type_manager *man) { - man->use_type = false; + return man->use_type; } static inline void ttm_bo_man_cleanup(struct ttm_mem_type_manager *man)