hc
2023-12-11 d2ccde1c8e90d38cee87a1b0309ad2827f3fd30d
kernel/drivers/scsi/fnic/fnic_scsi.c
....@@ -23,6 +23,7 @@
2323 #include <linux/scatterlist.h>
2424 #include <linux/skbuff.h>
2525 #include <linux/spinlock.h>
26
+#include <linux/etherdevice.h>
2627 #include <linux/if_ether.h>
2728 #include <linux/if_vlan.h>
2829 #include <linux/delay.h>
....@@ -126,17 +127,17 @@
126127 struct scsi_cmnd *sc)
127128 {
128129 if (io_req->sgl_list_pa)
129
- pci_unmap_single(fnic->pdev, io_req->sgl_list_pa,
130
+ dma_unmap_single(&fnic->pdev->dev, io_req->sgl_list_pa,
130131 sizeof(io_req->sgl_list[0]) * io_req->sgl_cnt,
131
- PCI_DMA_TODEVICE);
132
+ DMA_TO_DEVICE);
132133 scsi_dma_unmap(sc);
133134
134135 if (io_req->sgl_cnt)
135136 mempool_free(io_req->sgl_list_alloc,
136137 fnic->io_sgl_pool[io_req->sgl_type]);
137138 if (io_req->sense_buf_pa)
138
- pci_unmap_single(fnic->pdev, io_req->sense_buf_pa,
139
- SCSI_SENSE_BUFFERSIZE, PCI_DMA_FROMDEVICE);
139
+ dma_unmap_single(&fnic->pdev->dev, io_req->sense_buf_pa,
140
+ SCSI_SENSE_BUFFERSIZE, DMA_FROM_DEVICE);
140141 }
141142
142143 /* Free up Copy Wq descriptors. Called with copy_wq lock held */
....@@ -180,20 +181,19 @@
180181 __fnic_set_state_flags(struct fnic *fnic, unsigned long st_flags,
181182 unsigned long clearbits)
182183 {
183
- struct Scsi_Host *host = fnic->lport->host;
184
- int sh_locked = spin_is_locked(host->host_lock);
185184 unsigned long flags = 0;
185
+ unsigned long host_lock_flags = 0;
186186
187
- if (!sh_locked)
188
- spin_lock_irqsave(host->host_lock, flags);
187
+ spin_lock_irqsave(&fnic->fnic_lock, flags);
188
+ spin_lock_irqsave(fnic->lport->host->host_lock, host_lock_flags);
189189
190190 if (clearbits)
191191 fnic->state_flags &= ~st_flags;
192192 else
193193 fnic->state_flags |= st_flags;
194194
195
- if (!sh_locked)
196
- spin_unlock_irqrestore(host->host_lock, flags);
195
+ spin_unlock_irqrestore(fnic->lport->host->host_lock, host_lock_flags);
196
+ spin_unlock_irqrestore(&fnic->fnic_lock, flags);
197197
198198 return;
199199 }
....@@ -276,7 +276,7 @@
276276 }
277277
278278 if (fnic->ctlr.map_dest) {
279
- memset(gw_mac, 0xff, ETH_ALEN);
279
+ eth_broadcast_addr(gw_mac);
280280 format = FCPIO_FLOGI_REG_DEF_DEST;
281281 } else {
282282 memcpy(gw_mac, fnic->ctlr.dest_addr, ETH_ALEN);
....@@ -330,7 +330,6 @@
330330 int flags;
331331 u8 exch_flags;
332332 struct scsi_lun fc_lun;
333
- int r;
334333
335334 if (sg_count) {
336335 /* For each SGE, create a device desc entry */
....@@ -342,30 +341,25 @@
342341 desc++;
343342 }
344343
345
- io_req->sgl_list_pa = pci_map_single
346
- (fnic->pdev,
347
- io_req->sgl_list,
348
- sizeof(io_req->sgl_list[0]) * sg_count,
349
- PCI_DMA_TODEVICE);
350
-
351
- r = pci_dma_mapping_error(fnic->pdev, io_req->sgl_list_pa);
352
- if (r) {
353
- printk(KERN_ERR "PCI mapping failed with error %d\n", r);
344
+ io_req->sgl_list_pa = dma_map_single(&fnic->pdev->dev,
345
+ io_req->sgl_list,
346
+ sizeof(io_req->sgl_list[0]) * sg_count,
347
+ DMA_TO_DEVICE);
348
+ if (dma_mapping_error(&fnic->pdev->dev, io_req->sgl_list_pa)) {
349
+ printk(KERN_ERR "DMA mapping failed\n");
354350 return SCSI_MLQUEUE_HOST_BUSY;
355351 }
356352 }
357353
358
- io_req->sense_buf_pa = pci_map_single(fnic->pdev,
354
+ io_req->sense_buf_pa = dma_map_single(&fnic->pdev->dev,
359355 sc->sense_buffer,
360356 SCSI_SENSE_BUFFERSIZE,
361
- PCI_DMA_FROMDEVICE);
362
-
363
- r = pci_dma_mapping_error(fnic->pdev, io_req->sense_buf_pa);
364
- if (r) {
365
- pci_unmap_single(fnic->pdev, io_req->sgl_list_pa,
357
+ DMA_FROM_DEVICE);
358
+ if (dma_mapping_error(&fnic->pdev->dev, io_req->sense_buf_pa)) {
359
+ dma_unmap_single(&fnic->pdev->dev, io_req->sgl_list_pa,
366360 sizeof(io_req->sgl_list[0]) * sg_count,
367
- PCI_DMA_TODEVICE);
368
- printk(KERN_ERR "PCI mapping failed with error %d\n", r);
361
+ DMA_TO_DEVICE);
362
+ printk(KERN_ERR "DMA mapping failed\n");
369363 return SCSI_MLQUEUE_HOST_BUSY;
370364 }
371365
....@@ -1336,13 +1330,32 @@
13361330 unsigned int wq_work_done = 0;
13371331 unsigned int i, cq_index;
13381332 unsigned int cur_work_done;
1333
+ struct misc_stats *misc_stats = &fnic->fnic_stats.misc_stats;
1334
+ u64 start_jiffies = 0;
1335
+ u64 end_jiffies = 0;
1336
+ u64 delta_jiffies = 0;
1337
+ u64 delta_ms = 0;
13391338
13401339 for (i = 0; i < fnic->wq_copy_count; i++) {
13411340 cq_index = i + fnic->raw_wq_count + fnic->rq_count;
1341
+
1342
+ start_jiffies = jiffies;
13421343 cur_work_done = vnic_cq_copy_service(&fnic->cq[cq_index],
13431344 fnic_fcpio_cmpl_handler,
13441345 copy_work_to_do);
1346
+ end_jiffies = jiffies;
1347
+
13451348 wq_work_done += cur_work_done;
1349
+ delta_jiffies = end_jiffies - start_jiffies;
1350
+ if (delta_jiffies >
1351
+ (u64) atomic64_read(&misc_stats->max_isr_jiffies)) {
1352
+ atomic64_set(&misc_stats->max_isr_jiffies,
1353
+ delta_jiffies);
1354
+ delta_ms = jiffies_to_msecs(delta_jiffies);
1355
+ atomic64_set(&misc_stats->max_isr_time_ms, delta_ms);
1356
+ atomic64_set(&misc_stats->corr_work_done,
1357
+ cur_work_done);
1358
+ }
13461359 }
13471360 return wq_work_done;
13481361 }
....@@ -1389,7 +1402,7 @@
13891402 }
13901403 if (!io_req) {
13911404 spin_unlock_irqrestore(io_lock, flags);
1392
- goto cleanup_scsi_cmd;
1405
+ continue;
13931406 }
13941407
13951408 CMD_SP(sc) = NULL;
....@@ -1404,11 +1417,11 @@
14041417 fnic_release_ioreq_buf(fnic, io_req, sc);
14051418 mempool_free(io_req, fnic->io_req_pool);
14061419
1407
-cleanup_scsi_cmd:
14081420 sc->result = DID_TRANSPORT_DISRUPTED << 16;
14091421 FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host,
1410
- "%s: sc duration = %lu DID_TRANSPORT_DISRUPTED\n",
1411
- __func__, (jiffies - start_time));
1422
+ "%s: tag:0x%x : sc:0x%p duration = %lu DID_TRANSPORT_DISRUPTED\n",
1423
+ __func__, sc->request->tag, sc,
1424
+ (jiffies - start_time));
14121425
14131426 if (atomic64_read(&fnic->io_cmpl_skip))
14141427 atomic64_dec(&fnic->io_cmpl_skip);
....@@ -1417,6 +1430,11 @@
14171430
14181431 /* Complete the command to SCSI */
14191432 if (sc->scsi_done) {
1433
+ if (!(CMD_FLAGS(sc) & FNIC_IO_ISSUED))
1434
+ shost_printk(KERN_ERR, fnic->lport->host,
1435
+ "Calling done for IO not issued to fw: tag:0x%x sc:0x%p\n",
1436
+ sc->request->tag, sc);
1437
+
14201438 FNIC_TRACE(fnic_cleanup_io,
14211439 sc->device->host->host_no, i, sc,
14221440 jiffies_to_msecs(jiffies - start_time),
....@@ -2276,33 +2294,17 @@
22762294 static inline int
22772295 fnic_scsi_host_start_tag(struct fnic *fnic, struct scsi_cmnd *sc)
22782296 {
2279
- struct blk_queue_tag *bqt = fnic->lport->host->bqt;
2280
- int tag, ret = SCSI_NO_TAG;
2297
+ struct request_queue *q = sc->request->q;
2298
+ struct request *dummy;
22812299
2282
- BUG_ON(!bqt);
2283
- if (!bqt) {
2284
- pr_err("Tags are not supported\n");
2285
- goto end;
2286
- }
2300
+ dummy = blk_mq_alloc_request(q, REQ_OP_WRITE, BLK_MQ_REQ_NOWAIT);
2301
+ if (IS_ERR(dummy))
2302
+ return SCSI_NO_TAG;
22872303
2288
- do {
2289
- tag = find_next_zero_bit(bqt->tag_map, bqt->max_depth, 1);
2290
- if (tag >= bqt->max_depth) {
2291
- pr_err("Tag allocation failure\n");
2292
- goto end;
2293
- }
2294
- } while (test_and_set_bit(tag, bqt->tag_map));
2304
+ sc->tag = sc->request->tag = dummy->tag;
2305
+ sc->host_scribble = (unsigned char *)dummy;
22952306
2296
- bqt->tag_index[tag] = sc->request;
2297
- sc->request->tag = tag;
2298
- sc->tag = tag;
2299
- if (!sc->request->special)
2300
- sc->request->special = sc;
2301
-
2302
- ret = tag;
2303
-
2304
-end:
2305
- return ret;
2307
+ return dummy->tag;
23062308 }
23072309
23082310 /**
....@@ -2312,20 +2314,9 @@
23122314 static inline void
23132315 fnic_scsi_host_end_tag(struct fnic *fnic, struct scsi_cmnd *sc)
23142316 {
2315
- struct blk_queue_tag *bqt = fnic->lport->host->bqt;
2316
- int tag = sc->request->tag;
2317
+ struct request *dummy = (struct request *)sc->host_scribble;
23172318
2318
- if (tag == SCSI_NO_TAG)
2319
- return;
2320
-
2321
- BUG_ON(!bqt || !bqt->tag_index[tag]);
2322
- if (!bqt)
2323
- return;
2324
-
2325
- bqt->tag_index[tag] = NULL;
2326
- clear_bit(tag, bqt->tag_map);
2327
-
2328
- return;
2319
+ blk_mq_free_request(dummy);
23292320 }
23302321
23312322 /*
....@@ -2384,19 +2375,9 @@
23842375 tag = sc->request->tag;
23852376 if (unlikely(tag < 0)) {
23862377 /*
2387
- * XXX(hch): current the midlayer fakes up a struct
2388
- * request for the explicit reset ioctls, and those
2389
- * don't have a tag allocated to them. The below
2390
- * code pokes into midlayer structures to paper over
2391
- * this design issue, but that won't work for blk-mq.
2392
- *
2393
- * Either someone who can actually test the hardware
2394
- * will have to come up with a similar hack for the
2395
- * blk-mq case, or we'll have to bite the bullet and
2396
- * fix the way the EH ioctls work for real, but until
2397
- * that happens we fail these explicit requests here.
2378
+ * Really should fix the midlayer to pass in a proper
2379
+ * request for ioctls...
23982380 */
2399
-
24002381 tag = fnic_scsi_host_start_tag(fnic, sc);
24012382 if (unlikely(tag == SCSI_NO_TAG))
24022383 goto fnic_device_reset_end;
....@@ -2643,8 +2624,8 @@
26432624 unsigned long flags;
26442625
26452626 spin_lock_irqsave(&fnic->fnic_lock, flags);
2646
- if (fnic->internal_reset_inprogress == 0) {
2647
- fnic->internal_reset_inprogress = 1;
2627
+ if (!fnic->internal_reset_inprogress) {
2628
+ fnic->internal_reset_inprogress = true;
26482629 } else {
26492630 spin_unlock_irqrestore(&fnic->fnic_lock, flags);
26502631 FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host,
....@@ -2673,7 +2654,7 @@
26732654 }
26742655
26752656 spin_lock_irqsave(&fnic->fnic_lock, flags);
2676
- fnic->internal_reset_inprogress = 0;
2657
+ fnic->internal_reset_inprogress = false;
26772658 spin_unlock_irqrestore(&fnic->fnic_lock, flags);
26782659 return ret;
26792660 }