1. 04 Nov, 2020 8 commits
    • Sreekanth Reddy's avatar
      scsi: mpt3sas: Update hba_port objects after host reset · a5e99fda
      Sreekanth Reddy authored
      During host reset there is a chance that the Port number allocated by the
      firmware for the attached devices may change. Also, it may be possible that
      some HBA phy's can go down/come up after reset. As a result, the driver
      can't just trust the HBA Port table that it has populated before host reset
      as valid. Instead it has to update the HBA Port table in such a way that it
      shouldn't disturb the drives which are still accessible even after host
      reset.
      
      Use the following algorithm to update the HBA Port table during host reset:
      
      I. After host reset operation and before marking the devices as
         responding/non-responding, create a temporary Port table called "New
         Port table" by parsing each of the HBA phy's Phy data info read from SAS
         IOUnit Page0:
      
         a. Check whether Phy's negotiated link rate is greater than 1.5Gbps, if
            not go to next Phy;
      
         b. Get the SAS Address of the attached device;
      
         c. Create a new entry in the "New Port table" with SAS Address field
            filled with attached device's SAS Address, port number with Phy's
            Port number (read from SAS IOUnit Page0) and enable bit in the 'Phy
            mask' field corresponding to current Phy number.  New entry is
            created only if the driver can't find an entry in the "New Port
            table" which matches with attached device 'SAS Address' & 'Port
            Number'. If it finds an entry with matches with attached device 'SAS
            Address' & 'Port Number' then the driver takes that matched entry and
            will enable current Phy number bit in the 'Phy mask' field;
      
         d. After parsing all the HBA phy's info, the driver will have complete
            Port table info in "New Port table".
      
      II. Mark all the existing sas_device & sas_expander device structures as
          'dirty'.
      
      III. Mark each entry of the HBA Port lists as 'dirty'.
      
      IV. Take each entry from 'New Port table' one by one and check whether the
          entry has any corresponding matched entry (which is marked as 'dirty')
          in the HBA Port table or not.  While looking for a corresponding
          matched entry, look for matched entry in the sequence from top row to
          bottom row listed in the following table. If you find any matched entry
          (according to any of the rules tabulated below) then perform the action
          mentioned in the 'Action' column in that matched rule.
      
          ===========================================================================
          |Search  |SAS     | Phy Mask | Port    | Possibilities| Action            |
          |every   |Address |    or    | Number  |              | required          |
          |entry   |matched?| subset of| matched?|              |                   |
          |in below|        | phy mask |         |              |                   |
          |sequence|        | matched? |         |              |                   |
          ===========================================================================
          |  1     |matched | matched  | matched | nothing      |* unmark HBA port  |
          |        |        |          |         | changed      |table entry as     |
          |        |        |          |         |              |dirty              |
          ---------------------------------------------------------------------------
          |  2     |matched | matched  | not     | port number  |* Update port      |
          |        |        |          | matched | is changed   |number in the      |
          |        |        |          |         |              |matched port table |
          |        |        |          |         |              |entry              |
          |        |        |          |         |              |* unmask HBA port  |
          |        |        |          |         |              |table entry as     |
          |        |        |          |         |              |dirty              |
          ---------------------------------------------------------------------------
          |  3.a   |matched | subset of| matched |some phys     |* Add these new    |
          |        |        | phy mask | (or)    |might have    |phys to current    |
          |        |        | matched  | not     |enabled which |port in STL        |
          |        |        |          | matched |are previously|* Update phy mask  |
          |        |        |          | (but    |disabled      |field in HBA's port|
          |        |        |          | first   |              |table's matched    |
          |        |        |          | look for|              |entry,             |
          |        |        |          | matched |              |* Update port      |
          |        |        |          | one)    |              |number in the      |
          |	     |	      |		 | 	   |		  |matched port       |
          |        |        |          |         |              |table entry (if    |
          |        |        |          |         |              |port number is     |
          |        |        |          |         |              |changed),          |
          |        |        |          |         |              |* Unmask HBA port  |
          |        |        |          |         |              |table entry as     |
          |        |        |          |         |              |dirty              |
          ---------------------------------------------------------------------------
          |  3.b   |matched | subset of| matched |some phys     |*Remove these phys |
          |        |        | phy mask | (or)    |might have    |from current port  |
          |        |        | matched  | not     |disabled which|in STL             |
          |        |        |          | matched |are previously|* Update phy mask  |
          |        |        |          | (but    |enabled       |field in HBA's port|
          |        |        |          | first   |              |tables's matched   |
          |        |        |          | look for|              |entry,             |
          |        |        |          | matched |              |*Update port number|
          |        |        |          | one)    |              |in the matched port|
          |        |        |          |         |              |table entry (if    |
          |        |        |          |         |              |port number is     |
          |        |        |          |         |              |changed),          |
          |        |        |          |         |              |* Unmask HBA port  |
          |        |        |          |         |              |table entry as     |
          |        |        |          |         |              |dirty              |
          ---------------------------------------------------------------------------
          |  4     |matched | not      | matched |A cable       |*Remove old phys & |
          |        |        | matched  | (or)    |attached to an|new phys to current|
          |        |        |          | not     |expander is   |port in STL        |
          |        |        |          | matched |changed to    |* Update phy mask  |
          |        |        |          |         |another HBA   |field in HBA's port|
          |        |        |          |         |port during   |tables's matched   |
          |        |        |          |         |reset         |entry,             |
          |        |        |          |         |              |*Update port number|
          |        |        |          |         |              |in the matched port|
          |        |        |          |         |              |table entry (if    |
          |        |        |          |         |              |port number is     |
          |        |        |          |         |              |changed),          |
          |        |        |          |         |              |* Unmask HBA port  |
          |        |        |          |         |              |table entry as     |
          |        |        |          |         |              |dirty              |
          ---------------------------------------------------------------------------
      
      V. Delete the hba_port objects which are still marked as dirty.
      
      Link: https://lore.kernel.org/r/20201027130847.9962-9-sreekanth.reddy@broadcom.comReported-by: default avatarkernel test robot <lkp@intel.com>
      Reported-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
      Signed-off-by: default avatarSreekanth Reddy <sreekanth.reddy@broadcom.com>
      Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      a5e99fda
    • Sreekanth Reddy's avatar
      scsi: mpt3sas: Get sas_device objects using device's rphy · 6df6be91
      Sreekanth Reddy authored
      In the following scsi_host_template and sas_function_template callback
      functions the driver does not have PhysicalPort number information to
      retrieve the sas_device object using SAS Address & PhysicalPort number. In
      these callback functions the device's rphy object is used to retrieve
      sas_device object for the device.
      
      .target_alloc,
      .get_enclosure_identifier
      .get_bay_identifier
      
      When a rphy (of type sas_rphy) object is allocated then its address is
      saved in corresponding sas_device object's rphy field. In
      __mpt3sas_get_sdev_by_rphy(), the driver loops over all the sas_device
      objects from sas_device_list list to retrieve the sas_device objects whose
      rphy matches the provided rphy.
      
      Link: https://lore.kernel.org/r/20201027130847.9962-8-sreekanth.reddy@broadcom.comSigned-off-by: default avatarSreekanth Reddy <sreekanth.reddy@broadcom.com>
      Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      6df6be91
    • Sreekanth Reddy's avatar
      scsi: mpt3sas: Rename transport_del_phy_from_an_existing_port() · c71ccf93
      Sreekanth Reddy authored
      Renamed _transport_add_phy_to_an_existing_port() to
      mpt3sas_transport_add_phy_to_an_existing_port() and
      _transport_del_phy_from_an_existing_port() to
      mpt3sas_transport_del_phy_from_an_existing_port() as the driver needs to
      call these functions from outside mpt3sas_transport.c file.
      
      Added extra function argument 'port' of type struct hba_port to above
      functions and check for portID before adding/removing the phy from the
      _sas_port object.  I.e. add/remove the phy from _sas_port object only if
      _sas_port's port object and phy's port object are the same.
      
      Link: https://lore.kernel.org/r/20201027130847.9962-7-sreekanth.reddy@broadcom.comSigned-off-by: default avatarSreekanth Reddy <sreekanth.reddy@broadcom.com>
      Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      c71ccf93
    • Sreekanth Reddy's avatar
      scsi: mpt3sas: Get device objects using sas_address & portID · 7d310f24
      Sreekanth Reddy authored
      Currently driver retrieves the sas_device/sas_expander objects from
      corresponding object's lists using just device's SAS Address.
      
      Make driver retrieve the objects from the corresponding objects list using
      device's SAS Address and PhysicalPort (or PortID) number. PhysicalPort
      number is the port number of the HBA through which this device is accessed.
      
      Link: https://lore.kernel.org/r/20201027130847.9962-6-sreekanth.reddy@broadcom.comSigned-off-by: default avatarSreekanth Reddy <sreekanth.reddy@broadcom.com>
      Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      7d310f24
    • Sreekanth Reddy's avatar
      scsi: mpt3sas: Update hba_port's sas_address & phy_mask · e2f0cdf7
      Sreekanth Reddy authored
      Update hba_port's sas_address & phy_mask fields whenever a direct expander
      or sas/sata target devices are added or removed.
      
      When any direct attached device is discovered then driver:
      
       - Gets the hba_port object corresponding to device's PhysicalPort
         number;
      
       - Updates the hba_port's sas_address field with device's SAS
         Address;
      
       - Updates the hba_port's phy_mask filed with device's narrow/wide
         port Phy number bits;
      
       - If a sas/sata end device (not only direct-attached devices) is added
         then corresponding sas_device object's port variable is assigned with
         hba_port object's address whose port_id matches the device's
         PhysicalPort number.
      
       - If an expander device is added then corresponding sas_expander object's
         port variable is assigned with hba_port object's address whose port_id
         matches the expander device's PhysicalPort number.
      
      When any direct attached device is detached then driver will delete the
      hba_port object corresponding to device's PhysicalPort number.
      
      Whenever any HBA phy's link (of direct attached device's port) comes up
      then update the phy_mask field of corresponding hba_port object.
      
      Link: https://lore.kernel.org/r/20201027130847.9962-5-sreekanth.reddy@broadcom.comSigned-off-by: default avatarSreekanth Reddy <sreekanth.reddy@broadcom.com>
      Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      e2f0cdf7
    • Sreekanth Reddy's avatar
      78ca7003
    • Sreekanth Reddy's avatar
      scsi: mpt3sas: Allocate memory for hba_port objects · e238e71b
      Sreekanth Reddy authored
      Allocate hba_port object whenever a new HBA's wide/narrow port is
      identified while processing the SASIOUnitPage0's phy data and add this
      object to port_table_list.  Deallocate these objects during driver unload.
      
      Link: https://lore.kernel.org/r/20201027130847.9962-3-sreekanth.reddy@broadcom.comSigned-off-by: default avatarSreekanth Reddy <sreekanth.reddy@broadcom.com>
      Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      e238e71b
    • Sreekanth Reddy's avatar
      scsi: mpt3sas: Define hba_port structure · b22a0fac
      Sreekanth Reddy authored
      Define a new hba_port structure which holds the following variables:
      
       - port_id: Port ID of the narrow/wide port of the HBA
      
       - sas_address: SAS Address of the remote device that is attached to the
         current HBA port
      
       - phy_mask: HBA's phy bits to which above SAS addressed device is attached
      
       - flags: This field is used to refresh port details during HBA reset
      
      Link: https://lore.kernel.org/r/20201027130847.9962-2-sreekanth.reddy@broadcom.comSigned-off-by: default avatarSreekanth Reddy <sreekanth.reddy@broadcom.com>
      Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      b22a0fac
  2. 30 Oct, 2020 12 commits
  3. 27 Oct, 2020 10 commits
  4. 26 Oct, 2020 8 commits
  5. 25 Oct, 2020 2 commits