From patchwork Fri Aug 18 14:23:00 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "StDenis, Tom" X-Patchwork-Id: 9909277 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 4EF2960382 for ; Fri, 18 Aug 2017 14:38:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3AE4628CE2 for ; Fri, 18 Aug 2017 14:38:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2FA7928CEC; Fri, 18 Aug 2017 14:38:41 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.6 required=2.0 tests=BAD_ENC_HEADER,BAYES_00, DKIM_SIGNED, RCVD_IN_DNSWL_MED, RCVD_IN_SORBS_WEB, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 9193A28CE2 for ; Fri, 18 Aug 2017 14:38:40 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 26BB96E089; Fri, 18 Aug 2017 14:38:38 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org X-Greylist: delayed 1009 seconds by postgrey-1.35 at gabe; Fri, 18 Aug 2017 14:38:37 UTC Received: from NAM02-BL2-obe.outbound.protection.outlook.com (mail-bl2nam02on0054.outbound.protection.outlook.com [104.47.38.54]) by gabe.freedesktop.org (Postfix) with ESMTPS id 18B066E089 for ; Fri, 18 Aug 2017 14:38:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amdcloud.onmicrosoft.com; s=selector1-amd-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=Chy69NVT35XsTjjDDe0Et/x+BXgGaPxBnZmtYzampN8=; b=JfgOgyKL/H4e5Vf42PHWVxIl8u4vTOPhg4Co375PWJ7G90o1UO4892Fg1jVa4PSz+4iogqyiro4Ott6NvNoisyPocNiSUEpvA6LGWWwod84GAzz0eOE6lkMVZlUr4v9piA9nTyTE9kzePeR/isl9/rqMxybA5lcvYJsP4fbpAoQ= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Tom.StDenis@amd.com; Received: from fx8.amd.com (165.204.55.251) by MWHPR1201MB0080.namprd12.prod.outlook.com (10.174.98.19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.1.1362.18; Fri, 18 Aug 2017 14:23:14 +0000 From: Tom St Denis To: nouveau@lists.freedesktop.org Subject: [PATCH] drm/nouveau: use new TTM populate/DMA map function Date: Fri, 18 Aug 2017 10:23:00 -0400 Message-Id: <20170818142300.9787-1-tom.stdenis@amd.com> X-Mailer: git-send-email 2.12.0 MIME-Version: 1.0 X-Originating-IP: [165.204.55.251] X-ClientProxiedBy: MWHPR14CA0050.namprd14.prod.outlook.com (10.173.97.140) To MWHPR1201MB0080.namprd12.prod.outlook.com (10.174.98.19) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: c984ad73-b52e-4571-0fb3-08d4e644a9e0 X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(300000500095)(300135000095)(300000501095)(300135300095)(22001)(300000502095)(300135100095)(2017030254152)(300000503095)(300135400095)(48565401081)(201703131423075)(201703031133081)(201702281549075)(300000504095)(300135200095)(300000505095)(300135600095)(300000506095)(300135500095); SRVR:MWHPR1201MB0080; X-Microsoft-Exchange-Diagnostics: 1; MWHPR1201MB0080; 3:tDIUwoAwN4AXBKbN+8LcSfKbKLFrSXgdxtuQydIeu1NXKxRwqor4drUDA/lAmeveNCBQ2upmxNE47MEBdkQmHXJhtt+a/eQfkTp06v08V1uCUdk4eti5Gs4wU5t3Vzk9W5+Tw63aKzFlR5pq/bzV8PnLBV9SSCq+cXJTKWG6H5OTWKiDdYUAEOsLwTEoweuIXW/oFzqVk4XB7KNn07qic10Jeh0HLth9OdrJJyio6FglZbsR+ej6l6/mUigztANR; 25:gIwlSxwhla1DNvuDeB0KNS8VWuoeCP9RyZ4Q4Aqz+UeDl5SRS4Muc85BFU61Dxaw+w8cUO/F92iJX3fN3pDLP4Pwta3CDpArB1USpbo18fXk4CkS2+1PQVrTp0xPRKJGf6iBqWz0LNNYAp+g4rE4DeGSfHm29LX2L4vw7bao9CNK130eJcxzGDrByCBZfyP9K2ePsliLoNUvTlRnqUVdA2fZeUw/DMdKFBcJ6wk+N0pZw+aRe2c89sE0weEnMyxpxkgXNXpD9qwI6S77zEsb//kD0qOQqjNKOhe3cZQSXFboSrZ35lQj8VtiaCLU9rTcs7xHq8ENXHf54qwFv8EOMA==; 31:uWRTFj0C2J5RSjzEAwOCinLb58eoqH6xeRt/ZTCkulMuhXPh0QBmBB7Gk1KQC0a1G0FoiErTD755X9qPHn9Y533sbO61Z4K+YQse8xkroPKuvQc8etZJesvuPpZj5UoHHCY4MOAEtpyiGHA75FO0MIYwmSD/0YHDho/gqGTevDQMhfOjrlI+S/ZvJftPHySFPEnQYekwaevGTrEiTDgR2p6fj7bPnuf02292jeB9V0M= X-MS-TrafficTypeDiagnostic: MWHPR1201MB0080: X-Microsoft-Exchange-Diagnostics: 1; MWHPR1201MB0080; 20:l3P3lVWrS1Qts9dl8KS32dMMiXCKnlHdhLGcgADBjSQVFPKujdpX0FkvBpNKKca1K4XSJtQcafdvPtUUYEBDAfPkj9GK/ckraH7McZoJYSQXw0rCR2v0cXbIffhvosDSHLjspSk6YxFfMe+vXqyzXePxT7xMT4p2BPEeeOksb+pG0VvKsFKBdAYifY1Mn0cwuIwuRclCmFU7hIWqE5yS74ev8n2HkqWRORwzDjyx3v+Hp2Ta9pbu0lpSAcdGEOYbXST0z1MGiGSGl0h1a6UDF4DXOCcT4tF0vaYoYn9/EwQOMWopWQquWkhbA5xs9ad59BKrCl0rS7BHxuJKn7bF26r7pboKQHjzl19PIgkWJinEAAk77UbbKbgFrydDhlzToryJ7EIIJCm5d4n7ym56cMBJB7o+Tq0pL+fXHTNg2FcFArIR9lWjNYt7UgJCmKIojExV4Wz9DXOKFmVf4oyL+zHaIG716qUsWZ/K61RM3TzWwEsgvf1SxAWsN45keDXQ; 4:MOA3DqOIGRk96KaZhnowjSKpFQBZeqrCUMdgjvWbW+vW8iEhu8gp+7GBx8GrWhLVz+bpWtXpFv40tj8lO7zTDj7oY85eWL/FqiXSs0S9C8JON1uX37Sn4qFhT5fwXuNEk5K8AA1RbrLXdtrZ6vePSnkaOP5kepK2O0xS9Tn4nZIlVIJJll2u9WEMyE7VqGG0iQpBlGgg9sc9yr1fmPEgrWmOK4Zc5zEVoNMmW6nLrQqTKM7+1nxinOV6bpRUAf8Z9GSt3UwRa3ZI2Zd1qveeJcQvyGLigugcmWbf9AtMdYU= X-Exchange-Antispam-Report-Test: UriScan:(767451399110); X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(601004)(2401047)(8121501046)(5005006)(93006095)(93001095)(10201501046)(100000703101)(100105400095)(3002001)(6055026)(6041248)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123555025)(20161123564025)(20161123560025)(20161123558100)(20161123562025)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095); SRVR:MWHPR1201MB0080; BCL:0; PCL:0; RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095); SRVR:MWHPR1201MB0080; X-Forefront-PRVS: 040359335D X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4630300001)(7370300001)(6009001)(39860400002)(199003)(189002)(8676002)(81166006)(6486002)(81156014)(72206003)(2351001)(106356001)(33646002)(5660300001)(50226002)(7736002)(2361001)(4326008)(86362001)(36756003)(7350300001)(189998001)(575784001)(110136004)(5003940100001)(305945005)(2906002)(97736004)(53936002)(42186005)(3846002)(6116002)(101416001)(25786009)(47776003)(50986999)(53416004)(6916009)(6666003)(68736007)(478600001)(50466002)(66066001)(1076002)(48376002)(105586002)(450100002); DIR:OUT; SFP:1101; SCL:1; SRVR:MWHPR1201MB0080; H:fx8.amd.com; FPR:; SPF:None; PTR:InfoNoRecords; A:1; MX:1; LANG:en; Received-SPF: None (protection.outlook.com: amd.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; MWHPR1201MB0080; 23:uJiTbGTdj/pszH1OTUCXkJYEThdiFHcG/+hU1U3?= =?us-ascii?Q?CxwmfAAYa6deUqaWFNldFxJqMPwFzqbF4CFZGgJEs7WrvJDHLXSK2Nv0GrZY?= =?us-ascii?Q?NFLR4CbyVcu/Zwy9g7gUJ71JQjeqidGUVsBdHkQ8+XNZ1XJWMvAtj9bU7ibc?= =?us-ascii?Q?10qr643h4hSwmQ/PWdOC77+kXTtYSf8DrIquwcS+kzw1f9hrAo6cKIH5UW7g?= =?us-ascii?Q?g4yv5mjUW6906hr5Qo2iqqF4H78MPdHsofzpqyJt3QBC1l2ZgVpBRnNF3FDu?= =?us-ascii?Q?kgOq3t/6dlKfd+vgb4XPOilcBbaMDRd6uDES2JAEaWclCaAMur0LFVyMo3hD?= =?us-ascii?Q?zY1LW4dEFiYShFpljCZMV2+0d+xPIjFHmk5qMs4UTbMKPShdWvVcxJyEIZtL?= =?us-ascii?Q?v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IepgfszhlTFXzK8CjugG6mzAcYyooNnNrxK X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Aug 2017 14:23:14.4218 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR1201MB0080 Cc: Tom St Denis , dri-devel@lists.freedesktop.org X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP Removes common code found in numerous vendor drivers and places it higher up in the TTM tree. Signed-off-by: Tom St Denis --- drivers/gpu/drm/nouveau/nouveau_bo.c | 37 ++---------------------------------- 1 file changed, 2 insertions(+), 35 deletions(-) diff --git a/drivers/gpu/drm/nouveau/nouveau_bo.c b/drivers/gpu/drm/nouveau/nouveau_bo.c index e427f80344c4..6ad0ad53047a 100644 --- a/drivers/gpu/drm/nouveau/nouveau_bo.c +++ b/drivers/gpu/drm/nouveau/nouveau_bo.c @@ -1448,8 +1448,6 @@ nouveau_ttm_tt_populate(struct ttm_tt *ttm) struct nvkm_device *device; struct drm_device *dev; struct device *pdev; - unsigned i; - int r; bool slave = !!(ttm->page_flags & TTM_PAGE_FLAG_SG); if (ttm->state != tt_unpopulated) @@ -1480,30 +1478,7 @@ nouveau_ttm_tt_populate(struct ttm_tt *ttm) } #endif - r = ttm_pool_populate(ttm); - if (r) { - return r; - } - - for (i = 0; i < ttm->num_pages; i++) { - dma_addr_t addr; - - addr = dma_map_page(pdev, ttm->pages[i], 0, PAGE_SIZE, - DMA_BIDIRECTIONAL); - - if (dma_mapping_error(pdev, addr)) { - while (i--) { - dma_unmap_page(pdev, ttm_dma->dma_address[i], - PAGE_SIZE, DMA_BIDIRECTIONAL); - ttm_dma->dma_address[i] = 0; - } - ttm_pool_unpopulate(ttm); - return -EFAULT; - } - - ttm_dma->dma_address[i] = addr; - } - return 0; + return ttm_populate_and_map_pages(pdev, ttm_dma); } static void @@ -1514,7 +1489,6 @@ nouveau_ttm_tt_unpopulate(struct ttm_tt *ttm) struct nvkm_device *device; struct drm_device *dev; struct device *pdev; - unsigned i; bool slave = !!(ttm->page_flags & TTM_PAGE_FLAG_SG); if (slave) @@ -1539,14 +1513,7 @@ nouveau_ttm_tt_unpopulate(struct ttm_tt *ttm) } #endif - for (i = 0; i < ttm->num_pages; i++) { - if (ttm_dma->dma_address[i]) { - dma_unmap_page(pdev, ttm_dma->dma_address[i], PAGE_SIZE, - DMA_BIDIRECTIONAL); - } - } - - ttm_pool_unpopulate(ttm); + ttm_unmap_and_unpopulate_pages(pdev, ttm_dma); } void