Lots of the Accessors patches and !use_sg cleanup
Subsystems (7)
cover Lots of the Accessors patches and !use_sg cleanup
Here are more accessors patches. I have tried to find Maintainers of drivers but please help me if I missed any.
After this there are 3 drivers left (I think)
- gdth.c, pluto.c, seagate.c
These I'll send only next week in a set of their own. {Please tell me I can kill pluto and seagate.}
Some of the drivers that are not here were already posted by Tomo. Some of the drivers here were posted before but these are better versions of them.
[USB] - Greg Kroah-Hartman <[email protected]>, Alan Stern <[email protected]>,
Matthew Dharm <[email protected]>
0001- drivers/usb/storage/transport.c drivers/usb/storage/transport.h
0002- drivers/usb/storage/protocol.c
0003- drivers/usb/storage/shuttle_usbat.c
0004- drivers/usb/storage/freecom.c drivers/usb/storage/sddr09.c
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 <[email protected]>
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 <[email protected]>
0007 drivers/scsi/arm/acornscsi.c drivers/scsi/arm/scsi.h
[other drivers]
0008 drivers/scsi/pcmcia/nsp_cs.c - YOKOTA Hiroshi <[email protected]>
0009 drivers/ata/libata-scsi.c - Jeff Garzik <[email protected]>
0010 drivers/scsi/eata_pio.c - Bartlomiej Zolnierkiewicz <[email protected]> ?
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 <[email protected]>, Mark Fortescue <[email protected]>
0024 drivers/scsi/ide-scsi.c - Bartlomiej Zolnierkiewicz <[email protected]>
[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 - ?
Quoted 3 lines · Boaz Harrosh
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
Quoted 1 line · Steve
drivers/block/cciss_scsi.c
Already done by Tomo41ce639a1c50cb936f058f52f99f65740e3f550e
cciss: convert to use the data buffer accessors
PATCH 1/24 usb: transport - convert to accessors and !use_sg code path removal
In reply to Boaz Harrosh - This patch depends on:
usb: transport.c use scsi_eh API in REQUEST_SENSE execution
- Use scsi data accessors and remove of !use_sg code path.
- New usb_stor_bulk_srb() for use by drivers
--- drivers/usb/storage/transport.c | 44 +++++++++++++++++++++++--------------- drivers/usb/storage/transport.h | 2 + 2 files changed, 29 insertions(+), 17 deletions(-)
drivers/usb/storage/transport.c +27 -17
@@ -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)); } }
drivers/usb/storage/transport.h +2 -0
@@ -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
Signature · 1 line
1.5.3.1
PATCH 2/24 usb: protocol.c - convert to accessors and !use_sg code path removal
In reply to Boaz Harrosh- Use scsi data accessors and remove of !use_sg code path
--- drivers/usb/storage/protocol.c | 120 ++++++++++++++++----------------------- 1 files changed, 49 insertions(+), 71 deletions(-)
drivers/usb/storage/protocol.c +49 -71
@@ -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); }
Signature · 1 line
1.5.3.1
PATCH 3/24 usb: shuttle_usbat.c - convert to accessors and !use_sg code path removal
In reply to Boaz Harrosh - functions that received char* but where passed scatterlist* mostly were changed to receive void*
- Use scsi data accessors and remove of !use_sg code path
--- drivers/usb/storage/shuttle_usbat.c | 68 +++++++++++++--------------------- 1 files changed, 26 insertions(+), 42 deletions(-)
drivers/usb/storage/shuttle_usbat.c +26 -42
@@ -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;
Signature · 1 line
1.5.3.1
PATCH 4/24 usb: freecom.c & sddr09.c - convert to accessors and !use_sg cleanup
In reply to Boaz Harrosh - Use scsi data accessors and remove of !use_sg code path
- This patch is dependent on cleanup patch to usb transport.c/h
--- drivers/usb/storage/freecom.c | 14 ++++++-------- drivers/usb/storage/sddr09.c | 9 +++------ 2 files changed, 9 insertions(+), 14 deletions(-)
drivers/usb/storage/freecom.c +6 -8
@@ -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); }
drivers/usb/storage/sddr09.c +3 -6
@@ -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 );
Signature · 1 line
1.5.3.1
PATCH 5/24 isd200.c: use one-element sg list in issuing commands
In reply to Boaz Harrosh - isd200_action() was still using direct linear pointers in issuing commands to the USB transport level. This is no longer supported, use one-element scatterlist instead.
- Adjustment of command's length in the case of scsi-to-ata translation is now restored before return to queuecommand, since other wise it can leak BIOs.
- isd200_action() return Error on unknown requests. Used to print an error but still try to send garbage cdb.
- convert few places to scsi data accessors.
- Todo: This file will need to be changed when scsi_cmnd changes to scsi_data_buffer or any other solution.
--- drivers/usb/storage/isd200.c | 66 +++++++++++++++++++++++++++++------------ 1 files changed, 46 insertions(+), 20 deletions(-)
drivers/usb/storage/isd200.c +46 -20
@@ -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); }
Signature · 1 line
1.5.3.1
PATCH 6/24 NCR5380 familly convert to accessors & !use_sg cleanup
In reply to Boaz Harrosh - This patch depends on:
NCR5380: Use scsi_eh API for REQUEST_SENSE invocation
- convert to accessors and !use_sg cleanup
- FIXME: Not sg-chain ready look for ++cmd->SCp.buffer
--- drivers/scsi/NCR5380.c | 14 +++++++------- drivers/scsi/atari_NCR5380.c | 22 +++++++++++----------- drivers/scsi/sun3_NCR5380.c | 22 +++++++++++----------- 3 files changed, 29 insertions(+), 29 deletions(-)
drivers/scsi/NCR5380.c +7 -7
@@ -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 ; }
drivers/scsi/atari_NCR5380.c +11 -11
@@ -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 ; }
drivers/scsi/sun3_NCR5380.c +11 -11
@@ -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 ; }
Signature · 1 line
1.5.3.1
PATCH 7/24 arm: scsi convert to accessors and !use_sg cleanup
In reply to Boaz Harrosh- convert to accessors and !use_sg cleanup
--- drivers/scsi/arm/acornscsi.c | 14 +++++++------- drivers/scsi/arm/scsi.h | 34 +++++++++++----------------------- 2 files changed, 18 insertions(+), 30 deletions(-)
drivers/scsi/arm/acornscsi.c +7 -7
@@ -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);
drivers/scsi/arm/scsi.h +11 -23
@@ -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 ; } }
Signature · 1 line
1.5.3.1
Re: [PATCH 07/24] arm: scsi convert to accessors and !use_sg cleanup
drivers/scsi/arm/scsi.h static inline void init_SCp(struct scsi_cmnd *SCpnt) · line 94
Quoted 3 lines · Boaz Harrosh
drivers/scsi/arm/scsi.h +2
-1-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.
Quoted 18 lines
drivers/scsi/arm/scsi.h +2
-12printk (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) {
drivers/scsi/arm/scsi.h static inline void init_SCp(struct scsi_cmnd *SCpnt) · line 105
Quoted 10 lines
drivers/scsi/arm/scsi.h +2
-5-#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.
Signature · 3 lines
Russell King Linux kernel 2.6 ARM Linux - http://www.arm.linux.org.uk/ maintainer of:
Re: [PATCH 07/24] arm: scsi convert to accessors and !use_sg cleanup
Quoted 8 lines · Russell King
drivers/scsi/arm/scsi.h static inline void init_SCp(struct scsi_cmnd *SCpnt) · line 94
Quoted 3 lines · Boaz Harrosh
drivers/scsi/arm/scsi.h +2
-1-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.
Quoted 23 lines
Quoted 23 lines
drivers/scsi/arm/scsi.h +2
-17printk (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
Quoted 9 lines
drivers/scsi/arm/scsi.h static inline void init_SCp(struct scsi_cmnd *SCpnt) · line 105
Quoted 5 lines
drivers/scsi/arm/scsi.h +2
-0SCpnt->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
Re: [PATCH 07/24] arm: scsi convert to accessors and !use_sg cleanup
Quoted 45 lines · Boaz Harrosh
Quoted 8 lines · Russell King
drivers/scsi/arm/scsi.h static inline void init_SCp(struct scsi_cmnd *SCpnt) · line 94
Quoted 3 lines · Boaz Harrosh
drivers/scsi/arm/scsi.h +2
-1-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.
Quoted 23 lines
Quoted 23 lines
drivers/scsi/arm/scsi.h +2
-17printk (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 Quoted 9 lines
drivers/scsi/arm/scsi.h static inline void init_SCp(struct scsi_cmnd *SCpnt) · line 105
Quoted 5 lines
drivers/scsi/arm/scsi.h +2
-0SCpnt->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.
Quoted 7 lines
No! This check is no longer Relevant. The master
if()is onbufflen()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
Re: [PATCH 07/24] arm: scsi convert to accessors and !use_sg cleanup
Quoted 52 lines · James Bottomley
Quoted 43 lines · Boaz Harrosh
Quoted 7 lines · Russell King
Review
Quoted 3 lines · Boaz Harrosh
(quoted diff) +2
-1- 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.
Quoted 22 lines
Quoted 22 lines
(quoted diff) +2
-16printk(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);Quoted 9 lines
Review
Quoted 6 lines
(quoted diff) +2
-1-#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.
Quoted 7 lines
No! This check is no longer Relevant. The master
if()is onbufflen()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.
Quoted 7 lines
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)
------
Quoted 1 line
From
f02d6f44c9043258f8aa63c7dfe56c9a67db3fcfMon Sep 17 00:00:00 2001
From: Boaz Harrosh <[email protected]>
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
--- drivers/scsi/arm/acornscsi.c | 14 +++--- drivers/scsi/arm/scsi.h | 86 ++++++++++++++++++++++++----------------- 2 files changed, 57 insertions(+), 43 deletions(-)
drivers/scsi/arm/acornscsi.c +7 -7
@@ -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);
drivers/scsi/arm/scsi.h +50 -36
120 lines not on this page · raw message
Signature · 1 line
1.5.3.3
Re: [PATCH 07/24] arm: scsi convert to accessors and !use_sg cleanup
Quoted 3 lines · Boaz Harrosh
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:
drivers/scsi/arm/scsi.h static inline void init_SCp(struct scsi_cmnd *SCpnt) · line 118
Quoted 2 lines
drivers/scsi/arm/scsi.h +2
-0+ SCpnt->SCp.phase = +min (len,scsi_bufflen (SCpnt));
This min wants to be
+ min_t(unsigned long, len, scsi_bufflen(SCpnt));
Signature · 3 lines
Russell King Linux kernel 2.6 ARM Linux - http://www.arm.linux.org.uk/ maintainer of:
James Bottomley
maintainerRe: [PATCH 07/24] arm: scsi convert to accessors and !use_sg cleanup
In reply to Russell KingQuoted 31 lines · Russell King
drivers/scsi/arm/scsi.h static inline void init_SCp(struct scsi_cmnd *SCpnt) · line 94
Quoted 3 lines · Boaz Harrosh
drivers/scsi/arm/scsi.h +2
-1-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.
Quoted 23 lines
drivers/scsi/arm/scsi.h +2
-17printk (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
Quoted 8 lines
drivers/scsi/arm/scsi.h static inline void init_SCp(struct scsi_cmnd *SCpnt) · line 105
Quoted 5 lines
drivers/scsi/arm/scsi.h +2
-0SCpnt->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
PATCH 8/24 nsp_cs.c convert to data accessors and !use_sg cleanup
In reply to Boaz Harrosh - use scsi data accessors
- cleanup !use_sg code paths
- TODO: use next_sg() for Jens's sglist branch. Look for 2 places with "SCp.buffer++"
--- drivers/scsi/pcmcia/nsp_cs.c | 54 ++++++++++++++++++++++++++--------------- 1 files changed, 34 insertions(+), 20 deletions(-)
drivers/scsi/pcmcia/nsp_cs.c +34 -20
@@ -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 ;
Signature · 1 line
1.5.3.1
PATCH 9/24 libata-scsi: convert to use the data buffer accessors
In reply to Boaz Harrosh This is a minimal patch needed to use the data accessors but it is not a complete clean up of the !use_sg path. Libata-core still has the qc->flags & ATA_QCFLAG_SG and !qc->n_elem code paths. Perhaps an ata maintainer would have a go at it.
- TODO: further cleanup of qc->flags & ATA_QCFLAG_SG and !qc->n_elem code paths in libata-core
- TODO: Use scsi_dma_{map,unmap} where applicable.
--- drivers/ata/libata-scsi.c | 39 +++++++++++++-------------------------- 1 files changed, 13 insertions(+), 26 deletions(-)
drivers/ata/libata-scsi.c +13 -26
@@ -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 ;
Signature · 1 line
1.5.3.1
Re: [PATCH 09/24] libata-scsi: convert to use the data buffer accessors
I would much rather see the !use_sg cleanup in a separate patch series...
Jeff
Re: [PATCH 09/24] libata-scsi: convert to use the data buffer accessors
Quoted 6 lines · Jeff Garzik
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
Re: [PATCH 09/24] libata-scsi: convert to use the data buffer accessors
In reply to Jeff GarzikQuoted 1 line · Jeff Garzik
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
Signature · 6 lines
Matthew Dharm Home: [email protected] Maintainer, Linux USB Mass Storage Driver I could always suspend a few hundred accounts and watch what happens. -- Tanya User Friendly, 7/31/1998
Re: [PATCH 09/24] libata-scsi: convert to use the data buffer accessors
Quoted 8 lines · Matthew Dharm
Quoted 1 line · Jeff Garzik
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_IOwill 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
PATCH 1/2 libata-scsi: Remove !use_sg code paths
In reply to Jeff Garzik 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(-)
drivers/ata/libata-scsi.c +9 -22
@@ -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 ); - } }/**
Signature · 1 line
1.5.3.1
Re: [PATCH ver2 1/2] libata-scsi: Remove !use_sg code paths
Quoted 6 lines · Boaz Harrosh
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_SGand !qc->n_elem code paths. Perhaps an ata maintainer would have a go at it.
Quoted 6 lines
- TODO: further cleanup of
qc->flags&ATA_QCFLAG_SGand !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
PATCH 1/2 libata-scsi: Remove !use_sg code paths
In reply to Jeff Garzik 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(-)
drivers/ata/libata-scsi.c +9 -22
@@ -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 ); - } }/**
Signature · 1 line
1.5.3.1
PATCH 2/2 libata-scsi: convert to use the data buffer accessors
In reply to Jeff Garzik simple search-and-replace of direct scsi_cmnd access to use the data buffer accessors.
--- drivers/ata/libata-scsi.c | 18 +++++++++--------- 1 files changed, 9 insertions(+), 9 deletions(-)
drivers/ata/libata-scsi.c +9 -9
@@ -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 ;
Signature · 1 line
1.5.3.1
PATCH 2/2 libata-scsi: convert to use the data buffer accessors
In reply to Jeff Garzik simple search-and-replace of direct scsi_cmnd access to use the data buffer accessors.
--- drivers/ata/libata-scsi.c | 18 +++++++++--------- 1 files changed, 9 insertions(+), 9 deletions(-)
drivers/ata/libata-scsi.c +9 -9
@@ -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 ;
Signature · 1 line
1.5.3.1
PATCH 10/24 eata_pio.c: convert to accessors and !use_sg cleanup
In reply to Boaz Harrosh- convert to accessors and !use_sg cleanup
--- drivers/scsi/eata_pio.c | 12 ++++++------ 1 files changed, 6 insertions(+), 6 deletions(-)
drivers/scsi/eata_pio.c +6 -6
@@ -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; }
Signature · 1 line
1.5.3.1
PATCH 11/24 a2091.c: convert to accessors and !use_sg cleanup
In reply to Boaz Harrosh- convert to accessors and !use_sg cleanup
--- drivers/scsi/a2091.c | 36 +++++------------------------------- 1 files changed, 5 insertions(+), 31 deletions(-)
drivers/scsi/a2091.c +5 -31
@@ -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 ; } }
Signature · 1 line
1.5.3.1
PATCH 12/24 a3000.c: convert to accessors and !use_sg cleanup
In reply to Boaz Harrosh- convert to accessors and !use_sg cleanup
--- drivers/scsi/a3000.c | 15 +++------------ 1 files changed, 3 insertions(+), 12 deletions(-)
drivers/scsi/a3000.c +3 -12
@@ -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 ;
Signature · 1 line
1.5.3.1
PATCH 13/24 aha1542.c: convert to accessors and !use_sg cleanup
In reply to Boaz Harrosh- convert to accessors and !use_sg cleanup
--- drivers/scsi/aha1542.c | 54 +++++++++++------------------------------------ 1 files changed, 13 insertions(+), 41 deletions(-)
drivers/scsi/aha1542.c +13 -41
@@ -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 ;
Signature · 1 line
1.5.3.1
PATCH 14/24 atp870u.c: convert to accessors and !use_sg cleanup
In reply to Boaz Harrosh - convert to accessors and !use_sg cleanup
- Probably not ready for sg-chaining
--- drivers/scsi/atp870u.c | 102 ++++++++---------------------------------------- 1 files changed, 17 insertions(+), 85 deletions(-)
drivers/scsi/atp870u.c +17 -85
@@ -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
Signature · 1 line
1.5.3.1
PATCH 15/24 fd_mcs.c: convert to accessors and !use_sg cleanup
In reply to Boaz Harrosh - convert to accessors and !use_sg cleanup
- Not ready for sg-chaining
--- drivers/scsi/fd_mcs.c | 36 +++++++++++------------------------- 1 files changed, 11 insertions(+), 25 deletions(-)
drivers/scsi/fd_mcs.c +11 -25
@@ -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);
Signature · 1 line
1.5.3.1
PATCH 16/24 imm.c: convert to accessors and !use_sg cleanup
In reply to Boaz Harrosh - convert to accessors and !use_sg cleanup
- Not ready for sg-chaining
--- drivers/scsi/imm.c | 13 +++++-------- 1 files changed, 5 insertions(+), 8 deletions(-)
drivers/scsi/imm.c +5 -8
@@ -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++;
Signature · 1 line
1.5.3.1
PATCH 17/24 in2000.c: convert to accessors and !use_sg cleanup
In reply to Boaz Harrosh- convert to accessors and !use_sg cleanup
--- drivers/scsi/in2000.c | 10 +++++----- 1 files changed, 5 insertions(+), 5 deletions(-)
drivers/scsi/in2000.c +5 -5
@@ -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 ;
Signature · 1 line
1.5.3.1
Subject: [PATCH 20/24] scsi: esp family convert to accessors and !use_sg cleanup
In reply to Boaz Harrosh - convert to scsi data accessors and !use_sg code path removal
- When removing !use_sg code path I noticed that dma_mmu_get_scsi_one() && dma_mmu_release_scsi_one() are no longer used. So also remove all implementations of these.
- This family of drivers is totally not ready for chaining.
--- 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(-)
drivers/scsi/NCR53C9x.c +14 -28
@@ -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 ;
drivers/scsi/NCR53C9x.h +0 -2
@@ -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 *); };
drivers/scsi/dec_esp.c +0 -17
@@ -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);
drivers/scsi/oktagon_esp.c +0 -14
@@ -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) { }
drivers/scsi/sun3x_esp.c +2 -18
@@ -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);
Signature · 1 line
1.5.3.1
PATCH 18/24 ppa.c: convert to accessors and !use_sg cleanup
In reply to Boaz Harrosh- convert to accessors and !use_sg cleanup
--- drivers/scsi/ppa.c | 12 +++++------- 1 files changed, 5 insertions(+), 7 deletions(-)
drivers/scsi/ppa.c +5 -7
@@ -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 */
Signature · 1 line
1.5.3.1
Subject: [PATCH 22/24] Remove psi240i driver from kernel
In reply to Boaz Harrosh The psi240i driver is still written for cmnd->request_buffer as a char pointer to actual data. There was never any attempt to use the scatterlist option.
- remove all source files (3) from drivers/scsi
- Remove from Makefile and Kconfig
--- 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
drivers/scsi/Kconfig +0 -11
@@ -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
drivers/scsi/Makefile +0 -1
@@ -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
drivers/scsi/psi240i.c deleted +0 -689
689 lines not on this page · raw message
drivers/scsi/psi240i.h deleted +0 -315
315 lines not on this page · raw message
drivers/scsi/psi_chip.h deleted +0 -195
195 lines not on this page · raw message
Signature · 1 line
1.5.3.1
PATCH 19/24 wd33c93.c: convert to accessors and !use_sg cleanup
In reply to Boaz Harrosh- convert to accessors and !use_sg cleanup
--- drivers/scsi/wd33c93.c | 10 +++++----- 1 files changed, 5 insertions(+), 5 deletions(-)
drivers/scsi/wd33c93.c +5 -5
@@ -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
Signature · 1 line
1.5.3.1
PATCH 21/24 qlogicpti.c: convert to accessors and !use_sg cleanup
In reply to Boaz Harrosh- convert to accessors and !use_sg cleanup
[Note: This patch might conflict with upstream patches to this driver.
If so, please tell me and I'll fix it.]
--- drivers/scsi/qlogicpti.c | 54 +++++++++------------------------------------ 1 files changed, 11 insertions(+), 43 deletions(-)
drivers/scsi/qlogicpti.c +11 -43
@@ -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_intstatic 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;
Signature · 1 line
1.5.3.1
PATCH 21/24 qlogicpti.c: convert to accessors and !use_sg cleanup
- convert to accessors and !use_sg cleanup
--- drivers/scsi/qlogicpti.c | 29 +++++++---------------------- 1 files changed, 7 insertions(+), 22 deletions(-)
drivers/scsi/qlogicpti.c +7 -22
@@ -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;
Signature · 1 line
1.5.3.1
Re: [PATCH 21/24 ver2] qlogicpti.c: convert to accessors and !use_sg cleanup
From: Boaz Harrosh <[email protected]>
Date: Wed, 10 Oct 2007 20:25:30 +0200
Quoted 4 lines
- convert to accessors and !use_sg cleanup
Signed-off-by Boaz Harrosh <[email protected]>
PATCH 23/24 wd7000.c - proper fix for boards without sg support
In reply to Boaz Harrosh - code used to set sg_tablesize to zero for board revision less than 6. This is no longer supported, therefore I use sg_tablesize=1 and open code the sg handling for that case.
- Get rid of use of SG_NONE which will be removed soon.
--- drivers/scsi/wd7000.c | 12 ++++++------ 1 files changed, 6 insertions(+), 6 deletions(-)
drivers/scsi/wd7000.c +6 -6
@@ -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 */
Signature · 1 line
1.5.3.1
PATCH 24/24 ide-scsi.c: convert to data accessors and !use_sg cleanup
In reply to Boaz Harrosh- Convert ide-scsi to the new data accessors and cleanup the !use_sg code paths.
Inspecting old code I can see places that still assume scsi_cmnd->request_buffer is a linear char pointer. Though I admit this assumption is hidden behind a flag:
test_bit(PC_TRANSFORM, &pc->flags).
I have commented out the offending code and put a WARN_ON(1) in it's place. So if there is missing functionality it will complain but will not crash the kernel. Maintainer of this driver please inspect if this functionality is still needed, if not then please remove the commented code.
Thanks
--- drivers/scsi/ide-scsi.c | 53 ++++++++++++++++++++++++++++++---------------- 1 files changed, 34 insertions(+), 19 deletions(-)
drivers/scsi/ide-scsi.c +34 -19
@@ -175,7 +175,8 @@ static void idescsi_input_buffers (ide_drive_t *drive, idescsi_pc_t *pc, unsignechar *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, unsignchar *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;
Signature · 1 line
1.5.3.1
Re: [PATCH 24/24] ide-scsi.c: convert to data accessors and !use_sg cleanup
Quoted 8 lines · Boaz Harrosh
- Convert ide-scsi to the new data accessors and cleanup the !use_sg code paths.
Inspecting old code I can see places that still assume
scsi_cmnd->request_bufferis 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.
Quoted 2 lines
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()
Quoted 1 line
it will complain but will not crash the kernel.
sr is likely to complain due to scsi_mode_sense() usage :(
Quoted 141 lines
Maintainer of this driver please inspect if this functionality is still needed, if not then please remove the commented code.
Thanks
Signed-off-by Boaz Harrosh <[email protected]>--- drivers/scsi/ide-scsi.c | 53 ++++++++++++++++++++++++++++++---------------- 1 files changed, 34 insertions(+), 19 deletions(-)drivers/scsi/ide-scsi.c +34
-19@@ -175,7 +175,8 @@ static void idescsi_input_buffers (ide_drive_t *drive, idescsi_pc_t *pc, unsignechar *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, unsignchar *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;
Re: [PATCH 24/24] ide-scsi.c: convert to data accessors and !use_sg cleanup
Quoted 23 lines · Bartlomiej Zolnierkiewicz
Quoted 7 lines · Boaz Harrosh
- Convert ide-scsi to the new data accessors and cleanup the !use_sg code paths.
Inspecting old code I can see places that still assume
scsi_cmnd->request_bufferis 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.cwhile making SCSI use only sg forREQ_TYPE_BLOCK_PC.Quoted 2 lines
I have commented out the offending code and put a
WARN_ON(1)in it's place. So if there is missing functionalityin
idescsi_transform_pc2():if (drive->media == ide_cdrom || drive->media == ide_optical) { ... WARN_ON(1) + #if/#endif 0 should be here ... }
Quoted 14 lines
rest of the changes look OK and you can add my ACK after fixing
idescsi_transform_pc2()Quoted 1 line
it will complain but will not crash the kernel.
sr is likely to complain due to
scsi_mode_sense()usage :(Quoted 7 lines
Maintainer of this driver please inspect if this functionality is still needed, if not then please remove the commented code.
Thanks
Signed-off-by Boaz Harrosh <[email protected]>---
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
PATCH 24/24 ide-scsi.c: convert to data accessors and !use_sg cleanup
In reply to Boaz Harrosh- 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.
--- drivers/scsi/ide-scsi.c | 85 +++++++++++++++++++++++++++-------------------- 1 files changed, 49 insertions(+), 36 deletions(-)
drivers/scsi/ide-scsi.c +49 -36
@@ -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, unsignechar *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, unsignchar *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;
Signature · 1 line
1.5.3.1
Re: [PATCH ver2 24/24] ide-scsi.c: convert to data accessors and !use_sg cleanup
Quoted 53 lines · Boaz Harrosh
- Convert ide-scsi to the new data accessors and cleanup the !use_sg code paths.
In old code the
MODE_SENSEorMODE_SELECTcode paths still assumedscsi_cmnd->request_bufferis 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_SENSEorMODE_SELECT.Signed-off-by Boaz Harrosh <[email protected]>--- drivers/scsi/ide-scsi.c | 85 +++++++++++++++++++++++++++-------------------- 1 files changed, 49 insertions(+), 36 deletions(-)drivers/scsi/ide-scsi.c +3
-2@@ -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, unsignechar *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) {drivers/scsi/ide-scsi.c +2
-3-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 ) {
drivers/scsi/ide-scsi.c static void idescsi_output_buffers (ide_drive_t *drive, idescsi_pc_t *pc, unsign · line 262
Quoted 10 lines
drivers/scsi/ide-scsi.c +2
-2c[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.
Re: [PATCH ver2 24/24] ide-scsi.c: convert to data accessors and !use_sg cleanup
Quoted 59 lines · Christoph Hellwig
Quoted 58 lines · Boaz Harrosh
- Convert ide-scsi to the new data accessors and cleanup the !use_sg code paths.
In old code the
MODE_SENSEorMODE_SELECTcode paths still assumedscsi_cmnd->request_bufferis 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_SENSEorMODE_SELECT.Signed-off-by Boaz Harrosh <[email protected]>--- drivers/scsi/ide-scsi.c | 85 +++++++++++++++++++++++++++-------------------- 1 files changed, 49 insertions(+), 36 deletions(-)drivers/scsi/ide-scsi.c +3
-2@@ -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, unsignechar *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) {drivers/scsi/ide-scsi.c +3
-3-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;
Quoted 9 lines
drivers/scsi/ide-scsi.c static void idescsi_output_buffers (ide_drive_t *drive, idescsi_pc_t *pc, unsign · line 262
Quoted 4 lines
drivers/scsi/ide-scsi.c +1
-2+char *atapi_buf;unsigned short new_len; -if (!scsi_buf) -return ;Please just kill the translations. Once we set
use_10_for_rwanduse_10_for_msin the host template the upper layers won't send it anymore, and we should just reject these when coming fromSG_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
PATCH 24/24 ide-scsi.c: convert to data accessors and !use_sg cleanup
In reply to Boaz Harrosh- 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.
--- drivers/scsi/ide-scsi.c | 138 +++++------------------------------------------ 1 files changed, 13 insertions(+), 125 deletions(-)
drivers/scsi/ide-scsi.c +13 -125
@@ -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, unsignechar *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, unsignchar *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);
Signature · 1 line
1.5.3.1
Re: [PATCH 24/24 ver3 ] ide-scsi.c: convert to data accessors and !use_sg cleanup
Quoted 8 lines · Boaz Harrosh
- 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_bufferis 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
Quoted 5 lines
As suggested by Christoph Hellwig I set
use_10_for_rw= 1; anduse_10_for_ms= 1;
for this device and completely killed the translation.Signed-off-by Boaz Harrosh <[email protected]>
anyway patch looks good
Quoted 4 lines · Boaz Harrosh
[esp family] - Maciej W. Rozycki <[email protected]>
0020drivers/scsi/NCR53C9x.cdrivers/scsi/NCR53C9x.h
drivers/scsi/dec_esp.cdrivers/scsi/oktagon_esp.cdrivers/scsi/sun3x_esp.c
Not really, but I have suitable hardware and can test your changes todrivers/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
Quoted 3 lines · Boaz Harrosh
Here are more accessors patches. I have tried to find Maintainers of drivers but please help me if I missed any.
[ ... ]
Quoted 1 line
0010
drivers/scsi/eata_pio.c- Bartlomiej Zolnierkiewicz <[email protected]> ?
not me, according to MAINTAINTERS file:
EATA-PIO SCSI DRIVER
P: Michael Neuffer M: [email protected] L: [email protected], [email protected] S: Maintained
BTW patch looks obviously OK
Quoted 1 line
0024
drivers/scsi/ide-scsi.c- Bartlomiej Zolnierkiewicz <[email protected]>
This reminds me that ide-scsi needs a real Maintainer, I don't have a time to closely follow-up SCSI changes...
Thanks,
Bart
Quoted 19 lines · Bartlomiej Zolnierkiewicz
Quoted 3 lines · Boaz Harrosh
Here are more accessors patches. I have tried to find Maintainers of drivers but please help me if I missed any.
[ ... ]
Quoted 1 line
0010
drivers/scsi/eata_pio.c- Bartlomiej Zolnierkiewicz <[email protected]> ?not me, according to MAINTAINTERS file:
EATA-PIO SCSI DRIVER
P: Michael Neuffer M: [email protected] L: [email protected], [email protected] S: MaintainedBTW patch looks obviously OK
Quoted 7 lines
Quoted 1 line
0024
drivers/scsi/ide-scsi.c- Bartlomiej Zolnierkiewicz <[email protected]>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
Quoted 6 lines · Bartlomiej Zolnierkiewicz
0024
drivers/scsi/ide-scsi.c- Bartlomiej Zolnierkiewicz <[email protected]>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 <[email protected]> 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
Quoted 11 lines · James Bottomley
Quoted 6 lines · Bartlomiej Zolnierkiewicz
0024
drivers/scsi/ide-scsi.c- Bartlomiej Zolnierkiewicz <[email protected]>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).
Quoted 3 lines
many bugs were virtually unfixable in 2.5. Willem Riede <[email protected]> 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...
Quoted 3 lines
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
Quoted 10 lines · Bartlomiej Zolnierkiewicz
Quoted 3 lines · James Bottomley
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
Kconfigentry 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
Quoted 13 lines · Jeff Garzik
Quoted 10 lines · Bartlomiej Zolnierkiewicz
Quoted 3 lines · James Bottomley
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
Kconfigentry in 2.6.24 to later remove the ide-scsi driver completely in 2.6.25.
Quoted 7 lines
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
Quoted 12 lines · James Bottomley
Quoted 11 lines · Jeff Garzik
Quoted 9 lines · Bartlomiej Zolnierkiewicz
Quoted 3 lines · James Bottomley
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
Kconfigentry in 2.6.24 to later remove the ide-scsi driver completely in 2.6.25.
Quoted 7 lines
Quoted 5 lines
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
Quoted 55 lines · Boaz Harrosh
Here are more accessors patches. I have tried to find Maintainers of drivers but please help me if I missed any.
After this there are 3 drivers left (I think)
-gdth.c,pluto.c,seagate.c
These I'll send only next week in a set of their own. {Please tell me I can kill pluto and seagate.}Some of the drivers that are not here were already posted by Tomo. Some of the drivers here were posted before but these are better versions of them.
[USB] - Greg Kroah-Hartman <[email protected]>, Alan Stern <[email protected]>,
Matthew Dharm <[email protected]>
0001-drivers/usb/storage/transport.cdrivers/usb/storage/transport.h
0002-drivers/usb/storage/protocol.c
0003-drivers/usb/storage/shuttle_usbat.c
0004-drivers/usb/storage/freecom.cdrivers/usb/storage/sddr09.c
0005drivers/usb/storage/isd200.c[NCR5380 family] - ?
0006drivers/scsi/NCR5380.cdrivers/scsi/atari_NCR5380.cdrivers/scsi/sun3_NCR5380.c[esp family] - Maciej W. Rozycki <[email protected]>
0020drivers/scsi/NCR53C9x.cdrivers/scsi/NCR53C9x.h
drivers/scsi/dec_esp.cdrivers/scsi/oktagon_esp.cdrivers/scsi/sun3x_esp.c[ARM] - Russell King <[email protected]>
0007drivers/scsi/arm/acornscsi.cdrivers/scsi/arm/scsi.h[other drivers]
0008drivers/scsi/pcmcia/nsp_cs.c- YOKOTA Hiroshi <[email protected]>
0009drivers/ata/libata-scsi.c- Jeff Garzik <[email protected]>
0010drivers/scsi/eata_pio.c- Bartlomiej Zolnierkiewicz <[email protected]> ?
0011drivers/scsi/a2091.c- ?
0012drivers/scsi/a3000.c- ?
0013drivers/scsi/aha1542.c- ?
0014drivers/scsi/atp870u.c- ?
0015drivers/scsi/fd_mcs.c- ?
0016drivers/scsi/imm.c- ?
0017drivers/scsi/in2000.c- ?
0018drivers/scsi/ppa.c- ?
0019drivers/scsi/wd33c93.c- ?
0021drivers/scsi/qlogicpti.c- David S. Miller <[email protected]>, Mark Fortescue <[email protected]>
0024drivers/scsi/ide-scsi.c- Bartlomiej Zolnierkiewicz <[email protected]>[remove
psi240i.cdriver] - ?
0022drivers/scsi/Kconfigdrivers/scsi/Makefile
deletedrivers/scsi/psi240i.c
deletedrivers/scsi/psi240i.h
deletedrivers/scsi/psi_chip.h
Quoted 3 lines
[fixes]
0023drivers/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
Quoted 3 lines · Boaz Harrosh
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 ;-)
Signature · 4 lines
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."