mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Geert Uytterhoeven <Geert.Uytterhoeven@sonycom.com>
To: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: cbe-oss-dev@ozlabs.org, linux-kernel@vger.kernel.org,
	linux-fbdev-devel@lists.sourceforge.net,
	Geert Uytterhoeven <Geert.Uytterhoeven@sonycom.com>,
	Jim Paris <jim@jtan.com>
Subject: [PATCH 10/15] ps3vram: GPU memory mapping cleanup
Date: Fri,  8 May 2009 16:01:19 +0200	[thread overview]
Message-ID: <1241791284-11490-11-git-send-email-Geert.Uytterhoeven@sonycom.com> (raw)
In-Reply-To: <1241791284-11490-10-git-send-email-Geert.Uytterhoeven@sonycom.com>

  - Make the IOMMU flags used for mapping main memory into the GPU's I/O space
    explicit, instead of relying on the default in the hypervisor,
  - Add missing calls to lv1_gpu_context_iomap(..., IOPTE_M) to unmap the
    memory during cleanup.

Signed-off-by: Geert Uytterhoeven <Geert.Uytterhoeven@sonycom.com>
Cc: Jim Paris <jim@jtan.com>
---
 drivers/block/ps3vram.c |   18 +++++++++++++-----
 1 files changed, 13 insertions(+), 5 deletions(-)

diff --git a/drivers/block/ps3vram.c b/drivers/block/ps3vram.c
index 1396038..c58ac15 100644
--- a/drivers/block/ps3vram.c
+++ b/drivers/block/ps3vram.c
@@ -14,6 +14,7 @@
 #include <linux/seq_file.h>
 
 #include <asm/firmware.h>
+#include <asm/iommu.h>
 #include <asm/lv1call.h>
 #include <asm/ps3.h>
 
@@ -628,8 +629,8 @@ static int __devinit ps3vram_probe(struct ps3_system_bus_device *dev)
 	int error, status;
 	struct request_queue *queue;
 	struct gendisk *gendisk;
-	u64 ddr_lpar, ctrl_lpar, info_lpar, reports_lpar, ddr_size,
-	    reports_size;
+	u64 ddr_size, ddr_lpar, ctrl_lpar, info_lpar, reports_lpar,
+	    reports_size, xdr_lpar;
 	char *rest;
 
 	priv = kzalloc(sizeof(*priv), GFP_KERNEL);
@@ -700,9 +701,10 @@ static int __devinit ps3vram_probe(struct ps3_system_bus_device *dev)
 	}
 
 	/* Map XDR buffer to RSX */
+	xdr_lpar = ps3_mm_phys_to_lpar(__pa(priv->xdr_buf));
 	status = lv1_gpu_context_iomap(priv->context_handle, XDR_IOIF,
-				       ps3_mm_phys_to_lpar(__pa(priv->xdr_buf)),
-				       XDR_BUF_SIZE, 0);
+				       xdr_lpar, XDR_BUF_SIZE,
+				       IOPTE_PP_W | IOPTE_PP_R | IOPTE_M);
 	if (status) {
 		dev_err(&dev->core, "lv1_gpu_context_iomap failed %d\n",
 			status);
@@ -715,7 +717,7 @@ static int __devinit ps3vram_probe(struct ps3_system_bus_device *dev)
 	if (!priv->ddr_base) {
 		dev_err(&dev->core, "ioremap DDR failed\n");
 		error = -ENOMEM;
-		goto out_free_context;
+		goto out_unmap_context;
 	}
 
 	priv->ctrl = ioremap(ctrl_lpar, 64 * 1024);
@@ -801,6 +803,9 @@ out_unmap_ctrl:
 	iounmap(priv->ctrl);
 out_unmap_vram:
 	iounmap(priv->ddr_base);
+out_unmap_context:
+	lv1_gpu_context_iomap(priv->context_handle, XDR_IOIF, xdr_lpar,
+			      XDR_BUF_SIZE, IOPTE_M);
 out_free_context:
 	lv1_gpu_context_free(priv->context_handle);
 out_free_memory:
@@ -828,6 +833,9 @@ static int ps3vram_remove(struct ps3_system_bus_device *dev)
 	iounmap(priv->reports);
 	iounmap(priv->ctrl);
 	iounmap(priv->ddr_base);
+	lv1_gpu_context_iomap(priv->context_handle, XDR_IOIF,
+			      ps3_mm_phys_to_lpar(__pa(priv->xdr_buf)),
+			      XDR_BUF_SIZE, IOPTE_M);
 	lv1_gpu_context_free(priv->context_handle);
 	lv1_gpu_memory_free(priv->memory_handle);
 	ps3_close_hv_device(dev);
-- 
1.6.2.4


  reply	other threads:[~2009-05-08 14:05 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-05-08 14:01 [PATCH 0/15] ps3{fb,vram,disk} patches for 2.6.31 Geert Uytterhoeven
2009-05-08 14:01 ` [PATCH 01/15] ps3vram: Fix error path (return -EIO) for short read/write Geert Uytterhoeven
2009-05-08 14:01   ` [PATCH 02/15] ps3vram: Use proc_create_data() instead of proc_create() Geert Uytterhoeven
2009-05-08 14:01     ` [PATCH 03/15] ps3vram: Correct exchanged gotos in ps3vram_probe() error path Geert Uytterhoeven
2009-05-08 14:01       ` [PATCH 04/15] ps3vram: Replace mutex by spinlock + list Geert Uytterhoeven
2009-05-08 14:01         ` [PATCH 05/15] ps3fb: Remove useless debug checks in ps3fb_shutdown() Geert Uytterhoeven
2009-05-08 14:01           ` [PATCH 06/15] ps3fb: Inline functions in ps3fb_probe(), to ease cleanup in the error path Geert Uytterhoeven
2009-05-08 14:01             ` [PATCH 07/15] ps3fb: Correct handling of device opening in ps3fb_probe() Geert Uytterhoeven
2009-05-08 14:01               ` [PATCH 08/15] powerpc/cell: Extract duplicated IOPTE_* to <asm/iommu.h> Geert Uytterhoeven
2009-05-08 14:01                 ` [PATCH 09/15] ps3fb: GPU memory mapping cleanup Geert Uytterhoeven
2009-05-08 14:01                   ` Geert Uytterhoeven [this message]
2009-05-08 14:01                     ` [PATCH 11/15] ps3fb/vram: Extract common GPU stuff into <asm/ps3gpu.h> Geert Uytterhoeven
2009-05-08 14:01                       ` [PATCH 12/15] ps3fb: Tear down FB setup during cleanup Geert Uytterhoeven
2009-05-08 14:01                         ` [PATCH 13/15] ps3vram: Remove no longer used ps3vram_priv.ddr_base Geert Uytterhoeven
2009-05-08 14:01                           ` [PATCH 14/15] ps3vram: Make ps3vram_priv.reports a void * Geert Uytterhoeven
2009-05-08 14:01                             ` [PATCH 15/15] block/ps3: remove driver_data direct access of struct device Geert Uytterhoeven
2009-05-10 19:08                 ` [PATCH 08/15] powerpc/cell: Extract duplicated IOPTE_* to <asm/iommu.h> Christoph Hellwig
2009-05-11  7:24                   ` Geert Uytterhoeven
2009-05-08 23:05         ` [PATCH 04/15] ps3vram: Replace mutex by spinlock + list Andrew Morton
2009-05-11  6:38           ` Geert Uytterhoeven
2009-05-10 19:05         ` [Cbe-oss-dev] " Christoph Hellwig
2009-05-11 14:20           ` Geert Uytterhoeven

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=1241791284-11490-11-git-send-email-Geert.Uytterhoeven@sonycom.com \
    --to=geert.uytterhoeven@sonycom.com \
    --cc=benh@kernel.crashing.org \
    --cc=cbe-oss-dev@ozlabs.org \
    --cc=jim@jtan.com \
    --cc=linux-fbdev-devel@lists.sourceforge.net \
    --cc=linux-kernel@vger.kernel.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

all inboxes | Powered by JetHome®