From patchwork Wed Oct 19 15:27:31 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Somalapuram Amaranath X-Patchwork-Id: 13017612 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 22B4AECAAA1 for ; Mon, 24 Oct 2022 13:24:08 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 7262910E6E4; Mon, 24 Oct 2022 13:23:43 +0000 (UTC) Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2059.outbound.protection.outlook.com [40.107.243.59]) by gabe.freedesktop.org (Postfix) with ESMTPS id 2D9FE10F278; Wed, 19 Oct 2022 15:28:25 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=BBfpMRimrYYyGO2jvw31jLb3nuDUz9T8sqX7ZBTnlWSWlAx+3rW78ysG7az6L6Ca/gJGWdHTnCW2ZqtrwreyogUrHYYEWXiVuSYtbOxgS1U92YEGsbYnyzy5QvGMplJxs7eThgGIB7ZidjPCUXFbRaIsPhaMOdZQ3fyooLF8hsRQ4OFDLOv3zK6e4MCMlqvufDEefQgom03RUN4scS+ipdpxg/z01jKLpifYpgjk8uisAfyfrrQAHZi2dy7vio6nytnsVQugMlJ+ahZw8sfYuVhFLuHvcYeU+nlSJIpws9zpsuMcPX00OOcxaCRqv0BGXcOGevsJzkyQt7nNSx8UsA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=7mLgxSdMRC/oOsrVgU/r6OiUgX67D+x8v3cjge2PGvY=; b=Ovbs1fx+MsT/2AGd4a1D72sOy5oAJPsZgxdfGGX+Xqay0XmznylDG2Wk/TAtZ4/BM0s0QqBipPaQxqFKc6sfFkf0IlW9Ab3K6dcmQke2/AsPPss264sc7hxWFvcOmIF4xp6Sewwhczw9FwvpTPST47I1ci3x+XR+CwLbuI+vgukGyZjIExXeMMM2+jH5yU9t3HDKT+FUAnGlxLWgRErhz6DBKpkZKhfMi0shWYbhHmB4W8mWMQtxgzk20KeCc0RSei56+PEjqZJaF/sBQjQyZXuBQb96SyliKE/hlzZT+V36abVJTXmvErqd/uVW9r0hvRMkvtM6uPkRLxbCJHAPgA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.freedesktop.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=7mLgxSdMRC/oOsrVgU/r6OiUgX67D+x8v3cjge2PGvY=; b=26CmjupIxILlHWffmsJzJm6GxrKICSTP9oklfYH37zumQEwm415UKs6sRKwT6uLS/KmnAhjR4jSfJKru4BM4VAeVcCC2KPd/mW9m2HJQUhAf2UwDym1aR3W1vgB7M6quUOjF/HEaUueC/y1NR9XyCHXpQtK5xiGm1tp9oDtbV5M= Received: from DM6PR04CA0026.namprd04.prod.outlook.com (2603:10b6:5:334::31) by MW4PR12MB5602.namprd12.prod.outlook.com (2603:10b6:303:169::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5723.33; Wed, 19 Oct 2022 15:28:23 +0000 Received: from DM6NAM11FT081.eop-nam11.prod.protection.outlook.com (2603:10b6:5:334:cafe::57) by DM6PR04CA0026.outlook.office365.com (2603:10b6:5:334::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5723.34 via Frontend Transport; Wed, 19 Oct 2022 15:28:22 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by DM6NAM11FT081.mail.protection.outlook.com (10.13.172.136) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5746.16 via Frontend Transport; Wed, 19 Oct 2022 15:28:22 +0000 Received: from amar-X570-AORUS-ELITE.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Wed, 19 Oct 2022 10:28:18 -0500 From: Somalapuram Amaranath To: , , , Date: Wed, 19 Oct 2022 20:57:31 +0530 Message-ID: <20221019152736.654451-1-Amaranath.Somalapuram@amd.com> X-Mailer: git-send-email 2.32.0 MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6NAM11FT081:EE_|MW4PR12MB5602:EE_ X-MS-Office365-Filtering-Correlation-Id: 4040917f-4672-4115-be2e-08dab1e68f16 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: SPpnTVUFiO6fL8V99C0hjDcMV0jKdpLuLuDw6bwt2GuM7rLP/jmjGmhynlNZMTAkVMwtpg0bDw6ieRg26cCCqfFD7KqYwMIaRAFba3AXLRPerQUIwjthO3FDDPNoKy9Uab7xBQc8VzQ+pjZ3oV1plG+oLnXN4XbgCSF8rbaCnI5czNd4xauv8ljFkK7hHBgdBkAhvJgkklK2I0cAReu7xFTDcYz3oiszr3jrP3+2Ftmuyaw7xlt9sz1HzbDqLk8Czg/WizzbM1joktRyc2wdrxP2oB/8V9j3Vbt5F6z27jZAJdtP2Bck31kr+/anmYfC8F0aU0Xq/R2GtCPEW3qhzwts9v3nDzHKO95NuKmE4fkUjmj7bxc5A/KuRSfZreKH8nL8kLm3DAKY4njwF9gOb4zUjOwyJw61GxSdr2sglrdxUr9Ja6eexwPxhHZai4Q4RHELf3mTqkZ/CIKd6WOGsPxXAxSjDnf5MR8HmYuF5TEKEXfj+7kPZtHoU7nToY6H4VQrWlxWJCniJyP1pRPuvgsRU3WEgQ8j64y8Tx7AdrCBpToepuHsMrReRQDgXwgagWouTrQCfxdzYL0GqQ8ii7zHBHnoe8ksnKKRCcQjkmugP+8aiO1p9IT+uWxp0CJ1J8uWGSc3cFtk1oXpvcwVtOJGkiRH0H2Clh7AooYgo0QvEPNYutfZMKQxIT5PpcgFL7N/cKpVpqyHih1uDSgoUHa7GJxoLF/EpORN4etOKQv44CBZLKlHt2Y6MTKYkLxUBWGJvvR0jt049QsRXLkyV2RbcBbEbVq56x6GnUpstviwMbUSCZPOMXhhdA8gShuv X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230022)(4636009)(39860400002)(396003)(346002)(136003)(376002)(451199015)(40470700004)(36840700001)(46966006)(5660300002)(81166007)(2906002)(8936002)(356005)(40480700001)(82740400003)(41300700001)(40460700003)(4326008)(36860700001)(36756003)(8676002)(70206006)(70586007)(83380400001)(110136005)(316002)(47076005)(54906003)(86362001)(2616005)(426003)(336012)(1076003)(16526019)(186003)(450100002)(26005)(82310400005)(478600001)(7696005)(6666004)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Oct 2022 15:28:22.6792 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 4040917f-4672-4115-be2e-08dab1e68f16 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d; Ip=[165.204.84.17]; Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: DM6NAM11FT081.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW4PR12MB5602 X-Mailman-Approved-At: Mon, 24 Oct 2022 13:23:26 +0000 Subject: [Intel-gfx] [PATCH 1/6] drm/ttm: rework on ttm_resource to use size_t type X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: alexander.deucher@amd.com, Somalapuram Amaranath , arunpravin.paneerselvam@amd.com, christian.koenig@amd.com Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" Change ttm_resource structure from num_pages to size_t size in bytes. Signed-off-by: Somalapuram Amaranath --- drivers/gpu/drm/ttm/ttm_bo.c | 4 ++-- drivers/gpu/drm/ttm/ttm_bo_util.c | 6 +++--- drivers/gpu/drm/ttm/ttm_bo_vm.c | 4 ++-- drivers/gpu/drm/ttm/ttm_range_manager.c | 2 +- drivers/gpu/drm/ttm/ttm_resource.c | 8 ++++---- include/drm/ttm/ttm_resource.h | 2 +- 6 files changed, 13 insertions(+), 13 deletions(-) diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c index 7c8e8be774f1..394ccb13eaed 100644 --- a/drivers/gpu/drm/ttm/ttm_bo.c +++ b/drivers/gpu/drm/ttm/ttm_bo.c @@ -51,8 +51,8 @@ static void ttm_bo_mem_space_debug(struct ttm_buffer_object *bo, struct ttm_resource_manager *man; int i, mem_type; - drm_printf(&p, "No space for %p (%lu pages, %zuK, %zuM)\n", - bo, bo->resource->num_pages, bo->base.size >> 10, + drm_printf(&p, "No space for %p (%lu size, %zuK, %zuM)\n", + bo, bo->resource->size, bo->base.size >> 10, bo->base.size >> 20); for (i = 0; i < placement->num_placement; i++) { mem_type = placement->placement[i].mem_type; diff --git a/drivers/gpu/drm/ttm/ttm_bo_util.c b/drivers/gpu/drm/ttm/ttm_bo_util.c index fa04e62202c1..da5493f789df 100644 --- a/drivers/gpu/drm/ttm/ttm_bo_util.c +++ b/drivers/gpu/drm/ttm/ttm_bo_util.c @@ -173,7 +173,7 @@ int ttm_bo_move_memcpy(struct ttm_buffer_object *bo, clear = src_iter->ops->maps_tt && (!ttm || !ttm_tt_is_populated(ttm)); if (!(clear && ttm && !(ttm->page_flags & TTM_TT_FLAG_ZERO_ALLOC))) - ttm_move_memcpy(clear, dst_mem->num_pages, dst_iter, src_iter); + ttm_move_memcpy(clear, PFN_UP(dst_mem->size), dst_iter, src_iter); if (!src_iter->ops->maps_tt) ttm_kmap_iter_linear_io_fini(&_src_iter.io, bdev, src_mem); @@ -357,9 +357,9 @@ int ttm_bo_kmap(struct ttm_buffer_object *bo, map->virtual = NULL; map->bo = bo; - if (num_pages > bo->resource->num_pages) + if (num_pages > PFN_UP(bo->resource->size)) return -EINVAL; - if ((start_page + num_pages) > bo->resource->num_pages) + if ((start_page + num_pages) > PFN_UP(bo->resource->size)) return -EINVAL; ret = ttm_mem_io_reserve(bo->bdev, bo->resource); diff --git a/drivers/gpu/drm/ttm/ttm_bo_vm.c b/drivers/gpu/drm/ttm/ttm_bo_vm.c index 38119311284d..876e7d07273c 100644 --- a/drivers/gpu/drm/ttm/ttm_bo_vm.c +++ b/drivers/gpu/drm/ttm/ttm_bo_vm.c @@ -217,7 +217,7 @@ vm_fault_t ttm_bo_vm_fault_reserved(struct vm_fault *vmf, page_last = vma_pages(vma) + vma->vm_pgoff - drm_vma_node_start(&bo->base.vma_node); - if (unlikely(page_offset >= bo->resource->num_pages)) + if (unlikely(page_offset >= PFN_UP(bo->resource->size))) return VM_FAULT_SIGBUS; prot = ttm_io_prot(bo, bo->resource, prot); @@ -412,7 +412,7 @@ int ttm_bo_vm_access(struct vm_area_struct *vma, unsigned long addr, << PAGE_SHIFT); int ret; - if (len < 1 || (offset + len) >> PAGE_SHIFT > bo->resource->num_pages) + if (len < 1 || (offset + len) > bo->resource->size) return -EIO; ret = ttm_bo_reserve(bo, true, false, NULL); diff --git a/drivers/gpu/drm/ttm/ttm_range_manager.c b/drivers/gpu/drm/ttm/ttm_range_manager.c index f7c16c46cfbc..0a8bc0b7f380 100644 --- a/drivers/gpu/drm/ttm/ttm_range_manager.c +++ b/drivers/gpu/drm/ttm/ttm_range_manager.c @@ -83,7 +83,7 @@ static int ttm_range_man_alloc(struct ttm_resource_manager *man, spin_lock(&rman->lock); ret = drm_mm_insert_node_in_range(mm, &node->mm_nodes[0], - node->base.num_pages, + PFN_UP(node->base.size), bo->page_alignment, 0, place->fpfn, lpfn, mode); spin_unlock(&rman->lock); diff --git a/drivers/gpu/drm/ttm/ttm_resource.c b/drivers/gpu/drm/ttm/ttm_resource.c index a729c32a1e48..f9cce0727d40 100644 --- a/drivers/gpu/drm/ttm/ttm_resource.c +++ b/drivers/gpu/drm/ttm/ttm_resource.c @@ -177,7 +177,7 @@ void ttm_resource_init(struct ttm_buffer_object *bo, struct ttm_resource_manager *man; res->start = 0; - res->num_pages = PFN_UP(bo->base.size); + res->size = bo->base.size; res->mem_type = place->mem_type; res->placement = place->flags; res->bus.addr = NULL; @@ -192,7 +192,7 @@ void ttm_resource_init(struct ttm_buffer_object *bo, list_add_tail(&res->lru, &bo->bdev->pinned); else list_add_tail(&res->lru, &man->lru[bo->priority]); - man->usage += res->num_pages << PAGE_SHIFT; + man->usage += res->size; spin_unlock(&bo->bdev->lru_lock); } EXPORT_SYMBOL(ttm_resource_init); @@ -214,7 +214,7 @@ void ttm_resource_fini(struct ttm_resource_manager *man, spin_lock(&bdev->lru_lock); list_del_init(&res->lru); - man->usage -= res->num_pages << PAGE_SHIFT; + man->usage -= res->size; spin_unlock(&bdev->lru_lock); } EXPORT_SYMBOL(ttm_resource_fini); @@ -665,7 +665,7 @@ ttm_kmap_iter_linear_io_init(struct ttm_kmap_iter_linear_io *iter_io, iosys_map_set_vaddr(&iter_io->dmap, mem->bus.addr); iter_io->needs_unmap = false; } else { - size_t bus_size = (size_t)mem->num_pages << PAGE_SHIFT; + size_t bus_size = (size_t)mem->size; iter_io->needs_unmap = true; memset(&iter_io->dmap, 0, sizeof(iter_io->dmap)); diff --git a/include/drm/ttm/ttm_resource.h b/include/drm/ttm/ttm_resource.h index 5afc6d664fde..f93c9e52b063 100644 --- a/include/drm/ttm/ttm_resource.h +++ b/include/drm/ttm/ttm_resource.h @@ -208,7 +208,7 @@ struct ttm_bus_placement { */ struct ttm_resource { unsigned long start; - unsigned long num_pages; + size_t size; uint32_t mem_type; uint32_t placement; struct ttm_bus_placement bus; From patchwork Wed Oct 19 15:27:32 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Somalapuram Amaranath X-Patchwork-Id: 13017609 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 60E77C38A2D for ; Mon, 24 Oct 2022 13:24:04 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id B749910E6E6; Mon, 24 Oct 2022 13:23:43 +0000 (UTC) Received: from NAM02-BN1-obe.outbound.protection.outlook.com (mail-bn1nam07on2057.outbound.protection.outlook.com [40.107.212.57]) by gabe.freedesktop.org (Postfix) with ESMTPS id A740510EAED; Wed, 19 Oct 2022 15:28:31 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=nV08Zx03+Yt7lKM1B1pj9kh6sj+27lviYmIkGIdfaWfuqYEujvIE/brrbS474ltTOtdQlcUOSp07IJ/UECFrKygBuMgnv7ezyyoghsWQr63ZYb4V4dg4ObKDSzAcjFTCasaPQM4NTFxyPTe+zuD1Aj/7XhzfGD8+X+J9/vQlunL8c7g4fXOQ2wpwb3IMW6p1UUygXEGAl0rdSuBYym4IYdrdUDuoXI9Ve4wBP3pHmmGndsrKeAxGp9V0UKTFl+gxt504tNzDJ6P4fPu1wiaNF34CNTqyRzikYwUJWLYxpx5E+fa13r4cZl2DW87yg2cM96moNzBy0CPRJHJEEiFNaw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=6xVXkaHPEyPG35RS7y+3GJr7a1+kxSEoE3DrxQRFy+U=; b=ZJyYtco0hlYA7BRG39GKHEMsgnnmhpMWfjQSgBdsZbTVFfiSu9W6s1yx8/I5qgW9O3k+1NSCiFrvdRvU3j+46dL3UAlwbFpSMt+MgDhc3YODgO9GcdYVkca0VjkxN9CG1bHWhGhtaFDEbKnfVzGJ7esXpmycXiDBck1P+ahhu1C1uGikc5+RLquI6kHH6j6Rsz+7PsFPUvfiBLbmSFvHSI7aJn91DQ2+vonDp+ZkcFvvX0Xhe9yrqseeuNpaJEmgJ6b2T8ijvII9RNJVz6TL1hrdX0hbqGXZFA326cZi9euIEDHZ0jSNTddd3bgcyNX+Y5DpsRySU/Iij/62jVSlZA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.freedesktop.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=6xVXkaHPEyPG35RS7y+3GJr7a1+kxSEoE3DrxQRFy+U=; b=XEWuEuBirtuNJ3GUrQ9mK+py/1IHgT1XW6lLi9KLwmKgBxPnDlsfzovxYMr5NvG3sXcS1i0jwZB1Qkw76pqCrnHlMEreEBM15hpvRlbgF9uqVgC3PGBOUbpTEJ9TmaDkS8kibUGWogd/x56eTCGNFA/0hlFU+nZE7/WFsCdmMZw= Received: from DM6PR07CA0098.namprd07.prod.outlook.com (2603:10b6:5:337::31) by BL1PR12MB5972.namprd12.prod.outlook.com (2603:10b6:208:39b::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5723.29; Wed, 19 Oct 2022 15:28:28 +0000 Received: from DM6NAM11FT101.eop-nam11.prod.protection.outlook.com (2603:10b6:5:337:cafe::b9) by DM6PR07CA0098.outlook.office365.com (2603:10b6:5:337::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5723.34 via Frontend Transport; Wed, 19 Oct 2022 15:28:28 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by DM6NAM11FT101.mail.protection.outlook.com (10.13.172.208) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5746.16 via Frontend Transport; Wed, 19 Oct 2022 15:28:28 +0000 Received: from amar-X570-AORUS-ELITE.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Wed, 19 Oct 2022 10:28:25 -0500 From: Somalapuram Amaranath To: , , , Date: Wed, 19 Oct 2022 20:57:32 +0530 Message-ID: <20221019152736.654451-2-Amaranath.Somalapuram@amd.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20221019152736.654451-1-Amaranath.Somalapuram@amd.com> References: <20221019152736.654451-1-Amaranath.Somalapuram@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6NAM11FT101:EE_|BL1PR12MB5972:EE_ X-MS-Office365-Filtering-Correlation-Id: 2a22fe4b-74e1-4740-93c6-08dab1e69280 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Sqhqdgpze++26H76kT6WjNsqnqB6ew3+1ZTa1s5tHuPrwrkL9hudMh/0Auzh6FOl1bwbWurQKqntngJfdR+EHzmawPp5BfvOJfVNU6TnJ2+XnSjExxEfZTh8RBfsioM7d53GKW8fMnLEGS0lKF5kcF+pn6KbYeKk6vSu3MYmSavTeaGj2qECCzGbqZzJHWO4Z6jVt1AkYh0iKHG0YKIPkACqDE2MHdzEPB9bz1UlPnMVRGg2ASx3gVMiWVI7VnqumI1/vFiS9zBw0X4cPtb8zgXDjp/p/n8jBaYWri7YohrCC693xkqFgX3UiVpIUiC+nZlkzQH/vUeg3hB1zFh6o6Ukf3IVsbm/WTxCi4wEiBGgoCohv/lbnpTpFF3M8YS5Ye3PoA2cI2CXGWDpZ82yNxzJoiE9rWgoYuaFHF2SehdtkQ+yTKJw2dl0Y/rERFtIVFqGQiL08hS4Kd5/AWOC132wDWK63zgN6y4nfjBcHogxVA8gtixvsTLzQ/Pzr+Xoy3Qcm3CgTw1FkzolwnH1vjL8A5tvq+Z5OvLwr1hm/pN+bwlcjSwTOwm8AQsTQTIrUsRw7WYVtXElAeoVLz4M6gwU8qA4PqgYyKBhz/Sjsdg1SJu0Zk1IyTv+ldPdTdhLHvOJKZpeKzkR62LlwQpd72jrAIw0P0xCvjxfGwGEKtEFgmcZ+iF/hKcYF1dd4g9NmNPcZ2m/A92DnnPDS1VcEvIJWRBftXNPcNKwJ8HkrW5UdVwhVZxyJh6Ctp9LnkIeY2ec6NrH9vJ/bhbVw53S0NY7R1qumnWSAFUphG8wkw8= X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230022)(4636009)(39860400002)(346002)(376002)(136003)(396003)(451199015)(40470700004)(46966006)(36840700001)(8936002)(26005)(82740400003)(81166007)(356005)(86362001)(316002)(70206006)(36860700001)(54906003)(70586007)(4326008)(450100002)(110136005)(5660300002)(2906002)(41300700001)(40460700003)(426003)(47076005)(2616005)(16526019)(1076003)(82310400005)(186003)(83380400001)(478600001)(6666004)(7696005)(336012)(40480700001)(36756003)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Oct 2022 15:28:28.3903 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 2a22fe4b-74e1-4740-93c6-08dab1e69280 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d; Ip=[165.204.84.17]; Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: DM6NAM11FT101.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL1PR12MB5972 X-Mailman-Approved-At: Mon, 24 Oct 2022 13:23:26 +0000 Subject: [Intel-gfx] =?utf-8?q?=5BPATCH_2/6=5D_drm/amd=3A_fix=E2=80=99s_on_t?= =?utf-8?q?tm=5Fresource_rework_to_use_size=5Ft_type?= X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: alexander.deucher@amd.com, Somalapuram Amaranath , arunpravin.paneerselvam@amd.com, christian.koenig@amd.com Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" Fix the ttm_resource from num_pages to size_t size. Signed-off-by: Somalapuram Amaranath --- drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c | 2 +- drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 3 ++- drivers/gpu/drm/amd/amdgpu/amdgpu_res_cursor.h | 4 ++-- drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h | 2 +- drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 6 +++--- drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c | 8 ++++---- 6 files changed, 13 insertions(+), 12 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c index 1f3302aebeff..44367f03316f 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c @@ -144,7 +144,7 @@ static int amdgpu_gtt_mgr_new(struct ttm_resource_manager *man, node->base.start = node->mm_nodes[0].start; } else { node->mm_nodes[0].start = 0; - node->mm_nodes[0].size = node->base.num_pages; + node->mm_nodes[0].size = PFN_UP(node->base.size); node->base.start = AMDGPU_BO_INVALID_OFFSET; } diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c index 2e8f6cd7a729..e51f80bb1d07 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c @@ -542,6 +542,7 @@ int amdgpu_bo_create(struct amdgpu_device *adev, /* GWS and OA don't need any alignment. */ page_align = bp->byte_align; size <<= PAGE_SHIFT; + } else if (bp->domain & AMDGPU_GEM_DOMAIN_GDS) { /* Both size and alignment must be a multiple of 4. */ page_align = ALIGN(bp->byte_align, 4); @@ -776,7 +777,7 @@ int amdgpu_bo_kmap(struct amdgpu_bo *bo, void **ptr) return 0; } - r = ttm_bo_kmap(&bo->tbo, 0, bo->tbo.resource->num_pages, &bo->kmap); + r = ttm_bo_kmap(&bo->tbo, 0, PFN_UP(bo->tbo.resource->size), &bo->kmap); if (r) return r; diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_res_cursor.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_res_cursor.h index 6546552e596c..5c4f93ee0c57 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_res_cursor.h +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_res_cursor.h @@ -62,7 +62,7 @@ static inline void amdgpu_res_first(struct ttm_resource *res, if (!res) goto fallback; - BUG_ON(start + size > res->num_pages << PAGE_SHIFT); + BUG_ON(start + size > res->size); cur->mem_type = res->mem_type; @@ -110,7 +110,7 @@ static inline void amdgpu_res_first(struct ttm_resource *res, cur->size = size; cur->remaining = size; cur->node = NULL; - WARN_ON(res && start + size > res->num_pages << PAGE_SHIFT); + WARN_ON(res && start + size > res->size); return; } diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h index 5e6ddc7e101c..677ad2016976 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h @@ -127,7 +127,7 @@ TRACE_EVENT(amdgpu_bo_create, TP_fast_assign( __entry->bo = bo; - __entry->pages = bo->tbo.resource->num_pages; + __entry->pages = PFN_UP(bo->tbo.resource->size); __entry->type = bo->tbo.resource->mem_type; __entry->prefer = bo->preferred_domains; __entry->allow = bo->allowed_domains; diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c index dc262d2c2925..36066965346f 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c @@ -381,7 +381,7 @@ static int amdgpu_move_blit(struct ttm_buffer_object *bo, dst.offset = 0; r = amdgpu_ttm_copy_mem_to_mem(adev, &src, &dst, - new_mem->num_pages << PAGE_SHIFT, + new_mem->size, amdgpu_bo_encrypted(abo), bo->base.resv, &fence); if (r) @@ -424,7 +424,7 @@ static int amdgpu_move_blit(struct ttm_buffer_object *bo, static bool amdgpu_mem_visible(struct amdgpu_device *adev, struct ttm_resource *mem) { - u64 mem_size = (u64)mem->num_pages << PAGE_SHIFT; + u64 mem_size = (u64)mem->size; struct amdgpu_res_cursor cursor; u64 end; @@ -568,7 +568,7 @@ static int amdgpu_ttm_io_mem_reserve(struct ttm_device *bdev, struct ttm_resource *mem) { struct amdgpu_device *adev = amdgpu_ttm_adev(bdev); - size_t bus_size = (size_t)mem->num_pages << PAGE_SHIFT; + size_t bus_size = (size_t)mem->size; switch (mem->mem_type) { case TTM_PL_SYSTEM: diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c index 73a517bcf5c1..18c1a173d187 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c @@ -439,7 +439,7 @@ static int amdgpu_vram_mgr_new(struct ttm_resource_manager *man, /* Allocate blocks in desired range */ vres->flags |= DRM_BUDDY_RANGE_ALLOCATION; - remaining_size = (u64)vres->base.num_pages << PAGE_SHIFT; + remaining_size = (u64)vres->base.size; mutex_lock(&mgr->lock); while (remaining_size) { @@ -498,7 +498,7 @@ static int amdgpu_vram_mgr_new(struct ttm_resource_manager *man, LIST_HEAD(temp); trim_list = &vres->blocks; - original_size = (u64)vres->base.num_pages << PAGE_SHIFT; + original_size = (u64)vres->base.size; /* * If size value is rounded up to min_block_size, trim the last @@ -533,8 +533,8 @@ static int amdgpu_vram_mgr_new(struct ttm_resource_manager *man, amdgpu_vram_mgr_block_size(block); start >>= PAGE_SHIFT; - if (start > vres->base.num_pages) - start -= vres->base.num_pages; + if (start > PFN_UP(vres->base.size)) + start -= PFN_UP(vres->base.size); else start = 0; vres->base.start = max(vres->base.start, start); From patchwork Wed Oct 19 15:27:33 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Somalapuram Amaranath X-Patchwork-Id: 13017606 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id DD6E5FA373E for ; Mon, 24 Oct 2022 13:23:58 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id A464210E6D0; Mon, 24 Oct 2022 13:23:40 +0000 (UTC) Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2040.outbound.protection.outlook.com [40.107.236.40]) by gabe.freedesktop.org (Postfix) with ESMTPS id E73B910F27A; Wed, 19 Oct 2022 15:28:58 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=SsjkmC76JlT8EALxlPHhLWoQcYwPFMu99ikGSAvYfvdTDdgv66IZpquU5scnyCH/T6+6kDJz4Ciqqq4y2ZguruVwIFb/DV9ntBwkYWG3VKi1GLPsuBCcZBfjPXgc8Ua7NUuxrGHZMzFajCAoJJ6FZJbeaVDFBvbU09o+odWUdHianYs/OKTGW7JGVcCB8cGNk85M742Crj/aySaYzv57n/5ECElK2Er69yt9y2ig7aSduFZWj/76Uy9u12T4IJggbxguRhfV8+p3I7yEIXrerkhu1NSkedMeoisgvIe4HVLyD/zFDC/JEMaQJFHs3T9gDtQ2Is8y96/ObITByZEq3A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=9rZzSFX9bVRXs1nDK4WwHMrgDQeqUNfYdDtwH1iu77A=; b=PgO1zcZAEOfPW4RvkZ7DeJc0zaOd3jXFI9NtDo3e1N5f2fwh3M34O3jIF0TIUddlEiH6Cm5mC6+mgLf6bhm91+NCvHSRlpioLihfJOFVKsWOm6W8wqVaNwyCGntc4uwThzyFrR5sPxUudJaS7pE3RTkxwTuPC0ohvZxAA12G++W+TxvI70ZrpYo/cGFnr1WyOMZb789GD9PNJmZBeGk+GX75F1l6WJ6azOKugzP9+NO/FEnq98jvGEHDlNttr/Oy0Wq2cFdta0jMLFAYsCFMD34yTYfj6WbJT0+sgnrpHYHW4NzzuP2MPVtIXY0w6roLyleL9Bn9dJRls2YsiC+Vuw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.freedesktop.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=9rZzSFX9bVRXs1nDK4WwHMrgDQeqUNfYdDtwH1iu77A=; b=Aiy1Eq5BPtwsxLzPkNPoRf7ViJoBWx9FFqgq7xlFPl7K4g+4+CuSBlsm4XLgNUqeJCHaOyHYvpkzVMgDQ01G/IREAkqvUdKfFuOBl7XCewzj/5ZKXE//9JNMSoRb9DAmhTPRfxzaHeICKCCdE1V9cnGfd/OTudGdfRyk0KMigFs= Received: from DS7PR07CA0004.namprd07.prod.outlook.com (2603:10b6:5:3af::13) by DM4PR12MB7765.namprd12.prod.outlook.com (2603:10b6:8:102::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5723.26; Wed, 19 Oct 2022 15:28:56 +0000 Received: from DM6NAM11FT088.eop-nam11.prod.protection.outlook.com (2603:10b6:5:3af:cafe::88) by DS7PR07CA0004.outlook.office365.com (2603:10b6:5:3af::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5723.34 via Frontend Transport; Wed, 19 Oct 2022 15:28:56 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by DM6NAM11FT088.mail.protection.outlook.com (10.13.172.147) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5746.16 via Frontend Transport; Wed, 19 Oct 2022 15:28:55 +0000 Received: from amar-X570-AORUS-ELITE.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Wed, 19 Oct 2022 10:28:30 -0500 From: Somalapuram Amaranath To: , , , Date: Wed, 19 Oct 2022 20:57:33 +0530 Message-ID: <20221019152736.654451-3-Amaranath.Somalapuram@amd.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20221019152736.654451-1-Amaranath.Somalapuram@amd.com> References: <20221019152736.654451-1-Amaranath.Somalapuram@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6NAM11FT088:EE_|DM4PR12MB7765:EE_ X-MS-Office365-Filtering-Correlation-Id: 368f34d5-4040-41af-b78a-08dab1e6a2f4 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: rVZi8WsPl3wifQaAP9c+I4LQV3zYET2Yb9+Xg3IuFin/4/QjW5p23RWyR7KQCyR35wRM/W1GwvhZmZHXzMWVyf0NsXLTUI9NgOaTJNfR/aEwt1uLvISx+V+F/2GeddtaiOmxMVrF3k7hrqGU6wG84+6UAiBNzWXSxCrOpidoNTZwyaGCX83uZ4lh/9bKhXVzhkvyyXJ1klrjs7iOJwPchYHFscvX0YS28R7So7DysB1KpI+L06DAZCYdqL0IVwKoe3FNUbVGO8f8NQ9Qn1ljucSjHwcWxoO8Njk+CY4MIBVwoZlEGvNAbqMm+diOVPODV+dUB2Q9c5IJgxC5R8ZcUaEmRqxp45tVfo8cMAwqyyUjH9rq3cOLdBv0EgzCc0h1+aXnyKlSAxEd5xwDQRfuZrEQSntxvl7canO98S/BbJOyMCVjV3k6YENgzPhi2of3Al2XglIx0bVl/jNSnnnJRCQdB1rKfoA0pnyNa2Jv/2S7Cecej/cCw0du7WvgT9ECFU1eHlt5+anxwKtW/eXRlioEHeprJ6B7jj6xopIWDCtegpE0h1KQw90TEGjaAaaZt+9lXLFUPtQiPQr5nOl5JeB82Z2o5xlHhbVK8c4TvenqXGzKtfRtswx+4gSw8A2v+RPRSC5x4OaGG9A2/W80vUzRrxdvOHAHWean2uN9lyVMG7HwVE9ak00fURont6p1BIuzTWtnwoF/oRiytLqNlMFYz9YtDJPcH1MOPa8lBTGrbrys6ePnJR2eCfFUkLWxrfbI1Or+rVBMkT+kJ1ILgNeWuHua4Ele4LkR5m+8SWI= X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230022)(4636009)(346002)(136003)(376002)(396003)(39860400002)(451199015)(40470700004)(46966006)(36840700001)(16526019)(47076005)(426003)(1076003)(186003)(2616005)(83380400001)(356005)(81166007)(26005)(86362001)(36860700001)(336012)(82740400003)(5660300002)(2906002)(8936002)(4326008)(40480700001)(82310400005)(40460700003)(478600001)(110136005)(7696005)(316002)(41300700001)(450100002)(70206006)(54906003)(70586007)(36756003)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Oct 2022 15:28:55.9950 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 368f34d5-4040-41af-b78a-08dab1e6a2f4 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d; Ip=[165.204.84.17]; Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: DM6NAM11FT088.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB7765 X-Mailman-Approved-At: Mon, 24 Oct 2022 13:23:26 +0000 Subject: [Intel-gfx] =?utf-8?q?=5BPATCH_3/6=5D_drm/i915=3A_fix=E2=80=99s_on_?= =?utf-8?q?ttm=5Fresource_rework_to_use_size=5Ft_type?= X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: alexander.deucher@amd.com, Somalapuram Amaranath , arunpravin.paneerselvam@amd.com, christian.koenig@amd.com Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" Fix the ttm_resource from num_pages to size_t size. Signed-off-by: Somalapuram Amaranath --- drivers/gpu/drm/i915/gem/i915_gem_ttm.c | 2 +- drivers/gpu/drm/i915/i915_scatterlist.c | 4 ++-- drivers/gpu/drm/i915/i915_ttm_buddy_manager.c | 12 ++++++------ drivers/gpu/drm/i915/intel_region_ttm.c | 2 +- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/drivers/gpu/drm/i915/gem/i915_gem_ttm.c b/drivers/gpu/drm/i915/gem/i915_gem_ttm.c index 4f861782c3e8..7a1e92c11946 100644 --- a/drivers/gpu/drm/i915/gem/i915_gem_ttm.c +++ b/drivers/gpu/drm/i915/gem/i915_gem_ttm.c @@ -649,7 +649,7 @@ bool i915_ttm_resource_mappable(struct ttm_resource *res) if (!i915_ttm_cpu_maps_iomem(res)) return true; - return bman_res->used_visible_size == bman_res->base.num_pages; + return bman_res->used_visible_size == PFN_UP(bman_res->base.size); } static int i915_ttm_io_mem_reserve(struct ttm_device *bdev, struct ttm_resource *mem) diff --git a/drivers/gpu/drm/i915/i915_scatterlist.c b/drivers/gpu/drm/i915/i915_scatterlist.c index dcc081874ec8..114e5e39aa72 100644 --- a/drivers/gpu/drm/i915/i915_scatterlist.c +++ b/drivers/gpu/drm/i915/i915_scatterlist.c @@ -158,7 +158,7 @@ struct i915_refct_sgt *i915_rsgt_from_buddy_resource(struct ttm_resource *res, u32 page_alignment) { struct i915_ttm_buddy_resource *bman_res = to_ttm_buddy_resource(res); - const u64 size = res->num_pages << PAGE_SHIFT; + const u64 size = res->size; const u32 max_segment = round_down(UINT_MAX, page_alignment); struct drm_buddy *mm = bman_res->mm; struct list_head *blocks = &bman_res->blocks; @@ -177,7 +177,7 @@ struct i915_refct_sgt *i915_rsgt_from_buddy_resource(struct ttm_resource *res, i915_refct_sgt_init(rsgt, size); st = &rsgt->table; - if (sg_alloc_table(st, res->num_pages, GFP_KERNEL)) { + if (sg_alloc_table(st, PFN_UP(res->size), GFP_KERNEL)) { i915_refct_sgt_put(rsgt); return ERR_PTR(-ENOMEM); } diff --git a/drivers/gpu/drm/i915/i915_ttm_buddy_manager.c b/drivers/gpu/drm/i915/i915_ttm_buddy_manager.c index e19452f0e100..7e611476c7a4 100644 --- a/drivers/gpu/drm/i915/i915_ttm_buddy_manager.c +++ b/drivers/gpu/drm/i915/i915_ttm_buddy_manager.c @@ -62,8 +62,8 @@ static int i915_ttm_buddy_man_alloc(struct ttm_resource_manager *man, if (place->fpfn || lpfn != man->size) bman_res->flags |= DRM_BUDDY_RANGE_ALLOCATION; - GEM_BUG_ON(!bman_res->base.num_pages); - size = bman_res->base.num_pages << PAGE_SHIFT; + GEM_BUG_ON(!bman_res->base.size); + size = bman_res->base.size; min_page_size = bman->default_page_size; if (bo->page_alignment) @@ -72,7 +72,7 @@ static int i915_ttm_buddy_man_alloc(struct ttm_resource_manager *man, GEM_BUG_ON(min_page_size < mm->chunk_size); GEM_BUG_ON(!IS_ALIGNED(size, min_page_size)); - if (place->fpfn + bman_res->base.num_pages != place->lpfn && + if (place->fpfn + PFN_UP(bman_res->base.size) != place->lpfn && place->flags & TTM_PL_FLAG_CONTIGUOUS) { unsigned long pages; @@ -108,7 +108,7 @@ static int i915_ttm_buddy_man_alloc(struct ttm_resource_manager *man, goto err_free_blocks; if (place->flags & TTM_PL_FLAG_CONTIGUOUS) { - u64 original_size = (u64)bman_res->base.num_pages << PAGE_SHIFT; + u64 original_size = (u64)bman_res->base.size; drm_buddy_block_trim(mm, original_size, @@ -116,7 +116,7 @@ static int i915_ttm_buddy_man_alloc(struct ttm_resource_manager *man, } if (lpfn <= bman->visible_size) { - bman_res->used_visible_size = bman_res->base.num_pages; + bman_res->used_visible_size = PFN_UP(bman_res->base.size); } else { struct drm_buddy_block *block; @@ -228,7 +228,7 @@ static bool i915_ttm_buddy_man_compatible(struct ttm_resource_manager *man, if (!place->fpfn && place->lpfn == i915_ttm_buddy_man_visible_size(man)) - return bman_res->used_visible_size == res->num_pages; + return bman_res->used_visible_size == PFN_UP(res->size); /* Check each drm buddy block individually */ list_for_each_entry(block, &bman_res->blocks, link) { diff --git a/drivers/gpu/drm/i915/intel_region_ttm.c b/drivers/gpu/drm/i915/intel_region_ttm.c index 575d67bc6ffe..cf89d0c2a2d9 100644 --- a/drivers/gpu/drm/i915/intel_region_ttm.c +++ b/drivers/gpu/drm/i915/intel_region_ttm.c @@ -244,7 +244,7 @@ void intel_region_ttm_resource_free(struct intel_memory_region *mem, struct ttm_resource_manager *man = mem->region_private; struct ttm_buffer_object mock_bo = {}; - mock_bo.base.size = res->num_pages << PAGE_SHIFT; + mock_bo.base.size = res->size; mock_bo.bdev = &mem->i915->bdev; res->bo = &mock_bo; From patchwork Wed Oct 19 15:27:34 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Somalapuram Amaranath X-Patchwork-Id: 13017610 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 91BAEFA373E for ; Mon, 24 Oct 2022 13:24:05 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 495CF10E6E2; Mon, 24 Oct 2022 13:23:43 +0000 (UTC) Received: from NAM04-BN8-obe.outbound.protection.outlook.com (mail-bn8nam04on2063.outbound.protection.outlook.com [40.107.100.63]) by gabe.freedesktop.org (Postfix) with ESMTPS id 103B110F27B; Wed, 19 Oct 2022 15:29:43 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=DcU0HgrLx+d3LeQTaSN8Rwpxe8G6lI7RUOvS4VGJRxRofmm2QeKgU5lNfcgCWoQaczPFebPlB8xOAp+ukq7h26ZZ5Df+6SFreCzb3bq5AQG92XTcmWA0Bd33hRBdp2oPh4rc2mpZj2Rzb8yaHd898uK40fdMgloYL5ebo9mzyQTLEMECLJNFDtYgfbNe0z1FvAjrNH7POU2Yv1R+REMofADUJqR7KrUaIbHOhROm+FdqKsk7oQuv/efbsTXVklFgK0Gvzy/mFQI4my2SNJH6EShOri2bymP6w2hWRASHczh5Cf0QKWWIHiMD0TUgMwan6XD3/tZzyj32jPM2VjwqQA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=ENBBsTyalW/y8wKCBMnMIg8dft+2cF5nQ8rM29eME4Q=; b=Y3YELUNaARa+FBtiVu/2u0VC/4T5cbP60liTb+QCTZmNfNNSvXC6psEFYC2J56DEfxvGsCjBgPD6TSgLewH98LGlOv5BwR6hP4lGDsTvP6DeD1YP5OZPDpljxVjKK15Prf34IAnGjbmmD3ZwPl+1MiAvUGfx78arG0N/X2Au3b+zDVpoL9w+ZFWIXGRmAUOr8ZtbR/L7ThH2udoLov7p8vqvnhM335Wyzd3DutZbrcybHZnEK4xJvHtQKK8j2bdM4Wr/edmrdh85IIUQ0zom9FtRR8CIwyb/P6/oeYPbwa+KmC/HsXwv0NrtH67R2yC190BH7dBroiybgFIWKY8jIQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.freedesktop.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ENBBsTyalW/y8wKCBMnMIg8dft+2cF5nQ8rM29eME4Q=; b=QWX5LgeScpkVEs3xOwuxCbfO3g2Xo2dnjFBvjpTv+G0/qT0pIcWoiVbe+CncvfRqx6jARX2oQ7BeoeEL1cTssMA0bxKKl/ZDXrpuhER+byacvcH+lP+7TulKQJYHWwEH+crc+VD9Vioby6BmLCFrmJ26NK+3KOGYyhqwWaRGBQk= Received: from DM6PR06CA0030.namprd06.prod.outlook.com (2603:10b6:5:120::43) by IA0PR12MB7650.namprd12.prod.outlook.com (2603:10b6:208:436::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5723.33; Wed, 19 Oct 2022 15:29:40 +0000 Received: from DM6NAM11FT098.eop-nam11.prod.protection.outlook.com (2603:10b6:5:120:cafe::cc) by DM6PR06CA0030.outlook.office365.com (2603:10b6:5:120::43) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5723.34 via Frontend Transport; Wed, 19 Oct 2022 15:29:40 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by DM6NAM11FT098.mail.protection.outlook.com (10.13.173.61) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5746.16 via Frontend Transport; Wed, 19 Oct 2022 15:29:40 +0000 Received: from amar-X570-AORUS-ELITE.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Wed, 19 Oct 2022 10:29:35 -0500 From: Somalapuram Amaranath To: , , , Date: Wed, 19 Oct 2022 20:57:34 +0530 Message-ID: <20221019152736.654451-4-Amaranath.Somalapuram@amd.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20221019152736.654451-1-Amaranath.Somalapuram@amd.com> References: <20221019152736.654451-1-Amaranath.Somalapuram@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6NAM11FT098:EE_|IA0PR12MB7650:EE_ X-MS-Office365-Filtering-Correlation-Id: 1e223010-495e-4c0b-209c-08dab1e6bd4e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: btzmF9VY2MmPNkeQ8+LbQnmqOc0egqtj95/HPNfwQ/Ryq3/uZ7ypNGcAVnj7rVo1B9m+UtiGzbk++VrBJWKy3BjQx9amSycJMRsVidq9ifTz+QqT/0ThnHk3acKJq9ll7S/6iFrfQ25s9FpDkPGdIzdtjteF0D+ECw+pZpDMQlJQ4aUJhNryPwZlvRwsOwcfxGR2gP6pz8aH3PtRfaIIKijg/sAv3nVWScW77orssR7VlPkrzaGcy8q3bD2ANU2U1RPHz68vw4oJR83oxeSsuzcs2fViVaRODz7uqSrYmvBK0lJAS3SaDSdXaBzyeXCh2n1gVV3FvkwIhO5lHzDoIIczNoeFzGt7isK4KwcdyVhGsQqfImw1FZeEawAla71KsleidmcXfXwZdU2N6DatU0rRuL3na5PrvSGty8fXqgiWnCj/L2JVK36UiNSAIamwwi7m0FwDS45hIdKbDXjiSto3qCpf8zwj3LwVIfxL8Odk4Z9Fdhoef39fs9mfzg5QhfJ7CveA6otNUf/C/MQtQqpQwrpMqO1HLsh9rfe/KZexqHBv+IGo5xW/7m/iuAAW7MqK+GWTP/fqZ4t1Uc91uiRHLQ4mBUxPpFHevJZu5p+M9auzEEudrP3oXxTNpreR9TjluwHMPiFr/pt54Lad9RJ6uWJuWTY9u3wdocXxPfx7ab6cWbhs0O724BXhJ3jEotUbERkZ81TjL76w+nzZ/z+LgyA+Gyruejor+uVddesExxaB4OG862Mu36L1gA6UUemNyWIpboENezQ8F80XqwSXWOTWCgvNjLBqrvOEB9+N6Z8+FW7kjcnWZGpkj6dTD23QUxFnoSWaqk5I3jwNxg== X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230022)(4636009)(136003)(346002)(396003)(39860400002)(376002)(451199015)(40470700004)(36840700001)(46966006)(82310400005)(4326008)(36860700001)(7696005)(26005)(82740400003)(40460700003)(1076003)(40480700001)(41300700001)(47076005)(478600001)(8936002)(426003)(86362001)(81166007)(83380400001)(336012)(450100002)(70206006)(70586007)(356005)(5660300002)(2906002)(110136005)(36756003)(186003)(16526019)(316002)(2616005)(54906003)(36900700001)(309714004); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Oct 2022 15:29:40.2173 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 1e223010-495e-4c0b-209c-08dab1e6bd4e X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d; Ip=[165.204.84.17]; Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: DM6NAM11FT098.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA0PR12MB7650 X-Mailman-Approved-At: Mon, 24 Oct 2022 13:23:26 +0000 Subject: [Intel-gfx] =?utf-8?q?=5BPATCH_4/6=5D_drm/nouveau=3A_fix=E2=80=99s_?= =?utf-8?q?on_ttm=5Fresource_rework_to_use_size=5Ft_type?= X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: alexander.deucher@amd.com, Somalapuram Amaranath , arunpravin.paneerselvam@amd.com, christian.koenig@amd.com Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" Fix the ttm_resource from num_pages to size_t size. Signed-off-by: Somalapuram Amaranath --- drivers/gpu/drm/nouveau/nouveau_bo.c | 4 ++-- drivers/gpu/drm/nouveau/nouveau_bo0039.c | 4 ++-- drivers/gpu/drm/nouveau/nouveau_bo5039.c | 2 +- drivers/gpu/drm/nouveau/nouveau_bo74c1.c | 2 +- drivers/gpu/drm/nouveau/nouveau_bo85b5.c | 4 ++-- drivers/gpu/drm/nouveau/nouveau_bo9039.c | 4 ++-- drivers/gpu/drm/nouveau/nouveau_bo90b5.c | 4 ++-- drivers/gpu/drm/nouveau/nouveau_boa0b5.c | 2 +- drivers/gpu/drm/nouveau/nouveau_gem.c | 5 ++--- drivers/gpu/drm/nouveau/nouveau_mem.c | 4 ++-- drivers/gpu/drm/nouveau/nouveau_ttm.c | 2 +- 11 files changed, 18 insertions(+), 19 deletions(-) diff --git a/drivers/gpu/drm/nouveau/nouveau_bo.c b/drivers/gpu/drm/nouveau/nouveau_bo.c index 126b3c6e12f9..16ca4a141866 100644 --- a/drivers/gpu/drm/nouveau/nouveau_bo.c +++ b/drivers/gpu/drm/nouveau/nouveau_bo.c @@ -532,7 +532,7 @@ nouveau_bo_map(struct nouveau_bo *nvbo) if (ret) return ret; - ret = ttm_bo_kmap(&nvbo->bo, 0, nvbo->bo.resource->num_pages, &nvbo->kmap); + ret = ttm_bo_kmap(&nvbo->bo, 0, PFN_UP(nvbo->bo.resource->size), &nvbo->kmap); ttm_bo_unreserve(&nvbo->bo); return ret; @@ -1236,7 +1236,7 @@ vm_fault_t nouveau_ttm_fault_reserve_notify(struct ttm_buffer_object *bo) } else { /* make sure bo is in mappable vram */ if (drm->client.device.info.family >= NV_DEVICE_INFO_V0_TESLA || - bo->resource->start + bo->resource->num_pages < mappable) + bo->resource->start + PFN_UP(bo->resource->size) < mappable) return 0; for (i = 0; i < nvbo->placement.num_placement; ++i) { diff --git a/drivers/gpu/drm/nouveau/nouveau_bo0039.c b/drivers/gpu/drm/nouveau/nouveau_bo0039.c index 7390132129fe..e2ce44adaa5c 100644 --- a/drivers/gpu/drm/nouveau/nouveau_bo0039.c +++ b/drivers/gpu/drm/nouveau/nouveau_bo0039.c @@ -52,7 +52,7 @@ nv04_bo_move_m2mf(struct nouveau_channel *chan, struct ttm_buffer_object *bo, u32 src_offset = old_reg->start << PAGE_SHIFT; u32 dst_ctxdma = nouveau_bo_mem_ctxdma(bo, chan, new_reg); u32 dst_offset = new_reg->start << PAGE_SHIFT; - u32 page_count = new_reg->num_pages; + u32 page_count = PFN_UP(new_reg->size); int ret; ret = PUSH_WAIT(push, 3); @@ -62,7 +62,7 @@ nv04_bo_move_m2mf(struct nouveau_channel *chan, struct ttm_buffer_object *bo, PUSH_MTHD(push, NV039, SET_CONTEXT_DMA_BUFFER_IN, src_ctxdma, SET_CONTEXT_DMA_BUFFER_OUT, dst_ctxdma); - page_count = new_reg->num_pages; + page_count = PFN_UP(new_reg->size); while (page_count) { int line_count = (page_count > 2047) ? 2047 : page_count; diff --git a/drivers/gpu/drm/nouveau/nouveau_bo5039.c b/drivers/gpu/drm/nouveau/nouveau_bo5039.c index 4c75c7b3804c..c6cf3629a9f9 100644 --- a/drivers/gpu/drm/nouveau/nouveau_bo5039.c +++ b/drivers/gpu/drm/nouveau/nouveau_bo5039.c @@ -41,7 +41,7 @@ nv50_bo_move_m2mf(struct nouveau_channel *chan, struct ttm_buffer_object *bo, { struct nouveau_mem *mem = nouveau_mem(old_reg); struct nvif_push *push = chan->chan.push; - u64 length = (new_reg->num_pages << PAGE_SHIFT); + u64 length = new_reg->size; u64 src_offset = mem->vma[0].addr; u64 dst_offset = mem->vma[1].addr; int src_tiled = !!mem->kind; diff --git a/drivers/gpu/drm/nouveau/nouveau_bo74c1.c b/drivers/gpu/drm/nouveau/nouveau_bo74c1.c index ed6c09d67840..9b7ba31fae13 100644 --- a/drivers/gpu/drm/nouveau/nouveau_bo74c1.c +++ b/drivers/gpu/drm/nouveau/nouveau_bo74c1.c @@ -44,7 +44,7 @@ nv84_bo_move_exec(struct nouveau_channel *chan, struct ttm_buffer_object *bo, if (ret) return ret; - PUSH_NVSQ(push, NV74C1, 0x0304, new_reg->num_pages << PAGE_SHIFT, + PUSH_NVSQ(push, NV74C1, 0x0304, new_reg->size, 0x0308, upper_32_bits(mem->vma[0].addr), 0x030c, lower_32_bits(mem->vma[0].addr), 0x0310, upper_32_bits(mem->vma[1].addr), diff --git a/drivers/gpu/drm/nouveau/nouveau_bo85b5.c b/drivers/gpu/drm/nouveau/nouveau_bo85b5.c index dec29b2d8bb2..a15a38a87a95 100644 --- a/drivers/gpu/drm/nouveau/nouveau_bo85b5.c +++ b/drivers/gpu/drm/nouveau/nouveau_bo85b5.c @@ -44,10 +44,10 @@ nva3_bo_move_copy(struct nouveau_channel *chan, struct ttm_buffer_object *bo, struct nvif_push *push = chan->chan.push; u64 src_offset = mem->vma[0].addr; u64 dst_offset = mem->vma[1].addr; - u32 page_count = new_reg->num_pages; + u32 page_count = PFN_UP(new_reg->size); int ret; - page_count = new_reg->num_pages; + page_count = PFN_UP(new_reg->size); while (page_count) { int line_count = (page_count > 8191) ? 8191 : page_count; diff --git a/drivers/gpu/drm/nouveau/nouveau_bo9039.c b/drivers/gpu/drm/nouveau/nouveau_bo9039.c index 776b04976cdf..d2bb2687d401 100644 --- a/drivers/gpu/drm/nouveau/nouveau_bo9039.c +++ b/drivers/gpu/drm/nouveau/nouveau_bo9039.c @@ -42,10 +42,10 @@ nvc0_bo_move_m2mf(struct nouveau_channel *chan, struct ttm_buffer_object *bo, struct nouveau_mem *mem = nouveau_mem(old_reg); u64 src_offset = mem->vma[0].addr; u64 dst_offset = mem->vma[1].addr; - u32 page_count = new_reg->num_pages; + u32 page_count = PFN_UP(new_reg->size); int ret; - page_count = new_reg->num_pages; + page_count = PFN_UP(new_reg->size); while (page_count) { int line_count = (page_count > 2047) ? 2047 : page_count; diff --git a/drivers/gpu/drm/nouveau/nouveau_bo90b5.c b/drivers/gpu/drm/nouveau/nouveau_bo90b5.c index 8499f58213e3..4618f4f5ab56 100644 --- a/drivers/gpu/drm/nouveau/nouveau_bo90b5.c +++ b/drivers/gpu/drm/nouveau/nouveau_bo90b5.c @@ -37,10 +37,10 @@ nvc0_bo_move_copy(struct nouveau_channel *chan, struct ttm_buffer_object *bo, struct nvif_push *push = chan->chan.push; u64 src_offset = mem->vma[0].addr; u64 dst_offset = mem->vma[1].addr; - u32 page_count = new_reg->num_pages; + u32 page_count = PFN_UP(new_reg->size); int ret; - page_count = new_reg->num_pages; + page_count = PFN_UP(new_reg->size); while (page_count) { int line_count = (page_count > 8191) ? 8191 : page_count; diff --git a/drivers/gpu/drm/nouveau/nouveau_boa0b5.c b/drivers/gpu/drm/nouveau/nouveau_boa0b5.c index 575212472e7a..07a5c6302c98 100644 --- a/drivers/gpu/drm/nouveau/nouveau_boa0b5.c +++ b/drivers/gpu/drm/nouveau/nouveau_boa0b5.c @@ -58,7 +58,7 @@ nve0_bo_move_copy(struct nouveau_channel *chan, struct ttm_buffer_object *bo, PITCH_IN, PAGE_SIZE, PITCH_OUT, PAGE_SIZE, LINE_LENGTH_IN, PAGE_SIZE, - LINE_COUNT, new_reg->num_pages); + LINE_COUNT, PFN_UP(new_reg->size)); PUSH_IMMD(push, NVA0B5, LAUNCH_DMA, NVDEF(NVA0B5, LAUNCH_DMA, DATA_TRANSFER_TYPE, NON_PIPELINED) | diff --git a/drivers/gpu/drm/nouveau/nouveau_gem.c b/drivers/gpu/drm/nouveau/nouveau_gem.c index fab542a758ff..2f479c96e415 100644 --- a/drivers/gpu/drm/nouveau/nouveau_gem.c +++ b/drivers/gpu/drm/nouveau/nouveau_gem.c @@ -679,7 +679,7 @@ nouveau_gem_pushbuf_reloc_apply(struct nouveau_cli *cli, } if (!nvbo->kmap.virtual) { - ret = ttm_bo_kmap(&nvbo->bo, 0, nvbo->bo.resource->num_pages, + ret = ttm_bo_kmap(&nvbo->bo, 0, PFN_UP(nvbo->bo.resource->size), &nvbo->kmap); if (ret) { NV_PRINTK(err, cli, "failed kmap for reloc\n"); @@ -868,8 +868,7 @@ nouveau_gem_ioctl_pushbuf(struct drm_device *dev, void *data, if (unlikely(cmd != req->suffix0)) { if (!nvbo->kmap.virtual) { ret = ttm_bo_kmap(&nvbo->bo, 0, - nvbo->bo.resource-> - num_pages, + PFN_UP(nvbo->bo.resource->size), &nvbo->kmap); if (ret) { WIND_RING(chan); diff --git a/drivers/gpu/drm/nouveau/nouveau_mem.c b/drivers/gpu/drm/nouveau/nouveau_mem.c index 76f8edefa637..1fde3a5d7c32 100644 --- a/drivers/gpu/drm/nouveau/nouveau_mem.c +++ b/drivers/gpu/drm/nouveau/nouveau_mem.c @@ -115,7 +115,7 @@ nouveau_mem_host(struct ttm_resource *reg, struct ttm_tt *tt) mutex_lock(&drm->master.lock); ret = nvif_mem_ctor_type(mmu, "ttmHostMem", cli->mem->oclass, type, PAGE_SHIFT, - reg->num_pages << PAGE_SHIFT, + reg->size, &args, sizeof(args), &mem->mem); mutex_unlock(&drm->master.lock); return ret; @@ -128,7 +128,7 @@ nouveau_mem_vram(struct ttm_resource *reg, bool contig, u8 page) struct nouveau_cli *cli = mem->cli; struct nouveau_drm *drm = cli->drm; struct nvif_mmu *mmu = &cli->mmu; - u64 size = ALIGN(reg->num_pages << PAGE_SHIFT, 1 << page); + u64 size = ALIGN(reg->size, 1 << page); int ret; mutex_lock(&drm->master.lock); diff --git a/drivers/gpu/drm/nouveau/nouveau_ttm.c b/drivers/gpu/drm/nouveau/nouveau_ttm.c index 9602c30928f2..1469a88910e4 100644 --- a/drivers/gpu/drm/nouveau/nouveau_ttm.c +++ b/drivers/gpu/drm/nouveau/nouveau_ttm.c @@ -139,7 +139,7 @@ nv04_gart_manager_new(struct ttm_resource_manager *man, mem = nouveau_mem(*res); ttm_resource_init(bo, place, *res); ret = nvif_vmm_get(&mem->cli->vmm.vmm, PTES, false, 12, 0, - (long)(*res)->num_pages << PAGE_SHIFT, &mem->vma[0]); + (long)(*res)->size, &mem->vma[0]); if (ret) { nouveau_mem_del(man, *res); return ret; From patchwork Wed Oct 19 15:27:35 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Somalapuram Amaranath X-Patchwork-Id: 13017608 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 43404ECAAA1 for ; Mon, 24 Oct 2022 13:24:03 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id BC1E810E6E0; Mon, 24 Oct 2022 13:23:42 +0000 (UTC) Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2054.outbound.protection.outlook.com [40.107.93.54]) by gabe.freedesktop.org (Postfix) with ESMTPS id 1DBF110F27F; Wed, 19 Oct 2022 15:31:15 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=dHHPncJWNi0KY8HeCAcQFWXjb5Zo7kDz0OW1rnlK51lhttKMbBWQRuWr/sx+Ar6Xom3EqCdJDXPH41XpnUq3mSrHFHSZSOCaXcSAp1pTuEAlXmwLYwxTYRA5yAbSbQB/ADNlduWr9tTVmA250MQ2X+jaWYKzLOmkfMjKDJqBLCDCH34zdq1vE092wGDY1T2s0ZA+JS7R2Vgk+qHGkoMn46sMJqIqeKLcM4IRmVYYgqeW1U6LWNYdy6kFQ5setMY0hVap3bZCn/2WFTVTB2WiFL10zrjljYKi8kA6FSjxZDzkWDSsmJ9Tt9Mt6MFAbH7wISL+IHbNCQ9+MQFr/qMtVg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=+4aqs3GxfViI4JVZ/A0ORkYRLDdlt9Zw5Ah2KcJeWdc=; b=j63ZNKIosEs8s/WtBONhVdLMLwj3MbLgkQ71ywyTi8ICeYxSfCjg3PywHf89bfdkXAoaNz+bklNBITTSvoWA0BH0HvEW3DxQPQ9HBvzeCY9UBCnPnHUcFAiuJnWxlx/Prpy3yiRG4iSyEzRKFHHVBj/EBYXUqiztiIrKRn+dXhX7qD7DX+kZt92QFoS+be6RHWQZOPHiM2oY6lOW/HL9W/Pqf4C5oAeO3qkWSo9ZuZ295hayFgCFS6U6mhoXOpD+k13wGQUvHWv80+noViVmcKyQgWnXegZAed3wHtBUgaw5vlt4QZslhzDL0LVqyCTFgkUitpziDlrx8o8byizPag== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.freedesktop.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=+4aqs3GxfViI4JVZ/A0ORkYRLDdlt9Zw5Ah2KcJeWdc=; b=ua5vwGOjTIZJM8FNdmK04EfhvZcYlWwsi/F4X97TobzW7gG6K88GdW3HrCxA4g0RTJXsyYMNiOk8ifmEv3sKQ5A+/nF+Qm0RFTiWrurxEYBqTvrc0eVClG8n7nIZdfYaU/rwVWbNW4hYv79SsNB0FSl+UnTAKaXd94blxHI+i+w= Received: from BN9PR03CA0592.namprd03.prod.outlook.com (2603:10b6:408:10d::27) by DM8PR12MB5415.namprd12.prod.outlook.com (2603:10b6:8:25::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5723.34; Wed, 19 Oct 2022 15:31:13 +0000 Received: from BN8NAM11FT111.eop-nam11.prod.protection.outlook.com (2603:10b6:408:10d:cafe::79) by BN9PR03CA0592.outlook.office365.com (2603:10b6:408:10d::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5723.34 via Frontend Transport; Wed, 19 Oct 2022 15:31:13 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by BN8NAM11FT111.mail.protection.outlook.com (10.13.177.54) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5746.16 via Frontend Transport; Wed, 19 Oct 2022 15:31:13 +0000 Received: from amar-X570-AORUS-ELITE.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Wed, 19 Oct 2022 10:29:41 -0500 From: Somalapuram Amaranath To: , , , Date: Wed, 19 Oct 2022 20:57:35 +0530 Message-ID: <20221019152736.654451-5-Amaranath.Somalapuram@amd.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20221019152736.654451-1-Amaranath.Somalapuram@amd.com> References: <20221019152736.654451-1-Amaranath.Somalapuram@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN8NAM11FT111:EE_|DM8PR12MB5415:EE_ X-MS-Office365-Filtering-Correlation-Id: e2d0c4aa-7ee4-40c4-c990-08dab1e6f4a8 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: uC2pbB+jftov2FQFr6JQJANwGxtw+acPsWbKNCC/F8buEh11++2B6sbDdaDo1MOtAk1TRopVAKlghUd7/Uo+O73evv3Kb++PEHOj9LTsG148s6xqEJahhOB8cHsJXOcvVx4OlrO4CnFUrfvc+sdTsv1me0NEAeRvp2KiyzI5q5PgyGU18NXjsEO2c7BFBY3k8eUtsOttUG4IigksI4tWQbzv2q9KNEr579XrHyWKe2lctSgb0+MmjWcZpICtcxWMEq6xTMAQmjo1BDliRxGr7G7FY9vBxVGNKpre8CQ0/hPcZi+sOpVKj6Mu9GJMYEyJDXysOTxETShvTTvR79Uo+kLRvX4hw76CdkNlzG7dzgmOfAAEOsb1sOXkL2TTwF2GIQzvkDhArbuJroQ3MlVNEyFaXmPyakJ9J/MMqw1cxpAhT32yc19b6xMYWy8kftjYJm2+oiKEISbKGSUMNBXWG13XuFZLkd2RdHyX2uGSEm3QEe9dT77cpEM7huUCIaRWQWTtUfjfwY2MFAfruRl55EpWsD+JXgZA/3+sFmF9vp+7zjzsIanfJ8arc5PTkkDD8XCWo/bVdFJJgZ2X2qX9hCRO625XwcUXYmCtP2n20oqnVopRNHHmfoT34h7wtn09GXAJtvvm4Zo/gMC56gOnb8Hwrk6EDHOXdAU+XMfvVt4nUOxq15uOimv65HIgGnFBMJr+b7of9jGTtqkZztvCeiSdr5O0vQJHTTXSegMzJR7xpvwir1obCz+xPXX/RgfSXXIu1qiTgFuiUzgSAOLDTzePlj7xibqU0WoZAejGOHQ= X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230022)(4636009)(346002)(136003)(39860400002)(376002)(396003)(451199015)(40470700004)(46966006)(36840700001)(110136005)(4326008)(54906003)(5660300002)(6666004)(7696005)(70586007)(70206006)(450100002)(36756003)(8936002)(316002)(26005)(41300700001)(36860700001)(81166007)(82740400003)(356005)(82310400005)(2616005)(40480700001)(426003)(47076005)(40460700003)(16526019)(336012)(186003)(1076003)(2906002)(86362001)(83380400001)(478600001)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Oct 2022 15:31:13.1174 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e2d0c4aa-7ee4-40c4-c990-08dab1e6f4a8 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d; Ip=[165.204.84.17]; Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT111.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM8PR12MB5415 X-Mailman-Approved-At: Mon, 24 Oct 2022 13:23:26 +0000 Subject: [Intel-gfx] =?utf-8?q?=5BPATCH_5/6=5D_drm/radeon=3A_fix=E2=80=99s_o?= =?utf-8?q?n_ttm=5Fresource_rework_to_use_size=5Ft_type?= X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: alexander.deucher@amd.com, Somalapuram Amaranath , arunpravin.paneerselvam@amd.com, christian.koenig@amd.com Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" Fix the ttm_resource from num_pages to size_t size. Signed-off-by: Somalapuram Amaranath --- drivers/gpu/drm/radeon/radeon_cs.c | 4 ++-- drivers/gpu/drm/radeon/radeon_object.c | 4 ++-- drivers/gpu/drm/radeon/radeon_trace.h | 2 +- drivers/gpu/drm/radeon/radeon_ttm.c | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/gpu/drm/radeon/radeon_cs.c b/drivers/gpu/drm/radeon/radeon_cs.c index 446f7bae54c4..4c930f0cf132 100644 --- a/drivers/gpu/drm/radeon/radeon_cs.c +++ b/drivers/gpu/drm/radeon/radeon_cs.c @@ -400,8 +400,8 @@ static int cmp_size_smaller_first(void *priv, const struct list_head *a, struct radeon_bo_list *lb = list_entry(b, struct radeon_bo_list, tv.head); /* Sort A before B if A is smaller. */ - return (int)la->robj->tbo.resource->num_pages - - (int)lb->robj->tbo.resource->num_pages; + return (int)PFN_UP(la->robj->tbo.resource->size) - + (int)PFN_UP(lb->robj->tbo.resource->size); } /** diff --git a/drivers/gpu/drm/radeon/radeon_object.c b/drivers/gpu/drm/radeon/radeon_object.c index 00c33b24d5d3..710d04fcbea6 100644 --- a/drivers/gpu/drm/radeon/radeon_object.c +++ b/drivers/gpu/drm/radeon/radeon_object.c @@ -232,7 +232,7 @@ int radeon_bo_kmap(struct radeon_bo *bo, void **ptr) } return 0; } - r = ttm_bo_kmap(&bo->tbo, 0, bo->tbo.resource->num_pages, &bo->kmap); + r = ttm_bo_kmap(&bo->tbo, 0, PFN_UP(bo->tbo.resource->size), &bo->kmap); if (r) { return r; } @@ -737,7 +737,7 @@ vm_fault_t radeon_bo_fault_reserve_notify(struct ttm_buffer_object *bo) if (bo->resource->mem_type != TTM_PL_VRAM) return 0; - size = bo->resource->num_pages << PAGE_SHIFT; + size = bo->resource->size; offset = bo->resource->start << PAGE_SHIFT; if ((offset + size) <= rdev->mc.visible_vram_size) return 0; diff --git a/drivers/gpu/drm/radeon/radeon_trace.h b/drivers/gpu/drm/radeon/radeon_trace.h index c9fed5f2b870..22676617e1a5 100644 --- a/drivers/gpu/drm/radeon/radeon_trace.h +++ b/drivers/gpu/drm/radeon/radeon_trace.h @@ -22,7 +22,7 @@ TRACE_EVENT(radeon_bo_create, TP_fast_assign( __entry->bo = bo; - __entry->pages = bo->tbo.resource->num_pages; + __entry->pages = PFN_UP(bo->tbo.resource->size); ), TP_printk("bo=%p, pages=%u", __entry->bo, __entry->pages) ); diff --git a/drivers/gpu/drm/radeon/radeon_ttm.c b/drivers/gpu/drm/radeon/radeon_ttm.c index d33fec488713..fff48306c05f 100644 --- a/drivers/gpu/drm/radeon/radeon_ttm.c +++ b/drivers/gpu/drm/radeon/radeon_ttm.c @@ -181,7 +181,7 @@ static int radeon_move_blit(struct ttm_buffer_object *bo, BUILD_BUG_ON((PAGE_SIZE % RADEON_GPU_PAGE_SIZE) != 0); - num_pages = new_mem->num_pages * (PAGE_SIZE / RADEON_GPU_PAGE_SIZE); + num_pages = PFN_UP(new_mem->size) * (PAGE_SIZE / RADEON_GPU_PAGE_SIZE); fence = radeon_copy(rdev, old_start, new_start, num_pages, bo->base.resv); if (IS_ERR(fence)) return PTR_ERR(fence); @@ -268,7 +268,7 @@ static int radeon_bo_move(struct ttm_buffer_object *bo, bool evict, static int radeon_ttm_io_mem_reserve(struct ttm_device *bdev, struct ttm_resource *mem) { struct radeon_device *rdev = radeon_get_rdev(bdev); - size_t bus_size = (size_t)mem->num_pages << PAGE_SHIFT; + size_t bus_size = (size_t)mem->size; switch (mem->mem_type) { case TTM_PL_SYSTEM: From patchwork Wed Oct 19 15:27:36 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Somalapuram Amaranath X-Patchwork-Id: 13017611 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id D27F7C38A2D for ; Mon, 24 Oct 2022 13:24:06 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id BB79110E6E7; Mon, 24 Oct 2022 13:23:43 +0000 (UTC) Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2071.outbound.protection.outlook.com [40.107.223.71]) by gabe.freedesktop.org (Postfix) with ESMTPS id BEB6810F283; Wed, 19 Oct 2022 15:31:29 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=CJgmFMIx/9jN+XWpuTpV4H/S+61wiTolbJB02iCrMacRn4MdDwKrwObDcAG776w5f2RKOoR0+8YhRaV7bQOH+atRkkqg13wz+erV7bWphSh03mtmvyYfezdk7s4lYKhspuwZ/qytylZ7BzlSaSZRwqz6flqcAAiyeHWx1pn+TbFiODyXAylaiDUg8jjQJCwOTseyp9kRwyAqC1BPdtn1MUx8auzkruAxXjpsNFpjhAEBN/O96lhUIa4GmCLAMSI05n8jlLwywTL+W+HaQl/7CczmbqumdMQuLDIO3qHyoeZKc6wkZyiqQbZZdIZArj9C5ke1ur20OxfATPSt/WIZxg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=IOVKGMu3ZjZYcHWM79xuhocGWIPPkIMN0BVn/0VGkrs=; b=MFDdJcvZjbIkSxMg1zsxfmZm4jYGJnKRlyTku9ETBvDqqCa44siIMn5av5S0WQPNqV+lfnYEyn9rRCnR8Nzg6TOL1/5qtgGZQpI+NBbVlaECE/+2vuLCPi9+ohTo2T8TMBk9X9rLdYXGGJbsr6CqsHPAJeupcKpZYAhuBpjNXfc6MMJpsVasifYYgQZLrxIHP3vrdSnVa63QsFZKaOI6xGFBCbbAexJBzHI92GpjgaRqySLOn+oQQWfZffkHbG/PL0CqL0bPzpiBag9kVQ6lRxhKNjlRAtdq9k4csvg1FSGeZtsXvZZAlibtBKf3MvMX1PeMMCpi/0ojD7H85v+wvg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.freedesktop.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=IOVKGMu3ZjZYcHWM79xuhocGWIPPkIMN0BVn/0VGkrs=; b=J1E/UbhSj9LIMTXpbJelKbSbEd/Zit+zOxLEb4pUdbJhWgPqsBzy6BAmYC0g1g7IFfY/9nGB4Ts5hu47W+7N3tPI5rigeWOSHQTsjkzC7MuSMlk/0efyVKEKlUChy5eUqZVY+W18j0KQjwaXP+41+R3H18b7TnADKrhImMameZY= Received: from BN0PR04CA0154.namprd04.prod.outlook.com (2603:10b6:408:eb::9) by CY8PR12MB7219.namprd12.prod.outlook.com (2603:10b6:930:59::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5723.26; Wed, 19 Oct 2022 15:31:27 +0000 Received: from BN8NAM11FT033.eop-nam11.prod.protection.outlook.com (2603:10b6:408:eb:cafe::29) by BN0PR04CA0154.outlook.office365.com (2603:10b6:408:eb::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5723.34 via Frontend Transport; Wed, 19 Oct 2022 15:31:27 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by BN8NAM11FT033.mail.protection.outlook.com (10.13.177.149) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5746.16 via Frontend Transport; Wed, 19 Oct 2022 15:31:27 +0000 Received: from amar-X570-AORUS-ELITE.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Wed, 19 Oct 2022 10:31:11 -0500 From: Somalapuram Amaranath To: , , , Date: Wed, 19 Oct 2022 20:57:36 +0530 Message-ID: <20221019152736.654451-6-Amaranath.Somalapuram@amd.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20221019152736.654451-1-Amaranath.Somalapuram@amd.com> References: <20221019152736.654451-1-Amaranath.Somalapuram@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN8NAM11FT033:EE_|CY8PR12MB7219:EE_ X-MS-Office365-Filtering-Correlation-Id: cb8e17f3-d294-42e1-7430-08dab1e6fd52 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Z3BdmAKPH+aSmEuqMXg190ISvQVFqhorco1NII2i1yxWJQOPfGkyvOAsLpLR3GziDpZTHrDvmecPazk4dlJn86wH21uYFTOnjew6jGZ2psUoJI+74V9ygUpNamhBtvH8gs8iJYA/hyzWCOCHNJh/JnBWNNvbN5afFVgigsrAmL5Dv3I8Gjh9up2f45RP5NynbEFxRgJ5RTnRbuRuj0NTHt6RpetwlxPM+FUR5C/PQazHLvmLE+2z4phtFu2K5DIxnpVrpPdNvtpGv3xzA6CEY1vpOWWoVT6FrN6veOUowEn3zVN8JWRox5zxHNgUaFzzcVDXUICIU0br0IMyNg4PBFKPcpVf2clgqxI/cz4ODRpUvCpxZkNVfYtWH0U87vmDf99vbB6M8WSrYSYbmmrI/R6Kk6YJkm+OCh6IxzFpp8d4Ds50HIDtpMKUJjBiPRJp68yXxAOdxo1qT1VC5FNL0ZyQ9IfGssZVvbXTKxRY3kFvMICc2bprT2t5SsGAyaPLFCdMzdxF12LuafSAjsaEaA/zD7NL4XHvEidcWIzjDeiytbd/zugL4CVJ1VZcZVwEu+sIo1V0XDod3HRtwl2z32ubwB7fsaKWUYzMd8GnzbT1XYci5yB1pHq9R8KWwct0D/32sR5+Lea7mMOFkap6lXzZwIjG51cXvMiFvUg7ii19+Fq+6khgfAjz36oRj2CRJHaWf5Ar7tmkR8t6agEAcXk6TA/RtNcRDF1FWWQiXRyvMwffFItkWz8cTg9L9LbWn5BMa23HXmJSMi3ylvKqN6bpcUswOA7PKgQDdQbOs2SqRpIfwY6bd9byb4LkZ2bZ X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230022)(4636009)(136003)(376002)(346002)(396003)(39860400002)(451199015)(40470700004)(36840700001)(46966006)(2906002)(40480700001)(5660300002)(81166007)(356005)(82740400003)(36860700001)(82310400005)(86362001)(336012)(36756003)(40460700003)(83380400001)(426003)(47076005)(186003)(2616005)(16526019)(1076003)(26005)(478600001)(7696005)(6666004)(450100002)(4326008)(70586007)(70206006)(110136005)(54906003)(41300700001)(316002)(8936002)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Oct 2022 15:31:27.6667 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: cb8e17f3-d294-42e1-7430-08dab1e6fd52 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d; Ip=[165.204.84.17]; Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT033.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY8PR12MB7219 X-Mailman-Approved-At: Mon, 24 Oct 2022 13:23:26 +0000 Subject: [Intel-gfx] =?utf-8?q?=5BPATCH_6/6=5D_drm/vmwgfx=3A_fix=E2=80=99s_o?= =?utf-8?q?n_ttm=5Fresource_rework_to_use_size=5Ft_type?= X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: alexander.deucher@amd.com, Somalapuram Amaranath , arunpravin.paneerselvam@amd.com, christian.koenig@amd.com Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" Fix the ttm_resource from num_pages to size_t size. Signed-off-by: Somalapuram Amaranath --- drivers/gpu/drm/vmwgfx/vmwgfx_blit.c | 4 ++-- drivers/gpu/drm/vmwgfx/vmwgfx_bo.c | 6 +++--- drivers/gpu/drm/vmwgfx/vmwgfx_cotable.c | 2 +- drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c | 2 +- drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c | 6 +++--- drivers/gpu/drm/vmwgfx/vmwgfx_kms.c | 2 +- drivers/gpu/drm/vmwgfx/vmwgfx_page_dirty.c | 6 +++--- 7 files changed, 14 insertions(+), 14 deletions(-) diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_blit.c b/drivers/gpu/drm/vmwgfx/vmwgfx_blit.c index 09fe20e918f9..c52c7bf1485b 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_blit.c +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_blit.c @@ -483,8 +483,8 @@ int vmw_bo_cpu_blit(struct ttm_buffer_object *dst, d.src_addr = NULL; d.dst_pages = dst->ttm->pages; d.src_pages = src->ttm->pages; - d.dst_num_pages = dst->resource->num_pages; - d.src_num_pages = src->resource->num_pages; + d.dst_num_pages = PFN_UP(dst->resource->size); + d.src_num_pages = PFN_UP(src->resource->size); d.dst_prot = ttm_io_prot(dst, dst->resource, PAGE_KERNEL); d.src_prot = ttm_io_prot(src, src->resource, PAGE_KERNEL); d.diff = diff; diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_bo.c b/drivers/gpu/drm/vmwgfx/vmwgfx_bo.c index 822251aaab0a..134a13a50861 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_bo.c +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_bo.c @@ -194,7 +194,7 @@ int vmw_bo_pin_in_start_of_vram(struct vmw_private *dev_priv, int ret = 0; place = vmw_vram_placement.placement[0]; - place.lpfn = bo->resource->num_pages; + place.lpfn = PFN_UP(bo->resource->size); placement.num_placement = 1; placement.placement = &place; placement.num_busy_placement = 1; @@ -211,7 +211,7 @@ int vmw_bo_pin_in_start_of_vram(struct vmw_private *dev_priv, * that situation. */ if (bo->resource->mem_type == TTM_PL_VRAM && - bo->resource->start < bo->resource->num_pages && + bo->resource->start < PFN_UP(bo->resource->size) && bo->resource->start > 0 && buf->base.pin_count == 0) { ctx.interruptible = false; @@ -352,7 +352,7 @@ void *vmw_bo_map_and_cache(struct vmw_buffer_object *vbo) if (virtual) return virtual; - ret = ttm_bo_kmap(bo, 0, bo->resource->num_pages, &vbo->map); + ret = ttm_bo_kmap(bo, 0, PFN_UP(bo->resource->size), &vbo->map); if (ret) DRM_ERROR("Buffer object map failed: %d.\n", ret); diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_cotable.c b/drivers/gpu/drm/vmwgfx/vmwgfx_cotable.c index 79b30dc9d825..c5ed49241f9d 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_cotable.c +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_cotable.c @@ -427,7 +427,7 @@ static int vmw_cotable_resize(struct vmw_resource *res, size_t new_size) * Do a page by page copy of COTables. This eliminates slow vmap()s. * This should really be a TTM utility. */ - for (i = 0; i < old_bo->resource->num_pages; ++i) { + for (i = 0; i < PFN_UP(old_bo->resource->size); ++i) { bool dummy; ret = ttm_bo_kmap(old_bo, i, 1, &old_map); diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c b/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c index f085dbd4736d..2fb53aa57a56 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c @@ -1047,7 +1047,7 @@ static int vmw_query_bo_switch_prepare(struct vmw_private *dev_priv, if (unlikely(new_query_bo != sw_context->cur_query_bo)) { - if (unlikely(new_query_bo->base.resource->num_pages > 4)) { + if (unlikely(PFN_UP(new_query_bo->base.resource->size) > 4)) { VMW_DEBUG_USER("Query buffer too large.\n"); return -EINVAL; } diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c b/drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c index 60e3cc537f36..abd5e3323ebf 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c @@ -71,7 +71,7 @@ static int vmw_gmrid_man_get_node(struct ttm_resource_manager *man, spin_lock(&gman->lock); if (gman->max_gmr_pages > 0) { - gman->used_gmr_pages += (*res)->num_pages; + gman->used_gmr_pages += PFN_UP((*res)->size); /* * Because the graphics memory is a soft limit we can try to * expand it instead of letting the userspace apps crash. @@ -114,7 +114,7 @@ static int vmw_gmrid_man_get_node(struct ttm_resource_manager *man, return 0; nospace: - gman->used_gmr_pages -= (*res)->num_pages; + gman->used_gmr_pages -= PFN_UP((*res)->size); spin_unlock(&gman->lock); ida_free(&gman->gmr_ida, id); ttm_resource_fini(man, *res); @@ -129,7 +129,7 @@ static void vmw_gmrid_man_put_node(struct ttm_resource_manager *man, ida_free(&gman->gmr_ida, res->start); spin_lock(&gman->lock); - gman->used_gmr_pages -= res->num_pages; + gman->used_gmr_pages -= PFN_UP(res->size); spin_unlock(&gman->lock); ttm_resource_fini(man, res); kfree(res); diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c index 214829c32ed8..46c2642b3ec5 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c @@ -587,7 +587,7 @@ vmw_du_cursor_plane_prepare_fb(struct drm_plane *plane, cm_bo = vcp->cursor_mob[cursor_mob_idx]; - if (cm_bo->resource->num_pages * PAGE_SIZE < size) { + if (cm_bo->resource->size < size) { ret = -EINVAL; goto error_bo_unmap; } diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_page_dirty.c b/drivers/gpu/drm/vmwgfx/vmwgfx_page_dirty.c index 7bc99b1279f7..f41f041559f4 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_page_dirty.c +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_page_dirty.c @@ -230,7 +230,7 @@ void vmw_bo_dirty_unmap(struct vmw_buffer_object *vbo, int vmw_bo_dirty_add(struct vmw_buffer_object *vbo) { struct vmw_bo_dirty *dirty = vbo->dirty; - pgoff_t num_pages = vbo->base.resource->num_pages; + pgoff_t num_pages = PFN_UP(vbo->base.resource->size); size_t size; int ret; @@ -395,7 +395,7 @@ vm_fault_t vmw_bo_vm_mkwrite(struct vm_fault *vmf) return ret; page_offset = vmf->pgoff - drm_vma_node_start(&bo->base.vma_node); - if (unlikely(page_offset >= bo->resource->num_pages)) { + if (unlikely(page_offset >= PFN_UP(bo->resource->size))) { ret = VM_FAULT_SIGBUS; goto out_unlock; } @@ -438,7 +438,7 @@ vm_fault_t vmw_bo_vm_fault(struct vm_fault *vmf) page_offset = vmf->pgoff - drm_vma_node_start(&bo->base.vma_node); - if (page_offset >= bo->resource->num_pages || + if (page_offset >= PFN_UP(bo->resource->size) || vmw_resources_clean(vbo, page_offset, page_offset + PAGE_SIZE, &allowed_prefault)) {