Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

scsi: pm80xx: Add sysfs attribute to check MPI state

A new sysfs variable 'ctl_mpi_state' is being introduced to check the state
of MPI.

Using the 'ctl_mpi_state' sysfs variable we can check the MPI state:

linux-2dq0:~# cat /sys/class/scsi_host/host*/ctl_mpi_state
MPI is successfully initialized

Link: https://lore.kernel.org/r/20210415103352.3580-2-Viswas.G@microchip.com
Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Vishakha Channapattan <vishakhavc@google.com>
Signed-off-by: Viswas G <Viswas.G@microchip.com>
Signed-off-by: Ruksar Devadi <Ruksar.devadi@microchip.com>
Signed-off-by: Ashokkumar N <Ashokkumar.N@microchip.com>
Signed-off-by: Radha Ramachandran <radha@google.com>
Signed-off-by: kernel test robot <lkp@intel.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>

authored by

Vishakha Channapattan and committed by
Martin K. Petersen
4ddbea1b b3f0a1ee

+31 -1
+31 -1
drivers/scsi/pm8001/pm8001_ctl.c
··· 41 41 #include <linux/slab.h> 42 42 #include "pm8001_sas.h" 43 43 #include "pm8001_ctl.h" 44 + #include "pm8001_chips.h" 44 45 45 46 /* scsi host attributes */ 46 47 ··· 880 879 flash_error_table[i].err_code, 881 880 flash_error_table[i].reason); 882 881 } 883 - 884 882 static DEVICE_ATTR(update_fw, S_IRUGO|S_IWUSR|S_IWGRP, 885 883 pm8001_show_update_fw, pm8001_store_update_fw); 884 + 885 + /** 886 + * ctl_mpi_state_show - controller MPI state check 887 + * @cdev: pointer to embedded class device 888 + * @buf: the buffer returned 889 + * 890 + * A sysfs 'read-only' shost attribute. 891 + */ 892 + 893 + static const char *const mpiStateText[] = { 894 + "MPI is not initialized", 895 + "MPI is successfully initialized", 896 + "MPI termination is in progress", 897 + "MPI initialization failed with error in [31:16]" 898 + }; 899 + 900 + static ssize_t ctl_mpi_state_show(struct device *cdev, 901 + struct device_attribute *attr, char *buf) 902 + { 903 + struct Scsi_Host *shost = class_to_shost(cdev); 904 + struct sas_ha_struct *sha = SHOST_TO_SAS_HA(shost); 905 + struct pm8001_hba_info *pm8001_ha = sha->lldd_ha; 906 + unsigned int mpidw0; 907 + 908 + mpidw0 = pm8001_mr32(pm8001_ha->general_stat_tbl_addr, 0); 909 + return sysfs_emit(buf, "%s\n", mpiStateText[mpidw0 & 0x0003]); 910 + } 911 + static DEVICE_ATTR_RO(ctl_mpi_state); 912 + 886 913 struct device_attribute *pm8001_host_attrs[] = { 887 914 &dev_attr_interface_rev, 888 915 &dev_attr_controller_fatal_error, ··· 934 905 &dev_attr_ob_log, 935 906 &dev_attr_ila_version, 936 907 &dev_attr_inc_fw_ver, 908 + &dev_attr_ctl_mpi_state, 937 909 NULL, 938 910 }; 939 911