From patchwork Mon Sep 18 12:35:26 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "StDenis, Tom" X-Patchwork-Id: 9956615 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 A419F60385 for ; Mon, 18 Sep 2017 12:35:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 950B728C6D for ; Mon, 18 Sep 2017 12:35:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 89D8D28CA8; Mon, 18 Sep 2017 12:35:45 +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 4AD1B28C6D for ; Mon, 18 Sep 2017 12:35:45 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 480246E365; Mon, 18 Sep 2017 12:35:39 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from NAM03-BY2-obe.outbound.protection.outlook.com (mail-by2nam03on0075.outbound.protection.outlook.com [104.47.42.75]) by gabe.freedesktop.org (Postfix) with ESMTPS id 22D016E0C6; Mon, 18 Sep 2017 12:35:36 +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=jspeRPEfKmpvEgc5dxYXV8JJ1nBTMRb4sdrkzn7Eggc=; b=rGKceuvUeF4pZlEL4VZS7brqRGYizy0Ys8Ho7HpOkXZzghCe4OTHBxT0cIVGOj+uF6BgahjliZywCeVCDjvuSXuNRIEmE0tESdL8LAvvWT+3q2iInWBqcxWrb+VJAc6LQfUWQPnQQXsRg2DnH9oraQtFGGLA2BLJtiOqUw2GxqU= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Tom.StDenis@amd.com; Received: from fx8.amd.com (165.204.55.251) by DM5PR1201MB0074.namprd12.prod.outlook.com (10.174.106.16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.56.8; Mon, 18 Sep 2017 12:35:35 +0000 From: Tom St Denis To: amd-gfx@lists.freedesktop.org Subject: [PATCH 2/4] drm/amd/amdgpu: add support for iova_to_phys to replace TTM trace Date: Mon, 18 Sep 2017 08:35:26 -0400 Message-Id: <20170918123528.26629-3-tom.stdenis@amd.com> X-Mailer: git-send-email 2.12.0 In-Reply-To: <20170918123528.26629-1-tom.stdenis@amd.com> References: <20170918123528.26629-1-tom.stdenis@amd.com> MIME-Version: 1.0 X-Originating-IP: [165.204.55.251] X-ClientProxiedBy: MWHPR1401CA0007.namprd14.prod.outlook.com (10.174.253.145) To DM5PR1201MB0074.namprd12.prod.outlook.com (10.174.106.16) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 9defc100-9b46-4c0e-72ab-08d4fe91c2ca X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(300000500095)(300135000095)(300000501095)(300135300095)(22001)(300000502095)(300135100095)(2017030254152)(48565401081)(300000503095)(300135400095)(2017052603199)(201703131423075)(201703031133081)(201702281549075)(300000504095)(300135200095)(300000505095)(300135600095)(300000506095)(300135500095); SRVR:DM5PR1201MB0074; X-Microsoft-Exchange-Diagnostics: 1; DM5PR1201MB0074; 3:x/ldRoT3lnaXEypc3htCZbMuG0i3KUpFEUiZlz0Y/i+E3I6wTOsH0lEIa3OwkIahWkKVffWLQm/GCs+Fic0nFuEj+VNBQir9vS1sZxJKO89oAI/wQNvmfYP2pJVK9C94FHoAc+kQ4jXCXvi9GlXyk7hB0X3w47LMcPqHNUcqAbmmD37vmLUPpcTM0p/jD/DxTaX21S5FUVZvKzIzARRy9grKppKd/RtPZ/QCSA+5cYDPLKOAuUBU5mB4bHLOorJU; 25:gDPtqLQYIIYK7YVCEDgTxIY3a7ysDcf+OTHyvw2nWVTS8AmgpFno7tuS/G0zbk+2yl1mni2tS3dc63mjJBU2Pz2vAGaUsP2ZOyOqrQKkbA5PVH9jz4/dZccmpSC+qDoH6C/1BZrxCjnWQPz/+vBocE8vd0Rkd+jfK5REXdY2bm3ufFOV4ETxSdiOmfQP49fy94g1Q0RRnHfH9bJrfxlpK1+VFCQsf32Z1x8ECaGOyH48dQT3N/25Me4rDq3guly7XjHbVphMbDAk0kMEGjVsQMWrZAYGRhnZKtxBzYqkDE/gv6QPtGZ/hoMVUrS4+aGAsEQiv7+206qoaogf5MwQAg==; 31:e+nyeQlsQnGqaMyU7HbsOV3iil01aTaUxo96Qb0VHh/h9HRJvSsS1gl7ozVXClcrHp7JPo6gtzMChNQVIQAjFksL8wJeV9en16sn9SJNm3f0SKI7t8OYQmxrPEz6F6pZNQZHFLhq90+0WC1B83PUcF369GHz543hITJJNDL+S0b7DUFRUiUgPGEHaPyh8R79E0Rd2GchWBFd9Qaxwukbx3hTxlQSFO0BFFDzPaFN07U= X-MS-TrafficTypeDiagnostic: DM5PR1201MB0074: X-Microsoft-Exchange-Diagnostics: 1; DM5PR1201MB0074; 20:KURr/dZHarS0Aw/zU46Bz3XnS0+0DAhTGW6lKF2pHgcAs7tTlLsmK7/ReXp5Ww+rg2M6q5Q2MDBpTugSx5tDst6H2VLNy5JJ/ygPqm95rV4U3yqV1BDkAl5Q5pmVVF/CdGvXknWi/fW9p4XrcLH6JuFjqCxx0J18IiniyfnQ33mrAJ8zM06KmhalZ5E6QPcI9w35RdrB1REK0t3+QsBQsiBZa798mFHeU/Eq19LRZ6YB8SA0fgcl91nUrG9uA1jsv6BxqzxWSOZkWm9HQ03MK5m0IwGVXK1e74pIOWhWc0VZPC/71C9IHi8q1vI6qtGtNKsEGRRlRHwVTVu0Yns0hMcfRrBiOKh8hgXKRJ0RRMN/HnErhjcJMbjF40HsMnS3gZUjtIGqjWMIFjq6Fz1VKrcEDrjNqBX2ygIuNY/uwg8KVNc8tKWxTedUPfOkN7R8Pa81ZxmskkOqz9PbTwj7Bl8dlaARX72N4VkMloUFGGm7PN6M08tiTFBldJI/b4qE; 4:wcg/mm9x+HsuQhz1UzHDdN0Ls2+jpFz2F/sDLQEe/K4m5+r5ERctK5xnnfdpE2o9bg1UyDx1OG6Bn7LZOY4wMgmBClNiDKhS9gT3nAzhQgsctgSN1FB6a42xoPp0psuFSOgIxUmBqOMQHybaP5iGTv6zYR5IixkvWjEwKJUAVgAwDlD86/XUit1ITjgAXGES9fTMOS037W4o7Zxtugpu4ruN8S4Dk++JcsoCmZWRi+cqDLPzniUYPA3pWbOBOCCeGLdqCTOGu7Qvi7Ob6iS9E0rU1eqbnisxdvOiB8WOIOzyouvbEVrmZmT52qFjCyzv X-Exchange-Antispam-Report-Test: UriScan:(767451399110)(788757137089); X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(2401047)(8121501046)(5005006)(100000703101)(100105400095)(3002001)(93006095)(93001095)(10201501046)(6055026)(6041248)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123560025)(20161123562025)(20161123564025)(20161123558100)(20161123555025)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095); SRVR:DM5PR1201MB0074; BCL:0; PCL:0; RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095); SRVR:DM5PR1201MB0074; X-Forefront-PRVS: 04347F8039 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(6009001)(346002)(39860400002)(376002)(199003)(189002)(101416001)(81156014)(2950100002)(53936002)(4326008)(16526017)(316002)(6486002)(6916009)(86362001)(6666003)(8676002)(7736002)(2906002)(66066001)(189998001)(305945005)(81166006)(110136004)(16586007)(97736004)(5660300001)(36756003)(2351001)(76176999)(68736007)(72206003)(25786009)(450100002)(50466002)(50226002)(3846002)(6116002)(33646002)(48376002)(47776003)(5003940100001)(478600001)(50986999)(8936002)(106356001)(1076002)(105586002)(53416004)(2361001); DIR:OUT; SFP:1101; SCL:1; SRVR:DM5PR1201MB0074; 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; DM5PR1201MB0074; 23:c+fPBy8myq53RtOzHgOdpUTJzQaHZ3QgsgGpAPg?= =?us-ascii?Q?sDwwZs9Qkix4GU8PYovEH1l8b6a5N4fUUmLBhtl7TWVFkml//2YiSFdaLlBA?= =?us-ascii?Q?XftXHAomNylDICwChfg8XaoBdJAeuU0YCoPPGMqwwiRhT4YZp2BMGuIEypvm?= =?us-ascii?Q?Un7mXJyMGXdxCMlVY6YhVFBnwNLRlD2jTrFH+sOCARgtxfmvcBN703Q6zWQ+?= =?us-ascii?Q?KJaSDdn5W4swwJdoJFGFmALhtAAHnC26f3/e3xIrToHU4kGTtzryyOR66zYH?= =?us-ascii?Q?GuiGkMCFvvu0y9J7itczvYoau3Ep7DdFrbWl1AOz02PU2niS21/abtJddC6q?= =?us-ascii?Q?bCiD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soft-Exchange-Diagnostics: 1; DM5PR1201MB0074; 6:4QE3B61rJXanOMcuU0Z+utDPCHOD7/7y1Jpas8Z/98ZqvEONMzocsJ5BqLfkytl33d38+TfQ00VLZPavj1//Ip/ySnDgp+xZYH8LytuoNiwiKr3zBsWqc4zudvHpctUOFMk2VtGXW8v/G2EXCUlT67Qz41TlslQ2sc/NDGoE94wnLE4yYOvabzJzbasny+5RYi90pSDCL9GbUBY0YcfJAGkiNSe0lSHiBOmVPXRJhfGdlxQi4Lev6J0iPJ7AtrnUvdfLbe4S52zKN8BuVyX77KLA/KhMRa7H8TnHOTSB9Okrg82Bpdnj0CAbhTJkPIyCTAdk+3bL7BWuk/wkRTtjJQ==; 5:y4SsADlG52z5xiuX3RCt85jxqfXiV/zysI+8yDXCNJIUj/KT3C3FY2/weonowg9qLdB4Flc7s2ZtwKDS2J3Gz02OYEh07xVrqBsO8jVikFLvw0zpp2G7dghtnuYqUfn1Jxy6LipfVZrcSJpX4tBs5w==; 24:K9znzawBYK8ax0YDfI4QR0kQzQ1lVwch9koA2XynuobCwRUrOKe2ukNfP7V+GlWbkhB6SJklsa1jJmZoUl9kSmqTzcWWZChTJnNs1D5QTkY=; 7:Lamk8+fA+W3FfABLFV0md61UbsVKiLcJECw3UQIZuRT5nlvn/ZiR4CND2r7QukKOPHTFIaRGHGX2RtZBfxTFcFjdKnint6mjnIDwQiouGiFFy5GRiG3OXd/Haw4tB0BAmipjzbJ31WCJgyqSsrSB0d+Q5Q9TP9DgNi8/goBrgPTLw7q2lQQ3WMK3lJot2mv197tBVm779VbEZN7RSCVvquG1k3Gtf5XSkapJLmJorIQ= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; DM5PR1201MB0074; 20:WF7QFbztE3/Cqe2Y4E5wmpLcKCVXKHYwXo6rXb3ONjU7F7uzetSFRda4RhC17l6/y4IjGpSi/v64Ft5PoAOGLnSg39EzbGDyvOFZxcnh8p4HaOwAp97lt4B86XgnbCY+LYeOrPHaCOgFGvoQAH3vstNxcDeljhnUQTz112QFcWvn/MdcDeo6pA0/9Zf2aKDkU0eLRuUS5ZVbvWCR9uanGKpumn+cNN+JR+hE20Rx9KzM7c3+H+ntSNjTH2tOhxQf X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Sep 2017 12:35:35.1905 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR1201MB0074 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 Signed-off-by: Tom St Denis --- drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c index 7848ffa99eb4..b4c298925e2a 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c @@ -43,6 +43,7 @@ #include #include #include +#include #include "amdgpu.h" #include "amdgpu_trace.h" #include "bif/bif_4_1_d.h" @@ -1810,6 +1811,36 @@ static const struct file_operations amdgpu_ttm_gtt_fops = { #endif +static ssize_t amdgpu_iova_to_phys_read(struct file *f, char __user *buf, + size_t size, loff_t *pos) +{ + struct amdgpu_device *adev = file_inode(f)->i_private; + int r; + uint64_t phys; + + // always return 8 bytes + if (size != 8) + return -EINVAL; + + // only accept page addresses + if (*pos & 0xFFF) + return -EINVAL; + + + phys = iommu_iova_to_phys(iommu_get_domain_for_dev(adev->dev), *pos); + + r = copy_to_user(buf, &phys, 8); + if (r) + return -EFAULT; + + return 8; +} + +static const struct file_operations amdgpu_ttm_iova_fops = { + .owner = THIS_MODULE, + .read = amdgpu_iova_to_phys_read, + .llseek = default_llseek +}; static const struct { char *name; @@ -1819,6 +1850,7 @@ static const struct { #ifdef CONFIG_DRM_AMDGPU_GART_DEBUGFS { "amdgpu_gtt", &amdgpu_ttm_gtt_fops }, #endif + { "amdgpu_iova", &amdgpu_ttm_iova_fops }, }; #endif