All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Kai Mäkisara" <kai.makisara@kolumbus.fi>
To: Alan Stern <stern@rowland.harvard.edu>
Cc: Jens Axboe <axboe@suse.de>,
	James Bottomley <James.Bottomley@steeleye.com>,
	Oliver Neukum <oliver@neukum.org>,
	Patrick Mansfield <patmans@us.ibm.com>,
	Douglas Gilbert <dougg@torque.net>,
	SCSI development list <linux-scsi@vger.kernel.org>,
	USB development list <linux-usb-devel@lists.sourceforge.net>
Subject: Re: [linux-usb-devel] Re: Unaligned scatter-gather buffers and usb-storage
Date: Thu, 20 Nov 2003 21:18:59 +0200	[thread overview]
Message-ID: <20031120191859.GA3569@kai.makisara.local> (raw)
In-Reply-To: <Pine.LNX.4.58.0311201911070.2302@kai.makisara.local>

Thus spake Kai Makisara (Kai.Makisara@kolumbus.fi):

> On Thu, 20 Nov 2003, Alan Stern wrote:
> 
...
> > The answer seems very simple.  There should be a host template entry for
> > dma buffer alignment (there's already a dma_boundary member).  It would be
> > copied into the device's request queue stucture if it is nonzero,
> > overriding the default value of 512.  sg and st should check the user
> > buffer against the request queue's dma_alignment mask and avoid doing
> > direct I/O if the alignment is wrong -- just fall back to normal I/O.
> >
> > Any objections to this scheme?
> >
> My only objection is the default. It should be zero. If I read the
> usb-storage sources correctly, the scsi_host_template is defined in one
> file (scsiglue.c). If the mask is there set to 511, all USB storage
> devices get 512-byte alignment and other get no constraints. All get
> optimal result with minimal work. (Adding the check to st and sg is
> trivial.)
> 
To make this a little more than talk, here is a patch for 2.6.0-test9 plus
csets up to today (compiled and tested but does not include the check for sg):
---8<---
diff -ur linux-2.6-cset/drivers/scsi/st.c linux-2.6-cset-k/drivers/scsi/st.c
--- linux-2.6-cset/drivers/scsi/st.c	2003-09-09 18:19:45.000000000 +0300
+++ linux-2.6-cset-k/drivers/scsi/st.c	2003-11-20 20:49:25.000000000 +0200
@@ -1267,7 +1267,8 @@
 		i = STp->try_dio && try_rdio;
 	else
 		i = STp->try_dio && try_wdio;
-	if (i) {
+
+	if (i && ((unsigned int)buf & STp->device->host->hostt->dma_align_mask) == 0) {
 		i = st_map_user_pages(&(STbp->sg[0]), STbp->use_sg,
 				      (unsigned long)buf, count, (is_read ? READ : WRITE),
 				      STp->max_pfn);
diff -ur linux-2.6-cset/drivers/usb/storage/scsiglue.c linux-2.6-cset-k/drivers/usb/storage/scsiglue.c
--- linux-2.6-cset/drivers/usb/storage/scsiglue.c	2003-10-25 22:35:58.000000000 +0300
+++ linux-2.6-cset-k/drivers/usb/storage/scsiglue.c	2003-11-20 19:34:56.000000000 +0200
@@ -312,6 +312,9 @@
 	/* lots of sg segments can be handled */
 	.sg_tablesize =			SG_ALL,
 
+	/* alignment to 512-byte required */
+	.dma_align_mask =		0x1ff,
+
 	/* merge commands... this seems to help performance, but
 	 * periodically someone should test to see which setting is more
 	 * optimal.
Only in linux-2.6-cset/include/asm: page.h~
Only in linux-2.6-cset/include/asm-i386: page.h~
diff -ur linux-2.6-cset/include/scsi/scsi_host.h linux-2.6-cset-k/include/scsi/scsi_host.h
--- linux-2.6-cset/include/scsi/scsi_host.h	2003-10-25 22:35:58.000000000 +0300
+++ linux-2.6-cset-k/include/scsi/scsi_host.h	2003-11-20 19:33:32.000000000 +0200
@@ -268,6 +268,12 @@
 	unsigned long dma_boundary;
 
 	/*
+	 * Alignment mask for scatter/gather segments. The offset and'ed
+	 * with the mask must be zero for segments.
+	 */
+	unsigned int dma_align_mask;
+
+	/*
 	 * This specifies "machine infinity" for host templates which don't
 	 * limit the transfer size.  Note this limit represents an absolute
 	 * maximum, and may be over the transfer limits allowed for
---8<---

-- 
Kai

  reply	other threads:[~2003-11-20 19:19 UTC|newest]

Thread overview: 54+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <1068207145.3fab8c2988d43@webmail.netregistry.net>
2003-11-07 16:21 ` usb-storage and Sony Handycam Alan Stern
2003-11-07 17:29   ` Patrick Mansfield
2003-11-07 19:49     ` Alan Stern
2003-11-08  2:54       ` Dmitri Katchalov
2003-11-08  6:34         ` Patrick Mansfield
2003-11-08 13:29           ` Dmitri Katchalov
2003-11-08 16:28           ` Alan Stern
2003-11-08 20:37             ` Patrick Mansfield
2003-11-09  3:47               ` [linux-usb-devel] " Alan Stern
2003-11-09  8:45                 ` Dmitri Katchalov
2003-11-10 20:45                   ` Patrick Mansfield
2003-11-10 17:59                 ` Patrick Mansfield
2003-11-10 18:46                   ` Alan Stern
2003-11-10 19:04                     ` [linux-usb-devel] " Patrick Mansfield
2003-11-10 19:57                       ` Alan Stern
2003-11-10 22:46                     ` Sancho Dauskardt
2003-11-18 15:20                   ` Unaligned scatter-gather buffers and usb-storage Alan Stern
2003-11-18 22:37                     ` Patrick Mansfield
2003-11-19  8:47                       ` Jens Axboe
2003-11-19 13:01                         ` [linux-usb-devel] " Oliver Neukum
2003-11-19 13:04                           ` Jens Axboe
2003-11-19 14:37                             ` James Bottomley
2003-11-19 14:39                               ` Jens Axboe
2003-11-19 14:58                                 ` James Bottomley
2003-11-19 15:00                                   ` [linux-usb-devel] " Jens Axboe
2003-11-19 16:56                                     ` Kai Makisara
2003-11-19 20:19                                       ` Jens Axboe
2003-11-19 22:06                                         ` Kai Makisara
2003-11-20  6:53                                           ` Jens Axboe
2003-11-20 15:20                                             ` Alan Stern
2003-11-20 15:30                                               ` Jens Axboe
2003-11-20 16:09                                                 ` Alan Stern
2003-11-20 16:24                                                   ` Jens Axboe
2003-11-20 16:28                                                 ` [linux-usb-devel] " Oliver Neukum
2003-11-20 19:23                                                   ` Kai Makisara
2003-11-20 17:18                                               ` Kai Makisara
2003-11-20 19:18                                                 ` Kai Mäkisara [this message]
2003-11-21 18:03                                                   ` PATCH: (as141) " Alan Stern
2003-11-21 20:07                                                     ` Kai Makisara
2003-12-01  1:30                                                     ` Matthew Dharm
2004-01-05  0:41                                                     ` Matthew Dharm
2004-01-05 10:08                                                       ` Jens Axboe
2004-01-05 21:58                                                         ` PATCH: (as141b) " Alan Stern
2004-01-06 11:28                                                           ` Oliver Neukum
2004-01-06 16:10                                                             ` Alan Stern
2004-02-02 15:51                                                           ` James Bottomley
2004-02-03 15:47                                                             ` Alan Stern
2004-02-03 15:55                                                               ` James Bottomley
2004-02-03 16:02                                                               ` Matthew Wilcox
2003-11-19 15:44                         ` Alan Stern
2003-11-19 15:49                           ` Jens Axboe
2003-11-19 16:58                             ` Alan Stern
2003-11-19 17:03                               ` Jens Axboe
2003-11-07 22:09     ` usb-storage and Sony Handycam Alan Stern

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=20031120191859.GA3569@kai.makisara.local \
    --to=kai.makisara@kolumbus.fi \
    --cc=James.Bottomley@steeleye.com \
    --cc=axboe@suse.de \
    --cc=dougg@torque.net \
    --cc=linux-scsi@vger.kernel.org \
    --cc=linux-usb-devel@lists.sourceforge.net \
    --cc=oliver@neukum.org \
    --cc=patmans@us.ibm.com \
    --cc=stern@rowland.harvard.edu \
    /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.