linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 01/10] hpsa: fix per device memory leak on driver unload
@ 2012-01-19 20:00 Stephen M. Cameron
  2012-01-19 20:00 ` [PATCH 02/10] hpsa: removed unneeded structure member max_sg_entries and fix badly named constant MAXSGENTRIES Stephen M. Cameron
                   ` (8 more replies)
  0 siblings, 9 replies; 14+ messages in thread
From: Stephen M. Cameron @ 2012-01-19 20:00 UTC (permalink / raw)
  To: james.bottomley
  Cc: linux-scsi, linux-kernel, mikem, stephenmcameron, thenzl,
	scott.teel, akpm, stable

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

Signed-off-by: Stephen M. Cameron <scameron@beardog.cce.hp.com>
---
 drivers/scsi/hpsa.c |    9 +++++++++
 1 files changed, 9 insertions(+), 0 deletions(-)

diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
index 3ecb703..e9b1aa8 100644
--- a/drivers/scsi/hpsa.c
+++ b/drivers/scsi/hpsa.c
@@ -4480,6 +4480,14 @@ static void hpsa_shutdown(struct pci_dev *pdev)
 #endif				/* CONFIG_PCI_MSI */
 }
 
+static void __devexit hpsa_free_device_info(struct ctlr_info *h)
+{
+	int i;
+
+	for (i = 0; i < h->ndevices; i++)
+		kfree(h->dev[i]);
+}
+
 static void __devexit hpsa_remove_one(struct pci_dev *pdev)
 {
 	struct ctlr_info *h;
@@ -4495,6 +4503,7 @@ static void __devexit hpsa_remove_one(struct pci_dev *pdev)
 	iounmap(h->vaddr);
 	iounmap(h->transtable);
 	iounmap(h->cfgtable);
+	hpsa_free_device_info(h);
 	hpsa_free_sg_chain_blocks(h);
 	pci_free_consistent(h->pdev,
 		h->nr_cmds * sizeof(struct CommandList),


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

* [PATCH 02/10] hpsa: removed unneeded structure member max_sg_entries and fix badly named constant MAXSGENTRIES
  2012-01-19 20:00 [PATCH 01/10] hpsa: fix per device memory leak on driver unload Stephen M. Cameron
@ 2012-01-19 20:00 ` Stephen M. Cameron
  2012-01-19 20:00 ` [PATCH 03/10] hpsa: combine hpsa_scsi_detect and hpsa_register_scsi Stephen M. Cameron
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 14+ messages in thread
From: Stephen M. Cameron @ 2012-01-19 20:00 UTC (permalink / raw)
  To: james.bottomley
  Cc: linux-scsi, linux-kernel, mikem, stephenmcameron, thenzl,
	scott.teel, akpm, stable

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

We had both h->max_sg_entries and h->maxsgentries in the per controller
structure which is terribly confusing.  max_sg_entries was really
just a constant, 32, which defines how big the "block fetch table"
is, which is as large as the max number of SG elements embedded
within a command (excluding SG elements in chain blocks).

MAXSGENTRIES was the constant used to denote the max number of SG
elements embedded within a command, also a poor name.

So renamed MAXSGENTREIS to SG_ENTRIES_IN_CMD, and removed
h->max_sg_entries and replaced it with SG_ENTRIES_IN_CMD.

h->maxsgentries is unchanged, and is the maximum number of sg
elements the controller will support in a command, including
those in chain blocks, minus 1 for the chain block pointer..

Signed-off-by: Stephen M. Cameron <scameron@beardog.cce.hp.com>
---
 drivers/scsi/hpsa.c     |   20 ++++++++++----------
 drivers/scsi/hpsa.h     |    1 -
 drivers/scsi/hpsa_cmd.h |    4 ++--
 3 files changed, 12 insertions(+), 13 deletions(-)

diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
index e9b1aa8..d70d59c 100644
--- a/drivers/scsi/hpsa.c
+++ b/drivers/scsi/hpsa.c
@@ -2698,16 +2698,16 @@ static int hpsa_big_passthru_ioctl(struct ctlr_info *h, void __user *argp)
 		status = -EINVAL;
 		goto cleanup1;
 	}
-	if (ioc->buf_size > ioc->malloc_size * MAXSGENTRIES) {
+	if (ioc->buf_size > ioc->malloc_size * SG_ENTRIES_IN_CMD) {
 		status = -EINVAL;
 		goto cleanup1;
 	}
-	buff = kzalloc(MAXSGENTRIES * sizeof(char *), GFP_KERNEL);
+	buff = kzalloc(SG_ENTRIES_IN_CMD * sizeof(char *), GFP_KERNEL);
 	if (!buff) {
 		status = -ENOMEM;
 		goto cleanup1;
 	}
-	buff_size = kmalloc(MAXSGENTRIES * sizeof(int), GFP_KERNEL);
+	buff_size = kmalloc(SG_ENTRIES_IN_CMD * sizeof(int), GFP_KERNEL);
 	if (!buff_size) {
 		status = -ENOMEM;
 		goto cleanup1;
@@ -4599,15 +4599,15 @@ static __devinit void hpsa_enter_performant_mode(struct ctlr_info *h,
 	 * Each SG entry requires 16 bytes.  The eight registers are programmed
 	 * with the number of 16-byte blocks a command of that size requires.
 	 * The smallest command possible requires 5 such 16 byte blocks.
-	 * the largest command possible requires MAXSGENTRIES + 4 16-byte
+	 * the largest command possible requires SG_ENTRIES_IN_CMD + 4 16-byte
 	 * blocks.  Note, this only extends to the SG entries contained
 	 * within the command block, and does not extend to chained blocks
 	 * of SG elements.   bft[] contains the eight values we write to
 	 * the registers.  They are not evenly distributed, but have more
 	 * sizes for small commands, and fewer sizes for larger commands.
 	 */
-	int bft[8] = {5, 6, 8, 10, 12, 20, 28, MAXSGENTRIES + 4};
-	BUILD_BUG_ON(28 > MAXSGENTRIES + 4);
+	int bft[8] = {5, 6, 8, 10, 12, 20, 28, SG_ENTRIES_IN_CMD + 4};
+	BUILD_BUG_ON(28 > SG_ENTRIES_IN_CMD + 4);
 	/*  5 = 1 s/g entry or 4k
 	 *  6 = 2 s/g entry or 8k
 	 *  8 = 4 s/g entry or 16k
@@ -4620,8 +4620,9 @@ static __devinit void hpsa_enter_performant_mode(struct ctlr_info *h,
 	memset(h->reply_pool, 0, h->reply_pool_size);
 	h->reply_pool_head = h->reply_pool;
 
-	bft[7] = h->max_sg_entries + 4;
-	calc_bucket_map(bft, ARRAY_SIZE(bft), 32, h->blockFetchTable);
+	bft[7] = SG_ENTRIES_IN_CMD + 4;
+	calc_bucket_map(bft, ARRAY_SIZE(bft),
+				SG_ENTRIES_IN_CMD, h->blockFetchTable);
 	for (i = 0; i < 8; i++)
 		writel(bft[i], &h->transtable->BlockFetch[i]);
 
@@ -4659,14 +4660,13 @@ static __devinit void hpsa_put_ctlr_into_performant_mode(struct ctlr_info *h)
 		return;
 
 	hpsa_get_max_perf_mode_cmds(h);
-	h->max_sg_entries = 32;
 	/* Performant mode ring buffer and supporting data structures */
 	h->reply_pool_size = h->max_commands * sizeof(u64);
 	h->reply_pool = pci_alloc_consistent(h->pdev, h->reply_pool_size,
 				&(h->reply_pool_dhandle));
 
 	/* Need a block fetch table for performant mode */
-	h->blockFetchTable = kmalloc(((h->max_sg_entries+1) *
+	h->blockFetchTable = kmalloc(((SG_ENTRIES_IN_CMD + 1) *
 				sizeof(u32)), GFP_KERNEL);
 
 	if ((h->reply_pool == NULL)
diff --git a/drivers/scsi/hpsa.h b/drivers/scsi/hpsa.h
index 91edafb..b4b97eb 100644
--- a/drivers/scsi/hpsa.h
+++ b/drivers/scsi/hpsa.h
@@ -58,7 +58,6 @@ struct ctlr_info {
 	unsigned long paddr;
 	int 	nr_cmds; /* Number of commands allowed on this controller */
 	struct CfgTable __iomem *cfgtable;
-	int     max_sg_entries;
 	int	interrupts_enabled;
 	int	major;
 	int 	max_commands;
diff --git a/drivers/scsi/hpsa_cmd.h b/drivers/scsi/hpsa_cmd.h
index 3fd4715..516d6e5 100644
--- a/drivers/scsi/hpsa_cmd.h
+++ b/drivers/scsi/hpsa_cmd.h
@@ -23,7 +23,7 @@
 
 /* general boundary defintions */
 #define SENSEINFOBYTES          32 /* may vary between hbas */
-#define MAXSGENTRIES            32
+#define SG_ENTRIES_IN_CMD	32 /* Max SG entries excluding chain blocks */
 #define HPSA_SG_CHAIN		0x80000000
 #define MAXREPLYQS              256
 
@@ -282,7 +282,7 @@ struct CommandList {
 	struct CommandListHeader Header;
 	struct RequestBlock      Request;
 	struct ErrDescriptor     ErrDesc;
-	struct SGDescriptor      SG[MAXSGENTRIES];
+	struct SGDescriptor      SG[SG_ENTRIES_IN_CMD];
 	/* information associated with the command */
 	u32			   busaddr; /* physical addr of this record */
 	struct ErrorInfo *err_info; /* pointer to the allocated mem */


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

* [PATCH 03/10] hpsa: combine hpsa_scsi_detect and hpsa_register_scsi
  2012-01-19 20:00 [PATCH 01/10] hpsa: fix per device memory leak on driver unload Stephen M. Cameron
  2012-01-19 20:00 ` [PATCH 02/10] hpsa: removed unneeded structure member max_sg_entries and fix badly named constant MAXSGENTRIES Stephen M. Cameron
@ 2012-01-19 20:00 ` Stephen M. Cameron
  2012-01-19 20:00 ` [PATCH 04/10] hpsa: factor out driver name Stephen M. Cameron
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 14+ messages in thread
From: Stephen M. Cameron @ 2012-01-19 20:00 UTC (permalink / raw)
  To: james.bottomley
  Cc: linux-scsi, linux-kernel, mikem, stephenmcameron, thenzl,
	scott.teel, akpm, stable

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

hpsa_register_scsi just calls hpsa_scsi_detect.  Move
the guts of hpsa_scsi_detect into hpsa_register_scsi and
get rid of hpsa_scsi_detect.

Signed-off-by: Stephen M. Cameron <scameron@beardog.cce.hp.com>
---
 drivers/scsi/hpsa.c |   81 ++++++++++++++++++++++-----------------------------
 1 files changed, 35 insertions(+), 46 deletions(-)

diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
index d70d59c..d191e3f 100644
--- a/drivers/scsi/hpsa.c
+++ b/drivers/scsi/hpsa.c
@@ -1255,46 +1255,6 @@ static void complete_scsi_command(struct CommandList *cp)
 	cmd_free(h, cp);
 }
 
-static int hpsa_scsi_detect(struct ctlr_info *h)
-{
-	struct Scsi_Host *sh;
-	int error;
-
-	sh = scsi_host_alloc(&hpsa_driver_template, sizeof(h));
-	if (sh == NULL)
-		goto fail;
-
-	sh->io_port = 0;
-	sh->n_io_port = 0;
-	sh->this_id = -1;
-	sh->max_channel = 3;
-	sh->max_cmd_len = MAX_COMMAND_SIZE;
-	sh->max_lun = HPSA_MAX_LUN;
-	sh->max_id = HPSA_MAX_LUN;
-	sh->can_queue = h->nr_cmds;
-	sh->cmd_per_lun = h->nr_cmds;
-	sh->sg_tablesize = h->maxsgentries;
-	h->scsi_host = sh;
-	sh->hostdata[0] = (unsigned long) h;
-	sh->irq = h->intr[h->intr_mode];
-	sh->unique_id = sh->irq;
-	error = scsi_add_host(sh, &h->pdev->dev);
-	if (error)
-		goto fail_host_put;
-	scsi_scan_host(sh);
-	return 0;
-
- fail_host_put:
-	dev_err(&h->pdev->dev, "hpsa_scsi_detect: scsi_add_host"
-		" failed for controller %d\n", h->ctlr);
-	scsi_host_put(sh);
-	return error;
- fail:
-	dev_err(&h->pdev->dev, "hpsa_scsi_detect: scsi_host_alloc"
-		" failed for controller %d\n", h->ctlr);
-	return -ENOMEM;
-}
-
 static void hpsa_pci_unmap(struct pci_dev *pdev,
 	struct CommandList *c, int sg_used, int data_direction)
 {
@@ -2226,13 +2186,42 @@ static void hpsa_unregister_scsi(struct ctlr_info *h)
 
 static int hpsa_register_scsi(struct ctlr_info *h)
 {
-	int rc;
+	struct Scsi_Host *sh;
+	int error;
 
-	rc = hpsa_scsi_detect(h);
-	if (rc != 0)
-		dev_err(&h->pdev->dev, "hpsa_register_scsi: failed"
-			" hpsa_scsi_detect(), rc is %d\n", rc);
-	return rc;
+	sh = scsi_host_alloc(&hpsa_driver_template, sizeof(h));
+	if (sh == NULL)
+		goto fail;
+
+	sh->io_port = 0;
+	sh->n_io_port = 0;
+	sh->this_id = -1;
+	sh->max_channel = 3;
+	sh->max_cmd_len = MAX_COMMAND_SIZE;
+	sh->max_lun = HPSA_MAX_LUN;
+	sh->max_id = HPSA_MAX_LUN;
+	sh->can_queue = h->nr_cmds;
+	sh->cmd_per_lun = h->nr_cmds;
+	sh->sg_tablesize = h->maxsgentries;
+	h->scsi_host = sh;
+	sh->hostdata[0] = (unsigned long) h;
+	sh->irq = h->intr[h->intr_mode];
+	sh->unique_id = sh->irq;
+	error = scsi_add_host(sh, &h->pdev->dev);
+	if (error)
+		goto fail_host_put;
+	scsi_scan_host(sh);
+	return 0;
+
+ fail_host_put:
+	dev_err(&h->pdev->dev, "%s: scsi_add_host"
+		" failed for controller %d\n", __func__, h->ctlr);
+	scsi_host_put(sh);
+	return error;
+ fail:
+	dev_err(&h->pdev->dev, "%s: scsi_host_alloc"
+		" failed for controller %d\n", __func__, h->ctlr);
+	return -ENOMEM;
 }
 
 static int wait_for_device_to_become_ready(struct ctlr_info *h,


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

* [PATCH 04/10] hpsa: factor out driver name
  2012-01-19 20:00 [PATCH 01/10] hpsa: fix per device memory leak on driver unload Stephen M. Cameron
  2012-01-19 20:00 ` [PATCH 02/10] hpsa: removed unneeded structure member max_sg_entries and fix badly named constant MAXSGENTRIES Stephen M. Cameron
  2012-01-19 20:00 ` [PATCH 03/10] hpsa: combine hpsa_scsi_detect and hpsa_register_scsi Stephen M. Cameron
@ 2012-01-19 20:00 ` Stephen M. Cameron
  2012-01-19 20:01 ` [PATCH 05/10] hpsa: Fix problem with MSA2xxx devices Stephen M. Cameron
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 14+ messages in thread
From: Stephen M. Cameron @ 2012-01-19 20:00 UTC (permalink / raw)
  To: james.bottomley
  Cc: linux-scsi, linux-kernel, mikem, stephenmcameron, thenzl,
	scott.teel, akpm, stable

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

Sometimes, for testing purposes (e.g. testing rmmod on a system
that normally boots using hpsa) it's nice to rename the driver
and split it into two drivers and restrict it to certain
controllers.  This makes that easier.

Signed-off-by: Stephen M. Cameron <scameron@beardog.cce.hp.com>
---
 drivers/scsi/hpsa.c |   27 ++++++++++++++-------------
 drivers/scsi/hpsa.h |    2 +-
 2 files changed, 15 insertions(+), 14 deletions(-)

diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
index d191e3f..129655a 100644
--- a/drivers/scsi/hpsa.c
+++ b/drivers/scsi/hpsa.c
@@ -56,6 +56,7 @@
 /* HPSA_DRIVER_VERSION must be 3 byte values (0-255) separated by '.' */
 #define HPSA_DRIVER_VERSION "2.0.2-1"
 #define DRIVER_NAME "HP HPSA Driver (v " HPSA_DRIVER_VERSION ")"
+#define HPSA "hpsa"
 
 /* How long to wait (in milliseconds) for board to go into simple mode */
 #define MAX_CONFIG_WAIT 30000
@@ -202,30 +203,30 @@ static int check_for_unit_attention(struct ctlr_info *h,
 
 	switch (c->err_info->SenseInfo[12]) {
 	case STATE_CHANGED:
-		dev_warn(&h->pdev->dev, "hpsa%d: a state change "
+		dev_warn(&h->pdev->dev, HPSA "%d: a state change "
 			"detected, command retried\n", h->ctlr);
 		break;
 	case LUN_FAILED:
-		dev_warn(&h->pdev->dev, "hpsa%d: LUN failure "
+		dev_warn(&h->pdev->dev, HPSA "%d: LUN failure "
 			"detected, action required\n", h->ctlr);
 		break;
 	case REPORT_LUNS_CHANGED:
-		dev_warn(&h->pdev->dev, "hpsa%d: report LUN data "
+		dev_warn(&h->pdev->dev, HPSA "%d: report LUN data "
 			"changed, action required\n", h->ctlr);
 	/*
 	 * Note: this REPORT_LUNS_CHANGED condition only occurs on the MSA2012.
 	 */
 		break;
 	case POWER_OR_RESET:
-		dev_warn(&h->pdev->dev, "hpsa%d: a power on "
+		dev_warn(&h->pdev->dev, HPSA "%d: a power on "
 			"or device reset detected\n", h->ctlr);
 		break;
 	case UNIT_ATTENTION_CLEARED:
-		dev_warn(&h->pdev->dev, "hpsa%d: unit attention "
+		dev_warn(&h->pdev->dev, HPSA "%d: unit attention "
 		    "cleared by another initiator\n", h->ctlr);
 		break;
 	default:
-		dev_warn(&h->pdev->dev, "hpsa%d: unknown "
+		dev_warn(&h->pdev->dev, HPSA "%d: unknown "
 			"unit attention detected\n", h->ctlr);
 		break;
 	}
@@ -473,8 +474,8 @@ static struct device_attribute *hpsa_shost_attrs[] = {
 
 static struct scsi_host_template hpsa_driver_template = {
 	.module			= THIS_MODULE,
-	.name			= "hpsa",
-	.proc_name		= "hpsa",
+	.name			= HPSA,
+	.proc_name		= HPSA,
 	.queuecommand		= hpsa_scsi_queue_command,
 	.scan_start		= hpsa_scan_start,
 	.scan_finished		= hpsa_scan_finished,
@@ -3341,7 +3342,7 @@ static int hpsa_controller_hard_reset(struct pci_dev *pdev,
 static __devinit void init_driver_version(char *driver_version, int len)
 {
 	memset(driver_version, 0, len);
-	strncpy(driver_version, "hpsa " HPSA_DRIVER_VERSION, len - 1);
+	strncpy(driver_version, HPSA " " HPSA_DRIVER_VERSION, len - 1);
 }
 
 static __devinit int write_driver_ver_to_cfgtable(
@@ -3922,7 +3923,7 @@ static int __devinit hpsa_pci_init(struct ctlr_info *h)
 		return err;
 	}
 
-	err = pci_request_regions(h->pdev, "hpsa");
+	err = pci_request_regions(h->pdev, HPSA);
 	if (err) {
 		dev_err(&h->pdev->dev,
 			"cannot obtain PCI resources, aborting\n");
@@ -4240,7 +4241,7 @@ static void start_controller_lockup_detector(struct ctlr_info *h)
 		spin_lock_init(&lockup_detector_lock);
 		hpsa_lockup_detector =
 			kthread_run(detect_controller_lockup_thread,
-						NULL, "hpsa");
+						NULL, HPSA);
 	}
 	if (!hpsa_lockup_detector) {
 		dev_warn(&h->pdev->dev,
@@ -4312,7 +4313,7 @@ reinit_after_soft_reset:
 	if (rc != 0)
 		goto clean1;
 
-	sprintf(h->devname, "hpsa%d", number_of_controllers);
+	sprintf(h->devname, HPSA "%d", number_of_controllers);
 	h->ctlr = number_of_controllers;
 	number_of_controllers++;
 
@@ -4526,7 +4527,7 @@ static int hpsa_resume(__attribute__((unused)) struct pci_dev *pdev)
 }
 
 static struct pci_driver hpsa_pci_driver = {
-	.name = "hpsa",
+	.name = HPSA,
 	.probe = hpsa_init_one,
 	.remove = __devexit_p(hpsa_remove_one),
 	.id_table = hpsa_pci_device_id,	/* id_table */
diff --git a/drivers/scsi/hpsa.h b/drivers/scsi/hpsa.h
index b4b97eb..7b28d54 100644
--- a/drivers/scsi/hpsa.h
+++ b/drivers/scsi/hpsa.h
@@ -316,7 +316,7 @@ static unsigned long SA5_completed(struct ctlr_info *h)
 		dev_dbg(&h->pdev->dev, "Read %lx back from board\n",
 			register_value);
 	else
-		dev_dbg(&h->pdev->dev, "hpsa: FIFO Empty read\n");
+		dev_dbg(&h->pdev->dev, "FIFO Empty read\n");
 #endif
 
 	return register_value;


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

* [PATCH 05/10] hpsa: Fix problem with MSA2xxx devices
  2012-01-19 20:00 [PATCH 01/10] hpsa: fix per device memory leak on driver unload Stephen M. Cameron
                   ` (2 preceding siblings ...)
  2012-01-19 20:00 ` [PATCH 04/10] hpsa: factor out driver name Stephen M. Cameron
@ 2012-01-19 20:01 ` Stephen M. Cameron
  2012-05-20  9:47   ` [3.0.y, 3.2.y, 3.3.y] " Jonathan Nieder
  2012-01-19 20:01 ` [PATCH 06/10] hpsa: make target and lun match what SCSI REPORT LUNs returns Stephen M. Cameron
                   ` (4 subsequent siblings)
  8 siblings, 1 reply; 14+ messages in thread
From: Stephen M. Cameron @ 2012-01-19 20:01 UTC (permalink / raw)
  To: james.bottomley
  Cc: linux-scsi, linux-kernel, mikem, stephenmcameron, thenzl,
	scott.teel, akpm, stable

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

Upgraded firmware on Smart Array P7xx (and some others) made them show up as
SCSI revision 5 devices and this caused the driver to fail to map MSA2xxx
logical drives to the correct bus/target/lun.  A symptom of this would be that
the target ID of the logical drives as presented by the external storage array
is ignored, and all such logical drives are assigned to target zero,
differentiated only by LUN.  Some multipath software reportedly does not deal
well with this behavior, failing to recognize different paths to the same
device as such.

Signed-off-by: Stephen M. Cameron <scameron@beardog.cce.hp.com>
Signed-off-by: Scott Teel <scott.teel@hp.com>
---
 drivers/scsi/hpsa.c |   34 +++++++++++++++-------------------
 1 files changed, 15 insertions(+), 19 deletions(-)

diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
index 129655a..b30033b 100644
--- a/drivers/scsi/hpsa.c
+++ b/drivers/scsi/hpsa.c
@@ -1635,30 +1635,26 @@ static void figure_bus_target_lun(struct ctlr_info *h,
 
 	if (is_logical_dev_addr_mode(lunaddrbytes)) {
 		/* logical device */
-		if (unlikely(is_scsi_rev_5(h))) {
-			/* p1210m, logical drives lun assignments
-			 * match SCSI REPORT LUNS data.
+		lunid = le32_to_cpu(*((__le32 *) lunaddrbytes));
+		if (is_msa2xxx(h, device)) {
+			/* msa2xxx way, put logicals on bus 1
+			 * and match target/lun numbers box
+			 * reports.
 			 */
-			lunid = le32_to_cpu(*((__le32 *) lunaddrbytes));
-			*bus = 0;
-			*target = 0;
-			*lun = (lunid & 0x3fff) + 1;
+			*bus = 1;
+			*target = (lunid >> 16) & 0x3fff;
+			*lun = lunid & 0x00ff;
 		} else {
-			/* not p1210m... */
-			lunid = le32_to_cpu(*((__le32 *) lunaddrbytes));
-			if (is_msa2xxx(h, device)) {
-				/* msa2xxx way, put logicals on bus 1
-				 * and match target/lun numbers box
-				 * reports.
-				 */
-				*bus = 1;
-				*target = (lunid >> 16) & 0x3fff;
-				*lun = lunid & 0x00ff;
+			if (likely(is_scsi_rev_5(h))) {
+				/* All current smart arrays (circa 2011) */
+				*bus = 0;
+				*target = 0;
+				*lun = (lunid & 0x3fff) + 1;
 			} else {
-				/* Traditional smart array way. */
+				/* Traditional old smart array way. */
 				*bus = 0;
-				*lun = 0;
 				*target = lunid & 0x3fff;
+				*lun = 0;
 			}
 		}
 	} else {


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

* [PATCH 06/10] hpsa: make target and lun match what SCSI REPORT LUNs returns
  2012-01-19 20:00 [PATCH 01/10] hpsa: fix per device memory leak on driver unload Stephen M. Cameron
                   ` (3 preceding siblings ...)
  2012-01-19 20:01 ` [PATCH 05/10] hpsa: Fix problem with MSA2xxx devices Stephen M. Cameron
@ 2012-01-19 20:01 ` Stephen M. Cameron
  2012-01-19 20:01 ` [PATCH 07/10] hpsa: refactor hpsa_figure_bus_target_lun Stephen M. Cameron
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 14+ messages in thread
From: Stephen M. Cameron @ 2012-01-19 20:01 UTC (permalink / raw)
  To: james.bottomley
  Cc: linux-scsi, linux-kernel, mikem, stephenmcameron, thenzl,
	scott.teel, akpm, stable

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

Some distros have a "rescan-scsi-bus.sh" script which depends on
SCSI REPORT LUNs not reporting something different than what the
driver tells the kernel, even if the driver uses scan_start and
scan_finished methods of the SCSI host template to override the
usual SCSI midlayer discovery code.  Previously, 1 was added to
the LUN to make room to insert the RAID controller device at
LUN 0.  Now, the RAID controller is moved to bus 3, and 1 is no
longer added to the LUN.  However, SCSI REPORT LUNS on Smart Array
doesn't report physical devices like tape drives or auto-loaders
as it turns out, so those particular device types still won't match.
Generally the logical drives are reported first however, so at
least those should match.

Signed-off-by: Stephen M. Cameron <scameron@beardog.cce.hp.com>
---
 drivers/scsi/hpsa.c |   25 +++++--------------------
 1 files changed, 5 insertions(+), 20 deletions(-)

diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
index b30033b..c52bc76 100644
--- a/drivers/scsi/hpsa.c
+++ b/drivers/scsi/hpsa.c
@@ -1645,30 +1645,15 @@ static void figure_bus_target_lun(struct ctlr_info *h,
 			*target = (lunid >> 16) & 0x3fff;
 			*lun = lunid & 0x00ff;
 		} else {
-			if (likely(is_scsi_rev_5(h))) {
-				/* All current smart arrays (circa 2011) */
-				*bus = 0;
-				*target = 0;
-				*lun = (lunid & 0x3fff) + 1;
-			} else {
-				/* Traditional old smart array way. */
-				*bus = 0;
-				*target = lunid & 0x3fff;
-				*lun = 0;
-			}
+			*bus = 0;
+			*target = 0;
+			*lun = (lunid & 0x3fff);
 		}
 	} else {
-		/* physical device */
 		if (is_hba_lunid(lunaddrbytes))
-			if (unlikely(is_scsi_rev_5(h))) {
-				*bus = 0; /* put p1210m ctlr at 0,0,0 */
-				*target = 0;
-				*lun = 0;
-				return;
-			} else
-				*bus = 3; /* traditional smartarray */
+			*bus = 3; /* controller */
 		else
-			*bus = 2; /* physical disk */
+			*bus = 2; /* physical device */
 		*target = -1;
 		*lun = -1; /* we will fill these in later. */
 	}


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

* [PATCH 07/10] hpsa: refactor hpsa_figure_bus_target_lun
  2012-01-19 20:00 [PATCH 01/10] hpsa: fix per device memory leak on driver unload Stephen M. Cameron
                   ` (4 preceding siblings ...)
  2012-01-19 20:01 ` [PATCH 06/10] hpsa: make target and lun match what SCSI REPORT LUNs returns Stephen M. Cameron
@ 2012-01-19 20:01 ` Stephen M. Cameron
  2012-01-19 20:01 ` [PATCH 08/10] hpsa: eliminate 8 external target limitation Stephen M. Cameron
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 14+ messages in thread
From: Stephen M. Cameron @ 2012-01-19 20:01 UTC (permalink / raw)
  To: james.bottomley
  Cc: linux-scsi, linux-kernel, mikem, stephenmcameron, thenzl,
	scott.teel, akpm, stable

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

It should call hpsa_set_bus_target_lun rather
than individually setting bus, target and lun.

Signed-off-by: Stephen M. Cameron <scameron@beardog.cce.hp.com>
---
 drivers/scsi/hpsa.c |   68 +++++++++++++++++++++++----------------------------
 1 files changed, 30 insertions(+), 38 deletions(-)

diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
index c52bc76..ea9b685 100644
--- a/drivers/scsi/hpsa.c
+++ b/drivers/scsi/hpsa.c
@@ -1628,35 +1628,30 @@ static int is_msa2xxx(struct ctlr_info *h, struct hpsa_scsi_dev_t *device)
  * in hpsa_find_target_lun, called by hpsa_scsi_add_entry.)
  */
 static void figure_bus_target_lun(struct ctlr_info *h,
-	u8 *lunaddrbytes, int *bus, int *target, int *lun,
-	struct hpsa_scsi_dev_t *device)
-{
-	u32 lunid;
-
-	if (is_logical_dev_addr_mode(lunaddrbytes)) {
-		/* logical device */
-		lunid = le32_to_cpu(*((__le32 *) lunaddrbytes));
-		if (is_msa2xxx(h, device)) {
-			/* msa2xxx way, put logicals on bus 1
-			 * and match target/lun numbers box
-			 * reports.
-			 */
-			*bus = 1;
-			*target = (lunid >> 16) & 0x3fff;
-			*lun = lunid & 0x00ff;
-		} else {
-			*bus = 0;
-			*target = 0;
-			*lun = (lunid & 0x3fff);
-		}
-	} else {
+	u8 *lunaddrbytes, struct hpsa_scsi_dev_t *device)
+{
+	u32 lunid = le32_to_cpu(*((__le32 *) lunaddrbytes));
+
+	if (!is_logical_dev_addr_mode(lunaddrbytes)) {
+		/* physical device, target and lun filled in later */
 		if (is_hba_lunid(lunaddrbytes))
-			*bus = 3; /* controller */
+			hpsa_set_bus_target_lun(device, 3, 0, lunid & 0x3fff);
 		else
-			*bus = 2; /* physical device */
-		*target = -1;
-		*lun = -1; /* we will fill these in later. */
+			/* defer target, lun assignment for physical devices */
+			hpsa_set_bus_target_lun(device, 2, -1, -1);
+		return;
+	}
+	/* It's a logical device */
+	if (is_msa2xxx(h, device)) {
+		/* msa2xxx way, put logicals on bus 1
+		 * and match target/lun numbers box
+		 * reports, other smart array, bus 0, target 0, match lunid
+		 */
+		hpsa_set_bus_target_lun(device,
+			1, (lunid >> 16) & 0x3fff, lunid & 0x00ff);
+		return;
 	}
+	hpsa_set_bus_target_lun(device, 0, 0, lunid & 0x3fff);
 }
 
 /*
@@ -1673,12 +1668,11 @@ static void figure_bus_target_lun(struct ctlr_info *h,
 static int add_msa2xxx_enclosure_device(struct ctlr_info *h,
 	struct hpsa_scsi_dev_t *tmpdevice,
 	struct hpsa_scsi_dev_t *this_device, u8 *lunaddrbytes,
-	int bus, int target, int lun, unsigned long lunzerobits[],
-	int *nmsa2xxx_enclosures)
+	unsigned long lunzerobits[], int *nmsa2xxx_enclosures)
 {
 	unsigned char scsi3addr[8];
 
-	if (test_bit(target, lunzerobits))
+	if (test_bit(tmpdevice->target, lunzerobits))
 		return 0; /* There is already a lun 0 on this target. */
 
 	if (!is_logical_dev_addr_mode(lunaddrbytes))
@@ -1687,11 +1681,11 @@ static int add_msa2xxx_enclosure_device(struct ctlr_info *h,
 	if (!is_msa2xxx(h, tmpdevice))
 		return 0; /* It's only the MSA2xxx that have this problem. */
 
-	if (lun == 0) /* if lun is 0, then obviously we have a lun 0. */
+	if (tmpdevice->lun == 0) /* if lun is 0, then we have a lun 0. */
 		return 0;
 
 	memset(scsi3addr, 0, 8);
-	scsi3addr[3] = target;
+	scsi3addr[3] = tmpdevice->target;
 	if (is_hba_lunid(scsi3addr))
 		return 0; /* Don't add the RAID controller here. */
 
@@ -1708,8 +1702,9 @@ static int add_msa2xxx_enclosure_device(struct ctlr_info *h,
 	if (hpsa_update_device_info(h, scsi3addr, this_device, NULL))
 		return 0;
 	(*nmsa2xxx_enclosures)++;
-	hpsa_set_bus_target_lun(this_device, bus, target, 0);
-	set_bit(target, lunzerobits);
+	hpsa_set_bus_target_lun(this_device,
+				tmpdevice->bus, tmpdevice->target, 0);
+	set_bit(tmpdevice->target, lunzerobits);
 	return 1;
 }
 
@@ -1804,7 +1799,6 @@ static void hpsa_update_scsi_devices(struct ctlr_info *h, int hostno)
 	int ncurrent = 0;
 	int reportlunsize = sizeof(*physdev_list) + HPSA_MAX_PHYS_LUN * 8;
 	int i, nmsa2xxx_enclosures, ndevs_to_allocate;
-	int bus, target, lun;
 	int raid_ctlr_position;
 	DECLARE_BITMAP(lunzerobits, HPSA_MAX_TARGETS_PER_CTLR);
 
@@ -1869,8 +1863,7 @@ static void hpsa_update_scsi_devices(struct ctlr_info *h, int hostno)
 		if (hpsa_update_device_info(h, lunaddrbytes, tmpdevice,
 							&is_OBDR))
 			continue; /* skip it if we can't talk to it. */
-		figure_bus_target_lun(h, lunaddrbytes, &bus, &target, &lun,
-			tmpdevice);
+		figure_bus_target_lun(h, lunaddrbytes, tmpdevice);
 		this_device = currentsd[ncurrent];
 
 		/*
@@ -1881,14 +1874,13 @@ static void hpsa_update_scsi_devices(struct ctlr_info *h, int hostno)
 		 * there is no lun 0.
 		 */
 		if (add_msa2xxx_enclosure_device(h, tmpdevice, this_device,
-				lunaddrbytes, bus, target, lun, lunzerobits,
+				lunaddrbytes, lunzerobits,
 				&nmsa2xxx_enclosures)) {
 			ncurrent++;
 			this_device = currentsd[ncurrent];
 		}
 
 		*this_device = *tmpdevice;
-		hpsa_set_bus_target_lun(this_device, bus, target, lun);
 
 		switch (this_device->devtype) {
 		case TYPE_ROM:


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

* [PATCH 08/10] hpsa: eliminate 8 external target limitation
  2012-01-19 20:00 [PATCH 01/10] hpsa: fix per device memory leak on driver unload Stephen M. Cameron
                   ` (5 preceding siblings ...)
  2012-01-19 20:01 ` [PATCH 07/10] hpsa: refactor hpsa_figure_bus_target_lun Stephen M. Cameron
@ 2012-01-19 20:01 ` Stephen M. Cameron
  2012-01-19 20:01 ` [PATCH 09/10] hpsa: improve naming on external target device functions Stephen M. Cameron
  2012-01-19 20:01 ` [PATCH 10/10] hpsa: update device attributes when they change Stephen M. Cameron
  8 siblings, 0 replies; 14+ messages in thread
From: Stephen M. Cameron @ 2012-01-19 20:01 UTC (permalink / raw)
  To: james.bottomley
  Cc: linux-scsi, linux-kernel, mikem, stephenmcameron, thenzl,
	scott.teel, akpm, stable

From: Scott Teel <scott.teel@hp.com>

Driver limits SAS external target IDs to range 1-8.
Need to increase limit and clean up overlapping concepts of targets and paths
in the code.

There are several defined constants that control this:
HPSA_MAX_TARGETS_PER_CTLR     16
MAX_MSA2XXX_ENCLOSURES        32
HPSA_MAX_PATHS                8

We can condense this to one constant:
MAX_EXT_TARGETS               32

SAS switches allow for 8 connections, and there is capacity for 4 switches per
enclosure in largest blade enclosure type.

Signed-off-by: Scott Teel <scott.teel@hp.com>
Signed-off-by: Stephen M. Cameron <scameron@beardog.cce.hp.com>
---
 drivers/scsi/hpsa.c     |   16 ++++++++--------
 drivers/scsi/hpsa_cmd.h |    5 ++---
 2 files changed, 10 insertions(+), 11 deletions(-)

diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
index ea9b685..39ac161 100644
--- a/drivers/scsi/hpsa.c
+++ b/drivers/scsi/hpsa.c
@@ -1692,9 +1692,9 @@ static int add_msa2xxx_enclosure_device(struct ctlr_info *h,
 	if (is_scsi_rev_5(h))
 		return 0; /* p1210m doesn't need to do this. */
 
-	if (*nmsa2xxx_enclosures >= MAX_MSA2XXX_ENCLOSURES) {
-		dev_warn(&h->pdev->dev, "Maximum number of MSA2XXX "
-			"enclosures exceeded.  Check your hardware "
+	if (*nmsa2xxx_enclosures >= MAX_EXT_TARGETS) {
+		dev_warn(&h->pdev->dev, "Maximum number of external "
+			"target devices exceeded.  Check your hardware "
 			"configuration.");
 		return 0;
 	}
@@ -1800,7 +1800,7 @@ static void hpsa_update_scsi_devices(struct ctlr_info *h, int hostno)
 	int reportlunsize = sizeof(*physdev_list) + HPSA_MAX_PHYS_LUN * 8;
 	int i, nmsa2xxx_enclosures, ndevs_to_allocate;
 	int raid_ctlr_position;
-	DECLARE_BITMAP(lunzerobits, HPSA_MAX_TARGETS_PER_CTLR);
+	DECLARE_BITMAP(lunzerobits, MAX_EXT_TARGETS);
 
 	currentsd = kzalloc(sizeof(*currentsd) * HPSA_MAX_DEVICES, GFP_KERNEL);
 	physdev_list = kzalloc(reportlunsize, GFP_KERNEL);
@@ -1817,11 +1817,11 @@ static void hpsa_update_scsi_devices(struct ctlr_info *h, int hostno)
 			logdev_list, &nlogicals))
 		goto out;
 
-	/* We might see up to 32 MSA2xxx enclosures, actually 8 of them
-	 * but each of them 4 times through different paths.  The plus 1
-	 * is for the RAID controller.
+	/* We might see up to the maximum number of logical and physical disks
+	 * plus external target devices, and a device for the local RAID
+	 * controller.
 	 */
-	ndevs_to_allocate = nphysicals + nlogicals + MAX_MSA2XXX_ENCLOSURES + 1;
+	ndevs_to_allocate = nphysicals + nlogicals + MAX_EXT_TARGETS + 1;
 
 	/* Allocate the per device structures */
 	for (i = 0; i < ndevs_to_allocate; i++) {
diff --git a/drivers/scsi/hpsa_cmd.h b/drivers/scsi/hpsa_cmd.h
index 516d6e5..8049815 100644
--- a/drivers/scsi/hpsa_cmd.h
+++ b/drivers/scsi/hpsa_cmd.h
@@ -122,12 +122,11 @@ union u64bit {
 };
 
 /* FIXME this is a per controller value (barf!) */
-#define HPSA_MAX_TARGETS_PER_CTLR 16
 #define HPSA_MAX_LUN 1024
 #define HPSA_MAX_PHYS_LUN 1024
-#define MAX_MSA2XXX_ENCLOSURES 32
+#define MAX_EXT_TARGETS 32
 #define HPSA_MAX_DEVICES (HPSA_MAX_PHYS_LUN + HPSA_MAX_LUN + \
-	MAX_MSA2XXX_ENCLOSURES + 1) /* + 1 is for the controller itself */
+	MAX_EXT_TARGETS + 1) /* + 1 is for the controller itself */
 
 /* SCSI-3 Commands */
 #pragma pack(1)


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

* [PATCH 09/10] hpsa: improve naming on external target device functions
  2012-01-19 20:00 [PATCH 01/10] hpsa: fix per device memory leak on driver unload Stephen M. Cameron
                   ` (6 preceding siblings ...)
  2012-01-19 20:01 ` [PATCH 08/10] hpsa: eliminate 8 external target limitation Stephen M. Cameron
@ 2012-01-19 20:01 ` Stephen M. Cameron
  2012-01-19 20:01 ` [PATCH 10/10] hpsa: update device attributes when they change Stephen M. Cameron
  8 siblings, 0 replies; 14+ messages in thread
From: Stephen M. Cameron @ 2012-01-19 20:01 UTC (permalink / raw)
  To: james.bottomley
  Cc: linux-scsi, linux-kernel, mikem, stephenmcameron, thenzl,
	scott.teel, akpm, stable

From: Scott Teel <scott.teel@hp.com>

Reduce confusion and inaccuracy caused by dated naming of vars and functions
referring to external target devices.

CURRENT NAMING:                PROPOSED NAMING:

"MSA2xxx devices"              "external target devices"
msa2xxx_model                  ext_target_model
is_msa2xxx                     is_ext_target
add_msa2xxx_enclosure          add_ext_target_dev
nmsa2xxx_enclosures            n_ext_target_devs

Signed-off-by: Scott Teel <scott.teel@hp.com>
Signed-off-by: Stephen M. Cameron <scameron@beardog.cce.hp.com>
---
 drivers/scsi/hpsa.c |   43 ++++++++++++++++++++++---------------------
 1 files changed, 22 insertions(+), 21 deletions(-)

diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
index 39ac161..bf75e4c 100644
--- a/drivers/scsi/hpsa.c
+++ b/drivers/scsi/hpsa.c
@@ -214,7 +214,8 @@ static int check_for_unit_attention(struct ctlr_info *h,
 		dev_warn(&h->pdev->dev, HPSA "%d: report LUN data "
 			"changed, action required\n", h->ctlr);
 	/*
-	 * Note: this REPORT_LUNS_CHANGED condition only occurs on the MSA2012.
+	 * Note: this REPORT_LUNS_CHANGED condition only occurs on the external
+	 * target (array) devices.
 	 */
 		break;
 	case POWER_OR_RESET:
@@ -1600,7 +1601,7 @@ bail_out:
 	return 1;
 }
 
-static unsigned char *msa2xxx_model[] = {
+static unsigned char *ext_target_model[] = {
 	"MSA2012",
 	"MSA2024",
 	"MSA2312",
@@ -1609,19 +1610,19 @@ static unsigned char *msa2xxx_model[] = {
 	NULL,
 };
 
-static int is_msa2xxx(struct ctlr_info *h, struct hpsa_scsi_dev_t *device)
+static int is_ext_target(struct ctlr_info *h, struct hpsa_scsi_dev_t *device)
 {
 	int i;
 
-	for (i = 0; msa2xxx_model[i]; i++)
-		if (strncmp(device->model, msa2xxx_model[i],
-			strlen(msa2xxx_model[i])) == 0)
+	for (i = 0; ext_target_model[i]; i++)
+		if (strncmp(device->model, ext_target_model[i],
+			strlen(ext_target_model[i])) == 0)
 			return 1;
 	return 0;
 }
 
 /* Helper function to assign bus, target, lun mapping of devices.
- * Puts non-msa2xxx logical volumes on bus 0, msa2xxx logical
+ * Puts non-external target logical volumes on bus 0, external target logical
  * volumes on bus 1, physical devices on bus 2. and the hba on bus 3.
  * Logical drive target and lun are assigned at this time, but
  * physical device lun and target assignment are deferred (assigned
@@ -1642,8 +1643,8 @@ static void figure_bus_target_lun(struct ctlr_info *h,
 		return;
 	}
 	/* It's a logical device */
-	if (is_msa2xxx(h, device)) {
-		/* msa2xxx way, put logicals on bus 1
+	if (is_ext_target(h, device)) {
+		/* external target way, put logicals on bus 1
 		 * and match target/lun numbers box
 		 * reports, other smart array, bus 0, target 0, match lunid
 		 */
@@ -1656,7 +1657,7 @@ static void figure_bus_target_lun(struct ctlr_info *h,
 
 /*
  * If there is no lun 0 on a target, linux won't find any devices.
- * For the MSA2xxx boxes, we have to manually detect the enclosure
+ * For the external targets (arrays), we have to manually detect the enclosure
  * which is at lun zero, as CCISS_REPORT_PHYSICAL_LUNS doesn't report
  * it for some reason.  *tmpdevice is the target we're adding,
  * this_device is a pointer into the current element of currentsd[]
@@ -1665,10 +1666,10 @@ static void figure_bus_target_lun(struct ctlr_info *h,
  * lun 0 assigned.
  * Returns 1 if an enclosure was added, 0 if not.
  */
-static int add_msa2xxx_enclosure_device(struct ctlr_info *h,
+static int add_ext_target_dev(struct ctlr_info *h,
 	struct hpsa_scsi_dev_t *tmpdevice,
 	struct hpsa_scsi_dev_t *this_device, u8 *lunaddrbytes,
-	unsigned long lunzerobits[], int *nmsa2xxx_enclosures)
+	unsigned long lunzerobits[], int *n_ext_target_devs)
 {
 	unsigned char scsi3addr[8];
 
@@ -1678,8 +1679,8 @@ static int add_msa2xxx_enclosure_device(struct ctlr_info *h,
 	if (!is_logical_dev_addr_mode(lunaddrbytes))
 		return 0; /* It's the logical targets that may lack lun 0. */
 
-	if (!is_msa2xxx(h, tmpdevice))
-		return 0; /* It's only the MSA2xxx that have this problem. */
+	if (!is_ext_target(h, tmpdevice))
+		return 0; /* Only external target devices have this problem. */
 
 	if (tmpdevice->lun == 0) /* if lun is 0, then we have a lun 0. */
 		return 0;
@@ -1692,7 +1693,7 @@ static int add_msa2xxx_enclosure_device(struct ctlr_info *h,
 	if (is_scsi_rev_5(h))
 		return 0; /* p1210m doesn't need to do this. */
 
-	if (*nmsa2xxx_enclosures >= MAX_EXT_TARGETS) {
+	if (*n_ext_target_devs >= MAX_EXT_TARGETS) {
 		dev_warn(&h->pdev->dev, "Maximum number of external "
 			"target devices exceeded.  Check your hardware "
 			"configuration.");
@@ -1701,7 +1702,7 @@ static int add_msa2xxx_enclosure_device(struct ctlr_info *h,
 
 	if (hpsa_update_device_info(h, scsi3addr, this_device, NULL))
 		return 0;
-	(*nmsa2xxx_enclosures)++;
+	(*n_ext_target_devs)++;
 	hpsa_set_bus_target_lun(this_device,
 				tmpdevice->bus, tmpdevice->target, 0);
 	set_bit(tmpdevice->target, lunzerobits);
@@ -1798,7 +1799,7 @@ static void hpsa_update_scsi_devices(struct ctlr_info *h, int hostno)
 	struct hpsa_scsi_dev_t **currentsd, *this_device, *tmpdevice;
 	int ncurrent = 0;
 	int reportlunsize = sizeof(*physdev_list) + HPSA_MAX_PHYS_LUN * 8;
-	int i, nmsa2xxx_enclosures, ndevs_to_allocate;
+	int i, n_ext_target_devs, ndevs_to_allocate;
 	int raid_ctlr_position;
 	DECLARE_BITMAP(lunzerobits, MAX_EXT_TARGETS);
 
@@ -1847,7 +1848,7 @@ static void hpsa_update_scsi_devices(struct ctlr_info *h, int hostno)
 		raid_ctlr_position = nphysicals + nlogicals;
 
 	/* adjust our table of devices */
-	nmsa2xxx_enclosures = 0;
+	n_ext_target_devs = 0;
 	for (i = 0; i < nphysicals + nlogicals + 1; i++) {
 		u8 *lunaddrbytes, is_OBDR = 0;
 
@@ -1867,15 +1868,15 @@ static void hpsa_update_scsi_devices(struct ctlr_info *h, int hostno)
 		this_device = currentsd[ncurrent];
 
 		/*
-		 * For the msa2xxx boxes, we have to insert a LUN 0 which
+		 * For external target devices, we have to insert a LUN 0 which
 		 * doesn't show up in CCISS_REPORT_PHYSICAL data, but there
 		 * is nonetheless an enclosure device there.  We have to
 		 * present that otherwise linux won't find anything if
 		 * there is no lun 0.
 		 */
-		if (add_msa2xxx_enclosure_device(h, tmpdevice, this_device,
+		if (add_ext_target_dev(h, tmpdevice, this_device,
 				lunaddrbytes, lunzerobits,
-				&nmsa2xxx_enclosures)) {
+				&n_ext_target_devs)) {
 			ncurrent++;
 			this_device = currentsd[ncurrent];
 		}


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

* [PATCH 10/10] hpsa: update device attributes when they change
  2012-01-19 20:00 [PATCH 01/10] hpsa: fix per device memory leak on driver unload Stephen M. Cameron
                   ` (7 preceding siblings ...)
  2012-01-19 20:01 ` [PATCH 09/10] hpsa: improve naming on external target device functions Stephen M. Cameron
@ 2012-01-19 20:01 ` Stephen M. Cameron
  8 siblings, 0 replies; 14+ messages in thread
From: Stephen M. Cameron @ 2012-01-19 20:01 UTC (permalink / raw)
  To: james.bottomley
  Cc: linux-scsi, linux-kernel, mikem, stephenmcameron, thenzl,
	scott.teel, akpm, stable

From: Scott Teel <scott.teel@hp.com>

Certain types of changes to devices should not be interpreted as a device
change that would cause the device to be removed and re-added.  These include
RAID level and Firmware revision changes.  However, these attribute changes DO
need to be reflected in the controller info structure's dev structure list, so
that sysfs and /proc info files for the devices will reflect the new values.

Signed-off-by: Scott Teel <scott.stacy.teel@hp.com>
Acked-by: Stephen M. Cameron <scameron@beardog.cce.hp.com>
---
 drivers/scsi/hpsa.c |   43 ++++++++++++++++++++++++++++++++++++++++---
 1 files changed, 40 insertions(+), 3 deletions(-)

diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
index bf75e4c..56a4e8a 100644
--- a/drivers/scsi/hpsa.c
+++ b/drivers/scsi/hpsa.c
@@ -675,6 +675,20 @@ lun_assigned:
 	return 0;
 }
 
+/* Update an entry in h->dev[] array. */
+static void hpsa_scsi_update_entry(struct ctlr_info *h, int hostno,
+	int entry, struct hpsa_scsi_dev_t *new_entry)
+{
+	/* assumes h->devlock is held */
+	BUG_ON(entry < 0 || entry >= HPSA_MAX_DEVICES);
+
+	/* Raid level changed. */
+	h->dev[entry]->raid_level = new_entry->raid_level;
+	dev_info(&h->pdev->dev, "%s device c%db%dt%dl%d updated.\n",
+		scsi_device_type(new_entry->devtype), hostno, new_entry->bus,
+		new_entry->target, new_entry->lun);
+}
+
 /* Replace an entry from h->dev[] array. */
 static void hpsa_scsi_replace_entry(struct ctlr_info *h, int hostno,
 	int entry, struct hpsa_scsi_dev_t *new_entry,
@@ -781,10 +795,25 @@ static inline int device_is_the_same(struct hpsa_scsi_dev_t *dev1,
 	return 1;
 }
 
+static inline int device_updated(struct hpsa_scsi_dev_t *dev1,
+	struct hpsa_scsi_dev_t *dev2)
+{
+	/* Device attributes that can change, but don't mean
+	 * that the device is a different device, nor that the OS
+	 * needs to be told anything about the change.
+	 */
+	if (dev1->raid_level != dev2->raid_level)
+		return 1;
+	return 0;
+}
+
 /* Find needle in haystack.  If exact match found, return DEVICE_SAME,
  * and return needle location in *index.  If scsi3addr matches, but not
  * vendor, model, serial num, etc. return DEVICE_CHANGED, and return needle
- * location in *index.  If needle not found, return DEVICE_NOT_FOUND.
+ * location in *index.
+ * In the case of a minor device attribute change, such as RAID level, just
+ * return DEVICE_UPDATED, along with the updated device's location in index.
+ * If needle not found, return DEVICE_NOT_FOUND.
  */
 static int hpsa_scsi_find_entry(struct hpsa_scsi_dev_t *needle,
 	struct hpsa_scsi_dev_t *haystack[], int haystack_size,
@@ -794,15 +823,19 @@ static int hpsa_scsi_find_entry(struct hpsa_scsi_dev_t *needle,
 #define DEVICE_NOT_FOUND 0
 #define DEVICE_CHANGED 1
 #define DEVICE_SAME 2
+#define DEVICE_UPDATED 3
 	for (i = 0; i < haystack_size; i++) {
 		if (haystack[i] == NULL) /* previously removed. */
 			continue;
 		if (SCSI3ADDR_EQ(needle->scsi3addr, haystack[i]->scsi3addr)) {
 			*index = i;
-			if (device_is_the_same(needle, haystack[i]))
+			if (device_is_the_same(needle, haystack[i])) {
+				if (device_updated(needle, haystack[i]))
+					return DEVICE_UPDATED;
 				return DEVICE_SAME;
-			else
+			} else {
 				return DEVICE_CHANGED;
+			}
 		}
 	}
 	*index = -1;
@@ -838,6 +871,8 @@ static void adjust_hpsa_scsi_table(struct ctlr_info *h, int hostno,
 	 * sd[] and remove them from h->dev[], and for any
 	 * devices which have changed, remove the old device
 	 * info and add the new device info.
+	 * If minor device attributes change, just update
+	 * the existing device structure.
 	 */
 	i = 0;
 	nremoved = 0;
@@ -858,6 +893,8 @@ static void adjust_hpsa_scsi_table(struct ctlr_info *h, int hostno,
 			 * at the bottom of hpsa_update_scsi_devices()
 			 */
 			sd[entry] = NULL;
+		} else if (device_change == DEVICE_UPDATED) {
+			hpsa_scsi_update_entry(h, hostno, i, sd[entry]);
 		}
 		i++;
 	}


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

* [3.0.y, 3.2.y, 3.3.y] Re: [PATCH 05/10] hpsa: Fix problem with MSA2xxx devices
  2012-01-19 20:01 ` [PATCH 05/10] hpsa: Fix problem with MSA2xxx devices Stephen M. Cameron
@ 2012-05-20  9:47   ` Jonathan Nieder
  2012-05-22  2:17     ` Ben Hutchings
  2012-05-24 19:11     ` Greg KH
  0 siblings, 2 replies; 14+ messages in thread
From: Jonathan Nieder @ 2012-05-20  9:47 UTC (permalink / raw)
  To: stable
  Cc: Stephen M. Cameron, Steven Williamson, james.bottomley,
	linux-scsi, linux-kernel, mikem, stephenmcameron, thenzl,
	scott.teel, akpm

Hi Greg and Ben,

Please consider

  9bc3711cbb67 [SCSI] hpsa: Fix problem with MSA2xxx devices

for application to next week's 3.0.y, 3.2.y, and 3.3.y trees.

As Steven Williamson noticed[1], without this patch:

> The hpsa driver fails to correctly assign devices when there are
> multiple paths on at least the Smart Array 712m with the latest
> firmware.
>
> The end result is only one device node is created in /dev and multipath
> tools then only detect one path.

He tested this patch + fda38518f236 "[SCSI] hpsa: add P2000 to list of
shared SAS devices" (which is already in v3.0) on top of a
2.6.32.y-based kernel and found:

> Applying the patch here:
> http://www.spinics.net/lists/linux-scsi/msg56690.html
> to the current stable version of the squeeze kernel fixes the issue.
>
> This was tested on a Smart Array 712m, connected via 2 SAS switches to a
> HP P2000 G3 SAS Array.

Stephen, are any other patches from the series at [2] or elsewhere
candidates for inclusion in stable trees?

Thanks and hope that helps,
Jonathan

[1] http://bugs.debian.org/661057
[2] http://thread.gmane.org/gmane.linux.kernel/1241509

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

* Re: [3.0.y, 3.2.y, 3.3.y] Re: [PATCH 05/10] hpsa: Fix problem with MSA2xxx devices
  2012-05-20  9:47   ` [3.0.y, 3.2.y, 3.3.y] " Jonathan Nieder
@ 2012-05-22  2:17     ` Ben Hutchings
  2012-05-24 19:11     ` Greg KH
  1 sibling, 0 replies; 14+ messages in thread
From: Ben Hutchings @ 2012-05-22  2:17 UTC (permalink / raw)
  To: Jonathan Nieder
  Cc: stable, Stephen M. Cameron, Steven Williamson, james.bottomley,
	linux-scsi, linux-kernel, mikem, stephenmcameron, thenzl,
	scott.teel, akpm

[-- Attachment #1: Type: text/plain, Size: 370 bytes --]

On Sun, 2012-05-20 at 04:47 -0500, Jonathan Nieder wrote:
> Hi Greg and Ben,
> 
> Please consider
> 
>   9bc3711cbb67 [SCSI] hpsa: Fix problem with MSA2xxx devices
> 
> for application to next week's 3.0.y, 3.2.y, and 3.3.y trees.
[...]

Added to the queue for 3.2.y, thanks.

Ben.

-- 
Ben Hutchings
You can't have everything.  Where would you put it?

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 828 bytes --]

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

* Re: [3.0.y, 3.2.y, 3.3.y] Re: [PATCH 05/10] hpsa: Fix problem with MSA2xxx devices
  2012-05-20  9:47   ` [3.0.y, 3.2.y, 3.3.y] " Jonathan Nieder
  2012-05-22  2:17     ` Ben Hutchings
@ 2012-05-24 19:11     ` Greg KH
  2012-05-24 22:02       ` Jonathan Nieder
  1 sibling, 1 reply; 14+ messages in thread
From: Greg KH @ 2012-05-24 19:11 UTC (permalink / raw)
  To: Jonathan Nieder
  Cc: stable, Stephen M. Cameron, Steven Williamson, james.bottomley,
	linux-scsi, linux-kernel, mikem, stephenmcameron, thenzl,
	scott.teel, akpm

On Sun, May 20, 2012 at 04:47:35AM -0500, Jonathan Nieder wrote:
> Hi Greg and Ben,
> 
> Please consider
> 
>   9bc3711cbb67 [SCSI] hpsa: Fix problem with MSA2xxx devices
> 
> for application to next week's 3.0.y, 3.2.y, and 3.3.y trees.

Now applied to the 3.0.y and 3.3.y trees, thanks.

greg k-h

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

* Re: [3.0.y, 3.2.y, 3.3.y] Re: [PATCH 05/10] hpsa: Fix problem with MSA2xxx devices
  2012-05-24 19:11     ` Greg KH
@ 2012-05-24 22:02       ` Jonathan Nieder
  0 siblings, 0 replies; 14+ messages in thread
From: Jonathan Nieder @ 2012-05-24 22:02 UTC (permalink / raw)
  To: Greg KH, Ben Hutchings
  Cc: stable, Stephen M. Cameron, Steven Williamson, james.bottomley,
	linux-scsi, linux-kernel, mikem, stephenmcameron, thenzl,
	scott.teel, akpm

Greg KH wrote:

> Now applied

Thanks, both.

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

end of thread, other threads:[~2012-05-24 22:02 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-01-19 20:00 [PATCH 01/10] hpsa: fix per device memory leak on driver unload Stephen M. Cameron
2012-01-19 20:00 ` [PATCH 02/10] hpsa: removed unneeded structure member max_sg_entries and fix badly named constant MAXSGENTRIES Stephen M. Cameron
2012-01-19 20:00 ` [PATCH 03/10] hpsa: combine hpsa_scsi_detect and hpsa_register_scsi Stephen M. Cameron
2012-01-19 20:00 ` [PATCH 04/10] hpsa: factor out driver name Stephen M. Cameron
2012-01-19 20:01 ` [PATCH 05/10] hpsa: Fix problem with MSA2xxx devices Stephen M. Cameron
2012-05-20  9:47   ` [3.0.y, 3.2.y, 3.3.y] " Jonathan Nieder
2012-05-22  2:17     ` Ben Hutchings
2012-05-24 19:11     ` Greg KH
2012-05-24 22:02       ` Jonathan Nieder
2012-01-19 20:01 ` [PATCH 06/10] hpsa: make target and lun match what SCSI REPORT LUNs returns Stephen M. Cameron
2012-01-19 20:01 ` [PATCH 07/10] hpsa: refactor hpsa_figure_bus_target_lun Stephen M. Cameron
2012-01-19 20:01 ` [PATCH 08/10] hpsa: eliminate 8 external target limitation Stephen M. Cameron
2012-01-19 20:01 ` [PATCH 09/10] hpsa: improve naming on external target device functions Stephen M. Cameron
2012-01-19 20:01 ` [PATCH 10/10] hpsa: update device attributes when they change Stephen M. Cameron

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).