AMD-GFX Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Tom St Denis <tom.stdenis-5C7GfCeVMHo@public.gmane.org>
To: amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org
Cc: Tom St Denis <tom.stdenis-5C7GfCeVMHo@public.gmane.org>,
	dri-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.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	[thread overview]
Message-ID: <20170918123528.26629-3-tom.stdenis@amd.com> (raw)
In-Reply-To: <20170918123528.26629-1-tom.stdenis-5C7GfCeVMHo@public.gmane.org>

Signed-off-by: Tom St Denis <tom.stdenis@amd.com>
---
 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 <linux/swap.h>
 #include <linux/pagemap.h>
 #include <linux/debugfs.h>
+#include <linux/iommu.h>
 #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
-- 
2.12.0

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

  parent reply	other threads:[~2017-09-18 12:35 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-09-18 12:35 Remove TTM trace and use proper IOMMU api Tom St Denis
2017-09-18 12:35 ` [PATCH 1/4] drm/amd/amdgpu: Fold TTM debugfs entries into array Tom St Denis
     [not found]   ` <20170918123528.26629-2-tom.stdenis-5C7GfCeVMHo@public.gmane.org>
2017-09-18 12:48     ` Christian König
     [not found]       ` <049ebf9c-5293-f121-f005-a49ffeb65508-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2017-09-18 13:01         ` Tom St Denis
     [not found]           ` <350a7d1b-7548-1347-b7bc-533acb47b1b7-5C7GfCeVMHo@public.gmane.org>
2017-09-18 13:03             ` Christian König
     [not found] ` <20170918123528.26629-1-tom.stdenis-5C7GfCeVMHo@public.gmane.org>
2017-09-18 12:35   ` Tom St Denis [this message]
2017-09-18 12:52     ` [PATCH 2/4] drm/amd/amdgpu: add support for iova_to_phys to replace TTM trace Christian König
     [not found]       ` <927ae529-10cf-5cc9-fb96-76db8cfc0936-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2017-09-18 12:56         ` Tom St Denis
2017-09-18 12:35   ` [PATCH 4/4] drm/ttm: Remove TTM dma tracepoint since it's not required anymore Tom St Denis
2017-09-18 12:35 ` [PATCH 3/4] drm/amd/amdgpu: remove usage of ttm trace Tom St Denis

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170918123528.26629-3-tom.stdenis@amd.com \
    --to=tom.stdenis-5c7gfcevmho@public.gmane.org \
    --cc=amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org \
    --cc=dri-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox