[linux-dvb] Kernel locking in dst [Corrected PATCH]

Manu Abraham abraham.manu at gmail.com
Tue Oct 18 19:58:31 CEST 2005


Henrik Sjoberg wrote:

>There is still some up/down missing around dst_write_tuna (which was
>actually the root of my problem).
>The following additional patch is a remedy for my problem.
>  
>
Ah, forgot again, Similarly you would need one around dst_get_tuna() 
too. That would completely cover, all the 4 "pipes" that are fed to the MCU.

Regards,
Manu

>Regards,
>Henrik
>
>  
>
>>Ralph Metzler wrote:
>>
>>    
>>
>>>Manu Abraham writes:
>>>      
>>>
>>>>diff -Naurp bt8xx.orig/dst.c bt8xx/dst.c
>>>>--- bt8xx.orig/dst.c	2005-09-21 20:29:09.000000000 +0400
>>>>+++ bt8xx/dst.c	2005-10-18 19:38:27.000000000 +0400
>>>>@@ -910,6 +910,7 @@ static int dst_get_device_id(struct dst_
>>>>
>>>> static int dst_probe(struct dst_state *state)
>>>> {
>>>>+	sema_init(&state->dst_mutex, 1);
>>>> 	if ((rdc_8820_reset(state)) < 0) {
>>>> 		dprintk(verbose, DST_ERROR, 1, "RDC 8820 RESET Failed.");
>>>> 		return -1;
>>>>@@ -960,21 +961,23 @@ static int dst_probe(struct dst_state *s
>>>> int dst_command(struct dst_state *state, u8 *data, u8 len)
>>>> {
>>>> 	u8 reply;
>>>>+
>>>>+	up(&state->dst_mutex);
>>>> 	if ((dst_comm_init(state)) < 0) {
>>>> 		dprintk(verbose, DST_NOTICE, 1, "DST Communication Initialization
>>>>        
>>>>
>>>Failed.");
>>>
>>>
>>>This should be down()?
>>>
>>>
>>>
>>>      
>>>
>>Hello Ralph and all,
>>
>>I have attached the corrected patch. If it looks okay i can commit it to
>>CVS, such that Johannes can make the patchset at the earliest, when he
>>is back.
>>
>>
>>Regards,
>>Manu
>>
>>
>>
>>    
>>
>>------------------------------------------------------------------------
>>
>>Index: linux/drivers/media/dvb/bt8xx/dst.c
>>===================================================================
>>RCS file: /cvs/linuxtv/dvb-kernel/linux/drivers/media/dvb/bt8xx/dst.c,v
>>retrieving revision 1.41
>>diff -u -b -r1.41 dst.c
>>--- linux/drivers/media/dvb/bt8xx/dst.c	21 Sep 2005 16:29:09 -0000	1.41
>>+++ linux/drivers/media/dvb/bt8xx/dst.c	18 Oct 2005 17:42:44 -0000
>>@@ -1038,8 +1041,12 @@
>> 			state->decode_snr = state->rxbuffer[2] << 8 | state->rxbuffer[3];
>> 		} else if ((state->dst_type == DST_TYPE_IS_TERR) || (state->dst_type == DST_TYPE_IS_CABLE)) {
>> 			state->decode_lock = (state->rxbuffer[1]) ? 1 : 0;
>>-			state->decode_strength = state->rxbuffer[4] << 8;
>> 			state->decode_snr = state->rxbuffer[3] << 8;
>>+			if (state->dst_hw_cap & DST_TYPE_HAS_CA) {
>>+				state->decode_strength = state->rxbuffer[5] << 8;
>>+			} else {
>>+				state->decode_strength = state->rxbuffer[4] << 8;
>>+			}
>> 		}
>> 		state->cur_jiff = jiffies;
>> 	}
>>@@ -1122,9 +1129,11 @@
>> 	}
>> 	state->diseq_flags &= ~(HAS_LOCK | ATTEMPT_TUNE);
>> 
>>+	down(&state->dst_mutex);
>>+
>> 	if ((dst_comm_init(state)) < 0) {
>> 		dprintk(verbose, DST_DEBUG, 1, "DST Communication initialization failed.");
>>-		return -1;
>>+		goto error;
>> 	}
>> 	if (state->type_flags & DST_TYPE_HAS_NEWTUNE) {
>> 		state->tx_tuna[9] = dst_check_sum(&state->tx_tuna[0], 9);
>>@@ -1136,23 +1145,30 @@
>> 	if (retval < 0) {
>> 		dst_pio_disable(state);
>> 		dprintk(verbose, DST_DEBUG, 1, "write not successful");
>>-		return retval;
>>+		goto error;
>> 	}
>> 	if ((dst_pio_disable(state)) < 0) {
>> 		dprintk(verbose, DST_DEBUG, 1, "DST PIO disable failed !");
>>-		return -1;
>>+		goto error;
>> 	}
>> 	if ((read_dst(state, &reply, GET_ACK) < 0)) {
>> 		dprintk(verbose, DST_DEBUG, 1, "read verify not successful.");
>>-		return -1;
>>+		goto error;
>> 	}
>> 	if (reply != ACK) {
>> 		dprintk(verbose, DST_DEBUG, 1, "write not acknowledged 0x%02x ", reply);
>>-		return 0;
>>+		goto error;
>> 	}
>> 	state->diseq_flags |= ATTEMPT_TUNE;
>> 
>>-	return dst_get_tuna(state);
>>+	retval = dst_get_tuna(state);
>>+
>>+	up(&state->dst_mutex);
>>+	return retval;
>>+
>>+error:
>>+	up(&state->dst_mutex);
>>+	return -EIO;
>> }
>> 
>> /*
>>
>>------------------------------------------------------------------------
>>
>>_______________________________________________
>>linux-dvb mailing list
>>linux-dvb at linuxtv.org
>>http://www.linuxtv.org/cgi-bin/mailman/listinfo/linux-dvb
>>




More information about the linux-dvb mailing list