All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] hpsa: use bus '3' for legacy HBA devices
@ 2016-11-17 11:15 Hannes Reinecke
  2016-11-17 21:36 ` Don Brace
  2016-11-18  1:28 ` Martin K. Petersen
  0 siblings, 2 replies; 3+ messages in thread
From: Hannes Reinecke @ 2016-11-17 11:15 UTC (permalink / raw)
  To: Don Brace
  Cc: Martin K. Petersen, Christoph Hellwig, James Bottomley,
	Johannes Thumshirn, Jack Suter, linux-scsi, Hannes Reinecke,
	Hannes Reinecke

Older controllers use SCSI target id '0' for the first internal
disk. As the controllers are now placed on the same bus than the
internal disks this leads to a clash with the SCSI target id of
controller.
This patch checks the SCSI revision, and moves older controller
to bus '3' to be compatible with older releases and avoid this
problem.

Fixes: 09371d623c9 ("hpsa: Change SAS transport devices to bus 0.")
Signed-off-by: Hannes Reinecke <hare@suse.com>
---
 drivers/scsi/hpsa.c | 14 ++++++++++----
 drivers/scsi/hpsa.h |  2 ++
 2 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
index ef4e81a..d0a22aa 100644
--- a/drivers/scsi/hpsa.c
+++ b/drivers/scsi/hpsa.c
@@ -2034,7 +2034,8 @@ static int hpsa_slave_alloc(struct scsi_device *sdev)
 			sd->target = sdev_id(sdev);
 			sd->lun = sdev->lun;
 		}
-	} else
+	}
+	if (!sd)
 		sd = lookup_hpsa_scsi_dev(h, sdev_channel(sdev),
 					sdev_id(sdev), sdev->lun);
 
@@ -3850,6 +3851,7 @@ static int hpsa_update_device_info(struct ctlr_info *h,
 		sizeof(this_device->vendor));
 	memcpy(this_device->model, &inq_buff[16],
 		sizeof(this_device->model));
+	this_device->rev = inq_buff[2];
 	memset(this_device->device_id, 0,
 		sizeof(this_device->device_id));
 	if (hpsa_get_device_id(h, scsi3addr, this_device->device_id, 8,
@@ -3939,10 +3941,14 @@ static void figure_bus_target_lun(struct ctlr_info *h,
 
 	if (!is_logical_dev_addr_mode(lunaddrbytes)) {
 		/* physical device, target and lun filled in later */
-		if (is_hba_lunid(lunaddrbytes))
+		if (is_hba_lunid(lunaddrbytes)) {
+			int bus = HPSA_HBA_BUS;
+
+			if (!device->rev)
+				bus = HPSA_LEGACY_HBA_BUS;
 			hpsa_set_bus_target_lun(device,
-					HPSA_HBA_BUS, 0, lunid & 0x3fff);
-		else
+					bus, 0, lunid & 0x3fff);
+		} else
 			/* defer target, lun assignment for physical devices */
 			hpsa_set_bus_target_lun(device,
 					HPSA_PHYSICAL_DEVICE_BUS, -1, -1);
diff --git a/drivers/scsi/hpsa.h b/drivers/scsi/hpsa.h
index 3faf6cf..64e9829 100644
--- a/drivers/scsi/hpsa.h
+++ b/drivers/scsi/hpsa.h
@@ -69,6 +69,7 @@ struct hpsa_scsi_dev_t {
 	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 rev;		/* byte 2 of inquiry data */
 	unsigned char raid_level;	/* from inquiry page 0xC1 */
 	unsigned char volume_offline;	/* discovered via TUR or VPD */
 	u16 queue_depth;		/* max queue_depth for this device */
@@ -400,6 +401,7 @@ struct offline_device_entry {
 #define HPSA_RAID_VOLUME_BUS		1
 #define HPSA_EXTERNAL_RAID_VOLUME_BUS	2
 #define HPSA_HBA_BUS			0
+#define HPSA_LEGACY_HBA_BUS		3
 
 /*
 	Send the command to the hardware
-- 
1.8.5.6


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

* RE: [PATCH] hpsa: use bus '3' for legacy HBA devices
  2016-11-17 11:15 [PATCH] hpsa: use bus '3' for legacy HBA devices Hannes Reinecke
@ 2016-11-17 21:36 ` Don Brace
  2016-11-18  1:28 ` Martin K. Petersen
  1 sibling, 0 replies; 3+ messages in thread
From: Don Brace @ 2016-11-17 21:36 UTC (permalink / raw)
  To: Hannes Reinecke
  Cc: Martin K. Petersen, Christoph Hellwig, James Bottomley,
	Johannes Thumshirn, Jack Suter, linux-scsi, Hannes Reinecke

> -----Original Message-----
> From: Hannes Reinecke [mailto:hare@suse.de]
> Sent: Thursday, November 17, 2016 5:16 AM
> To: Don Brace
> Cc: Martin K. Petersen; Christoph Hellwig; James Bottomley; Johannes
> Thumshirn; Jack Suter; linux-scsi@vger.kernel.org; Hannes Reinecke; Hannes
> Reinecke
> Subject: [PATCH] hpsa: use bus '3' for legacy HBA devices
> 
> EXTERNAL EMAIL
> 
> 
> Older controllers use SCSI target id '0' for the first internal
> disk. As the controllers are now placed on the same bus than the
> internal disks this leads to a clash with the SCSI target id of
> controller.
> This patch checks the SCSI revision, and moves older controller
> to bus '3' to be compatible with older releases and avoid this
> problem.
> 
> Fixes: 09371d623c9 ("hpsa: Change SAS transport devices to bus 0.")
> Signed-off-by: Hannes Reinecke <hare@suse.com>

Acked-by: Don Brace <don.brace@microsemi.com>


> ---
>  drivers/scsi/hpsa.c | 14 ++++++++++----
>  drivers/scsi/hpsa.h |  2 ++
>  2 files changed, 12 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
> index ef4e81a..d0a22aa 100644
> --- a/drivers/scsi/hpsa.c
> +++ b/drivers/scsi/hpsa.c
> @@ -2034,7 +2034,8 @@ static int hpsa_slave_alloc(struct scsi_device *sdev)
>                         sd->target = sdev_id(sdev);
>                         sd->lun = sdev->lun;
>                 }
> -       } else
> +       }
> +       if (!sd)
>                 sd = lookup_hpsa_scsi_dev(h, sdev_channel(sdev),
>                                         sdev_id(sdev), sdev->lun);
> 
> @@ -3850,6 +3851,7 @@ static int hpsa_update_device_info(struct ctlr_info
> *h,
>                 sizeof(this_device->vendor));
>         memcpy(this_device->model, &inq_buff[16],
>                 sizeof(this_device->model));
> +       this_device->rev = inq_buff[2];
>         memset(this_device->device_id, 0,
>                 sizeof(this_device->device_id));
>         if (hpsa_get_device_id(h, scsi3addr, this_device->device_id, 8,
> @@ -3939,10 +3941,14 @@ static void figure_bus_target_lun(struct ctlr_info
> *h,
> 
>         if (!is_logical_dev_addr_mode(lunaddrbytes)) {
>                 /* physical device, target and lun filled in later */
> -               if (is_hba_lunid(lunaddrbytes))
> +               if (is_hba_lunid(lunaddrbytes)) {
> +                       int bus = HPSA_HBA_BUS;
> +
> +                       if (!device->rev)
> +                               bus = HPSA_LEGACY_HBA_BUS;
>                         hpsa_set_bus_target_lun(device,
> -                                       HPSA_HBA_BUS, 0, lunid & 0x3fff);
> -               else
> +                                       bus, 0, lunid & 0x3fff);
> +               } else
>                         /* defer target, lun assignment for physical devices */
>                         hpsa_set_bus_target_lun(device,
>                                         HPSA_PHYSICAL_DEVICE_BUS, -1, -1);
> diff --git a/drivers/scsi/hpsa.h b/drivers/scsi/hpsa.h
> index 3faf6cf..64e9829 100644
> --- a/drivers/scsi/hpsa.h
> +++ b/drivers/scsi/hpsa.h
> @@ -69,6 +69,7 @@ struct hpsa_scsi_dev_t {
>         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 rev;              /* byte 2 of inquiry data */
>         unsigned char raid_level;       /* from inquiry page 0xC1 */
>         unsigned char volume_offline;   /* discovered via TUR or VPD */
>         u16 queue_depth;                /* max queue_depth for this device */
> @@ -400,6 +401,7 @@ struct offline_device_entry {
>  #define HPSA_RAID_VOLUME_BUS           1
>  #define HPSA_EXTERNAL_RAID_VOLUME_BUS  2
>  #define HPSA_HBA_BUS                   0
> +#define HPSA_LEGACY_HBA_BUS            3
> 
>  /*
>         Send the command to the hardware
> --
> 1.8.5.6


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

* Re: [PATCH] hpsa: use bus '3' for legacy HBA devices
  2016-11-17 11:15 [PATCH] hpsa: use bus '3' for legacy HBA devices Hannes Reinecke
  2016-11-17 21:36 ` Don Brace
@ 2016-11-18  1:28 ` Martin K. Petersen
  1 sibling, 0 replies; 3+ messages in thread
From: Martin K. Petersen @ 2016-11-18  1:28 UTC (permalink / raw)
  To: Hannes Reinecke
  Cc: Don Brace, Martin K. Petersen, Christoph Hellwig,
	James Bottomley, Johannes Thumshirn, Jack Suter, linux-scsi,
	Hannes Reinecke

>>>>> "Hannes" == Hannes Reinecke <hare@suse.de> writes:

Hannes> Older controllers use SCSI target id '0' for the first internal
Hannes> disk. As the controllers are now placed on the same bus than the
Hannes> internal disks this leads to a clash with the SCSI target id of
Hannes> controller.  This patch checks the SCSI revision, and moves
Hannes> older controller to bus '3' to be compatible with older releases
Hannes> and avoid this problem.

Applied to 4.9/scsi-fixes.

-- 
Martin K. Petersen	Oracle Linux Engineering

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

end of thread, other threads:[~2016-11-18  1:28 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-11-17 11:15 [PATCH] hpsa: use bus '3' for legacy HBA devices Hannes Reinecke
2016-11-17 21:36 ` Don Brace
2016-11-18  1:28 ` 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.