[PATCH ver3 1/5] scsi_error: code cleanup before refactoring of scsi_send_eh_cmnd()

2007-09-11 Thread Boaz Harrosh

  - regrouped variables for easier reviewing of next patch
  - Support of cmnd==NULL in call to scsi_send_eh_cmnd()
  - In the copy_sense case set transfer size to the minimum
size of sense_buffer and passed @sense_bytes. cmnd[4] is
set accordingly.
  - REQUEST_SENSE is set into cmnd[0] so if @sense_bytes is
not Zero passed cmnd can/should be NULL.
  - Also save/restore resid of faild command.

Signed-off-by: Boaz Harrosh [EMAIL PROTECTED]
---
 drivers/scsi/scsi_error.c |   68 
 1 files changed, 37 insertions(+), 31 deletions(-)

diff --git a/drivers/scsi/scsi_error.c b/drivers/scsi/scsi_error.c
index c8e351f..46d57f1 100644
--- a/drivers/scsi/scsi_error.c
+++ b/drivers/scsi/scsi_error.c
@@ -607,21 +607,24 @@ static void scsi_abort_eh_cmnd(struct scsi_cmnd *scmd)
  *SUCCESS or FAILED or NEEDS_RETRY
  **/
 static int scsi_send_eh_cmnd(struct scsi_cmnd *scmd, unsigned char *cmnd,
-int cmnd_size, int timeout, int copy_sense)
+int cmnd_size, int timeout, unsigned sense_bytes)
 {
struct scsi_device *sdev = scmd-device;
struct Scsi_Host *shost = sdev-host;
-   int old_result = scmd-result;
DECLARE_COMPLETION_ONSTACK(done);
unsigned long timeleft;
unsigned long flags;
-   struct scatterlist sgl;
+
+   unsigned char old_cmd_len;
unsigned char old_cmnd[MAX_COMMAND_SIZE];
enum dma_data_direction old_data_direction;
-   unsigned short old_use_sg;
-   unsigned char old_cmd_len;
unsigned old_bufflen;
void *old_buffer;
+   unsigned short old_use_sg;
+   int old_resid;
+   int old_result;
+
+   struct scatterlist sgl;
int rtn;
 
/*
@@ -631,24 +634,36 @@ static int scsi_send_eh_cmnd(struct scsi_cmnd *scmd, 
unsigned char *cmnd,
 * we will need to restore these values prior to running the actual
 * command.
 */
-   old_buffer = scmd-request_buffer;
-   old_bufflen = scmd-request_bufflen;
+   old_cmd_len = scmd-cmd_len;
memcpy(old_cmnd, scmd-cmnd, sizeof(scmd-cmnd));
old_data_direction = scmd-sc_data_direction;
-   old_cmd_len = scmd-cmd_len;
+   old_bufflen = scmd-request_bufflen;
+   old_buffer = scmd-request_buffer;
old_use_sg = scmd-use_sg;
+   old_resid = scmd-resid;
+   old_result = scmd-result;
 
-   memset(scmd-cmnd, 0, sizeof(scmd-cmnd));
-   memcpy(scmd-cmnd, cmnd, cmnd_size);
-
-   if (copy_sense) {
-   sg_init_one(sgl, scmd-sense_buffer,
-   sizeof(scmd-sense_buffer));
+   if (cmnd) {
+   memset(scmd-cmnd, 0, sizeof(scmd-cmnd));
+   memcpy(scmd-cmnd, cmnd, cmnd_size);
+   scmd-cmd_len = COMMAND_SIZE(scmd-cmnd[0]);
+   }
 
-   scmd-sc_data_direction = DMA_FROM_DEVICE;
-   scmd-request_bufflen = sgl.length;
+   if (sense_bytes) {
+   scmd-request_bufflen = min_t(unsigned,
+  sizeof(scmd-sense_buffer), sense_bytes);
+   sg_init_one(sgl, scmd-sense_buffer, scmd-request_bufflen);
scmd-request_buffer = sgl;
+   scmd-sc_data_direction = DMA_FROM_DEVICE;
scmd-use_sg = 1;
+   memset(scmd-cmnd, 0, 6);
+   scmd-cmnd[0] = REQUEST_SENSE;
+   scmd-cmnd[4] = scmd-request_bufflen;
+   /*
+* Zero the sense buffer.  The scsi spec mandates that any
+* untransferred sense data should be interpreted as being zero.
+*/
+   memset(scmd-sense_buffer, 0, sizeof(scmd-sense_buffer));
} else {
scmd-request_buffer = NULL;
scmd-request_bufflen = 0;
@@ -657,18 +672,11 @@ static int scsi_send_eh_cmnd(struct scsi_cmnd *scmd, 
unsigned char *cmnd,
}
 
scmd-underflow = 0;
-   scmd-cmd_len = COMMAND_SIZE(scmd-cmnd[0]);
 
-   if (sdev-scsi_level = SCSI_2)
+   if (sdev-scsi_level = SCSI_2  sdev-scsi_level != SCSI_UNKNOWN)
scmd-cmnd[1] = (scmd-cmnd[1]  0x1f) |
(sdev-lun  5  0xe0);
 
-   /*
-* Zero the sense buffer.  The scsi spec mandates that any
-* untransferred sense data should be interpreted as being zero.
-*/
-   memset(scmd-sense_buffer, 0, sizeof(scmd-sense_buffer));
-
shost-eh_action = done;
 
spin_lock_irqsave(shost-host_lock, flags);
@@ -716,12 +724,13 @@ static int scsi_send_eh_cmnd(struct scsi_cmnd *scmd, 
unsigned char *cmnd,
/*
 * Restore original data
 */
-   scmd-request_buffer = old_buffer;
-   scmd-request_bufflen = old_bufflen;
+   scmd-cmd_len = old_cmd_len;
memcpy(scmd-cmnd, old_cmnd, sizeof(scmd-cmnd));
scmd-sc_data_direction = old_data_direction;
-   scmd-cmd_len = old_cmd_len;

Re: [PATCH ver3 1/5] scsi_error: code cleanup before refactoring of scsi_send_eh_cmnd()

2007-09-11 Thread Julian Calaby
(added CCs - that's what you get for sending emails after 5.)

On 9/11/07, Boaz Harrosh [EMAIL PROTECTED] wrote:

  static int scsi_send_eh_cmnd(struct scsi_cmnd *scmd, unsigned char *cmnd,
 -int cmnd_size, int timeout, int copy_sense)
 +int cmnd_size, int timeout, unsigned sense_bytes)

Shouldn't that be unsigned _int_?

Thanks,

--

Julian Calaby

Email: [EMAIL PROTECTED]
-
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH][RFC] Use bio markers for request callback

2007-09-11 Thread Hannes Reinecke

Hi all,

this is a proposal for a different implementation of request  
callbacks. The existing -endio callback of a request is actually a  
destructor function, to be called to terminate a request and free all  
structures.


However, on certain occasions (like request-based multipathing) it is  
desirable to have a callback function for a request which is called  
right after the request is finished, ie in end_that_request_first()  
before any bio-bi_endio callback is called.


So a simple solution for this is to clone the request and add a new  
'marker' bio in front of the bio list of the request. This callback  
will be attached a structure in bi_private which keeps a pointer to  
the cloned and the original request, thus serving as a callback for  
the request itself.


Proposed patch attached. As usual comments are welcome.

Cheers,

Hannes
diff --git a/block/ll_rw_blk.c b/block/ll_rw_blk.c
index a15845c..c286f05 100644
--- a/block/ll_rw_blk.c
+++ b/block/ll_rw_blk.c
@@ -40,7 +40,6 @@ static void blk_unplug_work(struct work_struct *work);
 static void blk_unplug_timeout(unsigned long data);
 static void drive_stat_acct(struct request *rq, int nr_sectors, int new_io);
 static void init_request_from_bio(struct request *req, struct bio *bio);
-static int __make_request(struct request_queue *q, struct bio *bio);
 static struct io_context *current_io_context(gfp_t gfp_flags, int node);
 
 /*
@@ -2912,7 +2911,7 @@ static void init_request_from_bio(struct request *req, struct bio *bio)
 	req-start_time = jiffies;
 }
 
-static int __make_request(struct request_queue *q, struct bio *bio)
+int __make_request(struct request_queue *q, struct bio *bio)
 {
 	struct request *req;
 	int el_ret, nr_sectors, barrier, err;
@@ -3030,6 +3029,7 @@ end_io:
 	bio_endio(bio, nr_sectors  9, err);
 	return 0;
 }
+EXPORT_SYMBOL(__make_request);
 
 /*
  * If bio-bi_dev is a partition, remap the location
diff --git a/drivers/md/dm-mpath.c b/drivers/md/dm-mpath.c
index d6ca9d0..76acda2 100644
--- a/drivers/md/dm-mpath.c
+++ b/drivers/md/dm-mpath.c
@@ -1,6 +1,7 @@
 /*
  * Copyright (C) 2003 Sistina Software Limited.
  * Copyright (C) 2004-2005 Red Hat, Inc. All rights reserved.
+ * Copyright (C) 2007 NEC Corporation.
  *
  * This file is released under the GPL.
  */
@@ -8,8 +9,7 @@
 #include dm.h
 #include dm-path-selector.h
 #include dm-hw-handler.h
-#include dm-bio-list.h
-#include dm-bio-record.h
+#include dm-rq-record.h
 
 #include linux/ctype.h
 #include linux/init.h
@@ -77,7 +77,7 @@ struct multipath {
 	unsigned saved_queue_if_no_path;/* Saved state during suspension */
 
 	struct work_struct process_queued_ios;
-	struct bio_list queued_ios;
+	struct list_head queued_ios;
 	unsigned queue_size;
 
 	struct work_struct trigger_event;
@@ -94,7 +94,7 @@ struct multipath {
  */
 struct dm_mpath_io {
 	struct pgpath *pgpath;
-	struct dm_bio_details details;
+	struct dm_rq_details details;
 };
 
 typedef int (*action_fn) (struct pgpath *pgpath);
@@ -171,6 +171,7 @@ static struct multipath *alloc_multipath(struct dm_target *ti)
 	m = kzalloc(sizeof(*m), GFP_KERNEL);
 	if (m) {
 		INIT_LIST_HEAD(m-priority_groups);
+		INIT_LIST_HEAD(m-queued_ios);
 		spin_lock_init(m-lock);
 		m-queue_io = 1;
 		INIT_WORK(m-process_queued_ios, process_queued_ios);
@@ -180,6 +181,9 @@ static struct multipath *alloc_multipath(struct dm_target *ti)
 			kfree(m);
 			return NULL;
 		}
+
+		dm_table_enable_elevator(ti-table);
+
 		m-ti = ti;
 		ti-private = m;
 	}
@@ -202,6 +206,8 @@ static void free_multipath(struct multipath *m)
 		dm_put_hw_handler(hwh-type);
 	}
 
+	dm_table_disable_elevator(m-ti-table);
+
 	mempool_destroy(m-mpio_pool);
 	kfree(m);
 }
@@ -299,7 +305,7 @@ static int __must_push_back(struct multipath *m)
 		dm_noflush_suspending(m-ti));
 }
 
-static int map_io(struct multipath *m, struct bio *bio,
+static int map_io(struct multipath *m, struct request *clone,
 		  struct dm_mpath_io *mpio, unsigned was_queued)
 {
 	int r = DM_MAPIO_REMAPPED;
@@ -321,22 +327,30 @@ static int map_io(struct multipath *m, struct bio *bio,
 	if ((pgpath  m-queue_io) ||
 	(!pgpath  m-queue_if_no_path)) {
 		/* Queue for the daemon to resubmit */
-		bio_list_add(m-queued_ios, bio);
+		list_add_tail(clone-queuelist, m-queued_ios);
 		m-queue_size++;
 		if ((m-pg_init_required  !m-pg_init_in_progress) ||
 		!m-queue_io)
 			queue_work(kmultipathd, m-process_queued_ios);
 		pgpath = NULL;
+		clone-q = NULL;
+		clone-rq_disk = NULL;
 		r = DM_MAPIO_SUBMITTED;
-	} else if (pgpath)
-		bio-bi_bdev = pgpath-path.dev-bdev;
-	else if (__must_push_back(m))
-		r = DM_MAPIO_REQUEUE;
-	else
+	} else if (pgpath) {
+		clone-q = bdev_get_queue(pgpath-path.dev-bdev);
+		clone-rq_disk = pgpath-path.dev-bdev-bd_disk;
+	} else {
+		printk(KERN_INFO request %p: failed to map\n, clone);
+		clone-q = NULL;
+		clone-rq_disk = NULL;
 		r = -EIO;	/* Failed */
+	}
 
 	mpio-pgpath = pgpath;
 
+	if (r == DM_MAPIO_REMAPPED  m-current_pg-ps.type-start_io)
+		

Re: [PATCH][RFC] Use bio markers for request callback

2007-09-11 Thread Jens Axboe
On Tue, Sep 11 2007, Hannes Reinecke wrote:
 Hi all,

 this is a proposal for a different implementation of request callbacks. The 
 existing -endio callback of a request is actually a destructor function, 
 to be called to terminate a request and free all structures.

 However, on certain occasions (like request-based multipathing) it is 
 desirable to have a callback function for a request which is called right 
 after the request is finished, ie in end_that_request_first() before any 
 bio-bi_endio callback is called.

 So a simple solution for this is to clone the request and add a new 
 'marker' bio in front of the bio list of the request. This callback will be 
 attached a structure in bi_private which keeps a pointer to the cloned and 
 the original request, thus serving as a callback for the request itself.

 Proposed patch attached. As usual comments are welcome.

Honestly, I think this approach is a much worse design than the NEC
callback option. Exporting __make_request() (which is an INTERNAL
function) aside, this looks like one big hack with pseudo bio attached
to front of list, the enable/disable elevator stuff (does that even work
on stacked devices?).

-- 
Jens Axboe

-
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH][RFC] Use bio markers for request callback

2007-09-11 Thread Hannes Reinecke
Am Tue 11 Sep 2007 01:11:34 PM CEST schrieb Jens Axboe  
[EMAIL PROTECTED]:



On Tue, Sep 11 2007, Hannes Reinecke wrote:

Hi all,

this is a proposal for a different implementation of request callbacks. The
existing -endio callback of a request is actually a destructor function,
to be called to terminate a request and free all structures.

However, on certain occasions (like request-based multipathing) it is
desirable to have a callback function for a request which is called right
after the request is finished, ie in end_that_request_first() before any
bio-bi_endio callback is called.

So a simple solution for this is to clone the request and add a new
'marker' bio in front of the bio list of the request. This callback will be
attached a structure in bi_private which keeps a pointer to the cloned and
the original request, thus serving as a callback for the request itself.

Proposed patch attached. As usual comments are welcome.


Honestly, I think this approach is a much worse design than the NEC
callback option. Exporting __make_request() (which is an INTERNAL
function) aside, this looks like one big hack with pseudo bio attached
to front of list, the enable/disable elevator stuff (does that even work
on stacked devices?).


Hmm; agreed. Main reason for the patch was to show an alternative.
Having callbacks within callbacks is not the most straightforward way.
But if you're okay with it: you're the maintainer, you get to decide.

Exporting __make_request() is just for enabling elevator support based
on the target type. Of course this can be done differently.

Main point here was the marker bio idea. If that's rejected everything else
is moot to discuss.

Cheers,

Hannes
---
No .sig today, my .message went away ...
-
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


switch sdev sysfs attributes to default attributes

2007-09-11 Thread Kay Sievers
From: Kay Sievers [EMAIL PROTECTED]
Subject: [SCSI] switch sdev sysfs attributes to default attributes

This removes the unused sysfs attribute overwriting logic for most of
the attributes, and plugs them into the driver core default attribute
creation.

Without this patch, at the time of the events for the SCSI LUN's, there
will be no sysfs files, because their creation is delayed until the sd
driver has spun up the disks, which might take several seconds. It is the
last WAIT_FOR_SYSFS rule in the default udev setup which can be removed
with this change.

Signed-off-by: Kay Sievers [EMAIL PROTECTED]
Signed-off-by: Hannes Reinecke [EMAIL PROTECTED]
---

 scsi_sysfs.c |  136 ++-
 1 file changed, 52 insertions(+), 84 deletions(-)

diff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c
index 34cdce6..cfdc5f8 100644
--- a/drivers/scsi/scsi_sysfs.c
+++ b/drivers/scsi/scsi_sysfs.c
@@ -576,24 +576,31 @@ sdev_show_modalias(struct device *dev, struct 
device_attribute *attr, char *buf)
 static DEVICE_ATTR(modalias, S_IRUGO, sdev_show_modalias, NULL);
 
 /* Default template for device attributes.  May NOT be modified */
-static struct device_attribute *scsi_sysfs_sdev_attrs[] = {
-   dev_attr_device_blocked,
-   dev_attr_queue_depth,
-   dev_attr_queue_type,
-   dev_attr_type,
-   dev_attr_scsi_level,
-   dev_attr_vendor,
-   dev_attr_model,
-   dev_attr_rev,
-   dev_attr_rescan,
-   dev_attr_delete,
-   dev_attr_state,
-   dev_attr_timeout,
-   dev_attr_iocounterbits,
-   dev_attr_iorequest_cnt,
-   dev_attr_iodone_cnt,
-   dev_attr_ioerr_cnt,
-   dev_attr_modalias,
+static struct attribute *scsi_sdev_attrs[] = {
+   dev_attr_device_blocked.attr,
+   dev_attr_type.attr,
+   dev_attr_scsi_level.attr,
+   dev_attr_vendor.attr,
+   dev_attr_model.attr,
+   dev_attr_rev.attr,
+   dev_attr_rescan.attr,
+   dev_attr_delete.attr,
+   dev_attr_state.attr,
+   dev_attr_timeout.attr,
+   dev_attr_iocounterbits.attr,
+   dev_attr_iorequest_cnt.attr,
+   dev_attr_iodone_cnt.attr,
+   dev_attr_ioerr_cnt.attr,
+   dev_attr_modalias.attr,
+   NULL
+};
+
+static struct attribute_group scsi_sdev_attr_group = {
+   .attrs =scsi_sdev_attrs,
+};
+
+static struct attribute_group *scsi_sdev_attr_groups[] = {
+   scsi_sdev_attr_group,
NULL
 };
 
@@ -655,56 +662,6 @@ static struct device_attribute sdev_attr_queue_type_rw =
__ATTR(queue_type, S_IRUGO | S_IWUSR, show_queue_type_field,
   sdev_store_queue_type_rw);
 
-static struct device_attribute *attr_changed_internally(
-   struct Scsi_Host *shost,
-   struct device_attribute * attr)
-{
-   if (!strcmp(queue_depth, attr-attr.name)
-shost-hostt-change_queue_depth)
-   return sdev_attr_queue_depth_rw;
-   else if (!strcmp(queue_type, attr-attr.name)
-shost-hostt-change_queue_type)
-   return sdev_attr_queue_type_rw;
-   return attr;
-}
-
-
-static struct device_attribute *attr_overridden(
-   struct device_attribute **attrs,
-   struct device_attribute *attr)
-{
-   int i;
-
-   if (!attrs)
-   return NULL;
-   for (i = 0; attrs[i]; i++)
-   if (!strcmp(attrs[i]-attr.name, attr-attr.name))
-   return attrs[i];
-   return NULL;
-}
-
-static int attr_add(struct device *dev, struct device_attribute *attr)
-{
-   struct device_attribute *base_attr;
-
-   /*
-* Spare the caller from having to copy things it's not interested in.
-*/
-   base_attr = attr_overridden(scsi_sysfs_sdev_attrs, attr);
-   if (base_attr) {
-   /* extend permissions */
-   attr-attr.mode |= base_attr-attr.mode;
-
-   /* override null show/store with default */
-   if (!attr-show)
-   attr-show = base_attr-show;
-   if (!attr-store)
-   attr-store = base_attr-store;
-   }
-
-   return device_create_file(dev, attr);
-}
-
 /**
  * scsi_sysfs_add_sdev - add scsi device to sysfs
  * @sdev:  scsi_device to add
@@ -736,6 +693,24 @@ int scsi_sysfs_add_sdev(struct scsi_device *sdev)
 * released by the sdev_class .release */
get_device(sdev-sdev_gendev);
 
+   /* create queue files, which may be writable, depending on the host */
+   if (sdev-host-hostt-change_queue_depth)
+   error = device_create_file(sdev-sdev_gendev, 
sdev_attr_queue_depth_rw);
+   else
+   error = device_create_file(sdev-sdev_gendev, 
dev_attr_queue_depth);
+   if (error) {
+   __scsi_remove_device(sdev);
+   goto out;
+   }
+   if (sdev-host-hostt-change_queue_type)
+   error = device_create_file(sdev-sdev_gendev, 

Re: [PATCH ver3 1/5] scsi_error: code cleanup before refactoring of scsi_send_eh_cmnd()

2007-09-11 Thread Alan Stern
On Tue, 11 Sep 2007, Boaz Harrosh wrote:

   - regrouped variables for easier reviewing of next patch
   - Support of cmnd==NULL in call to scsi_send_eh_cmnd()
   - In the copy_sense case set transfer size to the minimum
 size of sense_buffer and passed @sense_bytes. cmnd[4] is
 set accordingly.
   - REQUEST_SENSE is set into cmnd[0] so if @sense_bytes is
 not Zero passed cmnd can/should be NULL.
   - Also save/restore resid of faild command.

The if (sense_bytes) block doesn't set scmd-cmd_len.  Yes, I know 
that value gets changed by the usb-storage driver, but nevertheless it 
should be set here to 6.

Apart from that, this looks fine to me.

Alan Stern

-
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH][RFC] Use bio markers for request callback

2007-09-11 Thread Kiyoshi Ueda
Hi Hannes,

On Tue, 11 Sep 2007 12:44:46 +0200, Hannes Reinecke [EMAIL PROTECTED] wrote:
 this is a proposal for a different implementation of request  
 callbacks. The existing -endio callback of a request is actually a  
 destructor function, to be called to terminate a request and free all  
 structures.
 
 However, on certain occasions (like request-based multipathing) it is  
 desirable to have a callback function for a request which is called  
 right after the request is finished, ie in end_that_request_first()  
 before any bio-bi_endio callback is called.
 
 So a simple solution for this is to clone the request and add a new  
 'marker' bio in front of the bio list of the request. This callback  
 will be attached a structure in bi_private which keeps a pointer to  
 the cloned and the original request, thus serving as a callback for  
 the request itself.

Thank you for another idea for request-based multipath.

However, I disagree with the idea.
I think the design (bio-bi_end_io() completes a request) is complex
a little bit and is breaking layer stacking.
Also, I think that the design of completion handling by 2 hooks,
bio-bi_end_io() and rq-end_io(), makes error handing in dm-multipath
complex.
e.g. Even if we detect an error on the first bio-bi_end_io() hook,
 the request can't be retried until the second rq-end_io() hook
 is called, because the ownership of the request is still on
 low level drivers until the low level driver calls
 end_that_request_last().


Although this is just implementation issue, I think that the patch
can't handle leftover.
SCSI, scsi_end_request(), may have some leftovers in the request.
Then, the marker bio is freed in bio-bi_end_io() and the request
is resubmitted in SCSI level.  So the resubmitted request
doesn't have the marker bio any more.

Thanks,
Kiyoshi Ueda
-
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH ver3 1/5] scsi_error: code cleanup before refactoring of scsi_send_eh_cmnd()

2007-09-11 Thread Boaz Harrosh
On Tue, Sep 11 2007 at 18:41 +0300, Alan Stern [EMAIL PROTECTED] wrote:
 On Tue, 11 Sep 2007, Boaz Harrosh wrote:
 
   - regrouped variables for easier reviewing of next patch
   - Support of cmnd==NULL in call to scsi_send_eh_cmnd()
   - In the copy_sense case set transfer size to the minimum
 size of sense_buffer and passed @sense_bytes. cmnd[4] is
 set accordingly.
   - REQUEST_SENSE is set into cmnd[0] so if @sense_bytes is
 not Zero passed cmnd can/should be NULL.
   - Also save/restore resid of faild command.
 
 The if (sense_bytes) block doesn't set scmd-cmd_len.  Yes, I know 
 that value gets changed by the usb-storage driver, but nevertheless it 
 should be set here to 6.
 
 Apart from that, this looks fine to me.
 
 Alan Stern
 
Thanks a million. The 22:45 effect again.
Will patch ver4 of this patch as reply to
first one.

Boaz

-
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [0/22] Advansys updates 2007-09-09

2007-09-11 Thread Matthew Wilcox
On Tue, Sep 11, 2007 at 05:00:27AM +0900, FUJITA Tomonori wrote:
 On Sun, 9 Sep 2007 08:53:58 -0600
 Matthew Wilcox [EMAIL PROTECTED] wrote:
 
  Here's another mammoth patch series for the advansys driver against
  scsi-misc.  I've tested that it compiles at each stage and that the
  final result works.
 
 This is on the top of the patchset. Can I get your ACK on it?
 
 This depends on scsi-misc, the patchset, and sg chaining stuff.

Phew, that's one of the items on my todo list that I now don't have to
do.  Thanks!  I haven't tested it (I'm away from my machines for this
week), but please do submit it with the other sg work you've done.  Any
bugs can be figured out later.

Acked-by: Matthew Wilcox [EMAIL PROTECTED]

-- 
Intel are signing my paycheques ... these opinions are still mine
Bill, look, we understand that you're interested in selling us this
operating system, but compare it to ours.  We can't possibly take such
a retrograde step.
-
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


RE: SCSI device recover

2007-09-11 Thread Smarduch Mario-CMS063
Hi,
 
We're seeing an issue where a SCSI device failure freezes the system
and it takes about 13s for the system to recover. Not knowing enough
about SCSI or how SCSI works on Linux I have a couple questions.
 
- is there a way to configure the recovery timeouts such as aborts
  and resets?
 
- if yes to what values (ms, seconds) can these be changed?
 
BR,
  mjs.
-
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 00/27] blk_end_request: full I/O completion handler (take 2)

2007-09-11 Thread Kiyoshi Ueda
Hello,

The following is the revised patch-set, fixing the issue pointed
out by Jens and Benny.  Changes from the previous post are below:
  o Rebased on top of 2.6.23-rc4-mm1
  o Don't pass the lock held information (PATCH 01)
  o Removed sect2byte() macro (PATCH 02)
  o fixed blk_rq_size() and blk_rq_cur_size() for blk_pc_requests (PATCH 02)
  o Separated the patch for changes of end_that_request_* user (PATCH 03-26)
  o Removed the patch which changes the role of rq-end_io()
from this patch-set because some more discussions are needed
about it.

Summary of each patch are below:
  01/27: add new request completion interface, blk_end_request()
  02/27: add some functions to get the size of request in bytes
  03/27: convert to use blk_end_request() (core parts of block layer)
  04/27: convert to use blk_end_request() (arm)
  05/27: convert to use blk_end_request() (um)
  06/27: convert to use blk_end_request() (DAC960)
  07/27: convert to use blk_end_request() (floppy)
  08/27: convert to use blk_end_request() (lguest)
  09/27: convert to use blk_end_request() (nbd)
  10/27: convert to use blk_end_request() (ps3disk)
  11/27: convert to use blk_end_request() (sunvdc)
  12/27: convert to use blk_end_request() (sx8)
  13/27: convert to use blk_end_request() (ub)
  14/27: convert to use blk_end_request() (viodasd)
  15/27: convert to use blk_end_request() (xen-blkfront)
  16/27: convert to use blk_end_request() (viocd)
  17/27: convert to use blk_end_request() (i2o_block)
  18/27: convert to use blk_end_request() (mmc)
  19/27: convert to use blk_end_request() (s390)
  20/27: convert to use blk_end_request() (scsi mid-layer)
  21/27: convert to use blk_end_request() (ide-scsi)
  22/27: convert to use blk_end_request() (xsysace)
  23/27: convert to use blk_end_request() (cciss)
  24/27: convert to use blk_end_request() (cpqarray)
  25/27: convert to use blk_end_request() (normal parts of ide)
  26/27: convert to use blk_end_request() (ide-cd, cdrom_newpc_intr())
  27/27: remove/unexport no longer needed end_that_request_*

I have tested this patch-set on two machines,
IA64+QLA1280+QLA2200 box and x86_64+SATA+IDE-CDROM box.
Please review and apply.


Below is the explanation about needs and details of this patch-set.

SUMMARY
===
This set of patches changes request completion interface
between device drivers and block layer to 1 step procedure
from current 2 step procedures using end_that_request_{first/chunk}
and end_that_request_last().

This patch-set prepares for realizing another patch-set which changes
the role of rq-end_io().  It allows request-based multipath to hook
in before completing each chunk of request, check errors for it and
retry it using another path if error is detected.


BACKGROUND
==
The patch-set which changes the role of rq-end_io() is necessary
to allow device stacking at request level, that is request-based
device-mapper multipath.
Currently, device-mapper is implemented as a stacking block device
at BIO level.  OTOH, request-based dm will stack at request level
to allow better multipathing decision.
To allow device stacking at request level, the completion procedure
need to provide a hook for it.
For example, dm-multipath has to check errors and retry with other
paths if necessary before returning the I/O result to upper layer.
struct request has 'end_io' hook currently.  But it's called at
the very late stage of completion handling where the I/O result
is already returned to the upper layer.
So we need something here.

The first approach to hook in completion of each chunk of request
was adding a new rq-end_io_first() hook and calling it on the top
of __end_that_request_first().
  - http://marc.theaimsgroup.com/?l=linux-scsim=115520444515914w=2
  - http://marc.theaimsgroup.com/?l=linux-kernelm=116656637425880w=2
However, Jens pointed out that redesigning rq-end_io() as a full
completion handler would be better:

On Thu, 21 Dec 2006 08:49:47 +0100, Jens Axboe [EMAIL PROTECTED] wrote:
 Ok, I see what you are getting at. The current -end_io() is called when
 the request has fully completed, you want notification for each chunk
 potentially completed.
 
 I think a better design here would be to use -end_io() as the full
 completion handler, similar to how bio-bi_end_io() works. A request
 originating from __make_request() would set something ala:
.
 instead of calling the functions manually. That would allow you to get
 notification right at the beginning and do what you need, without adding
 a special hook for this.

I thought his comment was reasonable.
So I modified the patches based on his suggestion.


WHAT IS CHANGED
===
The change is basically illustlated by the following pseudo code:

[Before]
  if (end_that_request_{first/chunk} succeeds) { -- completes bios
 do something driver specific
 end_that_request_last() -- calls end_io()
 the request is free from the driver
  } else {
 the request was incomplete, retry for leftover 

[PATCH 03/27] blk_end_request: changing block layer core (take 2)

2007-09-11 Thread Kiyoshi Ueda
This patch converts core parts of block layer to use blk_end_request().

Signed-off-by: Kiyoshi Ueda [EMAIL PROTECTED]
Signed-off-by: Jun'ichi Nomura [EMAIL PROTECTED]
---
 block/ll_rw_blk.c |   15 +--
 1 files changed, 5 insertions(+), 10 deletions(-)

diff -rupN 02-rq-size-macro/block/ll_rw_blk.c 
03-blkcore-caller-change/block/ll_rw_blk.c
--- 02-rq-size-macro/block/ll_rw_blk.c  2007-09-10 17:42:56.0 -0400
+++ 03-blkcore-caller-change/block/ll_rw_blk.c  2007-09-10 17:57:59.0 
-0400
@@ -365,8 +365,8 @@ void blk_ordered_complete_seq(struct req
q-ordseq = 0;
rq = q-orig_bar_rq;
 
-   end_that_request_first(rq, uptodate, rq-hard_nr_sectors);
-   end_that_request_last(rq, uptodate);
+   if (__blk_end_request(rq, uptodate, blk_rq_size(rq)))
+   BUG();
 }
 
 static void pre_flush_end_io(struct request *rq, int error)
@@ -484,9 +484,8 @@ int blk_do_ordered(struct request_queue 
 * ORDERED_NONE while this request is on it.
 */
blkdev_dequeue_request(rq);
-   end_that_request_first(rq, -EOPNOTSUPP,
-  rq-hard_nr_sectors);
-   end_that_request_last(rq, -EOPNOTSUPP);
+   if (__blk_end_request(rq, -EOPNOTSUPP, blk_rq_size(rq)))
+   BUG();
*rqp = NULL;
return 0;
}
@@ -3720,11 +3719,7 @@ EXPORT_SYMBOL(end_that_request_last);
 static inline void __end_request(struct request *rq, int uptodate,
 unsigned int nr_bytes)
 {
-   if (!end_that_request_chunk(rq, uptodate, nr_bytes)) {
-   blkdev_dequeue_request(rq);
-   add_disk_randomness(rq-rq_disk);
-   end_that_request_last(rq, uptodate);
-   }
+   __blk_end_request(rq, uptodate, nr_bytes);
 }
 
 /**
-
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 01/27] blk_end_request: add new request completion interface (take 2)

2007-09-11 Thread Kiyoshi Ueda
This patch adds 2 new interfaces for request completion:
  o blk_end_request()   : called without queue lock
  o __blk_end_request() : called with queue lock held

Some device drivers call some generic functions below between
end_that_request_{first/chunk} and end_that_request_last().
  o add_disk_randomness()
  o blk_queue_end_tag()
  o blkdev_dequeue_request()
These are called in the blk_end_request() as a part of generic
request completion.
So all device drivers become to call above functions.

Normal drivers can be converted to use blk_end_request()
in a standard way shown below.

 a) end_that_request_{chunk/first}
spin_lock_irqsave()
(add_disk_randomness(), blk_queue_end_tag(), blkdev_dequeue_request())
end_that_request_last()
spin_unlock_irqrestore()
= blk_end_request()

 b) spin_lock_irqsave()
end_that_request_{chunk/first}
(add_disk_randomness(), blk_queue_end_tag(), blkdev_dequeue_request())
end_that_request_last()
spin_unlock_irqrestore()
= spin_lock_irqsave()
   __blk_end_request()
   spin_unlock_irqsave()

 c) end_that_request_last()
= __blk_end_request()

Signed-off-by: Kiyoshi Ueda [EMAIL PROTECTED]
Signed-off-by: Jun'ichi Nomura [EMAIL PROTECTED]
---
 block/ll_rw_blk.c  |   74 
 include/linux/blkdev.h |2 +
 2 files changed, 76 insertions(+)

diff -rupN 2.6.23-rc4-mm1/block/ll_rw_blk.c 
01-blkendreq-interface/block/ll_rw_blk.c
--- 2.6.23-rc4-mm1/block/ll_rw_blk.c2007-09-10 17:32:11.0 -0400
+++ 01-blkendreq-interface/block/ll_rw_blk.c2007-09-10 17:42:56.0 
-0400
@@ -3776,6 +3776,80 @@ void end_request(struct request *req, in
 }
 EXPORT_SYMBOL(end_request);
 
+static void complete_request(struct request *rq, int uptodate)
+{
+   if (blk_rq_tagged(rq))
+   blk_queue_end_tag(rq-q, rq);
+
+   if (!list_empty(rq-queuelist))
+   blkdev_dequeue_request(rq);
+
+   end_that_request_last(rq, uptodate);
+}
+
+/**
+ * blk_end_request - Helper function for drivers to complete the request.
+ * @rq:   the request being processed
+ * @uptodate: 1 for success, 0 for I/O error,  0 for specific error
+ * @nr_bytes: number of bytes to complete
+ *
+ * Description:
+ * Ends I/O on a number of bytes attached to @rq.
+ * If @rq has leftover, sets it up for the next range of segments.
+ *
+ * Return:
+ * 0 - we are done with this request
+ * 1 - still buffers pending for this request
+ **/
+int blk_end_request(struct request *rq, int uptodate, int nr_bytes)
+{
+   struct request_queue *q = rq-q;
+   unsigned long flags = 0UL;
+
+   if (blk_fs_request(rq) || blk_pc_request(rq)) {
+   if (__end_that_request_first(rq, uptodate, nr_bytes))
+   return 1;
+   }
+
+   /*
+* No need to check the argument here because it is done
+* in add_disk_randomness().
+*/
+   add_disk_randomness(rq-rq_disk);
+
+   spin_lock_irqsave(q-queue_lock, flags);
+   complete_request(rq, uptodate);
+   spin_unlock_irqrestore(q-queue_lock, flags);
+
+   return 0;
+}
+EXPORT_SYMBOL_GPL(blk_end_request);
+
+/**
+ * __blk_end_request - Helper function for drivers to complete the request.
+ *
+ * Description:
+ * Must be called with queue lock held unlike blk_end_request().
+ **/
+int __blk_end_request(struct request *rq, int uptodate, int nr_bytes)
+{
+   if (blk_fs_request(rq) || blk_pc_request(rq)) {
+   if (__end_that_request_first(rq, uptodate, nr_bytes))
+   return 1;
+   }
+
+   /*
+* No need to check the argument here because it is done
+* in add_disk_randomness().
+*/
+   add_disk_randomness(rq-rq_disk);
+
+   complete_request(rq, uptodate);
+
+   return 0;
+}
+EXPORT_SYMBOL_GPL(__blk_end_request);
+
 void blk_rq_bio_prep(struct request_queue *q, struct request *rq,
 struct bio *bio)
 {
diff -rupN 2.6.23-rc4-mm1/include/linux/blkdev.h 
01-blkendreq-interface/include/linux/blkdev.h
--- 2.6.23-rc4-mm1/include/linux/blkdev.h   2007-09-10 17:32:18.0 
-0400
+++ 01-blkendreq-interface/include/linux/blkdev.h   2007-09-10 
17:42:56.0 -0400
@@ -727,6 +727,8 @@ static inline void blk_run_address_space
  * for parts of the original function. This prevents
  * code duplication in drivers.
  */
+extern int blk_end_request(struct request *rq, int uptodate, int nr_bytes);
+extern int __blk_end_request(struct request *rq, int uptodate, int nr_bytes);
 extern int end_that_request_first(struct request *, int, int);
 extern int end_that_request_chunk(struct request *, int, int);
 extern void end_that_request_last(struct request *, int);
-
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 04/27] blk_end_request: changing arm (take 2)

2007-09-11 Thread Kiyoshi Ueda
This patch converts arm to use blk_end_request().

Signed-off-by: Kiyoshi Ueda [EMAIL PROTECTED]
Signed-off-by: Jun'ichi Nomura [EMAIL PROTECTED]
---

 arch/arm/plat-omap/mailbox.c |9 ++---
 1 files changed, 6 insertions(+), 3 deletions(-)

diff -rupN 03-blkcore-caller-change/arch/arm/plat-omap/mailbox.c 
04-arm-caller-change/arch/arm/plat-omap/mailbox.c
--- 03-blkcore-caller-change/arch/arm/plat-omap/mailbox.c   2007-08-27 
21:32:35.0 -0400
+++ 04-arm-caller-change/arch/arm/plat-omap/mailbox.c   2007-09-10 
17:59:02.0 -0400
@@ -117,7 +117,8 @@ static void mbox_tx_work(struct work_str
 
spin_lock(q-queue_lock);
blkdev_dequeue_request(rq);
-   end_that_request_last(rq, 0);
+   if (__blk_end_request(rq, 0, 0))
+   BUG();
spin_unlock(q-queue_lock);
}
 }
@@ -151,7 +152,8 @@ static void mbox_rx_work(struct work_str
 
spin_lock_irqsave(q-queue_lock, flags);
blkdev_dequeue_request(rq);
-   end_that_request_last(rq, 0);
+   if (__blk_end_request(rq, 0, 0))
+   BUG();
spin_unlock_irqrestore(q-queue_lock, flags);
 
mbox-rxq-callback((void *)msg);
@@ -265,7 +267,8 @@ omap_mbox_read(struct device *dev, struc
 
spin_lock_irqsave(q-queue_lock, flags);
blkdev_dequeue_request(rq);
-   end_that_request_last(rq, 0);
+   if (__blk_end_request(rq, 0, 0))
+   BUG();
spin_unlock_irqrestore(q-queue_lock, flags);
 
if (unlikely(mbox_seq_test(mbox, *p))) {
-
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 05/27] blk_end_request: changing um (take 2)

2007-09-11 Thread Kiyoshi Ueda
This patch converts um to use blk_end_request().

Signed-off-by: Kiyoshi Ueda [EMAIL PROTECTED]
Signed-off-by: Jun'ichi Nomura [EMAIL PROTECTED]
---
 arch/um/drivers/ubd_kern.c |   10 +-
 1 files changed, 1 insertion(+), 9 deletions(-)

diff -rupN 04-arm-caller-change/arch/um/drivers/ubd_kern.c 
05-um-caller-change/arch/um/drivers/ubd_kern.c
--- 04-arm-caller-change/arch/um/drivers/ubd_kern.c 2007-08-27 
21:32:35.0 -0400
+++ 05-um-caller-change/arch/um/drivers/ubd_kern.c  2007-09-10 
17:59:35.0 -0400
@@ -476,15 +476,7 @@ int thread_fd = -1;
 
 static void ubd_end_request(struct request *req, int bytes, int uptodate)
 {
-   if (!end_that_request_first(req, uptodate, bytes  9)) {
-   struct ubd *dev = req-rq_disk-private_data;
-   unsigned long flags;
-
-   add_disk_randomness(req-rq_disk);
-   spin_lock_irqsave(dev-lock, flags);
-   end_that_request_last(req, uptodate);
-   spin_unlock_irqrestore(dev-lock, flags);
-   }
+   blk_end_request(req, uptodate, bytes);
 }
 
 /* Callable only from interrupt context - otherwise you need to do
-
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 06/27] blk_end_request: changing DAC960 (take 2)

2007-09-11 Thread Kiyoshi Ueda
This patch converts DAC960 to use blk_end_request().

Signed-off-by: Kiyoshi Ueda [EMAIL PROTECTED]
Signed-off-by: Jun'ichi Nomura [EMAIL PROTECTED]
---
 drivers/block/DAC960.c |5 +
 1 files changed, 1 insertion(+), 4 deletions(-)

diff -rupN 05-um-caller-change/drivers/block/DAC960.c 
06-dac960-caller-change/drivers/block/DAC960.c
--- 05-um-caller-change/drivers/block/DAC960.c  2007-09-10 17:32:11.0 
-0400
+++ 06-dac960-caller-change/drivers/block/DAC960.c  2007-09-10 
18:00:55.0 -0400
@@ -3460,10 +3460,7 @@ static inline bool DAC960_ProcessComplet
pci_unmap_sg(Command-Controller-PCIDevice, Command-cmd_sglist,
Command-SegmentCount, Command-DmaDirection);
 
-if (!end_that_request_first(Request, UpToDate, Command-BlockCount)) {
-   add_disk_randomness(Request-rq_disk);
-   end_that_request_last(Request, UpToDate);
-
+if (!__blk_end_request(Request, UpToDate, Command-BlockCount  9)) {
if (Command-Completion) {
complete(Command-Completion);
Command-Completion = NULL;
-
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 07/27] blk_end_request: changing floppy (take 2)

2007-09-11 Thread Kiyoshi Ueda
This patch converts floppy to use blk_end_request().

Signed-off-by: Kiyoshi Ueda [EMAIL PROTECTED]
Signed-off-by: Jun'ichi Nomura [EMAIL PROTECTED]
---
 drivers/block/floppy.c |8 +++-
 1 files changed, 3 insertions(+), 5 deletions(-)

diff -rupN 06-dac960-caller-change/drivers/block/floppy.c 
07-floppy-caller-change/drivers/block/floppy.c
--- 06-dac960-caller-change/drivers/block/floppy.c  2007-09-10 
17:32:11.0 -0400
+++ 07-floppy-caller-change/drivers/block/floppy.c  2007-09-10 
18:01:23.0 -0400
@@ -2290,18 +2290,16 @@ static int do_format(int drive, struct f
 static void floppy_end_request(struct request *req, int uptodate)
 {
unsigned int nr_sectors = current_count_sectors;
+   unsigned int drive = (unsigned int)req-rq_disk-private_data;
 
/* current_count_sectors can be zero if transfer failed */
if (!uptodate)
nr_sectors = req-current_nr_sectors;
-   if (end_that_request_first(req, uptodate, nr_sectors))
+   if (__blk_end_request(req, uptodate, nr_sectors  9))
return;
-   add_disk_randomness(req-rq_disk);
-   floppy_off((long)req-rq_disk-private_data);
-   blkdev_dequeue_request(req);
-   end_that_request_last(req, uptodate);
 
/* We're done with the request */
+   floppy_off(drive);
current_req = NULL;
 }
 
-
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 08/27] blk_end_request: changing lguest (take 2)

2007-09-11 Thread Kiyoshi Ueda
This patch converts lguest to use blk_end_request().

Signed-off-by: Kiyoshi Ueda [EMAIL PROTECTED]
Signed-off-by: Jun'ichi Nomura [EMAIL PROTECTED]
---
 drivers/block/lguest_blk.c |5 +
 1 files changed, 1 insertion(+), 4 deletions(-)

diff -rupN 07-floppy-caller-change/drivers/block/lguest_blk.c 
08-lguest-caller-change/drivers/block/lguest_blk.c
--- 07-floppy-caller-change/drivers/block/lguest_blk.c  2007-08-27 
21:32:35.0 -0400
+++ 08-lguest-caller-change/drivers/block/lguest_blk.c  2007-09-10 
18:01:53.0 -0400
@@ -77,11 +77,8 @@ struct blockdev
  * request.  This improved disk speed by 130%. */
 static void end_entire_request(struct request *req, int uptodate)
 {
-   if (end_that_request_first(req, uptodate, req-hard_nr_sectors))
+   if (__blk_end_request(req, uptodate, blk_rq_size(req)))
BUG();
-   add_disk_randomness(req-rq_disk);
-   blkdev_dequeue_request(req);
-   end_that_request_last(req, uptodate);
 }
 
 /* I'm told there are only two stories in the world worth telling: love and
-
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 09/27] blk_end_request: changing nbd (take 2)

2007-09-11 Thread Kiyoshi Ueda
This patch converts nbd to use blk_end_request().

Signed-off-by: Kiyoshi Ueda [EMAIL PROTECTED]
Signed-off-by: Jun'ichi Nomura [EMAIL PROTECTED]
---
 drivers/block/nbd.c |4 +---
 1 files changed, 1 insertion(+), 3 deletions(-)

diff -rupN 08-lguest-caller-change/drivers/block/nbd.c 
09-nbd-caller-change/drivers/block/nbd.c
--- 08-lguest-caller-change/drivers/block/nbd.c 2007-09-10 17:32:11.0 
-0400
+++ 09-nbd-caller-change/drivers/block/nbd.c2007-09-10 18:02:30.0 
-0400
@@ -107,9 +107,7 @@ static void nbd_end_request(struct reque
req, uptodate? done: failed);
 
spin_lock_irqsave(q-queue_lock, flags);
-   if (!end_that_request_first(req, uptodate, req-nr_sectors)) {
-   end_that_request_last(req, uptodate);
-   }
+   __blk_end_request(req, uptodate, req-nr_sectors  9);
spin_unlock_irqrestore(q-queue_lock, flags);
 }
 
-
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 10/27] blk_end_request: changing ps3disk (take 2)

2007-09-11 Thread Kiyoshi Ueda
This patch converts ps3disk to use blk_end_request().

Signed-off-by: Kiyoshi Ueda [EMAIL PROTECTED]
Signed-off-by: Jun'ichi Nomura [EMAIL PROTECTED]
---
 drivers/block/ps3disk.c |6 +-
 1 files changed, 1 insertion(+), 5 deletions(-)

diff -rupN 09-nbd-caller-change/drivers/block/ps3disk.c 
10-ps3disk-caller-change/drivers/block/ps3disk.c
--- 09-nbd-caller-change/drivers/block/ps3disk.c2007-08-27 
21:32:35.0 -0400
+++ 10-ps3disk-caller-change/drivers/block/ps3disk.c2007-09-10 
18:03:00.0 -0400
@@ -280,11 +280,7 @@ static irqreturn_t ps3disk_interrupt(int
}
 
spin_lock(priv-lock);
-   if (!end_that_request_first(req, uptodate, num_sectors)) {
-   add_disk_randomness(req-rq_disk);
-   blkdev_dequeue_request(req);
-   end_that_request_last(req, uptodate);
-   }
+   __blk_end_request(req, uptodate, num_sectors  9);
priv-req = NULL;
ps3disk_do_request(dev, priv-queue);
spin_unlock(priv-lock);
-
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 11/27] blk_end_request: changing sunvdc (take 2)

2007-09-11 Thread Kiyoshi Ueda
This patch converts sunvdc to use blk_end_request().

Signed-off-by: Kiyoshi Ueda [EMAIL PROTECTED]
Signed-off-by: Jun'ichi Nomura [EMAIL PROTECTED]
---
 drivers/block/sunvdc.c |5 +
 1 files changed, 1 insertion(+), 4 deletions(-)

diff -rupN 10-ps3disk-caller-change/drivers/block/sunvdc.c 
11-sunvdc-caller-change/drivers/block/sunvdc.c
--- 10-ps3disk-caller-change/drivers/block/sunvdc.c 2007-08-27 
21:32:35.0 -0400
+++ 11-sunvdc-caller-change/drivers/block/sunvdc.c  2007-09-10 
18:03:31.0 -0400
@@ -213,10 +213,7 @@ static void vdc_end_special(struct vdc_p
 
 static void vdc_end_request(struct request *req, int uptodate, int num_sectors)
 {
-   if (end_that_request_first(req, uptodate, num_sectors))
-   return;
-   add_disk_randomness(req-rq_disk);
-   end_that_request_last(req, uptodate);
+   __blk_end_request(req, uptodate, num_sectors  9);
 }
 
 static void vdc_end_one(struct vdc_port *port, struct vio_dring_state *dr,
-
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 12/27] blk_end_request: changing sx8 (take 2)

2007-09-11 Thread Kiyoshi Ueda
This patch converts sx8 to use blk_end_request().

Signed-off-by: Kiyoshi Ueda [EMAIL PROTECTED]
Signed-off-by: Jun'ichi Nomura [EMAIL PROTECTED]
---
 drivers/block/sx8.c |4 +---
 1 files changed, 1 insertion(+), 3 deletions(-)

diff -rupN 11-sunvdc-caller-change/drivers/block/sx8.c 
12-sx8-caller-change/drivers/block/sx8.c
--- 11-sunvdc-caller-change/drivers/block/sx8.c 2007-08-27 21:32:35.0 
-0400
+++ 12-sx8-caller-change/drivers/block/sx8.c2007-09-10 18:04:02.0 
-0400
@@ -747,11 +747,9 @@ static inline void carm_end_request_queu
struct request *req = crq-rq;
int rc;
 
-   rc = end_that_request_first(req, uptodate, req-hard_nr_sectors);
+   rc = __blk_end_request(req, uptodate, blk_rq_size(req));
assert(rc == 0);
 
-   end_that_request_last(req, uptodate);
-
rc = carm_put_request(host, crq);
assert(rc == 0);
 }
-
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 13/27] blk_end_request: changing ub (take 2)

2007-09-11 Thread Kiyoshi Ueda
This patch converts ub to use blk_end_request().

Signed-off-by: Kiyoshi Ueda [EMAIL PROTECTED]
Signed-off-by: Jun'ichi Nomura [EMAIL PROTECTED]
---
 drivers/block/ub.c |4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff -rupN 12-sx8-caller-change/drivers/block/ub.c 
13-ub-caller-change/drivers/block/ub.c
--- 12-sx8-caller-change/drivers/block/ub.c 2007-08-27 21:32:35.0 
-0400
+++ 13-ub-caller-change/drivers/block/ub.c  2007-09-10 18:04:31.0 
-0400
@@ -814,8 +814,8 @@ static void ub_end_rq(struct request *rq
uptodate = 0;
rq-errors = scsi_status;
}
-   end_that_request_first(rq, uptodate, rq-hard_nr_sectors);
-   end_that_request_last(rq, uptodate);
+   if (__blk_end_request(rq, uptodate, blk_rq_size(rq)))
+   BUG();
 }
 
 static int ub_rw_cmd_retry(struct ub_dev *sc, struct ub_lun *lun,
-
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 14/27] blk_end_request: changing viodasd (take 2)

2007-09-11 Thread Kiyoshi Ueda
This patch converts viodasd to use blk_end_request().

Signed-off-by: Kiyoshi Ueda [EMAIL PROTECTED]
Signed-off-by: Jun'ichi Nomura [EMAIL PROTECTED]
---
 drivers/block/viodasd.c |5 +
 1 files changed, 1 insertion(+), 4 deletions(-)

diff -rupN 13-ub-caller-change/drivers/block/viodasd.c 
14-viodasd-caller-change/drivers/block/viodasd.c
--- 13-ub-caller-change/drivers/block/viodasd.c 2007-08-27 21:32:35.0 
-0400
+++ 14-viodasd-caller-change/drivers/block/viodasd.c2007-09-10 
18:05:02.0 -0400
@@ -275,10 +275,7 @@ static struct block_device_operations vi
 static void viodasd_end_request(struct request *req, int uptodate,
int num_sectors)
 {
-   if (end_that_request_first(req, uptodate, num_sectors))
-   return;
-   add_disk_randomness(req-rq_disk);
-   end_that_request_last(req, uptodate);
+   __blk_end_request(req, uptodate, num_sectors  9);
 }
 
 /*
-
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 16/27] blk_end_request: changing viocd (take 2)

2007-09-11 Thread Kiyoshi Ueda
This patch converts viocd to use blk_end_request().

Signed-off-by: Kiyoshi Ueda [EMAIL PROTECTED]
Signed-off-by: Jun'ichi Nomura [EMAIL PROTECTED]
---
 drivers/cdrom/viocd.c |5 +
 1 files changed, 1 insertion(+), 4 deletions(-)

diff -rupN 15-xen-caller-change/drivers/cdrom/viocd.c 
16-viocd-caller-change/drivers/cdrom/viocd.c
--- 15-xen-caller-change/drivers/cdrom/viocd.c  2007-08-27 21:32:35.0 
-0400
+++ 16-viocd-caller-change/drivers/cdrom/viocd.c2007-09-10 
18:06:02.0 -0400
@@ -389,11 +389,8 @@ static void viocd_end_request(struct req
if (!nsectors)
nsectors = 1;
 
-   if (end_that_request_first(req, uptodate, nsectors))
+   if (__blk_end_request(req, uptodate, nsectors  9))
BUG();
-   add_disk_randomness(req-rq_disk);
-   blkdev_dequeue_request(req);
-   end_that_request_last(req, uptodate);
 }
 
 static int rwreq;
-
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 17/27] blk_end_request: changing i2o_block (take 2)

2007-09-11 Thread Kiyoshi Ueda
This patch converts i2o_block to use blk_end_request().

Signed-off-by: Kiyoshi Ueda [EMAIL PROTECTED]
Signed-off-by: Jun'ichi Nomura [EMAIL PROTECTED]
---
 drivers/message/i2o/i2o_block.c |8 ++--
 1 files changed, 2 insertions(+), 6 deletions(-)

diff -rupN 16-viocd-caller-change/drivers/message/i2o/i2o_block.c 
17-i2o-caller-change/drivers/message/i2o/i2o_block.c
--- 16-viocd-caller-change/drivers/message/i2o/i2o_block.c  2007-09-10 
17:32:13.0 -0400
+++ 17-i2o-caller-change/drivers/message/i2o/i2o_block.c2007-09-10 
18:08:24.0 -0400
@@ -425,22 +425,18 @@ static void i2o_block_end_request(struct
struct request_queue *q = req-q;
unsigned long flags;
 
-   if (end_that_request_chunk(req, uptodate, nr_bytes)) {
+   if (blk_end_request(req, uptodate, nr_bytes)) {
int leftover = (req-hard_nr_sectors  KERNEL_SECTOR_SHIFT);
 
if (blk_pc_request(req))
leftover = req-data_len;
 
if (end_io_error(uptodate))
-   end_that_request_chunk(req, 0, leftover);
+   blk_end_request(req, 0, leftover);
}
 
-   add_disk_randomness(req-rq_disk);
-
spin_lock_irqsave(q-queue_lock, flags);
 
-   end_that_request_last(req, uptodate);
-
if (likely(dev)) {
dev-open_queue_depth--;
list_del(ireq-queue);
-
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 18/27] blk_end_request: changing mmc (take 2)

2007-09-11 Thread Kiyoshi Ueda
This patch converts mmc to use blk_end_request().

Signed-off-by: Kiyoshi Ueda [EMAIL PROTECTED]
Signed-off-by: Jun'ichi Nomura [EMAIL PROTECTED]
---
 drivers/mmc/card/block.c |   24 +---
 drivers/mmc/card/queue.c |4 ++--
 2 files changed, 7 insertions(+), 21 deletions(-)

diff -rupN 17-i2o-caller-change/drivers/mmc/card/block.c 
18-mmc-caller-change/drivers/mmc/card/block.c
--- 17-i2o-caller-change/drivers/mmc/card/block.c   2007-09-10 
17:32:13.0 -0400
+++ 18-mmc-caller-change/drivers/mmc/card/block.c   2007-09-10 
18:08:53.0 -0400
@@ -336,15 +336,7 @@ static int mmc_blk_issue_rq(struct mmc_q
 * A block was successfully transferred.
 */
spin_lock_irq(md-lock);
-   ret = end_that_request_chunk(req, 1, brq.data.bytes_xfered);
-   if (!ret) {
-   /*
-* The whole request completed successfully.
-*/
-   add_disk_randomness(req-rq_disk);
-   blkdev_dequeue_request(req);
-   end_that_request_last(req, 1);
-   }
+   ret = __blk_end_request(req, 1, brq.data.bytes_xfered);
spin_unlock_irq(md-lock);
} while (ret);
 
@@ -374,27 +366,21 @@ static int mmc_blk_issue_rq(struct mmc_q
else
bytes = blocks  9;
spin_lock_irq(md-lock);
-   ret = end_that_request_chunk(req, 1, bytes);
+   ret = __blk_end_request(req, 1, bytes);
spin_unlock_irq(md-lock);
}
} else if (rq_data_dir(req) != READ 
   (card-host-caps  MMC_CAP_MULTIWRITE)) {
spin_lock_irq(md-lock);
-   ret = end_that_request_chunk(req, 1, brq.data.bytes_xfered);
+   ret = __blk_end_request(req, 1, brq.data.bytes_xfered);
spin_unlock_irq(md-lock);
}
 
mmc_release_host(card-host);
 
spin_lock_irq(md-lock);
-   while (ret) {
-   ret = end_that_request_chunk(req, 0,
-   req-current_nr_sectors  9);
-   }
-
-   add_disk_randomness(req-rq_disk);
-   blkdev_dequeue_request(req);
-   end_that_request_last(req, 0);
+   while (ret)
+   ret = __blk_end_request(req, 0, blk_rq_cur_size(req));
spin_unlock_irq(md-lock);
 
return 0;
diff -rupN 17-i2o-caller-change/drivers/mmc/card/queue.c 
18-mmc-caller-change/drivers/mmc/card/queue.c
--- 17-i2o-caller-change/drivers/mmc/card/queue.c   2007-08-27 
21:32:35.0 -0400
+++ 18-mmc-caller-change/drivers/mmc/card/queue.c   2007-09-10 
18:08:53.0 -0400
@@ -93,8 +93,8 @@ static void mmc_request(struct request_q
printk(KERN_ERR MMC: killing requests for dead queue\n);
while ((req = elv_next_request(q)) != NULL) {
do {
-   ret = end_that_request_chunk(req, 0,
-   req-current_nr_sectors  9);
+   ret = __blk_end_request(req, 0,
+   blk_rq_cur_size(req));
} while (ret);
}
return;
-
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 19/27] blk_end_request: changing s390 (take 2)

2007-09-11 Thread Kiyoshi Ueda
This patch converts s390 to use blk_end_request().

Signed-off-by: Kiyoshi Ueda [EMAIL PROTECTED]
Signed-off-by: Jun'ichi Nomura [EMAIL PROTECTED]
---
 drivers/s390/block/dasd.c  |4 +---
 drivers/s390/char/tape_block.c |3 +--
 2 files changed, 2 insertions(+), 5 deletions(-)

diff -rupN 18-mmc-caller-change/drivers/s390/block/dasd.c 
19-s390-caller-change/drivers/s390/block/dasd.c
--- 18-mmc-caller-change/drivers/s390/block/dasd.c  2007-08-27 
21:32:35.0 -0400
+++ 19-s390-caller-change/drivers/s390/block/dasd.c 2007-09-10 
18:09:25.0 -0400
@@ -1080,10 +1080,8 @@ dasd_int_handler(struct ccw_device *cdev
 static inline void
 dasd_end_request(struct request *req, int uptodate)
 {
-   if (end_that_request_first(req, uptodate, req-hard_nr_sectors))
+   if (__blk_end_request(req, uptodate, blk_rq_size(req)))
BUG();
-   add_disk_randomness(req-rq_disk);
-   end_that_request_last(req, uptodate);
 }
 
 /*
diff -rupN 18-mmc-caller-change/drivers/s390/char/tape_block.c 
19-s390-caller-change/drivers/s390/char/tape_block.c
--- 18-mmc-caller-change/drivers/s390/char/tape_block.c 2007-08-27 
21:32:35.0 -0400
+++ 19-s390-caller-change/drivers/s390/char/tape_block.c2007-09-10 
18:09:25.0 -0400
@@ -76,9 +76,8 @@ tapeblock_trigger_requeue(struct tape_de
 static void
 tapeblock_end_request(struct request *req, int uptodate)
 {
-   if (end_that_request_first(req, uptodate, req-hard_nr_sectors))
+   if (__blk_end_request(req, uptodate, blk_rq_size(req)))
BUG();
-   end_that_request_last(req, uptodate);
 }
 
 static void
-
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 20/27] blk_end_request: changing scsi (take 2)

2007-09-11 Thread Kiyoshi Ueda
This patch converts scsi mid-layer to use blk_end_request().

Signed-off-by: Kiyoshi Ueda [EMAIL PROTECTED]
Signed-off-by: Jun'ichi Nomura [EMAIL PROTECTED]
---
 drivers/scsi/scsi_lib.c |   13 ++---
 1 files changed, 2 insertions(+), 11 deletions(-)

diff -rupN 19-s390-caller-change/drivers/scsi/scsi_lib.c 
20-scsi-mid-caller-change/drivers/scsi/scsi_lib.c
--- 19-s390-caller-change/drivers/scsi/scsi_lib.c   2007-09-10 
17:32:15.0 -0400
+++ 20-scsi-mid-caller-change/drivers/scsi/scsi_lib.c   2007-09-10 
18:11:55.0 -0400
@@ -655,13 +655,12 @@ static struct scsi_cmnd *scsi_end_reques
 {
struct request_queue *q = cmd-device-request_queue;
struct request *req = cmd-request;
-   unsigned long flags;
 
/*
 * If there are blocks left over at the end, set up the command
 * to queue the remainder of them.
 */
-   if (end_that_request_chunk(req, uptodate, bytes)) {
+   if (blk_end_request(req, uptodate, bytes)) {
int leftover = (req-hard_nr_sectors  9);
 
if (blk_pc_request(req))
@@ -669,7 +668,7 @@ static struct scsi_cmnd *scsi_end_reques
 
/* kill remainder if no retrys */
if (!uptodate  blk_noretry_request(req))
-   end_that_request_chunk(req, 0, leftover);
+   blk_end_request(req, 0, leftover);
else {
if (requeue) {
/*
@@ -684,14 +683,6 @@ static struct scsi_cmnd *scsi_end_reques
}
}
 
-   add_disk_randomness(req-rq_disk);
-
-   spin_lock_irqsave(q-queue_lock, flags);
-   if (blk_rq_tagged(req))
-   blk_queue_end_tag(q, req);
-   end_that_request_last(req, uptodate);
-   spin_unlock_irqrestore(q-queue_lock, flags);
-
/*
 * This will goose the queue request function at the end, so we don't
 * need to worry about launching another command.
-
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 21/27] blk_end_request: changing ide-scsi (take 2)

2007-09-11 Thread Kiyoshi Ueda
This patch converts ide-scsi to use blk_end_request().

Signed-off-by: Kiyoshi Ueda [EMAIL PROTECTED]
Signed-off-by: Jun'ichi Nomura [EMAIL PROTECTED]
---
 drivers/scsi/ide-scsi.c |8 
 1 files changed, 4 insertions(+), 4 deletions(-)

diff -rupN 20-scsi-mid-caller-change/drivers/scsi/ide-scsi.c 
21-ide-scsi-caller-change/drivers/scsi/ide-scsi.c
--- 20-scsi-mid-caller-change/drivers/scsi/ide-scsi.c   2007-09-10 
17:32:15.0 -0400
+++ 21-ide-scsi-caller-change/drivers/scsi/ide-scsi.c   2007-09-10 
18:13:51.0 -0400
@@ -1042,8 +1042,8 @@ static int idescsi_eh_reset (struct scsi
}
 
/* kill current request */
-   blkdev_dequeue_request(req);
-   end_that_request_last(req, 0);
+   if (__blk_end_request(req, 0, 0))
+   BUG();
if (blk_sense_request(req))
kfree(scsi-pc-buffer);
kfree(scsi-pc);
@@ -1052,8 +1052,8 @@ static int idescsi_eh_reset (struct scsi
 
/* now nuke the drive queue */
while ((req = elv_next_request(drive-queue))) {
-   blkdev_dequeue_request(req);
-   end_that_request_last(req, 0);
+   if (__blk_end_request(req, 0, 0))
+   BUG();
}
 
HWGROUP(drive)-rq = NULL;
-
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 22/27] blk_end_request: changing xsysace (take 2)

2007-09-11 Thread Kiyoshi Ueda
This patch converts xsysace to use blk_end_request().

xsysace is a little bit different from normal drivers.
xsysace driver has a state machine in it.
It calls end_that_request_first() and end_that_request_last()
from different states. (ACE_FSM_STATE_REQ_TRANSFER and
ACE_FSM_STATE_REQ_COMPLETE, respectively.)

However, those states are consecutive and without any interruption
inbetween.
So we can just follow the standard conversion rule (b) mentioned in
the patch subject [PATCH 01/27] blk_end_request: add new request
completion interface.

Signed-off-by: Kiyoshi Ueda [EMAIL PROTECTED]
Signed-off-by: Jun'ichi Nomura [EMAIL PROTECTED]
---
 drivers/block/xsysace.c |5 +
 1 files changed, 1 insertion(+), 4 deletions(-)

diff -rupN 21-ide-scsi-caller-change/drivers/block/xsysace.c 
22-xsysace-caller-change/drivers/block/xsysace.c
--- 21-ide-scsi-caller-change/drivers/block/xsysace.c   2007-09-10 
17:32:11.0 -0400
+++ 22-xsysace-caller-change/drivers/block/xsysace.c2007-09-10 
18:14:20.0 -0400
@@ -696,7 +696,7 @@ static void ace_fsm_dostate(struct ace_d
 
/* bio finished; is there another one? */
i = ace-req-current_nr_sectors;
-   if (end_that_request_first(ace-req, 1, i)) {
+   if (__blk_end_request(ace-req, 1, i)) {
/* dev_dbg(ace-dev, next block; h=%li c=%i\n,
 *  ace-req-hard_nr_sectors,
 *  ace-req-current_nr_sectors);
@@ -711,9 +711,6 @@ static void ace_fsm_dostate(struct ace_d
break;
 
case ACE_FSM_STATE_REQ_COMPLETE:
-   /* Complete the block request */
-   blkdev_dequeue_request(ace-req);
-   end_that_request_last(ace-req, 1);
ace-req = NULL;
 
/* Finished request; go to idle state */
-
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 24/27] blk_end_request: changing cpqarray (take 2)

2007-09-11 Thread Kiyoshi Ueda
This patch converts cpqarray to use blk_end_request().

cpqarray is a little bit different from normal drivers.
cpqarray directly calls bio_endio() and disk_stat_add()
when completing request.  But those can be replaced with
__end_that_request_first().
After the replacement, request completion procedures of
those drivers become like the following:
o end_that_request_first()
o add_disk_randomness()
o end_that_request_last()
This can be converted to blk_end_request() by following
the rule (b) mentioned in the patch subject
[PATCH 01/27] blk_end_request: add new request completion interface.

Signed-off-by: Kiyoshi Ueda [EMAIL PROTECTED]
Signed-off-by: Jun'ichi Nomura [EMAIL PROTECTED]
---
 drivers/block/cpqarray.c |   28 ++--
 1 files changed, 2 insertions(+), 26 deletions(-)

diff -rupN 23-cciss-caller-change/drivers/block/cpqarray.c 
24-cpqarray-caller-change/drivers/block/cpqarray.c
--- 23-cciss-caller-change/drivers/block/cpqarray.c 2007-08-27 
21:32:35.0 -0400
+++ 24-cpqarray-caller-change/drivers/block/cpqarray.c  2007-09-10 
18:17:03.0 -0400
@@ -166,7 +166,6 @@ static void start_io(ctlr_info_t *h);
 
 static inline void addQ(cmdlist_t **Qptr, cmdlist_t *c);
 static inline cmdlist_t *removeQ(cmdlist_t **Qptr, cmdlist_t *c);
-static inline void complete_buffers(struct bio *bio, int ok);
 static inline void complete_command(cmdlist_t *cmd, int timeout);
 
 static irqreturn_t do_ida_intr(int irq, void *dev_id);
@@ -978,20 +977,6 @@ static void start_io(ctlr_info_t *h)
}
 }
 
-static inline void complete_buffers(struct bio *bio, int ok)
-{
-   struct bio *xbh;
-   while(bio) {
-   int nr_sectors = bio_sectors(bio);
-
-   xbh = bio-bi_next;
-   bio-bi_next = NULL;
-   
-   bio_endio(bio, nr_sectors  9, ok ? 0 : -EIO);
-
-   bio = xbh;
-   }
-}
 /*
  * Mark all buffers that cmd was responsible for
  */
@@ -1029,18 +1014,9 @@ static inline void complete_command(cmdl
 pci_unmap_page(hba[cmd-ctlr]-pci_dev, cmd-req.sg[i].addr,
cmd-req.sg[i].size, ddir);
 
-   complete_buffers(rq-bio, ok);
-
-   if (blk_fs_request(rq)) {
-   const int rw = rq_data_dir(rq);
-
-   disk_stat_add(rq-rq_disk, sectors[rw], rq-nr_sectors);
-   }
-
-   add_disk_randomness(rq-rq_disk);
-
DBGPX(printk(Done with %p\n, rq););
-   end_that_request_last(rq, ok ? 1 : -EIO);
+   if (__blk_end_request(rq, ok, blk_rq_size(rq)))
+   BUG();
 }
 
 /*
-
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 23/27] blk_end_request: changing cciss (take 2)

2007-09-11 Thread Kiyoshi Ueda
This patch converts cciss to use blk_end_request().

cciss is a little bit different from normal drivers.
cciss directly calls bio_endio() and disk_stat_add()
when completing request.  But those can be replaced with
__end_that_request_first().
After the replacement, request completion procedures of
those drivers become like the following:
o end_that_request_first()
o add_disk_randomness()
o end_that_request_last()
This can be converted to blk_end_request() by following
the rule (a) mentioned in the patch subject
[PATCH 01/27] blk_end_request: add new request completion interface.

Signed-off-by: Kiyoshi Ueda [EMAIL PROTECTED]
Signed-off-by: Jun'ichi Nomura [EMAIL PROTECTED]
---
 drivers/block/cciss.c |   26 +++---
 1 files changed, 3 insertions(+), 23 deletions(-)

diff -rupN 22-xsysace-caller-change/drivers/block/cciss.c 
23-cciss-caller-change/drivers/block/cciss.c
--- 22-xsysace-caller-change/drivers/block/cciss.c  2007-09-10 
17:32:11.0 -0400
+++ 23-cciss-caller-change/drivers/block/cciss.c2007-09-10 
18:16:34.0 -0400
@@ -1187,18 +1187,6 @@ static int cciss_ioctl(struct inode *ino
}
 }
 
-static inline void complete_buffers(struct bio *bio, int status)
-{
-   while (bio) {
-   struct bio *xbh = bio-bi_next;
-   int nr_sectors = bio_sectors(bio);
-
-   bio-bi_next = NULL;
-   bio_endio(bio, nr_sectors  9, status ? 0 : -EIO);
-   bio = xbh;
-   }
-}
-
 static void cciss_check_queues(ctlr_info_t *h)
 {
int start_queue = h-next_to_run;
@@ -1264,21 +1252,14 @@ static void cciss_softirq_done(struct re
pci_unmap_page(h-pdev, temp64.val, cmd-SG[i].Len, ddir);
}
 
-   complete_buffers(rq-bio, (rq-errors == 0));
-
-   if (blk_fs_request(rq)) {
-   const int rw = rq_data_dir(rq);
-
-   disk_stat_add(rq-rq_disk, sectors[rw], rq-nr_sectors);
-   }
-
 #ifdef CCISS_DEBUG
printk(Done with %p\n, rq);
 #endif /* CCISS_DEBUG */
 
-   add_disk_randomness(rq-rq_disk);
+   if (blk_end_request(rq, (rq-errors == 0), blk_rq_size(rq)))
+   BUG();
+
spin_lock_irqsave(h-lock, flags);
-   end_that_request_last(rq, (rq-errors == 0));
cmd_free(h, cmd, 1);
cciss_check_queues(h);
spin_unlock_irqrestore(h-lock, flags);
@@ -2545,7 +2526,6 @@ after_error_processing:
}
cmd-rq-data_len = 0;
cmd-rq-completion_data = cmd;
-   blk_add_trace_rq(cmd-rq-q, cmd-rq, BLK_TA_COMPLETE);
blk_complete_request(cmd-rq);
 }
 
-
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 25/27] blk_end_request: changing ide normal caller (take 2)

2007-09-11 Thread Kiyoshi Ueda
This patch converts normal parts of ide to use blk_end_request().

Signed-off-by: Kiyoshi Ueda [EMAIL PROTECTED]
Signed-off-by: Jun'ichi Nomura [EMAIL PROTECTED]
---
 drivers/ide/ide-cd.c |6 +++---
 drivers/ide/ide-io.c |   22 +++---
 2 files changed, 10 insertions(+), 18 deletions(-)

diff -rupN 24-cpqarray-caller-change/drivers/ide/ide-cd.c 
25-ide-normal-caller-change/drivers/ide/ide-cd.c
--- 24-cpqarray-caller-change/drivers/ide/ide-cd.c  2007-08-27 
21:32:35.0 -0400
+++ 25-ide-normal-caller-change/drivers/ide/ide-cd.c2007-09-10 
18:17:38.0 -0400
@@ -655,9 +655,9 @@ static void cdrom_end_request (ide_drive
BUG();
} else {
spin_lock_irqsave(ide_lock, flags);
-   end_that_request_chunk(failed, 0,
-   failed-data_len);
-   end_that_request_last(failed, 0);
+   if (__blk_end_request(failed, 0,
+ failed-data_len))
+   BUG();
spin_unlock_irqrestore(ide_lock, flags);
}
} else
diff -rupN 24-cpqarray-caller-change/drivers/ide/ide-io.c 
25-ide-normal-caller-change/drivers/ide/ide-io.c
--- 24-cpqarray-caller-change/drivers/ide/ide-io.c  2007-09-10 
17:32:12.0 -0400
+++ 25-ide-normal-caller-change/drivers/ide/ide-io.c2007-09-10 
18:17:38.0 -0400
@@ -78,12 +78,8 @@ static int __ide_end_request(ide_drive_t
HWGROUP(drive)-hwif-ide_dma_on(drive);
}
 
-   if (!end_that_request_chunk(rq, uptodate, nr_bytes)) {
-   add_disk_randomness(rq-rq_disk);
-   if (!list_empty(rq-queuelist))
-   blkdev_dequeue_request(rq);
+   if (!__blk_end_request(rq, uptodate, nr_bytes)) {
HWGROUP(drive)-rq = NULL;
-   end_that_request_last(rq, uptodate);
ret = 0;
}
 
@@ -280,13 +276,9 @@ int ide_end_dequeued_request(ide_drive_t
HWGROUP(drive)-hwif-ide_dma_on(drive);
}
 
-   if (!end_that_request_first(rq, uptodate, nr_sectors)) {
-   add_disk_randomness(rq-rq_disk);
-   if (blk_rq_tagged(rq))
-   blk_queue_end_tag(drive-queue, rq);
-   end_that_request_last(rq, uptodate);
+   if (!__blk_end_request(rq, uptodate, nr_sectors  9))
ret = 0;
-   }
+
spin_unlock_irqrestore(ide_lock, flags);
return ret;
 }
@@ -316,9 +308,9 @@ static void ide_complete_pm_request (ide
drive-blocked = 0;
blk_start_queue(drive-queue);
}
-   blkdev_dequeue_request(rq);
HWGROUP(drive)-rq = NULL;
-   end_that_request_last(rq, 1);
+   if (__blk_end_request(rq, 1, 0))
+   BUG();
spin_unlock_irqrestore(ide_lock, flags);
 }
 
@@ -448,10 +440,10 @@ void ide_end_drive_cmd (ide_drive_t *dri
}
 
spin_lock_irqsave(ide_lock, flags);
-   blkdev_dequeue_request(rq);
HWGROUP(drive)-rq = NULL;
rq-errors = err;
-   end_that_request_last(rq, !rq-errors);
+   if (__blk_end_request(rq, !rq-errors, 0))
+   BUG();
spin_unlock_irqrestore(ide_lock, flags);
 }
 
-
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: sata scsi suggestion for make menuconfig

2007-09-11 Thread Bauke Jan Douma

Andi Kleen wrote on 09-09-07 23:22:



When it costs 1 people half an hour to learn and correct this it 
wasted 5000 hours of previous livetime.

 ^^   ^

Poor me. Here I am -- still waiting for my 15 minutes of fame in /this/ life...

;-)

bjd


-
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[patchset 0/24] Lots of the Accessors patches and !use_sg cleanup

2007-09-11 Thread Boaz Harrosh
Here are more accessors patches. I have tried
to find Maintainers of drivers but please help me if
I missed any.

After this there are 3 drivers left (I think)
- gdth.c, pluto.c, seagate.c
These I'll send only next week in a set of their own.
{Please tell me I can kill pluto and seagate.}

Some of the drivers that are not here were already posted by Tomo.
Some of the drivers here were posted before but these are better
versions of them.

[USB] - Greg Kroah-Hartman [EMAIL PROTECTED], Alan Stern [EMAIL PROTECTED],
Matthew Dharm [EMAIL PROTECTED]
0001-   drivers/usb/storage/transport.c drivers/usb/storage/transport.h
0002-   drivers/usb/storage/protocol.c
0003-   drivers/usb/storage/shuttle_usbat.c
0004-   drivers/usb/storage/freecom.c drivers/usb/storage/sddr09.c
0005drivers/usb/storage/isd200.c

[NCR5380 family] - ?
0006drivers/scsi/NCR5380.c drivers/scsi/atari_NCR5380.c
drivers/scsi/sun3_NCR5380.c

[esp family] - Maciej W. Rozycki [EMAIL PROTECTED]
0020drivers/scsi/NCR53C9x.c drivers/scsi/NCR53C9x.h
drivers/scsi/dec_esp.c drivers/scsi/oktagon_esp.c
drivers/scsi/sun3x_esp.c

[ARM] - Russell King [EMAIL PROTECTED]
0007drivers/scsi/arm/acornscsi.c drivers/scsi/arm/scsi.h

[other drivers]
0008drivers/scsi/pcmcia/nsp_cs.c - YOKOTA Hiroshi [EMAIL PROTECTED]
0009drivers/ata/libata-scsi.c - Jeff Garzik [EMAIL PROTECTED]
0010drivers/scsi/eata_pio.c - Bartlomiej Zolnierkiewicz [EMAIL PROTECTED] 
?
0011drivers/scsi/a2091.c - ?
0012drivers/scsi/a3000.c - ? 
0013drivers/scsi/aha1542.c - ? 
0014drivers/scsi/atp870u.c - ? 
0015drivers/scsi/fd_mcs.c - ? 
0016drivers/scsi/imm.c - ? 
0017drivers/scsi/in2000.c - ? 
0018drivers/scsi/ppa.c - ? 
0019drivers/scsi/wd33c93.c - ? 
0021drivers/scsi/qlogicpti.c - David S. Miller [EMAIL PROTECTED], Mark 
Fortescue [EMAIL PROTECTED]
0024drivers/scsi/ide-scsi.c - Bartlomiej Zolnierkiewicz [EMAIL PROTECTED]

[remove psi240i.c driver] - ?
0022drivers/scsi/Kconfig drivers/scsi/Makefile   
delete drivers/scsi/psi240i.c
delete drivers/scsi/psi240i.h
delete drivers/scsi/psi_chip.h

[fixes]
0023drivers/scsi/wd7000.c - ? 
-
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


RE: [patchset 0/24] Lots of the Accessors patches and !use_sg cleanup

2007-09-11 Thread Cameron, Steve

Boaz Harrosh wrote:

 Here are more accessors patches. I have tried
 to find Maintainers of drivers but please help me if
 I missed any.

The cciss tape drive code probably needs updating.

It's in drivers/block/cciss_scsi.c

-- steve











-
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [patchset 0/24] Lots of the Accessors patches and !use_sg cleanup

2007-09-11 Thread Boaz Harrosh
On Tue, Sep 11 2007 at 23:50 +0300, Cameron, Steve [EMAIL PROTECTED] wrote:
 drivers/block/cciss_scsi.c

Already done by Tomo
41ce639a1c50cb936f058f52f99f65740e3f550e 
  cciss: convert to use the data buffer accessors
-
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 02/24] usb: protocol.c - convert to accessors and !use_sg code path removal

2007-09-11 Thread Boaz Harrosh

 - Use scsi data accessors and remove of !use_sg code path

Signed-off-by: Boaz Harrosh [EMAIL PROTECTED]
---
 drivers/usb/storage/protocol.c |  120 ---
 1 files changed, 49 insertions(+), 71 deletions(-)

diff --git a/drivers/usb/storage/protocol.c b/drivers/usb/storage/protocol.c
index 9ad3042..e9fc873 100644
--- a/drivers/usb/storage/protocol.c
+++ b/drivers/usb/storage/protocol.c
@@ -149,10 +149,6 @@ void usb_stor_transparent_scsi_command(struct scsi_cmnd 
*srb,
  ***/
 
 /* Copy a buffer of length buflen to/from the srb's transfer buffer.
- * (Note: for scatter-gather transfers (srb-use_sg  0), srb-request_buffer
- * points to a list of s-g entries and we ignore srb-request_bufflen.
- * For non-scatter-gather transfers, srb-request_buffer points to the
- * transfer buffer itself and srb-request_bufflen is the buffer's length.)
  * Update the *index and *offset variables so that the next copy will
  * pick up from where this one left off. */
 
@@ -162,77 +158,59 @@ unsigned int usb_stor_access_xfer_buf(unsigned char 
*buffer,
 {
unsigned int cnt;
 
-   /* If not using scatter-gather, just transfer the data directly.
-* Make certain it will fit in the available buffer space. */
-   if (srb-use_sg == 0) {
-   if (*offset = srb-request_bufflen)
-   return 0;
-   cnt = min(buflen, srb-request_bufflen - *offset);
-   if (dir == TO_XFER_BUF)
-   memcpy((unsigned char *) srb-request_buffer + *offset,
-   buffer, cnt);
-   else
-   memcpy(buffer, (unsigned char *) srb-request_buffer +
-   *offset, cnt);
-   *offset += cnt;
-
-   /* Using scatter-gather.  We have to go through the list one entry
+   /* We have to go through the list one entry
 * at a time.  Each s-g entry contains some number of pages, and
 * each page has to be kmap()'ed separately.  If the page is already
 * in kernel-addressable memory then kmap() will return its address.
 * If the page is not directly accessible -- such as a user buffer
 * located in high memory -- then kmap() will map it to a temporary
 * position in the kernel's virtual address space. */
-   } else {
-   struct scatterlist *sg =
-   (struct scatterlist *) srb-request_buffer
-   + *index;
-
-   /* This loop handles a single s-g list entry, which may
-* include multiple pages.  Find the initial page structure
-* and the starting offset within the page, and update
-* the *offset and *index values for the next loop. */
-   cnt = 0;
-   while (cnt  buflen  *index  srb-use_sg) {
-   struct page *page = sg-page +
-   ((sg-offset + *offset)  PAGE_SHIFT);
-   unsigned int poff =
-   (sg-offset + *offset)  (PAGE_SIZE-1);
-   unsigned int sglen = sg-length - *offset;
-
-   if (sglen  buflen - cnt) {
-
-   /* Transfer ends within this s-g entry */
-   sglen = buflen - cnt;
-   *offset += sglen;
-   } else {
-
-   /* Transfer continues to next s-g entry */
-   *offset = 0;
-   ++*index;
-   ++sg;
-   }
-
-   /* Transfer the data for all the pages in this
-* s-g entry.  For each page: call kmap(), do the
-* transfer, and call kunmap() immediately after. */
-   while (sglen  0) {
-   unsigned int plen = min(sglen, (unsigned int)
-   PAGE_SIZE - poff);
-   unsigned char *ptr = kmap(page);
-
-   if (dir == TO_XFER_BUF)
-   memcpy(ptr + poff, buffer + cnt, plen);
-   else
-   memcpy(buffer + cnt, ptr + poff, plen);
-   kunmap(page);
-
-   /* Start at the beginning of the next page */
-   poff = 0;
-   ++page;
-   cnt += plen;
-   sglen -= plen;
-   }
+   struct scatterlist *sg = scsi_sglist(srb) + *index;
+
+   /* This loop handles a single s-g list entry, which may
+* 

[PATCH 03/24] usb: shuttle_usbat.c - convert to accessors and !use_sg code path removal

2007-09-11 Thread Boaz Harrosh

 - functions that received char* but where passed scatterlist* mostly
   were changed to receive void*
 - Use scsi data accessors and remove of !use_sg code path

Signed-off-by: Boaz Harrosh [EMAIL PROTECTED]
---
 drivers/usb/storage/shuttle_usbat.c |   68 +-
 1 files changed, 26 insertions(+), 42 deletions(-)

diff --git a/drivers/usb/storage/shuttle_usbat.c 
b/drivers/usb/storage/shuttle_usbat.c
index 5e27297..1cc1fcf 100644
--- a/drivers/usb/storage/shuttle_usbat.c
+++ b/drivers/usb/storage/shuttle_usbat.c
@@ -130,7 +130,7 @@ static int usbat_write(struct us_data *us,
  * Convenience function to perform a bulk read
  */
 static int usbat_bulk_read(struct us_data *us,
-  unsigned char *data,
+  void* buf,
   unsigned int len,
   int use_sg)
 {
@@ -138,14 +138,14 @@ static int usbat_bulk_read(struct us_data *us,
return USB_STOR_XFER_GOOD;
 
US_DEBUGP(usbat_bulk_read: len = %d\n, len);
-   return usb_stor_bulk_transfer_sg(us, us-recv_bulk_pipe, data, len, 
use_sg, NULL);
+   return usb_stor_bulk_transfer_sg(us, us-recv_bulk_pipe, buf, len, 
use_sg, NULL);
 }
 
 /*
  * Convenience function to perform a bulk write
  */
 static int usbat_bulk_write(struct us_data *us,
-   unsigned char *data,
+   void* buf,
unsigned int len,
int use_sg)
 {
@@ -153,7 +153,7 @@ static int usbat_bulk_write(struct us_data *us,
return USB_STOR_XFER_GOOD;
 
US_DEBUGP(usbat_bulk_write:  len = %d\n, len);
-   return usb_stor_bulk_transfer_sg(us, us-send_bulk_pipe, data, len, 
use_sg, NULL);
+   return usb_stor_bulk_transfer_sg(us, us-send_bulk_pipe, buf, len, 
use_sg, NULL);
 }
 
 /*
@@ -317,7 +317,7 @@ static int usbat_wait_not_busy(struct us_data *us, int 
minutes)
  * Read block data from the data register
  */
 static int usbat_read_block(struct us_data *us,
-   unsigned char *content,
+   void* buf,
unsigned short len,
int use_sg)
 {
@@ -340,7 +340,7 @@ static int usbat_read_block(struct us_data *us,
if (result != USB_STOR_XFER_GOOD)
return USB_STOR_TRANSPORT_ERROR;
 
-   result = usbat_bulk_read(us, content, len, use_sg);
+   result = usbat_bulk_read(us, buf, len, use_sg);
return (result == USB_STOR_XFER_GOOD ?
USB_STOR_TRANSPORT_GOOD : USB_STOR_TRANSPORT_ERROR);
 }
@@ -350,7 +350,7 @@ static int usbat_read_block(struct us_data *us,
  */
 static int usbat_write_block(struct us_data *us,
 unsigned char access,
-unsigned char *content,
+void* buf,
 unsigned short len,
 int minutes,
 int use_sg)
@@ -375,7 +375,7 @@ static int usbat_write_block(struct us_data *us,
if (result != USB_STOR_XFER_GOOD)
return USB_STOR_TRANSPORT_ERROR;
 
-   result = usbat_bulk_write(us, content, len, use_sg);
+   result = usbat_bulk_write(us, buf, len, use_sg);
if (result != USB_STOR_XFER_GOOD)
return USB_STOR_TRANSPORT_ERROR;
 
@@ -395,7 +395,7 @@ static int usbat_hp8200e_rw_block_test(struct us_data *us,
   unsigned char timeout,
   unsigned char qualifier,
   int direction,
-  unsigned char *content,
+  void *buf,
   unsigned short len,
   int use_sg,
   int minutes)
@@ -475,7 +475,7 @@ static int usbat_hp8200e_rw_block_test(struct us_data *us,
}
 
result = usb_stor_bulk_transfer_sg(us,
-   pipe, content, len, use_sg, NULL);
+   pipe, buf, len, use_sg, NULL);
 
/*
 * If we get a stall on the bulk download, we'll retry
@@ -609,7 +609,7 @@ static int usbat_multiple_write(struct us_data *us,
  * other related details) are defined beforehand with _set_shuttle_features().
  */
 static int usbat_read_blocks(struct us_data *us,
-unsigned char *buffer,
+void* buffer,
 int len,
 int use_sg)
 {
@@ -651,7 +651,7 @@ static int usbat_read_blocks(struct us_data *us,
  * other related details) are defined beforehand with _set_shuttle_features().
  */
 static int usbat_write_blocks(struct us_data *us,
- unsigned char *buffer,
+  

[PATCH 04/24] usb: freecom.c sddr09.c - convert to accessors and !use_sg cleanup

2007-09-11 Thread Boaz Harrosh

 - Use scsi data accessors and remove of !use_sg code path
 - This patch is dependent on cleanup patch to usb transport.c/h

Signed-off-by: Boaz Harrosh [EMAIL PROTECTED]
---
 drivers/usb/storage/freecom.c |   14 ++
 drivers/usb/storage/sddr09.c  |9 +++--
 2 files changed, 9 insertions(+), 14 deletions(-)

diff --git a/drivers/usb/storage/freecom.c b/drivers/usb/storage/freecom.c
index 88aa59a..f5a4e8d 100644
--- a/drivers/usb/storage/freecom.c
+++ b/drivers/usb/storage/freecom.c
@@ -132,8 +132,7 @@ freecom_readdata (struct scsi_cmnd *srb, struct us_data *us,
 
/* Now transfer all of our blocks. */
US_DEBUGP(Start of read\n);
-   result = usb_stor_bulk_transfer_sg(us, ipipe, srb-request_buffer,
-   count, srb-use_sg, srb-resid);
+   result = usb_stor_bulk_srb(us, ipipe, srb);
US_DEBUGP(freecom_readdata done!\n);
 
if (result  USB_STOR_XFER_SHORT)
@@ -166,8 +165,7 @@ freecom_writedata (struct scsi_cmnd *srb, struct us_data 
*us,
 
/* Now transfer all of our blocks. */
US_DEBUGP(Start of write\n);
-   result = usb_stor_bulk_transfer_sg(us, opipe, srb-request_buffer,
-   count, srb-use_sg, srb-resid);
+   result = usb_stor_bulk_srb(us, opipe, srb);
 
US_DEBUGP(freecom_writedata done!\n);
if (result  USB_STOR_XFER_SHORT)
@@ -281,7 +279,7 @@ int freecom_transport(struct scsi_cmnd *srb, struct us_data 
*us)
 * and such will hang. */
US_DEBUGP(Device indicates that it has %d bytes available\n,
le16_to_cpu (fst-Count));
-   US_DEBUGP(SCSI requested %d\n, srb-request_bufflen);
+   US_DEBUGP(SCSI requested %d\n, scsi_bufflen(srb));
 
/* Find the length we desire to read. */
switch (srb-cmnd[0]) {
@@ -292,12 +290,12 @@ int freecom_transport(struct scsi_cmnd *srb, struct 
us_data *us)
length = le16_to_cpu(fst-Count);
break;
default:
-   length = srb-request_bufflen;
+   length = scsi_bufflen(srb);
}
 
/* verify that this amount is legal */
-   if (length  srb-request_bufflen) {
-   length = srb-request_bufflen;
+   if (length  scsi_bufflen(srb)) {
+   length = scsi_bufflen(srb);
US_DEBUGP(Truncating request to match buffer length: %d\n, 
length);
}
 
diff --git a/drivers/usb/storage/sddr09.c b/drivers/usb/storage/sddr09.c
index b2ed2a3..bd69b75 100644
--- a/drivers/usb/storage/sddr09.c
+++ b/drivers/usb/storage/sddr09.c
@@ -1619,7 +1619,7 @@ int sddr09_transport(struct scsi_cmnd *srb, struct 
us_data *us)
return USB_STOR_TRANSPORT_ERROR;
}
 
-   if (srb-request_bufflen == 0)
+   if (scsi_bufflen(srb) == 0)
return USB_STOR_TRANSPORT_GOOD;
 
if (srb-sc_data_direction == DMA_TO_DEVICE ||
@@ -1630,12 +1630,9 @@ int sddr09_transport(struct scsi_cmnd *srb, struct 
us_data *us)
US_DEBUGP(SDDR09: %s %d bytes\n,
  (srb-sc_data_direction == DMA_TO_DEVICE) ?
  sending : receiving,
- srb-request_bufflen);
+ scsi_bufflen(srb));
 
-   result = usb_stor_bulk_transfer_sg(us, pipe,
-   srb-request_buffer,
-   srb-request_bufflen,
-   srb-use_sg, srb-resid);
+   result = usb_stor_bulk_srb(us, pipe, srb);
 
return (result == USB_STOR_XFER_GOOD ?
USB_STOR_TRANSPORT_GOOD : USB_STOR_TRANSPORT_ERROR);
-- 
1.5.3.1


-
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 01/24] usb: transport - convert to accessors and !use_sg code path removal

2007-09-11 Thread Boaz Harrosh

  - This patch depends on:
usb: transport.c use scsi_eh API in REQUEST_SENSE execution

  - Use scsi data accessors and remove of !use_sg code path.
  - New usb_stor_bulk_srb() for use by drivers

Signed-off-by: Boaz Harrosh [EMAIL PROTECTED]
---
 drivers/usb/storage/transport.c |   44 +++---
 drivers/usb/storage/transport.h |2 +
 2 files changed, 29 insertions(+), 17 deletions(-)

diff --git a/drivers/usb/storage/transport.c b/drivers/usb/storage/transport.c
index c646750..d3a84a2 100644
--- a/drivers/usb/storage/transport.c
+++ b/drivers/usb/storage/transport.c
@@ -459,6 +459,21 @@ static int usb_stor_bulk_transfer_sglist(struct us_data 
*us, unsigned int pipe,
 }
 
 /*
+ * Common used function. Transfer a complete command
+ * via usb_stor_bulk_transfer_sglist() above. Set cmnd resid
+ */
+int usb_stor_bulk_srb(struct us_data* us, unsigned int pipe,
+ struct scsi_cmnd* srb)
+{
+   int resid = scsi_get_resid(srb);
+   int result = usb_stor_bulk_transfer_sglist(us, pipe, scsi_sglist(srb),
+ scsi_sg_count(srb), scsi_bufflen(srb),
+ resid);
+   scsi_set_resid(srb, resid);
+   return result;
+}
+
+/*
  * Transfer an entire SCSI command's worth of data payload over the bulk
  * pipe.
  *
@@ -508,7 +523,7 @@ void usb_stor_invoke_transport(struct scsi_cmnd *srb, 
struct us_data *us)
int result;
 
/* send the command to the transport layer */
-   srb-resid = 0;
+   scsi_set_resid(srb, 0);
result = us-transport(srb, us);
 
/* if the command gets aborted by the higher layers, we need to
@@ -568,7 +583,7 @@ void usb_stor_invoke_transport(struct scsi_cmnd *srb, 
struct us_data *us)
 * A short transfer on a command where we don't expect it
 * is unusual, but it doesn't mean we need to auto-sense.
 */
-   if ((srb-resid  0) 
+   if ((scsi_get_resid(srb)  0) 
!((srb-cmnd[0] == REQUEST_SENSE) ||
  (srb-cmnd[0] == INQUIRY) ||
  (srb-cmnd[0] == MODE_SENSE) ||
@@ -593,7 +608,7 @@ void usb_stor_invoke_transport(struct scsi_cmnd *srb, 
struct us_data *us)
srb-cmd_len = 12;
 
/* issue the auto-sense command */
-   srb-resid = 0;
+   scsi_set_resid(srb, 0);
temp_result = us-transport(us-srb, us);
 
/* let's clean up right away */
@@ -649,7 +664,7 @@ void usb_stor_invoke_transport(struct scsi_cmnd *srb, 
struct us_data *us)
 
/* Did we transfer less than the minimum amount required? */
if (srb-result == SAM_STAT_GOOD 
-   srb-request_bufflen - srb-resid  srb-underflow)
+   scsi_bufflen(srb) - scsi_get_resid(srb)  
srb-underflow)
srb-result = (DID_ERROR  16) | (SUGGEST_RETRY  24);
 
return;
@@ -708,7 +723,7 @@ void usb_stor_stop_transport(struct us_data *us)
 
 int usb_stor_CBI_transport(struct scsi_cmnd *srb, struct us_data *us)
 {
-   unsigned int transfer_length = srb-request_bufflen;
+   unsigned int transfer_length = scsi_bufflen(srb);
unsigned int pipe = 0;
int result;
 
@@ -737,9 +752,7 @@ int usb_stor_CBI_transport(struct scsi_cmnd *srb, struct 
us_data *us)
if (transfer_length) {
pipe = srb-sc_data_direction == DMA_FROM_DEVICE ? 
us-recv_bulk_pipe : us-send_bulk_pipe;
-   result = usb_stor_bulk_transfer_sg(us, pipe,
-   srb-request_buffer, transfer_length,
-   srb-use_sg, srb-resid);
+   result = usb_stor_bulk_srb(us, pipe, srb);
US_DEBUGP(CBI data stage result is 0x%x\n, result);
 
/* if we stalled the data transfer it means command failed */
@@ -808,7 +821,7 @@ int usb_stor_CBI_transport(struct scsi_cmnd *srb, struct 
us_data *us)
  */
 int usb_stor_CB_transport(struct scsi_cmnd *srb, struct us_data *us)
 {
-   unsigned int transfer_length = srb-request_bufflen;
+   unsigned int transfer_length = scsi_bufflen(srb);
int result;
 
/* COMMAND STAGE */
@@ -836,9 +849,7 @@ int usb_stor_CB_transport(struct scsi_cmnd *srb, struct 
us_data *us)
if (transfer_length) {
unsigned int pipe = srb-sc_data_direction == DMA_FROM_DEVICE ? 
us-recv_bulk_pipe : us-send_bulk_pipe;
-   result = usb_stor_bulk_transfer_sg(us, pipe,
-   srb-request_buffer, transfer_length,
-   srb-use_sg, srb-resid);
+   result = usb_stor_bulk_srb(us, pipe, srb);
US_DEBUGP(CB data stage result is 0x%x\n, result);
 
/* if we stalled the data transfer it means command failed */
@@ -904,7 +915,7 @@ int 

[PATCH 06/24] NCR5380 familly convert to accessors !use_sg cleanup

2007-09-11 Thread Boaz Harrosh

  - This patch depends on:
  NCR5380: Use scsi_eh API for REQUEST_SENSE invocation
  - convert to accessors and !use_sg cleanup
  - FIXME: Not sg-chain ready look for ++cmd-SCp.buffer

Signed-off-by: Boaz Harrosh [EMAIL PROTECTED]
---
 drivers/scsi/NCR5380.c   |   14 +++---
 drivers/scsi/atari_NCR5380.c |   22 +++---
 drivers/scsi/sun3_NCR5380.c  |   22 +++---
 3 files changed, 29 insertions(+), 29 deletions(-)

diff --git a/drivers/scsi/NCR5380.c b/drivers/scsi/NCR5380.c
index 575c715..284bb3d 100644
--- a/drivers/scsi/NCR5380.c
+++ b/drivers/scsi/NCR5380.c
@@ -295,17 +295,17 @@ static __inline__ void initialize_SCp(Scsi_Cmnd * cmd)
 * various queues are valid.
 */
 
-   if (cmd-use_sg) {
-   cmd-SCp.buffer = (struct scatterlist *) cmd-request_buffer;
-   cmd-SCp.buffers_residual = cmd-use_sg - 1;
+   if (scsi_bufflen(cmd)) {
+   cmd-SCp.buffer = scsi_sglist(cmd);
+   cmd-SCp.buffers_residual = scsi_sg_count(cmd) - 1;
cmd-SCp.ptr = page_address(cmd-SCp.buffer-page)+
   cmd-SCp.buffer-offset;
cmd-SCp.this_residual = cmd-SCp.buffer-length;
} else {
cmd-SCp.buffer = NULL;
cmd-SCp.buffers_residual = 0;
-   cmd-SCp.ptr = (char *) cmd-request_buffer;
-   cmd-SCp.this_residual = cmd-request_bufflen;
+   cmd-SCp.ptr = NULL;
+   cmd-SCp.this_residual = 0;
}
 }
 
@@ -976,14 +976,14 @@ static int NCR5380_queue_command(Scsi_Cmnd * cmd, void 
(*done) (Scsi_Cmnd *))
case WRITE_6:
case WRITE_10:
hostdata-time_write[cmd-device-id] -= (jiffies - 
hostdata-timebase);
-   hostdata-bytes_write[cmd-device-id] += 
cmd-request_bufflen;
+   hostdata-bytes_write[cmd-device-id] += 
scsi_bufflen(cmd);
hostdata-pendingw++;
break;
case READ:
case READ_6:
case READ_10:
hostdata-time_read[cmd-device-id] -= (jiffies - 
hostdata-timebase);
-   hostdata-bytes_read[cmd-device-id] += 
cmd-request_bufflen;
+   hostdata-bytes_read[cmd-device-id] += 
scsi_bufflen(cmd);
hostdata-pendingr++;
break;
}
diff --git a/drivers/scsi/atari_NCR5380.c b/drivers/scsi/atari_NCR5380.c
index b253d37..a769abc 100644
--- a/drivers/scsi/atari_NCR5380.c
+++ b/drivers/scsi/atari_NCR5380.c
@@ -512,9 +512,9 @@ static inline void initialize_SCp(Scsi_Cmnd *cmd)
 * various queues are valid.
 */
 
-   if (cmd-use_sg) {
-   cmd-SCp.buffer = (struct scatterlist *)cmd-request_buffer;
-   cmd-SCp.buffers_residual = cmd-use_sg - 1;
+   if (scsi_bufflen(cmd)) {
+   cmd-SCp.buffer = scsi_sglist(cmd);
+   cmd-SCp.buffers_residual = scsi_sg_count(cmd) - 1;
cmd-SCp.ptr = (char *)page_address(cmd-SCp.buffer-page) +
   cmd-SCp.buffer-offset;
cmd-SCp.this_residual = cmd-SCp.buffer-length;
@@ -525,8 +525,8 @@ static inline void initialize_SCp(Scsi_Cmnd *cmd)
} else {
cmd-SCp.buffer = NULL;
cmd-SCp.buffers_residual = 0;
-   cmd-SCp.ptr = (char *)cmd-request_buffer;
-   cmd-SCp.this_residual = cmd-request_bufflen;
+   cmd-SCp.ptr = NULL;
+   cmd-SCp.this_residual = 0;
}
 }
 
@@ -938,21 +938,21 @@ static int NCR5380_queue_command(Scsi_Cmnd *cmd, void 
(*done)(Scsi_Cmnd *))
}
 # endif
 # ifdef NCR5380_STAT_LIMIT
-   if (cmd-request_bufflen  NCR5380_STAT_LIMIT)
+   if (scsi_bufflen(cmd)  NCR5380_STAT_LIMIT)
 # endif
switch (cmd-cmnd[0]) {
case WRITE:
case WRITE_6:
case WRITE_10:
hostdata-time_write[cmd-device-id] -= (jiffies - 
hostdata-timebase);
-   hostdata-bytes_write[cmd-device-id] += 
cmd-request_bufflen;
+   hostdata-bytes_write[cmd-device-id] += 
scsi_bufflen(cmd);
hostdata-pendingw++;
break;
case READ:
case READ_6:
case READ_10:
hostdata-time_read[cmd-device-id] -= (jiffies - 
hostdata-timebase);
-   hostdata-bytes_read[cmd-device-id] += 
cmd-request_bufflen;
+   hostdata-bytes_read[cmd-device-id] += 
scsi_bufflen(cmd);
hostdata-pendingr++;
break;
}
@@ -1354,21 +1354,21 @@ static irqreturn_t NCR5380_intr(int irq, void *dev_id)
 static void collect_stats(struct NCR5380_hostdata* hostdata, Scsi_Cmnd *cmd)
 {
 # ifdef 

[PATCH 08/24] nsp_cs.c convert to data accessors and !use_sg cleanup

2007-09-11 Thread Boaz Harrosh

  - use scsi data accessors
  - cleanup !use_sg code paths
  - TODO: use next_sg() for Jens's sglist branch. Look for 2
places with SCp.buffer++

 Signed-off-by: Boaz Harrosh [EMAIL PROTECTED]
---
 drivers/scsi/pcmcia/nsp_cs.c |   54 ++---
 1 files changed, 34 insertions(+), 20 deletions(-)

diff --git a/drivers/scsi/pcmcia/nsp_cs.c b/drivers/scsi/pcmcia/nsp_cs.c
index 445cfbb..e41908b 100644
--- a/drivers/scsi/pcmcia/nsp_cs.c
+++ b/drivers/scsi/pcmcia/nsp_cs.c
@@ -144,6 +144,11 @@ static nsp_hw_data nsp_data_base; /* attach - detect 
glue */
 
 #define NSP_DEBUG_BUF_LEN  150
 
+static inline void nsp_inc_resid(struct scsi_cmnd *SCpnt, int residInc)
+{
+   scsi_set_resid(SCpnt, scsi_get_resid(SCpnt) + residInc);
+}
+
 static void nsp_cs_message(const char *func, int line, char *type, char *fmt, 
...)
 {
va_list args;
@@ -201,8 +206,10 @@ static int nsp_queuecommand(struct scsi_cmnd *SCpnt,
 #endif
nsp_hw_data *data = (nsp_hw_data *)SCpnt-device-host-hostdata;
 
-   nsp_dbg(NSP_DEBUG_QUEUECOMMAND, SCpnt=0x%p target=%d lun=%d buff=0x%p 
bufflen=%d use_sg=%d,
-  SCpnt, target, SCpnt-device-lun, SCpnt-request_buffer, 
SCpnt-request_bufflen, SCpnt-use_sg);
+   nsp_dbg(NSP_DEBUG_QUEUECOMMAND,
+   SCpnt=0x%p target=%d lun=%d sglist=0x%p bufflen=%d 
sg_count=%d,
+   SCpnt, target, SCpnt-device-lun, scsi_sglist(SCpnt),
+   scsi_bufflen(SCpnt), scsi_sg_count(SCpnt));
//nsp_dbg(NSP_DEBUG_QUEUECOMMAND, before CurrentSC=0x%p, 
data-CurrentSC);
 
SCpnt-scsi_done= done;
@@ -234,7 +241,7 @@ static int nsp_queuecommand(struct scsi_cmnd *SCpnt,
SCpnt-SCp.have_data_in = IO_UNKNOWN;
SCpnt-SCp.sent_command = 0;
SCpnt-SCp.phase= PH_UNDETERMINED;
-   SCpnt-resid= SCpnt-request_bufflen;
+   scsi_set_resid(SCpnt, scsi_bufflen(SCpnt));
 
/* setup scratch area
   SCp.ptr  : buffer pointer
@@ -242,14 +249,14 @@ static int nsp_queuecommand(struct scsi_cmnd *SCpnt,
   SCp.buffer   : next buffer
   SCp.buffers_residual : left buffers in list
   SCp.phase: current state of the command */
-   if (SCpnt-use_sg) {
-   SCpnt-SCp.buffer   = (struct scatterlist *) 
SCpnt-request_buffer;
+   if (scsi_bufflen(SCpnt)) {
+   SCpnt-SCp.buffer   = scsi_sglist(SCpnt);
SCpnt-SCp.ptr  = BUFFER_ADDR;
SCpnt-SCp.this_residual= SCpnt-SCp.buffer-length;
-   SCpnt-SCp.buffers_residual = SCpnt-use_sg - 1;
+   SCpnt-SCp.buffers_residual = scsi_sg_count(SCpnt) - 1;
} else {
-   SCpnt-SCp.ptr  = (char *) SCpnt-request_buffer;
-   SCpnt-SCp.this_residual= SCpnt-request_bufflen;
+   SCpnt-SCp.ptr  = NULL;
+   SCpnt-SCp.this_residual= 0;
SCpnt-SCp.buffer   = NULL;
SCpnt-SCp.buffers_residual = 0;
}
@@ -730,7 +737,9 @@ static void nsp_pio_read(struct scsi_cmnd *SCpnt)
ocount = data-FifoCount;
 
nsp_dbg(NSP_DEBUG_DATA_IO, in SCpnt=0x%p resid=%d ocount=%d ptr=0x%p 
this_residual=%d buffers=0x%p nbuf=%d,
-   SCpnt, SCpnt-resid, ocount, SCpnt-SCp.ptr, 
SCpnt-SCp.this_residual, SCpnt-SCp.buffer, SCpnt-SCp.buffers_residual);
+   SCpnt, scsi_get_resid(SCpnt), ocount, SCpnt-SCp.ptr,
+   SCpnt-SCp.this_residual, SCpnt-SCp.buffer,
+   SCpnt-SCp.buffers_residual);
 
time_out = 1000;
 
@@ -780,7 +789,7 @@ static void nsp_pio_read(struct scsi_cmnd *SCpnt)
return;
}
 
-   SCpnt-resid -= res;
+   nsp_inc_resid(SCpnt, -res);
SCpnt-SCp.ptr   += res;
SCpnt-SCp.this_residual -= res;
ocount   += res;
@@ -804,10 +813,12 @@ static void nsp_pio_read(struct scsi_cmnd *SCpnt)
 
if (time_out == 0) {
nsp_msg(KERN_DEBUG, pio read timeout resid=%d this_residual=%d 
buffers_residual=%d,
-   SCpnt-resid, SCpnt-SCp.this_residual, 
SCpnt-SCp.buffers_residual);
+   scsi_get_resid(SCpnt), SCpnt-SCp.this_residual,
+   SCpnt-SCp.buffers_residual);
}
nsp_dbg(NSP_DEBUG_DATA_IO, read ocount=0x%x, ocount);
-   nsp_dbg(NSP_DEBUG_DATA_IO, r cmd=%d resid=0x%x\n, data-CmdId, 
SCpnt-resid);
+   nsp_dbg(NSP_DEBUG_DATA_IO, r cmd=%d resid=0x%x\n, data-CmdId,
+   scsi_get_resid(SCpnt));
 }
 
 /*
@@ -825,7 +836,9 @@ static void nsp_pio_write(struct scsi_cmnd *SCpnt)
ocount   = data-FifoCount;
 
nsp_dbg(NSP_DEBUG_DATA_IO, in fifocount=%d ptr=0x%p this_residual=%d 
buffers=0x%p nbuf=%d resid=0x%x,
- 

[PATCH 05/24] isd200.c: use one-element sg list in issuing commands

2007-09-11 Thread Boaz Harrosh

  - isd200_action() was still using direct linear pointers in issuing
commands to the USB transport level. This is no longer supported,
use one-element scatterlist instead.
  - Adjustment of command's length in the case of scsi-to-ata translation
is now restored before return to queuecommand, since other wise it can
leak BIOs.
  - isd200_action() return Error on unknown requests. Used to print an error
but still try to send garbage cdb.
  - convert few places to scsi data accessors.
  - Todo: This file will need to be changed when scsi_cmnd changes to
scsi_data_buffer or any other solution.

Signed-off-by: Boaz Harrosh [EMAIL PROTECTED]
---
 drivers/usb/storage/isd200.c |   66 +
 1 files changed, 46 insertions(+), 20 deletions(-)

diff --git a/drivers/usb/storage/isd200.c b/drivers/usb/storage/isd200.c
index 6831dca..a624b4e 100644
--- a/drivers/usb/storage/isd200.c
+++ b/drivers/usb/storage/isd200.c
@@ -49,6 +49,7 @@
 #include linux/slab.h
 #include linux/hdreg.h
 #include linux/ide.h
+#include linux/scatterlist.h
 
 #include scsi/scsi.h
 #include scsi/scsi_cmnd.h
@@ -287,6 +288,7 @@ struct isd200_info {
/* maximum number of LUNs supported */
unsigned char MaxLUNs;
struct scsi_cmnd srb;
+   struct scatterlist sg;
 };
 
 
@@ -398,6 +400,31 @@ static void isd200_build_sense(struct us_data *us, struct 
scsi_cmnd *srb)
  * Transport routines
  ***/
 
+/**
+ *  isd200_set_srb(), isd200_srb_set_bufflen()
+ *
+ * Two helpers to facilitate in initialization of scsi_cmnd structure
+ * Will need to change when struct scsi_cmnd changes
+ */
+static void isd200_set_srb(struct isd200_info *info,
+   enum dma_data_direction dir, void* buff, unsigned bufflen)
+{
+   struct scsi_cmnd *srb = info-srb;
+
+   if (buff)
+   sg_init_one(info-sg, buff, bufflen);
+
+   srb-sc_data_direction = dir;
+   srb-request_buffer = buff ? info-sg : NULL;
+   srb-request_bufflen = bufflen;
+   srb-use_sg = buff ? 1 : 0;
+}
+
+static void isd200_srb_set_bufflen(struct scsi_cmnd *srb, unsigned bufflen)
+{
+   srb-request_bufflen = bufflen;
+}
+
 
 /**
  *  isd200_action
@@ -432,9 +459,7 @@ static int isd200_action( struct us_data *us, int action,
ata.generic.RegisterSelect =
  REG_CYLINDER_LOW | REG_CYLINDER_HIGH |
  REG_STATUS | REG_ERROR;
-   srb-sc_data_direction = DMA_FROM_DEVICE;
-   srb-request_buffer = pointer;
-   srb-request_bufflen = value;
+   isd200_set_srb(info, DMA_FROM_DEVICE, pointer, value);
break;
 
case ACTION_ENUM:
@@ -444,7 +469,7 @@ static int isd200_action( struct us_data *us, int action,
   ACTION_SELECT_5;
ata.generic.RegisterSelect = REG_DEVICE_HEAD;
ata.write.DeviceHeadByte = value;
-   srb-sc_data_direction = DMA_NONE;
+   isd200_set_srb(info, DMA_NONE, NULL, 0);
break;
 
case ACTION_RESET:
@@ -453,7 +478,7 @@ static int isd200_action( struct us_data *us, int action,
   ACTION_SELECT_3|ACTION_SELECT_4;
ata.generic.RegisterSelect = REG_DEVICE_CONTROL;
ata.write.DeviceControlByte = ATA_DC_RESET_CONTROLLER;
-   srb-sc_data_direction = DMA_NONE;
+   isd200_set_srb(info, DMA_NONE, NULL, 0);
break;
 
case ACTION_REENABLE:
@@ -462,7 +487,7 @@ static int isd200_action( struct us_data *us, int action,
   ACTION_SELECT_3|ACTION_SELECT_4;
ata.generic.RegisterSelect = REG_DEVICE_CONTROL;
ata.write.DeviceControlByte = ATA_DC_REENABLE_CONTROLLER;
-   srb-sc_data_direction = DMA_NONE;
+   isd200_set_srb(info, DMA_NONE, NULL, 0);
break;
 
case ACTION_SOFT_RESET:
@@ -471,21 +496,20 @@ static int isd200_action( struct us_data *us, int action,
ata.generic.RegisterSelect = REG_DEVICE_HEAD | REG_COMMAND;
ata.write.DeviceHeadByte = info-DeviceHead;
ata.write.CommandByte = WIN_SRST;
-   srb-sc_data_direction = DMA_NONE;
+   isd200_set_srb(info, DMA_NONE, NULL, 0);
break;
 
case ACTION_IDENTIFY:
US_DEBUGP(   isd200_action(IDENTIFY)\n);
ata.generic.RegisterSelect = REG_COMMAND;
ata.write.CommandByte = WIN_IDENTIFY;
-   srb-sc_data_direction = DMA_FROM_DEVICE;
-   srb-request_buffer = (void *) info-id;
-   srb-request_bufflen = sizeof(struct 

[PATCH 09/24] libata-scsi: convert to use the data buffer accessors

2007-09-11 Thread Boaz Harrosh

 This is a minimal patch needed to use the data accessors
 but it is not a complete clean up of the !use_sg path.
 Libata-core still has the qc-flags  ATA_QCFLAG_SG
 and !qc-n_elem code paths. Perhaps an ata maintainer
 would have a go at it.

 - TODO: further cleanup of qc-flags  ATA_QCFLAG_SG
   and !qc-n_elem code paths in libata-core
 - TODO: Use scsi_dma_{map,unmap} where applicable.
---
 drivers/ata/libata-scsi.c |   39 +--
 1 files changed, 13 insertions(+), 26 deletions(-)

diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c
index e836476..d23a181 100644
--- a/drivers/ata/libata-scsi.c
+++ b/drivers/ata/libata-scsi.c
@@ -450,13 +450,8 @@ static struct ata_queued_cmd *ata_scsi_qc_new(struct 
ata_device *dev,
qc-scsicmd = cmd;
qc-scsidone = done;
 
-   if (cmd-use_sg) {
-   qc-__sg = (struct scatterlist *) cmd-request_buffer;
-   qc-n_elem = cmd-use_sg;
-   } else if (cmd-request_bufflen) {
-   qc-__sg = qc-sgent;
-   qc-n_elem = 1;
-   }
+   qc-__sg = scsi_sglist(cmd);
+   qc-n_elem = scsi_sg_count(cmd);
} else {
cmd-result = (DID_OK  16) | (QUEUE_FULL  1);
done(cmd);
@@ -1498,17 +1493,13 @@ static int ata_scsi_translate(struct ata_device *dev, 
struct scsi_cmnd *cmd,
/* data is present; dma-map it */
if (cmd-sc_data_direction == DMA_FROM_DEVICE ||
cmd-sc_data_direction == DMA_TO_DEVICE) {
-   if (unlikely(cmd-request_bufflen  1)) {
+   if (unlikely(scsi_bufflen(cmd)  1)) {
ata_dev_printk(dev, KERN_WARNING,
   WARNING: zero len r/w req\n);
goto err_did;
}
 
-   if (cmd-use_sg)
-   ata_sg_init(qc, cmd-request_buffer, cmd-use_sg);
-   else
-   ata_sg_init_one(qc, cmd-request_buffer,
-   cmd-request_bufflen);
+   ata_sg_init(qc, scsi_sglist(cmd), scsi_sg_count(cmd));
 
qc-dma_dir = cmd-sc_data_direction;
}
@@ -1562,15 +1553,14 @@ static unsigned int ata_scsi_rbuf_get(struct scsi_cmnd 
*cmd, u8 **buf_out)
u8 *buf;
unsigned int buflen;
 
-   if (cmd-use_sg) {
-   struct scatterlist *sg;
+   struct scatterlist *sg = scsi_sglist(cmd);
 
-   sg = (struct scatterlist *) cmd-request_buffer;
+   if (sg) {
buf = kmap_atomic(sg-page, KM_IRQ0) + sg-offset;
buflen = sg-length;
} else {
-   buf = cmd-request_buffer;
-   buflen = cmd-request_bufflen;
+   buf = NULL;
+   buflen = 0;
}
 
*buf_out = buf;
@@ -1590,12 +1580,9 @@ static unsigned int ata_scsi_rbuf_get(struct scsi_cmnd 
*cmd, u8 **buf_out)
 
 static inline void ata_scsi_rbuf_put(struct scsi_cmnd *cmd, u8 *buf)
 {
-   if (cmd-use_sg) {
-   struct scatterlist *sg;
-
-   sg = (struct scatterlist *) cmd-request_buffer;
+   struct scatterlist *sg = scsi_sglist(cmd);
+   if (sg)
kunmap_atomic(buf - sg-offset, KM_IRQ0);
-   }
 }
 
 /**
@@ -2396,7 +2383,7 @@ static unsigned int atapi_xlat(struct ata_queued_cmd *qc)
}
 
qc-tf.command = ATA_CMD_PACKET;
-   qc-nbytes = scmd-request_bufflen;
+   qc-nbytes = scsi_bufflen(scmd);
 
/* check whether ATAPI DMA is safe */
if (!using_pio  ata_check_atapi_dma(qc))
@@ -2631,7 +2618,7 @@ static unsigned int ata_scsi_pass_thru(struct 
ata_queued_cmd *qc)
case ATA_CMD_WRITE_LONG_ONCE:
if (tf-protocol != ATA_PROT_PIO || tf-nsect != 1)
goto invalid_fld;
-   qc-sect_size = scmd-request_bufflen;
+   qc-sect_size = scsi_bufflen(scmd);
}
 
/*
@@ -2661,7 +2648,7 @@ static unsigned int ata_scsi_pass_thru(struct 
ata_queued_cmd *qc)
 * TODO: find out if we need to do more here to
 *   cover scatter/gather case.
 */
-   qc-nbytes = scmd-request_bufflen;
+   qc-nbytes = scsi_bufflen(scmd);
 
/* request result TF */
qc-flags |= ATA_QCFLAG_RESULT_TF;
-- 
1.5.3.1


-
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 07/24] arm: scsi convert to accessors and !use_sg cleanup

2007-09-11 Thread Boaz Harrosh

 - convert to accessors and !use_sg cleanup

Signed-off-by: Boaz Harrosh [EMAIL PROTECTED]
---
 drivers/scsi/arm/acornscsi.c |   14 +++---
 drivers/scsi/arm/scsi.h  |   34 +++---
 2 files changed, 18 insertions(+), 30 deletions(-)

diff --git a/drivers/scsi/arm/acornscsi.c b/drivers/scsi/arm/acornscsi.c
index eceacf6..3bedf24 100644
--- a/drivers/scsi/arm/acornscsi.c
+++ b/drivers/scsi/arm/acornscsi.c
@@ -1790,7 +1790,7 @@ int acornscsi_starttransfer(AS_Host *host)
return 0;
 }
 
-residual = host-SCpnt-request_bufflen - host-scsi.SCp.scsi_xferred;
+residual = scsi_bufflen(host-SCpnt) - host-scsi.SCp.scsi_xferred;
 
 sbic_arm_write(host-scsi.io_port, SBIC_SYNCHTRANSFER, 
host-device[host-SCpnt-device-id].sync_xfer);
 sbic_arm_writenext(host-scsi.io_port, residual  16);
@@ -2270,7 +2270,7 @@ intr_ret_t acornscsi_sbicintr(AS_Host *host, int in_irq)
case 0x4b:  /* - PHASE_STATUSIN
*/
case 0x8b:  /* - PHASE_STATUSIN
*/
/* DATA IN - STATUS */
-   host-scsi.SCp.scsi_xferred = host-SCpnt-request_bufflen -
+   host-scsi.SCp.scsi_xferred = scsi_bufflen(host-SCpnt) -
  acornscsi_sbic_xfcount(host);
acornscsi_dma_stop(host);
acornscsi_readstatusbyte(host);
@@ -2281,7 +2281,7 @@ intr_ret_t acornscsi_sbicintr(AS_Host *host, int in_irq)
case 0x4e:  /* - PHASE_MSGOUT  
*/
case 0x8e:  /* - PHASE_MSGOUT  
*/
/* DATA IN - MESSAGE OUT */
-   host-scsi.SCp.scsi_xferred = host-SCpnt-request_bufflen -
+   host-scsi.SCp.scsi_xferred = scsi_bufflen(host-SCpnt) -
  acornscsi_sbic_xfcount(host);
acornscsi_dma_stop(host);
acornscsi_sendmessage(host);
@@ -2291,7 +2291,7 @@ intr_ret_t acornscsi_sbicintr(AS_Host *host, int in_irq)
case 0x4f:  /* message in   
*/
case 0x8f:  /* message in   
*/
/* DATA IN - MESSAGE IN */
-   host-scsi.SCp.scsi_xferred = host-SCpnt-request_bufflen -
+   host-scsi.SCp.scsi_xferred = scsi_bufflen(host-SCpnt) -
  acornscsi_sbic_xfcount(host);
acornscsi_dma_stop(host);
acornscsi_message(host);/* - PHASE_MSGIN, PHASE_DISCONNECT 
*/
@@ -2319,7 +2319,7 @@ intr_ret_t acornscsi_sbicintr(AS_Host *host, int in_irq)
case 0x4b:  /* - PHASE_STATUSIN
*/
case 0x8b:  /* - PHASE_STATUSIN
*/
/* DATA OUT - STATUS */
-   host-scsi.SCp.scsi_xferred = host-SCpnt-request_bufflen -
+   host-scsi.SCp.scsi_xferred = scsi_bufflen(host-SCpnt) -
  acornscsi_sbic_xfcount(host);
acornscsi_dma_stop(host);
acornscsi_dma_adjust(host);
@@ -2331,7 +2331,7 @@ intr_ret_t acornscsi_sbicintr(AS_Host *host, int in_irq)
case 0x4e:  /* - PHASE_MSGOUT  
*/
case 0x8e:  /* - PHASE_MSGOUT  
*/
/* DATA OUT - MESSAGE OUT */
-   host-scsi.SCp.scsi_xferred = host-SCpnt-request_bufflen -
+   host-scsi.SCp.scsi_xferred = scsi_bufflen(host-SCpnt) -
  acornscsi_sbic_xfcount(host);
acornscsi_dma_stop(host);
acornscsi_dma_adjust(host);
@@ -2342,7 +2342,7 @@ intr_ret_t acornscsi_sbicintr(AS_Host *host, int in_irq)
case 0x4f:  /* message in   
*/
case 0x8f:  /* message in   
*/
/* DATA OUT - MESSAGE IN */
-   host-scsi.SCp.scsi_xferred = host-SCpnt-request_bufflen -
+   host-scsi.SCp.scsi_xferred = scsi_bufflen(host-SCpnt) -
  acornscsi_sbic_xfcount(host);
acornscsi_dma_stop(host);
acornscsi_dma_adjust(host);
diff --git a/drivers/scsi/arm/scsi.h b/drivers/scsi/arm/scsi.h
index 21ba571..95cfb21 100644
--- a/drivers/scsi/arm/scsi.h
+++ b/drivers/scsi/arm/scsi.h
@@ -70,48 +70,36 @@ static inline void init_SCp(struct scsi_cmnd *SCpnt)
 {
memset(SCpnt-SCp, 0, sizeof(struct scsi_pointer));
 
-   if (SCpnt-use_sg) {
+   if (scsi_bufflen(SCpnt)) {
unsigned long len = 0;
int buf;
 
-   SCpnt-SCp.buffer = (struct scatterlist *) 
SCpnt-request_buffer;
-   SCpnt-SCp.buffers_residual = SCpnt-use_sg - 1;
+  

[PATCH 10/24] eata_pio.c: convert to accessors and !use_sg cleanup

2007-09-11 Thread Boaz Harrosh

 - convert to accessors and !use_sg cleanup

Signed-off-by: Boaz Harrosh [EMAIL PROTECTED]
---
 drivers/scsi/eata_pio.c |   12 ++--
 1 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/scsi/eata_pio.c b/drivers/scsi/eata_pio.c
index f33ad01..266ddc9 100644
--- a/drivers/scsi/eata_pio.c
+++ b/drivers/scsi/eata_pio.c
@@ -400,7 +400,7 @@ static int eata_pio_queue(struct scsi_cmnd *cmd,
cp-DataIn = 0; /* Input mode  */
 
cp-Interpret = (cmd-device-id == hd-hostid);
-   cp-cp_datalen = cpu_to_be32(cmd-request_bufflen);
+   cp-cp_datalen = cpu_to_be32(scsi_bufflen(cmd));
cp-Auto_Req_Sen = 0;
cp-cp_reqDMA = 0;
cp-reqlen = 0;
@@ -417,14 +417,14 @@ static int eata_pio_queue(struct scsi_cmnd *cmd,
cp-cmd = cmd;
cmd-host_scribble = (char *) hd-ccb[y];
 
-   if (cmd-use_sg == 0) {
+   if (!scsi_bufflen(cmd)) {
cmd-SCp.buffers_residual = 1;
-   cmd-SCp.ptr = cmd-request_buffer;
-   cmd-SCp.this_residual = cmd-request_bufflen;
+   cmd-SCp.ptr = NULL;
+   cmd-SCp.this_residual = 0;
cmd-SCp.buffer = NULL;
} else {
-   cmd-SCp.buffer = cmd-request_buffer;
-   cmd-SCp.buffers_residual = cmd-use_sg;
+   cmd-SCp.buffer = scsi_sglist(cmd);
+   cmd-SCp.buffers_residual = scsi_sg_count(cmd);
cmd-SCp.ptr = page_address(cmd-SCp.buffer-page) + 
cmd-SCp.buffer-offset;
cmd-SCp.this_residual = cmd-SCp.buffer-length;
}
-- 
1.5.3.1


-
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 14/24] atp870u.c: convert to accessors and !use_sg cleanup

2007-09-11 Thread Boaz Harrosh

 - convert to accessors and !use_sg cleanup
 - Probably not ready for sg-chaining

Signed-off-by: Boaz Harrosh [EMAIL PROTECTED]
---
 drivers/scsi/atp870u.c |  102 
 1 files changed, 17 insertions(+), 85 deletions(-)

diff --git a/drivers/scsi/atp870u.c b/drivers/scsi/atp870u.c
index fec58cc..db6de5e 100644
--- a/drivers/scsi/atp870u.c
+++ b/drivers/scsi/atp870u.c
@@ -471,18 +471,8 @@ go_42:
/*
 *  Complete the command
 */
-   if (workreq-use_sg) {
-   pci_unmap_sg(dev-pdev,
-   (struct scatterlist 
*)workreq-request_buffer,
-   workreq-use_sg,
-   workreq-sc_data_direction);
-   } else if (workreq-request_bufflen 
-   workreq-sc_data_direction != DMA_NONE) 
{
-   pci_unmap_single(dev-pdev,
-   workreq-SCp.dma_handle,
-   workreq-request_bufflen,
-   workreq-sc_data_direction);
-   }   
+   scsi_dma_unmap(workreq);
+
spin_lock_irqsave(dev-host-host_lock, flags);
(*workreq-scsi_done) (workreq);
 #ifdef ED_DBGP
@@ -624,7 +614,7 @@ static int atp870u_queuecommand(struct scsi_cmnd * req_p,
 
c = scmd_channel(req_p);
req_p-sense_buffer[0]=0;
-   req_p-resid = 0;
+   scsi_set_resid(req_p, 0);
if (scmd_channel(req_p)  1) {
req_p-result = 0x0004;
done(req_p);
@@ -722,7 +712,6 @@ static void send_s870(struct atp_unit *dev,unsigned char c)
unsigned short int tmpcip, w;
unsigned long l, bttl = 0;
unsigned int workport;
-   struct scatterlist *sgpnt;
unsigned long  sg_count;
 
if (dev-in_snd[c] != 0) {
@@ -793,6 +782,8 @@ oktosend:
}
printk(\n);
 #endif 
+   l = scsi_bufflen(workreq);
+
if (dev-dev_id == ATP885_DEVID) {
j = inb(dev-baseport + 0x29)  0xfe;
outb(j, dev-baseport + 0x29);
@@ -800,12 +791,11 @@ oktosend:
}

if (workreq-cmnd[0] == READ_CAPACITY) {
-   if (workreq-request_bufflen  8) {
-   workreq-request_bufflen = 0x08;
-   }
+   if (l  8)
+   l = 8;
}
if (workreq-cmnd[0] == 0x00) {
-   workreq-request_bufflen = 0;
+   l = 0;
}
 
tmport = workport + 0x1b;
@@ -852,40 +842,8 @@ oktosend:
 #ifdef ED_DBGP 
printk(dev-id[%d][%d].devsp = 
%2x\n,c,target_id,dev-id[c][target_id].devsp);
 #endif
-   /*
-*  Figure out the transfer size
-*/
-   if (workreq-use_sg) {
-#ifdef ED_DBGP
-   printk(Using SGL\n);
-#endif 
-   l = 0;
-   
-   sgpnt = (struct scatterlist *) workreq-request_buffer;
-   sg_count = pci_map_sg(dev-pdev, sgpnt, workreq-use_sg,
-   workreq-sc_data_direction);
-   
-   for (i = 0; i  workreq-use_sg; i++) {
-   if (sgpnt[i].length == 0 || workreq-use_sg  
ATP870U_SCATTER) {
-   panic(Fod fight!);
-   }
-   l += sgpnt[i].length;
-   }
-#ifdef ED_DBGP 
-   printk( send_s870: workreq-use_sg %d, sg_count %d l %8ld\n, 
workreq-use_sg, sg_count, l);
-#endif
-   } else if(workreq-request_bufflen  workreq-sc_data_direction != 
PCI_DMA_NONE) {
-#ifdef ED_DBGP
-   printk(Not using SGL\n);
-#endif 
-   workreq-SCp.dma_handle = pci_map_single(dev-pdev, 
workreq-request_buffer,
-   workreq-request_bufflen,
-   workreq-sc_data_direction);
-   l = workreq-request_bufflen;
-#ifdef ED_DBGP 
-   printk( send_s870: workreq-use_sg %d, l %8ld\n, 
workreq-use_sg, l);
-#endif
-   } else l = 0;
+
+   sg_count = scsi_dma_map(workreq);
/*
 *  Write transfer size
 */
@@ -938,16 +896,16 @@ oktosend:
 *  a linear chain.
 */
 
-   if (workreq-use_sg) {
-   sgpnt = (struct scatterlist *) workreq-request_buffer;
+   if (l) {
+   struct scatterlist *sgpnt;
i = 0;
-   for (j = 0; j  workreq-use_sg; j++) {
-   bttl = sg_dma_address(sgpnt[j]);
-   l=sg_dma_len(sgpnt[j]);
+   scsi_for_each_sg(workreq, sgpnt, sg_count, j) {
+  

[PATCH 11/24] a2091.c: convert to accessors and !use_sg cleanup

2007-09-11 Thread Boaz Harrosh

 - convert to accessors and !use_sg cleanup

Signed-off-by: Boaz Harrosh [EMAIL PROTECTED]
---
 drivers/scsi/a2091.c |   36 +---
 1 files changed, 5 insertions(+), 31 deletions(-)

diff --git a/drivers/scsi/a2091.c b/drivers/scsi/a2091.c
index b7c5385..23f27c9 100644
--- a/drivers/scsi/a2091.c
+++ b/drivers/scsi/a2091.c
@@ -73,18 +73,9 @@ static int dma_setup(struct scsi_cmnd *cmd, int dir_in)
}
 
if (!dir_in) {
-   /* copy to bounce buffer for a write */
-   if (cmd-use_sg)
-#if 0
-   panic (scsi%ddma: incomplete s/g support,
-  instance-host_no);
-#else
+   /* copy to bounce buffer for a write */
memcpy (HDATA(instance)-dma_bounce_buffer,
cmd-SCp.ptr, cmd-SCp.this_residual);
-#endif
-   else
-   memcpy (HDATA(instance)-dma_bounce_buffer,
-   cmd-request_buffer, cmd-request_bufflen);
}
 }
 
@@ -144,30 +135,13 @@ static void dma_stop(struct Scsi_Host *instance, struct 
scsi_cmnd *SCpnt,
 
 /* copy from a bounce buffer, if necessary */
 if (status  HDATA(instance)-dma_bounce_buffer) {
-   if (SCpnt  SCpnt-use_sg) {
-#if 0
-   panic (scsi%d: incomplete s/g support,
-  instance-host_no);
-#else
-   if( HDATA(instance)-dma_dir )
+   if( HDATA(instance)-dma_dir )
memcpy (SCpnt-SCp.ptr, 
HDATA(instance)-dma_bounce_buffer,
SCpnt-SCp.this_residual);
-   kfree (HDATA(instance)-dma_bounce_buffer);
-   HDATA(instance)-dma_bounce_buffer = NULL;
-   HDATA(instance)-dma_bounce_len = 0;
-   
-#endif
-   } else {
-   if (HDATA(instance)-dma_dir  SCpnt)
-   memcpy (SCpnt-request_buffer,
-   HDATA(instance)-dma_bounce_buffer,
-   SCpnt-request_bufflen);
-
-   kfree (HDATA(instance)-dma_bounce_buffer);
-   HDATA(instance)-dma_bounce_buffer = NULL;
-   HDATA(instance)-dma_bounce_len = 0;
-   }
+   kfree (HDATA(instance)-dma_bounce_buffer);
+   HDATA(instance)-dma_bounce_buffer = NULL;
+   HDATA(instance)-dma_bounce_len = 0;
 }
 }
 
-- 
1.5.3.1


-
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 15/24] fd_mcs.c: convert to accessors and !use_sg cleanup

2007-09-11 Thread Boaz Harrosh

 - convert to accessors and !use_sg cleanup
 - Not ready for sg-chaining

Signed-off-by: Boaz Harrosh [EMAIL PROTECTED]
---
 drivers/scsi/fd_mcs.c |   36 +++-
 1 files changed, 11 insertions(+), 25 deletions(-)

diff --git a/drivers/scsi/fd_mcs.c b/drivers/scsi/fd_mcs.c
index 668569e..3a5df96 100644
--- a/drivers/scsi/fd_mcs.c
+++ b/drivers/scsi/fd_mcs.c
@@ -1017,24 +1017,6 @@ static irqreturn_t fd_mcs_intr(int irq, void *dev_id)
printk( ** IN DONE %d ** , current_SC-SCp.have_data_in);
 #endif
 
-#if ERRORS_ONLY
-   if (current_SC-cmnd[0] == REQUEST_SENSE  
!current_SC-SCp.Status) {
-   if ((unsigned char) (*((char *) 
current_SC-request_buffer + 2))  0x0f) {
-   unsigned char key;
-   unsigned char code;
-   unsigned char qualifier;
-
-   key = (unsigned char) (*((char *) 
current_SC-request_buffer + 2))  0x0f;
-   code = (unsigned char) (*((char *) 
current_SC-request_buffer + 12));
-   qualifier = (unsigned char) (*((char *) 
current_SC-request_buffer + 13));
-
-   if (key != UNIT_ATTENTION  !(key == NOT_READY 
 code == 0x04  (!qualifier || qualifier == 0x02 || qualifier == 0x01))
-!(key == ILLEGAL_REQUEST  (code == 
0x25 || code == 0x24 || !code)))
-
-   printk(fd_mcs: REQUEST SENSE  Key = 
%x, Code = %x, Qualifier = %x\n, key, code, qualifier);
-   }
-   }
-#endif
 #if EVERY_ACCESS
printk(BEFORE MY_DONE. . .);
 #endif
@@ -1097,7 +1079,9 @@ static int fd_mcs_queue(Scsi_Cmnd * SCpnt, void (*done) 
(Scsi_Cmnd *))
panic(fd_mcs: fd_mcs_queue() NOT REENTRANT!\n);
}
 #if EVERY_ACCESS
-   printk(queue: target = %d cmnd = 0x%02x pieces = %d size = %u\n, 
SCpnt-target, *(unsigned char *) SCpnt-cmnd, SCpnt-use_sg, 
SCpnt-request_bufflen);
+   printk(queue: target = %d cmnd = 0x%02x pieces = %d size = %u\n,
+   SCpnt-target, *(unsigned char *) SCpnt-cmnd,
+   scsi_sg_count(SCpnt), scsi_bufflen(SCpnt));
 #endif
 
fd_mcs_make_bus_idle(shpnt);
@@ -1107,14 +1091,14 @@ static int fd_mcs_queue(Scsi_Cmnd * SCpnt, void (*done) 
(Scsi_Cmnd *))
 
/* Initialize static data */
 
-   if (current_SC-use_sg) {
-   current_SC-SCp.buffer = (struct scatterlist *) 
current_SC-request_buffer;
+   if (scsi_bufflen(current_SC)) {
+   current_SC-SCp.buffer = scsi_sglist(current_SC);
current_SC-SCp.ptr = 
page_address(current_SC-SCp.buffer-page) + current_SC-SCp.buffer-offset;
current_SC-SCp.this_residual = current_SC-SCp.buffer-length;
-   current_SC-SCp.buffers_residual = current_SC-use_sg - 1;
+   current_SC-SCp.buffers_residual = scsi_sg_count(current_SC) - 
1;
} else {
-   current_SC-SCp.ptr = (char *) current_SC-request_buffer;
-   current_SC-SCp.this_residual = current_SC-request_bufflen;
+   current_SC-SCp.ptr = NULL;
+   current_SC-SCp.this_residual = 0;
current_SC-SCp.buffer = NULL;
current_SC-SCp.buffers_residual = 0;
}
@@ -1166,7 +1150,9 @@ static void fd_mcs_print_info(Scsi_Cmnd * SCpnt)
break;
}
 
-   printk((%d), target = %d cmnd = 0x%02x pieces = %d size = %u\n, 
SCpnt-SCp.phase, SCpnt-device-id, *(unsigned char *) SCpnt-cmnd, 
SCpnt-use_sg, SCpnt-request_bufflen);
+   printk((%d), target = %d cmnd = 0x%02x pieces = %d size = %u\n,
+   SCpnt-SCp.phase, SCpnt-device-id, *(unsigned char *) 
SCpnt-cmnd,
+   scsi_sg_count(SCpnt), scsi_bufflen(SCpnt));
printk(sent_command = %d, have_data_in = %d, timeout = %d\n, 
SCpnt-SCp.sent_command, SCpnt-SCp.have_data_in, SCpnt-timeout);
 #if DEBUG_RACE
printk(in_interrupt_flag = %d\n, in_interrupt_flag);
-- 
1.5.3.1


-
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 12/24] a3000.c: convert to accessors and !use_sg cleanup

2007-09-11 Thread Boaz Harrosh

 - convert to accessors and !use_sg cleanup

Signed-off-by: Boaz Harrosh [EMAIL PROTECTED]
---
 drivers/scsi/a3000.c |   15 +++
 1 files changed, 3 insertions(+), 12 deletions(-)

diff --git a/drivers/scsi/a3000.c b/drivers/scsi/a3000.c
index 796f1c4..d7255c8 100644
--- a/drivers/scsi/a3000.c
+++ b/drivers/scsi/a3000.c
@@ -70,12 +70,8 @@ static int dma_setup(struct scsi_cmnd *cmd, int dir_in)
 
if (!dir_in) {
/* copy to bounce buffer for a write */
-   if (cmd-use_sg) {
-   memcpy (HDATA(a3000_host)-dma_bounce_buffer,
-   cmd-SCp.ptr, cmd-SCp.this_residual);
-   } else
-   memcpy (HDATA(a3000_host)-dma_bounce_buffer,
-   cmd-request_buffer, cmd-request_bufflen);
+   memcpy (HDATA(a3000_host)-dma_bounce_buffer,
+   cmd-SCp.ptr, cmd-SCp.this_residual);
}
 
addr = virt_to_bus(HDATA(a3000_host)-dma_bounce_buffer);
@@ -146,7 +142,7 @@ static void dma_stop(struct Scsi_Host *instance, struct 
scsi_cmnd *SCpnt,
 
 /* copy from a bounce buffer, if necessary */
 if (status  HDATA(instance)-dma_bounce_buffer) {
-   if (SCpnt  SCpnt-use_sg) {
+   if (SCpnt) {
if (HDATA(instance)-dma_dir  SCpnt)
memcpy (SCpnt-SCp.ptr,
HDATA(instance)-dma_bounce_buffer,
@@ -155,11 +151,6 @@ static void dma_stop(struct Scsi_Host *instance, struct 
scsi_cmnd *SCpnt,
HDATA(instance)-dma_bounce_buffer = NULL;
HDATA(instance)-dma_bounce_len = 0;
} else {
-   if (HDATA(instance)-dma_dir  SCpnt)
-   memcpy (SCpnt-request_buffer,
-   HDATA(instance)-dma_bounce_buffer,
-   SCpnt-request_bufflen);
-
kfree (HDATA(instance)-dma_bounce_buffer);
HDATA(instance)-dma_bounce_buffer = NULL;
HDATA(instance)-dma_bounce_len = 0;
-- 
1.5.3.1


-
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 16/24] imm.c: convert to accessors and !use_sg cleanup

2007-09-11 Thread Boaz Harrosh

 - convert to accessors and !use_sg cleanup
 - Not ready for sg-chaining

Signed-off-by: Boaz Harrosh [EMAIL PROTECTED]
---
 drivers/scsi/imm.c |   13 +
 1 files changed, 5 insertions(+), 8 deletions(-)

diff --git a/drivers/scsi/imm.c b/drivers/scsi/imm.c
index 005d2b0..5ee4e0a 100644
--- a/drivers/scsi/imm.c
+++ b/drivers/scsi/imm.c
@@ -843,21 +843,18 @@ static int imm_engine(imm_struct *dev, struct scsi_cmnd 
*cmd)
 
/* Phase 4 - Setup scatter/gather buffers */
case 4:
-   if (cmd-use_sg) {
-   /* if many buffers are available, start filling the 
first */
-   cmd-SCp.buffer =
-   (struct scatterlist *) cmd-request_buffer;
+   if (scsi_bufflen(cmd)) {
+   cmd-SCp.buffer = scsi_sglist(cmd);
cmd-SCp.this_residual = cmd-SCp.buffer-length;
cmd-SCp.ptr =
page_address(cmd-SCp.buffer-page) +
cmd-SCp.buffer-offset;
} else {
-   /* else fill the only available buffer */
cmd-SCp.buffer = NULL;
-   cmd-SCp.this_residual = cmd-request_bufflen;
-   cmd-SCp.ptr = cmd-request_buffer;
+   cmd-SCp.this_residual = 0;
+   cmd-SCp.ptr = NULL;
}
-   cmd-SCp.buffers_residual = cmd-use_sg - 1;
+   cmd-SCp.buffers_residual = scsi_sg_count(cmd) - 1;
cmd-SCp.phase++;
if (cmd-SCp.this_residual  0x01)
cmd-SCp.this_residual++;
-- 
1.5.3.1


-
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 13/24] aha1542.c: convert to accessors and !use_sg cleanup

2007-09-11 Thread Boaz Harrosh

 - convert to accessors and !use_sg cleanup

Signed-off-by: Boaz Harrosh [EMAIL PROTECTED]
---
 drivers/scsi/aha1542.c |   54 +++
 1 files changed, 13 insertions(+), 41 deletions(-)

diff --git a/drivers/scsi/aha1542.c b/drivers/scsi/aha1542.c
index cbbfbc9..1382d1e 100644
--- a/drivers/scsi/aha1542.c
+++ b/drivers/scsi/aha1542.c
@@ -51,15 +51,6 @@
 #define SCSI_BUF_PA(address)   isa_virt_to_bus(address)
 #define SCSI_SG_PA(sgent)  (isa_page_to_bus((sgent)-page) + 
(sgent)-offset)
 
-static void BAD_DMA(void *address, unsigned int length)
-{
-   printk(KERN_CRIT buf vaddress %p paddress 0x%lx length %d\n,
-  address,
-  SCSI_BUF_PA(address),
-  length);
-   panic(Buffer at physical address  16Mb used for aha1542);
-}
-
 static void BAD_SG_DMA(Scsi_Cmnd * SCpnt,
   struct scatterlist *sgpnt,
   int nseg,
@@ -598,8 +589,7 @@ static int aha1542_queuecommand(Scsi_Cmnd * SCpnt, void 
(*done) (Scsi_Cmnd *))
unchar target = SCpnt-device-id;
unchar lun = SCpnt-device-lun;
unsigned long flags;
-   void *buff = SCpnt-request_buffer;
-   int bufflen = SCpnt-request_bufflen;
+   int bufflen = scsi_bufflen(SCpnt);
int mbo;
struct mailbox *mb;
struct ccb *ccb;
@@ -690,45 +680,29 @@ static int aha1542_queuecommand(Scsi_Cmnd * SCpnt, void 
(*done) (Scsi_Cmnd *))
 
memcpy(ccb[mbo].cdb, cmd, ccb[mbo].cdblen);
 
-   if (SCpnt-use_sg) {
+   if (bufflen) {
struct scatterlist *sgpnt;
struct chain *cptr;
 #ifdef DEBUG
unsigned char *ptr;
 #endif
-   int i;
+   int i, sg_count = scsi_sg_count(SCpnt);
ccb[mbo].op = 2;/* SCSI Initiator Command  
w/scatter-gather */
-   SCpnt-host_scribble = kmalloc(512, GFP_KERNEL | GFP_DMA);
-   sgpnt = (struct scatterlist *) SCpnt-request_buffer;
+   SCpnt-host_scribble = kmalloc(sizeof(*cptr)*sg_count,
+GFP_KERNEL | GFP_DMA);
cptr = (struct chain *) SCpnt-host_scribble;
if (cptr == NULL) {
/* free the claimed mailbox slot */
HOSTDATA(SCpnt-device-host)-SCint[mbo] = NULL;
return SCSI_MLQUEUE_HOST_BUSY;
}
-   for (i = 0; i  SCpnt-use_sg; i++) {
-   if (sgpnt[i].length == 0 || SCpnt-use_sg  16 ||
-   (((int) sgpnt[i].offset)  1) || (sgpnt[i].length  
1)) {
-   unsigned char *ptr;
-   printk(KERN_CRIT Bad segment list supplied to 
aha1542.c (%d, %d)\n, SCpnt-use_sg, i);
-   for (i = 0; i  SCpnt-use_sg; i++) {
-   printk(KERN_CRIT %d: %p %d\n, i,
-  (page_address(sgpnt[i].page) +
-   sgpnt[i].offset),
-  sgpnt[i].length);
-   };
-   printk(KERN_CRIT cptr %x: , (unsigned int) 
cptr);
-   ptr = (unsigned char *) cptr[i];
-   for (i = 0; i  18; i++)
-   printk(%02x , ptr[i]);
-   panic(Fod fight!);
-   };
-   any2scsi(cptr[i].dataptr, SCSI_SG_PA(sgpnt[i]));
-   if (SCSI_SG_PA(sgpnt[i]) + sgpnt[i].length - 1  
ISA_DMA_THRESHOLD)
-   BAD_SG_DMA(SCpnt, sgpnt, SCpnt-use_sg, i);
-   any2scsi(cptr[i].datalen, sgpnt[i].length);
+   scsi_for_each_sg(SCpnt, sgpnt, sg_count, i) {
+   any2scsi(cptr[i].dataptr, SCSI_SG_PA(sgpnt));
+   if (SCSI_SG_PA(sgpnt) + sgpnt-length - 1  
ISA_DMA_THRESHOLD)
+   BAD_SG_DMA(SCpnt, scsi_sglist(SCpnt), sg_count, 
i);
+   any2scsi(cptr[i].datalen, sgpnt-length);
};
-   any2scsi(ccb[mbo].datalen, SCpnt-use_sg * sizeof(struct 
chain));
+   any2scsi(ccb[mbo].datalen, sg_count * sizeof(struct chain));
any2scsi(ccb[mbo].dataptr, SCSI_BUF_PA(cptr));
 #ifdef DEBUG
printk(cptr %x: , cptr);
@@ -739,10 +713,8 @@ static int aha1542_queuecommand(Scsi_Cmnd * SCpnt, void 
(*done) (Scsi_Cmnd *))
} else {
ccb[mbo].op = 0;/* SCSI Initiator Command */
SCpnt-host_scribble = NULL;
-   any2scsi(ccb[mbo].datalen, bufflen);
-   if (buff  SCSI_BUF_PA(buff + bufflen - 1)  ISA_DMA_THRESHOLD)
-   BAD_DMA(buff, bufflen);
-   

[PATCH 18/24] ppa.c: convert to accessors and !use_sg cleanup

2007-09-11 Thread Boaz Harrosh

 - convert to accessors and !use_sg cleanup

Signed-off-by: Boaz Harrosh [EMAIL PROTECTED]
---
 drivers/scsi/ppa.c |   12 +---
 1 files changed, 5 insertions(+), 7 deletions(-)

diff --git a/drivers/scsi/ppa.c b/drivers/scsi/ppa.c
index 67b6d76..f9fdc8a 100644
--- a/drivers/scsi/ppa.c
+++ b/drivers/scsi/ppa.c
@@ -752,19 +752,17 @@ static int ppa_engine(ppa_struct *dev, struct scsi_cmnd 
*cmd)
cmd-SCp.phase++;
 
case 4: /* Phase 4 - Setup scatter/gather buffers */
-   if (cmd-use_sg) {
-   /* if many buffers are available, start filling the 
first */
-   cmd-SCp.buffer = (struct scatterlist *) 
cmd-request_buffer;
+   if (scsi_bufflen(cmd)) {
+   cmd-SCp.buffer = scsi_sglist(cmd);
cmd-SCp.this_residual = cmd-SCp.buffer-length;
cmd-SCp.ptr = page_address(cmd-SCp.buffer-page) +
cmd-SCp.buffer-offset;
} else {
-   /* else fill the only available buffer */
cmd-SCp.buffer = NULL;
-   cmd-SCp.this_residual = cmd-request_bufflen;
-   cmd-SCp.ptr = cmd-request_buffer;
+   cmd-SCp.this_residual = 0;
+   cmd-SCp.ptr = NULL;
}
-   cmd-SCp.buffers_residual = cmd-use_sg - 1;
+   cmd-SCp.buffers_residual = scsi_sg_count(cmd) - 1;
cmd-SCp.phase++;
 
case 5: /* Phase 5 - Data transfer stage */
-- 
1.5.3.1


-
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Subject: [PATCH 20/24] scsi: esp family convert to accessors and !use_sg cleanup

2007-09-11 Thread Boaz Harrosh

  - convert to scsi data accessors and !use_sg code path
removal
  - When removing !use_sg code path I noticed that
dma_mmu_get_scsi_one()  dma_mmu_release_scsi_one()
are no longer used. So also remove all implementations
of these.
  - This family of drivers is totally not ready for chaining.

Signed-off-by: Boaz Harrosh [EMAIL PROTECTED]
---
 drivers/scsi/NCR53C9x.c|   42 ++
 drivers/scsi/NCR53C9x.h|2 --
 drivers/scsi/dec_esp.c |   17 -
 drivers/scsi/oktagon_esp.c |   14 --
 drivers/scsi/sun3x_esp.c   |   20 ++--
 5 files changed, 16 insertions(+), 79 deletions(-)

diff --git a/drivers/scsi/NCR53C9x.c b/drivers/scsi/NCR53C9x.c
index 79b4df1..303328d 100644
--- a/drivers/scsi/NCR53C9x.c
+++ b/drivers/scsi/NCR53C9x.c
@@ -910,36 +910,21 @@ EXPORT_SYMBOL(esp_proc_info);
 
 static void esp_get_dmabufs(struct NCR_ESP *esp, Scsi_Cmnd *sp)
 {
-   if(sp-use_sg == 0) {
-   sp-SCp.this_residual = sp-request_bufflen;
-   sp-SCp.buffer = (struct scatterlist *) sp-request_buffer;
-   sp-SCp.buffers_residual = 0;
-   if (esp-dma_mmu_get_scsi_one)
-   esp-dma_mmu_get_scsi_one(esp, sp);
-   else
-   sp-SCp.ptr =
-   (char *) virt_to_phys(sp-request_buffer);
-   } else {
-   sp-SCp.buffer = (struct scatterlist *) sp-request_buffer;
-   sp-SCp.buffers_residual = sp-use_sg - 1;
-   sp-SCp.this_residual = sp-SCp.buffer-length;
-   if (esp-dma_mmu_get_scsi_sgl)
-   esp-dma_mmu_get_scsi_sgl(esp, sp);
-   else
-   sp-SCp.ptr =
-   (char *) 
virt_to_phys((page_address(sp-SCp.buffer-page) + sp-SCp.buffer-offset));
-   }
+   sp-SCp.buffer = scsi_sglist(sp);
+   sp-SCp.buffers_residual = scsi_sg_count(sp) - 1;
+   sp-SCp.this_residual = sp-SCp.buffer-length;
+   if (esp-dma_mmu_get_scsi_sgl)
+   esp-dma_mmu_get_scsi_sgl(esp, sp);
+   else
+   sp-SCp.ptr = (char *)
+   virt_to_phys((page_address(sp-SCp.buffer-page) +
+ sp-SCp.buffer-offset));
 }
 
 static void esp_release_dmabufs(struct NCR_ESP *esp, Scsi_Cmnd *sp)
 {
-   if(sp-use_sg == 0) {
-   if (esp-dma_mmu_release_scsi_one)
-   esp-dma_mmu_release_scsi_one(esp, sp);
-   } else {
-   if (esp-dma_mmu_release_scsi_sgl)
-   esp-dma_mmu_release_scsi_sgl(esp, sp);
-   }
+   if (esp-dma_mmu_release_scsi_sgl)
+   esp-dma_mmu_release_scsi_sgl(esp, sp);
 }
 
 static void esp_restore_pointers(struct NCR_ESP *esp, Scsi_Cmnd *sp)
@@ -2102,9 +2087,10 @@ static int esp_do_data_finale(struct NCR_ESP *esp,
ESPLOG((esp%d: csz=%d fifocount=%d ecount=%d\n,
esp-esp_id,
esp-current_transfer_size, fifocnt, ecount));
-   ESPLOG((esp%d: use_sg=%d ptr=%p this_residual=%d\n,
+   ESPLOG((esp%d: sg_count=%d ptr=%p this_residual=%d\n,
esp-esp_id,
-   SCptr-use_sg, SCptr-SCp.ptr, 
SCptr-SCp.this_residual));
+   scsi_sg_count(SCptr), SCptr-SCp.ptr,
+   SCptr-SCp.this_residual));
ESPLOG((esp%d: Forcing async for target %d\n, esp-esp_id, 
SCptr-device-id));
SCptr-device-borken = 1;
diff --git a/drivers/scsi/NCR53C9x.h b/drivers/scsi/NCR53C9x.h
index d85cb73..b77eff4 100644
--- a/drivers/scsi/NCR53C9x.h
+++ b/drivers/scsi/NCR53C9x.h
@@ -440,9 +440,7 @@ struct NCR_ESP {
   void (*dma_reset)(struct NCR_ESP *);
 
   /* Optional virtual DMA functions */
-  void (*dma_mmu_get_scsi_one)(struct NCR_ESP *, Scsi_Cmnd *);
   void (*dma_mmu_get_scsi_sgl)(struct NCR_ESP *, Scsi_Cmnd *);
-  void (*dma_mmu_release_scsi_one)(struct NCR_ESP *, Scsi_Cmnd *);
   void (*dma_mmu_release_scsi_sgl)(struct NCR_ESP *, Scsi_Cmnd *);
   void (*dma_advance_sg)(Scsi_Cmnd *);
 };
diff --git a/drivers/scsi/dec_esp.c b/drivers/scsi/dec_esp.c
index d42ad66..b61da6c 100644
--- a/drivers/scsi/dec_esp.c
+++ b/drivers/scsi/dec_esp.c
@@ -64,7 +64,6 @@ static void dma_ints_on(struct NCR_ESP *esp);
 static int  dma_irq_p(struct NCR_ESP *esp);
 static int  dma_ports_p(struct NCR_ESP *esp);
 static void dma_setup(struct NCR_ESP *esp, u32 addr, int count, int write);
-static void dma_mmu_get_scsi_one(struct NCR_ESP *esp, struct scsi_cmnd * sp);
 static void dma_mmu_get_scsi_sgl(struct NCR_ESP *esp, struct scsi_cmnd * sp);
 static void dma_advance_sg(struct scsi_cmnd * sp);
 
@@ -74,7 +73,6 @@ static void pmaz_dma_init_write(struct NCR_ESP *esp, u32 
vaddress, int length);
 static void pmaz_dma_ints_off(struct NCR_ESP *esp);
 static void 

[PATCH 17/24] in2000.c: convert to accessors and !use_sg cleanup

2007-09-11 Thread Boaz Harrosh

 - convert to accessors and !use_sg cleanup

Signed-off-by: Boaz Harrosh [EMAIL PROTECTED]
---
 drivers/scsi/in2000.c |   10 +-
 1 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/scsi/in2000.c b/drivers/scsi/in2000.c
index 312190a..31e841c 100644
--- a/drivers/scsi/in2000.c
+++ b/drivers/scsi/in2000.c
@@ -369,16 +369,16 @@ static int in2000_queuecommand(Scsi_Cmnd * cmd, void 
(*done) (Scsi_Cmnd *))
  *  - SCp.phase records this command's SRCID_ER bit setting
  */
 
-   if (cmd-use_sg) {
-   cmd-SCp.buffer = (struct scatterlist *) cmd-request_buffer;
-   cmd-SCp.buffers_residual = cmd-use_sg - 1;
+   if (scsi_bufflen(cmd)) {
+   cmd-SCp.buffer = scsi_sglist(cmd);
+   cmd-SCp.buffers_residual = scsi_sg_count(cmd) - 1;
cmd-SCp.ptr = (char *) page_address(cmd-SCp.buffer-page) + 
cmd-SCp.buffer-offset;
cmd-SCp.this_residual = cmd-SCp.buffer-length;
} else {
cmd-SCp.buffer = NULL;
cmd-SCp.buffers_residual = 0;
-   cmd-SCp.ptr = (char *) cmd-request_buffer;
-   cmd-SCp.this_residual = cmd-request_bufflen;
+   cmd-SCp.ptr = NULL;
+   cmd-SCp.this_residual = 0;
}
cmd-SCp.have_data_in = 0;
 
-- 
1.5.3.1


-
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 09/24] libata-scsi: convert to use the data buffer accessors

2007-09-11 Thread Jeff Garzik

I would much rather see the !use_sg cleanup in a separate patch series...

Jeff



-
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 19/24] wd33c93.c: convert to accessors and !use_sg cleanup

2007-09-11 Thread Boaz Harrosh

 - convert to accessors and !use_sg cleanup

Signed-off-by: Boaz Harrosh [EMAIL PROTECTED]
---
 drivers/scsi/wd33c93.c |   10 +-
 1 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/scsi/wd33c93.c b/drivers/scsi/wd33c93.c
index b92ff04..0e3bdfb 100644
--- a/drivers/scsi/wd33c93.c
+++ b/drivers/scsi/wd33c93.c
@@ -407,17 +407,17 @@ wd33c93_queuecommand(struct scsi_cmnd *cmd,
  *  - SCp.phase records this command's SRCID_ER bit setting
  */
 
-   if (cmd-use_sg) {
-   cmd-SCp.buffer = (struct scatterlist *) cmd-request_buffer;
-   cmd-SCp.buffers_residual = cmd-use_sg - 1;
+   if (scsi_bufflen(cmd)) {
+   cmd-SCp.buffer = scsi_sglist(cmd);
+   cmd-SCp.buffers_residual = scsi_sg_count(cmd) - 1;
cmd-SCp.ptr = page_address(cmd-SCp.buffer-page) +
cmd-SCp.buffer-offset;
cmd-SCp.this_residual = cmd-SCp.buffer-length;
} else {
cmd-SCp.buffer = NULL;
cmd-SCp.buffers_residual = 0;
-   cmd-SCp.ptr = (char *) cmd-request_buffer;
-   cmd-SCp.this_residual = cmd-request_bufflen;
+   cmd-SCp.ptr = NULL;
+   cmd-SCp.this_residual = 0;
}
 
 /* WD docs state that at the conclusion of a LEVEL2 command, the
-- 
1.5.3.1


-
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Subject: [PATCH 22/24] Remove psi240i driver from kernel

2007-09-11 Thread Boaz Harrosh

  The psi240i driver is still written for cmnd-request_buffer
  as a char pointer to actual data. There was never any attempt
  to use the scatterlist option.

  - remove all source files (3) from drivers/scsi
  - Remove from Makefile and Kconfig

Signed-off-by: Boaz Harrosh [EMAIL PROTECTED]
---
 drivers/scsi/Kconfig|   11 -
 drivers/scsi/Makefile   |1 -
 drivers/scsi/psi240i.c  |  689 ---
 drivers/scsi/psi240i.h  |  315 -
 drivers/scsi/psi_chip.h |  195 -
 5 files changed, 0 insertions(+), 1211 deletions(-)
 delete mode 100644 drivers/scsi/psi240i.c
 delete mode 100644 drivers/scsi/psi240i.h
 delete mode 100644 drivers/scsi/psi_chip.h

diff --git a/drivers/scsi/Kconfig b/drivers/scsi/Kconfig
index 7877dfd..294b9f5 100644
--- a/drivers/scsi/Kconfig
+++ b/drivers/scsi/Kconfig
@@ -1265,17 +1265,6 @@ config SCSI_PAS16
  To compile this driver as a module, choose M here: the
  module will be called pas16.
 
-config SCSI_PSI240I
-   tristate PSI240i support
-   depends on ISA  SCSI
-   help
- This is support for the PSI240i EIDE interface card which acts as a
- SCSI host adapter.  Please read the SCSI-HOWTO, available from
- http://www.tldp.org/docs.html#howto.
-
- To compile this driver as a module, choose M here: the
- module will be called psi240i.
-
 config SCSI_QLOGIC_FAS
tristate Qlogic FAS SCSI support
depends on ISA  SCSI
diff --git a/drivers/scsi/Makefile b/drivers/scsi/Makefile
index 6141389..ffb800d 100644
--- a/drivers/scsi/Makefile
+++ b/drivers/scsi/Makefile
@@ -59,7 +59,6 @@ obj-$(CONFIG_MVME16x_SCSI)+= 53c700.o mvme16x_scsi.o
 obj-$(CONFIG_BVME6000_SCSI)+= 53c700.o bvme6000_scsi.o
 obj-$(CONFIG_SCSI_SIM710)  += 53c700.o sim710.o
 obj-$(CONFIG_SCSI_ADVANSYS)+= advansys.o
-obj-$(CONFIG_SCSI_PSI240I) += psi240i.o
 obj-$(CONFIG_SCSI_BUSLOGIC)+= BusLogic.o
 obj-$(CONFIG_SCSI_DPT_I2O) += dpt_i2o.o
 obj-$(CONFIG_SCSI_U14_34F) += u14-34f.o
diff --git a/drivers/scsi/psi240i.c b/drivers/scsi/psi240i.c
deleted file mode 100644
index 899e89d..000
--- a/drivers/scsi/psi240i.c
+++ /dev/null
@@ -1,689 +0,0 @@
-/*+M*
- * Perceptive Solutions, Inc. PSI-240I device driver proc support for Linux.
- *
- * Copyright (c) 1997 Perceptive Solutions, Inc.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, or (at your option)
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; see the file COPYING.  If not, write to
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- *
- * File Name:  psi240i.c
- *
- * Description:SCSI driver for the PSI240I EIDE interface card.
- *
- *-M*/
-
-#include linux/module.h
-
-#include linux/blkdev.h
-#include linux/kernel.h
-#include linux/types.h
-#include linux/string.h
-#include linux/ioport.h
-#include linux/delay.h
-#include linux/interrupt.h
-#include linux/proc_fs.h
-#include linux/spinlock.h
-#include linux/stat.h
-
-#include asm/dma.h
-#include asm/system.h
-#include asm/io.h
-#include scsi.h
-#include scsi/scsi_host.h
-
-#include psi240i.h
-#include psi_chip.h
-
-//#define DEBUG 1
-
-#ifdef DEBUG
-#define DEB(x) x
-#else
-#define DEB(x)
-#endif
-
-#define MAXBOARDS 6/* Increase this and the sizes of the arrays below, if 
you need more. */
-
-#definePORT_DATA   0
-#definePORT_ERROR  1
-#definePORT_SECTOR_COUNT   2
-#definePORT_LBA_0  3
-#definePORT_LBA_8  4
-#definePORT_LBA_16 5
-#definePORT_LBA_24 6
-#definePORT_STAT_CMD   7
-#definePORT_SEL_FAIL   8
-#definePORT_IRQ_STATUS 9
-#definePORT_ADDRESS10
-#definePORT_FAIL   11
-#definePORT_ALT_STAT   12
-
-typedef struct
-   {
-   UCHAR   device; // device code
-   UCHAR   byte6;  // device 
select register image
-   UCHAR   spigot; // 

[PATCH 23/24] wd7000.c - proper fix for boards without sg support

2007-09-11 Thread Boaz Harrosh

  - code used to set sg_tablesize to zero for board revision
less than 6. This is no longer supported, therefore I
use sg_tablesize=1 and open code the sg handling for that case.
  - Get rid of use of SG_NONE which will be removed soon.

Signed-off-by: Boaz Harrosh [EMAIL PROTECTED]
---
 drivers/scsi/wd7000.c |   12 ++--
 1 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/scsi/wd7000.c b/drivers/scsi/wd7000.c
index d6fd425..11db201 100644
--- a/drivers/scsi/wd7000.c
+++ b/drivers/scsi/wd7000.c
@@ -1108,13 +1108,10 @@ static int wd7000_queuecommand(struct scsi_cmnd *SCpnt,
scb-host = host;
 
nseg = scsi_sg_count(SCpnt);
-   if (nseg) {
+   if (nseg  1) {
struct scatterlist *sg;
unsigned i;
 
-   if (SCpnt-device-host-sg_tablesize == SG_NONE) {
-   panic(wd7000_queuecommand: scatter/gather not 
supported.\n);
-   }
dprintk(Using scatter/gather with %d elements.\n, nseg);
 
sgb = scb-sgb;
@@ -1128,7 +1125,10 @@ static int wd7000_queuecommand(struct scsi_cmnd *SCpnt,
}
} else {
scb-op = 0;
-   any2scsi(scb-dataptr, isa_virt_to_bus(scsi_sglist(SCpnt)));
+   if (nseg) {
+   struct scatterlist *sg = scsi_sglist(SCpnt);
+   any2scsi(scb-dataptr, isa_page_to_bus(sg-page) + 
sg-offset);
+   }
any2scsi(scb-maxlen, scsi_bufflen(SCpnt));
}
 
@@ -1524,7 +1524,7 @@ static __init int wd7000_detect(struct scsi_host_template 
*tpnt)
 *  For boards before rev 6.0, scatter/gather 
isn't supported.
 */
if (host-rev1  6)
-   sh-sg_tablesize = SG_NONE;
+   sh-sg_tablesize = 1;
 
present++;  /* count it */
 
-- 
1.5.3.1


-
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 21/24] qlogicpti.c: convert to accessors and !use_sg cleanup

2007-09-11 Thread Boaz Harrosh

 - convert to accessors and !use_sg cleanup

[Note: This patch might conflict with upstream patches to this driver.
 If so, please tell me and I'll fix it.]

Signed-off-by: Boaz Harrosh [EMAIL PROTECTED]
---
 drivers/scsi/qlogicpti.c |   54 +
 1 files changed, 11 insertions(+), 43 deletions(-)

diff --git a/drivers/scsi/qlogicpti.c b/drivers/scsi/qlogicpti.c
index 5948872..b685c4f 100644
--- a/drivers/scsi/qlogicpti.c
+++ b/drivers/scsi/qlogicpti.c
@@ -873,11 +873,12 @@ static inline int load_cmd(struct scsi_cmnd *Cmnd, struct 
Command_Entry *cmd,
struct scatterlist *sg;
int i, n;
 
-   if (Cmnd-use_sg) {
+   if (scsi_bufflen(Cmnd)) {
int sg_count;
 
-   sg = (struct scatterlist *) Cmnd-request_buffer;
-   sg_count = sbus_map_sg(qpti-sdev, sg, Cmnd-use_sg, 
Cmnd-sc_data_direction);
+   sg = scsi_sglist(Cmnd);
+   sg_count = sbus_map_sg(qpti-sdev, sg, scsi_sg_count(Cmnd),
+ Cmnd-sc_data_direction);
 
ds = cmd-dataseg;
cmd-segment_cnt = sg_count;
@@ -915,16 +916,6 @@ static inline int load_cmd(struct scsi_cmnd *Cmnd, struct 
Command_Entry *cmd,
}
sg_count -= n;
}
-   } else if (Cmnd-request_bufflen) {
-   Cmnd-SCp.ptr = (char *)(unsigned long)
-   sbus_map_single(qpti-sdev,
-   Cmnd-request_buffer,
-   Cmnd-request_bufflen,
-   Cmnd-sc_data_direction);
-
-   cmd-dataseg[0].d_base = (u32) ((unsigned long)Cmnd-SCp.ptr);
-   cmd-dataseg[0].d_count = Cmnd-request_bufflen;
-   cmd-segment_cnt = 1;
} else {
cmd-dataseg[0].d_base = 0;
cmd-dataseg[0].d_count = 0;
@@ -953,32 +944,15 @@ static inline void update_can_queue(struct Scsi_Host 
*host, u_int in_ptr, u_int
 
 static unsigned int scsi_rbuf_get(struct scsi_cmnd *cmd, unsigned char 
**buf_out)
 {
-   unsigned char *buf;
-   unsigned int buflen;
+   struct scatterlist *sg = scsi_sglist(cmd);
 
-   if (cmd-use_sg) {
-   struct scatterlist *sg;
-
-   sg = (struct scatterlist *) cmd-request_buffer;
-   buf = kmap_atomic(sg-page, KM_IRQ0) + sg-offset;
-   buflen = sg-length;
-   } else {
-   buf = cmd-request_buffer;
-   buflen = cmd-request_bufflen;
-   }
-
-   *buf_out = buf;
-   return buflen;
+   *buf_out = kmap_atomic(sg-page, KM_IRQ0) + sg-offset;
+   return sg-length;
 }
 
 static void scsi_rbuf_put(struct scsi_cmnd *cmd, unsigned char *buf)
 {
-   if (cmd-use_sg) {
-   struct scatterlist *sg;
-
-   sg = (struct scatterlist *) cmd-request_buffer;
-   kunmap_atomic(buf - sg-offset, KM_IRQ0);
-   }
+   kunmap_atomic(buf - scsi_sglist(cmd)-offset, KM_IRQ0);
 }
 
 /*
@@ -1278,17 +1252,11 @@ static struct scsi_cmnd *qlogicpti_intr_handler(struct 
qlogicpti *qpti)
else
Cmnd-result = DID_ERROR  16;
 
-   if (Cmnd-use_sg) {
+   if (scsi_bufflen(Cmnd))
sbus_unmap_sg(qpti-sdev,
- (struct scatterlist 
*)Cmnd-request_buffer,
- Cmnd-use_sg,
+ scsi_sglist(Cmnd), scsi_sg_count(Cmnd),
  Cmnd-sc_data_direction);
-   } else if (Cmnd-request_bufflen) {
-   sbus_unmap_single(qpti-sdev,
- (__u32)((unsigned long)Cmnd-SCp.ptr),
- Cmnd-request_bufflen,
- Cmnd-sc_data_direction);
-   }
+
qpti-cmd_count[Cmnd-device-id]--;
sbus_writew(out_ptr, qpti-qregs + MBOX5);
Cmnd-host_scribble = (unsigned char *) done_queue;
-- 
1.5.3.1


-
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 24/24] ide-scsi.c: convert to data accessors and !use_sg cleanup

2007-09-11 Thread Boaz Harrosh

 - Convert ide-scsi to the new data accessors and cleanup
   the !use_sg code paths.

  Inspecting old code I can see places that still assume
  scsi_cmnd-request_buffer is a linear char pointer. Though I
  admit this assumption is hidden behind a flag:
  test_bit(PC_TRANSFORM, pc-flags).
  I have commented out the offending code and put a
  WARN_ON(1) in it's place. So if there is missing functionality
  it will complain but will not crash the kernel.
  Maintainer of this driver please inspect if this functionality
  is still needed, if not then please remove the commented code.

  Thanks

Signed-off-by: Boaz Harrosh [EMAIL PROTECTED]
---
 drivers/scsi/ide-scsi.c |   53 ++
 1 files changed, 34 insertions(+), 19 deletions(-)

diff --git a/drivers/scsi/ide-scsi.c b/drivers/scsi/ide-scsi.c
index 1cc01ac..e3e7d65 100644
--- a/drivers/scsi/ide-scsi.c
+++ b/drivers/scsi/ide-scsi.c
@@ -175,7 +175,8 @@ static void idescsi_input_buffers (ide_drive_t *drive, 
idescsi_pc_t *pc, unsigne
char *buf;
 
while (bcount) {
-   if (pc-sg - (struct scatterlist *) 
pc-scsi_cmd-request_buffer  pc-scsi_cmd-use_sg) {
+   if (pc-sg - scsi_sglist(pc-scsi_cmd) 
+scsi_sg_count(pc-scsi_cmd)) {
printk (KERN_ERR ide-scsi: scatter gather table too 
small, discarding data\n);
idescsi_discard_data (drive, bcount);
return;
@@ -210,7 +211,8 @@ static void idescsi_output_buffers (ide_drive_t *drive, 
idescsi_pc_t *pc, unsign
char *buf;
 
while (bcount) {
-   if (pc-sg - (struct scatterlist *) 
pc-scsi_cmd-request_buffer  pc-scsi_cmd-use_sg) {
+   if (pc-sg - scsi_sglist(pc-scsi_cmd) 
+scsi_sg_count(pc-scsi_cmd)) {
printk (KERN_ERR ide-scsi: scatter gather table too 
small, padding with zeros\n);
idescsi_output_zeros (drive, bcount);
return;
@@ -260,6 +262,10 @@ static inline void idescsi_transform_pc1 (ide_drive_t 
*drive, idescsi_pc_t *pc)
unsigned short new_len;
if (!scsi_buf)
return;
+   /* FIXME: see comment below at idescsi_transform_pc2 */
+   WARN_ON(1);
+
+#if 0
if ((atapi_buf = kmalloc(pc-buffer_size + 4, 
GFP_ATOMIC)) == NULL)
return;
memset(atapi_buf, 0, pc-buffer_size + 4);
@@ -281,12 +287,28 @@ static inline void idescsi_transform_pc1 (ide_drive_t 
*drive, idescsi_pc_t *pc)
pc-buffer = atapi_buf;
pc-request_transfer += 4;
pc-buffer_size += 4;
+#endif
}
}
 }
 
 static inline void idescsi_transform_pc2 (ide_drive_t *drive, idescsi_pc_t *pc)
 {
+   if (!test_bit(PC_TRANSFORM, pc-flags))
+   return;
+
+   /*
+* FIXME: if code reached here then this driver is not
+* working for sure. If it is dead code then it can
+* surly be properly removed.
+*
+* Same is with above idescsi_transform_pc1() which
+* assumes pc-buffer must have something which surly
+* does not.
+*/
+WARN_ON(1);
+
+#if 0
u8 *atapi_buf = pc-buffer;
u8 *sc = pc-scsi_cmd-cmnd;
u8 *scsi_buf = pc-scsi_cmd-request_buffer;
@@ -308,6 +330,7 @@ static inline void idescsi_transform_pc2 (ide_drive_t 
*drive, idescsi_pc_t *pc)
}
if (atapi_buf  atapi_buf != scsi_buf)
kfree(atapi_buf);
+#endif
 }
 
 static void hexdump(u8 *x, int len)
@@ -435,6 +458,7 @@ static int idescsi_end_request (ide_drive_t *drive, int 
uptodate, int nrsecs)
} else {
pc-scsi_cmd-result = DID_OK  16;
idescsi_transform_pc2 (drive, pc);
+#if 0
if (log) {
printk (ide-scsi: %s: suc %lu, drive-name, 
pc-scsi_cmd-serial_number);
if (!test_bit(PC_WRITING, pc-flags)  
pc-actually_transferred  pc-actually_transferred = 1024  pc-buffer) {
@@ -443,6 +467,7 @@ static int idescsi_end_request (ide_drive_t *drive, int 
uptodate, int nrsecs)
hexdump(scsi_buf, min_t(unsigned, 16, 
pc-scsi_cmd-request_bufflen));
} else printk(\n);
}
+#endif
}
host = pc-scsi_cmd-device-host;
spin_lock_irqsave(host-host_lock, flags);
@@ -637,19 +662,14 @@ static int idescsi_map_sg(ide_drive_t *drive, 
idescsi_pc_t *pc)
return 1;
 
sg = hwif-sg_table;
-   scsi_sg = pc-scsi_cmd-request_buffer;
-   segments = pc-scsi_cmd-use_sg;
+   scsi_sg = scsi_sglist(pc-scsi_cmd);
+   segments = scsi_sg_count(pc-scsi_cmd);
 
   

Re: [PATCH 09/24] libata-scsi: convert to use the data buffer accessors

2007-09-11 Thread Boaz Harrosh
On Wed, Sep 12 2007 at 3:09 +0300, Jeff Garzik [EMAIL PROTECTED] wrote:
 I would much rather see the !use_sg cleanup in a separate patch series...
 
   Jeff
 
 
 

Sure. Only its 3:22 am (of the next day) here.
And I'm going on an Hebrew-new-year holiday
so it will only be for Sunday next.

Sorry
Boaz
-
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 09/24] libata-scsi: convert to use the data buffer accessors

2007-09-11 Thread Matthew Dharm
On Tue, Sep 11, 2007 at 08:09:51PM -0400, Jeff Garzik wrote:
 I would much rather see the !use_sg cleanup in a separate patch series...

Are we really sure this can all go?  No requests, not even ones from SG_IO
will ever use the non-sg paths?

Matt

-- 
Matthew Dharm  Home: [EMAIL PROTECTED] 
Maintainer, Linux USB Mass Storage Driver

I could always suspend a few hundred accounts and watch what happens.
-- Tanya
User Friendly, 7/31/1998


pgpgOsi3ElyJ1.pgp
Description: PGP signature