Re: usbmon and scatter-gather

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

 



On Thu, 22 Oct 2009, Pete Zaitcev wrote:

> On Wed, 21 Oct 2009 21:26:38 -0400 (EDT), Alan Stern <stern@xxxxxxxxxxxxxxxxxxx> wrote:
> 
> > I can do it, if it's okay with you.
> 
> Of course. As a lazy programmer, I abhor work. :-)
> 
> > Another possibility is to return an initial segment of the data, up to 
> > the first non-addressable buffer.  Would that work?  I don't know if 
> > usbmon can handle storing a partial (> 0 but < transfer_buffer_length) 
> > data block.
> 
> I see your point. In most cases people only ever see first 32 bytes
> anyway, so... As far as I can tell from a quick look to refresh my
> memory, struct mon_bin_hdr is ready for it. It has two lenghts:
> len_urb and len_cap, exactly so you can capture partials. It cannot
> represent a list of segments with holes, but a short capture is ok.
> So with your proposal old applications can continue working
> (remember that in theory the buffer is visible through mmap).
> For the text, it always returned less than was transferred and
> in any case its internal structures are not visible to applications.
> The only consideration, then, is how painful it is for you to
> code this.

While studying the code, I found an apparent error in
mon_buff_area_shrink(), plus another error in the place where it is
called.  You should be able to deduce the nature of the errors from
this patch.

Is this right?  The documentation doesn't say much about the relation 
among ep->flag_data, ep->lencap, and the isoc descriptor data.

Alan Stern


Index: usb-2.6/drivers/usb/mon/mon_bin.c
===================================================================
--- usb-2.6.orig/drivers/usb/mon/mon_bin.c
+++ usb-2.6/drivers/usb/mon/mon_bin.c
@@ -350,10 +350,13 @@ static unsigned int mon_buff_area_alloc_
  * Return a few (kilo-)bytes to the head of the buffer.
  * This is used if a DMA fetch fails.
  */
-static void mon_buff_area_shrink(struct mon_reader_bin *rp, unsigned int size)
+static void mon_buff_area_shrink(struct mon_reader_bin *rp, unsigned int num,
+		unsigned int oldsize)
 {
+	unsigned int size;
 
-	size = (size + PKT_ALIGN-1) & ~(PKT_ALIGN-1);
+	size = ((oldsize + PKT_ALIGN-1) & ~(PKT_ALIGN-1)) -
+			((oldsize - num + PKT_ALIGN-1) & ~(PKT_ALIGN-1));
 	rp->b_cnt -= size;
 	if (rp->b_in < size)
 		rp->b_in += rp->b_size;
@@ -537,8 +540,9 @@ static void mon_bin_event(struct mon_rea
 	if (length != 0) {
 		ep->flag_data = mon_bin_get_data(rp, offset, urb, length);
 		if (ep->flag_data != 0) {	/* Yes, it's 0x00, not '0' */
-			ep->len_cap = 0;
-			mon_buff_area_shrink(rp, length);
+			ep->len_cap = lendesc;
+			mon_buff_area_shrink(rp, length,
+					length + PKT_SIZE + lendesc);
 		}
 	} else {
 		ep->flag_data = data_tag;

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux