From patchwork Tue Oct 10 10:48:18 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jitendra Bhivare X-Patchwork-Id: 9995789 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 03E5B603B5 for ; Tue, 10 Oct 2017 10:49:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F240B28500 for ; Tue, 10 Oct 2017 10:49:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E731F28503; Tue, 10 Oct 2017 10:49:02 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 274AC28500 for ; Tue, 10 Oct 2017 10:49:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755813AbdJJKtB (ORCPT ); Tue, 10 Oct 2017 06:49:01 -0400 Received: from mail-pf0-f172.google.com ([209.85.192.172]:52079 "EHLO mail-pf0-f172.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755799AbdJJKtA (ORCPT ); Tue, 10 Oct 2017 06:49:00 -0400 Received: by mail-pf0-f172.google.com with SMTP id n14so14905160pfh.8 for ; Tue, 10 Oct 2017 03:49:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=ISySUAKto/PBjCzfGUxjQ/zhCEDKIYAWcC/G14c8Fho=; b=c4kHI9i1LTV4rDN0rWJ8zkpxEigA9UjHw+uHl+I/z5CQ4+975HW8W4QZ2YhSh3OmZ+ h1E01mZyQXYzKznB/Zi3hS9/fttaQLENmBlLXu7TfRG6FtknQ6z9Eeg7JV0/sELDvcrT i+jTvZpDrJz7qj6dlyYnpbjWjG4KvxL7tWMmc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=ISySUAKto/PBjCzfGUxjQ/zhCEDKIYAWcC/G14c8Fho=; b=aN7ipKhYJaQ+Volteuhii3r4EtbcczG6Q8+K3HeC2x5uB9giFJwU8UbeAZ+DLTXxrr oaq2AScKWdAa0+qYul3BJxKzMen7lViTY30INZcfL0f5zpHVLdnTtsFV7XQtT+5QoqPi dVd+yvFpdN+sd681s5Im6Ttgyt9vRA3gwh+5IIIWat2/3srQvMNpHhIyYV09r9ZHAyiq 4K4dw6iQRcsFhIFyDD6M2dYmMUAxXaoQlcIMbkF0VlPDh72Zw7wJOfx9JYr4XfGkHIxs t5nQgLEc45kW7wxADmv640w5E4FKz6M9yfwNpyTLLdMZ+ya7fxWbxXb0bBHu/0smTx6x eryQ== X-Gm-Message-State: AMCzsaVX6zilZbB2efrgSXKogJRjToQhIDvg+YqeUSet2fWa+HMLiE+4 pG7SkfjC6vTKKxCMSE8PfOsz5w== X-Google-Smtp-Source: AOwi7QDGHopyVy8G13krRuE2LtqzVvOYMXH1dhfjE+39VZRAb0HiW2+BJMQgNPMVa4ouDztZ9v5U2w== X-Received: by 10.98.147.73 with SMTP id b70mr7346578pfe.347.1507632539788; Tue, 10 Oct 2017 03:48:59 -0700 (PDT) Received: from localhost.localdomain ([103.195.99.222]) by smtp.gmail.com with ESMTPSA id w13sm16131313pgq.13.2017.10.10.03.48.57 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 10 Oct 2017 03:48:58 -0700 (PDT) From: Jitendra Bhivare To: cleech@redhat.com, lduncan@suse.com Cc: linux-scsi@vger.kernel.org, Jitendra Bhivare Subject: [PATCH 08/10] be2iscsi: Fix misc static analysis errors Date: Tue, 10 Oct 2017 16:18:18 +0530 Message-Id: <1507632500-26445-9-git-send-email-jitendra.bhivare@broadcom.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1507632500-26445-1-git-send-email-jitendra.bhivare@broadcom.com> References: <1507632500-26445-1-git-send-email-jitendra.bhivare@broadcom.com> Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The patch fixes errors reported by tools like smatch: - removes unused structure fields - removes dead code - fixes code identation Signed-off-by: Jitendra Bhivare --- drivers/scsi/be2iscsi/be.h | 17 ++++++++-------- drivers/scsi/be2iscsi/be_cmds.c | 1 - drivers/scsi/be2iscsi/be_cmds.h | 14 ++----------- drivers/scsi/be2iscsi/be_main.c | 40 ++++++++++++++++-------------------- drivers/scsi/be2iscsi/be_main.h | 45 ++--------------------------------------- drivers/scsi/be2iscsi/be_mgmt.h | 6 ------ 6 files changed, 29 insertions(+), 94 deletions(-) diff --git a/drivers/scsi/be2iscsi/be.h b/drivers/scsi/be2iscsi/be.h index 55e3f8b..1310fbf 100644 --- a/drivers/scsi/be2iscsi/be.h +++ b/drivers/scsi/be2iscsi/be.h @@ -81,12 +81,12 @@ static inline void queue_tail_inc(struct be_queue_info *q) /*ISCSI */ struct be_aic_obj { /* Adaptive interrupt coalescing (AIC) info */ - u32 min_eqd; /* in usecs */ - u32 max_eqd; /* in usecs */ - u32 prev_eqd; /* in usecs */ - u32 et_eqd; /* configured val when aic is off */ - ulong jiffies; - u64 eq_prev; /* Used to calculate eqe */ + unsigned long jiffies; + u32 eq_prev; /* Used to calculate eqe */ + u32 prev_eqd; +#define BEISCSI_EQ_DELAY_MIN 0 +#define BEISCSI_EQ_DELAY_DEF 32 +#define BEISCSI_EQ_DELAY_MAX 128 }; struct be_eq_obj { @@ -148,9 +148,8 @@ struct be_ctrl_info { /* TAG is from 1...MAX_MCC_CMD, MASK includes MAX_MCC_CMD */ #define MCC_Q_CMD_TAG_MASK ((MAX_MCC_CMD << 1) - 1) -#define PAGE_SHIFT_4K 12 -#define PAGE_SIZE_4K (1 << PAGE_SHIFT_4K) -#define mcc_timeout 120000 /* 12s timeout */ +#define PAGE_SHIFT_4K 12 +#define PAGE_SIZE_4K (1 << PAGE_SHIFT_4K) /* Returns number of pages spanned by the data starting at the given addr */ #define PAGES_4K_SPANNED(_address, size) \ diff --git a/drivers/scsi/be2iscsi/be_cmds.c b/drivers/scsi/be2iscsi/be_cmds.c index 0499666..7d633dd 100644 --- a/drivers/scsi/be2iscsi/be_cmds.c +++ b/drivers/scsi/be2iscsi/be_cmds.c @@ -947,7 +947,6 @@ int beiscsi_cmd_q_destroy(struct be_ctrl_info *ctrl, struct be_queue_info *q, default: mutex_unlock(&ctrl->mbox_lock); BUG(); - return -ENXIO; } be_cmd_hdr_prepare(&req->hdr, subsys, opcode, sizeof(*req)); if (queue_type != QTYPE_SGL) diff --git a/drivers/scsi/be2iscsi/be_cmds.h b/drivers/scsi/be2iscsi/be_cmds.h index 5d5e8fb..fc252de 100644 --- a/drivers/scsi/be2iscsi/be_cmds.h +++ b/drivers/scsi/be2iscsi/be_cmds.h @@ -1298,19 +1298,9 @@ struct be_cmd_get_port_name { * a read command */ #define TGT_CTX_UPDT_CMD 7 /* Target context update */ -#define TGT_STS_CMD 8 /* Target R2T and other BHS - * where only the status number - * need to be updated - */ -#define TGT_DATAIN_CMD 9 /* Target Data-Ins in response - * to read command - */ -#define TGT_SOS_PDU 10 /* Target:standalone status - * response - */ #define TGT_DM_CMD 11 /* Indicates that the bhs - * preparedby - * driver should not be touched + * prepared by driver should not + * be touched. */ /* Returns the number of items in the field array. */ diff --git a/drivers/scsi/be2iscsi/be_main.c b/drivers/scsi/be2iscsi/be_main.c index 02144c5..f8123ad5 100644 --- a/drivers/scsi/be2iscsi/be_main.c +++ b/drivers/scsi/be2iscsi/be_main.c @@ -455,14 +455,12 @@ static int beiscsi_map_pci_bars(struct beiscsi_hba *phba, return -ENOMEM; phba->ctrl.csr = addr; phba->csr_va = addr; - phba->csr_pa.u.a64.address = pci_resource_start(pcidev, 2); addr = ioremap_nocache(pci_resource_start(pcidev, 4), 128 * 1024); if (addr == NULL) goto pci_map_err; phba->ctrl.db = addr; phba->db_va = addr; - phba->db_pa.u.a64.address = pci_resource_start(pcidev, 4); if (phba->generation == BE_GEN2) pcicfg_reg = 1; @@ -476,7 +474,6 @@ static int beiscsi_map_pci_bars(struct beiscsi_hba *phba, goto pci_map_err; phba->ctrl.pcicfg = addr; phba->pci_va = addr; - phba->pci_pa.u.a64.address = pci_resource_start(pcidev, pcicfg_reg); return 0; pci_map_err: @@ -942,12 +939,11 @@ free_io_sgl_handle(struct beiscsi_hba *phba, struct sgl_handle *psgl_handle) * this can happen if clean_task is called on a task that * failed in xmit_task or alloc_pdu. */ - beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_IO, - "BM_%d : Double Free in IO SGL io_sgl_free_index=%d," - "value there=%p\n", phba->io_sgl_free_index, - phba->io_sgl_hndl_base - [phba->io_sgl_free_index]); - spin_unlock_irqrestore(&phba->io_sgl_lock, flags); + beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_IO, + "BM_%d : Double Free in IO SGL io_sgl_free_index=%d, value there=%p\n", + phba->io_sgl_free_index, + phba->io_sgl_hndl_base[phba->io_sgl_free_index]); + spin_unlock_irqrestore(&phba->io_sgl_lock, flags); return; } phba->io_sgl_hndl_base[phba->io_sgl_free_index] = psgl_handle; @@ -1882,8 +1878,8 @@ unsigned int beiscsi_process_cq(struct be_eq_obj *pbe_eq, int budget) be_dws_le_to_cpu(sol, sizeof(struct sol_cqe)); - code = (sol->dw[offsetof(struct amap_sol_cqe, code) / - 32] & CQE_CODE_MASK); + code = (sol->dw[offsetof(struct amap_sol_cqe, code) / 32] & + CQE_CODE_MASK); /* Get the CID */ if (is_chip_be2_be3r(phba)) { @@ -3042,7 +3038,7 @@ static int beiscsi_create_eqs(struct beiscsi_hba *phba, mem->dma = paddr; ret = beiscsi_cmd_eq_create(&phba->ctrl, eq, - phwi_context->cur_eqd); + BEISCSI_EQ_DELAY_DEF); if (ret) { beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, "BM_%d : beiscsi_cmd_eq_create" @@ -3526,13 +3522,14 @@ static int be_mcc_queues_create(struct beiscsi_hba *phba, goto err; /* Ask BE to create MCC compl queue; */ if (phba->pcidev->msix_enabled) { - if (beiscsi_cmd_cq_create(ctrl, cq, &phwi_context->be_eq - [phba->num_cpus].q, false, true, 0)) - goto mcc_cq_free; + if (beiscsi_cmd_cq_create(ctrl, cq, + &phwi_context->be_eq[phba->num_cpus].q, + false, true, 0)) + goto mcc_cq_free; } else { if (beiscsi_cmd_cq_create(ctrl, cq, &phwi_context->be_eq[0].q, false, true, 0)) - goto mcc_cq_free; + goto mcc_cq_free; } /* Alloc MCC queue */ @@ -3707,9 +3704,6 @@ static int hwi_init_port(struct beiscsi_hba *phba) phwi_ctrlr = phba->phwi_ctrlr; phwi_context = phwi_ctrlr->phwi_ctxt; - phwi_context->max_eqd = 128; - phwi_context->min_eqd = 0; - phwi_context->cur_eqd = 32; /* set port optic state to unknown */ phba->optic_state = 0xff; @@ -4810,10 +4804,10 @@ static int beiscsi_task_xmit(struct iscsi_task *task) sg = scsi_sglist(sc); if (sc->sc_data_direction == DMA_TO_DEVICE) writedir = 1; - else + else writedir = 0; - return phba->iotask_fn(task, sg, num_sg, xferlen, writedir); + return phba->iotask_fn(task, sg, num_sg, xferlen, writedir); } /** @@ -5234,8 +5228,8 @@ static void beiscsi_eqd_update_work(struct work_struct *work) if (eqd < 8) eqd = 0; - eqd = min_t(u32, eqd, phwi_context->max_eqd); - eqd = max_t(u32, eqd, phwi_context->min_eqd); + eqd = min_t(u32, eqd, BEISCSI_EQ_DELAY_MAX); + eqd = max_t(u32, eqd, BEISCSI_EQ_DELAY_MIN); aic->jiffies = now; aic->eq_prev = pbe_eq->cq_count; diff --git a/drivers/scsi/be2iscsi/be_main.h b/drivers/scsi/be2iscsi/be_main.h index 81ce3ff..6d8f819 100644 --- a/drivers/scsi/be2iscsi/be_main.h +++ b/drivers/scsi/be2iscsi/be_main.h @@ -59,7 +59,7 @@ #define BE2_DEFPDU_DATA_SZ 8192 #define BE2_MAX_NUM_CQ_PROC 512 -#define MAX_CPUS 64 +#define MAX_CPUS 64U #define BEISCSI_MAX_NUM_CPUS 7 #define BEISCSI_VER_STRLEN 32 @@ -77,9 +77,7 @@ #define BEISCSI_MAX_CMD_LEN 16 /* scsi_host->max_cmd_len */ #define BEISCSI_NUM_MAX_LUN 256 /* scsi_host->max_lun */ -#define BEISCSI_NUM_DEVICES_SUPPORTED 0x01 #define BEISCSI_MAX_FRAGS_INIT 192 -#define BE_NUM_MSIX_ENTRIES 1 #define BE_SENSE_INFO_SIZE 258 #define BE_ISCSI_PDU_HEADER_SIZE 64 @@ -209,13 +207,8 @@ struct mem_array { }; struct be_mem_descriptor { - unsigned int index; /* Index of this memory parameter */ - unsigned int category; /* type indicates cached/non-cached */ - unsigned int num_elements; /* number of elements in this - * descriptor - */ - unsigned int alignment_mask; /* Alignment mask for this block */ unsigned int size_in_bytes; /* Size required by memory block */ + unsigned int num_elements; struct mem_array *mem_array; }; @@ -238,32 +231,12 @@ struct hba_parameters { unsigned int num_eq_entries; unsigned int wrbs_per_cxn; unsigned int hwi_ws_sz; - /** - * These are calculated from other params. They're here - * for debug purposes - */ - unsigned int num_mcc_pages; - unsigned int num_mcc_cq_pages; - unsigned int num_cq_pages; - unsigned int num_eq_pages; - - unsigned int num_async_pdu_buf_pages; - unsigned int num_async_pdu_buf_sgl_pages; - unsigned int num_async_pdu_buf_cq_pages; - - unsigned int num_async_pdu_hdr_pages; - unsigned int num_async_pdu_hdr_sgl_pages; - unsigned int num_async_pdu_hdr_cq_pages; - - unsigned int num_sge; }; #define BEISCSI_GET_ULP_FROM_CRI(phwi_ctrlr, cri) \ (phwi_ctrlr->wrb_context[cri].ulp_num) struct hwi_wrb_context { spinlock_t wrb_lock; - struct list_head wrb_handle_list; - struct list_head wrb_handle_drvr_list; struct wrb_handle **pwrb_handle_base; struct wrb_handle **pwrb_handle_basestd; struct iscsi_wrb *plast_wrb; @@ -272,8 +245,6 @@ struct hwi_wrb_context { unsigned short wrb_handles_available; unsigned short cid; uint8_t ulp_num; /* ULP to which CID binded */ - uint16_t register_set; - uint16_t doorbell_format; uint32_t doorbell_offset; }; @@ -310,9 +281,6 @@ struct beiscsi_hba { u8 __iomem *csr_va; /* CSR */ u8 __iomem *db_va; /* Door Bell */ u8 __iomem *pci_va; /* PCI Config */ - struct be_bus_address csr_pa; /* CSR */ - struct be_bus_address db_pa; /* CSR */ - struct be_bus_address pci_pa; /* CSR */ /* PCI representation of our HBA */ struct pci_dev *pcidev; unsigned int num_cpus; @@ -324,7 +292,6 @@ struct beiscsi_hba { unsigned short io_sgl_free_index; unsigned short io_sgl_hndl_avbl; struct sgl_handle **io_sgl_hndl_base; - struct sgl_handle **sgl_hndl_array; unsigned short eh_sgl_alloc_index; unsigned short eh_sgl_free_index; @@ -1009,10 +976,6 @@ struct be_ring { }; struct hwi_controller { - struct list_head io_sgl_list; - struct list_head eh_sgl_list; - struct sgl_handle *psgl_handle_base; - struct hwi_wrb_context *wrb_context; struct be_ring default_pdu_hdr[BEISCSI_ULP_COUNT]; struct be_ring default_pdu_data[BEISCSI_ULP_COUNT]; @@ -1036,10 +999,6 @@ struct wrb_handle { }; struct hwi_context_memory { - /* Adaptive interrupt coalescing (AIC) info */ - u16 min_eqd; /* in usecs */ - u16 max_eqd; /* in usecs */ - u16 cur_eqd; /* in usecs */ struct be_eq_obj be_eq[MAX_CPUS]; struct be_queue_info be_cq[MAX_CPUS - 1]; diff --git a/drivers/scsi/be2iscsi/be_mgmt.h b/drivers/scsi/be2iscsi/be_mgmt.h index 8d886f8..b310c24 100644 --- a/drivers/scsi/be2iscsi/be_mgmt.h +++ b/drivers/scsi/be2iscsi/be_mgmt.h @@ -157,7 +157,6 @@ struct be_bsg_vendor_cmd { struct beiscsi_endpoint { struct beiscsi_hba *phba; - struct beiscsi_sess *sess; struct beiscsi_conn *conn; struct iscsi_endpoint *openiscsi_ep; unsigned short ip_type; @@ -169,11 +168,6 @@ struct beiscsi_endpoint { u16 cid_vld; }; -unsigned int mgmt_invalidate_connection(struct beiscsi_hba *phba, - struct beiscsi_endpoint *beiscsi_ep, - unsigned short cid, - unsigned short issue_reset, - unsigned short savecfg_flag); int beiscsi_mgmt_invalidate_icds(struct beiscsi_hba *phba, struct invldt_cmd_tbl *inv_tbl, unsigned int nents);