Skip to contentSkip to conversation

CVS: alsa-kernel/pci/emu10k1 emufx.c,1.59,1.60

alsa-cvslog James Courtier-Dutton 2 participants 3 messages Nov 7, 2004 – Nov 9, 2004 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw

Review

Quoted 33 lines · Jaroslav Kysela

Update of /cvsroot/alsa/alsa-kernel/pci/emu10k1
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7704/pci/emu10k1

Modified Files:
emufx.c
Log Message:
Summary: fixed emu10k1_fx8010_code_t structure to be less than 8192 bytes

This patch fixes emu10k1_fx8010_code_t structure using indirect pointers to be less than 8192 bytes to follow the ioctl semantics.

(quoted diff) +9 -4
-static void snd_emu10k1_audigy_write_op(emu10k1_fx8010_code_t *icode, unsigned int *ptr,
-					u32 op, u32 r, u32 a, u32 x, u32 y)
+static int snd_emu10k1_audigy_write_op(emu10k1_fx8010_code_t *icode, unsigned int *ptr,
+				       u32 op, u32 r, u32 a, u32 x, u32 y)
 {
 	snd_assert(*ptr < 1024, return);
 	set_bit(*ptr, icode->code_valid);
-	icode->code[*ptr    ][0] = ((x & 0x7ff) << 12) | (y & 0x7ff);
-	icode->code[(*ptr)++][1] = ((op & 0x0f) << 24) | ((r & 0x7ff) << 12) | (a & 0x7ff);
+	x = ((x & 0x7ff) << 12) | (y & 0x7ff);
+	y = ((op & 0x0f) << 24) | ((r & 0x7ff) << 12) | (a & 0x7ff);
+	a = *ptr++ * 2;
+	if (put_user(x, &icode->code[a + 0]) ||
+	    put_user(y, &icode->code[a + 1]))
+		return -EFAULT;
+	return 0;
 }
 
 #define A_OP(icode, ptr, op, r, a, x, y) \
@@ -501,83 +511,108 @@

This code breaks Audigy 1/2 support.
1)
+ a = *ptr++ * 2;
should be
+ a = (*ptr)++ * 2;
We want the integer to increase, not the pointer to the integer.

That bug causes the snd-emu10k1 driver to hang during modprobe.

2)

Review line 513

Quoted 3 lines
(quoted diff) +3 -0
+	if (put_user(x, &icode->code[a + 0]) ||
+	    put_user(y, &icode->code[a + 1]))
+		return -EFAULT;

Will always return -EFAULT on my system. I don't think that is what we really want.

James

-------------------------------------------------------
This SF.Net email is sponsored by:
Sybase ASE Linux Express Edition - download now for FREE LinuxWorld Reader's Choice Award Winner for best database on Linux.
http://ads.osdn.com/?ad_id=5588&alloc_id=12065&op=click

#2 lore raw
Quoted 7 lines · James Courtier-Dutton

2)

Review

Quoted 3 lines
(quoted diff) +3 -0
+	if (put_user(x, &icode->code[a + 0]) ||
+	    put_user(y, &icode->code[a + 1]))
+		return -EFAULT;

Will always return -EFAULT on my system. I don't think that is what we really want.

Does this patch help?

Index: emufx.c
===================================================================
RCS file: /cvsroot/alsa/alsa-kernel/pci/emu10k1/emufx.c,v retrieving revision 1.61

emufx.c +8 -6
diff -u -r1.61 emufx.c
@@ -468,11 +468,11 @@
 static int snd_emu10k1_write_op(emu10k1_fx8010_code_t *icode, unsigned int *ptr,
 				u32 op, u32 r, u32 a, u32 x, u32 y)
 {
-	snd_assert(*ptr < 512, return);
+	snd_assert(*ptr < 512, return -EINVAL);
 	set_bit(*ptr, icode->code_valid);
 	x = ((x & 0x3ff) << 10) | (y & 0x3ff);
 	y = ((op & 0x0f) << 20) | ((r & 0x3ff) << 10) | (a & 0x3ff);
-	a = *ptr++ * 2;
+	a = (*ptr)++ * 2;
 	if (put_user(x, &icode->code[a + 0]) ||
             put_user(y, &icode->code[a + 1]))
 		return -EFAULT;
@@ -485,11 +485,11 @@
 static int snd_emu10k1_audigy_write_op(emu10k1_fx8010_code_t *icode, unsigned int *ptr,
 				       u32 op, u32 r, u32 a, u32 x, u32 y)
 {
-	snd_assert(*ptr < 1024, return);
+	snd_assert(*ptr < 1024, return -EINVAL);
 	set_bit(*ptr, icode->code_valid);
 	x = ((x & 0x7ff) << 12) | (y & 0x7ff);
 	y = ((op & 0x0f) << 24) | ((r & 0x7ff) << 12) | (a & 0x7ff);
-	a = *ptr++ * 2;
+	a = (*ptr)++ * 2;
 	if (put_user(x, &icode->code[a + 0]) ||
 	    put_user(y, &icode->code[a + 1]))
 		return -EFAULT;
@@ -1010,7 +1010,7 @@
 	INIT_LIST_HEAD(&emu->fx8010.gpr_ctl);
 
 	if ((icode = kcalloc(1, sizeof(*icode), GFP_KERNEL)) == NULL ||
-	    (icode->gpr_map = kcalloc(512 + 256 + 256, sizeof(u_int32_t), GFP_KERNEL)) == NULL ||
+	    (icode->gpr_map = kcalloc(512 + 256 + 256 + 2 * 1024, sizeof(u_int32_t), GFP_KERNEL)) == NULL ||
 	    (controls = kcalloc(SND_EMU10K1_GPR_CONTROLS, sizeof(*controls), GFP_KERNEL)) == NULL) {
 		err = -ENOMEM;
 		goto __err;
@@ -1018,6 +1018,7 @@
 
 	icode->tram_data_map = icode->gpr_map + 512;
 	icode->tram_addr_map = icode->tram_data_map + 256;
+	icode->code = icode->tram_addr_map + 256;
 
 	/* clear free GPRs */
 	for (i = 0; i < 512; i++)
@@ -1460,7 +1461,7 @@
 
 	if ((icode = kcalloc(1, sizeof(*icode), GFP_KERNEL)) == NULL)
 		return -ENOMEM;
-	if ((icode->gpr_map = kcalloc(256 + 160 + 160, sizeof(u_int32_t), GFP_KERNEL)) == NULL ||
+	if ((icode->gpr_map = kcalloc(256 + 160 + 160 + 2 * 512, sizeof(u_int32_t), GFP_KERNEL)) == NULL ||
             (controls = kcalloc(SND_EMU10K1_GPR_CONTROLS, sizeof(emu10k1_fx8010_control_gpr_t), GFP_KERNEL)) == NULL ||
 	    (ipcm = kcalloc(1, sizeof(*ipcm), GFP_KERNEL)) == NULL) {
 		err = -ENOMEM;
@@ -1469,6 +1470,7 @@
 
 	icode->tram_data_map = icode->gpr_map + 256;
 	icode->tram_addr_map = icode->tram_data_map + 160;
+	icode->code = icode->tram_addr_map + 160;
 	
 	/* clear free GPRs */
 	for (i = 0; i < 256; i++)

Jaroslav

-----
Jaroslav Kysela <[email protected]>
Linux Kernel Sound Maintainer
ALSA Project, SUSE Labs

-------------------------------------------------------
This SF.Net email is sponsored by:
Sybase ASE Linux Express Edition - download now for FREE LinuxWorld Reader's Choice Award Winner for best database on Linux.
http://ads.osdn.com/?ad_id=5588&alloc_id=12065&op=click

#3 lore raw
Quoted 4 lines · Jaroslav Kysela
Quoted 1 line · James Courtier-Dutton

2)

Quoted 9 lines
Quoted 5 lines

Review

Quoted 3 lines
(quoted diff) +3 -0
+	if (put_user(x, &icode->code[a + 0]) ||
+	    put_user(y, &icode->code[a + 1]))
+		return -EFAULT;

Will always return -EFAULT on my system. I don't think that is what we really want.

Does this patch help?

I have just tried the CVS, that includes your fixes. Still returns -EFAULT.
At least the kernel module loads, but, no DSP code is installed.

James

-------------------------------------------------------
This SF.Net email is sponsored by:
Sybase ASE Linux Express Edition - download now for FREE LinuxWorld Reader's Choice Award Winner for best database on Linux.
http://ads.osdn.com/?ad_id=5588&alloc_id=12065&op=click