mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
To: linux-kernel@vger.kernel.org, thellstrom@vmware.com,
	dri-devel@lists.freedesktop.org, bskeggs@redhat.com,
	j.glisse@redhat.com, thomas@shipmail.org, airlied@redhat.com,
	airlied@linux.ie, alexdeucher@gmail.com
Cc: xen-devel@lists.xensource.com,
	Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Subject: [PATCH 8/9] ttm/tt: Move ttm_tt_set_page_caching implementation in TTM page pool code.
Date: Thu, 29 Sep 2011 16:33:51 -0400	[thread overview]
Message-ID: <1317328432-25620-9-git-send-email-konrad.wilk@oracle.com> (raw)
In-Reply-To: <1317328432-25620-1-git-send-email-konrad.wilk@oracle.com>

. and provide in the function callback a method to register
with the backend a new (*set_caching).

Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
---
 drivers/gpu/drm/ttm/ttm_page_alloc.c |   46 ++++++++++++++++++++++++++++++++++
 drivers/gpu/drm/ttm/ttm_tt.c         |   46 +++++----------------------------
 include/drm/ttm/ttm_page_alloc.h     |   29 +++++++++++++++++++++
 3 files changed, 82 insertions(+), 39 deletions(-)

diff --git a/drivers/gpu/drm/ttm/ttm_page_alloc.c b/drivers/gpu/drm/ttm/ttm_page_alloc.c
index f9a4d83..002f64f 100644
--- a/drivers/gpu/drm/ttm/ttm_page_alloc.c
+++ b/drivers/gpu/drm/ttm/ttm_page_alloc.c
@@ -455,6 +455,36 @@ static int ttm_set_pages_caching(struct page **pages,
 	return r;
 }
 
+#ifdef CONFIG_X86
+static int __ttm_page_set_page_caching(struct page *p,
+				       int flags,
+				       enum ttm_caching_state c_old,
+				       enum ttm_caching_state c_new,
+				       struct device *dev)
+{
+	int ret = 0;
+
+	if (PageHighMem(p))
+		return 0;
+
+	if (c_old != tt_cached) {
+		/* p isn't in the default caching state, set it to
+		 * writeback first to free its current memtype. */
+
+		ret = set_pages_wb(p, 1);
+		if (ret)
+			return ret;
+	}
+
+	if (c_new == tt_wc)
+		ret = set_memory_wc((unsigned long) page_address(p), 1);
+	else if (c_new == tt_uncached)
+		ret = set_pages_uc(p, 1);
+
+	return ret;
+}
+#endif
+
 /**
  * Free pages the pages that failed to change the caching state. If there is
  * any pages that have changed their caching state already put them to the
@@ -865,6 +895,9 @@ struct ttm_page_alloc_func ttm_page_alloc_default = {
 	.alloc_init	= __ttm_page_alloc_init,
 	.alloc_fini	= __ttm_page_alloc_fini,
 	.debugfs	= __ttm_page_alloc_debugfs,
+#ifdef CONFIG_X86
+	.set_caching	= __ttm_page_set_page_caching,
+#endif
 };
 
 int ttm_get_pages(struct list_head *pages, int flags,
@@ -902,3 +935,16 @@ int ttm_page_alloc_debugfs(struct seq_file *m, void *data)
 	return -1;
 }
 EXPORT_SYMBOL(ttm_page_alloc_debugfs);
+
+#ifdef CONFIG_X86
+int ttm_tt_set_page_caching(struct page *p,
+			    int flags,
+			    enum ttm_caching_state c_old,
+			    enum ttm_caching_state c_new,
+			    struct device *dev)
+{
+	if (ttm_page_alloc && ttm_page_alloc->set_caching)
+		return ttm_page_alloc->set_caching(p, flags, c_old, c_new, dev);
+	return -1;
+}
+#endif
diff --git a/drivers/gpu/drm/ttm/ttm_tt.c b/drivers/gpu/drm/ttm/ttm_tt.c
index 1f11a33..0f5ce97 100644
--- a/drivers/gpu/drm/ttm/ttm_tt.c
+++ b/drivers/gpu/drm/ttm/ttm_tt.c
@@ -176,41 +176,6 @@ int ttm_tt_populate(struct ttm_tt *ttm)
 }
 EXPORT_SYMBOL(ttm_tt_populate);
 
-#ifdef CONFIG_X86
-static inline int ttm_tt_set_page_caching(struct page *p,
-					  enum ttm_caching_state c_old,
-					  enum ttm_caching_state c_new)
-{
-	int ret = 0;
-
-	if (PageHighMem(p))
-		return 0;
-
-	if (c_old != tt_cached) {
-		/* p isn't in the default caching state, set it to
-		 * writeback first to free its current memtype. */
-
-		ret = set_pages_wb(p, 1);
-		if (ret)
-			return ret;
-	}
-
-	if (c_new == tt_wc)
-		ret = set_memory_wc((unsigned long) page_address(p), 1);
-	else if (c_new == tt_uncached)
-		ret = set_pages_uc(p, 1);
-
-	return ret;
-}
-#else /* CONFIG_X86 */
-static inline int ttm_tt_set_page_caching(struct page *p,
-					  enum ttm_caching_state c_old,
-					  enum ttm_caching_state c_new)
-{
-	return 0;
-}
-#endif /* CONFIG_X86 */
-
 /*
  * Change caching policy for the linear kernel map
  * for range of pages in a ttm.
@@ -238,9 +203,9 @@ static int ttm_tt_set_caching(struct ttm_tt *ttm,
 	for (i = 0; i < ttm->num_pages; ++i) {
 		cur_page = ttm->pages[i];
 		if (likely(cur_page != NULL)) {
-			ret = ttm_tt_set_page_caching(cur_page,
+			ret = ttm_tt_set_page_caching(cur_page, ttm->page_flags,
 						      ttm->caching_state,
-						      c_state);
+						      c_state, ttm->dev);
 			if (unlikely(ret != 0))
 				goto out_err;
 		}
@@ -254,8 +219,11 @@ out_err:
 	for (j = 0; j < i; ++j) {
 		cur_page = ttm->pages[j];
 		if (likely(cur_page != NULL)) {
-			(void)ttm_tt_set_page_caching(cur_page, c_state,
-						      ttm->caching_state);
+			(void)ttm_tt_set_page_caching(cur_page,
+						      ttm->page_flags,
+						      c_state,
+						      ttm->caching_state,
+						      ttm->dev);
 		}
 	}
 
diff --git a/include/drm/ttm/ttm_page_alloc.h b/include/drm/ttm/ttm_page_alloc.h
index 1dde3bd..73ad03c 100644
--- a/include/drm/ttm/ttm_page_alloc.h
+++ b/include/drm/ttm/ttm_page_alloc.h
@@ -93,6 +93,18 @@ struct ttm_page_alloc_func {
 	 * Output the state of pools to debugfs file
 	 */
 	int (*debugfs)(struct seq_file *m, void *data);
+
+	/**
+	 *
+	 * struct ttm_page_alloc_func member set_caching
+	 *
+	 * Set the caching on the page retrieved from get_pages.
+	 */
+	int (*set_caching)(struct page *p,
+			   int flags,
+			   enum ttm_caching_state c_old,
+			   enum ttm_caching_state c_new,
+			   struct device *dev);
 };
 
 extern struct ttm_page_alloc_func *ttm_page_alloc;
@@ -163,4 +175,21 @@ void ttm_page_alloc_fini(void);
  * Output the state of pools to debugfs file
  */
 extern int ttm_page_alloc_debugfs(struct seq_file *m, void *data);
+
+#ifdef CONFIG_X86
+int ttm_tt_set_page_caching(struct page *p,
+			    int flags,
+			    enum ttm_caching_state c_old,
+			    enum ttm_caching_state c_new,
+			    struct device *dev);
+#else
+static inline int ttm_tt_set_page_caching(struct page *p,
+					  int flags,
+					  enum ttm_caching_state c_old,
+					  enum ttm_caching_state c_new,
+					  struct device *dev)
+{
+	return 0;
+}
+#endif
 #endif
-- 
1.7.4.1


  parent reply	other threads:[~2011-09-29 20:34 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-09-29 20:33 [PATCH] TTM DMA pool v1.8 Konrad Rzeszutek Wilk
2011-09-29 20:33 ` [PATCH 1/9] ttm/radeon/nouveau: Check the DMA address from TTM against known value Konrad Rzeszutek Wilk
2011-09-29 20:33 ` [PATCH 2/9] ttm: Introduce ttm_page_alloc_func structure Konrad Rzeszutek Wilk
2011-09-29 20:33 ` [PATCH 3/9] ttm: Pass in 'struct device' to TTM so it can do DMA API on behalf of device Konrad Rzeszutek Wilk
2011-09-29 20:33 ` [PATCH 4/9] swiotlb: Expose swiotlb_nr_tlb function to modules Konrad Rzeszutek Wilk
2011-09-29 23:49   ` FUJITA Tomonori
2011-09-29 20:33 ` [PATCH 5/9] ttm: Provide a DMA aware TTM page pool code Konrad Rzeszutek Wilk
2011-09-29 20:33 ` [PATCH 6/9] ttm: Add 'no_dma' parameter to turn the TTM DMA pool off during runtime Konrad Rzeszutek Wilk
2011-09-29 20:33 ` [PATCH 7/9] nouveau/radeon: Set coherent DMA mask Konrad Rzeszutek Wilk
2011-09-29 20:33 ` Konrad Rzeszutek Wilk [this message]
2011-09-29 20:33 ` [PATCH 9/9] ttm/dma: Implement set_page_caching implementation in the TTM DMA pool code Konrad Rzeszutek Wilk
2011-09-30  6:59 ` [PATCH] TTM DMA pool v1.8 Thomas Hellstrom
2011-09-30 14:09   ` Konrad Rzeszutek Wilk
2011-10-03 16:35     ` Thomas Hellstrom
2011-10-03 16:46       ` Konrad Rzeszutek Wilk
2011-10-03 16:56         ` Thomas Hellstrom

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=1317328432-25620-9-git-send-email-konrad.wilk@oracle.com \
    --to=konrad.wilk@oracle.com \
    --cc=airlied@linux.ie \
    --cc=airlied@redhat.com \
    --cc=alexdeucher@gmail.com \
    --cc=bskeggs@redhat.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=j.glisse@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=thellstrom@vmware.com \
    --cc=thomas@shipmail.org \
    --cc=xen-devel@lists.xensource.com \
    /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

all inboxes | Powered by JetHome®