@@ -114,6 +114,15 @@ unsigned int enable_sdev_max_qd;
114
114
module_param (enable_sdev_max_qd , int , 0444 );
115
115
MODULE_PARM_DESC (enable_sdev_max_qd , "Enable sdev max qd as can_queue. Default: 0" );
116
116
117
+ int poll_queues ;
118
+ module_param (poll_queues , int , 0444 );
119
+ MODULE_PARM_DESC (poll_queues , "Number of queues to be use for io_uring poll mode.\n\t\t"
120
+ "This parameter is effective only if host_tagset_enable=1 &\n\t\t"
121
+ "It is not applicable for MFI_SERIES. &\n\t\t"
122
+ "Driver will work in latency mode. &\n\t\t"
123
+ "High iops queues are not allocated &\n\t\t"
124
+ );
125
+
117
126
int host_tagset_enable = 1 ;
118
127
module_param (host_tagset_enable , int , 0444 );
119
128
MODULE_PARM_DESC (host_tagset_enable , "Shared host tagset enable/disable Default: enable(1)" );
@@ -207,6 +216,7 @@ static bool support_pci_lane_margining;
207
216
static spinlock_t poll_aen_lock ;
208
217
209
218
extern struct dentry * megasas_debugfs_root ;
219
+ extern int megasas_blk_mq_poll (struct Scsi_Host * shost , unsigned int queue_num );
210
220
211
221
void
212
222
megasas_complete_cmd (struct megasas_instance * instance , struct megasas_cmd * cmd ,
@@ -3127,14 +3137,37 @@ megasas_bios_param(struct scsi_device *sdev, struct block_device *bdev,
3127
3137
static int megasas_map_queues (struct Scsi_Host * shost )
3128
3138
{
3129
3139
struct megasas_instance * instance ;
3140
+ int qoff = 0 , offset ;
3141
+ struct blk_mq_queue_map * map ;
3130
3142
3131
3143
instance = (struct megasas_instance * )shost -> hostdata ;
3132
3144
3133
3145
if (shost -> nr_hw_queues == 1 )
3134
3146
return 0 ;
3135
3147
3136
- return blk_mq_pci_map_queues (& shost -> tag_set .map [HCTX_TYPE_DEFAULT ],
3137
- instance -> pdev , instance -> low_latency_index_start );
3148
+ offset = instance -> low_latency_index_start ;
3149
+
3150
+ /* Setup Default hctx */
3151
+ map = & shost -> tag_set .map [HCTX_TYPE_DEFAULT ];
3152
+ map -> nr_queues = instance -> msix_vectors - offset ;
3153
+ map -> queue_offset = 0 ;
3154
+ blk_mq_pci_map_queues (map , instance -> pdev , offset );
3155
+ qoff += map -> nr_queues ;
3156
+ offset += map -> nr_queues ;
3157
+
3158
+ /* Setup Poll hctx */
3159
+ map = & shost -> tag_set .map [HCTX_TYPE_POLL ];
3160
+ map -> nr_queues = instance -> iopoll_q_count ;
3161
+ if (map -> nr_queues ) {
3162
+ /*
3163
+ * The poll queue(s) doesn't have an IRQ (and hence IRQ
3164
+ * affinity), so use the regular blk-mq cpu mapping
3165
+ */
3166
+ map -> queue_offset = qoff ;
3167
+ blk_mq_map_queues (map );
3168
+ }
3169
+
3170
+ return 0 ;
3138
3171
}
3139
3172
3140
3173
static void megasas_aen_polling (struct work_struct * work );
@@ -3446,6 +3479,7 @@ static struct scsi_host_template megasas_template = {
3446
3479
.shost_attrs = megaraid_host_attrs ,
3447
3480
.bios_param = megasas_bios_param ,
3448
3481
.map_queues = megasas_map_queues ,
3482
+ .mq_poll = megasas_blk_mq_poll ,
3449
3483
.change_queue_depth = scsi_change_queue_depth ,
3450
3484
.max_segment_size = 0xffffffff ,
3451
3485
};
@@ -5834,13 +5868,16 @@ __megasas_alloc_irq_vectors(struct megasas_instance *instance)
5834
5868
irq_flags = PCI_IRQ_MSIX ;
5835
5869
5836
5870
if (instance -> smp_affinity_enable )
5837
- irq_flags |= PCI_IRQ_AFFINITY ;
5871
+ irq_flags |= PCI_IRQ_AFFINITY | PCI_IRQ_ALL_TYPES ;
5838
5872
else
5839
5873
descp = NULL ;
5840
5874
5875
+ /* Do not allocate msix vectors for poll_queues.
5876
+ * msix_vectors is always within a range of FW supported reply queue.
5877
+ */
5841
5878
i = pci_alloc_irq_vectors_affinity (instance -> pdev ,
5842
5879
instance -> low_latency_index_start ,
5843
- instance -> msix_vectors , irq_flags , descp );
5880
+ instance -> msix_vectors - instance -> iopoll_q_count , irq_flags , descp );
5844
5881
5845
5882
return i ;
5846
5883
}
@@ -5856,10 +5893,30 @@ megasas_alloc_irq_vectors(struct megasas_instance *instance)
5856
5893
int i ;
5857
5894
unsigned int num_msix_req ;
5858
5895
5896
+ instance -> iopoll_q_count = 0 ;
5897
+ if ((instance -> adapter_type != MFI_SERIES ) &&
5898
+ poll_queues ) {
5899
+
5900
+ instance -> perf_mode = MR_LATENCY_PERF_MODE ;
5901
+ instance -> low_latency_index_start = 1 ;
5902
+
5903
+ /* reserve for default and non-mananged pre-vector. */
5904
+ if (instance -> msix_vectors > (poll_queues + 2 ))
5905
+ instance -> iopoll_q_count = poll_queues ;
5906
+ else
5907
+ instance -> iopoll_q_count = 0 ;
5908
+
5909
+ num_msix_req = num_online_cpus () + instance -> low_latency_index_start ;
5910
+ instance -> msix_vectors = min (num_msix_req ,
5911
+ instance -> msix_vectors );
5912
+
5913
+ }
5914
+
5859
5915
i = __megasas_alloc_irq_vectors (instance );
5860
5916
5861
- if ((instance -> perf_mode == MR_BALANCED_PERF_MODE ) &&
5862
- (i != instance -> msix_vectors )) {
5917
+ if (((instance -> perf_mode == MR_BALANCED_PERF_MODE )
5918
+ || instance -> iopoll_q_count ) &&
5919
+ (i != (instance -> msix_vectors - instance -> iopoll_q_count ))) {
5863
5920
if (instance -> msix_vectors )
5864
5921
pci_free_irq_vectors (instance -> pdev );
5865
5922
/* Disable Balanced IOPS mode and try realloc vectors */
@@ -5870,12 +5927,15 @@ megasas_alloc_irq_vectors(struct megasas_instance *instance)
5870
5927
instance -> msix_vectors = min (num_msix_req ,
5871
5928
instance -> msix_vectors );
5872
5929
5930
+ instance -> iopoll_q_count = 0 ;
5873
5931
i = __megasas_alloc_irq_vectors (instance );
5874
5932
5875
5933
}
5876
5934
5877
5935
dev_info (& instance -> pdev -> dev ,
5878
- "requested/available msix %d/%d\n" , instance -> msix_vectors , i );
5936
+ "requested/available msix %d/%d poll_queue %d\n" ,
5937
+ instance -> msix_vectors - instance -> iopoll_q_count ,
5938
+ i , instance -> iopoll_q_count );
5879
5939
5880
5940
if (i > 0 )
5881
5941
instance -> msix_vectors = i ;
@@ -6841,12 +6901,18 @@ static int megasas_io_attach(struct megasas_instance *instance)
6841
6901
instance -> smp_affinity_enable ) {
6842
6902
host -> host_tagset = 1 ;
6843
6903
host -> nr_hw_queues = instance -> msix_vectors -
6844
- instance -> low_latency_index_start ;
6904
+ instance -> low_latency_index_start + instance -> iopoll_q_count ;
6905
+ if (instance -> iopoll_q_count )
6906
+ host -> nr_maps = 3 ;
6907
+ } else {
6908
+ instance -> iopoll_q_count = 0 ;
6845
6909
}
6846
6910
6847
6911
dev_info (& instance -> pdev -> dev ,
6848
- "Max firmware commands: %d shared with nr_hw_queues = %d\n" ,
6849
- instance -> max_fw_cmds , host -> nr_hw_queues );
6912
+ "Max firmware commands: %d shared with default "
6913
+ "hw_queues = %d poll_queues %d\n" , instance -> max_fw_cmds ,
6914
+ host -> nr_hw_queues - instance -> iopoll_q_count ,
6915
+ instance -> iopoll_q_count );
6850
6916
/*
6851
6917
* Notify the mid-layer about the new controller
6852
6918
*/
@@ -8859,6 +8925,7 @@ static int __init megasas_init(void)
8859
8925
msix_vectors = 1 ;
8860
8926
rdpq_enable = 0 ;
8861
8927
dual_qdepth_disable = 1 ;
8928
+ poll_queues = 0 ;
8862
8929
}
8863
8930
8864
8931
/*
0 commit comments