[PATCH 10/26] cciss: factor out cciss_find_board_params

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Stephen M. Cameron
Date: Monday, July 19, 2010 - 11:45 am

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

cciss: factor out cciss_find_board_params

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

diff --git a/drivers/block/cciss.c b/drivers/block/cciss.c
index b702471..97feb50 100644
--- a/drivers/block/cciss.c
+++ b/drivers/block/cciss.c
@@ -4072,6 +4072,30 @@ static int __devinit cciss_find_cfgtables(ctlr_info_t *h)
 	return 0;
 }
 
+/* Interrogate the hardware for some limits:
+ * max commands, max SG elements without chaining, and with chaining,
+ * SG chain block size, etc.
+ */
+static void __devinit cciss_find_board_params(ctlr_info_t *h)
+{
+	h->max_commands = readl(&(h->cfgtable->MaxPerformantModeCommands));
+	h->nr_cmds = h->max_commands - 4; /* Allow room for some ioctls */
+	h->maxsgentries = readl(&(h->cfgtable->MaxSGElements));
+	/*
+	 * Limit in-command s/g elements to 32 save dma'able memory.
+	 * Howvever spec says if 0, use 31
+	 */
+	h->max_cmd_sgentries = 31;
+	if (h->maxsgentries > 512) {
+		h->max_cmd_sgentries = 32;
+		h->chainsize = h->maxsgentries - h->max_cmd_sgentries + 1;
+		h->maxsgentries--; /* save one for chain pointer */
+	} else {
+		h->maxsgentries = 31; /* default to traditional values */
+		h->chainsize = 0;
+	}
+}
+
 static int __devinit cciss_pci_init(ctlr_info_t *c)
 {
 	int prod_index, err;
@@ -4127,34 +4151,8 @@ static int __devinit cciss_pci_init(ctlr_info_t *c)
 #ifdef CCISS_DEBUG
 	print_cfg_table(c->cfgtable);
 #endif				/* CCISS_DEBUG */
+	cciss_find_board_params(c);
 
-	/* Some controllers support Zero Memory Raid (ZMR).
-	 * When configured in ZMR mode the number of supported
-	 * commands drops to 64. So instead of just setting an
-	 * arbitrary value we make the driver a little smarter.
-	 * We read the config table to tell us how many commands
-	 * are supported on the controller then subtract 4 to
-	 * leave a little room for ioctl calls.
-	 */
-	c->max_commands = readl(&(c->cfgtable->MaxPerformantModeCommands));
-	c->maxsgentries = readl(&(c->cfgtable->MaxSGElements));
-
-	/*
-	 * Limit native command to 32 s/g elements to save dma'able memory.
-	 * Howvever spec says if 0, use 31
-	 */
-
-	c->max_cmd_sgentries = 31;
-	if (c->maxsgentries > 512) {
-		c->max_cmd_sgentries = 32;
-		c->chainsize = c->maxsgentries - c->max_cmd_sgentries + 1;
-		c->maxsgentries -= 1;   /* account for chain pointer */
-	} else {
-		c->maxsgentries = 31;   /* Default to traditional value */
-		c->chainsize = 0;       /* traditional */
-	}
-
-	c->nr_cmds = c->max_commands - 4;
 	if ((readb(&c->cfgtable->Signature[0]) != 'C') ||
 	    (readb(&c->cfgtable->Signature[1]) != 'I') ||
 	    (readb(&c->cfgtable->Signature[2]) != 'S') ||

--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH 00/26] cciss updates July 19, 2010 , Stephen M. Cameron, (Mon Jul 19, 11:44 am)
[PATCH 01/26] cciss: Set the performant mode bit in the sc ..., Stephen M. Cameron, (Mon Jul 19, 11:44 am)
[PATCH 02/26] cciss: save pdev pointer in per hba structur ..., Stephen M. Cameron, (Mon Jul 19, 11:44 am)
[PATCH 03/26] cciss: factor out cciss_lookup_board_id, Stephen M. Cameron, (Mon Jul 19, 11:44 am)
[PATCH 04/26] cciss: factor out cciss_board_disabled, Stephen M. Cameron, (Mon Jul 19, 11:45 am)
[PATCH 05/26] cciss: remove board_id parameter from cciss_ ..., Stephen M. Cameron, (Mon Jul 19, 11:45 am)
[PATCH 06/26] cciss: factor out cciss_find_memory_BAR(), Stephen M. Cameron, (Mon Jul 19, 11:45 am)
[PATCH 07/26] cciss: factor out cciss_wait_for_board_ready(), Stephen M. Cameron, (Mon Jul 19, 11:45 am)
[PATCH 08/26] cciss: factor out cciss_find_cfgtables, Stephen M. Cameron, (Mon Jul 19, 11:45 am)
[PATCH 09/26] cciss: fix leak of ioremapped memory, Stephen M. Cameron, (Mon Jul 19, 11:45 am)
[PATCH 10/26] cciss: factor out cciss_find_board_params, Stephen M. Cameron, (Mon Jul 19, 11:45 am)
[PATCH 11/26] cciss: factor out CISS_signature_present(), Stephen M. Cameron, (Mon Jul 19, 11:45 am)
[PATCH 12/26] cciss: factor out cciss_enable_scsi_prefetch(), Stephen M. Cameron, (Mon Jul 19, 11:45 am)
[PATCH 13/26] cciss: factor out cciss_p600_dma_prefetch_qu ..., Stephen M. Cameron, (Mon Jul 19, 11:45 am)
[PATCH 14/26] cciss: cleanup some debug ifdefs, Stephen M. Cameron, (Mon Jul 19, 11:45 am)
[PATCH 15/26] cciss: make cciss_put_controller_into_perfor ..., Stephen M. Cameron, (Mon Jul 19, 11:45 am)
[PATCH 16/26] cciss: factor out cciss_wait_for_mode_change ..., Stephen M. Cameron, (Mon Jul 19, 11:46 am)
[PATCH 17/26] cciss: factor out cciss_enter_performant_mode, Stephen M. Cameron, (Mon Jul 19, 11:46 am)
[PATCH 18/26] cciss: factor out cciss_find_cfg_addrs., Stephen M. Cameron, (Mon Jul 19, 11:46 am)
[PATCH 19/26] cciss: factor out cciss_reset_devices(), Stephen M. Cameron, (Mon Jul 19, 11:46 am)
[PATCH 20/26] cciss: fix hard reset code., Stephen M. Cameron, (Mon Jul 19, 11:46 am)
[PATCH 21/26] cciss: sanitize max commands, Stephen M. Cameron, (Mon Jul 19, 11:46 am)
[PATCH 22/26] cciss: forbid hard reset of 640x boards, Stephen M. Cameron, (Mon Jul 19, 11:46 am)
[PATCH 23/26] cciss: use consistent variable names, Stephen M. Cameron, (Mon Jul 19, 11:46 am)
[PATCH 24/26] cciss: separate cmd_alloc() and cmd_special_ ..., Stephen M. Cameron, (Mon Jul 19, 11:46 am)
[PATCH 25/26] cciss: change printks to dev_warn, etc., Stephen M. Cameron, (Mon Jul 19, 11:46 am)
[PATCH 26/26] cciss: cleanup interrupt_not_for_us, Stephen M. Cameron, (Mon Jul 19, 11:46 am)
Re: [PATCH 00/26] cciss updates July 19, 2010, Jens Axboe, (Tue Jul 20, 7:05 pm)