linux-scsi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [patchset 0/24] Lots of the Accessors patches and !use_sg cleanup
@ 2007-09-11 20:23 Boaz Harrosh
  2007-09-11 20:50 ` Cameron, Steve
                   ` (27 more replies)
  0 siblings, 28 replies; 59+ messages in thread
From: Boaz Harrosh @ 2007-09-11 20:23 UTC (permalink / raw)
  To: James Bottomley, FUJITA Tomonori, Greg Kroah-Hartman, Alan Stern,
	Matthew

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 <gregkh@suse.de>, Alan Stern <stern@rowland.harvard.edu>,
	Matthew Dharm <mdharm-usb@one-eyed-alien.net>
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
0005 	drivers/usb/storage/isd200.c

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

[esp family] - Maciej W. Rozycki <macro@linux-mips.org>
0020 	drivers/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 <rmk@arm.linux.org.uk>
0007 	drivers/scsi/arm/acornscsi.c drivers/scsi/arm/scsi.h

[other drivers]
0008 	drivers/scsi/pcmcia/nsp_cs.c - YOKOTA Hiroshi <yokota@netlab.is.tsukuba.ac.jp>
0009 	drivers/ata/libata-scsi.c - Jeff Garzik <jeff@garzik.org>
0010 	drivers/scsi/eata_pio.c - Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ?
0011 	drivers/scsi/a2091.c - ?
0012 	drivers/scsi/a3000.c - ? 
0013 	drivers/scsi/aha1542.c - ? 
0014 	drivers/scsi/atp870u.c - ? 
0015 	drivers/scsi/fd_mcs.c - ? 
0016 	drivers/scsi/imm.c - ? 
0017 	drivers/scsi/in2000.c - ? 
0018 	drivers/scsi/ppa.c - ? 
0019 	drivers/scsi/wd33c93.c - ? 
0021 	drivers/scsi/qlogicpti.c - David S. Miller <davem@davemloft.net>, Mark Fortescue <mark@mtfhpc.demon.co.uk>
0024 	drivers/scsi/ide-scsi.c - Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>

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

[fixes]
0023 	drivers/scsi/wd7000.c - ? 

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

* RE: [patchset 0/24] Lots of the Accessors patches and !use_sg cleanup
  2007-09-11 20:23 [patchset 0/24] Lots of the Accessors patches and !use_sg cleanup Boaz Harrosh
@ 2007-09-11 20:50 ` Cameron, Steve
  2007-09-11 21:05   ` Boaz Harrosh
  2007-09-11 23:49 ` [PATCH 01/24] usb: transport - convert to accessors and !use_sg code path removal Boaz Harrosh
                   ` (26 subsequent siblings)
  27 siblings, 1 reply; 59+ messages in thread
From: Cameron, Steve @ 2007-09-11 20:50 UTC (permalink / raw)
  To: Boaz Harrosh, linux-scsi


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












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

* Re: [patchset 0/24] Lots of the Accessors patches and !use_sg cleanup
  2007-09-11 20:50 ` Cameron, Steve
@ 2007-09-11 21:05   ` Boaz Harrosh
  0 siblings, 0 replies; 59+ messages in thread
From: Boaz Harrosh @ 2007-09-11 21:05 UTC (permalink / raw)
  To: Cameron, Steve; +Cc: linux-scsi

On Tue, Sep 11 2007 at 23:50 +0300, "Cameron, Steve" <Steve.Cameron@hp.com> wrote:
> drivers/block/cciss_scsi.c

Already done by Tomo
41ce639a1c50cb936f058f52f99f65740e3f550e 
  cciss: convert to use the data buffer accessors

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

* [PATCH 01/24] usb: transport - convert to accessors and !use_sg code path removal
  2007-09-11 20:23 [patchset 0/24] Lots of the Accessors patches and !use_sg cleanup Boaz Harrosh
  2007-09-11 20:50 ` Cameron, Steve
@ 2007-09-11 23:49 ` Boaz Harrosh
  2007-09-11 23:50 ` [PATCH 02/24] usb: protocol.c " Boaz Harrosh
                   ` (25 subsequent siblings)
  27 siblings, 0 replies; 59+ messages in thread
From: Boaz Harrosh @ 2007-09-11 23:49 UTC (permalink / raw)
  To: James Bottomley, FUJITA Tomonori, Greg Kroah-Hartman, Alan Stern,
	Matthew


  - 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 <bharrosh@panasas.com>
---
 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 usb_stor_Bulk_transport(struct scsi_cmnd *srb, struct us_data *us)
 {
 	struct bulk_cb_wrap *bcb = (struct bulk_cb_wrap *) us->iobuf;
 	struct bulk_cs_wrap *bcs = (struct bulk_cs_wrap *) us->iobuf;
-	unsigned int transfer_length = srb->request_bufflen;
+	unsigned int transfer_length = scsi_bufflen(srb);
 	unsigned int residue;
 	int result;
 	int fake_sense = 0;
@@ -955,9 +966,7 @@ int usb_stor_Bulk_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("Bulk data transfer result 0x%x\n", result);
 		if (result == USB_STOR_XFER_ERROR)
 			return USB_STOR_TRANSPORT_ERROR;
@@ -1036,7 +1045,8 @@ int usb_stor_Bulk_transport(struct scsi_cmnd *srb, struct us_data *us)
 	if (residue) {
 		if (!(us->flags & US_FL_IGNORE_RESIDUE)) {
 			residue = min(residue, transfer_length);
-			srb->resid = max(srb->resid, (int) residue);
+			scsi_set_resid(srb, max(scsi_get_resid(srb),
+			                                       (int) residue));
 		}
 	}
 
diff --git a/drivers/usb/storage/transport.h b/drivers/usb/storage/transport.h
index 633a715..ada7c2f 100644
--- a/drivers/usb/storage/transport.h
+++ b/drivers/usb/storage/transport.h
@@ -139,6 +139,8 @@ extern int usb_stor_bulk_transfer_buf(struct us_data *us, unsigned int pipe,
 		void *buf, unsigned int length, unsigned int *act_len);
 extern int usb_stor_bulk_transfer_sg(struct us_data *us, unsigned int pipe,
 		void *buf, unsigned int length, int use_sg, int *residual);
+extern int usb_stor_bulk_srb(struct us_data* us, unsigned int pipe,
+		struct scsi_cmnd* srb);
 
 extern int usb_stor_port_reset(struct us_data *us);
 #endif
-- 
1.5.3.1



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

* [PATCH 02/24] usb: protocol.c - convert to accessors and !use_sg code path removal
  2007-09-11 20:23 [patchset 0/24] Lots of the Accessors patches and !use_sg cleanup Boaz Harrosh
  2007-09-11 20:50 ` Cameron, Steve
  2007-09-11 23:49 ` [PATCH 01/24] usb: transport - convert to accessors and !use_sg code path removal Boaz Harrosh
@ 2007-09-11 23:50 ` Boaz Harrosh
  2007-09-11 23:51 ` [PATCH 03/24] usb: shuttle_usbat.c " Boaz Harrosh
                   ` (24 subsequent siblings)
  27 siblings, 0 replies; 59+ messages in thread
From: Boaz Harrosh @ 2007-09-11 23:50 UTC (permalink / raw)
  To: James Bottomley, FUJITA Tomonori, Greg Kroah-Hartman, Alan Stern,
	Matthew


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

Signed-off-by: Boaz Harrosh <bharrosh@panasas.com>
---
 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
+	 * 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 < scsi_sg_count(srb)) {
+		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;
 		}
 	}
 
@@ -249,6 +227,6 @@ void usb_stor_set_xfer_buf(unsigned char *buffer,
 
 	usb_stor_access_xfer_buf(buffer, buflen, srb, &index, &offset,
 			TO_XFER_BUF);
-	if (buflen < srb->request_bufflen)
-		srb->resid = srb->request_bufflen - buflen;
+	if (buflen < scsi_bufflen(srb))
+		scsi_set_resid(srb, scsi_bufflen(srb) - buflen);
 }
-- 
1.5.3.1



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

* [PATCH 03/24] usb: shuttle_usbat.c - convert to accessors and !use_sg code path removal
  2007-09-11 20:23 [patchset 0/24] Lots of the Accessors patches and !use_sg cleanup Boaz Harrosh
                   ` (2 preceding siblings ...)
  2007-09-11 23:50 ` [PATCH 02/24] usb: protocol.c " Boaz Harrosh
@ 2007-09-11 23:51 ` Boaz Harrosh
  2007-09-11 23:51 ` [PATCH 04/24] usb: freecom.c & sddr09.c - convert to accessors and !use_sg cleanup Boaz Harrosh
                   ` (23 subsequent siblings)
  27 siblings, 0 replies; 59+ messages in thread
From: Boaz Harrosh @ 2007-09-11 23:51 UTC (permalink / raw)
  To: James Bottomley, FUJITA Tomonori, Greg Kroah-Hartman, Alan Stern,
	Matthew


 - 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 <bharrosh@panasas.com>
---
 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,
+			      void* buffer,
 			      int len,
 			      int use_sg)
 {
@@ -1171,15 +1171,15 @@ static int usbat_hp8200e_handle_read10(struct us_data *us,
 	US_DEBUGP("handle_read10: transfersize %d\n",
 		srb->transfersize);
 
-	if (srb->request_bufflen < 0x10000) {
+	if (scsi_bufflen(srb) < 0x10000) {
 
 		result = usbat_hp8200e_rw_block_test(us, USBAT_ATA, 
 			registers, data, 19,
 			USBAT_ATA_DATA, USBAT_ATA_STATUS, 0xFD,
 			(USBAT_QUAL_FCQ | USBAT_QUAL_ALQ),
 			DMA_FROM_DEVICE,
-			srb->request_buffer, 
-			srb->request_bufflen, srb->use_sg, 1);
+			scsi_sglist(srb),
+			scsi_bufflen(srb), scsi_sg_count(srb), 1);
 
 		return result;
 	}
@@ -1197,7 +1197,7 @@ static int usbat_hp8200e_handle_read10(struct us_data *us,
 		len <<= 16;
 		len |= data[7+7];
 		US_DEBUGP("handle_read10: GPCMD_READ_CD: len %d\n", len);
-		srb->transfersize = srb->request_bufflen/len;
+		srb->transfersize = scsi_bufflen(srb)/len;
 	}
 
 	if (!srb->transfersize)  {
@@ -1214,7 +1214,7 @@ static int usbat_hp8200e_handle_read10(struct us_data *us,
 
 	len = (65535/srb->transfersize) * srb->transfersize;
 	US_DEBUGP("Max read is %d bytes\n", len);
-	len = min(len, srb->request_bufflen);
+	len = min(len, scsi_bufflen(srb));
 	buffer = kmalloc(len, GFP_NOIO);
 	if (buffer == NULL) /* bloody hell! */
 		return USB_STOR_TRANSPORT_FAILED;
@@ -1226,10 +1226,10 @@ static int usbat_hp8200e_handle_read10(struct us_data *us,
 	sg_segment = 0; /* for keeping track of where we are in */
 	sg_offset = 0;  /* the scatter/gather list */
 
-	while (transferred != srb->request_bufflen) {
+	while (transferred != scsi_bufflen(srb)) {
 
-		if (len > srb->request_bufflen - transferred)
-			len = srb->request_bufflen - transferred;
+		if (len > scsi_bufflen(srb) - transferred)
+			len = scsi_bufflen(srb) - transferred;
 
 		data[3] = len&0xFF; 	  /* (cylL) = expected length (L) */
 		data[4] = (len>>8)&0xFF;  /* (cylH) = expected length (H) */
@@ -1265,7 +1265,7 @@ static int usbat_hp8200e_handle_read10(struct us_data *us,
 		transferred += len;
 		sector += len / srb->transfersize;
 
-	} /* while transferred != srb->request_bufflen */
+	} /* while transferred != scsi_bufflen(srb) */
 
 	kfree(buffer);
 	return result;
@@ -1433,9 +1433,8 @@ static int usbat_hp8200e_transport(struct scsi_cmnd *srb, struct us_data *us)
 	unsigned char data[32];
 	unsigned int len;
 	int i;
-	char string[64];
 
-	len = srb->request_bufflen;
+	len = scsi_bufflen(srb);
 
 	/* Send A0 (ATA PACKET COMMAND).
 	   Note: I guess we're never going to get any of the ATA
@@ -1476,8 +1475,8 @@ static int usbat_hp8200e_transport(struct scsi_cmnd *srb, struct us_data *us)
 			USBAT_ATA_DATA, USBAT_ATA_STATUS, 0xFD,
 			(USBAT_QUAL_FCQ | USBAT_QUAL_ALQ),
 			DMA_TO_DEVICE,
-			srb->request_buffer, 
-			len, srb->use_sg, 10);
+			scsi_sglist(srb),
+			len, scsi_sg_count(srb), 10);
 
 		if (result == USB_STOR_TRANSPORT_GOOD) {
 			transferred += len;
@@ -1544,23 +1543,8 @@ static int usbat_hp8200e_transport(struct scsi_cmnd *srb, struct us_data *us)
 			len = *status;
 
 
-		result = usbat_read_block(us, srb->request_buffer, len, srb->use_sg);
-
-		/* Debug-print the first 32 bytes of the transfer */
-
-		if (!srb->use_sg) {
-			string[0] = 0;
-			for (i=0; i<len && i<32; i++) {
-				sprintf(string+strlen(string), "%02X ",
-				  ((unsigned char *)srb->request_buffer)[i]);
-				if ((i%16)==15) {
-					US_DEBUGP("%s\n", string);
-					string[0] = 0;
-				}
-			}
-			if (string[0]!=0)
-				US_DEBUGP("%s\n", string);
-		}
+		result = usbat_read_block(us, scsi_sglist(srb), len,
+			                                   scsi_sg_count(srb));
 	}
 
 	return result;
-- 
1.5.3.1



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

* [PATCH 04/24] usb: freecom.c & sddr09.c - convert to accessors and !use_sg cleanup
  2007-09-11 20:23 [patchset 0/24] Lots of the Accessors patches and !use_sg cleanup Boaz Harrosh
                   ` (3 preceding siblings ...)
  2007-09-11 23:51 ` [PATCH 03/24] usb: shuttle_usbat.c " Boaz Harrosh
@ 2007-09-11 23:51 ` Boaz Harrosh
  2007-09-11 23:53 ` [PATCH 05/24] isd200.c: use one-element sg list in issuing commands Boaz Harrosh
                   ` (22 subsequent siblings)
  27 siblings, 0 replies; 59+ messages in thread
From: Boaz Harrosh @ 2007-09-11 23:51 UTC (permalink / raw)
  To: James Bottomley, FUJITA Tomonori, Greg Kroah-Hartman, Alan Stern,
	Matthew


 - 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 <bharrosh@panasas.com>
---
 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



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

* [PATCH 05/24] isd200.c: use one-element sg list in issuing commands
  2007-09-11 20:23 [patchset 0/24] Lots of the Accessors patches and !use_sg cleanup Boaz Harrosh
                   ` (4 preceding siblings ...)
  2007-09-11 23:51 ` [PATCH 04/24] usb: freecom.c & sddr09.c - convert to accessors and !use_sg cleanup Boaz Harrosh
@ 2007-09-11 23:53 ` Boaz Harrosh
  2007-09-11 23:54 ` [PATCH 06/24] NCR5380 familly convert to accessors & !use_sg cleanup Boaz Harrosh
                   ` (21 subsequent siblings)
  27 siblings, 0 replies; 59+ messages in thread
From: Boaz Harrosh @ 2007-09-11 23:53 UTC (permalink / raw)
  To: James Bottomley, FUJITA Tomonori, Greg Kroah-Hartman, Alan Stern,
	Matthew


  - 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 <bharrosh@panasas.com>
---
 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 hd_driveid);
+		isd200_set_srb(info, DMA_FROM_DEVICE, info->id,
+		                                sizeof(struct hd_driveid));
 		break;
 
 	default:
 		US_DEBUGP("Error: Undefined action %d\n",action);
-		break;
+		return ISD200_ERROR;
 	}
 
 	memcpy(srb->cmnd, &ata, sizeof(ata.generic));
@@ -590,7 +614,7 @@ static void isd200_invoke_transport( struct us_data *us,
 		return;
 	}
 
-	if ((srb->resid > 0) &&
+	if ((scsi_get_resid(srb) > 0) &&
 	    !((srb->cmnd[0] == REQUEST_SENSE) ||
 	      (srb->cmnd[0] == INQUIRY) ||
 	      (srb->cmnd[0] == MODE_SENSE) ||
@@ -1114,7 +1138,6 @@ static int isd200_get_inquiry_data( struct us_data *us )
 	return(retStatus);
 }
 
-
 /**************************************************************************
  * isd200_scsi_to_ata
  *									 
@@ -1163,7 +1186,7 @@ static int isd200_scsi_to_ata(struct scsi_cmnd *srb, struct us_data *us,
 			ataCdb->generic.TransferBlockSize = 1;
 			ataCdb->generic.RegisterSelect = REG_COMMAND;
 			ataCdb->write.CommandByte = ATA_COMMAND_GET_MEDIA_STATUS;
-			srb->request_bufflen = 0;
+			isd200_srb_set_bufflen(srb, 0);
 		} else {
 			US_DEBUGP("   Media Status not supported, just report okay\n");
 			srb->result = SAM_STAT_GOOD;
@@ -1181,7 +1204,7 @@ static int isd200_scsi_to_ata(struct scsi_cmnd *srb, struct us_data *us,
 			ataCdb->generic.TransferBlockSize = 1;
 			ataCdb->generic.RegisterSelect = REG_COMMAND;
 			ataCdb->write.CommandByte = ATA_COMMAND_GET_MEDIA_STATUS;
-			srb->request_bufflen = 0;
+			isd200_srb_set_bufflen(srb, 0);
 		} else {
 			US_DEBUGP("   Media Status not supported, just report okay\n");
 			srb->result = SAM_STAT_GOOD;
@@ -1287,7 +1310,7 @@ static int isd200_scsi_to_ata(struct scsi_cmnd *srb, struct us_data *us,
 			ataCdb->generic.RegisterSelect = REG_COMMAND;
 			ataCdb->write.CommandByte = (srb->cmnd[4] & 0x1) ?
 				WIN_DOORLOCK : WIN_DOORUNLOCK;
-			srb->request_bufflen = 0;
+			isd200_srb_set_bufflen(srb, 0);
 		} else {
 			US_DEBUGP("   Not removeable media, just report okay\n");
 			srb->result = SAM_STAT_GOOD;
@@ -1313,7 +1336,7 @@ static int isd200_scsi_to_ata(struct scsi_cmnd *srb, struct us_data *us,
 			ataCdb->generic.TransferBlockSize = 1;
 			ataCdb->generic.RegisterSelect = REG_COMMAND;
 			ataCdb->write.CommandByte = ATA_COMMAND_GET_MEDIA_STATUS;
-			srb->request_bufflen = 0;
+			isd200_srb_set_bufflen(srb, 0);
 		} else {
 			US_DEBUGP("   Nothing to do, just report okay\n");
 			srb->result = SAM_STAT_GOOD;
@@ -1422,7 +1445,7 @@ int isd200_Initialization(struct us_data *us)
 
 void isd200_ata_command(struct scsi_cmnd *srb, struct us_data *us)
 {
-	int sendToTransport = 1;
+	int sendToTransport = 1, orig_bufflen;
 	union ata_cdb ataCdb;
 
 	/* Make sure driver was initialized */
@@ -1430,11 +1453,14 @@ void isd200_ata_command(struct scsi_cmnd *srb, struct us_data *us)
 	if (us->extra == NULL)
 		US_DEBUGP("ERROR Driver not initialized\n");
 
-	/* Convert command */
-	srb->resid = 0;
+	scsi_set_resid(srb, 0);
+	/* scsi_bufflen might change in protocol translation to ata */
+	orig_bufflen = scsi_bufflen(srb);
 	sendToTransport = isd200_scsi_to_ata(srb, us, &ataCdb);
 
 	/* send the command to the transport layer */
 	if (sendToTransport)
 		isd200_invoke_transport(us, srb, &ataCdb);
+
+	isd200_srb_set_bufflen(srb, orig_bufflen);
 }
-- 
1.5.3.1



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

* [PATCH 06/24] NCR5380 familly convert to accessors & !use_sg cleanup
  2007-09-11 20:23 [patchset 0/24] Lots of the Accessors patches and !use_sg cleanup Boaz Harrosh
                   ` (5 preceding siblings ...)
  2007-09-11 23:53 ` [PATCH 05/24] isd200.c: use one-element sg list in issuing commands Boaz Harrosh
@ 2007-09-11 23:54 ` Boaz Harrosh
  2007-09-11 23:55 ` [PATCH 07/24] arm: scsi convert to accessors and " Boaz Harrosh
                   ` (20 subsequent siblings)
  27 siblings, 0 replies; 59+ messages in thread
From: Boaz Harrosh @ 2007-09-11 23:54 UTC (permalink / raw)
  To: James Bottomley, FUJITA Tomonori, Greg Kroah-Hartman, Alan Stern,
	Matthew


  - 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 <bharrosh@panasas.com>
---
 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 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;
 		}
diff --git a/drivers/scsi/sun3_NCR5380.c b/drivers/scsi/sun3_NCR5380.c
index 74081dd..d985108 100644
--- a/drivers/scsi/sun3_NCR5380.c
+++ b/drivers/scsi/sun3_NCR5380.c
@@ -516,9 +516,9 @@ static __inline__ void initialize_SCp(struct 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 *) SGADDR(cmd->SCp.buffer);
 	cmd->SCp.this_residual = cmd->SCp.buffer->length;
 
@@ -529,8 +529,8 @@ static __inline__ void initialize_SCp(struct 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;
     }
     
 }
@@ -936,7 +936,7 @@ static int NCR5380_queue_command(struct scsi_cmnd *cmd,
     }
 # endif
 # ifdef NCR5380_STAT_LIMIT
-    if (cmd->request_bufflen > NCR5380_STAT_LIMIT)
+    if (scsi_bufflen(cmd) > NCR5380_STAT_LIMIT)
 # endif
 	switch (cmd->cmnd[0])
 	{
@@ -944,14 +944,14 @@ static int NCR5380_queue_command(struct scsi_cmnd *cmd,
 	    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;
 	}
@@ -1346,7 +1346,7 @@ static void collect_stats(struct NCR5380_hostdata *hostdata,
 			  struct scsi_cmnd *cmd)
 {
 # ifdef NCR5380_STAT_LIMIT
-    if (cmd->request_bufflen > NCR5380_STAT_LIMIT)
+    if (scsi_bufflen(cmd) > NCR5380_STAT_LIMIT)
 # endif
 	switch (cmd->cmnd[0])
 	{
@@ -1354,14 +1354,14 @@ static void collect_stats(struct NCR5380_hostdata *hostdata,
 	    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;
 	}
-- 
1.5.3.1



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

* [PATCH 07/24] arm: scsi convert to accessors and !use_sg cleanup
  2007-09-11 20:23 [patchset 0/24] Lots of the Accessors patches and !use_sg cleanup Boaz Harrosh
                   ` (6 preceding siblings ...)
  2007-09-11 23:54 ` [PATCH 06/24] NCR5380 familly convert to accessors & !use_sg cleanup Boaz Harrosh
@ 2007-09-11 23:55 ` Boaz Harrosh
  2007-09-12  7:42   ` Russell King
  2007-09-11 23:56 ` [PATCH 08/24] nsp_cs.c convert to data " Boaz Harrosh
                   ` (19 subsequent siblings)
  27 siblings, 1 reply; 59+ messages in thread
From: Boaz Harrosh @ 2007-09-11 23:55 UTC (permalink / raw)
  To: James Bottomley, FUJITA Tomonori, Greg Kroah-Hartman, Alan Stern,
	Matthew


 - convert to accessors and !use_sg cleanup

Signed-off-by: Boaz Harrosh <bharrosh@panasas.com>
---
 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;
+		SCpnt->SCp.buffer = scsi_sglist(SCpnt);
+		SCpnt->SCp.buffers_residual = scsi_sg_count(SCpnt) - 1;
 		SCpnt->SCp.ptr = (char *)
 			 (page_address(SCpnt->SCp.buffer->page) +
 			  SCpnt->SCp.buffer->offset);
 		SCpnt->SCp.this_residual = SCpnt->SCp.buffer->length;
-		SCpnt->SCp.phase = SCpnt->request_bufflen;
+		SCpnt->SCp.phase = scsi_bufflen(SCpnt);
 
 #ifdef BELT_AND_BRACES
 		/*
 		 * Calculate correct buffer length.  Some commands
-		 * come in with the wrong request_bufflen.
+		 * come in with the wrong scsi_bufflen.
 		 */
 		for (buf = 0; buf <= SCpnt->SCp.buffers_residual; buf++)
 			len += SCpnt->SCp.buffer[buf].length;
 
-		if (SCpnt->request_bufflen != len)
+		if (scsi_bufflen(SCpnt) != len) {
+			WARN_ON(1);
 			printk(KERN_WARNING "scsi%d.%c: bad request buffer "
 			       "length %d, should be %ld\n", SCpnt->device->host->host_no,
-			       '0' + SCpnt->device->id, SCpnt->request_bufflen, len);
-		SCpnt->request_bufflen = len;
+			       '0' + SCpnt->device->id, scsi_bufflen(SCpnt), len);
+		}
 #endif
 	} else {
-		SCpnt->SCp.ptr = (unsigned char *)SCpnt->request_buffer;
-		SCpnt->SCp.this_residual = SCpnt->request_bufflen;
-		SCpnt->SCp.phase = SCpnt->request_bufflen;
-	}
-
-	/*
-	 * If the upper SCSI layers pass a buffer, but zero length,
-	 * we aren't interested in the buffer pointer.
-	 */
-	if (SCpnt->SCp.this_residual == 0 && SCpnt->SCp.ptr) {
-#if 0 //def BELT_AND_BRACES
-		printk(KERN_WARNING "scsi%d.%c: zero length buffer passed for "
-		       "command ", SCpnt->host->host_no, '0' + SCpnt->target);
-		__scsi_print_command(SCpnt->cmnd);
-#endif
 		SCpnt->SCp.ptr = NULL;
+		SCpnt->SCp.this_residual = 0;
+		SCpnt->SCp.phase = 0;
 	}
 }
-- 
1.5.3.1



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

* [PATCH 08/24] nsp_cs.c convert to data accessors and !use_sg cleanup
  2007-09-11 20:23 [patchset 0/24] Lots of the Accessors patches and !use_sg cleanup Boaz Harrosh
                   ` (7 preceding siblings ...)
  2007-09-11 23:55 ` [PATCH 07/24] arm: scsi convert to accessors and " Boaz Harrosh
@ 2007-09-11 23:56 ` Boaz Harrosh
  2007-09-11 23:58 ` [PATCH 09/24] libata-scsi: convert to use the data buffer accessors Boaz Harrosh
                   ` (18 subsequent siblings)
  27 siblings, 0 replies; 59+ messages in thread
From: Boaz Harrosh @ 2007-09-11 23:56 UTC (permalink / raw)
  To: James Bottomley, FUJITA Tomonori, Greg Kroah-Hartman, Alan Stern,
	Matthew


  - 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 <bharrosh@panasas.com>
---
 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",
-		data->FifoCount, SCpnt->SCp.ptr, SCpnt->SCp.this_residual, SCpnt->SCp.buffer, SCpnt->SCp.buffers_residual, SCpnt->resid);
+		data->FifoCount, SCpnt->SCp.ptr, SCpnt->SCp.this_residual,
+		SCpnt->SCp.buffer, SCpnt->SCp.buffers_residual,
+		scsi_get_resid(SCpnt));
 
 	time_out = 1000;
 
@@ -839,7 +852,7 @@ static void nsp_pio_write(struct scsi_cmnd *SCpnt)
 
 			nsp_dbg(NSP_DEBUG_DATA_IO, "phase changed stat=0x%x, res=%d\n", stat, res);
 			/* Put back pointer */
-			SCpnt->resid	       	 += res;
+			nsp_inc_resid(SCpnt, res);
 			SCpnt->SCp.ptr		 -= res;
 			SCpnt->SCp.this_residual += res;
 			ocount			 -= res;
@@ -875,7 +888,7 @@ static void nsp_pio_write(struct scsi_cmnd *SCpnt)
 			break;
 		}
 
-		SCpnt->resid	       	 -= res;
+		nsp_inc_resid(SCpnt, -res);
 		SCpnt->SCp.ptr		 += res;
 		SCpnt->SCp.this_residual -= res;
 		ocount			 += res;
@@ -895,10 +908,12 @@ static void nsp_pio_write(struct scsi_cmnd *SCpnt)
 	data->FifoCount = ocount;
 
 	if (time_out == 0) {
-		nsp_msg(KERN_DEBUG, "pio write timeout resid=0x%x", SCpnt->resid);
+		nsp_msg(KERN_DEBUG, "pio write timeout resid=0x%x",
+		                                        scsi_get_resid(SCpnt));
 	}
 	nsp_dbg(NSP_DEBUG_DATA_IO, "write ocount=0x%x", ocount);
-	nsp_dbg(NSP_DEBUG_DATA_IO, "w cmd=%d resid=0x%x\n", data->CmdId, SCpnt->resid);
+	nsp_dbg(NSP_DEBUG_DATA_IO, "w cmd=%d resid=0x%x\n", data->CmdId,
+	                                                scsi_get_resid(SCpnt));
 }
 #undef RFIFO_CRIT
 #undef WFIFO_CRIT
@@ -920,9 +935,8 @@ static int nsp_nexus(struct scsi_cmnd *SCpnt)
 	nsp_index_write(base, SYNCREG,	sync->SyncRegister);
 	nsp_index_write(base, ACKWIDTH, sync->AckWidth);
 
-	if (SCpnt->use_sg    == 0        ||
-	    SCpnt->resid % 4 != 0        ||
-	    SCpnt->resid     <= PAGE_SIZE ) {
+	if (scsi_get_resid(SCpnt) % 4 != 0 ||
+	    scsi_get_resid(SCpnt) <= PAGE_SIZE ) {
 		data->TransferMode = MODE_IO8;
 	} else if (nsp_burst_mode == BURST_MEM32) {
 		data->TransferMode = MODE_MEM32;
-- 
1.5.3.1



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

* [PATCH 09/24] libata-scsi: convert to use the data buffer accessors
  2007-09-11 20:23 [patchset 0/24] Lots of the Accessors patches and !use_sg cleanup Boaz Harrosh
                   ` (8 preceding siblings ...)
  2007-09-11 23:56 ` [PATCH 08/24] nsp_cs.c convert to data " Boaz Harrosh
@ 2007-09-11 23:58 ` Boaz Harrosh
  2007-09-12  0:09   ` Jeff Garzik
  2007-09-12  0:00 ` [PATCH 10/24] eata_pio.c: convert to accessors and !use_sg cleanup Boaz Harrosh
                   ` (17 subsequent siblings)
  27 siblings, 1 reply; 59+ messages in thread
From: Boaz Harrosh @ 2007-09-11 23:58 UTC (permalink / raw)
  To: James Bottomley, FUJITA Tomonori, Greg Kroah-Hartman, Alan Stern,
	Matthew


     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



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

* [PATCH 10/24] eata_pio.c: convert to accessors and !use_sg cleanup
  2007-09-11 20:23 [patchset 0/24] Lots of the Accessors patches and !use_sg cleanup Boaz Harrosh
                   ` (9 preceding siblings ...)
  2007-09-11 23:58 ` [PATCH 09/24] libata-scsi: convert to use the data buffer accessors Boaz Harrosh
@ 2007-09-12  0:00 ` Boaz Harrosh
  2007-09-12  0:00 ` [PATCH 11/24] a2091.c: " Boaz Harrosh
                   ` (16 subsequent siblings)
  27 siblings, 0 replies; 59+ messages in thread
From: Boaz Harrosh @ 2007-09-12  0:00 UTC (permalink / raw)
  To: James Bottomley, FUJITA Tomonori, Greg Kroah-Hartman, Alan Stern,
	Matthew


 - convert to accessors and !use_sg cleanup

Signed-off-by: Boaz Harrosh <bharrosh@panasas.com>
---
 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



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

* [PATCH 11/24] a2091.c: convert to accessors and !use_sg cleanup
  2007-09-11 20:23 [patchset 0/24] Lots of the Accessors patches and !use_sg cleanup Boaz Harrosh
                   ` (10 preceding siblings ...)
  2007-09-12  0:00 ` [PATCH 10/24] eata_pio.c: convert to accessors and !use_sg cleanup Boaz Harrosh
@ 2007-09-12  0:00 ` Boaz Harrosh
  2007-09-12  0:01 ` [PATCH 12/24] a3000.c: " Boaz Harrosh
                   ` (15 subsequent siblings)
  27 siblings, 0 replies; 59+ messages in thread
From: Boaz Harrosh @ 2007-09-12  0:00 UTC (permalink / raw)
  To: James Bottomley, FUJITA Tomonori, Greg Kroah-Hartman, Alan Stern,
	Matthew


 - convert to accessors and !use_sg cleanup

Signed-off-by: Boaz Harrosh <bharrosh@panasas.com>
---
 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



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

* [PATCH 12/24] a3000.c: convert to accessors and !use_sg cleanup
  2007-09-11 20:23 [patchset 0/24] Lots of the Accessors patches and !use_sg cleanup Boaz Harrosh
                   ` (11 preceding siblings ...)
  2007-09-12  0:00 ` [PATCH 11/24] a2091.c: " Boaz Harrosh
@ 2007-09-12  0:01 ` Boaz Harrosh
  2007-09-12  0:02 ` [PATCH 13/24] aha1542.c: " Boaz Harrosh
                   ` (14 subsequent siblings)
  27 siblings, 0 replies; 59+ messages in thread
From: Boaz Harrosh @ 2007-09-12  0:01 UTC (permalink / raw)
  To: James Bottomley, FUJITA Tomonori, Greg Kroah-Hartman, Alan Stern,
	Matthew


 - convert to accessors and !use_sg cleanup

Signed-off-by: Boaz Harrosh <bharrosh@panasas.com>
---
 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



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

* [PATCH 13/24] aha1542.c: convert to accessors and !use_sg cleanup
  2007-09-11 20:23 [patchset 0/24] Lots of the Accessors patches and !use_sg cleanup Boaz Harrosh
                   ` (12 preceding siblings ...)
  2007-09-12  0:01 ` [PATCH 12/24] a3000.c: " Boaz Harrosh
@ 2007-09-12  0:02 ` Boaz Harrosh
  2007-09-12  0:03 ` [PATCH 14/24] atp870u.c: " Boaz Harrosh
                   ` (13 subsequent siblings)
  27 siblings, 0 replies; 59+ messages in thread
From: Boaz Harrosh @ 2007-09-12  0:02 UTC (permalink / raw)
  To: James Bottomley, FUJITA Tomonori, Greg Kroah-Hartman, Alan Stern,
	Matthew


 - convert to accessors and !use_sg cleanup

Signed-off-by: Boaz Harrosh <bharrosh@panasas.com>
---
 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("Foooooooood 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);
-		any2scsi(ccb[mbo].dataptr, SCSI_BUF_PA(buff));
+		any2scsi(ccb[mbo].datalen, 0);
+		any2scsi(ccb[mbo].dataptr, 0);
 	};
 	ccb[mbo].idlun = (target & 7) << 5 | direction | (lun & 7);	/*SCSI Target Id */
 	ccb[mbo].rsalen = 16;
-- 
1.5.3.1



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

* [PATCH 14/24] atp870u.c: convert to accessors and !use_sg cleanup
  2007-09-11 20:23 [patchset 0/24] Lots of the Accessors patches and !use_sg cleanup Boaz Harrosh
                   ` (13 preceding siblings ...)
  2007-09-12  0:02 ` [PATCH 13/24] aha1542.c: " Boaz Harrosh
@ 2007-09-12  0:03 ` Boaz Harrosh
  2007-09-12  0:04 ` [PATCH 15/24] fd_mcs.c: " Boaz Harrosh
                   ` (12 subsequent siblings)
  27 siblings, 0 replies; 59+ messages in thread
From: Boaz Harrosh @ 2007-09-12  0:03 UTC (permalink / raw)
  To: James Bottomley, FUJITA Tomonori, Greg Kroah-Hartman, Alan Stern,
	Matthew


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

Signed-off-by: Boaz Harrosh <bharrosh@panasas.com>
---
 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 = 0x00040000;
 		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("Foooooooood 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) {
+			bttl = sg_dma_address(sgpnt);
+			l=sg_dma_len(sgpnt);
 #ifdef ED_DBGP		
-		printk("1. bttl %x, l %x\n",bttl, l);
+			printk("1. bttl %x, l %x\n",bttl, l);
 #endif			
-		while (l > 0x10000) {
+			while (l > 0x10000) {
 				(((u16 *) (prd))[i + 3]) = 0x0000;
 				(((u16 *) (prd))[i + 2]) = 0x0000;
 				(((u32 *) (prd))[i >> 1]) = cpu_to_le32(bttl);
@@ -965,32 +923,6 @@ oktosend:
 		printk("prd %4x %4x %4x %4x\n",(((unsigned short int *)prd)[0]),(((unsigned short int *)prd)[1]),(((unsigned short int *)prd)[2]),(((unsigned short int *)prd)[3]));
 		printk("2. bttl %x, l %x\n",bttl, l);
 #endif			
-	} else {
-		/*
-		 *	For a linear request write a chain of blocks
-		 */        
-		bttl = workreq->SCp.dma_handle;
-		l = workreq->request_bufflen;
-		i = 0;
-#ifdef ED_DBGP		
-		printk("3. bttl %x, l %x\n",bttl, l);
-#endif			
-		while (l > 0x10000) {
-				(((u16 *) (prd))[i + 3]) = 0x0000;
-				(((u16 *) (prd))[i + 2]) = 0x0000;
-				(((u32 *) (prd))[i >> 1]) = cpu_to_le32(bttl);
-				l -= 0x10000;
-				bttl += 0x10000;
-				i += 0x04;
-			}
-			(((u16 *) (prd))[i + 3]) = cpu_to_le16(0x8000);
-			(((u16 *) (prd))[i + 2]) = cpu_to_le16(l);
-			(((u32 *) (prd))[i >> 1]) = cpu_to_le32(bttl);		
-#ifdef ED_DBGP		
-		printk("prd %4x %4x %4x %4x\n",(((unsigned short int *)prd)[0]),(((unsigned short int *)prd)[1]),(((unsigned short int *)prd)[2]),(((unsigned short int *)prd)[3]));
-		printk("4. bttl %x, l %x\n",bttl, l);
-#endif			
-		
 	}
 	tmpcip += 4;
 #ifdef ED_DBGP		
-- 
1.5.3.1



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

* [PATCH 15/24] fd_mcs.c: convert to accessors and !use_sg cleanup
  2007-09-11 20:23 [patchset 0/24] Lots of the Accessors patches and !use_sg cleanup Boaz Harrosh
                   ` (14 preceding siblings ...)
  2007-09-12  0:03 ` [PATCH 14/24] atp870u.c: " Boaz Harrosh
@ 2007-09-12  0:04 ` Boaz Harrosh
  2007-09-12  0:05 ` [PATCH 16/24] imm.c: " Boaz Harrosh
                   ` (11 subsequent siblings)
  27 siblings, 0 replies; 59+ messages in thread
From: Boaz Harrosh @ 2007-09-12  0:04 UTC (permalink / raw)
  To: James Bottomley, FUJITA Tomonori, Greg Kroah-Hartman, Alan Stern,
	Matthew


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

Signed-off-by: Boaz Harrosh <bharrosh@panasas.com>
---
 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



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

* [PATCH 16/24] imm.c: convert to accessors and !use_sg cleanup
  2007-09-11 20:23 [patchset 0/24] Lots of the Accessors patches and !use_sg cleanup Boaz Harrosh
                   ` (15 preceding siblings ...)
  2007-09-12  0:04 ` [PATCH 15/24] fd_mcs.c: " Boaz Harrosh
@ 2007-09-12  0:05 ` Boaz Harrosh
  2007-09-12  0:06 ` [PATCH 17/24] in2000.c: " Boaz Harrosh
                   ` (10 subsequent siblings)
  27 siblings, 0 replies; 59+ messages in thread
From: Boaz Harrosh @ 2007-09-12  0:05 UTC (permalink / raw)
  To: James Bottomley, FUJITA Tomonori, Greg Kroah-Hartman, Alan Stern,
	Matthew


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

Signed-off-by: Boaz Harrosh <bharrosh@panasas.com>
---
 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



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

* [PATCH 17/24] in2000.c: convert to accessors and !use_sg cleanup
  2007-09-11 20:23 [patchset 0/24] Lots of the Accessors patches and !use_sg cleanup Boaz Harrosh
                   ` (16 preceding siblings ...)
  2007-09-12  0:05 ` [PATCH 16/24] imm.c: " Boaz Harrosh
@ 2007-09-12  0:06 ` Boaz Harrosh
  2007-09-12  0:07 ` [PATCH 18/24] ppa.c: " Boaz Harrosh
                   ` (9 subsequent siblings)
  27 siblings, 0 replies; 59+ messages in thread
From: Boaz Harrosh @ 2007-09-12  0:06 UTC (permalink / raw)
  To: James Bottomley, FUJITA Tomonori, Greg Kroah-Hartman, Alan Stern,
	Matthew


 - convert to accessors and !use_sg cleanup

Signed-off-by: Boaz Harrosh <bharrosh@panasas.com>
---
 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



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

* [PATCH 18/24] ppa.c: convert to accessors and !use_sg cleanup
  2007-09-11 20:23 [patchset 0/24] Lots of the Accessors patches and !use_sg cleanup Boaz Harrosh
                   ` (17 preceding siblings ...)
  2007-09-12  0:06 ` [PATCH 17/24] in2000.c: " Boaz Harrosh
@ 2007-09-12  0:07 ` Boaz Harrosh
  2007-09-12  0:07 ` [PATCH 19/24] wd33c93.c: " Boaz Harrosh
                   ` (8 subsequent siblings)
  27 siblings, 0 replies; 59+ messages in thread
From: Boaz Harrosh @ 2007-09-12  0:07 UTC (permalink / raw)
  To: James Bottomley, FUJITA Tomonori, Greg Kroah-Hartman, Alan Stern,
	Matthew


 - convert to accessors and !use_sg cleanup

Signed-off-by: Boaz Harrosh <bharrosh@panasas.com>
---
 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



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

* [PATCH 19/24] wd33c93.c: convert to accessors and !use_sg cleanup
  2007-09-11 20:23 [patchset 0/24] Lots of the Accessors patches and !use_sg cleanup Boaz Harrosh
                   ` (18 preceding siblings ...)
  2007-09-12  0:07 ` [PATCH 18/24] ppa.c: " Boaz Harrosh
@ 2007-09-12  0:07 ` Boaz Harrosh
  2007-09-12  0:09 ` Subject: [PATCH 20/24] scsi: esp family " Boaz Harrosh
                   ` (7 subsequent siblings)
  27 siblings, 0 replies; 59+ messages in thread
From: Boaz Harrosh @ 2007-09-12  0:07 UTC (permalink / raw)
  To: James Bottomley, FUJITA Tomonori, Greg Kroah-Hartman, Alan Stern,
	Matthew


 - convert to accessors and !use_sg cleanup

Signed-off-by: Boaz Harrosh <bharrosh@panasas.com>
---
 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



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

* Subject: [PATCH 20/24] scsi: esp family convert to accessors and !use_sg cleanup
  2007-09-11 20:23 [patchset 0/24] Lots of the Accessors patches and !use_sg cleanup Boaz Harrosh
                   ` (19 preceding siblings ...)
  2007-09-12  0:07 ` [PATCH 19/24] wd33c93.c: " Boaz Harrosh
@ 2007-09-12  0:09 ` Boaz Harrosh
  2007-09-12  0:09 ` [PATCH 21/24] qlogicpti.c: " Boaz Harrosh
                   ` (6 subsequent siblings)
  27 siblings, 0 replies; 59+ messages in thread
From: Boaz Harrosh @ 2007-09-12  0:09 UTC (permalink / raw)
  To: James Bottomley, FUJITA Tomonori, Greg Kroah-Hartman, Alan Stern,
	Matthew


  - 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 <bharrosh@panasas.com>
---
 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 pmaz_dma_ints_on(struct NCR_ESP *esp);
 static void pmaz_dma_setup(struct NCR_ESP *esp, u32 addr, int count, int write);
-static void pmaz_dma_mmu_get_scsi_one(struct NCR_ESP *esp, struct scsi_cmnd * sp);
 
 #define TC_ESP_RAM_SIZE 0x20000
 #define ESP_TGT_DMA_SIZE ((TC_ESP_RAM_SIZE/7) & ~(sizeof(int)-1))
@@ -153,9 +151,7 @@ static int dec_esp_platform_probe(void)
 		esp->dma_led_on = 0;
 
 		/* virtual DMA functions */
-		esp->dma_mmu_get_scsi_one = &dma_mmu_get_scsi_one;
 		esp->dma_mmu_get_scsi_sgl = &dma_mmu_get_scsi_sgl;
-		esp->dma_mmu_release_scsi_one = 0;
 		esp->dma_mmu_release_scsi_sgl = 0;
 		esp->dma_advance_sg = &dma_advance_sg;
 
@@ -290,9 +286,7 @@ static int __init dec_esp_probe(struct device *dev)
 	esp->dma_led_off = 0;
 	esp->dma_led_on = 0;
 
-	esp->dma_mmu_get_scsi_one = pmaz_dma_mmu_get_scsi_one;
 	esp->dma_mmu_get_scsi_sgl = 0;
-	esp->dma_mmu_release_scsi_one = 0;
 	esp->dma_mmu_release_scsi_sgl = 0;
 	esp->dma_advance_sg = 0;
 
@@ -536,11 +530,6 @@ static void dma_setup(struct NCR_ESP *esp, u32 addr, int count, int write)
 		dma_init_write(esp, addr, count);
 }
 
-static void dma_mmu_get_scsi_one(struct NCR_ESP *esp, struct scsi_cmnd * sp)
-{
-	sp->SCp.ptr = (char *)virt_to_phys(sp->request_buffer);
-}
-
 static void dma_mmu_get_scsi_sgl(struct NCR_ESP *esp, struct scsi_cmnd * sp)
 {
 	int sz = sp->SCp.buffers_residual;
@@ -617,12 +606,6 @@ static void pmaz_dma_setup(struct NCR_ESP *esp, u32 addr, int count, int write)
 		pmaz_dma_init_write(esp, addr, count);
 }
 
-static void pmaz_dma_mmu_get_scsi_one(struct NCR_ESP *esp, struct scsi_cmnd * sp)
-{
-	sp->SCp.ptr = (char *)virt_to_phys(sp->request_buffer);
-}
-
-
 #ifdef CONFIG_TC
 static int __init dec_esp_tc_probe(struct device *dev);
 static int __exit dec_esp_tc_remove(struct device *dev);
diff --git a/drivers/scsi/oktagon_esp.c b/drivers/scsi/oktagon_esp.c
index 26a6d55..49a6bf7 100644
--- a/drivers/scsi/oktagon_esp.c
+++ b/drivers/scsi/oktagon_esp.c
@@ -64,9 +64,7 @@ static void dma_setup(struct NCR_ESP *esp, __u32 addr, int count, int write);
 static void dma_irq_exit(struct NCR_ESP *esp);
 static void dma_invalidate(struct NCR_ESP *esp);
 
-static void dma_mmu_get_scsi_one(struct NCR_ESP *,Scsi_Cmnd *);
 static void dma_mmu_get_scsi_sgl(struct NCR_ESP *,Scsi_Cmnd *);
-static void dma_mmu_release_scsi_one(struct NCR_ESP *,Scsi_Cmnd *);
 static void dma_mmu_release_scsi_sgl(struct NCR_ESP *,Scsi_Cmnd *);
 static void dma_advance_sg(Scsi_Cmnd *);
 static int  oktagon_notify_reboot(struct notifier_block *this, unsigned long code, void *x);
@@ -169,9 +167,7 @@ int oktagon_esp_detect(struct scsi_host_template *tpnt)
 		esp->dma_poll = 0;
 		esp->dma_reset = 0;
 
-		esp->dma_mmu_get_scsi_one = &dma_mmu_get_scsi_one;
 		esp->dma_mmu_get_scsi_sgl = &dma_mmu_get_scsi_sgl;
-		esp->dma_mmu_release_scsi_one = &dma_mmu_release_scsi_one;
 		esp->dma_mmu_release_scsi_sgl = &dma_mmu_release_scsi_sgl;
 		esp->dma_advance_sg = &dma_advance_sg;
 
@@ -542,22 +538,12 @@ static void dma_invalidate(struct NCR_ESP *esp)
  * mmu interface to pass the virtual address, not the physical.
  */
 
-void dma_mmu_get_scsi_one(struct NCR_ESP *esp, Scsi_Cmnd *sp)
-{
-        sp->SCp.ptr =
-                sp->request_buffer;
-}
-
 void dma_mmu_get_scsi_sgl(struct NCR_ESP *esp, Scsi_Cmnd *sp)
 {
         sp->SCp.ptr = page_address(sp->SCp.buffer->page)+
 		      sp->SCp.buffer->offset;
 }
 
-void dma_mmu_release_scsi_one(struct NCR_ESP *esp, Scsi_Cmnd *sp)
-{
-}
-
 void dma_mmu_release_scsi_sgl(struct NCR_ESP *esp, Scsi_Cmnd *sp)
 {
 }
diff --git a/drivers/scsi/sun3x_esp.c b/drivers/scsi/sun3x_esp.c
index 80fb3f8..9107283 100644
--- a/drivers/scsi/sun3x_esp.c
+++ b/drivers/scsi/sun3x_esp.c
@@ -38,9 +38,7 @@ static void dma_poll(struct NCR_ESP *esp, unsigned char *vaddr);
 static int  dma_ports_p(struct NCR_ESP *esp);
 static void dma_reset(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, Scsi_Cmnd *sp);
 static void dma_mmu_get_scsi_sgl (struct NCR_ESP *esp, Scsi_Cmnd *sp);
-static void dma_mmu_release_scsi_one (struct NCR_ESP *esp, Scsi_Cmnd *sp);
 static void dma_mmu_release_scsi_sgl (struct NCR_ESP *esp, Scsi_Cmnd *sp);
 static void dma_advance_sg (Scsi_Cmnd *sp);
 
@@ -82,9 +80,7 @@ int sun3x_esp_detect(struct scsi_host_template *tpnt)
 	esp->dma_reset = &dma_reset;
 
         /* virtual DMA functions */
-        esp->dma_mmu_get_scsi_one = &dma_mmu_get_scsi_one;
         esp->dma_mmu_get_scsi_sgl = &dma_mmu_get_scsi_sgl;
-        esp->dma_mmu_release_scsi_one = &dma_mmu_release_scsi_one;
         esp->dma_mmu_release_scsi_sgl = &dma_mmu_release_scsi_sgl;
         esp->dma_advance_sg = &dma_advance_sg;
 	    
@@ -319,13 +315,6 @@ static void dma_setup(struct NCR_ESP *esp, __u32 addr, int count, int write)
 	dregs->st_addr = addr;
 }
 
-static void dma_mmu_get_scsi_one (struct NCR_ESP *esp, Scsi_Cmnd *sp)
-{
-    sp->SCp.have_data_in = dvma_map((unsigned long)sp->SCp.buffer,
-				       sp->SCp.this_residual);
-    sp->SCp.ptr = (char *)((unsigned long)sp->SCp.have_data_in);
-}
-
 static void dma_mmu_get_scsi_sgl (struct NCR_ESP *esp, Scsi_Cmnd *sp)
 {
     int sz = sp->SCp.buffers_residual;
@@ -339,15 +328,10 @@ static void dma_mmu_get_scsi_sgl (struct NCR_ESP *esp, Scsi_Cmnd *sp)
     sp->SCp.ptr=(char *)((unsigned long)sp->SCp.buffer->dma_address);
 }
 
-static void dma_mmu_release_scsi_one (struct NCR_ESP *esp, Scsi_Cmnd *sp)
-{
-    dvma_unmap((char *)sp->SCp.have_data_in);
-}
-
 static void dma_mmu_release_scsi_sgl (struct NCR_ESP *esp, Scsi_Cmnd *sp)
 {
-    int sz = sp->use_sg - 1;
-    struct scatterlist *sg = (struct scatterlist *)sp->request_buffer;
+    int sz = scsi_sg_count(sp) - 1;
+    struct scatterlist *sg = scsi_sglist(sp);
                         
     while(sz >= 0) {
         dvma_unmap((char *)sg[sz].dma_address);
-- 
1.5.3.1



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

* Re: [PATCH 09/24] libata-scsi: convert to use the data buffer accessors
  2007-09-11 23:58 ` [PATCH 09/24] libata-scsi: convert to use the data buffer accessors Boaz Harrosh
@ 2007-09-12  0:09   ` Jeff Garzik
  2007-09-12  0:25     ` Boaz Harrosh
                       ` (3 more replies)
  0 siblings, 4 replies; 59+ messages in thread
From: Jeff Garzik @ 2007-09-12  0:09 UTC (permalink / raw)
  To: Boaz Harrosh
  Cc: James Bottomley, FUJITA Tomonori, Greg Kroah-Hartman, Alan Stern,
	Matthew Dharm, Russell King, David S. Miller,
	Bartlomiej Zolnierkiewicz, YOKOTA Hiroshi, linux-scsi,
	Maciej W. Rozycki, Mark Fortescue

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

	Jeff




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

* [PATCH 21/24] qlogicpti.c: convert to accessors and !use_sg cleanup
  2007-09-11 20:23 [patchset 0/24] Lots of the Accessors patches and !use_sg cleanup Boaz Harrosh
                   ` (20 preceding siblings ...)
  2007-09-12  0:09 ` Subject: [PATCH 20/24] scsi: esp family " Boaz Harrosh
@ 2007-09-12  0:09 ` Boaz Harrosh
  2007-10-10 18:25   ` [PATCH 21/24 ver2] " Boaz Harrosh
  2007-09-12  0:10 ` Subject: [PATCH 22/24] Remove psi240i driver from kernel Boaz Harrosh
                   ` (5 subsequent siblings)
  27 siblings, 1 reply; 59+ messages in thread
From: Boaz Harrosh @ 2007-09-12  0:09 UTC (permalink / raw)
  To: James Bottomley, FUJITA Tomonori, Greg Kroah-Hartman, Alan Stern,
	Matthew


 - 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 <bharrosh@panasas.com>
---
 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



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

* Subject: [PATCH 22/24] Remove psi240i driver from kernel
  2007-09-11 20:23 [patchset 0/24] Lots of the Accessors patches and !use_sg cleanup Boaz Harrosh
                   ` (21 preceding siblings ...)
  2007-09-12  0:09 ` [PATCH 21/24] qlogicpti.c: " Boaz Harrosh
@ 2007-09-12  0:10 ` Boaz Harrosh
  2007-09-12  0:11 ` [PATCH 23/24] wd7000.c - proper fix for boards without sg support Boaz Harrosh
                   ` (4 subsequent siblings)
  27 siblings, 0 replies; 59+ messages in thread
From: Boaz Harrosh @ 2007-09-12  0:10 UTC (permalink / raw)
  To: James Bottomley, FUJITA Tomonori, Greg Kroah-Hartman, Alan Stern,
	Matthew


  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 <bharrosh@panasas.com>
---
 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..0000000
--- 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. */
-
-#define	PORT_DATA				0
-#define	PORT_ERROR				1
-#define	PORT_SECTOR_COUNT		2
-#define	PORT_LBA_0				3
-#define	PORT_LBA_8				4
-#define	PORT_LBA_16				5
-#define	PORT_LBA_24				6
-#define	PORT_STAT_CMD			7
-#define	PORT_SEL_FAIL			8
-#define	PORT_IRQ_STATUS			9
-#define	PORT_ADDRESS			10
-#define	PORT_FAIL				11
-#define	PORT_ALT_STAT		   	12
-
-typedef struct
-	{
-	UCHAR		   	device;				// device code
-	UCHAR			byte6;				// device select register image
-	UCHAR			spigot;				// spigot number
-	UCHAR			expectingIRQ;		// flag for expecting and interrupt
-	USHORT			sectors;			// number of sectors per track
-	USHORT			heads;				// number of heads
-	USHORT			cylinders;			// number of cylinders for this device
-	USHORT			spareword;			// placeholder
-	ULONG			blocks;				// number of blocks on device
-	}	OUR_DEVICE, *POUR_DEVICE;
-
-typedef struct
-	{
-	USHORT		 ports[13];
-	OUR_DEVICE	 device[8];
-	struct scsi_cmnd *pSCmnd;
-	IDE_STRUCT	 ide;
-	ULONG		 startSector;
-	USHORT		 sectorCount;
-	struct scsi_cmnd *SCpnt;
-	VOID		*buffer;
-	USHORT		 expectingIRQ;
-	}	ADAPTER240I, *PADAPTER240I;
-
-#define HOSTDATA(host) ((PADAPTER240I)&host->hostdata)
-
-static struct	Scsi_Host *PsiHost[6] = {NULL,};  /* One for each IRQ level (10-15) */
-static			IDENTIFY_DATA	identifyData;
-static			SETUP			ChipSetup;
-
-static	USHORT	portAddr[6] = {CHIP_ADRS_0, CHIP_ADRS_1, CHIP_ADRS_2, CHIP_ADRS_3, CHIP_ADRS_4, CHIP_ADRS_5};
-
-/****************************************************************
- *	Name:	WriteData	:LOCAL
- *
- *	Description:	Write data to device.
- *
- *	Parameters:		padapter - Pointer adapter data structure.
- *
- *	Returns:		TRUE if drive does not assert DRQ in time.
- *
- ****************************************************************/
-static int WriteData (PADAPTER240I padapter)
-	{
-	ULONG	timer;
-	USHORT *pports = padapter->ports;
-
-	timer = jiffies + TIMEOUT_DRQ;								// calculate the timeout value
-	do  {
-		if ( inb_p (pports[PORT_STAT_CMD]) & IDE_STATUS_DRQ )
-			{
-			outsw (pports[PORT_DATA], padapter->buffer, (USHORT)padapter->ide.ide.ide[2] * 256);
-			return 0;
-			}
-		}	while ( time_after(timer, jiffies) );									// test for timeout
-
-	padapter->ide.ide.ides.cmd = 0;									// null out the command byte
-	return 1;
-	}
-/****************************************************************
- *	Name:	IdeCmd	:LOCAL
- *
- *	Description:	Process a queued command from the SCSI manager.
- *
- *	Parameters:		padapter - Pointer adapter data structure.
- *
- *	Returns:		Zero if no error or status register contents on error.
- *
- ****************************************************************/
-static UCHAR IdeCmd (PADAPTER240I padapter)
-	{
-	ULONG	timer;
-	USHORT *pports = padapter->ports;
-	UCHAR	status;
-
-	outb_p (padapter->ide.ide.ides.spigot, pports[PORT_SEL_FAIL]);	// select the spigot
-	outb_p (padapter->ide.ide.ide[6], pports[PORT_LBA_24]);			// select the drive
-	timer = jiffies + TIMEOUT_READY;							// calculate the timeout value
-	do  {
-		status = inb_p (padapter->ports[PORT_STAT_CMD]);
-		if ( status & IDE_STATUS_DRDY )
-			{
-			outb_p (padapter->ide.ide.ide[2], pports[PORT_SECTOR_COUNT]);
-			outb_p (padapter->ide.ide.ide[3], pports[PORT_LBA_0]);
-			outb_p (padapter->ide.ide.ide[4], pports[PORT_LBA_8]);
-			outb_p (padapter->ide.ide.ide[5], pports[PORT_LBA_16]);
-			padapter->expectingIRQ = 1;
-			outb_p (padapter->ide.ide.ide[7], pports[PORT_STAT_CMD]);
-
-			if ( padapter->ide.ide.ides.cmd == IDE_CMD_WRITE_MULTIPLE )
-				return (WriteData (padapter));
-
-			return 0;
-			}
-		}	while ( time_after(timer, jiffies) );									// test for timeout
-
-	padapter->ide.ide.ides.cmd = 0;									// null out the command byte
-	return status;
-	}
-/****************************************************************
- *	Name:	SetupTransfer	:LOCAL
- *
- *	Description:	Setup a data transfer command.
- *
- *	Parameters:		padapter - Pointer adapter data structure.
- *					drive	 - Drive/head register upper nibble only.
- *
- *	Returns:		TRUE if no data to transfer.
- *
- ****************************************************************/
-static int SetupTransfer (PADAPTER240I padapter, UCHAR drive)
-	{
-	if ( padapter->sectorCount )
-		{
-		*(ULONG *)padapter->ide.ide.ides.lba = padapter->startSector;
-		padapter->ide.ide.ide[6] |= drive;
-		padapter->ide.ide.ides.sectors = ( padapter->sectorCount > SECTORSXFER ) ? SECTORSXFER : padapter->sectorCount;
-		padapter->sectorCount -= padapter->ide.ide.ides.sectors;	// bump the start and count for next xfer
-		padapter->startSector += padapter->ide.ide.ides.sectors;
-		return 0;
-		}
-	else
-		{
-		padapter->ide.ide.ides.cmd = 0;								// null out the command byte
-		padapter->SCpnt = NULL;
-		return 1;
-		}
-	}
-/****************************************************************
- *	Name:	DecodeError	:LOCAL
- *
- *	Description:	Decode and process device errors.
- *
- *	Parameters:		pshost - Pointer to host data block.
- *					status - Status register code.
- *
- *	Returns:		The driver status code.
- *
- ****************************************************************/
-static ULONG DecodeError (struct Scsi_Host *pshost, UCHAR status)
-	{
-	PADAPTER240I	padapter = HOSTDATA(pshost);
-	UCHAR			error;
-
-	padapter->expectingIRQ = 0;
-	padapter->SCpnt = NULL;
-	if ( status & IDE_STATUS_WRITE_FAULT )
-		{
-		return DID_PARITY << 16;
-		}
-	if ( status & IDE_STATUS_BUSY )
-		return DID_BUS_BUSY << 16;
-
-	error = inb_p (padapter->ports[PORT_ERROR]);
-	DEB(printk ("\npsi240i error register: %x", error));
-	switch ( error )
-		{
-		case IDE_ERROR_AMNF:
-		case IDE_ERROR_TKONF:
-		case IDE_ERROR_ABRT:
-		case IDE_ERROR_IDFN:
-		case IDE_ERROR_UNC:
-		case IDE_ERROR_BBK:
-		default:
-			return DID_ERROR << 16;
-		}
-	return DID_ERROR << 16;
-	}
-/****************************************************************
- *	Name:	Irq_Handler	:LOCAL
- *
- *	Description:	Interrupt handler.
- *
- *	Parameters:		irq		- Hardware IRQ number.
- *					dev_id	-
- *
- *	Returns:		TRUE if drive is not ready in time.
- *
- ****************************************************************/
-static void Irq_Handler (int irq, void *dev_id)
-	{
-	struct Scsi_Host *shost;	// Pointer to host data block
-	PADAPTER240I padapter;		// Pointer to adapter control structure
-	USHORT *pports;			// I/O port array
-	struct scsi_cmnd *SCpnt;
-	UCHAR status;
-	int z;
-
-	DEB(printk ("\npsi240i received interrupt\n"));
-
-	shost = PsiHost[irq - 10];
-	if ( !shost )
-		panic ("Splunge!");
-
-	padapter = HOSTDATA(shost);
-	pports = padapter->ports;
-	SCpnt = padapter->SCpnt;
-
-	if ( !padapter->expectingIRQ )
-		{
-		DEB(printk ("\npsi240i Unsolicited interrupt\n"));
-		return;
-		}
-	padapter->expectingIRQ = 0;
-
-	status = inb_p (padapter->ports[PORT_STAT_CMD]);			// read the device status
-	if ( status & (IDE_STATUS_ERROR | IDE_STATUS_WRITE_FAULT) )
-		goto irqerror;
-
-	DEB(printk ("\npsi240i processing interrupt"));
-	switch ( padapter->ide.ide.ides.cmd )							// decide how to handle the interrupt
-		{
-		case IDE_CMD_READ_MULTIPLE:
-			if ( status & IDE_STATUS_DRQ )
-				{
-				insw (pports[PORT_DATA], padapter->buffer, (USHORT)padapter->ide.ide.ides.sectors * 256);
-				padapter->buffer += padapter->ide.ide.ides.sectors * 512;
-				if ( SetupTransfer (padapter, padapter->ide.ide.ide[6] & 0xF0) )
-					{
-					SCpnt->result = DID_OK << 16;
-					padapter->SCpnt = NULL;
-					SCpnt->scsi_done (SCpnt);
-					return;
-					}
-				if ( !(status = IdeCmd (padapter)) )
-					return;
-				}
-			break;
-
-		case IDE_CMD_WRITE_MULTIPLE:
-			padapter->buffer += padapter->ide.ide.ides.sectors * 512;
-			if ( SetupTransfer (padapter, padapter->ide.ide.ide[6] & 0xF0) )
-				{
-				SCpnt->result = DID_OK << 16;
-				padapter->SCpnt = NULL;
-				SCpnt->scsi_done (SCpnt);
-				return;
-				}
-			if ( !(status = IdeCmd (padapter)) )
-				return;
-			break;
-
-		case IDE_COMMAND_IDENTIFY:
-			{
-			PINQUIRYDATA	pinquiryData  = SCpnt->request_buffer;
-
-			if ( status & IDE_STATUS_DRQ )
-				{
-				insw (pports[PORT_DATA], &identifyData, sizeof (identifyData) >> 1);
-
-				memset (pinquiryData, 0, SCpnt->request_bufflen);		// Zero INQUIRY data structure.
-				pinquiryData->DeviceType = 0;
-				pinquiryData->Versions = 2;
-				pinquiryData->AdditionalLength = 35 - 4;
-
-				// Fill in vendor identification fields.
-				for ( z = 0;  z < 8;  z += 2 )
-					{
-					pinquiryData->VendorId[z]	  = ((UCHAR *)identifyData.ModelNumber)[z + 1];
-					pinquiryData->VendorId[z + 1] = ((UCHAR *)identifyData.ModelNumber)[z];
-					}
-
-				// Initialize unused portion of product id.
-				for ( z = 0;  z < 4;  z++ )
-					pinquiryData->ProductId[12 + z] = ' ';
-
-				// Move firmware revision from IDENTIFY data to
-				// product revision in INQUIRY data.
-				for ( z = 0;  z < 4;  z += 2 )
-					{
-					pinquiryData->ProductRevisionLevel[z]	 = ((UCHAR *)identifyData.FirmwareRevision)[z + 1];
-					pinquiryData->ProductRevisionLevel[z + 1] = ((UCHAR *)identifyData.FirmwareRevision)[z];
-					}
-
-				SCpnt->result = DID_OK << 16;
-				padapter->SCpnt = NULL;
-				SCpnt->scsi_done (SCpnt);
-				return;
-				}
-			break;
-			}
-
-		default:
-			SCpnt->result = DID_OK << 16;
-			padapter->SCpnt = NULL;
-			SCpnt->scsi_done (SCpnt);
-			return;
-		}
-
-irqerror:;
-	DEB(printk ("\npsi240i error  Device Status: %X\n", status));
-	SCpnt->result = DecodeError (shost, status);
-	SCpnt->scsi_done (SCpnt);
-	}
-
-static irqreturn_t do_Irq_Handler (int irq, void *dev_id)
-{
-	unsigned long flags;
-	struct Scsi_Host *dev = dev_id;
-	
-	spin_lock_irqsave(dev->host_lock, flags);
-	Irq_Handler(irq, dev_id);
-	spin_unlock_irqrestore(dev->host_lock, flags);
-	return IRQ_HANDLED;
-}
-
-/****************************************************************
- *	Name:	Psi240i_QueueCommand
- *
- *	Description:	Process a queued command from the SCSI manager.
- *
- *	Parameters:		SCpnt - Pointer to SCSI command structure.
- *					done  - Pointer to done function to call.
- *
- *	Returns:		Status code.
- *
- ****************************************************************/
-static int Psi240i_QueueCommand(struct scsi_cmnd *SCpnt,
-				void (*done)(struct scsi_cmnd *))
-	{
-	UCHAR *cdb = (UCHAR *)SCpnt->cmnd;
-	// Pointer to SCSI CDB
-	PADAPTER240I padapter = HOSTDATA (SCpnt->device->host);
-	// Pointer to adapter control structure
-	POUR_DEVICE pdev = &padapter->device [SCpnt->device->id];
-	// Pointer to device information
-	UCHAR rc;
-	// command return code
-
-	SCpnt->scsi_done = done;
-	padapter->ide.ide.ides.spigot = pdev->spigot;
-	padapter->buffer = SCpnt->request_buffer;
-	if (done)
-		{
-		if ( !pdev->device )
-			{
-			SCpnt->result = DID_BAD_TARGET << 16;
-			done (SCpnt);
-			return 0;
-			}
-		}
-	else
-		{
-		printk("psi240i_queuecommand: %02X: done can't be NULL\n", *cdb);
-		return 0;
-		}
-
-	switch ( *cdb )
-		{
-		case SCSIOP_INQUIRY:   					// inquiry CDB
-			{
-			padapter->ide.ide.ide[6] = pdev->byte6;
-			padapter->ide.ide.ides.cmd = IDE_COMMAND_IDENTIFY;
-			break;
-			}
-
-		case SCSIOP_TEST_UNIT_READY:			// test unit ready CDB
-			SCpnt->result = DID_OK << 16;
-			done (SCpnt);
-			return 0;
-
-		case SCSIOP_READ_CAPACITY:			  	// read capctiy CDB
-			{
-			PREAD_CAPACITY_DATA	pdata = (PREAD_CAPACITY_DATA)SCpnt->request_buffer;
-
-			pdata->blksiz = 0x20000;
-			XANY2SCSI ((UCHAR *)&pdata->blks, pdev->blocks);
-			SCpnt->result = DID_OK << 16;
-			done (SCpnt);
-			return 0;
-			}
-
-		case SCSIOP_VERIFY:						// verify CDB
-			*(ULONG *)padapter->ide.ide.ides.lba = XSCSI2LONG (&cdb[2]);
-			padapter->ide.ide.ide[6] |= pdev->byte6;
-			padapter->ide.ide.ide[2] = (UCHAR)((USHORT)cdb[8] | ((USHORT)cdb[7] << 8));
-			padapter->ide.ide.ides.cmd = IDE_COMMAND_VERIFY;
-			break;
-
-		case SCSIOP_READ:						// read10 CDB
-			padapter->startSector = XSCSI2LONG (&cdb[2]);
-			padapter->sectorCount = (USHORT)cdb[8] | ((USHORT)cdb[7] << 8);
-			SetupTransfer (padapter, pdev->byte6);
-			padapter->ide.ide.ides.cmd = IDE_CMD_READ_MULTIPLE;
-			break;
-
-		case SCSIOP_READ6:						// read6  CDB
-			padapter->startSector = SCSI2LONG (&cdb[1]);
-			padapter->sectorCount = cdb[4];
-			SetupTransfer (padapter, pdev->byte6);
-			padapter->ide.ide.ides.cmd = IDE_CMD_READ_MULTIPLE;
-			break;
-
-		case SCSIOP_WRITE:						// write10 CDB
-			padapter->startSector = XSCSI2LONG (&cdb[2]);
-			padapter->sectorCount = (USHORT)cdb[8] | ((USHORT)cdb[7] << 8);
-			SetupTransfer (padapter, pdev->byte6);
-			padapter->ide.ide.ides.cmd = IDE_CMD_WRITE_MULTIPLE;
-			break;
-		case SCSIOP_WRITE6:						// write6  CDB
-			padapter->startSector = SCSI2LONG (&cdb[1]);
-			padapter->sectorCount = cdb[4];
-			SetupTransfer (padapter, pdev->byte6);
-			padapter->ide.ide.ides.cmd = IDE_CMD_WRITE_MULTIPLE;
-			break;
-
-		default:
-			DEB (printk ("psi240i_queuecommand: Unsupported command %02X\n", *cdb));
-			SCpnt->result = DID_ERROR << 16;
-			done (SCpnt);
-			return 0;
-		}
-
-	padapter->SCpnt = SCpnt;  									// Save this command data
-
-	rc = IdeCmd (padapter);
-	if ( rc )
-		{
-		padapter->expectingIRQ = 0;
-		DEB (printk ("psi240i_queuecommand: %02X, %02X: Device failed to respond for command\n", *cdb, padapter->ide.ide.ides.cmd));
-		SCpnt->result = DID_ERROR << 16;
-		done (SCpnt);
-		return 0;
-		}
-	DEB (printk("psi240i_queuecommand: %02X, %02X now waiting for interrupt ", *cdb, padapter->ide.ide.ides.cmd));
-	return 0;
-	}
-
-/***************************************************************************
- *	Name:			ReadChipMemory
- *
- *	Description:	Read information from controller memory.
- *
- *	Parameters:		psetup	- Pointer to memory image of setup information.
- *					base	- base address of memory.
- *					length	- lenght of data space in bytes.
- *					port	- I/O address of data port.
- *
- *	Returns:		Nothing.
- *
- **************************************************************************/
-static void ReadChipMemory (void *pdata, USHORT base, USHORT length, USHORT port)
-	{
-	USHORT	z, zz;
-	UCHAR	*pd = (UCHAR *)pdata;
-	outb_p (SEL_NONE, port + REG_SEL_FAIL);				// setup data port
-	zz = 0;
-	while ( zz < length )
-		{
-		outw_p (base, port + REG_ADDRESS);				// setup address
-
-		for ( z = 0;  z < 8;  z++ )
-			{
-			if ( (zz + z) < length )
-			*pd++ = inb_p (port + z);	// read data byte
-			}
-		zz += 8;
-		base += 8;
-		}
-	}
-/****************************************************************
- *	Name:	Psi240i_Detect
- *
- *	Description:	Detect and initialize our boards.
- *
- *	Parameters:		tpnt - Pointer to SCSI host template structure.
- *
- *	Returns:		Number of adapters found.
- *
- ****************************************************************/
-static int Psi240i_Detect (struct scsi_host_template *tpnt)
-	{
-	int					board;
-	int					count = 0;
-	int					unit;
-	int					z;
-	USHORT				port, port_range = 16;
-	CHIP_CONFIG_N		chipConfig;
-	CHIP_DEVICE_N		chipDevice[8];
-	struct Scsi_Host   *pshost;
-
-	for ( board = 0;  board < MAXBOARDS;  board++ )					// scan for I/O ports
-		{
-		pshost = NULL;
-		port = portAddr[board];								// get base address to test
-		if ( !request_region (port, port_range, "psi240i") )
-			continue;
-		if ( inb_p (port + REG_FAIL) != CHIP_ID )			// do the first test for likley hood that it is us
-			goto host_init_failure;
-		outb_p (SEL_NONE, port + REG_SEL_FAIL);				// setup EEPROM/RAM access
-		outw (0, port + REG_ADDRESS);						// setup EEPROM address zero
-		if ( inb_p (port) != 0x55 )							// test 1st byte
-			goto host_init_failure;									//   nope
-		if ( inb_p (port + 1) != 0xAA )						// test 2nd byte
-			goto host_init_failure;								//   nope
-
-		// at this point our board is found and can be accessed.  Now we need to initialize
-		// our informatation and register with the kernel.
-
-
-		ReadChipMemory (&chipConfig, CHIP_CONFIG, sizeof (chipConfig), port);
-		ReadChipMemory (&chipDevice, CHIP_DEVICE, sizeof (chipDevice), port);
-		ReadChipMemory (&ChipSetup, CHIP_EEPROM_DATA, sizeof (ChipSetup), port);
-
-		if ( !chipConfig.numDrives )						// if no devices on this board
-			goto host_init_failure;
-
-		pshost = scsi_register (tpnt, sizeof(ADAPTER240I));
-		if(pshost == NULL)
-			goto host_init_failure;	
-
-		PsiHost[chipConfig.irq - 10] = pshost;
-		pshost->unique_id = port;
-		pshost->io_port = port;
-		pshost->n_io_port = 16;  /* Number of bytes of I/O space used */
-		pshost->irq = chipConfig.irq;
-
-		for ( z = 0;  z < 11;  z++ )						// build regester address array
-			HOSTDATA(pshost)->ports[z] = port + z;
-		HOSTDATA(pshost)->ports[11] = port + REG_FAIL;
-		HOSTDATA(pshost)->ports[12] = port + REG_ALT_STAT;
-		DEB (printk ("\nPorts ="));
-		DEB (for (z=0;z<13;z++) printk(" %#04X",HOSTDATA(pshost)->ports[z]););
-
-		for ( z = 0;  z < chipConfig.numDrives;  ++z )
-			{
-			unit = chipDevice[z].channel & 0x0F;
-			HOSTDATA(pshost)->device[unit].device	 = ChipSetup.setupDevice[unit].device;
-			HOSTDATA(pshost)->device[unit].byte6	 = (UCHAR)(((unit & 1) << 4) | 0xE0);
-			HOSTDATA(pshost)->device[unit].spigot	 = (UCHAR)(1 << (unit >> 1));
-			HOSTDATA(pshost)->device[unit].sectors	 = ChipSetup.setupDevice[unit].sectors;
-			HOSTDATA(pshost)->device[unit].heads	 = ChipSetup.setupDevice[unit].heads;
-			HOSTDATA(pshost)->device[unit].cylinders = ChipSetup.setupDevice[unit].cylinders;
-			HOSTDATA(pshost)->device[unit].blocks	 = ChipSetup.setupDevice[unit].blocks;
-			DEB (printk ("\nHOSTDATA->device    = %X", HOSTDATA(pshost)->device[unit].device));
-			DEB (printk ("\n          byte6     = %X", HOSTDATA(pshost)->device[unit].byte6));
-			DEB (printk ("\n          spigot    = %X", HOSTDATA(pshost)->device[unit].spigot));
-			DEB (printk ("\n          sectors   = %X", HOSTDATA(pshost)->device[unit].sectors));
-			DEB (printk ("\n          heads     = %X", HOSTDATA(pshost)->device[unit].heads));
-			DEB (printk ("\n          cylinders = %X", HOSTDATA(pshost)->device[unit].cylinders));
-			DEB (printk ("\n          blocks    = %lX", HOSTDATA(pshost)->device[unit].blocks));
-			}
-
-		if ( request_irq (chipConfig.irq, do_Irq_Handler, 0, "psi240i", pshost) == 0 ) 
-			{
-			printk("\nPSI-240I EIDE CONTROLLER: at I/O = %x  IRQ = %d\n", port, chipConfig.irq);
-		        printk("(C) 1997 Perceptive Solutions, Inc. All rights reserved\n\n");
-		        count++;
-		        continue;
-			}
-
-		printk ("Unable to allocate IRQ for PSI-240I controller.\n");
-           
-host_init_failure:
-		
-		release_region (port, port_range);
-		if (pshost)
-			scsi_unregister (pshost);
-
-		}
-	return count;
-	}
-
-static int Psi240i_Release(struct Scsi_Host *shost)
-{
-	if (shost->irq)
-		free_irq(shost->irq, NULL);
-	if (shost->io_port && shost->n_io_port)
-		release_region(shost->io_port, shost->n_io_port);
-	scsi_unregister(shost);
-	return 0;
-}
-
-/****************************************************************
- *	Name:	Psi240i_BiosParam
- *
- *	Description:	Process the biosparam request from the SCSI manager to
- *					return C/H/S data.
- *
- *	Parameters:		disk - Pointer to SCSI disk structure.
- *					dev	 - Major/minor number from kernel.
- *					geom - Pointer to integer array to place geometry data.
- *
- *	Returns:		zero.
- *
- ****************************************************************/
-static int Psi240i_BiosParam (struct scsi_device *sdev, struct block_device *dev,
-		sector_t capacity, int geom[])
-	{
-	POUR_DEVICE	pdev;
-
-	pdev = &(HOSTDATA(sdev->host)->device[sdev_id(sdev)]);
-
-	geom[0] = pdev->heads;
-	geom[1] = pdev->sectors;
-	geom[2] = pdev->cylinders;
-	return 0;
-	}
-
-MODULE_LICENSE("GPL");
-
-static struct scsi_host_template driver_template = {
-	.proc_name		= "psi240i", 
-	.name			= "PSI-240I EIDE Disk Controller",
-	.detect			= Psi240i_Detect,
-	.release		= Psi240i_Release,
-	.queuecommand		= Psi240i_QueueCommand,
-	.bios_param	  	= Psi240i_BiosParam,
-	.can_queue	  	= 1,
-	.this_id	  	= -1,
-	.sg_tablesize	  	= SG_NONE,
-	.cmd_per_lun	  	= 1, 
-	.use_clustering		= DISABLE_CLUSTERING,
-};
-#include "scsi_module.c"
diff --git a/drivers/scsi/psi240i.h b/drivers/scsi/psi240i.h
deleted file mode 100644
index 21ebb92..0000000
--- a/drivers/scsi/psi240i.h
+++ /dev/null
@@ -1,315 +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.h
- *
- *	Description:	Header file for the SCSI driver for the PSI240I
- *					EIDE interface card.
- *
- *-M*************************************************************************/
-#ifndef _PSI240I_H
-#define _PSI240I_H
-
-#include <linux/types.h>
-
-#ifndef	PSI_EIDE_SCSIOP
-#define	PSI_EIDE_SCSIOP	1
-
-/************************************************/
-/*		Some defines that we like 				*/
-/************************************************/
-#define	CHAR		char
-#define	UCHAR		unsigned char
-#define	SHORT		short
-#define	USHORT		unsigned short
-#define	BOOL		unsigned short
-#define	LONG		long
-#define	ULONG		unsigned long
-#define	VOID		void
-
-/************************************************/
-/*		Timeout konstants		 				*/
-/************************************************/
-#define	TIMEOUT_READY				10		// 100 mSec
-#define	TIMEOUT_DRQ					40		// 400 mSec
-
-/************************************************/
-/*		Misc. macros			 				*/
-/************************************************/
-#define ANY2SCSI(up, p)					\
-((UCHAR *)up)[0] = (((ULONG)(p)) >> 8);	\
-((UCHAR *)up)[1] = ((ULONG)(p));
-
-#define SCSI2LONG(up)					\
-( (((long)*(((UCHAR *)up))) << 16)		\
-+ (((long)(((UCHAR *)up)[1])) << 8)		\
-+ ((long)(((UCHAR *)up)[2])) )
-
-#define XANY2SCSI(up, p)				\
-((UCHAR *)up)[0] = ((long)(p)) >> 24;	\
-((UCHAR *)up)[1] = ((long)(p)) >> 16;	\
-((UCHAR *)up)[2] = ((long)(p)) >> 8;	\
-((UCHAR *)up)[3] = ((long)(p));
-
-#define XSCSI2LONG(up)					\
-( (((long)(((UCHAR *)up)[0])) << 24)	\
-+ (((long)(((UCHAR *)up)[1])) << 16)	\
-+ (((long)(((UCHAR *)up)[2])) <<  8)	\
-+ ((long)(((UCHAR *)up)[3])) )
-
-/************************************************/
-/*		SCSI CDB operation codes 				*/
-/************************************************/
-#define SCSIOP_TEST_UNIT_READY		0x00
-#define SCSIOP_REZERO_UNIT			0x01
-#define SCSIOP_REWIND				0x01
-#define SCSIOP_REQUEST_BLOCK_ADDR	0x02
-#define SCSIOP_REQUEST_SENSE		0x03
-#define SCSIOP_FORMAT_UNIT			0x04
-#define SCSIOP_READ_BLOCK_LIMITS	0x05
-#define SCSIOP_REASSIGN_BLOCKS		0x07
-#define SCSIOP_READ6				0x08
-#define SCSIOP_RECEIVE				0x08
-#define SCSIOP_WRITE6				0x0A
-#define SCSIOP_PRINT				0x0A
-#define SCSIOP_SEND					0x0A
-#define SCSIOP_SEEK6				0x0B
-#define SCSIOP_TRACK_SELECT			0x0B
-#define SCSIOP_SLEW_PRINT			0x0B
-#define SCSIOP_SEEK_BLOCK			0x0C
-#define SCSIOP_PARTITION			0x0D
-#define SCSIOP_READ_REVERSE			0x0F
-#define SCSIOP_WRITE_FILEMARKS		0x10
-#define SCSIOP_FLUSH_BUFFER			0x10
-#define SCSIOP_SPACE				0x11
-#define SCSIOP_INQUIRY				0x12
-#define SCSIOP_VERIFY6				0x13
-#define SCSIOP_RECOVER_BUF_DATA		0x14
-#define SCSIOP_MODE_SELECT			0x15
-#define SCSIOP_RESERVE_UNIT			0x16
-#define SCSIOP_RELEASE_UNIT			0x17
-#define SCSIOP_COPY					0x18
-#define SCSIOP_ERASE				0x19
-#define SCSIOP_MODE_SENSE			0x1A
-#define SCSIOP_START_STOP_UNIT		0x1B
-#define SCSIOP_STOP_PRINT			0x1B
-#define SCSIOP_LOAD_UNLOAD			0x1B
-#define SCSIOP_RECEIVE_DIAGNOSTIC	0x1C
-#define SCSIOP_SEND_DIAGNOSTIC		0x1D
-#define SCSIOP_MEDIUM_REMOVAL		0x1E
-#define SCSIOP_READ_CAPACITY		0x25
-#define SCSIOP_READ					0x28
-#define SCSIOP_WRITE				0x2A
-#define SCSIOP_SEEK					0x2B
-#define SCSIOP_LOCATE				0x2B
-#define SCSIOP_WRITE_VERIFY			0x2E
-#define SCSIOP_VERIFY				0x2F
-#define SCSIOP_SEARCH_DATA_HIGH		0x30
-#define SCSIOP_SEARCH_DATA_EQUAL	0x31
-#define SCSIOP_SEARCH_DATA_LOW		0x32
-#define SCSIOP_SET_LIMITS			0x33
-#define SCSIOP_READ_POSITION		0x34
-#define SCSIOP_SYNCHRONIZE_CACHE	0x35
-#define SCSIOP_COMPARE				0x39
-#define SCSIOP_COPY_COMPARE			0x3A
-#define SCSIOP_WRITE_DATA_BUFF		0x3B
-#define SCSIOP_READ_DATA_BUFF		0x3C
-#define SCSIOP_CHANGE_DEFINITION	0x40
-#define SCSIOP_READ_SUB_CHANNEL		0x42
-#define SCSIOP_READ_TOC				0x43
-#define SCSIOP_READ_HEADER			0x44
-#define SCSIOP_PLAY_AUDIO			0x45
-#define SCSIOP_PLAY_AUDIO_MSF		0x47
-#define SCSIOP_PLAY_TRACK_INDEX		0x48
-#define SCSIOP_PLAY_TRACK_RELATIVE	0x49
-#define SCSIOP_PAUSE_RESUME			0x4B
-#define SCSIOP_LOG_SELECT			0x4C
-#define SCSIOP_LOG_SENSE			0x4D
-#define SCSIOP_MODE_SELECT10		0x55
-#define SCSIOP_MODE_SENSE10			0x5A
-#define SCSIOP_LOAD_UNLOAD_SLOT		0xA6
-#define SCSIOP_MECHANISM_STATUS		0xBD
-#define SCSIOP_READ_CD				0xBE
-
-// IDE command definitions
-#define IDE_COMMAND_ATAPI_RESET		0x08
-#define IDE_COMMAND_READ			0x20
-#define IDE_COMMAND_WRITE			0x30
-#define IDE_COMMAND_RECALIBRATE		0x10
-#define IDE_COMMAND_SEEK			0x70
-#define IDE_COMMAND_SET_PARAMETERS	0x91
-#define IDE_COMMAND_VERIFY			0x40
-#define IDE_COMMAND_ATAPI_PACKET	0xA0
-#define IDE_COMMAND_ATAPI_IDENTIFY	0xA1
-#define	IDE_CMD_READ_MULTIPLE		0xC4
-#define	IDE_CMD_WRITE_MULTIPLE		0xC5
-#define	IDE_CMD_SET_MULTIPLE		0xC6
-#define IDE_COMMAND_WRITE_DMA		0xCA
-#define IDE_COMMAND_READ_DMA		0xC8
-#define IDE_COMMAND_IDENTIFY		0xEC
-
-// IDE status definitions
-#define IDE_STATUS_ERROR			0x01
-#define IDE_STATUS_INDEX			0x02
-#define IDE_STATUS_CORRECTED_ERROR	0x04
-#define IDE_STATUS_DRQ				0x08
-#define IDE_STATUS_DSC				0x10
-#define	IDE_STATUS_WRITE_FAULT		0x20
-#define IDE_STATUS_DRDY				0x40
-#define IDE_STATUS_BUSY				0x80
-
-// IDE error definitions
-#define	IDE_ERROR_AMNF				0x01
-#define	IDE_ERROR_TKONF				0x02
-#define	IDE_ERROR_ABRT				0x04
-#define	IDE_ERROR_MCR				0x08
-#define	IDE_ERROR_IDFN				0x10
-#define	IDE_ERROR_MC				0x20
-#define	IDE_ERROR_UNC				0x40
-#define	IDE_ERROR_BBK				0x80
-
-//	IDE interface structure
-typedef struct _IDE_STRUCT
-	{
-	union
-		{
-		UCHAR	ide[9];
-		struct
-			{
-			USHORT	data;
-			UCHAR	sectors;
-			UCHAR	lba[4];
-			UCHAR	cmd;
-			UCHAR	spigot;
-			}	ides;
-		} ide;
-	}	IDE_STRUCT;
-
-// SCSI read capacity structure
-typedef	struct _READ_CAPACITY_DATA
-	{
-	ULONG blks;				/* total blocks (converted to little endian) */
-	ULONG blksiz;			/* size of each (converted to little endian) */
-	}	READ_CAPACITY_DATA, *PREAD_CAPACITY_DATA;
-
-// SCSI inquiry data
-#ifndef HOSTS_C
-
-typedef struct _INQUIRYDATA
-	{
-	UCHAR DeviceType			:5;
-	UCHAR DeviceTypeQualifier	:3;
-	UCHAR DeviceTypeModifier	:7;
-	UCHAR RemovableMedia		:1;
-    UCHAR Versions;
-    UCHAR ResponseDataFormat;
-    UCHAR AdditionalLength;
-    UCHAR Reserved[2];
-	UCHAR SoftReset				:1;
-	UCHAR CommandQueue			:1;
-	UCHAR Reserved2				:1;
-	UCHAR LinkedCommands		:1;
-	UCHAR Synchronous			:1;
-	UCHAR Wide16Bit				:1;
-	UCHAR Wide32Bit				:1;
-	UCHAR RelativeAddressing	:1;
-    UCHAR VendorId[8];
-    UCHAR ProductId[16];
-    UCHAR ProductRevisionLevel[4];
-    UCHAR VendorSpecific[20];
-    UCHAR Reserved3[40];
-	}	INQUIRYDATA, *PINQUIRYDATA;
-#endif
-
-// IDE IDENTIFY data
-typedef struct _IDENTIFY_DATA
-	{
-    USHORT GeneralConfiguration;            // 00
-    USHORT NumberOfCylinders;               // 02
-    USHORT Reserved1;                       // 04
-    USHORT NumberOfHeads;                   // 06
-    USHORT UnformattedBytesPerTrack;        // 08
-    USHORT UnformattedBytesPerSector;       // 0A
-    USHORT SectorsPerTrack;                 // 0C
-    USHORT VendorUnique1[3];                // 0E
-    USHORT SerialNumber[10];                // 14
-    USHORT BufferType;                      // 28
-    USHORT BufferSectorSize;                // 2A
-    USHORT NumberOfEccBytes;                // 2C
-    USHORT FirmwareRevision[4];             // 2E
-    USHORT ModelNumber[20];                 // 36
-    UCHAR  MaximumBlockTransfer;            // 5E
-    UCHAR  VendorUnique2;                   // 5F
-    USHORT DoubleWordIo;                    // 60
-    USHORT Capabilities;                    // 62
-    USHORT Reserved2;                       // 64
-    UCHAR  VendorUnique3;                   // 66
-    UCHAR  PioCycleTimingMode;              // 67
-    UCHAR  VendorUnique4;                   // 68
-    UCHAR  DmaCycleTimingMode;              // 69
-    USHORT TranslationFieldsValid:1;        // 6A
-    USHORT Reserved3:15;
-    USHORT NumberOfCurrentCylinders;        // 6C
-    USHORT NumberOfCurrentHeads;            // 6E
-    USHORT CurrentSectorsPerTrack;          // 70
-    ULONG  CurrentSectorCapacity;           // 72
-    USHORT Reserved4[197];                  // 76
-	}	IDENTIFY_DATA, *PIDENTIFY_DATA;
-
-// Identify data without the Reserved4.
-typedef struct _IDENTIFY_DATA2 {
-    USHORT GeneralConfiguration;            // 00
-    USHORT NumberOfCylinders;               // 02
-    USHORT Reserved1;                       // 04
-    USHORT NumberOfHeads;                   // 06
-    USHORT UnformattedBytesPerTrack;        // 08
-    USHORT UnformattedBytesPerSector;       // 0A
-    USHORT SectorsPerTrack;                 // 0C
-    USHORT VendorUnique1[3];                // 0E
-    USHORT SerialNumber[10];                // 14
-    USHORT BufferType;                      // 28
-    USHORT BufferSectorSize;                // 2A
-    USHORT NumberOfEccBytes;                // 2C
-    USHORT FirmwareRevision[4];             // 2E
-    USHORT ModelNumber[20];                 // 36
-    UCHAR  MaximumBlockTransfer;            // 5E
-    UCHAR  VendorUnique2;                   // 5F
-    USHORT DoubleWordIo;                    // 60
-    USHORT Capabilities;                    // 62
-    USHORT Reserved2;                       // 64
-    UCHAR  VendorUnique3;                   // 66
-    UCHAR  PioCycleTimingMode;              // 67
-    UCHAR  VendorUnique4;                   // 68
-    UCHAR  DmaCycleTimingMode;              // 69
-	USHORT TranslationFieldsValid:1;     	// 6A
-    USHORT Reserved3:15;
-    USHORT NumberOfCurrentCylinders;        // 6C
-    USHORT NumberOfCurrentHeads;            // 6E
-    USHORT CurrentSectorsPerTrack;          // 70
-    ULONG  CurrentSectorCapacity;           // 72
-	}	IDENTIFY_DATA2, *PIDENTIFY_DATA2;
-
-#endif	// PSI_EIDE_SCSIOP
-
-// function prototypes
-int Psi240i_Command(struct scsi_cmnd *SCpnt);
-int Psi240i_Abort(struct scsi_cmnd *SCpnt);
-int Psi240i_Reset(struct scsi_cmnd *SCpnt, unsigned int flags);
-#endif
diff --git a/drivers/scsi/psi_chip.h b/drivers/scsi/psi_chip.h
deleted file mode 100644
index 224cf8f..0000000
--- a/drivers/scsi/psi_chip.h
+++ /dev/null
@@ -1,195 +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:	psi_chip.h
- *
- *	Description:	This file contains the interface defines and
- *					error codes.
- *
- *-M*************************************************************************/
-#ifndef PSI_CHIP
-#define PSI_CHIP
-
-/************************************************/
-/*		Misc konstants							*/
-/************************************************/
-#define	CHIP_MAXDRIVES			8
-
-/************************************************/
-/*		Chip I/O addresses						*/
-/************************************************/
-#define	CHIP_ADRS_0				0x0130
-#define	CHIP_ADRS_1				0x0150
-#define	CHIP_ADRS_2				0x0190
-#define	CHIP_ADRS_3				0x0210
-#define	CHIP_ADRS_4				0x0230
-#define	CHIP_ADRS_5				0x0250
-
-/************************************************/
-/*		EEPROM locations		*/
-/************************************************/
-#define	CHIP_EEPROM_BIOS		0x0000		// BIOS base address
-#define	CHIP_EEPROM_DATA		0x2000	   	// SETUP data base address
-#define	CHIP_EEPROM_FACTORY		0x2400	   	// FACTORY data base address
-#define	CHIP_EEPROM_SETUP		0x3000	   	// SETUP PROGRAM base address
-
-#define	CHIP_EEPROM_SIZE		32768U	   	// size of the entire EEPROM
-#define	CHIP_EEPROM_BIOS_SIZE	8192	   	// size of the BIOS in bytes
-#define	CHIP_EEPROM_DATA_SIZE	4096	   	// size of factory, setup, log data block in bytes
-#define	CHIP_EEPROM_SETUP_SIZE	20480U	   	// size of the setup program in bytes
-
-/************************************************/
-/*		Chip Interrupts							*/
-/************************************************/
-#define	CHIP_IRQ_10				0x72
-#define	CHIP_IRQ_11				0x73
-#define	CHIP_IRQ_12				0x74
-
-/************************************************/
-/*		Chip Setup addresses		*/
-/************************************************/
-#define	CHIP_SETUP_BASE			0x0000C000L
-
-/************************************************/
-/*		Chip Register address offsets	*/
-/************************************************/
-#define	REG_DATA				0x00
-#define	REG_ERROR				0x01
-#define	REG_SECTOR_COUNT		0x02
-#define	REG_LBA_0				0x03
-#define	REG_LBA_8				0x04
-#define	REG_LBA_16				0x05
-#define	REG_LBA_24				0x06
-#define	REG_STAT_CMD			0x07
-#define	REG_SEL_FAIL			0x08
-#define	REG_IRQ_STATUS			0x09
-#define	REG_ADDRESS				0x0A
-#define	REG_FAIL				0x0C
-#define	REG_ALT_STAT		   	0x0E
-#define	REG_DRIVE_ADRS			0x0F
-
-/************************************************/
-/*		Chip RAM locations		*/
-/************************************************/
-#define	CHIP_DEVICE				0x8000
-#define	CHIP_DEVICE_0			0x8000
-#define CHIP_DEVICE_1			0x8008
-#define	CHIP_DEVICE_2			0x8010
-#define	CHIP_DEVICE_3			0x8018
-#define	CHIP_DEVICE_4			0x8020
-#define	CHIP_DEVICE_5			0x8028
-#define	CHIP_DEVICE_6			0x8030
-#define	CHIP_DEVICE_7			0x8038
-typedef struct
-	{
-	UCHAR	channel;		// channel of this device (0-8).
-	UCHAR	spt;			// Sectors Per Track.
-	ULONG	spc;			// Sectors Per Cylinder.
-	}	CHIP_DEVICE_N;
-
-#define	CHIP_CONFIG				0x8100		// address of boards configuration.
-typedef struct
-	{
-	UCHAR		irq;			// interrupt request channel number
-	UCHAR		numDrives;		// Number of accessible drives
-	UCHAR		fastFormat;	 	// Boolean for fast format enable
-	}	CHIP_CONFIG_N;
-
-#define	CHIP_MAP				0x8108 		// eight byte device type map.
-
-
-#define	CHIP_RAID				0x8120 		// array of RAID signature structures and LBA
-#define	CHIP_RAID_1				0x8120
-#define CHIP_RAID_2				0x8130
-#define	CHIP_RAID_3				0x8140
-#define	CHIP_RAID_4				0x8150
-
-/************************************************/
-/*		Chip Register Masks		*/
-/************************************************/
-#define	CHIP_ID					0x7B
-#define	SEL_RAM					0x8000
-#define	MASK_FAIL				0x80
-
-/************************************************/
-/*		Chip cable select bits		*/
-/************************************************/
-#define	SECTORSXFER				8
-
-/************************************************/
-/*		Chip cable select bits		*/
-/************************************************/
-#define	SEL_NONE				0x00
-#define	SEL_1					0x01
-#define	SEL_2					0x02
-#define	SEL_3					0x04
-#define	SEL_4					0x08
-
-/************************************************/
-/*		Programmable Interrupt Controller*/
-/************************************************/
-#define	PIC1					0x20		// first 8259 base port address
-#define	PIC2					0xA0		// second 8259 base port address
-#define	INT_OCW1				1			// Operation Control Word 1: IRQ mask
-#define	EOI						0x20		// non-specific end-of-interrupt
-
-/************************************************/
-/*		Device/Geometry controls				*/
-/************************************************/
-#define GEOMETRY_NONE		 	0x0			// No device
-#define GEOMETRY_AUTO			0x1			// Geometry set automatically
-#define GEOMETRY_USER		 	0x2			// User supplied geometry
-
-#define	DEVICE_NONE				0x0			// No device present
-#define	DEVICE_INACTIVE			0x1			// device present but not registered active
-#define	DEVICE_ATAPI			0x2			// ATAPI device (CD_ROM, Tape, Etc...)
-#define	DEVICE_DASD_NONLBA		0x3			// Non LBA incompatible device
-#define	DEVICE_DASD_LBA			0x4			// LBA compatible device
-
-/************************************************/
-/*		Setup Structure Definitions	*/
-/************************************************/
-typedef struct							// device setup parameters
-	{
-	UCHAR			geometryControl;	// geometry control flags
-	UCHAR		   	device;				// device code
-	USHORT			sectors;			// number of sectors per track
-	USHORT			heads;				// number of heads
-	USHORT			cylinders;			// number of cylinders for this device
-	ULONG			blocks;				// number of blocks on device
-	USHORT			spare1;
-	USHORT			spare2;
-	} SETUP_DEVICE, *PSETUP_DEVICE;
-
-typedef struct		// master setup structure
-	{
-	USHORT 			startupDelay;
-	USHORT 			promptBIOS;
-	USHORT 			fastFormat;
-	USHORT			spare2;
-	USHORT			spare3;
-	USHORT			spare4;
-	USHORT			spare5;
-	USHORT			spare6;
-	SETUP_DEVICE	setupDevice[8];
-	}	SETUP, *PSETUP;
-
-#endif
-
-- 
1.5.3.1



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

* [PATCH 23/24] wd7000.c - proper fix for boards without sg support
  2007-09-11 20:23 [patchset 0/24] Lots of the Accessors patches and !use_sg cleanup Boaz Harrosh
                   ` (22 preceding siblings ...)
  2007-09-12  0:10 ` Subject: [PATCH 22/24] Remove psi240i driver from kernel Boaz Harrosh
@ 2007-09-12  0:11 ` Boaz Harrosh
  2007-09-12  0:13 ` [PATCH 24/24] ide-scsi.c: convert to data accessors and !use_sg cleanup Boaz Harrosh
                   ` (3 subsequent siblings)
  27 siblings, 0 replies; 59+ messages in thread
From: Boaz Harrosh @ 2007-09-12  0:11 UTC (permalink / raw)
  To: James Bottomley, FUJITA Tomonori, Greg Kroah-Hartman, Alan Stern,
	Matthew


  - 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 <bharrosh@panasas.com>
---
 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



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

* [PATCH 24/24] ide-scsi.c: convert to data accessors and !use_sg cleanup
  2007-09-11 20:23 [patchset 0/24] Lots of the Accessors patches and !use_sg cleanup Boaz Harrosh
                   ` (23 preceding siblings ...)
  2007-09-12  0:11 ` [PATCH 23/24] wd7000.c - proper fix for boards without sg support Boaz Harrosh
@ 2007-09-12  0:13 ` Boaz Harrosh
  2007-09-17 11:04   ` Bartlomiej Zolnierkiewicz
                     ` (2 more replies)
  2007-09-12 16:00 ` [patchset 0/24] Lots of the Accessors patches " Maciej W. Rozycki
                   ` (2 subsequent siblings)
  27 siblings, 3 replies; 59+ messages in thread
From: Boaz Harrosh @ 2007-09-12  0:13 UTC (permalink / raw)
  To: James Bottomley, FUJITA Tomonori, Greg Kroah-Hartman, Alan Stern,
	Matthew


 - 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 <bharrosh@panasas.com>
---
 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);
 
 	if (segments > hwif->sg_max_nents)
 		return 1;
 
-	if (!segments) {
-		hwif->sg_nents = 1;
-		sg_init_one(sg, pc->scsi_cmd->request_buffer, pc->request_transfer);
-	} else {
-		hwif->sg_nents = segments;
-		memcpy(sg, scsi_sg, sizeof(*sg) * segments);
-	}
+	hwif->sg_nents = segments;
+	memcpy(sg, scsi_sg, sizeof(*sg) * segments);
 
 	return 0;
 }
@@ -905,15 +925,10 @@ static int idescsi_queue (struct scsi_cmnd *cmd,
 	pc->flags = 0;
 	pc->rq = rq;
 	memcpy (pc->c, cmd->cmnd, cmd->cmd_len);
-	if (cmd->use_sg) {
-		pc->buffer = NULL;
-		pc->sg = cmd->request_buffer;
-	} else {
-		pc->buffer = cmd->request_buffer;
-		pc->sg = NULL;
-	}
+	pc->buffer = NULL;
+	pc->sg = scsi_sglist(cmd);
 	pc->b_count = 0;
-	pc->request_transfer = pc->buffer_size = cmd->request_bufflen;
+	pc->request_transfer = pc->buffer_size = scsi_bufflen(cmd);
 	pc->scsi_cmd = cmd;
 	pc->done = done;
 	pc->timeout = jiffies + cmd->timeout_per_command;
-- 
1.5.3.1



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

* Re: [PATCH 09/24] libata-scsi: convert to use the data buffer accessors
  2007-09-12  0:09   ` Jeff Garzik
@ 2007-09-12  0:25     ` Boaz Harrosh
  2007-09-12  1:40     ` Matthew Dharm
                       ` (2 subsequent siblings)
  3 siblings, 0 replies; 59+ messages in thread
From: Boaz Harrosh @ 2007-09-12  0:25 UTC (permalink / raw)
  To: Jeff Garzik, linux-scsi

On Wed, Sep 12 2007 at 3:09 +0300, Jeff Garzik <jeff@garzik.org> 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

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

* Re: [PATCH 09/24] libata-scsi: convert to use the data buffer accessors
  2007-09-12  0:09   ` Jeff Garzik
  2007-09-12  0:25     ` Boaz Harrosh
@ 2007-09-12  1:40     ` Matthew Dharm
  2007-09-12  6:36       ` Boaz Harrosh
  2007-09-18 15:46     ` [PATCH ver2 1/2] libata-scsi: Remove !use_sg code paths Boaz Harrosh
  2007-09-18 15:48     ` [PATCH ver2 2/2] libata-scsi: convert to use the data buffer accessors Boaz Harrosh
  3 siblings, 1 reply; 59+ messages in thread
From: Matthew Dharm @ 2007-09-12  1:40 UTC (permalink / raw)
  To: Jeff Garzik
  Cc: Boaz Harrosh, James Bottomley, FUJITA Tomonori,
	Greg Kroah-Hartman, Alan Stern, Russell King, David S. Miller,
	Bartlomiej Zolnierkiewicz, YOKOTA Hiroshi, linux-scsi,
	Maciej W. Rozycki, Mark Fortescue

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

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: mdharm-usb@one-eyed-alien.net 
Maintainer, Linux USB Mass Storage Driver

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

[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]

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

* Re: [PATCH 09/24] libata-scsi: convert to use the data buffer accessors
  2007-09-12  1:40     ` Matthew Dharm
@ 2007-09-12  6:36       ` Boaz Harrosh
  0 siblings, 0 replies; 59+ messages in thread
From: Boaz Harrosh @ 2007-09-12  6:36 UTC (permalink / raw)
  To: Jeff Garzik, Boaz Harrosh, James Bottomley, FUJITA Tomonori,
	Greg 

On 9/12/07, Matthew Dharm <mdharm-scsi@one-eyed-alien.net> wrote:
> 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
>

The last place that did !use_sg was fixed Yesterday. It was the
REQUEST_SENSE in usb's transport.c
The before the last one was removed by Christoph in 2.6.18

Boaz

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

* Re: [PATCH 07/24] arm: scsi convert to accessors and !use_sg cleanup
  2007-09-11 23:55 ` [PATCH 07/24] arm: scsi convert to accessors and " Boaz Harrosh
@ 2007-09-12  7:42   ` Russell King
  2007-09-18 15:04     ` Boaz Harrosh
  2008-01-31 18:09     ` James Bottomley
  0 siblings, 2 replies; 59+ messages in thread
From: Russell King @ 2007-09-12  7:42 UTC (permalink / raw)
  To: Boaz Harrosh
  Cc: James Bottomley, FUJITA Tomonori, Greg Kroah-Hartman, Alan Stern,
	Matthew Dharm, Jeff Garzik, David S. Miller,
	Bartlomiej Zolnierkiewicz, YOKOTA Hiroshi, linux-scsi,
	Maciej W. Rozycki, Mark Fortescue

On Wed, Sep 12, 2007 at 02:55:19AM +0300, Boaz Harrosh wrote:
> -		if (SCpnt->request_bufflen != len)
> +		if (scsi_bufflen(SCpnt) != len) {
> +			WARN_ON(1);

NAK.  The call trace generally doesn't provide any additional information
on the cause of the error.

>  			printk(KERN_WARNING "scsi%d.%c: bad request buffer "
>  			       "length %d, should be %ld\n", SCpnt->device->host->host_no,
> -			       '0' + SCpnt->device->id, SCpnt->request_bufflen, len);
> -		SCpnt->request_bufflen = len;
> +			       '0' + SCpnt->device->id, scsi_bufflen(SCpnt), len);
> +		}
>  #endif
>  	} else {
> -		SCpnt->SCp.ptr = (unsigned char *)SCpnt->request_buffer;
> -		SCpnt->SCp.this_residual = SCpnt->request_bufflen;
> -		SCpnt->SCp.phase = SCpnt->request_bufflen;
> -	}
> -
> -	/*
> -	 * If the upper SCSI layers pass a buffer, but zero length,
> -	 * we aren't interested in the buffer pointer.
> -	 */
> -	if (SCpnt->SCp.this_residual == 0 && SCpnt->SCp.ptr) {
> -#if 0 //def BELT_AND_BRACES
> -		printk(KERN_WARNING "scsi%d.%c: zero length buffer passed for "
> -		       "command ", SCpnt->host->host_no, '0' + SCpnt->target);
> -		__scsi_print_command(SCpnt->cmnd);
> -#endif
>  		SCpnt->SCp.ptr = NULL;
> +		SCpnt->SCp.this_residual = 0;
> +		SCpnt->SCp.phase = 0;
>  	}
>  }

Also NAK.  This was added due to bad behaviour of the SCSI layer and
was found to be necessary.

-- 
Russell King
 Linux kernel    2.6 ARM Linux   - http://www.arm.linux.org.uk/
 maintainer of:

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

* Re: [patchset 0/24] Lots of the Accessors patches and !use_sg cleanup
  2007-09-11 20:23 [patchset 0/24] Lots of the Accessors patches and !use_sg cleanup Boaz Harrosh
                   ` (24 preceding siblings ...)
  2007-09-12  0:13 ` [PATCH 24/24] ide-scsi.c: convert to data accessors and !use_sg cleanup Boaz Harrosh
@ 2007-09-12 16:00 ` Maciej W. Rozycki
  2007-09-17 10:46 ` Bartlomiej Zolnierkiewicz
  2007-10-10 18:24 ` Boaz Harrosh
  27 siblings, 0 replies; 59+ messages in thread
From: Maciej W. Rozycki @ 2007-09-12 16:00 UTC (permalink / raw)
  To: Boaz Harrosh
  Cc: James Bottomley, FUJITA Tomonori, Greg Kroah-Hartman, Alan Stern,
	Matthew Dharm, Russell King, Jeff Garzik, David S. Miller,
	Bartlomiej Zolnierkiewicz, YOKOTA Hiroshi, linux-scsi,
	Mark Fortescue

On Tue, 11 Sep 2007, Boaz Harrosh wrote:

> [esp family] - Maciej W. Rozycki <macro@linux-mips.org>
> 0020 	drivers/scsi/NCR53C9x.c drivers/scsi/NCR53C9x.h
> 	drivers/scsi/dec_esp.c drivers/scsi/oktagon_esp.c
> 	drivers/scsi/sun3x_esp.c

 Not really, but I have suitable hardware and can test your changes to 
drivers/scsi/NCR53C9x.c, drivers/scsi/NCR53C9x.h and 
drivers/scsi/dec_esp.c only.  Fortunately it does not really matter that 
much, because the the whole family of drivers has been deprecated and is 
going away at some pace in favour to the framework around the new 
drivers/scsi/esp_scsi.c core.

 Thanks for your effort though!

  Maciej

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

* Re: [patchset 0/24] Lots of the Accessors patches and !use_sg cleanup
  2007-09-11 20:23 [patchset 0/24] Lots of the Accessors patches and !use_sg cleanup Boaz Harrosh
                   ` (25 preceding siblings ...)
  2007-09-12 16:00 ` [patchset 0/24] Lots of the Accessors patches " Maciej W. Rozycki
@ 2007-09-17 10:46 ` Bartlomiej Zolnierkiewicz
  2007-09-17 11:36   ` Boaz Harrosh
  2007-09-17 13:51   ` James Bottomley
  2007-10-10 18:24 ` Boaz Harrosh
  27 siblings, 2 replies; 59+ messages in thread
From: Bartlomiej Zolnierkiewicz @ 2007-09-17 10:46 UTC (permalink / raw)
  To: Boaz Harrosh
  Cc: James Bottomley, FUJITA Tomonori, Greg Kroah-Hartman, Alan Stern,
	Matthew Dharm, Russell King, Jeff Garzik, David S. Miller,
	YOKOTA Hiroshi, linux-scsi, Maciej W. Rozycki, Mark Fortescue

On Tuesday 11 September 2007, Boaz Harrosh wrote:
> Here are more accessors patches. I have tried
> to find Maintainers of drivers but please help me if
> I missed any.

[ ... ]

> 0010 	drivers/scsi/eata_pio.c - Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ?

not me, according to MAINTAINTERS file:

EATA-PIO SCSI DRIVER
P:      Michael Neuffer
M:      mike@i-Connect.Net
L:      linux-eata@i-connect.net, linux-scsi@vger.kernel.org
S:      Maintained

BTW patch looks obviously OK

> 0024 	drivers/scsi/ide-scsi.c - Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>

This reminds me that ide-scsi needs a real Maintainer, I don't have a time to
closely follow-up SCSI changes...

Thanks,
Bart

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

* Re: [PATCH 24/24] ide-scsi.c: convert to data accessors and !use_sg cleanup
  2007-09-12  0:13 ` [PATCH 24/24] ide-scsi.c: convert to data accessors and !use_sg cleanup Boaz Harrosh
@ 2007-09-17 11:04   ` Bartlomiej Zolnierkiewicz
  2007-09-18  8:49     ` Boaz Harrosh
  2007-09-18  9:03   ` [PATCH ver2 " Boaz Harrosh
  2007-09-18 10:27   ` [PATCH 24/24 ver3 ] " Boaz Harrosh
  2 siblings, 1 reply; 59+ messages in thread
From: Bartlomiej Zolnierkiewicz @ 2007-09-17 11:04 UTC (permalink / raw)
  To: Boaz Harrosh
  Cc: James Bottomley, FUJITA Tomonori, Greg Kroah-Hartman, Alan Stern,
	Matthew Dharm, Russell King, Jeff Garzik, David S. Miller,
	YOKOTA Hiroshi, linux-scsi, Maciej W. Rozycki, Mark Fortescue

On Wednesday 12 September 2007, Boaz Harrosh wrote:
> 
>  - 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).

Sigh... somebody forgot to update ide-scsi.c while making SCSI use
only sg for REQ_TYPE_BLOCK_PC.

>   I have commented out the offending code and put a
>   WARN_ON(1) in it's place. So if there is missing functionality

in idescsi_transform_pc2():

        if (drive->media == ide_cdrom || drive->media == ide_optical) {
...
		WARN_ON(1) + #if/#endif 0 should be here
...
	}

rest of the changes look OK and you can add my ACK after fixing
idescsi_transform_pc2()

>   it will complain but will not crash the kernel.

sr is likely to complain due to scsi_mode_sense() usage :(

>   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 <bharrosh@panasas.com>
> ---
>  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);
>  
>  	if (segments > hwif->sg_max_nents)
>  		return 1;
>  
> -	if (!segments) {
> -		hwif->sg_nents = 1;
> -		sg_init_one(sg, pc->scsi_cmd->request_buffer, pc->request_transfer);
> -	} else {
> -		hwif->sg_nents = segments;
> -		memcpy(sg, scsi_sg, sizeof(*sg) * segments);
> -	}
> +	hwif->sg_nents = segments;
> +	memcpy(sg, scsi_sg, sizeof(*sg) * segments);
>  
>  	return 0;
>  }
> @@ -905,15 +925,10 @@ static int idescsi_queue (struct scsi_cmnd *cmd,
>  	pc->flags = 0;
>  	pc->rq = rq;
>  	memcpy (pc->c, cmd->cmnd, cmd->cmd_len);
> -	if (cmd->use_sg) {
> -		pc->buffer = NULL;
> -		pc->sg = cmd->request_buffer;
> -	} else {
> -		pc->buffer = cmd->request_buffer;
> -		pc->sg = NULL;
> -	}
> +	pc->buffer = NULL;
> +	pc->sg = scsi_sglist(cmd);
>  	pc->b_count = 0;
> -	pc->request_transfer = pc->buffer_size = cmd->request_bufflen;
> +	pc->request_transfer = pc->buffer_size = scsi_bufflen(cmd);
>  	pc->scsi_cmd = cmd;
>  	pc->done = done;
>  	pc->timeout = jiffies + cmd->timeout_per_command;

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

* Re: [patchset 0/24] Lots of the Accessors patches and !use_sg cleanup
  2007-09-17 10:46 ` Bartlomiej Zolnierkiewicz
@ 2007-09-17 11:36   ` Boaz Harrosh
  2007-09-17 13:51   ` James Bottomley
  1 sibling, 0 replies; 59+ messages in thread
From: Boaz Harrosh @ 2007-09-17 11:36 UTC (permalink / raw)
  To: Bartlomiej Zolnierkiewicz; +Cc: linux-scsi

On Mon, Sep 17 2007 at 12:46 +0200, Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> wrote:
> On Tuesday 11 September 2007, Boaz Harrosh wrote:
>> Here are more accessors patches. I have tried
>> to find Maintainers of drivers but please help me if
>> I missed any.
> 
> [ ... ]
> 
>> 0010 	drivers/scsi/eata_pio.c - Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ?
> 
> not me, according to MAINTAINTERS file:
> 
> EATA-PIO SCSI DRIVER
> P:      Michael Neuffer
> M:      mike@i-Connect.Net
> L:      linux-eata@i-connect.net, linux-scsi@vger.kernel.org
> S:      Maintained
> 
> BTW patch looks obviously OK
> 
>> 0024 	drivers/scsi/ide-scsi.c - Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
> 
> This reminds me that ide-scsi needs a real Maintainer, I don't have a time to
> closely follow-up SCSI changes...
> 
> Thanks,
> Bart

Thanks! I sent him and the list a Note. I hope to get their ACK.

I did a case insensitive search on MAINTAINTERS for most drivers
but here I tripped over the "-" vs "_" thing.

Is there a script that helps match file name to maintainer?

Thanks again
Boaz


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

* Re: [patchset 0/24] Lots of the Accessors patches and !use_sg cleanup
  2007-09-17 10:46 ` Bartlomiej Zolnierkiewicz
  2007-09-17 11:36   ` Boaz Harrosh
@ 2007-09-17 13:51   ` James Bottomley
  2007-09-17 20:05     ` Bartlomiej Zolnierkiewicz
  1 sibling, 1 reply; 59+ messages in thread
From: James Bottomley @ 2007-09-17 13:51 UTC (permalink / raw)
  To: Bartlomiej Zolnierkiewicz
  Cc: Boaz Harrosh, FUJITA Tomonori, Greg Kroah-Hartman, Alan Stern,
	Matthew Dharm, Russell King, Jeff Garzik, David S. Miller,
	YOKOTA Hiroshi, linux-scsi, Maciej W. Rozycki, Mark Fortescue,
	osst

On Mon, 2007-09-17 at 12:46 +0200, Bartlomiej Zolnierkiewicz wrote:
> 0024  drivers/scsi/ide-scsi.c - Bartlomiej Zolnierkiewicz
> <bzolnier@gmail.com>
> 
> This reminds me that ide-scsi needs a real Maintainer, I don't have a
> time to
> closely follow-up SCSI changes...

Er, well, I thought it had been dead for some time ... we decided its
many bugs were virtually unfixable in 2.5.  Willem Riede
<osst@riede.org> had been trying to keep it working with chewing gum and
bailing wire for the onstream tape unit.

Realistically (and I hate myself for saying this) libata-pata does
provide a much better alternative for the ATAPI devices.  Is it just
time to recognise the inevitable and kill ide-scsi?

James



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

* Re: [patchset 0/24] Lots of the Accessors patches and !use_sg cleanup
  2007-09-17 13:51   ` James Bottomley
@ 2007-09-17 20:05     ` Bartlomiej Zolnierkiewicz
  2007-09-17 20:57       ` Jeff Garzik
  0 siblings, 1 reply; 59+ messages in thread
From: Bartlomiej Zolnierkiewicz @ 2007-09-17 20:05 UTC (permalink / raw)
  To: James Bottomley
  Cc: Boaz Harrosh, FUJITA Tomonori, Greg Kroah-Hartman, Alan Stern,
	Matthew Dharm, Russell King, Jeff Garzik, David S. Miller,
	YOKOTA Hiroshi, linux-scsi, Maciej W. Rozycki, Mark Fortescue,
	osst


On Monday 17 September 2007, James Bottomley wrote:
> On Mon, 2007-09-17 at 12:46 +0200, Bartlomiej Zolnierkiewicz wrote:
> > 0024  drivers/scsi/ide-scsi.c - Bartlomiej Zolnierkiewicz
> > <bzolnier@gmail.com>
> > 
> > This reminds me that ide-scsi needs a real Maintainer, I don't have a
> > time to
> > closely follow-up SCSI changes...
> 
> Er, well, I thought it had been dead for some time ... we decided its

>From looking at git log output I suspect that it has been dead since
October 2006 (but I hasn't verified this yet so I may be wrong).

> many bugs were virtually unfixable in 2.5.  Willem Riede
> <osst@riede.org> had been trying to keep it working with chewing gum and
> bailing wire for the onstream tape unit.

Yes, osst driver seems to be the main user of ide-scsi nowadays,
other ATAPI devices has (better) native IDE support...

> Realistically (and I hate myself for saying this) libata-pata does
> provide a much better alternative for the ATAPI devices.  Is it just
> time to recognise the inevitable and kill ide-scsi?

Agreed, libata-pata is a much better version of ide-scsi. ;-)

If there is general consensus about ide-scsi removal I think that we
should start with disabling ide-scsi Kconfig entry in 2.6.24 to later
remove the ide-scsi driver completely in 2.6.25.

Bart

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

* Re: [patchset 0/24] Lots of the Accessors patches and !use_sg cleanup
  2007-09-17 20:05     ` Bartlomiej Zolnierkiewicz
@ 2007-09-17 20:57       ` Jeff Garzik
  2007-09-17 21:00         ` James Bottomley
  0 siblings, 1 reply; 59+ messages in thread
From: Jeff Garzik @ 2007-09-17 20:57 UTC (permalink / raw)
  To: Bartlomiej Zolnierkiewicz
  Cc: James Bottomley, Boaz Harrosh, FUJITA Tomonori,
	Greg Kroah-Hartman, Alan Stern, Matthew Dharm, Russell King,
	David S. Miller, YOKOTA Hiroshi, linux-scsi, Maciej W. Rozycki,
	Mark Fortescue, osst

Bartlomiej Zolnierkiewicz wrote:
> On Monday 17 September 2007, James Bottomley wrote:
>> Realistically (and I hate myself for saying this) libata-pata does
>> provide a much better alternative for the ATAPI devices.  Is it just
>> time to recognise the inevitable and kill ide-scsi?
> 
> Agreed, libata-pata is a much better version of ide-scsi. ;-)
> 
> If there is general consensus about ide-scsi removal I think that we
> should start with disabling ide-scsi Kconfig entry in 2.6.24 to later
> remove the ide-scsi driver completely in 2.6.25.


Perhaps it is strange to hear me say this, but...

My experience with the IDE driver in the field is that ide-scsi sees a 
fair amount of use, as an intentional replacement for ide-cd and the 
other hand-written ide-$class ATAPI drivers.

I would prefer that ide-scsi stays around as long as ide stays around.

	Jeff



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

* Re: [patchset 0/24] Lots of the Accessors patches and !use_sg cleanup
  2007-09-17 20:57       ` Jeff Garzik
@ 2007-09-17 21:00         ` James Bottomley
  2007-09-17 21:05           ` Jeff Garzik
  0 siblings, 1 reply; 59+ messages in thread
From: James Bottomley @ 2007-09-17 21:00 UTC (permalink / raw)
  To: Jeff Garzik
  Cc: Bartlomiej Zolnierkiewicz, Boaz Harrosh, FUJITA Tomonori,
	Greg Kroah-Hartman, Alan Stern, Matthew Dharm, Russell King,
	David S. Miller, YOKOTA Hiroshi, linux-scsi, Maciej W. Rozycki,
	Mark Fortescue, osst

On Mon, 2007-09-17 at 16:57 -0400, Jeff Garzik wrote:
> Bartlomiej Zolnierkiewicz wrote:
> > On Monday 17 September 2007, James Bottomley wrote:
> >> Realistically (and I hate myself for saying this) libata-pata does
> >> provide a much better alternative for the ATAPI devices.  Is it just
> >> time to recognise the inevitable and kill ide-scsi?
> > 
> > Agreed, libata-pata is a much better version of ide-scsi. ;-)
> > 
> > If there is general consensus about ide-scsi removal I think that we
> > should start with disabling ide-scsi Kconfig entry in 2.6.24 to later
> > remove the ide-scsi driver completely in 2.6.25.
> 
> 
> Perhaps it is strange to hear me say this, but...
> 
> My experience with the IDE driver in the field is that ide-scsi sees a 
> fair amount of use, as an intentional replacement for ide-cd and the 
> other hand-written ide-$class ATAPI drivers.
> 
> I would prefer that ide-scsi stays around as long as ide stays around.

Of course ... as long as we get to address you as Mr Maintainer ...

James



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

* Re: [patchset 0/24] Lots of the Accessors patches and !use_sg cleanup
  2007-09-17 21:00         ` James Bottomley
@ 2007-09-17 21:05           ` Jeff Garzik
  0 siblings, 0 replies; 59+ messages in thread
From: Jeff Garzik @ 2007-09-17 21:05 UTC (permalink / raw)
  To: James Bottomley
  Cc: Bartlomiej Zolnierkiewicz, Boaz Harrosh, FUJITA Tomonori,
	Greg Kroah-Hartman, Alan Stern, Matthew Dharm, Russell King,
	David S. Miller, YOKOTA Hiroshi, linux-scsi, Maciej W. Rozycki,
	Mark Fortescue, osst

James Bottomley wrote:
> On Mon, 2007-09-17 at 16:57 -0400, Jeff Garzik wrote:
>> Bartlomiej Zolnierkiewicz wrote:
>>> On Monday 17 September 2007, James Bottomley wrote:
>>>> Realistically (and I hate myself for saying this) libata-pata does
>>>> provide a much better alternative for the ATAPI devices.  Is it just
>>>> time to recognise the inevitable and kill ide-scsi?
>>> Agreed, libata-pata is a much better version of ide-scsi. ;-)
>>>
>>> If there is general consensus about ide-scsi removal I think that we
>>> should start with disabling ide-scsi Kconfig entry in 2.6.24 to later
>>> remove the ide-scsi driver completely in 2.6.25.
>>
>> Perhaps it is strange to hear me say this, but...
>>
>> My experience with the IDE driver in the field is that ide-scsi sees a 
>> fair amount of use, as an intentional replacement for ide-cd and the 
>> other hand-written ide-$class ATAPI drivers.
>>
>> I would prefer that ide-scsi stays around as long as ide stays around.
> 
> Of course ... as long as we get to address you as Mr Maintainer ...

I don't claim maintainer, I only claim there are quite a few _users_.

Which is IMO the far more relevant point.

	Jeff




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

* Re: [PATCH 24/24] ide-scsi.c: convert to data accessors and !use_sg cleanup
  2007-09-17 11:04   ` Bartlomiej Zolnierkiewicz
@ 2007-09-18  8:49     ` Boaz Harrosh
  0 siblings, 0 replies; 59+ messages in thread
From: Boaz Harrosh @ 2007-09-18  8:49 UTC (permalink / raw)
  To: Bartlomiej Zolnierkiewicz, James Bottomley, Jeff Garzik
  Cc: FUJITA Tomonori, Greg Kroah-Hartman, Alan Stern, Matthew Dharm,
	Russell King, David S. Miller, YOKOTA Hiroshi, linux-scsi,
	Maciej W. Rozycki, Mark Fortescue

On Mon, Sep 17 2007 at 13:04 +0200, Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> wrote:
> On Wednesday 12 September 2007, Boaz Harrosh wrote:
>>  - 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).
> 
> Sigh... somebody forgot to update ide-scsi.c while making SCSI use
> only sg for REQ_TYPE_BLOCK_PC.
> 
>>   I have commented out the offending code and put a
>>   WARN_ON(1) in it's place. So if there is missing functionality
> 
> in idescsi_transform_pc2():
> 
>         if (drive->media == ide_cdrom || drive->media == ide_optical) {
> ...
> 		WARN_ON(1) + #if/#endif 0 should be here
> ...
> 	}
> 
> rest of the changes look OK and you can add my ACK after fixing
> idescsi_transform_pc2()
> 
>>   it will complain but will not crash the kernel.
> 
> sr is likely to complain due to scsi_mode_sense() usage :(
> 
>>   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 <bharrosh@panasas.com>
>> ---

Ok I had an hard look on this code and finally understood what is
going on. It looks like the ATAPI devices do not like the short 
mode_sense_6" commands and friends, and will translate them to 
the xxx_10 variant on the fly. Upper layer like sr still sends
short commands for compatibility with old scsi HW.

This stuff did not work for ages. and was usually bailing out on a NULL
pointer. Though I'm almost sure that there is one potential crash in there
and if Jeff is correct in saying that it gets used, than I do not understand
how it did not trigger.

In any way I have codded a fix. I have based my hack on the assumption that
SENSE INQUIRY and SELECT commands come with sg_count of 1. If not than I
just truncate the command to the first sg. I than do a kmap/kunmap on the
first sg and let the code do what it did before.

Please Note that I did not reference the standard and have not verified
at all the bit keeping in there. I have just converted the old code that
assumed a !use_sg in block pc commands to now assume an sg_count==1.

Please, anyone that can, give it an hard testing with any HW you have 
because that change is not trivial.

I will send the patch as reply to the first patch.

Boaz
 

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

* [PATCH ver2 24/24] ide-scsi.c: convert to data accessors and !use_sg cleanup
  2007-09-12  0:13 ` [PATCH 24/24] ide-scsi.c: convert to data accessors and !use_sg cleanup Boaz Harrosh
  2007-09-17 11:04   ` Bartlomiej Zolnierkiewicz
@ 2007-09-18  9:03   ` Boaz Harrosh
  2007-09-18  9:14     ` Christoph Hellwig
  2007-09-18 10:27   ` [PATCH 24/24 ver3 ] " Boaz Harrosh
  2 siblings, 1 reply; 59+ messages in thread
From: Boaz Harrosh @ 2007-09-18  9:03 UTC (permalink / raw)
  To: James Bottomley, FUJITA Tomonori, Greg Kroah-Hartman, Alan Stern,
	Matthew


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

  In old code the MODE_SENSE or MODE_SELECT code paths still
  assumed scsi_cmnd->request_buffer is a linear char pointer.
  This means that this driver was broken since 2.6.17. Though
  I admit this assumption is hidden behind a flag:
  test_bit(PC_TRANSFORM, &pc->flags).

  I have hacked these code paths to properly handle an sg_count==1,
  which is true in todays implementation of MODE_SENSE or
  MODE_SELECT.

Signed-off-by: Boaz Harrosh <bharrosh@panasas.com>
---
 drivers/scsi/ide-scsi.c |   85 +++++++++++++++++++++++++++--------------------
 1 files changed, 49 insertions(+), 36 deletions(-)

diff --git a/drivers/scsi/ide-scsi.c b/drivers/scsi/ide-scsi.c
index 1cc01ac..5c9a444 100644
--- a/drivers/scsi/ide-scsi.c
+++ b/drivers/scsi/ide-scsi.c
@@ -63,7 +63,7 @@
 
 typedef struct idescsi_pc_s {
 	u8 c[12];				/* Actual packet bytes */
-	int request_transfer;			/* Bytes to transfer */
+	unsigned int request_transfer;		/* Bytes to transfer */
 	int actually_transferred;		/* Bytes actually transferred */
 	int buffer_size;			/* Size of our data buffer */
 	struct request *rq;			/* The corresponding request */
@@ -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;
@@ -245,21 +247,21 @@ static void idescsi_output_buffers (ide_drive_t *drive, idescsi_pc_t *pc, unsign
  */
 static inline void idescsi_transform_pc1 (ide_drive_t *drive, idescsi_pc_t *pc)
 {
-	u8 *c = pc->c, *scsi_buf = pc->buffer, *sc = pc->scsi_cmd->cmnd;
-	char *atapi_buf;
-
 	if (!test_bit(PC_TRANSFORM, &pc->flags))
 		return;
 	if (drive->media == ide_cdrom || drive->media == ide_optical) {
+		u8 *c = pc->c;
+
 		if (c[0] == READ_6 || c[0] == WRITE_6) {
 			c[8] = c[4];		c[5] = c[3];		c[4] = c[2];
 			c[3] = c[1] & 0x1f;	c[2] = 0;		c[1] &= 0xe0;
 			c[0] += (READ_10 - READ_6);
 		}
 		if (c[0] == MODE_SENSE || c[0] == MODE_SELECT) {
+			u8 *sc = pc->scsi_cmd->cmnd;
+			char *atapi_buf;
 			unsigned short new_len;
-			if (!scsi_buf)
-				return;
+
 			if ((atapi_buf = kmalloc(pc->buffer_size + 4, GFP_ATOMIC)) == NULL)
 				return;
 			memset(atapi_buf, 0, pc->buffer_size + 4);
@@ -272,42 +274,62 @@ static inline void idescsi_transform_pc1 (ide_drive_t *drive, idescsi_pc_t *pc)
 			c[7] = new_len >> 8;
 			c[9] = sc[5];
 			if (c[0] == MODE_SELECT_10) {
+				struct scatterlist *sg = scsi_sglist(pc->scsi_cmd);
+				u8 *scsi_buf;
+
+				/* FIXME: Use proper copy_from_sg(...) */
+				BUG_ON(!sg || sg->length < 4);
+				if (pc->buffer_size > sg->length)
+					pc->buffer_size = sg->length;
+				scsi_buf = (u8 *)(kmap(sg->page) + sg->offset);
+
 				atapi_buf[1] = scsi_buf[0];	/* Mode data length */
 				atapi_buf[2] = scsi_buf[1];	/* Medium type */
 				atapi_buf[3] = scsi_buf[2];	/* Device specific parameter */
 				atapi_buf[7] = scsi_buf[3];	/* Block descriptor length */
 				memcpy(atapi_buf + 8, scsi_buf + 4, pc->buffer_size - 4);
+				kunmap(sg->page);
 			}
 			pc->buffer = atapi_buf;
-			pc->request_transfer += 4;
 			pc->buffer_size += 4;
+			pc->request_transfer = pc->buffer_size;
 		}
 	}
 }
 
 static inline void idescsi_transform_pc2 (ide_drive_t *drive, idescsi_pc_t *pc)
 {
-	u8 *atapi_buf = pc->buffer;
-	u8 *sc = pc->scsi_cmd->cmnd;
-	u8 *scsi_buf = pc->scsi_cmd->request_buffer;
-
 	if (!test_bit(PC_TRANSFORM, &pc->flags))
 		return;
 	if (drive->media == ide_cdrom || drive->media == ide_optical) {
-		if (pc->c[0] == MODE_SENSE_10 && sc[0] == MODE_SENSE) {
+		u8 *atapi_buf = pc->buffer;
+		u8 *sc = pc->scsi_cmd->cmnd;
+		u8 *scsi_buf;
+		int request_transfer;
+		struct scatterlist *sg = scsi_sglist(pc->scsi_cmd);
+
+		/* FIXME: Use proper copy_to_sg(...) */
+		BUG_ON(!sg || sg->length < 4);
+		request_transfer = min(sg->length - 4, pc->request_transfer - 8);
+		scsi_buf = (u8 *)(kmap(sg->page) + sg->offset);
+		if (atapi_buf &&
+		    (pc->c[0] == MODE_SENSE_10) && (sc[0] == MODE_SENSE)) {
 			scsi_buf[0] = atapi_buf[1];		/* Mode data length */
 			scsi_buf[1] = atapi_buf[2];		/* Medium type */
 			scsi_buf[2] = atapi_buf[3];		/* Device specific parameter */
 			scsi_buf[3] = atapi_buf[7];		/* Block descriptor length */
-			memcpy(scsi_buf + 4, atapi_buf + 8, pc->request_transfer - 8);
+			memcpy(scsi_buf + 4, atapi_buf + 8, request_transfer);
 		}
 		if (pc->c[0] == INQUIRY) {
 			scsi_buf[2] |= 2;			/* ansi_revision */
 			scsi_buf[3] = (scsi_buf[3] & 0xf0) | 2;	/* response data format */
 		}
+		kunmap(sg->page);
+	}
+	if (pc->buffer) {
+		kfree(pc->buffer);
+		pc->buffer = NULL;
 	}
-	if (atapi_buf && atapi_buf != scsi_buf)
-		kfree(atapi_buf);
 }
 
 static void hexdump(u8 *x, int len)
@@ -393,7 +415,6 @@ static int idescsi_end_request (ide_drive_t *drive, int uptodate, int nrsecs)
 	idescsi_pc_t *pc = (idescsi_pc_t *) rq->special;
 	int log = test_bit(IDESCSI_LOG_CMD, &scsi->log);
 	struct Scsi_Host *host;
-	u8 *scsi_buf;
 	int errors = rq->errors;
 	unsigned long flags;
 
@@ -435,6 +456,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 +465,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 +660,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);
 
 	if (segments > hwif->sg_max_nents)
 		return 1;
 
-	if (!segments) {
-		hwif->sg_nents = 1;
-		sg_init_one(sg, pc->scsi_cmd->request_buffer, pc->request_transfer);
-	} else {
-		hwif->sg_nents = segments;
-		memcpy(sg, scsi_sg, sizeof(*sg) * segments);
-	}
+	hwif->sg_nents = segments;
+	memcpy(sg, scsi_sg, sizeof(*sg) * segments);
 
 	return 0;
 }
@@ -667,7 +685,7 @@ static ide_startstop_t idescsi_issue_pc (ide_drive_t *drive, idescsi_pc_t *pc)
 	scsi->pc=pc;							/* Set the current packet command */
 	pc->actually_transferred=0;					/* We haven't transferred any data yet */
 	pc->current_position=pc->buffer;
-	bcount.all = min(pc->request_transfer, 63 * 1024);		/* Request to transfer the entire buffer at once */
+	bcount.all = min_t(unsigned, pc->request_transfer, 63 * 1024);	/* Request to transfer the entire buffer at once */
 
 	feature.all = 0;
 	if (drive->using_dma && !idescsi_map_sg(drive, pc)) {
@@ -905,15 +923,10 @@ static int idescsi_queue (struct scsi_cmnd *cmd,
 	pc->flags = 0;
 	pc->rq = rq;
 	memcpy (pc->c, cmd->cmnd, cmd->cmd_len);
-	if (cmd->use_sg) {
-		pc->buffer = NULL;
-		pc->sg = cmd->request_buffer;
-	} else {
-		pc->buffer = cmd->request_buffer;
-		pc->sg = NULL;
-	}
+	pc->buffer = NULL;
+	pc->sg = scsi_sglist(cmd);
 	pc->b_count = 0;
-	pc->request_transfer = pc->buffer_size = cmd->request_bufflen;
+	pc->request_transfer = pc->buffer_size = scsi_bufflen(cmd);
 	pc->scsi_cmd = cmd;
 	pc->done = done;
 	pc->timeout = jiffies + cmd->timeout_per_command;
-- 
1.5.3.1



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

* Re: [PATCH ver2 24/24] ide-scsi.c: convert to data accessors and !use_sg cleanup
  2007-09-18  9:03   ` [PATCH ver2 " Boaz Harrosh
@ 2007-09-18  9:14     ` Christoph Hellwig
  2007-09-18 10:24       ` Boaz Harrosh
  0 siblings, 1 reply; 59+ messages in thread
From: Christoph Hellwig @ 2007-09-18  9:14 UTC (permalink / raw)
  To: Boaz Harrosh
  Cc: James Bottomley, FUJITA Tomonori, Greg Kroah-Hartman, Alan Stern,
	Matthew Dharm, Russell King, Jeff Garzik, David S. Miller,
	Bartlomiej Zolnierkiewicz, YOKOTA Hiroshi, linux-scsi,
	Maciej W. Rozycki, Mark Fortescue

On Tue, Sep 18, 2007 at 11:03:21AM +0200, Boaz Harrosh wrote:
> 
>  - Convert ide-scsi to the new data accessors and cleanup
>    the !use_sg code paths.
> 
>   In old code the MODE_SENSE or MODE_SELECT code paths still
>   assumed scsi_cmnd->request_buffer is a linear char pointer.
>   This means that this driver was broken since 2.6.17. Though
>   I admit this assumption is hidden behind a flag:
>   test_bit(PC_TRANSFORM, &pc->flags).
> 
>   I have hacked these code paths to properly handle an sg_count==1,
>   which is true in todays implementation of MODE_SENSE or
>   MODE_SELECT.
> 
> Signed-off-by: Boaz Harrosh <bharrosh@panasas.com>
> ---
>  drivers/scsi/ide-scsi.c |   85 +++++++++++++++++++++++++++--------------------
>  1 files changed, 49 insertions(+), 36 deletions(-)
> 
> diff --git a/drivers/scsi/ide-scsi.c b/drivers/scsi/ide-scsi.c
> index 1cc01ac..5c9a444 100644
> --- a/drivers/scsi/ide-scsi.c
> +++ b/drivers/scsi/ide-scsi.c
> @@ -63,7 +63,7 @@
>  
>  typedef struct idescsi_pc_s {
>  	u8 c[12];				/* Actual packet bytes */
> -	int request_transfer;			/* Bytes to transfer */
> +	unsigned int request_transfer;		/* Bytes to transfer */
>  	int actually_transferred;		/* Bytes actually transferred */
>  	int buffer_size;			/* Size of our data buffer */
>  	struct request *rq;			/* The corresponding request */
> @@ -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;
>  static inline void idescsi_transform_pc1 (ide_drive_t *drive, idescsi_pc_t *pc)
>  {
> -	u8 *c = pc->c, *scsi_buf = pc->buffer, *sc = pc->scsi_cmd->cmnd;
> -	char *atapi_buf;
> -
>  	if (!test_bit(PC_TRANSFORM, &pc->flags))
>  		return;
>  	if (drive->media == ide_cdrom || drive->media == ide_optical) {
> +		u8 *c = pc->c;
> +
>  		if (c[0] == READ_6 || c[0] == WRITE_6) {
>  			c[8] = c[4];		c[5] = c[3];		c[4] = c[2];
>  			c[3] = c[1] & 0x1f;	c[2] = 0;		c[1] &= 0xe0;
>  			c[0] += (READ_10 - READ_6);
>  		}
>  		if (c[0] == MODE_SENSE || c[0] == MODE_SELECT) {
> +			u8 *sc = pc->scsi_cmd->cmnd;
> +			char *atapi_buf;
>  			unsigned short new_len;
> -			if (!scsi_buf)
> -				return;

Please just kill the translations.  Once we set use_10_for_rw and
use_10_for_ms in the host template the upper layers won't send it anymore,
and we should just reject these when coming from SG_IO.


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

* Re: [PATCH ver2 24/24] ide-scsi.c: convert to data accessors and !use_sg cleanup
  2007-09-18  9:14     ` Christoph Hellwig
@ 2007-09-18 10:24       ` Boaz Harrosh
  0 siblings, 0 replies; 59+ messages in thread
From: Boaz Harrosh @ 2007-09-18 10:24 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: James Bottomley, FUJITA Tomonori, Greg Kroah-Hartman, Alan Stern,
	Matthew Dharm, Russell King, Jeff Garzik, David S. Miller,
	Bartlomiej Zolnierkiewicz, YOKOTA Hiroshi, linux-scsi,
	Maciej W. Rozycki, Mark Fortescue

On Tue, Sep 18 2007 at 11:14 +0200, Christoph Hellwig <hch@infradead.org> wrote:
> On Tue, Sep 18, 2007 at 11:03:21AM +0200, Boaz Harrosh wrote:
>>  - Convert ide-scsi to the new data accessors and cleanup
>>    the !use_sg code paths.
>>
>>   In old code the MODE_SENSE or MODE_SELECT code paths still
>>   assumed scsi_cmnd->request_buffer is a linear char pointer.
>>   This means that this driver was broken since 2.6.17. Though
>>   I admit this assumption is hidden behind a flag:
>>   test_bit(PC_TRANSFORM, &pc->flags).
>>
>>   I have hacked these code paths to properly handle an sg_count==1,
>>   which is true in todays implementation of MODE_SENSE or
>>   MODE_SELECT.
>>
>> Signed-off-by: Boaz Harrosh <bharrosh@panasas.com>
>> ---
>>  drivers/scsi/ide-scsi.c |   85 +++++++++++++++++++++++++++--------------------
>>  1 files changed, 49 insertions(+), 36 deletions(-)
>>
>> diff --git a/drivers/scsi/ide-scsi.c b/drivers/scsi/ide-scsi.c
>> index 1cc01ac..5c9a444 100644
>> --- a/drivers/scsi/ide-scsi.c
>> +++ b/drivers/scsi/ide-scsi.c
>> @@ -63,7 +63,7 @@
>>  
>>  typedef struct idescsi_pc_s {
>>  	u8 c[12];				/* Actual packet bytes */
>> -	int request_transfer;			/* Bytes to transfer */
>> +	unsigned int request_transfer;		/* Bytes to transfer */
>>  	int actually_transferred;		/* Bytes actually transferred */
>>  	int buffer_size;			/* Size of our data buffer */
>>  	struct request *rq;			/* The corresponding request */
>> @@ -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;
>>  static inline void idescsi_transform_pc1 (ide_drive_t *drive, idescsi_pc_t *pc)
>>  {
>> -	u8 *c = pc->c, *scsi_buf = pc->buffer, *sc = pc->scsi_cmd->cmnd;
>> -	char *atapi_buf;
>> -
>>  	if (!test_bit(PC_TRANSFORM, &pc->flags))
>>  		return;
>>  	if (drive->media == ide_cdrom || drive->media == ide_optical) {
>> +		u8 *c = pc->c;
>> +
>>  		if (c[0] == READ_6 || c[0] == WRITE_6) {
>>  			c[8] = c[4];		c[5] = c[3];		c[4] = c[2];
>>  			c[3] = c[1] & 0x1f;	c[2] = 0;		c[1] &= 0xe0;
>>  			c[0] += (READ_10 - READ_6);
>>  		}
>>  		if (c[0] == MODE_SENSE || c[0] == MODE_SELECT) {
>> +			u8 *sc = pc->scsi_cmd->cmnd;
>> +			char *atapi_buf;
>>  			unsigned short new_len;
>> -			if (!scsi_buf)
>> -				return;
> 
> Please just kill the translations.  Once we set use_10_for_rw and
> use_10_for_ms in the host template the upper layers won't send it anymore,
> and we should just reject these when coming from SG_IO.
> 

Thank you Christoph This is what I needed. I have set these 2 bits
and killed the translation. I will let the Device deal with SG_IO.
So I will not do any filtering of these commands. If SG_IO sends
the wrong commands to the wrong Devices it can deal with the
errors, right?

I will post a new ver3 patch.

Thanks
Boaz


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

* [PATCH 24/24 ver3 ] ide-scsi.c: convert to data accessors and !use_sg cleanup
  2007-09-12  0:13 ` [PATCH 24/24] ide-scsi.c: convert to data accessors and !use_sg cleanup Boaz Harrosh
  2007-09-17 11:04   ` Bartlomiej Zolnierkiewicz
  2007-09-18  9:03   ` [PATCH ver2 " Boaz Harrosh
@ 2007-09-18 10:27   ` Boaz Harrosh
  2007-09-19 19:59     ` Bartlomiej Zolnierkiewicz
  2 siblings, 1 reply; 59+ messages in thread
From: Boaz Harrosh @ 2007-09-18 10:27 UTC (permalink / raw)
  To: James Bottomley, FUJITA Tomonori, Greg Kroah-Hartman, Alan Stern,
	Matthew


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

  In old code the driver was trying to translate narrow commands,
  if received, to wide commands. This code  path still assumed
  scsi_cmnd->request_buffer is a linear char pointer.
  This means that this driver was broken since 2.6.17.

  As suggested by Christoph Hellwig I set
  use_10_for_rw = 1; and use_10_for_ms = 1;
  for this device and completely killed the translation.

Signed-off-by: Boaz Harrosh <bharrosh@panasas.com>
---
 drivers/scsi/ide-scsi.c |  138 +++++------------------------------------------
 1 files changed, 13 insertions(+), 125 deletions(-)

diff --git a/drivers/scsi/ide-scsi.c b/drivers/scsi/ide-scsi.c
index 1cc01ac..3b55a6c 100644
--- a/drivers/scsi/ide-scsi.c
+++ b/drivers/scsi/ide-scsi.c
@@ -82,14 +82,12 @@ typedef struct idescsi_pc_s {
  */
 #define PC_DMA_IN_PROGRESS		0	/* 1 while DMA in progress */
 #define PC_WRITING			1	/* Data direction */
-#define PC_TRANSFORM			2	/* transform SCSI commands */
 #define PC_TIMEDOUT			3	/* command timed out */
 #define PC_DMA_OK			4	/* Use DMA */
 
 /*
  *	SCSI command transformation layer
  */
-#define IDESCSI_TRANSFORM		0	/* Enable/Disable transformation */
 #define IDESCSI_SG_TRANSFORM		1	/* /dev/sg transformation */
 
 /*
@@ -175,7 +173,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 +209,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;
@@ -239,77 +239,6 @@ static void idescsi_output_buffers (ide_drive_t *drive, idescsi_pc_t *pc, unsign
 	}
 }
 
-/*
- *	Most of the SCSI commands are supported directly by ATAPI devices.
- *	idescsi_transform_pc handles the few exceptions.
- */
-static inline void idescsi_transform_pc1 (ide_drive_t *drive, idescsi_pc_t *pc)
-{
-	u8 *c = pc->c, *scsi_buf = pc->buffer, *sc = pc->scsi_cmd->cmnd;
-	char *atapi_buf;
-
-	if (!test_bit(PC_TRANSFORM, &pc->flags))
-		return;
-	if (drive->media == ide_cdrom || drive->media == ide_optical) {
-		if (c[0] == READ_6 || c[0] == WRITE_6) {
-			c[8] = c[4];		c[5] = c[3];		c[4] = c[2];
-			c[3] = c[1] & 0x1f;	c[2] = 0;		c[1] &= 0xe0;
-			c[0] += (READ_10 - READ_6);
-		}
-		if (c[0] == MODE_SENSE || c[0] == MODE_SELECT) {
-			unsigned short new_len;
-			if (!scsi_buf)
-				return;
-			if ((atapi_buf = kmalloc(pc->buffer_size + 4, GFP_ATOMIC)) == NULL)
-				return;
-			memset(atapi_buf, 0, pc->buffer_size + 4);
-			memset (c, 0, 12);
-			c[0] = sc[0] | 0x40;
-			c[1] = sc[1];
-			c[2] = sc[2];
-			new_len = sc[4] + 4;
-			c[8] = new_len;
-			c[7] = new_len >> 8;
-			c[9] = sc[5];
-			if (c[0] == MODE_SELECT_10) {
-				atapi_buf[1] = scsi_buf[0];	/* Mode data length */
-				atapi_buf[2] = scsi_buf[1];	/* Medium type */
-				atapi_buf[3] = scsi_buf[2];	/* Device specific parameter */
-				atapi_buf[7] = scsi_buf[3];	/* Block descriptor length */
-				memcpy(atapi_buf + 8, scsi_buf + 4, pc->buffer_size - 4);
-			}
-			pc->buffer = atapi_buf;
-			pc->request_transfer += 4;
-			pc->buffer_size += 4;
-		}
-	}
-}
-
-static inline void idescsi_transform_pc2 (ide_drive_t *drive, idescsi_pc_t *pc)
-{
-	u8 *atapi_buf = pc->buffer;
-	u8 *sc = pc->scsi_cmd->cmnd;
-	u8 *scsi_buf = pc->scsi_cmd->request_buffer;
-
-	if (!test_bit(PC_TRANSFORM, &pc->flags))
-		return;
-	if (drive->media == ide_cdrom || drive->media == ide_optical) {
-		if (pc->c[0] == MODE_SENSE_10 && sc[0] == MODE_SENSE) {
-			scsi_buf[0] = atapi_buf[1];		/* Mode data length */
-			scsi_buf[1] = atapi_buf[2];		/* Medium type */
-			scsi_buf[2] = atapi_buf[3];		/* Device specific parameter */
-			scsi_buf[3] = atapi_buf[7];		/* Block descriptor length */
-			memcpy(scsi_buf + 4, atapi_buf + 8, pc->request_transfer - 8);
-		}
-		if (pc->c[0] == INQUIRY) {
-			scsi_buf[2] |= 2;			/* ansi_revision */
-			scsi_buf[3] = (scsi_buf[3] & 0xf0) | 2;	/* response data format */
-		}
-	}
-	if (atapi_buf && atapi_buf != scsi_buf)
-		kfree(atapi_buf);
-}
-
 static void hexdump(u8 *x, int len)
 {
 	int i;
@@ -393,7 +322,6 @@ static int idescsi_end_request (ide_drive_t *drive, int uptodate, int nrsecs)
 	idescsi_pc_t *pc = (idescsi_pc_t *) rq->special;
 	int log = test_bit(IDESCSI_LOG_CMD, &scsi->log);
 	struct Scsi_Host *host;
-	u8 *scsi_buf;
 	int errors = rq->errors;
 	unsigned long flags;
 
@@ -434,15 +362,6 @@ static int idescsi_end_request (ide_drive_t *drive, int uptodate, int nrsecs)
 		pc->scsi_cmd->result = (CHECK_CONDITION << 1) | (DID_OK << 16);
 	} else {
 		pc->scsi_cmd->result = DID_OK << 16;
-		idescsi_transform_pc2 (drive, pc);
-		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) {
-				printk(", rst = ");
-				scsi_buf = pc->scsi_cmd->request_buffer;
-				hexdump(scsi_buf, min_t(unsigned, 16, pc->scsi_cmd->request_bufflen));
-			} else printk("\n");
-		}
 	}
 	host = pc->scsi_cmd->device->host;
 	spin_lock_irqsave(host->host_lock, flags);
@@ -637,19 +556,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);
 
 	if (segments > hwif->sg_max_nents)
 		return 1;
 
-	if (!segments) {
-		hwif->sg_nents = 1;
-		sg_init_one(sg, pc->scsi_cmd->request_buffer, pc->request_transfer);
-	} else {
-		hwif->sg_nents = segments;
-		memcpy(sg, scsi_sg, sizeof(*sg) * segments);
-	}
+	hwif->sg_nents = segments;
+	memcpy(sg, scsi_sg, sizeof(*sg) * segments);
 
 	return 0;
 }
@@ -744,7 +658,6 @@ static void idescsi_setup (ide_drive_t *drive, idescsi_scsi_t *scsi)
 {
 	if (drive->id && (drive->id->config & 0x0060) == 0x20)
 		set_bit (IDESCSI_DRQ_INTERRUPT, &scsi->flags);
-	set_bit(IDESCSI_TRANSFORM, &scsi->transform);
 	clear_bit(IDESCSI_SG_TRANSFORM, &scsi->transform);
 #if IDESCSI_DEBUG_LOG
 	set_bit(IDESCSI_LOG_CMD, &scsi->log);
@@ -838,6 +751,8 @@ static struct block_device_operations idescsi_ops = {
 static int idescsi_slave_configure(struct scsi_device * sdp)
 {
 	/* Configure detected device */
+	sdp->use_10_for_rw = 1;
+	sdp->use_10_for_ms = 1;
 	scsi_adjust_queue_depth(sdp, MSG_SIMPLE_TAG, sdp->host->cmd_per_lun);
 	return 0;
 }
@@ -862,24 +777,6 @@ static int idescsi_ioctl (struct scsi_device *dev, int cmd, void __user *arg)
 	return -EINVAL;
 }
 
-static inline int should_transform(ide_drive_t *drive, struct scsi_cmnd *cmd)
-{
-	idescsi_scsi_t *scsi = drive_to_idescsi(drive);
-
-	/* this was a layering violation and we can't support it
-	   anymore, sorry. */
-#if 0
-	struct gendisk *disk = cmd->request->rq_disk;
-
-	if (disk) {
-		struct struct scsi_device_Template **p = disk->private_data;
-		if (strcmp((*p)->scsi_driverfs_driver.name, "sg") == 0)
-			return test_bit(IDESCSI_SG_TRANSFORM, &scsi->transform);
-	}
-#endif
-	return test_bit(IDESCSI_TRANSFORM, &scsi->transform);
-}
-
 static int idescsi_queue (struct scsi_cmnd *cmd,
 		void (*done)(struct scsi_cmnd *))
 {
@@ -905,23 +802,14 @@ static int idescsi_queue (struct scsi_cmnd *cmd,
 	pc->flags = 0;
 	pc->rq = rq;
 	memcpy (pc->c, cmd->cmnd, cmd->cmd_len);
-	if (cmd->use_sg) {
-		pc->buffer = NULL;
-		pc->sg = cmd->request_buffer;
-	} else {
-		pc->buffer = cmd->request_buffer;
-		pc->sg = NULL;
-	}
+	pc->buffer = NULL;
+	pc->sg = scsi_sglist(cmd);
 	pc->b_count = 0;
-	pc->request_transfer = pc->buffer_size = cmd->request_bufflen;
+	pc->request_transfer = pc->buffer_size = scsi_bufflen(cmd);
 	pc->scsi_cmd = cmd;
 	pc->done = done;
 	pc->timeout = jiffies + cmd->timeout_per_command;
 
-	if (should_transform(drive, cmd))
-		set_bit(PC_TRANSFORM, &pc->flags);
-	idescsi_transform_pc1 (drive, pc);
-
 	if (test_bit(IDESCSI_LOG_CMD, &scsi->log)) {
 		printk ("ide-scsi: %s: que %lu, cmd = ", drive->name, cmd->serial_number);
 		hexdump(cmd->cmnd, cmd->cmd_len);
-- 
1.5.3.1



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

* Re: [PATCH 07/24] arm: scsi convert to accessors and !use_sg cleanup
  2007-09-12  7:42   ` Russell King
@ 2007-09-18 15:04     ` Boaz Harrosh
  2007-12-15  0:27       ` James Bottomley
  2008-01-31 18:09     ` James Bottomley
  1 sibling, 1 reply; 59+ messages in thread
From: Boaz Harrosh @ 2007-09-18 15:04 UTC (permalink / raw)
  To: Russell King, James Bottomley
  Cc: FUJITA Tomonori, Greg Kroah-Hartman, Alan Stern, Matthew Dharm,
	Jeff Garzik, David S. Miller, Bartlomiej Zolnierkiewicz,
	YOKOTA Hiroshi, linux-scsi, Maciej W. Rozycki, Mark Fortescue

On Wed, Sep 12 2007 at 10:42 +0300, Russell King <rmk@arm.linux.org.uk> wrote:
> On Wed, Sep 12, 2007 at 02:55:19AM +0300, Boaz Harrosh wrote:
>> -		if (SCpnt->request_bufflen != len)
>> +		if (scsi_bufflen(SCpnt) != len) {
>> +			WARN_ON(1);
> 
> NAK.  The call trace generally doesn't provide any additional information
> on the cause of the error.
> 
In my opinion this can not happen any more. If it does, I want to see that
it is not through the regular scsi-ml .queuecommand mechanism.
But if you insist than sure I will remove it.

>>  			printk(KERN_WARNING "scsi%d.%c: bad request buffer "
>>  			       "length %d, should be %ld\n", SCpnt->device->host->host_no,
>> -			       '0' + SCpnt->device->id, SCpnt->request_bufflen, len);
>> -		SCpnt->request_bufflen = len;
>> +			       '0' + SCpnt->device->id, scsi_bufflen(SCpnt), len);
>> +		}
>>  #endif
>>  	} else {
>> -		SCpnt->SCp.ptr = (unsigned char *)SCpnt->request_buffer;
>> -		SCpnt->SCp.this_residual = SCpnt->request_bufflen;
>> -		SCpnt->SCp.phase = SCpnt->request_bufflen;
>> -	}
>> -
>> -	/*
>> -	 * If the upper SCSI layers pass a buffer, but zero length,
>> -	 * we aren't interested in the buffer pointer.
>> -	 */
>> -	if (SCpnt->SCp.this_residual == 0 && SCpnt->SCp.ptr) {
>> -#if 0 //def BELT_AND_BRACES
>> -		printk(KERN_WARNING "scsi%d.%c: zero length buffer passed for "
>> -		       "command ", SCpnt->host->host_no, '0' + SCpnt->target);
>> -		__scsi_print_command(SCpnt->cmnd);
>> -#endif
>>  		SCpnt->SCp.ptr = NULL;
>> +		SCpnt->SCp.this_residual = 0;
>> +		SCpnt->SCp.phase = 0;
>>  	}
>>  }
> 
> Also NAK.  This was added due to bad behaviour of the SCSI layer and
> was found to be necessary.
> 
No! This check is no longer Relevant. The master if() is on bufflen() now,
and only than do we ever set SCp.ptr. The else will always set both to Zero.
(Which is what you want)

In any way this check is done in scsi-ml, and since 2.6.18 only scsi-ml
can allocate and issue commands. All other sources of commands where removed.
All upper layers issue requests now.

Boaz


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

* [PATCH ver2 1/2] libata-scsi: Remove !use_sg code paths
  2007-09-12  0:09   ` Jeff Garzik
  2007-09-12  0:25     ` Boaz Harrosh
  2007-09-12  1:40     ` Matthew Dharm
@ 2007-09-18 15:46     ` Boaz Harrosh
  2007-09-20 21:12       ` Jeff Garzik
  2007-09-18 15:48     ` [PATCH ver2 2/2] libata-scsi: convert to use the data buffer accessors Boaz Harrosh
  3 siblings, 1 reply; 59+ messages in thread
From: Boaz Harrosh @ 2007-09-18 15:46 UTC (permalink / raw)
  To: Jeff Garzik, James Bottomley
  Cc: FUJITA Tomonori, Greg Kroah-Hartman, Alan Stern, Matthew Dharm,
	Russell King, David S. Miller, Bartlomiej Zolnierkiewicz,
	linux-scsi, Maciej W. Rozycki, Mark Fortescue


     This is a minimal patch needed to remove use of !use_sg
     but it is not a complete clean up of the !use_sg paths.
     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 |   31 +++++++++----------------------
 1 files changed, 9 insertions(+), 22 deletions(-)

diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c
index e836476..6145a64 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 = (struct scatterlist *) cmd->request_buffer;
+		qc->n_elem = cmd->use_sg;
 	} else {
 		cmd->result = (DID_OK << 16) | (QUEUE_FULL << 1);
 		done(cmd);
@@ -1504,11 +1499,7 @@ static int ata_scsi_translate(struct ata_device *dev, struct scsi_cmnd *cmd,
 			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, cmd->request_buffer, cmd->use_sg);
 
 		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 = (struct scatterlist *) cmd->request_buffer;
 
-		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 = (struct scatterlist *) cmd->request_buffer;
+	if (sg)
 		kunmap_atomic(buf - sg->offset, KM_IRQ0);
-	}
 }
 
 /**
-- 
1.5.3.1



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

* [PATCH ver2 2/2] libata-scsi: convert to use the data buffer accessors
  2007-09-12  0:09   ` Jeff Garzik
                       ` (2 preceding siblings ...)
  2007-09-18 15:46     ` [PATCH ver2 1/2] libata-scsi: Remove !use_sg code paths Boaz Harrosh
@ 2007-09-18 15:48     ` Boaz Harrosh
  3 siblings, 0 replies; 59+ messages in thread
From: Boaz Harrosh @ 2007-09-18 15:48 UTC (permalink / raw)
  To: Jeff Garzik, James Bottomley
  Cc: FUJITA Tomonori, Greg Kroah-Hartman, Alan Stern, Matthew Dharm,
	Russell King, David S. Miller, Bartlomiej Zolnierkiewicz,
	linux-scsi, Maciej W. Rozycki, Mark Fortescue


  simple search-and-replace of direct scsi_cmnd access to
  use the data buffer accessors.

Signed-off-by: Boaz Harrosh <bharrosh@panasas.com>
---
 drivers/ata/libata-scsi.c |   18 +++++++++---------
 1 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c
index 6145a64..d23a181 100644
--- a/drivers/ata/libata-scsi.c
+++ b/drivers/ata/libata-scsi.c
@@ -450,8 +450,8 @@ static struct ata_queued_cmd *ata_scsi_qc_new(struct ata_device *dev,
 		qc->scsicmd = cmd;
 		qc->scsidone = done;
 
-		qc->__sg = (struct scatterlist *) cmd->request_buffer;
-		qc->n_elem = cmd->use_sg;
+		qc->__sg = scsi_sglist(cmd);
+		qc->n_elem = scsi_sg_count(cmd);
 	} else {
 		cmd->result = (DID_OK << 16) | (QUEUE_FULL << 1);
 		done(cmd);
@@ -1493,13 +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;
 		}
 
-		ata_sg_init(qc, cmd->request_buffer, cmd->use_sg);
+		ata_sg_init(qc, scsi_sglist(cmd), scsi_sg_count(cmd));
 
 		qc->dma_dir = cmd->sc_data_direction;
 	}
@@ -1553,7 +1553,7 @@ static unsigned int ata_scsi_rbuf_get(struct scsi_cmnd *cmd, u8 **buf_out)
 	u8 *buf;
 	unsigned int buflen;
 
-	struct scatterlist *sg = (struct scatterlist *) cmd->request_buffer;
+	struct scatterlist *sg = scsi_sglist(cmd);
 
 	if (sg) {
 		buf = kmap_atomic(sg->page, KM_IRQ0) + sg->offset;
@@ -1580,7 +1580,7 @@ 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)
 {
-	struct scatterlist *sg = (struct scatterlist *) cmd->request_buffer;
+	struct scatterlist *sg = scsi_sglist(cmd);
 	if (sg)
 		kunmap_atomic(buf - sg->offset, KM_IRQ0);
 }
@@ -2383,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))
@@ -2618,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);
 	}
 
 	/*
@@ -2648,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



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

* Re: [PATCH 24/24 ver3 ] ide-scsi.c: convert to data accessors and !use_sg cleanup
  2007-09-18 10:27   ` [PATCH 24/24 ver3 ] " Boaz Harrosh
@ 2007-09-19 19:59     ` Bartlomiej Zolnierkiewicz
  0 siblings, 0 replies; 59+ messages in thread
From: Bartlomiej Zolnierkiewicz @ 2007-09-19 19:59 UTC (permalink / raw)
  To: Boaz Harrosh
  Cc: James Bottomley, FUJITA Tomonori, Greg Kroah-Hartman, Alan Stern,
	Matthew Dharm, Russell King, Jeff Garzik, David S. Miller,
	YOKOTA Hiroshi, linux-scsi, Maciej W. Rozycki, Mark Fortescue

On Tuesday 18 September 2007, Boaz Harrosh wrote:
> 
>  - Convert ide-scsi to the new data accessors and cleanup
>    the !use_sg code paths.
> 
>   In old code the driver was trying to translate narrow commands,
>   if received, to wide commands. This code  path still assumed
>   scsi_cmnd->request_buffer is a linear char pointer.
>   This means that this driver was broken since 2.6.17.

2.6.17 so it has been broken for the last *six* kernel releases
(and 2.6.17 == 18 Jun 2006 so more than a year in the timescale).

This raises serious questions whether it is really worth to fix it

>   As suggested by Christoph Hellwig I set
>   use_10_for_rw = 1; and use_10_for_ms = 1;
>   for this device and completely killed the translation.
> 
> Signed-off-by: Boaz Harrosh <bharrosh@panasas.com>

anyway patch looks good

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>

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

* Re: [PATCH ver2 1/2] libata-scsi: Remove !use_sg code paths
  2007-09-18 15:46     ` [PATCH ver2 1/2] libata-scsi: Remove !use_sg code paths Boaz Harrosh
@ 2007-09-20 21:12       ` Jeff Garzik
  0 siblings, 0 replies; 59+ messages in thread
From: Jeff Garzik @ 2007-09-20 21:12 UTC (permalink / raw)
  To: Boaz Harrosh
  Cc: James Bottomley, FUJITA Tomonori, Greg Kroah-Hartman, Alan Stern,
	Matthew Dharm, Russell King, David S. Miller,
	Bartlomiej Zolnierkiewicz, linux-scsi, Maciej W. Rozycki,
	Mark Fortescue

Boaz Harrosh wrote:
>      This is a minimal patch needed to remove use of !use_sg
>      but it is not a complete clean up of the !use_sg paths.
>      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 |   31 +++++++++----------------------
>  1 files changed, 9 insertions(+), 22 deletions(-)

applied 1-2



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

* Re: [patchset 0/24] Lots of the Accessors patches and !use_sg cleanup
  2007-09-11 20:23 [patchset 0/24] Lots of the Accessors patches and !use_sg cleanup Boaz Harrosh
                   ` (26 preceding siblings ...)
  2007-09-17 10:46 ` Bartlomiej Zolnierkiewicz
@ 2007-10-10 18:24 ` Boaz Harrosh
  2007-10-10 19:14   ` Matthew Wilcox
  27 siblings, 1 reply; 59+ messages in thread
From: Boaz Harrosh @ 2007-10-10 18:24 UTC (permalink / raw)
  To: James Bottomley, FUJITA Tomonori, Greg Kroah-Hartman, Alan Stern,
	Matthew

On Tue, Sep 11 2007 at 23:23 +0300, Boaz Harrosh <bharrosh@panasas.com> wrote:
> 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 <gregkh@suse.de>, Alan Stern <stern@rowland.harvard.edu>,
> 	Matthew Dharm <mdharm-usb@one-eyed-alien.net>
> 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
> 0005 	drivers/usb/storage/isd200.c
> 
> [NCR5380 family] - ?
> 0006 	drivers/scsi/NCR5380.c drivers/scsi/atari_NCR5380.c
> 	drivers/scsi/sun3_NCR5380.c
> 
> [esp family] - Maciej W. Rozycki <macro@linux-mips.org>
> 0020 	drivers/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 <rmk@arm.linux.org.uk>
> 0007 	drivers/scsi/arm/acornscsi.c drivers/scsi/arm/scsi.h
> 
> [other drivers]
> 0008 	drivers/scsi/pcmcia/nsp_cs.c - YOKOTA Hiroshi <yokota@netlab.is.tsukuba.ac.jp>
> 0009 	drivers/ata/libata-scsi.c - Jeff Garzik <jeff@garzik.org>
> 0010 	drivers/scsi/eata_pio.c - Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ?
> 0011 	drivers/scsi/a2091.c - ?
> 0012 	drivers/scsi/a3000.c - ? 
> 0013 	drivers/scsi/aha1542.c - ? 
> 0014 	drivers/scsi/atp870u.c - ? 
> 0015 	drivers/scsi/fd_mcs.c - ? 
> 0016 	drivers/scsi/imm.c - ? 
> 0017 	drivers/scsi/in2000.c - ? 
> 0018 	drivers/scsi/ppa.c - ? 
> 0019 	drivers/scsi/wd33c93.c - ? 
> 0021 	drivers/scsi/qlogicpti.c - David S. Miller <davem@davemloft.net>, Mark Fortescue <mark@mtfhpc.demon.co.uk>
> 0024 	drivers/scsi/ide-scsi.c - Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
> 
> [remove psi240i.c driver] - ?
> 0022 	drivers/scsi/Kconfig drivers/scsi/Makefile   
> 	delete drivers/scsi/psi240i.c
> 	delete drivers/scsi/psi240i.h
> 	delete drivers/scsi/psi_chip.h
> 
> [fixes]
> 0023 	drivers/scsi/wd7000.c - ? 
> -

James Hi!
I just did a rebase for all drivers they patch and compile
over current scsi-misc. Save one, qlogicpti.c, a fix will follow.
(I keep stumbling over Matthew's patches ;)

Please note that you must apply: 
"[PATCH 05/24] isd200.c: use one-element sg list in issuing commands"
first and specifically before the usb patches. Otherwise this driver
will be broken for the duration. (Sorry for the mess)

Please ask for any help needed or if you need all any patches
to be resent

Thanks
Boaz

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

* [PATCH 21/24 ver2] qlogicpti.c: convert to accessors and !use_sg cleanup
  2007-09-12  0:09 ` [PATCH 21/24] qlogicpti.c: " Boaz Harrosh
@ 2007-10-10 18:25   ` Boaz Harrosh
  2007-10-10 22:58     ` David Miller
  0 siblings, 1 reply; 59+ messages in thread
From: Boaz Harrosh @ 2007-10-10 18:25 UTC (permalink / raw)
  To: James Bottomley, David S. Miller, linux-scsi, Matthew Wilcox


 - convert to accessors and !use_sg cleanup

Signed-off-by: Boaz Harrosh <bharrosh@panasas.com>
---
 drivers/scsi/qlogicpti.c |   29 +++++++----------------------
 1 files changed, 7 insertions(+), 22 deletions(-)

diff --git a/drivers/scsi/qlogicpti.c b/drivers/scsi/qlogicpti.c
index e93f803..db43d1c 100644
--- a/drivers/scsi/qlogicpti.c
+++ b/drivers/scsi/qlogicpti.c
@@ -871,11 +871,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;
@@ -913,16 +914,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;
@@ -1158,17 +1149,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



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

* Re: [patchset 0/24] Lots of the Accessors patches and !use_sg cleanup
  2007-10-10 18:24 ` Boaz Harrosh
@ 2007-10-10 19:14   ` Matthew Wilcox
  0 siblings, 0 replies; 59+ messages in thread
From: Matthew Wilcox @ 2007-10-10 19:14 UTC (permalink / raw)
  To: Boaz Harrosh
  Cc: James Bottomley, FUJITA Tomonori, Greg Kroah-Hartman, Alan Stern,
	Matthew Dharm, Russell King, Jeff Garzik, David S. Miller,
	Bartlomiej Zolnierkiewicz, YOKOTA Hiroshi, linux-scsi,
	Maciej W. Rozycki, Mark Fortescue

On Wed, Oct 10, 2007 at 08:24:46PM +0200, Boaz Harrosh wrote:
> I just did a rebase for all drivers they patch and compile
> over current scsi-misc. Save one, qlogicpti.c, a fix will follow.
> (I keep stumbling over Matthew's patches ;)

At least this time I only deleted some code you were patching.  It's
nothing on the mess in the gdth driver ;-)

-- 
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."

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

* Re: [PATCH 21/24 ver2] qlogicpti.c: convert to accessors and !use_sg cleanup
  2007-10-10 18:25   ` [PATCH 21/24 ver2] " Boaz Harrosh
@ 2007-10-10 22:58     ` David Miller
  0 siblings, 0 replies; 59+ messages in thread
From: David Miller @ 2007-10-10 22:58 UTC (permalink / raw)
  To: bharrosh; +Cc: James.Bottomley, linux-scsi, matthew

From: Boaz Harrosh <bharrosh@panasas.com>
Date: Wed, 10 Oct 2007 20:25:30 +0200

> 
>  - convert to accessors and !use_sg cleanup
> 
> Signed-off-by: Boaz Harrosh <bharrosh@panasas.com>

Acked-by: David S. Miller <davem@davemloft.net>

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

* Re: [PATCH 07/24] arm: scsi convert to accessors and !use_sg cleanup
  2007-09-18 15:04     ` Boaz Harrosh
@ 2007-12-15  0:27       ` James Bottomley
  2007-12-16 15:28         ` Boaz Harrosh
  0 siblings, 1 reply; 59+ messages in thread
From: James Bottomley @ 2007-12-15  0:27 UTC (permalink / raw)
  To: Boaz Harrosh
  Cc: Russell King, FUJITA Tomonori, Greg Kroah-Hartman, Alan Stern,
	Matthew Dharm, Jeff Garzik, David S. Miller,
	Bartlomiej Zolnierkiewicz, YOKOTA Hiroshi, linux-scsi,
	Maciej W. Rozycki, Mark Fortescue


On Tue, 2007-09-18 at 17:04 +0200, Boaz Harrosh wrote:
> On Wed, Sep 12 2007 at 10:42 +0300, Russell King <rmk@arm.linux.org.uk> wrote:
> > On Wed, Sep 12, 2007 at 02:55:19AM +0300, Boaz Harrosh wrote:
> >> -		if (SCpnt->request_bufflen != len)
> >> +		if (scsi_bufflen(SCpnt) != len) {
> >> +			WARN_ON(1);
> > 
> > NAK.  The call trace generally doesn't provide any additional information
> > on the cause of the error.
> > 
> In my opinion this can not happen any more. If it does, I want to see that
> it is not through the regular scsi-ml .queuecommand mechanism.
> But if you insist than sure I will remove it.
> 
> >>  			printk(KERN_WARNING "scsi%d.%c: bad request buffer "
> >>  			       "length %d, should be %ld\n", SCpnt->device->host->host_no,
> >> -			       '0' + SCpnt->device->id, SCpnt->request_bufflen, len);
> >> -		SCpnt->request_bufflen = len;
> >> +			       '0' + SCpnt->device->id, scsi_bufflen(SCpnt), len);
> >> +		}
> >>  #endif
> >>  	} else {
> >> -		SCpnt->SCp.ptr = (unsigned char *)SCpnt->request_buffer;
> >> -		SCpnt->SCp.this_residual = SCpnt->request_bufflen;
> >> -		SCpnt->SCp.phase = SCpnt->request_bufflen;
> >> -	}
> >> -
> >> -	/*
> >> -	 * If the upper SCSI layers pass a buffer, but zero length,
> >> -	 * we aren't interested in the buffer pointer.
> >> -	 */
> >> -	if (SCpnt->SCp.this_residual == 0 && SCpnt->SCp.ptr) {
> >> -#if 0 //def BELT_AND_BRACES
> >> -		printk(KERN_WARNING "scsi%d.%c: zero length buffer passed for "
> >> -		       "command ", SCpnt->host->host_no, '0' + SCpnt->target);
> >> -		__scsi_print_command(SCpnt->cmnd);
> >> -#endif
> >>  		SCpnt->SCp.ptr = NULL;
> >> +		SCpnt->SCp.this_residual = 0;
> >> +		SCpnt->SCp.phase = 0;
> >>  	}
> >>  }
> > 
> > Also NAK.  This was added due to bad behaviour of the SCSI layer and
> > was found to be necessary.
> > 
> No! This check is no longer Relevant. The master if() is on bufflen() now,
> and only than do we ever set SCp.ptr. The else will always set both to Zero.
> (Which is what you want)
> 
> In any way this check is done in scsi-ml, and since 2.6.18 only scsi-ml
> can allocate and issue commands. All other sources of commands where removed.
> All upper layers issue requests now.

Russell, could you respond to this, please?  Boaz's points seem valid to
me and this conversion must be done soon otherwise these drivers will
break.

James



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

* Re: [PATCH 07/24] arm: scsi convert to accessors and !use_sg cleanup
  2007-12-15  0:27       ` James Bottomley
@ 2007-12-16 15:28         ` Boaz Harrosh
  2008-02-01 20:10           ` Russell King
  0 siblings, 1 reply; 59+ messages in thread
From: Boaz Harrosh @ 2007-12-16 15:28 UTC (permalink / raw)
  To: James Bottomley, Russell King
  Cc: FUJITA Tomonori, Alan Stern, Matthew Dharm, Jeff Garzik,
	David S. Miller, Bartlomiej Zolnierkiewicz, YOKOTA Hiroshi,
	linux-scsi, Maciej W. Rozycki, Mark Fortescue, linux-arm

On Sat, Dec 15 2007 at 2:27 +0200, James Bottomley <James.Bottomley@SteelEye.com> wrote:
> On Tue, 2007-09-18 at 17:04 +0200, Boaz Harrosh wrote:
>> On Wed, Sep 12 2007 at 10:42 +0300, Russell King <rmk@arm.linux.org.uk> wrote:
>>> On Wed, Sep 12, 2007 at 02:55:19AM +0300, Boaz Harrosh wrote:
>>>> -		if (SCpnt->request_bufflen != len)
>>>> +		if (scsi_bufflen(SCpnt) != len) {
>>>> +			WARN_ON(1);
>>> NAK.  The call trace generally doesn't provide any additional information
>>> on the cause of the error.
>>>
>> In my opinion this can not happen any more. If it does, I want to see that
>> it is not through the regular scsi-ml .queuecommand mechanism.
>> But if you insist than sure I will remove it.
>>
>>>>  			printk(KERN_WARNING "scsi%d.%c: bad request buffer "
>>>>  			       "length %d, should be %ld\n", SCpnt->device->host->host_no,
>>>> -			       '0' + SCpnt->device->id, SCpnt->request_bufflen, len);
>>>> -		SCpnt->request_bufflen = len;
>>>> +			       '0' + SCpnt->device->id, scsi_bufflen(SCpnt), len);
>>>> +		}
>>>>  #endif
>>>>  	} else {
>>>> -		SCpnt->SCp.ptr = (unsigned char *)SCpnt->request_buffer;
>>>> -		SCpnt->SCp.this_residual = SCpnt->request_bufflen;
>>>> -		SCpnt->SCp.phase = SCpnt->request_bufflen;
>>>> -	}
>>>> -
>>>> -	/*
>>>> -	 * If the upper SCSI layers pass a buffer, but zero length,
>>>> -	 * we aren't interested in the buffer pointer.
>>>> -	 */
>>>> -	if (SCpnt->SCp.this_residual == 0 && SCpnt->SCp.ptr) {
>>>> -#if 0 //def BELT_AND_BRACES
>>>> -		printk(KERN_WARNING "scsi%d.%c: zero length buffer passed for "
>>>> -		       "command ", SCpnt->host->host_no, '0' + SCpnt->target);
>>>> -		__scsi_print_command(SCpnt->cmnd);
>>>> -#endif
>>>>  		SCpnt->SCp.ptr = NULL;
>>>> +		SCpnt->SCp.this_residual = 0;
>>>> +		SCpnt->SCp.phase = 0;
>>>>  	}
>>>>  }
>>> Also NAK.  This was added due to bad behaviour of the SCSI layer and
>>> was found to be necessary.
>>>
>> No! This check is no longer Relevant. The master if() is on bufflen() now,
>> and only than do we ever set SCp.ptr. The else will always set both to Zero.
>> (Which is what you want)
>>
>> In any way this check is done in scsi-ml, and since 2.6.18 only scsi-ml
>> can allocate and issue commands. All other sources of commands where removed.
>> All upper layers issue requests now.
> 
> Russell, could you respond to this, please?  Boaz's points seem valid to
> me and this conversion must be done soon otherwise these drivers will
> break.
> 
> James
> 
> 

Reinspecting this code in view of the overall arm-scsi, I conclude that arm
is CURRENTLY BROKEN in 2.6.24-rcx tree. With or without this patch.

Resubmitted in this mail is the sg-safe version of this patch. Maybe
with the bug fixes it will finally be acknowledged by the arm people.

The reason it is currently broken is because of copy_SCp_to_sg() which I did not previously
touched. It is broken both on the account of the wrong assumption about the sg-list 
coming from scsi at SCp.buffer, and because inspecting the code, the sg-list pointed 
to by destination sg is later passed to a DMA mapper and it is not initialized properly.
These and more are fixed in the new patch.

After the new patch, arm drivers are not yet safe for chaining. But the 
arm-scsi-mid-layer is. Meaning, good behaving arm drivers will no longer 
suffer from bugs at the mid-level.

Russell or any other arm person. Please first see if this compiles at all, as I do
not have a cross compiler set up, and please check that this code works.
(Should apply on top of Linus latest)

------
>From f02d6f44c9043258f8aa63c7dfe56c9a67db3fcf Mon Sep 17 00:00:00 2001
From: Boaz Harrosh <bharrosh@panasas.com>
Date: Sun, 9 Sep 2007 21:31:21 +0300
Subject: [PATCH] [SCSI] arm:  sg bugfixes and convert to accessors

 - convert to accessors and !use_sg cleanup
 - fix for sg_chaining bugs

Signed-off-by: Boaz Harrosh <bharrosh@panasas.com>
Cc: Russell King <rmk@arm.linux.org.uk>
---
 drivers/scsi/arm/acornscsi.c |   14 +++---
 drivers/scsi/arm/scsi.h      |   86 ++++++++++++++++++++++++-----------------
 2 files changed, 57 insertions(+), 43 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 bb6550e..ce7d3d3 100644
--- a/drivers/scsi/arm/scsi.h
+++ b/drivers/scsi/arm/scsi.h
@@ -18,17 +18,32 @@
  * The scatter-gather list handling.  This contains all
  * the yucky stuff that needs to be fixed properly.
  */
+
+/*
+ * copy_SCp_to_sg() Assumes contiguous allocation at @sg of at-most @max
+ * entries of uninitialized memory. SCp is from scsi-ml and has a valid
+ * (possibly chained) sg-list
+ */
 static inline int copy_SCp_to_sg(struct scatterlist *sg, struct scsi_pointer *SCp, int max)
 {
 	int bufs = SCp->buffers_residual;
 
+	/* FIXME: It should be easy for drivers to loop on copy_SCp_to_sg().
+	 * and to remove this BUG_ON. Use min() in-its-place
+	 */
 	BUG_ON(bufs + 1 > max);
 
 	sg_set_buf(sg, SCp->ptr, SCp->this_residual);
 
-	if (bufs)
-		memcpy(sg + 1, SCp->buffer + 1,
-		       sizeof(struct scatterlist) * bufs);
+	if (bufs) {
+		struct scatterlist *src_sg;
+		unsigned i;
+
+		for_each_sg(sg_next(SCp->buffer), src_sg, bufs, i)
+			*(++sg) = *src_sg;
+		sg_mark_end(sg);
+	}
+
 	return bufs + 1;
 }
 
@@ -36,7 +51,7 @@ static inline int next_SCp(struct scsi_pointer *SCp)
 {
 	int ret = SCp->buffers_residual;
 	if (ret) {
-		SCp->buffer++;
+		SCp->buffer = sg_next(SCp->buffer);
 		SCp->buffers_residual--;
 		SCp->ptr = sg_virt(SCp->buffer);
 		SCp->this_residual = SCp->buffer->length;
@@ -68,46 +83,45 @@ 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;
+		SCpnt->SCp.buffer = scsi_sglist(SCpnt);
+		SCpnt->SCp.buffers_residual = scsi_sg_count(SCpnt) - 1;
 		SCpnt->SCp.ptr = sg_virt(SCpnt->SCp.buffer);
 		SCpnt->SCp.this_residual = SCpnt->SCp.buffer->length;
-		SCpnt->SCp.phase = SCpnt->request_bufflen;
+		SCpnt->SCp.phase = scsi_bufflen(SCpnt);
 
 #ifdef BELT_AND_BRACES
-		/*
-		 * Calculate correct buffer length.  Some commands
-		 * come in with the wrong request_bufflen.
-		 */
-		for (buf = 0; buf <= SCpnt->SCp.buffers_residual; buf++)
-			len += SCpnt->SCp.buffer[buf].length;
-
-		if (SCpnt->request_bufflen != len)
-			printk(KERN_WARNING "scsi%d.%c: bad request buffer "
-			       "length %d, should be %ld\n", SCpnt->device->host->host_no,
-			       '0' + SCpnt->device->id, SCpnt->request_bufflen, len);
-		SCpnt->request_bufflen = len;
+		{	/*
+			 * Calculate correct buffer length.  Some commands
+			 * come in with the wrong scsi_bufflen.
+			 */
+			struct scatterlist *sg;
+			unsigned i, sg_count = scsi_sg_count(SCpnt);
+
+			scsi_for_each_sg(SCpnt, sg, sg_count, i)
+				len += sg->length;
+
+			if (scsi_bufflen(SCpnt) != len) {
+				printk(KERN_WARNING
+				       "scsi%d.%c: bad request buffer "
+				       "length %d, should be %ld\n",
+					SCpnt->device->host->host_no,
+					'0' + SCpnt->device->id,
+					scsi_bufflen(SCpnt), len);
+				/*
+				 * FIXME: Totaly naive fixup. We should abort
+				 * with error
+				 */
+				SCpnt->SCp.phase =
+					min(len, scsi_bufflen(SCpnt));
+			}
+		}
 #endif
 	} else {
-		SCpnt->SCp.ptr = (unsigned char *)SCpnt->request_buffer;
-		SCpnt->SCp.this_residual = SCpnt->request_bufflen;
-		SCpnt->SCp.phase = SCpnt->request_bufflen;
-	}
-
-	/*
-	 * If the upper SCSI layers pass a buffer, but zero length,
-	 * we aren't interested in the buffer pointer.
-	 */
-	if (SCpnt->SCp.this_residual == 0 && SCpnt->SCp.ptr) {
-#if 0 //def BELT_AND_BRACES
-		printk(KERN_WARNING "scsi%d.%c: zero length buffer passed for "
-		       "command ", SCpnt->host->host_no, '0' + SCpnt->target);
-		__scsi_print_command(SCpnt->cmnd);
-#endif
 		SCpnt->SCp.ptr = NULL;
+		SCpnt->SCp.this_residual = 0;
+		SCpnt->SCp.phase = 0;
 	}
 }
-- 
1.5.3.3


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

* Re: [PATCH 07/24] arm: scsi convert to accessors and !use_sg cleanup
  2007-09-12  7:42   ` Russell King
  2007-09-18 15:04     ` Boaz Harrosh
@ 2008-01-31 18:09     ` James Bottomley
  1 sibling, 0 replies; 59+ messages in thread
From: James Bottomley @ 2008-01-31 18:09 UTC (permalink / raw)
  To: Russell King
  Cc: Boaz Harrosh, FUJITA Tomonori, Greg Kroah-Hartman, Alan Stern,
	Matthew Dharm, Jeff Garzik, David S. Miller,
	Bartlomiej Zolnierkiewicz, YOKOTA Hiroshi, linux-scsi,
	Maciej W. Rozycki, Mark Fortescue


On Wed, 2007-09-12 at 08:42 +0100, Russell King wrote:
> On Wed, Sep 12, 2007 at 02:55:19AM +0300, Boaz Harrosh wrote:
> > -		if (SCpnt->request_bufflen != len)
> > +		if (scsi_bufflen(SCpnt) != len) {
> > +			WARN_ON(1);
> 
> NAK.  The call trace generally doesn't provide any additional information
> on the cause of the error.
> 
> >  			printk(KERN_WARNING "scsi%d.%c: bad request buffer "
> >  			       "length %d, should be %ld\n", SCpnt->device->host->host_no,
> > -			       '0' + SCpnt->device->id, SCpnt->request_bufflen, len);
> > -		SCpnt->request_bufflen = len;
> > +			       '0' + SCpnt->device->id, scsi_bufflen(SCpnt), len);
> > +		}
> >  #endif
> >  	} else {
> > -		SCpnt->SCp.ptr = (unsigned char *)SCpnt->request_buffer;
> > -		SCpnt->SCp.this_residual = SCpnt->request_bufflen;
> > -		SCpnt->SCp.phase = SCpnt->request_bufflen;
> > -	}
> > -
> > -	/*
> > -	 * If the upper SCSI layers pass a buffer, but zero length,
> > -	 * we aren't interested in the buffer pointer.
> > -	 */
> > -	if (SCpnt->SCp.this_residual == 0 && SCpnt->SCp.ptr) {
> > -#if 0 //def BELT_AND_BRACES
> > -		printk(KERN_WARNING "scsi%d.%c: zero length buffer passed for "
> > -		       "command ", SCpnt->host->host_no, '0' + SCpnt->target);
> > -		__scsi_print_command(SCpnt->cmnd);
> > -#endif
> >  		SCpnt->SCp.ptr = NULL;
> > +		SCpnt->SCp.this_residual = 0;
> > +		SCpnt->SCp.phase = 0;
> >  	}
> >  }
> 
> Also NAK.  This was added due to bad behaviour of the SCSI layer and
> was found to be necessary.

Time is up on this one: this driver now won't build in mainline because
of the promised sg_table updates.  Either you ack the changes or provide
your own.  If not, I'll mark the driver BROKEN.

James



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

* Re: [PATCH 07/24] arm: scsi convert to accessors and !use_sg cleanup
  2007-12-16 15:28         ` Boaz Harrosh
@ 2008-02-01 20:10           ` Russell King
  0 siblings, 0 replies; 59+ messages in thread
From: Russell King @ 2008-02-01 20:10 UTC (permalink / raw)
  To: Boaz Harrosh
  Cc: James Bottomley, FUJITA Tomonori, Alan Stern, Matthew Dharm,
	Jeff Garzik, David S. Miller, Bartlomiej Zolnierkiewicz,
	YOKOTA Hiroshi, linux-scsi, Maciej W. Rozycki, Mark Fortescue

On Sun, Dec 16, 2007 at 05:28:33PM +0200, Boaz Harrosh wrote:
> Russell or any other arm person. Please first see if this compiles at all, as I do
> not have a cross compiler set up, and please check that this code works.
> (Should apply on top of Linus latest)

This patch seems to work with one change:

> +				SCpnt->SCp.phase =
> +					min(len, scsi_bufflen(SCpnt));

This min wants to be

+					min_t(unsigned long, len, scsi_bufflen(SCpnt));

-- 
Russell King
 Linux kernel    2.6 ARM Linux   - http://www.arm.linux.org.uk/
 maintainer of:

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

end of thread, other threads:[~2008-02-01 20:14 UTC | newest]

Thread overview: 59+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-09-11 20:23 [patchset 0/24] Lots of the Accessors patches and !use_sg cleanup Boaz Harrosh
2007-09-11 20:50 ` Cameron, Steve
2007-09-11 21:05   ` Boaz Harrosh
2007-09-11 23:49 ` [PATCH 01/24] usb: transport - convert to accessors and !use_sg code path removal Boaz Harrosh
2007-09-11 23:50 ` [PATCH 02/24] usb: protocol.c " Boaz Harrosh
2007-09-11 23:51 ` [PATCH 03/24] usb: shuttle_usbat.c " Boaz Harrosh
2007-09-11 23:51 ` [PATCH 04/24] usb: freecom.c & sddr09.c - convert to accessors and !use_sg cleanup Boaz Harrosh
2007-09-11 23:53 ` [PATCH 05/24] isd200.c: use one-element sg list in issuing commands Boaz Harrosh
2007-09-11 23:54 ` [PATCH 06/24] NCR5380 familly convert to accessors & !use_sg cleanup Boaz Harrosh
2007-09-11 23:55 ` [PATCH 07/24] arm: scsi convert to accessors and " Boaz Harrosh
2007-09-12  7:42   ` Russell King
2007-09-18 15:04     ` Boaz Harrosh
2007-12-15  0:27       ` James Bottomley
2007-12-16 15:28         ` Boaz Harrosh
2008-02-01 20:10           ` Russell King
2008-01-31 18:09     ` James Bottomley
2007-09-11 23:56 ` [PATCH 08/24] nsp_cs.c convert to data " Boaz Harrosh
2007-09-11 23:58 ` [PATCH 09/24] libata-scsi: convert to use the data buffer accessors Boaz Harrosh
2007-09-12  0:09   ` Jeff Garzik
2007-09-12  0:25     ` Boaz Harrosh
2007-09-12  1:40     ` Matthew Dharm
2007-09-12  6:36       ` Boaz Harrosh
2007-09-18 15:46     ` [PATCH ver2 1/2] libata-scsi: Remove !use_sg code paths Boaz Harrosh
2007-09-20 21:12       ` Jeff Garzik
2007-09-18 15:48     ` [PATCH ver2 2/2] libata-scsi: convert to use the data buffer accessors Boaz Harrosh
2007-09-12  0:00 ` [PATCH 10/24] eata_pio.c: convert to accessors and !use_sg cleanup Boaz Harrosh
2007-09-12  0:00 ` [PATCH 11/24] a2091.c: " Boaz Harrosh
2007-09-12  0:01 ` [PATCH 12/24] a3000.c: " Boaz Harrosh
2007-09-12  0:02 ` [PATCH 13/24] aha1542.c: " Boaz Harrosh
2007-09-12  0:03 ` [PATCH 14/24] atp870u.c: " Boaz Harrosh
2007-09-12  0:04 ` [PATCH 15/24] fd_mcs.c: " Boaz Harrosh
2007-09-12  0:05 ` [PATCH 16/24] imm.c: " Boaz Harrosh
2007-09-12  0:06 ` [PATCH 17/24] in2000.c: " Boaz Harrosh
2007-09-12  0:07 ` [PATCH 18/24] ppa.c: " Boaz Harrosh
2007-09-12  0:07 ` [PATCH 19/24] wd33c93.c: " Boaz Harrosh
2007-09-12  0:09 ` Subject: [PATCH 20/24] scsi: esp family " Boaz Harrosh
2007-09-12  0:09 ` [PATCH 21/24] qlogicpti.c: " Boaz Harrosh
2007-10-10 18:25   ` [PATCH 21/24 ver2] " Boaz Harrosh
2007-10-10 22:58     ` David Miller
2007-09-12  0:10 ` Subject: [PATCH 22/24] Remove psi240i driver from kernel Boaz Harrosh
2007-09-12  0:11 ` [PATCH 23/24] wd7000.c - proper fix for boards without sg support Boaz Harrosh
2007-09-12  0:13 ` [PATCH 24/24] ide-scsi.c: convert to data accessors and !use_sg cleanup Boaz Harrosh
2007-09-17 11:04   ` Bartlomiej Zolnierkiewicz
2007-09-18  8:49     ` Boaz Harrosh
2007-09-18  9:03   ` [PATCH ver2 " Boaz Harrosh
2007-09-18  9:14     ` Christoph Hellwig
2007-09-18 10:24       ` Boaz Harrosh
2007-09-18 10:27   ` [PATCH 24/24 ver3 ] " Boaz Harrosh
2007-09-19 19:59     ` Bartlomiej Zolnierkiewicz
2007-09-12 16:00 ` [patchset 0/24] Lots of the Accessors patches " Maciej W. Rozycki
2007-09-17 10:46 ` Bartlomiej Zolnierkiewicz
2007-09-17 11:36   ` Boaz Harrosh
2007-09-17 13:51   ` James Bottomley
2007-09-17 20:05     ` Bartlomiej Zolnierkiewicz
2007-09-17 20:57       ` Jeff Garzik
2007-09-17 21:00         ` James Bottomley
2007-09-17 21:05           ` Jeff Garzik
2007-10-10 18:24 ` Boaz Harrosh
2007-10-10 19:14   ` Matthew Wilcox

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).