From d2ccde1c8e90d38cee87a1b0309ad2827f3fd30d Mon Sep 17 00:00:00 2001 From: hc <hc@nodka.com> Date: Mon, 11 Dec 2023 02:45:28 +0000 Subject: [PATCH] add boot partition size --- kernel/drivers/scsi/fnic/fnic_scsi.c | 151 ++++++++++++++++++++++---------------------------- 1 files changed, 66 insertions(+), 85 deletions(-) diff --git a/kernel/drivers/scsi/fnic/fnic_scsi.c b/kernel/drivers/scsi/fnic/fnic_scsi.c index b521fc7..d1f7b84 100644 --- a/kernel/drivers/scsi/fnic/fnic_scsi.c +++ b/kernel/drivers/scsi/fnic/fnic_scsi.c @@ -23,6 +23,7 @@ #include <linux/scatterlist.h> #include <linux/skbuff.h> #include <linux/spinlock.h> +#include <linux/etherdevice.h> #include <linux/if_ether.h> #include <linux/if_vlan.h> #include <linux/delay.h> @@ -126,17 +127,17 @@ struct scsi_cmnd *sc) { if (io_req->sgl_list_pa) - pci_unmap_single(fnic->pdev, io_req->sgl_list_pa, + dma_unmap_single(&fnic->pdev->dev, io_req->sgl_list_pa, sizeof(io_req->sgl_list[0]) * io_req->sgl_cnt, - PCI_DMA_TODEVICE); + DMA_TO_DEVICE); scsi_dma_unmap(sc); if (io_req->sgl_cnt) mempool_free(io_req->sgl_list_alloc, fnic->io_sgl_pool[io_req->sgl_type]); if (io_req->sense_buf_pa) - pci_unmap_single(fnic->pdev, io_req->sense_buf_pa, - SCSI_SENSE_BUFFERSIZE, PCI_DMA_FROMDEVICE); + dma_unmap_single(&fnic->pdev->dev, io_req->sense_buf_pa, + SCSI_SENSE_BUFFERSIZE, DMA_FROM_DEVICE); } /* Free up Copy Wq descriptors. Called with copy_wq lock held */ @@ -180,20 +181,19 @@ __fnic_set_state_flags(struct fnic *fnic, unsigned long st_flags, unsigned long clearbits) { - struct Scsi_Host *host = fnic->lport->host; - int sh_locked = spin_is_locked(host->host_lock); unsigned long flags = 0; + unsigned long host_lock_flags = 0; - if (!sh_locked) - spin_lock_irqsave(host->host_lock, flags); + spin_lock_irqsave(&fnic->fnic_lock, flags); + spin_lock_irqsave(fnic->lport->host->host_lock, host_lock_flags); if (clearbits) fnic->state_flags &= ~st_flags; else fnic->state_flags |= st_flags; - if (!sh_locked) - spin_unlock_irqrestore(host->host_lock, flags); + spin_unlock_irqrestore(fnic->lport->host->host_lock, host_lock_flags); + spin_unlock_irqrestore(&fnic->fnic_lock, flags); return; } @@ -276,7 +276,7 @@ } if (fnic->ctlr.map_dest) { - memset(gw_mac, 0xff, ETH_ALEN); + eth_broadcast_addr(gw_mac); format = FCPIO_FLOGI_REG_DEF_DEST; } else { memcpy(gw_mac, fnic->ctlr.dest_addr, ETH_ALEN); @@ -330,7 +330,6 @@ int flags; u8 exch_flags; struct scsi_lun fc_lun; - int r; if (sg_count) { /* For each SGE, create a device desc entry */ @@ -342,30 +341,25 @@ desc++; } - io_req->sgl_list_pa = pci_map_single - (fnic->pdev, - io_req->sgl_list, - sizeof(io_req->sgl_list[0]) * sg_count, - PCI_DMA_TODEVICE); - - r = pci_dma_mapping_error(fnic->pdev, io_req->sgl_list_pa); - if (r) { - printk(KERN_ERR "PCI mapping failed with error %d\n", r); + io_req->sgl_list_pa = dma_map_single(&fnic->pdev->dev, + io_req->sgl_list, + sizeof(io_req->sgl_list[0]) * sg_count, + DMA_TO_DEVICE); + if (dma_mapping_error(&fnic->pdev->dev, io_req->sgl_list_pa)) { + printk(KERN_ERR "DMA mapping failed\n"); return SCSI_MLQUEUE_HOST_BUSY; } } - io_req->sense_buf_pa = pci_map_single(fnic->pdev, + io_req->sense_buf_pa = dma_map_single(&fnic->pdev->dev, sc->sense_buffer, SCSI_SENSE_BUFFERSIZE, - PCI_DMA_FROMDEVICE); - - r = pci_dma_mapping_error(fnic->pdev, io_req->sense_buf_pa); - if (r) { - pci_unmap_single(fnic->pdev, io_req->sgl_list_pa, + DMA_FROM_DEVICE); + if (dma_mapping_error(&fnic->pdev->dev, io_req->sense_buf_pa)) { + dma_unmap_single(&fnic->pdev->dev, io_req->sgl_list_pa, sizeof(io_req->sgl_list[0]) * sg_count, - PCI_DMA_TODEVICE); - printk(KERN_ERR "PCI mapping failed with error %d\n", r); + DMA_TO_DEVICE); + printk(KERN_ERR "DMA mapping failed\n"); return SCSI_MLQUEUE_HOST_BUSY; } @@ -1336,13 +1330,32 @@ unsigned int wq_work_done = 0; unsigned int i, cq_index; unsigned int cur_work_done; + struct misc_stats *misc_stats = &fnic->fnic_stats.misc_stats; + u64 start_jiffies = 0; + u64 end_jiffies = 0; + u64 delta_jiffies = 0; + u64 delta_ms = 0; for (i = 0; i < fnic->wq_copy_count; i++) { cq_index = i + fnic->raw_wq_count + fnic->rq_count; + + start_jiffies = jiffies; cur_work_done = vnic_cq_copy_service(&fnic->cq[cq_index], fnic_fcpio_cmpl_handler, copy_work_to_do); + end_jiffies = jiffies; + wq_work_done += cur_work_done; + delta_jiffies = end_jiffies - start_jiffies; + if (delta_jiffies > + (u64) atomic64_read(&misc_stats->max_isr_jiffies)) { + atomic64_set(&misc_stats->max_isr_jiffies, + delta_jiffies); + delta_ms = jiffies_to_msecs(delta_jiffies); + atomic64_set(&misc_stats->max_isr_time_ms, delta_ms); + atomic64_set(&misc_stats->corr_work_done, + cur_work_done); + } } return wq_work_done; } @@ -1389,7 +1402,7 @@ } if (!io_req) { spin_unlock_irqrestore(io_lock, flags); - goto cleanup_scsi_cmd; + continue; } CMD_SP(sc) = NULL; @@ -1404,11 +1417,11 @@ fnic_release_ioreq_buf(fnic, io_req, sc); mempool_free(io_req, fnic->io_req_pool); -cleanup_scsi_cmd: sc->result = DID_TRANSPORT_DISRUPTED << 16; FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host, - "%s: sc duration = %lu DID_TRANSPORT_DISRUPTED\n", - __func__, (jiffies - start_time)); + "%s: tag:0x%x : sc:0x%p duration = %lu DID_TRANSPORT_DISRUPTED\n", + __func__, sc->request->tag, sc, + (jiffies - start_time)); if (atomic64_read(&fnic->io_cmpl_skip)) atomic64_dec(&fnic->io_cmpl_skip); @@ -1417,6 +1430,11 @@ /* Complete the command to SCSI */ if (sc->scsi_done) { + if (!(CMD_FLAGS(sc) & FNIC_IO_ISSUED)) + shost_printk(KERN_ERR, fnic->lport->host, + "Calling done for IO not issued to fw: tag:0x%x sc:0x%p\n", + sc->request->tag, sc); + FNIC_TRACE(fnic_cleanup_io, sc->device->host->host_no, i, sc, jiffies_to_msecs(jiffies - start_time), @@ -2276,33 +2294,17 @@ static inline int fnic_scsi_host_start_tag(struct fnic *fnic, struct scsi_cmnd *sc) { - struct blk_queue_tag *bqt = fnic->lport->host->bqt; - int tag, ret = SCSI_NO_TAG; + struct request_queue *q = sc->request->q; + struct request *dummy; - BUG_ON(!bqt); - if (!bqt) { - pr_err("Tags are not supported\n"); - goto end; - } + dummy = blk_mq_alloc_request(q, REQ_OP_WRITE, BLK_MQ_REQ_NOWAIT); + if (IS_ERR(dummy)) + return SCSI_NO_TAG; - do { - tag = find_next_zero_bit(bqt->tag_map, bqt->max_depth, 1); - if (tag >= bqt->max_depth) { - pr_err("Tag allocation failure\n"); - goto end; - } - } while (test_and_set_bit(tag, bqt->tag_map)); + sc->tag = sc->request->tag = dummy->tag; + sc->host_scribble = (unsigned char *)dummy; - bqt->tag_index[tag] = sc->request; - sc->request->tag = tag; - sc->tag = tag; - if (!sc->request->special) - sc->request->special = sc; - - ret = tag; - -end: - return ret; + return dummy->tag; } /** @@ -2312,20 +2314,9 @@ static inline void fnic_scsi_host_end_tag(struct fnic *fnic, struct scsi_cmnd *sc) { - struct blk_queue_tag *bqt = fnic->lport->host->bqt; - int tag = sc->request->tag; + struct request *dummy = (struct request *)sc->host_scribble; - if (tag == SCSI_NO_TAG) - return; - - BUG_ON(!bqt || !bqt->tag_index[tag]); - if (!bqt) - return; - - bqt->tag_index[tag] = NULL; - clear_bit(tag, bqt->tag_map); - - return; + blk_mq_free_request(dummy); } /* @@ -2384,19 +2375,9 @@ tag = sc->request->tag; if (unlikely(tag < 0)) { /* - * XXX(hch): current the midlayer fakes up a struct - * request for the explicit reset ioctls, and those - * don't have a tag allocated to them. The below - * code pokes into midlayer structures to paper over - * this design issue, but that won't work for blk-mq. - * - * Either someone who can actually test the hardware - * will have to come up with a similar hack for the - * blk-mq case, or we'll have to bite the bullet and - * fix the way the EH ioctls work for real, but until - * that happens we fail these explicit requests here. + * Really should fix the midlayer to pass in a proper + * request for ioctls... */ - tag = fnic_scsi_host_start_tag(fnic, sc); if (unlikely(tag == SCSI_NO_TAG)) goto fnic_device_reset_end; @@ -2643,8 +2624,8 @@ unsigned long flags; spin_lock_irqsave(&fnic->fnic_lock, flags); - if (fnic->internal_reset_inprogress == 0) { - fnic->internal_reset_inprogress = 1; + if (!fnic->internal_reset_inprogress) { + fnic->internal_reset_inprogress = true; } else { spin_unlock_irqrestore(&fnic->fnic_lock, flags); FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host, @@ -2673,7 +2654,7 @@ } spin_lock_irqsave(&fnic->fnic_lock, flags); - fnic->internal_reset_inprogress = 0; + fnic->internal_reset_inprogress = false; spin_unlock_irqrestore(&fnic->fnic_lock, flags); return ret; } -- Gitblit v1.6.2