From 3d447ec0e30043a2acd52704f5ed1da07a6f2d6e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1rton=20N=C3=A9meth?= Date: Sun, 10 Jan 2010 13:39:29 +0100 Subject: block: make PCI device id constant MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The id_table field of the struct pci_driver is constant in so it is worth to make the initialization data also constant. The semantic match that finds this kind of pattern is as follows: (http://coccinelle.lip6.fr/) // @r@ disable decl_init,const_decl_init; identifier I1, I2, x; @@ struct I1 { ... const struct I2 *x; ... }; @s@ identifier r.I1, y; identifier r.x, E; @@ struct I1 y = { .x = E, }; @c@ identifier r.I2; identifier s.E; @@ const struct I2 E[] = ... ; @depends on !c@ identifier r.I2; identifier s.E; @@ + const struct I2 E[] = ...; // Signed-off-by: Márton Németh Cc: Julia Lawall Cc: cocci@diku.dk Signed-off-by: Jens Axboe --- drivers/block/DAC960.c | 2 +- drivers/block/sx8.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers/block') diff --git a/drivers/block/DAC960.c b/drivers/block/DAC960.c index ce1fa92..7412b5d 100644 --- a/drivers/block/DAC960.c +++ b/drivers/block/DAC960.c @@ -7134,7 +7134,7 @@ static struct DAC960_privdata DAC960_P_privdata = { .MemoryWindowSize = DAC960_PD_RegisterWindowSize, }; -static struct pci_device_id DAC960_id_table[] = { +static const struct pci_device_id DAC960_id_table[] = { { .vendor = PCI_VENDOR_ID_MYLEX, .device = PCI_DEVICE_ID_MYLEX_DAC960_GEM, diff --git a/drivers/block/sx8.c b/drivers/block/sx8.c index a7c4184..7bd7b2f 100644 --- a/drivers/block/sx8.c +++ b/drivers/block/sx8.c @@ -409,7 +409,7 @@ static int carm_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) static void carm_remove_one (struct pci_dev *pdev); static int carm_bdev_getgeo(struct block_device *bdev, struct hd_geometry *geo); -static struct pci_device_id carm_pci_tbl[] = { +static const struct pci_device_id carm_pci_tbl[] = { { PCI_VENDOR_ID_PROMISE, 0x8000, PCI_ANY_ID, PCI_ANY_ID, 0, 0, }, { PCI_VENDOR_ID_PROMISE, 0x8002, PCI_ANY_ID, PCI_ANY_ID, 0, 0, }, { } /* terminate list */ -- cgit v1.1 From 577cdf0cf5afa5f350fbaddf77bbacdb9f76d2f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1rton=20N=C3=A9meth?= Date: Sun, 10 Jan 2010 13:39:39 +0100 Subject: block: make USB device id constant MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The id_table field of the struct usb_device_id is constant in so it is worth to make ub_usb_ids also constant. The semantic match that finds this kind of pattern is as follows: (http://coccinelle.lip6.fr/) // @r@ disable decl_init,const_decl_init; identifier I1, I2, x; @@ struct I1 { ... const struct I2 *x; ... }; @s@ identifier r.I1, y; identifier r.x, E; @@ struct I1 y = { .x = E, }; @c@ identifier r.I2; identifier s.E; @@ const struct I2 E[] = ... ; @depends on !c@ identifier r.I2; identifier s.E; @@ + const struct I2 E[] = ...; // Signed-off-by: Márton Németh Cc: Julia Lawall Cc: cocci@diku.dk Signed-off-by: Jens Axboe --- drivers/block/ub.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/block') diff --git a/drivers/block/ub.c b/drivers/block/ub.c index c739b20..d86d135 100644 --- a/drivers/block/ub.c +++ b/drivers/block/ub.c @@ -393,7 +393,7 @@ static int ub_probe_lun(struct ub_dev *sc, int lnum); #define ub_usb_ids usb_storage_usb_ids #else -static struct usb_device_id ub_usb_ids[] = { +static const struct usb_device_id ub_usb_ids[] = { { USB_INTERFACE_INFO(USB_CLASS_MASS_STORAGE, US_SC_SCSI, US_PR_BULK) }, { } }; -- cgit v1.1 From 5cccfd9b3a9ca06b6245ea2c4af052b7db0105a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1rton=20N=C3=A9meth?= Date: Sun, 10 Jan 2010 13:39:46 +0100 Subject: block: make Open Firmware device id constant MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The match_table field of the struct of_device_id is constant in so it is worth to make ace_of_match also constant. The semantic match that finds this kind of pattern is as follows: (http://coccinelle.lip6.fr/) // @r@ disable decl_init,const_decl_init; identifier I1, I2, x; @@ struct I1 { ... const struct I2 *x; ... }; @s@ identifier r.I1, y; identifier r.x, E; @@ struct I1 y = { .x = E, }; @c@ identifier r.I2; identifier s.E; @@ const struct I2 E[] = ... ; @depends on !c@ identifier r.I2; identifier s.E; @@ + const struct I2 E[] = ...; // Signed-off-by: Márton Németh Cc: Julia Lawall Cc: cocci@diku.dk Signed-off-by: Jens Axboe --- drivers/block/xsysace.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/block') diff --git a/drivers/block/xsysace.c b/drivers/block/xsysace.c index e5c5415..e1c95e2 100644 --- a/drivers/block/xsysace.c +++ b/drivers/block/xsysace.c @@ -1227,7 +1227,7 @@ static int __devexit ace_of_remove(struct of_device *op) } /* Match table for of_platform binding */ -static struct of_device_id ace_of_match[] __devinitdata = { +static const struct of_device_id ace_of_match[] __devinitconst = { { .compatible = "xlnx,opb-sysace-1.00.b", }, { .compatible = "xlnx,opb-sysace-1.00.c", }, { .compatible = "xlnx,xps-sysace-1.00.a", }, -- cgit v1.1 From ec9c42ec793d428e99fdd219867b31932034b138 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1rton=20N=C3=A9meth?= Date: Sun, 10 Jan 2010 13:39:52 +0100 Subject: block: make xenbus device id constant MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The ids field of the struct xenbus_device_id is constant in so it is worth to make blkfront_ids also constant. The semantic match that finds this kind of pattern is as follows: (http://coccinelle.lip6.fr/) // @r@ disable decl_init,const_decl_init; identifier I1, I2, x; @@ struct I1 { ... const struct I2 *x; ... }; @s@ identifier r.I1, y; identifier r.x, E; @@ struct I1 y = { .x = E, }; @c@ identifier r.I2; identifier s.E; @@ const struct I2 E[] = ... ; @depends on !c@ identifier r.I2; identifier s.E; @@ + const struct I2 E[] = ...; // Signed-off-by: Márton Németh Cc: Julia Lawall Cc: cocci@diku.dk Signed-off-by: Jens Axboe --- drivers/block/xen-blkfront.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/block') diff --git a/drivers/block/xen-blkfront.c b/drivers/block/xen-blkfront.c index 05a31e5..a84702d 100644 --- a/drivers/block/xen-blkfront.c +++ b/drivers/block/xen-blkfront.c @@ -1050,7 +1050,7 @@ static const struct block_device_operations xlvbd_block_fops = }; -static struct xenbus_device_id blkfront_ids[] = { +static const struct xenbus_device_id blkfront_ids[] = { { "vbd" }, { "" } }; -- cgit v1.1 From 47483e25205f1f8d79784f0f7c733941bc080ec0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1rton=20N=C3=A9meth?= Date: Sun, 10 Jan 2010 13:40:02 +0100 Subject: block: make virtio device id constant MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The id_table field of the struct virtio_driver is constant in so it is worth to make id_table also constant. The semantic match that finds this kind of pattern is as follows: (http://coccinelle.lip6.fr/) // @r@ disable decl_init,const_decl_init; identifier I1, I2, x; @@ struct I1 { ... const struct I2 *x; ... }; @s@ identifier r.I1, y; identifier r.x, E; @@ struct I1 y = { .x = E, }; @c@ identifier r.I2; identifier s.E; @@ const struct I2 E[] = ... ; @depends on !c@ identifier r.I2; identifier s.E; @@ + const struct I2 E[] = ...; // Signed-off-by: Márton Németh Cc: Julia Lawall Cc: cocci@diku.dk Signed-off-by: Jens Axboe --- drivers/block/virtio_blk.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/block') diff --git a/drivers/block/virtio_blk.c b/drivers/block/virtio_blk.c index 51042f0ba7..c17e622 100644 --- a/drivers/block/virtio_blk.c +++ b/drivers/block/virtio_blk.c @@ -404,7 +404,7 @@ static void __devexit virtblk_remove(struct virtio_device *vdev) kfree(vblk); } -static struct virtio_device_id id_table[] = { +static const struct virtio_device_id id_table[] = { { VIRTIO_ID_BLOCK, VIRTIO_DEV_ANY_ID }, { 0 }, }; -- cgit v1.1 From b028461d66a4dc2754d4e5dab1b3974c44798c5d Mon Sep 17 00:00:00 2001 From: dann frazier Date: Wed, 17 Feb 2010 16:53:31 -0700 Subject: cciss: remove C99-style comments Some cleanup before the header file split-out so we don't propagate this style into new files. Acked-by: Stephen M. Cameron Signed-off-by: dann frazier Signed-off-by: Jens Axboe --- drivers/block/cciss.c | 37 ++++++++++++++-------------- drivers/block/cciss.h | 9 +++---- drivers/block/cciss_cmd.h | 61 ++++++++++++++++++++++------------------------ drivers/block/cciss_scsi.h | 18 +++++++------- 4 files changed, 61 insertions(+), 64 deletions(-) (limited to 'drivers/block') diff --git a/drivers/block/cciss.c b/drivers/block/cciss.c index 873e594..8df23c7 100644 --- a/drivers/block/cciss.c +++ b/drivers/block/cciss.c @@ -1341,26 +1341,27 @@ static int cciss_ioctl(struct block_device *bdev, fmode_t mode, kfree(buff); return -ENOMEM; } - // Fill in the command type + /* Fill in the command type */ c->cmd_type = CMD_IOCTL_PEND; - // Fill in Command Header - c->Header.ReplyQueue = 0; // unused in simple mode - if (iocommand.buf_size > 0) // buffer to fill + /* Fill in Command Header */ + c->Header.ReplyQueue = 0; /* unused in simple mode */ + if (iocommand.buf_size > 0) /* buffer to fill */ { c->Header.SGList = 1; c->Header.SGTotal = 1; - } else // no buffers to fill + } else /* no buffers to fill */ { c->Header.SGList = 0; c->Header.SGTotal = 0; } c->Header.LUN = iocommand.LUN_info; - c->Header.Tag.lower = c->busaddr; // use the kernel address the cmd block for tag + /* use the kernel address the cmd block for tag */ + c->Header.Tag.lower = c->busaddr; - // Fill in Request block + /* Fill in Request block */ c->Request = iocommand.Request; - // Fill in the scatter gather information + /* Fill in the scatter gather information */ if (iocommand.buf_size > 0) { temp64.val = pci_map_single(host->pdev, buff, iocommand.buf_size, @@ -1368,7 +1369,7 @@ static int cciss_ioctl(struct block_device *bdev, fmode_t mode, c->SG[0].Addr.lower = temp64.val32.lower; c->SG[0].Addr.upper = temp64.val32.upper; c->SG[0].Len = iocommand.buf_size; - c->SG[0].Ext = 0; // we are not chaining + c->SG[0].Ext = 0; /* we are not chaining */ } c->waiting = &wait; @@ -2422,7 +2423,7 @@ static int fill_cmd(CommandList_struct *c, __u8 cmd, int ctlr, void *buff, c->Request.Type.Direction = XFER_READ; c->Request.Timeout = 0; c->Request.CDB[0] = cmd; - c->Request.CDB[6] = (size >> 24) & 0xFF; //MSB + c->Request.CDB[6] = (size >> 24) & 0xFF; /* MSB */ c->Request.CDB[7] = (size >> 16) & 0xFF; c->Request.CDB[8] = (size >> 8) & 0xFF; c->Request.CDB[9] = size & 0xFF; @@ -2691,7 +2692,7 @@ static void cciss_geometry_inquiry(int ctlr, int logvol, "cciss: reading geometry failed, volume " "does not support reading geometry\n"); drv->heads = 255; - drv->sectors = 32; // Sectors per track + drv->sectors = 32; /* Sectors per track */ drv->cylinders = total_size + 1; drv->raid_level = RAID_UNKNOWN; } else { @@ -3109,19 +3110,19 @@ static void do_cciss_request(struct request_queue *q) /* fill in the request */ drv = creq->rq_disk->private_data; - c->Header.ReplyQueue = 0; // unused in simple mode + c->Header.ReplyQueue = 0; /* unused in simple mode */ /* got command from pool, so use the command block index instead */ /* for direct lookups. */ /* The first 2 bits are reserved for controller error reporting. */ c->Header.Tag.lower = (c->cmdindex << 3); c->Header.Tag.lower |= 0x04; /* flag for direct lookup. */ memcpy(&c->Header.LUN, drv->LunID, sizeof(drv->LunID)); - c->Request.CDBLen = 10; // 12 byte commands not in FW yet; - c->Request.Type.Type = TYPE_CMD; // It is a command. + c->Request.CDBLen = 10; /* 12 byte commands not in FW yet; */ + c->Request.Type.Type = TYPE_CMD; /* It is a command. */ c->Request.Type.Attribute = ATTR_SIMPLE; c->Request.Type.Direction = (rq_data_dir(creq) == READ) ? XFER_READ : XFER_WRITE; - c->Request.Timeout = 0; // Don't time out + c->Request.Timeout = 0; /* Don't time out */ c->Request.CDB[0] = (rq_data_dir(creq) == READ) ? h->cciss_read : h->cciss_write; start_blk = blk_rq_pos(creq); @@ -3206,11 +3207,11 @@ static void do_cciss_request(struct request_queue *q) if (likely(blk_fs_request(creq))) { if(h->cciss_read == CCISS_READ_10) { c->Request.CDB[1] = 0; - c->Request.CDB[2] = (start_blk >> 24) & 0xff; //MSB + c->Request.CDB[2] = (start_blk >> 24) & 0xff; /* MSB */ c->Request.CDB[3] = (start_blk >> 16) & 0xff; c->Request.CDB[4] = (start_blk >> 8) & 0xff; c->Request.CDB[5] = start_blk & 0xff; - c->Request.CDB[6] = 0; // (sect >> 24) & 0xff; MSB + c->Request.CDB[6] = 0; /* (sect >> 24) & 0xff; MSB */ c->Request.CDB[7] = (blk_rq_sectors(creq) >> 8) & 0xff; c->Request.CDB[8] = blk_rq_sectors(creq) & 0xff; c->Request.CDB[9] = c->Request.CDB[11] = c->Request.CDB[12] = 0; @@ -3219,7 +3220,7 @@ static void do_cciss_request(struct request_queue *q) c->Request.CDBLen = 16; c->Request.CDB[1]= 0; - c->Request.CDB[2]= (upper32 >> 24) & 0xff; //MSB + c->Request.CDB[2]= (upper32 >> 24) & 0xff; /* MSB */ c->Request.CDB[3]= (upper32 >> 16) & 0xff; c->Request.CDB[4]= (upper32 >> 8) & 0xff; c->Request.CDB[5]= upper32 & 0xff; diff --git a/drivers/block/cciss.h b/drivers/block/cciss.h index 1d95db2..2b07bda 100644 --- a/drivers/block/cciss.h +++ b/drivers/block/cciss.h @@ -66,7 +66,7 @@ struct ctlr_info int ctlr; char devname[8]; char *product_name; - char firm_ver[4]; // Firmware version + char firm_ver[4]; /* Firmware version */ struct pci_dev *pdev; __u32 board_id; void __iomem *vaddr; @@ -103,7 +103,7 @@ struct ctlr_info BYTE cciss_write; BYTE cciss_read_capacity; - // information about each logical volume + /* information about each logical volume */ drive_info_struct *drv[CISS_MAX_LUN]; struct access_method access; @@ -116,7 +116,7 @@ struct ctlr_info unsigned int maxSG; spinlock_t lock; - //* pointers to command and error info pool */ + /* pointers to command and error info pool */ CommandList_struct *cmd_pool; dma_addr_t cmd_pool_dhandle; ErrorInfo_struct *errinfo_pool; @@ -134,7 +134,7 @@ struct ctlr_info */ int next_to_run; - // Disk structures we need to pass back + /* Disk structures we need to pass back */ struct gendisk *gendisk[CISS_MAX_LUN]; #ifdef CONFIG_CISS_SCSI_TAPE void *scsi_ctlr; /* ptr to structure containing scsi related stuff */ @@ -315,4 +315,3 @@ struct board_type { #define CCISS_LOCK(i) (&hba[i]->lock) #endif /* CCISS_H */ - diff --git a/drivers/block/cciss_cmd.h b/drivers/block/cciss_cmd.h index 6afa700..277422b 100644 --- a/drivers/block/cciss_cmd.h +++ b/drivers/block/cciss_cmd.h @@ -1,17 +1,16 @@ #ifndef CCISS_CMD_H #define CCISS_CMD_H -//########################################################################### -//DEFINES -//########################################################################### +/* DEFINES */ #define CISS_VERSION "1.00" -//general boundary definitions -#define SENSEINFOBYTES 32//note that this value may vary between host implementations +/* general boundary definitions */ +#define SENSEINFOBYTES 32 /* note that this value may vary + between host implementations */ #define MAXSGENTRIES 32 #define CCISS_SG_CHAIN 0x80000000 #define MAXREPLYQS 256 -//Command Status value +/* Command Status value */ #define CMD_SUCCESS 0x0000 #define CMD_TARGET_STATUS 0x0001 #define CMD_DATA_UNDERRUN 0x0002 @@ -49,30 +48,30 @@ #define ASYM_ACCESS_CHANGED 0x06 #define LUN_CAPACITY_CHANGED 0x09 -//transfer direction +/* transfer direction */ #define XFER_NONE 0x00 #define XFER_WRITE 0x01 #define XFER_READ 0x02 #define XFER_RSVD 0x03 -//task attribute +/* task attribute */ #define ATTR_UNTAGGED 0x00 #define ATTR_SIMPLE 0x04 #define ATTR_HEADOFQUEUE 0x05 #define ATTR_ORDERED 0x06 #define ATTR_ACA 0x07 -//cdb type +/* cdb type */ #define TYPE_CMD 0x00 #define TYPE_MSG 0x01 -//config space register offsets +/* config space register offsets */ #define CFG_VENDORID 0x00 #define CFG_DEVICEID 0x02 #define CFG_I2OBAR 0x10 #define CFG_MEM1BAR 0x14 -//i2o space register offsets +/* i2o space register offsets */ #define I2O_IBDB_SET 0x20 #define I2O_IBDB_CLEAR 0x70 #define I2O_INT_STATUS 0x30 @@ -81,7 +80,7 @@ #define I2O_OBPOST_Q 0x44 #define I2O_DMA1_CFG 0x214 -//Configuration Table +/* Configuration Table */ #define CFGTBL_ChangeReq 0x00000001l #define CFGTBL_AccCmds 0x00000001l @@ -103,24 +102,22 @@ typedef union _u64bit __u64 val; } u64bit; -// Type defs used in the following structs +/* Type defs used in the following structs */ #define BYTE __u8 #define WORD __u16 #define HWORD __u16 #define DWORD __u32 #define QWORD vals32 -//########################################################################### -//STRUCTURES -//########################################################################### +/* STRUCTURES */ #define CISS_MAX_LUN 1024 #define CISS_MAX_PHYS_LUN 1024 -// SCSI-3 Cmmands +/* SCSI-3 Cmmands */ #pragma pack(1) #define CISS_INQUIRY 0x12 -//Date returned +/* Date returned */ typedef struct _InquiryData_struct { BYTE data_byte[36]; @@ -128,7 +125,7 @@ typedef struct _InquiryData_struct #define CISS_REPORT_LOG 0xc2 /* Report Logical LUNs */ #define CISS_REPORT_PHYS 0xc3 /* Report Physical LUNs */ -// Data returned +/* Data returned */ typedef struct _ReportLUNdata_struct { BYTE LUNListLength[4]; @@ -139,8 +136,8 @@ typedef struct _ReportLUNdata_struct #define CCISS_READ_CAPACITY 0x25 /* Read Capacity */ typedef struct _ReadCapdata_struct { - BYTE total_size[4]; // Total size in blocks - BYTE block_size[4]; // Size of blocks in bytes + BYTE total_size[4]; /* Total size in blocks */ + BYTE block_size[4]; /* Size of blocks in bytes */ } ReadCapdata_struct; #define CCISS_READ_CAPACITY_16 0x9e /* Read Capacity 16 */ @@ -172,29 +169,29 @@ typedef struct _ReadCapdata_struct_16 #define CDB_LEN10 10 #define CDB_LEN16 16 -// BMIC commands +/* BMIC commands */ #define BMIC_READ 0x26 #define BMIC_WRITE 0x27 #define BMIC_CACHE_FLUSH 0xc2 -#define CCISS_CACHE_FLUSH 0x01 //C2 was already being used by CCISS +#define CCISS_CACHE_FLUSH 0x01 /* C2 was already being used by CCISS */ -//Command List Structure +/* Command List Structure */ typedef union _SCSI3Addr_struct { struct { BYTE Dev; BYTE Bus:6; - BYTE Mode:2; // b00 + BYTE Mode:2; /* b00 */ } PeripDev; struct { BYTE DevLSB; BYTE DevMSB:6; - BYTE Mode:2; // b01 + BYTE Mode:2; /* b01 */ } LogDev; struct { BYTE Dev:5; BYTE Bus:3; BYTE Targ:6; - BYTE Mode:2; // b10 + BYTE Mode:2; /* b10 */ } LogUnit; } SCSI3Addr_struct; @@ -202,7 +199,7 @@ typedef struct _PhysDevAddr_struct { DWORD TargetId:24; DWORD Bus:6; DWORD Mode:2; - SCSI3Addr_struct Target[2]; //2 level target device addr + SCSI3Addr_struct Target[2]; /* 2 level target device addr */ } PhysDevAddr_struct; typedef struct _LogDevAddr_struct { @@ -255,8 +252,8 @@ typedef union _MoreErrInfo_struct{ }Common_Info; struct{ BYTE Reserved[2]; - BYTE offense_size;//size of offending entry - BYTE offense_num; //byte # of offense 0-base + BYTE offense_size; /* size of offending entry */ + BYTE offense_num; /* byte # of offense 0-base */ DWORD offense_value; }Invalid_Cmd; }MoreErrInfo_struct; @@ -300,7 +297,7 @@ typedef struct _CommandList_struct { char pad[PADSIZE]; } CommandList_struct; -//Configuration Table Structure +/* Configuration Table Structure */ typedef struct _HostWrite_struct { DWORD TransportRequest; DWORD Reserved; @@ -326,4 +323,4 @@ typedef struct _CfgTable_struct { DWORD MaxPhysicalDrivesPerLogicalUnit; } CfgTable_struct; #pragma pack() -#endif // CCISS_CMD_H +#endif /* CCISS_CMD_H */ diff --git a/drivers/block/cciss_scsi.h b/drivers/block/cciss_scsi.h index 7b75024..6d5822f 100644 --- a/drivers/block/cciss_scsi.h +++ b/drivers/block/cciss_scsi.h @@ -25,16 +25,16 @@ #include /* possibly irrelevant, since we don't show disks */ - // the scsi id of the adapter... + /* the scsi id of the adapter... */ #define SELF_SCSI_ID 15 - // 15 is somewhat arbitrary, since the scsi-2 bus - // that's presented by the driver to the OS is - // fabricated. The "real" scsi-3 bus the - // hardware presents is fabricated too. - // The actual, honest-to-goodness physical - // bus that the devices are attached to is not - // addressible natively, and may in fact turn - // out to be not scsi at all. + /* 15 is somewhat arbitrary, since the scsi-2 bus + that's presented by the driver to the OS is + fabricated. The "real" scsi-3 bus the + hardware presents is fabricated too. + The actual, honest-to-goodness physical + bus that the devices are attached to is not + addressible natively, and may in fact turn + out to be not scsi at all. */ #define SCSI_CCISS_CAN_QUEUE 2 -- cgit v1.1 From 429c42c9d246f5bda868495c09974312a0177328 Mon Sep 17 00:00:00 2001 From: dann frazier Date: Wed, 17 Feb 2010 16:55:11 -0700 Subject: cciss: Consolidate duplicate bits in cciss_cmd.h & cciss_ioctl.h There are several duplicate definitions in cciss_cmd.h and cciss_ioctl.h. Consolidate these into the new cciss_defs.h file. This patch doesn't change the definitions exposed under include/linux, so userspace apps shouldn't be affected. Acked-by: Stephen M. Cameron Signed-off-by: dann frazier Signed-off-by: Jens Axboe --- drivers/block/cciss_cmd.h | 113 ++-------------------------------------------- 1 file changed, 3 insertions(+), 110 deletions(-) (limited to 'drivers/block') diff --git a/drivers/block/cciss_cmd.h b/drivers/block/cciss_cmd.h index 277422b..25f9762 100644 --- a/drivers/block/cciss_cmd.h +++ b/drivers/block/cciss_cmd.h @@ -1,30 +1,16 @@ #ifndef CCISS_CMD_H #define CCISS_CMD_H + +#include + /* DEFINES */ #define CISS_VERSION "1.00" /* general boundary definitions */ -#define SENSEINFOBYTES 32 /* note that this value may vary - between host implementations */ #define MAXSGENTRIES 32 #define CCISS_SG_CHAIN 0x80000000 #define MAXREPLYQS 256 -/* Command Status value */ -#define CMD_SUCCESS 0x0000 -#define CMD_TARGET_STATUS 0x0001 -#define CMD_DATA_UNDERRUN 0x0002 -#define CMD_DATA_OVERRUN 0x0003 -#define CMD_INVALID 0x0004 -#define CMD_PROTOCOL_ERR 0x0005 -#define CMD_HARDWARE_ERR 0x0006 -#define CMD_CONNECTION_LOST 0x0007 -#define CMD_ABORTED 0x0008 -#define CMD_ABORT_FAILED 0x0009 -#define CMD_UNSOLICITED_ABORT 0x000A -#define CMD_TIMEOUT 0x000B -#define CMD_UNABORTABLE 0x000C - /* Unit Attentions ASC's as defined for the MSA2012sa */ #define POWER_OR_RESET 0x29 #define STATE_CHANGED 0x2a @@ -48,23 +34,6 @@ #define ASYM_ACCESS_CHANGED 0x06 #define LUN_CAPACITY_CHANGED 0x09 -/* transfer direction */ -#define XFER_NONE 0x00 -#define XFER_WRITE 0x01 -#define XFER_READ 0x02 -#define XFER_RSVD 0x03 - -/* task attribute */ -#define ATTR_UNTAGGED 0x00 -#define ATTR_SIMPLE 0x04 -#define ATTR_HEADOFQUEUE 0x05 -#define ATTR_ORDERED 0x06 -#define ATTR_ACA 0x07 - -/* cdb type */ -#define TYPE_CMD 0x00 -#define TYPE_MSG 0x01 - /* config space register offsets */ #define CFG_VENDORID 0x00 #define CFG_DEVICEID 0x02 @@ -103,14 +72,9 @@ typedef union _u64bit } u64bit; /* Type defs used in the following structs */ -#define BYTE __u8 -#define WORD __u16 -#define HWORD __u16 -#define DWORD __u32 #define QWORD vals32 /* STRUCTURES */ -#define CISS_MAX_LUN 1024 #define CISS_MAX_PHYS_LUN 1024 /* SCSI-3 Cmmands */ @@ -176,45 +140,6 @@ typedef struct _ReadCapdata_struct_16 #define CCISS_CACHE_FLUSH 0x01 /* C2 was already being used by CCISS */ /* Command List Structure */ -typedef union _SCSI3Addr_struct { - struct { - BYTE Dev; - BYTE Bus:6; - BYTE Mode:2; /* b00 */ - } PeripDev; - struct { - BYTE DevLSB; - BYTE DevMSB:6; - BYTE Mode:2; /* b01 */ - } LogDev; - struct { - BYTE Dev:5; - BYTE Bus:3; - BYTE Targ:6; - BYTE Mode:2; /* b10 */ - } LogUnit; -} SCSI3Addr_struct; - -typedef struct _PhysDevAddr_struct { - DWORD TargetId:24; - DWORD Bus:6; - DWORD Mode:2; - SCSI3Addr_struct Target[2]; /* 2 level target device addr */ -} PhysDevAddr_struct; - -typedef struct _LogDevAddr_struct { - DWORD VolId:30; - DWORD Mode:2; - BYTE reserved[4]; -} LogDevAddr_struct; - -typedef union _LUNAddr_struct { - BYTE LunAddrBytes[8]; - SCSI3Addr_struct SCSI3Lun[4]; - PhysDevAddr_struct PhysDev; - LogDevAddr_struct LogDev; -} LUNAddr_struct; - #define CTLR_LUNID "\0\0\0\0\0\0\0\0" typedef struct _CommandListHeader_struct { @@ -224,16 +149,6 @@ typedef struct _CommandListHeader_struct { QWORD Tag; LUNAddr_struct LUN; } CommandListHeader_struct; -typedef struct _RequestBlock_struct { - BYTE CDBLen; - struct { - BYTE Type:3; - BYTE Attribute:3; - BYTE Direction:2; - } Type; - HWORD Timeout; - BYTE CDB[16]; -} RequestBlock_struct; typedef struct _ErrDescriptor_struct { QWORD Addr; DWORD Len; @@ -244,28 +159,6 @@ typedef struct _SGDescriptor_struct { DWORD Ext; } SGDescriptor_struct; -typedef union _MoreErrInfo_struct{ - struct { - BYTE Reserved[3]; - BYTE Type; - DWORD ErrorInfo; - }Common_Info; - struct{ - BYTE Reserved[2]; - BYTE offense_size; /* size of offending entry */ - BYTE offense_num; /* byte # of offense 0-base */ - DWORD offense_value; - }Invalid_Cmd; -}MoreErrInfo_struct; -typedef struct _ErrorInfo_struct { - BYTE ScsiStatus; - BYTE SenseLen; - HWORD CommandStatus; - DWORD ResidualCnt; - MoreErrInfo_struct MoreErrInfo; - BYTE SenseInfo[SENSEINFOBYTES]; -} ErrorInfo_struct; - /* Command types */ #define CMD_RWREQ 0x00 #define CMD_IOCTL_PEND 0x01 -- cgit v1.1 From c5ecc484c528ff50bdbb16fbfbac758ee368b329 Mon Sep 17 00:00:00 2001 From: Akinobu Mita Date: Wed, 24 Feb 2010 08:30:08 +0100 Subject: pktcdvd: use BIO list management functions Now that the bio list management stuff is generic, convert pktcdvd to use bio lists instead of its own private bio list implementation. Signed-off-by: Akinobu Mita Acked-by: Peter Osterlund Cc: Christoph Hellwig Signed-off-by: Jens Axboe --- drivers/block/pktcdvd.c | 89 ++++++++++++------------------------------------- 1 file changed, 21 insertions(+), 68 deletions(-) (limited to 'drivers/block') diff --git a/drivers/block/pktcdvd.c b/drivers/block/pktcdvd.c index 68b5957..7cd2973 100644 --- a/drivers/block/pktcdvd.c +++ b/drivers/block/pktcdvd.c @@ -569,6 +569,7 @@ static struct packet_data *pkt_alloc_packet_data(int frames) } spin_lock_init(&pkt->lock); + bio_list_init(&pkt->orig_bios); for (i = 0; i < frames; i++) { struct bio *bio = pkt_bio_alloc(1); @@ -721,43 +722,6 @@ static void pkt_rbtree_insert(struct pktcdvd_device *pd, struct pkt_rb_node *nod } /* - * Add a bio to a single linked list defined by its head and tail pointers. - */ -static void pkt_add_list_last(struct bio *bio, struct bio **list_head, struct bio **list_tail) -{ - bio->bi_next = NULL; - if (*list_tail) { - BUG_ON((*list_head) == NULL); - (*list_tail)->bi_next = bio; - (*list_tail) = bio; - } else { - BUG_ON((*list_head) != NULL); - (*list_head) = bio; - (*list_tail) = bio; - } -} - -/* - * Remove and return the first bio from a single linked list defined by its - * head and tail pointers. - */ -static inline struct bio *pkt_get_list_first(struct bio **list_head, struct bio **list_tail) -{ - struct bio *bio; - - if (*list_head == NULL) - return NULL; - - bio = *list_head; - *list_head = bio->bi_next; - if (*list_head == NULL) - *list_tail = NULL; - - bio->bi_next = NULL; - return bio; -} - -/* * Send a packet_command to the underlying block device and * wait for completion. */ @@ -876,13 +840,10 @@ static noinline_for_stack int pkt_set_speed(struct pktcdvd_device *pd, static void pkt_queue_bio(struct pktcdvd_device *pd, struct bio *bio) { spin_lock(&pd->iosched.lock); - if (bio_data_dir(bio) == READ) { - pkt_add_list_last(bio, &pd->iosched.read_queue, - &pd->iosched.read_queue_tail); - } else { - pkt_add_list_last(bio, &pd->iosched.write_queue, - &pd->iosched.write_queue_tail); - } + if (bio_data_dir(bio) == READ) + bio_list_add(&pd->iosched.read_queue, bio); + else + bio_list_add(&pd->iosched.write_queue, bio); spin_unlock(&pd->iosched.lock); atomic_set(&pd->iosched.attention, 1); @@ -917,8 +878,8 @@ static void pkt_iosched_process_queue(struct pktcdvd_device *pd) int reads_queued, writes_queued; spin_lock(&pd->iosched.lock); - reads_queued = (pd->iosched.read_queue != NULL); - writes_queued = (pd->iosched.write_queue != NULL); + reads_queued = !bio_list_empty(&pd->iosched.read_queue); + writes_queued = !bio_list_empty(&pd->iosched.write_queue); spin_unlock(&pd->iosched.lock); if (!reads_queued && !writes_queued) @@ -927,7 +888,7 @@ static void pkt_iosched_process_queue(struct pktcdvd_device *pd) if (pd->iosched.writing) { int need_write_seek = 1; spin_lock(&pd->iosched.lock); - bio = pd->iosched.write_queue; + bio = bio_list_peek(&pd->iosched.write_queue); spin_unlock(&pd->iosched.lock); if (bio && (bio->bi_sector == pd->iosched.last_write)) need_write_seek = 0; @@ -950,13 +911,10 @@ static void pkt_iosched_process_queue(struct pktcdvd_device *pd) } spin_lock(&pd->iosched.lock); - if (pd->iosched.writing) { - bio = pkt_get_list_first(&pd->iosched.write_queue, - &pd->iosched.write_queue_tail); - } else { - bio = pkt_get_list_first(&pd->iosched.read_queue, - &pd->iosched.read_queue_tail); - } + if (pd->iosched.writing) + bio = bio_list_pop(&pd->iosched.write_queue); + else + bio = bio_list_pop(&pd->iosched.read_queue); spin_unlock(&pd->iosched.lock); if (!bio) @@ -1114,7 +1072,7 @@ static void pkt_gather_data(struct pktcdvd_device *pd, struct packet_data *pkt) int f; char written[PACKET_MAX_SIZE]; - BUG_ON(!pkt->orig_bios); + BUG_ON(bio_list_empty(&pkt->orig_bios)); atomic_set(&pkt->io_wait, 0); atomic_set(&pkt->io_errors, 0); @@ -1124,7 +1082,7 @@ static void pkt_gather_data(struct pktcdvd_device *pd, struct packet_data *pkt) */ memset(written, 0, sizeof(written)); spin_lock(&pkt->lock); - for (bio = pkt->orig_bios; bio; bio = bio->bi_next) { + bio_list_for_each(bio, &pkt->orig_bios) { int first_frame = (bio->bi_sector - pkt->sector) / (CD_FRAMESIZE >> 9); int num_frames = bio->bi_size / CD_FRAMESIZE; pd->stats.secs_w += num_frames * (CD_FRAMESIZE >> 9); @@ -1363,7 +1321,7 @@ try_next_bio: break; pkt_rbtree_erase(pd, node); spin_lock(&pkt->lock); - pkt_add_list_last(bio, &pkt->orig_bios, &pkt->orig_bios_tail); + bio_list_add(&pkt->orig_bios, bio); pkt->write_size += bio->bi_size / CD_FRAMESIZE; spin_unlock(&pkt->lock); } @@ -1409,7 +1367,7 @@ static void pkt_start_write(struct pktcdvd_device *pd, struct packet_data *pkt) */ frames_write = 0; spin_lock(&pkt->lock); - for (bio = pkt->orig_bios; bio; bio = bio->bi_next) { + bio_list_for_each(bio, &pkt->orig_bios) { int segment = bio->bi_idx; int src_offs = 0; int first_frame = (bio->bi_sector - pkt->sector) / (CD_FRAMESIZE >> 9); @@ -1472,20 +1430,14 @@ static void pkt_start_write(struct pktcdvd_device *pd, struct packet_data *pkt) static void pkt_finish_packet(struct packet_data *pkt, int uptodate) { - struct bio *bio, *next; + struct bio *bio; if (!uptodate) pkt->cache_valid = 0; /* Finish all bios corresponding to this packet */ - bio = pkt->orig_bios; - while (bio) { - next = bio->bi_next; - bio->bi_next = NULL; + while ((bio = bio_list_pop(&pkt->orig_bios))) bio_endio(bio, uptodate ? 0 : -EIO); - bio = next; - } - pkt->orig_bios = pkt->orig_bios_tail = NULL; } static void pkt_run_state_machine(struct pktcdvd_device *pd, struct packet_data *pkt) @@ -2567,8 +2519,7 @@ static int pkt_make_request(struct request_queue *q, struct bio *bio) spin_lock(&pkt->lock); if ((pkt->state == PACKET_WAITING_STATE) || (pkt->state == PACKET_READ_WAIT_STATE)) { - pkt_add_list_last(bio, &pkt->orig_bios, - &pkt->orig_bios_tail); + bio_list_add(&pkt->orig_bios, bio); pkt->write_size += bio->bi_size / CD_FRAMESIZE; if ((pkt->write_size >= pkt->frames) && (pkt->state == PACKET_WAITING_STATE)) { @@ -2898,6 +2849,8 @@ static int pkt_setup_dev(dev_t dev, dev_t* pkt_dev) spin_lock_init(&pd->lock); spin_lock_init(&pd->iosched.lock); + bio_list_init(&pd->iosched.read_queue); + bio_list_init(&pd->iosched.write_queue); sprintf(pd->name, DRIVER_NAME"%d", idx); init_waitqueue_head(&pd->wqueue); pd->bio_queue = RB_ROOT; -- cgit v1.1 From eb28d31bc97e6374d81f404da309401ffaed467b Mon Sep 17 00:00:00 2001 From: "Martin K. Petersen" Date: Fri, 26 Feb 2010 00:20:37 -0500 Subject: block: Add BLK_ prefix to definitions Add a BLK_ prefix to block layer constants. Signed-off-by: Martin K. Petersen Signed-off-by: Jens Axboe --- drivers/block/ps3vram.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers/block') diff --git a/drivers/block/ps3vram.c b/drivers/block/ps3vram.c index 1fb6c31..a7ecb43 100644 --- a/drivers/block/ps3vram.c +++ b/drivers/block/ps3vram.c @@ -753,8 +753,8 @@ static int __devinit ps3vram_probe(struct ps3_system_bus_device *dev) blk_queue_make_request(queue, ps3vram_make_request); blk_queue_max_phys_segments(queue, MAX_PHYS_SEGMENTS); blk_queue_max_hw_segments(queue, MAX_HW_SEGMENTS); - blk_queue_max_segment_size(queue, MAX_SEGMENT_SIZE); - blk_queue_max_sectors(queue, SAFE_MAX_SECTORS); + blk_queue_max_segment_size(queue, BLK_MAX_SEGMENT_SIZE); + blk_queue_max_sectors(queue, BLK_SAFE_MAX_SECTORS); gendisk = alloc_disk(1); if (!gendisk) { -- cgit v1.1 From 086fa5ff0854c676ec333760f4c0154b3b242616 Mon Sep 17 00:00:00 2001 From: "Martin K. Petersen" Date: Fri, 26 Feb 2010 00:20:38 -0500 Subject: block: Rename blk_queue_max_sectors to blk_queue_max_hw_sectors The block layer calling convention is blk_queue_. blk_queue_max_sectors predates this practice, leading to some confusion. Rename the function to appropriately reflect that its intended use is to set max_hw_sectors. Also introduce a temporary wrapper for backwards compability. This can be removed after the merge window is closed. Signed-off-by: Martin K. Petersen Signed-off-by: Jens Axboe --- drivers/block/DAC960.c | 2 +- drivers/block/brd.c | 2 +- drivers/block/cciss.c | 2 +- drivers/block/drbd/drbd_nl.c | 2 +- drivers/block/floppy.c | 2 +- drivers/block/hd.c | 2 +- drivers/block/mg_disk.c | 2 +- drivers/block/paride/pd.c | 2 +- drivers/block/pktcdvd.c | 4 ++-- drivers/block/ps3disk.c | 2 +- drivers/block/ps3vram.c | 2 +- drivers/block/sunvdc.c | 2 +- drivers/block/ub.c | 2 +- drivers/block/viodasd.c | 2 +- drivers/block/xd.c | 2 +- drivers/block/xen-blkfront.c | 2 +- 16 files changed, 17 insertions(+), 17 deletions(-) (limited to 'drivers/block') diff --git a/drivers/block/DAC960.c b/drivers/block/DAC960.c index 7412b5d..1c0cd35 100644 --- a/drivers/block/DAC960.c +++ b/drivers/block/DAC960.c @@ -2535,7 +2535,7 @@ static bool DAC960_RegisterBlockDevice(DAC960_Controller_T *Controller) RequestQueue->queuedata = Controller; blk_queue_max_hw_segments(RequestQueue, Controller->DriverScatterGatherLimit); blk_queue_max_phys_segments(RequestQueue, Controller->DriverScatterGatherLimit); - blk_queue_max_sectors(RequestQueue, Controller->MaxBlocksPerCommand); + blk_queue_max_hw_sectors(RequestQueue, Controller->MaxBlocksPerCommand); disk->queue = RequestQueue; sprintf(disk->disk_name, "rd/c%dd%d", Controller->ControllerNumber, n); disk->major = MajorNumber; diff --git a/drivers/block/brd.c b/drivers/block/brd.c index 4f68843..c6ddeac 100644 --- a/drivers/block/brd.c +++ b/drivers/block/brd.c @@ -434,7 +434,7 @@ static struct brd_device *brd_alloc(int i) goto out_free_dev; blk_queue_make_request(brd->brd_queue, brd_make_request); blk_queue_ordered(brd->brd_queue, QUEUE_ORDERED_TAG, NULL); - blk_queue_max_sectors(brd->brd_queue, 1024); + blk_queue_max_hw_sectors(brd->brd_queue, 1024); blk_queue_bounce_limit(brd->brd_queue, BLK_BOUNCE_ANY); disk = brd->brd_disk = alloc_disk(1 << part_shift); diff --git a/drivers/block/cciss.c b/drivers/block/cciss.c index 86acdca5..030e52d 100644 --- a/drivers/block/cciss.c +++ b/drivers/block/cciss.c @@ -1802,7 +1802,7 @@ static int cciss_add_disk(ctlr_info_t *h, struct gendisk *disk, /* This is a limit in the driver and could be eliminated. */ blk_queue_max_phys_segments(disk->queue, h->maxsgentries); - blk_queue_max_sectors(disk->queue, h->cciss_max_sectors); + blk_queue_max_hw_sectors(disk->queue, h->cciss_max_sectors); blk_queue_softirq_done(disk->queue, cciss_softirq_done); diff --git a/drivers/block/drbd/drbd_nl.c b/drivers/block/drbd/drbd_nl.c index 1292e06..9b55e64 100644 --- a/drivers/block/drbd/drbd_nl.c +++ b/drivers/block/drbd/drbd_nl.c @@ -709,7 +709,7 @@ void drbd_setup_queue_param(struct drbd_conf *mdev, unsigned int max_seg_s) __mu max_seg_s = min(queue_max_sectors(b) * queue_logical_block_size(b), max_seg_s); - blk_queue_max_sectors(q, max_seg_s >> 9); + blk_queue_max_hw_sectors(q, max_seg_s >> 9); blk_queue_max_phys_segments(q, max_segments ? max_segments : MAX_PHYS_SEGMENTS); blk_queue_max_hw_segments(q, max_segments ? max_segments : MAX_HW_SEGMENTS); blk_queue_max_segment_size(q, max_seg_s); diff --git a/drivers/block/floppy.c b/drivers/block/floppy.c index 3266b4f..b9b1170 100644 --- a/drivers/block/floppy.c +++ b/drivers/block/floppy.c @@ -4234,7 +4234,7 @@ static int __init floppy_init(void) err = -ENOMEM; goto out_unreg_driver; } - blk_queue_max_sectors(floppy_queue, 64); + blk_queue_max_hw_sectors(floppy_queue, 64); blk_register_region(MKDEV(FLOPPY_MAJOR, 0), 256, THIS_MODULE, floppy_find, NULL, NULL); diff --git a/drivers/block/hd.c b/drivers/block/hd.c index d5cdce0..5116c65 100644 --- a/drivers/block/hd.c +++ b/drivers/block/hd.c @@ -719,7 +719,7 @@ static int __init hd_init(void) return -ENOMEM; } - blk_queue_max_sectors(hd_queue, 255); + blk_queue_max_hw_sectors(hd_queue, 255); init_timer(&device_timer); device_timer.function = hd_times_out; blk_queue_logical_block_size(hd_queue, 512); diff --git a/drivers/block/mg_disk.c b/drivers/block/mg_disk.c index 02b2583..5416c9a 100644 --- a/drivers/block/mg_disk.c +++ b/drivers/block/mg_disk.c @@ -980,7 +980,7 @@ static int mg_probe(struct platform_device *plat_dev) __func__, __LINE__); goto probe_err_6; } - blk_queue_max_sectors(host->breq, MG_MAX_SECTS); + blk_queue_max_hw_sectors(host->breq, MG_MAX_SECTS); blk_queue_logical_block_size(host->breq, MG_SECTOR_SIZE); init_timer(&host->timer); diff --git a/drivers/block/paride/pd.c b/drivers/block/paride/pd.c index 569e39e..e712cd5 100644 --- a/drivers/block/paride/pd.c +++ b/drivers/block/paride/pd.c @@ -906,7 +906,7 @@ static int __init pd_init(void) if (!pd_queue) goto out1; - blk_queue_max_sectors(pd_queue, cluster); + blk_queue_max_hw_sectors(pd_queue, cluster); if (register_blkdev(major, name)) goto out2; diff --git a/drivers/block/pktcdvd.c b/drivers/block/pktcdvd.c index 7cd2973..6e1daa2 100644 --- a/drivers/block/pktcdvd.c +++ b/drivers/block/pktcdvd.c @@ -2312,7 +2312,7 @@ static int pkt_open_dev(struct pktcdvd_device *pd, fmode_t write) * even if the size is a multiple of the packet size. */ spin_lock_irq(q->queue_lock); - blk_queue_max_sectors(q, pd->settings.size); + blk_queue_max_hw_sectors(q, pd->settings.size); spin_unlock_irq(q->queue_lock); set_bit(PACKET_WRITABLE, &pd->flags); } else { @@ -2613,7 +2613,7 @@ static void pkt_init_queue(struct pktcdvd_device *pd) blk_queue_make_request(q, pkt_make_request); blk_queue_logical_block_size(q, CD_FRAMESIZE); - blk_queue_max_sectors(q, PACKET_MAX_SECTORS); + blk_queue_max_hw_sectors(q, PACKET_MAX_SECTORS); blk_queue_merge_bvec(q, pkt_merge_bvec); q->queuedata = pd; } diff --git a/drivers/block/ps3disk.c b/drivers/block/ps3disk.c index 03a130d..9cd1a4a 100644 --- a/drivers/block/ps3disk.c +++ b/drivers/block/ps3disk.c @@ -474,7 +474,7 @@ static int __devinit ps3disk_probe(struct ps3_system_bus_device *_dev) blk_queue_bounce_limit(queue, BLK_BOUNCE_HIGH); - blk_queue_max_sectors(queue, dev->bounce_size >> 9); + blk_queue_max_hw_sectors(queue, dev->bounce_size >> 9); blk_queue_segment_boundary(queue, -1UL); blk_queue_dma_alignment(queue, dev->blk_size-1); blk_queue_logical_block_size(queue, dev->blk_size); diff --git a/drivers/block/ps3vram.c b/drivers/block/ps3vram.c index a7ecb43..6416b26 100644 --- a/drivers/block/ps3vram.c +++ b/drivers/block/ps3vram.c @@ -754,7 +754,7 @@ static int __devinit ps3vram_probe(struct ps3_system_bus_device *dev) blk_queue_max_phys_segments(queue, MAX_PHYS_SEGMENTS); blk_queue_max_hw_segments(queue, MAX_HW_SEGMENTS); blk_queue_max_segment_size(queue, BLK_MAX_SEGMENT_SIZE); - blk_queue_max_sectors(queue, BLK_SAFE_MAX_SECTORS); + blk_queue_max_hw_sectors(queue, BLK_SAFE_MAX_SECTORS); gendisk = alloc_disk(1); if (!gendisk) { diff --git a/drivers/block/sunvdc.c b/drivers/block/sunvdc.c index 411f064..dd30cdd 100644 --- a/drivers/block/sunvdc.c +++ b/drivers/block/sunvdc.c @@ -693,7 +693,7 @@ static int probe_disk(struct vdc_port *port) blk_queue_max_hw_segments(q, port->ring_cookies); blk_queue_max_phys_segments(q, port->ring_cookies); - blk_queue_max_sectors(q, port->max_xfer_size); + blk_queue_max_hw_sectors(q, port->max_xfer_size); g->major = vdc_major; g->first_minor = port->vio.vdev->dev_no << PARTITION_SHIFT; strcpy(g->disk_name, port->disk_name); diff --git a/drivers/block/ub.c b/drivers/block/ub.c index d86d135..352ea24 100644 --- a/drivers/block/ub.c +++ b/drivers/block/ub.c @@ -2323,7 +2323,7 @@ static int ub_probe_lun(struct ub_dev *sc, int lnum) blk_queue_max_hw_segments(q, UB_MAX_REQ_SG); blk_queue_max_phys_segments(q, UB_MAX_REQ_SG); blk_queue_segment_boundary(q, 0xffffffff); /* Dubious. */ - blk_queue_max_sectors(q, UB_MAX_SECTORS); + blk_queue_max_hw_sectors(q, UB_MAX_SECTORS); blk_queue_logical_block_size(q, lun->capacity.bsize); lun->disk = disk; diff --git a/drivers/block/viodasd.c b/drivers/block/viodasd.c index a8c8b56..d44ece7 100644 --- a/drivers/block/viodasd.c +++ b/drivers/block/viodasd.c @@ -473,7 +473,7 @@ retry: d->disk = g; blk_queue_max_hw_segments(q, VIOMAXBLOCKDMA); blk_queue_max_phys_segments(q, VIOMAXBLOCKDMA); - blk_queue_max_sectors(q, VIODASD_MAXSECTORS); + blk_queue_max_hw_sectors(q, VIODASD_MAXSECTORS); g->major = VIODASD_MAJOR; g->first_minor = dev_no << PARTITION_SHIFT; if (dev_no >= 26) diff --git a/drivers/block/xd.c b/drivers/block/xd.c index d1fd032..1a325fb 100644 --- a/drivers/block/xd.c +++ b/drivers/block/xd.c @@ -242,7 +242,7 @@ static int __init xd_init(void) } /* xd_maxsectors depends on controller - so set after detection */ - blk_queue_max_sectors(xd_queue, xd_maxsectors); + blk_queue_max_hw_sectors(xd_queue, xd_maxsectors); for (i = 0; i < xd_drives; i++) add_disk(xd_gendisk[i]); diff --git a/drivers/block/xen-blkfront.c b/drivers/block/xen-blkfront.c index a84702d..f9861aa 100644 --- a/drivers/block/xen-blkfront.c +++ b/drivers/block/xen-blkfront.c @@ -346,7 +346,7 @@ static int xlvbd_init_blk_queue(struct gendisk *gd, u16 sector_size) /* Hard sector size and max sectors impersonate the equiv. hardware. */ blk_queue_logical_block_size(rq, sector_size); - blk_queue_max_sectors(rq, 512); + blk_queue_max_hw_sectors(rq, 512); /* Each segment in a request is up to an aligned page in size. */ blk_queue_segment_boundary(rq, PAGE_SIZE - 1); -- cgit v1.1 From 8a78362c4eefc1deddbefe2c7f38aabbc2429d6b Mon Sep 17 00:00:00 2001 From: "Martin K. Petersen" Date: Fri, 26 Feb 2010 00:20:39 -0500 Subject: block: Consolidate phys_segment and hw_segment limits Except for SCSI no device drivers distinguish between physical and hardware segment limits. Consolidate the two into a single segment limit. Signed-off-by: Martin K. Petersen Signed-off-by: Jens Axboe --- drivers/block/DAC960.c | 2 +- drivers/block/cciss.c | 5 +---- drivers/block/cpqarray.c | 5 +---- drivers/block/drbd/drbd_nl.c | 3 +-- drivers/block/paride/pf.c | 3 +-- drivers/block/pktcdvd.c | 4 ++-- drivers/block/ps3disk.c | 3 +-- drivers/block/ps3vram.c | 3 +-- drivers/block/sunvdc.c | 3 +-- drivers/block/sx8.c | 3 +-- drivers/block/ub.c | 3 +-- drivers/block/viodasd.c | 3 +-- drivers/block/xen-blkfront.c | 3 +-- 13 files changed, 14 insertions(+), 29 deletions(-) (limited to 'drivers/block') diff --git a/drivers/block/DAC960.c b/drivers/block/DAC960.c index 1c0cd35..459f1bc 100644 --- a/drivers/block/DAC960.c +++ b/drivers/block/DAC960.c @@ -2534,7 +2534,7 @@ static bool DAC960_RegisterBlockDevice(DAC960_Controller_T *Controller) blk_queue_bounce_limit(RequestQueue, Controller->BounceBufferLimit); RequestQueue->queuedata = Controller; blk_queue_max_hw_segments(RequestQueue, Controller->DriverScatterGatherLimit); - blk_queue_max_phys_segments(RequestQueue, Controller->DriverScatterGatherLimit); + blk_queue_max_segments(RequestQueue, Controller->DriverScatterGatherLimit); blk_queue_max_hw_sectors(RequestQueue, Controller->MaxBlocksPerCommand); disk->queue = RequestQueue; sprintf(disk->disk_name, "rd/c%dd%d", Controller->ControllerNumber, n); diff --git a/drivers/block/cciss.c b/drivers/block/cciss.c index 030e52d..a29e694 100644 --- a/drivers/block/cciss.c +++ b/drivers/block/cciss.c @@ -1797,10 +1797,7 @@ static int cciss_add_disk(ctlr_info_t *h, struct gendisk *disk, blk_queue_bounce_limit(disk->queue, h->pdev->dma_mask); /* This is a hardware imposed limit. */ - blk_queue_max_hw_segments(disk->queue, h->maxsgentries); - - /* This is a limit in the driver and could be eliminated. */ - blk_queue_max_phys_segments(disk->queue, h->maxsgentries); + blk_queue_max_segments(disk->queue, h->maxsgentries); blk_queue_max_hw_sectors(disk->queue, h->cciss_max_sectors); diff --git a/drivers/block/cpqarray.c b/drivers/block/cpqarray.c index 6422651..91d1163 100644 --- a/drivers/block/cpqarray.c +++ b/drivers/block/cpqarray.c @@ -448,11 +448,8 @@ static int __init cpqarray_register_ctlr( int i, struct pci_dev *pdev) blk_queue_bounce_limit(q, hba[i]->pci_dev->dma_mask); /* This is a hardware imposed limit. */ - blk_queue_max_hw_segments(q, SG_MAX); + blk_queue_max_segments(q, SG_MAX); - /* This is a driver limit and could be eliminated. */ - blk_queue_max_phys_segments(q, SG_MAX); - init_timer(&hba[i]->timer); hba[i]->timer.expires = jiffies + IDA_TIMER; hba[i]->timer.data = (unsigned long)hba[i]; diff --git a/drivers/block/drbd/drbd_nl.c b/drivers/block/drbd/drbd_nl.c index 9b55e64..4df3b40 100644 --- a/drivers/block/drbd/drbd_nl.c +++ b/drivers/block/drbd/drbd_nl.c @@ -710,8 +710,7 @@ void drbd_setup_queue_param(struct drbd_conf *mdev, unsigned int max_seg_s) __mu max_seg_s = min(queue_max_sectors(b) * queue_logical_block_size(b), max_seg_s); blk_queue_max_hw_sectors(q, max_seg_s >> 9); - blk_queue_max_phys_segments(q, max_segments ? max_segments : MAX_PHYS_SEGMENTS); - blk_queue_max_hw_segments(q, max_segments ? max_segments : MAX_HW_SEGMENTS); + blk_queue_max_segments(q, max_segments ? max_segments : BLK_MAX_SEGMENTS); blk_queue_max_segment_size(q, max_seg_s); blk_queue_logical_block_size(q, 512); blk_queue_segment_boundary(q, PAGE_SIZE-1); diff --git a/drivers/block/paride/pf.c b/drivers/block/paride/pf.c index ea54ea3..ddb4f9a 100644 --- a/drivers/block/paride/pf.c +++ b/drivers/block/paride/pf.c @@ -956,8 +956,7 @@ static int __init pf_init(void) return -ENOMEM; } - blk_queue_max_phys_segments(pf_queue, cluster); - blk_queue_max_hw_segments(pf_queue, cluster); + blk_queue_max_segments(pf_queue, cluster); for (pf = units, unit = 0; unit < PF_UNITS; pf++, unit++) { struct gendisk *disk = pf->disk; diff --git a/drivers/block/pktcdvd.c b/drivers/block/pktcdvd.c index 6e1daa2..b72935b 100644 --- a/drivers/block/pktcdvd.c +++ b/drivers/block/pktcdvd.c @@ -950,14 +950,14 @@ static void pkt_iosched_process_queue(struct pktcdvd_device *pd) static int pkt_set_segment_merging(struct pktcdvd_device *pd, struct request_queue *q) { if ((pd->settings.size << 9) / CD_FRAMESIZE - <= queue_max_phys_segments(q)) { + <= queue_max_segments(q)) { /* * The cdrom device can handle one segment/frame */ clear_bit(PACKET_MERGE_SEGS, &pd->flags); return 0; } else if ((pd->settings.size << 9) / PAGE_SIZE - <= queue_max_phys_segments(q)) { + <= queue_max_segments(q)) { /* * We can handle this case at the expense of some extra memory * copies during write operations diff --git a/drivers/block/ps3disk.c b/drivers/block/ps3disk.c index 9cd1a4a..bc95469 100644 --- a/drivers/block/ps3disk.c +++ b/drivers/block/ps3disk.c @@ -482,8 +482,7 @@ static int __devinit ps3disk_probe(struct ps3_system_bus_device *_dev) blk_queue_ordered(queue, QUEUE_ORDERED_DRAIN_FLUSH, ps3disk_prepare_flush); - blk_queue_max_phys_segments(queue, -1); - blk_queue_max_hw_segments(queue, -1); + blk_queue_max_segments(queue, -1); blk_queue_max_segment_size(queue, dev->bounce_size); gendisk = alloc_disk(PS3DISK_MINORS); diff --git a/drivers/block/ps3vram.c b/drivers/block/ps3vram.c index 6416b26..83ebb39 100644 --- a/drivers/block/ps3vram.c +++ b/drivers/block/ps3vram.c @@ -751,8 +751,7 @@ static int __devinit ps3vram_probe(struct ps3_system_bus_device *dev) priv->queue = queue; queue->queuedata = dev; blk_queue_make_request(queue, ps3vram_make_request); - blk_queue_max_phys_segments(queue, MAX_PHYS_SEGMENTS); - blk_queue_max_hw_segments(queue, MAX_HW_SEGMENTS); + blk_queue_max_segments(queue, BLK_MAX_HW_SEGMENTS); blk_queue_max_segment_size(queue, BLK_MAX_SEGMENT_SIZE); blk_queue_max_hw_sectors(queue, BLK_SAFE_MAX_SECTORS); diff --git a/drivers/block/sunvdc.c b/drivers/block/sunvdc.c index dd30cdd..48e8fee 100644 --- a/drivers/block/sunvdc.c +++ b/drivers/block/sunvdc.c @@ -691,8 +691,7 @@ static int probe_disk(struct vdc_port *port) port->disk = g; - blk_queue_max_hw_segments(q, port->ring_cookies); - blk_queue_max_phys_segments(q, port->ring_cookies); + blk_queue_max_segments(q, port->ring_cookies); blk_queue_max_hw_sectors(q, port->max_xfer_size); g->major = vdc_major; g->first_minor = port->vio.vdev->dev_no << PARTITION_SHIFT; diff --git a/drivers/block/sx8.c b/drivers/block/sx8.c index 7bd7b2f..b70f0fc 100644 --- a/drivers/block/sx8.c +++ b/drivers/block/sx8.c @@ -1518,8 +1518,7 @@ static int carm_init_disks(struct carm_host *host) break; } disk->queue = q; - blk_queue_max_hw_segments(q, CARM_MAX_REQ_SG); - blk_queue_max_phys_segments(q, CARM_MAX_REQ_SG); + blk_queue_max_segments(q, CARM_MAX_REQ_SG); blk_queue_segment_boundary(q, CARM_SG_BOUNDARY); q->queuedata = port; diff --git a/drivers/block/ub.c b/drivers/block/ub.c index 352ea24..2e88983 100644 --- a/drivers/block/ub.c +++ b/drivers/block/ub.c @@ -2320,8 +2320,7 @@ static int ub_probe_lun(struct ub_dev *sc, int lnum) disk->queue = q; blk_queue_bounce_limit(q, BLK_BOUNCE_HIGH); - blk_queue_max_hw_segments(q, UB_MAX_REQ_SG); - blk_queue_max_phys_segments(q, UB_MAX_REQ_SG); + blk_queue_max_segments(q, UB_MAX_REQ_SG); blk_queue_segment_boundary(q, 0xffffffff); /* Dubious. */ blk_queue_max_hw_sectors(q, UB_MAX_SECTORS); blk_queue_logical_block_size(q, lun->capacity.bsize); diff --git a/drivers/block/viodasd.c b/drivers/block/viodasd.c index d44ece7..c12b313 100644 --- a/drivers/block/viodasd.c +++ b/drivers/block/viodasd.c @@ -471,8 +471,7 @@ retry: } d->disk = g; - blk_queue_max_hw_segments(q, VIOMAXBLOCKDMA); - blk_queue_max_phys_segments(q, VIOMAXBLOCKDMA); + blk_queue_max_segments(q, VIOMAXBLOCKDMA); blk_queue_max_hw_sectors(q, VIODASD_MAXSECTORS); g->major = VIODASD_MAJOR; g->first_minor = dev_no << PARTITION_SHIFT; diff --git a/drivers/block/xen-blkfront.c b/drivers/block/xen-blkfront.c index f9861aa..9c09694 100644 --- a/drivers/block/xen-blkfront.c +++ b/drivers/block/xen-blkfront.c @@ -353,8 +353,7 @@ static int xlvbd_init_blk_queue(struct gendisk *gd, u16 sector_size) blk_queue_max_segment_size(rq, PAGE_SIZE); /* Ensure a merged request will fit in a single I/O ring slot. */ - blk_queue_max_phys_segments(rq, BLKIF_MAX_SEGMENTS_PER_REQUEST); - blk_queue_max_hw_segments(rq, BLKIF_MAX_SEGMENTS_PER_REQUEST); + blk_queue_max_segments(rq, BLKIF_MAX_SEGMENTS_PER_REQUEST); /* Make sure buffer addresses are sector-aligned. */ blk_queue_dma_alignment(rq, 511); -- cgit v1.1 From 58daa9ce96b847ed130453f5fdd63c579fb1f84f Mon Sep 17 00:00:00 2001 From: "Stephen M. Cameron" Date: Fri, 26 Feb 2010 16:01:12 -0600 Subject: cciss: clarify command list padding calculation cciss: clarify command list padding calculation Signed-off-by: Stephen M. Cameron Signed-off-by: Jens Axboe --- drivers/block/cciss_cmd.h | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'drivers/block') diff --git a/drivers/block/cciss_cmd.h b/drivers/block/cciss_cmd.h index 25f9762..515c9f0 100644 --- a/drivers/block/cciss_cmd.h +++ b/drivers/block/cciss_cmd.h @@ -168,9 +168,14 @@ typedef struct _SGDescriptor_struct { #define CMD_MSG_STALE 0xff /* This structure needs to be divisible by 8 for new - * indexing method. + * indexing method. PAD_32 and PAD_64 can be adjusted + * independently as needed for 32-bit and 64-bits systems. */ -#define PADSIZE (sizeof(long) - 4) +#define IS_64_BIT ((sizeof(long) - 4)/4) +#define IS_32_BIT (!IS_64_BIT) +#define PAD_32 (0) +#define PAD_64 (4) +#define PADSIZE (IS_32_BIT * PAD_32 + IS_64_BIT * PAD_64) typedef struct _CommandList_struct { CommandListHeader_struct Header; RequestBlock_struct Request; -- cgit v1.1 From 1b7d0d28ad82cbd5650c26ec8e370176b112e407 Mon Sep 17 00:00:00 2001 From: "Stephen M. Cameron" Date: Fri, 26 Feb 2010 16:01:17 -0600 Subject: cciss: detect bad alignment of scsi commands at build time cciss: detect bad alignment of scsi commands at build time Incidentally fix some nearby c++ style comments. Signed-off-by: Stephen M. Cameron Signed-off-by: Jens Axboe --- drivers/block/cciss.c | 2 +- drivers/block/cciss_cmd.h | 9 ++++++--- drivers/block/cciss_scsi.c | 12 ++++++++---- 3 files changed, 15 insertions(+), 8 deletions(-) (limited to 'drivers/block') diff --git a/drivers/block/cciss.c b/drivers/block/cciss.c index a29e694..cd8c7c2 100644 --- a/drivers/block/cciss.c +++ b/drivers/block/cciss.c @@ -4496,7 +4496,7 @@ static int __init cciss_init(void) * boundary. Given that we use pci_alloc_consistent() to allocate an * array of them, the size must be a multiple of 8 bytes. */ - BUILD_BUG_ON(sizeof(CommandList_struct) % 8); + BUILD_BUG_ON(sizeof(CommandList_struct) % COMMANDLIST_ALIGNMENT); printk(KERN_INFO DRIVER_NAME "\n"); diff --git a/drivers/block/cciss_cmd.h b/drivers/block/cciss_cmd.h index 515c9f0..e624ff9 100644 --- a/drivers/block/cciss_cmd.h +++ b/drivers/block/cciss_cmd.h @@ -167,10 +167,13 @@ typedef struct _SGDescriptor_struct { #define CMD_MSG_TIMEOUT 0x05 #define CMD_MSG_STALE 0xff -/* This structure needs to be divisible by 8 for new - * indexing method. PAD_32 and PAD_64 can be adjusted - * independently as needed for 32-bit and 64-bits systems. +/* This structure needs to be divisible by COMMANDLIST_ALIGNMENT + * because low bits of the address are used to to indicate that + * whether the tag contains an index or an address. PAD_32 and + * PAD_64 can be adjusted independently as needed for 32-bit + * and 64-bits systems. */ +#define COMMANDLIST_ALIGNMENT (8) #define IS_64_BIT ((sizeof(long) - 4)/4) #define IS_32_BIT (!IS_64_BIT) #define PAD_32 (0) diff --git a/drivers/block/cciss_scsi.c b/drivers/block/cciss_scsi.c index 5d0e46d..f203606 100644 --- a/drivers/block/cciss_scsi.c +++ b/drivers/block/cciss_scsi.c @@ -93,11 +93,15 @@ static struct scsi_host_template cciss_driver_template = { }; #pragma pack(1) + +#define SCSI_PAD_32 4 +#define SCSI_PAD_64 4 + struct cciss_scsi_cmd_stack_elem_t { CommandList_struct cmd; ErrorInfo_struct Err; __u32 busaddr; - __u32 pad; + u8 pad[IS_32_BIT * SCSI_PAD_32 + IS_64_BIT * SCSI_PAD_64]; }; #pragma pack() @@ -202,9 +206,9 @@ scsi_cmd_stack_setup(int ctlr, struct cciss_scsi_adapter_data_t *sa) stk = &sa->cmd_stack; size = sizeof(struct cciss_scsi_cmd_stack_elem_t) * CMD_STACK_SIZE; - // pci_alloc_consistent guarantees 32-bit DMA address will - // be used - + /* Check alignment, see cciss_cmd.h near CommandList_struct def. */ + BUILD_BUG_ON((sizeof(*stk->pool) % COMMANDLIST_ALIGNMENT) != 0); + /* pci_alloc_consistent guarantees 32-bit DMA address will be used */ stk->pool = (struct cciss_scsi_cmd_stack_elem_t *) pci_alloc_consistent(hba[ctlr]->pdev, size, &stk->cmd_pool_handle); -- cgit v1.1 From 49fc5601ea3bf9625d699dc777f80f72e8126c0b Mon Sep 17 00:00:00 2001 From: "Stephen M. Cameron" Date: Fri, 26 Feb 2010 16:01:22 -0600 Subject: cciss: factor out scatter gather chain block allocation and freeing cciss: factor out scatter gather chain block allocation and freeing Rationale is that I want to use this code from the scsi half of the driver. Signed-off-by: Stephen M. Cameron Signed-off-by: Jens Axboe --- drivers/block/cciss.c | 108 +++++++++++++++++++++++++++----------------------- 1 file changed, 58 insertions(+), 50 deletions(-) (limited to 'drivers/block') diff --git a/drivers/block/cciss.c b/drivers/block/cciss.c index cd8c7c2..eddb916 100644 --- a/drivers/block/cciss.c +++ b/drivers/block/cciss.c @@ -257,6 +257,59 @@ static inline void removeQ(CommandList_struct *c) hlist_del_init(&c->list); } +static void cciss_free_sg_chain_blocks(struct Cmd_sg_list **cmd_sg_list, + int nr_cmds) +{ + int i; + + if (!cmd_sg_list) + return; + for (i = 0; i < nr_cmds; i++) { + if (cmd_sg_list[i]) { + kfree(cmd_sg_list[i]->sgchain); + kfree(cmd_sg_list[i]); + cmd_sg_list[i] = NULL; + } + } + kfree(cmd_sg_list); +} + +static struct Cmd_sg_list **cciss_allocate_sg_chain_blocks(ctlr_info_t *h, + int chainsize, int nr_cmds) +{ + int j; + struct Cmd_sg_list **cmd_sg_list; + + if (chainsize <= 0) + return NULL; + + cmd_sg_list = kmalloc(sizeof(*cmd_sg_list) * nr_cmds, GFP_KERNEL); + if (!cmd_sg_list) + return NULL; + + /* Build up chain blocks for each command */ + for (j = 0; j < nr_cmds; j++) { + cmd_sg_list[j] = kmalloc(sizeof(*cmd_sg_list[j]), GFP_KERNEL); + if (!cmd_sg_list[j]) { + dev_err(&h->pdev->dev, "Cannot get memory " + "for chain block.\n"); + goto clean; + } + /* Need a block of chainsized s/g elements. */ + cmd_sg_list[j]->sgchain = kmalloc((chainsize * + sizeof(SGDescriptor_struct)), GFP_KERNEL); + if (!cmd_sg_list[j]->sgchain) { + dev_err(&h->pdev->dev, "Cannot get memory " + "for s/g chains.\n"); + goto clean; + } + } + return cmd_sg_list; +clean: + cciss_free_sg_chain_blocks(cmd_sg_list, nr_cmds); + return NULL; +} + #include "cciss_scsi.c" /* For SCSI tape support */ static const char *raid_label[] = { "0", "4", "1(1+0)", "5", "5+1", "ADG", @@ -4238,37 +4291,10 @@ static int __devinit cciss_init_one(struct pci_dev *pdev, goto clean4; } } - hba[i]->cmd_sg_list = kmalloc(sizeof(struct Cmd_sg_list *) * - hba[i]->nr_cmds, - GFP_KERNEL); - if (!hba[i]->cmd_sg_list) { - printk(KERN_ERR "cciss%d: Cannot get memory for " - "s/g chaining.\n", i); + hba[i]->cmd_sg_list = cciss_allocate_sg_chain_blocks(hba[i], + hba[i]->chainsize, hba[i]->nr_cmds); + if (!hba[i]->cmd_sg_list && hba[i]->chainsize > 0) goto clean4; - } - /* Build up chain blocks for each command */ - if (hba[i]->chainsize > 0) { - for (j = 0; j < hba[i]->nr_cmds; j++) { - hba[i]->cmd_sg_list[j] = - kmalloc(sizeof(struct Cmd_sg_list), - GFP_KERNEL); - if (!hba[i]->cmd_sg_list[j]) { - printk(KERN_ERR "cciss%d: Cannot get memory " - "for chain block.\n", i); - goto clean4; - } - /* Need a block of chainsized s/g elements. */ - hba[i]->cmd_sg_list[j]->sgchain = - kmalloc((hba[i]->chainsize * - sizeof(SGDescriptor_struct)), - GFP_KERNEL); - if (!hba[i]->cmd_sg_list[j]->sgchain) { - printk(KERN_ERR "cciss%d: Cannot get memory " - "for s/g chains\n", i); - goto clean4; - } - } - } spin_lock_init(&hba[i]->lock); @@ -4327,16 +4353,7 @@ clean4: for (k = 0; k < hba[i]->nr_cmds; k++) kfree(hba[i]->scatter_list[k]); kfree(hba[i]->scatter_list); - /* Only free up extra s/g lists if controller supports them */ - if (hba[i]->chainsize > 0) { - for (j = 0; j < hba[i]->nr_cmds; j++) { - if (hba[i]->cmd_sg_list[j]) { - kfree(hba[i]->cmd_sg_list[j]->sgchain); - kfree(hba[i]->cmd_sg_list[j]); - } - } - kfree(hba[i]->cmd_sg_list); - } + cciss_free_sg_chain_blocks(hba[i]->cmd_sg_list, hba[i]->nr_cmds); if (hba[i]->cmd_pool) pci_free_consistent(hba[i]->pdev, hba[i]->nr_cmds * sizeof(CommandList_struct), @@ -4454,16 +4471,7 @@ static void __devexit cciss_remove_one(struct pci_dev *pdev) for (j = 0; j < hba[i]->nr_cmds; j++) kfree(hba[i]->scatter_list[j]); kfree(hba[i]->scatter_list); - /* Only free up extra s/g lists if controller supports them */ - if (hba[i]->chainsize > 0) { - for (j = 0; j < hba[i]->nr_cmds; j++) { - if (hba[i]->cmd_sg_list[j]) { - kfree(hba[i]->cmd_sg_list[j]->sgchain); - kfree(hba[i]->cmd_sg_list[j]); - } - } - kfree(hba[i]->cmd_sg_list); - } + cciss_free_sg_chain_blocks(hba[i]->cmd_sg_list, hba[i]->nr_cmds); /* * Deliberately omit pci_disable_device(): it does something nasty to * Smart Array controllers that pci_enable_device does not undo -- cgit v1.1 From dccc9b563e455b91f7247b1ca6b0face40323538 Mon Sep 17 00:00:00 2001 From: "Stephen M. Cameron" Date: Fri, 26 Feb 2010 16:01:27 -0600 Subject: cciss: simplify scatter gather code cciss: simplify scatter gather code. Instead of allocating an array of pointers to a structure containing an SGDescriptor structure, and two other elements that aren't really used, just allocate SGDescriptor structs. Signed-off-by: Stephen M. Cameron Signed-off-by: Jens Axboe --- drivers/block/cciss.c | 43 +++++++++++++++---------------------------- drivers/block/cciss.h | 8 +------- 2 files changed, 16 insertions(+), 35 deletions(-) (limited to 'drivers/block') diff --git a/drivers/block/cciss.c b/drivers/block/cciss.c index eddb916..adc517c 100644 --- a/drivers/block/cciss.c +++ b/drivers/block/cciss.c @@ -257,7 +257,7 @@ static inline void removeQ(CommandList_struct *c) hlist_del_init(&c->list); } -static void cciss_free_sg_chain_blocks(struct Cmd_sg_list **cmd_sg_list, +static void cciss_free_sg_chain_blocks(SGDescriptor_struct **cmd_sg_list, int nr_cmds) { int i; @@ -265,20 +265,17 @@ static void cciss_free_sg_chain_blocks(struct Cmd_sg_list **cmd_sg_list, if (!cmd_sg_list) return; for (i = 0; i < nr_cmds; i++) { - if (cmd_sg_list[i]) { - kfree(cmd_sg_list[i]->sgchain); - kfree(cmd_sg_list[i]); - cmd_sg_list[i] = NULL; - } + kfree(cmd_sg_list[i]); + cmd_sg_list[i] = NULL; } kfree(cmd_sg_list); } -static struct Cmd_sg_list **cciss_allocate_sg_chain_blocks(ctlr_info_t *h, - int chainsize, int nr_cmds) +static SGDescriptor_struct **cciss_allocate_sg_chain_blocks( + ctlr_info_t *h, int chainsize, int nr_cmds) { int j; - struct Cmd_sg_list **cmd_sg_list; + SGDescriptor_struct **cmd_sg_list; if (chainsize <= 0) return NULL; @@ -289,16 +286,10 @@ static struct Cmd_sg_list **cciss_allocate_sg_chain_blocks(ctlr_info_t *h, /* Build up chain blocks for each command */ for (j = 0; j < nr_cmds; j++) { - cmd_sg_list[j] = kmalloc(sizeof(*cmd_sg_list[j]), GFP_KERNEL); - if (!cmd_sg_list[j]) { - dev_err(&h->pdev->dev, "Cannot get memory " - "for chain block.\n"); - goto clean; - } /* Need a block of chainsized s/g elements. */ - cmd_sg_list[j]->sgchain = kmalloc((chainsize * - sizeof(SGDescriptor_struct)), GFP_KERNEL); - if (!cmd_sg_list[j]->sgchain) { + cmd_sg_list[j] = kmalloc((chainsize * + sizeof(*cmd_sg_list[j])), GFP_KERNEL); + if (!cmd_sg_list[j]) { dev_err(&h->pdev->dev, "Cannot get memory " "for s/g chains.\n"); goto clean; @@ -1731,7 +1722,7 @@ static void cciss_softirq_done(struct request *rq) pci_unmap_single(h->pdev, temp64.val, cmd->SG[i].Len, ddir); /* Point to the next block */ - curr_sg = h->cmd_sg_list[cmd->cmdindex]->sgchain; + curr_sg = h->cmd_sg_list[cmd->cmdindex]; sg_index = 0; } temp64.val32.lower = curr_sg[sg_index].Addr.lower; @@ -3206,7 +3197,7 @@ static void do_cciss_request(struct request_queue *q) curr_sg[sg_index].Ext = CCISS_SG_CHAIN; /* Point to next chain block. */ - curr_sg = h->cmd_sg_list[c->cmdindex]->sgchain; + curr_sg = h->cmd_sg_list[c->cmdindex]; sg_index = 0; chained = 1; } @@ -3223,6 +3214,7 @@ static void do_cciss_request(struct request_queue *q) if (chained) { int len; + dma_addr_t dma_addr; curr_sg = c->SG; sg_index = h->max_cmd_sgentries - 1; len = curr_sg[sg_index].Len; @@ -3231,16 +3223,11 @@ static void do_cciss_request(struct request_queue *q) * block with address of next chain block. */ temp64.val = pci_map_single(h->pdev, - h->cmd_sg_list[c->cmdindex]->sgchain, - len, dir); - - h->cmd_sg_list[c->cmdindex]->sg_chain_dma = temp64.val; + h->cmd_sg_list[c->cmdindex], len, dir); + dma_addr = temp64.val; curr_sg[sg_index].Addr.lower = temp64.val32.lower; curr_sg[sg_index].Addr.upper = temp64.val32.upper; - - pci_dma_sync_single_for_device(h->pdev, - h->cmd_sg_list[c->cmdindex]->sg_chain_dma, - len, dir); + pci_dma_sync_single_for_device(h->pdev, dma_addr, len, dir); } /* track how many SG entries we are using */ diff --git a/drivers/block/cciss.h b/drivers/block/cciss.h index 2b07bda..ac454fd 100644 --- a/drivers/block/cciss.h +++ b/drivers/block/cciss.h @@ -55,12 +55,6 @@ typedef struct _drive_info_struct char device_initialized; /* indicates whether dev is initialized */ } drive_info_struct; -struct Cmd_sg_list { - SGDescriptor_struct *sgchain; - dma_addr_t sg_chain_dma; - int chain_block_size; -}; - struct ctlr_info { int ctlr; @@ -89,7 +83,7 @@ struct ctlr_info int maxsgentries; int chainsize; int max_cmd_sgentries; - struct Cmd_sg_list **cmd_sg_list; + SGDescriptor_struct **cmd_sg_list; # define DOORBELL_INT 0 # define PERF_MODE_INT 1 -- cgit v1.1 From 2ad6cdc20fbeea1e1744190c00cebb64e4b4c491 Mon Sep 17 00:00:00 2001 From: "Stephen M. Cameron" Date: Fri, 26 Feb 2010 16:01:32 -0600 Subject: cciss: fix scatter gather chain block dma direction kludge cciss: fix scatter gather chain block dma direction kludge The data direction for the chained block of scatter gather elements should always be PCI_DMA_TODEVICE, but was mistakenly set to the direction of the data transfer, then a kludge to fix it was added, in which pci_dma_sync_single_for_device or pci_dma_sync_single_for_cpu was called. If the correct direction is used in the first place, the kludge isn't needed. Signed-off-by: Stephen M. Cameron Signed-off-by: Jens Axboe --- drivers/block/cciss.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'drivers/block') diff --git a/drivers/block/cciss.c b/drivers/block/cciss.c index adc517c..c0d794c 100644 --- a/drivers/block/cciss.c +++ b/drivers/block/cciss.c @@ -1717,10 +1717,8 @@ static void cciss_softirq_done(struct request *rq) if (curr_sg[sg_index].Ext == CCISS_SG_CHAIN) { temp64.val32.lower = cmd->SG[i].Addr.lower; temp64.val32.upper = cmd->SG[i].Addr.upper; - pci_dma_sync_single_for_cpu(h->pdev, temp64.val, - cmd->SG[i].Len, ddir); pci_unmap_single(h->pdev, temp64.val, - cmd->SG[i].Len, ddir); + cmd->SG[i].Len, PCI_DMA_TODEVICE); /* Point to the next block */ curr_sg = h->cmd_sg_list[cmd->cmdindex]; sg_index = 0; @@ -3223,11 +3221,11 @@ static void do_cciss_request(struct request_queue *q) * block with address of next chain block. */ temp64.val = pci_map_single(h->pdev, - h->cmd_sg_list[c->cmdindex], len, dir); + h->cmd_sg_list[c->cmdindex], len, + PCI_DMA_TODEVICE); dma_addr = temp64.val; curr_sg[sg_index].Addr.lower = temp64.val32.lower; curr_sg[sg_index].Addr.upper = temp64.val32.upper; - pci_dma_sync_single_for_device(h->pdev, dma_addr, len, dir); } /* track how many SG entries we are using */ -- cgit v1.1 From d45033ef56fa9b09b73a6eb2a0f280fa7c1bab09 Mon Sep 17 00:00:00 2001 From: "Stephen M. Cameron" Date: Fri, 26 Feb 2010 16:01:37 -0600 Subject: cciss: factor out scatter gather chain block mapping code cciss: factor out scatter gather chain block mapping code Rationale is I want to use this code from the scsi half of the driver. Signed-off-by: Stephen M. Cameron Signed-off-by: Jens Axboe --- drivers/block/cciss.c | 63 +++++++++++++++++++++++++++------------------------ 1 file changed, 34 insertions(+), 29 deletions(-) (limited to 'drivers/block') diff --git a/drivers/block/cciss.c b/drivers/block/cciss.c index c0d794c..9e3af30 100644 --- a/drivers/block/cciss.c +++ b/drivers/block/cciss.c @@ -301,6 +301,35 @@ clean: return NULL; } +static void cciss_unmap_sg_chain_block(ctlr_info_t *h, CommandList_struct *c) +{ + SGDescriptor_struct *chain_sg; + u64bit temp64; + + if (c->Header.SGTotal <= h->max_cmd_sgentries) + return; + + chain_sg = &c->SG[h->max_cmd_sgentries - 1]; + temp64.val32.lower = chain_sg->Addr.lower; + temp64.val32.upper = chain_sg->Addr.upper; + pci_unmap_single(h->pdev, temp64.val, chain_sg->Len, PCI_DMA_TODEVICE); +} + +static void cciss_map_sg_chain_block(ctlr_info_t *h, CommandList_struct *c, + SGDescriptor_struct *chain_block, int len) +{ + SGDescriptor_struct *chain_sg; + u64bit temp64; + + chain_sg = &c->SG[h->max_cmd_sgentries - 1]; + chain_sg->Ext = CCISS_SG_CHAIN; + chain_sg->Len = len; + temp64.val = pci_map_single(h->pdev, chain_block, len, + PCI_DMA_TODEVICE); + chain_sg->Addr.lower = temp64.val32.lower; + chain_sg->Addr.upper = temp64.val32.upper; +} + #include "cciss_scsi.c" /* For SCSI tape support */ static const char *raid_label[] = { "0", "4", "1(1+0)", "5", "5+1", "ADG", @@ -1715,10 +1744,7 @@ static void cciss_softirq_done(struct request *rq) /* unmap the DMA mapping for all the scatter gather elements */ for (i = 0; i < cmd->Header.SGList; i++) { if (curr_sg[sg_index].Ext == CCISS_SG_CHAIN) { - temp64.val32.lower = cmd->SG[i].Addr.lower; - temp64.val32.upper = cmd->SG[i].Addr.upper; - pci_unmap_single(h->pdev, temp64.val, - cmd->SG[i].Len, PCI_DMA_TODEVICE); + cciss_unmap_sg_chain_block(h, cmd); /* Point to the next block */ curr_sg = h->cmd_sg_list[cmd->cmdindex]; sg_index = 0; @@ -3122,7 +3148,6 @@ static void do_cciss_request(struct request_queue *q) SGDescriptor_struct *curr_sg; drive_info_struct *drv; int i, dir; - int nseg = 0; int sg_index = 0; int chained = 0; @@ -3189,11 +3214,6 @@ static void do_cciss_request(struct request_queue *q) for (i = 0; i < seg; i++) { if (((sg_index+1) == (h->max_cmd_sgentries)) && !chained && ((seg - i) > 1)) { - nseg = seg - i; - curr_sg[sg_index].Len = (nseg) * - sizeof(SGDescriptor_struct); - curr_sg[sg_index].Ext = CCISS_SG_CHAIN; - /* Point to next chain block. */ curr_sg = h->cmd_sg_list[c->cmdindex]; sg_index = 0; @@ -3206,27 +3226,12 @@ static void do_cciss_request(struct request_queue *q) curr_sg[sg_index].Addr.lower = temp64.val32.lower; curr_sg[sg_index].Addr.upper = temp64.val32.upper; curr_sg[sg_index].Ext = 0; /* we are not chaining */ - ++sg_index; } - - if (chained) { - int len; - dma_addr_t dma_addr; - curr_sg = c->SG; - sg_index = h->max_cmd_sgentries - 1; - len = curr_sg[sg_index].Len; - /* Setup pointer to next chain block. - * Fill out last element in current chain - * block with address of next chain block. - */ - temp64.val = pci_map_single(h->pdev, - h->cmd_sg_list[c->cmdindex], len, - PCI_DMA_TODEVICE); - dma_addr = temp64.val; - curr_sg[sg_index].Addr.lower = temp64.val32.lower; - curr_sg[sg_index].Addr.upper = temp64.val32.upper; - } + if (chained) + cciss_map_sg_chain_block(h, c, h->cmd_sg_list[c->cmdindex], + (seg - (h->max_cmd_sgentries - 1)) * + sizeof(SGDescriptor_struct)); /* track how many SG entries we are using */ if (seg > h->maxSG) -- cgit v1.1 From aad9fb6f2c5beafe76a724c90a4bd0d695ab8b42 Mon Sep 17 00:00:00 2001 From: "Stephen M. Cameron" Date: Fri, 26 Feb 2010 16:01:42 -0600 Subject: cciss: do not use void pointer for scsi hba data cciss: do not use void pointer for scsi hba data and get rid of related unnecessary type casting and delete some superfluous and misleading comments nearby. Signed-off-by: Stephen M. Cameron Signed-off-by: Jens Axboe --- drivers/block/cciss.h | 4 +--- drivers/block/cciss_scsi.c | 23 ++++++++++------------- 2 files changed, 11 insertions(+), 16 deletions(-) (limited to 'drivers/block') diff --git a/drivers/block/cciss.h b/drivers/block/cciss.h index ac454fd..c5d4111 100644 --- a/drivers/block/cciss.h +++ b/drivers/block/cciss.h @@ -131,9 +131,7 @@ struct ctlr_info /* Disk structures we need to pass back */ struct gendisk *gendisk[CISS_MAX_LUN]; #ifdef CONFIG_CISS_SCSI_TAPE - void *scsi_ctlr; /* ptr to structure containing scsi related stuff */ - /* list of block side commands the scsi error handling sucked up */ - /* and saved for later processing */ + struct cciss_scsi_adapter_data_t *scsi_ctlr; #endif unsigned char alive; struct list_head scan_list; diff --git a/drivers/block/cciss_scsi.c b/drivers/block/cciss_scsi.c index f203606..c458232 100644 --- a/drivers/block/cciss_scsi.c +++ b/drivers/block/cciss_scsi.c @@ -127,11 +127,9 @@ struct cciss_scsi_adapter_data_t { }; #define CPQ_TAPE_LOCK(ctlr, flags) spin_lock_irqsave( \ - &(((struct cciss_scsi_adapter_data_t *) \ - hba[ctlr]->scsi_ctlr)->lock), flags); + &hba[ctlr]->scsi_ctlr->lock, flags); #define CPQ_TAPE_UNLOCK(ctlr, flags) spin_unlock_irqrestore( \ - &(((struct cciss_scsi_adapter_data_t *) \ - hba[ctlr]->scsi_ctlr)->lock), flags); + &hba[ctlr]->scsi_ctlr->lock, flags); static CommandList_struct * scsi_cmd_alloc(ctlr_info_t *h) @@ -147,7 +145,7 @@ scsi_cmd_alloc(ctlr_info_t *h) struct cciss_scsi_cmd_stack_t *stk; u64bit temp64; - sa = (struct cciss_scsi_adapter_data_t *) h->scsi_ctlr; + sa = h->scsi_ctlr; stk = &sa->cmd_stack; if (stk->top < 0) @@ -186,7 +184,7 @@ scsi_cmd_free(ctlr_info_t *h, CommandList_struct *cmd) struct cciss_scsi_adapter_data_t *sa; struct cciss_scsi_cmd_stack_t *stk; - sa = (struct cciss_scsi_adapter_data_t *) h->scsi_ctlr; + sa = h->scsi_ctlr; stk = &sa->cmd_stack; if (stk->top >= CMD_STACK_SIZE) { printk("cciss: scsi_cmd_free called too many times.\n"); @@ -233,7 +231,7 @@ scsi_cmd_stack_free(int ctlr) struct cciss_scsi_cmd_stack_t *stk; size_t size; - sa = (struct cciss_scsi_adapter_data_t *) hba[ctlr]->scsi_ctlr; + sa = hba[ctlr]->scsi_ctlr; stk = &sa->cmd_stack; if (stk->top != CMD_STACK_SIZE-1) { printk( "cciss: %d scsi commands are still outstanding.\n", @@ -534,8 +532,7 @@ adjust_cciss_scsi_table(int ctlr, int hostno, CPQ_TAPE_LOCK(ctlr, flags); if (hostno != -1) /* if it's not the first time... */ - sh = ((struct cciss_scsi_adapter_data_t *) - hba[ctlr]->scsi_ctlr)->scsi_host; + sh = hba[ctlr]->scsi_ctlr->scsi_host; /* find any devices in ccissscsi[] that are not in sd[] and remove them from ccissscsi[] */ @@ -706,7 +703,7 @@ cciss_scsi_setup(int cntl_num) kfree(shba); shba = NULL; } - hba[cntl_num]->scsi_ctlr = (void *) shba; + hba[cntl_num]->scsi_ctlr = shba; return; } @@ -853,7 +850,7 @@ cciss_scsi_detect(int ctlr) sh->this_id = SELF_SCSI_ID; ((struct cciss_scsi_adapter_data_t *) - hba[ctlr]->scsi_ctlr)->scsi_host = (void *) sh; + hba[ctlr]->scsi_ctlr)->scsi_host = sh; sh->hostdata[0] = (unsigned long) hba[ctlr]; sh->irq = hba[ctlr]->intr[SIMPLE_MODE_INT]; sh->unique_id = sh->irq; @@ -1518,7 +1515,7 @@ cciss_unregister_scsi(int ctlr) /* we are being forcibly unloaded, and may not refuse. */ spin_lock_irqsave(CCISS_LOCK(ctlr), flags); - sa = (struct cciss_scsi_adapter_data_t *) hba[ctlr]->scsi_ctlr; + sa = hba[ctlr]->scsi_ctlr; stk = &sa->cmd_stack; /* if we weren't ever actually registered, don't unregister */ @@ -1545,7 +1542,7 @@ cciss_engage_scsi(int ctlr) unsigned long flags; spin_lock_irqsave(CCISS_LOCK(ctlr), flags); - sa = (struct cciss_scsi_adapter_data_t *) hba[ctlr]->scsi_ctlr; + sa = hba[ctlr]->scsi_ctlr; stk = &sa->cmd_stack; if (sa->registered) { -- cgit v1.1 From bf8873781831c7799255e0932848401070185dd0 Mon Sep 17 00:00:00 2001 From: "Stephen M. Cameron" Date: Fri, 26 Feb 2010 16:01:47 -0600 Subject: cciss: eliminate unnecessary pointer use in cciss scsi code cciss: eliminate unnecessary pointer use in cciss scsi code An extra level of indirection was being used in some places for no real reason. Signed-off-by: Stephen M. Cameron Signed-off-by: Jens Axboe --- drivers/block/cciss_scsi.c | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) (limited to 'drivers/block') diff --git a/drivers/block/cciss_scsi.c b/drivers/block/cciss_scsi.c index c458232..6dc15b6 100644 --- a/drivers/block/cciss_scsi.c +++ b/drivers/block/cciss_scsi.c @@ -1400,7 +1400,7 @@ cciss_scatter_gather(struct pci_dev *pdev, static int cciss_scsi_queue_command (struct scsi_cmnd *cmd, void (* done)(struct scsi_cmnd *)) { - ctlr_info_t **c; + ctlr_info_t *c; int ctlr, rc; unsigned char scsi3addr[8]; CommandList_struct *cp; @@ -1408,8 +1408,8 @@ cciss_scsi_queue_command (struct scsi_cmnd *cmd, void (* done)(struct scsi_cmnd // Get the ptr to our adapter structure (hba[i]) out of cmd->host. // We violate cmd->host privacy here. (Is there another way?) - c = (ctlr_info_t **) &cmd->device->host->hostdata[0]; - ctlr = (*c)->ctlr; + c = (ctlr_info_t *) cmd->device->host->hostdata[0]; + ctlr = c->ctlr; rc = lookup_scsi3addr(ctlr, cmd->device->channel, cmd->device->id, cmd->device->lun, scsi3addr); @@ -1432,7 +1432,7 @@ cciss_scsi_queue_command (struct scsi_cmnd *cmd, void (* done)(struct scsi_cmnd see what the device thinks of it. */ spin_lock_irqsave(CCISS_LOCK(ctlr), flags); - cp = scsi_cmd_alloc(*c); + cp = scsi_cmd_alloc(c); spin_unlock_irqrestore(CCISS_LOCK(ctlr), flags); if (cp == NULL) { /* trouble... */ printk("scsi_cmd_alloc returned NULL!\n"); @@ -1490,15 +1490,14 @@ cciss_scsi_queue_command (struct scsi_cmnd *cmd, void (* done)(struct scsi_cmnd BUG(); break; } - - cciss_scatter_gather((*c)->pdev, cp, cmd); // Fill the SG list + cciss_scatter_gather(c->pdev, cp, cmd); /* Put the request on the tail of the request queue */ spin_lock_irqsave(CCISS_LOCK(ctlr), flags); - addQ(&(*c)->reqQ, cp); - (*c)->Qdepth++; - start_io(*c); + addQ(&c->reqQ, cp); + c->Qdepth++; + start_io(c); spin_unlock_irqrestore(CCISS_LOCK(ctlr), flags); /* the cmd'll come back via intr handler in complete_scsi_command() */ @@ -1655,14 +1654,14 @@ static int cciss_eh_device_reset_handler(struct scsi_cmnd *scsicmd) int rc; CommandList_struct *cmd_in_trouble; unsigned char lunaddr[8]; - ctlr_info_t **c; + ctlr_info_t *c; int ctlr; /* find the controller to which the command to be aborted was sent */ - c = (ctlr_info_t **) &scsicmd->device->host->hostdata[0]; + c = (ctlr_info_t *) scsicmd->device->host->hostdata[0]; if (c == NULL) /* paranoia */ return FAILED; - ctlr = (*c)->ctlr; + ctlr = c->ctlr; printk(KERN_WARNING "cciss%d: resetting tape drive or medium changer.\n", ctlr); /* find the command that's giving us trouble */ cmd_in_trouble = (CommandList_struct *) scsicmd->host_scribble; @@ -1672,7 +1671,7 @@ static int cciss_eh_device_reset_handler(struct scsi_cmnd *scsicmd) /* send a reset to the SCSI LUN which the command was sent to */ rc = sendcmd_withirq(CCISS_RESET_MSG, ctlr, NULL, 0, 0, lunaddr, TYPE_MSG); - if (rc == 0 && wait_for_device_to_become_ready(*c, lunaddr) == 0) + if (rc == 0 && wait_for_device_to_become_ready(c, lunaddr) == 0) return SUCCESS; printk(KERN_WARNING "cciss%d: resetting device failed.\n", ctlr); return FAILED; @@ -1683,14 +1682,14 @@ static int cciss_eh_abort_handler(struct scsi_cmnd *scsicmd) int rc; CommandList_struct *cmd_to_abort; unsigned char lunaddr[8]; - ctlr_info_t **c; + ctlr_info_t *c; int ctlr; /* find the controller to which the command to be aborted was sent */ - c = (ctlr_info_t **) &scsicmd->device->host->hostdata[0]; + c = (ctlr_info_t *) scsicmd->device->host->hostdata[0]; if (c == NULL) /* paranoia */ return FAILED; - ctlr = (*c)->ctlr; + ctlr = c->ctlr; printk(KERN_WARNING "cciss%d: aborting tardy SCSI cmd\n", ctlr); /* find the command to be aborted */ -- cgit v1.1 From 87c3a922a7ee8cfb9ab837f4ae38c993e9b30711 Mon Sep 17 00:00:00 2001 From: "Stephen M. Cameron" Date: Fri, 26 Feb 2010 16:01:53 -0600 Subject: cciss: Fix problem with scatter gather elements in the scsi half of the driver cciss: Fix problem with scatter gather elements in the scsi half of the driver When support for more than 31 scatter gather elements was added to the block half of the driver, the SCSI half of the driver was not addressed, and the bump from 31 to 32 scatter gather elements in the command block itself (not chained) actually broke the SCSI half of the driver, so that any transfer requiring 32 scatter gather elements wouldn't work. This fix also increases the max transfer size and size of the scatter gather table to the limit supported by the controller Signed-off-by: Stephen M. Cameron Signed-off-by: Jens Axboe --- drivers/block/cciss_scsi.c | 85 ++++++++++++++++++++++++++++++++-------------- 1 file changed, 59 insertions(+), 26 deletions(-) (limited to 'drivers/block') diff --git a/drivers/block/cciss_scsi.c b/drivers/block/cciss_scsi.c index 6dc15b6..e1d0e2c 100644 --- a/drivers/block/cciss_scsi.c +++ b/drivers/block/cciss_scsi.c @@ -84,7 +84,6 @@ static struct scsi_host_template cciss_driver_template = { .queuecommand = cciss_scsi_queue_command, .can_queue = SCSI_CCISS_CAN_QUEUE, .this_id = 7, - .sg_tablesize = MAXSGENTRIES, .cmd_per_lun = 1, .use_clustering = DISABLE_CLUSTERING, /* Can't have eh_bus_reset_handler or eh_host_reset_handler for cciss */ @@ -94,13 +93,14 @@ static struct scsi_host_template cciss_driver_template = { #pragma pack(1) -#define SCSI_PAD_32 4 -#define SCSI_PAD_64 4 +#define SCSI_PAD_32 0 +#define SCSI_PAD_64 0 struct cciss_scsi_cmd_stack_elem_t { CommandList_struct cmd; ErrorInfo_struct Err; __u32 busaddr; + int cmdindex; u8 pad[IS_32_BIT * SCSI_PAD_32 + IS_64_BIT * SCSI_PAD_64]; }; @@ -122,6 +122,7 @@ struct cciss_scsi_cmd_stack_t { struct cciss_scsi_adapter_data_t { struct Scsi_Host *scsi_host; struct cciss_scsi_cmd_stack_t cmd_stack; + SGDescriptor_struct **cmd_sg_list; int registered; spinlock_t lock; // to protect ccissscsi[ctlr]; }; @@ -156,6 +157,7 @@ scsi_cmd_alloc(ctlr_info_t *h) memset(&c->Err, 0, sizeof(c->Err)); /* set physical addr of cmd and addr of scsi parameters */ c->cmd.busaddr = c->busaddr; + c->cmd.cmdindex = c->cmdindex; /* (__u32) (stk->cmd_pool_handle + (sizeof(struct cciss_scsi_cmd_stack_elem_t)*stk->top)); */ @@ -201,6 +203,11 @@ scsi_cmd_stack_setup(int ctlr, struct cciss_scsi_adapter_data_t *sa) struct cciss_scsi_cmd_stack_t *stk; size_t size; + sa->cmd_sg_list = cciss_allocate_sg_chain_blocks(hba[ctlr], + hba[ctlr]->chainsize, CMD_STACK_SIZE); + if (!sa->cmd_sg_list && hba[ctlr]->chainsize > 0) + return -ENOMEM; + stk = &sa->cmd_stack; size = sizeof(struct cciss_scsi_cmd_stack_elem_t) * CMD_STACK_SIZE; @@ -211,14 +218,16 @@ scsi_cmd_stack_setup(int ctlr, struct cciss_scsi_adapter_data_t *sa) pci_alloc_consistent(hba[ctlr]->pdev, size, &stk->cmd_pool_handle); if (stk->pool == NULL) { - printk("stk->pool is null\n"); - return -1; + cciss_free_sg_chain_blocks(sa->cmd_sg_list, CMD_STACK_SIZE); + sa->cmd_sg_list = NULL; + return -ENOMEM; } for (i=0; ielem[i] = &stk->pool[i]; stk->elem[i]->busaddr = (__u32) (stk->cmd_pool_handle + (sizeof(struct cciss_scsi_cmd_stack_elem_t) * i)); + stk->elem[i]->cmdindex = i; } stk->top = CMD_STACK_SIZE-1; return 0; @@ -243,6 +252,7 @@ scsi_cmd_stack_free(int ctlr) pci_free_consistent(hba[ctlr]->pdev, size, stk->pool, stk->cmd_pool_handle); stk->pool = NULL; + cciss_free_sg_chain_blocks(sa->cmd_sg_list, CMD_STACK_SIZE); } #if 0 @@ -726,6 +736,8 @@ complete_scsi_command( CommandList_struct *cp, int timeout, __u32 tag) ctlr = hba[cp->ctlr]; scsi_dma_unmap(cmd); + if (cp->Header.SGTotal > ctlr->max_cmd_sgentries) + cciss_unmap_sg_chain_block(ctlr, cp); cmd->result = (DID_OK << 16); /* host byte */ cmd->result |= (COMMAND_COMPLETE << 8); /* msg byte */ @@ -848,6 +860,7 @@ cciss_scsi_detect(int ctlr) sh->io_port = 0; // good enough? FIXME, sh->n_io_port = 0; // I don't think we use these two... sh->this_id = SELF_SCSI_ID; + sh->sg_tablesize = hba[ctlr]->maxsgentries; ((struct cciss_scsi_adapter_data_t *) hba[ctlr]->scsi_ctlr)->scsi_host = sh; @@ -1365,34 +1378,54 @@ cciss_scsi_proc_info(struct Scsi_Host *sh, dma mapping and fills in the scatter gather entries of the cciss command, cp. */ -static void -cciss_scatter_gather(struct pci_dev *pdev, - CommandList_struct *cp, - struct scsi_cmnd *cmd) +static void cciss_scatter_gather(ctlr_info_t *h, CommandList_struct *cp, + struct scsi_cmnd *cmd) { unsigned int len; struct scatterlist *sg; __u64 addr64; - int use_sg, i; - - BUG_ON(scsi_sg_count(cmd) > MAXSGENTRIES); - - use_sg = scsi_dma_map(cmd); - if (use_sg) { /* not too many addrs? */ - scsi_for_each_sg(cmd, sg, use_sg, i) { + int request_nsgs, i, chained, sg_index; + struct cciss_scsi_adapter_data_t *sa = h->scsi_ctlr; + SGDescriptor_struct *curr_sg; + + BUG_ON(scsi_sg_count(cmd) > h->maxsgentries); + + chained = 0; + sg_index = 0; + curr_sg = cp->SG; + request_nsgs = scsi_dma_map(cmd); + if (request_nsgs) { + scsi_for_each_sg(cmd, sg, request_nsgs, i) { + if (sg_index + 1 == h->max_cmd_sgentries && + !chained && request_nsgs - i > 1) { + chained = 1; + sg_index = 0; + curr_sg = sa->cmd_sg_list[cp->cmdindex]; + } addr64 = (__u64) sg_dma_address(sg); len = sg_dma_len(sg); - cp->SG[i].Addr.lower = - (__u32) (addr64 & (__u64) 0x00000000FFFFFFFF); - cp->SG[i].Addr.upper = - (__u32) ((addr64 >> 32) & (__u64) 0x00000000FFFFFFFF); - cp->SG[i].Len = len; - cp->SG[i].Ext = 0; // we are not chaining + curr_sg[sg_index].Addr.lower = + (__u32) (addr64 & 0x0FFFFFFFFULL); + curr_sg[sg_index].Addr.upper = + (__u32) ((addr64 >> 32) & 0x0FFFFFFFFULL); + curr_sg[sg_index].Len = len; + curr_sg[sg_index].Ext = 0; + ++sg_index; } + if (chained) + cciss_map_sg_chain_block(h, cp, + sa->cmd_sg_list[cp->cmdindex], + (request_nsgs - (h->max_cmd_sgentries - 1)) * + sizeof(SGDescriptor_struct)); } - - cp->Header.SGList = (__u8) use_sg; /* no. SGs contig in this cmd */ - cp->Header.SGTotal = (__u16) use_sg; /* total sgs in this cmd list */ + /* track how many SG entries we are using */ + if (request_nsgs > h->maxSG) + h->maxSG = request_nsgs; + cp->Header.SGTotal = (__u8) request_nsgs + chained; + if (request_nsgs > h->max_cmd_sgentries) + cp->Header.SGList = h->max_cmd_sgentries; + else + cp->Header.SGList = cp->Header.SGTotal; return; } @@ -1490,7 +1523,7 @@ cciss_scsi_queue_command (struct scsi_cmnd *cmd, void (* done)(struct scsi_cmnd BUG(); break; } - cciss_scatter_gather(c->pdev, cp, cmd); + cciss_scatter_gather(c, cp, cmd); /* Put the request on the tail of the request queue */ -- cgit v1.1 From 91f63d0efa1b2ff3f8773aad61c2970f097232aa Mon Sep 17 00:00:00 2001 From: Stephen Rothwell Date: Mon, 1 Mar 2010 19:21:01 +1100 Subject: block: fix for "Consolidate phys_segment and hw_segment limits" Signed-off-by: Stephen Rothwell Signed-off-by: Jens Axboe --- drivers/block/ps3vram.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/block') diff --git a/drivers/block/ps3vram.c b/drivers/block/ps3vram.c index 83ebb39..e446082 100644 --- a/drivers/block/ps3vram.c +++ b/drivers/block/ps3vram.c @@ -751,7 +751,7 @@ static int __devinit ps3vram_probe(struct ps3_system_bus_device *dev) priv->queue = queue; queue->queuedata = dev; blk_queue_make_request(queue, ps3vram_make_request); - blk_queue_max_segments(queue, BLK_MAX_HW_SEGMENTS); + blk_queue_max_segments(queue, BLK_MAX_SEGMENTS); blk_queue_max_segment_size(queue, BLK_MAX_SEGMENT_SIZE); blk_queue_max_hw_sectors(queue, BLK_SAFE_MAX_SECTORS); -- cgit v1.1