Skip to contentSkip to conversation

sound: fix emu8000 DRAM sized 512 KiB too small

PATCH Superseded David Flater 2 participants 4 messages Aug 28, 2012 Sound

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 sound: fix emu8000 DRAM sized 512 KiB too small

[PATCH] sound: fix emu8000 DRAM sized 512 KiB too small

Applicable to 3.5.3 mainline.

In emu8000.c, size_dram determines the amount of memory on the sound card by doing write/readback tests starting at 512 KiB and incrementing by 512 KiB. On success, detected_size is updated to the successful address and testing continues. On failure, the loop is immediately exited. The resulting detected_size is 512 KiB too small except in two special cases:

1. If there is no memory, the initial 0 value of detected_size is used, which is correct.
2. If the address space wraps around, detected_size is updated before the bailout, so the result is correct.

The patch corrects all cases and was tested with an AWE64 Gold. Before:
EMU8000 [0x620]: 3584 Kb on-board memory detected
asfxload 4GMGSMT.SF2 (4174814 B) fails.
After:
EMU8000 [0x620]: 4096 Kb on-board memory detected
asfxload 4GMGSMT.SF2 succeeds.

C.f. Bug 46451 https://bugzilla.kernel.org/show_bug.cgi?id=46451

---

Note: I am having newbie problems with git, so I am unable to determine easily whether this was a regression or a primordial bug. git clone http://pub/scm/linux/kernel/git/torvalds/linux.git gitkernel Cloning into gitkernel...
warning: remote HEAD refers to nonexistent ref, unable to checkout.

sound/isa/sb/emu8000.c renamed from sound/isa/sb/emu8000.c~ +3 -3
@@ -417,9 +417,6 @@ size_dram(struct snd_emu8000 *emu)
 		EMU8000_SMLD_READ(emu); /* discard stale data  */
 		if (EMU8000_SMLD_READ(emu) != UNIQUE_ID2)
 			break; /* no memory at this address */
-
-		detected_size = size;
-
 		snd_emu8000_read_wait(emu);
 
 		/*
@@ -432,6 +429,9 @@ size_dram(struct snd_emu8000 *emu)
 		if (EMU8000_SMLD_READ(emu) != UNIQUE_ID1)
 			break; /* we must have wrapped around */
 		snd_emu8000_read_wait(emu);
+
+		/* Otherwise, it's valid memory. */
+		detected_size = size + 512 * 1024;
 	}
 
 	/* wait until FULL bit in SMAxW register is false */
#1 lore raw

PATCH v2 1/1 sound: fix emu8000 DRAM sized 512 KiB too small

v2: Fixed result still wrong in the case of 512 KiB DRAM. Oops.

Applicable to 3.5.3 mainline.

In emu8000.c, size_dram determines the amount of memory on the sound card by doing write/readback tests starting at 512 KiB and incrementing by 512 KiB. On success, detected_size is updated to the successful address and testing continues. On failure, the loop is immediately exited. The resulting detected_size is 512 KiB too small except in two special cases:

1. If there is no memory, the initial 0 value of detected_size is used, which is correct.
2. If the address space wraps around, detected_size is updated before the bailout, so the result is correct.

The patch corrects all cases and was tested with an AWE64 Gold. Before:
EMU8000 [0x620]: 3584 Kb on-board memory detected
asfxload 4GMGSMT.SF2 (4174814 B) fails.
After:
EMU8000 [0x620]: 4096 Kb on-board memory detected
asfxload 4GMGSMT.SF2 succeeds.

I do not have a card with 512 KiB to test with, but by forcibly enabling the added conditional I verified on the AWE64 Gold that it detects 512 KiB (successfully reading from the first memory location) and does not hang the card.

C.f. Bug 46451 https://bugzilla.kernel.org/show_bug.cgi?id=46451

---

sound/isa/sb/emu8000.c renamed from sound/isa/sb/emu8000.c.orig +12 -3
@@ -417,9 +417,6 @@ size_dram(struct snd_emu8000 *emu)
 		EMU8000_SMLD_READ(emu); /* discard stale data  */
 		if (EMU8000_SMLD_READ(emu) != UNIQUE_ID2)
 			break; /* no memory at this address */
-
-		detected_size = size;
-
 		snd_emu8000_read_wait(emu);
 
 		/*
@@ -432,6 +429,18 @@ size_dram(struct snd_emu8000 *emu)
 		if (EMU8000_SMLD_READ(emu) != UNIQUE_ID1)
 			break; /* we must have wrapped around */
 		snd_emu8000_read_wait(emu);
+
+		/* Otherwise, it's valid memory. */
+		detected_size = size + 512 * 1024;
+	}
+
+	/* Distinguish 512 KiB from 0. */
+	if (detected_size == 0) {
+		snd_emu8000_read_wait(emu);
+		EMU8000_SMALR_WRITE(emu, EMU8000_DRAM_OFFSET);
+		EMU8000_SMLD_READ(emu); /* discard stale data  */
+		if (EMU8000_SMLD_READ(emu) == UNIQUE_ID1)
+			detected_size = 512 * 1024;
 	}
 
 	/* wait until FULL bit in SMAxW register is false */
Applied
#2 lore raw

At Mon, 27 Aug 2012 22:25:21 -0400,

Quoted 23 lines · David Flater

v2: Fixed result still wrong in the case of 512 KiB DRAM. Oops.

Applicable to 3.5.3 mainline.

In emu8000.c, size_dram determines the amount of memory on the sound card by doing write/readback tests starting at 512 KiB and incrementing by 512 KiB. On success, detected_size is updated to the successful address and testing continues. On failure, the loop is immediately exited. The resulting detected_size is 512 KiB too small except in two special cases:

1. If there is no memory, the initial 0 value of detected_size is used, which is correct.
2. If the address space wraps around, detected_size is updated before the bailout, so the result is correct.

The patch corrects all cases and was tested with an AWE64 Gold. Before:
EMU8000 [0x620]: 3584 Kb on-board memory detected
asfxload 4GMGSMT.SF2 (4174814 B) fails.
After:
EMU8000 [0x620]: 4096 Kb on-board memory detected
asfxload 4GMGSMT.SF2 succeeds.

Quoted 8 lines

I do not have a card with 512 KiB to test with, but by forcibly enabling the added conditional I verified on the AWE64 Gold that it detects 512 KiB (successfully reading from the first memory location) and does not hang the card.

C.f. Bug 46451 https://bugzilla.kernel.org/show_bug.cgi?id=46451

Thanks, applied.

Takashi

Quoted 40 lines

---

sound/isa/sb/emu8000.c renamed from sound/isa/sb/emu8000.c.orig +12 -4
@@ -417,9 +417,6 @@ size_dram(struct snd_emu8000 *emu)
 		EMU8000_SMLD_READ(emu); /* discard stale data  */
 		if (EMU8000_SMLD_READ(emu) != UNIQUE_ID2)
 			break; /* no memory at this address */
-
-		detected_size = size;
-
 		snd_emu8000_read_wait(emu);
 
 		/*
@@ -432,6 +429,18 @@ size_dram(struct snd_emu8000 *emu)
 		if (EMU8000_SMLD_READ(emu) != UNIQUE_ID1)
 			break; /* we must have wrapped around */
 		snd_emu8000_read_wait(emu);
+
+		/* Otherwise, it's valid memory. */
+		detected_size = size + 512 * 1024;
+	}
+
+	/* Distinguish 512 KiB from 0. */
+	if (detected_size == 0) {
+		snd_emu8000_read_wait(emu);
+		EMU8000_SMALR_WRITE(emu, EMU8000_DRAM_OFFSET);
+		EMU8000_SMLD_READ(emu); /* discard stale data  */
+		if (EMU8000_SMLD_READ(emu) == UNIQUE_ID1)
+			detected_size = 512 * 1024;
 	}
 
 	/* wait until FULL bit in SMAxW register is false */
 
--

To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

Applied
#3 lore raw
In reply to David Flater

At Mon, 27 Aug 2012 22:25:21 -0400,

Quoted 23 lines · David Flater

v2: Fixed result still wrong in the case of 512 KiB DRAM. Oops.

Applicable to 3.5.3 mainline.

In emu8000.c, size_dram determines the amount of memory on the sound card by doing write/readback tests starting at 512 KiB and incrementing by 512 KiB. On success, detected_size is updated to the successful address and testing continues. On failure, the loop is immediately exited. The resulting detected_size is 512 KiB too small except in two special cases:

1. If there is no memory, the initial 0 value of detected_size is used, which is correct.
2. If the address space wraps around, detected_size is updated before the bailout, so the result is correct.

The patch corrects all cases and was tested with an AWE64 Gold. Before:
EMU8000 [0x620]: 3584 Kb on-board memory detected
asfxload 4GMGSMT.SF2 (4174814 B) fails.
After:
EMU8000 [0x620]: 4096 Kb on-board memory detected
asfxload 4GMGSMT.SF2 succeeds.

Quoted 8 lines

I do not have a card with 512 KiB to test with, but by forcibly enabling the added conditional I verified on the AWE64 Gold that it detects 512 KiB (successfully reading from the first memory location) and does not hang the card.

C.f. Bug 46451 https://bugzilla.kernel.org/show_bug.cgi?id=46451

Thanks, applied.

Takashi

Quoted 40 lines

---

sound/isa/sb/emu8000.c renamed from sound/isa/sb/emu8000.c.orig +12 -4
@@ -417,9 +417,6 @@ size_dram(struct snd_emu8000 *emu)
 		EMU8000_SMLD_READ(emu); /* discard stale data  */
 		if (EMU8000_SMLD_READ(emu) != UNIQUE_ID2)
 			break; /* no memory at this address */
-
-		detected_size = size;
-
 		snd_emu8000_read_wait(emu);
 
 		/*
@@ -432,6 +429,18 @@ size_dram(struct snd_emu8000 *emu)
 		if (EMU8000_SMLD_READ(emu) != UNIQUE_ID1)
 			break; /* we must have wrapped around */
 		snd_emu8000_read_wait(emu);
+
+		/* Otherwise, it's valid memory. */
+		detected_size = size + 512 * 1024;
+	}
+
+	/* Distinguish 512 KiB from 0. */
+	if (detected_size == 0) {
+		snd_emu8000_read_wait(emu);
+		EMU8000_SMALR_WRITE(emu, EMU8000_DRAM_OFFSET);
+		EMU8000_SMLD_READ(emu); /* discard stale data  */
+		if (EMU8000_SMLD_READ(emu) == UNIQUE_ID1)
+			detected_size = 512 * 1024;
 	}
 
 	/* wait until FULL bit in SMAxW register is false */
 
--

To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/