@@ -3247,10 +3247,72 @@ persistent_id_show(struct device *dev, struct device_attribute *attr,
32473247}
32483248static DEVICE_ATTR_RO (persistent_id );
32493249
3250+ /**
3251+ * sas_ncq_prio_supported_show - Indicate if device supports NCQ priority
3252+ * @dev: pointer to embedded device
3253+ * @attr: sas_ncq_prio_supported attribute descriptor
3254+ * @buf: the buffer returned
3255+ *
3256+ * A sysfs 'read-only' sdev attribute, only works with SATA devices
3257+ */
3258+ static ssize_t
3259+ sas_ncq_prio_supported_show (struct device * dev ,
3260+ struct device_attribute * attr , char * buf )
3261+ {
3262+ struct scsi_device * sdev = to_scsi_device (dev );
3263+
3264+ return sysfs_emit (buf , "%d\n" , sas_ata_ncq_prio_supported (sdev ));
3265+ }
3266+ static DEVICE_ATTR_RO (sas_ncq_prio_supported );
3267+
3268+ /**
3269+ * sas_ncq_prio_enable_show - send prioritized io commands to device
3270+ * @dev: pointer to embedded device
3271+ * @attr: sas_ncq_prio_enable attribute descriptor
3272+ * @buf: the buffer returned
3273+ *
3274+ * A sysfs 'read/write' sdev attribute, only works with SATA devices
3275+ */
3276+ static ssize_t
3277+ sas_ncq_prio_enable_show (struct device * dev ,
3278+ struct device_attribute * attr , char * buf )
3279+ {
3280+ struct scsi_device * sdev = to_scsi_device (dev );
3281+ struct mpi3mr_sdev_priv_data * sdev_priv_data = sdev -> hostdata ;
3282+
3283+ if (!sdev_priv_data )
3284+ return 0 ;
3285+
3286+ return sysfs_emit (buf , "%d\n" , sdev_priv_data -> ncq_prio_enable );
3287+ }
3288+
3289+ static ssize_t
3290+ sas_ncq_prio_enable_store (struct device * dev ,
3291+ struct device_attribute * attr ,
3292+ const char * buf , size_t count )
3293+ {
3294+ struct scsi_device * sdev = to_scsi_device (dev );
3295+ struct mpi3mr_sdev_priv_data * sdev_priv_data = sdev -> hostdata ;
3296+ bool ncq_prio_enable = 0 ;
3297+
3298+ if (kstrtobool (buf , & ncq_prio_enable ))
3299+ return - EINVAL ;
3300+
3301+ if (!sas_ata_ncq_prio_supported (sdev ))
3302+ return - EINVAL ;
3303+
3304+ sdev_priv_data -> ncq_prio_enable = ncq_prio_enable ;
3305+
3306+ return strlen (buf );
3307+ }
3308+ static DEVICE_ATTR_RW (sas_ncq_prio_enable );
3309+
32503310static struct attribute * mpi3mr_dev_attrs [] = {
32513311 & dev_attr_sas_address .attr ,
32523312 & dev_attr_device_handle .attr ,
32533313 & dev_attr_persistent_id .attr ,
3314+ & dev_attr_sas_ncq_prio_supported .attr ,
3315+ & dev_attr_sas_ncq_prio_enable .attr ,
32543316 NULL ,
32553317};
32563318
0 commit comments