linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/7] cciss: updates as of March 11, 2011
@ 2011-03-11 20:55 Stephen M. Cameron
  2011-03-11 20:55 ` [PATCH 1/7] cciss: hoist tag masking out of loop Stephen M. Cameron
                   ` (7 more replies)
  0 siblings, 8 replies; 10+ messages in thread
From: Stephen M. Cameron @ 2011-03-11 20:55 UTC (permalink / raw)
  To: axboe; +Cc: mikem, akpm, thenzl, linux-kernel, smcameron

The following series is vs. Jens Axboe's for-2.6.39/drivers branch. 

---

Stephen M. Cameron (7):
      cciss: hoist tag masking out of loop
      cciss: Inform controller we are using 32-bit tags.
      cciss: Mask off error bits of c->busaddr in cmd_special_free when calling pci_free_consistent
      cciss: remove unnecessary casts
      cciss: fix missed command status value CMD_UNABORTABLE
      cciss: add cciss_tape_cmds module paramter
      cciss: export resettable host attribute


 .../ABI/testing/sysfs-bus-pci-devices-cciss        |   11 ++
 Documentation/blockdev/cciss.txt                   |   15 +++
 drivers/block/cciss.c                              |   97 ++++++++++++++++----
 drivers/block/cciss_cmd.h                          |    1 
 drivers/block/cciss_scsi.c                         |   54 +++++++----
 drivers/block/cciss_scsi.h                         |    4 -
 6 files changed, 140 insertions(+), 42 deletions(-)

-- 
-- steve

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

* [PATCH 1/7] cciss: hoist tag masking out of loop
  2011-03-11 20:55 [PATCH 0/7] cciss: updates as of March 11, 2011 Stephen M. Cameron
@ 2011-03-11 20:55 ` Stephen M. Cameron
  2011-03-11 20:55 ` [PATCH 2/7] cciss: Inform controller we are using 32-bit tags Stephen M. Cameron
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 10+ messages in thread
From: Stephen M. Cameron @ 2011-03-11 20:55 UTC (permalink / raw)
  To: axboe; +Cc: mikem, akpm, thenzl, linux-kernel, smcameron

From: Stephen M. Cameron <scameron@beardog.cce.hp.com>

In process_nonindexed_cmd, hoist figuring of masked tag out of loop since
it is the same throughout.

Signed-off-by: Stephen M. Cameron <scameron@beardog.cce.hp.com>
---
 drivers/block/cciss.c |    4 +---
 1 files changed, 1 insertions(+), 3 deletions(-)

diff --git a/drivers/block/cciss.c b/drivers/block/cciss.c
index 35658f4..8c88944 100644
--- a/drivers/block/cciss.c
+++ b/drivers/block/cciss.c
@@ -3394,14 +3394,12 @@ static inline u32 process_indexed_cmd(ctlr_info_t *h, u32 raw_tag)
 /* process completion of a non-indexed command */
 static inline u32 process_nonindexed_cmd(ctlr_info_t *h, u32 raw_tag)
 {
-	u32 tag;
 	CommandList_struct *c = NULL;
 	__u32 busaddr_masked, tag_masked;
 
-	tag = cciss_tag_discard_error_bits(raw_tag);
+	tag_masked = cciss_tag_discard_error_bits(raw_tag);
 	list_for_each_entry(c, &h->cmpQ, list) {
 		busaddr_masked = cciss_tag_discard_error_bits(c->busaddr);
-		tag_masked = cciss_tag_discard_error_bits(tag);
 		if (busaddr_masked == tag_masked) {
 			finish_cmd(h, c, raw_tag);
 			return next_command(h);


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

* [PATCH 2/7] cciss: Inform controller we are using 32-bit tags.
  2011-03-11 20:55 [PATCH 0/7] cciss: updates as of March 11, 2011 Stephen M. Cameron
  2011-03-11 20:55 ` [PATCH 1/7] cciss: hoist tag masking out of loop Stephen M. Cameron
@ 2011-03-11 20:55 ` Stephen M. Cameron
  2011-03-11 20:55 ` [PATCH 3/7] cciss: Mask off error bits of c->busaddr in cmd_special_free when calling pci_free_consistent Stephen M. Cameron
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 10+ messages in thread
From: Stephen M. Cameron @ 2011-03-11 20:55 UTC (permalink / raw)
  To: axboe; +Cc: mikem, akpm, thenzl, linux-kernel, smcameron

From: Stephen M. Cameron <scameron@beardog.cce.hp.com>

Controller will DMA only 32-bits of the tag per command
on completion if it knows we are only using 32-bit tags.

Signed-off-by: Stephen M. Cameron <scameron@beardog.cce.hp.com>
---
 drivers/block/cciss.c     |   25 +++++++++++++++----------
 drivers/block/cciss_cmd.h |    1 +
 2 files changed, 16 insertions(+), 10 deletions(-)

diff --git a/drivers/block/cciss.c b/drivers/block/cciss.c
index 8c88944..66363f0 100644
--- a/drivers/block/cciss.c
+++ b/drivers/block/cciss.c
@@ -231,7 +231,7 @@ static const struct block_device_operations cciss_fops = {
  */
 static void set_performant_mode(ctlr_info_t *h, CommandList_struct *c)
 {
-	if (likely(h->transMethod == CFGTBL_Trans_Performant))
+	if (likely(h->transMethod & CFGTBL_Trans_Performant))
 		c->busaddr |= 1 | (h->blockFetchTable[c->Header.SGList] << 1);
 }
 
@@ -3136,10 +3136,13 @@ static inline u32 cciss_tag_to_index(u32 tag)
 	return tag >> DIRECT_LOOKUP_SHIFT;
 }
 
-static inline u32 cciss_tag_discard_error_bits(u32 tag)
+static inline u32 cciss_tag_discard_error_bits(ctlr_info_t *h, u32 tag)
 {
-#define CCISS_ERROR_BITS 0x03
-	return tag & ~CCISS_ERROR_BITS;
+#define CCISS_PERF_ERROR_BITS ((1 << DIRECT_LOOKUP_SHIFT) - 1)
+#define CCISS_SIMPLE_ERROR_BITS 0x03
+	if (likely(h->transMethod & CFGTBL_Trans_Performant))
+		return tag & ~CCISS_PERF_ERROR_BITS;
+	return tag & ~CCISS_SIMPLE_ERROR_BITS;
 }
 
 static inline void cciss_mark_tag_indexed(u32 *tag)
@@ -3359,7 +3362,7 @@ static inline u32 next_command(ctlr_info_t *h)
 {
 	u32 a;
 
-	if (unlikely(h->transMethod != CFGTBL_Trans_Performant))
+	if (unlikely(!(h->transMethod & CFGTBL_Trans_Performant)))
 		return h->access.command_completed(h);
 
 	if ((*(h->reply_pool_head) & 1) == (h->reply_pool_wraparound)) {
@@ -3397,9 +3400,9 @@ static inline u32 process_nonindexed_cmd(ctlr_info_t *h, u32 raw_tag)
 	CommandList_struct *c = NULL;
 	__u32 busaddr_masked, tag_masked;
 
-	tag_masked = cciss_tag_discard_error_bits(raw_tag);
+	tag_masked = cciss_tag_discard_error_bits(h, raw_tag);
 	list_for_each_entry(c, &h->cmpQ, list) {
-		busaddr_masked = cciss_tag_discard_error_bits(c->busaddr);
+		busaddr_masked = cciss_tag_discard_error_bits(h, c->busaddr);
 		if (busaddr_masked == tag_masked) {
 			finish_cmd(h, c, raw_tag);
 			return next_command(h);
@@ -3751,7 +3754,8 @@ static void __devinit cciss_wait_for_mode_change_ack(ctlr_info_t *h)
 	}
 }
 
-static __devinit void cciss_enter_performant_mode(ctlr_info_t *h)
+static __devinit void cciss_enter_performant_mode(ctlr_info_t *h,
+	u32 use_short_tags)
 {
 	/* This is a bit complicated.  There are 8 registers on
 	 * the controller which we write to to tell it 8 different
@@ -3806,7 +3810,7 @@ static __devinit void cciss_enter_performant_mode(ctlr_info_t *h)
 	writel(0, &h->transtable->RepQCtrAddrHigh32);
 	writel(h->reply_pool_dhandle, &h->transtable->RepQAddr0Low32);
 	writel(0, &h->transtable->RepQAddr0High32);
-	writel(CFGTBL_Trans_Performant,
+	writel(CFGTBL_Trans_Performant | use_short_tags,
 			&(h->cfgtable->HostWrite.TransportRequest));
 
 	writel(CFGTBL_ChangeReq, h->vaddr + SA5_DOORBELL);
@@ -3853,7 +3857,8 @@ static void __devinit cciss_put_controller_into_performant_mode(ctlr_info_t *h)
 	if ((h->reply_pool == NULL) || (h->blockFetchTable == NULL))
 		goto clean_up;
 
-	cciss_enter_performant_mode(h);
+	cciss_enter_performant_mode(h,
+		trans_support & CFGTBL_Trans_use_short_tags);
 
 	/* Change the access methods to the performant access methods */
 	h->access = SA5_performant_access;
diff --git a/drivers/block/cciss_cmd.h b/drivers/block/cciss_cmd.h
index 35463d2..cd441be 100644
--- a/drivers/block/cciss_cmd.h
+++ b/drivers/block/cciss_cmd.h
@@ -56,6 +56,7 @@
 
 #define CFGTBL_Trans_Simple     0x00000002l
 #define CFGTBL_Trans_Performant 0x00000004l
+#define CFGTBL_Trans_use_short_tags 0x20000000l
 
 #define CFGTBL_BusType_Ultra2   0x00000001l
 #define CFGTBL_BusType_Ultra3   0x00000002l


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

* [PATCH 3/7] cciss: Mask off error bits of c->busaddr in cmd_special_free when calling pci_free_consistent
  2011-03-11 20:55 [PATCH 0/7] cciss: updates as of March 11, 2011 Stephen M. Cameron
  2011-03-11 20:55 ` [PATCH 1/7] cciss: hoist tag masking out of loop Stephen M. Cameron
  2011-03-11 20:55 ` [PATCH 2/7] cciss: Inform controller we are using 32-bit tags Stephen M. Cameron
@ 2011-03-11 20:55 ` Stephen M. Cameron
  2011-03-11 20:55 ` [PATCH 4/7] cciss: remove unnecessary casts Stephen M. Cameron
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 10+ messages in thread
From: Stephen M. Cameron @ 2011-03-11 20:55 UTC (permalink / raw)
  To: axboe; +Cc: mikem, akpm, thenzl, linux-kernel, smcameron

From: Stephen M. Cameron <scameron@beardog.cce.hp.com>

Signed-off-by: Stephen M. Cameron <scameron@beardog.cce.hp.com>
---
 drivers/block/cciss.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/block/cciss.c b/drivers/block/cciss.c
index 66363f0..92bf364 100644
--- a/drivers/block/cciss.c
+++ b/drivers/block/cciss.c
@@ -193,7 +193,7 @@ static int __devinit cciss_find_cfg_addrs(struct pci_dev *pdev,
 	u64 *cfg_offset);
 static int __devinit cciss_pci_find_memory_BAR(struct pci_dev *pdev,
 	unsigned long *memory_bar);
-
+static inline u32 cciss_tag_discard_error_bits(ctlr_info_t *h, u32 tag);
 
 /* performant mode helper functions */
 static void  calc_bucket_map(int *bucket, int num_buckets, int nsgs,
@@ -973,8 +973,8 @@ static void cmd_special_free(ctlr_info_t *h, CommandList_struct *c)
 	temp64.val32.upper = c->ErrDesc.Addr.upper;
 	pci_free_consistent(h->pdev, sizeof(ErrorInfo_struct),
 			    c->err_info, (dma_addr_t) temp64.val);
-	pci_free_consistent(h->pdev, sizeof(CommandList_struct),
-			    c, (dma_addr_t) c->busaddr);
+	pci_free_consistent(h->pdev, sizeof(CommandList_struct), c,
+		(dma_addr_t) cciss_tag_discard_error_bits(h, (u32) c->busaddr));
 }
 
 static inline ctlr_info_t *get_host(struct gendisk *disk)


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

* [PATCH 4/7] cciss: remove unnecessary casts
  2011-03-11 20:55 [PATCH 0/7] cciss: updates as of March 11, 2011 Stephen M. Cameron
                   ` (2 preceding siblings ...)
  2011-03-11 20:55 ` [PATCH 3/7] cciss: Mask off error bits of c->busaddr in cmd_special_free when calling pci_free_consistent Stephen M. Cameron
@ 2011-03-11 20:55 ` Stephen M. Cameron
  2011-03-11 20:55 ` [PATCH 5/7] cciss: fix missed command status value CMD_UNABORTABLE Stephen M. Cameron
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 10+ messages in thread
From: Stephen M. Cameron @ 2011-03-11 20:55 UTC (permalink / raw)
  To: axboe; +Cc: mikem, akpm, thenzl, linux-kernel, smcameron

From: Stephen M. Cameron <scameron@beardog.cce.hp.com>

Signed-off-by: Stephen M. Cameron <scameron@beardog.cce.hp.com>
---
 drivers/block/cciss.c |    3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)

diff --git a/drivers/block/cciss.c b/drivers/block/cciss.c
index 92bf364..619b7c0 100644
--- a/drivers/block/cciss.c
+++ b/drivers/block/cciss.c
@@ -1490,8 +1490,7 @@ static int cciss_bigpassthru(ctlr_info_t *h, void __user *argp)
 		return -EINVAL;
 	if (!capable(CAP_SYS_RAWIO))
 		return -EPERM;
-	ioc = (BIG_IOCTL_Command_struct *)
-	    kmalloc(sizeof(*ioc), GFP_KERNEL);
+	ioc = kmalloc(sizeof(*ioc), GFP_KERNEL);
 	if (!ioc) {
 		status = -ENOMEM;
 		goto cleanup1;


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

* [PATCH 5/7] cciss: fix missed command status value CMD_UNABORTABLE
  2011-03-11 20:55 [PATCH 0/7] cciss: updates as of March 11, 2011 Stephen M. Cameron
                   ` (3 preceding siblings ...)
  2011-03-11 20:55 ` [PATCH 4/7] cciss: remove unnecessary casts Stephen M. Cameron
@ 2011-03-11 20:55 ` Stephen M. Cameron
  2011-03-11 20:56 ` [PATCH 6/7] cciss: add cciss_tape_cmds module paramter Stephen M. Cameron
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 10+ messages in thread
From: Stephen M. Cameron @ 2011-03-11 20:55 UTC (permalink / raw)
  To: axboe; +Cc: mikem, akpm, thenzl, linux-kernel, smcameron

From: Stephen M. Cameron <scameron@beardog.cce.hp.com>

and fix a nearby typo, "do" that should have been "due"

Signed-off-by: Stephen M. Cameron <scameron@beardog.cce.hp.com>
---
 drivers/block/cciss.c      |   11 +++++++++++
 drivers/block/cciss_scsi.c |   13 +++++++++++--
 2 files changed, 22 insertions(+), 2 deletions(-)

diff --git a/drivers/block/cciss.c b/drivers/block/cciss.c
index 619b7c0..6d2464e 100644
--- a/drivers/block/cciss.c
+++ b/drivers/block/cciss.c
@@ -2652,6 +2652,10 @@ static int process_sendcmd_error(ctlr_info_t *h, CommandList_struct *c)
 			c->Request.CDB[0]);
 		return_status = IO_NEEDS_RETRY;
 		break;
+	case CMD_UNABORTABLE:
+		dev_warn(&h->pdev->dev, "cmd unabortable\n");
+		return_status = IO_ERROR;
+		break;
 	default:
 		dev_warn(&h->pdev->dev, "cmd 0x%02x returned "
 		       "unknown status %x\n", c->Request.CDB[0],
@@ -3102,6 +3106,13 @@ static inline void complete_command(ctlr_info_t *h, CommandList_struct *cmd,
 			(cmd->rq->cmd_type == REQ_TYPE_BLOCK_PC) ?
 				DID_PASSTHROUGH : DID_ERROR);
 		break;
+	case CMD_UNABORTABLE:
+		dev_warn(&h->pdev->dev, "cmd %p unabortable\n", cmd);
+		rq->errors = make_status_bytes(SAM_STAT_GOOD,
+			cmd->err_info->CommandStatus, DRIVER_OK,
+			cmd->rq->cmd_type == REQ_TYPE_BLOCK_PC ?
+				DID_PASSTHROUGH : DID_ERROR);
+		break;
 	default:
 		dev_warn(&h->pdev->dev, "cmd %p returned "
 		       "unknown status %x\n", cmd,
diff --git a/drivers/block/cciss_scsi.c b/drivers/block/cciss_scsi.c
index 727d022..df79380 100644
--- a/drivers/block/cciss_scsi.c
+++ b/drivers/block/cciss_scsi.c
@@ -824,13 +824,18 @@ static void complete_scsi_command(CommandList_struct *c, int timeout,
 			break;
 			case CMD_UNSOLICITED_ABORT:
 				cmd->result = DID_ABORT << 16;
-				dev_warn(&h->pdev->dev, "%p aborted do to an "
+				dev_warn(&h->pdev->dev, "%p aborted due to an "
 					"unsolicited abort\n", c);
 			break;
 			case CMD_TIMEOUT:
 				cmd->result = DID_TIME_OUT << 16;
 				dev_warn(&h->pdev->dev, "%p timedout\n", c);
 			break;
+			case CMD_UNABORTABLE:
+				cmd->result = DID_ERROR << 16;
+				dev_warn(&h->pdev->dev, "c %p command "
+					"unabortable\n", c);
+			break;
 			default:
 				cmd->result = DID_ERROR << 16;
 				dev_warn(&h->pdev->dev,
@@ -1007,11 +1012,15 @@ cciss_scsi_interpret_error(ctlr_info_t *h, CommandList_struct *c)
 		break;
 		case CMD_UNSOLICITED_ABORT:
 			dev_warn(&h->pdev->dev,
-				"%p aborted do to an unsolicited abort\n", c);
+				"%p aborted due to an unsolicited abort\n", c);
 		break;
 		case CMD_TIMEOUT:
 			dev_warn(&h->pdev->dev, "%p timedout\n", c);
 		break;
+		case CMD_UNABORTABLE:
+			dev_warn(&h->pdev->dev,
+				"%p unabortable\n", c);
+		break;
 		default:
 			dev_warn(&h->pdev->dev,
 				"%p returned unknown status %x\n",


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

* [PATCH 6/7] cciss: add cciss_tape_cmds module paramter
  2011-03-11 20:55 [PATCH 0/7] cciss: updates as of March 11, 2011 Stephen M. Cameron
                   ` (4 preceding siblings ...)
  2011-03-11 20:55 ` [PATCH 5/7] cciss: fix missed command status value CMD_UNABORTABLE Stephen M. Cameron
@ 2011-03-11 20:56 ` Stephen M. Cameron
  2011-03-11 20:56 ` [PATCH 7/7] cciss: export resettable host attribute Stephen M. Cameron
  2011-03-12  9:03 ` [PATCH 0/7] cciss: updates as of March 11, 2011 Jens Axboe
  7 siblings, 0 replies; 10+ messages in thread
From: Stephen M. Cameron @ 2011-03-11 20:56 UTC (permalink / raw)
  To: axboe; +Cc: mikem, akpm, thenzl, linux-kernel, smcameron

From: Stephen M. Cameron <scameron@beardog.cce.hp.com>

This is to allow number of commands reserved for use by SCSI tape drives
and medium changers to be adjusted at driver load time via the kernel
parameter cciss_tape_cmds, with a default value of 6, and a range
of 2 - 16 inclusive.  Previously, the driver limited the number of
commands which could be queued to the SCSI half of the the driver
to only 2.  This is to fix the problem that if you had more than
two tape drives, you couldn't, for example, erase or rewind them all
at the same time.

Signed-off-by: Stephen M. Cameron <scameron@beardog.cce.hp.com>
---
 Documentation/blockdev/cciss.txt |   15 ++++++++++++++
 drivers/block/cciss.c            |   11 +++++++++-
 drivers/block/cciss_scsi.c       |   41 +++++++++++++++++++++-----------------
 drivers/block/cciss_scsi.h       |    4 ----
 4 files changed, 48 insertions(+), 23 deletions(-)

diff --git a/Documentation/blockdev/cciss.txt b/Documentation/blockdev/cciss.txt
index 89698e8..c00c6a5 100644
--- a/Documentation/blockdev/cciss.txt
+++ b/Documentation/blockdev/cciss.txt
@@ -169,3 +169,18 @@ is issued which positions the tape to a known position.  Typically you
 must rewind the tape (by issuing "mt -f /dev/st0 rewind" for example)
 before i/o can proceed again to a tape drive which was reset.
 
+There is a cciss_tape_cmds module parameter which can be used to make cciss
+allocate more commands for use by tape drives.  Ordinarily only a few commands
+(6) are allocated for tape drives because tape drives are slow and
+infrequently used and the primary purpose of Smart Array controllers is to
+act as a RAID controller for disk drives, so the vast majority of commands
+are allocated for disk devices.  However, if you have more than a few tape
+drives attached to a smart array, the default number of commands may not be
+enought (for example, if you have 8 tape drives, you could only rewind 6
+at one time with the default number of commands.)  The cciss_tape_cmds module
+parameter allows more commands (up to 16 more) to be allocated for use by
+tape drives.  For example:
+
+        insmod cciss.ko cciss_tape_cmds=16
+
+Or, as a kernel boot parameter passed in via grub:  cciss.cciss_tape_cmds=8
diff --git a/drivers/block/cciss.c b/drivers/block/cciss.c
index 6d2464e..0cc089a 100644
--- a/drivers/block/cciss.c
+++ b/drivers/block/cciss.c
@@ -64,6 +64,10 @@ MODULE_DESCRIPTION("Driver for HP Smart Array Controllers");
 MODULE_SUPPORTED_DEVICE("HP Smart Array Controllers");
 MODULE_VERSION("3.6.26");
 MODULE_LICENSE("GPL");
+static int cciss_tape_cmds = 6;
+module_param(cciss_tape_cmds, int, 0644);
+MODULE_PARM_DESC(cciss_tape_cmds,
+	"number of commands to allocate for tape devices (default: 6)");
 
 static DEFINE_MUTEX(cciss_mutex);
 static struct proc_dir_entry *proc_cciss;
@@ -4073,7 +4077,7 @@ static void __devinit cciss_get_max_perf_mode_cmds(struct ctlr_info *h)
 static void __devinit cciss_find_board_params(ctlr_info_t *h)
 {
 	cciss_get_max_perf_mode_cmds(h);
-	h->nr_cmds = h->max_commands - 4; /* Allow room for some ioctls */
+	h->nr_cmds = h->max_commands - 4 - cciss_tape_cmds;
 	h->maxsgentries = readl(&(h->cfgtable->MaxSGElements));
 	/*
 	 * Limit in-command s/g elements to 32 save dma'able memory.
@@ -4588,6 +4592,11 @@ static int __devinit cciss_init_one(struct pci_dev *pdev,
 	sprintf(h->devname, "cciss%d", i);
 	h->ctlr = i;
 
+	if (cciss_tape_cmds < 2)
+		cciss_tape_cmds = 2;
+	if (cciss_tape_cmds > 16)
+		cciss_tape_cmds = 16;
+
 	init_completion(&h->scan_wait);
 
 	if (cciss_create_hba_sysfs_entry(h))
diff --git a/drivers/block/cciss_scsi.c b/drivers/block/cciss_scsi.c
index df79380..6961002 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 = {
 	.proc_name		= "cciss",
 	.proc_info		= cciss_scsi_proc_info,
 	.queuecommand		= cciss_scsi_queue_command,
-	.can_queue		= SCSI_CCISS_CAN_QUEUE,
 	.this_id		= 7,
 	.cmd_per_lun		= 1,
 	.use_clustering		= DISABLE_CLUSTERING,
@@ -108,16 +107,13 @@ struct cciss_scsi_cmd_stack_elem_t {
 
 #pragma pack()
 
-#define CMD_STACK_SIZE (SCSI_CCISS_CAN_QUEUE * \
-		CCISS_MAX_SCSI_DEVS_PER_HBA + 2)
-			// plus two for init time usage
-
 #pragma pack(1)
 struct cciss_scsi_cmd_stack_t {
 	struct cciss_scsi_cmd_stack_elem_t *pool;
-	struct cciss_scsi_cmd_stack_elem_t *elem[CMD_STACK_SIZE];
+	struct cciss_scsi_cmd_stack_elem_t **elem;
 	dma_addr_t cmd_pool_handle;
 	int top;
+	int nelems;
 };
 #pragma pack()
 
@@ -191,7 +187,7 @@ scsi_cmd_free(ctlr_info_t *h, CommandList_struct *c)
 	sa = h->scsi_ctlr;
 	stk = &sa->cmd_stack; 
 	stk->top++;
-	if (stk->top >= CMD_STACK_SIZE) {
+	if (stk->top >= stk->nelems) {
 		dev_err(&h->pdev->dev,
 			"scsi_cmd_free called too many times.\n");
 		BUG();
@@ -206,13 +202,14 @@ scsi_cmd_stack_setup(ctlr_info_t *h, struct cciss_scsi_adapter_data_t *sa)
 	struct cciss_scsi_cmd_stack_t *stk;
 	size_t size;
 
+	stk = &sa->cmd_stack;
+	stk->nelems = cciss_tape_cmds + 2;
 	sa->cmd_sg_list = cciss_allocate_sg_chain_blocks(h,
-		h->chainsize, CMD_STACK_SIZE);
+		h->chainsize, stk->nelems);
 	if (!sa->cmd_sg_list && h->chainsize > 0)
 		return -ENOMEM;
 
-	stk = &sa->cmd_stack; 
-	size = sizeof(struct cciss_scsi_cmd_stack_elem_t) * CMD_STACK_SIZE;
+	size = sizeof(struct cciss_scsi_cmd_stack_elem_t) * stk->nelems;
 
 	/* Check alignment, see cciss_cmd.h near CommandList_struct def. */
 	BUILD_BUG_ON((sizeof(*stk->pool) % COMMANDLIST_ALIGNMENT) != 0);
@@ -221,18 +218,23 @@ scsi_cmd_stack_setup(ctlr_info_t *h, struct cciss_scsi_adapter_data_t *sa)
 		pci_alloc_consistent(h->pdev, size, &stk->cmd_pool_handle);
 
 	if (stk->pool == NULL) {
-		cciss_free_sg_chain_blocks(sa->cmd_sg_list, CMD_STACK_SIZE);
+		cciss_free_sg_chain_blocks(sa->cmd_sg_list, stk->nelems);
 		sa->cmd_sg_list = NULL;
 		return -ENOMEM;
 	}
-
-	for (i=0; i<CMD_STACK_SIZE; i++) {
+	stk->elem = kmalloc(sizeof(stk->elem[0]) * stk->nelems, GFP_KERNEL);
+	if (!stk->elem) {
+		pci_free_consistent(h->pdev, size, stk->pool,
+		stk->cmd_pool_handle);
+		return -1;
+	}
+	for (i = 0; i < stk->nelems; i++) {
 		stk->elem[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;
+	stk->top = stk->nelems-1;
 	return 0;
 }
 
@@ -245,16 +247,18 @@ scsi_cmd_stack_free(ctlr_info_t *h)
 
 	sa = h->scsi_ctlr;
 	stk = &sa->cmd_stack; 
-	if (stk->top != CMD_STACK_SIZE-1) {
+	if (stk->top != stk->nelems-1) {
 		dev_warn(&h->pdev->dev,
 			"bug: %d scsi commands are still outstanding.\n",
-			CMD_STACK_SIZE - stk->top);
+			stk->nelems - stk->top);
 	}
-	size = sizeof(struct cciss_scsi_cmd_stack_elem_t) * CMD_STACK_SIZE;
+	size = sizeof(struct cciss_scsi_cmd_stack_elem_t) * stk->nelems;
 
 	pci_free_consistent(h->pdev, size, stk->pool, stk->cmd_pool_handle);
 	stk->pool = NULL;
-	cciss_free_sg_chain_blocks(sa->cmd_sg_list, CMD_STACK_SIZE);
+	cciss_free_sg_chain_blocks(sa->cmd_sg_list, stk->nelems);
+	kfree(stk->elem);
+	stk->elem = NULL;
 }
 
 #if 0
@@ -859,6 +863,7 @@ cciss_scsi_detect(ctlr_info_t *h)
 	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->can_queue = cciss_tape_cmds;
 	sh->sg_tablesize = h->maxsgentries;
 	sh->max_cmd_len = MAX_COMMAND_SIZE;
 
diff --git a/drivers/block/cciss_scsi.h b/drivers/block/cciss_scsi.h
index 6d5822f..e71d986 100644
--- a/drivers/block/cciss_scsi.h
+++ b/drivers/block/cciss_scsi.h
@@ -36,13 +36,9 @@
 		   addressible natively, and may in fact turn
 		   out to be not scsi at all. */
 
-#define SCSI_CCISS_CAN_QUEUE 2
 
 /* 
 
-Note, cmd_per_lun could give us some trouble, so I'm setting it very low.
-Likewise, SCSI_CCISS_CAN_QUEUE is set very conservatively.
-
 If the upper scsi layer tries to track how many commands we have 
 outstanding, it will be operating under the misapprehension that it is
 the only one sending us requests.  We also have the block interface,


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

* [PATCH 7/7] cciss: export resettable host attribute
  2011-03-11 20:55 [PATCH 0/7] cciss: updates as of March 11, 2011 Stephen M. Cameron
                   ` (5 preceding siblings ...)
  2011-03-11 20:56 ` [PATCH 6/7] cciss: add cciss_tape_cmds module paramter Stephen M. Cameron
@ 2011-03-11 20:56 ` Stephen M. Cameron
  2011-03-12  9:03 ` [PATCH 0/7] cciss: updates as of March 11, 2011 Jens Axboe
  7 siblings, 0 replies; 10+ messages in thread
From: Stephen M. Cameron @ 2011-03-11 20:56 UTC (permalink / raw)
  To: axboe; +Cc: mikem, akpm, thenzl, linux-kernel, smcameron

From: Stephen M. Cameron <scameron@beardog.cce.hp.com>

This attribute, requested by Redhat, allows kexec-tools to know
whether the controller can honor the reset_devices kernel parameter
and actually reset the controller.  For kdump to work properly it
is necessary that the reset_devices parameter be honored.  This
attribute enables kexec-tools to warn the user if they attempt to
designate a non-resettable controller as the dump device.

Signed-off-by: Stephen M. Cameron <scameron@beardog.cce.hp.com>
---
 .../ABI/testing/sysfs-bus-pci-devices-cciss        |   11 ++++++
 drivers/block/cciss.c                              |   39 ++++++++++++++++++++
 2 files changed, 50 insertions(+), 0 deletions(-)

diff --git a/Documentation/ABI/testing/sysfs-bus-pci-devices-cciss b/Documentation/ABI/testing/sysfs-bus-pci-devices-cciss
index 4f29e5f..27efb26 100644
--- a/Documentation/ABI/testing/sysfs-bus-pci-devices-cciss
+++ b/Documentation/ABI/testing/sysfs-bus-pci-devices-cciss
@@ -59,3 +59,14 @@ Kernel Version: 2.6.31
 Contact:	iss_storagedev@hp.com
 Description:	Displays the usage count (number of opens) of logical drive Y
 		of controller X.
+
+Where:		/sys/bus/pci/devices/<dev>/ccissX/resettable
+Date:		February 2011
+Kernel Version:	2.6.38
+Contact:	iss_storagedev@hp.com
+Description:	Value of 1 indicates the controller can honor the reset_devices
+		kernel parameter.  Value of 0 indicates reset_devices cannot be
+		honored.  This is to allow, for example, kexec tools to be able
+		to warn the user if they designate an unresettable device as
+		a dump device, as kdump requires resetting the device in order
+		to work reliably.
diff --git a/drivers/block/cciss.c b/drivers/block/cciss.c
index 0cc089a..3798961 100644
--- a/drivers/block/cciss.c
+++ b/drivers/block/cciss.c
@@ -560,6 +560,44 @@ static void __devinit cciss_procinit(ctlr_info_t *h)
 #define to_hba(n) container_of(n, struct ctlr_info, dev)
 #define to_drv(n) container_of(n, drive_info_struct, dev)
 
+/* List of controllers which cannot be reset on kexec with reset_devices */
+static u32 unresettable_controller[] = {
+	0x324a103C, /* Smart Array P712m */
+	0x324b103C, /* SmartArray P711m */
+	0x3223103C, /* Smart Array P800 */
+	0x3234103C, /* Smart Array P400 */
+	0x3235103C, /* Smart Array P400i */
+	0x3211103C, /* Smart Array E200i */
+	0x3212103C, /* Smart Array E200 */
+	0x3213103C, /* Smart Array E200i */
+	0x3214103C, /* Smart Array E200i */
+	0x3215103C, /* Smart Array E200i */
+	0x3237103C, /* Smart Array E500 */
+	0x323D103C, /* Smart Array P700m */
+	0x409C0E11, /* Smart Array 6400 */
+	0x409D0E11, /* Smart Array 6400 EM */
+};
+
+static int ctlr_is_resettable(struct ctlr_info *h)
+{
+	int i;
+
+	for (i = 0; i < ARRAY_SIZE(unresettable_controller); i++)
+		if (unresettable_controller[i] == h->board_id)
+			return 0;
+	return 1;
+}
+
+static ssize_t host_show_resettable(struct device *dev,
+				    struct device_attribute *attr,
+				    char *buf)
+{
+	struct ctlr_info *h = to_hba(dev);
+
+	return snprintf(buf, 20, "%d\n", ctlr_is_resettable(h));
+}
+static DEVICE_ATTR(resettable, S_IRUGO, host_show_resettable, NULL);
+
 static ssize_t host_store_rescan(struct device *dev,
 				 struct device_attribute *attr,
 				 const char *buf, size_t count)
@@ -745,6 +783,7 @@ static DEVICE_ATTR(usage_count, S_IRUGO, cciss_show_usage_count, NULL);
 
 static struct attribute *cciss_host_attrs[] = {
 	&dev_attr_rescan.attr,
+	&dev_attr_resettable.attr,
 	NULL
 };
 


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

* Re: [PATCH 0/7] cciss: updates as of March 11, 2011
  2011-03-11 20:55 [PATCH 0/7] cciss: updates as of March 11, 2011 Stephen M. Cameron
                   ` (6 preceding siblings ...)
  2011-03-11 20:56 ` [PATCH 7/7] cciss: export resettable host attribute Stephen M. Cameron
@ 2011-03-12  9:03 ` Jens Axboe
  2011-03-14 16:37   ` scameron
  7 siblings, 1 reply; 10+ messages in thread
From: Jens Axboe @ 2011-03-12  9:03 UTC (permalink / raw)
  To: Stephen M. Cameron; +Cc: mikem, akpm, thenzl, linux-kernel, smcameron

On 2011-03-11 21:55, Stephen M. Cameron wrote:
> The following series is vs. Jens Axboe's for-2.6.39/drivers branch. 
> 
> ---
> 
> Stephen M. Cameron (7):
>       cciss: hoist tag masking out of loop
>       cciss: Inform controller we are using 32-bit tags.
>       cciss: Mask off error bits of c->busaddr in cmd_special_free when calling pci_free_consistent
>       cciss: remove unnecessary casts
>       cciss: fix missed command status value CMD_UNABORTABLE
>       cciss: add cciss_tape_cmds module paramter
>       cciss: export resettable host attribute

I have applied 1-5/7, 6 and 7 do not apply. Please check
for-2.6.39/drivers and check and resend those last two patches.

-- 
Jens Axboe


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

* Re: [PATCH 0/7] cciss: updates as of March 11, 2011
  2011-03-12  9:03 ` [PATCH 0/7] cciss: updates as of March 11, 2011 Jens Axboe
@ 2011-03-14 16:37   ` scameron
  0 siblings, 0 replies; 10+ messages in thread
From: scameron @ 2011-03-14 16:37 UTC (permalink / raw)
  To: Jens Axboe; +Cc: mikem, akpm, thenzl, linux-kernel, smcameron, scameron

On Sat, Mar 12, 2011 at 10:03:34AM +0100, Jens Axboe wrote:
> On 2011-03-11 21:55, Stephen M. Cameron wrote:
> > The following series is vs. Jens Axboe's for-2.6.39/drivers branch. 
> > 
> > ---
> > 
> > Stephen M. Cameron (7):
> >       cciss: hoist tag masking out of loop
> >       cciss: Inform controller we are using 32-bit tags.
> >       cciss: Mask off error bits of c->busaddr in cmd_special_free when calling pci_free_consistent
> >       cciss: remove unnecessary casts
> >       cciss: fix missed command status value CMD_UNABORTABLE
> >       cciss: add cciss_tape_cmds module paramter
> >       cciss: export resettable host attribute
> 
> I have applied 1-5/7, 6 and 7 do not apply. Please check
> for-2.6.39/drivers and check and resend those last two patches.

Ok, I am confused.  Maybe I'm doing something wrong, but
I can't quite spot what it is.

Does this look right?

[scameron@localhost linux-2.6]$ git remote update
Fetching origin
Fetching james
Fetching jens
[scameron@localhost linux-2.6]$ git checkout -b hp-cciss-2011-03-14 jens/for-2.6.39/drivers 
Branch hp-cciss-2011-03-14 set up to track remote branch for-2.6.39/drivers from jens.
Switched to a new branch 'hp-cciss-2011-03-14'

Now I try to apply the patch 6, which I downloadeded from here:
http://marc.info/?l=linux-kernel&m=129987702317844&q=raw
(that is, the same one I mailed out on Friday, which I had to do because stg
has a bug that it won't honor CC to yourself):

[scameron@localhost linux-2.6]$ patch -p1 --dry-run < /tmp/cciss-add-cciss_tape_cmds-module-parameter.patch 
patching file Documentation/blockdev/cciss.txt
patching file drivers/block/cciss.c
Hunk #2 succeeded at 4116 (offset 39 lines).
Hunk #3 succeeded at 4631 (offset 39 lines).
patching file drivers/block/cciss_scsi.c
patching file drivers/block/cciss_scsi.h
patch unexpectedly ends in middle of line

Ok... that's weird.

Well, if I delete this bit at the end (which was not put there by me) which says:
  --
  To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
  the body of a message to majordomo@vger.kernel.org
  More majordomo info at  http://vger.kernel.org/majordomo-info.html
  Please read the FAQ at  http://www.tux.org/lkml/

then it does seem to apply...
 
[scameron@localhost linux-2.6]$ patch -p1 --dry-run < /tmp/cciss-add-cciss_tape_cmds-module-parameter.patch 
patching file Documentation/blockdev/cciss.txt
patching file drivers/block/cciss.c
Hunk #2 succeeded at 4116 (offset 39 lines).
Hunk #3 succeeded at 4631 (offset 39 lines).
patching file drivers/block/cciss_scsi.c
patching file drivers/block/cciss_scsi.h
[scameron@localhost linux-2.6]$

And compiles too...

[scameron@localhost linux-2.6]$ make SUBDIRS=drivers/block modules
  CC [M]  drivers/block/floppy.o
  CC [M]  drivers/block/cciss.o
  CC [M]  drivers/block/pktcdvd.o
...

So not sure why it doesn't apply for you, unless somehow I'm not checking
out your git tree in the right way.

And then git log is showing patch 7 is applied after all?

commit 957c2ec558caff09a3bdf333871fc617830f063d
Author: Stephen M. Cameron <scameron@beardog.cce.hp.com>
Date:   Fri Mar 11 20:06:09 2011 +0100

    cciss: export resettable host attribute

    This attribute, requested by Redhat, allows kexec-tools to know
    whether the controller can honor the reset_devices kernel parameter
    and actually reset the controller.  For kdump to work properly it
    is necessary that the reset_devices parameter be honored.  This
    attribute enables kexec-tools to warn the user if they attempt to
    designate a non-resettable controller as the dump device.

    Signed-off-by: Stephen M. Cameron <scameron@beardog.cce.hp.com>
    Signed-off-by: Jens Axboe <jaxboe@fusionio.com>

Maybe you hand applied it?

-- steve


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

end of thread, other threads:[~2011-03-14 16:37 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-03-11 20:55 [PATCH 0/7] cciss: updates as of March 11, 2011 Stephen M. Cameron
2011-03-11 20:55 ` [PATCH 1/7] cciss: hoist tag masking out of loop Stephen M. Cameron
2011-03-11 20:55 ` [PATCH 2/7] cciss: Inform controller we are using 32-bit tags Stephen M. Cameron
2011-03-11 20:55 ` [PATCH 3/7] cciss: Mask off error bits of c->busaddr in cmd_special_free when calling pci_free_consistent Stephen M. Cameron
2011-03-11 20:55 ` [PATCH 4/7] cciss: remove unnecessary casts Stephen M. Cameron
2011-03-11 20:55 ` [PATCH 5/7] cciss: fix missed command status value CMD_UNABORTABLE Stephen M. Cameron
2011-03-11 20:56 ` [PATCH 6/7] cciss: add cciss_tape_cmds module paramter Stephen M. Cameron
2011-03-11 20:56 ` [PATCH 7/7] cciss: export resettable host attribute Stephen M. Cameron
2011-03-12  9:03 ` [PATCH 0/7] cciss: updates as of March 11, 2011 Jens Axboe
2011-03-14 16:37   ` scameron

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