Received: from milmhbs1.lsil.com (147.145.21.209) by coscas01.lsi.com
 (172.21.36.60) with Microsoft SMTP Server id 8.1.393.1; Wed, 25 Nov 2009
 13:01:33 -0700
Received: from mail1.lsil.com (mail1.lsil.com [147.145.40.21])	by
 milmhbs1.lsil.com (8.12.11/8.12.11) with ESMTP id nAPK1UVg003070	for
 <andy.sharp@lsi.com>; Wed, 25 Nov 2009 12:01:33 -0800
Received: from psmtp.com (na3sys009amx218.postini.com [74.125.149.58])	by
 mail1.lsil.com (8.12.11/8.12.11) with SMTP id nAPK1EF4027071	for
 <andy.sharp@lsi.com>; Wed, 25 Nov 2009 12:01:28 -0800 (PST)
Received: from source ([78.24.191.182]) by na3sys009amx218.postini.com
 ([74.125.148.14]) with SMTP;	Wed, 25 Nov 2009 12:01:29 PST
Received: from localhost.localdomain ([127.0.0.1]:47020 "EHLO
        eddie.linux-mips.org" rhost-flags-OK-OK-OK-FAIL)        by
 eddie.linux-mips.org with ESMTP id S1493434AbZKYUAx (ORCPT
        <rfc822;andy.sharp@lsi.com>); Wed, 25 Nov 2009 21:00:53 +0100
Received: with ECARTIS (v1.0.0; list linux-mips); Wed, 25 Nov 2009 21:00:35
 +0100 (CET)
Received: from sj-iport-5.cisco.com ([171.68.10.87]:11617 "EHLO
        sj-iport-5.cisco.com" rhost-flags-OK-OK-OK-OK) by eddie.linux-mips.org
        with ESMTP id S1493427AbZKYUAb (ORCPT
        <rfc822;linux-mips@linux-mips.org>); Wed, 25 Nov 2009 21:00:31 +0100
Received: from sj-core-3.cisco.com ([171.68.223.137])  by sj-iport-5.cisco.com
 with ESMTP; 25 Nov 2009 20:00:23 +0000
Received: from dvomlehn-lnx2.corp.sa.net ([64.101.20.155])        by
 sj-core-3.cisco.com (8.13.8/8.14.3) with ESMTP id nAPK0OKc010488;        Wed,
 25 Nov 2009 20:00:24 GMT
From: David VomLehn <dvomlehn@cisco.com>
To: "linux-mips@linux-mips.org" <linux-mips@linux-mips.org>
CC: "ralf@linux-mips.org" <ralf@linux-mips.org>
Sender: "linux-mips-bounce@linux-mips.org" <linux-mips-bounce@linux-mips.org>
Date: Wed, 25 Nov 2009 13:00:24 -0700
Subject: [PATCH 1/2] Set of fixes for DMA when dma_addr_t != physical
        address
Thread-Topic: [PATCH 1/2] Set of fixes for DMA when dma_addr_t != physical
        address
Thread-Index: AcpuChZEMsZNAUPGSTa7r6QqF2m1aw==
Message-ID: <20091125200024.GA13307@dvomlehn-lnx2.corp.sa.net>
Accept-Language: en-US
Content-Language: en-US
X-MS-Exchange-Organization-AuthAs: Anonymous
X-MS-Exchange-Organization-AuthSource: coscas01.lsi.com
X-MS-Has-Attach:
X-Auto-Response-Suppress: All
X-MS-TNEF-Correlator:
x-scanned-by: MIMEDefang 2.39
errors-to: linux-mips-bounce@linux-mips.org
x-pstn-levels: (S:96.46748/99.90000 CV:99.9000 FC:95.5390 LC:95.5390
 R:95.9108 P:95.9108 M:97.0282 C:98.6951 )
x-pstn-settings: 3 (1.0000:1.0000) s cv gt3 gt2 gt1 r p m c 
x-pstn-addresses: from <dvomlehn@cisco.com> [22/1] 
x-pstn-neptune: 2/1/0.50/71
user-agent: Mutt/1.5.18 (2008-05-17)
authentication-results: sj-iport-5.cisco.com; dkim=neutral (message not
 signed) header.i=none
x-ironport-anti-spam-filtered: true
x-ironport-anti-spam-result: ApoEAAccDUurRN+J/2dsb2JhbAC+GZdrhDIEgXE
x-ironport-av: E=Sophos;i="4.47,288,1257120000";
    d="scan'208";a="109641173"
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: quoted-printable
MIME-Version: 1.0

From: Jon Fraser <jfraser@broadcom.com>
DMA changes from Jon Fraser, slightly tweaked for 2.6.30.

Signed-off-by: Jon Fraser <jfraser@broadcom.com>
Signed-off-by: David VomLehn <dvomlehn@cisco.com>
---
 arch/mips/mm/dma-default.c |   14 ++++++++++----
 1 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/arch/mips/mm/dma-default.c b/arch/mips/mm/dma-default.c
index 4fdb7f5..70cff1f 100644
--- a/arch/mips/mm/dma-default.c
+++ b/arch/mips/mm/dma-default.c
@@ -135,6 +135,9 @@ EXPORT_SYMBOL(dma_free_coherent);
 static inline void __dma_sync(unsigned long addr, size_t size,
 	enum dma_data_direction direction)
 {
+
+	BUG_ON(addr < KSEG0);
+
 	switch (direction) {
 	case DMA_TO_DEVICE:
 		dma_cache_wback(addr, size);
@@ -188,11 +191,13 @@ int dma_map_sg(struct device *dev, struct scatterlist=
 *sg, int nents,
 	for (i =3D 0; i < nents; i++, sg++) {
 		unsigned long addr;
=20
+		BUG_ON(!sg_page(sg));
+
 		addr =3D (unsigned long) sg_virt(sg);
-		if (!plat_device_is_coherent(dev) && addr)
+		if (!plat_device_is_coherent(dev) && (addr >=3D KSEG0))
 			__dma_sync(addr, sg->length, direction);
-		sg->dma_address =3D plat_map_dma_mem(dev,
-				                   (void *)addr, sg->length);
+
+		sg->dma_address =3D sg_phys(sg);
 	}
=20
 	return nents;
@@ -229,7 +234,7 @@ void dma_unmap_sg(struct device *dev, struct scatterlis=
t *sg, int nhwentries,
 		if (!plat_device_is_coherent(dev) &&
 		    direction !=3D DMA_TO_DEVICE) {
 			addr =3D (unsigned long) sg_virt(sg);
-			if (addr)
+			if (addr >=3D KSEG0)
 				__dma_sync(addr, sg->length, direction);
 		}
 		plat_unmap_dma_mem(dev, sg->dma_address);
@@ -359,6 +364,7 @@ void dma_cache_sync(struct device *dev, void *vaddr, si=
ze_t size,
 	       enum dma_data_direction direction)
 {
 	BUG_ON(direction =3D=3D DMA_NONE);
+	BUG_ON(vaddr < (void *)KSEG0);
=20
 	plat_extra_sync_for_device(dev);
 	if (!plat_device_is_coherent(dev))

