Skip to content

Commit

Permalink
isci: fix sas address reporting
Browse files Browse the repository at this point in the history
Undo the open coded and incorrect translation of the oem parameter sas
address to its libsas expected format.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
  • Loading branch information
Dan Williams committed Jul 3, 2011
1 parent 7392d27 commit 150fc6f
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 38 deletions.
5 changes: 0 additions & 5 deletions drivers/scsi/isci/host.c
Original file line number Diff line number Diff line change
Expand Up @@ -517,11 +517,6 @@ int isci_host_init(struct isci_host *isci_host)
for (index = 0; index < SCI_MAX_PHYS; index++)
isci_phy_init(&isci_host->phys[index], isci_host, index);

/* Why are we doing this? Is this even necessary? */
memcpy(&isci_host->sas_addr[0],
&isci_host->phys[0].sas_addr[0],
SAS_ADDR_SIZE);

/* Start the ports */
for (index = 0; index < SCI_MAX_PORTS; index++) {
scic_controller_get_port_handle(controller, index, &scic_port);
Expand Down
1 change: 0 additions & 1 deletion drivers/scsi/isci/host.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@ struct isci_host {
spinlock_t state_lock;

struct pci_dev *pdev;
u8 sas_addr[SAS_ADDR_SIZE];

enum isci_status status;
#define IHOST_START_PENDING 0
Expand Down
2 changes: 1 addition & 1 deletion drivers/scsi/isci/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ static int isci_register_sas_ha(struct isci_host *isci_host)

sas_ha->sas_ha_name = DRV_NAME;
sas_ha->lldd_module = THIS_MODULE;
sas_ha->sas_addr = &(isci_host->sas_addr[0]);
sas_ha->sas_addr = &isci_host->phys[0].sas_addr[0];

/* set the array of phy and port structs. */
for (i = 0; i < SCI_MAX_PHYS; i++) {
Expand Down
32 changes: 11 additions & 21 deletions drivers/scsi/isci/phy.c
Original file line number Diff line number Diff line change
Expand Up @@ -75,39 +75,29 @@ void isci_phy_init(
struct isci_host *isci_host,
int index)
{
struct scic_sds_controller *controller = isci_host->core_controller;
struct scic_sds_controller *scic = isci_host->core_controller;
struct scic_sds_phy *scic_phy;
union scic_oem_parameters oem_parameters;
union scic_oem_parameters oem;
enum sci_status status = SCI_SUCCESS;
u64 sas_addr;

/*--------------- SCU_Phy Initialization Stuff -----------------------*/

status = scic_controller_get_phy_handle(controller, index, &scic_phy);
status = scic_controller_get_phy_handle(scic, index, &scic_phy);
if (status == SCI_SUCCESS) {
sci_object_set_association(scic_phy, (void *)phy);
phy->sci_phy_handle = scic_phy;
} else
dev_err(&isci_host->pdev->dev,
"failed scic_controller_get_phy_handle\n");

scic_oem_parameters_get(controller, &oem_parameters);

phy->sas_addr[0] = oem_parameters.sds1.phys[index].sas_address.low
& 0xFF;
phy->sas_addr[1] = (oem_parameters.sds1.phys[index].sas_address.low
>> 8) & 0xFF;
phy->sas_addr[2] = (oem_parameters.sds1.phys[index].sas_address.low
>> 16) & 0xFF;
phy->sas_addr[3] = (oem_parameters.sds1.phys[index].sas_address.low
>> 24) & 0xFF;
phy->sas_addr[4] = oem_parameters.sds1.phys[index].sas_address.high
& 0xFF;
phy->sas_addr[5] = (oem_parameters.sds1.phys[index].sas_address.high
>> 8) & 0xFF;
phy->sas_addr[6] = (oem_parameters.sds1.phys[index].sas_address.high
>> 16) & 0xFF;
phy->sas_addr[7] = (oem_parameters.sds1.phys[index].sas_address.high
>> 24) & 0xFF;
scic_oem_parameters_get(scic, &oem);
sas_addr = oem.sds1.phys[index].sas_address.high;
sas_addr <<= 32;
sas_addr |= oem.sds1.phys[index].sas_address.low;
swab64s(&sas_addr);

memcpy(phy->sas_addr, &sas_addr, sizeof(sas_addr));

phy->isci_port = NULL;
phy->sas_phy.enabled = 0;
Expand Down
17 changes: 7 additions & 10 deletions drivers/scsi/isci/port.c
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ void isci_port_link_up(
scic_port_get_properties(port, &properties);

if (properties.remote.protocols.u.bits.stp_target) {
u64 attached_sas_address;

struct scic_sata_phy_properties sata_phy_properties;

Expand Down Expand Up @@ -220,17 +221,13 @@ void isci_port_link_up(
* will not be the same as assigned to the PHY and needs
* to be obtained from struct scic_port_properties properties.
*/
attached_sas_address = properties.remote.sas_address.high;
attached_sas_address <<= 32;
attached_sas_address |= properties.remote.sas_address.low;
swab64s(&attached_sas_address);

BUG_ON(((size_t)SAS_ADDR_SIZE / 2)
!= sizeof(properties.remote.sas_address.low));

memcpy(&isci_phy->sas_phy.attached_sas_addr[0],
&properties.remote.sas_address.low,
SAS_ADDR_SIZE / 2);

memcpy(&isci_phy->sas_phy.attached_sas_addr[4],
&properties.remote.sas_address.high,
SAS_ADDR_SIZE / 2);
memcpy(&isci_phy->sas_phy.attached_sas_addr,
&attached_sas_address, sizeof(attached_sas_address));

} else if (properties.remote.protocols.u.bits.ssp_target ||
properties.remote.protocols.u.bits.smp_target) {
Expand Down

0 comments on commit 150fc6f

Please sign in to comment.