From: Oliver Endriss <o.endriss@gmx.de>
To: linux-dvb@linuxtv.org
Subject: Re: [linux-dvb] [PATCH] 2/3: implement DMX_SET_BUFFER_SIZE for dvr
Date: Sat, 22 Mar 2008 05:45:22 +0100 [thread overview]
Message-ID: <200803220545.23147@orion.escape-edv.de> (raw)
In-Reply-To: <47E45138.1030107@googlemail.com>
Andrea wrote:
> This patch implements the ioctl DMX_SET_BUFFER_SIZE for the dvr.
>
> The ioctl used to be supported but not yet implemented.
>
> The way it works is that it replaces the ringbuffer with a new one.
> Beforehand it flushes the old buffer.
> This means that part of the stream is lost, and reading errors (like overflow) are cleaned.
> The flushing is not a problem since this operation usually occurs at beginning before start reading.
>
> Since the dvr is *always* up and running this change has to be done while the buffer is written:
>
> 1) On the userspace side, it is as safe as dvb_dvr_read is now:
> - dvb_dvr_set_buffer_size locks the mutex
> - dvb_dvr_read does *not* lock the mutex (the code is there commented out)
>
> So as long as one does not call read simultaneously it works properly.
> Maybe the mutex should be enforced in dvb_dvr_read.
>
> 2) On the kernel side
> The only thing I am not 100% sure about is whether the spin_lock I've used is enough to guarantee
> synchronization between the new function dvb_dvr_set_buffer_size (which uses spin_lock_irq) and
> dvb_dmxdev_ts_callback and dvb_dmxdev_section_callback (using spin_lock).
> But this looks to me the same as all other functions do.
Please see my other mail, too
> spin_lock(&dmxdev->lock);
> mem = buf->data;
> buf->data = NULL;
> buf->size = size;
> dvb_ringbuffer_flush(buf);
> spin_unlock(&dmxdev->lock);
> vfree(mem);
>
> if (buf->size) {
> mem = vmalloc(dmxdev->dvr_buffer.size);
> if (!mem)
> return -ENOMEM;
> spin_lock(&dmxdev->lock);
> buf->data = mem;
> spin_unlock(&dmxdev->lock);
> }
I see some problems here:
- Do not release the lock before the ringbuffer is consistent again.
- We should not free the old buffer before we got a new one.
- As the ring buffer can be written from an ISR, we have to use
spin_lock_irqsave/spin_unlock_irqrestore here.
What about this fragment:
...
if (!size)
return -EINVAL;
mem = vmalloc(size);
if (!mem)
return -ENOMEM;
mem2 = buf->data;
spin_lock_irqsave(&dmxdev->lock);
buf->pread = buf->pwrite = 0;
buf->data = mem;
buf->size = size;
spin_unlock_irqrestore(&dmxdev->lock);
vfree(mem2);
return 0;
Any comemnts? I hope that someone else also has a look at this because
I don't have much time atm.
CU
Oliver
--
----------------------------------------------------------------
VDR Remote Plugin 0.4.0: http://www.escape-edv.de/endriss/vdr/
----------------------------------------------------------------
_______________________________________________
linux-dvb mailing list
linux-dvb@linuxtv.org
http://www.linuxtv.org/cgi-bin/mailman/listinfo/linux-dvb
next prev parent reply other threads:[~2008-03-22 4:46 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-03-22 0:22 [linux-dvb] [PATCH] 2/3: implement DMX_SET_BUFFER_SIZE for dvr Andrea
2008-03-22 4:45 ` Oliver Endriss [this message]
[not found] <mailman.1.1206183601.26852.linux-dvb@linuxtv.org>
2008-03-22 11:32 ` Andrea
2008-03-24 20:49 ` Andrea
2008-04-12 0:35 ` Oliver Endriss
2008-04-13 9:30 ` Andrea
2008-04-13 9:50 ` Andrea
2008-04-13 23:50 ` Oliver Endriss
2008-04-14 19:51 ` Andrea
2008-04-22 18:54 ` Oliver Endriss
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=200803220545.23147@orion.escape-edv.de \
--to=o.endriss@gmx.de \
--cc=linux-dvb@linuxtv.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox