All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 3/6] staging: most: aim-cdev: make syscall write accept buffers of arbitrary size
@ 2016-09-22  9:37 Christian Gromm
  2016-09-23 12:08 ` Greg KH
  0 siblings, 1 reply; 5+ messages in thread
From: Christian Gromm @ 2016-09-22  9:37 UTC (permalink / raw)
  To: gregkh; +Cc: Christian Gromm, driverdev-devel

This patch allows to call the write() function for synchronous and
isochronous channels with buffers of any size. The AIM simply waits for
data to fill up the MOST buffer object according to the network interface
controller specification for streaming channels, before it submits the
buffer to the HDM.

The new behavior is backward compatible to the old applications, since
all known applications needed to fill the buffer completely anyway.

Signed-off-by: Christian Gromm <christian.gromm@microchip.com>
---

v2: Since the previous patch of this series has beed dropped, this patch
needed some adaptation work to match the source tree again.

 drivers/staging/most/aim-cdev/cdev.c | 37 +++++++++++++++++++++---------------
 1 file changed, 22 insertions(+), 15 deletions(-)

diff --git a/drivers/staging/most/aim-cdev/cdev.c b/drivers/staging/most/aim-cdev/cdev.c
index 5458fb9..7f51024 100644
--- a/drivers/staging/most/aim-cdev/cdev.c
+++ b/drivers/staging/most/aim-cdev/cdev.c
@@ -57,7 +57,11 @@ static inline bool ch_has_mbo(struct aim_channel *c)
 
 static inline bool ch_get_mbo(struct aim_channel *c, struct mbo **mbo)
 {
-	*mbo = most_get_mbo(c->iface, c->channel_id, &cdev_aim);
+	if (!kfifo_peek(&c->fifo, mbo)) {
+		*mbo = most_get_mbo(c->iface, c->channel_id, &cdev_aim);
+		if (*mbo)
+			kfifo_in(&c->fifo, mbo, 1);
+	}
 	return *mbo;
 }
 
@@ -184,8 +188,7 @@ static ssize_t aim_write(struct file *filp, const char __user *buf,
 			 size_t count, loff_t *offset)
 {
 	int ret;
-	size_t actual_len;
-	size_t max_len;
+	size_t to_copy, left;
 	struct mbo *mbo = NULL;
 	struct aim_channel *c = filp->private_data;
 
@@ -205,20 +208,24 @@ static ssize_t aim_write(struct file *filp, const char __user *buf,
 		goto unlock;
 	}
 
-	max_len = c->cfg->buffer_size;
-	actual_len = min(count, max_len);
-	mbo->buffer_length = actual_len;
-
-	if (copy_from_user(mbo->virt_address, buf, mbo->buffer_length)) {
+	to_copy = min(count, c->cfg->buffer_size - c->mbo_offs);
+	left = copy_from_user(mbo->virt_address + c->mbo_offs, buf, to_copy);
+	if (left == to_copy) {
 		ret = -EFAULT;
-		goto put_mbo;
+		goto unlock;
 	}
 
-	most_submit_mbo(mbo);
-	mutex_unlock(&c->io_mutex);
-	return actual_len;
-put_mbo:
-	most_put_mbo(mbo);
+	c->mbo_offs += to_copy - left;
+	if (c->mbo_offs >= c->cfg->buffer_size ||
+	    c->cfg->data_type == MOST_CH_CONTROL ||
+	    c->cfg->data_type == MOST_CH_ASYNC) {
+		kfifo_skip(&c->fifo);
+		mbo->buffer_length = c->mbo_offs;
+		c->mbo_offs = 0;
+		most_submit_mbo(mbo);
+	}
+
+	ret = to_copy - left;
 unlock:
 	mutex_unlock(&c->io_mutex);
 	return ret;
@@ -287,7 +294,7 @@ static unsigned int aim_poll(struct file *filp, poll_table *wait)
 		if (!kfifo_is_empty(&c->fifo))
 			mask |= POLLIN | POLLRDNORM;
 	} else {
-		if (ch_has_mbo(c))
+		if (!kfifo_is_empty(&c->fifo) || ch_has_mbo(c))
 			mask |= POLLOUT | POLLWRNORM;
 	}
 	return mask;
-- 
1.9.1

_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

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

* Re: [PATCH v2 3/6] staging: most: aim-cdev: make syscall write accept buffers of arbitrary size
  2016-09-22  9:37 [PATCH v2 3/6] staging: most: aim-cdev: make syscall write accept buffers of arbitrary size Christian Gromm
@ 2016-09-23 12:08 ` Greg KH
  2016-09-23 12:49   ` Christian Gromm
  0 siblings, 1 reply; 5+ messages in thread
From: Greg KH @ 2016-09-23 12:08 UTC (permalink / raw)
  To: Christian Gromm; +Cc: driverdev-devel

On Thu, Sep 22, 2016 at 11:37:07AM +0200, Christian Gromm wrote:
> This patch allows to call the write() function for synchronous and
> isochronous channels with buffers of any size. The AIM simply waits for
> data to fill up the MOST buffer object according to the network interface
> controller specification for streaming channels, before it submits the
> buffer to the HDM.
> 
> The new behavior is backward compatible to the old applications, since
> all known applications needed to fill the buffer completely anyway.
> 
> Signed-off-by: Christian Gromm <christian.gromm@microchip.com>
> ---
> 
> v2: Since the previous patch of this series has beed dropped, this patch
> needed some adaptation work to match the source tree again.

Where are the 5 other patches in this series?

Please resend all of the remaining ones, as a new series, I don't have
any old patches around anymore, including this one now.

thanks,

greg k-h

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

* Re: [PATCH v2 3/6] staging: most: aim-cdev: make syscall write accept buffers of arbitrary size
  2016-09-23 12:08 ` Greg KH
@ 2016-09-23 12:49   ` Christian Gromm
  2016-09-23 13:20     ` Greg KH
  0 siblings, 1 reply; 5+ messages in thread
From: Christian Gromm @ 2016-09-23 12:49 UTC (permalink / raw)
  To: Greg KH; +Cc: driverdev-devel

On Fri, 23 Sep 2016 14:08:51 +0200
Greg KH <gregkh@linuxfoundation.org> wrote:

> On Thu, Sep 22, 2016 at 11:37:07AM +0200, Christian Gromm wrote:
> > This patch allows to call the write() function for synchronous and
> > isochronous channels with buffers of any size. The AIM simply waits
> > for data to fill up the MOST buffer object according to the network
> > interface controller specification for streaming channels, before
> > it submits the buffer to the HDM.
> > 
> > The new behavior is backward compatible to the old applications,
> > since all known applications needed to fill the buffer completely
> > anyway.
> > 
> > Signed-off-by: Christian Gromm <christian.gromm@microchip.com>
> > ---
> > 
> > v2: Since the previous patch of this series has beed dropped, this
> > patch needed some adaptation work to match the source tree again.
> 
> Where are the 5 other patches in this series?

You dropped one and added four of them. This is the remaining one
that couldn't be applied.

Why would I resend patches that have already been added?

regards,
Chris
  
> 
> Please resend all of the remaining ones, as a new series, I don't have
> any old patches around anymore, including this one now.
> 
> thanks,
> 
> greg k-h



-- 
Regards
Chris

Microchip Technology Germany II GmbH & Co. KG

Dipl.-Ing. (FH) Christian Gromm
Principal Software Engineer, AIS Engineering

Emmy-Noether-Straße 14, 76131 Karlsruhe | Germany
Tel: +49 721 62537 466 | Fax: +49 721 62537 119

christian.gromm@microchip.com | www.microchip.com

Firmensitz: Ismaning
Registergericht: Amtsgericht München HRA 98692
Haftender Gesellschafter: Microchip Technology Germany GmbH, Gilching
Geschäftsführer: Mohammed Nawaz Sharif, James Eric Bjornholt, Ulrich
Hallerberg

Diese E-Mail kann vertrauliche Informationen enthalten. Sie darf nicht
durch andere als die ursprünglich genannten Adressaten genutzt, kopiert
oder weitergeleitet werden. This e-mail may contain confidential
information and should not be used, copied or disclosed by anyone who
is not the original intended recipient.
_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

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

* Re: [PATCH v2 3/6] staging: most: aim-cdev: make syscall write accept buffers of arbitrary size
  2016-09-23 12:49   ` Christian Gromm
@ 2016-09-23 13:20     ` Greg KH
  2016-09-23 13:37       ` Christian Gromm
  0 siblings, 1 reply; 5+ messages in thread
From: Greg KH @ 2016-09-23 13:20 UTC (permalink / raw)
  To: Christian Gromm; +Cc: driverdev-devel

On Fri, Sep 23, 2016 at 02:49:28PM +0200, Christian Gromm wrote:
> On Fri, 23 Sep 2016 14:08:51 +0200
> Greg KH <gregkh@linuxfoundation.org> wrote:
> 
> > On Thu, Sep 22, 2016 at 11:37:07AM +0200, Christian Gromm wrote:
> > > This patch allows to call the write() function for synchronous and
> > > isochronous channels with buffers of any size. The AIM simply waits
> > > for data to fill up the MOST buffer object according to the network
> > > interface controller specification for streaming channels, before
> > > it submits the buffer to the HDM.
> > > 
> > > The new behavior is backward compatible to the old applications,
> > > since all known applications needed to fill the buffer completely
> > > anyway.
> > > 
> > > Signed-off-by: Christian Gromm <christian.gromm@microchip.com>
> > > ---
> > > 
> > > v2: Since the previous patch of this series has beed dropped, this
> > > patch needed some adaptation work to match the source tree again.
> > 
> > Where are the 5 other patches in this series?
> 
> You dropped one and added four of them. This is the remaining one
> that couldn't be applied.
> 
> Why would I resend patches that have already been added?

You shouldn't, but why would you resend a patch and claim it is the
middle of a series of patches that are not sent at the same time?

Remember, I have the short-term memory of a squirrel, I have no idea
what was previously sent.  You wouldn't either if you dealt with as many
patches as I get...

thanks,

greg k-h

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

* Re: [PATCH v2 3/6] staging: most: aim-cdev: make syscall write accept buffers of arbitrary size
  2016-09-23 13:20     ` Greg KH
@ 2016-09-23 13:37       ` Christian Gromm
  0 siblings, 0 replies; 5+ messages in thread
From: Christian Gromm @ 2016-09-23 13:37 UTC (permalink / raw)
  To: Greg KH; +Cc: driverdev-devel

On Fri, 23 Sep 2016 15:20:33 +0200
Greg KH <gregkh@linuxfoundation.org> wrote:

> On Fri, Sep 23, 2016 at 02:49:28PM +0200, Christian Gromm wrote:
> > On Fri, 23 Sep 2016 14:08:51 +0200
> > Greg KH <gregkh@linuxfoundation.org> wrote:
> > 
> > > On Thu, Sep 22, 2016 at 11:37:07AM +0200, Christian Gromm wrote:
> > > > This patch allows to call the write() function for synchronous
> > > > and isochronous channels with buffers of any size. The AIM
> > > > simply waits for data to fill up the MOST buffer object
> > > > according to the network interface controller specification for
> > > > streaming channels, before it submits the buffer to the HDM.
> > > > 
> > > > The new behavior is backward compatible to the old applications,
> > > > since all known applications needed to fill the buffer
> > > > completely anyway.
> > > > 
> > > > Signed-off-by: Christian Gromm <christian.gromm@microchip.com>
> > > > ---
> > > > 
> > > > v2: Since the previous patch of this series has beed dropped,
> > > > this patch needed some adaptation work to match the source tree
> > > > again.
> > > 
> > > Where are the 5 other patches in this series?
> > 
> > You dropped one and added four of them. This is the remaining one
> > that couldn't be applied.
> > 
> > Why would I resend patches that have already been added?
> 
> You shouldn't, but why would you resend a patch and claim it is the
> middle of a series of patches that are not sent at the same time?

Got your point and almost did it that way.

Then I thought the community would want the second version of a
patch to have the very same "subject" (except for v2) as the
original one to pull them together.

> 
> Remember, I have the short-term memory of a squirrel, I have no idea
> what was previously sent.  You wouldn't either if you dealt with as
> many patches as I get...

I see. :) But why do I need a v2 then anyway? If your process doesn't
track that there's been a first version around.

all the best,
Chris 

> 
> thanks,
> 
> greg k-h



-- 
Regards
Chris

Microchip Technology Germany II GmbH & Co. KG

Dipl.-Ing. (FH) Christian Gromm
Principal Software Engineer, AIS Engineering

Emmy-Noether-Straße 14, 76131 Karlsruhe | Germany
Tel: +49 721 62537 466 | Fax: +49 721 62537 119

christian.gromm@microchip.com | www.microchip.com

Firmensitz: Ismaning
Registergericht: Amtsgericht München HRA 98692
Haftender Gesellschafter: Microchip Technology Germany GmbH, Gilching
Geschäftsführer: Mohammed Nawaz Sharif, James Eric Bjornholt, Ulrich
Hallerberg

Diese E-Mail kann vertrauliche Informationen enthalten. Sie darf nicht
durch andere als die ursprünglich genannten Adressaten genutzt, kopiert
oder weitergeleitet werden. This e-mail may contain confidential
information and should not be used, copied or disclosed by anyone who
is not the original intended recipient.
_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

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

end of thread, other threads:[~2016-09-23 13:37 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-09-22  9:37 [PATCH v2 3/6] staging: most: aim-cdev: make syscall write accept buffers of arbitrary size Christian Gromm
2016-09-23 12:08 ` Greg KH
2016-09-23 12:49   ` Christian Gromm
2016-09-23 13:20     ` Greg KH
2016-09-23 13:37       ` Christian Gromm

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.