All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrea <mariofutire@googlemail.com>
To: linux-dvb@linuxtv.org
Subject: [linux-dvb] [PATCH] 2/3: implement DMX_SET_BUFFER_SIZE for dvr
Date: Sat, 22 Mar 2008 11:32:53 +0000	[thread overview]
Message-ID: <47E4EE65.1040901@googlemail.com> (raw)
In-Reply-To: <mailman.1.1206183601.26852.linux-dvb@linuxtv.org>

[-- Attachment #1: Type: text/plain, Size: 1503 bytes --]

I've updated this patch following your remarks about PATCH 1/3.

About your feedback, I am not sure I understand what you mean, but I will try:

  > Do not release the lock before the ringbuffer is consistent again.

If you mean that the lock should not be released while buf->data = NULL, this is *not* a problem.
A ringbuffer with NULL data *is* consistent (even though it is useless).
All functions in dmxdev.c check for a NULL pointer before calling read or write on the ringbuffer.
The same happens for the buffer of the demux.

  > We should not free the old buffer before we got a new one.

I like you idea, but I did not want to change the existing logic.

You might have noticed that the new function dvb_dvr_set_buffer_size is very similar to
dvb_dmxdev_set_buffer_size (which exists already): I did not want to introduce a new logic of
resizing the ringbuffer, but I've written a function very very similar.

Maybe in a following patch one could change both of them.

  > As the ring buffer can be written from an ISR, we have to use
    spin_lock_irqsave/spin_unlock_irqrestore here.

Ok, I've changed the patch.
If I use spin_lock_irqsave in dvb_dvr_set_buffer_size (called via IOCTL), do I need to use the same
kind of spin_lock on all other spin_lock on the same lock (e.g. dvb_dmxdev_ts_callback)?




Let me know if I should be more aggressive and change the resize for dvr and demux at once within
this patch. Otherwise if and when this is accepted I will rearrange the code.

Andrea


[-- Attachment #2: size2.diff --]
[-- Type: text/x-patch, Size: 1498 bytes --]

diff -r 1886a5ea2f84 linux/drivers/media/dvb/dvb-core/dmxdev.c
--- a/linux/drivers/media/dvb/dvb-core/dmxdev.c	Fri Mar 21 08:04:55 2008 -0300
+++ b/linux/drivers/media/dvb/dvb-core/dmxdev.c	Sat Mar 22 10:12:58 2008 +0000
@@ -259,6 +259,38 @@ static ssize_t dvb_dvr_read(struct file 
 	return ret;
 }
 
+static int dvb_dvr_set_buffer_size(struct dmxdev *dmxdev,
+				      unsigned long size)
+{
+	struct dvb_ringbuffer *buf = &dmxdev->dvr_buffer;
+	void *mem;
+
+	if (buf->size == size)
+		return 0;
+
+	dprintk("function : %s\n", __FUNCTION__);
+
+	spin_lock(&dmxdev->lock);
+	mem = buf->data;
+	buf->data = NULL;
+	buf->size = size;
+	dvb_ringbuffer_reset(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);
+	}
+
+	return 0;
+}
+
 static inline void dvb_dmxdev_filter_state_set(struct dmxdev_filter
 					       *dmxdevfilter, int state)
 {
@@ -1009,6 +1041,7 @@ static int dvb_dvr_do_ioctl(struct inode
 {
 	struct dvb_device *dvbdev = file->private_data;
 	struct dmxdev *dmxdev = dvbdev->priv;
+	unsigned long arg = (unsigned long)parg;
 	int ret;
 
 	if (mutex_lock_interruptible(&dmxdev->mutex))
@@ -1016,8 +1049,7 @@ static int dvb_dvr_do_ioctl(struct inode
 
 	switch (cmd) {
 	case DMX_SET_BUFFER_SIZE:
-		// FIXME: implement
-		ret = 0;
+		ret = dvb_dvr_set_buffer_size(dmxdev, arg);
 		break;
 
 	default:


[-- Attachment #3: Type: text/plain, Size: 150 bytes --]

_______________________________________________
linux-dvb mailing list
linux-dvb@linuxtv.org
http://www.linuxtv.org/cgi-bin/mailman/listinfo/linux-dvb

  parent reply	other threads:[~2008-03-22 11:33 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <mailman.1.1206183601.26852.linux-dvb@linuxtv.org>
2008-03-22 11:32 ` [linux-dvb] [PATCH] 1/3: BUG FIX in dvb_ringbuffer_flush Andrea
2008-04-13  9:30   ` Andrea
2008-04-13  9:49     ` Andrea
2008-04-14 19:51       ` Andrea
2008-04-22 18:54         ` Oliver Endriss
2008-03-22 11:32 ` Andrea [this message]
2008-03-24 20:49 ` [linux-dvb] [PATCH] 2/3: implement DMX_SET_BUFFER_SIZE for dvr 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
2008-03-22  0:22 Andrea
2008-03-22  4:45 ` 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=47E4EE65.1040901@googlemail.com \
    --to=mariofutire@googlemail.com \
    --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 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.