]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commitdiff
scsi: libsas: make the event threshold configurable
authorJason Yan <yanaijie@huawei.com>
Fri, 8 Dec 2017 09:42:06 +0000 (17:42 +0800)
committerSeth Forshee <seth.forshee@canonical.com>
Wed, 28 Feb 2018 14:47:02 +0000 (08:47 -0600)
BugLink: https://bugs.launchpad.net/bugs/1752146
Add a sysfs attr that LLDD can configure it for every host. We made an
example in hisi_sas. Other LLDDs using libsas can implement it if they
want.

Suggested-by: Hannes Reinecke <hare@suse.com>
Signed-off-by: Jason Yan <yanaijie@huawei.com>
CC: John Garry <john.garry@huawei.com>
CC: Johannes Thumshirn <jthumshirn@suse.de>
CC: Ewan Milne <emilne@redhat.com>
CC: Christoph Hellwig <hch@lst.de>
CC: Tomas Henzl <thenzl@redhat.com>
CC: Dan Williams <dan.j.williams@intel.com>
Acked-by: John Garry <john.garry@huawei.com> #for hisi_sas part
Reviewed-by: Hannes Reinecke <hare@suse.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
(cherry picked from commit 8eea9dd84e450e5262643823691108f2a208a2ac)
Signed-off-by: dann frazier <dann.frazier@canonical.com>
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
drivers/scsi/hisi_sas/hisi_sas_main.c
drivers/scsi/libsas/sas_init.c
include/scsi/libsas.h

index 5f503cb095085d2baa7e2f24248419dbbb432e29..b5ce64a42660cbc9a137a376abce7d5b1619940a 100644 (file)
@@ -1561,6 +1561,11 @@ EXPORT_SYMBOL_GPL(hisi_sas_kill_tasklets);
 struct scsi_transport_template *hisi_sas_stt;
 EXPORT_SYMBOL_GPL(hisi_sas_stt);
 
+struct device_attribute *host_attrs[] = {
+       &dev_attr_phy_event_threshold,
+       NULL,
+};
+
 static struct scsi_host_template _hisi_sas_sht = {
        .module                 = THIS_MODULE,
        .name                   = DRV_NAME,
@@ -1580,6 +1585,7 @@ static struct scsi_host_template _hisi_sas_sht = {
        .eh_target_reset_handler = sas_eh_target_reset_handler,
        .target_destroy         = sas_target_destroy,
        .ioctl                  = sas_ioctl,
+       .shost_attrs            = host_attrs,
 };
 struct scsi_host_template *hisi_sas_sht = &_hisi_sas_sht;
 EXPORT_SYMBOL_GPL(hisi_sas_sht);
index 22bfc025ae81913cb89ebc9771a48b5bc68ded78..afd928bf903eb6c8adda6d6adb2047c6f7a8d0a1 100644 (file)
@@ -538,6 +538,37 @@ static struct sas_function_template sft = {
        .smp_handler = sas_smp_handler,
 };
 
+static inline ssize_t phy_event_threshold_show(struct device *dev,
+                       struct device_attribute *attr, char *buf)
+{
+       struct Scsi_Host *shost = class_to_shost(dev);
+       struct sas_ha_struct *sha = SHOST_TO_SAS_HA(shost);
+
+       return scnprintf(buf, PAGE_SIZE, "%u\n", sha->event_thres);
+}
+
+static inline ssize_t phy_event_threshold_store(struct device *dev,
+                       struct device_attribute *attr,
+                       const char *buf, size_t count)
+{
+       struct Scsi_Host *shost = class_to_shost(dev);
+       struct sas_ha_struct *sha = SHOST_TO_SAS_HA(shost);
+
+       sha->event_thres = simple_strtol(buf, NULL, 10);
+
+       /* threshold cannot be set too small */
+       if (sha->event_thres < 32)
+               sha->event_thres = 32;
+
+       return count;
+}
+
+DEVICE_ATTR(phy_event_threshold,
+       S_IRUGO|S_IWUSR,
+       phy_event_threshold_show,
+       phy_event_threshold_store);
+EXPORT_SYMBOL_GPL(dev_attr_phy_event_threshold);
+
 struct scsi_transport_template *
 sas_domain_attach_transport(struct sas_domain_function_template *dft)
 {
index 26683e2452ba12f8aa63218312993522974d2407..701c67fc6286001a6ce065e306dba4e71713c9e0 100644 (file)
@@ -681,6 +681,7 @@ extern int sas_bios_param(struct scsi_device *,
                          sector_t capacity, int *hsc);
 extern struct scsi_transport_template *
 sas_domain_attach_transport(struct sas_domain_function_template *);
+extern struct device_attribute dev_attr_phy_event_threshold;
 
 int  sas_discover_root_expander(struct domain_device *);