All of lore.kernel.org
 help / color / mirror / Atom feed
* Re: [alsa-cvslog] CVS: alsa-kernel/pci/emu10k1 emufx.c,1.59,1.60
       [not found] <E1CNAGJ-000270-L7@sc8-pr-cvs1.sourceforge.net>
@ 2004-11-07 18:11 ` James Courtier-Dutton
  2004-11-08  6:39   ` Jaroslav Kysela
  0 siblings, 1 reply; 3+ messages in thread
From: James Courtier-Dutton @ 2004-11-07 18:11 UTC (permalink / raw)
  To: Jaroslav Kysela; +Cc: Alsa-devel

Jaroslav Kysela wrote:
> 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.
> 
> 
>  
> -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)
 > +	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

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [alsa-cvslog] CVS: alsa-kernel/pci/emu10k1 emufx.c,1.59,1.60
  2004-11-07 18:11 ` [alsa-cvslog] CVS: alsa-kernel/pci/emu10k1 emufx.c,1.59,1.60 James Courtier-Dutton
@ 2004-11-08  6:39   ` Jaroslav Kysela
  2004-11-09  0:12     ` James Courtier-Dutton
  0 siblings, 1 reply; 3+ messages in thread
From: Jaroslav Kysela @ 2004-11-08  6:39 UTC (permalink / raw)
  To: James Courtier-Dutton; +Cc: Jaroslav Kysela, Alsa-devel

On Sun, 7 Nov 2004, James Courtier-Dutton wrote:

> 2)
>  > +	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
diff -u -r1.61 emufx.c
--- emufx.c	30 Oct 2004 07:44:20 -0000	1.61
+++ emufx.c	8 Nov 2004 06:41:21 -0000
@@ -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 <perex@suse.cz>
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

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [alsa-cvslog] CVS: alsa-kernel/pci/emu10k1 emufx.c,1.59,1.60
  2004-11-08  6:39   ` Jaroslav Kysela
@ 2004-11-09  0:12     ` James Courtier-Dutton
  0 siblings, 0 replies; 3+ messages in thread
From: James Courtier-Dutton @ 2004-11-09  0:12 UTC (permalink / raw)
  To: Jaroslav Kysela; +Cc: Jaroslav Kysela, Alsa-devel

Jaroslav Kysela wrote:
> On Sun, 7 Nov 2004, James Courtier-Dutton wrote:
> 
> 
>>2)
>> > +	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

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2004-11-09  0:12 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <E1CNAGJ-000270-L7@sc8-pr-cvs1.sourceforge.net>
2004-11-07 18:11 ` [alsa-cvslog] CVS: alsa-kernel/pci/emu10k1 emufx.c,1.59,1.60 James Courtier-Dutton
2004-11-08  6:39   ` Jaroslav Kysela
2004-11-09  0:12     ` James Courtier-Dutton

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.