All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1 00/25] hpsa updates
@ 2015-10-28 22:04 Don Brace
  2015-10-28 22:04 ` [PATCH 1 01/25] hpsa: stop zeroing reset_cmds_out and ioaccel_cmds_out during rescan Don Brace
                   ` (25 more replies)
  0 siblings, 26 replies; 107+ messages in thread
From: Don Brace @ 2015-10-28 22:04 UTC (permalink / raw)
  To: scott.teel, Kevin.Barnett, scott.benesh, james.bottomley, hch,
	Justin.Lindley, elliott
  Cc: linux-scsi

These patches are based on Linus's tree

The changes are:
 - corrected issue with dev_printk
 - add driver requested rescans
 - stop rescans on memory allocation failures and
   skip over unresponsive devices
 - correct 0 byte READ(6)/WRITE(6) transfers
 - correct issues when looking at CISS_REPORT_PHYS data
 - correct mapping of ioaccel2 chain blocks
 - make hpsa_get_device_id more generic
 - add more information to messages
 - simplify device exposure checks
 - simplify hpsa_update_scsi_device
 - add function is_logical_device
 - simplify hpsa_figure_bus_target_lun
 - split out scsi_add_device scsi_remove_device calls
 - add in sas transport class for HBA devices
 - add in physical target resets
 - eliminate fake lun0 enclosures
 - add polling for PT RAID devices
 - disable report lu data caching

Changes from initial upload:
 - changed hpsa_scsi_dev_t.devtype to unsigned
 - changed driver initiated rescan messages
 - changed atomic_t to int from ctlr_info.reset_in_progress
 - added hpsa-stop-zeroing-reset-cmds-out-during-rescan
 - added hpsa-remove-unused-function
 - added hpsa-fix-multiple-issues-in-path_info_show

---

Don Brace (13):
      hpsa: stop zeroing reset_cmds_out and ioaccel_cmds_out during rescan
      hpsa: remove unused hpsa_tag_discard_error_bits
      hpsa: check for null arguments to dev_printk
      hpsa: fix null device issues
      hpsa: allow driver requested rescans
      hpsa: abandon rescans on memory alloaction failures.
      hpsa: correct transfer length for 6 byte read/write commands
      hpsa: fix hpsa_adjust_hpsa_scsi_table
      hpsa: correct check for non-disk devices
      hpsa: correct ioaccel2 sg chain len
      hpsa: enhance hpsa_get_device_id
      hpsa: enhance device messages
      hpsa: bump the driver version

Kevin Barnett (6):
      hpsa: simplify check for device exposure
      hpsa: simplify update scsi devices
      hpsa: add function is_logical_device
      hpsa: refactor hpsa_figure_bus_target_lun
      hpsa: move scsi_add_device and scsi_remove_device calls to new function
      hpsa: add in sas transport class

Rasmus Villemoes (1):
      hpsa: fix multiple issues in path_info_show

Scott Teel (5):
      hpsa: fix physical target reset
      External array LUNs must use target and lun numbers assigned by the
      hpsa: eliminate fake lun0 enclosures
      hpsa: add discovery polling for PT RAID devices.
      hpsa: disable report lun data caching


 drivers/block/cciss.h   |    1 
 drivers/scsi/hpsa.c     | 1289 ++++++++++++++++++++++++++++++++++++++---------
 drivers/scsi/hpsa.h     |   47 +-
 drivers/scsi/hpsa_cmd.h |   30 +
 4 files changed, 1118 insertions(+), 249 deletions(-)

--
Signature

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

* [PATCH 1 01/25] hpsa: stop zeroing reset_cmds_out and ioaccel_cmds_out during rescan
  2015-10-28 22:04 [PATCH 1 00/25] hpsa updates Don Brace
@ 2015-10-28 22:04 ` Don Brace
  2015-10-29 13:25   ` Tomas Henzl
  2015-10-30  7:45   ` Hannes Reinecke
  2015-10-28 22:04 ` [PATCH 1 02/25] hpsa: remove unused hpsa_tag_discard_error_bits Don Brace
                   ` (24 subsequent siblings)
  25 siblings, 2 replies; 107+ messages in thread
From: Don Brace @ 2015-10-28 22:04 UTC (permalink / raw)
  To: scott.teel, Kevin.Barnett, scott.benesh, james.bottomley, hch,
	Justin.Lindley, elliott
  Cc: linux-scsi

pulling the rug out from under the reset handler
likewise for ioaccel_cmds_out

Signed-off-by: Don Brace <don.brace@pmcs.com>
---
 drivers/scsi/hpsa.c |    2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
index 40669f8..e60c652 100644
--- a/drivers/scsi/hpsa.c
+++ b/drivers/scsi/hpsa.c
@@ -3673,8 +3673,6 @@ static void hpsa_get_ioaccel_drive_info(struct ctlr_info *h,
 				DRIVE_CMDS_RESERVED_FOR_FW;
 	else
 		dev->queue_depth = DRIVE_QUEUE_DEPTH; /* conservative */
-	atomic_set(&dev->ioaccel_cmds_out, 0);
-	atomic_set(&dev->reset_cmds_out, 0);
 }
 
 static void hpsa_get_path_info(struct hpsa_scsi_dev_t *this_device,


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

* [PATCH 1 02/25] hpsa: remove unused hpsa_tag_discard_error_bits
  2015-10-28 22:04 [PATCH 1 00/25] hpsa updates Don Brace
  2015-10-28 22:04 ` [PATCH 1 01/25] hpsa: stop zeroing reset_cmds_out and ioaccel_cmds_out during rescan Don Brace
@ 2015-10-28 22:04 ` Don Brace
  2015-10-29 13:26   ` Tomas Henzl
                     ` (2 more replies)
  2015-10-28 22:04 ` [PATCH 1 03/25] hpsa: check for null arguments to dev_printk Don Brace
                   ` (23 subsequent siblings)
  25 siblings, 3 replies; 107+ messages in thread
From: Don Brace @ 2015-10-28 22:04 UTC (permalink / raw)
  To: scott.teel, Kevin.Barnett, scott.benesh, james.bottomley, hch,
	Justin.Lindley, elliott
  Cc: linux-scsi

This function is no longer used.

Signed-off-by: Don Brace <don.brace@pmcs.com>
---
 drivers/scsi/hpsa.c |   12 ++----------
 1 file changed, 2 insertions(+), 10 deletions(-)

diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
index e60c652..864fb03 100644
--- a/drivers/scsi/hpsa.c
+++ b/drivers/scsi/hpsa.c
@@ -230,6 +230,8 @@ static int fill_cmd(struct CommandList *c, u8 cmd, struct ctlr_info *h,
 	int cmd_type);
 static void hpsa_free_cmd_pool(struct ctlr_info *h);
 #define VPD_PAGE (1 << 8)
+#define HPSA_PERF_ERROR_BITS ((1 << DIRECT_LOOKUP_SHIFT) - 1)
+#define HPSA_SIMPLE_ERROR_BITS 0x03
 
 static int hpsa_scsi_queue_command(struct Scsi_Host *h, struct scsi_cmnd *cmd);
 static void hpsa_scan_start(struct Scsi_Host *);
@@ -6438,16 +6440,6 @@ static inline void finish_cmd(struct CommandList *c)
 		complete(c->waiting);
 }
 
-
-static inline u32 hpsa_tag_discard_error_bits(struct ctlr_info *h, u32 tag)
-{
-#define HPSA_PERF_ERROR_BITS ((1 << DIRECT_LOOKUP_SHIFT) - 1)
-#define HPSA_SIMPLE_ERROR_BITS 0x03
-	if (unlikely(!(h->transMethod & CFGTBL_Trans_Performant)))
-		return tag & ~HPSA_SIMPLE_ERROR_BITS;
-	return tag & ~HPSA_PERF_ERROR_BITS;
-}
-
 /* process completion of an indexed ("direct lookup") command */
 static inline void process_indexed_cmd(struct ctlr_info *h,
 	u32 raw_tag)


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

* [PATCH 1 03/25] hpsa: check for null arguments to dev_printk
  2015-10-28 22:04 [PATCH 1 00/25] hpsa updates Don Brace
  2015-10-28 22:04 ` [PATCH 1 01/25] hpsa: stop zeroing reset_cmds_out and ioaccel_cmds_out during rescan Don Brace
  2015-10-28 22:04 ` [PATCH 1 02/25] hpsa: remove unused hpsa_tag_discard_error_bits Don Brace
@ 2015-10-28 22:04 ` Don Brace
  2015-10-29 13:41   ` Tomas Henzl
                     ` (2 more replies)
  2015-10-28 22:04 ` [PATCH 1 04/25] hpsa: fix null device issues Don Brace
                   ` (22 subsequent siblings)
  25 siblings, 3 replies; 107+ messages in thread
From: Don Brace @ 2015-10-28 22:04 UTC (permalink / raw)
  To: scott.teel, Kevin.Barnett, scott.benesh, james.bottomley, hch,
	Justin.Lindley, elliott
  Cc: linux-scsi

Check for NULLs.

Signed-off-by: Don Brace <don.brace@pmcs.com>
---
 drivers/scsi/hpsa.c |    6 ++++++
 drivers/scsi/hpsa.h |    2 +-
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
index 864fb03..6b6e9bb 100644
--- a/drivers/scsi/hpsa.c
+++ b/drivers/scsi/hpsa.c
@@ -1139,6 +1139,12 @@ static int hpsa_find_target_lun(struct ctlr_info *h,
 static inline void hpsa_show_dev_msg(const char *level, struct ctlr_info *h,
 	struct hpsa_scsi_dev_t *dev, char *description)
 {
+	if (dev == NULL)
+		return;
+
+	if (h == NULL || h->pdev == NULL || h->scsi_host == NULL)
+		return;
+
 	dev_printk(level, &h->pdev->dev,
 			"scsi %d:%d:%d:%d: %s %s %.8s %.16s RAID-%s SSDSmartPathCap%c En%c Exp=%d\n",
 			h->scsi_host->host_no, dev->bus, dev->target, dev->lun,
diff --git a/drivers/scsi/hpsa.h b/drivers/scsi/hpsa.h
index 27debb3..d6c4ebf 100644
--- a/drivers/scsi/hpsa.h
+++ b/drivers/scsi/hpsa.h
@@ -34,7 +34,7 @@ struct access_method {
 };
 
 struct hpsa_scsi_dev_t {
-	int devtype;
+	unsigned int devtype;
 	int bus, target, lun;		/* as presented to the OS */
 	unsigned char scsi3addr[8];	/* as presented to the HW */
 #define RAID_CTLR_LUNID "\0\0\0\0\0\0\0\0"


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

* [PATCH 1 04/25] hpsa: fix null device issues
  2015-10-28 22:04 [PATCH 1 00/25] hpsa updates Don Brace
                   ` (2 preceding siblings ...)
  2015-10-28 22:04 ` [PATCH 1 03/25] hpsa: check for null arguments to dev_printk Don Brace
@ 2015-10-28 22:04 ` Don Brace
  2015-10-29 14:06   ` Tomas Henzl
  2015-10-30  7:49   ` Hannes Reinecke
  2015-10-28 22:05 ` [PATCH 1 05/25] hpsa: allow driver requested rescans Don Brace
                   ` (21 subsequent siblings)
  25 siblings, 2 replies; 107+ messages in thread
From: Don Brace @ 2015-10-28 22:04 UTC (permalink / raw)
  To: scott.teel, Kevin.Barnett, scott.benesh, james.bottomley, hch,
	Justin.Lindley, elliott
  Cc: linux-scsi

Signed-off-by: Don Brace <don.brace@pmcs.com>
---
 drivers/scsi/hpsa.c |   25 ++++++++++++++++++++-----
 1 file changed, 20 insertions(+), 5 deletions(-)

diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
index 6b6e9bb..3fe8a18 100644
--- a/drivers/scsi/hpsa.c
+++ b/drivers/scsi/hpsa.c
@@ -1136,7 +1136,7 @@ static int hpsa_find_target_lun(struct ctlr_info *h,
 	return !found;
 }
 
-static inline void hpsa_show_dev_msg(const char *level, struct ctlr_info *h,
+static void hpsa_show_dev_msg(const char *level, struct ctlr_info *h,
 	struct hpsa_scsi_dev_t *dev, char *description)
 {
 	if (dev == NULL)
@@ -1423,6 +1423,9 @@ static int hpsa_scsi_find_entry(struct hpsa_scsi_dev_t *needle,
 #define DEVICE_CHANGED 1
 #define DEVICE_SAME 2
 #define DEVICE_UPDATED 3
+	if (needle == NULL)
+		return DEVICE_NOT_FOUND;
+
 	for (i = 0; i < haystack_size; i++) {
 		if (haystack[i] == NULL) /* previously removed. */
 			continue;
@@ -1574,6 +1577,9 @@ static void hpsa_figure_phys_disk_ptrs(struct ctlr_info *h,
 				total_disks_per_row;
 	int qdepth;
 
+	if (logical_drive == NULL)
+		return;
+
 	if (nraid_map_entries > RAID_MAP_MAX_ENTRIES)
 		nraid_map_entries = RAID_MAP_MAX_ENTRIES;
 
@@ -1585,6 +1591,8 @@ static void hpsa_figure_phys_disk_ptrs(struct ctlr_info *h,
 		if (!logical_drive->offload_config)
 			continue;
 		for (j = 0; j < ndevices; j++) {
+			if (dev[j] == NULL)
+				continue;
 			if (dev[j]->devtype != TYPE_DISK)
 				continue;
 			if (is_logical_dev_addr_mode(dev[j]->scsi3addr))
@@ -1628,6 +1636,8 @@ static void hpsa_update_log_drive_phys_drive_ptrs(struct ctlr_info *h,
 	int i;
 
 	for (i = 0; i < ndevices; i++) {
+		if (dev[i] == NULL)
+			continue;
 		if (dev[i]->devtype != TYPE_DISK)
 			continue;
 		if (!is_logical_dev_addr_mode(dev[i]->scsi3addr))
@@ -1743,8 +1753,11 @@ static void adjust_hpsa_scsi_table(struct ctlr_info *h, int hostno,
 	/* Now that h->dev[]->phys_disk[] is coherent, we can enable
 	 * any logical drives that need it enabled.
 	 */
-	for (i = 0; i < h->ndevices; i++)
+	for (i = 0; i < h->ndevices; i++) {
+		if (h->dev[i] == NULL)
+			continue;
 		h->dev[i]->offload_enabled = h->dev[i]->offload_to_be_enabled;
+	}
 
 	spin_unlock_irqrestore(&h->devlock, flags);
 
@@ -1769,6 +1782,8 @@ static void adjust_hpsa_scsi_table(struct ctlr_info *h, int hostno,
 	sh = h->scsi_host;
 	/* Notify scsi mid layer of any removed devices */
 	for (i = 0; i < nremoved; i++) {
+		if (removed[i] == NULL)
+			continue;
 		if (removed[i]->expose_state & HPSA_SCSI_ADD) {
 			struct scsi_device *sdev =
 				scsi_device_lookup(sh, removed[i]->bus,
@@ -1792,18 +1807,18 @@ static void adjust_hpsa_scsi_table(struct ctlr_info *h, int hostno,
 
 	/* Notify scsi mid layer of any added devices */
 	for (i = 0; i < nadded; i++) {
+		if (added[i] == NULL)
+			continue;
 		if (!(added[i]->expose_state & HPSA_SCSI_ADD))
 			continue;
 		if (scsi_add_device(sh, added[i]->bus,
 			added[i]->target, added[i]->lun) == 0)
 			continue;
-		hpsa_show_dev_msg(KERN_WARNING, h, added[i],
-					"addition failed, device not added.");
+		dev_warn(&h->pdev->dev, "addition failed, device not added.");
 		/* now we have to remove it from h->dev,
 		 * since it didn't get added to scsi mid layer
 		 */
 		fixup_botched_add(h, added[i]);
-		added[i] = NULL;
 	}
 
 free_and_out:


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

* [PATCH 1 05/25] hpsa: allow driver requested rescans
  2015-10-28 22:04 [PATCH 1 00/25] hpsa updates Don Brace
                   ` (3 preceding siblings ...)
  2015-10-28 22:04 ` [PATCH 1 04/25] hpsa: fix null device issues Don Brace
@ 2015-10-28 22:05 ` Don Brace
  2015-10-30  7:51   ` Hannes Reinecke
  2015-10-28 22:05 ` [PATCH 1 06/25] hpsa: abandon rescans on memory alloaction failures Don Brace
                   ` (20 subsequent siblings)
  25 siblings, 1 reply; 107+ messages in thread
From: Don Brace @ 2015-10-28 22:05 UTC (permalink / raw)
  To: scott.teel, Kevin.Barnett, scott.benesh, james.bottomley, hch,
	Justin.Lindley, elliott
  Cc: linux-scsi

Reviewed-by: Scott Teel <scott.teel@pmcs.com>
Reviewed-by: Justin Lindley <justin.lindley@pmcs.com>
Reviewed-by: Kevin Barnett <kevin.barnett@pmcs.com>
Reviewed-by: Tomas Henzl <thenzl@redhat.com>
Signed-off-by: Don Brace <don.brace@pmcs.com>
---
 drivers/scsi/hpsa.c |   17 +++++++++++++++--
 drivers/scsi/hpsa.h |    1 +
 2 files changed, 16 insertions(+), 2 deletions(-)

diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
index 3fe8a18..a3f671c 100644
--- a/drivers/scsi/hpsa.c
+++ b/drivers/scsi/hpsa.c
@@ -1819,6 +1819,7 @@ static void adjust_hpsa_scsi_table(struct ctlr_info *h, int hostno,
 		 * since it didn't get added to scsi mid layer
 		 */
 		fixup_botched_add(h, added[i]);
+		h->drv_req_rescan = 1;
 	}
 
 free_and_out:
@@ -3760,9 +3761,13 @@ static void hpsa_update_scsi_devices(struct ctlr_info *h, int hostno)
 	}
 	memset(lunzerobits, 0, sizeof(lunzerobits));
 
+	h->drv_req_rescan = 0; /* cancel scheduled rescan - we're doing it. */
+
 	if (hpsa_gather_lun_info(h, physdev_list, &nphysicals,
-			logdev_list, &nlogicals))
+			logdev_list, &nlogicals)) {
+		h->drv_req_rescan = 1;
 		goto out;
+	}
 
 	/* We might see up to the maximum number of logical and physical disks
 	 * plus external target devices, and a device for the local RAID
@@ -3783,6 +3788,7 @@ static void hpsa_update_scsi_devices(struct ctlr_info *h, int hostno)
 		if (!currentsd[i]) {
 			dev_warn(&h->pdev->dev, "out of memory at %s:%d\n",
 				__FILE__, __LINE__);
+			h->drv_req_rescan = 1;
 			goto out;
 		}
 		ndev_allocated++;
@@ -3810,8 +3816,10 @@ static void hpsa_update_scsi_devices(struct ctlr_info *h, int hostno)
 
 		/* Get device type, vendor, model, device id */
 		if (hpsa_update_device_info(h, lunaddrbytes, tmpdevice,
-							&is_OBDR))
+							&is_OBDR)) {
+			h->drv_req_rescan = 1;
 			continue; /* skip it if we can't talk to it. */
+		}
 		figure_bus_target_lun(h, lunaddrbytes, tmpdevice);
 		hpsa_update_device_supports_aborts(h, tmpdevice, lunaddrbytes);
 		this_device = currentsd[ncurrent];
@@ -7871,6 +7879,11 @@ static void hpsa_ack_ctlr_events(struct ctlr_info *h)
  */
 static int hpsa_ctlr_needs_rescan(struct ctlr_info *h)
 {
+	if (h->drv_req_rescan) {
+		h->drv_req_rescan = 0;
+		return 1;
+	}
+
 	if (!(h->fw_support & MISC_FW_EVENT_NOTIFY))
 		return 0;
 
diff --git a/drivers/scsi/hpsa.h b/drivers/scsi/hpsa.h
index d6c4ebf..b173c0e 100644
--- a/drivers/scsi/hpsa.h
+++ b/drivers/scsi/hpsa.h
@@ -262,6 +262,7 @@ struct ctlr_info {
 	spinlock_t offline_device_lock;
 	struct list_head offline_device_list;
 	int	acciopath_status;
+	int	drv_req_rescan;
 	int	raid_offload_debug;
 	int	needs_abort_tags_swizzled;
 	struct workqueue_struct *resubmit_wq;


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

* [PATCH 1 06/25] hpsa: abandon rescans on memory alloaction failures.
  2015-10-28 22:04 [PATCH 1 00/25] hpsa updates Don Brace
                   ` (4 preceding siblings ...)
  2015-10-28 22:05 ` [PATCH 1 05/25] hpsa: allow driver requested rescans Don Brace
@ 2015-10-28 22:05 ` Don Brace
  2015-10-30  7:53   ` Hannes Reinecke
  2015-10-28 22:05 ` [PATCH 1 07/25] hpsa: correct transfer length for 6 byte read/write commands Don Brace
                   ` (19 subsequent siblings)
  25 siblings, 1 reply; 107+ messages in thread
From: Don Brace @ 2015-10-28 22:05 UTC (permalink / raw)
  To: scott.teel, Kevin.Barnett, scott.benesh, james.bottomley, hch,
	Justin.Lindley, elliott
  Cc: linux-scsi

Abandon and reschedule rescan process only if device inquiries
fail due to mem alloc failures, which are likely to occur for
all devices.

Otherwise, skip device if inquiry fails for other reasons,
and continue rescanning process for other devices.

Reviewed-by: Scott Teel <scott.teel@pmcs.com>
Reviewed-by: Justin Lindley <justin.lindley@pmcs.com>
Reviewed-by: Kevin Barnett <kevin.barnett@pmcs.com>
Reviewed-by: Tomas Henzl <thenzl@redhat.com>
Signed-off-by: Don Brace <don.brace@pmcs.com>
---
 drivers/scsi/hpsa.c |   24 +++++++++++++++++++-----
 1 file changed, 19 insertions(+), 5 deletions(-)

diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
index a3f671c..ecc6ada 100644
--- a/drivers/scsi/hpsa.c
+++ b/drivers/scsi/hpsa.c
@@ -3375,10 +3375,13 @@ static int hpsa_update_device_info(struct ctlr_info *h,
 
 	unsigned char *inq_buff;
 	unsigned char *obdr_sig;
+	int rc = 0;
 
 	inq_buff = kzalloc(OBDR_TAPE_INQ_SIZE, GFP_KERNEL);
-	if (!inq_buff)
+	if (!inq_buff) {
+		rc = -ENOMEM;
 		goto bail_out;
+	}
 
 	/* Do an inquiry to the device to see what it is. */
 	if (hpsa_scsi_do_inquiry(h, scsi3addr, 0, inq_buff,
@@ -3386,6 +3389,7 @@ static int hpsa_update_device_info(struct ctlr_info *h,
 		/* Inquiry failed (msg printed already) */
 		dev_err(&h->pdev->dev,
 			"hpsa_update_device_info: inquiry failed\n");
+		rc = 1;
 		goto bail_out;
 	}
 
@@ -3435,7 +3439,7 @@ static int hpsa_update_device_info(struct ctlr_info *h,
 
 bail_out:
 	kfree(inq_buff);
-	return 1;
+	return rc;
 }
 
 static void hpsa_update_device_supports_aborts(struct ctlr_info *h,
@@ -3803,6 +3807,7 @@ static void hpsa_update_scsi_devices(struct ctlr_info *h, int hostno)
 	n_ext_target_devs = 0;
 	for (i = 0; i < nphysicals + nlogicals + 1; i++) {
 		u8 *lunaddrbytes, is_OBDR = 0;
+		int rc = 0;
 
 		/* Figure out where the LUN ID info is coming from */
 		lunaddrbytes = figure_lunaddrbytes(h, raid_ctlr_position,
@@ -3815,11 +3820,20 @@ static void hpsa_update_scsi_devices(struct ctlr_info *h, int hostno)
 				continue;
 
 		/* Get device type, vendor, model, device id */
-		if (hpsa_update_device_info(h, lunaddrbytes, tmpdevice,
-							&is_OBDR)) {
+		rc = hpsa_update_device_info(h, lunaddrbytes, tmpdevice,
+							&is_OBDR);
+		if (rc == -ENOMEM) {
+			dev_warn(&h->pdev->dev,
+				"Out of memory, rescan deferred.\n");
 			h->drv_req_rescan = 1;
-			continue; /* skip it if we can't talk to it. */
+			goto out;
 		}
+		if (rc) {
+			dev_warn(&h->pdev->dev,
+				"Inquiry failed, skipping device.\n");
+			continue;
+		}
+
 		figure_bus_target_lun(h, lunaddrbytes, tmpdevice);
 		hpsa_update_device_supports_aborts(h, tmpdevice, lunaddrbytes);
 		this_device = currentsd[ncurrent];


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

* [PATCH 1 07/25] hpsa: correct transfer length for 6 byte read/write commands
  2015-10-28 22:04 [PATCH 1 00/25] hpsa updates Don Brace
                   ` (5 preceding siblings ...)
  2015-10-28 22:05 ` [PATCH 1 06/25] hpsa: abandon rescans on memory alloaction failures Don Brace
@ 2015-10-28 22:05 ` Don Brace
  2015-10-30  7:54   ` Hannes Reinecke
  2015-10-28 22:05 ` [PATCH 1 08/25] hpsa: fix hpsa_adjust_hpsa_scsi_table Don Brace
                   ` (18 subsequent siblings)
  25 siblings, 1 reply; 107+ messages in thread
From: Don Brace @ 2015-10-28 22:05 UTC (permalink / raw)
  To: scott.teel, Kevin.Barnett, scott.benesh, james.bottomley, hch,
	Justin.Lindley, elliott
  Cc: linux-scsi

handle block counts of 0. Cleanup block and block count calculations.

Reviewed-by: Scott Teel <scott.teel@pmcs.com>
Reviewed-by: Justin Lindley <justin.lindley@pmcs.com>
Reviewed-by: Kevin Barnett <kevin.barnett@pmcs.com>
Reviewed-by: Tomas Henzl <thenzl@redhat.com>
Signed-off-by: Don Brace <don.brace@pmcs.com>
---
 drivers/scsi/hpsa.c |   19 ++++++-------------
 1 file changed, 6 insertions(+), 13 deletions(-)

diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
index ecc6ada..ced0d4c 100644
--- a/drivers/scsi/hpsa.c
+++ b/drivers/scsi/hpsa.c
@@ -4021,19 +4021,14 @@ static int fixup_ioaccel_cdb(u8 *cdb, int *cdb_len)
 	case READ_6:
 	case READ_12:
 		if (*cdb_len == 6) {
-			block = (((u32) cdb[2]) << 8) | cdb[3];
+			block = get_unaligned_be16(&cdb[2]);
 			block_cnt = cdb[4];
+			if (block_cnt == 0)
+				block_cnt = 256;
 		} else {
 			BUG_ON(*cdb_len != 12);
-			block = (((u32) cdb[2]) << 24) |
-				(((u32) cdb[3]) << 16) |
-				(((u32) cdb[4]) << 8) |
-				cdb[5];
-			block_cnt =
-				(((u32) cdb[6]) << 24) |
-				(((u32) cdb[7]) << 16) |
-				(((u32) cdb[8]) << 8) |
-				cdb[9];
+			block = get_unaligned_be32(&cdb[2]);
+			block_cnt = get_unaligned_be32(&cdb[6]);
 		}
 		if (block_cnt > 0xffff)
 			return IO_ACCEL_INELIGIBLE;
@@ -4419,9 +4414,7 @@ static int hpsa_scsi_ioaccel_raid_map(struct ctlr_info *h,
 	case WRITE_6:
 		is_write = 1;
 	case READ_6:
-		first_block =
-			(((u64) cmd->cmnd[2]) << 8) |
-			cmd->cmnd[3];
+		first_block = get_unaligned_be16(&cmd->cmnd[2]);
 		block_cnt = cmd->cmnd[4];
 		if (block_cnt == 0)
 			block_cnt = 256;


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

* [PATCH 1 08/25] hpsa: fix hpsa_adjust_hpsa_scsi_table
  2015-10-28 22:04 [PATCH 1 00/25] hpsa updates Don Brace
                   ` (6 preceding siblings ...)
  2015-10-28 22:05 ` [PATCH 1 07/25] hpsa: correct transfer length for 6 byte read/write commands Don Brace
@ 2015-10-28 22:05 ` Don Brace
  2015-10-29 14:23   ` Tomas Henzl
  2015-10-30  7:57   ` Hannes Reinecke
  2015-10-28 22:05 ` [PATCH 1 09/25] hpsa: fix physical target reset Don Brace
                   ` (17 subsequent siblings)
  25 siblings, 2 replies; 107+ messages in thread
From: Don Brace @ 2015-10-28 22:05 UTC (permalink / raw)
  To: scott.teel, Kevin.Barnett, scott.benesh, james.bottomley, hch,
	Justin.Lindley, elliott
  Cc: linux-scsi

Fix a NULL pointer issue in the driver when devices are removed
during a reset.

Signed-off-by: Don Brace <don.brace@pmcs.com>
---
 drivers/block/cciss.h |    1 +
 drivers/scsi/hpsa.c   |   16 ++++++++++++++++
 drivers/scsi/hpsa.h   |    1 +
 3 files changed, 18 insertions(+)

diff --git a/drivers/block/cciss.h b/drivers/block/cciss.h
index 7fda30e..f8b8c6b 100644
--- a/drivers/block/cciss.h
+++ b/drivers/block/cciss.h
@@ -155,6 +155,7 @@ struct ctlr_info
 	size_t reply_pool_size;
 	unsigned char reply_pool_wraparound;
 	u32 *blockFetchTable;
+	u8 reset_in_progress;
 };
 
 /*  Defining the diffent access_methods
diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
index ced0d4c..08a761c 100644
--- a/drivers/scsi/hpsa.c
+++ b/drivers/scsi/hpsa.c
@@ -1670,6 +1670,15 @@ static void adjust_hpsa_scsi_table(struct ctlr_info *h, int hostno,
 	int nadded, nremoved;
 	struct Scsi_Host *sh = NULL;
 
+	/*
+	 * A reset can cause a device status to change
+	 * re-schedule the scan to see what happened.
+	 */
+	if (h->reset_in_progress) {
+		h->drv_req_rescan = 1;
+		return;
+	}
+
 	added = kzalloc(sizeof(*added) * HPSA_MAX_DEVICES, GFP_KERNEL);
 	removed = kzalloc(sizeof(*removed) * HPSA_MAX_DEVICES, GFP_KERNEL);
 
@@ -1780,6 +1789,10 @@ static void adjust_hpsa_scsi_table(struct ctlr_info *h, int hostno,
 		goto free_and_out;
 
 	sh = h->scsi_host;
+	if (sh == NULL) {
+		dev_warn(&h->pdev->dev, "%s: scsi_host is null\n", __func__);
+		return;
+	}
 	/* Notify scsi mid layer of any removed devices */
 	for (i = 0; i < nremoved; i++) {
 		if (removed[i] == NULL)
@@ -5243,12 +5256,15 @@ static int hpsa_eh_device_reset_handler(struct scsi_cmnd *scsicmd)
 
 	hpsa_show_dev_msg(KERN_WARNING, h, dev, "resetting");
 
+	h->reset_in_progress = 1;
+
 	/* send a reset to the SCSI LUN which the command was sent to */
 	rc = hpsa_do_reset(h, dev, dev->scsi3addr, HPSA_RESET_TYPE_LUN,
 			   DEFAULT_REPLY_QUEUE);
 	snprintf(msg, sizeof(msg), "reset %s",
 		 rc == 0 ? "completed successfully" : "failed");
 	hpsa_show_dev_msg(KERN_WARNING, h, dev, msg);
+	h->reset_in_progress = 0;
 	return rc == 0 ? SUCCESS : FAILED;
 }
 
diff --git a/drivers/scsi/hpsa.h b/drivers/scsi/hpsa.h
index b173c0e..dc113c1a 100644
--- a/drivers/scsi/hpsa.h
+++ b/drivers/scsi/hpsa.h
@@ -271,6 +271,7 @@ struct ctlr_info {
 	wait_queue_head_t abort_cmd_wait_queue;
 	wait_queue_head_t event_sync_wait_queue;
 	struct mutex reset_mutex;
+	u8 reset_in_progress;
 };
 
 struct offline_device_entry {


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

* [PATCH 1 09/25] hpsa: fix physical target reset
  2015-10-28 22:04 [PATCH 1 00/25] hpsa updates Don Brace
                   ` (7 preceding siblings ...)
  2015-10-28 22:05 ` [PATCH 1 08/25] hpsa: fix hpsa_adjust_hpsa_scsi_table Don Brace
@ 2015-10-28 22:05 ` Don Brace
  2015-10-29 14:30   ` Tomas Henzl
  2015-10-30  7:59   ` Hannes Reinecke
  2015-10-28 22:05 ` [PATCH 1 10/25] hpsa: correct check for non-disk devices Don Brace
                   ` (16 subsequent siblings)
  25 siblings, 2 replies; 107+ messages in thread
From: Don Brace @ 2015-10-28 22:05 UTC (permalink / raw)
  To: scott.teel, Kevin.Barnett, scott.benesh, james.bottomley, hch,
	Justin.Lindley, elliott
  Cc: linux-scsi

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

Set reset type in device_reset_handler to do either
logical unit reset for logical devices, or physical
target reset, for physical devices.

Reviewed-by: Scott Teel <scott.teel@pmcs.com>
Reviewed-by: Justin Lindley <justin.lindley@pmcs.com>
Reviewed-by: Kevin Barnett <kevin.barnett@pmcs.com>
Signed-off-by: Don Brace <don.brace@pmcs.com>
---
 drivers/scsi/hpsa.c |   34 ++++++++++++++++++++++++++++------
 drivers/scsi/hpsa.h |    1 +
 2 files changed, 29 insertions(+), 6 deletions(-)

diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
index 08a761c..67136fb 100644
--- a/drivers/scsi/hpsa.c
+++ b/drivers/scsi/hpsa.c
@@ -2746,9 +2746,8 @@ static int hpsa_send_reset(struct ctlr_info *h, unsigned char *scsi3addr,
 
 
 	/* fill_cmd can't fail here, no data buffer to map. */
-	(void) fill_cmd(c, HPSA_DEVICE_RESET_MSG, h, NULL, 0, 0,
+	(void) fill_cmd(c, reset_type, h, NULL, 0, 0,
 			scsi3addr, TYPE_MSG);
-	c->Request.CDB[1] = reset_type; /* fill_cmd defaults to LUN reset */
 	rc = hpsa_scsi_do_simple_cmd(h, c, reply_queue, NO_TIMEOUT);
 	if (rc) {
 		dev_warn(&h->pdev->dev, "Failed to send reset command\n");
@@ -5216,6 +5215,7 @@ static int hpsa_eh_device_reset_handler(struct scsi_cmnd *scsicmd)
 	int rc;
 	struct ctlr_info *h;
 	struct hpsa_scsi_dev_t *dev;
+	u8 reset_type;
 	char msg[48];
 
 	/* find the controller to which the command to be aborted was sent */
@@ -5254,15 +5254,23 @@ static int hpsa_eh_device_reset_handler(struct scsi_cmnd *scsicmd)
 	if (is_hba_lunid(dev->scsi3addr))
 		return SUCCESS;
 
-	hpsa_show_dev_msg(KERN_WARNING, h, dev, "resetting");
+	if (is_logical_dev_addr_mode(dev->scsi3addr))
+		reset_type = HPSA_DEVICE_RESET_MSG;
+	else
+		reset_type = HPSA_PHYS_TARGET_RESET;
+
+	sprintf(msg, "resetting %s",
+		reset_type == HPSA_DEVICE_RESET_MSG ? "logical " : "physical ");
+	hpsa_show_dev_msg(KERN_WARNING, h, dev, msg);
 
 	h->reset_in_progress = 1;
 
 	/* send a reset to the SCSI LUN which the command was sent to */
-	rc = hpsa_do_reset(h, dev, dev->scsi3addr, HPSA_RESET_TYPE_LUN,
+	rc = hpsa_do_reset(h, dev, dev->scsi3addr, reset_type,
 			   DEFAULT_REPLY_QUEUE);
-	snprintf(msg, sizeof(msg), "reset %s",
-		 rc == 0 ? "completed successfully" : "failed");
+	sprintf(msg, "reset %s %s",
+		reset_type == HPSA_DEVICE_RESET_MSG ? "logical " : "physical ",
+		rc == 0 ? "completed successfully" : "failed");
 	hpsa_show_dev_msg(KERN_WARNING, h, dev, msg);
 	h->reset_in_progress = 0;
 	return rc == 0 ? SUCCESS : FAILED;
@@ -6379,6 +6387,20 @@ static int fill_cmd(struct CommandList *c, u8 cmd, struct ctlr_info *h,
 	} else if (cmd_type == TYPE_MSG) {
 		switch (cmd) {
 
+		case  HPSA_PHYS_TARGET_RESET:
+			c->Request.CDBLen = 16;
+			c->Request.type_attr_dir =
+				TYPE_ATTR_DIR(cmd_type, ATTR_SIMPLE, XFER_NONE);
+			c->Request.Timeout = 0; /* Don't time out */
+			memset(&c->Request.CDB[0], 0, sizeof(c->Request.CDB));
+			c->Request.CDB[0] = HPSA_RESET;
+			c->Request.CDB[1] = HPSA_TARGET_RESET_TYPE;
+			/* Physical target reset needs no control bytes 4-7*/
+			c->Request.CDB[4] = 0x00;
+			c->Request.CDB[5] = 0x00;
+			c->Request.CDB[6] = 0x00;
+			c->Request.CDB[7] = 0x00;
+			break;
 		case  HPSA_DEVICE_RESET_MSG:
 			c->Request.CDBLen = 16;
 			c->Request.type_attr_dir =
diff --git a/drivers/scsi/hpsa.h b/drivers/scsi/hpsa.h
index dc113c1a..04f98eb 100644
--- a/drivers/scsi/hpsa.h
+++ b/drivers/scsi/hpsa.h
@@ -285,6 +285,7 @@ struct offline_device_entry {
 #define HPSA_RESET_TYPE_BUS 0x01
 #define HPSA_RESET_TYPE_TARGET 0x03
 #define HPSA_RESET_TYPE_LUN 0x04
+#define HPSA_PHYS_TARGET_RESET 0x99 /* not defined by cciss spec */
 #define HPSA_MSG_SEND_RETRY_LIMIT 10
 #define HPSA_MSG_SEND_RETRY_INTERVAL_MSECS (10000)
 


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

* [PATCH 1 10/25] hpsa: correct check for non-disk devices
  2015-10-28 22:04 [PATCH 1 00/25] hpsa updates Don Brace
                   ` (8 preceding siblings ...)
  2015-10-28 22:05 ` [PATCH 1 09/25] hpsa: fix physical target reset Don Brace
@ 2015-10-28 22:05 ` Don Brace
  2015-10-29 14:37   ` Tomas Henzl
  2015-10-30  8:01   ` Hannes Reinecke
  2015-10-28 22:05 ` [PATCH 1 11/25] hpsa: correct ioaccel2 sg chain len Don Brace
                   ` (15 subsequent siblings)
  25 siblings, 2 replies; 107+ messages in thread
From: Don Brace @ 2015-10-28 22:05 UTC (permalink / raw)
  To: scott.teel, Kevin.Barnett, scott.benesh, james.bottomley, hch,
	Justin.Lindley, elliott
  Cc: linux-scsi

The driver is using two MACROs which seemingly are looking in
the wrong location for the device_flags returned from
CISS_REPORT_PHYS. Both MACROs, NON_DISK_PHYS_DEV and
PHYS_IOACCEL, are using the pointer returned from figure_lunaddrbytes
which is the address of the LUN.lunid element in
the extended CISS_REPORT_PHYS.  But the MACROS are using offsets
beyond the range of the element (offset 17 of an 8 byte element).

These MACROs actually are looking at the correct location but
they fail static checker analysis. It also will not work
if any new elements are added to the extended LUN structure.

Change the code to use the structure elements directly
since this MACRO is only used in one location.

Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Reviewed-by: Scott Teel <scott.teel@pmcs.com>
Reviewed-by: Justin Lindley <justin.lindley@pmcs.com>
Reviewed-by: Kevin Barnett <kevin.barnett@pmcs.com>
Signed-off-by: Don Brace <don.brace@pmcs.com>
---
 drivers/scsi/hpsa.c     |   28 +++++++++++++++-------------
 drivers/scsi/hpsa_cmd.h |    2 --
 2 files changed, 15 insertions(+), 15 deletions(-)

diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
index 67136fb..3973fb3 100644
--- a/drivers/scsi/hpsa.c
+++ b/drivers/scsi/hpsa.c
@@ -3690,19 +3690,18 @@ static u8 *figure_lunaddrbytes(struct ctlr_info *h, int raid_ctlr_position,
 /* get physical drive ioaccel handle and queue depth */
 static void hpsa_get_ioaccel_drive_info(struct ctlr_info *h,
 		struct hpsa_scsi_dev_t *dev,
-		u8 *lunaddrbytes,
+		struct ReportExtendedLUNdata *rlep, int rle_index,
 		struct bmic_identify_physical_device *id_phys)
 {
 	int rc;
-	struct ext_report_lun_entry *rle =
-		(struct ext_report_lun_entry *) lunaddrbytes;
+	struct ext_report_lun_entry *rle = &rlep->LUN[rle_index];
 
 	dev->ioaccel_handle = rle->ioaccel_handle;
-	if (PHYS_IOACCEL(lunaddrbytes) && dev->ioaccel_handle)
+	if ((rle->device_flags & 0x08) && dev->ioaccel_handle)
 		dev->hba_ioaccel_enabled = 1;
 	memset(id_phys, 0, sizeof(*id_phys));
-	rc = hpsa_bmic_id_physical_device(h, lunaddrbytes,
-			GET_BMIC_DRIVE_NUMBER(lunaddrbytes), id_phys,
+	rc = hpsa_bmic_id_physical_device(h, &rle->lunid[0],
+			GET_BMIC_DRIVE_NUMBER(&rle->lunid[0]), id_phys,
 			sizeof(*id_phys));
 	if (!rc)
 		/* Reserve space for FW operations */
@@ -3716,11 +3715,12 @@ static void hpsa_get_ioaccel_drive_info(struct ctlr_info *h,
 }
 
 static void hpsa_get_path_info(struct hpsa_scsi_dev_t *this_device,
-	u8 *lunaddrbytes,
+	struct ReportExtendedLUNdata *rlep, int rle_index,
 	struct bmic_identify_physical_device *id_phys)
 {
-	if (PHYS_IOACCEL(lunaddrbytes)
-		&& this_device->ioaccel_handle)
+	struct ext_report_lun_entry *rle = &rlep->LUN[rle_index];
+
+	if ((rle->device_flags & 0x08) && this_device->ioaccel_handle)
 		this_device->hba_ioaccel_enabled = 1;
 
 	memcpy(&this_device->active_path_index,
@@ -3820,6 +3820,7 @@ static void hpsa_update_scsi_devices(struct ctlr_info *h, int hostno)
 	for (i = 0; i < nphysicals + nlogicals + 1; i++) {
 		u8 *lunaddrbytes, is_OBDR = 0;
 		int rc = 0;
+		int phys_dev_index = i - (raid_ctlr_position == 0);
 
 		/* Figure out where the LUN ID info is coming from */
 		lunaddrbytes = figure_lunaddrbytes(h, raid_ctlr_position,
@@ -3828,7 +3829,8 @@ static void hpsa_update_scsi_devices(struct ctlr_info *h, int hostno)
 		/* skip masked non-disk devices */
 		if (MASKED_DEVICE(lunaddrbytes))
 			if (i < nphysicals + (raid_ctlr_position == 0) &&
-				NON_DISK_PHYS_DEV(lunaddrbytes))
+				(physdev_list->
+				LUN[phys_dev_index].device_flags & 0x01))
 				continue;
 
 		/* Get device type, vendor, model, device id */
@@ -3893,9 +3895,9 @@ static void hpsa_update_scsi_devices(struct ctlr_info *h, int hostno)
 				/* Never use RAID mapper in HBA mode. */
 				this_device->offload_enabled = 0;
 				hpsa_get_ioaccel_drive_info(h, this_device,
-					lunaddrbytes, id_phys);
-				hpsa_get_path_info(this_device, lunaddrbytes,
-							id_phys);
+					physdev_list, phys_dev_index, id_phys);
+				hpsa_get_path_info(this_device,
+					physdev_list, phys_dev_index, id_phys);
 			}
 			ncurrent++;
 			break;
diff --git a/drivers/scsi/hpsa_cmd.h b/drivers/scsi/hpsa_cmd.h
index 47c756b..c2c0737 100644
--- a/drivers/scsi/hpsa_cmd.h
+++ b/drivers/scsi/hpsa_cmd.h
@@ -260,8 +260,6 @@ struct ext_report_lun_entry {
 	u8 wwid[8];
 	u8 device_type;
 	u8 device_flags;
-#define NON_DISK_PHYS_DEV(x) ((x)[17] & 0x01)
-#define PHYS_IOACCEL(x) ((x)[17] & 0x08)
 	u8 lun_count; /* multi-lun device, how many luns */
 	u8 redundant_paths;
 	u32 ioaccel_handle; /* ioaccel1 only uses lower 16 bits */


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

* [PATCH 1 11/25] hpsa: correct ioaccel2 sg chain len
  2015-10-28 22:04 [PATCH 1 00/25] hpsa updates Don Brace
                   ` (9 preceding siblings ...)
  2015-10-28 22:05 ` [PATCH 1 10/25] hpsa: correct check for non-disk devices Don Brace
@ 2015-10-28 22:05 ` Don Brace
  2015-10-29 15:01   ` Tomas Henzl
  2015-10-30  8:01   ` Hannes Reinecke
  2015-10-28 22:05 ` [PATCH 1 12/25] hpsa: simplify check for device exposure Don Brace
                   ` (14 subsequent siblings)
  25 siblings, 2 replies; 107+ messages in thread
From: Don Brace @ 2015-10-28 22:05 UTC (permalink / raw)
  To: scott.teel, Kevin.Barnett, scott.benesh, james.bottomley, hch,
	Justin.Lindley, elliott
  Cc: linux-scsi

Reviewed-by: Scott Teel <scott.teel@pmcs.com>
Reviewed-by: Justin Lindley <justin.lindley@pmcs.com>
Reviewed-by: Kevin Barnett <kevin.barnett@pmcs.com>
Signed-off-by: Don Brace <don.brace@pmcs.com>
---
 drivers/scsi/hpsa.c |    5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
index 3973fb3..ffc0551 100644
--- a/drivers/scsi/hpsa.c
+++ b/drivers/scsi/hpsa.c
@@ -1992,7 +1992,7 @@ static int hpsa_map_ioaccel2_sg_chain_block(struct ctlr_info *h,
 	u32 chain_size;
 
 	chain_block = h->ioaccel2_cmd_sg_list[c->cmdindex];
-	chain_size = le32_to_cpu(cp->data_len);
+	chain_size = le32_to_cpu(cp->sg[0].length);
 	temp64 = pci_map_single(h->pdev, chain_block, chain_size,
 				PCI_DMA_TODEVICE);
 	if (dma_mapping_error(&h->pdev->dev, temp64)) {
@@ -2013,7 +2013,7 @@ static void hpsa_unmap_ioaccel2_sg_chain_block(struct ctlr_info *h,
 
 	chain_sg = cp->sg;
 	temp64 = le64_to_cpu(chain_sg->address);
-	chain_size = le32_to_cpu(cp->data_len);
+	chain_size = le32_to_cpu(cp->sg[0].length);
 	pci_unmap_single(h->pdev, temp64, chain_size, PCI_DMA_TODEVICE);
 }
 
@@ -4324,6 +4324,7 @@ static int hpsa_scsi_ioaccel2_queue_command(struct ctlr_info *h,
 	/* fill in sg elements */
 	if (use_sg > h->ioaccel_maxsg) {
 		cp->sg_count = 1;
+		cp->sg[0].length = cpu_to_le32(use_sg * sizeof(cp->sg[0]));
 		if (hpsa_map_ioaccel2_sg_chain_block(h, cp, c)) {
 			atomic_dec(&phys_disk->ioaccel_cmds_out);
 			scsi_dma_unmap(cmd);


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

* [PATCH 1 12/25] hpsa: simplify check for device exposure
  2015-10-28 22:04 [PATCH 1 00/25] hpsa updates Don Brace
                   ` (10 preceding siblings ...)
  2015-10-28 22:05 ` [PATCH 1 11/25] hpsa: correct ioaccel2 sg chain len Don Brace
@ 2015-10-28 22:05 ` Don Brace
  2015-10-29 15:03   ` Tomas Henzl
  2015-10-30  8:04   ` Hannes Reinecke
  2015-10-28 22:05 ` [PATCH 1 13/25] hpsa: simplify update scsi devices Don Brace
                   ` (13 subsequent siblings)
  25 siblings, 2 replies; 107+ messages in thread
From: Don Brace @ 2015-10-28 22:05 UTC (permalink / raw)
  To: scott.teel, Kevin.Barnett, scott.benesh, james.bottomley, hch,
	Justin.Lindley, elliott
  Cc: linux-scsi

From: Kevin Barnett <kevin.barnett@pmcs.com>

remove macros and cleanup device exposure checking

Reviewed-by: Scott Teel <scott.teel@pmcs.com>
Reviewed-by: Justin Lindley <justin.lindley@pmcs.com>
Reviewed-by: Kevin Barnett <kevin.barnett@pmcs.com>
Signed-off-by: Don Brace <don.brace@pmcs.com>
---
 drivers/scsi/hpsa.c |   25 +++++++++++--------------
 drivers/scsi/hpsa.h |    6 +-----
 2 files changed, 12 insertions(+), 19 deletions(-)

diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
index ffc0551..d011540 100644
--- a/drivers/scsi/hpsa.c
+++ b/drivers/scsi/hpsa.c
@@ -793,8 +793,7 @@ static ssize_t path_info_show(struct device *dev,
 				PATH_STRING_LEN,
 				"PORT: %.2s ",
 				phys_connector);
-		if (hdev->devtype == TYPE_DISK &&
-			hdev->expose_state != HPSA_DO_NOT_EXPOSE) {
+		if (hdev->devtype == TYPE_DISK && hdev->expose_device) {
 			if (box == 0 || box == 0xFF) {
 				output_len += snprintf(path[i] + output_len,
 					PATH_STRING_LEN,
@@ -1156,7 +1155,7 @@ static void hpsa_show_dev_msg(const char *level, struct ctlr_info *h,
 				"RAID-?" : raid_label[dev->raid_level],
 			dev->offload_config ? '+' : '-',
 			dev->offload_enabled ? '+' : '-',
-			dev->expose_state);
+			dev->expose_device);
 }
 
 /* Add an entry into h->dev[] array. */
@@ -1229,7 +1228,7 @@ lun_assigned:
 	added[*nadded] = device;
 	(*nadded)++;
 	hpsa_show_dev_msg(KERN_INFO, h, device,
-		device->expose_state & HPSA_SCSI_ADD ? "added" : "masked");
+		device->expose_device ? "added" : "masked");
 	device->offload_to_be_enabled = device->offload_enabled;
 	device->offload_enabled = 0;
 	return 0;
@@ -1797,7 +1796,7 @@ static void adjust_hpsa_scsi_table(struct ctlr_info *h, int hostno,
 	for (i = 0; i < nremoved; i++) {
 		if (removed[i] == NULL)
 			continue;
-		if (removed[i]->expose_state & HPSA_SCSI_ADD) {
+		if (removed[i]->expose_device) {
 			struct scsi_device *sdev =
 				scsi_device_lookup(sh, removed[i]->bus,
 					removed[i]->target, removed[i]->lun);
@@ -1822,7 +1821,7 @@ static void adjust_hpsa_scsi_table(struct ctlr_info *h, int hostno,
 	for (i = 0; i < nadded; i++) {
 		if (added[i] == NULL)
 			continue;
-		if (!(added[i]->expose_state & HPSA_SCSI_ADD))
+		if (!(added[i]->expose_device))
 			continue;
 		if (scsi_add_device(sh, added[i]->bus,
 			added[i]->target, added[i]->lun) == 0)
@@ -1870,7 +1869,7 @@ static int hpsa_slave_alloc(struct scsi_device *sdev)
 		sdev_id(sdev), sdev->lun);
 	if (likely(sd)) {
 		atomic_set(&sd->ioaccel_cmds_out, 0);
-		sdev->hostdata = (sd->expose_state & HPSA_SCSI_ADD) ? sd : NULL;
+		sdev->hostdata = sd->expose_device ? sd : NULL;
 	} else
 		sdev->hostdata = NULL;
 	spin_unlock_irqrestore(&h->devlock, flags);
@@ -1884,7 +1883,7 @@ static int hpsa_slave_configure(struct scsi_device *sdev)
 	int queue_depth;
 
 	sd = sdev->hostdata;
-	sdev->no_uld_attach = !sd || !(sd->expose_state & HPSA_ULD_ATTACH);
+	sdev->no_uld_attach = !sd || !sd->expose_device;
 
 	if (sd)
 		queue_depth = sd->queue_depth != 0 ?
@@ -3870,12 +3869,10 @@ static void hpsa_update_scsi_devices(struct ctlr_info *h, int hostno)
 
 		/* do not expose masked devices */
 		if (MASKED_DEVICE(lunaddrbytes) &&
-			i < nphysicals + (raid_ctlr_position == 0)) {
-			this_device->expose_state = HPSA_DO_NOT_EXPOSE;
-		} else {
-			this_device->expose_state =
-					HPSA_SG_ATTACH | HPSA_ULD_ATTACH;
-		}
+			i < nphysicals + (raid_ctlr_position == 0))
+			this_device->expose_device = 0;
+		else
+			this_device->expose_device = 1;
 
 		switch (this_device->devtype) {
 		case TYPE_ROM:
diff --git a/drivers/scsi/hpsa.h b/drivers/scsi/hpsa.h
index 04f98eb..a6ead07 100644
--- a/drivers/scsi/hpsa.h
+++ b/drivers/scsi/hpsa.h
@@ -37,6 +37,7 @@ struct hpsa_scsi_dev_t {
 	unsigned int devtype;
 	int bus, target, lun;		/* as presented to the OS */
 	unsigned char scsi3addr[8];	/* as presented to the HW */
+	u8 expose_device;
 #define RAID_CTLR_LUNID "\0\0\0\0\0\0\0\0"
 	unsigned char device_id[16];    /* from inquiry pg. 0x83 */
 	unsigned char vendor[8];        /* bytes 8-15 of inquiry data */
@@ -75,11 +76,6 @@ struct hpsa_scsi_dev_t {
 	struct hpsa_scsi_dev_t *phys_disk[RAID_MAP_MAX_ENTRIES];
 	int nphysical_disks;
 	int supports_aborts;
-#define HPSA_DO_NOT_EXPOSE	0x0
-#define HPSA_SG_ATTACH		0x1
-#define HPSA_ULD_ATTACH		0x2
-#define HPSA_SCSI_ADD		(HPSA_SG_ATTACH | HPSA_ULD_ATTACH)
-	u8 expose_state;
 };
 
 struct reply_queue_buffer {


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

* [PATCH 1 13/25] hpsa: simplify update scsi devices
  2015-10-28 22:04 [PATCH 1 00/25] hpsa updates Don Brace
                   ` (11 preceding siblings ...)
  2015-10-28 22:05 ` [PATCH 1 12/25] hpsa: simplify check for device exposure Don Brace
@ 2015-10-28 22:05 ` Don Brace
  2015-10-29 15:53   ` Tomas Henzl
                     ` (2 more replies)
  2015-10-28 22:05 ` [PATCH 1 14/25] hpsa: add function is_logical_device Don Brace
                   ` (12 subsequent siblings)
  25 siblings, 3 replies; 107+ messages in thread
From: Don Brace @ 2015-10-28 22:05 UTC (permalink / raw)
  To: scott.teel, Kevin.Barnett, scott.benesh, james.bottomley, hch,
	Justin.Lindley, elliott
  Cc: linux-scsi

From: Kevin Barnett <kevin.barnett@pmcs.com>

remove repeated calculation that checks for physical
or logical devices.

Reviewed-by: Scott Teel <scott.teel@pmcs.com>
Reviewed-by: Justin Lindley <justin.lindley@pmcs.com>
Reviewed-by: Kevin Barnett <kevin.barnett@pmcs.com>
Signed-off-by: Don Brace <don.brace@pmcs.com>
---
 drivers/scsi/hpsa.c |   23 ++++++++++++++---------
 drivers/scsi/hpsa.h |    1 +
 2 files changed, 15 insertions(+), 9 deletions(-)

diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
index d011540..7c1a552 100644
--- a/drivers/scsi/hpsa.c
+++ b/drivers/scsi/hpsa.c
@@ -3761,6 +3761,7 @@ static void hpsa_update_scsi_devices(struct ctlr_info *h, int hostno)
 	int ncurrent = 0;
 	int i, n_ext_target_devs, ndevs_to_allocate;
 	int raid_ctlr_position;
+	bool physical_device;
 	DECLARE_BITMAP(lunzerobits, MAX_EXT_TARGETS);
 
 	currentsd = kzalloc(sizeof(*currentsd) * HPSA_MAX_DEVICES, GFP_KERNEL);
@@ -3821,16 +3822,17 @@ static void hpsa_update_scsi_devices(struct ctlr_info *h, int hostno)
 		int rc = 0;
 		int phys_dev_index = i - (raid_ctlr_position == 0);
 
+		physical_device = i < nphysicals + (raid_ctlr_position == 0);
+
 		/* Figure out where the LUN ID info is coming from */
 		lunaddrbytes = figure_lunaddrbytes(h, raid_ctlr_position,
 			i, nphysicals, nlogicals, physdev_list, logdev_list);
 
 		/* skip masked non-disk devices */
-		if (MASKED_DEVICE(lunaddrbytes))
-			if (i < nphysicals + (raid_ctlr_position == 0) &&
-				(physdev_list->
-				LUN[phys_dev_index].device_flags & 0x01))
-				continue;
+		if (physical_device &&
+			MASKED_DEVICE(lunaddrbytes) &&
+			(physdev_list->LUN[phys_dev_index].device_flags & 0x01))
+			continue;
 
 		/* Get device type, vendor, model, device id */
 		rc = hpsa_update_device_info(h, lunaddrbytes, tmpdevice,
@@ -3866,10 +3868,13 @@ static void hpsa_update_scsi_devices(struct ctlr_info *h, int hostno)
 		}
 
 		*this_device = *tmpdevice;
+		this_device->physical_device = physical_device;
 
-		/* do not expose masked devices */
-		if (MASKED_DEVICE(lunaddrbytes) &&
-			i < nphysicals + (raid_ctlr_position == 0))
+		/*
+		 * Expose all devices except for physical devices that
+		 * are masked.
+		 */
+		if (MASKED_DEVICE(lunaddrbytes) && this_device->physical_device)
 			this_device->expose_device = 0;
 		else
 			this_device->expose_device = 1;
@@ -3887,7 +3892,7 @@ static void hpsa_update_scsi_devices(struct ctlr_info *h, int hostno)
 				ncurrent++;
 			break;
 		case TYPE_DISK:
-			if (i < nphysicals + (raid_ctlr_position == 0)) {
+			if (this_device->physical_device) {
 				/* The disk is in HBA mode. */
 				/* Never use RAID mapper in HBA mode. */
 				this_device->offload_enabled = 0;
diff --git a/drivers/scsi/hpsa.h b/drivers/scsi/hpsa.h
index a6ead07..808b520 100644
--- a/drivers/scsi/hpsa.h
+++ b/drivers/scsi/hpsa.h
@@ -37,6 +37,7 @@ struct hpsa_scsi_dev_t {
 	unsigned int devtype;
 	int bus, target, lun;		/* as presented to the OS */
 	unsigned char scsi3addr[8];	/* as presented to the HW */
+	u8 physical_device;
 	u8 expose_device;
 #define RAID_CTLR_LUNID "\0\0\0\0\0\0\0\0"
 	unsigned char device_id[16];    /* from inquiry pg. 0x83 */


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

* [PATCH 1 14/25] hpsa: add function is_logical_device
  2015-10-28 22:04 [PATCH 1 00/25] hpsa updates Don Brace
                   ` (12 preceding siblings ...)
  2015-10-28 22:05 ` [PATCH 1 13/25] hpsa: simplify update scsi devices Don Brace
@ 2015-10-28 22:05 ` Don Brace
  2015-10-29 15:53   ` Tomas Henzl
                     ` (2 more replies)
  2015-10-28 22:06 ` [PATCH 1 15/25] hpsa: enhance hpsa_get_device_id Don Brace
                   ` (11 subsequent siblings)
  25 siblings, 3 replies; 107+ messages in thread
From: Don Brace @ 2015-10-28 22:05 UTC (permalink / raw)
  To: scott.teel, Kevin.Barnett, scott.benesh, james.bottomley, hch,
	Justin.Lindley, elliott
  Cc: linux-scsi

From: Kevin Barnett <kevin.barnett@pmcs.com>

simplify checking for logical/physical devices

Reviewed-by: Scott Teel <scott.teel@pmcs.com>
Reviewed-by: Justin Lindley <justin.lindley@pmcs.com>
Reviewed-by: Kevin Barnett <kevin.barnett@pmcs.com>
Signed-off-by: Don Brace <don.brace@pmcs.com>
---
 drivers/scsi/hpsa.c |   19 ++++++++++++-------
 1 file changed, 12 insertions(+), 7 deletions(-)

diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
index 7c1a552..c1b053f 100644
--- a/drivers/scsi/hpsa.c
+++ b/drivers/scsi/hpsa.c
@@ -619,6 +619,11 @@ static const char * const raid_label[] = { "0", "4", "1(+0)", "5", "5+1", "6",
 #define HPSA_RAID_ADM	6	/* also used for RAID 1+0 ADM */
 #define RAID_UNKNOWN (ARRAY_SIZE(raid_label) - 1)
 
+static inline bool is_logical_device(struct hpsa_scsi_dev_t *device)
+{
+	return !device->physical_device;
+}
+
 static ssize_t raid_level_show(struct device *dev,
 	     struct device_attribute *attr, char *buf)
 {
@@ -639,7 +644,7 @@ static ssize_t raid_level_show(struct device *dev,
 	}
 
 	/* Is this even a logical drive? */
-	if (!is_logical_dev_addr_mode(hdev->scsi3addr)) {
+	if (!is_logical_device(hdev)) {
 		spin_unlock_irqrestore(&h->lock, flags);
 		l = snprintf(buf, PAGE_SIZE, "N/A\n");
 		return l;
@@ -773,8 +778,8 @@ static ssize_t path_info_show(struct device *dev,
 				scsi_device_type(hdev->devtype));
 
 		if (is_ext_target(h, hdev) ||
-			(hdev->devtype == TYPE_RAID) ||
-			is_logical_dev_addr_mode(hdev->scsi3addr)) {
+			hdev->devtype == TYPE_RAID ||
+			is_logical_device(hdev)) {
 			output_len += snprintf(path[i] + output_len,
 						PATH_STRING_LEN, "%s\n",
 						active);
@@ -1594,7 +1599,7 @@ static void hpsa_figure_phys_disk_ptrs(struct ctlr_info *h,
 				continue;
 			if (dev[j]->devtype != TYPE_DISK)
 				continue;
-			if (is_logical_dev_addr_mode(dev[j]->scsi3addr))
+			if (is_logical_device(dev[j]))
 				continue;
 			if (dev[j]->ioaccel_handle != dd[i].ioaccel_handle)
 				continue;
@@ -1639,7 +1644,7 @@ static void hpsa_update_log_drive_phys_drive_ptrs(struct ctlr_info *h,
 			continue;
 		if (dev[i]->devtype != TYPE_DISK)
 			continue;
-		if (!is_logical_dev_addr_mode(dev[i]->scsi3addr))
+		if (!is_logical_device(dev[i]))
 			continue;
 
 		/*
@@ -2246,7 +2251,7 @@ static void process_ioaccel2_completion(struct ctlr_info *h,
 	 * the normal I/O path so the controller can handle whatever's
 	 * wrong.
 	 */
-	if (is_logical_dev_addr_mode(dev->scsi3addr) &&
+	if (is_logical_device(dev) &&
 		c2->error_data.serv_response ==
 			IOACCEL2_SERV_RESPONSE_FAILURE) {
 		if (c2->error_data.status ==
@@ -2366,7 +2371,7 @@ static void complete_scsi_command(struct CommandList *cp)
 		 * the normal I/O path so the controller can handle whatever's
 		 * wrong.
 		 */
-		if (is_logical_dev_addr_mode(dev->scsi3addr)) {
+		if (is_logical_device(dev)) {
 			if (ei->CommandStatus == CMD_IOACCEL_DISABLED)
 				dev->offload_enabled = 0;
 			return hpsa_retry_cmd(h, cp);


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

* [PATCH 1 15/25] hpsa: enhance hpsa_get_device_id
  2015-10-28 22:04 [PATCH 1 00/25] hpsa updates Don Brace
                   ` (13 preceding siblings ...)
  2015-10-28 22:05 ` [PATCH 1 14/25] hpsa: add function is_logical_device Don Brace
@ 2015-10-28 22:06 ` Don Brace
  2015-10-29 16:04   ` Tomas Henzl
                     ` (2 more replies)
  2015-10-28 22:06 ` [PATCH 1 16/25] hpsa: refactor hpsa_figure_bus_target_lun Don Brace
                   ` (10 subsequent siblings)
  25 siblings, 3 replies; 107+ messages in thread
From: Don Brace @ 2015-10-28 22:06 UTC (permalink / raw)
  To: scott.teel, Kevin.Barnett, scott.benesh, james.bottomley, hch,
	Justin.Lindley, elliott
  Cc: linux-scsi

use an index into vpd data for SAS/SATA drives

Reviewed-by: Scott Teel <scott.teel@pmcs.com>
Reviewed-by: Justin Lindley <justin.lindley@pmcs.com>
Reviewed-by: Kevin Barnett <kevin.barnett@pmcs.com>
Signed-off-by: Don Brace <don.brace@pmcs.com>
---
 drivers/scsi/hpsa.c |   23 ++++++++++++++++++++---
 1 file changed, 20 insertions(+), 3 deletions(-)

diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
index c1b053f..1361414 100644
--- a/drivers/scsi/hpsa.c
+++ b/drivers/scsi/hpsa.c
@@ -3137,7 +3137,7 @@ out:
 
 /* Get the device id from inquiry page 0x83 */
 static int hpsa_get_device_id(struct ctlr_info *h, unsigned char *scsi3addr,
-	unsigned char *device_id, int buflen)
+	unsigned char *device_id, int index, int buflen)
 {
 	int rc;
 	unsigned char *buf;
@@ -3149,8 +3149,10 @@ static int hpsa_get_device_id(struct ctlr_info *h, unsigned char *scsi3addr,
 		return -ENOMEM;
 	rc = hpsa_scsi_do_inquiry(h, scsi3addr, VPD_PAGE | 0x83, buf, 64);
 	if (rc == 0)
-		memcpy(device_id, &buf[8], buflen);
+		memcpy(device_id, &buf[index], buflen);
+
 	kfree(buf);
+
 	return rc != 0;
 }
 
@@ -3379,6 +3381,18 @@ static int hpsa_device_supports_aborts(struct ctlr_info *h,
 	return rc;
 }
 
+static void sanitize_inquiry_string(unsigned char *s, int len)
+{
+	bool terminated = false;
+
+	for (; len > 0; (--len, ++s)) {
+		if (*s == 0)
+			terminated = true;
+		if (terminated || *s < 0x20 || *s > 0x7e)
+			*s = ' ';
+	}
+}
+
 static int hpsa_update_device_info(struct ctlr_info *h,
 	unsigned char scsi3addr[], struct hpsa_scsi_dev_t *this_device,
 	unsigned char *is_OBDR_device)
@@ -3409,6 +3423,9 @@ static int hpsa_update_device_info(struct ctlr_info *h,
 		goto bail_out;
 	}
 
+	sanitize_inquiry_string(&inq_buff[8], 8);
+	sanitize_inquiry_string(&inq_buff[16], 16);
+
 	this_device->devtype = (inq_buff[0] & 0x1f);
 	memcpy(this_device->scsi3addr, scsi3addr, 8);
 	memcpy(this_device->vendor, &inq_buff[8],
@@ -3417,7 +3434,7 @@ static int hpsa_update_device_info(struct ctlr_info *h,
 		sizeof(this_device->model));
 	memset(this_device->device_id, 0,
 		sizeof(this_device->device_id));
-	hpsa_get_device_id(h, scsi3addr, this_device->device_id,
+	hpsa_get_device_id(h, scsi3addr, this_device->device_id, 8,
 		sizeof(this_device->device_id));
 
 	if (this_device->devtype == TYPE_DISK &&


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

* [PATCH 1 16/25] hpsa: refactor hpsa_figure_bus_target_lun
  2015-10-28 22:04 [PATCH 1 00/25] hpsa updates Don Brace
                   ` (14 preceding siblings ...)
  2015-10-28 22:06 ` [PATCH 1 15/25] hpsa: enhance hpsa_get_device_id Don Brace
@ 2015-10-28 22:06 ` Don Brace
  2015-10-29 16:27   ` Tomas Henzl
  2015-10-30  8:09   ` Hannes Reinecke
  2015-10-28 22:06 ` [PATCH 1 17/25] hpsa: move scsi_add_device and scsi_remove_device calls to new function Don Brace
                   ` (9 subsequent siblings)
  25 siblings, 2 replies; 107+ messages in thread
From: Don Brace @ 2015-10-28 22:06 UTC (permalink / raw)
  To: scott.teel, Kevin.Barnett, scott.benesh, james.bottomley, hch,
	Justin.Lindley, elliott
  Cc: linux-scsi

From: Kevin Barnett <kevin.barnett@pmcs.com>

setup for sas transport. Need to set the
bus and target accordingly.

Reviewed-by: Scott Teel <scott.teel@pmcs.com>
Reviewed-by: Justin Lindley <justin.lindley@pmcs.com>
Reviewed-by: Kevin Barnett <kevin.barnett@pmcs.com>
Signed-off-by: Don Brace <don.brace@pmcs.com>
---
 drivers/scsi/hpsa.c |   25 ++++++++++++-------------
 drivers/scsi/hpsa.h |    5 +++++
 2 files changed, 17 insertions(+), 13 deletions(-)

diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
index 1361414..24b3c8c 100644
--- a/drivers/scsi/hpsa.c
+++ b/drivers/scsi/hpsa.c
@@ -3521,38 +3521,37 @@ static int is_ext_target(struct ctlr_info *h, struct hpsa_scsi_dev_t *device)
 	return 0;
 }
 
-/* Helper function to assign bus, target, lun mapping of devices.
- * 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.
+/*
+ * Helper function to assign bus, target, lun mapping of devices.
  * Logical drive target and lun are assigned at this time, but
  * physical device lun and target assignment are deferred (assigned
  * in hpsa_find_target_lun, called by hpsa_scsi_add_entry.)
- */
+*/
 static void figure_bus_target_lun(struct ctlr_info *h,
 	u8 *lunaddrbytes, struct hpsa_scsi_dev_t *device)
 {
-	u32 lunid = le32_to_cpu(*((__le32 *) lunaddrbytes));
+	u32 lunid = get_unaligned_le32(lunaddrbytes);
 
 	if (!is_logical_dev_addr_mode(lunaddrbytes)) {
 		/* physical device, target and lun filled in later */
 		if (is_hba_lunid(lunaddrbytes))
-			hpsa_set_bus_target_lun(device, 3, 0, lunid & 0x3fff);
+			hpsa_set_bus_target_lun(device,
+					HPSA_HBA_BUS, 0, lunid & 0x3fff);
 		else
 			/* defer target, lun assignment for physical devices */
-			hpsa_set_bus_target_lun(device, 2, -1, -1);
+			hpsa_set_bus_target_lun(device,
+					HPSA_PHYSICAL_DEVICE_BUS, -1, -1);
 		return;
 	}
 	/* It's a logical device */
 	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
-		 */
 		hpsa_set_bus_target_lun(device,
-			1, (lunid >> 16) & 0x3fff, lunid & 0x00ff);
+			HPSA_EXTERNAL_RAID_VOLUME_BUS, (lunid >> 16) & 0x3fff,
+			lunid & 0x00ff);
 		return;
 	}
-	hpsa_set_bus_target_lun(device, 0, 0, lunid & 0x3fff);
+	hpsa_set_bus_target_lun(device, HPSA_RAID_VOLUME_BUS,
+				0, lunid & 0x3fff);
 }
 
 /*
diff --git a/drivers/scsi/hpsa.h b/drivers/scsi/hpsa.h
index 808b520..38d5534 100644
--- a/drivers/scsi/hpsa.h
+++ b/drivers/scsi/hpsa.h
@@ -367,6 +367,11 @@ struct offline_device_entry {
 #define IOACCEL2_INBOUND_POSTQ_64_LOW	0xd0
 #define IOACCEL2_INBOUND_POSTQ_64_HI	0xd4
 
+#define HPSA_PHYSICAL_DEVICE_BUS	0
+#define HPSA_RAID_VOLUME_BUS		1
+#define HPSA_EXTERNAL_RAID_VOLUME_BUS	2
+#define HPSA_HBA_BUS			3
+
 /*
 	Send the command to the hardware
 */


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

* [PATCH 1 17/25] hpsa: move scsi_add_device and scsi_remove_device calls to new function
  2015-10-28 22:04 [PATCH 1 00/25] hpsa updates Don Brace
                   ` (15 preceding siblings ...)
  2015-10-28 22:06 ` [PATCH 1 16/25] hpsa: refactor hpsa_figure_bus_target_lun Don Brace
@ 2015-10-28 22:06 ` Don Brace
  2015-10-29 16:37   ` Tomas Henzl
                     ` (2 more replies)
  2015-10-28 22:06 ` [PATCH 1 18/25] External array LUNs must use target and lun numbers assigned by the Don Brace
                   ` (8 subsequent siblings)
  25 siblings, 3 replies; 107+ messages in thread
From: Don Brace @ 2015-10-28 22:06 UTC (permalink / raw)
  To: scott.teel, Kevin.Barnett, scott.benesh, james.bottomley, hch,
	Justin.Lindley, elliott
  Cc: linux-scsi

From: Kevin Barnett <kevin.barnett@pmcs.com>

preparation for adding the sas transport class

Reviewed-by: Scott Teel <scott.teel@pmcs.com>
Reviewed-by: Justin Lindley <justin.lindley@pmcs.com>
Reviewed-by: Kevin Barnett <kevin.barnett@pmcs.com>
Signed-off-by: Don Brace <don.brace@pmcs.com>
---
 drivers/scsi/hpsa.c |   65 +++++++++++++++++++++++++++++++--------------------
 1 file changed, 39 insertions(+), 26 deletions(-)

diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
index 24b3c8c..06207e2 100644
--- a/drivers/scsi/hpsa.c
+++ b/drivers/scsi/hpsa.c
@@ -1660,6 +1660,37 @@ static void hpsa_update_log_drive_phys_drive_ptrs(struct ctlr_info *h,
 	}
 }
 
+static int hpsa_add_device(struct ctlr_info *h, struct hpsa_scsi_dev_t *device)
+{
+	int rc = 0;
+
+	rc = scsi_add_device(h->scsi_host, device->bus,
+					device->target, device->lun);
+	return rc;
+}
+
+static void hpsa_remove_device(struct ctlr_info *h,
+			struct hpsa_scsi_dev_t *device)
+{
+	struct scsi_device *sdev = NULL;
+
+	sdev = scsi_device_lookup(h->scsi_host, device->bus,
+						device->target, device->lun);
+
+	if (sdev) {
+		scsi_remove_device(sdev);
+		scsi_device_put(sdev);
+	} else {
+		/*
+		 * We don't expect to get here.  Future commands
+		 * to this device will get a selection timeout as
+		 * if the device were gone.
+		 */
+		hpsa_show_dev_msg(KERN_WARNING, h, device,
+					"didn't find device for removal.");
+	}
+}
+
 static void adjust_hpsa_scsi_table(struct ctlr_info *h, int hostno,
 	struct hpsa_scsi_dev_t *sd[], int nsds)
 {
@@ -1672,7 +1703,6 @@ static void adjust_hpsa_scsi_table(struct ctlr_info *h, int hostno,
 	unsigned long flags;
 	struct hpsa_scsi_dev_t **added, **removed;
 	int nadded, nremoved;
-	struct Scsi_Host *sh = NULL;
 
 	/*
 	 * A reset can cause a device status to change
@@ -1792,46 +1822,29 @@ static void adjust_hpsa_scsi_table(struct ctlr_info *h, int hostno,
 	if (hostno == -1 || !changes)
 		goto free_and_out;
 
-	sh = h->scsi_host;
-	if (sh == NULL) {
-		dev_warn(&h->pdev->dev, "%s: scsi_host is null\n", __func__);
-		return;
-	}
 	/* Notify scsi mid layer of any removed devices */
 	for (i = 0; i < nremoved; i++) {
 		if (removed[i] == NULL)
 			continue;
-		if (removed[i]->expose_device) {
-			struct scsi_device *sdev =
-				scsi_device_lookup(sh, removed[i]->bus,
-					removed[i]->target, removed[i]->lun);
-			if (sdev != NULL) {
-				scsi_remove_device(sdev);
-				scsi_device_put(sdev);
-			} else {
-				/*
-				 * We don't expect to get here.
-				 * future cmds to this device will get selection
-				 * timeout as if the device was gone.
-				 */
-				hpsa_show_dev_msg(KERN_WARNING, h, removed[i],
-					"didn't find device for removal.");
-			}
-		}
+		if (removed[i]->expose_device)
+			hpsa_remove_device(h, removed[i]);
 		kfree(removed[i]);
 		removed[i] = NULL;
 	}
 
 	/* Notify scsi mid layer of any added devices */
 	for (i = 0; i < nadded; i++) {
+		int rc = 0;
+
 		if (added[i] == NULL)
 			continue;
 		if (!(added[i]->expose_device))
 			continue;
-		if (scsi_add_device(sh, added[i]->bus,
-			added[i]->target, added[i]->lun) == 0)
+		rc = hpsa_add_device(h, added[i]);
+		if (!rc)
 			continue;
-		dev_warn(&h->pdev->dev, "addition failed, device not added.");
+		dev_warn(&h->pdev->dev,
+			"addition failed %d, device not added.", rc);
 		/* now we have to remove it from h->dev,
 		 * since it didn't get added to scsi mid layer
 		 */


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

* [PATCH 1 18/25] External array LUNs must use target and lun numbers assigned by the
  2015-10-28 22:04 [PATCH 1 00/25] hpsa updates Don Brace
                   ` (16 preceding siblings ...)
  2015-10-28 22:06 ` [PATCH 1 17/25] hpsa: move scsi_add_device and scsi_remove_device calls to new function Don Brace
@ 2015-10-28 22:06 ` Don Brace
  2015-10-29 19:41   ` Matthew R. Ochs
                     ` (2 more replies)
  2015-10-28 22:06 ` [PATCH 1 19/25] hpsa: eliminate fake lun0 enclosures Don Brace
                   ` (7 subsequent siblings)
  25 siblings, 3 replies; 107+ messages in thread
From: Don Brace @ 2015-10-28 22:06 UTC (permalink / raw)
  To: scott.teel, Kevin.Barnett, scott.benesh, james.bottomley, hch,
	Justin.Lindley, elliott
  Cc: linux-scsi

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

external array. So the driver must treat these differently from
local LUNs when assigning lun/target.

LUN's 'model' field has been used to detect Lun types that need
special treatment, but the desire is to eliminate the need to reference
specific array models, and support any external array.

Pass-through RAID (PTRAID) luns are not luns of the local controller,
so they are not reported in LUN count of command 'ID controller'.
However, they ARE reported in "Report logical Luns" command.
Local luns are listed first, then PTRAID LUNs.

The number of luns from "Report LUNs" in excess of those reported by
'ID controller' are therefore the PTRAID LUNS.

We can now remove function is_ext_target, and the 'white list'
array of supported model names.

Reviewed-by: Scott Teel <scott.teel@pmcs.com>
Reviewed-by: Justin Lindley <justin.lindley@pmcs.com>
Reviewed-by: Kevin Barnett <kevin.barnett@pmcs.com>
Signed-off-by: Don Brace <don.brace@pmcs.com>
---
 drivers/scsi/hpsa.c     |  141 ++++++++++++++++++++++++++++++++++++++---------
 drivers/scsi/hpsa.h     |    1 
 drivers/scsi/hpsa_cmd.h |   11 ++++
 3 files changed, 127 insertions(+), 26 deletions(-)

diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
index 06207e2..11ea3e5 100644
--- a/drivers/scsi/hpsa.c
+++ b/drivers/scsi/hpsa.c
@@ -276,7 +276,6 @@ static int hpsa_scsi_ioaccel_queue_command(struct ctlr_info *h,
 static void hpsa_command_resubmit_worker(struct work_struct *work);
 static u32 lockup_detected(struct ctlr_info *h);
 static int detect_controller_lockup(struct ctlr_info *h);
-static int is_ext_target(struct ctlr_info *h, struct hpsa_scsi_dev_t *device);
 
 static inline struct ctlr_info *sdev_to_hba(struct scsi_device *sdev)
 {
@@ -777,7 +776,7 @@ static ssize_t path_info_show(struct device *dev,
 				hdev->bus, hdev->target, hdev->lun,
 				scsi_device_type(hdev->devtype));
 
-		if (is_ext_target(h, hdev) ||
+		if (hdev->external ||
 			hdev->devtype == TYPE_RAID ||
 			is_logical_device(hdev)) {
 			output_len += snprintf(path[i] + output_len,
@@ -3037,6 +3036,35 @@ out:
 	return rc;
 }
 
+static int hpsa_bmic_id_controller(struct ctlr_info *h,
+	struct bmic_identify_controller *buf, size_t bufsize)
+{
+	int rc = IO_OK;
+	struct CommandList *c;
+	struct ErrorInfo *ei;
+
+	c = cmd_alloc(h);
+
+	rc = fill_cmd(c, BMIC_IDENTIFY_CONTROLLER, h, buf, bufsize,
+		0, RAID_CTLR_LUNID, TYPE_CMD);
+	if (rc)
+		goto out;
+
+	rc = hpsa_scsi_do_simple_cmd_with_retry(h, c,
+		PCI_DMA_FROMDEVICE, NO_TIMEOUT);
+	if (rc)
+		goto out;
+	ei = c->err_info;
+	if (ei->CommandStatus != 0 && ei->CommandStatus != CMD_DATA_UNDERRUN) {
+		hpsa_scsi_interpret_error(h, c);
+		rc = -1;
+	}
+out:
+	cmd_free(h, c);
+	return rc;
+}
+
+
 static int hpsa_bmic_id_physical_device(struct ctlr_info *h,
 		unsigned char scsi3addr[], u16 bmic_device_index,
 		struct bmic_identify_physical_device *buf, size_t bufsize)
@@ -3513,27 +3541,6 @@ static void hpsa_update_device_supports_aborts(struct ctlr_info *h,
 	}
 }
 
-static unsigned char *ext_target_model[] = {
-	"MSA2012",
-	"MSA2024",
-	"MSA2312",
-	"MSA2324",
-	"P2000 G3 SAS",
-	"MSA 2040 SAS",
-	NULL,
-};
-
-static int is_ext_target(struct ctlr_info *h, struct hpsa_scsi_dev_t *device)
-{
-	int i;
-
-	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.
  * Logical drive target and lun are assigned at this time, but
@@ -3557,7 +3564,7 @@ static void figure_bus_target_lun(struct ctlr_info *h,
 		return;
 	}
 	/* It's a logical device */
-	if (is_ext_target(h, device)) {
+	if (device->external) {
 		hpsa_set_bus_target_lun(device,
 			HPSA_EXTERNAL_RAID_VOLUME_BUS, (lunid >> 16) & 0x3fff,
 			lunid & 0x00ff);
@@ -3591,7 +3598,7 @@ static int add_ext_target_dev(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_ext_target(h, tmpdevice))
+	if (!tmpdevice->external)
 		return 0; /* Only external target devices have this problem. */
 
 	if (tmpdevice->lun == 0) /* if lun is 0, then we have a lun 0. */
@@ -3650,6 +3657,29 @@ static int hpsa_get_pdisk_of_ioaccel2(struct ctlr_info *h,
 	return 0;
 }
 
+static int  figure_external_status(struct ctlr_info *h, int raid_ctlr_position,
+	int i, int nphysicals, int nlocal_logicals)
+{
+	/* In report logicals, local logicals are listed first,
+	* then any externals.
+	*/
+	int logicals_start = nphysicals + (raid_ctlr_position == 0);
+
+	if (i == raid_ctlr_position)
+		return 0;
+
+	if (i < logicals_start)
+		return 0;
+
+	/* i is in logicals range, but still within local logicals */
+	if ((i - nphysicals - (raid_ctlr_position == 0)) < nlocal_logicals)
+		return 0;
+
+	return 1; /* it's an external lun */
+}
+
+
+
 /*
  * Do CISS_REPORT_PHYS and CISS_REPORT_LOG.  Data is returned in physdev,
  * logdev.  The number of luns in physdev and logdev are returned in
@@ -3773,6 +3803,32 @@ static void hpsa_get_path_info(struct hpsa_scsi_dev_t *this_device,
 		sizeof(this_device->bay));
 }
 
+/* get number of local logical disks. */
+static int hpsa_set_local_logical_count(struct ctlr_info *h,
+	struct bmic_identify_controller *id_ctlr,
+	u32 *nlocals)
+{
+	int rc;
+
+	if (!id_ctlr) {
+		dev_warn(&h->pdev->dev, "%s: id_ctlr buffer is NULL.\n",
+			__func__);
+		return -ENOMEM;
+	}
+	memset(id_ctlr, 0, sizeof(*id_ctlr));
+	rc = hpsa_bmic_id_controller(h, id_ctlr, sizeof(*id_ctlr));
+	if (!rc)
+		if (id_ctlr->configured_logical_drive_count < 256)
+			*nlocals = id_ctlr->configured_logical_drive_count;
+		else
+			*nlocals = le16_to_cpu(
+					id_ctlr->extended_logical_unit_count);
+	else
+		*nlocals = -1;
+	return rc;
+}
+
+
 static void hpsa_update_scsi_devices(struct ctlr_info *h, int hostno)
 {
 	/* the idea here is we could get notified
@@ -3788,8 +3844,10 @@ static void hpsa_update_scsi_devices(struct ctlr_info *h, int hostno)
 	struct ReportExtendedLUNdata *physdev_list = NULL;
 	struct ReportLUNdata *logdev_list = NULL;
 	struct bmic_identify_physical_device *id_phys = NULL;
+	struct bmic_identify_controller *id_ctlr = NULL;
 	u32 nphysicals = 0;
 	u32 nlogicals = 0;
+	u32 nlocal_logicals = 0;
 	u32 ndev_allocated = 0;
 	struct hpsa_scsi_dev_t **currentsd, *this_device, *tmpdevice;
 	int ncurrent = 0;
@@ -3803,9 +3861,10 @@ static void hpsa_update_scsi_devices(struct ctlr_info *h, int hostno)
 	logdev_list = kzalloc(sizeof(*logdev_list), GFP_KERNEL);
 	tmpdevice = kzalloc(sizeof(*tmpdevice), GFP_KERNEL);
 	id_phys = kzalloc(sizeof(*id_phys), GFP_KERNEL);
+	id_ctlr = kzalloc(sizeof(*id_ctlr), GFP_KERNEL);
 
 	if (!currentsd || !physdev_list || !logdev_list ||
-		!tmpdevice || !id_phys) {
+		!tmpdevice || !id_phys || !id_ctlr) {
 		dev_err(&h->pdev->dev, "out of memory\n");
 		goto out;
 	}
@@ -3819,6 +3878,13 @@ static void hpsa_update_scsi_devices(struct ctlr_info *h, int hostno)
 		goto out;
 	}
 
+	/* Set number of local logicals (non PTRAID) */
+	if (hpsa_set_local_logical_count(h, id_ctlr, &nlocal_logicals)) {
+		dev_warn(&h->pdev->dev,
+			"%s: Can't determine number of local logical devices.\n",
+			__func__);
+	}
+
 	/* 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.
@@ -3883,6 +3949,11 @@ static void hpsa_update_scsi_devices(struct ctlr_info *h, int hostno)
 			continue;
 		}
 
+		/* Determine if this is a lun from an external target array */
+		tmpdevice->external =
+			figure_external_status(h, raid_ctlr_position, i,
+						nphysicals, nlocal_logicals);
+
 		figure_bus_target_lun(h, lunaddrbytes, tmpdevice);
 		hpsa_update_device_supports_aborts(h, tmpdevice, lunaddrbytes);
 		this_device = currentsd[ncurrent];
@@ -3966,6 +4037,7 @@ out:
 	kfree(currentsd);
 	kfree(physdev_list);
 	kfree(logdev_list);
+	kfree(id_ctlr);
 	kfree(id_phys);
 }
 
@@ -6418,6 +6490,23 @@ static int fill_cmd(struct CommandList *c, u8 cmd, struct ctlr_info *h,
 			c->Request.CDB[7] = (size >> 16) & 0xFF;
 			c->Request.CDB[8] = (size >> 8) & 0XFF;
 			break;
+		case BMIC_IDENTIFY_CONTROLLER:
+			c->Request.CDBLen = 10;
+			c->Request.type_attr_dir =
+				TYPE_ATTR_DIR(cmd_type, ATTR_SIMPLE, XFER_READ);
+			c->Request.Timeout = 0;
+			c->Request.CDB[0] = BMIC_READ;
+			c->Request.CDB[1] = 0;
+			c->Request.CDB[2] = 0;
+			c->Request.CDB[3] = 0;
+			c->Request.CDB[4] = 0;
+			c->Request.CDB[5] = 0;
+			c->Request.CDB[6] = BMIC_IDENTIFY_CONTROLLER;
+			c->Request.CDB[7] = (size >> 16) & 0xFF;
+			c->Request.CDB[8] = (size >> 8) & 0XFF;
+			c->Request.CDB[9] = 0;
+			break;
+
 		default:
 			dev_warn(&h->pdev->dev, "unknown command 0x%c\n", cmd);
 			BUG();
diff --git a/drivers/scsi/hpsa.h b/drivers/scsi/hpsa.h
index 38d5534..0cf147b 100644
--- a/drivers/scsi/hpsa.h
+++ b/drivers/scsi/hpsa.h
@@ -77,6 +77,7 @@ struct hpsa_scsi_dev_t {
 	struct hpsa_scsi_dev_t *phys_disk[RAID_MAP_MAX_ENTRIES];
 	int nphysical_disks;
 	int supports_aborts;
+	int external;   /* 1-from external array 0-not <0-unknown */
 };
 
 struct reply_queue_buffer {
diff --git a/drivers/scsi/hpsa_cmd.h b/drivers/scsi/hpsa_cmd.h
index c2c0737..c83eaf1 100644
--- a/drivers/scsi/hpsa_cmd.h
+++ b/drivers/scsi/hpsa_cmd.h
@@ -286,6 +286,7 @@ struct SenseSubsystem_info {
 #define BMIC_FLASH_FIRMWARE 0xF7
 #define BMIC_SENSE_CONTROLLER_PARAMETERS 0x64
 #define BMIC_IDENTIFY_PHYSICAL_DEVICE 0x15
+#define BMIC_IDENTIFY_CONTROLLER 0x11
 
 /* Command List Structure */
 union SCSI3Addr {
@@ -682,6 +683,16 @@ struct hpsa_pci_info {
 	u32		board_id;
 };
 
+struct bmic_identify_controller {
+	u8	configured_logical_drive_count;	/* offset 0 */
+	u8	pad1[153];
+	__le16	extended_logical_unit_count;	/* offset 154 */
+	u8	pad2[136];
+	u8	controller_mode;	/* offset 292 */
+	u8	pad3[32];
+};
+
+
 struct bmic_identify_physical_device {
 	u8    scsi_bus;          /* SCSI Bus number on controller */
 	u8    scsi_id;           /* SCSI ID on this bus */


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

* [PATCH 1 19/25] hpsa: eliminate fake lun0 enclosures
  2015-10-28 22:04 [PATCH 1 00/25] hpsa updates Don Brace
                   ` (17 preceding siblings ...)
  2015-10-28 22:06 ` [PATCH 1 18/25] External array LUNs must use target and lun numbers assigned by the Don Brace
@ 2015-10-28 22:06 ` Don Brace
  2015-10-29 20:05   ` Matthew R. Ochs
                     ` (2 more replies)
  2015-10-28 22:06 ` [PATCH 1 20/25] hpsa: add discovery polling for PT RAID devices Don Brace
                   ` (6 subsequent siblings)
  25 siblings, 3 replies; 107+ messages in thread
From: Don Brace @ 2015-10-28 22:06 UTC (permalink / raw)
  To: scott.teel, Kevin.Barnett, scott.benesh, james.bottomley, hch,
	Justin.Lindley, elliott
  Cc: linux-scsi

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

We don't need to create fake enclosure devices at Lun0
in external target array configurations anymore.
This was done to support Pre-SCSI rev 5 controllers
that didn't suppoprt report luns commands, so the
SCSI layer had to scan targets. If there was no
LUN at LUN 0, then the target scan would stop, and
move to the next target.  Lun0 enclosure device
was added to prevent sparsely-numbered LUNs from
being missed.

Reviewed-by: Scott Teel <scott.teel@pmcs.com>
Reviewed-by: Justin Lindley <justin.lindley@pmcs.com>
Reviewed-by: Kevin Barnett <kevin.barnett@pmcs.com>
Signed-off-by: Don Brace <don.brace@pmcs.com>
---
 drivers/scsi/hpsa.c |   68 ---------------------------------------------------
 1 file changed, 68 deletions(-)

diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
index 11ea3e5..8d67648 100644
--- a/drivers/scsi/hpsa.c
+++ b/drivers/scsi/hpsa.c
@@ -3574,60 +3574,6 @@ static void figure_bus_target_lun(struct ctlr_info *h,
 				0, lunid & 0x3fff);
 }
 
-/*
- * If there is no lun 0 on a target, linux won't find any devices.
- * 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[]
- * that we're building up in update_scsi_devices(), below.
- * lunzerobits is a bitmap that tracks which targets already have a
- * lun 0 assigned.
- * Returns 1 if an enclosure was added, 0 if not.
- */
-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 *n_ext_target_devs)
-{
-	unsigned char scsi3addr[8];
-
-	if (test_bit(tmpdevice->target, lunzerobits))
-		return 0; /* There is already a lun 0 on this target. */
-
-	if (!is_logical_dev_addr_mode(lunaddrbytes))
-		return 0; /* It's the logical targets that may lack lun 0. */
-
-	if (!tmpdevice->external)
-		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;
-
-	memset(scsi3addr, 0, 8);
-	scsi3addr[3] = tmpdevice->target;
-	if (is_hba_lunid(scsi3addr))
-		return 0; /* Don't add the RAID controller here. */
-
-	if (is_scsi_rev_5(h))
-		return 0; /* p1210m doesn't need to do this. */
-
-	if (*n_ext_target_devs >= MAX_EXT_TARGETS) {
-		dev_warn(&h->pdev->dev, "Maximum number of external "
-			"target devices exceeded.  Check your hardware "
-			"configuration.");
-		return 0;
-	}
-
-	if (hpsa_update_device_info(h, scsi3addr, this_device, NULL))
-		return 0;
-	(*n_ext_target_devs)++;
-	hpsa_set_bus_target_lun(this_device,
-				tmpdevice->bus, tmpdevice->target, 0);
-	hpsa_update_device_supports_aborts(h, this_device, scsi3addr);
-	set_bit(tmpdevice->target, lunzerobits);
-	return 1;
-}
 
 /*
  * Get address of physical disk used for an ioaccel2 mode command:
@@ -3958,20 +3904,6 @@ static void hpsa_update_scsi_devices(struct ctlr_info *h, int hostno)
 		hpsa_update_device_supports_aborts(h, tmpdevice, lunaddrbytes);
 		this_device = currentsd[ncurrent];
 
-		/*
-		 * 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_ext_target_dev(h, tmpdevice, this_device,
-				lunaddrbytes, lunzerobits,
-				&n_ext_target_devs)) {
-			ncurrent++;
-			this_device = currentsd[ncurrent];
-		}
-
 		*this_device = *tmpdevice;
 		this_device->physical_device = physical_device;
 


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

* [PATCH 1 20/25] hpsa: add discovery polling for PT RAID devices.
  2015-10-28 22:04 [PATCH 1 00/25] hpsa updates Don Brace
                   ` (18 preceding siblings ...)
  2015-10-28 22:06 ` [PATCH 1 19/25] hpsa: eliminate fake lun0 enclosures Don Brace
@ 2015-10-28 22:06 ` Don Brace
  2015-10-29 20:20   ` Matthew R. Ochs
  2015-10-30  8:15   ` Hannes Reinecke
  2015-10-28 22:06 ` [PATCH 1 21/25] hpsa: disable report lun data caching Don Brace
                   ` (5 subsequent siblings)
  25 siblings, 2 replies; 107+ messages in thread
From: Don Brace @ 2015-10-28 22:06 UTC (permalink / raw)
  To: scott.teel, Kevin.Barnett, scott.benesh, james.bottomley, hch,
	Justin.Lindley, elliott
  Cc: linux-scsi

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

There are problems with getting configuration change notification
in pass-through RAID environments.  So, activate flag
h->discovery_polling when one of these devices is detected in
update_scsi_devices.

After discovery_polling is set, execute a report luns from
rescan_controller_worker (every 30 seconds).

If the data from report_luns is different than last
time (binary compare), execute a full rescan via update_scsi_devices.

Reviewed-by: Scott Teel <scott.teel@pmcs.com>
Reviewed-by: Justin Lindley <justin.lindley@pmcs.com>
Reviewed-by: Kevin Barnett <kevin.barnett@pmcs.com>
Signed-off-by: Don Brace <don.brace@pmcs.com>
---
 drivers/scsi/hpsa.c |   68 +++++++++++++++++++++++++++++++++++++++++++++++++++
 drivers/scsi/hpsa.h |    2 ++
 2 files changed, 70 insertions(+)

diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
index 8d67648..e521acd 100644
--- a/drivers/scsi/hpsa.c
+++ b/drivers/scsi/hpsa.c
@@ -276,6 +276,7 @@ static int hpsa_scsi_ioaccel_queue_command(struct ctlr_info *h,
 static void hpsa_command_resubmit_worker(struct work_struct *work);
 static u32 lockup_detected(struct ctlr_info *h);
 static int detect_controller_lockup(struct ctlr_info *h);
+static int hpsa_luns_changed(struct ctlr_info *h);
 
 static inline struct ctlr_info *sdev_to_hba(struct scsi_device *sdev)
 {
@@ -3904,6 +3905,18 @@ static void hpsa_update_scsi_devices(struct ctlr_info *h, int hostno)
 		hpsa_update_device_supports_aborts(h, tmpdevice, lunaddrbytes);
 		this_device = currentsd[ncurrent];
 
+		/* Turn on discovery_polling if there are ext target devices.
+		 * Event-based change notification is unreliable for those.
+		 */
+		if (!h->discovery_polling) {
+			if (tmpdevice->external) {
+				h->discovery_polling = 1;
+				dev_info(&h->pdev->dev,
+					"External target, activate discovery polling.\n");
+			}
+		}
+
+
 		*this_device = *tmpdevice;
 		this_device->physical_device = physical_device;
 
@@ -8022,6 +8035,41 @@ static int hpsa_offline_devices_ready(struct ctlr_info *h)
 	return 0;
 }
 
+static int hpsa_luns_changed(struct ctlr_info *h)
+{
+	int rc = 1; /* assume there are changes */
+	struct ReportLUNdata *logdev = NULL;
+
+	/* if we can't find out if lun data has changed,
+	 * assume that it has.
+	 */
+
+	if (!h->lastlogicals)
+		goto out;
+
+	logdev = kzalloc(sizeof(*logdev), GFP_KERNEL);
+	if (!logdev) {
+		dev_warn(&h->pdev->dev,
+			"Out of memory, can't track lun changes.\n");
+		goto out;
+	}
+	if (hpsa_scsi_do_report_luns(h, 1, logdev, sizeof(*logdev), 0)) {
+		dev_warn(&h->pdev->dev,
+			"report luns failed, can't track lun changes.\n");
+		goto out;
+	}
+	if (memcmp(logdev, h->lastlogicals, sizeof(*logdev))) {
+		dev_info(&h->pdev->dev,
+			"Lun changes detected.\n");
+		memcpy(h->lastlogicals, logdev, sizeof(*logdev));
+		goto out;
+	} else
+		rc = 0; /* no changes detected. */
+out:
+	kfree(logdev);
+	return rc;
+}
+
 static void hpsa_rescan_ctlr_worker(struct work_struct *work)
 {
 	unsigned long flags;
@@ -8037,6 +8085,18 @@ static void hpsa_rescan_ctlr_worker(struct work_struct *work)
 		hpsa_ack_ctlr_events(h);
 		hpsa_scan_start(h->scsi_host);
 		scsi_host_put(h->scsi_host);
+	} else if (h->discovery_polling) {
+		if (hpsa_luns_changed(h)) {
+			struct Scsi_Host *sh = NULL;
+
+			dev_info(&h->pdev->dev,
+				"driver discovery polling rescan.\n");
+			sh = scsi_host_get(h->scsi_host);
+			if (sh != NULL) {
+				hpsa_scan_start(sh);
+				scsi_host_put(sh);
+			}
+		}
 	}
 	spin_lock_irqsave(&h->lock, flags);
 	if (!h->remove_in_progress)
@@ -8277,6 +8337,8 @@ reinit_after_soft_reset:
 
 	/* Enable Accelerated IO path at driver layer */
 	h->acciopath_status = 1;
+	/* Disable discovery polling.*/
+	h->discovery_polling = 0;
 
 
 	/* Turn the interrupts on so we can service requests */
@@ -8284,6 +8346,11 @@ reinit_after_soft_reset:
 
 	hpsa_hba_inquiry(h);
 
+	h->lastlogicals = kzalloc(sizeof(*(h->lastlogicals)), GFP_KERNEL);
+	if (!h->lastlogicals)
+		dev_info(&h->pdev->dev,
+			"Can't track change to report lun data\n");
+
 	/* Monitor the controller for firmware lockups */
 	h->heartbeat_sample_interval = HEARTBEAT_SAMPLE_INTERVAL;
 	INIT_DELAYED_WORK(&h->monitor_ctlr_work, hpsa_monitor_ctlr_worker);
@@ -8368,6 +8435,7 @@ static void hpsa_shutdown(struct pci_dev *pdev)
 	hpsa_flush_cache(h);
 	h->access.set_intr_mask(h, HPSA_INTR_OFF);
 	hpsa_free_irqs(h);			/* init_one 4 */
+	kfree(h->lastlogicals);
 	hpsa_disable_interrupt_mode(h);		/* pci_init 2 */
 }
 
diff --git a/drivers/scsi/hpsa.h b/drivers/scsi/hpsa.h
index 0cf147b..6c82d3c 100644
--- a/drivers/scsi/hpsa.h
+++ b/drivers/scsi/hpsa.h
@@ -262,6 +262,8 @@ struct ctlr_info {
 	int	acciopath_status;
 	int	drv_req_rescan;
 	int	raid_offload_debug;
+	int     discovery_polling;
+	struct  ReportLUNdata *lastlogicals;
 	int	needs_abort_tags_swizzled;
 	struct workqueue_struct *resubmit_wq;
 	struct workqueue_struct *rescan_ctlr_wq;


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

* [PATCH 1 21/25] hpsa: disable report lun data caching
  2015-10-28 22:04 [PATCH 1 00/25] hpsa updates Don Brace
                   ` (19 preceding siblings ...)
  2015-10-28 22:06 ` [PATCH 1 20/25] hpsa: add discovery polling for PT RAID devices Don Brace
@ 2015-10-28 22:06 ` Don Brace
  2015-10-30  8:16   ` Hannes Reinecke
                     ` (2 more replies)
  2015-10-28 22:06 ` [PATCH 1 22/25] hpsa: enhance device messages Don Brace
                   ` (4 subsequent siblings)
  25 siblings, 3 replies; 107+ messages in thread
From: Don Brace @ 2015-10-28 22:06 UTC (permalink / raw)
  To: scott.teel, Kevin.Barnett, scott.benesh, james.bottomley, hch,
	Justin.Lindley, elliott
  Cc: linux-scsi

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

When external target arrays are present, disable the firmware's
normal behavior of returning a cached copy of the report lun data,
and force it to collect new data each time we request a report luns.

This is necessary for external arrays, since there may be no
reliable signal from the external array to the smart array when
lun configuration changes, and thus when driver requests
report luns, it may be stale data.

Use diag options to turn off RPL data caching.

Reviewed-by: Scott Teel <scott.teel@pmcs.com>
Reviewed-by: Justin Lindley <justin.lindley@pmcs.com>
Reviewed-by: Kevin Barnett <kevin.barnett@pmcs.com>
Signed-off-by: Don Brace <don.brace@pmcs.com>
---
 drivers/scsi/hpsa.c     |   86 +++++++++++++++++++++++++++++++++++++++++++++++
 drivers/scsi/hpsa_cmd.h |    3 ++
 2 files changed, 89 insertions(+)

diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
index e521acd..33fd0aa 100644
--- a/drivers/scsi/hpsa.c
+++ b/drivers/scsi/hpsa.c
@@ -276,6 +276,7 @@ static int hpsa_scsi_ioaccel_queue_command(struct ctlr_info *h,
 static void hpsa_command_resubmit_worker(struct work_struct *work);
 static u32 lockup_detected(struct ctlr_info *h);
 static int detect_controller_lockup(struct ctlr_info *h);
+static void hpsa_disable_rld_caching(struct ctlr_info *h);
 static int hpsa_luns_changed(struct ctlr_info *h);
 
 static inline struct ctlr_info *sdev_to_hba(struct scsi_device *sdev)
@@ -6386,6 +6387,24 @@ static int fill_cmd(struct CommandList *c, u8 cmd, struct ctlr_info *h,
 			c->Request.CDB[8] = (size >> 8) & 0xFF;
 			c->Request.CDB[9] = size & 0xFF;
 			break;
+		case BMIC_SENSE_DIAG_OPTIONS:
+			c->Request.CDBLen = 16;
+			c->Request.type_attr_dir =
+				TYPE_ATTR_DIR(cmd_type, ATTR_SIMPLE, XFER_READ);
+			c->Request.Timeout = 0;
+			/* Spec says this should be BMIC_WRITE */
+			c->Request.CDB[0] = BMIC_READ;
+			c->Request.CDB[6] = BMIC_SENSE_DIAG_OPTIONS;
+			break;
+		case BMIC_SET_DIAG_OPTIONS:
+			c->Request.CDBLen = 16;
+			c->Request.type_attr_dir =
+					TYPE_ATTR_DIR(cmd_type,
+						ATTR_SIMPLE, XFER_WRITE);
+			c->Request.Timeout = 0;
+			c->Request.CDB[0] = BMIC_WRITE;
+			c->Request.CDB[6] = BMIC_SET_DIAG_OPTIONS;
+			break;
 		case HPSA_CACHE_FLUSH:
 			c->Request.CDBLen = 12;
 			c->Request.type_attr_dir =
@@ -8086,6 +8105,7 @@ static void hpsa_rescan_ctlr_worker(struct work_struct *work)
 		hpsa_scan_start(h->scsi_host);
 		scsi_host_put(h->scsi_host);
 	} else if (h->discovery_polling) {
+		hpsa_disable_rld_caching(h);
 		if (hpsa_luns_changed(h)) {
 			struct Scsi_Host *sh = NULL;
 
@@ -8423,6 +8443,72 @@ out:
 	kfree(flush_buf);
 }
 
+/* Make controller gather fresh report lun data each time we
+ * send down a report luns request
+ */
+static void hpsa_disable_rld_caching(struct ctlr_info *h)
+{
+	u32 *options;
+	struct CommandList *c;
+	int rc;
+
+	/* Don't bother trying to set diag options if locked up */
+	if (unlikely(h->lockup_detected))
+		return;
+
+	options = kzalloc(sizeof(*options), GFP_KERNEL);
+	if (!options) {
+		dev_err(&h->pdev->dev,
+			"Error: failed to disable rld caching, during alloc.\n");
+		return;
+	}
+
+	c = cmd_alloc(h);
+
+	/* first, get the current diag options settings */
+	if (fill_cmd(c, BMIC_SENSE_DIAG_OPTIONS, h, options, 4, 0,
+		RAID_CTLR_LUNID, TYPE_CMD))
+		goto errout;
+
+	rc = hpsa_scsi_do_simple_cmd_with_retry(h, c,
+		PCI_DMA_FROMDEVICE, NO_TIMEOUT);
+	if ((rc != 0) || (c->err_info->CommandStatus != 0))
+		goto errout;
+
+	/* Now, set the bit for disabling the RLD caching */
+	*options |= HPSA_DIAG_OPTS_DISABLE_RLD_CACHING;
+
+	if (fill_cmd(c, BMIC_SET_DIAG_OPTIONS, h, options, 4, 0,
+		RAID_CTLR_LUNID, TYPE_CMD))
+		goto errout;
+
+	rc = hpsa_scsi_do_simple_cmd_with_retry(h, c,
+		PCI_DMA_TODEVICE, NO_TIMEOUT);
+	if ((rc != 0)  || (c->err_info->CommandStatus != 0))
+		goto errout;
+
+	/* Now verify that it got set: */
+	if (fill_cmd(c, BMIC_SENSE_DIAG_OPTIONS, h, options, 4, 0,
+		RAID_CTLR_LUNID, TYPE_CMD))
+		goto errout;
+
+	rc = hpsa_scsi_do_simple_cmd_with_retry(h, c,
+		PCI_DMA_FROMDEVICE, NO_TIMEOUT);
+	if ((rc != 0)  || (c->err_info->CommandStatus != 0))
+		goto errout;
+
+	if (*options && HPSA_DIAG_OPTS_DISABLE_RLD_CACHING)
+		goto out;
+	else {
+errout:
+		dev_err(&h->pdev->dev,
+			"Error: failed to disable report lun data caching.\n");
+	}
+out:
+	cmd_free(h, c);
+	kfree(options);
+}
+
 static void hpsa_shutdown(struct pci_dev *pdev)
 {
 	struct ctlr_info *h;
diff --git a/drivers/scsi/hpsa_cmd.h b/drivers/scsi/hpsa_cmd.h
index c83eaf1..4910344 100644
--- a/drivers/scsi/hpsa_cmd.h
+++ b/drivers/scsi/hpsa_cmd.h
@@ -287,6 +287,9 @@ struct SenseSubsystem_info {
 #define BMIC_SENSE_CONTROLLER_PARAMETERS 0x64
 #define BMIC_IDENTIFY_PHYSICAL_DEVICE 0x15
 #define BMIC_IDENTIFY_CONTROLLER 0x11
+#define BMIC_SET_DIAG_OPTIONS 0xF4
+#define BMIC_SENSE_DIAG_OPTIONS 0xF5
+#define HPSA_DIAG_OPTS_DISABLE_RLD_CACHING 0x40000000
 
 /* Command List Structure */
 union SCSI3Addr {


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

* [PATCH 1 22/25] hpsa: enhance device messages
  2015-10-28 22:04 [PATCH 1 00/25] hpsa updates Don Brace
                   ` (20 preceding siblings ...)
  2015-10-28 22:06 ` [PATCH 1 21/25] hpsa: disable report lun data caching Don Brace
@ 2015-10-28 22:06 ` Don Brace
  2015-10-30  8:16   ` Hannes Reinecke
                     ` (2 more replies)
  2015-10-28 22:06 ` [PATCH 1 23/25] hpsa: fix multiple issues in path_info_show Don Brace
                   ` (3 subsequent siblings)
  25 siblings, 3 replies; 107+ messages in thread
From: Don Brace @ 2015-10-28 22:06 UTC (permalink / raw)
  To: scott.teel, Kevin.Barnett, scott.benesh, james.bottomley, hch,
	Justin.Lindley, elliott
  Cc: linux-scsi

Reviewed-by: Justin Lindley <justin.lindley@pmcs.com>
Reviewed-by: Scott Teel <scott.teel@pmcs.com>
Reviewed-by: Kevin Barnett <kevin.barnett@pmcs.com>
Signed-off-by: Don Brace <don.brace@pmcs.com>
---
 drivers/scsi/hpsa.c |   45 ++++++++++++++++++++++++++++++++++++++++-----
 1 file changed, 40 insertions(+), 5 deletions(-)

diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
index 33fd0aa..b2418c3 100644
--- a/drivers/scsi/hpsa.c
+++ b/drivers/scsi/hpsa.c
@@ -609,7 +609,7 @@ static inline int is_logical_dev_addr_mode(unsigned char scsi3addr[])
 }
 
 static const char * const raid_label[] = { "0", "4", "1(+0)", "5", "5+1", "6",
-	"1(+0)ADM", "UNKNOWN"
+	"1(+0)ADM", "UNKNOWN", "PHYS DRV"
 };
 #define HPSA_RAID_0	0
 #define HPSA_RAID_4	1
@@ -618,7 +618,8 @@ static const char * const raid_label[] = { "0", "4", "1(+0)", "5", "5+1", "6",
 #define HPSA_RAID_51	4
 #define HPSA_RAID_6	5	/* also used for RAID 60 */
 #define HPSA_RAID_ADM	6	/* also used for RAID 1+0 ADM */
-#define RAID_UNKNOWN (ARRAY_SIZE(raid_label) - 1)
+#define RAID_UNKNOWN (ARRAY_SIZE(raid_label) - 2)
+#define PHYSICAL_DRIVE (ARRAY_SIZE(raid_label) - 1)
 
 static inline bool is_logical_device(struct hpsa_scsi_dev_t *device)
 {
@@ -1144,21 +1145,55 @@ static int hpsa_find_target_lun(struct ctlr_info *h,
 static void hpsa_show_dev_msg(const char *level, struct ctlr_info *h,
 	struct hpsa_scsi_dev_t *dev, char *description)
 {
+#define LABEL_SIZE 25
+	char label[LABEL_SIZE];
+
 	if (dev == NULL)
 		return;
 
 	if (h == NULL || h->pdev == NULL || h->scsi_host == NULL)
 		return;
 
+	switch (dev->devtype) {
+	case TYPE_RAID:
+		snprintf(label, LABEL_SIZE, "controller");
+		break;
+	case TYPE_ENCLOSURE:
+		snprintf(label, LABEL_SIZE, "enclosure");
+		break;
+	case TYPE_DISK:
+		if (dev->external)
+			snprintf(label, LABEL_SIZE, "external");
+		else if (!is_logical_dev_addr_mode(dev->scsi3addr))
+			snprintf(label, LABEL_SIZE, "%s",
+				raid_label[PHYSICAL_DRIVE]);
+		else
+			snprintf(label, LABEL_SIZE, "RAID-%s",
+				dev->raid_level > RAID_UNKNOWN ? "?" :
+				raid_label[dev->raid_level]);
+		break;
+	case TYPE_ROM:
+		snprintf(label, LABEL_SIZE, "rom");
+		break;
+	case TYPE_TAPE:
+		snprintf(label, LABEL_SIZE, "tape");
+		break;
+	case TYPE_MEDIUM_CHANGER:
+		snprintf(label, LABEL_SIZE, "changer");
+		break;
+	default:
+		snprintf(label, LABEL_SIZE, "UNKNOWN");
+		break;
+	}
+
 	dev_printk(level, &h->pdev->dev,
-			"scsi %d:%d:%d:%d: %s %s %.8s %.16s RAID-%s SSDSmartPathCap%c En%c Exp=%d\n",
+			"scsi %d:%d:%d:%d: %s %s %.8s %.16s %s SSDSmartPathCap%c En%c Exp=%d\n",
 			h->scsi_host->host_no, dev->bus, dev->target, dev->lun,
 			description,
 			scsi_device_type(dev->devtype),
 			dev->vendor,
 			dev->model,
-			dev->raid_level > RAID_UNKNOWN ?
-				"RAID-?" : raid_label[dev->raid_level],
+			label,
 			dev->offload_config ? '+' : '-',
 			dev->offload_enabled ? '+' : '-',
 			dev->expose_device);


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

* [PATCH 1 23/25] hpsa: fix multiple issues in path_info_show
  2015-10-28 22:04 [PATCH 1 00/25] hpsa updates Don Brace
                   ` (21 preceding siblings ...)
  2015-10-28 22:06 ` [PATCH 1 22/25] hpsa: enhance device messages Don Brace
@ 2015-10-28 22:06 ` Don Brace
  2015-10-30  8:18   ` Hannes Reinecke
                     ` (2 more replies)
  2015-10-28 22:06 ` [PATCH 1 24/25] hpsa: add in sas transport class Don Brace
                   ` (2 subsequent siblings)
  25 siblings, 3 replies; 107+ messages in thread
From: Don Brace @ 2015-10-28 22:06 UTC (permalink / raw)
  To: scott.teel, Kevin.Barnett, scott.benesh, james.bottomley, hch,
	Justin.Lindley, elliott
  Cc: linux-scsi

From: Rasmus Villemoes <linux@rasmusvillemoes.dk>

path_info_show() seems to be broken in multiple ways.

First, there's

  817 return snprintf(buf, output_len+1, "%s%s%s%s%s%s%s%s",
  818       path[0], path[1], path[2], path[3],
  819       path[4], path[5], path[6], path[7]);

so hopefully output_len contains the combined length of the eight
strings. Otherwise, snprintf will stop copying to the output
buffer, but still end up reporting that combined length - which
in turn would result in user-space getting a bunch of useless nul
bytes (thankfully the upper sysfs layer seems to clear the output
buffer before passing it to the various ->show routines). But we have

  767      output_len = snprintf(path[i],
  768                       PATH_STRING_LEN, "[%d:%d:%d:%d] %20.20s ",
  769                       h->scsi_host->host_no,
  770                       hdev->bus, hdev->target, hdev->lun,
  771                       scsi_device_type(hdev->devtype));

so output_len at best contains the length of the last string printed.

Inside the loop, we then otherwise add to output_len. By magic,
we still have PATH_STRING_LEN available every time... This
wouldn't really be a problem if the bean-counting has been done
properly and each line actually does fit in 50 bytes, and maybe
it does, but I don't immediately see why. Suppose we end up
taking this branch:

  802                  output_len += snprintf(path[i] + output_len,
  803                          PATH_STRING_LEN,
  804                          "BOX: %hhu BAY: %hhu %s\n",
  805                          box, bay, active);

An optimistic estimate says this uses strlen("BOX: 1 BAY: 2
Active\n") which is 21. Now add the 20 bytes guaranteed by the
%20.20s and then some for the rest of that format string, and
we're easily over 50 bytes. I don't think we can get over 100
bytes even being pessimistic, so this just means we'll scribble
into the next path[i+1] and maybe get that overwritten later,
leading to some garbled output (in fact, since we'd overwrite the
previous string's 0-terminator, we could end up with one very
long string and then print various suffixes of that, leading to
much more than 400 bytes of output). Except of course when we're
filling path[7], where overrunning it means writing random stuff
to the kernel stack, which is usually a lot of fun.

We can fix all of that and get rid of the 400 byte stack buffer by
simply writing directly to the given output buffer, which the upper
layer guarantees is at least PAGE_SIZE. s[c]nprintf doesn't care where
it is writing to, so this doesn't make the spin lock hold time any
longer. Using scnprintf ensures that output_len always represents the
number of bytes actually written to the buffer, so we'll report the
proper amount to the upper layer.

Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>
Signed-off-by: Don Brace <don.brace@pmcs.com>
---
 drivers/scsi/hpsa.c |   38 +++++++++++++++++---------------------
 1 file changed, 17 insertions(+), 21 deletions(-)

diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
index b2418c3..56526312 100644
--- a/drivers/scsi/hpsa.c
+++ b/drivers/scsi/hpsa.c
@@ -735,7 +735,6 @@ static ssize_t host_show_hp_ssd_smart_path_enabled(struct device *dev,
 }
 
 #define MAX_PATHS 8
-#define PATH_STRING_LEN 50
 
 static ssize_t path_info_show(struct device *dev,
 	     struct device_attribute *attr, char *buf)
@@ -751,9 +750,7 @@ static ssize_t path_info_show(struct device *dev,
 	u8 path_map_index = 0;
 	char *active;
 	unsigned char phys_connector[2];
-	unsigned char path[MAX_PATHS][PATH_STRING_LEN];
 
-	memset(path, 0, MAX_PATHS * PATH_STRING_LEN);
 	sdev = to_scsi_device(dev);
 	h = sdev_to_hba(sdev);
 	spin_lock_irqsave(&h->devlock, flags);
@@ -773,8 +770,9 @@ static ssize_t path_info_show(struct device *dev,
 		else
 			continue;
 
-		output_len = snprintf(path[i],
-				PATH_STRING_LEN, "[%d:%d:%d:%d] %20.20s ",
+		output_len += scnprintf(buf + output_len,
+				PAGE_SIZE - output_len,
+				"[%d:%d:%d:%d] %20.20s ",
 				h->scsi_host->host_no,
 				hdev->bus, hdev->target, hdev->lun,
 				scsi_device_type(hdev->devtype));
@@ -782,9 +780,9 @@ static ssize_t path_info_show(struct device *dev,
 		if (hdev->external ||
 			hdev->devtype == TYPE_RAID ||
 			is_logical_device(hdev)) {
-			output_len += snprintf(path[i] + output_len,
-						PATH_STRING_LEN, "%s\n",
-						active);
+			output_len += snprintf(buf + output_len,
+						PAGE_SIZE - output_len,
+						"%s\n", active);
 			continue;
 		}
 
@@ -796,35 +794,33 @@ static ssize_t path_info_show(struct device *dev,
 		if (phys_connector[1] < '0')
 			phys_connector[1] = '0';
 		if (hdev->phys_connector[i] > 0)
-			output_len += snprintf(path[i] + output_len,
-				PATH_STRING_LEN,
+			output_len += snprintf(buf + output_len,
+				PAGE_SIZE - output_len,
 				"PORT: %.2s ",
 				phys_connector);
 		if (hdev->devtype == TYPE_DISK && hdev->expose_device) {
 			if (box == 0 || box == 0xFF) {
-				output_len += snprintf(path[i] + output_len,
-					PATH_STRING_LEN,
+				output_len += snprintf(buf + output_len,
+					PAGE_SIZE - output_len,
 					"BAY: %hhu %s\n",
 					bay, active);
 			} else {
-				output_len += snprintf(path[i] + output_len,
-					PATH_STRING_LEN,
+				output_len += snprintf(buf + output_len,
+					PAGE_SIZE - output_len,
 					"BOX: %hhu BAY: %hhu %s\n",
 					box, bay, active);
 			}
 		} else if (box != 0 && box != 0xFF) {
-			output_len += snprintf(path[i] + output_len,
-				PATH_STRING_LEN, "BOX: %hhu %s\n",
+			output_len += snprintf(buf + output_len,
+				PAGE_SIZE - output_len, "BOX: %hhu %s\n",
 				box, active);
 		} else
-			output_len += snprintf(path[i] + output_len,
-				PATH_STRING_LEN, "%s\n", active);
+			output_len += snprintf(buf + output_len,
+				PAGE_SIZE - output_len, "%s\n", active);
 	}
 
 	spin_unlock_irqrestore(&h->devlock, flags);
-	return snprintf(buf, output_len+1, "%s%s%s%s%s%s%s%s",
-		path[0], path[1], path[2], path[3],
-		path[4], path[5], path[6], path[7]);
+	return output_len;
 }
 
 static DEVICE_ATTR(raid_level, S_IRUGO, raid_level_show, NULL);


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

* [PATCH 1 24/25] hpsa: add in sas transport class
  2015-10-28 22:04 [PATCH 1 00/25] hpsa updates Don Brace
                   ` (22 preceding siblings ...)
  2015-10-28 22:06 ` [PATCH 1 23/25] hpsa: fix multiple issues in path_info_show Don Brace
@ 2015-10-28 22:06 ` Don Brace
  2015-10-30  8:21   ` Hannes Reinecke
                     ` (3 more replies)
  2015-10-28 22:07 ` [PATCH 1 25/25] hpsa: bump the driver version Don Brace
  2015-11-03  4:49 ` [PATCH 1 00/25] hpsa updates Martin K. Petersen
  25 siblings, 4 replies; 107+ messages in thread
From: Don Brace @ 2015-10-28 22:06 UTC (permalink / raw)
  To: scott.teel, Kevin.Barnett, scott.benesh, james.bottomley, hch,
	Justin.Lindley, elliott
  Cc: linux-scsi

From: Kevin Barnett <kevin.barnett@pmcs.com>

Reviewed-by: Scott Teel <scott.teel@pmcs.com>
Reviewed-by: Justin Lindley <justin.lindley@pmcs.com>
Reviewed-by: Kevin Barnett <kevin.barnett@pmcs.com>
Signed-off-by: Don Brace <don.brace@pmcs.com>
---
 drivers/scsi/hpsa.c     |  535 +++++++++++++++++++++++++++++++++++++++++++++--
 drivers/scsi/hpsa.h     |   27 ++
 drivers/scsi/hpsa_cmd.h |   14 +
 3 files changed, 555 insertions(+), 21 deletions(-)

diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
index 56526312..ca38a00 100644
--- a/drivers/scsi/hpsa.c
+++ b/drivers/scsi/hpsa.c
@@ -41,6 +41,7 @@
 #include <scsi/scsi_host.h>
 #include <scsi/scsi_tcq.h>
 #include <scsi/scsi_eh.h>
+#include <scsi/scsi_transport_sas.h>
 #include <scsi/scsi_dbg.h>
 #include <linux/cciss_ioctl.h>
 #include <linux/string.h>
@@ -205,6 +206,16 @@ static struct board_type products[] = {
 	{0xFFFF103C, "Unknown Smart Array", &SA5_access},
 };
 
+static struct scsi_transport_template *hpsa_sas_transport_template;
+static int hpsa_add_sas_host(struct ctlr_info *h);
+static void hpsa_delete_sas_host(struct ctlr_info *h);
+static int hpsa_add_sas_device(struct hpsa_sas_node *hpsa_sas_node,
+			struct hpsa_scsi_dev_t *device);
+static void hpsa_remove_sas_device(struct hpsa_scsi_dev_t *device);
+static struct hpsa_scsi_dev_t
+	*hpsa_find_device_by_sas_rphy(struct ctlr_info *h,
+		struct sas_rphy *rphy);
+
 #define SCSI_CMD_BUSY ((struct scsi_cmnd *)&hpsa_cmd_busy)
 static const struct scsi_cmnd hpsa_cmd_busy;
 #define SCSI_CMD_IDLE ((struct scsi_cmnd *)&hpsa_cmd_idle)
@@ -277,6 +288,8 @@ static void hpsa_command_resubmit_worker(struct work_struct *work);
 static u32 lockup_detected(struct ctlr_info *h);
 static int detect_controller_lockup(struct ctlr_info *h);
 static void hpsa_disable_rld_caching(struct ctlr_info *h);
+static inline int hpsa_scsi_do_report_phys_luns(struct ctlr_info *h,
+	struct ReportExtendedLUNdata *buf, int bufsize);
 static int hpsa_luns_changed(struct ctlr_info *h);
 
 static inline struct ctlr_info *sdev_to_hba(struct scsi_device *sdev)
@@ -1696,8 +1709,12 @@ static int hpsa_add_device(struct ctlr_info *h, struct hpsa_scsi_dev_t *device)
 {
 	int rc = 0;
 
-	rc = scsi_add_device(h->scsi_host, device->bus,
+	if (is_logical_device(device)) /* RAID */
+		rc = scsi_add_device(h->scsi_host, device->bus,
 					device->target, device->lun);
+	else /* HBA */
+		rc = hpsa_add_sas_device(h->sas_host, device);
+
 	return rc;
 }
 
@@ -1706,21 +1723,23 @@ static void hpsa_remove_device(struct ctlr_info *h,
 {
 	struct scsi_device *sdev = NULL;
 
-	sdev = scsi_device_lookup(h->scsi_host, device->bus,
+	if (is_logical_device(device)) { /* RAID */
+		sdev = scsi_device_lookup(h->scsi_host, device->bus,
 						device->target, device->lun);
-
-	if (sdev) {
-		scsi_remove_device(sdev);
-		scsi_device_put(sdev);
-	} else {
-		/*
-		 * We don't expect to get here.  Future commands
-		 * to this device will get a selection timeout as
-		 * if the device were gone.
-		 */
-		hpsa_show_dev_msg(KERN_WARNING, h, device,
+		if (sdev) {
+			scsi_remove_device(sdev);
+			scsi_device_put(sdev);
+		} else {
+			/*
+			 * We don't expect to get here.  Future commands
+			 * to this device will get a selection timeout as
+			 * if the device were gone.
+			 */
+			hpsa_show_dev_msg(KERN_WARNING, h, device,
 					"didn't find device for removal.");
-	}
+		}
+	} else /* HBA */
+		hpsa_remove_sas_device(device);
 }
 
 static void adjust_hpsa_scsi_table(struct ctlr_info *h, int hostno,
@@ -1915,11 +1934,24 @@ static int hpsa_slave_alloc(struct scsi_device *sdev)
 
 	h = sdev_to_hba(sdev);
 	spin_lock_irqsave(&h->devlock, flags);
-	sd = lookup_hpsa_scsi_dev(h, sdev_channel(sdev),
-		sdev_id(sdev), sdev->lun);
-	if (likely(sd)) {
+	if (sdev_channel(sdev) == HPSA_PHYSICAL_DEVICE_BUS) {
+		struct scsi_target *starget;
+		struct sas_rphy *rphy;
+
+		starget = scsi_target(sdev);
+		rphy = target_to_rphy(starget);
+		sd = hpsa_find_device_by_sas_rphy(h, rphy);
+		if (sd) {
+			sd->target = sdev_id(sdev);
+			sd->lun = sdev->lun;
+		}
+	} else
+		sd = lookup_hpsa_scsi_dev(h, sdev_channel(sdev),
+					sdev_id(sdev), sdev->lun);
+
+	if (sd && sd->expose_device) {
 		atomic_set(&sd->ioaccel_cmds_out, 0);
-		sdev->hostdata = sd->expose_device ? sd : NULL;
+		sdev->hostdata = sd;
 	} else
 		sdev->hostdata = NULL;
 	spin_unlock_irqrestore(&h->devlock, flags);
@@ -3069,6 +3101,38 @@ out:
 	return rc;
 }
 
+static int hpsa_bmic_sense_subsystem_information(struct ctlr_info *h,
+		unsigned char scsi3addr[], u16 bmic_device_index,
+		struct bmic_sense_subsystem_info *buf, size_t bufsize)
+{
+	int rc = IO_OK;
+	struct CommandList *c;
+	struct ErrorInfo *ei;
+
+	c = cmd_alloc(h);
+
+	rc = fill_cmd(c, BMIC_SENSE_SUBSYSTEM_INFORMATION, h, buf, bufsize,
+		0, RAID_CTLR_LUNID, TYPE_CMD);
+	if (rc)
+		goto out;
+
+	c->Request.CDB[2] = bmic_device_index & 0xff;
+	c->Request.CDB[9] = (bmic_device_index >> 8) & 0xff;
+
+	rc = hpsa_scsi_do_simple_cmd_with_retry(h, c,
+				PCI_DMA_FROMDEVICE, NO_TIMEOUT);
+	if (rc)
+		goto out;
+	ei = c->err_info;
+	if (ei->CommandStatus != 0 && ei->CommandStatus != CMD_DATA_UNDERRUN) {
+		hpsa_scsi_interpret_error(h, c);
+		rc = -1;
+	}
+out:
+	cmd_free(h, c);
+	return rc;
+}
+
 static int hpsa_bmic_id_controller(struct ctlr_info *h,
 	struct bmic_identify_controller *buf, size_t bufsize)
 {
@@ -3097,7 +3161,6 @@ out:
 	return rc;
 }
 
-
 static int hpsa_bmic_id_physical_device(struct ctlr_info *h,
 		unsigned char scsi3addr[], u16 bmic_device_index,
 		struct bmic_identify_physical_device *buf, size_t bufsize)
@@ -3124,9 +3187,64 @@ static int hpsa_bmic_id_physical_device(struct ctlr_info *h,
 	}
 out:
 	cmd_free(h, c);
+
 	return rc;
 }
 
+static u64 hpsa_get_sas_address_from_report_physical(struct ctlr_info *h,
+						unsigned char *scsi3addr)
+{
+	struct ReportExtendedLUNdata *physdev;
+	u32 nphysicals;
+	u64 sa = 0;
+	int i;
+
+	physdev = kzalloc(sizeof(*physdev), GFP_KERNEL);
+	if (!physdev)
+		return 0;
+
+	if (hpsa_scsi_do_report_phys_luns(h, physdev, sizeof(*physdev))) {
+		dev_err(&h->pdev->dev, "report physical LUNs failed.\n");
+		kfree(physdev);
+		return 0;
+	}
+	nphysicals = get_unaligned_be32(physdev->LUNListLength) / 24;
+
+	for (i = 0; i < nphysicals; i++)
+		if (!memcmp(&physdev->LUN[i].lunid[0], scsi3addr, 8))
+			sa = get_unaligned_be64(&physdev->LUN[i].wwid[0]);
+
+	kfree(physdev);
+
+	return sa;
+}
+
+static void hpsa_get_sas_address(struct ctlr_info *h, unsigned char *scsi3addr,
+					struct hpsa_scsi_dev_t *dev)
+{
+	int rc;
+	u64 sa = 0;
+
+	if (is_hba_lunid(scsi3addr)) {
+		struct bmic_sense_subsystem_info *ssi;
+
+		ssi = kzalloc(sizeof(*ssi), GFP_KERNEL);
+
+		rc = hpsa_bmic_sense_subsystem_information(h,
+					scsi3addr, 0, ssi, sizeof(*ssi));
+		if (rc == 0) {
+			sa = get_unaligned_be64(ssi->primary_world_wide_id);
+			h->sas_address = sa;
+		}
+
+		kfree(ssi);
+	} else
+		sa = hpsa_get_sas_address_from_report_physical(h, scsi3addr);
+
+	dev->sas_address = sa;
+}
+
+/* Get a device id from inquiry page 0x83 */
 static int hpsa_vpd_page_supported(struct ctlr_info *h,
 	unsigned char scsi3addr[], u8 page)
 {
@@ -3961,6 +4079,13 @@ static void hpsa_update_scsi_devices(struct ctlr_info *h, int hostno)
 		else
 			this_device->expose_device = 1;
 
+
+		/*
+		 * Get the SAS address for physical devices that are exposed.
+		 */
+		if (this_device->physical_device && this_device->expose_device)
+			hpsa_get_sas_address(h, lunaddrbytes, this_device);
+
 		switch (this_device->devtype) {
 		case TYPE_ROM:
 			/* We don't *really* support actual CD-ROM devices,
@@ -4006,6 +4131,10 @@ static void hpsa_update_scsi_devices(struct ctlr_info *h, int hostno)
 		if (ncurrent >= HPSA_MAX_DEVICES)
 			break;
 	}
+
+	if (h->sas_host == NULL)
+		hpsa_add_sas_host(h);
+
 	adjust_hpsa_scsi_table(h, hostno, currentsd, ncurrent);
 out:
 	kfree(tmpdevice);
@@ -5137,6 +5266,7 @@ static int hpsa_scsi_host_alloc(struct ctlr_info *h)
 	sh->can_queue = h->nr_cmds - HPSA_NRESERVED_CMDS;
 	sh->cmd_per_lun = sh->can_queue;
 	sh->sg_tablesize = h->maxsgentries;
+	sh->transportt = hpsa_sas_transport_template;
 	sh->hostdata[0] = (unsigned long) h;
 	sh->irq = h->intr[h->intr_mode];
 	sh->unique_id = sh->irq;
@@ -6485,6 +6615,16 @@ static int fill_cmd(struct CommandList *c, u8 cmd, struct ctlr_info *h,
 			c->Request.CDB[7] = (size >> 16) & 0xFF;
 			c->Request.CDB[8] = (size >> 8) & 0XFF;
 			break;
+		case BMIC_SENSE_SUBSYSTEM_INFORMATION:
+			c->Request.CDBLen = 10;
+			c->Request.type_attr_dir =
+				TYPE_ATTR_DIR(cmd_type, ATTR_SIMPLE, XFER_READ);
+			c->Request.Timeout = 0;
+			c->Request.CDB[0] = BMIC_READ;
+			c->Request.CDB[6] = BMIC_SENSE_SUBSYSTEM_INFORMATION;
+			c->Request.CDB[7] = (size >> 16) & 0xFF;
+			c->Request.CDB[8] = (size >> 8) & 0XFF;
+			break;
 		case BMIC_IDENTIFY_CONTROLLER:
 			c->Request.CDBLen = 10;
 			c->Request.type_attr_dir =
@@ -6501,7 +6641,6 @@ static int fill_cmd(struct CommandList *c, u8 cmd, struct ctlr_info *h,
 			c->Request.CDB[8] = (size >> 8) & 0XFF;
 			c->Request.CDB[9] = 0;
 			break;
-
 		default:
 			dev_warn(&h->pdev->dev, "unknown command 0x%c\n", cmd);
 			BUG();
@@ -8618,6 +8757,9 @@ static void hpsa_remove_one(struct pci_dev *pdev)
 	free_percpu(h->lockup_detected);		/* init_one 2 */
 	h->lockup_detected = NULL;			/* init_one 2 */
 	/* (void) pci_disable_pcie_error_reporting(pdev); */	/* init_one 1 */
+
+	hpsa_delete_sas_host(h);
+
 	kfree(h);					/* init_one 1 */
 }
 
@@ -9080,18 +9222,369 @@ static void hpsa_drain_accel_commands(struct ctlr_info *h)
 	} while (1);
 }
 
+static struct hpsa_sas_phy *hpsa_alloc_sas_phy(
+				struct hpsa_sas_port *hpsa_sas_port)
+{
+	struct hpsa_sas_phy *hpsa_sas_phy;
+	struct sas_phy *phy;
+
+	hpsa_sas_phy = kzalloc(sizeof(*hpsa_sas_phy), GFP_KERNEL);
+	if (!hpsa_sas_phy)
+		return NULL;
+
+	phy = sas_phy_alloc(hpsa_sas_port->parent_node->parent_dev,
+		hpsa_sas_port->next_phy_index);
+	if (!phy) {
+		kfree(hpsa_sas_phy);
+		return NULL;
+	}
+
+	hpsa_sas_port->next_phy_index++;
+	hpsa_sas_phy->phy = phy;
+	hpsa_sas_phy->parent_port = hpsa_sas_port;
+
+	return hpsa_sas_phy;
+}
+
+static void hpsa_free_sas_phy(struct hpsa_sas_phy *hpsa_sas_phy)
+{
+	struct sas_phy *phy = hpsa_sas_phy->phy;
+
+	sas_port_delete_phy(hpsa_sas_phy->parent_port->port, phy);
+	sas_phy_free(phy);
+	if (hpsa_sas_phy->added_to_port)
+		list_del(&hpsa_sas_phy->phy_list_entry);
+	kfree(hpsa_sas_phy);
+}
+
+static int hpsa_sas_port_add_phy(struct hpsa_sas_phy *hpsa_sas_phy)
+{
+	int rc;
+	struct hpsa_sas_port *hpsa_sas_port;
+	struct sas_phy *phy;
+	struct sas_identify *identify;
+
+	hpsa_sas_port = hpsa_sas_phy->parent_port;
+	phy = hpsa_sas_phy->phy;
+
+	identify = &phy->identify;
+	memset(identify, 0, sizeof(*identify));
+	identify->sas_address = hpsa_sas_port->sas_address;
+	identify->device_type = SAS_END_DEVICE;
+	identify->initiator_port_protocols = SAS_PROTOCOL_STP;
+	identify->target_port_protocols = SAS_PROTOCOL_STP;
+	phy->minimum_linkrate_hw = SAS_LINK_RATE_UNKNOWN;
+	phy->maximum_linkrate_hw = SAS_LINK_RATE_UNKNOWN;
+	phy->minimum_linkrate = SAS_LINK_RATE_UNKNOWN;
+	phy->maximum_linkrate = SAS_LINK_RATE_UNKNOWN;
+	phy->negotiated_linkrate = SAS_LINK_RATE_UNKNOWN;
+
+	rc = sas_phy_add(hpsa_sas_phy->phy);
+	if (rc)
+		return rc;
+
+	sas_port_add_phy(hpsa_sas_port->port, hpsa_sas_phy->phy);
+	list_add_tail(&hpsa_sas_phy->phy_list_entry,
+			&hpsa_sas_port->phy_list_head);
+	hpsa_sas_phy->added_to_port = true;
+
+	return 0;
+}
+
+static int
+	hpsa_sas_port_add_rphy(struct hpsa_sas_port *hpsa_sas_port,
+				struct sas_rphy *rphy)
+{
+	struct sas_identify *identify;
+
+	identify = &rphy->identify;
+	identify->sas_address = hpsa_sas_port->sas_address;
+	identify->initiator_port_protocols = SAS_PROTOCOL_STP;
+	identify->target_port_protocols = SAS_PROTOCOL_STP;
+
+	return sas_rphy_add(rphy);
+}
+
+static struct hpsa_sas_port
+	*hpsa_alloc_sas_port(struct hpsa_sas_node *hpsa_sas_node,
+				u64 sas_address)
+{
+	int rc;
+	struct hpsa_sas_port *hpsa_sas_port;
+	struct sas_port *port;
+
+	hpsa_sas_port = kzalloc(sizeof(*hpsa_sas_port), GFP_KERNEL);
+	if (!hpsa_sas_port)
+		return NULL;
+
+	INIT_LIST_HEAD(&hpsa_sas_port->phy_list_head);
+	hpsa_sas_port->parent_node = hpsa_sas_node;
+
+	port = sas_port_alloc_num(hpsa_sas_node->parent_dev);
+	if (!port)
+		goto free_hpsa_port;
+
+	rc = sas_port_add(port);
+	if (rc)
+		goto free_sas_port;
+
+	hpsa_sas_port->port = port;
+	hpsa_sas_port->sas_address = sas_address;
+	list_add_tail(&hpsa_sas_port->port_list_entry,
+			&hpsa_sas_node->port_list_head);
+
+	return hpsa_sas_port;
+
+free_sas_port:
+	sas_port_free(port);
+free_hpsa_port:
+	kfree(hpsa_sas_port);
+
+	return NULL;
+}
+
+static void hpsa_free_sas_port(struct hpsa_sas_port *hpsa_sas_port)
+{
+	struct hpsa_sas_phy *hpsa_sas_phy;
+	struct hpsa_sas_phy *next;
+
+	list_for_each_entry_safe(hpsa_sas_phy, next,
+			&hpsa_sas_port->phy_list_head, phy_list_entry)
+		hpsa_free_sas_phy(hpsa_sas_phy);
+
+	sas_port_delete(hpsa_sas_port->port);
+	list_del(&hpsa_sas_port->port_list_entry);
+	kfree(hpsa_sas_port);
+}
+
+static struct hpsa_sas_node *hpsa_alloc_sas_node(struct device *parent_dev)
+{
+	struct hpsa_sas_node *hpsa_sas_node;
+
+	hpsa_sas_node = kzalloc(sizeof(*hpsa_sas_node), GFP_KERNEL);
+	if (hpsa_sas_node) {
+		hpsa_sas_node->parent_dev = parent_dev;
+		INIT_LIST_HEAD(&hpsa_sas_node->port_list_head);
+	}
+
+	return hpsa_sas_node;
+}
+
+static void hpsa_free_sas_node(struct hpsa_sas_node *hpsa_sas_node)
+{
+	struct hpsa_sas_port *hpsa_sas_port;
+	struct hpsa_sas_port *next;
+
+	if (!hpsa_sas_node)
+		return;
+
+	list_for_each_entry_safe(hpsa_sas_port, next,
+			&hpsa_sas_node->port_list_head, port_list_entry)
+		hpsa_free_sas_port(hpsa_sas_port);
+
+	kfree(hpsa_sas_node);
+}
+
+static struct hpsa_scsi_dev_t
+	*hpsa_find_device_by_sas_rphy(struct ctlr_info *h,
+					struct sas_rphy *rphy)
+{
+	int i;
+	struct hpsa_scsi_dev_t *device;
+
+	for (i = 0; i < h->ndevices; i++) {
+		device = h->dev[i];
+		if (!device->sas_port)
+			continue;
+		if (device->sas_port->rphy == rphy)
+			return device;
+	}
+
+	return NULL;
+}
+
+static int hpsa_add_sas_host(struct ctlr_info *h)
+{
+	int rc;
+	struct device *parent_dev;
+	struct hpsa_sas_node *hpsa_sas_node;
+	struct hpsa_sas_port *hpsa_sas_port;
+	struct hpsa_sas_phy *hpsa_sas_phy;
+
+	parent_dev = &h->scsi_host->shost_gendev;
+
+	hpsa_sas_node = hpsa_alloc_sas_node(parent_dev);
+	if (!hpsa_sas_node)
+		return -ENOMEM;
+
+	hpsa_sas_port = hpsa_alloc_sas_port(hpsa_sas_node, h->sas_address);
+	if (!hpsa_sas_port) {
+		rc = -ENODEV;
+		goto free_sas_node;
+	}
+
+	hpsa_sas_phy = hpsa_alloc_sas_phy(hpsa_sas_port);
+	if (!hpsa_sas_phy) {
+		rc = -ENODEV;
+		goto free_sas_port;
+	}
+
+	rc = hpsa_sas_port_add_phy(hpsa_sas_phy);
+	if (rc)
+		goto free_sas_phy;
+
+	h->sas_host = hpsa_sas_node;
+
+	return 0;
+
+free_sas_phy:
+	hpsa_free_sas_phy(hpsa_sas_phy);
+free_sas_port:
+	hpsa_free_sas_port(hpsa_sas_port);
+free_sas_node:
+	hpsa_free_sas_node(hpsa_sas_node);
+
+	return rc;
+}
+
+static void hpsa_delete_sas_host(struct ctlr_info *h)
+{
+	hpsa_free_sas_node(h->sas_host);
+}
+
+static int hpsa_add_sas_device(struct hpsa_sas_node *hpsa_sas_node,
+				struct hpsa_scsi_dev_t *device)
+{
+	int rc;
+	struct hpsa_sas_port *hpsa_sas_port;
+	struct sas_rphy *rphy;
+
+	hpsa_sas_port = hpsa_alloc_sas_port(hpsa_sas_node, device->sas_address);
+	if (!hpsa_sas_port)
+		return -ENOMEM;
+
+	rphy = sas_end_device_alloc(hpsa_sas_port->port);
+	if (!rphy) {
+		rc = -ENODEV;
+		goto free_sas_port;
+	}
+
+	hpsa_sas_port->rphy = rphy;
+	device->sas_port = hpsa_sas_port;
+
+	rc = hpsa_sas_port_add_rphy(hpsa_sas_port, rphy);
+	if (rc)
+		goto free_sas_port;
+
+	return 0;
+
+free_sas_port:
+	hpsa_free_sas_port(hpsa_sas_port);
+	device->sas_port = NULL;
+
+	return rc;
+}
+
+static void hpsa_remove_sas_device(struct hpsa_scsi_dev_t *device)
+{
+	if (device->sas_port) {
+		hpsa_free_sas_port(device->sas_port);
+		device->sas_port = NULL;
+	}
+}
+
+static int
+hpsa_sas_get_linkerrors(struct sas_phy *phy)
+{
+	return 0;
+}
+
+static int
+hpsa_sas_get_enclosure_identifier(struct sas_rphy *rphy, u64 *identifier)
+{
+	return 0;
+}
+
+static int
+hpsa_sas_get_bay_identifier(struct sas_rphy *rphy)
+{
+	return -ENXIO;
+}
+
+static int
+hpsa_sas_phy_reset(struct sas_phy *phy, int hard_reset)
+{
+	return 0;
+}
+
+static int
+hpsa_sas_phy_enable(struct sas_phy *phy, int enable)
+{
+	return 0;
+}
+
+static int
+hpsa_sas_phy_setup(struct sas_phy *phy)
+{
+	return 0;
+}
+
+static void
+hpsa_sas_phy_release(struct sas_phy *phy)
+{
+}
+
+static int
+hpsa_sas_phy_speed(struct sas_phy *phy, struct sas_phy_linkrates *rates)
+{
+	return -EINVAL;
+}
+
+/* SMP = Serial Management Protocol */
+static int
+hpsa_sas_smp_handler(struct Scsi_Host *shost, struct sas_rphy *rphy,
+struct request *req)
+{
+	return -EINVAL;
+}
+
+static struct sas_function_template hpsa_sas_transport_functions = {
+	.get_linkerrors = hpsa_sas_get_linkerrors,
+	.get_enclosure_identifier = hpsa_sas_get_enclosure_identifier,
+	.get_bay_identifier = hpsa_sas_get_bay_identifier,
+	.phy_reset = hpsa_sas_phy_reset,
+	.phy_enable = hpsa_sas_phy_enable,
+	.phy_setup = hpsa_sas_phy_setup,
+	.phy_release = hpsa_sas_phy_release,
+	.set_phy_speed = hpsa_sas_phy_speed,
+	.smp_handler = hpsa_sas_smp_handler,
+};
+
 /*
  *  This is it.  Register the PCI driver information for the cards we control
  *  the OS will call our registered routines when it finds one of our cards.
  */
 static int __init hpsa_init(void)
 {
-	return pci_register_driver(&hpsa_pci_driver);
+	int rc;
+
+	hpsa_sas_transport_template =
+		sas_attach_transport(&hpsa_sas_transport_functions);
+	if (!hpsa_sas_transport_template)
+		return -ENODEV;
+
+	rc = pci_register_driver(&hpsa_pci_driver);
+
+	if (rc)
+		sas_release_transport(hpsa_sas_transport_template);
+
+	return rc;
 }
 
 static void __exit hpsa_cleanup(void)
 {
 	pci_unregister_driver(&hpsa_pci_driver);
+	sas_release_transport(hpsa_sas_transport_template);
 }
 
 static void __attribute__((unused)) verify_offsets(void)
diff --git a/drivers/scsi/hpsa.h b/drivers/scsi/hpsa.h
index 6c82d3c..7847405 100644
--- a/drivers/scsi/hpsa.h
+++ b/drivers/scsi/hpsa.h
@@ -33,6 +33,29 @@ struct access_method {
 	unsigned long (*command_completed)(struct ctlr_info *h, u8 q);
 };
 
+/* for SAS hosts and SAS expanders */
+struct hpsa_sas_node {
+	struct device *parent_dev;
+	struct list_head port_list_head;
+};
+
+struct hpsa_sas_port {
+	struct list_head port_list_entry;
+	u64 sas_address;
+	struct sas_port *port;
+	int next_phy_index;
+	struct list_head phy_list_head;
+	struct hpsa_sas_node *parent_node;
+	struct sas_rphy *rphy;
+};
+
+struct hpsa_sas_phy {
+	struct list_head phy_list_entry;
+	struct sas_phy *phy;
+	struct hpsa_sas_port *parent_port;
+	bool added_to_port;
+};
+
 struct hpsa_scsi_dev_t {
 	unsigned int devtype;
 	int bus, target, lun;		/* as presented to the OS */
@@ -41,6 +64,7 @@ struct hpsa_scsi_dev_t {
 	u8 expose_device;
 #define RAID_CTLR_LUNID "\0\0\0\0\0\0\0\0"
 	unsigned char device_id[16];    /* from inquiry pg. 0x83 */
+	u64 sas_address;
 	unsigned char vendor[8];        /* bytes 8-15 of inquiry data */
 	unsigned char model[16];        /* bytes 16-31 of inquiry data */
 	unsigned char raid_level;	/* from inquiry page 0xC1 */
@@ -77,6 +101,7 @@ struct hpsa_scsi_dev_t {
 	struct hpsa_scsi_dev_t *phys_disk[RAID_MAP_MAX_ENTRIES];
 	int nphysical_disks;
 	int supports_aborts;
+	struct hpsa_sas_port *sas_port;
 	int external;   /* 1-from external array 0-not <0-unknown */
 };
 
@@ -134,6 +159,7 @@ struct ctlr_info {
 	char    *product_name;
 	struct pci_dev *pdev;
 	u32	board_id;
+	u64	sas_address;
 	void __iomem *vaddr;
 	unsigned long paddr;
 	int 	nr_cmds; /* Number of commands allowed on this controller */
@@ -272,6 +298,7 @@ struct ctlr_info {
 	wait_queue_head_t event_sync_wait_queue;
 	struct mutex reset_mutex;
 	u8 reset_in_progress;
+	struct hpsa_sas_node *sas_host;
 };
 
 struct offline_device_entry {
diff --git a/drivers/scsi/hpsa_cmd.h b/drivers/scsi/hpsa_cmd.h
index 4910344..d92ef0d 100644
--- a/drivers/scsi/hpsa_cmd.h
+++ b/drivers/scsi/hpsa_cmd.h
@@ -290,6 +290,7 @@ struct SenseSubsystem_info {
 #define BMIC_SET_DIAG_OPTIONS 0xF4
 #define BMIC_SENSE_DIAG_OPTIONS 0xF5
 #define HPSA_DIAG_OPTS_DISABLE_RLD_CACHING 0x40000000
+#define BMIC_SENSE_SUBSYSTEM_INFORMATION 0x66
 
 /* Command List Structure */
 union SCSI3Addr {
@@ -828,5 +829,18 @@ struct bmic_identify_physical_device {
 	u8     padding[112];
 };
 
+struct bmic_sense_subsystem_info {
+	u8	primary_slot_number;
+	u8	reserved[3];
+	u8	chasis_serial_number[32];
+	u8	primary_world_wide_id[8];
+	u8	primary_array_serial_number[32]; /* NULL terminated */
+	u8	primary_cache_serial_number[32]; /* NULL terminated */
+	u8	reserved_2[8];
+	u8	secondary_array_serial_number[32];
+	u8	secondary_cache_serial_number[32];
+	u8	pad[332];
+};
+
 #pragma pack()
 #endif /* HPSA_CMD_H */


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

* [PATCH 1 25/25] hpsa: bump the driver version
  2015-10-28 22:04 [PATCH 1 00/25] hpsa updates Don Brace
                   ` (23 preceding siblings ...)
  2015-10-28 22:06 ` [PATCH 1 24/25] hpsa: add in sas transport class Don Brace
@ 2015-10-28 22:07 ` Don Brace
  2015-10-30  8:22   ` Hannes Reinecke
                     ` (2 more replies)
  2015-11-03  4:49 ` [PATCH 1 00/25] hpsa updates Martin K. Petersen
  25 siblings, 3 replies; 107+ messages in thread
From: Don Brace @ 2015-10-28 22:07 UTC (permalink / raw)
  To: scott.teel, Kevin.Barnett, scott.benesh, james.bottomley, hch,
	Justin.Lindley, elliott
  Cc: linux-scsi

Reviewed-by: Justin Lindley <justin.lindley@pmcs.com>
Reviewed-by: Scott Teel <scott.teel@pmcs.com>
Reviewed-by: Kevin Barnett <kevin.barnett@pmcs.com>
Reviewed-by: Gerry Morong <gerry.morong.pmcs.com>
Signed-off-by: Don Brace <don.brace@pmcs.com>
---
 drivers/scsi/hpsa.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
index ca38a00..1b43157 100644
--- a/drivers/scsi/hpsa.c
+++ b/drivers/scsi/hpsa.c
@@ -56,7 +56,7 @@
 #include "hpsa.h"
 
 /* HPSA_DRIVER_VERSION must be 3 byte values (0-255) separated by '.' */
-#define HPSA_DRIVER_VERSION "3.4.10-0"
+#define HPSA_DRIVER_VERSION "3.4.14-0"
 #define DRIVER_NAME "HP HPSA Driver (v " HPSA_DRIVER_VERSION ")"
 #define HPSA "hpsa"
 


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

* Re: [PATCH 1 01/25] hpsa: stop zeroing reset_cmds_out and ioaccel_cmds_out during rescan
  2015-10-28 22:04 ` [PATCH 1 01/25] hpsa: stop zeroing reset_cmds_out and ioaccel_cmds_out during rescan Don Brace
@ 2015-10-29 13:25   ` Tomas Henzl
  2015-10-30  7:45   ` Hannes Reinecke
  1 sibling, 0 replies; 107+ messages in thread
From: Tomas Henzl @ 2015-10-29 13:25 UTC (permalink / raw)
  To: Don Brace, scott.teel, Kevin.Barnett, scott.benesh,
	james.bottomley, hch, Justin.Lindley, elliott
  Cc: linux-scsi

On 28.10.2015 23:04, Don Brace wrote:
> pulling the rug out from under the reset handler
> likewise for ioaccel_cmds_out
>
> Signed-off-by: Don Brace <don.brace@pmcs.com>

Reviewed-by: Tomas Henzl <thenzl@redhat.com>

Tomas


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

* Re: [PATCH 1 02/25] hpsa: remove unused hpsa_tag_discard_error_bits
  2015-10-28 22:04 ` [PATCH 1 02/25] hpsa: remove unused hpsa_tag_discard_error_bits Don Brace
@ 2015-10-29 13:26   ` Tomas Henzl
  2015-10-29 14:37   ` Manoj Kumar
  2015-10-30  7:46   ` Hannes Reinecke
  2 siblings, 0 replies; 107+ messages in thread
From: Tomas Henzl @ 2015-10-29 13:26 UTC (permalink / raw)
  To: Don Brace, scott.teel, Kevin.Barnett, scott.benesh,
	james.bottomley, hch, Justin.Lindley, elliott
  Cc: linux-scsi

On 28.10.2015 23:04, Don Brace wrote:
> This function is no longer used.
>
> Signed-off-by: Don Brace <don.brace@pmcs.com>

Reviewed-by: Tomas Henzl <thenzl@redhat.com>

Tomas


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

* Re: [PATCH 1 03/25] hpsa: check for null arguments to dev_printk
  2015-10-28 22:04 ` [PATCH 1 03/25] hpsa: check for null arguments to dev_printk Don Brace
@ 2015-10-29 13:41   ` Tomas Henzl
  2015-10-29 14:41   ` Manoj Kumar
  2015-10-30  7:47   ` Hannes Reinecke
  2 siblings, 0 replies; 107+ messages in thread
From: Tomas Henzl @ 2015-10-29 13:41 UTC (permalink / raw)
  To: Don Brace, scott.teel, Kevin.Barnett, scott.benesh,
	james.bottomley, hch, Justin.Lindley, elliott
  Cc: linux-scsi

On 28.10.2015 23:04, Don Brace wrote:
> Check for NULLs.

How is the devtype change related to this?

Please next time use separated patch for every change.

Reviewed-by: Tomas Henzl <thenzl@redhat.com>

Cheers,
Tomas


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

* Re: [PATCH 1 04/25] hpsa: fix null device issues
  2015-10-28 22:04 ` [PATCH 1 04/25] hpsa: fix null device issues Don Brace
@ 2015-10-29 14:06   ` Tomas Henzl
  2015-10-30  7:49   ` Hannes Reinecke
  1 sibling, 0 replies; 107+ messages in thread
From: Tomas Henzl @ 2015-10-29 14:06 UTC (permalink / raw)
  To: Don Brace, scott.teel, Kevin.Barnett, scott.benesh,
	james.bottomley, hch, Justin.Lindley, elliott
  Cc: linux-scsi

On 28.10.2015 23:04, Don Brace wrote:
> Signed-off-by: Don Brace <don.brace@pmcs.com>
> ---
>  drivers/scsi/hpsa.c |   25 ++++++++++++++++++++-----
>  1 file changed, 20 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
> index 6b6e9bb..3fe8a18 100644
> --- a/drivers/scsi/hpsa.c
> +++ b/drivers/scsi/hpsa.c
> @@ -1136,7 +1136,7 @@ static int hpsa_find_target_lun(struct ctlr_info *h,
>  	return !found;
>  }
>  
> -static inline void hpsa_show_dev_msg(const char *level, struct ctlr_info *h,
> +static void hpsa_show_dev_msg(const char *level, struct ctlr_info *h,
>  	struct hpsa_scsi_dev_t *dev, char *description)
>  {
>  	if (dev == NULL)
> @@ -1423,6 +1423,9 @@ static int hpsa_scsi_find_entry(struct hpsa_scsi_dev_t *needle,
>  #define DEVICE_CHANGED 1
>  #define DEVICE_SAME 2
>  #define DEVICE_UPDATED 3
> +	if (needle == NULL)
> +		return DEVICE_NOT_FOUND;
> +
>  	for (i = 0; i < haystack_size; i++) {
>  		if (haystack[i] == NULL) /* previously removed. */
>  			continue;
> @@ -1574,6 +1577,9 @@ static void hpsa_figure_phys_disk_ptrs(struct ctlr_info *h,
>  				total_disks_per_row;
>  	int qdepth;
>  
> +	if (logical_drive == NULL)
> +		return;

logical_drive
- is used before this check
- this function is called only from hpsa_update_log_drive_phys_drive_ptrs
and there is a check (dev[i] == NULL) ->  logical_drive can never be NULL here

-tm

> +
>  	if (nraid_map_entries > RAID_MAP_MAX_ENTRIES)
>  		nraid_map_entries = RAID_MAP_MAX_ENTRIES;
>  
> @@ -1585,6 +1591,8 @@ static void hpsa_figure_phys_disk_ptrs(struct ctlr_info *h,
>  		if (!logical_drive->offload_config)
>  			continue;
>  		for (j = 0; j < ndevices; j++) {
> +			if (dev[j] == NULL)
> +				continue;
>  			if (dev[j]->devtype != TYPE_DISK)
>  				continue;
>  			if (is_logical_dev_addr_mode(dev[j]->scsi3addr))
> @@ -1628,6 +1636,8 @@ static void hpsa_update_log_drive_phys_drive_ptrs(struct ctlr_info *h,
>  	int i;
>  
>  	for (i = 0; i < ndevices; i++) {
> +		if (dev[i] == NULL)
> +			continue;
>  		if (dev[i]->devtype != TYPE_DISK)
>  			continue;
>  		if (!is_logical_dev_addr_mode(dev[i]->scsi3addr))
> @@ -1743,8 +1753,11 @@ static void adjust_hpsa_scsi_table(struct ctlr_info *h, int hostno,
>  	/* Now that h->dev[]->phys_disk[] is coherent, we can enable
>  	 * any logical drives that need it enabled.
>  	 */
> -	for (i = 0; i < h->ndevices; i++)
> +	for (i = 0; i < h->ndevices; i++) {
> +		if (h->dev[i] == NULL)
> +			continue;
>  		h->dev[i]->offload_enabled = h->dev[i]->offload_to_be_enabled;
> +	}
>  
>  	spin_unlock_irqrestore(&h->devlock, flags);
>  
> @@ -1769,6 +1782,8 @@ static void adjust_hpsa_scsi_table(struct ctlr_info *h, int hostno,
>  	sh = h->scsi_host;
>  	/* Notify scsi mid layer of any removed devices */
>  	for (i = 0; i < nremoved; i++) {
> +		if (removed[i] == NULL)
> +			continue;
>  		if (removed[i]->expose_state & HPSA_SCSI_ADD) {
>  			struct scsi_device *sdev =
>  				scsi_device_lookup(sh, removed[i]->bus,
> @@ -1792,18 +1807,18 @@ static void adjust_hpsa_scsi_table(struct ctlr_info *h, int hostno,
>  
>  	/* Notify scsi mid layer of any added devices */
>  	for (i = 0; i < nadded; i++) {
> +		if (added[i] == NULL)
> +			continue;
>  		if (!(added[i]->expose_state & HPSA_SCSI_ADD))
>  			continue;
>  		if (scsi_add_device(sh, added[i]->bus,
>  			added[i]->target, added[i]->lun) == 0)
>  			continue;
> -		hpsa_show_dev_msg(KERN_WARNING, h, added[i],
> -					"addition failed, device not added.");
> +		dev_warn(&h->pdev->dev, "addition failed, device not added.");
>  		/* now we have to remove it from h->dev,
>  		 * since it didn't get added to scsi mid layer
>  		 */
>  		fixup_botched_add(h, added[i]);
> -		added[i] = NULL;
>  	}
>  
>  free_and_out:
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html


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

* Re: [PATCH 1 08/25] hpsa: fix hpsa_adjust_hpsa_scsi_table
  2015-10-28 22:05 ` [PATCH 1 08/25] hpsa: fix hpsa_adjust_hpsa_scsi_table Don Brace
@ 2015-10-29 14:23   ` Tomas Henzl
  2015-10-30  7:57   ` Hannes Reinecke
  1 sibling, 0 replies; 107+ messages in thread
From: Tomas Henzl @ 2015-10-29 14:23 UTC (permalink / raw)
  To: Don Brace, scott.teel, Kevin.Barnett, scott.benesh,
	james.bottomley, hch, Justin.Lindley, elliott
  Cc: linux-scsi

On 28.10.2015 23:05, Don Brace wrote:
> Fix a NULL pointer issue in the driver when devices are removed
> during a reset.
>
> Signed-off-by: Don Brace <don.brace@pmcs.com>
> ---
>  drivers/block/cciss.h |    1 +
>  drivers/scsi/hpsa.c   |   16 ++++++++++++++++
>  drivers/scsi/hpsa.h   |    1 +
>  3 files changed, 18 insertions(+)
>
> diff --git a/drivers/block/cciss.h b/drivers/block/cciss.h
> index 7fda30e..f8b8c6b 100644
> --- a/drivers/block/cciss.h
> +++ b/drivers/block/cciss.h
> @@ -155,6 +155,7 @@ struct ctlr_info
>  	size_t reply_pool_size;
>  	unsigned char reply_pool_wraparound;
>  	u32 *blockFetchTable;
> +	u8 reset_in_progress;
>  };
>  
>  /*  Defining the diffent access_methods
> diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
> index ced0d4c..08a761c 100644
> --- a/drivers/scsi/hpsa.c
> +++ b/drivers/scsi/hpsa.c
> @@ -1670,6 +1670,15 @@ static void adjust_hpsa_scsi_table(struct ctlr_info *h, int hostno,
>  	int nadded, nremoved;
>  	struct Scsi_Host *sh = NULL;
>  
> +	/*
> +	 * A reset can cause a device status to change
> +	 * re-schedule the scan to see what happened.
> +	 */
> +	if (h->reset_in_progress) {
> +		h->drv_req_rescan = 1;
> +		return;
> +	}
> +

If another process start the reset at this point will you get the
the same Null pointer issue as before? Isn't some kind of
exclusive access protection needed ?

-tm

>  	added = kzalloc(sizeof(*added) * HPSA_MAX_DEVICES, GFP_KERNEL);
>  	removed = kzalloc(sizeof(*removed) * HPSA_MAX_DEVICES, GFP_KERNEL);
>  
> @@ -1780,6 +1789,10 @@ static void adjust_hpsa_scsi_table(struct ctlr_info *h, int hostno,
>  		goto free_and_out;
>  
>  	sh = h->scsi_host;
> +	if (sh == NULL) {
> +		dev_warn(&h->pdev->dev, "%s: scsi_host is null\n", __func__);
> +		return;
> +	}
>  	/* Notify scsi mid layer of any removed devices */
>  	for (i = 0; i < nremoved; i++) {
>  		if (removed[i] == NULL)
> @@ -5243,12 +5256,15 @@ static int hpsa_eh_device_reset_handler(struct scsi_cmnd *scsicmd)
>  
>  	hpsa_show_dev_msg(KERN_WARNING, h, dev, "resetting");
>  
> +	h->reset_in_progress = 1;
> +
>  	/* send a reset to the SCSI LUN which the command was sent to */
>  	rc = hpsa_do_reset(h, dev, dev->scsi3addr, HPSA_RESET_TYPE_LUN,
>  			   DEFAULT_REPLY_QUEUE);
>  	snprintf(msg, sizeof(msg), "reset %s",
>  		 rc == 0 ? "completed successfully" : "failed");
>  	hpsa_show_dev_msg(KERN_WARNING, h, dev, msg);
> +	h->reset_in_progress = 0;
>  	return rc == 0 ? SUCCESS : FAILED;
>  }
>  
> diff --git a/drivers/scsi/hpsa.h b/drivers/scsi/hpsa.h
> index b173c0e..dc113c1a 100644
> --- a/drivers/scsi/hpsa.h
> +++ b/drivers/scsi/hpsa.h
> @@ -271,6 +271,7 @@ struct ctlr_info {
>  	wait_queue_head_t abort_cmd_wait_queue;
>  	wait_queue_head_t event_sync_wait_queue;
>  	struct mutex reset_mutex;
> +	u8 reset_in_progress;
>  };
>  
>  struct offline_device_entry {
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html


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

* Re: [PATCH 1 09/25] hpsa: fix physical target reset
  2015-10-28 22:05 ` [PATCH 1 09/25] hpsa: fix physical target reset Don Brace
@ 2015-10-29 14:30   ` Tomas Henzl
  2015-10-29 15:29     ` Don Brace
  2015-10-30  7:59   ` Hannes Reinecke
  1 sibling, 1 reply; 107+ messages in thread
From: Tomas Henzl @ 2015-10-29 14:30 UTC (permalink / raw)
  To: Don Brace, scott.teel, Kevin.Barnett, scott.benesh,
	james.bottomley, hch, Justin.Lindley, elliott
  Cc: linux-scsi

On 28.10.2015 23:05, Don Brace wrote:
> From: Scott Teel <scott.teel@pmcs.com>
>
> Set reset type in device_reset_handler to do either
> logical unit reset for logical devices, or physical
> target reset, for physical devices.
>
> Reviewed-by: Scott Teel <scott.teel@pmcs.com>
> Reviewed-by: Justin Lindley <justin.lindley@pmcs.com>
> Reviewed-by: Kevin Barnett <kevin.barnett@pmcs.com>
> Signed-off-by: Don Brace <don.brace@pmcs.com>
> ---
>  drivers/scsi/hpsa.c |   34 ++++++++++++++++++++++++++++------
>  drivers/scsi/hpsa.h |    1 +
>  2 files changed, 29 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
> index 08a761c..67136fb 100644
> --- a/drivers/scsi/hpsa.c
> +++ b/drivers/scsi/hpsa.c
> @@ -2746,9 +2746,8 @@ static int hpsa_send_reset(struct ctlr_info *h, unsigned char *scsi3addr,
>  
>  
>  	/* fill_cmd can't fail here, no data buffer to map. */
> -	(void) fill_cmd(c, HPSA_DEVICE_RESET_MSG, h, NULL, 0, 0,
> +	(void) fill_cmd(c, reset_type, h, NULL, 0, 0,
>  			scsi3addr, TYPE_MSG);
> -	c->Request.CDB[1] = reset_type; /* fill_cmd defaults to LUN reset */
>  	rc = hpsa_scsi_do_simple_cmd(h, c, reply_queue, NO_TIMEOUT);
>  	if (rc) {
>  		dev_warn(&h->pdev->dev, "Failed to send reset command\n");
> @@ -5216,6 +5215,7 @@ static int hpsa_eh_device_reset_handler(struct scsi_cmnd *scsicmd)
>  	int rc;
>  	struct ctlr_info *h;
>  	struct hpsa_scsi_dev_t *dev;
> +	u8 reset_type;
>  	char msg[48];
>  
>  	/* find the controller to which the command to be aborted was sent */
> @@ -5254,15 +5254,23 @@ static int hpsa_eh_device_reset_handler(struct scsi_cmnd *scsicmd)
>  	if (is_hba_lunid(dev->scsi3addr))
>  		return SUCCESS;
>  
> -	hpsa_show_dev_msg(KERN_WARNING, h, dev, "resetting");
> +	if (is_logical_dev_addr_mode(dev->scsi3addr))
> +		reset_type = HPSA_DEVICE_RESET_MSG;
> +	else
> +		reset_type = HPSA_PHYS_TARGET_RESET;
> +
> +	sprintf(msg, "resetting %s",
> +		reset_type == HPSA_DEVICE_RESET_MSG ? "logical " : "physical ");
> +	hpsa_show_dev_msg(KERN_WARNING, h, dev, msg);
>  
>  	h->reset_in_progress = 1;
>  
>  	/* send a reset to the SCSI LUN which the command was sent to */
> -	rc = hpsa_do_reset(h, dev, dev->scsi3addr, HPSA_RESET_TYPE_LUN,
> +	rc = hpsa_do_reset(h, dev, dev->scsi3addr, reset_type,
>  			   DEFAULT_REPLY_QUEUE);
> -	snprintf(msg, sizeof(msg), "reset %s",
> -		 rc == 0 ? "completed successfully" : "failed");
> +	sprintf(msg, "reset %s %s",
> +		reset_type == HPSA_DEVICE_RESET_MSG ? "logical " : "physical ",
> +		rc == 0 ? "completed successfully" : "failed");
>  	hpsa_show_dev_msg(KERN_WARNING, h, dev, msg);
>  	h->reset_in_progress = 0;
>  	return rc == 0 ? SUCCESS : FAILED;
> @@ -6379,6 +6387,20 @@ static int fill_cmd(struct CommandList *c, u8 cmd, struct ctlr_info *h,
>  	} else if (cmd_type == TYPE_MSG) {
>  		switch (cmd) {
>  
> +		case  HPSA_PHYS_TARGET_RESET:
> +			c->Request.CDBLen = 16;
> +			c->Request.type_attr_dir =
> +				TYPE_ATTR_DIR(cmd_type, ATTR_SIMPLE, XFER_NONE);
> +			c->Request.Timeout = 0; /* Don't time out */
> +			memset(&c->Request.CDB[0], 0, sizeof(c->Request.CDB));
> +			c->Request.CDB[0] = HPSA_RESET;
> +			c->Request.CDB[1] = HPSA_TARGET_RESET_TYPE;
> +			/* Physical target reset needs no control bytes 4-7*/
> +			c->Request.CDB[4] = 0x00;
> +			c->Request.CDB[5] = 0x00;
> +			c->Request.CDB[6] = 0x00;
> +			c->Request.CDB[7] = 0x00;
> +			break;
>  		case  HPSA_DEVICE_RESET_MSG:
>  			c->Request.CDBLen = 16;
>  			c->Request.type_attr_dir =
> diff --git a/drivers/scsi/hpsa.h b/drivers/scsi/hpsa.h
> index dc113c1a..04f98eb 100644
> --- a/drivers/scsi/hpsa.h
> +++ b/drivers/scsi/hpsa.h
> @@ -285,6 +285,7 @@ struct offline_device_entry {
>  #define HPSA_RESET_TYPE_BUS 0x01
>  #define HPSA_RESET_TYPE_TARGET 0x03
>  #define HPSA_RESET_TYPE_LUN 0x04
> +#define HPSA_PHYS_TARGET_RESET 0x99 /* not defined by cciss spec */

Will this new reset command work for the whole range of hpsa devices?
(and for the older cciss hw - hpsa_allow_any) ?

>  #define HPSA_MSG_SEND_RETRY_LIMIT 10
>  #define HPSA_MSG_SEND_RETRY_INTERVAL_MSECS (10000)
>  
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html


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

* Re: [PATCH 1 02/25] hpsa: remove unused hpsa_tag_discard_error_bits
  2015-10-28 22:04 ` [PATCH 1 02/25] hpsa: remove unused hpsa_tag_discard_error_bits Don Brace
  2015-10-29 13:26   ` Tomas Henzl
@ 2015-10-29 14:37   ` Manoj Kumar
  2015-10-29 14:49     ` Don Brace
  2015-10-30  7:46   ` Hannes Reinecke
  2 siblings, 1 reply; 107+ messages in thread
From: Manoj Kumar @ 2015-10-29 14:37 UTC (permalink / raw)
  To: Don Brace, scott.teel, Kevin.Barnett, scott.benesh,
	james.bottomley, hch, Justin.Lindley, elliott
  Cc: linux-scsi

Don: See comment below.

- Manoj Kumar

On 10/28/2015 5:04 PM, Don Brace wrote:
> This function is no longer used.
>
> diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
> +#define HPSA_PERF_ERROR_BITS ((1 << DIRECT_LOOKUP_SHIFT) - 1)

HPSA_PERF_ERROR_BITS seems to be only used in the function that was
removed. Is there a reason to redefine this?



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

* Re: [PATCH 1 10/25] hpsa: correct check for non-disk devices
  2015-10-28 22:05 ` [PATCH 1 10/25] hpsa: correct check for non-disk devices Don Brace
@ 2015-10-29 14:37   ` Tomas Henzl
  2015-10-30  8:01   ` Hannes Reinecke
  1 sibling, 0 replies; 107+ messages in thread
From: Tomas Henzl @ 2015-10-29 14:37 UTC (permalink / raw)
  To: Don Brace, scott.teel, Kevin.Barnett, scott.benesh,
	james.bottomley, hch, Justin.Lindley, elliott
  Cc: linux-scsi

On 28.10.2015 23:05, Don Brace wrote:
> The driver is using two MACROs which seemingly are looking in
> the wrong location for the device_flags returned from
> CISS_REPORT_PHYS. Both MACROs, NON_DISK_PHYS_DEV and
> PHYS_IOACCEL, are using the pointer returned from figure_lunaddrbytes
> which is the address of the LUN.lunid element in
> the extended CISS_REPORT_PHYS.  But the MACROS are using offsets
> beyond the range of the element (offset 17 of an 8 byte element).
>
> These MACROs actually are looking at the correct location but
> they fail static checker analysis. It also will not work
> if any new elements are added to the extended LUN structure.
>
> Change the code to use the structure elements directly
> since this MACRO is only used in one location.
>
> Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
> Reviewed-by: Scott Teel <scott.teel@pmcs.com>
> Reviewed-by: Justin Lindley <justin.lindley@pmcs.com>
> Reviewed-by: Kevin Barnett <kevin.barnett@pmcs.com>
> Signed-off-by: Don Brace <don.brace@pmcs.com>

Reviewed-by: Tomas Henzl <thenzl@redhat.com>

Tomas


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

* Re: [PATCH 1 03/25] hpsa: check for null arguments to dev_printk
  2015-10-28 22:04 ` [PATCH 1 03/25] hpsa: check for null arguments to dev_printk Don Brace
  2015-10-29 13:41   ` Tomas Henzl
@ 2015-10-29 14:41   ` Manoj Kumar
  2015-10-30  7:47   ` Hannes Reinecke
  2 siblings, 0 replies; 107+ messages in thread
From: Manoj Kumar @ 2015-10-29 14:41 UTC (permalink / raw)
  To: Don Brace, scott.teel, Kevin.Barnett, scott.benesh,
	james.bottomley, hch, Justin.Lindley, elliott
  Cc: linux-scsi


On 10/28/2015 5:04 PM, Don Brace wrote:
> Check for NULLs.
> -	int devtype;
> +	unsigned int devtype;

Don:

Unrelated to the NULL argument check. Would have been preferable in a
distinct patch.

Reviewed-by: Manoj Kumar <manoj@linux.vnet.ibm.com>

---
Manoj Kumar



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

* Re: [PATCH 1 02/25] hpsa: remove unused hpsa_tag_discard_error_bits
  2015-10-29 14:37   ` Manoj Kumar
@ 2015-10-29 14:49     ` Don Brace
  0 siblings, 0 replies; 107+ messages in thread
From: Don Brace @ 2015-10-29 14:49 UTC (permalink / raw)
  To: manoj, scott.teel, Kevin.Barnett, scott.benesh, james.bottomley,
	hch, Justin.Lindley, elliott
  Cc: linux-scsi

On 10/29/2015 09:37 AM, Manoj Kumar wrote:
> Don: See comment below.
>
> - Manoj Kumar
>
> On 10/28/2015 5:04 PM, Don Brace wrote:
>> This function is no longer used.
>>
>> diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
>> +#define HPSA_PERF_ERROR_BITS ((1 << DIRECT_LOOKUP_SHIFT) - 1)
>
> HPSA_PERF_ERROR_BITS seems to be only used in the function that was
> removed. Is there a reason to redefine this?
>
No, I'll remove it. Thanks!


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

* Re: [PATCH 1 11/25] hpsa: correct ioaccel2 sg chain len
  2015-10-28 22:05 ` [PATCH 1 11/25] hpsa: correct ioaccel2 sg chain len Don Brace
@ 2015-10-29 15:01   ` Tomas Henzl
  2015-10-30  8:01   ` Hannes Reinecke
  1 sibling, 0 replies; 107+ messages in thread
From: Tomas Henzl @ 2015-10-29 15:01 UTC (permalink / raw)
  To: Don Brace, scott.teel, Kevin.Barnett, scott.benesh,
	james.bottomley, hch, Justin.Lindley, elliott
  Cc: linux-scsi

On 28.10.2015 23:05, Don Brace wrote:
> Reviewed-by: Scott Teel <scott.teel@pmcs.com>
> Reviewed-by: Justin Lindley <justin.lindley@pmcs.com>
> Reviewed-by: Kevin Barnett <kevin.barnett@pmcs.com>
> Signed-off-by: Don Brace <don.brace@pmcs.com>

Reviewed-by: Tomas Henzl <thenzl@redhat.com>

Tomas


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

* Re: [PATCH 1 12/25] hpsa: simplify check for device exposure
  2015-10-28 22:05 ` [PATCH 1 12/25] hpsa: simplify check for device exposure Don Brace
@ 2015-10-29 15:03   ` Tomas Henzl
  2015-10-30  8:04   ` Hannes Reinecke
  1 sibling, 0 replies; 107+ messages in thread
From: Tomas Henzl @ 2015-10-29 15:03 UTC (permalink / raw)
  To: Don Brace, scott.teel, Kevin.Barnett, scott.benesh,
	james.bottomley, hch, Justin.Lindley, elliott
  Cc: linux-scsi

On 28.10.2015 23:05, Don Brace wrote:
> From: Kevin Barnett <kevin.barnett@pmcs.com>
>
> remove macros and cleanup device exposure checking
>
> Reviewed-by: Scott Teel <scott.teel@pmcs.com>
> Reviewed-by: Justin Lindley <justin.lindley@pmcs.com>
> Reviewed-by: Kevin Barnett <kevin.barnett@pmcs.com>
> Signed-off-by: Don Brace <don.brace@pmcs.com>

Reviewed-by: Tomas Henzl <thenzl@redhat.com>

Tomas


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

* Re: [PATCH 1 09/25] hpsa: fix physical target reset
  2015-10-29 14:30   ` Tomas Henzl
@ 2015-10-29 15:29     ` Don Brace
  2015-10-29 15:52       ` Tomas Henzl
  0 siblings, 1 reply; 107+ messages in thread
From: Don Brace @ 2015-10-29 15:29 UTC (permalink / raw)
  To: Tomas Henzl, scott.teel, Kevin.Barnett, scott.benesh,
	james.bottomley, hch, Justin.Lindley, elliott
  Cc: linux-scsi

On 10/29/2015 09:30 AM, Tomas Henzl wrote:
> On 28.10.2015 23:05, Don Brace wrote:
>> From: Scott Teel <scott.teel@pmcs.com>
>>
>> Set reset type in device_reset_handler to do either
>> logical unit reset for logical devices, or physical
>> target reset, for physical devices.
>>
>> Reviewed-by: Scott Teel <scott.teel@pmcs.com>
>> Reviewed-by: Justin Lindley <justin.lindley@pmcs.com>
>> Reviewed-by: Kevin Barnett <kevin.barnett@pmcs.com>
>> Signed-off-by: Don Brace <don.brace@pmcs.com>
>> ---
>>   drivers/scsi/hpsa.c |   34 ++++++++++++++++++++++++++++------
>>   drivers/scsi/hpsa.h |    1 +
>>   2 files changed, 29 insertions(+), 6 deletions(-)
>>
>> diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
>> index 08a761c..67136fb 100644
>> --- a/drivers/scsi/hpsa.c
>> +++ b/drivers/scsi/hpsa.c
>> @@ -2746,9 +2746,8 @@ static int hpsa_send_reset(struct ctlr_info *h, unsigned char *scsi3addr,
>>   
>>   
>>   	/* fill_cmd can't fail here, no data buffer to map. */
>> -	(void) fill_cmd(c, HPSA_DEVICE_RESET_MSG, h, NULL, 0, 0,
>> +	(void) fill_cmd(c, reset_type, h, NULL, 0, 0,
>>   			scsi3addr, TYPE_MSG);
>> -	c->Request.CDB[1] = reset_type; /* fill_cmd defaults to LUN reset */
>>   	rc = hpsa_scsi_do_simple_cmd(h, c, reply_queue, NO_TIMEOUT);
>>   	if (rc) {
>>   		dev_warn(&h->pdev->dev, "Failed to send reset command\n");
>> @@ -5216,6 +5215,7 @@ static int hpsa_eh_device_reset_handler(struct scsi_cmnd *scsicmd)
>>   	int rc;
>>   	struct ctlr_info *h;
>>   	struct hpsa_scsi_dev_t *dev;
>> +	u8 reset_type;
>>   	char msg[48];
>>   
>>   	/* find the controller to which the command to be aborted was sent */
>> @@ -5254,15 +5254,23 @@ static int hpsa_eh_device_reset_handler(struct scsi_cmnd *scsicmd)
>>   	if (is_hba_lunid(dev->scsi3addr))
>>   		return SUCCESS;
>>   
>> -	hpsa_show_dev_msg(KERN_WARNING, h, dev, "resetting");
>> +	if (is_logical_dev_addr_mode(dev->scsi3addr))
>> +		reset_type = HPSA_DEVICE_RESET_MSG;
>> +	else
>> +		reset_type = HPSA_PHYS_TARGET_RESET;
>> +
>> +	sprintf(msg, "resetting %s",
>> +		reset_type == HPSA_DEVICE_RESET_MSG ? "logical " : "physical ");
>> +	hpsa_show_dev_msg(KERN_WARNING, h, dev, msg);
>>   
>> */
> Will this new reset command work for the whole range of hpsa devices?
> (and for the older cciss hw - hpsa_allow_any) ?
The new reset works for newer controller that support HBA mode or IO
bypass mode that allow the driver to send commands directly to a
physical device. This new reset is for those situations.

We still do the existing reset for RAID volumes.
>
>>   #define HPSA_MSG_SEND_RETRY_LIMIT 10
>>   #define HPSA_MSG_SEND_RETRY_INTERVAL_MSECS (10000)
>>   
>>
>> --
>> To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
>> the body of a message to majordomo@vger.kernel.org
>> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> --
> To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html


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

* Re: [PATCH 1 09/25] hpsa: fix physical target reset
  2015-10-29 15:29     ` Don Brace
@ 2015-10-29 15:52       ` Tomas Henzl
  0 siblings, 0 replies; 107+ messages in thread
From: Tomas Henzl @ 2015-10-29 15:52 UTC (permalink / raw)
  To: Don Brace, scott.teel, Kevin.Barnett, scott.benesh,
	james.bottomley, hch, Justin.Lindley, elliott
  Cc: linux-scsi

On 29.10.2015 16:29, Don Brace wrote:
> On 10/29/2015 09:30 AM, Tomas Henzl wrote:
>> On 28.10.2015 23:05, Don Brace wrote:
>>> From: Scott Teel <scott.teel@pmcs.com>
>>>
>>> Set reset type in device_reset_handler to do either
>>> logical unit reset for logical devices, or physical
>>> target reset, for physical devices.
>>>
>>> Reviewed-by: Scott Teel <scott.teel@pmcs.com>
>>> Reviewed-by: Justin Lindley <justin.lindley@pmcs.com>
>>> Reviewed-by: Kevin Barnett <kevin.barnett@pmcs.com>
>>> Signed-off-by: Don Brace <don.brace@pmcs.com>
>>> ---
>>>   drivers/scsi/hpsa.c |   34 ++++++++++++++++++++++++++++------
>>>   drivers/scsi/hpsa.h |    1 +
>>>   2 files changed, 29 insertions(+), 6 deletions(-)
>>>
>>> diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
>>> index 08a761c..67136fb 100644
>>> --- a/drivers/scsi/hpsa.c
>>> +++ b/drivers/scsi/hpsa.c
>>> @@ -2746,9 +2746,8 @@ static int hpsa_send_reset(struct ctlr_info *h, unsigned char *scsi3addr,
>>>   
>>>   
>>>   	/* fill_cmd can't fail here, no data buffer to map. */
>>> -	(void) fill_cmd(c, HPSA_DEVICE_RESET_MSG, h, NULL, 0, 0,
>>> +	(void) fill_cmd(c, reset_type, h, NULL, 0, 0,
>>>   			scsi3addr, TYPE_MSG);
>>> -	c->Request.CDB[1] = reset_type; /* fill_cmd defaults to LUN reset */
>>>   	rc = hpsa_scsi_do_simple_cmd(h, c, reply_queue, NO_TIMEOUT);
>>>   	if (rc) {
>>>   		dev_warn(&h->pdev->dev, "Failed to send reset command\n");
>>> @@ -5216,6 +5215,7 @@ static int hpsa_eh_device_reset_handler(struct scsi_cmnd *scsicmd)
>>>   	int rc;
>>>   	struct ctlr_info *h;
>>>   	struct hpsa_scsi_dev_t *dev;
>>> +	u8 reset_type;
>>>   	char msg[48];
>>>   
>>>   	/* find the controller to which the command to be aborted was sent */
>>> @@ -5254,15 +5254,23 @@ static int hpsa_eh_device_reset_handler(struct scsi_cmnd *scsicmd)
>>>   	if (is_hba_lunid(dev->scsi3addr))
>>>   		return SUCCESS;
>>>   
>>> -	hpsa_show_dev_msg(KERN_WARNING, h, dev, "resetting");
>>> +	if (is_logical_dev_addr_mode(dev->scsi3addr))
>>> +		reset_type = HPSA_DEVICE_RESET_MSG;
>>> +	else
>>> +		reset_type = HPSA_PHYS_TARGET_RESET;
>>> +
>>> +	sprintf(msg, "resetting %s",
>>> +		reset_type == HPSA_DEVICE_RESET_MSG ? "logical " : "physical ");
>>> +	hpsa_show_dev_msg(KERN_WARNING, h, dev, msg);
>>>   
>>> */
>> Will this new reset command work for the whole range of hpsa devices?
>> (and for the older cciss hw - hpsa_allow_any) ?
> The new reset works for newer controller that support HBA mode or IO
> bypass mode that allow the driver to send commands directly to a
> physical device. This new reset is for those situations.
>
> We still do the existing reset for RAID volumes.

ok, so -
Reviewed-by: Tomas Henzl <thenzl@redhat.com>

Tomas



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

* Re: [PATCH 1 13/25] hpsa: simplify update scsi devices
  2015-10-28 22:05 ` [PATCH 1 13/25] hpsa: simplify update scsi devices Don Brace
@ 2015-10-29 15:53   ` Tomas Henzl
  2015-10-29 16:43   ` Matthew R. Ochs
  2015-10-30  8:05   ` Hannes Reinecke
  2 siblings, 0 replies; 107+ messages in thread
From: Tomas Henzl @ 2015-10-29 15:53 UTC (permalink / raw)
  To: Don Brace, scott.teel, Kevin.Barnett, scott.benesh,
	james.bottomley, hch, Justin.Lindley, elliott
  Cc: linux-scsi

On 28.10.2015 23:05, Don Brace wrote:
> From: Kevin Barnett <kevin.barnett@pmcs.com>
>
> remove repeated calculation that checks for physical
> or logical devices.
>
> Reviewed-by: Scott Teel <scott.teel@pmcs.com>
> Reviewed-by: Justin Lindley <justin.lindley@pmcs.com>
> Reviewed-by: Kevin Barnett <kevin.barnett@pmcs.com>
> Signed-off-by: Don Brace <don.brace@pmcs.com>

Reviewed-by: Tomas Henzl <thenzl@redhat.com>

Tomas


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

* Re: [PATCH 1 14/25] hpsa: add function is_logical_device
  2015-10-28 22:05 ` [PATCH 1 14/25] hpsa: add function is_logical_device Don Brace
@ 2015-10-29 15:53   ` Tomas Henzl
  2015-10-29 16:46   ` Matthew R. Ochs
  2015-10-30  8:05   ` Hannes Reinecke
  2 siblings, 0 replies; 107+ messages in thread
From: Tomas Henzl @ 2015-10-29 15:53 UTC (permalink / raw)
  To: Don Brace, scott.teel, Kevin.Barnett, scott.benesh,
	james.bottomley, hch, Justin.Lindley, elliott
  Cc: linux-scsi

On 28.10.2015 23:05, Don Brace wrote:
> From: Kevin Barnett <kevin.barnett@pmcs.com>
>
> simplify checking for logical/physical devices
>
> Reviewed-by: Scott Teel <scott.teel@pmcs.com>
> Reviewed-by: Justin Lindley <justin.lindley@pmcs.com>
> Reviewed-by: Kevin Barnett <kevin.barnett@pmcs.com>
> Signed-off-by: Don Brace <don.brace@pmcs.com>

Reviewed-by: Tomas Henzl <thenzl@redhat.com>

Tomas


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

* Re: [PATCH 1 15/25] hpsa: enhance hpsa_get_device_id
  2015-10-28 22:06 ` [PATCH 1 15/25] hpsa: enhance hpsa_get_device_id Don Brace
@ 2015-10-29 16:04   ` Tomas Henzl
  2015-10-29 17:04   ` Matthew R. Ochs
  2015-10-30  8:08   ` Hannes Reinecke
  2 siblings, 0 replies; 107+ messages in thread
From: Tomas Henzl @ 2015-10-29 16:04 UTC (permalink / raw)
  To: Don Brace, scott.teel, Kevin.Barnett, scott.benesh,
	james.bottomley, hch, Justin.Lindley, elliott
  Cc: linux-scsi

On 28.10.2015 23:06, Don Brace wrote:
> use an index into vpd data for SAS/SATA drives
>
> Reviewed-by: Scott Teel <scott.teel@pmcs.com>
> Reviewed-by: Justin Lindley <justin.lindley@pmcs.com>
> Reviewed-by: Kevin Barnett <kevin.barnett@pmcs.com>
> Signed-off-by: Don Brace <don.brace@pmcs.com>

Reviewed-by: Tomas Henzl <thenzl@redhat.com>

Tomas


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

* Re: [PATCH 1 16/25] hpsa: refactor hpsa_figure_bus_target_lun
  2015-10-28 22:06 ` [PATCH 1 16/25] hpsa: refactor hpsa_figure_bus_target_lun Don Brace
@ 2015-10-29 16:27   ` Tomas Henzl
  2015-10-30  8:09   ` Hannes Reinecke
  1 sibling, 0 replies; 107+ messages in thread
From: Tomas Henzl @ 2015-10-29 16:27 UTC (permalink / raw)
  To: Don Brace, scott.teel, Kevin.Barnett, scott.benesh,
	james.bottomley, hch, Justin.Lindley, elliott
  Cc: linux-scsi

On 28.10.2015 23:06, Don Brace wrote:
> From: Kevin Barnett <kevin.barnett@pmcs.com>
>
> setup for sas transport. Need to set the
> bus and target accordingly.
>
> Reviewed-by: Scott Teel <scott.teel@pmcs.com>
> Reviewed-by: Justin Lindley <justin.lindley@pmcs.com>
> Reviewed-by: Kevin Barnett <kevin.barnett@pmcs.com>
> Signed-off-by: Don Brace <don.brace@pmcs.com>
> ---
>  drivers/scsi/hpsa.c |   25 ++++++++++++-------------
>  drivers/scsi/hpsa.h |    5 +++++
>  2 files changed, 17 insertions(+), 13 deletions(-)
>
> diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
> index 1361414..24b3c8c 100644
> --- a/drivers/scsi/hpsa.c
> +++ b/drivers/scsi/hpsa.c
> @@ -3521,38 +3521,37 @@ static int is_ext_target(struct ctlr_info *h, struct hpsa_scsi_dev_t *device)
>  	return 0;
>  }
>  
> -/* Helper function to assign bus, target, lun mapping of devices.
> - * 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.
> +/*
> + * Helper function to assign bus, target, lun mapping of devices.
>   * Logical drive target and lun are assigned at this time, but
>   * physical device lun and target assignment are deferred (assigned
>   * in hpsa_find_target_lun, called by hpsa_scsi_add_entry.)
> - */
> +*/
>  static void figure_bus_target_lun(struct ctlr_info *h,
>  	u8 *lunaddrbytes, struct hpsa_scsi_dev_t *device)
>  {
> -	u32 lunid = le32_to_cpu(*((__le32 *) lunaddrbytes));
> +	u32 lunid = get_unaligned_le32(lunaddrbytes);
>  
>  	if (!is_logical_dev_addr_mode(lunaddrbytes)) {
>  		/* physical device, target and lun filled in later */
>  		if (is_hba_lunid(lunaddrbytes))
> -			hpsa_set_bus_target_lun(device, 3, 0, lunid & 0x3fff);
> +			hpsa_set_bus_target_lun(device,
> +					HPSA_HBA_BUS, 0, lunid & 0x3fff);
>  		else
>  			/* defer target, lun assignment for physical devices */
> -			hpsa_set_bus_target_lun(device, 2, -1, -1);
> +			hpsa_set_bus_target_lun(device,
> +					HPSA_PHYSICAL_DEVICE_BUS, -1, -1);
>  		return;
>  	}
>  	/* It's a logical device */
>  	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
> -		 */
>  		hpsa_set_bus_target_lun(device,
> -			1, (lunid >> 16) & 0x3fff, lunid & 0x00ff);
> +			HPSA_EXTERNAL_RAID_VOLUME_BUS, (lunid >> 16) & 0x3fff,
> +			lunid & 0x00ff);
>  		return;
>  	}
> -	hpsa_set_bus_target_lun(device, 0, 0, lunid & 0x3fff);
> +	hpsa_set_bus_target_lun(device, HPSA_RAID_VOLUME_BUS,
> +				0, lunid & 0x3fff);
>  }
>  
>  /*
> diff --git a/drivers/scsi/hpsa.h b/drivers/scsi/hpsa.h
> index 808b520..38d5534 100644
> --- a/drivers/scsi/hpsa.h
> +++ b/drivers/scsi/hpsa.h
> @@ -367,6 +367,11 @@ struct offline_device_entry {
>  #define IOACCEL2_INBOUND_POSTQ_64_LOW	0xd0
>  #define IOACCEL2_INBOUND_POSTQ_64_HI	0xd4
>  
> +#define HPSA_PHYSICAL_DEVICE_BUS	0
> +#define HPSA_RAID_VOLUME_BUS		1
> +#define HPSA_EXTERNAL_RAID_VOLUME_BUS	2
> +#define HPSA_HBA_BUS			3

Some of the numbers changed their values from what they used 
to be before. It probably doesn't matter, but users may be used
to certain numbers assigned and this will change the scheme.
If there is no reason for the change, please keep the numbering
stable.
-tm

> +
>  /*
>  	Send the command to the hardware
>  */
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html


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

* Re: [PATCH 1 17/25] hpsa: move scsi_add_device and scsi_remove_device calls to new function
  2015-10-28 22:06 ` [PATCH 1 17/25] hpsa: move scsi_add_device and scsi_remove_device calls to new function Don Brace
@ 2015-10-29 16:37   ` Tomas Henzl
  2015-10-29 17:21   ` Matthew R. Ochs
  2015-10-30  8:09   ` Hannes Reinecke
  2 siblings, 0 replies; 107+ messages in thread
From: Tomas Henzl @ 2015-10-29 16:37 UTC (permalink / raw)
  To: Don Brace, scott.teel, Kevin.Barnett, scott.benesh,
	james.bottomley, hch, Justin.Lindley, elliott
  Cc: linux-scsi

On 28.10.2015 23:06, Don Brace wrote:
> From: Kevin Barnett <kevin.barnett@pmcs.com>
>
> preparation for adding the sas transport class
>
> Reviewed-by: Scott Teel <scott.teel@pmcs.com>
> Reviewed-by: Justin Lindley <justin.lindley@pmcs.com>
> Reviewed-by: Kevin Barnett <kevin.barnett@pmcs.com>
> Signed-off-by: Don Brace <don.brace@pmcs.com>
> ---
>  drivers/scsi/hpsa.c |   65 +++++++++++++++++++++++++++++++--------------------
>  1 file changed, 39 insertions(+), 26 deletions(-)
>
> diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
> index 24b3c8c..06207e2 100644
> --- a/drivers/scsi/hpsa.c
> +++ b/drivers/scsi/hpsa.c
> @@ -1660,6 +1660,37 @@ static void hpsa_update_log_drive_phys_drive_ptrs(struct ctlr_info *h,
>  	}
>  }
>  
> +static int hpsa_add_device(struct ctlr_info *h, struct hpsa_scsi_dev_t *device)
> +{
> +	int rc = 0;

Just int rc; is better, but it's a nit.
(and struct scsi_device *sdev; few lines below)

Reviewed-by: Tomas Henzl <thenzl@redhat.com>

Tomas

> +
> +	rc = scsi_add_device(h->scsi_host, device->bus,
> +					device->target, device->lun);
> +	return rc;
> +}
> +
> +static void hpsa_remove_device(struct ctlr_info *h,
> +			struct hpsa_scsi_dev_t *device)
> +{
> +	struct scsi_device *sdev = NULL;
> +
> +	sdev = scsi_device_lookup(h->scsi_host, device->bus,
> +						device->target, device->lun);
> +
> +	if (sdev) {
> +		scsi_remove_device(sdev);
> +		scsi_device_put(sdev);
> +	} else {
> +		/*
> +		 * We don't expect to get here.  Future commands
> +		 * to this device will get a selection timeout as
> +		 * if the device were gone.
> +		 */
> +		hpsa_show_dev_msg(KERN_WARNING, h, device,
> +					"didn't find device for removal.");
> +	}
> +}
> +
>  static void adjust_hpsa_scsi_table(struct ctlr_info *h, int hostno,
>  	struct hpsa_scsi_dev_t *sd[], int nsds)
>  {
> @@ -1672,7 +1703,6 @@ static void adjust_hpsa_scsi_table(struct ctlr_info *h, int hostno,
>  	unsigned long flags;
>  	struct hpsa_scsi_dev_t **added, **removed;
>  	int nadded, nremoved;
> -	struct Scsi_Host *sh = NULL;
>  
>  	/*
>  	 * A reset can cause a device status to change
> @@ -1792,46 +1822,29 @@ static void adjust_hpsa_scsi_table(struct ctlr_info *h, int hostno,
>  	if (hostno == -1 || !changes)
>  		goto free_and_out;
>  
> -	sh = h->scsi_host;
> -	if (sh == NULL) {
> -		dev_warn(&h->pdev->dev, "%s: scsi_host is null\n", __func__);
> -		return;
> -	}
>  	/* Notify scsi mid layer of any removed devices */
>  	for (i = 0; i < nremoved; i++) {
>  		if (removed[i] == NULL)
>  			continue;
> -		if (removed[i]->expose_device) {
> -			struct scsi_device *sdev =
> -				scsi_device_lookup(sh, removed[i]->bus,
> -					removed[i]->target, removed[i]->lun);
> -			if (sdev != NULL) {
> -				scsi_remove_device(sdev);
> -				scsi_device_put(sdev);
> -			} else {
> -				/*
> -				 * We don't expect to get here.
> -				 * future cmds to this device will get selection
> -				 * timeout as if the device was gone.
> -				 */
> -				hpsa_show_dev_msg(KERN_WARNING, h, removed[i],
> -					"didn't find device for removal.");
> -			}
> -		}
> +		if (removed[i]->expose_device)
> +			hpsa_remove_device(h, removed[i]);
>  		kfree(removed[i]);
>  		removed[i] = NULL;
>  	}
>  
>  	/* Notify scsi mid layer of any added devices */
>  	for (i = 0; i < nadded; i++) {
> +		int rc = 0;
> +
>  		if (added[i] == NULL)
>  			continue;
>  		if (!(added[i]->expose_device))
>  			continue;
> -		if (scsi_add_device(sh, added[i]->bus,
> -			added[i]->target, added[i]->lun) == 0)
> +		rc = hpsa_add_device(h, added[i]);
> +		if (!rc)
>  			continue;
> -		dev_warn(&h->pdev->dev, "addition failed, device not added.");
> +		dev_warn(&h->pdev->dev,
> +			"addition failed %d, device not added.", rc);
>  		/* now we have to remove it from h->dev,
>  		 * since it didn't get added to scsi mid layer
>  		 */
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html


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

* Re: [PATCH 1 13/25] hpsa: simplify update scsi devices
  2015-10-28 22:05 ` [PATCH 1 13/25] hpsa: simplify update scsi devices Don Brace
  2015-10-29 15:53   ` Tomas Henzl
@ 2015-10-29 16:43   ` Matthew R. Ochs
  2015-10-29 19:01     ` Don Brace
  2015-10-30  8:05   ` Hannes Reinecke
  2 siblings, 1 reply; 107+ messages in thread
From: Matthew R. Ochs @ 2015-10-29 16:43 UTC (permalink / raw)
  To: Don Brace
  Cc: scott.teel, Kevin.Barnett, scott.benesh, james.bottomley, hch,
	Justin.Lindley, elliott, linux-scsi

> On Oct 28, 2015, at 5:05 PM, Don Brace <don.brace@pmcs.com> wrote:
> 
> From: Kevin Barnett <kevin.barnett@pmcs.com>
> 
> remove repeated calculation that checks for physical
> or logical devices.
> 
> Reviewed-by: Scott Teel <scott.teel@pmcs.com>
> Reviewed-by: Justin Lindley <justin.lindley@pmcs.com>
> Reviewed-by: Kevin Barnett <kevin.barnett@pmcs.com>
> Signed-off-by: Don Brace <don.brace@pmcs.com>
> ---
> drivers/scsi/hpsa.c |   23 ++++++++++++++---------
> drivers/scsi/hpsa.h |    1 +
> 2 files changed, 15 insertions(+), 9 deletions(-)
> 
> diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
> index d011540..7c1a552 100644
> --- a/drivers/scsi/hpsa.c
> +++ b/drivers/scsi/hpsa.c
> @@ -3761,6 +3761,7 @@ static void hpsa_update_scsi_devices(struct ctlr_info *h, int hostno)
> 	int ncurrent = 0;
> 	int i, n_ext_target_devs, ndevs_to_allocate;
> 	int raid_ctlr_position;
> +	bool physical_device;

Any particular reason for using a bool here and a u8 when you cache the value?

> 	DECLARE_BITMAP(lunzerobits, MAX_EXT_TARGETS);
> 
> 	currentsd = kzalloc(sizeof(*currentsd) * HPSA_MAX_DEVICES, GFP_KERNEL);
> @@ -3821,16 +3822,17 @@ static void hpsa_update_scsi_devices(struct ctlr_info *h, int hostno)
> 		int rc = 0;
> 		int phys_dev_index = i - (raid_ctlr_position == 0);
> 
> +		physical_device = i < nphysicals + (raid_ctlr_position == 0);
> +
> 		/* Figure out where the LUN ID info is coming from */
> 		lunaddrbytes = figure_lunaddrbytes(h, raid_ctlr_position,
> 			i, nphysicals, nlogicals, physdev_list, logdev_list);
> 
> 		/* skip masked non-disk devices */
> -		if (MASKED_DEVICE(lunaddrbytes))
> -			if (i < nphysicals + (raid_ctlr_position == 0) &&
> -				(physdev_list->
> -				LUN[phys_dev_index].device_flags & 0x01))
> -				continue;
> +		if (physical_device &&
> +			MASKED_DEVICE(lunaddrbytes) &&
> +			(physdev_list->LUN[phys_dev_index].device_flags & 0x01))
> +			continue;

In this conditional you swapped the ordering, evaluating physical_device first, why?

> 
> 		/* Get device type, vendor, model, device id */
> 		rc = hpsa_update_device_info(h, lunaddrbytes, tmpdevice,
> @@ -3866,10 +3868,13 @@ static void hpsa_update_scsi_devices(struct ctlr_info *h, int hostno)
> 		}
> 
> 		*this_device = *tmpdevice;
> +		this_device->physical_device = physical_device;
> 
> -		/* do not expose masked devices */
> -		if (MASKED_DEVICE(lunaddrbytes) &&
> -			i < nphysicals + (raid_ctlr_position == 0))
> +		/*
> +		 * Expose all devices except for physical devices that
> +		 * are masked.
> +		 */
> +		if (MASKED_DEVICE(lunaddrbytes) && this_device->physical_device)
> 			this_device->expose_device = 0;
> 		else
> 			this_device->expose_device = 1;
> @@ -3887,7 +3892,7 @@ static void hpsa_update_scsi_devices(struct ctlr_info *h, int hostno)
> 				ncurrent++;
> 			break;
> 		case TYPE_DISK:
> -			if (i < nphysicals + (raid_ctlr_position == 0)) {
> +			if (this_device->physical_device) {
> 				/* The disk is in HBA mode. */
> 				/* Never use RAID mapper in HBA mode. */
> 				this_device->offload_enabled = 0;
> diff --git a/drivers/scsi/hpsa.h b/drivers/scsi/hpsa.h
> index a6ead07..808b520 100644
> --- a/drivers/scsi/hpsa.h
> +++ b/drivers/scsi/hpsa.h
> @@ -37,6 +37,7 @@ struct hpsa_scsi_dev_t {
> 	unsigned int devtype;
> 	int bus, target, lun;		/* as presented to the OS */
> 	unsigned char scsi3addr[8];	/* as presented to the HW */
> +	u8 physical_device;
> 	u8 expose_device;
> #define RAID_CTLR_LUNID "\0\0\0\0\0\0\0\0"
> 	unsigned char device_id[16];    /* from inquiry pg. 0x83 */
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 


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

* Re: [PATCH 1 14/25] hpsa: add function is_logical_device
  2015-10-28 22:05 ` [PATCH 1 14/25] hpsa: add function is_logical_device Don Brace
  2015-10-29 15:53   ` Tomas Henzl
@ 2015-10-29 16:46   ` Matthew R. Ochs
  2015-10-30  8:05   ` Hannes Reinecke
  2 siblings, 0 replies; 107+ messages in thread
From: Matthew R. Ochs @ 2015-10-29 16:46 UTC (permalink / raw)
  To: Don Brace
  Cc: scott.teel, Kevin.Barnett, scott.benesh, james.bottomley, hch,
	Justin.Lindley, elliott, linux-scsi

Reviewed-by: Matthew R. Ochs <mrochs@linux.vnet.ibm.com>


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

* Re: [PATCH 1 15/25] hpsa: enhance hpsa_get_device_id
  2015-10-28 22:06 ` [PATCH 1 15/25] hpsa: enhance hpsa_get_device_id Don Brace
  2015-10-29 16:04   ` Tomas Henzl
@ 2015-10-29 17:04   ` Matthew R. Ochs
  2015-10-30  8:08   ` Hannes Reinecke
  2 siblings, 0 replies; 107+ messages in thread
From: Matthew R. Ochs @ 2015-10-29 17:04 UTC (permalink / raw)
  To: Don Brace
  Cc: scott.teel, Kevin.Barnett, scott.benesh, james.bottomley, hch,
	Justin.Lindley, elliott, linux-scsi

> On Oct 28, 2015, at 5:06 PM, Don Brace <don.brace@pmcs.com> wrote:
> 
> use an index into vpd data for SAS/SATA drives
> 
> Reviewed-by: Scott Teel <scott.teel@pmcs.com>
> Reviewed-by: Justin Lindley <justin.lindley@pmcs.com>
> Reviewed-by: Kevin Barnett <kevin.barnett@pmcs.com>
> Signed-off-by: Don Brace <don.brace@pmcs.com>
> ---
> drivers/scsi/hpsa.c |   23 ++++++++++++++++++++---
> 1 file changed, 20 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
> index c1b053f..1361414 100644
> --- a/drivers/scsi/hpsa.c
> +++ b/drivers/scsi/hpsa.c
> @@ -3137,7 +3137,7 @@ out:
> 
> /* Get the device id from inquiry page 0x83 */
> static int hpsa_get_device_id(struct ctlr_info *h, unsigned char *scsi3addr,
> -	unsigned char *device_id, int buflen)
> +	unsigned char *device_id, int index, int buflen)
> {
> 	int rc;
> 	unsigned char *buf;
> @@ -3149,8 +3149,10 @@ static int hpsa_get_device_id(struct ctlr_info *h, unsigned char *scsi3addr,
> 		return -ENOMEM;
> 	rc = hpsa_scsi_do_inquiry(h, scsi3addr, VPD_PAGE | 0x83, buf, 64);
> 	if (rc == 0)
> -		memcpy(device_id, &buf[8], buflen);
> +		memcpy(device_id, &buf[index], buflen);
> +
> 	kfree(buf);
> +
> 	return rc != 0;
> }
> 
> @@ -3379,6 +3381,18 @@ static int hpsa_device_supports_aborts(struct ctlr_info *h,
> 	return rc;
> }
> 
> +static void sanitize_inquiry_string(unsigned char *s, int len)
> +{
> +	bool terminated = false;
> +
> +	for (; len > 0; (--len, ++s)) {
> +		if (*s == 0)
> +			terminated = true;
> +		if (terminated || *s < 0x20 || *s > 0x7e)
> +			*s = ' ';
> +	}
> +}
> +

Perhaps in a future commit the version in scsi_scan can be exported and this duplication
can be eliminated.

Reviewed-by: Matthew R. Ochs <mrochs@linux.vnet.ibm.com>


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

* Re: [PATCH 1 17/25] hpsa: move scsi_add_device and scsi_remove_device calls to new function
  2015-10-28 22:06 ` [PATCH 1 17/25] hpsa: move scsi_add_device and scsi_remove_device calls to new function Don Brace
  2015-10-29 16:37   ` Tomas Henzl
@ 2015-10-29 17:21   ` Matthew R. Ochs
  2015-10-29 20:30     ` Don Brace
  2015-10-30  8:09   ` Hannes Reinecke
  2 siblings, 1 reply; 107+ messages in thread
From: Matthew R. Ochs @ 2015-10-29 17:21 UTC (permalink / raw)
  To: Don Brace
  Cc: scott.teel, Kevin.Barnett, scott.benesh, james.bottomley, hch,
	Justin.Lindley, elliott, linux-scsi

> On Oct 28, 2015, at 5:06 PM, Don Brace <don.brace@pmcs.com> wrote:
> 
> From: Kevin Barnett <kevin.barnett@pmcs.com>
> 
> preparation for adding the sas transport class
> 
> Reviewed-by: Scott Teel <scott.teel@pmcs.com>
> Reviewed-by: Justin Lindley <justin.lindley@pmcs.com>
> Reviewed-by: Kevin Barnett <kevin.barnett@pmcs.com>
> Signed-off-by: Don Brace <don.brace@pmcs.com>
> ---
> drivers/scsi/hpsa.c |   65 +++++++++++++++++++++++++++++++--------------------
> 1 file changed, 39 insertions(+), 26 deletions(-)
> 
> diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
> index 24b3c8c..06207e2 100644
> --- a/drivers/scsi/hpsa.c
> +++ b/drivers/scsi/hpsa.c
> @@ -1660,6 +1660,37 @@ static void hpsa_update_log_drive_phys_drive_ptrs(struct ctlr_info *h,
> 	}
> }
> 
> +static int hpsa_add_device(struct ctlr_info *h, struct hpsa_scsi_dev_t *device)
> +{
> +	int rc = 0;
> +
> +	rc = scsi_add_device(h->scsi_host, device->bus,
> +					device->target, device->lun);
> +	return rc;
> +}
> +
> +static void hpsa_remove_device(struct ctlr_info *h,
> +			struct hpsa_scsi_dev_t *device)
> +{
> +	struct scsi_device *sdev = NULL;
> +
> +	sdev = scsi_device_lookup(h->scsi_host, device->bus,
> +						device->target, device->lun);
> +
> +	if (sdev) {
> +		scsi_remove_device(sdev);
> +		scsi_device_put(sdev);
> +	} else {
> +		/*
> +		 * We don't expect to get here.  Future commands
> +		 * to this device will get a selection timeout as
> +		 * if the device were gone.
> +		 */
> +		hpsa_show_dev_msg(KERN_WARNING, h, device,
> +					"didn't find device for removal.");
> +	}
> +}
> +
> static void adjust_hpsa_scsi_table(struct ctlr_info *h, int hostno,
> 	struct hpsa_scsi_dev_t *sd[], int nsds)
> {
> @@ -1672,7 +1703,6 @@ static void adjust_hpsa_scsi_table(struct ctlr_info *h, int hostno,
> 	unsigned long flags;
> 	struct hpsa_scsi_dev_t **added, **removed;
> 	int nadded, nremoved;
> -	struct Scsi_Host *sh = NULL;
> 
> 	/*
> 	 * A reset can cause a device status to change
> @@ -1792,46 +1822,29 @@ static void adjust_hpsa_scsi_table(struct ctlr_info *h, int hostno,
> 	if (hostno == -1 || !changes)
> 		goto free_and_out;
> 
> -	sh = h->scsi_host;
> -	if (sh == NULL) {
> -		dev_warn(&h->pdev->dev, "%s: scsi_host is null\n", __func__);
> -		return;
> -	}

Are we guaranteed that h->scsi_host will never be NULL when running in here? Or when
the newly introduced hpsa_remove_device() is invoked elsewhere for that matter?

This commit loses this check and scsi_device_lookup() is not tolerant of a NULL
scsi_host * (first action is to grab the host_lock).

> 	/* Notify scsi mid layer of any removed devices */
> 	for (i = 0; i < nremoved; i++) {
> 		if (removed[i] == NULL)
> 			continue;
> -		if (removed[i]->expose_device) {
> -			struct scsi_device *sdev =
> -				scsi_device_lookup(sh, removed[i]->bus,
> -					removed[i]->target, removed[i]->lun);
> -			if (sdev != NULL) {
> -				scsi_remove_device(sdev);
> -				scsi_device_put(sdev);
> -			} else {
> -				/*
> -				 * We don't expect to get here.
> -				 * future cmds to this device will get selection
> -				 * timeout as if the device was gone.
> -				 */
> -				hpsa_show_dev_msg(KERN_WARNING, h, removed[i],
> -					"didn't find device for removal.");
> -			}
> -		}
> +		if (removed[i]->expose_device)
> +			hpsa_remove_device(h, removed[i]);
> 		kfree(removed[i]);
> 		removed[i] = NULL;
> 	}
> 
> 	/* Notify scsi mid layer of any added devices */
> 	for (i = 0; i < nadded; i++) {
> +		int rc = 0;
> +
> 		if (added[i] == NULL)
> 			continue;
> 		if (!(added[i]->expose_device))
> 			continue;
> -		if (scsi_add_device(sh, added[i]->bus,
> -			added[i]->target, added[i]->lun) == 0)
> +		rc = hpsa_add_device(h, added[i]);
> +		if (!rc)
> 			continue;
> -		dev_warn(&h->pdev->dev, "addition failed, device not added.");
> +		dev_warn(&h->pdev->dev,
> +			"addition failed %d, device not added.", rc);
> 		/* now we have to remove it from h->dev,
> 		 * since it didn't get added to scsi mid layer
> 		 */
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 


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

* Re: [PATCH 1 13/25] hpsa: simplify update scsi devices
  2015-10-29 16:43   ` Matthew R. Ochs
@ 2015-10-29 19:01     ` Don Brace
  2015-10-29 20:28       ` Matthew R. Ochs
  0 siblings, 1 reply; 107+ messages in thread
From: Don Brace @ 2015-10-29 19:01 UTC (permalink / raw)
  To: Matthew R. Ochs
  Cc: scott.teel, Kevin.Barnett, scott.benesh, james.bottomley, hch,
	Justin.Lindley, elliott, linux-scsi

On 10/29/2015 11:43 AM, Matthew R. Ochs wrote:
>> On Oct 28, 2015, at 5:05 PM, Don Brace <don.brace@pmcs.com> wrote:
>>
>> From: Kevin Barnett <kevin.barnett@pmcs.com>
>>
>> remove repeated calculation that checks for physical
>> or logical devices.
>>
>> Reviewed-by: Scott Teel <scott.teel@pmcs.com>
>> Reviewed-by: Justin Lindley <justin.lindley@pmcs.com>
>> Reviewed-by: Kevin Barnett <kevin.barnett@pmcs.com>
>> Signed-off-by: Don Brace <don.brace@pmcs.com>
>> ---
>> drivers/scsi/hpsa.c |   23 ++++++++++++++---------
>> drivers/scsi/hpsa.h |    1 +
>> 2 files changed, 15 insertions(+), 9 deletions(-)
>>
>> diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
>> index d011540..7c1a552 100644
>> --- a/drivers/scsi/hpsa.c
>> +++ b/drivers/scsi/hpsa.c
>> @@ -3761,6 +3761,7 @@ static void hpsa_update_scsi_devices(struct ctlr_info *h, int hostno)
>> 	int ncurrent = 0;
>> 	int i, n_ext_target_devs, ndevs_to_allocate;
>> 	int raid_ctlr_position;
>> +	bool physical_device;
> Any particular reason for using a bool here and a u8 when you cache the value?
Changed definition to u8 physical_device : 1; in hpsa_scsi_dev_t

>
>> 	DECLARE_BITMAP(lunzerobits, MAX_EXT_TARGETS);
>>
>> 	currentsd = kzalloc(sizeof(*currentsd) * HPSA_MAX_DEVICES, GFP_KERNEL);
>> @@ -3821,16 +3822,17 @@ static void hpsa_update_scsi_devices(struct ctlr_info *h, int hostno)
>> 		int rc = 0;
>> 		int phys_dev_index = i - (raid_ctlr_position == 0);
>>
>> +		physical_device = i < nphysicals + (raid_ctlr_position == 0);
>> +
>> 		/* Figure out where the LUN ID info is coming from */
>> 		lunaddrbytes = figure_lunaddrbytes(h, raid_ctlr_position,
>> 			i, nphysicals, nlogicals, physdev_list, logdev_list);
>>
>> 		/* skip masked non-disk devices */
>> -		if (MASKED_DEVICE(lunaddrbytes))
>> -			if (i < nphysicals + (raid_ctlr_position == 0) &&
>> -				(physdev_list->
>> -				LUN[phys_dev_index].device_flags & 0x01))
>> -				continue;
>> +		if (physical_device &&
>> +			MASKED_DEVICE(lunaddrbytes) &&
>> +			(physdev_list->LUN[phys_dev_index].device_flags & 0x01))
>> +			continue;
> In this conditional you swapped the ordering, evaluating physical_device first, why?
Changed it back. Better to be consistent.
>
>> 		/* Get device type, vendor, model, device id */
>> 		rc = hpsa_update_device_info(h, lunaddrbytes, tmpdevice,
>> @@ -3866,10 +3868,13 @@ static void hpsa_update_scsi_devices(struct ctlr_info *h, int hostno)
>> 		}
>>
>> 		*this_device = *tmpdevice;
>> +		this_device->physical_device = physical_device;
>>
>> -		/* do not expose masked devices */
>> -		if (MASKED_DEVICE(lunaddrbytes) &&
>> -			i < nphysicals + (raid_ctlr_position == 0))
>> +		/*
>> +		 * Expose all devices except for physical devices that
>> +		 * are masked.
>> +		 */
>> +		if (MASKED_DEVICE(lunaddrbytes) && this_device->physical_device)
>> 			this_device->expose_device = 0;
>> 		else
>> 			this_device->expose_device = 1;
>> @@ -3887,7 +3892,7 @@ static void hpsa_update_scsi_devices(struct ctlr_info *h, int hostno)
>> 				ncurrent++;
>> 			break;
>> 		case TYPE_DISK:
>> -			if (i < nphysicals + (raid_ctlr_position == 0)) {
>> +			if (this_device->physical_device) {
>> 				/* The disk is in HBA mode. */
>> 				/* Never use RAID mapper in HBA mode. */
>> 				this_device->offload_enabled = 0;
>> diff --git a/drivers/scsi/hpsa.h b/drivers/scsi/hpsa.h
>> index a6ead07..808b520 100644
>> --- a/drivers/scsi/hpsa.h
>> +++ b/drivers/scsi/hpsa.h
>> @@ -37,6 +37,7 @@ struct hpsa_scsi_dev_t {
>> 	unsigned int devtype;
>> 	int bus, target, lun;		/* as presented to the OS */
>> 	unsigned char scsi3addr[8];	/* as presented to the HW */
>> +	u8 physical_device;
>> 	u8 expose_device;
>> #define RAID_CTLR_LUNID "\0\0\0\0\0\0\0\0"
>> 	unsigned char device_id[16];    /* from inquiry pg. 0x83 */
>>
>> --
>> To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
>> the body of a message to majordomo@vger.kernel.org
>> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html


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

* Re: [PATCH 1 18/25] External array LUNs must use target and lun numbers assigned by the
  2015-10-28 22:06 ` [PATCH 1 18/25] External array LUNs must use target and lun numbers assigned by the Don Brace
@ 2015-10-29 19:41   ` Matthew R. Ochs
  2015-10-30  8:11   ` Hannes Reinecke
  2015-10-30 14:11   ` Tomas Henzl
  2 siblings, 0 replies; 107+ messages in thread
From: Matthew R. Ochs @ 2015-10-29 19:41 UTC (permalink / raw)
  To: Don Brace
  Cc: scott.teel, Kevin.Barnett, scott.benesh, james.bottomley, hch,
	Justin.Lindley, elliott, linux-scsi

> On Oct 28, 2015, at 5:06 PM, Don Brace <don.brace@pmcs.com> wrote:
> 
> From: Scott Teel <scott.teel@pmcs.com>
> 
> external array. So the driver must treat these differently from
> local LUNs when assigning lun/target.
> 
> LUN's 'model' field has been used to detect Lun types that need
> special treatment, but the desire is to eliminate the need to reference
> specific array models, and support any external array.
> 
> Pass-through RAID (PTRAID) luns are not luns of the local controller,
> so they are not reported in LUN count of command 'ID controller'.
> However, they ARE reported in "Report logical Luns" command.
> Local luns are listed first, then PTRAID LUNs.
> 
> The number of luns from "Report LUNs" in excess of those reported by
> 'ID controller' are therefore the PTRAID LUNS.
> 
> We can now remove function is_ext_target, and the 'white list'
> array of supported model names.
> 
> Reviewed-by: Scott Teel <scott.teel@pmcs.com>
> Reviewed-by: Justin Lindley <justin.lindley@pmcs.com>
> Reviewed-by: Kevin Barnett <kevin.barnett@pmcs.com>
> Signed-off-by: Don Brace <don.brace@pmcs.com>
> ---
> drivers/scsi/hpsa.c     |  141 ++++++++++++++++++++++++++++++++++++++---------
> drivers/scsi/hpsa.h     |    1 
> drivers/scsi/hpsa_cmd.h |   11 ++++
> 3 files changed, 127 insertions(+), 26 deletions(-)
> 
> diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
> index 06207e2..11ea3e5 100644
> --- a/drivers/scsi/hpsa.c
> +++ b/drivers/scsi/hpsa.c
> @@ -276,7 +276,6 @@ static int hpsa_scsi_ioaccel_queue_command(struct ctlr_info *h,
> static void hpsa_command_resubmit_worker(struct work_struct *work);
> static u32 lockup_detected(struct ctlr_info *h);
> static int detect_controller_lockup(struct ctlr_info *h);
> -static int is_ext_target(struct ctlr_info *h, struct hpsa_scsi_dev_t *device);
> 
> static inline struct ctlr_info *sdev_to_hba(struct scsi_device *sdev)
> {
> @@ -777,7 +776,7 @@ static ssize_t path_info_show(struct device *dev,
> 				hdev->bus, hdev->target, hdev->lun,
> 				scsi_device_type(hdev->devtype));
> 
> -		if (is_ext_target(h, hdev) ||
> +		if (hdev->external ||
> 			hdev->devtype == TYPE_RAID ||
> 			is_logical_device(hdev)) {
> 			output_len += snprintf(path[i] + output_len,
> @@ -3037,6 +3036,35 @@ out:
> 	return rc;
> }
> 
> +static int hpsa_bmic_id_controller(struct ctlr_info *h,
> +	struct bmic_identify_controller *buf, size_t bufsize)
> +{
> +	int rc = IO_OK;
> +	struct CommandList *c;
> +	struct ErrorInfo *ei;
> +
> +	c = cmd_alloc(h);
> +
> +	rc = fill_cmd(c, BMIC_IDENTIFY_CONTROLLER, h, buf, bufsize,
> +		0, RAID_CTLR_LUNID, TYPE_CMD);
> +	if (rc)
> +		goto out;
> +
> +	rc = hpsa_scsi_do_simple_cmd_with_retry(h, c,
> +		PCI_DMA_FROMDEVICE, NO_TIMEOUT);
> +	if (rc)
> +		goto out;
> +	ei = c->err_info;
> +	if (ei->CommandStatus != 0 && ei->CommandStatus != CMD_DATA_UNDERRUN) {
> +		hpsa_scsi_interpret_error(h, c);
> +		rc = -1;
> +	}
> +out:
> +	cmd_free(h, c);
> +	return rc;
> +}
> +
> +
> static int hpsa_bmic_id_physical_device(struct ctlr_info *h,
> 		unsigned char scsi3addr[], u16 bmic_device_index,
> 		struct bmic_identify_physical_device *buf, size_t bufsize)
> @@ -3513,27 +3541,6 @@ static void hpsa_update_device_supports_aborts(struct ctlr_info *h,
> 	}
> }
> 
> -static unsigned char *ext_target_model[] = {
> -	"MSA2012",
> -	"MSA2024",
> -	"MSA2312",
> -	"MSA2324",
> -	"P2000 G3 SAS",
> -	"MSA 2040 SAS",
> -	NULL,
> -};
> -
> -static int is_ext_target(struct ctlr_info *h, struct hpsa_scsi_dev_t *device)
> -{
> -	int i;
> -
> -	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.
>  * Logical drive target and lun are assigned at this time, but
> @@ -3557,7 +3564,7 @@ static void figure_bus_target_lun(struct ctlr_info *h,
> 		return;
> 	}
> 	/* It's a logical device */
> -	if (is_ext_target(h, device)) {
> +	if (device->external) {
> 		hpsa_set_bus_target_lun(device,
> 			HPSA_EXTERNAL_RAID_VOLUME_BUS, (lunid >> 16) & 0x3fff,
> 			lunid & 0x00ff);
> @@ -3591,7 +3598,7 @@ static int add_ext_target_dev(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_ext_target(h, tmpdevice))
> +	if (!tmpdevice->external)
> 		return 0; /* Only external target devices have this problem. */
> 
> 	if (tmpdevice->lun == 0) /* if lun is 0, then we have a lun 0. */
> @@ -3650,6 +3657,29 @@ static int hpsa_get_pdisk_of_ioaccel2(struct ctlr_info *h,
> 	return 0;
> }
> 
> +static int  figure_external_status(struct ctlr_info *h, int raid_ctlr_position,
> +	int i, int nphysicals, int nlocal_logicals)
> +{
> +	/* In report logicals, local logicals are listed first,
> +	* then any externals.
> +	*/
> +	int logicals_start = nphysicals + (raid_ctlr_position == 0);
> +
> +	if (i == raid_ctlr_position)
> +		return 0;
> +
> +	if (i < logicals_start)
> +		return 0;
> +
> +	/* i is in logicals range, but still within local logicals */
> +	if ((i - nphysicals - (raid_ctlr_position == 0)) < nlocal_logicals)
> +		return 0;
> +
> +	return 1; /* it's an external lun */
> +}
> +
> +
> +
> /*
>  * Do CISS_REPORT_PHYS and CISS_REPORT_LOG.  Data is returned in physdev,
>  * logdev.  The number of luns in physdev and logdev are returned in
> @@ -3773,6 +3803,32 @@ static void hpsa_get_path_info(struct hpsa_scsi_dev_t *this_device,
> 		sizeof(this_device->bay));
> }
> 
> +/* get number of local logical disks. */
> +static int hpsa_set_local_logical_count(struct ctlr_info *h,
> +	struct bmic_identify_controller *id_ctlr,
> +	u32 *nlocals)
> +{
> +	int rc;
> +
> +	if (!id_ctlr) {
> +		dev_warn(&h->pdev->dev, "%s: id_ctlr buffer is NULL.\n",
> +			__func__);
> +		return -ENOMEM;
> +	}
> +	memset(id_ctlr, 0, sizeof(*id_ctlr));
> +	rc = hpsa_bmic_id_controller(h, id_ctlr, sizeof(*id_ctlr));
> +	if (!rc)
> +		if (id_ctlr->configured_logical_drive_count < 256)
> +			*nlocals = id_ctlr->configured_logical_drive_count;
> +		else
> +			*nlocals = le16_to_cpu(
> +					id_ctlr->extended_logical_unit_count);
> +	else
> +		*nlocals = -1;
> +	return rc;
> +}
> +
> +
> static void hpsa_update_scsi_devices(struct ctlr_info *h, int hostno)
> {
> 	/* the idea here is we could get notified
> @@ -3788,8 +3844,10 @@ static void hpsa_update_scsi_devices(struct ctlr_info *h, int hostno)
> 	struct ReportExtendedLUNdata *physdev_list = NULL;
> 	struct ReportLUNdata *logdev_list = NULL;
> 	struct bmic_identify_physical_device *id_phys = NULL;
> +	struct bmic_identify_controller *id_ctlr = NULL;
> 	u32 nphysicals = 0;
> 	u32 nlogicals = 0;
> +	u32 nlocal_logicals = 0;
> 	u32 ndev_allocated = 0;
> 	struct hpsa_scsi_dev_t **currentsd, *this_device, *tmpdevice;
> 	int ncurrent = 0;
> @@ -3803,9 +3861,10 @@ static void hpsa_update_scsi_devices(struct ctlr_info *h, int hostno)
> 	logdev_list = kzalloc(sizeof(*logdev_list), GFP_KERNEL);
> 	tmpdevice = kzalloc(sizeof(*tmpdevice), GFP_KERNEL);
> 	id_phys = kzalloc(sizeof(*id_phys), GFP_KERNEL);
> +	id_ctlr = kzalloc(sizeof(*id_ctlr), GFP_KERNEL);
> 
> 	if (!currentsd || !physdev_list || !logdev_list ||
> -		!tmpdevice || !id_phys) {
> +		!tmpdevice || !id_phys || !id_ctlr) {
> 		dev_err(&h->pdev->dev, "out of memory\n");
> 		goto out;
> 	}
> @@ -3819,6 +3878,13 @@ static void hpsa_update_scsi_devices(struct ctlr_info *h, int hostno)
> 		goto out;
> 	}
> 
> +	/* Set number of local logicals (non PTRAID) */
> +	if (hpsa_set_local_logical_count(h, id_ctlr, &nlocal_logicals)) {
> +		dev_warn(&h->pdev->dev,
> +			"%s: Can't determine number of local logical devices.\n",
> +			__func__);
> +	}
> +
> 	/* 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.
> @@ -3883,6 +3949,11 @@ static void hpsa_update_scsi_devices(struct ctlr_info *h, int hostno)
> 			continue;
> 		}
> 
> +		/* Determine if this is a lun from an external target array */
> +		tmpdevice->external =
> +			figure_external_status(h, raid_ctlr_position, i,
> +						nphysicals, nlocal_logicals);
> +
> 		figure_bus_target_lun(h, lunaddrbytes, tmpdevice);
> 		hpsa_update_device_supports_aborts(h, tmpdevice, lunaddrbytes);
> 		this_device = currentsd[ncurrent];
> @@ -3966,6 +4037,7 @@ out:
> 	kfree(currentsd);
> 	kfree(physdev_list);
> 	kfree(logdev_list);
> +	kfree(id_ctlr);
> 	kfree(id_phys);
> }
> 
> @@ -6418,6 +6490,23 @@ static int fill_cmd(struct CommandList *c, u8 cmd, struct ctlr_info *h,
> 			c->Request.CDB[7] = (size >> 16) & 0xFF;
> 			c->Request.CDB[8] = (size >> 8) & 0XFF;
> 			break;
> +		case BMIC_IDENTIFY_CONTROLLER:
> +			c->Request.CDBLen = 10;
> +			c->Request.type_attr_dir =
> +				TYPE_ATTR_DIR(cmd_type, ATTR_SIMPLE, XFER_READ);
> +			c->Request.Timeout = 0;
> +			c->Request.CDB[0] = BMIC_READ;
> +			c->Request.CDB[1] = 0;
> +			c->Request.CDB[2] = 0;
> +			c->Request.CDB[3] = 0;
> +			c->Request.CDB[4] = 0;
> +			c->Request.CDB[5] = 0;
> +			c->Request.CDB[6] = BMIC_IDENTIFY_CONTROLLER;
> +			c->Request.CDB[7] = (size >> 16) & 0xFF;
> +			c->Request.CDB[8] = (size >> 8) & 0XFF;
> +			c->Request.CDB[9] = 0;
> +			break;

The CDB is wiped during the command allocation as part of hpsa_cmd_partial_init()
so these explicit zeroing statements are not required.

Also, these BMIC cases are the same excluding the command ID (CDB[6]), so there
is a potential opportunity for collapsing, but it's not critical and definitely not something
I would target with this patch.

> +
> 		default:
> 			dev_warn(&h->pdev->dev, "unknown command 0x%c\n", cmd);
> 			BUG();
> diff --git a/drivers/scsi/hpsa.h b/drivers/scsi/hpsa.h
> index 38d5534..0cf147b 100644
> --- a/drivers/scsi/hpsa.h
> +++ b/drivers/scsi/hpsa.h
> @@ -77,6 +77,7 @@ struct hpsa_scsi_dev_t {
> 	struct hpsa_scsi_dev_t *phys_disk[RAID_MAP_MAX_ENTRIES];
> 	int nphysical_disks;
> 	int supports_aborts;
> +	int external;   /* 1-from external array 0-not <0-unknown */
> };
> 
> struct reply_queue_buffer {
> diff --git a/drivers/scsi/hpsa_cmd.h b/drivers/scsi/hpsa_cmd.h
> index c2c0737..c83eaf1 100644
> --- a/drivers/scsi/hpsa_cmd.h
> +++ b/drivers/scsi/hpsa_cmd.h
> @@ -286,6 +286,7 @@ struct SenseSubsystem_info {
> #define BMIC_FLASH_FIRMWARE 0xF7
> #define BMIC_SENSE_CONTROLLER_PARAMETERS 0x64
> #define BMIC_IDENTIFY_PHYSICAL_DEVICE 0x15
> +#define BMIC_IDENTIFY_CONTROLLER 0x11
> 
> /* Command List Structure */
> union SCSI3Addr {
> @@ -682,6 +683,16 @@ struct hpsa_pci_info {
> 	u32		board_id;
> };
> 
> +struct bmic_identify_controller {
> +	u8	configured_logical_drive_count;	/* offset 0 */
> +	u8	pad1[153];
> +	__le16	extended_logical_unit_count;	/* offset 154 */
> +	u8	pad2[136];
> +	u8	controller_mode;	/* offset 292 */
> +	u8	pad3[32];
> +};
> +
> +
> struct bmic_identify_physical_device {
> 	u8    scsi_bus;          /* SCSI Bus number on controller */
> 	u8    scsi_id;           /* SCSI ID on this bus */
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 


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

* Re: [PATCH 1 19/25] hpsa: eliminate fake lun0 enclosures
  2015-10-28 22:06 ` [PATCH 1 19/25] hpsa: eliminate fake lun0 enclosures Don Brace
@ 2015-10-29 20:05   ` Matthew R. Ochs
  2015-10-30  8:12   ` Hannes Reinecke
  2015-10-30 14:12   ` Tomas Henzl
  2 siblings, 0 replies; 107+ messages in thread
From: Matthew R. Ochs @ 2015-10-29 20:05 UTC (permalink / raw)
  To: Don Brace
  Cc: scott.teel, Kevin.Barnett, scott.benesh, james.bottomley, hch,
	Justin.Lindley, elliott, linux-scsi

Reviewed-by: Matthew R. Ochs <mrochs@linux.vnet.ibm.com>


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

* Re: [PATCH 1 20/25] hpsa: add discovery polling for PT RAID devices.
  2015-10-28 22:06 ` [PATCH 1 20/25] hpsa: add discovery polling for PT RAID devices Don Brace
@ 2015-10-29 20:20   ` Matthew R. Ochs
       [not found]     ` <563286B7.8070200@pmcs.com>
  2015-10-30  8:15   ` Hannes Reinecke
  1 sibling, 1 reply; 107+ messages in thread
From: Matthew R. Ochs @ 2015-10-29 20:20 UTC (permalink / raw)
  To: Don Brace
  Cc: scott.teel, Kevin.Barnett, scott.benesh, james.bottomley, hch,
	Justin.Lindley, elliott, linux-scsi

> On Oct 28, 2015, at 5:06 PM, Don Brace <don.brace@pmcs.com> wrote:
> 
> From: Scott Teel <scott.teel@pmcs.com>
> 
> There are problems with getting configuration change notification
> in pass-through RAID environments.  So, activate flag
> h->discovery_polling when one of these devices is detected in
> update_scsi_devices.
> 
> After discovery_polling is set, execute a report luns from
> rescan_controller_worker (every 30 seconds).
> 
> If the data from report_luns is different than last
> time (binary compare), execute a full rescan via update_scsi_devices.
> 
> Reviewed-by: Scott Teel <scott.teel@pmcs.com>
> Reviewed-by: Justin Lindley <justin.lindley@pmcs.com>
> Reviewed-by: Kevin Barnett <kevin.barnett@pmcs.com>
> Signed-off-by: Don Brace <don.brace@pmcs.com>
> ---
> drivers/scsi/hpsa.c |   68 +++++++++++++++++++++++++++++++++++++++++++++++++++
> drivers/scsi/hpsa.h |    2 ++
> 2 files changed, 70 insertions(+)
> 
> diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
> index 8d67648..e521acd 100644
> --- a/drivers/scsi/hpsa.c
> +++ b/drivers/scsi/hpsa.c
> @@ -276,6 +276,7 @@ static int hpsa_scsi_ioaccel_queue_command(struct ctlr_info *h,
> static void hpsa_command_resubmit_worker(struct work_struct *work);
> static u32 lockup_detected(struct ctlr_info *h);
> static int detect_controller_lockup(struct ctlr_info *h);
> +static int hpsa_luns_changed(struct ctlr_info *h);
> 
> static inline struct ctlr_info *sdev_to_hba(struct scsi_device *sdev)
> {
> @@ -3904,6 +3905,18 @@ static void hpsa_update_scsi_devices(struct ctlr_info *h, int hostno)
> 		hpsa_update_device_supports_aborts(h, tmpdevice, lunaddrbytes);
> 		this_device = currentsd[ncurrent];
> 
> +		/* Turn on discovery_polling if there are ext target devices.
> +		 * Event-based change notification is unreliable for those.
> +		 */
> +		if (!h->discovery_polling) {
> +			if (tmpdevice->external) {
> +				h->discovery_polling = 1;
> +				dev_info(&h->pdev->dev,
> +					"External target, activate discovery polling.\n");
> +			}
> +		}
> +
> +
> 		*this_device = *tmpdevice;
> 		this_device->physical_device = physical_device;
> 
> @@ -8022,6 +8035,41 @@ static int hpsa_offline_devices_ready(struct ctlr_info *h)
> 	return 0;
> }
> 
> +static int hpsa_luns_changed(struct ctlr_info *h)
> +{
> +	int rc = 1; /* assume there are changes */
> +	struct ReportLUNdata *logdev = NULL;
> +
> +	/* if we can't find out if lun data has changed,
> +	 * assume that it has.
> +	 */
> +
> +	if (!h->lastlogicals)
> +		goto out;
> +
> +	logdev = kzalloc(sizeof(*logdev), GFP_KERNEL);
> +	if (!logdev) {
> +		dev_warn(&h->pdev->dev,
> +			"Out of memory, can't track lun changes.\n");
> +		goto out;
> +	}
> +	if (hpsa_scsi_do_report_luns(h, 1, logdev, sizeof(*logdev), 0)) {
> +		dev_warn(&h->pdev->dev,
> +			"report luns failed, can't track lun changes.\n");
> +		goto out;
> +	}
> +	if (memcmp(logdev, h->lastlogicals, sizeof(*logdev))) {
> +		dev_info(&h->pdev->dev,
> +			"Lun changes detected.\n");
> +		memcpy(h->lastlogicals, logdev, sizeof(*logdev));
> +		goto out;
> +	} else
> +		rc = 0; /* no changes detected. */
> +out:
> +	kfree(logdev);
> +	return rc;
> +}
> +
> static void hpsa_rescan_ctlr_worker(struct work_struct *work)
> {
> 	unsigned long flags;
> @@ -8037,6 +8085,18 @@ static void hpsa_rescan_ctlr_worker(struct work_struct *work)
> 		hpsa_ack_ctlr_events(h);
> 		hpsa_scan_start(h->scsi_host);
> 		scsi_host_put(h->scsi_host);
> +	} else if (h->discovery_polling) {
> +		if (hpsa_luns_changed(h)) {
> +			struct Scsi_Host *sh = NULL;
> +
> +			dev_info(&h->pdev->dev,
> +				"driver discovery polling rescan.\n");
> +			sh = scsi_host_get(h->scsi_host);
> +			if (sh != NULL) {
> +				hpsa_scan_start(sh);
> +				scsi_host_put(sh);
> +			}
> +		}
> 	}
> 	spin_lock_irqsave(&h->lock, flags);
> 	if (!h->remove_in_progress)
> @@ -8277,6 +8337,8 @@ reinit_after_soft_reset:
> 
> 	/* Enable Accelerated IO path at driver layer */
> 	h->acciopath_status = 1;
> +	/* Disable discovery polling.*/
> +	h->discovery_polling = 0;
> 
> 
> 	/* Turn the interrupts on so we can service requests */
> @@ -8284,6 +8346,11 @@ reinit_after_soft_reset:
> 
> 	hpsa_hba_inquiry(h);
> 
> +	h->lastlogicals = kzalloc(sizeof(*(h->lastlogicals)), GFP_KERNEL);
> +	if (!h->lastlogicals)
> +		dev_info(&h->pdev->dev,
> +			"Can't track change to report lun data\n");
> +
> 	/* Monitor the controller for firmware lockups */
> 	h->heartbeat_sample_interval = HEARTBEAT_SAMPLE_INTERVAL;
> 	INIT_DELAYED_WORK(&h->monitor_ctlr_work, hpsa_monitor_ctlr_worker);
> @@ -8368,6 +8435,7 @@ static void hpsa_shutdown(struct pci_dev *pdev)
> 	hpsa_flush_cache(h);
> 	h->access.set_intr_mask(h, HPSA_INTR_OFF);
> 	hpsa_free_irqs(h);			/* init_one 4 */
> +	kfree(h->lastlogicals);

Is this the best place to free this memory? If your rescan worker is running
concurrently you might run into trouble. 

> 	hpsa_disable_interrupt_mode(h);		/* pci_init 2 */
> }
> 
> diff --git a/drivers/scsi/hpsa.h b/drivers/scsi/hpsa.h
> index 0cf147b..6c82d3c 100644
> --- a/drivers/scsi/hpsa.h
> +++ b/drivers/scsi/hpsa.h
> @@ -262,6 +262,8 @@ struct ctlr_info {
> 	int	acciopath_status;
> 	int	drv_req_rescan;
> 	int	raid_offload_debug;
> +	int     discovery_polling;
> +	struct  ReportLUNdata *lastlogicals;
> 	int	needs_abort_tags_swizzled;
> 	struct workqueue_struct *resubmit_wq;
> 	struct workqueue_struct *rescan_ctlr_wq;
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 


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

* Re: [PATCH 1 13/25] hpsa: simplify update scsi devices
  2015-10-29 19:01     ` Don Brace
@ 2015-10-29 20:28       ` Matthew R. Ochs
  0 siblings, 0 replies; 107+ messages in thread
From: Matthew R. Ochs @ 2015-10-29 20:28 UTC (permalink / raw)
  To: Don Brace
  Cc: scott.teel, Kevin.Barnett, scott.benesh, james.bottomley, hch,
	Justin.Lindley, elliott, linux-scsi

> On Oct 29, 2015, at 2:01 PM, Don Brace <brace77070@gmail.com> wrote:
> 
> On 10/29/2015 11:43 AM, Matthew R. Ochs wrote:
>>> On Oct 28, 2015, at 5:05 PM, Don Brace <don.brace@pmcs.com> wrote:
>>> 
>>> From: Kevin Barnett <kevin.barnett@pmcs.com>
>>> 
>>> remove repeated calculation that checks for physical
>>> or logical devices.
>>> 
>>> Reviewed-by: Scott Teel <scott.teel@pmcs.com>
>>> Reviewed-by: Justin Lindley <justin.lindley@pmcs.com>
>>> Reviewed-by: Kevin Barnett <kevin.barnett@pmcs.com>
>>> Signed-off-by: Don Brace <don.brace@pmcs.com>
>>> ---
>>> drivers/scsi/hpsa.c |   23 ++++++++++++++---------
>>> drivers/scsi/hpsa.h |    1 +
>>> 2 files changed, 15 insertions(+), 9 deletions(-)
>>> 
>>> diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
>>> index d011540..7c1a552 100644
>>> --- a/drivers/scsi/hpsa.c
>>> +++ b/drivers/scsi/hpsa.c
>>> @@ -3761,6 +3761,7 @@ static void hpsa_update_scsi_devices(struct ctlr_info *h, int hostno)
>>> 	int ncurrent = 0;
>>> 	int i, n_ext_target_devs, ndevs_to_allocate;
>>> 	int raid_ctlr_position;
>>> +	bool physical_device;
>> Any particular reason for using a bool here and a u8 when you cache the value?
> Changed definition to u8 physical_device : 1; in hpsa_scsi_dev_t
> 
>> 
>>> 	DECLARE_BITMAP(lunzerobits, MAX_EXT_TARGETS);
>>> 
>>> 	currentsd = kzalloc(sizeof(*currentsd) * HPSA_MAX_DEVICES, GFP_KERNEL);
>>> @@ -3821,16 +3822,17 @@ static void hpsa_update_scsi_devices(struct ctlr_info *h, int hostno)
>>> 		int rc = 0;
>>> 		int phys_dev_index = i - (raid_ctlr_position == 0);
>>> 
>>> +		physical_device = i < nphysicals + (raid_ctlr_position == 0);
>>> +
>>> 		/* Figure out where the LUN ID info is coming from */
>>> 		lunaddrbytes = figure_lunaddrbytes(h, raid_ctlr_position,
>>> 			i, nphysicals, nlogicals, physdev_list, logdev_list);
>>> 
>>> 		/* skip masked non-disk devices */
>>> -		if (MASKED_DEVICE(lunaddrbytes))
>>> -			if (i < nphysicals + (raid_ctlr_position == 0) &&
>>> -				(physdev_list->
>>> -				LUN[phys_dev_index].device_flags & 0x01))
>>> -				continue;
>>> +		if (physical_device &&
>>> +			MASKED_DEVICE(lunaddrbytes) &&
>>> +			(physdev_list->LUN[phys_dev_index].device_flags & 0x01))
>>> +			continue;
>> In this conditional you swapped the ordering, evaluating physical_device first, why?
> Changed it back. Better to be consistent.

With these changes I'm fine with you adding

Reviewed-by: Matthew R. Ochs <mrochs@linux.vnet.ibm.com>


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

* Re: [PATCH 1 17/25] hpsa: move scsi_add_device and scsi_remove_device calls to new function
  2015-10-29 17:21   ` Matthew R. Ochs
@ 2015-10-29 20:30     ` Don Brace
  2015-10-30 15:56       ` Matthew R. Ochs
  0 siblings, 1 reply; 107+ messages in thread
From: Don Brace @ 2015-10-29 20:30 UTC (permalink / raw)
  To: Matthew R. Ochs
  Cc: scott.teel, Kevin.Barnett, scott.benesh, james.bottomley, hch,
	Justin.Lindley, elliott, linux-scsi

On 10/29/2015 12:21 PM, Matthew R. Ochs wrote:
>> On Oct 28, 2015, at 5:06 PM, Don Brace <don.brace@pmcs.com> wrote:
>>
>> From: Kevin Barnett <kevin.barnett@pmcs.com>
>>
>> preparation for adding the sas transport class
>>
>> Reviewed-by: Scott Teel <scott.teel@pmcs.com>
>> Reviewed-by: Justin Lindley <justin.lindley@pmcs.com>
>> Reviewed-by: Kevin Barnett <kevin.barnett@pmcs.com>
>> Signed-off-by: Don Brace <don.brace@pmcs.com>
>> ---
>> drivers/scsi/hpsa.c |   65 +++++++++++++++++++++++++++++++--------------------
>> 1 file changed, 39 insertions(+), 26 deletions(-)
>>
>> diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
>> index 24b3c8c..06207e2 100644
>> --- a/drivers/scsi/hpsa.c
>> +++ b/drivers/scsi/hpsa.c
>> @@ -1660,6 +1660,37 @@ static void hpsa_update_log_drive_phys_drive_ptrs(struct ctlr_info *h,
>> 	}
>> }
>>
>> +static int hpsa_add_device(struct ctlr_info *h, struct hpsa_scsi_dev_t *device)
>> +{
>> +	int rc = 0;
>> +
>> +	rc = scsi_add_device(h->scsi_host, device->bus,
>> +					device->target, device->lun);
>> +	return rc;
>> +}
>> +
>> +static void hpsa_remove_device(struct ctlr_info *h,
>> +			struct hpsa_scsi_dev_t *device)
>> +{
>> +	struct scsi_device *sdev = NULL;
>> +
>> +	sdev = scsi_device_lookup(h->scsi_host, device->bus,
>> +						device->target, device->lun);
>> +
>> +	if (sdev) {
>> +		scsi_remove_device(sdev);
>> +		scsi_device_put(sdev);
>> +	} else {
>> +		/*
>> +		 * We don't expect to get here.  Future commands
>> +		 * to this device will get a selection timeout as
>> +		 * if the device were gone.
>> +		 */
>> +		hpsa_show_dev_msg(KERN_WARNING, h, device,
>> +					"didn't find device for removal.");
>> +	}
>> +}
>> +
>> static void adjust_hpsa_scsi_table(struct ctlr_info *h, int hostno,
>> 	struct hpsa_scsi_dev_t *sd[], int nsds)
>> {
>> @@ -1672,7 +1703,6 @@ static void adjust_hpsa_scsi_table(struct ctlr_info *h, int hostno,
>> 	unsigned long flags;
>> 	struct hpsa_scsi_dev_t **added, **removed;
>> 	int nadded, nremoved;
>> -	struct Scsi_Host *sh = NULL;
>>
>> 	/*
>> 	 * A reset can cause a device status to change
>> @@ -1792,46 +1822,29 @@ static void adjust_hpsa_scsi_table(struct ctlr_info *h, int hostno,
>> 	if (hostno == -1 || !changes)
>> 		goto free_and_out;
>>
>> -	sh = h->scsi_host;
>> -	if (sh == NULL) {
>> -		dev_warn(&h->pdev->dev, "%s: scsi_host is null\n", __func__);
>> -		return;
>> -	}
> Are we guaranteed that h->scsi_host will never be NULL when running in here? Or when
> the newly introduced hpsa_remove_device() is invoked elsewhere for that matter?
>
> This commit loses this check and scsi_device_lookup() is not tolerant of a NULL
> scsi_host * (first action is to grab the host_lock).
Better to be safe. I'll add a check in both functions.
>
>> 	/* Notify scsi mid layer of any removed devices */
>> 	for (i = 0; i < nremoved; i++) {
>> 		if (removed[i] == NULL)
>> 			continue;
>> -		if (removed[i]->expose_device) {
>> -			struct scsi_device *sdev =
>> -				scsi_device_lookup(sh, removed[i]->bus,
>> -					removed[i]->target, removed[i]->lun);
>> -			if (sdev != NULL) {
>> -				scsi_remove_device(sdev);
>> -				scsi_device_put(sdev);
>> -			} else {
>> -				/*
>> -				 * We don't expect to get here.
>> -				 * future cmds to this device will get selection
>> -				 * timeout as if the device was gone.
>> -				 */
>> -				hpsa_show_dev_msg(KERN_WARNING, h, removed[i],
>> -					"didn't find device for removal.");
>> -			}
>> -		}
>> +		if (removed[i]->expose_device)
>> +			hpsa_remove_device(h, removed[i]);
>> 		kfree(removed[i]);
>> 		removed[i] = NULL;
>> 	}
>>
>> 	/* Notify scsi mid layer of any added devices */
>> 	for (i = 0; i < nadded; i++) {
>> +		int rc = 0;
>> +
>> 		if (added[i] == NULL)
>> 			continue;
>> 		if (!(added[i]->expose_device))
>> 			continue;
>> -		if (scsi_add_device(sh, added[i]->bus,
>> -			added[i]->target, added[i]->lun) == 0)
>> +		rc = hpsa_add_device(h, added[i]);
>> +		if (!rc)
>> 			continue;
>> -		dev_warn(&h->pdev->dev, "addition failed, device not added.");
>> +		dev_warn(&h->pdev->dev,
>> +			"addition failed %d, device not added.", rc);
>> 		/* now we have to remove it from h->dev,
>> 		 * since it didn't get added to scsi mid layer
>> 		 */
>>
>> --
>> To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
>> the body of a message to majordomo@vger.kernel.org
>> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html


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

* Re: [PATCH 1 20/25] hpsa: add discovery polling for PT RAID devices.
       [not found]     ` <563286B7.8070200@pmcs.com>
@ 2015-10-29 20:59       ` Matthew R. Ochs
  2015-10-30 14:08         ` Don Brace
  0 siblings, 1 reply; 107+ messages in thread
From: Matthew R. Ochs @ 2015-10-29 20:59 UTC (permalink / raw)
  To: Don Brace
  Cc: scott.teel, Kevin.Barnett, scott.benesh, james.bottomley, hch,
	Justin.Lindley, elliott, linux-scsi

> On Oct 29, 2015, at 3:51 PM, Don Brace <brace77070@gmail.com> wrote:
> On 10/29/2015 03:20 PM, Matthew R. Ochs wrote:
>>> On Oct 28, 2015, at 5:06 PM, Don Brace <don.brace@pmcs.com>
>>>  wrote:
>>> 
>>> From: Scott Teel 
>>> <scott.teel@pmcs.com>
>>> 
>>> 
>>> There are problems with getting configuration change notification
>>> in pass-through RAID environments.  So, activate flag
>>> h->discovery_polling when one of these devices is detected in
>>> update_scsi_devices.
>>> 
>>> After discovery_polling is set, execute a report luns from
>>> rescan_controller_worker (every 30 seconds).
>>> 
>>> If the data from report_luns is different than last
>>> time (binary compare), execute a full rescan via update_scsi_devices.
>>> 
>>> Reviewed-by: Scott Teel 
>>> <scott.teel@pmcs.com>
>>> 
>>> Reviewed-by: Justin Lindley 
>>> <justin.lindley@pmcs.com>
>>> 
>>> Reviewed-by: Kevin Barnett 
>>> <kevin.barnett@pmcs.com>
>>> 
>>> Signed-off-by: Don Brace 
>>> <don.brace@pmcs.com>
>>> 
>>> ---
>>> drivers/scsi/hpsa.c |   68 +++++++++++++++++++++++++++++++++++++++++++++++++++
>>> drivers/scsi/hpsa.h |    2 ++
>>> 2 files changed, 70 insertions(+)
>>> 
>>> diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
>>> index 8d67648..e521acd 100644
>>> --- a/drivers/scsi/hpsa.c
>>> +++ b/drivers/scsi/hpsa.c
>>> @@ -276,6 +276,7 @@ static int hpsa_scsi_ioaccel_queue_command(struct ctlr_info *h,
>>> static void hpsa_command_resubmit_worker(struct work_struct *work);
>>> static u32 lockup_detected(struct ctlr_info *h);
>>> static int detect_controller_lockup(struct ctlr_info *h);
>>> +static int hpsa_luns_changed(struct ctlr_info *h);
>>> 
>>> static inline struct ctlr_info *sdev_to_hba(struct scsi_device *sdev)
>>> {
>>> @@ -3904,6 +3905,18 @@ static void hpsa_update_scsi_devices(struct ctlr_info *h, int hostno)
>>> 		hpsa_update_device_supports_aborts(h, tmpdevice, lunaddrbytes);
>>> 		this_device = currentsd[ncurrent];
>>> 
>>> +		/* Turn on discovery_polling if there are ext target devices.
>>> +		 * Event-based change notification is unreliable for those.
>>> +		 */
>>> +		if (!h->discovery_polling) {
>>> +			if (tmpdevice->external) {
>>> +				h->discovery_polling = 1;
>>> +				dev_info(&h->pdev->dev,
>>> +					"External target, activate discovery polling.\n");
>>> +			}
>>> +		}
>>> +
>>> +
>>> 		*this_device = *tmpdevice;
>>> 		this_device->physical_device = physical_device;
>>> 
>>> @@ -8022,6 +8035,41 @@ static int hpsa_offline_devices_ready(struct ctlr_info *h)
>>> 	return 0;
>>> }
>>> 
>>> +static int hpsa_luns_changed(struct ctlr_info *h)
>>> +{
>>> +	int rc = 1; /* assume there are changes */
>>> +	struct ReportLUNdata *logdev = NULL;
>>> +
>>> +	/* if we can't find out if lun data has changed,
>>> +	 * assume that it has.
>>> +	 */
>>> +
>>> +	if (!h->lastlogicals)
>>> +		goto out;
>>> +
>>> +	logdev = kzalloc(sizeof(*logdev), GFP_KERNEL);
>>> +	if (!logdev) {
>>> +		dev_warn(&h->pdev->dev,
>>> +			"Out of memory, can't track lun changes.\n");
>>> +		goto out;
>>> +	}
>>> +	if (hpsa_scsi_do_report_luns(h, 1, logdev, sizeof(*logdev), 0)) {
>>> +		dev_warn(&h->pdev->dev,
>>> +			"report luns failed, can't track lun changes.\n");
>>> +		goto out;
>>> +	}
>>> +	if (memcmp(logdev, h->lastlogicals, sizeof(*logdev))) {
>>> +		dev_info(&h->pdev->dev,
>>> +			"Lun changes detected.\n");
>>> +		memcpy(h->lastlogicals, logdev, sizeof(*logdev));
>>> +		goto out;
>>> +	} else
>>> +		rc = 0; /* no changes detected. */
>>> +out:
>>> +	kfree(logdev);
>>> +	return rc;
>>> +}
>>> +
>>> static void hpsa_rescan_ctlr_worker(struct work_struct *work)
>>> {
>>> 	unsigned long flags;
>>> @@ -8037,6 +8085,18 @@ static void hpsa_rescan_ctlr_worker(struct work_struct *work)
>>> 		hpsa_ack_ctlr_events(h);
>>> 		hpsa_scan_start(h->scsi_host);
>>> 		scsi_host_put(h->scsi_host);
>>> +	} else if (h->discovery_polling) {
>>> +		if (hpsa_luns_changed(h)) {
>>> +			struct Scsi_Host *sh = NULL;
>>> +
>>> +			dev_info(&h->pdev->dev,
>>> +				"driver discovery polling rescan.\n");
>>> +			sh = scsi_host_get(h->scsi_host);
>>> +			if (sh != NULL) {
>>> +				hpsa_scan_start(sh);
>>> +				scsi_host_put(sh);
>>> +			}
>>> +		}
>>> 	}
>>> 	spin_lock_irqsave(&h->lock, flags);
>>> 	if (!h->remove_in_progress)
>>> @@ -8277,6 +8337,8 @@ reinit_after_soft_reset:
>>> 
>>> 	/* Enable Accelerated IO path at driver layer */
>>> 	h->acciopath_status = 1;
>>> +	/* Disable discovery polling.*/
>>> +	h->discovery_polling = 0;
>>> 
>>> 
>>> 	/* Turn the interrupts on so we can service requests */
>>> @@ -8284,6 +8346,11 @@ reinit_after_soft_reset:
>>> 
>>> 	hpsa_hba_inquiry(h);
>>> 
>>> +	h->lastlogicals = kzalloc(sizeof(*(h->lastlogicals)), GFP_KERNEL);
>>> +	if (!h->lastlogicals)
>>> +		dev_info(&h->pdev->dev,
>>> +			"Can't track change to report lun data\n");
>>> +
>>> 	/* Monitor the controller for firmware lockups */
>>> 	h->heartbeat_sample_interval = HEARTBEAT_SAMPLE_INTERVAL;
>>> 	INIT_DELAYED_WORK(&h->monitor_ctlr_work, hpsa_monitor_ctlr_worker);
>>> @@ -8368,6 +8435,7 @@ static void hpsa_shutdown(struct pci_dev *pdev)
>>> 	hpsa_flush_cache(h);
>>> 	h->access.set_intr_mask(h, HPSA_INTR_OFF);
>>> 	hpsa_free_irqs(h);			/* init_one 4 */
>>> +	kfree(h->lastlogicals);
>>> 
>> Is this the best place to free this memory? If your rescan worker is running
>> concurrently you might run into trouble. 
>> 
> Since hpsa_shutdown is called from hpsa_remove_one, at a point after 
> cancel_delayed_work_sync(&h->rescan_ctlr_work) has already been called, 
> I  think that the rescan worker won’t be running at this point.

My concern wasn't about the remove path but rather the shutdown notification path.


--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH 1 01/25] hpsa: stop zeroing reset_cmds_out and ioaccel_cmds_out during rescan
  2015-10-28 22:04 ` [PATCH 1 01/25] hpsa: stop zeroing reset_cmds_out and ioaccel_cmds_out during rescan Don Brace
  2015-10-29 13:25   ` Tomas Henzl
@ 2015-10-30  7:45   ` Hannes Reinecke
  1 sibling, 0 replies; 107+ messages in thread
From: Hannes Reinecke @ 2015-10-30  7:45 UTC (permalink / raw)
  To: Don Brace, scott.teel, Kevin.Barnett, scott.benesh,
	james.bottomley, hch, Justin.Lindley, elliott
  Cc: linux-scsi

On 10/28/2015 11:04 PM, Don Brace wrote:
> pulling the rug out from under the reset handler
> likewise for ioaccel_cmds_out
> 
> Signed-off-by: Don Brace <don.brace@pmcs.com>
> ---
>  drivers/scsi/hpsa.c |    2 --
>  1 file changed, 2 deletions(-)
> 
> diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
> index 40669f8..e60c652 100644
> --- a/drivers/scsi/hpsa.c
> +++ b/drivers/scsi/hpsa.c
> @@ -3673,8 +3673,6 @@ static void hpsa_get_ioaccel_drive_info(struct ctlr_info *h,
>  				DRIVE_CMDS_RESERVED_FOR_FW;
>  	else
>  		dev->queue_depth = DRIVE_QUEUE_DEPTH; /* conservative */
> -	atomic_set(&dev->ioaccel_cmds_out, 0);
> -	atomic_set(&dev->reset_cmds_out, 0);
>  }
>  
>  static void hpsa_get_path_info(struct hpsa_scsi_dev_t *this_device,
> 
Reviewed-by: Hannes Reinecke <hare@suse.de>

Cheers,

Hannes
-- 
Dr. Hannes Reinecke		      zSeries & Storage
hare@suse.de			      +49 911 74053 688
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: J. Hawn, J. Guild, F. Imendörffer, HRB 16746 (AG Nürnberg)
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH 1 02/25] hpsa: remove unused hpsa_tag_discard_error_bits
  2015-10-28 22:04 ` [PATCH 1 02/25] hpsa: remove unused hpsa_tag_discard_error_bits Don Brace
  2015-10-29 13:26   ` Tomas Henzl
  2015-10-29 14:37   ` Manoj Kumar
@ 2015-10-30  7:46   ` Hannes Reinecke
  2 siblings, 0 replies; 107+ messages in thread
From: Hannes Reinecke @ 2015-10-30  7:46 UTC (permalink / raw)
  To: Don Brace, scott.teel, Kevin.Barnett, scott.benesh,
	james.bottomley, hch, Justin.Lindley, elliott
  Cc: linux-scsi

On 10/28/2015 11:04 PM, Don Brace wrote:
> This function is no longer used.
> 
> Signed-off-by: Don Brace <don.brace@pmcs.com>
> ---
Reviewed-by: Hannes Reinecke <hare@suse.de>

Cheers,

Hannes
-- 
Dr. Hannes Reinecke		      zSeries & Storage
hare@suse.de			      +49 911 74053 688
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: J. Hawn, J. Guild, F. Imendörffer, HRB 16746 (AG Nürnberg)
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH 1 03/25] hpsa: check for null arguments to dev_printk
  2015-10-28 22:04 ` [PATCH 1 03/25] hpsa: check for null arguments to dev_printk Don Brace
  2015-10-29 13:41   ` Tomas Henzl
  2015-10-29 14:41   ` Manoj Kumar
@ 2015-10-30  7:47   ` Hannes Reinecke
  2015-10-30 14:16     ` Don Brace
  2 siblings, 1 reply; 107+ messages in thread
From: Hannes Reinecke @ 2015-10-30  7:47 UTC (permalink / raw)
  To: Don Brace, scott.teel, Kevin.Barnett, scott.benesh,
	james.bottomley, hch, Justin.Lindley, elliott
  Cc: linux-scsi

On 10/28/2015 11:04 PM, Don Brace wrote:
> Check for NULLs.
> 
> Signed-off-by: Don Brace <don.brace@pmcs.com>
> ---
>  drivers/scsi/hpsa.c |    6 ++++++
>  drivers/scsi/hpsa.h |    2 +-
>  2 files changed, 7 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
> index 864fb03..6b6e9bb 100644
> --- a/drivers/scsi/hpsa.c
> +++ b/drivers/scsi/hpsa.c
> @@ -1139,6 +1139,12 @@ static int hpsa_find_target_lun(struct ctlr_info *h,
>  static inline void hpsa_show_dev_msg(const char *level, struct ctlr_info *h,
>  	struct hpsa_scsi_dev_t *dev, char *description)
>  {
> +	if (dev == NULL)
> +		return;
> +
> +	if (h == NULL || h->pdev == NULL || h->scsi_host == NULL)
> +		return;
> +
>  	dev_printk(level, &h->pdev->dev,
>  			"scsi %d:%d:%d:%d: %s %s %.8s %.16s RAID-%s SSDSmartPathCap%c En%c Exp=%d\n",
>  			h->scsi_host->host_no, dev->bus, dev->target, dev->lun,
> diff --git a/drivers/scsi/hpsa.h b/drivers/scsi/hpsa.h
> index 27debb3..d6c4ebf 100644
> --- a/drivers/scsi/hpsa.h
> +++ b/drivers/scsi/hpsa.h
> @@ -34,7 +34,7 @@ struct access_method {
>  };
>  
>  struct hpsa_scsi_dev_t {
> -	int devtype;
> +	unsigned int devtype;
>  	int bus, target, lun;		/* as presented to the OS */
>  	unsigned char scsi3addr[8];	/* as presented to the HW */
>  #define RAID_CTLR_LUNID "\0\0\0\0\0\0\0\0"
> 
That's not really a check for NULL, isn't it?
Should rather be moved into an individual patch.

Cheers,

Hannes
-- 
Dr. Hannes Reinecke		      zSeries & Storage
hare@suse.de			      +49 911 74053 688
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: J. Hawn, J. Guild, F. Imendörffer, HRB 16746 (AG Nürnberg)
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH 1 04/25] hpsa: fix null device issues
  2015-10-28 22:04 ` [PATCH 1 04/25] hpsa: fix null device issues Don Brace
  2015-10-29 14:06   ` Tomas Henzl
@ 2015-10-30  7:49   ` Hannes Reinecke
  1 sibling, 0 replies; 107+ messages in thread
From: Hannes Reinecke @ 2015-10-30  7:49 UTC (permalink / raw)
  To: Don Brace, scott.teel, Kevin.Barnett, scott.benesh,
	james.bottomley, hch, Justin.Lindley, elliott
  Cc: linux-scsi

On 10/28/2015 11:04 PM, Don Brace wrote:
> Signed-off-by: Don Brace <don.brace@pmcs.com>
> ---
>  drivers/scsi/hpsa.c |   25 ++++++++++++++++++++-----
>  1 file changed, 20 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
> index 6b6e9bb..3fe8a18 100644
> --- a/drivers/scsi/hpsa.c
> +++ b/drivers/scsi/hpsa.c
> @@ -1136,7 +1136,7 @@ static int hpsa_find_target_lun(struct ctlr_info *h,
>  	return !found;
>  }
>  
> -static inline void hpsa_show_dev_msg(const char *level, struct ctlr_info *h,
> +static void hpsa_show_dev_msg(const char *level, struct ctlr_info *h,
>  	struct hpsa_scsi_dev_t *dev, char *description)
>  {
>  	if (dev == NULL)
This is not a null device check; you modified the function.
Please put it into a separate function.

Or make a patch 'cleanup' or something.

> @@ -1423,6 +1423,9 @@ static int hpsa_scsi_find_entry(struct hpsa_scsi_dev_t *needle,
>  #define DEVICE_CHANGED 1
>  #define DEVICE_SAME 2
>  #define DEVICE_UPDATED 3
> +	if (needle == NULL)
> +		return DEVICE_NOT_FOUND;
> +
>  	for (i = 0; i < haystack_size; i++) {
>  		if (haystack[i] == NULL) /* previously removed. */
>  			continue;
> @@ -1574,6 +1577,9 @@ static void hpsa_figure_phys_disk_ptrs(struct ctlr_info *h,
>  				total_disks_per_row;
>  	int qdepth;
>  
> +	if (logical_drive == NULL)
> +		return;
> +
>  	if (nraid_map_entries > RAID_MAP_MAX_ENTRIES)
>  		nraid_map_entries = RAID_MAP_MAX_ENTRIES;
>  
> @@ -1585,6 +1591,8 @@ static void hpsa_figure_phys_disk_ptrs(struct ctlr_info *h,
>  		if (!logical_drive->offload_config)
>  			continue;
>  		for (j = 0; j < ndevices; j++) {
> +			if (dev[j] == NULL)
> +				continue;
>  			if (dev[j]->devtype != TYPE_DISK)
>  				continue;
>  			if (is_logical_dev_addr_mode(dev[j]->scsi3addr))
> @@ -1628,6 +1636,8 @@ static void hpsa_update_log_drive_phys_drive_ptrs(struct ctlr_info *h,
>  	int i;
>  
>  	for (i = 0; i < ndevices; i++) {
> +		if (dev[i] == NULL)
> +			continue;
>  		if (dev[i]->devtype != TYPE_DISK)
>  			continue;
>  		if (!is_logical_dev_addr_mode(dev[i]->scsi3addr))
> @@ -1743,8 +1753,11 @@ static void adjust_hpsa_scsi_table(struct ctlr_info *h, int hostno,
>  	/* Now that h->dev[]->phys_disk[] is coherent, we can enable
>  	 * any logical drives that need it enabled.
>  	 */
> -	for (i = 0; i < h->ndevices; i++)
> +	for (i = 0; i < h->ndevices; i++) {
> +		if (h->dev[i] == NULL)
> +			continue;
>  		h->dev[i]->offload_enabled = h->dev[i]->offload_to_be_enabled;
> +	}
>  
>  	spin_unlock_irqrestore(&h->devlock, flags);
>  
> @@ -1769,6 +1782,8 @@ static void adjust_hpsa_scsi_table(struct ctlr_info *h, int hostno,
>  	sh = h->scsi_host;
>  	/* Notify scsi mid layer of any removed devices */
>  	for (i = 0; i < nremoved; i++) {
> +		if (removed[i] == NULL)
> +			continue;
>  		if (removed[i]->expose_state & HPSA_SCSI_ADD) {
>  			struct scsi_device *sdev =
>  				scsi_device_lookup(sh, removed[i]->bus,
> @@ -1792,18 +1807,18 @@ static void adjust_hpsa_scsi_table(struct ctlr_info *h, int hostno,
>  
>  	/* Notify scsi mid layer of any added devices */
>  	for (i = 0; i < nadded; i++) {
> +		if (added[i] == NULL)
> +			continue;
>  		if (!(added[i]->expose_state & HPSA_SCSI_ADD))
>  			continue;
>  		if (scsi_add_device(sh, added[i]->bus,
>  			added[i]->target, added[i]->lun) == 0)
>  			continue;
> -		hpsa_show_dev_msg(KERN_WARNING, h, added[i],
> -					"addition failed, device not added.");
> +		dev_warn(&h->pdev->dev, "addition failed, device not added.");
>  		/* now we have to remove it from h->dev,
>  		 * since it didn't get added to scsi mid layer
>  		 */
>  		fixup_botched_add(h, added[i]);
> -		added[i] = NULL;
>  	}
>  
>  free_and_out:
> 
Again, modifying the logging message is not a null device check.
Please move it into another patch.

Cheers,

Hannes
-- 
Dr. Hannes Reinecke		      zSeries & Storage
hare@suse.de			      +49 911 74053 688
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: J. Hawn, J. Guild, F. Imendörffer, HRB 16746 (AG Nürnberg)
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH 1 05/25] hpsa: allow driver requested rescans
  2015-10-28 22:05 ` [PATCH 1 05/25] hpsa: allow driver requested rescans Don Brace
@ 2015-10-30  7:51   ` Hannes Reinecke
  0 siblings, 0 replies; 107+ messages in thread
From: Hannes Reinecke @ 2015-10-30  7:51 UTC (permalink / raw)
  To: Don Brace, scott.teel, Kevin.Barnett, scott.benesh,
	james.bottomley, hch, Justin.Lindley, elliott
  Cc: linux-scsi

On 10/28/2015 11:05 PM, Don Brace wrote:
> Reviewed-by: Scott Teel <scott.teel@pmcs.com>
> Reviewed-by: Justin Lindley <justin.lindley@pmcs.com>
> Reviewed-by: Kevin Barnett <kevin.barnett@pmcs.com>
> Reviewed-by: Tomas Henzl <thenzl@redhat.com>
> Signed-off-by: Don Brace <don.brace@pmcs.com>
> ---
>  drivers/scsi/hpsa.c |   17 +++++++++++++++--
>  drivers/scsi/hpsa.h |    1 +
>  2 files changed, 16 insertions(+), 2 deletions(-)

I did notice that using real LUNs would make this whole
issue go away, didn't I?

Just to be annoying :-)

Reviewed-by; Hannes Reinecke <hare@suse.de>

Cheers,

Hannes
-- 
Dr. Hannes Reinecke		      zSeries & Storage
hare@suse.de			      +49 911 74053 688
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: J. Hawn, J. Guild, F. Imendörffer, HRB 16746 (AG Nürnberg)
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH 1 06/25] hpsa: abandon rescans on memory alloaction failures.
  2015-10-28 22:05 ` [PATCH 1 06/25] hpsa: abandon rescans on memory alloaction failures Don Brace
@ 2015-10-30  7:53   ` Hannes Reinecke
  2015-10-30 20:44     ` Don Brace
  0 siblings, 1 reply; 107+ messages in thread
From: Hannes Reinecke @ 2015-10-30  7:53 UTC (permalink / raw)
  To: Don Brace, scott.teel, Kevin.Barnett, scott.benesh,
	james.bottomley, hch, Justin.Lindley, elliott
  Cc: linux-scsi

On 10/28/2015 11:05 PM, Don Brace wrote:
> Abandon and reschedule rescan process only if device inquiries
> fail due to mem alloc failures, which are likely to occur for
> all devices.
> 
> Otherwise, skip device if inquiry fails for other reasons,
> and continue rescanning process for other devices.
> 
> Reviewed-by: Scott Teel <scott.teel@pmcs.com>
> Reviewed-by: Justin Lindley <justin.lindley@pmcs.com>
> Reviewed-by: Kevin Barnett <kevin.barnett@pmcs.com>
> Reviewed-by: Tomas Henzl <thenzl@redhat.com>
> Signed-off-by: Don Brace <don.brace@pmcs.com>
> ---
>  drivers/scsi/hpsa.c |   24 +++++++++++++++++++-----
>  1 file changed, 19 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
> index a3f671c..ecc6ada 100644
> --- a/drivers/scsi/hpsa.c
> +++ b/drivers/scsi/hpsa.c
> @@ -3375,10 +3375,13 @@ static int hpsa_update_device_info(struct ctlr_info *h,
>  
>  	unsigned char *inq_buff;
>  	unsigned char *obdr_sig;
> +	int rc = 0;
>  
>  	inq_buff = kzalloc(OBDR_TAPE_INQ_SIZE, GFP_KERNEL);
> -	if (!inq_buff)
> +	if (!inq_buff) {
> +		rc = -ENOMEM;
>  		goto bail_out;
> +	}
>  
>  	/* Do an inquiry to the device to see what it is. */
>  	if (hpsa_scsi_do_inquiry(h, scsi3addr, 0, inq_buff,
> @@ -3386,6 +3389,7 @@ static int hpsa_update_device_info(struct ctlr_info *h,
>  		/* Inquiry failed (msg printed already) */
>  		dev_err(&h->pdev->dev,
>  			"hpsa_update_device_info: inquiry failed\n");
> +		rc = 1;
>  		goto bail_out;
>  	}
>  
Why '1' and not a normal error code, seeing that you're using -ENOMEM above?

> @@ -3435,7 +3439,7 @@ static int hpsa_update_device_info(struct ctlr_info *h,
>  
>  bail_out:
>  	kfree(inq_buff);
> -	return 1;
> +	return rc;
>  }
>  
>  static void hpsa_update_device_supports_aborts(struct ctlr_info *h,
> @@ -3803,6 +3807,7 @@ static void hpsa_update_scsi_devices(struct ctlr_info *h, int hostno)
>  	n_ext_target_devs = 0;
>  	for (i = 0; i < nphysicals + nlogicals + 1; i++) {
>  		u8 *lunaddrbytes, is_OBDR = 0;
> +		int rc = 0;
>  
>  		/* Figure out where the LUN ID info is coming from */
>  		lunaddrbytes = figure_lunaddrbytes(h, raid_ctlr_position,
> @@ -3815,11 +3820,20 @@ static void hpsa_update_scsi_devices(struct ctlr_info *h, int hostno)
>  				continue;
>  
>  		/* Get device type, vendor, model, device id */
> -		if (hpsa_update_device_info(h, lunaddrbytes, tmpdevice,
> -							&is_OBDR)) {
> +		rc = hpsa_update_device_info(h, lunaddrbytes, tmpdevice,
> +							&is_OBDR);
> +		if (rc == -ENOMEM) {
> +			dev_warn(&h->pdev->dev,
> +				"Out of memory, rescan deferred.\n");
>  			h->drv_req_rescan = 1;
> -			continue; /* skip it if we can't talk to it. */
> +			goto out;
>  		}
> +		if (rc) {
> +			dev_warn(&h->pdev->dev,
> +				"Inquiry failed, skipping device.\n");
> +			continue;
> +		}
> +
>  		figure_bus_target_lun(h, lunaddrbytes, tmpdevice);
>  		hpsa_update_device_supports_aborts(h, tmpdevice, lunaddrbytes);
>  		this_device = currentsd[ncurrent];
> 
Cheers,

Hannes
-- 
Dr. Hannes Reinecke		      zSeries & Storage
hare@suse.de			      +49 911 74053 688
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: J. Hawn, J. Guild, F. Imendörffer, HRB 16746 (AG Nürnberg)
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH 1 07/25] hpsa: correct transfer length for 6 byte read/write commands
  2015-10-28 22:05 ` [PATCH 1 07/25] hpsa: correct transfer length for 6 byte read/write commands Don Brace
@ 2015-10-30  7:54   ` Hannes Reinecke
  0 siblings, 0 replies; 107+ messages in thread
From: Hannes Reinecke @ 2015-10-30  7:54 UTC (permalink / raw)
  To: Don Brace, scott.teel, Kevin.Barnett, scott.benesh,
	james.bottomley, hch, Justin.Lindley, elliott
  Cc: linux-scsi

On 10/28/2015 11:05 PM, Don Brace wrote:
> handle block counts of 0. Cleanup block and block count calculations.
> 
> Reviewed-by: Scott Teel <scott.teel@pmcs.com>
> Reviewed-by: Justin Lindley <justin.lindley@pmcs.com>
> Reviewed-by: Kevin Barnett <kevin.barnett@pmcs.com>
> Reviewed-by: Tomas Henzl <thenzl@redhat.com>
> Signed-off-by: Don Brace <don.brace@pmcs.com>
> ---
Reviewed-by: Hannes Reinecke <hare@suse.de>

Cheers,

Hannes
-- 
Dr. Hannes Reinecke		      zSeries & Storage
hare@suse.de			      +49 911 74053 688
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: J. Hawn, J. Guild, F. Imendörffer, HRB 16746 (AG Nürnberg)
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH 1 08/25] hpsa: fix hpsa_adjust_hpsa_scsi_table
  2015-10-28 22:05 ` [PATCH 1 08/25] hpsa: fix hpsa_adjust_hpsa_scsi_table Don Brace
  2015-10-29 14:23   ` Tomas Henzl
@ 2015-10-30  7:57   ` Hannes Reinecke
  2015-10-30 20:46     ` Don Brace
  1 sibling, 1 reply; 107+ messages in thread
From: Hannes Reinecke @ 2015-10-30  7:57 UTC (permalink / raw)
  To: Don Brace, scott.teel, Kevin.Barnett, scott.benesh,
	james.bottomley, hch, Justin.Lindley, elliott
  Cc: linux-scsi

On 10/28/2015 11:05 PM, Don Brace wrote:
> Fix a NULL pointer issue in the driver when devices are removed
> during a reset.
> 
> Signed-off-by: Don Brace <don.brace@pmcs.com>
> ---
>  drivers/block/cciss.h |    1 +
>  drivers/scsi/hpsa.c   |   16 ++++++++++++++++
>  drivers/scsi/hpsa.h   |    1 +
>  3 files changed, 18 insertions(+)
> 
> diff --git a/drivers/block/cciss.h b/drivers/block/cciss.h
> index 7fda30e..f8b8c6b 100644
> --- a/drivers/block/cciss.h
> +++ b/drivers/block/cciss.h
> @@ -155,6 +155,7 @@ struct ctlr_info
>  	size_t reply_pool_size;
>  	unsigned char reply_pool_wraparound;
>  	u32 *blockFetchTable;
> +	u8 reset_in_progress;
>  };
>  
>  /*  Defining the diffent access_methods
Why do you need to add it here?
To my knowledge cciss and hpsa are different drivers ...

Cheers,

Hannes
-- 
Dr. Hannes Reinecke		      zSeries & Storage
hare@suse.de			      +49 911 74053 688
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: J. Hawn, J. Guild, F. Imendörffer, HRB 16746 (AG Nürnberg)
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH 1 09/25] hpsa: fix physical target reset
  2015-10-28 22:05 ` [PATCH 1 09/25] hpsa: fix physical target reset Don Brace
  2015-10-29 14:30   ` Tomas Henzl
@ 2015-10-30  7:59   ` Hannes Reinecke
  1 sibling, 0 replies; 107+ messages in thread
From: Hannes Reinecke @ 2015-10-30  7:59 UTC (permalink / raw)
  To: Don Brace, scott.teel, Kevin.Barnett, scott.benesh,
	james.bottomley, hch, Justin.Lindley, elliott
  Cc: linux-scsi

On 10/28/2015 11:05 PM, Don Brace wrote:
> From: Scott Teel <scott.teel@pmcs.com>
> 
> Set reset type in device_reset_handler to do either
> logical unit reset for logical devices, or physical
> target reset, for physical devices.
> 
> Reviewed-by: Scott Teel <scott.teel@pmcs.com>
> Reviewed-by: Justin Lindley <justin.lindley@pmcs.com>
> Reviewed-by: Kevin Barnett <kevin.barnett@pmcs.com>
> Signed-off-by: Don Brace <don.brace@pmcs.com>
> ---
Hmm. I would have done this in firmware by making 'physical target
reset' equivalent to a logical unit reset, but that's firmware for you.

Reviewed-by: Hannes Reinecke <hare@suse.de>


Cheers,

Hannes
-- 
Dr. Hannes Reinecke		      zSeries & Storage
hare@suse.de			      +49 911 74053 688
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: J. Hawn, J. Guild, F. Imendörffer, HRB 16746 (AG Nürnberg)
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH 1 10/25] hpsa: correct check for non-disk devices
  2015-10-28 22:05 ` [PATCH 1 10/25] hpsa: correct check for non-disk devices Don Brace
  2015-10-29 14:37   ` Tomas Henzl
@ 2015-10-30  8:01   ` Hannes Reinecke
  1 sibling, 0 replies; 107+ messages in thread
From: Hannes Reinecke @ 2015-10-30  8:01 UTC (permalink / raw)
  To: Don Brace, scott.teel, Kevin.Barnett, scott.benesh,
	james.bottomley, hch, Justin.Lindley, elliott
  Cc: linux-scsi

On 10/28/2015 11:05 PM, Don Brace wrote:
> The driver is using two MACROs which seemingly are looking in
> the wrong location for the device_flags returned from
> CISS_REPORT_PHYS. Both MACROs, NON_DISK_PHYS_DEV and
> PHYS_IOACCEL, are using the pointer returned from figure_lunaddrbytes
> which is the address of the LUN.lunid element in
> the extended CISS_REPORT_PHYS.  But the MACROS are using offsets
> beyond the range of the element (offset 17 of an 8 byte element).
> 
> These MACROs actually are looking at the correct location but
> they fail static checker analysis. It also will not work
> if any new elements are added to the extended LUN structure.
> 
> Change the code to use the structure elements directly
> since this MACRO is only used in one location.
> 
> Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
> Reviewed-by: Scott Teel <scott.teel@pmcs.com>
> Reviewed-by: Justin Lindley <justin.lindley@pmcs.com>
> Reviewed-by: Kevin Barnett <kevin.barnett@pmcs.com>
> Signed-off-by: Don Brace <don.brace@pmcs.com>
> ---
>  drivers/scsi/hpsa.c     |   28 +++++++++++++++-------------
>  drivers/scsi/hpsa_cmd.h |    2 --
>  2 files changed, 15 insertions(+), 15 deletions(-)
> 
Reviewed-by: Hannes Reinecke <hare@suse.de>

Cheers,

Hannes
-- 
Dr. Hannes Reinecke		      zSeries & Storage
hare@suse.de			      +49 911 74053 688
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: J. Hawn, J. Guild, F. Imendörffer, HRB 16746 (AG Nürnberg)
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH 1 11/25] hpsa: correct ioaccel2 sg chain len
  2015-10-28 22:05 ` [PATCH 1 11/25] hpsa: correct ioaccel2 sg chain len Don Brace
  2015-10-29 15:01   ` Tomas Henzl
@ 2015-10-30  8:01   ` Hannes Reinecke
  1 sibling, 0 replies; 107+ messages in thread
From: Hannes Reinecke @ 2015-10-30  8:01 UTC (permalink / raw)
  To: Don Brace, scott.teel, Kevin.Barnett, scott.benesh,
	james.bottomley, hch, Justin.Lindley, elliott
  Cc: linux-scsi

On 10/28/2015 11:05 PM, Don Brace wrote:
> Reviewed-by: Scott Teel <scott.teel@pmcs.com>
> Reviewed-by: Justin Lindley <justin.lindley@pmcs.com>
> Reviewed-by: Kevin Barnett <kevin.barnett@pmcs.com>
> Signed-off-by: Don Brace <don.brace@pmcs.com>
> ---
>  drivers/scsi/hpsa.c |    5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
Reviewed-by: Hannes Reinecke <hare@suse.de>

Cheers,

Hannes
-- 
Dr. Hannes Reinecke		      zSeries & Storage
hare@suse.de			      +49 911 74053 688
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: J. Hawn, J. Guild, F. Imendörffer, HRB 16746 (AG Nürnberg)
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH 1 12/25] hpsa: simplify check for device exposure
  2015-10-28 22:05 ` [PATCH 1 12/25] hpsa: simplify check for device exposure Don Brace
  2015-10-29 15:03   ` Tomas Henzl
@ 2015-10-30  8:04   ` Hannes Reinecke
  1 sibling, 0 replies; 107+ messages in thread
From: Hannes Reinecke @ 2015-10-30  8:04 UTC (permalink / raw)
  To: Don Brace, scott.teel, Kevin.Barnett, scott.benesh,
	james.bottomley, hch, Justin.Lindley, elliott
  Cc: linux-scsi

On 10/28/2015 11:05 PM, Don Brace wrote:
> From: Kevin Barnett <kevin.barnett@pmcs.com>
> 
> remove macros and cleanup device exposure checking
> 
> Reviewed-by: Scott Teel <scott.teel@pmcs.com>
> Reviewed-by: Justin Lindley <justin.lindley@pmcs.com>
> Reviewed-by: Kevin Barnett <kevin.barnett@pmcs.com>
> Signed-off-by: Don Brace <don.brace@pmcs.com>
> ---
>  drivers/scsi/hpsa.c |   25 +++++++++++--------------
>  drivers/scsi/hpsa.h |    6 +-----
>  2 files changed, 12 insertions(+), 19 deletions(-)
> 
Reviewed-by: Hannes Reinecke <hare@suse.de>

Cheers,

Hannes
-- 
Dr. Hannes Reinecke		      zSeries & Storage
hare@suse.de			      +49 911 74053 688
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: J. Hawn, J. Guild, F. Imendörffer, HRB 16746 (AG Nürnberg)
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH 1 13/25] hpsa: simplify update scsi devices
  2015-10-28 22:05 ` [PATCH 1 13/25] hpsa: simplify update scsi devices Don Brace
  2015-10-29 15:53   ` Tomas Henzl
  2015-10-29 16:43   ` Matthew R. Ochs
@ 2015-10-30  8:05   ` Hannes Reinecke
  2 siblings, 0 replies; 107+ messages in thread
From: Hannes Reinecke @ 2015-10-30  8:05 UTC (permalink / raw)
  To: Don Brace, scott.teel, Kevin.Barnett, scott.benesh,
	james.bottomley, hch, Justin.Lindley, elliott
  Cc: linux-scsi

On 10/28/2015 11:05 PM, Don Brace wrote:
> From: Kevin Barnett <kevin.barnett@pmcs.com>
> 
> remove repeated calculation that checks for physical
> or logical devices.
> 
> Reviewed-by: Scott Teel <scott.teel@pmcs.com>
> Reviewed-by: Justin Lindley <justin.lindley@pmcs.com>
> Reviewed-by: Kevin Barnett <kevin.barnett@pmcs.com>
> Signed-off-by: Don Brace <don.brace@pmcs.com>
> ---
>  drivers/scsi/hpsa.c |   23 ++++++++++++++---------
>  drivers/scsi/hpsa.h |    1 +
>  2 files changed, 15 insertions(+), 9 deletions(-)
> 
Reviewed-by: Hannes Reinecke <hare@suse.de>

Cheers,

Hannes
-- 
Dr. Hannes Reinecke		      zSeries & Storage
hare@suse.de			      +49 911 74053 688
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: J. Hawn, J. Guild, F. Imendörffer, HRB 16746 (AG Nürnberg)
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH 1 14/25] hpsa: add function is_logical_device
  2015-10-28 22:05 ` [PATCH 1 14/25] hpsa: add function is_logical_device Don Brace
  2015-10-29 15:53   ` Tomas Henzl
  2015-10-29 16:46   ` Matthew R. Ochs
@ 2015-10-30  8:05   ` Hannes Reinecke
  2 siblings, 0 replies; 107+ messages in thread
From: Hannes Reinecke @ 2015-10-30  8:05 UTC (permalink / raw)
  To: Don Brace, scott.teel, Kevin.Barnett, scott.benesh,
	james.bottomley, hch, Justin.Lindley, elliott
  Cc: linux-scsi

On 10/28/2015 11:05 PM, Don Brace wrote:
> From: Kevin Barnett <kevin.barnett@pmcs.com>
> 
> simplify checking for logical/physical devices
> 
> Reviewed-by: Scott Teel <scott.teel@pmcs.com>
> Reviewed-by: Justin Lindley <justin.lindley@pmcs.com>
> Reviewed-by: Kevin Barnett <kevin.barnett@pmcs.com>
> Signed-off-by: Don Brace <don.brace@pmcs.com>
> ---
>  drivers/scsi/hpsa.c |   19 ++++++++++++-------
>  1 file changed, 12 insertions(+), 7 deletions(-)
> 
Reviewed-by: Hannes Reinecke <hare@suse.de>

Cheers,

Hannes
-- 
Dr. Hannes Reinecke		      zSeries & Storage
hare@suse.de			      +49 911 74053 688
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: J. Hawn, J. Guild, F. Imendörffer, HRB 16746 (AG Nürnberg)
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH 1 15/25] hpsa: enhance hpsa_get_device_id
  2015-10-28 22:06 ` [PATCH 1 15/25] hpsa: enhance hpsa_get_device_id Don Brace
  2015-10-29 16:04   ` Tomas Henzl
  2015-10-29 17:04   ` Matthew R. Ochs
@ 2015-10-30  8:08   ` Hannes Reinecke
  2015-10-30 20:59     ` Don Brace
  2 siblings, 1 reply; 107+ messages in thread
From: Hannes Reinecke @ 2015-10-30  8:08 UTC (permalink / raw)
  To: Don Brace, scott.teel, Kevin.Barnett, scott.benesh,
	james.bottomley, hch, Justin.Lindley, elliott
  Cc: linux-scsi

On 10/28/2015 11:06 PM, Don Brace wrote:
> use an index into vpd data for SAS/SATA drives
> 
> Reviewed-by: Scott Teel <scott.teel@pmcs.com>
> Reviewed-by: Justin Lindley <justin.lindley@pmcs.com>
> Reviewed-by: Kevin Barnett <kevin.barnett@pmcs.com>
> Signed-off-by: Don Brace <don.brace@pmcs.com>
> ---
>  drivers/scsi/hpsa.c |   23 ++++++++++++++++++++---
>  1 file changed, 20 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
> index c1b053f..1361414 100644
> --- a/drivers/scsi/hpsa.c
> +++ b/drivers/scsi/hpsa.c
> @@ -3137,7 +3137,7 @@ out:
>  
>  /* Get the device id from inquiry page 0x83 */
>  static int hpsa_get_device_id(struct ctlr_info *h, unsigned char *scsi3addr,
> -	unsigned char *device_id, int buflen)
> +	unsigned char *device_id, int index, int buflen)
>  {
>  	int rc;
>  	unsigned char *buf;
> @@ -3149,8 +3149,10 @@ static int hpsa_get_device_id(struct ctlr_info *h, unsigned char *scsi3addr,
>  		return -ENOMEM;
>  	rc = hpsa_scsi_do_inquiry(h, scsi3addr, VPD_PAGE | 0x83, buf, 64);
>  	if (rc == 0)
> -		memcpy(device_id, &buf[8], buflen);
> +		memcpy(device_id, &buf[index], buflen);
> +
>  	kfree(buf);
> +
>  	return rc != 0;
>  }
>  
> @@ -3379,6 +3381,18 @@ static int hpsa_device_supports_aborts(struct ctlr_info *h,
>  	return rc;
>  }
>  
> +static void sanitize_inquiry_string(unsigned char *s, int len)
> +{
> +	bool terminated = false;
> +
> +	for (; len > 0; (--len, ++s)) {
> +		if (*s == 0)
> +			terminated = true;
> +		if (terminated || *s < 0x20 || *s > 0x7e)
> +			*s = ' ';
> +	}
> +}
> +
>  static int hpsa_update_device_info(struct ctlr_info *h,
>  	unsigned char scsi3addr[], struct hpsa_scsi_dev_t *this_device,
>  	unsigned char *is_OBDR_device)
I would prefer to have the function from scsi_scan.c to be exported.
Hardly a point to duplicate it.

Cheers,

Hannes
-- 
Dr. Hannes Reinecke		      zSeries & Storage
hare@suse.de			      +49 911 74053 688
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: J. Hawn, J. Guild, F. Imendörffer, HRB 16746 (AG Nürnberg)
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH 1 16/25] hpsa: refactor hpsa_figure_bus_target_lun
  2015-10-28 22:06 ` [PATCH 1 16/25] hpsa: refactor hpsa_figure_bus_target_lun Don Brace
  2015-10-29 16:27   ` Tomas Henzl
@ 2015-10-30  8:09   ` Hannes Reinecke
  1 sibling, 0 replies; 107+ messages in thread
From: Hannes Reinecke @ 2015-10-30  8:09 UTC (permalink / raw)
  To: Don Brace, scott.teel, Kevin.Barnett, scott.benesh,
	james.bottomley, hch, Justin.Lindley, elliott
  Cc: linux-scsi

On 10/28/2015 11:06 PM, Don Brace wrote:
> From: Kevin Barnett <kevin.barnett@pmcs.com>
> 
> setup for sas transport. Need to set the
> bus and target accordingly.
> 
> Reviewed-by: Scott Teel <scott.teel@pmcs.com>
> Reviewed-by: Justin Lindley <justin.lindley@pmcs.com>
> Reviewed-by: Kevin Barnett <kevin.barnett@pmcs.com>
> Signed-off-by: Don Brace <don.brace@pmcs.com>
> ---
>  drivers/scsi/hpsa.c |   25 ++++++++++++-------------
>  drivers/scsi/hpsa.h |    5 +++++
>  2 files changed, 17 insertions(+), 13 deletions(-)
> 
Reviewed-by: Hannes Reinecke <hare@suse.de>

Cheers,

Hannes
-- 
Dr. Hannes Reinecke		      zSeries & Storage
hare@suse.de			      +49 911 74053 688
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: J. Hawn, J. Guild, F. Imendörffer, HRB 16746 (AG Nürnberg)
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH 1 17/25] hpsa: move scsi_add_device and scsi_remove_device calls to new function
  2015-10-28 22:06 ` [PATCH 1 17/25] hpsa: move scsi_add_device and scsi_remove_device calls to new function Don Brace
  2015-10-29 16:37   ` Tomas Henzl
  2015-10-29 17:21   ` Matthew R. Ochs
@ 2015-10-30  8:09   ` Hannes Reinecke
  2 siblings, 0 replies; 107+ messages in thread
From: Hannes Reinecke @ 2015-10-30  8:09 UTC (permalink / raw)
  To: Don Brace, scott.teel, Kevin.Barnett, scott.benesh,
	james.bottomley, hch, Justin.Lindley, elliott
  Cc: linux-scsi

On 10/28/2015 11:06 PM, Don Brace wrote:
> From: Kevin Barnett <kevin.barnett@pmcs.com>
> 
> preparation for adding the sas transport class
> 
> Reviewed-by: Scott Teel <scott.teel@pmcs.com>
> Reviewed-by: Justin Lindley <justin.lindley@pmcs.com>
> Reviewed-by: Kevin Barnett <kevin.barnett@pmcs.com>
> Signed-off-by: Don Brace <don.brace@pmcs.com>
> ---
>  drivers/scsi/hpsa.c |   65 +++++++++++++++++++++++++++++++--------------------
>  1 file changed, 39 insertions(+), 26 deletions(-)
> 
Reviewed-by: Hannes Reinecke <hare@suse.de>

Cheers,

Hannes
-- 
Dr. Hannes Reinecke		      zSeries & Storage
hare@suse.de			      +49 911 74053 688
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: J. Hawn, J. Guild, F. Imendörffer, HRB 16746 (AG Nürnberg)
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH 1 18/25] External array LUNs must use target and lun numbers assigned by the
  2015-10-28 22:06 ` [PATCH 1 18/25] External array LUNs must use target and lun numbers assigned by the Don Brace
  2015-10-29 19:41   ` Matthew R. Ochs
@ 2015-10-30  8:11   ` Hannes Reinecke
  2015-10-30 14:11   ` Tomas Henzl
  2 siblings, 0 replies; 107+ messages in thread
From: Hannes Reinecke @ 2015-10-30  8:11 UTC (permalink / raw)
  To: Don Brace, scott.teel, Kevin.Barnett, scott.benesh,
	james.bottomley, hch, Justin.Lindley, elliott
  Cc: linux-scsi

On 10/28/2015 11:06 PM, Don Brace wrote:
> From: Scott Teel <scott.teel@pmcs.com>
> 
> external array. So the driver must treat these differently from
> local LUNs when assigning lun/target.
> 
Please fixup the description; looks like it has been incorrectly
broken up during git commit.

> LUN's 'model' field has been used to detect Lun types that need
> special treatment, but the desire is to eliminate the need to reference
> specific array models, and support any external array.
> 
> Pass-through RAID (PTRAID) luns are not luns of the local controller,
> so they are not reported in LUN count of command 'ID controller'.
> However, they ARE reported in "Report logical Luns" command.
> Local luns are listed first, then PTRAID LUNs.
> 
> The number of luns from "Report LUNs" in excess of those reported by
> 'ID controller' are therefore the PTRAID LUNS.
> 
> We can now remove function is_ext_target, and the 'white list'
> array of supported model names.
> 
> Reviewed-by: Scott Teel <scott.teel@pmcs.com>
> Reviewed-by: Justin Lindley <justin.lindley@pmcs.com>
> Reviewed-by: Kevin Barnett <kevin.barnett@pmcs.com>
> Signed-off-by: Don Brace <don.brace@pmcs.com>
> ---
Reviewed-by: Hannes Reinecke <hare@suse.de>

Cheers,

Hannes
-- 
Dr. Hannes Reinecke		      zSeries & Storage
hare@suse.de			      +49 911 74053 688
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: J. Hawn, J. Guild, F. Imendörffer, HRB 16746 (AG Nürnberg)
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH 1 19/25] hpsa: eliminate fake lun0 enclosures
  2015-10-28 22:06 ` [PATCH 1 19/25] hpsa: eliminate fake lun0 enclosures Don Brace
  2015-10-29 20:05   ` Matthew R. Ochs
@ 2015-10-30  8:12   ` Hannes Reinecke
  2015-10-30 14:12   ` Tomas Henzl
  2 siblings, 0 replies; 107+ messages in thread
From: Hannes Reinecke @ 2015-10-30  8:12 UTC (permalink / raw)
  To: Don Brace, scott.teel, Kevin.Barnett, scott.benesh,
	james.bottomley, hch, Justin.Lindley, elliott
  Cc: linux-scsi

On 10/28/2015 11:06 PM, Don Brace wrote:
> From: Scott Teel <scott.teel@pmcs.com>
> 
> We don't need to create fake enclosure devices at Lun0
> in external target array configurations anymore.
> This was done to support Pre-SCSI rev 5 controllers
> that didn't suppoprt report luns commands, so the
> SCSI layer had to scan targets. If there was no
> LUN at LUN 0, then the target scan would stop, and
> move to the next target.  Lun0 enclosure device
> was added to prevent sparsely-numbered LUNs from
> being missed.
> 
> Reviewed-by: Scott Teel <scott.teel@pmcs.com>
> Reviewed-by: Justin Lindley <justin.lindley@pmcs.com>
> Reviewed-by: Kevin Barnett <kevin.barnett@pmcs.com>
> Signed-off-by: Don Brace <don.brace@pmcs.com>
> ---
Reviewed-by: Hannes Reinecke <hare@suse.de>

Cheers,

Hannes
-- 
Dr. Hannes Reinecke		      zSeries & Storage
hare@suse.de			      +49 911 74053 688
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: J. Hawn, J. Guild, F. Imendörffer, HRB 16746 (AG Nürnberg)
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH 1 20/25] hpsa: add discovery polling for PT RAID devices.
  2015-10-28 22:06 ` [PATCH 1 20/25] hpsa: add discovery polling for PT RAID devices Don Brace
  2015-10-29 20:20   ` Matthew R. Ochs
@ 2015-10-30  8:15   ` Hannes Reinecke
  1 sibling, 0 replies; 107+ messages in thread
From: Hannes Reinecke @ 2015-10-30  8:15 UTC (permalink / raw)
  To: Don Brace, scott.teel, Kevin.Barnett, scott.benesh,
	james.bottomley, hch, Justin.Lindley, elliott
  Cc: linux-scsi

On 10/28/2015 11:06 PM, Don Brace wrote:
> From: Scott Teel <scott.teel@pmcs.com>
> 
> There are problems with getting configuration change notification
> in pass-through RAID environments.  So, activate flag
> h->discovery_polling when one of these devices is detected in
> update_scsi_devices.
> 
> After discovery_polling is set, execute a report luns from
> rescan_controller_worker (every 30 seconds).
> 
> If the data from report_luns is different than last
> time (binary compare), execute a full rescan via update_scsi_devices.
> 
> Reviewed-by: Scott Teel <scott.teel@pmcs.com>
> Reviewed-by: Justin Lindley <justin.lindley@pmcs.com>
> Reviewed-by: Kevin Barnett <kevin.barnett@pmcs.com>
> Signed-off-by: Don Brace <don.brace@pmcs.com>
> ---
>  drivers/scsi/hpsa.c |   68 +++++++++++++++++++++++++++++++++++++++++++++++++++
>  drivers/scsi/hpsa.h |    2 ++
>  2 files changed, 70 insertions(+)
> 
Hmm. Can't say I like it, but if there's no other way...

Reviewed-by: Hannes Reinecke <hare@suse.de>

Cheers,

Hannes
-- 
Dr. Hannes Reinecke		      zSeries & Storage
hare@suse.de			      +49 911 74053 688
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: J. Hawn, J. Guild, F. Imendörffer, HRB 16746 (AG Nürnberg)
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH 1 21/25] hpsa: disable report lun data caching
  2015-10-28 22:06 ` [PATCH 1 21/25] hpsa: disable report lun data caching Don Brace
@ 2015-10-30  8:16   ` Hannes Reinecke
  2015-10-30 14:25   ` Tomas Henzl
  2015-10-30 16:27   ` Matthew R. Ochs
  2 siblings, 0 replies; 107+ messages in thread
From: Hannes Reinecke @ 2015-10-30  8:16 UTC (permalink / raw)
  To: Don Brace, scott.teel, Kevin.Barnett, scott.benesh,
	james.bottomley, hch, Justin.Lindley, elliott
  Cc: linux-scsi

On 10/28/2015 11:06 PM, Don Brace wrote:
> From: Scott Teel <scott.teel@pmcs.com>
> 
> When external target arrays are present, disable the firmware's
> normal behavior of returning a cached copy of the report lun data,
> and force it to collect new data each time we request a report luns.
> 
> This is necessary for external arrays, since there may be no
> reliable signal from the external array to the smart array when
> lun configuration changes, and thus when driver requests
> report luns, it may be stale data.
> 
> Use diag options to turn off RPL data caching.
> 
> Reviewed-by: Scott Teel <scott.teel@pmcs.com>
> Reviewed-by: Justin Lindley <justin.lindley@pmcs.com>
> Reviewed-by: Kevin Barnett <kevin.barnett@pmcs.com>
> Signed-off-by: Don Brace <don.brace@pmcs.com>
> ---
>  drivers/scsi/hpsa.c     |   86 +++++++++++++++++++++++++++++++++++++++++++++++
>  drivers/scsi/hpsa_cmd.h |    3 ++
>  2 files changed, 89 insertions(+)
> 
Reviewed-by: Hannes Reinecke <hare@suse.de>

Cheers,

Hannes
-- 
Dr. Hannes Reinecke		      zSeries & Storage
hare@suse.de			      +49 911 74053 688
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: J. Hawn, J. Guild, F. Imendörffer, HRB 16746 (AG Nürnberg)
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH 1 22/25] hpsa: enhance device messages
  2015-10-28 22:06 ` [PATCH 1 22/25] hpsa: enhance device messages Don Brace
@ 2015-10-30  8:16   ` Hannes Reinecke
  2015-10-30 14:32   ` Tomas Henzl
  2015-10-30 16:53   ` Matthew R. Ochs
  2 siblings, 0 replies; 107+ messages in thread
From: Hannes Reinecke @ 2015-10-30  8:16 UTC (permalink / raw)
  To: Don Brace, scott.teel, Kevin.Barnett, scott.benesh,
	james.bottomley, hch, Justin.Lindley, elliott
  Cc: linux-scsi

On 10/28/2015 11:06 PM, Don Brace wrote:
> Reviewed-by: Justin Lindley <justin.lindley@pmcs.com>
> Reviewed-by: Scott Teel <scott.teel@pmcs.com>
> Reviewed-by: Kevin Barnett <kevin.barnett@pmcs.com>
> Signed-off-by: Don Brace <don.brace@pmcs.com>
> ---
>  drivers/scsi/hpsa.c |   45 ++++++++++++++++++++++++++++++++++++++++-----
>  1 file changed, 40 insertions(+), 5 deletions(-)
> 
Reviewed-by: Hannes Reinecke <hare@suse.de>

Cheers,

Hannes
-- 
Dr. Hannes Reinecke		      zSeries & Storage
hare@suse.de			      +49 911 74053 688
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: J. Hawn, J. Guild, F. Imendörffer, HRB 16746 (AG Nürnberg)
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH 1 23/25] hpsa: fix multiple issues in path_info_show
  2015-10-28 22:06 ` [PATCH 1 23/25] hpsa: fix multiple issues in path_info_show Don Brace
@ 2015-10-30  8:18   ` Hannes Reinecke
  2015-10-30 14:33   ` Tomas Henzl
  2015-10-30 17:07   ` Matthew R. Ochs
  2 siblings, 0 replies; 107+ messages in thread
From: Hannes Reinecke @ 2015-10-30  8:18 UTC (permalink / raw)
  To: Don Brace, scott.teel, Kevin.Barnett, scott.benesh,
	james.bottomley, hch, Justin.Lindley, elliott
  Cc: linux-scsi

On 10/28/2015 11:06 PM, Don Brace wrote:
> From: Rasmus Villemoes <linux@rasmusvillemoes.dk>
> 
> path_info_show() seems to be broken in multiple ways.
> 
> First, there's
> 
>   817 return snprintf(buf, output_len+1, "%s%s%s%s%s%s%s%s",
>   818       path[0], path[1], path[2], path[3],
>   819       path[4], path[5], path[6], path[7]);
> 
> so hopefully output_len contains the combined length of the eight
> strings. Otherwise, snprintf will stop copying to the output
> buffer, but still end up reporting that combined length - which
> in turn would result in user-space getting a bunch of useless nul
> bytes (thankfully the upper sysfs layer seems to clear the output
> buffer before passing it to the various ->show routines). But we have
> 
>   767      output_len = snprintf(path[i],
>   768                       PATH_STRING_LEN, "[%d:%d:%d:%d] %20.20s ",
>   769                       h->scsi_host->host_no,
>   770                       hdev->bus, hdev->target, hdev->lun,
>   771                       scsi_device_type(hdev->devtype));
> 
> so output_len at best contains the length of the last string printed.
> 
> Inside the loop, we then otherwise add to output_len. By magic,
> we still have PATH_STRING_LEN available every time... This
> wouldn't really be a problem if the bean-counting has been done
> properly and each line actually does fit in 50 bytes, and maybe
> it does, but I don't immediately see why. Suppose we end up
> taking this branch:
> 
>   802                  output_len += snprintf(path[i] + output_len,
>   803                          PATH_STRING_LEN,
>   804                          "BOX: %hhu BAY: %hhu %s\n",
>   805                          box, bay, active);
> 
> An optimistic estimate says this uses strlen("BOX: 1 BAY: 2
> Active\n") which is 21. Now add the 20 bytes guaranteed by the
> %20.20s and then some for the rest of that format string, and
> we're easily over 50 bytes. I don't think we can get over 100
> bytes even being pessimistic, so this just means we'll scribble
> into the next path[i+1] and maybe get that overwritten later,
> leading to some garbled output (in fact, since we'd overwrite the
> previous string's 0-terminator, we could end up with one very
> long string and then print various suffixes of that, leading to
> much more than 400 bytes of output). Except of course when we're
> filling path[7], where overrunning it means writing random stuff
> to the kernel stack, which is usually a lot of fun.
> 
> We can fix all of that and get rid of the 400 byte stack buffer by
> simply writing directly to the given output buffer, which the upper
> layer guarantees is at least PAGE_SIZE. s[c]nprintf doesn't care where
> it is writing to, so this doesn't make the spin lock hold time any
> longer. Using scnprintf ensures that output_len always represents the
> number of bytes actually written to the buffer, so we'll report the
> proper amount to the upper layer.
> 
> Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>
> Signed-off-by: Don Brace <don.brace@pmcs.com>
> ---
>  drivers/scsi/hpsa.c |   38 +++++++++++++++++---------------------
>  1 file changed, 17 insertions(+), 21 deletions(-)
> 
Reviewed-by: Hannes Reinecke <hare@suse.de>

Cheers,

Hannes
-- 
Dr. Hannes Reinecke		      zSeries & Storage
hare@suse.de			      +49 911 74053 688
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: J. Hawn, J. Guild, F. Imendörffer, HRB 16746 (AG Nürnberg)
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH 1 24/25] hpsa: add in sas transport class
  2015-10-28 22:06 ` [PATCH 1 24/25] hpsa: add in sas transport class Don Brace
@ 2015-10-30  8:21   ` Hannes Reinecke
  2015-10-30 14:40   ` Tomas Henzl
                     ` (2 subsequent siblings)
  3 siblings, 0 replies; 107+ messages in thread
From: Hannes Reinecke @ 2015-10-30  8:21 UTC (permalink / raw)
  To: Don Brace, scott.teel, Kevin.Barnett, scott.benesh,
	james.bottomley, hch, Justin.Lindley, elliott
  Cc: linux-scsi

On 10/28/2015 11:06 PM, Don Brace wrote:
> From: Kevin Barnett <kevin.barnett@pmcs.com>
> 
> Reviewed-by: Scott Teel <scott.teel@pmcs.com>
> Reviewed-by: Justin Lindley <justin.lindley@pmcs.com>
> Reviewed-by: Kevin Barnett <kevin.barnett@pmcs.com>
> Signed-off-by: Don Brace <don.brace@pmcs.com>
> ---
>  drivers/scsi/hpsa.c     |  535 +++++++++++++++++++++++++++++++++++++++++++++--
>  drivers/scsi/hpsa.h     |   27 ++
>  drivers/scsi/hpsa_cmd.h |   14 +
>  3 files changed, 555 insertions(+), 21 deletions(-)
> 
Reviewed-by: Hannes Reinecke <hare@suse.de>

Cheers,

Hannes
-- 
Dr. Hannes Reinecke		      zSeries & Storage
hare@suse.de			      +49 911 74053 688
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: J. Hawn, J. Guild, F. Imendörffer, HRB 16746 (AG Nürnberg)
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH 1 25/25] hpsa: bump the driver version
  2015-10-28 22:07 ` [PATCH 1 25/25] hpsa: bump the driver version Don Brace
@ 2015-10-30  8:22   ` Hannes Reinecke
  2015-10-30 14:44   ` Tomas Henzl
  2015-10-30 20:08   ` Matthew R. Ochs
  2 siblings, 0 replies; 107+ messages in thread
From: Hannes Reinecke @ 2015-10-30  8:22 UTC (permalink / raw)
  To: Don Brace, scott.teel, Kevin.Barnett, scott.benesh,
	james.bottomley, hch, Justin.Lindley, elliott
  Cc: linux-scsi

On 10/28/2015 11:07 PM, Don Brace wrote:
> Reviewed-by: Justin Lindley <justin.lindley@pmcs.com>
> Reviewed-by: Scott Teel <scott.teel@pmcs.com>
> Reviewed-by: Kevin Barnett <kevin.barnett@pmcs.com>
> Reviewed-by: Gerry Morong <gerry.morong.pmcs.com>
> Signed-off-by: Don Brace <don.brace@pmcs.com>
> ---
>  drivers/scsi/hpsa.c |    2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
Reviewed-by: Hannes Reinecke <hare@suse.de>

Cheers,

Hannes
-- 
Dr. Hannes Reinecke		      zSeries & Storage
hare@suse.de			      +49 911 74053 688
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: J. Hawn, J. Guild, F. Imendörffer, HRB 16746 (AG Nürnberg)
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH 1 20/25] hpsa: add discovery polling for PT RAID devices.
  2015-10-29 20:59       ` Matthew R. Ochs
@ 2015-10-30 14:08         ` Don Brace
  2015-10-30 15:58           ` Matthew R. Ochs
  0 siblings, 1 reply; 107+ messages in thread
From: Don Brace @ 2015-10-30 14:08 UTC (permalink / raw)
  To: Matthew R. Ochs, Don Brace
  Cc: scott.teel, Kevin.Barnett, scott.benesh, james.bottomley, hch,
	Justin.Lindley, elliott, linux-scsi

On 10/29/2015 03:59 PM, Matthew R. Ochs wrote:
>> On Oct 29, 2015, at 3:51 PM, Don Brace <brace77070@gmail.com> wrote:
>> On 10/29/2015 03:20 PM, Matthew R. Ochs wrote:
>>>> On Oct 28, 2015, at 5:06 PM, Don Brace <don.brace@pmcs.com>
>>>>   wrote:
>>>>
>>>> From: Scott Teel
>>>> <scott.teel@pmcs.com>
>>>>
>>>>
>>>> There are problems with getting configuration change notification
>>>> in pass-through RAID environments.  So, activate flag
>>>> h->discovery_polling when one of these devices is detected in
>>>> update_scsi_devices.
>>>>
>>>> After discovery_polling is set, execute a report luns from
>>>> rescan_controller_worker (every 30 seconds).
>>>>
>>>> If the data from report_luns is different than last
>>>> time (binary compare), execute a full rescan via update_scsi_devices.
>>>>
>>>> Reviewed-by: Scott Teel
>>>> <scott.teel@pmcs.com>
>>>>
>>>> Reviewed-by: Justin Lindley
>>>> <justin.lindley@pmcs.com>
>>>>
>>>> Reviewed-by: Kevin Barnett
>>>> <kevin.barnett@pmcs.com>
>>>>
>>>> Signed-off-by: Don Brace
>>>> <don.brace@pmcs.com>
>>>>
>>>> ---
>>>> drivers/scsi/hpsa.c |   68 +++++++++++++++++++++++++++++++++++++++++++++++++++
>>>> drivers/scsi/hpsa.h |    2 ++
>>>> 2 files changed, 70 insertions(+)
>>>>
>>>> diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
>>>> index 8d67648..e521acd 100644
>>>> --- a/drivers/scsi/hpsa.c
>>>> +++ b/drivers/scsi/hpsa.c
>>>> @@ -276,6 +276,7 @@ static int hpsa_scsi_ioaccel_queue_command(struct ctlr_info *h,
>>>> static void hpsa_command_resubmit_worker(struct work_struct *work);
>>>> static u32 lockup_detected(struct ctlr_info *h);
>>>> static int detect_controller_lockup(struct ctlr_info *h);
>>>> +static int hpsa_luns_changed(struct ctlr_info *h);
>>>>
>>>> static inline struct ctlr_info *sdev_to_hba(struct scsi_device *sdev)
>>>> {
>>>> @@ -3904,6 +3905,18 @@ static void hpsa_update_scsi_devices(struct ctlr_info *h, int hostno)
>>>> 		hpsa_update_device_supports_aborts(h, tmpdevice, lunaddrbytes);
>>>> 		this_device = currentsd[ncurrent];
>>>>
>>>> +		/* Turn on discovery_polling if there are ext target devices.
>>>> +		 * Event-based change notification is unreliable for those.
>>>> +		 */
>>>> +		if (!h->discovery_polling) {
>>>> +			if (tmpdevice->external) {
>>>> +				h->discovery_polling = 1;
>>>> +				dev_info(&h->pdev->dev,
>>>> +					"External target, activate discovery polling.\n");
>>>> +			}
>>>> +		}
>>>> +
>>>> +
>>>> 		*this_device = *tmpdevice;
>>>> 		this_device->physical_device = physical_device;
>>>>
>>>> @@ -8022,6 +8035,41 @@ static int hpsa_offline_devices_ready(struct ctlr_info *h)
>>>> 	return 0;
>>>> }
>>>>
>>>> +static int hpsa_luns_changed(struct ctlr_info *h)
>>>> +{
>>>> +	int rc = 1; /* assume there are changes */
>>>> +	struct ReportLUNdata *logdev = NULL;
>>>> +
>>>> +	/* if we can't find out if lun data has changed,
>>>> +	 * assume that it has.
>>>> +	 */
>>>> +
>>>> +	if (!h->lastlogicals)
>>>> +		goto out;
>>>> +
>>>> +	logdev = kzalloc(sizeof(*logdev), GFP_KERNEL);
>>>> +	if (!logdev) {
>>>> +		dev_warn(&h->pdev->dev,
>>>> +			"Out of memory, can't track lun changes.\n");
>>>> +		goto out;
>>>> +	}
>>>> +	if (hpsa_scsi_do_report_luns(h, 1, logdev, sizeof(*logdev), 0)) {
>>>> +		dev_warn(&h->pdev->dev,
>>>> +			"report luns failed, can't track lun changes.\n");
>>>> +		goto out;
>>>> +	}
>>>> +	if (memcmp(logdev, h->lastlogicals, sizeof(*logdev))) {
>>>> +		dev_info(&h->pdev->dev,
>>>> +			"Lun changes detected.\n");
>>>> +		memcpy(h->lastlogicals, logdev, sizeof(*logdev));
>>>> +		goto out;
>>>> +	} else
>>>> +		rc = 0; /* no changes detected. */
>>>> +out:
>>>> +	kfree(logdev);
>>>> +	return rc;
>>>> +}
>>>> +
>>>> static void hpsa_rescan_ctlr_worker(struct work_struct *work)
>>>> {
>>>> 	unsigned long flags;
>>>> @@ -8037,6 +8085,18 @@ static void hpsa_rescan_ctlr_worker(struct work_struct *work)
>>>> 		hpsa_ack_ctlr_events(h);
>>>> 		hpsa_scan_start(h->scsi_host);
>>>> 		scsi_host_put(h->scsi_host);
>>>> +	} else if (h->discovery_polling) {
>>>> +		if (hpsa_luns_changed(h)) {
>>>> +			struct Scsi_Host *sh = NULL;
>>>> +
>>>> +			dev_info(&h->pdev->dev,
>>>> +				"driver discovery polling rescan.\n");
>>>> +			sh = scsi_host_get(h->scsi_host);
>>>> +			if (sh != NULL) {
>>>> +				hpsa_scan_start(sh);
>>>> +				scsi_host_put(sh);
>>>> +			}
>>>> +		}
>>>> 	}
>>>> 	spin_lock_irqsave(&h->lock, flags);
>>>> 	if (!h->remove_in_progress)
>>>> @@ -8277,6 +8337,8 @@ reinit_after_soft_reset:
>>>>
>>>> 	/* Enable Accelerated IO path at driver layer */
>>>> 	h->acciopath_status = 1;
>>>> +	/* Disable discovery polling.*/
>>>> +	h->discovery_polling = 0;
>>>>
>>>>
>>>> 	/* Turn the interrupts on so we can service requests */
>>>> @@ -8284,6 +8346,11 @@ reinit_after_soft_reset:
>>>>
>>>> 	hpsa_hba_inquiry(h);
>>>>
>>>> +	h->lastlogicals = kzalloc(sizeof(*(h->lastlogicals)), GFP_KERNEL);
>>>> +	if (!h->lastlogicals)
>>>> +		dev_info(&h->pdev->dev,
>>>> +			"Can't track change to report lun data\n");
>>>> +
>>>> 	/* Monitor the controller for firmware lockups */
>>>> 	h->heartbeat_sample_interval = HEARTBEAT_SAMPLE_INTERVAL;
>>>> 	INIT_DELAYED_WORK(&h->monitor_ctlr_work, hpsa_monitor_ctlr_worker);
>>>> @@ -8368,6 +8435,7 @@ static void hpsa_shutdown(struct pci_dev *pdev)
>>>> 	hpsa_flush_cache(h);
>>>> 	h->access.set_intr_mask(h, HPSA_INTR_OFF);
>>>> 	hpsa_free_irqs(h);			/* init_one 4 */
>>>> +	kfree(h->lastlogicals);
>>>>
>>> Is this the best place to free this memory? If your rescan worker is running
>>> concurrently you might run into trouble.
>>>
>> Since hpsa_shutdown is called from hpsa_remove_one, at a point after
>> cancel_delayed_work_sync(&h->rescan_ctlr_work) has already been called,
>> I  think that the rescan worker won’t be running at this point.
> My concern wasn't about the remove path but rather the shutdown notification path.
> ]
You are correct. I moved this to hpsa_remove_one.
Thanks
>

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH 1 18/25] External array LUNs must use target and lun numbers assigned by the
  2015-10-28 22:06 ` [PATCH 1 18/25] External array LUNs must use target and lun numbers assigned by the Don Brace
  2015-10-29 19:41   ` Matthew R. Ochs
  2015-10-30  8:11   ` Hannes Reinecke
@ 2015-10-30 14:11   ` Tomas Henzl
  2 siblings, 0 replies; 107+ messages in thread
From: Tomas Henzl @ 2015-10-30 14:11 UTC (permalink / raw)
  To: Don Brace, scott.teel, Kevin.Barnett, scott.benesh,
	james.bottomley, hch, Justin.Lindley, elliott
  Cc: linux-scsi

On 28.10.2015 23:06, Don Brace wrote:
> From: Scott Teel <scott.teel@pmcs.com>
>
> external array. So the driver must treat these differently from
> local LUNs when assigning lun/target.
>
> LUN's 'model' field has been used to detect Lun types that need
> special treatment, but the desire is to eliminate the need to reference
> specific array models, and support any external array.
>
> Pass-through RAID (PTRAID) luns are not luns of the local controller,
> so they are not reported in LUN count of command 'ID controller'.
> However, they ARE reported in "Report logical Luns" command.
> Local luns are listed first, then PTRAID LUNs.
>
> The number of luns from "Report LUNs" in excess of those reported by
> 'ID controller' are therefore the PTRAID LUNS.
>
> We can now remove function is_ext_target, and the 'white list'
> array of supported model names.
>
> Reviewed-by: Scott Teel <scott.teel@pmcs.com>
> Reviewed-by: Justin Lindley <justin.lindley@pmcs.com>
> Reviewed-by: Kevin Barnett <kevin.barnett@pmcs.com>
> Signed-off-by: Don Brace <don.brace@pmcs.com>
> ---
>  drivers/scsi/hpsa.c     |  141 ++++++++++++++++++++++++++++++++++++++---------
>  drivers/scsi/hpsa.h     |    1 
>  drivers/scsi/hpsa_cmd.h |   11 ++++
>  3 files changed, 127 insertions(+), 26 deletions(-)
>
> diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
> index 06207e2..11ea3e5 100644
> --- a/drivers/scsi/hpsa.c
> +++ b/drivers/scsi/hpsa.c
> @@ -276,7 +276,6 @@ static int hpsa_scsi_ioaccel_queue_command(struct ctlr_info *h,
>  static void hpsa_command_resubmit_worker(struct work_struct *work);
>  static u32 lockup_detected(struct ctlr_info *h);
>  static int detect_controller_lockup(struct ctlr_info *h);
> -static int is_ext_target(struct ctlr_info *h, struct hpsa_scsi_dev_t *device);
>  
>  static inline struct ctlr_info *sdev_to_hba(struct scsi_device *sdev)
>  {
> @@ -777,7 +776,7 @@ static ssize_t path_info_show(struct device *dev,
>  				hdev->bus, hdev->target, hdev->lun,
>  				scsi_device_type(hdev->devtype));
>  
> -		if (is_ext_target(h, hdev) ||
> +		if (hdev->external ||
>  			hdev->devtype == TYPE_RAID ||
>  			is_logical_device(hdev)) {
>  			output_len += snprintf(path[i] + output_len,
> @@ -3037,6 +3036,35 @@ out:
>  	return rc;
>  }
>  
> +static int hpsa_bmic_id_controller(struct ctlr_info *h,
> +	struct bmic_identify_controller *buf, size_t bufsize)
> +{
> +	int rc = IO_OK;
> +	struct CommandList *c;
> +	struct ErrorInfo *ei;
> +
> +	c = cmd_alloc(h);
> +
> +	rc = fill_cmd(c, BMIC_IDENTIFY_CONTROLLER, h, buf, bufsize,
> +		0, RAID_CTLR_LUNID, TYPE_CMD);
> +	if (rc)
> +		goto out;
> +
> +	rc = hpsa_scsi_do_simple_cmd_with_retry(h, c,
> +		PCI_DMA_FROMDEVICE, NO_TIMEOUT);
> +	if (rc)
> +		goto out;
> +	ei = c->err_info;
> +	if (ei->CommandStatus != 0 && ei->CommandStatus != CMD_DATA_UNDERRUN) {
> +		hpsa_scsi_interpret_error(h, c);
> +		rc = -1;
> +	}
> +out:
> +	cmd_free(h, c);
> +	return rc;
> +}
> +
> +
>  static int hpsa_bmic_id_physical_device(struct ctlr_info *h,
>  		unsigned char scsi3addr[], u16 bmic_device_index,
>  		struct bmic_identify_physical_device *buf, size_t bufsize)
> @@ -3513,27 +3541,6 @@ static void hpsa_update_device_supports_aborts(struct ctlr_info *h,
>  	}
>  }
>  
> -static unsigned char *ext_target_model[] = {
> -	"MSA2012",
> -	"MSA2024",
> -	"MSA2312",
> -	"MSA2324",
> -	"P2000 G3 SAS",
> -	"MSA 2040 SAS",
> -	NULL,
> -};
> -
> -static int is_ext_target(struct ctlr_info *h, struct hpsa_scsi_dev_t *device)
> -{
> -	int i;
> -
> -	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.
>   * Logical drive target and lun are assigned at this time, but
> @@ -3557,7 +3564,7 @@ static void figure_bus_target_lun(struct ctlr_info *h,
>  		return;
>  	}
>  	/* It's a logical device */
> -	if (is_ext_target(h, device)) {
> +	if (device->external) {
>  		hpsa_set_bus_target_lun(device,
>  			HPSA_EXTERNAL_RAID_VOLUME_BUS, (lunid >> 16) & 0x3fff,
>  			lunid & 0x00ff);
> @@ -3591,7 +3598,7 @@ static int add_ext_target_dev(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_ext_target(h, tmpdevice))
> +	if (!tmpdevice->external)
>  		return 0; /* Only external target devices have this problem. */
>  
>  	if (tmpdevice->lun == 0) /* if lun is 0, then we have a lun 0. */
> @@ -3650,6 +3657,29 @@ static int hpsa_get_pdisk_of_ioaccel2(struct ctlr_info *h,
>  	return 0;
>  }
>  
> +static int  figure_external_status(struct ctlr_info *h, int raid_ctlr_position,
> +	int i, int nphysicals, int nlocal_logicals)
> +{
> +	/* In report logicals, local logicals are listed first,
> +	* then any externals.
> +	*/
> +	int logicals_start = nphysicals + (raid_ctlr_position == 0);
> +
> +	if (i == raid_ctlr_position)
> +		return 0;

This^ is only to catch the case where (i == nphysicals + nlogicals),
so the last iteration in the outer for cycle?

> +
> +	if (i < logicals_start)
> +		return 0;
> +
> +	/* i is in logicals range, but still within local logicals */
> +	if ((i - nphysicals - (raid_ctlr_position == 0)) < nlocal_logicals)

Is this thea same as ((i - logicals_start) < nlocal_logicals) ?
the previous condition  (i < logicals_start) looks as it were 
a subset of this one and could be removed.
so a single
  if ((i - logicals_start) < nlocal_logicals))
		return 0;
would be sufficient?


The nlocal_logicals is in hpsa_update_scsi_devices an u32
to which you assign a '-1' in hpsa_set_local_logical_count,
here it's converted to an int , so it may be negative - is that intended?

-tm
 

> +		return 0;
> +
> +	return 1; /* it's an external lun */
> +}
> +
> +
> +
>  /*
>   * Do CISS_REPORT_PHYS and CISS_REPORT_LOG.  Data is returned in physdev,
>   * logdev.  The number of luns in physdev and logdev are returned in
> @@ -3773,6 +3803,32 @@ static void hpsa_get_path_info(struct hpsa_scsi_dev_t *this_device,
>  		sizeof(this_device->bay));
>  }
>  
> +/* get number of local logical disks. */
> +static int hpsa_set_local_logical_count(struct ctlr_info *h,
> +	struct bmic_identify_controller *id_ctlr,
> +	u32 *nlocals)
> +{
> +	int rc;
> +
> +	if (!id_ctlr) {
> +		dev_warn(&h->pdev->dev, "%s: id_ctlr buffer is NULL.\n",
> +			__func__);
> +		return -ENOMEM;
> +	}
> +	memset(id_ctlr, 0, sizeof(*id_ctlr));
> +	rc = hpsa_bmic_id_controller(h, id_ctlr, sizeof(*id_ctlr));
> +	if (!rc)
> +		if (id_ctlr->configured_logical_drive_count < 256)
> +			*nlocals = id_ctlr->configured_logical_drive_count;
> +		else
> +			*nlocals = le16_to_cpu(
> +					id_ctlr->extended_logical_unit_count);
> +	else
> +		*nlocals = -1;
> +	return rc;
> +}
> +
> +
>  static void hpsa_update_scsi_devices(struct ctlr_info *h, int hostno)
>  {
>  	/* the idea here is we could get notified
> @@ -3788,8 +3844,10 @@ static void hpsa_update_scsi_devices(struct ctlr_info *h, int hostno)
>  	struct ReportExtendedLUNdata *physdev_list = NULL;
>  	struct ReportLUNdata *logdev_list = NULL;
>  	struct bmic_identify_physical_device *id_phys = NULL;
> +	struct bmic_identify_controller *id_ctlr = NULL;
>  	u32 nphysicals = 0;
>  	u32 nlogicals = 0;
> +	u32 nlocal_logicals = 0;
>  	u32 ndev_allocated = 0;
>  	struct hpsa_scsi_dev_t **currentsd, *this_device, *tmpdevice;
>  	int ncurrent = 0;
> @@ -3803,9 +3861,10 @@ static void hpsa_update_scsi_devices(struct ctlr_info *h, int hostno)
>  	logdev_list = kzalloc(sizeof(*logdev_list), GFP_KERNEL);
>  	tmpdevice = kzalloc(sizeof(*tmpdevice), GFP_KERNEL);
>  	id_phys = kzalloc(sizeof(*id_phys), GFP_KERNEL);
> +	id_ctlr = kzalloc(sizeof(*id_ctlr), GFP_KERNEL);
>  
>  	if (!currentsd || !physdev_list || !logdev_list ||
> -		!tmpdevice || !id_phys) {
> +		!tmpdevice || !id_phys || !id_ctlr) {
>  		dev_err(&h->pdev->dev, "out of memory\n");
>  		goto out;
>  	}
> @@ -3819,6 +3878,13 @@ static void hpsa_update_scsi_devices(struct ctlr_info *h, int hostno)
>  		goto out;
>  	}
>  
> +	/* Set number of local logicals (non PTRAID) */
> +	if (hpsa_set_local_logical_count(h, id_ctlr, &nlocal_logicals)) {
> +		dev_warn(&h->pdev->dev,
> +			"%s: Can't determine number of local logical devices.\n",
> +			__func__);
> +	}
> +
>  	/* 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.
> @@ -3883,6 +3949,11 @@ static void hpsa_update_scsi_devices(struct ctlr_info *h, int hostno)
>  			continue;
>  		}
>  
> +		/* Determine if this is a lun from an external target array */
> +		tmpdevice->external =
> +			figure_external_status(h, raid_ctlr_position, i,
> +						nphysicals, nlocal_logicals);
> +
>  		figure_bus_target_lun(h, lunaddrbytes, tmpdevice);
>  		hpsa_update_device_supports_aborts(h, tmpdevice, lunaddrbytes);
>  		this_device = currentsd[ncurrent];
> @@ -3966,6 +4037,7 @@ out:
>  	kfree(currentsd);
>  	kfree(physdev_list);
>  	kfree(logdev_list);
> +	kfree(id_ctlr);
>  	kfree(id_phys);
>  }
>  
> @@ -6418,6 +6490,23 @@ static int fill_cmd(struct CommandList *c, u8 cmd, struct ctlr_info *h,
>  			c->Request.CDB[7] = (size >> 16) & 0xFF;
>  			c->Request.CDB[8] = (size >> 8) & 0XFF;
>  			break;
> +		case BMIC_IDENTIFY_CONTROLLER:
> +			c->Request.CDBLen = 10;
> +			c->Request.type_attr_dir =
> +				TYPE_ATTR_DIR(cmd_type, ATTR_SIMPLE, XFER_READ);
> +			c->Request.Timeout = 0;
> +			c->Request.CDB[0] = BMIC_READ;
> +			c->Request.CDB[1] = 0;
> +			c->Request.CDB[2] = 0;
> +			c->Request.CDB[3] = 0;
> +			c->Request.CDB[4] = 0;
> +			c->Request.CDB[5] = 0;
> +			c->Request.CDB[6] = BMIC_IDENTIFY_CONTROLLER;
> +			c->Request.CDB[7] = (size >> 16) & 0xFF;
> +			c->Request.CDB[8] = (size >> 8) & 0XFF;
> +			c->Request.CDB[9] = 0;
> +			break;
> +
>  		default:
>  			dev_warn(&h->pdev->dev, "unknown command 0x%c\n", cmd);
>  			BUG();
> diff --git a/drivers/scsi/hpsa.h b/drivers/scsi/hpsa.h
> index 38d5534..0cf147b 100644
> --- a/drivers/scsi/hpsa.h
> +++ b/drivers/scsi/hpsa.h
> @@ -77,6 +77,7 @@ struct hpsa_scsi_dev_t {
>  	struct hpsa_scsi_dev_t *phys_disk[RAID_MAP_MAX_ENTRIES];
>  	int nphysical_disks;
>  	int supports_aborts;
> +	int external;   /* 1-from external array 0-not <0-unknown */
>  };
>  
>  struct reply_queue_buffer {
> diff --git a/drivers/scsi/hpsa_cmd.h b/drivers/scsi/hpsa_cmd.h
> index c2c0737..c83eaf1 100644
> --- a/drivers/scsi/hpsa_cmd.h
> +++ b/drivers/scsi/hpsa_cmd.h
> @@ -286,6 +286,7 @@ struct SenseSubsystem_info {
>  #define BMIC_FLASH_FIRMWARE 0xF7
>  #define BMIC_SENSE_CONTROLLER_PARAMETERS 0x64
>  #define BMIC_IDENTIFY_PHYSICAL_DEVICE 0x15
> +#define BMIC_IDENTIFY_CONTROLLER 0x11
>  
>  /* Command List Structure */
>  union SCSI3Addr {
> @@ -682,6 +683,16 @@ struct hpsa_pci_info {
>  	u32		board_id;
>  };
>  
> +struct bmic_identify_controller {
> +	u8	configured_logical_drive_count;	/* offset 0 */
> +	u8	pad1[153];
> +	__le16	extended_logical_unit_count;	/* offset 154 */
> +	u8	pad2[136];
> +	u8	controller_mode;	/* offset 292 */
> +	u8	pad3[32];
> +};
> +
> +
>  struct bmic_identify_physical_device {
>  	u8    scsi_bus;          /* SCSI Bus number on controller */
>  	u8    scsi_id;           /* SCSI ID on this bus */
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html


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

* Re: [PATCH 1 19/25] hpsa: eliminate fake lun0 enclosures
  2015-10-28 22:06 ` [PATCH 1 19/25] hpsa: eliminate fake lun0 enclosures Don Brace
  2015-10-29 20:05   ` Matthew R. Ochs
  2015-10-30  8:12   ` Hannes Reinecke
@ 2015-10-30 14:12   ` Tomas Henzl
  2 siblings, 0 replies; 107+ messages in thread
From: Tomas Henzl @ 2015-10-30 14:12 UTC (permalink / raw)
  To: Don Brace, scott.teel, Kevin.Barnett, scott.benesh,
	james.bottomley, hch, Justin.Lindley, elliott
  Cc: linux-scsi

On 28.10.2015 23:06, Don Brace wrote:
> From: Scott Teel <scott.teel@pmcs.com>
>
> We don't need to create fake enclosure devices at Lun0
> in external target array configurations anymore.
> This was done to support Pre-SCSI rev 5 controllers
> that didn't suppoprt report luns commands, so the
> SCSI layer had to scan targets. If there was no
> LUN at LUN 0, then the target scan would stop, and
> move to the next target.  Lun0 enclosure device
> was added to prevent sparsely-numbered LUNs from
> being missed.
>
> Reviewed-by: Scott Teel <scott.teel@pmcs.com>
> Reviewed-by: Justin Lindley <justin.lindley@pmcs.com>
> Reviewed-by: Kevin Barnett <kevin.barnett@pmcs.com>
> Signed-off-by: Don Brace <don.brace@pmcs.com>

Reviewed-by: Tomas Henzl <thenzl@redhat.com>

Tomas


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

* Re: [PATCH 1 03/25] hpsa: check for null arguments to dev_printk
  2015-10-30  7:47   ` Hannes Reinecke
@ 2015-10-30 14:16     ` Don Brace
  0 siblings, 0 replies; 107+ messages in thread
From: Don Brace @ 2015-10-30 14:16 UTC (permalink / raw)
  To: Hannes Reinecke, scott.teel, Kevin.Barnett, scott.benesh,
	james.bottomley, hch, Justin.Lindley, elliott
  Cc: linux-scsi

On 10/30/2015 02:47 AM, Hannes Reinecke wrote:
> On 10/28/2015 11:04 PM, Don Brace wrote:
>> Check for NULLs.
>>
>> Signed-off-by: Don Brace <don.brace@pmcs.com>
>> ---
>>   drivers/scsi/hpsa.c |    6 ++++++
>>   drivers/scsi/hpsa.h |    2 +-
>>   2 files changed, 7 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
>> index 864fb03..6b6e9bb 100644
>> --- a/drivers/scsi/hpsa.c
>> +++ b/drivers/scsi/hpsa.c
>> @@ -1139,6 +1139,12 @@ static int hpsa_find_target_lun(struct ctlr_info *h,
>>   static inline void hpsa_show_dev_msg(const char *level, struct ctlr_info *h,
>>   	struct hpsa_scsi_dev_t *dev, char *description)
>>   {
>> +	if (dev == NULL)
>> +		return;
>> +
>> +	if (h == NULL || h->pdev == NULL || h->scsi_host == NULL)
>> +		return;
>> +
>>   	dev_printk(level, &h->pdev->dev,
>>   			"scsi %d:%d:%d:%d: %s %s %.8s %.16s RAID-%s SSDSmartPathCap%c En%c Exp=%d\n",
>>   			h->scsi_host->host_no, dev->bus, dev->target, dev->lun,
>> diff --git a/drivers/scsi/hpsa.h b/drivers/scsi/hpsa.h
>> index 27debb3..d6c4ebf 100644
>> --- a/drivers/scsi/hpsa.h
>> +++ b/drivers/scsi/hpsa.h
>> @@ -34,7 +34,7 @@ struct access_method {
>>   };
>>   
>>   struct hpsa_scsi_dev_t {
>> -	int devtype;
>> +	unsigned int devtype;
>>   	int bus, target, lun;		/* as presented to the OS */
>>   	unsigned char scsi3addr[8];	/* as presented to the HW */
>>   #define RAID_CTLR_LUNID "\0\0\0\0\0\0\0\0"
>>
> That's not really a check for NULL, isn't it?
> Should rather be moved into an individual patch.
>
> Cheers,
>
> Hannes

Making the change.


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

* Re: [PATCH 1 21/25] hpsa: disable report lun data caching
  2015-10-28 22:06 ` [PATCH 1 21/25] hpsa: disable report lun data caching Don Brace
  2015-10-30  8:16   ` Hannes Reinecke
@ 2015-10-30 14:25   ` Tomas Henzl
  2015-10-30 21:18     ` Don Brace
  2015-10-30 16:27   ` Matthew R. Ochs
  2 siblings, 1 reply; 107+ messages in thread
From: Tomas Henzl @ 2015-10-30 14:25 UTC (permalink / raw)
  To: Don Brace, scott.teel, Kevin.Barnett, scott.benesh,
	james.bottomley, hch, Justin.Lindley, elliott
  Cc: linux-scsi

On 28.10.2015 23:06, Don Brace wrote:
> From: Scott Teel <scott.teel@pmcs.com>
>
> When external target arrays are present, disable the firmware's
> normal behavior of returning a cached copy of the report lun data,
> and force it to collect new data each time we request a report luns.
>
> This is necessary for external arrays, since there may be no
> reliable signal from the external array to the smart array when
> lun configuration changes, and thus when driver requests
> report luns, it may be stale data.
>
> Use diag options to turn off RPL data caching.
>
> Reviewed-by: Scott Teel <scott.teel@pmcs.com>
> Reviewed-by: Justin Lindley <justin.lindley@pmcs.com>
> Reviewed-by: Kevin Barnett <kevin.barnett@pmcs.com>
> Signed-off-by: Don Brace <don.brace@pmcs.com>
> ---
>  drivers/scsi/hpsa.c     |   86 +++++++++++++++++++++++++++++++++++++++++++++++
>  drivers/scsi/hpsa_cmd.h |    3 ++
>  2 files changed, 89 insertions(+)
>
> diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
> index e521acd..33fd0aa 100644
> --- a/drivers/scsi/hpsa.c
> +++ b/drivers/scsi/hpsa.c
> @@ -276,6 +276,7 @@ static int hpsa_scsi_ioaccel_queue_command(struct ctlr_info *h,
>  static void hpsa_command_resubmit_worker(struct work_struct *work);
>  static u32 lockup_detected(struct ctlr_info *h);
>  static int detect_controller_lockup(struct ctlr_info *h);
> +static void hpsa_disable_rld_caching(struct ctlr_info *h);
>  static int hpsa_luns_changed(struct ctlr_info *h);
>  
>  static inline struct ctlr_info *sdev_to_hba(struct scsi_device *sdev)
> @@ -6386,6 +6387,24 @@ static int fill_cmd(struct CommandList *c, u8 cmd, struct ctlr_info *h,
>  			c->Request.CDB[8] = (size >> 8) & 0xFF;
>  			c->Request.CDB[9] = size & 0xFF;
>  			break;
> +		case BMIC_SENSE_DIAG_OPTIONS:
> +			c->Request.CDBLen = 16;
> +			c->Request.type_attr_dir =
> +				TYPE_ATTR_DIR(cmd_type, ATTR_SIMPLE, XFER_READ);
> +			c->Request.Timeout = 0;
> +			/* Spec says this should be BMIC_WRITE */
> +			c->Request.CDB[0] = BMIC_READ;
> +			c->Request.CDB[6] = BMIC_SENSE_DIAG_OPTIONS;
> +			break;
> +		case BMIC_SET_DIAG_OPTIONS:
> +			c->Request.CDBLen = 16;
> +			c->Request.type_attr_dir =
> +					TYPE_ATTR_DIR(cmd_type,
> +						ATTR_SIMPLE, XFER_WRITE);
> +			c->Request.Timeout = 0;
> +			c->Request.CDB[0] = BMIC_WRITE;
> +			c->Request.CDB[6] = BMIC_SET_DIAG_OPTIONS;
> +			break;
>  		case HPSA_CACHE_FLUSH:
>  			c->Request.CDBLen = 12;
>  			c->Request.type_attr_dir =
> @@ -8086,6 +8105,7 @@ static void hpsa_rescan_ctlr_worker(struct work_struct *work)
>  		hpsa_scan_start(h->scsi_host);
>  		scsi_host_put(h->scsi_host);
>  	} else if (h->discovery_polling) {
> +		hpsa_disable_rld_caching(h);
>  		if (hpsa_luns_changed(h)) {
>  			struct Scsi_Host *sh = NULL;
>  
> @@ -8423,6 +8443,72 @@ out:
>  	kfree(flush_buf);
>  }
>  
> +/* Make controller gather fresh report lun data each time we
> + * send down a report luns request
> + */
> +static void hpsa_disable_rld_caching(struct ctlr_info *h)
> +{
> +	u32 *options;
> +	struct CommandList *c;
> +	int rc;
> +
> +	/* Don't bother trying to set diag options if locked up */
> +	if (unlikely(h->lockup_detected))
> +		return;
> +
> +	options = kzalloc(sizeof(*options), GFP_KERNEL);
> +	if (!options) {
> +		dev_err(&h->pdev->dev,
> +			"Error: failed to disable rld caching, during alloc.\n");
> +		return;
> +	}
> +
> +	c = cmd_alloc(h);
> +
> +	/* first, get the current diag options settings */
> +	if (fill_cmd(c, BMIC_SENSE_DIAG_OPTIONS, h, options, 4, 0,
> +		RAID_CTLR_LUNID, TYPE_CMD))
> +		goto errout;
> +
> +	rc = hpsa_scsi_do_simple_cmd_with_retry(h, c,
> +		PCI_DMA_FROMDEVICE, NO_TIMEOUT);
> +	if ((rc != 0) || (c->err_info->CommandStatus != 0))
> +		goto errout;
> +
> +	/* Now, set the bit for disabling the RLD caching */
> +	*options |= HPSA_DIAG_OPTS_DISABLE_RLD_CACHING;
> +
> +	if (fill_cmd(c, BMIC_SET_DIAG_OPTIONS, h, options, 4, 0,
> +		RAID_CTLR_LUNID, TYPE_CMD))
> +		goto errout;
> +
> +	rc = hpsa_scsi_do_simple_cmd_with_retry(h, c,
> +		PCI_DMA_TODEVICE, NO_TIMEOUT);
> +	if ((rc != 0)  || (c->err_info->CommandStatus != 0))
> +		goto errout;
> +
> +	/* Now verify that it got set: */
> +	if (fill_cmd(c, BMIC_SENSE_DIAG_OPTIONS, h, options, 4, 0,
> +		RAID_CTLR_LUNID, TYPE_CMD))
> +		goto errout;
> +
> +	rc = hpsa_scsi_do_simple_cmd_with_retry(h, c,
> +		PCI_DMA_FROMDEVICE, NO_TIMEOUT);
> +	if ((rc != 0)  || (c->err_info->CommandStatus != 0))
> +		goto errout;
> +
> +	if (*options && HPSA_DIAG_OPTS_DISABLE_RLD_CACHING)
> +		goto out;
> +	else {
> +errout:
> +		dev_err(&h->pdev->dev,
> +			"Error: failed to disable report lun data caching.\n");
> +	}
> +out:
> +	cmd_free(h, c);
> +	kfree(options);
> +}

The last if statement looks too complicated - what about :

+	if (*options && HPSA_DIAG_OPTS_DISABLE_RLD_CACHING)
		goto out;

+errout:
+	dev_err(&h->pdev->dev,
+		"Error: failed to disable report lun data caching.\n");
+out:
+	cmd_free(h, c);
+	kfree(options);
+}


> +
>  static void hpsa_shutdown(struct pci_dev *pdev)
>  {
>  	struct ctlr_info *h;
> diff --git a/drivers/scsi/hpsa_cmd.h b/drivers/scsi/hpsa_cmd.h
> index c83eaf1..4910344 100644
> --- a/drivers/scsi/hpsa_cmd.h
> +++ b/drivers/scsi/hpsa_cmd.h
> @@ -287,6 +287,9 @@ struct SenseSubsystem_info {
>  #define BMIC_SENSE_CONTROLLER_PARAMETERS 0x64
>  #define BMIC_IDENTIFY_PHYSICAL_DEVICE 0x15
>  #define BMIC_IDENTIFY_CONTROLLER 0x11
> +#define BMIC_SET_DIAG_OPTIONS 0xF4
> +#define BMIC_SENSE_DIAG_OPTIONS 0xF5
> +#define HPSA_DIAG_OPTS_DISABLE_RLD_CACHING 0x40000000
>  
>  /* Command List Structure */
>  union SCSI3Addr {
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html


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

* Re: [PATCH 1 22/25] hpsa: enhance device messages
  2015-10-28 22:06 ` [PATCH 1 22/25] hpsa: enhance device messages Don Brace
  2015-10-30  8:16   ` Hannes Reinecke
@ 2015-10-30 14:32   ` Tomas Henzl
  2015-11-02 16:54     ` Don Brace
  2015-10-30 16:53   ` Matthew R. Ochs
  2 siblings, 1 reply; 107+ messages in thread
From: Tomas Henzl @ 2015-10-30 14:32 UTC (permalink / raw)
  To: Don Brace, scott.teel, Kevin.Barnett, scott.benesh,
	james.bottomley, hch, Justin.Lindley, elliott
  Cc: linux-scsi

On 28.10.2015 23:06, Don Brace wrote:
> Reviewed-by: Justin Lindley <justin.lindley@pmcs.com>
> Reviewed-by: Scott Teel <scott.teel@pmcs.com>
> Reviewed-by: Kevin Barnett <kevin.barnett@pmcs.com>
> Signed-off-by: Don Brace <don.brace@pmcs.com>
> ---
>  drivers/scsi/hpsa.c |   45 ++++++++++++++++++++++++++++++++++++++++-----
>  1 file changed, 40 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
> index 33fd0aa..b2418c3 100644
> --- a/drivers/scsi/hpsa.c
> +++ b/drivers/scsi/hpsa.c
> @@ -609,7 +609,7 @@ static inline int is_logical_dev_addr_mode(unsigned char scsi3addr[])
>  }
>  
>  static const char * const raid_label[] = { "0", "4", "1(+0)", "5", "5+1", "6",
> -	"1(+0)ADM", "UNKNOWN"
> +	"1(+0)ADM", "UNKNOWN", "PHYS DRV"
>  };
>  #define HPSA_RAID_0	0
>  #define HPSA_RAID_4	1
> @@ -618,7 +618,8 @@ static const char * const raid_label[] = { "0", "4", "1(+0)", "5", "5+1", "6",
>  #define HPSA_RAID_51	4
>  #define HPSA_RAID_6	5	/* also used for RAID 60 */
>  #define HPSA_RAID_ADM	6	/* also used for RAID 1+0 ADM */
> -#define RAID_UNKNOWN (ARRAY_SIZE(raid_label) - 1)
> +#define RAID_UNKNOWN (ARRAY_SIZE(raid_label) - 2)
> +#define PHYSICAL_DRIVE (ARRAY_SIZE(raid_label) - 1)

RAID_UNKNOWN is used in few other places - raid_level_show for example,
shouldn't be that also adapted?

-tm

> /
>  
>  static inline bool is_logical_device(struct hpsa_scsi_dev_t *device)
>  {
> @@ -1144,21 +1145,55 @@ static int hpsa_find_target_lun(struct ctlr_info *h,
>  static void hpsa_show_dev_msg(const char *level, struct ctlr_info *h,
>  	struct hpsa_scsi_dev_t *dev, char *description)
>  {
> +#define LABEL_SIZE 25
> +	char label[LABEL_SIZE];
> +
>  	if (dev == NULL)
>  		return;
>  
>  	if (h == NULL || h->pdev == NULL || h->scsi_host == NULL)
>  		return;
>  
> +	switch (dev->devtype) {
> +	case TYPE_RAID:
> +		snprintf(label, LABEL_SIZE, "controller");
> +		break;
> +	case TYPE_ENCLOSURE:
> +		snprintf(label, LABEL_SIZE, "enclosure");
> +		break;
> +	case TYPE_DISK:
> +		if (dev->external)
> +			snprintf(label, LABEL_SIZE, "external");
> +		else if (!is_logical_dev_addr_mode(dev->scsi3addr))
> +			snprintf(label, LABEL_SIZE, "%s",
> +				raid_label[PHYSICAL_DRIVE]);
> +		else
> +			snprintf(label, LABEL_SIZE, "RAID-%s",
> +				dev->raid_level > RAID_UNKNOWN ? "?" :
> +				raid_label[dev->raid_level]);
> +		break;
> +	case TYPE_ROM:
> +		snprintf(label, LABEL_SIZE, "rom");
> +		break;
> +	case TYPE_TAPE:
> +		snprintf(label, LABEL_SIZE, "tape");
> +		break;
> +	case TYPE_MEDIUM_CHANGER:
> +		snprintf(label, LABEL_SIZE, "changer");
> +		break;
> +	default:
> +		snprintf(label, LABEL_SIZE, "UNKNOWN");
> +		break;
> +	}
> +
>  	dev_printk(level, &h->pdev->dev,
> -			"scsi %d:%d:%d:%d: %s %s %.8s %.16s RAID-%s SSDSmartPathCap%c En%c Exp=%d\n",
> +			"scsi %d:%d:%d:%d: %s %s %.8s %.16s %s SSDSmartPathCap%c En%c Exp=%d\n",
>  			h->scsi_host->host_no, dev->bus, dev->target, dev->lun,
>  			description,
>  			scsi_device_type(dev->devtype),
>  			dev->vendor,
>  			dev->model,
> -			dev->raid_level > RAID_UNKNOWN ?
> -				"RAID-?" : raid_label[dev->raid_level],
> +			label,
>  			dev->offload_config ? '+' : '-',
>  			dev->offload_enabled ? '+' : '-',
>  			dev->expose_device);
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html


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

* Re: [PATCH 1 23/25] hpsa: fix multiple issues in path_info_show
  2015-10-28 22:06 ` [PATCH 1 23/25] hpsa: fix multiple issues in path_info_show Don Brace
  2015-10-30  8:18   ` Hannes Reinecke
@ 2015-10-30 14:33   ` Tomas Henzl
  2015-10-30 17:07   ` Matthew R. Ochs
  2 siblings, 0 replies; 107+ messages in thread
From: Tomas Henzl @ 2015-10-30 14:33 UTC (permalink / raw)
  To: Don Brace, scott.teel, Kevin.Barnett, scott.benesh,
	james.bottomley, hch, Justin.Lindley, elliott
  Cc: linux-scsi

On 28.10.2015 23:06, Don Brace wrote:
> From: Rasmus Villemoes <linux@rasmusvillemoes.dk>
>
> path_info_show() seems to be broken in multiple ways.
>
> First, there's
>
>   817 return snprintf(buf, output_len+1, "%s%s%s%s%s%s%s%s",
>   818       path[0], path[1], path[2], path[3],
>   819       path[4], path[5], path[6], path[7]);
>
> so hopefully output_len contains the combined length of the eight
> strings. Otherwise, snprintf will stop copying to the output
> buffer, but still end up reporting that combined length - which
> in turn would result in user-space getting a bunch of useless nul
> bytes (thankfully the upper sysfs layer seems to clear the output
> buffer before passing it to the various ->show routines). But we have
>
>   767      output_len = snprintf(path[i],
>   768                       PATH_STRING_LEN, "[%d:%d:%d:%d] %20.20s ",
>   769                       h->scsi_host->host_no,
>   770                       hdev->bus, hdev->target, hdev->lun,
>   771                       scsi_device_type(hdev->devtype));
>
> so output_len at best contains the length of the last string printed.
>
> Inside the loop, we then otherwise add to output_len. By magic,
> we still have PATH_STRING_LEN available every time... This
> wouldn't really be a problem if the bean-counting has been done
> properly and each line actually does fit in 50 bytes, and maybe
> it does, but I don't immediately see why. Suppose we end up
> taking this branch:
>
>   802                  output_len += snprintf(path[i] + output_len,
>   803                          PATH_STRING_LEN,
>   804                          "BOX: %hhu BAY: %hhu %s\n",
>   805                          box, bay, active);
>
> An optimistic estimate says this uses strlen("BOX: 1 BAY: 2
> Active\n") which is 21. Now add the 20 bytes guaranteed by the
> %20.20s and then some for the rest of that format string, and
> we're easily over 50 bytes. I don't think we can get over 100
> bytes even being pessimistic, so this just means we'll scribble
> into the next path[i+1] and maybe get that overwritten later,
> leading to some garbled output (in fact, since we'd overwrite the
> previous string's 0-terminator, we could end up with one very
> long string and then print various suffixes of that, leading to
> much more than 400 bytes of output). Except of course when we're
> filling path[7], where overrunning it means writing random stuff
> to the kernel stack, which is usually a lot of fun.
>
> We can fix all of that and get rid of the 400 byte stack buffer by
> simply writing directly to the given output buffer, which the upper
> layer guarantees is at least PAGE_SIZE. s[c]nprintf doesn't care where
> it is writing to, so this doesn't make the spin lock hold time any
> longer. Using scnprintf ensures that output_len always represents the
> number of bytes actually written to the buffer, so we'll report the
> proper amount to the upper layer.
>
> Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>
> Signed-off-by: Don Brace <don.brace@pmcs.com>

Reviewed-by: Tomas Henzl <thenzl@redhat.com>

Tomas


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

* Re: [PATCH 1 24/25] hpsa: add in sas transport class
  2015-10-28 22:06 ` [PATCH 1 24/25] hpsa: add in sas transport class Don Brace
  2015-10-30  8:21   ` Hannes Reinecke
@ 2015-10-30 14:40   ` Tomas Henzl
  2015-10-30 20:07   ` Matthew R. Ochs
  2015-11-03  0:40   ` kbuild test robot
  3 siblings, 0 replies; 107+ messages in thread
From: Tomas Henzl @ 2015-10-30 14:40 UTC (permalink / raw)
  To: Don Brace, scott.teel, Kevin.Barnett, scott.benesh,
	james.bottomley, hch, Justin.Lindley, elliott
  Cc: linux-scsi

On 28.10.2015 23:06, Don Brace wrote:
> From: Kevin Barnett <kevin.barnett@pmcs.com>
>
> Reviewed-by: Scott Teel <scott.teel@pmcs.com>
> Reviewed-by: Justin Lindley <justin.lindley@pmcs.com>
> Reviewed-by: Kevin Barnett <kevin.barnett@pmcs.com>
> Signed-off-by: Don Brace <don.brace@pmcs.com>

Reviewed-by: Tomas Henzl <thenzl@redhat.com>

Tomas


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

* Re: [PATCH 1 25/25] hpsa: bump the driver version
  2015-10-28 22:07 ` [PATCH 1 25/25] hpsa: bump the driver version Don Brace
  2015-10-30  8:22   ` Hannes Reinecke
@ 2015-10-30 14:44   ` Tomas Henzl
  2015-10-30 20:08   ` Matthew R. Ochs
  2 siblings, 0 replies; 107+ messages in thread
From: Tomas Henzl @ 2015-10-30 14:44 UTC (permalink / raw)
  To: Don Brace, scott.teel, Kevin.Barnett, scott.benesh,
	james.bottomley, hch, Justin.Lindley, elliott
  Cc: linux-scsi

On 28.10.2015 23:07, Don Brace wrote:
> Reviewed-by: Justin Lindley <justin.lindley@pmcs.com>
> Reviewed-by: Scott Teel <scott.teel@pmcs.com>
> Reviewed-by: Kevin Barnett <kevin.barnett@pmcs.com>
> Reviewed-by: Gerry Morong <gerry.morong.pmcs.com>
> Signed-off-by: Don Brace <don.brace@pmcs.com>
> ---
>  drivers/scsi/hpsa.c |    2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
> index ca38a00..1b43157 100644
> --- a/drivers/scsi/hpsa.c
> +++ b/drivers/scsi/hpsa.c
> @@ -56,7 +56,7 @@
>  #include "hpsa.h"
>  
>  /* HPSA_DRIVER_VERSION must be 3 byte values (0-255) separated by '.' */

Is the description^ still valid ?

Reviewed-by: Tomas Henzl <thenzl@redhat.com>

Tomas

> -#define HPSA_DRIVER_VERSION "3.4.10-0"
> +#define HPSA_DRIVER_VERSION "3.4.14-0"
>  #define DRIVER_NAME "HP HPSA Driver (v " HPSA_DRIVER_VERSION ")"
>  #define HPSA "hpsa"
>  
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html


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

* Re: [PATCH 1 17/25] hpsa: move scsi_add_device and scsi_remove_device calls to new function
  2015-10-29 20:30     ` Don Brace
@ 2015-10-30 15:56       ` Matthew R. Ochs
  0 siblings, 0 replies; 107+ messages in thread
From: Matthew R. Ochs @ 2015-10-30 15:56 UTC (permalink / raw)
  To: Don Brace
  Cc: scott.teel, Kevin.Barnett, scott.benesh, james.bottomley, hch,
	Justin.Lindley, elliott, linux-scsi

> On Oct 29, 2015, at 3:30 PM, Don Brace <brace77070@gmail.com> wrote:
> 
> On 10/29/2015 12:21 PM, Matthew R. Ochs wrote:
>>> On Oct 28, 2015, at 5:06 PM, Don Brace <don.brace@pmcs.com> wrote:
>>> 
>>> From: Kevin Barnett <kevin.barnett@pmcs.com>
>>> 
>>> preparation for adding the sas transport class
>>> 
>>> Reviewed-by: Scott Teel <scott.teel@pmcs.com>
>>> Reviewed-by: Justin Lindley <justin.lindley@pmcs.com>
>>> Reviewed-by: Kevin Barnett <kevin.barnett@pmcs.com>
>>> Signed-off-by: Don Brace <don.brace@pmcs.com>
>>> ---
>>> drivers/scsi/hpsa.c |   65 +++++++++++++++++++++++++++++++--------------------
>>> 1 file changed, 39 insertions(+), 26 deletions(-)
>>> 
>>> diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
>>> index 24b3c8c..06207e2 100644
>>> --- a/drivers/scsi/hpsa.c
>>> +++ b/drivers/scsi/hpsa.c
>>> @@ -1660,6 +1660,37 @@ static void hpsa_update_log_drive_phys_drive_ptrs(struct ctlr_info *h,
>>> 	}
>>> }
>>> 
>>> +static int hpsa_add_device(struct ctlr_info *h, struct hpsa_scsi_dev_t *device)
>>> +{
>>> +	int rc = 0;
>>> +
>>> +	rc = scsi_add_device(h->scsi_host, device->bus,
>>> +					device->target, device->lun);
>>> +	return rc;
>>> +}
>>> +
>>> +static void hpsa_remove_device(struct ctlr_info *h,
>>> +			struct hpsa_scsi_dev_t *device)
>>> +{
>>> +	struct scsi_device *sdev = NULL;
>>> +
>>> +	sdev = scsi_device_lookup(h->scsi_host, device->bus,
>>> +						device->target, device->lun);
>>> +
>>> +	if (sdev) {
>>> +		scsi_remove_device(sdev);
>>> +		scsi_device_put(sdev);
>>> +	} else {
>>> +		/*
>>> +		 * We don't expect to get here.  Future commands
>>> +		 * to this device will get a selection timeout as
>>> +		 * if the device were gone.
>>> +		 */
>>> +		hpsa_show_dev_msg(KERN_WARNING, h, device,
>>> +					"didn't find device for removal.");
>>> +	}
>>> +}
>>> +
>>> static void adjust_hpsa_scsi_table(struct ctlr_info *h, int hostno,
>>> 	struct hpsa_scsi_dev_t *sd[], int nsds)
>>> {
>>> @@ -1672,7 +1703,6 @@ static void adjust_hpsa_scsi_table(struct ctlr_info *h, int hostno,
>>> 	unsigned long flags;
>>> 	struct hpsa_scsi_dev_t **added, **removed;
>>> 	int nadded, nremoved;
>>> -	struct Scsi_Host *sh = NULL;
>>> 
>>> 	/*
>>> 	 * A reset can cause a device status to change
>>> @@ -1792,46 +1822,29 @@ static void adjust_hpsa_scsi_table(struct ctlr_info *h, int hostno,
>>> 	if (hostno == -1 || !changes)
>>> 		goto free_and_out;
>>> 
>>> -	sh = h->scsi_host;
>>> -	if (sh == NULL) {
>>> -		dev_warn(&h->pdev->dev, "%s: scsi_host is null\n", __func__);
>>> -		return;
>>> -	}
>> Are we guaranteed that h->scsi_host will never be NULL when running in here? Or when
>> the newly introduced hpsa_remove_device() is invoked elsewhere for that matter?
>> 
>> This commit loses this check and scsi_device_lookup() is not tolerant of a NULL
>> scsi_host * (first action is to grab the host_lock).
> Better to be safe. I'll add a check in both functions.

With these changes

Reviewed-by: Matthew R. Ochs <mrochs@linux.vnet.ibm.com>


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

* Re: [PATCH 1 20/25] hpsa: add discovery polling for PT RAID devices.
  2015-10-30 14:08         ` Don Brace
@ 2015-10-30 15:58           ` Matthew R. Ochs
  0 siblings, 0 replies; 107+ messages in thread
From: Matthew R. Ochs @ 2015-10-30 15:58 UTC (permalink / raw)
  To: Don Brace
  Cc: scott.teel, Kevin.Barnett, scott.benesh, james.bottomley, hch,
	Justin.Lindley, elliott, linux-scsi

> On Oct 30, 2015, at 9:08 AM, Don Brace <brace77070@gmail.com> wrote:
> 
> On 10/29/2015 03:59 PM, Matthew R. Ochs wrote:
>>> On Oct 29, 2015, at 3:51 PM, Don Brace <brace77070@gmail.com> wrote:
>>> On 10/29/2015 03:20 PM, Matthew R. Ochs wrote:
>>>>> On Oct 28, 2015, at 5:06 PM, Don Brace <don.brace@pmcs.com>
>>>>>  wrote:
>>>>> 
>>>>> From: Scott Teel
>>>>> <scott.teel@pmcs.com>
>>>>> 
>>>>> 
>>>>> There are problems with getting configuration change notification
>>>>> in pass-through RAID environments.  So, activate flag
>>>>> h->discovery_polling when one of these devices is detected in
>>>>> update_scsi_devices.
>>>>> 
>>>>> After discovery_polling is set, execute a report luns from
>>>>> rescan_controller_worker (every 30 seconds).
>>>>> 
>>>>> If the data from report_luns is different than last
>>>>> time (binary compare), execute a full rescan via update_scsi_devices.
>>>>> 
>>>>> Reviewed-by: Scott Teel
>>>>> <scott.teel@pmcs.com>
>>>>> 
>>>>> Reviewed-by: Justin Lindley
>>>>> <justin.lindley@pmcs.com>
>>>>> 
>>>>> Reviewed-by: Kevin Barnett
>>>>> <kevin.barnett@pmcs.com>
>>>>> 
>>>>> Signed-off-by: Don Brace
>>>>> <don.brace@pmcs.com>
>>>>> 
>>>>> ---
>>>>> drivers/scsi/hpsa.c |   68 +++++++++++++++++++++++++++++++++++++++++++++++++++
>>>>> drivers/scsi/hpsa.h |    2 ++
>>>>> 2 files changed, 70 insertions(+)
>>>>> 
>>>>> diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
>>>>> index 8d67648..e521acd 100644
>>>>> --- a/drivers/scsi/hpsa.c
>>>>> +++ b/drivers/scsi/hpsa.c
>>>>> @@ -276,6 +276,7 @@ static int hpsa_scsi_ioaccel_queue_command(struct ctlr_info *h,
>>>>> static void hpsa_command_resubmit_worker(struct work_struct *work);
>>>>> static u32 lockup_detected(struct ctlr_info *h);
>>>>> static int detect_controller_lockup(struct ctlr_info *h);
>>>>> +static int hpsa_luns_changed(struct ctlr_info *h);
>>>>> 
>>>>> static inline struct ctlr_info *sdev_to_hba(struct scsi_device *sdev)
>>>>> {
>>>>> @@ -3904,6 +3905,18 @@ static void hpsa_update_scsi_devices(struct ctlr_info *h, int hostno)
>>>>> 		hpsa_update_device_supports_aborts(h, tmpdevice, lunaddrbytes);
>>>>> 		this_device = currentsd[ncurrent];
>>>>> 
>>>>> +		/* Turn on discovery_polling if there are ext target devices.
>>>>> +		 * Event-based change notification is unreliable for those.
>>>>> +		 */
>>>>> +		if (!h->discovery_polling) {
>>>>> +			if (tmpdevice->external) {
>>>>> +				h->discovery_polling = 1;
>>>>> +				dev_info(&h->pdev->dev,
>>>>> +					"External target, activate discovery polling.\n");
>>>>> +			}
>>>>> +		}
>>>>> +
>>>>> +
>>>>> 		*this_device = *tmpdevice;
>>>>> 		this_device->physical_device = physical_device;
>>>>> 
>>>>> @@ -8022,6 +8035,41 @@ static int hpsa_offline_devices_ready(struct ctlr_info *h)
>>>>> 	return 0;
>>>>> }
>>>>> 
>>>>> +static int hpsa_luns_changed(struct ctlr_info *h)
>>>>> +{
>>>>> +	int rc = 1; /* assume there are changes */
>>>>> +	struct ReportLUNdata *logdev = NULL;
>>>>> +
>>>>> +	/* if we can't find out if lun data has changed,
>>>>> +	 * assume that it has.
>>>>> +	 */
>>>>> +
>>>>> +	if (!h->lastlogicals)
>>>>> +		goto out;
>>>>> +
>>>>> +	logdev = kzalloc(sizeof(*logdev), GFP_KERNEL);
>>>>> +	if (!logdev) {
>>>>> +		dev_warn(&h->pdev->dev,
>>>>> +			"Out of memory, can't track lun changes.\n");
>>>>> +		goto out;
>>>>> +	}
>>>>> +	if (hpsa_scsi_do_report_luns(h, 1, logdev, sizeof(*logdev), 0)) {
>>>>> +		dev_warn(&h->pdev->dev,
>>>>> +			"report luns failed, can't track lun changes.\n");
>>>>> +		goto out;
>>>>> +	}
>>>>> +	if (memcmp(logdev, h->lastlogicals, sizeof(*logdev))) {
>>>>> +		dev_info(&h->pdev->dev,
>>>>> +			"Lun changes detected.\n");
>>>>> +		memcpy(h->lastlogicals, logdev, sizeof(*logdev));
>>>>> +		goto out;
>>>>> +	} else
>>>>> +		rc = 0; /* no changes detected. */
>>>>> +out:
>>>>> +	kfree(logdev);
>>>>> +	return rc;
>>>>> +}
>>>>> +
>>>>> static void hpsa_rescan_ctlr_worker(struct work_struct *work)
>>>>> {
>>>>> 	unsigned long flags;
>>>>> @@ -8037,6 +8085,18 @@ static void hpsa_rescan_ctlr_worker(struct work_struct *work)
>>>>> 		hpsa_ack_ctlr_events(h);
>>>>> 		hpsa_scan_start(h->scsi_host);
>>>>> 		scsi_host_put(h->scsi_host);
>>>>> +	} else if (h->discovery_polling) {
>>>>> +		if (hpsa_luns_changed(h)) {
>>>>> +			struct Scsi_Host *sh = NULL;
>>>>> +
>>>>> +			dev_info(&h->pdev->dev,
>>>>> +				"driver discovery polling rescan.\n");
>>>>> +			sh = scsi_host_get(h->scsi_host);
>>>>> +			if (sh != NULL) {
>>>>> +				hpsa_scan_start(sh);
>>>>> +				scsi_host_put(sh);
>>>>> +			}
>>>>> +		}
>>>>> 	}
>>>>> 	spin_lock_irqsave(&h->lock, flags);
>>>>> 	if (!h->remove_in_progress)
>>>>> @@ -8277,6 +8337,8 @@ reinit_after_soft_reset:
>>>>> 
>>>>> 	/* Enable Accelerated IO path at driver layer */
>>>>> 	h->acciopath_status = 1;
>>>>> +	/* Disable discovery polling.*/
>>>>> +	h->discovery_polling = 0;
>>>>> 
>>>>> 
>>>>> 	/* Turn the interrupts on so we can service requests */
>>>>> @@ -8284,6 +8346,11 @@ reinit_after_soft_reset:
>>>>> 
>>>>> 	hpsa_hba_inquiry(h);
>>>>> 
>>>>> +	h->lastlogicals = kzalloc(sizeof(*(h->lastlogicals)), GFP_KERNEL);
>>>>> +	if (!h->lastlogicals)
>>>>> +		dev_info(&h->pdev->dev,
>>>>> +			"Can't track change to report lun data\n");
>>>>> +
>>>>> 	/* Monitor the controller for firmware lockups */
>>>>> 	h->heartbeat_sample_interval = HEARTBEAT_SAMPLE_INTERVAL;
>>>>> 	INIT_DELAYED_WORK(&h->monitor_ctlr_work, hpsa_monitor_ctlr_worker);
>>>>> @@ -8368,6 +8435,7 @@ static void hpsa_shutdown(struct pci_dev *pdev)
>>>>> 	hpsa_flush_cache(h);
>>>>> 	h->access.set_intr_mask(h, HPSA_INTR_OFF);
>>>>> 	hpsa_free_irqs(h);			/* init_one 4 */
>>>>> +	kfree(h->lastlogicals);
>>>>> 
>>>> Is this the best place to free this memory? If your rescan worker is running
>>>> concurrently you might run into trouble.
>>>> 
>>> Since hpsa_shutdown is called from hpsa_remove_one, at a point after
>>> cancel_delayed_work_sync(&h->rescan_ctlr_work) has already been called,
>>> I  think that the rescan worker won’t be running at this point.
>> My concern wasn't about the remove path but rather the shutdown notification path.
>> ]
> You are correct. I moved this to hpsa_remove_one.

With this change

Reviewed-by: Matthew R. Ochs <mrochs@linux.vnet.ibm.com>

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH 1 21/25] hpsa: disable report lun data caching
  2015-10-28 22:06 ` [PATCH 1 21/25] hpsa: disable report lun data caching Don Brace
  2015-10-30  8:16   ` Hannes Reinecke
  2015-10-30 14:25   ` Tomas Henzl
@ 2015-10-30 16:27   ` Matthew R. Ochs
  2 siblings, 0 replies; 107+ messages in thread
From: Matthew R. Ochs @ 2015-10-30 16:27 UTC (permalink / raw)
  To: Don Brace
  Cc: scott.teel, Kevin.Barnett, scott.benesh, james.bottomley, hch,
	Justin.Lindley, elliott, linux-scsi


> On Oct 28, 2015, at 5:06 PM, Don Brace <don.brace@pmcs.com> wrote:
> 
> From: Scott Teel <scott.teel@pmcs.com>
> 
> When external target arrays are present, disable the firmware's
> normal behavior of returning a cached copy of the report lun data,
> and force it to collect new data each time we request a report luns.
> 
> This is necessary for external arrays, since there may be no
> reliable signal from the external array to the smart array when
> lun configuration changes, and thus when driver requests
> report luns, it may be stale data.
> 
> Use diag options to turn off RPL data caching.
> 
> Reviewed-by: Scott Teel <scott.teel@pmcs.com>
> Reviewed-by: Justin Lindley <justin.lindley@pmcs.com>
> Reviewed-by: Kevin Barnett <kevin.barnett@pmcs.com>
> Signed-off-by: Don Brace <don.brace@pmcs.com>
> ---
> drivers/scsi/hpsa.c     |   86 +++++++++++++++++++++++++++++++++++++++++++++++
> drivers/scsi/hpsa_cmd.h |    3 ++
> 2 files changed, 89 insertions(+)
> 
> diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
> index e521acd..33fd0aa 100644
> --- a/drivers/scsi/hpsa.c
> +++ b/drivers/scsi/hpsa.c
> @@ -276,6 +276,7 @@ static int hpsa_scsi_ioaccel_queue_command(struct ctlr_info *h,
> static void hpsa_command_resubmit_worker(struct work_struct *work);
> static u32 lockup_detected(struct ctlr_info *h);
> static int detect_controller_lockup(struct ctlr_info *h);
> +static void hpsa_disable_rld_caching(struct ctlr_info *h);
> static int hpsa_luns_changed(struct ctlr_info *h);
> 
> static inline struct ctlr_info *sdev_to_hba(struct scsi_device *sdev)
> @@ -6386,6 +6387,24 @@ static int fill_cmd(struct CommandList *c, u8 cmd, struct ctlr_info *h,
> 			c->Request.CDB[8] = (size >> 8) & 0xFF;
> 			c->Request.CDB[9] = size & 0xFF;
> 			break;
> +		case BMIC_SENSE_DIAG_OPTIONS:
> +			c->Request.CDBLen = 16;
> +			c->Request.type_attr_dir =
> +				TYPE_ATTR_DIR(cmd_type, ATTR_SIMPLE, XFER_READ);
> +			c->Request.Timeout = 0;
> +			/* Spec says this should be BMIC_WRITE */
> +			c->Request.CDB[0] = BMIC_READ;
> +			c->Request.CDB[6] = BMIC_SENSE_DIAG_OPTIONS;
> +			break;
> +		case BMIC_SET_DIAG_OPTIONS:
> +			c->Request.CDBLen = 16;
> +			c->Request.type_attr_dir =
> +					TYPE_ATTR_DIR(cmd_type,
> +						ATTR_SIMPLE, XFER_WRITE);
> +			c->Request.Timeout = 0;
> +			c->Request.CDB[0] = BMIC_WRITE;
> +			c->Request.CDB[6] = BMIC_SET_DIAG_OPTIONS;
> +			break;
> 		case HPSA_CACHE_FLUSH:
> 			c->Request.CDBLen = 12;
> 			c->Request.type_attr_dir =
> @@ -8086,6 +8105,7 @@ static void hpsa_rescan_ctlr_worker(struct work_struct *work)
> 		hpsa_scan_start(h->scsi_host);
> 		scsi_host_put(h->scsi_host);
> 	} else if (h->discovery_polling) {
> +		hpsa_disable_rld_caching(h);
> 		if (hpsa_luns_changed(h)) {
> 			struct Scsi_Host *sh = NULL;
> 
> @@ -8423,6 +8443,72 @@ out:
> 	kfree(flush_buf);
> }
> 
> +/* Make controller gather fresh report lun data each time we
> + * send down a report luns request
> + */
> +static void hpsa_disable_rld_caching(struct ctlr_info *h)
> +{
> +	u32 *options;
> +	struct CommandList *c;
> +	int rc;
> +
> +	/* Don't bother trying to set diag options if locked up */
> +	if (unlikely(h->lockup_detected))
> +		return;
> +
> +	options = kzalloc(sizeof(*options), GFP_KERNEL);
> +	if (!options) {
> +		dev_err(&h->pdev->dev,
> +			"Error: failed to disable rld caching, during alloc.\n");
> +		return;
> +	}
> +
> +	c = cmd_alloc(h);
> +
> +	/* first, get the current diag options settings */
> +	if (fill_cmd(c, BMIC_SENSE_DIAG_OPTIONS, h, options, 4, 0,
> +		RAID_CTLR_LUNID, TYPE_CMD))
> +		goto errout;
> +
> +	rc = hpsa_scsi_do_simple_cmd_with_retry(h, c,
> +		PCI_DMA_FROMDEVICE, NO_TIMEOUT);
> +	if ((rc != 0) || (c->err_info->CommandStatus != 0))
> +		goto errout;
> +
> +	/* Now, set the bit for disabling the RLD caching */
> +	*options |= HPSA_DIAG_OPTS_DISABLE_RLD_CACHING;
> +
> +	if (fill_cmd(c, BMIC_SET_DIAG_OPTIONS, h, options, 4, 0,
> +		RAID_CTLR_LUNID, TYPE_CMD))
> +		goto errout;
> +
> +	rc = hpsa_scsi_do_simple_cmd_with_retry(h, c,
> +		PCI_DMA_TODEVICE, NO_TIMEOUT);
> +	if ((rc != 0)  || (c->err_info->CommandStatus != 0))
> +		goto errout;
> +
> +	/* Now verify that it got set: */
> +	if (fill_cmd(c, BMIC_SENSE_DIAG_OPTIONS, h, options, 4, 0,
> +		RAID_CTLR_LUNID, TYPE_CMD))
> +		goto errout;
> +
> +	rc = hpsa_scsi_do_simple_cmd_with_retry(h, c,
> +		PCI_DMA_FROMDEVICE, NO_TIMEOUT);
> +	if ((rc != 0)  || (c->err_info->CommandStatus != 0))
> +		goto errout;
> +
> +	if (*options && HPSA_DIAG_OPTS_DISABLE_RLD_CACHING)
> +		goto out;
> +	else {
> +errout:
> +		dev_err(&h->pdev->dev,
> +			"Error: failed to disable report lun data caching.\n");
> +	}

I agree with the simplification suggested by Tomas Henzl.

Reviewed-by: Matthew R. Ochs <mrochs@linux.vnet.ibm.com>

> +out:
> +	cmd_free(h, c);
> +	kfree(options);
> +}
> +
> static void hpsa_shutdown(struct pci_dev *pdev)
> {
> 	struct ctlr_info *h;
> diff --git a/drivers/scsi/hpsa_cmd.h b/drivers/scsi/hpsa_cmd.h
> index c83eaf1..4910344 100644
> --- a/drivers/scsi/hpsa_cmd.h
> +++ b/drivers/scsi/hpsa_cmd.h
> @@ -287,6 +287,9 @@ struct SenseSubsystem_info {
> #define BMIC_SENSE_CONTROLLER_PARAMETERS 0x64
> #define BMIC_IDENTIFY_PHYSICAL_DEVICE 0x15
> #define BMIC_IDENTIFY_CONTROLLER 0x11
> +#define BMIC_SET_DIAG_OPTIONS 0xF4
> +#define BMIC_SENSE_DIAG_OPTIONS 0xF5
> +#define HPSA_DIAG_OPTS_DISABLE_RLD_CACHING 0x40000000
> 
> /* Command List Structure */
> union SCSI3Addr {
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 


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

* Re: [PATCH 1 22/25] hpsa: enhance device messages
  2015-10-28 22:06 ` [PATCH 1 22/25] hpsa: enhance device messages Don Brace
  2015-10-30  8:16   ` Hannes Reinecke
  2015-10-30 14:32   ` Tomas Henzl
@ 2015-10-30 16:53   ` Matthew R. Ochs
  2 siblings, 0 replies; 107+ messages in thread
From: Matthew R. Ochs @ 2015-10-30 16:53 UTC (permalink / raw)
  To: Don Brace
  Cc: scott.teel, Kevin.Barnett, scott.benesh, james.bottomley, hch,
	Justin.Lindley, elliott, linux-scsi

Reviewed-by: Matthew R. Ochs <mrochs@linux.vnet.ibm.com>


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

* Re: [PATCH 1 23/25] hpsa: fix multiple issues in path_info_show
  2015-10-28 22:06 ` [PATCH 1 23/25] hpsa: fix multiple issues in path_info_show Don Brace
  2015-10-30  8:18   ` Hannes Reinecke
  2015-10-30 14:33   ` Tomas Henzl
@ 2015-10-30 17:07   ` Matthew R. Ochs
  2 siblings, 0 replies; 107+ messages in thread
From: Matthew R. Ochs @ 2015-10-30 17:07 UTC (permalink / raw)
  To: Don Brace
  Cc: scott.teel, Kevin.Barnett, scott.benesh, james.bottomley, hch,
	Justin.Lindley, elliott, linux-scsi

Reviewed-by: Matthew R. Ochs <mrochs@linux.vnet.ibm.com>


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

* Re: [PATCH 1 24/25] hpsa: add in sas transport class
  2015-10-28 22:06 ` [PATCH 1 24/25] hpsa: add in sas transport class Don Brace
  2015-10-30  8:21   ` Hannes Reinecke
  2015-10-30 14:40   ` Tomas Henzl
@ 2015-10-30 20:07   ` Matthew R. Ochs
  2015-10-30 22:00     ` Don Brace
  2015-11-03  0:40   ` kbuild test robot
  3 siblings, 1 reply; 107+ messages in thread
From: Matthew R. Ochs @ 2015-10-30 20:07 UTC (permalink / raw)
  To: Don Brace
  Cc: scott.teel, Kevin.Barnett, scott.benesh, james.bottomley, hch,
	Justin.Lindley, elliott, linux-scsi


> On Oct 28, 2015, at 5:06 PM, Don Brace <don.brace@pmcs.com> wrote:
> 
> From: Kevin Barnett <kevin.barnett@pmcs.com>
> 
> Reviewed-by: Scott Teel <scott.teel@pmcs.com>
> Reviewed-by: Justin Lindley <justin.lindley@pmcs.com>
> Reviewed-by: Kevin Barnett <kevin.barnett@pmcs.com>
> Signed-off-by: Don Brace <don.brace@pmcs.com>
> ---
> drivers/scsi/hpsa.c     |  535 +++++++++++++++++++++++++++++++++++++++++++++--
> drivers/scsi/hpsa.h     |   27 ++
> drivers/scsi/hpsa_cmd.h |   14 +
> 3 files changed, 555 insertions(+), 21 deletions(-)
> 
> diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
> index 56526312..ca38a00 100644
> --- a/drivers/scsi/hpsa.c
> +++ b/drivers/scsi/hpsa.c
> @@ -41,6 +41,7 @@
> #include <scsi/scsi_host.h>
> #include <scsi/scsi_tcq.h>
> #include <scsi/scsi_eh.h>
> +#include <scsi/scsi_transport_sas.h>
> #include <scsi/scsi_dbg.h>
> #include <linux/cciss_ioctl.h>
> #include <linux/string.h>
> @@ -205,6 +206,16 @@ static struct board_type products[] = {
> 	{0xFFFF103C, "Unknown Smart Array", &SA5_access},
> };
> 
> +static struct scsi_transport_template *hpsa_sas_transport_template;
> +static int hpsa_add_sas_host(struct ctlr_info *h);
> +static void hpsa_delete_sas_host(struct ctlr_info *h);
> +static int hpsa_add_sas_device(struct hpsa_sas_node *hpsa_sas_node,
> +			struct hpsa_scsi_dev_t *device);
> +static void hpsa_remove_sas_device(struct hpsa_scsi_dev_t *device);
> +static struct hpsa_scsi_dev_t
> +	*hpsa_find_device_by_sas_rphy(struct ctlr_info *h,
> +		struct sas_rphy *rphy);
> +
> #define SCSI_CMD_BUSY ((struct scsi_cmnd *)&hpsa_cmd_busy)
> static const struct scsi_cmnd hpsa_cmd_busy;
> #define SCSI_CMD_IDLE ((struct scsi_cmnd *)&hpsa_cmd_idle)
> @@ -277,6 +288,8 @@ static void hpsa_command_resubmit_worker(struct work_struct *work);
> static u32 lockup_detected(struct ctlr_info *h);
> static int detect_controller_lockup(struct ctlr_info *h);
> static void hpsa_disable_rld_caching(struct ctlr_info *h);
> +static inline int hpsa_scsi_do_report_phys_luns(struct ctlr_info *h,
> +	struct ReportExtendedLUNdata *buf, int bufsize);
> static int hpsa_luns_changed(struct ctlr_info *h);
> 
> static inline struct ctlr_info *sdev_to_hba(struct scsi_device *sdev)
> @@ -1696,8 +1709,12 @@ static int hpsa_add_device(struct ctlr_info *h, struct hpsa_scsi_dev_t *device)
> {
> 	int rc = 0;
> 
> -	rc = scsi_add_device(h->scsi_host, device->bus,
> +	if (is_logical_device(device)) /* RAID */
> +		rc = scsi_add_device(h->scsi_host, device->bus,
> 					device->target, device->lun);
> +	else /* HBA */
> +		rc = hpsa_add_sas_device(h->sas_host, device);
> +
> 	return rc;
> }
> 
> @@ -1706,21 +1723,23 @@ static void hpsa_remove_device(struct ctlr_info *h,
> {
> 	struct scsi_device *sdev = NULL;
> 
> -	sdev = scsi_device_lookup(h->scsi_host, device->bus,
> +	if (is_logical_device(device)) { /* RAID */
> +		sdev = scsi_device_lookup(h->scsi_host, device->bus,
> 						device->target, device->lun);
> -
> -	if (sdev) {
> -		scsi_remove_device(sdev);
> -		scsi_device_put(sdev);
> -	} else {
> -		/*
> -		 * We don't expect to get here.  Future commands
> -		 * to this device will get a selection timeout as
> -		 * if the device were gone.
> -		 */
> -		hpsa_show_dev_msg(KERN_WARNING, h, device,
> +		if (sdev) {
> +			scsi_remove_device(sdev);
> +			scsi_device_put(sdev);
> +		} else {
> +			/*
> +			 * We don't expect to get here.  Future commands
> +			 * to this device will get a selection timeout as
> +			 * if the device were gone.
> +			 */
> +			hpsa_show_dev_msg(KERN_WARNING, h, device,
> 					"didn't find device for removal.");
> -	}
> +		}
> +	} else /* HBA */
> +		hpsa_remove_sas_device(device);
> }
> 
> static void adjust_hpsa_scsi_table(struct ctlr_info *h, int hostno,
> @@ -1915,11 +1934,24 @@ static int hpsa_slave_alloc(struct scsi_device *sdev)
> 
> 	h = sdev_to_hba(sdev);
> 	spin_lock_irqsave(&h->devlock, flags);
> -	sd = lookup_hpsa_scsi_dev(h, sdev_channel(sdev),
> -		sdev_id(sdev), sdev->lun);
> -	if (likely(sd)) {
> +	if (sdev_channel(sdev) == HPSA_PHYSICAL_DEVICE_BUS) {
> +		struct scsi_target *starget;
> +		struct sas_rphy *rphy;
> +
> +		starget = scsi_target(sdev);
> +		rphy = target_to_rphy(starget);
> +		sd = hpsa_find_device_by_sas_rphy(h, rphy);
> +		if (sd) {
> +			sd->target = sdev_id(sdev);
> +			sd->lun = sdev->lun;
> +		}
> +	} else
> +		sd = lookup_hpsa_scsi_dev(h, sdev_channel(sdev),
> +					sdev_id(sdev), sdev->lun);
> +
> +	if (sd && sd->expose_device) {
> 		atomic_set(&sd->ioaccel_cmds_out, 0);
> -		sdev->hostdata = sd->expose_device ? sd : NULL;
> +		sdev->hostdata = sd;
> 	} else
> 		sdev->hostdata = NULL;
> 	spin_unlock_irqrestore(&h->devlock, flags);
> @@ -3069,6 +3101,38 @@ out:
> 	return rc;
> }
> 
> +static int hpsa_bmic_sense_subsystem_information(struct ctlr_info *h,
> +		unsigned char scsi3addr[], u16 bmic_device_index,
> +		struct bmic_sense_subsystem_info *buf, size_t bufsize)
> +{
> +	int rc = IO_OK;
> +	struct CommandList *c;
> +	struct ErrorInfo *ei;
> +
> +	c = cmd_alloc(h);
> +
> +	rc = fill_cmd(c, BMIC_SENSE_SUBSYSTEM_INFORMATION, h, buf, bufsize,
> +		0, RAID_CTLR_LUNID, TYPE_CMD);
> +	if (rc)
> +		goto out;
> +
> +	c->Request.CDB[2] = bmic_device_index & 0xff;
> +	c->Request.CDB[9] = (bmic_device_index >> 8) & 0xff;
> +
> +	rc = hpsa_scsi_do_simple_cmd_with_retry(h, c,
> +				PCI_DMA_FROMDEVICE, NO_TIMEOUT);
> +	if (rc)
> +		goto out;
> +	ei = c->err_info;
> +	if (ei->CommandStatus != 0 && ei->CommandStatus != CMD_DATA_UNDERRUN) {
> +		hpsa_scsi_interpret_error(h, c);
> +		rc = -1;
> +	}
> +out:
> +	cmd_free(h, c);
> +	return rc;
> +}
> +
> static int hpsa_bmic_id_controller(struct ctlr_info *h,
> 	struct bmic_identify_controller *buf, size_t bufsize)
> {
> @@ -3097,7 +3161,6 @@ out:
> 	return rc;
> }
> 
> -
> static int hpsa_bmic_id_physical_device(struct ctlr_info *h,
> 		unsigned char scsi3addr[], u16 bmic_device_index,
> 		struct bmic_identify_physical_device *buf, size_t bufsize)
> @@ -3124,9 +3187,64 @@ static int hpsa_bmic_id_physical_device(struct ctlr_info *h,
> 	}
> out:
> 	cmd_free(h, c);
> +
> 	return rc;
> }
> 
> +static u64 hpsa_get_sas_address_from_report_physical(struct ctlr_info *h,
> +						unsigned char *scsi3addr)
> +{
> +	struct ReportExtendedLUNdata *physdev;
> +	u32 nphysicals;
> +	u64 sa = 0;
> +	int i;
> +
> +	physdev = kzalloc(sizeof(*physdev), GFP_KERNEL);
> +	if (!physdev)
> +		return 0;
> +
> +	if (hpsa_scsi_do_report_phys_luns(h, physdev, sizeof(*physdev))) {
> +		dev_err(&h->pdev->dev, "report physical LUNs failed.\n");
> +		kfree(physdev);
> +		return 0;
> +	}
> +	nphysicals = get_unaligned_be32(physdev->LUNListLength) / 24;
> +
> +	for (i = 0; i < nphysicals; i++)
> +		if (!memcmp(&physdev->LUN[i].lunid[0], scsi3addr, 8))
> +			sa = get_unaligned_be64(&physdev->LUN[i].wwid[0]);

Don't you want to break out here if you found a match?

> +
> +	kfree(physdev);
> +
> +	return sa;
> +}
> +
> +static void hpsa_get_sas_address(struct ctlr_info *h, unsigned char *scsi3addr,
> +					struct hpsa_scsi_dev_t *dev)
> +{
> +	int rc;
> +	u64 sa = 0;
> +
> +	if (is_hba_lunid(scsi3addr)) {
> +		struct bmic_sense_subsystem_info *ssi;
> +
> +		ssi = kzalloc(sizeof(*ssi), GFP_KERNEL);

What happens if this allocation fails? If the I/O can succeed without the
DMA buffer then you will run into trouble when deriving sa.

> +
> +		rc = hpsa_bmic_sense_subsystem_information(h,
> +					scsi3addr, 0, ssi, sizeof(*ssi));
> +		if (rc == 0) {
> +			sa = get_unaligned_be64(ssi->primary_world_wide_id);
> +			h->sas_address = sa;
> +		}
> +
> +		kfree(ssi);
> +	} else
> +		sa = hpsa_get_sas_address_from_report_physical(h, scsi3addr);
> +
> +	dev->sas_address = sa;
> +}
> +
> +/* Get a device id from inquiry page 0x83 */
> static int hpsa_vpd_page_supported(struct ctlr_info *h,
> 	unsigned char scsi3addr[], u8 page)
> {
> @@ -3961,6 +4079,13 @@ static void hpsa_update_scsi_devices(struct ctlr_info *h, int hostno)
> 		else
> 			this_device->expose_device = 1;
> 
> +
> +		/*
> +		 * Get the SAS address for physical devices that are exposed.
> +		 */
> +		if (this_device->physical_device && this_device->expose_device)
> +			hpsa_get_sas_address(h, lunaddrbytes, this_device);
> +
> 		switch (this_device->devtype) {
> 		case TYPE_ROM:
> 			/* We don't *really* support actual CD-ROM devices,
> @@ -4006,6 +4131,10 @@ static void hpsa_update_scsi_devices(struct ctlr_info *h, int hostno)
> 		if (ncurrent >= HPSA_MAX_DEVICES)
> 			break;
> 	}
> +
> +	if (h->sas_host == NULL)
> +		hpsa_add_sas_host(h);
> +
> 	adjust_hpsa_scsi_table(h, hostno, currentsd, ncurrent);
> out:
> 	kfree(tmpdevice);
> @@ -5137,6 +5266,7 @@ static int hpsa_scsi_host_alloc(struct ctlr_info *h)
> 	sh->can_queue = h->nr_cmds - HPSA_NRESERVED_CMDS;
> 	sh->cmd_per_lun = sh->can_queue;
> 	sh->sg_tablesize = h->maxsgentries;
> +	sh->transportt = hpsa_sas_transport_template;
> 	sh->hostdata[0] = (unsigned long) h;
> 	sh->irq = h->intr[h->intr_mode];
> 	sh->unique_id = sh->irq;
> @@ -6485,6 +6615,16 @@ static int fill_cmd(struct CommandList *c, u8 cmd, struct ctlr_info *h,
> 			c->Request.CDB[7] = (size >> 16) & 0xFF;
> 			c->Request.CDB[8] = (size >> 8) & 0XFF;
> 			break;
> +		case BMIC_SENSE_SUBSYSTEM_INFORMATION:
> +			c->Request.CDBLen = 10;
> +			c->Request.type_attr_dir =
> +				TYPE_ATTR_DIR(cmd_type, ATTR_SIMPLE, XFER_READ);
> +			c->Request.Timeout = 0;
> +			c->Request.CDB[0] = BMIC_READ;
> +			c->Request.CDB[6] = BMIC_SENSE_SUBSYSTEM_INFORMATION;
> +			c->Request.CDB[7] = (size >> 16) & 0xFF;
> +			c->Request.CDB[8] = (size >> 8) & 0XFF;
> +			break;
> 		case BMIC_IDENTIFY_CONTROLLER:
> 			c->Request.CDBLen = 10;
> 			c->Request.type_attr_dir =
> @@ -6501,7 +6641,6 @@ static int fill_cmd(struct CommandList *c, u8 cmd, struct ctlr_info *h,
> 			c->Request.CDB[8] = (size >> 8) & 0XFF;
> 			c->Request.CDB[9] = 0;
> 			break;
> -
> 		default:
> 			dev_warn(&h->pdev->dev, "unknown command 0x%c\n", cmd);
> 			BUG();
> @@ -8618,6 +8757,9 @@ static void hpsa_remove_one(struct pci_dev *pdev)
> 	free_percpu(h->lockup_detected);		/* init_one 2 */
> 	h->lockup_detected = NULL;			/* init_one 2 */
> 	/* (void) pci_disable_pcie_error_reporting(pdev); */	/* init_one 1 */
> +
> +	hpsa_delete_sas_host(h);
> +
> 	kfree(h);					/* init_one 1 */
> }
> 
> @@ -9080,18 +9222,369 @@ static void hpsa_drain_accel_commands(struct ctlr_info *h)
> 	} while (1);
> }
> 
> +static struct hpsa_sas_phy *hpsa_alloc_sas_phy(
> +				struct hpsa_sas_port *hpsa_sas_port)
> +{
> +	struct hpsa_sas_phy *hpsa_sas_phy;
> +	struct sas_phy *phy;
> +
> +	hpsa_sas_phy = kzalloc(sizeof(*hpsa_sas_phy), GFP_KERNEL);
> +	if (!hpsa_sas_phy)
> +		return NULL;
> +
> +	phy = sas_phy_alloc(hpsa_sas_port->parent_node->parent_dev,
> +		hpsa_sas_port->next_phy_index);
> +	if (!phy) {
> +		kfree(hpsa_sas_phy);
> +		return NULL;
> +	}
> +
> +	hpsa_sas_port->next_phy_index++;
> +	hpsa_sas_phy->phy = phy;
> +	hpsa_sas_phy->parent_port = hpsa_sas_port;
> +
> +	return hpsa_sas_phy;
> +}
> +
> +static void hpsa_free_sas_phy(struct hpsa_sas_phy *hpsa_sas_phy)
> +{
> +	struct sas_phy *phy = hpsa_sas_phy->phy;
> +
> +	sas_port_delete_phy(hpsa_sas_phy->parent_port->port, phy);
> +	sas_phy_free(phy);
> +	if (hpsa_sas_phy->added_to_port)
> +		list_del(&hpsa_sas_phy->phy_list_entry);
> +	kfree(hpsa_sas_phy);
> +}
> +
> +static int hpsa_sas_port_add_phy(struct hpsa_sas_phy *hpsa_sas_phy)
> +{
> +	int rc;
> +	struct hpsa_sas_port *hpsa_sas_port;
> +	struct sas_phy *phy;
> +	struct sas_identify *identify;
> +
> +	hpsa_sas_port = hpsa_sas_phy->parent_port;
> +	phy = hpsa_sas_phy->phy;
> +
> +	identify = &phy->identify;
> +	memset(identify, 0, sizeof(*identify));
> +	identify->sas_address = hpsa_sas_port->sas_address;
> +	identify->device_type = SAS_END_DEVICE;
> +	identify->initiator_port_protocols = SAS_PROTOCOL_STP;
> +	identify->target_port_protocols = SAS_PROTOCOL_STP;
> +	phy->minimum_linkrate_hw = SAS_LINK_RATE_UNKNOWN;
> +	phy->maximum_linkrate_hw = SAS_LINK_RATE_UNKNOWN;
> +	phy->minimum_linkrate = SAS_LINK_RATE_UNKNOWN;
> +	phy->maximum_linkrate = SAS_LINK_RATE_UNKNOWN;
> +	phy->negotiated_linkrate = SAS_LINK_RATE_UNKNOWN;
> +
> +	rc = sas_phy_add(hpsa_sas_phy->phy);
> +	if (rc)
> +		return rc;
> +
> +	sas_port_add_phy(hpsa_sas_port->port, hpsa_sas_phy->phy);
> +	list_add_tail(&hpsa_sas_phy->phy_list_entry,
> +			&hpsa_sas_port->phy_list_head);
> +	hpsa_sas_phy->added_to_port = true;
> +
> +	return 0;
> +}
> +
> +static int
> +	hpsa_sas_port_add_rphy(struct hpsa_sas_port *hpsa_sas_port,
> +				struct sas_rphy *rphy)
> +{
> +	struct sas_identify *identify;
> +
> +	identify = &rphy->identify;
> +	identify->sas_address = hpsa_sas_port->sas_address;
> +	identify->initiator_port_protocols = SAS_PROTOCOL_STP;
> +	identify->target_port_protocols = SAS_PROTOCOL_STP;
> +
> +	return sas_rphy_add(rphy);
> +}
> +
> +static struct hpsa_sas_port
> +	*hpsa_alloc_sas_port(struct hpsa_sas_node *hpsa_sas_node,
> +				u64 sas_address)
> +{
> +	int rc;
> +	struct hpsa_sas_port *hpsa_sas_port;
> +	struct sas_port *port;
> +
> +	hpsa_sas_port = kzalloc(sizeof(*hpsa_sas_port), GFP_KERNEL);
> +	if (!hpsa_sas_port)
> +		return NULL;
> +
> +	INIT_LIST_HEAD(&hpsa_sas_port->phy_list_head);
> +	hpsa_sas_port->parent_node = hpsa_sas_node;
> +
> +	port = sas_port_alloc_num(hpsa_sas_node->parent_dev);
> +	if (!port)
> +		goto free_hpsa_port;
> +
> +	rc = sas_port_add(port);
> +	if (rc)
> +		goto free_sas_port;
> +
> +	hpsa_sas_port->port = port;
> +	hpsa_sas_port->sas_address = sas_address;
> +	list_add_tail(&hpsa_sas_port->port_list_entry,
> +			&hpsa_sas_node->port_list_head);
> +
> +	return hpsa_sas_port;
> +
> +free_sas_port:
> +	sas_port_free(port);
> +free_hpsa_port:
> +	kfree(hpsa_sas_port);
> +
> +	return NULL;
> +}
> +
> +static void hpsa_free_sas_port(struct hpsa_sas_port *hpsa_sas_port)
> +{
> +	struct hpsa_sas_phy *hpsa_sas_phy;
> +	struct hpsa_sas_phy *next;
> +
> +	list_for_each_entry_safe(hpsa_sas_phy, next,
> +			&hpsa_sas_port->phy_list_head, phy_list_entry)
> +		hpsa_free_sas_phy(hpsa_sas_phy);
> +
> +	sas_port_delete(hpsa_sas_port->port);
> +	list_del(&hpsa_sas_port->port_list_entry);
> +	kfree(hpsa_sas_port);
> +}
> +
> +static struct hpsa_sas_node *hpsa_alloc_sas_node(struct device *parent_dev)
> +{
> +	struct hpsa_sas_node *hpsa_sas_node;
> +
> +	hpsa_sas_node = kzalloc(sizeof(*hpsa_sas_node), GFP_KERNEL);
> +	if (hpsa_sas_node) {
> +		hpsa_sas_node->parent_dev = parent_dev;
> +		INIT_LIST_HEAD(&hpsa_sas_node->port_list_head);
> +	}
> +
> +	return hpsa_sas_node;
> +}
> +
> +static void hpsa_free_sas_node(struct hpsa_sas_node *hpsa_sas_node)
> +{
> +	struct hpsa_sas_port *hpsa_sas_port;
> +	struct hpsa_sas_port *next;
> +
> +	if (!hpsa_sas_node)
> +		return;
> +
> +	list_for_each_entry_safe(hpsa_sas_port, next,
> +			&hpsa_sas_node->port_list_head, port_list_entry)
> +		hpsa_free_sas_port(hpsa_sas_port);
> +
> +	kfree(hpsa_sas_node);
> +}
> +
> +static struct hpsa_scsi_dev_t
> +	*hpsa_find_device_by_sas_rphy(struct ctlr_info *h,
> +					struct sas_rphy *rphy)
> +{
> +	int i;
> +	struct hpsa_scsi_dev_t *device;
> +
> +	for (i = 0; i < h->ndevices; i++) {
> +		device = h->dev[i];
> +		if (!device->sas_port)
> +			continue;
> +		if (device->sas_port->rphy == rphy)
> +			return device;
> +	}
> +
> +	return NULL;
> +}
> +
> +static int hpsa_add_sas_host(struct ctlr_info *h)
> +{
> +	int rc;
> +	struct device *parent_dev;
> +	struct hpsa_sas_node *hpsa_sas_node;
> +	struct hpsa_sas_port *hpsa_sas_port;
> +	struct hpsa_sas_phy *hpsa_sas_phy;
> +
> +	parent_dev = &h->scsi_host->shost_gendev;
> +
> +	hpsa_sas_node = hpsa_alloc_sas_node(parent_dev);
> +	if (!hpsa_sas_node)
> +		return -ENOMEM;
> +
> +	hpsa_sas_port = hpsa_alloc_sas_port(hpsa_sas_node, h->sas_address);
> +	if (!hpsa_sas_port) {
> +		rc = -ENODEV;
> +		goto free_sas_node;
> +	}
> +
> +	hpsa_sas_phy = hpsa_alloc_sas_phy(hpsa_sas_port);
> +	if (!hpsa_sas_phy) {
> +		rc = -ENODEV;
> +		goto free_sas_port;
> +	}
> +
> +	rc = hpsa_sas_port_add_phy(hpsa_sas_phy);
> +	if (rc)
> +		goto free_sas_phy;
> +
> +	h->sas_host = hpsa_sas_node;
> +
> +	return 0;
> +
> +free_sas_phy:
> +	hpsa_free_sas_phy(hpsa_sas_phy);
> +free_sas_port:
> +	hpsa_free_sas_port(hpsa_sas_port);
> +free_sas_node:
> +	hpsa_free_sas_node(hpsa_sas_node);
> +
> +	return rc;
> +}
> +
> +static void hpsa_delete_sas_host(struct ctlr_info *h)
> +{
> +	hpsa_free_sas_node(h->sas_host);
> +}
> +
> +static int hpsa_add_sas_device(struct hpsa_sas_node *hpsa_sas_node,
> +				struct hpsa_scsi_dev_t *device)
> +{
> +	int rc;
> +	struct hpsa_sas_port *hpsa_sas_port;
> +	struct sas_rphy *rphy;
> +
> +	hpsa_sas_port = hpsa_alloc_sas_port(hpsa_sas_node, device->sas_address);
> +	if (!hpsa_sas_port)
> +		return -ENOMEM;
> +
> +	rphy = sas_end_device_alloc(hpsa_sas_port->port);
> +	if (!rphy) {
> +		rc = -ENODEV;
> +		goto free_sas_port;
> +	}
> +
> +	hpsa_sas_port->rphy = rphy;
> +	device->sas_port = hpsa_sas_port;
> +
> +	rc = hpsa_sas_port_add_rphy(hpsa_sas_port, rphy);
> +	if (rc)
> +		goto free_sas_port;
> +
> +	return 0;
> +
> +free_sas_port:
> +	hpsa_free_sas_port(hpsa_sas_port);
> +	device->sas_port = NULL;
> +
> +	return rc;
> +}
> +
> +static void hpsa_remove_sas_device(struct hpsa_scsi_dev_t *device)
> +{
> +	if (device->sas_port) {
> +		hpsa_free_sas_port(device->sas_port);
> +		device->sas_port = NULL;
> +	}
> +}
> +
> +static int
> +hpsa_sas_get_linkerrors(struct sas_phy *phy)
> +{
> +	return 0;
> +}
> +
> +static int
> +hpsa_sas_get_enclosure_identifier(struct sas_rphy *rphy, u64 *identifier)
> +{
> +	return 0;
> +}
> +
> +static int
> +hpsa_sas_get_bay_identifier(struct sas_rphy *rphy)
> +{
> +	return -ENXIO;
> +}
> +
> +static int
> +hpsa_sas_phy_reset(struct sas_phy *phy, int hard_reset)
> +{
> +	return 0;
> +}
> +
> +static int
> +hpsa_sas_phy_enable(struct sas_phy *phy, int enable)
> +{
> +	return 0;
> +}
> +
> +static int
> +hpsa_sas_phy_setup(struct sas_phy *phy)
> +{
> +	return 0;
> +}
> +
> +static void
> +hpsa_sas_phy_release(struct sas_phy *phy)
> +{
> +}
> +
> +static int
> +hpsa_sas_phy_speed(struct sas_phy *phy, struct sas_phy_linkrates *rates)
> +{
> +	return -EINVAL;
> +}
> +
> +/* SMP = Serial Management Protocol */
> +static int
> +hpsa_sas_smp_handler(struct Scsi_Host *shost, struct sas_rphy *rphy,
> +struct request *req)
> +{
> +	return -EINVAL;
> +}
> +
> +static struct sas_function_template hpsa_sas_transport_functions = {
> +	.get_linkerrors = hpsa_sas_get_linkerrors,
> +	.get_enclosure_identifier = hpsa_sas_get_enclosure_identifier,
> +	.get_bay_identifier = hpsa_sas_get_bay_identifier,
> +	.phy_reset = hpsa_sas_phy_reset,
> +	.phy_enable = hpsa_sas_phy_enable,
> +	.phy_setup = hpsa_sas_phy_setup,
> +	.phy_release = hpsa_sas_phy_release,
> +	.set_phy_speed = hpsa_sas_phy_speed,
> +	.smp_handler = hpsa_sas_smp_handler,
> +};
> +
> /*
>  *  This is it.  Register the PCI driver information for the cards we control
>  *  the OS will call our registered routines when it finds one of our cards.
>  */
> static int __init hpsa_init(void)
> {
> -	return pci_register_driver(&hpsa_pci_driver);
> +	int rc;
> +
> +	hpsa_sas_transport_template =
> +		sas_attach_transport(&hpsa_sas_transport_functions);
> +	if (!hpsa_sas_transport_template)
> +		return -ENODEV;
> +
> +	rc = pci_register_driver(&hpsa_pci_driver);
> +
> +	if (rc)
> +		sas_release_transport(hpsa_sas_transport_template);
> +
> +	return rc;
> }
> 
> static void __exit hpsa_cleanup(void)
> {
> 	pci_unregister_driver(&hpsa_pci_driver);
> +	sas_release_transport(hpsa_sas_transport_template);
> }
> 
> static void __attribute__((unused)) verify_offsets(void)
> diff --git a/drivers/scsi/hpsa.h b/drivers/scsi/hpsa.h
> index 6c82d3c..7847405 100644
> --- a/drivers/scsi/hpsa.h
> +++ b/drivers/scsi/hpsa.h
> @@ -33,6 +33,29 @@ struct access_method {
> 	unsigned long (*command_completed)(struct ctlr_info *h, u8 q);
> };
> 
> +/* for SAS hosts and SAS expanders */
> +struct hpsa_sas_node {
> +	struct device *parent_dev;
> +	struct list_head port_list_head;
> +};
> +
> +struct hpsa_sas_port {
> +	struct list_head port_list_entry;
> +	u64 sas_address;
> +	struct sas_port *port;
> +	int next_phy_index;
> +	struct list_head phy_list_head;
> +	struct hpsa_sas_node *parent_node;
> +	struct sas_rphy *rphy;
> +};
> +
> +struct hpsa_sas_phy {
> +	struct list_head phy_list_entry;
> +	struct sas_phy *phy;
> +	struct hpsa_sas_port *parent_port;
> +	bool added_to_port;
> +};
> +
> struct hpsa_scsi_dev_t {
> 	unsigned int devtype;
> 	int bus, target, lun;		/* as presented to the OS */
> @@ -41,6 +64,7 @@ struct hpsa_scsi_dev_t {
> 	u8 expose_device;
> #define RAID_CTLR_LUNID "\0\0\0\0\0\0\0\0"
> 	unsigned char device_id[16];    /* from inquiry pg. 0x83 */
> +	u64 sas_address;
> 	unsigned char vendor[8];        /* bytes 8-15 of inquiry data */
> 	unsigned char model[16];        /* bytes 16-31 of inquiry data */
> 	unsigned char raid_level;	/* from inquiry page 0xC1 */
> @@ -77,6 +101,7 @@ struct hpsa_scsi_dev_t {
> 	struct hpsa_scsi_dev_t *phys_disk[RAID_MAP_MAX_ENTRIES];
> 	int nphysical_disks;
> 	int supports_aborts;
> +	struct hpsa_sas_port *sas_port;
> 	int external;   /* 1-from external array 0-not <0-unknown */
> };
> 
> @@ -134,6 +159,7 @@ struct ctlr_info {
> 	char    *product_name;
> 	struct pci_dev *pdev;
> 	u32	board_id;
> +	u64	sas_address;
> 	void __iomem *vaddr;
> 	unsigned long paddr;
> 	int 	nr_cmds; /* Number of commands allowed on this controller */
> @@ -272,6 +298,7 @@ struct ctlr_info {
> 	wait_queue_head_t event_sync_wait_queue;
> 	struct mutex reset_mutex;
> 	u8 reset_in_progress;
> +	struct hpsa_sas_node *sas_host;
> };
> 
> struct offline_device_entry {
> diff --git a/drivers/scsi/hpsa_cmd.h b/drivers/scsi/hpsa_cmd.h
> index 4910344..d92ef0d 100644
> --- a/drivers/scsi/hpsa_cmd.h
> +++ b/drivers/scsi/hpsa_cmd.h
> @@ -290,6 +290,7 @@ struct SenseSubsystem_info {
> #define BMIC_SET_DIAG_OPTIONS 0xF4
> #define BMIC_SENSE_DIAG_OPTIONS 0xF5
> #define HPSA_DIAG_OPTS_DISABLE_RLD_CACHING 0x40000000
> +#define BMIC_SENSE_SUBSYSTEM_INFORMATION 0x66
> 
> /* Command List Structure */
> union SCSI3Addr {
> @@ -828,5 +829,18 @@ struct bmic_identify_physical_device {
> 	u8     padding[112];
> };
> 
> +struct bmic_sense_subsystem_info {
> +	u8	primary_slot_number;
> +	u8	reserved[3];
> +	u8	chasis_serial_number[32];
> +	u8	primary_world_wide_id[8];
> +	u8	primary_array_serial_number[32]; /* NULL terminated */
> +	u8	primary_cache_serial_number[32]; /* NULL terminated */
> +	u8	reserved_2[8];
> +	u8	secondary_array_serial_number[32];
> +	u8	secondary_cache_serial_number[32];
> +	u8	pad[332];
> +};
> +
> #pragma pack()
> #endif /* HPSA_CMD_H */
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 


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

* Re: [PATCH 1 25/25] hpsa: bump the driver version
  2015-10-28 22:07 ` [PATCH 1 25/25] hpsa: bump the driver version Don Brace
  2015-10-30  8:22   ` Hannes Reinecke
  2015-10-30 14:44   ` Tomas Henzl
@ 2015-10-30 20:08   ` Matthew R. Ochs
  2 siblings, 0 replies; 107+ messages in thread
From: Matthew R. Ochs @ 2015-10-30 20:08 UTC (permalink / raw)
  To: Don Brace
  Cc: scott.teel, Kevin.Barnett, scott.benesh, james.bottomley, hch,
	Justin.Lindley, elliott, linux-scsi

Reviewed-by: Matthew R. Ochs <mrochs@linux.vnet.ibm.com>


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

* Re: [PATCH 1 06/25] hpsa: abandon rescans on memory alloaction failures.
  2015-10-30  7:53   ` Hannes Reinecke
@ 2015-10-30 20:44     ` Don Brace
  0 siblings, 0 replies; 107+ messages in thread
From: Don Brace @ 2015-10-30 20:44 UTC (permalink / raw)
  To: Hannes Reinecke, scott.teel, Kevin.Barnett, scott.benesh,
	james.bottomley, hch, Justin.Lindley, elliott
  Cc: linux-scsi



On 10/30/2015 02:53 AM, Hannes Reinecke wrote:
> On 10/28/2015 11:05 PM, Don Brace wrote:
>> Abandon and reschedule rescan process only if device inquiries
>> fail due to mem alloc failures, which are likely to occur for
>> all devices.
>>
>> Otherwise, skip device if inquiry fails for other reasons,
>> and continue rescanning process for other devices.
>>
>> Reviewed-by: Scott Teel <scott.teel@pmcs.com>
>> Reviewed-by: Justin Lindley <justin.lindley@pmcs.com>
>> Reviewed-by: Kevin Barnett <kevin.barnett@pmcs.com>
>> Reviewed-by: Tomas Henzl <thenzl@redhat.com>
>> Signed-off-by: Don Brace <don.brace@pmcs.com>
>> ---
>>   drivers/scsi/hpsa.c |   24 +++++++++++++++++++-----
>>   1 file changed, 19 insertions(+), 5 deletions(-)
>>
>> diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
>> index a3f671c..ecc6ada 100644
>> --- a/drivers/scsi/hpsa.c
>> +++ b/drivers/scsi/hpsa.c
>> @@ -3375,10 +3375,13 @@ static int hpsa_update_device_info(struct ctlr_info *h,
>>   
>>   	unsigned char *inq_buff;
>>   	unsigned char *obdr_sig;
>> +	int rc = 0;
>>   
>>   	inq_buff = kzalloc(OBDR_TAPE_INQ_SIZE, GFP_KERNEL);
>> -	if (!inq_buff)
>> +	if (!inq_buff) {
>> +		rc = -ENOMEM;
>>   		goto bail_out;
>> +	}
>>   
>>   	/* Do an inquiry to the device to see what it is. */
>>   	if (hpsa_scsi_do_inquiry(h, scsi3addr, 0, inq_buff,
>> @@ -3386,6 +3389,7 @@ static int hpsa_update_device_info(struct ctlr_info *h,
>>   		/* Inquiry failed (msg printed already) */
>>   		dev_err(&h->pdev->dev,
>>   			"hpsa_update_device_info: inquiry failed\n");
>> +		rc = 1;
>>   		goto bail_out;
>>   	}
>>   
> Why '1' and not a normal error code, seeing that you're using -ENOMEM above?
Changed to -EIO
>
>> @@ -3435,7 +3439,7 @@ static int hpsa_update_device_info(struct ctlr_info *h,
>>   
>>   bail_out:
>>   	kfree(inq_buff);
>> -	return 1;
>> +	return rc;
>>   }
>>   
>>   static void hpsa_update_device_supports_aborts(struct ctlr_info *h,
>> @@ -3803,6 +3807,7 @@ static void hpsa_update_scsi_devices(struct ctlr_info *h, int hostno)
>>   	n_ext_target_devs = 0;
>>   	for (i = 0; i < nphysicals + nlogicals + 1; i++) {
>>   		u8 *lunaddrbytes, is_OBDR = 0;
>> +		int rc = 0;
>>   
>>   		/* Figure out where the LUN ID info is coming from */
>>   		lunaddrbytes = figure_lunaddrbytes(h, raid_ctlr_position,
>> @@ -3815,11 +3820,20 @@ static void hpsa_update_scsi_devices(struct ctlr_info *h, int hostno)
>>   				continue;
>>   
>>   		/* Get device type, vendor, model, device id */
>> -		if (hpsa_update_device_info(h, lunaddrbytes, tmpdevice,
>> -							&is_OBDR)) {
>> +		rc = hpsa_update_device_info(h, lunaddrbytes, tmpdevice,
>> +							&is_OBDR);
>> +		if (rc == -ENOMEM) {
>> +			dev_warn(&h->pdev->dev,
>> +				"Out of memory, rescan deferred.\n");
>>   			h->drv_req_rescan = 1;
>> -			continue; /* skip it if we can't talk to it. */
>> +			goto out;
>>   		}
>> +		if (rc) {
>> +			dev_warn(&h->pdev->dev,
>> +				"Inquiry failed, skipping device.\n");
>> +			continue;
>> +		}
>> +
>>   		figure_bus_target_lun(h, lunaddrbytes, tmpdevice);
>>   		hpsa_update_device_supports_aborts(h, tmpdevice, lunaddrbytes);
>>   		this_device = currentsd[ncurrent];
>>
> Cheers,
>
> Hannes


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

* Re: [PATCH 1 08/25] hpsa: fix hpsa_adjust_hpsa_scsi_table
  2015-10-30  7:57   ` Hannes Reinecke
@ 2015-10-30 20:46     ` Don Brace
  0 siblings, 0 replies; 107+ messages in thread
From: Don Brace @ 2015-10-30 20:46 UTC (permalink / raw)
  To: Hannes Reinecke, scott.teel, Kevin.Barnett, scott.benesh,
	james.bottomley, hch, Justin.Lindley, elliott
  Cc: linux-scsi



On 10/30/2015 02:57 AM, Hannes Reinecke wrote:
> On 10/28/2015 11:05 PM, Don Brace wrote:
>> Fix a NULL pointer issue in the driver when devices are removed
>> during a reset.
>>
>> Signed-off-by: Don Brace <don.brace@pmcs.com>
>> ---
>>   drivers/block/cciss.h |    1 +
>>   drivers/scsi/hpsa.c   |   16 ++++++++++++++++
>>   drivers/scsi/hpsa.h   |    1 +
>>   3 files changed, 18 insertions(+)
>>
>> diff --git a/drivers/block/cciss.h b/drivers/block/cciss.h
>> index 7fda30e..f8b8c6b 100644
>> --- a/drivers/block/cciss.h
>> +++ b/drivers/block/cciss.h
>> @@ -155,6 +155,7 @@ struct ctlr_info
>>   	size_t reply_pool_size;
>>   	unsigned char reply_pool_wraparound;
>>   	u32 *blockFetchTable;
>> +	u8 reset_in_progress;
>>   };
>>   
>>   /*  Defining the diffent access_methods
> Why do you need to add it here?
> To my knowledge cciss and hpsa are different drivers ...
ctag issue. corrected.
>
> Cheers,
>
> Hannes


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

* Re: [PATCH 1 15/25] hpsa: enhance hpsa_get_device_id
  2015-10-30  8:08   ` Hannes Reinecke
@ 2015-10-30 20:59     ` Don Brace
  0 siblings, 0 replies; 107+ messages in thread
From: Don Brace @ 2015-10-30 20:59 UTC (permalink / raw)
  To: Hannes Reinecke, scott.teel, Kevin.Barnett, scott.benesh,
	james.bottomley, hch, Justin.Lindley, elliott
  Cc: linux-scsi

On 10/30/2015 03:08 AM, Hannes Reinecke wrote:
> On 10/28/2015 11:06 PM, Don Brace wrote:
>> use an index into vpd data for SAS/SATA drives
>>
>> Reviewed-by: Scott Teel <scott.teel@pmcs.com>
>> Reviewed-by: Justin Lindley <justin.lindley@pmcs.com>
>> Reviewed-by: Kevin Barnett <kevin.barnett@pmcs.com>
>> Signed-off-by: Don Brace <don.brace@pmcs.com>
>> ---
>>   drivers/scsi/hpsa.c |   23 ++++++++++++++++++++---
>>   1 file changed, 20 insertions(+), 3 deletions(-)
>>
>> diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
>> index c1b053f..1361414 100644
>> --- a/drivers/scsi/hpsa.c
>> +++ b/drivers/scsi/hpsa.c
>> @@ -3137,7 +3137,7 @@ out:
>>   
>>   /* Get the device id from inquiry page 0x83 */
>>   static int hpsa_get_device_id(struct ctlr_info *h, unsigned char *scsi3addr,
>> -	unsigned char *device_id, int buflen)
>> +	unsigned char *device_id, int index, int buflen)
>>   {
>>   	int rc;
>>   	unsigned char *buf;
>> @@ -3149,8 +3149,10 @@ static int hpsa_get_device_id(struct ctlr_info *h, unsigned char *scsi3addr,
>>   		return -ENOMEM;
>>   	rc = hpsa_scsi_do_inquiry(h, scsi3addr, VPD_PAGE | 0x83, buf, 64);
>>   	if (rc == 0)
>> -		memcpy(device_id, &buf[8], buflen);
>> +		memcpy(device_id, &buf[index], buflen);
>> +
>>   	kfree(buf);
>> +
>>   	return rc != 0;
>>   }
>>   
>> @@ -3379,6 +3381,18 @@ static int hpsa_device_supports_aborts(struct ctlr_info *h,
>>   	return rc;
>>   }
>>   
>> +static void sanitize_inquiry_string(unsigned char *s, int len)
>> +{
>> +	bool terminated = false;
>> +
>> +	for (; len > 0; (--len, ++s)) {
>> +		if (*s == 0)
>> +			terminated = true;
>> +		if (terminated || *s < 0x20 || *s > 0x7e)
>> +			*s = ' ';
>> +	}
>> +}
>> +
>>   static int hpsa_update_device_info(struct ctlr_info *h,
>>   	unsigned char scsi3addr[], struct hpsa_scsi_dev_t *this_device,
>>   	unsigned char *is_OBDR_device)
> I would prefer to have the function from scsi_scan.c to be exported.
> Hardly a point to duplicate it.
>
> Cheers,
>
> Hannes
I can submit a patch to change it. Can it be in a later patch?

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

* Re: [PATCH 1 21/25] hpsa: disable report lun data caching
  2015-10-30 14:25   ` Tomas Henzl
@ 2015-10-30 21:18     ` Don Brace
  0 siblings, 0 replies; 107+ messages in thread
From: Don Brace @ 2015-10-30 21:18 UTC (permalink / raw)
  To: Tomas Henzl, scott.teel, Kevin.Barnett, scott.benesh,
	james.bottomley, hch, Justin.Lindley, elliott
  Cc: linux-scsi

On 10/30/2015 09:25 AM, Tomas Henzl wrote:
> On 28.10.2015 23:06, Don Brace wrote:
>> From: Scott Teel <scott.teel@pmcs.com>
>>
>> When external target arrays are present, disable the firmware's
>> normal behavior of returning a cached copy of the report lun data,
>> and force it to collect new data each time we request a report luns.
>>
>> This is necessary for external arrays, since there may be no
>> reliable signal from the external array to the smart array when
>> lun configuration changes, and thus when driver requests
>> report luns, it may be stale data.
>>
>> Use diag options to turn off RPL data caching.
>>
>> Reviewed-by: Scott Teel <scott.teel@pmcs.com>
>> Reviewed-by: Justin Lindley <justin.lindley@pmcs.com>
>> Reviewed-by: Kevin Barnett <kevin.barnett@pmcs.com>
>> Signed-off-by: Don Brace <don.brace@pmcs.com>
>> ---
>>   drivers/scsi/hpsa.c     |   86 +++++++++++++++++++++++++++++++++++++++++++++++
>>   drivers/scsi/hpsa_cmd.h |    3 ++
>>   2 files changed, 89 insertions(+)
>>
>> diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
>> index e521acd..33fd0aa 100644
>> --- a/drivers/scsi/hpsa.c
>> +++ b/drivers/scsi/hpsa.c
>> @@ -276,6 +276,7 @@ static int hpsa_scsi_ioaccel_queue_command(struct ctlr_info *h,
>>   static void hpsa_command_resubmit_worker(struct work_struct *work);
>>   static u32 lockup_detected(struct ctlr_info *h);
>>   static int detect_controller_lockup(struct ctlr_info *h);
>> +static void hpsa_disable_rld_caching(struct ctlr_info *h);
>>   static int hpsa_luns_changed(struct ctlr_info *h);
>>   
>>   static inline struct ctlr_info *sdev_to_hba(struct scsi_device *sdev)
>> @@ -6386,6 +6387,24 @@ static int fill_cmd(struct CommandList *c, u8 cmd, struct ctlr_info *h,
>>   			c->Request.CDB[8] = (size >> 8) & 0xFF;
>>   			c->Request.CDB[9] = size & 0xFF;
>>   			break;
>> +		case BMIC_SENSE_DIAG_OPTIONS:
>> +			c->Request.CDBLen = 16;
>> +			c->Request.type_attr_dir =
>> +				TYPE_ATTR_DIR(cmd_type, ATTR_SIMPLE, XFER_READ);
>> +			c->Request.Timeout = 0;
>> +			/* Spec says this should be BMIC_WRITE */
>> +			c->Request.CDB[0] = BMIC_READ;
>> +			c->Request.CDB[6] = BMIC_SENSE_DIAG_OPTIONS;
>> +			break;
>> +		case BMIC_SET_DIAG_OPTIONS:
>> +			c->Request.CDBLen = 16;
>> +			c->Request.type_attr_dir =
>> +					TYPE_ATTR_DIR(cmd_type,
>> +						ATTR_SIMPLE, XFER_WRITE);
>> +			c->Request.Timeout = 0;
>> +			c->Request.CDB[0] = BMIC_WRITE;
>> +			c->Request.CDB[6] = BMIC_SET_DIAG_OPTIONS;
>> +			break;
>>   		case HPSA_CACHE_FLUSH:
>>   			c->Request.CDBLen = 12;
>>   			c->Request.type_attr_dir =
>> @@ -8086,6 +8105,7 @@ static void hpsa_rescan_ctlr_worker(struct work_struct *work)
>>   		hpsa_scan_start(h->scsi_host);
>>   		scsi_host_put(h->scsi_host);
>>   	} else if (h->discovery_polling) {
>> +		hpsa_disable_rld_caching(h);
>>   		if (hpsa_luns_changed(h)) {
>>   			struct Scsi_Host *sh = NULL;
>>   
>> @@ -8423,6 +8443,72 @@ out:
>>   	kfree(flush_buf);
>>   }
>>   
>> +/* Make controller gather fresh report lun data each time we
>> + * send down a report luns request
>> + */
>> +static void hpsa_disable_rld_caching(struct ctlr_info *h)
>> +{
>> +	u32 *options;
>> +	struct CommandList *c;
>> +	int rc;
>> +
>> +	/* Don't bother trying to set diag options if locked up */
>> +	if (unlikely(h->lockup_detected))
>> +		return;
>> +
>> +	options = kzalloc(sizeof(*options), GFP_KERNEL);
>> +	if (!options) {
>> +		dev_err(&h->pdev->dev,
>> +			"Error: failed to disable rld caching, during alloc.\n");
>> +		return;
>> +	}
>> +
>> +	c = cmd_alloc(h);
>> +
>> +	/* first, get the current diag options settings */
>> +	if (fill_cmd(c, BMIC_SENSE_DIAG_OPTIONS, h, options, 4, 0,
>> +		RAID_CTLR_LUNID, TYPE_CMD))
>> +		goto errout;
>> +
>> +	rc = hpsa_scsi_do_simple_cmd_with_retry(h, c,
>> +		PCI_DMA_FROMDEVICE, NO_TIMEOUT);
>> +	if ((rc != 0) || (c->err_info->CommandStatus != 0))
>> +		goto errout;
>> +
>> +	/* Now, set the bit for disabling the RLD caching */
>> +	*options |= HPSA_DIAG_OPTS_DISABLE_RLD_CACHING;
>> +
>> +	if (fill_cmd(c, BMIC_SET_DIAG_OPTIONS, h, options, 4, 0,
>> +		RAID_CTLR_LUNID, TYPE_CMD))
>> +		goto errout;
>> +
>> +	rc = hpsa_scsi_do_simple_cmd_with_retry(h, c,
>> +		PCI_DMA_TODEVICE, NO_TIMEOUT);
>> +	if ((rc != 0)  || (c->err_info->CommandStatus != 0))
>> +		goto errout;
>> +
>> +	/* Now verify that it got set: */
>> +	if (fill_cmd(c, BMIC_SENSE_DIAG_OPTIONS, h, options, 4, 0,
>> +		RAID_CTLR_LUNID, TYPE_CMD))
>> +		goto errout;
>> +
>> +	rc = hpsa_scsi_do_simple_cmd_with_retry(h, c,
>> +		PCI_DMA_FROMDEVICE, NO_TIMEOUT);
>> +	if ((rc != 0)  || (c->err_info->CommandStatus != 0))
>> +		goto errout;
>> +
>> +	if (*options && HPSA_DIAG_OPTS_DISABLE_RLD_CACHING)
>> +		goto out;
>> +	else {
>> +errout:
>> +		dev_err(&h->pdev->dev,
>> +			"Error: failed to disable report lun data caching.\n");
>> +	}
>> +out:
>> +	cmd_free(h, c);
>> +	kfree(options);
>> +}
> The last if statement looks too complicated - what about :
>
> +	if (*options && HPSA_DIAG_OPTS_DISABLE_RLD_CACHING)
> 		goto out;
>
> +errout:
> +	dev_err(&h->pdev->dev,
> +		"Error: failed to disable report lun data caching.\n");
> +out:
> +	cmd_free(h, c);
> +	kfree(options);
> +}
> Agreed.
>
>> +
>>   static void hpsa_shutdown(struct pci_dev *pdev)
>>   {
>>   	struct ctlr_info *h;
>> diff --git a/drivers/scsi/hpsa_cmd.h b/drivers/scsi/hpsa_cmd.h
>> index c83eaf1..4910344 100644
>> --- a/drivers/scsi/hpsa_cmd.h
>> +++ b/drivers/scsi/hpsa_cmd.h
>> @@ -287,6 +287,9 @@ struct SenseSubsystem_info {
>>   #define BMIC_SENSE_CONTROLLER_PARAMETERS 0x64
>>   #define BMIC_IDENTIFY_PHYSICAL_DEVICE 0x15
>>   #define BMIC_IDENTIFY_CONTROLLER 0x11
>> +#define BMIC_SET_DIAG_OPTIONS 0xF4
>> +#define BMIC_SENSE_DIAG_OPTIONS 0xF5
>> +#define HPSA_DIAG_OPTS_DISABLE_RLD_CACHING 0x40000000
>>   
>>   /* Command List Structure */
>>   union SCSI3Addr {
>>
>> --
>> To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
>> the body of a message to majordomo@vger.kernel.org
>> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> --
> To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html


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

* Re: [PATCH 1 24/25] hpsa: add in sas transport class
  2015-10-30 20:07   ` Matthew R. Ochs
@ 2015-10-30 22:00     ` Don Brace
  2015-10-30 23:23       ` Matthew R. Ochs
  0 siblings, 1 reply; 107+ messages in thread
From: Don Brace @ 2015-10-30 22:00 UTC (permalink / raw)
  To: Matthew R. Ochs
  Cc: scott.teel, Kevin.Barnett, scott.benesh, james.bottomley, hch,
	Justin.Lindley, elliott, linux-scsi

On 10/30/2015 03:07 PM, Matthew R. Ochs wrote:
>> On Oct 28, 2015, at 5:06 PM, Don Brace <don.brace@pmcs.com> wrote:
>>
>> From: Kevin Barnett <kevin.barnett@pmcs.com>
>>
>> Reviewed-by: Scott Teel <scott.teel@pmcs.com>
>> Reviewed-by: Justin Lindley <justin.lindley@pmcs.com>
>> Reviewed-by: Kevin Barnett <kevin.barnett@pmcs.com>
>> Signed-off-by: Don Brace <don.brace@pmcs.com>
>> ---
>> drivers/scsi/hpsa.c     |  535 +++++++++++++++++++++++++++++++++++++++++++++--
>> drivers/scsi/hpsa.h     |   27 ++
>> drivers/scsi/hpsa_cmd.h |   14 +
>> 3 files changed, 555 insertions(+), 21 deletions(-)
>>
>> diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
>> index 56526312..ca38a00 100644
>> --- a/drivers/scsi/hpsa.c
>> +++ b/drivers/scsi/hpsa.c
>> @@ -41,6 +41,7 @@
>>
>> +static u64 hpsa_get_sas_address_from_report_physical(struct ctlr_info *h,
>> +						unsigned char *scsi3addr)
>> +{
>> +	struct ReportExtendedLUNdata *physdev;
>> +	u32 nphysicals;
>> +	u64 sa = 0;
>> +	int i;
>> +
>> +	physdev = kzalloc(sizeof(*physdev), GFP_KERNEL);
>> +	if (!physdev)
>> +		return 0;
>> +
>> +	if (hpsa_scsi_do_report_phys_luns(h, physdev, sizeof(*physdev))) {
>> +		dev_err(&h->pdev->dev, "report physical LUNs failed.\n");
>> +		kfree(physdev);
>> +		return 0;
>> +	}
>> +	nphysicals = get_unaligned_be32(physdev->LUNListLength) / 24;
>> +
>> +	for (i = 0; i < nphysicals; i++)
>> +		if (!memcmp(&physdev->LUN[i].lunid[0], scsi3addr, 8))
>> +			sa = get_unaligned_be64(&physdev->LUN[i].wwid[0]);
> Don't you want to break out here if you found a match?
Agreed.
>
>> +
>> +	kfree(physdev);
>> +
>> +	return sa;
>> +}
>> +
>> +static void hpsa_get_sas_address(struct ctlr_info *h, unsigned char *scsi3addr,
>> +					struct hpsa_scsi_dev_t *dev)
>> +{
>> +	int rc;
>> +	u64 sa = 0;
>> +
>> +	if (is_hba_lunid(scsi3addr)) {
>> +		struct bmic_sense_subsystem_info *ssi;
>> +
>> +		ssi = kzalloc(sizeof(*ssi), GFP_KERNEL);
> What happens if this allocation fails? If the I/O can succeed without the
> DMA buffer then you will run into trouble when deriving sa.
Added check for NULL.
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html


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

* Re: [PATCH 1 24/25] hpsa: add in sas transport class
  2015-10-30 22:00     ` Don Brace
@ 2015-10-30 23:23       ` Matthew R. Ochs
  0 siblings, 0 replies; 107+ messages in thread
From: Matthew R. Ochs @ 2015-10-30 23:23 UTC (permalink / raw)
  To: Don Brace
  Cc: scott.teel, Kevin.Barnett, scott.benesh, james.bottomley, hch,
	Justin.Lindley, elliott, linux-scsi

> On Oct 30, 2015, at 5:00 PM, Don Brace <brace77070@gmail.com> wrote:
> On 10/30/2015 03:07 PM, Matthew R. Ochs wrote:
>>> On Oct 28, 2015, at 5:06 PM, Don Brace <don.brace@pmcs.com> wrote:
>>> 
>>> From: Kevin Barnett <kevin.barnett@pmcs.com>
>>> 
>>> Reviewed-by: Scott Teel <scott.teel@pmcs.com>
>>> Reviewed-by: Justin Lindley <justin.lindley@pmcs.com>
>>> Reviewed-by: Kevin Barnett <kevin.barnett@pmcs.com>
>>> Signed-off-by: Don Brace <don.brace@pmcs.com>
>>> ---
>>> drivers/scsi/hpsa.c     |  535 +++++++++++++++++++++++++++++++++++++++++++++--
>>> drivers/scsi/hpsa.h     |   27 ++
>>> drivers/scsi/hpsa_cmd.h |   14 +
>>> 3 files changed, 555 insertions(+), 21 deletions(-)
>>> 
>>> diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
>>> index 56526312..ca38a00 100644
>>> --- a/drivers/scsi/hpsa.c
>>> +++ b/drivers/scsi/hpsa.c
>>> @@ -41,6 +41,7 @@
>>> 
>>> +static u64 hpsa_get_sas_address_from_report_physical(struct ctlr_info *h,
>>> +						unsigned char *scsi3addr)
>>> +{
>>> +	struct ReportExtendedLUNdata *physdev;
>>> +	u32 nphysicals;
>>> +	u64 sa = 0;
>>> +	int i;
>>> +
>>> +	physdev = kzalloc(sizeof(*physdev), GFP_KERNEL);
>>> +	if (!physdev)
>>> +		return 0;
>>> +
>>> +	if (hpsa_scsi_do_report_phys_luns(h, physdev, sizeof(*physdev))) {
>>> +		dev_err(&h->pdev->dev, "report physical LUNs failed.\n");
>>> +		kfree(physdev);
>>> +		return 0;
>>> +	}
>>> +	nphysicals = get_unaligned_be32(physdev->LUNListLength) / 24;
>>> +
>>> +	for (i = 0; i < nphysicals; i++)
>>> +		if (!memcmp(&physdev->LUN[i].lunid[0], scsi3addr, 8))
>>> +			sa = get_unaligned_be64(&physdev->LUN[i].wwid[0]);
>> Don't you want to break out here if you found a match?
> Agreed.
>> 
>>> +
>>> +	kfree(physdev);
>>> +
>>> +	return sa;
>>> +}
>>> +
>>> +static void hpsa_get_sas_address(struct ctlr_info *h, unsigned char *scsi3addr,
>>> +					struct hpsa_scsi_dev_t *dev)
>>> +{
>>> +	int rc;
>>> +	u64 sa = 0;
>>> +
>>> +	if (is_hba_lunid(scsi3addr)) {
>>> +		struct bmic_sense_subsystem_info *ssi;
>>> +
>>> +		ssi = kzalloc(sizeof(*ssi), GFP_KERNEL);
>> What happens if this allocation fails? If the I/O can succeed without the
>> DMA buffer then you will run into trouble when deriving sa.
> Added check for NULL.

With these changes

Reviewed-by: Matthew R. Ochs <mrochs@linux.vnet.ibm.com>


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

* Re: [PATCH 1 22/25] hpsa: enhance device messages
  2015-10-30 14:32   ` Tomas Henzl
@ 2015-11-02 16:54     ` Don Brace
  2015-11-03 13:12       ` Tomas Henzl
  0 siblings, 1 reply; 107+ messages in thread
From: Don Brace @ 2015-11-02 16:54 UTC (permalink / raw)
  To: Tomas Henzl, scott.teel, Kevin.Barnett, scott.benesh,
	james.bottomley, hch, Justin.Lindley, elliott
  Cc: linux-scsi

On 10/30/2015 09:32 AM, Tomas Henzl wrote:
> RAID_UNKNOWN is used in few other places - raid_level_show for example,

raid_level_show handles physical devices by using "N/A", otherwise it 
displays
the RAID level for logical devices.

Other functions avoid the use of raid_type when the drive is not a RAID 
device.

Or, am I missing your point?


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

* Re: [PATCH 1 24/25] hpsa: add in sas transport class
  2015-10-28 22:06 ` [PATCH 1 24/25] hpsa: add in sas transport class Don Brace
                     ` (2 preceding siblings ...)
  2015-10-30 20:07   ` Matthew R. Ochs
@ 2015-11-03  0:40   ` kbuild test robot
  3 siblings, 0 replies; 107+ messages in thread
From: kbuild test robot @ 2015-11-03  0:40 UTC (permalink / raw)
  To: Don Brace
  Cc: kbuild-all, scott.teel, Kevin.Barnett, scott.benesh,
	james.bottomley, hch, Justin.Lindley, elliott, linux-scsi

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

Hi Kevin,

[auto build test ERROR on scsi/for-next -- if it's inappropriate base, please suggest rules for selecting the more suitable base]

url:    https://github.com/0day-ci/linux/commits/Don-Brace/hpsa-updates/20151029-061230
config: i386-randconfig-b0-11030633 (attached as .config)
reproduce:
        # save the attached .config to linux build tree
        make ARCH=i386 

All errors (new ones prefixed by >>):

   drivers/built-in.o: In function `hpsa_free_sas_phy':
>> hpsa.c:(.text+0x11439a): undefined reference to `sas_port_delete_phy'
>> hpsa.c:(.text+0x1143a1): undefined reference to `sas_phy_free'
   drivers/built-in.o: In function `hpsa_free_sas_port':
>> hpsa.c:(.text+0x1143e5): undefined reference to `sas_port_delete'
   drivers/built-in.o: In function `hpsa_alloc_sas_port':
>> hpsa.c:(.text+0x11457a): undefined reference to `sas_port_alloc_num'
>> hpsa.c:(.text+0x114585): undefined reference to `sas_port_add'
>> hpsa.c:(.text+0x1145b0): undefined reference to `sas_port_free'
   drivers/built-in.o: In function `hpsa_scan_start':
>> hpsa.c:(.text+0x11a725): undefined reference to `sas_phy_alloc'
>> hpsa.c:(.text+0x11a7c2): undefined reference to `sas_phy_add'
>> hpsa.c:(.text+0x11a7d4): undefined reference to `sas_port_add_phy'
>> hpsa.c:(.text+0x11b2f9): undefined reference to `sas_end_device_alloc'
>> hpsa.c:(.text+0x11b331): undefined reference to `sas_rphy_add'
   drivers/built-in.o: In function `hpsa_init':
>> hpsa.c:(.init.text+0xb4b9): undefined reference to `sas_attach_transport'
>> hpsa.c:(.init.text+0xb4ea): undefined reference to `sas_release_transport'
   drivers/built-in.o: In function `hpsa_cleanup':
>> hpsa.c:(.exit.text+0xf72): undefined reference to `sas_release_transport'

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

[-- Attachment #2: .config.gz --]
[-- Type: application/octet-stream, Size: 28206 bytes --]

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

* Re: [PATCH 1 00/25] hpsa updates
  2015-10-28 22:04 [PATCH 1 00/25] hpsa updates Don Brace
                   ` (24 preceding siblings ...)
  2015-10-28 22:07 ` [PATCH 1 25/25] hpsa: bump the driver version Don Brace
@ 2015-11-03  4:49 ` Martin K. Petersen
  25 siblings, 0 replies; 107+ messages in thread
From: Martin K. Petersen @ 2015-11-03  4:49 UTC (permalink / raw)
  To: Don Brace
  Cc: scott.teel, Kevin.Barnett, scott.benesh, james.bottomley, hch,
	Justin.Lindley, elliott, linux-scsi

>>>>> "Don" == Don Brace <don.brace@pmcs.com> writes:

Don,

There were several minor nits in the review comments. Please address
these and repost with the relevant Reviewed-by tags added so we can get
this series queued up.

Thanks!

-- 
Martin K. Petersen	Oracle Linux Engineering

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

* Re: [PATCH 1 22/25] hpsa: enhance device messages
  2015-11-02 16:54     ` Don Brace
@ 2015-11-03 13:12       ` Tomas Henzl
  0 siblings, 0 replies; 107+ messages in thread
From: Tomas Henzl @ 2015-11-03 13:12 UTC (permalink / raw)
  To: Don Brace, scott.teel, Kevin.Barnett, scott.benesh,
	james.bottomley, hch, Justin.Lindley, elliott
  Cc: linux-scsi

On 2.11.2015 17:54, Don Brace wrote:
> On 10/30/2015 09:32 AM, Tomas Henzl wrote:
>> RAID_UNKNOWN is used in few other places - raid_level_show for example,
> raid_level_show handles physical devices by using "N/A", otherwise it 
> displays
> the RAID level for logical devices.
>
> Other functions avoid the use of raid_type when the drive is not a RAID 
> device.
>
> Or, am I missing your point?

Seems that I missed the fact that raid_level_show output is N/A,
I thought it would be "RAID-Unknown".

Last minor point is that you could replace 
+				dev->raid_level > RAID_UNKNOWN ? "?" :
+				raid_label[dev->raid_level]);
with
+				dev->raid_level > RAID_UNKNOWN ? raid_label[RAID_UNKNOWN] :
+				raid_label[dev->raid_level]);
but that's not important.

Reviewed-by: Tomas Henzl <thenzl@redhat.com>

Tomas


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

end of thread, other threads:[~2015-11-03 13:12 UTC | newest]

Thread overview: 107+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-10-28 22:04 [PATCH 1 00/25] hpsa updates Don Brace
2015-10-28 22:04 ` [PATCH 1 01/25] hpsa: stop zeroing reset_cmds_out and ioaccel_cmds_out during rescan Don Brace
2015-10-29 13:25   ` Tomas Henzl
2015-10-30  7:45   ` Hannes Reinecke
2015-10-28 22:04 ` [PATCH 1 02/25] hpsa: remove unused hpsa_tag_discard_error_bits Don Brace
2015-10-29 13:26   ` Tomas Henzl
2015-10-29 14:37   ` Manoj Kumar
2015-10-29 14:49     ` Don Brace
2015-10-30  7:46   ` Hannes Reinecke
2015-10-28 22:04 ` [PATCH 1 03/25] hpsa: check for null arguments to dev_printk Don Brace
2015-10-29 13:41   ` Tomas Henzl
2015-10-29 14:41   ` Manoj Kumar
2015-10-30  7:47   ` Hannes Reinecke
2015-10-30 14:16     ` Don Brace
2015-10-28 22:04 ` [PATCH 1 04/25] hpsa: fix null device issues Don Brace
2015-10-29 14:06   ` Tomas Henzl
2015-10-30  7:49   ` Hannes Reinecke
2015-10-28 22:05 ` [PATCH 1 05/25] hpsa: allow driver requested rescans Don Brace
2015-10-30  7:51   ` Hannes Reinecke
2015-10-28 22:05 ` [PATCH 1 06/25] hpsa: abandon rescans on memory alloaction failures Don Brace
2015-10-30  7:53   ` Hannes Reinecke
2015-10-30 20:44     ` Don Brace
2015-10-28 22:05 ` [PATCH 1 07/25] hpsa: correct transfer length for 6 byte read/write commands Don Brace
2015-10-30  7:54   ` Hannes Reinecke
2015-10-28 22:05 ` [PATCH 1 08/25] hpsa: fix hpsa_adjust_hpsa_scsi_table Don Brace
2015-10-29 14:23   ` Tomas Henzl
2015-10-30  7:57   ` Hannes Reinecke
2015-10-30 20:46     ` Don Brace
2015-10-28 22:05 ` [PATCH 1 09/25] hpsa: fix physical target reset Don Brace
2015-10-29 14:30   ` Tomas Henzl
2015-10-29 15:29     ` Don Brace
2015-10-29 15:52       ` Tomas Henzl
2015-10-30  7:59   ` Hannes Reinecke
2015-10-28 22:05 ` [PATCH 1 10/25] hpsa: correct check for non-disk devices Don Brace
2015-10-29 14:37   ` Tomas Henzl
2015-10-30  8:01   ` Hannes Reinecke
2015-10-28 22:05 ` [PATCH 1 11/25] hpsa: correct ioaccel2 sg chain len Don Brace
2015-10-29 15:01   ` Tomas Henzl
2015-10-30  8:01   ` Hannes Reinecke
2015-10-28 22:05 ` [PATCH 1 12/25] hpsa: simplify check for device exposure Don Brace
2015-10-29 15:03   ` Tomas Henzl
2015-10-30  8:04   ` Hannes Reinecke
2015-10-28 22:05 ` [PATCH 1 13/25] hpsa: simplify update scsi devices Don Brace
2015-10-29 15:53   ` Tomas Henzl
2015-10-29 16:43   ` Matthew R. Ochs
2015-10-29 19:01     ` Don Brace
2015-10-29 20:28       ` Matthew R. Ochs
2015-10-30  8:05   ` Hannes Reinecke
2015-10-28 22:05 ` [PATCH 1 14/25] hpsa: add function is_logical_device Don Brace
2015-10-29 15:53   ` Tomas Henzl
2015-10-29 16:46   ` Matthew R. Ochs
2015-10-30  8:05   ` Hannes Reinecke
2015-10-28 22:06 ` [PATCH 1 15/25] hpsa: enhance hpsa_get_device_id Don Brace
2015-10-29 16:04   ` Tomas Henzl
2015-10-29 17:04   ` Matthew R. Ochs
2015-10-30  8:08   ` Hannes Reinecke
2015-10-30 20:59     ` Don Brace
2015-10-28 22:06 ` [PATCH 1 16/25] hpsa: refactor hpsa_figure_bus_target_lun Don Brace
2015-10-29 16:27   ` Tomas Henzl
2015-10-30  8:09   ` Hannes Reinecke
2015-10-28 22:06 ` [PATCH 1 17/25] hpsa: move scsi_add_device and scsi_remove_device calls to new function Don Brace
2015-10-29 16:37   ` Tomas Henzl
2015-10-29 17:21   ` Matthew R. Ochs
2015-10-29 20:30     ` Don Brace
2015-10-30 15:56       ` Matthew R. Ochs
2015-10-30  8:09   ` Hannes Reinecke
2015-10-28 22:06 ` [PATCH 1 18/25] External array LUNs must use target and lun numbers assigned by the Don Brace
2015-10-29 19:41   ` Matthew R. Ochs
2015-10-30  8:11   ` Hannes Reinecke
2015-10-30 14:11   ` Tomas Henzl
2015-10-28 22:06 ` [PATCH 1 19/25] hpsa: eliminate fake lun0 enclosures Don Brace
2015-10-29 20:05   ` Matthew R. Ochs
2015-10-30  8:12   ` Hannes Reinecke
2015-10-30 14:12   ` Tomas Henzl
2015-10-28 22:06 ` [PATCH 1 20/25] hpsa: add discovery polling for PT RAID devices Don Brace
2015-10-29 20:20   ` Matthew R. Ochs
     [not found]     ` <563286B7.8070200@pmcs.com>
2015-10-29 20:59       ` Matthew R. Ochs
2015-10-30 14:08         ` Don Brace
2015-10-30 15:58           ` Matthew R. Ochs
2015-10-30  8:15   ` Hannes Reinecke
2015-10-28 22:06 ` [PATCH 1 21/25] hpsa: disable report lun data caching Don Brace
2015-10-30  8:16   ` Hannes Reinecke
2015-10-30 14:25   ` Tomas Henzl
2015-10-30 21:18     ` Don Brace
2015-10-30 16:27   ` Matthew R. Ochs
2015-10-28 22:06 ` [PATCH 1 22/25] hpsa: enhance device messages Don Brace
2015-10-30  8:16   ` Hannes Reinecke
2015-10-30 14:32   ` Tomas Henzl
2015-11-02 16:54     ` Don Brace
2015-11-03 13:12       ` Tomas Henzl
2015-10-30 16:53   ` Matthew R. Ochs
2015-10-28 22:06 ` [PATCH 1 23/25] hpsa: fix multiple issues in path_info_show Don Brace
2015-10-30  8:18   ` Hannes Reinecke
2015-10-30 14:33   ` Tomas Henzl
2015-10-30 17:07   ` Matthew R. Ochs
2015-10-28 22:06 ` [PATCH 1 24/25] hpsa: add in sas transport class Don Brace
2015-10-30  8:21   ` Hannes Reinecke
2015-10-30 14:40   ` Tomas Henzl
2015-10-30 20:07   ` Matthew R. Ochs
2015-10-30 22:00     ` Don Brace
2015-10-30 23:23       ` Matthew R. Ochs
2015-11-03  0:40   ` kbuild test robot
2015-10-28 22:07 ` [PATCH 1 25/25] hpsa: bump the driver version Don Brace
2015-10-30  8:22   ` Hannes Reinecke
2015-10-30 14:44   ` Tomas Henzl
2015-10-30 20:08   ` Matthew R. Ochs
2015-11-03  4:49 ` [PATCH 1 00/25] hpsa updates Martin K. Petersen

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.