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

scsi: libsas: make the event threshold configurable

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>

authored by

Jason Yan and committed by
Martin K. Petersen
8eea9dd8 f12486e0

+38
+6
drivers/scsi/hisi_sas/hisi_sas_main.c
··· 1672 1672 struct scsi_transport_template *hisi_sas_stt; 1673 1673 EXPORT_SYMBOL_GPL(hisi_sas_stt); 1674 1674 1675 + struct device_attribute *host_attrs[] = { 1676 + &dev_attr_phy_event_threshold, 1677 + NULL, 1678 + }; 1679 + 1675 1680 static struct scsi_host_template _hisi_sas_sht = { 1676 1681 .module = THIS_MODULE, 1677 1682 .name = DRV_NAME, ··· 1696 1691 .eh_target_reset_handler = sas_eh_target_reset_handler, 1697 1692 .target_destroy = sas_target_destroy, 1698 1693 .ioctl = sas_ioctl, 1694 + .shost_attrs = host_attrs, 1699 1695 }; 1700 1696 struct scsi_host_template *hisi_sas_sht = &_hisi_sas_sht; 1701 1697 EXPORT_SYMBOL_GPL(hisi_sas_sht);
+31
drivers/scsi/libsas/sas_init.c
··· 538 538 .smp_handler = sas_smp_handler, 539 539 }; 540 540 541 + static inline ssize_t phy_event_threshold_show(struct device *dev, 542 + struct device_attribute *attr, char *buf) 543 + { 544 + struct Scsi_Host *shost = class_to_shost(dev); 545 + struct sas_ha_struct *sha = SHOST_TO_SAS_HA(shost); 546 + 547 + return scnprintf(buf, PAGE_SIZE, "%u\n", sha->event_thres); 548 + } 549 + 550 + static inline ssize_t phy_event_threshold_store(struct device *dev, 551 + struct device_attribute *attr, 552 + const char *buf, size_t count) 553 + { 554 + struct Scsi_Host *shost = class_to_shost(dev); 555 + struct sas_ha_struct *sha = SHOST_TO_SAS_HA(shost); 556 + 557 + sha->event_thres = simple_strtol(buf, NULL, 10); 558 + 559 + /* threshold cannot be set too small */ 560 + if (sha->event_thres < 32) 561 + sha->event_thres = 32; 562 + 563 + return count; 564 + } 565 + 566 + DEVICE_ATTR(phy_event_threshold, 567 + S_IRUGO|S_IWUSR, 568 + phy_event_threshold_show, 569 + phy_event_threshold_store); 570 + EXPORT_SYMBOL_GPL(dev_attr_phy_event_threshold); 571 + 541 572 struct scsi_transport_template * 542 573 sas_domain_attach_transport(struct sas_domain_function_template *dft) 543 574 {
+1
include/scsi/libsas.h
··· 681 681 sector_t capacity, int *hsc); 682 682 extern struct scsi_transport_template * 683 683 sas_domain_attach_transport(struct sas_domain_function_template *); 684 + extern struct device_attribute dev_attr_phy_event_threshold; 684 685 685 686 int sas_discover_root_expander(struct domain_device *); 686 687