From patchwork Mon Jun 29 22:54:46 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 213652 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.0 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DAC90C433E0 for ; Mon, 29 Jun 2020 22:55:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C4FDD20786 for ; Mon, 29 Jun 2020 22:55:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728409AbgF2WzI (ORCPT ); Mon, 29 Jun 2020 18:55:08 -0400 Received: from mail-pj1-f66.google.com ([209.85.216.66]:36212 "EHLO mail-pj1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726078AbgF2WzH (ORCPT ); Mon, 29 Jun 2020 18:55:07 -0400 Received: by mail-pj1-f66.google.com with SMTP id h22so8649094pjf.1 for ; Mon, 29 Jun 2020 15:55:06 -0700 (PDT) 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:mime-version:content-transfer-encoding; bh=2sO4M/I6KZtr0qUW3pRrWNvAvtKK9SHCZ3zIc16BBCk=; b=YbXLyPsc1qCylt+wx6SbHCqdD6YgoO3IgkuXzk4/KcrTT39eDtnr5Bae73vfhfmQse 7rO4qffY/8muH46is3vf4RlfWNyGi/RyYKKbTfOISL1HWz/WfindWDtCDXeXEaRYMrpD sippoY/M/1L2egIUM8U/F/ZC+QLpzAdNmORcNNer5ze0UEtymHT6le803m2nfj7HoB2w LfjQCy+hI7X6nScBxAGTL2Z4Fomxfptlta9iR0yJ9BC3mD+YobZNtCNVF9uBV9YHGVRd rLo16TzoLo4pr8mSWxnruF3oXq31oayTMkH9BUv/JUVXY7Tkf4qwo+iv5PdkW9+Wk6+h r00w== X-Gm-Message-State: AOAM531hqFdXkNn1oRPXDooWPU1iFBE5TqMcbajzv11gpywaL7FUNF56 naN8xnxvuNV64gU6kWlPRL90Tgh/pzw= X-Google-Smtp-Source: ABdhPJyt8LUwn9tEoJpwq4vKzZc4Y+bppMSq4DCh95VP8pukq8Ekd91gILIHFZpBAGeFPhRB8/i7tQ== X-Received: by 2002:a17:90b:fd3:: with SMTP id gd19mr20596322pjb.83.1593471306431; Mon, 29 Jun 2020 15:55:06 -0700 (PDT) Received: from localhost.localdomain (c-73-241-217-19.hsd1.ca.comcast.net. [73.241.217.19]) by smtp.gmail.com with ESMTPSA id mr8sm478379pjb.5.2020.06.29.15.55.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Jun 2020 15:55:05 -0700 (PDT) From: Bart Van Assche To: "Martin K . Petersen" , "James E . J . Bottomley" Cc: linux-scsi@vger.kernel.org, Bart Van Assche , Daniel Wagner , Nilesh Javali , Quinn Tran , Himanshu Madhani , Martin Wilck , Roman Bolshakov Subject: [PATCH v2 1/9] qla2xxx: Check the size of struct fcp_hdr at compile time Date: Mon, 29 Jun 2020 15:54:46 -0700 Message-Id: <20200629225454.22863-2-bvanassche@acm.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200629225454.22863-1-bvanassche@acm.org> References: <20200629225454.22863-1-bvanassche@acm.org> MIME-Version: 1.0 Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Since struct fcp_hdr is used to exchange data with the firmware, check its size at compile time. Reviewed-by: Daniel Wagner Cc: Nilesh Javali Cc: Quinn Tran Cc: Himanshu Madhani Cc: Martin Wilck Cc: Roman Bolshakov Signed-off-by: Bart Van Assche --- drivers/scsi/qla2xxx/tcm_qla2xxx.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/scsi/qla2xxx/tcm_qla2xxx.c b/drivers/scsi/qla2xxx/tcm_qla2xxx.c index 188aa5f02c01..f7e9b5bc0b26 100644 --- a/drivers/scsi/qla2xxx/tcm_qla2xxx.c +++ b/drivers/scsi/qla2xxx/tcm_qla2xxx.c @@ -1971,6 +1971,7 @@ static int __init tcm_qla2xxx_init(void) BUILD_BUG_ON(sizeof(struct ctio_crc2_to_fw) != 64); BUILD_BUG_ON(sizeof(struct ctio_crc_from_fw) != 64); BUILD_BUG_ON(sizeof(struct ctio_to_2xxx) != 64); + BUILD_BUG_ON(sizeof(struct fcp_hdr) != 24); BUILD_BUG_ON(sizeof(struct fcp_hdr_le) != 24); BUILD_BUG_ON(sizeof(struct nack_to_isp) != 64); From patchwork Mon Jun 29 22:54:48 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 213651 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.0 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3423EC433DF for ; Mon, 29 Jun 2020 22:55:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 19C4220702 for ; Mon, 29 Jun 2020 22:55:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728493AbgF2WzL (ORCPT ); Mon, 29 Jun 2020 18:55:11 -0400 Received: from mail-pl1-f194.google.com ([209.85.214.194]:35846 "EHLO mail-pl1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728467AbgF2WzK (ORCPT ); Mon, 29 Jun 2020 18:55:10 -0400 Received: by mail-pl1-f194.google.com with SMTP id j4so7677227plk.3 for ; Mon, 29 Jun 2020 15:55:09 -0700 (PDT) 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:mime-version:content-transfer-encoding; bh=HZ7cTZEpamxkssXb8i/G6iTr/lV89FSt/1GQloGQWP8=; b=kTgNIY+0+08Qk4A/11R6235fiB98CYt0aO4MkfGQwpkJajB/t3ZjslKJvWCfpsjDbG MZ65wdravZpNM5U5PuGL7RTfKxFnM8L9dhVnEBxqZkkiXt+aWoXmEYuNtScDH+tsk8Du z/uhQenHkABECFtNJciUbhpAvChJQI2jlBqISktJUtcHqxaEqDotlH9i2amXxRDAOyTM UidokMuptj1o2Dyp1xp9uCAOBGxruOlPaABjHs5TP0zPjroVl1wF7DbVi6l42NERvU3S UrWazmZYTs+y5z1zh9uAdY0uuNY16DQHHpWTtgiwCSvPVRJHEJ6tbFSprZqNpPQqHT2Q lMhA== X-Gm-Message-State: AOAM533d3w5xfZjTmM5CSk512jj9Sp2kB/9Yfy1P8AmUIxhxL3y4BJJS /N+WZj5w7D6WypLFf0jgB8E= X-Google-Smtp-Source: ABdhPJxyVp1sNRk9M+h+4gggPOTGcDEMbVZVQ2vIJTpe9bQgbkvJyypEbL/ZBD2PXPXDBFKMBqP2ZA== X-Received: by 2002:a17:90b:2350:: with SMTP id ms16mr11288250pjb.224.1593471309534; Mon, 29 Jun 2020 15:55:09 -0700 (PDT) Received: from localhost.localdomain (c-73-241-217-19.hsd1.ca.comcast.net. [73.241.217.19]) by smtp.gmail.com with ESMTPSA id mr8sm478379pjb.5.2020.06.29.15.55.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Jun 2020 15:55:08 -0700 (PDT) From: Bart Van Assche To: "Martin K . Petersen" , "James E . J . Bottomley" Cc: linux-scsi@vger.kernel.org, Bart Van Assche , Daniel Wagner , Nilesh Javali , Quinn Tran , Himanshu Madhani , Martin Wilck , Roman Bolshakov Subject: [PATCH v2 3/9] qla2xxx: Make qla82xx_flash_wait_write_finish() easier to read Date: Mon, 29 Jun 2020 15:54:48 -0700 Message-Id: <20200629225454.22863-4-bvanassche@acm.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200629225454.22863-1-bvanassche@acm.org> References: <20200629225454.22863-1-bvanassche@acm.org> MIME-Version: 1.0 Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Return early instead of having a single return statement at the end of this function. This patch fixes the following sparse warning: qla_nx.c:1018: qla82xx_flash_wait_write_finish() error: uninitialized symbol 'val'. Reviewed-by: Daniel Wagner Cc: Nilesh Javali Cc: Quinn Tran Cc: Himanshu Madhani Cc: Martin Wilck Cc: Roman Bolshakov Signed-off-by: Bart Van Assche --- drivers/scsi/qla2xxx/qla_nx.c | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/drivers/scsi/qla2xxx/qla_nx.c b/drivers/scsi/qla2xxx/qla_nx.c index 0baf55b7e88f..ff365b434a02 100644 --- a/drivers/scsi/qla2xxx/qla_nx.c +++ b/drivers/scsi/qla2xxx/qla_nx.c @@ -966,26 +966,21 @@ qla82xx_read_status_reg(struct qla_hw_data *ha, uint32_t *val) static int qla82xx_flash_wait_write_finish(struct qla_hw_data *ha) { - long timeout = 0; - uint32_t done = 1 ; uint32_t val; - int ret = 0; + int i, ret; scsi_qla_host_t *vha = pci_get_drvdata(ha->pdev); qla82xx_wr_32(ha, QLA82XX_ROMUSB_ROM_ABYTE_CNT, 0); - while ((done != 0) && (ret == 0)) { + for (i = 0; i < 50000; i++) { ret = qla82xx_read_status_reg(ha, &val); - done = val & 1; - timeout++; + if (ret < 0 || (val & 1) == 0) + return ret; udelay(10); cond_resched(); - if (timeout >= 50000) { - ql_log(ql_log_warn, vha, 0xb00d, - "Timeout reached waiting for write finish.\n"); - return -1; - } } - return ret; + ql_log(ql_log_warn, vha, 0xb00d, + "Timeout reached waiting for write finish.\n"); + return -1; } static int From patchwork Mon Jun 29 22:54:50 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 213650 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.0 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 78BCBC433E0 for ; Mon, 29 Jun 2020 22:55:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5A3B620702 for ; Mon, 29 Jun 2020 22:55:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728560AbgF2WzO (ORCPT ); Mon, 29 Jun 2020 18:55:14 -0400 Received: from mail-pj1-f68.google.com ([209.85.216.68]:33496 "EHLO mail-pj1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728557AbgF2WzN (ORCPT ); Mon, 29 Jun 2020 18:55:13 -0400 Received: by mail-pj1-f68.google.com with SMTP id gc15so1258288pjb.0 for ; Mon, 29 Jun 2020 15:55:13 -0700 (PDT) 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:mime-version:content-transfer-encoding; bh=JJfxNrKKcLvoNDjxOhPtlO9Z+XbDfNF+OP1B6dUZvjE=; b=AUJVF1pINgJObGhGU3h2n54SjI2IN+Z1FGBWa+rXMcNVt04HE/DZvCdwk/+FX7Kmwu RSAVJXtrkUOQG6eAVdJTisn0yxYdII1QIVY5XYXG3fcrZKvBOUFX92lr57ah9AHNFBID hbxRg6RyNDz1ZLImiQYUsh+NZOV+qJfcu9p7a4CNVpdkvV+/+XRsquhqov8HKLP7icNz fatlEJHxX+bbO0KSZAf7ad+o1qscdpP4Hn0Rhagw8NjgA3rlbBrzIvL3klVKtVqccdk7 OCzRDgQt/IZO829iaNxP1TCZYs/uQVtfykeJA/Pot8kcoBwgzEoiCjZYYIotxcZZMfzp 2aVA== X-Gm-Message-State: AOAM530WezIUkXMBl1ETrbJpCvdoy/4bBqp7lglGW/v3VWIpzSPGtcz1 Ncedl7Kzg3M3mwiqsEx6nbPLPU8ohlM= X-Google-Smtp-Source: ABdhPJxXz6QQbMaZxz2VXwWshOd+Ka5zriFWu+z6lAGTZLhmVr+jDnOTZ0ySpkiDNdQxGeqkWTFsmQ== X-Received: by 2002:a17:902:7204:: with SMTP id ba4mr14495971plb.250.1593471312710; Mon, 29 Jun 2020 15:55:12 -0700 (PDT) Received: from localhost.localdomain (c-73-241-217-19.hsd1.ca.comcast.net. [73.241.217.19]) by smtp.gmail.com with ESMTPSA id mr8sm478379pjb.5.2020.06.29.15.55.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Jun 2020 15:55:11 -0700 (PDT) From: Bart Van Assche To: "Martin K . Petersen" , "James E . J . Bottomley" Cc: linux-scsi@vger.kernel.org, Bart Van Assche , Daniel Wagner , Nilesh Javali , Quinn Tran , Himanshu Madhani , Martin Wilck , Roman Bolshakov Subject: [PATCH v2 5/9] qla2xxx: Remove a superfluous cast Date: Mon, 29 Jun 2020 15:54:50 -0700 Message-Id: <20200629225454.22863-6-bvanassche@acm.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200629225454.22863-1-bvanassche@acm.org> References: <20200629225454.22863-1-bvanassche@acm.org> MIME-Version: 1.0 Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Remove an unnecessary cast because it prevents the compiler to perform type checking. Reviewed-by: Daniel Wagner Cc: Nilesh Javali Cc: Quinn Tran Cc: Himanshu Madhani Cc: Martin Wilck Cc: Roman Bolshakov Signed-off-by: Bart Van Assche --- drivers/scsi/qla2xxx/qla_bsg.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/scsi/qla2xxx/qla_bsg.c b/drivers/scsi/qla2xxx/qla_bsg.c index 88c0338a2ec7..67efde1d4b8e 100644 --- a/drivers/scsi/qla2xxx/qla_bsg.c +++ b/drivers/scsi/qla2xxx/qla_bsg.c @@ -223,8 +223,7 @@ qla24xx_proc_fcp_prio_cfg_cmd(struct bsg_job *bsg_job) /* validate fcp priority data */ - if (!qla24xx_fcp_prio_cfg_valid(vha, - (struct qla_fcp_prio_cfg *) ha->fcp_prio_cfg, 1)) { + if (!qla24xx_fcp_prio_cfg_valid(vha, ha->fcp_prio_cfg, 1)) { bsg_reply->result = (DID_ERROR << 16); ret = -EINVAL; /* If buffer was invalidatic int From patchwork Mon Jun 29 22:54:52 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 213649 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.0 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7CA87C433E0 for ; Mon, 29 Jun 2020 22:55:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 61EB22063A for ; Mon, 29 Jun 2020 22:55:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728614AbgF2WzR (ORCPT ); Mon, 29 Jun 2020 18:55:17 -0400 Received: from mail-pf1-f196.google.com ([209.85.210.196]:40591 "EHLO mail-pf1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728557AbgF2WzR (ORCPT ); Mon, 29 Jun 2020 18:55:17 -0400 Received: by mail-pf1-f196.google.com with SMTP id u5so8534658pfn.7 for ; Mon, 29 Jun 2020 15:55:16 -0700 (PDT) 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:mime-version:content-transfer-encoding; bh=7xa6NFI+S11VWHfwvQSsdqPE2V3UYkuUqqGGNmptq44=; b=iXUXw0nv8+OO7DAFfEaREMsZfWewGWOdQXGNL8+v/EAk45WPQM3wILzvIRuBR1S7UR BJ1k18jewWRUJoI0rIGREjXoe+qHuqQ924G+/8JxK1FPf2cKByfQRYrzqgMJdF87Y4im wl5wlje8RtJeKMn9eYJP7BNU7RWkyTUIiPJhICy3jSNaxTFpMMheujcwLr8WWYTFS2ZT YAEW6O0zzgaDoGWLcJvLvpTADwxJfvE3trfii9O9XmmUOsnLrSYRHMhwiPG9WQiyR5f3 v3MLhUTBzsHVgRojCv/sSyvdwO5Qb0m0JmGWGi/LQu7tE2NNemx7cBxBGvK5rgGKBtcY j7kw== X-Gm-Message-State: AOAM531uBoWSfPaSwZZ83S+y3H7ttIyusJQwJCreWqAJhOFYJw5HYDTd xhFznc9g5AjCodt+ZjuSJUCwaGXyCDg= X-Google-Smtp-Source: ABdhPJzivQbT7mYtD71pZidu4L8m252lttzTO8nY97j0s44ZnhqmHFrtWIFZh4wGf1Ow2fTOaScFAg== X-Received: by 2002:a62:2743:: with SMTP id n64mr15950295pfn.163.1593471315831; Mon, 29 Jun 2020 15:55:15 -0700 (PDT) Received: from localhost.localdomain (c-73-241-217-19.hsd1.ca.comcast.net. [73.241.217.19]) by smtp.gmail.com with ESMTPSA id mr8sm478379pjb.5.2020.06.29.15.55.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Jun 2020 15:55:15 -0700 (PDT) From: Bart Van Assche To: "Martin K . Petersen" , "James E . J . Bottomley" Cc: linux-scsi@vger.kernel.org, Bart Van Assche , Daniel Wagner , Nilesh Javali , Quinn Tran , Himanshu Madhani , Martin Wilck , Roman Bolshakov Subject: [PATCH v2 7/9] qla2xxx: Fix a Coverity complaint in qla2100_fw_dump() Date: Mon, 29 Jun 2020 15:54:52 -0700 Message-Id: <20200629225454.22863-8-bvanassche@acm.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200629225454.22863-1-bvanassche@acm.org> References: <20200629225454.22863-1-bvanassche@acm.org> MIME-Version: 1.0 Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org 'cnt' can exceed the size of the risc_ram[] array. Prevent that Coverity complains by rewriting an address calculation expression. This patch fixes the following Coverity complaint: CID 337803 (#1 of 1): Out-of-bounds read (OVERRUN) 109. overrun-local: Overrunning array of 122880 bytes at byte offset 122880 by dereferencing pointer &fw->risc_ram[cnt]. Reviewed-by: Daniel Wagner Cc: Nilesh Javali Cc: Quinn Tran Cc: Himanshu Madhani Cc: Martin Wilck Cc: Roman Bolshakov Signed-off-by: Bart Van Assche --- drivers/scsi/qla2xxx/qla_dbg.c | 2 +- drivers/scsi/qla2xxx/qla_dbg.h | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/scsi/qla2xxx/qla_dbg.c b/drivers/scsi/qla2xxx/qla_dbg.c index 19005710f7f6..41493bd53fc0 100644 --- a/drivers/scsi/qla2xxx/qla_dbg.c +++ b/drivers/scsi/qla2xxx/qla_dbg.c @@ -1063,7 +1063,7 @@ qla2100_fw_dump(scsi_qla_host_t *vha) } if (rval == QLA_SUCCESS) - qla2xxx_copy_queues(ha, &fw->risc_ram[cnt]); + qla2xxx_copy_queues(ha, &fw->queue_dump[0]); qla2xxx_dump_post_process(base_vha, rval); } diff --git a/drivers/scsi/qla2xxx/qla_dbg.h b/drivers/scsi/qla2xxx/qla_dbg.h index 54ed020e6f75..91eb6901815c 100644 --- a/drivers/scsi/qla2xxx/qla_dbg.h +++ b/drivers/scsi/qla2xxx/qla_dbg.h @@ -53,6 +53,7 @@ struct qla2100_fw_dump { __be16 fpm_b0_reg[64]; __be16 fpm_b1_reg[64]; __be16 risc_ram[0xf000]; + u8 queue_dump[]; }; struct qla24xx_fw_dump { From patchwork Mon Jun 29 22:54:54 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 213648 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.0 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 108C8C433DF for ; Mon, 29 Jun 2020 22:55:21 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E9C1F2063A for ; Mon, 29 Jun 2020 22:55:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728638AbgF2WzU (ORCPT ); Mon, 29 Jun 2020 18:55:20 -0400 Received: from mail-pg1-f193.google.com ([209.85.215.193]:44605 "EHLO mail-pg1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728557AbgF2WzU (ORCPT ); Mon, 29 Jun 2020 18:55:20 -0400 Received: by mail-pg1-f193.google.com with SMTP id j19so2132927pgm.11 for ; Mon, 29 Jun 2020 15:55:19 -0700 (PDT) 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:mime-version:content-transfer-encoding; bh=sXoyxTA9nquAbHQWx0ETGGYQKA6A8CSQCoKl/HAnywk=; b=m4R4uttvm0sGG1N6kX908vRGH3JHgV4oqYCPk6vNtI7EfLs5Ayyi5AewQw5LCi2Nlu JgzSKc3sTNGZAavSPnaHT+zyR4jxnCNUB7Osvfhk85ia7me8Txsk6CXssX+jBLIir/S+ tlgHbqcwe4KhB4RNBzNb4oGyvUR3ZEy7k+PlzbSYML5vDU5QZNigxw8qJv7yevGAqWWF JQDG+2OhUlp0BYNm9p2db/N0jJcFnpo0+G1vvXH0DJUY5Fh5ZKgtIbUF+tQECvbwoPwm /8SbENFDe9Nr3JWFdjCnF+0dg+WwzAFvnoIUcEVE8avRAcxbdIouBGNWnGsvYprPElDS TXtA== X-Gm-Message-State: AOAM531Cz0GvWz3/Of58V3kzgYyJLtWWiGsOTChcLRQFWba8ml9NTyOQ mqDJAczFdZjUUZCXlxZ+ZWg= X-Google-Smtp-Source: ABdhPJzADcnlSqb2xN2XfLnqnNlGfkPPccToj/tAxEABpJfb7IVKSbsYoK0ksHubcf7jWgmF1pMNyg== X-Received: by 2002:a05:6a00:15ca:: with SMTP id o10mr16531571pfu.169.1593471318930; Mon, 29 Jun 2020 15:55:18 -0700 (PDT) Received: from localhost.localdomain (c-73-241-217-19.hsd1.ca.comcast.net. [73.241.217.19]) by smtp.gmail.com with ESMTPSA id mr8sm478379pjb.5.2020.06.29.15.55.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Jun 2020 15:55:18 -0700 (PDT) From: Bart Van Assche To: "Martin K . Petersen" , "James E . J . Bottomley" Cc: linux-scsi@vger.kernel.org, Bart Van Assche , Daniel Wagner , Nilesh Javali , Quinn Tran , Himanshu Madhani , Martin Wilck , Roman Bolshakov Subject: [PATCH v2 9/9] qla2xxx: Introduce a function for computing the debug message prefix Date: Mon, 29 Jun 2020 15:54:54 -0700 Message-Id: <20200629225454.22863-10-bvanassche@acm.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200629225454.22863-1-bvanassche@acm.org> References: <20200629225454.22863-1-bvanassche@acm.org> MIME-Version: 1.0 Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Instead of repeating the code for generating a debug message prefix six times, introduce a function for computing the debug message prefix. Reviewed-by: Daniel Wagner Cc: Nilesh Javali Cc: Quinn Tran Cc: Himanshu Madhani Cc: Martin Wilck Cc: Roman Bolshakov Signed-off-by: Bart Van Assche --- drivers/scsi/qla2xxx/qla_dbg.c | 96 ++++++++++++---------------------- 1 file changed, 32 insertions(+), 64 deletions(-) diff --git a/drivers/scsi/qla2xxx/qla_dbg.c b/drivers/scsi/qla2xxx/qla_dbg.c index 41493bd53fc0..911c7852e660 100644 --- a/drivers/scsi/qla2xxx/qla_dbg.c +++ b/drivers/scsi/qla2xxx/qla_dbg.c @@ -2447,6 +2447,23 @@ qla83xx_fw_dump(scsi_qla_host_t *vha) /* Driver Debug Functions. */ /****************************************************************************/ +/* Write the debug message prefix into @pbuf. */ +static void ql_dbg_prefix(char *pbuf, int pbuf_size, + const scsi_qla_host_t *vha, uint msg_id) +{ + if (vha) { + const struct pci_dev *pdev = vha->hw->pdev; + + /* []-:: */ + snprintf(pbuf, pbuf_size, "%s [%s]-%04x:%ld: ", QL_MSGHDR, + dev_name(&(pdev->dev)), msg_id, vha->host_no); + } else { + /* []-: : */ + snprintf(pbuf, pbuf_size, "%s [%s]-%04x: : ", QL_MSGHDR, + "0000:00:00.0", msg_id); + } +} + /* * This function is for formatting and logging debug information. * It is to be used when vha is available. It formats the message @@ -2465,41 +2482,19 @@ ql_dbg(uint level, scsi_qla_host_t *vha, uint id, const char *fmt, ...) { va_list va; struct va_format vaf; + char pbuf[64]; va_start(va, fmt); vaf.fmt = fmt; vaf.va = &va; - if (!ql_mask_match(level)) { - char pbuf[64]; + ql_dbg_prefix(pbuf, ARRAY_SIZE(pbuf), vha, id); - if (vha != NULL) { - const struct pci_dev *pdev = vha->hw->pdev; - /* : Message */ - snprintf(pbuf, sizeof(pbuf), "%s [%s]-%04x:%ld: ", - QL_MSGHDR, dev_name(&(pdev->dev)), id, - vha->host_no); - } else { - snprintf(pbuf, sizeof(pbuf), "%s [%s]-%04x: : ", - QL_MSGHDR, "0000:00:00.0", id); - } - pbuf[sizeof(pbuf) - 1] = 0; + if (!ql_mask_match(level)) trace_ql_dbg_log(pbuf, &vaf); - va_end(va); - return; - } - - if (vha != NULL) { - const struct pci_dev *pdev = vha->hw->pdev; - /* : Message */ - pr_warn("%s [%s]-%04x:%ld: %pV", - QL_MSGHDR, dev_name(&(pdev->dev)), id + ql_dbg_offset, - vha->host_no, &vaf); - } else { - pr_warn("%s [%s]-%04x: : %pV", - QL_MSGHDR, "0000:00:00.0", id + ql_dbg_offset, &vaf); - } + else + pr_warn("%s%pV", pbuf, &vaf); va_end(va); @@ -2524,6 +2519,7 @@ ql_dbg_pci(uint level, struct pci_dev *pdev, uint id, const char *fmt, ...) { va_list va; struct va_format vaf; + char pbuf[128]; if (pdev == NULL) return; @@ -2535,9 +2531,8 @@ ql_dbg_pci(uint level, struct pci_dev *pdev, uint id, const char *fmt, ...) vaf.fmt = fmt; vaf.va = &va; - /* : Message */ - pr_warn("%s [%s]-%04x: : %pV", - QL_MSGHDR, dev_name(&(pdev->dev)), id + ql_dbg_offset, &vaf); + ql_dbg_prefix(pbuf, ARRAY_SIZE(pbuf), NULL, id + ql_dbg_offset); + pr_warn("%s%pV", pbuf, &vaf); va_end(va); } @@ -2565,16 +2560,7 @@ ql_log(uint level, scsi_qla_host_t *vha, uint id, const char *fmt, ...) if (level > ql_errlev) return; - if (vha != NULL) { - const struct pci_dev *pdev = vha->hw->pdev; - /* : Message */ - snprintf(pbuf, sizeof(pbuf), "%s [%s]-%04x:%ld: ", - QL_MSGHDR, dev_name(&(pdev->dev)), id, vha->host_no); - } else { - snprintf(pbuf, sizeof(pbuf), "%s [%s]-%04x: : ", - QL_MSGHDR, "0000:00:00.0", id); - } - pbuf[sizeof(pbuf) - 1] = 0; + ql_dbg_prefix(pbuf, ARRAY_SIZE(pbuf), vha, id); va_start(va, fmt); @@ -2625,10 +2611,7 @@ ql_log_pci(uint level, struct pci_dev *pdev, uint id, const char *fmt, ...) if (level > ql_errlev) return; - /* : Message */ - snprintf(pbuf, sizeof(pbuf), "%s [%s]-%04x: : ", - QL_MSGHDR, dev_name(&(pdev->dev)), id); - pbuf[sizeof(pbuf) - 1] = 0; + ql_dbg_prefix(pbuf, ARRAY_SIZE(pbuf), NULL, id); va_start(va, fmt); @@ -2724,16 +2707,7 @@ ql_log_qp(uint32_t level, struct qla_qpair *qpair, int32_t id, if (level > ql_errlev) return; - if (qpair != NULL) { - const struct pci_dev *pdev = qpair->pdev; - /* : Message */ - snprintf(pbuf, sizeof(pbuf), "%s [%s]-%04x: ", - QL_MSGHDR, dev_name(&(pdev->dev)), id); - } else { - snprintf(pbuf, sizeof(pbuf), "%s [%s]-%04x: : ", - QL_MSGHDR, "0000:00:00.0", id); - } - pbuf[sizeof(pbuf) - 1] = 0; + ql_dbg_prefix(pbuf, ARRAY_SIZE(pbuf), qpair ? qpair->vha : NULL, id); va_start(va, fmt); @@ -2777,6 +2751,7 @@ ql_dbg_qp(uint32_t level, struct qla_qpair *qpair, int32_t id, { va_list va; struct va_format vaf; + char pbuf[128]; if (!ql_mask_match(level)) return; @@ -2786,16 +2761,9 @@ ql_dbg_qp(uint32_t level, struct qla_qpair *qpair, int32_t id, vaf.fmt = fmt; vaf.va = &va; - if (qpair != NULL) { - const struct pci_dev *pdev = qpair->pdev; - /* : Message */ - pr_warn("%s [%s]-%04x: %pV", - QL_MSGHDR, dev_name(&(pdev->dev)), id + ql_dbg_offset, - &vaf); - } else { - pr_warn("%s [%s]-%04x: : %pV", - QL_MSGHDR, "0000:00:00.0", id + ql_dbg_offset, &vaf); - } + ql_dbg_prefix(pbuf, ARRAY_SIZE(pbuf), qpair ? qpair->vha : NULL, + id + ql_dbg_offset); + pr_warn("%s%pV", pbuf, &vaf); va_end(va);