Skip to content

use sg helper to operate scatterlist

Ming Lei linux-s390 linux-scsi linux-usb 3 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v5 Latest16 patches 14 repliesIn review
  2. v416 patches 23 repliesSuperseded
  3. v315 patches 8 repliesSuperseded

Changes in v5 from the cover letter

- one patch style fix in 5/11
- re-write convertion for 'staging: rtsx' as suggested by Christoph
- fix another issue in aha152x by Finn, and change the author to Finn now
- add reviewed-by tag

Patches in v5 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/16scsi: vmw_pscsi: use sg helper to operate scatterlistdrivers/scsi/vmw_pvscsi.c+1 -10 replies
2/16scsi: advansys: use sg helper to operate scatterlistdrivers/scsi/advansys.c+1 -10 replies
3/16scsi: lpfc: use sg helper to operate scatterlistdrivers/scsi/lpfc/lpfc_nvmet.c+1 -20 replies
4/16scsi: mvumi: use sg helper to operate scatterlistdrivers/scsi/mvumi.c+4 -50 replies
5/16scsi: ipr: use sg helper to operate scatterlistdrivers/scsi/ipr.c+16 -130 replies
6/16scsi: pmcraid: use sg helper to operate scatterlistdrivers/scsi/pmcraid.c+7 -70 replies
7/16usb: image: microtek: use sg helper to operate scatterlistdrivers/usb/image/microtek.c drivers/usb/image/microtek.h+9 -130 replies
8/16staging: unisys: visorhba: use sg helper to operate scatterlistdrivers/staging/unisys/visorhba/visorhba_main.c+4 -50 replies
9/16staging: rtsx: use sg helper to operate scatterlistdrivers/staging/rts5208/rtsx_transport.c drivers/staging/rts5208/rtsx_transport.h drivers/staging/rts5208/spi.c+24 -240 replies
10/16s390: zfcp_fc: use sg helper to operate scatterlistdrivers/s390/scsi/zfcp_fc.c+2 -28 replies
11/16scsi: aha152x: use sg helper to operate scatterlistdrivers/scsi/aha152x.c+23 -231 reply
12/16scsi: imm: use sg helper to operate scatterlistdrivers/scsi/imm.c+1 -10 replies
13/16scsi: pcmcia: nsp_cs: use sg helper to operate scatterlistdrivers/scsi/pcmcia/nsp_cs.c+2 -20 replies
14/16scsi: ppa: use sg helper to operate scatterlistdrivers/scsi/ppa.c+1 -10 replies
15/16scsi: wd33c93: use sg helper to operate scatterlistdrivers/scsi/wd33c93.c+1 -10 replies
16/16NCR5380: Support chained sg listsdrivers/scsi/NCR5380.c+18 -230 replies

Reviews trailers per patch

14 of 16 patches have a Reviewed-by or Acked-by.

PatchEwan D. MilneChristoph HellwigBart Van AsscheGreg Kroah-HartmanBenjamin BlockMichael Schmitz
1/16R-b R-b R-b
2/16R-b R-b R-b
3/16R-b R-b
4/16R-b R-b R-b
5/16R-b
6/16R-b R-b
7/16R-b R-b
8/16R-b R-b A-b
9/16
10/16R-b R-b A-b
11/16
12/16R-b R-b
13/16R-b R-b
14/16R-b R-b
15/16R-b R-b
16/16R-b R-b R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes. Scroll the table sideways for all 6 reviewers.

Read the v5 thread

Cover letter [PATCH V5 00/16] use sg helper to operate scatterlist

Hi,

Scsi MQ makes a large static allocation for the first scatter gather list chunk for the driver to use. This is a performance headache we'd like to fix by reducing the size of the allocation to a 2 element array. Doing this will break the current guarantee that any driver using SG_ALL doesn't need to use the scatterlist iterators and can get away with directly dereferencing the array. Thus we need to update all drivers to use the scatterlist iterators and remove direct indexing of the scatterlist array before reducing the initial scatterlist allocation size in SCSI.

So convert drivers to use scatterlist helper.

There are two types of direct access on scatterlist in SCSI drivers:

1) operate on the scatterlist via scsi_sglist(scmd) directly, then one local variable of 'struct scatterlist *' is involved.

2) scsi_sglist(scmd) is stored to cmd->SCp.buffer and the scatterlist is used via cmd->SCp.buffer.

The following coccinelle semantic patch is developed for finding the above two types of direct scatterlist uses:

	@@ struct scatterlist *p; @@
	(
	- ++p
	+ p = sg_next(p)
	|
	- p++
	+ p = sg_next(p)
	|
	- p = p + 1
	+ p = sg_next(p)
	|
	- p += 1
	+ p = sg_next(p)
	|
	- --p
	+ p = sg_non_exist_prev(p)
	|
	- p--
	+ p = sg_non_exist_prev(p)
	|
	- p = p - 1
	+ p = sg_non_exist_prev(p)
	|
	- p -= 1
	+ p = sg_non_exist_prev(p)
	)
	
	@@
	struct scatterlist *p;
	expression data != 0;
	@@
	- p[data]
	+ '!!!!!!use sg iterator helper!!!!!!'
	
	@@
	struct scatterlist[] p;
	expression data != 0;
	@@
	- p[data]
	+ '!!!!!!use sg iterator helper!!!!!!'
	
	
	@@ struct scsi_cmnd *scmd; @@
	(
	-	scmd->SCp.buffer++
	+	scmd->SCp.buffer = sg_next(scmd->SCp.buffer)
	|
	-	++scmd->SCp.buffer
	+	scmd->SCp.buffer = sg_next(scmd->SCp.buffer)
	|
	-	scmd->SCp.buffer += 1
	+	scmd->SCp.buffer = sg_next(scmd->SCp.buffer)
	|
	-	scmd->SCp.buffer = scmd->SCp.buffer + 1
	+	scmd->SCp.buffer = sg_next(scmd->SCp.buffer)
	|
	-	scmd->SCp.buffer--
	+	scmd->SCp.buffer = sg_no_exit_prev(scmd->SCp.buffer)
	|
	-	--scmd->SCp.buffer
	+	scmd->SCp.buffer = sg_no_exit_prev(scmd->SCp.buffer)
	|
	-	scmd->SCp.buffer -= 1
	+	scmd->SCp.buffer = sg_no_exit_prev(scmd->SCp.buffer)
	|
	-	scmd->SCp.buffer = scmd->SCp.buffer - 1
	+	scmd->SCp.buffer = sg_no_exit_prev(scmd->SCp.buffer)
	)
	
	@@
	struct scsi_cmnd *scmd;
	expression data != 0;
	@@
	- scmd->SCp.buffer[data]
	+ '!!!!!!use sg iterator helper!!!!!!'

The 1st 10 patches are for handling type #1, and the other 6 patches for handling type #2, and all the 16 are found by the above coccinelle semantic patch.

V5:
- one patch style fix in 5/11
- re-write convertion for 'staging: rtsx' as suggested by Christoph
- fix another issue in aha152x by Finn, and change the author to Finn now
- add reviewed-by tag

V4:
- fix building failure on pmcraid's conversion
- improve the coccinelle semantic patch to cover both two types of scatterlist direct use
- driver 'staging: rtsx' is covered

V3:
- update commit log and cover letter, most of words are from James Bottomley

V2:
- use coccinelle semantic patch for finding direct sgl uses from scsi command(9 drivers found)
- run 'git grep -E "SCp.buffer"' to find direct sgl uses from SCp.buffer(6 drivers are found)

Finn Thain (2):
scsi: aha152x: use sg helper to operate scatterlist
NCR5380: Support chained sg lists

Ming Lei (14):
scsi: vmw_pscsi: use sg helper to operate scatterlist
scsi: advansys: use sg helper to operate scatterlist
scsi: lpfc: use sg helper to operate scatterlist
scsi: mvumi: use sg helper to operate scatterlist
scsi: ipr: use sg helper to operate scatterlist
scsi: pmcraid: use sg helper to operate scatterlist
usb: image: microtek: use sg helper to operate scatterlist
staging: unisys: visorhba: use sg helper to operate scatterlist
staging: rtsx: use sg helper to operate scatterlist
s390: zfcp_fc: use sg helper to operate scatterlist
scsi: imm: use sg helper to operate scatterlist
scsi: pcmcia: nsp_cs: use sg helper to operate scatterlist
scsi: ppa: use sg helper to operate scatterlist
scsi: wd33c93: use sg helper to operate scatterlist

 drivers/s390/scsi/zfcp_fc.c                   |  4 +-
 drivers/scsi/NCR5380.c                        | 41 ++++++++---------
 drivers/scsi/advansys.c                       |  2 +-
 drivers/scsi/aha152x.c                        | 46 +++++++++----------
 drivers/scsi/imm.c                            |  2 +-
 drivers/scsi/ipr.c                            | 29 ++++++------
 drivers/scsi/lpfc/lpfc_nvmet.c                |  3 +-
 drivers/scsi/mvumi.c                          |  9 ++--
 drivers/scsi/pcmcia/nsp_cs.c                  |  4 +-
 drivers/scsi/pmcraid.c                        | 14 +++---
 drivers/scsi/ppa.c                            |  2 +-
 drivers/scsi/vmw_pvscsi.c                     |  2 +-
 drivers/scsi/wd33c93.c                        |  2 +-
 drivers/staging/rts5208/rtsx_transport.c      | 32 ++++++-------
 drivers/staging/rts5208/rtsx_transport.h      |  2 +-
 drivers/staging/rts5208/spi.c                 | 14 +++---
 .../staging/unisys/visorhba/visorhba_main.c   |  9 ++--
 drivers/usb/image/microtek.c                  | 20 ++++----
 drivers/usb/image/microtek.h                  |  2 +-
 19 files changed, 115 insertions(+), 124 deletions(-)
Signature · 1 line
2.20.1