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: megaraid_sas: Introduce module parameter for default queue depth

This patch provides a module parameter and sysfs interface to select
whether the queue depth for each device should be based on the value
suggested by firmware (the default) or the maximum supported by the
controller (can_queue).

Although we have a sysfs interface per sdev to change the queue depth of
individual scsi devices, this implementation provides a single sysfs entry
per shost to switch between the controller max and the value reported by
firmware. The module parameter can provide an interface for one time grub
settings and provides persistent settings across the boot.

[mkp: tweaked commit desc]

Signed-off-by: Kashyap Desai <kashyap.desai@broadcom.com>
Signed-off-by: Chandrakanth Patil <chandrakanth.patil@broadcom.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>

authored by

Chandrakanth Patil and committed by
Martin K. Petersen
9ab089d3 d1436e45

+93 -22
+1
drivers/scsi/megaraid/megaraid_sas.h
··· 2429 2429 u8 adapter_type; 2430 2430 bool consistent_mask_64bit; 2431 2431 bool support_nvme_passthru; 2432 + bool enable_sdev_max_qd; 2432 2433 u8 task_abort_tmo; 2433 2434 u8 max_reset_tmo; 2434 2435 u8 snapdump_wait_time;
+92 -22
drivers/scsi/megaraid/megaraid_sas_base.c
··· 109 109 module_param(event_log_level, int, 0644); 110 110 MODULE_PARM_DESC(event_log_level, "Asynchronous event logging level- range is: -2(CLASS_DEBUG) to 4(CLASS_DEAD), Default: 2(CLASS_CRITICAL)"); 111 111 112 + unsigned int enable_sdev_max_qd; 113 + module_param(enable_sdev_max_qd, int, 0444); 114 + MODULE_PARM_DESC(enable_sdev_max_qd, "Enable sdev max qd as can_queue. Default: 0"); 115 + 112 116 MODULE_LICENSE("GPL"); 113 117 MODULE_VERSION(MEGASAS_VERSION); 114 118 MODULE_AUTHOR("megaraidlinux.pdl@broadcom.com"); ··· 1945 1941 blk_queue_virt_boundary(sdev->request_queue, mr_nvme_pg_size - 1); 1946 1942 } 1947 1943 1948 - 1949 1944 /* 1950 - * megasas_set_static_target_properties - 1951 - * Device property set by driver are static and it is not required to be 1952 - * updated after OCR. 1953 - * 1954 - * set io timeout 1955 - * set device queue depth 1956 - * set nvme device properties. see - megasas_set_nvme_device_properties 1945 + * megasas_set_fw_assisted_qd - 1946 + * set device queue depth to can_queue 1947 + * set device queue depth to fw assisted qd 1957 1948 * 1958 1949 * @sdev: scsi device 1959 1950 * @is_target_prop true, if fw provided target properties. 1960 1951 */ 1961 - static void megasas_set_static_target_properties(struct scsi_device *sdev, 1952 + static void megasas_set_fw_assisted_qd(struct scsi_device *sdev, 1962 1953 bool is_target_prop) 1963 1954 { 1964 1955 u8 interface_type; 1965 1956 u32 device_qd = MEGASAS_DEFAULT_CMD_PER_LUN; 1966 - u32 max_io_size_kb = MR_DEFAULT_NVME_MDTS_KB; 1967 1957 u32 tgt_device_qd; 1968 1958 struct megasas_instance *instance; 1969 1959 struct MR_PRIV_DEVICE *mr_device_priv_data; ··· 1965 1967 instance = megasas_lookup_instance(sdev->host->host_no); 1966 1968 mr_device_priv_data = sdev->hostdata; 1967 1969 interface_type = mr_device_priv_data->interface_type; 1968 - 1969 - /* 1970 - * The RAID firmware may require extended timeouts. 1971 - */ 1972 - blk_queue_rq_timeout(sdev->request_queue, scmd_timeout * HZ); 1973 1970 1974 1971 switch (interface_type) { 1975 1972 case SAS_PD: ··· 1983 1990 if (tgt_device_qd && 1984 1991 (tgt_device_qd <= instance->host->can_queue)) 1985 1992 device_qd = tgt_device_qd; 1986 - 1987 - /* max_io_size_kb will be set to non zero for 1988 - * nvme based vd and syspd. 1989 - */ 1990 - max_io_size_kb = le32_to_cpu(instance->tgt_prop->max_io_size_kb); 1991 1993 } 1994 + 1995 + if (instance->enable_sdev_max_qd && interface_type != UNKNOWN_DRIVE) 1996 + device_qd = instance->host->can_queue; 1997 + 1998 + scsi_change_queue_depth(sdev, device_qd); 1999 + } 2000 + 2001 + /* 2002 + * megasas_set_static_target_properties - 2003 + * Device property set by driver are static and it is not required to be 2004 + * updated after OCR. 2005 + * 2006 + * set io timeout 2007 + * set device queue depth 2008 + * set nvme device properties. see - megasas_set_nvme_device_properties 2009 + * 2010 + * @sdev: scsi device 2011 + * @is_target_prop true, if fw provided target properties. 2012 + */ 2013 + static void megasas_set_static_target_properties(struct scsi_device *sdev, 2014 + bool is_target_prop) 2015 + { 2016 + u32 max_io_size_kb = MR_DEFAULT_NVME_MDTS_KB; 2017 + struct megasas_instance *instance; 2018 + 2019 + instance = megasas_lookup_instance(sdev->host->host_no); 2020 + 2021 + /* 2022 + * The RAID firmware may require extended timeouts. 2023 + */ 2024 + blk_queue_rq_timeout(sdev->request_queue, scmd_timeout * HZ); 2025 + 2026 + /* max_io_size_kb will be set to non zero for 2027 + * nvme based vd and syspd. 2028 + */ 2029 + if (is_target_prop) 2030 + max_io_size_kb = le32_to_cpu(instance->tgt_prop->max_io_size_kb); 1992 2031 1993 2032 if (instance->nvme_page_size && max_io_size_kb) 1994 2033 megasas_set_nvme_device_properties(sdev, (max_io_size_kb << 10)); 1995 2034 1996 - scsi_change_queue_depth(sdev, device_qd); 1997 - 2035 + megasas_set_fw_assisted_qd(sdev, is_target_prop); 1998 2036 } 1999 2037 2000 2038 ··· 3306 3282 } 3307 3283 3308 3284 static ssize_t 3285 + enable_sdev_max_qd_show(struct device *cdev, 3286 + struct device_attribute *attr, char *buf) 3287 + { 3288 + struct Scsi_Host *shost = class_to_shost(cdev); 3289 + struct megasas_instance *instance = (struct megasas_instance *)shost->hostdata; 3290 + 3291 + return snprintf(buf, PAGE_SIZE, "%d\n", instance->enable_sdev_max_qd); 3292 + } 3293 + 3294 + static ssize_t 3295 + enable_sdev_max_qd_store(struct device *cdev, 3296 + struct device_attribute *attr, const char *buf, size_t count) 3297 + { 3298 + struct Scsi_Host *shost = class_to_shost(cdev); 3299 + struct megasas_instance *instance = (struct megasas_instance *)shost->hostdata; 3300 + u32 val = 0; 3301 + bool is_target_prop; 3302 + int ret_target_prop = DCMD_FAILED; 3303 + struct scsi_device *sdev; 3304 + 3305 + if (kstrtou32(buf, 0, &val) != 0) { 3306 + pr_err("megasas: could not set enable_sdev_max_qd\n"); 3307 + return -EINVAL; 3308 + } 3309 + 3310 + mutex_lock(&instance->reset_mutex); 3311 + if (val) 3312 + instance->enable_sdev_max_qd = true; 3313 + else 3314 + instance->enable_sdev_max_qd = false; 3315 + 3316 + shost_for_each_device(sdev, shost) { 3317 + ret_target_prop = megasas_get_target_prop(instance, sdev); 3318 + is_target_prop = (ret_target_prop == DCMD_SUCCESS) ? true : false; 3319 + megasas_set_fw_assisted_qd(sdev, is_target_prop); 3320 + } 3321 + mutex_unlock(&instance->reset_mutex); 3322 + 3323 + return strlen(buf); 3324 + } 3325 + 3326 + static ssize_t 3309 3327 dump_system_regs_show(struct device *cdev, 3310 3328 struct device_attribute *attr, char *buf) 3311 3329 { ··· 3376 3310 static DEVICE_ATTR_RO(page_size); 3377 3311 static DEVICE_ATTR_RO(ldio_outstanding); 3378 3312 static DEVICE_ATTR_RO(fw_cmds_outstanding); 3313 + static DEVICE_ATTR_RW(enable_sdev_max_qd); 3379 3314 static DEVICE_ATTR_RO(dump_system_regs); 3380 3315 static DEVICE_ATTR_RO(raid_map_id); 3381 3316 ··· 3387 3320 &dev_attr_page_size, 3388 3321 &dev_attr_ldio_outstanding, 3389 3322 &dev_attr_fw_cmds_outstanding, 3323 + &dev_attr_enable_sdev_max_qd, 3390 3324 &dev_attr_dump_system_regs, 3391 3325 &dev_attr_raid_map_id, 3392 3326 NULL, ··· 5958 5890 MR_MAX_RAID_MAP_SIZE_OFFSET_SHIFT) & 5959 5891 MR_MAX_RAID_MAP_SIZE_MASK); 5960 5892 } 5893 + 5894 + instance->enable_sdev_max_qd = enable_sdev_max_qd; 5961 5895 5962 5896 switch (instance->adapter_type) { 5963 5897 case VENTURA_SERIES: