>From 714323e8eb464d3ef613b695dbcdc5f24f88c60b Mon Sep 17 00:00:00 2001
From: Ken Mills <[email protected]>
Date: Mon, 18 Oct 2010 18:33:01 -0700
Subject: [PATCH 3/4] Modified function pti_write_to_aperture() to be endian 
independent.
 Put lock around mipi_release_masterchannel().

Signed-off-by: Ken Mills <[email protected]>
---
 drivers/misc/pti.c |   48 ++++++++++++++++++------------------------------
 1 files changed, 18 insertions(+), 30 deletions(-)

diff --git a/drivers/misc/pti.c b/drivers/misc/pti.c
index 4be6b0c..8c0dff4 100644
--- a/drivers/misc/pti.c
+++ b/drivers/misc/pti.c
@@ -98,10 +98,8 @@ static unsigned int pti_console_channel;
 static void pti_write_to_aperture(struct masterchannel *mc, u8 *buf, int len)
 {
        int dwordcnt, final, i;
-       union {
-               u32 val;
-               u8 c[4];
-       } ptiword;
+
+       u32 ptiword;
        u8 *p;
        u32 __iomem *aperture;
 
@@ -121,44 +119,29 @@ static void pti_write_to_aperture(struct masterchannel 
*mc, u8 *buf, int len)
                dwordcnt--;
        }
 
-       /*
-          FIXME: This algorithm builds the dword from the input buffer.
-          This algorithm does work correctly with the PTI HW
-          and Fido debugging HW.  However, this got flagged in upstream
-          review not conforming to proper endian practices.
-          u32 ptiword = cpu_to_le32(*(u32 *)p);
-          was tried but was incorrect endianess.  Then the Fido
-          HW used to test this code broke.  The goal is to submit
-          something known to work and then fix this when it can be tested.
-       */
        for (i = 0; i < dwordcnt; i++) {
-               ptiword.c[3] = *p++;
-               ptiword.c[2] = *p++;
-               ptiword.c[1] = *p++;
-               ptiword.c[0] = *p++;
+               ptiword = be32_to_cpu(*(u32 *)p);
+               p += 4;
                pr_debug("%s(%d): PTI aperture: master(%d), channel(%d)\n",
                        __func__, __LINE__, mc->master, mc->channel);
                pr_debug("%s(%d): PTI double word: %#x\n\n",
-                       __func__, __LINE__, ptiword.val);
-               iowrite32(ptiword.val, aperture);
+                       __func__, __LINE__, ptiword);
+               iowrite32(ptiword, aperture);
        }
 
+       /* build final PTI word with trailing message bytes */
+
        aperture += DTS;                /* adding DTS signals that is EOM */
-       ptiword.val = 0;
-       /*
-          FIXME: This has the same issue as stated in other FIXME.
-          u32 ptiword |= *p++ << (8 * i); was tried and had the
-          same character-swapping endianess problem.
-        */
+       ptiword = 0;
+
        for (i = 0; i < final; i++)
-               ptiword.c[3-i] = *p++;
+               ptiword |= *p++ << (24-(8*i));
 
        pr_debug("%s(%d): PTI aperture: master(%d), channel(%d)\n",
                __func__, __LINE__, mc->master, mc->channel);
        pr_debug("%s(%d): Final PTI double word: %#x\n\n",
-               __func__, __LINE__, ptiword.val);
-       iowrite32(ptiword.val, aperture);
-
+               __func__, __LINE__, ptiword);
+       iowrite32(ptiword, aperture);
        return;
 }
 
@@ -260,6 +243,9 @@ EXPORT_SYMBOL(mipi_request_masterchannel);
 void mipi_release_masterchannel(struct masterchannel *mc)
 {
        u8 master, channel, i;
+
+       mutex_lock(&alloclock);
+
        if (mc) {
                master = mc->master;
                channel = mc->channel;
@@ -275,6 +261,8 @@ void mipi_release_masterchannel(struct masterchannel *mc)
 
                kfree(mc);
        }
+
+       mutex_unlock(&alloclock);
 }
 EXPORT_SYMBOL(mipi_release_masterchannel);
 
-- 
1.7.0.4
From 714323e8eb464d3ef613b695dbcdc5f24f88c60b Mon Sep 17 00:00:00 2001
From: Ken Mills <[email protected]>
Date: Mon, 18 Oct 2010 18:33:01 -0700
Subject: [PATCH 3/4] Modified function pti_write_to_aperture() to be endian independent.
 Put lock around mipi_release_masterchannel().

Signed-off-by: Ken Mills <[email protected]>
---
 drivers/misc/pti.c |   48 ++++++++++++++++++------------------------------
 1 files changed, 18 insertions(+), 30 deletions(-)

diff --git a/drivers/misc/pti.c b/drivers/misc/pti.c
index 4be6b0c..8c0dff4 100644
--- a/drivers/misc/pti.c
+++ b/drivers/misc/pti.c
@@ -98,10 +98,8 @@ static unsigned int pti_console_channel;
 static void pti_write_to_aperture(struct masterchannel *mc, u8 *buf, int len)
 {
 	int dwordcnt, final, i;
-	union {
-		u32 val;
-		u8 c[4];
-	} ptiword;
+
+	u32 ptiword;
 	u8 *p;
 	u32 __iomem *aperture;
 
@@ -121,44 +119,29 @@ static void pti_write_to_aperture(struct masterchannel *mc, u8 *buf, int len)
 		dwordcnt--;
 	}
 
-	/*
-	   FIXME: This algorithm builds the dword from the input buffer.
-	   This algorithm does work correctly with the PTI HW
-	   and Fido debugging HW.  However, this got flagged in upstream
-	   review not conforming to proper endian practices.
-	   u32 ptiword = cpu_to_le32(*(u32 *)p);
-	   was tried but was incorrect endianess.  Then the Fido
-	   HW used to test this code broke.  The goal is to submit
-	   something known to work and then fix this when it can be tested.
-	*/
 	for (i = 0; i < dwordcnt; i++) {
-		ptiword.c[3] = *p++;
-		ptiword.c[2] = *p++;
-		ptiword.c[1] = *p++;
-		ptiword.c[0] = *p++;
+		ptiword = be32_to_cpu(*(u32 *)p);
+		p += 4;
 		pr_debug("%s(%d): PTI aperture: master(%d), channel(%d)\n",
 			__func__, __LINE__, mc->master, mc->channel);
 		pr_debug("%s(%d): PTI double word: %#x\n\n",
-			__func__, __LINE__, ptiword.val);
-		iowrite32(ptiword.val, aperture);
+			__func__, __LINE__, ptiword);
+		iowrite32(ptiword, aperture);
 	}
 
+	/* build final PTI word with trailing message bytes */
+
 	aperture += DTS;		/* adding DTS signals that is EOM */
-	ptiword.val = 0;
-	/*
-	   FIXME: This has the same issue as stated in other FIXME.
-	   u32 ptiword |= *p++ << (8 * i); was tried and had the
-	   same character-swapping endianess problem.
-	 */
+	ptiword = 0;
+
 	for (i = 0; i < final; i++)
-		ptiword.c[3-i] = *p++;
+		ptiword |= *p++ << (24-(8*i));
 
 	pr_debug("%s(%d): PTI aperture: master(%d), channel(%d)\n",
 		__func__, __LINE__, mc->master, mc->channel);
 	pr_debug("%s(%d): Final PTI double word: %#x\n\n",
-		__func__, __LINE__, ptiword.val);
-	iowrite32(ptiword.val, aperture);
-
+		__func__, __LINE__, ptiword);
+	iowrite32(ptiword, aperture);
 	return;
 }
 
@@ -260,6 +243,9 @@ EXPORT_SYMBOL(mipi_request_masterchannel);
 void mipi_release_masterchannel(struct masterchannel *mc)
 {
 	u8 master, channel, i;
+
+	mutex_lock(&alloclock);
+
 	if (mc) {
 		master = mc->master;
 		channel = mc->channel;
@@ -275,6 +261,8 @@ void mipi_release_masterchannel(struct masterchannel *mc)
 
 		kfree(mc);
 	}
+
+	mutex_unlock(&alloclock);
 }
 EXPORT_SYMBOL(mipi_release_masterchannel);
 
-- 
1.7.0.4

_______________________________________________
Meego-kernel mailing list
[email protected]
http://lists.meego.com/listinfo/meego-kernel

Reply via email to