Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 8eea9dd8 authored by Jason Yan's avatar Jason Yan Committed by Martin K. Petersen
Browse files

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: default avatarHannes Reinecke <hare@suse.com>
Signed-off-by: default avatarJason 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: default avatarHannes Reinecke <hare@suse.com>
Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
parent f12486e0
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -1672,6 +1672,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,
@@ -1691,6 +1696,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);
+31 −0
Original line number Diff line number Diff line
@@ -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)
{
+1 −0
Original line number Diff line number Diff line
@@ -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 *);