scsi: mpt3sas: Sync time periodically between driver and firmware
authorSuganath Prabu S <suganath-prabu.subramani@broadcom.com>
Thu, 26 Nov 2020 09:43:04 +0000 (15:13 +0530)
committerMartin K. Petersen <martin.petersen@oracle.com>
Wed, 9 Dec 2020 16:34:18 +0000 (11:34 -0500)
commitf98790c0037590cd7022ba9e22cf4ff90d3b2bb3
tree1dabebe9ec0d007dd7c5174f01375689b9f96442
parentafc516dcfe52802e0d29e37e3200c0f08583bd8f
scsi: mpt3sas: Sync time periodically between driver and firmware

The controller time currently gets updated with host time during driver
load or when a controller reset is issued. I.e. when host issues the
IOCInit request message to the HBA firmware. This IOCInit message has a
field named 'TimeStamp' with which the host updates the controller time.

Sometimes controller time drifts with respect to the host and it is
difficult to correlate host logs with controller logs. Issuing a controller
reset to sync the time would impact in-flight I/O and is not a viable
option.

Instead the driver now sends an IO_UNIT_CONTROL Request to sync the time
periodically. This is done from the watchdog thread which gets invoked
every second.

The time synchronization interval is specified in the 'TimeSyncInterval'
field in Manufacturing Page11 by the controller:

    TimeSyncInterval - 8 bits
bits  0-6: Time stamp Synchronization interval value
bit 7: Time stamp Synchronization interval unit,
   (if this bit is one then Timestamp Synchronization
   interval value is specified in terms of hours else
   Timestamp Synchronization interval value is
   specified in terms of minutes).

The driver keeps track of the timer using IOC's timestamp_update_count
field. This field value gets incremented whenever the watchdog thread gets
invoked. And whenever this field value is greater than or equal to the Time
Stamp Synchronization interval value, the driver sends the IO_UNIT_CONTROL
Request message to controller to update the time and then it resets the
timestamp_update_count field to zero.

Link: https://lore.kernel.org/r/20201126094311.8686-2-suganath-prabu.subramani@broadcom.com
Reported-by: kernel test robot <lkp@intel.com>
Signed-off-by: Suganath Prabu S <suganath-prabu.subramani@broadcom.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
drivers/scsi/mpt3sas/mpt3sas_base.c
drivers/scsi/mpt3sas/mpt3sas_base.h