@@ -1669,7 +1669,8 @@ void mpt3sas_device_remove_by_sas_address(struct MPT3SAS_ADAPTER *ioc,
u8 mpt3sas_check_for_pending_internal_cmds(struct MPT3SAS_ADAPTER *ioc,
u16 smid);
struct hba_port *
-mpt3sas_get_port_by_id(struct MPT3SAS_ADAPTER *ioc, u8 port);
+mpt3sas_get_port_by_id(struct MPT3SAS_ADAPTER *ioc, u8 port,
+ u8 bypass_dirty_port_flag);
struct _sas_node *mpt3sas_scsih_expander_find_by_handle(
struct MPT3SAS_ADAPTER *ioc, u16 handle);
@@ -361,20 +361,27 @@ _scsih_srch_boot_encl_slot(u64 enclosure_logical_id, u16 slot_number,
* port number from port list
* @ioc: per adapter object
* @port_id: port number
+ * @bypass_dirty_port_flag: when set look the matching hba port entry even
+ * if hba port entry is marked as dirty.
*
* Search for hba port entry corresponding to provided port number,
* if available return port object otherwise return NULL.
*/
struct hba_port *
-mpt3sas_get_port_by_id(struct MPT3SAS_ADAPTER *ioc, u8 port_id)
+mpt3sas_get_port_by_id(struct MPT3SAS_ADAPTER *ioc,
+ u8 port_id, u8 bypass_dirty_port_flag)
{
struct hba_port *port, *port_next;
list_for_each_entry_safe(port, port_next,
&ioc->port_table_list, list) {
- if (port->port_id == port_id &&
- !(port->flags & HBA_PORT_FLAG_DIRTY_PORT))
+ if (port->port_id != port_id)
+ continue;
+ if (bypass_dirty_port_flag)
return port;
+ if (port->flags & HBA_PORT_FLAG_DIRTY_PORT)
+ continue;
+ return port;
}
return NULL;
@@ -5991,7 +5998,7 @@ _scsih_alloc_vphy(struct MPT3SAS_ADAPTER *ioc, u8 port_id, u8 phy_num)
struct virtual_phy *vphy;
struct hba_port *port;
- port = mpt3sas_get_port_by_id(ioc, port_id);
+ port = mpt3sas_get_port_by_id(ioc, port_id, 0);
if (!port)
return NULL;
@@ -6065,7 +6072,7 @@ _scsih_sas_host_refresh(struct MPT3SAS_ADAPTER *ioc)
ioc->sas_hba.handle = le16_to_cpu(
sas_iounit_pg0->PhyData[0].ControllerDevHandle);
port_id = sas_iounit_pg0->PhyData[i].Port;
- if (!(mpt3sas_get_port_by_id(ioc, port_id))) {
+ if (!(mpt3sas_get_port_by_id(ioc, port_id, 0))) {
port = kzalloc(sizeof(struct hba_port), GFP_KERNEL);
if (!port)
goto out;
@@ -6108,7 +6115,8 @@ _scsih_sas_host_refresh(struct MPT3SAS_ADAPTER *ioc)
AttachedDevHandle);
if (attached_handle && link_rate < MPI2_SAS_NEG_LINK_RATE_1_5)
link_rate = MPI2_SAS_NEG_LINK_RATE_1_5;
- ioc->sas_hba.phy[i].port = mpt3sas_get_port_by_id(ioc, port_id);
+ ioc->sas_hba.phy[i].port =
+ mpt3sas_get_port_by_id(ioc, port_id, 0);
mpt3sas_transport_update_links(ioc, ioc->sas_hba.sas_address,
attached_handle, i, link_rate,
ioc->sas_hba.phy[i].port);
@@ -6232,7 +6240,7 @@ _scsih_sas_host_add(struct MPT3SAS_ADAPTER *ioc)
PhyData[0].ControllerDevHandle);
port_id = sas_iounit_pg0->PhyData[i].Port;
- if (!(mpt3sas_get_port_by_id(ioc, port_id))) {
+ if (!(mpt3sas_get_port_by_id(ioc, port_id, 0))) {
port = kzalloc(sizeof(struct hba_port), GFP_KERNEL);
if (!port)
goto out;
@@ -6262,7 +6270,8 @@ _scsih_sas_host_add(struct MPT3SAS_ADAPTER *ioc)
ioc->sas_hba.phy[i].handle = ioc->sas_hba.handle;
ioc->sas_hba.phy[i].phy_id = i;
- ioc->sas_hba.phy[i].port = mpt3sas_get_port_by_id(ioc, port_id);
+ ioc->sas_hba.phy[i].port =
+ mpt3sas_get_port_by_id(ioc, port_id, 0);
mpt3sas_transport_add_host_phy(ioc, &ioc->sas_hba.phy[i],
phy_pg0, ioc->sas_hba.parent_dev);
}
@@ -6354,7 +6363,8 @@ _scsih_expander_add(struct MPT3SAS_ADAPTER *ioc, u16 handle)
if (sas_address_parent != ioc->sas_hba.sas_address) {
spin_lock_irqsave(&ioc->sas_node_lock, flags);
sas_expander = mpt3sas_scsih_expander_find_by_sas_address(ioc,
- sas_address_parent, mpt3sas_get_port_by_id(ioc, port_id));
+ sas_address_parent,
+ mpt3sas_get_port_by_id(ioc, port_id, 0));
spin_unlock_irqrestore(&ioc->sas_node_lock, flags);
if (!sas_expander) {
rc = _scsih_expander_add(ioc, parent_handle);
@@ -6366,7 +6376,7 @@ _scsih_expander_add(struct MPT3SAS_ADAPTER *ioc, u16 handle)
spin_lock_irqsave(&ioc->sas_node_lock, flags);
sas_address = le64_to_cpu(expander_pg0.SASAddress);
sas_expander = mpt3sas_scsih_expander_find_by_sas_address(ioc,
- sas_address, mpt3sas_get_port_by_id(ioc, port_id));
+ sas_address, mpt3sas_get_port_by_id(ioc, port_id, 0));
spin_unlock_irqrestore(&ioc->sas_node_lock, flags);
if (sas_expander)
@@ -6384,7 +6394,7 @@ _scsih_expander_add(struct MPT3SAS_ADAPTER *ioc, u16 handle)
sas_expander->num_phys = expander_pg0.NumPhys;
sas_expander->sas_address_parent = sas_address_parent;
sas_expander->sas_address = sas_address;
- sas_expander->port = mpt3sas_get_port_by_id(ioc, port_id);
+ sas_expander->port = mpt3sas_get_port_by_id(ioc, port_id, 0);
if (!sas_expander->port) {
ioc_err(ioc, "failure at %s:%d/%s()!\n",
__FILE__, __LINE__, __func__);
@@ -6429,7 +6439,8 @@ _scsih_expander_add(struct MPT3SAS_ADAPTER *ioc, u16 handle)
}
sas_expander->phy[i].handle = handle;
sas_expander->phy[i].phy_id = i;
- sas_expander->phy[i].port = mpt3sas_get_port_by_id(ioc, port_id);
+ sas_expander->phy[i].port =
+ mpt3sas_get_port_by_id(ioc, port_id, 0);
if ((mpt3sas_transport_add_expander_phy(ioc,
&sas_expander->phy[i], expander_pg1,
@@ -6636,7 +6647,7 @@ _scsih_check_device(struct MPT3SAS_ADAPTER *ioc,
spin_lock_irqsave(&ioc->sas_device_lock, flags);
sas_address = le64_to_cpu(sas_device_pg0.SASAddress);
- port = mpt3sas_get_port_by_id(ioc, sas_device_pg0.PhysicalPort);
+ port = mpt3sas_get_port_by_id(ioc, sas_device_pg0.PhysicalPort, 0);
if (!port)
goto out_unlock;
sas_device = __mpt3sas_get_sdev_by_addr(ioc,
@@ -6769,7 +6780,7 @@ _scsih_add_device(struct MPT3SAS_ADAPTER *ioc, u16 handle, u8 phy_num,
port_id = sas_device_pg0.PhysicalPort;
sas_device = mpt3sas_get_sdev_by_addr(ioc,
- sas_address, mpt3sas_get_port_by_id(ioc, port_id));
+ sas_address, mpt3sas_get_port_by_id(ioc, port_id, 0));
if (sas_device) {
clear_bit(handle, ioc->pend_os_device_add);
sas_device_put(sas_device);
@@ -6810,7 +6821,7 @@ _scsih_add_device(struct MPT3SAS_ADAPTER *ioc, u16 handle, u8 phy_num,
sas_device->phy = sas_device_pg0.PhyNum;
sas_device->fast_path = (le16_to_cpu(sas_device_pg0.Flags) &
MPI25_SAS_DEVICE0_FLAGS_FAST_PATH_CAPABLE) ? 1 : 0;
- sas_device->port = mpt3sas_get_port_by_id(ioc, port_id);
+ sas_device->port = mpt3sas_get_port_by_id(ioc, port_id, 0);
if (!sas_device->port) {
ioc_err(ioc, "failure at %s:%d/%s()!\n",
__FILE__, __LINE__, __func__);
@@ -7025,7 +7036,7 @@ _scsih_sas_topology_change_event(struct MPT3SAS_ADAPTER *ioc,
}
parent_handle = le16_to_cpu(event_data->ExpanderDevHandle);
- port = mpt3sas_get_port_by_id(ioc, event_data->PhysicalPort);
+ port = mpt3sas_get_port_by_id(ioc, event_data->PhysicalPort, 0);
/* handle expander add */
if (event_data->ExpStatus == MPI2_EVENT_SAS_TOPO_ES_ADDED)
@@ -7216,7 +7227,8 @@ _scsih_sas_device_status_change_event(struct MPT3SAS_ADAPTER *ioc,
spin_lock_irqsave(&ioc->sas_device_lock, flags);
sas_address = le64_to_cpu(event_data->SASAddress);
sas_device = __mpt3sas_get_sdev_by_addr(ioc,
- sas_address, mpt3sas_get_port_by_id(ioc, event_data->PhysicalPort));
+ sas_address,
+ mpt3sas_get_port_by_id(ioc, event_data->PhysicalPort, 0));
if (!sas_device || !sas_device->starget)
goto out;
@@ -8657,7 +8669,8 @@ _scsih_sas_pd_add(struct MPT3SAS_ADAPTER *ioc,
if (!_scsih_get_sas_address(ioc, parent_handle, &sas_address))
mpt3sas_transport_update_links(ioc, sas_address, handle,
sas_device_pg0.PhyNum, MPI2_SAS_NEG_LINK_RATE_1_5,
- mpt3sas_get_port_by_id(ioc, sas_device_pg0.PhysicalPort));
+ mpt3sas_get_port_by_id(ioc,
+ sas_device_pg0.PhysicalPort, 0));
_scsih_ir_fastpath(ioc, handle, element->PhysDiskNum);
_scsih_add_device(ioc, handle, 0, 1);
@@ -8965,7 +8978,7 @@ _scsih_sas_ir_physical_disk_event(struct MPT3SAS_ADAPTER *ioc,
mpt3sas_transport_update_links(ioc, sas_address, handle,
sas_device_pg0.PhyNum, MPI2_SAS_NEG_LINK_RATE_1_5,
mpt3sas_get_port_by_id(ioc,
- sas_device_pg0.PhysicalPort));
+ sas_device_pg0.PhysicalPort, 0));
_scsih_add_device(ioc, handle, 0, 1);
@@ -9091,7 +9104,7 @@ Mpi2SasDevicePage0_t *sas_device_pg0)
struct _enclosure_node *enclosure_dev = NULL;
unsigned long flags;
struct hba_port *port = mpt3sas_get_port_by_id(
- ioc, sas_device_pg0->PhysicalPort);
+ ioc, sas_device_pg0->PhysicalPort, 0);
if (sas_device_pg0->EnclosureHandle) {
enclosure_dev =
@@ -9519,7 +9532,7 @@ _scsih_mark_responding_expander(struct MPT3SAS_ADAPTER *ioc,
u16 enclosure_handle = le16_to_cpu(expander_pg0->EnclosureHandle);
u64 sas_address = le64_to_cpu(expander_pg0->SASAddress);
struct hba_port *port = mpt3sas_get_port_by_id(
- ioc, expander_pg0->PhysicalPort);
+ ioc, expander_pg0->PhysicalPort, 0);
if (enclosure_handle)
enclosure_dev =
@@ -9766,7 +9779,7 @@ _scsih_scan_for_devices_after_reset(struct MPT3SAS_ADAPTER *ioc)
port_id = expander_pg0.PhysicalPort;
expander_device = mpt3sas_scsih_expander_find_by_sas_address(
ioc, le64_to_cpu(expander_pg0.SASAddress),
- mpt3sas_get_port_by_id(ioc, port_id));
+ mpt3sas_get_port_by_id(ioc, port_id, 0));
spin_unlock_irqrestore(&ioc->sas_node_lock, flags);
if (expander_device)
_scsih_refresh_expander_links(ioc, expander_device,
@@ -9829,7 +9842,7 @@ _scsih_scan_for_devices_after_reset(struct MPT3SAS_ADAPTER *ioc)
mpt3sas_transport_update_links(ioc, sas_address,
handle, sas_device_pg0.PhyNum,
MPI2_SAS_NEG_LINK_RATE_1_5,
- mpt3sas_get_port_by_id(ioc, port_id));
+ mpt3sas_get_port_by_id(ioc, port_id, 0));
set_bit(handle, ioc->pd_handles);
retry_count = 0;
/* This will retry adding the end device.
@@ -9918,7 +9931,7 @@ _scsih_scan_for_devices_after_reset(struct MPT3SAS_ADAPTER *ioc)
port_id = sas_device_pg0.PhysicalPort;
sas_device = mpt3sas_get_sdev_by_addr(ioc,
le64_to_cpu(sas_device_pg0.SASAddress),
- mpt3sas_get_port_by_id(ioc, port_id));
+ mpt3sas_get_port_by_id(ioc, port_id, 0));
if (sas_device) {
sas_device_put(sas_device);
continue;
@@ -9930,7 +9943,7 @@ _scsih_scan_for_devices_after_reset(struct MPT3SAS_ADAPTER *ioc)
(u64)le64_to_cpu(sas_device_pg0.SASAddress));
mpt3sas_transport_update_links(ioc, sas_address, handle,
sas_device_pg0.PhyNum, MPI2_SAS_NEG_LINK_RATE_1_5,
- mpt3sas_get_port_by_id(ioc, port_id));
+ mpt3sas_get_port_by_id(ioc, port_id, 0));
retry_count = 0;
/* This will retry adding the end device.
* _scsih_add_device() will decide on retries and
@@ -1414,7 +1414,7 @@ _transport_get_linkerrors(struct sas_phy *phy)
spin_lock_irqsave(&ioc->sas_node_lock, flags);
if (_transport_sas_node_find_by_sas_address(ioc,
phy->identify.sas_address,
- mpt3sas_get_port_by_id(ioc, port_id)) == NULL) {
+ mpt3sas_get_port_by_id(ioc, port_id, 0)) == NULL) {
spin_unlock_irqrestore(&ioc->sas_node_lock, flags);
return -EINVAL;
}
@@ -1703,7 +1703,7 @@ _transport_phy_reset(struct sas_phy *phy, int hard_reset)
spin_lock_irqsave(&ioc->sas_node_lock, flags);
if (_transport_sas_node_find_by_sas_address(ioc,
phy->identify.sas_address,
- mpt3sas_get_port_by_id(ioc, port_id)) == NULL) {
+ mpt3sas_get_port_by_id(ioc, port_id, 0)) == NULL) {
spin_unlock_irqrestore(&ioc->sas_node_lock, flags);
return -EINVAL;
}
@@ -1762,7 +1762,7 @@ _transport_phy_enable(struct sas_phy *phy, int enable)
spin_lock_irqsave(&ioc->sas_node_lock, flags);
if (_transport_sas_node_find_by_sas_address(ioc,
phy->identify.sas_address,
- mpt3sas_get_port_by_id(ioc, port_id)) == NULL) {
+ mpt3sas_get_port_by_id(ioc, port_id, 0)) == NULL) {
spin_unlock_irqrestore(&ioc->sas_node_lock, flags);
return -EINVAL;
}
@@ -1902,7 +1902,7 @@ _transport_phy_speed(struct sas_phy *phy, struct sas_phy_linkrates *rates)
spin_lock_irqsave(&ioc->sas_node_lock, flags);
if (_transport_sas_node_find_by_sas_address(ioc,
phy->identify.sas_address,
- mpt3sas_get_port_by_id(ioc, port_id)) == NULL) {
+ mpt3sas_get_port_by_id(ioc, port_id, 0)) == NULL) {
spin_unlock_irqrestore(&ioc->sas_node_lock, flags);
return -EINVAL;
}