linux-scsi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Boaz Harrosh <bharrosh@panasas.com>
To: James Bottomley <James.Bottomley@SteelEye.com>,
	FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>,
	Greg Kroah-Hartman <gregkh@suse.de>,
	Alan Stern <stern@rowland.harvard.edu>,
	Matthew
Subject: [PATCH 14/24] atp870u.c: convert to accessors and !use_sg cleanup
Date: Wed, 12 Sep 2007 03:03:36 +0300	[thread overview]
Message-ID: <46E72CD8.5070908@panasas.com> (raw)
In-Reply-To: <46E6F92D.2090409@panasas.com>


 - 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



  parent reply	other threads:[~2007-09-12  0:04 UTC|newest]

Thread overview: 59+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 ` Boaz Harrosh [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=46E72CD8.5070908@panasas.com \
    --to=bharrosh@panasas.com \
    --cc=James.Bottomley@SteelEye.com \
    --cc=fujita.tomonori@lab.ntt.co.jp \
    --cc=gregkh@suse.de \
    --cc=stern@rowland.harvard.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is 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).