Re: Regression: DVBSky S960 USB tuner doesn't work in 4.10 or newer

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Em Fri, 27 Apr 2018 16:25:08 +0200
Olli Salonen <olli.salonen@xxxxxx> escreveu:

> Thanks for the suggestion Antti.
> 
> I've tried to add a delay in various places, but haven't seen any
> improvement. However, what I did saw was that if I added an msleep
> after the lock:
> 
> static int dvbsky_usb_generic_rw(struct dvb_usb_device *d,
>                 u8 *wbuf, u16 wlen, u8 *rbuf, u16 rlen)
> {
>         int ret;
>         struct dvbsky_state *state = d_to_priv(d);
> 
>         mutex_lock(&d->usb_mutex);
>         msleep(20);
> 
> The error was seen very within a minute. If I increased the msleep to
> 50, it failed within seconds. This doesn't seem to make sense to me.
> This is the only function where usb_mutex is used. If the mutex is
> held for a longer time, the next attempt to lock the mutex should just
> be delayed a bit, no?

I don't like the idea of having two mutexes there to protect reading/writing
to data one for "generic" r/w ops, and another one just for streaming
control, with ends by calling the "generic" mutex.

IMHO, I would get rid of one of the mutexes, e. g. something like the
patch below (untested).

Regards,
Mauro

media: dvbsky: use just one mutex for serializing device R/W ops

Right now, there are two mutexes serializing r/w ops: one "generic"
and another one specifically for stream on/off.

Clean it a little bit, getting rid of one of the mutexes.

Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@xxxxxxxxxx>

diff --git a/drivers/media/usb/dvb-usb-v2/dvbsky.c b/drivers/media/usb/dvb-usb-v2/dvbsky.c
index 43eb82884555..50553975c39d 100644
--- a/drivers/media/usb/dvb-usb-v2/dvbsky.c
+++ b/drivers/media/usb/dvb-usb-v2/dvbsky.c
@@ -31,7 +31,6 @@ MODULE_PARM_DESC(disable_rc, "Disable inbuilt IR receiver.");
 DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr);
 
 struct dvbsky_state {
-	struct mutex stream_mutex;
 	u8 ibuf[DVBSKY_BUF_LEN];
 	u8 obuf[DVBSKY_BUF_LEN];
 	u8 last_lock;
@@ -68,18 +67,17 @@ static int dvbsky_usb_generic_rw(struct dvb_usb_device *d,
 
 static int dvbsky_stream_ctrl(struct dvb_usb_device *d, u8 onoff)
 {
-	struct dvbsky_state *state = d_to_priv(d);
 	int ret;
-	u8 obuf_pre[3] = { 0x37, 0, 0 };
-	u8 obuf_post[3] = { 0x36, 3, 0 };
+	static u8 obuf_pre[3] = { 0x37, 0, 0 };
+	static u8 obuf_post[3] = { 0x36, 3, 0 };
 
-	mutex_lock(&state->stream_mutex);
-	ret = dvbsky_usb_generic_rw(d, obuf_pre, 3, NULL, 0);
+	mutex_lock(&d->usb_mutex);
+	ret = dvb_usbv2_generic_rw_locked(d, obuf_pre, 3, NULL, 0);
 	if (!ret && onoff) {
 		msleep(20);
-		ret = dvbsky_usb_generic_rw(d, obuf_post, 3, NULL, 0);
+		ret = dvb_usbv2_generic_rw_locked(d, obuf_post, 3, NULL, 0);
 	}
-	mutex_unlock(&state->stream_mutex);
+	mutex_unlock(&d->usb_mutex);
 	return ret;
 }
 
@@ -744,8 +742,6 @@ static int dvbsky_init(struct dvb_usb_device *d)
 	if (ret)
 		return ret;
 	*/
-	mutex_init(&state->stream_mutex);
-
 	state->last_lock = 0;
 
 	return 0;



Thanks,
Mauro



[Index of Archives]     [Linux Input]     [Video for Linux]     [Gstreamer Embedded]     [Mplayer Users]     [Linux USB Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]

  Powered by Linux