@@ -2362,68 +2362,36 @@ static irqreturn_t cq_interrupt_v3_hw(int irq_no, void *p)
23622362 return IRQ_WAKE_THREAD ;
23632363}
23642364
2365- static void setup_reply_map_v3_hw (struct hisi_hba * hisi_hba , int nvecs )
2365+ static int interrupt_preinit_v3_hw (struct hisi_hba * hisi_hba )
23662366{
2367- const struct cpumask * mask ;
2368- int queue , cpu ;
2367+ int vectors ;
2368+ int max_msi = HISI_SAS_MSI_COUNT_V3_HW , min_msi ;
2369+ struct Scsi_Host * shost = hisi_hba -> shost ;
2370+ struct irq_affinity desc = {
2371+ .pre_vectors = BASE_VECTORS_V3_HW ,
2372+ };
23692373
2370- for (queue = 0 ; queue < nvecs ; queue ++ ) {
2371- struct hisi_sas_cq * cq = & hisi_hba -> cq [queue ];
2374+ min_msi = MIN_AFFINE_VECTORS_V3_HW ;
2375+ vectors = pci_alloc_irq_vectors_affinity (hisi_hba -> pci_dev ,
2376+ min_msi , max_msi ,
2377+ PCI_IRQ_MSI |
2378+ PCI_IRQ_AFFINITY ,
2379+ & desc );
2380+ if (vectors < 0 )
2381+ return - ENOENT ;
23722382
2373- mask = pci_irq_get_affinity (hisi_hba -> pci_dev , queue +
2374- BASE_VECTORS_V3_HW );
2375- if (!mask )
2376- goto fallback ;
2377- cq -> irq_mask = mask ;
2378- for_each_cpu (cpu , mask )
2379- hisi_hba -> reply_map [cpu ] = queue ;
2380- }
2381- return ;
23822383
2383- fallback :
2384- for_each_possible_cpu ( cpu )
2385- hisi_hba -> reply_map [ cpu ] = cpu % hisi_hba -> queue_count ;
2386- /* Don't clean all CQ masks */
2384+ hisi_hba -> cq_nvecs = vectors - BASE_VECTORS_V3_HW ;
2385+ shost -> nr_hw_queues = hisi_hba -> cq_nvecs ;
2386+
2387+ return 0 ;
23872388}
23882389
23892390static int interrupt_init_v3_hw (struct hisi_hba * hisi_hba )
23902391{
23912392 struct device * dev = hisi_hba -> dev ;
23922393 struct pci_dev * pdev = hisi_hba -> pci_dev ;
2393- int vectors , rc , i ;
2394- int max_msi = HISI_SAS_MSI_COUNT_V3_HW , min_msi ;
2395-
2396- if (auto_affine_msi_experimental ) {
2397- struct irq_affinity desc = {
2398- .pre_vectors = BASE_VECTORS_V3_HW ,
2399- };
2400-
2401- dev_info (dev , "Enable MSI auto-affinity\n" );
2402-
2403- min_msi = MIN_AFFINE_VECTORS_V3_HW ;
2404-
2405- hisi_hba -> reply_map = devm_kcalloc (dev , nr_cpu_ids ,
2406- sizeof (unsigned int ),
2407- GFP_KERNEL );
2408- if (!hisi_hba -> reply_map )
2409- return - ENOMEM ;
2410- vectors = pci_alloc_irq_vectors_affinity (hisi_hba -> pci_dev ,
2411- min_msi , max_msi ,
2412- PCI_IRQ_MSI |
2413- PCI_IRQ_AFFINITY ,
2414- & desc );
2415- if (vectors < 0 )
2416- return - ENOENT ;
2417- setup_reply_map_v3_hw (hisi_hba , vectors - BASE_VECTORS_V3_HW );
2418- } else {
2419- min_msi = max_msi ;
2420- vectors = pci_alloc_irq_vectors (hisi_hba -> pci_dev , min_msi ,
2421- max_msi , PCI_IRQ_MSI );
2422- if (vectors < 0 )
2423- return vectors ;
2424- }
2425-
2426- hisi_hba -> cq_nvecs = vectors - BASE_VECTORS_V3_HW ;
2394+ int rc , i ;
24272395
24282396 rc = devm_request_irq (dev , pci_irq_vector (pdev , 1 ),
24292397 int_phy_up_down_bcast_v3_hw , 0 ,
@@ -3072,6 +3040,15 @@ static int debugfs_set_bist_v3_hw(struct hisi_hba *hisi_hba, bool enable)
30723040 return 0 ;
30733041}
30743042
3043+ static int hisi_sas_map_queues (struct Scsi_Host * shost )
3044+ {
3045+ struct hisi_hba * hisi_hba = shost_priv (shost );
3046+ struct blk_mq_queue_map * qmap = & shost -> tag_set .map [HCTX_TYPE_DEFAULT ];
3047+
3048+ return blk_mq_pci_map_queues (qmap , hisi_hba -> pci_dev ,
3049+ BASE_VECTORS_V3_HW );
3050+ }
3051+
30753052static struct scsi_host_template sht_v3_hw = {
30763053 .name = DRV_NAME ,
30773054 .proc_name = DRV_NAME ,
@@ -3082,6 +3059,7 @@ static struct scsi_host_template sht_v3_hw = {
30823059 .slave_configure = hisi_sas_slave_configure ,
30833060 .scan_finished = hisi_sas_scan_finished ,
30843061 .scan_start = hisi_sas_scan_start ,
3062+ .map_queues = hisi_sas_map_queues ,
30853063 .change_queue_depth = sas_change_queue_depth ,
30863064 .bios_param = sas_bios_param ,
30873065 .this_id = -1 ,
@@ -3098,6 +3076,7 @@ static struct scsi_host_template sht_v3_hw = {
30983076 .shost_attrs = host_attrs_v3_hw ,
30993077 .tag_alloc_policy = BLK_TAG_ALLOC_RR ,
31003078 .host_reset = hisi_sas_host_reset ,
3079+ .host_tagset = 1 ,
31013080};
31023081
31033082static const struct hisi_sas_hw hisi_sas_v3_hw = {
@@ -3269,6 +3248,10 @@ hisi_sas_v3_probe(struct pci_dev *pdev, const struct pci_device_id *id)
32693248 if (hisi_sas_debugfs_enable )
32703249 hisi_sas_debugfs_init (hisi_hba );
32713250
3251+ rc = interrupt_preinit_v3_hw (hisi_hba );
3252+ if (rc )
3253+ goto err_out_ha ;
3254+ dev_err (dev , "%d hw queues\n" , shost -> nr_hw_queues );
32723255 rc = scsi_add_host (shost , dev );
32733256 if (rc )
32743257 goto err_out_ha ;
0 commit comments